Browse Source

#2109: Skip id ranges with no events

pull/2145/head
Siegfried Pammer 5 years ago
parent
commit
19719ee1fb
  1. 11
      ILSpy.BamlDecompiler/Rewrite/ConnectionIdRewritePass.cs

11
ILSpy.BamlDecompiler/Rewrite/ConnectionIdRewritePass.cs

@ -139,15 +139,19 @@ namespace ILSpy.BamlDecompiler.Rewrite
var block = function.Body.Children.OfType<Block>().First(); var block = function.Body.Children.OfType<Block>().First();
var ilSwitch = block.Descendants.OfType<SwitchInstruction>().FirstOrDefault(); var ilSwitch = block.Descendants.OfType<SwitchInstruction>().FirstOrDefault();
var events = new List<EventRegistration>();
if (ilSwitch != null) if (ilSwitch != null)
{ {
foreach (var section in ilSwitch.Sections) foreach (var section in ilSwitch.Sections)
{ {
var events = new List<EventRegistration>(); events.Clear();
FindEvents(section.Body, events); FindEvents(section.Body, events);
if (events.Count > 0)
{
result.Add((section.Labels, events.ToArray())); result.Add((section.Labels, events.ToArray()));
} }
} }
}
else else
{ {
foreach (var ifInst in function.Descendants.OfType<IfInstruction>()) foreach (var ifInst in function.Descendants.OfType<IfInstruction>())
@ -161,12 +165,15 @@ namespace ILSpy.BamlDecompiler.Rewrite
var inst = comp.Kind == ComparisonKind.Inequality var inst = comp.Kind == ComparisonKind.Inequality
? ifInst.FalseInst ? ifInst.FalseInst
: ifInst.TrueInst; : ifInst.TrueInst;
var events = new List<EventRegistration>(); events.Clear();
FindEvents(inst, events); FindEvents(inst, events);
if (events.Count > 0)
{
result.Add((new LongSet(id), events.ToArray())); result.Add((new LongSet(id), events.ToArray()));
} }
} }
} }
}
void FindEvents(ILInstruction inst, List<EventRegistration> events) void FindEvents(ILInstruction inst, List<EventRegistration> events)
{ {

Loading…
Cancel
Save