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

BAML decompiler throws NullReferenceExceptions #371

Closed
moretti opened this issue Nov 25, 2012 · 0 comments
Closed

BAML decompiler throws NullReferenceExceptions #371

moretti opened this issue Nov 25, 2012 · 0 comments
Assignees

Comments

@moretti
Copy link

moretti commented Nov 25, 2012

In XmlBamlReader there is a property named LastKey:

KeyMapping LastKey {
    get { return keys.LastOrDefault(); }
}

This property can definitely return null, but this is not handled and it causes the following exception:

System.NullReferenceException: Object reference not set to an instance of an object.
   in Ricciolo.StylesExplorer.MarkupReflection.XmlBamlReader.ReadOptimizedStaticResource()
   in Ricciolo.StylesExplorer.MarkupReflection.XmlBamlReader.ProcessNext()
   in Ricciolo.StylesExplorer.MarkupReflection.XmlBamlReader.ReadInternal()
   in System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r)
   in System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o)
   in System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
   in ILSpy.BamlDecompiler.BamlResourceEntryNode.LoadIntoDocument(IAssemblyResolver resolver, AssemblyDefinition asm, Stream stream)
   in ILSpy.BamlDecompiler.BamlResourceEntryNode.LoadBaml(AvalonEditTextOutput output)
   in ILSpy.BamlDecompiler.BamlResourceEntryNode.<>c__DisplayClass3.<View>b__1()

I think this property is pretty useful. We could definitely replace the two points where it is used with something like:

var lastKey = this.keys.LastOrDefault();
if (lastKey != null) {
    // ...
}
@ghost ghost assigned siegfriedpammer May 10, 2013
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants