From 791cf0f07ec95f9b5f6e1bf0dbfbb9d006f20730 Mon Sep 17 00:00:00 2001 From: Marcin Polewski Date: Wed, 25 Nov 2026 16:20:13 -0700 Subject: [PATCH 1/4] Plan step 1: Point _src_path at the template's GitHub address --- .copier-answers.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.copier-answers.yml b/.copier-answers.yml index 4fa4914..d65c48b 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -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 +_src_path: https://github.com/NCodeGroup/project-template.git author_name: NCode Group build_command: dotnet build code_review: true From 733fde47784c7dc4334e34ba40b7028eea230fdc Mon Sep 17 00:00:00 2001 From: Marcin Polewski Date: Wed, 25 Nov 2026 16:22:35 -0700 Subject: [PATCH 2/4] Plan step 2: Update from project-template v0.114.0 --- .claude/hooks/ensure-pwsh.sh | 2 + .claude/hooks/session-start.sh | 2 + .copier-answers.yml | 2 +- .editorconfig | 4 + .githooks/pre-push | 2 + .../instructions/csharp-tests.instructions.md | 23 +++-- .../project-template.instructions.md | 1 + .github/workflows/scorecard.yml | 3 - .template-version | 2 +- .template/Get-PlanState.ps1 | 3 + .template/Get-TemplateUpdate.ps1 | 3 + .template/Publish-Release.ps1 | 3 + .template/Test-AdrIndex.ps1 | 3 + .template/Test-Coverage.ps1 | 3 + .template/Test-FileHeaders.ps1 | 12 ++- .template/Test-ReproducibleBuild.ps1 | 14 ++-- .template/Update-Project.ps1 | 84 +++++++++++++++++-- build/Get-TestRuntimes.ps1 | 3 + build/Install-Dotnet.ps1 | 3 + build/Update-Baseline.ps1 | 5 +- build/Update-PublicApi.ps1 | 5 +- build/dod.ps1 | 5 +- docs/best-practices-criteria.md | 6 +- ...rry-the-templates-copyright-and-license.md | 49 +++++++++++ docs/decisions/project-template/README.md | 1 + 25 files changed, 206 insertions(+), 37 deletions(-) create mode 100644 docs/decisions/project-template/0038-the-templates-scripts-carry-the-templates-copyright-and-license.md diff --git a/.claude/hooks/ensure-pwsh.sh b/.claude/hooks/ensure-pwsh.sh index 20e25f7..31efa6d 100644 --- a/.claude/hooks/ensure-pwsh.sh +++ b/.claude/hooks/ensure-pwsh.sh @@ -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. # diff --git a/.claude/hooks/session-start.sh b/.claude/hooks/session-start.sh index e423ddd..26ecb0a 100644 --- a/.claude/hooks/session-start.sh +++ b/.claude/hooks/session-start.sh @@ -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. # diff --git a/.copier-answers.yml b/.copier-answers.yml index d65c48b..6980d32 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Written by Copier; never edit by hand. Change an answer with .template\Update-Project.ps1 -Data. -_commit: v0.113.2 +_commit: v0.114.0 _src_path: https://github.com/NCodeGroup/project-template.git author_name: NCode Group build_command: dotnet build diff --git a/.editorconfig b/.editorconfig index bd3d36d..b5e4107 100644 --- a/.editorconfig +++ b/.editorconfig @@ -48,3 +48,7 @@ indent_size = 2 # 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. +[**/obj/**/XunitAutoGeneratedEntryPoint.cs] +dotnet_diagnostic.RS0030.severity = none diff --git a/.githooks/pre-push b/.githooks/pre-push index 9c551e5..e1e3c3c 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -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. # diff --git a/.github/instructions/csharp-tests.instructions.md b/.github/instructions/csharp-tests.instructions.md index 13159a0..9327f34 100644 --- a/.github/instructions/csharp-tests.instructions.md +++ b/.github/instructions/csharp-tests.instructions.md @@ -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 `Exe`, 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: @@ -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 CreateStrictMock(params object[] args) - where T : class => _mocks.Create(args); + protected Mock CreateStrictMock(params IEnumerable args) + where T : class => Mocks.Create([.. args]); - protected Mock CreateLooseMock(params object[] args) - where T : class => _mocks.Create(MockBehavior.Loose, args); + protected Mock CreateLooseMock(params IEnumerable args) + where T : class => Mocks.Create(MockBehavior.Loose, [.. args]); - protected Mock CreatePartialMock(params object[] args) + protected Mock CreatePartialMock(params IEnumerable args) where T : class { var mock = CreateLooseMock(args); @@ -135,7 +144,7 @@ public abstract class UnitTestBase : IDisposable protected virtual void Dispose(bool disposing) { if (disposing) - _mocks.Verify(); + Mocks.Verify(); } } ``` diff --git a/.github/instructions/project-template.instructions.md b/.github/instructions/project-template.instructions.md index bc0acf7..4057ccd 100644 --- a/.github/instructions/project-template.instructions.md +++ b/.github/instructions/project-template.instructions.md @@ -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 `. - Package versions are in `Directory.Packages.props` (central package management); `` items carry no `Version`. `dotnet add package` already writes the version there. `dotnet new` templates don't: they put `Version` on each ``, which fails the build with NU1008 — move each version into a `` 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. diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index 7737454..a548d57 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -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: diff --git a/.template-version b/.template-version index 46ed501..de4d977 100644 --- a/.template-version +++ b/.template-version @@ -1 +1 @@ -v0.113.2 +v0.114.0 diff --git a/.template/Get-PlanState.ps1 b/.template/Get-PlanState.ps1 index e364e17..7fe6a59 100644 --- a/.template/Get-PlanState.ps1 +++ b/.template/Get-PlanState.ps1 @@ -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. diff --git a/.template/Get-TemplateUpdate.ps1 b/.template/Get-TemplateUpdate.ps1 index 766a83c..500456b 100644 --- a/.template/Get-TemplateUpdate.ps1 +++ b/.template/Get-TemplateUpdate.ps1 @@ -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. diff --git a/.template/Publish-Release.ps1 b/.template/Publish-Release.ps1 index 4b4d1d2..001c7db 100644 --- a/.template/Publish-Release.ps1 +++ b/.template/Publish-Release.ps1 @@ -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. diff --git a/.template/Test-AdrIndex.ps1 b/.template/Test-AdrIndex.ps1 index b51f42b..96fec28 100644 --- a/.template/Test-AdrIndex.ps1 +++ b/.template/Test-AdrIndex.ps1 @@ -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. diff --git a/.template/Test-Coverage.ps1 b/.template/Test-Coverage.ps1 index 4aa9780..01fc3cd 100644 --- a/.template/Test-Coverage.ps1 +++ b/.template/Test-Coverage.ps1 @@ -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. diff --git a/.template/Test-FileHeaders.ps1 b/.template/Test-FileHeaders.ps1 index 6a37c0a..3a6af24 100644 --- a/.template/Test-FileHeaders.ps1 +++ b/.template/Test-FileHeaders.ps1 @@ -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. @@ -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 @@ -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 diff --git a/.template/Test-ReproducibleBuild.ps1 b/.template/Test-ReproducibleBuild.ps1 index 88b9f94..a479130 100644 --- a/.template/Test-ReproducibleBuild.ps1 +++ b/.template/Test-ReproducibleBuild.ps1 @@ -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. @@ -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 { diff --git a/.template/Update-Project.ps1 b/.template/Update-Project.ps1 index 3b4f22b..2d71226 100644 --- a/.template/Update-Project.ps1 +++ b/.template/Update-Project.ps1 @@ -1,3 +1,6 @@ +# Copyright (c) 2026 Marcin Polewski +# SPDX-License-Identifier: MIT + <# .SYNOPSIS Update this project to the newest version of the project template it was created from, and commit it. @@ -18,6 +21,9 @@ reset first, discarding a local edit, and listed as refreshed. A file the update leaves as the project had it, such as an edit the new version also makes or a deleted file it also deletes, is listed under none of these. + An action pin, a uses: @ # line, that the project moved past + the new version's pin of that action in the same file, such as a Dependabot bump the + template hasn't made yet, is kept and listed as kept, so an update never downgrades it. Merged Files whose tools can't include a second file (copier.yml's _merged_files). The template's changes are merged with the project's edits, like a Git merge; the same lines changed on both sides conflict. An adopted project's own lines at the end of .gitignore, @@ -95,7 +101,7 @@ in .github/workflows runs on a release event or uploads release assets, whose releases the template's tools/Set-RepositoryBaseline.ps1 leaves mutable, it says to delete or leave out that paragraph, also when the project is already up to date (the template's ADR-0028). - With NCode Review, when .github/workflows/code-review.yml pins NCodeGroup/code-review before v1.5.0, passes no approve: true or passes approve: true without approver-private-key, or AGENTS.md's Landing section doesn't say draft: yes, it says what to change, to store the approver's key with tools/Enable-CodeReview.ps1 -ApproverPrivateKeyPath from NCodeGroup/code-review and to run the template's tools/Set-RepositoryBaseline.ps1 again, also when the project is already up to date (the template's ADR-0022 and ADR-0036). It says that v1.5.0, published on 2026-11-21, waits out the three-day cooldown of the template's ADR-0009 until 2026-11-24, or is adopted sooner only by that record's commented exception. + With NCode Review, when .github/workflows/code-review.yml pins NCodeGroup/code-review before v1.5.0, passes no approve: true or passes approve: true without approver-private-key, or AGENTS.md's Landing section doesn't say draft: yes, it says what to change, to store the approver's key with tools/Enable-CodeReview.ps1 -ApproverPrivateKeyPath from NCodeGroup/code-review and to run the template's tools/Set-RepositoryBaseline.ps1 again, also when the project is already up to date (the template's ADR-0022 and ADR-0036). On Windows it stops before it changes anything when the project's template version has a path Git for Windows refuses to check out, such as the uses_node file names of v0.69.0 to v0.75.0, because the update starts with @@ -321,8 +327,7 @@ function Get-CiPermissionNote { # NCode Review approves a clean pull request only with approve: true, and from NCodeGroup/code-review v1.5.0 on submits the # approval as the NCode Review Approver, which meets a required approval, when approver-private-key is passed; code-review.yml -# and AGENTS.md are project-owned, so the update can only say what they still lack (the template's ADR-0022 and ADR-0036), -# and when ADR-0009's cooldown lets it adopt v1.5.0. +# and AGENTS.md are project-owned, so the update can only say what they still lack (the template's ADR-0022 and ADR-0036). function Get-CodeReviewNote { $workflow = '.github/workflows/code-review.yml' if (-not (Test-Path -LiteralPath $workflow -PathType Leaf)) { return } @@ -350,7 +355,7 @@ function Get-CodeReviewNote { } if (-not $findings.Count) { return } '' - "NCode Review approves a clean pull request only with approve: true, and from NCodeGroup/code-review v1.5.0 on, given approver-private-key, submits the approval as the NCode Review Approver, an app that can write, so the approval meets a required approval (the template's ADR-0022, ADR-0034 and ADR-0036, in docs/decisions/project-template/): $($findings -join '; '). Pin v1.5.0 or later (published on 2026-11-21: the three-day cooldown of the template's ADR-0009 adopts it from 2026-11-24, and sooner only by that record's commented exception) and pass approve: true and approver-private-key: `${{ secrets.NCODE_REVIEW_APPROVER_PRIVATE_KEY }} in the review job of .github/workflows/code-review.yml, as the template's code-review.yml does, store the approver's key in the code-review environment with tools/Enable-CodeReview.ps1 -ApproverPrivateKeyPath from NCodeGroup/code-review, set - draft: yes in AGENTS.md's Landing section, so a pull request opens as a draft and marking it ready is the maintainer's review, then run the template's tools/Set-RepositoryBaseline.ps1 again, so the default branch dismisses stale approvals and requires one approval, of the last push, where the approver is set up or a second person has write access." + "NCode Review approves a clean pull request only with approve: true, and from NCodeGroup/code-review v1.5.0 on, given approver-private-key, submits the approval as the NCode Review Approver, an app that can write, so the approval meets a required approval (the template's ADR-0022, ADR-0034 and ADR-0036, in docs/decisions/project-template/): $($findings -join '; '). Pin v1.5.0 or later and pass approve: true and approver-private-key: `${{ secrets.NCODE_REVIEW_APPROVER_PRIVATE_KEY }} in the review job of .github/workflows/code-review.yml, as the template's code-review.yml does, store the approver's key in the code-review environment with tools/Enable-CodeReview.ps1 -ApproverPrivateKeyPath from NCodeGroup/code-review, set - draft: yes in AGENTS.md's Landing section, so a pull request opens as a draft and marking it ready is the maintainer's review, then run the template's tools/Set-RepositoryBaseline.ps1 again, so the default branch dismisses stale approvals and requires one approval, of the last push, where the approver is set up or a second person has write access." } # Nerdbank.GitVersioning, which version.json turns on (the template's ADR-0138), fails a build on a shallow clone and ignores -p:Version: name each job of the project's own workflows, other than publish.yml, which has its own check, that builds, packs, tests without --no-build or pushes packages in a shallow actions/checkout's folder, by the step's working-directory: or the job's or workflow's defaults:, or with a -p:Version argument. @@ -628,6 +633,57 @@ function Test-EditKept([string]$File, [string]$ResetCommit, [string]$Head) { $true } +# Writes back each action pin of a template-owned file that the project moved past the new version's pin of that action, such as a Dependabot bump the template hasn't made yet (#495), so the update never downgrades it. Leaves a file Git lists as conflicted as it is, and throws, naming the file, when Git can't read its state or the project's changes to it. Returns File, Action, Kept and Template, once per action written back, in the order the file pins them. +function Restore-NewerPin([string]$File, [string]$ResetCommit, [string]$Head) { + $pin = '^(?[ \t]*(?:-[ \t]+)?uses:[ \t]*)(?[A-Za-z0-9_.-]+/[A-Za-z0-9_./-]+)@(?[0-9a-fA-F]{40})(?[ \t]+#[ \t]*)(?v?[0-9]+(?:\.[0-9]+){0,3})[ \t]*\z' + $unmerged = @(git -c core.quotePath=false ls-files --unmerged -- $File) + if ($LASTEXITCODE) { throw "Reading whether $File has a conflict failed." } + if ($unmerged) { return } + $diff = @(git -c core.quotePath=false diff --no-color --no-ext-diff --no-renames -U0 $ResetCommit $Head -- $File) + if ($LASTEXITCODE) { throw "Reading this project's changes to $File failed." } + $path = Join-Path $project $File + if (-not (Test-Path -LiteralPath $path -PathType Leaf)) { return } + $ours = @{} + $inHunk = $false + foreach ($line in $diff) { + if ($line.StartsWith('@@')) { $inHunk = $true; continue } + if (-not $inHunk -or -not $line.StartsWith('+')) { continue } + if ($line.Substring(1).TrimEnd("`r") -match $pin) { + $entry = "$($Matches['sha']) $($Matches['version'])" + if (-not $ours.ContainsKey($Matches['action'])) { $ours[$Matches['action']] = [Collections.Generic.List[string]]::new() } + if (-not $ours[$Matches['action']].Contains($entry)) { $ours[$Matches['action']].Add($entry) } + } + } + if (-not $ours.Count) { return } + $parse = { + param([string]$Text) + $number = $Text.TrimStart('v') + if (-not $number.Contains('.')) { $number += '.0' } + $parsed = $null + if ([version]::TryParse($number, [ref]$parsed)) { $parsed } + } + $pieces = @([IO.File]::ReadAllText($path) -split '(?<=\n)') + $recorded = [ordered]@{} + $changed = $false + for ($i = 0; $i -lt $pieces.Count; $i++) { + $piece = $pieces[$i] + $eol = if ($piece -match '\r?\n\z') { $Matches[0] } else { '' } + $body = $piece.Substring(0, $piece.Length - $eol.Length) + if ($body -notmatch $pin) { continue } + $lead = $Matches['lead']; $action = $Matches['action']; $gap = $Matches['gap']; $version = $Matches['version'] + if (-not $ours.ContainsKey($action) -or $ours[$action].Count -ne 1) { continue } + $sha, $ourVersion = $ours[$action][0] -split ' ' + $ourParsed = & $parse $ourVersion + $lineParsed = & $parse $version + if (-not $ourParsed -or -not $lineParsed -or $ourParsed -le $lineParsed) { continue } + $pieces[$i] = "$lead$action@$sha$gap$ourVersion$eol" + $changed = $true + if (-not $recorded.Contains($action)) { $recorded[$action] = [pscustomobject]@{ File = $File; Action = $action; Kept = $ourVersion; Template = $version } } + } + if ($changed) { [IO.File]::WriteAllText($path, -join $pieces) } + $recorded.Values +} + # How to run the template's .githooks in this clone: HooksPath when core.hooksPath can point at it, otherwise the # Note to warn with. A hooks path turns off the hooks in .git/hooks. # A hooks path the clone already has, from any Git config, is never changed: one that names a .githooks folder runs the @@ -718,8 +774,9 @@ function Get-CSharpFileWithoutHeader { $setting = [regex]::Match([IO.File]::ReadAllText((Join-Path (Get-Location).Path '.editorconfig')), '(?m)^file_header_template\s*=\s*(.+?)\r?$') if (-not $setting.Success) { return } $header = (($setting.Groups[1].Value -split '\\n') | ForEach-Object { "// $_" }) -join "`n" + $root = (Get-Location).ProviderPath foreach ($file in Get-ChildItem -LiteralPath . -Filter *.cs -File -Recurse -ErrorAction SilentlyContinue) { - if ($file.FullName -match '[\\/](bin|obj|node_modules|artifacts|\.git|Migrations)[\\/]' -or $file.Name -match '\.(g|generated|designer)\.cs$') { continue } + if ([IO.Path]::GetRelativePath($root, $file.FullName) -match '(^|[\\/])(bin|obj|node_modules|artifacts|\.git|\.claude|Migrations)[\\/]' -or $file.Name -match '\.(g|generated|designer)\.cs$') { continue } $text = ([IO.File]::ReadAllText($file.FullName).TrimStart([char]0xFEFF)) -replace "`r`n", "`n" if (-not $text.StartsWith("$header`n")) { [IO.Path]::GetRelativePath((Get-Location).Path, $file.FullName) -replace '\\', '/' } } @@ -792,8 +849,9 @@ function Get-AssemblyVersionFloor { function Get-PublishedPackageVersion { param([scriptblock]$Fetch = { param($Uri) Invoke-RestMethod -Uri $Uri -TimeoutSec 20 }) + $root = (Get-Location).ProviderPath foreach ($file in Get-ChildItem -LiteralPath . -Filter *.csproj -File -Recurse -ErrorAction SilentlyContinue) { - if ($file.FullName -match '[\\/](bin|obj|node_modules|artifacts|\.git)[\\/]' -or $file.Name -like '*.Tests.csproj') { continue } + if ([IO.Path]::GetRelativePath($root, $file.FullName) -match '(^|[\\/])(bin|obj|node_modules|artifacts|\.git|\.claude)[\\/]' -or $file.Name -like '*.Tests.csproj') { continue } $text = Get-Content -LiteralPath $file.FullName -Raw if ($text -match '\s*false') { continue } $id = if ($text -match '\s*([^<\s]+)\s*') { $Matches[1] } else { $file.BaseName } @@ -820,7 +878,7 @@ function Get-PackageMetadataDrift { ) $root = (Get-Location).ProviderPath foreach ($file in Get-ChildItem -LiteralPath . -Filter *.csproj -File -Recurse -ErrorAction SilentlyContinue) { - if ($file.FullName -match '[\\/](bin|obj|node_modules|artifacts|\.git)[\\/]' -or $file.Name -like '*.Tests.csproj') { continue } + if ([IO.Path]::GetRelativePath($root, $file.FullName) -match '(^|[\\/])(bin|obj|node_modules|artifacts|\.git|\.claude)[\\/]' -or $file.Name -like '*.Tests.csproj') { continue } $text = Get-Content -LiteralPath $file.FullName -Raw if ($text -match '\s*false') { continue } $id = if ($text -match '\s*([^<\s]+)\s*') { $Matches[1] } else { $file.BaseName } @@ -858,7 +916,7 @@ function Get-PackageMetadataDrift { # A deliberate copy of tools/adopt/Adoption.psm1's Get-NuGetLogistics: change both, or tests\Test-NuGetLogistics.ps1 fails. function Get-NuGetLogistics { $root = (Get-Location).ProviderPath - $excluded = 'bin', 'obj', 'node_modules', 'artifacts', '.git' + $excluded = 'bin', 'obj', 'node_modules', 'artifacts', '.git', '.claude' $found = [Collections.Generic.List[object]]::new() $pending = [Collections.Generic.Stack[string]]::new() $pending.Push($root) @@ -939,7 +997,8 @@ function Get-NuGetLogistics { # tools/adopt/Adoption.psm1 in the template has a deliberate copy of this function, not shared code: this script runs on its own, from an older template's copy. Change both together; tests/Test-LibraryRelease.ps1 keeps the two equal. function Test-PackageValidationBaseline { if ((Test-Path -LiteralPath Directory.Build.props -PathType Leaf) -and (Get-Content -LiteralPath Directory.Build.props -Raw) -match 'PackageValidationBaselineVersion') { return $true } - @(Get-ChildItem -LiteralPath . -Filter *.csproj -File -Recurse -ErrorAction SilentlyContinue | Where-Object { $_.FullName -notmatch '[\\/](bin|obj|node_modules|artifacts|\.git)[\\/]' -and (Get-Content -LiteralPath $_.FullName -Raw) -match 'PackageValidationBaselineVersion' }).Count -gt 0 + $root = (Get-Location).ProviderPath + @(Get-ChildItem -LiteralPath . -Filter *.csproj -File -Recurse -ErrorAction SilentlyContinue | Where-Object { [IO.Path]::GetRelativePath($root, $_.FullName) -notmatch '(^|[\\/])(bin|obj|node_modules|artifacts|\.git|\.claude)[\\/]' -and (Get-Content -LiteralPath $_.FullName -Raw) -match 'PackageValidationBaselineVersion' }).Count -gt 0 } # A deliberate copy of tools/adopt/Adoption.psm1's Update-VersionFile: change both, or tests\Test-LibraryRelease.ps1 fails. @@ -1129,6 +1188,7 @@ try { } $versionFileNew = $false $resetCommit = $null + $keptPins = @() try { # Reset the template-owned files to the project's current version; what changes was edited or deleted here. A file the project owns is left out, so its copy is never overwritten. $exclude = foreach ($file in $projectOwned + $merged + $ownedFiles) { '--exclude', "/$file" } @@ -1198,6 +1258,11 @@ try { if (Test-Path -LiteralPath $full) { [IO.File]::WriteAllText($full, [IO.File]::ReadAllText($full).TrimEnd("`r", "`n") + $keptLines[$file]) } } + # Put back each action pin the project moved past the new version's (Restore-NewerPin, #495), so the update never downgrades one. + if ($resetCommit) { + $keptPins = @(foreach ($change in $reset) { if ($change.Kind -eq 'modified') { Restore-NewerPin $change.File $resetCommit $head } }) + } + # Drop the reset commit but keep its changes, and any conflict, in the index and the working tree. if ($resetCommitted) { git update-ref HEAD $head; if ($LASTEXITCODE) { throw 'Removing the reset commit failed.' } } } @@ -1256,6 +1321,7 @@ try { $restored = @($reset | Where-Object { $_.Kind -eq 'added' -and $_.File -in $differs } | ForEach-Object File) $refreshed = @($refreshed | Where-Object { $_ -in $differs }) if ($edited) { ''; 'Local edits discarded — these files are the template''s; make the change in a project file instead:'; $edited | ForEach-Object { " $_" } } + if ($keptPins) { ''; 'Kept — action pins this project moved past the template''s, such as a Dependabot bump; the template''s older pin would downgrade them:'; $keptPins | ForEach-Object { " $($_.File): $($_.Action) $($_.Kept), where the template pins $($_.Template)" } } if ($restored) { ''; 'Restored — these files are the template''s, so the project can''t delete them:'; $restored | ForEach-Object { " $_" } } if ($droppedTextRules) { ''; "Left out of the lines .gitattributes kept from this repository at adoption: its catch-all text rule ($($droppedTextRules -join '; ')). Git uses the last rule that matches, so the rule overrode the template's binary rules, such as *.png binary and *.ico binary, and git add dropped the CR of each CR LF pair in a binary file it staged. Check the binary files committed while the rule applied, and replace any that no longer open." } if ($refreshed) { ''; 'Refreshed — these files are the template''s, but earlier template versions never updated them; a local edit to one is discarded, so make the change in a project file instead:'; $refreshed | ForEach-Object { " $_" } } diff --git a/build/Get-TestRuntimes.ps1 b/build/Get-TestRuntimes.ps1 index 1c1cfd5..2f08da3 100644 --- a/build/Get-TestRuntimes.ps1 +++ b/build/Get-TestRuntimes.ps1 @@ -1,3 +1,6 @@ +# Copyright (c) 2026 Marcin Polewski +# SPDX-License-Identifier: MIT + <# .SYNOPSIS Names the .NET runtimes the test projects target besides the SDK's own. diff --git a/build/Install-Dotnet.ps1 b/build/Install-Dotnet.ps1 index c7da9fe..a434228 100644 --- a/build/Install-Dotnet.ps1 +++ b/build/Install-Dotnet.ps1 @@ -1,3 +1,6 @@ +# Copyright (c) 2026 Marcin Polewski +# SPDX-License-Identifier: MIT + <# .SYNOPSIS Installs the .NET SDK global.json selects and the runtimes build/Get-TestRuntimes.ps1 names. diff --git a/build/Update-Baseline.ps1 b/build/Update-Baseline.ps1 index 37005e9..74b1ea5 100644 --- a/build/Update-Baseline.ps1 +++ b/build/Update-Baseline.ps1 @@ -1,3 +1,6 @@ +# Copyright (c) 2026 Marcin Polewski +# SPDX-License-Identifier: MIT + <# .SYNOPSIS Raises PackageValidationBaselineVersion to a released version once nuget.org lists it, the template's ADR-0150. @@ -64,7 +67,7 @@ $candidates = @( Relative = [IO.Path]::GetRelativePath($Root, $_.FullName) } } | - Where-Object { $_.Relative -notmatch '(^|[\\/])(bin|obj|node_modules|artifacts|\.git)[\\/]' } | + Where-Object { $_.Relative -notmatch '(^|[\\/])(bin|obj|node_modules|artifacts|\.git|\.claude)[\\/]' } | Sort-Object -Property Relative ) diff --git a/build/Update-PublicApi.ps1 b/build/Update-PublicApi.ps1 index db0f65f..4dc5542 100644 --- a/build/Update-PublicApi.ps1 +++ b/build/Update-PublicApi.ps1 @@ -1,3 +1,6 @@ +# Copyright (c) 2026 Marcin Polewski +# SPDX-License-Identifier: MIT + <# .SYNOPSIS Records each packable project's public API in its PublicAPI.Shipped.txt and PublicAPI.Unshipped.txt. @@ -55,7 +58,7 @@ function Write-ApiFile([string]$Path, [string[]]$Lines) { $projects = if ($Project) { @($Project | ForEach-Object { (Resolve-Path -LiteralPath $_).Path }) } else { @(Get-ChildItem -LiteralPath $root -Recurse -File -Filter '*.csproj' | - Where-Object { $_.FullName -notmatch '[\\/](bin|obj|node_modules|\.git|\.claude)[\\/]' } | + Where-Object { [IO.Path]::GetRelativePath($root, $_.FullName) -notmatch '(^|[\\/])(bin|obj|node_modules|\.git|\.claude)[\\/]' } | ForEach-Object FullName) } $packable = @(foreach ($p in $projects) { diff --git a/build/dod.ps1 b/build/dod.ps1 index d7983c5..dfd0c2a 100644 --- a/build/dod.ps1 +++ b/build/dod.ps1 @@ -1,3 +1,6 @@ +# Copyright (c) 2026 Marcin Polewski +# SPDX-License-Identifier: MIT + <# .SYNOPSIS The Definition of Done: the one gate a change passes before it counts as done, run the same way by people, agents @@ -75,7 +78,7 @@ try { Invoke-Stage 'Build' { dotnet build @buildArgs } $testArgs = @('--configuration', $configuration, '--no-build', '--nologo') if ($Filter) { $testArgs += '--filter', $Filter } - $hasTests = [bool](Get-ChildItem -LiteralPath $root -Recurse -File -Filter '*.Tests.csproj' | Where-Object { $_.FullName -notmatch '[\\/](bin|obj|artifacts|\.claude)[\\/]' } | Select-Object -First 1) + $hasTests = [bool](Get-ChildItem -LiteralPath $root -Recurse -File -Filter '*.Tests.csproj' | Where-Object { [IO.Path]::GetRelativePath($root, $_.FullName) -notmatch '(^|[\\/])(bin|obj|artifacts|\.claude)[\\/]' } | Select-Object -First 1) $coverage = $coverage -and $hasTests if (-not $Fast) { $testArgs += '--logger', 'trx' } if ($coverage -or -not $Fast) { $testArgs += '--results-directory', 'artifacts/test-results' } diff --git a/docs/best-practices-criteria.md b/docs/best-practices-criteria.md index 2164fb8..3fb1ab5 100644 --- a/docs/best-practices-criteria.md +++ b/docs/best-practices-criteria.md @@ -178,7 +178,7 @@ The [silver criteria](https://www.bestpractices.dev/en/criteria/1), 55 in all. | `build_repeatable` | MUST | yes | no | **Check**: Met while `reproducible-build` in `.github/workflows/ci.yml` passes (`./.template/Test-ReproducibleBuild.ps1`, which packs twice and compares entry by entry); a rebuild of a release's tag also matches in a later year because `Copyright` names no year ([ADR-0154](decisions/project-template/0154-a-library-build-takes-nothing-from-the-clock-and-ci-builds-it-twice.md)). | | `installation_common` | MUST | yes | no | **Met**: a NuGet package reference. | | `installation_standard_variables` | MUST | yes | no | **N/A**: it applies only to an installer that writes files where users choose. | -| `installation_development_quick` | MUST | yes | no | **Met**: [CONTRIBUTING.md](../CONTRIBUTING.md) names the prerequisites, the one command that sets up a clone, and the build and test commands. | +| `installation_development_quick` | MUST | yes | no | **Met**: [CONTRIBUTING.md](../CONTRIBUTING.md) names the prerequisites, the commands that set up a clone, and the build and test commands. | | `external_dependencies` | MUST | yes | yes | **Met**: `Directory.Packages.props` and the project files. | | `dependency_monitoring` | MUST | yes | no | **Check**: Dependabot (`.github/dependabot.yml`) and its alerts, which the template's `tools/Set-RepositoryBaseline.ps1` turns on; Security > Dependabot shows the open ones. | | `updateable_reused_components` | MUST | yes | no | **Met**: dependencies are pinned and moved by reviewed updates that Dependabot proposes, with actions pinned to a full commit SHA. | @@ -226,8 +226,8 @@ The [gold criteria](https://www.bestpractices.dev/en/criteria/2), 23 in all. | `achieve_silver` | MUST | no | no | **Check**: the site sets it once the silver level is earned. | | `bus_factor` | MUST | no | yes | **Person**: two or more people who could carry the project on; Unmet with one maintainer, which keeps gold from being earned. | | `contributors_unassociated` | MUST | no | yes | **Person**: at least two significant contributors from different organizations. | -| `copyright_per_file` | MUST | no | no | **Check**: the C# file header `.editorconfig` sets starts with the copyright line, and the build fails a C# file without it; check every other source file, such as scripts. | -| `license_per_file` | MUST | no | no | **Check**: the C# file header holds `SPDX-License-Identifier: Apache-2.0`, and the build fails a C# file without it; check every other source file. | +| `copyright_per_file` | MUST | no | no | **Check**: the C# file header `.editorconfig` sets starts with the copyright line, and the build fails a C# file without it; check every other source file, such as scripts. The scripts the template owns, in `.template/`, `build/`, `.claude/hooks/` and `.githooks/`, carry the template's own copyright line ([ADR-0038](decisions/project-template/0038-the-templates-scripts-carry-the-templates-copyright-and-license.md)). | +| `license_per_file` | MUST | no | no | **Check**: the C# file header holds `SPDX-License-Identifier: Apache-2.0`, and the build fails a C# file without it; check every other source file. The scripts the template owns carry the template's `SPDX-License-Identifier: MIT` ([ADR-0038](decisions/project-template/0038-the-templates-scripts-carry-the-templates-copyright-and-license.md)). | ### Change Control diff --git a/docs/decisions/project-template/0038-the-templates-scripts-carry-the-templates-copyright-and-license.md b/docs/decisions/project-template/0038-the-templates-scripts-carry-the-templates-copyright-and-license.md new file mode 100644 index 0000000..ceab641 --- /dev/null +++ b/docs/decisions/project-template/0038-the-templates-scripts-carry-the-templates-copyright-and-license.md @@ -0,0 +1,49 @@ +# 0038. The template's scripts carry the template's copyright and license + +- **Status:** Accepted +- **Date:** 2026-11-25 +- **Amends:** 0027, where a project has it + +## Context + +The OpenSSF Best Practices gold MUSTs `copyright_per_file` and `license_per_file` ask for a copyright notice and a +license statement in each source file. A project's own files get both from `.editorconfig` for C# and from +`.template/Test-FileHeaders.ps1 -Fix` for the rest. The scripts the template owns are replaced by every template +update, so a header a project adds to one is discarded, and both criteria stay Unmet +([#503](https://github.com/NCodeGroup/project-template/issues/503)). These scripts are the template's code, published +under its MIT license, whose notice is kept with every copy. + +## Decision + +1. Every script the template owns carries the template's copyright line and license line as `#` comments: each + `.ps1` and `.sh` file in `.template/`, the `build/*.ps1` scripts, `.claude/hooks/*.sh` and `.githooks/pre-push`. + The lines are `# Copyright (c) 2026 Marcin Polewski`, the copyright line of the template's `LICENSE`, and + `# SPDX-License-Identifier: MIT`. They come first in the file, or right after a `#!` line or a `# shellcheck` + directive. +2. `.template/Test-FileHeaders.ps1` checks a project's own files for the project's `author_name` and `license`, and + leaves the template's scripts alone, since they carry the template's lines. +3. The template's tests fail a script the template owns that lacks either line. + +## Options considered + +- Render the project's `author_name` and `license` into each script through Jinja. Rejected: each script would be a + `.jinja` file that the template's tests can't run or analyze where it is, PowerShell text such as `${{ }}` would + need escaping, and the template's code would be credited to each project. +- Keep the scripts without a header. Rejected: no project made from the template can meet either gold criterion. +- The template's own copyright and license lines (chosen): they are true of the code, the same in every project, and + keep the MIT notice with each copy. + +## Consequences + +- A project's source files name two copyright holders: its own files name `author_name`, and the template's scripts + name the template's author. +- A project under another license ships the template's scripts under MIT, which the MIT license allows; each script + says so. +- `docs/best-practices-criteria.md` counts the template's scripts toward both criteria. +- Where a project has record 0027, this replaces its consequence that the template's own scripts carry no header. + +## References + +- `.template/Test-FileHeaders.ps1` and `docs/best-practices-criteria.md`; `tests/Test-FileHeaders.ps1` in the + project template's repository +- NCodeGroup/project-template#503 and #449 diff --git a/docs/decisions/project-template/README.md b/docs/decisions/project-template/README.md index b0987bf..7033c56 100644 --- a/docs/decisions/project-template/README.md +++ b/docs/decisions/project-template/README.md @@ -50,6 +50,7 @@ never brings a number the project already uses | [0035](0035-a-sole-maintainer-dismisses-the-scorecard-alerts-one-person-cannot-clear.md) | With one writer, the Scorecard alerts of Branch-Protection, CII-Best-Practices and Contributors are dismissed as won't fix with a standard comment, through the project template's tools/Dismiss-ScorecardAlerts.ps1, and /best-practices reports a dismissed alert as accepted (amends 0020 and 0037) | | [0036](0036-a-required-approval-is-met-by-ncode-reviews-approver-app.md) | Where NCode Review's approver app is set up, the baseline requires one approval, of the last push, whatever the number of writers, since GitHub counts an approval from a reviewer that can write; Actions never approve pull requests, and the baseline pull request is opened from an issue's link (amends 0022, 0034 and, where a project has it, 0150) | | [0037](0037-best-practices-reports-scorecard-and-answers-for-the-default-branch.md) | `/best-practices` reports the Scorecard checks under 10 with their actions, finds an existing registration by URL, and answers for the default branch's tip (amends 0020 and 0025) | +| [0038](0038-the-templates-scripts-carry-the-templates-copyright-and-license.md) | Every script the template owns, in `.template/`, `build/`, `.claude/hooks/` and `.githooks/`, carries the template's copyright line and `SPDX-License-Identifier: MIT`, which a project's header check leaves alone | ## .NET From df789b0586e0fcf30fad8989b17e06ca3203edc0 Mon Sep 17 00:00:00 2001 From: Marcin Polewski Date: Wed, 25 Nov 2026 16:23:35 -0700 Subject: [PATCH 3/4] Plan step 4: Drop the expired NCode Review pin exception from code-review.yml --- .github/workflows/code-review.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/code-review.yml b/.github/workflows/code-review.yml index 877dbc0..a28085d 100644 --- a/.github/workflows/code-review.yml +++ b/.github/workflows/code-review.yml @@ -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. From 0329b728a9a9226da5e13f175c1d03025a12b3c0 Mon Sep 17 00:00:00 2001 From: Marcin Polewski Date: Wed, 25 Nov 2026 16:24:07 -0700 Subject: [PATCH 4/4] Plan step 5: Bring the UnitTestBase copy in line with the template's sample --- tests/NCode.Randomness.Tests/UnitTestBase.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/NCode.Randomness.Tests/UnitTestBase.cs b/tests/NCode.Randomness.Tests/UnitTestBase.cs index fbb070b..e027bae 100644 --- a/tests/NCode.Randomness.Tests/UnitTestBase.cs +++ b/tests/NCode.Randomness.Tests/UnitTestBase.cs @@ -7,10 +7,10 @@ namespace NCode.Randomness.Tests; public abstract class UnitTestBase : IDisposable { - private readonly MockRepository _mocks = new(MockBehavior.Strict); + private MockRepository Mocks { get; } = new(MockBehavior.Strict); - protected Mock CreateStrictMock(params object[] args) - where T : class => _mocks.Create(args); + protected Mock CreateStrictMock(params IEnumerable args) + where T : class => Mocks.Create([.. args]); public void Dispose() { @@ -22,7 +22,7 @@ protected virtual void Dispose(bool disposing) { if (disposing) { - _mocks.Verify(); + Mocks.Verify(); } } }