Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .claude/hooks/ensure-pwsh.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env bash
# Copyright (c) 2026 Marcin Polewski
# SPDX-License-Identifier: MIT
#
# ensure-pwsh.sh - make PowerShell available in a Claude Code cloud session.
#
Expand Down
2 changes: 2 additions & 0 deletions .claude/hooks/session-start.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env bash
# Copyright (c) 2026 Marcin Polewski
# SPDX-License-Identifier: MIT
#
# session-start.sh - bootstrap the tools a Claude Code cloud session needs.
#
Expand Down
4 changes: 2 additions & 2 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Written by Copier; never edit by hand. Change an answer with .template\Update-Project.ps1 -Data.
_commit: v0.113.2
_src_path: /home/user/project-template
_commit: v0.114.0
_src_path: https://github.com/NCodeGroup/project-template.git
author_name: NCode Group
build_command: dotnet build
code_review: true
Expand Down
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@
# EF Core migrations are scaffolded by dotnet ef, not written by hand: the analyzers treat them as generated code.
[**/Migrations/**.cs]
generated_code = true

# xunit.v3 generates each test project's entry point into obj/, and it blocks on the test run's task, which build/BannedSymbols.txt bans (RS0030): the ban holds for the project's own code, not this generated file.

Check notice on line 52 in .editorconfig

View check run for this annotation

NCode Review / Code review

F1 Nit: New comments are not wrapped to the 120-column width of nearby comments

Two new comments are each a single long line: the RS0030 exemption comment in `.editorconfig` runs about 230–270 columns, while the EF Core migrations comment above it stays near 120, and the `Restore-NewerPin` header comment in `.template/Update-Project.ps1` (line 636) runs about 480 characters. Consequence: The lines are hard to read and break the wrap used around them. Both files come from the template, so reflowing them here would create a diff against the template's text. Fix: Is it intended to keep the template's text unwrapped? If not, wrap each comment to about 120 columns over several `#` lines, ideally upstream in the template.
Comment thread
polewskm marked this conversation as resolved.
Resolved
[**/obj/**/XunitAutoGeneratedEntryPoint.cs]

Check notice on line 53 in .editorconfig

View check run for this annotation

NCode Review / Code review

F2 Nit: RS0030 override names no issue, decision or removal condition

The new `[**/obj/**/XunitAutoGeneratedEntryPoint.cs]` section turns RS0030 off and explains why, but it names no tracking issue or ADR and no condition for removing it. Consequence: A later maintainer can't tell when the override can go, for example once xunit.v3 stops generating the blocking call. Fix: Does a template-owned line need this? If so, add the template's issue or ADR reference and the removal condition to the comment.
Comment thread
polewskm marked this conversation as resolved.
Resolved
dotnet_diagnostic.RS0030.severity = none
2 changes: 2 additions & 0 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env sh
# Copyright (c) 2026 Marcin Polewski
# SPDX-License-Identifier: MIT
#
# pre-push - keep pushes off the default branch when the Landing policy says so.
#
Expand Down
23 changes: 16 additions & 7 deletions .github/instructions/csharp-tests.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ using System.Runtime.CompilerServices;

`DynamicProxyGenAssembly2` lets Moq proxy internal types; the second name must match the real test assembly. Keep test-only access `internal`. Never make a member `public` for a test.

### xUnit Packages

`./build/dod.ps1` runs `dotnet test` in VSTest mode, which collects coverage through `Microsoft.NET.Test.Sdk`, so every test project runs on VSTest.

- On xUnit v2, a test project references `xunit`, `xunit.runner.visualstudio` and `Microsoft.NET.Test.Sdk`, as `dotnet new xunit` writes them.
- On xUnit v3, it references `xunit.v3.mtp-off`, never `xunit.v3`, with `xunit.runner.visualstudio` 4.0 or later and `Microsoft.NET.Test.Sdk`, and sets `<OutputType>Exe</OutputType>`, as `dotnet new xunit3 --test-runner vstest` writes them. From 4.0 on, `xunit.v3` runs on Microsoft.Testing.Platform, and the .NET 10 SDK refuses to run such a project in VSTest mode: "Testing with VSTest target is no longer supported by Microsoft.Testing.Platform on .NET 10 SDK and later".
- Never set `global.json`'s test runner to `Microsoft.Testing.Platform`: `dotnet test` then runs every test project on it, and the filter, test results and coverage `./build/dod.ps1` asks for are VSTest's.
- xunit.v3 generates each test project's entry point into `obj/`, `XunitAutoGeneratedEntryPoint.cs`, which blocks on the test run's task. `.editorconfig` turns RS0030, the banned-API rule, off for that file alone; the project's own code keeps the ban.

### Regions

Group tests in a class with `#region` blocks per member under test:
Expand Down Expand Up @@ -110,15 +119,15 @@ public void MyMethod_WhenCondition_ExpectedBehavior()
```csharp
public abstract class UnitTestBase : IDisposable
{
private readonly MockRepository _mocks = new(MockBehavior.Strict);
private MockRepository Mocks { get; } = new(MockBehavior.Strict);

protected Mock<T> CreateStrictMock<T>(params object[] args)
where T : class => _mocks.Create<T>(args);
protected Mock<T> CreateStrictMock<T>(params IEnumerable<object> args)
where T : class => Mocks.Create<T>([.. args]);

protected Mock<T> CreateLooseMock<T>(params object[] args)
where T : class => _mocks.Create<T>(MockBehavior.Loose, args);
protected Mock<T> CreateLooseMock<T>(params IEnumerable<object> args)
where T : class => Mocks.Create<T>(MockBehavior.Loose, [.. args]);

protected Mock<T> CreatePartialMock<T>(params object[] args)
protected Mock<T> CreatePartialMock<T>(params IEnumerable<object> args)
where T : class
{
var mock = CreateLooseMock<T>(args);
Expand All @@ -135,7 +144,7 @@ public abstract class UnitTestBase : IDisposable
protected virtual void Dispose(bool disposing)
{
if (disposing)
_mocks.Verify();
Mocks.Verify();
}
}
```
Expand Down
1 change: 1 addition & 0 deletions .github/instructions/project-template.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ When GitHub Copilot's cloud agent works on an issue in this repository, its envi
- The SDK version is pinned in `global.json`, and Dependabot proposes newer ones. Moving the target frameworks to a new .NET major version is a planned migration (`/plan-migration`).
- Production projects live under `src/` and test projects under `tests/`, each test project named for the project it tests with a `.Tests` suffix. Every project belongs to the solution at the repository root, so `dotnet build` and `dotnet test` there cover all of them. Create it with `dotnet new sln` when adding the first project, and add each new project with `dotnet sln add <project folder>`.
- Package versions are in `Directory.Packages.props` (central package management); `<PackageReference>` items carry no `Version`. `dotnet add package` already writes the version there. `dotnet new` templates don't: they put `Version` on each `<PackageReference>`, which fails the build with NU1008 — move each version into a `<PackageVersion>` item in `Directory.Packages.props`.
- A test project on xUnit v3 references `xunit.v3.mtp-off`, never `xunit.v3`, with `xunit.runner.visualstudio` and `Microsoft.NET.Test.Sdk`, as `dotnet new xunit3 --test-runner vstest` writes them: `./build/dod.ps1` runs `dotnet test` in VSTest mode, which the .NET 10 SDK refuses for a project on Microsoft.Testing.Platform, the default of `xunit.v3` from 4.0 on. `.github/instructions/csharp-tests.instructions.md` says more.
- C# conventions: `.github/instructions/csharp.instructions.md`, and `.github/instructions/csharp-tests.instructions.md` for test projects. Read them before editing `.cs` files.
3 changes: 0 additions & 3 deletions .github/workflows/code-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ name: Code review
# docs/decisions/project-template/0022-ncode-reviews-approval-gates-the-merge.md,
# 0034-with-one-writer-the-baseline-requires-no-approval.md and
# 0036-a-required-approval-is-met-by-ncode-reviews-approver-app.md say why.
# v1.5.0 was released on 2026-11-21, under the three days ADR-0009 waits: approver-private-key needs it, so it is
# pinned by that record's commented exception, and this sentence goes once 2026-11-24 has passed
# (NCodeGroup/project-template#475).
#
# pull_request_target and issue_comment both run this file from the default branch, so a pull request can't change its
# own review. The engine fetches its code only to read it: nothing from it is built, run or installed.
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# v2.6.0 was released on 2026-11-19, under the three days ADR-0009 waits: it runs Scorecard v5.7.0, which counts
# immutable releases, so it is pinned by that record's commented exception, and this comment goes once
# 2026-11-22 has passed (NCodeGroup/project-template#481).
- name: Run Scorecard
uses: ossf/scorecard-action@23f22cd43608bae7a1f1fa2603d7314dee9538a5 # v2.6.0
with:
Expand Down
2 changes: 1 addition & 1 deletion .template-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.113.2
v0.114.0
3 changes: 3 additions & 0 deletions .template/Get-PlanState.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2026 Marcin Polewski
# SPDX-License-Identifier: MIT

<#
.SYNOPSIS
Print where the plan in a folder stands, and the workflow command to run next.
Expand Down
3 changes: 3 additions & 0 deletions .template/Get-TemplateUpdate.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2026 Marcin Polewski
# SPDX-License-Identifier: MIT

<#
.SYNOPSIS
Keep one open GitHub issue that says a newer project template version is out, with its release notes.
Expand Down
3 changes: 3 additions & 0 deletions .template/Publish-Release.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2026 Marcin Polewski
# SPDX-License-Identifier: MIT

<#
.SYNOPSIS
Tag and publish the release the changelog's newest section names, once the remote has no tag for it.
Expand Down
3 changes: 3 additions & 0 deletions .template/Test-AdrIndex.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2026 Marcin Polewski
# SPDX-License-Identifier: MIT

<#
.SYNOPSIS
Checks that docs/decisions/README.md indexes every decision record in docs/decisions/, and nothing else.
Expand Down
3 changes: 3 additions & 0 deletions .template/Test-Coverage.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2026 Marcin Polewski
# SPDX-License-Identifier: MIT

<#
.SYNOPSIS
Fail when the tests cover less than 90% of the statements or 80% of the branches.
Expand Down
12 changes: 8 additions & 4 deletions .template/Test-FileHeaders.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2026 Marcin Polewski
# SPDX-License-Identifier: MIT

<#
.SYNOPSIS
Fail on a source file that doesn't start with the copyright line and the SPDX license line.
Expand All @@ -12,9 +15,9 @@
.astro, whose lines must sit between its leading "---" lines so nothing reaches the built page. Files of other
kinds, and names ending in .min.js, aren't checked. Nor does it check the five build scripts the template owns
(build/dod.ps1, Update-PublicApi.ps1, Get-TestRuntimes.ps1, Install-Dotnet.ps1 and Update-Baseline.ps1), which
updates replace. A hand-written declaration file (.d.ts) is checked like any
TypeScript file; a generated one, like other build output, sits in a git-ignored folder, which git ls-files
leaves out.
updates replace and which carry the template's own copyright and license lines (the template's ADR-0038). A
hand-written declaration file (.d.ts) is checked like any TypeScript file; a generated one, like other build
output, sits in a git-ignored folder, which git ls-files leaves out.
Prints each miss and exits 1 when there is one, else 0. With -Fix, it adds the missing lines instead, after any #!
line or an .astro file's opening "---" line, giving an .astro file without frontmatter a "---" block that holds
them, keeping the file's line endings and byte order mark, and exits 0. Without an author_name answer there is no
Expand Down Expand Up @@ -61,7 +64,8 @@ $spdxLine = if ($license) { "SPDX-License-Identifier: $license" }
$hashMarker = '.ps1', '.psm1', '.py', '.sh', '.bash', '.rb', '.tf'
$slashMarker = '.js', '.mjs', '.cjs', '.jsx', '.ts', '.mts', '.cts', '.tsx', '.go', '.rs', '.java', '.kt', '.kts', '.swift', '.c', '.h', '.cc', '.cpp', '.hpp', '.cs', '.scala', '.dart', '.groovy', '.astro'
$blockMarker = '.css', '.scss', '.less'
# Scripts the template owns and updates replace, so a header added to one would be discarded.
# Scripts the template owns and updates replace: they carry the template's copyright and license lines, not the
# project's (the template's ADR-0038).
$templateOwned = 'build/dod.ps1', 'build/Update-PublicApi.ps1', 'build/Get-TestRuntimes.ps1', 'build/Install-Dotnet.ps1', 'build/Update-Baseline.ps1'

$listed = git -C $Root ls-files -z
Expand Down
14 changes: 8 additions & 6 deletions .template/Test-ReproducibleBuild.ps1
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Copyright (c) 2026 Marcin Polewski
# SPDX-License-Identifier: MIT

<#
.SYNOPSIS
Packs the project twice from clean build folders and compares the packages entry by entry, the template's ADR-0154.

.DESCRIPTION
From the project template; template updates replace this file. Proves a commit's packages depend on nothing the
clock or the machine supplies. It deletes every bin and obj folder under the root, packs, deletes them again and
packs a second time, then compares each package of the first build with the same-named package of the second:
the same entry names and the same SHA-256 of each entry's contents. Zip timestamps are never compared.
clock or the machine supplies. It deletes every bin and obj folder under the root, except those under its
artifacts, node_modules, .git and .claude folders, packs, deletes them again and packs a second time, then
compares each package of the first build with the same-named package of the second: the same entry names and the
same SHA-256 of each entry's contents. Zip timestamps are never compared.

It prints one line per difference and exits 1, prints how many packages match and exits 0, or prints
'No packages to compare.' and exits 0 when nothing was packed.
Expand Down Expand Up @@ -59,9 +63,7 @@ if (Test-Path -LiteralPath $output) {
}

foreach ($pass in 'first', 'second') {
$skipped = [IO.Path]::DirectorySeparatorChar + 'artifacts' + [IO.Path]::DirectorySeparatorChar,
[IO.Path]::DirectorySeparatorChar + 'node_modules' + [IO.Path]::DirectorySeparatorChar,
[IO.Path]::DirectorySeparatorChar + '.git' + [IO.Path]::DirectorySeparatorChar
$skipped = @('artifacts', 'node_modules', '.git', '.claude' | ForEach-Object { [IO.Path]::DirectorySeparatorChar + $_ + [IO.Path]::DirectorySeparatorChar })
Get-ChildItem -LiteralPath $root -Directory -Recurse -Force |
Where-Object { $_.Name -in 'bin', 'obj' } |
Where-Object {
Expand Down
Loading
Loading