code-cracker/code-cracker — pull request #93 by vbfox (2014-11-30 14:12:07+00:00)
Title: Add a refactoring to switch between "string" and @"verbatim string"

Hi I started to migrate some code from my personal refactoring project (See #77 for context) this is the first PR about that.
Part of this code was previously integrated into a bigger set of diagnostic / code fixes but I extracted it as a refactoring as it make more sense for the user IMHO.

This refactoring transform code using regular strings to verbatim strings, this code :
```C#
var s = "Hello \r\n \"world\"";
```

Become:

```C#
var s = @"Hello
""world""";
```

The code is pretty small but introduce the necessary infrastructure to unit test Refactorings. One annoying point is that we must create a class derived from `CustomWorkspace` to avoid `NotImplementedException` being thrown. It is already solved in roslyn master but we have to live with it until the next VS preview (There is also multiple ways in the current Roslyn master to apply `CodeAction`s to a `Solution` instance without a workspace)

As refactorings require a selection to work I choose to define it using 2 rarely used unicode characters: `├` and `┤` producing test code looking like that :

```C#
[Fact]
public Task ConvertStringToVerbatimSelection()
{
const string before = @"
class C
{
void M()
{
var s = ├""Hello world""┤;
}
}";

const string expected = @"
class C
{
void M()
{
var s = @""Hello world"";
}
}";

return VerifyCSharpRefactoringAsync(before, expected,
StringTypeCodeRefactoringProvider.ToVerbatimId);
}
```

It make the tests easier to read than specifying the span manually but let me think what you think about it.

BTW I kept the namespaces in the test projects as they were... but namespaces not following folder structure, not being prefixed with project root NS, with partial classes spanning multiple folders... It seem unkempt to me.