TUnit: Bug - Code Generator fails on string escape sequences and nullable annotated bytes.
I have a branch for my project, trying to convert to TUnit - https://github.com/SharpMUSH/SharpMUSH/tree/TUnit
However, when I run a build, it fails on the CodeGeneration step of TUnit. I would inspect it, myself to see what lies at the source of this, but the files are not there when the generation fails.
Build failure: https://github.com/SharpMUSH/SharpMUSH/actions/runs/10967113289/job/30456269303
D:\SharpMUSH\SharpMUSH.Tests\obj\Debug\net8.0\TUnit.Engine.SourceGenerator\TUnit.Engine.SourceGenerator.CodeGenerators.TestsGenerator\ANSI_StringFunctionUnitTests_6d4f9a184b1643f1aa38939779ad444e.Generated.cs(21,38): error CS1525: Invalid expression term ';' [D:\SharpMUSH\SharpMUSH.Tests\SharpMUSH.Tests.csproj]
D:\SharpMUSH\SharpMUSH.Tests\obj\Debug\net8.0\TUnit.Engine.SourceGenerator\TUnit.Engine.SourceGenerator.CodeGenerators.TestsGenerator\ANSI_StringFunctionUnitTests_63f9bdb954cb4113951ebca02dec1a3f.Generated.cs(21,38): error CS1525: Invalid expression term ';' [D:\SharpMUSH\SharpMUSH.Tests\SharpMUSH.Tests.csproj]
D:\SharpMUSH\SharpMUSH.Tests\obj\Debug\net8.0\TUnit.Engine.SourceGenerator\TUnit.Engine.SourceGenerator.CodeGenerators.TestsGenerator\ANSIBackground_StringFunctionUnitTests_e019f1f3687a4844b495b947601aaf7f.Generated.cs(21,38): error CS1525: Invalid expression term ';' [D:\SharpMUSH\SharpMUSH.Tests\SharpMUSH.Tests.csproj]
D:\SharpMUSH\SharpMUSH.Tests\obj\Debug\net8.0\TUnit.Engine.SourceGenerator\TUnit.Engine.SourceGenerator.CodeGenerators.TestsGenerator\ANSIBackground_StringFunctionUnitTests_57c663cdb02d4e30bc56189193dec533.Generated.cs(21,38): error CS1525: Invalid expression term ';' [D:\SharpMUSH\SharpMUSH.Tests\SharpMUSH.Tests.csproj]
D:\SharpMUSH\SharpMUSH.Tests\obj\Debug\net8.0\TUnit.Engine.SourceGenerator\TUnit.Engine.SourceGenerator.CodeGenerators.TestsGenerator\Test_FunctionUnitTests_2fa6f6d356ab4af3b6a65198d6e38199.Generated.cs(18,50): error CS1009: Unrecognized escape sequence [D:\SharpMUSH\SharpMUSH.Tests\SharpMUSH.Tests.csproj]
D:\SharpMUSH\SharpMUSH.Tests\obj\Debug\net8.0\TUnit.Engine.SourceGenerator\TUnit.Engine.SourceGenerator.CodeGenerators.TestsGenerator\Test_FunctionUnitTests_2fa6f6d356ab4af3b6a65198d6e38199.Generated.cs(54,37): error CS1009: Unrecognized escape sequence [D:\SharpMUSH\SharpMUSH.Tests\SharpMUSH.Tests.csproj]
D:\SharpMUSH\SharpMUSH.Tests\obj\Debug\net8.0\TUnit.Engine.SourceGenerator\TUnit.Engine.SourceGenerator.CodeGenerators.TestsGenerator\Test_FunctionUnitTests_e11ab05ffb2c4b0496addd4cb43df1ed.Generated.cs(19,43): error CS1009: Unrecognized escape sequence [D:\SharpMUSH\SharpMUSH.Tests\SharpMUSH.Tests.csproj]
D:\SharpMUSH\SharpMUSH.Tests\obj\Debug\net8.0\TUnit.Engine.SourceGenerator\TUnit.Engine.SourceGenerator.CodeGenerators.TestsGenerator\Test_FunctionUnitTests_e11ab05ffb2c4b0496addd4cb43df1ed.Generated.cs(54,53): error CS1009: Unrecognized escape sequence [D:\SharpMUSH\SharpMUSH.Tests\SharpMUSH.Tests.csproj]
D:\SharpMUSH\SharpMUSH.Tests\obj\Debug\net8.0\TestPlatformEntryPoint.cs(10,66): error CS8892: Method 'TestingPlatformEntryPoint.Main(string[])' will not be used as an entry point because a synchronous entry point 'AutoGeneratedProgram.Main(string[])' was found. [D:\SharpMUSH\SharpMUSH.Tests\SharpMUSH.Tests.csproj]
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 21 (8 by maintainers)
Cheers for the repro. Can you raise a separate issue for the byte issue and I’ll take a look tomorrow if I can!
That did the trick. And the tests are running. Some fixing left to do on my end, and I’ll get back to you again.
Will do in a few hours, and I’ll report back to you!
I’ll see if I can figure out TUnit’s source generation on my side while you are busy, and try to generate a Pull Review. But no guarantees.
https://github.com/HarryCordewener/TUnit/tree/ISSUE%23575-Failing-CodeGeneration
Edit: I am likely missing something obvious. Because changes to
TypedConstantParser.csandArguments.cs’s MapValue are not adjusting the code generation when I emit them into TUnit.TestProject.Thanks! I’m a bit busy the next few days so might have to leave it with me but I’ll try and reproduce and get a fix out. Thanks for the report
This originates from here. You may be able to source-generate using
@"string"string formats instead of a plain"string".