nanoFramework.Protobuf
1.0.2
Prefix Reserved
dotnet add package nanoFramework.Protobuf --version 1.0.2
NuGet\Install-Package nanoFramework.Protobuf -Version 1.0.2
<PackageReference Include="nanoFramework.Protobuf" Version="1.0.2" />
paket add nanoFramework.Protobuf --version 1.0.2
#r "nuget: nanoFramework.Protobuf, 1.0.2"
// Install nanoFramework.Protobuf as a Cake Addin #addin nuget:?package=nanoFramework.Protobuf&version=1.0.2 // Install nanoFramework.Protobuf as a Cake Tool #tool nuget:?package=nanoFramework.Protobuf&version=1.0.2
Welcome to the .NET nanoFramework Protobuf repository
This repository contains the Protobuf library for the .NET nanoFramework. It provides high-performance serialization and deserialization with the smallest possible payload, making it ideal for embedded systems with limited resources.
Build status
Component | Build Status | NuGet Package |
---|---|---|
nanoFramework.Protobuf |
.NET nanoFramework.Protobuf
This library is useful for projects looking to transfer data to or from embedded systems using the .NET nanoFramework. It provides assemblies compiled with .NET nanoFramework and netstandard 2.0, making it usable in both .NET nanoFramework projects and other .NET flavors.
While JSON is a viable option for data transfer, the goal of this library is to provide high-performance serialization and deserialization with the smallest possible payload. This is beneficial given the limited RAM and storage capacity of embedded systems.
The library mimics the principles of Protobuf-net. Many features of protobuf-net are not needed (so far) or do not make sense in the context of .NET nanoFramework. Hence, some features are lacking or shortcuts have been taken. A noteworthy choice in this regard is the format of the binary data, which is stored in accordance with the MessagePack spec instead of the less concise .NET nanoFramework format.
Due to current limitations of the .NET nanoFramework API, there are some restrictions in the current implementation:
- Only fields can be decorated with
ProtoMember
. .NET nanoFramework lacksType.GetProperties
at the moment. All code to support properties is present in the codebase, so this can be easily added whenGetProperties
is implemented. - The
ProtoInclude
attribute allows describing inherited types on the base type so that they are properly serialized. Thetypeof()
syntax does compile in .NET nanoFramework but yields an emptyType
at runtime. - The current implementation of
Type.GetElementType
returnsnull
at runtime which prevents from detecting the array element type. An additional attributeProtoArrayElementAttribute
is provided to get around this. - There is no
Enum.ToObject
implementation in .NET nanoFramework which means enums are not currently supported. This can be solved by casting an enum to an integer in a wrapper class. - Conversions from unsigned types to signed types with the same or less byte size are not supported in .NET nanoFramework (
ushort
toint
for instance). While this has no consequences on a functional level, it does on the performance side since it is currently solved with string parsing. - Lastly, the .NET nanoFramework
MemoryStream
is limited to 65kB. Since the payload may be bigger an interfaceIStream
is implemented in either a wrapper aroundMemoryStream
(the preferred approach) or, when in need of (de)serializing a bigger payload, an alternativeProtobufStream
implementation is available. See also theBigString
unit test. TheSerializer
class defaults to theMemoryStream
wrapper.
With these limitations in mind, the library requires specific contracts, which means existing DTOs can probably not be reused as such. This is easily circumvented by creating wrapper classes, though.
The first five limitations mentioned are denoted in the code with a comment (look for //NanoTODO
).
Acknowledgements
The initial version of the protobuf library was coded by Klaus Vancamelbeke, who has kindly handed over the library to the .NET nanoFramework project.
Feedback and documentation
For documentation, providing feedback, issues, and finding out how to contribute, please refer to the Home repo.
Join our Discord community here.
Credits
The list of contributors to this project can be found at CONTRIBUTORS.
License
The nanoFramework WebServer library is licensed under the MIT license.
Code of Conduct
This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behaviour in our community. For more information see the .NET Foundation Code of Conduct.
.NET Foundation
This project is supported by the .NET Foundation.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
.NETnanoFramework | netnano is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETnanoFramework 0.0
- nanoFramework.CoreLibrary (>= 1.15.5)
- nanoFramework.System.Collections (>= 1.5.45)
- nanoFramework.System.IO.Streams (>= 1.1.59)
- nanoFramework.System.Text (>= 1.2.54)
-
.NETStandard 2.0
- NETStandard.Library (>= 2.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.