Skip to content

Commit

Permalink
Apply feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 authored Jan 5, 2021
1 parent 1268525 commit 55094d3
Showing 1 changed file with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,15 @@ void OnOperationBlockStart(OperationBlockStartAnalysisContext blockStartContext)
return;
}

bool isInstanceReferenced = methodSymbol.AssociatedSymbol.IsIndexer();
bool isInstanceReferenced = false;

if (!isInstanceReferenced)
blockStartContext.RegisterOperationAction(operationContext =>
{
blockStartContext.RegisterOperationAction(operationContext =>
if (((IInstanceReferenceOperation)operationContext.Operation).ReferenceKind == InstanceReferenceKind.ContainingTypeInstance)
{
if (((IInstanceReferenceOperation)operationContext.Operation).ReferenceKind == InstanceReferenceKind.ContainingTypeInstance)
{
isInstanceReferenced = true;
}
}, OperationKind.InstanceReference);
}
isInstanceReferenced = true;
}
}, OperationKind.InstanceReference);

blockStartContext.RegisterOperationBlockEndAction(blockEndContext =>
{
Expand Down Expand Up @@ -205,8 +202,8 @@ private static bool ShouldAnalyze(
return false;
}

// Do not analyze constructors and finalizers.
if (methodSymbol.IsConstructor() || methodSymbol.IsFinalizer())
// Do not analyze constructors, finalizers, and indexers.
if (methodSymbol.IsConstructor() || methodSymbol.IsFinalizer() || methodSymbol.AssociatedSymbol.IsIndexer())
{
return false;
}
Expand Down

0 comments on commit 55094d3

Please sign in to comment.