Cache reflection calls when running utility lints and commands.

Reduces runtime of --check-yaml command to 70% of original.
This commit is contained in:
RoosterDragon
2023-03-28 19:04:14 +01:00
committed by Matthias Mailänder
parent 1a2aafa17c
commit 9dd4f938da
24 changed files with 116 additions and 87 deletions

View File

@@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
{
type.Namespace,
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()
.Select(y => y.Name)
.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<>))
.Select(fi =>
{
var description = string.Join(" ", fi.GetCustomAttributes<DescAttribute>(false)
var description = string.Join(" ", Utility.GetCustomAttributes<DescAttribute>(fi, false)
.SelectMany(d => d.Lines));
var valueType = fi.FieldType.GetGenericArguments()[0];