Skip to content

Commit f2dc018

Browse files
committed
Merge branch 'main' into llama/transitionhelper
2 parents 072052c + 3bde759 commit f2dc018

File tree

113 files changed

+3143
-558
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+3143
-558
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,3 +432,6 @@ csharp_style_prefer_extended_property_pattern = true:suggestion
432432

433433
# Require file header
434434
dotnet_diagnostic.IDE0073.severity = warning
435+
436+
# Uno platform exposes IDisposable on Storyboard publicly when it should be internal. Ignore this.
437+
dotnet_code_quality.CA1001.excluded_type_names_with_derived_types = T:Windows.UI.Xaml.Media.Animation.Storyboard

.vscode/launch.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@
1414
"/p:UnoSourceGeneratorUseGenerationHost=true",
1515
"/p:UnoSourceGeneratorUseGenerationController=false",
1616
"/p:UnoRemoteControlPort=443",
17-
"--project=${workspaceFolder}/common/ProjectHeads/AllComponents/CommunityToolkit.Labs.Wasm/CommunityToolkit.Labs.Wasm.csproj"
17+
"--project=${workspaceFolder}/common/ProjectHeads/AllComponents/Wasm/CommunityToolkit.App.Wasm.csproj"
1818
],
1919
"presentation": {
2020
"group": "1",
2121
"order": 1
2222
},
23-
"cwd": "${workspaceFolder}/common/ProjectHeads/AllComponents/CommunityToolkit.Labs.Wasm",
23+
"cwd": "${workspaceFolder}/common/ProjectHeads/AllComponents/Wasm",
2424
"preLaunchTask": "generateAllSolution"
2525
},
2626
{
2727
"type": "PowerShell",
2828
"request": "launch",
2929
"name": "Discover samples",
30-
"script": "${workspaceFolder}/common/MultiTarget/GenerateAllProjectReferences.ps1; ${workspaceFolder}/common/GenerateVSCodeLaunchConfig.ps1; ",
30+
"script": "foreach ($component in Get-ChildItem -Directory -Depth 0 -Path './components/*') { ${workspaceFolder}/common/ProjectHeads/GenerateSingleSampleHeads.ps1 -ComponentPath $component } ; ${workspaceFolder}/common/GenerateVSCodeLaunchConfig.ps1; ",
3131
"presentation": {
3232
"group": "2",
3333
"order": 2

Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<Project>
22
<PropertyGroup>
3+
<PackageIdPrefix>CommunityToolkit.Labs</PackageIdPrefix>
34
<RepositoryDirectory>$(MSBuildThisFileDirectory)</RepositoryDirectory>
45
<EnableNETAnalyzers>true</EnableNETAnalyzers>
56
</PropertyGroup>

common/CommunityToolkit.App.Shared/App.xaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
1+
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
22
<Application x:Class="CommunityToolkit.App.Shared.App"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
@@ -23,6 +23,10 @@
2323

2424
<SolidColorBrush x:Key="BackgroundColorBrush"
2525
Color="{ThemeResource SolidBackgroundFillColorBase}" />
26+
<SolidColorBrush x:Key="WindowCaptionBackground"
27+
Color="Transparent" />
28+
<SolidColorBrush x:Key="WindowCaptionBackgroundDisabled"
29+
Color="Transparent" />
2630

2731
<!-- PathData for the GitHub icon -->
2832
<x:String x:Key="GithubIcon">M21.7999992370605,0L19.220495223999,0.26007080078125 16.81787109375,1.00595712661743 14.6436157226563,2.18616962432861 12.7492189407349,3.74921894073486 11.1861696243286,5.64361572265625 10.0059566497803,7.81787109375 9.26007080078125,10.2204961776733 9,12.8000001907349 9.65248012542725,16.8459720611572 11.4694375991821,20.3591785430908 14.2401514053345,23.1291217803955 17.7539005279541,24.9453010559082 18.4305686950684,24.8080005645752 18.6273498535156,24.3296756744385 18.6207065582275,23.4247951507568 18.609375,21.9468746185303 16.4340572357178,22.0373229980469 15.1187467575073,21.4822216033936 14.4708204269409,20.7821025848389 14.2976503372192,20.4375 13.8297338485718,19.5214366912842 13.3685493469238,18.947265625 12.8765497207642,18.5656261444092 12.3995819091797,18.1091804504395 12.4844465255737,17.87890625 12.7874250411987,17.7974605560303 12.9647998809814,17.7875003814697 13.8134965896606,18.0311241149902 14.4276065826416,18.4802703857422 14.8007507324219,18.9127178192139 14.926549911499,19.1062507629395 15.8880548477173,20.1437015533447 16.9443283081055,20.494140625 17.9229640960693,20.416259765625 18.6515502929688,20.1687507629395 18.9645938873291,19.1242198944092 19.4640502929688,18.4593753814697 17.3543262481689,18.0241260528564 15.4833002090454,17.014066696167 14.1450357437134,15.1450166702271 13.6336002349854,12.1328001022339 13.9853601455688,10.2268438339233 14.9500007629395,8.69764995574951 14.7027282714844,7.54188776016235 14.7441072463989,6.53565359115601 15.0765495300293,5.30859994888306 15.2825078964233,5.28076791763306 15.9191312789917,5.34375619888306 17.0145378112793,5.71729135513306 18.596851348877,6.62109994888306 21.799976348877,6.19062519073486 25.004674911499,6.62265014648438 26.5845413208008,5.71818733215332 27.6791000366211,5.34472513198853 28.315746307373,5.28210020065308 28.5218753814697,5.31015014648438 28.8556652069092,6.53784370422363 28.8976573944092,7.5438346862793 28.6499996185303,8.69764995574951 29.6154251098633,10.2268533706665 29.9656257629395,12.1328001022339 29.453296661377,15.1497011184692 28.1123065948486,17.0164012908936 26.2366523742676,18.020601272583 24.120325088501,18.4500007629395 24.7275562286377,19.3355484008789 24.9890747070313,20.8187503814697 24.9804744720459,23.0584030151367 24.9718742370605,24.3312511444092 25.1693305969238,24.8128852844238 25.8531246185303,24.9453010559082 29.3641395568848,23.1273632049561 32.1326217651367,20.3568344116211 33.948070526123,16.8442134857178 34.5999984741211,12.8000001907349 34.3399276733398,10.2204961776733 33.5940399169922,7.81787109375 32.4138298034668,5.64361572265625 30.8507804870605,3.74921894073486 28.9563827514648,2.18616962432861 26.7821273803711,1.00595712661743 24.3795032501221,0.26007080078125 21.7999992370605,0z</x:String>

common/GenerateAllSolution.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ Param (
3030

3131
# Generate required props for "All" solution.
3232
& ./common/MultiTarget/GenerateAllProjectReferences.ps1
33-
& ./common/GenerateVSCodeLaunchConfig.ps1
3433

3534
# Set up constant values
3635
$generatedSolutionFilePath = 'Toolkit.Labs.All.sln'

common/GenerateVSCodeLaunchConfig.ps1

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ function CreateVsCodeLaunchConfigJson {
2020
`"/p:UnoSourceGeneratorUseGenerationHost=true`",
2121
`"/p:UnoSourceGeneratorUseGenerationController=false`",
2222
`"/p:UnoRemoteControlPort=443`",
23-
`"--project=`$`{workspaceFolder`}/components/$projectName/samples/$projectName.Wasm/$projectName.Wasm.csproj`"
23+
`"--project=`$`{workspaceFolder`}/components/$projectName/heads/Wasm/$projectName.Wasm.csproj`"
2424
],
2525
`"presentation`": {
2626
`"group`": `"2`"
2727
},
28-
`"cwd`": `"`$`{workspaceFolder`}/components/$projectName/samples/$projectName.Wasm`"
28+
`"cwd`": `"`$`{workspaceFolder`}/components/$projectName/heads/Wasm`"
2929
}";
3030
}
3131

@@ -38,8 +38,10 @@ $launchConfig.configurations = @();
3838
$launchConfig.configurations += $originalConfigurations[0];
3939
$launchConfig.configurations += $originalConfigurations[1];
4040

41-
foreach ($wasmProjectPath in Get-ChildItem -Recurse -Path "$PSScriptRoot/../*/*/samples/*.Wasm/*.Wasm.csproj") {
42-
$projectName = [System.IO.Path]::GetFileNameWithoutExtension($wasmProjectPath) -Replace ".Wasm", "";
41+
& $PSScriptRoot/MultiTarget/GenerateAllProjectReferences.ps1 -MultiTarget 'wasm'
42+
43+
foreach ($projectPath in Get-ChildItem -Directory -Depth 0 -Path "$PSScriptRoot/../components/*") {
44+
$projectName = [System.IO.Path]::GetFileNameWithoutExtension($projectPath);
4345
Write-Host "Generating VSCode launch config for $projectName";
4446

4547
$configJson = CreateVsCodeLaunchConfigJson $projectName;

common/GlobalUsings_WinUI.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
global using System.Runtime.InteropServices.WindowsRuntime;
99

10-
global using CommunityToolkit.Labs.WinUI;
11-
1210
global using Windows.Foundation;
1311
global using Windows.Foundation.Collections;
1412

@@ -26,6 +24,7 @@
2624
global using Windows.UI.Xaml.Input;
2725
global using Windows.UI.Xaml.Markup;
2826
global using Windows.UI.Xaml.Media;
27+
global using Windows.UI.Xaml.Media.Animation;
2928
global using Windows.UI.Xaml.Navigation;
3029

3130
#else
@@ -40,6 +39,7 @@
4039
global using Microsoft.UI.Xaml.Input;
4140
global using Microsoft.UI.Xaml.Markup;
4241
global using Microsoft.UI.Xaml.Media;
42+
global using Microsoft.UI.Xaml.Media.Animation;
4343
global using Microsoft.UI.Xaml.Navigation;
4444
#endif
4545

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Param (
22
[Parameter(HelpMessage = "The directory where props files for discovered projects should be saved.")]
3-
[string]$projectPropsOutputDir = "$PSScriptRoot/Generated"
3+
[string]$projectPropsOutputDir = "$PSScriptRoot/Generated",
4+
5+
[Parameter(HelpMessage = "Only projects that support these targets will have references generated for use by deployable heads.")]
6+
[string[]] $MultiTarget = @("uwp", "wasdk", "wpf", "wasm", "linuxgtk", "macos", "ios", "android")
47
)
58

69
$preWorkingDir = $pwd;
@@ -12,35 +15,18 @@ New-Item -ItemType Directory -Force -Path $projectPropsOutputDir -ErrorAction Si
1215

1316
# Discover projects in provided paths
1417
foreach ($projectPath in Get-ChildItem -Directory -Depth 0 -Path "$PSScriptRoot/../../components/*") {
15-
# Normalize project path
16-
$projectName = $projectPath.Name;
17-
18-
# Folder layout is expected to match the Community Toolkit.
19-
# Uses the <MultiTarget> values from the source library project as the fallback for the sample project.
20-
# This behavior also implemented in MultiTarget.props for TargetFramework evaluation.
2118
$srcPath = Resolve-Path "$($projectPath.FullName)\src";
2219
$srcProjectPath = Get-ChildItem -File "$srcPath\*.csproj";
2320

2421
$samplePath = Resolve-Path "$($projectPath.FullName)\samples";
2522
$sampleProjectPath = Get-ChildItem -File "$samplePath\*.csproj";
2623

27-
if ($srcProjectPath.Length -eq 0) {
28-
Write-Error "Could not locate source csproj for $projectName";
29-
exit(-1);
30-
}
31-
32-
if ($sampleProjectPath.Length -eq 0) {
33-
Write-Error "Could not locate sample csproj for $projectName";
34-
exit(-1);
35-
}
36-
3724
# Generate <ProjectReference>s for sample project
3825
# Use source project MultiTarget as first fallback.
39-
& $PSScriptRoot\GenerateMultiTargetAwareProjectReferenceProps.ps1 -projectPath $sampleProjectPath -outputPath "$projectPropsOutputDir/$($sampleProjectPath.BaseName).props" -multiTargetFallbackPropsPath @("$srcPath/MultiTarget.props", "$samplePath/MultiTarget.props", "$PSScriptRoot/Defaults.props");
26+
& $PSScriptRoot\GenerateMultiTargetAwareProjectReferenceProps.ps1 -projectPath $sampleProjectPath -outputPath "$projectPropsOutputDir/$($sampleProjectPath.BaseName).props" -MultiTarget $MultiTarget
4027

4128
# Generate <ProjectReference>s for src project
42-
& $PSScriptRoot\GenerateMultiTargetAwareProjectReferenceProps.ps1 -projectPath $srcProjectPath -outputPath "$projectPropsOutputDir/$($srcProjectPath.BaseName).props" -multiTargetFallbackPropsPath @("$srcPath/MultiTarget.props", "$PSScriptRoot/Defaults.props");
29+
& $PSScriptRoot\GenerateMultiTargetAwareProjectReferenceProps.ps1 -projectPath $srcProjectPath -outputPath "$projectPropsOutputDir/$($srcProjectPath.BaseName).props" -MultiTarget $MultiTarget
4330
}
4431

45-
4632
Set-Location $preWorkingDir;

common/MultiTarget/GenerateMultiTargetAwareProjectReferenceProps.ps1

Lines changed: 22 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Param (
55
[Parameter(HelpMessage = "A path to a .props file where generated content should be saved to.", Mandatory = $true)]
66
[string]$outputPath,
77

8-
[Parameter(HelpMessage = "The path to the template used to generate the props file.")]
8+
[Parameter(HelpMessage = "The path to the template used to generate the props file.")]
99
[string]$templatePath = "$PSScriptRoot/MultiTargetAwareProjectReference.props.template",
1010

1111
[Parameter(HelpMessage = "The path to the props file that contains the default MultiTarget values.")]
@@ -15,7 +15,11 @@ Param (
1515
[string]$projectFileNamePlaceholder = "[ProjectFileName]",
1616

1717
[Parameter(HelpMessage = "The placeholder text to replace when inserting the project path into the template.")]
18-
[string]$projectRootPlaceholder = "[ProjectRoot]"
18+
[string]$projectRootPlaceholder = "[ProjectRoot]",
19+
20+
[Parameter(HelpMessage = "Only projects that support these targets will have references generated for use by deployable heads.")]
21+
[ValidateSet("uwp", "wasdk", "wpf", "wasm", "linuxgtk", "macos", "ios", "android")]
22+
[string[]] $MultiTarget = @("uwp", "wasdk", "wpf", "wasm", "linuxgtk", "macos", "ios", "android")
1923
)
2024

2125
$preWorkingDir = $pwd;
@@ -29,56 +33,31 @@ Set-Location $preWorkingDir;
2933
# Insert csproj file name.
3034
$csprojFileName = [System.IO.Path]::GetFileName($relativeProjectPath);
3135
$templateContents = $templateContents -replace [regex]::escape($projectFileNamePlaceholder), $csprojFileName;
36+
$projectName = (Get-Item (Split-Path -Parent $projectPath)).Name;
3237

3338
# Insert project directory
3439
$projectDirectoryRelativeToRoot = [System.IO.Path]::GetDirectoryName($relativeProjectPath).TrimStart('.').TrimStart('\');
3540
$templateContents = $templateContents -replace [regex]::escape($projectRootPlaceholder), "$projectDirectoryRelativeToRoot";
3641

37-
function LoadMultiTargetsFrom([string] $path) {
38-
$fileContents = "";
39-
40-
# If file does not exist
41-
if ($false -eq (Test-Path -Path $path -PathType Leaf)) {
42-
# Load first available default
43-
foreach ($fallbackPath in $multiTargetFallbackPropsPath) {
44-
if (Test-Path $fallbackPath) {
45-
$fileContents = Get-Content $fallbackPath -ErrorAction Stop;
46-
break;
47-
}
48-
}
49-
}
50-
else {
51-
# Load requested file
52-
$fileContents = Get-Content $path -ErrorAction Stop;
53-
}
54-
55-
# Parse file contents
56-
$regex = Select-String -Pattern '<MultiTarget>(.+?)<\/MultiTarget>' -InputObject $fileContents;
57-
58-
if ($null -eq $regex -or $null -eq $regex.Matches -or $null -eq $regex.Matches.Groups -or $regex.Matches.Groups.Length -lt 2) {
59-
Write-Error "Couldn't get MultiTarget property from $path";
60-
exit(-1);
61-
}
62-
63-
return $regex.Matches.Groups[1].Value;
64-
}
65-
6642
# Load multitarget preferences for project
67-
$multiTargets = LoadMultiTargetsFrom("$([System.IO.Path]::GetDirectoryName($projectPath))\MultiTarget.props");
68-
43+
$multiTargets = & $PSScriptRoot\GetMultiTargets.ps1 -ComponentName $projectName -ErrorAction Stop;
44+
6945
$templateContents = $templateContents -replace [regex]::escape("[IntendedTargets]"), $multiTargets;
70-
7146
$multiTargets = $multiTargets.Split(';');
72-
Write-Host "Generating project references for $([System.IO.Path]::GetFileNameWithoutExtension($csprojFileName)): $($multiTargets -Join ', ')"
7347

74-
$templateContents = $templateContents -replace [regex]::escape("[CanTargetWasm]"), "'$($multiTargets.Contains("wasm").ToString().ToLower())'";
75-
$templateContents = $templateContents -replace [regex]::escape("[CanTargetUwp]"), "'$($multiTargets.Contains("uwp").ToString().ToLower())'";
76-
$templateContents = $templateContents -replace [regex]::escape("[CanTargetWasdk]"), "'$($multiTargets.Contains("wasdk").ToString().ToLower())'";
77-
$templateContents = $templateContents -replace [regex]::escape("[CanTargetWpf]"), "'$($multiTargets.Contains("wpf").ToString().ToLower())'";
78-
$templateContents = $templateContents -replace [regex]::escape("[CanTargetLinuxGtk]"), "'$($multiTargets.Contains("linuxgtk").ToString().ToLower())'";
79-
$templateContents = $templateContents -replace [regex]::escape("[CanTargetMacOS]"), "'$($multiTargets.Contains("macos").ToString().ToLower())'";
80-
$templateContents = $templateContents -replace [regex]::escape("[CanTargetiOS]"), "'$($multiTargets.Contains("ios").ToString().ToLower())'";
81-
$templateContents = $templateContents -replace [regex]::escape("[CanTargetDroid]"), "'$($multiTargets.Contains("android").ToString().ToLower())'";
48+
function ShouldMultiTarget([string] $target) {
49+
return ($multiTargets.Contains($target) -and $MultiTarget.Contains($target)).ToString().ToLower()
50+
}
51+
52+
Write-Host "Generating project references for $([System.IO.Path]::GetFileNameWithoutExtension($csprojFileName)): $($multiTargets -Join ', ')"
53+
$templateContents = $templateContents -replace [regex]::escape("[CanTargetWasm]"), "'$(ShouldMultiTarget "wasm")'";
54+
$templateContents = $templateContents -replace [regex]::escape("[CanTargetUwp]"), "'$(ShouldMultiTarget "uwp")'";
55+
$templateContents = $templateContents -replace [regex]::escape("[CanTargetWasdk]"), "'$(ShouldMultiTarget "wasdk")'";
56+
$templateContents = $templateContents -replace [regex]::escape("[CanTargetWpf]"), "'$(ShouldMultiTarget "wpf")'";
57+
$templateContents = $templateContents -replace [regex]::escape("[CanTargetLinuxGtk]"), "'$(ShouldMultiTarget "linuxgtk")'";
58+
$templateContents = $templateContents -replace [regex]::escape("[CanTargetMacOS]"), "'$(ShouldMultiTarget "macos")'";
59+
$templateContents = $templateContents -replace [regex]::escape("[CanTargetiOS]"), "'$(ShouldMultiTarget "ios")'";
60+
$templateContents = $templateContents -replace [regex]::escape("[CanTargetDroid]"), "'$(ShouldMultiTarget "droid")'";
8261

8362
# Save to disk
8463
Set-Content -Path $outputPath -Value $templateContents;
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<#
2+
.SYNOPSIS
3+
Returns the defined MultiTarget value for the provided project name.
4+
.DESCRIPTION
5+
Locates a component by the provided name from the root ./components folder, and pulls the <MultiTarget> value that should be used.
6+
The MultiTarget value can be defined by a component in multiple places, but in a MultiTarget.props next to a *.csproj.
7+
8+
The load order is as follows:
9+
- ./components/SomeComponent/src/MultiTarget.props
10+
- ./components/SomeComponent/samples/MultiTarget.props
11+
- $PSScriptRoot/Defaults.props
12+
.PARAMETER ComponentName
13+
The name of the component.
14+
.EXAMPLE
15+
C:\PS> .\GetMultiTargets "CanvasView"
16+
Return the multitargets for the component named "CanvasView".
17+
.NOTES
18+
Author: Windows Community Toolkit Labs Team
19+
Date: February 27, 2023
20+
#>
21+
Param (
22+
[Parameter(HelpMessage = "The name of the component.", Mandatory = $true)]
23+
[string]$ComponentName
24+
)
25+
26+
$componentPath = "$PSScriptRoot/../../components/$ComponentName";
27+
28+
Test-Path $componentPath -ErrorAction Stop | Out-Null
29+
30+
# Folder layout is expected to match the Community Toolkit.
31+
# Uses the <MultiTarget> values from the source library project as the fallback for the sample project.
32+
# This behavior also implemented in MultiTarget.props for TargetFramework evaluation.
33+
$parent = Split-Path -Parent $projectPath
34+
$srcPath = Resolve-Path "$parent\..\src";
35+
$samplePath = Resolve-Path "$parent\..\samples";
36+
37+
$multiTargetFallbackPropsPaths = @("$srcPath/MultiTarget.props", "$samplePath/MultiTarget.props", "$PSScriptRoot/Defaults.props")
38+
39+
$fileContents = "";
40+
# Load first available default
41+
foreach ($fallbackPath in $multiTargetFallbackPropsPaths) {
42+
if (Test-Path $fallbackPath) {
43+
$fileContents = Get-Content $fallbackPath -ErrorAction Stop;
44+
break;
45+
}
46+
}
47+
48+
# Parse file contents
49+
$regex = Select-String -Pattern '<MultiTarget>(.+?)<\/MultiTarget>' -InputObject $fileContents;
50+
51+
if ($null -eq $regex -or $null -eq $regex.Matches -or $null -eq $regex.Matches.Groups -or $regex.Matches.Groups.Length -lt 2) {
52+
Write-Error "Couldn't get MultiTarget property from $path";
53+
exit(-1);
54+
}
55+
56+
$value = $regex.Matches.Groups[1].Value;
57+
58+
return $value;

0 commit comments

Comments
 (0)