mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-18 17:28:56 +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,15 +8,15 @@ using FlatBuffers;
|
||||
public sealed class Test : Struct {
|
||||
public Test __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
|
||||
|
||||
public short A() { return bb.GetShort(bb_pos + 0); }
|
||||
public sbyte B() { return bb.GetSbyte(bb_pos + 2); }
|
||||
public short A { get { return bb.GetShort(bb_pos + 0); } }
|
||||
public sbyte B { get { return bb.GetSbyte(bb_pos + 2); } }
|
||||
|
||||
public static int CreateTest(FlatBufferBuilder builder, short A, sbyte B) {
|
||||
builder.Prep(2, 4);
|
||||
builder.Pad(1);
|
||||
builder.PutSbyte(B);
|
||||
builder.PutShort(A);
|
||||
return builder.Offset();
|
||||
return builder.Offset;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user