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

Provide more console details on how to correct 'System.NullReferenceException: Object reference not set to an instance of an object.' #23

Closed
ddemeyer opened this issue Jul 15, 2016 · 3 comments
Labels

Comments

@ddemeyer
Copy link

While debugging 'System.NullReferenceException: Object reference not set to an instance of an object.' at XmlDoc2CmdletDoc.Core.Domain.Command.<>c.<get_OutputTypes> 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.

@ChrisLambrou
Copy link
Contributor

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.

@ddemeyer
Copy link
Author

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.EnumerableSorter2.ComputeKeys(TElement[] elements, Int32 count)
1> at System.Linq.EnumerableSorter1.Sort(TElement[] elements, Int32 count) 1> at System.Linq.OrderedEnumerable1.d__1.MoveNext()
1> at XmlDoc2CmdletDoc.Core.Engine.GenerateReturnValuesElement(ICommentReader commentReader, Command command, ReportWarning reportWarning)
1> at XmlDoc2CmdletDoc.Core.Engine.GenerateCommandElement(ICommentReader commentReader, Command command, ReportWarning reportWarning)
1> at XmlDoc2CmdletDoc.Core.Engine.GenerateHelpItemsElement(ICommentReader commentReader, IEnumerable1 commands, ReportWarning reportWarning) 1> at XmlDoc2CmdletDoc.Core.Engine.GenerateHelp(Options options) 1> GenerateHelp completed with exit code 'UnhandledException'

@ChrisLambrou
Copy link
Contributor

Superseded by #30.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants