Skip to content

Commit ca7fa2e

Browse files
committed
C#: Use ASP.NET dlls when needed and available.
1 parent b71c410 commit ca7fa2e

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

csharp/extractor/Semmle.Extraction.CSharp.Standalone/BuildAnalysis.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,19 @@ public BuildAnalysis(Options options, ProgressMonitor progressMonitor)
6363

6464
var dllDirNames = options.DllDirs.Select(Path.GetFullPath).ToList();
6565

66-
// Find DLLs in the .Net Framework
66+
// Find DLLs in the .Net / Asp.Net Framework
6767
if (options.ScanNetFrameworkDlls)
6868
{
69-
var runtimeLocation = new Runtime(dotnet).GetRuntime(options.UseSelfContainedDotnet);
70-
progressMonitor.Log(Util.Logging.Severity.Info, $"Runtime location selected: {runtimeLocation}");
69+
var runtime = new Runtime(dotnet);
70+
var runtimeLocation = runtime.GetRuntime(options.UseSelfContainedDotnet);
71+
progressMonitor.LogInfo($".NET runtime location selected: {runtimeLocation}");
7172
dllDirNames.Add(runtimeLocation);
73+
74+
if (UseAspNetDlls() && runtime.GetAspRuntime() is string aspRuntime)
75+
{
76+
progressMonitor.LogInfo($"ASP.NET runtime location selected: {aspRuntime}");
77+
dllDirNames.Add(aspRuntime);
78+
}
7279
}
7380

7481
if (options.UseMscorlib)

csharp/extractor/Semmle.Extraction.CSharp.Standalone/Runtime.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,6 @@ public string GetRuntime(bool useSelfContained)
159159
return netCoreVersion.FullPath;
160160
}
161161

162-
// Location of the newest ASP.NET Core Runtime.
163-
if (newestRuntimes.TryGetValue(aspNetCoreApp, out var aspNetCoreVersion))
164-
{
165-
return aspNetCoreVersion.FullPath;
166-
}
167-
168162
if (DesktopRuntimes.Any())
169163
{
170164
return DesktopRuntimes.First();
@@ -173,5 +167,17 @@ public string GetRuntime(bool useSelfContained)
173167
// A bad choice if it's the self-contained runtime distributed in codeql dist.
174168
return ExecutingRuntime;
175169
}
170+
171+
public string? GetAspRuntime()
172+
{
173+
var newestRuntimes = GetNewestRuntimes();
174+
175+
// Location of the newest ASP.NET Core Runtime.
176+
if (newestRuntimes.TryGetValue(aspNetCoreApp, out var aspNetCoreVersion))
177+
{
178+
return aspNetCoreVersion.FullPath;
179+
}
180+
return null;
181+
}
176182
}
177183
}

0 commit comments

Comments
 (0)