From 32c15f214b29bfa9edc18124115b3308c4382f06 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Mon, 14 Nov 2022 21:25:51 -0800 Subject: [PATCH] feat: Adds GUID support for codegen (#1251) --- .config/dotnet-tools.json | 2 +- Projects/Server/Json/Converters/GuidConverter.cs | 15 ++++----------- Projects/Server/Server.csproj | 2 +- Projects/UOContent/UOContent.csproj | 2 +- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index a488b9e93..3aec5f0cc 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "modernuoschemagenerator": { - "version": "2.6.0", + "version": "2.6.1", "commands": [ "ModernUOSchemaGenerator" ] diff --git a/Projects/Server/Json/Converters/GuidConverter.cs b/Projects/Server/Json/Converters/GuidConverter.cs index 64a5fb13e..6bd5da8f2 100644 --- a/Projects/Server/Json/Converters/GuidConverter.cs +++ b/Projects/Server/Json/Converters/GuidConverter.cs @@ -21,16 +21,9 @@ namespace Server.Json; public class GuidConverter : JsonConverter { - public override Guid Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (Guid.TryParse(reader.GetString()!, out var guid)) - { - return guid; - } + public override Guid Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => + reader.GetGuid(); - throw new JsonException("Guid must be in the correct format"); - } - - public override void Write(Utf8JsonWriter writer, Guid value, JsonSerializerOptions options) - => writer.WriteStringValue(value.ToString()); + public override void Write(Utf8JsonWriter writer, Guid value, JsonSerializerOptions options) => + writer.WriteStringValue(value.ToString()); } diff --git a/Projects/Server/Server.csproj b/Projects/Server/Server.csproj index aedf820b8..723038fb9 100755 --- a/Projects/Server/Server.csproj +++ b/Projects/Server/Server.csproj @@ -37,7 +37,7 @@ - + diff --git a/Projects/UOContent/UOContent.csproj b/Projects/UOContent/UOContent.csproj index 65c9aa1ae..c24f8732b 100755 --- a/Projects/UOContent/UOContent.csproj +++ b/Projects/UOContent/UOContent.csproj @@ -38,7 +38,7 @@ - +