From 83f89c6ef31b783bd6afa4782df14cbbace0f022 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 26 Apr 2018 23:18:53 -0400 Subject: don't warn when converting net fields to an interface they implement --- .../NetFieldAnalyzer.cs | 25 +++------------------- src/SMAPI.ModBuildConfig/package.nuspec | 2 +- 2 files changed, 4 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/SMAPI.ModBuildConfig.Analyzer/NetFieldAnalyzer.cs b/src/SMAPI.ModBuildConfig.Analyzer/NetFieldAnalyzer.cs index e3c92617..0e9154a1 100644 --- a/src/SMAPI.ModBuildConfig.Analyzer/NetFieldAnalyzer.cs +++ b/src/SMAPI.ModBuildConfig.Analyzer/NetFieldAnalyzer.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; @@ -19,12 +18,6 @@ namespace StardewModdingAPI.ModBuildConfig.Analyzer /// The namespace for Stardew Valley's Netcode types. private const string NetcodeNamespace = "Netcode"; - /// 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 { @@ -226,21 +219,9 @@ namespace StardewModdingAPI.ModBuildConfig.Analyzer if (!this.IsNetType(typeInfo.Type) || this.IsNetType(typeInfo.ConvertedType)) return false; - // list conversion to an implemented interface is OK - if (AnalyzerUtilities.GetConcreteTypes(typeInfo.Type).Any(p => p.ToString().StartsWith(this.NetListTypeFullName))) // StartsWith to ignore generics - { - string toType = typeInfo.ConvertedType.ToString(); - if (toType.StartsWith(typeof(IEnumerable<>).Namespace) || toType == typeof(IEnumerable).FullName) - 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; - } + // conversion to implemented interface is OK + if (typeInfo.Type.AllInterfaces.Contains(typeInfo.ConvertedType)) + return false; // avoid any other conversions return true; diff --git a/src/SMAPI.ModBuildConfig/package.nuspec b/src/SMAPI.ModBuildConfig/package.nuspec index 5e0b479e..6bb7736c 100644 --- a/src/SMAPI.ModBuildConfig/package.nuspec +++ b/src/SMAPI.ModBuildConfig/package.nuspec @@ -2,7 +2,7 @@ Pathoschild.Stardew.ModBuildConfig - 2.1.0-beta + 2.1.0-beta-20180426 Build package for SMAPI mods Pathoschild Pathoschild -- cgit