mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Add command to dump injector cache list.
To allow me to figure out how big it is.
This commit is contained in:
@@ -529,3 +529,7 @@ cmd-vv-desc = Usage: vv <path|entity ID|guihover>
|
||||
|
||||
cmd-vvinvoke-desc = Invoke/Call a path with arguments using VV.
|
||||
cmd-vvinvoke-desc = Usage: vvinvoke <path> [arguments...]
|
||||
|
||||
cmd-dump_dependency_injectors-desc = Dump IoCManager's dependency injector cache.
|
||||
cmd-dump_dependency_injectors-help = Usage: dump_dependency_injectors
|
||||
cmd-dump_dependency_injectors-total-count = Total count: { $total }
|
||||
|
||||
25
Robust.Shared/Console/Commands/DumpDependencyInjectors.cs
Normal file
25
Robust.Shared/Console/Commands/DumpDependencyInjectors.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
|
||||
namespace Robust.Shared.Console.Commands;
|
||||
|
||||
internal sealed class DumpDependencyInjectors : LocalizedCommands
|
||||
{
|
||||
[Dependency] private readonly IDependencyCollection _dependencies = default!;
|
||||
|
||||
public override string Command => "dump_dependency_injectors";
|
||||
|
||||
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var deps = (DependencyCollection)_dependencies;
|
||||
|
||||
var types = deps.GetCachedInjectorTypes();
|
||||
|
||||
foreach (var type in types)
|
||||
{
|
||||
shell.WriteLine(type.FullName ?? "");
|
||||
}
|
||||
|
||||
shell.WriteLine(Loc.GetString("cmd-dump_dependency_injectors-total-count", ("total", types.Length)));
|
||||
}
|
||||
}
|
||||
@@ -83,6 +83,12 @@ namespace Robust.Shared.IoC
|
||||
: _services.Keys;
|
||||
}
|
||||
|
||||
public Type[] GetCachedInjectorTypes()
|
||||
{
|
||||
using var _ = _injectorCacheLock.ReadGuard();
|
||||
return _injectorCache.Where(kv => kv.Value.Delegate != null).Select(kv => kv.Key).ToArray();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool TryResolveType<T>([NotNullWhen(true)] out T? instance)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user