2 implementations of Syntax
Microsoft.CodeAnalysis (1)
Operations\Operation.cs (1)
70public SyntaxNode Syntax { get; }
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (1)
Semantics\CollectionExpressionTests.cs (1)
27086SyntaxNode IOperation.Syntax => throw null;
1217 references to Syntax
Aspire.Hosting.Analyzers (1)
AppHostAnalyzer.cs (1)
131if (argumentOperation?.Syntax is not ArgumentSyntax routePatternArgumentSyntax ||
ConfigurationSchemaGenerator (2)
RuntimeSource\Configuration.Binder\Specs\InterceptorInfo.cs (2)
173if (invocation.Syntax is not InvocationExpressionSyntax { Expression: MemberAccessExpressionSyntax memberAccessExprSyntax }) 179SyntaxTree operationSyntaxTree = invocation.Syntax.SyntaxTree;
ILLink.RoslynAnalyzer (19)
COMAnalyzer.cs (1)
55 operationContext.Operation.Syntax.GetLocation (), targetMethod.GetDisplayName ()));
DataFlow\LocalDataFlowVisitor.cs (7)
104 $"{OwningSymbol.GetType ()}: {branchValueOperation.Syntax.GetLocation ().GetLineSpan ()}"); 112 $"{OwningSymbol.GetType ()}: {branchValueOperation.Syntax.GetLocation ().GetLineSpan ()}"); 205 $"{local.ContainingSymbol.GetType ()}: {localReference.Syntax.GetLocation ().GetLineSpan ()}"); 452 $"{operation.Syntax.GetLocation ().GetLineSpan ()}"); 454 $"{operation.Syntax.GetLocation ().GetLineSpan ()}"); 473 $"{operation.Syntax.GetLocation ().GetLineSpan ()}"); 475 $"{operation.Syntax.GetLocation ().GetLineSpan ()}");
DataFlow\UnexpectedOperationHandler.cs (1)
47 throw new NotImplementedException ($"Unexpected operation type {operation.GetType ()}: {operation.Syntax.GetLocation ().GetLineSpan ()}");
TrimAnalysis\FeatureCheckReturnValuePattern.cs (1)
35 var diagnosticContext = new DiagnosticContext (Operation.Syntax.GetLocation (), reportDiagnostic);
TrimAnalysis\TrimAnalysisAssignmentPattern.cs (1)
58 var diagnosticContext = new DiagnosticContext (Operation.Syntax.GetLocation (), reportDiagnostic);
TrimAnalysis\TrimAnalysisFieldAccessPattern.cs (1)
49 DiagnosticContext diagnosticContext = new (Operation.Syntax.GetLocation (), reportDiagnostic);
TrimAnalysis\TrimAnalysisGenericInstantiationPattern.cs (1)
51 var location = Operation.Syntax.GetLocation ();
TrimAnalysis\TrimAnalysisMethodCallPattern.cs (2)
75 Location location = Operation.Syntax.GetLocation (); 84 location = Operation.Syntax switch {
TrimAnalysis\TrimAnalysisReflectionAccessPattern.cs (1)
48 var location = Operation.Syntax.GetLocation ();
TrimAnalysis\TrimDataFlowAnalysis.cs (3)
96 var method = op.Syntax.FirstAncestorOrSelf<MethodDeclarationSyntax> (); 116 TraceWriteLine (firstBlockOp.Syntax.ToString ()); 118 TraceWriteLine (branchOp.Syntax.ToString ());
Metrics (11)
src\RoslynAnalyzers\Utilities\Compiler\DoNotCatchGeneralUnlessRethrown.cs (1)
83operationBlockAnalysisContext.ReportDiagnostic(CreateDiagnostic(method, catchClause.Syntax.GetFirstToken()));
src\RoslynAnalyzers\Utilities\Compiler\Extensions\DiagnosticExtensions.cs (2)
57return operation.Syntax.CreateDiagnostic(rule, properties, args); 67return operation.Syntax.CreateDiagnostic(rule, additionalLocations, properties, args);
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IOperationExtensions.cs (7)
35GetReceiverType(invocation.Instance.Syntax, compilation, cancellationToken) : 44GetReceiverType(firstArg.Value.Syntax, compilation, cancellationToken) : 312return operation.GetAncestor(OperationKind.ConditionalAccess, (IConditionalAccessOperation c) => c.Operation.Syntax == operation.Syntax); 340if (current.Syntax == operation.Syntax) 640=> invocationOperation.GetInstance()?.Syntax;
src\RoslynAnalyzers\Utilities\Compiler\Extensions\OperationBlockAnalysisContextExtension.cs (1)
47(body.Operations.Length == 3 && body.Syntax.Language == LanguageNames.VisualBasic &&
Metrics.Legacy (11)
src\RoslynAnalyzers\Utilities\Compiler\DoNotCatchGeneralUnlessRethrown.cs (1)
83operationBlockAnalysisContext.ReportDiagnostic(CreateDiagnostic(method, catchClause.Syntax.GetFirstToken()));
src\RoslynAnalyzers\Utilities\Compiler\Extensions\DiagnosticExtensions.cs (2)
57return operation.Syntax.CreateDiagnostic(rule, properties, args); 67return operation.Syntax.CreateDiagnostic(rule, additionalLocations, properties, args);
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IOperationExtensions.cs (7)
35GetReceiverType(invocation.Instance.Syntax, compilation, cancellationToken) : 44GetReceiverType(firstArg.Value.Syntax, compilation, cancellationToken) : 312return operation.GetAncestor(OperationKind.ConditionalAccess, (IConditionalAccessOperation c) => c.Operation.Syntax == operation.Syntax); 340if (current.Syntax == operation.Syntax) 640=> invocationOperation.GetInstance()?.Syntax;
src\RoslynAnalyzers\Utilities\Compiler\Extensions\OperationBlockAnalysisContextExtension.cs (1)
47(body.Operations.Length == 3 && body.Syntax.Language == LanguageNames.VisualBasic &&
Microsoft.Analyzers.Extra (21)
AsyncCallInsideUsingBlockAnalyzer.cs (1)
123Diagnostic.Create(DiagDescriptors.AsyncCallInsideUsingBlock, invocation.Syntax.GetLocation());
CallAnalysis\Arrays.cs (2)
101static void HandleMethod(OperationAnalysisContext context, IInvocationOperation op) => HandleSuspectType(context, (INamedTypeSymbol)op.TargetMethod.ReturnType, op.Syntax.GetLocation()); 103static void HandleConstructor(OperationAnalysisContext context, IObjectCreationOperation op) => HandleSuspectType(context, (INamedTypeSymbol)op.Type!, op.Syntax.GetLocation());
CallAnalysis\Fixers\LegacyLoggingFixer.cs (5)
404var type = e.SemanticModel?.GetTypeInfo(e.Syntax).Type!; 492loggerSyntaxNode = arg.Syntax; 502argList.Add(a.Syntax.WithoutTrivia()); 509argList.Add(e.Syntax.WithoutTrivia()); 514argList.Add(arg.Syntax.WithoutTrivia());
CallAnalysis\Fixers\LegacyLoggingFixer.FixDetails.cs (1)
71var argName = operation.Syntax.GetLastToken().Text;
CallAnalysis\LegacyCollection.cs (1)
33var diagnostic = Diagnostic.Create(DiagDescriptors.LegacyCollection, op.Syntax.GetLocation());
CallAnalysis\LegacyLogging.cs (1)
38var diagnostic = Diagnostic.Create(DiagDescriptors.LegacyLogging, op.Syntax.GetLocation());
CallAnalysis\Split.cs (1)
28var diagnostic = Diagnostic.Create(DiagDescriptors.Split, op.Syntax.GetLocation());
CallAnalysis\StartsEndsWith.cs (1)
59var diagnostic = Diagnostic.Create(DiagDescriptors.StartsEndsWith, op.Syntax.GetLocation(), op.TargetMethod.Name);
CallAnalysis\StaticTime.cs (2)
52var diagnostic = Diagnostic.Create(DiagDescriptors.StaticTime, op.Syntax.GetLocation()); 58var diagnostic = Diagnostic.Create(DiagDescriptors.StaticTime, op.Syntax.GetLocation());
CallAnalysis\ValueTuple.cs (2)
42var diagnostic = Diagnostic.Create(DiagDescriptors.ValueTuple, op.Syntax.GetLocation()); 48var diagnostic = Diagnostic.Create(DiagDescriptors.ValueTuple, op.Syntax.GetLocation());
CoalesceAnalyzer.cs (2)
52var diagnostic = Diagnostic.Create(DiagDescriptors.CoalesceAssignment, op.Syntax.GetLocation()); 79var diagnostic = Diagnostic.Create(DiagDescriptors.Coalesce, op.Syntax.GetLocation());
ConditionalAccessAnalyzer.cs (1)
111var diagnostic = Diagnostic.Create(DiagDescriptors.ConditionalAccess, op.Syntax.GetLocation());
UsingToStringInLoggersAnalyzer.cs (1)
69yield return Diagnostic.Create(DiagDescriptors.UsingToStringInLoggers, arg.Syntax.GetLocation());
Microsoft.Analyzers.Local (5)
CallAnalysis\Throws.cs (4)
35if (op.Syntax.IsKind(SyntaxKind.ThrowStatement)) 39op.Syntax.GetLocation(), 44else if (op.Syntax.IsKind(SyntaxKind.ThrowExpression)) 48var throwExpression = (ThrowExpressionSyntax)op.Syntax;
CallAnalysis\ToInvariantString.cs (1)
51var diagnostic = Diagnostic.Create(DiagDescriptors.ToInvariantString, op.Syntax.GetLocation());
Microsoft.AspNetCore.Analyzers (4)
BuildServiceProviderAnalyzer.cs (1)
33serviceItem.Operation.Syntax.GetLocation(),
UseAuthorizationAnalyzer.cs (2)
51middlewareItem.Operation.Syntax.GetLocation(), 71useAuthorizationItem.Operation.Syntax.GetLocation(),
UseMvcAnalyzer.cs (1)
45middlewareItem.Operation.Syntax.GetLocation(),
Microsoft.AspNetCore.App.Analyzers (21)
Authorization\AddAuthorizationBuilderAnalyzer.cs (1)
62AddDiagnosticInformation(context, invocation.Syntax.GetLocation());
Http\HeaderDictionaryAddAnalyzer.cs (1)
38AddDiagnosticWarning(context, invocation.Syntax.GetLocation());
Http\HeaderDictionaryIndexerAnalyzer.cs (1)
41AddDiagnosticWarning(context, propertyReference.Syntax.GetLocation(), indexerValue, propertyName);
Http\RequestDelegateReturnTypeAnalyzer.cs (2)
40AddDiagnosticWarning(context, methodReference.Syntax.GetLocation(), returnType); 66AddDiagnosticWarning(context, anonymousFunction.Syntax.GetLocation(), returnType);
RenderTreeBuilder\RenderTreeBuilderAnalyzer.cs (3)
43if (!argument.Value.Syntax.IsKind(SyntaxKind.NumericLiteralExpression)) 47argument.Syntax.GetLocation(), 48argument.Syntax.ToString()));
RouteHandlers\DetectMisplacedLambdaAttribute.cs (1)
41var location = lambda.Syntax.GetLocation();
RouteHandlers\DisallowReturningActionResultFromMapMethods.cs (1)
83returnOperation.Syntax.GetLocation(),
RouteHandlers\RouteHandlerAnalyzer.cs (5)
110DisallowReturningActionResultFromMapMethods(in context, wellKnownTypes, invocation, lambda, delegateCreation.Syntax); 140delegateCreation.Syntax); 151delegateCreation.Syntax); 165delegateCreation.Syntax); 184if (argumentOperation?.Syntax is not ArgumentSyntax routePatternArgumentSyntax ||
src\Shared\Roslyn\CodeAnalysisExtensions.cs (2)
183return GetReceiverType(invocation.Instance.Syntax, invocation.SemanticModel, cancellationToken); 190return GetReceiverType(firstArg.Value.Syntax, invocation.SemanticModel, cancellationToken);
WebApplicationBuilder\WebApplicationBuilderAnalyzer.cs (4)
258var location = operation.Syntax.GetLocation(); 280var methodName = operation.Syntax 301location = Location.Create(operation.Syntax.SyntaxTree, targetSpan); 368var arguments = argument?.Syntax as ArgumentSyntax;
Microsoft.AspNetCore.Components.Analyzers (3)
ComponentParameterUsageAnalyzer.cs (1)
107propertyReference.Syntax.GetLocation(),
InternalUsageAnalyzer.cs (2)
139context.Operation.Syntax.GetLocation(), 149context.Operation.Syntax.GetLocation(),
Microsoft.AspNetCore.Components.SdkAnalyzers (3)
ComponentParameterUsageAnalyzer.cs (1)
107propertyReference.Syntax.GetLocation(),
InternalUsageAnalyzer.cs (2)
139context.Operation.Syntax.GetLocation(), 149context.Operation.Syntax.GetLocation(),
Microsoft.AspNetCore.Http.RequestDelegateGenerator (13)
StaticRouteHandlerModel\Endpoint.cs (9)
24InterceptableLocation = semanticModel.GetInterceptableLocation((InvocationExpressionSyntax)operation.Syntax)!; 31Diagnostics.Add(Diagnostic.Create(DiagnosticDescriptors.UnableToResolveMethod, Operation.Syntax.GetLocation())); 36Response.EmitRequiredDiagnostics(Diagnostics, Operation.Syntax.GetLocation()); 58parameterSymbol.EmitRequiredDiagnostics(Diagnostics, Operation.Syntax.GetLocation()); 79Operation.Syntax.GetLocation(), 156var memberAccessorExpression = ((MemberAccessExpressionSyntax)((InvocationExpressionSyntax)operation.Syntax).Expression); 164var lineSpan = operation.Syntax.SyntaxTree.GetLineSpan(invocationNameSpan); 166var filePath = operation.Syntax.SyntaxTree.GetInterceptorFilePath(operation.SemanticModel?.Compilation.Options.SourceReferenceResolver); 173var syntax = (InvocationExpressionSyntax)operation.Syntax;
StaticRouteHandlerModel\EndpointParameter.cs (4)
116var location = endpoint.Operation.Syntax.GetLocation(); 152var location = endpoint.Operation.Syntax.GetLocation(); 165var location = endpoint.Operation.Syntax.GetLocation(); 463var location = endpoint.Operation.Syntax.GetLocation();
Microsoft.AspNetCore.Mvc.Analyzers (5)
AvoidHtmlPartialAnalyzer.cs (2)
33context.Operation.Syntax.GetLocation(), 40context.Operation.Syntax.GetLocation(),
src\Shared\Roslyn\CodeAnalysisExtensions.cs (2)
183return GetReceiverType(invocation.Instance.Syntax, invocation.SemanticModel, cancellationToken); 190return GetReceiverType(firstArg.Value.Syntax, invocation.SemanticModel, cancellationToken);
TagHelpersInCodeBlocksAnalyzer.cs (1)
88capturedDiagnosticLocations.Add(parent.Syntax.GetLocation());
Microsoft.AspNetCore.Mvc.Api.Analyzers (6)
ApiActionsDoNotRequireExplicitModelValidationCheckAnalyzer.cs (3)
114var returnStatementSyntax = returnOperation.Syntax; 117ifOperation.Syntax.GetLocation(), 124ifOperation.Syntax.GetLocation(),
ApiConventionAnalyzer.cs (1)
53var location = actualMetadata.ReturnOperation.ReturnedValue.Syntax.GetLocation();
src\Shared\Roslyn\CodeAnalysisExtensions.cs (2)
183return GetReceiverType(invocation.Instance.Syntax, invocation.SemanticModel, cancellationToken); 190return GetReceiverType(firstArg.Value.Syntax, invocation.SemanticModel, cancellationToken);
Microsoft.CodeAnalysis (253)
DiagnosticAnalyzer\AnalysisContextInfo.cs (2)
48this(compilation: compilation, operation: operation, symbol: null, file: new SourceOrAdditionalFile(operation.Syntax.SyntaxTree), node: operation.Syntax)
DiagnosticAnalyzer\AnalyzerDriver.cs (1)
2775? operationsToAnalyze.WhereAsArray(operation => analysisScope.ShouldAnalyze(operation.Syntax))
DiagnosticAnalyzer\AnalyzerExecutor.cs (4)
1158diagReporter.FilterSpanForLocalDiagnostics = operation.Syntax.FullSpan; 1526if (operation.Syntax != null && _shouldSkipAnalysisOnGeneratedCode(analyzer) && 1527_isGeneratedCodeLocation(operation.Syntax.SyntaxTree, operation.Syntax.Span, cancellationToken))
DiagnosticAnalyzer\DiagnosticAnalysisContext.cs (3)
1296filterTree: operationBlocks[0].Syntax.SyntaxTree, filterSpan: null, isGeneratedCode: false, cancellationToken) 1440filterTree: operationBlocks[0].Syntax.SyntaxTree, filterSpan: null, isGeneratedCode: false, cancellationToken) 1853FilterTree = operation.Syntax.SyntaxTree;
Operations\ControlFlowGraphBuilder.cs (229)
1412return result ?? MakeInvalidOperation(originalOperation.Syntax, originalOperation.Type, ImmutableArray<IOperation>.Empty); 1672CaptureResultIfNotAlready(operation.Syntax, captureId, result); 1912AddStatement(new FlowCaptureOperation(captureId, operationOpt.Syntax, operationOpt) 2104return PopStackFrame(frame, new SimpleAssignmentOperation(operation.IsRef, PopOperand(), value, null, operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation))); 2116syntax: operation.Syntax, type: operation.Type, isImplicit: IsImplicit(operation))); 2127operation.Syntax, operation.Type, IsImplicit(operation)); 2138operation.Syntax, operation.Type, IsImplicit(operation)); 2149operation.Syntax, operation.Type, IsImplicit(operation)); 2232semanticModel: null, operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation))); 2246semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 2258semanticModel: null, operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation)); 2384AddStatement(new FlowCaptureOperation(resultId, binOp.Syntax, OperationCloner.CloneOperation(capturedRight))); 2390AddStatement(new FlowCaptureOperation(resultId, binOp.Syntax, OperationCloner.CloneOperation(capturedLeft))); 2402semanticModel: null, operand.Syntax, operand.Type, constantValue: null, isImplicit: true); 2434AddStatement(new FlowCaptureOperation(resultId, binOp.Syntax, new LiteralOperation(semanticModel: null, left.Syntax, booleanType, constantValue, isImplicit: true))); 2443AddStatement(new FlowCaptureOperation(resultId, binOp.Syntax, condition)); 2450condition = new FlowCaptureReferenceOperation(resultId, binOp.Syntax, booleanType, constantValue: null); 2453semanticModel: null, binOp.Syntax, binOp.Type, binOp.GetConstantValue(), isImplicit: true); 2459semanticModel: null, operand.Syntax, type, constantValue, isImplicit: true); 2505semanticModel: null, condition.Syntax, booleanType, constantValue: null, isImplicit: true); 2530AddStatement(new FlowCaptureOperation(resultId, binOp.Syntax, resultFromLeft)); 2538AddStatement(new FlowCaptureOperation(resultId, binOp.Syntax, 2549binOp.Syntax, 2608semanticModel: null, condition.Syntax, unaryOperatorMethod.ReturnType, constantValue: null, isImplicit: true); 2619AddStatement(new FlowCaptureOperation(resultId, binOp.Syntax, OperationCloner.CloneOperation(capturedLeft))); 2628AddStatement(new FlowCaptureOperation(resultId, binOp.Syntax, 2639binOp.Syntax, 2681CaptureResultIfNotAlready(condition.RightOperand.Syntax, captureId, resultFromRight); 2693SyntaxNode leftSyntax = (lazyFallThrough!.GetSingletonPredecessorOrDefault() != null ? condition.LeftOperand : condition).Syntax; 2739lastUnary.OperatorMethod, lastUnary.ConstrainedToType, semanticModel: null, lastUnary.Syntax, 2742operatorMethod: null, constrainedToType: null, semanticModel: null, condition.Syntax, 2987SyntaxNode valueSyntax = operationValue.Syntax; 3078AddStatement(new FlowCaptureOperation(resultCaptureId, operation.Value.Syntax, convertedTestExpression)); 3121AddStatement(new FlowCaptureOperation(valueCaptureId, locationCapture.Syntax, locationCapture)); 3185operation.Target.Syntax, 3200operation.Syntax, 3219AddStatement(new FlowCaptureOperation(intermediateValueCaptureId, whenNullValue.Syntax, whenNullValue)); 3224operation.Syntax, 3234syntax: operation.Syntax, 3252AddStatement(new FlowCaptureOperation(resultCaptureId, operation.Syntax, OperationCloner.CloneOperation(valueCapture))); 3268operation.Syntax, operation.Type, constantValue: operation.GetConstantValue(), isImplicit: true); 3276AddStatement(new FlowCaptureOperation(resultCaptureId, operation.Syntax, whenNullAssignment)); 3291semanticModel: null, child.Syntax, type, 3318return new IsNullOperation(operand.Syntax, operand, 3344ImmutableArray<IArgumentOperation>.Empty, semanticModel: null, value.Syntax, 3417result = new ExpressionStatementOperation(result, semanticModel: null, expressionStatement.Syntax, 3433AddStatement(new FlowCaptureOperation(resultCaptureId, currentConditionalAccess.WhenNotNull.Syntax, 3438CaptureResultIfNotAlready(currentConditionalAccess.WhenNotNull.Syntax, resultCaptureId, 3452SyntaxNode defaultValueSyntax = (operation.Operation == testExpression ? testExpression : operation).Syntax; 3530SyntaxNode testExpressionSyntax = testExpression.Syntax; 3570return FinishVisitingStatement(operation, new ExpressionStatementOperation(underlying, semanticModel: null, operation.Syntax, IsImplicit(operation))); 3790SyntaxNode syntax = exceptionDeclarationOrExpression.Syntax; 3835AddStatement(new ReturnOperation(returnedValue, OperationKind.YieldReturn, semanticModel: null, operation.Syntax, IsImplicit(operation))); 3932return new NoneOperation(children: ImmutableArray<IOperation>.Empty, semanticModel: null, operation.Syntax, constantValue: null, isImplicit: true, type: null); 4019processResource(new LocalReferenceOperation(localSymbol, isDeclaration: false, semanticModel: null, declarator.Syntax, localSymbol.Type, 4081AddStatement(new FlowCaptureOperation(captureId, resource.Syntax, resource)); 4129AddStatement(new FlowCaptureOperation(captureId, resource.Syntax, resource)); 4190args, semanticModel: null, value.Syntax, 4195return new AwaitOperation(invocation, semanticModel: null, value.Syntax, _compilation.GetSpecialType(SpecialType.System_Void), isImplicit: true); 4215semanticModel: null, operand.Syntax, iDisposable, constantValue, isImplicit: true); 4247syntax: lockObject.Syntax, 4263operation.Syntax, 4350lockedValue.Syntax, 4352semanticModel: null, lockedValue.Syntax, 4368lockTaken = new LocalReferenceOperation(lockStatement.LockTakenSymbol, isDeclaration: true, semanticModel: null, lockedValue.Syntax, 4378lockedValue.Syntax, 4386lockedValue.Syntax, 4388semanticModel: null, lockedValue.Syntax, 4409IOperation condition = new LocalReferenceOperation(lockStatement.LockTakenSymbol, isDeclaration: false, semanticModel: null, lockedValue.Syntax, 4433lockedValue.Syntax, 4435semanticModel: null, lockedValue.Syntax, 4564operand.Syntax, targetType, constantValue: null, isImplicit: true); 4585AddStatement(new FlowCaptureOperation(localCopyCaptureId, operation.Collection.Syntax, collection)); 4587collection = new FlowCaptureReferenceOperation(localCopyCaptureId, operation.Collection.Syntax, collection.Type, constantValue: null); 4593IOperation invocation = makeInvocation(operation.Collection.Syntax, 4599AddStatement(new FlowCaptureOperation(enumeratorCaptureId, operation.Collection.Syntax, invocation)); 4601result = new FlowCaptureReferenceOperation(enumeratorCaptureId, operation.Collection.Syntax, info.GetEnumeratorMethod.ReturnType, constantValue: null); 4607result = new InvalidOperation(ImmutableArray<IOperation>.Empty, semanticModel: null, operation.Collection.Syntax, 4622return new AwaitOperation(moveNext, semanticModel: null, operation.Syntax, _compilation.GetSpecialType(SpecialType.System_Boolean), isImplicit: true); 4644operation.LoopControlVariable.Syntax, 4667declarator.Syntax, 4673declarator.Syntax, 4684operation.LoopControlVariable.Syntax, operation.LoopControlVariable.Type, 4689current, semanticModel: null, operation.LoopControlVariable.Syntax, 4697return makeInvocation(instance.Syntax, method, method.IsStatic ? null : instance, arguments); 4785operation.LoopControlVariable.Syntax, loopObject.Type, 4802return MakeInvalidOperation(operation.LimitValue.Syntax, booleanType, builder.ToImmutableAndFree()); 4827semanticModel: null, isInitialization ? value.Syntax : syntax, isImplicit: true); 4834semanticModel: null, operation.LimitValue.Syntax, method.ReturnType, 4873IOperation condition = tryCallObjectForLoopControlHelper(operation.LoopControlVariable.Syntax, 4948isUp = new LiteralOperation(semanticModel: null, stepValue.Syntax, booleanType, constantValue: ConstantValue.Create(false), isImplicit: true); 4950AddStatement(new FlowCaptureOperation(positiveFlagId, isUp.Syntax, isUp)); 4956IOperation literal = new LiteralOperation(semanticModel: null, stepValue.Syntax, stepValue.Type, 4970stepValue.Syntax, 4975AddStatement(new FlowCaptureOperation(positiveFlagId, isUp.Syntax, isUp)); 4992semanticModel: null, operation.InitialValue.Syntax, type: null, 5028IOperation condition = tryCallObjectForLoopControlHelper(operation.LimitValue.Syntax, 5124operation.LimitValue.Syntax, 5139condition = MakeInvalidOperation(operation.LimitValue.Syntax, booleanType, PopOperand(), limitReference); 5161operation.StepValue.Syntax, 5202operation.LimitValue.Syntax, 5222operation.LimitValue.Syntax, 5243var shiftConst = new LiteralOperation(semanticModel: null, operand.Syntax, _compilation.GetSpecialType(SpecialType.System_Int32), 5256operand.Syntax, 5271operand.Syntax, 5309controlVariableReferenceForAssignment.Syntax, 5344operation.StepValue.Syntax, 5360controlVariableReferenceForAssignment.Syntax, 5365controlVariableReferenceForAssignment.Syntax, 5395operation.StepValue.Syntax, 5412controlVariableReferenceForAssignment.Syntax, 5432declarator.Syntax, local.Type, constantValue: null, isImplicit: true); 5446return new FlowCaptureReferenceOperation(id, underlying.Syntax, underlying.Type, underlying.GetConstantValue()); 5589compareWith.Syntax, 5610patternClause.Pattern.Syntax, booleanType, isImplicit: true); 5833var initializationSemaphore = new StaticLocalInitializationSemaphoreOperation(localSymbol, declarator.Syntax, booleanType); 5847assignmentSyntax = declarator.Syntax; 5853assignmentSyntax = declaration.Syntax; 5858declaration.Syntax, 5876var localRef = new LocalReferenceOperation(localSymbol, isDeclaration: true, semanticModel: null, declarator.Syntax, localSymbol.Type, constantValue: null, isImplicit: true); 5933return new InvocationOperation(operation.TargetMethod, operation.ConstrainedToType, visitedInstance, operation.IsVirtual, visitedArguments, semanticModel: null, operation.Syntax, 5943return new FunctionPointerInvocationOperation(visitedPointer, visitedArguments, semanticModel: null, operation.Syntax, 5976IOperation initializedInstance = new NoPiaObjectCreationOperation(initializer: null, semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 5988operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation)); 5996var initializedInstance = new TypeParameterObjectCreationOperation(initializer: null, semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 6009hasDynamicArguments.ArgumentRefKinds, semanticModel: null, operation.Syntax, 6096result = new SimpleAssignmentOperation(assignmentOperation.IsRef, left, right, semanticModel: null, assignmentOperation.Syntax, 6234fieldReference.Syntax, fieldReference.Type, fieldReference.GetConstantValue(), IsImplicit(fieldReference)); 6238return new EventReferenceOperation(eventReference.Event, eventReference.ConstrainedToType, instance, semanticModel: null, eventReference.Syntax, 6244return new PropertyReferenceOperation(propertyReference.Property, propertyReference.ConstrainedToType, propertyArguments, instance, semanticModel: null, propertyReference.Syntax, 6250return new ArrayElementReferenceOperation(instance, indices, semanticModel: null, originalTarget.Syntax, originalTarget.Type, IsImplicit(originalTarget)); 6257semanticModel: null, originalTarget.Syntax, originalTarget.Type, IsImplicit(originalTarget)); 6269dynamicReference.ContainingType, semanticModel: null, dynamicReference.Syntax, 6360return MakeInvalidOperation(operation.Syntax, operation.Type, ImmutableArray<IOperation>.Empty); 6366return MakeInvalidOperation(operation.Syntax, operation.Type, ImmutableArray<IOperation>.Empty); 6374operation.Syntax, operation.Type, IsImplicit(operation)); 6399propertyReference.Instance.Syntax, propertyReference.Instance.Type, IsImplicit(propertyReference.Instance)); 6401semanticModel: null, propertyReference.Syntax, propertyReference.Type, IsImplicit(propertyReference)); 6404semanticModel: null, simpleAssignment.Syntax, simpleAssignment.Type, simpleAssignment.GetConstantValue(), IsImplicit(simpleAssignment)); 6418operation.Syntax, operation.Type, IsImplicit(operation)); 6492operation.Syntax, operation.Type, IsImplicit(operation)); 6538return new ArrayInitializerOperation(builder.ToImmutableAndFree(), semanticModel: null, initializer.Syntax, IsImplicit(initializer)); 6561spread.Syntax, 6570operation.Syntax, 6596return MakeInvalidOperation(operation.Syntax, operation.Type, ImmutableArray<IOperation>.Empty); 6601return new FlowCaptureReferenceOperation(_currentInterpolatedStringHandlerCreationContext.HandlerPlaceholder, operation.Syntax, operation.Type, operation.GetConstantValue()); 6604return new InstanceReferenceOperation(operation.ReferenceKind, semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 6633dynamicMemberReference.ContainingType, semanticModel: null, dynamicMemberReference.Syntax, dynamicMemberReference.Type, IsImplicit(dynamicMemberReference)); 6642((HasDynamicArgumentsExpression)operation).ArgumentRefKinds, semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 6653((HasDynamicArgumentsExpression)operation).ArgumentRefKinds, semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 6659operation.ContainingType, semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 6665return new DeconstructionAssignmentOperation(visitedTarget, visitedValue, semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 6703return new TupleOperation(elementBuilder.ToImmutableAndFree(), tuple.NaturalType, semanticModel: null, tuple.Syntax, tuple.Type, IsImplicit(tuple)); 6713return new DeclarationExpressionOperation(VisitPreservingTupleOperations(operation.Expression), semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 6761return new NoneOperation(ImmutableArray<IOperation>.Empty, semanticModel: null, operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation)); 6767new NoneOperation(VisitArray(((Operation)operation).ChildOperations.ToImmutableArray()), semanticModel: null, operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation))); 6843ConditionalBranch(new FlowCaptureReferenceOperation(outParameterFlowCapture, outParameterPlaceholder.Syntax, outParameterPlaceholder.Type, constantValue: null), jumpIfTrue: false, resultBlock); 6890return new FlowCaptureReferenceOperation(handlerCaptureId, operation.Syntax, operation.Type, operation.GetConstantValue()); 6971return new FlowCaptureReferenceOperation(_currentInterpolatedStringHandlerCreationContext.OutPlaceholder, operation.Syntax, operation.Type, operation.GetConstantValue(), isInitialization: true); 6983return new InvalidOperation(ImmutableArray<IOperation>.Empty, semanticModel: null, operation.Syntax, operation.Type, operation.GetConstantValue(), isImplicit: true); 6996return new InvalidOperation(ImmutableArray<IOperation>.Empty, semanticModel: null, operation.Syntax, operation.Type, operation.GetConstantValue(), isImplicit: true); 7066rewrittenElement = new InterpolationOperation(rewrittenExpression, rewrittenAlignment, rewrittenFormatString, semanticModel: null, element.Syntax, IsImplicit(element)); 7071rewrittenElement = new InterpolatedStringTextOperation(rewrittenInterpolationText, semanticModel: null, element.Syntax, IsImplicit(element)); 7083return new InterpolatedStringOperation(partsBuilder.ToImmutableAndFree(), semanticModel: null, operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation)); 7099return new LiteralOperation(semanticModel: null, operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation)); 7104return new LiteralOperation(semanticModel: null, operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation)); 7109return new Utf8StringOperation(operation.Value, semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 7114return new LocalReferenceOperation(operation.Local, operation.IsDeclaration, semanticModel: null, operation.Syntax, 7120return new ParameterReferenceOperation(operation.Parameter, semanticModel: null, operation.Syntax, 7128operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation)); 7135operation.Syntax, operation.Type, IsImplicit(operation)); 7155return MakeInvalidOperation(operation.Syntax, operation.Type, ImmutableArray<IOperation>.Empty); 7164operation.Syntax, operation.Type, IsImplicit(operation)); 7171operation.Syntax, operation.Type, IsImplicit(operation)); 7176return new TypeOfOperation(operation.TypeOperand, semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 7181return new ParenthesizedOperation(VisitRequired(operation.Operand), semanticModel: null, operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation)); 7186return new AwaitOperation(VisitRequired(operation.Operation), semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 7191return new SizeOfOperation(operation.TypeOperand, semanticModel: null, operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation)); 7196return new StopOperation(semanticModel: null, operation.Syntax, IsImplicit(operation)); 7201return new IsTypeOperation(VisitRequired(operation.ValueOperand), operation.TypeOperand, operation.IsNegated, semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 7209operation.Syntax, operation.Parameter.Type, isImplicit: true); 7223operation.Syntax, fieldSymbol.ContainingType, isImplicit: true); 7225operation.Syntax, fieldSymbol.Type, constantValue: null, isImplicit: true); 7241operation.Syntax, propertySymbol.ContainingType, isImplicit: true); 7251operation.Syntax, parameter.Type, constantValue: null, isImplicit: true); 7255semanticModel: null, operation.Syntax, isImplicit: true); 7267semanticModel: null, operation.Syntax, propertySymbol.Type, isImplicit: true); 7280initializer.Syntax, rewrittenTarget.Type, constantValue: null, isImplicit: true); 7308semanticModel: null, operation.EventReference.Syntax, operation.EventReference.Type, IsImplicit(operation.EventReference)); 7321operation.Syntax, operation.Type, IsImplicit(operation)); 7354semanticModel: null, operation.EventReference.Syntax, operation.EventReference.Type, IsImplicit(operation.EventReference)); 7358operation.Syntax, IsImplicit(operation))); 7363return new AddressOfOperation(VisitRequired(operation.Reference), semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 7370operation.Kind, semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 7375return new DiscardOperation(operation.DiscardSymbol, semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 7380return new DiscardPatternOperation(pat.InputType, pat.NarrowedType, semanticModel: null, pat.Syntax, IsImplicit(pat)); 7385return new OmittedArgumentOperation(semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 7419return new PlaceholderOperation(operation.PlaceholderKind, semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 7424return new ConversionOperation(VisitRequired(operation.Operand), ((ConversionOperation)operation).ConversionConvertible, operation.IsTryCast, operation.IsChecked, semanticModel: null, operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation)); 7429return new DefaultValueOperation(semanticModel: null, operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation)); 7440operation.Syntax, operation.Type, IsImplicit(operation)); 7472IOperation initializedInstance = new InvalidOperation(children.ToImmutableAndFree(), semanticModel: null, operation.Syntax, operation.Type, 7496return new InvalidOperation(ImmutableArray<IOperation>.Empty, semanticModel: null, invalidOperation.Syntax, invalidOperation.Type, invalidOperation.GetConstantValue(), IsImplicit(invalidOperation)); 7503invalidOperation.Syntax, invalidOperation.Type, invalidOperation.GetConstantValue(), IsImplicit(operation))); 7522semanticModel: null, operation.Syntax, isImplicit); 7534return new ReDimClauseOperation(visitedOperand, visitedDimensionSizes, semanticModel: null, clause.Syntax, IsImplicit(clause)); 7545return new TranslatedQueryOperation(VisitRequired(operation.Operation), semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 7551syntax: operation.Syntax, isImplicit: IsImplicit(operation)); 7562syntax: operation.Syntax, 7602syntax: operation.Syntax, 7614syntax: operation.Syntax, 7625syntax: operation.Syntax, 7638operation.Syntax, 7650operation.Syntax, 7664operation.Syntax, 7679operation.Syntax, 7689syntax: operation.Syntax, 7696operation.Syntax, operation.Type, IsImplicit(operation)); 7714return new RangeOperation(visitedLeftOperand, visitedRightOperand, operation.IsLifted, operation.Method, semanticModel: null, operation.Syntax, operation.Type, isImplicit: IsImplicit(operation)); 7760arm.Syntax, booleanType, IsImplicit(arm)); 7795? MakeInvalidOperation(operation.Syntax, type: _compilation.GetSpecialType(SpecialType.System_Object), ImmutableArray<IOperation>.Empty) 7797matchFailureCtor, initializer: null, ImmutableArray<IArgumentOperation>.Empty, semanticModel: null, operation.Syntax, 7833BlockOperation logicalBlock = BlockOperation.CreateTemporaryBlock(statementsBuilder.ToImmutableAndFree(), ((Operation)operation).OwningSemanticModel!, operation.Syntax); 7936semanticModel: null, operation.Syntax, operation.Type, isImplicit: true); 8012var valueCaptureRef = new FlowCaptureReferenceOperation(valueCaptureId, operation.Operand.Syntax, 8033var oldInstance = new FlowCaptureReferenceOperation(oldValueCaptureId, operation.Operand.Syntax, 8043var extraValueCaptureRef = new FlowCaptureReferenceOperation(extraValueCaptureId, operation.Operand.Syntax, 8097return new AttributeOperation(Visit(operation.Operation, captureIdForResult)!, semanticModel: null, operation.Syntax, IsImplicit(operation));
Operations\OperationCloner.cs (5)
21return new NoneOperation(VisitArray(((Operation)operation).ChildOperations.ToImmutableArray()), ((Operation)operation).OwningSemanticModel, operation.Syntax, operation.Type, operation.GetConstantValue(), operation.IsImplicit); 32return new DynamicObjectCreationOperation(Visit(operation.Initializer), VisitArray(operation.Arguments), ((HasDynamicArgumentsExpression)operation).ArgumentNames, ((HasDynamicArgumentsExpression)operation).ArgumentRefKinds, ((Operation)operation).OwningSemanticModel, operation.Syntax, operation.Type, operation.IsImplicit); 37return new DynamicInvocationOperation(Visit(operation.Operation), VisitArray(operation.Arguments), ((HasDynamicArgumentsExpression)operation).ArgumentNames, ((HasDynamicArgumentsExpression)operation).ArgumentRefKinds, ((Operation)operation).OwningSemanticModel, operation.Syntax, operation.Type, operation.IsImplicit); 42return new DynamicIndexerAccessOperation(Visit(operation.Operation), VisitArray(operation.Arguments), ((HasDynamicArgumentsExpression)operation).ArgumentNames, ((HasDynamicArgumentsExpression)operation).ArgumentRefKinds, ((Operation)operation).OwningSemanticModel, operation.Syntax, operation.Type, operation.IsImplicit); 47return new InvalidOperation(VisitArray(((InvalidOperation)operation).Children), ((Operation)operation).OwningSemanticModel, operation.Syntax, operation.Type, operation.GetConstantValue(), operation.IsImplicit);
Operations\OperationExtensions.cs (4)
41if (operation.Syntax == null) 51if (model is null || model.SyntaxTree != operation.Syntax.SyntaxTree) 53model = compilation.GetSemanticModel(operation.Syntax.SyntaxTree); 63return model.GetDiagnostics(operation.Syntax.Span, cancellationToken).Any(static d => d.DefaultSeverity == DiagnosticSeverity.Error);
Operations\OperationMapBuilder.cs (4)
113!argument.ContainsKey(operation.Syntax), 114$"Duplicate operation node for {operation.Syntax}. Existing node is {(argument.TryGetValue(operation.Syntax, out var original) ? (OperationKind?)original.Kind : null)}, new node is {operation.Kind}."); 115argument.Add(operation.Syntax, operation);
Operations\OperationNodes.cs (1)
156base(semanticModel: null, original.Syntax, isImplicit)
Microsoft.CodeAnalysis.Analyzers (51)
MetaAnalyzers\CompareSymbolsCorrectlyAnalyzer.cs (2)
163context.ReportDiagnostic(binary.Syntax.GetLocation().CreateDiagnostic(s_equalityRule, s_EqualityRuleProperties)); 195context.ReportDiagnostic(invocationOperation.Syntax.GetLocation().CreateDiagnostic(s_equalityRule, s_EqualityRuleProperties));
MetaAnalyzers\DiagnosticDescriptorCreationAnalyzer.cs (6)
896fieldReferenceOperation.Syntax.SyntaxTree == argumentValueOperation.Syntax.SyntaxTree && 899fieldDeclaration.SyntaxTree == argumentValueOperation.Syntax.SyntaxTree && 916valueLocation = valueOperation.Syntax.GetLocation(); 1211var location = argument.Value.Syntax.GetLocation(); 1250operationAnalysisContext.ReportDiagnostic(argument.Value.Syntax.CreateDiagnostic(DoNotUseReservedDiagnosticIdRule, ruleId));
MetaAnalyzers\DoNotUseCompilationGetSemanticModelAnalyzer.cs (1)
68operationContext.ReportDiagnostic(invocation.Syntax.CreateDiagnostic(Rule));
MetaAnalyzers\Fixers\CompareSymbolsCorrectlyFix.cs (12)
96document, objectCreation.Syntax, objectCreation.Constructor, objectCreation.Arguments, isUsedAsExtensionMethod: false, 102document, invocation.Syntax, invocation.TargetMethod, invocation.Arguments, IsExtensionMethodUsedAsSuch(invocation), 128var syntaxArguments = arguments.Skip(extensionMethodShift).Select(x => x.Syntax).ToList(); 204conditionalAccessMembers.Add(conditionalAccess.Operation.Syntax); 210var nodeToReplace = currentOperation.Syntax; 219var arguments = invocationOperation.Arguments.Select(argument => argument.Syntax); 228return new[] { instance.Syntax }.Concat(arguments); 258var expression = binaryOperation.Syntax; 267binaryOperation.LeftOperand.Syntax.WithoutLeadingTrivia(), 268binaryOperation.RightOperand.Syntax.WithoutTrailingTrivia()), 275binaryOperation.LeftOperand.Syntax.WithoutLeadingTrivia(), 276binaryOperation.RightOperand.Syntax.WithoutTrailingTrivia())
MetaAnalyzers\Fixers\DefineDiagnosticDescriptorArgumentsCorrectlyFix.cs (2)
163var newLiteral = generator.LiteralExpression(fixInfo.FixValue).WithTriviaFrom(literal.Syntax); 164var newRoot = root.ReplaceNode(literal.Syntax, newLiteral);
src\RoslynAnalyzers\Microsoft.CodeAnalysis.BannedApiAnalyzers\Core\SymbolIsBannedAnalyzerBase.cs (17)
77VerifySymbol(context.ReportDiagnostic, objectCreation.Constructor, context.Operation.Syntax); 78VerifyType(context.ReportDiagnostic, objectCreation.Type, context.Operation.Syntax); 82VerifySymbol(context.ReportDiagnostic, invocation.TargetMethod, context.Operation.Syntax); 83VerifyType(context.ReportDiagnostic, invocation.TargetMethod.ContainingType, context.Operation.Syntax); 87VerifySymbol(context.ReportDiagnostic, memberReference.Member, context.Operation.Syntax); 88VerifyType(context.ReportDiagnostic, memberReference.Member.ContainingType, context.Operation.Syntax); 92VerifyType(context.ReportDiagnostic, arrayCreation.Type, context.Operation.Syntax); 96VerifyType(context.ReportDiagnostic, addressOf.Type, context.Operation.Syntax); 102VerifySymbol(context.ReportDiagnostic, conversion.OperatorMethod, context.Operation.Syntax); 103VerifyType(context.ReportDiagnostic, conversion.OperatorMethod.ContainingType, context.Operation.Syntax); 111VerifySymbol(context.ReportDiagnostic, unary.OperatorMethod, context.Operation.Syntax); 112VerifyType(context.ReportDiagnostic, unary.OperatorMethod.ContainingType, context.Operation.Syntax); 120VerifySymbol(context.ReportDiagnostic, binary.OperatorMethod, context.Operation.Syntax); 121VerifyType(context.ReportDiagnostic, binary.OperatorMethod.ContainingType, context.Operation.Syntax); 129VerifySymbol(context.ReportDiagnostic, incrementOrDecrement.OperatorMethod, context.Operation.Syntax); 130VerifyType(context.ReportDiagnostic, incrementOrDecrement.OperatorMethod.ContainingType, context.Operation.Syntax); 135VerifyType(context.ReportDiagnostic, typeOfOperation.TypeOperand, context.Operation.Syntax);
src\RoslynAnalyzers\Utilities\Compiler\DoNotCatchGeneralUnlessRethrown.cs (1)
83operationBlockAnalysisContext.ReportDiagnostic(CreateDiagnostic(method, catchClause.Syntax.GetFirstToken()));
src\RoslynAnalyzers\Utilities\Compiler\Extensions\DiagnosticExtensions.cs (2)
57return operation.Syntax.CreateDiagnostic(rule, properties, args); 67return operation.Syntax.CreateDiagnostic(rule, additionalLocations, properties, args);
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IOperationExtensions.cs (7)
35GetReceiverType(invocation.Instance.Syntax, compilation, cancellationToken) : 44GetReceiverType(firstArg.Value.Syntax, compilation, cancellationToken) : 312return operation.GetAncestor(OperationKind.ConditionalAccess, (IConditionalAccessOperation c) => c.Operation.Syntax == operation.Syntax); 340if (current.Syntax == operation.Syntax) 640=> invocationOperation.GetInstance()?.Syntax;
src\RoslynAnalyzers\Utilities\Compiler\Extensions\OperationBlockAnalysisContextExtension.cs (1)
47(body.Operations.Length == 3 && body.Syntax.Language == LanguageNames.VisualBasic &&
Microsoft.CodeAnalysis.AnalyzerUtilities (38)
src\RoslynAnalyzers\Utilities\Compiler\DoNotCatchGeneralUnlessRethrown.cs (1)
83operationBlockAnalysisContext.ReportDiagnostic(CreateDiagnostic(method, catchClause.Syntax.GetFirstToken()));
src\RoslynAnalyzers\Utilities\Compiler\Extensions\DiagnosticExtensions.cs (2)
57return operation.Syntax.CreateDiagnostic(rule, properties, args); 67return operation.Syntax.CreateDiagnostic(rule, additionalLocations, properties, args);
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IOperationExtensions.cs (7)
35GetReceiverType(invocation.Instance.Syntax, compilation, cancellationToken) : 44GetReceiverType(firstArg.Value.Syntax, compilation, cancellationToken) : 312return operation.GetAncestor(OperationKind.ConditionalAccess, (IConditionalAccessOperation c) => c.Operation.Syntax == operation.Syntax); 340if (current.Syntax == operation.Syntax) 640=> invocationOperation.GetInstance()?.Syntax;
src\RoslynAnalyzers\Utilities\Compiler\Extensions\OperationBlockAnalysisContextExtension.cs (1)
47(body.Operations.Length == 3 && body.Syntax.Language == LanguageNames.VisualBasic &&
src\RoslynAnalyzers\Utilities\FlowAnalysis\Extensions\ControlFlowGraphExtensions.cs (1)
53if (cfg.OriginalOperation.Syntax.GetDiagnostics().Any(d => d.DefaultSeverity == DiagnosticSeverity.Error) ||
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\ParameterValidationAnalysis\ParameterValidationAnalysis.cs (3)
51var performCopyAnalysis = analyzerOptions.GetCopyAnalysisOption(rule, topmostBlock.Syntax.SyntaxTree, compilation, defaultValue: false); 52var nullCheckValidationMethods = analyzerOptions.GetNullCheckValidationMethodsOption(rule, topmostBlock.Syntax.SyntaxTree, compilation); 53var pointsToAnalysisKind = analyzerOptions.GetPointsToAnalysisKindOption(rule, topmostBlock.Syntax.SyntaxTree, compilation, defaultPointsToAnalysisKind);
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\ParameterValidationAnalysis\ParameterValidationAnalysis.ParameterValidationDataFlowOperationVisitor.cs (1)
183HandleHazardousOperation(operation.Syntax, nonValidatedLocations);
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\PropertySetAnalysis\PropertySetAnalysis.PropertySetDataFlowOperationVisitor.cs (6)
201operation.Syntax, 397assignmentOperation.Syntax, 421assignmentOperation.Syntax, 466visitedArgument.Value.Syntax, 490originalOperation.Syntax, 659returnValue.Syntax,
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\TaintedDataAnalysis\TaintedDataAnalysis.TaintedDataOperationVisitor.cs (6)
236return TaintedDataAbstractValue.CreateTainted(propertyReferenceOperation.Member, propertyReferenceOperation.Syntax, this.OwningSymbol); 323this.CacheAbstractValue(argumentOperation, TaintedDataAbstractValue.CreateTainted(argumentOperation.Parameter, argumentOperation.Syntax, method)); 332result = TaintedDataAbstractValue.CreateTainted(method, originalOperation.Syntax, this.OwningSymbol); 508TaintedDataAbstractValue taintedDataAbstractValue = TaintedDataAbstractValue.CreateTainted(arrayTypeSymbol, arrayCreationOperation.Syntax, this.OwningSymbol); 572this.TrackTaintedDataEnteringSink(targetMethod, originalOperation.Syntax.GetLocation(), sinkKinds, abstractValue.SourceOrigins); 608propertyReferenceOperation.Syntax.GetLocation(),
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\TaintedDataAnalysis\TaintedDataSymbolMapExtensions.cs (3)
70pointsToAnalysisResult[o.Kind, o.Syntax]).ToImmutableArray())); 93arguments.Select(o => pointsToAnalysisResult[o.Kind, o.Syntax]).ToImmutableArray(), 94arguments.Select(o => valueContentAnalysisResult[o.Kind, o.Syntax]).ToImmutableArray()));
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Framework\DataFlow\AbstractLocation.cs (2)
151return Creation?.Syntax; 188return operation.Syntax;
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Framework\DataFlow\AnalysisEntity.cs (1)
76: this(symbol: null, indices: ImmutableArray<AbstractIndex>.Empty, instanceReferenceOperationSyntax: instanceReferenceOperation.Syntax,
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Framework\DataFlow\DataFlowAnalysisResult.cs (1)
130if (kvp.Key.Kind == operationKind && kvp.Key.Syntax == syntax)
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Framework\DataFlow\DataFlowOperationVisitor.cs (1)
1300Debug.Fail($"Unexpected 'null' target type for '{operation.Syntax}'");
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Framework\DataFlow\InterproceduralAnalysisConfiguration.cs (2)
49=> Create(analyzerOptions, rule, cfg.OriginalOperation.Syntax.SyntaxTree, compilation, defaultInterproceduralAnalysisKind, 101var tree = operation.Syntax.SyntaxTree;
Microsoft.CodeAnalysis.BannedApiAnalyzers (29)
RestrictedInternalsVisibleToAnalyzer.cs (1)
100VerifySymbol(symbol, context.Operation.Syntax,
src\RoslynAnalyzers\Utilities\Compiler\DoNotCatchGeneralUnlessRethrown.cs (1)
83operationBlockAnalysisContext.ReportDiagnostic(CreateDiagnostic(method, catchClause.Syntax.GetFirstToken()));
src\RoslynAnalyzers\Utilities\Compiler\Extensions\DiagnosticExtensions.cs (2)
57return operation.Syntax.CreateDiagnostic(rule, properties, args); 67return operation.Syntax.CreateDiagnostic(rule, additionalLocations, properties, args);
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IOperationExtensions.cs (7)
35GetReceiverType(invocation.Instance.Syntax, compilation, cancellationToken) : 44GetReceiverType(firstArg.Value.Syntax, compilation, cancellationToken) : 312return operation.GetAncestor(OperationKind.ConditionalAccess, (IConditionalAccessOperation c) => c.Operation.Syntax == operation.Syntax); 340if (current.Syntax == operation.Syntax) 640=> invocationOperation.GetInstance()?.Syntax;
src\RoslynAnalyzers\Utilities\Compiler\Extensions\OperationBlockAnalysisContextExtension.cs (1)
47(body.Operations.Length == 3 && body.Syntax.Language == LanguageNames.VisualBasic &&
SymbolIsBannedAnalyzerBase.cs (17)
77VerifySymbol(context.ReportDiagnostic, objectCreation.Constructor, context.Operation.Syntax); 78VerifyType(context.ReportDiagnostic, objectCreation.Type, context.Operation.Syntax); 82VerifySymbol(context.ReportDiagnostic, invocation.TargetMethod, context.Operation.Syntax); 83VerifyType(context.ReportDiagnostic, invocation.TargetMethod.ContainingType, context.Operation.Syntax); 87VerifySymbol(context.ReportDiagnostic, memberReference.Member, context.Operation.Syntax); 88VerifyType(context.ReportDiagnostic, memberReference.Member.ContainingType, context.Operation.Syntax); 92VerifyType(context.ReportDiagnostic, arrayCreation.Type, context.Operation.Syntax); 96VerifyType(context.ReportDiagnostic, addressOf.Type, context.Operation.Syntax); 102VerifySymbol(context.ReportDiagnostic, conversion.OperatorMethod, context.Operation.Syntax); 103VerifyType(context.ReportDiagnostic, conversion.OperatorMethod.ContainingType, context.Operation.Syntax); 111VerifySymbol(context.ReportDiagnostic, unary.OperatorMethod, context.Operation.Syntax); 112VerifyType(context.ReportDiagnostic, unary.OperatorMethod.ContainingType, context.Operation.Syntax); 120VerifySymbol(context.ReportDiagnostic, binary.OperatorMethod, context.Operation.Syntax); 121VerifyType(context.ReportDiagnostic, binary.OperatorMethod.ContainingType, context.Operation.Syntax); 129VerifySymbol(context.ReportDiagnostic, incrementOrDecrement.OperatorMethod, context.Operation.Syntax); 130VerifyType(context.ReportDiagnostic, incrementOrDecrement.OperatorMethod.ContainingType, context.Operation.Syntax); 135VerifyType(context.ReportDiagnostic, typeOfOperation.TypeOperand, context.Operation.Syntax);
Microsoft.CodeAnalysis.CodeStyle (58)
src\Analyzers\Core\Analyzers\ConvertTypeofToNameof\AbstractConvertTypeOfToNameOfDiagnosticAnalyzer.cs (1)
34var node = context.Operation.Syntax;
src\Analyzers\Core\Analyzers\PopulateSwitch\AbstractPopulateSwitchDiagnosticAnalyzer.cs (1)
51if (switchOperation.Syntax is not TSwitchSyntax switchBlock || IsSwitchTypeUnknown(switchOperation))
src\Analyzers\Core\Analyzers\QualifyMemberAccess\AbstractQualifyMemberAccessDiagnosticAnalyzer.cs (2)
95if (!CanMemberAccessBeQualified(context.ContainingSymbol, instanceOperation.Syntax)) 103if (instanceOperation.Syntax is not TSimpleNameSyntax simpleName)
src\Analyzers\Core\Analyzers\RemoveRedundantEquality\AbstractRemoveRedundantEqualityDiagnosticAnalyzer.cs (2)
34var syntax = context.Operation.Syntax; 56var syntax = context.Operation.Syntax;
src\Analyzers\Core\Analyzers\RemoveUnusedMembers\AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (3)
357var methods = _analyzer.SemanticFacts.GetDeconstructionAssignmentMethods(operation.SemanticModel!, operation.Syntax); 451var symbols = _analyzer.SemanticFacts.GetForEachSymbols(operation.SemanticModel!, loopOperation.Syntax); 489var symbolInfo = nameofArgument.SemanticModel!.GetSymbolInfo(nameofArgument.Syntax, operationContext.CancellationToken);
src\Analyzers\Core\Analyzers\RemoveUnusedParametersAndValues\AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.BlockAnalyzer.cs (7)
99if (!symbolStartAnalyzer._compilationAnalyzer.TryGetOptions(firstBlock.Syntax.SyntaxTree, 116firstBlock.Syntax.SyntaxTree != filterTree) 126var root = firstBlock.Syntax.SyntaxTree.GetRoot(context.CancellationToken); 127var spanStart = firstBlock.Syntax.SpanStart; 140if (operationBlock.Syntax.GetDiagnostics().ToImmutableArrayOrEmpty().HasAnyErrors()) 151if (operationBlock.Syntax.DescendantNodes(descendIntoTrivia: true) 216value.Syntax.GetLocation(),
src\Analyzers\Core\Analyzers\SimplifyInterpolation\AbstractSimplifyInterpolationDiagnosticAnalyzer.cs (1)
85additionalLocations: [interpolation.Syntax.GetLocation()],
src\Analyzers\Core\Analyzers\SimplifyInterpolation\AbstractSimplifyInterpolationHelpers.cs (7)
58.SelectAsArray(interpolation.Syntax.SyntaxTree.GetLocation); 95!syntaxFacts.IsBaseExpression(instance.Syntax) && 109unnecessarySpans.AddRange(invocation.Syntax.Span 111.Subtract(GetSpanWithinLiteralQuotes(virtualCharService, literal.Syntax.GetFirstToken()))); 124unnecessarySpans.AddRange(invocation.Syntax.Span 228var alignmentSyntax = alignmentOp.Syntax; 234unnecessarySpans.AddRange(invocation.Syntax.Span
src\Analyzers\Core\Analyzers\SimplifyLinqExpression\AbstractSimplifyLinqExpressionDiagnosticAnalyzer.cs (4)
123if (context.Operation.Syntax.GetDiagnostics().Any(diagnostic => diagnostic.Severity == DiagnosticSeverity.Error)) 173context.ReportDiagnostic(Diagnostic.Create(Descriptor, nextInvocation.Syntax.GetLocation())); 187if (invocation.Syntax is not TInvocationExpressionSyntax invocationNode || 199if (invocation.Syntax is not TInvocationExpressionSyntax invocationNode ||
src\Analyzers\Core\Analyzers\UseConditionalExpression\AbstractUseConditionalExpressionDiagnosticAnalyzer.cs (1)
41if (ifOperation.Syntax is not TIfStatementSyntax ifStatement)
src\Analyzers\Core\Analyzers\UseConditionalExpression\ForAssignment\UseConditionalExpressionForAssignmentHelpers.cs (6)
54!syntaxFacts.AreEquivalent(trueAssignment.Target.Syntax, falseAssignment.Target.Syntax)) 95if (ContainsReference(nullCheckedExpression.Syntax, trueAssignment?.Target.Syntax) || 96ContainsReference(nullCheckedExpression.Syntax, falseAssignment?.Target.Syntax))
src\Analyzers\Core\Analyzers\UseConditionalExpression\UseConditionalExpressionHelpers.cs (7)
41if (syntaxFacts.SpansPreprocessorDirective(ifOperation.Syntax, whenFalse.Syntax)) 47if (HasRegularComments(syntaxFacts, whenTrue.Syntax) || 48HasRegularComments(syntaxFacts, whenFalse.Syntax)) 58var whenTrueSymbols = semanticModel.GetAllDeclaredSymbols(whenTrue.Syntax, cancellationToken, n => !syntaxFacts.IsAnonymousOrLocalFunction(n)); 59var whenFalseSymbols = semanticModel.GetAllDeclaredSymbols(whenFalse.Syntax, cancellationToken, n => !syntaxFacts.IsAnonymousOrLocalFunction(n)); 106if (!syntaxFacts.SupportsThrowExpression(anyThrow.Syntax.SyntaxTree.Options))
src\Analyzers\Core\Analyzers\UseExplicitTupleName\UseExplicitTupleNameDiagnosticAnalyzer.cs (1)
57var memberAccessSyntax = fieldReferenceOperation.Syntax;
src\Analyzers\Core\Analyzers\UseSystemHashCode\UseSystemHashCodeDiagnosticAnalyzer.cs (2)
72var option = context.Options.GetAnalyzerOptions(operation.Syntax.SyntaxTree).PreferSystemHashCode; 77var operationLocation = operation.Syntax.GetLocation();
src\Analyzers\Core\Analyzers\UseThrowExpression\AbstractUseThrowExpressionDiagnosticAnalyzer.cs (9)
77var throwStatementSyntax = throwOperation.Syntax; 129ifOperation.Syntax.GetLocation(), 130throwOperation.Exception.Syntax.GetLocation(), 131assignmentExpression.Value.Syntax.GetLocation(), 132expressionStatement.Syntax.GetLocation()); 149statements[ifOperationIndex + 1].Syntax, 150statements[expressionStatementIndex - 1].Syntax); 161var exprDataFlow = semanticModel.AnalyzeDataFlow(assignmentExpression.Target.Syntax); 272var throwStatement = throwOperation.Syntax;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\AnalysisContextExtensions.cs (3)
186=> operationBlock.Syntax.FindNode(context.FilterSpan, findInTrivia, getInnermostNodeForTie); 192=> operationBlock.Syntax.FindNode(context.FilterSpan, findInTrivia, getInnermostNodeForTie); 198=> context.Operation.Syntax.FindNode(context.FilterSpan, findInTrivia, getInnermostNodeForTie);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\SymbolUsageAnalysis.DataFlowAnalyzer.FlowGraphAnalysisData.cs (1)
193var dataFlow = operation.SemanticModel.AnalyzeDataFlow(operation.Syntax);
Microsoft.CodeAnalysis.CodeStyle.Fixes (20)
src\Analyzers\Core\CodeFixes\SimplifyInterpolation\AbstractSimplifyInterpolationCodeFixProvider.cs (1)
59if (interpolation?.Syntax is TInterpolationSyntax interpolationSyntax &&
src\Analyzers\Core\CodeFixes\UseConditionalExpression\AbstractUseConditionalExpressionCodeFixProvider.cs (4)
116trueValue.Syntax, falseValue.Syntax, formattingOptions, cancellationToken).ConfigureAwait(false); 133=> (TExpressionSyntax)operation.Condition.Syntax; 171var sourceSyntax = value.Syntax;
src\Analyzers\Core\CodeFixes\UseConditionalExpression\ForAssignment\AbstractUseConditionalExpressionForAssignmentCodeFixProvider.cs (7)
111var ifStatement = (TIfStatementSyntax)ifOperation.Syntax; 112var assignment = generator.AssignmentStatement(assignmentOperation.Target.Syntax, conditionalExpression); 117conditionalAccess.Operation.Syntax, 124ifOperation.Syntax, 142var localDeclaration = localDeclarationOperation.Syntax; 156editor.RemoveNode(ifOperation.Syntax, GetRemoveOptions(syntaxFacts, ifOperation.Syntax));
src\Analyzers\Core\CodeFixes\UseConditionalExpression\ForReturn\AbstractUseConditionalExpressionForReturnCodeFixProvider.cs (2)
92editor.RemoveNode(falseStatement.Syntax, GetRemoveOptions(syntaxFacts, falseStatement.Syntax));
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\InitializeParameter\AbstractInitializerParameterService.cs (2)
176return statement.Syntax; 181return statementIndex > 0 && blockStatement.Operations[statementIndex - 1] is { IsImplicit: false, Syntax: var priorSyntax }
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\NullableHelpers.cs (4)
76assignmentOperation.Syntax.RawKind == semanticFacts.SyntaxFacts.SyntaxKinds.SimpleAssignmentExpression) 83var typeInfo = semanticModel.GetTypeInfo(assignmentOperation.Value.Syntax, cancellationToken); 99var foreachInfo = semanticFacts.GetForEachSymbols(semanticModel, forEachLoop.Syntax); 111var syntax = variableDeclarator.GetVariableInitializer()!.Value.Syntax;
Microsoft.CodeAnalysis.CSharp (6)
Operations\CSharpOperationFactory.cs (3)
1050Debug.Assert(isImplicit || target.Syntax != syntax || target.IsImplicit || boundConversion.ConversionGroupOpt != null); 1052isImplicit = isImplicit || (target.Syntax == syntax && !target.IsImplicit); 2369Debug.Assert(valueOperation.Syntax != part.Syntax);
Operations\CSharpOperationFactory_Methods.cs (3)
40(SyntaxNode syntax, bool isImplicit) = expression.Syntax is { Parent: ArgumentSyntax or AttributeArgumentSyntax } ? (expression.Syntax.Parent, expression.WasCompilerGenerated) : (value.Syntax, true); 446syntax: value.Syntax, 464var assignmentSyntax = value.Syntax?.Parent ?? syntax;
Microsoft.CodeAnalysis.CSharp.Analyzers (1)
MetaAnalyzers\Fixers\CSharpCompareSymbolsCorrectlyFix.cs (1)
23=> ((InvocationExpressionSyntax)invocationOperation.Syntax).Expression;
Microsoft.CodeAnalysis.CSharp.CodeStyle (56)
src\Analyzers\CSharp\Analyzers\ConvertTypeofToNameof\CSharpConvertTypeOfToNameOfDiagnosticAnalyzer.cs (1)
23var node = context.Operation.Syntax;
src\Analyzers\CSharp\Analyzers\MakeStructMemberReadOnly\CSharpMakeStructMemberReadOnlyAnalyzer.cs (4)
271CSharpSemanticFacts.Instance.IsWrittenTo(semanticModel, instanceOperation.Syntax, cancellationToken)) 293if (CSharpSemanticFacts.Instance.IsWrittenTo(semanticModel, fieldReference.Syntax, cancellationToken)) 304if (CSharpSemanticFacts.Instance.IsWrittenTo(semanticModel, propertyReference.Syntax, cancellationToken)) 335if (CSharpSemanticFacts.Instance.IsWrittenTo(semanticModel, operation.Syntax, cancellationToken))
src\Analyzers\CSharp\Analyzers\QualifyMemberAccess\CSharpQualifyMemberAccessDiagnosticAnalyzer.cs (1)
67protected override Location GetLocation(IOperation operation) => operation.Syntax.GetLocation();
src\Analyzers\CSharp\Analyzers\RemoveUnusedParametersAndValues\CSharpRemoveUnusedParametersAndValuesDiagnosticAnalyzer.cs (6)
69var statementAncestor = unusedSymbolWriteOperation.Syntax.FirstAncestorOrSelf<StatementSyntax>()?.Parent; 79!blockOperation.Syntax.IsKind(SyntaxKind.Block); 83switch (unusedDefinition.Syntax) 103if (unusedDefinition.Syntax.Parent is ForEachStatementSyntax forEachStatement && 104forEachStatement.Type == unusedDefinition.Syntax) 109return unusedDefinition.Syntax.GetLocation();
src\Analyzers\CSharp\Analyzers\SimplifyInterpolation\CSharpSimplifyInterpolationHelpers.cs (1)
21return operation.Syntax switch
src\Analyzers\CSharp\Analyzers\UseConditionalExpression\CSharpUseConditionalExpressionForReturnDiagnosticAnalyzer.cs (1)
39if (block.Syntax.Parent is UnsafeStatementSyntax or CheckedStatementSyntax)
src\Analyzers\CSharp\Analyzers\UseIndexOrRangeOperator\CSharpUseIndexOperatorDiagnosticAnalyzer.cs (2)
175if (subtraction.Syntax is not BinaryExpressionSyntax binaryExpression) 200if (CSharpSemanticFacts.Instance.IsInExpressionTree(semanticModel, instance.Syntax, infoCache.ExpressionOfTType, cancellationToken))
src\Analyzers\CSharp\Analyzers\UseIndexOrRangeOperator\CSharpUseRangeOperatorDiagnosticAnalyzer.cs (9)
85if (CSharpSemanticFacts.Instance.IsInExpressionTree(semanticModel, operation.Syntax, infoCache.ExpressionOfTType, context.CancellationToken)) 95if (invocation.Syntax is not InvocationExpressionSyntax invocationSyntax || 191if (!CSharpSyntaxFacts.Instance.AreEquivalent(lengthOperation.Syntax, subtraction.RightOperand.Syntax)) 207if (!CSharpSyntaxFacts.Instance.AreEquivalent(startOperation.Syntax, subtraction.RightOperand.Syntax)) 245if (CSharpSyntaxFacts.Instance.AreEquivalent(startOperation.Syntax, subtraction.RightOperand.Syntax)) 307return !invocation.Syntax.IsLeftSideOfAnyAssignExpression() || indexer == null || !IsWriteableIndexer(invocation, indexer);
src\Analyzers\CSharp\Analyzers\UseIndexOrRangeOperator\Helpers.cs (2)
48CSharpSyntaxFacts.Instance.AreEquivalent(instance.Syntax, propertyRef.Instance.Syntax);
src\Analyzers\CSharp\Analyzers\UseIsNullCheck\CSharpUseNullCheckOverTypeCheckDiagnosticAnalyzer.cs (3)
60context.Operation.Syntax is not UnaryPatternSyntax) 80Descriptor, context.Operation.Syntax.GetLocation(), notificationOption, context.Options, additionalLocations: null, properties: null)); 88var syntax = operation.Syntax;
src\Analyzers\CSharp\Analyzers\UsePatternCombinators\CSharpUsePatternCombinatorsAnalyzer.cs (9)
18return pattern?.Target.Syntax is ExpressionSyntax ? pattern : null; 49case IBinaryOperation { OperatorKind: ConditionalOr, Syntax: BinaryExpressionSyntax syntax } op: 52case IBinaryOperation { OperatorKind: ConditionalAnd, Syntax: BinaryExpressionSyntax syntax } op: 61case IIsTypeOperation { Syntax: BinaryExpressionSyntax binaryExpression } op: 64case IIsPatternOperation { Pattern.Syntax: PatternSyntax pattern } op: 101ConstantResult.Left when op.LeftOperand.Syntax is ExpressionSyntax left 106ConstantResult.Right when op.RightOperand.Syntax is ExpressionSyntax right 116ConstantResult.Left when op.LeftOperand.Syntax is ExpressionSyntax left 118ConstantResult.Right when op.RightOperand.Syntax is ExpressionSyntax right
src\Analyzers\CSharp\Analyzers\UsePrimaryConstructor\CSharpUsePrimaryConstructorDiagnosticAnalyzer.cs (2)
512operation is IParameterReferenceOperation { Syntax: IdentifierNameSyntax parameterName } parameterReference) 574var symbols = semanticModel.LookupSymbols(operation.Syntax.SpanStart, name: parameter.Name);
src\Analyzers\CSharp\Analyzers\UseSystemThreadingLock\CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs (1)
185if (lockOperation.Syntax.ContainsYield())
src\Analyzers\CSharp\Analyzers\UseUtf8StringLiteral\UseUtf8StringLiteralDiagnosticAnalyzer.cs (10)
82if (arrayCreationOperation.Syntax.Ancestors().OfType<AttributeSyntax>().Any()) 88if (arrayCreationOperation.Syntax.IsInExpressionTree(semanticModel, expressionType, context.CancellationToken)) 101if (arrayCreationOperation.Syntax is ImplicitArrayCreationExpressionSyntax or ArrayCreationExpressionSyntax) 103ReportArrayCreationDiagnostic(context, arrayCreationOperation.Syntax, option.Notification); 105else if (elements is [{ Syntax.Parent: ArgumentSyntax }, ..]) 108ReportParameterArrayDiagnostic(context, arrayCreationOperation.Syntax, elements, option.Notification, ArrayCreationOperationLocation.Descendants); 110else if (elements is [{ Syntax.Parent: (kind: SyntaxKind.CollectionInitializerExpression) }, ..]) 114ReportParameterArrayDiagnostic(context, arrayCreationOperation.Syntax, elements, option.Notification, ArrayCreationOperationLocation.Ancestors); 124var span = TextSpan.FromBounds(elements[0].Syntax.SpanStart, elements[^1].Syntax.Span.End);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (3)
278conversionOperation.Syntax == castNode && 981if (IsExplicitCast(conversionOperation.Syntax)) 1501var argumentSyntax = argument?.Syntax as ArgumentSyntax;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseImplicitTypeHelper.cs (1)
239var argumentOp = invocationOp.Arguments.FirstOrDefault(a => a.Syntax == argument);
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (13)
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordHelpers.cs (3)
295? assignment.Syntax as ExpressionSyntax 305if (arg is { Parameter: IParameterSymbol param, Value.Syntax: ExpressionSyntax captured }) 385Value: IOperation { Syntax: ExpressionSyntax syntax }
src\Analyzers\CSharp\CodeFixes\MakeLocalFunctionStatic\MakeLocalFunctionStaticCodeFixHelper.cs (2)
156syntaxEditor.ReplaceNode(instanceReference.Syntax, IdentifierName("@this")); 158else if (instanceReference.Syntax is SimpleNameSyntax name)
src\Analyzers\CSharp\CodeFixes\UseConditionalExpression\CSharpUseConditionalExpressionForAssignmentCodeFixProvider.cs (1)
38=> (VariableDeclaratorSyntax)declarator.Syntax;
src\Analyzers\CSharp\CodeFixes\UseConditionalExpression\CSharpUseConditionalExpressionForReturnCodeFixProvider.cs (2)
46if (operation.Syntax is IfStatementSyntax { Condition: CheckedExpressionSyntax exp }) 54if (returnOperation.Syntax is ReturnStatementSyntax { Expression: CheckedExpressionSyntax exp })
src\Analyzers\CSharp\CodeFixes\UseConditionalExpression\CSharpUseConditionalExpressionHelpers.cs (2)
20var throwStatement = (ThrowStatementSyntax)throwOperation.Syntax; 29var ifStatement = (IfStatementSyntax)originalIfStatement.Syntax;
src\Analyzers\CSharp\CodeFixes\UseUtf8StringLiteral\UseUtf8StringLiteralCodeFixProvider.cs (1)
120.Where(a => a.Initializer?.ElementValues.FirstOrDefault()?.Syntax.SpanStart == diagnostic.Location.SourceSpan.Start)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\InitializeParameter\InitializeParameterHelpers.cs (2)
158=> blockStatement?.Syntax is BlockSyntax block 160: blockStatement?.Syntax;
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (78)
Diagnostics\DiagnosticAnalyzerTests.cs (3)
2348ReportDiagnosticsCore(addDiagnostic, operation.Syntax.Location, $"Operation: {name}"); 3863context => context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(Rule, context.Operation.Syntax.GetLocation())), 3869context => context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(Rule, context.Operation.Syntax.GetLocation())),
Diagnostics\GetDiagnosticsTests.cs (6)
1108context => analyzeNode(context.Operation.Syntax, context.ContainingSymbol, context.ReportDiagnostic), 1115blockEndContext.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(DescriptorForBlockEnd, operationBlock.Syntax.GetLocation())); 1117if (operationBlock.Syntax is PropertyDeclarationSyntax or IndexerDeclarationSyntax) 1118throw new Exception($"Unexpected topmost node for operation block '{operationBlock.Syntax.Kind()}'"); 1771AssertEx.SetEqual(expectedOperationCallbacks, analyzer.AnalyzedOperations.Select(op => op.Syntax.ToString()).ToHashSet()); 1775AssertEx.SetEqual(expectedOperationInsideBlockCallbacks, analyzer.AnalyzedOperationsInsideOperationBlock.Select(op => op.Syntax.ToString()).ToHashSet());
Semantics\PrimaryConstructorTests.cs (37)
1158VerifyFlowGraph(comp, operation.Parent.Parent.Syntax, @" 4329Assert.Equal(SyntaxKind.ClassDeclaration, context.Operation.Syntax.Kind()); 4333Assert.Equal(SyntaxKind.ClassDeclaration, context.Operation.Syntax.Kind()); 4337Assert.Equal(SyntaxKind.ConstructorDeclaration, context.Operation.Syntax.Kind()); 4351Assert.Equal(SyntaxKind.PrimaryConstructorBaseType, context.Operation.Syntax.Kind()); 4366Assert.Equal(SyntaxKind.BaseConstructorInitializer, context.Operation.Syntax.Kind()); 4387switch (context.Operation.Syntax.ToString()) 4433switch (context.Operation.Syntax.ToString()) 4517Assert.Equal("= 0", context.OperationBlocks[0].Syntax.ToString()); 4520Assert.Equal("Attr1(100)", context.OperationBlocks[1].Syntax.ToString()); 4528Assert.Equal("= 1", context.OperationBlocks[0].Syntax.ToString()); 4531Assert.Equal("Attr2(200)", context.OperationBlocks[1].Syntax.ToString()); 4534Assert.Equal("A(2)", context.OperationBlocks[2].Syntax.ToString()); 4542Assert.Equal("= 4", context.OperationBlocks[0].Syntax.ToString()); 4545Assert.Equal("Attr3(300)", context.OperationBlocks[1].Syntax.ToString()); 4550Assert.Equal(": base(5)", context.OperationBlocks[3].Syntax.ToString()); 4651Assert.Equal("= 0", context.OperationBlocks[0].Syntax.ToString()); 4654Assert.Equal("Attr1(100)", context.OperationBlocks[1].Syntax.ToString()); 4664Assert.Equal("= 1", context.OperationBlocks[0].Syntax.ToString()); 4667Assert.Equal("Attr2(200)", context.OperationBlocks[1].Syntax.ToString()); 4670Assert.Equal("A(2)", context.OperationBlocks[2].Syntax.ToString()); 4680Assert.Equal("= 4", context.OperationBlocks[0].Syntax.ToString()); 4683Assert.Equal("Attr3(300)", context.OperationBlocks[1].Syntax.ToString()); 4688Assert.Equal(": base(5)", context.OperationBlocks[3].Syntax.ToString()); 4725Assert.Equal("= 0", context.OperationBlocks[0].Syntax.ToString()); 4728Assert.Equal("Attr1(100)", context.OperationBlocks[1].Syntax.ToString()); 4736Assert.Equal("= 1", context.OperationBlocks[0].Syntax.ToString()); 4739Assert.Equal("Attr2(200)", context.OperationBlocks[1].Syntax.ToString()); 4742Assert.Equal("A(2)", context.OperationBlocks[2].Syntax.ToString()); 4750Assert.Equal("= 4", context.OperationBlocks[0].Syntax.ToString()); 4753Assert.Equal("Attr3(300)", context.OperationBlocks[1].Syntax.ToString()); 4758Assert.Equal(": base(5)", context.OperationBlocks[3].Syntax.ToString()); 5697Assert.Equal(SyntaxKind.RecordDeclaration, context.Operation.Syntax.Kind()); 5714switch (context.Operation.Syntax.ToString()) 5732switch (context.Operation.Syntax.ToString()) 5792Assert.Equal("= 0", context.OperationBlocks[0].Syntax.ToString()); 5795Assert.Equal("Attr1(100)", context.OperationBlocks[1].Syntax.ToString());
Semantics\RecordTests.cs (32)
21335VerifyFlowGraph(comp, operation.Parent.Parent.Syntax, @" 26896Assert.Equal(SyntaxKind.RecordDeclaration, context.Operation.Syntax.Kind()); 26900Assert.Equal(SyntaxKind.RecordDeclaration, context.Operation.Syntax.Kind()); 26904Assert.Equal(SyntaxKind.ConstructorDeclaration, context.Operation.Syntax.Kind()); 26918Assert.Equal(SyntaxKind.PrimaryConstructorBaseType, context.Operation.Syntax.Kind()); 26933Assert.Equal(SyntaxKind.BaseConstructorInitializer, context.Operation.Syntax.Kind()); 26954switch (context.Operation.Syntax.ToString()) 27000switch (context.Operation.Syntax.ToString()) 27084Assert.Equal("= 0", context.OperationBlocks[0].Syntax.ToString()); 27087Assert.Equal("Attr1(100)", context.OperationBlocks[1].Syntax.ToString()); 27095Assert.Equal("= 1", context.OperationBlocks[0].Syntax.ToString()); 27098Assert.Equal("Attr2(200)", context.OperationBlocks[1].Syntax.ToString()); 27101Assert.Equal("A(2)", context.OperationBlocks[2].Syntax.ToString()); 27109Assert.Equal("= 4", context.OperationBlocks[0].Syntax.ToString()); 27112Assert.Equal("Attr3(300)", context.OperationBlocks[1].Syntax.ToString()); 27117Assert.Equal(": base(5)", context.OperationBlocks[3].Syntax.ToString()); 27218Assert.Equal("= 0", context.OperationBlocks[0].Syntax.ToString()); 27221Assert.Equal("Attr1(100)", context.OperationBlocks[1].Syntax.ToString()); 27231Assert.Equal("= 1", context.OperationBlocks[0].Syntax.ToString()); 27234Assert.Equal("Attr2(200)", context.OperationBlocks[1].Syntax.ToString()); 27237Assert.Equal("A(2)", context.OperationBlocks[2].Syntax.ToString()); 27247Assert.Equal("= 4", context.OperationBlocks[0].Syntax.ToString()); 27250Assert.Equal("Attr3(300)", context.OperationBlocks[1].Syntax.ToString()); 27255Assert.Equal(": base(5)", context.OperationBlocks[3].Syntax.ToString()); 27292Assert.Equal("= 0", context.OperationBlocks[0].Syntax.ToString()); 27295Assert.Equal("Attr1(100)", context.OperationBlocks[1].Syntax.ToString()); 27303Assert.Equal("= 1", context.OperationBlocks[0].Syntax.ToString()); 27306Assert.Equal("Attr2(200)", context.OperationBlocks[1].Syntax.ToString()); 27309Assert.Equal("A(2)", context.OperationBlocks[2].Syntax.ToString()); 27317Assert.Equal("= 4", context.OperationBlocks[0].Syntax.ToString()); 27320Assert.Equal("Attr3(300)", context.OperationBlocks[1].Syntax.ToString()); 27325Assert.Equal(": base(5)", context.OperationBlocks[3].Syntax.ToString());
Microsoft.CodeAnalysis.CSharp.Features (80)
ConvertIfToSwitch\CSharpConvertIfToSwitchCodeRefactoringProvider.Analyzer.cs (2)
19=> !operation.SemanticModel.AnalyzeControlFlow(operation.Syntax).EndPointIsReachable; 32=> !operation.SemanticModel.AnalyzeControlFlow(operation.Syntax).ExitPoints.Any(static n => n.IsKind(SyntaxKind.BreakStatement));
ConvertIfToSwitch\CSharpConvertIfToSwitchCodeRefactoringProvider.Rewriting.cs (3)
62IReturnOperation { ReturnedValue: { } value } => (ExpressionSyntax)value.Syntax, 63IThrowOperation { Exception: { } exception } => ThrowExpression((ExpressionSyntax)exception.Syntax), 109var node = operation.Syntax;
Copilot\CSharpImplementNotImplementedExceptionDiagnosticAnalyzer.cs (3)
58Syntax: var throwSyntax 65throwOperation.Syntax.GetLocation())); 106operation.Syntax.Parent is not ArrowExpressionClauseSyntax { Parent: PropertyDeclarationSyntax })
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.cs (4)
1101if (!ReturnOperationBelongsToMethod(returnOperation.Syntax, methodOperation.Syntax)) 1104var syntax = returnOperation.ReturnedValue?.Syntax ?? returnOperation.Syntax;
ImplementInterface\CSharpImplementExplicitlyCodeRefactoringProvider.cs (1)
137instance.Syntax, (current, g) =>
src\Analyzers\CSharp\Analyzers\ConvertTypeofToNameof\CSharpConvertTypeOfToNameOfDiagnosticAnalyzer.cs (1)
23var node = context.Operation.Syntax;
src\Analyzers\CSharp\Analyzers\MakeStructMemberReadOnly\CSharpMakeStructMemberReadOnlyAnalyzer.cs (4)
271CSharpSemanticFacts.Instance.IsWrittenTo(semanticModel, instanceOperation.Syntax, cancellationToken)) 293if (CSharpSemanticFacts.Instance.IsWrittenTo(semanticModel, fieldReference.Syntax, cancellationToken)) 304if (CSharpSemanticFacts.Instance.IsWrittenTo(semanticModel, propertyReference.Syntax, cancellationToken)) 335if (CSharpSemanticFacts.Instance.IsWrittenTo(semanticModel, operation.Syntax, cancellationToken))
src\Analyzers\CSharp\Analyzers\QualifyMemberAccess\CSharpQualifyMemberAccessDiagnosticAnalyzer.cs (1)
67protected override Location GetLocation(IOperation operation) => operation.Syntax.GetLocation();
src\Analyzers\CSharp\Analyzers\RemoveUnusedParametersAndValues\CSharpRemoveUnusedParametersAndValuesDiagnosticAnalyzer.cs (6)
69var statementAncestor = unusedSymbolWriteOperation.Syntax.FirstAncestorOrSelf<StatementSyntax>()?.Parent; 79!blockOperation.Syntax.IsKind(SyntaxKind.Block); 83switch (unusedDefinition.Syntax) 103if (unusedDefinition.Syntax.Parent is ForEachStatementSyntax forEachStatement && 104forEachStatement.Type == unusedDefinition.Syntax) 109return unusedDefinition.Syntax.GetLocation();
src\Analyzers\CSharp\Analyzers\SimplifyInterpolation\CSharpSimplifyInterpolationHelpers.cs (1)
21return operation.Syntax switch
src\Analyzers\CSharp\Analyzers\UseConditionalExpression\CSharpUseConditionalExpressionForReturnDiagnosticAnalyzer.cs (1)
39if (block.Syntax.Parent is UnsafeStatementSyntax or CheckedStatementSyntax)
src\Analyzers\CSharp\Analyzers\UseIndexOrRangeOperator\CSharpUseIndexOperatorDiagnosticAnalyzer.cs (2)
175if (subtraction.Syntax is not BinaryExpressionSyntax binaryExpression) 200if (CSharpSemanticFacts.Instance.IsInExpressionTree(semanticModel, instance.Syntax, infoCache.ExpressionOfTType, cancellationToken))
src\Analyzers\CSharp\Analyzers\UseIndexOrRangeOperator\CSharpUseRangeOperatorDiagnosticAnalyzer.cs (9)
85if (CSharpSemanticFacts.Instance.IsInExpressionTree(semanticModel, operation.Syntax, infoCache.ExpressionOfTType, context.CancellationToken)) 95if (invocation.Syntax is not InvocationExpressionSyntax invocationSyntax || 191if (!CSharpSyntaxFacts.Instance.AreEquivalent(lengthOperation.Syntax, subtraction.RightOperand.Syntax)) 207if (!CSharpSyntaxFacts.Instance.AreEquivalent(startOperation.Syntax, subtraction.RightOperand.Syntax)) 245if (CSharpSyntaxFacts.Instance.AreEquivalent(startOperation.Syntax, subtraction.RightOperand.Syntax)) 307return !invocation.Syntax.IsLeftSideOfAnyAssignExpression() || indexer == null || !IsWriteableIndexer(invocation, indexer);
src\Analyzers\CSharp\Analyzers\UseIndexOrRangeOperator\Helpers.cs (2)
48CSharpSyntaxFacts.Instance.AreEquivalent(instance.Syntax, propertyRef.Instance.Syntax);
src\Analyzers\CSharp\Analyzers\UseIsNullCheck\CSharpUseNullCheckOverTypeCheckDiagnosticAnalyzer.cs (3)
60context.Operation.Syntax is not UnaryPatternSyntax) 80Descriptor, context.Operation.Syntax.GetLocation(), notificationOption, context.Options, additionalLocations: null, properties: null)); 88var syntax = operation.Syntax;
src\Analyzers\CSharp\Analyzers\UsePatternCombinators\CSharpUsePatternCombinatorsAnalyzer.cs (9)
18return pattern?.Target.Syntax is ExpressionSyntax ? pattern : null; 49case IBinaryOperation { OperatorKind: ConditionalOr, Syntax: BinaryExpressionSyntax syntax } op: 52case IBinaryOperation { OperatorKind: ConditionalAnd, Syntax: BinaryExpressionSyntax syntax } op: 61case IIsTypeOperation { Syntax: BinaryExpressionSyntax binaryExpression } op: 64case IIsPatternOperation { Pattern.Syntax: PatternSyntax pattern } op: 101ConstantResult.Left when op.LeftOperand.Syntax is ExpressionSyntax left 106ConstantResult.Right when op.RightOperand.Syntax is ExpressionSyntax right 116ConstantResult.Left when op.LeftOperand.Syntax is ExpressionSyntax left 118ConstantResult.Right when op.RightOperand.Syntax is ExpressionSyntax right
src\Analyzers\CSharp\Analyzers\UsePrimaryConstructor\CSharpUsePrimaryConstructorDiagnosticAnalyzer.cs (2)
512operation is IParameterReferenceOperation { Syntax: IdentifierNameSyntax parameterName } parameterReference) 574var symbols = semanticModel.LookupSymbols(operation.Syntax.SpanStart, name: parameter.Name);
src\Analyzers\CSharp\Analyzers\UseSystemThreadingLock\CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs (1)
185if (lockOperation.Syntax.ContainsYield())
src\Analyzers\CSharp\Analyzers\UseUtf8StringLiteral\UseUtf8StringLiteralDiagnosticAnalyzer.cs (10)
82if (arrayCreationOperation.Syntax.Ancestors().OfType<AttributeSyntax>().Any()) 88if (arrayCreationOperation.Syntax.IsInExpressionTree(semanticModel, expressionType, context.CancellationToken)) 101if (arrayCreationOperation.Syntax is ImplicitArrayCreationExpressionSyntax or ArrayCreationExpressionSyntax) 103ReportArrayCreationDiagnostic(context, arrayCreationOperation.Syntax, option.Notification); 105else if (elements is [{ Syntax.Parent: ArgumentSyntax }, ..]) 108ReportParameterArrayDiagnostic(context, arrayCreationOperation.Syntax, elements, option.Notification, ArrayCreationOperationLocation.Descendants); 110else if (elements is [{ Syntax.Parent: (kind: SyntaxKind.CollectionInitializerExpression) }, ..]) 114ReportParameterArrayDiagnostic(context, arrayCreationOperation.Syntax, elements, option.Notification, ArrayCreationOperationLocation.Ancestors); 124var span = TextSpan.FromBounds(elements[0].Syntax.SpanStart, elements[^1].Syntax.Span.End);
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordHelpers.cs (3)
295? assignment.Syntax as ExpressionSyntax 305if (arg is { Parameter: IParameterSymbol param, Value.Syntax: ExpressionSyntax captured }) 385Value: IOperation { Syntax: ExpressionSyntax syntax }
src\Analyzers\CSharp\CodeFixes\MakeLocalFunctionStatic\MakeLocalFunctionStaticCodeFixHelper.cs (2)
156syntaxEditor.ReplaceNode(instanceReference.Syntax, IdentifierName("@this")); 158else if (instanceReference.Syntax is SimpleNameSyntax name)
src\Analyzers\CSharp\CodeFixes\UseConditionalExpression\CSharpUseConditionalExpressionForAssignmentCodeFixProvider.cs (1)
38=> (VariableDeclaratorSyntax)declarator.Syntax;
src\Analyzers\CSharp\CodeFixes\UseConditionalExpression\CSharpUseConditionalExpressionForReturnCodeFixProvider.cs (2)
46if (operation.Syntax is IfStatementSyntax { Condition: CheckedExpressionSyntax exp }) 54if (returnOperation.Syntax is ReturnStatementSyntax { Expression: CheckedExpressionSyntax exp })
src\Analyzers\CSharp\CodeFixes\UseConditionalExpression\CSharpUseConditionalExpressionHelpers.cs (2)
20var throwStatement = (ThrowStatementSyntax)throwOperation.Syntax; 29var ifStatement = (IfStatementSyntax)originalIfStatement.Syntax;
src\Analyzers\CSharp\CodeFixes\UseIndexOrRangeOperator\CSharpUseRangeOperatorCodeFixProvider.cs (2)
160return (startExpr: null, startFromEnd: false, (ExpressionSyntax)subtraction.RightOperand.Syntax, endFromEnd: true); 174return ((ExpressionSyntax)subtraction.RightOperand.Syntax, startFromEnd: true, endExpr: null, endFromEnd: false);
src\Analyzers\CSharp\CodeFixes\UsePatternCombinators\CSharpUsePatternCombinatorsCodeFixProvider.cs (2)
86editor.ReplaceNode(expression, IsPatternExpression((ExpressionSyntax)pattern.Target.Syntax, patternSyntax)); 141var governingType = semanticModel.GetTypeInfo(p.Target.Syntax).Type.RemoveNullableIfPresent();
src\Analyzers\CSharp\CodeFixes\UseUtf8StringLiteral\UseUtf8StringLiteralCodeFixProvider.cs (1)
120.Where(a => a.Initializer?.ElementValues.FirstOrDefault()?.Syntax.SpanStart == diagnostic.Location.SourceSpan.Start)
Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests (5)
IOperation\IOperationTests.cs (1)
690Assert.Same(expectedRootSyntax, operation.Syntax);
IOperation\IOperationTests_IBranchOperation.Extensions.cs (4)
363Assert.Equal(expected.Syntax, actual.Syntax); 370Assert.Equal(expected.Syntax, actual.Syntax);
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (20)
Semantics\RecordStructTests.cs (5)
6494Assert.Equal(SyntaxKind.RecordDeclaration, context.Operation.Syntax.Kind()); 6511switch (context.Operation.Syntax.ToString()) 6529switch (context.Operation.Syntax.ToString()) 6589Assert.Equal("= 0", context.OperationBlocks[0].Syntax.ToString()); 6592Assert.Equal("Attr1(100)", context.OperationBlocks[1].Syntax.ToString());
Semantics\TopLevelStatementsTests.cs (15)
6721Assert.Same(context.ContainingSymbol.DeclaringSyntaxReferences.Single().SyntaxTree, context.Operation.Syntax.SyntaxTree); 6723Assert.Equal(SyntaxKind.InvocationExpression, context.Operation.Syntax.Kind()); 6725switch (context.Operation.Syntax.ToString()) 6742Assert.Same(context.ContainingSymbol.DeclaringSyntaxReferences.Single().GetSyntax(), context.Operation.Syntax); 6743Assert.Equal(SyntaxKind.CompilationUnit, context.Operation.Syntax.Kind()); 6745switch (context.Operation.Syntax.ToString()) 6801Assert.Equal(SyntaxKind.CompilationUnit, context.OperationBlocks.Single().Syntax.Kind()); 6803switch (context.OperationBlocks.Single().Syntax.ToString()) 6859Assert.Equal(SyntaxKind.CompilationUnit, context.OperationBlocks.Single().Syntax.Kind()); 6861switch (context.OperationBlocks.Single().Syntax.ToString()) 7353Assert.Equal(SyntaxKind.CompilationUnit, context.OperationBlocks.Single().Syntax.Kind()); 7355switch (context.OperationBlocks.Single().Syntax.ToString()) 7420Assert.Same(context.ContainingSymbol.DeclaringSyntaxReferences.Single().GetSyntax(), context.Operation.Syntax); 7421Assert.Equal(SyntaxKind.CompilationUnit, context.Operation.Syntax.Kind()); 7423switch (context.Operation.Syntax.ToString())
Microsoft.CodeAnalysis.CSharp.Workspaces (6)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (3)
278conversionOperation.Syntax == castNode && 981if (IsExplicitCast(conversionOperation.Syntax)) 1501var argumentSyntax = argument?.Syntax as ArgumentSyntax;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseImplicitTypeHelper.cs (1)
239var argumentOp = invocationOp.Arguments.FirstOrDefault(a => a.Syntax == argument);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\InitializeParameter\InitializeParameterHelpers.cs (2)
158=> blockStatement?.Syntax is BlockSyntax block 160: blockStatement?.Syntax;
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (2)
CodeFixes\CodeFixServiceTests.cs (2)
1195=> variableDeclarations.Add(context.Operation.Syntax), OperationKind.VariableDeclaration); 1215context.ReportDiagnostic(Diagnostic.Create(Descriptor, context.Operation.Syntax.GetLocation())),
Microsoft.CodeAnalysis.Features (98)
ConvertIfToSwitch\AbstractConvertIfToSwitchCodeRefactoringProvider.Analyzer.cs (17)
81sections.Add(new AnalyzedSwitchSection(labels: default, defaultBodyOpt, defaultBodyOpt.Syntax)); 196return new AnalyzedSwitchSection(labels.ToImmutable(), operation.WhenTrue, operation.Syntax); 287ConstantResult.Left when op.LeftOperand.Syntax is TExpressionSyntax left 289ConstantResult.Right when op.RightOperand.Syntax is TExpressionSyntax right 322if (Supports(Feature.CaseGuard) && op.RightOperand.Syntax is TExpressionSyntax node) 332when Supports(Feature.IsTypePattern) && CheckTargetExpression(op.ValueOperand) && op.Syntax is TIsExpressionSyntax node: 336when Supports(Feature.SourcePattern) && CheckTargetExpression(op.Value) && op.Pattern.Syntax is TPatternSyntax pattern: 350ConstantResult.Left when op.LeftOperand.Syntax is TExpressionSyntax left 352ConstantResult.Right when op.RightOperand.Syntax is TExpressionSyntax right 385when CheckTargetExpression(low.Expression, high.Expression) => (low.Value.Syntax, high.Value.Syntax), 387when CheckTargetExpression(low.Expression, high.Expression) => (low.Value.Syntax, high.Value.Syntax), 392=> _syntaxFacts.AreEquivalent(left.Syntax, right.Syntax) && this.CheckTargetExpression(left); 453var expression = operation.Syntax; 473return CanImplicitlyConvert(operation.SemanticModel, operation.Syntax, _switchTargetType);
InitializeParameter\AbstractAddParameterCheckCodeRefactoringProvider.cs (5)
203var syntax = statement.Syntax; 210syntaxFacts.IsThrowExpression(coalesceExpression.WhenNull.Syntax)) 283if (!CanOffer(blockStatementOpt.Syntax)) 498return checkStatement.Syntax; 510return statementIndex > 0 && blockStatement.Operations[statementIndex - 1] is { IsImplicit: false, Syntax: var priorSyntax }
InitializeParameter\AbstractInitializeMemberFromParameterCodeRefactoringProviderMemberCreation.cs (2)
374nodesToTrack.Add(blockStatement.Syntax); 396currentBlockStatement = (IBlockOperation?)currentSemanticModel.GetOperation(currentRoot.GetCurrentNode(blockStatement.Syntax)!, cancellationToken);
InitializeParameter\AbstractInitializeParameterCodeRefactoringProvider.cs (1)
185foreach (var child in condition.Syntax.DescendantNodes().OfType<TExpressionSyntax>())
InlineMethod\AbstractInlineMethodRefactoringProvider.MethodParametersInfo.cs (3)
380.Where(argument => argument.Value.Syntax is TExpressionSyntax 381&& !_syntaxFacts.IsDeclarationExpression(argument.Value.Syntax)) 526return (TExpressionSyntax)syntaxGenerator.AddParentheses(argumentExpressionOperation.Syntax);
src\Analyzers\Core\Analyzers\ConvertTypeofToNameof\AbstractConvertTypeOfToNameOfDiagnosticAnalyzer.cs (1)
34var node = context.Operation.Syntax;
src\Analyzers\Core\Analyzers\PopulateSwitch\AbstractPopulateSwitchDiagnosticAnalyzer.cs (1)
51if (switchOperation.Syntax is not TSwitchSyntax switchBlock || IsSwitchTypeUnknown(switchOperation))
src\Analyzers\Core\Analyzers\QualifyMemberAccess\AbstractQualifyMemberAccessDiagnosticAnalyzer.cs (2)
95if (!CanMemberAccessBeQualified(context.ContainingSymbol, instanceOperation.Syntax)) 103if (instanceOperation.Syntax is not TSimpleNameSyntax simpleName)
src\Analyzers\Core\Analyzers\RemoveRedundantEquality\AbstractRemoveRedundantEqualityDiagnosticAnalyzer.cs (2)
34var syntax = context.Operation.Syntax; 56var syntax = context.Operation.Syntax;
src\Analyzers\Core\Analyzers\RemoveUnusedMembers\AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (3)
357var methods = _analyzer.SemanticFacts.GetDeconstructionAssignmentMethods(operation.SemanticModel!, operation.Syntax); 451var symbols = _analyzer.SemanticFacts.GetForEachSymbols(operation.SemanticModel!, loopOperation.Syntax); 489var symbolInfo = nameofArgument.SemanticModel!.GetSymbolInfo(nameofArgument.Syntax, operationContext.CancellationToken);
src\Analyzers\Core\Analyzers\RemoveUnusedParametersAndValues\AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.BlockAnalyzer.cs (7)
99if (!symbolStartAnalyzer._compilationAnalyzer.TryGetOptions(firstBlock.Syntax.SyntaxTree, 116firstBlock.Syntax.SyntaxTree != filterTree) 126var root = firstBlock.Syntax.SyntaxTree.GetRoot(context.CancellationToken); 127var spanStart = firstBlock.Syntax.SpanStart; 140if (operationBlock.Syntax.GetDiagnostics().ToImmutableArrayOrEmpty().HasAnyErrors()) 151if (operationBlock.Syntax.DescendantNodes(descendIntoTrivia: true) 216value.Syntax.GetLocation(),
src\Analyzers\Core\Analyzers\SimplifyInterpolation\AbstractSimplifyInterpolationDiagnosticAnalyzer.cs (1)
85additionalLocations: [interpolation.Syntax.GetLocation()],
src\Analyzers\Core\Analyzers\SimplifyInterpolation\AbstractSimplifyInterpolationHelpers.cs (7)
58.SelectAsArray(interpolation.Syntax.SyntaxTree.GetLocation); 95!syntaxFacts.IsBaseExpression(instance.Syntax) && 109unnecessarySpans.AddRange(invocation.Syntax.Span 111.Subtract(GetSpanWithinLiteralQuotes(virtualCharService, literal.Syntax.GetFirstToken()))); 124unnecessarySpans.AddRange(invocation.Syntax.Span 228var alignmentSyntax = alignmentOp.Syntax; 234unnecessarySpans.AddRange(invocation.Syntax.Span
src\Analyzers\Core\Analyzers\SimplifyLinqExpression\AbstractSimplifyLinqExpressionDiagnosticAnalyzer.cs (4)
123if (context.Operation.Syntax.GetDiagnostics().Any(diagnostic => diagnostic.Severity == DiagnosticSeverity.Error)) 173context.ReportDiagnostic(Diagnostic.Create(Descriptor, nextInvocation.Syntax.GetLocation())); 187if (invocation.Syntax is not TInvocationExpressionSyntax invocationNode || 199if (invocation.Syntax is not TInvocationExpressionSyntax invocationNode ||
src\Analyzers\Core\Analyzers\UseConditionalExpression\AbstractUseConditionalExpressionDiagnosticAnalyzer.cs (1)
41if (ifOperation.Syntax is not TIfStatementSyntax ifStatement)
src\Analyzers\Core\Analyzers\UseConditionalExpression\ForAssignment\UseConditionalExpressionForAssignmentHelpers.cs (6)
54!syntaxFacts.AreEquivalent(trueAssignment.Target.Syntax, falseAssignment.Target.Syntax)) 95if (ContainsReference(nullCheckedExpression.Syntax, trueAssignment?.Target.Syntax) || 96ContainsReference(nullCheckedExpression.Syntax, falseAssignment?.Target.Syntax))
src\Analyzers\Core\Analyzers\UseConditionalExpression\UseConditionalExpressionHelpers.cs (7)
41if (syntaxFacts.SpansPreprocessorDirective(ifOperation.Syntax, whenFalse.Syntax)) 47if (HasRegularComments(syntaxFacts, whenTrue.Syntax) || 48HasRegularComments(syntaxFacts, whenFalse.Syntax)) 58var whenTrueSymbols = semanticModel.GetAllDeclaredSymbols(whenTrue.Syntax, cancellationToken, n => !syntaxFacts.IsAnonymousOrLocalFunction(n)); 59var whenFalseSymbols = semanticModel.GetAllDeclaredSymbols(whenFalse.Syntax, cancellationToken, n => !syntaxFacts.IsAnonymousOrLocalFunction(n)); 106if (!syntaxFacts.SupportsThrowExpression(anyThrow.Syntax.SyntaxTree.Options))
src\Analyzers\Core\Analyzers\UseExplicitTupleName\UseExplicitTupleNameDiagnosticAnalyzer.cs (1)
57var memberAccessSyntax = fieldReferenceOperation.Syntax;
src\Analyzers\Core\Analyzers\UseSystemHashCode\UseSystemHashCodeDiagnosticAnalyzer.cs (2)
72var option = context.Options.GetAnalyzerOptions(operation.Syntax.SyntaxTree).PreferSystemHashCode; 77var operationLocation = operation.Syntax.GetLocation();
src\Analyzers\Core\Analyzers\UseThrowExpression\AbstractUseThrowExpressionDiagnosticAnalyzer.cs (9)
77var throwStatementSyntax = throwOperation.Syntax; 129ifOperation.Syntax.GetLocation(), 130throwOperation.Exception.Syntax.GetLocation(), 131assignmentExpression.Value.Syntax.GetLocation(), 132expressionStatement.Syntax.GetLocation()); 149statements[ifOperationIndex + 1].Syntax, 150statements[expressionStatementIndex - 1].Syntax); 161var exprDataFlow = semanticModel.AnalyzeDataFlow(assignmentExpression.Target.Syntax); 272var throwStatement = throwOperation.Syntax;
src\Analyzers\Core\CodeFixes\SimplifyInterpolation\AbstractSimplifyInterpolationCodeFixProvider.cs (1)
59if (interpolation?.Syntax is TInterpolationSyntax interpolationSyntax &&
src\Analyzers\Core\CodeFixes\UseConditionalExpression\AbstractUseConditionalExpressionCodeFixProvider.cs (4)
116trueValue.Syntax, falseValue.Syntax, formattingOptions, cancellationToken).ConfigureAwait(false); 133=> (TExpressionSyntax)operation.Condition.Syntax; 171var sourceSyntax = value.Syntax;
src\Analyzers\Core\CodeFixes\UseConditionalExpression\ForAssignment\AbstractUseConditionalExpressionForAssignmentCodeFixProvider.cs (7)
111var ifStatement = (TIfStatementSyntax)ifOperation.Syntax; 112var assignment = generator.AssignmentStatement(assignmentOperation.Target.Syntax, conditionalExpression); 117conditionalAccess.Operation.Syntax, 124ifOperation.Syntax, 142var localDeclaration = localDeclarationOperation.Syntax; 156editor.RemoveNode(ifOperation.Syntax, GetRemoveOptions(syntaxFacts, ifOperation.Syntax));
src\Analyzers\Core\CodeFixes\UseConditionalExpression\ForReturn\AbstractUseConditionalExpressionForReturnCodeFixProvider.cs (2)
92editor.RemoveNode(falseStatement.Syntax, GetRemoveOptions(syntaxFacts, falseStatement.Syntax));
ValueTracking\ValueTracker.OperationCollector.cs (2)
79var symbolInfo = semanticModel.GetSymbolInfo(operation.Syntax, cancellationToken); 176operation.Syntax.GetLocation(),
Microsoft.CodeAnalysis.PublicApiAnalyzers (2)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\DiagnosticExtensions.cs (2)
57return operation.Syntax.CreateDiagnostic(rule, properties, args); 67return operation.Syntax.CreateDiagnostic(rule, additionalLocations, properties, args);
Microsoft.CodeAnalysis.ResxSourceGenerator (11)
src\RoslynAnalyzers\Utilities\Compiler\DoNotCatchGeneralUnlessRethrown.cs (1)
83operationBlockAnalysisContext.ReportDiagnostic(CreateDiagnostic(method, catchClause.Syntax.GetFirstToken()));
src\RoslynAnalyzers\Utilities\Compiler\Extensions\DiagnosticExtensions.cs (2)
57return operation.Syntax.CreateDiagnostic(rule, properties, args); 67return operation.Syntax.CreateDiagnostic(rule, additionalLocations, properties, args);
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IOperationExtensions.cs (7)
35GetReceiverType(invocation.Instance.Syntax, compilation, cancellationToken) : 44GetReceiverType(firstArg.Value.Syntax, compilation, cancellationToken) : 312return operation.GetAncestor(OperationKind.ConditionalAccess, (IConditionalAccessOperation c) => c.Operation.Syntax == operation.Syntax); 340if (current.Syntax == operation.Syntax) 640=> invocationOperation.GetInstance()?.Syntax;
src\RoslynAnalyzers\Utilities\Compiler\Extensions\OperationBlockAnalysisContextExtension.cs (1)
47(body.Operations.Length == 3 && body.Syntax.Language == LanguageNames.VisualBasic &&
Microsoft.CodeAnalysis.Test.Utilities (154)
CommonTestBase.cs (2)
686VerifyOperationTreeSpine(semanticModel, set, child.Syntax); 690Assert.True(semanticModel.Root.FullSpan.Contains(child.Syntax.FullSpan));
Compilation\CompilationExtensions.cs (7)
300Assert.True(node == operation.Syntax, $"Expected : {node} - Actual : {operation.Syntax}"); 312roots.Add((operation, semanticModel.GetDeclaredSymbol(operation.Syntax))); 333explicitNodeMap.Add(operation.Syntax, operation); 337Assert.False(true, $"Duplicate explicit node for syntax ({operation.Syntax.RawKind}): {operation.Syntax.ToString()}"); 367if (blockOperation.Syntax.SyntaxTree.Options.Kind != SourceCodeKind.Script)
Compilation\ControlFlowGraphVerifier.cs (36)
78var declaredSymbol = model.GetDeclaredSymbol(operationRoot.Syntax); 349var model = compilation.GetSemanticModel(graph.OriginalOperation.Syntax.SyntaxTree); 350if (model.GetDiagnostics(graph.OriginalOperation.Syntax.Span). 525referencesAfter.All(r => isLongLivedCaptureReferenceSyntax(r.Syntax)), 545VisualBasicSyntaxNode syntax = applyParenthesizedIfAnyVB((VisualBasicSyntaxNode)candidate.Syntax); 572VisualBasicSyntaxNode syntax = applyParenthesizedIfAnyVB((VisualBasicSyntaxNode)candidate.Syntax); 597return reference.Syntax is CSharp.Syntax.SwitchExpressionSyntax switchExpr && switchExpr.Arms.Count == 0; 610CSharpSyntaxNode syntax = applyParenthesizedOrNullSuppressionIfAnyCS((CSharpSyntaxNode)candidate.Syntax); 626VisualBasicSyntaxNode syntax = applyParenthesizedIfAnyVB((VisualBasicSyntaxNode)candidate.Syntax); 653CSharpSyntaxNode syntax = applyParenthesizedOrNullSuppressionIfAnyCS((CSharpSyntaxNode)candidate.Syntax); 664VisualBasicSyntaxNode syntax = applyParenthesizedIfAnyVB((VisualBasicSyntaxNode)candidate.Syntax); 692VisualBasicSyntaxNode syntax = applyParenthesizedIfAnyVB((VisualBasicSyntaxNode)candidate.Syntax); 696if (query.Syntax is VisualBasic.Syntax.QueryExpressionSyntax querySyntax && 698aggregate.AggregateKeyword.SpanStart < candidate.Syntax.SpanStart && 699aggregate.IntoKeyword.SpanStart > candidate.Syntax.SpanStart && 829SyntaxNode captureReferenceSyntax = reference.Syntax; 867CSharpSyntaxNode referenceSyntax = applyParenthesizedOrNullSuppressionIfAnyCS((CSharpSyntaxNode)reference.Syntax); 880CSharpSyntaxNode referenceSyntax = applyParenthesizedOrNullSuppressionIfAnyCS((CSharpSyntaxNode)reference.Syntax); 911Syntax: CSharpSyntaxNode syntax 954if (binOp.Syntax is CSharp.Syntax.BinaryExpressionSyntax binOpSyntax && 956binOpSyntax.Left == applyParenthesizedOrNullSuppressionIfAnyCS((CSharpSyntaxNode)reference.Syntax) && 957binOpSyntax.Right == applyParenthesizedOrNullSuppressionIfAnyCS((CSharpSyntaxNode)binOp.RightOperand.Syntax)) 964var referenceSyntax = applyParenthesizedIfAnyVB((VisualBasicSyntaxNode)reference.Syntax); 965if (binOp.Syntax is VisualBasic.Syntax.BinaryExpressionSyntax binOpSyntax && 968binOpSyntax.Right == applyParenthesizedIfAnyVB((VisualBasicSyntaxNode)binOp.RightOperand.Syntax)) 972else if (binOp.Syntax is VisualBasic.Syntax.RangeCaseClauseSyntax range && 975range.UpperBound == applyParenthesizedIfAnyVB((VisualBasicSyntaxNode)binOp.RightOperand.Syntax)) 979else if (binOp.Syntax is VisualBasic.Syntax.CaseStatementSyntax caseStmt && 983caseStmt.Cases.Contains(applyParenthesizedIfAnyVB((VisualBasicSyntaxNode)binOp.RightOperand.Syntax) as CaseClauseSyntax)) 1000assignment.Syntax.Parent is VisualBasic.Syntax.ForStatementSyntax forStmt && 1001assignment.Syntax == forStmt.ControlVariable && 1002reference.Syntax == assignment.Syntax && 1003assignment.Value.Syntax == forStmt.StepClause.StepValue) 1013if (isLongLivedCaptureReferenceSyntax(reference.Syntax)) 1080if (whenNotNull.Contains(candidate.Syntax))
Compilation\OperationTreeVerifier.cs (6)
131Assert.NotNull(operation.Syntax); 132LogString($" (Syntax: {GetSnippetFromSyntax(operation.Syntax)})"); 313_explicitNodeMap.Add(operation.Syntax, operation); 317Assert.False(true, $"Duplicate explicit node for syntax ({operation.Syntax.RawKind}): {operation.Syntax.ToString()}"); 334Assert.True(operation.Syntax.Language == operation.Language);
Compilation\TestOperationVisitor.cs (18)
46var syntax = operation.Syntax; 200explicitNodeMap.Add(descendant.Syntax, descendant); 204Assert.False(true, $"Duplicate explicit node for syntax ({descendant.Syntax.RawKind}): {descendant.Syntax.ToString()}"); 558Assert.False(operation.Instance.IsImplicit, $"Implicit {nameof(IInstanceReferenceOperation)} on {operation.Syntax}"); 588Assert.True(operation.Descendants().All(n => n.IsImplicit), $"Explicit node in default argument value ({operation.Syntax.RawKind}): {operation.Syntax.ToString()}"); 668Assert.False(operation.Instance.IsImplicit, $"Implicit {nameof(IInstanceReferenceOperation)} on {operation.Syntax}"); 757CheckOperators(operation.SemanticModel, operation.Syntax); 792CheckOperators(operation.SemanticModel, operation.Syntax); 1176if (operation.Syntax.Language == LanguageNames.CSharp) 1415if (operation.Syntax.IsKind(CSharp.SyntaxKind.VarPattern) || 1417operation.Syntax.IsKind(CSharp.SyntaxKind.SingleVariableDesignation)) 1429(operation.Syntax as CSharp.Syntax.DeclarationPatternSyntax)?.Designation ?? 1430(operation.Syntax as CSharp.Syntax.VarPatternSyntax)?.Designation ?? 1431(operation.Syntax as CSharp.Syntax.VariableDesignationSyntax); 1463var designation = (operation.Syntax as CSharp.Syntax.ListPatternSyntax)?.Designation; 1500var designation = (operation.Syntax as CSharp.Syntax.RecursivePatternSyntax)?.Designation;
Diagnostics\BoxingOperationAnalyzer.cs (2)
53Report(operationContext, conversion.Syntax); 66Report(operationContext, invocation.Instance.Syntax);
Diagnostics\CommonDiagnosticAnalyzers.cs (15)
1258return _controlFlowGraphMapOpt.Values.OrderBy(flowGraphAndSymbol => flowGraphAndSymbol.Graph.OriginalOperation.Syntax.SpanStart).ToImmutableArray(); 1353ReportDiagnostic(operationContext.ReportDiagnostic, operationContext.Operation.Syntax.GetLocation()); 1365ReportDiagnostic(operationContext.ReportDiagnostic, operationContext.Operation.Syntax.GetLocation()); 1445var diagnostic = Diagnostic.Create(Descriptor, operation.Syntax.GetLocation(), operation.Field.Name, operation.Field.ConstantValue); 1466var diagnostic = Diagnostic.Create(Descriptor, operationContext.Operation.Syntax.GetLocation(), operationContext.ContainingSymbol.Name); 2074operationContext.ReportDiagnostic(Diagnostic.Create(OperationRule, Location.None, symbolStartContext.Symbol.Name, operationContext.ContainingSymbol.Name, operationContext.Operation.Syntax.ToString(), _analyzerId)); 2149diagnostics.Add(Diagnostic.Create(OperationOrderingRule, Location.None, symbolStartContext.Symbol, operationContext.Operation.Syntax.ToString(), _analyzerId)); 2758ReportDiagnostics($"RegisterOperationAction({operationContext.Operation.Syntax}) in RegisterSymbolStartAction", operationContext.Operation.Syntax.SyntaxTree, operationContext.ContainingSymbol, operationContext.ReportDiagnostic), 2772ReportDiagnostics($"RegisterOperationAction({operationContext.Operation.Syntax})", operationContext.Operation.Syntax.SyntaxTree, operationContext.ContainingSymbol, operationContext.ReportDiagnostic), 2785ReportDiagnostics($"RegisterOperationAction({operationContext.Operation.Syntax}) in RegisterOperationBlockStartAction", operationContext.Operation.Syntax.SyntaxTree, operationContext.ContainingSymbol, operationContext.ReportDiagnostic), 2888context => context.ReportDiagnostic(Diagnostic.Create(Descriptor, context.Operation.Syntax.GetLocation())), 2943context.RegisterOperationAction(context => HandleCallback(context.Operation.Syntax.GetLocation(), context.Compilation, context.ReportDiagnostic, context.CancellationToken), OperationKind.VariableDeclaration);
Diagnostics\CouldHaveMoreSpecificTypeAnalyzer.cs (1)
66SyntaxNode syntax = increment.Syntax;
Diagnostics\EmptyArrayAnalyzer.cs (1)
83Report(operationContext, arrayCreation.Syntax);
Diagnostics\OperationTestAnalyzer.cs (66)
59operationContext.ReportDiagnostic(Diagnostic.Create(InvalidStatementDescriptor, operationContext.Operation.Syntax.GetLocation())); 63operationContext.ReportDiagnostic(Diagnostic.Create(InvalidExpressionDescriptor, operationContext.Operation.Syntax.GetLocation())); 73operationContext.ReportDiagnostic(Diagnostic.Create(IsInvalidDescriptor, operationContext.Operation.Syntax.GetLocation())); 109operationContext.ReportDiagnostic(Diagnostic.Create(ExpressionDescriptor, operationContext.Operation.Syntax.GetLocation())); 213Report(operationContext, forLoop.Syntax, BigForDescriptor); 453Report(operationContext, switchOperation.Value.Syntax, SparseSwitchDescriptor); 457Report(operationContext, switchOperation.Value.Syntax, NoDefaultSwitchDescriptor); 461Report(operationContext, switchOperation.Value.Syntax, OnlyDefaultSwitchDescriptor); 549operationContext.ReportDiagnostic(Diagnostic.Create(InvalidArgumentDescriptor, argument.Syntax.GetLocation())); 555operationContext.ReportDiagnostic(Diagnostic.Create(UseDefaultArgumentDescriptor, invocation.Syntax.GetLocation(), argument.Parameter.Name)); 569Report(operationContext, invocation.Syntax, BigParamArrayArgumentsDescriptor); 592Report(operationContext, argument.Syntax, OutOfNumericalOrderArgumentsDescriptor); 635operationContext.ReportDiagnostic(Diagnostic.Create(SeventeenDescriptor, literal.Syntax.GetLocation())); 670Report(operationContext, argument.Syntax, NullArgumentsDescriptor); 716Report(operationContext, initializer.Syntax, initializer.Kind == OperationKind.FieldReference ? DoNotUseFieldInitializerDescriptor : DoNotUsePropertyInitializerDescriptor); 757Report(operationContext, assignment.Syntax, DoNotUseMemberAssignmentDescriptor); 797Report(operationContext, initializer.Syntax, DoNotUseLargeListOfArrayInitializersDescriptor); 845Report(operationContext, declarationStatement.Syntax, TooManyLocalVarDeclarationsDescriptor); 905Report(operationContext, caseClause.Syntax, HasDefaultCaseDescriptor); 912Report(operationContext, switchSection.Syntax, MultipleCaseClausesDescriptor); 955instanceReference.Syntax.GetLocation())); 1034operationContext.ReportDiagnostic(Diagnostic.Create(EventReferenceDescriptor, operationContext.Operation.Syntax.GetLocation())); 1042operationContext.ReportDiagnostic(Diagnostic.Create(eventAssignment.Adds ? HandlerAddedDescriptor : HandlerRemovedDescriptor, operationContext.Operation.Syntax.GetLocation())); 1046operationContext.ReportDiagnostic(Diagnostic.Create(InvalidEventDescriptor, eventAssignment.Syntax.GetLocation())); 1054operationContext.ReportDiagnostic(Diagnostic.Create(PropertyReferenceDescriptor, operationContext.Operation.Syntax.GetLocation())); 1061operationContext.ReportDiagnostic(Diagnostic.Create(FieldReferenceDescriptor, operationContext.Operation.Syntax.GetLocation())); 1068operationContext.ReportDiagnostic(Diagnostic.Create(MethodBindingDescriptor, operationContext.Operation.Syntax.GetLocation())); 1111operationContext.ReportDiagnostic(Diagnostic.Create(LongParamsDescriptor, argument.Value.Syntax.GetLocation())); 1126operationContext.ReportDiagnostic(Diagnostic.Create(InvalidConstructorDescriptor, creation.Syntax.GetLocation())); 1138operationContext.ReportDiagnostic(Diagnostic.Create(LongParamsDescriptor, argument.Value.Syntax.GetLocation())); 1184operationContext.ReportDiagnostic(Diagnostic.Create(EqualsValueDescriptor, equalsValue.Syntax.GetLocation())); 1195operationContext.ReportDiagnostic(Diagnostic.Create(EqualsValueDescriptor, equalsValue.Syntax.GetLocation())); 1226operationContext.ReportDiagnostic(Diagnostic.Create(NoneOperationDescriptor, operationContext.Operation.Syntax.GetLocation())); 1262operationContext.ReportDiagnostic(Diagnostic.Create(AddressOfDescriptor, addressOfOperation.Syntax.GetLocation())); 1266operationContext.ReportDiagnostic(Diagnostic.Create(InvalidAddressOfReferenceDescriptor, addressOfOperation.Reference.Syntax.GetLocation())); 1314operationContext.ReportDiagnostic(Diagnostic.Create(LambdaExpressionDescriptor, operationContext.Operation.Syntax.GetLocation())); 1323operationContext.ReportDiagnostic(Diagnostic.Create(TooManyStatementsInLambdaExpressionDescriptor, operationContext.Operation.Syntax.GetLocation())); 1336operationContext.ReportDiagnostic(Diagnostic.Create(NoneOperationInLambdaExpressionDescriptor, operationContext.Operation.Syntax.GetLocation())); 1408operationContext.ReportDiagnostic(Diagnostic.Create(StaticMemberDescriptor, operation.Syntax.GetLocation())); 1412operationContext.ReportDiagnostic(Diagnostic.Create(StaticMemberWithInstanceDescriptor, operation.Syntax.GetLocation())); 1452operationContext.ReportDiagnostic(Diagnostic.Create(LabelDescriptor, operationContext.Operation.Syntax.GetLocation())); 1466operationContext.ReportDiagnostic(Diagnostic.Create(GotoDescriptor, branch.Syntax.GetLocation())); 1518operationContext.ReportDiagnostic(Diagnostic.Create(OperatorAddMethodDescriptor, binary.Syntax.GetLocation())); 1523operationContext.ReportDiagnostic(Diagnostic.Create(DoubleMultiplyDescriptor, binary.Syntax.GetLocation())); 1534operationContext.ReportDiagnostic(Diagnostic.Create(OperatorMinusMethodDescriptor, unary.Syntax.GetLocation())); 1539operationContext.ReportDiagnostic(Diagnostic.Create(BooleanNotDescriptor, unary.Syntax.GetLocation())); 1544operationContext.ReportDiagnostic(Diagnostic.Create(BooleanNotDescriptor, unary.Syntax.GetLocation())); 1574binary.Syntax.GetLocation(), 1627binary.Syntax.GetLocation(), 1651unary.Syntax.GetLocation(), 1707paramsarrayArgumentOperation.Syntax.GetLocation())); 1731if (operation.Syntax == null) 1791operationContext.ReportDiagnostic(Diagnostic.Create(InvalidBinaryDescriptor, binary.Syntax.GetLocation())); 1799operationContext.ReportDiagnostic(Diagnostic.Create(InvalidUnaryDescriptor, unary.Syntax.GetLocation())); 1807operationContext.ReportDiagnostic(Diagnostic.Create(InvalidIncrementDescriptor, inc.Syntax.GetLocation())); 1848operationContext.ReportDiagnostic(Diagnostic.Create(ConditionalAccessOperationDescriptor, conditionalAccess.Syntax.GetLocation())); 1857operationContext.ReportDiagnostic(Diagnostic.Create(ConditionalAccessInstanceOperationDescriptor, conditionalAccessInstance.Syntax.GetLocation())); 1897operationContext.ReportDiagnostic(Diagnostic.Create(InvalidConversionExpressionDescriptor, conversion.Syntax.GetLocation())); 1935operationContext.ReportDiagnostic(Diagnostic.Create(ForLoopConditionCrashDescriptor, forLoop.LimitValue.Syntax.GetLocation())); 1974operationContext.ReportDiagnostic(Diagnostic.Create(UnaryTrueDescriptor, unary.Syntax.GetLocation())); 1978operationContext.ReportDiagnostic(Diagnostic.Create(UnaryFalseDescriptor, unary.Syntax.GetLocation())); 2015operationContext.ReportDiagnostic(Diagnostic.Create(AssignmentOperationDescriptor, operationContext.Operation.Syntax.GetLocation())); 2052operationContext.ReportDiagnostic(Diagnostic.Create(LiteralDescriptor, literal.Syntax.GetLocation(), literal.Syntax.ToString())); 2080Diagnostic.Create(OperationActionDescriptor, operationContext.Operation.Syntax.GetLocation(), "Operation", "Analysis")); 2111Diagnostic.Create(OperationActionDescriptor, operationContext.Operation.Syntax.GetLocation(), "Operation", "CompilationStart within Analysis"));
Microsoft.CodeAnalysis.VisualBasic (3)
Operations\VisualBasicOperationFactory_Methods.vb (3)
260syntax = value.Syntax 336value.Syntax, 348Dim syntax As SyntaxNode = If(value.Syntax?.Parent, expression.Syntax)
Microsoft.CodeAnalysis.VisualBasic.Analyzers (1)
MetaAnalyzers\Fixers\BasicCompareSymbolsCorrectlyFix.vb (1)
27Dim invocation = DirectCast(invocationOperation.Syntax, InvocationExpressionSyntax)
Microsoft.CodeAnalysis.VisualBasic.CodeStyle (6)
src\Analyzers\VisualBasic\Analyzers\ConvertTypeofToNameof\VisualBasicConvertTypeOfToNameOfDiagnosticAnalyzer.vb (1)
22Dim node = context.Operation.Syntax
src\Analyzers\VisualBasic\Analyzers\QualifyMemberAccess\VisualBasicQualifyMemberAccessDiagnosticAnalyzer.vb (2)
41Dim unaryExpressionSyntax As UnaryExpressionSyntax = TryCast(operation.Syntax, UnaryExpressionSyntax) 46Return operation.Syntax.GetLocation()
src\Analyzers\VisualBasic\Analyzers\RemoveUnusedParametersAndValues\VisualBasicRemoveUnusedParametersAndValuesDiagnosticAnalyzer.vb (2)
50Return TryCast(expressionStatement.Syntax, CallStatementSyntax) IsNot Nothing 75Return unusedDefinition.Syntax.GetLocation()
src\Analyzers\VisualBasic\Analyzers\SimplifyInterpolation\VisualBasicSimplifyInterpolationHelpers.vb (1)
20Return operation.Syntax
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes (2)
src\Analyzers\VisualBasic\CodeFixes\UseConditionalExpression\VisualBasicUseConditionalExpressionForAssignmentCodeFixProvider.vb (1)
47Return DirectCast(declarator.Syntax.Parent, VariableDeclaratorSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\LanguageServices\InitializeParameter\InitializeParameterHelpers.vb (1)
45Return GetStatements(blockStatementOpt.Syntax).LastOrDefault()
Microsoft.CodeAnalysis.VisualBasic.Features (10)
ConvertIfToSwitch\VisualBasicConvertIfToSwitchCodeRefactoringProvider.Analyzer.vb (2)
19Dim statements = operation.Syntax.GetStatements() 24Select Case operation.Syntax.Kind
ConvertIfToSwitch\VisualBasicConvertIfToSwitchCodeRefactoringProvider.Rewriting.vb (1)
31Dim node = operation.Syntax
src\Analyzers\VisualBasic\Analyzers\ConvertTypeofToNameof\VisualBasicConvertTypeOfToNameOfDiagnosticAnalyzer.vb (1)
22Dim node = context.Operation.Syntax
src\Analyzers\VisualBasic\Analyzers\QualifyMemberAccess\VisualBasicQualifyMemberAccessDiagnosticAnalyzer.vb (2)
41Dim unaryExpressionSyntax As UnaryExpressionSyntax = TryCast(operation.Syntax, UnaryExpressionSyntax) 46Return operation.Syntax.GetLocation()
src\Analyzers\VisualBasic\Analyzers\RemoveUnusedParametersAndValues\VisualBasicRemoveUnusedParametersAndValuesDiagnosticAnalyzer.vb (2)
50Return TryCast(expressionStatement.Syntax, CallStatementSyntax) IsNot Nothing 75Return unusedDefinition.Syntax.GetLocation()
src\Analyzers\VisualBasic\Analyzers\SimplifyInterpolation\VisualBasicSimplifyInterpolationHelpers.vb (1)
20Return operation.Syntax
src\Analyzers\VisualBasic\CodeFixes\UseConditionalExpression\VisualBasicUseConditionalExpressionForAssignmentCodeFixProvider.vb (1)
47Return DirectCast(declarator.Syntax.Parent, VariableDeclaratorSyntax)
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (5)
Diagnostics\GetDiagnosticsTests.vb (5)
641AnalyzeNode(context.Operation.Syntax, context.ContainingSymbol, AddressOf context.ReportDiagnostic) 646context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(DescriptorForBlockEnd, operationBlock.Syntax.GetLocation())) 648If TryCast(operationBlock.Syntax, PropertyBlockSyntax) IsNot Nothing OrElse 649TryCast(operationBlock.Syntax, EventBlockSyntax) IsNot Nothing Then 650Throw New Exception($"Unexpected topmost node for operation block '{operationBlock.Syntax.Kind()}'")
Microsoft.CodeAnalysis.VisualBasic.Workspaces (1)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\LanguageServices\InitializeParameter\InitializeParameterHelpers.vb (1)
45Return GetStatements(blockStatementOpt.Syntax).LastOrDefault()
Microsoft.CodeAnalysis.Workspaces (14)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\AnalysisContextExtensions.cs (3)
186=> operationBlock.Syntax.FindNode(context.FilterSpan, findInTrivia, getInnermostNodeForTie); 192=> operationBlock.Syntax.FindNode(context.FilterSpan, findInTrivia, getInnermostNodeForTie); 198=> context.Operation.Syntax.FindNode(context.FilterSpan, findInTrivia, getInnermostNodeForTie);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\SymbolUsageAnalysis.DataFlowAnalyzer.FlowGraphAnalysisData.cs (1)
193var dataFlow = operation.SemanticModel.AnalyzeDataFlow(operation.Syntax);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\InitializeParameter\AbstractInitializerParameterService.cs (2)
176return statement.Syntax; 181return statementIndex > 0 && blockStatement.Operations[statementIndex - 1] is { IsImplicit: false, Syntax: var priorSyntax }
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\NullableHelpers.cs (8)
43semanticFacts, semanticModel, rootOperation, declaredSymbol, rootOperation.Syntax.Span, includeDeclaration: true, cancellationToken) == true; 67if (!span.IntersectsWith(operation.Syntax.Span)) 70if (span.Contains(operation.Syntax.Span) && 76assignmentOperation.Syntax.RawKind == semanticFacts.SyntaxFacts.SyntaxKinds.SimpleAssignmentExpression) 83var typeInfo = semanticModel.GetTypeInfo(assignmentOperation.Value.Syntax, cancellationToken); 99var foreachInfo = semanticFacts.GetForEachSymbols(semanticModel, forEachLoop.Syntax); 111var syntax = variableDeclarator.GetVariableInitializer()!.Value.Syntax; 120var typeInfo = semanticModel.GetTypeInfo(operation.Syntax, cancellationToken);
Microsoft.Interop.ComInterfaceGenerator (9)
Analyzers\RuntimeComApiUsageWithSourceGeneratedComAnalyzer.cs (9)
123operation.TargetMethod.ToMinimalDisplayString(operation.SemanticModel, operation.Syntax.SpanStart), 124targetType.ToMinimalDisplayString(operation.SemanticModel, operation.Syntax.SpanStart))); 163operation.Syntax.GetLocation())); 183operation.Syntax.GetLocation())); 193operation.Syntax.GetLocation())); 202IConversionOperation conversion => (conversion.Operand.Type, conversion.Operand.Syntax.GetLocation()), 203IOperation op => (op.Type, op.Syntax.GetLocation()) 210var invocationSyntax = (InvocationExpressionSyntax)invocation.Syntax; 237ITypeOfOperation typeOf => (typeOf.TypeOperand, ((TypeOfExpressionSyntax)typeOf.Syntax).Type.GetLocation()),
Microsoft.Interop.LibraryImportGenerator (7)
Analyzers\CustomMarshallerAttributeAnalyzer.cs (5)
652DiagnosticReporter managedTypeReporter = DiagnosticReporter.CreateForLocation(managedTypeArgument.Value.Syntax.GetLocation(), context.ReportDiagnostic); 657DiagnosticReporter managedTypeReporter = DiagnosticReporter.CreateForLocation(((TypeOfExpressionSyntax)managedTypeOfOp.Syntax).Type.GetLocation(), context.ReportDiagnostic); 673DiagnosticReporter marshallerTypeReporter = DiagnosticReporter.CreateForLocation(marshallerTypeArgument.Value.Syntax.GetLocation(), context.ReportDiagnostic); 678DiagnosticReporter marshallerTypeReporter = DiagnosticReporter.CreateForLocation(((TypeOfExpressionSyntax)marshallerTypeOfOp.Syntax).Type.GetLocation(), context.ReportDiagnostic); 692DiagnosticReporter marshalModeReporter = DiagnosticReporter.CreateForLocation(marshalModeArgument.Syntax.GetLocation(), context.ReportDiagnostic);
Analyzers\NativeMarshallingAttributeAnalyzer.cs (2)
93DiagnosticReporter diagnosticFactory = DiagnosticReporter.CreateForLocation(marshallerEntryPointTypeArgument.Value.Syntax.GetLocation(), context.ReportDiagnostic); 102DiagnosticReporter.CreateForLocation(((TypeOfExpressionSyntax)typeOfOp.Syntax).Type.GetLocation(), context.ReportDiagnostic),
Roslyn.Compilers.VisualBasic.IOperation.UnitTests (2)
IOperation\IOperationTests_IUsingStatement.vb (2)
45Assert.NotNull(op.Resources.Syntax) 46Assert.Same(node.UsingStatement, op.Resources.Syntax)
Roslyn.Diagnostics.Analyzers (17)
AbstractDoNotCopyValue.cs (2)
1570_context.ReportDiagnostic(operation.Syntax.CreateDiagnostic(AvoidNullableWrapperRule, type, operation.Kind)); 1644var node = operation.Syntax;
DoNotCallGetTestAccessor.cs (4)
57context.ReportDiagnostic(memberReference.Syntax.CreateDiagnostic(DoNotCallGetTestAccessorRule)); 67context.ReportDiagnostic(invocation.Syntax.CreateDiagnostic(DoNotCallGetTestAccessorRule)); 72context.ReportDiagnostic(invocation.Syntax.CreateDiagnostic(DoNotCallGetTestAccessorRule)); 82context.ReportDiagnostic(objectCreation.Syntax.CreateDiagnostic(DoNotCallGetTestAccessorRule));
src\RoslynAnalyzers\Utilities\Compiler\DoNotCatchGeneralUnlessRethrown.cs (1)
83operationBlockAnalysisContext.ReportDiagnostic(CreateDiagnostic(method, catchClause.Syntax.GetFirstToken()));
src\RoslynAnalyzers\Utilities\Compiler\Extensions\DiagnosticExtensions.cs (2)
57return operation.Syntax.CreateDiagnostic(rule, properties, args); 67return operation.Syntax.CreateDiagnostic(rule, additionalLocations, properties, args);
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IOperationExtensions.cs (7)
35GetReceiverType(invocation.Instance.Syntax, compilation, cancellationToken) : 44GetReceiverType(firstArg.Value.Syntax, compilation, cancellationToken) : 312return operation.GetAncestor(OperationKind.ConditionalAccess, (IConditionalAccessOperation c) => c.Operation.Syntax == operation.Syntax); 340if (current.Syntax == operation.Syntax) 640=> invocationOperation.GetInstance()?.Syntax;
src\RoslynAnalyzers\Utilities\Compiler\Extensions\OperationBlockAnalysisContextExtension.cs (1)
47(body.Operations.Length == 3 && body.Syntax.Language == LanguageNames.VisualBasic &&
Roslyn.Diagnostics.CSharp.Analyzers (2)
CSharpDoNotCapturePrimaryContructorParameters.cs (1)
60context.ReportDiagnostic(Diagnostic.Create(Rule, operation.Syntax.GetLocation(), operation.Parameter.Name));
CSharpDoNotCopyValue.cs (1)
35if (operation.Syntax is CommonForEachStatementSyntax syntax
System.Private.CoreLib.Generators (5)
IntrinsicsInSystemPrivateCoreLibAnalyzer.cs (5)
546context.ReportDiagnostic(Diagnostic.Create(RuleAttributeNotSpecificEnough, operation.Syntax.GetLocation(), attributeExplicitlyAllowsRelatedSymbol.ToDisplayString())); 566var ancestorNodes = operation.Syntax.AncestorsAndSelf(true); 613context.ReportDiagnostic(Diagnostic.Create(RuleCantParse, operation.Syntax.GetLocation())); 686context.ReportDiagnostic(Diagnostic.Create(Rule, operation.Syntax.GetLocation(), symbol.ContainingSymbol.ToDisplayString())); 688context.ReportDiagnostic(Diagnostic.Create(RuleHelper, operation.Syntax.GetLocation(), symbol.ToDisplayString()));
System.Text.RegularExpressions.Generator (5)
UpgradeToGeneratedRegexAnalyzer.cs (2)
111SyntaxNode? syntaxNodeForDiagnostic = invocationOperation.Syntax; 143SyntaxNode? syntaxNodeForDiagnostic = operation.Syntax;
UpgradeToGeneratedRegexCodeFixer.cs (3)
167.Select(arg => arg.Syntax); 292return literalOperation.Syntax; 297return generator.Argument(fieldReferenceOperation.Syntax);
Test.Utilities (11)
src\RoslynAnalyzers\Utilities\Compiler\DoNotCatchGeneralUnlessRethrown.cs (1)
83operationBlockAnalysisContext.ReportDiagnostic(CreateDiagnostic(method, catchClause.Syntax.GetFirstToken()));
src\RoslynAnalyzers\Utilities\Compiler\Extensions\DiagnosticExtensions.cs (2)
57return operation.Syntax.CreateDiagnostic(rule, properties, args); 67return operation.Syntax.CreateDiagnostic(rule, additionalLocations, properties, args);
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IOperationExtensions.cs (7)
35GetReceiverType(invocation.Instance.Syntax, compilation, cancellationToken) : 44GetReceiverType(firstArg.Value.Syntax, compilation, cancellationToken) : 312return operation.GetAncestor(OperationKind.ConditionalAccess, (IConditionalAccessOperation c) => c.Operation.Syntax == operation.Syntax); 340if (current.Syntax == operation.Syntax) 640=> invocationOperation.GetInstance()?.Syntax;
src\RoslynAnalyzers\Utilities\Compiler\Extensions\OperationBlockAnalysisContextExtension.cs (1)
47(body.Operations.Length == 3 && body.Syntax.Language == LanguageNames.VisualBasic &&
Text.Analyzers (11)
src\RoslynAnalyzers\Utilities\Compiler\DoNotCatchGeneralUnlessRethrown.cs (1)
83operationBlockAnalysisContext.ReportDiagnostic(CreateDiagnostic(method, catchClause.Syntax.GetFirstToken()));
src\RoslynAnalyzers\Utilities\Compiler\Extensions\DiagnosticExtensions.cs (2)
57return operation.Syntax.CreateDiagnostic(rule, properties, args); 67return operation.Syntax.CreateDiagnostic(rule, additionalLocations, properties, args);
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IOperationExtensions.cs (7)
35GetReceiverType(invocation.Instance.Syntax, compilation, cancellationToken) : 44GetReceiverType(firstArg.Value.Syntax, compilation, cancellationToken) : 312return operation.GetAncestor(OperationKind.ConditionalAccess, (IConditionalAccessOperation c) => c.Operation.Syntax == operation.Syntax); 340if (current.Syntax == operation.Syntax) 640=> invocationOperation.GetInstance()?.Syntax;
src\RoslynAnalyzers\Utilities\Compiler\Extensions\OperationBlockAnalysisContextExtension.cs (1)
47(body.Operations.Length == 3 && body.Syntax.Language == LanguageNames.VisualBasic &&