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
e.g. this isn't caught at compile (but is caught at runtime)
vargt=newGenericThing<MyVo>();varv1=gt.GetNewItem();varv2=gt.GetMe<MyVo>();Console.WriteLine(v1.Value);// bang! use of uninitalized objectConsole.WriteLine(v2.Value);// bang! use of uninitalized object[ValueObject(typeof(int))]publicpartialrecordMyVo;publicclassGenericThing<T>whereT:new(){publicXGetMe<X>()whereX:new()=>default!;publicTGetNewItem()=>newT();}
Note the above has generic new() constraint at the class level and method level, so need to check for both.
We need to find invocations of methods where the target method is generic (don't need to check parameters), and the return value is the generic type, and the generic type has a new() constraint.
The text was updated successfully, but these errors were encountered:
Had a quick stab at this. It won't work with a semantic compilationContext.RegisterOperationAction(AnalyzeExpression, OperationKind.ObjectCreation) - it needs to use syntax, and then get the model, and then get the generic type.
Describe the feature
e.g. this isn't caught at compile (but is caught at runtime)
Note the above has generic new() constraint at the class level and method level, so need to check for both.
We need to find invocations of methods where the target method is generic (don't need to check parameters), and the return value is the generic type, and the generic type has a
new()
constraint.The text was updated successfully, but these errors were encountered: