1
1
using System ;
2
+ using System . Reflection ;
2
3
using System . Reflection . PortableExecutable ;
3
4
using CompatibilityChecker ;
4
5
5
- namespace CompatibilityCheckerCLI
6
+ namespace CompatibilityCheckerCoreCLI
6
7
{
7
8
using File = System . IO . File ;
8
9
using FileInfo = System . IO . FileInfo ;
@@ -18,11 +19,15 @@ private static void Main(string[] args)
18
19
}
19
20
else
20
21
{
21
-
22
+
22
23
FileInfo referenceFile = new FileInfo ( args [ 0 ] ) ;
23
24
FileInfo newFile = new FileInfo ( args [ 1 ] ) ;
24
25
if ( referenceFile . Exists && newFile . Exists )
25
26
{
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 ) ;
26
31
using ( PEReader referenceAssembly = new PEReader ( File . OpenRead ( referenceFile . FullName ) ) )
27
32
{
28
33
using ( PEReader newAssembly = new PEReader ( File . OpenRead ( newFile . FullName ) ) )
@@ -31,19 +36,32 @@ private static void Main(string[] args)
31
36
analyzer . Run ( ) ;
32
37
if ( analyzer . HasRun )
33
38
{
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 )
36
41
{
37
42
Environment . ExitCode = - 2 ;
38
43
}
39
- } else
44
+ }
45
+ else
40
46
{
41
47
Environment . ExitCode = - 1 ;
42
48
}
43
49
}
44
50
}
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 ) ;
45
59
}
46
60
}
61
+ #if DEBUG
62
+ Console . WriteLine ( "Done. Press any key to exit." ) ;
63
+ Console . ReadKey ( ) ;
64
+ #endif
47
65
}
48
66
}
49
67
}
0 commit comments