mirror of
https://github.com/dcronqvist/DotTiled.git
synced 2025-05-08 18:26:03 +03:00
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.
This commit is contained in:
parent
8dba9e81a0
commit
c83c8c7be9
1 changed files with 4 additions and 1 deletions
|
@ -40,7 +40,8 @@ public class Color : IParsable<Color>, IEquatable<Color>
|
||||||
public static Color Parse(string s, IFormatProvider provider)
|
public static Color Parse(string s, IFormatProvider provider)
|
||||||
{
|
{
|
||||||
_ = TryParse(s, provider, out var result);
|
_ = 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
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -62,6 +63,8 @@ public class Color : IParsable<Color>, IEquatable<Color>
|
||||||
// Format: #RRGGBB or #AARRGGBB
|
// Format: #RRGGBB or #AARRGGBB
|
||||||
if (s is null || (s.Length != 7 && s.Length != 9) || s[0] != '#')
|
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;
|
result = default;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue