From 1449e46c6a895418e7d606b3bb7b7cdf49af8e3c Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Wed, 6 Jan 2021 22:46:49 -0600 Subject: [PATCH] Slight improvement to error reporting --- IPA/Program.cs | 11 +++++++---- IPA/_Attributes.cs | 10 ++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 IPA/_Attributes.cs diff --git a/IPA/Program.cs b/IPA/Program.cs index 2dd05d27..2f4faa8a 100644 --- a/IPA/Program.cs +++ b/IPA/Program.cs @@ -95,10 +95,13 @@ namespace IPA AppDomain.CurrentDomain.AssemblyResolve += AssemblyLibLoader; var argExeName = Arguments.CmdLine.PositionalArgs.FirstOrDefault(s => s.EndsWith(".exe")); + argExeName ??= new DirectoryInfo(Directory.GetCurrentDirectory()).GetFiles() + .FirstOrDefault(o => o.Extension == ".exe" && o.FullName != Assembly.GetEntryAssembly().Location) + ?.FullName; if (argExeName == null) - context = PatchContext.Create(new DirectoryInfo(Directory.GetCurrentDirectory()).GetFiles() - .First(o => o.Extension == ".exe" && o.FullName != Assembly.GetEntryAssembly().Location) - .FullName); + { + Fail("Could not locate game executable"); + } else context = PatchContext.Create(argExeName); @@ -341,7 +344,7 @@ namespace IPA } } - + [DoesNotReturn] private static void Fail(string message) { Console.Error.WriteLine("ERROR: " + message); diff --git a/IPA/_Attributes.cs b/IPA/_Attributes.cs new file mode 100644 index 00000000..72f7b779 --- /dev/null +++ b/IPA/_Attributes.cs @@ -0,0 +1,10 @@ +#if NET461 +namespace System.Diagnostics.CodeAnalysis +{ + [AttributeUsage(AttributeTargets.Method, Inherited = false)] + public sealed class DoesNotReturnAttribute : Attribute + { + public DoesNotReturnAttribute() { } + } +} +#endif \ No newline at end of file