コード例 #1
0
ファイル: Utility.cs プロジェクト: NNNIC/haxe-test
        internal static IEnumerable <ITypeSymbol> AllTypes(ITypeSymbol type)
        {
            yield return(type);

            if (type is INamedTypeSymbol)
            {
                foreach (var ta in type.As <INamedTypeSymbol>().TypeArguments)
                {
                    foreach (var t in AllTypes(ta))
                    {
                        yield return(t);
                    }
                }
            }
            else if (type is IArrayTypeSymbol)
            {
                yield return(type.As <IArrayTypeSymbol>().ElementType);
            }
        }
コード例 #2
0
        public static bool IsCollectionTypeOf(this ITypeSymbol type, Predicate <ITypeSymbol> predicate)
        {
            var arrayType = type.As <IArrayTypeSymbol>();

            if (arrayType != null)
            {
                return(predicate(arrayType.ElementType));
            }

            var namedType = type.As <INamedTypeSymbol>();

            if (IsIEnumerableOf(namedType, predicate))
            {
                return(true);
            }

            if (type.AllInterfaces.Any(r => IsCollectionTypeOf(r, predicate)))
            {
                return(true);
            }

            return(false);
        }
コード例 #3
0
        private static ITypeSymbol TryFindIEnumerableType(ITypeSymbol type)
        {
            if (type.Name == "IEnumerable" && type.ContainingNamespace.FullName() == "System.Collections.Generic")
            {
                return(type.As <INamedTypeSymbol>().TypeArguments[0]);
            }

            foreach (var intface in type.Interfaces)
            {
                var recur = TryFindIEnumerableType(intface);
                if (recur != null)
                {
                    return(recur);
                }
            }

            return(null);
        }
コード例 #4
0
ファイル: TypeProcessor.cs プロジェクト: al-sabr/Cs2hx
        private static string ConvertTypeUncached(ITypeSymbol typeSymbol)
        {
            if (typeSymbol.IsAnonymousType)
            {
                return(WriteAnonymousObjectCreationExpression.TypeName(typeSymbol.As <INamedTypeSymbol>()));
            }

            var array = typeSymbol as IArrayTypeSymbol;

            if (array != null)
            {
                if (array.ElementType.ToString() == "byte")
                {
                    return("haxe.io.Bytes");                    //byte arrays become haxe.io.Bytes
                }
                else
                {
                    return("Array<" + (ConvertType(array.ElementType) ?? "Dynamic") + ">");
                }
            }

            var typeInfoStr = typeSymbol.ToString();

            var named = typeSymbol as INamedTypeSymbol;

            if (typeSymbol.TypeKind == TypeKind.TypeParameter)
            {
                return(typeSymbol.Name);
            }

            if (typeSymbol.TypeKind == TypeKind.Delegate)
            {
                var dlg = named.DelegateInvokeMethod.As <IMethodSymbol>();
                if (dlg.Parameters.Length == 0)
                {
                    return("(Void -> " + ConvertType(dlg.ReturnType) + ")");
                }
                else
                {
                    return("(" + string.Join("", dlg.Parameters.ToList().Select(o => ConvertType(o.Type) + " -> ")) + ConvertType(dlg.ReturnType) + ")");
                }
            }

            if (typeSymbol.TypeKind == TypeKind.Enum)
            {
                return("Int");                //enums are always ints
            }
            if (named != null && named.Name == "Nullable" && named.ContainingNamespace.ToString() == "System")
            {
                //Nullable types get replaced by our Nullable_ alternatives
                var nullableType = ConvertType(named.TypeArguments.Single());
                if (nullableType == "Int" || nullableType == "Bool" || nullableType == "Float")
                {
                    return("Nullable_" + nullableType);
                }
                else
                {
                    return("Nullable<" + nullableType + ">");
                }
            }

            var typeStr = GenericTypeName(typeSymbol);


            var trans = TypeTranslation.Get(typeStr);

            if (named != null && named.IsGenericType && !named.IsUnboundGenericType && TypeArguments(named).Any() && (trans == null || trans.SkipGenericTypes == false))
            {
                //Generic type
                var genericTypeRoot          = ConvertType(named.ConstructUnboundGenericType());
                var genericTypeArgs          = TypeArguments(named).ToList();
                var genericTypeArgsConverted = genericTypeArgs.Select(o => ConvertType(o) ?? "Dynamic").ToList();

                if (genericTypeRoot == "system.collections.generic.Dictionary" || genericTypeRoot == "system.collections.generic.HashSet")
                {
                    //Cs2hx does not support the GetHashCode() or Equals() functions, and therefore will only work correctly with basic types as the keys of dictionaries and hash sets.  We should throw on any improper usage since it may not run the same as the original C#
                    var hashArg = genericTypeArgsConverted[0];

                    if (genericTypeArgs[0].TypeKind != TypeKind.TypeParameter && hashArg != "Int" && hashArg != "String" && hashArg != "Dynamic") //TODO: Is Dynamic really ok in this list?  This will happen on a Dictionary<object, ...>, which could be a problem unless it was used carefully.
                    {
                        throw new Exception("Improper hash type: " + hashArg + " used on " + genericTypeRoot);                                    //TODO: How can we provide code location?
                    }
                }

                return(genericTypeRoot + "<" + string.Join(", ", genericTypeArgsConverted) + ">");
            }

            switch (typeStr)
            {
            case "System.Void":
                return("Void");

            case "System.Boolean":
                return("Bool");

            case "System.Object":
                return("Dynamic");

            case "System.Int64":
            case "System.UInt64":
            case "System.Single":
            case "System.Double":
                return("Float");

            case "System.String":
                return("String");

            case "System.Int32":
            case "System.UInt32":
            case "System.Byte":
            case "System.Int16":
            case "System.UInt16":
            case "System.Char":
                return("Int");


            case "System.Collections.Generic.List<>":
            case "System.Collections.Generic.IList<>":
            case "System.Collections.Generic.Queue<>":
            case "System.Collections.Generic.IEnumerable<>":
            case "System.Collections.Generic.Dictionary<,>.ValueCollection":
            case "System.Collections.Generic.Dictionary<,>.KeyCollection":
            case "System.Collections.Generic.ICollection<>":
            case "System.Linq.IOrderedEnumerable<>":
            case "System.Collections.IEnumerable":
            case "System.Collections.Specialized.NameObjectCollectionBase.KeysCollection":
                return("Array");

            case "System.Array":
                return(null);                        //in haxe, unlike C#, array must always have type arguments.  To work around this, just avoid printing the type anytime we see a bare Array type in C#. haxe will infer it.

            case "System.Collections.Generic.LinkedList<>":
                return("List");

            default:


                if (trans != null)
                {
                    return(trans.As <Translations.TypeTranslation>().Replace(named));
                }

                if (named != null)
                {
                    return(typeSymbol.ContainingNamespace.FullNameWithDot().ToLower() + WriteType.TypeName(named));
                }

                //This type does not get translated and gets used as-is
                return(typeSymbol.ContainingNamespace.FullNameWithDot().ToLower() + typeSymbol.Name);
            }
        }
コード例 #5
0
        private static string ConvertTypeUncached(ITypeSymbol typeSymbol, bool localize)
        {
            if (typeSymbol.IsAnonymousType)
            {
                return(WriteAnonymousObjectCreationExpression.TypeName(typeSymbol.As <INamedTypeSymbol>()));
            }

            var array = typeSymbol as IArrayTypeSymbol;

            var ptr = array != null && (array.ElementType.IsValueType == false);

            if (array != null)
            {
                var typeString = TryConvertType(array.ElementType, localize);
                if (localize)
                {
                    var name =
                        Context.Instance.UsingDeclarations.FirstOrDefault(
                            k => typeString.StartsWith(k.Name.ToFullString() + ".Namespace.", StringComparison.Ordinal));

                    if (name != null)
                    {
                        typeString = typeString.RemoveFromStartOfString(name.Name.ToFullString() + ".Namespace.");
                    }
                }
                //if (array.Rank == 1) // Jagged / Single
                return("Array_T!(" + typeString + ")");
//				else
//				{
//					return  "Array_T!(" + typeString + Enumerable.Range (0, array.Rank-1).Select (l => "[]").Aggregate ((a, b) => a + b).ToString () +")";
//
//				}
            }

            if (typeSymbol.TypeKind == TypeKind.PointerType)
            {
                var pointer = typeSymbol as IPointerTypeSymbol;
                return(ConvertType(pointer.PointedAtType) + "*");
            }

            var typeInfoStr = typeSymbol.ToString();

            var named = typeSymbol as INamedTypeSymbol;

            if (typeSymbol.TypeKind == TypeKind.TypeParameter)
            {
                return(typeSymbol.Name);
            }

//			if (typeSymbol.TypeKind == TypeKind.Delegate) {
//				var dlg = named.DelegateInvokeMethod.As<IMethodSymbol> ();
//				if (dlg.Parameters.Length == 0)
//					return "() => " + TryConvertType (dlg.ReturnType);
//				else
//					return "(" + string.Join (", ", dlg.Parameters.ToList ().Select (o => TryConvertType (o.Type))) + ") => " + TryConvertType (dlg.ReturnType);

//			}

            // if (typeSymbol.TypeKind == TypeKind.Enum)
            //   return "int"; //enums are always ints

            if (named.ContainingNamespace.ToString() == "System" && named.Name == "Exception")
            {
                return("System.Namespace.NException");
            }

            if (named != null && named.Name == "Nullable" && named.ContainingNamespace.ToString() == "System")
            {
                //Nullable types
                var convertedType = TryConvertType(named.TypeArguments.Single());

                switch (convertedType)
                {
                case "Int":
                    return("int");

                case "Boolean":
                    return("bool");

                case "Byte":
                    return("byte");

                case "Short":
                    return("short");

                case "Float":
                    return("float");

                case "Double":
                    return("double");

                case "Char":
                    return("char");

                case "Long":
                    return("long");

                default:
                    return(convertedType);
                }
            }

            var typeStr = GenericTypeName(typeSymbol);

            if (named != null && named.IsGenericType && !named.IsUnboundGenericType && TypeArguments(named).Any())
            {
                return(TryConvertType(named.ConstructUnboundGenericType()) + "!(" +
                       string.Join(", ", TypeArguments(named).Select(o => TryConvertType(o))) + ")");
            }

            switch (typeStr)
            {
            case "System.Namespace.Void":
                return("void");

            case "System.Namespace.Boolean":
                return("bool");

            case "System.Object":
            case "System.Namespace.Object":
                return("NObject");

            case "System.Namespace.UInt64":
                return("ulong");

            case "System.Namespace.Double":
                return("double");

            case "System.Namespace.Single":
                return("float");

            case "System.Namespace.String":
                return("String");

            case "System.Namespace.Int32":
                return("int");

            case "System.Namespace.UInt16":
                return("ushort");

            case "System.Namespace.Int64":
                return("long");

            case "System.Namespace.UInt32":
                return("long");    // Looks like d's uint32 is smaller than C#'s

            case "System.Namespace.Byte":
                return("byte");

            case "System.Namespace.Int16":
                return("short");

            case "System.Namespace.Char":
                return("char");

            case "System.Namespace.Array":
                return("Array_T");    //All template (generic) classes have atleast one "_T" appended

            default:

                if (named != null)
                {
                    return(typeSymbol.ContainingNamespace.FullNameWithDot() + WriteType.TypeName(named));
                }

                //This type does not get translated and gets used as-is
                return(typeSymbol.ContainingNamespace.FullNameWithDot() + typeSymbol.Name);
            }
        }
コード例 #6
0
        private static string ConvertTypeUncached(ITypeSymbol typeSymbol)
        {
            if (typeSymbol.IsAnonymousType)
            {
                return(WriteAnonymousObjectCreationExpression.TypeName(typeSymbol.As <INamedTypeSymbol>()));
            }

            var array = typeSymbol as IArrayTypeSymbol;

            if (array != null)
            {
                return("Array[" + TryConvertType(array.ElementType) + "]");
            }

            var typeInfoStr = typeSymbol.ToString();

            var named = typeSymbol as INamedTypeSymbol;

            if (typeSymbol.TypeKind == TypeKind.TypeParameter)
            {
                return(typeSymbol.Name);
            }

            if (typeSymbol.TypeKind == TypeKind.Delegate)
            {
                var dlg = named.DelegateInvokeMethod.As <IMethodSymbol>();
                if (dlg.Parameters.Length == 0)
                {
                    return("() => " + TryConvertType(dlg.ReturnType));
                }
                else
                {
                    return("(" + string.Join(", ", dlg.Parameters.ToList().Select(o => TryConvertType(o.Type))) + ") => " + TryConvertType(dlg.ReturnType));
                }
            }

            if (typeSymbol.TypeKind == TypeKind.Enum)
            {
                return("Int"); //enums are always ints
            }
            if (named != null && named.Name == "Nullable" && named.ContainingNamespace.ToString() == "System")
            {
                //Nullable types, if value types, get replaced with the java.lang alternatives.  If reference types, just use them as-is
                var convertedType = TryConvertType(named.TypeArguments.Single());

                switch (convertedType)
                {
                case "Int":
                    return("java.lang.Integer");

                case "Boolean":
                    return("java.lang.Boolean");

                case "Byte":
                    return("java.lang.Byte");

                case "Short":
                    return("java.lang.Short");

                case "Float":
                    return("java.lang.Float");

                case "Double":
                    return("java.lang.Double");

                case "Char":
                    return("java.lang.Char");

                case "Long":
                    return("java.lang.Long");

                default:
                    return(convertedType);
                }
            }

            var typeStr = GenericTypeName(typeSymbol);

            var trans = TypeTranslation.Get(typeStr, named);

            if (named.IsGenericType() && !named.IsUnboundGenericType && (trans == null || trans.SkipGenericTypes == false))
            {
                return(TryConvertType(named.ConstructUnboundGenericType()) + "[" + string.Join(", ", TypeArguments(named).Select(o => TryConvertType(o))) + "]");
            }


            switch (typeStr)
            {
            case "System.Void":
                return("Unit");

            case "System.Boolean":
                return("Boolean");

            case "System.Object":
                return("Any");

            case "System.UInt64":
            case "System.Double":
                return("Double");

            case "System.Single":
                return("Float");

            case "System.String":
                return("String");

            case "System.Int32":
            case "System.UInt16":
                return("Int");


            case "System.Int64":
            case "System.UInt32":
                return("Long");

            case "System.Byte":
                return("Byte");

            case "System.Int16":
                return("Short");

            case "System.Char":
                return("Char");

            case "System.Array":
                return(null);    //in scala, unlike C#, array must always have type arguments.  To work around this, just avoid printing the type anytime we see a bare Array type in C#. scala will infer it.

            default:
                if (trans != null)
                {
                    return(trans.As <TypeTranslation>().Replace(named));
                }

                if (named != null)
                {
                    return(typeSymbol.ContainingNamespace.FullNameWithDot() + WriteType.TypeName(named));
                }

                //This type does not get translated and gets used as-is
                return(typeSymbol.ContainingNamespace.FullNameWithDot() + typeSymbol.Name);
            }
        }
コード例 #7
0
        private static string ConvertTypeUncached(ITypeSymbol typeSymbol)
        {
            if (typeSymbol.IsAnonymousType)
            {
                return(WriteAnonymousObjectCreationExpression.TypeName(typeSymbol.As <INamedTypeSymbol>()));
            }

            var array = typeSymbol as IArrayTypeSymbol;

            if (array != null)
            {
                if (array.ElementType.ToString() == "byte")
                {
                    return("haxe.io.Bytes");                    //byte arrays become haxe.io.Bytes
                }
                else
                {
                    return("Array<" + (ConvertType(array.ElementType) ?? "Dynamic") + ">");
                }
            }

            var typeInfoStr = typeSymbol.ToString();

            var named = typeSymbol as INamedTypeSymbol;

            if (typeSymbol.TypeKind == TypeKind.TypeParameter)
            {
                return(typeSymbol.Name);
            }

            if (typeSymbol.TypeKind == TypeKind.Delegate)
            {
                var dlg = named.DelegateInvokeMethod.As <IMethodSymbol>();
                if (dlg.Parameters.Length == 0)
                {
                    return("(Void -> " + ConvertType(dlg.ReturnType) + ")");
                }
                else
                {
                    return("(" + string.Join("", dlg.Parameters.ToList().Select(o => ConvertType(o.Type) + " -> ")) + ConvertType(dlg.ReturnType) + ")");
                }
            }

            if (typeSymbol.TypeKind == TypeKind.Enum)
            {
                return("Int");                //enums are always ints
            }
            if (named != null && named.Name == "Nullable" && named.ContainingNamespace.ToString() == "System")
            {
                //Nullable types get replaced by our Nullable_ alternatives
                var nullableType = ConvertType(named.TypeArguments.Single());
                if (nullableType == "Int" || nullableType == "Bool" || nullableType == "Float")
                {
                    return("Nullable_" + nullableType);
                }
                else
                {
                    return("Nullable<" + nullableType + ">");
                }
            }

            var typeStr = GenericTypeName(typeSymbol);

            var trans = TypeTranslation.Get(typeStr);

            if (named != null && named.IsGenericType && !named.IsUnboundGenericType && TypeArguments(named).Any() && (trans == null || trans.SkipGenericTypes == false))
            {
                return(ConvertType(named.ConstructUnboundGenericType()) + "<" + string.Join(", ", TypeArguments(named).Select(o => ConvertType(o) ?? "Dynamic")) + ">");
            }


            switch (typeStr)
            {
            case "System.Void":
                return("Void");

            case "System.Boolean":
                return("Bool");

            case "System.Object":
                return("Dynamic");

            case "System.Int64":
            case "System.UInt64":
            case "System.Single":
            case "System.Double":
                return("Float");

            case "System.String":
                return("String");

            case "System.Int32":
            case "System.UInt32":
            case "System.Byte":
            case "System.Int16":
            case "System.UInt16":
            case "System.Char":
                return("Int");


            case "System.Collections.Generic.List<>":
            case "System.Collections.Generic.IList<>":
            case "System.Collections.Generic.Queue<>":
            case "System.Collections.Generic.IEnumerable<>":
            case "System.Collections.Generic.Dictionary<,>.ValueCollection":
            case "System.Collections.Generic.Dictionary<,>.KeyCollection":
            case "System.Collections.Generic.ICollection<>":
            case "System.Linq.IOrderedEnumerable<>":
            case "System.Collections.IEnumerable":
            case "System.Collections.Specialized.NameObjectCollectionBase.KeysCollection":
                return("Array");

            case "System.Array":
                return(null);                        //in haxe, unlike C#, array must always have type arguments.  To work around this, just avoid printing the type anytime we see a bare Array type in C#. haxe will infer it.

            case "System.Collections.Generic.LinkedList<>":
                return("List");

            default:


                if (trans != null)
                {
                    return(trans.As <Translations.TypeTranslation>().Replace(named));
                }

                if (named != null)
                {
                    return(typeSymbol.ContainingNamespace.FullNameWithDot().ToLower() + WriteType.TypeName(named));
                }

                //This type does not get translated and gets used as-is
                return(typeSymbol.ContainingNamespace.FullNameWithDot().ToLower() + typeSymbol.Name);
            }
        }
コード例 #8
0
        private static string ConvertTypeUncached(ITypeSymbol typeSymbol)
        {
            if (typeSymbol.IsAnonymousType)
                return WriteAnonymousObjectCreationExpression.TypeName(typeSymbol.As<INamedTypeSymbol>());

            var array = typeSymbol as IArrayTypeSymbol;

            if (array != null)
            {
                var typeString = TryConvertType(array.ElementType, false);
//                if (localize)
//                {
//                    var name =
//                        Context.Instance.UsingDeclarations.FirstOrDefault(
//                            k => typeString.StartsWith(k.Name.ToFullString() + ".Namespace.", StringComparison.Ordinal));
//
//                    if (name != null)
//                        typeString = typeString.RemoveFromStartOfString(name.Name.ToFullString() + ".Namespace.");
//                }
                return "Array_T!(" + typeString + ")";
            }

            if (typeSymbol.TypeKind == TypeKind.PointerType)
            {
                var pointer = typeSymbol as IPointerTypeSymbol;
                return ConvertType(pointer.PointedAtType) + "*";
            }

            var typeInfoStr = typeSymbol.ToString();

            var named = typeSymbol as INamedTypeSymbol;

            if (typeSymbol.TypeKind == TypeKind.TypeParameter)
                return  WriteIdentifierName.TransformIdentifier(typeSymbol.Name,typeSymbol);

           
            if (named != null && (named.ContainingNamespace.ToString() == "System" && named.Name == "Exception"))
                return "System.Namespace.NException";

            //TODO: Add explicit support for Nullable
            if (named != null && (named.Name == "Nullable" && named.ContainingNamespace.ToString() == "System"))
            {
                //Nullable types
                if (named.TypeArguments.Any())
                {
                    
                    string convertedType="";

                    if (named.TypeArguments.FirstOrDefault() is IErrorTypeSymbol)
                    {
                        //unbound generic 
                        convertedType = "__UNBOUND";
                    }
                    else
                    {
                        convertedType = TryConvertType(named.TypeArguments.FirstOrDefault(), false);
                    }

                   
                    return "Nullable__G!(" + convertedType + ")";
                }
            }

            var typeStr = GenericTypeName(typeSymbol);

            if (named != null && named.IsGenericType)
            {
                if(!named.IsUnboundGenericType && TypeArguments(named).Any())
                
                return GetFullGenericName(named);
                else
                {
                    return GetFullGenericName(named.OriginalDefinition);
                }
            }


            switch (typeStr)
            {
                case "System.Namespace.Void":
                    return "void";

                case "System.Namespace.Boolean":
                    return "bool";

                case "System.Object":
                case "System.Namespace.Object":
                    return "NObject";

                case "System.Namespace.UInt64":
                    return "ulong";

                case "System.Namespace.Double":
                    return "double";

                case "System.Namespace.Single":
                    return "float";

                case "System.Namespace.String":
                    return "String";

                case "System.Namespace.Int32":
                    return "int";

                case "System.Namespace.UInt16":
                    return "ushort";

                case "System.Namespace.Int64":
                    return "long";

                case "System.Namespace.UInt32":
                    return "uint"; // /TODO: Looks like d's uint32 is smaller than C#'s

                case "System.Namespace.Byte":
                    return "ubyte";

                case "System.Namespace.SByte":
                    return "byte";

                case "System.Namespace.Int16":
                    return "short";

                case "System.Namespace.Char":
                    return "wchar";

                case "System.Namespace.Array":
                    return "Array"; //All template (generic) classes have atleast one "_T" appended

                default:

                    if (named != null)
                        return typeSymbol.ContainingNamespace.FullNameWithDot(true,false) + WriteType.TypeName(named);

                    //This type does not get translated and gets used as-is
                    return typeSymbol.ContainingNamespace.FullNameWithDot(true,false) + WriteIdentifierName.TransformIdentifier(typeSymbol.Name);
            }
        }
コード例 #9
0
ファイル: TypeProcessor.cs プロジェクト: xdrie/SharpNative
        private static string ConvertTypeUncached(ITypeSymbol typeSymbol)
        {
            if (typeSymbol.IsAnonymousType)
            {
                return(WriteAnonymousObjectCreationExpression.TypeName(typeSymbol.As <INamedTypeSymbol>()));
            }

            var array = typeSymbol as IArrayTypeSymbol;

            if (array != null)
            {
                var typeString = TryConvertType(array.ElementType, false);
//                if (localize)
//                {
//                    var name =
//                        Context.Instance.UsingDeclarations.FirstOrDefault(
//                            k => typeString.StartsWith(k.Name.ToFullString() + ".Namespace.", StringComparison.Ordinal));
//
//                    if (name != null)
//                        typeString = typeString.RemoveFromStartOfString(name.Name.ToFullString() + ".Namespace.");
//                }
                return("Array_T!(" + typeString + ")");
            }

            if (typeSymbol.TypeKind == TypeKind.PointerType)
            {
                var pointer = typeSymbol as IPointerTypeSymbol;
                return(ConvertType(pointer.PointedAtType) + "*");
            }

            var typeInfoStr = typeSymbol.ToString();

            var named = typeSymbol as INamedTypeSymbol;

            if (typeSymbol.TypeKind == TypeKind.TypeParameter)
            {
                return(WriteIdentifierName.TransformIdentifier(typeSymbol.Name, typeSymbol));
            }


            if (named != null && (named.ContainingNamespace.ToString() == "System" && named.Name == "Exception"))
            {
                return("System.Namespace.NException");
            }

            //TODO: Add explicit support for Nullable
            if (named != null && (named.Name == "Nullable" && named.ContainingNamespace.ToString() == "System"))
            {
                //Nullable types
                if (named.TypeArguments.Any())
                {
                    string convertedType = "";

                    if (named.TypeArguments.FirstOrDefault() is IErrorTypeSymbol)
                    {
                        //unbound generic
                        convertedType = "__UNBOUND";
                    }
                    else
                    {
                        convertedType = TryConvertType(named.TypeArguments.FirstOrDefault(), false);
                    }


                    return("Nullable__G!(" + convertedType + ")");
                }
            }

            var typeStr = GenericTypeName(typeSymbol);

            if (named != null && named.IsGenericType)
            {
                if (!named.IsUnboundGenericType && TypeArguments(named).Any())
                {
                    return(GetFullGenericName(named));
                }
                else
                {
                    return(GetFullGenericName(named.OriginalDefinition));
                }
            }


            switch (typeStr)
            {
            case "System.Namespace.Void":
                return("void");

            case "System.Namespace.Boolean":
                return("bool");

            case "System.Object":
            case "System.Namespace.Object":
                return("NObject");

            case "System.Namespace.UInt64":
                return("ulong");

            case "System.Namespace.Double":
                return("double");

            case "System.Namespace.Single":
                return("float");

            case "System.Namespace.String":
                return("String");

            case "System.Namespace.Int32":
                return("int");

            case "System.Namespace.UInt16":
                return("ushort");

            case "System.Namespace.Int64":
                return("long");

            case "System.Namespace.UInt32":
                return("uint");    // /TODO: Looks like d's uint32 is smaller than C#'s

            case "System.Namespace.Byte":
                return("ubyte");

            case "System.Namespace.SByte":
                return("byte");

            case "System.Namespace.Int16":
                return("short");

            case "System.Namespace.Char":
                return("wchar");

            case "System.Namespace.Array":
                return("Array");    //All template (generic) classes have atleast one "_T" appended

            default:

                if (named != null)
                {
                    return(typeSymbol.ContainingNamespace.FullNameWithDot(true, false) + WriteType.TypeName(named));
                }

                //This type does not get translated and gets used as-is
                return(typeSymbol.ContainingNamespace.FullNameWithDot(true, false) + WriteIdentifierName.TransformIdentifier(typeSymbol.Name));
            }
        }