diff --git a/Core/Core.csproj b/Core/Core.csproj index 34c8f9b6..938e44df 100644 --- a/Core/Core.csproj +++ b/Core/Core.csproj @@ -6,8 +6,10 @@ enable + + - + diff --git a/Core/Heuristics.cs b/Core/Heuristics.cs index 60d82ad7..97143fff 100644 --- a/Core/Heuristics.cs +++ b/Core/Heuristics.cs @@ -15,21 +15,24 @@ internal static class Heuristics static Heuristics() { - string? path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - if (path == null) + var assembly = Assembly.GetExecutingAssembly(); + var resourceName = assembly.GetManifestResourceNames().FirstOrDefault(name => name.EndsWith("words_alpha.txt")); + + if (resourceName == null) { - Console.WriteLine("Executing assembly path is null???"); + Console.WriteLine("Can't find words dictionary in embedded resources"); dict = []; return; } - var DictPath = Path.Combine(path, "words_alpha.txt"); - if (!File.Exists(DictPath)) + + using var stream = assembly.GetManifestResourceStream(resourceName); + if (stream != null) { - Console.WriteLine("Can't find words dictionary"); - dict = []; - return; + using var reader = new StreamReader(stream); + dict = reader.ReadToEnd().Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).ToImmutableHashSet(); } - dict = [.. File.ReadAllLines(DictPath)]; + + dict = []; }