コード例 #1
0
        private void WriteMethodDefinitionSignature(IMethodDefinition method, string name)
        {
            bool isOperator = method.IsConversionOperator();

            if (!isOperator && !method.IsConstructor)
            {
                WriteAttributes(method.ReturnValueAttributes, true);
                // We are ignoring custom modifiers right now, we might need to add them later.
                WriteTypeName(method.Type, isDynamic: IsDynamic(method.ReturnValueAttributes));
            }

            WriteIdentifier(name);

            if (isOperator)
            {
                WriteSpace();
                WriteTypeName(method.Type);
            }

            Contract.Assert(!(method is IGenericMethodInstance), "Currently don't support generic method instances");
            if (method.IsGeneric)
            {
                WriteGenericParameters(method.GenericParameters);
            }

            WriteParameters(method.Parameters, extensionMethod: method.IsExtensionMethod(), acceptsExtraArguments: method.AcceptsExtraArguments);
            if (method.IsGeneric && !method.IsOverride() && !method.IsExplicitInterfaceMethod())
            {
                WriteGenericContraints(method.GenericParameters);
            }
        }
コード例 #2
0
        private void WriteMethodDefinitionSignature(IMethodDefinition method, string name)
        {
            bool isOperator = method.IsConversionOperator();

            if (!isOperator && !method.IsConstructor)
            {
                WriteAttributes(method.ReturnValueAttributes, true);
                // We are ignoring custom modifiers right now, we might need to add them later.
                WriteTypeName(method.Type, isDynamic: IsDynamic(method.ReturnValueAttributes));
            }

            WriteIdentifier(name);

            if (isOperator)
            {
                WriteSpace();
                WriteTypeName(method.Type);
            }

            Contract.Assert(!(method is IGenericMethodInstance), "Currently don't support generic method instances");
            if (method.IsGeneric)
                WriteGenericParameters(method.GenericParameters);

            WriteParameters(method.Parameters, extensionMethod: method.IsExtensionMethod(), acceptsExtraArguments: method.AcceptsExtraArguments);
            if (method.IsGeneric && !method.IsOverride() && !method.IsExplicitInterfaceMethod())
                WriteGenericContraints(method.GenericParameters);
        }
コード例 #3
0
        private void WriteMethodDefinitionSignature(IMethodDefinition method)
        {
            byte?nullableContextValue = method.Attributes.GetCustomAttributeArgumentValue <byte?>(CSharpCciExtensions.NullableContextAttributeFullName);
            bool isOperator           = method.IsConversionOperator();

            if (!isOperator && !method.IsConstructor && !method.IsStaticConstructor)
            {
                if (method.Attributes.HasIsReadOnlyAttribute() && (LangVersion >= LangVersion8_0))
                {
                    WriteKeyword("readonly");
                }

                if (method.ReturnValueIsByRef)
                {
                    WriteKeyword("ref");

                    if (method.ReturnValueAttributes.HasIsReadOnlyAttribute())
                    {
                        WriteKeyword("readonly");
                    }
                }

                // We are ignoring custom modifiers right now, we might need to add them later.
                WriteTypeName(method.Type, method.ContainingType, method.ReturnValueAttributes, nullableContextValue);
            }

            if (method.IsExplicitInterfaceMethod() && _forCompilationIncludeGlobalprefix)
            {
                Write("global::");
            }

            WriteMethodName(method);

            if (isOperator)
            {
                WriteSpace();

                WriteTypeName(method.Type, method.ContainingType, methodNullableContextValue: nullableContextValue);
            }

            Contract.Assert(!(method is IGenericMethodInstance), "Currently don't support generic method instances");
            if (method.IsGeneric)
            {
                WriteGenericParameters(method.GenericParameters);
            }

            WriteParameters(method.Parameters, method.ContainingType, nullableContextValue, extensionMethod: method.IsExtensionMethod(), acceptsExtraArguments: method.AcceptsExtraArguments);
            if (method.IsGeneric && !method.IsOverride() && !method.IsExplicitInterfaceMethod())
            {
                WriteGenericContraints(method.GenericParameters, nullableContextValue);
            }
        }