Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .agents/skills/writing-csharp/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: writing-csharp
description: Coding conventions for C# in this repo — design, naming, layout, XML documentation and tests — based on the C# Coding Guidelines (csharpcodingguidelines.com) with Fallout's exceptions. Trigger whenever you write, change or review C# code under src/, tests/ or build/, including test specs.
---

These rules apply to code you add or change. Where existing code does
something else, follow these rules anyway. Don't reformat code you don't
otherwise touch. There is no `.editorconfig` to enforce them, so review does.

## Rules that are missed most often

Check these before you finish. Each one came up in a real review.

- A `Get…` method never returns `null`. If it can, name it `Find…` or `TryGet…`.
- Check for null with `is null` and `is not null`.
- Use `var` only when the right side shows the type. Never use it for `bool`, `int`, `string` and other built-in types. Test code is exempt.
- Keep a method under 15 statements. Put a method before the methods it calls.
- Put one type in each file. Keep lines at 130 characters or less.
- Document every `public` and `internal` member. Say what the signature doesn't: when the result is `null`, which input wins, what gets rejected.
- Put `<summary>` and `</summary>` on their own lines.
- Use `//` only for why. Use `<summary>` for what a member does.
- No constructors or shared fields in a `Specs` class.
- Give every new rule a test. When it depends on the environment, move the decision into a method that takes those values as parameters.

## References

Read the file that matches your task:

| File | Read it when |
| --- | --- |
| [references/project-rules.md](references/project-rules.md) | Writing any C#. It has Fallout's exceptions, such as static `*Tasks` classes and `bool?` on tool options. |
| [references/testing.md](references/testing.md) | Writing or changing a `*Specs.cs` file. |
| [references/coding-guidelines.md](references/coding-guidelines.md) | You need the full rule behind an `AV` rule ID. |
| [references/review-checklist.md](references/review-checklist.md) | Before opening a PR, or when reviewing one. |
192 changes: 192 additions & 0 deletions .agents/skills/writing-csharp/references/coding-guidelines.md

Large diffs are not rendered by default.

55 changes: 55 additions & 0 deletions .agents/skills/writing-csharp/references/project-rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Project rules

Rules that add to the [C# Coding Guidelines](coding-guidelines.md), and the places where Fallout makes an exception to them.

## Exceptions for Fallout

- **Static task classes are fine.** The `*Tasks` classes (`DotNetTasks`, `GitTasks`, ...) and their extension methods are the public API of a build script. AV1008 and AV1125 don't apply to them. A new static class that is not part of that API still needs a reason.
- **`bool?` is fine on tool options.** In a `ToolOptions` class, `null` means "don't pass the argument", which differs from `false`. Everywhere else, use `bool` when no value means `false`.
- **Public API is a promise.** A public interface or extension point is fine with one implementation when consumers implement it. Internal interfaces still need a reason (see below).
- **Check the target framework.** Many projects also target `netstandard2.0`. A new C# feature (AV1145, AV1155, `required`, `init`) must compile for every target framework of the project.
- **Generated code is exempt.** Don't apply these rules to `*.Generated.cs` files. Change the tool's `.json` spec or the generator instead.

## Design

- Make a type `internal` unless it is meant to be public API. Its members may be `public`: they can't be more visible than the type. Don't flag a `public` member on an `internal` type.
- Add an abstraction only when at least three places use it.
- Don't add an interface only for dependency injection or tests. Add one when it separates two parts of the system that must not know each other.
- Make nullability match the contract. Mark a property that must have a value as `required`, or make it non-nullable, instead of declaring it nullable and rejecting `null` at run time. A property that may be absent must be nullable, not just documented as optional.
- When you validate arguments, check each one on its own and throw an exception that names it. One message for several fields doesn't tell the caller which one is wrong.
- Don't add an early-return guard before code that already handles empty input. It adds noise and can skip logging that should still run.

## Names

- A method whose name starts with `Get` never returns `null`. If it can, name it `Find…` or `TryGet…`.
- Never abbreviate a word in a folder, type or namespace name: `Configuration`, not `Config`. Widely used acronyms such as `Id`, `Uri` and `Xml` are fine.
- The namespace follows the folder structure.

## Code

- Use `var` only when the right side shows the type, as in `new Foo()` or a cast. Never use it for built-in types such as `bool`, `int` and `string`. `var` is required for anonymous types. Test code is exempt.
- Check for null with `is null` and `is not null`, not `== null` and `!= null`.
- Never compare a `bool` to `true` or `false`. Write `if (isActive)`, not `if (isActive == true)`.
- Don't write `(await FooAsync()).ToList()`. Use an async LINQ method, or split it over two lines.
- Never use `Thread.Sleep` in async code. Use `await Task.Delay`.
- Never put `!` after a deserialization call, such as `JsonSerializer.Deserialize<T>(...)!`. A `null` result then turns into a `NullReferenceException` far from the cause. Check for `null` and throw a clear exception.
- Put `[UsedImplicitly]` (JetBrains.Annotations) on a member that only reflection or a serializer uses, such as a `[Parameter]` field. Use `[UsedImplicitly(ImplicitUseTargetFlags.WithMembers)]` on the type when this applies to all of its members.

## Size and order

- Keep a method under 15 statements, at one level of abstraction. Split a longer method into well-named private methods. A flat list of independent guard clauses is fine.
- Order methods so that a method comes before the methods it calls. The file then reads from top to bottom.
- Put one type in each file, and name the file after the type.
- Keep lines at 130 characters or less.

## Documentation and comments

- Document every `public` and `internal` type and member with XML comments. Skip it only when the comment would repeat the name.
- Say what the reader can't see from the signature: when the result is `null`, which input wins, what gets rejected. "Gets the test runner" adds nothing to `GetTestRunner`.
- Put `<summary>` and `</summary>` on their own lines, also for one-line summaries.
- Use a `//` comment only to explain why the code does something unexpected. To describe what a member does, use `<summary>`.
- `// REFACTOR` and `// SMELL` comments are fine to point the next person at a known problem. Don't leave a `// TODO` without an issue.

## Packages

- Every new package needs a maintainer's approval. Add it to the right group in `Directory.Packages.props`, never with `Version=` in a project file, and record it in [docs/dependencies.md](../../../../docs/dependencies.md).
42 changes: 42 additions & 0 deletions .agents/skills/writing-csharp/references/review-checklist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Review checklist

Use this before you open a PR, or when you review one. Walk the block that matches each changed file. Every changed method also gets block M, whatever file it is in.

Each item has an ID so a review can say which items it checked. The rule behind each item is in [project-rules.md](project-rules.md), [testing.md](testing.md) or [coding-guidelines.md](coding-guidelines.md).

## T. A new or changed `*Specs.cs` file

- **T1.** Is the class suffixed `Specs`, and do its file and namespace mirror the project under test?
- **T2.** Does each test name state a fact in plain English, with no method or type names and no `Can_` for behavior that always happens?
- **T3.** Is every statement under the right Arrange, Act or Assert heading?
- **T4.** Is everything the scenario doesn't depend on left out: no restated defaults, no assertions the setup already guarantees?
- **T5.** Is there no constructor and no shared field in the class?
- **T6.** Are the values that matter visible in the test body, including in `[InlineData]` rows?
- **T7.** Is the expected value known independently, not computed with the code under test?
- **T8.** Does every new rule in the production code have a test, including rules that depend on the environment?

## M. Any changed method, whatever file it is in

- **M1.** Is it under 15 statements, at one level of abstraction?
- **M2.** Can a reader follow every branch without guessing the author's intent?
- **M3.** Does an existing helper already do what this code does by hand?
- **M4.** Is `var` used only where the right side shows the type, and never for built-in types?
- **M5.** Is a method that only its own type uses `private`?
- **M6.** Does a `Get…` method never return `null`?
- **M7.** Are null checks written as `is null` and `is not null`?
- **M8.** Does it come before the methods it calls?

## D. A new or changed `public` or `internal` type or member

- **D1.** Is the type `internal` unless it is meant to be public API? If it is public and not yet stable, is it marked `[Experimental]`?
- **D2.** Does it have an XML comment that says what the signature doesn't?
- **D3.** Are `<summary>` and `</summary>` on their own lines?
- **D4.** Is there one type per file, with the file named after the type?
- **D5.** Is a new abstraction or interface used in at least three places, or does it separate parts that must not know each other?
- **D6.** Does nullability match the contract, with no `!` needed downstream?
- **D7.** Are all lines 130 characters or less?

## P. A changed `*.csproj` or `Directory.Packages.props`

- **P1.** Does it add a package? Then it needs a maintainer's approval, an entry in the right group of `Directory.Packages.props` and a line in `docs/dependencies.md`.
- **P2.** Does a `PackageReference` have a `Version=`? Move the version to `Directory.Packages.props`.
58 changes: 58 additions & 0 deletions .agents/skills/writing-csharp/references/testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Tests

Fallout tests use xUnit v3, FluentAssertions and Verify. Don't add another test or mocking framework.

## Structure

- Use Arrange, Act and Assert, marked with `// Arrange`, `// Act` and `// Assert` comments. Leave out a phase that has nothing in it.
- Put each statement under the phase it belongs to. A value that feeds the call under test is Arrange, however late it appears. Reading the result of the call is Act. Every check is Assert, even a one-line sanity check.
- Don't invent other headings, such as `// Assign / Act`. The only allowed combination is `// Act/Assert`, for a test where the act is the check, such as "does not throw".
- Don't use constructors or shared fields in a `Specs` class. Set up what a test needs inside the test, or in a helper that the test calls.
- Set up state through the public API where you can. A test that sets up through the internals no longer proves that the public API works.

## What to leave out

- Leave out anything the scenario doesn't depend on. When everything is shown, nothing stands out.
- Don't check something the setup already guarantees, and don't restate defaults you rely on.
- Ask of each assertion: would the test prove less without it? If not, remove it.

## Assertions

- Use the single most specific FluentAssertions method. A row of checks per property or key almost always becomes one `BeEquivalentTo` or one collection assertion, with a better failure message.
- Avoid `AssertionScope`. Normal tests rarely need every failure reported at once, and a `null` inside the scope causes a `NullReferenceException` instead of a clear failure.
- Compare with values you know independently. Never compute the expected value with the production code under test.
- Build dates with the FluentAssertions extensions, such as `1.September(2026)`. Never use `DateTime.Parse` in a test.
- Never take a value from one fixed input and apply it to a different input that is read at run time. For example, a time-zone offset taken from a fixed date is wrong for a date in another DST period.

## Test data

- Make the values that matter visible in the test body.
- Make test data rows describe themselves. A row of bare values in `[InlineData]` or `TheoryData` doesn't tell the reader which value is input and which is expected. Use a named record or named arguments.
- Prefer a Test Data Builder over small private helper methods. Name the builder after the type it builds, and don't add methods that no test uses yet.
- Hundreds of theory rows are a finding. Keep a few rows that each show a different rule, and move the bulk into a data file.

## Names

A test name is read in a failure report, usually without the code. It must say what is true of the system.

- Use snake case, and state a fact. Never use "should" or "when".
- State the rule, not the mechanism that enforces it. "An empty project path is not valid" is better than "Validation rejects the request".
- Write a real English sentence, with articles: `A_project_path_is_required`, not `Project_path_required`.
- Never use the name of the method under test, a type name or any other code element.
- Don't use `Can_` for behavior that always happens. `Can_throw_for_a_missing_project` suggests it sometimes doesn't.
- Don't repeat the purpose of the test class in the method name.
- Suffix test classes with `Specs`, never `Tests`.

| Instead of | Write |
| --- | --- |
| `GetNuGetReleaseNotes_WithMissingChangelog_DoesNotThrow` | `Missing_changelog_does_not_add_a_full_changelog_link_to_release_notes` |
| `Throws_error_if_project_path_is_empty` | `An_empty_project_path_is_not_valid` |
| `Can_throw_when_target_is_not_found` | `An_unknown_target_is_rejected` |
| `ParseTestRunner_returns_null_for_unknown` | `Unknown_test_runner_names_are_ignored` |

## Coverage

- Give every new rule its own test.
- When a rule depends on the environment, such as an environment variable or the installed SDK, move the decision into a method that takes those values as parameters. Test that method.
- Test reusable parts, such as a parser or an argument builder, on their own and not only through the code that uses them.
- Test files and namespaces mirror the project under test.
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Do commit code generated by `GenerateTools` — the `.Generated.cs` files are ch

Full rules and examples: the `plain-english` skill, including issue/PR shape (Problem → Outcome → Acceptance criteria, anti-patterns).
9. **Never ping the former NUKE maintainer, Matthias Koch (GitHub handle `matkoch`).** He no longer maintains Fallout and does not want the notifications. Do not `@`-mention him (never write `@` before his handle, in any file or GitHub surface), add him as a reviewer/assignee, request his review, tag him in issue/PR/commit text, or add him as a commit co-author/`Co-authored-by:` trailer — from any AI tool. Credit NUKE's origin by name or a plain profile link — just never with a leading `@` (a bare `@handle` is what fires a mention).
10. **Follow the `writing-csharp` skill for every C# change**, in `src/`, `tests/` and `build/`. Its rules win over the style of the code around your change. Don't reformat code you don't otherwise touch. Before you open a PR, walk its review checklist.

## Repository map

Expand All @@ -96,6 +97,7 @@ Production code lives under `src/`, tests under `tests/` — don't reintroduce a
| --- | --- |
| Opening a PR, writing commits, picking a base branch | `creating-a-pr` skill |
| Writing any PR, commit, issue, or doc text | `plain-english` skill |
| Writing, changing, or reviewing C# code, including tests | `writing-csharp` skill |
| Adding/extending a `Tools/<Tool>/<Tool>.json` wrapper | `adding-a-tool-wrapper` skill |
| Adding public API that isn't stable yet, or deprecating one | `marking-experimental-apis` skill |
| Proposing a new public API before writing code | [CONTRIBUTING.md § Proposing new public API](CONTRIBUTING.md#proposing-new-public-api) |
Expand Down
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Skills live under `.agents/skills/` (tool-neutral — Copilot CLI auto-discovers

- [.agents/skills/creating-a-pr/SKILL.md](.agents/skills/creating-a-pr/SKILL.md) — opening a PR, writing commits, picking a base branch, writing plain terse PR/issue descriptions.
- [.agents/skills/plain-english/SKILL.md](.agents/skills/plain-english/SKILL.md) — writing any PR, commit, issue, or doc text so non-native English readers follow it on the first pass.
- [.agents/skills/writing-csharp/SKILL.md](.agents/skills/writing-csharp/SKILL.md) — writing, changing, or reviewing C# code, including tests.
- [.agents/skills/adding-a-tool-wrapper/SKILL.md](.agents/skills/adding-a-tool-wrapper/SKILL.md) — adding or extending a `Tools/<Tool>/<Tool>.json` wrapper.
- [.agents/skills/marking-experimental-apis/SKILL.md](.agents/skills/marking-experimental-apis/SKILL.md) — adding public API that isn't stable yet, or deprecating one.
- [.agents/skills/editing-ci-workflows/SKILL.md](.agents/skills/editing-ci-workflows/SKILL.md) — touching `.github/workflows/**` or `build/Build.CI.GitHubActions.cs`.
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ This applies to a new public type or member, not a small additive overload or a
### When writing the PR

- **Write functional commit and PR titles** — describe what the change accomplishes, not how it's categorised. Do not use conventional-commit prefixes (`feat:`, `fix:`, `chore:`, `refactor:`, etc.). Good examples: "Add retry logic to the HTTP tool wrapper", "Fix null-reference in target dependency resolution". The `!` suffix (e.g. `fix(security)!: …`) is recognised only as a breaking-change detection signal, not a general style requirement.
- Aim for qualitative, readable code that matches the surrounding style.
- Aim for qualitative, readable code. Follow the [C# conventions](.agents/skills/writing-csharp/SKILL.md). Where they say nothing, match the surrounding style.
- There's no committed `.editorconfig` or ReSharper/`*.DotSettings` file — they were removed during the takeover. Rely on `dotnet format` defaults and review; don't reintroduce them without a maintainer-level decision.
- Add tests when meaningful — every `Foo` project has a sibling `Foo.Tests`. A few conventions to follow:
- **Test names read as behavior, not method calls** (AV1600-style): `Missing_changelog_does_not_add_a_full_changelog_link_to_release_notes`, not `GetNuGetReleaseNotes_WithMissingChangelog_AndGitHubRepository_DoesNotThrow`.
Expand Down
Loading