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

Commit

Permalink
Merge pull request #88 from neos-modding-group/why-the-hell-did-micro…
Browse files Browse the repository at this point in the history
…soft-think-this-was-a-good-idea

Fix the garbage that Directory.GetFiles returns
  • Loading branch information
zkxs authored Mar 11, 2023
2 parents c5bb9ae + 96f4232 commit 8ccc47e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions NeosModLoader/AssemblyLoader.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;

namespace NeosModLoader
Expand All @@ -16,8 +17,14 @@ internal static class AssemblyLoader
string[]? assembliesToLoad = null;
try
{
assembliesToLoad = Directory.GetFiles(assembliesDirectory, "*.dll", SearchOption.AllDirectories);
Array.Sort(assembliesToLoad, (a, b) => string.CompareOrdinal(a, b));
// 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)
// long story short if I searched for "*.dll" it would unhelpfully use some incredibly inconsistent behavior and return results like "foo.dll_disabled"
// So I have to filter shit after the fact... ugh
Logger.DebugInternal("I'm morbing");
assembliesToLoad = Directory.EnumerateFiles(assembliesDirectory, "*.dll", SearchOption.AllDirectories)
.Where(file => file.EndsWith(".dll"))
.ToArray();
Array.Sort(assembliesToLoad, string.CompareOrdinal);
}
catch (Exception e)
{
Expand Down

0 comments on commit 8ccc47e

Please sign in to comment.