Skip to content

Commit

Permalink
Merge branch 'main' into ac/overhaul-metrics
Browse files Browse the repository at this point in the history
* main:
  [v11] 10. Annotate projects for nullability (#3243)
  Merge v11 into main (#3268)
  Prepare for vNext (#3271)
  Prepare for 10.21.0 (#3270)
  Upgrade to Core 13.6.0 (#3269)
  Corrected error on README.md [skip-ci]
  Create simple project with Avalonia (#3263)
  Add support for compensating writes (#3259)

# Conflicts:
#	Realm/Realm.Weaver/ImportedReferences.cs
#	Realm/Realm.Weaver/RealmWeaver.cs
  • Loading branch information
nirinchev committed Mar 24, 2023
2 parents 35ab0c6 + 4ed604e commit c699d38
Show file tree
Hide file tree
Showing 249 changed files with 1,907 additions and 2,443 deletions.
2 changes: 1 addition & 1 deletion .github/templates/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
* None
### Compatibility
* Realm Studio: 12.0.0 or later.
* Realm Studio: 13.0.0 or later.
### Internal
* Using Core x.y.z.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
* None
### Compatibility
* Realm Studio: 12.0.0 or later.
* Realm Studio: 13.0.0 or later.
### Internal
* Using Core x.y.z.
Expand Down
71 changes: 69 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,85 @@
## 11.0.0 (TBD)

### Breaking changes
* The `error` argument in `NotificationCallbackDelegate` and `DictionaryNotificationCallbackDelegate` used in `*collection*.SubscribeForNotifications` has been removed. It has been unused for a long time, since internal changes to the database made it impossible for errors to occur during notification callbacks. (Issue [#3014](https://github.com/realm/realm-dotnet/issues/3014))
* Removed `RealmObjectBase.GetBacklinks` - instead `RealmObjectBase.DynamicApi.GetBacklinksFromType` should be used. (Issue [#2391](https://github.com/realm/realm-dotnet/issues/2391))
* Removed `Realm.DynamicApi.CreateObject(string, object)` and replaced it with more specialized overloads:
* `RealmObjectBase.DynamicApi.CreateObject(string)` can be used to create an object without a primary key.
* `RealmObjectBase.DynamicApi.CreateObject(string, string/long?/ObjectId?/Guid?)` can be used to create an object with a primary key of the corresponding type.
* The API exposed by `Realm.DynamicApi` no longer return `dynamic`, instead opting to return concrete types, such as `IRealmObject`, `IEmbeddedObject`, and so on. You can still cast the returned objects to `dynamic` and go through the dynamic API, but that's generally less performant than using the string-based API, such as `IRealmObjectBase.DynamicApi.Get/Set`, especially on AOT platforms such as iOS or Unity. (Issue [#2391](https://github.com/realm/realm-dotnet/issues/2391))
* Removed `Realm.WriteAsync(Action<Realm>)` in favor of `Realm.WriteAsync(Action)`. The new `WriteAsync` method introduced in 10.14.0 is more efficient and doesn't require reopening the Realm on a background thread. While not recommended, if you prefer to get the old behavior, you can write an extension method like:
```csharp
public static async Task WriteAsync(this Realm realm, Action<Realm> writeAction)
{
await Task.Run(() =>
{
using var bgRealm = Realm.GetInstance(realm.Config);
bgRealm.Write(() =>
{
writeAction(bgRealm);
});
});

await realm.RefreshAsync();
}
```
(PR [#3234](https://github.com/realm/realm-dotnet/pull/3234))
* Removed `InMemoryConfiguration.EncryptionKey`. It was never possible to encrypt in-memory Realms and setting that property would have resulted in runtime errors. (PR [#3236](https://github.com/realm/realm-dotnet/pull/3236))
* Removed `SyncConfiguration` - use `PartitionSyncConfiguration` or `FlexibleSyncConfiguration` instead. (PR [#3237](https://github.com/realm/realm-dotnet/pull/3237))
* Removed `Realm.GetSession` - use `Realm.SyncSession` instead. (PR [#3237](https://github.com/realm/realm-dotnet/pull/3237))
* Removed `DiscardLocalResetHandler` - use `DiscardUnsyncedChangedHandler` instead. (PR [#3237](https://github.com/realm/realm-dotnet/pull/3237))
* Removed `Session.SimulateClientReset` extensions. These didn't work with automatic reset handlers and were more confusing than helpful. (PR [#3237](https://github.com/realm/realm-dotnet/pull/3237))
* Removed `AppConfiguration.CustomLogger` and `AppConfiguration.LogLevel` - use `Logger.Default` and `Logger.LogLevel` instead. (PR [#3238](https://github.com/realm/realm-dotnet/pull/3238))
* Removed `RealmConfigurationBase.ObjectClasses` - use `RealmConfigurationBase.Schema` instead. (PR [#3240](https://github.com/realm/realm-dotnet/pull/3240))
* Removed `ObjectSchema.IsEmbedded` - use `ObjectSchema.BaseType` instead. (PR [#3240](https://github.com/realm/realm-dotnet/pull/3240))
* Removed `ObjectSchema.Builder.IsEmbedded` - use `ObjectSchema.Builder.RealmSchemaType` instead. (PR [#3240](https://github.com/realm/realm-dotnet/pull/3240))
* Removed `ObjectSchema.Builder(string name, bool isEmbedded = false)` - use `Builder(string name, ObjectSchemaType schemaType)` instead. (PR [#3240](https://github.com/realm/realm-dotnet/pull/3240))
* Removed `RealmSchema.Find` - use `RealmSchema.TryFindObjectSchema` instead. (PR [#3240](https://github.com/realm/realm-dotnet/pull/3240))
* Removed `User.GetPushClient` as it has been deprecated in Atlas App Services - see https://www.mongodb.com/docs/atlas/app-services/reference/push-notifications/. (PR [#3241](https://github.com/realm/realm-dotnet/pull/3241))
* Removed `SyncSession.Error` event - use `SyncConfigurationBase.OnSessionError` when opening a Realm instead. (PR [#3241](https://github.com/realm/realm-dotnet/pull/3242))
* Removed the parameterless constructor for `ManualRecoveryHandler` - use the one that takes a callback instead. (PR [#3241](https://github.com/realm/realm-dotnet/pull/3242))

### Enhancements

### Fixed

### Compatibility
* Realm Studio: 12.0.0 or later.

### Internal
* Using Core x.y.z.

## vNext (TBD)

### Enhancements
* None

### Fixed
* None

### Compatibility
* Realm Studio: 13.0.0 or later.

### Internal
* Using Core x.y.z.

## 10.21.0 (2023-03-24)

### Enhancements
* Added `SyncConfiguration.CancelAsyncOperationsOnNonFatalErrors` which controls whether async operations (such as `Realm.GetInstanceAsync`, `Session.WaitForUploadAsync` and so on) should throw an exception whenever a non-fatal session error occurs. (Issue [#3222](https://github.com/realm/realm-dotnet/issues/3222))
* Added `AppConfiguration.SyncTimeoutOptions` which has a handful of properties that control sync timeouts, such as the connection timeout, ping-pong intervals, and others. (Issue [#3223](https://github.com/realm/realm-dotnet/issues/3223))
* Updated some of the exceptions being thrown by the SDK to align them better with system exceptions and include more information - for example, we'll now throw `ArgumentException` when invalid arguments are provided rather than `RealmException`. (Issue [#2796](https://github.com/realm/realm-dotnet/issues/2796))
* Added a new exception - `CompensatingWriteException` that contains information about the writes that have been reverted by the server due to permissions. It will be passed to the supplied `FlexibleSyncConfiguration.OnSessionError` callback similarly to other session errors. (Issue [#3258](https://github.com/realm/realm-dotnet/issues/3258))

### Fixed
* Changed the way the Realm SDK registers BsonSerializers. Previously, it would indiscriminately register them via `BsonSerializer.RegisterSerializer`, which would conflict if your app was using the `MongoDB.Bson` package and defined its own serializers for `DateTimeOffset`, `decimal`, or `Guid`. Now, registration happens via `BsonSerializer.RegisterSerializationProvider`, which means that the default serializers used by the SDK can be overriden by calling `BsonSerializer.RegisterSerializer` at any point before a serializer is instantiated or by calling `BsonSerializer.RegisterSerializationProvider` after creating an App/opening a Realm. (Issue [#3225](https://github.com/realm/realm-dotnet/issues/3225))
* Creating subscriptions with queries having unicode parameters causes a server error. (Core 13.6.0)

### Compatibility
* Realm Studio: 12.0.0 or later.
* Realm Studio: 13.0.0 or later.

### Internal
* Using Core 13.5.0.
* Using Core 13.6.0.
* Cancel existing builds when a new commit is pushed to a PR. (PR [#3260](https://github.com/realm/realm-dotnet/pull/3260))

## 10.20.0 (2023-02-10)
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Instructions:

1. Download and build the native libraries using the instructions in [`wrappers/README.md`](wrappers/README.md)
1. Open the `Realm.sln` in `Visual Studio`
1. Build 'Realm`, `Realm.Fody` and `Realm.SourceGenerator`
1. Build `Realm`, `Realm.Fody` and `Realm.SourceGenerator`
1. Build and run the tests for the relevant platforms.

If you are actively testing code against the Realm source, see also the unit test projects and other tests under the Tests folder.
Expand All @@ -56,7 +56,8 @@ If you are actively testing code against the Realm source, see also the unit tes

Some minimal examples of Realm use can be found in the `examples` folder:

* [QuickJournal](examples/QuickJournal): a simple Xamarin.Forms application that shows how Realm can be used effectively in conjunction with MVVM and data binding.
* [QuickJournal](examples/QuickJournal): a quick journaling [MAUI](https://github.com/dotnet/maui) application that shows how Realm can be used effectively in conjunction with MVVM and data binding.
* [SimpleToDo](examples/SimpleToDoAvalonia): a simple to-do list [Avalonia](https://github.com/AvaloniaUI/Avalonia) application that shows how Realm can be used effectively in conjunction with MVVM and data binding.

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion Realm/AssemblyInfo.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Product>Realm .NET</Product>
<VersionPrefix>10.20.0</VersionPrefix>
<VersionPrefix>10.21.0</VersionPrefix>
<Description Condition="'$(Description)' == ''">Realm is a mobile database: a replacement for SQLite</Description>
<Company>Realm Inc.</Company>
<Copyright>Copyright © $([System.DateTime]::Now.ToString(yyyy)) Realm Inc.</Copyright>
Expand Down
4 changes: 2 additions & 2 deletions Realm/Realm.SourceGenerator/ClassCodeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ private void UnsubscribeFromNotifications()
private string GenerateClassObjectHelper()
{
var primaryKeyProperty = _classInfo.PrimaryKey;
var valueAccessor = primaryKeyProperty == null ? "null" : $"(({_accessorInterfaceName})instance.Accessor).{primaryKeyProperty.Name}";
var valueAccessor = primaryKeyProperty == null ? "RealmValue.Null" : $"(({_accessorInterfaceName})instance.Accessor).{primaryKeyProperty.Name}";

return $@"[EditorBrowsable(EditorBrowsableState.Never)]
private class {_helperClassName} : Realms.Weaving.IRealmObjectHelper
Expand All @@ -490,7 +490,7 @@ public void CopyToRealm(Realms.IRealmObjectBase instance, bool update, bool skip
public Realms.IRealmObjectBase CreateInstance() => new {_classInfo.Name}();
public bool TryGetPrimaryKeyValue(Realms.IRealmObjectBase instance, out object? value)
public bool TryGetPrimaryKeyValue(Realms.IRealmObjectBase instance, out RealmValue value)
{{
value = {valueAccessor};
return {BoolToString(primaryKeyProperty != null)};
Expand Down
6 changes: 3 additions & 3 deletions Realm/Realm.SourceGenerator/Diagnostics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public static Diagnostic NotPersistedPropertyWithRealmAttributes(string classNam
#endregion

private static Diagnostic CreateDiagnostic(Id id, string title, string messageFormat, DiagnosticSeverity severity,
Location location, string category, string description)
Location location, string category, string? description)
{
var reportedId = $"RLM{(int)id:000}";
DiagnosticDescriptor descriptor = new(reportedId, title, messageFormat, category, severity, isEnabledByDefault: true, description: description);
Expand All @@ -315,11 +315,11 @@ private static Diagnostic CreateDiagnostic(Id id, string title, string messageFo
}

private static Diagnostic CreateDiagnosticError(Id id, string title, string messageFormat,
Location location, string category = "RealmClassGeneration", string description = null)
Location location, string category = "RealmClassGeneration", string? description = null)
=> CreateDiagnostic(id, title, messageFormat, DiagnosticSeverity.Error, location, category, description);

private static Diagnostic CreateDiagnosticWarning(Id id, string title, string messageFormat,
Location location, string category = "RealmClassGeneration", string description = null)
Location location, string category = "RealmClassGeneration", string? description = null)
=> CreateDiagnostic(id, title, messageFormat, DiagnosticSeverity.Warning, location, category, description);
}
}
28 changes: 14 additions & 14 deletions Realm/Realm.SourceGenerator/DiagnosticsEmitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,14 @@ private static void SerializeDiagnostics(GeneratorExecutionContext context, Clas

private static DiagnosticInfo Convert(Diagnostic diag)
{
return new DiagnosticInfo
{
Id = diag.Id,
Severity = diag.Severity,
Message = diag.GetMessage(),
Location = Convert(diag.Location),
};
return new(diag.Id, diag.Severity, diag.GetMessage(), location: Convert(diag.Location));
}

private static DiagnosticLocation Convert(Location location)
{
// The +1 are necessary because line position start counting at 0
var mapped = location.GetLineSpan();
return new DiagnosticLocation
return new()
{
StartColumn = mapped.StartLinePosition.Character + 1,
StartLine = mapped.StartLinePosition.Line + 1,
Expand All @@ -101,19 +95,25 @@ private static DiagnosticLocation Convert(Location location)

internal class DiagnosticInfo
{
public string Id { get; set; }
public string Id { get; }

public DiagnosticSeverity Severity { get; }

public DiagnosticSeverity Severity { get; set; }
public string Message { get; }

public string Message { get; set; }
public DiagnosticLocation Location { get; }

public DiagnosticLocation Location { get; set; }
public DiagnosticInfo(string id, DiagnosticSeverity severity, string message, DiagnosticLocation location)
{
Id = id;
Severity = severity;
Message = message;
Location = location;
}
}

internal class DiagnosticLocation
{
public string Path { get; set; }

public int StartLine { get; set; }

public int StartColumn { get; set; }
Expand Down
Loading

0 comments on commit c699d38

Please sign in to comment.