Skip to content

Commit 6f9bcc2

Browse files
committed
Fix multiple invocation bug
This bug arose when all of the libraries were consoliated into the same library for better packaging. Each set of classes was being instantiated 3 times as a result.
1 parent 0fb0ecd commit 6f9bcc2

File tree

6 files changed

+4
-40
lines changed

6 files changed

+4
-40
lines changed

BinaryObjectScanner/FileType/Executable.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,8 @@ public ConcurrentDictionary<IPortableExecutableCheck, string> RunPortableExecuta
399399
/// <summary>
400400
/// Initialize all implementations of a type
401401
/// </summary>
402-
private static IEnumerable<T>? InitCheckClasses<T>()
403-
=> InitCheckClasses<T>(typeof(GameEngine._DUMMY).Assembly) ?? Enumerable.Empty<T>()
404-
.Concat(InitCheckClasses<T>(typeof(Packer._DUMMY).Assembly) ?? Enumerable.Empty<T>())
405-
.Concat(InitCheckClasses<T>(typeof(Protection._DUMMY).Assembly) ?? Enumerable.Empty<T>());
402+
private static IEnumerable<T>? InitCheckClasses<T>() =>
403+
InitCheckClasses<T>(typeof(Handler).Assembly) ?? Enumerable.Empty<T>();
406404

407405
/// <summary>
408406
/// Initialize all implementations of a type
@@ -412,11 +410,7 @@ public ConcurrentDictionary<IPortableExecutableCheck, string> RunPortableExecuta
412410
return assembly.GetTypes()?
413411
.Where(t => t.IsClass && t.GetInterface(typeof(T).Name) != null)?
414412
.Select(t => (T?)Activator.CreateInstance(t))
415-
#if NET40 || NET452
416413
.Cast<T>() ?? [];
417-
#else
418-
.Cast<T>() ?? Array.Empty<T>();
419-
#endif
420414
}
421415

422416
#endregion

BinaryObjectScanner/GameEngine/_DUMMY.cs

Lines changed: 0 additions & 7 deletions
This file was deleted.

BinaryObjectScanner/Handler.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,8 @@ public static ConcurrentDictionary<string, ConcurrentQueue<string>> HandlePathCh
171171
/// <summary>
172172
/// Initialize all implementations of a type
173173
/// </summary>
174-
private static IEnumerable<T?> InitCheckClasses<T>()
175-
{
176-
return InitCheckClasses<T>(typeof(GameEngine._DUMMY).Assembly)
177-
.Concat(InitCheckClasses<T>(typeof(Packer._DUMMY).Assembly))
178-
.Concat(InitCheckClasses<T>(typeof(Protection._DUMMY).Assembly));
179-
}
174+
private static IEnumerable<T?> InitCheckClasses<T>() =>
175+
InitCheckClasses<T>(typeof(Handler).Assembly);
180176

181177
/// <summary>
182178
/// Initialize all implementations of a type
@@ -185,11 +181,7 @@ public static ConcurrentDictionary<string, ConcurrentQueue<string>> HandlePathCh
185181
{
186182
return assembly.GetTypes()?
187183
.Where(t => t.IsClass && t.GetInterface(typeof(T).Name) != null)?
188-
#if NET40 || NET452
189184
.Select(t => (T?)Activator.CreateInstance(t)) ?? [];
190-
#else
191-
.Select(t => (T?)Activator.CreateInstance(t)) ?? Array.Empty<T>();
192-
#endif
193185
}
194186

195187
#endregion

BinaryObjectScanner/Packer/_DUMMY.cs

Lines changed: 0 additions & 7 deletions
This file was deleted.

BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ internal ConcurrentQueue<string> SafeDiscCheckDirectoryPath(string path, IEnumer
146146
new PathMatch("drvmgt.dll", useEndsWith: true),
147147
new PathMatch("mcp.dll", useEndsWith: true),
148148
new PathMatch("secdrv.sys", useEndsWith: true),
149-
150149
}, "SafeDisc 1.45.011-1.50.020"),
151150

152151
// TODO: Research "splash16.bmp" and "splash256.bmp".

BinaryObjectScanner/Protection/_DUMMY.cs

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)