Skip to content

Commit 251bf9c

Browse files
committed
Order is important
1 parent fe5f114 commit 251bf9c

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

ProtectionScan/Program.cs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
using System;
22
using System.IO;
3-
#if NET35_OR_GREATER || NETCOREAPP
4-
using System.Linq;
5-
#endif
63
using BinaryObjectScanner;
74

85
namespace ProtectionScan
@@ -107,25 +104,22 @@ private static void WriteProtectionResultFile(string path, ProtectionDictionary?
107104
Console.WriteLine("Could not open protection log file for writing. Only a console log will be provided.");
108105
}
109106

110-
#if NET20
111-
var keysArr = new string[protections.Keys.Count];
112-
protections.Keys.CopyTo(keysArr, 0);
113-
Array.Sort(keysArr);
114-
foreach (string key in keysArr)
115-
#else
116-
foreach (string key in protections.Keys.OrderBy(k => k))
117-
#endif
107+
// Sort the keys for consistent output
108+
string[] keys = [.. protections.Keys];
109+
Array.Sort(keys);
110+
111+
// Loop over all keys
112+
foreach (string key in keys)
118113
{
119114
// Skip over files with no protection
120115
if (protections[key] == null || protections[key].Count == 0)
121116
continue;
122117

123-
#if NET20
118+
// Sort the detected protections for consistent output
124119
string[] fileProtections = [.. protections[key]];
125120
Array.Sort(fileProtections);
126-
#else
127-
string[] fileProtections = [.. protections[key].OrderBy(p => p)];
128-
#endif
121+
122+
// Format and output the line
129123
string line = $"{key}: {string.Join(", ", fileProtections)}";
130124
Console.WriteLine(line);
131125
sw?.WriteLine(line);

0 commit comments

Comments
 (0)