Skip to content

Provides protobuf message definition to represent the `decimal` type.

License

Notifications You must be signed in to change notification settings

duskembayev/Enhanced.Protobuf.DecimalValue

Repository files navigation

Enhanced.Protobuf.DecimalValue

This is a simple library that allows you to use decimal values in your protobuf messages.

It implements the approach described in ASP.NET documentation

Message definition

syntax = "proto3";

package enhanced.protobuf;

option csharp_namespace = "Enhanced.Protobuf";

message DecimalValue {
    int64 units = 1;
    sfixed32 nanos = 2;
}

Features

  • Serialization and deserialization of decimal values.
  • Implicit conversion between decimal and DecimalValue.

Installation

dotnet add package Enhanced.Protobuf.DecimalValue

Usage

Define a message that uses DecimalValue type.

syntax = "proto3";

import "enhanced/protobuf/DecimalValue.proto";

message Product {
    string name = 1;
    enhanced.protobuf.DecimalValue price = 2;
}

Use the generated C# classes in your code.

using Enhanced.Protobuf;

var product = new Product
{
    Name = "Apple",
    Price = 3.14m
};

About

Provides protobuf message definition to represent the `decimal` type.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages