Skip to content

Commit fd6c39e

Browse files
arcadiogarciaSergio0694
authored andcommitted
Shorter expression strings
1 parent ae07326 commit fd6c39e

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

Microsoft.Toolkit.Uwp.UI.Animations/Expressions/ExpressionNodes/ExpressionNode.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,10 @@ internal void EnsureReferenceInfo()
283283

284284
// Create a map to store the generated paramNames for each CompObj
285285
_compObjToParamNameMap = new Dictionary<CompositionObject, string>();
286+
var paramCount = 0;
286287
foreach (var compObj in compObjects)
287288
{
288-
string paramName = Guid.NewGuid().ToUppercaseAsciiLetters();
289+
string paramName = UniqueParamNameFromIndex(paramCount++); // Guid.NewGuid().ToUppercaseAsciiLetters();
289290

290291
_compObjToParamNameMap.Add(compObj, paramName);
291292
}
@@ -312,6 +313,22 @@ internal void EnsureReferenceInfo()
312313
refNode.ParamName = paramName;
313314
}
314315
}
316+
317+
//Generates Excel-column-like identifiers, e.g. A, B, ..., Z, AA, AB...
318+
string UniqueParamNameFromIndex(int i)
319+
{
320+
var alphabetLength = 'Z' - 'A' + 1;
321+
var paramName = ((char)('A' + (i % alphabetLength))).ToString();
322+
323+
while (i / alphabetLength > 0)
324+
{
325+
i = (i / alphabetLength) - 1;
326+
var nextCharacter = (char)('A' + (i % alphabetLength));
327+
paramName = nextCharacter + paramName;
328+
}
329+
330+
return paramName;
331+
}
315332
}
316333

317334
/// <summary>

0 commit comments

Comments
 (0)