Skip to content

Fix immutability violations and redundant initialization in F1 replay sources#13

Merged
codegefluester merged 5 commits intofeat/f1-replay-sourcefrom
copilot/sub-pr-12
Feb 11, 2026
Merged

Fix immutability violations and redundant initialization in F1 replay sources#13
codegefluester merged 5 commits intofeat/f1-replay-sourcefrom
copilot/sub-pr-12

Conversation

Copy link
Contributor

Copilot AI commented Feb 11, 2026

The F1 replay source classes mutated input FileWatcherOptions instead of returning new instances, and performed redundant double-initialization. Additionally, the debounce delay default logic failed to override the library's 1s default.

Changes

  • Immutable options pattern: EnsurePath methods now return new FileWatcherOptions instances instead of mutating the input parameter (F1RaceReplaySource, F12022-2025RaceReplaySource)

  • Simplified initialization: Removed redundant EnsurePath call in options-based constructors; ApplyDefaults now handles path defaulting directly

  • Fixed debounce delay detection: ApplyDefaults now checks for both default (00:00:00) and library default (1s) to consistently apply F1's 2s default across constructor paths

  • Code clarity: Extracted LibraryDefaultDebounceDelay and F1DebounceDelay constants; replaced foreach with LINQ .Select() in path detection

Before

private static FileWatcherOptions EnsurePath(FileWatcherOptions options)
{
    if (string.IsNullOrEmpty(options.Path))
    {
        options.Path = GetDefaultReplayPath();  // Mutates input
    }
    return options;
}

public F12025RaceReplaySource(FileWatcherOptions options)
    : base(ApplyDefaults(EnsurePath(options)))  // Double call
{
}

After

private static FileWatcherOptions EnsurePath(FileWatcherOptions options)
{
    if (string.IsNullOrEmpty(options.Path))
    {
        return new FileWatcherOptions  // Returns new instance
        {
            Path = GetDefaultReplayPath(),
            Patterns = options.Patterns,
            IncludeSubdirectories = options.IncludeSubdirectories,
            DebounceDelay = options.DebounceDelay
        };
    }
    return options;
}

public F12025RaceReplaySource(FileWatcherOptions options)
    : base(ApplyDefaults(options))  // Single call
{
}

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits February 11, 2026 14:01
Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>
Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>
Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>
Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>
Copilot AI changed the title [WIP] Add F1 replay file sources for detection Fix immutability violations and redundant initialization in F1 replay sources Feb 11, 2026
Copilot AI requested a review from codegefluester February 11, 2026 14:06
@codegefluester codegefluester marked this pull request as ready for review February 11, 2026 14:09
@codegefluester codegefluester merged commit 40532a2 into feat/f1-replay-source Feb 11, 2026
@codegefluester codegefluester deleted the copilot/sub-pr-12 branch February 11, 2026 14:09
codegefluester added a commit that referenced this pull request Feb 11, 2026
* F1 replay file sources

* Fix immutability violations and redundant initialization in F1 replay sources (#13)

* Initial plan

* Fix EnsurePath to return new instances and update foreach to Select

Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>

* Extract debounce delay constants for better maintainability

Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>

* Add clarifying comments and improve variable naming

Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>

* Document library default coupling in constant

Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
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