Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException when running against .net 8 assembly #260

Open
ddechant-bvc opened this issue Nov 20, 2023 · 1 comment
Open

NullReferenceException when running against .net 8 assembly #260

ddechant-bvc opened this issue Nov 20, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@ddechant-bvc
Copy link

I am running the following against a .net 8 assembly:

mddocs apireference --assemblies "C:\Git\...\bin\Debug\net8.0\Assembly.dll" --outdir "C:\Git\....\docs"

Which results in the following exception being thrown:

INFORMATION - Reading XML documentation comments from 'C:\Git\...\bin\Debug\net8.0\Assembly.xml'
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at Grynwald.MdDocs.Common.ParameterDefinitionExtensions.<>c.<GetCustomAttributes>b__0_0(CustomAttribute attribute) in /_/src/MdDocs.Common/_Extensions/_Cecil/ParameterDefinitionExtensions.cs:line 31
   at System.Linq.Utilities.<>c__DisplayClass1_0`1.<CombinePredicates>b__0(TSource x)
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at Grynwald.MdDocs.ApiReference.Model.CSharpDefinitionFormatter.AppendCustomAttributes(StringBuilder definitionBuilder, IEnumerable`1 customAttributes, Boolean singleLine) in /_/src/MdDocs.ApiReference/Model/_Helpers/CSharpDefinitionFormatter.cs:line 362
   at Grynwald.MdDocs.ApiReference.Model.CSharpDefinitionFormatter.GetDefinition(ParameterDefinition parameter) in /_/src/MdDocs.ApiReference/Model/_Helpers/CSharpDefinitionFormatter.cs:line 747
   at System.Linq.Enumerable.SelectIListIterator`2.MoveNext()
   at System.Text.StringBuilder.AppendJoinCore[T](Char& separator, Int32 separatorLength, IEnumerable`1 values)
   at System.Text.StringBuilder.AppendJoin[T](String separator, IEnumerable`1 values)
   at Grynwald.MdDocs.ApiReference.Model.CSharpDefinitionFormatter.GetDefinition(MethodDefinition method) in /_/src/MdDocs.ApiReference/Model/_Helpers/CSharpDefinitionFormatter.cs:line 235
   at Grynwald.MdDocs.ApiReference.Model.MethodLikeOverloadDocumentation..ctor(MethodDefinition definition, IXmlDocsProvider xmlDocsProvider) in /_/src/MdDocs.ApiReference/Model/MethodLikeOverloadDocumentation.cs:line 64
   at Grynwald.MdDocs.ApiReference.Model.ConstructorOverloadDocumentation..ctor(ConstructorDocumentation methodDocumentation, MethodDefinition definition, IXmlDocsProvider xmlDocsProvider) in /_/src/MdDocs.ApiReference/Model/ConstructorOverloadDocumentation.cs:line 29
   at Grynwald.MdDocs.ApiReference.Model.ConstructorDocumentation.<>c__DisplayClass5_0.<.ctor>b__1(MethodDefinition d) in /_/src/MdDocs.ApiReference/Model/ConstructorDocumentation.cs:line 42
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.ToDictionary[TSource,TKey](IEnumerable`1 source, Func`2 keySelector, IEqualityComparer`1 comparer)
   at Grynwald.MdDocs.ApiReference.Model.ConstructorDocumentation..ctor(TypeDocumentation typeDocumentation, IEnumerable`1 definitions, IXmlDocsProvider xmlDocsProvider) in /_/src/MdDocs.ApiReference/Model/ConstructorDocumentation.cs:line 41
   at Grynwald.MdDocs.ApiReference.Model.TypeDocumentation..ctor(AssemblyDocumentation assemblyDocumentation, NamespaceDocumentation namespaceDocumentation, TypeDefinition definition, IXmlDocsProvider xmlDocsProvider, ILogger logger, TypeDocumentation declaringType) in /_/src/MdDocs.ApiReference/Model/TypeDocumentation.cs:line 237
   at Grynwald.MdDocs.ApiReference.Model.AssemblySetDocumentation.LoadTypeRecursively(AssemblyDocumentation assemblyDocumentation, IXmlDocsProvider xmlDocsProvider, TypeDefinition typeDefinition, TypeDocumentation declaringType) in /_/src/MdDocs.ApiReference/Model/AssemblySetDocumentation.cs:line 185
   at Grynwald.MdDocs.ApiReference.Model.AssemblySetDocumentation.LoadAssemblies(IReadOnlyList`1 assemblyDefinitions) in /_/src/MdDocs.ApiReference/Model/AssemblySetDocumentation.cs:line 170
   at Grynwald.MdDocs.ApiReference.Model.AssemblySetDocumentation..ctor(IReadOnlyList`1 assemblyDefinitions, IXmlDocsProvider xmlDocsProvider, ILogger logger) in /_/src/MdDocs.ApiReference/Model/AssemblySetDocumentation.cs:line 61
   at Grynwald.MdDocs.ApiReference.Model.AssemblySetDocumentation.FromAssemblyFiles(IEnumerable`1 filePaths, ILogger logger) in /_/src/MdDocs.ApiReference/Model/AssemblySetDocumentation.cs:line 116
   at Grynwald.MdDocs.ApiReference.Commands.ApiReferenceCommand.Execute() in /_/src/MdDocs.ApiReference/Commands/ApiReferenceCommand.cs:line 31
   at Grynwald.MdDocs.Program.OnApiReferenceCommand(ILogger logger, ApiReferenceOptions opts) in /_/src/MdDocs/Program.cs:line 59
   at Grynwald.MdDocs.Program.<>c.<Main>b__0_1(ApiReferenceOptions opts) in /_/src/MdDocs/Program.cs:line 31
   at CommandLine.ParserResultExtensions.MapResult[T1,T2,TResult](ParserResult`1 result, Func`2 parsedFunc1, Func`2 parsedFunc2, Func`2 notParsedFunc)
   at Grynwald.MdDocs.Program.Main(String[] args) in /_/src/MdDocs/Program.cs:line 28

The same extract runs properly against the same assembly when it is built with .net 6.

@ap0llo
Copy link
Owner

ap0llo commented Nov 26, 2023

Thanks for reporting.

At first glance, seems like the compiler adds an attribute which is not handled properly.

@ap0llo ap0llo added the bug Something isn't working label Nov 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants