зеркало из https://github.com/DeGsoft/maui-linux.git
Родитель
e38776cdec
Коммит
3b6374893b
|
@ -392,7 +392,11 @@ namespace Xamarin.Forms.Build.Tasks
|
||||||
yield break; //throw
|
yield break; //throw
|
||||||
|
|
||||||
var properties = ParsePath(path, tSourceRef, node as IXmlLineInfo, module);
|
var properties = ParsePath(path, tSourceRef, node as IXmlLineInfo, module);
|
||||||
var tPropertyRef = properties != null && properties.Any() ? properties.Last().Item1.PropertyType : tSourceRef;
|
TypeReference tPropertyRef = tSourceRef;
|
||||||
|
if (properties != null && properties.Count > 0) {
|
||||||
|
var lastProp = properties[properties.Count - 1];
|
||||||
|
tPropertyRef = lastProp.property.ResolveGenericPropertyType(lastProp.propDeclTypeRef, module);
|
||||||
|
}
|
||||||
tPropertyRef = module.ImportReference(tPropertyRef);
|
tPropertyRef = module.ImportReference(tPropertyRef);
|
||||||
|
|
||||||
var funcRef = module.ImportReference(module.ImportReference(("mscorlib", "System", "Func`2")).MakeGenericInstanceType(new [] { tSourceRef, tPropertyRef }));
|
var funcRef = module.ImportReference(module.ImportReference(("mscorlib", "System", "Func`2")).MakeGenericInstanceType(new [] { tSourceRef, tPropertyRef }));
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?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:local="using:Xamarin.Forms.Xaml.UnitTests"
|
||||||
|
x:Class="Xamarin.Forms.Xaml.UnitTests.Gh4438"
|
||||||
|
x:DataType="local:Gh4438VM">
|
||||||
|
<Label x:Name="label" Text="{Binding SelectedItem}" />
|
||||||
|
</ContentPage>
|
|
@ -0,0 +1,62 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
using Xamarin.Forms.Core.UnitTests;
|
||||||
|
|
||||||
|
namespace Xamarin.Forms.Xaml.UnitTests
|
||||||
|
{
|
||||||
|
public class Gh4438VM : Gh4438VMBase<string>
|
||||||
|
{
|
||||||
|
public Gh4438VM()
|
||||||
|
{
|
||||||
|
Add("test");
|
||||||
|
SelectedItem = this.First();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Gh4438VMBase<T> : Collection<string>
|
||||||
|
{
|
||||||
|
public virtual T SelectedItem { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public partial class Gh4438 : ContentPage
|
||||||
|
{
|
||||||
|
public Gh4438()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Gh4438(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 GenericBaseClassResolution(bool useCompiledXaml)
|
||||||
|
{
|
||||||
|
if (useCompiledXaml)
|
||||||
|
Assert.DoesNotThrow(() => MockCompiler.Compile(typeof(Gh4438)));
|
||||||
|
var layout = new Gh4438(useCompiledXaml) { BindingContext = new Gh4438VM() };
|
||||||
|
Assert.That(layout.label.Text, Is.EqualTo("test"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Загрузка…
Ссылка в новой задаче