Fix RemoveUnusedMembers handling of default parameter reads - #80810
#80810Merged
CyrusNajmabadi merged 3 commits intoNov 29, 2025
dotnet:maindotnet/roslyn:mainfrom
molostovvs:molostov/63892/const-field-unused-fixCopy head branch name to clipboard
Merged
Fix RemoveUnusedMembers handling of default parameter reads#80810CyrusNajmabadi merged 3 commits intodotnet:maindotnet/roslyn:mainfrom molostovvs:molostov/63892/const-field-unused-fixCopy head branch name to clipboard
CyrusNajmabadi merged 3 commits into
dotnet:maindotnet/roslyn:mainfrom
molostovvs:molostov/63892/const-field-unused-fixCopy head branch name to clipboard
Conversation
fixes #63892 - treat parameter default value expressions as symbol reads inside lambdas and local funcs - add related test cases
| private const int _goo = 42; | ||
| public void M() | ||
| { | ||
| var lam = (int x = _goo) => x; |
Contributor
There was a problem hiding this comment.
Add test with delegate (int x = _goo) { }
Contributor
Author
There was a problem hiding this comment.
@DoctorKrolic
Hi! Can you please come back with a review?
Contributor
Author
|
@dotnet-policy-service agree |
molostovvs
marked this pull request as ready for review
October 18, 2025 20:13
Contributor
Author
|
@CyrusNajmabadi Hi! |
| FixedCode = code, | ||
| LanguageVersion = LanguageVersion.CSharp12, | ||
| }.RunAsync(); | ||
| } |
Contributor
There was a problem hiding this comment.
can you add a test like so: var lam = (int x = _goo + _bar) => x + y;
also var lam = (int x = MyClass._goo) => x;
thanks!
CyrusNajmabadi
approved these changes
Nov 29, 2025
CyrusNajmabadi
left a comment
Contributor
There was a problem hiding this comment.
Change looks great! Just a couple of tests to add. If they are added and pass, i'll merge. tnx.
CyrusNajmabadi
enabled auto-merge
November 29, 2025 19:45
Contributor
|
Thanks @molostovvs ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #63892