Skip to content

Commit

Permalink
Merge pull request dnSpy#1530 from HoLLy-HaCKeR/extension-directory-cli
Browse files Browse the repository at this point in the history
Add commandline argument for additional extension directory
  • Loading branch information
wtfsck authored Jul 17, 2020
2 parents f9178f8 + a678e42 commit e1b96bd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions dnSpy/dnSpy.Contracts.DnSpy/App/IAppCommandLineArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ public interface IAppCommandLineArgs {
/// <summary>Attach to this process name, unless it's empty. Can contain wildcards.</summary>
string DebugAttachProcess { get; }

/// <summary>Additional directory to check for extensions.</summary>
string ExtraExtensionDirectory { get; }

/// <summary>
/// Returns true if the argument is present
/// </summary>
Expand Down
8 changes: 6 additions & 2 deletions dnSpy/dnSpy/MainApp/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ static void ShowException(Exception? ex) {
Stopwatch? startupStopwatch;
public App(bool readSettings, Stopwatch startupStopwatch) {
resourceManagerTokenCacheImpl = new ResourceManagerTokenCacheImpl();
args = new AppCommandLineArgs();

// PERF: Init MEF on a BG thread. Results in slightly faster startup, eg. InitializeComponent() becomes a 'free' call on this UI thread
initializeMEFTask = Task.Run(() => InitializeMEF(readSettings, useCache: readSettings));
this.startupStopwatch = startupStopwatch;

resourceManagerTokenCacheImpl.TokensUpdated += ResourceManagerTokenCacheImpl_TokensUpdated;
ResourceHelper.SetResourceManagerTokenCache(resourceManagerTokenCacheImpl);
args = new AppCommandLineArgs();
AppDirectories.SetSettingsFilename(args.SettingsFilename);

AddAppContextFixes();
Expand Down Expand Up @@ -324,10 +324,14 @@ Assembly[] GetAssemblies() {

Assembly[] LoadExtensionAssemblies() {
var dir = AppDirectories.BinDirectory;
var unsortedFiles = GetExtensionFiles(dir);
if (!(args.ExtraExtensionDirectory is null))
unsortedFiles = unsortedFiles.Concat(GetExtensionFiles(args.ExtraExtensionDirectory));

// Load the modules in a predictable order or multicore-JIT could stop recording. See
// "Understanding Background JIT compilation -> What can go wrong with background JIT compilation"
// in the PerfView docs for more info.
var files = GetExtensionFiles(dir).OrderBy(a => a, StringComparer.OrdinalIgnoreCase).ToArray();
var files = unsortedFiles.OrderBy(a => a, StringComparer.OrdinalIgnoreCase).ToArray();
#if NETCOREAPP
foreach (var file in files)
netCoreAssemblyLoader.AddSearchPath(Path.GetDirectoryName(file)!);
Expand Down
6 changes: 6 additions & 0 deletions dnSpy/dnSpy/MainApp/AppCommandLineArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ sealed class AppCommandLineArgs : IAppCommandLineArgs {
public uint DebugEvent { get; }
public ulong JitDebugInfo { get; }
public string DebugAttachProcess { get; }
public string ExtraExtensionDirectory { get; }

readonly Dictionary<string, string> userArgs = new Dictionary<string, string>();
readonly List<string> filenames = new List<string>();
Expand Down Expand Up @@ -194,6 +195,11 @@ public AppCommandLineArgs(string[] args) {
i++;
break;

case "--extension-directory":
ExtraExtensionDirectory = GetFullPath(next);
i++;
break;

default:
int sepIndex = arg.IndexOf(ARG_SEP);
string argName, argValue;
Expand Down

0 comments on commit e1b96bd

Please sign in to comment.