-
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.
[C] respect specificity while overriding DynRes (#24306)
fixes an unreported issue
- Loading branch information
1 parent
73c2987
commit 87ddfcc
Showing
3 changed files
with
64 additions
and
1 deletion.
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
15 changes: 15 additions & 0 deletions
15
src/Controls/tests/Xaml.UnitTests/Issues/Unreported010.xaml
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,15 @@ | ||
<?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" | ||
x:Class="Microsoft.Maui.Controls.Xaml.UnitTests.Unreported010"> | ||
<ContentPage.Resources> | ||
<Color x:Key="Foo">Blue</Color> | ||
<Style TargetType="Button"> | ||
<Setter Property="BackgroundColor" Value="{DynamicResource Foo}"/> | ||
</Style> | ||
</ContentPage.Resources> | ||
|
||
<VerticalStackLayout> | ||
<Button x:Name="button0" Text="Hello World" BackgroundColor="{DynamicResource Foo}"/> | ||
</VerticalStackLayout> | ||
</ContentPage> |
47 changes: 47 additions & 0 deletions
47
src/Controls/tests/Xaml.UnitTests/Issues/Unreported010.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,47 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.Maui.ApplicationModel; | ||
using Microsoft.Maui.Graphics; | ||
using Microsoft.Maui.Controls.Core.UnitTests; | ||
using Microsoft.Maui.Dispatching; | ||
using Microsoft.Maui.UnitTests; | ||
using NUnit.Framework; | ||
|
||
namespace Microsoft.Maui.Controls.Xaml.UnitTests; | ||
|
||
public partial class Unreported010 | ||
{ | ||
public Unreported010() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public Unreported010(bool useCompiledXaml) | ||
{ | ||
//this stub will be replaced at compile time | ||
} | ||
|
||
[TestFixture] | ||
class Test | ||
{ | ||
[SetUp] | ||
public void Setup() | ||
{ | ||
Application.SetCurrentApplication(new MockApplication()); | ||
DispatcherProvider.SetCurrent(new DispatcherProviderStub()); | ||
} | ||
|
||
[TearDown] public void TearDown() => AppInfo.SetCurrent(null); | ||
|
||
[Test] | ||
public void LocalDynamicResources([Values(false, true)] bool useCompiledXaml) | ||
{ | ||
var page = new Unreported010(useCompiledXaml); | ||
Assert.That(page.button0.BackgroundColor, Is.EqualTo(Colors.Blue)); | ||
page.Resources["Foo"] = Colors.Red; | ||
Assert.That(page.button0.BackgroundColor, Is.EqualTo(Colors.Red)); | ||
} | ||
} | ||
|
||
|
||
} |