Skip to content

Commit

Permalink
Discover extension from different contexts
Browse files Browse the repository at this point in the history
Fixes #146
  • Loading branch information
nvborisenko committed Feb 17, 2024
1 parent 40b1344 commit e71430a
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/ReportPortal.Shared/Extensibility/ExtensionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@ public class ExtensionManager : IExtensionManager
{
var ext = new ExtensionManager();

var assemblyLocation = AppContext.BaseDirectory;
_traceLogger.Verbose($"Executing assembly location: {assemblyLocation}");
var extentionDirectories = new List<string>
{
AppContext.BaseDirectory,
Path.GetDirectoryName(typeof(ExtensionManager).Assembly.Location),
Environment.CurrentDirectory,
};

ext.Explore(assemblyLocation);
foreach (var extentionDirectory in extentionDirectories)
{
ext.Explore(extentionDirectory);
}

return ext;
});
Expand All @@ -38,13 +45,13 @@ public void Explore(string path)
{
if (!_exploredPaths.Contains(path))
{
_traceLogger.Info($"Exploring extensions in '{path}' directory.");

var reportEventObservers = new List<IReportEventsObserver>();
var commandsListeners = new List<ICommandsListener>();

var currentDirectory = new DirectoryInfo(path);

_traceLogger.Info($"Exploring extensions in '{currentDirectory}' directory.");

foreach (var file in currentDirectory.GetFiles("*ReportPortal*.dll"))
{
_traceLogger.Verbose($"Found '{file.Name}' and loading it into current AppDomain.");
Expand Down Expand Up @@ -108,6 +115,10 @@ public void Explore(string path)
}
}
}
else
{
_traceLogger.Verbose($"The extensions '{path}' path was visited before, skipping");
}
}

public IList<IReportEventsObserver> ReportEventObservers { get; } = new List<IReportEventsObserver>();
Expand Down

0 comments on commit e71430a

Please sign in to comment.