Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 8fd31a6

Browse files
committed
Make reflection code more robust
1 parent 436c3c6 commit 8fd31a6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/GitHub.Services.Vssdk/Services/TippingService.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Linq;
3+
using System.Reflection;
34
using System.Runtime.InteropServices;
45
using System.Windows;
56
using GitHub.Logging;
@@ -58,8 +59,10 @@ void RequestCalloutDisplay(Guid clientId, Guid calloutId, string title, string m
5859
var parameterTypes = new Type[] { typeof(Guid), typeof(Guid), typeof(string), typeof(string), typeof(bool),
5960
typeof(Microsoft.VisualStudio.OLE.Interop.POINT), typeof(Guid), typeof(uint) };
6061
var tippingServiceType = tippingService.GetType();
61-
var method = tippingService.GetType().GetInterfaces().Where(i => i.GUID == IVsTippingServiceGuid)
62-
.FirstOrDefault()?.GetMethod("RequestCalloutDisplay", parameterTypes);
62+
var method = tippingServiceType.GetInterfaces()
63+
.FirstOrDefault(i => i.GUID == IVsTippingServiceGuid)?.GetMethod("RequestCalloutDisplay",
64+
BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly,
65+
null, parameterTypes, null);
6366
if (method == null)
6467
{
6568
log.Error("Couldn't find method on {Type} with parameters {Parameters}", tippingServiceType, parameterTypes);

0 commit comments

Comments
 (0)