Skip to content

Colocate explicit DTO generation with SelectExpr files#248

Merged
arika0093 merged 5 commits intomainfrom
copilot/add-dto-classes-in-select-expr-file
Dec 12, 2025
Merged

Colocate explicit DTO generation with SelectExpr files#248
arika0093 merged 5 commits intomainfrom
copilot/add-dto-classes-in-select-expr-file

Conversation

Copy link
Contributor

Copilot AI commented Dec 11, 2025

Explicit DTOs were always emitted into a global generated file, making it hard to see the SelectExpr replacement context. DTOs under hashed namespaces may stay shared; playground code can remain single-file.

  • Generation flow

    • Per-file/group DTO collection and deduplication; hash-namespace DTOs still emitted globally.
    • Expression snippets now embed co-located DTO code when present.
    • Hash-namespace detection centralized via a prefix constant.
  • Test

    • Added regression ensuring explicit DTOs appear in the same generated expression file and not in the global DTO file.

Example (conceptual)

// Before: DTO emitted only in GeneratedDtos.g.cs
query.SelectExpr<SimpleDto>(x => new { x.Id });

// After: DTO emitted alongside GeneratedExpression_*.g.cs for that file/group
// Hash-namespaced auto DTOs remain in the shared DTO file.
Original prompt

This section details on the original issue you should resolve

<issue_title>feat: It would be convenient if explicit DTO classes were created within the same file as the intercepted SelectExpr.</issue_title>
<issue_description>Although the improvements made in PR #240 have resolved declaration duplication, the current implementation generates all classes in a single file and performs filtering in the process. However, due to the nature of the Interceptor, there is currently no way to directly view the replacement code for SelectExpr. As a stepping stone, it would be useful to generate DTO classes in the same file as SelectExpr.
Specifically, explicit DTOs should be in the same file as the generated SelectExpr method. For (auto-inferred) DTO classes generated in the namespace Linqraft_Hash1234, it is acceptable to generate them in separate files from the perspective of duplication management.
For code generated in the Playground, it is still acceptable to generate it in a single file.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 11, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI and others added 4 commits December 11, 2025 14:11
Co-authored-by: arika0093 <4524647+arika0093@users.noreply.github.com>
Co-authored-by: arika0093 <4524647+arika0093@users.noreply.github.com>
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 explicit DTO classes in SelectExpr file Colocate explicit DTO generation with SelectExpr files Dec 11, 2025
Copilot AI requested a review from arika0093 December 11, 2025 14:21
@arika0093 arika0093 marked this pull request as ready for review December 12, 2025 00:18
@arika0093 arika0093 merged commit 67d7693 into main Dec 12, 2025
5 checks passed
@arika0093 arika0093 deleted the copilot/add-dto-classes-in-select-expr-file branch December 12, 2025 00:20
arika0093 added a commit that referenced this pull request Dec 12, 2025
* Initial plan

* feat: colocate explicit dtos with expressions

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

* chore: factor hash namespace prefix constant

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

* chore: refine hash namespace detection

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

* docs: reflect dto emission in generator comment

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

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: arika0093 <4524647+arika0093@users.noreply.github.com>
(cherry picked from commit 67d7693)
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.

feat: It would be convenient if explicit DTO classes were created within the same file as the intercepted SelectExpr.

2 participants