Skip to content

Commit 5e502ed

Browse files
committed
Added extra messages to CLI output and added Debug code to help debug in VS.
1 parent 4399eef commit 5e502ed

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

CompatibilityCheckerCLI/Program.cs

+23-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
using System;
2+
using System.Reflection;
23
using System.Reflection.PortableExecutable;
34
using CompatibilityChecker;
45

5-
namespace CompatibilityCheckerCLI
6+
namespace CompatibilityCheckerCoreCLI
67
{
78
using File = System.IO.File;
89
using FileInfo = System.IO.FileInfo;
@@ -18,11 +19,15 @@ private static void Main(string[] args)
1819
}
1920
else
2021
{
21-
22+
2223
FileInfo referenceFile = new FileInfo(args[0]);
2324
FileInfo newFile = new FileInfo(args[1]);
2425
if (referenceFile.Exists && newFile.Exists)
2526
{
27+
var refName = AssemblyName.GetAssemblyName(referenceFile.FullName);
28+
var newName = AssemblyName.GetAssemblyName(newFile.FullName);
29+
Console.WriteLine("Using '{0}' as the reference assembly.", refName.FullName);
30+
Console.WriteLine("Using '{0}' as the new assembly.", refName.FullName);
2631
using (PEReader referenceAssembly = new PEReader(File.OpenRead(referenceFile.FullName)))
2732
{
2833
using (PEReader newAssembly = new PEReader(File.OpenRead(newFile.FullName)))
@@ -31,19 +36,32 @@ private static void Main(string[] args)
3136
analyzer.Run();
3237
if (analyzer.HasRun)
3338
{
34-
Console.Error.WriteLine(string.Format("Analyzer done. {0} errors, {1} warnings, {2} informational items.",analyzer.ResultStatistics.SeverityCounts.error, analyzer.ResultStatistics.SeverityCounts.warning, analyzer.ResultStatistics.SeverityCounts.information));
35-
if(analyzer.ResultStatistics.SeverityCounts.error > 0)
39+
Console.Error.WriteLine(string.Format("Analyzer done. {0} errors, {1} warnings, {2} informational items.", analyzer.ResultStatistics.SeverityCounts.error, analyzer.ResultStatistics.SeverityCounts.warning, analyzer.ResultStatistics.SeverityCounts.information));
40+
if (analyzer.ResultStatistics.SeverityCounts.error > 0)
3641
{
3742
Environment.ExitCode = -2;
3843
}
39-
} else
44+
}
45+
else
4046
{
4147
Environment.ExitCode = -1;
4248
}
4349
}
4450
}
51+
52+
}
53+
else
54+
{
55+
if (!referenceFile.Exists)
56+
Console.Error.WriteLine("Reference file '{0}' not found or inaccessible.", referenceFile.FullName);
57+
if (!newFile.Exists)
58+
Console.Error.WriteLine("New file '{0}' not found or inaccessible.", newFile.FullName);
4559
}
4660
}
61+
#if DEBUG
62+
Console.WriteLine("Done. Press any key to exit.");
63+
Console.ReadKey();
64+
#endif
4765
}
4866
}
4967
}

CompatibilityCheckerCoreCLI/Program.cs

+17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Reflection;
23
using System.Reflection.PortableExecutable;
34
using CompatibilityChecker;
45

@@ -23,6 +24,10 @@ private static void Main(string[] args)
2324
FileInfo newFile = new FileInfo(args[1]);
2425
if (referenceFile.Exists && newFile.Exists)
2526
{
27+
var refName = AssemblyName.GetAssemblyName(referenceFile.FullName);
28+
var newName = AssemblyName.GetAssemblyName(newFile.FullName);
29+
Console.WriteLine("Using '{0}' as the reference assembly.", refName.FullName);
30+
Console.WriteLine("Using '{0}' as the new assembly.", refName.FullName);
2631
using (PEReader referenceAssembly = new PEReader(File.OpenRead(referenceFile.FullName)))
2732
{
2833
using (PEReader newAssembly = new PEReader(File.OpenRead(newFile.FullName)))
@@ -43,8 +48,20 @@ private static void Main(string[] args)
4348
}
4449
}
4550
}
51+
52+
}
53+
else
54+
{
55+
if (!referenceFile.Exists)
56+
Console.Error.WriteLine("Reference file '{0}' not found or inaccessible.", referenceFile.FullName);
57+
if (!newFile.Exists)
58+
Console.Error.WriteLine("New file '{0}' not found or inaccessible.", newFile.FullName);
4659
}
4760
}
61+
#if DEBUG
62+
Console.WriteLine("Done. Press any key to exit.");
63+
Console.ReadKey();
64+
#endif
4865
}
4966
}
5067
}

CompatibilityCheckerCoreCLI/Properties/launchSettings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"profiles": {
33
"CompatibilityCheckerCoreExample": {
44
"commandName": "Project",
5-
"commandLineArgs": "\"F:\\Users\\Erwin\\Documents\\GitHub\\dotnet-compatibility\\MediaBrowser.Common.10.0.1.dll\" \"F:\\Users\\Erwin\\Documents\\GitHub\\dotnet-compatibility\\MediaBrowser.Common.10.1.0.dll\""
5+
"commandLineArgs": "\"..\\..\\..\\..\\MediaBrowser.Common.10.1.0.dll\" \"..\\..\\..\\..\\MediaBrowser.Common.10.2.0.dll\""
66
}
77
}
88
}

0 commit comments

Comments
 (0)