public TypeWrapper(ITypeSymbol namedTypeSymbol, MetadataLoadContextInternal metadataLoadContext) { _typeSymbol = namedTypeSymbol; _metadataLoadContext = metadataLoadContext; _namedTypeSymbol = _typeSymbol as INamedTypeSymbol; _arrayTypeSymbol = _typeSymbol as IArrayTypeSymbol; }
bool IArrayTypeSymbol.Equals(IArrayTypeSymbol?other) { return(this.Equals( other as ArrayTypeSymbol, CodeAnalysis.SymbolEqualityComparer.Default )); }
public TypeWrapper(ITypeSymbol namedTypeSymbol, MetadataLoadContext metadataLoadContext) { _TypeSymbol = namedTypeSymbol; _MetadataLoadContext = metadataLoadContext; _NamedTypeSymbol = _TypeSymbol as INamedTypeSymbol; _ArrayTypeSymbol = _TypeSymbol as IArrayTypeSymbol; }
public static string?TryFullName(this IArrayTypeSymbol?symbol) { if (symbol == null) { return(null); } return($"{symbol.ElementType.TryFullName()}[{(new string(',', symbol.Rank - 1))}]"); }
protected sealed override SymbolKeyResolution Resolve( SymbolKeyReader reader, IArrayTypeSymbol?contextualSymbol, out string?failureReason) { var elementTypeResolution = reader.ReadSymbolKey(contextualSymbol?.ElementType, out var elementTypeFailureReason); var rank = reader.ReadInteger(); if (elementTypeFailureReason != null) { failureReason = $"({nameof(ArrayTypeSymbolKey)} {nameof(elementTypeResolution)} failed -> {elementTypeFailureReason})"; return(default);
private SyntaxNode TryGenerateNewDocumentRoot( Document doc, SyntaxNode root, IInvocationOperation invocation, string invocationTokenArgumentName, string ancestorTokenParameterName, SyntaxNode expression, ImmutableArray <TArgumentSyntax> currentArguments, IArrayTypeSymbol?paramsArrayType) { SyntaxGenerator generator = SyntaxGenerator.GetGenerator(doc); ImmutableArray <SyntaxNode> newArguments; if (paramsArrayType is not null) { // current callsite is a params array, we need to wrap all these arguments to preserve semantics var typeSyntax = GetTypeSyntaxForArray(paramsArrayType); var expressions = GetExpressions(currentArguments); newArguments = ImmutableArray.Create(GetArrayCreationExpression(generator, typeSyntax, expressions)); } else { // not a params array just pass the existing arguments along newArguments = currentArguments.CastArray <SyntaxNode>(); } SyntaxNode identifier = generator.IdentifierName(invocationTokenArgumentName); SyntaxNode cancellationTokenArgument; if (!string.IsNullOrEmpty(ancestorTokenParameterName)) { cancellationTokenArgument = generator.Argument(ancestorTokenParameterName, RefKind.None, identifier); } else { cancellationTokenArgument = generator.Argument(identifier); } newArguments = newArguments.Add(cancellationTokenArgument); // Insert the new arguments to the new invocation SyntaxNode newInvocationWithArguments = generator.InvocationExpression(expression, newArguments).WithTriviaFrom(invocation.Syntax); return(generator.ReplaceNode(root, invocation.Syntax, newInvocationWithArguments)); }