コード例 #1
0
        public override bool IsSupportedMethod(MethodDefinition mdef)
        {
            if (DocUtils.IsExtensionMethod(mdef)
                //no support of 'params';
                //can be substituted with 'Variadic functions' hovewer it's not full equivalent(not type safe + specific mechanism for reading)
                || mdef.Parameters.Any(IsParamsParameter)
                )
            {
                return(false);
            }

            return
                (IsSupported(mdef.ReturnType) &&
                 mdef.Parameters.All(i => IsSupported(i.ParameterType)));
        }
コード例 #2
0
        private StringBuilder AppendParameters(StringBuilder buf, MethodDefinition method, IList <ParameterDefinition> parameters, char begin, char end)
        {
            buf.Append(begin);

            if (parameters.Count > 0)
            {
                if (DocUtils.IsExtensionMethod(method))
                {
                    buf.Append("this ");
                }
                AppendParameter(buf, parameters[0]);
                for (int i = 1; i < parameters.Count; ++i)
                {
                    buf.Append(", ");
                    AppendParameter(buf, parameters[i]);
                }
            }

            return(buf.Append(end));
        }
コード例 #3
0
        protected override string GetMethodDeclaration(MethodDefinition method)
        {
            if (method.HasCustomAttributes && method.CustomAttributes.Any(
                    ca => ca.GetDeclaringType() == "System.Diagnostics.Contracts.ContractInvariantMethodAttribute"))
            {
                return(null);
            }

            // Special signature for destructors.
            if (method.Name == "Finalize" && method.Parameters.Count == 0)
            {
                return(GetFinalizerName(method));
            }

            StringBuilder buf = new StringBuilder();

            AppendVisibility(buf, method);
            AppendGenericMethod(buf, method);
            AppendGenericMethodConstraints(buf, method);

            if (DocUtils.IsExtensionMethod(method))
            {
                //no notion of Extension method; needs to mark with attribute and call as standard static method
                buf.Append("[System::Runtime::CompilerServices::Extension]").Append(GetLineEnding());
            }

            AppendModifiers(buf, method);

            if (buf.Length != 0)
            {
                buf.Append(" ");
            }

            buf.Append(GetTypeNameWithOptions(method.ReturnType, AppendHatOnReturn)).Append(" ");

            AppendMethodName(buf, method);
            AppendParameters(buf, method, method.Parameters);
            AppendExplisitImplementationMethod(buf, method);

            return(buf.Append(";").ToString());
        }