docfx
                                
                                 docfx copied to clipboard
                                
                                    docfx copied to clipboard
                            
                            
                            
                        Inheritdoc on the constructor function of a struct crashes DocFX
Operating System: (Windows or Linux or MacOS)
Windows
DocFX Version Used: 2.58
Template used: (default or statictoc or contain custom template)
default with minor cosmetic customizations
Steps to Reproduce:
- Place an inheritdoc element on the constructor function of a struct:
public struct BadInheritance
{
    /// <inheritdoc/>
    public BadInheritance(string foo)
    {
    }
}
- Run DocFX
Expected Behavior: DocFX would complete and, ideally, emit a warning that the inheritdoc element didn't find any docs to inherit (since structs cannot inherit from other structs).
Actual Behavior: DocFX exits with a null reference exception stack trace and does not produce any output.
I suspect the problem is here: https://github.com/dotnet/docfx/blob/0341b6c0e4ec999da8cef6ac50ab720160d09c35/src/Microsoft.DocAsCode.Metadata.ManagedReference/Resolvers/CopyInheritedDocumentation.cs#L37
There's an assertion that the constructor function belongs to a class, but that isn't necessarily the case.
@jo3w4rd For reference, is the comment below the type of documentation you are expecting to inherit in this case?
Initializes a new instance of the ValueType class.
@paulushub I don't think inheritdoc needs to do anything useful here (a warning would suffice). However, DocFX simply exiting without any indication of what or where the problem lies is extremely bad.
In the case that spurred this issue, I had a largish code base that some engineer at some point in time had inserted this inheritdoc element into. The way I found the problem was by deleting files from the project until I narrowed down which file was the cause (half-split method).
@jo3w4rd Thanks for the information.