Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@
<!--
Analyzers
-->

<!--
Since the Microsoft.CodeAnalysis.Analyzers package is a public dependency of our NuGet
packages we will keep it untied to the RoslynDiagnosticsAnalyzersPackageVersion we use for
other analyzers to ensure it stays on a release version.
-->
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="$(MicrosoftCodeAnalysisAnalyzersVersion)" />

<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="$(MicrosoftCodeAnalysisNetAnalyzersVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="$(CodeStyleAnalyzerVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.CodeStyle" Version="$(CodeStyleAnalyzerVersion)" />
Expand Down
24 changes: 24 additions & 0 deletions eng/targets/Imports.targets
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,30 @@
<None Include="$(AppDesignerFolder)\launchSettings.json" Condition="Exists('$(AppDesignerFolder)\launchSettings.json')" />
</ItemGroup>

<ItemGroup Condition="'$(UseRoslynAnalyzersFromSource)' == 'true'
and '$(MSBuildProjectName)' != 'Microsoft.CodeAnalysis.Analyzers'
and '$(MSBuildProjectName)' != 'Microsoft.CodeAnalysis.CSharp.Analyzers'
and '$(MSBuildProjectName)' != 'Microsoft.CodeAnalysis.VisualBasic.Analyzers'">
<ProjectReference Include="$(RepoRoot)src\RoslynAnalyzers\Microsoft.CodeAnalysis.Analyzers\Core\Microsoft.CodeAnalysis.Analyzers.csproj"
ReferenceOutputAssembly="false"
OutputItemType="Analyzer"
PrivateAssets="all" />
<ProjectReference Include="$(RepoRoot)src\RoslynAnalyzers\Microsoft.CodeAnalysis.Analyzers\CSharp\Microsoft.CodeAnalysis.CSharp.Analyzers.csproj"
ReferenceOutputAssembly="false"
OutputItemType="Analyzer"
PrivateAssets="all" />
<ProjectReference Include="$(RepoRoot)src\RoslynAnalyzers\Microsoft.CodeAnalysis.Analyzers\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.Analyzers.vbproj"
ReferenceOutputAssembly="false"
OutputItemType="Analyzer"
PrivateAssets="all" />
</ItemGroup>

<ItemGroup Condition="'$(UseRoslynAnalyzersFromSource)' == 'true' and '$(IncludeRoslynAnalyzersPackageDependency)' == 'true' and '$(IsPackable)' == 'true' and '$(DotNetBuildSourceOnly)' != 'true'">
<!-- Preserve package dependency shape while analyzer assets come from source project references -->
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers"
ExcludeAssets="analyzers;build;buildTransitive" />
</ItemGroup>

<!--
Add ThirdPartyNotices.rtf to all shipping NuGet packages.
-->
Expand Down
2 changes: 2 additions & 0 deletions eng/targets/Settings.props
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
<NoWarn Condition="'$(DefineConstants.Contains(`CODE_STYLE`))' == 'false'">$(NoWarn);RS1041;RS1038</NoWarn>

<EnableNetAnalyzers>true</EnableNetAnalyzers>
<UseRoslynAnalyzersFromSource Condition="'$(UseRoslynAnalyzersFromSource)' == ''">false</UseRoslynAnalyzersFromSource>
<IncludeRoslynAnalyzersPackageDependency Condition="'$(IncludeRoslynAnalyzersPackageDependency)' == ''">false</IncludeRoslynAnalyzersPackageDependency>
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)TargetFrameworks.props" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@

<!-- Package used for symbol publishing. The assembly ships in analyzer packages Microsoft.CodeAnalysis.(CSharp|VisualBasic).CodeStyle -->
<IsSymbolPublishingPackage>true</IsSymbolPublishingPackage>
<UseRoslynAnalyzersFromSource>true</UseRoslynAnalyzersFromSource>
<IncludeRoslynAnalyzersPackageDependency>true</IncludeRoslynAnalyzersPackageDependency>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
<PackageReference Include="System.Threading.Tasks.Extensions" />
<PackageReference Include="System.Threading.Channels" />
Expand Down Expand Up @@ -50,4 +51,4 @@
<Import Project="..\..\..\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems" Label="Shared" />
<Import Project="..\..\..\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Microsoft.CodeAnalysis.Extensions.projitems" Label="Shared" />
<Import Project="..\..\..\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.projitems" Label="Shared" />
</Project>
</Project>
10 changes: 2 additions & 8 deletions src/Compilers/Core/Portable/Microsoft.CodeAnalysis.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<!-- NuGet -->
<IsPackable>true</IsPackable>
<PackageId>Microsoft.CodeAnalysis.Common</PackageId>
<UseRoslynAnalyzersFromSource>true</UseRoslynAnalyzersFromSource>
<IncludeRoslynAnalyzersPackageDependency>true</IncludeRoslynAnalyzersPackageDependency>
<PackageDescription>
A shared package used by the Microsoft .NET Compiler Platform ("Roslyn").
Do not install this package manually, it will be added as a prerequisite by other packages that require it.
Expand All @@ -27,14 +29,6 @@
<None Include="Operations\OperationInterfaces.xml" />
</ItemGroup>
<ItemGroup>
<!--
Analyzers that will be used to analyze projects that references
Microsoft.CodeAnalysis project or Microsoft.CodeAnalysis.Common package.

Note: PrivateAssets="ContentFiles" ensures that projects referencing Microsoft.CodeAnalysis.Common package
will import everything but content files from Microsoft.CodeAnalysis.Analyzers, specifically, analyzers.
-->
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Condition="'$(DotNetBuildSourceOnly)' != 'true'" PrivateAssets="ContentFiles" />
<PackageReference Include="System.Collections.Immutable" />
<PackageReference Include="System.Memory" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
<PackageReference Include="System.Reflection.Metadata" />
Expand Down
6 changes: 6 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
<PropertyGroup>
<UseRoslynAnalyzersFromSource Condition="'$(DotNetBuildSourceOnly)' != 'true'">true</UseRoslynAnalyzersFromSource>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
<RuntimeIdentifiers>$(RoslynPortableRuntimeIdentifiers)</RuntimeIdentifiers>
<IsShipping>false</IsShipping>
<ExcludeFromSourceOnlyBuild>false</ExcludeFromSourceOnlyBuild>
<UseRoslynAnalyzersFromSource>true</UseRoslynAnalyzersFromSource>
</PropertyGroup>
<ItemGroup>
<!-- Make sure to reference the same version of Microsoft.CodeAnalysis.Analyzers as the rest of the build -->
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" PrivateAssets="all" />
<!-- Pin SCI and SRM to 8.0, since this generator is built & consumed in our pipeline so it has to work with stock compiler in msbuild (currently shipped with 8.0) -->
<PackageReference Include="System.Collections.Immutable" VersionOverride="8.0.0" />
<PackageReference Include="System.Reflection.Metadata" VersionOverride="8.0.0" />
Expand All @@ -27,4 +26,4 @@

<PackageReference Include="Microsoft.CodeAnalysis.Common" PrivateAssets="all" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
</ItemGroup>
</Project>
</Project>
Loading