mirror of
https://github.com/dcronqvist/DotTiled.git
synced 2025-05-08 15:16:04 +03:00
TryParse on empty color string now returns null
Moved exception into Parse in the case of a string greater than 1 character ("#")
This commit is contained in:
parent
d943a8d8b7
commit
e8fa9cd983
1 changed files with 5 additions and 1 deletions
|
@ -40,7 +40,7 @@ public class Color : IParsable<Color>, IEquatable<Color>
|
|||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -62,6 +62,10 @@ public class Color : IParsable<Color>, IEquatable<Color>
|
|||
// 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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue