Update Microsoft.CodeAnalysis.Collections et al.#12161
Merged
YuliiaKovalova merged 6 commits intodotnet:mainfrom Jul 14, 2025
Merged
Update Microsoft.CodeAnalysis.Collections et al.#12161YuliiaKovalova merged 6 commits intodotnet:mainfrom
Microsoft.CodeAnalysis.Collections et al.#12161YuliiaKovalova merged 6 commits intodotnet:mainfrom
Conversation
…ramework` and use it for some polyfills. Fixes duplicate type definition warnings.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR updates the Roslyn collections package and adjusts how its polyfills are consumed across the Microsoft.Build and Microsoft.Build.Framework projects.
- Bump Microsoft.CodeAnalysis.Collections to 5.0.0-1.25277.114 and bring in its new dependencies (
ContractsandPooledObjects) - Move the
CodeAnalysis.Collectionspackage reference from MSBuild.Framework to MSBuild and remove duplicate polyfills - Remove legacy nullable-attributes polyfills now provided by the updated contracts package
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Shared/IsExternalInit.cs | Added assembly type-forward for IsExternalInit on .NET and kept the old polyfill for earlier TFMs |
| src/Framework/Polyfills/NullableAttributes.cs | Deleted all nullable attribute polyfills, relying on Microsoft.CodeAnalysis.Contracts instead |
| src/Framework/Microsoft.Build.Framework.csproj | Replaced the Collections reference with Contracts and added System.Collections.Immutable |
| src/Framework/AssemblyUtilities.cs | Removed duplicate IsExternalInit polyfill |
| src/Build/Microsoft.Build.csproj | Added CodeAnalysis.Collections and PooledObjects refs; commented out manual IsExternalInit compile |
| eng/Versions.props | Bumped MicrosoftCodeAnalysisCollectionsVersion to 5.0.0-1.25277.114 |
| eng/Packages.props | Added package versions for Contracts and PooledObjects |
Comments suppressed due to low confidence (1)
eng/Packages.props:13
- [nitpick] The Contracts and PooledObjects packages share the Collections version variable; consider introducing dedicated version properties to reduce confusion if package versions diverge in the future.
<PackageVersion Include="Microsoft.CodeAnalysis.Contracts" Version="$(MicrosoftCodeAnalysisCollectionsVersion)" />
JanProvaznik
approved these changes
Jul 14, 2025
YuliiaKovalova
approved these changes
Jul 14, 2025
Microsoft.CodeAnalysis.Collections et. al.Microsoft.CodeAnalysis.Collections et al.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
The
Microsoft.Buildproject has a dependency on theMicrosoft.CodeAnalysis.Collectionssource-only package, but that package is depended on by theMicrosoft.Build.Frameworkproject, and gets transitively consumed byBuild.In #11109, as an effort to reduce the size of the
Frameworkassembly, I tried to move the dependency to a direct one onBuild. This led to failures that would be fixed in a newer version ofMicrosoft.CodeAnalysis.Collections. Because the update is more involved than a simple version bump, I extracted that change from #11109 into its own PR.Changes Made
Microsoft.CodeAnalysis.Collectionsdependency updated to 5.0.0-1.25277.114, released a month ago.Microsoft.CodeAnalysis.ContractsandPooledObjects, that are required by the above.Microsoft.CodeAnalysis.Collectionsfrom theMicrosoft.Build.Frameworkproject toMicrosoft.Build.Microsoft.Build.Frameworkto theSystem.Collections.Immutablepackage.Microsoft.CodeAnalysis.Contracts.Testing
Build-only change, validated by successfully building
Microsoft.Buildlocally.Notes