-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix generic resolution for interfaces with generic array types. - fix #10583
- Loading branch information
1 parent
f04c5af
commit 0e4cf32
Showing
5 changed files
with
108 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:d="http://schemas.microsoft.com/dotnet/2021/maui/design" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:local="clr-namespace:Microsoft.Maui.Controls.Xaml.UnitTests" | ||
x:Class="Microsoft.Maui.Controls.Xaml.UnitTests.Maui10583"> | ||
<ListView x:Name="lv" ItemsSource="{local:Maui10583EnumValues x:TypeArguments=local:Maui10583Enum}" /> | ||
</ContentPage> |
75 changes: 75 additions & 0 deletions
75
src/Controls/tests/Xaml.UnitTests/Issues/Maui10583.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using System; | ||
using Microsoft.Maui.ApplicationModel; | ||
using Microsoft.Maui.Controls.Core.UnitTests; | ||
using Microsoft.Maui.Devices; | ||
using Microsoft.Maui.Graphics; | ||
using Microsoft.Maui.UnitTests; | ||
using Microsoft.Maui.Dispatching; | ||
using NUnit.Framework; | ||
using System.Collections.Generic; | ||
|
||
namespace Microsoft.Maui.Controls.Xaml.UnitTests | ||
{ | ||
[AcceptEmptyServiceProvider] | ||
public class Maui10583EnumValuesExtension<T> : IMarkupExtension<T[]> where T : struct, Enum | ||
{ | ||
public T[] ProvideValue(IServiceProvider serviceProvider) | ||
{ | ||
return Enum.GetValues<T>(); | ||
} | ||
|
||
object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider) | ||
{ | ||
return ProvideValue(serviceProvider); | ||
} | ||
} | ||
|
||
public enum Maui10583Enum { | ||
John, Paul, George, Ringo | ||
} | ||
|
||
public partial class Maui10583 : ContentPage | ||
{ | ||
public Maui10583() => InitializeComponent(); | ||
public Maui10583(bool useCompiledXaml) | ||
{ | ||
//this stub will be replaced at compile time | ||
} | ||
|
||
[TestFixture] | ||
class Tests | ||
{ | ||
[SetUp] | ||
public void Setup() | ||
{ | ||
AppInfo.SetCurrent(new MockAppInfo()); | ||
DispatcherProvider.SetCurrent(new DispatcherProviderStub()); | ||
|
||
} | ||
|
||
[TearDown] | ||
public void TearDown() | ||
{ | ||
DispatcherProvider.SetCurrent(null); | ||
AppInfo.SetCurrent(null); | ||
} | ||
|
||
[Test] | ||
public void GenericMarkupExtensions([Values(false, true)] bool useCompiledXaml) | ||
{ | ||
if (true) | ||
{ | ||
MockCompiler.Compile(typeof(Maui10583), out var methodDefinition); | ||
|
||
} | ||
var page = new Maui10583(useCompiledXaml); | ||
|
||
Assert.That(page.lv.ItemsSource, Is.Not.Null); | ||
var items = page.lv.ItemsSource as Maui10583Enum[]; | ||
Assert.That(items[1], Is.EqualTo(Maui10583Enum.Paul)); | ||
|
||
|
||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters