forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
COMObject invoke through reflection (dotnet#106677)
A regression was introduced by implementing IDynamicInterfaceCastable on __ComObject. This means that the order of checks is now important. Made the order consistent in all places and added a test for this particular case.
- Loading branch information
1 parent
b3481b4
commit 21fe571
Showing
4 changed files
with
51 additions
and
16 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
33 changes: 33 additions & 0 deletions
33
src/tests/Interop/COM/NETClients/Primitives/CallViaReflectionTests.cs
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,33 @@ | ||
// 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.Reflection; | ||
using Xunit; | ||
|
||
class CallViaReflectionTests | ||
{ | ||
private readonly Server.Contract.Servers.NumericTesting server; | ||
|
||
public CallViaReflectionTests() | ||
{ | ||
this.server = (Server.Contract.Servers.NumericTesting)new Server.Contract.Servers.NumericTestingClass(); | ||
} | ||
|
||
public void Run() | ||
{ | ||
Console.WriteLine(nameof(CallViaReflectionTests)); | ||
this.InvokeInstanceMethod(); | ||
} | ||
|
||
private void InvokeInstanceMethod() | ||
{ | ||
MethodInfo minfo = typeof(Server.Contract.INumericTesting).GetMethod("Add_Int")!; | ||
object[] parameters = new object[2] { 10, 20 }; | ||
int sum = (int)minfo.Invoke(this.server, parameters); | ||
Assert.Equal(30, sum); | ||
} | ||
} | ||
} |
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