Skip to content

Commit 55094d3

Browse files
authored
Apply feedback
1 parent 1268525 commit 55094d3

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/MarkMembersAsStatic.cs

+8-11
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,15 @@ void OnOperationBlockStart(OperationBlockStartAnalysisContext blockStartContext)
111111
return;
112112
}
113113

114-
bool isInstanceReferenced = methodSymbol.AssociatedSymbol.IsIndexer();
114+
bool isInstanceReferenced = false;
115115

116-
if (!isInstanceReferenced)
116+
blockStartContext.RegisterOperationAction(operationContext =>
117117
{
118-
blockStartContext.RegisterOperationAction(operationContext =>
118+
if (((IInstanceReferenceOperation)operationContext.Operation).ReferenceKind == InstanceReferenceKind.ContainingTypeInstance)
119119
{
120-
if (((IInstanceReferenceOperation)operationContext.Operation).ReferenceKind == InstanceReferenceKind.ContainingTypeInstance)
121-
{
122-
isInstanceReferenced = true;
123-
}
124-
}, OperationKind.InstanceReference);
125-
}
120+
isInstanceReferenced = true;
121+
}
122+
}, OperationKind.InstanceReference);
126123

127124
blockStartContext.RegisterOperationBlockEndAction(blockEndContext =>
128125
{
@@ -205,8 +202,8 @@ private static bool ShouldAnalyze(
205202
return false;
206203
}
207204

208-
// Do not analyze constructors and finalizers.
209-
if (methodSymbol.IsConstructor() || methodSymbol.IsFinalizer())
205+
// Do not analyze constructors, finalizers, and indexers.
206+
if (methodSymbol.IsConstructor() || methodSymbol.IsFinalizer() || methodSymbol.AssociatedSymbol.IsIndexer())
210207
{
211208
return false;
212209
}

0 commit comments

Comments
 (0)