Re-enable CoreLib analyzers (#424)
authorViktor Hofer <viktor.hofer@microsoft.com>
Mon, 2 Dec 2019 17:13:28 +0000 (18:13 +0100)
committerGitHub <noreply@github.com>
Mon, 2 Dec 2019 17:13:28 +0000 (18:13 +0100)
* Re-enable CoreLib analyzers

CoreLib analyzers were unintentionally disabled with
6afe96cc2e950379d13a87efa1fa5a651cbce9bd. This re-enables the analyzers.

* Remove Microsoft.CodeAnalysis.Common from common

Microsoft.CodeAnalysis.Common shouldn't be referenced directly,
therefore removing that package from the common location and only
restoring and marking it as an analyzer in the libraries restore phase.

eng/Analyzers.props
src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj
src/libraries/restore/analyzers/analyzers.depproj

index 24d83dc..e2163a7 100644 (file)
@@ -3,9 +3,8 @@
     <CodeAnalysisRuleset>$(MSBuildThisFileDirectory)CodeAnalysis.ruleset</CodeAnalysisRuleset>
   </PropertyGroup>
   <ItemGroup Condition="'$(EnableAnalyzers)' == 'true'">
-    <PackageReference Include="Microsoft.DotNet.CodeAnalysis" Version="$(MicrosoftDotNetCodeAnalysisVersion)" />
-    <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="3.4.0-beta2-final" />
-    <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.6" />
-    <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.66" />
+    <PackageReference Include="Microsoft.DotNet.CodeAnalysis" Version="$(MicrosoftDotNetCodeAnalysisVersion)" PrivateAssets="all" IsImplicitlyDefined="true" />
+    <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.6" PrivateAssets="all" />
+    <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.66" PrivateAssets="all" />
   </ItemGroup>
 </Project>
index 307f884..58b4d5f 100644 (file)
@@ -63,7 +63,7 @@
     <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)/Documentation</_FullFrameworkReferenceAssemblyPaths>
     <SkipCommonResourcesIncludes>true</SkipCommonResourcesIncludes>
     <DocumentationFile>$(OutputPath)$(MSBuildProjectName).xml</DocumentationFile>
-    <EnableAnalyzers>false</EnableAnalyzers>
+    <EnableAnalyzers>true</EnableAnalyzers>
   </PropertyGroup>
 
   <!-- Platform specific properties -->
index 75547d7..93e179e 100644 (file)
@@ -5,6 +5,14 @@
     <Language>C#</Language>
   </PropertyGroup>
 
+  <ItemGroup>
+    <!-- 
+      Microsoft.CodeAnalysis.Common shouldn't be referenced directly but is needed by the analyzer depproj restore.
+      TODO: Remove when project restore is enabled for non test projects: https://github.com/dotnet/corefx/issues/41512.
+    -->
+    <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="3.4.0-beta2-final" PrivateAssets="all" />
+  </ItemGroup>
+
   <UsingTask TaskName="Microsoft.DotNet.Arcade.Sdk.SaveItems" AssemblyFile="$(ArcadeSdkBuildTasksAssembly)" />
 
   <Target Name="GenerateAnalyzersPropsFile"