Skip to content

Commit

Permalink
[X] pass the logging helper to Template context (#17507)
Browse files Browse the repository at this point in the history
- fixes #17484
  • Loading branch information
StephaneDelcroix authored Sep 20, 2023
1 parent 63be80c commit 8d125c8
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1614,6 +1614,7 @@ static void SetDataTemplate(IElementNode parentNode, ElementNode node, ILContext
{
Root = root,
XamlFilePath = parentContext.XamlFilePath,
LoggingHelper = parentContext.LoggingHelper,
};

//Instanciate nested class
Expand Down
15 changes: 15 additions & 0 deletions src/Controls/tests/Xaml.UnitTests/Issues/Maui17484.xaml
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"
xmlns:local="clr-namespace:Microsoft.Maui.Controls.Xaml.UnitTests"
x:Class="Microsoft.Maui.Controls.Xaml.UnitTests.Maui17484">
<ContentPage.Resources>
<DataTemplate x:Key="Template">
<Image
Source="dotnet_bot.png"
AutomationProperties.Name="Cute dot net bot waving hi to you!"
HeightRequest="200"
HorizontalOptions="Center" />
</DataTemplate>
</ContentPage.Resources>
</ContentPage>
42 changes: 42 additions & 0 deletions src/Controls/tests/Xaml.UnitTests/Issues/Maui17484.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
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.Graphics;
using NUnit.Framework;

namespace Microsoft.Maui.Controls.Xaml.UnitTests;

public partial class Maui17484 : ContentPage
{

public Maui17484() => InitializeComponent();

public Maui17484(bool useCompiledXaml)
{
//this stub will be replaced at compile time
}

[TestFixture]
class Test
{
[SetUp] public void Setup() => AppInfo.SetCurrent(new MockAppInfo());
[TearDown] public void TearDown() => AppInfo.SetCurrent(null);

[Test]
public void ObsoleteinDT([Values(false, true)] bool useCompiledXaml)
{
if (useCompiledXaml)
Assert.DoesNotThrow(()=>MockCompiler.Compile(typeof(Maui17484)));
else
Assert.DoesNotThrow(()=>new Maui17484(useCompiledXaml));



}
}
}

0 comments on commit 8d125c8

Please sign in to comment.