Add tests for OAVariantLib#101841
Merged
AaronRobinsonMSFT merged 11 commits intodotnet:mainfrom May 5, 2024
Merged
Conversation
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 <[email protected]>
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 <[email protected]>
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.ChangeTypewill 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.ChangeTypein 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.ChangeTypeandOAVariant_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.ChangeTypeand 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