private IEnumerable <FieldInfo> FindAllTweakables()
 {
     foreach (Type type in GenTypes.AllTypes)
     {
         foreach (FieldInfo field in type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))
         {
             TweakValue tv = field.TryGetAttribute <TweakValue>();
             if (tv != null)
             {
                 if (!field.IsStatic)
                 {
                     Log.Error(string.Format("Field {0}.{1} is marked with TweakValue, but isn't static; TweakValue won't work", field.DeclaringType.FullName, field.Name), false);
                 }
                 else if (field.IsLiteral)
                 {
                     Log.Error(string.Format("Field {0}.{1} is marked with TweakValue, but is const; TweakValue won't work", field.DeclaringType.FullName, field.Name), false);
                 }
                 else if (field.IsInitOnly)
                 {
                     Log.Error(string.Format("Field {0}.{1} is marked with TweakValue, but is readonly; TweakValue won't work", field.DeclaringType.FullName, field.Name), false);
                 }
                 else
                 {
                     yield return(field);
                 }
             }
         }
     }
     yield break;
 }
Пример #2
0
        private IEnumerable <FieldInfo> FindAllTweakables()
        {
            foreach (Type allType in GenTypes.AllTypes)
            {
                FieldInfo[] fields = allType.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
                foreach (FieldInfo field in fields)
                {
                    TweakValue tv = field.TryGetAttribute <TweakValue>();
                    if (tv != null)
                    {
                        if (!field.IsStatic)
                        {
                            Log.Error($"Field {field.DeclaringType.FullName}.{field.Name} is marked with TweakValue, but isn't static; TweakValue won't work");
                        }
                        else if (field.IsLiteral)
                        {
                            Log.Error($"Field {field.DeclaringType.FullName}.{field.Name} is marked with TweakValue, but is const; TweakValue won't work");
                        }
                        else
                        {
                            if (!field.IsInitOnly)
                            {
                                yield return(field);

                                /*Error: Unable to find new state assignment for yield return*/;
                            }
                            Log.Error($"Field {field.DeclaringType.FullName}.{field.Name} is marked with TweakValue, but is readonly; TweakValue won't work");
                        }
                    }
                }
            }
            yield break;
IL_01e2:
            /*Error near IL_01e3: Unexpected return in MoveNext()*/;
        }