diff --git a/test/Misc/TestSerializerExternalModels/Models.cs b/test/Misc/TestSerializerExternalModels/Models.cs index 74e0e5d5953..d9a63e0fe01 100644 --- a/test/Misc/TestSerializerExternalModels/Models.cs +++ b/test/Misc/TestSerializerExternalModels/Models.cs @@ -12,6 +12,16 @@ public record struct Person2ExternalStruct(int Age, string Name) public string StarSign { get; set; } } +[GenerateSerializer] +public record struct GenericPersonExternalStruct(T CtorParam, string Name) +{ + [Id(0)] + public T BodyParam { get; set; } + + [Id(1)] + public string StarSign { get; set; } +} + #if NET6_0_OR_GREATER [GenerateSerializer] public record Person2External(int Age, string Name) @@ -22,4 +32,14 @@ public record Person2External(int Age, string Name) [Id(1)] public string StarSign { get; set; } } + +[GenerateSerializer] +public record GenericPersonExternal(T CtorParam, string Name) +{ + [Id(0)] + public T BodyParam { get; set; } + + [Id(1)] + public string StarSign { get; set; } +} #endif diff --git a/test/Orleans.Serialization.UnitTests/GeneratedSerializerTests.cs b/test/Orleans.Serialization.UnitTests/GeneratedSerializerTests.cs index 8969d37f46a..21d230d668d 100644 --- a/test/Orleans.Serialization.UnitTests/GeneratedSerializerTests.cs +++ b/test/Orleans.Serialization.UnitTests/GeneratedSerializerTests.cs @@ -151,7 +151,6 @@ public void GeneratedLibExternalRecordStructWithPCtorSerializersRoundTripThrough } #if NET6_0_OR_GREATER - [Fact] public void GeneratedLibExternalRecordWithPCtorSerializersRoundTripThroughCodec() { @@ -169,6 +168,55 @@ public void GeneratedLibExternalRecordWithPCtorSerializersRoundTripThroughCodec( Assert.Equal(original.StarSign, result.StarSign); } + [Fact] + public void GeneratedLibExternalGenericRecordStructWithPCtorSerializersRoundTripThroughCodec() + { + var originalInner = new Person2External(2, "harry") + { + FavouriteColor = "redborine", + StarSign = "Aquaricorn" + }; + + var original = new GenericPersonExternalStruct(originalInner, "harry") + { + BodyParam = originalInner, + StarSign = "Aquaricorn" + }; + + var result = RoundTripThroughCodec(original); + + Assert.Equal(original.CtorParam, result.CtorParam); + Assert.Equal(original.Name, result.Name); + Assert.Equal(original.BodyParam, result.BodyParam); + Assert.Equal(original.StarSign, result.StarSign); + Assert.Same(result.CtorParam, result.BodyParam); + } +#endif + +#if NET9_0_OR_GREATER + [Fact] + public void GeneratedLibExternalGenericRecordWithPCtorSerializersRoundTripThroughCodec() + { + var originalInner = new Person2External(2, "harry") + { + FavouriteColor = "redborine", + StarSign = "Aquaricorn" + }; + + var original = new GenericPersonExternal(originalInner, "harry") + { + BodyParam = originalInner, + StarSign = "Aquaricorn" + }; + + var result = RoundTripThroughCodec(original); + + Assert.Equal(original.CtorParam, result.CtorParam); + Assert.Equal(original.Name, result.Name); + Assert.Equal(original.BodyParam, result.BodyParam); + Assert.Equal(original.StarSign, result.StarSign); + Assert.Same(result.CtorParam, result.BodyParam); + } #endif #if NET6_0_OR_GREATER