Skip to content

Keep LinqraftMapping capture support and remove AsLeftJoin / QueryExtensions work#304

Merged
arika0093 merged 7 commits into
mainfrom
copilot/add-capture-variable-support
Mar 17, 2026
Merged

Keep LinqraftMapping capture support and remove AsLeftJoin / QueryExtensions work#304
arika0093 merged 7 commits into
mainfrom
copilot/add-capture-variable-support

Conversation

Copilot AI commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

This PR narrows the scope back to LinqraftMapping capture variables only. All AsLeftJoin / Linqraft.QueryExtensions work has been removed so it can proceed separately, while mapping-generated methods continue to support captured values.

  • Scope reset

    • Removed all AsLeftJoin-related generator changes
    • Removed Linqraft.QueryExtensions package and its registration infrastructure
    • Removed SG / EF Core test coverage that existed only for the left-join extension path
    • Dropped the plan.md content that had shifted to the separate query-extension design
  • Mapping capture support retained

    • Kept capture-aware method generation for LinqraftMappingGenerate
    • Kept capture-aware method generation for LinqraftMappingDeclare<T>
    • Generated mapping methods still surface captured values as explicit parameters
  • Documentation

    • Expanded docs/library/mapping-methods.md with capture-parameter guidance and examples for both:
      • helper-class mappings
      • static partial class mappings

Example of the retained mapping capture flow:

[LinqraftMappingGenerate("ProjectToDtoWithCapture")]
internal static IQueryable<OrderDto> Template(
    this IQueryable<Order> source,
    int offset,
    string suffix) =>
    source.SelectExpr<Order, OrderDto>(
        order => new
        {
            order.Id,
            AdjustedTotal = order.Total + offset,
            DisplayName = order.Name + suffix,
        },
        capture: () => (offset, suffix)
    );

This keeps the PR focused on the mapping capture feature and leaves the query-extension / left-join work for a separate follow-up.


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Copilot AI and others added 2 commits March 16, 2026 15:34
Co-authored-by: arika0093 <4524647+arika0093@users.noreply.github.com>
Co-authored-by: arika0093 <4524647+arika0093@users.noreply.github.com>
Copilot AI changed the title [WIP] Add capture variable support for mapping methods Add capture-aware mapping generation and AsLeftJoin projection hint support Mar 16, 2026
Copilot AI requested a review from arika0093 March 16, 2026 15:39
Copilot stopped work on behalf of arika0093 due to an error March 17, 2026 00:17
Copilot AI and others added 2 commits March 17, 2026 00:52
Co-authored-by: arika0093 <4524647+arika0093@users.noreply.github.com>
Co-authored-by: arika0093 <4524647+arika0093@users.noreply.github.com>
Copilot AI changed the title Add capture-aware mapping generation and AsLeftJoin projection hint support Add string-based query extension registration and ship AsLeftJoin via Linqraft.QueryExtensions Mar 17, 2026
Co-authored-by: arika0093 <4524647+arika0093@users.noreply.github.com>
Copilot AI changed the title Add string-based query extension registration and ship AsLeftJoin via Linqraft.QueryExtensions Keep LinqraftMapping capture support and remove AsLeftJoin / QueryExtensions work Mar 17, 2026
@arika0093
arika0093 marked this pull request as ready for review March 17, 2026 01:41

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 060404a8a5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


builder.AppendLine(
$"{request.MethodAccessibilityKeyword} static {receiverType}<{request.ResultTypeName}> {request.MethodName}(this {receiverType}<{request.SourceTypeName}> source)"
$"{request.MethodAccessibilityKeyword} static {receiverType}<{request.ResultTypeName}> {request.MethodName}(this {receiverType}<{request.SourceTypeName}> source{string.Concat(request.Captures.Select(capture => $", {capture.TypeName} {capture.LocalName}"))})"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use capture member names in generated mapping signatures

The generated mapping method now declares capture parameters using capture.LocalName, which is the internal synthetic name (for example __linqraft_capture_0_offset) rather than the user-facing capture name (offset, suffix). This makes named-argument calls fail (ProjectTo...(..., offset: 10, suffix: "x") no longer compiles) and exposes unstable implementation-detail names in the public API surface, which is especially problematic for mappings generated as public methods.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@copilot apply this review

@arika0093

Copy link
Copy Markdown
Owner

@copilot apply codex's review.

in src/Linqraft.SourceGenerator/SourceWriters.cs

The generated mapping method now declares capture parameters using capture.LocalName, which is the internal synthetic name (for example __linqraft_capture_0_offset) rather than the user-facing capture name (offset, suffix). This makes named-argument calls fail (ProjectTo...(..., offset: 10, suffix: "x") no longer compiles) and exposes unstable implementation-detail names in the public API surface, which is especially problematic for mappings generated as public methods.

Co-authored-by: arika0093 <4524647+arika0093@users.noreply.github.com>

Copilot AI commented Mar 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot apply codex's review.

in src/Linqraft.SourceGenerator/SourceWriters.cs
...

Fixed in d75e27d. The generated mapping signature now uses the stable capture property names (offset, suffix) again, and the generator aliases those parameters back to the existing internal synthetic locals inside the method body so the projection emission still works. I also added a regression test that calls the generated mapping with named arguments.

@arika0093
arika0093 merged commit 19005f0 into main Mar 17, 2026
5 checks passed
@arika0093
arika0093 deleted the copilot/add-capture-variable-support branch March 17, 2026 02:30
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.

2 participants