Version Used:
Microsoft.CodeAnalysis.CSharp.NetAnalyzers 5.0.102
Microsoft.CodeAnalysis.NetAnalyzers 5.0.102
Steps to Reproduce:
Write the following code:
public static class StructExtensions
{
public static T? ToNullable<T>(this T value)
where T : struct
=> new T?(value);
}
Expected Behavior:
Code fixes offered should be for correct code.
Actual Behavior:
Roslyn suggests "IDE0090: 'new' expression can be simplified" on the new T?(value) expression in the above code snippet. It suggests the code fix new(value). However, applying this change results in an error, "CS0417: 'T': cannot provide arguments when created an instance of a variable type".
Version Used:
Microsoft.CodeAnalysis.CSharp.NetAnalyzers5.0.102Microsoft.CodeAnalysis.NetAnalyzers5.0.102Steps to Reproduce:
Write the following code:
Expected Behavior:
Code fixes offered should be for correct code.
Actual Behavior:
Roslyn suggests "IDE0090: 'new' expression can be simplified" on the
new T?(value)expression in the above code snippet. It suggests the code fixnew(value). However, applying this change results in an error, "CS0417: 'T': cannot provide arguments when created an instance of a variable type".