Skip to content

Commit def522d

Browse files
committed
C#: Make sure that the file exists before attempting to get version info.
1 parent af5622a commit def522d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public CompilerVersion(Options options)
7676

7777
// If csc is specified as compiler name, then attempt to read the version information from csc.dll
7878
var compilerBinaryName = Path.GetFileName(SpecifiedCompiler) == "csc" ? $"{SpecifiedCompiler}.dll" : SpecifiedCompiler;
79-
var versionInfo = FileVersionInfo.GetVersionInfo(compilerBinaryName);
79+
var versionInfo = FileVersionInfo.GetVersionInfo(File.Exists(compilerBinaryName) ? compilerBinaryName : SpecifiedCompiler);
8080
if (!knownCompilerNames.TryGetValue(versionInfo.OriginalFilename ?? string.Empty, out var vendor))
8181
{
8282
SkipExtractionBecause("the compiler name is not recognised");

0 commit comments

Comments
 (0)