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

Replace invalid sourcegen debug assertion with runtime check #68828

Conversation

eiriktsarpalis
Copy link
Member

Per #68072, Roslyn's AttributeData.AttributeConstructor property can return null if generating source for unresolved symbols. The STJ source generator erroneously asserts that the constructor can never be null, resulting in assert failure popups when working with debug builds of the source generator. This PR replaces the debug assertion with a runtime check (in line with how we throw exceptions in other parts of the source generator).

Fix #68072.

@ghost
Copy link

ghost commented May 3, 2022

Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis
See info in area-owners.md if you want to be subscribed.

Issue Details

Per #68072, Roslyn's AttributeData.AttributeConstructor property can return null if generating source for unresolved symbols. The STJ source generator erroneously asserts that the constructor can never be null, resulting in assert failure popups when working with debug builds of the source generator. This PR replaces the debug assertion with a runtime check (in line with how we throw exceptions in other parts of the source generator).

Fix #68072.

Author: eiriktsarpalis
Assignees: -
Labels:

area-System.Text.Json

Milestone: -

@eiriktsarpalis eiriktsarpalis added this to the 7.0.0 milestone May 3, 2022
@eiriktsarpalis eiriktsarpalis requested a review from krwq May 4, 2022 08:31
@eiriktsarpalis eiriktsarpalis merged commit d66d72d into dotnet:main May 5, 2022
@eiriktsarpalis eiriktsarpalis deleted the fix-sourcegen-attribute-ctor-assertion branch May 5, 2022 11:08
@ghost ghost locked as resolved and limited conversation to collaborators Jun 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

System.Text.Json source generator crashes when processing unresolved symbols
2 participants