Skip to content
Merged
10 changes: 5 additions & 5 deletions .github/workflows/pr-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Setup GitVersion
uses: gittools/actions/gitversion/setup@v3
uses: gittools/actions/gitversion/setup@v4
with:
versionSpec: 5.x
versionSpec: 6.x

- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v3
uses: gittools/actions/gitversion/execute@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x

Expand Down
46 changes: 36 additions & 10 deletions .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,55 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Setup .NET
uses: actions/setup-dotnet@v4
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x

- name: Setup GitVersion
uses: gittools/actions/gitversion/setup@v3
uses: gittools/actions/gitversion/setup@v4
with:
versionSpec: 5.x
versionSpec: 6.x

- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v3
uses: gittools/actions/gitversion/execute@v4

- name: Resolve GitVersion outputs
id: resolved_version
shell: bash
run: |
set -euo pipefail

semver='${{ steps.gitversion.outputs.semVer }}'
package_version='${{ steps.gitversion.outputs.NuGetVersionV2 }}'

if [ -z "${package_version}" ]; then
package_version='${{ steps.gitversion.outputs.nuGetVersionV2 }}'
fi

if [ -z "${semver}" ]; then
echo "GitVersion semVer output is empty."
exit 1
fi

if [ -z "${package_version}" ]; then
echo "GitVersion NuGetVersionV2 output is empty."
exit 1
fi

echo "semver=${semver}" >> "${GITHUB_OUTPUT}"
echo "package_version=${package_version}" >> "${GITHUB_OUTPUT}"

- name: Restore
run: dotnet restore

- name: Build
run: dotnet build --configuration Release --no-restore /p:Version=${{ steps.gitversion.outputs.semVer }}
run: dotnet build --configuration Release --no-restore /p:Version=${{ steps.resolved_version.outputs.semver }}

- name: Test
run: dotnet test --configuration Release --no-build --verbosity normal
Expand All @@ -49,8 +75,8 @@ jobs:
--configuration Release
--no-build
--output ./artifacts
/p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersionV2 }}
/p:Version=${{ steps.gitversion.outputs.semVer }}
/p:PackageVersion=${{ steps.resolved_version.outputs.package_version }}
/p:Version=${{ steps.resolved_version.outputs.semver }}

- name: Publish package to nuget.org
shell: bash
Expand Down Expand Up @@ -91,6 +117,6 @@ jobs:

- name: Workflow Summary
run: |
echo "SemVer: ${{ steps.gitversion.outputs.semVer }}" >> "$GITHUB_STEP_SUMMARY"
echo "NuGet version: ${{ steps.gitversion.outputs.nuGetVersionV2 }}" >> "$GITHUB_STEP_SUMMARY"
echo "SemVer: ${{ steps.resolved_version.outputs.semver }}" >> "$GITHUB_STEP_SUMMARY"
echo "NuGet version: ${{ steps.resolved_version.outputs.package_version }}" >> "$GITHUB_STEP_SUMMARY"
echo "Feed: https://api.nuget.org/v3/index.json" >> "$GITHUB_STEP_SUMMARY"
8 changes: 4 additions & 4 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

<ItemGroup>
<PackageVersion Include="AutoFixture" Version="4.18.1" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="NUnit" Version="4.2.2" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageVersion Include="coverlet.collector" Version="8.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
<PackageVersion Include="NUnit" Version="4.5.1" />
<PackageVersion Include="NUnit3TestAdapter" Version="6.1.0" />
</ItemGroup>
</Project>
6 changes: 0 additions & 6 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
mode: ContinuousDeployment
next-version: 0.0.0
tag-prefix: '[vV]'

branches:
main:
regex: ^main$
label: beta
increment: None
is-main-branch: true
prevent-increment:
when-current-commit-tagged: true

develop:
regex: ^develop$
label: alpha
increment: None
source-branches:
- main
prevent-increment:
when-current-commit-tagged: true

pull-request:
label: pr
Expand Down
44 changes: 34 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,36 @@

Constructor-first customization for AutoFixture with clean defaults, per-test overrides, and extension points for advanced object creation.

## Install
## Why This Package?

`AutoFixture` provides powerful Fixture creation and customization capabilities.
But it creates objects by setting properties after the constructor is called.

*But what if you have Guards and follow the Always-Valid-Model principle?*

`ConstructorCustomization.AutoFixture` provides a constructor-first customization model for `AutoFixture`. This is a package only built on `AutoFixture` and provides an `ICustomization` implementation with minimal effort to get started but highly extensible for advanced scenarios.

### ✨ Features
- Create simple objects in a one-liner.
- Use Fluent API to override defaults on a per-test basis.
- Explicitly map constructor parameters to properties.
- Pluggable extension model for matching and specimen/value creation behavior.
- Fully compatible with AutoFixture ecosystem and existing customizations.

### 🔧 How it works
Under the hood, `ConstructorCustomization` uses reflection to retrieve a constructor and matches property names to parameter names.
Values are created using `AutoFixture`'s existing value creation.

Constructor selection, parameter matching and value creation can all be customized using the provided extension models.


## 📦 Install

```bash
dotnet add package ConstructorCustomization.AutoFixture
```

## Quick Entry
## Quick Entry

Use this when you want a fast start in a test.

Expand All @@ -26,7 +49,7 @@ fixture.Customize(new ConstructorCustomization<Person>()
var person = fixture.Create<Person>();
```

## Simple Usage Pattern
## 🧩 Simple Usage Pattern

For reusable test behavior, create a typed customization once and use it across many tests.

Expand Down Expand Up @@ -57,7 +80,7 @@ var youngPerson = fixture.Create<Person>();
customization.Clear();
```

## Capabilities at a Glance
## Capabilities at a Glance

- Constructor-first object creation for test models.
- Stable defaults with `SetDefault(...)`.
Expand All @@ -66,14 +89,15 @@ customization.Clear();
- Deferred value generation with factory delegates.
- Pluggable extension model for matching and specimen/value creation behavior.

## Documentation and Wiki
## 📚 Documentation and Wiki

- Wiki home: [Home](wiki/Home.md)
- Getting started: [Getting Started](wiki/Getting-Started.md)
- Behavior customization: [Customizing Behavior](wiki/Customizing-Behavior.md)
- Extension points: [Extensions Overview](wiki/Extensions-Overview.md)
- Wiki home: [Home](https://github.com/scorixear/ConstructorCustomization.AutoFixture/wiki)
- Getting started: [Getting Started](https://github.com/scorixear/ConstructorCustomization.AutoFixture/wiki/Getting-Started)
- Behavior customization: [Customizing Behavior](https://github.com/scorixear/ConstructorCustomization.AutoFixture/wiki/Customizing-Behavior)
- Extension points: [Extensions Overview](https://github.com/scorixear/ConstructorCustomization.AutoFixture/wiki/Extensions-Overview)
- How it Works: [Creation Pipeline](https://github.com/scorixear/ConstructorCustomization.AutoFixture/wiki/Creation-Pipeline)

## Build and Test
## 🛠️ Build and Test

```bash
dotnet restore
Expand Down
103 changes: 103 additions & 0 deletions release-process.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Release Process

This document describes how to ship a new **major**, **minor**, or **patch** release for this package to both GitHub and nuget.org.

## Current Automation (Repository Setup)

- PR validation workflow: [.github/workflows/pr-build-test.yml](.github/workflows/pr-build-test.yml)
- Manual publish workflow: [.github/workflows/publish-nuget.yml](.github/workflows/publish-nuget.yml)
- Versioning rules: [GitVersion.yml](GitVersion.yml)
- NuGet target feed: `https://api.nuget.org/v3/index.json`

## Versioning Model

- Branch prerelease labels:
- `develop` -> `alpha`
- `main` -> `beta`
- Final stable release versions come from Git tags in the form `vX.Y.Z`.

Examples:
- `v1.0.0` -> stable `1.0.0`
- `v1.3.0` -> stable `1.3.0`
- `v1.3.5` -> stable `1.3.5`

## Prerequisites

1. GitHub repository secret `NUGET_API_KEY` is configured.
2. Changes are merged and CI is green in GitHub Actions.
3. You are ready to release from the commit that should become the package.

## Choose the Next Version

Use Semantic Versioning:

- **Patch**: backward-compatible bug fix
- Example: `1.4.2` -> `1.4.3`
- **Minor**: backward-compatible feature
- Example: `1.4.2` -> `1.5.0`
- **Major**: breaking change
- Example: `1.4.2` -> `2.0.0`

## Release Steps (Git + GitHub + NuGet)

1. Make sure your release commit is on `main` (recommended for stable releases).
2. Create and push a tag for the target release version.

```bash
git checkout main
git pull

git tag vX.Y.Z
git push origin vX.Y.Z
```

3. In GitHub, open **Actions** -> **Publish NuGet Package**.
4. Click **Run workflow**.
5. Select the release tag as the workflow ref (for example `v1.5.0`).
6. Run the workflow.
7. Verify in the workflow summary:
- SemVer
- NuGet version
8. Verify package published on nuget.org.

## GitHub Release (Recommended)

After the package is published:

1. Open **Releases** in GitHub.
2. Create a release from the same tag (`vX.Y.Z`).
3. Add release notes (breaking changes, new features, fixes).
4. Publish the release.

## Quick Checklists

### Patch Release

1. Confirm fix merged.
2. Tag `vA.B.(C+1)`.
3. Run publish workflow on the tag.
4. Create GitHub Release.

### Minor Release

1. Confirm feature set merged.
2. Tag `vA.(B+1).0`.
3. Run publish workflow on the tag.
4. Create GitHub Release.

### Major Release

1. Confirm breaking changes are documented.
2. Tag `v(A+1).0.0`.
3. Run publish workflow on the tag.
4. Create GitHub Release with migration notes.

## Troubleshooting

- Wrong version generated:
- Confirm workflow was run against the correct ref (tag, not branch).
- Confirm tag format is exactly `vX.Y.Z`.
- Publish fails with auth error:
- Recreate/rotate `NUGET_API_KEY` secret in GitHub.
- Package already exists:
- Publishing uses `--skip-duplicate`; verify whether this is expected.
42 changes: 0 additions & 42 deletions wiki/Architecture-Schema.md

This file was deleted.

Loading
Loading