-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Remove NET9_0_OR_GREATER and NET10_0_OR_GREATER preprocessor constants #122953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Tagging subscribers to this area: @dotnet/area-meta |
…oreLib Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
|
@copilot, what about NET8_0_OR_GREATER, NET7_0_OR_GREATER, NET6_0_OR_GREATER, etc. Any of those that also need to be cleaned up? |
src/libraries/System.Numerics.Tensors/ref/System.Numerics.Tensors.netcore.cs
Outdated
Show resolved
Hide resolved
I searched for |
|
@copilot, there are build failures, e.g. |
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
…hared files Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
... Fixed in 156bd27. The issue was that files like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR performs a systematic cleanup of obsolete .NET version-specific preprocessor constants (NET9_0_OR_GREATER and NET10_0_OR_GREATER) since the repository no longer builds for .NET versions older than 10. The changes follow a clear strategy based on file location and target frameworks.
Key changes:
- System.Private.CoreLib files: Replace version constants with
#if NETto maintain compatibility with packages targeting netstandard/netframework - Files in netcore directories or ending in
netcore.cs: Remove conditionals entirely as they only build for .NET Core - Other multi-target files: Replace with
#if NETto distinguish between .NET Core and netstandard/netframework
Reviewed changes
Copilot reviewed 89 out of 89 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| System.Threading.Channels/AsyncOperation.cs | Replaced NET9_0_OR_GREATER with NET for bool/int field type selection |
| System.Text.Json/EnumConverter.cs | Replaced NET9_0_OR_GREATER with NET for alternate lookup APIs |
| System.Text.Json/JsonHelpers.cs | Replaced NET9_0_OR_GREATER with NET for dictionary alternate lookup |
| System.Security.Cryptography.Xml/SignedXmlDebugLog.cs | Replaced NET9_0_OR_GREATER with NET for ToHexStringLower usage |
| System.Security.Cryptography.Pkcs/SignerInfo.cs | Replaced NET9_0_OR_GREATER with NET for AsnWriter.Encode callback |
| System.Private.CoreLib (IAsyncEnumerable/Enumerator) | Replaced NET9_0_OR_GREATER/NET10_0_OR_GREATER with NET for ref struct constraints |
| System.Private.CoreLib/Base64 helpers | Removed NET9_0_OR_GREATER conditionals around CompExactlyDependsOn attributes and ARM intrinsics |
| System.Numerics.Tensors/netcore files | Removed all version conditionals as these only build for .NET Core |
| System.Numerics.Tensors reference assembly | Replaced NET9_0_OR_GREATER with NET for allows ref struct constraints |
| System.Formats.Nrbf/Asn1 | Replaced NET9_0_OR_GREATER/NET10_0_OR_GREATER with NET |
| System.DirectoryServices.Protocols | Replaced NET10_0_OR_GREATER with NET for Obsolete attributes |
| System.Diagnostics.DiagnosticSource | Replaced NET9_0_OR_GREATER with NET for Activity/MeterListener |
| System.Collections.Immutable | Replaced NET9_0_OR_GREATER with NET for allows ref struct constraints |
| Microsoft.Extensions.* | Replaced version constants with NET for various features |
| Microsoft.Bcl.* | Replaced version constants and adjusted type forwards |
| Common/src/System | Replaced NET10_0_OR_GREATER with NET in crypto helpers and HexConverter |
All changes appear to be systematic and consistent with the stated strategy. The PR correctly maintains compatibility for packages that target netstandard/netframework while simplifying conditional compilation for .NET Core-only code.
…nstead of NET10_0_OR_GREATER Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/IReadOnlyTensor_1.cs
Show resolved
Hide resolved
Co-authored-by: MihaZupan <25307628+MihaZupan@users.noreply.github.com>
|
@copilot, please search the repo for any remaining NET9_0_OR_GREATER or NET10_0_OR_GREATER constants in any files. |
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Found and fixed 18 remaining occurrences in test files (commit 6a4b0e8):
All replaced with |
@copilot, are there remaining uses elsewhere than src/libraries? |
No, there are no remaining occurrences anywhere in the repo. I searched the entire repository (excluding |
Cleanup of .NET Version Constants
The repo no longer builds for .NET Core versions older than 10. This PR removes obsolete version-specific preprocessor constants (
NET9_0_OR_GREATER,NET10_0_OR_GREATER).Strategy
For files that only build for .NET 10+ runtime (System.Private.CoreLib):
#if NET9_0_OR_GREATER/#if NET10_0_OR_GREATERwith#if NETMicrosoft.Bcl.AsyncInterfaceswhich target netstandard/netframeworkFor files in
netcoredirectories or ending innetcore.cs:#if NETchecks are removed entirely and code is made unconditional#ifdirectivesFor other files that also build for netstandard/netframework:
NET9_0_OR_GREATER/NET10_0_OR_GREATERwith justNET#if NET ... #else ... #endifstructureFor test files:
NET9_0_OR_GREATER/NET10_0_OR_GREATERwithNETsince test projects target both .NET Core and .NET FrameworkFiles Changed
Source files:
#if NET ... #elsestructure)Test files:
Note: Searched for older version constants (
NET8_0_OR_GREATER,NET7_0_OR_GREATER,NET6_0_OR_GREATER, etc.) - none were found in the source files.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.