Skip to content

Extend clock shimming to support TimeProvider abstract class#9

Merged
JerrettDavis merged 69 commits into
masterfrom
copilot/extend-library-with-abstract-classes
May 13, 2026
Merged

Extend clock shimming to support TimeProvider abstract class#9
JerrettDavis merged 69 commits into
masterfrom
copilot/extend-library-with-abstract-classes

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 8, 2026

  • Review the latest new PR comment and identify actionable requested changes
  • Inspect latest workflow runs/logs for CI/build status
  • Run targeted pre-change tests/build to baseline current state
  • Update partial-type TimeProvider test inputs so readonly field scenarios remain compilable
  • Re-run targeted tests/build and restore tracked build artifacts
  • Run parallel validation and address any actionable feedback
  • Reply to the new PR comment with the addressing commit hash

Copilot AI and others added 7 commits May 8, 2026 20:15
Agent-Logs-Url: https://github.com/JerrettDavis/In-Shim-Inator/sessions/d6cd3cb6-46c0-4ccb-a73f-f024d176bec3

Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
Agent-Logs-Url: https://github.com/JerrettDavis/In-Shim-Inator/sessions/d6cd3cb6-46c0-4ccb-a73f-f024d176bec3

Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
This reverts commit 580d248.

Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
Agent-Logs-Url: https://github.com/JerrettDavis/In-Shim-Inator/sessions/d6cd3cb6-46c0-4ccb-a73f-f024d176bec3

Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Extends the INSHIM001 clock shimming experience to also offer a TimeProvider-based code fix path (in addition to the existing IClock path), and updates analyzer/README messaging accordingly.

Changes:

  • Adds a second INSHIM001 code fix option: “Use injected TimeProvider”, injecting a System.TimeProvider field and rewriting UtcNow/Now usages.
  • Updates the INSHIM001 diagnostic message to recommend IClock or TimeProvider.
  • Updates README feature text to mention support for framework abstractions like TimeProvider.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
src/Inshiminator.CodeFixes/ClockCodeFixProvider.cs Registers the new TimeProvider code action and implements the injection + replacement logic.
src/Inshiminator.Analyzers/ClockAnalyzer.cs Updates the diagnostic message text for INSHIM001.
README.md Mentions TimeProvider support in the “Generate” feature description.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Inshiminator.CodeFixes/ClockCodeFixProvider.cs Outdated
Comment thread src/Inshiminator.CodeFixes/ClockCodeFixProvider.cs Outdated
Comment thread src/Inshiminator.CodeFixes/ClockCodeFixProvider.cs Outdated
Comment thread src/Inshiminator.CodeFixes/ClockCodeFixProvider.cs Outdated
Comment thread src/Inshiminator.CodeFixes/ClockCodeFixProvider.cs Outdated
Comment thread src/Inshiminator.Analyzers/ClockAnalyzer.cs Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

Comment thread src/Inshiminator.CodeFixes/ClockCodeFixProvider.cs Outdated
Comment thread src/Inshiminator.CodeFixes/ClockCodeFixProvider.cs Outdated
Comment thread src/Inshiminator.CodeFixes/ClockCodeFixProvider.cs Outdated
Comment thread src/Inshiminator.CodeFixes/ClockCodeFixProvider.cs Outdated
Comment thread src/Inshiminator.CodeFixes/ClockCodeFixProvider.cs Outdated
Comment thread src/Inshiminator.CodeFixes/ClockCodeFixProvider.cs Outdated
@JerrettDavis
Copy link
Copy Markdown
Owner

@copilot apply changes based on the comments in this thread

Copilot AI and others added 3 commits May 8, 2026 21:52
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 8, 2026

@copilot apply changes based on the comments in this thread

Applied the requested PR-thread updates in commits c3d9dbd, 8426a78, and 30ee563.

This includes: gating the TimeProvider code action by availability, preserving DateTime vs DateTimeOffset rewrite types, hardening constructor/assignment handling (including collisions), using semantic System.TimeProvider checks, and adding targeted TimeProvider code-fix tests for UtcNow/Now.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comment thread src/Inshiminator.CodeFixes/ClockCodeFixProvider.cs Outdated
Comment thread src/Inshiminator.CodeFixes/ClockCodeFixProvider.cs Outdated
Comment thread src/Inshiminator.CodeFixes/ClockCodeFixProvider.cs Outdated
@JerrettDavis
Copy link
Copy Markdown
Owner

@copilot apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 12, 2026

@copilot apply changes based on the comments in this thread

Applied in commit 24f8046.

I updated EnsureThisInitializerHasArgument so when a this(...) initializer already supplies the target TimeProvider parameter with a different expression (including timeProvider: null), the fix rewrites that argument to the injected parameter identifier instead of treating it as already correctly passed. I also updated the related regression expectation to assert the rewritten initializer flow.

Screenshot: N/A (no UI changes in this PR).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread src/Inshiminator.Analyzers/ClockAnalyzer.cs Outdated
Comment thread src/Inshiminator.CodeFixes/ClockCodeFixProvider.cs Outdated
@JerrettDavis
Copy link
Copy Markdown
Owner

@copilot apply changes based on the comments in this thread

Copilot AI and others added 2 commits May 12, 2026 21:05
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 12, 2026

@copilot apply changes based on the comments in this thread

Applied in commit 3275b85 (with cleanup in a28ec95). Updated INSHIM001 wording to .NET 7+ and renamed the unsafe injected-field context helper to a generic injected-dependency name used by both IClock and TimeProvider paths.

Screenshot: N/A (no UI changes).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread src/Inshiminator.Analyzers/ClockAnalyzer.cs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread tests/Inshiminator.Analyzers.Tests/ClockCodeFixTests.cs Outdated
@JerrettDavis
Copy link
Copy Markdown
Owner

@copilot apply changes based on the comments in this thread

Copilot AI and others added 2 commits May 12, 2026 23:03
Agent-Logs-Url: https://github.com/JerrettDavis/In-Shim-Inator/sessions/16ab3d7f-5286-4365-954f-3130e0b94c2a

Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 12, 2026

@copilot apply changes based on the comments in this thread

Addressed in commit eb83d61: the analyzer message now uses availability-based wording (TimeProvider when available) instead of hard-coding a framework version. I also re-ran targeted TimeProvider code-fix tests to confirm behavior remains green.

Screenshot: N/A (no UI changes).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread tests/Inshiminator.Analyzers.Tests/ClockCodeFixTests.cs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread src/Inshiminator.CodeFixes/ClockCodeFixProvider.cs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread src/Inshiminator.CodeFixes/ClockCodeFixProvider.cs
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread src/Inshiminator.CodeFixes/ClockCodeFixProvider.cs
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread src/Inshiminator.CodeFixes/ClockCodeFixProvider.cs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread src/Inshiminator.CodeFixes/ClockCodeFixProvider.cs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

tests/Inshiminator.Analyzers.Tests/ClockCodeFixTests.cs:1061

  • This test input declares private readonly CustomTimeProvider _timeProvider; but does not assign it in the constructor, which is a compile-time error for readonly fields. To keep the scenario realistic and ensure the test compiles, either assign _timeProvider in the constructor or remove readonly from the pre-fix input.
    private readonly CustomTimeProvider _timeProvider;

    public Test(string name)
    {
    }

tests/Inshiminator.Analyzers.Tests/ClockCodeFixTests.cs:1121

  • The pre-fix test code includes an unassigned readonly field (private readonly MyApp.CustomTimeProvider _timeProvider;), which will not compile. Consider making the field non-readonly in the test input or initializing/assigning it so the test represents a valid starting point for the code fix.
    private readonly MyApp.CustomTimeProvider _timeProvider;

    public Test(string name)
    {
    }

Comment thread tests/Inshiminator.Analyzers.Tests/ClockCodeFixTests.cs Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

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.

3 participants