Skip to content

Refactor foreach loops to explicit LINQ and fix resource disposal#10

Merged
JDRay42 merged 5 commits intodocs/phase2-completion-updatefrom
copilot/sub-pr-8-again
Jan 6, 2026
Merged

Refactor foreach loops to explicit LINQ and fix resource disposal#10
JDRay42 merged 5 commits intodocs/phase2-completion-updatefrom
copilot/sub-pr-8-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 6, 2026

Addresses code review feedback from PR #8 by refactoring implicit filtering/mapping patterns to explicit LINQ methods and fixing unmanaged resource disposal.

Changes

EntitiesController.cs - Refactored 6 foreach loops:

  • Replaced implicit filtering with explicit .Where() predicates
  • Replaced immediate variable mapping with explicit .Select() projections
  • Materialized queries with .ToList() to prevent deferred execution re-evaluation

UniversesControllerTests.cs - Fixed resource leaks:

  • Added using var declarations for FormUrlEncodedContent instances

Example

Before:

foreach (var line in aliasLines)
{
    var trimmed = line.Trim();
    if (!string.IsNullOrWhiteSpace(trimmed))
    {
        newAliases.Add(trimmed);
    }
}

After:

var validAliases = aliasLines
    .Select(line => line.Trim())
    .Where(trimmed => !string.IsNullOrWhiteSpace(trimmed))
    .ToList();

foreach (var trimmed in validAliases)
{
    newAliases.Add(trimmed);
}

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits January 6, 2026 18:35
Co-authored-by: JDRay42 <10964706+JDRay42@users.noreply.github.com>
Co-authored-by: JDRay42 <10964706+JDRay42@users.noreply.github.com>
Co-authored-by: JDRay42 <10964706+JDRay42@users.noreply.github.com>
Co-authored-by: JDRay42 <10964706+JDRay42@users.noreply.github.com>
Copilot AI changed the title [WIP] Update documentation for Phase 2 completion Refactor foreach loops to explicit LINQ and fix resource disposal Jan 6, 2026
Copilot AI requested a review from JDRay42 January 6, 2026 18:43
@JDRay42 JDRay42 marked this pull request as ready for review January 6, 2026 19:11
@JDRay42 JDRay42 merged commit a4b9840 into docs/phase2-completion-update Jan 6, 2026
@JDRay42 JDRay42 deleted the copilot/sub-pr-8-again branch January 7, 2026 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants