-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16541 from tamasvajk/buildless/use-nuget-config-f…
…allback C#: Use nuget feeds from nuget.config in fallback restore
- Loading branch information
Showing
15 changed files
with
179 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...ration-tests/posix-only/standalone_dependencies_nuget_config_fallback/Assemblies.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
| [...]/newtonsoft.json/13.0.3/lib/net6.0/Newtonsoft.Json.dll | |
11 changes: 11 additions & 0 deletions
11
.../integration-tests/posix-only/standalone_dependencies_nuget_config_fallback/Assemblies.ql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import csharp | ||
|
||
private string getPath(Assembly a) { | ||
not a.getCompilation().getOutputAssembly() = a and | ||
exists(string s | s = a.getFile().getAbsolutePath() | | ||
result = "[...]/" + s.substring(s.indexOf("newtonsoft.json"), s.length()) | ||
) | ||
} | ||
|
||
from Assembly a | ||
select getPath(a) |
16 changes: 16 additions & 0 deletions
16
...n-tests/posix-only/standalone_dependencies_nuget_config_fallback/CompilationInfo.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
| All Nuget feeds reachable | 0.0 | | ||
| Fallback nuget restore | 1.0 | | ||
| NuGet feed responsiveness checked | 1.0 | | ||
| Project files on filesystem | 1.0 | | ||
| Reachable fallback Nuget feed count | 2.0 | | ||
| Resolved assembly conflicts | 7.0 | | ||
| Resource extraction enabled | 0.0 | | ||
| Restored .NET framework variants | 0.0 | | ||
| Solution files on filesystem | 1.0 | | ||
| Source files generated | 0.0 | | ||
| Source files on filesystem | 1.0 | | ||
| Successfully ran fallback nuget restore | 1.0 | | ||
| Unresolved references | 0.0 | | ||
| UseWPF set | 0.0 | | ||
| UseWindowsForms set | 0.0 | | ||
| WebView extraction enabled | 1.0 | |
15 changes: 15 additions & 0 deletions
15
...gration-tests/posix-only/standalone_dependencies_nuget_config_fallback/CompilationInfo.ql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import csharp | ||
import semmle.code.csharp.commons.Diagnostics | ||
|
||
query predicate compilationInfo(string key, float 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 | ||
) | ||
} |
42 changes: 42 additions & 0 deletions
42
...ation-tests/posix-only/standalone_dependencies_nuget_config_fallback/diagnostics.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"markdownMessage": "C# analysis with build-mode 'none' completed.", | ||
"severity": "unknown", | ||
"source": { | ||
"extractorName": "csharp", | ||
"id": "csharp/autobuilder/buildless/complete", | ||
"name": "C# analysis with build-mode 'none' completed" | ||
}, | ||
"visibility": { | ||
"cliSummaryTable": true, | ||
"statusPage": false, | ||
"telemetry": true | ||
} | ||
} | ||
{ | ||
"markdownMessage": "C# with build-mode set to 'none'. This means that all C# source in the working directory will be scanned, with build tools, such as Nuget and Dotnet CLIs, only contributing information about external dependencies.", | ||
"severity": "note", | ||
"source": { | ||
"extractorName": "csharp", | ||
"id": "csharp/autobuilder/buildless/mode-active", | ||
"name": "C# with build-mode set to 'none'" | ||
}, | ||
"visibility": { | ||
"cliSummaryTable": true, | ||
"statusPage": true, | ||
"telemetry": true | ||
} | ||
} | ||
{ | ||
"markdownMessage": "Found unreachable Nuget feed in C# analysis with build-mode 'none'. This may cause missing dependencies in the analysis.", | ||
"severity": "warning", | ||
"source": { | ||
"extractorName": "csharp", | ||
"id": "csharp/autobuilder/buildless/unreachable-feed", | ||
"name": "Found unreachable Nuget feed in C# analysis with build-mode 'none'" | ||
}, | ||
"visibility": { | ||
"cliSummaryTable": true, | ||
"statusPage": true, | ||
"telemetry": true | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...ntegration-tests/posix-only/standalone_dependencies_nuget_config_fallback/proj/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...egration-tests/posix-only/standalone_dependencies_nuget_config_fallback/proj/nuget.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<packageSources> | ||
<clear /> | ||
<add key="x" value="https://www.nuget.org/api/v2/" /> | ||
</packageSources> | ||
</configuration> |
16 changes: 16 additions & 0 deletions
16
...tegration-tests/posix-only/standalone_dependencies_nuget_config_fallback/proj/proj.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFrameworks>net8.0</TargetFrameworks> | ||
</PropertyGroup> | ||
|
||
<Target Name="DeleteBinObjFolders" BeforeTargets="Clean"> | ||
<RemoveDir Directories=".\bin" /> | ||
<RemoveDir Directories=".\obj" /> | ||
</Target> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> | ||
</ItemGroup> | ||
</Project> |
19 changes: 19 additions & 0 deletions
19
...integration-tests/posix-only/standalone_dependencies_nuget_config_fallback/standalone.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.5.002.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "proj", "proj\proj.csproj", "{6ED00460-7666-4AE9-A405-4B6C8B02279A}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {4ED55A1C-066C-43DF-B32E-7EAA035985EE} | ||
EndGlobalSection | ||
EndGlobal |
14 changes: 14 additions & 0 deletions
14
csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_config_fallback/test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from create_database_utils import * | ||
from diagnostics_test_utils import * | ||
import os | ||
|
||
# os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK"] = "true" # Nuget feed check is enabled by default | ||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_TIMEOUT"] = "1" # 1ms, the GET request should fail with such short timeout | ||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_LIMIT"] = "1" # Limit the count of checks to 1 | ||
|
||
# Making sure the reachability test succeeds when doing a fallback restore: | ||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_FALLBACK_TIMEOUT"] = "1000" | ||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_FALLBACK_LIMIT"] = "5" | ||
|
||
run_codeql_database_create([], lang="csharp", extra_args=["--build-mode=none"]) | ||
check_diagnostics() |