Skip to content

Allow 'ref' and 'in' parameters to be null-checked#58938

Merged
RikkiGibson merged 1 commit intodotnet:mainfrom
RikkiGibson:pnc-ref
Jan 19, 2022
Merged

Allow 'ref' and 'in' parameters to be null-checked#58938
RikkiGibson merged 1 commit intodotnet:mainfrom
RikkiGibson:pnc-ref

Conversation

@RikkiGibson
Copy link
Copy Markdown
Member

Related to #36024
Related to #58699

Please take a look @cston @chsienki @CyrusNajmabadi

@RikkiGibson RikkiGibson requested a review from a team as a code owner January 19, 2022 01:26
@ghost ghost added the Area-Compilers label Jan 19, 2022
Copy link
Copy Markdown
Contributor

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

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

ide side lgtm

@jcouv jcouv self-assigned this Jan 19, 2022
Copy link
Copy Markdown
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

LGTM Thanks (iteration 1)

}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseIsNullCheck)]
public async Task TestOutParameter()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's more common that we assert the expected compiler diagnostics here, ie, remove CompilerDiagnostics = ... below.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think this is a reasonable suggestion, and would be happy to take a change that makes this happen in a follow up.


class C
{
public C(out string s)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
public C(out string s)
public {|CS0177:C|}(out string s)

{
public C(out string s)
{
if (s is null)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if (s is null)
if ({|CS0269:s|} is null)

@RikkiGibson RikkiGibson merged commit 0ada814 into dotnet:main Jan 19, 2022
@RikkiGibson RikkiGibson deleted the pnc-ref branch January 19, 2022 20:09
@ghost ghost added this to the Next milestone Jan 19, 2022
@RikkiGibson RikkiGibson modified the milestones: Next, 17.2.P1 Feb 4, 2022
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