Replace NET8_0_OR_GREATER with NET across all source files#118363
Replace NET8_0_OR_GREATER with NET across all source files#118363
Conversation
Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
NET8_0_OR_GREATER symbol|
@copilot, these two as well: |
@am11 NET8_0 != NET8_0_OR_GREATER. I do not think it would be correct that change these. |
There was a problem hiding this comment.
Pull Request Overview
This PR systematically replaces all 258 occurrences of the conditional compilation symbol NET8_0_OR_GREATER with NET across 114 source files. This is a cleanup change that takes advantage of the fact that .NET 8.0 is now the minimum supported version, making the simpler NET symbol equivalent to NET8_0_OR_GREATER in all supported scenarios.
Key changes:
- Replacement of
#if NET8_0_OR_GREATERwith#if NETthroughout the codebase - Corresponding updates to
#if !NET8_0_OR_GREATER→#if !NET - Updates to comment references in
#endifstatements
Reviewed Changes
Copilot reviewed 115 out of 115 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/tasks/Common/JoinedString.cs | Updates conditional compilation for interpolated string handlers |
| src/libraries/System.Windows.Extensions/src/System/Media/SoundPlayer.cs | Updates obsolete attribute conditional compilation |
| src/libraries/System.Threading.Tasks.Dataflow/src/Internal/DataflowEtwProvider.cs | Updates conditional compilation for event logging |
| src/libraries/System.Threading.RateLimiting/src/System/Threading/RateLimiting/DefaultPartitionedRateLimiter.cs | Updates ConfigureAwait options conditional compilation |
| src/libraries/System.Threading.Channels/src/System/Threading/Channels/ChannelClosedException.netcoreapp.cs | Updates exception serialization attributes |
| src/libraries/System.Text.Json/src/System/Text/Json/Writer/JsonWriterHelper.cs | Updates UTF-8 validation and encoding conditionals |
| src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/VersionConverter.cs | Updates span allocation for version formatting |
| src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderHelper.cs | Updates search values and line counting logic |
| src/libraries/System.Text.Json/src/System/Text/Json/JsonException.cs | Updates exception serialization attributes |
| src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParseException.cs | Updates exception serialization attributes |
| Various System.Security.* libraries | Updates exception serialization attributes across security components |
| Various System.DirectoryServices.* libraries | Updates exception serialization attributes for directory services |
| Various configuration and data libraries | Updates exception serialization and utility method conditionals |
| Test files | Updates test conditional compilation for .NET version-specific features |
|
/ba-g test was disabled and tracked in #114912 |
1 similar comment
|
/ba-g test was disabled and tracked in #114912 |
|
Some of these directives could have been removed entirely, see #118421 for context. It looks like Copilot may have overlooked that detail. |
Since .NET 8.0 is now the minimum supported version (as defined by
NetCoreAppMinimum = net8.0in Directory.Build.props), the conditional compilation symbolNET8_0_OR_GREATERcan be simplified toNETthroughout the codebase.Changes Made
This PR systematically replaces all 258 occurrences of
NET8_0_OR_GREATERacross 114 source files with the simplerNETsymbol. The changes include:#if NET8_0_OR_GREATER→#if NET#if !NET8_0_OR_GREATER→#if !NET#elif NET8_0_OR_GREATER→#elif NET#endif // NET8_0_OR_GREATER→#endif // NET#endif // !NET8_0_OR_GREATER→#endif // !NETRationale
The replacement is safe because:
NETsymbol is defined for .NET 5+ and since we now require .NET 8.0 minimum, any .NET target will be .NET 8.0 or greaterNET8_0_OR_GREATERnorNETare defined, so the conditional compilation behavior remains unchangedExamples
Before:
After:
Affected Libraries
The changes span across many core libraries including:
Verification
Fixes #109226.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.