Skip to content

Conversation

@arika0093
Copy link
Owner

@arika0093 arika0093 commented Dec 10, 2025

Introduce the EmbeddedAttribute to facilitate source generation in the ExportAllConstantSnippets method, enhancing the attribute system for generated code.

close #227

Summary by CodeRabbit

  • Chores

    • Removed obsolete platform-specific entries from dependency configurations across projects.
  • Refactor

    • Enhanced code generation infrastructure with improved attribute handling for generated source files.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 10, 2025

Walkthrough

This pull request introduces an EmbeddedAttribute marker annotation to internal source-generated attributes (InterceptsLocationAttribute and LinqraftAutoGeneratedDtoAttribute) to prevent them from leaking through [InternalVisibleTo] declarations. Additionally, empty Windows-specific target entries are removed from three NuGet lock files as structural cleanup.

Changes

Cohort / File(s) Summary
Lock file cleanup
src/Linqraft.Analyzer/packages.lock.json, src/Linqraft.Core/packages.lock.json, src/Linqraft.SourceGenerator/packages.lock.json
Removed empty platform-specific target entries (.NETStandard,Version=v2.0/win-x64) from dependency graphs
EmbeddedAttribute source generation
src/Linqraft.Core/GenerateSourceCodeSnippets.cs
Added new public constant EmbeddedAttribute containing C# source code; emitted as generated source EmbeddedAttribute.g.cs; applied [EmbeddedAttribute] annotation to InterceptsLocationAttribute and LinqraftAutoGeneratedDtoAttribute; added using Microsoft.CodeAnalysis; imports

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Lock file changes are straightforward structural cleanup with no behavioral impact
  • Primary review focus: src/Linqraft.Core/GenerateSourceCodeSnippets.cs — verify that the EmbeddedAttribute constant correctly generates valid C# source code and that the attribute annotations are applied to the correct generated types

Possibly related PRs

Poem

🐰 A marker so tiny, yet mighty and keen,
Prevents attribute leaks in the in-between,
With [Embedded] declared, our attributes stay tight,
No sneaking through backdoors—what a delight! ✨

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: adding EmbeddedAttribute for source generation in ExportAllConstantSnippets, which is the primary objective of the pull request.
Linked Issues check ✅ Passed The code changes successfully implement the objective from issue #227 by adding EmbeddedAttribute with proper annotations to InterceptsLocationAttribute and LinqraftAutoGeneratedDtoAttribute to prevent attribute leakage.
Out of Scope Changes check ✅ Passed All changes are directly related to the linked issue #227 objectives; the packages.lock.json updates are supporting maintenance changes with no unrelated modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ 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/add-embbed-attribute

📜 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 ca5f105 and 0ea9d42.

📒 Files selected for processing (4)
  • src/Linqraft.Analyzer/packages.lock.json (1 hunks)
  • src/Linqraft.Core/GenerateSourceCodeSnippets.cs (3 hunks)
  • src/Linqraft.Core/packages.lock.json (1 hunks)
  • src/Linqraft.SourceGenerator/packages.lock.json (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/Linqraft.{Analyzer,Core}/**/*.cs

📄 CodeRabbit inference engine (CLAUDE.md)

src/Linqraft.{Analyzer,Core}/**/*.cs: Always prefer semantic analysis over string matching; use RoslynTypeHelper instead of string-based type checking
Use ISymbolEqualityComparer for symbol comparisons in analyzer code

Files:

  • src/Linqraft.Core/GenerateSourceCodeSnippets.cs
src/Linqraft.Core/**/*.cs

📄 CodeRabbit inference engine (CLAUDE.md)

src/Linqraft.Core/**/*.cs: Keep helper methods lightweight and focused; helper methods are called frequently during analysis
Cache expensive operations in helper methods when possible

Files:

  • src/Linqraft.Core/GenerateSourceCodeSnippets.cs
🧠 Learnings (14)
📚 Learning: 2025-12-05T13:51:45.005Z
Learnt from: arika0093
Repo: arika0093/Linqraft PR: 210
File: .github/workflows/test-strict.yaml:17-17
Timestamp: 2025-12-05T13:51:45.005Z
Learning: In the Linqraft repository, the library projects (src/) target netstandard2.0, which maintains compatibility with .NET 6.0 and older versions. The test matrix in .github/workflows/test-strict.yaml specifies which .NET versions are used to run tests, not the library's compatibility. Changes to the test matrix (TFMS variable) do not affect library compatibility and should not be treated as breaking changes.

Applied to files:

  • src/Linqraft.SourceGenerator/packages.lock.json
  • src/Linqraft.Core/packages.lock.json
  • src/Linqraft.Analyzer/packages.lock.json
📚 Learning: 2025-11-25T12:08:35.849Z
Learnt from: CR
Repo: arika0093/Linqraft PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T12:08:35.849Z
Learning: Add test cases for source generators to `tests/Linqraft.Tests/`

Applied to files:

  • src/Linqraft.SourceGenerator/packages.lock.json
  • src/Linqraft.Core/GenerateSourceCodeSnippets.cs
📚 Learning: 2025-11-25T12:08:35.849Z
Learnt from: CR
Repo: arika0093/Linqraft PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T12:08:35.849Z
Learning: Applies to src/Linqraft.Core/**/*.cs : Keep helper methods lightweight and focused; helper methods are called frequently during analysis

Applied to files:

  • src/Linqraft.SourceGenerator/packages.lock.json
  • src/Linqraft.Core/GenerateSourceCodeSnippets.cs
  • src/Linqraft.Core/packages.lock.json
  • src/Linqraft.Analyzer/packages.lock.json
📚 Learning: 2025-11-25T12:08:35.849Z
Learnt from: CR
Repo: arika0093/Linqraft PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T12:08:35.849Z
Learning: Applies to src/Linqraft.Analyzer/**/*.cs : Do not use hardcoded line endings; use `TriviaHelper.EndOfLine(root)` for cross-platform line ending detection

Applied to files:

  • src/Linqraft.SourceGenerator/packages.lock.json
  • src/Linqraft.Core/packages.lock.json
  • src/Linqraft.Analyzer/packages.lock.json
📚 Learning: 2025-11-25T12:08:35.849Z
Learnt from: CR
Repo: arika0093/Linqraft PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T12:08:35.849Z
Learning: Applies to src/Linqraft/DummyExpression.cs : Do not edit `DummyExpression.cs`; it serves only as a marker for the Source Generator

Applied to files:

  • src/Linqraft.SourceGenerator/packages.lock.json
  • src/Linqraft.Core/GenerateSourceCodeSnippets.cs
📚 Learning: 2025-11-25T12:08:35.849Z
Learnt from: CR
Repo: arika0093/Linqraft PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T12:08:35.849Z
Learning: Always perform a clean build to avoid stale generator caches; run: `dotnet clean && dotnet build --no-incremental`

Applied to files:

  • src/Linqraft.SourceGenerator/packages.lock.json
📚 Learning: 2025-11-25T12:08:35.849Z
Learnt from: CR
Repo: arika0093/Linqraft PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T12:08:35.849Z
Learning: Applies to src/Linqraft.Analyzer/**/*.cs : Use `TriviaHelper` for formatting to preserve whitespace, comments, and detect line endings for cross-platform compatibility

Applied to files:

  • src/Linqraft.SourceGenerator/packages.lock.json
  • src/Linqraft.Core/packages.lock.json
  • src/Linqraft.Analyzer/packages.lock.json
📚 Learning: 2025-11-25T12:08:35.849Z
Learnt from: CR
Repo: arika0093/Linqraft PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T12:08:35.849Z
Learning: Applies to src/Linqraft.Core/**/*Helper.cs : Document complex helper methods with XML comments

Applied to files:

  • src/Linqraft.Core/GenerateSourceCodeSnippets.cs
📚 Learning: 2025-11-25T12:08:35.849Z
Learnt from: CR
Repo: arika0093/Linqraft PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T12:08:35.849Z
Learning: Applies to src/Linqraft.{Analyzer,Core}/**/*.cs : Always prefer semantic analysis over string matching; use `RoslynTypeHelper` instead of string-based type checking

Applied to files:

  • src/Linqraft.Core/GenerateSourceCodeSnippets.cs
  • src/Linqraft.Analyzer/packages.lock.json
📚 Learning: 2025-11-25T12:08:35.849Z
Learnt from: CR
Repo: arika0093/Linqraft PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T12:08:35.849Z
Learning: Applies to src/Linqraft.{Analyzer,Core}/**/*.cs : Use `ISymbolEqualityComparer` for symbol comparisons in analyzer code

Applied to files:

  • src/Linqraft.Analyzer/packages.lock.json
📚 Learning: 2025-11-25T12:08:35.849Z
Learnt from: CR
Repo: arika0093/Linqraft PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T12:08:35.849Z
Learning: Applies to src/Linqraft.Analyzer/**/*.cs : Follow naming conventions: Analyzers use `*Analyzer.cs`, Code Fix Providers use `*CodeFixProvider.cs`

Applied to files:

  • src/Linqraft.Analyzer/packages.lock.json
📚 Learning: 2025-11-25T12:08:35.849Z
Learnt from: CR
Repo: arika0093/Linqraft PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T12:08:35.849Z
Learning: Add test cases for analyzers to `tests/Linqraft.Analyzer.Tests/`

Applied to files:

  • src/Linqraft.Analyzer/packages.lock.json
📚 Learning: 2025-11-25T12:08:35.849Z
Learnt from: CR
Repo: arika0093/Linqraft PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T12:08:35.849Z
Learning: Applies to src/Linqraft.Core/AnalyzerHelpers/*.cs : Analyzer helpers should be placed in `Linqraft.Core/AnalyzerHelpers/` and named `*Helper.cs`

Applied to files:

  • src/Linqraft.Analyzer/packages.lock.json
📚 Learning: 2025-11-25T12:08:35.849Z
Learnt from: CR
Repo: arika0093/Linqraft PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T12:08:35.849Z
Learning: Applies to src/Linqraft.Analyzer/**/*Analyzer.cs : All new analyzers should inherit from `BaseLinqraftAnalyzer`

Applied to files:

  • src/Linqraft.Analyzer/packages.lock.json
🔇 Additional comments (7)
src/Linqraft.Analyzer/packages.lock.json (1)

263-263: LGTM!

Structural cleanup removing the empty .NETStandard,Version=v2.0/win-x64 target entry. No impact on package resolution.

src/Linqraft.Core/packages.lock.json (1)

130-130: LGTM!

Consistent structural cleanup removing the empty Windows-specific target entry.

src/Linqraft.SourceGenerator/packages.lock.json (1)

137-137: LGTM!

Consistent structural cleanup across all package lock files in this PR.

src/Linqraft.Core/GenerateSourceCodeSnippets.cs (4)

17-17: LGTM - Correct export order.

EmbeddedAttribute is exported before the attributes that depend on it, ensuring proper compilation order.


178-187: Well-designed embedded attribute definition.

Good implementation choices:

  • partial modifier enables coexistence with other source generators that may emit the same attribute
  • internal sealed provides correct visibility scoping
  • global::System.Attribute avoids potential namespace ambiguities

This correctly addresses issue #227 to prevent attribute leakage via [InternalsVisibleTo].


195-201: LGTM!

Correctly adds the using directive and applies [EmbeddedAttribute] to InterceptsLocationAttribute, preventing it from being exposed via [InternalsVisibleTo].


226-232: LGTM!

Consistent application of [EmbeddedAttribute] to LinqraftAutoGeneratedDtoAttribute, completing the fix for issue #227.


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.

@arika0093 arika0093 merged commit 84af23f into main Dec 10, 2025
4 checks passed
@arika0093 arika0093 deleted the feat/add-embbed-attribute branch December 10, 2025 15:37
arika0093 added a commit that referenced this pull request Dec 12, 2025
…tSnippets (#242)

* feat: add EmbeddedAttribute for source generation in ExportAllConstantSnippets

* fix: remove empty target framework entries from packages.lock.json

(cherry picked from commit 84af23f)
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: add [Embedded] attributes

2 participants