Skip to content

Conversation

@jcouv
Copy link
Member

@jcouv jcouv commented Jul 17, 2025

Removes remaining references to test plan #76130
Closes #77933

This is best reviewed commit by commit.

Corresponding spec update: dotnet/csharplang#9535

@jcouv jcouv self-assigned this Jul 17, 2025
@jcouv jcouv added Area-Compilers Feature - Extension Everything The extension everything feature labels Jul 17, 2025
@jcouv jcouv force-pushed the extensions-followups branch 2 times, most recently from b7c6cd8 to 7312e4f Compare July 18, 2025 06:33
@jcouv jcouv force-pushed the extensions-followups branch 2 times, most recently from e86b2f1 to e4260cc Compare July 18, 2025 07:31
@jcouv jcouv force-pushed the extensions-followups branch from e4260cc to e62a6e7 Compare July 18, 2025 08:04
@jcouv
Copy link
Member Author

jcouv commented Jul 18, 2025

        // Tracked by https://github.com/dotnet/roslyn/issues/76130 : It looks like the following error is not reported for instance scenario. Noise?

📝 See MakeDeconstructInvocationExpression line 661 #Closed


Refers to: src/Compilers/CSharp/Test/Emit3/Semantics/ExtensionTests.cs:24200 in 8d46bd8. [](commit_id = 8d46bd8, deletion_comment = True)

continue;
}

// Note: we only care about methods since we're already decided this is a method group (ie. not resolving to some other kind of extension member)
Copy link
Contributor

@AlekseyTs AlekseyTs Jul 21, 2025

Choose a reason for hiding this comment

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

since we're already decided this is a method group

Where did we decide that? #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.

  1. that's the behavior we have chosen for determining unique signature in newer LangVer (see GetUniqueSignatureFromMethodGroup line 11090 below)
  2. that's consistent with how lookup works in general (we work up inheritance chain and if we get a method first, we'll keep looking at other methods to complete the method group, ignoring non-methods)

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe I misunderstood the question. If we get here, the caller is asking what is the function type of this method group.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps it would be clearer to say that we decided that we want to extract signature from candidate methods. The term "method group" is somewhat confusing with respect to extensions, since it can resolve to a non-method.

Assert.Equal(SymbolKind.Parameter, symbol.Kind);
Assert.Equal("System.Int32 i", symbol.ToTestDisplayString());

Assert.Equal("E", model.GetEnclosingSymbol(extensionParameter.SpanStart).ToTestDisplayString());
Copy link
Contributor

@AlekseyTs AlekseyTs Jul 21, 2025

Choose a reason for hiding this comment

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

Assert.Equal("E", model.GetEnclosingSymbol(extensionParameter.SpanStart).ToTestDisplayString());

Is this consistent with method parameters? Do we get type when we call GetEnclosingSymbol in parameter list? #Closed

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Jul 21, 2025

        // Tracked by https://github.com/dotnet/roslyn/issues/76130 : It looks like the following error is not reported for instance scenario. Noise?

The reason behind removal of this comment is not obvious #Closed


Refers to: src/Compilers/CSharp/Test/Emit3/Semantics/ExtensionTests.cs:24200 in 8d46bd8. [](commit_id = 8d46bd8, deletion_comment = True)

}
else if (typeKind == TypeKind.Extension)
{
_ = compilation.GetSpecialType(SpecialType.System_Object);
Copy link
Contributor

@AlekseyTs AlekseyTs Jul 21, 2025

Choose a reason for hiding this comment

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

_ = compilation.GetSpecialType(SpecialType.System_Object);

What is the purpose of this operation? #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.

It's meant to produce a diagnostic, but doesn't... Fixed,, added test and stepped through. Thanks

Debug.Assert(((Cci.ITypeReference)this).AsTypeDefinition(context) != null);
NamedTypeSymbol baseType = AdaptedNamedTypeSymbol.BaseTypeNoUseSiteDiagnostics;

if (AdaptedNamedTypeSymbol.IsScriptClass || AdaptedNamedTypeSymbol.IsExtension) // Tracked by https://github.com/dotnet/roslyn/issues/76130 : we should have checked the presence of System.Object
Copy link
Contributor

@AlekseyTs AlekseyTs Jul 21, 2025

Choose a reason for hiding this comment

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

// Tracked by #76130 : we should have checked the presence of System.Object

I would expect to see a test added. #Closed

}

[Fact]
public void Dynamic_07()
Copy link
Contributor

@AlekseyTs AlekseyTs Jul 21, 2025

Choose a reason for hiding this comment

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

Dynamic_07

What is the purpose of Dynamic_07 - Dynamic_09? It doesn't look like they test dynamic invocations? #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 didn't understand the comment. In Dynamic_07 the parameter of the local function is dynamic and the invocation uses runtime binder. Each of these tests goes through LocalRewriter.VisitDynamicInvocation

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't understand the comment.

What dynamic invocation you intend to test?

@AlekseyTs
Copy link
Contributor

Done with review pass (commit 23)

@jcouv
Copy link
Member Author

jcouv commented Jul 21, 2025

        // Tracked by https://github.com/dotnet/roslyn/issues/76130 : It looks like the following error is not reported for instance scenario. Noise?

Just to confirm, did you see the comment I'd left?

📝 See MakeDeconstructInvocationExpression line 661


In reply to: 3096811863


Refers to: src/Compilers/CSharp/Test/Emit3/Semantics/ExtensionTests.cs:24200 in 8d46bd8. [](commit_id = 8d46bd8, deletion_comment = True)

@AlekseyTs
Copy link
Contributor

        // Tracked by https://github.com/dotnet/roslyn/issues/76130 : It looks like the following error is not reported for instance scenario. Noise?

Just to confirm, did you see the comment I'd left?

📝 See MakeDeconstructInvocationExpression line 661

What am I supposed to see there?


In reply to: 3097572916


Refers to: src/Compilers/CSharp/Test/Emit3/Semantics/ExtensionTests.cs:24200 in 8d46bd8. [](commit_id = 8d46bd8, deletion_comment = True)

@jcouv jcouv requested a review from jjonescz July 22, 2025 17:29
@jcouv jcouv requested a review from AlekseyTs July 22, 2025 17:34
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 26)

@jcouv jcouv enabled auto-merge (squash) July 22, 2025 18:56
comp = CreateCompilation(src, references: [libRef], parseOptions: TestOptions.Regular13);
CompileAndVerify(comp, expectedOutput: "ran").VerifyDiagnostics(unnecessaryDirective);

if (!CompilationExtensions.EnableVerifyUsedAssemblies) // Tracked by https://github.com/dotnet/roslyn/issues/78968
Copy link
Member Author

Choose a reason for hiding this comment

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

@AlekseyTs FYI, the used assemblies leg hit an issue in VerifyUsedAssemblyReferences (line 1843, reporting an unexpected diagnostic that namespace N cannot be found when the set of referenced assemblies is shrunk).
The strange thing is that VerifyDiagnostics doesn't complain about unnecessary using but GetUsedAssemblyReferences() doesn't report the assembly containing namespace N as used.
I will investigate in a follow-up.

@jcouv jcouv merged commit cb8d294 into dotnet:main Jul 23, 2025
23 of 24 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jul 23, 2025
@jcouv jcouv deleted the extensions-followups branch July 23, 2025 17:42
@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.

Extension everything clean up translated prototype comments

4 participants