More HashSet trait fields & Lint support

This commit is contained in:
atlimit8
2015-09-05 15:54:00 -05:00
parent e74c0d6c13
commit 8250f223c4
57 changed files with 115 additions and 89 deletions

View File

@@ -9,21 +9,24 @@
#endregion
using System;
using System.Collections.Generic;
using System.Reflection;
namespace OpenRA.Mods.Common.Lint
{
public class LintExts
{
public static string[] GetFieldValues(object ruleInfo, FieldInfo fieldInfo, Action<string> emitError)
public static IEnumerable<string> GetFieldValues(object ruleInfo, FieldInfo fieldInfo, Action<string> emitError)
{
var type = fieldInfo.FieldType;
if (type == typeof(string))
return new[] { (string)fieldInfo.GetValue(ruleInfo) };
if (type == typeof(string[]))
return (string[])fieldInfo.GetValue(ruleInfo);
if (type == typeof(HashSet<string>))
return (HashSet<string>)fieldInfo.GetValue(ruleInfo);
emitError("Bad type for reference on {0}.{1}. Supported types: string, string[]"
emitError("Bad type for reference on {0}.{1}. Supported types: string, string[], HashSet<string>"
.F(ruleInfo.GetType().Name, fieldInfo.Name));
return new string[] { };