Example #1
0
        private static void ParseEvent(NamedTypeDocumentData parent, IEventSymbol symbol, string rootName, string id)
        {
            if (IsNotVisibleInGeneratedDocumentation(symbol))
            {
                return;
            }

            var data = parent.GetEvent(symbol.Name);

            if (data == null)
            {
                data = CreateDocumentData <EventDocumentData>(symbol, rootName, id);
                parent.AddEvent(data);
            }
            else
            {
                data.SupportedProjects.Add(id);
            }
        }
Example #2
0
        private static void ParseProperty(NamedTypeDocumentData parent, IPropertySymbol symbol, string rootName, string id)
        {
            if (IsNotVisibleInGeneratedDocumentation(symbol))
            {
                return;
            }

            var data = parent.GetProperty(symbol.Name);

            if (data == null)
            {
                data      = CreateDocumentData <PropertyDocumentData>(symbol, rootName, id);
                data.Type = CreateDocumentData <DocumentDataObject>(symbol.Type, null, string.Empty);
                parent.AddProperty(data);
            }
            else
            {
                data.SupportedProjects.Add(id);
            }
        }
Example #3
0
        private static void ParseField(NamedTypeDocumentData parent, IFieldSymbol symbol, string rootName, string id)
        {
            if (IsNotVisibleInGeneratedDocumentation(symbol) || !symbol.IsConst)
            {
                return;
            }

            var data = parent.GetConstant(symbol.Name);

            if (data == null)
            {
                data            = CreateDocumentData <ConstantDocumentData>(symbol, rootName, id);
                data.Value      = symbol.ConstantValue.ToString();
                data.MemberType = CreateDocumentData <DocumentDataObject>(symbol.Type, null, string.Empty);
                parent.AddConstant(data);
            }
            else
            {
                data.SupportedProjects.Add(id);
            }
        }
Example #4
0
        private static void ParseMethod(NamedTypeDocumentData parent, IMethodSymbol symbol, string rootName, string id)
        {
            if (symbol.AssociatedSymbol != null)
            {
                // We don't want to include methods that are associated with
                // events or properties.
                return;
            }

            if (IsNotVisibleInGeneratedDocumentation(symbol))
            {
                return;
            }

            var data = CreateDocumentData <MethodDocumentData>(symbol, rootName, id);

            DocumentationComment comment = null;

            try
            {
                var commentXml = symbol.GetDocumentationCommentXml();
                comment = DocumentationComment.FromXmlFragment(commentXml);
            }
            catch
            {
            }

            var parameters = symbol.Parameters;

            foreach (var parameter in parameters)
            {
                var parameterData = CreateDocumentData <MethodParameterData>(parameter, null, string.Empty);
                parameterData.Summary = comment.GetParameterText(parameterData.Name) ?? string.Empty;
                parameterData.Type    = CreateDocumentData <DocumentDataObject>(parameter.Type, null, string.Empty);
                data.Parameters.Add(parameterData);
            }

            var typeArguments = symbol.TypeArguments;

            foreach (var typeArgument in typeArguments)
            {
                var typeArgumentData = CreateDocumentData <MethodTypeArgumentData>(typeArgument, null, string.Empty);
                data.TypeArguments.Add(typeArgumentData);
            }

            data.GenerateId();
            if (symbol.MethodKind == MethodKind.Constructor || symbol.MethodKind == MethodKind.StaticConstructor)
            {
                var existingConstructor = parent.GetConstructor(data.Id);
                if (existingConstructor == null)
                {
                    data.ReturnType = null;
                    parent.AddConstructor(data);
                }
                else
                {
                    existingConstructor.SupportedProjects.Add(id);
                }
            }
            else
            {
                var existingMethod = parent.GetMethod(data.Id);
                if (existingMethod == null)
                {
                    data.ReturnType = CreateDocumentData <DocumentDataObject>(symbol.ReturnType, null, string.Empty);
                    parent.AddMethod(data);
                }
                else
                {
                    existingMethod.SupportedProjects.Add(id);
                }
            }
        }