|
| 1 | +# Contributing to Community.Microsoft.Extensions.Caching.PostgreSql |
| 2 | + |
| 3 | +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. |
| 4 | + |
| 5 | +## Development Environment Setup |
| 6 | + |
| 7 | +1. Install the following prerequisites: |
| 8 | + |
| 9 | + - .NET SDK (versions 6.0, 8.0, and 9.0) |
| 10 | + - PostgreSQL 11+ |
| 11 | + - Your preferred IDE (Visual Studio, VS Code, Rider, etc.) |
| 12 | + |
| 13 | +1. Clone the repository: |
| 14 | + |
| 15 | +```bash |
| 16 | +git clone https://github.com/leonibr/community-extensions-cache-postgres.git |
| 17 | +``` |
| 18 | + |
| 19 | +## Code Standards |
| 20 | + |
| 21 | +### Project Structure |
| 22 | + |
| 23 | +- Source code goes in `Extensions.Caching.PostgreSql/` |
| 24 | +- Sample projects in `PostgreSqlCacheSample/` and `WebSample/` |
| 25 | +- Tests should be placed in a corresponding test project |
| 26 | + |
| 27 | +### Coding Conventions |
| 28 | + |
| 29 | +1. **Language Version** |
| 30 | + |
| 31 | + - Use C# 11 features (`<LangVersion>11</LangVersion>`) |
| 32 | + - Target multiple frameworks: net6.0, net8.0, and net9.0 |
| 33 | + |
| 34 | +1. **Naming Conventions** |
| 35 | + |
| 36 | + - Use PascalCase for public members and types |
| 37 | + - Use camelCase for private fields |
| 38 | + - Prefix private fields with underscore (\_) |
| 39 | + |
| 40 | + ```csharp |
| 41 | + private readonly ILogger<DatabaseOperations> _logger; |
| 42 | + ``` |
| 43 | + |
| 44 | +1. **String Interpolation** |
| 45 | + |
| 46 | + - Use raw string literals for SQL queries |
| 47 | + |
| 48 | + ```csharp |
| 49 | + public string CreateSchemaAndTableSql => |
| 50 | + $""" |
| 51 | + CREATE SCHEMA IF NOT EXISTS "{_schemaName}"; |
| 52 | + // ... |
| 53 | + """; |
| 54 | + ``` |
| 55 | + |
| 56 | +1. **Async/Await** |
| 57 | + |
| 58 | + - Always provide async versions of methods with CancellationToken support |
| 59 | + - Use the Async suffix for async methods |
| 60 | + |
| 61 | + ```csharp |
| 62 | + public async Task DeleteCacheItemAsync(string key, CancellationToken cancellationToken) |
| 63 | + ``` |
| 64 | + |
| 65 | +1. **Dependency Injection** |
| 66 | + |
| 67 | + - Use constructor injection |
| 68 | + - Mark dependencies as readonly when possible |
| 69 | + |
| 70 | + ```csharp |
| 71 | + private readonly ILogger<DatabaseOperations> _logger; |
| 72 | + ``` |
| 73 | + |
| 74 | +1. **Error Handling** |
| 75 | + - Use structured logging with ILogger |
| 76 | + - Validate input parameters |
| 77 | + - Throw appropriate exceptions with meaningful messages |
| 78 | + |
| 79 | +### Documentation |
| 80 | + |
| 81 | +1. **XML Comments** |
| 82 | + |
| 83 | + - Add XML comments for public APIs |
| 84 | + - Include parameter descriptions and examples where appropriate |
| 85 | + |
| 86 | + ```csharp |
| 87 | + /// <summary> |
| 88 | + /// The factory to create a NpgsqlDataSource instance. |
| 89 | + /// Either <see cref="DataSourceFactory"/> or <see cref="ConnectionString"/> should be set. |
| 90 | + /// </summary> |
| 91 | + public Func<NpgsqlDataSource> DataSourceFactory { get; set; } |
| 92 | + ``` |
| 93 | + |
| 94 | +1. **README Updates** |
| 95 | + - Update README.md when adding new features |
| 96 | + - Include usage examples for new functionality |
| 97 | + |
| 98 | +### Testing (optional for now) |
| 99 | + |
| 100 | +1. Write unit tests for new functionality |
| 101 | +1. Ensure all tests pass before submitting PR |
| 102 | +1. Include integration tests for database operations |
| 103 | + |
| 104 | +## Pull Request Process |
| 105 | + |
| 106 | +1. Create a feature branch from `master` |
| 107 | +1. Make your changes following the coding standards |
| 108 | +1. Update documentation as needed |
| 109 | +1. Run all tests (if any) |
| 110 | +1. Submit a pull request with: |
| 111 | + - Clear description of changes |
| 112 | + - Any related issue numbers |
| 113 | + - Breaking changes noted |
| 114 | + - Documentation updates |
| 115 | + |
| 116 | +### Dependencies |
| 117 | + |
| 118 | +Keep dependencies up to date with the latest stable versions: |
| 119 | + |
| 120 | +## Release Process |
| 121 | + |
| 122 | +1. Version numbers follow SemVer |
| 123 | +1. Update version in .csproj: |
| 124 | + |
| 125 | + ```xml |
| 126 | + <Version>4.0.0</Version> |
| 127 | + ``` |
| 128 | + |
| 129 | +1. Update PackageReleaseNotes in .csproj |
| 130 | +1. Document breaking changes in README.md |
| 131 | + |
| 132 | +## Questions or Problems? |
| 133 | + |
| 134 | +- Open an issue for bugs or feature requests |
| 135 | +- For questions, use GitHub Discussions |
| 136 | +- For security issues, please see [SECURITY.md](SECURITY.md) |
| 137 | + |
| 138 | +## License |
| 139 | + |
| 140 | +This project is licensed under the MIT License - see the LICENSE file for details. |
0 commit comments