Skip to content

Commit

Permalink
Add support for extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
kevingosse committed May 14, 2020
1 parent 55d5a20 commit 4abf635
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/Tools/dotnet-dump/Analyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class Analyzer
{
private readonly ServiceProvider _serviceProvider;
private readonly ConsoleProvider _consoleProvider;
private readonly CommandProcessor _commandProcessor;
private CommandProcessor _commandProcessor;
private bool _isDesktop;
private string _dacFilePath;

Expand All @@ -42,11 +42,20 @@ public Analyzer()
{
_serviceProvider = new ServiceProvider();
_consoleProvider = new ConsoleProvider();
_commandProcessor = new CommandProcessor(_serviceProvider, _consoleProvider, new Assembly[] { typeof(Analyzer).Assembly });
}

public async Task<int> Analyze(FileInfo dump_path, string[] command)
public async Task<int> Analyze(FileInfo dump_path, string[] extensions, string[] command)
{
var assemblies = new List<Assembly> { typeof(Analyzer).Assembly };

foreach (var path in extensions)
{
var assembly = Assembly.LoadFrom(path);
assemblies.Add(assembly);
}

_commandProcessor = new CommandProcessor(_serviceProvider, _consoleProvider, assemblies);

_consoleProvider.WriteLine($"Loading core dump: {dump_path} ...");

try
Expand Down
10 changes: 9 additions & 1 deletion src/Tools/dotnet-dump/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ private static Command AnalyzeCommand() =>
description: "Starts an interactive shell with debugging commands to explore a dump")
{
// Handler
CommandHandler.Create<FileInfo, string[]>(new Analyzer().Analyze),
CommandHandler.Create<FileInfo, string[], string[]>(new Analyzer().Analyze),
// Arguments and Options
DumpPath(),
Extensions(),
RunCommand()
};

Expand All @@ -88,6 +89,13 @@ private static Argument DumpPath() =>
Description = "Name of the dump file to analyze."
}.ExistingOnly();

private static Option Extensions() =>
new Option(
aliases: new[] { "-e", "--extensions" })
{
Argument = new Argument<string[]>("extensions", System.Array.Empty<string>()) { Arity = ArgumentArity.ZeroOrMore }
};

private static Option RunCommand() =>
new Option(
aliases: new[] { "-c", "--command" },
Expand Down

0 comments on commit 4abf635

Please sign in to comment.