From d9eba5d5d93f387271dedd3914f3b6af06fce055 Mon Sep 17 00:00:00 2001 From: Joshua Larkin <70237359+j0shuams@users.noreply.github.com> Date: Wed, 11 Aug 2021 11:12:21 -0700 Subject: [PATCH 1/3] Exit code --- src/Perf/IIDOptimizer/Program.cs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/Perf/IIDOptimizer/Program.cs b/src/Perf/IIDOptimizer/Program.cs index 225bc621d..dc7ea55a7 100644 --- a/src/Perf/IIDOptimizer/Program.cs +++ b/src/Perf/IIDOptimizer/Program.cs @@ -40,7 +40,7 @@ class Program arity: ArgumentArity.ZeroOrMore ); - static async Task Main(string[] args) + static int Main(string[] args) { var rootCommand = new RootCommand { }; // friendlier option names @@ -53,7 +53,8 @@ static async Task Main(string[] args) rootCommand.AddOption(_references); rootCommand.Handler = CommandHandler.Create>(GuidPatch); - await rootCommand.InvokeAsync(args); + Task retVal = rootCommand.InvokeAsync(args); + return retVal.Result; } private static ReaderParameters MakeReaderParams(ReferenceAssemblyResolver resolver) @@ -72,7 +73,7 @@ private static ReaderParameters MakeReaderParams(ReferenceAssemblyResolver resol // Set WinRT.Runtime.dll -- either we are patching it, or it is in the references - private static AssemblyDefinition ResolveWinRTRuntime(AssemblyDefinition targetAssemblyDefinition, ReferenceAssemblyResolver resolver) + private static AssemblyDefinition? ResolveWinRTRuntime(AssemblyDefinition targetAssemblyDefinition, ReferenceAssemblyResolver resolver) { AssemblyDefinition? winRTRuntimeAssembly = null; @@ -81,14 +82,21 @@ private static AssemblyDefinition ResolveWinRTRuntime(AssemblyDefinition targetA winRTRuntimeAssembly = targetAssemblyDefinition; } else - { + { var winrtAssembly = targetAssemblyDefinition .MainModule .AssemblyReferences .Where(refAssembly => refAssembly.Name == "WinRT.Runtime") - .First(); - - winRTRuntimeAssembly = resolver.Resolve(winrtAssembly); + .FirstOrDefault(); + + if (winrtAssembly == default(AssemblyNameReference)) + { + winRTRuntimeAssembly = null; + } + else + { + winRTRuntimeAssembly = resolver.Resolve(winrtAssembly); + } } return winRTRuntimeAssembly; From 6dffecad97349daa4733cc56f4dabbe3e4d0aca6 Mon Sep 17 00:00:00 2001 From: Joshua Larkin <70237359+j0shuams@users.noreply.github.com> Date: Thu, 12 Aug 2021 16:11:24 -0700 Subject: [PATCH 2/3] exception --- src/Perf/IIDOptimizer/Program.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Perf/IIDOptimizer/Program.cs b/src/Perf/IIDOptimizer/Program.cs index dc7ea55a7..a73228ea5 100644 --- a/src/Perf/IIDOptimizer/Program.cs +++ b/src/Perf/IIDOptimizer/Program.cs @@ -141,6 +141,12 @@ private static int GuidPatch(string targetAssembly, string outputDirectory, IEnu Console.WriteLine($"\tAssembly : {e.AssemblyReference.Name}"); return -1; } + catch (Exception e) + { + Console.WriteLine("Application failed with unexpected exception."); + Console.WriteLine($"{e}"); + return -1; + } } } } From 281d3dfb1f54e84b0345b4dad65538fc1caa5d72 Mon Sep 17 00:00:00 2001 From: Joshua Larkin <70237359+j0shuams@users.noreply.github.com> Date: Wed, 18 Aug 2021 08:03:54 -0700 Subject: [PATCH 3/3] error msg --- src/Perf/IIDOptimizer/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Perf/IIDOptimizer/Program.cs b/src/Perf/IIDOptimizer/Program.cs index a73228ea5..2aa1e20f3 100644 --- a/src/Perf/IIDOptimizer/Program.cs +++ b/src/Perf/IIDOptimizer/Program.cs @@ -143,7 +143,7 @@ private static int GuidPatch(string targetAssembly, string outputDirectory, IEnu } catch (Exception e) { - Console.WriteLine("Application failed with unexpected exception."); + Console.WriteLine("Failed with unexpected exception."); Console.WriteLine($"{e}"); return -1; }