From 1848abe7d57e32207db9535c9c83d96dbda64ced Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 14 Apr 2018 20:14:31 -0400 Subject: don't warn for NetCollection conversion to implemented interface (#471) --- .../Mock/Netcode/NetCollection.cs | 10 ++++++++++ .../Mock/StardewValley/Farmer.cs | 7 ------- .../Mock/StardewValley/Item.cs | 9 +++++++++ 3 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetCollection.cs (limited to 'src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock') diff --git a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetCollection.cs b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetCollection.cs new file mode 100644 index 00000000..d160610e --- /dev/null +++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/Netcode/NetCollection.cs @@ -0,0 +1,10 @@ +// ReSharper disable CheckNamespace -- matches Stardew Valley's code +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; + +namespace Netcode +{ + /// A simplified version of Stardew Valley's Netcode.NetCollection for unit testing. + public class NetCollection : Collection, IList, ICollection, IEnumerable, IEnumerable { } +} diff --git a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Farmer.cs b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Farmer.cs index 54e91682..13fab069 100644 --- a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Farmer.cs +++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Farmer.cs @@ -1,7 +1,6 @@ // ReSharper disable CheckNamespace, InconsistentNaming -- matches Stardew Valley's code #pragma warning disable 649 // (never assigned) -- only used to test type conversions using System.Collections.Generic; -using Netcode; namespace StardewValley { @@ -10,11 +9,5 @@ namespace StardewValley { /// A sample field which should be replaced with a different property. public readonly IDictionary friendships; - - /// A sample net list. - public readonly NetList eventsSeen; - - /// A sample net object list. - public readonly NetObjectList netObjectList; } } diff --git a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Item.cs b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Item.cs index 386767d7..1b6317c1 100644 --- a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Item.cs +++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Mock/StardewValley/Item.cs @@ -20,5 +20,14 @@ namespace StardewValley /// A generic net ref property with no equivalent non-net property. public NetRef netRefProperty { get; } = new NetRef(); + + /// A sample net list. + public readonly NetList netList = new NetList(); + + /// A sample net object list. + public readonly NetObjectList netObjectList = new NetObjectList(); + + /// A sample net collection. + public readonly NetCollection netCollection = new NetCollection(); } } -- cgit