Skip to content

Releases: realm/realm-dotnet

10.13.0

18 May 13:07
ffdb2bb
Compare
Choose a tag to compare

10.13.0 (2022-05-18)

Enhancements

  • Adds the functionality to convert Sync Realms into Local Realms and Local Realms into Sync Realms. (Issue #2746)
  • Added support for a new client reset strategy, called Discard Unsynced Changes. This new stragegy greatly simplifies the handling of a client reset event on a synchronized Realm.
    This addition makes Session.Error deprecated. In order to temporarily contiue using the current Session.Error the following must be done:
      var conf = new PartitionSyncConfiguration(partition, user)
      {
        ClientResetHandler = new ManualRecoveryHandler();
      };
    In order to take advantage of the new Discard Unsynced Changes feature, the following should be done (all callbacks are optional):
      var conf = new PartitionSyncConfiguration(partition, user)
      {
        ClientResetHandler = new DiscardLocalResetHandler
        {
          OnBeforeReset = (beforeFrozen) =>
          {
            // executed right before a client reset is about to happen
          },
          OnAfterReset = (beforeFrozen, after) =>
          {
            // executed right after a client reset is has completed
          },
          ManualResetFallback = (session, err) =>
          {
            // handle the reset manually
          }
        }
      };
    If, instead, you want to continue using the manual solution even after the end of the deprecation period, the following should be done
      var conf = new PartitionSyncConfiguration(partition, user)
      {
        ClientResetHandler = new ManualRecoveryHandler((sender, e) =>
        {
            // user's code for manual recovery
        });

Fixed

  • Fixed a System.DllNotFoundException being thrown by Realm APIs at startup on Xamarin.iOS (Issue #2926, since 10.12.0)

Compatibility

  • Realm Studio: 11.0.0 or later.

Internal

  • Using Core 11.14.0.

10.12.0

05 May 21:20
6ee01ed
Compare
Choose a tag to compare

10.12.0 (2022-05-05)

Note for Xamarin.iOS targets: This release has a regression that causes Realm to fail to find the native binaries on iOS when using the Xamarin toolchain (not MAUI), resulting in a System.DllNotFoundException the first time a Realm API is used. Since the release only contains MAUI-related changes, it is safe to roll back to 10.11.2. The fix for the regression will be released in 10.13.0.

Enhancements

  • Preview support for .NET 6 with iOS, Android, and MAUI.
    We've added tentative support for the new .NET 6 Mobile workloads (except MacCatalyst, which will be enabled later). The .NET tooling itself is still in preview so we don't have good test coverage of the new platforms just yet. Please report any issues you find at https://github.com/realm/realm-dotnet/issues/new/choose.

Compatibility

  • Realm Studio: 11.0.0 or later.

Internal

  • Using Core 11.14.0.

10.11.2

21 Apr 10:30
653353e
Compare
Choose a tag to compare

10.11.2 (2022-04-12)

Fixed

  • Fixed corruption bugs when encryption is used. (Core Issue #5360)

Compatibility

  • Realm Studio: 11.0.0 or later.

Internal

  • Using Core 11.14.0.

10.11.1

31 Mar 11:38
319d77a
Compare
Choose a tag to compare

10.11.1 (2022-03-31)

Fixed

  • Fixed an issue that would cause the managed HttpClientHandler to be used in Xamarin applications, even if the project is configured to use the native one. (Issue #2892)

Compatibility

  • Realm Studio: 11.0.0 or later.

Internal

  • Using Core 11.12.0.

10.11.0

28 Mar 15:22
36f4dc0
Compare
Choose a tag to compare

10.11.0 (2022-03-28)

Enhancements

  • Added property Session.ConnectionState to get a Session's SessionConnectionState. Additionally, Session now implements INotifyPropertyChanged so that you can listen for changes on Session.ConnectionState. (Issue #2801)
  • Realm now supports running on Windows ARM64 for .NET Framework, .NET Core, and UWP apps. (Issues #2704 and #2817)
  • Added a property AppConfiguration.HttpClientHandler that allows you to override the default http client handler used by the Realm .NET SDK to make http calls. Note that this only affects the behavior of http calls, such as user login, function calls, and remote mongodb calls. The sync client uses a native websocket implementation and will not use the provided message handler. (Issue #2865)

Fixed

  • [Unity] Fixed an issue that caused the weaver to fail when invoked via the Tools->Realm->Weave Assemblies editor menu with the error UnityEngine.UnityException: get_dataPath can only be called from the main thread. (Issue #2836)
  • Fixed an issue that caused RealmInvalidObjectException to be caused when enumerating an invalid Realm collection (e.g. a list belonging to a deleted object). (Issue #2840)
  • Query parser would not accept "in" as a property name (Core Issue #5312)
  • Application would sometimes crash with exceptions like 'KeyNotFound' or assertion "has_refs()". Other issues indicating file corruption may also be fixed by this. The one mentioned here is the one that lead to solving the problem. (Core Issue #5283)

Compatibility

  • Realm Studio: 11.0.0 or later.

Internal

  • Using Core 11.12.0.
  • Enabled running Benchmarks on iOS devices by turning on the interpreter for some windows assemblies.

10.10.0

28 Feb 15:06
344f8a1
Compare
Choose a tag to compare

10.10.0 (2022-02-28)

Guid representation issue

This release fixes a major bug in the way Guid values are stored in the database. It provides an automatic migration for local (non-synchronized) databases, but extra caution is needed when upgrading an app that uses Sync.

Context

A Guid is represented by 4 components - int, short, short, and a byte[8]. Microsoft's Guids diverge from the UUID spec in that they encode the first three components with the endianness of the system (little-endian for all modern CPUs), while UUIDs encode their components as big-endian. The end result is that the same bytes have a different string representations when interpreted as a Guid by the .NET SDK vs when interpreted as a UUID by the Realm Database - e.g. f2952191-a847-41c3-8362-497f92cb7d24 vs 912195f2-47a8-c341-8362-497f92cb7d24 (note the swapping of bytes in the first three components). You can see the issue by opening a database created by the .NET SDK in Realm Studio and inspecting the values for Guid properties.

Fix

The fix we're providing is to adjust the behavior of the .NET SDK to read/write Guids to the database with big-endian representation. This means that the SDK and the database will consistently display the same values. This has some implications which are described in the Local- and Synchronized Realms sections.

Local Realms

For local Realms, we're executing a one-time migration the first time the Realm is opened with the new SDK. During this migration, we'll update all Guid fields to big-endian format. This means that their string representation will remain the same, but the value in the database will change to match it. This means that the upgrade process should be seamless, but if you decide to downgrade to an older version of the SDK, you'll see the byte order get flipped. The migration will not execute multiple times, even if you downgrade.

Synchronized Realms

There's no client migration provided for synchronized Realms. This is because the distributed nature of the system would mean that there will inevitably be a period of inconsistent state. Instead, the values of the Guid properties are read as they're already stored in the database, meaning the string representation will be flipped compared to previous versions of the SDK but it will now match the representation in Atlas/Compass/Realm Studio. There are three general groups your app will fall under:

  • If you don't care about the string values of Guid properties on the client, then you don't need to do anything. The values will still be unique and valid Guids.
  • If you do use the string guid values from the client app - e.g. to correlate user ids with a CMS, but have complete control over your client devices - e.g. because this an internal company app, then it's advised that you execute a one-time migration of the data in Atlas and force all users to upgrade to the latest version of the app.
  • If you can't force all users to update at the same time, you can do a live migration by adding an extra property for each Guid property that you have and write a trigger function that will migrate the data between the two. The old version of the app will write to the original property, while the new version will write to the new property and the trigger will convert between the two.

If you are using sync and need to update to the latest version of the SDK but are not ready to migrate your data yet, see the Opting out section.

Opting out

If for some reason, you want to opt out of the fixed behavior, you can temporarily opt out of it by setting the Realm.UseLegacyGuidRepresentation property to true. This is not recommended but can be used when you need more time to test out the migration while still getting bugfixes and other improvements. Setting it to true does two things:

  1. It brings back the pre-10.10.0 behavior of reading/writing Guid values with little-endian representation.
  2. It disables the migration code for local Realms. Note that it will not revert the migration if you already opened the Realm file when UseLegacyGuidRepresentation was set to false.

Enhancements

  • Lifted a limitation that would prevent you from changing the primary key of objects during a migration. It is now possible to do it with both the dynamic and the strongly-typed API:
    var config = new RealmConfiguration
    {
      SchemaVersion = 5,
      MigrationCallback = (migration, oldVersion) =>
      {
        // Increment the primary key value of all Foos
        foreach (var obj in migration.NewRealm.All<Foo>())
        {
          obj.Id = obj.Id + 1000;
        }
      }
    }
  • [Unity] The Realm menu item in the Unity Editor was moved to Tools/Realm to reduce clutter and align with other 3rd party editor plugins. (Issue #2807)

Fixed

  • Fixed an issue with xUnit tests that would cause System.Runtime.InteropServices.SEHException to be thrown whenever Realm was accessed in a non-async test. (Issue #1865)
  • Fixed a bug that would lead to unnecessary metadata allocation when freezing a realm. (Issue #2789)
  • Fixed an issue that would cause Realm-managed objects (e.g. RealmObject, list, results, and so on) allocated during a migration block to keep the Realm open until they are garbage collected. This had subtle implications, such as being unable to delete the Realm shortly after a migration or being unable to open the Realm with a different configuration. (PR #2795)
  • Fixed an issue that prevented Unity3D's IL2CPP compiler to correctly process one of Realm's dependencies. (Issue #2666)
  • Fixed the osx runtime path in the Realm NuGet package to also apply to Apple Silicon (universal) architectures (Issue #2732)

Compatibility

  • Realm Studio: 11.0.0 or later.

Internal

  • Using Core 11.8.0

10.9.0 - Flexible Sync support

21 Jan 21:33
c63ed01
Compare
Choose a tag to compare

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 a Realm instance that uses the new synchronization mode with the server.
    • Deprecated the SyncConfiguration class in favor of PartitionSyncConfiguration. The two classes are equivalent and the new type is introduced to better contrast with FlexibleSyncConfiguration. The two types are equivalent and allow you to open a Realm 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 the Realm.Subscriptions property. It will be null 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.

Compatibility

  • Realm Studio: 11.0.0 or later.

10.8.0

17 Jan 15:44
197e9c1
Compare
Choose a tag to compare

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 when Count() is invoked on a IQueryable - e.g. expressions like realm.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

20 Nov 02:27
1a250a4
Compare
Choose a tag to compare

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

10 Nov 12:51
feb41ad
Compare
Choose a tag to compare

Enhancements

  • Added the Realm.SyncSession property which will return the sync session for this Realm if the Realm is a synchronized one or null for local Realms. This is replacing the GetSession(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 a RealmConfiguration with an explicitly set Schema 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.