public static SymbolKeyResolution Resolve(SymbolKeyReader reader) { var isError = reader.ReadBoolean(); if (isError) { using var elementTypes = reader.ReadSymbolKeyArray <ITypeSymbol>(); using var elementNames = reader.ReadStringArray(); var elementLocations = ReadElementLocations(reader); if (!elementTypes.IsDefault) { try { var result = reader.Compilation.CreateTupleTypeSymbol( elementTypes.ToImmutable(), elementNames.ToImmutable(), elementLocations); return(new SymbolKeyResolution(result)); } catch (ArgumentException) { } } } else { var underlyingTypeResolution = reader.ReadSymbolKey(); using var elementNamesBuilder = reader.ReadStringArray(); var elementLocations = ReadElementLocations(reader); try { using var result = PooledArrayBuilder <INamedTypeSymbol> .GetInstance(); var elementNames = elementNamesBuilder.ToImmutable(); foreach (var namedType in underlyingTypeResolution.OfType <INamedTypeSymbol>()) { result.AddIfNotNull(reader.Compilation.CreateTupleTypeSymbol( namedType, elementNames, elementLocations)); } return(CreateResolution(result)); } catch (ArgumentException) { } } return(new SymbolKeyResolution(reader.Compilation.ObjectType)); }
private static SymbolKeyResolution ResolveNormalTuple(SymbolKeyReader reader, out string?failureReason) { using var elementNames = reader.ReadStringArray(); var elementLocations = ReadElementLocations(reader, out var elementLocationsFailureReason); var underlyingTypeResolution = reader.ReadSymbolKey(out var underlyingTypeFailureReason); if (underlyingTypeFailureReason != null) { failureReason = $"({nameof(TupleTypeSymbolKey)} {nameof(underlyingTypeResolution)} failed -> {underlyingTypeFailureReason})"; return(default);
public static SymbolKeyResolution Resolve(SymbolKeyReader reader) { var isError = reader.ReadBoolean(); if (isError) { var elementTypes = reader.ReadSymbolKeyArray().SelectAsArray(r => r.GetAnySymbol() as ITypeSymbol); var elementNames = reader.ReadStringArray(); var elementLocations = ReadElementLocations(reader); if (!elementTypes.Any(t => t == null)) { try { var result = reader.Compilation.CreateTupleTypeSymbol( elementTypes, elementNames, elementLocations); return(new SymbolKeyResolution(result)); } catch (ArgumentException) { } } } else { var underlyingTypeResolution = reader.ReadSymbolKey(); var elementNames = reader.ReadStringArray(); var elementLocations = ReadElementLocations(reader); try { var result = GetAllSymbols <INamedTypeSymbol>(underlyingTypeResolution).Select( t => reader.Compilation.CreateTupleTypeSymbol(t, elementNames, elementLocations)); return(CreateSymbolInfo(result)); } catch (ArgumentException) { } } return(new SymbolKeyResolution(reader.Compilation.ObjectType)); }
public static SymbolKeyResolution Resolve(SymbolKeyReader reader, out string failureReason) { using var propertyTypes = reader.ReadSymbolKeyArray <ITypeSymbol>(out var propertyTypesFailureReason); using var propertyNames = reader.ReadStringArray(); using var propertyIsReadOnly = reader.ReadBooleanArray(); using var propertyLocations = reader.ReadLocationArray(out var propertyLocationsFailureReason); if (propertyTypesFailureReason != null) { failureReason = $"({nameof(AnonymousTypeSymbolKey)} {nameof(propertyTypes)} failed -> {propertyTypesFailureReason})"; return(default);
public static SymbolKeyResolution Resolve(SymbolKeyReader reader, out string?failureReason) { using var propertyTypes = reader.ReadSymbolKeyArray <ITypeSymbol>(out var propertyTypesFailureReason); #pragma warning disable IDE0007 // Use implicit type using PooledArrayBuilder <string> propertyNames = reader.ReadStringArray() !; #pragma warning restore IDE0007 // Use implicit type using var propertyIsReadOnly = reader.ReadBooleanArray(); var propertyLocations = ReadPropertyLocations(reader, out var propertyLocationsFailureReason); if (propertyTypesFailureReason != null) { failureReason = $"({nameof(AnonymousTypeSymbolKey)} {nameof(propertyTypes)} failed -> {propertyTypesFailureReason})"; return(default);
public static SymbolKeyResolution Resolve(SymbolKeyReader reader) { var underlyingTypeResolution = reader.ReadSymbolKey(); var tupleElementNames = reader.ReadStringArray(); try { var result = GetAllSymbols <INamedTypeSymbol>(underlyingTypeResolution).Select( t => reader.Compilation.CreateTupleTypeSymbol(t, tupleElementNames)); return(CreateSymbolInfo(result)); } catch (ArgumentException) { return(new SymbolKeyResolution(reader.Compilation.ObjectType)); } }
public static SymbolKeyResolution Resolve(SymbolKeyReader reader) { var propertyTypeSymbols = reader.ReadSymbolKeyArray(); var propertyTypes = propertyTypeSymbols.Select(r => GetFirstSymbol <ITypeSymbol>(r)).ToImmutableArray(); var propertyNames = reader.ReadStringArray(); if (propertyTypes.Length == propertyNames.Length) { try { var anonymousType = reader.Compilation.CreateAnonymousTypeSymbol(propertyTypes, propertyNames); return(new SymbolKeyResolution(anonymousType)); } catch (ArgumentException) { } } return(new SymbolKeyResolution(reader.Compilation.ObjectType)); }
public static SymbolKeyResolution Resolve(SymbolKeyReader reader) { using var propertyTypes = reader.ReadSymbolKeyArray <ITypeSymbol>(); using var propertyNames = reader.ReadStringArray(); using var propertyIsReadOnly = reader.ReadBooleanArray(); using var propertyLocations = reader.ReadLocationArray(); if (!propertyTypes.IsDefault) { try { var anonymousType = reader.Compilation.CreateAnonymousTypeSymbol( propertyTypes.ToImmutable(), propertyNames.ToImmutable(), propertyIsReadOnly.ToImmutable(), propertyLocations.ToImmutable()); return(new SymbolKeyResolution(anonymousType)); } catch (ArgumentException) { } } return(new SymbolKeyResolution(reader.Compilation.ObjectType)); }