From c83c8c7be98eb362b45f46753d8321205ced1430 Mon Sep 17 00:00:00 2001 From: differenceclouds Date: Tue, 12 Nov 2024 20:46:44 -0500 Subject: [PATCH] Changed behavior for empty string Color properties When an unset Color property was parsed, an exception was thrown. This exception was moved into TryParse. Now, the Color can be null. --- src/DotTiled/Color.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/DotTiled/Color.cs b/src/DotTiled/Color.cs index 78d0b80..c4f846a 100644 --- a/src/DotTiled/Color.cs +++ b/src/DotTiled/Color.cs @@ -40,7 +40,8 @@ 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 ?? throw new FormatException($"Invalid format for TiledColor: {s}"); + return result; //let result be null } /// @@ -62,6 +63,8 @@ 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; }