Skip to content
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 test coverage for StandardOleMarshalObject #27485

Closed
ericstj opened this issue Sep 26, 2018 · 2 comments
Closed

Add test coverage for StandardOleMarshalObject #27485

ericstj opened this issue Sep 26, 2018 · 2 comments
Assignees
Labels
area-System.Runtime.InteropServices increase-code-coverage Tracking need to add more test and increase code coverage of a component
Milestone

Comments

@ericstj
Copy link
Member

ericstj commented Sep 26, 2018

See dotnet/corefx#32491

We should add test coverage for this newly ported type.

@luqunl do you know of a trick to route a call through COM using purely managed code (eg: an RCW(CCW(managedobject)))

If we can do that, then I can imagine we could just call a COM-exposed method on the StandardOleMarshalObject derived type from a different thread and verify that it runs on the main thread.

/cc @Anipik

@luqunl
Copy link
Contributor

luqunl commented Sep 27, 2018

Yes, You can use ICustomQueryInterface to trick interop --- the StandardOleMarshalObject derived type should implements ICustomQueryInterface to tell interop this is a native object.

``
class MyStandardOleMarshalObject : StandardOleMarshalObject, ICustomQueryInterface
{

    static readonly Guid IID_IMarshal = new Guid("00000003-0000-0000-C000-000000000046");
    static readonly Guid IID_IManagedObject = new Guid("C3FCC19E-A970-11d2-8B5A-00A0C9B7C9C4");

    CustomQueryInterfaceResult ICustomQueryInterface.GetInterface(ref Guid iid, out IntPtr ppv)
    {
        if (iid == IID_IMarshal ||
            iid == IID_IManagedObject
            )
        {
            ppv = IntPtr.Zero;
            return CustomQueryInterfaceResult.Failed;
        }

        ppv = IntPtr.Zero;
        return CustomQueryInterfaceResult.NotHandled;
    }

``

@ericstj
Copy link
Member Author

ericstj commented Oct 24, 2018

@ericstj ericstj closed this as completed Oct 24, 2018
@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 3.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Runtime.InteropServices increase-code-coverage Tracking need to add more test and increase code coverage of a component
Projects
None yet
Development

No branches or pull requests

4 participants