Files
SpacetimeDB/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#MultiTableRow.verified.cs
james gilles 0d2a45b239 Fix fields named 'read' (#2525)
# Description of Changes

Fixes
https://github.com/orgs/clockworklabs/projects/22?pane=issue&itemId=102392974&issue=clockworklabs%7Ccom.clockworklabs.spacetimedbsdk%7C276

by renaming `internal` `static` serializer fields so that they do not
overlap with user-provided names.

Note, however, that some field names still will not work: `ReadFields`,
`WriteFields`, `Equals`, and `GetHashCode`.
This would require a separate fix since the error would happen in a
different place. In this case we would need to change the name of the
generated member to something like `ReadFields_` or `Equals_`, which I'm
not sure is a good idea.

# API and ABI breaking changes

N/A

# Expected complexity level and risk

0

# Testing

SDK tests and `dotnet-verify` tests are passing.

---------

Signed-off-by: rekhoff <r.ekhoff@clockworklabs.io>
Co-authored-by: rekhoff <r.ekhoff@clockworklabs.io>
2025-08-26 21:17:46 +00:00

116 lines
3.7 KiB
C#

//HintName: MultiTableRow.cs
// <auto-generated />
#nullable enable
partial struct MultiTableRow
: System.IEquatable<MultiTableRow>,
SpacetimeDB.BSATN.IStructuralReadWrite
{
public void ReadFields(System.IO.BinaryReader reader)
{
Name = BSATN.NameRW.Read(reader);
Foo = BSATN.FooRW.Read(reader);
Bar = BSATN.BarRW.Read(reader);
}
public void WriteFields(System.IO.BinaryWriter writer)
{
BSATN.NameRW.Write(writer, Name);
BSATN.FooRW.Write(writer, Foo);
BSATN.BarRW.Write(writer, Bar);
}
object SpacetimeDB.BSATN.IStructuralReadWrite.GetSerializer()
{
return new BSATN();
}
public override string ToString() =>
$"MultiTableRow {{ Name = {SpacetimeDB.BSATN.StringUtil.GenericToString(Name)}, Foo = {SpacetimeDB.BSATN.StringUtil.GenericToString(Foo)}, Bar = {SpacetimeDB.BSATN.StringUtil.GenericToString(Bar)} }}";
public readonly partial struct BSATN : SpacetimeDB.BSATN.IReadWrite<MultiTableRow>
{
internal static readonly SpacetimeDB.BSATN.String NameRW = new();
internal static readonly SpacetimeDB.BSATN.U32 FooRW = new();
internal static readonly SpacetimeDB.BSATN.U32 BarRW = new();
public MultiTableRow Read(System.IO.BinaryReader reader)
{
var ___result = new MultiTableRow();
___result.ReadFields(reader);
return ___result;
}
public void Write(System.IO.BinaryWriter writer, MultiTableRow value)
{
value.WriteFields(writer);
}
public SpacetimeDB.BSATN.AlgebraicType.Ref GetAlgebraicType(
SpacetimeDB.BSATN.ITypeRegistrar registrar
) =>
registrar.RegisterType<MultiTableRow>(_ => new SpacetimeDB.BSATN.AlgebraicType.Product(
new SpacetimeDB.BSATN.AggregateElement[]
{
new("Name", NameRW.GetAlgebraicType(registrar)),
new("Foo", FooRW.GetAlgebraicType(registrar)),
new("Bar", BarRW.GetAlgebraicType(registrar))
}
));
SpacetimeDB.BSATN.AlgebraicType SpacetimeDB.BSATN.IReadWrite<MultiTableRow>.GetAlgebraicType(
SpacetimeDB.BSATN.ITypeRegistrar registrar
) => GetAlgebraicType(registrar);
}
public override int GetHashCode()
{
var ___hashName = Name == null ? 0 : Name.GetHashCode();
var ___hashFoo = Foo.GetHashCode();
var ___hashBar = Bar.GetHashCode();
return ___hashName ^ ___hashFoo ^ ___hashBar;
}
#nullable enable
public bool Equals(MultiTableRow that)
{
var ___eqName = this.Name == null ? that.Name == null : this.Name.Equals(that.Name);
var ___eqFoo = this.Foo.Equals(that.Foo);
var ___eqBar = this.Bar.Equals(that.Bar);
return ___eqName && ___eqFoo && ___eqBar;
}
public override bool Equals(object? that)
{
if (that == null)
{
return false;
}
var that_ = that as MultiTableRow?;
if (((object?)that_) == null)
{
return false;
}
return Equals(that_);
}
public static bool operator ==(MultiTableRow this_, MultiTableRow that)
{
if (((object?)this_) == null || ((object?)that) == null)
{
return object.Equals(this_, that);
}
return this_.Equals(that);
}
public static bool operator !=(MultiTableRow this_, MultiTableRow that)
{
if (((object?)this_) == null || ((object?)that) == null)
{
return !object.Equals(this_, that);
}
return !this_.Equals(that);
}
#nullable restore
} // MultiTableRow