diff options
17 files changed, 144 insertions, 132 deletions
diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj index 860f0304186..c27c6653a73 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj @@ -1,6 +1,7 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> + <AssemblyName>Microsoft.Interop.DllImportGenerator</AssemblyName> <TargetFramework>netstandard2.0</TargetFramework> <IncludeBuildOutput>false</IncludeBuildOutput> <SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking> diff --git a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/Ancillary.Interop.csproj b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/Ancillary.Interop.csproj index 642e04fe9e5..e2234522094 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/Ancillary.Interop.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/Ancillary.Interop.csproj @@ -1,6 +1,7 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> + <AssemblyName>Microsoft.Interop.Ancillary</AssemblyName> <TargetFramework>net5.0</TargetFramework> <LangVersion>8.0</LangVersion> <RootNamespace>System.Runtime.InteropServices</RootNamespace> diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs index 14874d43643..778e30b6bfd 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/ArrayTests.cs @@ -12,30 +12,30 @@ namespace DllImportGenerator.IntegrationTests { public partial class Arrays { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "sum_int_array")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array")] public static partial int Sum(int[] values, int numValues); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "sum_int_array_ref")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array_ref")] public static partial int SumInArray(in int[] values, int numValues); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "duplicate_int_array")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "duplicate_int_array")] public static partial void Duplicate([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] ref int[] values, int numValues); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "create_range_array")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "create_range_array")] [return:MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] public static partial int[] CreateRange(int start, int end, out int numValues); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "sum_string_lengths")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_string_lengths")] public static partial int SumStringLengths([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr)] string[] strArray); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_strings")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "reverse_strings")] public static partial void ReverseStrings([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 1)] ref string[] strArray, out int numElements); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "get_long_bytes")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "get_long_bytes")] [return:MarshalAs(UnmanagedType.LPArray, SizeConst = sizeof(long))] public static partial byte[] GetLongBytes(long l); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "append_int_to_array")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "append_int_to_array")] public static partial void Append([MarshalAs(UnmanagedType.LPArray, SizeConst = 1, SizeParamIndex = 1)] ref int[] values, int numOriginalValues, int newValue); } } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BlittableStructTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BlittableStructTests.cs index 558f596b386..7c8c7130f4b 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BlittableStructTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BlittableStructTests.cs @@ -8,15 +8,15 @@ namespace DllImportGenerator.IntegrationTests { partial class NativeExportsNE { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "blittablestructs_double_intfields_byref")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_double_intfields_byref")] public static partial void DoubleIntFieldsByRef(ref IntFields result); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "blittablestructs_double_intfields_refreturn")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_double_intfields_refreturn")] public static partial void DoubleIntFieldsRefReturn( IntFields input, ref IntFields result); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "blittablestructs_double_intfields_refreturn")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_double_intfields_refreturn")] public static partial void DoubleIntFieldsOutReturn( IntFields input, out IntFields result); diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BooleanTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BooleanTests.cs index 4f870d7a44a..673e7647b53 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BooleanTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/BooleanTests.cs @@ -7,52 +7,52 @@ namespace DllImportGenerator.IntegrationTests { partial class NativeExportsNE { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bytebool_return_as_uint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bytebool_return_as_uint")] public static partial uint ReturnByteBoolAsUInt([MarshalAs(UnmanagedType.U1)] bool input); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bytebool_return_as_uint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bytebool_return_as_uint")] public static partial uint ReturnSByteBoolAsUInt([MarshalAs(UnmanagedType.I1)] bool input); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "variantbool_return_as_uint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "variantbool_return_as_uint")] public static partial uint ReturnVariantBoolAsUInt([MarshalAs(UnmanagedType.VariantBool)] bool input); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_uint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_uint")] public static partial uint ReturnIntBoolAsUInt([MarshalAs(UnmanagedType.I4)] bool input); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_uint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_uint")] public static partial uint ReturnUIntBoolAsUInt([MarshalAs(UnmanagedType.U4)] bool input); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_uint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_uint")] public static partial uint ReturnWinBoolAsUInt([MarshalAs(UnmanagedType.Bool)] bool input); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_uint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_uint")] [return: MarshalAs(UnmanagedType.U1)] public static partial bool ReturnUIntAsByteBool(uint input); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_uint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_uint")] [return: MarshalAs(UnmanagedType.VariantBool)] public static partial bool ReturnUIntAsVariantBool(uint input); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_uint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_uint")] [return: MarshalAs(UnmanagedType.Bool)] public static partial bool ReturnUIntAsWinBool(uint input); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_refuint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_refuint")] public static partial void ReturnUIntAsRefByteBool(uint input, [MarshalAs(UnmanagedType.U1)] ref bool res); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_refuint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_refuint")] public static partial void ReturnUIntAsOutByteBool(uint input, [MarshalAs(UnmanagedType.U1)] out bool res); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_refuint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_refuint")] public static partial void ReturnUIntAsRefVariantBool(uint input, [MarshalAs(UnmanagedType.VariantBool)] ref bool res); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_refuint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_refuint")] public static partial void ReturnUIntAsOutVariantBool(uint input, [MarshalAs(UnmanagedType.VariantBool)] out bool res); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_refuint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_refuint")] public static partial void ReturnUIntAsRefWinBool(uint input, [MarshalAs(UnmanagedType.Bool)] ref bool res); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "bool_return_as_refuint")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bool_return_as_refuint")] public static partial void ReturnUIntAsOutWinBool(uint input, [MarshalAs(UnmanagedType.Bool)] out bool res); } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CharacterTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CharacterTests.cs index b8a547904c8..1ca56d1197a 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CharacterTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CharacterTests.cs @@ -7,23 +7,23 @@ namespace DllImportGenerator.IntegrationTests { partial class NativeExportsNE { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "unicode_return_as_uint", CharSet = CharSet.Unicode)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "unicode_return_as_uint", CharSet = CharSet.Unicode)] public static partial uint ReturnUnicodeAsUInt(char input); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "char_return_as_uint", CharSet = CharSet.Unicode)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_uint", CharSet = CharSet.Unicode)] public static partial char ReturnUIntAsUnicode(uint input); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "char_return_as_refuint", CharSet = CharSet.Unicode)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_refuint", CharSet = CharSet.Unicode)] public static partial void ReturnUIntAsRefUnicode(uint input, ref char res); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "char_return_as_refuint", CharSet = CharSet.Unicode)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_refuint", CharSet = CharSet.Unicode)] public static partial void ReturnUIntAsOutUnicode(uint input, out char res); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "char_return_as_uint", CharSet = CharSet.None)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_uint", CharSet = CharSet.None)] [return: MarshalAs(UnmanagedType.U2)] public static partial char ReturnU2AsU2IgnoreCharSet([MarshalAs(UnmanagedType.U2)] char input); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "char_return_as_uint", CharSet = CharSet.Ansi)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_uint", CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I2)] public static partial char ReturnI2AsI2IgnoreCharSet([MarshalAs(UnmanagedType.I2)] char input); } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/Constants.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/Constants.cs new file mode 100644 index 00000000000..8c5a2812d08 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/Constants.cs @@ -0,0 +1,7 @@ +namespace DllImportGenerator.IntegrationTests +{ + partial class NativeExportsNE + { + public const string NativeExportsNE_Binary = "Microsoft.Interop.Tests." + nameof(NativeExportsNE); + } +}
\ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CustomMarshallingTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CustomMarshallingTests.cs index 1dab47e72a2..a52aae7029e 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CustomMarshallingTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/CustomMarshallingTests.cs @@ -9,31 +9,31 @@ namespace DllImportGenerator.IntegrationTests { partial class NativeExportsNE { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "stringcontainer_deepduplicate")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "stringcontainer_deepduplicate")] public static partial void DeepDuplicateStrings(StringContainer strings, out StringContainer pStringsOut); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "stringcontainer_reverse_strings")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "stringcontainer_reverse_strings")] public static partial void ReverseStrings(ref StringContainer strings); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "get_long_bytes_as_double")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "get_long_bytes_as_double")] public static partial double GetLongBytesAsDouble([MarshalUsing(typeof(DoubleToLongMarshaler))] double d); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "negate_bools")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "negate_bools")] public static partial void NegateBools( BoolStruct boolStruct, out BoolStruct pBoolStructOut); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "and_bools_ref")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "and_bools_ref")] [return: MarshalAs(UnmanagedType.U1)] public static partial bool AndBoolsRef(in BoolStruct boolStruct); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "double_int_ref")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "double_int_ref")] public static partial IntWrapper DoubleIntRef(IntWrapper pInt); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "reverse_replace_ref_ushort")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "reverse_replace_ref_ushort")] public static partial void ReverseReplaceString([MarshalUsing(typeof(Utf16StringMarshaler))] ref string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "return_length_ushort")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "return_length_ushort")] public static partial int ReturnStringLength([MarshalUsing(typeof(Utf16StringMarshaler))] string s); } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DelegateTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DelegateTests.cs index 24ac17cec0d..72160892d97 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DelegateTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DelegateTests.cs @@ -8,12 +8,12 @@ namespace DllImportGenerator.IntegrationTests { public delegate void VoidVoid(); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "invoke_callback_after_gc")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_after_gc")] public static partial void InvokeAfterGC(VoidVoid cb); public delegate int IntIntInt(int a, int b); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "invoke_callback_blittable_args")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_blittable_args")] public static partial int InvokeWithBlittableArgument(IntIntInt cb, int a, int b); } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/EnumTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/EnumTests.cs index 1ad4397724c..d39b3805abc 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/EnumTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/EnumTests.cs @@ -9,31 +9,31 @@ namespace DllImportGenerator.IntegrationTests { public partial class IntEnum { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_return_int")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_return_int")] public static partial EnumTests.IntEnum Subtract_Return(EnumTests.IntEnum a, EnumTests.IntEnum b); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_out_int")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_out_int")] public static partial void Subtract_Out(EnumTests.IntEnum a, EnumTests.IntEnum b, out EnumTests.IntEnum c); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_ref_int")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_ref_int")] public static partial void Subtract_Ref(EnumTests.IntEnum a, ref EnumTests.IntEnum b); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_ref_int")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_ref_int")] public static partial void Subtract_In(EnumTests.IntEnum a, in EnumTests.IntEnum b); } public partial class ByteEnum { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_return_byte")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_return_byte")] public static partial EnumTests.ByteEnum Subtract_Return(EnumTests.ByteEnum a, EnumTests.ByteEnum b); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_out_byte")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_out_byte")] public static partial void Subtract_Out(EnumTests.ByteEnum a, EnumTests.ByteEnum b, out EnumTests.ByteEnum c); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_ref_byte")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_ref_byte")] public static partial void Subtract_Ref(EnumTests.ByteEnum a, ref EnumTests.ByteEnum b); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_ref_byte")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_ref_byte")] public static partial void Subtract_In(EnumTests.ByteEnum a, in EnumTests.ByteEnum b); } } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PointerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PointerTests.cs index 121ff0e254e..8a15c7ce36e 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PointerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PointerTests.cs @@ -8,13 +8,13 @@ namespace DllImportGenerator.IntegrationTests { partial class NativeExportsNE { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_ref_int")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_ref_int")] public static unsafe partial void Subtract_Int_Ptr(int a, int* b); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "subtract_ref_byte")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_ref_byte")] public static unsafe partial void Subtract_Byte_Ptr(byte a, byte* b); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "blittablestructs_double_intfields_byref")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_double_intfields_byref")] public static unsafe partial void DoubleIntFields_Ptr(IntFields* result); } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PreserveSigTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PreserveSigTests.cs index 2422192a9a3..079f1d17bb9 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PreserveSigTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/PreserveSigTests.cs @@ -11,54 +11,54 @@ namespace DllImportGenerator.IntegrationTests { public partial class False { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_return", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_return", PreserveSig = false)] public static partial void NoReturnValue(int i); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_int", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_int", PreserveSig = false)] public static partial void Int_Out(int i, out int ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_int", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_int", PreserveSig = false)] public static partial int Int_AsReturn(int i); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_int", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_int", PreserveSig = false)] public static partial void Bool_Out(int i, [MarshalAs(UnmanagedType.U4)] out bool ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_int", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_int", PreserveSig = false)] [return: MarshalAs(UnmanagedType.U4)] public static partial bool Bool_AsReturn(int i); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_ushort", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_ushort", PreserveSig = false)] public static partial void Char_Out(int i, [MarshalAs(UnmanagedType.U2)] out char ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_ushort", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_ushort", PreserveSig = false)] [return: MarshalAs(UnmanagedType.U2)] public static partial char Char_AsReturn(int i); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_ushort_string", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_ushort_string", PreserveSig = false)] public static partial void String_Out(int i, [MarshalAs(UnmanagedType.LPWStr)] out string ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_ushort_string", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_ushort_string", PreserveSig = false)] [return: MarshalAs(UnmanagedType.LPWStr)] public static partial string String_AsReturn(int i); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_int_array", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_int_array", PreserveSig = false)] public static partial void IntArray_Out(int i, [MarshalAs(UnmanagedType.LPArray, SizeConst = sizeof(int))] out int[] ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_int_array", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_int_array", PreserveSig = false)] [return: MarshalAs(UnmanagedType.LPArray, SizeConst = sizeof(int))] public static partial int[] IntArray_AsReturn(int i); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_ushort_string_array", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_ushort_string_array", PreserveSig = false)] public static partial void StringArray_Out(int i, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeConst = sizeof(int))] out string[] ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_ushort_string_array", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_ushort_string_array", PreserveSig = false)] [return: MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeConst = sizeof(int))] public static partial string[] StringArray_AsReturn(int i); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_handle", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_handle", PreserveSig = false)] public static partial void SafeHandle_Out(int hr, out DummySafeHandle ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_handle", PreserveSig = false)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_handle", PreserveSig = false)] public static partial DummySafeHandle SafeHandle_AsReturn(int hr); } @@ -71,10 +71,10 @@ namespace DllImportGenerator.IntegrationTests public partial class True { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_return", PreserveSig = true)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_return", PreserveSig = true)] public static partial int NoReturnValue(int i); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "hresult_out_int", PreserveSig = true)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "hresult_out_int", PreserveSig = true)] public static partial int Int_Out(int i, out int ret); } } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SafeHandleTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SafeHandleTests.cs index fc717100574..94903b34301 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SafeHandleTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SafeHandleTests.cs @@ -20,18 +20,18 @@ namespace DllImportGenerator.IntegrationTests } } - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "alloc_handle")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "alloc_handle")] public static partial NativeExportsSafeHandle AllocateHandle(); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "release_handle")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "release_handle")] [return:MarshalAs(UnmanagedType.I1)] private static partial bool ReleaseHandle(nint handle); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "is_handle_alive")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "is_handle_alive")] [return:MarshalAs(UnmanagedType.I1)] public static partial bool IsHandleAlive(NativeExportsSafeHandle handle); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "modify_handle")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "modify_handle")] public static partial void ModifyHandle(ref NativeExportsSafeHandle handle, [MarshalAs(UnmanagedType.I1)] bool newHandle); } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs index ba59f95803a..45407ce0222 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/SetLastErrorTests.cs @@ -27,14 +27,14 @@ namespace DllImportGenerator.IntegrationTests { public partial class SetLastError { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "set_error", SetLastError = true)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "set_error", SetLastError = true)] public static partial int SetError(int error, byte shouldSetError); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "set_error_return_string", SetLastError = true)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "set_error_return_string", SetLastError = true)] [return: MarshalUsing(typeof(SetLastErrorMarshaller))] public static partial int SetError_CustomMarshallingSetsError(int error, byte shouldSetError); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "set_error_return_string", SetLastError = true)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "set_error_return_string", SetLastError = true)] [return: MarshalAs(UnmanagedType.LPWStr)] public static partial string SetError_NonBlittableSignature(int error, [MarshalAs(UnmanagedType.U1)] bool shouldSetError, [MarshalAs(UnmanagedType.LPWStr)] string errorString); } diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/StringTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/StringTests.cs index e35bfd671e4..cb2b9cb6853 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/StringTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/StringTests.cs @@ -41,143 +41,143 @@ namespace DllImportGenerator.IntegrationTests public partial class Unicode { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReturnLength, CharSet = CharSet.Unicode)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength, CharSet = CharSet.Unicode)] public static partial int ReturnLength(string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseReturn, CharSet = CharSet.Unicode)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReturn, CharSet = CharSet.Unicode)] public static partial string Reverse_Return(string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseOut, CharSet = CharSet.Unicode)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseOut, CharSet = CharSet.Unicode)] public static partial void Reverse_Out(string s, out string ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Unicode)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Unicode)] public static partial void Reverse_Ref(ref string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Unicode)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Unicode)] public static partial void Reverse_In(in string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseReplace, CharSet = CharSet.Unicode)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReplace, CharSet = CharSet.Unicode)] public static partial void Reverse_Replace_Ref(ref string s); } public partial class LPTStr { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReturnLength)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength)] public static partial int ReturnLength([MarshalAs(UnmanagedType.LPTStr)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReturnLength, CharSet = CharSet.None)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength, CharSet = CharSet.None)] public static partial int ReturnLength_IgnoreCharSet([MarshalAs(UnmanagedType.LPTStr)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseReturn)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReturn)] [return: MarshalAs(UnmanagedType.LPTStr)] public static partial string Reverse_Return([MarshalAs(UnmanagedType.LPTStr)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseOut)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseOut)] public static partial void Reverse_Out([MarshalAs(UnmanagedType.LPTStr)] string s, [MarshalAs(UnmanagedType.LPTStr)] out string ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace)] public static partial void Reverse_Ref([MarshalAs(UnmanagedType.LPTStr)] ref string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace)] public static partial void Reverse_In([MarshalAs(UnmanagedType.LPTStr)] in string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace)] public static partial void Reverse_Replace_Ref([MarshalAs(UnmanagedType.LPTStr)] ref string s); } public partial class LPWStr { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReturnLength)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength)] public static partial int ReturnLength([MarshalAs(UnmanagedType.LPWStr)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReturnLength, CharSet = CharSet.None)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength, CharSet = CharSet.None)] public static partial int ReturnLength_IgnoreCharSet([MarshalAs(UnmanagedType.LPWStr)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseReturn)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReturn)] [return: MarshalAs(UnmanagedType.LPWStr)] public static partial string Reverse_Return([MarshalAs(UnmanagedType.LPWStr)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseOut)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseOut)] public static partial void Reverse_Out([MarshalAs(UnmanagedType.LPWStr)] string s, [MarshalAs(UnmanagedType.LPWStr)] out string ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace)] public static partial void Reverse_Ref([MarshalAs(UnmanagedType.LPWStr)] ref string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace)] public static partial void Reverse_In([MarshalAs(UnmanagedType.LPWStr)] in string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace)] public static partial void Reverse_Replace_Ref([MarshalAs(UnmanagedType.LPWStr)] ref string s); } public partial class LPUTF8Str { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReturnLength)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength)] public static partial int ReturnLength([MarshalAs(UnmanagedType.LPUTF8Str)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReturnLength, CharSet = CharSet.None)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength, CharSet = CharSet.None)] public static partial int ReturnLength_IgnoreCharSet([MarshalAs(UnmanagedType.LPUTF8Str)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseReturn)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseReturn)] [return: MarshalAs(UnmanagedType.LPUTF8Str)] public static partial string Reverse_Return([MarshalAs(UnmanagedType.LPUTF8Str)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseOut)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseOut)] public static partial void Reverse_Out([MarshalAs(UnmanagedType.LPUTF8Str)] string s, [MarshalAs(UnmanagedType.LPUTF8Str)] out string ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace)] public static partial void Reverse_In([MarshalAs(UnmanagedType.LPUTF8Str)] in string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace)] public static partial void Reverse_Ref([MarshalAs(UnmanagedType.LPUTF8Str)] ref string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace)] public static partial void Reverse_Replace_Ref([MarshalAs(UnmanagedType.LPUTF8Str)] ref string s); } public partial class Ansi { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReturnLength, CharSet = CharSet.Ansi)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength, CharSet = CharSet.Ansi)] public static partial int ReturnLength(string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseReturn, CharSet = CharSet.Ansi)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseReturn, CharSet = CharSet.Ansi)] public static partial string Reverse_Return(string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseOut, CharSet = CharSet.Ansi)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseOut, CharSet = CharSet.Ansi)] public static partial void Reverse_Out(string s, out string ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Ansi)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Ansi)] public static partial void Reverse_Ref(ref string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Ansi)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Ansi)] public static partial void Reverse_In(in string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Ansi)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Ansi)] public static partial void Reverse_Replace_Ref(ref string s); } public partial class LPStr { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReturnLength)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength)] public static partial int ReturnLength([MarshalAs(UnmanagedType.LPStr)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReturnLength, CharSet = CharSet.None)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength, CharSet = CharSet.None)] public static partial int ReturnLength_IgnoreCharSet([MarshalAs(UnmanagedType.LPStr)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseReturn)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseReturn)] [return: MarshalAs(UnmanagedType.LPStr)] public static partial string Reverse_Return([MarshalAs(UnmanagedType.LPStr)] string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseOut)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseOut)] public static partial void Reverse_Out([MarshalAs(UnmanagedType.LPStr)] string s, [MarshalAs(UnmanagedType.LPStr)] out string ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace)] public static partial void Reverse_Ref([MarshalAs(UnmanagedType.LPStr)] ref string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace)] public static partial void Reverse_In([MarshalAs(UnmanagedType.LPStr)] in string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace)] public static partial void Reverse_Replace_Ref([MarshalAs(UnmanagedType.LPStr)] ref string s); } @@ -185,43 +185,43 @@ namespace DllImportGenerator.IntegrationTests { public partial class Unix { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReturnLength, CharSet = CharSet.Auto)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength, CharSet = CharSet.Auto)] public static partial int ReturnLength(string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseReturn, CharSet = CharSet.Auto)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseReturn, CharSet = CharSet.Auto)] public static partial string Reverse_Return(string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseOut, CharSet = CharSet.Auto)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseOut, CharSet = CharSet.Auto)] public static partial void Reverse_Out(string s, out string ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Auto)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Auto)] public static partial void Reverse_Ref(ref string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Auto)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Auto)] public static partial void Reverse_In(in string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Auto)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, CharSet = CharSet.Auto)] public static partial void Reverse_Replace_Ref(ref string s); } public partial class Windows { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReturnLength, CharSet = CharSet.Auto)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength, CharSet = CharSet.Auto)] public static partial int ReturnLength(string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseReturn, CharSet = CharSet.Auto)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReturn, CharSet = CharSet.Auto)] public static partial string Reverse_Return(string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseOut, CharSet = CharSet.Auto)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseOut, CharSet = CharSet.Auto)] public static partial void Reverse_Out(string s, out string ret); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Auto)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Auto)] public static partial void Reverse_Ref(ref string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Auto)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Auto)] public static partial void Reverse_In(in string s); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Auto)] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace, CharSet = CharSet.Auto)] public static partial void Reverse_Replace_Ref(ref string s); } } diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj index 301246364e8..85da2e62d45 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj @@ -1,6 +1,7 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> + <AssemblyName>Microsoft.Interop.Tests.NativeExports</AssemblyName> <TargetFramework>net5.0</TargetFramework> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <EnableDynamicLoading>true</EnableDynamicLoading> diff --git a/src/samples/DllImportGeneratorSample/Program.cs b/src/samples/DllImportGeneratorSample/Program.cs index f0490390f6a..6e2f1defd97 100644 --- a/src/samples/DllImportGeneratorSample/Program.cs +++ b/src/samples/DllImportGeneratorSample/Program.cs @@ -5,13 +5,15 @@ namespace Demo { partial class NativeExportsNE { - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "sumi")] + public const string NativeExportsNE_Binary = "Microsoft.Interop.Tests." + nameof(NativeExportsNE); + + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sumi")] public static partial int Sum(int a, int b); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "sumouti")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sumouti")] public static partial void Sum(int a, int b, out int c); - [GeneratedDllImport(nameof(NativeExportsNE), EntryPoint = "sumrefi")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sumrefi")] public static partial void Sum(int a, ref int b); } |