-
-
Notifications
You must be signed in to change notification settings - Fork 224
feat: add [MapperNoInlining] attribute and MapperAttribute.NoInlining property #2240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
trejjam
wants to merge
18
commits into
riok:main
Choose a base branch
from
trejjam:fix/enum-explicit-cast-regression-repro
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
2e3a97e
test(enum): reproduce enum by-name mapping with different underlying …
trejjam b8b4e15
feat(abstractions): add MapperNoInliningAttribute
trejjam 02b4f4b
feat(abstractions): add NoInlining property to MapperAttribute
trejjam c234b30
test: update public API snapshot for MapperNoInlining
trejjam 867ec80
feat: implement MapperNoInlining inlining prevention
trejjam 230ccdc
docs: document MapperNoInlining and NoInlining
trejjam 9a57c03
fix: remove impossible null check for method containing type
trejjam 63ff646
Refactor TryInlineMapping
trejjam 7e139c1
refactor: pass NoInlining through IUserMapping instead of symbol lookup
trejjam 73f1bff
refactor: rename NoInlining to NoExpressionInlining
trejjam 7f5d54d
feat: promote RMG032 to error and short-circuit enum fallback
trejjam 7181f99
docs: note RMG032 promotion to error in 5.0 migration guide
trejjam 5c3c4b3
docs: move inlining section from mapper.mdx to queryable-projections.mdx
trejjam 005f39d
refactor: read mapper-level NoExpressionInlining through ctx.Configur…
trejjam f3de520
Update ProjectionMapper to use the NoExpressionInlining
trejjam 58eacaa
📝 docs: use AsAsyncEnumerable in non-inlined projection example
trejjam 83d002f
🐛 fix: never inline mappings declared in other assemblies
trejjam 9aeaf61
🐛 fix: honor MapperDefaults NoExpressionInlining for external mappers
trejjam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/Riok.Mapperly.Abstractions/MapperNoExpressionInliningAttribute.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| using System.Diagnostics; | ||
|
|
||
| namespace Riok.Mapperly.Abstractions; | ||
|
|
||
| /// <summary> | ||
| /// Prevents a mapping method from being inlined into expression trees for queryable projection mappings. | ||
| /// When applied, the method call is preserved as-is instead of being rebuilt in expression context. | ||
| /// This only applies to expression / queryable projection mappings; | ||
| /// regular (non-expression) mappings are unaffected. | ||
| /// This is useful when inlining causes issues such as false enum mapping diagnostics | ||
| /// due to expression tree limitations. | ||
| /// </summary> | ||
| [AttributeUsage(AttributeTargets.Method)] | ||
| [Conditional("MAPPERLY_ABSTRACTIONS_SCOPE_RUNTIME")] | ||
| public sealed class MapperNoExpressionInliningAttribute : Attribute; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,8 @@ | ||
| ; Unshipped analyzer release | ||
| ; https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md | ||
|
|
||
| ### Changed Rules | ||
|
|
||
| Rule ID | New Category | New Severity | Old Category | Old Severity | Notes | ||
| --------|--------------|--------------|--------------|--------------|------ | ||
| RMG032 | Mapper | Error | Mapper | Warning | The enum mapping strategy ByName, ByValueCheckDefined, explicit enum mappings and ignored enum values cannot be used in projection mappings |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work does it? After
AsEnumerableit is of typeIEnumerable<T>which doesn't have aToListAsync(or at least not as a built in method or extension method by ef core)…There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In older C# you need to use other implementation. But since net 10 it's there: https://learn.microsoft.com/en-us/dotnet/api/system.linq.asyncenumerable.tolistasync
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you are right. It should have been
.AsAsyncEnumerable()