Skip to content

Add a target-forwarding behavior, including a lazy target #264

Description

@kzu

Summary

Ship a behavior that forwards an invocation to another instance, including a target created on first use. This is the decorator, the interface proxy with a target, and the virtual proxy used by ORMs.

API

The behavior holds either an instance or Func<object?>. Each applicable call invokes the same member on that instance and returns its result, including arguments, ref / out values, and exceptions.

The factory runs on the first forwarded call and the instance is reused after that. The factory may return another stunt.

Constraints

  • Invoke the target through the compiled call shape. Native AOT has no reflection fallback for an arbitrary member.
  • An interface stunt has no base body, so a result requires a target. A class stunt with no target calls the base implementation.
  • Virtual calls from a base constructor already enter the pipeline. The factory must be safe to run from that call.

Acceptance

  • An interface stunt forwards arguments and the return value to a hand-written implementation, and a thrown exception reaches the caller.
  • The factory runs once.
  • A class stunt with no target still runs the base implementation.

Composition

Outer to inner, the recommended pipeline is observation, resilience, transaction, cache, then this forwarder.

Back this issue
Back this issue

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions