Skip to content

Technical roadmap: make this a usable .NET pre-commit hook repo #2

Description

@HamidMolareza

Context

This repository currently has the right high-level idea: reusable pre-commit checks for .NET projects. The existing TODO points to build, test, format, and coverage checks, and the linked OnRails scripts show the intended behavior.

The main risk is turning this into a collection of project-specific shell scripts. The more useful direction is to make this a real pre-commit hook repository that .NET projects can consume with a small .pre-commit-config.yaml entry.

Recommended direction

Build a small, focused hook repository for .NET quality gates:

  • dotnet-build
  • dotnet-test
  • dotnet-format
  • dotnet-coverage

Prefer a .NET CLI tool behind the hooks instead of bash-only scripts. pre-commit supports language: dotnet, but the repository should contain a .NET CLI tool that can be packed and installed. This gives better cross-platform behavior and a stronger resume/project story than shell scripts alone.

Technical suggestions

  • Add .pre-commit-hooks.yaml with stable hook IDs, names, entries, stages, and pass_filenames: false for solution-level commands.
  • Implement a small CLI, for example pre-commit-dotnet, with subcommands such as build, test, format, and coverage.
  • Support solution/project selection through arguments:
    • --path <sln|slnx|csproj|directory>
    • --configuration Debug|Release
    • --framework <tfm> when needed
    • --no-restore / --restore
    • --property NuGetAudit=false or a general MSBuild property pass-through option
  • Make coverage threshold configurable:
    • --line-threshold <number>
    • --branch-threshold <number>
    • support Cobertura output from XPlat Code Coverage
  • Avoid hardcoded repository paths, folder names, or project-specific rules. Any path filtering should be opt-in through args.
  • Keep the first version intentionally narrow: no replacement for Husky.Net, no full CI framework, no broad lint-staged clone.
  • Provide clear exit codes and concise output so hook failures are easy to understand.
  • Add sample projects under samples/ to demonstrate common use cases.
  • Add automated tests for argument parsing, command construction, coverage parsing, and failure output.
  • Add CI on Ubuntu and Windows at minimum. macOS can be added later if needed.
  • Add a README with quickstart examples, including:
repos:
  - repo: https://github.com/Payadel/pre-commit-dotnet
    rev: v0.1.0
    hooks:
      - id: dotnet-format
      - id: dotnet-build
        args: [--path, MySolution.sln]
      - id: dotnet-test
        args: [--path, MySolution.sln, --no-restore]
      - id: dotnet-coverage
        args: [--path, tests/MyProject.Tests/MyProject.Tests.csproj, --line-threshold, "80"]

Suggested MVP

  1. Create the .NET CLI project.
  2. Add .pre-commit-hooks.yaml.
  3. Implement format, build, and test.
  4. Add one sample .NET project and test the hooks with pre-commit try-repo.
  5. Add README quickstart.
  6. Tag v0.1.0.
  7. Add coverage after the basic hooks are stable.

Acceptance checklist

  • A new .NET project can consume this repository from .pre-commit-config.yaml.
  • Hooks work on Linux and Windows.
  • Hooks support .sln, .slnx, .csproj, and directory paths where practical.
  • No hook contains project-specific paths or assumptions.
  • README includes copy-pasteable configuration.
  • CI validates the package and sample hook usage.
  • A tagged release can be used by pre-commit with rev: v0.1.0.

Non-goals for now

  • Competing directly with Husky.Net.
  • Implementing a general-purpose task runner.
  • Supporting every possible dotnet CLI option in v0.1.
  • Adding complex changed-file detection before the basic hook flow is stable.

Why this is worth doing

This is not likely to become a strong standalone business, but it can be useful as:

  • a practical .NET developer tool,
  • a reusable helper for personal and team projects,
  • a compact resume project if packaged and documented well,
  • a learning project around CLI design, cross-platform tooling, pre-commit internals, and release hygiene.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions