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

Unwrap NullableValue for diagnostics creation and add try/catch for formatting diagnostics #110229

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jtschuster
Copy link
Member

Fixes #109536

See #93800 for more context.

When a NullableValue is the source of an assignment, we consider use the TypeArgumentTargetsX diagnostic since the underlying value is a generic argument, but use the source of the generic argument for diagnostics. This leads to some confusing warning messages, and sometimes crashes in formatting the diagnostics. Ideally, we would want to unwrap the NullableValues and use the UnderlyingTypeValue as the source, but this would be a breaking change for the situations that don't crash.

FieldValue and MethodReturnValue only provide 1 diagnostic arguments, but the diagnostics for TypeArgumentTargetsX expects 2 arguments from the source. This caused crashes when the situation was encountered. Since they didn't work before at all, this won't be a breaking change to provide the correct warning here.

@jtschuster jtschuster added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Nov 27, 2024
@jtschuster jtschuster added this to the 10.0.0 milestone Nov 27, 2024
@jtschuster jtschuster requested a review from a team November 27, 2024 17:01
@jtschuster jtschuster self-assigned this Nov 27, 2024
@dotnet-policy-service dotnet-policy-service bot added the linkable-framework Issues associated with delivering a linker friendly framework label Nov 27, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/illink
See info in area-owners.md if you want to be subscribed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers linkable-framework Issues associated with delivering a linker friendly framework
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

[area-Tools-ILLink]: dotnet publish crashing when using PublishTrimmed option
1 participant