Closed wolfman42 closed 2 years ago
The write method you're mentioning is an extension method defined here: https://github.com/jamescourtney/FlatSharp/blob/593a94498cd0e6031edb2557bf48e640380acf8a/src/FlatSharp.Runtime/ISerializerExtensions.cs#L129
I usually use extension methods on interfaces to reduce the need to implement boilerplate like this in each implementation.
I don't see any errors doing a clean build of the samples. Are you using VS, or some other IDE?
Thanks for getting back. This helped. I was missing using FlatSharp.Runtime;
which then makes those extension methods available. Since the sample project is using global usings and the SchemaFilesExample2.cs doesn't have any using statements that wasn't immediately obvious. I guess I should have checked for that first, though.
I'm trying to use the latest 6.2.1 with build time compilation and am running into issue with generated Serializer Write and Parse methods. Tried building Example03-SchemaFiles2 and it doesn't compile with .NET 6.
The code in SchemaFilesExample2.cs line 58 expects this write method:
int bytesWritten = FooBarContainer.Serializer.Write(destination, container);
However, the GeneratedSerializer() has the following method signature which is inherited from ISerializer:
int Write<TSpanWriter>(TSpanWriter writer, Span<byte> destination, T item) where TSpanWriter : ISpanWriter;
Using the FlatBufferSerializer.Default serializer works, though:
int bytesWritten = FlatBufferSerializer.Default.Serialize(container, destination);