Skip to content

Commit

Permalink
fix(cs): generator lingering $
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmd5 committed Aug 12, 2024
1 parent 38f4545 commit ccb3e2f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 6 additions & 2 deletions Core/Generators/CSharp/CSharpGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,8 @@ private string CompileDecodeUnion(UnionDefinition definition)
/// </summary>
private void CompileUnionFamily(IndentedStringBuilder builder, UnionDefinition ud)
{


var recordAttribute = "[global::Bebop.Attributes.BebopRecord(global::Bebop.Runtime.BebopKind.Union)]";
var genericPositionalArguments = string.Join(", ", ud.Branches.Select(b => $"T{b.GenericIndex()}")).Trim();
var genericTypeArguments = string.Join(", ", ud.Branches.Select(b => $"{PrefixNamespace(b.Definition.ClassName())}")).Trim();
Expand All @@ -497,6 +499,7 @@ private void CompileUnionFamily(IndentedStringBuilder builder, UnionDefinition u
var interfaceName = $"I{ud.ClassName()}Member";



var nullCheck = LanguageVersion == CSharpNine ? "is null" : "== null";
var notNullCheck = LanguageVersion == CSharpNine ? "is not null" : "!= null";
var isCheck = LanguageVersion == CSharpNine ? "is" : "==";
Expand Down Expand Up @@ -603,7 +606,7 @@ void CompileUnionInterface()
builder.AppendLine($"/// Interface for members of the {ud.ClassName()} union");
builder.AppendLine("/// </summary>");
builder.AppendLine(GeneratedAttribute);
builder.AppendLine($"public partial interface ${interfaceName} {{").Indent(indentStep);
builder.AppendLine($"public partial interface {interfaceName} {{").Indent(indentStep);

builder.Dedent(indentStep).AppendLine("}").AppendLine();
}
Expand Down Expand Up @@ -757,10 +760,11 @@ void CompileUnionConcreteClass()

builder.Dedent(indentStep).AppendLine("}").AppendLine();
}
CompileUnionInterface();

CompileUnionBaseClass();
CompileUnionConcreteClass();
CompileUnionStruct();
CompileUnionInterface();
}

#endregion
Expand Down
3 changes: 1 addition & 2 deletions Laboratory/C#/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# C# Bebop Laboratory

To run the C# tests, from PowerShell:

dotnet run --project ..\..\Compiler\ --cs ".\GeneratedTestCode\Output.g.cs" --namespace Bebop.Codegen --files (gci ..\Schemas\Valid\*.bop)
dotnet run --project ../../Compiler/ -i ../Schemas/Valid/*.bop build -g "cs:./GeneratedTestCode/Output.g.cs,namespace=Bebop.Codegen"
dotnet test -nowarn:CS0618

0 comments on commit ccb3e2f

Please sign in to comment.