From 7c1327e4ce37276f1326c0f236aca29d5f05b1ac Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Sat, 24 Aug 2024 00:31:11 +0300 Subject: [PATCH] Fix a warning and Unity build (#3663) --- Realm/Realm/Logging/Logger.cs | 2 ++ Tests/Realm.Tests/Sync/DataTypeSynchronizationTests.cs | 5 +++-- Tests/Realm.Tests/Sync/SynchronizedInstanceTests.cs | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Realm/Realm/Logging/Logger.cs b/Realm/Realm/Logging/Logger.cs index da28f9a331..de3d7648e5 100644 --- a/Realm/Realm/Logging/Logger.cs +++ b/Realm/Realm/Logging/Logger.cs @@ -18,6 +18,7 @@ using System; using System.Collections.Concurrent; +using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; using System.Text; using System.Threading; @@ -49,6 +50,7 @@ protected override void LogImpl(LogLevel level, LogCategory category, string mes /// A few built-in implementations are provided by , , and , /// but you can implement your own. /// + [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Original logger is deprecated")] public abstract class RealmLogger { private readonly Lazy _gcHandle; diff --git a/Tests/Realm.Tests/Sync/DataTypeSynchronizationTests.cs b/Tests/Realm.Tests/Sync/DataTypeSynchronizationTests.cs index 310af261d8..bb7418e6d9 100644 --- a/Tests/Realm.Tests/Sync/DataTypeSynchronizationTests.cs +++ b/Tests/Realm.Tests/Sync/DataTypeSynchronizationTests.cs @@ -902,14 +902,15 @@ public void NestedCollections_Merge() var list2 = obj1.RealmValueProperty.AsDictionary()["list"].AsList(); var dictionary2 = obj1.RealmValueProperty.AsDictionary()["dictionary"].AsDictionary(); - Assert.That(list1, Does.Not.Contain((RealmValue)1)); + Assert.That(list1, Does.Not.Contains((RealmValue)1)); Assert.That(list1, Contains.Item((RealmValue)2)); Assert.That(list1, Contains.Item((RealmValue)3)); Assert.That(list1, Contains.Item((RealmValue)4)); Assert.That(list1, Contains.Item((RealmValue)5)); Assert.That(list1, Is.EqualTo(list2).Using(_rvComparer)); - Assert.That(dictionary1, Does.Not.ContainKey("key1")); + // Unity Nunit doesn't support Does.Not.ContainKey, so use a more simplistic expression here + Assert.That(dictionary1.ContainsKey("key1"), Is.False); Assert.That(dictionary1, Contains.Key("key2")); Assert.That(dictionary1, Contains.Key("key3")); Assert.That(dictionary1, Is.EqualTo(dictionary2).Using(_rvComparer)); diff --git a/Tests/Realm.Tests/Sync/SynchronizedInstanceTests.cs b/Tests/Realm.Tests/Sync/SynchronizedInstanceTests.cs index c2bd1259a6..df4a678202 100644 --- a/Tests/Realm.Tests/Sync/SynchronizedInstanceTests.cs +++ b/Tests/Realm.Tests/Sync/SynchronizedInstanceTests.cs @@ -803,7 +803,7 @@ public void SyncLogger_WhenLevelChanges_LogsAtNewLevel() } var regex = new Regex("Connection\\[\\d+] Session\\[\\d+]"); - var logger = RealmLogger.Function((level, msg) => + var logger = RealmLogger.Function((level, _, msg) => { if (regex.IsMatch(msg)) {