diff --git a/src/libraries/Common/src/Interop/Interop.Ldap.cs b/src/libraries/Common/src/Interop/Interop.Ldap.cs
index 423973b759d45..9486caeddfd79 100644
--- a/src/libraries/Common/src/Interop/Interop.Ldap.cs
+++ b/src/libraries/Common/src/Interop/Interop.Ldap.cs
@@ -3,8 +3,12 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+#if NET7_0_OR_GREATER
+using System.Runtime.InteropServices.Marshalling;
+#endif
using System.Security.Authentication;
+
internal static partial class Interop
{
public const int SEC_WINNT_AUTH_IDENTITY_UNICODE = 0x2;
diff --git a/src/libraries/Common/src/Interop/Interop.Odbc.cs b/src/libraries/Common/src/Interop/Interop.Odbc.cs
index 7e20cba698e7d..250ef4371298b 100644
--- a/src/libraries/Common/src/Interop/Interop.Odbc.cs
+++ b/src/libraries/Common/src/Interop/Interop.Odbc.cs
@@ -6,7 +6,7 @@
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
-using System.Runtime.InteropServices.GeneratedMarshalling;
+using System.Runtime.InteropServices.Marshalling;
#endif
using System.Runtime.Versioning;
using System.Security;
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupNames2.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupNames2.cs
index 94dd8bc43608b..6a59a1061642d 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupNames2.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupNames2.cs
@@ -3,6 +3,7 @@
using System;
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
using Microsoft.Win32.SafeHandles;
internal static partial class Interop
diff --git a/src/libraries/Common/src/Interop/Windows/CryptUI/Interop.CryptUIDlgCertificate.cs b/src/libraries/Common/src/Interop/Windows/CryptUI/Interop.CryptUIDlgCertificate.cs
index ce07eea1841ec..216c3142045a2 100644
--- a/src/libraries/Common/src/Interop/Windows/CryptUI/Interop.CryptUIDlgCertificate.cs
+++ b/src/libraries/Common/src/Interop/Windows/CryptUI/Interop.CryptUIDlgCertificate.cs
@@ -4,6 +4,9 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+#if NET7_0_OR_GREATER
+using System.Runtime.InteropServices.Marshalling;
+#endif
using Microsoft.Win32.SafeHandles;
internal static partial class Interop
diff --git a/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.Structs.cs b/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.Structs.cs
index a4219658a3a45..269ef4659c05b 100644
--- a/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.Structs.cs
+++ b/src/libraries/Common/src/Interop/Windows/WebSocket/Interop.Structs.cs
@@ -4,6 +4,7 @@
using System;
using System.Net.WebSockets;
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
internal static partial class Interop
{
diff --git a/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp.cs b/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp.cs
index b7e40e77b996a..e968ca3a1b33d 100644
--- a/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp.cs
+++ b/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp.cs
@@ -3,6 +3,9 @@
using System;
using System.Runtime.InteropServices;
+#if NET7_0_OR_GREATER
+using System.Runtime.InteropServices.Marshalling;
+#endif
using System.Text;
internal static partial class Interop
diff --git a/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.cs b/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.cs
index 0a0c24292ca9c..7833cacc76cc2 100644
--- a/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.cs
+++ b/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.cs
@@ -3,6 +3,9 @@
using System;
using System.Runtime.InteropServices;
+#if NET7_0_OR_GREATER
+using System.Runtime.InteropServices.Marshalling;
+#endif
using System.Text;
internal static partial class Interop
diff --git a/src/libraries/Common/src/Interop/Windows/WinMm/Interop.waveOutGetDevCaps.cs b/src/libraries/Common/src/Interop/Windows/WinMm/Interop.waveOutGetDevCaps.cs
index 3af5f064d15b8..c8cdab71522f3 100644
--- a/src/libraries/Common/src/Interop/Windows/WinMm/Interop.waveOutGetDevCaps.cs
+++ b/src/libraries/Common/src/Interop/Windows/WinMm/Interop.waveOutGetDevCaps.cs
@@ -3,6 +3,9 @@
using System;
using System.Runtime.InteropServices;
+#if NET7_0_OR_GREATER
+using System.Runtime.InteropServices.Marshalling;
+#endif
internal static partial class Interop
{
diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WinsockBSD.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WinsockBSD.cs
index b19cd8dba064d..7ab26fa8a0952 100644
--- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WinsockBSD.cs
+++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WinsockBSD.cs
@@ -4,6 +4,7 @@
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
internal static partial class Interop
{
diff --git a/src/libraries/Common/src/System/Runtime/InteropServices/HandleRefMarshaller.cs b/src/libraries/Common/src/System/Runtime/InteropServices/HandleRefMarshaller.cs
index d5b0a308bc6da..f414803d67b2f 100644
--- a/src/libraries/Common/src/System/Runtime/InteropServices/HandleRefMarshaller.cs
+++ b/src/libraries/Common/src/System/Runtime/InteropServices/HandleRefMarshaller.cs
@@ -3,8 +3,7 @@
#nullable enable
-
-namespace System.Runtime.InteropServices.GeneratedMarshalling
+namespace System.Runtime.InteropServices.Marshalling
{
[CustomTypeMarshaller(typeof(HandleRef), Direction = CustomTypeMarshallerDirection.In, Features = CustomTypeMarshallerFeatures.UnmanagedResources | CustomTypeMarshallerFeatures.TwoStageMarshalling)]
internal struct HandleRefMarshaller
diff --git a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/UnsafeNativeMethods.cs b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/UnsafeNativeMethods.cs
index a4d40ab0cc44d..b70e89445db8d 100644
--- a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/UnsafeNativeMethods.cs
+++ b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/UnsafeNativeMethods.cs
@@ -5,6 +5,9 @@
using System;
using System.Diagnostics.Eventing.Reader;
using System.Runtime.InteropServices;
+#if NET7_0_OR_GREATER
+using System.Runtime.InteropServices.Marshalling;
+#endif
using System.Security;
using System.Text;
diff --git a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Gdi32.cs b/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Gdi32.cs
index e048b7c0a36d6..e57ca965a90d4 100644
--- a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Gdi32.cs
+++ b/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Gdi32.cs
@@ -4,7 +4,7 @@
using System;
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
-using System.Runtime.InteropServices.GeneratedMarshalling;
+using System.Runtime.InteropServices.Marshalling;
#endif
internal static partial class Interop
diff --git a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Kernel32.cs b/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Kernel32.cs
index 4cf179f74a758..42d5a7c50230f 100644
--- a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Kernel32.cs
+++ b/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Kernel32.cs
@@ -4,7 +4,7 @@
using System;
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
-using System.Runtime.InteropServices.GeneratedMarshalling;
+using System.Runtime.InteropServices.Marshalling;
#endif
internal static partial class Interop
diff --git a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Shell32.cs b/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Shell32.cs
index 0f7647555f8c9..6162795d061e1 100644
--- a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Shell32.cs
+++ b/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Shell32.cs
@@ -4,7 +4,7 @@
using System;
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
-using System.Runtime.InteropServices.GeneratedMarshalling;
+using System.Runtime.InteropServices.Marshalling;
#endif
internal static partial class Interop
diff --git a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.User32.cs b/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.User32.cs
index 6c1cdf0629579..52ecb5f1ddde3 100644
--- a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.User32.cs
+++ b/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.User32.cs
@@ -4,7 +4,7 @@
using System;
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
-using System.Runtime.InteropServices.GeneratedMarshalling;
+using System.Runtime.InteropServices.Marshalling;
#endif
internal static partial class Interop
diff --git a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Winspool.cs b/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Winspool.cs
index 6623b0f888ac6..60b611dd63f32 100644
--- a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Winspool.cs
+++ b/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Winspool.cs
@@ -4,7 +4,7 @@
using System;
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
-using System.Runtime.InteropServices.GeneratedMarshalling;
+using System.Runtime.InteropServices.Marshalling;
#endif
internal static partial class Interop
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.cs
index 6fed3bdce2210..660bb5d7bed3b 100644
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.cs
+++ b/src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.cs
@@ -7,7 +7,7 @@
using System.Drawing.Text;
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
-using System.Runtime.InteropServices.GeneratedMarshalling;
+using System.Runtime.InteropServices.Marshalling;
#endif
namespace System.Drawing
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/BitmapData.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/BitmapData.cs
index 4e6a97984269a..9df3935e7d7ec 100644
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/BitmapData.cs
+++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/BitmapData.cs
@@ -3,6 +3,9 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+#if NET7_0_OR_GREATER
+using System.Runtime.InteropServices.Marshalling;
+#endif
namespace System.Drawing.Imaging
{
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorMatrix.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorMatrix.cs
index 336d6c68a0f93..f33046ac4a122 100644
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorMatrix.cs
+++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorMatrix.cs
@@ -3,6 +3,9 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+#if NET7_0_OR_GREATER
+using System.Runtime.InteropServices.Marshalling;
+#endif
namespace System.Drawing.Imaging
{
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderEmf.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderEmf.cs
index 55575087df76e..e6b2d82df6b5d 100644
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderEmf.cs
+++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderEmf.cs
@@ -5,6 +5,9 @@ namespace System.Drawing.Imaging
{
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+#if NET7_0_OR_GREATER
+ using System.Runtime.InteropServices.Marshalling;
+#endif
#if NET7_0_OR_GREATER
[NativeMarshalling(typeof(PinningMarshaller))]
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderWmf.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderWmf.cs
index 3295b5ca55434..e0f56e45a923b 100644
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderWmf.cs
+++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderWmf.cs
@@ -6,6 +6,9 @@ namespace System.Drawing.Imaging
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+#if NET7_0_OR_GREATER
+using System.Runtime.InteropServices.Marshalling;
+#endif
[StructLayout(LayoutKind.Sequential, Pack = 8)]
internal sealed class MetafileHeaderWmf
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/WmfPlaceableFileHeader.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/WmfPlaceableFileHeader.cs
index 1f7d7cdfd70bb..006c3296745f3 100644
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/WmfPlaceableFileHeader.cs
+++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/WmfPlaceableFileHeader.cs
@@ -3,6 +3,9 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+#if NET7_0_OR_GREATER
+using System.Runtime.InteropServices.Marshalling;
+#endif
namespace System.Drawing.Imaging
{
diff --git a/src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/Interop/MsQuicNativeMethods.cs b/src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/Interop/MsQuicNativeMethods.cs
index 6a7e35ca14e72..165a4b2fe15b2 100644
--- a/src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/Interop/MsQuicNativeMethods.cs
+++ b/src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/Interop/MsQuicNativeMethods.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
namespace System.Net.Quic.Implementations.MsQuic.Internal
{
diff --git a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.Shared.xml b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.Shared.xml
index 7a08bf7533728..5d965dfd023a8 100644
--- a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.Shared.xml
+++ b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.Shared.xml
@@ -268,7 +268,7 @@
-
+
diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
index b6c8e95fc10d2..04af36187e3f4 100644
--- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
+++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
@@ -792,9 +792,7 @@
-
-
@@ -836,10 +834,6 @@
-
-
-
-
@@ -869,16 +863,24 @@
-
+
+
+
+
+
+
+
+
+
+
+
-
-
@@ -899,8 +901,6 @@
-
-
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/AnsiStringMarshaller.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/AnsiStringMarshaller.cs
similarity index 98%
rename from src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/AnsiStringMarshaller.cs
rename to src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/AnsiStringMarshaller.cs
index bda83c8cd40d7..d8e0576fc1bf2 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/AnsiStringMarshaller.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/AnsiStringMarshaller.cs
@@ -3,7 +3,7 @@
using System.Runtime.CompilerServices;
-namespace System.Runtime.InteropServices
+namespace System.Runtime.InteropServices.Marshalling
{
///
/// Marshaller for ANSI strings
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ArrayMarshaller.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/ArrayMarshaller.cs
similarity index 99%
rename from src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ArrayMarshaller.cs
rename to src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/ArrayMarshaller.cs
index 4282b96f63055..0a98f2194a8d0 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ArrayMarshaller.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/ArrayMarshaller.cs
@@ -4,7 +4,7 @@
using System.Diagnostics;
using System.Runtime.CompilerServices;
-namespace System.Runtime.InteropServices
+namespace System.Runtime.InteropServices.Marshalling
{
///
/// Marshaller for arrays
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/CustomTypeMarshallerAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/CustomTypeMarshallerAttribute.cs
similarity index 97%
rename from src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/CustomTypeMarshallerAttribute.cs
rename to src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/CustomTypeMarshallerAttribute.cs
index 9b9bb3f450920..8017d3d667b40 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/CustomTypeMarshallerAttribute.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/CustomTypeMarshallerAttribute.cs
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-namespace System.Runtime.InteropServices
+namespace System.Runtime.InteropServices.Marshalling
{
///
/// Attribute used to indicate that the type can be used to convert a value of the provided to a native representation.
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/CustomTypeMarshallerDirection.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/CustomTypeMarshallerDirection.cs
similarity index 94%
rename from src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/CustomTypeMarshallerDirection.cs
rename to src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/CustomTypeMarshallerDirection.cs
index 0a876b37a5a4e..0f18e6d9ad038 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/CustomTypeMarshallerDirection.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/CustomTypeMarshallerDirection.cs
@@ -3,7 +3,7 @@
using System.ComponentModel;
-namespace System.Runtime.InteropServices
+namespace System.Runtime.InteropServices.Marshalling
{
///
/// A direction of marshalling data into or out of the managed environment
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/CustomTypeMarshallerFeatures.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/CustomTypeMarshallerFeatures.cs
similarity index 94%
rename from src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/CustomTypeMarshallerFeatures.cs
rename to src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/CustomTypeMarshallerFeatures.cs
index cc0c88f86eed9..c9aaa7c2d60c5 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/CustomTypeMarshallerFeatures.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/CustomTypeMarshallerFeatures.cs
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-namespace System.Runtime.InteropServices
+namespace System.Runtime.InteropServices.Marshalling
{
///
/// Optional features supported by custom type marshallers.
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/CustomTypeMarshallerKind.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/CustomTypeMarshallerKind.cs
similarity index 93%
rename from src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/CustomTypeMarshallerKind.cs
rename to src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/CustomTypeMarshallerKind.cs
index 11171ab0006aa..bf4b967d1772a 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/CustomTypeMarshallerKind.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/CustomTypeMarshallerKind.cs
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-namespace System.Runtime.InteropServices
+namespace System.Runtime.InteropServices.Marshalling
{
///
/// The shape of a custom type marshaller for usage in source-generated interop scenarios.
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MarshalUsingAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/MarshalUsingAttribute.cs
similarity index 98%
rename from src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MarshalUsingAttribute.cs
rename to src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/MarshalUsingAttribute.cs
index 11482e10eb7c1..f10c2743a6021 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MarshalUsingAttribute.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/MarshalUsingAttribute.cs
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-namespace System.Runtime.InteropServices
+namespace System.Runtime.InteropServices.Marshalling
{
///
/// Attribute used to provide a custom marshaller type or size information for marshalling.
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeMarshallingAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/NativeMarshallingAttribute.cs
similarity index 96%
rename from src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeMarshallingAttribute.cs
rename to src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/NativeMarshallingAttribute.cs
index 2b2530ab341a7..c4883cba97a46 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeMarshallingAttribute.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/NativeMarshallingAttribute.cs
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-namespace System.Runtime.InteropServices
+namespace System.Runtime.InteropServices.Marshalling
{
///
/// Attribute used to provide a default custom marshaller type for a given managed type.
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/PointerArrayMarshaller.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/PointerArrayMarshaller.cs
similarity index 99%
rename from src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/PointerArrayMarshaller.cs
rename to src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/PointerArrayMarshaller.cs
index 0d998b834a1ec..7399748bd1a1a 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/PointerArrayMarshaller.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/PointerArrayMarshaller.cs
@@ -4,7 +4,7 @@
using System.Diagnostics;
using System.Runtime.CompilerServices;
-namespace System.Runtime.InteropServices
+namespace System.Runtime.InteropServices.Marshalling
{
///
/// Marshaller for arrays of pointers
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Utf16StringMarshaller.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/Utf16StringMarshaller.cs
similarity index 98%
rename from src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Utf16StringMarshaller.cs
rename to src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/Utf16StringMarshaller.cs
index c722adb2c0e20..e5220a1571f7c 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Utf16StringMarshaller.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/Utf16StringMarshaller.cs
@@ -3,7 +3,7 @@
using System.Runtime.CompilerServices;
-namespace System.Runtime.InteropServices
+namespace System.Runtime.InteropServices.Marshalling
{
///
/// Marshaller for UTF-16 strings
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Utf8StringMarshaller.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/Utf8StringMarshaller.cs
similarity index 98%
rename from src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Utf8StringMarshaller.cs
rename to src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/Utf8StringMarshaller.cs
index 119fb3e2d3221..8737d0de3928b 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Utf8StringMarshaller.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/Utf8StringMarshaller.cs
@@ -4,7 +4,7 @@
using System.Runtime.CompilerServices;
using System.Text;
-namespace System.Runtime.InteropServices
+namespace System.Runtime.InteropServices.Marshalling
{
///
/// Marshaller for UTF-8 strings
diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/CustomTypeMarshallerAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/CustomTypeMarshallerAnalyzer.cs
index b95508feb2487..f3ede3364ab83 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/CustomTypeMarshallerAnalyzer.cs
+++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/CustomTypeMarshallerAnalyzer.cs
@@ -5,6 +5,7 @@
using System.Collections.Immutable;
using System.Linq;
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/CustomTypeMarshallerFixer.cs b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/CustomTypeMarshallerFixer.cs
index e59c4d14371b6..7b24fe7ae701a 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/CustomTypeMarshallerFixer.cs
+++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/CustomTypeMarshallerFixer.cs
@@ -7,6 +7,7 @@
using System.Composition;
using System.Linq;
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs
index 24887b880ed88..59d91fed346c5 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs
+++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs
@@ -6,6 +6,7 @@
using System.Collections.Immutable;
using System.Linq;
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
using Microsoft.CodeAnalysis;
namespace Microsoft.Interop
diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorFactory.cs
index ffff64e4d841b..5cd08a37f28f4 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorFactory.cs
+++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorFactory.cs
@@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/MarshallingAttributeInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/MarshallingAttributeInfo.cs
index 87b103df3c88d..5d3b81eec53ab 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/MarshallingAttributeInfo.cs
+++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/MarshallingAttributeInfo.cs
@@ -8,6 +8,7 @@
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
namespace Microsoft.Interop
{
diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Microsoft.Interop.SourceGeneration.csproj b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Microsoft.Interop.SourceGeneration.csproj
index da5fbad191d81..a169234d97a29 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Microsoft.Interop.SourceGeneration.csproj
+++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Microsoft.Interop.SourceGeneration.csproj
@@ -8,12 +8,12 @@
-
-
-
+
+
+
diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypeNames.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypeNames.cs
index 2e2f65c02c4f3..c619e6ce3dfa8 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypeNames.cs
+++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypeNames.cs
@@ -11,17 +11,17 @@ public static class TypeNames
public const string GeneratedMarshallingAttribute = "System.Runtime.InteropServices.GeneratedMarshallingAttribute";
- public const string NativeMarshallingAttribute = "System.Runtime.InteropServices.NativeMarshallingAttribute";
+ public const string NativeMarshallingAttribute = "System.Runtime.InteropServices.Marshalling.NativeMarshallingAttribute";
- public const string MarshalUsingAttribute = "System.Runtime.InteropServices.MarshalUsingAttribute";
+ public const string MarshalUsingAttribute = "System.Runtime.InteropServices.Marshalling.MarshalUsingAttribute";
- public const string CustomTypeMarshallerAttribute = "System.Runtime.InteropServices.CustomTypeMarshallerAttribute";
+ public const string CustomTypeMarshallerAttribute = "System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerAttribute";
- public const string CustomTypeMarshallerAttributeGenericPlaceholder = "System.Runtime.InteropServices.CustomTypeMarshallerAttribute.GenericPlaceholder";
+ public const string CustomTypeMarshallerAttributeGenericPlaceholder = "System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerAttribute.GenericPlaceholder";
- public const string AnsiStringMarshaller = "System.Runtime.InteropServices.AnsiStringMarshaller";
- public const string Utf16StringMarshaller = "System.Runtime.InteropServices.Utf16StringMarshaller";
- public const string Utf8StringMarshaller = "System.Runtime.InteropServices.Utf8StringMarshaller";
+ public const string AnsiStringMarshaller = "System.Runtime.InteropServices.Marshalling.AnsiStringMarshaller";
+ public const string Utf16StringMarshaller = "System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller";
+ public const string Utf8StringMarshaller = "System.Runtime.InteropServices.Marshalling.Utf8StringMarshaller";
public const string LCIDConversionAttribute = "System.Runtime.InteropServices.LCIDConversionAttribute";
@@ -56,9 +56,9 @@ public static string MarshalEx(InteropGenerationOptions options)
public const string System_Runtime_InteropServices_MemoryMarshal = "System.Runtime.InteropServices.MemoryMarshal";
- public const string System_Runtime_InteropServices_ArrayMarshaller_Metadata = "System.Runtime.InteropServices.ArrayMarshaller`1";
+ public const string System_Runtime_InteropServices_ArrayMarshaller_Metadata = "System.Runtime.InteropServices.Marshalling.ArrayMarshaller`1";
- public const string System_Runtime_InteropServices_PointerArrayMarshaller_Metadata = "System.Runtime.InteropServices.PointerArrayMarshaller`1";
+ public const string System_Runtime_InteropServices_PointerArrayMarshaller_Metadata = "System.Runtime.InteropServices.Marshalling.PointerArrayMarshaller`1";
public const string System_Runtime_InteropServices_SafeHandle = "System.Runtime.InteropServices.SafeHandle";
diff --git a/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs b/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs
index 0897a7938d20c..898b96ba95ea8 100644
--- a/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs
+++ b/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs
@@ -98,41 +98,6 @@ public sealed partial class AllowReversePInvokeCallsAttribute : System.Attribute
{
public AllowReversePInvokeCallsAttribute() { }
}
- [System.CLSCompliant(false)]
- [System.Runtime.InteropServices.CustomTypeMarshallerAttribute(typeof(string), BufferSize = 0x100,
- Features = System.Runtime.InteropServices.CustomTypeMarshallerFeatures.UnmanagedResources
- | System.Runtime.InteropServices.CustomTypeMarshallerFeatures.CallerAllocatedBuffer
- | System.Runtime.InteropServices.CustomTypeMarshallerFeatures.TwoStageMarshalling )]
- public unsafe ref struct AnsiStringMarshaller
- {
- public AnsiStringMarshaller(string? str) { }
- public AnsiStringMarshaller(string? str, System.Span buffer) { }
- public byte* ToNativeValue() { throw null; }
- public void FromNativeValue(byte* value) { }
- public string? ToManaged() { throw null; }
- public void FreeNative() { }
- }
- [System.CLSCompliantAttribute(false)]
- [System.Runtime.InteropServices.CustomTypeMarshallerAttribute(typeof(System.Runtime.InteropServices.CustomTypeMarshallerAttribute.GenericPlaceholder[]),
- System.Runtime.InteropServices.CustomTypeMarshallerKind.LinearCollection, BufferSize = 0x200,
- Features = System.Runtime.InteropServices.CustomTypeMarshallerFeatures.UnmanagedResources
- | System.Runtime.InteropServices.CustomTypeMarshallerFeatures.CallerAllocatedBuffer
- | System.Runtime.InteropServices.CustomTypeMarshallerFeatures.TwoStageMarshalling)]
- public unsafe ref struct ArrayMarshaller
- {
- public ArrayMarshaller(int sizeOfNativeElement) { }
- public ArrayMarshaller(T[]? array, int sizeOfNativeElement) { }
- public ArrayMarshaller(T[]? array, System.Span buffer, int sizeOfNativeElement) { }
- public System.ReadOnlySpan GetManagedValuesSource() { throw null; }
- public System.Span GetManagedValuesDestination(int length) { throw null; }
- public System.ReadOnlySpan GetNativeValuesSource(int length) { throw null; }
- public System.Span GetNativeValuesDestination() { throw null; }
- public ref byte GetPinnableReference() { throw null; }
- public byte* ToNativeValue() { throw null; }
- public void FromNativeValue(byte* value) { }
- public T[]? ToManaged() { throw null; }
- public void FreeNative() { }
- }
public readonly partial struct ArrayWithOffset : System.IEquatable
{
private readonly object _dummy;
@@ -358,41 +323,6 @@ public enum CustomQueryInterfaceResult
NotHandled = 1,
Failed = 2,
}
- [System.AttributeUsageAttribute(System.AttributeTargets.Struct)]
- public sealed partial class CustomTypeMarshallerAttribute : System.Attribute
- {
- public CustomTypeMarshallerAttribute(System.Type managedType, System.Runtime.InteropServices.CustomTypeMarshallerKind marshallerKind = System.Runtime.InteropServices.CustomTypeMarshallerKind.Value) { }
- public System.Type ManagedType { get { throw null; } }
- public System.Runtime.InteropServices.CustomTypeMarshallerKind MarshallerKind { get { throw null; } }
- public int BufferSize { get { throw null; } set { } }
- public System.Runtime.InteropServices.CustomTypeMarshallerDirection Direction { get { throw null; } set { } }
- public System.Runtime.InteropServices.CustomTypeMarshallerFeatures Features { get { throw null; } set { } }
- public struct GenericPlaceholder
- {
- }
- }
- [System.FlagsAttribute]
- public enum CustomTypeMarshallerDirection
- {
- [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
- None = 0,
- In = 0x1,
- Out = 0x2,
- Ref = In | Out,
- }
- [System.FlagsAttribute]
- public enum CustomTypeMarshallerFeatures
- {
- None = 0,
- UnmanagedResources = 0x1,
- CallerAllocatedBuffer = 0x2,
- TwoStageMarshalling = 0x4
- }
- public enum CustomTypeMarshallerKind
- {
- Value,
- LinearCollection
- }
[System.AttributeUsageAttribute(System.AttributeTargets.Module, Inherited=false)]
public sealed partial class DefaultCharSetAttribute : System.Attribute
{
@@ -847,17 +777,6 @@ protected MarshalDirectiveException(System.Runtime.Serialization.SerializationIn
public MarshalDirectiveException(string? message) { }
public MarshalDirectiveException(string? message, System.Exception? inner) { }
}
- [System.AttributeUsageAttribute(System.AttributeTargets.Parameter | System.AttributeTargets.ReturnValue, AllowMultiple = true)]
- public sealed partial class MarshalUsingAttribute : System.Attribute
- {
- public MarshalUsingAttribute() { }
- public MarshalUsingAttribute(System.Type nativeType) { }
- public System.Type? NativeType { get { throw null; } }
- public string CountElementName { get { throw null; } set { } }
- public int ConstantElementCount { get { throw null; } set { } }
- public int ElementIndirectionDepth { get { throw null; } set { } }
- public const string ReturnsCountValue = "return-value";
- }
public static partial class NativeLibrary
{
public static void Free(System.IntPtr handle) { }
@@ -870,12 +789,6 @@ public static void SetDllImportResolver(System.Reflection.Assembly assembly, Sys
public static bool TryLoad(string libraryPath, out System.IntPtr handle) { throw null; }
public static bool TryLoad(string libraryName, System.Reflection.Assembly assembly, System.Runtime.InteropServices.DllImportSearchPath? searchPath, out System.IntPtr handle) { throw null; }
}
- [System.AttributeUsageAttribute(System.AttributeTargets.Struct | System.AttributeTargets.Class | System.AttributeTargets.Enum | System.AttributeTargets.Delegate)]
- public sealed partial class NativeMarshallingAttribute : System.Attribute
- {
- public NativeMarshallingAttribute(System.Type nativeType) { }
- public System.Type NativeType { get { throw null; } }
- }
public static unsafe partial class NativeMemory
{
[System.CLSCompliantAttribute(false)]
@@ -1087,27 +1000,6 @@ public sealed partial class OptionalAttribute : System.Attribute
{
public OptionalAttribute() { }
}
- [System.CLSCompliantAttribute(false)]
- [System.Runtime.InteropServices.CustomTypeMarshallerAttribute(typeof(System.Runtime.InteropServices.CustomTypeMarshallerAttribute.GenericPlaceholder*[]),
- System.Runtime.InteropServices.CustomTypeMarshallerKind.LinearCollection, BufferSize = 0x200,
- Features = System.Runtime.InteropServices.CustomTypeMarshallerFeatures.UnmanagedResources
- | System.Runtime.InteropServices.CustomTypeMarshallerFeatures.CallerAllocatedBuffer
- | System.Runtime.InteropServices.CustomTypeMarshallerFeatures.TwoStageMarshalling)]
- public unsafe ref struct PointerArrayMarshaller where T : unmanaged
- {
- public PointerArrayMarshaller(int sizeOfNativeElement) { }
- public PointerArrayMarshaller(T*[]? array, int sizeOfNativeElement) { }
- public PointerArrayMarshaller(T*[]? array, System.Span buffer, int sizeOfNativeElement) { }
- public System.ReadOnlySpan GetManagedValuesSource() { throw null; }
- public System.Span GetManagedValuesDestination(int length) { throw null; }
- public System.ReadOnlySpan GetNativeValuesSource(int length) { throw null; }
- public System.Span GetNativeValuesDestination() { throw null; }
- public ref byte GetPinnableReference() { throw null; }
- public byte* ToNativeValue() { throw null; }
- public void FromNativeValue(byte* value) { }
- public T*[]? ToManaged() { throw null; }
- public void FreeNative() { }
- }
public enum PosixSignal
{
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("windows")]
@@ -1428,35 +1320,6 @@ public UnmanagedCallersOnlyAttribute() { }
public System.Type[]? CallConvs;
public string? EntryPoint;
}
- [System.CLSCompliant(false)]
- [System.Runtime.InteropServices.CustomTypeMarshallerAttribute(typeof(string), BufferSize = 0x100,
- Features = System.Runtime.InteropServices.CustomTypeMarshallerFeatures.UnmanagedResources
- | System.Runtime.InteropServices.CustomTypeMarshallerFeatures.CallerAllocatedBuffer
- | System.Runtime.InteropServices.CustomTypeMarshallerFeatures.TwoStageMarshalling )]
- public unsafe ref struct Utf8StringMarshaller
- {
- public Utf8StringMarshaller(string? str) { }
- public Utf8StringMarshaller(string? str, System.Span buffer) { }
- public byte* ToNativeValue() { throw null; }
- public void FromNativeValue(byte* value) { }
- public string? ToManaged() { throw null; }
- public void FreeNative() { }
- }
- [System.CLSCompliant(false)]
- [System.Runtime.InteropServices.CustomTypeMarshallerAttribute(typeof(string), BufferSize = 0x100,
- Features = System.Runtime.InteropServices.CustomTypeMarshallerFeatures.UnmanagedResources
- | System.Runtime.InteropServices.CustomTypeMarshallerFeatures.CallerAllocatedBuffer
- | System.Runtime.InteropServices.CustomTypeMarshallerFeatures.TwoStageMarshalling )]
- public unsafe ref struct Utf16StringMarshaller
- {
- public Utf16StringMarshaller(string? str) { }
- public Utf16StringMarshaller(string? str, System.Span buffer) { }
- public ref ushort GetPinnableReference() { throw null; }
- public ushort* ToNativeValue() { throw null; }
- public void FromNativeValue(ushort* value) { }
- public string? ToManaged() { throw null; }
- public void FreeNative() { }
- }
}
namespace System.Runtime.InteropServices.ComTypes
{
@@ -2199,6 +2062,146 @@ public enum MessageSendFunction
public static void SetMessageSendPendingException(Exception? exception) => throw null;
}
}
+namespace System.Runtime.InteropServices.Marshalling
+{
+ [System.CLSCompliant(false)]
+ [System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerAttribute(typeof(string), BufferSize = 0x100,
+ Features = System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerFeatures.UnmanagedResources
+ | System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerFeatures.CallerAllocatedBuffer
+ | System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerFeatures.TwoStageMarshalling )]
+ public unsafe ref struct AnsiStringMarshaller
+ {
+ public AnsiStringMarshaller(string? str) { }
+ public AnsiStringMarshaller(string? str, System.Span buffer) { }
+ public byte* ToNativeValue() { throw null; }
+ public void FromNativeValue(byte* value) { }
+ public string? ToManaged() { throw null; }
+ public void FreeNative() { }
+ }
+ [System.CLSCompliantAttribute(false)]
+ [System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerAttribute(typeof(System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerAttribute.GenericPlaceholder[]),
+ System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerKind.LinearCollection, BufferSize = 0x200,
+ Features = System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerFeatures.UnmanagedResources
+ | System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerFeatures.CallerAllocatedBuffer
+ | System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerFeatures.TwoStageMarshalling)]
+ public unsafe ref struct ArrayMarshaller
+ {
+ public ArrayMarshaller(int sizeOfNativeElement) { }
+ public ArrayMarshaller(T[]? array, int sizeOfNativeElement) { }
+ public ArrayMarshaller(T[]? array, System.Span buffer, int sizeOfNativeElement) { }
+ public System.ReadOnlySpan GetManagedValuesSource() { throw null; }
+ public System.Span GetManagedValuesDestination(int length) { throw null; }
+ public System.ReadOnlySpan GetNativeValuesSource(int length) { throw null; }
+ public System.Span GetNativeValuesDestination() { throw null; }
+ public ref byte GetPinnableReference() { throw null; }
+ public byte* ToNativeValue() { throw null; }
+ public void FromNativeValue(byte* value) { }
+ public T[]? ToManaged() { throw null; }
+ public void FreeNative() { }
+ }
+ [System.AttributeUsageAttribute(System.AttributeTargets.Struct)]
+ public sealed partial class CustomTypeMarshallerAttribute : System.Attribute
+ {
+ public CustomTypeMarshallerAttribute(System.Type managedType, System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerKind marshallerKind = System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerKind.Value) { }
+ public System.Type ManagedType { get { throw null; } }
+ public System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerKind MarshallerKind { get { throw null; } }
+ public int BufferSize { get { throw null; } set { } }
+ public System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerDirection Direction { get { throw null; } set { } }
+ public System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerFeatures Features { get { throw null; } set { } }
+ public struct GenericPlaceholder
+ {
+ }
+ }
+ [System.FlagsAttribute]
+ public enum CustomTypeMarshallerDirection
+ {
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
+ None = 0,
+ In = 0x1,
+ Out = 0x2,
+ Ref = In | Out,
+ }
+ [System.FlagsAttribute]
+ public enum CustomTypeMarshallerFeatures
+ {
+ None = 0,
+ UnmanagedResources = 0x1,
+ CallerAllocatedBuffer = 0x2,
+ TwoStageMarshalling = 0x4
+ }
+ public enum CustomTypeMarshallerKind
+ {
+ Value,
+ LinearCollection
+ }
+ [System.AttributeUsageAttribute(System.AttributeTargets.Parameter | System.AttributeTargets.ReturnValue, AllowMultiple = true)]
+ public sealed partial class MarshalUsingAttribute : System.Attribute
+ {
+ public MarshalUsingAttribute() { }
+ public MarshalUsingAttribute(System.Type nativeType) { }
+ public System.Type? NativeType { get { throw null; } }
+ public string CountElementName { get { throw null; } set { } }
+ public int ConstantElementCount { get { throw null; } set { } }
+ public int ElementIndirectionDepth { get { throw null; } set { } }
+ public const string ReturnsCountValue = "return-value";
+ }
+ [System.AttributeUsageAttribute(System.AttributeTargets.Struct | System.AttributeTargets.Class | System.AttributeTargets.Enum | System.AttributeTargets.Delegate)]
+ public sealed partial class NativeMarshallingAttribute : System.Attribute
+ {
+ public NativeMarshallingAttribute(System.Type nativeType) { }
+ public System.Type NativeType { get { throw null; } }
+ }
+ [System.CLSCompliantAttribute(false)]
+ [System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerAttribute(typeof(System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerAttribute.GenericPlaceholder*[]),
+ System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerKind.LinearCollection, BufferSize = 0x200,
+ Features = System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerFeatures.UnmanagedResources
+ | System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerFeatures.CallerAllocatedBuffer
+ | System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerFeatures.TwoStageMarshalling)]
+ public unsafe ref struct PointerArrayMarshaller where T : unmanaged
+ {
+ public PointerArrayMarshaller(int sizeOfNativeElement) { }
+ public PointerArrayMarshaller(T*[]? array, int sizeOfNativeElement) { }
+ public PointerArrayMarshaller(T*[]? array, System.Span buffer, int sizeOfNativeElement) { }
+ public System.ReadOnlySpan GetManagedValuesSource() { throw null; }
+ public System.Span GetManagedValuesDestination(int length) { throw null; }
+ public System.ReadOnlySpan GetNativeValuesSource(int length) { throw null; }
+ public System.Span GetNativeValuesDestination() { throw null; }
+ public ref byte GetPinnableReference() { throw null; }
+ public byte* ToNativeValue() { throw null; }
+ public void FromNativeValue(byte* value) { }
+ public T*[]? ToManaged() { throw null; }
+ public void FreeNative() { }
+ }
+ [System.CLSCompliant(false)]
+ [System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerAttribute(typeof(string), BufferSize = 0x100,
+ Features = System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerFeatures.UnmanagedResources
+ | System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerFeatures.CallerAllocatedBuffer
+ | System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerFeatures.TwoStageMarshalling )]
+ public unsafe ref struct Utf8StringMarshaller
+ {
+ public Utf8StringMarshaller(string? str) { }
+ public Utf8StringMarshaller(string? str, System.Span buffer) { }
+ public byte* ToNativeValue() { throw null; }
+ public void FromNativeValue(byte* value) { }
+ public string? ToManaged() { throw null; }
+ public void FreeNative() { }
+ }
+ [System.CLSCompliant(false)]
+ [System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerAttribute(typeof(string), BufferSize = 0x100,
+ Features = System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerFeatures.UnmanagedResources
+ | System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerFeatures.CallerAllocatedBuffer
+ | System.Runtime.InteropServices.Marshalling.CustomTypeMarshallerFeatures.TwoStageMarshalling )]
+ public unsafe ref struct Utf16StringMarshaller
+ {
+ public Utf16StringMarshaller(string? str) { }
+ public Utf16StringMarshaller(string? str, System.Span buffer) { }
+ public ref ushort GetPinnableReference() { throw null; }
+ public ushort* ToNativeValue() { throw null; }
+ public void FromNativeValue(ushort* value) { }
+ public string? ToManaged() { throw null; }
+ public void FreeNative() { }
+ }
+}
namespace System.Security
{
public sealed partial class SecureString : System.IDisposable
diff --git a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/SpanMarshallers.cs b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/SpanMarshallers.cs
index 358fc92cf6be1..3e9af57776a96 100644
--- a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/SpanMarshallers.cs
+++ b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/SpanMarshallers.cs
@@ -4,7 +4,7 @@
using System.Diagnostics;
using System.Runtime.CompilerServices;
-namespace System.Runtime.InteropServices.GeneratedMarshalling
+namespace System.Runtime.InteropServices.Marshalling
{
// Stack-alloc threshold set to 256 bytes to enable small arrays to be passed on the stack.
// Number kept small to ensure that P/Invokes with a lot of array parameters doesn't
@@ -239,7 +239,7 @@ public Span GetNativeValuesDestination() => _allocatedMemory != null
: MemoryMarshal.Cast(_data);
public ReadOnlySpan GetNativeValuesSource(int length) => new ReadOnlySpan(_nativeValue, length * sizeof(T));
-
+
public ref T GetPinnableReference() => ref _data.GetPinnableReference();
public T* ToNativeValue()
diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/ArrayTests.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/ArrayTests.cs
index 6b0d4739d4caf..69b85f33cfa35 100644
--- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/ArrayTests.cs
+++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/ArrayTests.cs
@@ -6,6 +6,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
using System.Text;
using Xunit;
diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CollectionTests.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CollectionTests.cs
index f77258710ca37..947e9b28e4ed4 100644
--- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CollectionTests.cs
+++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CollectionTests.cs
@@ -6,6 +6,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
using System.Text;
using Xunit;
diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CustomMarshallingTests.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CustomMarshallingTests.cs
index f563b6ff5dd88..8afd4544cdcf4 100644
--- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CustomMarshallingTests.cs
+++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CustomMarshallingTests.cs
@@ -3,6 +3,7 @@
using System;
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
using System.Text;
using SharedTypes;
diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/SetLastErrorTests.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/SetLastErrorTests.cs
index 18a3ac4fc1a6a..b0ed8cdaff25d 100644
--- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/SetLastErrorTests.cs
+++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/SetLastErrorTests.cs
@@ -3,6 +3,7 @@
using System;
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
using Xunit;
diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/SpanTests.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/SpanTests.cs
index 3b0a91cf26c55..f92e2bc9e5e96 100644
--- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/SpanTests.cs
+++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/SpanTests.cs
@@ -7,7 +7,7 @@
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-using System.Runtime.InteropServices.GeneratedMarshalling;
+using System.Runtime.InteropServices.Marshalling;
using System.Text;
using Xunit;
diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/StringTests.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/StringTests.cs
index 81560998fde92..d9c1f82c8e8d8 100644
--- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/StringTests.cs
+++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/StringTests.cs
@@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
using System.Text;
using Xunit;
diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/AddDisableRuntimeMarshallingAttributeFixerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/AddDisableRuntimeMarshallingAttributeFixerTests.cs
index c905bfa14ef04..7032a471e6b38 100644
--- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/AddDisableRuntimeMarshallingAttributeFixerTests.cs
+++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/AddDisableRuntimeMarshallingAttributeFixerTests.cs
@@ -34,6 +34,7 @@ public static async Task Adds_NewFile_With_Attribute()
// Source will have CS8795 (Partial method must have an implementation) without generator run
var source = @"
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
partial class Foo
{
[LibraryImport(""Foo"")]
@@ -64,6 +65,7 @@ public static async Task Appends_Attribute_To_Existing_AssemblyInfo_File()
{
var source = @"
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
partial class Foo
{
[LibraryImport(""Foo"")]
diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/AdditionalAttributesOnStub.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/AdditionalAttributesOnStub.cs
index 5287538574a3f..6082c923a2928 100644
--- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/AdditionalAttributesOnStub.cs
+++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/AdditionalAttributesOnStub.cs
@@ -19,6 +19,7 @@ public async Task SkipLocalsInitAdded()
string source = @"
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
[assembly:DisableRuntimeMarshalling]
partial class C
{
@@ -71,6 +72,7 @@ public async Task GeneratedCodeAdded()
string source = @"
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
[assembly:DisableRuntimeMarshalling]
partial class C
{
@@ -162,6 +164,7 @@ public async Task SkipLocalsInitNotAddedWhenDefinedAtModuleLevel()
{
string source = @"
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
using System.Runtime.CompilerServices;
[module:SkipLocalsInit]
partial class C
@@ -195,6 +198,7 @@ public async Task SkipLocalsInitNotAddedWhenDefinedAtClassLevel()
{
string source = @"
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
using System.Runtime.CompilerServices;
[SkipLocalsInit]
partial class C
@@ -228,6 +232,7 @@ public async Task SkipLocalsInitNotAddedWhenDefinedOnMethodByUser()
{
string source = @"
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
using System.Runtime.CompilerServices;
partial class C
{
diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/AttributeForwarding.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/AttributeForwarding.cs
index 9f583c2be6ee0..a91bf5f5a74ef 100644
--- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/AttributeForwarding.cs
+++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/AttributeForwarding.cs
@@ -25,6 +25,7 @@ public async Task KnownParameterlessAttribute(string attributeSourceName, string
string source = @$"
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
[assembly:DisableRuntimeMarshalling]
partial class C
{{
@@ -67,6 +68,7 @@ public async Task UnmanagedCallConvAttribute_EmptyCallConvArray()
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
[assembly:DisableRuntimeMarshalling]
partial class C
{
@@ -111,6 +113,7 @@ public async Task UnmanagedCallConvAttribute_SingleCallConvType()
string source = @"
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
[assembly:DisableRuntimeMarshalling]
partial class C
{
@@ -159,6 +162,7 @@ public async Task UnmanagedCallConvAttribute_MultipleCallConvTypes()
string source = @"
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
[assembly:DisableRuntimeMarshalling]
partial class C
{
@@ -211,6 +215,7 @@ public async Task DefaultDllImportSearchPathsAttribute()
string source = @$"
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
[assembly:DisableRuntimeMarshalling]
partial class C
{{
@@ -257,6 +262,7 @@ public async Task OtherAttributeType()
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
[assembly:DisableRuntimeMarshalling]
class OtherAttribute : Attribute {}
diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CodeSnippets.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CodeSnippets.cs
index c5a348a4ce8b8..b99404232e1c5 100644
--- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CodeSnippets.cs
+++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CodeSnippets.cs
@@ -336,6 +336,9 @@ partial class Test
";
public static readonly string DisableRuntimeMarshalling = "[assembly:System.Runtime.CompilerServices.DisableRuntimeMarshalling]";
+ public static readonly string UseCustomTypeMarshaller =
+@$"using System.Runtime.InteropServices.Marshalling;
+{DisableRuntimeMarshalling}";
///
/// Declaration with parameters with set.
@@ -380,7 +383,7 @@ public static string BasicParametersAndModifiersWithStringMarshallingCustomType<
public static string CustomStringMarshallingParametersAndModifiers()
{
string typeName = typeof(T).ToString();
- return BasicParametersAndModifiersWithStringMarshallingCustomType(typeName, "Native", DisableRuntimeMarshalling) + @$"
+ return BasicParametersAndModifiersWithStringMarshallingCustomType(typeName, "Native", UseCustomTypeMarshaller) + @$"
[CustomTypeMarshaller(typeof({typeName}))]
struct Native
{{
@@ -649,9 +652,9 @@ public Native(S s)
public S ToManaged() => new S { b = i != 0 };
}";
- public static string CustomStructMarshallingParametersAndModifiers = BasicParametersAndModifiers("S", DisableRuntimeMarshalling) + BasicNonBlittableUserDefinedType;
+ public static string CustomStructMarshallingParametersAndModifiers = BasicParametersAndModifiers("S", UseCustomTypeMarshaller) + BasicNonBlittableUserDefinedType;
- public static string CustomStructMarshallingMarshalUsingParametersAndModifiers = MarshalUsingParametersAndModifiers("S", "Native", DisableRuntimeMarshalling) + @"
+ public static string CustomStructMarshallingMarshalUsingParametersAndModifiers = MarshalUsingParametersAndModifiers("S", "Native", UseCustomTypeMarshaller) + @"
struct S
{
public bool b;
@@ -670,7 +673,7 @@ public Native(S s)
}
";
- public static string CustomStructMarshallingStackallocParametersAndModifiersNoRef = BasicParametersAndModifiersNoRef("S", DisableRuntimeMarshalling) + @"
+ public static string CustomStructMarshallingStackallocParametersAndModifiersNoRef = BasicParametersAndModifiersNoRef("S", UseCustomTypeMarshaller) + @"
[NativeMarshalling(typeof(Native))]
struct S
{
@@ -689,7 +692,7 @@ public Native(S s, System.Span b)
public S ToManaged() => new S { b = i != 0 };
}
";
- public static string CustomStructMarshallingStackallocOnlyRefParameter = BasicParameterWithByRefModifier("ref", "S", DisableRuntimeMarshalling) + @"
+ public static string CustomStructMarshallingStackallocOnlyRefParameter = BasicParameterWithByRefModifier("ref", "S", UseCustomTypeMarshaller) + @"
[NativeMarshalling(typeof(Native))]
struct S
{
@@ -708,7 +711,7 @@ public Native(S s, System.Span b)
public S ToManaged() => new S { b = i != 0 };
}
";
- public static string CustomStructMarshallingOptionalStackallocParametersAndModifiers = BasicParametersAndModifiers("S", DisableRuntimeMarshalling) + @"
+ public static string CustomStructMarshallingOptionalStackallocParametersAndModifiers = BasicParametersAndModifiers("S", UseCustomTypeMarshaller) + @"
[NativeMarshalling(typeof(Native))]
struct S
{
@@ -732,7 +735,7 @@ public Native(S s)
}
";
- public static string CustomStructMarshallingStackallocValuePropertyParametersAndModifiersNoRef = BasicParametersAndModifiersNoRef("S", DisableRuntimeMarshalling) + @"
+ public static string CustomStructMarshallingStackallocValuePropertyParametersAndModifiersNoRef = BasicParametersAndModifiersNoRef("S", UseCustomTypeMarshaller) + @"
[NativeMarshalling(typeof(Native))]
struct S
{
@@ -752,7 +755,7 @@ public Native(S s, System.Span b)
public void FromNativeValue(int value) => throw null;
}
";
- public static string CustomStructMarshallingValuePropertyParametersAndModifiers = BasicParametersAndModifiers("S", DisableRuntimeMarshalling) + @"
+ public static string CustomStructMarshallingValuePropertyParametersAndModifiers = BasicParametersAndModifiers("S", UseCustomTypeMarshaller) + @"
[NativeMarshalling(typeof(Native))]
struct S
{
@@ -772,7 +775,7 @@ public Native(S s)
public void FromNativeValue(int value) => throw null;
}
";
- public static string CustomStructMarshallingPinnableParametersAndModifiers = BasicParametersAndModifiers("S", DisableRuntimeMarshalling) + @"
+ public static string CustomStructMarshallingPinnableParametersAndModifiers = BasicParametersAndModifiers("S", UseCustomTypeMarshaller) + @"
[NativeMarshalling(typeof(Native))]
class S
{
@@ -802,6 +805,7 @@ public Native(S s)
public static string CustomStructMarshallingNativeTypePinnable = @"
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
using System;
[assembly:System.Runtime.CompilerServices.DisableRuntimeMarshalling]
@@ -860,7 +864,7 @@ public static partial void Method(
}
";
- public static string CustomStructMarshallingByRefValueProperty = BasicParametersAndModifiers("S", DisableRuntimeMarshalling) + @"
+ public static string CustomStructMarshallingByRefValueProperty = BasicParametersAndModifiers("S", UseCustomTypeMarshaller) + @"
[NativeMarshalling(typeof(Native))]
class S
{
@@ -919,7 +923,7 @@ partial class Test
public static partial {returnType} Method({parameterType} p);
}}";
- public static string CustomStructMarshallingManagedToNativeOnlyOutParameter => BasicParameterWithByRefModifier("out", "S", DisableRuntimeMarshalling) + @"
+ public static string CustomStructMarshallingManagedToNativeOnlyOutParameter => BasicParameterWithByRefModifier("out", "S", UseCustomTypeMarshaller) + @"
[NativeMarshalling(typeof(Native))]
[StructLayout(LayoutKind.Sequential)]
struct S
@@ -938,7 +942,7 @@ public Native(S s)
}
";
- public static string CustomStructMarshallingManagedToNativeOnlyReturnValue => BasicReturnType("S", DisableRuntimeMarshalling) + @"
+ public static string CustomStructMarshallingManagedToNativeOnlyReturnValue => BasicReturnType("S", UseCustomTypeMarshaller) + @"
[NativeMarshalling(typeof(Native))]
[StructLayout(LayoutKind.Sequential)]
struct S
@@ -957,7 +961,7 @@ public Native(S s)
}
";
- public static string CustomStructMarshallingNativeToManagedOnlyInParameter => BasicParameterWithByRefModifier("in", "S", DisableRuntimeMarshalling) + @"
+ public static string CustomStructMarshallingNativeToManagedOnlyInParameter => BasicParameterWithByRefModifier("in", "S", UseCustomTypeMarshaller) + @"
[NativeMarshalling(typeof(Native))]
struct S
{
@@ -973,7 +977,7 @@ struct Native
}
";
- public static string ArrayMarshallingWithCustomStructElementWithValueProperty => MarshalAsArrayParametersAndModifiers("IntStructWrapper", DisableRuntimeMarshalling) + @"
+ public static string ArrayMarshallingWithCustomStructElementWithValueProperty => MarshalAsArrayParametersAndModifiers("IntStructWrapper", UseCustomTypeMarshaller) + @"
[NativeMarshalling(typeof(IntStructWrapperNative))]
public struct IntStructWrapper
{
@@ -994,7 +998,7 @@ public IntStructWrapperNative(IntStructWrapper managed)
}
";
- public static string ArrayMarshallingWithCustomStructElement => MarshalAsArrayParametersAndModifiers("IntStructWrapper", DisableRuntimeMarshalling) + @"
+ public static string ArrayMarshallingWithCustomStructElement => MarshalAsArrayParametersAndModifiers("IntStructWrapper", UseCustomTypeMarshaller) + @"
[NativeMarshalling(typeof(IntStructWrapperNative))]
public struct IntStructWrapper
{
@@ -1123,7 +1127,7 @@ struct RecursiveStruct2
int i;
}";
- public static string CollectionByValue(string elementType) => BasicParameterByValue($"TestCollection<{elementType}>", DisableRuntimeMarshalling) + @"
+ public static string CollectionByValue(string elementType) => BasicParameterByValue($"TestCollection<{elementType}>", UseCustomTypeMarshaller) + @"
[NativeMarshalling(typeof(Marshaller<>))]
class TestCollection {}
@@ -1146,6 +1150,7 @@ public Marshaller(TestCollection managed, int nativeElementSize) : this() {}
public static string MarshalUsingCollectionCountInfoParametersAndModifiers(string collectionType) => $@"
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
{DisableRuntimeMarshalling}
partial class Test
{{
@@ -1189,6 +1194,7 @@ public Marshaller(TestCollection managed, int nativeElementSize) : this() {}
public static string MarshalUsingCollectionParametersAndModifiers(string collectionType, string marshallerType) => $@"
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
{DisableRuntimeMarshalling}
partial class Test
{{
@@ -1210,6 +1216,7 @@ out int pOutSize
public static string MarshalUsingCollectionReturnValueLength(string collectionType, string marshallerType) => $@"
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
{DisableRuntimeMarshalling}
partial class Test
{{
@@ -1225,6 +1232,7 @@ public static partial int Method(
public static string MarshalUsingArrayParameterWithSizeParam(string sizeParamType, bool isByRef) => $@"
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
{DisableRuntimeMarshalling}
partial class Test
{{
@@ -1239,6 +1247,7 @@ public static partial void Method(
public static string MarshalUsingCollectionWithConstantAndElementCount => $@"
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
{DisableRuntimeMarshalling}
partial class Test
{{
@@ -1251,6 +1260,7 @@ public static partial void Method(
public static string MarshalUsingCollectionWithNullElementName => $@"
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
{DisableRuntimeMarshalling}
partial class Test
{{
@@ -1261,7 +1271,7 @@ public static partial void Method(
);
}}";
- public static string GenericCollectionMarshallingArityMismatch => BasicParameterByValue("TestCollection", DisableRuntimeMarshalling) + @"
+ public static string GenericCollectionMarshallingArityMismatch => BasicParameterByValue("TestCollection", UseCustomTypeMarshaller) + @"
[NativeMarshalling(typeof(Marshaller<,>))]
class TestCollection {}
@@ -1282,6 +1292,7 @@ public Marshaller(TestCollection managed, int nativeElementSize) : this() {}
public static string GenericCollectionWithCustomElementMarshalling => @"
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
[assembly:System.Runtime.CompilerServices.DisableRuntimeMarshalling]
partial class Test
{
@@ -1308,6 +1319,7 @@ public IntWrapper(int i){}
public static string GenericCollectionWithCustomElementMarshallingDuplicateElementIndirectionDepth => @"
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
[assembly:System.Runtime.CompilerServices.DisableRuntimeMarshalling]
partial class Test
{
@@ -1326,6 +1338,7 @@ public IntWrapper(int i){}
public static string GenericCollectionWithCustomElementMarshallingUnusedElementIndirectionDepth => @"
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
[assembly:System.Runtime.CompilerServices.DisableRuntimeMarshalling]
partial class Test
{
@@ -1344,6 +1357,7 @@ public IntWrapper(int i){}
public static string MarshalAsAndMarshalUsingOnReturnValue => @"
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
[assembly:System.Runtime.CompilerServices.DisableRuntimeMarshalling]
partial class Test
{
@@ -1356,6 +1370,7 @@ partial class Test
public static string RecursiveCountElementNameOnReturnValue => @"
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
[assembly:System.Runtime.CompilerServices.DisableRuntimeMarshalling]
partial class Test
{
@@ -1367,6 +1382,7 @@ partial class Test
public static string RecursiveCountElementNameOnParameter => @"
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
[assembly:System.Runtime.CompilerServices.DisableRuntimeMarshalling]
partial class Test
{
@@ -1378,6 +1394,7 @@ public static partial void Method(
";
public static string MutuallyRecursiveCountElementNameOnParameter => @"
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
[assembly:System.Runtime.CompilerServices.DisableRuntimeMarshalling]
partial class Test
{
@@ -1403,6 +1420,7 @@ public static partial void Method(
public static string CollectionsOfCollectionsStress => @"
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
[assembly:System.Runtime.CompilerServices.DisableRuntimeMarshalling]
partial class Test
{
diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/Compiles.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/Compiles.cs
index 70475232d6df6..9d709c81f5e79 100644
--- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/Compiles.cs
+++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/Compiles.cs
@@ -115,8 +115,8 @@ public static IEnumerable