https://github.com/sepppenner/protobufnetprimitives
ProtobufNetPrimitives is a library to transfer basic data types with protobuf-net.Grpc.
https://github.com/sepppenner/protobufnetprimitives
basic datatype datatypes primitives protobuf protobufnet
Last synced: about 2 months ago
JSON representation
ProtobufNetPrimitives is a library to transfer basic data types with protobuf-net.Grpc.
- Host: GitHub
- URL: https://github.com/sepppenner/protobufnetprimitives
- Owner: SeppPenner
- License: mit
- Created: 2022-02-21T17:35:06.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2025-01-05T21:55:03.000Z (9 months ago)
- Last Synced: 2025-07-22T05:59:51.825Z (3 months ago)
- Topics: basic, datatype, datatypes, primitives, protobuf, protobufnet
- Language: C#
- Homepage:
- Size: 49.8 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: Changelog.md
- License: License.txt
Awesome Lists containing this project
README
ProtobufNetPrimitives
====================================ProtobufNetPrimitives is a library to transfer basic data types with [protobuf-net.Grpc](https://github.com/protobuf-net/protobuf-net.Grpc).
[](https://ci.appveyor.com/project/SeppPenner/protobufnetprimitives)
[](https://github.com/SeppPenner/ProtobufNetPrimitives/issues)
[](https://github.com/SeppPenner/ProtobufNetPrimitives/network)
[](https://github.com/SeppPenner/ProtobufNetPrimitives/stargazers)
[](https://raw.githubusercontent.com/SeppPenner/ProtobufNetPrimitives/master/License.txt)
[](https://www.nuget.org/packages/HaemmerElectronics.SeppPenner.ProtobufNetPrimitives/)
[](https://www.nuget.org/packages/HaemmerElectronics.SeppPenner.ProtobufNetPrimitives/)
[](https://snyk.io/test/github/SeppPenner/ProtobufNetPrimitives)
[](https://matrix.to/#/#ProtobufNetPrimitives_community:gitter.im)
[](https://franzhuber23.blogspot.de/)
[](https://patreon.com/SeppPennerOpenSourceDevelopment)
[](https://paypal.me/th070795)## Available for
* Net 8.0
* Net 9.0## Net Core and Net Framework latest and LTS versions
* https://dotnet.microsoft.com/download/dotnet## Available data types
|Net type|GRPC type|Remark|
|-|-|-|
|`bool`|`DtoBool`|-|
|`byte`|`DtoByte`|-|
|`char`|`DtoChar`|-|
|`DateTime`|`DtoDateTime`|The value is internally stored as long, use the property `DateTime` to get the correct value.|
|`DateTimeOffset`|`DtoDateTimeOffset`|The value is internally stored as long, use the property `DateTimeOffset` to get the correct value.|
|`decimal`|`DtoDecimal`|-|
|`double`|`DtoDouble`|-|
|`float`|`DtoFloat`|-|
|`Guid`|`DtoGuid`|The value is internally stored as string, use the property `Uuid` to get the correct value.|
|`int`|`DtoInt`|-|
|`long`|`DtoLong`|-|
|`nint`|`DtoNint`|-|
|`nuint`|`DtoNuint`|-|
|`sbyte`|`DtoSbyte`|-|
|`short`|`DtoShort`|-|
|`string`|`DtoString`|-|
|`TimeSpan`|`DtoTimeSpan`|The value is internally stored as long, use the property `TimeSpan` to get the correct value.|
|`uint`|`DtoUint`|-|
|`ulong`|`DtoUlong`|-|
|`ushort`|`DtoUshort`|-|Non-Nullable and Nullable types are supported (Different sub-namespaces).
# Why you can't use generics here
```csharp
///
/// The base DTO class.
///
[ProtoContract]
[ProtoInclude(1, typeof(DtoBool))]
public class DtoBase where T : new()
{
///
/// Initializes a new instance of the class.
///
public DtoBase()
{
}///
/// Initializes a new instance of the class.
///
/// The value.
public DtoBase(T value)
{
this.Data = value;
}///
/// Gets or sets the data.
///
[ProtoMember(2)]
public T Data { get; set; } = new();
}///
/// The DTO class to transfer bool data.
///
[ProtoContract]
public class DtoBool : DtoBase
{
///
/// Initializes a new instance of the class.
///
public DtoBool()
{
}///
/// Initializes a new instance of the class.
///
/// The value.
public DtoBool(bool value)
{
this.Data = value;
}
}
```throws the error subscribed under https://github.com/protobuf-net/protobuf-net/issues/829 (Not resolved yet).
## Install
```bash
dotnet add package HaemmerElectronics.SeppPenner.ProtobufNetPrimitives
```Change history
--------------See the [Changelog](https://github.com/SeppPenner/ProtobufNetPrimitives/blob/master/Changelog.md).