Update string marshallers to V2 shape (#71849)
authorAaron Robinson <arobins@microsoft.com>
Sun, 10 Jul 2022 02:20:48 +0000 (19:20 -0700)
committerGitHub <noreply@github.com>
Sun, 10 Jul 2022 02:20:48 +0000 (19:20 -0700)
commit1af8727eeea7c0cb89e0c78be90017112f3c610b
treeaf158151b9d54dd2437566e4809171fd156210a9
parent25216ae833cbbef3447df377a1506f9067a90bd6
Update string marshallers to V2 shape (#71849)

* Update to string marshallers to new V2 shape.

* Fix incorrect BStr casing.

* Use NativeMemory.Alloc/Free where possible.
Avoid initialization of marshaller when not used.
Remove unneccessary unmanaged->managed APIs for In marshallers.

* Add a ClassLoader::LoadTypeByNameThrowing overload
  that can be used to load nested classes.

* Allocate precise amounts for UTF8 and ANSI marshallers.

* Use CoTaskMemAlloc/Free

* Keep allocation in local.
15 files changed:
src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.cs
src/coreclr/vm/assemblynative.cpp
src/coreclr/vm/binder.cpp
src/coreclr/vm/clsload.cpp
src/coreclr/vm/clsload.hpp
src/coreclr/vm/corelib.h
src/coreclr/vm/ilmarshalers.cpp
src/coreclr/vm/metasig.h
src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Descriptors.Shared.xml
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/AnsiStringMarshaller.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/BStrStringMarshaller.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/Utf16StringMarshaller.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/Utf8StringMarshaller.cs
src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ICustomNativeTypeMarshallingStrategy.cs
src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs