Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ private string GetRestoreArgs(RestoreSettings restoreSettings)
args += $" /p:TargetFrameworkRootPath=\"{path}\" /p:NetCoreTargetingPackRoot=\"{path}\" /p:AllowMissingPrunePackageData=true";
}

if (restoreSettings.PathToNugetConfig != null)
{
args += $" --configfile \"{restoreSettings.PathToNugetConfig}\"";
}

if (restoreSettings.ForceReevaluation)
{
args += " --force";
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface IDotNet
IList<string> GetNugetFeedsFromFolder(string folderPath);
}

public record class RestoreSettings(string File, string PackageDirectory, bool ForceDotnetRefAssemblyFetching, string? NugetSources = null, string? PathToNugetConfig = null, bool ForceReevaluation = false, bool TargetWindows = false);
public record class RestoreSettings(string File, string PackageDirectory, bool ForceDotnetRefAssemblyFetching, string? NugetSources = null, bool ForceReevaluation = false, bool TargetWindows = false);

public partial record class RestoreResult(bool Success, IList<string> Output)
{
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -33,11 +34,11 @@ internal interface IPackagesConfigRestore
/// </summary>
internal class PackagesConfigRestoreFactory
{
public static IPackagesConfigRestore Create(FileProvider fileProvider, DependencyDirectory packageDirectory, Semmle.Util.Logging.ILogger logger, FeedManager feedManager, HashSet<string> reachableFeeds)
public static IPackagesConfigRestore Create(FileProvider fileProvider, DependencyDirectory packageDirectory, Semmle.Util.Logging.ILogger logger, FeedManager feedManager)
{
if (SystemBuildActions.Instance.IsWindows() || SystemBuildActions.Instance.IsMonoInstalled())
{
return new NugetExeWrapper(fileProvider, packageDirectory, logger, feedManager, reachableFeeds);
return new NugetExeWrapper(fileProvider, packageDirectory, logger, feedManager);
}

return new NoOpPackagesConfig(fileProvider.PackagesConfigs, logger);
Expand All @@ -64,7 +65,6 @@ private class NugetExeWrapper : IPackagesConfigRestore
/// </summary>
private readonly DependencyDirectory packageDirectory;
private readonly FeedManager feedManager;
private readonly HashSet<string> reachableFeeds;

private bool IsWindows => SystemBuildActions.Instance.IsWindows();

Expand All @@ -75,13 +75,12 @@ private class NugetExeWrapper : IPackagesConfigRestore
/// <summary>
/// Create the package manager for a specified source tree.
/// </summary>
public NugetExeWrapper(FileProvider fileProvider, DependencyDirectory packageDirectory, Semmle.Util.Logging.ILogger logger, FeedManager feedManager, HashSet<string> reachableFeeds)
public NugetExeWrapper(FileProvider fileProvider, DependencyDirectory packageDirectory, Semmle.Util.Logging.ILogger logger, FeedManager feedManager)
{
this.fileProvider = fileProvider;
this.packageDirectory = packageDirectory;
this.logger = logger;
this.feedManager = feedManager;
this.reachableFeeds = reachableFeeds;

if (fileProvider.PackagesConfigs.Count > 0)
{
Expand Down Expand Up @@ -170,7 +169,7 @@ private bool TryRestoreNugetPackage(string packagesConfig)
logger.LogInfo($"Restoring file \"{packagesConfig}\"...");

var sourcesArgument = "";
var feedsToUse = feedManager.FeedsToUse(packagesConfig, reachableFeeds).ToList();
var feedsToUse = feedManager.FeedsToUse(packagesConfig).ToList();
var useDefaultFeed = feedsToUse.Count == 0 && IsDefaultFeedReachable;

// Explicitly construct the sources to be used for the restore command when checking feed
Expand Down
8 changes: 4 additions & 4 deletions csharp/extractor/Semmle.Extraction.Tests/DotNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ public void TestDotnetRestoreProjectToDirectory2()
var dotnet = MakeDotnet(dotnetCliInvoker);

// Execute
var res = dotnet.Restore(new("myproject.csproj", "mypackages", false, null, "myconfig.config"));
var res = dotnet.Restore(new("myproject.csproj", "mypackages", false, null));

// Verify
var lastArgs = dotnetCliInvoker.GetLastArgs();
Assert.Equal("restore --no-dependencies \"myproject.csproj\" --packages \"mypackages\" /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile \"myconfig.config\"", lastArgs);
Assert.Equal("restore --no-dependencies \"myproject.csproj\" --packages \"mypackages\" /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal", lastArgs);
Assert.Equal(2, res.AssetsFilePaths.Count());
Assert.Contains("/path/to/project.assets.json", res.AssetsFilePaths);
Assert.Contains("/path/to/project2.assets.json", res.AssetsFilePaths);
Expand All @@ -148,11 +148,11 @@ public void TestDotnetRestoreProjectToDirectory3()
var dotnet = MakeDotnet(dotnetCliInvoker);

// Execute
var res = dotnet.Restore(new("myproject.csproj", "mypackages", false, null, "myconfig.config", true));
var res = dotnet.Restore(new("myproject.csproj", "mypackages", false, null, true));

// Verify
var lastArgs = dotnetCliInvoker.GetLastArgs();
Assert.Equal("restore --no-dependencies \"myproject.csproj\" --packages \"mypackages\" /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile \"myconfig.config\" --force", lastArgs);
Assert.Equal("restore --no-dependencies \"myproject.csproj\" --packages \"mypackages\" /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --force", lastArgs);
Assert.Equal(2, res.AssetsFilePaths.Count());
Assert.Contains("/path/to/project.assets.json", res.AssetsFilePaths);
Assert.Contains("/path/to/project2.assets.json", res.AssetsFilePaths);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
| All NuGet feeds reachable | 1.0 |
| Failed project restore with missing package error | 0.0 |
| Failed project restore with package source error | 0.0 |
| Failed solution restore with missing package error | 0.0 |
| Failed solution restore with package source error | 0.0 |
| Inherited NuGet feed count | 1.0 |
| NuGet feed responsiveness checked | 1.0 |
| Project files on filesystem | 1.0 |
| Reachable fallback NuGet feed count | 1.0 |
| Resource extraction enabled | 1.0 |
| Restored .NET framework variants | 1.0 |
| Restored projects through solution files | 0.0 |
| Solution files on filesystem | 0.0 |
| Source files generated | 2.0 |
| Source files on filesystem | 1.0 |
| Successfully restored project files | 1.0 |
| Successfully restored solution files | 0.0 |
| Unresolved references | 0.0 |
| UseWPF set | 0.0 |
| UseWindowsForms set | 0.0 |
| WebView extraction enabled | 1.0 |
| All NuGet feeds reachable | 1 |
| Failed project restore with missing package error | 0 |
| Failed project restore with package source error | 0 |
| Failed solution restore with missing package error | 0 |
| Failed solution restore with package source error | 0 |
| Inherited NuGet feed count | 1 |
| NuGet feed responsiveness checked | 1 |
| Project files on filesystem | 1 |
| Reachable fallback NuGet feed count | 1 |
| Resource extraction enabled | 1 |
| Restored .NET framework variants | 1 |
| Restored projects through solution files | 0 |
| Solution files on filesystem | 0 |
| Source files generated | 2 |
| Source files on filesystem | 1 |
| Successfully restored project files | 1 |
| Successfully restored solution files | 0 |
| Unresolved references | 0 |
| UseWPF set | 0 |
| UseWindowsForms set | 0 |
| WebView extraction enabled | 1 |
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import csharp
import semmle.code.csharp.commons.Diagnostics

query predicate compilationInfo(string key, float value) {
query predicate compilationInfo(string key, string value) {
key != "Resolved references" and
key != "Resolved assembly conflicts" and
not key.matches("Compiler diagnostic count for%") and
exists(Compilation c, string infoKey, string infoValue | infoValue = c.getInfo(infoKey) |
key = infoKey and
value = infoValue.toFloat()
or
not exists(infoValue.toFloat()) and
key = infoKey + ": " + infoValue and
value = 1
)
value = any(Compilation c).getInfo(key)
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
| All NuGet feeds reachable | 1.0 |
| Failed project restore with missing package error | 0.0 |
| Failed project restore with package source error | 0.0 |
| Failed solution restore with missing package error | 0.0 |
| Failed solution restore with package source error | 0.0 |
| Inherited NuGet feed count | 1.0 |
| NuGet feed responsiveness checked | 1.0 |
| Project files on filesystem | 2.0 |
| Reachable fallback NuGet feed count | 1.0 |
| Resource extraction enabled | 0.0 |
| Restored .NET framework variants | 1.0 |
| Restored projects through solution files | 2.0 |
| Solution files on filesystem | 1.0 |
| Source files generated | 1.0 |
| Source files on filesystem | 2.0 |
| Successfully restored project files | 0.0 |
| Successfully restored solution files | 1.0 |
| Unresolved references | 0.0 |
| UseWPF set | 0.0 |
| UseWindowsForms set | 0.0 |
| WebView extraction enabled | 1.0 |
| All NuGet feeds reachable | 1 |
| Failed project restore with missing package error | 0 |
| Failed project restore with package source error | 0 |
| Failed solution restore with missing package error | 0 |
| Failed solution restore with package source error | 0 |
| Inherited NuGet feed count | 1 |
| NuGet feed responsiveness checked | 1 |
| Project files on filesystem | 2 |
| Reachable fallback NuGet feed count | 1 |
| Resource extraction enabled | 0 |
| Restored .NET framework variants | 1 |
| Restored projects through solution files | 2 |
| Solution files on filesystem | 1 |
| Source files generated | 1 |
| Source files on filesystem | 2 |
| Successfully restored project files | 0 |
| Successfully restored solution files | 1 |
| Unresolved references | 0 |
| UseWPF set | 0 |
| UseWindowsForms set | 0 |
| WebView extraction enabled | 1 |
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import csharp
import semmle.code.csharp.commons.Diagnostics

query predicate compilationInfo(string key, float value) {
query predicate compilationInfo(string key, string value) {
key != "Resolved references" and
key != "Resolved assembly conflicts" and
not key.matches(["Compiler diagnostic count for%", "Extractor message count for group%"]) and
exists(Compilation c, string infoKey, string infoValue | infoValue = c.getInfo(infoKey) |
key = infoKey and
value = infoValue.toFloat()
or
not exists(infoValue.toFloat()) and
key = infoKey + ": " + infoValue and
value = 1
)
value = any(Compilation c).getInfo(key)
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
| All NuGet feeds reachable | 1.0 |
| Failed project restore with missing package error | 0.0 |
| Failed project restore with package source error | 0.0 |
| Failed solution restore with missing package error | 0.0 |
| Failed solution restore with package source error | 0.0 |
| Inherited NuGet feed count | 1.0 |
| NuGet feed responsiveness checked | 1.0 |
| Project files on filesystem | 1.0 |
| Reachable fallback NuGet feed count | 1.0 |
| Resource extraction enabled | 0.0 |
| Restored .NET framework variants | 1.0 |
| Restored projects through solution files | 0.0 |
| Solution files on filesystem | 0.0 |
| Source files generated | 1.0 |
| Source files on filesystem | 3.0 |
| Successfully restored project files | 1.0 |
| Successfully restored solution files | 0.0 |
| Unresolved references | 0.0 |
| UseWPF set | 0.0 |
| UseWindowsForms set | 1.0 |
| WebView extraction enabled | 1.0 |
| All NuGet feeds reachable | 1 |
| Failed project restore with missing package error | 0 |
| Failed project restore with package source error | 0 |
| Failed solution restore with missing package error | 0 |
| Failed solution restore with package source error | 0 |
| Inherited NuGet feed count | 1 |
| NuGet feed responsiveness checked | 1 |
| Project files on filesystem | 1 |
| Reachable fallback NuGet feed count | 1 |
| Resource extraction enabled | 0 |
| Restored .NET framework variants | 1 |
| Restored projects through solution files | 0 |
| Solution files on filesystem | 0 |
| Source files generated | 1 |
| Source files on filesystem | 3 |
| Successfully restored project files | 1 |
| Successfully restored solution files | 0 |
| Unresolved references | 0 |
| UseWPF set | 0 |
| UseWindowsForms set | 1 |
| WebView extraction enabled | 1 |
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import csharp
import semmle.code.csharp.commons.Diagnostics

query predicate compilationInfo(string key, float value) {
query predicate compilationInfo(string key, string value) {
key != "Resolved references" and
key != "Resolved assembly conflicts" and
not key.matches(["Compiler diagnostic count for%", "Extractor message count for group%"]) and
exists(Compilation c, string infoKey, string infoValue | infoValue = c.getInfo(infoKey) |
key = infoKey and
value = infoValue.toFloat()
or
not exists(infoValue.toFloat()) and
key = infoKey + ": " + infoValue and
value = 1
)
value = any(Compilation c).getInfo(key)
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
| All NuGet feeds reachable | 1.0 |
| Failed project restore with missing package error | 0.0 |
| Failed project restore with package source error | 0.0 |
| Failed solution restore with missing package error | 0.0 |
| Failed solution restore with package source error | 0.0 |
| Inherited NuGet feed count | 1.0 |
| NuGet feed responsiveness checked | 1.0 |
| Project files on filesystem | 1.0 |
| Reachable fallback NuGet feed count | 1.0 |
| Resolved assembly conflicts | 0.0 |
| Resource extraction enabled | 0.0 |
| Restored .NET framework variants | 1.0 |
| Restored projects through solution files | 0.0 |
| Solution files on filesystem | 0.0 |
| Source files generated | 0.0 |
| Source files on filesystem | 1.0 |
| Successfully restored project files | 1.0 |
| Successfully restored solution files | 0.0 |
| Unresolved references | 0.0 |
| UseWPF set | 0.0 |
| UseWindowsForms set | 0.0 |
| WebView extraction enabled | 1.0 |
| All NuGet feeds reachable | 1 |
| Failed project restore with missing package error | 0 |
| Failed project restore with package source error | 0 |
| Failed solution restore with missing package error | 0 |
| Failed solution restore with package source error | 0 |
| Inherited NuGet feed count | 1 |
| NuGet feed responsiveness checked | 1 |
| Project files on filesystem | 1 |
| Reachable fallback NuGet feed count | 1 |
| Resolved assembly conflicts | 0 |
| Resource extraction enabled | 0 |
| Restored .NET framework variants | 1 |
| Restored projects through solution files | 0 |
| Solution files on filesystem | 0 |
| Source files generated | 0 |
| Source files on filesystem | 1 |
| Successfully restored project files | 1 |
| Successfully restored solution files | 0 |
| Unresolved references | 0 |
| UseWPF set | 0 |
| UseWindowsForms set | 0 |
| WebView extraction enabled | 1 |
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import csharp
import semmle.code.csharp.commons.Diagnostics

query predicate compilationInfo(string key, float value) {
query predicate compilationInfo(string key, string value) {
key != "Resolved references" and
not key.matches("Compiler diagnostic count for%") and
exists(Compilation c, string infoKey, string infoValue | infoValue = c.getInfo(infoKey) |
key = infoKey and
value = infoValue.toFloat()
or
not exists(infoValue.toFloat()) and
key = infoKey + ": " + infoValue and
value = 1
)
value = any(Compilation c).getInfo(key)
}
Loading
Loading