Skip to content

Conversation

@RikkiGibson
Copy link
Member

Related to #78828

@RikkiGibson RikkiGibson marked this pull request as ready for review July 14, 2025 20:56
@RikkiGibson RikkiGibson requested a review from a team as a code owner July 14, 2025 20:57
@AlekseyTs AlekseyTs requested review from jcouv and jjonescz July 15, 2025 12:18
@AlekseyTs AlekseyTs added the Feature - Extension Everything The extension everything feature label Jul 15, 2025
@AlekseyTs
Copy link
Contributor

AlekseyTs commented Jul 15, 2025

Done with review pass (commit 5) #Closed

@jcouv
Copy link
Member

jcouv commented Jul 15, 2025

            // Reinfer the return type of the collectionExpression.GetEnumerator().Current property, so that if

nit: consider leaving assertions that Current and MoveNext/MoveNextAsync aren't extensions (old or new)


Refers to: src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs:11685 in e09ff76. [](commit_id = e09ff76, deletion_comment = False)

s = null;

var c = M(s); // 'C<string?>'
foreach (var x in c)
Copy link
Member

Choose a reason for hiding this comment

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

nit: Consider also covering the happy case where IEnumerator<string> is inferred/returned

}
}";
var verifier = CompileAndVerify(source, expectedOutput: "23", parseOptions: TestOptions.RegularPreview.WithFeature("run-nullable-analysis", "never")); // Tracked by https://github.com/dotnet/roslyn/issues/78828: Nullable analysis asserts
var verifier = CompileAndVerify(source, expectedOutput: "23", parseOptions: TestOptions.RegularPreview);
Copy link
Member

Choose a reason for hiding this comment

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

nit: could remove RegularPreview since it's the default

Copy link
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.

Done with review pass (commit 5)

@jcouv jcouv self-assigned this Jul 15, 2025
@RikkiGibson
Copy link
Member Author

            // Reinfer the return type of the collectionExpression.GetEnumerator().Current property, so that if

nit: consider leaving assertions that Current and MoveNext/MoveNextAsync aren't extensions (old or new)

Refers to: src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs:11685 in e09ff76. [](commit_id = e09ff76, deletion_comment = False)

I think this will be covered by a future change which adds an assertion to AsMemberOfType.

""";
var comp = CreateCompilation(src);
CompileAndVerify(comp, expectedOutput: "42").VerifyDiagnostics();
}
Copy link
Member

Choose a reason for hiding this comment

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

nit: Consider adding a test like foreach (var x in M(null)) where the receiver of GetEnumerator produces a warning (only once).

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't follow what you meant by M(null). But, I added a version of the GetEnumerator test with a null receiver and classic extension method.

Copy link
Member

Choose a reason for hiding this comment

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

I meant a test where we have a nullability warning in the receiver of GetEnumerator, showing that we only report that warning once.

Copy link
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 (commit 8)

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 9)

@RikkiGibson
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@RikkiGibson RikkiGibson merged commit e7af5dc into dotnet:main Jul 16, 2025
24 of 27 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jul 16, 2025
@RikkiGibson RikkiGibson deleted the ext-nullability-2 branch July 16, 2025 20:55
@RikkiGibson RikkiGibson modified the milestones: Next, 18.0 P1 Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Compilers Feature - Extension Everything The extension everything feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants