Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set a Function Breakpoint on a C# Generic Class/Method in Visual Studio?

How can I set a Function Breakpoint on a generic class/method?

I'm possibly trying to figure out the syntax to use. Here is the class/method I want to set it on:-

namespace MyCustom.SpecialNS
{
  public class SomeGenericConditionClass<T> : BaseConditionNS.WhenCondition<T> where T : BaseRuleNS.RuleContext
  {

    protected override bool Execute(T ruleContextParam)
    {
        string hello = "Hello. Set Breakpoint here!";
        return true;
    }
  }
}

As an FYI, I am attempting to debug a third party dll, in which I have setup other ways to debug regular concrete classes/methods using Function Breakpoints. i.e I can set

MyCustom.SpecialNS.SimpleConcreteClass.BasicExecute(MyCustomAttrNS.MyAttributeType)

and it will successfully break. But for the generic, I'm not sure what the type T is, or what the syntax is to properly set the Function Breakpoint, and it's a third party DLL, so I can't just open the code and click to create the breakpoint.

I have tried

MyCustom.SpecialNS.SomeGenericConditionClass.Execute

and

MyCustom.SpecialNS.SomeGenericConditionClass<T>.Execute<T>

And many other variations around it, but I get nowhere.

Any ideas?

like image 273
Sean Holmesby Avatar asked Nov 01 '25 17:11

Sean Holmesby


1 Answers

SomeGenericConditionClass<T>.Execute works for me. (Promoted from my comment above.)

like image 194
asherber Avatar answered Nov 04 '25 10:11

asherber



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!