static void CaptureOrReportComputeHashInvocationOperation(OperationAnalysisContext context, MethodHelper methodHelper, DataCollector dataCollector, IInvocationOperation computeHashInvocation, ComputeType computeType) { switch (computeHashInvocation.Instance) { case ILocalReferenceOperation: dataCollector.CollectComputeHashInvocation(computeHashInvocation, computeType); break; case IInvocationOperation chainedInvocationOperation when methodHelper.IsHashCreateMethod(chainedInvocationOperation): ReportChainedComputeHashInvocationOperation(chainedInvocationOperation.TargetMethod.ContainingType); break; case IObjectCreationOperation chainObjectCreationOperation when methodHelper.IsObjectCreationInheritingHashAlgorithm(chainObjectCreationOperation): ReportChainedComputeHashInvocationOperation(chainObjectCreationOperation.Type); break; } void ReportChainedComputeHashInvocationOperation(ITypeSymbol originalHashType) { if (!methodHelper.TryGetHashDataMethod(originalHashType, computeType, out var staticHashMethod)) { return; } var diagnostics = CreateDiagnostics(computeHashInvocation, staticHashMethod.ContainingType, computeType); context.ReportDiagnostic(diagnostics); } }