Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 23, 2025

This PR restores immutability to the IIssue interface by making the Run and FileLink properties read-only and implementing a copy-based enhancement pattern in IssuesReader.

Problem

The IIssue interface was no longer immutable due to two properties that were settable:

  • Run { get; set; }
  • FileLink { get; set; }

These properties couldn't be made read-only in the original design because they are not set by issue providers during construction, but rather generically for all issue providers by the IssuesReader after creation.

Solution

Following the approach suggested in the issue, this PR implements cloning and enhancement of issues in the IssuesReader:

  1. Made properties immutable: Changed Run and FileLink to { get; } in both IIssue interface and Issue class
  2. Added copy method: Implemented Issue.WithRunAndFileLink() that creates a new Issue instance with updated Run and FileLink values
  3. Updated IssuesReader: Modified to create enhanced copies instead of mutating original issues
  4. Fixed tests: Updated all affected tests to compare issues by identifier instead of reference equality

Key Changes

Core immutability changes:

// Before (mutable)
public interface IIssue 
{
    string Run { get; set; }
    Uri FileLink { get; set; }
}

// After (immutable)
public interface IIssue 
{
    string Run { get; }
    Uri FileLink { get; }
}

Copy-based enhancement:

public Issue WithRunAndFileLink(string run, Uri fileLink) =>
    new(/* all existing properties + new run and fileLink */);

IssuesReader enhancement pattern:

// Creates new enhanced issues instead of mutating originals
foreach (var issue in currentIssues)
{
    var enhancedIssue = originalIssue.WithRunAndFileLink(run, fileLink);
    enhancedIssues.Add(enhancedIssue);
}

Benefits

  • Immutability restored: IIssue objects cannot be modified after creation
  • Thread safety: Immutable objects are inherently thread-safe
  • Type safety: Compile-time enforcement prevents accidental mutations
  • Backward compatibility: Issue providers require no changes
  • Functionality preserved: All existing features work unchanged

Testing

All 3000+ tests pass, including comprehensive test updates to handle the new immutable behavior. Tests now compare issues by content (identifier) rather than reference equality since the reader returns enhanced copies.

Fixes #194.


💡 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 Copilot AI changed the title [WIP] IIssue should be immutable Make IIssue immutable by removing mutable Run and FileLink properties Sep 24, 2025
@Copilot Copilot AI requested a review from pascalberger September 24, 2025 00:34
Copilot finished work on behalf of pascalberger September 24, 2025 00:34
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.

IIssue should be immutable
2 participants