RmSharp is a C# .NET class library designed for deserializing and serializing Ruby Marshal files. It enables seamless translation between C# models and Ruby Marshal files, allowing you to work with Ruby data structures directly in your C# applications.
This library is built upon the work done in HNIdesu's RubyMarshal project. Please note that not all Ruby Marshal tokens are supported in the current version, making it unsuitable for production use at this time.
- Deserialize Ruby Marshal files directly into C# objects.
- Serialize C# objects into Ruby Marshal files.
- Support for Arrays, basic types, and objects.
- Attribute-based mapping to maintain Ruby naming conventions for classes and properties.
You can install RmSharp via NuGet:
dotnet add package RmSharp
You can deserialize a Ruby Marshal file into your C# model as shown below:
using (var stream = File.OpenRead(file))
{
var instance = RmSerialiser.Deserialise<YourType>(stream);
}
To serialize your C# object into a Ruby Marshal file:
using (var stream = File.OpenWrite(file))
{
RmSerialiser.Serialise(stream, instance);
}
To ensure that Ruby naming conventions are maintained in your C# classes, you need to use the [RmName]
attribute:
[RmName("ModuleName::ClassName")]
public class YourClass
{
[RmName("ruby_name")]
public string YourProperty { get; set; }
}
This will map your C# class and properties to the corresponding Ruby class and properties during serialization and deserialization.
- Not Production-Ready: This library is still in its early stages and is not ready for production use.
- Limited Token Support: Currently, only a subset of Ruby Marshal tokens is supported, including arrays, basic types, and objects.
This library is based on the work done in the RubyMarshal project by HNIdesu. We are deeply grateful for their contributions to the Ruby Marshal serialization format.
Contributions are welcome! Feel free to open issues or submit pull requests to improve the library.
RmSharp is licensed under the MIT License. See the LICENSE file for more details.