I'm trying to capture the first parameter of a method call using a named group in a regular expression.
E.g. given:
.MyMethod(foo);
.MyMethod(foo, bar);
.MyMethod(new MyObject(1, 2), 3);
.MyMethod(new MyObject()).MyChainedMethod();
The pattern should return for the named group:
foo
foo
new MyObject(1, 2)
new MyObject()
I've tried various combinations, but can't match every case, for example the following matches the second and third cases:
\.MyMethod\((?<firstParam>.+)(?=,|\),)