From 1f3c688f190f524f4be5361b3901187be4cf2d17 Mon Sep 17 00:00:00 2001 From: yowl00 Date: Sat, 21 Oct 2023 18:46:56 -0500 Subject: [PATCH 1/6] Add WasmImportAttribute to control wasm module names --- .../src/System.Private.CoreLib.Shared.projitems | 3 ++- .../Runtime/InteropServices/WasmImportAttribute.cs | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportAttribute.cs 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 ac73beb0c03e3..7a0d2a9cc2690 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 @@ -1016,6 +1016,7 @@ + @@ -2721,4 +2722,4 @@ - \ No newline at end of file + diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportAttribute.cs new file mode 100644 index 0000000000000..c90b8d314bd61 --- /dev/null +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportAttribute.cs @@ -0,0 +1,11 @@ +// 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 +{ + [AttributeUsage(AttributeTargets.Method, Inherited = false)] + public sealed class WasmImportAttribute : Attribute + { + public WasmImportAttribute() { } + } +} From 3691bec53de08ae77ee9f8bc381c67ce98b43a8c Mon Sep 17 00:00:00 2001 From: yowl00 Date: Sun, 22 Oct 2023 11:34:01 -0500 Subject: [PATCH 2/6] add usage for assembly and Class add ref class --- .../src/System/Runtime/InteropServices/WasmImportAttribute.cs | 2 +- .../ref/System.Runtime.InteropServices.cs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportAttribute.cs index c90b8d314bd61..5456a65296b8d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportAttribute.cs @@ -3,7 +3,7 @@ namespace System.Runtime.InteropServices { - [AttributeUsage(AttributeTargets.Method, Inherited = false)] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method, Inherited = false)] public sealed class WasmImportAttribute : Attribute { public WasmImportAttribute() { } 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 59dfcf2713620..7cb270b07e251 100644 --- a/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs +++ b/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs @@ -1711,6 +1711,10 @@ public sealed partial class VariantWrapper public VariantWrapper(object? obj) { } public object? WrappedObject { get { throw null; } } } + [AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | AttributeTargets.Method, Inherited = false)] + public sealed class WasmImportAttribute : Attribute + { + } } namespace System.Runtime.InteropServices.ComTypes { From 82601e821cea3d116f526d415a1a25eb933c6665 Mon Sep 17 00:00:00 2001 From: yowl00 Date: Tue, 24 Oct 2023 19:00:52 -0500 Subject: [PATCH 3/6] Bring AttributeTargets in line with DllImportAttribute --- .../src/System/Runtime/InteropServices/WasmImportAttribute.cs | 2 +- .../ref/System.Runtime.InteropServices.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportAttribute.cs index 5456a65296b8d..c90b8d314bd61 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportAttribute.cs @@ -3,7 +3,7 @@ namespace System.Runtime.InteropServices { - [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method, Inherited = false)] + [AttributeUsage(AttributeTargets.Method, Inherited = false)] public sealed class WasmImportAttribute : Attribute { public WasmImportAttribute() { } 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 7cb270b07e251..42ef0a33b2da4 100644 --- a/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs +++ b/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs @@ -1711,7 +1711,7 @@ public sealed partial class VariantWrapper public VariantWrapper(object? obj) { } public object? WrappedObject { get { throw null; } } } - [AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | AttributeTargets.Method, Inherited = false)] + [System.AttributeUsageAttribute(System.AttributeTargets.Method, Inherited = false)] public sealed class WasmImportAttribute : Attribute { } From b1928d11a7441c30a192d6cb130fe1f42a884083 Mon Sep 17 00:00:00 2001 From: Aaron R Robinson Date: Tue, 7 Nov 2023 11:12:39 -0800 Subject: [PATCH 4/6] Update based on API review. --- .../src/System.Private.CoreLib.Shared.projitems | 2 +- .../InteropServices/WasmImportAttribute.cs | 11 ----------- .../WasmImportLinkageAttribute.cs | 17 +++++++++++++++++ .../ref/System.Runtime.InteropServices.cs | 3 ++- 4 files changed, 20 insertions(+), 13 deletions(-) delete mode 100644 src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportAttribute.cs create mode 100644 src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportLinkageAttribute.cs 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 7a0d2a9cc2690..62cc6527848c1 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 @@ -1016,7 +1016,7 @@ - + diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportAttribute.cs deleted file mode 100644 index c90b8d314bd61..0000000000000 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportAttribute.cs +++ /dev/null @@ -1,11 +0,0 @@ -// 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 -{ - [AttributeUsage(AttributeTargets.Method, Inherited = false)] - public sealed class WasmImportAttribute : Attribute - { - public WasmImportAttribute() { } - } -} diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportLinkageAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportLinkageAttribute.cs new file mode 100644 index 0000000000000..4705bc595ddc7 --- /dev/null +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportLinkageAttribute.cs @@ -0,0 +1,17 @@ +// 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 +{ + /// + /// Used to control WASM import module linkage for an associated P/Invoke. + /// + [AttributeUsage(AttributeTargets.Method, Inherited = false)] + public sealed class WasmImportLinkageAttribute : Attribute + { + /// + /// Instance constructor. + /// + public WasmImportLinkageAttribute() { } + } +} 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 42ef0a33b2da4..7126b3877521e 100644 --- a/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs +++ b/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs @@ -1712,8 +1712,9 @@ public VariantWrapper(object? obj) { } public object? WrappedObject { get { throw null; } } } [System.AttributeUsageAttribute(System.AttributeTargets.Method, Inherited = false)] - public sealed class WasmImportAttribute : Attribute + public sealed class WasmImportLinkageAttribute : Attribute { + public WasmImportLinkageAttribute() { } } } namespace System.Runtime.InteropServices.ComTypes From 0d59044b08332381723606baac865749b9001fde Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Tue, 7 Nov 2023 11:23:08 -0800 Subject: [PATCH 5/6] Update src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportLinkageAttribute.cs Co-authored-by: Aaron Robinson --- .../Runtime/InteropServices/WasmImportLinkageAttribute.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportLinkageAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportLinkageAttribute.cs index 4705bc595ddc7..bb273a5d4672a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportLinkageAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportLinkageAttribute.cs @@ -4,7 +4,7 @@ namespace System.Runtime.InteropServices { /// - /// Used to control WASM import module linkage for an associated P/Invoke. + /// Specifies that the P/Invoke marked with this attribute should be linked in as a WASM import. /// [AttributeUsage(AttributeTargets.Method, Inherited = false)] public sealed class WasmImportLinkageAttribute : Attribute From 4ccf2e4f04d973b4074fdfc0918cbf5fd8e521a3 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Tue, 7 Nov 2023 11:24:26 -0800 Subject: [PATCH 6/6] Apply suggestions from code review --- .../Runtime/InteropServices/WasmImportLinkageAttribute.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportLinkageAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportLinkageAttribute.cs index bb273a5d4672a..e498e0d874cc5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportLinkageAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/WasmImportLinkageAttribute.cs @@ -6,6 +6,9 @@ namespace System.Runtime.InteropServices /// /// Specifies that the P/Invoke marked with this attribute should be linked in as a WASM import. /// + /// + /// See https://webassembly.github.io/spec/core/syntax/modules.html#imports. + /// [AttributeUsage(AttributeTargets.Method, Inherited = false)] public sealed class WasmImportLinkageAttribute : Attribute {