diff options
author | Jan Vorlicek <janvorli@microsoft.com> | 2018-12-01 10:31:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-01 10:31:35 +0100 |
commit | 4c461d754ff29d1ba37c145676c397062378d1c0 (patch) | |
tree | 3f31b4015f010054dae1b5bd2f2a516915d0fe74 /tests/src/Interop | |
parent | 9fca919fdc8f20f80d923088620ec026196785bf (diff) | |
download | coreclr-4c461d754ff29d1ba37c145676c397062378d1c0.tar.gz coreclr-4c461d754ff29d1ba37c145676c397062378d1c0.tar.bz2 coreclr-4c461d754ff29d1ba37c145676c397062378d1c0.zip |
Enable COM interop for collectible classes (#20919)
* Enable COM interop for collectible classes
* Modify DispatchInfo to use LoaderAllocator handles
The DispatchMemberInfo was using global handles to refer to the managed
MemberInfo instances. That doesn't work with unloadability.
This change modifies it to use handles allocated from LoaderAllocator.
* Disable COM interop for WinRT types
* Remove collectible check from IsTypeVisibleFromCom. That fixes three
new COM interop tests
* Add collectible check to GetComClassFactory when we check for
unsupported interop with WinRT
* Add COM unloadability tests
Add two tests to test COM unloadability:
* One for using native COM server from managed COM client
* One for using managed COM objects from native client
* Add unloading test for IUnknownTest
* Disable NETClientPrimitivesInALC on Win ARM
The NETClientPrimitives is disabled there too.
Diffstat (limited to 'tests/src/Interop')
7 files changed, 179 insertions, 1 deletions
diff --git a/tests/src/Interop/COM/NETClients/Primitives/NETClientPrimitivesInALC.csproj b/tests/src/Interop/COM/NETClients/Primitives/NETClientPrimitivesInALC.csproj new file mode 100644 index 0000000000..48409316a0 --- /dev/null +++ b/tests/src/Interop/COM/NETClients/Primitives/NETClientPrimitivesInALC.csproj @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>NETClientPrimitivesInALC</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{85C57688-DA98-4DE3-AC9B-526E4747434C}</ProjectGuid> + <OutputType>Exe</OutputType> + <ProjectTypeGuids>{209912F9-0DA1-4184-9CC1-8D583BAF4A28};{87799F5D-CEBD-499D-BDBA-B2C6105CD766}</ProjectTypeGuids> + <ApplicationManifest>App.manifest</ApplicationManifest> + + <!-- Blocked on ILAsm supporting embedding resources. See https://github.com/dotnet/coreclr/issues/20819 --> + <IlrtTestKind>BuildOnly</IlrtTestKind> + + <!-- Blocked on CrossGen.exe supporting embedding resources. See https://github.com/dotnet/coreclr/issues/21006 --> + <CrossGenTest>false</CrossGenTest> + + <!-- Test unsupported outside of windows --> + <TestUnsupportedOutsideWindows>true</TestUnsupportedOutsideWindows> + <DisableProjectBuild Condition="'$(TargetsUnix)' == 'true'">true</DisableProjectBuild> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> + </PropertyGroup> + <ItemGroup> + <Compile Include="TestInALC.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../NativeServer/CMakeLists.txt" /> + <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + <ProjectReference Include="NetClientPrimitives.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Interop/COM/NETClients/Primitives/TestInALC.cs b/tests/src/Interop/COM/NETClients/Primitives/TestInALC.cs new file mode 100644 index 0000000000..eb5e9dd240 --- /dev/null +++ b/tests/src/Interop/COM/NETClients/Primitives/TestInALC.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System; +using System.IO; +using System.Reflection; + +namespace TestInALC +{ + class Test + { + static int Main(string[] args) + { + string currentAssemblyDirectory = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath); + string testAssemblyFullPath = Path.Combine(currentAssemblyDirectory, "NETClientPrimitives.exe"); + return TestLibrary.Utilities.ExecuteAndUnload(testAssemblyFullPath, args); + } + } +} diff --git a/tests/src/Interop/MarshalAPI/IUnknown/IUnknownTest.csproj b/tests/src/Interop/MarshalAPI/IUnknown/IUnknownTest.csproj index ddcd2c3e5b..855cb065de 100644 --- a/tests/src/Interop/MarshalAPI/IUnknown/IUnknownTest.csproj +++ b/tests/src/Interop/MarshalAPI/IUnknown/IUnknownTest.csproj @@ -28,7 +28,7 @@ </CodeAnalysisDependentAssemblyPaths> </ItemGroup> <ItemGroup> - <Compile Include="*.cs" /> + <Compile Include="IUnknownTest.cs" /> </ItemGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> diff --git a/tests/src/Interop/MarshalAPI/IUnknown/IUnknownTestInALC.csproj b/tests/src/Interop/MarshalAPI/IUnknown/IUnknownTestInALC.csproj new file mode 100644 index 0000000000..26824ed271 --- /dev/null +++ b/tests/src/Interop/MarshalAPI/IUnknown/IUnknownTestInALC.csproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>IUnknownTestInALC</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{F1E66554-8C8E-4141-85CF-D0CD6A0CD0B0}</ProjectGuid> + <OutputType>Exe</OutputType> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + + <DefineConstants>$(DefineConstants);STATIC</DefineConstants> + + <!-- Test unsupported outside of windows --> + <TestUnsupportedOutsideWindows>true</TestUnsupportedOutsideWindows> + <DisableProjectBuild Condition="'$(TargetsUnix)' == 'true'">true</DisableProjectBuild> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <Compile Include="TestInALC.cs" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\..\Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj"> + <Project>{c8c0dc74-fac4-45b1-81fe-70c4808366e0}</Project> + <Name>CoreCLRTestLibrary</Name> + </ProjectReference> + <ProjectReference Include="IUnknownTest.csproj" /> + <ProjectReference Include="CMakeLists.txt" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Interop/MarshalAPI/IUnknown/TestInALC.cs b/tests/src/Interop/MarshalAPI/IUnknown/TestInALC.cs new file mode 100644 index 0000000000..c14766a08c --- /dev/null +++ b/tests/src/Interop/MarshalAPI/IUnknown/TestInALC.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System; +using System.IO; +using System.Reflection; + +namespace TestInALC +{ + class Test + { + static int Main(string[] args) + { + string currentAssemblyDirectory = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath); + string testAssemblyFullPath = Path.Combine(currentAssemblyDirectory, "IUnknownTest.exe"); + return TestLibrary.Utilities.ExecuteAndUnload(testAssemblyFullPath, args); + } + } +} diff --git a/tests/src/Interop/PInvoke/NativeCallManagedComVisible/Default/DefaultTestInALC.csproj b/tests/src/Interop/PInvoke/NativeCallManagedComVisible/Default/DefaultTestInALC.csproj new file mode 100644 index 0000000000..f197d1aab0 --- /dev/null +++ b/tests/src/Interop/PInvoke/NativeCallManagedComVisible/Default/DefaultTestInALC.csproj @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>DefaultTestInALC</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{43531C46-AFE2-4254-93C6-7F17E30D750C}</ProjectGuid> + <OutputType>Exe</OutputType> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\</SolutionDir> + <DefineConstants>$(DefineConstants);STATIC</DefineConstants> + <!-- Test unsupported outside of windows --> + <TestUnsupportedOutsideWindows>true</TestUnsupportedOutsideWindows> + <DisableProjectBuild Condition="'$(TargetsUnix)' == 'true'">true</DisableProjectBuild> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"></PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"></PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <Compile Include="TestInALC.cs" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\CMakeLists.txt" /> + <ProjectReference Include="DefaultTest.csproj" /> + </ItemGroup> + <Import Project="../../../Interop.settings.targets" /> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Interop/PInvoke/NativeCallManagedComVisible/Default/TestInALC.cs b/tests/src/Interop/PInvoke/NativeCallManagedComVisible/Default/TestInALC.cs new file mode 100644 index 0000000000..265d70fa32 --- /dev/null +++ b/tests/src/Interop/PInvoke/NativeCallManagedComVisible/Default/TestInALC.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System; +using System.IO; +using System.Reflection; + +namespace TestInALC +{ + class Test + { + static int Main(string[] args) + { + string currentAssemblyDirectory = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath); + string testAssemblyFullPath = Path.Combine(currentAssemblyDirectory, "DefaultTest.exe"); + return TestLibrary.Utilities.ExecuteAndUnload(testAssemblyFullPath, args); + } + } +} |