Browse Source

fix ConnectionIdRewritePass

field assignment and event mapping can in the same block
pull/2327/head
wwh1004 4 years ago committed by GitHub
parent
commit
d799fdb492
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      ILSpy.BamlDecompiler/Rewrite/ConnectionIdRewritePass.cs

13
ILSpy.BamlDecompiler/Rewrite/ConnectionIdRewritePass.cs

@ -57,13 +57,15 @@ namespace ILSpy.BamlDecompiler.Rewrite @@ -57,13 +57,15 @@ namespace ILSpy.BamlDecompiler.Rewrite
foreach (var annotation in element.Annotations<BamlConnectionId>())
{
int index;
bool found = false;
if ((index = fieldAssignments.FindIndex(item => item.key.Contains(annotation.Id))) > -1)
{
var xName = ctx.GetKnownNamespace("Name", XamlContext.KnownNamespace_Xaml, element);
if (element.Attribute("Name") is null && element.Attribute(xName) is null)
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)
{
@ -80,8 +82,9 @@ namespace ILSpy.BamlDecompiler.Rewrite @@ -80,8 +82,9 @@ namespace ILSpy.BamlDecompiler.Rewrite
element.Add(new XAttribute(xmlns + entry.EventName, entry.MethodName));
}
}
found = true;
}
else
if (!found)
{
element.Add(new XComment($"Unknown connection ID: {annotation.Id}"));
}
@ -164,8 +167,6 @@ namespace ILSpy.BamlDecompiler.Rewrite @@ -164,8 +167,6 @@ namespace ILSpy.BamlDecompiler.Rewrite
{
fieldAssignments.Add((section.Labels, field));
}
else
{
events.Clear();
FindEvents(section.Body, events);
if (events.Count > 0)
@ -174,7 +175,6 @@ namespace ILSpy.BamlDecompiler.Rewrite @@ -174,7 +175,6 @@ namespace ILSpy.BamlDecompiler.Rewrite
}
}
}
}
else
{
foreach (var ifInst in function.Descendants.OfType<IfInstruction>())
@ -194,8 +194,6 @@ namespace ILSpy.BamlDecompiler.Rewrite @@ -194,8 +194,6 @@ namespace ILSpy.BamlDecompiler.Rewrite
{
fieldAssignments.Add((new LongSet(id), field));
}
else
{
events.Clear();
FindEvents(inst, events);
if (events.Count > 0)
@ -205,7 +203,6 @@ namespace ILSpy.BamlDecompiler.Rewrite @@ -205,7 +203,6 @@ namespace ILSpy.BamlDecompiler.Rewrite
}
}
}
}
FieldAssignment FindField(ILInstruction inst)
{

Loading…
Cancel
Save