dotnet/roslynator

[generate-docs] Error generating the API docs

Closed this issue · 0 comments

Hi,

I'm using the CLI version to generate the docs of my public API and I'm getting some errors. I suppose that a file will contain an invalid character but I don't know what file throws the exception.

Now I will describe the details of the scenario:

Product and Version Used

  • Roslynator Version: 0.9.0.0
  • Roslynator Target Framework: .NET Core
  • Roslyn Version: 4.11.0.0
  • Available MSBuild locations:
    • .NET Core SDK, Version: 8.0.400

Steps to Reproduce

  1. Create a CSharp project with several classes, interfaces and inheritance.
  2. Run the following command line to gernate the docs and it generates the exception.
 roslynator.exe generate-doc .\ProjectFolder\MyProject.csproj --heading "My Project" --host "docusaurus" --include-inherited-interface-members --language "cs" --no-delete --output "build/ref" --root-file-path "build/ref/ref_my_project.md" --file-log .\build\log_generatedoc_my_project.txt --file-log-verbosity diag

Actual Behavior

Exception: System.AggregateException: One or more errors occurred. (length ('-1') must be a non-negative value. (Parameter 'length')
Actual value was -1.)

Loading project 'C:\ProjectFolder\MyProject.csproj'...
  Evaluate  00:00.50  MyProject.csproj
  Build     00:00.32  MyProject.csproj
Compile 'MyProject'
Relative path from root file to output directory is ''.
Generate documentation root to 'C:\MyProject\build\ref\ref_my_project.md'.
Documentation root successfully generated to 'C:\MyProject\build\ref\ref_my_project.md'.
Generate documentation to 'build/ref'
  Save 'build/ref\MyProject\Classes\Implementations\index.md'
  Save 'build/ref\MyProject\Classes\index.md'
  Save 'build/ref\MyProject\index.md'
  ...
  
  System.AggregateException: One or more errors occurred. (length ('-1') must be a non-negative value. (Parameter 'length')
Actual value was -1.)
 ---> System.ArgumentOutOfRangeException: length ('-1') must be a non-negative value. (Parameter 'length')
Actual value was -1.
   at System.ArgumentOutOfRangeException.ThrowNegative[T](T value, String paramName)
   at System.ArgumentOutOfRangeException.ThrowIfNegative[T](T value, String paramName)
   at System.String.ThrowSubstringArgumentOutOfRange(Int32 startIndex, Int32 length)
   at System.String.Substring(Int32 startIndex, Int32 length)
   at Roslynator.Documentation.TextUtility.RemoveLeadingTrailingNewLine(String s, Boolean leadingNewLine, Boolean trailingNewLine) in /_/src/Documentation/TextUtility.cs:line 49
   at Roslynator.Documentation.XmlExtensions.WriteContentTo(XElement element, DocumentationWriter writer, Boolean inlineOnly) in /_/src/Documentation/Extensions/XmlExtensions.cs:line 33
   at Roslynator.Documentation.DocumentationWriter.WriteTable(IEnumerable`1 symbols, String heading, Int32 headingLevel, String header1, String header2, SymbolDisplayFormat format, SymbolDisplayAdditionalMemberOptions additionalOptions, Boolean addLink, Boolean canIncludeInterfaceImplementation, INamedTypeSymbol containingType) in /_/src/Documentation/DocumentationWriter.cs:line 1436
   at Roslynator.Documentation.DocumentationWriter.WriteMethods(IEnumerable`1 methods, INamedTypeSymbol containingType) in /_/src/Documentation/DocumentationWriter.cs:line 1091
   at Roslynator.Documentation.DocumentationGenerator.GenerateType(TypeDocumentationModel typeModel) in /_/src/Documentation/DocumentationGenerator.cs:line 749
   at Roslynator.Documentation.DocumentationGenerator.Generate(CancellationToken cancellationToken)+MoveNext() in /_/src/Documentation/DocumentationGenerator.cs:line 184
   at Roslynator.CommandLine.GenerateDocCommand.ExecuteAsync(ProjectOrSolution projectOrSolution, CancellationToken cancellationToken) in /_/src/CommandLine/Commands/GenerateDocCommand.cs:line 234
   at Roslynator.CommandLine.MSBuildWorkspaceCommand`1.ExecuteAsync(String path, MSBuildWorkspace workspace, CancellationToken cancellationToken) in /_/src/CommandLine/Commands/MSBuildWorkspaceCommand.cs:line 164
   at Roslynator.CommandLine.MSBuildWorkspaceCommand`1.ExecuteAsync(IEnumerable`1 paths, String msbuildPath, IEnumerable`1 properties) in /_/src/CommandLine/Commands/MSBuildWorkspaceCommand.cs:line 89
   at Roslynator.CommandLine.Program.GenerateDocAsync(GenerateDocCommandLineOptions options) in /_/src/CommandLine/Program.cs:line 738
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at Roslynator.CommandLine.Program.<>c.<Main>b__0_3(MSBuildCommandLineOptions options) in /_/src/CommandLine/Program.cs:line 181
   at CommandLine.ParserResultExtensions.MapResult[T1,T2,TResult](ParserResult`1 result, Func`2 parsedFunc1, Func`2 parsedFunc2, Func`2 notParsedFunc)
   at Roslynator.CommandLine.Program.Main(String[] args) in /_/src/CommandLine/Program.cs:line 169

Expected Behavior

To generate all docs correctly. Due to the exception, some files are not generated.