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.
This PR adds a new public API to MarshalInspectable, which allows calls to CreateMarshaler to pass in a VTable as generic param and an IID as a function param. This reduces .As() call and prevents unnecessary allocations.
In the table below, "Unwrap" refers to the case where CreateMarshaler returns early, and "CreateCCW" is the case where CreateMarshaler calls the CreateCCW function. Time is measured in microseconds (us) and memory is measured in bytes (B).
Net5.0
NetStandard2.0
While saving only a microsecond or two, we consistently use at least 120 B less of memory everytime we call CreateMarshaler.
Will provide a diff of generated code
Below is an example of a common pattern in projected code for structs used with marshaling, we provide a new (generic) function that handles the implementation that does not need the same subsequent method calls.