Skip to content

Commit 15ec0a1

Browse files
committed
Code quality improvements
1 parent 3b4ea27 commit 15ec0a1

File tree

4 files changed

+14
-16
lines changed

4 files changed

+14
-16
lines changed

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ public DependencyManager(string srcDir, IDependencyOptions options, ILogger logg
101101
var existsNetFrameworkRefNugetPackage = false;
102102

103103
// Find DLLs in the .Net / Asp.Net Framework
104+
// This block needs to come after the nuget restore, because the nuget restore might fetch the .NET Core/Framework reference assemblies.
104105
if (options.ScanNetFrameworkDlls)
105106
{
106107
existsNetCoreRefNugetPackage = IsNugetPackageAvailable("microsoft.netcore.app.ref");

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FileContent.cs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -162,19 +162,15 @@ private void DoInitialize()
162162
}
163163

164164
// Determine if ASP.NET is used.
165-
if (!useAspNetCoreDlls)
166-
{
167-
useAspNetCoreDlls =
168-
IsGroupMatch(line, ProjectSdk(), "Sdk", "Microsoft.NET.Sdk.Web") ||
169-
IsGroupMatch(line, FrameworkReference(), "Include", "Microsoft.AspNetCore.App");
170-
}
165+
useAspNetCoreDlls = useAspNetCoreDlls
166+
|| IsGroupMatch(line, ProjectSdk(), "Sdk", "Microsoft.NET.Sdk.Web")
167+
|| IsGroupMatch(line, FrameworkReference(), "Include", "Microsoft.AspNetCore.App");
168+
171169

172170
// Determine if implicit usings are used.
173-
if (!useImplicitUsings)
174-
{
175-
useImplicitUsings = line.Contains("<ImplicitUsings>enable</ImplicitUsings>".AsSpan(), StringComparison.Ordinal) ||
176-
line.Contains("<ImplicitUsings>true</ImplicitUsings>".AsSpan(), StringComparison.Ordinal);
177-
}
171+
useImplicitUsings = useImplicitUsings
172+
|| line.Contains("<ImplicitUsings>enable</ImplicitUsings>".AsSpan(), StringComparison.Ordinal)
173+
|| line.Contains("<ImplicitUsings>true</ImplicitUsings>".AsSpan(), StringComparison.Ordinal);
178174

179175
// Find all custom implicit usings.
180176
foreach (var valueMatch in CustomImplicitUsingDeclarations().EnumerateMatches(line))
@@ -187,9 +183,10 @@ private void DoInitialize()
187183
}
188184

189185
// Determine project structure:
190-
isLegacyProjectStructureUsed |= MicrosoftCSharpTargets().IsMatch(line);
191-
isNewProjectStructureUsed |= ProjectSdk().IsMatch(line);
192-
isNewProjectStructureUsed |= FrameworkReference().IsMatch(line);
186+
isLegacyProjectStructureUsed = isLegacyProjectStructureUsed || MicrosoftCSharpTargets().IsMatch(line);
187+
isNewProjectStructureUsed = isNewProjectStructureUsed
188+
|| ProjectSdk().IsMatch(line)
189+
|| FrameworkReference().IsMatch(line);
193190
// TODO: we could also check `<Sdk Name="Microsoft.NET.Sdk" />`
194191
}
195192
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ private static IEnumerable<string> DesktopRuntimes
116116
public string? DesktopRuntime => DesktopRuntimes?.FirstOrDefault();
117117

118118
/// <summary>
119-
/// Gets the executiing runtime location, this is the self contained runtime shipped in the CodeQL CLI bundle.
119+
/// Gets the executing runtime location, this is the self contained runtime shipped in the CodeQL CLI bundle.
120120
/// </summary>
121121
public string ExecutingRuntime => RuntimeEnvironment.GetRuntimeDirectory();
122122

csharp/extractor/Semmle.Extraction.Tests/FileContent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using Xunit;
2+
using System;
23
using System.Collections.Generic;
34
using Semmle.Extraction.CSharp.DependencyFetching;
4-
using System;
55

66
namespace Semmle.Extraction.Tests
77
{

0 commit comments

Comments
 (0)