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) --- src/SMAPI.ModBuildConfig.Analyzer/NetFieldAnalyzer.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/SMAPI.ModBuildConfig.Analyzer') diff --git a/src/SMAPI.ModBuildConfig.Analyzer/NetFieldAnalyzer.cs b/src/SMAPI.ModBuildConfig.Analyzer/NetFieldAnalyzer.cs index 7c8b804e..72d3bbf8 100644 --- a/src/SMAPI.ModBuildConfig.Analyzer/NetFieldAnalyzer.cs +++ b/src/SMAPI.ModBuildConfig.Analyzer/NetFieldAnalyzer.cs @@ -22,6 +22,9 @@ namespace StardewModdingAPI.ModBuildConfig.Analyzer /// The full name for Stardew Valley's Netcode.NetList type. private readonly string NetListTypeFullName = "Netcode.NetList"; + /// The full name for Stardew Valley's Netcode.NetCollection type. + private readonly string NetCollectionTypeFullName = "Netcode.NetCollection"; + /// Maps net fields to their equivalent non-net properties where available. private readonly IDictionary NetFieldWrapperProperties = new Dictionary { @@ -232,6 +235,14 @@ namespace StardewModdingAPI.ModBuildConfig.Analyzer return false; } + // collection conversion to an implemented interface is OK + if (AnalyzerUtilities.GetConcreteTypes(typeInfo.Type).Any(p => p.ToString().StartsWith(this.NetCollectionTypeFullName))) // StartsWith to ignore generics + { + string toType = typeInfo.ConvertedType.ToString(); + if (toType.StartsWith(typeof(IEnumerable<>).Namespace) || toType == typeof(IEnumerable).FullName) + return false; + } + // avoid any other conversions return true; } -- cgit