Skip to content

Adds an analyzer/fixer to inform the user when the compiler silently inserts a fallible explicit cast.#82039

Merged
CyrusNajmabadi merged 12 commits intodotnet:mainfrom
CyrusNajmabadi:hiddenCasts
Jan 17, 2026
Merged

Adds an analyzer/fixer to inform the user when the compiler silently inserts a fallible explicit cast.#82039
CyrusNajmabadi merged 12 commits intodotnet:mainfrom
CyrusNajmabadi:hiddenCasts

Conversation

@CyrusNajmabadi
Copy link
Contributor

based on discussion dotnet/csharplang#9917.

There are cases where only one explicit cast is written in source, but two may be inserted int eh final code. Both of these may fail for different reasons, and the user may be unaware of the inner cast and the impact it may have.

This analyzer let's you know when that is happening, and recommends moving to make both casts explicit in source so that the source is clear about what it is doing.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner January 16, 2026 12:47
@CyrusNajmabadi CyrusNajmabadi merged commit da6cf36 into dotnet:main Jan 17, 2026
24 of 25 checks passed
@CyrusNajmabadi CyrusNajmabadi deleted the hiddenCasts branch January 17, 2026 13:30
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jan 17, 2026
@davidwengier davidwengier modified the milestones: Next, 18.4 Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants