Skip to content

Conversation

@arika0093
Copy link
Owner

@arika0093 arika0093 commented Nov 16, 2025

Improve the method header generation by adding the location type to the SelectExpr records, providing clearer context in the generated documentation.

Summary by CodeRabbit

  • Refactor

    • Consolidated method header generation in the source generator to streamline how generated method documentation and attributes are produced.
  • Documentation

    • Generated method summaries now include the expression type and show only the file portion of the location.
    • Expression types are indicated (e.g., anonymous, explicit, predefined) in generated docs.

@coderabbitai
Copy link

coderabbitai bot commented Nov 16, 2025

Walkthrough

Replaced a previously implicit expression-type mechanism with an abstract GetExprTypeString() on SelectExprInfo, implemented in three subclasses; GenerateMethodHeaderPart now uses that method and extracts the file-only segment from the location for XML summary output.

Changes

Cohort / File(s) Summary
Core: SelectExprInfo
src/Linqraft.SourceGenerator/SelectExprInfo.cs
Added protected abstract string GetExprTypeString(); GenerateMethodHeaderPart now calls GetExprTypeString(), computes displayLocationRaw from location.GetDisplayLocation() and derives locationFileOnly (last path segment), and updates XML summary to include the expression type and file-only location.
Anonymous implementation
src/Linqraft.SourceGenerator/SelectExprInfoAnonymous.cs
Implemented protected override string GetExprTypeString() returning "anonymous".
Explicit DTO implementation
src/Linqraft.SourceGenerator/SelectExprInfoExplicitDto.cs
Implemented protected override string GetExprTypeString() returning "explicit"; replaced inline header/attribute emission with a call to GenerateMethodHeaderPart(dtoName, location).
Named implementation
src/Linqraft.SourceGenerator/SelectExprInfoNamed.cs
Implemented protected override string GetExprTypeString() returning "predefined".

Sequence Diagram(s)

(omitted — changes are localized to documentation emission and small overrides; no new runtime control flow to visualize)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Consistent, small refactor across a few files.
  • Areas to inspect closely:
    • GenerateMethodHeaderPart — verify null/format handling when extracting the last segment of displayLocationRaw.
    • Callsite in SelectExprInfoExplicitDto where header generation was consolidated — ensure attributes and summary formatting are preserved.

Poem

🐰 A nibble of bytes, a new little string,
"anonymous", "explicit", "predefined" take wing.
Header notes trimmed to the file at the end,
I hop through the code — tidy, neat, and well penned!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: adding expression type information to method header generation across SelectExprInfo classes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/comment-location-only-filename

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b41a561 and e9f4c04.

📒 Files selected for processing (4)
  • src/Linqraft.SourceGenerator/SelectExprInfo.cs (2 hunks)
  • src/Linqraft.SourceGenerator/SelectExprInfoAnonymous.cs (1 hunks)
  • src/Linqraft.SourceGenerator/SelectExprInfoExplicitDto.cs (2 hunks)
  • src/Linqraft.SourceGenerator/SelectExprInfoNamed.cs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/Linqraft.SourceGenerator/SelectExprInfoNamed.cs
  • src/Linqraft.SourceGenerator/SelectExprInfoExplicitDto.cs
  • src/Linqraft.SourceGenerator/SelectExprInfo.cs
🧰 Additional context used
🧬 Code graph analysis (1)
src/Linqraft.SourceGenerator/SelectExprInfoAnonymous.cs (3)
src/Linqraft.SourceGenerator/SelectExprInfo.cs (1)
  • GetExprTypeString (38-38)
src/Linqraft.SourceGenerator/SelectExprInfoExplicitDto.cs (1)
  • GetExprTypeString (123-123)
src/Linqraft.SourceGenerator/SelectExprInfoNamed.cs (1)
  • GetExprTypeString (40-40)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build (windows-latest)
🔇 Additional comments (1)
src/Linqraft.SourceGenerator/SelectExprInfoAnonymous.cs (1)

36-38: LGTM! Clean implementation of the abstract method.

The override correctly implements the abstract GetExprTypeString() method from the base class, following the same pattern as the other subclasses.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/Linqraft.SourceGenerator/SelectExprInfo.cs (2)

139-140: Consider handling edge cases in path parsing.

While the current implementation using Split(['/', '\\']).Last() works for typical paths, it could return an empty string if the path ends with a separator. Consider a more defensive approach:

Apply this diff for more robust filename extraction:

-        var displayLocationRaw = location.GetDisplayLocation();
-        var locationFileOnly = displayLocationRaw.Split(['/', '\\']).Last();
+        var displayLocationRaw = location.GetDisplayLocation();
+        var locationFileOnly = displayLocationRaw.Split(['/', '\\'], StringSplitOptions.RemoveEmptyEntries).LastOrDefault() ?? displayLocationRaw;

This ensures that even with trailing separators or edge cases, a meaningful location is always shown.


133-148: Optional: Consider using constants for type identifiers.

The type identifiers ("anonymous", "explicit", "predefined") are currently hardcoded strings across multiple files. While functional, defining them as constants would improve maintainability and prevent typos:

Add constants to the base class:

protected const string TypeAnonymous = "anonymous";
protected const string TypeExplicit = "explicit";
protected const string TypePredefined = "predefined";

Then update call sites to use TypeAnonymous, TypeExplicit, and TypePredefined respectively. Given the small number of call sites (3) and stability of these values, this is purely a nice-to-have improvement.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6d33e3c and b41a561.

📒 Files selected for processing (4)
  • src/Linqraft.SourceGenerator/SelectExprInfo.cs (1 hunks)
  • src/Linqraft.SourceGenerator/SelectExprInfoAnonymous.cs (1 hunks)
  • src/Linqraft.SourceGenerator/SelectExprInfoExplicitDto.cs (1 hunks)
  • src/Linqraft.SourceGenerator/SelectExprInfoNamed.cs (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
src/Linqraft.SourceGenerator/SelectExprInfoAnonymous.cs (1)
src/Linqraft.SourceGenerator/SelectExprInfo.cs (1)
  • GenerateMethodHeaderPart (133-148)
src/Linqraft.SourceGenerator/SelectExprInfoNamed.cs (1)
src/Linqraft.SourceGenerator/SelectExprInfo.cs (1)
  • GenerateMethodHeaderPart (133-148)
src/Linqraft.SourceGenerator/SelectExprInfoExplicitDto.cs (1)
src/Linqraft.SourceGenerator/SelectExprInfo.cs (1)
  • GenerateMethodHeaderPart (133-148)
🔇 Additional comments (5)
src/Linqraft.SourceGenerator/SelectExprInfoAnonymous.cs (1)

48-48: LGTM! Call site correctly updated.

The call to GenerateMethodHeaderPart now includes the type identifier "anonymous", which aligns with the updated signature and provides clearer context in generated documentation.

src/Linqraft.SourceGenerator/SelectExprInfoNamed.cs (1)

53-53: LGTM! Call site correctly updated.

The call to GenerateMethodHeaderPart now includes the type identifier "predefined", which is appropriate for named/predefined types and maintains consistency with the other variants.

src/Linqraft.SourceGenerator/SelectExprInfoExplicitDto.cs (1)

172-172: LGTM! Call site correctly updated.

The call to GenerateMethodHeaderPart now includes the type identifier "explicit", appropriately distinguishing this variant in the generated documentation.

src/Linqraft.SourceGenerator/SelectExprInfo.cs (2)

133-137: LGTM! Method signature appropriately extended.

The addition of the type parameter enables clearer documentation by distinguishing between method variants. All call sites across the derived classes have been correctly updated.


141-147: LGTM! Documentation format enhanced as intended.

The updated XML summary now includes the type identifier (anonymous/explicit/predefined) and displays only the filename instead of the full path, which improves readability while maintaining sufficient context for debugging.

@arika0093 arika0093 merged commit 405d02c into main Nov 16, 2025
4 checks passed
@arika0093 arika0093 deleted the feat/comment-location-only-filename branch November 16, 2025 12:33
arika0093 added a commit that referenced this pull request Nov 17, 2025
feat: add workflow to verify NuGet package installation and functionality (#29)

docs: update C# version requirements and remove Polysharp references in README files

docs: update C# version requirements and add details on language features in README files

Enhance method header generation to include location type (#30)

* feat: enhance method header generation to include location type in SelectExpr records

* feat: add expression type string for documentation in SelectExpr records

chore: remove branch restrictions from NuGet package verification workflow

fix: update descendant node retrieval to include the current node in HasNullableAccess method

fix: enable locked mode for dotnet restore in workflow files

refactor: streamline NuGet package verification workflow by consolidating directory creation and file copying steps

refactor: remove unnecessary TargetFrameworks from project files

refactor: remove Windows from build matrix due to performance issues

chore: Separate core functionalities into Linqraft.Core project (#31)

* chore: Separate core functionalities from SourceGenerator project into Linqraft.Core project

* feat: add GetExprTypeString method for documentation of anonymous expression types

* chore: disable documentation file generation in Directory.Build.props

fix: add missing comma and restore additionalVersions in devcontainer.json

fix: add missing PropertyGroup for DevelopmentDependency in Linqraft.csproj

close #35

fix: remove PolySharp package reference from Directory.Build.props

Revert "fix: add missing PropertyGroup for DevelopmentDependency in Linqraft.csproj"

This reverts commit 7916999.

Revert "fix: add missing comma and restore additionalVersions in devcontainer.json"

This reverts commit 8a386ab.

Reapply "fix: add missing comma and restore additionalVersions in devcontainer.json"

This reverts commit 1743adc.

Reapply "fix: add missing PropertyGroup for DevelopmentDependency in Linqraft.csproj"

This reverts commit ad3f14a.

Revert "fix: remove PolySharp package reference from Directory.Build.props"

This reverts commit 5b1a189.

fix: add PolySharp package reference and update LangVersion instructions in README files

fix: update generic type parameters in SelectExpr methods for consistency

fix: update build instructions to ensure a clean build without incremental compilation

fix: add clean-test.sh script for easier test cleanup and build process

fix: update SelectExpr method signatures for consistency across implementations

close #33

fix: change Issue33_SealedPatternTest class to partial for extensibility

fix: refactor DummyExpression class and update SelectExpr method summaries for clarity (#38)
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