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 of Mixed #3441

Merged
merged 97 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from 96 commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
49e0200
Added stub
papafe Sep 5, 2023
572704f
Stubs with comments
papafe Sep 5, 2023
3f0ed7f
Notes
papafe Sep 14, 2023
197aee1
Various fixes
papafe Sep 14, 2023
3f46db7
Updated core
papafe Sep 14, 2023
d4601c0
Finished stub
papafe Sep 14, 2023
c0f01c8
Removed comment [skip-ci]
papafe Sep 14, 2023
877190e
Removed unused
papafe Sep 15, 2023
686d5fe
Added stub for lists in lists
papafe Sep 20, 2023
b9c5a8f
Fixed error with null and added basic test with all types
papafe Sep 21, 2023
dfd7697
Improved base testing for list, added support for add/insert/set and …
papafe Sep 22, 2023
cda7a87
Improved test and removed useless content
papafe Sep 22, 2023
7727f37
Added tests
papafe Sep 25, 2023
2fdefc7
Small fixes
papafe Sep 25, 2023
cdeaa4c
Small fixes
papafe Sep 25, 2023
943e6d9
Merge branch 'main' into fp/mixed-collections plus moved core to next…
papafe Sep 25, 2023
0c888ce
Added common method for creating a list and adding elements
papafe Sep 27, 2023
19f2167
Fixed error [skip-ci]
papafe Sep 27, 2023
064a559
Added set and dictionary to primitive value
papafe Sep 27, 2023
9b75290
Various improvements
papafe Sep 28, 2023
87b7ce3
Added conversion per list
papafe Sep 28, 2023
4711912
Fixed Operator
papafe Sep 28, 2023
84fd027
Added missing conversion methods
papafe Sep 28, 2023
acf2b82
Corrected wrapper
papafe Sep 28, 2023
bbc8f43
Added test helper method for realm value types and removed unused ref…
papafe Sep 28, 2023
4cb3020
Added missing types for marshaling
papafe Sep 28, 2023
b0e4cd9
Small improvement in operator
papafe Sep 28, 2023
4785943
Small corrections
papafe Sep 28, 2023
013bfb7
Added error for sets adding collections
papafe Sep 29, 2023
143f27c
Trting to uniform access
papafe Sep 29, 2023
b13f4aa
Created common method for collections
papafe Sep 29, 2023
bf9aff5
Various improvements [skip-ci]
papafe Oct 2, 2023
5db21f4
Fixed dictionary and added more tests
papafe Oct 2, 2023
17fb66f
Small corrections
papafe Oct 2, 2023
3231490
Improved tests for dictionaries
papafe Oct 3, 2023
a70b483
Small fixes
papafe Oct 3, 2023
da46cb9
Simplified set collection on object
papafe Oct 3, 2023
9e60c87
Added test for dynamic and simplified collection generation
papafe Oct 16, 2023
cf6387f
Updated db
papafe Oct 17, 2023
b82e5be
Updated changelog [skip-ci]
papafe Oct 17, 2023
956a0a1
Updated another db
papafe Oct 17, 2023
87074ce
Updated db
papafe Oct 17, 2023
d0042f6
Updated changelog
papafe Oct 17, 2023
6598fd5
Merge branch 'main' into fp/mixed-collections
papafe Oct 17, 2023
5954996
Test
papafe Oct 17, 2023
2fdea52
Fix to generated files
papafe Oct 18, 2023
9dfc21c
Test
papafe Oct 18, 2023
4a4c6d1
Small improvement
papafe Oct 23, 2023
452924d
Added field offset
papafe Oct 31, 2023
0620eb6
Working version
papafe Oct 31, 2023
47acf8b
Small renaming
papafe Oct 31, 2023
78271b6
Reordering
papafe Nov 1, 2023
08cbb78
Working version
papafe Nov 1, 2023
a833eb6
Solution 1
papafe Nov 1, 2023
b01ef4f
Final version of the RealmValue explicit layout
papafe Nov 1, 2023
9163497
Merge branch 'main' into fp/mixed-collections
papafe Nov 1, 2023
dca0b97
Added changelog
papafe Nov 1, 2023
778b1fc
Removed set from RealmValue
papafe Nov 13, 2023
dc4545e
Continuing removal of set
papafe Nov 13, 2023
2498be7
Simplified CreateInternalCollectionAndPopulate
papafe Nov 13, 2023
ff99118
Ulterior removal of set and added method parameter name
papafe Nov 14, 2023
7f0456f
Removed other set-related things, added implicit method from array of…
papafe Nov 14, 2023
77c439e
Changed name to method
papafe Nov 14, 2023
aa1a315
Added explicit sequence equals
papafe Nov 14, 2023
041e0cf
Unified set_collection and add_collection for dictionary
papafe Nov 14, 2023
c803df9
Moved _intValue out of primitiveValue
papafe Nov 14, 2023
0d92fef
Removed unnecessary structs
papafe Nov 14, 2023
fac6d3a
Changed return value
papafe Nov 14, 2023
90bb0bc
Small corrections
papafe Nov 14, 2023
4d7a056
Fixed changelog
papafe Nov 14, 2023
0a57641
Updated core and a couple of fixes
papafe Feb 26, 2024
6057b25
Small corrections
papafe Feb 26, 2024
c79f63d
Updated dbs
papafe Feb 26, 2024
b77685f
Merge remote-tracking branch 'refs/remotes/origin/fp/update-to-core-1…
papafe Feb 26, 2024
2e98c0a
Updated core to 14.0.1 and changelog
papafe Feb 27, 2024
3db20b5
Added test for collection indexes
papafe Feb 27, 2024
82c6b50
Updated changelog
papafe Feb 27, 2024
ee596a5
Fixed realm studio version
papafe Feb 27, 2024
ef0075e
Updated guids to v24
papafe Feb 28, 2024
26bfc48
Corrected methods
papafe Feb 28, 2024
28b8b88
Corrected changelog and wrapper
papafe Feb 28, 2024
2479b2a
Added comments
papafe Feb 28, 2024
2a8e89e
Corrected changelog
papafe Feb 28, 2024
bf98fd4
Corrected changelog
papafe Feb 28, 2024
2d04e61
Updated core
papafe Mar 5, 2024
b5d6e1d
Updated changelog
papafe Mar 5, 2024
41effa6
Merge branch 'main' into fp/mixed-collections
papafe Mar 5, 2024
cc0e5aa
Merge branch 'fp/update-to-core-14' into fp/mixed-collections
papafe Mar 5, 2024
b41a033
Used correct core version
papafe Mar 5, 2024
1b346ca
Merge branch 'main' into fp/mixed-collections
papafe Mar 5, 2024
8149c89
Fixed changelog
papafe Mar 5, 2024
bfd027f
Fixed changelog
papafe Mar 5, 2024
cab3aae
Merge branch 'main' into fp/mixed-collections
papafe Mar 6, 2024
69d0610
Added missing tests
papafe Mar 6, 2024
7a8de04
Fixed tests
papafe Mar 7, 2024
cbb7cb8
Merge branch 'main' into fp/mixed-collections
papafe Mar 7, 2024
0d40c41
[RNET-1092] Added support for indexed RealmValue (#3544)
papafe Mar 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@
* Opening realm with file format 23 or lower (Realm .NET versions earlier than 12.0.0) in read-only mode will crash. (Core 14.0.0)

### Enhancements
* Added support for list and dictionaries of `RealmValue` (`IList<RealmValue>` and `IDictionary<string, RealmValue>`) to be contained in a `RealmValue`. Lists and dictionaries can contain an arbitrary number of collections themselves. It is possible to convert an existing collection to a `RealmValue` using the new static methods `RealmValue.List` and `RealmValue.Dictionary` or using the implicit operators if converting from common types like `List`, `RealmValue[]` or `Dictionary`. Finally, it is possible to obtain the contained collections by using the new conversion method `AsList` and `AsDictionary`. For example:

```csharp
var list = new List<RealmValue> { 1, true, "stringVal" };

var rvo = realm.Write(() =>
{
return realm.Add(new RealmValueObject { RealmValueProperty = list});
});

var retrievedList = rvo.RealmValueProperty.AsList();
```
(PR [#3441](https://github.com/realm/realm-dotnet/pull/3441))
* Reduced memory usage of `RealmValue`. (PR [#3441](https://github.com/realm/realm-dotnet/pull/3441))
* Add support for passing a key paths collection (`KeyPathsCollection`) when using `IRealmCollection.SubscribeForNotifications`. Passing a `KeyPathsCollection` allows to specify which changes in properties should raise a notification.

A `KeyPathsCollection` can be obtained by:
Expand Down
17 changes: 17 additions & 0 deletions Realm/Realm/DatabaseTypes/RealmDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ public TValue this[string key]
ValidateKey(key);
var realmValue = Operator.Convert<TValue, RealmValue>(value);

if (realmValue.Type.IsCollection())
{
CollectionHelpers.PopulateCollection(Realm, _dictionaryHandle.SetCollection(key, realmValue.Type), realmValue);
return;
}

if (_isEmbedded && realmValue.Type != RealmValueType.Null)
{
if (IsDynamic)
Expand Down Expand Up @@ -124,6 +130,12 @@ public void Add(string key, TValue value)
ValidateKey(key);
var realmValue = Operator.Convert<TValue, RealmValue>(value);

if (realmValue.Type.IsCollection())
{
CollectionHelpers.PopulateCollection(Realm, _dictionaryHandle.AddCollection(key, realmValue.Type), realmValue);
return;
}

if (_isEmbedded && realmValue.Type != RealmValueType.Null)
{
if (IsDynamic)
Expand Down Expand Up @@ -163,6 +175,11 @@ public bool Remove(KeyValuePair<string, TValue> item)
return false;
}

if (realmValue.Type.IsCollection())
{
return false;
}

return _dictionaryHandle.Remove(item.Key, realmValue);
}

Expand Down
26 changes: 25 additions & 1 deletion Realm/Realm/DatabaseTypes/RealmList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Dynamic;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using Realms.Dynamic;
using Realms.Helpers;
Expand Down Expand Up @@ -66,6 +67,12 @@ internal RealmList(Realm realm, ListHandle adoptedList, Metadata? metadata) : ba
ValidateIndex(index);
var realmValue = ValidateValueToInsert(value);

if (realmValue.Type.IsCollection())
{
CollectionHelpers.PopulateCollection(Realm, _listHandle.SetCollection(index, realmValue.Type), realmValue);
return;
}

if (_isEmbedded)
{
if (IsDynamic)
Expand All @@ -88,6 +95,12 @@ public void Add(T value)
{
var realmValue = ValidateValueToInsert(value);

if (realmValue.Type.IsCollection())
{
CollectionHelpers.PopulateCollection(Realm, _listHandle.AddCollection(realmValue.Type), realmValue);
return;
}

if (_isEmbedded)
{
if (IsDynamic)
Expand All @@ -112,6 +125,11 @@ public override int IndexOf([AllowNull] T value)
return -1;
}

if (realmValue.Type.IsCollection())
{
return -1;
}

return _listHandle.Find(realmValue);
}

Expand All @@ -120,6 +138,12 @@ public void Insert(int index, T value)
ValidateIndex(index);
var realmValue = ValidateValueToInsert(value);

if (realmValue.Type.IsCollection())
{
CollectionHelpers.PopulateCollection(Realm, _listHandle.InsertCollection(index, realmValue.Type), realmValue);
return;
}

if (_isEmbedded)
{
if (IsDynamic)
Expand Down Expand Up @@ -151,7 +175,7 @@ public override void RemoveAt(int index)
{
ValidateIndex(index);

_listHandle.Erase((IntPtr)index);
_listHandle.Erase(index);
}

#endregion
Expand Down
5 changes: 5 additions & 0 deletions Realm/Realm/DatabaseTypes/RealmSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ public bool Add(T value)

var realmValue = Operator.Convert<T, RealmValue>(value);

if (realmValue.Type.IsCollection())
{
throw new InvalidOperationException("Set cannot contain other collections.");
}

AddToRealmIfNecessary(realmValue);
return _setHandle.Add(realmValue);
}
Expand Down
Loading
Loading