* Remove shared tests from the Roslyn3.11 test project.
* Decouple Roslyn3.11 smoke tests from shared test classes.
* Fix project file order.
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;
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;
- }
}
}
[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);
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; }
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;
+ }
+ }
}
[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);
}
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);
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);
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);
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);
ClassWithCustomConverterFactoryProperty obj = new()
{
- MyEnum = SampleEnum.One
+ MyEnum = SourceGenSampleEnum.One
};
if (DefaultContext.JsonSourceGenerationMode == JsonSourceGenerationMode.Serialization)
else
{
obj = JsonSerializer.Deserialize(Json, DefaultContext.ClassWithCustomConverterFactoryProperty);
- Assert.Equal(SampleEnum.One, obj.MyEnum);
+ Assert.Equal(SourceGenSampleEnum.One, obj.MyEnum);
}
}
StructWithCustomConverterFactoryProperty obj = new()
{
- MyEnum = SampleEnum.One
+ MyEnum = SourceGenSampleEnum.One
};
if (DefaultContext.JsonSourceGenerationMode == JsonSourceGenerationMode.Serialization)
else
{
obj = JsonSerializer.Deserialize(Json, DefaultContext.StructWithCustomConverterFactoryProperty);
- Assert.Equal(SampleEnum.One, obj.MyEnum);
+ Assert.Equal(SourceGenSampleEnum.One, obj.MyEnum);
}
}
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);
<Project Sdk="Microsoft.NET.Sdk">
+ <PropertyGroup>
+ <TestedRoslynVersion>3.11</TestedRoslynVersion>
+ </PropertyGroup>
+
<Import Project="System.Text.Json.SourceGeneration.Tests.targets" />
<ItemGroup Condition="'$(ContinuousIntegrationBuild)' == 'true'">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <RoslynSupportsRequiredAttributes>true</RoslynSupportsRequiredAttributes>
+ <TestedRoslynVersion>4.4</TestedRoslynVersion>
</PropertyGroup>
<ItemGroup Condition="'$(ContinuousIntegrationBuild)' == 'true'">
</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" />
<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" />
<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>
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
{
public int MyInt { get; set; }
}
+
+ public enum SourceGenSampleEnum
+ {
+ MinZero = 0,
+ One = 1,
+ Two = 2
+ }
}
[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
{
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];
}
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];
}