summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Build.Tasks
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2016-12-23 07:50:02 (GMT)
committerGitHub <noreply@github.com>2016-12-23 07:50:02 (GMT)
commit2c91b0facd2a25d0de9a283b44cf818329d4c06f (patch)
treea1e659906258f2fc5c8c67d825a229ecf82db67b /Xamarin.Forms.Build.Tasks
parent0c87fcff41bef841f83ef62de5cdc3d821980d33 (diff)
downloadxamarin-forms-2c91b0facd2a25d0de9a283b44cf818329d4c06f.zip
xamarin-forms-2c91b0facd2a25d0de9a283b44cf818329d4c06f.tar.gz
xamarin-forms-2c91b0facd2a25d0de9a283b44cf818329d4c06f.tar.bz2
[XamlC] import members on x:Static and factories (#642)
Diffstat (limited to 'Xamarin.Forms.Build.Tasks')
-rw-r--r--Xamarin.Forms.Build.Tasks/CompiledMarkupExtensions/StaticExtension.cs4
-rw-r--r--Xamarin.Forms.Build.Tasks/CreateObjectVisitor.cs6
-rw-r--r--Xamarin.Forms.Build.Tasks/MethodReferenceExtensions.cs4
-rw-r--r--Xamarin.Forms.Build.Tasks/TypeReferenceExtensions.cs10
4 files changed, 16 insertions, 8 deletions
diff --git a/Xamarin.Forms.Build.Tasks/CompiledMarkupExtensions/StaticExtension.cs b/Xamarin.Forms.Build.Tasks/CompiledMarkupExtensions/StaticExtension.cs
index 014fb82..464eeac 100644
--- a/Xamarin.Forms.Build.Tasks/CompiledMarkupExtensions/StaticExtension.cs
+++ b/Xamarin.Forms.Build.Tasks/CompiledMarkupExtensions/StaticExtension.cs
@@ -26,7 +26,7 @@ namespace Xamarin.Forms.Build.Tasks
var typename = member.Substring(0, dotIdx);
var membername = member.Substring(dotIdx + 1);
- var typeRef = GetTypeReference(typename, module, node);
+ var typeRef = module.Import(GetTypeReference(typename, module, node));
var fieldRef = GetFieldReference(typeRef, membername, module);
var propertyDef = GetPropertyDefinition(typeRef, membername, module);
@@ -75,7 +75,7 @@ namespace Xamarin.Forms.Build.Tasks
}
memberRef = propertyDef.PropertyType;
- var getterDef = propertyDef.GetMethod;
+ var getterDef = module.Import(propertyDef.GetMethod);
return new [] { Instruction.Create(OpCodes.Call, getterDef) };
}
diff --git a/Xamarin.Forms.Build.Tasks/CreateObjectVisitor.cs b/Xamarin.Forms.Build.Tasks/CreateObjectVisitor.cs
index ac53021..ff8f84f 100644
--- a/Xamarin.Forms.Build.Tasks/CreateObjectVisitor.cs
+++ b/Xamarin.Forms.Build.Tasks/CreateObjectVisitor.cs
@@ -48,7 +48,7 @@ namespace Xamarin.Forms.Build.Tasks
public void Visit(ElementNode node, INode parentNode)
{
- var typeref = node.XmlType.GetTypeReference(Module, node);
+ var typeref = Module.Import(node.XmlType.GetTypeReference(Module, node));
TypeDefinition typedef = typeref.Resolve();
if (IsXaml2009LanguagePrimitive(node)) {
@@ -65,6 +65,7 @@ namespace Xamarin.Forms.Build.Tasks
var markupProvider = new StaticExtension();
var il = markupProvider.ProvideValue(node, Module, Context, out typeref);
+ typeref = Module.Import(typeref);
var vardef = new VariableDefinition(typeref);
Context.Variables [node] = vardef;
@@ -154,8 +155,7 @@ namespace Xamarin.Forms.Build.Tasks
Context.IL.Emit(OpCodes.Call, implicitOperator);
Context.IL.Emit(OpCodes.Stloc, vardef);
} else if (factorymethodinforef != null) {
- var factory = Module.Import(factorymethodinforef);
- Context.IL.Emit(OpCodes.Call, factory);
+ Context.IL.Emit(OpCodes.Call, Module.Import(factorymethodinforef));
Context.IL.Emit(OpCodes.Stloc, vardef);
} else if (!typedef.IsValueType) {
var ctor = Module.Import(ctorinforef);
diff --git a/Xamarin.Forms.Build.Tasks/MethodReferenceExtensions.cs b/Xamarin.Forms.Build.Tasks/MethodReferenceExtensions.cs
index 13b4aaf..e3b2f3a 100644
--- a/Xamarin.Forms.Build.Tasks/MethodReferenceExtensions.cs
+++ b/Xamarin.Forms.Build.Tasks/MethodReferenceExtensions.cs
@@ -13,9 +13,9 @@ namespace Xamarin.Forms.Build.Tasks
if (declaringTypeRef == null)
throw new ArgumentNullException(nameof(declaringTypeRef));
- var reference = new MethodReference(self.Name, self.ReturnType)
+ var reference = new MethodReference(self.Name, module.Import(self.ReturnType))
{
- DeclaringType = declaringTypeRef,
+ DeclaringType = module.Import(declaringTypeRef),
HasThis = self.HasThis,
ExplicitThis = self.ExplicitThis,
CallingConvention = self.CallingConvention
diff --git a/Xamarin.Forms.Build.Tasks/TypeReferenceExtensions.cs b/Xamarin.Forms.Build.Tasks/TypeReferenceExtensions.cs
index 9e1cc16..a347c2f 100644
--- a/Xamarin.Forms.Build.Tasks/TypeReferenceExtensions.cs
+++ b/Xamarin.Forms.Build.Tasks/TypeReferenceExtensions.cs
@@ -21,7 +21,15 @@ namespace Xamarin.Forms.Build.Tasks
public bool Equals(TypeReference x, TypeReference y)
{
- return GetAssembly(x) == GetAssembly(y) && x.FullName == y.FullName;
+ if (x.FullName != y.FullName)
+ return false;
+ var xasm = GetAssembly(x);
+ if (xasm.StartsWith("System.Runtime", StringComparison.Ordinal) || xasm.StartsWith("mscorlib", StringComparison.Ordinal))
+ xasm = "mscorlib";
+ var yasm = GetAssembly(y);
+ if (yasm.StartsWith("System.Runtime", StringComparison.Ordinal) || yasm.StartsWith("mscorlib", StringComparison.Ordinal))
+ yasm = "mscorlib";
+ return xasm == yasm;
}
public int GetHashCode(TypeReference obj)