public override void VisitForEachLoop(IForEachLoopOperation operation) { VisitLoop(operation); Assert.Equal(LoopKind.ForEach, operation.LoopKind); IEnumerable <IOperation> children = new[] { operation.Collection, operation.LoopControlVariable, operation.Body }.Concat(operation.NextVariables); AssertEx.Equal(children, operation.Children); ForEachLoopOperationInfo info = ((BaseForEachLoopStatement)operation).Info; visitArguments(info.GetEnumeratorArguments); visitArguments(info.MoveNextArguments); visitArguments(info.CurrentArguments); void visitArguments(Lazy <ImmutableArray <IArgumentOperation> > arguments) { if (arguments != null) { foreach (IArgumentOperation arg in arguments.Value) { VerifySubTree(arg); } } } }
public override void VisitForEachLoop(IForEachLoopOperation operation) { Assert.Equal(OperationKind.Loop, operation.Kind); Assert.Equal(LoopKind.ForEach, operation.LoopKind); VisitLocals(operation); IEnumerable <IOperation> children = new[] { operation.Collection, operation.LoopControlVariable, operation.Body }.Concat(operation.NextVariables); AssertEx.Equal(children, operation.Children); }
protected override bool CheckForEachGetEnumerator(IForEachLoopOperation operation, [DisallowNull] ref IConversionOperation?conversion, [DisallowNull] ref IOperation?instance) { if (operation.Syntax is CommonForEachStatementSyntax syntax && operation.SemanticModel.GetForEachStatementInfo(syntax).GetEnumeratorMethod is { } getEnumeratorMethod) { CheckMethodSymbolInUnsupportedContext(operation, getEnumeratorMethod); if (instance is not null && Cache.IsNonCopyableType(getEnumeratorMethod.ReceiverType) && !getEnumeratorMethod.IsReadOnly && Acquire(instance) == RefKind.In) { // mark the instance as not checked by this method instance = null; } return(true); } return(false); }
public override void VisitForEachLoop(IForEachLoopOperation operation) { Assert.Equal(OperationKind.Loop, operation.Kind); Assert.Equal(LoopKind.ForEach, operation.LoopKind); VisitLocals(operation); IEnumerable <IOperation> children; // operation.LoopControlVariable shouldn't be null. // The following conditional logic should be removed once https://github.com/dotnet/roslyn/issues/23820 // is fixed. if (operation.LoopControlVariable == null) { Assert.Equal(LanguageNames.CSharp, operation.Language); children = new[] { operation.Collection, operation.Body }; } else { children = new[] { operation.Collection, operation.LoopControlVariable, operation.Body }; } children = children.Concat(operation.NextVariables); AssertEx.Equal(children, operation.Children); }
/// <summary> /// Perform language specific checks if the conversion is supported. /// C#: Currently nothing blocking a conversion /// VB: Nested foreach loops sharing a single Next statement, Next statements with multiple variables and next statements /// not using the loop variable are not supported. /// </summary> protected abstract bool IsSupported(ILocalSymbol foreachVariable, IForEachLoopOperation forEachOperation, TForEachStatement foreachStatement);
public override IOperation VisitForEachLoop(IForEachLoopOperation operation, object argument) { return(new ForEachLoopStatement(operation.Locals, operation.ContinueLabel, operation.ExitLabel, Visit(operation.LoopControlVariable), Visit(operation.Collection), VisitArray(operation.NextVariables), Visit(operation.Body), ((BaseForEachLoopStatement)operation).Info, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit)); }
public virtual void VisitForEachLoop(IForEachLoopOperation operation) { DefaultVisit(operation); }
public override void VisitForEachLoop([NotNull] IForEachLoopOperation operation) { Visit(operation.LoopControlVariable); Visit(operation.Collection); }
public override void VisitForEachLoop([NotNull] IForEachLoopOperation operation) { base.VisitForEachLoop(operation); }
public override void VisitForEachLoop([NotNull] IForEachLoopOperation operation) { IncrementStatementCount(operation); base.VisitForEachLoop(operation); }
public override Location VisitForEachLoop([NotNull] IForEachLoopOperation operation, [CanBeNull] object argument) { var syntax = (ForEachStatementSyntax)operation.Syntax; return(syntax.ForEachKeyword.GetLocation()); }
public override void VisitForEachLoop(IForEachLoopOperation operation) { WalkLoop(operation); base.VisitForEachLoop(operation); }
public override bool VisitForEachLoop([NotNull] IForEachLoopOperation operation1, [CanBeNull] IOperation argument) { return(argument is IForEachLoopOperation operation2 && AreBaseOperationsEqual(operation1, operation2) && operation1.LoopKind == operation2.LoopKind && AreSymbolSequencesEqual(operation1.Locals, operation2.Locals)); }
public override void VisitForEachLoop([NotNull] IForEachLoopOperation operation) { LoopStatementLocation = operation.GetLocationForKeyword(); }