feat: Adds GUID support for codegen (#1251)

This commit is contained in:
Kamron Batman 2022-11-14 21:25:51 -08:00 committed by GitHub
parent 58acfcabad
commit 32c15f214b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 14 deletions

View file

@ -3,7 +3,7 @@
"isRoot": true, "isRoot": true,
"tools": { "tools": {
"modernuoschemagenerator": { "modernuoschemagenerator": {
"version": "2.6.0", "version": "2.6.1",
"commands": [ "commands": [
"ModernUOSchemaGenerator" "ModernUOSchemaGenerator"
] ]

View file

@ -21,16 +21,9 @@ namespace Server.Json;
public class GuidConverter : JsonConverter<Guid> public class GuidConverter : JsonConverter<Guid>
{ {
public override Guid Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) public override Guid Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) =>
{ reader.GetGuid();
if (Guid.TryParse(reader.GetString()!, out var guid))
{
return guid;
}
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());
} }

View file

@ -37,7 +37,7 @@
<PackageReference Include="Zlib.Bindings" Version="1.10.1" /> <PackageReference Include="Zlib.Bindings" Version="1.10.1" />
<PackageReference Include="ModernUO.Serialization.Annotations" Version="2.6.0" /> <PackageReference Include="ModernUO.Serialization.Annotations" Version="2.6.0" />
<PackageReference Include="ModernUO.Serialization.Generator" Version="2.6.0" /> <PackageReference Include="ModernUO.Serialization.Generator" Version="2.6.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<AdditionalFiles Include="Migrations/*.v*.json" /> <AdditionalFiles Include="Migrations/*.v*.json" />

View file

@ -38,7 +38,7 @@
<PackageReference Include="Zstd.Binaries" Version="1.5.1" /> <PackageReference Include="Zstd.Binaries" Version="1.5.1" />
<PackageReference Include="ModernUO.Serialization.Annotations" Version="2.6.0" /> <PackageReference Include="ModernUO.Serialization.Annotations" Version="2.6.0" />
<PackageReference Include="ModernUO.Serialization.Generator" Version="2.6.0" /> <PackageReference Include="ModernUO.Serialization.Generator" Version="2.6.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<AdditionalFiles Include="Migrations/*.v*.json" /> <AdditionalFiles Include="Migrations/*.v*.json" />