|
|
@ -57,13 +57,15 @@ namespace ILSpy.BamlDecompiler.Rewrite |
|
|
|
foreach (var annotation in element.Annotations<BamlConnectionId>()) |
|
|
|
foreach (var annotation in element.Annotations<BamlConnectionId>()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int index; |
|
|
|
int index; |
|
|
|
|
|
|
|
bool found = false; |
|
|
|
if ((index = fieldAssignments.FindIndex(item => item.key.Contains(annotation.Id))) > -1) |
|
|
|
if ((index = fieldAssignments.FindIndex(item => item.key.Contains(annotation.Id))) > -1) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var xName = ctx.GetKnownNamespace("Name", XamlContext.KnownNamespace_Xaml, element); |
|
|
|
var xName = ctx.GetKnownNamespace("Name", XamlContext.KnownNamespace_Xaml, element); |
|
|
|
if (element.Attribute("Name") is null && element.Attribute(xName) is null) |
|
|
|
if (element.Attribute("Name") is null && element.Attribute(xName) is null) |
|
|
|
element.Add(new XAttribute(xName, fieldAssignments[index].value.FieldName)); |
|
|
|
element.Add(new XAttribute(xName, fieldAssignments[index].value.FieldName)); |
|
|
|
|
|
|
|
found = true; |
|
|
|
} |
|
|
|
} |
|
|
|
else if ((index = eventMappings.FindIndex(item => item.key.Contains(annotation.Id))) > -1) |
|
|
|
if ((index = eventMappings.FindIndex(item => item.key.Contains(annotation.Id))) > -1) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (var entry in eventMappings[index].value) |
|
|
|
foreach (var entry in eventMappings[index].value) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -80,8 +82,9 @@ namespace ILSpy.BamlDecompiler.Rewrite |
|
|
|
element.Add(new XAttribute(xmlns + entry.EventName, entry.MethodName)); |
|
|
|
element.Add(new XAttribute(xmlns + entry.EventName, entry.MethodName)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
found = true; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
if (!found) |
|
|
|
{ |
|
|
|
{ |
|
|
|
element.Add(new XComment($"Unknown connection ID: {annotation.Id}")); |
|
|
|
element.Add(new XComment($"Unknown connection ID: {annotation.Id}")); |
|
|
|
} |
|
|
|
} |
|
|
@ -159,20 +162,7 @@ namespace ILSpy.BamlDecompiler.Rewrite |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (var section in ilSwitch.Sections) |
|
|
|
foreach (var section in ilSwitch.Sections) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var field = FindField(section.Body); |
|
|
|
Add(section.Labels, section.Body); |
|
|
|
if (!(field is null)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fieldAssignments.Add((section.Labels, field)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
events.Clear(); |
|
|
|
|
|
|
|
FindEvents(section.Body, events); |
|
|
|
|
|
|
|
if (events.Count > 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
eventMappings.Add((section.Labels, events.ToArray())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
@ -189,20 +179,22 @@ namespace ILSpy.BamlDecompiler.Rewrite |
|
|
|
? ifInst.FalseInst |
|
|
|
? ifInst.FalseInst |
|
|
|
: ifInst.TrueInst; |
|
|
|
: ifInst.TrueInst; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Add(new LongSet(id), inst); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Add(LongSet ids, ILInstruction inst) |
|
|
|
|
|
|
|
{ |
|
|
|
var field = FindField(inst); |
|
|
|
var field = FindField(inst); |
|
|
|
if (!(field is null)) |
|
|
|
if (!(field is null)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
fieldAssignments.Add((new LongSet(id), field)); |
|
|
|
fieldAssignments.Add((ids, field)); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
events.Clear(); |
|
|
|
events.Clear(); |
|
|
|
FindEvents(inst, events); |
|
|
|
FindEvents(inst, events); |
|
|
|
if (events.Count > 0) |
|
|
|
if (events.Count > 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
eventMappings.Add((new LongSet(id), events.ToArray())); |
|
|
|
eventMappings.Add((ids, events.ToArray())); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|