Skip to content

Conversation

@PhenX
Copy link
Collaborator

@PhenX PhenX commented Jan 14, 2026

Fixes #141

Copilot AI and others added 3 commits January 14, 2026 20:52
Co-authored-by: PhenX <42170+PhenX@users.noreply.github.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds support for C# 14 extension members to the EntityFrameworkCore.Projectables source generator. Extension members are a new C# 14 feature that allow defining members within an extension() block, providing a more natural syntax for extending types compared to traditional extension methods.

Changes:

  • Updated Microsoft.CodeAnalysis.CSharp to version 5.0.0 to support C# 14 features
  • Modified the source generator to detect and process extension members using the IsExtension property
  • Added logic to rewrite extension parameter references (e.g., e) to @this in generated expressions
  • Added comprehensive test coverage including generator tests and functional tests for extension member properties, methods, and methods with parameters

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Directory.Packages.props Updated Microsoft.CodeAnalysis.CSharp from 4.11.0 to 5.0.0
Directory.Build.props Added conditional LangVersion 14.0 for net10.0 target framework
ProjectableInterpreter.cs Added extension member detection and handling logic with helper methods
ExpressionSyntaxRewriter.cs Added extension parameter name tracking and identifier replacement
ProjectionExpressionGeneratorTests.cs Added 5 generator tests for extension member scenarios (NET10_0_OR_GREATER)
ExtensionMemberTests.cs Added 2 functional tests for extension member methods
EntityExtensions.cs Added extension member definitions for Entity and int types
Entity.cs Added Entity class for extension member testing
Various .verified.txt files Expected output verification files for all new tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +29 to +41
static IEnumerable<string> GetNestedInClassPathForExtensionMember(ITypeSymbol extensionType)
{
// For extension members, the ContainingType is the extension block,
// and its ContainingType is the outer class (e.g., EntityExtensions)
var outerType = extensionType.ContainingType;

if (outerType is not null)
{
return GetNestedInClassPath(outerType);
}

return [];
}
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

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

The documentation comment describes the method's purpose well, but should be a proper XML documentation comment using /// instead of // to match the project's documentation style and provide IntelliSense support.

Copilot uses AI. Check for mistakes.
Comment on lines +286 to +298
// Handle C# 14 extension parameter replacement (e.g., `e` in `extension(Entity e)` becomes `@this`)
if (_extensionParameterName is not null && node.Identifier.Text == _extensionParameterName)
{
var symbol = _semanticModel.GetSymbolInfo(node).Symbol;

// Check if this identifier refers to the extension parameter
if (symbol is IParameterSymbol { ContainingSymbol: INamedTypeSymbol { IsExtension: true } })
{
return SyntaxFactory.IdentifierName("@this")
.WithLeadingTrivia(node.GetLeadingTrivia())
.WithTrailingTrivia(node.GetTrailingTrivia());
}
}
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

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

While the inline comment is helpful, consider adding XML documentation to the VisitIdentifierName method explaining that it now handles extension parameter replacement in addition to its other responsibilities. This would improve maintainability and help future developers understand the method's full scope.

Copilot uses AI. Check for mistakes.
@PhenX PhenX requested a review from koenbeuk January 15, 2026 08:12
@PhenX PhenX changed the title Copilot/add csharp 14 extension members Add csharp 14 extension members Jan 15, 2026
@PhenX PhenX changed the title Add csharp 14 extension members Add C#14 extension members Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support C# 14 extension members

1 participant