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);
            }

            if (operatorInfo != null)
            {
                for (int i = 0; i < operatorInfo.Length - 1; i++)
                {
                    WriteOperatorInfoString(operatorInfo[i]);
                    WriteSpace();
                }
            }
            else
            {
                bool isSub = method.GetMethodSignature().ReturnType == method.AppDomain.System_Void;
                OutputWrite(isSub ? Keyword_Sub : Keyword_Function, BoxedTextColor.Keyword);
                WriteSpace();
            }

            if (DeclaringTypes)
            {
                FormatType(method.DeclaringType);
                WritePeriod();
            }
            if (method is DmdConstructorInfo)
            {
                OutputWrite(Keyword_New, BoxedTextColor.Keyword);
            }
            else
            {
                if (TypeFormatterUtils.TryGetMethodName(method.Name, out var containingMethodName, out var localFunctionName))
                {
                    var methodColor = TypeFormatterUtils.GetColor(method, canBeModule: true);
                    WriteIdentifier(containingMethodName, methodColor);
                    WritePeriod();
                    WriteIdentifier(localFunctionName, methodColor);
                }
Beispiel #2
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);
                }