Create a library using netstandard2.0 and <LangVersion>preview</LangVersion>
Insert following snippet code
public static void RaisesWarning()
{
using var aesEncryption = new RijndaelManaged
{
KeySize = 128
};
}
public static void DoesNotRaiseWarning()
{
using (var aesEncryption = new RijndaelManaged
{
KeySize = 128
}) {}
}
Expected behavior
Either both methods generate CA2000, or neither.
Actual behavior
Only the method with a using declaration generates a CA2000 warning.
Analyzer package
Microsoft.CodeAnalysis.FxCopAnalyzers
Package Version
v2.9.3 (Latest)
Diagnostic ID
CA2000
Repro steps
<LangVersion>preview</LangVersion>
Expected behavior
Either both methods generate CA2000, or neither.
Actual behavior
Only the method with a using declaration generates a CA2000 warning.