Skip to content

Add source generator unit tests for invalid JsonExtensionData cases #58945

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

Open
layomia opened this issue Sep 10, 2021 · 1 comment
Open

Add source generator unit tests for invalid JsonExtensionData cases #58945

layomia opened this issue Sep 10, 2021 · 1 comment
Labels
area-System.Text.Json source-generator Indicates an issue with a source generator feature test-enhancement Improvements of test source code
Milestone

Comments

@layomia
Copy link
Contributor

layomia commented Sep 10, 2021

Some of the serializer tests intentionally define invalid JsonExtensionData properties which would cause InvalidOperationException to be thrown at runtime, e.g.

private class ClassWithInvalidExtensionProperty
{
[JsonExtensionData]
public Dictionary<string, int> MyOverflow { get; set; }
}

When source generation is used, compile-time errors are logged rather than deferred to runtime. The PR adding support for JsonExtensionData (#58912) thus disables these tests so that the source generator test project (System.Text.Json.SourceGeneration.Tests) can compile. We should add unit test variants for coverage in System.Text.Json.SourceGeneration.Unit.Tests.

@layomia layomia added this to the 7.0.0 milestone Sep 10, 2021
@ghost
Copy link

ghost commented Sep 10, 2021

Tagging subscribers to this area: @eiriktsarpalis, @layomia
See info in area-owners.md if you want to be subscribed.

Issue Details

Some of the serializer tests intentionally define invalid JsonExtensionData properties which would cause InvalidOperationException to be thrown at runtime, e.g.

private class ClassWithInvalidExtensionProperty
{
[JsonExtensionData]
public Dictionary<string, int> MyOverflow { get; set; }
}

When source generation is used, compile-time errors are logged rather than deferred to runtime. The PR adding support for JsonExtensionData (#58912) thus disables these tests so that the source generator test project (System.Text.Json.SourceGeneration.Tests) can compile. We should add unit test variants for coverage in System.Text.Json.SourceGeneration.Unit.Tests.

Author: layomia
Assignees: -
Labels:

area-System.Text.Json

Milestone: 7.0.0

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Sep 10, 2021
@eiriktsarpalis eiriktsarpalis removed the untriaged New issue has not been triaged by the area owner label Sep 10, 2021
@layomia layomia added the source-generator Indicates an issue with a source generator feature label Sep 22, 2021
@eiriktsarpalis eiriktsarpalis added the test-enhancement Improvements of test source code label Oct 14, 2021
@jeffhandley jeffhandley modified the milestones: 7.0.0, Future Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Text.Json source-generator Indicates an issue with a source generator feature test-enhancement Improvements of test source code
Projects
None yet
Development

No branches or pull requests

3 participants