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
{{ message }}
Repository navigation
SA1118: Fails when using new(){...} but not new myObject{...} #3339
public class MyClass
{
public class MyObject
{
public string MyValue { get; init; }
}
public void MyTestFunctionOk()
{
MyCallingFunction(0, new MyObject
{
MyValue = "Test"
});
}
public void MyTestFunctionNotOk()
{
MyCallingFunction(0, new()
{
MyValue = "Test"
});
}
public void MyCallingFunction(int index, MyObject myObject)
{
Console.WriteLine($"{index}: {myObject}");
}
}
these are syntactically the same, except one states the object type in the initialisation, and one does not, yet MyTestFunctionNotOk gives a SA1118 warning
changed the title [-]SA1118: Fails when using `new{}` but not `new myObject{}`[/-][+]SA1118: Fails when using `new(){}` but not `new myObject{}`[/+]on Apr 28, 2021
changed the title [-]SA1118: Fails when using `new(){}` but not `new myObject{}`[/-][+]SA1118: Fails when using `new(){...}` but not `new myObject{...}`[/+]on Apr 28, 2021
Activity
[-]SA1118: Fails when using `new{}` but not `new myObject{}`[/-][+]SA1118: Fails when using `new(){}` but not `new myObject{}`[/+][-]SA1118: Fails when using `new(){}` but not `new myObject{}`[/-][+]SA1118: Fails when using `new(){...}` but not `new myObject{...}`[/+]