Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

jcouv
Copy link
Member

@jcouv jcouv commented Oct 11, 2025

Closes #80273 (pending API review to decide whether to have an API on ISymbol or split as implemented here)

There is a small change in behavior when dealing with extensions that aren't fully inferred. Previously, GetCompatibleSubstitutedMember dropped them. Now, it's up to the caller to decide.
The LookupSymbols_WasNotFullyInferred test illustrates such a change. For lookup, we do want to return members that can't be fully inferred.

Relates to test plan #76130

@jcouv jcouv self-assigned this Oct 11, 2025
@jcouv jcouv added Area-Compilers Feature - Extension Everything The extension everything feature labels Oct 11, 2025
@dotnet-policy-service dotnet-policy-service bot added VSCode Needs API Review Needs to be reviewed by the API review council labels Oct 11, 2025
Copy link
Contributor

This PR modifies public API files. Please follow the instructions at https://github.com/dotnet/roslyn/blob/main/docs/contributing/API%20Review%20Process.md for ensuring all public APIs are reviewed before merging.

@jcouv jcouv force-pushed the extensions-reduce branch from cadd91d to a151018 Compare October 14, 2025 18:21
@jcouv jcouv marked this pull request as ready for review October 14, 2025 20:11
@jcouv jcouv requested review from a team as code owners October 14, 2025 20:11
@jcouv jcouv requested review from AlekseyTs and jjonescz October 15, 2025 17:42
IMethodSymbol? ReduceExtensionMethod(ITypeSymbol receiverType);

/// <summary>
/// If this is a (new) extension method that can be applied to a receiver of the given type,
Copy link
Contributor

@AlekseyTs AlekseyTs Oct 16, 2025

Choose a reason for hiding this comment

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

(new) extension method

"method of an extension block"? #Closed

if (_underlying.GetIsNewExtensionMember() && SourceMemberContainerTypeSymbol.IsAllowedExtensionMember(_underlying))
{
var csharpReceiver = receiverType.EnsureCSharpSymbolOrNull(nameof(receiverType));
return (IMethodSymbol?)SourceNamedTypeSymbol.GetCompatibleSubstitutedMember(compilation: null, _underlying, csharpReceiver, wasExtensionFullyInferred: out _).GetPublicSymbol();
Copy link
Contributor

@AlekseyTs AlekseyTs Oct 16, 2025

Choose a reason for hiding this comment

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

wasExtensionFullyInferred

Should we be checking this value? #Closed

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 don't think so. See description in OP: "For lookup, we do want to return members that can't be fully inferred."

if (_underlying.GetIsNewExtensionMember() && SourceMemberContainerTypeSymbol.IsAllowedExtensionMember(_underlying))
{
var csharpReceiver = receiverType.EnsureCSharpSymbolOrNull(nameof(receiverType));
return (IPropertySymbol?)SourceNamedTypeSymbol.GetCompatibleSubstitutedMember(compilation: null, _underlying, csharpReceiver, wasExtensionFullyInferred: out _).GetPublicSymbol();
Copy link
Contributor

@AlekseyTs AlekseyTs Oct 16, 2025

Choose a reason for hiding this comment

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

wasExtensionFullyInferred

Should we be checking this value? #Closed

Copy link
Member Author

Choose a reason for hiding this comment

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

Answered elsewhere


INamedTypeSymbol systemObject = comp.GetSpecialType(SpecialType.System_Object).GetPublicSymbol();

AssertEx.Equal("void E.<G>$66F77D1E46F965A5B22D4932892FA78B<T>.M()", method.ToTestDisplayString());
Copy link
Contributor

@AlekseyTs AlekseyTs Oct 16, 2025

Choose a reason for hiding this comment

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

method.ToTestDisplayString()

I think for these tests it would be better to use default display style with "extension" instead of the grouping name. #Closed

}

[Fact]
public void ReduceExtensionMember_12()
Copy link
Contributor

@AlekseyTs AlekseyTs Oct 16, 2025

Choose a reason for hiding this comment

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

ReduceExtensionMember_12

It doesn't look like this test is trying to use ReduceExtensionMember APIs. #Closed

Copy link
Member Author

Choose a reason for hiding this comment

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

That's correct, this is testing the internal API which has a different name, but is morally equivalent. I don't think this warrants a different test name. An alternative would be to rename the internal API to use the same name as the public one.

}

[Fact]
public void ReduceExtensionMember_13()
Copy link
Contributor

@AlekseyTs AlekseyTs Oct 16, 2025

Choose a reason for hiding this comment

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

ReduceExtensionMember_13

It doesn't look like this test is trying to use ReduceExtensionMember APIs. #Closed

Copy link
Member Author

Choose a reason for hiding this comment

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

Asnwered above

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Oct 16, 2025

Done with review pass (Commit 1) #Closed

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)

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 Needs API Review Needs to be reviewed by the API review council VSCode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Need way to check if a particular (modern) extension member is applicable to a receiver type.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.