Thank you for your interest in contributing! This document provides guidelines and instructions for contributing to this project.
-
Fork and clone the repository
git clone https://github.com/YOUR-USERNAME/csharp-ai-driven-development-pipeline-template.git cd csharp-ai-driven-development-pipeline-template -
Install .NET SDK
Install .NET 8.0 SDK from dotnet.microsoft.com.
-
Install Bun (for helper scripts)
curl -fsSL https://bun.sh/install | bash -
Restore dependencies and build
dotnet restore dotnet build
-
Install pre-commit hooks (optional but recommended)
pip install pre-commit pre-commit install
-
Create a feature branch
git checkout -b feature/my-feature
-
Make your changes
- Write code following the project's style guidelines
- Add tests for any new functionality
- Update documentation as needed
-
Run quality checks
# Format code dotnet format # Build with warnings as errors dotnet build --configuration Release /warnaserror # Check file sizes bun run scripts/check-file-size.mjs # Run all checks together dotnet format --verify-no-changes && dotnet build --configuration Release /warnaserror && bun run scripts/check-file-size.mjs
-
Run tests
# Run all tests dotnet test # Run tests with verbose output dotnet test --verbosity normal # Run tests with coverage dotnet test --collect:"XPlat Code Coverage" # Run a specific test dotnet test --filter "FullyQualifiedName~TestName"
-
Add a changeset
For any user-facing changes, create a changeset file in
.changeset/:# Create a changeset file cat > .changeset/my-change.md << 'EOF' --- 'MyPackage': patch --- Description of your changes EOF
Changeset format:
- First line after
---:'PackageName': version_type - Version types:
major,minor, orpatch - Description after the second
---
Why changesets? This workflow:
- Prevents merge conflicts in CHANGELOG.md
- Ensures version bumps happen safely after merge
- Matches the JavaScript Changesets workflow
- First line after
-
Commit your changes
git add . git commit -m "feat: add new feature"
Pre-commit hooks will automatically run and check your code.
-
Push and create a Pull Request
git push origin feature/my-feature
Then create a Pull Request on GitHub.
This project uses:
- EditorConfig for code style configuration
- .NET Analyzers for static analysis
- dotnet format for code formatting
- xUnit for testing
- Follow C# conventions and best practices
- Use XML documentation comments (
///) for all public APIs - Write tests for all new functionality
- Keep functions focused and reasonably sized
- Keep files under 1000 lines
- Use meaningful variable and function names
- Prefer file-scoped namespaces
- Use expression-bodied members where appropriate
Use XML documentation comments:
/// <summary>
/// Brief description of the method.
/// </summary>
/// <param name="arg1">Description of arg1.</param>
/// <param name="arg2">Description of arg2.</param>
/// <returns>Description of return value.</returns>
/// <exception cref="ArgumentException">When argument is invalid.</exception>
/// <example>
/// <code>
/// var result = MyMethod(1, 2);
/// Console.WriteLine(result); // Output: 3
/// </code>
/// </example>
public int MyMethod(int arg1, int arg2)
{
return arg1 + arg2;
}- Write tests for all new features
- Maintain or improve test coverage
- Use descriptive test names
- Organize tests using nested classes when appropriate
- Use
[Theory]for data-driven tests
Example test structure:
public class MyFeatureTests
{
public class WhenDoingSomething
{
[Fact]
public void Should_ReturnExpectedResult()
{
// Arrange
var input = "test";
// Act
var result = MyFeature.DoSomething(input);
// Assert
Assert.Equal("expected", result);
}
[Theory]
[InlineData("input1", "output1")]
[InlineData("input2", "output2")]
public void Should_HandleVariousInputs(string input, string expected)
{
var result = MyFeature.DoSomething(input);
Assert.Equal(expected, result);
}
}
}- Ensure all tests pass locally
- Update documentation if needed
- Add a changeset file (see step 5 in Development Workflow)
- Ensure the PR description clearly describes the changes
- Link any related issues in the PR description
- Wait for CI checks to pass (including changeset validation)
- Address any review feedback
This project uses a changesets workflow similar to Changesets in JavaScript.
# Create a changeset file
cat > .changeset/my-change.md << 'EOF'
---
'MyPackage': patch
---
Description of your changes
EOFmajor- Breaking changes (1.x.x -> 2.0.0)minor- New features, backwards compatible (x.1.x -> x.2.0)patch- Bug fixes, backwards compatible (x.x.1 -> x.x.2)
- Each PR adds a changeset file in
.changeset/ - CI validates that exactly one changeset is added per PR
- When merged to main, the release workflow:
- Merges multiple changesets (if any) using highest bump type
- Updates version in csproj and CHANGELOG.md
- Creates git tag and pushes changes
- Publishes to NuGet and creates GitHub release
- No merge conflicts: Multiple PRs can add changesets independently
- Version safety: Version bumps happen after merge, not before
- Consistent with JS/Python templates: Same workflow across all templates
.
├── .changeset/ # Changesets configuration
│ ├── config.json # Changeset settings
│ ├── README.md # Changeset instructions
│ └── *.md # Individual changesets
├── .github/workflows/ # GitHub Actions CI/CD
├── examples/ # Usage examples
├── scripts/ # Utility scripts (.mjs)
├── src/MyPackage/ # Source code
│ ├── Calculator.cs # Example implementation
│ ├── PackageInfo.cs # Package version info
│ └── MyPackage.csproj # Library project
├── tests/MyPackage.Tests/ # Test files
├── .editorconfig # Code style configuration
├── .pre-commit-config.yaml # Pre-commit hooks
├── Directory.Build.props # Shared build properties
├── MyPackage.sln # Solution file
├── CHANGELOG.md # Project changelog
├── CONTRIBUTING.md # This file
└── README.md # Project README
This project uses semantic versioning (MAJOR.MINOR.PATCH):
- MAJOR: Breaking changes
- MINOR: New features (backward compatible)
- PATCH: Bug fixes (backward compatible)
Releases are triggered automatically when changesets are merged to main, or manually via workflow_dispatch:
Automatic Release:
- PR with changeset is merged to main
- Release workflow detects and processes changesets
- Version is bumped, changelog updated, tag created
- Package published to NuGet, GitHub release created
Manual Release:
- Go to Actions > CI/CD Pipeline > Run workflow
- Select release mode (
instantorchangeset-pr) - Choose bump type and optional description
- Open an issue for bugs or feature requests
- Use discussions for questions and general help
- Check existing issues and PRs before creating new ones
- Be respectful and inclusive
- Provide constructive feedback
- Focus on what is best for the community
- Show empathy towards other community members
Thank you for contributing!