2 implementations of Syntax
Microsoft.CodeAnalysis (1)
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (1)
1001 references to Syntax
Aspire.Hosting.Analyzers (1)
ConfigurationSchemaGenerator (2)
ILLink.RoslynAnalyzer (18)
Microsoft.Analyzers.Extra (21)
Microsoft.Analyzers.Local (5)
Microsoft.AspNetCore.Analyzers (4)
Microsoft.AspNetCore.App.Analyzers (21)
Microsoft.AspNetCore.Components.Analyzers (3)
Microsoft.AspNetCore.Components.SdkAnalyzers (3)
Microsoft.AspNetCore.Http.RequestDelegateGenerator (13)
Microsoft.AspNetCore.Mvc.Analyzers (5)
Microsoft.AspNetCore.Mvc.Api.Analyzers (6)
Microsoft.CodeAnalysis (253)
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);
Microsoft.CodeAnalysis.CodeStyle (52)
Microsoft.CodeAnalysis.CodeStyle.Fixes (19)
Microsoft.CodeAnalysis.CSharp (6)
Microsoft.CodeAnalysis.CSharp.CodeStyle (56)
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);
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (12)
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (78)
Semantics\PrimaryConstructorTests.cs (37)
1157VerifyFlowGraph(comp, operation.Parent.Parent.Syntax, @"
4328Assert.Equal(SyntaxKind.ClassDeclaration, context.Operation.Syntax.Kind());
4332Assert.Equal(SyntaxKind.ClassDeclaration, context.Operation.Syntax.Kind());
4336Assert.Equal(SyntaxKind.ConstructorDeclaration, context.Operation.Syntax.Kind());
4350Assert.Equal(SyntaxKind.PrimaryConstructorBaseType, context.Operation.Syntax.Kind());
4365Assert.Equal(SyntaxKind.BaseConstructorInitializer, context.Operation.Syntax.Kind());
4386switch (context.Operation.Syntax.ToString())
4432switch (context.Operation.Syntax.ToString())
4516Assert.Equal("= 0", context.OperationBlocks[0].Syntax.ToString());
4519Assert.Equal("Attr1(100)", context.OperationBlocks[1].Syntax.ToString());
4527Assert.Equal("= 1", context.OperationBlocks[0].Syntax.ToString());
4530Assert.Equal("Attr2(200)", context.OperationBlocks[1].Syntax.ToString());
4533Assert.Equal("A(2)", context.OperationBlocks[2].Syntax.ToString());
4541Assert.Equal("= 4", context.OperationBlocks[0].Syntax.ToString());
4544Assert.Equal("Attr3(300)", context.OperationBlocks[1].Syntax.ToString());
4549Assert.Equal(": base(5)", context.OperationBlocks[3].Syntax.ToString());
4650Assert.Equal("= 0", context.OperationBlocks[0].Syntax.ToString());
4653Assert.Equal("Attr1(100)", context.OperationBlocks[1].Syntax.ToString());
4663Assert.Equal("= 1", context.OperationBlocks[0].Syntax.ToString());
4666Assert.Equal("Attr2(200)", context.OperationBlocks[1].Syntax.ToString());
4669Assert.Equal("A(2)", context.OperationBlocks[2].Syntax.ToString());
4679Assert.Equal("= 4", context.OperationBlocks[0].Syntax.ToString());
4682Assert.Equal("Attr3(300)", context.OperationBlocks[1].Syntax.ToString());
4687Assert.Equal(": base(5)", context.OperationBlocks[3].Syntax.ToString());
4724Assert.Equal("= 0", context.OperationBlocks[0].Syntax.ToString());
4727Assert.Equal("Attr1(100)", context.OperationBlocks[1].Syntax.ToString());
4735Assert.Equal("= 1", context.OperationBlocks[0].Syntax.ToString());
4738Assert.Equal("Attr2(200)", context.OperationBlocks[1].Syntax.ToString());
4741Assert.Equal("A(2)", context.OperationBlocks[2].Syntax.ToString());
4749Assert.Equal("= 4", context.OperationBlocks[0].Syntax.ToString());
4752Assert.Equal("Attr3(300)", context.OperationBlocks[1].Syntax.ToString());
4757Assert.Equal(": base(5)", context.OperationBlocks[3].Syntax.ToString());
5696Assert.Equal(SyntaxKind.RecordDeclaration, context.Operation.Syntax.Kind());
5713switch (context.Operation.Syntax.ToString())
5731switch (context.Operation.Syntax.ToString())
5791Assert.Equal("= 0", context.OperationBlocks[0].Syntax.ToString());
5794Assert.Equal("Attr1(100)", context.OperationBlocks[1].Syntax.ToString());
Semantics\RecordTests.cs (32)
21275VerifyFlowGraph(comp, operation.Parent.Parent.Syntax, @"
26836Assert.Equal(SyntaxKind.RecordDeclaration, context.Operation.Syntax.Kind());
26840Assert.Equal(SyntaxKind.RecordDeclaration, context.Operation.Syntax.Kind());
26844Assert.Equal(SyntaxKind.ConstructorDeclaration, context.Operation.Syntax.Kind());
26858Assert.Equal(SyntaxKind.PrimaryConstructorBaseType, context.Operation.Syntax.Kind());
26873Assert.Equal(SyntaxKind.BaseConstructorInitializer, context.Operation.Syntax.Kind());
26894switch (context.Operation.Syntax.ToString())
26940switch (context.Operation.Syntax.ToString())
27024Assert.Equal("= 0", context.OperationBlocks[0].Syntax.ToString());
27027Assert.Equal("Attr1(100)", context.OperationBlocks[1].Syntax.ToString());
27035Assert.Equal("= 1", context.OperationBlocks[0].Syntax.ToString());
27038Assert.Equal("Attr2(200)", context.OperationBlocks[1].Syntax.ToString());
27041Assert.Equal("A(2)", context.OperationBlocks[2].Syntax.ToString());
27049Assert.Equal("= 4", context.OperationBlocks[0].Syntax.ToString());
27052Assert.Equal("Attr3(300)", context.OperationBlocks[1].Syntax.ToString());
27057Assert.Equal(": base(5)", context.OperationBlocks[3].Syntax.ToString());
27158Assert.Equal("= 0", context.OperationBlocks[0].Syntax.ToString());
27161Assert.Equal("Attr1(100)", context.OperationBlocks[1].Syntax.ToString());
27171Assert.Equal("= 1", context.OperationBlocks[0].Syntax.ToString());
27174Assert.Equal("Attr2(200)", context.OperationBlocks[1].Syntax.ToString());
27177Assert.Equal("A(2)", context.OperationBlocks[2].Syntax.ToString());
27187Assert.Equal("= 4", context.OperationBlocks[0].Syntax.ToString());
27190Assert.Equal("Attr3(300)", context.OperationBlocks[1].Syntax.ToString());
27195Assert.Equal(": base(5)", context.OperationBlocks[3].Syntax.ToString());
27232Assert.Equal("= 0", context.OperationBlocks[0].Syntax.ToString());
27235Assert.Equal("Attr1(100)", context.OperationBlocks[1].Syntax.ToString());
27243Assert.Equal("= 1", context.OperationBlocks[0].Syntax.ToString());
27246Assert.Equal("Attr2(200)", context.OperationBlocks[1].Syntax.ToString());
27249Assert.Equal("A(2)", context.OperationBlocks[2].Syntax.ToString());
27257Assert.Equal("= 4", context.OperationBlocks[0].Syntax.ToString());
27260Assert.Equal("Attr3(300)", context.OperationBlocks[1].Syntax.ToString());
27265Assert.Equal(": base(5)", context.OperationBlocks[3].Syntax.ToString());
Microsoft.CodeAnalysis.CSharp.Features (76)
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);
Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests (5)
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (20)
Microsoft.CodeAnalysis.CSharp.Workspaces (6)
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (2)
Microsoft.CodeAnalysis.Features (91)
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);
Microsoft.CodeAnalysis.Test.Utilities (154)
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\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)
Microsoft.CodeAnalysis.VisualBasic.CodeStyle (6)
src\Analyzers\VisualBasic\Analyzers\SimplifyInterpolation\VisualBasicSimplifyInterpolationHelpers.vb (1)
19Return operation.Syntax
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes (2)
Microsoft.CodeAnalysis.VisualBasic.Features (10)
src\Analyzers\VisualBasic\Analyzers\SimplifyInterpolation\VisualBasicSimplifyInterpolationHelpers.vb (1)
19Return operation.Syntax
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (5)
Microsoft.CodeAnalysis.VisualBasic.Workspaces (1)
Microsoft.CodeAnalysis.Workspaces (14)
Microsoft.Interop.ComInterfaceGenerator (9)
Microsoft.Interop.LibraryImportGenerator (7)
Roslyn.Compilers.VisualBasic.IOperation.UnitTests (2)
System.Private.CoreLib.Generators (5)
System.Text.RegularExpressions.Generator (5)