Doraku / DefaultDocumentation

Create a simple markdown documentation from the Visual Studio xml one.
MIT No Attribution
160 stars 26 forks source link

<inheritdoc cref="Self" /> causes StackOverflowException #142

Closed Emik03 closed 1 year ago

Emik03 commented 1 year ago

The following code causes an unhandled exception.

/// <inheritdoc cref="A" />
public class A { }

Log:

  MSBuild version 17.4.1+9a89d02ff for .NET
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
Build has started
Stack overflow.
   at System.Collections.Generic.GenericArraySortHelper`1[[ICSharpCode.Decompiler.Documentation.XmlDocumentationProvider+IndexEntry, ICSharpCode.Decompiler, Version=7.2.0.6844, Culture=neutral, PublicKeyToken=d4bfe873e7598c49]].BinarySearch(IndexEntry[], Int32, Int32, IndexEntry)
   at System.Collections.Generic.GenericArraySortHelper`1[[ICSharpCode.Decompiler.Documentation.XmlDocumentationProvider+IndexEntry, ICSharpCode.Decompiler, Version=7.2.0.6844, Culture=neutral, PublicKeyToken=d4bfe873e7598c49]].BinarySearch(IndexEntry[], Int32, Int32, IndexEntry, System.Collections.Generic.IComparer`1<IndexEntry>)
   at System.Array.BinarySearch[[ICSharpCode.Decompiler.Documentation.XmlDocumentationProvider+IndexEntry, ICSharpCode.Decompiler, Version=7.2.0.6844, Culture=neutral, PublicKeyToken=d4bfe873e7598c49]](IndexEntry[], Int32, Int32, IndexEntry, System.Collections.Generic.IComparer`1<IndexEntry>)
   at System.Array.BinarySearch[[ICSharpCode.Decompiler.Documentation.XmlDocumentationProvider+IndexEntry, ICSharpCode.Decompiler, Version=7.2.0.6844, Culture=neutral, PublicKeyToken=d4bfe873e7598c49]](IndexEntry[], IndexEntry)
   at ICSharpCode.Decompiler.Documentation.XmlDocumentationProvider.GetDocumentation(System.String, Boolean)
   at ICSharpCode.Decompiler.Documentation.XmlDocumentationProvider.GetDocumentation(System.String)
   at ICSharpCode.Decompiler.Documentation.XmlDocumentationProvider.GetDocumentation(ICSharpCode.Decompiler.TypeSystem.IEntity)
   at DefaultDocumentation.Internal.DocItemReader.TryGetDocumentation(ICSharpCode.Decompiler.TypeSystem.IEntity, System.Xml.Linq.XElement ByRef)
(above line repeated over and over)
Doraku commented 1 year ago

This is probably something that should be safe guarded against to return a more explicit exception, or is something else expected? I don't think it make sens for a type to inherit its own documentation.

Emik03 commented 1 year ago

Most IDEs simply ignore it, so I would suggest doing the same. I often see it used to suppress the warning that everything must be documented, even in other files of partial types that already have the documentation needed.