diff options
author | Elinor Fung <elfung@microsoft.com> | 2022-03-10 05:07:52 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-10 05:07:52 +0300 |
commit | c2ec86b1c552ac8a1749f9f98e012f707e325660 (patch) | |
tree | fef23a383576f9a71ac11345d7259a6e0b05d9a5 /src/libraries/System.Runtime.InteropServices/tests | |
parent | b71eba8b3a74fa6282dc1526e68abbd26f3e385f (diff) |
Rename `GeneratedDllImportAttribute` -> `LibraryImportAttribute` (#66307)
Diffstat (limited to 'src/libraries/System.Runtime.InteropServices/tests')
26 files changed, 352 insertions, 352 deletions
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 054016b29c9..60e536023fb 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 @@ -11,7 +11,7 @@ </PropertyGroup> <ItemGroup> - <Compile Include="$(LibrariesProjectRoot)Common/src/System/Runtime/InteropServices/GeneratedDllImportAttribute.cs" Link="GeneratedDllImportAttribute.cs" /> + <Compile Include="$(LibrariesProjectRoot)Common/src/System/Runtime/InteropServices/LibraryImportAttribute.cs" Link="LibraryImportAttribute.cs" /> <Compile Include="$(LibrariesProjectRoot)Common/src/System/Runtime/InteropServices/GeneratedMarshallingAttribute.cs" Link="GeneratedMarshallingAttribute.cs" /> <Compile Include="$(LibrariesProjectRoot)Common/src/System/Runtime/InteropServices/ArrayMarshaller.cs" Link="ArrayMarshaller.cs" /> <Compile Include="$(LibrariesProjectRoot)Common/src/System/Runtime/InteropServices/StringMarshalling.cs" Link="StringMarshalling.cs" /> 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 5e24cae338c..8fd114021a4 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/ArrayTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/ArrayTests.cs @@ -16,66 +16,66 @@ namespace LibraryImportGenerator.IntegrationTests { public partial class Arrays { - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array")] public static partial int Sum(int[] values, int numValues); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array")] public static partial int Sum(ref int values, int numValues); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array_ref")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array_ref")] public static partial int SumInArray(in int[] values, int numValues); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "duplicate_int_array")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "duplicate_int_array")] public static partial void Duplicate([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] ref int[] values, int numValues); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "create_range_array")] + [LibraryImport(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(NativeExportsNE_Binary, EntryPoint = "create_range_array_out")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "create_range_array_out")] public static partial void CreateRange_Out(int start, int end, out int numValues, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] out int[] res); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_char_array", StringMarshalling = StringMarshalling.Utf16)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "sum_char_array", StringMarshalling = StringMarshalling.Utf16)] public static partial int SumChars(char[] chars, int numElements); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "fill_char_array", StringMarshalling = StringMarshalling.Utf16)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "fill_char_array", StringMarshalling = StringMarshalling.Utf16)] public static partial void FillChars([Out] char[] chars, int length, ushort start); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "reverse_char_array", StringMarshalling = StringMarshalling.Utf16)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "reverse_char_array", StringMarshalling = StringMarshalling.Utf16)] public static partial void ReverseChars([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] ref char[] chars, int numElements); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_string_lengths")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "sum_string_lengths")] public static partial int SumStringLengths([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr)] string[] strArray); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "reverse_strings_replace")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "reverse_strings_replace")] public static partial void ReverseStrings_Ref([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 1)] ref string[] strArray, out int numElements); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "reverse_strings_return")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "reverse_strings_return")] [return: MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 1)] public static partial string[] ReverseStrings_Return([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr)] string[] strArray, out int numElements); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "reverse_strings_out")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "reverse_strings_out")] public static partial void ReverseStrings_Out([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr)] string[] strArray, out int numElements, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 1)] out string[] res); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "get_long_bytes")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "get_long_bytes")] [return:MarshalAs(UnmanagedType.LPArray, SizeConst = sizeof(long))] public static partial byte[] GetLongBytes(long l); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "append_int_to_array")] + [LibraryImport(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); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "fill_range_array")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "fill_range_array")] [return: MarshalAs(UnmanagedType.U1)] public static partial bool FillRangeArray([Out] IntStructWrapper[] array, int length, int start); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "double_values")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "double_values")] public static partial void DoubleValues([In, Out] IntStructWrapper[] array, int length); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "and_all_members")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "and_all_members")] [return:MarshalAs(UnmanagedType.U1)] public static partial bool AndAllMembers(BoolStruct[] pArray, int length); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "transpose_matrix")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "transpose_matrix")] [return: MarshalUsing(CountElementName = "numColumns")] [return: MarshalUsing(CountElementName = "numRows", ElementIndirectionLevel = 1)] public static partial int[][] TransposeMatrix(int[][] matrix, int[] numRows, int numColumns); diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/BlittableStructTests.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/BlittableStructTests.cs index 1375901563e..f02379ddcab 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/BlittableStructTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/BlittableStructTests.cs @@ -11,32 +11,32 @@ namespace LibraryImportGenerator.IntegrationTests { partial class NativeExportsNE { - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_return_instance")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_return_instance")] public static partial IntFields DoubleIntFields(IntFields result); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_double_intfields_byref")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_double_intfields_byref")] public static partial void DoubleIntFieldsByRef(ref IntFields result); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_double_intfields_byref")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_double_intfields_byref")] public static partial void DoubleIntFieldsByRefIn(in IntFields result); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_double_intfields_refreturn")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_double_intfields_refreturn")] public static partial void DoubleIntFieldsRefReturn( IntFields input, ref IntFields result); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_double_intfields_refreturn")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_double_intfields_refreturn")] public static partial void DoubleIntFieldsOutReturn( IntFields input, out IntFields result); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_increment_invert_ptrfields_byref")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_increment_invert_ptrfields_byref")] public static partial void IncrementInvertPointerFieldsByRef(ref PointerFields result); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_increment_invert_ptrfields_byref")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_increment_invert_ptrfields_byref")] public static partial void IncrementInvertPointerFieldsByRefIn(in PointerFields result); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_increment_invert_ptrfields_refreturn")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_increment_invert_ptrfields_refreturn")] public static partial void IncrementInvertPointerFieldsRefReturn( PointerFields input, ref PointerFields result); diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/BooleanTests.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/BooleanTests.cs index 3b66fc69b8a..2f820824719 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/BooleanTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/BooleanTests.cs @@ -11,61 +11,61 @@ namespace LibraryImportGenerator.IntegrationTests { partial class NativeExportsNE { - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bytebool_return_as_uint")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "bytebool_return_as_uint")] public static partial uint ReturnByteBoolAsUInt([MarshalAs(UnmanagedType.U1)] bool input); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "bytebool_return_as_uint")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "bytebool_return_as_uint")] public static partial uint ReturnSByteBoolAsUInt([MarshalAs(UnmanagedType.I1)] bool input); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "variantbool_return_as_uint")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "variantbool_return_as_uint")] public static partial uint ReturnVariantBoolAsUInt([MarshalAs(UnmanagedType.VariantBool)] bool input); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_uint")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_uint")] public static partial uint ReturnIntBoolAsUInt([MarshalAs(UnmanagedType.I4)] bool input); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_uint")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_uint")] public static partial uint ReturnUIntBoolAsUInt([MarshalAs(UnmanagedType.U4)] bool input); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_uint")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_uint")] public static partial uint ReturnWinBoolAsUInt([MarshalAs(UnmanagedType.Bool)] bool input); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_uint")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_uint")] [return: MarshalAs(UnmanagedType.U1)] public static partial bool ReturnUIntAsByteBool(uint input); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_uint")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_uint")] [return: MarshalAs(UnmanagedType.VariantBool)] public static partial bool ReturnUIntAsVariantBool(uint input); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_uint")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_uint")] [return: MarshalAs(UnmanagedType.Bool)] public static partial bool ReturnUIntAsWinBool(uint input); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_refuint")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_refuint")] public static partial void ReturnUIntAsByteBool_Ref(uint input, [MarshalAs(UnmanagedType.U1)] ref bool res); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_refuint")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_refuint")] public static partial void ReturnUIntAsByteBool_Out(uint input, [MarshalAs(UnmanagedType.U1)] out bool res); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_refuint")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_refuint")] public static partial void ReturnUIntAsByteBool_In(uint input, [MarshalAs(UnmanagedType.U1)] in bool res); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_refuint")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_refuint")] public static partial void ReturnUIntAsVariantBool_Ref(uint input, [MarshalAs(UnmanagedType.VariantBool)] ref bool res); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_refuint")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_refuint")] public static partial void ReturnUIntAsVariantBool_Out(uint input, [MarshalAs(UnmanagedType.VariantBool)] out bool res); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_refuint")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_refuint")] public static partial void ReturnUIntAsVariantBool_In(uint input, [MarshalAs(UnmanagedType.VariantBool)] in bool res); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_refuint")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_refuint")] public static partial void ReturnUIntAsWinBool_Ref(uint input, [MarshalAs(UnmanagedType.Bool)] ref bool res); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_refuint")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_refuint")] public static partial void ReturnUIntAsWinBool_Out(uint input, [MarshalAs(UnmanagedType.Bool)] out bool res); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_refuint")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "winbool_return_as_refuint")] public static partial void ReturnUIntAsWinBool_In(uint input, [MarshalAs(UnmanagedType.Bool)] in bool res); } diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CallingConventionTests.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CallingConventionTests.cs index d58e6cc34ce..1452fef1656 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CallingConventionTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CallingConventionTests.cs @@ -16,10 +16,10 @@ namespace LibraryImportGenerator.IntegrationTests { internal partial class CallingConventions { - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "add_integers_cdecl")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "add_integers_cdecl")] [UnmanagedCallConv(CallConvs = new[] { typeof(CallConvCdecl) })] public static partial long AddLongsCdecl(long i, long j, long k, long l, long m, long n, long o, long p, long q); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "add_integers_stdcall")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "add_integers_stdcall")] [UnmanagedCallConv(CallConvs = new[] { typeof(CallConvStdcall) })] public static partial long AddLongsStdcall(long i, long j, long k, long l, long m, long n, long o, long p, long q); } diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CharacterTests.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CharacterTests.cs index f55902edba9..48dcdd175f5 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CharacterTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CharacterTests.cs @@ -12,30 +12,30 @@ namespace LibraryImportGenerator.IntegrationTests { partial class NativeExportsNE { - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "unicode_return_as_uint", StringMarshalling = StringMarshalling.Utf16)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "unicode_return_as_uint", StringMarshalling = StringMarshalling.Utf16)] public static partial uint ReturnUnicodeAsUInt(char input); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_uint", StringMarshalling = StringMarshalling.Utf16)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_uint", StringMarshalling = StringMarshalling.Utf16)] public static partial char ReturnUIntAsUnicode(uint input); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_refuint", StringMarshalling = StringMarshalling.Utf16)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_refuint", StringMarshalling = StringMarshalling.Utf16)] public static partial void ReturnUIntAsUnicode_Ref(uint input, ref char res); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_refuint", StringMarshalling = StringMarshalling.Utf16)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_refuint", StringMarshalling = StringMarshalling.Utf16)] public static partial void ReturnUIntAsUnicode_Out(uint input, out char res); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_refuint", StringMarshalling = StringMarshalling.Utf16)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_refuint", StringMarshalling = StringMarshalling.Utf16)] public static partial void ReturnUIntAsUnicode_In(uint input, in char res); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_uint", StringMarshalling = StringMarshalling.Utf8)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_uint", StringMarshalling = StringMarshalling.Utf8)] [return: MarshalAs(UnmanagedType.U2)] public static partial char ReturnU2AsU2IgnoreCharSet([MarshalAs(UnmanagedType.U2)] char input); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_uint", StringMarshalling = StringMarshalling.Utf8)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "char_return_as_uint", StringMarshalling = StringMarshalling.Utf8)] [return: MarshalAs(UnmanagedType.I2)] public static partial char ReturnI2AsI2IgnoreCharSet([MarshalAs(UnmanagedType.I2)] char input); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "char_reverse_buffer_ref", StringMarshalling = StringMarshalling.Utf16)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "char_reverse_buffer_ref", StringMarshalling = StringMarshalling.Utf16)] public static partial void ReverseBuffer(ref char buffer, int len); } 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 d33fad2b499..f8676d68e26 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CollectionTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CollectionTests.cs @@ -16,46 +16,46 @@ namespace LibraryImportGenerator.IntegrationTests { public partial class Collections { - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array")] public static partial int Sum([MarshalUsing(typeof(ListMarshaller<int>))] List<int> values, int numValues); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array")] public static partial int Sum(ref int values, int numValues); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array_ref")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array_ref")] public static partial int SumInArray([MarshalUsing(typeof(ListMarshaller<int>))] in List<int> values, int numValues); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "duplicate_int_array")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "duplicate_int_array")] public static partial void Duplicate([MarshalUsing(typeof(ListMarshaller<int>), CountElementName = "numValues")] ref List<int> values, int numValues); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "create_range_array")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "create_range_array")] [return:MarshalUsing(typeof(ListMarshaller<int>), CountElementName = "numValues")] public static partial List<int> CreateRange(int start, int end, out int numValues); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "create_range_array_out")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "create_range_array_out")] public static partial void CreateRange_Out(int start, int end, out int numValues, [MarshalUsing(typeof(ListMarshaller<int>), CountElementName = "numValues")] out List<int> res); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_string_lengths")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "sum_string_lengths")] public static partial int SumStringLengths([MarshalUsing(typeof(ListMarshaller<string>)), MarshalUsing(typeof(Utf16StringMarshaller), ElementIndirectionLevel = 1)] List<string> strArray); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "reverse_strings_replace")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "reverse_strings_replace")] public static partial void ReverseStrings_Ref([MarshalUsing(typeof(ListMarshaller<string>), CountElementName = "numElements"), MarshalUsing(typeof(Utf16StringMarshaller), ElementIndirectionLevel = 1)] ref List<string> strArray, out int numElements); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "reverse_strings_return")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "reverse_strings_return")] [return: MarshalUsing(typeof(ListMarshaller<string>), CountElementName = "numElements"), MarshalUsing(typeof(Utf16StringMarshaller), ElementIndirectionLevel = 1)] public static partial List<string> ReverseStrings_Return([MarshalUsing(typeof(ListMarshaller<string>), CountElementName = "numElements"), MarshalUsing(typeof(Utf16StringMarshaller), ElementIndirectionLevel = 1)] List<string> strArray, out int numElements); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "reverse_strings_out")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "reverse_strings_out")] public static partial void ReverseStrings_Out( [MarshalUsing(typeof(ListMarshaller<string>)), MarshalUsing(typeof(Utf16StringMarshaller), ElementIndirectionLevel = 1)] List<string> strArray, out int numElements, [MarshalUsing(typeof(ListMarshaller<string>), CountElementName = "numElements"), MarshalUsing(typeof(Utf16StringMarshaller), ElementIndirectionLevel = 1)] out List<string> res); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "get_long_bytes")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "get_long_bytes")] [return:MarshalUsing(typeof(ListMarshaller<byte>), ConstantElementCount = sizeof(long))] public static partial List<byte> GetLongBytes(long l); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "and_all_members")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "and_all_members")] [return:MarshalAs(UnmanagedType.U1)] public static partial bool AndAllMembers([MarshalUsing(typeof(ListMarshaller<BoolStruct>))] List<BoolStruct> pArray, int length); } 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 0477c6b08ac..f563b6ff5dd 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CustomMarshallingTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CustomMarshallingTests.cs @@ -12,31 +12,31 @@ namespace LibraryImportGenerator.IntegrationTests { partial class NativeExportsNE { - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "stringcontainer_deepduplicate")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "stringcontainer_deepduplicate")] public static partial void DeepDuplicateStrings(StringContainer strings, out StringContainer pStringsOut); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "stringcontainer_reverse_strings")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "stringcontainer_reverse_strings")] public static partial void ReverseStrings(ref StringContainer strings); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "get_long_bytes_as_double")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "get_long_bytes_as_double")] public static partial double GetLongBytesAsDouble([MarshalUsing(typeof(DoubleToLongMarshaler))] double d); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "negate_bools")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "negate_bools")] public static partial void NegateBools( BoolStruct boolStruct, out BoolStruct pBoolStructOut); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "and_bools_ref")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "and_bools_ref")] [return: MarshalAs(UnmanagedType.U1)] public static partial bool AndBoolsRef(in BoolStruct boolStruct); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "double_int_ref")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "double_int_ref")] public static partial IntWrapper DoubleIntRef(IntWrapper pInt); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "reverse_replace_ref_ushort")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "reverse_replace_ref_ushort")] public static partial void ReverseReplaceString([MarshalUsing(typeof(Utf16StringMarshaller))] ref string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "return_length_ushort")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "return_length_ushort")] public static partial int ReturnStringLength([MarshalUsing(typeof(Utf16StringMarshaller))] string s); } diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/DelegateTests.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/DelegateTests.cs index b7db86694f1..639c607b378 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/DelegateTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/DelegateTests.cs @@ -11,12 +11,12 @@ namespace LibraryImportGenerator.IntegrationTests { public delegate void VoidVoid(); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_after_gc")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_after_gc")] public static partial void InvokeAfterGC(VoidVoid cb); public delegate int IntIntInt(int a, int b); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_blittable_args")] + [LibraryImport(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/LibraryImportGenerator.Tests/EnumTests.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/EnumTests.cs index c5d06dd5ccf..14585b2ac61 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/EnumTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/EnumTests.cs @@ -12,31 +12,31 @@ namespace LibraryImportGenerator.IntegrationTests { public partial class IntEnum { - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_return_int")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "subtract_return_int")] public static partial EnumTests.IntEnum Subtract_Return(EnumTests.IntEnum a, EnumTests.IntEnum b); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_out_int")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "subtract_out_int")] public static partial void Subtract_Out(EnumTests.IntEnum a, EnumTests.IntEnum b, out EnumTests.IntEnum c); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_ref_int")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "subtract_ref_int")] public static partial void Subtract_Ref(EnumTests.IntEnum a, ref EnumTests.IntEnum b); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_ref_int")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "subtract_ref_int")] public static partial void Subtract_In(EnumTests.IntEnum a, in EnumTests.IntEnum b); } public partial class ByteEnum { - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_return_byte")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "subtract_return_byte")] public static partial EnumTests.ByteEnum Subtract_Return(EnumTests.ByteEnum a, EnumTests.ByteEnum b); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_out_byte")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "subtract_out_byte")] public static partial void Subtract_Out(EnumTests.ByteEnum a, EnumTests.ByteEnum b, out EnumTests.ByteEnum c); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_ref_byte")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "subtract_ref_byte")] public static partial void Subtract_Ref(EnumTests.ByteEnum a, ref EnumTests.ByteEnum b); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_ref_byte")] + [LibraryImport(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/LibraryImportGenerator.Tests/FunctionPointerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/FunctionPointerTests.cs index ce270b6e9cb..fde6b235ed4 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/FunctionPointerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/FunctionPointerTests.cs @@ -13,22 +13,22 @@ namespace LibraryImportGenerator.IntegrationTests { public partial class FunctionPointer { - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_managed_callback_after_gc")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "invoke_managed_callback_after_gc")] public static unsafe partial void InvokeAfterGC(delegate* <void> cb); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_after_gc")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_after_gc")] public static unsafe partial void InvokeAfterGC(delegate* unmanaged<void> cb); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_after_gc")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_after_gc")] public static unsafe partial void InvokeAfterGC(delegate* unmanaged[Stdcall]<void> cb); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_managed_callback_blittable_args")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "invoke_managed_callback_blittable_args")] public static unsafe partial int InvokeWithBlittableArgument(delegate* <int, int, int> cb, int a, int b); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_blittable_args")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_blittable_args")] public static unsafe partial int InvokeWithBlittableArgument(delegate* unmanaged<int, int, int> cb, int a, int b); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_blittable_args")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_blittable_args")] public static unsafe partial int InvokeWithBlittableArgument(delegate* unmanaged[Stdcall]<int, int, int> cb, int a, int b); } } diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/PointerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/PointerTests.cs index dd3cef0cea9..f1b68d8a17b 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/PointerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/PointerTests.cs @@ -11,13 +11,13 @@ namespace LibraryImportGenerator.IntegrationTests { partial class NativeExportsNE { - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_ref_int")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "subtract_ref_int")] public static unsafe partial void Subtract_Int_Ptr(int a, int* b); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "subtract_ref_byte")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "subtract_ref_byte")] public static unsafe partial void Subtract_Byte_Ptr(byte a, byte* b); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "blittablestructs_double_intfields_byref")] + [LibraryImport(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/LibraryImportGenerator.Tests/SafeHandleTests.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/SafeHandleTests.cs index 2e5b9af199c..1ae443c457e 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/SafeHandleTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/SafeHandleTests.cs @@ -25,25 +25,25 @@ namespace LibraryImportGenerator.IntegrationTests public static NativeExportsSafeHandle CreateNewHandle() => AllocateHandle(); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "alloc_handle")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "alloc_handle")] private static partial NativeExportsSafeHandle AllocateHandle(); } - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "alloc_handle")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "alloc_handle")] public static partial NativeExportsSafeHandle AllocateHandle(); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "alloc_handle_out")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "alloc_handle_out")] public static partial void AllocateHandle(out NativeExportsSafeHandle handle); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "release_handle")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "release_handle")] [return:MarshalAs(UnmanagedType.I1)] private static partial bool ReleaseHandle(nint handle); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "is_handle_alive")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "is_handle_alive")] [return:MarshalAs(UnmanagedType.I1)] public static partial bool IsHandleAlive(NativeExportsSafeHandle handle); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "modify_handle")] + [LibraryImport(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/LibraryImportGenerator.Tests/SetLastErrorTests.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/SetLastErrorTests.cs index 02db0381f7f..057bef953c7 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/SetLastErrorTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/SetLastErrorTests.cs @@ -29,14 +29,14 @@ namespace LibraryImportGenerator.IntegrationTests { public partial class SetLastError { - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "set_error", SetLastError = true)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "set_error", SetLastError = true)] public static partial int SetError(int error, byte shouldSetError); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "set_error", SetLastError = true)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "set_error", SetLastError = true)] [return: MarshalUsing(typeof(SetLastErrorMarshaller))] public static partial int SetError_CustomMarshallingSetsError(int error, byte shouldSetError); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "set_error_return_string", SetLastError = true)] + [LibraryImport(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/LibraryImportGenerator.Tests/SpanTests.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/SpanTests.cs index fc30ca2fea7..3b0a91cf26c 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/SpanTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/SpanTests.cs @@ -18,36 +18,36 @@ namespace LibraryImportGenerator.IntegrationTests { public partial class Span { - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array")] public static partial int Sum([MarshalUsing(typeof(SpanMarshaller<int>))] Span<int> values, int numValues); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array")] public static partial int SumNeverNull([MarshalUsing(typeof(NeverNullSpanMarshaller<int>))] Span<int> values, int numValues); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array")] public static partial int SumNeverNull([MarshalUsing(typeof(NeverNullReadOnlySpanMarshaller<int>))] ReadOnlySpan<int> values, int numValues); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array_ref")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "sum_int_array_ref")] public static partial int SumInArray([MarshalUsing(typeof(SpanMarshaller<int>))] in Span<int> values, int numValues); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "duplicate_int_array")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "duplicate_int_array")] public static partial void Duplicate([MarshalUsing(typeof(SpanMarshaller<int>), CountElementName = "numValues")] ref Span<int> values, int numValues); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "duplicate_int_array")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "duplicate_int_array")] public static partial void DuplicateRaw([MarshalUsing(typeof(DirectSpanMarshaller<int>), CountElementName = "numValues")] ref Span<int> values, int numValues); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "create_range_array")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "create_range_array")] [return: MarshalUsing(typeof(SpanMarshaller<int>), CountElementName = "numValues")] public static partial Span<int> CreateRange(int start, int end, out int numValues); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "create_range_array_out")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "create_range_array_out")] public static partial void CreateRange_Out(int start, int end, out int numValues, [MarshalUsing(typeof(SpanMarshaller<int>), CountElementName = "numValues")] out Span<int> res); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "get_long_bytes")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "get_long_bytes")] [return: MarshalUsing(typeof(SpanMarshaller<byte>), ConstantElementCount = sizeof(long))] public static partial Span<byte> GetLongBytes(long l); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "and_all_members")] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = "and_all_members")] [return: MarshalAs(UnmanagedType.U1)] public static partial bool AndAllMembers([MarshalUsing(typeof(SpanMarshaller<BoolStruct>))] Span<BoolStruct> pArray, int length); } 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 29d0922ff50..73ac84acdfa 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/StringTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/StringTests.cs @@ -44,143 +44,143 @@ namespace LibraryImportGenerator.IntegrationTests public partial class Utf16 { - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength, StringMarshalling = StringMarshalling.Utf16)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength, StringMarshalling = StringMarshalling.Utf16)] public static partial int ReturnLength(string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReturn, StringMarshalling = StringMarshalling.Utf16)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReturn, StringMarshalling = StringMarshalling.Utf16)] public static partial string Reverse_Return(string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseOut, StringMarshalling = StringMarshalling.Utf16)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseOut, StringMarshalling = StringMarshalling.Utf16)] public static partial void Reverse_Out(string s, out string ret); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace, StringMarshalling = StringMarshalling.Utf16)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace, StringMarshalling = StringMarshalling.Utf16)] public static partial void Reverse_Ref(ref string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace, StringMarshalling = StringMarshalling.Utf16)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace, StringMarshalling = StringMarshalling.Utf16)] public static partial void Reverse_In(in string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReplace, StringMarshalling = StringMarshalling.Utf16)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReplace, StringMarshalling = StringMarshalling.Utf16)] public static partial void Reverse_Replace_Ref(ref string s); } public partial class LPTStr { - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength)] public static partial int ReturnLength([MarshalAs(UnmanagedType.LPTStr)] string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength, StringMarshalling = StringMarshalling.Utf8)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength, StringMarshalling = StringMarshalling.Utf8)] public static partial int ReturnLength_IgnoreStringMarshalling([MarshalAs(UnmanagedType.LPTStr)] string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReturn)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReturn)] [return: MarshalAs(UnmanagedType.LPTStr)] public static partial string Reverse_Return([MarshalAs(UnmanagedType.LPTStr)] string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseOut)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseOut)] public static partial void Reverse_Out([MarshalAs(UnmanagedType.LPTStr)] string s, [MarshalAs(UnmanagedType.LPTStr)] out string ret); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace)] public static partial void Reverse_Ref([MarshalAs(UnmanagedType.LPTStr)] ref string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace)] public static partial void Reverse_In([MarshalAs(UnmanagedType.LPTStr)] in string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace)] public static partial void Reverse_Replace_Ref([MarshalAs(UnmanagedType.LPTStr)] ref string s); } public partial class LPWStr { - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength)] public static partial int ReturnLength([MarshalAs(UnmanagedType.LPWStr)] string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength, StringMarshalling = StringMarshalling.Utf8)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength, StringMarshalling = StringMarshalling.Utf8)] public static partial int ReturnLength_IgnoreStringMarshalling([MarshalAs(UnmanagedType.LPWStr)] string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReturn)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReturn)] [return: MarshalAs(UnmanagedType.LPWStr)] public static partial string Reverse_Return([MarshalAs(UnmanagedType.LPWStr)] string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseOut)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseOut)] public static partial void Reverse_Out([MarshalAs(UnmanagedType.LPWStr)] string s, [MarshalAs(UnmanagedType.LPWStr)] out string ret); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace)] public static partial void Reverse_Ref([MarshalAs(UnmanagedType.LPWStr)] ref string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace)] public static partial void Reverse_In([MarshalAs(UnmanagedType.LPWStr)] in string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace)] public static partial void Reverse_Replace_Ref([MarshalAs(UnmanagedType.LPWStr)] ref string s); } public partial class LPUTF8Str { - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength)] public static partial int ReturnLength([MarshalAs(UnmanagedType.LPUTF8Str)] string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength, StringMarshalling = StringMarshalling.Utf16)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength, StringMarshalling = StringMarshalling.Utf16)] public static partial int ReturnLength_IgnoreStringMarshalling([MarshalAs(UnmanagedType.LPUTF8Str)] string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseReturn)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseReturn)] [return: MarshalAs(UnmanagedType.LPUTF8Str)] public static partial string Reverse_Return([MarshalAs(UnmanagedType.LPUTF8Str)] string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseOut)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseOut)] public static partial void Reverse_Out([MarshalAs(UnmanagedType.LPUTF8Str)] string s, [MarshalAs(UnmanagedType.LPUTF8Str)] out string ret); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace)] public static partial void Reverse_In([MarshalAs(UnmanagedType.LPUTF8Str)] in string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace)] public static partial void Reverse_Ref([MarshalAs(UnmanagedType.LPUTF8Str)] ref string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace)] public static partial void Reverse_Replace_Ref([MarshalAs(UnmanagedType.LPUTF8Str)] ref string s); } public partial class Utf8 { - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength, StringMarshalling = StringMarshalling.Utf8)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength, StringMarshalling = StringMarshalling.Utf8)] public static partial int ReturnLength(string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseReturn, StringMarshalling = StringMarshalling.Utf8)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseReturn, StringMarshalling = StringMarshalling.Utf8)] public static partial string Reverse_Return(string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseOut, StringMarshalling = StringMarshalling.Utf8)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseOut, StringMarshalling = StringMarshalling.Utf8)] public static partial void Reverse_Out(string s, out string ret); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, StringMarshalling = StringMarshalling.Utf8)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, StringMarshalling = StringMarshalling.Utf8)] public static partial void Reverse_Ref(ref string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, StringMarshalling = StringMarshalling.Utf8)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, StringMarshalling = StringMarshalling.Utf8)] public static partial void Reverse_In(in string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, StringMarshalling = StringMarshalling.Utf8)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, StringMarshalling = StringMarshalling.Utf8)] public static partial void Reverse_Replace_Ref(ref string s); } public partial class LPStr { - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength)] public static partial int ReturnLength([MarshalAs(UnmanagedType.LPStr)] string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength, StringMarshalling = StringMarshalling.Utf16)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength, StringMarshalling = StringMarshalling.Utf16)] public static partial int ReturnLength_IgnoreStringMarshalling([MarshalAs(UnmanagedType.LPStr)] string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseReturn)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseReturn)] [return: MarshalAs(UnmanagedType.LPStr)] public static partial string Reverse_Return([MarshalAs(UnmanagedType.LPStr)] string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseOut)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseOut)] public static partial void Reverse_Out([MarshalAs(UnmanagedType.LPStr)] string s, [MarshalAs(UnmanagedType.LPStr)] out string ret); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace)] public static partial void Reverse_Ref([MarshalAs(UnmanagedType.LPStr)] ref string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace)] public static partial void Reverse_In([MarshalAs(UnmanagedType.LPStr)] in string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace)] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace)] public static partial void Reverse_Replace_Ref([MarshalAs(UnmanagedType.LPStr)] ref string s); } @@ -188,43 +188,43 @@ namespace LibraryImportGenerator.IntegrationTests { public partial class Utf16 { - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength, StringMarshallingCustomType = typeof(SharedTypes.Utf16StringMarshaller))] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReturnLength, StringMarshallingCustomType = typeof(SharedTypes.Utf16StringMarshaller))] public static partial int ReturnLength(string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReturn, StringMarshallingCustomType = typeof(SharedTypes.Utf16StringMarshaller))] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReturn, StringMarshallingCustomType = typeof(SharedTypes.Utf16StringMarshaller))] public static partial string Reverse_Return(string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseOut, StringMarshallingCustomType = typeof(SharedTypes.Utf16StringMarshaller))] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseOut, StringMarshallingCustomType = typeof(SharedTypes.Utf16StringMarshaller))] public static partial void Reverse_Out(string s, out string ret); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace, StringMarshallingCustomType = typeof(SharedTypes.Utf16StringMarshaller))] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace, StringMarshallingCustomType = typeof(SharedTypes.Utf16StringMarshaller))] public static partial void Reverse_Ref(ref string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace, StringMarshallingCustomType = typeof(SharedTypes.Utf16StringMarshaller))] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseInplace, StringMarshallingCustomType = typeof(SharedTypes.Utf16StringMarshaller))] public static partial void Reverse_In(in string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReplace, StringMarshallingCustomType = typeof(SharedTypes.Utf16StringMarshaller))] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.UShort.ReverseReplace, StringMarshallingCustomType = typeof(SharedTypes.Utf16StringMarshaller))] public static partial void Reverse_Replace_Ref(ref string s); } public partial class Utf8 { - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength, StringMarshallingCustomType = typeof(SharedTypes.Utf8StringMarshaller))] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReturnLength, StringMarshallingCustomType = typeof(SharedTypes.Utf8StringMarshaller))] public static partial int ReturnLength(string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseReturn, StringMarshallingCustomType = typeof(SharedTypes.Utf8StringMarshaller))] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseReturn, StringMarshallingCustomType = typeof(SharedTypes.Utf8StringMarshaller))] public static partial string Reverse_Return(string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseOut, StringMarshallingCustomType = typeof(SharedTypes.Utf8StringMarshaller))] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseOut, StringMarshallingCustomType = typeof(SharedTypes.Utf8StringMarshaller))] public static partial void Reverse_Out(string s, out string ret); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, StringMarshallingCustomType = typeof(SharedTypes.Utf8StringMarshaller))] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, StringMarshallingCustomType = typeof(SharedTypes.Utf8StringMarshaller))] public static partial void Reverse_Ref(ref string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, StringMarshallingCustomType = typeof(SharedTypes.Utf8StringMarshaller))] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseInplace, StringMarshallingCustomType = typeof(SharedTypes.Utf8StringMarshaller))] public static partial void Reverse_In(in string s); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseReplace, StringMarshallingCustomType = typeof(SharedTypes.Utf8StringMarshaller))] + [LibraryImport(NativeExportsNE_Binary, EntryPoint = EntryPoints.Byte.ReverseReplace, StringMarshallingCustomType = typeof(SharedTypes.Utf8StringMarshaller))] public static partial void Reverse_Replace_Ref(ref string s); } } 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 7894fbe70f7..748e160f35e 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/AdditionalAttributesOnStub.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/AdditionalAttributesOnStub.cs @@ -22,7 +22,7 @@ using System.Runtime.InteropServices; [assembly:DisableRuntimeMarshalling] partial class C { - [GeneratedDllImportAttribute(""DoesNotExist"")] + [LibraryImportAttribute(""DoesNotExist"")] public static partial S Method(); } @@ -52,7 +52,7 @@ struct Native using System.Runtime.InteropServices; partial class C { - [GeneratedDllImportAttribute(""DoesNotExist"")] + [LibraryImportAttribute(""DoesNotExist"")] public static partial void Method(); }"; Compilation comp = await TestUtils.CreateCompilation(source); @@ -73,7 +73,7 @@ using System.Runtime.InteropServices; [assembly:DisableRuntimeMarshalling] partial class C { - [GeneratedDllImportAttribute(""DoesNotExist"")] + [LibraryImportAttribute(""DoesNotExist"")] public static partial S Method(); } @@ -103,7 +103,7 @@ struct Native using System.Runtime.InteropServices; partial class C { - [GeneratedDllImportAttribute(""DoesNotExist"")] + [LibraryImportAttribute(""DoesNotExist"")] public static partial void Method(); }"; Compilation comp = await TestUtils.CreateCompilation(source); @@ -131,10 +131,10 @@ partial class C { string source = $@" using System.Runtime.InteropServices; -{CodeSnippets.GeneratedDllImportAttributeDeclaration} +{CodeSnippets.LibraryImportAttributeDeclaration} partial class C {{ - [GeneratedDllImportAttribute(""DoesNotExist"")] + [LibraryImportAttribute(""DoesNotExist"")] [return: MarshalAs(UnmanagedType.Bool)] public static partial bool Method(); }}"; @@ -163,7 +163,7 @@ using System.Runtime.CompilerServices; [module:SkipLocalsInit] partial class C { - [GeneratedDllImportAttribute(""DoesNotExist"")] + [LibraryImportAttribute(""DoesNotExist"")] public static partial S Method(); } @@ -195,7 +195,7 @@ using System.Runtime.CompilerServices; [SkipLocalsInit] partial class C { - [GeneratedDllImportAttribute(""DoesNotExist"")] + [LibraryImportAttribute(""DoesNotExist"")] public static partial S Method(); } @@ -227,7 +227,7 @@ using System.Runtime.CompilerServices; partial class C { [SkipLocalsInit] - [GeneratedDllImportAttribute(""DoesNotExist"")] + [LibraryImportAttribute(""DoesNotExist"")] public static partial S Method(); } 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 7a7c59a178a..3e24015cfe3 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/AttributeForwarding.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/AttributeForwarding.cs @@ -29,7 +29,7 @@ using System.Runtime.InteropServices; partial class C {{ [{attributeSourceName}] - [GeneratedDllImportAttribute(""DoesNotExist"")] + [LibraryImportAttribute(""DoesNotExist"")] public static partial S Method1(); }} @@ -70,7 +70,7 @@ using System.Runtime.InteropServices; partial class C { [UnmanagedCallConv(CallConvs = new Type[0])] - [GeneratedDllImportAttribute(""DoesNotExist"")] + [LibraryImportAttribute(""DoesNotExist"")] public static partial S Method1(); } @@ -113,7 +113,7 @@ using System.Runtime.InteropServices; partial class C { [UnmanagedCallConv(CallConvs = new[]{typeof(CallConvStdcall)})] - [GeneratedDllImportAttribute(""DoesNotExist"")] + [LibraryImportAttribute(""DoesNotExist"")] public static partial S Method1(); } @@ -160,7 +160,7 @@ using System.Runtime.InteropServices; partial class C { [UnmanagedCallConv(CallConvs = new[]{typeof(CallConvStdcall), typeof(CallConvSuppressGCTransition)})] - [GeneratedDllImportAttribute(""DoesNotExist"")] + [LibraryImportAttribute(""DoesNotExist"")] public static partial S Method1(); } @@ -211,7 +211,7 @@ using System.Runtime.InteropServices; partial class C {{ [DefaultDllImportSearchPaths(DllImportSearchPath.System32 | DllImportSearchPath.UserDirectories)] - [GeneratedDllImportAttribute(""DoesNotExist"")] + [LibraryImportAttribute(""DoesNotExist"")] public static partial S Method1(); }} @@ -259,7 +259,7 @@ class OtherAttribute : Attribute {} partial class C { [Other] - [GeneratedDllImportAttribute(""DoesNotExist"")] + [LibraryImportAttribute(""DoesNotExist"")] public static partial S Method1(); } @@ -298,11 +298,11 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; partial class C { - [GeneratedDllImportAttribute(""DoesNotExist"")] + [LibraryImportAttribute(""DoesNotExist"")] [return: MarshalAs(UnmanagedType.Bool)] public static partial bool Method1([In, Out] int[] a); } -" + CodeSnippets.GeneratedDllImportAttributeDeclaration; +" + CodeSnippets.LibraryImportAttributeDeclaration; Compilation origComp = await TestUtils.CreateCompilation(source, TestTargetFramework.Standard); Compilation newComp = TestUtils.RunGenerators(origComp, out _, new Microsoft.Interop.LibraryImportGenerator()); @@ -341,11 +341,11 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; partial class C { - [GeneratedDllImportAttribute(""DoesNotExist"")] + [LibraryImportAttribute(""DoesNotExist"")] [return: MarshalAs(UnmanagedType.Bool)] public static partial bool Method1([MarshalAs(UnmanagedType.I2)] int a); } -" + CodeSnippets.GeneratedDllImportAttributeDeclaration; +" + CodeSnippets.LibraryImportAttributeDeclaration; Compilation origComp = await TestUtils.CreateCompilation(source, TestTargetFramework.Standard); Compilation newComp = TestUtils.RunGenerators(origComp, out _, new Microsoft.Interop.LibraryImportGenerator()); @@ -370,11 +370,11 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; partial class C { - [GeneratedDllImportAttribute(""DoesNotExist"")] + [LibraryImportAttribute(""DoesNotExist"")] [return: MarshalAs(UnmanagedType.Bool)] public static partial bool Method1([MarshalAs(UnmanagedType.LPArray, SizeConst = 10, SizeParamIndex = 1, ArraySubType = UnmanagedType.I4)] int[] a, int b); } -" + CodeSnippets.GeneratedDllImportAttributeDeclaration; +" + CodeSnippets.LibraryImportAttributeDeclaration; Compilation origComp = await TestUtils.CreateCompilation(source, TestTargetFramework.Standard); Compilation newComp = TestUtils.RunGenerators(origComp, out _, new Microsoft.Interop.LibraryImportGenerator()); 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 a1be0baa469..93b822d6f7b 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CodeSnippets.cs @@ -8,9 +8,9 @@ namespace LibraryImportGenerator.UnitTests internal static class CodeSnippets { /// <summary> - /// Partially define attribute for pre-.NET 6.0 + /// Partially define attribute for pre-.NET 7.0 /// </summary> - public static readonly string GeneratedDllImportAttributeDeclaration = @" + public static readonly string LibraryImportAttributeDeclaration = @" namespace System.Runtime.InteropServices { internal enum StringMarshalling @@ -20,9 +20,9 @@ namespace System.Runtime.InteropServices Utf16, } - sealed class GeneratedDllImportAttribute : System.Attribute + sealed class LibraryImportAttribute : System.Attribute { - public GeneratedDllImportAttribute(string a) { } + public LibraryImportAttribute(string a) { } public StringMarshalling StringMarshalling { get; set; } public Type StringMarshallingCustomType { get; set; } } @@ -30,42 +30,42 @@ namespace System.Runtime.InteropServices "; /// <summary> - /// Trivial declaration of GeneratedDllImport usage + /// Trivial declaration of LibraryImport usage /// </summary> public static readonly string TrivialClassDeclarations = @" using System.Runtime.InteropServices; partial class Basic { - [GeneratedDllImportAttribute(""DoesNotExist"")] + [LibraryImportAttribute(""DoesNotExist"")] public static partial void Method1(); - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method2(); - [System.Runtime.InteropServices.GeneratedDllImportAttribute(""DoesNotExist"")] + [System.Runtime.InteropServices.LibraryImportAttribute(""DoesNotExist"")] public static partial void Method3(); - [System.Runtime.InteropServices.GeneratedDllImport(""DoesNotExist"")] + [System.Runtime.InteropServices.LibraryImport(""DoesNotExist"")] public static partial void Method4(); } "; /// <summary> - /// Trivial declaration of GeneratedDllImport usage + /// Trivial declaration of LibraryImport usage /// </summary> public static readonly string TrivialStructDeclarations = @" using System.Runtime.InteropServices; partial struct Basic { - [GeneratedDllImportAttribute(""DoesNotExist"")] + [LibraryImportAttribute(""DoesNotExist"")] public static partial void Method1(); - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method2(); - [System.Runtime.InteropServices.GeneratedDllImportAttribute(""DoesNotExist"")] + [System.Runtime.InteropServices.LibraryImportAttribute(""DoesNotExist"")] public static partial void Method3(); - [System.Runtime.InteropServices.GeneratedDllImport(""DoesNotExist"")] + [System.Runtime.InteropServices.LibraryImport(""DoesNotExist"")] public static partial void Method4(); } "; @@ -90,7 +90,7 @@ sealed class Dummy2Attribute : Attribute partial class Test { [DummyAttribute] - [GeneratedDllImport(""DoesNotExist""), Dummy2Attribute(""string value"")] + [LibraryImport(""DoesNotExist""), Dummy2Attribute(""string value"")] public static partial void Method(); } "; @@ -106,7 +106,7 @@ namespace NS { partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method1(); } } @@ -115,7 +115,7 @@ namespace NS.InnerNS { partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method2(); } } @@ -132,7 +132,7 @@ namespace NS { partial class InnerClass { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method(); } } @@ -140,7 +140,7 @@ namespace NS { partial struct InnerStruct { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method(); } } @@ -148,7 +148,7 @@ namespace NS { partial struct InnerStruct { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method(); } } @@ -156,7 +156,7 @@ namespace NS { partial class InnerClass { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method(); } } @@ -170,12 +170,12 @@ namespace NS using System.Runtime.InteropServices; partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method1(); } unsafe partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial int* Method2(); } "; @@ -186,19 +186,19 @@ unsafe partial class Test using System.Runtime.InteropServices; partial class Test { - [GeneratedDllImport(""DoesNotExist"", EntryPoint=""UserDefinedEntryPoint"")] + [LibraryImport(""DoesNotExist"", EntryPoint=""UserDefinedEntryPoint"")] public static partial void NotAnExport(); } "; /// <summary> - /// Declaration with all GeneratedDllImport named arguments. + /// Declaration with all LibraryImport named arguments. /// </summary> - public static readonly string AllGeneratedDllImportNamedArguments = @" + public static readonly string AllLibraryImportNamedArguments = @" using System.Runtime.InteropServices; partial class Test { - [GeneratedDllImport(""DoesNotExist"", + [LibraryImport(""DoesNotExist"", StringMarshalling = StringMarshalling.Utf16, EntryPoint = ""UserDefinedEntryPoint"", SetLastError = true)] @@ -219,19 +219,19 @@ partial class Test private const int One = 1; private const int Two = 2; - [GeneratedDllImport(nameof(Test), + [LibraryImport(nameof(Test), StringMarshalling = (StringMarshalling)2, EntryPoint = EntryPointName, SetLastError = IsFalse)] public static partial void Method1(); - [GeneratedDllImport(nameof(Test), + [LibraryImport(nameof(Test), StringMarshalling = (StringMarshalling)Two, EntryPoint = EntryPointName, SetLastError = !IsTrue)] public static partial void Method2(); - [GeneratedDllImport(nameof(Test), + [LibraryImport(nameof(Test), StringMarshalling = (StringMarshalling)2, EntryPoint = EntryPointName, SetLastError = 0 != 1)] @@ -246,7 +246,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method(int t = 0); } "; @@ -259,7 +259,7 @@ using System.Runtime.InteropServices; partial class Test { [LCIDConversion(0)] - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method(); } "; @@ -296,11 +296,11 @@ namespace NS partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(NS.MyCustomMarshaler), MarshalCookie=""COOKIE1"")] public static partial bool Method1([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(NS.MyCustomMarshaler), MarshalCookie=""COOKIE2"")]bool t); - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = ""NS.MyCustomMarshaler"", MarshalCookie=""COOKIE3"")] public static partial bool Method2([MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = ""NS.MyCustomMarshaler"", MarshalCookie=""COOKIE4"")]bool t); } @@ -316,21 +316,21 @@ using System.Runtime.InteropServices; namespace System.Runtime.InteropServices { // Prefix with ATTRIBUTE so the lengths will match during check. - sealed class ATTRIBUTEGeneratedDllImportAttribute : Attribute + sealed class ATTRIBUTELibraryImportAttribute : Attribute { - public ATTRIBUTEGeneratedDllImportAttribute(string a) { } + public ATTRIBUTELibraryImportAttribute(string a) { } } } partial class Test { - [ATTRIBUTEGeneratedDllImportAttribute(""DoesNotExist"")] + [ATTRIBUTELibraryImportAttribute(""DoesNotExist"")] public static partial void Method1(); - [ATTRIBUTEGeneratedDllImport(""DoesNotExist"")] + [ATTRIBUTELibraryImport(""DoesNotExist"")] public static partial void Method2(); - [System.Runtime.InteropServices.ATTRIBUTEGeneratedDllImport(""DoesNotExist"")] + [System.Runtime.InteropServices.ATTRIBUTELibraryImport(""DoesNotExist"")] public static partial void Method3(); } "; @@ -345,7 +345,7 @@ using System.Runtime.InteropServices; {preDeclaration} partial class Test {{ - [GeneratedDllImport(""DoesNotExist"", StringMarshalling = StringMarshalling.{value})] + [LibraryImport(""DoesNotExist"", StringMarshalling = StringMarshalling.{value})] public static partial {typename} Method( {typename} p, in {typename} pIn, @@ -365,7 +365,7 @@ using System.Runtime.InteropServices; {preDeclaration} partial class Test {{ - [GeneratedDllImport(""DoesNotExist"", StringMarshallingCustomType = typeof({stringMarshallingCustomTypeName}))] + [LibraryImport(""DoesNotExist"", StringMarshallingCustomType = typeof({stringMarshallingCustomTypeName}))] public static partial {typeName} Method( {typeName} p, in {typeName} pIn, @@ -397,7 +397,7 @@ using System.Runtime.InteropServices; {preDeclaration} partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial {typeName} Method( {typeName} p, in {typeName} pIn, @@ -413,7 +413,7 @@ using System.Runtime.InteropServices; {preDeclaration} partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial {typeName} Method( {typeName} p, in {typeName} pIn, @@ -428,7 +428,7 @@ using System.Runtime.InteropServices; {preDeclaration} partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static unsafe partial {typeName} Method( {typeName} p, in {typeName} pIn, @@ -446,7 +446,7 @@ using System.Runtime.InteropServices; {preDeclaration} partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method( [{attributeName}] {typeName} p); }}"; @@ -460,7 +460,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void {methodName}( int {paramName}); }}"; @@ -472,7 +472,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] [return: MarshalAs(UnmanagedType.{unmanagedType})] public static partial {typeName} Method( [MarshalAs(UnmanagedType.{unmanagedType})] {typeName} p, @@ -489,7 +489,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] [return: MarshalAs(UnmanagedType.{unmanagedType})] public static unsafe partial {typeName} Method( [MarshalAs(UnmanagedType.{unmanagedType})] {typeName} p, @@ -515,7 +515,7 @@ namespace NS partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial MyEnum Method( MyEnum p, in MyEnum pIn, @@ -535,7 +535,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ - [GeneratedDllImport(""DoesNotExist"", SetLastError = true)] + [LibraryImport(""DoesNotExist"", SetLastError = true)] public static partial {typeName} Method({typeName} p); }}"; @@ -569,7 +569,7 @@ using System.Runtime.InteropServices; {preDeclaration} partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] [return:MarshalAs(UnmanagedType.LPArray, SizeConst=10)] public static partial {elementType}[] Method( {elementType}[] p, @@ -588,7 +588,7 @@ using System.Runtime.InteropServices; {DisableRuntimeMarshalling} partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method( {(isByRef ? "ref" : "")} {sizeParamType} pRefSize, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)] ref int[] pRef @@ -603,7 +603,7 @@ using System.Runtime.InteropServices; {preDeclaration} partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method( [MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.{nestedMarshalInfo})] {elementType}[] pRef ); @@ -619,7 +619,7 @@ using System.Runtime.InteropServices; {preDeclaration} partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] [return: MarshalUsing(typeof({nativeTypeName}))] public static partial {typeName} Method( [MarshalUsing(typeof({nativeTypeName}))] {typeName} p, @@ -857,7 +857,7 @@ unsafe ref struct Native partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method( S s, in S sIn); @@ -889,7 +889,7 @@ using System.Runtime.InteropServices; {preDeclaration} partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method( {byRefKind} {typeName} p); }}"; @@ -899,7 +899,7 @@ using System.Runtime.InteropServices; {preDeclaration} partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method( {typeName} p); }}"; @@ -909,7 +909,7 @@ using System.Runtime.InteropServices; {preDeclaration} partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial {typeName} Method(); }}"; @@ -1019,7 +1019,7 @@ class MySafeHandle : SafeHandle partial class Test {{ #if {define} - [System.Runtime.InteropServices.GeneratedDllImport(""DoesNotExist"")] + [System.Runtime.InteropServices.LibraryImport(""DoesNotExist"")] public static partial int Method( int p, in int pIn, @@ -1033,7 +1033,7 @@ using System.Runtime.InteropServices; partial class Test {{ #if {define} - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial int Method( int p, in int pIn, @@ -1048,7 +1048,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] #if {define} public static partial int Method( int p, @@ -1067,7 +1067,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] #if {define} public static partial int Method( int p, @@ -1133,7 +1133,7 @@ using System.Runtime.InteropServices; {DisableRuntimeMarshalling} partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] [return:MarshalUsing(ConstantElementCount=10)] public static partial {collectionType} Method( {collectionType} p, @@ -1174,7 +1174,7 @@ using System.Runtime.InteropServices; {DisableRuntimeMarshalling} partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] [return:MarshalUsing(typeof({marshallerType}), ConstantElementCount=10)] public static partial {collectionType} Method( [MarshalUsing(typeof({marshallerType}))] {collectionType} p, @@ -1195,7 +1195,7 @@ using System.Runtime.InteropServices; {DisableRuntimeMarshalling} partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial int Method( [MarshalUsing(typeof({marshallerType}), CountElementName = MarshalUsingAttribute.ReturnsCountValue)] out {collectionType} pOut ); @@ -1210,7 +1210,7 @@ using System.Runtime.InteropServices; {DisableRuntimeMarshalling} partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method( {(isByRef ? "ref" : "")} {sizeParamType} pRefSize, [MarshalUsing(CountElementName = ""pRefSize"")] ref int[] pRef @@ -1224,7 +1224,7 @@ using System.Runtime.InteropServices; {DisableRuntimeMarshalling} partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method( int pRefSize, [MarshalUsing(ConstantElementCount = 10, CountElementName = ""pRefSize"")] ref int[] pRef @@ -1236,7 +1236,7 @@ using System.Runtime.InteropServices; {DisableRuntimeMarshalling} partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method( int pRefSize, [MarshalUsing(CountElementName = null)] ref int[] pRef @@ -1262,7 +1262,7 @@ using System.Runtime.InteropServices; [assembly:System.Runtime.CompilerServices.DisableRuntimeMarshalling] partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] [return:MarshalUsing(ConstantElementCount=10)] [return:MarshalUsing(typeof(IntWrapper), ElementIndirectionLevel = 1)] public static partial TestCollection<int> Method( @@ -1288,7 +1288,7 @@ using System.Runtime.InteropServices; [assembly:System.Runtime.CompilerServices.DisableRuntimeMarshalling] partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method( [MarshalUsing(typeof(IntWrapper), ElementIndirectionLevel = 1)] [MarshalUsing(typeof(IntWrapper), ElementIndirectionLevel = 1)] TestCollection<int> p); } @@ -1306,7 +1306,7 @@ using System.Runtime.InteropServices; [assembly:System.Runtime.CompilerServices.DisableRuntimeMarshalling] partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method( [MarshalUsing(typeof(IntWrapper), ElementIndirectionLevel = 2)] TestCollection<int> p); } @@ -1324,7 +1324,7 @@ using System.Runtime.InteropServices; [assembly:System.Runtime.CompilerServices.DisableRuntimeMarshalling] partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] [return:MarshalUsing(ConstantElementCount=10)] [return:MarshalAs(UnmanagedType.LPArray, SizeConst=10)] public static partial int[] Method(); @@ -1336,7 +1336,7 @@ using System.Runtime.InteropServices; [assembly:System.Runtime.CompilerServices.DisableRuntimeMarshalling] partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] [return:MarshalUsing(CountElementName=MarshalUsingAttribute.ReturnsCountValue)] public static partial int[] Method(); } @@ -1347,7 +1347,7 @@ using System.Runtime.InteropServices; [assembly:System.Runtime.CompilerServices.DisableRuntimeMarshalling] partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method( [MarshalUsing(CountElementName=""arr"")] ref int[] arr ); @@ -1358,7 +1358,7 @@ using System.Runtime.InteropServices; [assembly:System.Runtime.CompilerServices.DisableRuntimeMarshalling] partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method( [MarshalUsing(CountElementName=""arr2"")] ref int[] arr, [MarshalUsing(CountElementName=""arr"")] ref int[] arr2 @@ -1370,7 +1370,7 @@ using System.Runtime.InteropServices; [assembly:System.Runtime.CompilerServices.DisableRuntimeMarshalling] partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method( [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=1)] ref int[] arr, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)] ref int[] arr2 @@ -1383,7 +1383,7 @@ using System.Runtime.InteropServices; [assembly:System.Runtime.CompilerServices.DisableRuntimeMarshalling] partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method( [MarshalUsing(CountElementName=""arr0"", ElementIndirectionLevel = 0)] [MarshalUsing(CountElementName=""arr1"", ElementIndirectionLevel = 1)] @@ -1460,9 +1460,9 @@ partial class Test using System.Runtime.InteropServices; partial struct Basic {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial ref {typeName} RefReturn(); - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial ref readonly {typeName} RefReadonlyReturn(); }}"; @@ -1471,7 +1471,7 @@ using System.Runtime.InteropServices; partial struct Basic { - [GeneratedDllImport(""DoesNotExist"", SetLa)] + [LibraryImport(""DoesNotExist"", SetLa)] public static partial void Method(); } "; @@ -1480,7 +1480,7 @@ using System.Runtime.InteropServices; partial struct Basic { - [GeneratedDllImport(DoesNotExist)] + [LibraryImport(DoesNotExist)] public static partial void Method(); } "; @@ -1489,7 +1489,7 @@ using System.Runtime.InteropServices; partial struct Basic { - [GeneratedDllImport(""DoesNotExist"", SetLastError = ""Foo"")] + [LibraryImport(""DoesNotExist"", SetLastError = ""Foo"")] public static partial void Method(); } "; diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CompileFails.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CompileFails.cs index 686e4787b01..eb10a5217c9 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CompileFails.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CompileFails.cs @@ -17,7 +17,7 @@ namespace LibraryImportGenerator.UnitTests { public static IEnumerable<object[]> CodeSnippetsToCompile() { - // Not GeneratedDllImportAttribute + // Not LibraryImportAttribute yield return new object[] { CodeSnippets.UserDefinedPrefixedAttributes, 0, 3 }; // No explicit marshalling for char or string 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 0ce0de3f02a..9ee978e9817 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/Compiles.cs @@ -24,7 +24,7 @@ namespace LibraryImportGenerator.UnitTests yield return new[] { CodeSnippets.NestedTypes }; yield return new[] { CodeSnippets.UnsafeContext }; yield return new[] { CodeSnippets.UserDefinedEntryPoint }; - yield return new[] { CodeSnippets.AllGeneratedDllImportNamedArguments }; + yield return new[] { CodeSnippets.AllLibraryImportNamedArguments }; yield return new[] { CodeSnippets.DefaultParameters }; yield return new[] { CodeSnippets.UseCSharpFeaturesForConstants }; @@ -277,7 +277,7 @@ namespace LibraryImportGenerator.UnitTests // Confirm that all unsupported target frameworks can be generated. { - string code = CodeSnippets.BasicParametersAndModifiers<byte>(CodeSnippets.GeneratedDllImportAttributeDeclaration); + string code = CodeSnippets.BasicParametersAndModifiers<byte>(CodeSnippets.LibraryImportAttributeDeclaration); yield return new object[] { code, TestTargetFramework.Net5, false }; yield return new object[] { code, TestTargetFramework.Core, false }; yield return new object[] { code, TestTargetFramework.Standard, false }; @@ -286,7 +286,7 @@ namespace LibraryImportGenerator.UnitTests // Confirm that all unsupported target frameworks fallback to a forwarder. { - string code = CodeSnippets.BasicParametersAndModifiers<byte[]>(CodeSnippets.GeneratedDllImportAttributeDeclaration); + string code = CodeSnippets.BasicParametersAndModifiers<byte[]>(CodeSnippets.LibraryImportAttributeDeclaration); yield return new object[] { code, TestTargetFramework.Net5, true }; yield return new object[] { code, TestTargetFramework.Core, true }; yield return new object[] { code, TestTargetFramework.Standard, true }; @@ -295,7 +295,7 @@ namespace LibraryImportGenerator.UnitTests // Confirm that all unsupported target frameworks fallback to a forwarder. { - string code = CodeSnippets.BasicParametersAndModifiersWithStringMarshalling<string>(StringMarshalling.Utf16, CodeSnippets.GeneratedDllImportAttributeDeclaration); + string code = CodeSnippets.BasicParametersAndModifiersWithStringMarshalling<string>(StringMarshalling.Utf16, CodeSnippets.LibraryImportAttributeDeclaration); yield return new object[] { code, TestTargetFramework.Net5, true }; yield return new object[] { code, TestTargetFramework.Core, true }; yield return new object[] { code, TestTargetFramework.Standard, true }; @@ -369,7 +369,7 @@ namespace LibraryImportGenerator.UnitTests public static IEnumerable<object[]> SnippetsWithBlittableTypesButNonBlittableDataToCompile() { - yield return new[] { CodeSnippets.AllGeneratedDllImportNamedArguments }; + yield return new[] { CodeSnippets.AllLibraryImportNamedArguments }; yield return new[] { CodeSnippets.BasicParametersAndModifiers<int>() }; yield return new[] { CodeSnippets.SetLastErrorTrue<int>() }; } diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/ConvertToLibraryImportAnalyzerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/ConvertToLibraryImportAnalyzerTests.cs index 23c9db0c867..fca4e291241 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/ConvertToLibraryImportAnalyzerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/ConvertToLibraryImportAnalyzerTests.cs @@ -153,13 +153,13 @@ unsafe partial class Test } [ConditionalFact] - public async Task GeneratedDllImport_NoDiagnostic() + public async Task LibraryImport_NoDiagnostic() { string source = @$" using System.Runtime.InteropServices; partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method(); }} partial class Test diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/ConvertToLibraryImportFixerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/ConvertToLibraryImportFixerTests.cs index 8398378555f..da4793e8594 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/ConvertToLibraryImportFixerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/ConvertToLibraryImportFixerTests.cs @@ -34,7 +34,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial int {{|CS8795:Method|}}(out int ret); }}"; await VerifyCS.VerifyCodeFixAsync( @@ -64,11 +64,11 @@ using System.Runtime.InteropServices; partial class Test {{ // P/Invoke - [GeneratedDllImport(/*name*/""DoesNotExist"")] // comment + [LibraryImport(/*name*/""DoesNotExist"")] // comment public static partial int {{|CS8795:Method1|}}(out int ret); /** P/Invoke **/ - [GeneratedDllImport(""DoesNotExist"") /*name*/] + [LibraryImport(""DoesNotExist"") /*name*/] // < ... > public static partial int {{|CS8795:Method2|}}(out int ret); }}"; @@ -97,11 +97,11 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ - [System.ComponentModel.Description(""Test""), GeneratedDllImport(""DoesNotExist"")] + [System.ComponentModel.Description(""Test""), LibraryImport(""DoesNotExist"")] public static partial int {{|CS8795:Method1|}}(out int ret); [System.ComponentModel.Description(""Test"")] - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] [return: MarshalAs(UnmanagedType.I4)] public static partial int {{|CS8795:Method2|}}(out int ret); }}"; @@ -128,10 +128,10 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ - [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"")] + [LibraryImport(""DoesNotExist"", EntryPoint = ""Entry"")] public static partial int {{|CS8795:Method1|}}(out int ret); - [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"", StringMarshalling = StringMarshalling.Utf16)] + [LibraryImport(""DoesNotExist"", EntryPoint = ""Entry"", StringMarshalling = StringMarshalling.Utf16)] public static partial string {{|CS8795:Method2|}}(out int ret); }}"; await VerifyCS.VerifyCodeFixAsync( @@ -166,19 +166,19 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ - [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"")] + [LibraryImport(""DoesNotExist"", EntryPoint = ""Entry"")] public static partial int {{|CS8795:Method|}}(out int ret); - [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"")] + [LibraryImport(""DoesNotExist"", EntryPoint = ""Entry"")] public static partial int {{|CS8795:Method1|}}(out int ret); - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial int {{|CS8795:Method2|}}(out int ret); - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial int {{|CS8795:Method3|}}(out int ret); - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial int {{|CS8795:Method4|}}(out int ret); }}"; await VerifyCS.VerifyCodeFixAsync( @@ -201,7 +201,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ - [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"")] + [LibraryImport(""DoesNotExist"", EntryPoint = ""Entry"")] public static partial int {{|CS8795:Method1|}}(out int ret); }}"; await VerifyCS.VerifyCodeFixAsync( @@ -228,7 +228,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ - [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"")] + [LibraryImport(""DoesNotExist"", EntryPoint = ""Entry"")] [UnmanagedCallConv(CallConvs = new System.Type[] {{ typeof({callConvType.FullName}) }})] public static partial int {{|CS8795:Method1|}}(out int ret); }}"; @@ -252,7 +252,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ - [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)] + [LibraryImport(""DoesNotExist"", EntryPoint = ""Entry"", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)] public static partial string {{|CS8795:Method|}}(out int ret); }}"; await VerifyCS.VerifyCodeFixAsync( @@ -276,7 +276,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ - [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"")] + [LibraryImport(""DoesNotExist"", EntryPoint = ""Entry"")] public static partial void {{|CS8795:Method|}}(); }}"; await VerifyCS.VerifyCodeFixAsync(source, fixedSourceNoSuffix, ConvertToLibraryImportKey); @@ -284,7 +284,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ - [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry{suffix}"")] + [LibraryImport(""DoesNotExist"", EntryPoint = ""Entry{suffix}"")] public static partial void {{|CS8795:Method|}}(); }}"; await VerifyCS.VerifyCodeFixAsync(source, fixedSourceWithSuffix, $"{ConvertToLibraryImportKey}{suffix}"); @@ -304,7 +304,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ - [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"")] + [LibraryImport(""DoesNotExist"", EntryPoint = ""Entry"")] public static partial void {{|CS8795:Method|}}(); }}"; await VerifyCS.VerifyCodeFixAsync(source, fixedSourceNoSuffix, ConvertToLibraryImportKey); @@ -312,7 +312,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ - [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""EntryA"")] + [LibraryImport(""DoesNotExist"", EntryPoint = ""EntryA"")] public static partial void {{|CS8795:Method|}}(); }}"; await VerifyCS.VerifyCodeFixAsync(source, fixedSourceWithASuffix, $"{ConvertToLibraryImportKey}A"); @@ -320,7 +320,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ - [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""EntryW"")] + [LibraryImport(""DoesNotExist"", EntryPoint = ""EntryW"")] public static partial void {{|CS8795:Method|}}(); }}"; await VerifyCS.VerifyCodeFixAsync(source, fixedSourceWithWSuffix, $"{ConvertToLibraryImportKey}W"); @@ -340,7 +340,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ - [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""Entry"")] + [LibraryImport(""DoesNotExist"", EntryPoint = ""Entry"")] public static partial void {{|CS8795:Method|}}(); }}"; await VerifyCS.VerifyCodeFixAsync(source, fixedSourceNoSuffix, ConvertToLibraryImportKey); @@ -348,7 +348,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ - [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""EntryA"")] + [LibraryImport(""DoesNotExist"", EntryPoint = ""EntryA"")] public static partial void {{|CS8795:Method|}}(); }}"; await VerifyCS.VerifyCodeFixAsync(source, fixedSourceWithASuffix, $"{ConvertToLibraryImportKey}A"); @@ -370,7 +370,7 @@ using System.Runtime.InteropServices; partial class Test {{ private const string EntryPoint = ""Entry""; - [GeneratedDllImport(""DoesNotExist"", EntryPoint = EntryPoint + ""A"")] + [LibraryImport(""DoesNotExist"", EntryPoint = EntryPoint + ""A"")] public static partial void {{|CS8795:Method|}}(); }}"; await VerifyCS.VerifyCodeFixAsync(source, fixedSourceWithASuffix, $"{ConvertToLibraryImportKey}A"); @@ -390,7 +390,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ - [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""MethodA"")] + [LibraryImport(""DoesNotExist"", EntryPoint = ""MethodA"")] public static partial void {{|CS8795:Method|}}(); }}"; await VerifyCS.VerifyCodeFixAsync(source, fixedSourceWithASuffix, $"{ConvertToLibraryImportKey}A"); @@ -412,7 +412,7 @@ using System.Runtime.InteropServices; partial class Test {{ private const string Foo = ""Bar""; - [GeneratedDllImport(""DoesNotExist"", EntryPoint = nameof(Foo) + ""A"")] + [LibraryImport(""DoesNotExist"", EntryPoint = nameof(Foo) + ""A"")] public static partial void {{|CS8795:Method|}}(); }}"; await VerifyCS.VerifyCodeFixAsync(source, fixedSourceWithASuffix, $"{ConvertToLibraryImportKey}A"); @@ -432,7 +432,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ - [GeneratedDllImport(""DoesNotExist"", EntryPoint = ""MethodA"")] + [LibraryImport(""DoesNotExist"", EntryPoint = ""MethodA"")] public static partial void {{|CS8795:Method|}}(); }}"; await VerifyCS.VerifyCodeFixAsync(source, fixedSourceWithASuffix, $"{ConvertToLibraryImportKey}A"); @@ -463,9 +463,9 @@ partial class Test using System.Runtime.InteropServices; partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial int {|CS8795:VoidMethod|}(int param); - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial int {|CS8795:Method|}(int param, out long @return); public static void Code() @@ -519,11 +519,11 @@ partial class Enclosing { partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial int {|CS8795:Method|}(out int ret); - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial int {|CS8795:Method2|}(out int ret); - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial int {|CS8795:Method3|}(out int ret); } } @@ -531,11 +531,11 @@ partial class EnclosingPartial { partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial int {|CS8795:Method|}(out int ret); - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial int {|CS8795:Method2|}(out int ret); - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial int {|CS8795:Method3|}(out int ret); } }"; @@ -559,7 +559,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] [return: MarshalAs(UnmanagedType.Bool)] public static partial bool {{|CS8795:Method|}}([MarshalAs(UnmanagedType.Bool)] bool b); }}"; diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/Diagnostics.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/Diagnostics.cs index 56ad8895a66..1c7a492b775 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/Diagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/Diagnostics.cs @@ -25,10 +25,10 @@ namespace LibraryImportGenerator.UnitTests { string source = $@" using System.Runtime.InteropServices; -{CodeSnippets.GeneratedDllImportAttributeDeclaration} +{CodeSnippets.LibraryImportAttributeDeclaration} partial class Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method(); }} "; @@ -47,7 +47,7 @@ partial class Test [InlineData(TestTargetFramework.Core)] [InlineData(TestTargetFramework.Standard)] [InlineData(TestTargetFramework.Net5)] - public async Task TargetFrameworkNotSupported_NoGeneratedDllImport_NoDiagnostic(TestTargetFramework targetFramework) + public async Task TargetFrameworkNotSupported_NoLibraryImport_NoDiagnostic(TestTargetFramework targetFramework) { string source = @" using System.Runtime.InteropServices; @@ -79,10 +79,10 @@ namespace NS } partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method1(NS.MyClass c); - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method2(int i, List<int> list); } "; @@ -117,10 +117,10 @@ namespace NS } partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial NS.MyClass Method1(); - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial List<int> Method2(); } "; @@ -150,7 +150,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method(char c, string s); } "; @@ -178,10 +178,10 @@ partial class Test using System.Runtime.InteropServices; partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial char Method1(); - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial string Method2(); } "; @@ -209,10 +209,10 @@ partial class Test using System.Runtime.InteropServices; partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method1([MarshalAs(UnmanagedType.BStr)] int i1, int i2); - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method2(int i1, [MarshalAs(UnmanagedType.FunctionPtr)] bool b2); } "; @@ -242,11 +242,11 @@ partial class Test using System.Runtime.InteropServices; partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] [return: MarshalAs(UnmanagedType.BStr)] public static partial int Method1(int i); - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] [return: MarshalAs(UnmanagedType.FunctionPtr)] public static partial bool Method2(int i); } @@ -277,11 +277,11 @@ partial class Test using System.Runtime.InteropServices; partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] [return: MarshalAs(1)] public static partial int Method1(int i); - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial int Method2([MarshalAs((short)0)] bool b); } "; @@ -317,11 +317,11 @@ partial class Test using System.Runtime.InteropServices; partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] [return: MarshalAs(UnmanagedType.I4, SafeArraySubType=VarEnum.VT_I4)] public static partial int Method1(int i); - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial int Method2([MarshalAs(UnmanagedType.I1, IidParameterIndex = 1)] bool b); } "; @@ -350,10 +350,10 @@ partial class Test using System.Runtime.InteropServices; partial class Test { - [GeneratedDllImport(""DoesNotExist"", StringMarshalling = StringMarshalling.Utf8)] + [LibraryImport(""DoesNotExist"", StringMarshalling = StringMarshalling.Utf8)] public static partial void Method1(string s); - [GeneratedDllImport(""DoesNotExist"", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(Native))] + [LibraryImport(""DoesNotExist"", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(Native))] public static partial void Method2(string s); struct Native @@ -362,7 +362,7 @@ partial class Test public string ToManaged() => default; } } -" + CodeSnippets.GeneratedDllImportAttributeDeclaration; +" + CodeSnippets.LibraryImportAttributeDeclaration; // Compile against Standard so that we generate forwarders Compilation comp = await TestUtils.CreateCompilation(source, TestTargetFramework.Standard); @@ -373,13 +373,13 @@ partial class Test { (new DiagnosticResult(GeneratorDiagnostics.CannotForwardToDllImport)) .WithSpan(6, 32, 6, 39) - .WithArguments($"{nameof(TypeNames.GeneratedDllImportAttribute)}{Type.Delimiter}{nameof(StringMarshalling)}={nameof(StringMarshalling)}{Type.Delimiter}{nameof(StringMarshalling.Utf8)}"), + .WithArguments($"{nameof(TypeNames.LibraryImportAttribute)}{Type.Delimiter}{nameof(StringMarshalling)}={nameof(StringMarshalling)}{Type.Delimiter}{nameof(StringMarshalling.Utf8)}"), (new DiagnosticResult(GeneratorDiagnostics.CannotForwardToDllImport)) .WithSpan(9, 32, 9, 39) - .WithArguments($"{nameof(TypeNames.GeneratedDllImportAttribute)}{Type.Delimiter}{nameof(StringMarshalling)}={nameof(StringMarshalling)}{Type.Delimiter}{nameof(StringMarshalling.Custom)}"), + .WithArguments($"{nameof(TypeNames.LibraryImportAttribute)}{Type.Delimiter}{nameof(StringMarshalling)}={nameof(StringMarshalling)}{Type.Delimiter}{nameof(StringMarshalling.Custom)}"), (new DiagnosticResult(GeneratorDiagnostics.CannotForwardToDllImport)) .WithSpan(9, 32, 9, 39) - .WithArguments($"{nameof(TypeNames.GeneratedDllImportAttribute)}{Type.Delimiter}{nameof(GeneratedDllImportAttribute.StringMarshallingCustomType)}", $"{nameof(StringMarshalling)}{Type.Delimiter}{nameof(StringMarshalling.Custom)}"), + .WithArguments($"{nameof(TypeNames.LibraryImportAttribute)}{Type.Delimiter}{nameof(LibraryImportAttribute.StringMarshallingCustomType)}", $"{nameof(StringMarshalling)}{Type.Delimiter}{nameof(StringMarshalling.Custom)}"), (new DiagnosticResult(GeneratorDiagnostics.ParameterTypeNotSupportedWithDetails)) .WithSpan(9, 47, 9, 48) }; @@ -396,10 +396,10 @@ using System.Runtime.InteropServices; {CodeSnippets.DisableRuntimeMarshalling} partial class Test {{ - [GeneratedDllImport(""DoesNotExist"", StringMarshalling = StringMarshalling.Custom)] + [LibraryImport(""DoesNotExist"", StringMarshalling = StringMarshalling.Custom)] public static partial void Method1(out int i); - [GeneratedDllImport(""DoesNotExist"", StringMarshalling = StringMarshalling.Utf8, StringMarshallingCustomType = typeof(Native))] + [LibraryImport(""DoesNotExist"", StringMarshalling = StringMarshalling.Utf8, StringMarshallingCustomType = typeof(Native))] public static partial void Method2(out int i); struct Native @@ -417,9 +417,9 @@ partial class Test DiagnosticResult[] expectedDiags = new DiagnosticResult[] { (new DiagnosticResult(GeneratorDiagnostics.InvalidStringMarshallingConfiguration)) - .WithSpan(6, 6, 6, 86), + .WithSpan(6, 6, 6, 81), (new DiagnosticResult(GeneratorDiagnostics.InvalidStringMarshallingConfiguration)) - .WithSpan(9, 6, 9, 130) + .WithSpan(9, 6, 9, 125) }; VerifyDiagnostics(expectedDiags, GetSortedDiagnostics(generatorDiags)); var newCompDiags = newComp.GetDiagnostics(); @@ -433,10 +433,10 @@ partial class Test using System.Runtime.InteropServices; partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static void Method() { } - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static extern void ExternMethod(); } "; @@ -465,7 +465,7 @@ partial class Test using System.Runtime.InteropServices; partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public partial void Method(); } "; @@ -492,10 +492,10 @@ partial class Test using System.Runtime.InteropServices; partial class Test { - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method1<T>(); - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method2<T, U>(); } "; @@ -528,7 +528,7 @@ partial class Test using System.Runtime.InteropServices; {typeKind} Test {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] public static partial void Method(); }} "; @@ -563,7 +563,7 @@ using System.Runtime.InteropServices; {{ partial class TestInner {{ - [GeneratedDllImport(""DoesNotExist"")] + [LibraryImport(""DoesNotExist"")] static partial void Method(); }} }} diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/IncrementalGenerationTests.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/IncrementalGenerationTests.cs index a5a70734dee..688b24beb3d 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/IncrementalGenerationTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/IncrementalGenerationTests.cs @@ -76,7 +76,7 @@ namespace LibraryImportGenerator.UnitTests } [ConditionalFact] - public async Task AddingFileWithNewGeneratedDllImport_DoesNotRegenerateOriginalMethod() + public async Task AddingFileWithNewLibraryImport_DoesNotRegenerateOriginalMethod() { string source = CodeSnippets.BasicParametersAndModifiers<int>(); @@ -106,7 +106,7 @@ namespace LibraryImportGenerator.UnitTests } [ConditionalFact] - public async Task ReplacingFileWithNewGeneratedDllImport_DoesNotRegenerateStubsInOtherFiles() + public async Task ReplacingFileWithNewLibraryImport_DoesNotRegenerateStubsInOtherFiles() { Compilation comp1 = await TestUtils.CreateCompilation(new string[] { CodeSnippets.BasicParametersAndModifiers<int>(), CodeSnippets.BasicParametersAndModifiers<bool>() }); diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/TestUtils.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/TestUtils.cs index 1864d2ed66f..cabfb327be4 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/TestUtils.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/TestUtils.cs @@ -75,8 +75,8 @@ namespace LibraryImportGenerator.UnitTests var allowedDiagnostics = new HashSet<string>() { "CS8795", // Partial method impl missing - "CS0234", // Missing type or namespace - GeneratedDllImportAttribute - "CS0246", // Missing type or namespace - GeneratedDllImportAttribute + "CS0234", // Missing type or namespace - LibraryImportAttribute + "CS0246", // Missing type or namespace - LibraryImportAttribute "CS8019", // Unnecessary using }; @@ -183,7 +183,7 @@ namespace LibraryImportGenerator.UnitTests { // Include the assembly containing the new attribute and all of its references. // [TODO] Remove once the attribute has been added to the BCL - var attrAssem = typeof(GeneratedDllImportAttribute).GetTypeInfo().Assembly; + var attrAssem = typeof(LibraryImportAttribute).GetTypeInfo().Assembly; return MetadataReference.CreateFromFile(attrAssem.Location); } |