From c955f3c99b5698c906e0700ef691b5b1571c8136 Mon Sep 17 00:00:00 2001 From: Charles Stoner Date: Fri, 30 Aug 2019 13:05:18 -0700 Subject: [PATCH 1/8] Consider nullability when comparing IReference instances during emit (#38249) (#38396) Port the fix for #38183 to 16.3. --- .../Semantics/NullableReferenceTypesTests.cs | 72 +++++++++++++++++++ .../Core/Portable/CodeGen/TokenMap.cs | 11 +-- .../Portable/Emit/CommonPEModuleBuilder.cs | 2 +- .../Emit/MetadataEntityReferenceComparer.cs | 44 ++++++++++++ 4 files changed, 123 insertions(+), 6 deletions(-) create mode 100644 src/Compilers/Core/Portable/Emit/MetadataEntityReferenceComparer.cs diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs index 851788448cbb5..a4bec1ecd0e67 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs @@ -113675,5 +113675,77 @@ class Result // 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>(); + } + + static void F() + { + if (typeof(T).GetGenericTypeDefinition() == typeof(Boxed<>)) + { + } + } +} + +class Boxed + where T : struct +{ + public bool Equals(Boxed? other) => + false; + + public override bool Equals(object? obj) => + Equals(obj as Boxed); + + 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>(); + } + + static void F() + { + if (typeof(T).GetGenericTypeDefinition() == typeof(Boxed<>)) + { + } + } +} + +class Boxed + where T : class +{ + public bool Equals(Boxed? other) => + false; + + public override bool Equals(object? obj) => + Equals(obj as Boxed); + + public override int GetHashCode() => + 0; +}"; + var comp = CreateCompilation(source, options: WithNonNullTypesTrue(TestOptions.ReleaseExe)); + CompileAndVerify(comp, expectedOutput: ""); + } } } diff --git a/src/Compilers/Core/Portable/CodeGen/TokenMap.cs b/src/Compilers/Core/Portable/CodeGen/TokenMap.cs index c4588f678af63..c02730df23790 100644 --- a/src/Compilers/Core/Portable/CodeGen/TokenMap.cs +++ b/src/Compilers/Core/Portable/CodeGen/TokenMap.cs @@ -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 @@ -25,9 +21,14 @@ internal sealed class TokenMap where T : class { private readonly ConcurrentDictionary _itemIdentityToToken = new ConcurrentDictionary(ReferenceEqualityComparer.Instance); - private readonly Dictionary _itemToToken = new Dictionary(); + private readonly Dictionary _itemToToken; private readonly ArrayBuilder _items = new ArrayBuilder(); + internal TokenMap(IEqualityComparer comparer) + { + _itemToToken = new Dictionary(comparer); + } + public uint GetOrAddTokenFor(T item, out bool referenceAdded) { uint tmp; diff --git a/src/Compilers/Core/Portable/Emit/CommonPEModuleBuilder.cs b/src/Compilers/Core/Portable/Emit/CommonPEModuleBuilder.cs index f3b74224ef3e8..e189afa01b5ab 100644 --- a/src/Compilers/Core/Portable/Emit/CommonPEModuleBuilder.cs +++ b/src/Compilers/Core/Portable/Emit/CommonPEModuleBuilder.cs @@ -30,7 +30,7 @@ internal abstract class CommonPEModuleBuilder : Cci.IUnit, Cci.IModuleReference internal Cci.IMethodReference DebugEntryPoint; private readonly ConcurrentDictionary _methodBodyMap; - private readonly TokenMap _referencesInILMap = new TokenMap(); + private readonly TokenMap _referencesInILMap = new TokenMap(MetadataEntityReferenceComparer.ConsiderEverything); private readonly ItemTokenMap _stringsInILMap = new ItemTokenMap(); private readonly ItemTokenMap _sourceDocumentsInILMap = new ItemTokenMap(); diff --git a/src/Compilers/Core/Portable/Emit/MetadataEntityReferenceComparer.cs b/src/Compilers/Core/Portable/Emit/MetadataEntityReferenceComparer.cs new file mode 100644 index 0000000000000..3cbe08d1960f9 --- /dev/null +++ b/src/Compilers/Core/Portable/Emit/MetadataEntityReferenceComparer.cs @@ -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 + { + 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; + } + } +} From 4f6fe5d384310014ba319b16f06722be4671f2df Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Fri, 30 Aug 2019 13:55:06 -0700 Subject: [PATCH 2/8] Support building the workspaces layer in source-build. Also added a verification step to CI to ensure we don't break the build. --- azure-pipelines.yml | 17 +++++++++++++++++ eng/build.ps1 | 6 ++++++ eng/build.sh | 6 ++++++ eng/targets/Settings.props | 4 ++++ .../Microsoft.CodeAnalysis.Workspaces.csproj | 3 ++- .../Storage/PersistenceStorageServiceFactory.cs | 5 +++++ 6 files changed, 40 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 32b320637289e..01ae2059cba99 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -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' diff --git a/eng/build.ps1 b/eng/build.ps1 index 6520919bba32f..baa24295b3a18 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -42,6 +42,7 @@ param ( [switch]$prepareMachine, [switch]$useGlobalNuGetCache = $true, [switch]$warnAsError = $false, + [switch]$sourceBuild = $false, # official build settings [string]$officialBuildId = "", @@ -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" @@ -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 ` @@ -258,6 +263,7 @@ function BuildSolution() { /p:IbcOptimizationDataDir=$ibcDir ` $suppressExtensionDeployment ` $msbuildWarnAsError ` + $buildFromSource ` @properties } finally { diff --git a/eng/build.sh b/eng/build.sh index d9f25b5046929..54a7dd2062d1c 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -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." } @@ -68,6 +69,7 @@ prepare_machine=false warn_as_error=false properties="" disable_parallel_restore=false +source_build=false docker=false args="" @@ -141,6 +143,9 @@ while [[ $# > 0 ]]; do shift continue ;; + --sourcebuild) + source_build=true + ;; /p:*) properties="$properties $1" ;; @@ -274,6 +279,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 diff --git a/eng/targets/Settings.props b/eng/targets/Settings.props index 584c19fb3a7c8..7aeedd9a6b2b8 100644 --- a/eng/targets/Settings.props +++ b/eng/targets/Settings.props @@ -194,4 +194,8 @@ + + + DotNetBuildFromSource + diff --git a/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj b/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj index c467c0c8df517..f98e1566adfeb 100644 --- a/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj +++ b/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj @@ -24,10 +24,11 @@ - + + Execution\Desktop\DesktopAnalyzerAssemblyLoader.cs diff --git a/src/Workspaces/Core/Portable/Storage/PersistenceStorageServiceFactory.cs b/src/Workspaces/Core/Portable/Storage/PersistenceStorageServiceFactory.cs index b92569a1a58bb..5942bfdd861c5 100644 --- a/src/Workspaces/Core/Portable/Storage/PersistenceStorageServiceFactory.cs +++ b/src/Workspaces/Core/Portable/Storage/PersistenceStorageServiceFactory.cs @@ -5,7 +5,10 @@ using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.SolutionSize; +// When building for source-build, there is no sqlite dependency +#if !DotNetBuildFromSource using Microsoft.CodeAnalysis.SQLite; +#endif namespace Microsoft.CodeAnalysis.Storage { @@ -22,6 +25,7 @@ public PersistenceStorageServiceFactory(ISolutionSizeTracker solutionSizeTracker public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) { +#if !DotNetBuildFromSource var optionService = workspaceServices.GetRequiredService(); var database = optionService.GetOption(StorageOptions.Database); switch (database) @@ -35,6 +39,7 @@ public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) break; } +#endif return NoOpPersistentStorageService.Instance; } From 0734dedeb976131eedd2e93a87d1c7268e5a7695 Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Fri, 30 Aug 2019 15:07:22 -0700 Subject: [PATCH 3/8] Use SourceBuild.sln --- eng/build.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/eng/build.sh b/eng/build.sh index 54a7dd2062d1c..4d6b92f593337 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -211,6 +211,9 @@ function MakeBootstrapBuild { function BuildSolution { local solution="Compilers.sln" + if [[ "$source_build" == true ]]; then + solution="SourceBuild.sln" + fi echo "$solution:" InitializeToolset From d754f770940a2e2463d700b1ad1bc2c31b75ad9c Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Fri, 30 Aug 2019 15:33:13 -0700 Subject: [PATCH 4/8] Add workspaces projects to SourceBuild.sln and don't remove DefineConstants. --- SourceBuild.sln | 52 ++++++++++++++++++++++++++++++++++++-- eng/targets/Settings.props | 2 +- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/SourceBuild.sln b/SourceBuild.sln index 71d7b261583f7..d4624933084bd 100644 --- a/SourceBuild.sln +++ b/SourceBuild.sln @@ -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 @@ -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 @@ -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 @@ -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} diff --git a/eng/targets/Settings.props b/eng/targets/Settings.props index 7aeedd9a6b2b8..777a9fcdda9e0 100644 --- a/eng/targets/Settings.props +++ b/eng/targets/Settings.props @@ -196,6 +196,6 @@ - DotNetBuildFromSource + $(DefineConstants);DotNetBuildFromSource From c5b18f36ce316d0bcc3bae40e3374f7e8a4d3ccb Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Fri, 30 Aug 2019 15:39:45 -0700 Subject: [PATCH 5/8] Condition targets that use InitializeSourceControlInformation on whether or not that target is available. --- eng/targets/Imports.targets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/targets/Imports.targets b/eng/targets/Imports.targets index 675b37eb44c04..fc72c1bfff441 100644 --- a/eng/targets/Imports.targets +++ b/eng/targets/Imports.targets @@ -87,7 +87,7 @@ + Condition="'$(GenerateMicrosoftCodeAnalysisCommitHashAttribute)' == 'true' AND '$(SourceControlInformationFeatureSupported)' == 'true'"> <_Parameter1 Condition="'$(OfficialBuild)' == 'true'">$(SourceRevisionId) @@ -186,7 +186,7 @@ + Condition="'$(IsPackable)' == 'true' AND '$(SourceControlInformationFeatureSupported)' == 'true'"> $(PackageDescription) From fb1e3ffb5a50ea1757494bf4370d953349864fa5 Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Fri, 30 Aug 2019 16:01:19 -0700 Subject: [PATCH 6/8] Format constant. --- eng/targets/Settings.props | 2 +- .../Core/Portable/Storage/PersistenceStorageServiceFactory.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/targets/Settings.props b/eng/targets/Settings.props index 777a9fcdda9e0..1880b137d8245 100644 --- a/eng/targets/Settings.props +++ b/eng/targets/Settings.props @@ -196,6 +196,6 @@ - $(DefineConstants);DotNetBuildFromSource + DOTNET_BUILD_FROM_SOURCE;$(DefineConstants) diff --git a/src/Workspaces/Core/Portable/Storage/PersistenceStorageServiceFactory.cs b/src/Workspaces/Core/Portable/Storage/PersistenceStorageServiceFactory.cs index 5942bfdd861c5..b865645649471 100644 --- a/src/Workspaces/Core/Portable/Storage/PersistenceStorageServiceFactory.cs +++ b/src/Workspaces/Core/Portable/Storage/PersistenceStorageServiceFactory.cs @@ -6,7 +6,7 @@ using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.SolutionSize; // When building for source-build, there is no sqlite dependency -#if !DotNetBuildFromSource +#if !DOTNET_BUILD_FROM_SOURCE using Microsoft.CodeAnalysis.SQLite; #endif @@ -25,7 +25,7 @@ public PersistenceStorageServiceFactory(ISolutionSizeTracker solutionSizeTracker public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) { -#if !DotNetBuildFromSource +#if !DOTNET_BUILD_FROM_SOURCE var optionService = workspaceServices.GetRequiredService(); var database = optionService.GetOption(StorageOptions.Database); switch (database) From 46a46661563cc5bbc382576e0f49faa30a9ca87d Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Fri, 30 Aug 2019 16:49:41 -0700 Subject: [PATCH 7/8] Fix DefineConstants for vbc --- eng/targets/Settings.props | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/eng/targets/Settings.props b/eng/targets/Settings.props index 1880b137d8245..60bda23f7c0c4 100644 --- a/eng/targets/Settings.props +++ b/eng/targets/Settings.props @@ -196,6 +196,8 @@ - DOTNET_BUILD_FROM_SOURCE;$(DefineConstants) + + DOTNET_BUILD_FROM_SOURCE;$(DefineConstants) + DOTNET_BUILD_FROM_SOURCE From db910a7f4a057151dae1c9b30efabe5c5ec005a9 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Sun, 1 Sep 2019 08:02:52 -0700 Subject: [PATCH 8/8] Move to a newer FlowAnalysis utilities package This addresses the memory leak in #38330. The underlying memory leak was fixed in the FlowAnalysis utilities assembly with https://github.com/dotnet/roslyn-analyzers/pull/2795. This PR just moves to newer Roslyn Flow analysis utilities package reference with the fix. Fixes #38330 --- eng/Versions.props | 2 +- .../DisposableFieldsShouldBeDisposedDiagnosticAnalyzer.cs | 2 +- .../DisposeObjectsBeforeLosingScopeDiagnosticAnalyzer.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/Versions.props b/eng/Versions.props index 2ef98e4cb76cb..af1dcb0ea7ffe 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -59,7 +59,7 @@ 2.0.18 $(MicrosoftCodeAnalysisTestingVersion) $(CodeStyleAnalyzerVersion) - 2.9.4 + 2.9.5 $(RoslynDiagnosticsNugetPackageVersion) 1.0.31 4.3.0 diff --git a/src/Features/Core/Portable/DisposeAnalysis/DisposableFieldsShouldBeDisposedDiagnosticAnalyzer.cs b/src/Features/Core/Portable/DisposeAnalysis/DisposableFieldsShouldBeDisposedDiagnosticAnalyzer.cs index d9c71251953fe..3b24d09999b32 100644 --- a/src/Features/Core/Portable/DisposeAnalysis/DisposableFieldsShouldBeDisposedDiagnosticAnalyzer.cs +++ b/src/Features/Core/Portable/DisposeAnalysis/DisposableFieldsShouldBeDisposedDiagnosticAnalyzer.cs @@ -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; diff --git a/src/Features/Core/Portable/DisposeAnalysis/DisposeObjectsBeforeLosingScopeDiagnosticAnalyzer.cs b/src/Features/Core/Portable/DisposeAnalysis/DisposeObjectsBeforeLosingScopeDiagnosticAnalyzer.cs index 6619f64c77a2f..6306ae98e2afd 100644 --- a/src/Features/Core/Portable/DisposeAnalysis/DisposeObjectsBeforeLosingScopeDiagnosticAnalyzer.cs +++ b/src/Features/Core/Portable/DisposeAnalysis/DisposeObjectsBeforeLosingScopeDiagnosticAnalyzer.cs @@ -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);