Wednesday, November 14, 2018

Another day another project: MultiLineStringAnalyzer

Today I had a lot of potentially tedious and error-prone work to do regarding changing some long string constants within some unit tests.

The tests (among a few other things) compare multi-line generated strings.

All had been good while it was only running on Windows, but now it needs to run regardless of the line-endings in use. This meant that everywhere there were implicit, multi-line strings, tests were failing.

The solution was to change all the tests so that they worked regardless of the line-endings of the machine they are running on.

To make this easier for me I created a tool.
It's probably easiest to show what it does.

It's a C# analyzer that makes changing multi-line strings to use environment appropriate line-endings much simpler and without the risk of manual error.

Just two clicks and it's all converted for me. And as I did this in 100's of places, even with the time spent creating the analyzer the conversion process was much quicker.

The chances are you'll never need it but if you have to do something like this is future it's here for you.
When I say here, I, of course, mean on GitHub.
Or you could install it as a NuGet package.

1 comment:

I get a lot of comment spam :( - moderation may take a while.