Skip to content
This repository was archived by the owner on Nov 8, 2018. It is now read-only.

Commit 00829a2

Browse files
committed
Code simplifications based on code review feedback
1 parent e66e1d6 commit 00829a2

File tree

5 files changed

+3
-41
lines changed

5 files changed

+3
-41
lines changed

AsyncUsageAnalyzers/AsyncUsageAnalyzers/Naming/AvoidAsyncSuffixAnalyzer.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,8 @@ public class AvoidAsyncSuffixAnalyzer : DiagnosticAnalyzer
2626
private static readonly DiagnosticDescriptor Descriptor =
2727
new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, Category, DiagnosticSeverity.Warning, true, Description, HelpLink);
2828

29-
private static readonly ImmutableArray<DiagnosticDescriptor> SupportedDiagnosticsValue =
30-
ImmutableArray.Create(Descriptor);
31-
3229
/// <inheritdoc/>
33-
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
34-
{
35-
get
36-
{
37-
return SupportedDiagnosticsValue;
38-
}
39-
}
30+
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } = ImmutableArray.Create(Descriptor);
4031

4132
/// <inheritdoc/>
4233
public override void Initialize(AnalysisContext context)
@@ -69,7 +60,6 @@ private void HandleMethodDeclaration(SymbolAnalysisContext context)
6960
}
7061
}
7162

72-
7363
context.ReportDiagnostic(Diagnostic.Create(Descriptor, symbol.Locations[0], symbol.Name));
7464
}
7565
}

AsyncUsageAnalyzers/AsyncUsageAnalyzers/Naming/AvoidAsyncSuffixCodeFixProvider.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
4141
}
4242

4343
var token = root.FindToken(diagnostic.Location.SourceSpan.Start);
44-
if (token.IsMissing)
45-
{
46-
continue;
47-
}
48-
4944
var newName = token.ValueText.Substring(0, token.ValueText.Length - "Async".Length);
5045
context.RegisterCodeFix(CodeAction.Create($"Rename method to '{newName}'", cancellationToken => RenameHelper.RenameSymbolAsync(document, root, token, newName, cancellationToken)), diagnostic);
5146
}

AsyncUsageAnalyzers/AsyncUsageAnalyzers/Naming/UseAsyncSuffixAnalyzer.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,8 @@ public class UseAsyncSuffixAnalyzer : DiagnosticAnalyzer
2626
private static readonly DiagnosticDescriptor Descriptor =
2727
new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, Category, DiagnosticSeverity.Warning, true, Description, HelpLink);
2828

29-
private static readonly ImmutableArray<DiagnosticDescriptor> SupportedDiagnosticsValue =
30-
ImmutableArray.Create(Descriptor);
31-
3229
/// <inheritdoc/>
33-
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
34-
{
35-
get
36-
{
37-
return SupportedDiagnosticsValue;
38-
}
39-
}
30+
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } = ImmutableArray.Create(Descriptor);
4031

4132
/// <inheritdoc/>
4233
public override void Initialize(AnalysisContext context)

AsyncUsageAnalyzers/AsyncUsageAnalyzers/Naming/UseAsyncSuffixCodeFixProvider.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
4141
}
4242

4343
var token = root.FindToken(diagnostic.Location.SourceSpan.Start);
44-
if (token.IsMissing)
45-
{
46-
continue;
47-
}
48-
4944
var newName = token.ValueText + "Async";
5045
context.RegisterCodeFix(CodeAction.Create($"Rename method to '{newName}'", cancellationToken => RenameHelper.RenameSymbolAsync(document, root, token, newName, cancellationToken)), diagnostic);
5146
}

AsyncUsageAnalyzers/AsyncUsageAnalyzers/Reliability/AvoidAsyncVoidAnalyzer.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,8 @@ public class AvoidAsyncVoidAnalyzer : DiagnosticAnalyzer
2525
private static readonly DiagnosticDescriptor Descriptor =
2626
new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, Category, DiagnosticSeverity.Warning, true, Description, HelpLink);
2727

28-
private static readonly ImmutableArray<DiagnosticDescriptor> SupportedDiagnosticsValue =
29-
ImmutableArray.Create(Descriptor);
30-
3128
/// <inheritdoc/>
32-
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
33-
{
34-
get
35-
{
36-
return SupportedDiagnosticsValue;
37-
}
38-
}
29+
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } = ImmutableArray.Create(Descriptor);
3930

4031
/// <inheritdoc/>
4132
public override void Initialize(AnalysisContext context)

0 commit comments

Comments
 (0)