Skip to content

Commit

Permalink
Corrected method format
Browse files Browse the repository at this point in the history
  • Loading branch information
dustin-wojciechowski committed Nov 17, 2023
1 parent 156ef22 commit d231c30
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/bgen/BindingTouch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using Mono.Options;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -649,19 +648,21 @@ void Compile (List<string> 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 ()
Expand Down

0 comments on commit d231c30

Please sign in to comment.