Exemplo n.º 1
0
        private static string Format(PropertyReference property)
        {
            var sb = new StringBuilder();

            sb.Append(CecilFormat.GetTypeName(property.DeclaringType));
            sb.Append('.');
            sb.Append(property.Name);
            return(sb.ToString());
        }
Exemplo n.º 2
0
        private static string Format(EventReference @event)
        {
            var sb = new StringBuilder();

            sb.Append(CecilFormat.GetTypeName(@event.DeclaringType));
            sb.Append('.');
            sb.Append(@event.Name);
            return(sb.ToString());
        }
Exemplo n.º 3
0
        private static string Format(FieldReference field)
        {
            var sb = new StringBuilder();

            sb.Append(CecilFormat.GetTypeName(field.DeclaringType));
            sb.Append('.');
            sb.Append(field.Name);
            return(sb.ToString());
        }
Exemplo n.º 4
0
        private static string Format(MethodReference method, bool includeGenericArguments)
        {
            var sb = new StringBuilder();

            sb.Append(CecilFormat.GetTypeName(method.DeclaringType, true, includeGenericArguments));
            sb.Append('.');
            sb.Append(method.Name);
            sb.Append(Descriptor.Format(method.GenericParameters));
            sb.Append('(');
            sb.Append(string.Join(", ", method.Parameters.Select(x => Descriptor.Format(x, includeGenericArguments))));
            sb.Append(')');
            return(sb.ToString());
        }
Exemplo n.º 5
0
        /// <summary>
        /// Generate XML documentation
        /// </summary>
        internal void Generate(List <FrameworkDocumentationSet> frameworks, string outputFolder)
        {
            var root = new XElement("api");
            var doc  = new XDocument(root);

            foreach (var ns in Namespaces)
            {
                // Add namespace element
                root.Add(ns.Generate(frameworks));

                // Add type elements
                root.Add(ns.Types.OrderBy(x => CecilFormat.GetTypeName(x.Type)).Select(x => x.Generate(frameworks)));
            }

            // Save root
            doc.Save(Path.Combine(outputFolder, "api.xml"));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Check the given type reference.
        /// </summary>
        /// <returns>True on success, false otherwise</returns>
        private bool Check(TypeReference type, string context)
        {
            bool error;

            try
            {
                if (type.IsGenericInstance)
                {
                    return(Check((GenericInstanceType)type, context));
                }
                if (type.IsGenericParameter)
                {
                    return(Check((GenericParameter)type, context));
                }
                if (type.IsArray)
                {
                    return(Check((ArrayType)type, context));
                }
                if (type.IsByReference)
                {
                    return(Check((ByReferenceType)type, context));
                }
                if (type.IsFunctionPointer)
                {
                    Error(MessageTypes.UnsupportedFeature, type.FullName, type.Scope, "Function pointer types are not supported (in {0})", context);
                    return(false);
                }
                if (type.IsPinned)
                {
                    Error(MessageTypes.UnsupportedFeature, type.FullName, type.Scope, "Pinned are not supported ({0})", context);
                    return(false);
                }
                if (type.IsOptionalModifier)
                {
                    Error(MessageTypes.UnsupportedFeature, type.FullName, type.Scope, "Optional modifier types are not supported (in {0})", context);
                    return(false);
                }
                if (type.IsRequiredModifier)
                {
                    Error(MessageTypes.UnsupportedFeature, type.FullName, type.Scope, "Required modifier types are not supported (in {0})", context);
                    return(false);
                }
                var typeDef = type.Resolve();
                error = (typeDef == null);
            }
            catch (Exception)
            {
                error = true;
            }
            CheckResolveData data;
            var key = type.FullName;

            if (!resolveErrorTypeNames.TryGetValue(key, out data))
            {
                data = new CheckResolveData {
                    IsAvailable = !error
                };
                resolveErrorTypeNames.Add(key, data);
                if (error)
                {
                    Error(MessageTypes.MissingType, CecilFormat.GetTypeName(type), type.Scope, context);
                }
            }
            data.CheckCount++;
            return(!error);
        }