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

Collections marshalling improvements #344

Merged
merged 5 commits into from
Aug 1, 2024
Merged

Conversation

jasongin
Copy link
Member

@jasongin jasongin commented Aug 1, 2024

Fixes: #242

  • Marshal the collection classes in the System.Collections.Generic namespace, such as List<>, Queue<>, Stack<>, HashSet<>, and Dictionary<>.
    • Since these classes are all sealed they cannot be overridden to proxy collection data access to JS. Therefore the collections are marshalled by value, similar to .NET arrays.
  • Marshal some collection classes in the System.Collections.ObjectModel namespace, such as Collection<> and ReadOnlyDictionary<>.
    • These classes can be marshalled by reference, similar to the generic collection interfaces, because they are already designed to wrap/proxy access to other collections.
    • ObservableCollection<> is not supported for now. It could be possible to support observability in JS, but that will depend on events support (Marshalling: Events #59).
  • Add a JSPropertyDescriptor.ToObject() conversion and use it with JSProxy.GetOwnPropertyDescriptor to allow for more convenient proxying of that method.
  • Fix a bug in iteration of JS collection proxies - it required additional proxy traps.
  • Update the doc page about collections.

Non-generic collections are still not supported. (#243)

@jasongin jasongin requested a review from vmoroz August 1, 2024 17:23
@jasongin jasongin merged commit ecd2bca into main Aug 1, 2024
24 checks passed
@jasongin jasongin deleted the dev/jasongin/collections branch August 1, 2024 22:43
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

Successfully merging this pull request may close these issues.

Marshalling: Collection classes like List<T>, Dictionary<T>, ReadOnlyCollection<T>
2 participants