-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Implement the ComVariant struct, the ComVariantMarshaller type, and generator integration #93635
Conversation
…reLib and Microsoft.CSharp. Remove the prior internal Variant type that covered this scenario.
…r "in object" to propagate back the value, we will instead require the user to specify "ref object" to get that behavior (and we'll notify the user of the breaking change with an info diagnostic).
Tagging subscribers to this area: @dotnet/interop-contrib Issue DetailsImplement the OleVariant type and the OleVariantMarshaller type as proposed in #89543 Behavior changes from the proposal:
The interop source generators will provide an info-level diagnostic when a parameter using the Additionally, this PR replaces the (previously internal) Fixes #89543
|
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
Is there a good reason why we have named this
|
We chose OLE as the online search results generally showed equal or better results for OLE, the Microsoft standard that mention VARIANT are the MS-OLE Automation standards, MS-OAUT, and the native DLL that implements most of the VARIANT support on Windows is the OLEAUT DLL, not ComBase. Additionally, other languages (such as Delphi and Perl) use the name OleVariant or OLE::Variant as well. |
OLE Automation is the old obsolete name. I believe that the official name has been just "Automation" for many years now. |
Yes, it is expected since these languages introduced the type when the tech still used the now obsolete name. I guess the question is whether we should stick with obsolete names when naming new APIs; or whether we should prefer current names. I think it should be the later. |
We also use the term OLE Variant throughout the runtime's source code. COM Variant in CoreCLR's code actually refers to a different type (the internal System.Variant type that's used by the runtime to convert between OLE VARIANTs and .NET objects). Also, the Microsoft docs still refer to OLE Automation as OLE Automation: https://learn.microsoft.com/en-us/openspecs/windows_protocols/MS-OAUT/bbb05720-f724-45c7-8d17-f83c3d1a3961 |
Yes, this code is from the late 1990 when the tech used the now obsolete name, and nobody bothered to rename it. We have number of obsolete names like that.
These docs were created for compliance with consent decree. They are frozen in time. The live docs at https://learn.microsoft.com/en-us/windows/win32/api/oaidl/ns-oaidl-variant are better up-to-date reference. |
I'm fine with |
The Automation page that is the parent of this page refers to the technology as OLE Automation (to distinguish it from UI Automation). In any case, I'll email the API Review Board to get the name change approved. |
...ibraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/OleVariant.cs
Outdated
Show resolved
Hide resolved
...ibraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/OleVariant.cs
Outdated
Show resolved
Hide resolved
...ibraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/OleVariant.cs
Outdated
Show resolved
Hide resolved
...ibraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/OleVariant.cs
Outdated
Show resolved
Hide resolved
...ibraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/OleVariant.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs
Outdated
Show resolved
Hide resolved
...ntime.InteropServices/src/System/Runtime/InteropServices/Marshalling/OleVariantMarshaller.cs
Outdated
Show resolved
Hide resolved
...ntime.InteropServices/src/System/Runtime/InteropServices/Marshalling/OleVariantMarshaller.cs
Outdated
Show resolved
Hide resolved
...ntime.InteropServices/src/System/Runtime/InteropServices/Marshalling/OleVariantMarshaller.cs
Outdated
Show resolved
Hide resolved
...ntime.InteropServices/src/System/Runtime/InteropServices/Marshalling/OleVariantMarshaller.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/System/Runtime/InteropServices/BuiltInVariantExtensions.cs
Outdated
Show resolved
Hide resolved
...s/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ComVariantTests.cs
Outdated
Show resolved
Hide resolved
...s/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/ComVariantTests.cs
Show resolved
Hide resolved
...ibraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/ComVariant.cs
Show resolved
Hide resolved
…code paths that they were inverted on. Fix integration test.
src/libraries/Common/src/System/Runtime/InteropServices/BuiltInVariantExtensions.cs
Outdated
Show resolved
Hide resolved
...ibraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/ComVariant.cs
Show resolved
Hide resolved
...ntime.InteropServices/src/System/Runtime/InteropServices/Marshalling/ComVariantMarshaller.cs
Show resolved
Hide resolved
… (ArgumentOutOfRange on 32-bit platforms)
Failure is #93999. I'll look into moving the tests into a different assembly at least for now to unblock merging this PR. |
Blocked on #94059 |
…enerator integration (dotnet#93635)
Implement the OleVariant type and the OleVariantMarshaller type as proposed in #89543
Behavior changes from the proposal:
OleVariant
does not support source-generated or built-in COM interop types in its Create method.OleVaraintMarshaller
does not support built-in COM interop types.OleVariantMarshaller
will only support propagating back results through a byref VARIANT inref
scenarios, notin
scenarios.The interop source generators will provide an info-level diagnostic when a parameter using the
OleVariantMarshaller
(whether through MarshalAs or directly) is declared as anin
parameter in an unmanaged-to-managed scenario to notify the user of the possibly unintuitive behavior/breaking change from built-in interop.Additionally, this PR replaces the (previously internal)
System.Runtime.InteropServices.Variant
type and changes the places that used it (COM Events anddynamic
support for COM objects, NativeAOT VARIANT marshalling) to use the newOleVariant
type instead.Fixes #89543