An open API service indexing awesome lists of open source software.

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.

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).

[![Build status](https://ci.appveyor.com/api/projects/status/q89qcgvtb45fcri0?svg=true)](https://ci.appveyor.com/project/SeppPenner/protobufnetprimitives)
[![GitHub issues](https://img.shields.io/github/issues/SeppPenner/ProtobufNetPrimitives.svg)](https://github.com/SeppPenner/ProtobufNetPrimitives/issues)
[![GitHub forks](https://img.shields.io/github/forks/SeppPenner/ProtobufNetPrimitives.svg)](https://github.com/SeppPenner/ProtobufNetPrimitives/network)
[![GitHub stars](https://img.shields.io/github/stars/SeppPenner/ProtobufNetPrimitives.svg)](https://github.com/SeppPenner/ProtobufNetPrimitives/stargazers)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://raw.githubusercontent.com/SeppPenner/ProtobufNetPrimitives/master/License.txt)
[![Nuget](https://img.shields.io/badge/ProtobufNetPrimitives-Nuget-brightgreen.svg)](https://www.nuget.org/packages/HaemmerElectronics.SeppPenner.ProtobufNetPrimitives/)
[![NuGet Downloads](https://img.shields.io/nuget/dt/HaemmerElectronics.SeppPenner.ProtobufNetPrimitives.svg)](https://www.nuget.org/packages/HaemmerElectronics.SeppPenner.ProtobufNetPrimitives/)
[![Known Vulnerabilities](https://snyk.io/test/github/SeppPenner/ProtobufNetPrimitives/badge.svg)](https://snyk.io/test/github/SeppPenner/ProtobufNetPrimitives)
[![Gitter](https://img.shields.io/matrix/ProtobufNetPrimitives_community%3Agitter.im?server_fqdn=matrix.org)](https://matrix.to/#/#ProtobufNetPrimitives_community:gitter.im)
[![Blogger](https://img.shields.io/badge/Follow_me_on-blogger-orange)](https://franzhuber23.blogspot.de/)
[![Patreon](https://img.shields.io/badge/Patreon-F96854?logo=patreon&logoColor=white)](https://patreon.com/SeppPennerOpenSourceDevelopment)
[![PayPal](https://img.shields.io/badge/PayPal-00457C?logo=paypal&logoColor=white)](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).