Skip to content
Merged
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
@@ -1,3 +1,4 @@
using Microsoft.Build.Construction;
using Microsoft.Extensions.Logging;
using ModularPipelines.Attributes;
using ModularPipelines.Context;
Expand All @@ -9,23 +10,23 @@ namespace ModularPipelines.Build.Modules;
[DependsOn<FindProjectsModule>]
public class FindProjectDependenciesModule : Module<FindProjectDependenciesModule.ProjectDependencies>
{
public override async Task<ProjectDependencies?> ExecuteAsync(IModuleContext context, CancellationToken cancellationToken)
public override Task<ProjectDependencies?> ExecuteAsync(IModuleContext context, CancellationToken cancellationToken)
{
var projects = context.GetModule<FindProjectsModule, IReadOnlyList<File>>();

var dependencies = new List<File>();

foreach (var file in projects.Value!)
{
await foreach (var line in file.ReadLinesAsync(cancellationToken))
{
if (!line.Contains("<ProjectReference"))
{
continue;
}
var projectRootElement = ProjectRootElement.Open(file)!;

var name = line.Split('\\').Last().Split('"').First();
var projectReferences = projectRootElement.Items
.Where(i => i.ItemType == "ProjectReference")
.Select(i => i.Include);

foreach (var reference in projectReferences)
{
var name = Path.GetFileName(reference);
Comment on lines +28 to +29
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path.GetFileName can return null if the reference path is null, but the null check from line 29 should prevent this. However, the compiler may not recognize this flow. Consider using the null-forgiving operator or add an explicit null check before calling Path.GetFileName.

Suggested change
{
var name = Path.GetFileName(reference);
{
if (reference is null)
{
continue;
}
var name = Path.GetFileName(reference);
if (name is null)
{
continue;
}

Copilot uses AI. Check for mistakes.
var project = projects.Value!.FirstOrDefault(x => x.Name == name);

if (project != null)
Expand All @@ -39,7 +40,7 @@ public class FindProjectDependenciesModule : Module<FindProjectDependenciesModul

LogProjects(context, projectDependencies);

return projectDependencies;
return Task.FromResult<ProjectDependencies?>(projectDependencies);
}

private static void LogProjects(IModuleContext context, ProjectDependencies projectDependencies)
Expand Down
Loading