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

Commit 834d3d1

Browse files
committed
Fix behavior and test for properties
1 parent 8c33c6c commit 834d3d1

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

AsyncUsageAnalyzers/AsyncUsageAnalyzers.Test/Usage/IncludeCancellationParameterUnitTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public async Task TestPropertyAsync()
3939
using System.Threading.Tasks;
4040
class ClassName
4141
{
42-
Task PropertyName { get; set; }
42+
public Task PropertyName { get; set; }
4343
}
4444
";
4545

AsyncUsageAnalyzers/AsyncUsageAnalyzers/Usage/IncludeCancellationParameterAnalyzer.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,38 @@ public void HandleMethodDeclaration(SymbolAnalysisContext context)
7878
return;
7979
}
8080

81+
switch (symbol.MethodKind)
82+
{
83+
case MethodKind.LambdaMethod:
84+
case MethodKind.Constructor:
85+
case MethodKind.Conversion:
86+
case MethodKind.UserDefinedOperator:
87+
case MethodKind.PropertyGet:
88+
case MethodKind.PropertySet:
89+
case MethodKind.StaticConstructor:
90+
case MethodKind.BuiltinOperator:
91+
case MethodKind.Destructor:
92+
case MethodKind.EventAdd:
93+
case MethodKind.EventRaise:
94+
case MethodKind.EventRemove:
95+
// These can't be async
96+
return;
97+
98+
case MethodKind.DelegateInvoke:
99+
// Not sure if this is reachable
100+
return;
101+
102+
case MethodKind.ExplicitInterfaceImplementation:
103+
// These are ignored
104+
return;
105+
106+
case MethodKind.ReducedExtension:
107+
case MethodKind.Ordinary:
108+
case MethodKind.DeclareMethod:
109+
default:
110+
break;
111+
}
112+
81113
if (!symbol.IsInAnalyzedSource(this.generatedHeaderCache, context.CancellationToken))
82114
{
83115
return;

0 commit comments

Comments
 (0)