Skip to content

Conversation

@hez2010
Copy link
Contributor

@hez2010 hez2010 commented May 12, 2024

We need to treat the object as unmanaged object and create an RCW for this case.

Fixes #1510.

@hez2010 hez2010 force-pushed the fix/invalid-cast branch from 46eebc3 to 378ca8e Compare May 12, 2024 13:37
@hez2010 hez2010 marked this pull request as draft May 12, 2024 13:59
@hez2010 hez2010 marked this pull request as ready for review May 12, 2024 14:10
@hez2010
Copy link
Contributor Author

hez2010 commented May 12, 2024

Can confirm the issue has been fixed:
image

@hez2010
Copy link
Contributor Author

hez2010 commented May 13, 2024

PTAL.

@hez2010 hez2010 requested review from Sergio0694 and manodasanW May 13, 2024 05:55
@manodasanW
Copy link
Member

I can see this being a feasible solution to this problem with different projections. Going to run the CI pipelines to make sure everything continues to pass.

@hez2010

This comment was marked as resolved.

@manodasanW
Copy link
Member

Do you think we should handle this in the projection as well? i.e. turning all global::WinRT.ComWrappersSupport.FindObject<T>(thisPtr) into global::WinRT.ComWrappersSupport.FindObject<object>(thisPtr) is T __obj__ ? __obj__ : global::WinRT.ComWrappersSupport.CreateRcwForComObject<T>(thisPtr)

All of the FindObject calls in the generated projections are part of the Do_ABI_ implementations of the various interfaces. I feel like if we are ending up there, we have already decided that is the right interface for the call. If it was for another projection, I feel like it would end up on the helper type for that interface from that projection. Until we find a scenario that impacts those, I would hold off on updating those.

@manodasanW
Copy link
Member

CI passed, thanks for this change.

@manodasanW manodasanW merged commit 1a8e726 into microsoft:master May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to cast object of type 'TaskToAsyncOperationAdapter' to type 'IAsyncOperation'

3 participants