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

Avoid returning default from MethodSymbol.Parameters #54179

Merged
merged 4 commits into from
Jun 18, 2021

Conversation

sharwell
Copy link
Member

@sharwell sharwell commented Jun 17, 2021

Review commit-by-commit recommended.

This change ensures that all implementations of MethodSymbol.Parameters return a non-default array, excluding cases where LazyMethodChecks fails to initialize parameters. It also cleans up some initialization sites to use current practices.

@sharwell sharwell marked this pull request as ready for review June 17, 2021 18:20
@sharwell sharwell requested a review from a team as a code owner June 17, 2021 18:20
@sharwell sharwell marked this pull request as draft June 17, 2021 18:35
@sharwell sharwell marked this pull request as ready for review June 17, 2021 18:50
Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

LGTM (commit 4)

@AlekseyTs
Copy link
Contributor

@dotnet/roslyn-compiler For the second review.

@@ -106,7 +106,7 @@ public sealed override ImmutableArray<ParameterSymbol> Parameters
{
if (_parameters.IsDefault)
{
ImmutableInterlocked.InterlockedCompareExchange(ref _parameters, MakeParameters(), default(ImmutableArray<ParameterSymbol>));
ImmutableInterlocked.InterlockedInitialize(ref _parameters, MakeParameters());
Copy link
Member

Choose a reason for hiding this comment

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

Can you help me understand how these two lines are different? I'm missing the distinction here.

Copy link
Member Author

Choose a reason for hiding this comment

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

➡️ They are semantically identical. The simpler form allows a reader to understand the behavior without the mental burden of relating the third parameter of InterlockedCompareExchange to the default state for the field.

@jcouv jcouv merged commit 22a7203 into dotnet:main Jun 18, 2021
@ghost ghost added this to the Next milestone Jun 18, 2021
@jcouv
Copy link
Member

jcouv commented Jun 18, 2021

Merged/squashed. Will take another look at https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1341051 with this new baseline. Thanks

@sharwell sharwell deleted the init-params branch June 18, 2021 14:26
@sharwell
Copy link
Member Author

@jcouv Please do not squash merge pull requests submitted by me. I meticulously separated this pull request into four distinct changes with the intent they would be preserved as such. Thanks!

@jcouv
Copy link
Member

jcouv commented Jun 18, 2021

@sharwell Sorry about that.

@sharwell
Copy link
Member Author

@jcouv no problem glad it's merged !

@RikkiGibson RikkiGibson modified the milestones: Next, 17.0.P2 Jun 29, 2021
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.

5 participants