-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
The repository contains redundant #if NET conditional compilation directives. This check is unnecessary when a file is only compiled in a .NET (not NET Standard/Framework) build configuration. In any .NET build the NET symbol will always be defined, making the #if NET block effectively always true and thus redundant.
Example
In HuffmanDecodingException.cs, the following code is wrapped in an unnecessary #if NET directive:
runtime/src/libraries/Common/src/System/Net/Http/aspnetcore/Http2/Hpack/HuffmanDecodingException.cs
Lines 22 to 24 in e399fff
| #if NET | |
| [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] | |
| #endif |
However, this file is only compiled in the NetCoreAppCurrent build configuration:
| <TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-linux;$(NetCoreAppCurrent)-osx;$(NetCoreAppCurrent)-freebsd;$(NetCoreAppCurrent)-maccatalyst;$(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-tvos;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent)-illumos;$(NetCoreAppCurrent)-solaris;$(NetCoreAppCurrent)-haiku;$(NetCoreAppCurrent)-android;$(NetCoreAppCurrent)</TargetFrameworks> |
Since that configuration targets .NET 10, the NET symbol is always defined, and the directive can be safely removed.