Thank you for your interest in contributing to our PostgreSQL Distributed Cache implementation for .NET! This document provides guidelines and standards for contributing to the project.
-
Install the following prerequisites:
- .NET SDK (versions 6.0, 8.0, and 9.0)
- PostgreSQL 11+
- Your preferred IDE (Visual Studio, VS Code, Rider, etc.)
-
Clone the repository:
git clone https://github.com/leonibr/community-extensions-cache-postgres.git
- Source code goes in
Extensions.Caching.PostgreSql/
- Sample projects in
PostgreSqlCacheSample/
andWebSample/
- Tests should be placed in a corresponding test project
-
Language Version
- Use C# 11 features (
<LangVersion>11</LangVersion>
) - Target multiple frameworks: net6.0, net8.0, and net9.0
- Use C# 11 features (
-
Naming Conventions
- Use PascalCase for public members and types
- Use camelCase for private fields
- Prefix private fields with underscore (_)
private readonly ILogger<DatabaseOperations> _logger;
-
String Interpolation
- Use raw string literals for SQL queries
public string CreateSchemaAndTableSql => $""" CREATE SCHEMA IF NOT EXISTS "{_schemaName}"; // ... """;
-
Async/Await
- Always provide async versions of methods with CancellationToken support
- Use the Async suffix for async methods
public async Task DeleteCacheItemAsync(string key, CancellationToken cancellationToken)
-
Dependency Injection
- Use constructor injection
- Mark dependencies as readonly when possible
private readonly ILogger<DatabaseOperations> _logger;
-
Error Handling
- Use structured logging with ILogger
- Validate input parameters
- Throw appropriate exceptions with meaningful messages
-
XML Comments
- Add XML comments for public APIs
- Include parameter descriptions and examples where appropriate
/// <summary> /// The factory to create a NpgsqlDataSource instance. /// Either <see cref="DataSourceFactory"/> or <see cref="ConnectionString"/> should be set. /// </summary> public Func<NpgsqlDataSource> DataSourceFactory { get; set; }
-
README Updates
- Update README.md when adding new features
- Include usage examples for new functionality
- Write unit tests for new functionality
- Ensure all tests pass before submitting PR
- Include integration tests for database operations
- Create a feature branch from
master
- Make your changes following the coding standards
- Update documentation as needed
- Run all tests (if any)
- Submit a pull request with:
- Clear description of changes
- Any related issue numbers
- Breaking changes noted
- Documentation updates
Keep dependencies up to date with the latest stable versions:
-
Version numbers follow SemVer
-
Update version in .csproj:
<Version>4.0.0</Version>
-
Update PackageReleaseNotes in .csproj
-
Document breaking changes in README.md
- Open an issue for bugs or feature requests
- For questions, use GitHub Discussions
- For security issues, please see SECURITY.md
This project is licensed under the MIT License - see the LICENSE file for details.