Skip to content

Commit 2e0a8ee

Browse files
Update Microsoft.CodeAnalysis.Collections et al. (dotnet#12161)
* Update `Microsoft.CodeAnalysis.Collections` and move reference to `Microsoft.Build`. * Use unified polyfill of `IsExternalInit`. * Move `Microsoft.CodeAnalysis.Contracts` dependency from `Build` to `Framework` and use it for some polyfills. Fixes duplicate type definition warnings. * Remove commented out code. * Fix compile errors in `MSBuildTaskHost`. --------- Co-authored-by: YuliiaKovalova <95473390+YuliiaKovalova@users.noreply.github.com>
1 parent a8f1bc9 commit 2e0a8ee

8 files changed

Lines changed: 25 additions & 13 deletions

File tree

eng/Packages.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
<ItemGroup>
1111
<PackageVersion Include="Microsoft.Build.NuGetSdkResolver" Version="$(NuGetBuildTasksVersion)" />
1212
<PackageVersion Include="Microsoft.CodeAnalysis.Collections" Version="$(MicrosoftCodeAnalysisCollectionsVersion)" />
13+
<PackageVersion Include="Microsoft.CodeAnalysis.Contracts" Version="$(MicrosoftCodeAnalysisCollectionsVersion)" />
14+
<PackageVersion Include="Microsoft.CodeAnalysis.PooledObjects" Version="$(MicrosoftCodeAnalysisCollectionsVersion)" />
1315
<PackageVersion Include="Microsoft.DotNet.XUnitExtensions" Version="$(MicrosoftDotNetXUnitExtensionsVersion)" />
1416
<PackageVersion Include="Microsoft.IO.Redist" Version="$(MicrosoftIORedistVersion)" />
1517
<PackageVersion Include="Microsoft.Net.Compilers.Toolset" Version="$(MicrosoftNetCompilersToolsetVersion)" Condition="'$(UsingToolMicrosoftNetCompilers)' != 'true'" />

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
<!-- DotNetCliVersion MUST match the dotnet version in global.json.
8080
Otherwise, this version of dotnet will not be installed and the build will error out. -->
8181
<DotNetCliVersion>$([System.Text.RegularExpressions.Regex]::Match($([System.IO.File]::ReadAllText('$(MSBuildThisFileDirectory)..\global.json')), '"dotnet": "([^"]*)"').Groups.get_Item(1))</DotNetCliVersion>
82-
<MicrosoftCodeAnalysisCollectionsVersion>4.2.0-1.22102.8</MicrosoftCodeAnalysisCollectionsVersion>
82+
<MicrosoftCodeAnalysisCollectionsVersion>5.0.0-1.25277.114</MicrosoftCodeAnalysisCollectionsVersion>
8383
<MicrosoftDotNetXUnitExtensionsVersion>10.0.0-beta.25358.3</MicrosoftDotNetXUnitExtensionsVersion>
8484
<NuGetBuildTasksVersion>6.15.0-preview.1.86</NuGetBuildTasksVersion>
8585
<MicrosoftNetCompilersToolsetVersion>5.0.0-1.25361.3</MicrosoftNetCompilersToolsetVersion>

src/Build/Microsoft.Build.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838

3939
<PackageReference Include="Microsoft.IO.Redist" Condition="'$(FeatureMSIORedist)' == 'true'" />
4040

41+
<PackageReference Include="Microsoft.CodeAnalysis.Collections" PrivateAssets="all" />
42+
<PackageReference Include="Microsoft.CodeAnalysis.PooledObjects" PrivateAssets="all" />
4143
<PackageReference Include="Microsoft.BuildXL.Processes" Condition="'$(FeatureReportFileAccesses)' == 'true'" PrivateAssets="all" />
4244
<!-- Remove the direct NETStandard.Library dependency when Microsoft.BuildXL.Processes stops bringing in netstandard1.x dependencies
4345
or when a .NET 10 SDK is used (NuGet Package Pruning eliminates netstandard1.x dependencies). -->
@@ -124,9 +126,6 @@
124126
<Compile Include="..\Shared\TaskLoggingHelperExtension.cs">
125127
<Link>BackEnd\Components\RequestBuilder\IntrinsicTasks\TaskLoggingHelperExtension.cs</Link>
126128
</Compile>
127-
<Compile Include="..\Shared\IsExternalInit.cs">
128-
<Link>BuildCheck\Utilities\IsExternalInit.cs</Link>
129-
</Compile>
130129
<Compile Include="..\Shared\TaskParameter.cs" />
131130
<Compile Include="..\Shared\TaskParameterTypeVerifier.cs" />
132131
<Compile Include="..\Shared\TranslatorHelpers.cs" />

src/Framework/AssemblyUtilities.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,8 @@
1010
using Microsoft.Build.Framework;
1111
#endif
1212

13-
14-
// Declare this to get init properties. See https://github.com/dotnet/roslyn/issues/45510#issuecomment-694977239
1513
#nullable disable
1614

17-
namespace System.Runtime.CompilerServices
18-
{
19-
internal static class IsExternalInit { }
20-
}
21-
2215
namespace Microsoft.Build.Shared
2316
{
2417
/// <summary>

src/Framework/Microsoft.Build.Framework.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</PropertyGroup>
1616

1717
<ItemGroup>
18-
<PackageReference Include="Microsoft.CodeAnalysis.Collections" PrivateAssets="all" />
18+
<PackageReference Include="Microsoft.CodeAnalysis.Contracts" PrivateAssets="all" />
1919
</ItemGroup>
2020

2121
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
@@ -29,8 +29,9 @@
2929
<PackageReference Include="Microsoft.VisualStudio.OpenTelemetry.ClientExtensions" PrivateAssets="all" />
3030
</ItemGroup>
3131

32-
<!-- Framework and standard don't have DiagnosticSource. -->
32+
<!-- Framework and standard don't have these. -->
3333
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' OR '$(TargetFrameworkIdentifier)' == '.NETStandard'">
34+
<PackageReference Include="System.Collections.Immutable" />
3435
<PackageReference Include="System.Diagnostics.DiagnosticSource" />
3536
</ItemGroup>
3637

src/MSBuildTaskHost/MSBuildTaskHost.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
<Link>CopyOnWriteDictionary.cs</Link>
7171
</Compile>
7272
<Compile Include="..\Shared\Constants.cs" />
73+
<Compile Include="..\Shared\IsExternalInit.cs" />
7374
<Compile Include="..\Shared\EnvironmentUtilities.cs" Link="EnvironmentUtilities.cs" />
7475
<Compile Include="..\Shared\ReadOnlyEmptyDictionary.cs" />
7576
<Compile Include="..\Framework\ErrorUtilities.cs">
@@ -202,6 +203,7 @@
202203
<Compile Include="Concurrent\ConcurrentDictionary.cs" />
203204
<Compile Include="Concurrent\ConcurrentQueue.cs" />
204205
<Compile Include="Immutable\ImmutableDictionary.cs" />
206+
<Compile Include="NullableAttributes.cs" />
205207
<Compile Include="Properties\AssemblyInfo.cs" />
206208
<Compile Include="TypeLoader.cs" />
207209
<Compile Include="..\MSBuild\LogMessagePacket.cs">

src/Framework/Polyfills/NullableAttributes.cs renamed to src/MSBuildTaskHost/NullableAttributes.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
// This was copied from https://github.com/dotnet/runtime/blob/39b9607807f29e48cae4652cd74735182b31182e/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/NullableAttributes.cs
55
// and updated to have the scope of the attributes be internal.
6+
// This file is used only by MSBuildTaskHost; other projects should get the polyfills from the
7+
// Microsoft.CodeAnalysis.Contracts package, through the Microsoft.Build.Framework project.
68

79
#nullable disable
810

src/Shared/IsExternalInit.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
#if NET
5+
using System.Runtime.CompilerServices;
6+
7+
// Type-forward to the inbox class where available, in order to maintain binary compatibility
8+
// between the .NET and .NET Standard 2.0 assemblies.
9+
[assembly: TypeForwardedTo(typeof(IsExternalInit))]
10+
11+
#else
12+
13+
using System.ComponentModel;
14+
415
namespace System.Runtime.CompilerServices
516
{
617
// Needed so we can use init setters in full fw or netstandard
718
// (details: https://developercommunity.visualstudio.com/t/error-cs0518-predefined-type-systemruntimecompiler/1244809)
19+
[EditorBrowsable(EditorBrowsableState.Never)]
820
internal static class IsExternalInit { }
921
}
22+
#endif

0 commit comments

Comments
 (0)