3F / Conari

🧬 One-touch unmanaged memory, runtime dynamic use of the unmanaged native C/C++ in .NET world, related P/Invoke features, and …
MIT License
252 stars 28 forks source link

IUnknown. COM Interface support #8

Open 3F opened 7 years ago

3F commented 7 years ago

Currently all works fine, but I need more flexible things like here #2

How we can play with current versions:

// the working half-declaration of original interface:
[Guid("23170F69-40C1-278A-0000-000600600000")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IInArchive
{
      void a(); void b();

0x02: uint GetNumberOfArchiveProperties();                             // <-- uint GetNumberOfItems();
                                                                            |
      void c(); void d(); void e(); void f(); void g();                     |
                                                                            |
0x08: uint GetNumberOfItems(); //uint GetNumberOfArchiveProperties();  // <-/  moreover, it can be like MySPecial001() for calling from our side.
}
...

IInArchive ar;
// DLR for STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
l.DLR.CreateObject<int>(ref cid, ref iid, out ar); 
ar.GetNumberOfItems() <--> GetNumberOfArchiveProperties()  // ok

How about of Inheritance:

In COM it does not mean code reuse, it means only that contract associated with an interface is inherited.

The coreclr could have better support for all IUnknown interfaces like a COW. I mean we already have contract for all this, why not to wrap this via optional allocation of new required records and remap pointers for new slot. But anyway, it requires any modifications of this, so... my time -_-

[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("23170F69-40C1-278A-0000-000300010000")]
public interface ISequentialInStream
{
    void Read(...);
}

[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("23170F69-40C1-278A-0000-000300030000")]
public interface IInStream: ISequentialInStream
{
    void m(...);    // only as offset of position like above. The Read() from base we still can't use
    void Seek(...); // ok 
}

just to think