-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Remove redundant #if NET
directives from .NET-only files
#118424
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
…asses Co-authored-by: jkotas <[email protected]>
Co-authored-by: jkotas <[email protected]>
#if NET
directives#if NET
directives from .NET-only exception classes
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.
LGTM
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 removes redundant #if NET
conditional compilation directives from exception classes that are only compiled in .NET builds, making the code cleaner and more maintainable.
- Removed
#if NET
blocks around[Obsolete]
attributes for legacy serialization methods - Changes affect 4 exception classes in HTTP and network libraries
- No functional changes - the
[Obsolete]
attributes are now always applied as intended
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
File | Description |
---|---|
NetworkInformationException.cs | Removed 1 redundant #if NET block around obsolete serialization constructor |
QPackEncodingException.cs | Removed 1 redundant #if NET block around obsolete serialization constructor |
QPackDecodingException.cs | Removed 1 redundant #if NET block around obsolete serialization constructor |
HuffmanDecodingException.cs | Removed 3 redundant #if NET blocks around obsolete serialization constructor and GetObjectData methods |
Tagging subscribers to this area: @dotnet/ncl |
@copilot Your analysis currently focuses on instances of the "#if NET" pattern. To ensure a more comprehensive evaluation, consider generalizing your search logic to detect all redundant or unnecessary uses of the |
@xtqqczze Copilot won't listed to external contributors. |
@copilot Your analysis currently focuses on instances of the "#if NET" pattern. To ensure a more comprehensive evaluation, consider generalizing your search logic to detect all redundant or unnecessary uses of the NET symbol, including inverse conditions such as #if !NET and other conditional forms. |
….NET-only files Co-authored-by: jkotas <[email protected]>
Expanded the search beyond
These Commit: 3db9939 |
#if NET
directives from .NET-only exception classes#if NET
directives from .NET-only files
/ba-g intermittent network issue |
This PR removes redundant
#if NET
conditional compilation directives from files that are only compiled in .NET builds, making the code cleaner and more maintainable.Files Changed
Exception Classes (aspnetcore shared folder):
HuffmanDecodingException.cs
- removed 3 redundant#if NET
blocks around[Obsolete]
attributesQPackEncodingException.cs
- removed 1 redundant#if NET
block around[Obsolete]
attributeQPackDecodingException.cs
- removed 1 redundant#if NET
block around[Obsolete]
attributeNetwork Exception Class:
NetworkInformationException.cs
- removed 1 redundant#if NET
block around[Obsolete]
attribute.NET-Only Reference Files:
System.Text.Json.netcoreapp.cs
- removed 1 redundant#if NET
block around Int128/UInt128 converter propertiesSystem.Security.Permissions.netcoreapp.cs
- removed 1 redundant#if NET
block around XamlLoadPermission obsolete attributeRationale
These files are only included in .NET builds where the
NET
symbol is always defined:$(NetCoreAppCurrent)
and its platform-specific variantsNetworkInformationException.cs
is in Common folder but only used in .NET-only contexts.netcoreapp.cs
files are conditionally included only when'$(TargetFrameworkIdentifier)' == '.NETCoreApp'
Since the
NET
symbol is always defined in these build contexts, the#if NET
conditionals are always true and therefore redundant.Testing
[Obsolete]
attributes and properties are now always applied as intendedFixes #118421.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.