예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NExtensionMethod"/> class.
        /// </summary>
        public NExtensionMethod(INTypeReference extendedType, NMethod extensionMethod)
        {
            ExtendedType = extendedType;

            Method                   = new NMethod();
            Method.Assembly          = extensionMethod.Assembly;
            Method.Description       = extensionMethod.Description;
            Method.DocNode           = extensionMethod.DocNode;
            Method.ElementType       = extensionMethod.ElementType;
            Method.FullName          = extensionMethod.FullName;
            Method.GenericArguments  = extensionMethod.GenericArguments;
            Method.GenericParameters = extensionMethod.GenericParameters;
            Method.HasOverrides      = extensionMethod.HasOverrides;
            Method.Id                = extensionMethod.Id;
            Method.Implements        = extensionMethod.Implements;
            Method.IsAbstract        = extensionMethod.IsAbstract;
            Method.IsObsolete        = extensionMethod.IsObsolete;
            Method.IsVirtual         = extensionMethod.IsVirtual;
            Method.IsObsolete        = extensionMethod.IsObsolete;
            Method.MsdnId            = extensionMethod.MsdnId;
            Method.Name              = extensionMethod.Name;
            Method.ObsoleteMessage   = extensionMethod.ObsoleteMessage;
            Method.PageId            = extensionMethod.PageId;
            Method.PageTitle         = extensionMethod.PageTitle;
            Method.Remarks           = extensionMethod.Remarks;
            Method.SeeAlsos          = extensionMethod.SeeAlsos;
            Method.TopicLink         = extensionMethod.TopicLink;
            Method.UnManagedApi      = extensionMethod.UnManagedApi;
            Method.UnManagedShortApi = extensionMethod.UnManagedShortApi;
            Method.Namespace         = extensionMethod.Namespace;
            Method.Visibility        = extensionMethod.Visibility;
            Method.ReturnDescription = extensionMethod.ReturnDescription;
            Method.ReturnType        = extensionMethod.ReturnType;
            Method.MemberType        = extensionMethod.MemberType;
            foreach (var group in extensionMethod.Groups)
            {
                Method.SetApiGroup(group, true);
            }

            // The extension method as member method is not static
            Method.IsStatic = false;


            Method.MemberType        = NMemberType.Extension;
            Method.IsExtensionMethod = true;
            Method.DeclaringType     = extendedType.ElementType;
            Method.ExtensionSource   = extensionMethod.DeclaringType;


            // Remove the "this parameter"
            Method.Parameters = new List <NParameter>(extensionMethod.Parameters);
            Method.Parameters.RemoveAt(0);

            // Rebuild the signature without the "this parameter"
            var signature = new StringBuilder();

            signature.Append(Method.Name);
            MonoCecilModelBuilder.BuildMethodSignatureParameters(Method, signature);
            Method.Signature = signature.ToString();
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NExtensionMethod"/> class.
        /// </summary>
        public NExtensionMethod(INTypeReference extendedType, NMethod extensionMethod)
        {
            ExtendedType = extendedType;

            Method = new NMethod();
            Method.Assembly = extensionMethod.Assembly;
            Method.Description = extensionMethod.Description;
            Method.DocNode = extensionMethod.DocNode;
            Method.ElementType = extensionMethod.ElementType;
            Method.FullName = extensionMethod.FullName;
            Method.GenericArguments = extensionMethod.GenericArguments;
            Method.GenericParameters = extensionMethod.GenericParameters;
            Method.HasOverrides = extensionMethod.HasOverrides;
            Method.Id = extensionMethod.Id;
            Method.Implements = extensionMethod.Implements;
            Method.IsAbstract = extensionMethod.IsAbstract;
            Method.IsObsolete = extensionMethod.IsObsolete;
            Method.IsVirtual = extensionMethod.IsVirtual;
            Method.IsObsolete = extensionMethod.IsObsolete;
            Method.MsdnId = extensionMethod.MsdnId;
            Method.Name = extensionMethod.Name;
            Method.ObsoleteMessage = extensionMethod.ObsoleteMessage;
            Method.PageId = extensionMethod.PageId;
            Method.PageTitle = extensionMethod.PageTitle;
            Method.Remarks = extensionMethod.Remarks;
            Method.SeeAlsos = extensionMethod.SeeAlsos;
            Method.TopicLink = extensionMethod.TopicLink;
            Method.UnManagedApi = extensionMethod.UnManagedApi;
            Method.UnManagedShortApi = extensionMethod.UnManagedShortApi;
            Method.Namespace = extensionMethod.Namespace;
            Method.Visibility = extensionMethod.Visibility;
            Method.ReturnDescription = extensionMethod.ReturnDescription;
            Method.ReturnType = extensionMethod.ReturnType;
            Method.MemberType = extensionMethod.MemberType;
            foreach (var group in extensionMethod.Groups)
                Method.SetApiGroup(group, true);

            // The extension method as member method is not static
            Method.IsStatic = false;


            Method.MemberType = NMemberType.Extension;
            Method.IsExtensionMethod = true;
            Method.DeclaringType = extendedType.ElementType;
            Method.ExtensionSource = extensionMethod.DeclaringType;

            
            // Remove the "this parameter"
            Method.Parameters = new List<NParameter>(extensionMethod.Parameters);
            Method.Parameters.RemoveAt(0);

            // Rebuild the signature without the "this parameter"
            var signature = new StringBuilder();
            signature.Append(Method.Name);
            MonoCecilModelBuilder.BuildMethodSignatureParameters(Method, signature);
            Method.Signature = signature.ToString();
        }