From d67d9913b5afb21dc5e06d6de43a849789fb716b Mon Sep 17 00:00:00 2001 From: Alex O'Ree Date: Mon, 3 Sep 2018 21:08:04 -0400 Subject: [PATCH] #9 kind of resolves issue 9. Room for improvement --- .gitignore | 3 ++- .../Documentation/Generators/BaseGenerator.cs | 14 +++++++++++++- .../Generators/NamespaceGenerator.cs | 15 +++++++++++---- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index ec2f21f..490526b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ bin obj _ReSharper* artifacts -TestResult.xml \ No newline at end of file +TestResult.xml +src/.vs/ diff --git a/src/Docu.Console/Documentation/Generators/BaseGenerator.cs b/src/Docu.Console/Documentation/Generators/BaseGenerator.cs index 9a26689..d41e657 100644 --- a/src/Docu.Console/Documentation/Generators/BaseGenerator.cs +++ b/src/Docu.Console/Documentation/Generators/BaseGenerator.cs @@ -84,7 +84,19 @@ protected void ParseReturns(IDocumentationMember member, Method doc) protected Namespace FindNamespace(IDocumentationMember association, List namespaces) { var identifier = Identifier.FromNamespace(association.TargetType.Namespace); - return namespaces.Find(x => x.IsIdentifiedBy(identifier)); + Namespace ns= namespaces.Find(x => x.IsIdentifiedBy(identifier)); + if (ns == null) + { + for (int i = 0; i < namespaces.Count; i++) + { + if (namespaces[i].Name == "NoNamespace") + { + ns = namespaces[i]; + break; + } + } + } + return ns; } protected DeclaredType FindType(Namespace ns, IDocumentationMember association) diff --git a/src/Docu.Console/Documentation/Generators/NamespaceGenerator.cs b/src/Docu.Console/Documentation/Generators/NamespaceGenerator.cs index 66c3d89..87f02a1 100644 --- a/src/Docu.Console/Documentation/Generators/NamespaceGenerator.cs +++ b/src/Docu.Console/Documentation/Generators/NamespaceGenerator.cs @@ -15,12 +15,19 @@ public NamespaceGenerator(IDictionary matchedAssociat public void Add(List namespaces, IDocumentationMember association) { + string namespace2 = "NoNamespace"; if (association.TargetType.Namespace == null) - throw new NullReferenceException( - string.Format("There was no namespace found for {0}", - association.TargetType.AssemblyQualifiedName)); + { + //TODO this may be better as a build warning + System.Console.WriteLine(string.Format("There was no namespace found for {0}", + association.TargetType.AssemblyQualifiedName)); + } + else + { + namespace2 = association.TargetType.Namespace; + } - var ns = Identifier.FromNamespace(association.TargetType.Namespace); + var ns = Identifier.FromNamespace(namespace2); if (!namespaces.Exists(x => x.IsIdentifiedBy(ns))) {