Use nameof instead of hardcoded strings in reflection calls.
This helps improve the safety of code the uses reflection when methods may get renamed, and helps navigating code as the nameof will show up when searching for references to members.
This commit is contained in:
@@ -287,7 +287,7 @@ namespace OpenRA.Scripting
|
||||
|
||||
Type[] FilterCommands(ActorInfo ai, Type[] knownCommands)
|
||||
{
|
||||
var method = typeof(ActorInfo).GetMethod("HasTraitInfo");
|
||||
var method = typeof(ActorInfo).GetMethod(nameof(ActorInfo.HasTraitInfo));
|
||||
return knownCommands.Where(c => ExtractRequiredTypes(c)
|
||||
.All(t => (bool)method.MakeGenericMethod(t).Invoke(ai, NoArguments)))
|
||||
.ToArray();
|
||||
|
||||
Reference in New Issue
Block a user