@@ -16,69 +16,70 @@ public static void CompareBuilds(string xml1, string xml2)
1616 FileItem [ ] build2 = Deserialize ( xml2 ) ;
1717
1818 Console . WriteLine ( "Getting paths 1" ) ;
19- var build1Paths = build1 . Select ( x => Sanitize ( x . Location ) ) . Where ( x => ! ExcludedFromChecks ( x ) ) . ToHashSet ( ) ;
19+ HashSet < string > build1Paths = build1 . Select ( x => Sanitize ( x . Location ) ) . Where ( x => ! ExcludedFromChecks ( x ) ) . ToHashSet ( ) ;
2020 Console . WriteLine ( "Getting paths 2" ) ;
21- var build2Paths = build2 . Select ( x => Sanitize ( x . Location ) ) . Where ( x => ! ExcludedFromChecks ( x ) ) . ToHashSet ( ) ;
21+ HashSet < string > build2Paths = build2 . Select ( x => Sanitize ( x . Location ) ) . Where ( x => ! ExcludedFromChecks ( x ) ) . ToHashSet ( ) ;
2222
2323 Console . WriteLine ( "Getting common paths" ) ;
24- var commonPaths = build1Paths . Intersect ( build2Paths ) . ToHashSet ( ) ;
24+ HashSet < string > commonPaths = build1Paths . Intersect ( build2Paths ) . ToHashSet ( ) ;
2525
2626 Console . WriteLine ( "Getting unique paths 1" ) ;
27- var uniqueBuild1 = build1Paths . Where ( x => ! commonPaths . Contains ( x ) ) . ToHashSet ( ) ;
27+ HashSet < string > uniqueBuild1 = build1Paths . Where ( x => ! commonPaths . Contains ( x ) ) . ToHashSet ( ) ;
2828 Console . WriteLine ( "Getting unique paths 2" ) ;
29- var uniqueBuild2 = build2Paths . Where ( x => ! commonPaths . Contains ( x ) ) . ToHashSet ( ) ;
29+ HashSet < string > uniqueBuild2 = build2Paths . Where ( x => ! commonPaths . Contains ( x ) ) . ToHashSet ( ) ;
3030
3131 Console . WriteLine ( "Getting common resources" ) ;
32- var commonResources = commonPaths . Where ( x => x . Contains ( @"\.rsrc\" ) ) . ToHashSet ( ) ;
32+ HashSet < string > commonResources = commonPaths . Where ( x => x . Contains ( @"\.rsrc\" ) ) . ToHashSet ( ) ;
3333
34- Console . WriteLine ( $ "{ commonPaths . Count ( ) } common paths") ;
35- Console . WriteLine ( $ "{ commonResources . Count ( ) } common resources") ;
36- Console . WriteLine ( $ "{ uniqueBuild1 . Count ( ) } unique 1") ;
37- Console . WriteLine ( $ "{ uniqueBuild2 . Count ( ) } unique 2") ;
34+ Console . WriteLine ( $ "{ commonPaths . Count } common paths") ;
35+ Console . WriteLine ( $ "{ commonResources . Count } common resources") ;
36+ Console . WriteLine ( $ "{ uniqueBuild1 . Count } unique 1") ;
37+ Console . WriteLine ( $ "{ uniqueBuild2 . Count } unique 2") ;
3838
3939 Console . WriteLine ( "Processing common resources" ) ;
40- HashSet < string > modifiedResources = new HashSet < string > ( ) ;
40+ HashSet < string > modifiedResources = new ( ) ;
4141
4242 long total = commonResources . Count ;
4343 long counter = 0 ;
4444
45- foreach ( var resource in commonResources )
45+ foreach ( string resource in commonResources )
4646 {
4747 Console . Title = $ "Processing { counter } /{ total } ";
48- var item1 = GetFileItem ( build1 , resource ) ;
49- var item2 = GetFileItem ( build2 , resource ) ;
48+ FileItem item1 = GetFileItem ( build1 , resource ) ;
49+ FileItem item2 = GetFileItem ( build2 , resource ) ;
5050
5151 if ( item1 . Hash != null )
5252 {
53- if ( item1 . Hash . SHA1 != item2 . Hash . SHA1 )
53+ if ( item1 . Hash . Sha1 != item2 . Hash . Sha1 )
5454 {
5555 Console . WriteLine ( "modified" ) ;
5656 modifiedResources . Add ( item1 . Location ) ;
5757 }
5858 }
59+
5960 counter ++ ;
6061 }
6162
6263 Console . WriteLine ( ) ;
6364 Console . WriteLine ( "Files unique to build 1" ) ;
6465 Console . WriteLine ( ) ;
65- foreach ( var file in uniqueBuild1 )
66+ foreach ( string file in uniqueBuild1 )
6667 {
6768 Console . WriteLine ( file ) ;
6869 }
6970
7071 Console . WriteLine ( ) ;
7172 Console . WriteLine ( "Files unique to build 2" ) ;
7273 Console . WriteLine ( ) ;
73- foreach ( var file in uniqueBuild2 )
74+ foreach ( string file in uniqueBuild2 )
7475 {
7576 Console . WriteLine ( file ) ;
7677 }
7778
7879 Console . WriteLine ( ) ;
7980 Console . WriteLine ( "Modified resources between both builds" ) ;
8081 Console . WriteLine ( ) ;
81- foreach ( var file in modifiedResources )
82+ foreach ( string file in modifiedResources )
8283 {
8384 Console . WriteLine ( file ) ;
8485 }
@@ -88,77 +89,77 @@ private static string Sanitize(string path1)
8889 {
8990 if ( path1 . Contains ( @"installedrepository\" , StringComparison . InvariantCultureIgnoreCase ) )
9091 {
91- var fold1t = path1 . ToLower ( ) . Split ( @"installedrepository\" ) [ 0 ] ;
92- var fold1 = path1 . ToLower ( ) . Split ( @"installedrepository\" ) [ 1 ] ;
92+ string fold1T = path1 . ToLower ( ) . Split ( @"installedrepository\" ) [ 0 ] ;
93+ string fold1 = path1 . ToLower ( ) . Split ( @"installedrepository\" ) [ 1 ] ;
9394
94- var number = fold1 . Count ( x => x == '_' ) ;
95+ int number = fold1 . Count ( x => x == '_' ) ;
9596 if ( number < 1 )
9697 {
9798 return path1 ;
9899 }
99100
100- var fsplit1 = fold1 . Split ( @"\" ) ;
101+ string [ ] fsplit1 = fold1 . Split ( @"\" ) ;
101102
102- var san1 = string . Join ( "_" , fsplit1 [ 0 ] . Split ( "_" ) [ 0 ..^ 1 ] ) ;
103+ string san1 = string . Join ( "_" , fsplit1 [ 0 ] . Split ( "_" ) [ ..^ 1 ] ) ;
103104
104105 if ( fsplit1 . Length < 2 )
105106 {
106107 return san1 ;
107108 }
108109
109- var f1 = fold1t + "installedrepository\\ " + san1 + "\\ " + string . Join ( "\\ " , fsplit1 [ 1 ..^ 0 ] ) ;
110+ string f1 = fold1T + "installedrepository\\ " + san1 + "\\ " + string . Join ( "\\ " , fsplit1 [ 1 ..] ) ;
110111 return f1 ;
111112 }
112- else if ( path1 . Contains ( @"build\filerepository\" , StringComparison . InvariantCultureIgnoreCase ) )
113+
114+ if ( path1 . Contains ( @"build\filerepository\" , StringComparison . InvariantCultureIgnoreCase ) )
113115 {
114- var fold1t = path1 . ToLower ( ) . Split ( @"build\filerepository\" ) [ 0 ] ;
115- var fold1 = path1 . ToLower ( ) . Split ( @"build\filerepository\" ) [ 1 ] ;
116+ string fold1T = path1 . ToLower ( ) . Split ( @"build\filerepository\" ) [ 0 ] ;
117+ string fold1 = path1 . ToLower ( ) . Split ( @"build\filerepository\" ) [ 1 ] ;
116118
117- var number = fold1 . Count ( x => x == '_' ) ;
119+ int number = fold1 . Count ( x => x == '_' ) ;
118120 if ( number < 1 )
119121 {
120122 return path1 ;
121123 }
122124
123- var fsplit1 = fold1 . Split ( @"\" ) ;
125+ string [ ] fsplit1 = fold1 . Split ( @"\" ) ;
124126
125- var san1 = string . Join ( "_" , fsplit1 [ 0 ] . Split ( "_" ) [ 0 ..^ 1 ] ) ;
127+ string san1 = string . Join ( "_" , fsplit1 [ 0 ] . Split ( "_" ) [ ..^ 1 ] ) ;
126128
127129 if ( fsplit1 . Length < 2 )
128130 {
129131 return san1 ;
130132 }
131133
132- var f1 = fold1t + "build\\ filerepository\\ " + san1 + "\\ " + string . Join ( "\\ " , fsplit1 [ 1 ..^ 0 ] ) ;
134+ string f1 = fold1T + "build\\ filerepository\\ " + san1 + "\\ " + string . Join ( "\\ " , fsplit1 [ 1 ..] ) ;
133135 return f1 ;
134136 }
135- else if ( path1 . Contains ( @"Windows\winsxs\" , StringComparison . InvariantCultureIgnoreCase ) )
137+
138+ if ( path1 . Contains ( @"Windows\winsxs\" , StringComparison . InvariantCultureIgnoreCase ) )
136139 {
137- var fold1t = path1 . ToLower ( ) . Split ( @"windows\winsxs\" ) [ 0 ] ;
138- var fold1 = path1 . ToLower ( ) . Split ( @"windows\winsxs\" ) [ 1 ] ;
140+ string fold1T = path1 . ToLower ( ) . Split ( @"windows\winsxs\" ) [ 0 ] ;
141+ string fold1 = path1 . ToLower ( ) . Split ( @"windows\winsxs\" ) [ 1 ] ;
139142
140- var number = fold1 . Count ( x => x == '_' ) ;
143+ int number = fold1 . Count ( x => x == '_' ) ;
141144 if ( number < 1 )
142145 {
143146 return path1 ;
144147 }
145148
146- var fsplit1 = fold1 . Split ( @"\" ) ;
149+ string [ ] fsplit1 = fold1 . Split ( @"\" ) ;
147150
148- var san1 = string . Join ( "_" , fsplit1 [ 0 ] . Split ( "_" ) [ 0 ..^ 1 ] ) ;
151+ string san1 = string . Join ( "_" , fsplit1 [ 0 ] . Split ( "_" ) [ ..^ 1 ] ) ;
149152
150153 if ( fsplit1 . Length < 2 )
151154 {
152155 return san1 ;
153156 }
154157
155- var f1 = fold1t + "windows\\ winsxs\\ " + san1 + "\\ " + string . Join ( "\\ " , fsplit1 [ 1 ..^ 0 ] ) ;
158+ string f1 = fold1T + "windows\\ winsxs\\ " + san1 + "\\ " + string . Join ( "\\ " , fsplit1 [ 1 ..] ) ;
156159 return f1 ;
157160 }
158- else
159- {
160- return path1 ;
161- }
161+
162+ return path1 ;
162163 }
163164
164165 private static FileItem GetFileItem ( FileItem [ ] array , string path )
@@ -171,7 +172,9 @@ private static bool ExcludedFromChecks(string path)
171172 string index = @"install.wim\3\" ;
172173
173174 if ( ! path . Contains ( index , StringComparison . InvariantCultureIgnoreCase ) )
175+ {
174176 return true ;
177+ }
175178
176179 if ( path . Contains ( @"\.rsrc\" ) )
177180 {
@@ -186,13 +189,13 @@ private static bool ExcludedFromChecks(string path)
186189
187190 private static FileItem [ ] Deserialize ( string path )
188191 {
189- XmlSerializer deserializer = new XmlSerializer ( typeof ( FileItem [ ] ) ) ;
192+ XmlSerializer deserializer = new ( typeof ( FileItem [ ] ) ) ;
190193 TextReader reader = new StreamReader ( path ) ;
191194 object obj = deserializer . Deserialize ( reader ) ;
192- FileItem [ ] XmlData = ( FileItem [ ] ) obj ;
195+ FileItem [ ] xmlData = ( FileItem [ ] ) obj ;
193196 reader . Close ( ) ;
194197
195- return XmlData ;
198+ return xmlData ;
196199 }
197200 }
198- }
201+ }
0 commit comments