Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Immutable Collections #24

Open
michalciolek opened this issue Oct 13, 2021 · 1 comment
Open

Support Immutable Collections #24

michalciolek opened this issue Oct 13, 2021 · 1 comment
Assignees

Comments

@michalciolek
Copy link

It is possible to add support for Microsoft Immutable Collections eg. ImmutableList?

Now when I use ImmutableList DeepCopy generates incorrect code and I get JIT error.

DeepCopy generates:

public class MyClass
{
    public ImmutableList<String> MyProperty { get; set; }
		
	public MyClass(MyClass source)
	{
		ImmutableList<string> immutableList = new ImmutableList<string>();
		foreach (string item in (IEnumerable<string>)source.MyProperty)
		{
			immutableList.Add((item != null) ? string.Copy(item) : null);
		}
		MyProperty = immutableList;
	}
}

ImmutableList does not have empty constructor.

DeepCopy should generate:

public class MyClass
{
    public ImmutableList<String> MyProperty { get; set; }
		
    public MyClass(SituationAwarenessSendingModel source)
    {
        ImmutableList<string>.Builder immutableList = ImmutableList.CreateBuilder<string>();
        foreach (string item in (IEnumerable<string>)source.MyProperty)
        {
            immutableList.Add((item != null) ? string.Copy(item) : null);
        }
        MyProperty = immutableList.ToImmutable();
    }
}

@greuelpirat
Copy link
Owner

I do not know this library. I will have a look. but this may take some time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants