Skip to content

libmir/mir.net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mir.net

.NET Implementation of Mir Ref-Counted Type System (MTS)

Features

  • Fast generic types that are easy to construct, use, and pass between managed and unmanaged code.
  • Faster than Protocol Buffers as well as any other serialization library because it is completely zero-copy.
  • Requires around half the user code compared to Protocol Buffers.
  • D and C++ implementations are provided via Mir Algorithm
  • D, C++, and C# MTS implementations are self-contained. C# implementation requires neither Mir Algorithm nor D/C/C++ runtimes.
  • Hands-free. Just construct, pass, and forget. Mir objects hold all required information to destroy them and free memory.

The library is used in a large private codebase.

Or build NuGet package your self.

cd Mir
dotnet pack --configuration Release

Basic Types

  • Array
  • Array slices
  • Matrices
  • Sorted dictionaries (Series)
  • Slim shared pointers
  • Shared Pointers with inheritance
  • POD small strings

Composed user-defined types

Mir types can be composed using other Mir types and C# POD types that don't require special marshaling. MirWrapper is a base class for all non-POD library and user-defined Mir types. It requires the structure payload (Impl) to be defined.

MirPtr and MirSlimPtr can be used to wrap a native type without defining its structure payload in C#.

Table of correspondence

(check the source repository if the table isn't rendered correctly because of the nuget issue)

D Type C# Type C++ Type
SlimRCPtr!Type MirSlimPtr<Type> mir_slim_rcptr<Type>
RCPtr!Type MirPtr<Type> mir_rcptr<Type>
RCArray!Type MirArray<Type, @> ×2 mir_rcarray<Type>
Slice!(RCI!Type) Slice<Type> ×2 mir_slice<mir_rci<Type>>
Slice!(RCI!Type, 2) Matrix<Type> ×2 mir_slice<mir_rci<Type>, 2>
Slice!(Type*) SliceView<Type, @> ×2 mir_slice<Type*>
Series!(RCI!Key, RCI!Value) Series<Key, Value, @> ×2 mir_series<mir_rci<Key>, mir_rci<Value>>
SmallString!N SmallStringN, N=4,31,32,64,128 mir::SmallString<N>
Series!(RCI!(RCArray!(const char)), RCI!Value) StringSeries<Value> mir_series<mir_rci<mir_rcarray<const char>>, mir_rci<Value>>

Name<... , @> ×2 - means a type has two declarations, Name<... > and Name<... , Impl>, where Impl is an unmanaged C# handle structure that describes non-POD Mir Type.

Composed Mir Type (CMT) is a type that is composed of CMT fields, library RefCounted fields, and POD structures and types.

Unmanaged C# handles should use byte instead of bool.