How project Lombok in java works and is that possible in .net using attributes?
Now there is a .NET port! Check out Lombok.NET.
Disclaimer: I am the author of this library.
Well in Lombok a Java class might look like this
import lombok.Data;
@Data public class Cart {
private int id;
private DateTime created;
private int items;
private int status;
}
While in C# the same class would look like this
public class Cart {
public int Id { get; set; }
public DateTime Created { get; set; }
public int Items { get; set; }
public int Status { get; set; }
}
So C# (3.0 in this example) gets rather close without any other libraries, but as you start adding "final" to some properties the magic "auto constructor" part of Lombok really shines. As for a .Net alternative, as I understand it the .Net annotations don't provide the ability to intercept the byte code before it goes to the compiler (what Lombok uses to such great effect), so your options are limited to some template system + a build script like nAnt. This would be a mess to maintain.