Skip to content

Commit 7f3fc6a

Browse files
authored
Merge pull request #144 from unoplatform/dev/jela/doc-update
Update `Link` support docs
2 parents 528874f + 9c16566 commit 7f3fc6a

File tree

5 files changed

+56
-4
lines changed

5 files changed

+56
-4
lines changed

doc/using-xamlmerge.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ To limit the impact of the traversal, this task takes all resource dictionaries
6565
1. By default, the generated file is called `Generated\mergedpages.xaml`, but can be overridden as follows:
6666

6767
```xml
68-
<PropertyGroup>
69-
<XamlMergeOutputFile>Themes\Generic.xaml</XamlMergeOutputFile>
70-
</PropertyGroup>
68+
<ItemGroup>
69+
<XamlMergeOutputFiles Include="Themes\Generic.xaml" />
70+
</ItemGroup>
7171
```
7272

7373
1. The generated file can be referenced as follows:
@@ -86,6 +86,18 @@ To limit the impact of the traversal, this task takes all resource dictionaries
8686

8787
Then replace `REPLACE_ME/` with either the library name if you're adding the package to a class library, or with nothing if you're adding it to your main project (e.g. `ms-appx:///Generated/mergedpages.xaml`).
8888

89+
1. If your project is multi-targeted and that your set of input files is different for each target, the output file for each target must be placed in the intermediate output to avoid breaking the incremental compilation:
90+
91+
```xml
92+
<ItemGroup>
93+
<XamlMergeOutputFiles
94+
Include="$(IntermediateOutputPath)\Themes\Generic.xaml"
95+
Link="Themes\Generic.xaml" />
96+
</ItemGroup>
97+
```
98+
99+
The `Link` value is the path that can be used in the `ResourceDictionary.Source` property.
100+
89101
## Multiple generated files
90102

91103
There are scenarios where placing groups of XAML files in separate merged files are useful, particularly, when IL Linking must be used.

src/Uno.XamlMerge.Tests/Given_BatchMergeXaml.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@ public void When_HR_Enabled_Main_App()
4747
ValidateOutput(task);
4848
}
4949

50+
[TestMethod]
51+
public void When_HR_Enabled_Main_App_No_Overwrite()
52+
{
53+
var task = CreateMerger(isHotReloadEnabled: true, isMainAssembly: true);
54+
55+
Assert.IsTrue(task.Execute());
56+
57+
var originalFiles = task.MergedXamlFiles.Select(f => new FileInfo(f.ItemSpec).LastWriteTimeUtc).ToArray();
58+
59+
Assert.IsTrue(task.Execute());
60+
61+
var newFiles = task.MergedXamlFiles.Select(f => new FileInfo(f.ItemSpec).LastWriteTimeUtc).ToArray();
62+
63+
Assert.IsTrue(originalFiles.SequenceEqual(newFiles));
64+
}
65+
5066
[TestMethod]
5167
public void When_Key_TargeType_Conflict()
5268
{
@@ -107,7 +123,6 @@ public void When_Duplicate_ThemeResources_With_Prefix()
107123
ValidateOutput(task);
108124
}
109125

110-
111126
[TestMethod]
112127
public void When_Duplicate_ThemeResources_With_Ignored_Prefix()
113128
{
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<ResourceDictionary
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
5+
6+
<x:String x:Key="Key1">Value1</x:String>
7+
</ResourceDictionary>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<ResourceDictionary
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
5+
6+
<x:String x:Key="Key2">Value2</x:String>
7+
</ResourceDictionary>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- Generating a resource dictionary that references existing dictionaries for HotReload support -->
2+
<!-- Proper merging of XAML files will happen if you build in Release configuration -->
3+
<ResourceDictionary
4+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
6+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
7+
<ResourceDictionary.MergedDictionaries>
8+
<ResourceDictionary Source="ms-appx:///TestAssemblyName/When_HR_Enabled/Input_Dictionary_1.xml" />
9+
<ResourceDictionary Source="ms-appx:///TestAssemblyName/When_HR_Enabled/Input_Dictionary_2.xml" />
10+
</ResourceDictionary.MergedDictionaries>
11+
</ResourceDictionary>

0 commit comments

Comments
 (0)