PowerShell through your String Literals - Using PowerShell to extract and review all the string literals in your applications
CodeProject - PowerShell Script for Reviewing Text Shown to Users
"Introduction
It's embarrassing when users see text containing spelling and grammar errors. Error handling code is most likely to contain bad prose because developers are sloppy with code that isn't "supposed" to ever run. Imagine a snapshot of your dialog landing on your bosses desk. The message text reads "If you got here, your #$%@ed." How humiliating for your boss to see that you misspelled "you're".
String tables are supposed to avoid this problem, but error handling strings often get left out. After all, why go to the effort to put a message string in a table when you know the code will never run? And while it's an exaggeration to say the code never runs, it may run so seldom that it is never seen in testing.
The PowerShell script described in this article searches through a source code tree and extracts string literals that may be visible to users. It tries to filter out strings that are code from strings that are prose. The script isn't perfect; a complete solution would require a lot more work than a little script. But it does a good job of finding errors that would otherwise go undetected. You will probably find that your source code has far more typos than you thought.
...
The script is configured to search C++, C#, VB, ASP.NET, JavaScript, and XML files. You may want to modify this line to change the file extensions you want to search.
$sourceExtensions = "\.(cs|vb|aspx|resx|cpp|rc|h|js|xml)$"..."
Nice...and though I would never need this (cough... yeah, right!... cough) I can see it being a handy utility. Both in its intent and as a PowerShell learning tool.
This could also come in real handy when taking over someone else's code and to batch find all the string literals in my code, to help me move them to resource files.
No comments:
Post a Comment