diff --git a/src/StronglyTypedIds.Templates/long-full.typedid b/src/StronglyTypedIds.Templates/long-full.typedid index c63c34af..924b02ce 100644 --- a/src/StronglyTypedIds.Templates/long-full.typedid +++ b/src/StronglyTypedIds.Templates/long-full.typedid @@ -88,7 +88,7 @@ public partial class PLACEHOLDERIDSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter { public override PLACEHOLDERID Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) - => new (reader.GetInt32()); + => new (reader.GetInt64()); public override void Write(global::System.Text.Json.Utf8JsonWriter writer, PLACEHOLDERID value, global::System.Text.Json.JsonSerializerOptions options) => writer.WriteNumberValue(value.Value); diff --git a/test/StronglyTypedIds.IntegrationTests/LongIdTests.cs b/test/StronglyTypedIds.IntegrationTests/LongIdTests.cs index 45805b94..6f541b6d 100644 --- a/test/StronglyTypedIds.IntegrationTests/LongIdTests.cs +++ b/test/StronglyTypedIds.IntegrationTests/LongIdTests.cs @@ -258,6 +258,18 @@ public void CanDeserializeFromLong_WithSystemTextJsonProvider() Assert.Equal(foo, deserializedFoo); } + [Fact] + public void CanDeserializeFromLong_MaxLongValue_WithSystemTextJsonProvider() + { + var value = long.MaxValue; + var foo = new ConvertersLongId(value); + var serializedLong = SystemTextJsonSerializer.Serialize(value); + + var deserializedFoo = SystemTextJsonSerializer.Deserialize(serializedLong); + + Assert.Equal(foo, deserializedFoo); + } + [Fact] public void WhenEfCoreValueConverterUsesValueConverter() {