Easier Immutable Objects in C# 6 and VB 12

That’s really cool. I’ve heard about some other C# 6 features, but not that one. It could make a lot of EWL classes a lot shorter, especially if we’re able to extend the record classes with static constructors and make the actual constructor private.

1 Like

I’m a bit excited for the new null-coalescing Elvis operator: http://blogs.msdn.com/b/jerrynixon/archive/2014/02/26/at-last-c-is-getting-sometimes-called-the-safe-navigation-operator.aspx

Yeah, I’ve heard about that operator and it’s definitely going to be great.

1 Like

There is one new feature I didn’t like at all, or maybe I don’t get it. It allows you to setup some sort of using statement with static methods so that you don’t need to qualify them with the type. As I understand it, you will be able to see WriteLine(“Test”); and honestly not be able to tell if that’s your own method or if it’s calling Console.WriteLine();

Maybe this is to make it easier to have your extension methods be discoverable even if the proper using statement isn’t there?

The ?. operator is a big deal. The record class isn’t that big of a deal because they’re just making it easier for the implementer of the class. It really needs to be easier for the client code. It needs to support complex immutable objects without having a giant constructor that takes 30 parameters, and this does nothing to improve that. It also doesn’t do anything to help with MVC and other frameworks requiring empty constructors and setter properties on every field in order to do their magic.

I don’t think so. The only example I’ve seen to express the feature is turning Console.WriteLine() into WriteLine() which I think is pretty stupid, especially if it’s to benefit extension methods.

How does it not support constructors that that take 30 parameters? Our problem with that is intellisense, not the programming language.

It does support them, but that’s not what we want. We want a way to build up an immutable object bit by bit, not all in one giant line.

But you can already to that with popsicle immutability, we just never do.

That’s exactly my point. They need better compiler support for popsicle immutability.

1 Like