Example #1
0
            protected sealed override SymbolKeyResolution Resolve(
                SymbolKeyReader reader, IAliasSymbol?contextualSymbol, out string?failureReason)
            {
                var name             = reader.ReadRequiredString();
                var targetResolution = reader.ReadSymbolKey(contextualSymbol?.Target, out var targetFailureReason);
                var filePath         = reader.ReadRequiredString();

                if (targetFailureReason != null)
                {
                    failureReason = $"({nameof(AliasSymbolKey)} {nameof(targetResolution)} failed -> {targetFailureReason})";
                    return(default);
            protected sealed override SymbolKeyResolution Resolve(
                SymbolKeyReader reader, IParameterSymbol?contextualSymbol, out string?failureReason)
            {
                var metadataName = reader.ReadRequiredString();

                // Parameters are owned by members, and members are never resolved in a way where we have contextual
                // types to guide how the outer parts of the member may resolve.  We can use contextual typing for the
                // *signature* portion of the member though.
                var containingSymbolResolution = reader.ReadSymbolKey(
                    contextualSymbol?.ContainingSymbol, out var containingSymbolFailureReason);

                if (containingSymbolFailureReason != null)
                {
                    failureReason = $"({nameof(ParameterSymbolKey)} {nameof(containingSymbolResolution)} failed -> {containingSymbolFailureReason})";
                    return(default);
            public static SymbolKeyResolution Resolve(SymbolKeyReader reader, out string?failureReason)
            {
                var cancellationToken = reader.CancellationToken;

                var name = reader.ReadRequiredString();
                var kind = (SymbolKind)reader.ReadInteger();

#pragma warning disable IDE0007 // Use implicit type
                PooledArrayBuilder <Location> locations = reader.ReadLocationArray(out var locationsFailureReason) !;
#pragma warning restore IDE0007 // Use implicit type
                var ordinal = reader.ReadInteger();

                if (locationsFailureReason != null)
                {
                    failureReason = $"({nameof(BodyLevelSymbolKey)} {nameof(locations)} failed -> {locationsFailureReason})";
                    return(default);
Example #4
0
            protected sealed override SymbolKeyResolution Resolve(
                SymbolKeyReader reader, INamedTypeSymbol?contextualType, out string?failureReason)
            {
                var name = reader.ReadRequiredString();
                var containingSymbolResolution = ResolveContainer(reader, contextualType, out var containingSymbolFailureReason);
                var arity         = reader.ReadInteger();
                var isConstructed = reader.ReadBoolean();

                using var typeArguments = reader.ReadSymbolKeyArray <INamedTypeSymbol, ITypeSymbol>(
                          contextualType,
                          getContextualSymbol: static (contextualType, i) => SafeGet(contextualType.TypeArguments, i),
                          out var typeArgumentsFailureReason);

                if (containingSymbolFailureReason != null)
                {
                    failureReason = $"({nameof(ErrorTypeSymbolKey)} {nameof(containingSymbolResolution)} failed -> {containingSymbolFailureReason})";
                    return(default);
            protected sealed override SymbolKeyResolution Resolve(
                SymbolKeyReader reader, INamedTypeSymbol?contextualSymbol, out string?failureReason)
            {
                var containingSymbolResolution = reader.ReadSymbolKey(contextualSymbol?.ContainingSymbol, out var containingSymbolFailureReason);
                var name                 = reader.ReadRequiredString();
                var arity                = reader.ReadInteger();
                var filePath             = reader.ReadString();
                var isUnboundGenericType = reader.ReadBoolean();

                using var typeArguments = reader.ReadSymbolKeyArray <INamedTypeSymbol, ITypeSymbol>(
                          contextualSymbol,
                          getContextualSymbol: static (contextualType, i) => SafeGet(contextualType.TypeArguments, i),
                          out var typeArgumentsFailureReason);

                if (typeArgumentsFailureReason != null)
                {
                    Contract.ThrowIfFalse(typeArguments.IsDefault);

                    failureReason = $"({nameof(NamedTypeSymbolKey)} {nameof(typeArguments)} failed -> {typeArgumentsFailureReason})";
                    return(default);
            protected sealed override SymbolKeyResolution Resolve(
                SymbolKeyReader reader, INamespaceSymbol?contextualSymbol, out string?failureReason)
            {
                var metadataName  = reader.ReadRequiredString();
                var containerKind = reader.ReadInteger();

                var containingContextualSymbol = containerKind switch
                {
                    0 => contextualSymbol?.ContainingNamespace,
                    1 => contextualSymbol?.ContainingModule,
                    2 => contextualSymbol?.ContainingAssembly,
                    3 => (ISymbol?)null,
                    _ => throw ExceptionUtilities.UnexpectedValue(containerKind),
                };

                // Namespaces are never parented by types, so there can be no contextual type to resolve our container.
                var containingSymbolResolution = reader.ReadSymbolKey(
                    containingContextualSymbol, out var containingSymbolFailureReason);

                if (containingSymbolFailureReason != null)
                {
                    failureReason = $"({nameof(EventSymbolKey)} {nameof(containingSymbolResolution)} failed -> {containingSymbolFailureReason})";
                    return(default);