Cache reflection calls when running utility lints and commands.
Reduces runtime of --check-yaml command to 70% of original.
This commit is contained in:
committed by
Matthias Mailänder
parent
1a2aafa17c
commit
9dd4f938da
@@ -45,21 +45,16 @@ namespace OpenRA
|
|||||||
return a.GetTypes().Select(t => t.Namespace).Distinct().Where(n => n != null);
|
return a.GetTypes().Select(t => t.Namespace).Distinct().Where(n => n != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool HasAttribute<T>(this MemberInfo mi)
|
public static bool HasAttribute<TAttribute>(this MemberInfo mi)
|
||||||
|
where TAttribute : Attribute
|
||||||
{
|
{
|
||||||
return Attribute.IsDefined(mi, typeof(T));
|
return Attribute.IsDefined(mi, typeof(TAttribute));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T[] GetCustomAttributes<T>(this MemberInfo mi, bool inherit)
|
public static TAttribute[] GetCustomAttributes<TAttribute>(this MemberInfo mi, bool inherit)
|
||||||
where T : class
|
where TAttribute : Attribute
|
||||||
{
|
{
|
||||||
return (T[])mi.GetCustomAttributes(typeof(T), inherit);
|
return (TAttribute[])mi.GetCustomAttributes(typeof(TAttribute), inherit);
|
||||||
}
|
|
||||||
|
|
||||||
public static T[] GetCustomAttributes<T>(this ParameterInfo mi)
|
|
||||||
where T : class
|
|
||||||
{
|
|
||||||
return (T[])mi.GetCustomAttributes(typeof(T), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T Clamp<T>(this T val, T min, T max) where T : IComparable<T>
|
public static T Clamp<T>(this T val, T min, T max) where T : IComparable<T>
|
||||||
|
|||||||
@@ -9,12 +9,43 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA
|
namespace OpenRA
|
||||||
{
|
{
|
||||||
public class Utility
|
public class Utility
|
||||||
{
|
{
|
||||||
|
static readonly ConcurrentCache<Type, FieldInfo[]> TypeFields =
|
||||||
|
new ConcurrentCache<Type, FieldInfo[]>(type => type.GetFields());
|
||||||
|
|
||||||
|
static readonly ConcurrentCache<(MemberInfo Member, Type AttributeType), bool> MemberHasAttribute =
|
||||||
|
new ConcurrentCache<(MemberInfo Member, Type AttributeType), bool>(
|
||||||
|
x => Attribute.IsDefined(x.Member, x.AttributeType));
|
||||||
|
|
||||||
|
static readonly ConcurrentCache<(MemberInfo Member, Type AttributeType, bool Inherit), object[]> MemberCustomAttributes =
|
||||||
|
new ConcurrentCache<(MemberInfo Member, Type AttributeType, bool Inherit), object[]>(
|
||||||
|
x => x.Member.GetCustomAttributes(x.AttributeType, x.Inherit));
|
||||||
|
|
||||||
|
public static FieldInfo[] GetFields(Type type)
|
||||||
|
{
|
||||||
|
return TypeFields[type];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool HasAttribute<TAttribute>(MemberInfo member)
|
||||||
|
where TAttribute : Attribute
|
||||||
|
{
|
||||||
|
return MemberHasAttribute[(member, typeof(TAttribute))];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TAttribute[] GetCustomAttributes<TAttribute>(MemberInfo member, bool inherit)
|
||||||
|
where TAttribute : Attribute
|
||||||
|
{
|
||||||
|
return (TAttribute[])MemberCustomAttributes[(member, typeof(TAttribute), inherit)];
|
||||||
|
}
|
||||||
|
|
||||||
public readonly ModData ModData;
|
public readonly ModData ModData;
|
||||||
public readonly InstalledMods Mods;
|
public readonly InstalledMods Mods;
|
||||||
|
|
||||||
|
|||||||
@@ -39,16 +39,16 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
void CheckTrait(Action<string> emitError, ActorInfo actorInfo, TraitInfo traitInfo, Ruleset rules)
|
void CheckTrait(Action<string> emitError, ActorInfo actorInfo, TraitInfo traitInfo, Ruleset rules)
|
||||||
{
|
{
|
||||||
var actualType = traitInfo.GetType();
|
var actualType = traitInfo.GetType();
|
||||||
foreach (var field in actualType.GetFields())
|
foreach (var field in Utility.GetFields(actualType))
|
||||||
{
|
{
|
||||||
if (field.HasAttribute<ActorReferenceAttribute>())
|
if (Utility.HasAttribute<ActorReferenceAttribute>(field))
|
||||||
CheckActorReference(emitError, actorInfo, traitInfo, field, rules.Actors,
|
CheckActorReference(emitError, actorInfo, traitInfo, field, rules.Actors,
|
||||||
field.GetCustomAttributes<ActorReferenceAttribute>(true)[0]);
|
Utility.GetCustomAttributes<ActorReferenceAttribute>(field, true)[0]);
|
||||||
|
|
||||||
if (field.HasAttribute<WeaponReferenceAttribute>())
|
if (Utility.HasAttribute<WeaponReferenceAttribute>(field))
|
||||||
CheckWeaponReference(emitError, actorInfo, traitInfo, field, rules.Weapons);
|
CheckWeaponReference(emitError, actorInfo, traitInfo, field, rules.Weapons);
|
||||||
|
|
||||||
if (field.HasAttribute<VoiceSetReferenceAttribute>())
|
if (Utility.HasAttribute<VoiceSetReferenceAttribute>(field))
|
||||||
CheckVoiceReference(emitError, actorInfo, traitInfo, field, rules.Voices);
|
CheckVoiceReference(emitError, actorInfo, traitInfo, field, rules.Voices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
|
|
||||||
// Build the list of widget keys to validate
|
// Build the list of widget keys to validate
|
||||||
var checkWidgetFields = modData.ObjectCreator.GetTypesImplementing<Widget>()
|
var checkWidgetFields = modData.ObjectCreator.GetTypesImplementing<Widget>()
|
||||||
.SelectMany(w => w.GetFields()
|
.SelectMany(w => Utility.GetFields(w)
|
||||||
.Where(f => f.FieldType == typeof(HotkeyReference))
|
.Where(f => f.FieldType == typeof(HotkeyReference))
|
||||||
.Select(f => (w.Name.Substring(0, w.Name.Length - 6), f.Name)))
|
.Select(f => (w.Name.Substring(0, w.Name.Length - 6), f.Name)))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
|
|
||||||
foreach (var w in modData.ObjectCreator.GetTypesImplementing<Widget>())
|
foreach (var w in modData.ObjectCreator.GetTypesImplementing<Widget>())
|
||||||
{
|
{
|
||||||
foreach (var m in w.GetMethods().Where(m => m.HasAttribute<CustomLintableHotkeyNames>()))
|
foreach (var m in w.GetMethods().Where(m => Utility.HasAttribute<CustomLintableHotkeyNames>(m)))
|
||||||
{
|
{
|
||||||
var p = m.GetParameters();
|
var p = m.GetParameters();
|
||||||
if (p.Length == 3 && p[0].ParameterType == typeof(MiniYamlNode) && p[1].ParameterType == typeof(Action<string>)
|
if (p.Length == 3 && p[0].ParameterType == typeof(MiniYamlNode) && p[1].ParameterType == typeof(Action<string>)
|
||||||
@@ -104,7 +104,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
if (type == null)
|
if (type == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
checkArgKeys.AddRange(type.GetCustomAttributes<ChromeLogicArgsHotkeys>(true).SelectMany(x => x.LogicArgKeys));
|
checkArgKeys.AddRange(Utility.GetCustomAttributes<ChromeLogicArgsHotkeys>(type, true).SelectMany(x => x.LogicArgKeys));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var n in node.Value.Nodes)
|
foreach (var n in node.Value.Nodes)
|
||||||
|
|||||||
@@ -38,20 +38,23 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
|
|
||||||
foreach (var trait in actorInfo.Value.TraitInfos<TraitInfo>())
|
foreach (var trait in actorInfo.Value.TraitInfos<TraitInfo>())
|
||||||
{
|
{
|
||||||
var fieldConsumed = trait.GetType().GetFields()
|
var fields = Utility.GetFields(trait.GetType());
|
||||||
.Where(x => x.HasAttribute<ConsumedConditionReferenceAttribute>())
|
var properties = trait.GetType().GetProperties();
|
||||||
|
|
||||||
|
var fieldConsumed = fields
|
||||||
|
.Where(x => Utility.HasAttribute<ConsumedConditionReferenceAttribute>(x))
|
||||||
.SelectMany(f => LintExts.GetFieldValues(trait, f));
|
.SelectMany(f => LintExts.GetFieldValues(trait, f));
|
||||||
|
|
||||||
var propertyConsumed = trait.GetType().GetProperties()
|
var propertyConsumed = properties
|
||||||
.Where(x => x.HasAttribute<ConsumedConditionReferenceAttribute>())
|
.Where(x => Utility.HasAttribute<ConsumedConditionReferenceAttribute>(x))
|
||||||
.SelectMany(p => LintExts.GetPropertyValues(trait, p));
|
.SelectMany(p => LintExts.GetPropertyValues(trait, p));
|
||||||
|
|
||||||
var fieldGranted = trait.GetType().GetFields()
|
var fieldGranted = fields
|
||||||
.Where(x => x.HasAttribute<GrantedConditionReferenceAttribute>())
|
.Where(x => Utility.HasAttribute<GrantedConditionReferenceAttribute>(x))
|
||||||
.SelectMany(f => LintExts.GetFieldValues(trait, f));
|
.SelectMany(f => LintExts.GetFieldValues(trait, f));
|
||||||
|
|
||||||
var propertyGranted = trait.GetType().GetProperties()
|
var propertyGranted = properties
|
||||||
.Where(x => x.HasAttribute<GrantedConditionReferenceAttribute>())
|
.Where(x => Utility.HasAttribute<GrantedConditionReferenceAttribute>(x))
|
||||||
.SelectMany(f => LintExts.GetPropertyValues(trait, f));
|
.SelectMany(f => LintExts.GetPropertyValues(trait, f));
|
||||||
|
|
||||||
foreach (var c in fieldConsumed.Concat(propertyConsumed))
|
foreach (var c in fieldConsumed.Concat(propertyConsumed))
|
||||||
|
|||||||
@@ -45,10 +45,10 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
{
|
{
|
||||||
foreach (var traitInfo in actorInfo.Value.TraitInfos<TraitInfo>())
|
foreach (var traitInfo in actorInfo.Value.TraitInfos<TraitInfo>())
|
||||||
{
|
{
|
||||||
var fields = traitInfo.GetType().GetFields();
|
var fields = Utility.GetFields(traitInfo.GetType());
|
||||||
foreach (var field in fields)
|
foreach (var field in fields)
|
||||||
{
|
{
|
||||||
var cursorReference = field.GetCustomAttributes<CursorReferenceAttribute>(true).FirstOrDefault();
|
var cursorReference = Utility.GetCustomAttributes<CursorReferenceAttribute>(field, true).FirstOrDefault();
|
||||||
if (cursorReference == null)
|
if (cursorReference == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
{
|
{
|
||||||
foreach (var traitInfo in actorInfo.Value.TraitInfos<TraitInfo>())
|
foreach (var traitInfo in actorInfo.Value.TraitInfos<TraitInfo>())
|
||||||
{
|
{
|
||||||
var fields = traitInfo.GetType().GetFields().Where(f => f.HasAttribute<LocomotorReferenceAttribute>());
|
var fields = Utility.GetFields(traitInfo.GetType()).Where(f => Utility.HasAttribute<LocomotorReferenceAttribute>(f));
|
||||||
foreach (var field in fields)
|
foreach (var field in fields)
|
||||||
{
|
{
|
||||||
var locomotors = LintExts.GetFieldValues(traitInfo, field);
|
var locomotors = LintExts.GetFieldValues(traitInfo, field);
|
||||||
|
|||||||
@@ -35,11 +35,11 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
{
|
{
|
||||||
foreach (var traitInfo in actorInfo.Value.TraitInfos<TraitInfo>())
|
foreach (var traitInfo in actorInfo.Value.TraitInfos<TraitInfo>())
|
||||||
{
|
{
|
||||||
var fields = traitInfo.GetType().GetFields();
|
var fields = Utility.GetFields(traitInfo.GetType());
|
||||||
foreach (var field in fields.Where(x => x.HasAttribute<NotificationReferenceAttribute>()))
|
foreach (var field in fields.Where(x => Utility.HasAttribute<NotificationReferenceAttribute>(x)))
|
||||||
{
|
{
|
||||||
string type = null;
|
string type = null;
|
||||||
var notificationReference = field.GetCustomAttributes<NotificationReferenceAttribute>(true).First();
|
var notificationReference = Utility.GetCustomAttributes<NotificationReferenceAttribute>(field, true).First();
|
||||||
if (!string.IsNullOrEmpty(notificationReference.NotificationTypeFieldName))
|
if (!string.IsNullOrEmpty(notificationReference.NotificationTypeFieldName))
|
||||||
{
|
{
|
||||||
var fieldInfo = fields.First(f => f.Name == notificationReference.NotificationTypeFieldName);
|
var fieldInfo = fields.First(f => f.Name == notificationReference.NotificationTypeFieldName);
|
||||||
|
|||||||
@@ -39,10 +39,10 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
{
|
{
|
||||||
foreach (var traitInfo in actorInfo.Value.TraitInfos<TraitInfo>())
|
foreach (var traitInfo in actorInfo.Value.TraitInfos<TraitInfo>())
|
||||||
{
|
{
|
||||||
var fields = traitInfo.GetType().GetFields();
|
var fields = Utility.GetFields(traitInfo.GetType());
|
||||||
foreach (var field in fields)
|
foreach (var field in fields)
|
||||||
{
|
{
|
||||||
var paletteReference = field.GetCustomAttributes<PaletteReferenceAttribute>(true).FirstOrDefault();
|
var paletteReference = Utility.GetCustomAttributes<PaletteReferenceAttribute>(field, true).FirstOrDefault();
|
||||||
if (paletteReference == null)
|
if (paletteReference == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -82,10 +82,10 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
if (projectileInfo == null)
|
if (projectileInfo == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var fields = projectileInfo.GetType().GetFields();
|
var fields = Utility.GetFields(projectileInfo.GetType());
|
||||||
foreach (var field in fields)
|
foreach (var field in fields)
|
||||||
{
|
{
|
||||||
var paletteReference = field.GetCustomAttributes<PaletteReferenceAttribute>(true).FirstOrDefault();
|
var paletteReference = Utility.GetCustomAttributes<PaletteReferenceAttribute>(field, true).FirstOrDefault();
|
||||||
if (paletteReference == null)
|
if (paletteReference == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -126,10 +126,10 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
var tilesetPalettes = new List<(string Tileset, string PaletteName)>();
|
var tilesetPalettes = new List<(string Tileset, string PaletteName)>();
|
||||||
foreach (var traitInfo in worldActorInfo.TraitInfos<TraitInfo>())
|
foreach (var traitInfo in worldActorInfo.TraitInfos<TraitInfo>())
|
||||||
{
|
{
|
||||||
var fields = traitInfo.GetType().GetFields();
|
var fields = Utility.GetFields(traitInfo.GetType());
|
||||||
foreach (var field in fields)
|
foreach (var field in fields)
|
||||||
{
|
{
|
||||||
var paletteDefinition = field.GetCustomAttributes<PaletteDefinitionAttribute>(true).FirstOrDefault();
|
var paletteDefinition = Utility.GetCustomAttributes<PaletteDefinitionAttribute>(field, true).FirstOrDefault();
|
||||||
if (paletteDefinition == null)
|
if (paletteDefinition == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -47,10 +47,10 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
var traitName = traitInfo.GetType().Name;
|
var traitName = traitInfo.GetType().Name;
|
||||||
traitName = traitName.Remove(traitName.Length - 4);
|
traitName = traitName.Remove(traitName.Length - 4);
|
||||||
|
|
||||||
var fields = traitInfo.GetType().GetFields();
|
var fields = Utility.GetFields(traitInfo.GetType());
|
||||||
foreach (var field in fields)
|
foreach (var field in fields)
|
||||||
{
|
{
|
||||||
var sequenceReference = field.GetCustomAttributes<SequenceReferenceAttribute>(true).FirstOrDefault();
|
var sequenceReference = Utility.GetCustomAttributes<SequenceReferenceAttribute>(field, true).FirstOrDefault();
|
||||||
if (sequenceReference == null)
|
if (sequenceReference == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -103,10 +103,10 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
if (projectileInfo == null)
|
if (projectileInfo == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var fields = projectileInfo.GetType().GetFields();
|
var fields = Utility.GetFields(projectileInfo.GetType());
|
||||||
foreach (var field in fields)
|
foreach (var field in fields)
|
||||||
{
|
{
|
||||||
var sequenceReference = field.GetCustomAttributes<SequenceReferenceAttribute>(true).FirstOrDefault();
|
var sequenceReference = Utility.GetCustomAttributes<SequenceReferenceAttribute>(field, true).FirstOrDefault();
|
||||||
if (sequenceReference == null)
|
if (sequenceReference == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
const BindingFlags Flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly;
|
const BindingFlags Flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly;
|
||||||
while (type != null)
|
while (type != null)
|
||||||
{
|
{
|
||||||
if (((MemberInfo[])type.GetFields(Flags)).Concat(type.GetProperties(Flags)).Any(x => x.HasAttribute<SyncAttribute>()))
|
if (((MemberInfo[])type.GetFields(Flags)).Concat(type.GetProperties(Flags)).Any(x => Utility.HasAttribute<SyncAttribute>(x)))
|
||||||
return true;
|
return true;
|
||||||
type = type.BaseType;
|
type = type.BaseType;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
{
|
{
|
||||||
foreach (var traitInfo in actorInfo.Value.TraitInfos<TraitInfo>())
|
foreach (var traitInfo in actorInfo.Value.TraitInfos<TraitInfo>())
|
||||||
{
|
{
|
||||||
var traitLocation = traitInfo.GetType().GetCustomAttributes<TraitLocationAttribute>(true).FirstOrDefault();
|
var traitLocation = Utility.GetCustomAttributes<TraitLocationAttribute>(traitInfo.GetType(), true).FirstOrDefault();
|
||||||
if (traitLocation == null)
|
if (traitLocation == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -39,10 +39,10 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
{
|
{
|
||||||
foreach (var traitInfo in actorInfo.Value.TraitInfos<TraitInfo>())
|
foreach (var traitInfo in actorInfo.Value.TraitInfos<TraitInfo>())
|
||||||
{
|
{
|
||||||
var fields = traitInfo.GetType().GetFields();
|
var fields = Utility.GetFields(traitInfo.GetType());
|
||||||
foreach (var field in fields)
|
foreach (var field in fields)
|
||||||
{
|
{
|
||||||
var translationReference = field.GetCustomAttributes<TranslationReferenceAttribute>(true).FirstOrDefault();
|
var translationReference = Utility.GetCustomAttributes<TranslationReferenceAttribute>(field, true).FirstOrDefault();
|
||||||
if (translationReference == null)
|
if (translationReference == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
|
|
||||||
foreach (var modType in modData.ObjectCreator.GetTypes())
|
foreach (var modType in modData.ObjectCreator.GetTypes())
|
||||||
{
|
{
|
||||||
foreach (var fieldInfo in modType.GetFields(Binding).Where(m => m.HasAttribute<TranslationReferenceAttribute>()))
|
foreach (var fieldInfo in modType.GetFields(Binding).Where(m => Utility.HasAttribute<TranslationReferenceAttribute>(m)))
|
||||||
{
|
{
|
||||||
if (fieldInfo.FieldType != typeof(string))
|
if (fieldInfo.FieldType != typeof(string))
|
||||||
emitError($"Translation attribute on non string field {fieldInfo.Name}.");
|
emitError($"Translation attribute on non string field {fieldInfo.Name}.");
|
||||||
@@ -87,7 +87,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
if (!translation.HasMessage(key))
|
if (!translation.HasMessage(key))
|
||||||
emitError($"{key} not present in {language} translation.");
|
emitError($"{key} not present in {language} translation.");
|
||||||
|
|
||||||
var translationReference = fieldInfo.GetCustomAttributes<TranslationReferenceAttribute>(true)[0];
|
var translationReference = Utility.GetCustomAttributes<TranslationReferenceAttribute>(fieldInfo, true)[0];
|
||||||
if (translationReference.RequiredVariableNames != null && translationReference.RequiredVariableNames.Length > 0)
|
if (translationReference.RequiredVariableNames != null && translationReference.RequiredVariableNames.Length > 0)
|
||||||
referencedVariablesPerKey.GetOrAdd(key, translationReference.RequiredVariableNames);
|
referencedVariablesPerKey.GetOrAdd(key, translationReference.RequiredVariableNames);
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
{
|
{
|
||||||
foreach (var traitInfo in actorInfo.Value.TraitInfos<TraitInfo>())
|
foreach (var traitInfo in actorInfo.Value.TraitInfos<TraitInfo>())
|
||||||
{
|
{
|
||||||
var fields = traitInfo.GetType().GetFields().Where(f => f.HasAttribute<VoiceSetReferenceAttribute>());
|
var fields = Utility.GetFields(traitInfo.GetType()).Where(f => Utility.HasAttribute<VoiceSetReferenceAttribute>(f));
|
||||||
foreach (var field in fields)
|
foreach (var field in fields)
|
||||||
{
|
{
|
||||||
var voiceSets = LintExts.GetFieldValues(traitInfo, field);
|
var voiceSets = LintExts.GetFieldValues(traitInfo, field);
|
||||||
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
|
|
||||||
foreach (var traitInfo in actorInfo.TraitInfos<TraitInfo>())
|
foreach (var traitInfo in actorInfo.TraitInfos<TraitInfo>())
|
||||||
{
|
{
|
||||||
var fields = traitInfo.GetType().GetFields().Where(f => f.HasAttribute<VoiceReferenceAttribute>());
|
var fields = Utility.GetFields(traitInfo.GetType()).Where(f => Utility.HasAttribute<VoiceReferenceAttribute>(f));
|
||||||
foreach (var field in fields)
|
foreach (var field in fields)
|
||||||
{
|
{
|
||||||
var voices = LintExts.GetFieldValues(traitInfo, field);
|
var voices = LintExts.GetFieldValues(traitInfo, field);
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
var interfaces = implementingType.GetInterfaces();
|
var interfaces = implementingType.GetInterfaces();
|
||||||
foreach (var interfaceType in interfaces)
|
foreach (var interfaceType in interfaces)
|
||||||
{
|
{
|
||||||
if (!interfaceType.HasAttribute<RequireExplicitImplementationAttribute>())
|
if (!Utility.HasAttribute<RequireExplicitImplementationAttribute>(interfaceType))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var interfaceMembers = interfaceType.GetMembers();
|
var interfaceMembers = interfaceType.GetMembers();
|
||||||
|
|||||||
@@ -41,10 +41,10 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
sections.Add("Launch", new LaunchArguments(new Arguments(Array.Empty<string>())));
|
sections.Add("Launch", new LaunchArguments(new Arguments(Array.Empty<string>())));
|
||||||
foreach (var section in sections.OrderBy(s => s.Key))
|
foreach (var section in sections.OrderBy(s => s.Key))
|
||||||
{
|
{
|
||||||
var fields = section.Value.GetType().GetFields();
|
var fields = Utility.GetFields(section.Value.GetType());
|
||||||
foreach (var field in fields)
|
foreach (var field in fields)
|
||||||
{
|
{
|
||||||
if (!field.HasAttribute<DescAttribute>())
|
if (!Utility.HasAttribute<DescAttribute>(field))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Console.WriteLine(".TP");
|
Console.WriteLine(".TP");
|
||||||
@@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
else
|
else
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
|
|
||||||
var lines = field.GetCustomAttributes<DescAttribute>(false).SelectMany(d => d.Lines);
|
var lines = Utility.GetCustomAttributes<DescAttribute>(field, false).SelectMany(d => d.Lines);
|
||||||
foreach (var line in lines)
|
foreach (var line in lines)
|
||||||
Console.WriteLine(line);
|
Console.WriteLine(line);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
{
|
{
|
||||||
foreach (var t in globalTables)
|
foreach (var t in globalTables)
|
||||||
{
|
{
|
||||||
var name = t.GetCustomAttributes<ScriptGlobalAttribute>(true).First().Name;
|
var name = Utility.GetCustomAttributes<ScriptGlobalAttribute>(t, true).First().Name;
|
||||||
Console.WriteLine("---Global variable provided by the game scripting engine.");
|
Console.WriteLine("---Global variable provided by the game scripting engine.");
|
||||||
|
|
||||||
foreach (var obsolete in t.GetCustomAttributes(false).OfType<ObsoleteAttribute>())
|
foreach (var obsolete in t.GetCustomAttributes(false).OfType<ObsoleteAttribute>())
|
||||||
@@ -191,9 +191,9 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
|
|
||||||
var body = "";
|
var body = "";
|
||||||
|
|
||||||
if (member.HasAttribute<DescAttribute>())
|
if (Utility.HasAttribute<DescAttribute>(member))
|
||||||
{
|
{
|
||||||
var lines = member.GetCustomAttributes<DescAttribute>(true).First().Lines;
|
var lines = Utility.GetCustomAttributes<DescAttribute>(member, true).First().Lines;
|
||||||
foreach (var line in lines)
|
foreach (var line in lines)
|
||||||
Console.WriteLine($" --- {line}");
|
Console.WriteLine($" --- {line}");
|
||||||
}
|
}
|
||||||
@@ -258,11 +258,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
{
|
{
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
|
|
||||||
var isActivity = memberInfo.HasAttribute<ScriptActorPropertyActivityAttribute>();
|
var isActivity = Utility.HasAttribute<ScriptActorPropertyActivityAttribute>(memberInfo);
|
||||||
|
|
||||||
if (memberInfo.HasAttribute<DescAttribute>())
|
if (Utility.HasAttribute<DescAttribute>(memberInfo))
|
||||||
{
|
{
|
||||||
var lines = memberInfo.GetCustomAttributes<DescAttribute>(true).First().Lines;
|
var lines = Utility.GetCustomAttributes<DescAttribute>(memberInfo, true).First().Lines;
|
||||||
foreach (var line in lines)
|
foreach (var line in lines)
|
||||||
Console.WriteLine($" --- {line}");
|
Console.WriteLine($" --- {line}");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
|
|
||||||
foreach (var t in tables)
|
foreach (var t in tables)
|
||||||
{
|
{
|
||||||
var name = t.GetCustomAttributes<ScriptGlobalAttribute>(true).First().Name;
|
var name = Utility.GetCustomAttributes<ScriptGlobalAttribute>(t, true).First().Name;
|
||||||
var members = ScriptMemberWrapper.WrappableMembers(t);
|
var members = ScriptMemberWrapper.WrappableMembers(t);
|
||||||
|
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
Console.WriteLine("|---------:|-------------|");
|
Console.WriteLine("|---------:|-------------|");
|
||||||
foreach (var m in members.OrderBy(m => m.Name))
|
foreach (var m in members.OrderBy(m => m.Name))
|
||||||
{
|
{
|
||||||
var desc = m.HasAttribute<DescAttribute>() ? m.GetCustomAttributes<DescAttribute>(true).First().Lines.JoinWith("<br />") : "";
|
var desc = Utility.HasAttribute<DescAttribute>(m) ? Utility.GetCustomAttributes<DescAttribute>(m, true).First().Lines.JoinWith("<br />") : "";
|
||||||
Console.WriteLine($"| **{m.LuaDocString()}** | {desc} |");
|
Console.WriteLine($"| **{m.LuaDocString()}** | {desc} |");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
|
|
||||||
var actorCategories = utility.ModData.ObjectCreator.GetTypesImplementing<ScriptActorProperties>().SelectMany(cg =>
|
var actorCategories = utility.ModData.ObjectCreator.GetTypesImplementing<ScriptActorProperties>().SelectMany(cg =>
|
||||||
{
|
{
|
||||||
var catAttr = cg.GetCustomAttributes<ScriptPropertyGroupAttribute>(false).FirstOrDefault();
|
var catAttr = Utility.GetCustomAttributes<ScriptPropertyGroupAttribute>(cg, false).FirstOrDefault();
|
||||||
var category = catAttr != null ? catAttr.Category : "Unsorted";
|
var category = catAttr != null ? catAttr.Category : "Unsorted";
|
||||||
|
|
||||||
var required = ScriptMemberWrapper.RequiredTraitNames(cg);
|
var required = ScriptMemberWrapper.RequiredTraitNames(cg);
|
||||||
@@ -106,9 +106,9 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
{
|
{
|
||||||
var mi = property.mi;
|
var mi = property.mi;
|
||||||
var required = property.required;
|
var required = property.required;
|
||||||
var hasDesc = mi.HasAttribute<DescAttribute>();
|
var hasDesc = Utility.HasAttribute<DescAttribute>(mi);
|
||||||
var hasRequires = required.Length > 0;
|
var hasRequires = required.Length > 0;
|
||||||
var isActivity = mi.HasAttribute<ScriptActorPropertyActivityAttribute>();
|
var isActivity = Utility.HasAttribute<ScriptActorPropertyActivityAttribute>(mi);
|
||||||
|
|
||||||
Console.Write($"| **{mi.LuaDocString()}**");
|
Console.Write($"| **{mi.LuaDocString()}**");
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
Console.Write(" | ");
|
Console.Write(" | ");
|
||||||
|
|
||||||
if (hasDesc)
|
if (hasDesc)
|
||||||
Console.Write(mi.GetCustomAttributes<DescAttribute>(false).First().Lines.JoinWith("<br />"));
|
Console.Write(Utility.GetCustomAttributes<DescAttribute>(mi, false).First().Lines.JoinWith("<br />"));
|
||||||
|
|
||||||
if (hasDesc && hasRequires)
|
if (hasDesc && hasRequires)
|
||||||
Console.Write("<br />");
|
Console.Write("<br />");
|
||||||
@@ -136,7 +136,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
|
|
||||||
var playerCategories = utility.ModData.ObjectCreator.GetTypesImplementing<ScriptPlayerProperties>().SelectMany(cg =>
|
var playerCategories = utility.ModData.ObjectCreator.GetTypesImplementing<ScriptPlayerProperties>().SelectMany(cg =>
|
||||||
{
|
{
|
||||||
var catAttr = cg.GetCustomAttributes<ScriptPropertyGroupAttribute>(false).FirstOrDefault();
|
var catAttr = Utility.GetCustomAttributes<ScriptPropertyGroupAttribute>(cg, false).FirstOrDefault();
|
||||||
var category = catAttr != null ? catAttr.Category : "Unsorted";
|
var category = catAttr != null ? catAttr.Category : "Unsorted";
|
||||||
|
|
||||||
var required = ScriptMemberWrapper.RequiredTraitNames(cg);
|
var required = ScriptMemberWrapper.RequiredTraitNames(cg);
|
||||||
@@ -155,9 +155,9 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
{
|
{
|
||||||
var mi = property.mi;
|
var mi = property.mi;
|
||||||
var required = property.required;
|
var required = property.required;
|
||||||
var hasDesc = mi.HasAttribute<DescAttribute>();
|
var hasDesc = Utility.HasAttribute<DescAttribute>(mi);
|
||||||
var hasRequires = required.Length > 0;
|
var hasRequires = required.Length > 0;
|
||||||
var isActivity = mi.HasAttribute<ScriptActorPropertyActivityAttribute>();
|
var isActivity = Utility.HasAttribute<ScriptActorPropertyActivityAttribute>(mi);
|
||||||
|
|
||||||
Console.Write($"| **{mi.LuaDocString()}**");
|
Console.Write($"| **{mi.LuaDocString()}**");
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
Console.Write(" | ");
|
Console.Write(" | ");
|
||||||
|
|
||||||
if (hasDesc)
|
if (hasDesc)
|
||||||
Console.Write(mi.GetCustomAttributes<DescAttribute>(false).First().Lines.JoinWith("<br />"));
|
Console.Write(Utility.GetCustomAttributes<DescAttribute>(mi, false).First().Lines.JoinWith("<br />"));
|
||||||
|
|
||||||
if (hasDesc && hasRequires)
|
if (hasDesc && hasRequires)
|
||||||
Console.Write("<br />");
|
Console.Write("<br />");
|
||||||
|
|||||||
@@ -59,8 +59,8 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
sections.Add("Launch", new LaunchArguments(new Arguments(Array.Empty<string>())));
|
sections.Add("Launch", new LaunchArguments(new Arguments(Array.Empty<string>())));
|
||||||
foreach (var section in sections.OrderBy(s => s.Key))
|
foreach (var section in sections.OrderBy(s => s.Key))
|
||||||
{
|
{
|
||||||
var fields = section.Value.GetType().GetFields();
|
var fields = Utility.GetFields(section.Value.GetType());
|
||||||
if (fields.Any(field => field.GetCustomAttributes<DescAttribute>(false).Length > 0))
|
if (fields.Any(field => Utility.GetCustomAttributes<DescAttribute>(field, false).Length > 0))
|
||||||
{
|
{
|
||||||
Console.WriteLine($"## {section.Key}");
|
Console.WriteLine($"## {section.Key}");
|
||||||
if (section.Key == "Launch")
|
if (section.Key == "Launch")
|
||||||
@@ -72,11 +72,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
|
|
||||||
foreach (var field in fields)
|
foreach (var field in fields)
|
||||||
{
|
{
|
||||||
if (!field.HasAttribute<DescAttribute>())
|
if (!Utility.HasAttribute<DescAttribute>(field))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Console.WriteLine($"### {field.Name}");
|
Console.WriteLine($"### {field.Name}");
|
||||||
var lines = field.GetCustomAttributes<DescAttribute>(false).SelectMany(d => d.Lines);
|
var lines = Utility.GetCustomAttributes<DescAttribute>(field, false).SelectMany(d => d.Lines);
|
||||||
foreach (var line in lines)
|
foreach (var line in lines)
|
||||||
{
|
{
|
||||||
Console.WriteLine(line);
|
Console.WriteLine(line);
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
{
|
{
|
||||||
type.Namespace,
|
type.Namespace,
|
||||||
type.Name,
|
type.Name,
|
||||||
Description = string.Join(" ", type.GetCustomAttributes<DescAttribute>(false).SelectMany(d => d.Lines)),
|
Description = string.Join(" ", Utility.GetCustomAttributes<DescAttribute>(type, false).SelectMany(d => d.Lines)),
|
||||||
InheritedTypes = type.BaseTypes()
|
InheritedTypes = type.BaseTypes()
|
||||||
.Select(y => y.Name)
|
.Select(y => y.Name)
|
||||||
.Where(y => y != type.Name && y != "Object"),
|
.Where(y => y != type.Name && y != "Object"),
|
||||||
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
.Where(fi => fi.FieldType.IsGenericType && fi.FieldType.GetGenericTypeDefinition() == typeof(SpriteSequenceField<>))
|
.Where(fi => fi.FieldType.IsGenericType && fi.FieldType.GetGenericTypeDefinition() == typeof(SpriteSequenceField<>))
|
||||||
.Select(fi =>
|
.Select(fi =>
|
||||||
{
|
{
|
||||||
var description = string.Join(" ", fi.GetCustomAttributes<DescAttribute>(false)
|
var description = string.Join(" ", Utility.GetCustomAttributes<DescAttribute>(fi, false)
|
||||||
.SelectMany(d => d.Lines));
|
.SelectMany(d => d.Lines));
|
||||||
|
|
||||||
var valueType = fi.FieldType.GetGenericArguments()[0];
|
var valueType = fi.FieldType.GetGenericArguments()[0];
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
{
|
{
|
||||||
type.Namespace,
|
type.Namespace,
|
||||||
Name = type.Name.EndsWith("Info") ? type.Name.Substring(0, type.Name.Length - 4) : type.Name,
|
Name = type.Name.EndsWith("Info") ? type.Name.Substring(0, type.Name.Length - 4) : type.Name,
|
||||||
Description = string.Join(" ", type.GetCustomAttributes<DescAttribute>(false).SelectMany(d => d.Lines)),
|
Description = string.Join(" ", Utility.GetCustomAttributes<DescAttribute>(type, false).SelectMany(d => d.Lines)),
|
||||||
RequiresTraits = RequiredTraitTypes(type)
|
RequiresTraits = RequiredTraitTypes(type)
|
||||||
.Select(y => y.Name),
|
.Select(y => y.Name),
|
||||||
InheritedTypes = type.BaseTypes()
|
InheritedTypes = type.BaseTypes()
|
||||||
@@ -73,7 +73,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
DefaultValue = FieldSaver.SaveField(objectCreator.CreateBasic(type), fi.Field.Name).Value.Value,
|
DefaultValue = FieldSaver.SaveField(objectCreator.CreateBasic(type), fi.Field.Name).Value.Value,
|
||||||
InternalType = Util.InternalTypeName(fi.Field.FieldType),
|
InternalType = Util.InternalTypeName(fi.Field.FieldType),
|
||||||
UserFriendlyType = Util.FriendlyTypeName(fi.Field.FieldType),
|
UserFriendlyType = Util.FriendlyTypeName(fi.Field.FieldType),
|
||||||
Description = string.Join(" ", fi.Field.GetCustomAttributes<DescAttribute>(true).SelectMany(d => d.Lines)),
|
Description = string.Join(" ", Utility.GetCustomAttributes<DescAttribute>(fi.Field, true).SelectMany(d => d.Lines)),
|
||||||
OtherAttributes = fi.Field.CustomAttributes
|
OtherAttributes = fi.Field.CustomAttributes
|
||||||
.Where(a => a.AttributeType.Name != nameof(DescAttribute) && a.AttributeType.Name != nameof(FieldLoader.LoadUsingAttribute))
|
.Where(a => a.AttributeType.Name != nameof(DescAttribute) && a.AttributeType.Name != nameof(FieldLoader.LoadUsingAttribute))
|
||||||
.Select(a =>
|
.Select(a =>
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
{
|
{
|
||||||
type.Namespace,
|
type.Namespace,
|
||||||
Name = type.Name.EndsWith("Info") ? type.Name.Substring(0, type.Name.Length - 4) : type.Name,
|
Name = type.Name.EndsWith("Info") ? type.Name.Substring(0, type.Name.Length - 4) : type.Name,
|
||||||
Description = string.Join(" ", type.GetCustomAttributes<DescAttribute>(false).SelectMany(d => d.Lines)),
|
Description = string.Join(" ", Utility.GetCustomAttributes<DescAttribute>(type, false).SelectMany(d => d.Lines)),
|
||||||
InheritedTypes = type.BaseTypes()
|
InheritedTypes = type.BaseTypes()
|
||||||
.Select(y => y.Name)
|
.Select(y => y.Name)
|
||||||
.Where(y => y != type.Name && y != $"{type.Name}Info" && y != "Object"),
|
.Where(y => y != type.Name && y != $"{type.Name}Info" && y != "Object"),
|
||||||
@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
DefaultValue = FieldSaver.SaveField(objectCreator.CreateBasic(type), fi.Field.Name).Value.Value,
|
DefaultValue = FieldSaver.SaveField(objectCreator.CreateBasic(type), fi.Field.Name).Value.Value,
|
||||||
InternalType = Util.InternalTypeName(fi.Field.FieldType),
|
InternalType = Util.InternalTypeName(fi.Field.FieldType),
|
||||||
UserFriendlyType = Util.FriendlyTypeName(fi.Field.FieldType),
|
UserFriendlyType = Util.FriendlyTypeName(fi.Field.FieldType),
|
||||||
Description = string.Join(" ", fi.Field.GetCustomAttributes<DescAttribute>(true).SelectMany(d => d.Lines)),
|
Description = string.Join(" ", Utility.GetCustomAttributes<DescAttribute>(fi.Field, true).SelectMany(d => d.Lines)),
|
||||||
OtherAttributes = fi.Field.CustomAttributes
|
OtherAttributes = fi.Field.CustomAttributes
|
||||||
.Where(a => a.AttributeType.Name != nameof(DescAttribute) && a.AttributeType.Name != nameof(FieldLoader.LoadUsingAttribute))
|
.Where(a => a.AttributeType.Name != nameof(DescAttribute) && a.AttributeType.Name != nameof(FieldLoader.LoadUsingAttribute))
|
||||||
.Select(a =>
|
.Select(a =>
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
var tables = utility.ModData.ObjectCreator.GetTypesImplementing<ScriptGlobal>().OrderBy(t => t.Name);
|
var tables = utility.ModData.ObjectCreator.GetTypesImplementing<ScriptGlobal>().OrderBy(t => t.Name);
|
||||||
foreach (var t in tables)
|
foreach (var t in tables)
|
||||||
{
|
{
|
||||||
var name = t.GetCustomAttributes<ScriptGlobalAttribute>(true).First().Name;
|
var name = Utility.GetCustomAttributes<ScriptGlobalAttribute>(t, true).First().Name;
|
||||||
Console.WriteLine(" " + name + " = {");
|
Console.WriteLine(" " + name + " = {");
|
||||||
Console.WriteLine(" type = \"class\",");
|
Console.WriteLine(" type = \"class\",");
|
||||||
Console.WriteLine(" childs = {");
|
Console.WriteLine(" childs = {");
|
||||||
@@ -64,9 +64,9 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
if (propertyInfo != null)
|
if (propertyInfo != null)
|
||||||
Console.WriteLine(" type = \"value\",");
|
Console.WriteLine(" type = \"value\",");
|
||||||
|
|
||||||
if (member.HasAttribute<DescAttribute>())
|
if (Utility.HasAttribute<DescAttribute>(member))
|
||||||
{
|
{
|
||||||
var desc = member.GetCustomAttributes<DescAttribute>(true).First().Lines.JoinWith("\n");
|
var desc = Utility.GetCustomAttributes<DescAttribute>(member, true).First().Lines.JoinWith("\n");
|
||||||
Console.WriteLine(" description = [[{0}]],", desc);
|
Console.WriteLine(" description = [[{0}]],", desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,9 +105,9 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
if (propertyInfo != null)
|
if (propertyInfo != null)
|
||||||
Console.WriteLine(" type = \"value\",");
|
Console.WriteLine(" type = \"value\",");
|
||||||
|
|
||||||
if (property.HasAttribute<DescAttribute>())
|
if (Utility.HasAttribute<DescAttribute>(property))
|
||||||
{
|
{
|
||||||
var desc = property.GetCustomAttributes<DescAttribute>(true).First().Lines.JoinWith("\n");
|
var desc = Utility.GetCustomAttributes<DescAttribute>(property, true).First().Lines.JoinWith("\n");
|
||||||
Console.WriteLine(" description = [[{0}]],", desc);
|
Console.WriteLine(" description = [[{0}]],", desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
static void GetActionUsage(string key, Action<Utility, string[]> action)
|
static void GetActionUsage(string key, Action<Utility, string[]> action)
|
||||||
{
|
{
|
||||||
var descParts = action.Method.GetCustomAttributes<DescAttribute>(true)
|
var descParts = Utility.GetCustomAttributes<DescAttribute>(action.Method, true)
|
||||||
.SelectMany(d => d.Lines).ToArray();
|
.SelectMany(d => d.Lines).ToArray();
|
||||||
|
|
||||||
if (descParts.Length == 0)
|
if (descParts.Length == 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user