mirror of
https://github.com/dcronqvist/DotTiled.git
synced 2025-02-05 08:52:50 +02:00
More lint fixing
This commit is contained in:
parent
bb8c3a133c
commit
b6721934e4
7 changed files with 36 additions and 108 deletions
|
@ -42,7 +42,7 @@ dotnet_style_require_accessibility_modifiers = for_non_interface_members
|
|||
dotnet_style_coalesce_expression = true
|
||||
dotnet_style_collection_initializer = false
|
||||
dotnet_style_explicit_tuple_names = true
|
||||
dotnet_style_namespace_match_folder = true
|
||||
dotnet_style_namespace_match_folder = false
|
||||
dotnet_style_null_propagation = true
|
||||
dotnet_style_object_initializer = true
|
||||
dotnet_style_operator_placement_when_wrapping = beginning_of_line
|
||||
|
@ -116,7 +116,7 @@ csharp_style_prefer_top_level_statements = true
|
|||
# Expression-level preferences
|
||||
csharp_prefer_simple_default_expression = true
|
||||
csharp_style_deconstructed_variable_declaration = true
|
||||
csharp_style_implicit_object_creation_when_type_is_apparent = true
|
||||
csharp_style_implicit_object_creation_when_type_is_apparent = false
|
||||
csharp_style_inlined_variable_declaration = true
|
||||
csharp_style_prefer_index_operator = true
|
||||
csharp_style_prefer_local_over_anonymous_function = true
|
||||
|
@ -234,7 +234,9 @@ dotnet_diagnostic.IDE0001.severity = none
|
|||
dotnet_diagnostic.IDE0004.severity = silent
|
||||
dotnet_diagnostic.IDE0005.severity = error
|
||||
dotnet_diagnostic.IDE0008.severity = silent
|
||||
dotnet_diagnostic.IDE0055.severity = silent
|
||||
dotnet_diagnostic.IDE0160.severity = none
|
||||
dotnet_diagnostic.CA1707.severity = silent
|
||||
|
||||
[.github/**/*.yml]
|
||||
charset = utf-8
|
||||
|
|
8
.github/workflows/pull-request.yml
vendored
8
.github/workflows/pull-request.yml
vendored
|
@ -19,7 +19,7 @@ jobs:
|
|||
run: dotnet build --no-restore src/DotTiled.sln
|
||||
- name: Test
|
||||
run: dotnet test --no-build --verbosity normal src/DotTiled.sln
|
||||
- name: Lint
|
||||
run: |
|
||||
dotnet format style --verify-no-changes --verbosity diagnostic src/DotTiled.sln
|
||||
dotnet format analyzers --verify-no-changes --verbosity diagnostic src/DotTiled.sln
|
||||
- name: Lint style
|
||||
run: dotnet format style --verify-no-changes --verbosity diagnostic src/DotTiled.sln
|
||||
- name: Lint analyzers
|
||||
run: dotnet format analyzers --verify-no-changes --verbosity diagnostic src/DotTiled.sln
|
||||
|
|
4
Makefile
4
Makefile
|
@ -11,8 +11,8 @@ docs-build:
|
|||
|
||||
lint:
|
||||
dotnet build src/DotTiled.sln
|
||||
dotnet format style --verify-no-changes --verbosity diagnostic src/DotTiled.sln
|
||||
dotnet format analyzers --verify-no-changes --verbosity diagnostic src/DotTiled.sln
|
||||
dotnet format style --verify-no-changes src/DotTiled.sln
|
||||
dotnet format analyzers --verify-no-changes src/DotTiled.sln
|
||||
|
||||
BENCHMARK_SOURCES = DotTiled.Benchmark/Program.cs DotTiled.Benchmark/DotTiled.Benchmark.csproj
|
||||
BENCHMARK_OUTPUTDIR = DotTiled.Benchmark/BenchmarkDotNet.Artifacts
|
||||
|
|
|
@ -24,30 +24,15 @@ public static partial class DotTiledAssert
|
|||
AssertObject((dynamic)expected, (dynamic)actual);
|
||||
}
|
||||
|
||||
private static void AssertObject(RectangleObject expected, RectangleObject actual)
|
||||
{
|
||||
Assert.True(true); // A rectangle object is the same as the abstract Object
|
||||
}
|
||||
private static void AssertObject(RectangleObject _, RectangleObject __) => Assert.True(true); // A rectangle object is the same as the abstract Object
|
||||
|
||||
private static void AssertObject(EllipseObject expected, EllipseObject actual)
|
||||
{
|
||||
Assert.True(true); // An ellipse object is the same as the abstract Object
|
||||
}
|
||||
private static void AssertObject(EllipseObject _, EllipseObject __) => Assert.True(true); // An ellipse object is the same as the abstract Object
|
||||
|
||||
private static void AssertObject(PointObject expected, PointObject actual)
|
||||
{
|
||||
Assert.True(true); // A point object is the same as the abstract Object
|
||||
}
|
||||
private static void AssertObject(PointObject _, PointObject __) => Assert.True(true); // A point object is the same as the abstract Object
|
||||
|
||||
private static void AssertObject(PolygonObject expected, PolygonObject actual)
|
||||
{
|
||||
AssertEqual(expected.Points, actual.Points, nameof(PolygonObject.Points));
|
||||
}
|
||||
private static void AssertObject(PolygonObject expected, PolygonObject actual) => AssertEqual(expected.Points, actual.Points, nameof(PolygonObject.Points));
|
||||
|
||||
private static void AssertObject(PolylineObject expected, PolylineObject actual)
|
||||
{
|
||||
AssertEqual(expected.Points, actual.Points, nameof(PolylineObject.Points));
|
||||
}
|
||||
private static void AssertObject(PolylineObject expected, PolylineObject actual) => AssertEqual(expected.Points, actual.Points, nameof(PolylineObject.Points));
|
||||
|
||||
private static void AssertObject(TextObject expected, TextObject actual)
|
||||
{
|
||||
|
@ -67,9 +52,5 @@ public static partial class DotTiledAssert
|
|||
AssertEqual(expected.Text, actual.Text, nameof(TextObject.Text));
|
||||
}
|
||||
|
||||
private static void AssertObject(TileObject expected, TileObject actual)
|
||||
{
|
||||
// Attributes
|
||||
AssertEqual(expected.GID, actual.GID, nameof(TileObject.GID));
|
||||
}
|
||||
private static void AssertObject(TileObject expected, TileObject actual) => AssertEqual(expected.GID, actual.GID, nameof(TileObject.GID));
|
||||
}
|
||||
|
|
|
@ -28,40 +28,19 @@ public static partial class DotTiledAssert
|
|||
AssertProperties((dynamic)actual, (dynamic)expected);
|
||||
}
|
||||
|
||||
private static void AssertProperty(StringProperty expected, StringProperty actual)
|
||||
{
|
||||
AssertEqual(expected.Value, actual.Value, "StringProperty.Value");
|
||||
}
|
||||
private static void AssertProperty(StringProperty expected, StringProperty actual) => AssertEqual(expected.Value, actual.Value, "StringProperty.Value");
|
||||
|
||||
private static void AssertProperty(IntProperty expected, IntProperty actual)
|
||||
{
|
||||
AssertEqual(expected.Value, actual.Value, "IntProperty.Value");
|
||||
}
|
||||
private static void AssertProperty(IntProperty expected, IntProperty actual) => AssertEqual(expected.Value, actual.Value, "IntProperty.Value");
|
||||
|
||||
private static void AssertProperty(FloatProperty expected, FloatProperty actual)
|
||||
{
|
||||
AssertEqual(expected.Value, actual.Value, "FloatProperty.Value");
|
||||
}
|
||||
private static void AssertProperty(FloatProperty expected, FloatProperty actual) => AssertEqual(expected.Value, actual.Value, "FloatProperty.Value");
|
||||
|
||||
private static void AssertProperty(BoolProperty expected, BoolProperty actual)
|
||||
{
|
||||
AssertEqual(expected.Value, actual.Value, "BoolProperty.Value");
|
||||
}
|
||||
private static void AssertProperty(BoolProperty expected, BoolProperty actual) => AssertEqual(expected.Value, actual.Value, "BoolProperty.Value");
|
||||
|
||||
private static void AssertProperty(ColorProperty expected, ColorProperty actual)
|
||||
{
|
||||
AssertEqual(expected.Value, actual.Value, "ColorProperty.Value");
|
||||
}
|
||||
private static void AssertProperty(ColorProperty expected, ColorProperty actual) => AssertEqual(expected.Value, actual.Value, "ColorProperty.Value");
|
||||
|
||||
private static void AssertProperty(FileProperty expected, FileProperty actual)
|
||||
{
|
||||
AssertEqual(expected.Value, actual.Value, "FileProperty.Value");
|
||||
}
|
||||
private static void AssertProperty(FileProperty expected, FileProperty actual) => AssertEqual(expected.Value, actual.Value, "FileProperty.Value");
|
||||
|
||||
private static void AssertProperty(ObjectProperty expected, ObjectProperty actual)
|
||||
{
|
||||
AssertEqual(expected.Value, actual.Value, "ObjectProperty.Value");
|
||||
}
|
||||
private static void AssertProperty(ObjectProperty expected, ObjectProperty actual) => AssertEqual(expected.Value, actual.Value, "ObjectProperty.Value");
|
||||
|
||||
private static void AssertProperty(ClassProperty expected, ClassProperty actual)
|
||||
{
|
||||
|
|
|
@ -32,49 +32,14 @@ public static partial class TestData
|
|||
|
||||
public static IEnumerable<object[]> MapTests =>
|
||||
[
|
||||
["Serialization/TestData/Map/default_map/default-map", (string f) => TestData.DefaultMap(), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_with_common_props/map-with-common-props", (string f) => TestData.MapWithCommonProps(), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_with_custom_type_props/map-with-custom-type-props", (string f) => TestData.MapWithCustomTypeProps(), TestData.MapWithCustomTypePropsCustomTypeDefinitions()],
|
||||
["Serialization/TestData/Map/map_with_embedded_tileset/map-with-embedded-tileset", (string f) => TestData.MapWithEmbeddedTileset(), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_with_external_tileset/map-with-external-tileset", (string f) => TestData.MapWithExternalTileset(f), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_with_flippingflags/map-with-flippingflags", (string f) => TestData.MapWithFlippingFlags(f), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_external_tileset_multi/map-external-tileset-multi", (string f) => TestData.MapExternalTilesetMulti(f), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_external_tileset_wangset/map-external-tileset-wangset", (string f) => TestData.MapExternalTilesetWangset(f), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_with_many_layers/map-with-many-layers", (string f) => TestData.MapWithManyLayers(f), Array.Empty<CustomTypeDefinition>()],
|
||||
];
|
||||
|
||||
private static CustomTypeDefinition[] typedefs = [
|
||||
new CustomClassDefinition
|
||||
{
|
||||
Name = "TestClass",
|
||||
ID = 1,
|
||||
UseAs = CustomClassUseAs.Property,
|
||||
Members = [
|
||||
new StringProperty
|
||||
{
|
||||
Name = "Name",
|
||||
Value = ""
|
||||
},
|
||||
new FloatProperty
|
||||
{
|
||||
Name = "Amount",
|
||||
Value = 0f
|
||||
}
|
||||
]
|
||||
},
|
||||
new CustomClassDefinition
|
||||
{
|
||||
Name = "Test",
|
||||
ID = 2,
|
||||
UseAs = CustomClassUseAs.All,
|
||||
Members = [
|
||||
new ClassProperty
|
||||
{
|
||||
Name = "Yep",
|
||||
PropertyType = "TestClass",
|
||||
Properties = []
|
||||
}
|
||||
]
|
||||
}
|
||||
["Serialization/TestData/Map/default_map/default-map", (string f) => DefaultMap(), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_with_common_props/map-with-common-props", (string f) => MapWithCommonProps(), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_with_custom_type_props/map-with-custom-type-props", (string f) => MapWithCustomTypeProps(), MapWithCustomTypePropsCustomTypeDefinitions()],
|
||||
["Serialization/TestData/Map/map_with_embedded_tileset/map-with-embedded-tileset", (string f) => MapWithEmbeddedTileset(), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_with_external_tileset/map-with-external-tileset", (string f) => MapWithExternalTileset(f), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_with_flippingflags/map-with-flippingflags", (string f) => MapWithFlippingFlags(f), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_external_tileset_multi/map-external-tileset-multi", (string f) => MapExternalTilesetMulti(f), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_external_tileset_wangset/map-external-tileset-wangset", (string f) => MapExternalTilesetWangset(f), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_with_many_layers/map-with-many-layers", (string f) => MapWithManyLayers(f), Array.Empty<CustomTypeDefinition>()],
|
||||
];
|
||||
}
|
||||
|
|
|
@ -9,9 +9,10 @@ internal static class ExtensionsJsonElement
|
|||
{
|
||||
internal static T GetRequiredProperty<T>(this JsonElement element, string propertyName)
|
||||
{
|
||||
return !element.TryGetProperty(propertyName, out var property)
|
||||
? throw new JsonException($"Missing required property '{propertyName}'.")
|
||||
: property.GetValueAs<T>();
|
||||
if (!element.TryGetProperty(propertyName, out var property))
|
||||
throw new JsonException($"Missing required property '{propertyName}'.");
|
||||
|
||||
return property.GetValueAs<T>();
|
||||
}
|
||||
|
||||
internal static T GetOptionalProperty<T>(this JsonElement element, string propertyName, T defaultValue)
|
||||
|
|
Loading…
Add table
Reference in a new issue