summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2016-07-25 21:40:34 +0200
committerJason Smith <jason.smith@xamarin.com>2016-07-25 12:40:34 -0700
commitd04a4a3cf23c51d8401364d13b9201bf27873618 (patch)
tree12ae78b757b55fb176b5bb8929f8612431bada56
parent2590d913f7c69f1be60c2c5ac7fb60d0ec8732ed (diff)
downloadxamarin-forms-d04a4a3cf23c51d8401364d13b9201bf27873618.tar.gz
xamarin-forms-d04a4a3cf23c51d8401364d13b9201bf27873618.tar.bz2
xamarin-forms-d04a4a3cf23c51d8401364d13b9201bf27873618.zip
[XamlC] fix a bug in the debugging code introduced last week (#267)
-rw-r--r--Xamarin.Forms.Build.Tasks/DebugXamlCTask.cs4
-rw-r--r--Xamarin.Forms.Build.Tasks/XamlCTask.cs18
2 files changed, 14 insertions, 8 deletions
diff --git a/Xamarin.Forms.Build.Tasks/DebugXamlCTask.cs b/Xamarin.Forms.Build.Tasks/DebugXamlCTask.cs
index e0f81972..c4744cc2 100644
--- a/Xamarin.Forms.Build.Tasks/DebugXamlCTask.cs
+++ b/Xamarin.Forms.Build.Tasks/DebugXamlCTask.cs
@@ -69,8 +69,8 @@ namespace Xamarin.Forms.Build.Tasks
}
var initCompRuntime = typeDef.Methods.FirstOrDefault(md => md.Name == "__InitComponentRuntime");
if (initCompRuntime == null) {
- LogLine(2, "no __InitComponentRuntime found... skipped.");
- continue;
+ LogLine(2, "no __InitComponentRuntime found... duplicating.");
+ initCompRuntime = DuplicateMethodDef(typeDef, initComp, "__InitComponentRuntime");
}
// IL_0000: ldarg.0
diff --git a/Xamarin.Forms.Build.Tasks/XamlCTask.cs b/Xamarin.Forms.Build.Tasks/XamlCTask.cs
index b6387c0f..ae2a66d0 100644
--- a/Xamarin.Forms.Build.Tasks/XamlCTask.cs
+++ b/Xamarin.Forms.Build.Tasks/XamlCTask.cs
@@ -232,13 +232,12 @@ namespace Xamarin.Forms.Build.Tasks
}
LogLine(2, "");
- if (typeDef.Methods.FirstOrDefault(md => md.Name == "__InitComponentRuntime") != null) {
+ var initCompRuntime = typeDef.Methods.FirstOrDefault(md => md.Name == "__InitComponentRuntime");
+ if (initCompRuntime != null)
LogLine(2, " __InitComponentRuntime already exists... not duplicating");
- } else {
+ else {
LogString(2, " Duplicating {0}.InitializeComponent () into {0}.__InitComponentRuntime ... ", typeDef.Name);
- var initCompRuntime = new MethodDefinition("__InitComponentRuntime", initComp.Attributes, initComp.ReturnType);
- initCompRuntime.Body = initComp.Body;
- typeDef.Methods.Add(initCompRuntime);
+ initCompRuntime = DuplicateMethodDef(typeDef, initComp, "__InitComponentRuntime");
LogLine(2, "done.");
}
@@ -293,7 +292,6 @@ namespace Xamarin.Forms.Build.Tasks
il.Emit(OpCodes.Callvirt, func);
il.Emit(OpCodes.Brfalse, nop);
il.Emit(OpCodes.Ldarg_0);
- var initCompRuntime = typeDef.Methods.FirstOrDefault(md => md.Name == "__InitComponentRuntime");
il.Emit(OpCodes.Call, initCompRuntime);
il.Emit(OpCodes.Ret);
il.Append(nop);
@@ -404,6 +402,14 @@ namespace Xamarin.Forms.Build.Tasks
return success;
}
+ protected static MethodDefinition DuplicateMethodDef(TypeDefinition typeDef, MethodDefinition methodDef, string newName)
+ {
+ var dup = new MethodDefinition(newName, methodDef.Attributes, methodDef.ReturnType);
+ dup.Body = methodDef.Body;
+ typeDef.Methods.Add(dup);
+ return dup;
+ }
+
static ILRootNode ParseXaml(Stream stream, TypeReference typeReference)
{
ILRootNode rootnode = null;