public override void VisitTuple(ITupleOperation operation) { Assert.Equal(OperationKind.Tuple, operation.Kind); var naturalType = operation.NaturalType; AssertEx.Equal(operation.Elements, operation.Children); }
public override ExpressionSyntax VisitTuple(ITupleOperation operation, Scope scope) => TupleExpression( SeparatedList( operation.Elements.Select( element => Argument(element.Accept(this, scope)) ) ) );
public override PointsToAbstractValue VisitTuple(ITupleOperation operation, object argument) { // TODO: Handle tuples. // https://github.com/dotnet/roslyn-analyzers/issues/1571 return(base.VisitTuple(operation, argument)); }
public bool TryCreateForTupleElements(ITupleOperation tupleOperation, out ImmutableArray <AnalysisEntity> elementEntities) { if (_tupleElementEntitiesMap.TryGetValue(tupleOperation, out elementEntities)) { return(!elementEntities.IsDefault); } try { elementEntities = default; if (!tupleOperation.Type.IsTupleType) { return(false); } var tupleType = (INamedTypeSymbol)tupleOperation.Type; if (tupleType.TupleElements.IsDefault) { return(false); } PointsToAbstractValue instanceLocation = _getPointsToAbstractValueOpt(tupleOperation); var underlyingValueTupleType = tupleType.GetUnderlyingValueTupleTypeOrThis(); AnalysisEntity parentEntity = null; if (tupleOperation.TryGetParentTupleOperation(out var parentTupleOperationOpt, out var elementOfParentTupleContainingTuple) && TryCreateForTupleElements(parentTupleOperationOpt, out var parentTupleElementEntities)) { Debug.Assert(parentTupleOperationOpt.Elements.Length == parentTupleElementEntities.Length); for (int i = 0; i < parentTupleOperationOpt.Elements.Length; i++) { if (parentTupleOperationOpt.Elements[i] == elementOfParentTupleContainingTuple) { parentEntity = parentTupleElementEntities[i]; instanceLocation = parentEntity.InstanceLocation; break; } } Debug.Assert(parentEntity != null); } else { parentEntity = AnalysisEntity.Create(underlyingValueTupleType, ImmutableArray <AbstractIndex> .Empty, underlyingValueTupleType, instanceLocation, parentOpt: null); } Debug.Assert(parentEntity.InstanceLocation == instanceLocation); var builder = ArrayBuilder <AnalysisEntity> .GetInstance(tupleType.TupleElements.Length); foreach (var field in tupleType.TupleElements) { var tupleFieldName = field.CorrespondingTupleField.Name; var mappedValueTupleField = underlyingValueTupleType.GetMembers(tupleFieldName).OfType <IFieldSymbol>().FirstOrDefault(); if (mappedValueTupleField == null) { builder.Free(); return(false); } builder.Add(AnalysisEntity.Create(mappedValueTupleField, indices: ImmutableArray <AbstractIndex> .Empty, type: mappedValueTupleField.Type, instanceLocation, parentEntity)); } elementEntities = builder.ToImmutableAndFree(); return(true); }
public override NullAbstractValue VisitTuple(ITupleOperation operation, object argument) { var _ = base.VisitTuple(operation, argument); return(NullAbstractValue.NotNull); }
public override IOperation VisitTuple(ITupleOperation operation, object argument) { return(new TupleExpression(VisitArray(operation.Elements), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.NaturalType, operation.ConstantValue, operation.IsImplicit)); }
public virtual void VisitTuple(ITupleOperation operation) { DefaultVisit(operation); }
public override void VisitTuple([NotNull] ITupleOperation operation) { base.VisitTuple(operation); }
public override Scope VisitTuple(ITupleOperation operation, Scope currentScope) => operation.Elements.Aggregate(currentScope, (scope, element) => element.Accept(this, scope));
public override bool VisitTuple([NotNull] ITupleOperation operation1, [CanBeNull] IOperation argument) { return(argument is ITupleOperation operation2 && AreBaseOperationsEqual(operation1, operation2)); }