Skip to content

Commit

Permalink
load assemblies manually
Browse files Browse the repository at this point in the history
  • Loading branch information
oguzhankoral committed Nov 30, 2024
1 parent 8e70a5d commit 9b906dc
Showing 1 changed file with 38 additions and 5 deletions.
43 changes: 38 additions & 5 deletions Sdk/FeatureImpactAnalyzer/GitHubPullRequestAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,48 @@ private List<string> GetFeatureImpactAttributes(string methodName)
{
var impactedFeatures = new List<string>();

// Load all assemblies in the current AppDomain
var assemblies = AppDomain
.CurrentDomain.GetAssemblies()
.Where(a => a.FullName != null && a.FullName.StartsWith("Speckle"))
.ToList();
var assemblies = new List<Assembly>();

// Load all assemblies in the current AppDomain
string? solutionDirectory = Path.GetFullPath(
Path.Combine(Assembly.GetExecutingAssembly().Location, "..", "..", "..")
);
if (!string.IsNullOrEmpty(solutionDirectory))
{
// Search for all DLLs in the parent directory and subdirectories
var dllFiles = Directory
.GetFiles(solutionDirectory, "*.dll", SearchOption.AllDirectories)
.Where(dll =>
(
Path.GetFileName(dll).StartsWith("Speckle.Connectors.", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(dll).StartsWith("Speckle.Converters.", StringComparison.OrdinalIgnoreCase)
) && !Path.GetFileName(dll).Contains("Test", StringComparison.OrdinalIgnoreCase) // Exclude test assemblies
);

foreach (var dll in dllFiles)
{
try
{
var assemblyName = AssemblyName.GetAssemblyName(dll);
if (!assemblies.Any(a => a.FullName == assemblyName.FullName))
{
var loadedAssembly = Assembly.LoadFrom(dll);
assemblies.Add(loadedAssembly);
Console.WriteLine($"Loaded assembly: {loadedAssembly.FullName}");
}
}
catch (BadImageFormatException)
{
Console.WriteLine($"Skipping invalid assembly: {dll}");
}
catch (Exception ex) when (!ex.IsFatal())
{
Console.WriteLine($"Failed to load assembly: {dll}. Error: {ex.Message}");
}
}
}

Console.WriteLine($"Solution directory {solutionDirectory}");

// Dynamically load assemblies from the solution directory
// string? solutionDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
Expand Down

0 comments on commit 9b906dc

Please sign in to comment.