Skip to content

Enhancement: Revisits the Immutable Classes Instantiation #753

@mikependon

Description

@mikependon

Describe the enhancement

As a referenced to this issue #748 and to some various reports via GitterChat, the existing code for the classes with extra ctros were affected when the users upgraded the library from the version below v1.11.x to >= v1.12x. This is because the support to the immutable classes has been supported on this version.

Though we clearly explained it here, but I think, it is good if we can further optimize how the immutable classes instantiation behaved.

It is better if we can support the below.

// C#/F# records (basic)
public class C
{
	public C(string n, int v)
	{
		N = n;
		V = v;
	}
	public string N { get; }
	public int V { get; }
}

// Combination
public class C
{
	public C(string n)
	{
		N = n;
	}
	public string N { get; }
	public int V { get; set; }
}

// With Extra (default???)
public class C
{
	public C(string n, double notMapped)
	{
		N = n;
		NotMapped = notMapped;
	}
	public string N { get; }
	public double NotMapped { get; }
}

// Multiple Ctor
public class C
{
	public C(){ }
	public C(string n)
	{
		N = n;
	}
	public string N { get; }
}

// Multiple Ctor / Fallback
public class C
{
	public C(){ }
	public C(double notMapped)
	{
		NotMapped = notMapped;
	}
	public string N { get; set; }
	public double NotMapped { get; }
}

FYI: @kbilsted

Metadata

Metadata

Assignees

Labels

deployedFeature or bug is deployed at the current releaseenhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions