Releases: realm/realm-dotnet
10.9.0 - Flexible Sync support
10.9.0 (2022-01-21)
Enhancements
-
Added support for a new mode of synchronization with MongoDB Realm, called "Flexible Sync". When using Flexible Sync, the client decides which queries it's interested in and asks the server for all objects matching these queries. The matching objects will be stored in a local Realm, just like before and can be queried and accessed while offline. This feature is in beta, so feedback - both positive and negative - is greatly appreciated and, as usual, we don't recommend using it for production workloads yet.
- Added a new configuration type, called
FlexibleSyncConfiguration
. Use this type to get aRealm
instance that uses the new synchronization mode with the server. - Deprecated the
SyncConfiguration
class in favor ofPartitionSyncConfiguration
. The two classes are equivalent and the new type is introduced to better contrast withFlexibleSyncConfiguration
. The two types are equivalent and allow you to open aRealm
instance that is using the old "Partition Sync" mode. - Added a new type, called
SubscriptionSet
. It is a collection, holding the various active query subscriptions that have been created for this Realm. This collection can be accessed via theRealm.Subscriptions
property. It will benull
for local and partition sync Realms and non-null for flexible sync Realms.
A minimal example would look like this:
var config = new FlexibleSyncConfiguration(user); var realm = Realm.GetInstance(config); // Add a new subscription realm.Subscriptions.Update(() => { var year2022 = new DateTimeOffset(2022, 1, 1); var saleOrders = realm.All<SaleOrder>().Where(o => o.Created > year2022); realm.Subscriptions.Add(saleOrders); }); // Wait for the server to acknowledge the subscription and return all objects // matching the query await realm.Subscriptions.WaitForSynchronizationAsync(); // Now we have all orders that existed on the server at the time of // subscribing. From now on, the server will send us updates as new // orders get created. var orderCount = realm.All<SaleOrder>().Count();
- Multiple subscriptions can be created for queries on the same class, in which case they'll be combined with a logical
OR
. For example, if you create a subscription for all orders created in 2022 and another for all orders created by the current user, your local Realm will contain the union of the two result sets. - Subscriptions can be named (which makes it easier to unsubscribe) or unnamed. Adding multiple unnamed subscriptions with the same query is a no-op.
- Modifying the set of active subscriptions is an expensive operation server-side, even if the resulting diff is not large. This is why we recommend batching subscription updates as much as possible to avoid overloading the server instance. A good practice is to declare the user subscriptions upfront - usually the first time the Realm is opened, and only update them when absolutely necessary.
- Find more information about the API and current limitations in the docs.
- Added a new configuration type, called
Compatibility
- Realm Studio: 11.0.0 or later.
10.8.0
10.8.0 (2022-01-17)
Enhancements
- Added the
RealmConfigurationBase.FallbackPipePath
property. In the majority of cases this property can be left null, but it should be used when a realm is opened on a filesystem where named pipes cannot be created, such as external storage on Android that uses FAT32. In this case the path needs to point to a location on another filesystem where named pipes can be created. (PR #2766) - Added support arithmetric operations (+, -, *, /) in the string-based query syntax (
realm.All<Foo>().Filter("some-query")
). Operands can be properties and/or constants of numeric types (integer, float, double or Decimal128). You can now write a query like"(age + 5) * 2 > child.age"
. (Core upgrade)
Fixed
- Fixed a race condition that could result in
Sharing violation on path ...
error when opening a Unity project on macOS. (Issue #2720, fix by @tomkrikorian) - Fixed an error being thrown when
Realm.GetInstance
is called multiple times on a readonly Realm. (Issue #2731) - Fixed a bug that would result in the
LIMIT
clause being ignored whenCount()
is invoked on aIQueryable
- e.g. expressions likerealm.All<Foo>().Filter("Bar > 5 LIMIT(1)).Count()
would ignore the limit in the string-based predicate and return the count of all matches. (Issue #2755) - Fixed the logic in
RealmResultsVisitor.TraverseSort
to allow sorting on interface properties. (Issue #1373, contribution by @daawaan)
Compatibility
- Realm Studio: 11.0.0 or later.
10.7.1 - Bug fixes
Fixed
- A sync user's Realm was not deleted when the user was removed if the Realm path was too long such that it triggered the fallback hashed name (this is OS dependant but is 300 characters on linux). (Core upgrade)
- Don't keep trying to refresh the access token if the client's clock is more than 30 minutes ahead. (Core upgrade)
- Don't sleep the sync thread artificially if an auth request fails. This could be observed as a UI hang on applications when sync tries to connect after being offline for more than 30 minutes. (Core upgrade)
Compatibility
- Realm Studio: 11.0.0 or later.
10.7.0 - bug fixes
Enhancements
- Added the
Realm.SyncSession
property which will return the sync session for this Realm if the Realm is a synchronized one ornull
for local Realms. This is replacing theGetSession(this Realm)
extension method which is now deprecated. (PR #2711)
Fixed
- Fixed a bug that would result in a
RealmException
being thrown when opening a readonly Realm with schema that is a superset of the schema on disk. Now the code will just work and treat any classes not present in the on-disk schema to be treated as empty collections - e.g.realm.All<ThisIsNotInOnDiskSchema>().Count == 0
. (Issue #2619) - Fixed a bug that would create a "Documents" folder in the binary app folder when the ransomware protection in Windows is turned on. (Issue #2685)
- Fixed an issue that would cause incorrect property implementation to be generated if
PropertyChanged.Fody
runs after the Realm weaver. (Issue #1873) - [Unity] Preserved additional constructors necessary to serialize and deserialize Custom User Data. (PR #2519)
- Fixed an issue that would result in
InvalidOperationException
when concurrently creating aRealmConfiguration
with an explicitly setSchema
property. (Issue #2701) - [Unity] Fixed an issue that would result in
NullReferenceException
when building for iOS when the Realm package hasn't been installed via the Unity Package Manager. (Issue #2698) - Fixed a bug that could cause properties of frozen objects to return incorrect value/throw an exception if the provided Realm schema didn't match the schema on disk. (Issue #2670)
- Fixed a rare assertion failure or deadlock when a sync session is racing to close at the same time that external reference to the Realm is being released. (Core upgrade)
- Fixed an assertion failure when opening a sync Realm with a user who had been removed. Instead an exception will be thrown. (Core upgrade)
- Fixed a rare segfault which could trigger if a user was being logged out while the access token refresh response comes in. (Core upgrade)
- Fixed a bug where progress notifiers continue to be called after the download of a synced realm is complete. (Core upgrade)
- Allow for EPERM to be returned from fallocate(). This improves support for running on Linux environments with interesting filesystems, like AWS Lambda. Thanks to @ztane for reporting and suggesting a fix. (Core upgrade)
- Fixed a user being left in the logged in state when the user's refresh token expires. (Core upgrade)
- SyncManager had some inconsistent locking which could result in data races and/or deadlocks, mostly in ways that would never be hit outside of tests doing very strange things. (Core upgrade)
Compatibility
- Realm Studio: 11.0.0 or later.
10.6.0 - Runtime schema definition
Enhancements
-
Added two extension methods on
ISet
to get anIQueryable
collection wrapping the set:set.AsRealmQueryable()
allows you to get aIQueryable<T>
fromISet<T>
that can be then treated as a regular queryable collection and filtered/ordered with LINQ orFilter(string)
.set.Filter(query, arguments)
will filter the set and return the filtered collection. It is roughly equivalent toset.AsRealmQueryable().Filter(query, arguments)
.
The resulting queryable collection will behave identically to the results obtained by calling
realm.All<T>()
, i.e. it will emit notifications when it changes and automatically update itself. (Issue #2555) -
Added two new methods on
Migration
(Issue #2543):RemoveType(typeName)
allows to completely remove a type and its schema from a realm during a migration.RenameProperty(typeName, oldPropertyName, newPropertyName)
allows to rename a property during a migration.
-
A Realm Schema can now be constructed at runtime as opposed to generated automatically from the model classes. The automatic generation continues to work and should cover the needs of the vast majority of Realm users. Manually constructing the schema may be required when the shape of the objects depends on some information only known at runtime or in very rare cases where it may provide performance benefits by representing a collection of known size as properties on the class. (Issue #824)
RealmConfiguration.ObjectClasses
has now been deprecated in favor ofRealmConfiguration.Schema
.RealmSchema
has an implicit conversion operator fromType[]
so code that previously looked likeObjectClasses = new[] { typeof(Foo), typeof(Bar) }
can be trivially updated toSchema = new[] { typeof(Foo), typeof(Bar) }
.Property
has been converted to a read-only struct by removing the setters from its properties. Those didn't do anything previously, so we don't expect anyone was using them.- Added several factory methods on
Property
to simplify declaration of Realm properties by being explicit about the range of valid options - e.g.Property.FromType<int>("IntProperty")
orProperty.Object("MyPersonProp", "Person")
. The constructor ofProperty
is now public to support advanced scenarios, but we recommend using the factory methods. - Made
ObjectSchema.Builder
public and streamlined its API. It allows you to construct a mutable representation of the schema of a single object and add/remove properties to it. You can either get an empty builder or you can see it with the information from an existing model class (i.e. inheriting fromRealmObject
orEmbeddedObject
). - Made
RealmSchema.Builder
public and streamlined its API. It allows you to construct a mutable representation of the schema of an entire Realm and add/remove object schemas to it. - A simple example for how to use the new API would look like:
public class Person : RealmObject { public string Name { get; set; } public Address Address { get; set; } } // Declare schema from existing model classes var config = new RealmConfiguration { Schema = new[] { typeof(Person), typeof(Address) } }; // Manually construct a schema - we don't need to call .Build() on the builders // because we have implicit conversion operators defined that will call it for us. // Explicitly calling .Build() is also perfectly fine, if a little more verbose. var config = new RealmConfiguration { Schema = new RealmSchema.Builder { new ObjectSchema.Builder("MyClass", isEmbedded: false) { Property.FromType<int>("Id", isPrimaryKey: true), Property.PrimitiveDictionary("Tags", RealmValueType.String) }, new ObjectSchema.Builder("EmbeddedClass", isEmbedded: true) { Property.Primitive("DateProp", RealmValueType.Date, isNullable: true) } } }; // Enhance an existing model with new properties that will be accessible via // the dynamic API. var personSchema = new ObjectSchema.Builder(typeof(Person)) { Property.FromType<string>("NewStringProp") }; var config = new RealmConfiguration { Schema = new RealmSchema.Builder { personSchema, new ObjectSchema.Builder(typeof(Address)) } }; // Regular Person properties can be accessed as usual while runtime defined ones // need to go through the dynamic API. var person = realm.All<Person>().First(); var name = person.Name; var stringPropValue = person.DynamicApi.Get<string>("NewStringProp");
-
Fixed an issue that would result in SIGABORT on macOS/Linux when opening a Realm in dynamic mode (i.e. read the schema from disk) and the schema contains an object with no properties. (Issue #1978)
Compatibility
- Realm Studio: 11.0.0 or later.
Internal
- Using Core 11.4.1.
- Moved perf tests to run on a self-hosted runner. (PR #2638)
10.5.1 - Bug fixes
Fixed
- Fixed a bug that would cause a
NullReferenceException
to be reported during compilation of a class containing a getter-onlyRealmObject
property. (Issue #2576) - Fixed an issue that would result in
Unable to load DLL 'realm-wrappers'
when deploying a WPF .NET Framework application with ClickOnce. This was due to the incorrect BuildAction type being applied to the native libraries that Realm depends on. (Issue #1877) - [Unity] Fixed an issue that would fail Unity builds with
Multiple precompiled assemblies with the same name Mono.Cecil.dll
if importing the Realm package into a project that already referencesMono.Cecil
. (Issue #2630) - Fixed a bug that would sometimes result in assemblies not found at runtime in a very specific edge scenario. More details about such a scenario can be found in its PR's description. (Issue #1568)
Compatibility
- Realm Studio: 11.0.0 or later.
Internal
- Using Core 11.4.1.
10.5.0
Enhancements
- ThreadSafeReference no longer pins the source transaction version for anything other than a Results backed by a Query. (Core upgrade)
- A ThreadSafeReference to a Results backed by a collection can now be created inside a write transaction as long as the collection was not created in the current write transaction. (Core upgrade)
- Synchronized Realms are no longer opened twice, cutting the address space and file descriptors used in half. (Core upgrade)
Fixed
- If an object with a null primary key was deleted by another sync client, the exception
KeyNotFound: No such object
could be triggered. (Core upgrade) - Fixed a race condition that could result in an assertion
m_state == SyncUser::State::LoggedIn
if the app previously crashed during user logout. (Core upgrade)
Compatibility
- Realm Studio: 11.0.0 or later.
Internal
10.4.1
Fixed
- Fixed a regression that would prevent the SDK from working on older Linux versions. (Issue #2602)
- Fixed an issue that manifested in circumventing the check for changing a primary key when using the dynamic API - i.e.
myObj.DynamicApi.Set("Id", "some-new-value")
will now correctly throw aNotSupportedException
if"some-new-value"
is different frommyObj
's primary key value. (PR #2601)
Compatibility
- Realm Studio: 11.0.0 or later.
10.4.0 - Bug fixes and small improvements
Fixed
- Fixed an issue that would cause
Logger.Default
on Unity to always revert toDebug.Log
, even when a custom logger was set. (Issue #2481) - Fixed an issue where
Logger.Console
on Unity would still useConsole.WriteLine
instead ofDebug.Log
. (Issue #2481) - Added serialization annotations to RealmObjectBase to prevent Newtonsoft.Json and similar serializers from attempting to serialize the base properties. (Issue #2579)
- Fixed an issue that would cause an
InvalidOperationException
when removing an element from an UI-bound collection in WPF. (Issue #1903) - User profile now correctly persists between runs. (Core upgrade)
- Fixed a crash when delivering notifications over a nested hierarchy of lists of RealmValue that contain RealmObject inheritors. (Core upgrade)
- Fixed a crash when an object which is linked to by a RealmValue property is invalidated (sync only). (Core upgrade)
- Fixes prior_size history corruption when replacing an embedded object in a list. (Core upgrade)
- Fixed an assertion failure in the sync client when applying an AddColumn instruction for a RealmValue property when that property already exists locally. (Core upgrade)
- Fixed an
Invalid data type
assertion failure in the sync client when applying anAddColumn
instruction for aRealmValue
property when that property already exists locally. (Core upgrade)
Enhancements
-
Added two extension methods on
IList
to get anIQueryable
collection wrapping the list:list.AsRealmQueryable()
allows you to get aIQueryable<T>
fromIList<T>
that can be then treated as a regular queryable collection and filtered/ordered with LINQ orFilter(string)
.list.Filter(query, arguments)
will filter the list and return the filtered collection. It is roughly equivalent tolist.AsRealmQueryable().Filter(query, arguments)
.
The resulting queryable collection will behave identically to the results obtained by calling
realm.All<T>()
, i.e. it will emit notifications when it changes and automatically update itself. (Issue #1499) -
Added a cache for the Realm schema. This will speed up
Realm.GetInstance
invocations whereRealmConfiguration.ObjectClasses
is explicitly set. The speed gains will depend on the number and complexity of your model classes. A reference benchmark that tests a schema containing all valid Realm property types showed a 25% speed increase of Realm.GetInstance. (Issue #2194) -
Improve performance of creating collection notifiers for Realms with a complex schema. In the SDKs this means that the first run of a synchronous query, first call to subscribe for notifications will do significantly less work on the calling thread.
-
Improve performance of calculating changesets for notifications, particularly for deeply nested object graphs and objects which have List or Set properties with small numbers of objects in the collection.
-
Query parser now accepts
BETWEEN
operator. Can be used likerealm.All<Person>().Filter("Age BETWEEN {20, 60}")
which means "'Age' must be in the open interval ]20;60[". (Core upgrade)
Compatibility
- Realm Studio: 11.0.0 or later.
10.3.0 - Unity Support
This release marks our Unity support as GA. This means that our automated tests pass on all supported platforms. We've also done extensive manual testing and believe the SDK is of high enough quality for production use. Take a look at the docs for more information on how to get started or head over to MongoDB .live for a walkthrough of using the local database and Sync in a Unity game.
Note: This release uses xcframework and enables bitcode for the iOS native libraries. This significantly increases the package size and may appear to increase the .ipa size when compiling for iOS. However, the bitcode portion, as well as the unnecessary architectures, will be trimmed by the App Store, so the size of the actual download sent to users will be unchanged or smaller than before.
Fixed
- Fixed an issue that would prevent
realm-wrappers.dll
from being loaded on Windows 8.1. (Issue #2298) - Fixed an assertion failure when listening for changes to a list of primitive Mixed which contains links. (Core upgrade)
- Fixed an assertion failure when listening for changes to a dictionary or set which contains an invalidated link. (Core upgrade)
- Fixed an endless recursive loop that could cause a stack overflow when computing changes on a set of objects which contained cycles. (Core upgrade)
- Add collision handling to Dictionary implementation. (Core upgrade)
- Fixed a crash after clearing a list or set of Mixed containing links to objects. (Core upgrade)
- Fixed a recursive loop which would eventually crash trying to refresh a user app token when it had been revoked by an admin. Now this situation logs the user out and reports an error. (Core upgrade)
- Fixed a race between calling
Realm.DeleteRealm
and concurrent opening of the realm file. (Core upgrade) - [Unity] Added code to preserve the constructors of several base serializers to ensure that most of the basic serialization/deserialization workloads work out of the box. (PR #2489)
Enhancements
- Changed the native iOS library to use xcframework. This means that running in the simulator on M1 macs is now supported. (Issue #2240)
- Added bitcode to the native iOS library. This has no effect on Xamarin.iOS, but allows Unity applications to take advantage of optimizations performed by the App Store servers and eventually support new architectures as they are released. (Issue #2240)
Compatibility
- Realm Studio: 11.0.0 or later.
- This release uses xcframework for the iOS native libraries, which requires Xamarin.iOS 14.14.2.5 or later.