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 propertyTypeSymbols = reader.ReadSymbolKeyArray(); var propertyTypes = propertyTypeSymbols.Select(r => GetFirstSymbol <ITypeSymbol>(r)).ToImmutableArray(); var propertyNames = reader.ReadStringArray(); var propertyIsReadOnly = reader.ReadBooleanArray(); var propertyLocations = reader.ReadLocationArray(); if (propertyTypes.Length == propertyNames.Length) { try { var anonymousType = reader.Compilation.CreateAnonymousTypeSymbol( propertyTypes, propertyNames, propertyIsReadOnly, propertyLocations); 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)); }