Skip to content

Can we avoid DynamicallyAccessedMemberTypes.All on RpcMarshalableOptionalInterfaceAttribute? #1285

@AArnott

Description

@AArnott

What if:

  1. We drop the [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] attribute from the optionalInterface parameter of the RpcMarshalableOptionalInterfaceAttribute constructor.
  2. We use a source generator to find uses of the RpcMarshalableOptionalInterfaceAttribute and emit code that:
  3. Builds up an RpcTargetMetadata.InterfaceCollection.
  4. Adds another attribute to the originally annotated member that points to the generated code.
  5. At runtime when we find RpcMarshalableOptionalInterfaceAttribute we look for the source generated attribute and use that instead of reflecting over the OptionalInterface type.

We'll get better performance and more trimmable apps.

Doing this later (after our PolyType milestone release) would be problematic for existing applications because libraries may use the attribute but haven't compiled with the source generator, thus breaking an app that trims until all its libraries recompile against the newer StreamJsonRpc.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions