Skip to content

Commit

Permalink
Rebuild Microsoft.CodeAnalysis (#50968)
Browse files Browse the repository at this point in the history
Co-authored-by: Jared Parsons <jaredpparsons@gmail.com>
  • Loading branch information
RikkiGibson and jaredpar authored Feb 17, 2021
1 parent b272206 commit bf2a49d
Show file tree
Hide file tree
Showing 39 changed files with 1,173 additions and 371 deletions.
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": "Launch BuildValidator.dll",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/artifacts/bin/BuildValidator/Debug/netcoreapp3.1/BuildValidator.dll",
"args": [
"--assembliesPath", "./artifacts/obj/RunTests",
"--debugPath", "./artifacts/BuildValidator",
"--sourcePath", "."
],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "internalConsole"
},
{
"name": "Launch RunTests.dll",
"type": "coreclr",
Expand Down
35 changes: 35 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,38 @@ jobs:
continueOnError: true
condition: not(succeeded())

- job: Correctness_Rebuild
pool:
vmImage: windows-2019
timeoutInMinutes: 90
steps:
- template: eng/pipelines/checkout-windows-task.yml

- task: PowerShell@2
displayName: Restore
inputs:
filePath: eng/build.ps1
arguments: -configuration Debug -prepareMachine -ci -restore -binaryLog

- task: PowerShell@2
displayName: Build
inputs:
filePath: eng/build.ps1
arguments: -configuration Debug -prepareMachine -ci -build -bootstrap -publish -binaryLog -skipDocumentation

- script: .\artifacts\bin\BuildValidator\Debug\net472\BuildValidator.exe --assembliesPath .\artifacts\obj\Microsoft.CodeAnalysis --debugPath .\artifacts\BuildValidator --sourcePath .
displayName: Run BuildValidator

- task: PublishBuildArtifacts@1
displayName: Publish BuildValidator debug outputs
inputs:
PathtoPublish: '$(Build.SourcesDirectory)/artifacts/BuildValidator'
ArtifactName: 'BuildValidator_DebugOut'
publishLocation: Container
continueOnError: true
condition: failed()

- template: eng/pipelines/publish-logs.yml
parameters:
jobName: Correctness_Rebuild
configuration: Debug
3 changes: 2 additions & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<MicrosoftIdentityModelClientsActiveDirectoryVersion>3.13.8</MicrosoftIdentityModelClientsActiveDirectoryVersion>
<MicrosoftInternalPerformanceCodeMarkersDesignTimeVersion>15.8.27812-alpha</MicrosoftInternalPerformanceCodeMarkersDesignTimeVersion>
<MicrosoftInternalVisualStudioShellInterop140DesignTimeVersion>14.3.25407-alpha</MicrosoftInternalVisualStudioShellInterop140DesignTimeVersion>
<MicrosoftMetadataVisualizerVersion>1.0.0-beta3.20174.1</MicrosoftMetadataVisualizerVersion>
<MicrosoftMetadataVisualizerVersion>1.0.0-beta3.21075.2</MicrosoftMetadataVisualizerVersion>
<MicrosoftMSXMLVersion>8.0.0</MicrosoftMSXMLVersion>
<MicrosoftNETBuildExtensionsVersion>2.2.101</MicrosoftNETBuildExtensionsVersion>
<MicrosoftNETCorePlatformsVersion>2.1.2</MicrosoftNETCorePlatformsVersion>
Expand Down Expand Up @@ -205,6 +205,7 @@
<SystemBuffersVersion>4.5.1</SystemBuffersVersion>
<SystemCompositionVersion>1.0.31</SystemCompositionVersion>
<SystemCodeDomVersion>4.7.0</SystemCodeDomVersion>
<SystemCommandLineVersion>2.0.0-beta1.20574.7</SystemCommandLineVersion>
<SystemCommandLineExperimentalVersion>0.3.0-alpha.19577.1</SystemCommandLineExperimentalVersion>
<SystemComponentModelCompositionVersion>4.5.0</SystemComponentModelCompositionVersion>
<SystemDrawingCommonVersion>4.5.0</SystemDrawingCommonVersion>
Expand Down
2 changes: 1 addition & 1 deletion eng/build-utils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ function Make-BootstrapBuild([switch]$force32 = $false) {

Run-MSBuild $projectPath "/restore /t:Pack /p:RoslynEnforceCodeStyle=false /p:RunAnalyzersDuringBuild=false /p:DotNetUseShippingVersions=true /p:InitialDefineConstants=BOOTSTRAP /p:PackageOutputPath=`"$dir`" /p:EnableNgenOptimization=false /p:PublishWindowsPdb=false $force32Flag" -logFileName "Bootstrap" -configuration $bootstrapConfiguration -runAnalyzers
$packageFile = Get-ChildItem -Path $dir -Filter "$packageName.*.nupkg"
Unzip "$dir\$packageFile" $dir
Unzip (Join-Path $dir $packageFile) $dir

Write-Host "Cleaning Bootstrap compiler artifacts"
Run-MSBuild $projectPath "/t:Clean" -logFileName "BootstrapClean"
Expand Down
43 changes: 43 additions & 0 deletions eng/test-rebuild.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<#
This script tests that Roslyn artifacts are rebuildable--i.e. that the source code and resources can be identified
#>

[CmdletBinding(PositionalBinding=$false)]
param(
[string]$configuration = "Debug",
[switch]$ci = $false,
[switch]$help)

Set-StrictMode -version 2.0
$ErrorActionPreference="Stop"

function Print-Usage() {
Write-Host "Usage: test-rebuild.ps1"
Write-Host " -configuration Build configuration ('Debug' or 'Release')"
Write-Host " -ci Set when running on CI server"
Write-Host " -help Print help and exit"
}

try {
if ($help) {
Print-Usage
exit 0
}

. (Join-Path $PSScriptRoot "build-utils.ps1")
Push-Location $RepoRoot

Write-Host "Building Roslyn"
Exec-Console (Join-Path $PSScriptRoot "build.ps1") "-restore -build -ci:$ci -configuration:$configuration -pack -binaryLog"
Exec-Console "artifacts\bin\BuildValidator\$configuration\net472\BuildValidator.exe" "--assembliesPath '$ArtifactsDir/obj/Microsoft.CodeAnalysis'"

exit 0
}
catch [exception] {
Write-Host $_
Write-Host $_.Exception
exit 1
}
finally {
Pop-Location
}
12 changes: 7 additions & 5 deletions src/Compilers/CSharp/Test/Emit/PDB/PDBAsyncTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2016,11 +2016,13 @@ async partial void M() {}

AssertEx.AssertEqualToleratingWhitespaceDifferences(@"
MethodDebugInformation (index: 0x31, size: 20):
==================================================
1: nil
2: nil
3: nil
4:
================================================
IL
================================================
1: nil
2: nil
3: nil
4:
{
Kickoff Method: 0x06000001 (MethodDef)
Locals: 0x11000002 (StandAloneSig)
Expand Down
25 changes: 13 additions & 12 deletions src/Compilers/CSharp/Test/Emit/PDB/PDBIteratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1599,12 +1599,14 @@ public class C

AssertEx.AssertEqualToleratingWhitespaceDifferences(@"
MethodDebugInformation (index: 0x31, size: 40):
==================================================
1: nil
2: nil
3: nil
4: nil
5:
================================================
IL
================================================
1: nil
2: nil
3: nil
4: nil
5:
{
Kickoff Method: 0x06000001 (MethodDef)
Locals: 0x11000001 (StandAloneSig)
Expand All @@ -1615,12 +1617,11 @@ public class C
IL_0030: <hidden>
IL_0037: (5, 44) - (5, 45)
}
6: nil
7: nil
8: nil
9: nil
a: nil
",
6: nil
7: nil
8: nil
9: nil
a: nil",
writer.ToString());
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Compilers/CSharp/Test/Emit/PDB/PDBSourceLinkTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public static void Main()
debugEntryPoint: null,
sourceLinkStream: new MemoryStream(new byte[] { 1, 2, 3 }),
embeddedTexts: null,
pdbOptionsBlobReader: null,
testData: new CompilationTestData()
{
SymWriterFactory = metadataProvider => new SymUnmanagedWriterWithoutSourceLinkSupport(metadataProvider)
Expand Down
4 changes: 4 additions & 0 deletions src/Compilers/CSharp/Test/Emit/PDB/PDBTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ public void SymWriterErrors()
debugEntryPoint: null,
sourceLinkStream: null,
embeddedTexts: null,
pdbOptionsBlobReader: null,
testData: new CompilationTestData() { SymWriterFactory = _ => new MockSymUnmanagedWriter() });

result.Diagnostics.Verify(
Expand Down Expand Up @@ -219,6 +220,7 @@ public void SymWriterErrors2()
debugEntryPoint: null,
sourceLinkStream: null,
embeddedTexts: null,
pdbOptionsBlobReader: null,
testData: new CompilationTestData() { SymWriterFactory = SymWriterTestUtilities.ThrowingFactory });

result.Diagnostics.Verify(
Expand Down Expand Up @@ -250,6 +252,7 @@ public void SymWriterErrors3()
debugEntryPoint: null,
sourceLinkStream: null,
embeddedTexts: null,
pdbOptionsBlobReader: null,
testData: new CompilationTestData() { SymWriterFactory = SymWriterTestUtilities.ThrowingFactory });

result.Diagnostics.Verify(
Expand Down Expand Up @@ -281,6 +284,7 @@ public void SymWriterErrors4()
debugEntryPoint: null,
sourceLinkStream: null,
embeddedTexts: null,
pdbOptionsBlobReader: null,
testData: new CompilationTestData() { SymWriterFactory = _ => throw new DllNotFoundException("xxx") });

result.Diagnostics.Verify(
Expand Down
1 change: 1 addition & 0 deletions src/Compilers/Core/Portable/CommandLine/CommonCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,7 @@ private void CompileAndEmit(
peStreamProvider,
refPeStreamProviderOpt,
pdbStreamProviderOpt,
pdbOptionsBlobReader: null,
testSymWriterFactory: null,
diagnostics: diagnostics,
emitOptions: emitOptions,
Expand Down
38 changes: 38 additions & 0 deletions src/Compilers/Core/Portable/Compilation/Compilation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2454,6 +2454,35 @@ public EmitResult Emit(
IEnumerable<EmbeddedText>? embeddedTexts = null,
Stream? metadataPEStream = null,
CancellationToken cancellationToken = default(CancellationToken))
{
return Emit(
peStream,
pdbStream,
xmlDocumentationStream,
win32Resources,
manifestResources,
options,
debugEntryPoint,
sourceLinkStream,
embeddedTexts,
metadataPEStream,
pdbOptionsBlobReader: null,
cancellationToken);
}

internal EmitResult Emit(
Stream peStream,
Stream? pdbStream,
Stream? xmlDocumentationStream,
Stream? win32Resources,
IEnumerable<ResourceDescription>? manifestResources,
EmitOptions? options,
IMethodSymbol? debugEntryPoint,
Stream? sourceLinkStream,
IEnumerable<EmbeddedText>? embeddedTexts,
Stream? metadataPEStream,
BlobReader? pdbOptionsBlobReader,
CancellationToken cancellationToken)
{
if (peStream == null)
{
Expand Down Expand Up @@ -2549,6 +2578,7 @@ public EmitResult Emit(
debugEntryPoint,
sourceLinkStream,
embeddedTexts,
pdbOptionsBlobReader,
testData: null,
cancellationToken: cancellationToken);
}
Expand All @@ -2568,6 +2598,7 @@ internal EmitResult Emit(
IMethodSymbol? debugEntryPoint,
Stream? sourceLinkStream,
IEnumerable<EmbeddedText>? embeddedTexts,
BlobReader? pdbOptionsBlobReader,
CompilationTestData? testData,
CancellationToken cancellationToken)
{
Expand Down Expand Up @@ -2648,6 +2679,7 @@ internal EmitResult Emit(
new SimpleEmitStreamProvider(peStream),
(metadataPEStream != null) ? new SimpleEmitStreamProvider(metadataPEStream) : null,
(pdbStream != null) ? new SimpleEmitStreamProvider(pdbStream) : null,
pdbOptionsBlobReader,
testData?.SymWriterFactory,
diagnostics,
emitOptions: options,
Expand Down Expand Up @@ -2809,6 +2841,7 @@ internal bool SerializeToPeStream(
EmitStreamProvider peStreamProvider,
EmitStreamProvider? metadataPEStreamProvider,
EmitStreamProvider? pdbStreamProvider,
BlobReader? pdbOptionsBlobReader,
Func<ISymWriterMetadataProvider, SymUnmanagedWriter>? testSymWriterFactory,
DiagnosticBag diagnostics,
EmitOptions emitOptions,
Expand Down Expand Up @@ -2882,6 +2915,7 @@ internal bool SerializeToPeStream(
getPortablePdbStream,
nativePdbWriter,
pePdbFilePath,
pdbOptionsBlobReader,
emitOptions.EmitMetadataOnly,
emitOptions.IncludePrivateMembers,
deterministic,
Expand Down Expand Up @@ -2963,6 +2997,7 @@ internal static bool SerializePeToStream(
Func<Stream?>? getPortablePdbStreamOpt,
Cci.PdbWriter? nativePdbWriterOpt,
string? pdbPathOpt,
BlobReader? pdbOptionsBlobReader,
bool metadataOnly,
bool includePrivateMembers,
bool isDeterministic,
Expand All @@ -2980,6 +3015,7 @@ internal static bool SerializePeToStream(
getPeStream,
getPortablePdbStreamOpt,
nativePdbWriterOpt,
pdbOptionsBlobReader,
pdbPathOpt,
metadataOnly,
deterministicPrimaryOutput,
Expand All @@ -3002,6 +3038,7 @@ internal static bool SerializePeToStream(
getMetadataPeStreamOpt,
getPortablePdbStreamOpt: null,
nativePdbWriterOpt: null,
pdbOptionsBlobReader: null,
pdbPathOpt: null,
metadataOnly: true,
isDeterministic: true,
Expand Down Expand Up @@ -3057,6 +3094,7 @@ internal static bool SerializePeToStream(
metadataStream,
ilStream,
(nativePdbWriterOpt == null) ? pdbStream : null,
pdbOptionsBlobReader: null,
out MetadataSizes metadataSizes);

writer.GetMethodTokens(updatedMethods);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public abstract class CompilationOptions
/// <summary>
/// Emit mode that favors debuggability.
/// </summary>
internal bool DebugPlusMode { get; private protected set; }
internal bool DebugPlusMode { get; set; }

/// <summary>
/// Specifies whether to import members with accessibility other than public or protected by default.
Expand Down
4 changes: 3 additions & 1 deletion src/Compilers/Core/Portable/Microsoft.CodeAnalysis.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<NoStdLib>true</NoStdLib>
<ApplyNgenOptimization Condition="'$(TargetFramework)' == 'netstandard2.0'">partial</ApplyNgenOptimization>
<GeneratePerformanceSensitiveAttribute>true</GeneratePerformanceSensitiveAttribute>

<EmbedUntrackedSources>true</EmbedUntrackedSources>

<!-- NuGet -->
<IsPackable>true</IsPackable>
<PackageId>Microsoft.CodeAnalysis.Common</PackageId>
Expand Down Expand Up @@ -51,6 +52,7 @@
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator.ExpressionCompiler" />
<InternalsVisibleTo Include="csc" />
<InternalsVisibleTo Include="csi" />
<InternalsVisibleTo Include="BuildValidator" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.Scripting" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.Scripting" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.Scripting" />
Expand Down
Loading

0 comments on commit bf2a49d

Please sign in to comment.