Skip to content

Commit

Permalink
Merge pull request unoplatform#4986 from unoplatform/dev/djo/resource…
Browse files Browse the repository at this point in the history
…dictionary-fix-2

Fix ResourceDictionary.Source resolution when globbed includes are defined in an included file
  • Loading branch information
davidjohnoliver authored Jan 21, 2021
2 parents eb97cad + b1d4741 commit c78a700
Show file tree
Hide file tree
Showing 11 changed files with 198 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/Common_ViewLibraryProps/Globbing.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project ToolsVersion="Current">
<ItemGroup>
<Page Include="**\*.xaml" Exclude="bin\**\*.xaml;obj\**\*.xaml" />
<Compile Update="**\*.xaml.cs">
<DependentUpon>%(Filename)</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<UpToDateCheckInput Include="**\*.xaml" Exclude="bin\**\*.xaml;obj\**\*.xaml" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@

<CompilerVisibleItemMetadata Include="AdditionalFiles" MetadataName="SourceItemGroup" />
<CompilerVisibleItemMetadata Include="AdditionalFiles" MetadataName="Link" />
<CompilerVisibleItemMetadata Include="AdditionalFiles" MetadataName="FullPath" />
<CompilerVisibleItemMetadata Include="AdditionalFiles" MetadataName="FullPath" />
<CompilerVisibleItemMetadata Include="AdditionalFiles" MetadataName="Identity" />
</ItemGroup>

</When>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ private string GetSourceLink(MSBuildItem projectItemInstance)
{
link = fullPath.Substring(definingProjectDirectory.Length);
}
else
{
link = projectItemInstance.GetMetadataValue("Identity");
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/Uno.UI-UnitTests-only.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"T4Generator\\T4Generator.csproj",
"Uno.Foundation\\Uno.Foundation.csproj",
"Uno.UI.FluentTheme\\Uno.UI.FluentTheme.csproj",
"Uno.UI.Tests.ViewLibraryProps\\Uno.UI.Tests.ViewLibraryProps.csproj",
"Uno.UI.Tests.ViewLibrary\\Uno.UI.Tests.ViewLibrary.csproj",
"Uno.UI.Tests\\Uno.UI.Tests.csproj",
"Uno.UI\\Uno.UI.csproj",
Expand Down
8 changes: 8 additions & 0 deletions src/Uno.UI.Tests.ViewLibraryProps/Themes/Button.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<Style x:Key="GlobPropsMarginButtonStyle" TargetType="Button">
<Setter Property="Margin"
Value="99,33,7,7" />
</Style>
</ResourceDictionary>
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<TargetFrameworks>net461</TargetFrameworks>
<NoWarn>1998;4014;67</NoWarn>
<OutputPath>bin\$(Platform)\$(Configuration)</OutputPath>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<ImportFrameworkWinFXTargets>false</ImportFrameworkWinFXTargets>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineConstants>TRACE;DEBUG;HAS_UMBRELLA_BINDING;IS_UNIT_TESTS;HAS_GEOCOORDINATE_WATCHER;HAS_GEOCOORDINATE;HAS_COMPILED_REGEX;HAS_ISTORAGEFILE;HAS_SEMAPHORE;HAS_FILE_IO;IS_UNO;HAS_CRIPPLEDREFLECTION;NET46</DefineConstants>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineConstants>TRACE;HAS_UMBRELLA_BINDING;IS_UNIT_TESTS;HAS_GEOCOORDINATE_WATCHER;HAS_GEOCOORDINATE;HAS_COMPILED_REGEX;HAS_ISTORAGEFILE;HAS_SEMAPHORE;HAS_FILE_IO;IS_UNO;HAS_CRIPPLEDREFLECTION</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" />
<PackageReference Include="System.Collections.Immutable">
<Version>1.7.0</Version>
</PackageReference>
<PackageReference Include="Uno.SourceGenerationTasks" />
<PackageReference Include="Uno.Core" />
</ItemGroup>

<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="WindowsBase" />
</ItemGroup>

<PropertyGroup>
<UnoUIMSBuildTasksPath>$(MSBuildThisFileDirectory)..\SourceGenerators\Uno.UI.Tasks\bin\$(Configuration)_Shadow</UnoUIMSBuildTasksPath>
<UnoForceProcessPRIResource>true</UnoForceProcessPRIResource>
</PropertyGroup>

<Import Project="..\SourceGenerators\Uno.UI.SourceGenerators\Content\Uno.UI.SourceGenerators.props" />
<Import Project="..\SourceGenerators\Uno.UI.Tasks\Content\Uno.UI.Tasks.targets" Condition="'$(SkipUnoResourceGeneration)' == '' " />

<Target Name="BeforeBuildCleanup" BeforeTargets="XamlMarkupCompilePass1;_UnoSourceGenerator" />

<Import Project="..\Common.targets" />

<Import Project="..\Common_ViewLibraryProps\Globbing.props" />

<ItemGroup>
<ProjectReference Include="..\SourceGenerators\System.Xaml\Uno.Xaml.csproj" />
<ProjectReference Include="..\Uno.UI\Uno.UI.csproj" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions src/Uno.UI.Tests/Uno.UI.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
<ProjectReference Include="..\SourceGenerators\System.Xaml\Uno.Xaml.csproj" />
<ProjectReference Include="..\Uno.UI.FluentTheme\Uno.UI.FluentTheme.csproj" />
<ProjectReference Include="..\Uno.UI.Tests.ViewLibrary\Uno.UI.Tests.ViewLibrary.csproj" />
<ProjectReference Include="..\Uno.UI.Tests.ViewLibraryProps\Uno.UI.Tests.ViewLibraryProps.csproj" />
<ProjectReference Include="..\Uno.UI\Uno.UI.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<UserControl
x:Class="Uno.UI.Tests.Windows_UI_Xaml.Controls.When_Source_And_Globbing_From_Included_File"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Uno.UI.Tests.Windows_UI_Xaml.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">
<UserControl.Resources>
<ResourceDictionary Source="ms-appx:///Uno.UI.Tests.ViewLibraryProps/Themes/Button.xaml"/>
</UserControl.Resources>

<Grid>

</Grid>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236

namespace Uno.UI.Tests.Windows_UI_Xaml.Controls
{
public sealed partial class When_Source_And_Globbing_From_Included_File : UserControl
{
public When_Source_And_Globbing_From_Included_File()
{
this.InitializeComponent();
}
}
}
13 changes: 13 additions & 0 deletions src/Uno.UI.Tests/Windows_UI_Xaml/Given_ResourceDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -735,5 +735,18 @@ public void When_Only_Theme_Dictionaries()
var tb = page.ThemeDictionaryOnlyTextBlock;
Assert.AreEqual(Colors.MediumPurple, (tb.Foreground as SolidColorBrush).Color);
}

[TestMethod]
public void When_Source_And_Globbing_From_Included_File()
{
var ctrl = new When_Source_And_Globbing_From_Included_File();
var resources = ctrl.Resources;
Assert.IsTrue(resources.ContainsKey("GlobPropsMarginButtonStyle"));

var style = resources["GlobPropsMarginButtonStyle"] as Style;
var button = new Button();
button.Style = style;
Assert.AreEqual(new Thickness(99, 33, 7, 7), button.Margin);
}
}
}
45 changes: 45 additions & 0 deletions src/Uno.UI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Uno.UI.FluentTheme", "Uno.U
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Uno.UI.FluentTheme.Skia", "Uno.UI.FluentTheme\Uno.UI.FluentTheme.Skia.csproj", "{E7113F80-584B-4DF1-9BF0-166BB453B807}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Uno.UI.Tests.ViewLibraryProps", "Uno.UI.Tests.ViewLibraryProps\Uno.UI.Tests.ViewLibraryProps.csproj", "{68090F3E-ACE3-49D0-BC68-151F8A92A38B}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
SamplesApp\SamplesApp.UnitTests.Shared\SamplesApp.UnitTests.Shared.projitems*{04b1b5eb-d42e-47de-ada0-eb863e5574fd}*SharedItemsImports = 13
Expand Down Expand Up @@ -3598,6 +3600,48 @@ Global
{E7113F80-584B-4DF1-9BF0-166BB453B807}.Release|x64.Build.0 = Release|Any CPU
{E7113F80-584B-4DF1-9BF0-166BB453B807}.Release|x86.ActiveCfg = Release|Any CPU
{E7113F80-584B-4DF1-9BF0-166BB453B807}.Release|x86.Build.0 = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Debug|ARM.ActiveCfg = Debug|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Debug|ARM.Build.0 = Debug|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Debug|ARM64.Build.0 = Debug|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Debug|iPhone.Build.0 = Debug|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Debug|x64.ActiveCfg = Debug|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Debug|x64.Build.0 = Debug|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Debug|x86.ActiveCfg = Debug|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Debug|x86.Build.0 = Debug|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release_NoSamples|Any CPU.ActiveCfg = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release_NoSamples|Any CPU.Build.0 = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release_NoSamples|ARM.ActiveCfg = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release_NoSamples|ARM.Build.0 = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release_NoSamples|ARM64.ActiveCfg = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release_NoSamples|ARM64.Build.0 = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release_NoSamples|iPhone.ActiveCfg = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release_NoSamples|iPhone.Build.0 = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release_NoSamples|iPhoneSimulator.ActiveCfg = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release_NoSamples|iPhoneSimulator.Build.0 = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release_NoSamples|x64.ActiveCfg = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release_NoSamples|x64.Build.0 = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release_NoSamples|x86.ActiveCfg = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release_NoSamples|x86.Build.0 = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release|Any CPU.Build.0 = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release|ARM.ActiveCfg = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release|ARM.Build.0 = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release|ARM64.ActiveCfg = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release|ARM64.Build.0 = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release|iPhone.ActiveCfg = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release|iPhone.Build.0 = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release|x64.ActiveCfg = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release|x64.Build.0 = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release|x86.ActiveCfg = Release|Any CPU
{68090F3E-ACE3-49D0-BC68-151F8A92A38B}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -3691,6 +3735,7 @@ Global
{10807E33-4A73-4AA9-A8F2-B395CC555BD1} = {416684CF-A4E3-4079-B380-3FF0B00E433C}
{535339E2-6C01-4478-9889-F6E76B1C00F4} = {416684CF-A4E3-4079-B380-3FF0B00E433C}
{E7113F80-584B-4DF1-9BF0-166BB453B807} = {416684CF-A4E3-4079-B380-3FF0B00E433C}
{68090F3E-ACE3-49D0-BC68-151F8A92A38B} = {416684CF-A4E3-4079-B380-3FF0B00E433C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9B2608F4-D82B-4B72-B399-33E822DF01D0}
Expand Down

0 comments on commit c78a700

Please sign in to comment.