Example #1
0
        public override void VisitClassDeclaration(ClassDeclarationSyntax node)
        {
            var symbol = model.GetDeclaredSymbol(node);
            var fqName = symbol.ToDisplayString(_symDisplayFormat);

            string ns, name;

            Extensions.GetNamespaceAndName(fqName, out ns, out name);
            if (!string.IsNullOrWhiteSpace(ns))
            {
                CSharpNamespace nsObj;
                if (!CSFile.Elements.TryGetValue(ns, out nsObj))
                {
                    // This handles classes within classes
                    nsObj             = new CSharpNamespace();
                    nsObj.DisplayText = ns;
                    CSFile.Elements.Add(ns, nsObj);
                    _subClassConversions.Add(fqName, string.Format("{0}.{1}", fqName, name));
                }
                var classObj = new CSharpClass()
                {
                    IsPartial = symbol.DeclaringSyntaxReferences.Length > 1
                };

                Dictionary <string, HashSet <string> > references = new Dictionary <string, HashSet <string> >();
                string typeSuffix = GetGenericTypeSuffix(symbol, references);
                classObj.ExtendedInterface = GetExtendingType(symbol, references);
                if (string.IsNullOrEmpty(classObj.ExtendedInterface))
                {
                    foreach (var baseProperty in GetBasePropertiesFromExternalAssembly(symbol, classObj))
                    {
                        if (!baseProperty.Key.StartsWith("this", StringComparison.Ordinal) &&
                            !classObj.Children.ContainsKey(baseProperty.Key))
                        {
                            classObj.Children.Add(baseProperty.Key, baseProperty.Value);
                        }
                    }
                }

                var commentXml = symbol.GetDocumentationCommentXml();

                classObj.SetSummaryViaXml(commentXml);
                classObj.DisplayText = name + typeSuffix;

                if (references.Count > 0)
                {
                    classObj.AddReferences(references);
                }

                nsObj.Children.Add(name, classObj);
            }
            base.VisitClassDeclaration(node);
        }
Example #2
0
        public override void VisitNamespaceDeclaration(NamespaceDeclarationSyntax node)
        {
            var symbol = model.GetDeclaredSymbol(node);
            var fqName = symbol.ToDisplayString(_symDisplayFormat);

            CSharpNamespace nsObj = null;

            if (!CSFile.Elements.TryGetValue(fqName, out nsObj))
            {
                nsObj = new CSharpNamespace();

                var commentXml = symbol.GetDocumentationCommentXml();

                nsObj.SetSummaryViaXml(commentXml);
                nsObj.DisplayText = fqName;
                CSFile.Elements.Add(fqName, nsObj);
            }

            base.VisitNamespaceDeclaration(node);
        }