SOURCE DUMP v1

This commit is contained in:
Rian Drake 2026-10-15 14:09:11 +13:00
commit fb20299e9d

View file

@ -0,0 +1,26 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
namespace Brutal.Strings.Analyzers;
using static SyntaxFactory;
// TODO: move this to a shared package...
public static class SyntaxFactoryExtensions
{
/// <inheritdoc cref="Utf8Literal(string,string)" />
public static SyntaxToken Utf8Literal(string value)
{
return Utf8Literal(SymbolDisplay.FormatLiteral(value, quote: true) + "u8", value);
}
/// <summary>
/// Creates a token with kind Utf8StringLiteralToken from the text and corresponding string value.
/// </summary>
/// <param name="text">The raw text of the literal, including quotes and escape sequences.</param>
/// <param name="value">The string value to be represented by the returned token.</param>
public static SyntaxToken Utf8Literal(string text, string value)
{
return Token(SyntaxTriviaList.Empty, SyntaxKind.Utf8StringLiteralToken, text, value, SyntaxTriviaList.Empty);
}
}