Closed ddemeyer closed 7 years ago
Could you please provide a stack trace, or more specific steps on how to repeat this bug? There's a non-trivial amount of code in the Command
class, and whilst I have some idea what might be causing this problem, it's not entirely clear. Also, you could try using [OutputType(typeof(SomeObject))]
rather than [OutputType(nameof(SomeObject))]
. nameof
won't give you the fully-qualified name of SomeObject
, which might be causing problems either instantiating the OutputTypeAttribute
or resolving its Type
property.
Thanks Chris... doing some late night OSS coding often means eyes are half-closed to spot a thing like this. Switched [OutputType(nameof(SomeObject))] to [OutputType(typeof(SomeObject))] on top of my public sealed cmdlet class with success.
For the record, the 'nameof' stacktrace is
1> System.NullReferenceException: Object reference not set to an instance of an object. 1> at XmlDoc2CmdletDoc.Core.Domain.Command.<>c.<get_OutputTypes>b__10_2(Type type) 1> at System.Linq.EnumerableSorter
2.ComputeKeys(TElement[] elements, Int32 count)
1> at System.Linq.EnumerableSorter1.Sort(TElement[] elements, Int32 count) 1> at System.Linq.OrderedEnumerable
1.1 commands, ReportWarning reportWarning) 1> at XmlDoc2CmdletDoc.Core.Engine.GenerateHelp(Options options) 1> GenerateHelp completed with exit code 'UnhandledException'
Superseded by #30.
While debugging 'System.NullReferenceException: Object reference not set to an instance of an object.' at XmlDoc2CmdletDoc.Core.Domain.Command.<>c. I eventually found the culprit to be the OutputType attribute on my cmdlet [OutputType(nameof(SomeObject))].
Removing it resolved it for now. It would be nice to know on which cmdlet, property or attribute it fails to easily correct the situation. At least the above will give guidance to others.