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

Fix datapackage to datapackageview invalid cast #903

Merged
merged 5 commits into from
Jul 8, 2021

Conversation

ujjwalchadha
Copy link
Contributor

This PR adds a fallback while casting the rcw to the managed type using the cache. The fallback is to not use the cache and try creating the rcw again. This takes care of the invalid case where aa different runtime class represents the same object pointer that has been seen before.

@ujjwalchadha ujjwalchadha requested a review from manodasanW July 7, 2021 22:24
@ujjwalchadha ujjwalchadha linked an issue Jul 7, 2021 that may be closed by this pull request
@manodasanW manodasanW requested a review from jkoritzinsky July 7, 2021 23:49
@ujjwalchadha ujjwalchadha requested a review from manodasanW July 8, 2021 04:31
ABI.System.Nullable<Type> nt => (T)(object)nt.Value,
T castRcw => castRcw,
_ when tryUseCache => CreateRcwForComObject<T>(ptr, false),
_ => throw new ArgumentException(string.Format("Unable to create rcw. The com object {0} has type {1} which cannot be assigned to type {2}", ptr, rcw.GetType(), typeof(T)))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
_ => throw new ArgumentException(string.Format("Unable to create rcw. The com object {0} has type {1} which cannot be assigned to type {2}", ptr, rcw.GetType(), typeof(T)))
_ => throw new ArgumentException(string.Format("Unable to create a wrapper object. The WinRT object {0} has type {1} which cannot be assigned to type {2}", ptr, rcw.GetType(), typeof(T)))

@ujjwalchadha ujjwalchadha merged commit e6122f0 into master Jul 8, 2021
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.

Drag&Drop scenario broken because InvalidCastException
3 participants