Skip to content

Add CronCraft dependency injection registration#19

Merged
teesofttech merged 1 commit into
masterfrom
feat/issue-9-dependency-injection
Jun 18, 2026
Merged

Add CronCraft dependency injection registration#19
teesofttech merged 1 commit into
masterfrom
feat/issue-9-dependency-injection

Conversation

@teesofttech

@teesofttech teesofttech commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • add AddCronCraft() as an IServiceCollection extension
  • support optional CronSettings configuration
  • register options infrastructure for both configured and default usage
  • register CronCraftService as a singleton
  • document dependency injection setup in the repository and packaged READMEs
  • add integration tests for singleton resolution, configuration, and fluent chaining

Why

Consumers currently need to register CronSettings and CronCraftService manually. This adds an idiomatic one-call registration API for ASP.NET Core and generic host applications while keeping direct, non-DI usage available.

Closes #9

Validation

  • dotnet test CronCraft.Test/CronCraft.Test.csproj --no-restore — 39 tests passed
  • dotnet build CronCraft.sln --no-restore — succeeded with 0 warnings and 0 errors

Summary by CodeRabbit

  • New Features

    • CronCraft now includes optional dependency injection support, enabling convenient service registration and seamless integration with ASP.NET Core applications and other dependency injection containers.
  • Tests

    • Added comprehensive unit tests validating dependency injection registration behavior, configuration application, singleton service registration, and service collection method chaining support.
  • Documentation

    • Updated project and main documentation with complete dependency injection setup examples, configuration patterns, and practical guidance for integrating and injecting services.

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 68d01864-0a59-4b74-8e5f-7ee495b4b49d

📥 Commits

Reviewing files that changed from the base of the PR and between ac107bd and ca3b8f1.

📒 Files selected for processing (6)
  • CronCraft.Test/CronCraft.Test.csproj
  • CronCraft.Test/ServiceCollectionExtensionsTest.cs
  • CronCraft/CronCraft.csproj
  • CronCraft/Extensions/ServiceCollectionExtensions.cs
  • CronCraft/README.md
  • README.md

📝 Walkthrough

Walkthrough

Adds an AddCronCraft extension method on IServiceCollection that registers CronSettings options and CronCraftService as a singleton, with an optional configuration delegate. Updates both project files with the required NuGet packages, adds three MSTest unit tests, and documents the new DI pattern in both READMEs.

Changes

AddCronCraft DI Registration

Layer / File(s) Summary
AddCronCraft extension method and project dependency
CronCraft/CronCraft.csproj, CronCraft/Extensions/ServiceCollectionExtensions.cs
Adds Microsoft.Extensions.DependencyInjection.Abstractions 9.0.6 to the main project, then creates ServiceCollectionExtensions with AddCronCraft that null-checks services, registers CronSettings options, conditionally applies the Action<CronSettings> delegate, registers CronCraftService as singleton, and returns the original collection.
Unit tests for AddCronCraft
CronCraft.Test/CronCraft.Test.csproj, CronCraft.Test/ServiceCollectionExtensionsTest.cs
Adds Microsoft.Extensions.DependencyInjection 9.0.6 to the test project and introduces three MSTest methods validating singleton resolution, settings callback application with Convert output assertion, and fluent chaining identity.
README DI documentation
README.md, CronCraft/README.md
Updates the "Why CronCraft" tagline to note DI is optional, adds an AddCronCraft feature bullet, and inserts a "Dependency Injection" subsection with registration and injection code examples in both READMEs.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • teesofttech/CronCraft#14: Modifies CronCraftService.Convert/ToHumanReadable signatures and CronSettings, which are directly exercised by the new AddCronCraft configuration test that asserts Convert output.

Poem

🐰 A hop, a skip, a DI trick,
AddCronCraft wired up quick!
No more manual singleton woes,
Just inject wherever your cron job goes.
The rabbit typed—and chaining flows! ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/issue-9-dependency-injection

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@teesofttech teesofttech changed the title [codex] Add CronCraft dependency injection registration Add CronCraft dependency injection registration Jun 18, 2026
@teesofttech
teesofttech marked this pull request as ready for review June 18, 2026 03:35
Copilot AI review requested due to automatic review settings June 18, 2026 03:35
@teesofttech
teesofttech merged commit 2d9f354 into master Jun 18, 2026
3 checks passed
@github-actions

Copy link
Copy Markdown

🎉 Thank you for your contribution!

This PR was included in CronCraft v1.0.5 and is now live on NuGet for everyone to use. We really appreciate the time and effort you put in — it makes the library better for the whole community! 🚀

dotnet add package CronCraft --version 1.0.5

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds an idiomatic dependency-injection registration entrypoint for CronCraft so consumers can register CronCraftService (and optional CronSettings configuration) via a single IServiceCollection extension method, with accompanying docs and integration tests.

Changes:

  • Introduces IServiceCollection.AddCronCraft(...) to register options infrastructure and CronCraftService as a singleton.
  • Updates repository and package READMEs with DI usage guidance.
  • Adds DI-focused integration tests and required DI package references.

Reviewed changes

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

Show a summary per file
File Description
README.md Documents AddCronCraft DI registration and injection usage.
CronCraft/README.md Mirrors DI documentation for the packaged README.
CronCraft/Extensions/ServiceCollectionExtensions.cs Adds AddCronCraft extension to register options + singleton service.
CronCraft/CronCraft.csproj Adds DI abstractions package dependency needed for IServiceCollection extensions.
CronCraft.Test/ServiceCollectionExtensionsTest.cs Adds integration tests for singleton registration, configuration, and fluent chaining.
CronCraft.Test/CronCraft.Test.csproj Adds DI package dependency for ServiceCollection/BuildServiceProvider usage in tests.

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

Comment thread README.md
`IServiceCollection`:

```csharp
using CronCraft.Extensions;
Comment thread CronCraft/README.md
`IServiceCollection`:

```csharp
using CronCraft.Extensions;
@github-actions

Copy link
Copy Markdown

🎉 Thank you for your contribution!

This PR was included in CronCraft v1.0.6 and is now live on NuGet for everyone to use. We really appreciate the time and effort you put in — it makes the library better for the whole community! 🚀

dotnet add package CronCraft --version 1.0.6

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.

Add IServiceCollection extension method for dependency injection (AddCronCraft)

2 participants