danslapman/RecSharp

语言: Nemerle

git: https://github.com/danslapman/RecSharp

.NET的不可变记录生成器
Immutable record generator for .NET
README.md (中文)

RecSharp

cSharp是.NET的不可变记录生成器 不可变记录类似于F#的记录或Scala的案例类,但可以安全地从C#中使用。

这是样本记录定义(您可以在sample.rcs中找到它)

namespace Records {
    using System;

    record Test {
        Int32 Id;
        String Name;
        Nullable<Decimal> Amount;
    }
}

发电机类测试将具有:

  • 仅限吸气剂的属性
  • 具有属性初始化参数的构造函数
  • 带有可选参数的Copy()方法
  • IEquatable实现
  • 重写Equals()和GetHashCode()
  • ==和!=运营商

外部库可以通过命令行参数或以下语法引用(如果对VS扩展有用):

#ref System.Linq.dll;

使用RecSharpC -i sample.rcs编译-o Records.dll并将Records.dll引用到您的项目中。 而已!

本文使用googletrans自动翻译,仅供参考, 原文来自github.com

en_README.md

RecSharp

RecSharp is an immutable record generator for .NET
Immutable records are similiar to F#'s records or Scala's case classes, but can be used from C# safely.

Here is the sample record definition (You can found it in sample.rcs)

namespace Records {
    using System;

    record Test {
        Int32 Id;
        String Name;
        Nullable<Decimal> Amount;
    }
}

Generater class Test will have:

  • getter-only properties
  • constructor with parameters for properties initialization
  • Copy() method with optional parameters
  • IEquatable implementation
  • overrides os Equals() and GetHashCode()
  • == and != operators

External libraries can be referenced by command-line parameter or by the following syntax (which if useful for VS extension):

#ref System.Linq.dll;

Compile it with RecSharpC -i sample.rcs -o Records.dll and reference Records.dll to Your project.
That's it!