Join 34,000+ subscribers and receive articles from our
blog about software quality, testing, QA and security.

EnterMethod: pass arguments using variable parameters


#1

Hi

We’re evaluating using SmartInspect for our web services platform and I thought i might as well capture our feedback here.

It appears that the current EnterMethod implementation expects an array of the parameters to the format string. Are there plans in the future to implement a version of this that takes variable arguments? eg:

void EnterMethod(string methodNameFmt, params object[] args)

Using the current one is somewhat annoying, the difference would be:

current: EnterMethod(“MyMethod({0},{1})”, new object[] { arg1, arg2 })

future: EnterMethod(“MyMethod({0},{1})”, arg1, arg2)

Also, after .NET version 4.5, there could be a version:

void EnterMethod([CallerMemberName] string memberName = “”)

Cheers,
Chris


#2

Hello Chris,

Thanks for your posting. It’s difficult to change the existing method signature in order to stay backwards-compatible but I agree that leveraging some of the new language features make sense. I’ve added this to our feature request list for now (e.g. as an additional EnterMethodFmt method, or similar), thanks.

Regards,
Tobias


#3

Hi Tobias,

Thanks for getting back to me.

In this instance changing the signature from EnterMethod(string, object[] ) to EnterMethod(string, params object[]) would be completely backwards compatible afaik? For example:

EnterMethod(“test {0}”, new object[] { “hi” })

This would continue to work but static analysis tools would likely start generating hints to simplify these calls.

Cheers
Chris


#4

Hello Chris,

We will make sure to look into this, thanks again!

Regards,
Tobias