diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-04-14 20:14:31 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-04-14 20:14:31 -0400 |
commit | 1848abe7d57e32207db9535c9c83d96dbda64ced (patch) | |
tree | 64d4137e14e7fe7c09584289d5b5581fc34749ff /src/SMAPI.ModBuildConfig.Analyzer | |
parent | 6d8cf614a24ab69baffa89c351b9a22776741442 (diff) | |
download | SMAPI-1848abe7d57e32207db9535c9c83d96dbda64ced.tar.gz SMAPI-1848abe7d57e32207db9535c9c83d96dbda64ced.tar.bz2 SMAPI-1848abe7d57e32207db9535c9c83d96dbda64ced.zip |
don't warn for NetCollection conversion to implemented interface (#471)
Diffstat (limited to 'src/SMAPI.ModBuildConfig.Analyzer')
-rw-r--r-- | src/SMAPI.ModBuildConfig.Analyzer/NetFieldAnalyzer.cs | 11 |
1 files changed, 11 insertions, 0 deletions
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 /// <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> { @@ -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; } |