From 8c9ec7b626e6e0def0fa5319aa3190812ad090f0 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Fri, 18 Apr 2014 09:28:12 +0200 Subject: [PATCH] fix #445 - Baml Decompiler Exception: ArgumentException: Cannot find StaticResource --- .../XmlBamlReader.cs | 2 +- ILSpy.BamlDecompiler/Tests/Cases/Issue445.xaml | 11 +++-------- ILSpy.BamlDecompiler/Tests/TestRunner.cs | 2 +- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs index 12c55ae18..f45e9f4ab 100644 --- a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs +++ b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs @@ -1553,7 +1553,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection object GetStaticResource(short identifier) { - int keyIndex = currentKey - 1; + int keyIndex = Math.Max(0, currentKey - 1); while (keyIndex >= 0 && !keys[keyIndex].HasStaticResources) keyIndex--; if (keyIndex >= 0 && identifier < keys[keyIndex].StaticResources.Count) diff --git a/ILSpy.BamlDecompiler/Tests/Cases/Issue445.xaml b/ILSpy.BamlDecompiler/Tests/Cases/Issue445.xaml index d6eba3b8f..1c447620d 100644 --- a/ILSpy.BamlDecompiler/Tests/Cases/Issue445.xaml +++ b/ILSpy.BamlDecompiler/Tests/Cases/Issue445.xaml @@ -1,17 +1,12 @@ - + -