Skip to content

When marshalling a layout class, fall-back to dynamically marshalling the type if it doesn't match the static type in the signature.#50137

Merged
jkoritzinsky merged 3 commits intodotnet:mainfrom
jkoritzinsky:derived-layouttype-marshalling
Mar 24, 2021
Merged

When marshalling a layout class, fall-back to dynamically marshalling the type if it doesn't match the static type in the signature.#50137
jkoritzinsky merged 3 commits intodotnet:mainfrom
jkoritzinsky:derived-layouttype-marshalling

Conversation

@jkoritzinsky
Copy link
Member

When we switched the struct marshalling system to be IL based, we accidentally stopped checking if the passed in object matched the type in the signature in the "layout class" case (where we have a sequential or explicit layout class type). This causes failures to marshal the derived types correctly since only the base type ends up being marshalled.

This PR fixes the regression by falling back to dynamically marshalling the object if the runtime type does not match the declared type.

Fixes #49857

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect PInvoke when parameter has base class with no members

2 participants