Remove common tests from the Roslyn3.11 test project. (#85165)
authorEirik Tsarpalis <eirik.tsarpalis@gmail.com>
Mon, 24 Apr 2023 13:19:41 +0000 (14:19 +0100)
committerGitHub <noreply@github.com>
Mon, 24 Apr 2023 13:19:41 +0000 (14:19 +0100)
* Remove shared tests from the Roslyn3.11 test project.

* Decouple Roslyn3.11 smoke tests from shared test classes.

* Fix project file order.

14 files changed:
src/libraries/System.Text.Json/tests/Common/JsonTestHelper.cs
src/libraries/System.Text.Json/tests/Common/NodeInteropTests.cs
src/libraries/System.Text.Json/tests/Common/SampleTestData.OrderPayload.cs
src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/JsonSerializerContextTests.cs
src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/MetadataAndSerializationContextTests.cs
src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/MetadataContextTests.cs
src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/MixedModeContextTests.cs
src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/RealWorldContextTests.cs
src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/SerializationContextTests.cs
src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/System.Text.Json.SourceGeneration.Roslyn3.11.Tests.csproj
src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/System.Text.Json.SourceGeneration.Roslyn4.4.Tests.csproj
src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/System.Text.Json.SourceGeneration.Tests.targets
src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/TestClasses.CustomConverters.cs
src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Stream.WriteTests.cs

index f95fb43..08adddd 100644 (file)
@@ -4,8 +4,6 @@
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Linq;
-using System.Text.Json.Serialization.Tests;
-using System.Text.Json.Serialization.Tests.Schemas.OrderPayload;
 using System.Text.RegularExpressions;
 using System.Threading.Tasks;
 using Xunit;
@@ -189,187 +187,5 @@ namespace System.Text.Json
 
         public static string StripWhitespace(this string value)
             => s_stripWhitespace.Replace(value, string.Empty);
-
-        internal static List<Order> PopulateLargeObject(int size)
-        {
-            List<Order> orders = new List<Order>(size);
-            for (int i = 0; i < size; i++)
-            {
-                Order order = new Order
-                {
-                    OrderNumber = i,
-                    Customer = new User
-                    {
-                        UserId = "222ffbbb888kkk",
-                        Name = "John Doe",
-                        Username = "johndoe",
-                        CreatedAt = new DateTime(),
-                        ImageId = string.Empty,
-                        UserType = UserType.Customer,
-                        UpdatedAt = new DateTime(),
-                        TwitterId = string.Empty,
-                        FacebookId = "9988998877662222111",
-                        SubscriptionType = 2,
-                        IsNew = true,
-                        IsEmployee = false
-                    },
-                    ShippingInfo = new List<ShippingInfo>
-                    {
-                        new ShippingInfo()
-                        {
-                            OrderNumber = i,
-                            Employee = new User
-                            {
-                                UserId = "222ffbbb888" + i,
-                                Name = "Shipping Coordinator",
-                                Username = "coordinator" + i,
-                                CreatedAt = new DateTime(),
-                                ImageId = string.Empty,
-                                UserType = UserType.Employee,
-                                UpdatedAt = new DateTime(),
-                                TwitterId = string.Empty,
-                                SubscriptionType = 0,
-                                IsEmployee = true
-                            },
-                            CarrierId = "TTT123999MMM",
-                            ShippingType = "Ground",
-                            EstimatedDelivery = new DateTime(),
-                            Tracking = new Uri("http://TestShipCompany.test/track/123" + i),
-                            CarrierName = "TestShipCompany",
-                            HandlingInstruction = "Do cats eat bats? Do cats eat bats. Do cats eat bats? Do cats eat bats. Do cats eat bats? Do cats eat bats. Do cats eat bats? Do cats eat bats",
-                            CurrentStatus = "Out for delivery",
-                            IsDangerous = false
-                        }
-                    },
-                    OneTime = true,
-                    Cancelled = false,
-                    IsGift = i % 2 == 0,
-                    IsGPickUp = i % 5 == 0,
-                    ShippingAddress = new Address()
-                    {
-                        City = "Redmond"
-                    },
-                    PickupAddress = new Address
-                    {
-                        City = "Bellevue"
-                    },
-                    Coupon = SampleEnumInt64.Max,
-                    UserInteractions = new List<Comment>
-                    {
-                        new Comment
-                        {
-                            Id = 200 + i,
-                            OrderNumber = i,
-                            Customer = new User
-                            {
-                                UserId = "222ffbbb888kkk",
-                                Name = "John Doe",
-                                Username = "johndoe",
-                                CreatedAt = new DateTime(),
-                                ImageId = string.Empty,
-                                UserType = UserType.Customer,
-                                UpdatedAt = new DateTime(),
-                                TwitterId = "twitterId" + i,
-                                FacebookId = "9988998877662222111",
-                                SubscriptionType = 2,
-                                IsNew = true,
-                                IsEmployee = false
-                            },
-                            Title = "Green Field",
-                            Message = "Down, down, down. Would the fall never come to an end! 'I wonder how many miles I've fallen by this time. I think-' (for, you see, Alice had learnt several things of this sort in her lessons in the schoolroom, and though this was not a very good opportunity for showing off her knowledge, as there was no one to listen to her, still it was good practice to say it over) '-yes, that's about the right distance-but then I wonder what Latitude or Longitude I've got to",
-                            Responses = new List<Comment>()
-                        }
-                    },
-                    Created = new DateTime(2019, 11, 10),
-                    Confirmed = new DateTime(2019, 11, 11),
-                    ShippingDate = new DateTime(2019, 11, 12),
-                    EstimatedDelivery = new DateTime(2019, 11, 15),
-                    ReviewedBy = new User()
-                    {
-                        UserId = "222ffbbb888" + i,
-                        Name = "Shipping Coordinator",
-                        Username = "coordinator" + i,
-                        CreatedAt = new DateTime(),
-                        ImageId = string.Empty,
-                        UserType = UserType.Employee,
-                        UpdatedAt = new DateTime(),
-                        TwitterId = string.Empty,
-                        SubscriptionType = 0,
-                        IsEmployee = true
-                    }
-                };
-                List<Product> products = new List<Product>();
-                for (int j = 0; j < i % 4; j++)
-                {
-                    Product product = new Product()
-                    {
-                        ProductId = Guid.NewGuid(),
-                        Name = "Surface Pro",
-                        SKU = "LL123" + j,
-                        Brand = new TestClassWithInitializedProperties(),
-                        ProductCategory = new SimpleTestClassWithNonGenericCollectionWrappers(),
-                        Description = "Down, down, down. Would the fall never come to an end! 'I wonder how many miles I've fallen by this time. I think-' (for, you see, Alice had learnt several things of this sort in her lessons in the schoolroom, and though this was not a very good opportunity for showing off her knowledge, as there was no one to listen to her, still it was good practice to say it over) '-yes, that's about the right distance-but then I wonder what Latitude or Longitude I've got to",
-                        Created = new DateTime(2000, 10, 12),
-                        Title = "Surface Pro 6 for Business - 512GB",
-                        Price = new Price(),
-                        BestChoice = true,
-                        AverageStars = 4.8f,
-                        Featured = true,
-                        ProductRestrictions = new TestClassWithInitializedProperties(),
-                        SalesInfo = new SimpleTestClassWithGenericCollectionWrappers(),
-                        Origin = SampleEnum.One,
-                        Manufacturer = new BasicCompany(),
-                        Fragile = true,
-                        DetailsUrl = new Uri("http://dotnet.test/link/entries/entry/1"),
-                        NetWeight = 2.7m,
-                        GrossWeight = 3.3m,
-                        Length = i,
-                        Height = i + 1,
-                        Width = i + 2,
-                        FeaturedImage = new FeaturedImage(),
-                        PreviewImage = new PreviewImage(),
-                        KeyWords = new List<string> { "surface", "pro", "laptop" },
-                        RelatedImages = new List<Image>(),
-                        RelatedVideo = new Uri("http://dotnet.test/link/entries/entry/2"),
-                        GuaranteeStartsAt = new DateTime(),
-                        GuaranteeEndsAt = new DateTime(),
-                        IsActive = true,
-                        RelatedProducts = new List<Product>()
-                    };
-                    product.SalesInfo.Initialize();
-                    List<Review> reviews = new List<Review>();
-                    for (int k = 0; k < i % 3; k++)
-                    {
-
-                        Review review = new Review
-                        {
-                            Customer = new User
-                            {
-                                UserId = "333344445555",
-                                Name = "Customer" + i + k,
-                                Username = "cust" + i + k,
-                                CreatedAt = new DateTime(),
-                                ImageId = string.Empty,
-                                UserType = UserType.Customer,
-                                SubscriptionType = k
-                            },
-                            ProductSku = product.SKU,
-                            CustomerName = "Customer" + i + k,
-                            Stars = j + k,
-                            Title = $"Title {i}{j}{k}",
-                            Comment = "",
-                            Images = new List<Uri> { new Uri($"http://dotnet.test/link/images/image/{k}"), new Uri($"http://dotnet.test/link/images/image/{j}") },
-                            ReviewId = i + j + k
-                        };
-                        reviews.Add(review);
-                    }
-                    product.Reviews = reviews;
-                    products.Add(product);
-                }
-                order.Products = products;
-                orders.Add(order);
-            }
-            return orders;
-        }
     }
 }
index 3f79f69..15a1992 100644 (file)
@@ -16,7 +16,7 @@ namespace System.Text.Json.Serialization.Tests
         [Fact]
         public async Task CompareResultsAgainstSerializer()
         {
-            List<Order> obj = JsonTestHelper.PopulateLargeObject(2);
+            List<Order> obj = Order.PopulateLargeObject(2);
             string expected = await Serializer.SerializeWrapper(obj);
 
             JsonArray jArray = await Serializer.DeserializeWrapper<JsonArray>(expected);
index c8d39d4..452389d 100644 (file)
@@ -5,7 +5,7 @@ using System.Collections.Generic;
 
 namespace System.Text.Json.Serialization.Tests.Schemas.OrderPayload
 { 
-    public class Order
+    public partial class Order
     {
         public long OrderNumber { get; set; }
         public User Customer { get; set; }
@@ -162,4 +162,189 @@ namespace System.Text.Json.Serialization.Tests.Schemas.OrderPayload
         Employee = 2,
         Supplier = 3
     }
+
+    public partial class Order
+    {
+        public static List<Order> PopulateLargeObject(int size)
+        {
+            List<Order> orders = new List<Order>(size);
+            for (int i = 0; i < size; i++)
+            {
+                Order order = new Order
+                {
+                    OrderNumber = i,
+                    Customer = new User
+                    {
+                        UserId = "222ffbbb888kkk",
+                        Name = "John Doe",
+                        Username = "johndoe",
+                        CreatedAt = new DateTime(),
+                        ImageId = string.Empty,
+                        UserType = UserType.Customer,
+                        UpdatedAt = new DateTime(),
+                        TwitterId = string.Empty,
+                        FacebookId = "9988998877662222111",
+                        SubscriptionType = 2,
+                        IsNew = true,
+                        IsEmployee = false
+                    },
+                    ShippingInfo = new List<ShippingInfo>
+                    {
+                        new ShippingInfo()
+                        {
+                            OrderNumber = i,
+                            Employee = new User
+                            {
+                                UserId = "222ffbbb888" + i,
+                                Name = "Shipping Coordinator",
+                                Username = "coordinator" + i,
+                                CreatedAt = new DateTime(),
+                                ImageId = string.Empty,
+                                UserType = UserType.Employee,
+                                UpdatedAt = new DateTime(),
+                                TwitterId = string.Empty,
+                                SubscriptionType = 0,
+                                IsEmployee = true
+                            },
+                            CarrierId = "TTT123999MMM",
+                            ShippingType = "Ground",
+                            EstimatedDelivery = new DateTime(),
+                            Tracking = new Uri("http://TestShipCompany.test/track/123" + i),
+                            CarrierName = "TestShipCompany",
+                            HandlingInstruction = "Do cats eat bats? Do cats eat bats. Do cats eat bats? Do cats eat bats. Do cats eat bats? Do cats eat bats. Do cats eat bats? Do cats eat bats",
+                            CurrentStatus = "Out for delivery",
+                            IsDangerous = false
+                        }
+                    },
+                    OneTime = true,
+                    Cancelled = false,
+                    IsGift = i % 2 == 0,
+                    IsGPickUp = i % 5 == 0,
+                    ShippingAddress = new Address()
+                    {
+                        City = "Redmond"
+                    },
+                    PickupAddress = new Address
+                    {
+                        City = "Bellevue"
+                    },
+                    Coupon = SampleEnumInt64.Max,
+                    UserInteractions = new List<Comment>
+                    {
+                        new Comment
+                        {
+                            Id = 200 + i,
+                            OrderNumber = i,
+                            Customer = new User
+                            {
+                                UserId = "222ffbbb888kkk",
+                                Name = "John Doe",
+                                Username = "johndoe",
+                                CreatedAt = new DateTime(),
+                                ImageId = string.Empty,
+                                UserType = UserType.Customer,
+                                UpdatedAt = new DateTime(),
+                                TwitterId = "twitterId" + i,
+                                FacebookId = "9988998877662222111",
+                                SubscriptionType = 2,
+                                IsNew = true,
+                                IsEmployee = false
+                            },
+                            Title = "Green Field",
+                            Message = "Down, down, down. Would the fall never come to an end! 'I wonder how many miles I've fallen by this time. I think-' (for, you see, Alice had learnt several things of this sort in her lessons in the schoolroom, and though this was not a very good opportunity for showing off her knowledge, as there was no one to listen to her, still it was good practice to say it over) '-yes, that's about the right distance-but then I wonder what Latitude or Longitude I've got to",
+                            Responses = new List<Comment>()
+                        }
+                    },
+                    Created = new DateTime(2019, 11, 10),
+                    Confirmed = new DateTime(2019, 11, 11),
+                    ShippingDate = new DateTime(2019, 11, 12),
+                    EstimatedDelivery = new DateTime(2019, 11, 15),
+                    ReviewedBy = new User()
+                    {
+                        UserId = "222ffbbb888" + i,
+                        Name = "Shipping Coordinator",
+                        Username = "coordinator" + i,
+                        CreatedAt = new DateTime(),
+                        ImageId = string.Empty,
+                        UserType = UserType.Employee,
+                        UpdatedAt = new DateTime(),
+                        TwitterId = string.Empty,
+                        SubscriptionType = 0,
+                        IsEmployee = true
+                    }
+                };
+                List<Product> products = new List<Product>();
+                for (int j = 0; j < i % 4; j++)
+                {
+                    Product product = new Product()
+                    {
+                        ProductId = Guid.NewGuid(),
+                        Name = "Surface Pro",
+                        SKU = "LL123" + j,
+                        Brand = new TestClassWithInitializedProperties(),
+                        ProductCategory = new SimpleTestClassWithNonGenericCollectionWrappers(),
+                        Description = "Down, down, down. Would the fall never come to an end! 'I wonder how many miles I've fallen by this time. I think-' (for, you see, Alice had learnt several things of this sort in her lessons in the schoolroom, and though this was not a very good opportunity for showing off her knowledge, as there was no one to listen to her, still it was good practice to say it over) '-yes, that's about the right distance-but then I wonder what Latitude or Longitude I've got to",
+                        Created = new DateTime(2000, 10, 12),
+                        Title = "Surface Pro 6 for Business - 512GB",
+                        Price = new Price(),
+                        BestChoice = true,
+                        AverageStars = 4.8f,
+                        Featured = true,
+                        ProductRestrictions = new TestClassWithInitializedProperties(),
+                        SalesInfo = new SimpleTestClassWithGenericCollectionWrappers(),
+                        Origin = SampleEnum.One,
+                        Manufacturer = new BasicCompany(),
+                        Fragile = true,
+                        DetailsUrl = new Uri("http://dotnet.test/link/entries/entry/1"),
+                        NetWeight = 2.7m,
+                        GrossWeight = 3.3m,
+                        Length = i,
+                        Height = i + 1,
+                        Width = i + 2,
+                        FeaturedImage = new FeaturedImage(),
+                        PreviewImage = new PreviewImage(),
+                        KeyWords = new List<string> { "surface", "pro", "laptop" },
+                        RelatedImages = new List<Image>(),
+                        RelatedVideo = new Uri("http://dotnet.test/link/entries/entry/2"),
+                        GuaranteeStartsAt = new DateTime(),
+                        GuaranteeEndsAt = new DateTime(),
+                        IsActive = true,
+                        RelatedProducts = new List<Product>()
+                    };
+                    product.SalesInfo.Initialize();
+                    List<Review> reviews = new List<Review>();
+                    for (int k = 0; k < i % 3; k++)
+                    {
+
+                        Review review = new Review
+                        {
+                            Customer = new User
+                            {
+                                UserId = "333344445555",
+                                Name = "Customer" + i + k,
+                                Username = "cust" + i + k,
+                                CreatedAt = new DateTime(),
+                                ImageId = string.Empty,
+                                UserType = UserType.Customer,
+                                SubscriptionType = k
+                            },
+                            ProductSku = product.SKU,
+                            CustomerName = "Customer" + i + k,
+                            Stars = j + k,
+                            Title = $"Title {i}{j}{k}",
+                            Comment = "",
+                            Images = new List<Uri> { new Uri($"http://dotnet.test/link/images/image/{k}"), new Uri($"http://dotnet.test/link/images/image/{j}") },
+                            ReviewId = i + j + k
+                        };
+                        reviews.Add(review);
+                    }
+                    product.Reviews = reviews;
+                    products.Add(product);
+                }
+                order.Products = products;
+                orders.Add(order);
+            }
+            return orders;
+        }
+    }
 }
index d199424..2af24e5 100644 (file)
@@ -667,7 +667,7 @@ namespace System.Text.Json.SourceGeneration.Tests
         [Fact]
         public static void SupportsPropertiesWithCustomConverterFactory()
         {
-            var value = new ClassWithCustomConverterFactoryProperty { MyEnum = Serialization.Tests.SampleEnum.MinZero };
+            var value = new ClassWithCustomConverterFactoryProperty { MyEnum = SourceGenSampleEnum.MinZero };
             string json = JsonSerializer.Serialize(value, SingleClassWithCustomConverterFactoryPropertyContext.Default.ClassWithCustomConverterFactoryProperty);
             Assert.Equal(@"{""MyEnum"":""MinZero""}", json);
         }
index a1fd660..8e37e93 100644 (file)
@@ -83,7 +83,7 @@ namespace System.Text.Json.SourceGeneration.Tests
             Assert.NotNull(MetadataAndSerializationContext.Default.MyNestedClass.SerializeHandler);
             Assert.NotNull(MetadataAndSerializationContext.Default.MyNestedNestedClass.SerializeHandler);
             Assert.Null(MetadataAndSerializationContext.Default.ObjectArray.SerializeHandler);
-            Assert.Null(MetadataAndSerializationContext.Default.SampleEnum.SerializeHandler);
+            Assert.Null(MetadataAndSerializationContext.Default.SourceGenSampleEnum.SerializeHandler);
             Assert.Null(MetadataAndSerializationContext.Default.String.SerializeHandler);
             Assert.NotNull(MetadataAndSerializationContext.Default.ValueTupleStringInt32Boolean.SerializeHandler);
             Assert.Null(MetadataAndSerializationContext.Default.JsonDocument.SerializeHandler);
index c1961e7..4cb8394 100644 (file)
@@ -81,7 +81,7 @@ namespace System.Text.Json.SourceGeneration.Tests
             Assert.Null(MetadataWithPerTypeAttributeContext.Default.MyNestedNestedClass.SerializeHandler);
             Assert.Null(MetadataWithPerTypeAttributeContext.Default.ObjectArray.SerializeHandler);
             Assert.Null(MetadataWithPerTypeAttributeContext.Default.ByteArray.SerializeHandler);
-            Assert.Null(MetadataWithPerTypeAttributeContext.Default.SampleEnum.SerializeHandler);
+            Assert.Null(MetadataWithPerTypeAttributeContext.Default.SourceGenSampleEnum.SerializeHandler);
             Assert.Null(MetadataWithPerTypeAttributeContext.Default.String.SerializeHandler);
             Assert.Null(MetadataWithPerTypeAttributeContext.Default.ValueTupleStringInt32Boolean.SerializeHandler);
             Assert.Null(MetadataWithPerTypeAttributeContext.Default.JsonDocument.SerializeHandler);
@@ -204,7 +204,7 @@ namespace System.Text.Json.SourceGeneration.Tests
             Assert.Null(MetadataContext.Default.MyNestedNestedClass.SerializeHandler);
             Assert.Null(MetadataContext.Default.ObjectArray.SerializeHandler);
             Assert.Null(MetadataContext.Default.ByteArray.SerializeHandler);
-            Assert.Null(MetadataContext.Default.SampleEnum.SerializeHandler);
+            Assert.Null(MetadataContext.Default.SourceGenSampleEnum.SerializeHandler);
             Assert.Null(MetadataContext.Default.String.SerializeHandler);
             Assert.Null(MetadataContext.Default.ValueTupleStringInt32Boolean.SerializeHandler);
             Assert.Null(MetadataContext.Default.JsonDocument.SerializeHandler);
index 2affcb3..98d3dfa 100644 (file)
@@ -83,7 +83,7 @@ namespace System.Text.Json.SourceGeneration.Tests
             Assert.NotNull(MixedModeContext.Default.MyNestedNestedClass.SerializeHandler);
             Assert.Null(MixedModeContext.Default.ObjectArray.SerializeHandler);
             Assert.Null(MixedModeContext.Default.ByteArray.SerializeHandler);
-            Assert.Null(MixedModeContext.Default.SampleEnum.SerializeHandler);
+            Assert.Null(MixedModeContext.Default.SourceGenSampleEnum.SerializeHandler);
             Assert.Null(MixedModeContext.Default.String.SerializeHandler);
             Assert.NotNull(MixedModeContext.Default.ValueTupleStringInt32Boolean.SerializeHandler);
             Assert.Null(MixedModeContext.Default.JsonDocument.SerializeHandler);
index 1f791fc..1d482e1 100644 (file)
@@ -291,7 +291,7 @@ namespace System.Text.Json.SourceGeneration.Tests
 
             ClassWithCustomConverterFactoryProperty obj = new()
             {
-                MyEnum = SampleEnum.One
+                MyEnum = SourceGenSampleEnum.One
             };
 
             if (DefaultContext.JsonSourceGenerationMode == JsonSourceGenerationMode.Serialization)
@@ -311,7 +311,7 @@ namespace System.Text.Json.SourceGeneration.Tests
             else
             {
                 obj = JsonSerializer.Deserialize(Json, DefaultContext.ClassWithCustomConverterFactoryProperty);
-                Assert.Equal(SampleEnum.One, obj.MyEnum);
+                Assert.Equal(SourceGenSampleEnum.One, obj.MyEnum);
             }
         }
 
@@ -322,7 +322,7 @@ namespace System.Text.Json.SourceGeneration.Tests
 
             StructWithCustomConverterFactoryProperty obj = new()
             {
-                MyEnum = SampleEnum.One
+                MyEnum = SourceGenSampleEnum.One
             };
 
             if (DefaultContext.JsonSourceGenerationMode == JsonSourceGenerationMode.Serialization)
@@ -342,7 +342,7 @@ namespace System.Text.Json.SourceGeneration.Tests
             else
             {
                 obj = JsonSerializer.Deserialize(Json, DefaultContext.StructWithCustomConverterFactoryProperty);
-                Assert.Equal(SampleEnum.One, obj.MyEnum);
+                Assert.Equal(SourceGenSampleEnum.One, obj.MyEnum);
             }
         }
 
index 971b858..837e896 100644 (file)
@@ -568,7 +568,7 @@ namespace System.Text.Json.SourceGeneration.Tests
             Assert.NotNull(SerializationWithPerTypeAttributeContext.Default.MyNestedNestedClass.SerializeHandler);
             Assert.Null(SerializationWithPerTypeAttributeContext.Default.ObjectArray.SerializeHandler);
             Assert.Null(SerializationWithPerTypeAttributeContext.Default.ByteArray.SerializeHandler);
-            Assert.Null(SerializationWithPerTypeAttributeContext.Default.SampleEnum.SerializeHandler);
+            Assert.Null(SerializationWithPerTypeAttributeContext.Default.SourceGenSampleEnum.SerializeHandler);
             Assert.Null(SerializationWithPerTypeAttributeContext.Default.String.SerializeHandler);
             Assert.NotNull(SerializationWithPerTypeAttributeContext.Default.ValueTupleStringInt32Boolean.SerializeHandler);
             Assert.Null(SerializationWithPerTypeAttributeContext.Default.JsonDocument.SerializeHandler);
index eed730c..ddaadbb 100644 (file)
   </ItemGroup>
 
   <ItemGroup>
+    <!-- Core test suite shared with the Roslyn3.11 target. Do not add new tests here. -->
     <Compile Include="$(CommonTestPath)System\DateTimeTestHelpers.cs" Link="CommonTest\System\DateTimeTestHelpers.cs" />
+    <Compile Include="..\Common\JsonSerializerWrapper.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\JsonSerializerWrapper.cs" />
+    <Compile Include="..\Common\JsonTestHelper.cs" Link="CommonTest\System\Text\Json\JsonTestHelper.cs" />
+    <Compile Include="..\Common\SerializerTests.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\SerializerTests.cs" />
+    <Compile Include="..\Common\StreamingJsonSerializerWrapper.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\StreamingJsonSerializerWrapper.cs" />
+    <Compile Include="..\Common\Utf8MemoryStream.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\Utf8MemoryStream.cs" />
+    <Compile Include="ContextClasses.cs" />
+    <Compile Include="JsonSerializerContextTests.cs" />
+    <Compile Include="JsonTestHelper.cs" />
+    <Compile Include="MetadataAndSerializationContextTests.cs" />
+    <Compile Include="MetadataContextTests.cs" />
+    <Compile Include="MixedModeContextTests.cs" />
+    <Compile Include="NETStandardContextTests.cs" />
+    <Compile Include="RealWorldContextTests.cs" />
+    <Compile Include="Serialization\JsonSerializerWrapper.SourceGen.cs" />
+    <Compile Include="SerializationContextTests.cs" />
+    <Compile Include="SerializationLogicTests.cs" />
+    <Compile Include="TestClasses.cs" />
+    <Compile Include="TestClasses.CustomConverters.cs" />
+  </ItemGroup>
+
+  <ItemGroup Condition="'$(TestedRoslynVersion)' >= '4.0'">
+    <!-- Newly added test suites typically go here. -->
     <Compile Include="..\Common\CollectionTests\CollectionTests.AsyncEnumerable.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\CollectionTests\CollectionTests.AsyncEnumerable.cs" />
     <Compile Include="..\Common\CollectionTests\CollectionTests.Concurrent.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\CollectionTests\CollectionTests.Concurrent.cs" />
     <Compile Include="..\Common\CollectionTests\CollectionTests.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\CollectionTests\CollectionTests.cs" />
@@ -48,9 +71,6 @@
     <Compile Include="..\Common\ConstructorTests\ConstructorTests.ParameterMatching.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\ConstructorTests\ConstructorTests.ParameterMatching.cs" />
     <Compile Include="..\Common\ConstructorTests\ConstructorTests.Stream.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\ConstructorTests\ConstructorTests.Stream.cs" />
     <Compile Include="..\Common\ExtensionDataTests.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\ExtensionDataTests.cs" />
-    <Compile Include="..\Common\StreamingJsonSerializerWrapper.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\StreamingJsonSerializerWrapper.cs" />
-    <Compile Include="..\Common\JsonSerializerWrapper.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\JsonSerializerWrapper.cs" />
-    <Compile Include="..\Common\JsonTestHelper.cs" Link="CommonTest\System\Text\Json\JsonTestHelper.cs" />
     <Compile Include="..\Common\NodeInteropTests.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\NodeInteropTests.cs" />
     <Compile Include="..\Common\PropertyNameTests.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\PropertyNameTests.cs" />
     <Compile Include="..\Common\PropertyVisibilityTests.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\PropertyVisibilityTests.cs" />
@@ -61,8 +81,6 @@
     <Compile Include="..\Common\ReferenceHandlerTests\ReferenceHandlerTests.IgnoreCycles.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\ReferenceHandlerTests\ReferenceHandlerTests.IgnoreCycles.cs" />
     <Compile Include="..\Common\ReferenceHandlerTests\ReferenceHandlerTests.Serialize.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\ReferenceHandlerTests\ReferenceHandlerTests.Serialize.cs" />
     <Compile Include="..\Common\SampleTestData.OrderPayload.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\SampleTestData.OrderPayload.cs" />
-    <Compile Include="..\Common\SerializerTests.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\SerializerTests.cs" />
-    <Compile Include="..\Common\UnmappedMemberHandlingTests.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\UnmappedMemberHandlingTests.cs" />
     <Compile Include="..\Common\TestClasses\TestClasses.ConcurrentCollections.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\TestClasses\TestClasses.ConcurrentCollections.cs" />
     <Compile Include="..\Common\TestClasses\TestClasses.Constructor.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\TestClasses\TestClasses.Constructor.cs" />
     <Compile Include="..\Common\TestClasses\TestClasses.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\TestClasses\TestClasses.cs" />
     <Compile Include="..\Common\TestClasses\TestClasses.SimpleTestStructWithFields.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\TestClasses\TestClasses.SimpleTestStructWithFields.cs" />
     <Compile Include="..\Common\TestClasses\TestClasses.ValueTypedMember.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\TestClasses\TestClasses.ValueTypedMember.cs" />
     <Compile Include="..\Common\TestClasses\TestData.cs"  Link="CommonTest\System\Text\Json\Tests\Serialization\TestClasses\TestData.cs" />
+    <Compile Include="..\Common\UnmappedMemberHandlingTests.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\UnmappedMemberHandlingTests.cs" />
     <Compile Include="..\Common\UnsupportedTypesTests.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\UnsupportedTypesTests.cs" />
-    <Compile Include="..\Common\Utf8MemoryStream.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\Utf8MemoryStream.cs" />
-    <Compile Include="ContextClasses.cs" />
-    <Compile Include="JsonSerializerContextTests.cs" />
     <Compile Include="Serialization\CollectionTests.cs" />
     <Compile Include="Serialization\ConstructorTests.cs" />
     <Compile Include="Serialization\ExtensionDataTests.cs" />
-    <Compile Include="Serialization\JsonSerializerWrapper.SourceGen.cs" />
     <Compile Include="Serialization\ReferenceHandlerTests.cs" />
     <Compile Include="Serialization\ReferenceHandlerTests.IgnoreCycles.cs" />
-    <Compile Include="JsonTestHelper.cs" />
-    <Compile Include="MetadataAndSerializationContextTests.cs" />
-    <Compile Include="MetadataContextTests.cs" />
-    <Compile Include="MixedModeContextTests.cs" />
-    <Compile Include="NETStandardContextTests.cs" />
-    <Compile Include="RealWorldContextTests.cs" />
-    <Compile Include="SerializationContextTests.cs" />
-    <Compile Include="SerializationLogicTests.cs" />
     <Compile Include="Serialization\NodeInteropTests.cs" />
     <Compile Include="Serialization\PropertyNameTests.cs" />
     <Compile Include="Serialization\PropertyVisibilityTests.cs" />
     <Compile Include="Serialization\UnmappedMemberHandlingTests.cs" />
     <Compile Include="Serialization\UnsupportedTypesTests.cs" />
-    <Compile Include="TestClasses.cs" />
-    <Compile Include="TestClasses.CustomConverters.cs" />
     <Compile Include="UnspeakableTypeTests.cs" />
   </ItemGroup>
 
-  <ItemGroup Condition="'$(RoslynSupportsRequiredAttributes)' == 'true'">
+  <ItemGroup Condition="'$(TestedRoslynVersion)' >= '4.4'">
    <Compile Include="..\Common\RequiredKeywordTests.cs" Link="CommonTest\System\Text\Json\Tests\Serialization\RequiredKeywordTests.cs" /> 
    <Compile Include="Serialization\RequiredKeywordTests.cs" />
   </ItemGroup>
index 4de62e0..18762d2 100644 (file)
@@ -248,13 +248,13 @@ namespace System.Text.Json.SourceGeneration.Tests
     public class ClassWithCustomConverterFactoryProperty
     {
         [JsonConverter(typeof(JsonStringEnumConverter))] // This converter is a JsonConverterFactory
-        public Serialization.Tests.SampleEnum MyEnum { get; set; }
+        public SourceGenSampleEnum MyEnum { get; set; }
     }
 
     public struct StructWithCustomConverterFactoryProperty
     {
         [JsonConverter(typeof(JsonStringEnumConverter))] // This converter is a JsonConverterFactory
-        public Serialization.Tests.SampleEnum MyEnum { get; set; }
+        public SourceGenSampleEnum MyEnum { get; set; }
     }
 
     [JsonConverter(typeof(CustomConverter_StructWithCustomConverter))] // Invalid
@@ -268,4 +268,11 @@ namespace System.Text.Json.SourceGeneration.Tests
     {
         public int MyInt { get; set; }
     }
+
+    public enum SourceGenSampleEnum
+    {
+        MinZero = 0,
+        One = 1,
+        Two = 2
+    }
 }
index d1062f1..c3734c5 100644 (file)
@@ -290,7 +290,7 @@ namespace System.Text.Json.Serialization.Tests
         [InlineData(1000, false, false)]
         public async Task VeryLargeJsonFileTest(int payloadSize, bool ignoreNull, bool writeIndented)
         {
-            List<Order> list = JsonTestHelper.PopulateLargeObject(payloadSize);
+            List<Order> list = Order.PopulateLargeObject(payloadSize);
 
             JsonSerializerOptions options = new JsonSerializerOptions
             {
@@ -338,10 +338,10 @@ namespace System.Text.Json.Serialization.Tests
 
             int length = ListLength * depthFactor;
             List<Order>[] orders = new List<Order>[length];
-            orders[0] = JsonTestHelper.PopulateLargeObject(1);
+            orders[0] = Order.PopulateLargeObject(1);
             for (int i = 1; i < length; i++ )
             {
-                orders[i] = JsonTestHelper.PopulateLargeObject(1);
+                orders[i] = Order.PopulateLargeObject(1);
                 orders[i - 1][0].RelatedOrder = orders[i];
             }
 
@@ -382,10 +382,10 @@ namespace System.Text.Json.Serialization.Tests
 
             int length = ListLength * depthFactor;
             List<Order>[] orders = new List<Order>[length];
-            orders[0] = JsonTestHelper.PopulateLargeObject(1000);
+            orders[0] = Order.PopulateLargeObject(1000);
             for (int i = 1; i < length; i++)
             {
-                orders[i] = JsonTestHelper.PopulateLargeObject(1);
+                orders[i] = Order.PopulateLargeObject(1);
                 orders[i - 1][0].RelatedOrder = orders[i];
             }