Doraku / DefaultDocumentation

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

Got System.NullReferenceException when running DefaultDocumentation #124

Open HuiyunPeng opened 2 years ago

HuiyunPeng commented 2 years ago

I'm not able to run default documentation on one of my c# projects. Is this caused by default documentation or ICSharpCode.Decompiler?

Stack trace:

|INFO|DefaultDocumentation|Starting DefaultDocumentation with those settings:
    AssemblyFile: c:\myFile.dll
    DocumentationFile: c:\myFile.xml
    ProjectDirectory:
    OutputDirectory: c:\myDirectory
    AssemblyPageName: index
    GeneratedAccessModifiers: Public, Protected, ProtectedInternal
    GeneratedPages: Assembly, Namespaces, Types, Members
    IncludeUndocumentedItems: False
    LinksOutputFile:
    LinksBaseUrl:
    ExternLinksFiles:

 Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
     at ICSharpCode.Decompiler.TypeSystem.AccessibilityExtensions.EffectiveAccessibility(IEntity entity) in /_/ICSharpCode.Decompiler/TypeSystem/Accessibility.cs:line 134
     at DefaultDocumentation.Internal.DocItemReader.<.ctor>g__IsGenerated|5_0(IEntity entity, <>c__DisplayClass5_0& ) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Internal\DocItemReader.cs:line 29
     at DefaultDocumentation.Internal.DocItemReader.<.ctor>g__IsGenerated|5_0(IEntity entity, <>c__DisplayClass5_0& ) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Internal\DocItemReader.cs:line 35
     at DefaultDocumentation.Internal.DocItemReader..ctor(Settings settings) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Internal\DocItemReader.cs:line 157
     at DefaultDocumentation.Internal.DocItemReader.GetItems(Settings settings) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Internal\DocItemReader.cs:line 354
     at DefaultDocumentation.Generator..ctor(Target loggerTarget, IRawSettings settings) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Generator.cs:line 116
     at DefaultDocumentation.Generator.Execute(Target loggerTarget, IRawSettings settings) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Generator.cs:line 195
     at DefaultDocumentation.Program.<>c.<Main>b__0_1(SettingsArgs a) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Console\Program.cs:line 24
     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 18
Doraku commented 2 years ago

Hum from the stack trace it seems it fails to get the DeclaringTypeDefinition for an explicit interface implementation method. Can you provide the code that generate this error? You can get more infos by changing the LogLevel to pinpoint the member it is handling during the exception if needed.

HuiyunPeng commented 1 year ago

This is the member that generate this error.

/// <summary>
/// NOTE: must be kept in sync with Execute{TResult}/>
/// </summary>
Task<TResult> AsyncQueryProvider.ExecuteAsync<TResult>(Expression expression, CancellationToken cancellationToken)
{
    ...
}
Doraku commented 1 year ago

sorry for the laaaaate reply, I have been pretty busy with work and completely disconnected for some nice holydays. It seems related to an old issue someone reported to me, for some reason there is some dependencies that doesn't manage to be loaded and ICsharpCode.Decompiler can't find the full type information. I'll need to test (can you provide the package reference/dependencies from where AsyncQueryProvider is coming from?) just to be sure but I will probably need to safe guard against those cases :/