diff --git a/eng/Versions.props b/eng/Versions.props index bee17626e1f47f..b7e09d4ad6e62f 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -144,7 +144,7 @@ 1.0.0-beta-build0015 1.0.4-preview6.19326.1 0.2.61701 - 1.0.23 + 1.0.26 $(NetCoreAppCurrent)-Unix diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj b/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj index 718551f9b65d55..29bbd6f8f083e9 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj @@ -7,6 +7,7 @@ true true $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-OSX + true diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/AssemblyInfo.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/AssemblyInfo.cs new file mode 100644 index 00000000000000..f95036d8de482b --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/AssemblyInfo.cs @@ -0,0 +1,10 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Xunit; + +// We build the libraries tests in CI once per target OS+Arch+Configuration, but we share it between runtime test runs. +// As a result, we need to exclude the Mono run here since we build the tests once for CoreCLR and Mono for desktop test runs. +// We should switch this to another mechanism in the future so we don't submit a work item of this assembly that skips every test +// for Mono-on-Desktop-Platforms test runs. +[assembly:ActiveIssue("https://github.com/dotnet/runtime/issues/59815", TestRuntimes.Mono)] diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj index 887a041b0e0618..351241b66278d6 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/DllImportGenerator.Tests.csproj @@ -1,6 +1,6 @@  - $(NetCoreAppCurrent) + $(NetCoreAppCurrent) false Preview true diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/FunctionPointerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/FunctionPointerTests.cs index f083c24f4131f0..87332f16e2d67b 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/FunctionPointerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.Tests/FunctionPointerTests.cs @@ -13,7 +13,7 @@ partial class NativeExportsNE { public partial class FunctionPointer { - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_after_gc")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_managed_callback_after_gc")] public static unsafe partial void InvokeAfterGC(delegate* cb); [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_after_gc")] @@ -22,7 +22,7 @@ public partial class FunctionPointer [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_after_gc")] public static unsafe partial void InvokeAfterGC(delegate* unmanaged[Stdcall] cb); - [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_blittable_args")] + [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_managed_callback_blittable_args")] public static unsafe partial int InvokeWithBlittableArgument(delegate* cb, int a, int b); [GeneratedDllImport(NativeExportsNE_Binary, EntryPoint = "invoke_callback_blittable_args")] diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj index 89b2d192140cec..6186cea54a53be 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.UnitTests.csproj @@ -1,7 +1,7 @@  - $(NetCoreAppCurrent) + $(NetCoreAppCurrent) false Preview enable diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/DelegatesAndFunctionPointers.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/DelegatesAndFunctionPointers.cs index 50abe95c3a3810..8925bcd038f2b9 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/DelegatesAndFunctionPointers.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/DelegatesAndFunctionPointers.cs @@ -23,10 +23,31 @@ public static void InvokeCallbackAfterGCCollect(delegate* unmanaged fptr) fptr(); } + [UnmanagedCallersOnly(EntryPoint = "invoke_managed_callback_after_gc")] + public static void InvokeManagedCallbackAfterGCCollect(void* fptr) + { + // We are at the mercy of the GC to verify our delegate has been retain + // across the native function call. This is a best effort validation. + for (int i = 0; i < 5; ++i) + { + GC.Collect(); + GC.WaitForPendingFinalizers(); + } + + // If the corresponding Delegate was collected, the runtime will rudely abort. + ((delegate*)fptr)(); + } + [UnmanagedCallersOnly(EntryPoint = "invoke_callback_blittable_args")] public static int InvokeCallbackWithBlittableArgument(delegate* unmanaged fptr, int a, int b) { return fptr(a, b); } + + [UnmanagedCallersOnly(EntryPoint = "invoke_managed_callback_blittable_args")] + public static int InvokeManagedCallbackWithBlittableArgument(void* fptr, int a, int b) + { + return ((delegate*)fptr)(a, b); + } } } diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj index 00a8f53fd133bd..c93a8ac56d9e0d 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj @@ -7,6 +7,9 @@ true true Major + + $(OutputRid) + $(OutputRid) @@ -17,4 +20,97 @@ + + + $(Compiler) + clang + + + + + + + + + + + + + + + + + + + + + --target=$(TargetTriple) --gcc-toolchain=$(ROOTFS_DIR)/usr --sysroot=$(ROOTFS_DIR) + $(CommonToolchainArgs) $(DnneLinkerUserFlags.Replace(';',' ')) + $(CommonToolchainArgs) $(DnneCompilerUserFlags.Replace(';',' ')) + + + + + + arm64-apple-ios14.2-macabi + x86_64-apple-ios13.5-macabi + + + arm64-apple-macos11 + x86_64-apple-macos10.13 + macosx + + + + + + + + + + + + + + + + -target $(TargetTriple) + -isysroot "$(SysRootIncludePath)" -target $(TargetTriple) + + + + + + $([System.IO.Path]::GetDirectoryName('$(AppHostSourcePath)')) + + diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index aefca41a35b6b5..05d56f00feedd8 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -32,6 +32,21 @@ + + + + + + + + + + + + + + + diff --git a/src/samples/Directory.Build.props b/src/samples/Directory.Build.props new file mode 100644 index 00000000000000..4590be123eb7f9 --- /dev/null +++ b/src/samples/Directory.Build.props @@ -0,0 +1,8 @@ + + + + + true + true + + diff --git a/src/samples/Directory.Build.targets b/src/samples/Directory.Build.targets new file mode 100644 index 00000000000000..74fb272013ea8d --- /dev/null +++ b/src/samples/Directory.Build.targets @@ -0,0 +1,5 @@ + + + + + diff --git a/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj b/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj index f42621f44c254b..32bd062dfe8c7e 100644 --- a/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj +++ b/src/samples/DllImportGeneratorSample/DllImportGeneratorSample.csproj @@ -16,6 +16,7 @@ + diff --git a/src/samples/DllImportGeneratorSample/Program.cs b/src/samples/DllImportGeneratorSample/Program.cs index 6e2f1defd97c7e..4a1c8335bf4180 100644 --- a/src/samples/DllImportGeneratorSample/Program.cs +++ b/src/samples/DllImportGeneratorSample/Program.cs @@ -1,9 +1,12 @@ -using System; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; using System.Runtime.InteropServices; namespace Demo { - partial class NativeExportsNE + internal static partial class NativeExportsNE { public const string NativeExportsNE_Binary = "Microsoft.Interop.Tests." + nameof(NativeExportsNE); @@ -17,9 +20,9 @@ partial class NativeExportsNE public static partial void Sum(int a, ref int b); } - class Program + internal static class Program { - static void Main(string[] args) + public static void Main(string[] args) { int a = 12; int b = 13;