Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return IIDOptimizer exit code #960

Merged
merged 3 commits into from
Aug 18, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions src/Perf/IIDOptimizer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -53,7 +53,8 @@ static async Task Main(string[] args)
rootCommand.AddOption(_references);

rootCommand.Handler = CommandHandler.Create<string, string, IEnumerable<FileInfo>>(GuidPatch);
await rootCommand.InvokeAsync(args);
Task<int> retVal = rootCommand.InvokeAsync(args);
return retVal.Result;
}

private static ReaderParameters MakeReaderParams(ReferenceAssemblyResolver resolver)
Expand All @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -133,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.");
j0shuams marked this conversation as resolved.
Show resolved Hide resolved
Console.WriteLine($"{e}");
return -1;
}
}
}
}