Closed yewnyx closed 3 years ago
FlatSharp targets C# 8.0, which looks like you need Unity version 2020.2 or greater.
Gotcha. A little disappointing that I'll have to wait to use it, but understandable.
For some clarity, Unity comes out with a new version every year, and it typically starts stabilizing towards the end of the year before becoming LTS. Devs will often track the LTS -1 and update to the next LTS after it's baked for a little bit, so 2019 and 2020 will be the best targets for 2021, and 2020 and 2021 the best targets for 2022, and so on.
Thanks for that context. I don't have too much experience with Unity, unfortunately.
If you're wiling to use an older version of FlatSharp, I think 4.X uses C# 7.3 or less. It doesn't contain many of the newer features, but still has the compiler and most things you'd expect.
Appreciate the tip, I'll try that out!
reporting back - 4.2.2 generated code with calls to functions that didn't exist (different number of parameters), i.e. ParseItem, WriteUOffset, GetAbsoluteTableFieldLocation, etc.
Did you also downgrade FlatSharp.Runtime to 4.2.2? Versions are tied together.
D'oh! I did indeed forget that. Once I fixed expressions such as index3Value is not null
to index3Value != null
, it compiled. Thanks!
Glad it worked. If you're willing to fiddle with the code, then removing the extra ?
's and !
's shouldn't be too bad if you want to use the new version. There might be a few 8.0-only things, but probably not more than a handful.
Those are related to nullable reference types, if you aren't familiar. The reason I include them is that the annotations are very helpful, and I compile my unit tests with warnings-as-errors so I get hard breaks if I forgot to check for null.
#nullable disable
and#nullable enable annotations
produce compilation errors, as do the!
and?
sprinkled throughout.This was tested with both
dotnet path\to\FlatSharp.Compiler.dll -i path\to\MySchema.fbs -o path\to\output --nullable-warnings=true
anddotnet path\to\FlatSharp.Compiler.dll -i path\to\MySchema.fbs -o path\to\output --nullable-warnings=false
(or with the option omitted altogether), and produce output that can't be compiled in Unity 2019.4, whose language support is C# 7.3.