DotNetAnalyzers / TSqlAnalyzer

T-SQL Code Analyzer for Visual Studio 2015 CTP6
MIT License
57 stars 12 forks source link

Parsing StringBuilder.ToString() #9

Open RonnieHegelund opened 9 years ago

RonnieHegelund commented 9 years ago

It should be possible to parse a stringbuilder for sql string

dothenrik commented 9 years ago

How would you actually find the SQL string to check for validity? Strings constructed by StringBuilders are typically the result of multiple operations. Very simple examples where the StringBuilders does not manipulate the initial SQL string could be checked, but thats not really a realistic use case.

RonnieHegelund commented 9 years ago

I would look for values in the constructor and on the append method, yes it will only work in simple cases.

dothenrik commented 9 years ago

Yes, it can be done if you limit yourself to very simple scenarios. But is it really worth the effort? Have you seen many (or any at all) developers using StringBuilder for simple SQL statement construction?

ErikEJ commented 9 years ago

Scope, boys, scope...

RonnieHegelund commented 9 years ago

well now you can use simple stringbuilder functionality, though I agree this maybe not worth the effort!