diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-05-01 18:16:09 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-05-01 18:16:09 -0400 |
commit | c8ad50dad1d706a1901798f9396f6becfea36c0e (patch) | |
tree | 28bd818a5db39ec5ece1bd141a28de955950463b /src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock | |
parent | 451b70953ff4c0b1b27ae0de203ad99379b45b2a (diff) | |
parent | f78093bdb58d477b400cde3f19b70ffd6ddf833d (diff) | |
download | SMAPI-c8ad50dad1d706a1901798f9396f6becfea36c0e.tar.gz SMAPI-c8ad50dad1d706a1901798f9396f6becfea36c0e.tar.bz2 SMAPI-c8ad50dad1d706a1901798f9396f6becfea36c0e.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock')
6 files changed, 19 insertions, 18 deletions
diff --git a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetCollection.cs b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetCollection.cs index d160610e..8bedd583 100644 --- a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetCollection.cs +++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetCollection.cs @@ -1,10 +1,8 @@ // 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 140c6f59..8f6b8987 100644 --- a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetFieldBase.cs +++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetFieldBase.cs @@ -7,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/NetList.cs b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetList.cs index 1699f71c..33e616fb 100644 --- a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetList.cs +++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetList.cs @@ -1,9 +1,8 @@ // 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/StardewValley/Farmer.cs b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Farmer.cs index 13fab069..dbd05792 100644 --- a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Farmer.cs +++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Farmer.cs @@ -1,5 +1,5 @@ // 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 @@ -8,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 1b6317c1..d50deb72 100644 --- a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Item.cs +++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Item.cs @@ -1,4 +1,5 @@ // ReSharper disable CheckNamespace, InconsistentNaming -- matches Stardew Valley's code +// ReSharper disable UnusedMember.Global -- used dynamically for unit tests using Netcode; namespace StardewValley @@ -7,27 +8,27 @@ namespace StardewValley public class Item { /// <summary>A net int field with an equivalent non-net <c>Category</c> property.</summary> - public readonly NetInt category = new NetInt { Value = 42 }; + public readonly NetInt category = new() { Value = 42 }; /// <summary>A generic net int field with no equivalent non-net property.</summary> - public readonly NetInt netIntField = new NetInt { Value = 42 }; + public readonly NetInt netIntField = new() { Value = 42 }; /// <summary>A generic net ref field with no equivalent non-net property.</summary> - public readonly NetRef<object> netRefField = new NetRef<object>(); + public readonly NetRef<object> netRefField = new(); /// <summary>A generic net int property with no equivalent non-net property.</summary> - public NetInt netIntProperty = new NetInt { Value = 42 }; + public NetInt netIntProperty = new() { Value = 42 }; /// <summary>A generic net ref property with no equivalent non-net property.</summary> - public NetRef<object> netRefProperty { get; } = new NetRef<object>(); + public NetRef<object> netRefProperty { get; } = new(); /// <summary>A sample net list.</summary> - public readonly NetList<int> netList = new NetList<int>(); + public readonly NetList<int> netList = new(); /// <summary>A sample net object list.</summary> - public readonly NetObjectList<int> netObjectList = new NetObjectList<int>(); + public readonly NetObjectList<int> netObjectList = new(); /// <summary>A sample net collection.</summary> - public readonly NetCollection<int> netCollection = new NetCollection<int>(); + public readonly NetCollection<int> netCollection = new(); } } diff --git a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Object.cs b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Object.cs index 3dd66a6d..151010a7 100644 --- a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Object.cs +++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Object.cs @@ -7,6 +7,6 @@ namespace StardewValley public class Object : Item { /// <summary>A net int field with an equivalent non-net property.</summary> - public NetInt type = new NetInt { Value = 42 }; + public NetInt type = new() { Value = 42 }; } } |