Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.

Commit 8ccc47e

Browse files
authored
Merge pull request #88 from neos-modding-group/why-the-hell-did-microsoft-think-this-was-a-good-idea
Fix the garbage that Directory.GetFiles returns
2 parents c5bb9ae + 96f4232 commit 8ccc47e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

NeosModLoader/AssemblyLoader.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.IO;
4+
using System.Linq;
45
using System.Reflection;
56

67
namespace NeosModLoader
@@ -16,8 +17,14 @@ internal static class AssemblyLoader
1617
string[]? assembliesToLoad = null;
1718
try
1819
{
19-
assembliesToLoad = Directory.GetFiles(assembliesDirectory, "*.dll", SearchOption.AllDirectories);
20-
Array.Sort(assembliesToLoad, (a, b) => string.CompareOrdinal(a, b));
20+
// Directory.GetFiles and Directory.EnumerateFiles have a fucked up API: https://learn.microsoft.com/en-us/dotnet/api/system.io.directory.getfiles?view=netframework-4.6.2#system-io-directory-getfiles(system-string-system-string-system-io-searchoption)
21+
// long story short if I searched for "*.dll" it would unhelpfully use some incredibly inconsistent behavior and return results like "foo.dll_disabled"
22+
// So I have to filter shit after the fact... ugh
23+
Logger.DebugInternal("I'm morbing");
24+
assembliesToLoad = Directory.EnumerateFiles(assembliesDirectory, "*.dll", SearchOption.AllDirectories)
25+
.Where(file => file.EndsWith(".dll"))
26+
.ToArray();
27+
Array.Sort(assembliesToLoad, string.CompareOrdinal);
2128
}
2229
catch (Exception e)
2330
{

0 commit comments

Comments
 (0)