From f3f674437d101ebdd647dd21aa1bbba4b51b6229 Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Mon, 4 Oct 2021 18:44:14 +0200 Subject: [PATCH] Ensured order of Deploy artifact dependencies irrespective of ICU or NLS globalization settings. (#11265) --- src/Umbraco.Core/Udi.cs | 4 +-- .../Umbraco.Core/Deploy/ArtifactBaseTests.cs | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Core/Udi.cs b/src/Umbraco.Core/Udi.cs index b861bcc68b78..208ac536c1f1 100644 --- a/src/Umbraco.Core/Udi.cs +++ b/src/Umbraco.Core/Udi.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.ComponentModel; using System.Linq; @@ -44,7 +44,7 @@ protected Udi(Uri uriValue) public int CompareTo(Udi other) { - return string.Compare(UriValue.ToString(), other.UriValue.ToString(), StringComparison.InvariantCultureIgnoreCase); + return string.Compare(UriValue.ToString(), other.UriValue.ToString(), StringComparison.OrdinalIgnoreCase); } public override string ToString() diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Deploy/ArtifactBaseTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Deploy/ArtifactBaseTests.cs index 1a2ffa8011f5..c4cd4f0c02a3 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Deploy/ArtifactBaseTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Deploy/ArtifactBaseTests.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Linq; using Newtonsoft.Json; using NUnit.Framework; using Umbraco.Cms.Core; @@ -29,6 +30,33 @@ public void CanSerialize() Assert.AreEqual(expected, serialized); } + [Test] + public void Dependencies_Are_Correctly_Ordered() + { + // This test was introduced following: https://github.com/umbraco/Umbraco.Deploy.Issues/issues/72 to verify + // that consistent ordering rules are used across platforms. + var udi = new GuidUdi("test", Guid.Parse("3382d5433b5749d08919bc9961422a1f")); + var artifact = new TestArtifact(udi, new List()) + { + Name = "Test Name", + Alias = "testAlias", + }; + + var dependencies = new ArtifactDependencyCollection(); + + var dependencyUdi1 = new GuidUdi("template", Guid.Parse("d4651496fad24c1290a53ea4d55d945b")); + dependencies.Add(new ArtifactDependency(dependencyUdi1, true, ArtifactDependencyMode.Exist)); + + var dependencyUdi2 = new StringUdi(Constants.UdiEntityType.TemplateFile, "TestPage.cshtml"); + dependencies.Add(new ArtifactDependency(dependencyUdi2, true, ArtifactDependencyMode.Exist)); + + artifact.Dependencies = dependencies; + + Assert.AreEqual( + "umb://template-file/TestPage.cshtml,umb://template/d4651496fad24c1290a53ea4d55d945b", + string.Join(",", artifact.Dependencies.Select(x => x.Udi.ToString()))); + } + private class TestArtifact : ArtifactBase { public TestArtifact(GuidUdi udi, IEnumerable dependencies = null) : base(udi, dependencies)