Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ public CompilerVersion(Options options)
specifiedFramework = compilerDir;
}

var versionInfo = FileVersionInfo.GetVersionInfo(SpecifiedCompiler);
// If csc is specified as compiler name, then attempt to read the version information from csc.dll
var compilerBinaryName = SpecifiedCompiler.EndsWith("csc") ? $"{SpecifiedCompiler}.dll" : SpecifiedCompiler;
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The EndsWith check is too broad and could incorrectly match paths ending with 'csc' that aren't the compiler binary (e.g., /path/to/misc). Use Path.GetFileNameWithoutExtension(SpecifiedCompiler) == "csc" to ensure only the actual csc compiler binary is matched.

Suggested change
var compilerBinaryName = SpecifiedCompiler.EndsWith("csc") ? $"{SpecifiedCompiler}.dll" : SpecifiedCompiler;
var compilerBinaryName = Path.GetFileNameWithoutExtension(SpecifiedCompiler) == "csc" ? $"{SpecifiedCompiler}.dll" : SpecifiedCompiler;

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion - we do however need to take the file extension into account.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we also need to make sure not to read the version information from a non-existing file 😄

var versionInfo = FileVersionInfo.GetVersionInfo(compilerBinaryName);
if (!knownCompilerNames.TryGetValue(versionInfo.OriginalFilename ?? string.Empty, out var vendor))
{
SkipExtractionBecause("the compiler name is not recognised");
Expand Down
4 changes: 4 additions & 0 deletions csharp/ql/lib/change-notes/2025-10-21-dotnet-rc2-tracing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* Added tracer support for macOS and Linux when the .NET CLI (`dotnet`) directly invokes the C# compiler (`csc`). This enhancement provides basic tracing and extraction capabilities for .NET 10 RC2 on these platforms.
5 changes: 5 additions & 0 deletions csharp/tools/tracing-config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ function RegisterExtractorPack(id)
prepend = { '--compiler', '"${compiler}"' },
order = ORDER_BEFORE
}),
CreatePatternMatcher({ '^csc$' }, MatchCompilerName,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just include '^csc$' in the list above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to the quotation in the above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per our offline discussion, the matchers have been merged, which means that the quotation has been removed for the .exe cases.

extractor, {
prepend = { '--compiler', '${compiler}' },
order = ORDER_BEFORE
}),
MsBuildMatcher,
function(compilerName, compilerPath, compilerArguments, _languageId)
-- handle cases like `dotnet exec csc.dll <args>` and `mono(-sgen64) csc.exe <args>`
Expand Down