зеркало из https://github.com/DeGsoft/maui-linux.git
* Add fake Platform property to Page to keep Previewer happy: fixes #4351 * Make the fake Platform property internal * Add unit tests to verify Previewer-required stuff in Core has not be changed * Adding Obsolete to Page.Platform
This commit is contained in:
Родитель
63f34daa00
Коммит
003cc44549
|
@ -0,0 +1,42 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Xamarin.Forms.Core.UnitTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class PreviewerReflectionTests
|
||||
{
|
||||
[Test]
|
||||
public void PageHasPlatformProperty()
|
||||
{
|
||||
var page = new Page();
|
||||
|
||||
var setPlatform = page.GetType ().GetProperty ("Platform", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
Assert.That(setPlatform, Is.Not.Null, "Previewer requires that Page have a property called 'Platform'");
|
||||
|
||||
TestDelegate setValue = () => setPlatform.SetValue(page, new object(), null);
|
||||
Assert.That(setValue, Throws.Nothing, "'Page.Platform' must have a setter");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RegisterAllExists()
|
||||
{
|
||||
var type = typeof(Registrar);
|
||||
|
||||
var methods = type.GetMethods(BindingFlags.Static | BindingFlags.NonPublic);
|
||||
var method = methods.Single(t =>
|
||||
{
|
||||
var parameters = t.GetParameters();
|
||||
|
||||
return t.Name == "RegisterAll"
|
||||
&& parameters.Length == 1
|
||||
&& parameters[0].ParameterType == typeof(Type[]);
|
||||
});
|
||||
|
||||
Assert.That(method, Is.Not.Null, "Previewer requires that Registrar have a static non-public method "
|
||||
+ "'RegisterAll' which takes a single parameter of Type[]");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -80,6 +80,7 @@
|
|||
<Compile Include="ImageButtonUnitTest.cs" />
|
||||
<Compile Include="LayoutChildIntoBoundingRegionTests.cs" />
|
||||
<Compile Include="MenuUnitTests.cs" />
|
||||
<Compile Include="PreviewerReflectionTests.cs" />
|
||||
<Compile Include="RegionTests.cs" />
|
||||
<Compile Include="SpanTests.cs" />
|
||||
<Compile Include="TitleViewUnitTests.cs" />
|
||||
|
|
|
@ -437,5 +437,12 @@ namespace Xamarin.Forms
|
|||
|
||||
_titleView = newTitleView;
|
||||
}
|
||||
|
||||
// This is a dummy property for the Previewer
|
||||
// Platform isn't needed anymore, but the Previewer will still try to set it via reflection
|
||||
// and throw an NRE if it's not available; this fake property keeps it happy.
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[Obsolete("This property is no longer used as of version 3.4.")]
|
||||
internal object Platform { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче