public static void Create(INamedTypeSymbol symbol, SymbolKeyWriter visitor) { visitor.WriteString(symbol.Name); switch (symbol.ContainingSymbol) { case INamedTypeSymbol parentType: visitor.WriteInteger(0); visitor.WriteSymbolKey(parentType); break; case INamespaceSymbol parentNamespace: visitor.WriteInteger(1); visitor.WriteStringArray(GetContainingNamespaceNamesInReverse(parentNamespace)); break; default: visitor.WriteInteger(2); break; } visitor.WriteInteger(symbol.Arity); if (!symbol.Equals(symbol.ConstructedFrom)) { visitor.WriteSymbolKeyArray(symbol.TypeArguments); } else { visitor.WriteSymbolKeyArray(ImmutableArray <ITypeSymbol> .Empty); } }
public static void Create(INamedTypeSymbol symbol, SymbolKeyWriter visitor) { Debug.Assert(symbol.IsAnonymousType); var properties = symbol.GetMembers().OfType <IPropertySymbol>().ToArray(); var propertyTypes = properties.Select(p => p.Type).ToImmutableArray(); var propertyNames = properties.Select(p => p.Name).ToImmutableArray(); visitor.WriteSymbolKeyArray(propertyTypes); visitor.WriteStringArray(propertyNames); }
public static void Create(INamedTypeSymbol symbol, SymbolKeyWriter visitor) { Debug.Assert(symbol.IsAnonymousType); var properties = symbol.GetMembers().OfType<IPropertySymbol>().ToArray(); var propertyTypes = properties.Select(p => p.Type).ToImmutableArray(); var propertyNames = properties.Select(p => p.Name).ToImmutableArray(); visitor.WriteSymbolKeyArray(propertyTypes); visitor.WriteStringArray(propertyNames); }
public static void Create(INamedTypeSymbol symbol, SymbolKeyWriter visitor) { Debug.Assert(symbol.IsTupleType); visitor.WriteSymbolKey(symbol.TupleUnderlyingType); visitor.WriteStringArray(symbol.TupleElementNames); var locations = ArrayBuilder<Location>.GetInstance(); for (var i = 0; i < symbol.TupleElementTypes.Length; i++) { locations.Add(symbol.GetMembers("Item" + (i + 1)).FirstOrDefault()?.Locations.FirstOrDefault()); } visitor.WriteLocationArray(locations.ToImmutableAndFree()); }
public sealed override void Create(INamedTypeSymbol symbol, SymbolKeyWriter visitor) { Debug.Assert(symbol.IsAnonymousType); var properties = symbol.GetMembers().OfType <IPropertySymbol>().ToImmutableArray(); var propertyTypes = properties.SelectAsArray(p => p.Type); var propertyNames = properties.SelectAsArray(p => p.Name); var propertyIsReadOnly = properties.SelectAsArray(p => p.SetMethod == null); var propertyLocations = properties.SelectAsArray(p => p.Locations.FirstOrDefault()); visitor.WriteSymbolKeyArray(propertyTypes); visitor.WriteStringArray(propertyNames); visitor.WriteBooleanArray(propertyIsReadOnly); visitor.WriteLocationArray(propertyLocations); }
public static void Create(INamedTypeSymbol symbol, SymbolKeyWriter visitor) { Debug.Assert(symbol.IsAnonymousType); var properties = symbol.GetMembers().OfType<IPropertySymbol>().ToImmutableArray(); var propertyTypes = properties.SelectAsArray(p => p.Type); var propertyNames = properties.SelectAsArray(p => p.Name); var propertyIsReadOnly = properties.SelectAsArray(p => p.SetMethod == null); var propertyLocations = properties.SelectAsArray(p => p.Locations.FirstOrDefault()); visitor.WriteSymbolKeyArray(propertyTypes); visitor.WriteStringArray(propertyNames); visitor.WriteBooleanArray(propertyIsReadOnly); visitor.WriteLocationArray(propertyLocations); }
public static void Create(INamedTypeSymbol symbol, SymbolKeyWriter visitor) { Debug.Assert(symbol.IsTupleType); visitor.WriteSymbolKey(symbol.TupleUnderlyingType); visitor.WriteStringArray(symbol.TupleElementNames); var locations = ArrayBuilder <Location> .GetInstance(); for (var i = 0; i < symbol.TupleElementTypes.Length; i++) { locations.Add(symbol.GetMembers("Item" + (i + 1)).FirstOrDefault()?.Locations.FirstOrDefault()); } visitor.WriteLocationArray(locations.ToImmutableAndFree()); }
public static void Create(INamedTypeSymbol symbol, SymbolKeyWriter visitor) { Debug.Assert(symbol.IsTupleType); visitor.WriteSymbolKey(symbol.TupleUnderlyingType); var friendlyNames = ArrayBuilder<String>.GetInstance(); var locations = ArrayBuilder<Location>.GetInstance(); foreach (var element in symbol.TupleElements) { friendlyNames.Add(element.IsImplicitlyDeclared ? null : element.Name); locations.Add(element.Locations.FirstOrDefault()); } visitor.WriteStringArray(friendlyNames.ToImmutableAndFree()); visitor.WriteLocationArray(locations.ToImmutableAndFree()); }
public static void Create(INamedTypeSymbol symbol, SymbolKeyWriter visitor) { Debug.Assert(symbol.IsTupleType); visitor.WriteSymbolKey(symbol.TupleUnderlyingType); var friendlyNames = ArrayBuilder <String> .GetInstance(); var locations = ArrayBuilder <Location> .GetInstance(); foreach (var element in symbol.TupleElements) { friendlyNames.Add(element.IsImplicitlyDeclared ? null : element.Name); locations.Add(element.Locations.FirstOrDefault()); } visitor.WriteStringArray(friendlyNames.ToImmutableAndFree()); visitor.WriteLocationArray(locations.ToImmutableAndFree()); }
public static void Create(INamedTypeSymbol symbol, SymbolKeyWriter visitor) { Debug.Assert(symbol.IsTupleType); var friendlyNames = ArrayBuilder <string> .GetInstance(); var locations = ArrayBuilder <Location> .GetInstance(); var isError = symbol.TupleUnderlyingType.TypeKind == TypeKind.Error; visitor.WriteBoolean(isError); if (isError) { var elementTypes = ArrayBuilder <ISymbol> .GetInstance(); foreach (var element in symbol.TupleElements) { elementTypes.Add(element.Type); } visitor.WriteSymbolKeyArray(elementTypes.ToImmutableAndFree()); } else { visitor.WriteSymbolKey(symbol.TupleUnderlyingType); } foreach (var element in symbol.TupleElements) { friendlyNames.Add(element.IsImplicitlyDeclared ? null : element.Name); locations.Add(element.Locations.FirstOrDefault() ?? Location.None); } visitor.WriteStringArray(friendlyNames.ToImmutableAndFree()); visitor.WriteLocationArray(locations.ToImmutableAndFree()); }
public static void Create(INamedTypeSymbol symbol, SymbolKeyWriter visitor) { Debug.Assert(symbol.IsTupleType); visitor.WriteSymbolKey(symbol.TupleUnderlyingType); visitor.WriteStringArray(symbol.TupleElementNames); }
public static void Create(INamedTypeSymbol symbol, SymbolKeyWriter visitor) { Debug.Assert(symbol.IsTupleType); visitor.WriteSymbolKey(symbol.TupleUnderlyingType); visitor.WriteStringArray(symbol.TupleElementNames); }