From 02cf0c69d4a67649de49aa88d10c7df92121336d Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Mon, 26 Oct 2026 11:41:33 +0100 Subject: [PATCH 1/3] C#: Uncondionally log the number of Restore Nuget Dlls using nuget.exe and log non-excluded candidates as debug info. --- .../NugetPackageRestorer.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs index fee72034781f..a87940eab9d5 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs @@ -148,10 +148,9 @@ public HashSet Restore() .Where(path => IsPathInSubfolder(path, legacyPackageDirectory.DirInfo.FullName, "tools")) .ToList(); - if (nugetPackageDllPaths.Count > 0) - { - logger.LogInfo($"Restored {nugetPackageDllPaths.Count} NuGet DLLs."); - } + + logger.LogInfo($"Restored {nugetPackageDllPaths.Count} NuGet DLLs."); + if (excludedPaths.Count > 0) { logger.LogInfo($"Excluding {excludedPaths.Count} NuGet DLLs."); @@ -163,6 +162,13 @@ public HashSet Restore() } nugetPackageDllPaths.ExceptWith(excludedPaths); + + logger.LogInfo($"Using {nugetPackageDllPaths.Count} NuGet DLLs as dependency candidates."); + foreach (var path in nugetPackageDllPaths) + { + logger.LogDebug($"Using NuGet DLL as dependency candidate: {path}"); + } + assemblyLookupLocations.UnionWith(nugetPackageDllPaths.Select(p => new AssemblyLookupLocation(p))); } catch (Exception exc) From cb5a682245e6330bff5f6f8fa3521dbd26244fd4 Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Mon, 26 Oct 2026 11:52:43 +0100 Subject: [PATCH 2/3] C#: Add some logging related to project file content. --- .../FileContent.cs | 8 ++++++++ .../NugetPackageRestorer.cs | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FileContent.cs b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FileContent.cs index f5199de1c13a..376d76032199 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FileContent.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FileContent.cs @@ -240,6 +240,14 @@ private void DoInitialize() logger.LogDebug($"Failed to read file {file}, exception: {ex}"); } } + + logger.LogInfo("Finished reading project files."); + logger.LogInfo($"Legacy project structure usage detected: {isLegacyProjectStructureUsed}"); + logger.LogInfo($"New project structure usage detected: {isNewProjectStructureUsed}"); + logger.LogInfo($"ASP.NET usage detected: {useAspNetCoreDlls}"); + logger.LogInfo($"Windows Forms usage detected: {useWindowsForms}"); + logger.LogInfo($"WPF usage detected: {useWpf}"); + logger.LogInfo($"Implicit usings enabled: {useImplicitUsings}"); } [GeneratedRegex("(?", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)] diff --git a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs index a87940eab9d5..3d4972b5637b 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs @@ -149,7 +149,7 @@ public HashSet Restore() .ToList(); - logger.LogInfo($"Restored {nugetPackageDllPaths.Count} NuGet DLLs."); + logger.LogInfo($"Restored {nugetPackageDllPaths.Count} NuGet DLLs from packages.config files using the NuGet CLI."); if (excludedPaths.Count > 0) { @@ -163,7 +163,7 @@ public HashSet Restore() nugetPackageDllPaths.ExceptWith(excludedPaths); - logger.LogInfo($"Using {nugetPackageDllPaths.Count} NuGet DLLs as dependency candidates."); + logger.LogInfo($"Using {nugetPackageDllPaths.Count} DLLs as dependency candidates from NuGet packages restored via the NuGet CLI based on packages.config files."); foreach (var path in nugetPackageDllPaths) { logger.LogDebug($"Using NuGet DLL as dependency candidate: {path}"); From 3f2a590f8d796572f6735a4d01473c8e8df569ff Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Wed, 28 Oct 2026 09:01:59 +0100 Subject: [PATCH 3/3] C#: Rename new project structure to SDK project structure. --- .../DependencyManager.cs | 2 +- .../FileContent.cs | 12 ++++++------ .../SourceGenerators/DotnetSourceGeneratorBase.cs | 2 +- .../extractor/Semmle.Extraction.Tests/FileContent.cs | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.cs b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.cs index 4bd0bb764a66..8c4fb0c79ea0 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.cs @@ -295,7 +295,7 @@ private void AddNetFrameworkDlls(ISet dllLocations, ISet string? runtimeLocation = null; - if (fileContent.IsNewProjectStructureUsed) + if (fileContent.IsSdkProjectStructureUsed) { runtimeLocation = Runtime.NetCoreRuntime; } diff --git a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FileContent.cs b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FileContent.cs index 376d76032199..7a1a4502ce5e 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FileContent.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FileContent.cs @@ -54,7 +54,7 @@ public bool IsAspNetCoreDetected { get { - return IsNewProjectStructureUsed && UseAspNetCoreDlls; + return IsSdkProjectStructureUsed && UseAspNetCoreDlls; } } @@ -102,13 +102,13 @@ public bool IsLegacyProjectStructureUsed } } - private bool isNewProjectStructureUsed = false; - public bool IsNewProjectStructureUsed + private bool isSdkProjectStructureUsed = false; + public bool IsSdkProjectStructureUsed { get { initialize.Run(); - return isNewProjectStructureUsed; + return isSdkProjectStructureUsed; } } @@ -228,7 +228,7 @@ private void DoInitialize() // Determine project structure: isLegacyProjectStructureUsed = isLegacyProjectStructureUsed || MicrosoftCSharpTargets().IsMatch(line); - isNewProjectStructureUsed = isNewProjectStructureUsed + isSdkProjectStructureUsed = isSdkProjectStructureUsed || ProjectSdk().IsMatch(line) || FrameworkReference().IsMatch(line); // TODO: we could also check `` @@ -243,7 +243,7 @@ private void DoInitialize() logger.LogInfo("Finished reading project files."); logger.LogInfo($"Legacy project structure usage detected: {isLegacyProjectStructureUsed}"); - logger.LogInfo($"New project structure usage detected: {isNewProjectStructureUsed}"); + logger.LogInfo($"SDK project structure usage detected: {isSdkProjectStructureUsed}"); logger.LogInfo($"ASP.NET usage detected: {useAspNetCoreDlls}"); logger.LogInfo($"Windows Forms usage detected: {useWindowsForms}"); logger.LogInfo($"WPF usage detected: {useWpf}"); diff --git a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/SourceGenerators/DotnetSourceGeneratorBase.cs b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/SourceGenerators/DotnetSourceGeneratorBase.cs index 6a150e8d542a..74f5c40d8198 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/SourceGenerators/DotnetSourceGeneratorBase.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/SourceGenerators/DotnetSourceGeneratorBase.cs @@ -39,7 +39,7 @@ protected override IEnumerable Run() return []; } - if (!fileContent.IsNewProjectStructureUsed) + if (!fileContent.IsSdkProjectStructureUsed) { logger.LogInfo($"Generating source files from {FileType} files is only supported for new (SDK-style) project files"); return []; diff --git a/csharp/extractor/Semmle.Extraction.Tests/FileContent.cs b/csharp/extractor/Semmle.Extraction.Tests/FileContent.cs index cbbf6ed4d24f..8d042fcc33b2 100644 --- a/csharp/extractor/Semmle.Extraction.Tests/FileContent.cs +++ b/csharp/extractor/Semmle.Extraction.Tests/FileContent.cs @@ -179,7 +179,7 @@ public void TestFileContent_LegacyProjectStructure() // Execute var isLegacy = fileContent.IsLegacyProjectStructureUsed; - var isNew = fileContent.IsNewProjectStructureUsed; + var isNew = fileContent.IsSdkProjectStructureUsed; // Verify Assert.True(isLegacy); @@ -204,7 +204,7 @@ public void TestFileContent_NewProjectStructure() // Execute var isLegacy = fileContent.IsLegacyProjectStructureUsed; - var isNew = fileContent.IsNewProjectStructureUsed; + var isNew = fileContent.IsSdkProjectStructureUsed; // Verify Assert.True(isNew);