Skip to content

Commit eb04497

Browse files
committed
Remove sourcePath
1 parent b5141ba commit eb04497

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/Neo/Plugins/Plugin.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,18 +166,20 @@ protected IConfigurationSection GetConfiguration()
166166
.GetSection("PluginConfiguration");
167167
}
168168

169-
private static void LoadPlugin(Assembly assembly, string? sourcePath = null)
169+
private static void LoadPlugin(Assembly assembly)
170170
{
171171
Type[] exportedTypes;
172-
var origin = sourcePath ?? assembly.GetName().Name ?? "unknown";
172+
173+
var assemblyName = assembly.GetName().Name;
174+
var location = assembly.Location;
173175

174176
try
175177
{
176178
exportedTypes = (Type[])assembly.ExportedTypes;
177179
}
178180
catch (Exception ex)
179181
{
180-
Utility.Log(nameof(Plugin), LogLevel.Error, $"Failed to load plugin assembly {origin}");
182+
Utility.Log(nameof(Plugin), LogLevel.Error, $"Failed to load plugin assembly {assemblyName} from {location}");
181183
Utility.Log(nameof(Plugin), LogLevel.Error, ex);
182184
throw;
183185
}
@@ -196,7 +198,7 @@ private static void LoadPlugin(Assembly assembly, string? sourcePath = null)
196198
}
197199
catch (Exception ex)
198200
{
199-
Utility.Log(nameof(Plugin), LogLevel.Error, $"Failed to initialize plugin type {type.FullName} from {origin}");
201+
Utility.Log(nameof(Plugin), LogLevel.Error, $"Failed to initialize plugin type {type.FullName} from {location}");
200202
Utility.Log(nameof(Plugin), LogLevel.Error, ex);
201203
}
202204
}
@@ -205,15 +207,14 @@ private static void LoadPlugin(Assembly assembly, string? sourcePath = null)
205207
internal static void LoadPlugins()
206208
{
207209
if (!Directory.Exists(PluginsDirectory)) return;
208-
List<(Assembly Assembly, string FileName)> assemblies = [];
210+
List<Assembly> assemblies = [];
209211
foreach (var rootPath in Directory.GetDirectories(PluginsDirectory))
210212
{
211213
foreach (var filename in Directory.EnumerateFiles(rootPath, "*.dll", SearchOption.TopDirectoryOnly))
212214
{
213215
try
214216
{
215-
var assembly = Assembly.Load(File.ReadAllBytes(filename));
216-
assemblies.Add((assembly, filename));
217+
assemblies.Add(Assembly.Load(File.ReadAllBytes(filename)));
217218
}
218219
catch (Exception ex)
219220
{
@@ -223,9 +224,9 @@ internal static void LoadPlugins()
223224
}
224225
}
225226

226-
foreach (var (assembly, filename) in assemblies)
227+
foreach (var assembly in assemblies)
227228
{
228-
LoadPlugin(assembly, filename);
229+
LoadPlugin(assembly);
229230
}
230231
}
231232

0 commit comments

Comments
 (0)