Skip to content

Commit 7f15655

Browse files
committed
Use expression bodied members
1 parent 5af2614 commit 7f15655

File tree

43 files changed

+96
-384
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+96
-384
lines changed

VSDiagnostics/VSDiagnostics/VSDiagnostics.Test/Tests/Utilities/ExtensionsTests.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -528,10 +528,7 @@ private static void AssertMethodIsDefinedInAncestor(string source)
528528
Assert.IsTrue(methodSymbol.IsDefinedInAncestor());
529529
}
530530

531-
private static IEnumerable<MethodDeclarationSyntax> GetMethodNodes(SyntaxTree tree)
532-
{
533-
return tree.GetRoot().DescendantNodes().OfType<MethodDeclarationSyntax>();
534-
}
531+
private static IEnumerable<MethodDeclarationSyntax> GetMethodNodes(SyntaxTree tree) => tree.GetRoot().DescendantNodes().OfType<MethodDeclarationSyntax>();
535532

536533
private static SemanticModel GetSemanticModel(SyntaxTree tree)
537534
{

VSDiagnostics/VSDiagnostics/VSDiagnostics.Test/Tests/Utilities/NamingConventionsTests.cs

Lines changed: 51 additions & 204 deletions
Large diffs are not rendered by default.

VSDiagnostics/VSDiagnostics/VSDiagnostics/Diagnostics/Async/AsyncMethodWithoutAsyncSuffix/AsyncMethodWithoutAsyncSuffixAnalyzer.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ internal static DiagnosticDescriptor Rule
2424

2525
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(Rule);
2626

27-
public override void Initialize(AnalysisContext context)
28-
{
29-
context.RegisterSyntaxNodeAction(AnalyzeSyntaxNode, SyntaxKind.MethodDeclaration);
30-
}
27+
public override void Initialize(AnalysisContext context) => context.RegisterSyntaxNodeAction(AnalyzeSyntaxNode, SyntaxKind.MethodDeclaration);
3128

3229
private static void AnalyzeSyntaxNode(SyntaxNodeAnalysisContext context)
3330
{

VSDiagnostics/VSDiagnostics/VSDiagnostics/Diagnostics/Async/AsyncMethodWithoutAsyncSuffix/AsyncMethodWithoutAsyncSuffixCodeFix.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
3535
}
3636

3737
private async Task<Solution> AddSuffixAsync(Document document, MethodDeclarationSyntax methodDeclaration, SyntaxNode root,
38-
CancellationToken cancellationToken)
39-
{
40-
return await RenameHelper.RenameSymbolAsync(document, root, methodDeclaration.Identifier, methodDeclaration.Identifier.Text + "Async", cancellationToken);
41-
}
38+
CancellationToken cancellationToken) => await RenameHelper.RenameSymbolAsync(document, root, methodDeclaration.Identifier, methodDeclaration.Identifier.Text + "Async", cancellationToken);
4239
}
4340
}

VSDiagnostics/VSDiagnostics/VSDiagnostics/Diagnostics/Async/SyncMethodWithAsyncSuffix/SyncMethodWithAsyncSuffixAnalyzer.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ internal static DiagnosticDescriptor Rule
2424

2525
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(Rule);
2626

27-
public override void Initialize(AnalysisContext context)
28-
{
29-
context.RegisterSyntaxNodeAction(AnalyzeSyntaxNode, SyntaxKind.MethodDeclaration);
30-
}
27+
public override void Initialize(AnalysisContext context) => context.RegisterSyntaxNodeAction(AnalyzeSyntaxNode, SyntaxKind.MethodDeclaration);
3128

3229
private static void AnalyzeSyntaxNode(SyntaxNodeAnalysisContext context)
3330
{

VSDiagnostics/VSDiagnostics/VSDiagnostics/Diagnostics/Attributes/AttributeWithEmptyArgumentList/AttributeWithEmptyArgumentListCodeFix.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,9 @@ private Task<Solution> RemoveEmptyArgumentListAsync(Document document, SyntaxNod
4949
return Task.FromResult(newDocument.Project.Solution);
5050
}
5151

52-
private SyntaxNode RemoveEmptyArgumentListCSharp(SyntaxNode root, CSharpAttributeSyntax attributeExpression)
53-
{
54-
return root.RemoveNode(attributeExpression.ArgumentList, SyntaxRemoveOptions.KeepNoTrivia);
55-
}
52+
private SyntaxNode RemoveEmptyArgumentListCSharp(SyntaxNode root, CSharpAttributeSyntax attributeExpression) => root.RemoveNode(attributeExpression.ArgumentList, SyntaxRemoveOptions.KeepNoTrivia);
5653

5754
private SyntaxNode RemoveEmptyArgumentListVisualBasic(SyntaxNode root,
58-
VisualBasicAttributeSyntax attributeExpression)
59-
{
60-
return root.RemoveNode(attributeExpression.ArgumentList, SyntaxRemoveOptions.KeepNoTrivia);
61-
}
55+
VisualBasicAttributeSyntax attributeExpression) => root.RemoveNode(attributeExpression.ArgumentList, SyntaxRemoveOptions.KeepNoTrivia);
6256
}
6357
}

VSDiagnostics/VSDiagnostics/VSDiagnostics/Diagnostics/Attributes/FlagsEnumValuesAreNotPowersOfTwo/FlagsEnumValuesAreNotPowersOfTwoAnalyzer.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@ internal static DiagnosticDescriptor ValuesDontFitRule
4646
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
4747
=> ImmutableArray.Create(DefaultRule, ValuesDontFitRule);
4848

49-
public override void Initialize(AnalysisContext context)
50-
{
51-
context.RegisterSyntaxNodeAction(AnalyzeSymbol, SyntaxKind.EnumDeclaration);
52-
}
49+
public override void Initialize(AnalysisContext context) => context.RegisterSyntaxNodeAction(AnalyzeSymbol, SyntaxKind.EnumDeclaration);
5350

5451
private void AnalyzeSymbol(SyntaxNodeAnalysisContext context)
5552
{

VSDiagnostics/VSDiagnostics/VSDiagnostics/Diagnostics/Attributes/OnPropertyChangedWithoutCallerMemberName/OnPropertyChangedWithoutCallerMemberNameAnalyzer.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ internal static DiagnosticDescriptor Rule
2828

2929
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(Rule);
3030

31-
public override void Initialize(AnalysisContext context)
32-
{
33-
context.RegisterSyntaxNodeAction(AnalyzeSymbol, SyntaxKind.MethodDeclaration);
34-
}
31+
public override void Initialize(AnalysisContext context) => context.RegisterSyntaxNodeAction(AnalyzeSymbol, SyntaxKind.MethodDeclaration);
3532

3633
private void AnalyzeSymbol(SyntaxNodeAnalysisContext context)
3734
{

VSDiagnostics/VSDiagnostics/VSDiagnostics/Diagnostics/Exceptions/ArgumentExceptionWithoutNameofOperator/ArgumentExceptionWithoutNameofOperatorAnalyzer.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ internal static DiagnosticDescriptor Rule
2727

2828
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(Rule);
2929

30-
public override void Initialize(AnalysisContext context)
31-
{
32-
context.RegisterSyntaxNodeAction(AnalyzeSyntaxNode, SyntaxKind.ObjectCreationExpression);
33-
}
30+
public override void Initialize(AnalysisContext context) => context.RegisterSyntaxNodeAction(AnalyzeSyntaxNode, SyntaxKind.ObjectCreationExpression);
3431

3532
private void AnalyzeSyntaxNode(SyntaxNodeAnalysisContext context)
3633
{

VSDiagnostics/VSDiagnostics/VSDiagnostics/Diagnostics/Exceptions/CatchNullReferenceException/CatchingNullReferenceExceptionAnalyzer.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ internal static DiagnosticDescriptor Rule
2222

2323
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(Rule);
2424

25-
public override void Initialize(AnalysisContext context)
26-
{
27-
context.RegisterSyntaxNodeAction(AnalyzeSyntaxNode, SyntaxKind.CatchDeclaration);
28-
}
25+
public override void Initialize(AnalysisContext context) => context.RegisterSyntaxNodeAction(AnalyzeSyntaxNode, SyntaxKind.CatchDeclaration);
2926

3027
private void AnalyzeSyntaxNode(SyntaxNodeAnalysisContext context)
3128
{

0 commit comments

Comments
 (0)