diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1118CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1118CSharp9UnitTests.cs index bcbec918d4..9974f21a69 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1118CSharp9UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1118CSharp9UnitTests.cs @@ -75,5 +75,37 @@ r with TestCode = testCode, }.RunAsync(CancellationToken.None).ConfigureAwait(false); } + + [Fact] + [WorkItem(3339, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3339")] + public async Task TestNewExpressionAsync() + { + var testCode = @" + public class MyClass + { + public class MyObject + { + public string MyValue { get; init; } + } + + public void MyTestFunction() + { + MyCallingFunction(0, new() + { + MyValue = ""Test"" + }); + } + + public void MyCallingFunction(int index, MyObject myObject) + { + } + }"; + + await new CSharpTest(LanguageVersion.CSharp9) + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + TestCode = testCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1118ParameterMustNotSpanMultipleLines.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1118ParameterMustNotSpanMultipleLines.cs index 5deaafa007..cb29b67e08 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1118ParameterMustNotSpanMultipleLines.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1118ParameterMustNotSpanMultipleLines.cs @@ -84,6 +84,7 @@ internal class SA1118ParameterMustNotSpanMultipleLines : DiagnosticAnalyzer SyntaxKind.ArrayCreationExpression, SyntaxKind.ImplicitArrayCreationExpression, SyntaxKindEx.WithExpression, + SyntaxKindEx.ImplicitObjectCreationExpression, }; ///