Esempio n. 1
0
            private static ImmutableArray <Location> ReadElementLocations(SymbolKeyReader reader)
            {
                // Compiler API requires that all the locations are non-null, or that there is a default
                // immutable array passed in.
                var elementLocations = reader.ReadLocationArray();

                if (elementLocations.All(loc => loc == null))
                {
                    elementLocations = default;
                }

                return(elementLocations);
            }
            public static SymbolKeyResolution Resolve(SymbolKeyReader reader)
            {
                var underlyingTypeResolution = reader.ReadSymbolKey();
                var elementNames = reader.ReadStringArray();
                var elementLocations = reader.ReadLocationArray();

                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)
            {
                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);
            }
Esempio n. 4
0
            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));
            }