Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix RemoveUnusedMembers handling of default parameter reads - #80810

#80810
Merged
CyrusNajmabadi merged 3 commits into
dotnet:maindotnet/roslyn:mainfrom
molostovvs:molostov/63892/const-field-unused-fixCopy head branch name to clipboard
Nov 29, 2025
Merged

Fix RemoveUnusedMembers handling of default parameter reads#80810
CyrusNajmabadi merged 3 commits into
dotnet:maindotnet/roslyn:mainfrom
molostovvs:molostov/63892/const-field-unused-fixCopy head branch name to clipboard

Conversation

@molostovvs

Copy link
Copy Markdown
Contributor

fixes #63892

  • treat parameter default value expressions as symbol reads inside lambdas and local funcs
  • add related test cases

fixes #63892

- treat parameter default value expressions as symbol reads inside lambdas and local funcs
- add related test cases
@dotnet-policy-service dotnet-policy-service Bot added Community The pull request was submitted by a contributor who is not a Microsoft employee. VSCode labels Oct 18, 2025
private const int _goo = 42;
public void M()
{
var lam = (int x = _goo) => x;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add test with delegate (int x = _goo) { }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This results in error CS1065

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DoctorKrolic
Hi! Can you please come back with a review?

@molostovvs

Copy link
Copy Markdown
Contributor Author

@dotnet-policy-service agree

@molostovvs
molostovvs marked this pull request as ready for review October 18, 2025 20:13
@molostovvs
molostovvs requested a review from a team as a code owner October 18, 2025 20:14
@molostovvs

Copy link
Copy Markdown
Contributor Author

@CyrusNajmabadi Hi!
Can you do a pull request review, please?

FixedCode = code,
LanguageVersion = LanguageVersion.CSharp12,
}.RunAsync();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CyrusNajmabadi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks great! Just a couple of tests to add. If they are added and pass, i'll merge. tnx.

@CyrusNajmabadi
CyrusNajmabadi merged commit 350a8fc into dotnet:main Nov 29, 2025
25 of 26 checks passed
@dotnet-policy-service dotnet-policy-service Bot added this to the Next milestone Nov 29, 2025
@CyrusNajmabadi

Copy link
Copy Markdown
Contributor

Thanks @molostovvs !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee. VSCode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IDE Usage Analysis Does Not Account for Lambda Default Parameters

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.