Skip to content

Commit

Permalink
fix icsharpcode#206 - BAML decompiler - NotImplementedException: Stat…
Browse files Browse the repository at this point in the history
…icResourceStart
  • Loading branch information
siegfriedpammer committed Apr 18, 2014
1 parent 8c9ec7b commit ee5ddb7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ public List<object> StaticResources {
get { return staticResources; }
}

public bool HasStaticResources {
get { return staticResources != null && staticResources.Count > 0; }
public bool HasStaticResource(int identifier)
{
return staticResources != null && staticResources.Count > identifier;
}

public string KeyString { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,9 @@ public KnownInfo(ITypeResolver resolver)
KnownResourceTable.Add(0xda, new ResourceName("InternalSystemParametersEnd"));
KnownResourceTable.Add(0x5e, new ResourceName("InternalSystemParametersStart"));
KnownResourceTable.Add(0xe8, new ResourceName("InternalSystemThemeStylesEnd"));
KnownResourceTable.Add(0xe9, new ResourceName("InternalSystemColorsExtendedStart"));
KnownResourceTable.Add(0xea, new ResourceName("InactiveSelectionHighlightBrush"));
KnownResourceTable.Add(0xeb, new ResourceName("InactiveSelectionHighlightTextBrush"));
KnownResourceTable.Add(0xd6, new ResourceName("InternalSystemThemeStylesStart"));
KnownResourceTable.Add(0x95, new ResourceName("SystemParameters.IsImmEnabled"));
KnownResourceTable.Add(150, new ResourceName("SystemParameters.IsMediaCenter"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,13 +682,21 @@ object GetResourceName(short identifier)
return declaration;
} else {
identifier = (short)-identifier;
bool isNotKey = (identifier > 0xe8);
if (isNotKey)
identifier = (short)(identifier - 0xe8);
bool isKey = true;
if (identifier > 0xe8 && identifier < 0x1d0) {
isKey = false;
identifier -= 0xe8;
} else if (identifier > 0x1d0 && identifier < 0x1d3) {
identifier -= 0xe7;
} else if (identifier > 0x1d3 && identifier < 0x1d6) {
identifier -= 0xea;
isKey = false;
}
ResourceName resource;
if (!KnownInfo.KnownResourceTable.TryGetValue(identifier, out resource))
// resource = new ResourceName("???Resource" + identifier + "???");
throw new ArgumentException("Cannot find resource name " + identifier);
if (!isNotKey)
if (isKey)
return new ResourceName(resource.Name + "Key");
return resource;
}
Expand Down Expand Up @@ -1554,7 +1562,9 @@ void ReadPropertyWithStaticResourceIdentifier()
object GetStaticResource(short identifier)
{
int keyIndex = Math.Max(0, currentKey - 1);
while (keyIndex >= 0 && !keys[keyIndex].HasStaticResources)
while (keyIndex > keys.Count)
keyIndex--;
while (keyIndex >= 0 && !keys[keyIndex].HasStaticResource(identifier))
keyIndex--;
if (keyIndex >= 0 && identifier < keys[keyIndex].StaticResources.Count)
return keys[keyIndex].StaticResources[(int)identifier];
Expand Down

0 comments on commit ee5ddb7

Please sign in to comment.