Skip to content

Commit fd54400

Browse files
committed
Merge branch 'main' into winui
# Conflicts: # CommunityToolkit.WinUI.UI.Animations/Expressions/ExpressionNodes/ExpressionNode.cs # CommunityToolkit.WinUI.UI.Animations/Extensions/System/GuidExtensions.cs # CommunityToolkit.WinUI.UI.Media/Extensions/System/GuidExtensions.cs # CommunityToolkit.WinUI.UI.Media/Pipelines/PipelineBuilder.Effects.Internals.cs # CommunityToolkit.WinUI.UI.Media/Pipelines/PipelineBuilder.Effects.cs # CommunityToolkit.WinUI.UI.Media/Pipelines/PipelineBuilder.Initialization.cs # CommunityToolkit.WinUI.UI.Media/Pipelines/PipelineBuilder.Merge.cs # CommunityToolkit.WinUI.UI.Media/Pipelines/PipelineBuilder.cs
2 parents 312fcc4 + 529624c commit fd54400

File tree

8 files changed

+42
-35
lines changed

8 files changed

+42
-35
lines changed

CommunityToolkit.WinUI.UI.Animations/Expressions/ExpressionNodes/ExpressionNode.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,10 @@ internal void EnsureReferenceInfo()
282282
}
283283

284284
// Create a map to store the generated paramNames for each CompObj
285-
uint id = 0;
286285
_compObjToParamNameMap = new Dictionary<CompositionObject, string>();
287286
foreach (var compObj in compObjects)
288287
{
289-
// compObj.ToString() will return something like "Microsoft.UI.Composition.SpriteVisual"
290-
// Make it look like "SpriteVisual_1"
291-
string paramName = compObj.ToString();
292-
paramName = $"{paramName.Substring(paramName.LastIndexOf('.') + 1)}_{++id}"; // make sure the created param name doesn't overwrite a custom name
288+
string paramName = Guid.NewGuid().ToUppercaseAsciiLetters();
293289

294290
_compObjToParamNameMap.Add(compObj, paramName);
295291
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
using System.Diagnostics.Contracts;
7+
8+
namespace CommunityToolkit.WinUI.UI.Animations
9+
{
10+
/// <summary>
11+
/// An extension <see langword="class"/> for the <see cref="Guid"/> type
12+
/// </summary>
13+
internal static class GuidExtensions
14+
{
15+
/// <summary>
16+
/// Returns a <see cref="string"/> representation of a <see cref="Guid"/> only made of uppercase letters
17+
/// </summary>
18+
/// <param name="guid">The input <see cref="Guid"/> to process</param>
19+
/// <returns>A <see cref="string"/> representation of <paramref name="guid"/> only made up of letters in the [A-Z] range</returns>
20+
[Pure]
21+
public static string ToUppercaseAsciiLetters(in this Guid guid)
22+
{
23+
// Composition IDs must only be composed of characters in the [A-Z0-9_] set,
24+
// and also have the restriction that the initial character cannot be a digit.
25+
// Because of this, we need to prepend an underscore to a serialized guid to
26+
// avoid cases where the first character is a digit. Additionally, we're forced
27+
// to use ToUpper() here because ToString("N") currently returns a lowercase
28+
// hexadecimal string. Note: this extension might be improved once we move to
29+
// .NET 5 in the WinUI 3 release, by using string.Create<TState>(...) to only
30+
// have a single string allocation, and then using Guid.TryFormat(...) to
31+
// serialize the guid in place over the Span<char> starting from the second
32+
// character. For now, this implementation is fine on UWP and still fast enough.
33+
return $"_{guid.ToString("N").ToUpper()}";
34+
}
35+
}
36+
}

CommunityToolkit.WinUI.UI.Media/Extensions/System/GuidExtensions.cs

Lines changed: 0 additions & 30 deletions
This file was deleted.

CommunityToolkit.WinUI.UI.Media/Pipelines/PipelineBuilder.Effects.Internals.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System;
66
using System.Diagnostics.Contracts;
77
using System.Threading.Tasks;
8+
using CommunityToolkit.WinUI.UI.Animations;
89
using Microsoft.Graphics.Canvas.Effects;
910
using Microsoft.UI.Composition;
1011
using Windows.Graphics.Effects;

CommunityToolkit.WinUI.UI.Media/Pipelines/PipelineBuilder.Effects.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Diagnostics.Contracts;
88
using System.Linq;
99
using System.Threading.Tasks;
10+
using CommunityToolkit.WinUI.UI.Animations;
1011
using Microsoft.Graphics.Canvas.Effects;
1112
using Microsoft.UI.Composition;
1213
using Windows.Graphics.Effects;

CommunityToolkit.WinUI.UI.Media/Pipelines/PipelineBuilder.Initialization.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Diagnostics.Contracts;
88
using System.Numerics;
99
using System.Threading.Tasks;
10+
using CommunityToolkit.WinUI.UI.Animations;
1011
using CommunityToolkit.WinUI.UI.Media.Helpers;
1112
using CommunityToolkit.WinUI.UI.Media.Helpers.Cache;
1213
using Microsoft.Graphics.Canvas;

CommunityToolkit.WinUI.UI.Media/Pipelines/PipelineBuilder.Merge.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Diagnostics.Contracts;
88
using System.Linq;
99
using System.Threading.Tasks;
10+
using CommunityToolkit.WinUI.UI.Animations;
1011
using Microsoft.Graphics.Canvas.Effects;
1112
using Microsoft.UI.Composition;
1213
using Windows.Graphics.Effects;

CommunityToolkit.WinUI.UI.Media/Pipelines/PipelineBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Collections.Generic;
77
using System.Diagnostics.Contracts;
88
using System.Threading.Tasks;
9+
using CommunityToolkit.WinUI.UI.Animations;
910
using Microsoft.UI.Composition;
1011
using Microsoft.UI.Xaml;
1112
using Microsoft.UI.Xaml.Hosting;

0 commit comments

Comments
 (0)