dotnet/roslyn-sdk

Add option to disable markup in tests

thinker227 opened this issue · 2 comments

In the markup syntax used for tests, $$ is a special reserved character. However, in C# 10+, $$ can now occur in regular C# source code (raw string literals with one level of interpolation escaping). This makes it impossible to run tests containing $$ naturally in the source code without overriding AnalyzerTest<TVerifier>.RunImplAsync to explicitly not call WithProcessedMarkup.

It would be useful if there either was an easily available option to disable markup entirely or there was some sort of markup escape character.

@thinker227 This already exists.

/// <summary>
/// Markup syntax is disabled, and any syntax which could be treated as markup is preserved in the contents of
/// sources and additional files.
/// </summary>
None,

and

/// <summary>
/// Ignore position indicators (<c>$$</c>) in markup processing. Spans and named spans are still supported in markup.
/// </summary>
/// <remarks>
/// This flag makes it easier to write tests for code containing interpolated raw strings (<see href="https://github.com/dotnet/roslyn-sdk/issues/1067">dotnet/roslyn-sdk#1067</see>).
/// </remarks>
TreatPositionIndicatorsAsCode = 0x0002,

Oh, didn't know those existed.