mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Code quality improvements
This commit is contained in:
@@ -101,6 +101,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
|
||||
var existsNetFrameworkRefNugetPackage = false;
|
||||
|
||||
// Find DLLs in the .Net / Asp.Net Framework
|
||||
// This block needs to come after the nuget restore, because the nuget restore might fetch the .NET Core/Framework reference assemblies.
|
||||
if (options.ScanNetFrameworkDlls)
|
||||
{
|
||||
existsNetCoreRefNugetPackage = IsNugetPackageAvailable("microsoft.netcore.app.ref");
|
||||
|
||||
@@ -162,19 +162,15 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
|
||||
}
|
||||
|
||||
// Determine if ASP.NET is used.
|
||||
if (!useAspNetCoreDlls)
|
||||
{
|
||||
useAspNetCoreDlls =
|
||||
IsGroupMatch(line, ProjectSdk(), "Sdk", "Microsoft.NET.Sdk.Web") ||
|
||||
IsGroupMatch(line, FrameworkReference(), "Include", "Microsoft.AspNetCore.App");
|
||||
}
|
||||
useAspNetCoreDlls = useAspNetCoreDlls
|
||||
|| IsGroupMatch(line, ProjectSdk(), "Sdk", "Microsoft.NET.Sdk.Web")
|
||||
|| IsGroupMatch(line, FrameworkReference(), "Include", "Microsoft.AspNetCore.App");
|
||||
|
||||
|
||||
// Determine if implicit usings are used.
|
||||
if (!useImplicitUsings)
|
||||
{
|
||||
useImplicitUsings = line.Contains("<ImplicitUsings>enable</ImplicitUsings>".AsSpan(), StringComparison.Ordinal) ||
|
||||
line.Contains("<ImplicitUsings>true</ImplicitUsings>".AsSpan(), StringComparison.Ordinal);
|
||||
}
|
||||
useImplicitUsings = useImplicitUsings
|
||||
|| line.Contains("<ImplicitUsings>enable</ImplicitUsings>".AsSpan(), StringComparison.Ordinal)
|
||||
|| line.Contains("<ImplicitUsings>true</ImplicitUsings>".AsSpan(), StringComparison.Ordinal);
|
||||
|
||||
// Find all custom implicit usings.
|
||||
foreach (var valueMatch in CustomImplicitUsingDeclarations().EnumerateMatches(line))
|
||||
@@ -187,9 +183,10 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
|
||||
}
|
||||
|
||||
// Determine project structure:
|
||||
isLegacyProjectStructureUsed |= MicrosoftCSharpTargets().IsMatch(line);
|
||||
isNewProjectStructureUsed |= ProjectSdk().IsMatch(line);
|
||||
isNewProjectStructureUsed |= FrameworkReference().IsMatch(line);
|
||||
isLegacyProjectStructureUsed = isLegacyProjectStructureUsed || MicrosoftCSharpTargets().IsMatch(line);
|
||||
isNewProjectStructureUsed = isNewProjectStructureUsed
|
||||
|| ProjectSdk().IsMatch(line)
|
||||
|| FrameworkReference().IsMatch(line);
|
||||
// TODO: we could also check `<Sdk Name="Microsoft.NET.Sdk" />`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
|
||||
public string? DesktopRuntime => DesktopRuntimes?.FirstOrDefault();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the executiing runtime location, this is the self contained runtime shipped in the CodeQL CLI bundle.
|
||||
/// Gets the executing runtime location, this is the self contained runtime shipped in the CodeQL CLI bundle.
|
||||
/// </summary>
|
||||
public string ExecutingRuntime => RuntimeEnvironment.GetRuntimeDirectory();
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Xunit;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Semmle.Extraction.CSharp.DependencyFetching;
|
||||
using System;
|
||||
|
||||
namespace Semmle.Extraction.Tests
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user