Skip to content

Commit d7d623a

Browse files
committed
Add SA1003 test for expression-bodied local functions
1 parent 57a8b93 commit d7d623a

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1003CSharp7UnitTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ public class C1
3333
public event EventHandler E { add=>e += value; remove=>e -= value; } // Event accessors
3434
public int Answer { get=>42; set=>x = 2; } // Property accessors
3535
public int this[int index] { get=>42; set=>x = value; } // Indexer accessors
36+
public void Method()
37+
{
38+
int LocalFunction()=>42; // Local functions
39+
}
3640
}
3741
}
3842
";
@@ -49,6 +53,10 @@ public class C1
4953
public event EventHandler E { add => e += value; remove => e -= value; } // Event accessors
5054
public int Answer { get => 42; set => x = 2; } // Property accessors
5155
public int this[int index] { get => 42; set => x = value; } // Indexer accessors
56+
public void Method()
57+
{
58+
int LocalFunction() => 42; // Local functions
59+
}
5260
}
5361
}
5462
";
@@ -74,6 +82,9 @@ public class C1
7482
this.CSharpDiagnostic(DescriptorFollowedByWhitespace).WithLocation(13, 41).WithArguments("=>"),
7583
this.CSharpDiagnostic(DescriptorPrecededByWhitespace).WithLocation(13, 50).WithArguments("=>"),
7684
this.CSharpDiagnostic(DescriptorFollowedByWhitespace).WithLocation(13, 50).WithArguments("=>"),
85+
86+
this.CSharpDiagnostic(DescriptorPrecededByWhitespace).WithLocation(16, 32).WithArguments("=>"),
87+
this.CSharpDiagnostic(DescriptorFollowedByWhitespace).WithLocation(16, 32).WithArguments("=>"),
7788
};
7889

7990
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);

0 commit comments

Comments
 (0)