diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs index 4667df2c..b04381e5 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs @@ -2271,21 +2271,29 @@ private string EscapeAndStripName(string name) } internal static string EscapeCharacter(char value) => value switch { - '\0' => "\\0", - '\\' => "\\\\", - '\r' => "\\r", - '\n' => "\\n", - '\t' => "\\t", - '\'' => "\\'", + '\0' => @"\0", + '\\' => @"\\", + '\r' => @"\r", + '\n' => @"\n", + '\t' => @"\t", + '\'' => @"\'", _ => value.ToString(), }; - internal static string EscapeString(string value) => value.Replace("\0", "\\0", StringComparison.Ordinal) - .Replace("\\", "\\\\", StringComparison.Ordinal) - .Replace("\r", "\\r", StringComparison.Ordinal) - .Replace("\n", "\\n", StringComparison.Ordinal) - .Replace("\t", "\\t", StringComparison.Ordinal) - .Replace("\"", "\\\"", StringComparison.Ordinal); + // We first replace already escaped characters with their raw counterpart + // We then re-escape any raw characters. This ensures we don't end up with double escaped backslashes + internal static string EscapeString(string value) => value.Replace(@"\\", "\\", StringComparison.Ordinal) + .Replace(@"\0", "\0", StringComparison.Ordinal) + .Replace(@"\r", "\r", StringComparison.Ordinal) + .Replace(@"\n", "\n", StringComparison.Ordinal) + .Replace(@"\t", "\t", StringComparison.Ordinal) + .Replace(@"\""", "\"", StringComparison.Ordinal) + .Replace("\\", @"\\", StringComparison.Ordinal) + .Replace("\0", @"\0", StringComparison.Ordinal) + .Replace("\r", @"\r", StringComparison.Ordinal) + .Replace("\n", @"\n", StringComparison.Ordinal) + .Replace("\t", @"\t", StringComparison.Ordinal) + .Replace("\"", @"\""", StringComparison.Ordinal); private AccessSpecifier GetAccessSpecifier(NamedDecl namedDecl, bool matchStar) { diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/VarDeclarationTest.cs index fb6ef467..df8f4626 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/VarDeclarationTest.cs @@ -115,7 +115,7 @@ protected override Task NoInitializerTestImpl(string nativeType) protected override Task Utf8StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 ""Test"""; + var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@"using System; @@ -123,8 +123,8 @@ namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""#define MyMacro1 \""Test\"""")] - public static ReadOnlySpan MyMacro1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + [NativeTypeName(""#define MyMacro1 \""Test\0\\\r\n\t\""\"""")] + public static ReadOnlySpan MyMacro1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; }} }} "; @@ -134,14 +134,14 @@ public static partial class Methods protected override Task Utf16StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 u""Test"""; + var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""#define MyMacro1 u\""Test\"""")] - public const string MyMacro1 = ""Test""; + [NativeTypeName(""#define MyMacro1 u\""Test\0\\\r\n\t\""\"""")] + public const string MyMacro1 = ""Test\0\\\r\n\t\""""; }} }} "; @@ -151,22 +151,22 @@ public static partial class Methods protected override Task WideStringLiteralConstTestImpl() { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; -const wchar_t* MyConst2 = L""Test""; -const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const wchar_t[5]"")] - public static readonly uint[] MyConst1 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }}; + [NativeTypeName(""const wchar_t[11]"")] + public static readonly uint[] MyConst1 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; [NativeTypeName(""const wchar_t *"")] - public static uint[] MyConst2 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }}; + public static uint[] MyConst2 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; [NativeTypeName(""const wchar_t *const"")] - public static readonly uint[] MyConst3 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }}; + public static readonly uint[] MyConst3 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; }} }} "; @@ -176,9 +176,9 @@ public static partial class Methods protected override Task StringLiteralConstTestImpl() { - var inputContents = $@"const char MyConst1[] = ""Test""; -const char* MyConst2 = ""Test""; -const char* const MyConst3 = ""Test"";"; + var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; +const char* MyConst2 = ""Test\0\\\r\n\t\""""; +const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"using System; @@ -186,14 +186,14 @@ namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const char[5]"")] - public static ReadOnlySpan MyConst1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + [NativeTypeName(""const char[11]"")] + public static ReadOnlySpan MyConst1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + public static byte[] MyConst2 = new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + public static ReadOnlySpan MyConst3 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; }} }} "; @@ -203,22 +203,22 @@ public static partial class Methods protected override Task WideStringLiteralStaticConstTestImpl() { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; -static const wchar_t* MyConst2 = L""Test""; -static const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const wchar_t[5]"")] - public static readonly uint[] MyConst1 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }}; + [NativeTypeName(""const wchar_t[11]"")] + public static readonly uint[] MyConst1 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; [NativeTypeName(""const wchar_t *"")] - public static uint[] MyConst2 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }}; + public static uint[] MyConst2 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; [NativeTypeName(""const wchar_t *const"")] - public static readonly uint[] MyConst3 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }}; + public static readonly uint[] MyConst3 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; }} }} "; @@ -228,9 +228,9 @@ public static partial class Methods protected override Task StringLiteralStaticConstTestImpl() { - var inputContents = $@"static const char MyConst1[] = ""Test""; -static const char* MyConst2 = ""Test""; -static const char* const MyConst3 = ""Test"";"; + var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; +static const char* MyConst2 = ""Test\0\\\r\n\t\""""; +static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"using System; @@ -238,14 +238,14 @@ namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const char[5]"")] - public static ReadOnlySpan MyConst1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + [NativeTypeName(""const char[11]"")] + public static ReadOnlySpan MyConst1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + public static byte[] MyConst2 = new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + public static ReadOnlySpan MyConst3 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; }} }} "; diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/VarDeclarationTest.cs index 52b39637..929ffaa4 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/VarDeclarationTest.cs @@ -116,7 +116,7 @@ protected override Task NoInitializerTestImpl(string nativeType) protected override Task Utf8StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 ""Test"""; + var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@"using System; @@ -124,8 +124,8 @@ namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""#define MyMacro1 \""Test\"""")] - public static ReadOnlySpan MyMacro1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + [NativeTypeName(""#define MyMacro1 \""Test\0\\\r\n\t\""\"""")] + public static ReadOnlySpan MyMacro1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; }} }} "; @@ -135,14 +135,14 @@ public static partial class Methods protected override Task Utf16StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 u""Test"""; + var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""#define MyMacro1 u\""Test\"""")] - public const string MyMacro1 = ""Test""; + [NativeTypeName(""#define MyMacro1 u\""Test\0\\\r\n\t\""\"""")] + public const string MyMacro1 = ""Test\0\\\r\n\t\""""; }} }} "; @@ -152,22 +152,22 @@ public static partial class Methods protected override Task WideStringLiteralConstTestImpl() { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; -const wchar_t* MyConst2 = L""Test""; -const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const wchar_t[5]"")] - public const string MyConst1 = ""Test""; + [NativeTypeName(""const wchar_t[11]"")] + public const string MyConst1 = ""Test\0\\\r\n\t\""""; [NativeTypeName(""const wchar_t *"")] - public static string MyConst2 = ""Test""; + public static string MyConst2 = ""Test\0\\\r\n\t\""""; [NativeTypeName(""const wchar_t *const"")] - public const string MyConst3 = ""Test""; + public const string MyConst3 = ""Test\0\\\r\n\t\""""; }} }} "; @@ -177,9 +177,9 @@ public static partial class Methods protected override Task StringLiteralConstTestImpl() { - var inputContents = $@"const char MyConst1[] = ""Test""; -const char* MyConst2 = ""Test""; -const char* const MyConst3 = ""Test"";"; + var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; +const char* MyConst2 = ""Test\0\\\r\n\t\""""; +const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"using System; @@ -187,14 +187,14 @@ namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const char[5]"")] - public static ReadOnlySpan MyConst1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + [NativeTypeName(""const char[11]"")] + public static ReadOnlySpan MyConst1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + public static byte[] MyConst2 = new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + public static ReadOnlySpan MyConst3 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; }} }} "; @@ -204,22 +204,22 @@ public static partial class Methods protected override Task WideStringLiteralStaticConstTestImpl() { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; -static const wchar_t* MyConst2 = L""Test""; -static const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const wchar_t[5]"")] - public const string MyConst1 = ""Test""; + [NativeTypeName(""const wchar_t[11]"")] + public const string MyConst1 = ""Test\0\\\r\n\t\""""; [NativeTypeName(""const wchar_t *"")] - public static string MyConst2 = ""Test""; + public static string MyConst2 = ""Test\0\\\r\n\t\""""; [NativeTypeName(""const wchar_t *const"")] - public const string MyConst3 = ""Test""; + public const string MyConst3 = ""Test\0\\\r\n\t\""""; }} }} "; @@ -229,9 +229,9 @@ public static partial class Methods protected override Task StringLiteralStaticConstTestImpl() { - var inputContents = $@"static const char MyConst1[] = ""Test""; -static const char* MyConst2 = ""Test""; -static const char* const MyConst3 = ""Test"";"; + var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; +static const char* MyConst2 = ""Test\0\\\r\n\t\""""; +static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"using System; @@ -239,14 +239,14 @@ namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const char[5]"")] - public static ReadOnlySpan MyConst1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + [NativeTypeName(""const char[11]"")] + public static ReadOnlySpan MyConst1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + public static byte[] MyConst2 = new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + public static ReadOnlySpan MyConst3 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; }} }} "; diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/VarDeclarationTest.cs index 06f3d3ea..29b0977b 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/VarDeclarationTest.cs @@ -116,7 +116,7 @@ protected override Task NoInitializerTestImpl(string nativeType) protected override Task Utf8StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 ""Test"""; + var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@"using System; @@ -124,8 +124,8 @@ namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""#define MyMacro1 \""Test\"""")] - public static ReadOnlySpan MyMacro1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + [NativeTypeName(""#define MyMacro1 \""Test\0\\\r\n\t\""\"""")] + public static ReadOnlySpan MyMacro1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; }} }} "; @@ -135,14 +135,14 @@ public static partial class Methods protected override Task Utf16StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 u""Test"""; + var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""#define MyMacro1 u\""Test\"""")] - public const string MyMacro1 = ""Test""; + [NativeTypeName(""#define MyMacro1 u\""Test\0\\\r\n\t\""\"""")] + public const string MyMacro1 = ""Test\0\\\r\n\t\""""; }} }} "; @@ -152,22 +152,22 @@ public static partial class Methods protected override Task WideStringLiteralConstTestImpl() { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; -const wchar_t* MyConst2 = L""Test""; -const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const wchar_t[5]"")] - public static readonly uint[] MyConst1 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }}; + [NativeTypeName(""const wchar_t[11]"")] + public static readonly uint[] MyConst1 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; [NativeTypeName(""const wchar_t *"")] - public static uint[] MyConst2 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }}; + public static uint[] MyConst2 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; [NativeTypeName(""const wchar_t *const"")] - public static readonly uint[] MyConst3 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }}; + public static readonly uint[] MyConst3 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; }} }} "; @@ -177,9 +177,9 @@ public static partial class Methods protected override Task StringLiteralConstTestImpl() { - var inputContents = $@"const char MyConst1[] = ""Test""; -const char* MyConst2 = ""Test""; -const char* const MyConst3 = ""Test"";"; + var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; +const char* MyConst2 = ""Test\0\\\r\n\t\""""; +const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"using System; @@ -187,14 +187,14 @@ namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const char[5]"")] - public static ReadOnlySpan MyConst1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + [NativeTypeName(""const char[11]"")] + public static ReadOnlySpan MyConst1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + public static byte[] MyConst2 = new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + public static ReadOnlySpan MyConst3 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; }} }} "; @@ -204,22 +204,22 @@ public static partial class Methods protected override Task WideStringLiteralStaticConstTestImpl() { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; -static const wchar_t* MyConst2 = L""Test""; -static const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const wchar_t[5]"")] - public static readonly uint[] MyConst1 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }}; + [NativeTypeName(""const wchar_t[11]"")] + public static readonly uint[] MyConst1 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; [NativeTypeName(""const wchar_t *"")] - public static uint[] MyConst2 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }}; + public static uint[] MyConst2 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; [NativeTypeName(""const wchar_t *const"")] - public static readonly uint[] MyConst3 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }}; + public static readonly uint[] MyConst3 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; }} }} "; @@ -229,9 +229,9 @@ public static partial class Methods protected override Task StringLiteralStaticConstTestImpl() { - var inputContents = $@"static const char MyConst1[] = ""Test""; -static const char* MyConst2 = ""Test""; -static const char* const MyConst3 = ""Test"";"; + var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; +static const char* MyConst2 = ""Test\0\\\r\n\t\""""; +static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"using System; @@ -239,14 +239,14 @@ namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const char[5]"")] - public static ReadOnlySpan MyConst1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + [NativeTypeName(""const char[11]"")] + public static ReadOnlySpan MyConst1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + public static byte[] MyConst2 = new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + public static ReadOnlySpan MyConst3 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; }} }} "; diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/VarDeclarationTest.cs index fc499a97..da6922fc 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/VarDeclarationTest.cs @@ -116,7 +116,7 @@ protected override Task NoInitializerTestImpl(string nativeType) protected override Task Utf8StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 ""Test"""; + var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@"using System; @@ -124,8 +124,8 @@ namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""#define MyMacro1 \""Test\"""")] - public static ReadOnlySpan MyMacro1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + [NativeTypeName(""#define MyMacro1 \""Test\0\\\r\n\t\""\"""")] + public static ReadOnlySpan MyMacro1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; }} }} "; @@ -135,14 +135,14 @@ public static partial class Methods protected override Task Utf16StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 u""Test"""; + var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""#define MyMacro1 u\""Test\"""")] - public const string MyMacro1 = ""Test""; + [NativeTypeName(""#define MyMacro1 u\""Test\0\\\r\n\t\""\"""")] + public const string MyMacro1 = ""Test\0\\\r\n\t\""""; }} }} "; @@ -152,22 +152,22 @@ public static partial class Methods protected override Task WideStringLiteralConstTestImpl() { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; -const wchar_t* MyConst2 = L""Test""; -const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const wchar_t[5]"")] - public const string MyConst1 = ""Test""; + [NativeTypeName(""const wchar_t[11]"")] + public const string MyConst1 = ""Test\0\\\r\n\t\""""; [NativeTypeName(""const wchar_t *"")] - public static string MyConst2 = ""Test""; + public static string MyConst2 = ""Test\0\\\r\n\t\""""; [NativeTypeName(""const wchar_t *const"")] - public const string MyConst3 = ""Test""; + public const string MyConst3 = ""Test\0\\\r\n\t\""""; }} }} "; @@ -177,9 +177,9 @@ public static partial class Methods protected override Task StringLiteralConstTestImpl() { - var inputContents = $@"const char MyConst1[] = ""Test""; -const char* MyConst2 = ""Test""; -const char* const MyConst3 = ""Test"";"; + var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; +const char* MyConst2 = ""Test\0\\\r\n\t\""""; +const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"using System; @@ -187,14 +187,14 @@ namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const char[5]"")] - public static ReadOnlySpan MyConst1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + [NativeTypeName(""const char[11]"")] + public static ReadOnlySpan MyConst1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + public static byte[] MyConst2 = new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + public static ReadOnlySpan MyConst3 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; }} }} "; @@ -204,22 +204,22 @@ public static partial class Methods protected override Task WideStringLiteralStaticConstTestImpl() { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; -static const wchar_t* MyConst2 = L""Test""; -static const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const wchar_t[5]"")] - public const string MyConst1 = ""Test""; + [NativeTypeName(""const wchar_t[11]"")] + public const string MyConst1 = ""Test\0\\\r\n\t\""""; [NativeTypeName(""const wchar_t *"")] - public static string MyConst2 = ""Test""; + public static string MyConst2 = ""Test\0\\\r\n\t\""""; [NativeTypeName(""const wchar_t *const"")] - public const string MyConst3 = ""Test""; + public const string MyConst3 = ""Test\0\\\r\n\t\""""; }} }} "; @@ -229,9 +229,9 @@ public static partial class Methods protected override Task StringLiteralStaticConstTestImpl() { - var inputContents = $@"static const char MyConst1[] = ""Test""; -static const char* MyConst2 = ""Test""; -static const char* const MyConst3 = ""Test"";"; + var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; +static const char* MyConst2 = ""Test\0\\\r\n\t\""""; +static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"using System; @@ -239,14 +239,14 @@ namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const char[5]"")] - public static ReadOnlySpan MyConst1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + [NativeTypeName(""const char[11]"")] + public static ReadOnlySpan MyConst1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + public static byte[] MyConst2 = new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }}; + public static ReadOnlySpan MyConst3 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; }} }} "; diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/VarDeclarationTest.cs index c4b29661..dc8b3ac8 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/VarDeclarationTest.cs @@ -116,7 +116,7 @@ protected override Task NoInitializerTestImpl(string nativeType) protected override Task Utf8StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 ""Test"""; + var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@"using System; @@ -124,8 +124,8 @@ namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""#define MyMacro1 \""Test\"""")] - public static ReadOnlySpan MyMacro1 => ""Test""u8; + [NativeTypeName(""#define MyMacro1 \""Test\0\\\r\n\t\""\"""")] + public static ReadOnlySpan MyMacro1 => ""Test\0\\\r\n\t\""""u8; }} }} "; @@ -135,14 +135,14 @@ public static partial class Methods protected override Task Utf16StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 u""Test"""; + var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""#define MyMacro1 u\""Test\"""")] - public const string MyMacro1 = ""Test""; + [NativeTypeName(""#define MyMacro1 u\""Test\0\\\r\n\t\""\"""")] + public const string MyMacro1 = ""Test\0\\\r\n\t\""""; }} }} "; @@ -152,22 +152,22 @@ public static partial class Methods protected override Task WideStringLiteralConstTestImpl() { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; -const wchar_t* MyConst2 = L""Test""; -const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const wchar_t[5]"")] - public static readonly uint[] MyConst1 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }}; + [NativeTypeName(""const wchar_t[11]"")] + public static readonly uint[] MyConst1 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; [NativeTypeName(""const wchar_t *"")] - public static uint[] MyConst2 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }}; + public static uint[] MyConst2 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; [NativeTypeName(""const wchar_t *const"")] - public static readonly uint[] MyConst3 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }}; + public static readonly uint[] MyConst3 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; }} }} "; @@ -177,9 +177,9 @@ public static partial class Methods protected override Task StringLiteralConstTestImpl() { - var inputContents = $@"const char MyConst1[] = ""Test""; -const char* MyConst2 = ""Test""; -const char* const MyConst3 = ""Test"";"; + var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; +const char* MyConst2 = ""Test\0\\\r\n\t\""""; +const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"using System; @@ -187,14 +187,14 @@ namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const char[5]"")] - public static ReadOnlySpan MyConst1 => ""Test""u8; + [NativeTypeName(""const char[11]"")] + public static ReadOnlySpan MyConst1 => ""Test\0\\\r\n\t\""""u8; [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = ""Test""u8.ToArray(); + public static byte[] MyConst2 = ""Test\0\\\r\n\t\""""u8.ToArray(); [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => ""Test""u8; + public static ReadOnlySpan MyConst3 => ""Test\0\\\r\n\t\""""u8; }} }} "; @@ -204,22 +204,22 @@ public static partial class Methods protected override Task WideStringLiteralStaticConstTestImpl() { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; -static const wchar_t* MyConst2 = L""Test""; -static const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const wchar_t[5]"")] - public static readonly uint[] MyConst1 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }}; + [NativeTypeName(""const wchar_t[11]"")] + public static readonly uint[] MyConst1 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; [NativeTypeName(""const wchar_t *"")] - public static uint[] MyConst2 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }}; + public static uint[] MyConst2 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; [NativeTypeName(""const wchar_t *const"")] - public static readonly uint[] MyConst3 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }}; + public static readonly uint[] MyConst3 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; }} }} "; @@ -229,9 +229,9 @@ public static partial class Methods protected override Task StringLiteralStaticConstTestImpl() { - var inputContents = $@"static const char MyConst1[] = ""Test""; -static const char* MyConst2 = ""Test""; -static const char* const MyConst3 = ""Test"";"; + var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; +static const char* MyConst2 = ""Test\0\\\r\n\t\""""; +static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"using System; @@ -239,14 +239,14 @@ namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const char[5]"")] - public static ReadOnlySpan MyConst1 => ""Test""u8; + [NativeTypeName(""const char[11]"")] + public static ReadOnlySpan MyConst1 => ""Test\0\\\r\n\t\""""u8; [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = ""Test""u8.ToArray(); + public static byte[] MyConst2 = ""Test\0\\\r\n\t\""""u8.ToArray(); [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => ""Test""u8; + public static ReadOnlySpan MyConst3 => ""Test\0\\\r\n\t\""""u8; }} }} "; diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/VarDeclarationTest.cs index 3c023101..13ee4259 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/VarDeclarationTest.cs @@ -116,7 +116,7 @@ protected override Task NoInitializerTestImpl(string nativeType) protected override Task Utf8StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 ""Test"""; + var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@"using System; @@ -124,8 +124,8 @@ namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""#define MyMacro1 \""Test\"""")] - public static ReadOnlySpan MyMacro1 => ""Test""u8; + [NativeTypeName(""#define MyMacro1 \""Test\0\\\r\n\t\""\"""")] + public static ReadOnlySpan MyMacro1 => ""Test\0\\\r\n\t\""""u8; }} }} "; @@ -135,14 +135,14 @@ public static partial class Methods protected override Task Utf16StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 u""Test"""; + var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""#define MyMacro1 u\""Test\"""")] - public const string MyMacro1 = ""Test""; + [NativeTypeName(""#define MyMacro1 u\""Test\0\\\r\n\t\""\"""")] + public const string MyMacro1 = ""Test\0\\\r\n\t\""""; }} }} "; @@ -152,22 +152,22 @@ public static partial class Methods protected override Task WideStringLiteralConstTestImpl() { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; -const wchar_t* MyConst2 = L""Test""; -const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const wchar_t[5]"")] - public const string MyConst1 = ""Test""; + [NativeTypeName(""const wchar_t[11]"")] + public const string MyConst1 = ""Test\0\\\r\n\t\""""; [NativeTypeName(""const wchar_t *"")] - public static string MyConst2 = ""Test""; + public static string MyConst2 = ""Test\0\\\r\n\t\""""; [NativeTypeName(""const wchar_t *const"")] - public const string MyConst3 = ""Test""; + public const string MyConst3 = ""Test\0\\\r\n\t\""""; }} }} "; @@ -177,9 +177,9 @@ public static partial class Methods protected override Task StringLiteralConstTestImpl() { - var inputContents = $@"const char MyConst1[] = ""Test""; -const char* MyConst2 = ""Test""; -const char* const MyConst3 = ""Test"";"; + var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; +const char* MyConst2 = ""Test\0\\\r\n\t\""""; +const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"using System; @@ -187,14 +187,14 @@ namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const char[5]"")] - public static ReadOnlySpan MyConst1 => ""Test""u8; + [NativeTypeName(""const char[11]"")] + public static ReadOnlySpan MyConst1 => ""Test\0\\\r\n\t\""""u8; [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = ""Test""u8.ToArray(); + public static byte[] MyConst2 = ""Test\0\\\r\n\t\""""u8.ToArray(); [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => ""Test""u8; + public static ReadOnlySpan MyConst3 => ""Test\0\\\r\n\t\""""u8; }} }} "; @@ -204,22 +204,22 @@ public static partial class Methods protected override Task WideStringLiteralStaticConstTestImpl() { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; -static const wchar_t* MyConst2 = L""Test""; -static const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const wchar_t[5]"")] - public const string MyConst1 = ""Test""; + [NativeTypeName(""const wchar_t[11]"")] + public const string MyConst1 = ""Test\0\\\r\n\t\""""; [NativeTypeName(""const wchar_t *"")] - public static string MyConst2 = ""Test""; + public static string MyConst2 = ""Test\0\\\r\n\t\""""; [NativeTypeName(""const wchar_t *const"")] - public const string MyConst3 = ""Test""; + public const string MyConst3 = ""Test\0\\\r\n\t\""""; }} }} "; @@ -229,9 +229,9 @@ public static partial class Methods protected override Task StringLiteralStaticConstTestImpl() { - var inputContents = $@"static const char MyConst1[] = ""Test""; -static const char* MyConst2 = ""Test""; -static const char* const MyConst3 = ""Test"";"; + var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; +static const char* MyConst2 = ""Test\0\\\r\n\t\""""; +static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"using System; @@ -239,14 +239,14 @@ namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const char[5]"")] - public static ReadOnlySpan MyConst1 => ""Test""u8; + [NativeTypeName(""const char[11]"")] + public static ReadOnlySpan MyConst1 => ""Test\0\\\r\n\t\""""u8; [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = ""Test""u8.ToArray(); + public static byte[] MyConst2 = ""Test\0\\\r\n\t\""""u8.ToArray(); [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => ""Test""u8; + public static ReadOnlySpan MyConst3 => ""Test\0\\\r\n\t\""""u8; }} }} "; diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/VarDeclarationTest.cs index 0ad4d6ab..c90f5fec 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/VarDeclarationTest.cs @@ -116,7 +116,7 @@ protected override Task NoInitializerTestImpl(string nativeType) protected override Task Utf8StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 ""Test"""; + var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@"using System; @@ -124,8 +124,8 @@ namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""#define MyMacro1 \""Test\"""")] - public static ReadOnlySpan MyMacro1 => ""Test""u8; + [NativeTypeName(""#define MyMacro1 \""Test\0\\\r\n\t\""\"""")] + public static ReadOnlySpan MyMacro1 => ""Test\0\\\r\n\t\""""u8; }} }} "; @@ -135,14 +135,14 @@ public static partial class Methods protected override Task Utf16StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 u""Test"""; + var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""#define MyMacro1 u\""Test\"""")] - public const string MyMacro1 = ""Test""; + [NativeTypeName(""#define MyMacro1 u\""Test\0\\\r\n\t\""\"""")] + public const string MyMacro1 = ""Test\0\\\r\n\t\""""; }} }} "; @@ -152,9 +152,9 @@ public static partial class Methods protected override Task WideStringLiteralConstTestImpl() { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; -const wchar_t* MyConst2 = L""Test""; -const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"using System; @@ -162,14 +162,14 @@ namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const wchar_t[5]"")] - public static ReadOnlySpan MyConst1 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000]; + [NativeTypeName(""const wchar_t[11]"")] + public static ReadOnlySpan MyConst1 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; [NativeTypeName(""const wchar_t *"")] - public static uint[] MyConst2 = [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000]; + public static uint[] MyConst2 = [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; [NativeTypeName(""const wchar_t *const"")] - public static ReadOnlySpan MyConst3 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000]; + public static ReadOnlySpan MyConst3 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; }} }} "; @@ -179,9 +179,9 @@ public static partial class Methods protected override Task StringLiteralConstTestImpl() { - var inputContents = $@"const char MyConst1[] = ""Test""; -const char* MyConst2 = ""Test""; -const char* const MyConst3 = ""Test"";"; + var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; +const char* MyConst2 = ""Test\0\\\r\n\t\""""; +const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"using System; @@ -189,14 +189,14 @@ namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const char[5]"")] - public static ReadOnlySpan MyConst1 => ""Test""u8; + [NativeTypeName(""const char[11]"")] + public static ReadOnlySpan MyConst1 => ""Test\0\\\r\n\t\""""u8; [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = ""Test""u8.ToArray(); + public static byte[] MyConst2 = ""Test\0\\\r\n\t\""""u8.ToArray(); [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => ""Test""u8; + public static ReadOnlySpan MyConst3 => ""Test\0\\\r\n\t\""""u8; }} }} "; @@ -206,9 +206,9 @@ public static partial class Methods protected override Task WideStringLiteralStaticConstTestImpl() { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; -static const wchar_t* MyConst2 = L""Test""; -static const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"using System; @@ -216,14 +216,14 @@ namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const wchar_t[5]"")] - public static ReadOnlySpan MyConst1 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000]; + [NativeTypeName(""const wchar_t[11]"")] + public static ReadOnlySpan MyConst1 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; [NativeTypeName(""const wchar_t *"")] - public static uint[] MyConst2 = [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000]; + public static uint[] MyConst2 = [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; [NativeTypeName(""const wchar_t *const"")] - public static ReadOnlySpan MyConst3 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000]; + public static ReadOnlySpan MyConst3 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; }} }} "; @@ -233,9 +233,9 @@ public static partial class Methods protected override Task StringLiteralStaticConstTestImpl() { - var inputContents = $@"static const char MyConst1[] = ""Test""; -static const char* MyConst2 = ""Test""; -static const char* const MyConst3 = ""Test"";"; + var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; +static const char* MyConst2 = ""Test\0\\\r\n\t\""""; +static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"using System; @@ -243,14 +243,14 @@ namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const char[5]"")] - public static ReadOnlySpan MyConst1 => ""Test""u8; + [NativeTypeName(""const char[11]"")] + public static ReadOnlySpan MyConst1 => ""Test\0\\\r\n\t\""""u8; [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = ""Test""u8.ToArray(); + public static byte[] MyConst2 = ""Test\0\\\r\n\t\""""u8.ToArray(); [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => ""Test""u8; + public static ReadOnlySpan MyConst3 => ""Test\0\\\r\n\t\""""u8; }} }} "; diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/VarDeclarationTest.cs index 3507ad83..6386ad82 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/VarDeclarationTest.cs @@ -116,7 +116,7 @@ protected override Task NoInitializerTestImpl(string nativeType) protected override Task Utf8StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 ""Test"""; + var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@"using System; @@ -124,8 +124,8 @@ namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""#define MyMacro1 \""Test\"""")] - public static ReadOnlySpan MyMacro1 => ""Test""u8; + [NativeTypeName(""#define MyMacro1 \""Test\0\\\r\n\t\""\"""")] + public static ReadOnlySpan MyMacro1 => ""Test\0\\\r\n\t\""""u8; }} }} "; @@ -135,14 +135,14 @@ public static partial class Methods protected override Task Utf16StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 u""Test"""; + var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""#define MyMacro1 u\""Test\"""")] - public const string MyMacro1 = ""Test""; + [NativeTypeName(""#define MyMacro1 u\""Test\0\\\r\n\t\""\"""")] + public const string MyMacro1 = ""Test\0\\\r\n\t\""""; }} }} "; @@ -152,22 +152,22 @@ public static partial class Methods protected override Task WideStringLiteralConstTestImpl() { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; -const wchar_t* MyConst2 = L""Test""; -const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const wchar_t[5]"")] - public const string MyConst1 = ""Test""; + [NativeTypeName(""const wchar_t[11]"")] + public const string MyConst1 = ""Test\0\\\r\n\t\""""; [NativeTypeName(""const wchar_t *"")] - public static string MyConst2 = ""Test""; + public static string MyConst2 = ""Test\0\\\r\n\t\""""; [NativeTypeName(""const wchar_t *const"")] - public const string MyConst3 = ""Test""; + public const string MyConst3 = ""Test\0\\\r\n\t\""""; }} }} "; @@ -177,9 +177,9 @@ public static partial class Methods protected override Task StringLiteralConstTestImpl() { - var inputContents = $@"const char MyConst1[] = ""Test""; -const char* MyConst2 = ""Test""; -const char* const MyConst3 = ""Test"";"; + var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; +const char* MyConst2 = ""Test\0\\\r\n\t\""""; +const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"using System; @@ -187,14 +187,14 @@ namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const char[5]"")] - public static ReadOnlySpan MyConst1 => ""Test""u8; + [NativeTypeName(""const char[11]"")] + public static ReadOnlySpan MyConst1 => ""Test\0\\\r\n\t\""""u8; [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = ""Test""u8.ToArray(); + public static byte[] MyConst2 = ""Test\0\\\r\n\t\""""u8.ToArray(); [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => ""Test""u8; + public static ReadOnlySpan MyConst3 => ""Test\0\\\r\n\t\""""u8; }} }} "; @@ -204,22 +204,22 @@ public static partial class Methods protected override Task WideStringLiteralStaticConstTestImpl() { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; -static const wchar_t* MyConst2 = L""Test""; -static const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const wchar_t[5]"")] - public const string MyConst1 = ""Test""; + [NativeTypeName(""const wchar_t[11]"")] + public const string MyConst1 = ""Test\0\\\r\n\t\""""; [NativeTypeName(""const wchar_t *"")] - public static string MyConst2 = ""Test""; + public static string MyConst2 = ""Test\0\\\r\n\t\""""; [NativeTypeName(""const wchar_t *const"")] - public const string MyConst3 = ""Test""; + public const string MyConst3 = ""Test\0\\\r\n\t\""""; }} }} "; @@ -229,9 +229,9 @@ public static partial class Methods protected override Task StringLiteralStaticConstTestImpl() { - var inputContents = $@"static const char MyConst1[] = ""Test""; -static const char* MyConst2 = ""Test""; -static const char* const MyConst3 = ""Test"";"; + var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; +static const char* MyConst2 = ""Test\0\\\r\n\t\""""; +static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@"using System; @@ -239,14 +239,14 @@ namespace ClangSharp.Test {{ public static partial class Methods {{ - [NativeTypeName(""const char[5]"")] - public static ReadOnlySpan MyConst1 => ""Test""u8; + [NativeTypeName(""const char[11]"")] + public static ReadOnlySpan MyConst1 => ""Test\0\\\r\n\t\""""u8; [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = ""Test""u8.ToArray(); + public static byte[] MyConst2 = ""Test\0\\\r\n\t\""""u8.ToArray(); [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => ""Test""u8; + public static ReadOnlySpan MyConst3 => ""Test\0\\\r\n\t\""""u8; }} }} "; diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/VarDeclarationTest.cs index 59996e28..45f7a3fa 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/VarDeclarationTest.cs @@ -143,7 +143,7 @@ protected override Task NoInitializerTestImpl(string nativeType) protected override Task Utf8StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 ""Test"""; + var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@" @@ -152,7 +152,7 @@ protected override Task Utf8StringLiteralMacroTestImpl() ReadOnlySpan<byte> - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} @@ -165,7 +165,7 @@ protected override Task Utf8StringLiteralMacroTestImpl() protected override Task Utf16StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 u""Test"""; + var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@" @@ -174,7 +174,7 @@ protected override Task Utf16StringLiteralMacroTestImpl() string - ""Test"" + ""Test\0\\\r\n\t\"""" @@ -187,9 +187,9 @@ protected override Task Utf16StringLiteralMacroTestImpl() protected override Task WideStringLiteralConstTestImpl() { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; -const wchar_t* MyConst2 = L""Test""; -const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -198,19 +198,19 @@ protected override Task WideStringLiteralConstTestImpl() uint[] - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }} + new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} uint[] - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }} + new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} uint[] - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }} + new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} @@ -223,9 +223,9 @@ protected override Task WideStringLiteralConstTestImpl() protected override Task StringLiteralConstTestImpl() { - var inputContents = $@"const char MyConst1[] = ""Test""; -const char* MyConst2 = ""Test""; -const char* const MyConst3 = ""Test"";"; + var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; +const char* MyConst2 = ""Test\0\\\r\n\t\""""; +const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -234,19 +234,19 @@ protected override Task StringLiteralConstTestImpl() ReadOnlySpan<byte> - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} byte[] - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} ReadOnlySpan<byte> - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} @@ -259,9 +259,9 @@ protected override Task StringLiteralConstTestImpl() protected override Task WideStringLiteralStaticConstTestImpl() { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; -static const wchar_t* MyConst2 = L""Test""; -static const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -270,19 +270,19 @@ protected override Task WideStringLiteralStaticConstTestImpl() uint[] - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }} + new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} uint[] - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }} + new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} uint[] - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }} + new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} @@ -295,9 +295,9 @@ protected override Task WideStringLiteralStaticConstTestImpl() protected override Task StringLiteralStaticConstTestImpl() { - var inputContents = $@"static const char MyConst1[] = ""Test""; -static const char* MyConst2 = ""Test""; -static const char* const MyConst3 = ""Test"";"; + var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; +static const char* MyConst2 = ""Test\0\\\r\n\t\""""; +static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -306,19 +306,19 @@ protected override Task StringLiteralStaticConstTestImpl() ReadOnlySpan<byte> - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} byte[] - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} ReadOnlySpan<byte> - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/VarDeclarationTest.cs index b2b1ca53..e051510b 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/VarDeclarationTest.cs @@ -143,7 +143,7 @@ protected override Task NoInitializerTestImpl(string nativeType) protected override Task Utf8StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 ""Test"""; + var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@" @@ -152,7 +152,7 @@ protected override Task Utf8StringLiteralMacroTestImpl() ReadOnlySpan<byte> - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} @@ -165,7 +165,7 @@ protected override Task Utf8StringLiteralMacroTestImpl() protected override Task Utf16StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 u""Test"""; + var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@" @@ -174,7 +174,7 @@ protected override Task Utf16StringLiteralMacroTestImpl() string - ""Test"" + ""Test\0\\\r\n\t\"""" @@ -187,9 +187,9 @@ protected override Task Utf16StringLiteralMacroTestImpl() protected override Task WideStringLiteralConstTestImpl() { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; -const wchar_t* MyConst2 = L""Test""; -const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -198,19 +198,19 @@ protected override Task WideStringLiteralConstTestImpl() string - ""Test"" + ""Test\0\\\r\n\t\"""" string - ""Test"" + ""Test\0\\\r\n\t\"""" string - ""Test"" + ""Test\0\\\r\n\t\"""" @@ -223,9 +223,9 @@ protected override Task WideStringLiteralConstTestImpl() protected override Task StringLiteralConstTestImpl() { - var inputContents = $@"const char MyConst1[] = ""Test""; -const char* MyConst2 = ""Test""; -const char* const MyConst3 = ""Test"";"; + var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; +const char* MyConst2 = ""Test\0\\\r\n\t\""""; +const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -234,19 +234,19 @@ protected override Task StringLiteralConstTestImpl() ReadOnlySpan<byte> - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} byte[] - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} ReadOnlySpan<byte> - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} @@ -259,9 +259,9 @@ protected override Task StringLiteralConstTestImpl() protected override Task WideStringLiteralStaticConstTestImpl() { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; -static const wchar_t* MyConst2 = L""Test""; -static const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -270,19 +270,19 @@ protected override Task WideStringLiteralStaticConstTestImpl() string - ""Test"" + ""Test\0\\\r\n\t\"""" string - ""Test"" + ""Test\0\\\r\n\t\"""" string - ""Test"" + ""Test\0\\\r\n\t\"""" @@ -295,9 +295,9 @@ protected override Task WideStringLiteralStaticConstTestImpl() protected override Task StringLiteralStaticConstTestImpl() { - var inputContents = $@"static const char MyConst1[] = ""Test""; -static const char* MyConst2 = ""Test""; -static const char* const MyConst3 = ""Test"";"; + var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; +static const char* MyConst2 = ""Test\0\\\r\n\t\""""; +static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -306,19 +306,19 @@ protected override Task StringLiteralStaticConstTestImpl() ReadOnlySpan<byte> - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} byte[] - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} ReadOnlySpan<byte> - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/VarDeclarationTest.cs index 0687fe3d..47830d15 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/VarDeclarationTest.cs @@ -143,7 +143,7 @@ protected override Task NoInitializerTestImpl(string nativeType) protected override Task Utf8StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 ""Test"""; + var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@" @@ -152,7 +152,7 @@ protected override Task Utf8StringLiteralMacroTestImpl() ReadOnlySpan<byte> - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} @@ -165,7 +165,7 @@ protected override Task Utf8StringLiteralMacroTestImpl() protected override Task Utf16StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 u""Test"""; + var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@" @@ -174,7 +174,7 @@ protected override Task Utf16StringLiteralMacroTestImpl() string - ""Test"" + ""Test\0\\\r\n\t\"""" @@ -187,9 +187,9 @@ protected override Task Utf16StringLiteralMacroTestImpl() protected override Task WideStringLiteralConstTestImpl() { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; -const wchar_t* MyConst2 = L""Test""; -const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -198,19 +198,19 @@ protected override Task WideStringLiteralConstTestImpl() uint[] - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }} + new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} uint[] - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }} + new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} uint[] - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }} + new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} @@ -223,9 +223,9 @@ protected override Task WideStringLiteralConstTestImpl() protected override Task StringLiteralConstTestImpl() { - var inputContents = $@"const char MyConst1[] = ""Test""; -const char* MyConst2 = ""Test""; -const char* const MyConst3 = ""Test"";"; + var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; +const char* MyConst2 = ""Test\0\\\r\n\t\""""; +const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -234,19 +234,19 @@ protected override Task StringLiteralConstTestImpl() ReadOnlySpan<byte> - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} byte[] - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} ReadOnlySpan<byte> - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} @@ -259,9 +259,9 @@ protected override Task StringLiteralConstTestImpl() protected override Task WideStringLiteralStaticConstTestImpl() { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; -static const wchar_t* MyConst2 = L""Test""; -static const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -270,19 +270,19 @@ protected override Task WideStringLiteralStaticConstTestImpl() uint[] - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }} + new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} uint[] - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }} + new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} uint[] - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }} + new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} @@ -295,9 +295,9 @@ protected override Task WideStringLiteralStaticConstTestImpl() protected override Task StringLiteralStaticConstTestImpl() { - var inputContents = $@"static const char MyConst1[] = ""Test""; -static const char* MyConst2 = ""Test""; -static const char* const MyConst3 = ""Test"";"; + var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; +static const char* MyConst2 = ""Test\0\\\r\n\t\""""; +static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -306,19 +306,19 @@ protected override Task StringLiteralStaticConstTestImpl() ReadOnlySpan<byte> - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} byte[] - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} ReadOnlySpan<byte> - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/VarDeclarationTest.cs index 232fa3da..1838ec4b 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/VarDeclarationTest.cs @@ -143,7 +143,7 @@ protected override Task NoInitializerTestImpl(string nativeType) protected override Task Utf8StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 ""Test"""; + var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@" @@ -152,7 +152,7 @@ protected override Task Utf8StringLiteralMacroTestImpl() ReadOnlySpan<byte> - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} @@ -165,7 +165,7 @@ protected override Task Utf8StringLiteralMacroTestImpl() protected override Task Utf16StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 u""Test"""; + var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@" @@ -174,7 +174,7 @@ protected override Task Utf16StringLiteralMacroTestImpl() string - ""Test"" + ""Test\0\\\r\n\t\"""" @@ -187,9 +187,9 @@ protected override Task Utf16StringLiteralMacroTestImpl() protected override Task WideStringLiteralConstTestImpl() { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; -const wchar_t* MyConst2 = L""Test""; -const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -198,19 +198,19 @@ protected override Task WideStringLiteralConstTestImpl() string - ""Test"" + ""Test\0\\\r\n\t\"""" string - ""Test"" + ""Test\0\\\r\n\t\"""" string - ""Test"" + ""Test\0\\\r\n\t\"""" @@ -223,9 +223,9 @@ protected override Task WideStringLiteralConstTestImpl() protected override Task StringLiteralConstTestImpl() { - var inputContents = $@"const char MyConst1[] = ""Test""; -const char* MyConst2 = ""Test""; -const char* const MyConst3 = ""Test"";"; + var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; +const char* MyConst2 = ""Test\0\\\r\n\t\""""; +const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -234,19 +234,19 @@ protected override Task StringLiteralConstTestImpl() ReadOnlySpan<byte> - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} byte[] - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} ReadOnlySpan<byte> - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} @@ -259,9 +259,9 @@ protected override Task StringLiteralConstTestImpl() protected override Task WideStringLiteralStaticConstTestImpl() { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; -static const wchar_t* MyConst2 = L""Test""; -static const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -270,19 +270,19 @@ protected override Task WideStringLiteralStaticConstTestImpl() string - ""Test"" + ""Test\0\\\r\n\t\"""" string - ""Test"" + ""Test\0\\\r\n\t\"""" string - ""Test"" + ""Test\0\\\r\n\t\"""" @@ -295,9 +295,9 @@ protected override Task WideStringLiteralStaticConstTestImpl() protected override Task StringLiteralStaticConstTestImpl() { - var inputContents = $@"static const char MyConst1[] = ""Test""; -static const char* MyConst2 = ""Test""; -static const char* const MyConst3 = ""Test"";"; + var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; +static const char* MyConst2 = ""Test\0\\\r\n\t\""""; +static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -306,19 +306,19 @@ protected override Task StringLiteralStaticConstTestImpl() ReadOnlySpan<byte> - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} byte[] - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} ReadOnlySpan<byte> - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00 }} + new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/VarDeclarationTest.cs index 369debcc..3f25701e 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/VarDeclarationTest.cs @@ -143,7 +143,7 @@ protected override Task NoInitializerTestImpl(string nativeType) protected override Task Utf8StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 ""Test"""; + var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@" @@ -152,7 +152,7 @@ protected override Task Utf8StringLiteralMacroTestImpl() ReadOnlySpan<byte> - ""Test""u8 + ""Test\0\\\r\n\t\""""u8 @@ -165,7 +165,7 @@ protected override Task Utf8StringLiteralMacroTestImpl() protected override Task Utf16StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 u""Test"""; + var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@" @@ -174,7 +174,7 @@ protected override Task Utf16StringLiteralMacroTestImpl() string - ""Test"" + ""Test\0\\\r\n\t\"""" @@ -187,9 +187,9 @@ protected override Task Utf16StringLiteralMacroTestImpl() protected override Task WideStringLiteralConstTestImpl() { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; -const wchar_t* MyConst2 = L""Test""; -const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -198,19 +198,19 @@ protected override Task WideStringLiteralConstTestImpl() ReadOnlySpan<uint> - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }} + new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} uint[] - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }} + new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} ReadOnlySpan<uint> - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }} + new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} @@ -223,9 +223,9 @@ protected override Task WideStringLiteralConstTestImpl() protected override Task StringLiteralConstTestImpl() { - var inputContents = $@"const char MyConst1[] = ""Test""; -const char* MyConst2 = ""Test""; -const char* const MyConst3 = ""Test"";"; + var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; +const char* MyConst2 = ""Test\0\\\r\n\t\""""; +const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -234,19 +234,19 @@ protected override Task StringLiteralConstTestImpl() ReadOnlySpan<byte> - ""Test""u8 + ""Test\0\\\r\n\t\""""u8 byte[] - ""Test""u8.ToArray() + ""Test\0\\\r\n\t\""""u8.ToArray() ReadOnlySpan<byte> - ""Test""u8 + ""Test\0\\\r\n\t\""""u8 @@ -259,9 +259,9 @@ protected override Task StringLiteralConstTestImpl() protected override Task WideStringLiteralStaticConstTestImpl() { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; -static const wchar_t* MyConst2 = L""Test""; -static const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -270,19 +270,19 @@ protected override Task WideStringLiteralStaticConstTestImpl() ReadOnlySpan<uint> - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }} + new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} uint[] - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }} + new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} ReadOnlySpan<uint> - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000 }} + new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} @@ -295,9 +295,9 @@ protected override Task WideStringLiteralStaticConstTestImpl() protected override Task StringLiteralStaticConstTestImpl() { - var inputContents = $@"static const char MyConst1[] = ""Test""; -static const char* MyConst2 = ""Test""; -static const char* const MyConst3 = ""Test"";"; + var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; +static const char* MyConst2 = ""Test\0\\\r\n\t\""""; +static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -306,19 +306,19 @@ protected override Task StringLiteralStaticConstTestImpl() ReadOnlySpan<byte> - ""Test""u8 + ""Test\0\\\r\n\t\""""u8 byte[] - ""Test""u8.ToArray() + ""Test\0\\\r\n\t\""""u8.ToArray() ReadOnlySpan<byte> - ""Test""u8 + ""Test\0\\\r\n\t\""""u8 diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/VarDeclarationTest.cs index 84ca154a..720b0e90 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/VarDeclarationTest.cs @@ -144,7 +144,7 @@ protected override Task NoInitializerTestImpl(string nativeType) protected override Task Utf8StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 ""Test"""; + var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@" @@ -153,7 +153,7 @@ protected override Task Utf8StringLiteralMacroTestImpl() ReadOnlySpan<byte> - ""Test""u8 + ""Test\0\\\r\n\t\""""u8 @@ -166,7 +166,7 @@ protected override Task Utf8StringLiteralMacroTestImpl() protected override Task Utf16StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 u""Test"""; + var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@" @@ -175,7 +175,7 @@ protected override Task Utf16StringLiteralMacroTestImpl() string - ""Test"" + ""Test\0\\\r\n\t\"""" @@ -188,9 +188,9 @@ protected override Task Utf16StringLiteralMacroTestImpl() protected override Task WideStringLiteralConstTestImpl() { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; -const wchar_t* MyConst2 = L""Test""; -const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -199,19 +199,19 @@ protected override Task WideStringLiteralConstTestImpl() string - ""Test"" + ""Test\0\\\r\n\t\"""" string - ""Test"" + ""Test\0\\\r\n\t\"""" string - ""Test"" + ""Test\0\\\r\n\t\"""" @@ -224,9 +224,9 @@ protected override Task WideStringLiteralConstTestImpl() protected override Task StringLiteralConstTestImpl() { - var inputContents = $@"const char MyConst1[] = ""Test""; -const char* MyConst2 = ""Test""; -const char* const MyConst3 = ""Test"";"; + var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; +const char* MyConst2 = ""Test\0\\\r\n\t\""""; +const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -235,19 +235,19 @@ protected override Task StringLiteralConstTestImpl() ReadOnlySpan<byte> - ""Test""u8 + ""Test\0\\\r\n\t\""""u8 byte[] - ""Test""u8.ToArray() + ""Test\0\\\r\n\t\""""u8.ToArray() ReadOnlySpan<byte> - ""Test""u8 + ""Test\0\\\r\n\t\""""u8 @@ -260,9 +260,9 @@ protected override Task StringLiteralConstTestImpl() protected override Task WideStringLiteralStaticConstTestImpl() { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; -static const wchar_t* MyConst2 = L""Test""; -static const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -271,19 +271,19 @@ protected override Task WideStringLiteralStaticConstTestImpl() string - ""Test"" + ""Test\0\\\r\n\t\"""" string - ""Test"" + ""Test\0\\\r\n\t\"""" string - ""Test"" + ""Test\0\\\r\n\t\"""" @@ -296,9 +296,9 @@ protected override Task WideStringLiteralStaticConstTestImpl() protected override Task StringLiteralStaticConstTestImpl() { - var inputContents = $@"static const char MyConst1[] = ""Test""; -static const char* MyConst2 = ""Test""; -static const char* const MyConst3 = ""Test"";"; + var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; +static const char* MyConst2 = ""Test\0\\\r\n\t\""""; +static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -307,19 +307,19 @@ protected override Task StringLiteralStaticConstTestImpl() ReadOnlySpan<byte> - ""Test""u8 + ""Test\0\\\r\n\t\""""u8 byte[] - ""Test""u8.ToArray() + ""Test\0\\\r\n\t\""""u8.ToArray() ReadOnlySpan<byte> - ""Test""u8 + ""Test\0\\\r\n\t\""""u8 diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/VarDeclarationTest.cs index fbc6c8e3..d6416f80 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/VarDeclarationTest.cs @@ -143,7 +143,7 @@ protected override Task NoInitializerTestImpl(string nativeType) protected override Task Utf8StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 ""Test"""; + var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@" @@ -152,7 +152,7 @@ protected override Task Utf8StringLiteralMacroTestImpl() ReadOnlySpan<byte> - ""Test""u8 + ""Test\0\\\r\n\t\""""u8 @@ -165,7 +165,7 @@ protected override Task Utf8StringLiteralMacroTestImpl() protected override Task Utf16StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 u""Test"""; + var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@" @@ -174,7 +174,7 @@ protected override Task Utf16StringLiteralMacroTestImpl() string - ""Test"" + ""Test\0\\\r\n\t\"""" @@ -187,9 +187,9 @@ protected override Task Utf16StringLiteralMacroTestImpl() protected override Task WideStringLiteralConstTestImpl() { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; -const wchar_t* MyConst2 = L""Test""; -const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -198,19 +198,19 @@ protected override Task WideStringLiteralConstTestImpl() ReadOnlySpan<uint> - [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000] + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] uint[] - [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000] + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] ReadOnlySpan<uint> - [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000] + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] @@ -223,9 +223,9 @@ protected override Task WideStringLiteralConstTestImpl() protected override Task StringLiteralConstTestImpl() { - var inputContents = $@"const char MyConst1[] = ""Test""; -const char* MyConst2 = ""Test""; -const char* const MyConst3 = ""Test"";"; + var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; +const char* MyConst2 = ""Test\0\\\r\n\t\""""; +const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -234,19 +234,19 @@ protected override Task StringLiteralConstTestImpl() ReadOnlySpan<byte> - ""Test""u8 + ""Test\0\\\r\n\t\""""u8 byte[] - ""Test""u8.ToArray() + ""Test\0\\\r\n\t\""""u8.ToArray() ReadOnlySpan<byte> - ""Test""u8 + ""Test\0\\\r\n\t\""""u8 @@ -259,9 +259,9 @@ protected override Task StringLiteralConstTestImpl() protected override Task WideStringLiteralStaticConstTestImpl() { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; -static const wchar_t* MyConst2 = L""Test""; -static const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -270,19 +270,19 @@ protected override Task WideStringLiteralStaticConstTestImpl() ReadOnlySpan<uint> - [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000] + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] uint[] - [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000] + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] ReadOnlySpan<uint> - [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000] + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] @@ -295,9 +295,9 @@ protected override Task WideStringLiteralStaticConstTestImpl() protected override Task StringLiteralStaticConstTestImpl() { - var inputContents = $@"static const char MyConst1[] = ""Test""; -static const char* MyConst2 = ""Test""; -static const char* const MyConst3 = ""Test"";"; + var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; +static const char* MyConst2 = ""Test\0\\\r\n\t\""""; +static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -306,19 +306,19 @@ protected override Task StringLiteralStaticConstTestImpl() ReadOnlySpan<byte> - ""Test""u8 + ""Test\0\\\r\n\t\""""u8 byte[] - ""Test""u8.ToArray() + ""Test\0\\\r\n\t\""""u8.ToArray() ReadOnlySpan<byte> - ""Test""u8 + ""Test\0\\\r\n\t\""""u8 diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/VarDeclarationTest.cs index b81a2c91..dd8ed9a3 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/VarDeclarationTest.cs @@ -143,7 +143,7 @@ protected override Task NoInitializerTestImpl(string nativeType) protected override Task Utf8StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 ""Test"""; + var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@" @@ -152,7 +152,7 @@ protected override Task Utf8StringLiteralMacroTestImpl() ReadOnlySpan<byte> - ""Test""u8 + ""Test\0\\\r\n\t\""""u8 @@ -165,7 +165,7 @@ protected override Task Utf8StringLiteralMacroTestImpl() protected override Task Utf16StringLiteralMacroTestImpl() { - var inputContents = $@"#define MyMacro1 u""Test"""; + var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; var expectedOutputContents = $@" @@ -174,7 +174,7 @@ protected override Task Utf16StringLiteralMacroTestImpl() string - ""Test"" + ""Test\0\\\r\n\t\"""" @@ -187,9 +187,9 @@ protected override Task Utf16StringLiteralMacroTestImpl() protected override Task WideStringLiteralConstTestImpl() { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; -const wchar_t* MyConst2 = L""Test""; -const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -198,19 +198,19 @@ protected override Task WideStringLiteralConstTestImpl() string - ""Test"" + ""Test\0\\\r\n\t\"""" string - ""Test"" + ""Test\0\\\r\n\t\"""" string - ""Test"" + ""Test\0\\\r\n\t\"""" @@ -223,9 +223,9 @@ protected override Task WideStringLiteralConstTestImpl() protected override Task StringLiteralConstTestImpl() { - var inputContents = $@"const char MyConst1[] = ""Test""; -const char* MyConst2 = ""Test""; -const char* const MyConst3 = ""Test"";"; + var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; +const char* MyConst2 = ""Test\0\\\r\n\t\""""; +const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -234,19 +234,19 @@ protected override Task StringLiteralConstTestImpl() ReadOnlySpan<byte> - ""Test""u8 + ""Test\0\\\r\n\t\""""u8 byte[] - ""Test""u8.ToArray() + ""Test\0\\\r\n\t\""""u8.ToArray() ReadOnlySpan<byte> - ""Test""u8 + ""Test\0\\\r\n\t\""""u8 @@ -259,9 +259,9 @@ protected override Task StringLiteralConstTestImpl() protected override Task WideStringLiteralStaticConstTestImpl() { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; -static const wchar_t* MyConst2 = L""Test""; -static const wchar_t* const MyConst3 = L""Test"";"; + var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -270,19 +270,19 @@ protected override Task WideStringLiteralStaticConstTestImpl() string - ""Test"" + ""Test\0\\\r\n\t\"""" string - ""Test"" + ""Test\0\\\r\n\t\"""" string - ""Test"" + ""Test\0\\\r\n\t\"""" @@ -295,9 +295,9 @@ protected override Task WideStringLiteralStaticConstTestImpl() protected override Task StringLiteralStaticConstTestImpl() { - var inputContents = $@"static const char MyConst1[] = ""Test""; -static const char* MyConst2 = ""Test""; -static const char* const MyConst3 = ""Test"";"; + var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; +static const char* MyConst2 = ""Test\0\\\r\n\t\""""; +static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; var expectedOutputContents = $@" @@ -306,19 +306,19 @@ protected override Task StringLiteralStaticConstTestImpl() ReadOnlySpan<byte> - ""Test""u8 + ""Test\0\\\r\n\t\""""u8 byte[] - ""Test""u8.ToArray() + ""Test\0\\\r\n\t\""""u8.ToArray() ReadOnlySpan<byte> - ""Test""u8 + ""Test\0\\\r\n\t\""""u8