From 0f31fc7cbe6d7b3062cfd384d5da8dabfd9a446c Mon Sep 17 00:00:00 2001 From: Tamas Vajk Date: Tue, 7 Nov 2023 12:12:59 +0100 Subject: [PATCH 1/2] C#: Keep only one framework reference nuget package in standalone --- .../DependencyManager.cs | 52 ++++++++++++++----- 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.cs b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.cs index 30e0c5c0354c..e277d58c4379 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.cs @@ -82,8 +82,8 @@ public DependencyManager(string srcDir, IDependencyOptions options, ILogger logg ? new[] { options.SolutionFile } : allNonBinaryFiles.SelectFileNamesByExtension(".sln"); var dllPaths = options.DllDirs.Count == 0 - ? allFiles.SelectFileNamesByExtension(".dll").ToList() - : options.DllDirs.Select(Path.GetFullPath).ToList(); + ? allFiles.SelectFileNamesByExtension(".dll").ToHashSet() + : options.DllDirs.Select(Path.GetFullPath).ToHashSet(); if (options.UseNuGet) { @@ -107,7 +107,7 @@ public DependencyManager(string srcDir, IDependencyOptions options, ILogger logg .RequiredPaths .Select(d => Path.Combine(packageDirectory.DirInfo.FullName, d)) .ToList(); - dllPaths.AddRange(paths); + dllPaths.UnionWith(paths); LogAllUnusedPackages(dependencies); DownloadMissingPackages(allNonBinaryFiles, dllPaths); @@ -205,7 +205,7 @@ private void RemoveNugetAnalyzerReferences() } } - private void AddNetFrameworkDlls(List dllPaths) + private void AddNetFrameworkDlls(ISet dllPaths) { // Multiple dotnet framework packages could be present. // The order of the packages is important, we're adding the first one that is present in the nuget cache. @@ -218,13 +218,19 @@ private void AddNetFrameworkDlls(List dllPaths) }; var frameworkPath = packagesInPrioOrder - .Select(GetPackageDirectory) - .FirstOrDefault(dir => dir is not null); + .Select((s, index) => (Index: index, Path: GetPackageDirectory(s))) + .FirstOrDefault(pair => pair.Path is not null); - if (frameworkPath is not null) + if (frameworkPath.Path is not null) { - dllPaths.Add(frameworkPath); - progressMonitor.LogInfo("Found .NET Core/Framework DLLs in NuGet packages. Not adding installation directory."); + dllPaths.Add(frameworkPath.Path); + progressMonitor.LogInfo($"Found .NET Core/Framework DLLs in NuGet packages at {frameworkPath.Path}. Not adding installation directory."); + + for (var i = frameworkPath.Index + 1; i < packagesInPrioOrder.Length; i++) + { + RemoveNugetPackageReference(packagesInPrioOrder[i], dllPaths); + } + return; } @@ -249,7 +255,29 @@ private void AddNetFrameworkDlls(List dllPaths) dllPaths.Add(runtimeLocation); } - private void AddAspNetCoreFrameworkDlls(List dllPaths) + private void RemoveNugetPackageReference(string packagePrefix, ISet dllPaths) + { + if (!options.UseNuGet) + { + return; + } + + var packageFolder = packageDirectory.DirInfo.FullName.ToLowerInvariant(); + if (packageFolder == null) + { + return; + } + + var packagePathPrefix = Path.Combine(packageFolder, packagePrefix.ToLowerInvariant()); + var toRemove = dllPaths.Where(s => s.ToLowerInvariant().StartsWith(packagePathPrefix)); + foreach (var path in toRemove) + { + dllPaths.Remove(path); + progressMonitor.RemovedReference(path); + } + } + + private void AddAspNetCoreFrameworkDlls(ISet dllPaths) { if (!fileContent.IsNewProjectStructureUsed || !fileContent.UseAspNetCoreDlls) { @@ -269,7 +297,7 @@ private void AddAspNetCoreFrameworkDlls(List dllPaths) } } - private void AddMicrosoftWindowsDesktopDlls(List dllPaths) + private void AddMicrosoftWindowsDesktopDlls(ISet dllPaths) { if (GetPackageDirectory("microsoft.windowsdesktop.app.ref") is string windowsDesktopApp) { @@ -628,7 +656,7 @@ private void RestoreProjects(IEnumerable projects, out IEnumerable allFiles, List dllPaths) + private void DownloadMissingPackages(List allFiles, ISet dllPaths) { var nugetConfigs = allFiles.SelectFileNamesByName("nuget.config").ToArray(); string? nugetConfig = null; From a70d9691da42fab9d4eece982b8319d210ff0384 Mon Sep 17 00:00:00 2001 From: Tamas Vajk Date: Tue, 7 Nov 2023 13:39:43 +0100 Subject: [PATCH 2/2] C#: Add standalone test with multiple targets --- .../Assemblies.expected | 163 ++++++++++++++++++ .../Assemblies.ql | 15 ++ .../Program.cs | 1 + .../global.json | 5 + .../net48.csproj | 10 ++ .../net70.csproj | 10 ++ .../test.py | 3 + 7 files changed, 207 insertions(+) create mode 100644 csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/Assemblies.expected create mode 100644 csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/Assemblies.ql create mode 100644 csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/Program.cs create mode 100644 csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/global.json create mode 100644 csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/net48.csproj create mode 100644 csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/net70.csproj create mode 100644 csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/test.py diff --git a/csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/Assemblies.expected b/csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/Assemblies.expected new file mode 100644 index 000000000000..cd527ec5addb --- /dev/null +++ b/csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/Assemblies.expected @@ -0,0 +1,163 @@ +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/Microsoft.CSharp.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/Microsoft.VisualBasic.Core.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/Microsoft.VisualBasic.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/Microsoft.Win32.Primitives.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/Microsoft.Win32.Registry.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.AppContext.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Buffers.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Collections.Concurrent.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Collections.Immutable.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Collections.NonGeneric.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Collections.Specialized.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Collections.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.ComponentModel.Annotations.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.ComponentModel.DataAnnotations.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.ComponentModel.EventBasedAsync.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.ComponentModel.Primitives.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.ComponentModel.TypeConverter.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.ComponentModel.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Configuration.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Console.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Core.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Data.Common.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Data.DataSetExtensions.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Data.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Diagnostics.Contracts.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Diagnostics.Debug.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Diagnostics.DiagnosticSource.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Diagnostics.FileVersionInfo.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Diagnostics.Process.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Diagnostics.StackTrace.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Diagnostics.TextWriterTraceListener.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Diagnostics.Tools.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Diagnostics.TraceSource.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Diagnostics.Tracing.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Drawing.Primitives.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Drawing.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Dynamic.Runtime.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Formats.Asn1.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Formats.Tar.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Globalization.Calendars.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Globalization.Extensions.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Globalization.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.IO.Compression.Brotli.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.IO.Compression.FileSystem.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.IO.Compression.ZipFile.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.IO.Compression.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.IO.FileSystem.AccessControl.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.IO.FileSystem.DriveInfo.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.IO.FileSystem.Primitives.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.IO.FileSystem.Watcher.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.IO.FileSystem.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.IO.IsolatedStorage.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.IO.MemoryMappedFiles.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.IO.Pipes.AccessControl.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.IO.Pipes.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.IO.UnmanagedMemoryStream.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.IO.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Linq.Expressions.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Linq.Parallel.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Linq.Queryable.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Linq.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Memory.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Net.Http.Json.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Net.Http.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Net.HttpListener.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Net.Mail.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Net.NameResolution.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Net.NetworkInformation.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Net.Ping.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Net.Primitives.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Net.Quic.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Net.Requests.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Net.Security.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Net.ServicePoint.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Net.Sockets.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Net.WebClient.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Net.WebHeaderCollection.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Net.WebProxy.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Net.WebSockets.Client.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Net.WebSockets.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Net.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Numerics.Vectors.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Numerics.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.ObjectModel.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Reflection.DispatchProxy.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Reflection.Emit.ILGeneration.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Reflection.Emit.Lightweight.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Reflection.Emit.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Reflection.Extensions.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Reflection.Metadata.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Reflection.Primitives.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Reflection.TypeExtensions.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Reflection.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Resources.Reader.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Resources.ResourceManager.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Resources.Writer.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Runtime.CompilerServices.Unsafe.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Runtime.CompilerServices.VisualC.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Runtime.Extensions.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Runtime.Handles.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Runtime.InteropServices.JavaScript.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Runtime.InteropServices.RuntimeInformation.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Runtime.InteropServices.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Runtime.Intrinsics.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Runtime.Loader.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Runtime.Numerics.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Runtime.Serialization.Formatters.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Runtime.Serialization.Json.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Runtime.Serialization.Primitives.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Runtime.Serialization.Xml.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Runtime.Serialization.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Runtime.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Security.AccessControl.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Security.Claims.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Security.Cryptography.Algorithms.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Security.Cryptography.Cng.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Security.Cryptography.Csp.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Security.Cryptography.Encoding.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Security.Cryptography.OpenSsl.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Security.Cryptography.Primitives.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Security.Cryptography.X509Certificates.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Security.Cryptography.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Security.Principal.Windows.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Security.Principal.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Security.SecureString.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Security.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.ServiceModel.Web.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.ServiceProcess.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Text.Encoding.CodePages.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Text.Encoding.Extensions.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Text.Encoding.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Text.Encodings.Web.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Text.Json.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Text.RegularExpressions.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Threading.Channels.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Threading.Overlapped.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Threading.Tasks.Dataflow.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Threading.Tasks.Extensions.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Threading.Tasks.Parallel.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Threading.Tasks.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Threading.Thread.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Threading.ThreadPool.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Threading.Timer.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Threading.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Transactions.Local.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Transactions.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.ValueTuple.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Web.HttpUtility.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Web.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Windows.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Xml.Linq.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Xml.ReaderWriter.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Xml.Serialization.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Xml.XDocument.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Xml.XPath.XDocument.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Xml.XPath.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Xml.XmlDocument.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Xml.XmlSerializer.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.Xml.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/System.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/WindowsBase.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/mscorlib.dll | +| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/netstandard.dll | diff --git a/csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/Assemblies.ql b/csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/Assemblies.ql new file mode 100644 index 000000000000..91ee82c1c7aa --- /dev/null +++ b/csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/Assemblies.ql @@ -0,0 +1,15 @@ +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("GitHub/packages/") + "GitHub/packages/".length() + 16, s.length()) + or + result = s and + not exists(s.indexOf("GitHub/packages/")) + ) +} + +from Assembly a +select getPath(a) diff --git a/csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/Program.cs b/csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/Program.cs new file mode 100644 index 000000000000..47eee48cc791 --- /dev/null +++ b/csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/Program.cs @@ -0,0 +1 @@ +var dummy = "dummy"; \ No newline at end of file diff --git a/csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/global.json b/csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/global.json new file mode 100644 index 000000000000..1a974fd253ec --- /dev/null +++ b/csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "7.0.102" + } +} \ No newline at end of file diff --git a/csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/net48.csproj b/csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/net48.csproj new file mode 100644 index 000000000000..65bdc7d90508 --- /dev/null +++ b/csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/net48.csproj @@ -0,0 +1,10 @@ + + + + Exe + net48 + enable + enable + + + diff --git a/csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/net70.csproj b/csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/net70.csproj new file mode 100644 index 000000000000..f02677bf640f --- /dev/null +++ b/csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/net70.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/test.py b/csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/test.py new file mode 100644 index 000000000000..58074b430b29 --- /dev/null +++ b/csharp/ql/integration-tests/posix-only/standalone_dependencies_multi_target/test.py @@ -0,0 +1,3 @@ +from create_database_utils import * + +run_codeql_database_create([], lang="csharp", extra_args=["--extractor-option=buildless=true", "--extractor-option=cil=false"])