Improvements related to Remote MongoDB access #1385
Annotations
16 errors and 4 warnings
changelog
Please add an entry in CHANGELOG.md or apply the 'no-changelog' label to skip this check.
|
Realm.SourceGenerator.Tests.dll.SourceGeneratorTests.ComparisonTests. ► SourceGeneratorTests.ComparisonTests ► IgnoreObjectNullabilityTest:
No path available#L-1
Failed test found in:
TestResults.SourceGeneration.xml
Error:
Context: Source generator application
content of 'Realm.SourceGenerator\Realms.SourceGenerator.RealmGenerator\IgnoreObjectNullabilityClass_generated.cs' did not match. Diff shown with expected as baseline:
// <auto-generated />
#nullable enable
+using MongoDB.Bson.Serialization;
using Realms;
using Realms.Schema;
using Realms.Weaving;
using SourceGeneratorAssemblyToProcess;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Xml.Serialization;
namespace SourceGeneratorAssemblyToProcess
{
[Generated]
[Woven(typeof(IgnoreObjectNullabilityClassObjectHelper)), Realms.Preserve(AllMembers = true)]
public partial class IgnoreObjectNullabilityClass : IRealmObject, INotifyPropertyChanged, IReflectableType
{
+
+ [Realms.Preserve]
+ static IgnoreObjectNullabilityClass()
+ {
+ Realms.Serialization.RealmObjectSerializer.Register(new IgnoreObjectNullabilityClassSerializer());
+ }
+
/// <summary>
/// Defines the schema for the <see cref="IgnoreObjectNullabilityClass"/> class.
/// </summary>
public static Realms.Schema.ObjectSchema RealmSchema = new Realms.Schema.ObjectSchema.Builder("IgnoreObjectNullabilityClass", ObjectSchema.ObjectType.RealmObject)
{
Realms.Schema.Property.Object("NullableObject", "IgnoreObjectNullabilityClass", managedName: "NullableObject"),
Realms.Schema.Property.Object("NonNullableObject", "IgnoreObjectNullabilityClass", managedName: "NonNullableObject"),
Realms.Schema.Property.ObjectList("ListNonNullableObject", "IgnoreObjectNullabilityClass", managedName: "ListNonNullableObject"),
Realms.Schema.Property.ObjectList("ListNullableObject", "IgnoreObjectNullabilityClass", managedName: "ListNullableObject"),
Realms.Schema.Property.ObjectSet("SetNonNullableObject", "IgnoreObjectNullabilityClass", managedName: "SetNonNullableObject"),
Realms.Schema.Property.ObjectSet("SetNullableObject", "IgnoreObjectNullabilityClass", managedName: "SetNullableObject"),
Realms.Schema.Property.ObjectDictionary("DictionaryNonNullableObject", "IgnoreObjectNullabilityClass", managedName: "DictionaryNonNullableObject"),
Realms.Schema.Property.ObjectDictionary("DictionaryNullableObject", "IgnoreObjectNullabilityClass", managedName: "DictionaryNullableObject"),
Realms.Schema.Property.Backlinks("BacklinkNullableObject", "IgnoreObjectNullabilityClass", "NullableObject", managedName: "BacklinkNullableObject"),
Realms.Schema.Property.Backlinks("BacklinkNonNullableObject", "IgnoreObjectNullabilityClass", "NullableObject", managedName: "BacklinkNonNullableObject"),
}.Build();
#region IRealmObject implementation
private IIgnoreObjectNullabilityClassAccessor? _accessor;
Realms.IRealmAccessor Realms.IRealmObjectBase.Accessor => Accessor;
private IIgnoreObjectNullabilityClassAccessor Accessor => _accessor ??= new IgnoreObjectNullabilityClassUnmanagedAccessor(typeof(IgnoreObjectNullabilityClass));
/// <inheritdoc />
[IgnoreDataMember, XmlIgnore]
public bool IsManaged => Accessor.IsManaged;
/// <inheritdoc />
[IgnoreDataMember, XmlIgnore]
public bool IsValid => Accessor.IsValid;
/// <inheritdoc />
[IgnoreDataMember, XmlIgnore]
public bool IsFrozen => Accessor.IsFrozen;
/// <inheritdoc />
[IgnoreDataMember, XmlIgnore]
public Realms.Realm? Realm => Accessor.Realm;
/// <inheritdoc />
[IgnoreDataMember, XmlIgnore]
public Realms.Schema.ObjectSchema ObjectSchema => Accessor.ObjectSchema!;
/// <inheritdoc />
[IgnoreDataMember, XmlIgnore]
public Realms.DynamicObjectApi DynamicApi => Accessor.DynamicApi;
/// <inheritdoc />
[IgnoreDataMember, XmlIgnore]
public int BacklinksCount => Accessor.BacklinksCount;
void ISettableManagedAccessor.SetManagedAccessor(Realms.IRealmAccessor managedAccessor, Realms.Weaving.IRealmObjectHelper? helper, bool update, bool skipDefaults)
{
var newAccessor = (IIgnoreObjectNullabilityClassAccessor)managedAccessor;
var oldAccessor = _accessor;
_accessor = newAccessor;
if (helper != null && oldAccessor != null)
{
if (!skipDefaults)
{
newAccessor.ListNonNullableObject.Clear();
newAccessor.ListNullableObject.Clear();
newAccessor.SetNonNullableObject.Clear();
newAccessor.SetNullableObject.Clear();
newAccessor.DictionaryNonNullableObject.Clear();
newAccessor.DictionaryNullableObject.Clear();
}
if (oldAccessor.NullableObject != null && newAccessor.Realm != null)
{
newAccessor.Realm.Add(oldAccessor.NullableObject, update);
}
newAccessor.NullableObject = oldAccessor.NullableObject;
if (oldAccessor.NonNullableObject != null && newAccessor.Realm != null)
{
newAccessor.Realm.Add(oldAccessor.NonNullableObject, update);
}
newAccessor.NonNullableObject = oldAccessor.NonNullableObject;
Realms.CollectionExtensions.PopulateCollection(oldAccessor.ListNonNullableObject, newAccessor.ListNonNullableObject, update, skipDefaults);
Realms.CollectionExtensions.PopulateCollection(oldAccessor.ListNullableObject, newAccessor.ListNullableObject, update, skipDefaults);
Realms.CollectionExtensions.PopulateCollection(oldAccessor.SetNonNullableObject, newAccessor.SetNonNullableObject, update, skipDefaults);
Realms.CollectionExtensions.PopulateCollection(oldAccessor.SetNullableObject, newAccessor.SetNullableObject, update, skipDefaults);
Realms.CollectionExtensions.PopulateCollection(oldAccessor.DictionaryNonNullableObject, newAccessor.DictionaryNonNullableObject, update, skipDefaults);
Realms.CollectionExtensions.PopulateCollection(oldAccessor.DictionaryNullableObject, newAccessor.DictionaryNullableObject, update, skipDefaults);
}
if (_propertyChanged != null)
{
SubscribeForNotifications();
}
OnManaged();
}
#endregion
/// <summary>
/// Called when the object has been managed by a Realm.
/// </summary>
/// <remarks>
/// This method will be called either when a managed object is materialized or when an unmanaged object has been
/// added to the Realm. It can be useful for providing some initialization logic as when the constructor is invoked,
/// it is not yet clear whether the object is managed or not.
/// </remarks>
partial void OnManaged();
private event PropertyChangedEventHandler? _propertyChanged;
/// <inheritdoc />
public event PropertyChangedEventHandler? PropertyChanged
{
add
{
if (_propertyChanged == null)
{
SubscribeForNotifications();
}
_propertyChanged += value;
}
remove
{
_propertyChanged -= value;
if (_propertyChanged == null)
{
UnsubscribeFromNotifications();
}
}
}
/// <summary>
/// Called when a property has changed on this class.
/// </summary>
/// <param name="propertyName">The name of the property.</param>
/// <remarks>
/// For this method to be called, you need to have first subscribed to <see cref="PropertyChanged"/>.
/// This can be used to react to changes to the current object, e.g. raising <see cref="PropertyChanged"/> for computed properties.
/// </remarks>
/// <example>
/// <code>
/// class MyClass : IRealmObject
/// {
/// public int StatusCodeRaw { get; set; }
/// public StatusCodeEnum StatusCode => (StatusCodeEnum)StatusCodeRaw;
/// partial void OnPropertyChanged(string propertyName)
/// {
/// if (propertyName == nameof(StatusCodeRaw))
/// {
/// RaisePropertyChanged(nameof(StatusCode));
/// }
/// }
/// }
/// </code>
/// Here, we have a computed property that depends on a persisted one. In order to notify any <see cref="PropertyChanged"/>
/// subscribers that <c>StatusCode</c> has changed, we implement <see cref="OnPropertyChanged"/> and
/// raise <see cref="PropertyChanged"/> manually by calling <see cref="RaisePropertyChanged"/>.
/// </example>
partial void OnPropertyChanged(string? propertyName);
private void RaisePropertyChanged([CallerMemberName] string propertyName = "")
{
_propertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
OnPropertyChanged(propertyName);
}
private void SubscribeForNotifications()
{
Accessor.SubscribeForNotifications(RaisePropertyChanged);
}
private void UnsubscribeFromNotifications()
{
Accessor.UnsubscribeFromNotifications();
}
/// <summary>
/// Converts a <see cref="Realms.RealmValue"/> to <see cref="IgnoreObjectNullabilityClass"/>. Equivalent to <see cref="Realms.RealmValue.AsNullableRealmObject{T}"/>.
/// </summary>
/// <param name="val">The <see cref="Realms.RealmValue"/> to convert.</param>
/// <returns>The <see cref="IgnoreObjectNullabilityClass"/> stored in the <see cref="Realms.RealmValue"/>.</returns>
public static explicit operator IgnoreObjectNullabilityClass?(Realms.RealmValue val) => val.Type == Realms.RealmValueType.Null ? null : val.AsRealmObject<IgnoreObjectNullabilityClass>();
/// <summary>
/// Implicitly constructs a <see cref="Realms.RealmValue"/> from <see cref="IgnoreObjectNullabilityClass"/>.
/// </summary>
/// <param name="val">The value to store in the <see cref="Realms.RealmValue"/>.</param>
/// <returns>A <see cref="Realms.RealmValue"/> containing the supplied <paramref name="val"/>.</returns>
public static implicit operator Realms.RealmValue(IgnoreObjectNullabilityClass? val) => val == null ? Realms.RealmValue.Null : Realms.RealmValue.Object(val);
/// <summary>
/// Implicitly constructs a <see cref="Realms.QueryArgument"/> from <see cref="IgnoreObjectNullabilityClass"/>.
/// </summary>
/// <param name="val">The value to store in the <see cref="Realms.QueryArgument"/>.</param>
/// <returns>A <see cref="Realms.QueryArgument"/> containing the supplied <paramref name="val"/>.</returns>
public static implicit operator Realms.QueryArgument(IgnoreObjectNullabilityClass? val) => (Realms.RealmValue)val;
/// <inheritdoc />
[EditorBrowsable(EditorBrowsableState.Never)]
public TypeInfo GetTypeInfo() => Accessor.GetTypeInfo(this);
/// <inheritdoc />
public override bool Equals(object? obj)
{
if (obj is null)
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
if (obj is InvalidObject)
{
return !IsValid;
}
if (obj is not Realms.IRealmObjectBase iro)
{
return false;
}
return Accessor.Equals(iro.Accessor);
}
/// <inheritdoc />
public override int GetHashCode() => IsManaged ? Accessor.GetHashCode() : base.GetHashCode();
/// <inheritdoc />
public override string? ToString() => Accessor.ToString();
[EditorBrowsable(EditorBrowsableState.Never), Realms.Preserve(AllMembers = true)]
private class IgnoreObjectNullabilityClassObjectHelper : Realms.Weaving.IRealmObjectHelper
{
public void CopyToRealm(Realms.IRealmObjectBase instance, bool update, bool skipDefaults)
{
throw new InvalidOperationException("This method should not be called for source generated classes.");
}
public Realms.ManagedAccessor CreateAccessor() => new IgnoreObjectNullabilityClassManagedAccessor();
public Realms.IRealmObjectBase CreateInstance() => new IgnoreObjectNullabilityClass();
public bool TryGetPrimaryKeyValue(Realms.IRealmObjectBase instance, out RealmValue value)
{
value = RealmValue.Null;
return false;
}
}
[EditorBrowsable(EditorBrowsableState.Never), Realms.Preserve(AllMembers = true)]
internal interface IIgnoreObjectNullabilityClassAccessor : Realms.IRealmAccessor
{
SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass? NullableObject { get; set; }
SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass NonNullableObject { get; set; }
System.Collections.Generic.IList<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass> ListNonNullableObject { get; }
System.Collections.Generic.IList<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass?> ListNullableObject { get; }
System.Collections.Generic.ISet<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass> SetNonNullableObject { get; }
System.Collections.Generic.ISet<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass?> SetNullableObject { get; }
System.Collections.Generic.IDictionary<string, SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass> DictionaryNonNullableObject { get; }
System.Collections.Generic.IDictionary<string, SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass> DictionaryNullableObject { get; }
System.Linq.IQueryable<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass?> BacklinkNullableObject { get; }
System.Linq.IQueryable<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass> BacklinkNonNullableObject { get; }
}
[EditorBrowsable(EditorBrowsableState.Never), Realms.Preserve(AllMembers = true)]
- internal class IgnoreObjectNullabilityClassManagedAccessor : Realms.ManagedAccessor, IIgnoreObjectNullabilityClassAccessor
+ private class IgnoreObjectNullabilityClassManagedAccessor : Realms.ManagedAccessor, IIgnoreObjectNullabilityClassAccessor
{
public SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass? NullableObject
{
get => (SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass?)GetValue("NullableObject");
set => SetValue("NullableObject", value);
}
public SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass NonNullableObject
{
get => (SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass)GetValue("NonNullableObject");
set => SetValue("NonNullableObject", value);
}
private System.Collections.Generic.IList<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass> _listNonNullableObject = null!;
public System.Collections.Generic.IList<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass> ListNonNullableObject
{
get
{
if (_listNonNullableObject == null)
{
_listNonNullableObject = GetListValue<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass>("ListNonNullableObject");
}
return _listNonNullableObject;
}
}
private System.Collections.Generic.IList<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass?> _listNullableObject = null!;
public System.Collections.Generic.IList<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass?> ListNullableObject
{
get
{
if (_listNullableObject == null)
{
_listNullableObject = GetListValue<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass?>("ListNullableObject");
}
return _listNullableObject;
}
}
private System.Collections.Generic.ISet<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass> _setNonNullableObject = null!;
public System.Collections.Generic.ISet<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass> SetNonNullableObject
{
get
{
if (_setNonNullableObject == null)
{
_setNonNullableObject = GetSetValue<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass>("SetNonNullableObject");
}
return _setNonNullableObject;
}
}
private System.Collections.Generic.ISet<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass?> _setNullableObject = null!;
public System.Collections.Generic.ISet<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass?> SetNullableObject
{
get
{
if (_setNullableObject == null)
{
_setNullableObject = GetSetValue<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass?>("SetNullableObject");
}
return _setNullableObject;
}
}
private System.Collections.Generic.IDictionary<string, SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass> _dictionaryNonNullableObject = null!;
public System.Collections.Generic.IDictionary<string, SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass> DictionaryNonNullableObject
{
get
{
if (_dictionaryNonNullableObject == null)
{
_dictionaryNonNullableObject = GetDictionaryValue<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass>("DictionaryNonNullableObject");
}
return _dictionaryNonNullableObject;
}
}
private System.Collections.Generic.IDictionary<string, SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass> _dictionaryNullableObject = null!;
public System.Collections.Generic.IDictionary<string, SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass> DictionaryNullableObject
{
get
{
if (_dictionaryNullableObject == null)
{
_dictionaryNullableObject = GetDictionaryValue<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass>("DictionaryNullableObject");
}
return _dictionaryNullableObject;
}
}
private System.Linq.IQueryable<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass?> _backlinkNullableObject = null!;
public System.Linq.IQueryable<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass?> BacklinkNullableObject
{
get
{
if (_backlinkNullableObject == null)
{
_backlinkNullableObject = GetBacklinks<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass?>("BacklinkNullableObject");
}
return _backlinkNullableObject;
}
}
private System.Linq.IQueryable<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass> _backlinkNonNullableObject = null!;
public System.Linq.IQueryable<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass> BacklinkNonNullableObject
{
get
{
if (_backlinkNonNullableObject == null)
{
_backlinkNonNullableObject = GetBacklinks<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass>("BacklinkNonNullableObject");
}
return _backlinkNonNullableObject;
}
}
}
[EditorBrowsable(EditorBrowsableState.Never), Realms.Preserve(AllMembers = true)]
- internal class IgnoreObjectNullabilityClassUnmanagedAccessor : Realms.UnmanagedAccessor, IIgnoreObjectNullabilityClassAccessor
+ private class IgnoreObjectNullabilityClassUnmanagedAccessor : Realms.UnmanagedAccessor, IIgnoreObjectNullabilityClassAccessor
{
public override ObjectSchema ObjectSchema => IgnoreObjectNullabilityClass.RealmSchema;
private SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass? _nullableObject = null!;
public SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass? NullableObject
{
get => _nullableObject;
set
{
_nullableObject = value;
RaisePropertyChanged("NullableObject");
}
}
private SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass _nonNullableObject = null!;
public SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass NonNullableObject
{
get => _nonNullableObject;
set
{
_nonNullableObject = value;
RaisePropertyChanged("NonNullableObject");
}
}
public System.Collections.Generic.IList<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass> ListNonNullableObject { get; } = new List<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass>();
public System.Collections.Generic.IList<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass?> ListNullableObject { get; } = new List<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass?>();
public System.Collections.Generic.ISet<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass> SetNonNullableObject { get; } = new HashSet<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass>(RealmSet<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass>.Comparer);
public System.Collections.Generic.ISet<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass?> SetNullableObject { get; } = new HashSet<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass?>(RealmSet<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass?>.Comparer);
public System.Collections.Generic.IDictionary<string, SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass> DictionaryNonNullableObject { get; } = new Dictionary<string, SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass>();
public System.Collections.Generic.IDictionary<string, SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass> DictionaryNullableObject { get; } = new Dictionary<string, SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass>();
public System.Linq.IQueryable<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass?> BacklinkNullableObject => throw new NotSupportedException("Using backlinks is only possible for managed(persisted) objects.");
public System.Linq.IQueryable<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass> BacklinkNonNullableObject => throw new NotSupportedException("Using backlinks is only possible for managed(persisted) objects.");
public IgnoreObjectNullabilityClassUnmanagedAccessor(Type objectType) : base(objectType)
{
}
public override Realms.RealmValue GetValue(string propertyName)
{
return propertyName switch
{
"NullableObject" => _nullableObject,
"NonNullableObject" => _nonNullableObject,
"BacklinkNullableObject" => throw new NotSupportedException("Using backlinks is only possible for managed(persisted) objects."),
"BacklinkNonNullableObject" => throw new NotSupportedException("Using backlinks is only possible for managed(persisted) objects."),
_ => throw new MissingMemberException($"The object does not have a gettable Realm property with name {propertyName}"),
};
}
public override void SetValue(string propertyName, Realms.RealmValue val)
{
switch (propertyName)
{
case "NullableObject":
NullableObject = (SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass?)val;
return;
case "NonNullableObject":
NonNullableObject = (SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass)val;
return;
default:
throw new MissingMemberException($"The object does not have a settable Realm property with name {propertyName}");
}
}
public override void SetValueUnique(string propertyName, Realms.RealmValue val)
{
throw new InvalidOperationException("Cannot set the value of an non primary key property with SetValueUnique");
}
public override IList<T> GetListValue<T>(string propertyName)
{
return propertyName switch
{
"ListNonNullableObject" => (IList<T>)ListNonNullableObject,
"ListNullableObject" => (IList<T>)ListNullableObject,
_ => throw new MissingMemberException($"The object does not have a Realm list property with name {propertyName}"),
};
}
public override ISet<T> GetSetValue<T>(string propertyName)
{
return propertyName switch
{
"SetNonNullableObject" => (ISet<T>)SetNonNullableObject,
"SetNullableObject" => (ISet<T>)SetNullableObject,
_ => throw new MissingMemberException($"The object does not have a Realm set property with name {propertyName}"),
};
}
public override IDictionary<string, TValue> GetDictionaryValue<TValue>(string propertyName)
{
return propertyName switch
{
"DictionaryNonNullableObject" => (IDictionary<string, TValue>)DictionaryNonNullableObject,
"DictionaryNullableObject" => (IDictionary<string, TValue>)DictionaryNullableObject,
_ => throw new MissingMemberException($"The object does not have a Realm dictionary property with name {propertyName}"),
};
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never), Realms.Preserve(AllMembers = true)]
+ private class IgnoreObjectNullabilityClassSerializer : Realms.Serialization.RealmObjectSerializer<IgnoreObjectNullabilityClass>
+ {
+ protected override void SerializeValue(MongoDB.Bson.Serialization.BsonSerializationContext context, BsonSerializationArgs args, IgnoreObjectNullabilityClass value)
+ {
+ context.Writer.WriteStartDocument();
+
+ WriteValue(context, args, "NullableObject", value.NullableObject);
+ WriteValue(context, args, "NonNullableObject", value.NonNullableObject);
+ WriteList(context, args, "ListNonNullableObject", value.ListNonNullableObject);
+ WriteList(context, args, "ListNullableObject", value.ListNullableObject);
+ WriteSet(context, args, "SetNonNullableObject", value.SetNonNullableObject);
+ WriteSet(context, args, "SetNullableObject", value.SetNullableObject);
+ WriteDictionary(context, args, "DictionaryNonNullableObject", value.DictionaryNonNullableObject);
+ WriteDictionary(context, args, "DictionaryNullableObject", value.DictionaryNullableObject);
+
+ context.Writer.WriteEndDocument();
+ }
+
+ protected override IgnoreObjectNullabilityClass CreateInstance() => new IgnoreObjectNullabilityClass();
+
+ protected override void ReadValue(IgnoreObjectNullabilityClass instance, string name, BsonDeserializationContext context)
+ {
+ switch (name)
+ {
+ case "NullableObject":
+ instance.NullableObject = LookupSerializer<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass?>()!.DeserializeById(context);
+ break;
+ case "NonNullableObject":
+ instance.NonNullableObject = LookupSerializer<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass>()!.DeserializeById(context);
+ break;
+ }
+ }
+
+ protected override void ReadArrayElement(IgnoreObjectNullabilityClass instance, string name, BsonDeserializationContext context)
+ {
+ switch (name)
+ {
+ case "ListNonNullableObject":
+ instance.ListNonNullableObject.Add(LookupSerializer<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass>()!.DeserializeById(context)!);
+ break;
+ case "ListNullableObject":
+ instance.ListNullableObject.Add(LookupSerializer<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass?>()!.DeserializeById(context)!);
+ break;
+ case "SetNonNullableObject":
+ instance.SetNonNullableObject.Add(LookupSerializer<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass>()!.DeserializeById(context)!);
+ break;
+ case "SetNullableObject":
+ instance.SetNullableObject.Add(LookupSerializer<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass?>()!.DeserializeById(context)!);
+ break;
+ }
+ }
+
+ protected override void ReadDocumentField(IgnoreObjectNullabilityClass instance, string name, string fieldName, BsonDeserializationContext context)
+ {
+ switch (name)
+ {
+ case "DictionaryNonNullableObject":
+ instance.DictionaryNonNullableObject[fieldName] = LookupSerializer<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass>()!.DeserializeById(context)!;
+ break;
+ case "DictionaryNullableObject":
+ instance.DictionaryNullableObject[fieldName] = LookupSerializer<SourceGeneratorAssemblyToProcess.IgnoreObjectNullabilityClass>()!.DeserializeById(context)!;
+ break;
+ }
}
}
}
}
|
Realm.SourceGenerator.Tests.dll.SourceGeneratorTests.ComparisonTests.ComparisonTest. ► SourceGeneratorTests.ComparisonTests ► ComparisonTest(AllTypesClass):
No path available#L-1
Failed test found in:
TestResults.SourceGeneration.xml
Error:
Context: Source generator application
content of 'Realm.SourceGenerator\Realms.SourceGenerator.RealmGenerator\AllTypesClass_generated.cs' did not match. Diff shown with expected as baseline:
// <auto-generated />
#nullable enable
using MongoDB.Bson;
using MongoDB.Bson.Serialization;
using Realms;
using Realms.Schema;
using Realms.Weaving;
using SourceGeneratorAssemblyToProcess;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Xml.Serialization;
namespace SourceGeneratorAssemblyToProcess
{
[Generated]
[Woven(typeof(AllTypesClassObjectHelper)), Realms.Preserve(AllMembers = true)]
public partial class AllTypesClass : IRealmObject, INotifyPropertyChanged, IReflectableType
{
[Realms.Preserve]
static AllTypesClass()
{
Realms.Serialization.RealmObjectSerializer.Register(new AllTypesClassSerializer());
}
/// <summary>
/// Defines the schema for the <see cref="AllTypesClass"/> class.
/// </summary>
public static Realms.Schema.ObjectSchema RealmSchema = new Realms.Schema.ObjectSchema.Builder("AllTypesClass", ObjectSchema.ObjectType.RealmObject)
{
Realms.Schema.Property.Primitive("CharProperty", Realms.RealmValueType.Int, isPrimaryKey: false, indexType: IndexType.None, isNullable: false, managedName: "CharProperty"),
Realms.Schema.Property.Primitive("ByteProperty", Realms.RealmValueType.Int, isPrimaryKey: false, indexType: IndexType.None, isNullable: false, managedName: "ByteProperty"),
Realms.Schema.Property.Primitive("Int16Property", Realms.RealmValueType.Int, isPrimaryKey: false, indexType: IndexType.None, isNullable: false, managedName: "Int16Property"),
Realms.Schema.Property.Primitive("Int32Property", Realms.RealmValueType.Int, isPrimaryKey: false, indexType: IndexType.None, isNullable: false, managedName: "Int32Property"),
Realms.Schema.Property.Primitive("Int64Property", Realms.RealmValueType.Int, isPrimaryKey: false, indexType: IndexType.None, isNullable: false, managedName: "Int64Property"),
Realms.Schema.Property.Primitive("SingleProperty", Realms.RealmValueType.Float, isPrimaryKey: false, indexType: IndexType.None, isNullable: false, managedName: "SingleProperty"),
Realms.Schema.Property.Primitive("DoubleProperty", Realms.RealmValueType.Double, isPrimaryKey: false, indexType: IndexType.None, isNullable: false, managedName: "DoubleProperty"),
Realms.Schema.Property.Primitive("BooleanProperty", Realms.RealmValueType.Bool, isPrimaryKey: false, indexType: IndexType.None, isNullable: false, managedName: "BooleanProperty"),
Realms.Schema.Property.Primitive("DateTimeOffsetProperty", Realms.RealmValueType.Date, isPrimaryKey: false, indexType: IndexType.None, isNullable: false, managedName: "DateTimeOffsetProperty"),
Realms.Schema.Property.Primitive("DecimalProperty", Realms.RealmValueType.Decimal128, isPrimaryKey: false, indexType: IndexType.None, isNullable: false, managedName: "DecimalProperty"),
Realms.Schema.Property.Primitive("Decimal128Property", Realms.RealmValueType.Decimal128, isPrimaryKey: false, indexType: IndexType.None, isNullable: false, managedName: "Decimal128Property"),
Realms.Schema.Property.Primitive("ObjectIdProperty", Realms.RealmValueType.ObjectId, isPrimaryKey: false, indexType: IndexType.None, isNullable: false, managedName: "ObjectIdProperty"),
Realms.Schema.Property.Primitive("GuidProperty", Realms.RealmValueType.Guid, isPrimaryKey: false, indexType: IndexType.None, isNullable: false, managedName: "GuidProperty"),
Realms.Schema.Property.Primitive("RequiredStringProperty", Realms.RealmValueType.String, isPrimaryKey: false, indexType: IndexType.None, isNullable: false, managedName: "RequiredStringProperty"),
Realms.Schema.Property.Primitive("StringProperty", Realms.RealmValueType.String, isPrimaryKey: false, indexType: IndexType.None, isNullable: true, managedName: "StringProperty"),
Realms.Schema.Property.Primitive("RequiredByteArrayProperty", Realms.RealmValueType.Data, isPrimaryKey: false, indexType: IndexType.None, isNullable: false, managedName: "RequiredByteArrayProperty"),
Realms.Schema.Property.Primitive("ByteArrayProperty", Realms.RealmValueType.Data, isPrimaryKey: false, indexType: IndexType.None, isNullable: true, managedName: "ByteArrayProperty"),
Realms.Schema.Property.Primitive("NullableCharProperty", Realms.RealmValueType.Int, isPrimaryKey: false, indexType: IndexType.None, isNullable: true, managedName: "NullableCharProperty"),
Realms.Schema.Property.Primitive("NullableByteProperty", Realms.RealmValueType.Int, isPrimaryKey: false, indexType: IndexType.None, isNullable: true, managedName: "NullableByteProperty"),
Realms.Schema.Property.Primitive("NullableInt16Property", Realms.RealmValueType.Int, isPrimaryKey: false, indexType: IndexType.None, isNullable: true, managedName: "NullableInt16Property"),
Realms.Schema.Property.Primitive("NullableInt32Property", Realms.RealmValueType.Int, isPrimaryKey: false, indexType: IndexType.None, isNullable: true, managedName: "NullableInt32Property"),
Realms.Schema.Property.Primitive("NullableInt64Property", Realms.RealmValueType.Int, isPrimaryKey: false, indexType: IndexType.None, isNullable: true, managedName: "NullableInt64Property"),
Realms.Schema.Property.Primitive("NullableSingleProperty", Realms.RealmValueType.Float, isPrimaryKey: false, indexType: IndexType.None, isNullable: true, managedName: "NullableSingleProperty"),
Realms.Schema.Property.Primitive("NullableDoubleProperty", Realms.RealmValueType.Double, isPrimaryKey: false, indexType: IndexType.None, isNullable: true, managedName: "NullableDoubleProperty"),
Realms.Schema.Property.Primitive("NullableBooleanProperty", Realms.RealmValueType.Bool, isPrimaryKey: false, indexType: IndexType.None, isNullable: true, managedName: "NullableBooleanProperty"),
Realms.Schema.Property.Primitive("NullableDateTimeOffsetProperty", Realms.RealmValueType.Date, isPrimaryKey: false, indexType: IndexType.None, isNullable: true, managedName: "NullableDateTimeOffsetProperty"),
Realms.Schema.Property.Primitive("NullableDecimalProperty", Realms.RealmValueType.Decimal128, isPrimaryKey: false, indexType: IndexType.None, isNullable: true, managedName: "NullableDecimalProperty"),
Realms.Schema.Property.Primitive("NullableDecimal128Property", Realms.RealmValueType.Decimal128, isPrimaryKey: false, indexType: IndexType.None, isNullable: true, managedName: "NullableDecimal128Property"),
Realms.Schema.Property.Primitive("NullableObjectIdProperty", Realms.RealmValueType.ObjectId, isPrimaryKey: false, indexType: IndexType.None, isNullable: true, managedName: "NullableObjectIdProperty"),
Realms.Schema.Property.Primitive("NullableGuidProperty", Realms.RealmValueType.Guid, isPrimaryKey: false, indexType: IndexType.None, isNullable: true, managedName: "NullableGuidProperty"),
Realms.Schema.Property.Primitive("ByteCounterProperty", Realms.RealmValueType.Int, isPrimaryKey: false, indexType: IndexType.None, isNullable: false, managedName: "ByteCounterProperty"),
Realms.Schema.Property.Primitive("Int16CounterProperty", Realms.RealmValueType.Int, isPrimaryKey: false, indexType: IndexType.None, isNullable: false, managedName: "Int16CounterProperty"),
Realms.Schema.Property.Primitive("Int32CounterProperty", Realms.RealmValueType.Int, isPrimaryKey: false, indexType: IndexType.None, isNullable: false, managedName: "Int32CounterProperty"),
Realms.Schema.Property.Primitive("Int64CounterProperty", Realms.RealmValueType.Int, isPrimaryKey: false, indexType: IndexType.None, isNullable: false, managedName: "Int64CounterProperty"),
Realms.Schema.Property.RealmValue("RealmValueProperty", managedName: "RealmValueProperty"),
Realms.Schema.Property.Object("ObjectProperty", "AllTypesClass", managedName: "ObjectProperty"),
Realms.Schema.Property.ObjectList("ObjectCollectionProperty", "AllTypesClass", managedName: "ObjectCollectionProperty"),
Realms.Schema.Property.PrimitiveList("IntCollectionProperty", Realms.RealmValueType.Int, areElementsNullable: false, managedName: "IntCollectionProperty"),
Realms.Schema.Property.PrimitiveList("NullableIntCollectionProperty", Realms.RealmValueType.Int, areElementsNullable: true, managedName: "NullableIntCollectionProperty"),
Realms.Schema.Property.PrimitiveList("StringCollectionProperty", Realms.RealmValueType.String, areElementsNullable: false, managedName: "StringCollectionProperty"),
Realms.Schema.Property.PrimitiveList("RequiredStringListProperty", Realms.RealmValueType.String, areElementsNullable: false, managedName: "RequiredStringListProperty"),
Realms.Schema.Property.PrimitiveSet("RequiredStringSetProperty", Realms.RealmValueType.String, areElementsNullable: false, managedName: "RequiredStringSetProperty"),
Realms.Schema.Property.PrimitiveDictionary("RequiredStringDictionaryProperty", Realms.RealmValueType.String, areElementsNullable: false, managedName: "RequiredStringDictionaryProperty"),
Realms.Schema.Property.PrimitiveList("NonRequiredStringListProperty", Realms.RealmValueType.String, areElementsNullable: true, managedName: "NonRequiredStringListProperty"),
Realms.Schema.Property.PrimitiveSet("NonRequiredStringSetProperty", Realms.RealmValueType.String, areElementsNullable: true, managedName: "NonRequiredStringSetProperty"),
Realms.Schema.Property.PrimitiveDictionary("NonRequiredStringDictionaryProperty", Realms.RealmValueType.String, areElementsNullable: true, managedName: "NonRequiredStringDictionaryProperty"),
}.Build();
#region IRealmObject implementation
private IAllTypesClassAccessor? _accessor;
Realms.IRealmAccessor Realms.IRealmObjectBase.Accessor => Accessor;
private IAllTypesClassAccessor Accessor => _accessor ??= new AllTypesClassUnmanagedAccessor(typeof(AllTypesClass));
/// <inheritdoc />
[IgnoreDataMember, XmlIgnore]
public bool IsManaged => Accessor.IsManaged;
/// <inheritdoc />
[IgnoreDataMember, XmlIgnore]
public bool IsValid => Accessor.IsValid;
/// <inheritdoc />
[IgnoreDataMember, XmlIgnore]
public bool IsFrozen => Accessor.IsFrozen;
/// <inheritdoc />
[IgnoreDataMember, XmlIgnore]
public Realms.Realm? Realm => Accessor.Realm;
/// <inheritdoc />
[IgnoreDataMember, XmlIgnore]
public Realms.Schema.ObjectSchema ObjectSchema => Accessor.ObjectSchema!;
/// <inheritdoc />
[IgnoreDataMember, XmlIgnore]
public Realms.DynamicObjectApi DynamicApi => Accessor.DynamicApi;
/// <inheritdoc />
[IgnoreDataMember, XmlIgnore]
public int BacklinksCount => Accessor.BacklinksCount;
void ISettableManagedAccessor.SetManagedAccessor(Realms.IRealmAccessor managedAccessor, Realms.Weaving.IRealmObjectHelper? helper, bool update, bool skipDefaults)
{
var newAccessor = (IAllTypesClassAccessor)managedAccessor;
var oldAccessor = _accessor;
_accessor = newAccessor;
if (helper != null && oldAccessor != null)
{
if (!skipDefaults)
{
newAccessor.ObjectCollectionProperty.Clear();
newAccessor.IntCollectionProperty.Clear();
newAccessor.NullableIntCollectionProperty.Clear();
newAccessor.StringCollectionProperty.Clear();
newAccessor.RequiredStringListProperty.Clear();
newAccessor.RequiredStringSetProperty.Clear();
newAccessor.RequiredStringDictionaryProperty.Clear();
newAccessor.NonRequiredStringListProperty.Clear();
newAccessor.NonRequiredStringSetProperty.Clear();
newAccessor.NonRequiredStringDictionaryProperty.Clear();
}
if (!skipDefaults || oldAccessor.CharProperty != default(char))
{
newAccessor.CharProperty = oldAccessor.CharProperty;
}
if (!skipDefaults || oldAccessor.ByteProperty != default(byte))
{
newAccessor.ByteProperty = oldAccessor.ByteProperty;
}
if (!skipDefaults || oldAccessor.Int16Property != default(short))
{
newAccessor.Int16Property = oldAccessor.Int16Property;
}
if (!skipDefaults || oldAccessor.Int32Property != default(int))
{
newAccessor.Int32Property = oldAccessor.Int32Property;
}
if (!skipDefaults || oldAccessor.Int64Property != default(long))
{
newAccessor.Int64Property = oldAccessor.Int64Property;
}
if (!skipDefaults || oldAccessor.SingleProperty != default(float))
{
newAccessor.SingleProperty = oldAccessor.SingleProperty;
}
if (!skipDefaults || oldAccessor.DoubleProperty != default(double))
{
newAccessor.DoubleProperty = oldAccessor.DoubleProperty;
}
if (!skipDefaults || oldAccessor.BooleanProperty != default(bool))
{
newAccessor.BooleanProperty = oldAccessor.BooleanProperty;
}
newAccessor.DateTimeOffsetProperty = oldAccessor.DateTimeOffsetProperty;
if (!skipDefaults || oldAccessor.DecimalProperty != default(decimal))
{
newAccessor.DecimalProperty = oldAccessor.DecimalProperty;
}
if (!skipDefaults || oldAccessor.Decimal128Property != default(MongoDB.Bson.Decimal128))
{
newAccessor.Decimal128Property = oldAccessor.Decimal128Property;
}
if (!skipDefaults || oldAccessor.ObjectIdProperty != default(MongoDB.Bson.ObjectId))
{
newAccessor.ObjectIdProperty = oldAccessor.ObjectIdProperty;
}
if (!skipDefaults || oldAccessor.GuidProperty != default(System.Guid))
{
newAccessor.GuidProperty = oldAccessor.GuidProperty;
}
newAccessor.RequiredStringProperty = oldAccessor.RequiredStringProperty;
if (!skipDefaults || oldAccessor.StringProperty != default(string?))
{
newAccessor.StringProperty = oldAccessor.StringProperty;
}
newAccessor.RequiredByteArrayProperty = oldAccessor.RequiredByteArrayProperty;
if (!skipDefaults || oldAccessor.ByteArrayProperty != default(byte[]?))
{
newAccessor.ByteArrayProperty = oldAccessor.ByteArrayProperty;
}
if (!skipDefaults || oldAccessor.NullableCharProperty != default(char?))
{
newAccessor.NullableCharProperty = oldAccessor.NullableCharProperty;
}
if (!skipDefaults || oldAccessor.NullableByteProperty != default(byte?))
{
newAccessor.NullableByteProperty = oldAccessor.NullableByteProperty;
}
if (!skipDefaults || oldAccessor.NullableInt16Property != default(short?))
{
newAccessor.NullableInt16Property = oldAccessor.NullableInt16Property;
}
if (!skipDefaults || oldAccessor.NullableInt32Property != default(int?))
{
newAccessor.NullableInt32Property = oldAccessor.NullableInt32Property;
}
if (!skipDefaults || oldAccessor.NullableInt64Property != default(long?))
{
newAccessor.NullableInt64Property = oldAccessor.NullableInt64Property;
}
if (!skipDefaults || oldAccessor.NullableSingleProperty != default(float?))
{
newAccessor.NullableSingleProperty = oldAccessor.NullableSingleProperty;
}
if (!skipDefaults || oldAccessor.NullableDoubleProperty != default(double?))
{
newAccessor.NullableDoubleProperty = oldAccessor.NullableDoubleProperty;
}
if (!skipDefaults || oldAccessor.NullableBooleanProperty != default(bool?))
{
newAccessor.NullableBooleanProperty = oldAccessor.NullableBooleanProperty;
}
newAccessor.NullableDateTimeOffsetProperty = oldAccessor.NullableDateTimeOffsetProperty;
if (!skipDefaults || oldAccessor.NullableDecimalProperty != default(decimal?))
{
newAccessor.NullableDecimalProperty = oldAccessor.NullableDecimalProperty;
}
if (!skipDefaults || oldAccessor.NullableDecimal128Property != default(MongoDB.Bson.Decimal128?))
{
newAccessor.NullableDecimal128Property = oldAccessor.NullableDecimal128Property;
}
if (!skipDefaults || oldAccessor.NullableObjectIdProperty != default(MongoDB.Bson.ObjectId?))
{
newAccessor.NullableObjectIdProperty = oldAccessor.NullableObjectIdProperty;
}
if (!skipDefaults || oldAccessor.NullableGuidProperty != default(System.Guid?))
{
newAccessor.NullableGuidProperty = oldAccessor.NullableGuidProperty;
}
if (!skipDefaults || oldAccessor.ByteCounterProperty != default(Realms.RealmInteger<byte>))
{
newAccessor.ByteCounterProperty = oldAccessor.ByteCounterProperty;
}
if (!skipDefaults || oldAccessor.Int16CounterProperty != default(Realms.RealmInteger<short>))
{
newAccessor.Int16CounterProperty = oldAccessor.Int16CounterProperty;
}
if (!skipDefaults || oldAccessor.Int32CounterProperty != default(Realms.RealmInteger<int>))
{
newAccessor.Int32CounterProperty = oldAccessor.Int32CounterProperty;
}
if (!skipDefaults || oldAccessor.Int64CounterProperty != default(Realms.RealmInteger<long>))
{
newAccessor.Int64CounterProperty = oldAccessor.Int64CounterProperty;
}
newAccessor.RealmValueProperty = oldAccessor.RealmValueProperty;
if (oldAccessor.ObjectProperty != null && newAccessor.Realm != null)
{
newAccessor.Realm.Add(oldAccessor.ObjectProperty, update);
}
newAccessor.ObjectProperty = oldAccessor.ObjectProperty;
Realms.CollectionExtensions.PopulateCollection(oldAccessor.ObjectCollectionProperty, newAccessor.ObjectCollectionProperty, update, skipDefaults);
Realms.CollectionExtensions.PopulateCollection(oldAccessor.IntCollectionProperty, newAccessor.IntCollectionProperty, update, skipDefaults);
Realms.CollectionExtensions.PopulateCollection(oldAccessor.NullableIntCollectionProperty, newAccessor.NullableIntCollectionProperty, update, skipDefaults);
Realms.CollectionExtensions.PopulateCollection(oldAccessor.StringCollectionProperty, newAccessor.StringCollectionProperty, update, skipDefaults);
Realms.CollectionExtensions.PopulateCollection(oldAccessor.RequiredStringListProperty, newAccessor.RequiredStringListProperty, update, skipDefaults);
Realms.CollectionExtensions.PopulateCollection(oldAccessor.RequiredStringSetProperty, newAccessor.RequiredStringSetProperty, update, skipDefaults);
Realms.CollectionExtensions.PopulateCollection(oldAccessor.RequiredStringDictionaryProperty, newAccessor.RequiredStringDictionaryProperty, update, skipDefaults);
Realms.CollectionExtensions.PopulateCollection(oldAccessor.NonRequiredStringListProperty, newAccessor.NonRequiredStringListProperty, update, skipDefaults);
Realms.CollectionExtensions.PopulateCollection(oldAccessor.NonRequiredStringSetProperty, newAccessor.NonRequiredStringSetProperty, update, skipDefaults);
Realms.CollectionExtensions.PopulateCollection(oldAccessor.NonRequiredStringDictionaryProperty, newAccessor.NonRequiredStringDictionaryProperty, update, skipDefaults);
}
if (_propertyChanged != null)
{
SubscribeForNotifications();
}
OnManaged();
}
#endregion
/// <summary>
/// Called when the object has been managed by a Realm.
/// </summary>
/// <remarks>
/// This method will be called either when a managed object is materialized or when an unmanaged object has been
/// added to the Realm. It can be useful for providing some initialization logic as when the constructor is invoked,
/// it is not yet clear whether the object is managed or not.
/// </remarks>
partial void OnManaged();
private event PropertyChangedEventHandler? _propertyChanged;
/// <inheritdoc />
public event PropertyChangedEventHandler? PropertyChanged
{
add
{
if (_propertyChanged == null)
{
SubscribeForNotifications();
}
_propertyChanged += value;
}
remove
{
_propertyChanged -= value;
if (_propertyChanged == null)
{
UnsubscribeFromNotifications();
}
}
}
/// <summary>
/// Called when a property has changed on this class.
/// </summary>
/// <param name="propertyName">The name of the property.</param>
/// <remarks>
/// For this method to be called, you need to have first subscribed to <see cref="PropertyChanged"/>.
/// This can be used to react to changes to the current object, e.g. raising <see cref="PropertyChanged"/> for computed properties.
/// </remarks>
/// <example>
/// <code>
/// class MyClass : IRealmObject
/// {
/// public int StatusCodeRaw { get; set; }
/// public StatusCodeEnum StatusCode => (StatusCodeEnum)StatusCodeRaw;
/// partial void OnPropertyChanged(string propertyName)
/// {
/// if (propertyName == nameof(StatusCodeRaw))
/// {
/// RaisePropertyChanged(nameof(StatusCode));
/// }
/// }
/// }
/// </code>
/// Here, we have a computed property that depends on a persisted one. In order to notify any <see cref="PropertyChanged"/>
/// subscribers that <c>StatusCode</c> has changed, we implement <see cref="OnPropertyChanged"/> and
/// raise <see cref="PropertyChanged"/> manually by calling <see cref="RaisePropertyChanged"/>.
/// </example>
partial void OnPropertyChanged(string? propertyName);
private void RaisePropertyChanged([CallerMemberName] string propertyName = "")
{
_propertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
OnPropertyChanged(propertyName);
}
private void SubscribeForNotifications()
{
Accessor.SubscribeForNotifications(RaisePropertyChanged);
}
private void UnsubscribeFromNotifications()
{
Accessor.UnsubscribeFromNotifications();
}
/// <summary>
/// Converts a <see cref="Realms.RealmValue"/> to <see cref="AllTypesClass"/>. Equivalent to <see cref="Realms.RealmValue.AsNullableRealmObject{T}"/>.
/// </summary>
/// <param name="val">The <see cref="Realms.RealmValue"/> to convert.</param>
/// <returns>The <see cref="AllTypesClass"/> stored in the <see cref="Realms.RealmValue"/>.</returns>
public static explicit operator AllTypesClass?(Realms.RealmValue val) => val.Type == Realms.RealmValueType.Null ? null : val.AsRealmObject<AllTypesClass>();
/// <summary>
/// Implicitly constructs a <see cref="Realms.RealmValue"/> from <see cref="AllTypesClass"/>.
/// </summary>
/// <param name="val">The value to store in the <see cref="Realms.RealmValue"/>.</param>
/// <returns>A <see cref="Realms.RealmValue"/> containing the supplied <paramref name="val"/>.</returns>
public static implicit operator Realms.RealmValue(AllTypesClass? val) => val == null ? Realms.RealmValue.Null : Realms.RealmValue.Object(val);
/// <summary>
/// Implicitly constructs a <see cref="Realms.QueryArgument"/> from <see cref="AllTypesClass"/>.
/// </summary>
/// <param name="val">The value to store in the <see cref="Realms.QueryArgument"/>.</param>
/// <returns>A <see cref="Realms.QueryArgument"/> containing the supplied <paramref name="val"/>.</returns>
public static implicit operator Realms.QueryArgument(AllTypesClass? val) => (Realms.RealmValue)val;
/// <inheritdoc />
[EditorBrowsable(EditorBrowsableState.Never)]
public TypeInfo GetTypeInfo() => Accessor.GetTypeInfo(this);
/// <inheritdoc />
public override bool Equals(object? obj)
{
if (obj is null)
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
if (obj is InvalidObject)
{
return !IsValid;
}
if (obj is not Realms.IRealmObjectBase iro)
{
return false;
}
return Accessor.Equals(iro.Accessor);
}
/// <inheritdoc />
public override int GetHashCode() => IsManaged ? Accessor.GetHashCode() : base.GetHashCode();
/// <inheritdoc />
public override string? ToString() => Accessor.ToString();
[EditorBrowsable(EditorBrowsableState.Never), Realms.Preserve(AllMembers = true)]
private class AllTypesClassObjectHelper : Realms.Weaving.IRealmObjectHelper
{
public void CopyToRealm(Realms.IRealmObjectBase instance, bool update, bool skipDefaults)
{
throw new InvalidOperationException("This method should not be called for source generated classes.");
}
public Realms.ManagedAccessor CreateAccessor() => new AllTypesClassManagedAccessor();
public Realms.IRealmObjectBase CreateInstance() => new AllTypesClass();
public bool TryGetPrimaryKeyValue(Realms.IRealmObjectBase instance, out RealmValue value)
{
value = RealmValue.Null;
return false;
}
}
[EditorBrowsable(EditorBrowsableState.Never), Realms.Preserve(AllMembers = true)]
internal interface IAllTypesClassAccessor : Realms.IRealmAccessor
{
char CharProperty { get; set; }
byte ByteProperty { get; set; }
short Int16Property { get; set; }
int Int32Property { get; set; }
long Int64Property { get; set; }
float SingleProperty { get; set; }
double DoubleProperty { get; set; }
bool BooleanProperty { get; set; }
System.DateTimeOffset DateTimeOffsetProperty { get; set; }
decimal DecimalProperty { get; set; }
MongoDB.Bson.Decimal128 Decimal128Property { get; set; }
MongoDB.Bson.ObjectId ObjectIdProperty { get; set; }
System.Guid GuidProperty { get; set; }
string RequiredStringProperty { get; set; }
string? StringProperty { get; set; }
byte[] RequiredByteArrayProperty { get; set; }
byte[]? ByteArrayProperty { get; set; }
char? NullableCharProperty { get; set; }
byte? NullableByteProperty { get; set; }
short? NullableInt16Property { get; set; }
int? NullableInt32Property { get; set; }
long? NullableInt64Property { get; set; }
float? NullableSingleProperty { get; set; }
double? NullableDoubleProperty { get; set; }
bool? NullableBooleanProperty { get; set; }
System.DateTimeOffset? NullableDateTimeOffsetProperty { get; set; }
decimal? NullableDecimalProperty { get; set; }
MongoDB.Bson.Decimal128? NullableDecimal128Property { get; set; }
MongoDB.Bson.ObjectId? NullableObjectIdProperty { get; set; }
System.Guid? NullableGuidProperty { get; set; }
Realms.RealmInteger<byte> ByteCounterProperty { get; set; }
Realms.RealmInteger<short> Int16CounterProperty { get; set; }
Realms.RealmInteger<int> Int32CounterProperty { get; set; }
Realms.RealmInteger<long> Int64CounterProperty { get; set; }
Realms.RealmValue RealmValueProperty { get; set; }
SourceGeneratorAssemblyToProcess.AllTypesClass? ObjectProperty { get; set; }
System.Collections.Generic.IList<SourceGeneratorAssemblyToProcess.AllTypesClass> ObjectCollectionProperty { get; }
System.Collections.Generic.IList<int> IntCollectionProperty { get; }
System.Collections.Generic.IList<int?> NullableIntCollectionProperty { get; }
System.Collections.Generic.IList<string> StringCollectionProperty { get; }
System.Collections.Generic.IList<string> RequiredStringListProperty { get; }
System.Collections.Generic.ISet<string> RequiredStringSetProperty { get; }
System.Collections.Generic.IDictionary<string, string> RequiredStringDictionaryProperty { get; }
System.Collections.Generic.IList<string?> NonRequiredStringListProperty { get; }
System.Collections.Generic.ISet<string?> NonRequiredStringSetProperty { get; }
System.Collections.Generic.IDictionary<string, string?> NonRequiredStringDictionaryProperty { get; }
}
[EditorBrowsable(EditorBrowsableState.Never), Realms.Preserve(AllMembers = true)]
private class AllTypesClassManagedAccessor : Realms.ManagedAccessor, IAllTypesClassAccessor
{
public char CharProperty
{
get => (char)GetValue("CharProperty");
set => SetValue("CharProperty", value);
}
public byte ByteProperty
{
get => (byte)GetValue("ByteProperty");
set => SetValue("ByteProperty", value);
}
public short Int16Property
{
get => (short)GetValue("Int16Property");
set => SetValue("Int16Property", value);
}
public int Int32Property
{
get => (int)GetValue("Int32Property");
set => SetValue("Int32Property", value);
}
public long Int64Property
{
get => (long)GetValue("Int64Property");
set => SetValue("Int64Property", value);
}
public float SingleProperty
{
get => (float)GetValue("SingleProperty");
set => SetValue("SingleProperty", value);
}
public double DoubleProperty
{
get => (double)GetValue("DoubleProperty");
set => SetValue("DoubleProperty", value);
}
public bool BooleanProperty
{
get => (bool)GetValue("BooleanProperty");
set => SetValue("BooleanProperty", value);
}
public System.DateTimeOffset DateTimeOffsetProperty
{
get => (System.DateTimeOffset)GetValue("DateTimeOffsetProperty");
set => SetValue("DateTimeOffsetProperty", value);
}
public decimal DecimalProperty
{
get => (decimal)GetValue("DecimalProperty");
set => SetValue("DecimalProperty", value);
}
public MongoDB.Bson.Decimal128 Decimal128Property
{
get => (MongoDB.Bson.Decimal128)GetValue("Decimal128Property");
set => SetValue("Decimal128Property", value);
}
public MongoDB.Bson.ObjectId ObjectIdProperty
{
get => (MongoDB.Bson.ObjectId)GetValue("ObjectIdProperty");
set => SetValue("ObjectIdProperty", value);
}
public System.Guid GuidProperty
{
get => (System.Guid)GetValue("GuidProperty");
set => SetValue("GuidProperty", value);
}
public string RequiredStringProperty
{
get => (string)GetValue("RequiredStringProperty")!;
set => SetValue("RequiredStringProperty", value);
}
public string? StringProperty
{
get => (string?)GetValue("StringProperty");
set => SetValue("StringProperty", value);
}
public byte[] RequiredByteArrayProperty
{
get => (byte[])GetValue("RequiredByteArrayProperty")!;
set => SetValue("RequiredByteArrayProperty", value);
}
public byte[]? ByteArrayProperty
{
get => (byte[]?)GetValue("ByteArrayProperty");
set => SetValue("ByteArrayProperty", value);
}
public char? NullableCharProperty
{
get => (char?)GetValue("NullableCharProperty");
set => SetValue("NullableCharProperty", value);
}
public byte? NullableByteProperty
{
get => (byte?)GetValue("NullableByteProperty");
set => SetValue("NullableByteProperty", value);
}
public short? NullableInt16Property
{
get => (short?)GetValue("NullableInt16Property");
set => SetValue("NullableInt16Property", value);
}
public int? NullableInt32Property
{
get => (int?)GetValue("NullableInt32Property");
set => SetValue("NullableInt32Property", value);
}
public long? NullableInt64Property
{
get => (long?)GetValue("NullableInt64Property");
set => SetValue("NullableInt64Property", value);
}
public float? NullableSingleProperty
{
get => (float?)GetValue("NullableSingleProperty");
set => SetValue("NullableSingleProperty", value);
}
public double? NullableDoubleProperty
{
get => (double?)GetValue("NullableDoubleProperty");
set => SetValue("NullableDoubleProperty", value);
}
public bool? NullableBooleanProperty
{
get => (bool?)GetValue("NullableBooleanProperty");
set => SetValue("NullableBooleanProperty", value);
}
public System.DateTimeOffset? NullableDateTimeOffsetProperty
{
get => (System.DateTimeOffset?)GetValue("NullableDateTimeOffsetProperty");
set => SetValue("NullableDateTimeOffsetProperty", value);
}
public decimal? NullableDecimalProperty
{
get => (decimal?)GetValue("NullableDecimalProperty");
set => SetValue("NullableDecimalProperty", value);
}
public MongoDB.Bson.Decimal128? NullableDecimal128Property
{
get => (MongoDB.Bson.Decimal128?)GetValue("NullableDecimal128Property");
set => SetValue("NullableDecimal128Property", value);
}
public MongoDB.Bson.ObjectId? NullableObjectIdProperty
{
get => (MongoDB.Bson.ObjectId?)GetValue("NullableObjectIdProperty");
set => SetValue("NullableObjectIdProperty", value);
}
public System.Guid? NullableGuidProperty
{
get => (System.Guid?)GetValue("NullableGuidProperty");
set => SetValue("NullableGuidProperty", value);
}
public Realms.RealmInteger<byte> ByteCounterProperty
{
get => (Realms.RealmInteger<byte>)GetValue("ByteCounterProperty");
set => SetValue("ByteCounterProperty", value);
}
public Realms.RealmInteger<short> Int16CounterProperty
{
get => (Realms.RealmInteger<short>)GetValue("Int16CounterProperty");
set => SetValue("Int16CounterProperty", value);
}
public Realms.RealmInteger<int> Int32CounterProperty
{
get => (Realms.RealmInteger<int>)GetValue("Int32CounterProperty");
set => SetValue("Int32CounterProperty", value);
}
public Realms.RealmInteger<long> Int64CounterProperty
{
get => (Realms.RealmInteger<long>)GetValue("Int64CounterProperty");
set => SetValue("Int64CounterProperty", value);
}
public Realms.RealmValue RealmValueProperty
{
get => (Realms.RealmValue)GetValue("RealmValueProperty");
set => SetValue("RealmValueProperty", value);
}
public SourceGeneratorAssemblyToProcess.AllTypesClass? ObjectProperty
{
get => (SourceGeneratorAssemblyToProcess.AllTypesClass?)GetValue("ObjectProperty");
set => SetValue("ObjectProperty", value);
}
private System.Collections.Generic.IList<SourceGeneratorAssemblyToProcess.AllTypesClass> _objectCollectionProperty = null!;
public System.Collections.Generic.IList<SourceGeneratorAssemblyToProcess.AllTypesClass> ObjectCollectionProperty
{
get
{
if (_objectCollectionProperty == null)
{
_objectCollectionProperty = GetListValue<SourceGeneratorAssemblyToProcess.AllTypesClass>("ObjectCollectionProperty");
}
return _objectCollectionProperty;
}
}
private System.Collections.Generic.IList<int> _intCollectionProperty = null!;
public System.Collections.Generic.IList<int> IntCollectionProperty
{
get
{
if (_intCollectionProperty == null)
{
_intCollectionProperty = GetListValue<int>("IntCollectionProperty");
}
return _intCollectionProperty;
}
}
private System.Collections.Generic.IList<int?> _nullableIntCollectionProperty = null!;
public System.Collections.Generic.IList<int?> NullableIntCollectionProperty
{
get
{
if (_nullableIntCollectionProperty == null)
{
_nullableIntCollectionProperty = GetListValue<int?>("NullableIntCollectionProperty");
}
return _nullableIntCollectionProperty;
}
}
private System.Collections.Generic.IList<string> _stringCollectionProperty = null!;
public System.Collections.Generic.IList<string> StringCollectionProperty
{
get
{
if (_stringCollectionProperty == null)
{
_stringCollectionProperty = GetListValue<string>("StringCollectionProperty");
}
return _stringCollectionProperty;
}
}
private System.Collections.Generic.IList<string> _requiredStringListProperty = null!;
public System.Collections.Generic.IList<string> RequiredStringListProperty
{
get
{
if (_requiredStringListProperty == null)
{
_requiredStringListProperty = GetListValue<string>("RequiredStringListProperty");
}
return _requiredStringListProperty;
}
}
private System.Collections.Generic.ISet<string> _requiredStringSetProperty = null!;
public System.Collections.Generic.ISet<string> RequiredStringSetProperty
{
get
{
if (_requiredStringSetProperty == null)
{
_requiredStringSetProperty = GetSetValue<string>("RequiredStringSetProperty");
}
return _requiredStringSetProperty;
}
}
private System.Collections.Generic.IDictionary<string, string> _requiredStringDictionaryProperty = null!;
public System.Collections.Generic.IDictionary<string, string> RequiredStringDictionaryProperty
{
get
{
if (_requiredStringDictionaryProperty == null)
{
_requiredStringDictionaryProperty = GetDictionaryValue<string>("RequiredStringDictionaryProperty");
}
return _requiredStringDictionaryProperty;
}
}
private System.Collections.Generic.IList<string?> _nonRequiredStringListProperty = null!;
public System.Collections.Generic.IList<string?> NonRequiredStringListProperty
{
get
{
if (_nonRequiredStringListProperty == null)
{
_nonRequiredStringListProperty = GetListValue<string?>("NonRequiredStringListProperty");
}
return _nonRequiredStringListProperty;
}
}
private System.Collections.Generic.ISet<string?> _nonRequiredStringSetProperty = null!;
public System.Collections.Generic.ISet<string?> NonRequiredStringSetProperty
{
get
{
if (_nonRequiredStringSetProperty == null)
{
_nonRequiredStringSetProperty = GetSetValue<string?>("NonRequiredStringSetProperty");
}
return _nonRequiredStringSetProperty;
}
}
private System.Collections.Generic.IDictionary<string, string?> _nonRequiredStringDictionaryProperty = null!;
public System.Collections.Generic.IDictionary<string, string?> NonRequiredStringDictionaryProperty
{
get
{
if (_nonRequiredStringDictionaryProperty == null)
{
_nonRequiredStringDictionaryProperty = GetDictionaryValue<string?>("NonRequiredStringDictionaryProperty");
}
return _nonRequiredStringDictionaryProperty;
}
}
}
[EditorBrowsable(EditorBrowsableState.Never), Realms.Preserve(AllMembers = true)]
private class AllTypesClassUnmanagedAccessor : Realms.UnmanagedAccessor, IAllTypesClassAccessor
{
public override ObjectSchema ObjectSchema => AllTypesClass.RealmSchema;
private char _charProperty;
public char CharProperty
{
get => _charProperty;
set
{
_charProperty = value;
RaisePropertyChanged("CharProperty");
}
}
private byte _byteProperty;
public byte ByteProperty
{
get => _byteProperty;
set
{
_byteProperty = value;
RaisePropertyChanged("ByteProperty");
}
}
private short _int16Property;
public short Int16Property
{
get => _int16Property;
set
{
_int16Property = value;
RaisePropertyChanged("Int16Property");
}
}
private int _int32Property;
public int Int32Property
{
get => _int32Property;
set
{
_int32Property = value;
RaisePropertyChanged("Int32Property");
}
}
private long _int64Property;
public long Int64Property
{
get => _int64Property;
set
{
_int64Property = value;
RaisePropertyChanged("Int64Property");
}
}
private float _singleProperty;
public float SingleProperty
{
get => _singleProperty;
set
{
_singleProperty = value;
RaisePropertyChanged("SingleProperty");
}
}
private double _doubleProperty;
public double DoubleProperty
{
get => _doubleProperty;
set
{
_doubleProperty = value;
RaisePropertyChanged("DoubleProperty");
}
}
private bool _booleanProperty;
public bool BooleanProperty
{
get => _booleanProperty;
set
{
_booleanProperty = value;
RaisePropertyChanged("BooleanProperty");
}
}
private System.DateTimeOffset _dateTimeOffsetProperty;
public System.DateTimeOffset DateTimeOffsetProperty
{
get => _dateTimeOffsetProperty;
set
{
_dateTimeOffsetProperty = value;
RaisePropertyChanged("DateTimeOffsetProperty");
}
}
private decimal _decimalProperty;
public decimal DecimalProperty
{
get => _decimalProperty;
set
{
_decimalProperty = value;
RaisePropertyChanged("DecimalProperty");
}
}
private MongoDB.Bson.Decimal128 _decimal128Property;
public MongoDB.Bson.Decimal128 Decimal128Property
{
get => _decimal128Property;
set
{
_decimal128Property = value;
RaisePropertyChanged("Decimal128Property");
}
}
private MongoDB.Bson.ObjectId _objectIdProperty;
public MongoDB.Bson.ObjectId ObjectIdProperty
{
get => _objectIdProperty;
set
{
_objectIdProperty = value;
RaisePropertyChanged("ObjectIdProperty");
}
}
private System.Guid _guidProperty;
public System.Guid GuidProperty
{
get => _guidProperty;
set
{
_guidProperty = value;
RaisePropertyChanged("GuidProperty");
}
}
private string _requiredStringProperty = "";
public string RequiredStringProperty
{
get => _requiredStringProperty;
set
{
_requiredStringProperty = value;
RaisePropertyChanged("RequiredStringProperty");
}
}
private string? _stringProperty;
public string? StringProperty
{
get => _stringProperty;
set
{
_stringProperty = value;
RaisePropertyChanged("StringProperty");
}
}
private byte[] _requiredByteArrayProperty = Array.Empty<byte>();
public byte[] RequiredByteArrayProperty
{
get => _requiredByteArrayProperty;
set
{
_requiredByteArrayProperty = value;
RaisePropertyChanged("RequiredByteArrayProperty");
}
}
private byte[]? _byteArrayProperty;
public byte[]? ByteArrayProperty
{
get => _byteArrayProperty;
set
{
_byteArrayProperty = value;
RaisePropertyChanged("ByteArrayProperty");
}
}
private char? _nullableCharProperty;
public char? NullableCharProperty
{
get => _nullableCharProperty;
set
{
_nullableCharProperty = value;
RaisePropertyChanged("NullableCharProperty");
}
}
private byte? _nullableByteProperty;
public byte? NullableByteProperty
{
get => _nullableByteProperty;
set
{
_nullableByteProperty = value;
RaisePropertyChanged("NullableByteProperty");
}
}
private short? _nullableInt16Property;
public short? NullableInt16Property
{
get => _nullableInt16Property;
set
{
_nullableInt16Property = value;
RaisePropertyChanged("NullableInt16Property");
}
}
private int? _nullableInt32Property;
public int? NullableInt32Property
{
get => _nullableInt32Property;
set
{
_nullableInt32Property = value;
RaisePropertyChanged("NullableInt32Property");
}
}
private long? _nullableInt64Property;
public long? NullableInt64Property
{
get => _nullableInt64Property;
set
{
_nullableInt64Property = value;
RaisePropertyChanged("NullableInt64Property");
}
}
private float? _nullableSingleProperty;
public float? NullableSingleProperty
{
get => _nullableSingleProperty;
set
{
_nullableSingleProperty = value;
RaisePropertyChanged("NullableSingleProperty");
}
}
private double? _nullableDoubleProperty;
public double? NullableDoubleProperty
{
get => _nullableDoubleProperty;
set
{
_nullableDoubleProperty = value;
RaisePropertyChanged("NullableDoubleProperty");
}
}
private bool? _nullableBooleanProperty;
public bool? NullableBooleanProperty
{
get => _nullableBooleanProperty;
set
{
_nullableBooleanProperty = value;
RaisePropertyChanged("NullableBooleanProperty");
}
}
private System.DateTimeOffset? _nullableDateTimeOffsetProperty;
public System.DateTimeOffset? NullableDateTimeOffsetProperty
{
get => _nullableDateTimeOffsetProperty;
set
{
_nullableDateTimeOffsetProperty = value;
RaisePropertyChanged("NullableDateTimeOffsetProperty");
}
}
private decimal? _nullableDecimalProperty;
public decimal? NullableDecimalProperty
{
get => _nullableDecimalProperty;
set
{
_nullableDecimalProperty = value;
RaisePropertyChanged("NullableDecimalProperty");
}
}
private MongoDB.Bson.Decimal128? _nullableDecimal128Property;
public MongoDB.Bson.Decimal128? NullableDecimal128Property
{
get => _nullableDecimal128Property;
set
{
_nullableDecimal128Property = value;
RaisePropertyChanged("NullableDecimal128Property");
}
}
private MongoDB.Bson.ObjectId? _nullableObjectIdProperty;
public MongoDB.Bson.ObjectId? NullableObjectIdProperty
{
get => _nullableObjectIdProperty;
set
{
_nullableObjectIdProperty = value;
RaisePropertyChanged("NullableObjectIdProperty");
}
}
private System.Guid? _nullableGuidProperty;
public System.Guid? NullableGuidProperty
{
get => _nullableGuidProperty;
set
{
_nullableGuidProperty = value;
RaisePropertyChanged("NullableGuidProperty");
}
}
private Realms.RealmInteger<byte> _byteCounterProperty;
public Realms.RealmInteger<byte> ByteCounterProperty
{
get => _byteCounterProperty;
set
{
_byteCounterProperty = value;
RaisePropertyChanged("ByteCounterProperty");
}
}
private Realms.RealmInteger<short> _int16CounterProperty;
public Realms.RealmInteger<short> Int16CounterProperty
{
get => _int16CounterProperty;
set
{
_int16CounterProperty = value;
RaisePropertyChanged("Int16CounterProperty");
}
}
private Realms.RealmInteger<int> _int32CounterProperty;
public Realms.RealmInteger<int> Int32CounterProperty
{
get => _int32CounterProperty;
set
{
_int32CounterProperty = value;
RaisePropertyChanged("Int32CounterProperty");
}
}
private Realms.RealmInteger<long> _int64CounterProperty;
public Realms.RealmInteger<long> Int64CounterProperty
{
get => _int64CounterProperty;
set
{
_int64CounterProperty = value;
RaisePropertyChanged("Int64CounterProperty");
}
}
private Realms.RealmValue _realmValueProperty;
public Realms.RealmValue RealmValueProperty
{
get => _realmValueProperty;
set
{
_realmValueProperty = value;
RaisePropertyChanged("RealmValueProperty");
}
}
private SourceGeneratorAssemblyToProcess.AllTypesClass? _objectProperty;
public SourceGeneratorAssemblyToProcess.AllTypesClass? ObjectProperty
{
get => _objectProperty;
set
{
_objectProperty = value;
RaisePropertyChanged("ObjectProperty");
}
}
public System.Collections.Generic.IList<SourceGeneratorAssemblyToProcess.AllTypesClass> ObjectCollectionProperty { get; } = new List<SourceGeneratorAssemblyToProcess.AllTypesClass>();
public System.Collections.Generic.IList<int> IntCollectionProperty { get; } = new List<int>();
public System.Collections.Generic.IList<int?> NullableIntCollectionProperty { get; } = new List<int?>();
public System.Collections.Generic.IList<string> StringCollectionProperty { get; } = new List<string>();
public System.Collections.Generic.IList<string> RequiredStringListProperty { get; } = new List<string>();
public System.Collections.Generic.ISet<string> RequiredStringSetProperty { get; } = new HashSet<string>(RealmSet<string>.Comparer);
public System.Collections.Generic.IDictionary<string, string> RequiredStringDictionaryProperty { get; } = new Dictionary<string, string>();
public System.Collections.Generic.IList<string?> NonRequiredStringListProperty { get; } = new List<string?>();
public System.Collections.Generic.ISet<string?> NonRequiredStringSetProperty { get; } = new HashSet<string?>(RealmSet<string?>.Comparer);
public System.Collections.Generic.IDictionary<string, string?> NonRequiredStringDictionaryProperty { get; } = new Dictionary<string, string?>();
public AllTypesClassUnmanagedAccessor(Type objectType) : base(objectType)
{
}
public override Realms.RealmValue GetValue(string propertyName)
{
return propertyName switch
{
"CharProperty" => _charProperty,
"ByteProperty" => _byteProperty,
"Int16Property" => _int16Property,
"Int32Property" => _int32Property,
"Int64Property" => _int64Property,
"SingleProperty" => _singleProperty,
"DoubleProperty" => _doubleProperty,
"BooleanProperty" => _booleanProperty,
"DateTimeOffsetProperty" => _dateTimeOffsetProperty,
"DecimalProperty" => _decimalProperty,
"Decimal128Property" => _decimal128Property,
"ObjectIdProperty" => _objectIdProperty,
"GuidProperty" => _guidProperty,
"RequiredStringProperty" => _requiredStringProperty,
"StringProperty" => _stringProperty,
"RequiredByteArrayProperty" => _requiredByteArrayProperty,
"ByteArrayProperty" => _byteArrayProperty,
"NullableCharProperty" => _nullableCharProperty,
"NullableByteProperty" => _nullableByteProperty,
"NullableInt16Property" => _nullableInt16Property,
"NullableInt32Property" => _nullableInt32Property,
"NullableInt64Property" => _nullableInt64Property,
"NullableSingleProperty" => _nullableSingleProperty,
"NullableDoubleProperty" => _nullableDoubleProperty,
"NullableBooleanProperty" => _nullableBooleanProperty,
"NullableDateTimeOffsetProperty" => _nullableDateTimeOffsetProperty,
"NullableDecimalProperty" => _nullableDecimalProperty,
"NullableDecimal128Property" => _nullableDecimal128Property,
"NullableObjectIdProperty" => _nullableObjectIdProperty,
"NullableGuidProperty" => _nullableGuidProperty,
"ByteCounterP...
|
Realm.SourceGenerator.Tests.dll.SourceGeneratorTests.ComparisonTests.ComparisonTest. ► SourceGeneratorTests.ComparisonTests ► ComparisonTest(NullableClass):
No path available#L-1
Failed test found in:
TestResults.SourceGeneration.xml
Error:
Context: Source generator application
content of 'Realm.SourceGenerator\Realms.SourceGenerator.RealmGenerator\NullableClass_generated.cs' did not match. Diff shown with expected as baseline:
// <auto-generated />
#nullable enable
using MongoDB.Bson.Serialization;
using Realms;
using Realms.Schema;
using Realms.Weaving;
using SourceGeneratorAssemblyToProcess;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Xml.Serialization;
namespace SourceGeneratorAssemblyToProcess
{
[Generated]
[Woven(typeof(NullableClassObjectHelper)), Realms.Preserve(AllMembers = true)]
public partial class NullableClass : IRealmObject, INotifyPropertyChanged, IReflectableType
{
[Realms.Preserve]
static NullableClass()
{
Realms.Serialization.RealmObjectSerializer.Register(new NullableClassSerializer());
}
/// <summary>
/// Defines the schema for the <see cref="NullableClass"/> class.
/// </summary>
public static Realms.Schema.ObjectSchema RealmSchema = new Realms.Schema.ObjectSchema.Builder("NullableClass", ObjectSchema.ObjectType.RealmObject)
{
Realms.Schema.Property.Primitive("NonNullableInt", Realms.RealmValueType.Int, isPrimaryKey: false, indexType: IndexType.None, isNullable: false, managedName: "NonNullableInt"),
Realms.Schema.Property.Primitive("NullableInt", Realms.RealmValueType.Int, isPrimaryKey: false, indexType: IndexType.None, isNullable: true, managedName: "NullableInt"),
Realms.Schema.Property.Primitive("NonNullableString", Realms.RealmValueType.String, isPrimaryKey: false, indexType: IndexType.None, isNullable: false, managedName: "NonNullableString"),
Realms.Schema.Property.Primitive("NullableString", Realms.RealmValueType.String, isPrimaryKey: false, indexType: IndexType.None, isNullable: true, managedName: "NullableString"),
Realms.Schema.Property.Primitive("NonNullableData", Realms.RealmValueType.Data, isPrimaryKey: false, indexType: IndexType.None, isNullable: false, managedName: "NonNullableData"),
Realms.Schema.Property.Primitive("NullableData", Realms.RealmValueType.Data, isPrimaryKey: false, indexType: IndexType.None, isNullable: true, managedName: "NullableData"),
Realms.Schema.Property.PrimitiveList("CollectionOfNullableInt", Realms.RealmValueType.Int, areElementsNullable: true, managedName: "CollectionOfNullableInt"),
Realms.Schema.Property.PrimitiveList("CollectionOfNonNullableInt", Realms.RealmValueType.Int, areElementsNullable: false, managedName: "CollectionOfNonNullableInt"),
Realms.Schema.Property.PrimitiveList("CollectionOfNullableString", Realms.RealmValueType.String, areElementsNullable: true, managedName: "CollectionOfNullableString"),
Realms.Schema.Property.PrimitiveList("CollectionOfNonNullableString", Realms.RealmValueType.String, areElementsNullable: false, managedName: "CollectionOfNonNullableString"),
Realms.Schema.Property.Primitive("NonNullableRealmInt", Realms.RealmValueType.Int, isPrimaryKey: false, indexType: IndexType.None, isNullable: false, managedName: "NonNullableRealmInt"),
Realms.Schema.Property.Primitive("NullableRealmInt", Realms.RealmValueType.Int, isPrimaryKey: false, indexType: IndexType.None, isNullable: true, managedName: "NullableRealmInt"),
Realms.Schema.Property.Object("NullableObject", "NullableClass", managedName: "NullableObject"),
Realms.Schema.Property.ObjectList("ListNonNullabeObject", "NullableClass", managedName: "ListNonNullabeObject"),
Realms.Schema.Property.ObjectSet("SetNonNullableObject", "NullableClass", managedName: "SetNonNullableObject"),
Realms.Schema.Property.ObjectDictionary("DictionaryNullableObject", "NullableClass", managedName: "DictionaryNullableObject"),
Realms.Schema.Property.RealmValue("NonNullableRealmValue", managedName: "NonNullableRealmValue"),
Realms.Schema.Property.Backlinks("Backlink", "NullableClass", "NullableObject", managedName: "Backlink"),
}.Build();
#region IRealmObject implementation
private INullableClassAccessor? _accessor;
Realms.IRealmAccessor Realms.IRealmObjectBase.Accessor => Accessor;
private INullableClassAccessor Accessor => _accessor ??= new NullableClassUnmanagedAccessor(typeof(NullableClass));
/// <inheritdoc />
[IgnoreDataMember, XmlIgnore]
public bool IsManaged => Accessor.IsManaged;
/// <inheritdoc />
[IgnoreDataMember, XmlIgnore]
public bool IsValid => Accessor.IsValid;
/// <inheritdoc />
[IgnoreDataMember, XmlIgnore]
public bool IsFrozen => Accessor.IsFrozen;
/// <inheritdoc />
[IgnoreDataMember, XmlIgnore]
public Realms.Realm? Realm => Accessor.Realm;
/// <inheritdoc />
[IgnoreDataMember, XmlIgnore]
public Realms.Schema.ObjectSchema ObjectSchema => Accessor.ObjectSchema!;
/// <inheritdoc />
[IgnoreDataMember, XmlIgnore]
public Realms.DynamicObjectApi DynamicApi => Accessor.DynamicApi;
/// <inheritdoc />
[IgnoreDataMember, XmlIgnore]
public int BacklinksCount => Accessor.BacklinksCount;
void ISettableManagedAccessor.SetManagedAccessor(Realms.IRealmAccessor managedAccessor, Realms.Weaving.IRealmObjectHelper? helper, bool update, bool skipDefaults)
{
var newAccessor = (INullableClassAccessor)managedAccessor;
var oldAccessor = _accessor;
_accessor = newAccessor;
if (helper != null && oldAccessor != null)
{
if (!skipDefaults)
{
newAccessor.CollectionOfNullableInt.Clear();
newAccessor.CollectionOfNonNullableInt.Clear();
newAccessor.CollectionOfNullableString.Clear();
newAccessor.CollectionOfNonNullableString.Clear();
newAccessor.ListNonNullabeObject.Clear();
newAccessor.SetNonNullableObject.Clear();
newAccessor.DictionaryNullableObject.Clear();
}
if (!skipDefaults || oldAccessor.NonNullableInt != default(int))
{
newAccessor.NonNullableInt = oldAccessor.NonNullableInt;
}
if (!skipDefaults || oldAccessor.NullableInt != default(int?))
{
newAccessor.NullableInt = oldAccessor.NullableInt;
}
newAccessor.NonNullableString = oldAccessor.NonNullableString;
if (!skipDefaults || oldAccessor.NullableString != default(string?))
{
newAccessor.NullableString = oldAccessor.NullableString;
}
newAccessor.NonNullableData = oldAccessor.NonNullableData;
if (!skipDefaults || oldAccessor.NullableData != default(byte[]?))
{
newAccessor.NullableData = oldAccessor.NullableData;
}
Realms.CollectionExtensions.PopulateCollection(oldAccessor.CollectionOfNullableInt, newAccessor.CollectionOfNullableInt, update, skipDefaults);
Realms.CollectionExtensions.PopulateCollection(oldAccessor.CollectionOfNonNullableInt, newAccessor.CollectionOfNonNullableInt, update, skipDefaults);
Realms.CollectionExtensions.PopulateCollection(oldAccessor.CollectionOfNullableString, newAccessor.CollectionOfNullableString, update, skipDefaults);
Realms.CollectionExtensions.PopulateCollection(oldAccessor.CollectionOfNonNullableString, newAccessor.CollectionOfNonNullableString, update, skipDefaults);
if (!skipDefaults || oldAccessor.NonNullableRealmInt != default(Realms.RealmInteger<int>))
{
newAccessor.NonNullableRealmInt = oldAccessor.NonNullableRealmInt;
}
if (!skipDefaults || oldAccessor.NullableRealmInt != default(Realms.RealmInteger<int>?))
{
newAccessor.NullableRealmInt = oldAccessor.NullableRealmInt;
}
if (oldAccessor.NullableObject != null && newAccessor.Realm != null)
{
newAccessor.Realm.Add(oldAccessor.NullableObject, update);
}
newAccessor.NullableObject = oldAccessor.NullableObject;
Realms.CollectionExtensions.PopulateCollection(oldAccessor.ListNonNullabeObject, newAccessor.ListNonNullabeObject, update, skipDefaults);
Realms.CollectionExtensions.PopulateCollection(oldAccessor.SetNonNullableObject, newAccessor.SetNonNullableObject, update, skipDefaults);
Realms.CollectionExtensions.PopulateCollection(oldAccessor.DictionaryNullableObject, newAccessor.DictionaryNullableObject, update, skipDefaults);
newAccessor.NonNullableRealmValue = oldAccessor.NonNullableRealmValue;
}
if (_propertyChanged != null)
{
SubscribeForNotifications();
}
OnManaged();
}
#endregion
/// <summary>
/// Called when the object has been managed by a Realm.
/// </summary>
/// <remarks>
/// This method will be called either when a managed object is materialized or when an unmanaged object has been
/// added to the Realm. It can be useful for providing some initialization logic as when the constructor is invoked,
/// it is not yet clear whether the object is managed or not.
/// </remarks>
partial void OnManaged();
private event PropertyChangedEventHandler? _propertyChanged;
/// <inheritdoc />
public event PropertyChangedEventHandler? PropertyChanged
{
add
{
if (_propertyChanged == null)
{
SubscribeForNotifications();
}
_propertyChanged += value;
}
remove
{
_propertyChanged -= value;
if (_propertyChanged == null)
{
UnsubscribeFromNotifications();
}
}
}
/// <summary>
/// Called when a property has changed on this class.
/// </summary>
/// <param name="propertyName">The name of the property.</param>
/// <remarks>
/// For this method to be called, you need to have first subscribed to <see cref="PropertyChanged"/>.
/// This can be used to react to changes to the current object, e.g. raising <see cref="PropertyChanged"/> for computed properties.
/// </remarks>
/// <example>
/// <code>
/// class MyClass : IRealmObject
/// {
/// public int StatusCodeRaw { get; set; }
/// public StatusCodeEnum StatusCode => (StatusCodeEnum)StatusCodeRaw;
/// partial void OnPropertyChanged(string propertyName)
/// {
/// if (propertyName == nameof(StatusCodeRaw))
/// {
/// RaisePropertyChanged(nameof(StatusCode));
/// }
/// }
/// }
/// </code>
/// Here, we have a computed property that depends on a persisted one. In order to notify any <see cref="PropertyChanged"/>
/// subscribers that <c>StatusCode</c> has changed, we implement <see cref="OnPropertyChanged"/> and
/// raise <see cref="PropertyChanged"/> manually by calling <see cref="RaisePropertyChanged"/>.
/// </example>
partial void OnPropertyChanged(string? propertyName);
private void RaisePropertyChanged([CallerMemberName] string propertyName = "")
{
_propertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
OnPropertyChanged(propertyName);
}
private void SubscribeForNotifications()
{
Accessor.SubscribeForNotifications(RaisePropertyChanged);
}
private void UnsubscribeFromNotifications()
{
Accessor.UnsubscribeFromNotifications();
}
/// <summary>
/// Converts a <see cref="Realms.RealmValue"/> to <see cref="NullableClass"/>. Equivalent to <see cref="Realms.RealmValue.AsNullableRealmObject{T}"/>.
/// </summary>
/// <param name="val">The <see cref="Realms.RealmValue"/> to convert.</param>
/// <returns>The <see cref="NullableClass"/> stored in the <see cref="Realms.RealmValue"/>.</returns>
public static explicit operator NullableClass?(Realms.RealmValue val) => val.Type == Realms.RealmValueType.Null ? null : val.AsRealmObject<NullableClass>();
/// <summary>
/// Implicitly constructs a <see cref="Realms.RealmValue"/> from <see cref="NullableClass"/>.
/// </summary>
/// <param name="val">The value to store in the <see cref="Realms.RealmValue"/>.</param>
/// <returns>A <see cref="Realms.RealmValue"/> containing the supplied <paramref name="val"/>.</returns>
public static implicit operator Realms.RealmValue(NullableClass? val) => val == null ? Realms.RealmValue.Null : Realms.RealmValue.Object(val);
/// <summary>
/// Implicitly constructs a <see cref="Realms.QueryArgument"/> from <see cref="NullableClass"/>.
/// </summary>
/// <param name="val">The value to store in the <see cref="Realms.QueryArgument"/>.</param>
/// <returns>A <see cref="Realms.QueryArgument"/> containing the supplied <paramref name="val"/>.</returns>
public static implicit operator Realms.QueryArgument(NullableClass? val) => (Realms.RealmValue)val;
/// <inheritdoc />
[EditorBrowsable(EditorBrowsableState.Never)]
public TypeInfo GetTypeInfo() => Accessor.GetTypeInfo(this);
/// <inheritdoc />
public override bool Equals(object? obj)
{
if (obj is null)
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
if (obj is InvalidObject)
{
return !IsValid;
}
if (obj is not Realms.IRealmObjectBase iro)
{
return false;
}
return Accessor.Equals(iro.Accessor);
}
/// <inheritdoc />
public override int GetHashCode() => IsManaged ? Accessor.GetHashCode() : base.GetHashCode();
/// <inheritdoc />
public override string? ToString() => Accessor.ToString();
[EditorBrowsable(EditorBrowsableState.Never), Realms.Preserve(AllMembers = true)]
private class NullableClassObjectHelper : Realms.Weaving.IRealmObjectHelper
{
public void CopyToRealm(Realms.IRealmObjectBase instance, bool update, bool skipDefaults)
{
throw new InvalidOperationException("This method should not be called for source generated classes.");
}
public Realms.ManagedAccessor CreateAccessor() => new NullableClassManagedAccessor();
public Realms.IRealmObjectBase CreateInstance() => new NullableClass();
public bool TryGetPrimaryKeyValue(Realms.IRealmObjectBase instance, out RealmValue value)
{
value = RealmValue.Null;
return false;
}
}
[EditorBrowsable(EditorBrowsableState.Never), Realms.Preserve(AllMembers = true)]
internal interface INullableClassAccessor : Realms.IRealmAccessor
{
int NonNullableInt { get; set; }
int? NullableInt { get; set; }
string NonNullableString { get; set; }
string? NullableString { get; set; }
byte[] NonNullableData { get; set; }
byte[]? NullableData { get; set; }
System.Collections.Generic.IList<int?> CollectionOfNullableInt { get; }
System.Collections.Generic.IList<int> CollectionOfNonNullableInt { get; }
System.Collections.Generic.IList<string?> CollectionOfNullableString { get; }
System.Collections.Generic.IList<string> CollectionOfNonNullableString { get; }
Realms.RealmInteger<int> NonNullableRealmInt { get; set; }
Realms.RealmInteger<int>? NullableRealmInt { get; set; }
SourceGeneratorAssemblyToProcess.NullableClass? NullableObject { get; set; }
System.Collections.Generic.IList<SourceGeneratorAssemblyToProcess.NullableClass> ListNonNullabeObject { get; }
System.Collections.Generic.ISet<SourceGeneratorAssemblyToProcess.NullableClass> SetNonNullableObject { get; }
System.Collections.Generic.IDictionary<string, SourceGeneratorAssemblyToProcess.NullableClass?> DictionaryNullableObject { get; }
Realms.RealmValue NonNullableRealmValue { get; set; }
System.Linq.IQueryable<SourceGeneratorAssemblyToProcess.NullableClass> Backlink { get; }
}
[EditorBrowsable(EditorBrowsableState.Never), Realms.Preserve(AllMembers = true)]
private class NullableClassManagedAccessor : Realms.ManagedAccessor, INullableClassAccessor
{
public int NonNullableInt
{
get => (int)GetValue("NonNullableInt");
set => SetValue("NonNullableInt", value);
}
public int? NullableInt
{
get => (int?)GetValue("NullableInt");
set => SetValue("NullableInt", value);
}
public string NonNullableString
{
get => (string)GetValue("NonNullableString")!;
set => SetValue("NonNullableString", value);
}
public string? NullableString
{
get => (string?)GetValue("NullableString");
set => SetValue("NullableString", value);
}
public byte[] NonNullableData
{
get => (byte[])GetValue("NonNullableData")!;
set => SetValue("NonNullableData", value);
}
public byte[]? NullableData
{
get => (byte[]?)GetValue("NullableData");
set => SetValue("NullableData", value);
}
private System.Collections.Generic.IList<int?> _collectionOfNullableInt = null!;
public System.Collections.Generic.IList<int?> CollectionOfNullableInt
{
get
{
if (_collectionOfNullableInt == null)
{
_collectionOfNullableInt = GetListValue<int?>("CollectionOfNullableInt");
}
return _collectionOfNullableInt;
}
}
private System.Collections.Generic.IList<int> _collectionOfNonNullableInt = null!;
public System.Collections.Generic.IList<int> CollectionOfNonNullableInt
{
get
{
if (_collectionOfNonNullableInt == null)
{
_collectionOfNonNullableInt = GetListValue<int>("CollectionOfNonNullableInt");
}
return _collectionOfNonNullableInt;
}
}
private System.Collections.Generic.IList<string?> _collectionOfNullableString = null!;
public System.Collections.Generic.IList<string?> CollectionOfNullableString
{
get
{
if (_collectionOfNullableString == null)
{
_collectionOfNullableString = GetListValue<string?>("CollectionOfNullableString");
}
return _collectionOfNullableString;
}
}
private System.Collections.Generic.IList<string> _collectionOfNonNullableString = null!;
public System.Collections.Generic.IList<string> CollectionOfNonNullableString
{
get
{
if (_collectionOfNonNullableString == null)
{
_collectionOfNonNullableString = GetListValue<string>("CollectionOfNonNullableString");
}
return _collectionOfNonNullableString;
}
}
public Realms.RealmInteger<int> NonNullableRealmInt
{
get => (Realms.RealmInteger<int>)GetValue("NonNullableRealmInt");
set => SetValue("NonNullableRealmInt", value);
}
public Realms.RealmInteger<int>? NullableRealmInt
{
get => (Realms.RealmInteger<int>?)GetValue("NullableRealmInt");
set => SetValue("NullableRealmInt", value);
}
public SourceGeneratorAssemblyToProcess.NullableClass? NullableObject
{
get => (SourceGeneratorAssemblyToProcess.NullableClass?)GetValue("NullableObject");
set => SetValue("NullableObject", value);
}
private System.Collections.Generic.IList<SourceGeneratorAssemblyToProcess.NullableClass> _listNonNullabeObject = null!;
public System.Collections.Generic.IList<SourceGeneratorAssemblyToProcess.NullableClass> ListNonNullabeObject
{
get
{
if (_listNonNullabeObject == null)
{
_listNonNullabeObject = GetListValue<SourceGeneratorAssemblyToProcess.NullableClass>("ListNonNullabeObject");
}
return _listNonNullabeObject;
}
}
private System.Collections.Generic.ISet<SourceGeneratorAssemblyToProcess.NullableClass> _setNonNullableObject = null!;
public System.Collections.Generic.ISet<SourceGeneratorAssemblyToProcess.NullableClass> SetNonNullableObject
{
get
{
if (_setNonNullableObject == null)
{
_setNonNullableObject = GetSetValue<SourceGeneratorAssemblyToProcess.NullableClass>("SetNonNullableObject");
}
return _setNonNullableObject;
}
}
private System.Collections.Generic.IDictionary<string, SourceGeneratorAssemblyToProcess.NullableClass?> _dictionaryNullableObject = null!;
public System.Collections.Generic.IDictionary<string, SourceGeneratorAssemblyToProcess.NullableClass?> DictionaryNullableObject
{
get
{
if (_dictionaryNullableObject == null)
{
_dictionaryNullableObject = GetDictionaryValue<SourceGeneratorAssemblyToProcess.NullableClass?>("DictionaryNullableObject");
}
return _dictionaryNullableObject;
}
}
public Realms.RealmValue NonNullableRealmValue
{
get => (Realms.RealmValue)GetValue("NonNullableRealmValue");
set => SetValue("NonNullableRealmValue", value);
}
private System.Linq.IQueryable<SourceGeneratorAssemblyToProcess.NullableClass> _backlink = null!;
public System.Linq.IQueryable<SourceGeneratorAssemblyToProcess.NullableClass> Backlink
{
get
{
if (_backlink == null)
{
_backlink = GetBacklinks<SourceGeneratorAssemblyToProcess.NullableClass>("Backlink");
}
return _backlink;
}
}
}
[EditorBrowsable(EditorBrowsableState.Never), Realms.Preserve(AllMembers = true)]
private class NullableClassUnmanagedAccessor : Realms.UnmanagedAccessor, INullableClassAccessor
{
public override ObjectSchema ObjectSchema => NullableClass.RealmSchema;
private int _nonNullableInt;
public int NonNullableInt
{
get => _nonNullableInt;
set
{
_nonNullableInt = value;
RaisePropertyChanged("NonNullableInt");
}
}
private int? _nullableInt;
public int? NullableInt
{
get => _nullableInt;
set
{
_nullableInt = value;
RaisePropertyChanged("NullableInt");
}
}
private string _nonNullableString = null!;
public string NonNullableString
{
get => _nonNullableString;
set
{
_nonNullableString = value;
RaisePropertyChanged("NonNullableString");
}
}
private string? _nullableString;
public string? NullableString
{
get => _nullableString;
set
{
_nullableString = value;
RaisePropertyChanged("NullableString");
}
}
private byte[] _nonNullableData = null!;
public byte[] NonNullableData
{
get => _nonNullableData;
set
{
_nonNullableData = value;
RaisePropertyChanged("NonNullableData");
}
}
private byte[]? _nullableData;
public byte[]? NullableData
{
get => _nullableData;
set
{
_nullableData = value;
RaisePropertyChanged("NullableData");
}
}
public System.Collections.Generic.IList<int?> CollectionOfNullableInt { get; } = new List<int?>();
public System.Collections.Generic.IList<int> CollectionOfNonNullableInt { get; } = new List<int>();
public System.Collections.Generic.IList<string?> CollectionOfNullableString { get; } = new List<string?>();
public System.Collections.Generic.IList<string> CollectionOfNonNullableString { get; } = new List<string>();
private Realms.RealmInteger<int> _nonNullableRealmInt;
public Realms.RealmInteger<int> NonNullableRealmInt
{
get => _nonNullableRealmInt;
set
{
_nonNullableRealmInt = value;
RaisePropertyChanged("NonNullableRealmInt");
}
}
private Realms.RealmInteger<int>? _nullableRealmInt;
public Realms.RealmInteger<int>? NullableRealmInt
{
get => _nullableRealmInt;
set
{
_nullableRealmInt = value;
RaisePropertyChanged("NullableRealmInt");
}
}
private SourceGeneratorAssemblyToProcess.NullableClass? _nullableObject;
public SourceGeneratorAssemblyToProcess.NullableClass? NullableObject
{
get => _nullableObject;
set
{
_nullableObject = value;
RaisePropertyChanged("NullableObject");
}
}
public System.Collections.Generic.IList<SourceGeneratorAssemblyToProcess.NullableClass> ListNonNullabeObject { get; } = new List<SourceGeneratorAssemblyToProcess.NullableClass>();
public System.Collections.Generic.ISet<SourceGeneratorAssemblyToProcess.NullableClass> SetNonNullableObject { get; } = new HashSet<SourceGeneratorAssemblyToProcess.NullableClass>(RealmSet<SourceGeneratorAssemblyToProcess.NullableClass>.Comparer);
public System.Collections.Generic.IDictionary<string, SourceGeneratorAssemblyToProcess.NullableClass?> DictionaryNullableObject { get; } = new Dictionary<string, SourceGeneratorAssemblyToProcess.NullableClass?>();
private Realms.RealmValue _nonNullableRealmValue;
public Realms.RealmValue NonNullableRealmValue
{
get => _nonNullableRealmValue;
set
{
_nonNullableRealmValue = value;
RaisePropertyChanged("NonNullableRealmValue");
}
}
public System.Linq.IQueryable<SourceGeneratorAssemblyToProcess.NullableClass> Backlink => throw new NotSupportedException("Using backlinks is only possible for managed(persisted) objects.");
public NullableClassUnmanagedAccessor(Type objectType) : base(objectType)
{
}
public override Realms.RealmValue GetValue(string propertyName)
{
return propertyName switch
{
"NonNullableInt" => _nonNullableInt,
"NullableInt" => _nullableInt,
"NonNullableString" => _nonNullableString,
"NullableString" => _nullableString,
"NonNullableData" => _nonNullableData,
"NullableData" => _nullableData,
"NonNullableRealmInt" => _nonNullableRealmInt,
"NullableRealmInt" => _nullableRealmInt,
"NullableObject" => _nullableObject,
"NonNullableRealmValue" => _nonNullableRealmValue,
"Backlink" => throw new NotSupportedException("Using backlinks is only possible for managed(persisted) objects."),
_ => throw new MissingMemberException($"The object does not have a gettable Realm property with name {propertyName}"),
};
}
public override void SetValue(string propertyName, Realms.RealmValue val)
{
switch (propertyName)
{
case "NonNullableInt":
NonNullableInt = (int)val;
return;
case "NullableInt":
NullableInt = (int?)val;
return;
case "NonNullableString":
NonNullableString = (string)val!;
return;
case "NullableString":
NullableString = (string?)val;
return;
case "NonNullableData":
NonNullableData = (byte[])val!;
return;
case "NullableData":
NullableData = (byte[]?)val;
return;
case "NonNullableRealmInt":
NonNullableRealmInt = (Realms.RealmInteger<int>)val;
return;
case "NullableRealmInt":
NullableRealmInt = (Realms.RealmInteger<int>?)val;
return;
case "NullableObject":
NullableObject = (SourceGeneratorAssemblyToProcess.NullableClass?)val;
return;
case "NonNullableRealmValue":
NonNullableRealmValue = (Realms.RealmValue)val;
return;
default:
throw new MissingMemberException($"The object does not have a settable Realm property with name {propertyName}");
}
}
public override void SetValueUnique(string propertyName, Realms.RealmValue val)
{
throw new InvalidOperationException("Cannot set the value of an non primary key property with SetValueUnique");
}
public override IList<T> GetListValue<T>(string propertyName)
{
return propertyName switch
{
"CollectionOfNullableInt" => (IList<T>)CollectionOfNullableInt,
"CollectionOfNonNullableInt" => (IList<T>)CollectionOfNonNullableInt,
"CollectionOfNullableString" => (IList<T>)CollectionOfNullableString,
"CollectionOfNonNullableString" => (IList<T>)CollectionOfNonNullableString,
"ListNonNullabeObject" => (IList<T>)ListNonNullabeObject,
_ => throw new MissingMemberException($"The object does not have a Realm list property with name {propertyName}"),
};
}
public override ISet<T> GetSetValue<T>(string propertyName)
{
return propertyName switch
{
"SetNonNullableObject" => (ISet<T>)SetNonNullableObject,
_ => throw new MissingMemberException($"The object does not have a Realm set property with name {propertyName}"),
};
}
public override IDictionary<string, TValue> GetDictionaryValue<TValue>(string propertyName)
{
return propertyName switch
{
"DictionaryNullableObject" => (IDictionary<string, TValue>)DictionaryNullableObject,
_ => throw new MissingMemberException($"The object does not have a Realm dictionary property with name {propertyName}"),
};
}
}
[EditorBrowsable(EditorBrowsableState.Never), Realms.Preserve(AllMembers = true)]
private class NullableClassSerializer : Realms.Serialization.RealmObjectSerializer<NullableClass>
{
protected override void SerializeValue(MongoDB.Bson.Serialization.BsonSerializationContext context, BsonSerializationArgs args, NullableClass value)
{
context.Writer.WriteStartDocument();
WriteValue(context, args, "NonNullableInt", value.NonNullableInt);
WriteValue(context, args, "NullableInt", value.NullableInt);
WriteValue(context, args, "NonNullableString", value.NonNullableString);
WriteValue(context, args, "NullableString", value.NullableString);
WriteValue(context, args, "NonNullableData", value.NonNullableData);
WriteValue(context, args, "NullableData", value.NullableData);
WriteList(context, args, "CollectionOfNullableInt", value.CollectionOfNullableInt);
WriteList(context, args, "CollectionOfNonNullableInt", value.CollectionOfNonNullableInt);
WriteList(context, args, "CollectionOfNullableString", value.CollectionOfNullableString);
WriteList(context, args, "CollectionOfNonNullableString", value.CollectionOfNonNullableString);
WriteValue(context, args, "NonNullableRealmInt", value.NonNullableRealmInt);
WriteValue(context, args, "NullableRealmInt", value.NullableRealmInt);
WriteValue(context, args, "NullableObject", value.NullableObject);
WriteList(context, args, "ListNonNullabeObject", value.ListNonNullabeObject);
WriteSet(context, args, "SetNonNullableObject", value.SetNonNullableObject);
WriteDictionary(context, args, "DictionaryNullableObject", value.DictionaryNullableObject);
WriteValue(context, args, "NonNullableRealmValue", value.NonNullableRealmValue);
context.Writer.WriteEndDocument();
}
protected override NullableClass CreateInstance() => new NullableClass();
protected override void ReadValue(NullableClass instance, string name, BsonDeserializationContext context)
{
switch (name)
{
case "NonNullableInt":
instance.NonNullableInt = BsonSerializer.LookupSerializer<int>().Deserialize(context);
break;
case "NullableInt":
instance.NullableInt = BsonSerializer.LookupSerializer<int?>().Deserialize(context);
break;
case "NonNullableString":
instance.NonNullableString = BsonSerializer.LookupSerializer<string>().Deserialize(context);
break;
case "NullableString":
instance.NullableString = BsonSerializer.LookupSerializer<string?>().Deserialize(context);
break;
case "NonNullableData":
instance.NonNullableData = BsonSerializer.LookupSerializer<byte[]>().Deserialize(context);
break;
case "NullableData":
instance.NullableData = BsonSerializer.LookupSerializer<byte[]?>().Deserialize(context);
break;
case "NonNullableRealmInt":
instance.NonNullableRealmInt = BsonSerializer.LookupSerializer<Realms.RealmInteger<int>>().Deserialize(context);
break;
case "NullableRealmInt":
instance.NullableRealmInt = BsonSerializer.LookupSerializer<Realms.RealmInteger<int>?>().Deserialize(context);
break;
case "NullableObject":
instance.NullableObject = LookupSerializer<SourceGeneratorAssemblyToProcess.NullableClass?>()!.DeserializeById(context);
break;
case "NonNullableRealmValue":
instance.NonNullableRealmValue = BsonSerializer.LookupSerializer<Realms.RealmValue>().Deserialize(context);
break;
}
}
protected override void ReadArrayElement(NullableClass instance, string name, BsonDeserializationContext context)
{
switch (name)
{
case "CollectionOfNullableInt":
instance.CollectionOfNullableInt.Add(BsonSerializer.LookupSerializer<int?>().Deserialize(context));
break;
case "CollectionOfNonNullableInt":
instance.CollectionOfNonNullableInt.Add(BsonSerializer.LookupSerializer<int>().Deserialize(context));
break;
case "CollectionOfNullableString":
instance.CollectionOfNullableString.Add(BsonSerializer.LookupSerializer<string?>().Deserialize(context));
break;
case "CollectionOfNonNullableString":
instance.CollectionOfNonNullableString.Add(BsonSerializer.LookupSerializer<string>().Deserialize(context));
break;
case "ListNonNullabeObject":
instance.ListNonNullabeObject.Add(LookupSerializer<SourceGeneratorAssemblyToProcess.NullableClass>()!.DeserializeById(context)!);
break;
case "SetNonNullableObject":
instance.SetNonNullableObject.Add(LookupSerializer<SourceGeneratorAssemblyToProcess.NullableClass>()!.DeserializeById(context)!);
break;
}
}
protected override void ReadDocumentField(NullableClass instance, string name, string fieldName, BsonDeserializationContext context)
{
switch (name)
{
case "DictionaryNullableObject":
- instance.DictionaryNullableObject[fieldName] = LookupSerializer<SourceGeneratorAssemblyToProcess.NullableClass?>()!.DeserializeById(context)!;
- break;
+ instance.DictionaryNullableObject[fieldName] = LookupSerializer<SourceGeneratorAssemblyToProcess.NullableClass?>()!.DeserializeById(context)!;
+ break;
}
}
}
}
}
|
Tests.Unity.Realm.Tests.dll.Realms.Tests.Database.RealmObjectTests. ► Realms.Tests.Database.RealmObjectTests ► FrozenObject_GetsGarbageCollected:
No path available#L-1
Failed test found in:
TestResults.xml
Error:
Realms.Exceptions.RealmInUseException : Cannot delete files of an open Realm: 'C:\Users\runneradmin\AppData\LocalLow\DefaultCompany\Tests_Unity\dce42d36-c8b2-45b9-a334-9667469fd4e6' is still in use.
|
Realm.Tests.dll.Realms.Tests.Sync.AsymmetricObjectTests. ► Realms.Tests.Sync.AsymmetricObjectTests ► AddCollectionOfAsymmetricObjs:
No path available#L-1
Failed test found in:
TestResults.Linux.xml
Error:
Expected: 4
But was: 0
|
Realm.Tests.dll.Realms.Tests.Sync.AsymmetricObjectTests. ► Realms.Tests.Sync.AsymmetricObjectTests ► AddHugeAsymmetricObj:
No path available#L-1
Failed test found in:
TestResults.Linux.xml
Error:
Expected: 1
But was: 0
|
Realm.Tests.dll.Realms.Tests.Sync.AsymmetricObjectTests.SetAndRemotelyReadValue. ► Realms.Tests.Sync.AsymmetricObjectTests ► SetAndRemotelyReadValue("CharProperty",'0'):
No path available#L-1
Failed test found in:
TestResults.Linux.xml
Error:
Expected: 1
But was: 0
|
Realm.Tests.dll.Realms.Tests.Sync.AsymmetricObjectTests.SetAndRemotelyReadValue. ► Realms.Tests.Sync.AsymmetricObjectTests ► SetAndRemotelyReadValue("ByteProperty",100):
No path available#L-1
Failed test found in:
TestResults.Linux.xml
Error:
Expected: 1
But was: 0
|
Realm.Tests.dll.Realms.Tests.Sync.AsymmetricObjectTests.SetAndRemotelyReadValue. ► Realms.Tests.Sync.AsymmetricObjectTests ► SetAndRemotelyReadValue("Int16Property",100):
No path available#L-1
Failed test found in:
TestResults.Linux.xml
Error:
Expected: 1
But was: 0
|
Realm.Tests.dll.Realms.Tests.Sync.AsymmetricObjectTests.SetAndRemotelyReadValue. ► Realms.Tests.Sync.AsymmetricObjectTests ► SetAndRemotelyReadValue("Int32Property",100):
No path available#L-1
Failed test found in:
TestResults.Linux.xml
Error:
Expected: 1
But was: 0
|
Realm.Tests.dll.Realms.Tests.Sync.AsymmetricObjectTests.SetAndRemotelyReadValue. ► Realms.Tests.Sync.AsymmetricObjectTests ► SetAndRemotelyReadValue("Int64Property",100L):
No path available#L-1
Failed test found in:
TestResults.Linux.xml
Error:
Expected: 1
But was: 0
|
Realm.Tests.dll.Realms.Tests.Sync.AsymmetricObjectTests.SetAndRemotelyReadValue. ► Realms.Tests.Sync.AsymmetricObjectTests ► SetAndRemotelyReadValue("SingleProperty",123.123f):
No path available#L-1
Failed test found in:
TestResults.Linux.xml
Error:
Expected: 1
But was: 0
|
Realm.Tests.dll.Realms.Tests.Sync.AsymmetricObjectTests.SetAndRemotelyReadValue. ► Realms.Tests.Sync.AsymmetricObjectTests ► SetAndRemotelyReadValue("DoubleProperty",123.123d):
No path available#L-1
Failed test found in:
TestResults.Linux.xml
Error:
Expected: 1
But was: 0
|
Realm.Tests.dll.Realms.Tests.Sync.AsymmetricObjectTests.SetAndRemotelyReadValue. ► Realms.Tests.Sync.AsymmetricObjectTests ► SetAndRemotelyReadValue("BooleanProperty",True):
No path available#L-1
Failed test found in:
TestResults.Linux.xml
Error:
Expected: 1
But was: 0
|
Realm.Tests.dll.Realms.Tests.Sync.AsymmetricObjectTests.SetAndRemotelyReadValue. ► Realms.Tests.Sync.AsymmetricObjectTests ► SetAndRemotelyReadValue("ByteArrayProperty",[222, 173, 190, 239]):
No path available#L-1
Failed test found in:
TestResults.Linux.xml
Error:
Expected: 1
But was: 0
|
Tests/Realm.Tests/Sync/MongoClientTests.cs#L2278
TODO entry doesn't have a link to Github issue or Jira ticket
this should be provided by Sync
|
Tests/Realm.Tests/TestHelpers.cs#L430
TODO entry doesn't have a link to Github issue or Jira ticket
handle collections
|
Tests/Realm.Tests/TestHelpers.cs#L441
TODO entry doesn't have a link to Github issue or Jira ticket
handle objects
|
changelog
The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
|