Open
Description
We encountered an issue where generated code results in compilation errors when using directives are conditionally included using #if / #endif.
Here is a minimal reproducible example:
#if !MASTER_MEMORY_DISABLED
using MasterMemory;
using MessagePack;
#endif
namespace Example1
{
#if !MASTER_MEMORY_DISABLED
[MemoryTable("person")]
[MessagePackObject(true)]
#endif
public record Person
{
#if !MASTER_MEMORY_DISABLED
[PrimaryKey]
#endif
public int Id { get; set; }
}
}
When using this pattern, the generated code causes compilation errors with the following messages:
MasterMemory.SourceGenerator/MasterMemory.SourceGenerator.MasterMemoryGenerator/MasterMemory.DatabaseBuilder.g.cs(29,2): error CS1027: #endif directive expected
MasterMemory.SourceGenerator/MasterMemory.SourceGenerator.MasterMemoryGenerator/MasterMemory.ImmutableBuilder.g.cs(64,2): error CS1027: #endif directive expected
MasterMemory.SourceGenerator/MasterMemory.SourceGenerator.MasterMemoryGenerator/MasterMemory.MemoryDatabase.g.cs(129,2): error CS1027: #endif directive expected
MasterMemory.SourceGenerator/MasterMemory.SourceGenerator.MasterMemoryGenerator/MasterMemory.MasterMemoryResolver.g.cs(70,2): error CS1027: #endif directive expected
MasterMemory.SourceGenerator/MasterMemory.SourceGenerator.MasterMemoryGenerator/MasterMemory.PersonTable.g.cs(105,2): error CS1027: #endif directive expected
We’d appreciate it if you could take a look and consider supporting this pattern.
Metadata
Metadata
Assignees
Labels
No labels