Last active
December 7, 2022 13:28
-
-
Save ufcpp/2262fe3f607974b68b849b5b47a4dc32 to your computer and use it in GitHub Desktop.
Convert T4 to StringBuilder.Append($$""" """);
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Text.RegularExpressions; | |
using System.Windows; | |
class Program | |
{ | |
[STAThread] | |
static void Main() | |
{ | |
var x = Clipboard.GetText(); | |
x = Reg.A().Replace(x, m => "{{" + m.Groups[1].Value + "}}"); | |
x = Reg.C().Replace(x, """" | |
s.Append($$$$""" | |
""""); | |
x = Reg.B().Replace(x, """" | |
"""); | |
""""); | |
Clipboard.SetText("""" | |
public string TransformText() | |
{ | |
var s = new StringBuilder(); | |
s.Append($$""" | |
"""" | |
+ x + | |
"""" | |
"""); | |
return s.ToString(); | |
} | |
""""); | |
} | |
} | |
static partial class Reg | |
{ | |
[GeneratedRegex(""" | |
\<\#\=(.*?)\#\> | |
""", RegexOptions.Multiline)] | |
public static partial Regex A(); | |
[GeneratedRegex(""" | |
^\<\# | |
""", RegexOptions.Multiline)] | |
public static partial Regex B(); | |
[GeneratedRegex(""" | |
^\#\> | |
""", RegexOptions.Multiline)] | |
public static partial Regex C(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment