-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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 tests for OAVariantLib #101841
Merged
Merged
Add tests for OAVariantLib #101841
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AaronRobinsonMSFT
approved these changes
May 4, 2024
michaelgsharp
pushed a commit
to michaelgsharp/runtime
that referenced
this pull request
May 9, 2024
* Add native return test for basic supported types --------- Co-authored-by: Aaron Robinson <arobins@microsoft.com>
Ruihan-Yin
pushed a commit
to Ruihan-Yin/runtime
that referenced
this pull request
May 30, 2024
* Add native return test for basic supported types --------- Co-authored-by: Aaron Robinson <arobins@microsoft.com>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
area-Interop-coreclr
community-contribution
Indicates that the PR has been added by a community member
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Test for #100176.
OAVariantLib.ChangeType
will be called when a value is passed from native COM to managed via IDispatch (parameter in ComToClr call, or return value of ClrToCom call, or out value from byref parameter), and the type mismatches from managed signature. The calling order of current behavior is roughly:OleVariant::MarshalObjectForOleVariant
, marshals a default managed representation of the VARIANT. Invalid/unsupported VARIANT type will be rejected here and throws InvalidOleVariantTypeException.RuntimeType.ForwardCallToInvokeMember
,OleAutBinder.ChangeType
in managed code, handles common cases like type already matches, primitive->enum and ref non-primitive->underlying type. It misses the case of ref primitive->underlying type and will always treat it as a type mismatch.OAVariantLib.ChangeType
andOAVariant_ChangeType
: Convert source value and target type back to VARIANT and VARENUM. Specially handles the case when target isSystem.Color
. Uses a custom mapping logic that's slightly different. Types rejected here will throwNotSupportedException
, caught byOleAutBinder.ChangeType
and rethrown asCOMException(0x80020005)
.VariantChangeTypeEx
. It does the conversion with its own order. Errors will be thrown as-is, typicallyInvalidCastException
.This PR adds test for:
The test is not exhaustive and try not to exercise of detailed behavior of
VariantChangeTypeEx
.@AaronRobinsonMSFT @jkotas