Merge pull request #20663 from michaelnebel/csharp/dotnet10rc2traced

C#: Tracer support for invoking `csc` directly.
This commit is contained in:
Michael Nebel
2025-10-22 15:36:34 +02:00
committed by GitHub
11 changed files with 53 additions and 3 deletions

View File

@@ -74,7 +74,9 @@ namespace Semmle.Extraction.CSharp
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 = Path.GetFileName(SpecifiedCompiler) == "csc" ? $"{SpecifiedCompiler}.dll" : SpecifiedCompiler;
var versionInfo = FileVersionInfo.GetVersionInfo(File.Exists(compilerBinaryName) ? compilerBinaryName : SpecifiedCompiler);
if (!knownCompilerNames.TryGetValue(versionInfo.OriginalFilename ?? string.Empty, out var vendor))
{
SkipExtractionBecause("the compiler name is not recognised");

View File

@@ -0,0 +1 @@
Console.WriteLine($"<arguments>{string.Join(",", args)}</arguments>");

View File

@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,5 @@
{
"sdk": {
"version": "10.0.100-rc.2.25502.107"
}
}

View File

@@ -0,0 +1,6 @@
import os
import runs_on
@runs_on.linux
def test(codeql, csharp):
codeql.database.create()

View File

@@ -0,0 +1 @@
Console.WriteLine($"<arguments>{string.Join(",", args)}</arguments>");

View File

@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,5 @@
{
"sdk": {
"version": "10.0.100-rc.2.25502.107"
}
}

View File

@@ -0,0 +1,6 @@
import os
import runs_on
@runs_on.windows
def test(codeql, csharp):
codeql.database.create()

View File

@@ -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.

View File

@@ -221,9 +221,9 @@ function RegisterExtractorPack(id)
}
local posixMatchers = {
DotnetMatcherBuild,
CreatePatternMatcher({ '^mcs%.exe$', '^csc%.exe$' }, MatchCompilerName,
CreatePatternMatcher({ '^mcs%.exe$', '^csc%.exe$', '^csc$' }, MatchCompilerName,
extractor, {
prepend = { '--compiler', '"${compiler}"' },
prepend = { '--compiler', '${compiler}' },
order = ORDER_BEFORE
}),
MsBuildMatcher,