-
Notifications
You must be signed in to change notification settings - Fork 202
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
Add Variant marshalling #1142
Add Variant marshalling #1142
Conversation
I did not test that yet. Just trying to gather feedback on the direction of the change. |
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Com.cs
Outdated
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Com.cs
Outdated
Show resolved
Hide resolved
I found this one when implement VARIANT marshalling for NativeAOT. Without that I have to resort to duplicate implementation in that class. PR where I discover this - dotnet/runtimelab#1142 Problem is `Marshal.PtrToStringBSTR` throw exception when passed `IntPtr.Zero`, but `Marshal.StringToBSTR` produce `IntPtr.Zero` when given null.
Not tested
Current tests in the |
Yes. Note that there is ongoing work to split the tests that require built-in COM marshalling in dotnet/runtime, so contributing to that would be definitely welcomed: |
Does this really only need to QueryInterface for |
Yes. Pedantic me want to implement |
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Com.cs
Outdated
Show resolved
Hide resolved
src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.Aot.cs
Outdated
Show resolved
Hide resolved
* Return null when Variant contains BSTR I found this one when implement VARIANT marshalling for NativeAOT. Without that I have to resort to duplicate implementation in that class. PR where I discover this - dotnet/runtimelab#1142 Problem is `Marshal.PtrToStringBSTR` throw exception when passed `IntPtr.Zero`, but `Marshal.StringToBSTR` produce `IntPtr.Zero` when given null. * Update nullable annotations
In NativeAOT scenario this allow to not rely on reflection to get GUID of the IDispatch, since it is well known. Related to dotnet/runtimelab#1142
Locally seems to be working. Build issues seems to be unrelated. But current PR I rely on the changes to runtime which is not yet landed, and as such not integrated. ComboBox now demands IDispatch implementation from my ComWrappers instance. Sigh. |
Actually three lines may not working It's not clear for me
|
Yeah, that looks odd. It would be useful to run it on CoreCLR to see where it is comming from.
It should throw whatever CoreCLR throws. In general, there is no much consistency around The full Variant marshalling is very complex. It is fine to only implement a reasonable subset. |
Can we leave this 3 cases? I would check TimeSpan for sure, but would like to move forward if possible |
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Com.cs
Outdated
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj
Outdated
Show resolved
Hide resolved
In NativeAOT scenario this allow to not rely on reflection to get GUID of the IDispatch, since it is well known. Related to dotnet/runtimelab#1142
In NativeAOT scenario this allow to not rely on reflection to get GUID of the IDispatch, since it is well known. Related to dotnet#1142
@jkotas build issues seems to be unrelated. Do I miss anything else here? |
It is failing with:
It looks like bad IL generated by the new marshaler. |
@jkotas this was fixed in ea76dd0 as part of #1102 . Exception was part of
|
Other location is
For me this seems as unrelated change. (This one actually exposes another issue with IUnknown marshalling). I need more time to understand what's going on. |
7ea113a
to
c1a78ce
Compare
- Marshal_XXX_Boolean - Marshal_XXX_Currency - Marshal_XXX_Object - Marshal_XXX_Object_IUnknown VariantBool somehow does not recognized. Probably something is messed up. I will do that in subsequent commit.
So based on my understanding, problem is with delegates who has This indicates missing coverage in tests. If I have courage, I will find out what case trigger issue, then I may create test. Should I do that, if so, where should I do that? |
Throw exception for the unhandled case before it crashes the JIT. |
c1a78ce
to
db09743
Compare
Phew, I'm finally understand where to put exception. My understanding that this was related to #176 because I was able to replicate with
|
@jkotas anything here? |
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Com.cs
Outdated
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Com.cs
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Com.cs
Outdated
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Com.cs
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Com.cs
Outdated
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Com.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you!
#1100, #306