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

Add support for System.Collections.Immutable #11

Closed
wieslawsoltes opened this issue Jan 6, 2016 · 6 comments
Closed

Add support for System.Collections.Immutable #11

wieslawsoltes opened this issue Jan 6, 2016 · 6 comments

Comments

@wieslawsoltes
Copy link
Contributor

Sample model:
https://github.com/wieslawsoltes/XamlDemo/blob/immutable/XamlDemo/Model.cs

Sample Xaml:
https://github.com/wieslawsoltes/XamlDemo/blob/immutable/XamlDemo/Project.caml

@cwensley
Copy link
Owner

cwensley commented Jan 6, 2016

nice suggestion! do you know if System.Xaml supports immutable collections? I ask as I'm not sure the best way to implement this. E.g. should we look for the Add() method and if it returns the same collection instance, set it back to the property? Or is it that it builds up an internal list and creates a new instance of the immutable when setting the property..

Probably a good idea to add some tests to see what it does and try to emulate that somehow.

@wieslawsoltes
Copy link
Contributor Author

System.Xaml does not support, at least in my sample it failed.

I have found this solution used in Newtonsoft.Json: https://github.com/JamesNK/Newtonsoft.Json/blob/4c256e7afd46197a6e40127f77dff18e8f044b8c/Src/Newtonsoft.Json/Utilities/ImmutableCollectionsUtils.cs

@cwensley
Copy link
Owner

cwensley commented Jan 6, 2016

ah ok, that makes it easy then as we can then come up with our own strategy to implement this. Thanks for the link I'll take a look.

@wieslawsoltes
Copy link
Contributor Author

The Newtonsoft.Json works great with Immutable Collections.

I've been trying to find solution using built-in Xaml mechanisms from Portable.Xaml:
https://github.com/wieslawsoltes/XamlDemo/tree/ImmutableArray/XamlDemo/Xaml

But this is as fat I've got. And it does not work yet when properties are of Immutable type, only when they are IList<> and later created as Immutable.

@cwensley
Copy link
Owner

Now supported!

@Mike-E-angelo
Copy link

I'd just like to say that this thread has totally influenced me and led me to the light of immutable collections. I am starting to take the dive and require them for my design going forward. Just thought I would share! 😎

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

3 participants