don't warn when converting net fields to an interface they implement
This commit is contained in:
parent
5fc706c182
commit
83f89c6ef3
|
@ -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;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>Pathoschild.Stardew.ModBuildConfig</id>
|
||||
<version>2.1.0-beta</version>
|
||||
<version>2.1.0-beta-20180426</version>
|
||||
<title>Build package for SMAPI mods</title>
|
||||
<authors>Pathoschild</authors>
|
||||
<owners>Pathoschild</owners>
|
||||
|
|
Loading…
Reference in New Issue