You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
C#10 introduced the ability to declare and use parameterless struct constructors, which means new Struct() and default(Struct) can be different. Consider the following code sample,
using System;
X.L();// 12
X.K();// 0internalstructX{publicintI;publicX(){I=12;}publicstaticvoidL(){
Console.WriteLine(new X().I);}publicstaticvoidK(){
Console.WriteLine(default(X).I);}}
I believe that SA1129 "A value type was constructed using the syntax new T()." should not be removed, rather, it should check whether the struct defines a parameterless constructor before raising any warnings
The text was updated successfully, but these errors were encountered:
C#10 introduced the ability to declare and use parameterless struct constructors, which means
new Struct()
anddefault(Struct)
can be different. Consider the following code sample,I believe that SA1129 "A value type was constructed using the syntax
new T()
." should not be removed, rather, it should check whether the struct defines a parameterless constructor before raising any warningsThe text was updated successfully, but these errors were encountered: