summaryrefslogtreecommitdiff
path: root/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-04-12 20:52:01 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-04-12 20:52:01 -0400
commit5f7a92a74592a53529890eebb1ee9fe519afd92f (patch)
tree67c515794b8dcc7d4721adc3b2f239edd68f9009 /src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock
parentc3851ae2e6c8fb286d4744612fbfea039d1baf7f (diff)
downloadSMAPI-5f7a92a74592a53529890eebb1ee9fe519afd92f.tar.gz
SMAPI-5f7a92a74592a53529890eebb1ee9fe519afd92f.tar.bz2
SMAPI-5f7a92a74592a53529890eebb1ee9fe519afd92f.zip
enable nullable annotations in unit tests (#837)
Diffstat (limited to 'src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock')
-rw-r--r--src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetCollection.cs6
-rw-r--r--src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetFieldBase.cs9
-rw-r--r--src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetInt.cs2
-rw-r--r--src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetList.cs5
-rw-r--r--src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetObjectList.cs2
-rw-r--r--src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Farmer.cs6
-rw-r--r--src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Item.cs3
-rw-r--r--src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Object.cs2
8 files changed, 10 insertions, 25 deletions
diff --git a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetCollection.cs b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetCollection.cs
index 54aa1c6c..8bedd583 100644
--- a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetCollection.cs
+++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetCollection.cs
@@ -1,12 +1,8 @@
-#nullable disable
-
// ReSharper disable CheckNamespace -- matches Stardew Valley's code
-using System.Collections;
-using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace Netcode
{
/// <summary>A simplified version of Stardew Valley's <c>Netcode.NetCollection</c> for unit testing.</summary>
- public class NetCollection<T> : Collection<T>, IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable { }
+ public class NetCollection<T> : Collection<T> { }
}
diff --git a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetFieldBase.cs b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetFieldBase.cs
index 1c349a0b..8f6b8987 100644
--- a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetFieldBase.cs
+++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetFieldBase.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
// ReSharper disable CheckNamespace -- matches Stardew Valley's code
namespace Netcode
{
@@ -9,10 +7,13 @@ namespace Netcode
public class NetFieldBase<T, TSelf> where TSelf : NetFieldBase<T, TSelf>
{
/// <summary>The synchronised value.</summary>
- public T Value { get; set; }
+ public T? Value { get; set; }
/// <summary>Implicitly convert a net field to the its type.</summary>
/// <param name="field">The field to convert.</param>
- public static implicit operator T(NetFieldBase<T, TSelf> field) => field.Value;
+ public static implicit operator T?(NetFieldBase<T, TSelf> field)
+ {
+ return field.Value;
+ }
}
}
diff --git a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetInt.cs b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetInt.cs
index e8e1dc63..b3abc467 100644
--- a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetInt.cs
+++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetInt.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
// ReSharper disable CheckNamespace -- matches Stardew Valley's code
namespace Netcode
{
diff --git a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetList.cs b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetList.cs
index f7fb9617..33e616fb 100644
--- a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetList.cs
+++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetList.cs
@@ -1,11 +1,8 @@
-#nullable disable
-
// ReSharper disable CheckNamespace -- matches Stardew Valley's code
-using System.Collections;
using System.Collections.Generic;
namespace Netcode
{
/// <summary>A simplified version of Stardew Valley's <c>Netcode.NetObjectList</c> for unit testing.</summary>
- public class NetList<T> : List<T>, IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable { }
+ public class NetList<T> : List<T> { }
}
diff --git a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetObjectList.cs b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetObjectList.cs
index 74c17843..7814e7d6 100644
--- a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetObjectList.cs
+++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetObjectList.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
// ReSharper disable CheckNamespace -- matches Stardew Valley's code
namespace Netcode
{
diff --git a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Farmer.cs b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Farmer.cs
index bdbf9b45..dbd05792 100644
--- a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Farmer.cs
+++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Farmer.cs
@@ -1,7 +1,5 @@
-#nullable disable
-
// ReSharper disable CheckNamespace, InconsistentNaming -- matches Stardew Valley's code
-#pragma warning disable 649 // (never assigned) -- only used to test type conversions
+// ReSharper disable UnusedMember.Global -- used dynamically for unit tests
using System.Collections.Generic;
namespace StardewValley
@@ -10,6 +8,6 @@ namespace StardewValley
internal class Farmer
{
/// <summary>A sample field which should be replaced with a different property.</summary>
- public readonly IDictionary<string, int[]> friendships;
+ public readonly IDictionary<string, int[]> friendships = new Dictionary<string, int[]>();
}
}
diff --git a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Item.cs b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Item.cs
index d1f0afc4..d50deb72 100644
--- a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Item.cs
+++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Item.cs
@@ -1,6 +1,5 @@
-#nullable disable
-
// ReSharper disable CheckNamespace, InconsistentNaming -- matches Stardew Valley's code
+// ReSharper disable UnusedMember.Global -- used dynamically for unit tests
using Netcode;
namespace StardewValley
diff --git a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Object.cs b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Object.cs
index f54b22fe..151010a7 100644
--- a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Object.cs
+++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Object.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
// ReSharper disable CheckNamespace, InconsistentNaming -- matches Stardew Valley's code
using Netcode;