-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Block casting to an interface marked ComInterfaceType.InterfaceIsIIns…
…pectable (#41633)
- Loading branch information
1 parent
393c1b2
commit eb22f4e
Showing
12 changed files
with
196 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/tests/Interop/COM/NETClients/IInspectable/App.manifest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<assemblyIdentity | ||
type="win32" | ||
name="NetPrimitivesIInspectable" | ||
version="1.0.0.0" /> | ||
|
||
<dependency> | ||
<dependentAssembly> | ||
<!-- RegFree COM --> | ||
<assemblyIdentity | ||
type="win32" | ||
name="COMNativeServer.X" | ||
version="1.0.0.0"/> | ||
</dependentAssembly> | ||
</dependency> | ||
|
||
</assembly> |
22 changes: 22 additions & 0 deletions
22
src/tests/Interop/COM/NETClients/IInspectable/NETClientIInspectable.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<ApplicationManifest>App.manifest</ApplicationManifest> | ||
<!-- ilasm round-trip testing blocked on ILAsm supporting embedding resources. See https://github.com/dotnet/runtime/issues/11412 --> | ||
<IlasmRoundTripIncompatible>true</IlasmRoundTripIncompatible> | ||
<!-- Test unsupported outside of windows --> | ||
<CLRTestTargetUnsupported Condition="'$(TargetsWindows)' != 'true'">true</CLRTestTargetUnsupported> | ||
<!-- This test would require the runincontext.exe to include App.manifest describing the COM interfaces --> | ||
<UnloadabilityIncompatible>true</UnloadabilityIncompatible> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="../../ServerContracts/Server.CoClasses.cs" /> | ||
<Compile Include="../../ServerContracts/Server.Contracts.cs" /> | ||
<Compile Include="../../ServerContracts/ServerGuids.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="../../NativeServer/CMakeLists.txt" /> | ||
<ProjectReference Include="$(TestSourceDir)Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace NetClient | ||
{ | ||
using System; | ||
using System.Globalization; | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
|
||
using TestLibrary; | ||
using Server.Contract; | ||
using Server.Contract.Servers; | ||
|
||
class Program | ||
{ | ||
static void Validate_IInspectable() | ||
{ | ||
var server = (InspectableTesting)new InspectableTestingClass(); | ||
Assert.Throws<PlatformNotSupportedException>(() => _ = (IInspectableTesting2)server); | ||
} | ||
|
||
static int Main(string[] doNotUse) | ||
{ | ||
// RegFree COM is not supported on Windows Nano | ||
if (Utilities.IsWindowsNanoServer) | ||
{ | ||
return 100; | ||
} | ||
|
||
try | ||
{ | ||
Validate_IInspectable(); | ||
} | ||
catch (Exception e) | ||
{ | ||
Console.WriteLine($"Test Failure: {e}"); | ||
return 101; | ||
} | ||
|
||
return 100; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#pragma once | ||
|
||
#include "Servers.h" | ||
|
||
class InspectableTesting : public UnknownImpl, public IInspectableTesting, public IInspectableTesting2 | ||
{ | ||
public: // IInspectableTesting2 | ||
DEF_FUNC(Add)( | ||
/*[in]*/ int a, | ||
/*[in]*/ int b, | ||
/*[out] [retval] */ int* retVal) | ||
{ | ||
*retVal = a + b; | ||
return S_OK; | ||
} | ||
|
||
public: // IInspectable | ||
STDMETHOD(GetIids)( | ||
/* [out] */ ULONG *iidCount, | ||
/* [size_is][size_is][out] */ IID **iids) | ||
{ | ||
return E_NOTIMPL; | ||
} | ||
|
||
STDMETHOD(GetRuntimeClassName)( | ||
/* [out] */ HSTRING *className) | ||
{ | ||
className = nullptr; | ||
return S_OK; | ||
} | ||
|
||
STDMETHOD(GetTrustLevel)( | ||
/* [out] */ TrustLevel *trustLevel) | ||
{ | ||
*trustLevel = TrustLevel::FullTrust; | ||
return S_OK; | ||
} | ||
|
||
public: // IUnknown | ||
STDMETHOD(QueryInterface)( | ||
/* [in] */ REFIID riid, | ||
/* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppvObject) | ||
{ | ||
return DoQueryInterface(riid, ppvObject, static_cast<IInspectableTesting *>(this), static_cast<IInspectableTesting2 *>(this), static_cast<IInspectable*>(this)); | ||
} | ||
|
||
DEFINE_REF_COUNTING(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters