Skip to content

Commit 4deb3de

Browse files
committed
Fixed an issue where duplicate modules were being added to the modules collection.
references: https://be.exceptionless.io/stack/555672627436f20f805f8f84
1 parent 1dac0ba commit 4deb3de

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

Source/Extras/Extensions/ToErrorModelExtensions.cs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,12 @@ private static ModuleCollection GetLoadedModules(IExceptionlessLog log, bool inc
135135
} catch {}
136136
}
137137

138-
var module = assembly.ToModuleInfo(log);
138+
var module = assembly.ToModuleInfo();
139+
if (module.ModuleId > 0)
140+
continue;
141+
139142
module.ModuleId = id;
140-
modules.Add(assembly.ToModuleInfo(log));
143+
modules.Add(module);
141144

142145
id++;
143146
}
@@ -221,18 +224,15 @@ private static int GetModuleId(Error root, System.Reflection.Module module) {
221224
return -1;
222225
}
223226

224-
public static Module ToModuleInfo(this System.Reflection.Module module, IExceptionlessLog log = null) {
225-
return ToModuleInfo(module.Assembly, log);
227+
public static Module ToModuleInfo(this System.Reflection.Module module) {
228+
return ToModuleInfo(module.Assembly);
226229
}
227230

228-
public static Module ToModuleInfo(this Assembly assembly, IExceptionlessLog log = null) {
231+
public static Module ToModuleInfo(this Assembly assembly) {
229232
if (assembly == null)
230233
return null;
231234

232-
if (log == null)
233-
log = new NullExceptionlessLog();
234-
235-
Module module = _moduleCache.GetOrAdd(assembly.FullName, k => {
235+
return _moduleCache.GetOrAdd(assembly.FullName, k => {
236236
var mod = new Module();
237237
AssemblyName name = assembly.GetAssemblyName();
238238
if (name != null) {
@@ -258,16 +258,12 @@ public static Module ToModuleInfo(this Assembly assembly, IExceptionlessLog log
258258
DateTime? lastWriteTime = assembly.GetLastWriteTime();
259259
if (lastWriteTime.HasValue)
260260
mod.ModifiedDate = lastWriteTime.Value;
261+
262+
if (assembly == Assembly.GetEntryAssembly())
263+
mod.IsEntry = true;
261264

262265
return mod;
263266
});
264-
265-
if (module != null) {
266-
if (assembly == Assembly.GetEntryAssembly())
267-
module.IsEntry = true;
268-
}
269-
270-
return module;
271267
}
272268
}
273269
}

0 commit comments

Comments
 (0)