-
Notifications
You must be signed in to change notification settings - Fork 214
Implement marshaler selection based on metadata model #109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement marshaler selection based on metadata model #109
Conversation
…o marshaler-selector
…number of casts in the fast-path scenario of unmarked blittable primitives) and collapse the nested switch into patterns (since Roslyn optimizes the two the same way)
Signed-off-by: Jeremy Koritzinsky <[email protected]>
…g expensive struct copies for large blittable structs.
…stem (since we aren't parsing the new attributes yet).
DllImportGenerator/DllImportGenerator/Marshalling/BlittableMarshaller.cs
Outdated
Show resolved
Hide resolved
DllImportGenerator/DllImportGenerator/Marshalling/BoolMarshaller.cs
Outdated
Show resolved
Hide resolved
DllImportGenerator/DllImportGenerator/Marshalling/MarshallingGenerator.cs
Outdated
Show resolved
Hide resolved
DllImportGenerator/DllImportGenerator/Marshalling/MarshallingGenerator.cs
Outdated
Show resolved
Hide resolved
Signed-off-by: Jeremy Koritzinsky <[email protected]>
Signed-off-by: Jeremy Koritzinsky <[email protected]>
…ntext and move it into the P/Invoke generator.
…lling boundary when the native representation doesn't keep the managed representation alive.
…ttableTypeAttrbiute on the type instead of on the parameter/return value.
…oc constructor exists.
…bugs. Treat in byref as byref. Correctly compare against false when unmarshalling bools.
…stackalloc constructor exists." This reverts commit 09f0f8c.
|
I've added the metadata reader for the new attributes and added some tests around the BlittableType attribute. I did do some work around non-blittable structs, but I've pulled that out of this PR and I'll put out a new PR in the future once we get to supporting them. From this work though, I found a bug where we were treating Can I get another review pass? |
Create a basic data model to represent parsed attribute metadata either with the old system or with the new attribute model described in the StructMarshalling design doc. (Reading the metadata into the model for the new attributes TBD).
Update MarshalerGenerators.TryCreate to use the new data model to determine generators and have more specific coverage of primitive types.
Make the bool marshaler more compatible with the new data model (use a parameterized marshaler instance instead of reading the metadata in the marshaler).
Implement more efficient blittable byref marshalling so we can more efficiently marshal blittable structs (which are coming with the new model)
Implement delegate->function pointer marshaller generator to show the flexibility of the pattern matching approach for the MarshalerGenerators.TryCreate method.
I've validated that the Roslyn code-gen for the pattern matching switch is as optimal as doing a nested switch statement model more similar to what we currently do in the runtime. I will say that the readability for the more complex patterns could use some improvement, so I'm open to suggestions/recommendations.