From b0ae957a4d0d948780f897287ec52752552c52c2 Mon Sep 17 00:00:00 2001 From: Mark Cassidy Date: Tue, 4 May 2021 22:19:15 +0200 Subject: [PATCH] Fixed endless loop that would happen if an attribute was omitted in a predicate instantiation --- src/SharedAssemblyInfo.cs | 6 +++--- src/Unicorn/Configuration/PredicatePreset.cs | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/SharedAssemblyInfo.cs b/src/SharedAssemblyInfo.cs index 4e6bdc89..897fd58e 100644 --- a/src/SharedAssemblyInfo.cs +++ b/src/SharedAssemblyInfo.cs @@ -4,7 +4,7 @@ [assembly: AssemblyProduct("Unicorn")] [assembly: ComVisible(false)] -[assembly: AssemblyVersion("4.1.4.0")] -[assembly: AssemblyFileVersion("4.1.4.0")] -[assembly: AssemblyInformationalVersion("4.1.4")] +[assembly: AssemblyVersion("4.1.5.0")] +[assembly: AssemblyFileVersion("4.1.5.0")] +[assembly: AssemblyInformationalVersion("4.1.5-pre1")] [assembly: CLSCompliant(false)] diff --git a/src/Unicorn/Configuration/PredicatePreset.cs b/src/Unicorn/Configuration/PredicatePreset.cs index c9a08829..0de96c09 100644 --- a/src/Unicorn/Configuration/PredicatePreset.cs +++ b/src/Unicorn/Configuration/PredicatePreset.cs @@ -68,7 +68,7 @@ protected virtual XmlElement ReplaceValues(Dictionary replacers, // ReSharper disable once PossibleNullReferenceException foreach (XmlNode att in clone.Attributes) { - while (att.Value.Contains("$")) + if (att.Value.Contains("$")) { didReplacement = true; @@ -76,6 +76,11 @@ protected virtual XmlElement ReplaceValues(Dictionary replacers, { att.Value = Regex.Replace(att.Value, "\\$" + replacerKey, replacers[replacerKey], RegexOptions.IgnoreCase); } + + if (att.Value.Contains("$")) + { + throw new InvalidOperationException($"Predicate Preset '{((XmlElement)includeElement.ParentNode).Attributes["id"].Value}' could not be expanded, there are unresolved token attributes '{att.Value}'"); + } } }