Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test failures and proper fix this time #18

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -605,10 +605,10 @@ private static void CreateJsonTypeInfo_Generic<T>()

static void TestCreateJsonTypeInfo(Func<JsonSerializerOptions, JsonTypeInfo<T>> getTypeInfo)
{
JsonSerializerOptions o = new();
JsonSerializerOptions o = new() { TypeInfoResolver = new DefaultJsonTypeInfoResolver() };
TestCreateJsonTypeInfoInstance(o, getTypeInfo(o));

o = new JsonSerializerOptions();
o = new JsonSerializerOptions() { TypeInfoResolver = new DefaultJsonTypeInfoResolver() };
var conv = new DummyConverter<T>();
o.Converters.Add(conv);
JsonTypeInfo<T> ti = getTypeInfo(o);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public static async Task DeserializeAsyncEnumerable_ReadSourceAsync<TElement>(IE
{
JsonSerializerOptions options = new JsonSerializerOptions
{
DefaultBufferSize = bufferSize
DefaultBufferSize = bufferSize,
TypeInfoResolver = new DefaultJsonTypeInfoResolver()
};

byte[] data = JsonSerializer.SerializeToUtf8Bytes(source);
Expand All @@ -82,7 +83,13 @@ public static async Task DeserializeAsyncEnumerable_ShouldStreamPartialData(bool
string json = JsonSerializer.Serialize(Enumerable.Range(0, 100));

using var stream = new Utf8MemoryStream(json);
IAsyncEnumerable<int> asyncEnumerable = DeserializeAsyncEnumerableWrapper<int>(stream, new JsonSerializerOptions { DefaultBufferSize = 1 }, useJsonTypeInfoOverload: useJsonTypeInfoOverload);
JsonSerializerOptions options = new JsonSerializerOptions
{
DefaultBufferSize = 1,
TypeInfoResolver = new DefaultJsonTypeInfoResolver()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests are being used both in reflection and source gen contexts. By hardcoding the resolver to the reflection converter this is effectively not testing source generation. It should be reverted.

};

IAsyncEnumerable<int> asyncEnumerable = DeserializeAsyncEnumerableWrapper<int>(stream, options, useJsonTypeInfoOverload: useJsonTypeInfoOverload);
await using IAsyncEnumerator<int> asyncEnumerator = asyncEnumerable.GetAsyncEnumerator();

for (int i = 0; i < 20; i++)
Expand All @@ -102,7 +109,8 @@ public static async Task DeserializeAsyncEnumerable_ShouldTolerateCustomQueueCon

JsonSerializerOptions options = new JsonSerializerOptions
{
Converters = { new DegenerateQueueConverterFactory() }
Converters = { new DegenerateQueueConverterFactory() },
TypeInfoResolver = new DefaultJsonTypeInfoResolver()
};

byte[] data = JsonSerializer.SerializeToUtf8Bytes(Enumerable.Repeat(Enumerable.Repeat(1,3), expectedCount));
Expand Down Expand Up @@ -181,7 +189,8 @@ public static async Task DeserializeAsyncEnumerable_CancellationToken_ThrowsOnCa
{
JsonSerializerOptions options = new JsonSerializerOptions
{
DefaultBufferSize = 1
DefaultBufferSize = 1,
TypeInfoResolver = new DefaultJsonTypeInfoResolver()
};

byte[] data = JsonSerializer.SerializeToUtf8Bytes(Enumerable.Range(1, 100));
Expand All @@ -205,7 +214,8 @@ public static async Task DeserializeAsyncEnumerable_EnumeratorWithCancellationTo
{
JsonSerializerOptions options = new JsonSerializerOptions
{
DefaultBufferSize = 1
DefaultBufferSize = 1,
TypeInfoResolver = new DefaultJsonTypeInfoResolver()
};

byte[] data = JsonSerializer.SerializeToUtf8Bytes(Enumerable.Range(1, 100));
Expand Down