Skip to content

Extensions: address or split remaining open issues directly associated with test plan - #79452

Merged
jcouv merged 29 commits into
dotnet:mainfrom
jcouv:extensions-followups
Jul 23, 2025
Merged

jcouv merged 29 commits into
dotnet:mainfrom
jcouv:extensions-followups

Conversation

@jcouv

@jcouv jcouv commented Jul 17, 2025 •

Copy link
Copy Markdown
Contributor

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

jcouv commented Jul 18, 2025 •

Copy link
Copy Markdown
Contributor Author
        // 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)

ghost Jul 21, 2025 •

Copy link
Copy Markdown
Contributor

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

ghost Jul 21, 2025

Copy link
Copy Markdown
Contributor 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)

ghost Jul 21, 2025

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

ghost Jul 22, 2025

Copy link
Copy Markdown
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());

ghost Jul 21, 2025 •

Copy link
Copy Markdown
Contributor

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

ghost commented Jul 21, 2025 •

Copy link
Copy Markdown
Contributor
        // 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);

ghost Jul 21, 2025 •

Copy link
Copy Markdown
Contributor

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

ghost Jul 21, 2025

Copy link
Copy Markdown
Contributor 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

ghost Jul 21, 2025 •

Copy link
Copy Markdown
Contributor

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

ghost Jul 21, 2025 •

Copy link
Copy Markdown
Contributor

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

ghost Jul 21, 2025

Copy link
Copy Markdown
Contributor 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

ghost Jul 22, 2025

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

ghost commented Jul 21, 2025

Copy link
Copy Markdown
Contributor

Done with review pass (commit 23)

@jcouv

ghost commented Jul 21, 2025

Copy link
Copy Markdown
Contributor Author
        // 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

ghost commented Jul 22, 2025

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

ghost left a comment

Copy link
Copy Markdown
Contributor

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

ghost Jul 23, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Couldn't load reviewers.

Assignees

Couldn't load assignees.