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

Commit 8c4852f

Browse files
committed
Don't copy parameter types from current method
Using the current method as a template was useful while prototyping, but it's time to lock down the parameter types.
1 parent a7d80b3 commit 8c4852f

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ void RequestCalloutDisplay(Guid clientId, Guid calloutId, string title, string m
5050
{
5151
var tippingService = serviceProvider.GetService(typeof(SVsTippingService));
5252
Assumes.Present(tippingService);
53-
var currentMethod = MethodBase.GetCurrentMethod();
54-
var parameterTypes = currentMethod.GetParameters().Select(p => p.ParameterType).ToArray();
55-
var method = tippingService.GetType().GetMethod(currentMethod.Name, parameterTypes);
53+
var parameterTypes = new Type[] { typeof(Guid), typeof(Guid), typeof(string), typeof(string),
54+
typeof(bool), typeof(FrameworkElement), typeof(Guid), typeof(uint), typeof(object) };
55+
var method = tippingService.GetType().GetMethod("RequestCalloutDisplay", parameterTypes);
5656
var arguments = new object[] { clientId, calloutId, title, message, isPermanentlyDismissible, targetElement,
5757
vsCommandGroupId, vsCommandId, commandOption };
5858
method.Invoke(tippingService, arguments);
@@ -70,13 +70,13 @@ void RequestCalloutDisplay(Guid clientId, Guid calloutId, string title, string m
7070
}
7171

7272
Assumes.Present(tippingService);
73-
var currentMethod = MethodBase.GetCurrentMethod();
74-
var parameterTypes = currentMethod.GetParameters().Select(p => p.ParameterType).ToArray();
73+
var parameterTypes = new Type[] { typeof(Guid), typeof(Guid), typeof(string), typeof(string), typeof(bool),
74+
typeof(Microsoft.VisualStudio.OLE.Interop.POINT), typeof(Guid), typeof(uint) };
7575
var tippingServiceType = tippingService.GetType();
76-
var method = tippingServiceType.GetMethod(currentMethod.Name, parameterTypes);
76+
var method = tippingServiceType.GetMethod("RequestCalloutDisplay", parameterTypes);
7777
if (method == null)
7878
{
79-
log.Error("Couldn't find method on {Type} with parameters like {Method}", tippingServiceType, currentMethod);
79+
log.Error("Couldn't find method on {Type} with parameters {Parameters}", tippingServiceType, parameterTypes);
8080
return;
8181
}
8282

@@ -92,5 +92,8 @@ void RequestCalloutDisplay(Guid clientId, Guid calloutId, string title, string m
9292
[ComImport]
9393
public interface SVsTippingService
9494
{
95+
void RequestCalloutDisplay(Guid clientId, Guid calloutId, string title, string message,
96+
bool isPermanentlyDismissible, FrameworkElement targetElement,
97+
Guid vsCommandGroupId, uint vsCommandId, object commandOption = null);
9598
}
9699
}

0 commit comments

Comments
 (0)