How static scan all C# code for string format argument errors
Asked Answered
I

2

6

We have thousands of different log messages coded using the log4net library and string format method calls.

One problem with this is that it's only at run time that we get an error if the string format parameters like {0}, {1}, {2} have the right count of method parameters.

Many of these methods only get called on error conditions that rarely or never occur during automated testing.

So is there any tool that can scan all C# code and notify of any string format problems?

NOTE: I see many other questions on here at static code analysis which appears duplicate but after looking at some of those tools, they don't seem to handle this specific situation.

IF nothing really good for this, we'll write this tool in-house.

Interior answered 19/10, 2012 at 16:48 Comment(0)
B
2

We're using VS2012. The code analysis tool built into it helped us identify all of those types of issues.

Baez answered 19/10, 2012 at 16:51 Comment(1)
We also use VS2012 so I'm marking this as the best answer for us. Thank you very much!Interior
J
4

FxCop/Code Analysis can do this.

Jeer answered 19/10, 2012 at 16:50 Comment(0)
B
2

We're using VS2012. The code analysis tool built into it helped us identify all of those types of issues.

Baez answered 19/10, 2012 at 16:51 Comment(1)
We also use VS2012 so I'm marking this as the best answer for us. Thank you very much!Interior

© 2022 - 2024 — McMap. All rights reserved.