diff --git a/Orleans.sln b/Orleans.sln index b9967bcc95..5e22715188 100644 --- a/Orleans.sln +++ b/Orleans.sln @@ -217,6 +217,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tester.Redis", "test\Extens EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.Serialization.Protobuf", "src\Serializers\Orleans.Serialization.Protobuf\Orleans.Serialization.Protobuf.csproj", "{A073C0EE-8732-42F9-A22E-D47034E25076}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestSerializerExternalModels", "test\Misc\TestSerializerExternalModels\TestSerializerExternalModels.csproj", "{F9674B6B-67FF-4779-9B0F-41385AB1CE9E}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.Streaming.AdoNet", "src\AdoNet\Orleans.Streaming.AdoNet\Orleans.Streaming.AdoNet.csproj", "{2B994F33-16CF-4679-936A-5AEABC529D2C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Benchmarks.AdoNet", "test\Benchmarks.AdoNet\Benchmarks.AdoNet.csproj", "{B8F43537-2D2E-42A0-BE67-5E07E4313AEA}" @@ -579,6 +580,10 @@ Global {A073C0EE-8732-42F9-A22E-D47034E25076}.Debug|Any CPU.Build.0 = Debug|Any CPU {A073C0EE-8732-42F9-A22E-D47034E25076}.Release|Any CPU.ActiveCfg = Release|Any CPU {A073C0EE-8732-42F9-A22E-D47034E25076}.Release|Any CPU.Build.0 = Release|Any CPU + {F9674B6B-67FF-4779-9B0F-41385AB1CE9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F9674B6B-67FF-4779-9B0F-41385AB1CE9E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F9674B6B-67FF-4779-9B0F-41385AB1CE9E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F9674B6B-67FF-4779-9B0F-41385AB1CE9E}.Release|Any CPU.Build.0 = Release|Any CPU {2B994F33-16CF-4679-936A-5AEABC529D2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2B994F33-16CF-4679-936A-5AEABC529D2C}.Debug|Any CPU.Build.0 = Debug|Any CPU {2B994F33-16CF-4679-936A-5AEABC529D2C}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -693,6 +698,7 @@ Global {8FC6457C-6273-4338-AD2A-ECAA8FE2C5D7} = {082D25DB-70CA-48F4-93E0-EC3455F494B8} {F13247A0-70C9-4200-9CB1-2002CB8105E0} = {082D25DB-70CA-48F4-93E0-EC3455F494B8} {A073C0EE-8732-42F9-A22E-D47034E25076} = {4CD3AA9E-D937-48CA-BB6C-158E12257D23} + {F9674B6B-67FF-4779-9B0F-41385AB1CE9E} = {70BCC54E-1618-4742-A079-07588065E361} {2B994F33-16CF-4679-936A-5AEABC529D2C} = {EB2EDE59-5021-42EE-A97A-D59939B39C66} {B8F43537-2D2E-42A0-BE67-5E07E4313AEA} = {2CAB7894-777C-42B1-8B1E-322868CE92C7} EndGlobalSection diff --git a/test/Misc/TestSerializerExternalModels/Models.cs b/test/Misc/TestSerializerExternalModels/Models.cs new file mode 100644 index 0000000000..c87b46e6cd --- /dev/null +++ b/test/Misc/TestSerializerExternalModels/Models.cs @@ -0,0 +1,13 @@ +using Orleans; + +namespace UnitTests.SerializerExternalModels; + +[GenerateSerializer] +public record struct Person2External(int Age, string Name) +{ + [Id(0)] + public string FavouriteColor { get; set; } + + [Id(1)] + public string StarSign { get; set; } +} diff --git a/test/Misc/TestSerializerExternalModels/TestSerializerExternalModels.csproj b/test/Misc/TestSerializerExternalModels/TestSerializerExternalModels.csproj new file mode 100644 index 0000000000..a74ccc43b1 --- /dev/null +++ b/test/Misc/TestSerializerExternalModels/TestSerializerExternalModels.csproj @@ -0,0 +1,10 @@ + + + UnitTests.SerializerExternalModels + SerializerExternalModels + $(TestTargetFrameworks);netcoreapp3.1 + + + + + diff --git a/test/Orleans.Serialization.UnitTests/GeneratedSerializerTests.cs b/test/Orleans.Serialization.UnitTests/GeneratedSerializerTests.cs index 479b1e0a0a..ba0a8605b3 100644 --- a/test/Orleans.Serialization.UnitTests/GeneratedSerializerTests.cs +++ b/test/Orleans.Serialization.UnitTests/GeneratedSerializerTests.cs @@ -1,3 +1,4 @@ +using Orleans; using Orleans.Serialization.Buffers; using Orleans.Serialization.Codecs; using Orleans.Serialization.Serializers; @@ -11,6 +12,9 @@ using System.IO.Pipelines; using Xunit; using System.Linq; +using UnitTests.SerializerExternalModels; + +[assembly: GenerateCodeForDeclaringAssembly(typeof(Person2External))] namespace Orleans.Serialization.UnitTests; @@ -126,6 +130,23 @@ public void GeneratedRecordWithPCtorSerializersRoundTripThroughCodec() Assert.Equal(original.StarSign, result.StarSign); } + [Fact(Skip = "TODO: Fix")] + public void GeneratedLibExternalRecordWithPCtorSerializersRoundTripThroughCodec() + { + var original = new Person2External(2, "harry") + { + FavouriteColor = "redborine", + StarSign = "Aquaricorn" + }; + + var result = RoundTripThroughCodec(original); + + Assert.Equal(original.Age, result.Age); + Assert.Equal(original.Name, result.Name); + Assert.Equal(original.FavouriteColor, result.FavouriteColor); + Assert.Equal(original.StarSign, result.StarSign); + } + #if NET6_0_OR_GREATER [Fact] public void RequiredMembersAreSupported() @@ -200,7 +221,7 @@ public void RecordSerializedAsRegularClass() // Note that this only works because we are serializing each object using the "expected type" optimization and // therefore omitting the concrete type names. var originalAsArray = _serializer.SerializeToArray(original); - var classVersion = new Person5_Class { Age = 2, Name = "harry", FavouriteColor = "redborine", StarSign = "Aquaricorn" }; + var classVersion = new Person5_Class { Age = 2, Name = "harry", FavouriteColor = "redborine", StarSign = "Aquaricorn" }; var classAsArray = _serializer.SerializeToArray(classVersion); Assert.Equal(originalAsArray, classAsArray); } @@ -231,7 +252,7 @@ public void GeneratedSerializersRoundTripThroughSerializer_ImmutableClass() public void GeneratedSerializersRoundTripThroughSerializer_ImmutableStruct() { var original = new ImmutableStruct(30, 2); - var result = (ImmutableStruct)RoundTripThroughUntypedSerializer(original, out _); + var result = (ImmutableStruct)RoundTripThroughUntypedSerializer(original, out _); Assert.Equal(original.GetIntField(), result.GetIntField()); Assert.Equal(original.IntProperty, result.IntProperty); diff --git a/test/Orleans.Serialization.UnitTests/Orleans.Serialization.UnitTests.csproj b/test/Orleans.Serialization.UnitTests/Orleans.Serialization.UnitTests.csproj index 12592548bd..a659e0bca1 100644 --- a/test/Orleans.Serialization.UnitTests/Orleans.Serialization.UnitTests.csproj +++ b/test/Orleans.Serialization.UnitTests/Orleans.Serialization.UnitTests.csproj @@ -28,6 +28,7 @@ +