From e8fa9cd98346e3d74ee359103c36bc56c4d30161 Mon Sep 17 00:00:00 2001 From: differenceclouds Date: Thu, 14 Nov 2024 09:32:22 -0500 Subject: [PATCH] TryParse on empty color string now returns null Moved exception into Parse in the case of a string greater than 1 character ("#") --- src/DotTiled/Color.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/DotTiled/Color.cs b/src/DotTiled/Color.cs index 78d0b80..d173782 100644 --- a/src/DotTiled/Color.cs +++ b/src/DotTiled/Color.cs @@ -40,7 +40,7 @@ public class Color : IParsable, IEquatable public static Color Parse(string s, IFormatProvider provider) { _ = TryParse(s, provider, out var result); - return result ?? throw new FormatException($"Invalid format for TiledColor: {s}"); + return result; } /// @@ -62,6 +62,10 @@ public class Color : IParsable, IEquatable // Format: #RRGGBB or #AARRGGBB if (s is null || (s.Length != 7 && s.Length != 9) || s[0] != '#') { + if(s.Length > 1) + { + throw new FormatException($"Invalid format for TiledColor: {s}"); + } result = default; return false; }