RevenantX / LiteNetLib

Lite reliable UDP library for Mono and .NET
https://revenantx.github.io/LiteNetLib/index.html
MIT License
3k stars 489 forks source link

improve: return empty string when its size is 0 #519

Closed insthync closed 1 year ago

insthync commented 1 year ago

I think it should return an empty string when its size is 0, so we won't have to check null string when reading it, but still return null when its size reached the max length so we can know error occurring because of too big string size

RevenantX commented 1 year ago

@insthync how do you know that it reached maxlength on receive side?

insthync commented 1 year ago

Know because it will return null (notice at line 292), but if its length is 0 it will returns string.Empty

RevenantX commented 1 year ago

But if it reach max size on "send" side - it will be 0 https://github.com/RevenantX/LiteNetLib/blob/master/LiteNetLib/Utils/NetDataWriter.cs#L366

insthync commented 1 year ago

Oh, I just saw that one.

Hmm, then I think it is up to how users like it, I've just upgraded from 0.9, the old one did not return null, so I change yours to return string.Empty for my convenience.