예제 #1
0
        void Format(DmdMethodBase method)
        {
            if (StateMachineUtils.TryGetKickoffMethod(method, out var kickoffMethod))
            {
                method = kickoffMethod;
            }

            var sig = method.GetMethodSignature();

            string[] operatorInfo;
            if (method is DmdConstructorInfo)
            {
                operatorInfo = null;
            }
            else
            {
                operatorInfo = Operators.TryGetOperatorInfo(method.Name);
            }
            bool isExplicitOrImplicit = operatorInfo != null && (operatorInfo[0] == "explicit" || operatorInfo[0] == "implicit");

            if (!isExplicitOrImplicit)
            {
                if (ReturnTypes && !(method is DmdConstructorInfo))
                {
                    FormatReturnType(sig.ReturnType, TypeFormatterUtils.IsReadOnlyMethod(method));
                    WriteSpace();
                }
            }

            if (DeclaringTypes)
            {
                FormatType(method.DeclaringType);
                WritePeriod();
            }
            if (method is DmdConstructorInfo)
            {
                WriteIdentifier(TypeFormatterUtils.RemoveGenericTick(method.DeclaringType.MetadataName), TypeFormatterUtils.GetColor(method, canBeModule: false));
            }
            else
            {
                if (TypeFormatterUtils.TryGetMethodName(method.Name, out var containingMethodName, out var localFunctionName))
                {
                    var methodColor = TypeFormatterUtils.GetColor(method, canBeModule: false);
                    WriteIdentifier(containingMethodName, methodColor);
                    WritePeriod();
                    WriteIdentifier(localFunctionName, methodColor);
                }
예제 #2
0
        void WriteTypeName(DmdType type, KeywordType keywordType)
        {
            switch (keywordType)
            {
            case KeywordType.Boolean:       OutputWrite("Boolean", BoxedTextColor.Keyword); return;

            case KeywordType.Byte:          OutputWrite("Byte", BoxedTextColor.Keyword); return;

            case KeywordType.Char:          OutputWrite("Char", BoxedTextColor.Keyword); return;

            case KeywordType.Date:          OutputWrite("Date", BoxedTextColor.Keyword); return;

            case KeywordType.Decimal:       OutputWrite("Decimal", BoxedTextColor.Keyword); return;

            case KeywordType.Double:        OutputWrite("Double", BoxedTextColor.Keyword); return;

            case KeywordType.Integer:       OutputWrite("Integer", BoxedTextColor.Keyword); return;

            case KeywordType.Long:          OutputWrite("Long", BoxedTextColor.Keyword); return;

            case KeywordType.Object:        OutputWrite("Object", BoxedTextColor.Keyword); return;

            case KeywordType.SByte:         OutputWrite("SByte", BoxedTextColor.Keyword); return;

            case KeywordType.Short:         OutputWrite("Short", BoxedTextColor.Keyword); return;

            case KeywordType.Single:        OutputWrite("Single", BoxedTextColor.Keyword); return;

            case KeywordType.String:        OutputWrite("String", BoxedTextColor.Keyword); return;

            case KeywordType.UInteger:      OutputWrite("UInteger", BoxedTextColor.Keyword); return;

            case KeywordType.ULong:         OutputWrite("ULong", BoxedTextColor.Keyword); return;

            case KeywordType.UShort:        OutputWrite("UShort", BoxedTextColor.Keyword); return;

            case KeywordType.NoKeyword:
                break;

            default:
                throw new InvalidOperationException();
            }

            WriteIdentifier(TypeFormatterUtils.RemoveGenericTick(type.MetadataName), TypeFormatterUtils.GetTypeColor(type, canBeModule: true));
            WriteTokenComment(type.MetadataToken);
        }
예제 #3
0
        void WriteTypeName(DmdType type, KeywordType keywordType)
        {
            switch (keywordType)
            {
            case KeywordType.Void:          OutputWrite("void", BoxedTextColor.Keyword); return;

            case KeywordType.Boolean:       OutputWrite("bool", BoxedTextColor.Keyword); return;

            case KeywordType.Char:          OutputWrite("char", BoxedTextColor.Keyword); return;

            case KeywordType.SByte:         OutputWrite("sbyte", BoxedTextColor.Keyword); return;

            case KeywordType.Byte:          OutputWrite("byte", BoxedTextColor.Keyword); return;

            case KeywordType.Int16:         OutputWrite("short", BoxedTextColor.Keyword); return;

            case KeywordType.UInt16:        OutputWrite("ushort", BoxedTextColor.Keyword); return;

            case KeywordType.Int32:         OutputWrite("int", BoxedTextColor.Keyword); return;

            case KeywordType.UInt32:        OutputWrite("uint", BoxedTextColor.Keyword); return;

            case KeywordType.Int64:         OutputWrite("long", BoxedTextColor.Keyword); return;

            case KeywordType.UInt64:        OutputWrite("ulong", BoxedTextColor.Keyword); return;

            case KeywordType.Single:        OutputWrite("float", BoxedTextColor.Keyword); return;

            case KeywordType.Double:        OutputWrite("double", BoxedTextColor.Keyword); return;

            case KeywordType.Object:        OutputWrite("object", BoxedTextColor.Keyword); return;

            case KeywordType.Decimal:       OutputWrite("decimal", BoxedTextColor.Keyword); return;

            case KeywordType.String:        OutputWrite("string", BoxedTextColor.Keyword); return;

            case KeywordType.NoKeyword:
                break;

            default:
                throw new InvalidOperationException();
            }

            WriteIdentifier(TypeFormatterUtils.RemoveGenericTick(type.MetadataName), TypeFormatterUtils.GetColor(type, canBeModule: false));
            new CSharpPrimitiveValueFormatter(output, options.ToValueFormatterOptions(), cultureInfo).WriteTokenComment(type.MetadataToken);
        }