Tracking: avoid suppressing SYSLIB0001 in shipping sources
See original GitHub issueThere are a few cases in the sources where aspnet is comparing if (encoding == Encoding.UTF7) { /* do something */ }
. Since this accesses the Encoding.UTF7
property getter, a warning is produced.
From https://github.com/dotnet/docs/issues/19274:
If you’re trying to compare an Encoding
instance against Encoding.UTF7
, consider instead performing a check against the well-known UTF-7 code page (65000
). This has the dual advantage that it both avoids the warning and handles some edge cases (such as somebody having subclassed UTF7Encoding
).
void DoSomething(Encoding enc)
{
// don't perform the check this way; it produces a warning and misses some edge cases
if (enc == Encoding.UTF7)
{
// encoding is UTF-7
}
// instead, perform the check this way
if (enc != null && enc.CodePage == 65000)
{
// encoding is UTF-7
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Obsoletion of UTF-7 code paths within the framework · ...
UTF7 or UTF7Encoding , you can suppress the SYSLIB0001 warning in code or ... Tracking: avoid suppressing SYSLIB0001 in shipping sources ...
Read more >SYSLIB0001 warning - .NET
To suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the warning. C# Copy. // ......
Read more >Breaking change: UTF-7 code paths are obsolete - .NET
Suppressing SYSLIB0001 only disables the Encoding.UTF7 and UTF7Encoding obsoletion warnings. It doesn't disable any other warnings or change the ...
Read more >7124b168cc7e0c6a11120728ad...
dotnet nuget disable source ... How to: Prevent a Child Task from Attaching to its Parent Dataflow ... sudo apt-get install -y apt-transport-https...
Read more >Net | PDF | Xml | Microsoft Visual Studio
How to suppress warnings ... How to: Prevent a Child Task from Attaching to its Parent ... NET Core 3.0 shipped in September...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Fixed via https://github.com/dotnet/aspnetcore/pull/28913
Thanks for contacting us. We’re moving this issue to the
Next sprint planning
milestone for future evaluation / consideration. We will evaluate the request when we are planning the work for the next milestone. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.