Skip to content
Merged
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
52 changes: 50 additions & 2 deletions SourceBuild.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.10
# Visual Studio Version 16
VisualStudioVersion = 16.0.29229.4
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{6D173F59-562E-4BAA-8D98-9A8F4901D99A}"
EndProject
Expand Down Expand Up @@ -28,6 +28,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VBCSCompiler", "src\Compile
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Server", "Server", "{B57E7F86-EB16-4F60-A47C-F9D170F54400}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Workspaces", "src\Workspaces\Core\Portable\Microsoft.CodeAnalysis.Workspaces.csproj", "{5889B407-1FC8-4713-9A15-AD91117C1D7B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workspaces", "Workspaces", "{839D0C7B-C07C-4EBC-B264-D9800729301D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.Workspaces", "src\Workspaces\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.Workspaces.csproj", "{8D000386-3349-4720-A75A-F2875DFCD446}"
EndProject
Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.Workspaces", "src\Workspaces\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Workspaces.vbproj", "{F9F835CB-8238-401B-8BB5-917C45B759D0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -122,6 +130,42 @@ Global
{649CE05A-529C-40D7-A501-CA9BCFEE40DC}.Release|x64.Build.0 = Release|Any CPU
{649CE05A-529C-40D7-A501-CA9BCFEE40DC}.Release|x86.ActiveCfg = Release|Any CPU
{649CE05A-529C-40D7-A501-CA9BCFEE40DC}.Release|x86.Build.0 = Release|Any CPU
{5889B407-1FC8-4713-9A15-AD91117C1D7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5889B407-1FC8-4713-9A15-AD91117C1D7B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5889B407-1FC8-4713-9A15-AD91117C1D7B}.Debug|x64.ActiveCfg = Debug|Any CPU
{5889B407-1FC8-4713-9A15-AD91117C1D7B}.Debug|x64.Build.0 = Debug|Any CPU
{5889B407-1FC8-4713-9A15-AD91117C1D7B}.Debug|x86.ActiveCfg = Debug|Any CPU
{5889B407-1FC8-4713-9A15-AD91117C1D7B}.Debug|x86.Build.0 = Debug|Any CPU
{5889B407-1FC8-4713-9A15-AD91117C1D7B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5889B407-1FC8-4713-9A15-AD91117C1D7B}.Release|Any CPU.Build.0 = Release|Any CPU
{5889B407-1FC8-4713-9A15-AD91117C1D7B}.Release|x64.ActiveCfg = Release|Any CPU
{5889B407-1FC8-4713-9A15-AD91117C1D7B}.Release|x64.Build.0 = Release|Any CPU
{5889B407-1FC8-4713-9A15-AD91117C1D7B}.Release|x86.ActiveCfg = Release|Any CPU
{5889B407-1FC8-4713-9A15-AD91117C1D7B}.Release|x86.Build.0 = Release|Any CPU
{8D000386-3349-4720-A75A-F2875DFCD446}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8D000386-3349-4720-A75A-F2875DFCD446}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8D000386-3349-4720-A75A-F2875DFCD446}.Debug|x64.ActiveCfg = Debug|Any CPU
{8D000386-3349-4720-A75A-F2875DFCD446}.Debug|x64.Build.0 = Debug|Any CPU
{8D000386-3349-4720-A75A-F2875DFCD446}.Debug|x86.ActiveCfg = Debug|Any CPU
{8D000386-3349-4720-A75A-F2875DFCD446}.Debug|x86.Build.0 = Debug|Any CPU
{8D000386-3349-4720-A75A-F2875DFCD446}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8D000386-3349-4720-A75A-F2875DFCD446}.Release|Any CPU.Build.0 = Release|Any CPU
{8D000386-3349-4720-A75A-F2875DFCD446}.Release|x64.ActiveCfg = Release|Any CPU
{8D000386-3349-4720-A75A-F2875DFCD446}.Release|x64.Build.0 = Release|Any CPU
{8D000386-3349-4720-A75A-F2875DFCD446}.Release|x86.ActiveCfg = Release|Any CPU
{8D000386-3349-4720-A75A-F2875DFCD446}.Release|x86.Build.0 = Release|Any CPU
{F9F835CB-8238-401B-8BB5-917C45B759D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F9F835CB-8238-401B-8BB5-917C45B759D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F9F835CB-8238-401B-8BB5-917C45B759D0}.Debug|x64.ActiveCfg = Debug|Any CPU
{F9F835CB-8238-401B-8BB5-917C45B759D0}.Debug|x64.Build.0 = Debug|Any CPU
{F9F835CB-8238-401B-8BB5-917C45B759D0}.Debug|x86.ActiveCfg = Debug|Any CPU
{F9F835CB-8238-401B-8BB5-917C45B759D0}.Debug|x86.Build.0 = Debug|Any CPU
{F9F835CB-8238-401B-8BB5-917C45B759D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F9F835CB-8238-401B-8BB5-917C45B759D0}.Release|Any CPU.Build.0 = Release|Any CPU
{F9F835CB-8238-401B-8BB5-917C45B759D0}.Release|x64.ActiveCfg = Release|Any CPU
{F9F835CB-8238-401B-8BB5-917C45B759D0}.Release|x64.Build.0 = Release|Any CPU
{F9F835CB-8238-401B-8BB5-917C45B759D0}.Release|x86.ActiveCfg = Release|Any CPU
{F9F835CB-8238-401B-8BB5-917C45B759D0}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -139,6 +183,10 @@ Global
{7AD4FE65-9A30-41A6-8004-AA8F89BCB7F3} = {5DC491BA-E836-47C1-A4AA-3C770742718B}
{649CE05A-529C-40D7-A501-CA9BCFEE40DC} = {B57E7F86-EB16-4F60-A47C-F9D170F54400}
{B57E7F86-EB16-4F60-A47C-F9D170F54400} = {DDFAE591-7414-4CC9-AD99-427C2D153893}
{5889B407-1FC8-4713-9A15-AD91117C1D7B} = {839D0C7B-C07C-4EBC-B264-D9800729301D}
{839D0C7B-C07C-4EBC-B264-D9800729301D} = {6D173F59-562E-4BAA-8D98-9A8F4901D99A}
{8D000386-3349-4720-A75A-F2875DFCD446} = {839D0C7B-C07C-4EBC-B264-D9800729301D}
{F9F835CB-8238-401B-8BB5-917C45B759D0} = {839D0C7B-C07C-4EBC-B264-D9800729301D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8157FCF4-7FB2-412F-883A-DC40977425EC}
Expand Down
17 changes: 17 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,23 @@ jobs:
continueOnError: true
condition: not(succeeded())

- job: SourceBuild_Test
pool:
name: NetCorePublic-Pool
queue: BuildPool.Ubuntu.1604.amd64.Open
timeoutInMinutes: 90
steps:
- script: ./eng/cibuild.sh --configuration Debug --prepareMachine --docker --sourceBuild
displayName: Build
- task: PublishBuildArtifacts@1
displayName: Publish Logs
inputs:
PathtoPublish: '$(Build.SourcesDirectory)/artifacts/log/Debug'
ArtifactName: 'SourceBuild_Test'
publishLocation: Container
continueOnError: true
condition: not(succeeded())

- job: macOS_Test
pool:
vmImage: 'macOS-10.13'
Expand Down
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<MicrosoftCodeAnalysisTestResourcesProprietaryVersion>2.0.18</MicrosoftCodeAnalysisTestResourcesProprietaryVersion>
<MicrosoftCodeAnalysisVisualBasicCodeFixTestingXUnitVersion>$(MicrosoftCodeAnalysisTestingVersion)</MicrosoftCodeAnalysisVisualBasicCodeFixTestingXUnitVersion>
<MicrosoftCodeAnalysisVisualBasicCodeStyleVersion>$(CodeStyleAnalyzerVersion)</MicrosoftCodeAnalysisVisualBasicCodeStyleVersion>
<MicrosoftCodeAnalysisFlowAnalysisUtilitiesVersion>2.9.4</MicrosoftCodeAnalysisFlowAnalysisUtilitiesVersion>
<MicrosoftCodeAnalysisFlowAnalysisUtilitiesVersion>2.9.5</MicrosoftCodeAnalysisFlowAnalysisUtilitiesVersion>
<MicrosoftCodeQualityAnalyzersVersion>$(RoslynDiagnosticsNugetPackageVersion)</MicrosoftCodeQualityAnalyzersVersion>
<SystemCompositionVersion>1.0.31</SystemCompositionVersion>
<MicrosoftCSharpVersion>4.3.0</MicrosoftCSharpVersion>
Expand Down
6 changes: 6 additions & 0 deletions eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ param (
[switch]$prepareMachine,
[switch]$useGlobalNuGetCache = $true,
[switch]$warnAsError = $false,
[switch]$sourceBuild = $false,

# official build settings
[string]$officialBuildId = "",
Expand Down Expand Up @@ -102,6 +103,7 @@ function Print-Usage() {
Write-Host " -prepareMachine Prepare machine for CI run, clean up processes after build"
Write-Host " -useGlobalNuGetCache Use global NuGet cache."
Write-Host " -warnAsError Treat all warnings as errors"
Write-Host " -sourceBuild Simulate building source-build"
Write-Host ""
Write-Host "Official build settings:"
Write-Host " -officialBuildId An official build id, e.g. 20190102.3"
Expand Down Expand Up @@ -233,6 +235,9 @@ function BuildSolution() {
# Workaround for some machines in the AzDO pool not allowing long paths (%5c is msbuild escaped backslash)
$ibcDir = Join-Path $RepoRoot ".o%5c"

# Set DotNetBuildFromSource to 'true' if we're simulating building for source-build.
$buildFromSource = if ($sourceBuild) { "/p:DotNetBuildFromSource=true" } else { "" }

try {
MSBuild $toolsetBuildProj `
$bl `
Expand All @@ -258,6 +263,7 @@ function BuildSolution() {
/p:IbcOptimizationDataDir=$ibcDir `
$suppressExtensionDeployment `
$msbuildWarnAsError `
$buildFromSource `
@properties
}
finally {
Expand Down
9 changes: 9 additions & 0 deletions eng/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ usage()
echo " --skipAnalyzers Do not run analyzers during build operations"
echo " --prepareMachine Prepare machine for CI run, clean up processes after build"
echo " --warnAsError Treat all warnings as errors"
echo " --sourceBuild Simulate building for source-build"
echo ""
echo "Command line arguments starting with '/p:' are passed through to MSBuild."
}
Expand Down Expand Up @@ -68,6 +69,7 @@ prepare_machine=false
warn_as_error=false
properties=""
disable_parallel_restore=false
source_build=false

docker=false
args=""
Expand Down Expand Up @@ -141,6 +143,9 @@ while [[ $# > 0 ]]; do
shift
continue
;;
--sourcebuild)
source_build=true
;;
/p:*)
properties="$properties $1"
;;
Expand Down Expand Up @@ -206,6 +211,9 @@ function MakeBootstrapBuild {

function BuildSolution {
local solution="Compilers.sln"
if [[ "$source_build" == true ]]; then
solution="SourceBuild.sln"
fi
echo "$solution:"

InitializeToolset
Expand Down Expand Up @@ -274,6 +282,7 @@ function BuildSolution {
/p:TreatWarningsAsErrors=true \
/p:RestoreDisableParallel=$disable_parallel_restore \
/p:TestRuntimeAdditionalArguments=$test_runtime_args \
/p:DotNetBuildFromSource=$source_build \
$test_runtime \
$mono_tool \
$properties
Expand Down
4 changes: 2 additions & 2 deletions eng/targets/Imports.targets
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<Target Name="_AddCommitHashAttribute"
DependsOnTargets="InitializeSourceControlInformation"
BeforeTargets="GetAssemblyAttributes"
Condition="'$(GenerateMicrosoftCodeAnalysisCommitHashAttribute)' == 'true'">
Condition="'$(GenerateMicrosoftCodeAnalysisCommitHashAttribute)' == 'true' AND '$(SourceControlInformationFeatureSupported)' == 'true'">
<ItemGroup>
<AssemblyAttribute Include="Microsoft.CodeAnalysis.CommitHashAttribute">
<_Parameter1 Condition="'$(OfficialBuild)' == 'true'">$(SourceRevisionId)</_Parameter1>
Expand Down Expand Up @@ -186,7 +186,7 @@
<Target Name="_AppendCommonPackageDescription"
BeforeTargets="InitializeStandardNuspecProperties;GenerateNuspec"
DependsOnTargets="InitializeSourceControlInformation"
Condition="'$(IsPackable)' == 'true'">
Condition="'$(IsPackable)' == 'true' AND '$(SourceControlInformationFeatureSupported)' == 'true'">
<PropertyGroup>
<PackageDescription>
$(PackageDescription)
Expand Down
6 changes: 6 additions & 0 deletions eng/targets/Settings.props
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,10 @@
</PropertyGroup>
</When>
</Choose>

<PropertyGroup Condition="'$(DotNetBuildFromSource)' == 'true'">
<!-- https://github.com/dotnet/roslyn/issues/38433 Vbc does not like the extra semicolon -->
<DefineConstants Condition="'$(DefineConstants)' != ''">DOTNET_BUILD_FROM_SOURCE;$(DefineConstants)</DefineConstants>
<DefineConstants Condition="'$(DefineConstants)' == ''">DOTNET_BUILD_FROM_SOURCE</DefineConstants>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -113675,5 +113675,77 @@ class Result<A, B>
// Use VerifyEmitDiagnostics() to test assertions in CodeGenerator.EmitCallExpression.
comp.VerifyEmitDiagnostics();
}

[Fact]
[WorkItem(38183, "https://github.com/dotnet/roslyn/issues/38183")]
public void UnboundGenericTypeReference_StructConstraint()
{
var source =
@"class Program
{
static void Main(string[] args)
{
F<Boxed<int>>();
}

static void F<T>()
{
if (typeof(T).GetGenericTypeDefinition() == typeof(Boxed<>))
{
}
}
}

class Boxed<T>
where T : struct
{
public bool Equals(Boxed<T>? other) =>
false;

public override bool Equals(object? obj) =>
Equals(obj as Boxed<T>);

public override int GetHashCode() =>
0;
}";
var comp = CreateCompilation(source, options: WithNonNullTypesTrue(TestOptions.ReleaseExe));
CompileAndVerify(comp, expectedOutput: "");
}

[Fact]
[WorkItem(38183, "https://github.com/dotnet/roslyn/issues/38183")]
public void UnboundGenericTypeReference_ClassConstraint()
{
var source =
@"class Program
{
static void Main(string[] args)
{
F<Boxed<object>>();
}

static void F<T>()
{
if (typeof(T).GetGenericTypeDefinition() == typeof(Boxed<>))
{
}
}
}

class Boxed<T>
where T : class
{
public bool Equals(Boxed<T>? other) =>
false;

public override bool Equals(object? obj) =>
Equals(obj as Boxed<T>);

public override int GetHashCode() =>
0;
}";
var comp = CreateCompilation(source, options: WithNonNullTypesTrue(TestOptions.ReleaseExe));
CompileAndVerify(comp, expectedOutput: "");
}
}
}
11 changes: 6 additions & 5 deletions src/Compilers/Core/Portable/CodeGen/TokenMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.CodeGen
Expand All @@ -25,9 +21,14 @@ internal sealed class TokenMap<T> where T : class
{
private readonly ConcurrentDictionary<T, uint> _itemIdentityToToken = new ConcurrentDictionary<T, uint>(ReferenceEqualityComparer.Instance);

private readonly Dictionary<T, uint> _itemToToken = new Dictionary<T, uint>();
private readonly Dictionary<T, uint> _itemToToken;
private readonly ArrayBuilder<T> _items = new ArrayBuilder<T>();

internal TokenMap(IEqualityComparer<T> comparer)
{
_itemToToken = new Dictionary<T, uint>(comparer);
}

public uint GetOrAddTokenFor(T item, out bool referenceAdded)
{
uint tmp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ internal abstract class CommonPEModuleBuilder : Cci.IUnit, Cci.IModuleReference
internal Cci.IMethodReference DebugEntryPoint;

private readonly ConcurrentDictionary<IMethodSymbol, Cci.IMethodBody> _methodBodyMap;
private readonly TokenMap<Cci.IReference> _referencesInILMap = new TokenMap<Cci.IReference>();
private readonly TokenMap<Cci.IReference> _referencesInILMap = new TokenMap<Cci.IReference>(MetadataEntityReferenceComparer.ConsiderEverything);
private readonly ItemTokenMap<string> _stringsInILMap = new ItemTokenMap<string>();
private readonly ItemTokenMap<Cci.DebugSourceDocument> _sourceDocumentsInILMap = new ItemTokenMap<Cci.DebugSourceDocument>();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Collections.Generic;
using Microsoft.CodeAnalysis.Symbols;

namespace Microsoft.CodeAnalysis.Emit
{
internal sealed class MetadataEntityReferenceComparer : IEqualityComparer<Cci.IReference>
{
internal static readonly MetadataEntityReferenceComparer ConsiderEverything = new MetadataEntityReferenceComparer(TypeCompareKind.ConsiderEverything);

private readonly TypeCompareKind _compareKind;

private MetadataEntityReferenceComparer(TypeCompareKind compareKind)
{
_compareKind = compareKind;
}

public bool Equals(Cci.IReference x, Cci.IReference y)
{
if (x is null)
{
return y is null;
}
else if (ReferenceEquals(x, y))
{
return true;
}
else if (x is ISymbolInternal sx && y is ISymbolInternal sy)
{
return sx.Equals(sy, _compareKind);
}
else
{
return x.Equals(y);
}
}

public int GetHashCode(Cci.IReference obj)
{
return obj?.GetHashCode() ?? 0;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ void AnalyzeDisposeMethod()
disposeAnalysisResult: out var disposeAnalysisResult,
pointsToAnalysisResult: out var pointsToAnalysisResult))
{
var exitBlock = disposeAnalysisResult.ControlFlowGraph.GetExit();
var exitBlock = disposeAnalysisResult.ControlFlowGraph.ExitBlock();
foreach (var fieldWithPointsToValue in disposeAnalysisResult.TrackedInstanceFieldPointsToMap)
{
var field = fieldWithPointsToValue.Key;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private void PerformFlowAnalysisOnOperationBlock(
try
{
// Compute diagnostics for undisposed objects at exit block.
var exitBlock = disposeAnalysisResult.ControlFlowGraph.GetExit();
var exitBlock = disposeAnalysisResult.ControlFlowGraph.ExitBlock();
var disposeDataAtExit = disposeAnalysisResult.ExitBlockOutput.Data;
ComputeDiagnostics(disposeDataAtExit, notDisposedDiagnostics, mayBeNotDisposedDiagnostics,
disposeAnalysisResult, pointsToAnalysisResult);
Expand Down
Loading