Nikhil Agrawal
Nikhil Agrawal

Reputation: 48568

ProtoBuff.Net do not support null. Why?

Why do ProtoBuff.Net not support null?

I was going through ProtoBuf and was wondering why null values are not supported. When we try to assign null value, it gives exception. Even ref kind like string do not support this.

pb::ThrowHelper.ThrowIfNull(value, "value"); 

I know that PROTOs want to keep things minimum basic so that it support large number of languages (that's why no DateTime), but null is a concept across languages?

Or may be I am overlooking something.

Upvotes: 3

Views: 534

Answers (1)

Marc Gravell
Marc Gravell

Reputation: 1062820

Simply, because the underlying protocol specification ("protobuf") has no concept of null and no way of expressing it. If I can't express it in the protocol, the best that can be supported is some kind of implicit "the absence of something means leave it alone which means it will probably be null".

Upvotes: 3

Related Questions