Skip to content

Commit 826d15e

Browse files
committed
C#: Address review comments
1 parent 976e5ed commit 826d15e

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

csharp/extractor/Semmle.Extraction.CSharp/CompilerVersion.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,21 @@ public CompilerVersion(Options options)
5555
var versionInfo = FileVersionInfo.GetVersionInfo(SpecifiedCompiler);
5656

5757
var compilerDir = Path.GetDirectoryName(SpecifiedCompiler);
58-
var known_compiler_names = new Dictionary<string, string>
58+
var knownCompilerNames = new Dictionary<string, string>
5959
{
6060
{ "csc.exe", "Microsoft" },
6161
{ "csc2.exe", "Microsoft" },
6262
{ "csc.dll", "Microsoft" },
6363
{ "mcs.exe", "Novell" }
6464
};
65-
var mscorlib_exists = File.Exists(Path.Combine(compilerDir, "mscorlib.dll"));
65+
var mscorlibExists = File.Exists(Path.Combine(compilerDir, "mscorlib.dll"));
6666

67-
if (specifiedFramework == null && mscorlib_exists)
67+
if (specifiedFramework == null && mscorlibExists)
6868
{
6969
specifiedFramework = compilerDir;
7070
}
7171

72-
if (!known_compiler_names.TryGetValue(versionInfo.OriginalFilename, out var vendor))
72+
if (!knownCompilerNames.TryGetValue(versionInfo.OriginalFilename, out var vendor))
7373
{
7474
SkipExtractionBecause("the compiler name is not recognised");
7575
return;

csharp/extractor/Semmle.Extraction/TrapWriter.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,14 @@ public void Emit(ITrapEmitter emitter)
211211
/// </summary>
212212
static string ComputeHash(string filePath)
213213
{
214-
using (var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
214+
using (var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
215215
using (var shaAlg = new SHA256Managed())
216216
{
217217
var sha = shaAlg.ComputeHash(fileStream);
218-
return Convert.ToBase64String(sha);
218+
var hex = new StringBuilder(sha.Length * 2);
219+
foreach (var b in sha)
220+
hex.AppendFormat("{0:x2}", b);
221+
return hex.ToString();
219222
}
220223
}
221224

0 commit comments

Comments
 (0)