private void AnalyzeIntToLongSyntaxNode(SyntaxNodeAnalysisContext context) { var semanticModel = context.SemanticModel; var node = context.Node; var typeInfo = semanticModel.GetTypeInfo(node, cancellationToken: context.CancellationToken); if (typeInfo.Type.SpecialType != SpecialType.System_Int32) { return; } Diagnostic diagnostic = node.Kind() switch { SyntaxKind.MultiplyExpression => DiagnosticDescriptors.AC0001_MultiplyOverflowInt32(context.Node), SyntaxKind.LeftShiftExpression => DiagnosticDescriptors.AC0002_LeftShiftOverflowInt32(context.Node), _ => throw new InvalidOperationException(), }; for (; node is not null; node = GetParent(node)) { if (semanticModel.GetTypeInfo(node, cancellationToken: context.CancellationToken) .ConvertedType.SpecialType == SpecialType.System_Int64) { context.ReportDiagnostic(diagnostic); return; } }