Analyzer
Diagnostic ID: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0004:
Remove unnecessary cast
Analyzer source
SDK: Built-in CA analyzers in .NET 5 SDK or later
Version: SDK 5.0.100
Describe the bug
With the <Nullable>enable</Nullable> parameter ON, a cast to a non-nullable might be necessary.
The analyzer proposes to remove an unnecessary cast from this code.
static IEnumerable<string> DoThis(IEnumerable<string?> notreallynull)
{
return notreallynull.Where(s => s is not null) as IEnumerable<string>;
}
Expected behavior
The analyzer should not say unnecessary in that situation.
Analyzer
Diagnostic ID: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0004:
Remove unnecessary castAnalyzer source
SDK: Built-in CA analyzers in .NET 5 SDK or later
Version: SDK 5.0.100
Describe the bug
With the
<Nullable>enable</Nullable>parameter ON, a cast to a non-nullable might be necessary.The analyzer proposes to remove an unnecessary cast from this code.
Expected behavior
The analyzer should not say
unnecessaryin that situation.