-
Notifications
You must be signed in to change notification settings - Fork 169
Defensive copies for non-readonly struct queries #43
Copy link
Copy link
Closed
Description
At the moment the generator adds the in parameter modifier for read-only structs, it does not add it for non-readonly structs.
But the method signature of the wrapper always containts the in modifier.
Mediator/src/Mediator.SourceGenerator.Implementation/resources/Mediator.sbn-cs
Lines 143 to 144 in 27761e0
| public {{ wrapperType.ReturnTypeName }} Handle(in TRequest request, global::System.Threading.CancellationToken cancellationToken) => | |
| _rootHandler(request, cancellationToken); |
This means, that for non-readonly structs a defensive copy is always made, which is wrong from the code-correctness perspective and for performance.
See: https://devblogs.microsoft.com/premier-developer/the-in-modifier-and-the-readonly-structs-in-c/#performance-characteristics-of-the-in-modifier for more details
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels