Beispiel #1
0
        private static RQUnconstructedType BuildNamedType(INamedTypeSymbol type)
        {
            // Anything that is a valid RQUnconstructed types is ALWAYS safe for public APIs

            if (type == null)
            {
                return(null);
            }

            // Anonymous types are unsupported
            if (type.IsAnonymousType)
            {
                return(null);
            }

            // the following types are supported for BuildType() used in signatures, but are not supported
            // for UnconstructedTypes
            if (type != type.ConstructedFrom || type.SpecialType == SpecialType.System_Void)
            {
                return(null);
            }

            // make an RQUnconstructedType
            var namespaceNames = RQNodeBuilder.GetNameParts(@type.ContainingNamespace);
            var typeInfos      = new List <RQUnconstructedTypeInfo>();

            for (INamedTypeSymbol currentType = type; currentType != null; currentType = currentType.ContainingType)
            {
                typeInfos.Insert(0, new RQUnconstructedTypeInfo(currentType.Name, currentType.TypeParameters.Length));
            }

            return(new RQUnconstructedType(namespaceNames, typeInfos));
        }
Beispiel #2
0
        public static bool TryBuild(ISymbol symbol, out string rqname)
        {
            var node = RQNodeBuilder.Build(symbol);

            rqname = (node != null) ? ParenthesesTreeWriter.ToParenthesesFormat(node.ToSimpleTree()) : null;

            return(node != null);
        }
Beispiel #3
0
 private static RQNamespace BuildNamespace(INamespaceSymbol @namespace)
 {
     return(new RQNamespace(RQNodeBuilder.GetNameParts(@namespace)));
 }