Cysharp / MemoryPack

Zero encoding extreme performance binary serializer for C# and Unity.
MIT License
3.01k stars 182 forks source link

Fix issue 304: Use of C# 9 feature in library targeted at C# 7. #305

Open jsupnik-ext-sd opened 1 month ago

jsupnik-ext-sd commented 1 month ago

Calling new (someSize) instead of new Dictionary<type,ushort>(someSize) is not allowed in .net versions below 9, but this library is supposed to be .net 7 compatible.

See https://github.com/Cysharp/MemoryPack/issues/304 for more info.

neuecc commented 4 weeks ago

C# 7 is too old and I don't feel I can guarantee full support all the time. Is there any reason why you must go with C# 7?

jsupnik-ext-sd commented 3 weeks ago

The documentation on the readme page guarantees C#7 support. For our own uses, we were using C# 8, which also didn't support the feature. Once I fixed this one particular defect, the library built and ran correctly in C# 8.

neuecc commented 3 weeks ago

Where is mentioned about C# 7? .NET 7 and C# 7 is completely different...

jsupnik-ext-sd commented 3 weeks ago

Ah, that's confusion on my part. I hadn't realized the versioning system for C# was so complicated. Regardless, I think my fix improves compatibility with older C# versions, and doesn't introduce any problems. Older C# is particularly desirable for people integrating with Unity, which tends to lag behind (and games tend to be cautious about upgrading to latest-and-greatest Unity versions).