Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ private void AddNetFrameworkDlls(ISet<AssemblyLookupLocation> dllLocations, ISet

string? runtimeLocation = null;

if (fileContent.IsNewProjectStructureUsed)
if (fileContent.IsSdkProjectStructureUsed)
{
runtimeLocation = Runtime.NetCoreRuntime;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public bool IsAspNetCoreDetected
{
get
{
return IsNewProjectStructureUsed && UseAspNetCoreDlls;
return IsSdkProjectStructureUsed && UseAspNetCoreDlls;
}
}

Expand Down Expand Up @@ -102,13 +102,13 @@ public bool IsLegacyProjectStructureUsed
}
}

private bool isNewProjectStructureUsed = false;
public bool IsNewProjectStructureUsed
private bool isSdkProjectStructureUsed = false;
public bool IsSdkProjectStructureUsed
{
get
{
initialize.Run();
return isNewProjectStructureUsed;
return isSdkProjectStructureUsed;
}
}

Expand Down Expand Up @@ -228,7 +228,7 @@ private void DoInitialize()

// Determine project structure:
isLegacyProjectStructureUsed = isLegacyProjectStructureUsed || MicrosoftCSharpTargets().IsMatch(line);
isNewProjectStructureUsed = isNewProjectStructureUsed
isSdkProjectStructureUsed = isSdkProjectStructureUsed
|| ProjectSdk().IsMatch(line)
|| FrameworkReference().IsMatch(line);
// TODO: we could also check `<Sdk Name="Microsoft.NET.Sdk" />`
Expand All @@ -240,6 +240,14 @@ private void DoInitialize()
logger.LogDebug($"Failed to read file {file}, exception: {ex}");
}
}

logger.LogInfo("Finished reading project files.");
logger.LogInfo($"Legacy project structure usage detected: {isLegacyProjectStructureUsed}");
logger.LogInfo($"SDK project structure usage detected: {isSdkProjectStructureUsed}");
logger.LogInfo($"ASP.NET usage detected: {useAspNetCoreDlls}");
logger.LogInfo($"Windows Forms usage detected: {useWindowsForms}");
logger.LogInfo($"WPF usage detected: {useWpf}");
logger.LogInfo($"Implicit usings enabled: {useImplicitUsings}");
}

[GeneratedRegex("(?<!<!--.*)<PackageReference.*\\sInclude=\"(.*?)\".*/?>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,9 @@ public HashSet<AssemblyLookupLocation> Restore()
.Where(path => IsPathInSubfolder(path, legacyPackageDirectory.DirInfo.FullName, "tools"))
.ToList();

if (nugetPackageDllPaths.Count > 0)
{
logger.LogInfo($"Restored {nugetPackageDllPaths.Count} NuGet DLLs.");
}

logger.LogInfo($"Restored {nugetPackageDllPaths.Count} NuGet DLLs from packages.config files using the NuGet CLI.");

if (excludedPaths.Count > 0)
{
logger.LogInfo($"Excluding {excludedPaths.Count} NuGet DLLs.");
Expand All @@ -163,6 +162,13 @@ public HashSet<AssemblyLookupLocation> Restore()
}

nugetPackageDllPaths.ExceptWith(excludedPaths);

logger.LogInfo($"Using {nugetPackageDllPaths.Count} DLLs as dependency candidates from NuGet packages restored via the NuGet CLI based on packages.config files.");
foreach (var path in nugetPackageDllPaths)
{
logger.LogDebug($"Using NuGet DLL as dependency candidate: {path}");
}

assemblyLookupLocations.UnionWith(nugetPackageDllPaths.Select(p => new AssemblyLookupLocation(p)));
}
catch (Exception exc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected override IEnumerable<string> Run()
return [];
}

if (!fileContent.IsNewProjectStructureUsed)
if (!fileContent.IsSdkProjectStructureUsed)
{
logger.LogInfo($"Generating source files from {FileType} files is only supported for new (SDK-style) project files");
return [];
Expand Down
4 changes: 2 additions & 2 deletions csharp/extractor/Semmle.Extraction.Tests/FileContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public void TestFileContent_LegacyProjectStructure()

// Execute
var isLegacy = fileContent.IsLegacyProjectStructureUsed;
var isNew = fileContent.IsNewProjectStructureUsed;
var isNew = fileContent.IsSdkProjectStructureUsed;

// Verify
Assert.True(isLegacy);
Expand All @@ -204,7 +204,7 @@ public void TestFileContent_NewProjectStructure()

// Execute
var isLegacy = fileContent.IsLegacyProjectStructureUsed;
var isNew = fileContent.IsNewProjectStructureUsed;
var isNew = fileContent.IsSdkProjectStructureUsed;

// Verify
Assert.True(isNew);
Expand Down
Loading