Skip to content

Commit

Permalink
Add arcade-powered-source-build local and ci builds
Browse files Browse the repository at this point in the history
  • Loading branch information
omajid committed Mar 12, 2021
1 parent 9e5f533 commit 437b074
Show file tree
Hide file tree
Showing 15 changed files with 1,144 additions and 0 deletions.
1 change: 1 addition & 0 deletions Directory.Build.props
Expand Up @@ -32,6 +32,7 @@
CS1712: Type parameter 'parameter' has no matching typeparam tag in the XML comment on 'type_or_member' (but other type parameters do)
-->
<NoWarn Condition="'$(Language)' == 'C#'">$(NoWarn),1573,1591,1712</NoWarn>
<NoWarn Condition=" '$(DotnetBuildFromSource)' == 'true' ">$(NoWarn);AD0001;CS8600;CS8601;CS8602;CS8603;CS8604;CS8605;CS8609;CS8619;CS8620;CS8625;CS8621;CS8631;CS8714;CS8762;CS8765;IDE0005</NoWarn>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 2 additions & 0 deletions azure-pipelines.yml
Expand Up @@ -112,6 +112,8 @@ jobs:
continueOnError: true
condition: always()

- template: eng/common/templates/job/source-build.yml

- job: Markdownlint
pool:
vmImage: ubuntu-18.04
Expand Down
23 changes: 23 additions & 0 deletions eng/SourceBuild.props
@@ -0,0 +1,23 @@
<Project>

<PropertyGroup>
<GitHubRepositoryName>roslyn-analyzers</GitHubRepositoryName>
<SourceBuildManagedOnly>true</SourceBuildManagedOnly>
</PropertyGroup>

<Target Name="ApplySourceBuildPatchFiles"
Condition="
'$(ArcadeBuildFromSource)' == 'true' and
'$(ArcadeInnerBuildFromSource)' == 'true'"
BeforeTargets="Execute">
<ItemGroup>
<SourceBuildPatchFile Include="$(RepositoryEngineeringDir)source-build-patches\*.patch" />
</ItemGroup>

<Exec
Command="git apply --ignore-whitespace --whitespace=nowarn &quot;%(SourceBuildPatchFile.FullPath)&quot;"
WorkingDirectory="$(RepoRoot)"
Condition="'@(SourceBuildPatchFile)' != ''" />
</Target>

</Project>
5 changes: 5 additions & 0 deletions eng/SourceBuildPrebuiltBaseline.xml
@@ -0,0 +1,5 @@
<UsageData>
<IgnorePatterns>
<UsagePattern IdentityGlob="*/*" />
</IgnorePatterns>
</UsageData>
1 change: 1 addition & 0 deletions eng/Version.Details.xml
Expand Up @@ -6,6 +6,7 @@
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="6.0.0-beta.21125.5">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>15246f4af00a1cb2e580783d32ec2937b1878a64</Sha>
<SourceBuild RepoName="arcade" ManagedOnly="true" />
</Dependency>
</ToolsetDependencies>
</Dependencies>
491 changes: 491 additions & 0 deletions eng/source-build-patches/0001-WIP-for-source-build.patch

Large diffs are not rendered by default.

335 changes: 335 additions & 0 deletions eng/source-build-patches/0004-Update-to-netstandard2.0.patch

Large diffs are not rendered by default.

@@ -0,0 +1,30 @@
From f3f0b2eec1f707260718dbd6e44dfb785b7b5d82 Mon Sep 17 00:00:00 2001
From: Omair Majid <omajid@redhat.com>
Date: Fri, 6 Nov 2020 18:18:48 -0500
Subject: [PATCH 3/4] Update Microsoft.CodeAnalysis packages

The version used in 5.0 SDK is Microsoft.CodeAnalysis 3.8.0
---
eng/Versions.props | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/eng/Versions.props b/eng/Versions.props
index 605321faf..1360b589a 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -28,9 +28,9 @@
<MicrosoftNetCompilersToolsetVersion>$(MicrosoftNETCoreCompilersPackageVersion)</MicrosoftNetCompilersToolsetVersion>
<CodeStyleAnalyersVersion>$(MicrosoftNETCoreCompilersPackageVersion)</CodeStyleAnalyersVersion>
<!-- Roslyn -->
- <MicrosoftCodeAnalysisVersion>3.3.1</MicrosoftCodeAnalysisVersion>
- <MicrosoftCodeAnalysisCommonVersion>3.3.1</MicrosoftCodeAnalysisCommonVersion>
- <MicrosoftCodeAnalysisForRoslynDiagnosticsAnalyzersVersion>3.7.0</MicrosoftCodeAnalysisForRoslynDiagnosticsAnalyzersVersion>
+ <MicrosoftCodeAnalysisVersion>3.8.0</MicrosoftCodeAnalysisVersion>
+ <MicrosoftCodeAnalysisCommonVersion>3.8.0</MicrosoftCodeAnalysisCommonVersion>
+ <MicrosoftCodeAnalysisForRoslynDiagnosticsAnalyzersVersion>$(MicrosoftCodeAnalysisVersion)</MicrosoftCodeAnalysisForRoslynDiagnosticsAnalyzersVersion>
<MicrosoftCodeAnalysisVersionForTests>3.8.0</MicrosoftCodeAnalysisVersionForTests>
<DogfoodAnalyzersVersion>3.3.2</DogfoodAnalyzersVersion>
<DogfoodNetAnalyzersVersion>5.0.4-preview1.21126.5</DogfoodNetAnalyzersVersion>
--
2.26.2

@@ -0,0 +1,39 @@
From 1839e0370d5416b45f0a8fbcc370f4984237f1ba Mon Sep 17 00:00:00 2001
From: Omair Majid <omajid@redhat.com>
Date: Mon, 9 Nov 2020 11:52:28 -0500
Subject: [PATCH 4/4] Fix version for Microsoft.CodeAnalysis.CSharp.CodeStyle

---
eng/Versions.props | 2 +-
src/Directory.Build.props | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/eng/Versions.props b/eng/Versions.props
index 677b44310..f9e213be1 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -34,7 +34,7 @@
<!-- Dependencies from https://github.com/dotnet/roslyn -->
<MicrosoftNETCoreCompilersPackageVersion>3.8.0</MicrosoftNETCoreCompilersPackageVersion>
<MicrosoftNetCompilersToolsetVersion>$(MicrosoftNETCoreCompilersPackageVersion)</MicrosoftNetCompilersToolsetVersion>
- <CodeStyleAnalyersVersion>$(MicrosoftNETCoreCompilersPackageVersion)</CodeStyleAnalyersVersion>
+ <MicrosoftCodeAnalysisCSharpCodeStyleVersion>$(MicrosoftNETCoreCompilersPackageVersion)</MicrosoftCodeAnalysisCSharpCodeStyleVersion>
<!-- Roslyn -->
<MicrosoftCodeAnalysisVersion>3.8.0</MicrosoftCodeAnalysisVersion>
<MicrosoftCodeAnalysisCommonVersion>3.8.0</MicrosoftCodeAnalysisCommonVersion>
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 24e9fe3eb..6c95f9d7b 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -31,7 +31,7 @@

<!-- Code Style analyzers -->
<ItemGroup Condition="'$(Language)' == 'C#'">
- <PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="$(CodeStyleAnalyersVersion)" />
+ <PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="$(MicrosoftCodeAnalysisCSharpCodeStyleVersion)" />
</ItemGroup>
<ItemGroup Condition="'$(Language)' == 'VB'">
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.CodeStyle" Version="$(CodeStyleAnalyersVersion)" />
--
2.26.2

@@ -0,0 +1,30 @@
From 6511158d415c1a7d87b825d8975b231a96f97c65 Mon Sep 17 00:00:00 2001
From: Davis Goodin <dagood@microsoft.com>
Date: Wed, 18 Nov 2020 14:30:39 -0600
Subject: [PATCH] Disable code analyzers when building from source

Some analyzers are not buildable from source due to VS dependencies. We
might as well disable all analyzers, because the analyzers seem most
important to run against PRs in upstream. In source-build, we don't
expect to make impactful changes to the C# code so they're unlikely to
catch anything.
---
src/Directory.Build.props | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 6c95f9d7b..63c1ce376 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -16,7 +16,7 @@
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
</PropertyGroup>

- <ItemGroup>
+ <ItemGroup Condition="'$(DotNetBuildFromSource)' != 'true'">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="$(DogfoodNetAnalyzersVersion)" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="$(MicrosoftCodeAnalysisAnalyzersVersion)" />
<PackageReference Include="Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers" Version="$(MicrosoftCodeAnalysisPerformanceSensitiveAnalyzersVersion)" />
--
2.25.2

@@ -0,0 +1,52 @@
From f1ffa381244fa08d4ba38fd6815a3dead7c3a954 Mon Sep 17 00:00:00 2001
From: dseefeld <dseefeld@microsoft.com>
Date: Fri, 11 Dec 2020 20:13:28 +0000
Subject: [PATCH] Build roslyn-analyzer tools with net5.0 TFM

---
eng/GenerateAnalyzerNuspec.targets | 2 +-
src/Tools/GenerateAnalyzerNuspec/GenerateAnalyzerNuspec.csproj | 1 +
.../GenerateDocumentationAndConfigFiles.csproj | 1 +
.../GenerateGlobalAnalyzerConfigs/GenerateGlobalAnalyzerConfigs.csproj | 1 +
4 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/eng/GenerateAnalyzerNuspec.targets b/eng/GenerateAnalyzerNuspec.targets
index 91c6a26..f683eab 100644
--- a/eng/GenerateAnalyzerNuspec.targets
+++ b/eng/GenerateAnalyzerNuspec.targets
@@ -109,7 +109,7 @@

<PropertyGroup>
<!-- Ideally, we would extract this from the MSBuild task, but we need this as the Target Output before that task is executed -->
- <_GenerateAnalyzerNuspecPath>$(ArtifactsBinDir)GenerateAnalyzerNuspec\$(Configuration)\netcoreapp3.1\GenerateAnalyzerNuspec.dll</_GenerateAnalyzerNuspecPath>
+ <_GenerateAnalyzerNuspecPath>$(ArtifactsBinDir)GenerateAnalyzerNuspec\$(Configuration)\net5.0\GenerateAnalyzerNuspec.dll</_GenerateAnalyzerNuspecPath>
</PropertyGroup>

<Target Name="BuildGenerateAnalyzerNuspecFile"
diff --git a/src/Tools/GenerateAnalyzerNuspec/GenerateAnalyzerNuspec.csproj b/src/Tools/GenerateAnalyzerNuspec/GenerateAnalyzerNuspec.csproj
index ba0a961..3a16ac4 100644
--- a/src/Tools/GenerateAnalyzerNuspec/GenerateAnalyzerNuspec.csproj
+++ b/src/Tools/GenerateAnalyzerNuspec/GenerateAnalyzerNuspec.csproj
@@ -2,6 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
+ <TargetFramework Condition="'$(DotNetBuildFromSource)' == 'true'">net5.0</TargetFramework>
<NonShipping>true</NonShipping>
<UseAppHost>false</UseAppHost>
</PropertyGroup>
diff --git a/src/Tools/GenerateDocumentationAndConfigFiles/GenerateDocumentationAndConfigFiles.csproj b/src/Tools/GenerateDocumentationAndConfigFiles/GenerateDocumentationAndConfigFiles.csproj
index 0056792..181473c 100644
--- a/src/Tools/GenerateDocumentationAndConfigFiles/GenerateDocumentationAndConfigFiles.csproj
+++ b/src/Tools/GenerateDocumentationAndConfigFiles/GenerateDocumentationAndConfigFiles.csproj
@@ -2,6 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
+ <TargetFramework Condition="'$(DotNetBuildFromSource)' == 'true'">net5.0</TargetFramework>
<NonShipping>true</NonShipping>
<UseAppHost>false</UseAppHost>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
--
1.8.3.1

@@ -0,0 +1,73 @@
From 20eff0e62e16c49d0b02e861f2cc553d7de66061 Mon Sep 17 00:00:00 2001
From: Davis Goodin <dagood@microsoft.com>
Date: Mon, 28 Dec 2020 11:20:26 -0600
Subject: [PATCH] Reference latest when running in build

---
Directory.Build.targets | 35 +++++++++++++++++++
...GenerateDocumentationAndConfigFiles.csproj | 3 ++
2 files changed, 38 insertions(+)

diff --git a/Directory.Build.targets b/Directory.Build.targets
index 34e0b7966..6633a023a 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -14,6 +14,41 @@
</Content>
</ItemGroup>

+ <!--
+ If this project executes during the build (a tool project, rather than a project that compiles
+ against reference assemblies for maximum compatibility), use the latest version of every package
+ rather than whatever the transitive closure happens to include. In source-build, if we use an
+ old reference-only package, it will fail to execute becuase methods are missing implementations.
+ -->
+ <ItemGroup Condition="'$(ExecutesDuringBuild)' == 'true'">
+ <ExecuteDuringBuildLatestPackageId Include="Microsoft.Bcl.AsyncInterfaces" />
+ <ExecuteDuringBuildLatestPackageId Include="System.Collections.Immutable" />
+ <ExecuteDuringBuildLatestPackageId Include="System.Composition" />
+ <ExecuteDuringBuildLatestPackageId Include="System.Composition.AttributedModel" />
+ <ExecuteDuringBuildLatestPackageId Include="System.Composition.Convention" />
+ <ExecuteDuringBuildLatestPackageId Include="System.Composition.Hosting" />
+ <ExecuteDuringBuildLatestPackageId Include="System.Composition.Runtime" />
+ <ExecuteDuringBuildLatestPackageId Include="System.Composition.TypedParts" />
+ <ExecuteDuringBuildLatestPackageId Include="System.Reflection.Metadata" />
+ <ExecuteDuringBuildLatestPackageId Include="System.Runtime.CompilerServices.Unsafe" />
+ <ExecuteDuringBuildLatestPackageId Include="System.Text.Encoding.CodePages" />
+
+ <!-- Find the name used by the PackageVersions.props infrastructure. -->
+ <ExecuteDuringBuildLatestPackageId
+ Update="@(ExecuteDuringBuildLatestPackageId)"
+ VersionPropertyName="$([System.String]::new('%(Identity)').Replace('.',''))Version" />
+
+ <!--
+ If the package version property is set (we are running in source-build or have the version in
+ eng/Versions.props), use it.
+ -->
+ <ExecuteDuringBuildLatestPackageId
+ Update="@(ExecuteDuringBuildLatestPackageId)"
+ Version="$(%(VersionPropertyName))" />
+
+ <PackageReference Include="@(ExecuteDuringBuildLatestPackageId->HasMetadata('Version'))" />
+ </ItemGroup>
+
<ItemGroup Condition="'$(IsUnitTestProject)' == 'true'">
<PackageReference Include="coverlet.msbuild" Version="$(CoverletVersion)" PrivateAssets="all" />
</ItemGroup>
diff --git a/src/Tools/GenerateDocumentationAndConfigFiles/GenerateDocumentationAndConfigFiles.csproj b/src/Tools/GenerateDocumentationAndConfigFiles/GenerateDocumentationAndConfigFiles.csproj
index 181473c7f..51da76e35 100644
--- a/src/Tools/GenerateDocumentationAndConfigFiles/GenerateDocumentationAndConfigFiles.csproj
+++ b/src/Tools/GenerateDocumentationAndConfigFiles/GenerateDocumentationAndConfigFiles.csproj
@@ -8,6 +8,9 @@
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<MicrosoftCodeAnalysisVersion>$(MicrosoftCodeAnalysisForRoslynDiagnosticsAnalyzersVersion)</MicrosoftCodeAnalysisVersion>
</PropertyGroup>
+ <PropertyGroup>
+ <ExecutesDuringBuild>true</ExecutesDuringBuild>
+ </PropertyGroup>
<ItemGroup>
<Compile Include="..\..\Microsoft.CodeAnalysis.Analyzers\Core\MetaAnalyzers\ReleaseTrackingHelper.cs" Link="ReleaseTrackingHelper.cs" />
<Compile Include="..\..\Utilities\Compiler\Debug.cs" Link="Debug.cs" />
--
2.25.4

30 changes: 30 additions & 0 deletions eng/source-build-patches/0012-Fix-version-for-MCVC.patch
@@ -0,0 +1,30 @@
From 1839e0370d5416b45f0a8fbcc370f4984237f1ba Mon Sep 17 00:00:00 2001
From: Omair Majid <omajid@redhat.com>
Date: Fri, 5 Mar 2021 11:52:28 -0500
Subject: [PATCH] Fix version for Microsoft.CodeAnalysis.VisualBasic.CodeStyle

diff --git a/eng/Versions.props b/eng/Versions.props
index 2af360df5..066ddcaf3 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -30,6 +30,7 @@
<!-- Roslyn -->
<MicrosoftCodeAnalysisVersion>3.8.0</MicrosoftCodeAnalysisVersion>
<MicrosoftCodeAnalysisCommonVersion>3.8.0</MicrosoftCodeAnalysisCommonVersion>
+ <MicrosoftCodeAnalysisVisualBasicCodeStyleVersion>3.8.0</MicrosoftCodeAnalysisVisualBasicCodeStyleVersion>
<MicrosoftCodeAnalysisForRoslynDiagnosticsAnalyzersVersion>$(MicrosoftCodeAnalysisVersion)</MicrosoftCodeAnalysisForRoslynDiagnosticsAnalyzersVersion>
<MicrosoftCodeAnalysisVersionForTests>3.8.0</MicrosoftCodeAnalysisVersionForTests>
<DogfoodAnalyzersVersion>3.3.2</DogfoodAnalyzersVersion>
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 40baf698c..ed66c81e6 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -34,7 +34,7 @@
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="$(MicrosoftCodeAnalysisCSharpCodeStyleVersion)" />
</ItemGroup>
<ItemGroup Condition="'$(Language)' == 'VB'">
- <PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.CodeStyle" Version="$(CodeStyleAnalyersVersion)" />
+ <PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.CodeStyle" Version="$(MicrosoftCodeAnalysisVisualBasicCodeStyleVersion)" />
</ItemGroup>

<!-- Setup the correct code analysis rulesets -->
19 changes: 19 additions & 0 deletions eng/source-build-patches/0013-package-versions.patch
@@ -0,0 +1,19 @@
diff --git a/eng/Versions.props b/eng/Versions.props
index 605321faf..bd747b098 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -42,10 +42,10 @@
<!-- Roslyn Testing -->
<MicrosoftCodeAnalysisTestingVersion>1.0.1-beta1.21126.1</MicrosoftCodeAnalysisTestingVersion>
<!-- Libs -->
- <SystemCollectionsImmutableVersion>1.3.1</SystemCollectionsImmutableVersion>
- <SystemComponentModelCompositionVersion>4.7.0</SystemComponentModelCompositionVersion>
- <SystemDirectoryServicesVersion>4.7.0</SystemDirectoryServicesVersion>
- <SystemReflectionMetadataVersion>1.4.2</SystemReflectionMetadataVersion>
+ <SystemCollectionsImmutableVersion>5.0.0</SystemCollectionsImmutableVersion>
+ <SystemComponentModelCompositionVersion>5.0.0</SystemComponentModelCompositionVersion>
+ <SystemDirectoryServicesVersion>5.0.0</SystemDirectoryServicesVersion>
+ <SystemReflectionMetadataVersion>5.0.0</SystemReflectionMetadataVersion>
<MicrosoftVisualBasicVersion>10.1.0</MicrosoftVisualBasicVersion>
<MicrosoftBuildLocatorVersion>1.1.2</MicrosoftBuildLocatorVersion>
<SQLitePCLRawVersion>1.1.2</SQLitePCLRawVersion>
13 changes: 13 additions & 0 deletions eng/source-build-patches/0014-comment-performancesensitive.patch
@@ -0,0 +1,13 @@
diff --git a/src/Utilities/Compiler/WellKnownTypeProvider.cs b/src/Utilities/Compiler/WellKnownTypeProvider.cs
index b2e1b5876..7169c1500 100644
--- a/src/Utilities/Compiler/WellKnownTypeProvider.cs
+++ b/src/Utilities/Compiler/WellKnownTypeProvider.cs
@@ -84,7 +84,7 @@ public static WellKnownTypeProvider GetOrCreate(Compilation compilation)
/// <param name="fullTypeName">Namespace + type name, e.g. "System.Exception".</param>
/// <param name="namedTypeSymbol">Named type symbol, if any.</param>
/// <returns>True if found in the compilation, false otherwise.</returns>
- [PerformanceSensitive("https://github.com/dotnet/roslyn-analyzers/issues/4893", AllowCaptures = false)]
+ // [PerformanceSensitive("https://github.com/dotnet/roslyn-analyzers/issues/4893", AllowCaptures = false)]
public bool TryGetOrCreateTypeByMetadataName(
string fullTypeName,
[NotNullWhen(returnValue: true)] out INamedTypeSymbol? namedTypeSymbol)

0 comments on commit 437b074

Please sign in to comment.