diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-04-26 23:18:53 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-04-26 23:18:53 -0400 |
commit | 83f89c6ef31b783bd6afa4782df14cbbace0f022 (patch) | |
tree | e8801678efed28a4b5aba3c256f02cffed23f436 /src/SMAPI.ModBuildConfig.Analyzer/NetFieldAnalyzer.cs | |
parent | 5fc706c18267f5ff4cf31fd0e1ab76f1a57e1588 (diff) | |
download | SMAPI-83f89c6ef31b783bd6afa4782df14cbbace0f022.tar.gz SMAPI-83f89c6ef31b783bd6afa4782df14cbbace0f022.tar.bz2 SMAPI-83f89c6ef31b783bd6afa4782df14cbbace0f022.zip |
don't warn when converting net fields to an interface they implement
Diffstat (limited to 'src/SMAPI.ModBuildConfig.Analyzer/NetFieldAnalyzer.cs')
-rw-r--r-- | src/SMAPI.ModBuildConfig.Analyzer/NetFieldAnalyzer.cs | 25 |
1 files changed, 3 insertions, 22 deletions
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 /// <summary>The namespace for Stardew Valley's <c>Netcode</c> types.</summary> private const string NetcodeNamespace = "Netcode"; - /// <summary>The full name for Stardew Valley's <c>Netcode.NetList</c> type.</summary> - private readonly string NetListTypeFullName = "Netcode.NetList"; - - /// <summary>The full name for Stardew Valley's <c>Netcode.NetCollection</c> type.</summary> - private readonly string NetCollectionTypeFullName = "Netcode.NetCollection"; - /// <summary>Maps net fields to their equivalent non-net properties where available.</summary> private readonly IDictionary<string, string> NetFieldWrapperProperties = new Dictionary<string, string> { @@ -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; |