2 implementations of Parent
Microsoft.CodeAnalysis (1)
Operations\Operation.cs (1)
48public IOperation? Parent
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (1)
Semantics\CollectionExpressionTests.cs (1)
27082IOperation IOperation.Parent => throw null;
352 references to Parent
ILLink.RoslynAnalyzer (29)
DataFlow\LValueFlowCaptureProvider.cs (1)
43 assignment = flowCaptureReference.Parent as IAssignmentOperation;
IOperationExtensions.cs (26)
45 while (operation.Parent is IBinaryPatternOperation || 46 operation.Parent is INegatedPatternOperation || 47 operation.Parent is IRelationalPatternOperation) { 48 operation = operation.Parent; 51 switch (operation.Parent) { 107 if (operation.Parent is IAssignmentOperation assignmentOperation && 109 return operation.Parent.IsAnyCompoundAssignment () 112 } else if (operation.Parent is IIncrementOrDecrementOperation) { 114 } else if (operation.Parent is IParenthesizedOperation parenthesizedOperation) { 120 } else if (operation.Parent is INameOfOperation || 121 operation.Parent is ITypeOfOperation || 122 operation.Parent is ISizeOfOperation) { 124 } else if (operation.Parent is IArgumentOperation argumentOperation) { 138 } else if (operation.Parent is IReturnOperation returnOperation) { 144 } else if (operation.Parent is IConditionalOperation conditionalOperation) { 151 } else if (operation.Parent is IReDimClauseOperation reDimClauseOperation && 153 return (reDimClauseOperation.Parent as IReDimOperation)?.Preserve == true 156 } else if (operation.Parent is IDeclarationExpressionOperation declarationExpression) { 160 } else if (operation.Parent is IVariableInitializerOperation variableInitializerOperation) { 161 if (variableInitializerOperation.Parent is IVariableDeclaratorOperation variableDeclaratorOperation) { 183 operation = operation?.Parent; 193 operation = operation.Parent; 204 var current = operation.Parent; 216 current = current.Parent; 254 var parent = operation.Parent; 270 parent = parent.Parent;
RequiresAnalyzerBase.cs (2)
204 var parent = operationContext.Operation.Parent; 220 parent = parent.Parent;
Microsoft.Analyzers.Extra (7)
AsyncCallInsideUsingBlockAnalyzer.cs (2)
49if (operation.Parent == null) 54ValidateDisposable(analysisContext, disposable, operation.Parent);
CallAnalysis\Fixers\LegacyLoggingFixer.cs (1)
368if (invocationOp.Parent?.Kind == OperationKind.ConditionalAccess)
Utilities\OperationExtensions.cs (4)
19while (operationToStart.Parent != null) 21if (operationToStart.Parent == parent) 26yield return operationToStart.Parent; 27operationToStart = operationToStart.Parent;
Microsoft.AspNetCore.App.Analyzers (11)
Authorization\AddAuthorizationBuilderAnalyzer.cs (3)
179if (propertyReferenceOperation.Parent is IAssignmentOperation { Target: IPropertyReferenceOperation targetProperty } 184if (propertyReferenceOperation.Parent is IAssignmentOperation { Value: IPropertyReferenceOperation valueProperty } 225return invocation.Parent is IExpressionStatementOperation;
Http\RequestDelegateReturnTypeAnalyzer.cs (2)
31if (methodReference.Parent is { } parent && 47if (anonymousFunction.Parent is { } parent &&
RouteHandlers\DetectAmbiguousRoutes.cs (6)
62if (current.Parent is IArgumentOperation { Parent: IInvocationOperation invocationOperation } && 70if (current.Parent is IBlockOperation or ISwitchCaseOperation) 72return current.Parent; 74else if (current.Parent is IConditionalOperation or 84current = current.Parent;
Microsoft.AspNetCore.Mvc.Analyzers (2)
TagHelpersInCodeBlocksAnalyzer.cs (2)
60var parent = context.Operation.Parent; 63parent = parent.Parent;
Microsoft.AspNetCore.Mvc.Api.Analyzers (5)
ActualApiResponseMetadataFactory.cs (2)
305var parent = operation.Parent; 313parent = parent.Parent;
ApiActionsDoNotRequireExplicitModelValidationCheckAnalyzer.cs (3)
51var parent = ifOperation.Parent; 58if (parent.Kind == OperationKind.Block && parent.Parent != null) 60parent = parent.Parent;
Microsoft.CodeAnalysis (30)
DiagnosticAnalyzer\AnalyzerDriver.cs (13)
2951if (operationBlock.Parent != null) 2953switch (operationBlock.Parent.Kind) 2957Debug.Assert(!operationBlock.Parent.IsImplicit); 2958operationsToAnalyze.Add(operationBlock.Parent); 2965Debug.Assert(operationBlock.Parent.IsImplicit); 2966Debug.Assert(operationBlock.Parent.Parent is IConstructorBodyOperation ctorBody && 2967ctorBody.Initializer == operationBlock.Parent); 2968Debug.Assert(!operationBlock.Parent.Parent.IsImplicit); 2970operationsToAnalyze.Add(operationBlock.Parent.Parent); 2975Debug.Fail($"Expected operation with kind '{operationBlock.Kind}' to be the root operation with null 'Parent', but instead it has a non-null Parent with kind '{operationBlock.Parent.Kind}'");
DiagnosticAnalyzer\AnalyzerExecutor.cs (1)
1502Debug.Assert(operation.Parent == null);
Operations\ControlFlowGraph.cs (1)
180if (operation.Parent != null)
Operations\ControlFlowGraphBuilder.cs (5)
95Debug.Assert(body.Parent == null); 3103Debug.Assert(operation.Parent != null); 3104bool isStatement = _currentStatement == operation || operation.Parent.Kind == OperationKind.ExpressionStatement; 3367bool isOnStatementLevel = _currentStatement == operation || (_currentStatement == operation.Parent && _currentStatement?.Kind == OperationKind.ExpressionStatement); 6594Debug.Assert(operation.Parent is InvocationOperation { Parent: CollectionExpressionOperation ce } && ce.HasErrors(_compilation),
Operations\ControlFlowGraphBuilder.InterpolatedStringContext.cs (2)
52IOperation? operation = placeholderOperation.Parent; 55operation = operation.Parent;
Operations\Operation.cs (1)
178Debug.Assert((object?)child.Parent == parent);
Operations\OperationExtensions.cs (5)
180return declarationOperation.Initializer ?? (declarationOperation.Parent as IVariableDeclarationOperation)?.Initializer; 336while (operation.Parent != null) 338operation = operation.Parent; 373for (IOperation current = operation; current.Parent != null; current = current.Parent)
Operations\OperationNodes.cs (2)
699Debug.Assert(statements.All(s => s.Parent != this && s.Parent!.Kind is OperationKind.Block or OperationKind.SwitchCase));
Microsoft.CodeAnalysis.CodeStyle (64)
src\Analyzers\Core\Analyzers\ConvertTypeofToNameof\AbstractConvertTypeOfToNameOfDiagnosticAnalyzer.cs (2)
58if (operation.Parent is not IPropertyReferenceOperation) 64var operationParent = (IPropertyReferenceOperation)operation.Parent;
src\Analyzers\Core\Analyzers\QualifyMemberAccess\AbstractQualifyMemberAccessDiagnosticAnalyzer.cs (1)
88if (context.Operation.Parent?.Kind == OperationKind.PropertySubpattern)
src\Analyzers\Core\Analyzers\RemoveUnusedMembers\AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (8)
235if (operation is { Kind: OperationKind.None, Parent: INameOfOperation { Argument: var nameofArgument } } && 364Debug.Assert(memberReference.Parent is ICompoundAssignmentOperation compoundAssignment && 366memberReference.Parent is ICoalesceAssignmentOperation coalesceAssignment && 368memberReference.Parent is IIncrementOrDecrementOperation || 369memberReference.Parent is IReDimClauseOperation reDimClause && reDimClause.Operand == memberReference); 388if (memberReference?.Parent?.Parent is IExpressionStatementOperation && 389memberReference.Parent is not ICoalesceAssignmentOperation)
src\Analyzers\Core\Analyzers\RemoveUnusedParametersAndValues\AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.BlockAnalyzer.cs (10)
265if (operation.Parent is IVariableInitializerOperation) 274if (operation.Parent is ISimpleAssignmentOperation assignment && 285operation.Parent is IDelegateCreationOperation) 287return IsHandledDelegateCreationOrAnonymousFunctionTreeShape(operation.Parent); 320if (operation.Parent is IInvocationOperation) 325if (operation.Parent is ISimpleAssignmentOperation assignmentOperation) 353if (operation.Parent is IBinaryOperation) 393hasUnknownOperationNoneDescendant = operation.Parent is not INameOfOperation; 640if (unusedSymbolWriteOperation.Parent is IAssignmentOperation assignment && 645else if (unusedSymbolWriteOperation.Parent is IIncrementOrDecrementOperation)
src\Analyzers\Core\Analyzers\SimplifyInterpolation\AbstractSimplifyInterpolationHelpers.cs (6)
58if (towardsParent && expression?.Parent is null) 64expression = towardsParent ? expression.Parent : parenthesized.Operand; 67expression = towardsParent ? expression.Parent : conversion.Operand; 162return Unwrap(interpolatedStringOperation?.Parent, towardsParent: true) is IArgumentOperation 164Parent: IInvocationOperation 179for (var current = operation; current is not null; current = current.Parent)
src\Analyzers\Core\Analyzers\UseConditionalExpression\ForReturn\UseConditionalExpressionForReturnHelpers.cs (1)
49if (ifOperation.Parent is not IBlockOperation parentBlock)
src\Analyzers\Core\Analyzers\UseThrowExpression\AbstractUseThrowExpressionDiagnosticAnalyzer.cs (1)
104if (ifOperation.Parent is not IBlockOperation containingBlock)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\OperationExtensions.cs (24)
19=> operation.Parent is IAssignmentOperation assignmentOperation && 21assignmentOperation.Parent?.Kind == OperationKind.ObjectOrCollectionInitializer; 60while (operation.Parent is IBinaryPatternOperation or 64operation = operation.Parent; 67switch (operation.Parent) 128if (operation.Parent is IAssignmentOperation assignmentOperation && 131return operation.Parent.IsAnyCompoundAssignment() 135else if (operation.Parent is ISimpleAssignmentOperation simpleAssignmentOperation && 141else if (operation.Parent is IIncrementOrDecrementOperation || (operation.Parent is IForToLoopOperation forToLoopOperation && forToLoopOperation.LoopControlVariable.Equals(operation))) 145else if (operation.Parent is IParenthesizedOperation parenthesizedOperation) 153else if (operation.Parent is INameOfOperation or 159else if (operation.Parent is IArgumentOperation argumentOperation) 176else if (operation.Parent is IReturnOperation returnOperation) 185else if (operation.Parent is IConditionalOperation conditionalOperation) 197else if (operation.Parent is IReDimClauseOperation reDimClauseOperation && 200return (reDimClauseOperation.Parent as IReDimOperation)?.Preserve == true 204else if (operation.Parent is IDeclarationExpressionOperation declarationExpression) 212else if (operation.Parent is IVariableInitializerOperation variableInitializerOperation) 214if (variableInitializerOperation.Parent is IVariableDeclaratorOperation variableDeclaratorOperation) 238operation = operation?.Parent; 250operation = operation.Parent; 261var current = operation.Parent; 275current = current.Parent;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\LValueFlowCaptureProvider.cs (2)
56if (flowCaptureReference.Parent is IAssignmentOperation assignment && 61var captureKind = flowCaptureReference.Parent.IsAnyCompoundAssignment() || rvalueFlowCaptureIds.Contains(flowCaptureReference.Id)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\SymbolUsageAnalysis.Walker.cs (9)
131if (operation.Parent is IFlowCaptureOperation flowCapture && 153if (operation.Parent is IIncrementOrDecrementOperation && 154operation.Parent.Parent?.Kind != OperationKind.ExpressionStatement) 164if (operation.Parent is IAssignmentOperation assignmentOperation && 192operation.Parent?.Kind != OperationKind.ExpressionStatement; 272operation.Parent is IForEachLoopOperation forEachLoop && forEachLoop.LoopControlVariable == operation || 273operation.Parent is ICatchClauseOperation catchClause && catchClause.ExceptionDeclarationOrExpression == operation) 421else if (write.Parent is ISimpleAssignmentOperation simpleAssignment)
Microsoft.CodeAnalysis.CodeStyle.Fixes (1)
src\Analyzers\Core\CodeFixes\UseConditionalExpression\ForAssignment\AbstractUseConditionalExpressionForAssignmentCodeFixProvider.cs (1)
187if (ifOperation.Parent is not IBlockOperation parentBlock)
Microsoft.CodeAnalysis.CSharp.CodeStyle (22)
src\Analyzers\CSharp\Analyzers\MakeStructMemberReadOnly\CSharpMakeStructMemberReadOnlyAnalyzer.cs (3)
284for (var operation = instanceOperation.Parent; operation != null; operation = operation.Parent) 325if (operation.Parent is IEventAssignmentOperation)
src\Analyzers\CSharp\Analyzers\RemoveUnusedParametersAndValues\CSharpRemoveUnusedParametersAndValuesDiagnosticAnalyzer.cs (1)
78=> expressionStatementOperation.Parent is IBlockOperation blockOperation &&
src\Analyzers\CSharp\Analyzers\SimplifyLinqExpression\CSharpSimplifyLinqExpressionDiagnosticAnalyzer.cs (2)
24=> invocation.Parent is IArgumentOperation { Parent: IInvocationOperation nextInvocation } ? nextInvocation : null;
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\UseCollectionExpressionHelpers.cs (1)
138if (operation?.Parent is IAssignmentOperation { Type.TypeKind: TypeKind.Dynamic })
src\Analyzers\CSharp\Analyzers\UseConditionalExpression\CSharpUseConditionalExpressionForReturnDiagnosticAnalyzer.cs (1)
36if (statement is not IReturnOperation { Parent: IBlockOperation block })
src\Analyzers\CSharp\Analyzers\UseSystemThreadingLock\CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs (3)
183if (fieldReferenceOperation.Parent is ILockOperation lockOperation) 202if (fieldReferenceOperation.Parent is IAssignmentOperation assignment && 210if (fieldReferenceOperation.Parent is INameOfOperation)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (11)
91Parent.Kind: OperationKind.DelegateCreation, 95var current = castExpressionOperation.Parent.Parent; 97current = current.Parent; 106if (current.Parent is IConversionOperation { Type: { } parentConversionType, IsImplicit: false } && 266if (rewrittenOperation.Parent is not IDelegateCreationOperation rewrittenDelegateCreationOperation) 277if (originalDelegateCreationOperation.Parent is IConversionOperation conversionOperation && 404if (originalConversionOperation.Parent is IConversionOperation { Conversion.IsUserDefined: true } originalParentConversionOperation) 746if (originalConversionOperation.Parent is not IConversionOperation outerOriginalConversionOperation) 799if (rewrittenOperation.Parent is not IConversionOperation rewrittenBitwiseNotConversionOperation) 888if (rewrittenConditionalOperation.Parent is IConversionOperation conditionalParentConversion &&
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (1)
src\Analyzers\CSharp\CodeFixes\UseUtf8StringLiteral\UseUtf8StringLiteralCodeFixProvider.cs (1)
133operation = operation.Parent!;
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (5)
CodeGen\CodeGenLocalFunctionTests.cs (5)
161Assert.Equal(OperationKind.ExpressionStatement, objectCreationOperation.Parent.Kind); 162Assert.Equal(OperationKind.Block, objectCreationOperation.Parent.Parent.Kind); 163Assert.Same(localFunctionOperation.IgnoredBody, objectCreationOperation.Parent.Parent);
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (40)
Semantics\OutVarTests.cs (22)
3516Assert.Null(initializerOperation.Parent.Parent.Parent); 3517VerifyOperationTree(compilation, initializerOperation.Parent.Parent, @" 35999Assert.Equal(OperationKind.ExpressionStatement, initializerOperation.Parent.Kind); 36022Assert.Equal(OperationKind.ConstructorBody, blockBodyOperation.Parent.Kind); 36023Assert.Same(initializerOperation.Parent.Parent, blockBodyOperation.Parent); 36024Assert.Null(blockBodyOperation.Parent.Parent); 36047Assert.Same(blockBodyOperation.Parent, model.GetOperation(expressionBodySyntax).Parent); 36051Assert.Same(blockBodyOperation.Parent, model.GetOperation(declarationSyntax)); 36143Assert.Equal(OperationKind.MethodBody, expressionBodyOperation.Parent.Kind); 36144Assert.Null(expressionBodyOperation.Parent.Parent); 36168Assert.Same(expressionBodyOperation.Parent, blockBodyOperation.Parent); 36176Assert.Same(expressionBodyOperation.Parent, model.GetOperation(declarationSyntax)); 36250Assert.Null(model.GetOperation(node3).Parent);
Semantics\PrimaryConstructorTests.cs (9)
1129Assert.Same(operation.Parent.Parent, model.GetOperation(baseWithargs.Parent.Parent)); 1132VerifyOperationTree(comp, operation.Parent.Parent, 1156Assert.Null(operation.Parent.Parent.Parent); 1157VerifyFlowGraph(comp, operation.Parent.Parent.Syntax, @"
Semantics\RecordTests.cs (9)
21247Assert.Same(operation.Parent.Parent, model.GetOperation(baseWithargs.Parent.Parent)); 21250VerifyOperationTree(comp, operation.Parent.Parent, 21274Assert.Null(operation.Parent.Parent.Parent); 21275VerifyFlowGraph(comp, operation.Parent.Parent.Syntax, @"
Microsoft.CodeAnalysis.CSharp.EndToEnd.UnitTests (2)
EndToEndTests.cs (2)
885for (; operation.Parent is not null; operation = operation.Parent) { }
Microsoft.CodeAnalysis.CSharp.Features (12)
src\Analyzers\CSharp\Analyzers\MakeStructMemberReadOnly\CSharpMakeStructMemberReadOnlyAnalyzer.cs (3)
284for (var operation = instanceOperation.Parent; operation != null; operation = operation.Parent) 325if (operation.Parent is IEventAssignmentOperation)
src\Analyzers\CSharp\Analyzers\RemoveUnusedParametersAndValues\CSharpRemoveUnusedParametersAndValuesDiagnosticAnalyzer.cs (1)
78=> expressionStatementOperation.Parent is IBlockOperation blockOperation &&
src\Analyzers\CSharp\Analyzers\SimplifyLinqExpression\CSharpSimplifyLinqExpressionDiagnosticAnalyzer.cs (2)
24=> invocation.Parent is IArgumentOperation { Parent: IInvocationOperation nextInvocation } ? nextInvocation : null;
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\UseCollectionExpressionHelpers.cs (1)
138if (operation?.Parent is IAssignmentOperation { Type.TypeKind: TypeKind.Dynamic })
src\Analyzers\CSharp\Analyzers\UseConditionalExpression\CSharpUseConditionalExpressionForReturnDiagnosticAnalyzer.cs (1)
36if (statement is not IReturnOperation { Parent: IBlockOperation block })
src\Analyzers\CSharp\Analyzers\UseSystemThreadingLock\CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs (3)
183if (fieldReferenceOperation.Parent is ILockOperation lockOperation) 202if (fieldReferenceOperation.Parent is IAssignmentOperation assignment && 210if (fieldReferenceOperation.Parent is INameOfOperation)
src\Analyzers\CSharp\CodeFixes\UseUtf8StringLiteral\UseUtf8StringLiteralCodeFixProvider.cs (1)
133operation = operation.Parent!;
Microsoft.CodeAnalysis.CSharp.Features.UnitTests (1)
Diagnostics\Suppression\RemoveUnnecessaryPragmaSuppressionsTests.cs (1)
82if (localReference.Parent is ISimpleAssignmentOperation simpleAssignment &&
Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests (3)
IOperation\IOperationTests.cs (3)
514Assert.Null(operation.Parent); 687if (operation.Parent == null) 694operation = operation.Parent;
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (8)
Semantics\TopLevelStatementsTests.cs (8)
204Assert.NotNull(ControlFlowGraph.Create((IMethodBodyOperation)((IBlockOperation)operation1.Parent.Parent).Parent)); 332Assert.NotNull(ControlFlowGraph.Create((IMethodBodyOperation)((IBlockOperation)operation1.Parent.Parent).Parent)); 370Assert.NotNull(ControlFlowGraph.Create((IMethodBodyOperation)((IBlockOperation)operation2.Parent).Parent));
Microsoft.CodeAnalysis.CSharp.Test.Utilities (1)
CompilationTestUtils.cs (1)
376if (iop is { Parent: IConversionOperation parentConversion })
Microsoft.CodeAnalysis.CSharp.Workspaces (11)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (11)
91Parent.Kind: OperationKind.DelegateCreation, 95var current = castExpressionOperation.Parent.Parent; 97current = current.Parent; 106if (current.Parent is IConversionOperation { Type: { } parentConversionType, IsImplicit: false } && 266if (rewrittenOperation.Parent is not IDelegateCreationOperation rewrittenDelegateCreationOperation) 277if (originalDelegateCreationOperation.Parent is IConversionOperation conversionOperation && 404if (originalConversionOperation.Parent is IConversionOperation { Conversion.IsUserDefined: true } originalParentConversionOperation) 746if (originalConversionOperation.Parent is not IConversionOperation outerOriginalConversionOperation) 799if (rewrittenOperation.Parent is not IConversionOperation rewrittenBitwiseNotConversionOperation) 888if (rewrittenConditionalOperation.Parent is IConversionOperation conditionalParentConversion &&
Microsoft.CodeAnalysis.Features (32)
ConvertIfToSwitch\AbstractConvertIfToSwitchCodeRefactoringProvider.cs (1)
87if (ifOperation is not IConditionalOperation { Parent: IBlockOperation parentBlock })
src\Analyzers\Core\Analyzers\ConvertTypeofToNameof\AbstractConvertTypeOfToNameOfDiagnosticAnalyzer.cs (2)
58if (operation.Parent is not IPropertyReferenceOperation) 64var operationParent = (IPropertyReferenceOperation)operation.Parent;
src\Analyzers\Core\Analyzers\QualifyMemberAccess\AbstractQualifyMemberAccessDiagnosticAnalyzer.cs (1)
88if (context.Operation.Parent?.Kind == OperationKind.PropertySubpattern)
src\Analyzers\Core\Analyzers\RemoveUnusedMembers\AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (8)
235if (operation is { Kind: OperationKind.None, Parent: INameOfOperation { Argument: var nameofArgument } } && 364Debug.Assert(memberReference.Parent is ICompoundAssignmentOperation compoundAssignment && 366memberReference.Parent is ICoalesceAssignmentOperation coalesceAssignment && 368memberReference.Parent is IIncrementOrDecrementOperation || 369memberReference.Parent is IReDimClauseOperation reDimClause && reDimClause.Operand == memberReference); 388if (memberReference?.Parent?.Parent is IExpressionStatementOperation && 389memberReference.Parent is not ICoalesceAssignmentOperation)
src\Analyzers\Core\Analyzers\RemoveUnusedParametersAndValues\AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.BlockAnalyzer.cs (10)
265if (operation.Parent is IVariableInitializerOperation) 274if (operation.Parent is ISimpleAssignmentOperation assignment && 285operation.Parent is IDelegateCreationOperation) 287return IsHandledDelegateCreationOrAnonymousFunctionTreeShape(operation.Parent); 320if (operation.Parent is IInvocationOperation) 325if (operation.Parent is ISimpleAssignmentOperation assignmentOperation) 353if (operation.Parent is IBinaryOperation) 393hasUnknownOperationNoneDescendant = operation.Parent is not INameOfOperation; 640if (unusedSymbolWriteOperation.Parent is IAssignmentOperation assignment && 645else if (unusedSymbolWriteOperation.Parent is IIncrementOrDecrementOperation)
src\Analyzers\Core\Analyzers\SimplifyInterpolation\AbstractSimplifyInterpolationHelpers.cs (6)
58if (towardsParent && expression?.Parent is null) 64expression = towardsParent ? expression.Parent : parenthesized.Operand; 67expression = towardsParent ? expression.Parent : conversion.Operand; 162return Unwrap(interpolatedStringOperation?.Parent, towardsParent: true) is IArgumentOperation 164Parent: IInvocationOperation 179for (var current = operation; current is not null; current = current.Parent)
src\Analyzers\Core\Analyzers\UseConditionalExpression\ForReturn\UseConditionalExpressionForReturnHelpers.cs (1)
49if (ifOperation.Parent is not IBlockOperation parentBlock)
src\Analyzers\Core\Analyzers\UseThrowExpression\AbstractUseThrowExpressionDiagnosticAnalyzer.cs (1)
104if (ifOperation.Parent is not IBlockOperation containingBlock)
src\Analyzers\Core\CodeFixes\UseConditionalExpression\ForAssignment\AbstractUseConditionalExpressionForAssignmentCodeFixProvider.cs (1)
187if (ifOperation.Parent is not IBlockOperation parentBlock)
ValueTracking\ValueTracker.OperationCollector.cs (1)
289operation = operation.Parent;
Microsoft.CodeAnalysis.Test.Utilities (25)
CommonTestBase.cs (1)
585Assert.Equal(child.Parent, parent);
Compilation\CompilationExtensions.cs (1)
310if (operation.Parent == null)
Compilation\ControlFlowGraphVerifier.cs (15)
34(operationRoot.Parent?.Kind == OperationKind.ConstructorBody || 35operationRoot.Parent?.Kind == OperationKind.MethodBody) ? 36operationRoot.Parent : 899containingArgument = containingArgument.Parent; 906Parent: IObjectCreationOperation 908Parent: IFlowCaptureOperation, 931Parent: IInvocationOperation 944if (reference.Parent is IBinaryOperation binOp) 996if (reference.Parent is ISimpleAssignmentOperation assignment && 1042if (operation.Parent == null && operation is IsNullOperation isNull && isNull.Operand.Kind == OperationKind.FlowCaptureReference) 1631Assert.Null(root.Parent); 1639Assert.NotNull(operation.Parent); 1893n.Parent is IPropertyReferenceOperation propertyReference && 1895propertyReference.Parent is ISimpleAssignmentOperation simpleAssignment && 1897simpleAssignment.Parent.Kind == OperationKind.AnonymousObjectCreation);
Compilation\OperationTreeVerifier.cs (2)
1040if (operation.Parent is IMemberReferenceOperation memberReference && memberReference.Instance == operation) 1044else if (operation.Parent is IInvocationOperation invocation && invocation.Instance == operation)
Compilation\TestOperationVisitor.cs (4)
56Assert.Equal(LanguageNames.CSharp, operation.Parent.Language); 184Assert.NotNull(root.Parent); 185Assert.Same(root, ((SwitchCaseOperation)root.Parent).Condition); 189Assert.Null(root.Parent);
Diagnostics\CouldHaveMoreSpecificTypeAnalyzer.cs (2)
105if (initializer.Parent is IVariableDeclaratorOperation singleVariableDeclaration) 110else if (initializer.Parent is IVariableDeclarationOperation multiVariableDeclaration)
Microsoft.CodeAnalysis.VisualBasic.CodeStyle (1)
src\Analyzers\VisualBasic\Analyzers\SimplifyLinqExpression\VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer.vb (1)
24Return TryCast(invocation.Parent, IInvocationOperation)
Microsoft.CodeAnalysis.VisualBasic.Features (1)
src\Analyzers\VisualBasic\Analyzers\SimplifyLinqExpression\VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer.vb (1)
24Return TryCast(invocation.Parent, IInvocationOperation)
Microsoft.CodeAnalysis.Workspaces (37)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\OperationExtensions.cs (24)
19=> operation.Parent is IAssignmentOperation assignmentOperation && 21assignmentOperation.Parent?.Kind == OperationKind.ObjectOrCollectionInitializer; 60while (operation.Parent is IBinaryPatternOperation or 64operation = operation.Parent; 67switch (operation.Parent) 128if (operation.Parent is IAssignmentOperation assignmentOperation && 131return operation.Parent.IsAnyCompoundAssignment() 135else if (operation.Parent is ISimpleAssignmentOperation simpleAssignmentOperation && 141else if (operation.Parent is IIncrementOrDecrementOperation || (operation.Parent is IForToLoopOperation forToLoopOperation && forToLoopOperation.LoopControlVariable.Equals(operation))) 145else if (operation.Parent is IParenthesizedOperation parenthesizedOperation) 153else if (operation.Parent is INameOfOperation or 159else if (operation.Parent is IArgumentOperation argumentOperation) 176else if (operation.Parent is IReturnOperation returnOperation) 185else if (operation.Parent is IConditionalOperation conditionalOperation) 197else if (operation.Parent is IReDimClauseOperation reDimClauseOperation && 200return (reDimClauseOperation.Parent as IReDimOperation)?.Preserve == true 204else if (operation.Parent is IDeclarationExpressionOperation declarationExpression) 212else if (operation.Parent is IVariableInitializerOperation variableInitializerOperation) 214if (variableInitializerOperation.Parent is IVariableDeclaratorOperation variableDeclaratorOperation) 238operation = operation?.Parent; 250operation = operation.Parent; 261var current = operation.Parent; 275current = current.Parent;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\LValueFlowCaptureProvider.cs (2)
56if (flowCaptureReference.Parent is IAssignmentOperation assignment && 61var captureKind = flowCaptureReference.Parent.IsAnyCompoundAssignment() || rvalueFlowCaptureIds.Contains(flowCaptureReference.Id)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\SymbolUsageAnalysis.Walker.cs (9)
131if (operation.Parent is IFlowCaptureOperation flowCapture && 153if (operation.Parent is IIncrementOrDecrementOperation && 154operation.Parent.Parent?.Kind != OperationKind.ExpressionStatement) 164if (operation.Parent is IAssignmentOperation assignmentOperation && 192operation.Parent?.Kind != OperationKind.ExpressionStatement; 272operation.Parent is IForEachLoopOperation forEachLoop && forEachLoop.LoopControlVariable == operation || 273operation.Parent is ICatchClauseOperation catchClause && catchClause.ExceptionDeclarationOrExpression == operation) 421else if (write.Parent is ISimpleAssignmentOperation simpleAssignment)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\NullableHelpers.cs (2)
37rootOperation.Parent is not null) 39rootOperation = rootOperation.Parent;
System.Private.CoreLib.Generators (1)
IntrinsicsInSystemPrivateCoreLibAnalyzer.cs (1)
506operationSearch = operationSearch.Parent;