From 03b525b689e21839f45fb812e515b262362b7ddd Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Thu, 18 Jun 2026 15:29:03 +0200 Subject: [PATCH] C#: Handle the places where we could risk that Path.Combine would have thrown away the first argument. --- csharp/autobuilder/Semmle.Autobuild.Shared/Project.cs | 3 ++- .../Semmle.Extraction.CSharp/Extractor/CsProjFile.cs | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/csharp/autobuilder/Semmle.Autobuild.Shared/Project.cs b/csharp/autobuilder/Semmle.Autobuild.Shared/Project.cs index 4a6acb127e3..9c2902f8973 100644 --- a/csharp/autobuilder/Semmle.Autobuild.Shared/Project.cs +++ b/csharp/autobuilder/Semmle.Autobuild.Shared/Project.cs @@ -108,7 +108,8 @@ namespace Semmle.Autobuild.Shared } var includePath = builder.Actions.PathJoin(include.Value.Split('\\', StringSplitOptions.RemoveEmptyEntries)); - ret.Add(new Project(builder, builder.Actions.PathJoin(DirectoryName, includePath))); + var path = Path.IsPathRooted(includePath) ? includePath : builder.Actions.PathJoin(DirectoryName, includePath); + ret.Add(new Project(builder, path)); } return ret; }); diff --git a/csharp/extractor/Semmle.Extraction.CSharp/Extractor/CsProjFile.cs b/csharp/extractor/Semmle.Extraction.CSharp/Extractor/CsProjFile.cs index d130e4002ff..844f16086c6 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp/Extractor/CsProjFile.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp/Extractor/CsProjFile.cs @@ -159,7 +159,11 @@ namespace Semmle.Extraction.CSharp return null; } - return Path.GetFullPath(Path.Join(projDir?.FullName ?? string.Empty, Path.DirectorySeparatorChar == '/' ? file.Replace("\\", "/") : file)); + var normalized = Path.DirectorySeparatorChar == '/' ? file.Replace("\\", "/") : file; + var path = projDir is not null && !Path.IsPathRooted(normalized) + ? Path.Join(projDir.FullName, normalized) + : normalized; + return Path.GetFullPath(path); } private readonly string[] references;