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);
}
memberRef = propertyDef.PropertyType;
- var getterDef = propertyDef.GetMethod;
+ var getterDef = module.Import(propertyDef.GetMethod);
return new [] { Instruction.Create(OpCodes.Call, getterDef) };
}
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)) {
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;
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);
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
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)
using System;
using NUnit.Framework;
+using Xamarin.Forms.Core.UnitTests;
namespace Xamarin.Forms.Xaml.UnitTests
{
InitializeComponent ();
}
+ public BuiltInConversions(bool useCompiledXaml)
+ {
+ //this stub will be replaced at compile time
+ }
+
[TestFixture]
public class Tests
{
- [Test]
- public void Datetime ()
+ [SetUp]
+ public void Setup()
+ {
+ Device.PlatformServices = new MockPlatformServices();
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ Device.PlatformServices = null;
+ }
+
+ [TestCase(false)]
+ [TestCase(true)]
+ public void Datetime (bool useCompiledXaml)
{
- var layout = new BuiltInConversions ();
+ var layout = new BuiltInConversions (useCompiledXaml);
Assert.AreEqual (new DateTime (2015, 01, 16), layout.datetime0.Date);
Assert.AreEqual (new DateTime (2015, 01, 16), layout.datetime1.Date);
}
- [Test]
- public void String ()
+ [TestCase(false)]
+ [TestCase(true)]
+ public void String (bool useCompiledXaml)
{
- var layout = new BuiltInConversions ();
+ var layout = new BuiltInConversions (useCompiledXaml);
Assert.AreEqual ("foobar", layout.label0.Text);
Assert.AreEqual ("foobar", layout.label1.Text);
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
+ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+ xmlns:sys="clr-namespace:System;assembly=mscorlib"
+ x:Class="Xamarin.Forms.Xaml.UnitTests.Unreported008">
+ <DatePicker Date="{x:Static sys:DateTime.Now}" x:Name="picker0">
+ <DatePicker.Format>yyyy-MM-dd</DatePicker.Format>
+ <DatePicker.MinimumDate>
+ <sys:DateTime x:FactoryMethod="Parse">
+ <x:Arguments>
+ <x:String>Jan 1 2000</x:String>
+ </x:Arguments>
+ </sys:DateTime>
+ </DatePicker.MinimumDate>
+ <DatePicker.MaximumDate>
+ <sys:DateTime x:FactoryMethod="Parse">
+ <x:Arguments>
+ <x:String>Dec 31 2050</x:String>
+ </x:Arguments>
+ </sys:DateTime>
+ </DatePicker.MaximumDate>
+ </DatePicker>
+</ContentPage>
\ No newline at end of file
--- /dev/null
+using System;
+using NUnit.Framework;
+using Xamarin.Forms.Core.UnitTests;
+
+namespace Xamarin.Forms.Xaml.UnitTests
+{
+ [XamlCompilation(XamlCompilationOptions.Skip)]
+ public partial class Unreported008 : ContentPage
+ {
+ public Unreported008()
+ {
+ InitializeComponent();
+ }
+
+ public Unreported008(bool useCompiledXaml)
+ {
+ //this stub will be replaced at compile time
+ }
+
+ [TestFixture]
+ class Tests
+ {
+ [SetUp]
+ public void Setup()
+ {
+ Device.PlatformServices = new MockPlatformServices();
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ Device.PlatformServices = null;
+ }
+
+ [TestCase(true), TestCase(false)]
+ public void PickerDateTimesAndXamlC(bool useCompiledXaml)
+ {
+ var page = new Unreported008(useCompiledXaml);
+ var picker = page.picker0;
+ Assert.AreEqual(DateTime.Today, picker.Date.Date);
+ Assert.AreEqual(new DateTime(2000, 1, 1), picker.MinimumDate);
+ Assert.AreEqual(new DateTime(2050, 12, 31), picker.MaximumDate);
+ }
+ }
+ }
+}
\ No newline at end of file
<Compile Include="Issues\Bz49307.xaml.cs">
<DependentUpon>Bz49307.xaml</DependentUpon>
</Compile>
+ <Compile Include="Issues\Unreported008.xaml.cs">
+ <DependentUpon>Unreported008.xaml</DependentUpon>
+ </Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="..\.nuspec\Xamarin.Forms.Debug.targets" />
<EmbeddedResource Include="Issues\Bz49307.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
+ <EmbeddedResource Include="Issues\Unreported008.xaml">
+ <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+ </EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />