当前位置: 首页>>代码示例>>C#>>正文


C# TypeSymbol.GetFullName方法代码示例

本文整理汇总了C#中TypeSymbol.GetFullName方法的典型用法代码示例。如果您正苦于以下问题:C# TypeSymbol.GetFullName方法的具体用法?C# TypeSymbol.GetFullName怎么用?C# TypeSymbol.GetFullName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TypeSymbol的用法示例。


在下文中一共展示了TypeSymbol.GetFullName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetErrorReportingName

        public static string GetErrorReportingName(TypeSymbol type, RefKind refKind = RefKind.None)
        {
            string prefix = "";
            switch (refKind)
            {
                case RefKind.Ref: prefix = "ref "; break;
                case RefKind.Out: prefix = "out "; break;
            }

            switch (type.GetSpecialTypeSafe())
            {
                case SpecialType.System_Void: 
                case SpecialType.System_SByte:
                case SpecialType.System_Int16:
                case SpecialType.System_Int32:
                case SpecialType.System_Int64:
                case SpecialType.System_Byte: 
                case SpecialType.System_UInt16:
                case SpecialType.System_UInt32:
                case SpecialType.System_UInt64:
                case SpecialType.System_Single:
                case SpecialType.System_Double:
                case SpecialType.System_Decimal:
                case SpecialType.System_Char:
                case SpecialType.System_Boolean:
                case SpecialType.System_String:
                case SpecialType.System_Object:
                    return prefix + SemanticFacts.GetLanguageName(type.SpecialType);

                case SpecialType.None:
                    if (type != null && type.IsNullableType() && !ReferenceEquals(type, type.OriginalDefinition))
                    {
                        TypeSymbol underlyingType = type.GetNullableUnderlyingType();

                        switch (underlyingType.GetSpecialTypeSafe())
                        {
                            case SpecialType.System_Boolean:
                            case SpecialType.System_SByte:
                            case SpecialType.System_Int16:
                            case SpecialType.System_Int32:
                            case SpecialType.System_Int64:
                            case SpecialType.System_Byte:
                            case SpecialType.System_UInt16:
                            case SpecialType.System_UInt32:
                            case SpecialType.System_UInt64:
                            case SpecialType.System_Single:
                            case SpecialType.System_Double:
                            case SpecialType.System_Decimal:
                            case SpecialType.System_Char:
                                return prefix + SemanticFacts.GetLanguageName(underlyingType.SpecialType) + "?";
                        }

                        return prefix + GetErrorReportingName(underlyingType) + "?";
                    }

                    break;
            }

            var dynamicType = type as DynamicTypeSymbol;
            if (dynamicType != null)
            {
                return prefix + "dynamic";
            }

            var arrayType = type as ArrayTypeSymbol;
            if (arrayType != null)
            {
                string suffix = "";
                while (true)
                {
                    var elementType = arrayType.ElementType;
                    suffix += GetSuffix(arrayType.Rank);
                    arrayType = elementType as ArrayTypeSymbol;
                    if (arrayType == null)
                    {
                        return prefix + GetErrorReportingName(elementType) + suffix;
                    }
                }
            }

            var pointerType = type as PointerTypeSymbol;
            if (pointerType != null)
            {
                return prefix + GetErrorReportingName(pointerType.BaseType) + "*";
            }

            var namedType = type as NamedTypeSymbol;
            if (namedType != null)
            {
                string result = "";
                if (namedType.ContainingType != null)
                {
                    result = GetErrorReportingName(namedType.ContainingType) + ".";
                }
                else if (namedType.ContainingNamespace != null && !namedType.ContainingNamespace.IsGlobalNamespace)
                {
                    result = namedType.ContainingNamespace.GetFullName() + ".";
                }
                result += type.Name;
                if (namedType.TypeArguments.Count != 0)
//.........这里部分代码省略.........
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:101,代码来源:ErrorFormatting.cs


注:本文中的TypeSymbol.GetFullName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。