Skip to content

Defensive copies for non-readonly struct queries #43

@Tornhoof

Description

@Tornhoof

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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions