diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/AnsiStringMarshaller.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/AnsiStringMarshaller.cs index 6d729263bda5e..5baea94b9372d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/AnsiStringMarshaller.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/AnsiStringMarshaller.cs @@ -32,8 +32,8 @@ public AnsiStringMarshaller(string? str) /// /// The must not be movable - that is, it should not be /// on the managed heap or it should be pinned. - /// /// + /// public AnsiStringMarshaller(string? str, Span buffer) { _allocated = false; @@ -65,18 +65,14 @@ public AnsiStringMarshaller(string? str, Span buffer) /// /// Returns the native value representing the string. /// - /// /// - /// public byte* ToNativeValue() => _nativeValue; /// /// Sets the native value representing the string. /// /// The native value. - /// /// - /// public void FromNativeValue(byte* value) { _nativeValue = value; @@ -86,17 +82,13 @@ public void FromNativeValue(byte* value) /// /// Returns the managed string. /// - /// /// - /// public string? ToManaged() => Marshal.PtrToStringAnsi((IntPtr)_nativeValue); /// /// Frees native resources. /// - /// /// - /// public void FreeNative() { if (_allocated) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/ArrayMarshaller.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/ArrayMarshaller.cs index ac65ab279cc1e..07386d0864c62 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/ArrayMarshaller.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/ArrayMarshaller.cs @@ -50,8 +50,8 @@ public ArrayMarshaller(T[]? array, int sizeOfNativeElement) /// /// The must not be movable - that is, it should not be /// on the managed heap or it should be pinned. - /// /// + /// public ArrayMarshaller(T[]? array, Span buffer, int sizeOfNativeElement) { _allocatedMemory = default; @@ -83,9 +83,7 @@ public ArrayMarshaller(T[]? array, Span buffer, int sizeOfNativeElement) /// Gets a span that points to the memory where the managed values of the array are stored. /// /// Span over managed values of the array. - /// /// - /// public ReadOnlySpan GetManagedValuesSource() => _managedArray; /// @@ -93,9 +91,7 @@ public ArrayMarshaller(T[]? array, Span buffer, int sizeOfNativeElement) /// /// Length of the array. /// Span where managed values of the array should be stored. - /// /// - /// public Span GetManagedValuesDestination(int length) => _allocatedMemory == IntPtr.Zero ? null : _managedArray = new T[length]; /// @@ -103,9 +99,7 @@ public ArrayMarshaller(T[]? array, Span buffer, int sizeOfNativeElement) /// /// Length of the array. /// Span over the native values of the array. - /// /// - /// public ReadOnlySpan GetNativeValuesSource(int length) { if (_allocatedMemory == IntPtr.Zero) @@ -120,9 +114,7 @@ public ReadOnlySpan GetNativeValuesSource(int length) /// Returns a span that points to the memory where the native values of the array should be stored. /// /// Span where native values of the array should be stored. - /// /// - /// public Span GetNativeValuesDestination() => _span; /// @@ -133,18 +125,14 @@ public ReadOnlySpan GetNativeValuesSource(int length) /// /// Returns the native value representing the array. /// - /// /// - /// public byte* ToNativeValue() => (byte*)Unsafe.AsPointer(ref GetPinnableReference()); /// /// Sets the native value representing the array. /// /// The native value. - /// /// - /// public void FromNativeValue(byte* value) { _allocatedMemory = (IntPtr)value; @@ -153,17 +141,13 @@ public void FromNativeValue(byte* value) /// /// Returns the managed array. /// - /// /// - /// public T[]? ToManaged() => _managedArray; /// /// Frees native resources. /// - /// /// - /// public void FreeNative() { Marshal.FreeCoTaskMem(_allocatedMemory); diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/BStrStringMarshaller.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/BStrStringMarshaller.cs index ce5a83a69e1ab..4f246a26bc326 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/BStrStringMarshaller.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/BStrStringMarshaller.cs @@ -34,8 +34,8 @@ public BStrStringMarshaller(string? str) /// /// The must not be movable - that is, it should not be /// on the managed heap or it should be pinned. - /// /// + /// public BStrStringMarshaller(string? str, Span buffer) { _allocated = false; @@ -78,18 +78,14 @@ public BStrStringMarshaller(string? str, Span buffer) /// /// Returns the native value representing the string. /// - /// /// - /// public void* ToNativeValue() => _ptrToFirstChar; /// /// Sets the native value representing the string. /// /// The native value. - /// /// - /// public void FromNativeValue(void* value) { _ptrToFirstChar = value; @@ -99,9 +95,7 @@ public void FromNativeValue(void* value) /// /// Returns the managed string. /// - /// /// - /// public string? ToManaged() { if (_ptrToFirstChar is null) @@ -113,9 +107,7 @@ public void FromNativeValue(void* value) /// /// Frees native resources. /// - /// /// - /// public void FreeNative() { if (_allocated) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/CustomTypeMarshallerAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/CustomTypeMarshallerAttribute.cs index 8017d3d667b40..1bdad6fbaedc0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/CustomTypeMarshallerAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/CustomTypeMarshallerAttribute.cs @@ -9,8 +9,8 @@ namespace System.Runtime.InteropServices.Marshalling /// /// This attribute is recognized by the runtime-provided source generators for source-generated interop scenarios. /// It is not used by the interop marshalling system at runtime. - /// /// + /// [AttributeUsage(AttributeTargets.Struct)] public sealed class CustomTypeMarshallerAttribute : Attribute { diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/CustomTypeMarshallerKind.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/CustomTypeMarshallerKind.cs index f19d59b0fbe1c..02cba782fd6e0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/CustomTypeMarshallerKind.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/CustomTypeMarshallerKind.cs @@ -10,9 +10,7 @@ namespace System.Runtime.InteropServices.Marshalling /// /// The shape of a custom type marshaller for usage in source-generated interop scenarios. /// - /// /// - /// public enum CustomTypeMarshallerKind { /// diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/PointerArrayMarshaller.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/PointerArrayMarshaller.cs index 18e1bd162847e..03e2f3d245926 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/PointerArrayMarshaller.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/PointerArrayMarshaller.cs @@ -50,8 +50,8 @@ public PointerArrayMarshaller(T*[]? array, int sizeOfNativeElement) /// /// The must not be movable - that is, it should not be /// on the managed heap or it should be pinned. - /// /// + /// public PointerArrayMarshaller(T*[]? array, Span buffer, int sizeOfNativeElement) { _allocatedMemory = default; @@ -83,9 +83,7 @@ public PointerArrayMarshaller(T*[]? array, Span buffer, int sizeOfNativeEl /// Gets a span that points to the memory where the managed values of the array are stored. /// /// Span over managed values of the array. - /// /// - /// public ReadOnlySpan GetManagedValuesSource() => Unsafe.As(_managedArray); /// @@ -93,9 +91,7 @@ public PointerArrayMarshaller(T*[]? array, Span buffer, int sizeOfNativeEl /// /// Length of the array. /// Span where managed values of the array should be stored. - /// /// - /// public Span GetManagedValuesDestination(int length) { if (_allocatedMemory == IntPtr.Zero) @@ -110,9 +106,7 @@ public Span GetManagedValuesDestination(int length) /// /// Length of the array. /// Span over the native values of the array. - /// /// - /// public ReadOnlySpan GetNativeValuesSource(int length) { if (_allocatedMemory == IntPtr.Zero) @@ -127,9 +121,7 @@ public ReadOnlySpan GetNativeValuesSource(int length) /// Returns a span that points to the memory where the native values of the array should be stored. /// /// Span where native values of the array should be stored. - /// /// - /// public Span GetNativeValuesDestination() => _span; /// @@ -140,34 +132,26 @@ public ReadOnlySpan GetNativeValuesSource(int length) /// /// Returns the native value representing the array. /// - /// /// - /// public byte* ToNativeValue() => (byte*)Unsafe.AsPointer(ref GetPinnableReference()); /// /// Sets the native value representing the array. /// /// The native value. - /// /// - /// public void FromNativeValue(byte* value) => _allocatedMemory = (IntPtr)value; /// /// Returns the managed array. /// - /// /// - /// public T*[]? ToManaged() => _managedArray; /// /// Frees native resources. /// - /// /// - /// public void FreeNative() { Marshal.FreeCoTaskMem(_allocatedMemory); diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/Utf16StringMarshaller.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/Utf16StringMarshaller.cs index 04ada6d9d5132..22d317a9cb17d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/Utf16StringMarshaller.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/Utf16StringMarshaller.cs @@ -31,34 +31,26 @@ public Utf16StringMarshaller(string? str) /// /// Returns the native value representing the string. /// - /// /// - /// public void* ToNativeValue() => _nativeValue; /// /// Sets the native value representing the string. /// /// The native value. - /// /// - /// public void FromNativeValue(void* value) => _nativeValue = value; /// /// Returns the managed string. /// - /// /// - /// public string? ToManaged() => Marshal.PtrToStringUni((IntPtr)_nativeValue); /// /// Frees native resources. /// - /// /// - /// public void FreeNative() { Marshal.FreeCoTaskMem((IntPtr)_nativeValue); diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/Utf8StringMarshaller.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/Utf8StringMarshaller.cs index e60db5416dfa6..955e6b7b62f70 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/Utf8StringMarshaller.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/Utf8StringMarshaller.cs @@ -33,8 +33,8 @@ public Utf8StringMarshaller(string? str) /// /// The must not be movable - that is, it should not be /// on the managed heap or it should be pinned. - /// /// + /// public Utf8StringMarshaller(string? str, Span buffer) { _allocated = false; @@ -69,18 +69,14 @@ public Utf8StringMarshaller(string? str, Span buffer) /// /// Returns the native value representing the string. /// - /// /// - /// public byte* ToNativeValue() => _nativeValue; /// /// Sets the native value representing the string. /// /// The native value. - /// /// - /// public void FromNativeValue(byte* value) { _nativeValue = value; @@ -90,17 +86,13 @@ public void FromNativeValue(byte* value) /// /// Returns the managed string. /// - /// /// - /// public string? ToManaged() => Marshal.PtrToStringUTF8((IntPtr)_nativeValue); /// /// Frees native resources. /// - /// /// - /// public void FreeNative() { if (_allocated)