Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Add basic implementation of the ComWrappers #8143

Closed
wants to merge 2 commits into from
Closed

Add basic implementation of the ComWrappers #8143

wants to merge 2 commits into from

Conversation

kant2002
Copy link
Contributor

@kant2002 kant2002 commented May 9, 2020

Added tests, but they are not working yet due to wrong targeting.

See #4219

@jkotas
Copy link
Member

jkotas commented May 9, 2020

Added tests, but they are not working yet due to wrong targeting.

Fixing the targeting for the tests is non-trivial with the build system in the repo. It would be best to wait with automating these tests after we move CoreRT into dotnet/runtimelab, and we would probably just want to reuse the CoreCLR tests for this. For now, I think it is good enough if you just do a manual testing.

namespace API
{
// Documentation found at https://docs.microsoft.com/windows/win32/api/windows.ui.xaml.hosting.referencetracker/
class DECLSPEC_UUID("64bd43f8-bfee-4ec4-b7eb-2935158dae21") IReferenceTrackerTarget : public IUnknown
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think you need to worry about the reference tracking. It is for WinRT only - not required for what you are trying to achieve.

@jkotas
Copy link
Member

jkotas commented May 9, 2020

I have mentioned earlier that the implementation should be 99% C# ... I take that back. I think you want to reuse a good chunk of https://github.com/dotnet/runtime/tree/master/src/coreclr/src/interop from CoreCLR. You can reimplement some of it in C#, but it would not be that much of an improvement.

@kant2002
Copy link
Contributor Author

kant2002 commented May 9, 2020

I see that. Plus one more place

Given that there some interesting scenarios in the test, I decide add implementation blindly trying make tests to pass just to excercise the code paths where it blow up.

I have set of questions

@Suchiman
Copy link
Contributor

Suchiman commented May 9, 2020

@jkotas
Copy link
Member

jkotas commented May 10, 2020

I do not think there is much to directly reuse for CoreRT from the files under vm.

QCall

The equivalent of QCall in CoreRT is [DllImport(RuntimeLibrary, ExactSpelling = true)]. You should be able to fine number of examples.

The most significant difference between CoreCLR QCalls is that CoreRT does not have exception interop. If you need to throw exception in CoreRT, you need to return an error code and then throw the exception in C#.

@jkoritzinsky
Copy link
Member

There is an implementation of the identity cache in managed code that you could borrow. https://github.com/microsoft/CsWinRT/blob/master/WinRT.Runtime/ComWrappersSupport.netstandard2.0.cs has an implementation of the identity caching entirely in managed. There's likely some optimizations that could be done.

@jkotas jkotas mentioned this pull request Jul 26, 2020
@kant2002
Copy link
Contributor Author

I will try to revitalize my attempts to make some progress.
@jkotas if I try to borrow idea/impl from @jkoritzinsky link, would you think is this good plan?

@jkotas
Copy link
Member

jkotas commented Jul 27, 2020

It has quite a bit of CsWinRT-specific code that you will need to fix up, otherwise sounds reasonable to me.

@VS-ux VS-ux mentioned this pull request Aug 11, 2020
Added tests, but they are not working yet due to wrong targeting.
@jkotas
Copy link
Member

jkotas commented Oct 15, 2020

If you would live to continue working on this, could you please open a new PR in https://github.com/dotnet/runtimelab/tree/feature/NativeAOT ? Thank you!

The new place should make reusing the coreclr implementation at https://github.com/dotnet/runtime/tree/master/src/coreclr/src/interop easier.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants