mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-21 00:27:31 +00:00
[BREAKING CHANGE] Field accessors should use property getters in C#
In C#, plain field accessors should not be nonparametric methods but should be standard property getters. The accessor methods with parameters were renamed to `GetXxx` because a method cannot be named identically to a property. Also, `ByteBuffer.Position`, `FlatBufferBuilder.Offset` and `FlatBufferBuilder.DataBuffer` are now properties instead of nonparametric accessor methods, for more idiomatic C# style. This is a breaking change, all client C# code accessing these fields needs to be changed (i.e. remove those `()` or add the `Get` prefix). Issue: #77 Change-Id: Iaabe9ada076e5ea2c69911cf6170fdda2df3487e
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
a50711ad13
commit
0ee1b99c5d
@@ -8,13 +8,13 @@ using FlatBuffers;
|
||||
public sealed class Vec3 : Struct {
|
||||
public Vec3 __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
|
||||
|
||||
public float X() { return bb.GetFloat(bb_pos + 0); }
|
||||
public float Y() { return bb.GetFloat(bb_pos + 4); }
|
||||
public float Z() { return bb.GetFloat(bb_pos + 8); }
|
||||
public double Test1() { return bb.GetDouble(bb_pos + 16); }
|
||||
public Color Test2() { return (Color)bb.GetSbyte(bb_pos + 24); }
|
||||
public Test Test3() { return Test3(new Test()); }
|
||||
public Test Test3(Test obj) { return obj.__init(bb_pos + 26, bb); }
|
||||
public float X { get { return bb.GetFloat(bb_pos + 0); } }
|
||||
public float Y { get { return bb.GetFloat(bb_pos + 4); } }
|
||||
public float Z { get { return bb.GetFloat(bb_pos + 8); } }
|
||||
public double Test1 { get { return bb.GetDouble(bb_pos + 16); } }
|
||||
public Color Test2 { get { return (Color)bb.GetSbyte(bb_pos + 24); } }
|
||||
public Test Test3 { get { return GetTest3(new Test()); } }
|
||||
public Test GetTest3(Test obj) { return obj.__init(bb_pos + 26, bb); }
|
||||
|
||||
public static int CreateVec3(FlatBufferBuilder builder, float X, float Y, float Z, double Test1, Color Test2, short Test_A, sbyte Test_B) {
|
||||
builder.Prep(16, 32);
|
||||
@@ -30,7 +30,7 @@ public sealed class Vec3 : Struct {
|
||||
builder.PutFloat(Z);
|
||||
builder.PutFloat(Y);
|
||||
builder.PutFloat(X);
|
||||
return builder.Offset();
|
||||
return builder.Offset;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user