From 53b74e75510a2593f407b4d8543f8921071286fb Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Tue, 19 Oct 2021 11:51:47 -0500 Subject: [PATCH] Eliminate pre-built assets during source-build for roslyn-analyzers This is taking the approach used in previous versions of source-build: update the dependency versions of Microsoft.CodeAnalysis to the version currently being built by source-build. This is a short-term solution to get unblocked in the 6.0.0 timeframe. In the future, the previous Microsoft.CodeAnalysis versions will be available in SBRP. Contributes to https://github.com/dotnet/source-build/issues/2420 Contributes to https://github.com/dotnet/source-build/issues/2527 --- .../content/repos/roslyn-analyzers.proj | 6 +- ...ilt-assets-during-source-build-for-r.patch | 211 ++++++++++++++++++ 2 files changed, 212 insertions(+), 5 deletions(-) create mode 100644 src/SourceBuild/tarball/patches/roslyn-analyzers/0001-Eliminate-pre-built-assets-during-source-build-for-r.patch diff --git a/src/SourceBuild/tarball/content/repos/roslyn-analyzers.proj b/src/SourceBuild/tarball/content/repos/roslyn-analyzers.proj index 3c7dc4453..3d7882a5b 100644 --- a/src/SourceBuild/tarball/content/repos/roslyn-analyzers.proj +++ b/src/SourceBuild/tarball/content/repos/roslyn-analyzers.proj @@ -2,12 +2,8 @@ - - $(StandardSourceBuildArgs.Replace('/p:DotNetPackageVersionPropsPath="$(PackageVersionPropsPath)"', '')) + $(StandardSourceBuildArgs) $(BuildCommandArgs) $(FlagParameterPrefix)warnAsError $(ArcadeFalseBoolBuildArg) - $(BuildCommandArgs) /p:SourceBuildPackageVersionPropsPath="$(PackageVersionPropsPath)" $(StandardSourceBuildCommand) $(BuildCommandArgs) false diff --git a/src/SourceBuild/tarball/patches/roslyn-analyzers/0001-Eliminate-pre-built-assets-during-source-build-for-r.patch b/src/SourceBuild/tarball/patches/roslyn-analyzers/0001-Eliminate-pre-built-assets-during-source-build-for-r.patch new file mode 100644 index 000000000..953624bfd --- /dev/null +++ b/src/SourceBuild/tarball/patches/roslyn-analyzers/0001-Eliminate-pre-built-assets-during-source-build-for-r.patch @@ -0,0 +1,211 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Eric Erhardt +Date: Tue, 19 Oct 2021 11:12:25 -0500 +Subject: [PATCH] Eliminate pre-built assets during source-build for + roslyn-analyzers + +This is taking the approach used in previous versions of source-build: update the dependency versions of Microsoft.CodeAnalysis to the version currently being built by source-build. This is a short-term solution to get unblocked in the 6.0.0 timeframe. In the future, the previous Microsoft.CodeAnalysis versions will be available in SBRP. + +* Remove SourceBuildPackageVersionPropsPath at the top of Versions.props. The PVP from source-build will be imported after the repo's Versions.props +* Workaround a naming collison with DocumentBasedFixAllProvider. The latest Roslyn has a class with the same name. +* Remove hard-coded versions to Microsoft.CodeAnalysis in ResxSourceGenerator, Roslyn.Diagnostics.Analyzers, and GenerateDocumentationAndConfigFiles, so the latest gets picked up. +* Exclude ReleaseNotesUtil from source-build since it brings in the 3.1 app host. This tool shouldn't be needed during source-build. +* Disable BannedApiAnalyzers when in source-build. Other previously built code analysis packages are disabled already. + +Contributes to https://github.com/dotnet/source-build/issues/2420 +Contributes to https://github.com/dotnet/source-build/issues/2527 +--- + eng/Versions.props | 14 -------------- + src/Directory.Build.targets | 5 +++-- + .../Core/MetaAnalyzers/Fixers/PreferIsKindFix.cs | 2 +- + ....CodeAnalysis.ResxSourceGenerator.CSharp.csproj | 1 - + ...Analysis.ResxSourceGenerator.VisualBasic.csproj | 1 - + ...crosoft.CodeAnalysis.ResxSourceGenerator.csproj | 1 - + .../DoNotDirectlyAwaitATask.Fixer.cs | 2 +- + .../Roslyn.Diagnostics.CSharp.Analyzers.csproj | 2 +- + .../Core/Roslyn.Diagnostics.Analyzers.csproj | 1 - + ...Roslyn.Diagnostics.VisualBasic.Analyzers.vbproj | 2 +- + .../GenerateDocumentationAndConfigFiles.csproj | 1 - + ...umentationAndConfigFilesForBrokenRuntime.csproj | 4 +--- + src/Tools/ReleaseNotesUtil/ReleaseNotesUtil.csproj | 1 + + 13 files changed, 9 insertions(+), 28 deletions(-) + +diff --git a/eng/Versions.props b/eng/Versions.props +index 46d30b3bd..635f8bb5c 100644 +--- a/eng/Versions.props ++++ b/eng/Versions.props +@@ -1,18 +1,4 @@ + +- +- +- +- $(SystemCollectionsImmutableVersion) +- 5.0.0 +- $(SystemReflectionMetadataVersion) +- 5.0.0 +- $(MicrosoftCodeAnalysisVersion) +- 3.8.0 +- + + 3.3.3 + beta1 +diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets +index c7c28fd9f..e5be9e028 100644 +--- a/src/Directory.Build.targets ++++ b/src/Directory.Build.targets +@@ -35,8 +35,9 @@ + AnalyzerReleases\$(AssemblyName)\AnalyzerReleases.Shipped.md + + +- +- ++ ++ ++ + + + +diff --git a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/Fixers/PreferIsKindFix.cs b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/Fixers/PreferIsKindFix.cs +index 7a6877e0e..a0cbd06e7 100644 +--- a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/Fixers/PreferIsKindFix.cs ++++ b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/Fixers/PreferIsKindFix.cs +@@ -48,7 +48,7 @@ private async Task ConvertKindToIsKindAsync(Document document, TextSpa + + protected abstract void FixDiagnostic(DocumentEditor editor, SyntaxNode nodeToFix); + +- private sealed class CustomFixAllProvider : DocumentBasedFixAllProvider ++ private sealed class CustomFixAllProvider : Analyzer.Utilities.DocumentBasedFixAllProvider + { + private readonly PreferIsKindFix _fixer; + +diff --git a/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.csproj b/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.csproj +index 114e30a43..e38f8549f 100644 +--- a/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.csproj ++++ b/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.csproj +@@ -7,7 +7,6 @@ + + + *$(MSBuildProjectFile)* +- 3.9.0 + + + +diff --git a/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator.VisualBasic/Microsoft.CodeAnalysis.ResxSourceGenerator.VisualBasic.csproj b/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator.VisualBasic/Microsoft.CodeAnalysis.ResxSourceGenerator.VisualBasic.csproj +index a44df8a50..cba084cd5 100644 +--- a/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator.VisualBasic/Microsoft.CodeAnalysis.ResxSourceGenerator.VisualBasic.csproj ++++ b/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator.VisualBasic/Microsoft.CodeAnalysis.ResxSourceGenerator.VisualBasic.csproj +@@ -7,7 +7,6 @@ + + + *$(MSBuildProjectFile)* +- 3.9.0 + + + +diff --git a/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator.csproj b/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator.csproj +index 46a4fca6b..c9fa15584 100644 +--- a/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator.csproj ++++ b/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator.csproj +@@ -7,7 +7,6 @@ + + + *$(MSBuildProjectFile)* +- 3.9.0 + + + +diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotDirectlyAwaitATask.Fixer.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotDirectlyAwaitATask.Fixer.cs +index 738fdebf2..6d13947ce 100644 +--- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotDirectlyAwaitATask.Fixer.cs ++++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotDirectlyAwaitATask.Fixer.cs +@@ -82,7 +82,7 @@ private class MyCodeAction : DocumentChangeAction + } + } + +- private sealed class CustomFixAllProvider : DocumentBasedFixAllProvider ++ private sealed class CustomFixAllProvider : Analyzer.Utilities.DocumentBasedFixAllProvider + { + public static readonly CustomFixAllProvider Instance = new(); + +diff --git a/src/Roslyn.Diagnostics.Analyzers/CSharp/Roslyn.Diagnostics.CSharp.Analyzers.csproj b/src/Roslyn.Diagnostics.Analyzers/CSharp/Roslyn.Diagnostics.CSharp.Analyzers.csproj +index e62266894..b858d7097 100644 +--- a/src/Roslyn.Diagnostics.Analyzers/CSharp/Roslyn.Diagnostics.CSharp.Analyzers.csproj ++++ b/src/Roslyn.Diagnostics.Analyzers/CSharp/Roslyn.Diagnostics.CSharp.Analyzers.csproj +@@ -10,7 +10,7 @@ + + + +- ++ + + + +\ No newline at end of file +diff --git a/src/Roslyn.Diagnostics.Analyzers/Core/Roslyn.Diagnostics.Analyzers.csproj b/src/Roslyn.Diagnostics.Analyzers/Core/Roslyn.Diagnostics.Analyzers.csproj +index 60450aee0..3489028d4 100644 +--- a/src/Roslyn.Diagnostics.Analyzers/Core/Roslyn.Diagnostics.Analyzers.csproj ++++ b/src/Roslyn.Diagnostics.Analyzers/Core/Roslyn.Diagnostics.Analyzers.csproj +@@ -7,7 +7,6 @@ + Restore would conclude that there is a cyclic dependency between us and the Roslyn.Diagnostics.Analyzers package. + --> + *$(MSBuildProjectFile)* +- $(MicrosoftCodeAnalysisForRoslynDiagnosticsAnalyzersVersion) + + + +diff --git a/src/Roslyn.Diagnostics.Analyzers/VisualBasic/Roslyn.Diagnostics.VisualBasic.Analyzers.vbproj b/src/Roslyn.Diagnostics.Analyzers/VisualBasic/Roslyn.Diagnostics.VisualBasic.Analyzers.vbproj +index 509a3c069..737a2cf24 100644 +--- a/src/Roslyn.Diagnostics.Analyzers/VisualBasic/Roslyn.Diagnostics.VisualBasic.Analyzers.vbproj ++++ b/src/Roslyn.Diagnostics.Analyzers/VisualBasic/Roslyn.Diagnostics.VisualBasic.Analyzers.vbproj +@@ -7,7 +7,7 @@ + + + +- ++ + + + +\ No newline at end of file +diff --git a/src/Tools/GenerateDocumentationAndConfigFiles/GenerateDocumentationAndConfigFiles.csproj b/src/Tools/GenerateDocumentationAndConfigFiles/GenerateDocumentationAndConfigFiles.csproj +index c00a9ab5d..74f5f4d5a 100644 +--- a/src/Tools/GenerateDocumentationAndConfigFiles/GenerateDocumentationAndConfigFiles.csproj ++++ b/src/Tools/GenerateDocumentationAndConfigFiles/GenerateDocumentationAndConfigFiles.csproj +@@ -5,7 +5,6 @@ + true + false + true +- $(MicrosoftCodeAnalysisForRoslynDiagnosticsAnalyzersVersion) + + + +diff --git a/src/Tools/GenerateDocumentationAndConfigFilesForBrokenRuntime/GenerateDocumentationAndConfigFilesForBrokenRuntime.csproj b/src/Tools/GenerateDocumentationAndConfigFilesForBrokenRuntime/GenerateDocumentationAndConfigFilesForBrokenRuntime.csproj +index fa2233feb..f19ae8d4d 100644 +--- a/src/Tools/GenerateDocumentationAndConfigFilesForBrokenRuntime/GenerateDocumentationAndConfigFilesForBrokenRuntime.csproj ++++ b/src/Tools/GenerateDocumentationAndConfigFilesForBrokenRuntime/GenerateDocumentationAndConfigFilesForBrokenRuntime.csproj +@@ -12,8 +12,6 @@ + + + +- +- +- ++ + + +diff --git a/src/Tools/ReleaseNotesUtil/ReleaseNotesUtil.csproj b/src/Tools/ReleaseNotesUtil/ReleaseNotesUtil.csproj +index fe90e93ca..01b64e055 100644 +--- a/src/Tools/ReleaseNotesUtil/ReleaseNotesUtil.csproj ++++ b/src/Tools/ReleaseNotesUtil/ReleaseNotesUtil.csproj +@@ -3,6 +3,7 @@ + Exe + netcoreapp3.1 + true ++ true + + +