Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[X] Fix XamlCompilation of RD subclasses
Fix an issue when compiling a non-direct descendant of RD - fixes #19535
- Loading branch information
1 parent
b43f265
commit f39eaf9
Showing
3 changed files
with
71 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
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,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<local:Maui19535CustomThemeDictionary xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:local="clr-namespace:Microsoft.Maui.Controls.Xaml.UnitTests" | ||
x:Class="Microsoft.Maui.Controls.Xaml.UnitTests.Maui19535"> | ||
|
||
<x:String x:Key="CustomTheme">LightTheme</x:String> | ||
<Color x:Key="PrimaryBackground">#6750A4</Color> | ||
<Color x:Key="ContentBackground">#FFFBFE</Color> | ||
|
||
</local:Maui19535CustomThemeDictionary> |
59 changes: 59 additions & 0 deletions
59
src/Controls/tests/Xaml.UnitTests/Issues/Maui19535.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,59 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Globalization; | ||
using System.Linq; | ||
using Microsoft.Maui.ApplicationModel; | ||
using Microsoft.Maui.Controls.Core.UnitTests; | ||
using Microsoft.Maui.Controls.Shapes; | ||
using Microsoft.Maui.Devices; | ||
using Microsoft.Maui.Dispatching; | ||
|
||
using Microsoft.Maui.Graphics; | ||
using Microsoft.Maui.UnitTests; | ||
using NUnit.Framework; | ||
|
||
namespace Microsoft.Maui.Controls.Xaml.UnitTests; | ||
|
||
public class Maui19535CustomThemeDictionary : ResourceDictionary | ||
{ | ||
|
||
} | ||
|
||
public partial class Maui19535 : Maui19535CustomThemeDictionary | ||
{ | ||
public Maui19535() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public Maui19535(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 SubClassOfRDShouldNotThrow([Values(false, true)] bool useCompiledXaml) | ||
{ | ||
if (useCompiledXaml) | ||
MockCompiler.Compile(typeof(Maui19535)); | ||
var rd = new Maui19535(useCompiledXaml); | ||
Assert.That(rd.Count, Is.EqualTo(3)); | ||
Assert.True(rd.TryGetValue("CustomTheme", out var theme)); | ||
Assert.That(theme, Is.EqualTo("LightTheme")); | ||
} | ||
} | ||
|
||
} |