Skip to content

Fix MakeFieldReadonly false positive for ref assignments#58459

Merged
mavasani merged 1 commit intodotnet:mainfrom
mavasani:IDE0044_FP
Dec 22, 2021
Merged

Fix MakeFieldReadonly false positive for ref assignments#58459
mavasani merged 1 commit intodotnet:mainfrom
mavasani:IDE0044_FP

Conversation

@mavasani
Copy link
Copy Markdown
Contributor

Fixes #46785
Fixes #57983

@mavasani mavasani added this to the 17.1 milestone Dec 22, 2021
@mavasani mavasani requested review from a team and sharwell December 22, 2021 06:25
@mavasani mavasani enabled auto-merge December 22, 2021 07:37
@mavasani mavasani merged commit bf84ccf into dotnet:main Dec 22, 2021
@ghost ghost modified the milestones: 17.1, Next Dec 22, 2021
@mavasani mavasani deleted the IDE0044_FP branch December 22, 2021 08:27
simpleAssignmentOperation.Value == operation &&
simpleAssignmentOperation.IsRef)
{
return ValueUsageInfo.ReadableWritableReference;
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.

if you have: readonly ref int x = ref y does this count as a read/write ref now? or just a read-ref? It should be the latter. Can you check, fix if necessary, and add test?

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.

➡️ Filed #58466 to resolve this comment

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.

Yep, agreed. This case should be readable reference, I'll make the change

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IDE0044 "make field readonly" false positive Make field readonly "IDE0044" false positive when used with ref locals

5 participants