зеркало из https://github.com/DeGsoft/maui-linux.git
[Xaml[C]] avoid processing nested RD multiple times (#1300)
This commit is contained in:
Родитель
9ebd062f84
Коммит
2f84a94360
|
@ -46,9 +46,14 @@ namespace Xamarin.Forms.Build.Tasks
|
|||
}
|
||||
}
|
||||
|
||||
if (parentNode is IElementNode && IsResourceDictionary((IElementNode)parentNode))
|
||||
//Only proceed further if the node is a keyless RD
|
||||
if ( parentNode is IElementNode
|
||||
&& IsResourceDictionary((IElementNode)parentNode)
|
||||
&& !((IElementNode)parentNode).Properties.ContainsKey(XmlName.xKey))
|
||||
node.Accept(new SetPropertiesVisitor(Context, stopOnResourceDictionary: false), parentNode);
|
||||
else if (parentNode is ListNode && IsResourceDictionary((IElementNode)parentNode.Parent))
|
||||
else if ( parentNode is ListNode
|
||||
&& IsResourceDictionary((IElementNode)parentNode.Parent)
|
||||
&& !((IElementNode)parentNode.Parent).Properties.ContainsKey(XmlName.xKey))
|
||||
node.Accept(new SetPropertiesVisitor(Context, stopOnResourceDictionary: false), parentNode);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="Xamarin.Forms.Xaml.UnitTests.Bz60788">
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary x:Key="RedTextBlueBackground">
|
||||
<Style TargetType="StackLayout">
|
||||
<Setter Property="BackgroundColor" Value="Blue" />
|
||||
</Style>
|
||||
<Style TargetType="Label">
|
||||
<Setter Property="TextColor" Value="Red" />
|
||||
</Style>
|
||||
<Color x:Key="notpink">Purple</Color>
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Key="BlueTextRedBackground">
|
||||
<Style TargetType="StackLayout">
|
||||
<Setter Property="BackgroundColor" Value="Red" />
|
||||
</Style>
|
||||
<Style TargetType="Label">
|
||||
<Setter Property="TextColor" Value="Blue" />
|
||||
</Style>
|
||||
<Color x:Key="notpink">Purple</Color>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary>
|
||||
</ContentPage.Resources>
|
||||
</ContentPage>
|
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using NUnit.Framework;
|
||||
using Xamarin.Forms.Core.UnitTests;
|
||||
|
||||
namespace Xamarin.Forms.Xaml.UnitTests
|
||||
{
|
||||
public partial class Bz60788 : ContentPage
|
||||
{
|
||||
public Bz60788()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public Bz60788(bool useCompiledXaml)
|
||||
{
|
||||
//this stub will be replaced at compile time
|
||||
}
|
||||
|
||||
[TestFixture]
|
||||
class Tests
|
||||
{
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Device.PlatformServices = new MockPlatformServices();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
Device.PlatformServices = null;
|
||||
}
|
||||
|
||||
[TestCase(true), TestCase(false)]
|
||||
public void KeyedRDWithImplicitStyles(bool useCompiledXaml)
|
||||
{
|
||||
var layout = new Bz60788(useCompiledXaml);
|
||||
Assert.That(layout.Resources.Count, Is.EqualTo(2));
|
||||
Assert.That(((ResourceDictionary)layout.Resources["RedTextBlueBackground"]).Count, Is.EqualTo(3));
|
||||
Assert.That(((ResourceDictionary)layout.Resources["BlueTextRedBackground"]).Count, Is.EqualTo(3));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -508,6 +508,9 @@
|
|||
<Compile Include="Issues\Bz59818.xaml.cs">
|
||||
<DependentUpon>Bz59818.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Issues\Bz60788.xaml.cs">
|
||||
<DependentUpon>Bz60788.xaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\.nuspec\Xamarin.Forms.Debug.targets" />
|
||||
|
@ -931,6 +934,9 @@
|
|||
<EmbeddedResource Include="Issues\Bz59818.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Issues\Bz60788.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
||||
|
|
|
@ -47,10 +47,14 @@ namespace Xamarin.Forms.Xaml
|
|||
}
|
||||
}
|
||||
|
||||
//Only proceed further if the node is a RD
|
||||
if (parentNode is IElementNode && typeof(ResourceDictionary).IsAssignableFrom(Context.Types[((IElementNode)parentNode)]))
|
||||
//Only proceed further if the node is a keyless RD
|
||||
if ( parentNode is IElementNode
|
||||
&& typeof(ResourceDictionary).IsAssignableFrom(Context.Types[((IElementNode)parentNode)])
|
||||
&& !((IElementNode)parentNode).Properties.ContainsKey(XmlName.xKey))
|
||||
node.Accept(new ApplyPropertiesVisitor(Context, stopOnResourceDictionary: false), parentNode);
|
||||
else if (parentNode is ListNode && typeof(ResourceDictionary).IsAssignableFrom(Context.Types[((IElementNode)parentNode.Parent)]))
|
||||
else if ( parentNode is ListNode
|
||||
&& typeof(ResourceDictionary).IsAssignableFrom(Context.Types[((IElementNode)parentNode.Parent)])
|
||||
&& !((IElementNode)parentNode.Parent).Properties.ContainsKey(XmlName.xKey))
|
||||
node.Accept(new ApplyPropertiesVisitor(Context, stopOnResourceDictionary: false), parentNode);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче