Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate C# ModuleDef to V9 #1670

Merged
merged 15 commits into from
Dec 16, 2024
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion crates/bindings-csharp/BSATN.Codegen/Type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,13 @@ public void Write(System.IO.BinaryWriter writer, {{FullName}} value) {
{{write}}
}

public SpacetimeDB.BSATN.AlgebraicType GetAlgebraicType(SpacetimeDB.BSATN.ITypeRegistrar registrar) =>
public SpacetimeDB.BSATN.AlgebraicType.Ref GetAlgebraicType(SpacetimeDB.BSATN.ITypeRegistrar registrar) =>
RReverser marked this conversation as resolved.
Show resolved Hide resolved
registrar.RegisterType<{{FullName}}>(_ => new SpacetimeDB.BSATN.AlgebraicType.{{Kind}}(new SpacetimeDB.BSATN.AggregateElement[] {
{{MemberDeclaration.GenerateDefs(Members)}}
}));

SpacetimeDB.BSATN.AlgebraicType SpacetimeDB.BSATN.IReadWrite<{{FullName}}>.GetAlgebraicType(SpacetimeDB.BSATN.ITypeRegistrar registrar) =>
kazimuth marked this conversation as resolved.
Show resolved Hide resolved
GetAlgebraicType(registrar);
}
"""
);
Expand Down
6 changes: 5 additions & 1 deletion crates/bindings-csharp/BSATN.Codegen/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,11 @@ public override string ToString()
sb.Append(" : ").AppendJoin(", ", BaseTypes);
}

sb.Append(typeScope.Constraints).AppendLine(" {");
if (typeScope.Constraints.Length > 0)
{
sb.Append(' ').Append(typeScope.Constraints);
}
sb.AppendLine(" {");
}

sb.AppendLine();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void Write(System.IO.BinaryWriter writer, CustomClass value)
value.WriteFields(writer);
}

public SpacetimeDB.BSATN.AlgebraicType GetAlgebraicType(
public SpacetimeDB.BSATN.AlgebraicType.Ref GetAlgebraicType(
SpacetimeDB.BSATN.ITypeRegistrar registrar
) =>
registrar.RegisterType<CustomClass>(_ => new SpacetimeDB.BSATN.AlgebraicType.Product(
Expand All @@ -39,5 +39,9 @@ SpacetimeDB.BSATN.ITypeRegistrar registrar
new(nameof(StringField), StringField.GetAlgebraicType(registrar))
}
));

SpacetimeDB.BSATN.AlgebraicType SpacetimeDB.BSATN.IReadWrite<CustomClass>.GetAlgebraicType(
SpacetimeDB.BSATN.ITypeRegistrar registrar
) => GetAlgebraicType(registrar);
}
} // CustomClass
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void Write(System.IO.BinaryWriter writer, CustomStruct value)
value.WriteFields(writer);
}

public SpacetimeDB.BSATN.AlgebraicType GetAlgebraicType(
public SpacetimeDB.BSATN.AlgebraicType.Ref GetAlgebraicType(
SpacetimeDB.BSATN.ITypeRegistrar registrar
) =>
registrar.RegisterType<CustomStruct>(_ => new SpacetimeDB.BSATN.AlgebraicType.Product(
Expand All @@ -39,5 +39,9 @@ SpacetimeDB.BSATN.ITypeRegistrar registrar
new(nameof(StringField), StringField.GetAlgebraicType(registrar))
}
));

SpacetimeDB.BSATN.AlgebraicType SpacetimeDB.BSATN.IReadWrite<CustomStruct>.GetAlgebraicType(
SpacetimeDB.BSATN.ITypeRegistrar registrar
) => GetAlgebraicType(registrar);
}
} // CustomStruct
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void Write(System.IO.BinaryWriter writer, CustomTaggedEnum value)
}
}

public SpacetimeDB.BSATN.AlgebraicType GetAlgebraicType(
public SpacetimeDB.BSATN.AlgebraicType.Ref GetAlgebraicType(
SpacetimeDB.BSATN.ITypeRegistrar registrar
) =>
registrar.RegisterType<CustomTaggedEnum>(_ => new SpacetimeDB.BSATN.AlgebraicType.Sum(
Expand All @@ -58,5 +58,9 @@ SpacetimeDB.BSATN.ITypeRegistrar registrar
new(nameof(StringVariant), StringVariant.GetAlgebraicType(registrar))
}
));

SpacetimeDB.BSATN.AlgebraicType SpacetimeDB.BSATN.IReadWrite<CustomTaggedEnum>.GetAlgebraicType(
SpacetimeDB.BSATN.ITypeRegistrar registrar
) => GetAlgebraicType(registrar);
}
} // CustomTaggedEnum
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void Write(System.IO.BinaryWriter writer, PublicTable value)
value.WriteFields(writer);
}

public SpacetimeDB.BSATN.AlgebraicType GetAlgebraicType(
public SpacetimeDB.BSATN.AlgebraicType.Ref GetAlgebraicType(
SpacetimeDB.BSATN.ITypeRegistrar registrar
) =>
registrar.RegisterType<PublicTable>(_ => new SpacetimeDB.BSATN.AlgebraicType.Product(
Expand Down Expand Up @@ -144,5 +144,9 @@ SpacetimeDB.BSATN.ITypeRegistrar registrar
)
}
));

SpacetimeDB.BSATN.AlgebraicType SpacetimeDB.BSATN.IReadWrite<PublicTable>.GetAlgebraicType(
SpacetimeDB.BSATN.ITypeRegistrar registrar
) => GetAlgebraicType(registrar);
}
} // PublicTable
Loading
Loading