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

Run ref safety analysis for field initializers on bound nodes transformed to assignments to the target fields. #69088

Merged
merged 2 commits into from
Jul 19, 2023

Conversation

AlekseyTs
Copy link
Contributor

Fixes #67371.

@AlekseyTs
Copy link
Contributor Author

@cston, @RikkiGibson, @jjonescz, @dotnet/roslyn-compiler Please review.

public ref int R3 = ref x;
}

ref struct S4([System.Diagnostics.CodeAnalysis.UnscopedRef] ref int x)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also have a test for a scoped ref primary constructor parameter which is ref-assigned to ref field in a constructor and in a field initializer?

";
var comp = CreateCompilation(source, options: TestOptions.ReleaseDll, targetFramework: TargetFramework.NetCoreApp);
comp.VerifyDiagnostics();
}
Copy link
Member

Choose a reason for hiding this comment

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

}

Consider adding ref readonly cases as well.

ref struct S5(in int x)
{
    ref readonly int R5 = ref x;
}

@AlekseyTs AlekseyTs enabled auto-merge (squash) July 19, 2023 13:30
@AlekseyTs AlekseyTs merged commit 9a2664f into dotnet:main Jul 19, 2023
25 checks passed
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.

Ref-assigning a ref parameter to a ref field with primary constructor
3 participants