Closed maxweisel closed 3 years ago
It seems the command-line tool doesn't support the short flags. If I use the explicit command-line flags, I can get a little farther, but now I get this:
defaultdocumentation.exe --AssemblyFilePath MyAssembly.dll
Unhandled exception. System.Exception: Error while writing documentation for MyAssembly.MyClass
---> System.InvalidCastException: Unable to cast object of type 'ICSharpCode.Decompiler.TypeSystem.ParameterizedType' to type 'ICSharpCode.Decompiler.TypeSystem.ITypeDefinition'.
at DefaultDocumentation.Writer.MarkdownWriter.WriteInheritances(DocItem item) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Writer\MarkdownWriter.cs:line 403
at DefaultDocumentation.Writer.MarkdownWriter.WriteItem(DocItem item) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Writer\MarkdownWriter.cs:line 537
at DefaultDocumentation.Writer.MarkdownWriter.WritePage(DirectoryInfo directory, DocItem item) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Writer\MarkdownWriter.cs:line 607
at DefaultDocumentation.Writer.DocItemWriter.Execute() in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Writer\DocItemWriter.cs:line 121
--- End of inner exception stack trace ---
at DefaultDocumentation.Writer.DocItemWriter.Execute() in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Writer\DocItemWriter.cs:line 125
at DefaultDocumentation.Generator.Execute(Settings settings) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Generator.cs:line 7
at DefaultDocumentation.Program.<>c.<Main>b__0_2(SettingsArgs a) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Console\Program.cs:line 31
at CommandLine.ParserResultExtensions.WithParsed[T](ParserResult`1 result, Action`1 action)
at DefaultDocumentation.Program.Main(String[] args) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Console\Program.cs:line 23
That's weird, I can reproduce the issue with short flag, I will check why commandlineparser complains.
The second error is something else. Can you share the code of the type MyAssembly.MyClass
? There seems to be a derived type causing problem.
Edit: looking closer it may actually be because of a type deriving from MyAssembly.MyClass
.
So I found the culprit for the first exception, I thought putting case insensitive parsing for the arguments would only apply to long name for some reason, and I was using lower and upper variant of the same character for different options. I changed the problematic short flags.
It seems the command-line tool doesn't support the short flags. If I use the explicit command-line flags, I can get a little farther, but now I get this:
Unhandled exception. System.Exception: Error while writing documentation for MyAssembly.MyClass ---> System.InvalidCastException: Unable to cast object of type 'ICSharpCode.Decompiler.TypeSystem.ParameterizedType' to type 'ICSharpCode.Decompiler.TypeSystem.ITypeDefinition'.
I am also seeing this exception.
It's source is in MarkdownWriter, at 'WriteInheritances' method:
foreach (ITypeDefinition t in typeItem.Type.GetNonInterfaceBaseTypes().Where(t => t != typeItem.Type)) { _builder.Append(GetLink(item, t)).Append(" 🡒 "); }
Cast to ITypeDefinition in first foreach seems to be incorrect.
Maybe it should be changed to IType?
From this:
foreach (ITypeDefinition t in typeItem.Type.GetNonInterfaceBaseTypes().Where(t => t != typeItem.Type))
to this :
foreach (IType t in typeItem.Type.GetNonInterfaceBaseTypes().Where(t => t != typeItem.Type))
ah that's definitely it, pretty stupid of me I probably missed it during the big refactoring and I didn't hit this case with my projects >_> I will push the fix later today, thanks @IggaF
@maxweisel @IggaF Could one of you try the latest ci version and see if it run correctly now with those fix? Or maybe the source you are running DefaultDocumentation on are public and I can try it myself?
@Doraku Hi, Source is not public... And I'm using nuget only - not console
There is also a preview version for the msbuild task, but I created an official version 0.7.3 with the fix anyway. Could you confirm that it fixes the problem please :)?
@Doraku Hi, I've tested it - works :) Thanks a lot!
I've just installed the command-line tool, and when I run it on a C# assembly built with Visual Studio 2019 I get the following:
Any idea what I could be missing here? The assembly and xml file are both valid.
Max