mirror of
https://github.com/dcronqvist/DotTiled.git
synced 2025-02-05 17:02:49 +02:00
Remove nullables
This commit is contained in:
parent
3185e038c0
commit
3b6c5f8111
9 changed files with 19 additions and 19 deletions
|
@ -37,7 +37,7 @@ public class Color : IParsable<Color>, IEquatable<Color>
|
|||
/// <param name="provider">An object that supplies culture-specific information about the format of s.</param>
|
||||
/// <returns>The parsed <see cref="Color"/></returns>
|
||||
/// <exception cref="FormatException">Thrown in case the provided string <paramref name="s"/> is not in a valid format.</exception>
|
||||
public static Color Parse(string s, IFormatProvider? provider)
|
||||
public static Color Parse(string s, IFormatProvider provider)
|
||||
{
|
||||
_ = TryParse(s, provider, out var result);
|
||||
return result ?? throw new FormatException($"Invalid format for TiledColor: {s}");
|
||||
|
@ -52,8 +52,8 @@ public class Color : IParsable<Color>, IEquatable<Color>
|
|||
/// <param name="result">When this method returns, contains the parsed <see cref="Color"/> or <c>null</c> on failure.</param>
|
||||
/// <returns><c>true</c> if <paramref name="s"/> was successfully parsed; otherwise, <c>false</c>.</returns>
|
||||
public static bool TryParse(
|
||||
[NotNullWhen(true)] string? s,
|
||||
IFormatProvider? provider,
|
||||
[NotNullWhen(true)] string s,
|
||||
IFormatProvider provider,
|
||||
[MaybeNullWhen(false)] out Color result)
|
||||
{
|
||||
if (s is not null && !s.StartsWith('#'))
|
||||
|
@ -90,7 +90,7 @@ public class Color : IParsable<Color>, IEquatable<Color>
|
|||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(Color? other)
|
||||
public bool Equals(Color other)
|
||||
{
|
||||
if (other is null)
|
||||
return false;
|
||||
|
@ -99,7 +99,7 @@ public class Color : IParsable<Color>, IEquatable<Color>
|
|||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Equals(object? obj) => obj is Color other && Equals(other);
|
||||
public override bool Equals(object obj) => obj is Color other && Equals(other);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode() => HashCode.Combine(R, G, B, A);
|
||||
|
|
|
@ -51,7 +51,7 @@ public class ClassProperty : IHasProperties, IProperty<IList<IProperty>>
|
|||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool TryGetProperty<T>(string name, [NotNullWhen(true)] out T? property) where T : IProperty
|
||||
public bool TryGetProperty<T>(string name, [NotNullWhen(true)] out T property) where T : IProperty
|
||||
{
|
||||
if (Value.FirstOrDefault(_properties => _properties.Name == name) is T prop)
|
||||
{
|
||||
|
|
|
@ -76,7 +76,7 @@ public class CustomClassDefinition : HasPropertiesBase, ICustomTypeDefinition
|
|||
/// <summary>
|
||||
/// The color of the custom class inside the Tiled editor.
|
||||
/// </summary>
|
||||
public Color? Color { get; set; }
|
||||
public Color Color { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the custom class should be drawn with a fill color.
|
||||
|
|
|
@ -22,7 +22,7 @@ public interface IHasProperties
|
|||
/// <param name="name">The name of the property to get.</param>
|
||||
/// <param name="property">The property with the specified name, if found.</param>
|
||||
/// <returns>True if a property with the specified name was found; otherwise, false.</returns>
|
||||
bool TryGetProperty<T>(string name, out T? property) where T : IProperty;
|
||||
bool TryGetProperty<T>(string name, out T property) where T : IProperty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a property of the specified type with the specified name.
|
||||
|
@ -57,7 +57,7 @@ public abstract class HasPropertiesBase : IHasProperties
|
|||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool TryGetProperty<T>(string name, [NotNullWhen(true)] out T? property) where T : IProperty
|
||||
public bool TryGetProperty<T>(string name, [NotNullWhen(true)] out T property) where T : IProperty
|
||||
{
|
||||
var properties = GetProperties();
|
||||
if (properties.FirstOrDefault(_properties => _properties.Name == name) is T prop)
|
||||
|
|
|
@ -106,7 +106,7 @@ internal static partial class Helpers
|
|||
}).ToList();
|
||||
}
|
||||
|
||||
internal static IList<IProperty> MergeProperties(IList<IProperty>? baseProperties, IList<IProperty>? overrideProperties)
|
||||
internal static IList<IProperty> MergeProperties(IList<IProperty> baseProperties, IList<IProperty> overrideProperties)
|
||||
{
|
||||
if (baseProperties is null)
|
||||
return overrideProperties ?? [];
|
||||
|
@ -148,7 +148,7 @@ internal static partial class Helpers
|
|||
properties[index] = property;
|
||||
}
|
||||
|
||||
internal static void SetAtMostOnce<T>(ref T? field, T value, string fieldName)
|
||||
internal static void SetAtMostOnce<T>(ref T field, T value, string fieldName)
|
||||
{
|
||||
if (field is not null)
|
||||
throw new InvalidOperationException($"{fieldName} already set");
|
||||
|
@ -156,7 +156,7 @@ internal static partial class Helpers
|
|||
field = value;
|
||||
}
|
||||
|
||||
internal static void SetAtMostOnceUsingCounter<T>(ref T? field, T value, string fieldName, ref int counter)
|
||||
internal static void SetAtMostOnceUsingCounter<T>(ref T field, T value, string fieldName, ref int counter)
|
||||
{
|
||||
if (counter > 0)
|
||||
throw new InvalidOperationException($"{fieldName} already set");
|
||||
|
|
|
@ -16,8 +16,8 @@ public class MapReader : IMapReader
|
|||
private readonly Func<string, Template> _externalTemplateResolver;
|
||||
private readonly Func<string, ICustomTypeDefinition> _customTypeResolver;
|
||||
|
||||
private readonly StringReader? _mapStringReader;
|
||||
private readonly XmlReader? _xmlReader;
|
||||
private readonly StringReader _mapStringReader;
|
||||
private readonly XmlReader _xmlReader;
|
||||
private readonly IMapReader _mapReader;
|
||||
private bool disposedValue;
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ public class TemplateReader : ITemplateReader
|
|||
private readonly Func<string, Template> _externalTemplateResolver;
|
||||
private readonly Func<string, ICustomTypeDefinition> _customTypeResolver;
|
||||
|
||||
private readonly StringReader? _templateStringReader;
|
||||
private readonly XmlReader? _xmlReader;
|
||||
private readonly StringReader _templateStringReader;
|
||||
private readonly XmlReader _xmlReader;
|
||||
private readonly ITemplateReader _templateReader;
|
||||
private bool disposedValue;
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ public class TilesetReader : ITilesetReader
|
|||
private readonly Func<string, Template> _externalTemplateResolver;
|
||||
private readonly Func<string, ICustomTypeDefinition> _customTypeResolver;
|
||||
|
||||
private readonly StringReader? _tilesetStringReader;
|
||||
private readonly XmlReader? _xmlReader;
|
||||
private readonly StringReader _tilesetStringReader;
|
||||
private readonly XmlReader _xmlReader;
|
||||
private readonly ITilesetReader _tilesetReader;
|
||||
private bool disposedValue;
|
||||
|
||||
|
|
|
@ -21,5 +21,5 @@ public class TsxTilesetReader : TmxReaderBase, ITilesetReader
|
|||
{ }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public new Tileset ReadTileset() => base.ReadTileset();
|
||||
public Tileset ReadTileset() => base.ReadTileset();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue