Skip to content

Commit 127dd35

Browse files
enable pre-built detection (#6610)
* Enable pre-built detection - Move various Microsoft.CodeAnalysis version numbers into Versions.props (some were already this way. but made this more complete. - Remove MicrosoftCodeAnalysisVersion from eng/Versions.props, forcing each project that references it to specify which of the various MicrosoftCodeAnalysis*Versions they actually want. This will do two things: - Source build will build against the same surface area as Microsoft's build, except in cases where projects must be executed at build time (only the case for internal tooling). This was the not the case before, because some projects used the default MicrosoftCodeAnalysisVersion, which would have been overridden. - Remove the need for the current RA source build patch
1 parent 2f6e15a commit 127dd35

File tree

49 files changed

+176
-50
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+176
-50
lines changed

Directory.Build.props

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@
4545
<NoWarn Condition="'$(Language)' == 'C#'">$(NoWarn),1573,1591,1712</NoWarn>
4646
</PropertyGroup>
4747

48+
<PropertyGroup Condition="'$(DotNetBuildFromSource)' == 'true'">
49+
<!-- When building in source build mode, treat this set of warnings not as errors.-->
50+
<!-- Some crefs reference internal APIs not present in the reference package. -->
51+
<NoWarn>$(NoWarn);CS1574;CS8602</NoWarn>
52+
</PropertyGroup>
53+
4854
<PropertyGroup>
4955
<!-- We generate per-project assembly attributes files, so we can safely delete them when cleaning the project -->
5056
<TargetFrameworkMonikerAssemblyAttributesFileClean>true</TargetFrameworkMonikerAssemblyAttributesFileClean>

NuGet.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<add key="dotnet5" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json" />
77
<add key="dotnet7" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json" />
88
<add key="dotnet8" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json" />
9+
<add key="dotnet8-transport" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8-transport/nuget/v3/index.json" />
910
<add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" />
1011
<add key="dotnet-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" />
1112
<add key="dotnet-public" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" />

eng/SourceBuildPrebuiltBaseline.xml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1+
<!-- See aka.ms/dotnet/prebuilts for guidance on what pre-builts are and how to eliminate them. -->
12
<UsageData>
23
<IgnorePatterns>
3-
<UsagePattern IdentityGlob="*/*" />
4+
<UsagePattern IdentityGlob="Microsoft.SourceBuild.Intermediate.*" />
5+
6+
<!-- This packages contain functionality that is executed in the build -->
7+
<UsagePattern IdentityGlob="Microsoft.Net.Compilers.Toolset/*" />
8+
<UsagePattern IdentityGlob="System.Composition*/*" />
9+
10+
<!-- This is the version of Microsoft.CodeAnalysis used for tooling executed in repo source-build,
11+
as well as unit tests. -->
12+
<UsagePattern IdentityGlob="Microsoft.CodeAnalysis*/*4.6.0-1.final*" />
13+
<!-- Dependency of Microsoft.CodeAnalysis.Common 4.6.0-1.final -->
14+
<UsagePattern IdentityGlob="Microsoft.CodeAnalysis.Analyzers/*3.3.4*" />
415
</IgnorePatterns>
5-
</UsageData>
16+
</UsageData>

eng/Version.Details.xml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,39 @@
55
<Uri>https://github.com/dotnet/roslyn</Uri>
66
<Sha>66a912c9463eebe832cf742d2fe8bb2e1a4600ec</Sha>
77
</Dependency>
8+
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="8.0.0-alpha.1.23305.4">
9+
<Uri>https://github.com/dotnet/source-build-reference-packages</Uri>
10+
<Sha>540ccf1a6831993d8ac8bf10bdfd3fde93ecee2e</Sha>
11+
<SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" />
12+
</Dependency>
13+
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-externals" Version="8.0.0-alpha.1.23214.1">
14+
<Uri>https://github.com/dotnet/source-build-externals</Uri>
15+
<Sha>de4dda48d0cf31e13182bc24107b2246c61ed483</Sha>
16+
<SourceBuild RepoName="source-build-externals" ManagedOnly="true" />
17+
</Dependency>
818
</ProductDependencies>
919
<ToolsetDependencies>
1020
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.23269.1">
1121
<Uri>https://github.com/dotnet/arcade</Uri>
1222
<Sha>fb6291b40fa4334dbd167e2071953e83cc8b9fdc</Sha>
1323
<SourceBuild RepoName="arcade" ManagedOnly="true" />
1424
</Dependency>
15-
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.5.0">
16-
<Uri>https://github.com/dotnet/roslyn</Uri>
17-
<Sha>6a5a63bbc9f4449d9bd1e95a8f9624939c3ccdc3</Sha>
25+
<!-- Used in repo tooling. Not updated automatically -->
26+
<Dependency Name="System.Composition" Version="8.0.0-preview.4.23259.5">
27+
<Uri>https://github.com/dotnet/runtime</Uri>
28+
<Sha>84a3d0e37e8f22b0b55f8bf932cb788b2bdd728f</Sha>
1829
</Dependency>
19-
<Dependency Name="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="4.5.0">
20-
<Uri>https://github.com/dotnet/roslyn</Uri>
21-
<Sha>6a5a63bbc9f4449d9bd1e95a8f9624939c3ccdc3</Sha>
30+
<Dependency Name="Microsoft.SourceLink.GitHub" Version="8.0.0-beta.23252.2" CoherentParentDependency="Microsoft.DotNet.Arcade.Sdk">
31+
<Uri>https://github.com/dotnet/sourcelink</Uri>
32+
<Sha>54eb3b811c57f5e94617d31a102fc9cb664ccdd5</Sha>
33+
<SourceBuild RepoName="sourcelink" ManagedOnly="true" />
2234
</Dependency>
23-
<Dependency Name="Microsoft.CodeAnalysis.VisualBasic.CodeStyle" Version="4.5.0">
35+
<Dependency Name="Microsoft.DotNet.XliffTasks" Version="1.0.0-beta.23266.1" CoherentParentDependency="Microsoft.DotNet.Arcade.Sdk">
36+
<Uri>https://github.com/dotnet/xliff-tasks</Uri>
37+
<Sha>9e7fbcab4e5275f63c0cd37553ba426de9194309</Sha>
38+
<SourceBuild RepoName="xliff-tasks" ManagedOnly="true" />
39+
</Dependency>
40+
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.5.0">
2441
<Uri>https://github.com/dotnet/roslyn</Uri>
2542
<Sha>6a5a63bbc9f4449d9bd1e95a8f9624939c3ccdc3</Sha>
2643
</Dependency>

eng/Versions.props

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
11
<Project>
22
<Import Project="$(SourceBuildPackageVersionPropsPath)" Condition="'$(SourceBuildPackageVersionPropsPath)' != ''" />
3-
<PropertyGroup>
4-
<!--
5-
Binaries that need to be executable during source build are restricted to versions available within source build.
6-
This section defines executable versions of packages which are referenced via lower-version reference assemblies
7-
during the build.
8-
-->
9-
<SystemCollectionsImmutableExecutableVersion>$(SystemCollectionsImmutableVersion)</SystemCollectionsImmutableExecutableVersion>
10-
<SystemCollectionsImmutableExecutableVersion Condition="'$(SystemCollectionsImmutableExecutableVersion)' == ''">5.0.0</SystemCollectionsImmutableExecutableVersion>
11-
<SystemReflectionMetadataExecutableVersion>$(SystemReflectionMetadataVersion)</SystemReflectionMetadataExecutableVersion>
12-
<SystemReflectionMetadataExecutableVersion Condition="'$(SystemReflectionMetadataExecutableVersion)' == ''">5.0.0</SystemReflectionMetadataExecutableVersion>
13-
<MicrosoftCodeAnalysisExecutableVersion>$(MicrosoftCodeAnalysisVersion)</MicrosoftCodeAnalysisExecutableVersion>
14-
<MicrosoftCodeAnalysisExecutableVersion Condition="'$(MicrosoftCodeAnalysisExecutableVersion)' == ''">3.8.0</MicrosoftCodeAnalysisExecutableVersion>
15-
</PropertyGroup>
163
<PropertyGroup>
174
<VersionPrefix>3.3.5</VersionPrefix>
185
<PreReleaseVersionLabel>beta1</PreReleaseVersionLabel>
@@ -40,12 +27,57 @@
4027
<UsingToolMicrosoftNetCompilers>true</UsingToolMicrosoftNetCompilers>
4128
<!-- Dependencies from https://github.com/dotnet/roslyn -->
4229
<MicrosoftNetCompilersToolsetVersion>4.5.0</MicrosoftNetCompilersToolsetVersion>
43-
<MicrosoftCodeAnalysisCSharpCodeStyleVersion>4.5.0</MicrosoftCodeAnalysisCSharpCodeStyleVersion>
44-
<MicrosoftCodeAnalysisVisualBasicCodeStyleVersion>4.5.0</MicrosoftCodeAnalysisVisualBasicCodeStyleVersion>
45-
<!-- Roslyn -->
46-
<MicrosoftCodeAnalysisVersion>3.3.1</MicrosoftCodeAnalysisVersion>
30+
<!-- Microsoft.CodeAnalysis.* versions. Read this!
31+
This repo uses a wide variety of M.CA.* package versions. This is an atypical pattern in
32+
.NET's repositories but a necessary one for roslyn-analyzers.
33+
34+
Some facts:
35+
- These versions are chosen on purpose.
36+
- They often represent the base required surface area of Microsoft.CA to support for a given feature or analyzer.
37+
This means that the analyzer would be supported in the widest array of C# compilation scenarios.
38+
- Most of these dependencies only represent target surface area. In some cases, the M.CA libraries are
39+
redistributed (tools) or used within the build.
40+
- Some of these versions are used for testing to ensure that analyzers built against older surface area
41+
still work against new implementations.
42+
- Linux source-build only builds a single implementation of M.CA.*.
43+
- Linux source-build does have some ability to provide surface area packages via the source-build-reference-packages repo.
44+
However, because these reference packages do not provide implementations, they cannot be used in any case
45+
where the package contents would be redisted or executed. An SBRP may not be created for a version that is used both
46+
as a reference assembly and redisted.
47+
48+
In this repo, the MicrosoftCodeAnalysis property should **not** be set globally in this file. Instead, it should
49+
be set for each project, based on the properties below. When the project is executable, it should be
50+
set only for non-source build or repo-source build. Product source build will set an incoming MicrosoftCodeAnalysis property
51+
that will denote the available implementation version.
52+
53+
Example of surface area usage:
54+
55+
<MicrosoftCodeAnalysisVersion>$(MicrosoftCodeAnalysisVersionForPerfSensitiveAnalyzers)</MicrosoftCodeAnalysisVersion>
56+
57+
Example of executable usage:
58+
59+
<MicrosoftCodeAnalysisVersion Condition="'$(DotNetBuildFromSource)' != 'true' or '$(DotNetBuildFromSourceFlavor)' != 'Product'">$(MicrosoftCodeAnalysisVersionForExecution)</MicrosoftCodeAnalysisVersion>
60+
-->
61+
<!-- Microsoft.CodeAnalysis versions for different purposes. -->
62+
<!-- Surface area that various projects compile against. These should have source-build reference packages -->
4763
<MicrosoftCodeAnalysisForRoslynDiagnosticsAnalyzersVersion>3.7.0</MicrosoftCodeAnalysisForRoslynDiagnosticsAnalyzersVersion>
64+
<MicrosoftCodeAnalysisVersionForPublicApiAnalyzers>1.2.1</MicrosoftCodeAnalysisVersionForPublicApiAnalyzers>
65+
<MicrosoftCodeAnalysisVersionForBannedApiAnalyzers>2.9.0</MicrosoftCodeAnalysisVersionForBannedApiAnalyzers>
66+
<MicrosoftCodeAnalysisVersionForBannedApiAnalyzersTests>3.3.1</MicrosoftCodeAnalysisVersionForBannedApiAnalyzersTests>
67+
<MicrosoftCodeAnalysisVersionForPerfSensitiveAnalyzers>2.9.0</MicrosoftCodeAnalysisVersionForPerfSensitiveAnalyzers>
68+
<MicrosoftCodeAnalysisVersionForPerfSensitiveAnalyzersTests>3.3.1</MicrosoftCodeAnalysisVersionForPerfSensitiveAnalyzersTests>
69+
<MicrosoftCodeAnalysisVersionForResxSourceGenerators>4.0.1</MicrosoftCodeAnalysisVersionForResxSourceGenerators>
70+
<MicrosoftCodeAnalysisVersionForNetAnalyzers>3.3.1</MicrosoftCodeAnalysisVersionForNetAnalyzers>
71+
<MicrosoftCodeAnalysisVersionForTextAnalyzers>3.3.1</MicrosoftCodeAnalysisVersionForTextAnalyzers>
72+
<MicrosoftCodeAnalysisVersionForCodeAnalysisAnalyzers>3.3.1</MicrosoftCodeAnalysisVersionForCodeAnalysisAnalyzers>
73+
<MicrosoftCodeAnalysisVersionForToolsAndUtilities>3.3.1</MicrosoftCodeAnalysisVersionForToolsAndUtilities>
74+
<!-- Versions for tests and general utility execution. -->
75+
<!-- This version is for utility and executable assemblies. The version here should not overlap with any of the surface
76+
area versions. -->
4877
<MicrosoftCodeAnalysisVersionForTests>4.6.0-1.final</MicrosoftCodeAnalysisVersionForTests>
78+
<MicrosoftCodeAnalysisVersionForExecution>4.6.0-1.final</MicrosoftCodeAnalysisVersionForExecution>
79+
<MicrosoftCodeAnalysisCSharpCodeStyleVersion>4.5.0</MicrosoftCodeAnalysisCSharpCodeStyleVersion>
80+
<MicrosoftCodeAnalysisVisualBasicCodeStyleVersion>4.5.0</MicrosoftCodeAnalysisVisualBasicCodeStyleVersion>
4981
<DogfoodAnalyzersVersion>3.3.4</DogfoodAnalyzersVersion>
5082
<DogfoodNetAnalyzersVersion>8.0.0-preview1.22621.6</DogfoodNetAnalyzersVersion>
5183
<MicrosoftCodeAnalysisBannedApiAnalyzersVersion>$(DogfoodAnalyzersVersion)</MicrosoftCodeAnalysisBannedApiAnalyzersVersion>
@@ -59,7 +91,7 @@
5991
<MicrosoftCodeAnalysisTestingVersion>1.1.2-beta1.23205.1</MicrosoftCodeAnalysisTestingVersion>
6092
<!-- Libs -->
6193
<BenchmarkDotNetVersion>0.13.0</BenchmarkDotNetVersion>
62-
<HumanizerVersion>2.2.0</HumanizerVersion>
94+
<HumanizerVersion>2.14.1</HumanizerVersion>
6395
<MicrosoftBuildLocatorVersion>1.4.1</MicrosoftBuildLocatorVersion>
6496
<MicrosoftDiagnosticsTracingTraceEventVersion>2.0.69</MicrosoftDiagnosticsTracingTraceEventVersion>
6597
<MicrosoftExtensionsLoggingVersion>6.0.0-preview.5.21301.5</MicrosoftExtensionsLoggingVersion>
@@ -72,6 +104,7 @@
72104
<SystemCommandLineRenderingVersion>2.0.0-beta1.20074.1</SystemCommandLineRenderingVersion>
73105
<SystemCommandLineVersion>2.0.0-beta1.21216.1</SystemCommandLineVersion>
74106
<SystemComponentModelCompositionVersion>4.7.0</SystemComponentModelCompositionVersion>
107+
<SystemCompositionVersion>8.0.0-preview.4.23259.5</SystemCompositionVersion>
75108
<SystemDirectoryServicesVersion>4.7.0</SystemDirectoryServicesVersion>
76109
<XunitCombinatorialVersion>1.2.7</XunitCombinatorialVersion>
77110
<SystemMemoryVersion>4.5.5</SystemMemoryVersion>

src/Directory.Build.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
</None>
3434
</ItemGroup>
3535

36-
<ItemGroup>
36+
<ItemGroup Condition="'$(DotNetBuildFromSource)' != 'true'">
3737
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="$(MicrosoftCodeAnalysisBannedApiAnalyzersVersion)" />
3838
<AdditionalFiles Include="$(MSBuildThisFileDirectory)\BannedSymbols.txt" Condition="'$(BannedSymbolsOptOut)' != 'true'" />
3939
</ItemGroup>

src/Microsoft.CodeAnalysis.AnalyzerUtilities/Microsoft.CodeAnalysis.AnalyzerUtilities.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
<!-- RS0026: Avoid public API overloads with differences in optional parameters -->
1616
<NoWarn>$(NoWarn);RS0026</NoWarn>
17+
<MicrosoftCodeAnalysisVersion>$(MicrosoftCodeAnalysisVersionForCodeAnalysisAnalyzers)</MicrosoftCodeAnalysisVersion>
1718
</PropertyGroup>
1819
<Import Project="..\Utilities\Compiler\Analyzer.Utilities.projitems" Label="Shared" />
1920
<Import Project="..\Utilities\FlowAnalysis\FlowAnalysis.Utilities.projitems" Label="Shared" />

src/Microsoft.CodeAnalysis.Analyzers/CSharp/Microsoft.CodeAnalysis.CSharp.Analyzers.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
5+
<MicrosoftCodeAnalysisVersion>$(MicrosoftCodeAnalysisVersionForCodeAnalysisAnalyzers)</MicrosoftCodeAnalysisVersion>
56
</PropertyGroup>
67
<ItemGroup>
78
<ProjectReference Include="..\Core\Microsoft.CodeAnalysis.Analyzers.csproj" />

src/Microsoft.CodeAnalysis.Analyzers/Core/Microsoft.CodeAnalysis.Analyzers.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
Restore would conclude that there is a cyclic dependency between Microsoft.CodeAnalysis and Microsoft.CodeAnalysis.Analyzers.
99
-->
1010
<PackageId>*$(MSBuildProjectFile)*</PackageId>
11+
<MicrosoftCodeAnalysisVersion>$(MicrosoftCodeAnalysisVersionForCodeAnalysisAnalyzers)</MicrosoftCodeAnalysisVersion>
1112
</PropertyGroup>
1213
<ItemGroup>
1314
<Compile Include="..\..\Microsoft.CodeAnalysis.BannedApiAnalyzers\Core\DocumentationCommentIdParser.cs" Link="DocumentationCommentIdParser.cs" />

src/Microsoft.CodeAnalysis.Analyzers/UnitTests/Microsoft.CodeAnalysis.Analyzers.UnitTests.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
<PropertyGroup>
44
<TargetFramework>$(NetCurrent)</TargetFramework>
55
<ServerGarbageCollection>true</ServerGarbageCollection>
6+
<!-- Executable code, so set this in non-source build or repo source-build. Full
7+
source build will use the incoming, pre-set MicrosoftCodeAnalysisVersion. -->
8+
<MicrosoftCodeAnalysisVersion Condition="'$(DotNetBuildFromSource)' != 'true' or '$(DotNetBuildFromSourceFlavor)' != 'Product'">$(MicrosoftCodeAnalysisVersionForTests)</MicrosoftCodeAnalysisVersion>
69
</PropertyGroup>
710
<ItemGroup>
8-
<PackageReference Include="Microsoft.CodeAnalysis" Version="$(MicrosoftCodeAnalysisVersionForTests)" />
11+
<PackageReference Include="Microsoft.CodeAnalysis" Version="$(MicrosoftCodeAnalysisVersion)" />
912
</ItemGroup>
1013
<ItemGroup>
1114
<ProjectReference Include="..\..\Test.Utilities\Test.Utilities.csproj" />

0 commit comments

Comments
 (0)