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

Commit

Permalink
Merge pull request #22 from tristal/issue/21
Browse files Browse the repository at this point in the history
Allowing UseAsyncSuffixAnalyzer to ignore property getter and setters
  • Loading branch information
sharwell committed May 6, 2015
2 parents 79ddddc + db8f860 commit 844ec04
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,19 @@ class ClassName
await VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TestPropertyGetterAndSetterTaskAsync()
{
string testCode = @"
using System.Threading.Tasks;
class ClassName
{
public Task<string> TaskString { get; set; }
}
";
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

protected override DiagnosticAnalyzer GetCSharpDiagnosticAnalyzer()
{
return new UseAsyncSuffixAnalyzer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ private void HandleMethodDeclaration(SymbolAnalysisContext context)
if (!string.Equals(typeof(Task).Namespace, symbol.ReturnType?.ContainingNamespace?.ToString(), StringComparison.Ordinal))
return;

if (symbol.MethodKind == MethodKind.PropertyGet || symbol.MethodKind == MethodKind.PropertySet)
return;

context.ReportDiagnostic(Diagnostic.Create(Descriptor, symbol.Locations[0], symbol.Name));
}
}
Expand Down

0 comments on commit 844ec04

Please sign in to comment.