// The containing symbol can be one of many things. // 1) Null when this is the global namespace for a compilation. // 2) The SymbolId for an assembly symbol if this is the global namespace for an // assembly. // 3) The SymbolId for a module symbol if this is the global namespace for a module. // 4) The SymbolId for the containing namespace symbol if this is not a global // namespace. public static void Create(INamespaceSymbol symbol, SymbolKeyWriter visitor) { visitor.WriteString(symbol.MetadataName); if (symbol.ContainingNamespace != null) { visitor.WriteBoolean(false); visitor.WriteSymbolKey(symbol.ContainingNamespace); } else { // A global namespace can either belong to a module or to a compilation. Debug.Assert(symbol.IsGlobalNamespace); switch (symbol.NamespaceKind) { case NamespaceKind.Module: visitor.WriteBoolean(false); visitor.WriteSymbolKey(symbol.ContainingModule); break; case NamespaceKind.Assembly: visitor.WriteBoolean(false); visitor.WriteSymbolKey(symbol.ContainingAssembly); break; case NamespaceKind.Compilation: visitor.WriteBoolean(true); visitor.WriteSymbolKey(null); break; default: throw new NotImplementedException(); } } }
// The containing symbol can be one of many things. // 1) Null when this is the global namespace for a compilation. // 2) The SymbolId for an assembly symbol if this is the global namespace for an // assembly. // 3) The SymbolId for a module symbol if this is the global namespace for a module. // 4) The SymbolId for the containing namespace symbol if this is not a global // namespace. public static void Create(INamespaceSymbol symbol, SymbolKeyWriter visitor) { visitor.WriteString(symbol.MetadataName); if (symbol.ContainingNamespace != null) { visitor.WriteBoolean(false); visitor.WriteSymbolKey(symbol.ContainingNamespace); } else { // A global namespace can either belong to a module or to a compilation. Debug.Assert(symbol.IsGlobalNamespace); switch (symbol.NamespaceKind) { case NamespaceKind.Module: visitor.WriteBoolean(false); visitor.WriteSymbolKey(symbol.ContainingModule); break; case NamespaceKind.Assembly: visitor.WriteBoolean(false); visitor.WriteSymbolKey(symbol.ContainingAssembly); break; case NamespaceKind.Compilation: visitor.WriteBoolean(true); visitor.WriteSymbolKey(null); break; default: throw new NotImplementedException(); } } }
public static void Create(ITypeParameterSymbol symbol, SymbolKeyWriter visitor) { if (symbol.TypeParameterKind == TypeParameterKind.Cref) { visitor.WriteBoolean(true); visitor.WriteLocation(symbol.Locations[0]); } else { visitor.WriteBoolean(false); visitor.WriteString(symbol.MetadataName); visitor.WriteSymbolKey(symbol.ContainingSymbol); } }
public static void Create(IMethodSymbol symbol, SymbolKeyWriter visitor) { Debug.Assert(symbol.Equals(symbol.ConstructedFrom)); visitor.WriteString(symbol.MetadataName); visitor.WriteSymbolKey(symbol.ContainingSymbol); visitor.WriteInteger(symbol.Arity); visitor.WriteBoolean(symbol.PartialDefinitionPart != null); visitor.WriteRefKindArray(symbol.Parameters); // Mark that we're writing out the signature of a method. This way if we hit a // method type parameter in our parameter-list or return type, we won't recurse // into it, but will instead only write out the type parameter ordinal. This // happens with cases like Foo<T>(T t); visitor.PushMethod(symbol); visitor.WriteParameterTypesArray(symbol.OriginalDefinition.Parameters); if (symbol.MethodKind == MethodKind.Conversion) { visitor.WriteSymbolKey(symbol.ReturnType); } else { visitor.WriteSymbolKey(null); } // Done writing the signature of this method. Remove it from the set of methods // we're writing signatures for. visitor.PopMethod(symbol); }
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; } var isConstructed = !symbol.Equals(symbol.ConstructedFrom); visitor.WriteInteger(symbol.Arity); visitor.WriteBoolean(isConstructed); if (isConstructed) { visitor.WriteSymbolKeyArray(symbol.TypeArguments); } else { visitor.WriteSymbolKeyArray(ImmutableArray <ITypeSymbol> .Empty); } }
public static void Create(IMethodSymbol symbol, SymbolKeyWriter visitor) { Debug.Assert(symbol.Equals(symbol.ConstructedFrom)); visitor.WriteString(symbol.MetadataName); visitor.WriteSymbolKey(symbol.ContainingSymbol); visitor.WriteInteger(symbol.Arity); visitor.WriteBoolean(symbol.PartialDefinitionPart != null); visitor.WriteRefKindArray(symbol.Parameters); // Mark that we're writing out the signature of a method. This way if we hit a // method type parameter in our parameter-list or return type, we won't recurse // into it, but will instead only write out the type parameter ordinal. This // happens with cases like Foo<T>(T t); Debug.Assert(!visitor.WritingSignature); visitor.WritingSignature = true; visitor.WriteParameterTypesArray(symbol.OriginalDefinition.Parameters); if (symbol.MethodKind == MethodKind.Conversion) { visitor.WriteSymbolKey(symbol.ReturnType); } else { visitor.WriteSymbolKey(null); } // Done writing the signature. Go back to normal mode. Debug.Assert(visitor.WritingSignature); visitor.WritingSignature = false; }
public sealed override void Create(IPropertySymbol symbol, SymbolKeyWriter visitor) { visitor.WriteString(symbol.MetadataName); visitor.WriteSymbolKey(symbol.ContainingSymbol); visitor.WriteBoolean(symbol.IsIndexer); visitor.WriteRefKindArray(symbol.Parameters); visitor.WriteParameterTypesArray(symbol.OriginalDefinition.Parameters); }
public static void Create(IPropertySymbol symbol, SymbolKeyWriter visitor) { visitor.WriteString(symbol.MetadataName); visitor.WriteSymbolKey(symbol.ContainingSymbol); visitor.WriteBoolean(symbol.IsIndexer); visitor.WriteRefKindArray(symbol.Parameters); visitor.WriteParameterTypesArray(symbol.OriginalDefinition.Parameters); }
public static void Create(ISymbol symbol, SymbolKeyWriter visitor) { Debug.Assert(symbol.IsAnonymousDelegateType() || symbol.IsAnonymousFunction()); // Write out if this was an anonymous delegate or anonymous function. // In both cases they'll have the same location (the location of // the lambda that forced them into existence). When we resolve the // symbol later, if it's an anonymous delegate, we'll first resolve to // the anonymous-function, then use that anonymous-functoin to get at // the synthesized anonymous delegate. visitor.WriteBoolean(symbol.IsAnonymousDelegateType()); visitor.WriteLocation(symbol.Locations.First()); }
public static void Create(ISymbol symbol, SymbolKeyWriter visitor) { Debug.Assert(symbol.IsAnonymousDelegateType() || symbol.IsAnonymousFunction()); // Write out if this was an anonymous delegate or anonymous function. // In both cases they'll have the same location (the location of // the lambda that forced them into existence). When we resolve the // symbol later, if it's an anonymous delegate, we'll first resolve to // the anonymous-function, then use that anonymous-functoin to get at // the synthesized anonymous delegate. visitor.WriteBoolean(symbol.IsAnonymousDelegateType()); visitor.WriteLocation(symbol.Locations.FirstOrDefault()); }
public static void Create(INamedTypeSymbol symbol, SymbolKeyWriter visitor) { visitor.WriteString(symbol.MetadataName); visitor.WriteSymbolKey(symbol.ContainingSymbol); visitor.WriteInteger(symbol.Arity); visitor.WriteBoolean(symbol.IsUnboundGenericType); if (!symbol.Equals(symbol.ConstructedFrom) && !symbol.IsUnboundGenericType) { visitor.WriteSymbolKeyArray(symbol.TypeArguments); } else { visitor.WriteSymbolKeyArray(ImmutableArray <ITypeSymbol> .Empty); } }
public static void Create(INamedTypeSymbol symbol, SymbolKeyWriter visitor) { visitor.WriteString(symbol.MetadataName); visitor.WriteSymbolKey(symbol.ContainingSymbol); visitor.WriteInteger(symbol.Arity); visitor.WriteInteger((int)symbol.TypeKind); visitor.WriteBoolean(symbol.IsUnboundGenericType); if (!symbol.Equals(symbol.ConstructedFrom) && !symbol.IsUnboundGenericType) { visitor.WriteSymbolKeyArray(symbol.TypeArguments); } else { visitor.WriteSymbolKeyArray(default(ImmutableArray<ITypeSymbol>)); } }
public sealed override void Create(INamedTypeSymbol symbol, SymbolKeyWriter visitor) { visitor.WriteSymbolKey(symbol.ContainingSymbol); visitor.WriteString(symbol.Name); visitor.WriteInteger(symbol.Arity); visitor.WriteString(symbol.IsFileLocal ? symbol.DeclaringSyntaxReferences[0].SyntaxTree.FilePath : null); visitor.WriteBoolean(symbol.IsUnboundGenericType); if (!symbol.Equals(symbol.ConstructedFrom) && !symbol.IsUnboundGenericType) { visitor.WriteSymbolKeyArray(symbol.TypeArguments); } else { visitor.WriteSymbolKeyArray(ImmutableArray <ITypeSymbol> .Empty); } }
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()); } visitor.WriteStringArray(friendlyNames.ToImmutableAndFree()); visitor.WriteLocationArray(locations.ToImmutableAndFree()); }
public sealed override void Create(INamedTypeSymbol symbol, SymbolKeyWriter visitor) { Debug.Assert(symbol.IsTupleType); var isError = symbol.TupleUnderlyingType !.TypeKind == TypeKind.Error; using var _1 = ArrayBuilder <string?> .GetInstance(out var friendlyNames); using var _2 = ArrayBuilder <Location> .GetInstance(out var locations); foreach (var element in symbol.TupleElements) { friendlyNames.Add(element.IsImplicitlyDeclared ? null : element.Name); locations.Add(element.Locations.FirstOrDefault() ?? Location.None); } visitor.WriteBoolean(isError); visitor.WriteStringArray(friendlyNames.ToImmutable()); visitor.WriteLocationArray(locations.ToImmutable()); if (isError) { using var _3 = ArrayBuilder <ISymbol> .GetInstance(out var elementTypes); foreach (var element in symbol.TupleElements) { elementTypes.Add(element.Type); } visitor.WriteSymbolKeyArray(elementTypes.ToImmutable()); } else { visitor.WriteSymbolKey(symbol.TupleUnderlyingType); } }