Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
10 changes: 9 additions & 1 deletion csharp/autobuilder/Semmle.Autobuild.Shared/Autobuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,16 @@ protected Autobuilder(IBuildActions actions, TAutobuildOptions options, Diagnost
if (ret is not null)
return ret;

// Then look for language specific solution files, e.g. `.slnx` files
if (Options.Language.SolutionExtension is string solutionExtension)
{
ret = FindFiles(solutionExtension, f => new Solution<TAutobuildOptions>(this, f, false))?.ToList();
if (ret is not null)
return ret;
}

// Finally look for language specific project files, e.g. `.csproj` files
ret = FindFiles(this.Options.Language.ProjectExtension, f => new Project<TAutobuildOptions>(this, f))?.ToList();
ret = FindFiles(Options.Language.ProjectExtension, f => new Project<TAutobuildOptions>(this, f))?.ToList();
return ret ?? new List<IProjectOrSolution>();
});

Expand Down
1 change: 1 addition & 0 deletions csharp/autobuilder/Semmle.Autobuild.Shared/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ codeql_csharp_library(
deps = [
"//csharp/extractor/Semmle.Util",
"@paket.main//microsoft.build",
"@paket.main//microsoft.visualstudio.solutionpersistence",
],
)
3 changes: 1 addition & 2 deletions csharp/autobuilder/Semmle.Autobuild.Shared/Solution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
using System.Linq;
using Microsoft.Build.Construction;
using Microsoft.Build.Exceptions;
using Semmle.Util.Logging;

namespace Semmle.Autobuild.Shared
{
/// <summary>
/// A solution file, extension .sln.
/// A solution file, extension .sln or .slnx.
/// </summary>
public interface ISolution : IProjectOrSolution
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Microsoft.Build
Microsoft.VisualStudio.SolutionPersistence
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ codeql_csharp_library(
deps = [
"//csharp/extractor/Semmle.Extraction.CSharp",
"//csharp/extractor/Semmle.Util",
"@paket.main//microsoft.visualstudio.solutionpersistence",
"@paket.main//newtonsoft.json",
"@paket.main//nuget.versioning",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public FileProvider(DirectoryInfo sourceDir, ILogger logger)
smallNonBinary = new Lazy<string[]>(() => ReturnAndLogFiles("small non-binary", SelectSmallFiles(allNonBinary.Value).SelectFileNames().ToArray()));
sources = new Lazy<string[]>(() => SelectTextFileNamesByExtension("source", ".cs"));
projects = new Lazy<string[]>(() => SelectTextFileNamesByExtension("project", ".csproj"));
solutions = new Lazy<string[]>(() => SelectTextFileNamesByExtension("solution", ".sln"));
solutions = new Lazy<string[]>(() => SelectTextFileNamesByExtension("solution", ".sln", ".slnx"));
dlls = new Lazy<string[]>(() => SelectBinaryFileNamesByExtension("DLL", ".dll"));
nugetConfigs = new Lazy<string[]>(() => SelectTextFileNamesByName("nuget.config"));
globalJsons = new Lazy<string[]>(() => SelectTextFileNamesByName("global.json"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace Semmle.Extraction.CSharp.DependencyFetching
{
/// <summary>
/// Access data in a .sln file.
/// Access data in a .sln or .slnx file.
/// </summary>
internal class SolutionFile
{
Expand All @@ -17,7 +17,7 @@ internal class SolutionFile
/// <summary>
/// Read the file.
/// </summary>
/// <param name="filename">The filename of the .sln.</param>
/// <param name="filename">The filename of the .sln or .slnx.</param>
public SolutionFile(string filename)
{
// SolutionFile.Parse() expects a rooted path.
Expand All @@ -26,7 +26,7 @@ public SolutionFile(string filename)
}

/// <summary>
/// Projects directly included in the .sln file.
/// Projects directly included in the .sln or .slnx file.
/// </summary>
public IEnumerable<string> MsBuildProjects
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Microsoft.VisualStudio.SolutionPersistence
Newtonsoft.Json
NuGet.Versioning
14 changes: 10 additions & 4 deletions csharp/extractor/Semmle.Util/Language.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,27 @@
{
public sealed class Language
{
public static Language Cpp { get; } = new Language(".vcxproj", "CPP");
public static Language CSharp { get; } = new Language(".csproj", "CSHARP");
public static Language Cpp { get; } = new Language("CPP", ".vcxproj");
public static Language CSharp { get; } = new Language("CSHARP", ".csproj", ".slnx");

public bool ProjectFileHasThisLanguage(string path) =>
System.IO.Path.GetExtension(path) == ProjectExtension;

public string ProjectExtension { get; }
public string? SolutionExtension { get; }
public string UpperCaseName { get; }

private Language(string extension, string name)
private Language(string name, string projectExtension)
{
ProjectExtension = extension;
ProjectExtension = projectExtension;
UpperCaseName = name;
}
Comment on lines +15 to 19
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The parameter order has been changed in the constructor, which could be a breaking change if this constructor is called from other places in the codebase. However, this appears to be intentional to make the API more readable with the name parameter first. Note that both constructors have their parameters swapped from (extension, name) to (name, extension).

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.

The constructors are private.


private Language(string name, string projectExtension, string solutionExtension) : this(name, projectExtension)
{
SolutionExtension = solutionExtension;
}

public override string ToString() =>
ProjectExtension == Cpp.ProjectExtension ? "C/C++" : "C#";
}
Expand Down
1 change: 1 addition & 0 deletions csharp/paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ nuget Microsoft.NET.Test.Sdk
nuget Microsoft.CodeAnalysis.CSharp 5.0.0
nuget Microsoft.CodeAnalysis 5.0.0
nuget Microsoft.Build 18.0.2
nuget Microsoft.VisualStudio.SolutionPersistence
61 changes: 31 additions & 30 deletions csharp/paket.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading