From d231c303a788bea1f85f54d2be15a1cc2b31f2a1 Mon Sep 17 00:00:00 2001 From: Dustin Wojciechowski Date: Thu, 16 Nov 2023 20:46:20 -0800 Subject: [PATCH] Corrected method format --- src/bgen/BindingTouch.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/bgen/BindingTouch.cs b/src/bgen/BindingTouch.cs index 0aefe21c97aa..378158a96023 100644 --- a/src/bgen/BindingTouch.cs +++ b/src/bgen/BindingTouch.cs @@ -31,6 +31,7 @@ using System.IO; using System.Linq; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Reflection; using Mono.Options; @@ -444,10 +445,8 @@ int Main3 (string [] args) references.ToArray ()), "mscorlib" ); - Assembly? api = TryLoadApi (tmpass); - Assembly? baselib = TryLoadApi (baselibdll); - if (api is null || baselib is null) + if (!TryLoadApi (tmpass, out Assembly? api) || !TryLoadApi (baselibdll, out Assembly? baselib)) return 1; attributeManager ??= new AttributeManager (this); @@ -649,19 +648,21 @@ void Compile (List arguments, int errorCode, string tmpdir) Console.WriteLine (output); } - Assembly? TryLoadApi (string? name) + bool TryLoadApi (string? name, [NotNullWhen (true)] out Assembly? assembly) { - if (name is null) - return null; + assembly = null; + if (string.IsNullOrEmpty (name)) + return false; try { - return universe?.LoadFromAssemblyPath (name); + assembly = universe?.LoadFromAssemblyPath (name); } catch (Exception e) { if (Driver.Verbosity > 0) Console.WriteLine (e); Console.Error.WriteLine ("Error loading {0}", name); - return null; } + + return assembly is not null; } static string GetWorkDir ()