Realm Xamarin v10.0.1 Release Notes

Release Date: 2021-02-02 // over 3 years ago
  • ๐Ÿ’ฅ Breaking Changes

    • ๐Ÿ— We no longer support Realm Cloud (legacy), but instead the new MongoDB Realm Cloud. MongoDB Realm is a serverless platform that enables developers to quickly build applications without having to set up server infrastructure. MongoDB Realm is built on top of MongoDB Atlas, automatically integrating the connection to your database. (#2011)
    • โœ‚ Remove support for Query-based sync, including the configuration parameters and the SyncSubscription types. (#2011)
    • โœ‚ Remove everything related to sync permissions, including both the path-based permission system and the object-level privileges for query-based sync. Permissions in MongoDB Realm are defined serverside. (#2011)
    • ๐Ÿšš Moved all API for dynamic access on the Realm class to Realm.DynamicApi:
      • Realm.CreateObject(string className, object primaryKey) is now Realm.DynamicApi.CreateObject(string className, object primaryKey).
      • Realm.All(string className) is now Realm.DynamicApi.All(string className).
      • Realm.RemoveAll(string className) is now Realm.DynamicApi.RemoveAll(string className).
      • Realm.Find(string className, long? primaryKey) is now Realm.DynamicApi.Find(string className, long? primaryKey).
      • Realm.Find(string className, string primaryKey) is now Realm.DynamicApi.Find(string className, string primaryKey).
    • It is now required that all top-level objects in a synchronized Realm have a primary key called _id. You can use the MapTo("_id") attribute to avoid using unidiomatic names for the model properties.
    • โฌ†๏ธ Bumped the minimum target for Xamarin.iOS apps to iOS 9.
    • โฌ†๏ธ Bumped the minimum API level for Xamarin.Android apps to 16 (Android 4.1).
    • ๐Ÿ”€ Renamed FullSyncConfiguration to SyncConfiguration.
    • โœ‚ Removed RealmObject.FreezeInPlace. To freeze a realm object use the Freeze extension method. (Issue #2180)

    โœจ Enhancements

    • โž• Added support for syncing to MongoDB instead of Realm Object Server. Applications must be created at realm.mongodb.com.
    • โž• Added an App class which is the entrypoint for synchronizing with a MongoDB Realm App.
    • โž• Added User.CustomData containing an unstructured document with additional information about the user. Custom data is configured in your MongoDB Realm App.
    • โž• Added User.Functions. This is the entry point for calling Remote MongoDB Realm functions. Functions allow you to define and execute server-side logic for your application. Functions are written in modern JavaScript (ES6+) and execute in a serverless manner. When you call a function, you can dynamically access components of the current application as well as information about the request to execute the function and the logged in user that sent the request.
    • โž• Added User.GetMongoClient exposing an API for CRUD operations on a Remote MongoDB Service.
    • โž• Added User.GetPushClient exposing an API for registering a device for push notifications.
    • ๐Ÿ”„ Change SyncConfiguration to accept partition value instead of a server Uri. Partition values can currently be of types string, long, or ObjectId. Opening a realm by partition value is the equivalent of previously opening a realm by URL. In this case, partitions are meant to be more closely associated with your data. E.g., if you are a large retailer with multiple locations, the partition key can be the store Id and you each Realm will only contain data related to the specified store.
    • โž• Add support for the Decimal128 data type. This is a 128-bit IEEE 754 decimal floating point number. Properties of this type can be declared either as MongoDB.Bson.Decimal128 type or the built-in decimal type. Note that .NET's built-in decimal is 96-bit, so it cannot represent the full range of numbers, representable by Decimal128. (PR #2014)
    • โž• Add support for the ObjectId data type. This is a 12 byte unique identifier that is common as a document id in MongoDB databases. It can be used as primary key. (PR #2035)
    • โž• Add support for embedded objects. Embedded objects are objects which are owned by a single parent object, and are deleted when that parent object is deleted or their parent no longer references them. Embedded objects are declared by subclassing EmbeddedObject instead of RealmObject. Reassigning an embedded object is not allowed and neither is linking to it from multiple parents. Querying for embedded objects directly is also disallowed as they should be viewed as complex structures belonging to their parents as opposed to standalone objects. A trivial example is:
      public class Address : EmbeddedObject
      {
          public string Street { get; set; }
    
          public string City { get; set; }
      }
    
      public class Person : RealmObject
      {
          public string Name { get; set; }
    
          // Address is an embedded object - you reference it as usual
          public Address Address { get; set; }
      }
    
      public class Company : RealmObject
      {
          public string PhoneNumber { get; set; }
    
          // Embedded objects can be contained in lists too
          public IList<Address> OfficeAddresses { get; }
      }
    
    • โž• Added new dynamic methods for instantiating embedded objects:

      • Realm.DynamicApi.CreateEmbeddedObjectForProperty should be used to create an embedded object and assign it to a parent's property. For example:
      // static API
      var person = new Person();
      person.Address = new Address
      {
          City = "New York"
      };
      
      // dynamic API
      var dynamicPerson = realm.DynamicApi.CreateObject("Person");
      var address = realm.DynamicApi.CreateEmbeddedObjectForProperty(dynamicPerson, "Address")
      address.City = "New York";
      
      • Realm.DynamicApi.AddEmbeddedObjectToList should be used to create an embedded object and add it to a parent's list property.
      • Realm.DynamicApi.InsertEmbeddedObjectInList should be used to create an embedded object and insert it in a parent's list property at a specified index.
      • Realm.DynamicApi.SetEmbeddedObjectInList should be used to create an embedded object and set it at an index in a parent's list property.
      // static API
      var company = new Company();
      company.OfficeAddresses.Add(new Address
      {
          City = "New York"
      });
      
      company.OfficeAddresses.Insert(0, new Address
      {
          City = "Palo Alto"
      });
      
      company.OfficeAddresses[1] = new Address
      {
          City = "New Jersey"
      };
      
      // dynamic API
      var dynamicCompany = realm.DynamicApi.CreateObject("Company");
      var officeToAdd = realm.DynamicApi.AddEmbeddedObjectToList(dynamicCompany.OfficeAddresses);
      officeToAdd.City = "New York";
      
      var officeToInsert = realm.DynamicApi.InsertEmbeddedObjectInList(dynamicCompany.OfficeAddresses, 0);
      officeToInsert.City = "Palo Alto";
      
      var officeToSet = realm.DynamicApi.SetEmbeddedObjectInList(dynamicCompany.OfficeAddresses, 1);
      officeToSet.City = "New Jersey";
      
    • ๐Ÿ‘ The memory mapping scheme for Realm files has changed to better support opening very large files.

    • Replaced the implementation of the string query parser (the one used for realm.All().Filter("some-string-query")). This results in ~5% reduction of the size of the native binary while keeping the query execution times on par with the old parser. (PR #2185, Core upgrade)

    • ๐ŸŽ Optimized the internal code that handles conversions between types. This should result in a minor performance increase for most data operations that should be most noticeable on Ahead-of-Time compiled platforms, such as iOS/UWP. Due to the nature of the change, it's possible that conversions that previously happened automatically when working with dynamic objects no longer do. If you encounter a NotSupportedException with the message No conversion exists from *type A* to *type B* and believe this is a bug, please open a Github Issue. (PR #2149)

    • โž• Added an extra compile-time check to detect erroneous List declarations and suggest IList for collection properties in Realm objects. (Issue #2083)

    • โž• Added overloads for Realm.Write and Realm.WriteAsync that can return a value. (Issue #2081)

    ๐Ÿ›  Fixed

    • ๐Ÿš€ Worked around an issue with the .NET Native compiler (used in UWP projects) that would result in the following exception being thrown in Release: Incompatible MarshalAs detected in parameter named 'value'. Please refer to MCG's warning message for more information.. (Issue #2169)
    • ๐Ÿ›  Fixed a bug that could cause incorrect property values to be read during a migration for apps running on .NET Core 3.0 or newer. The issue manifests itself when different classes have persisted properties with the same name and could result in the wrong property being accessed - e.g. foo.Name could return foo.Bar. This could only happen when using the dynamic API during a migration and does not affect apps that use the strongly typed API or run on platforms other than .NET Core 3.x/.NET 5.
    • ๐Ÿ›  Fixed a bug that could cause a deadlock in a multiprocess scenario where multiple processes share the same Realm file and listen for notifications from the file. (Core upgrade)
    • ๐Ÿ›  Fixed an issue with deleting and recreating objects with embedded objects. (Core upgrade)
    • ๐Ÿ›  Fix a race condition which would lead to "uncaught exception in notifier thread: N5realm15InvalidTableRefE: transaction_ended" and a crash when the source Realm was closed or invalidated at a very specific time during the first run of a collection notifier (Core upgrade)
    • ๐Ÿ›  Fix crash in case insensitive query on indexed string columns when nothing matches (Core upgrade)

    Compatibility

    • Realm Studio: 10.0.0 or later.

    Internal

    • Using Core 10.3.3.
    • ๐Ÿ“œ Migrated to bison parser.
    • ๐Ÿ“ˆ Submit Analytics to S3/Segment in addition to Mixpanel.
    • ๐Ÿ“ˆ Analytics now also reports if Sync functionality is in use.
    • โœ… SDK is now also tested against .NET 5.
    • ๐Ÿš€ This release uses monorepo releases that bundle Core, Sync, and OS.
    • Replaced Expressions-based Operator with T4. (PR #2149)