Skip to content

Commit c4f2ecb

Browse files
Merge pull request #36 from Chris-Wolfgang/copilot/update-readme-and-contributing-docs
Update documentation and configure build settings for Wolfgang.Extensions.IAsyncEnumerable
2 parents de40873 + 56ba679 commit c4f2ecb

File tree

3 files changed

+365
-9
lines changed

3 files changed

+365
-9
lines changed

CONTRIBUTING.md

Lines changed: 186 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Contributing to <Application Name>
1+
# Contributing to Wolfgang.Extensions.IAsyncEnumerable
22

3-
Thank you for your interest in contributing to **<Application Name>**! We welcome contributions to help improve this project.
3+
Thank you for your interest in contributing to **Wolfgang.Extensions.IAsyncEnumerable**! We welcome contributions to help improve this project.
44

55
## How Can You Contribute?
66

@@ -11,8 +11,9 @@ You can contribute in several ways:
1111
- Improving documentation
1212
- Writing or improving tests
1313

14-
Please note: Before coding anything please check with me first by entering an issue and getting approval for it. PRs are more likely to get merged if I have agreed to the changes.
14+
**Please note:** Before coding anything please check with me first by entering an issue and getting approval for it. PRs are more likely to get merged if I have agreed to the changes.
1515

16+
---
1617

1718
## Getting Started
1819

@@ -36,27 +37,206 @@ Please note: Before coding anything please check with me first by entering an is
3637
- Building the project
3738
- Running automated tests
3839
- Checking code style and linting
40+
- Running static analysis with 8 different analyzers
3941

4042
**It is important to make sure that all CI steps pass before your PR can be merged.**
4143
- If any CI step fails, please review the error messages and update your PR as needed.
4244
- Maintainers will review your PR once all checks have passed.
4345

46+
---
47+
48+
## Code Quality Standards
49+
50+
This project maintains **extremely high code quality standards** through multiple layers of static analysis and automated enforcement.
51+
52+
### The 8 Analyzers
53+
54+
All code is analyzed by these tools during build:
55+
56+
1. **Microsoft.CodeAnalysis.NetAnalyzers** (Built-in .NET SDK)
57+
- Correctness, performance, and security rules
58+
- Latest analysis level enabled
59+
60+
2. **StyleCop.Analyzers**
61+
- Enforces consistent code style and formatting
62+
- Documentation comment requirements
63+
64+
3. **Roslynator.Analyzers**
65+
- 500+ refactoring and code quality rules
66+
- Advanced C# pattern detection
67+
68+
4. **AsyncFixer**
69+
- Detects async/await anti-patterns
70+
- Ensures proper `ConfigureAwait()` usage
71+
- Prevents fire-and-forget async calls
72+
73+
5. **Microsoft.VisualStudio.Threading.Analyzers**
74+
- Thread safety enforcement
75+
- Async method naming conventions
76+
- Deadlock prevention
77+
78+
6. **Microsoft.CodeAnalysis.BannedApiAnalyzers**
79+
- Blocks usage of APIs listed in `BannedSymbols.txt`
80+
- Enforces async-first patterns (see below)
81+
82+
7. **Meziantou.Analyzer**
83+
- Comprehensive code quality checks
84+
- Performance optimizations
85+
- Best practice enforcement
86+
87+
8. **SonarAnalyzer.CSharp**
88+
- Industry-standard code analysis
89+
- Security vulnerability detection
90+
- Code smell identification
91+
92+
### Async-First Enforcement
93+
94+
This library **prohibits synchronous blocking calls** via `BannedSymbols.txt`. The following APIs are **banned**:
95+
96+
#### ❌ Blocking Async Operations
97+
```csharp
98+
// Banned - blocks threads
99+
task.Wait();
100+
task.Result;
101+
Task.WaitAll(tasks);
102+
103+
// Required - truly async
104+
await task;
105+
await Task.WhenAll(tasks);
106+
```
107+
108+
#### ❌ Synchronous I/O
109+
```csharp
110+
// Banned
111+
File.ReadAllText(path);
112+
stream.Read(buffer, 0, count);
113+
streamReader.ReadLine();
114+
115+
// Required
116+
await File.ReadAllTextAsync(path);
117+
await stream.ReadAsync(buffer, 0, count);
118+
await streamReader.ReadLineAsync();
119+
```
120+
121+
#### ❌ Thread Blocking
122+
```csharp
123+
// Banned
124+
Thread.Sleep(1000);
125+
Console.ReadLine();
126+
127+
// Required
128+
await Task.Delay(1000);
129+
// Avoid blocking console reads in async code
130+
```
131+
132+
#### ❌ Obsolete/Insecure APIs
133+
```csharp
134+
// Banned
135+
var client = new WebClient();
136+
var formatter = new BinaryFormatter();
137+
var now = DateTime.Now; // Use DateTimeOffset
138+
139+
// Required
140+
var client = new HttpClient();
141+
// Use System.Text.Json.JsonSerializer
142+
var now = DateTimeOffset.UtcNow;
143+
```
144+
145+
**Why?** This ensures all code is **truly asynchronous** and **non-blocking**, providing optimal performance in async contexts.
146+
147+
---
148+
149+
## Build and Test Instructions
150+
151+
### Prerequisites
152+
- .NET 8.0 SDK or later
153+
- PowerShell Core (optional, for formatting scripts)
154+
155+
### Build the Project
156+
157+
```bash
158+
# Restore NuGet packages
159+
dotnet restore
160+
161+
# Build in Release configuration (enforces all analyzers)
162+
dotnet build --configuration Release
163+
```
164+
165+
**Note:** Release builds treat all analyzer warnings as errors (`<TreatWarningsAsErrors>true</TreatWarningsAsErrors>`). Debug builds allow warnings to facilitate development.
166+
167+
### Run Tests
168+
169+
```bash
170+
# Run all unit tests
171+
dotnet test --configuration Release
172+
173+
# Run with coverage (if configured)
174+
dotnet test --collect:"XPlat Code Coverage"
175+
```
176+
177+
### Code Formatting
178+
179+
This project uses `.editorconfig` for consistent code style:
180+
181+
```bash
182+
# Format all code
183+
dotnet format
184+
185+
# Check formatting without changes (CI mode)
186+
dotnet format --verify-no-changes
187+
188+
# PowerShell formatting script
189+
pwsh ./format.ps1
190+
```
191+
192+
See [README-FORMATTING.md](README-FORMATTING.md) for detailed formatting rules.
193+
194+
---
195+
196+
## .editorconfig Rules
197+
198+
Key style rules enforced:
199+
200+
- **Indentation:** 4 spaces (C#), 2 spaces (XML/JSON)
201+
- **Line endings:** LF (Unix-style)
202+
- **Charset:** UTF-8
203+
- **Trim trailing whitespace:** Yes
204+
- **Final newline:** Yes
205+
- **Braces:** New line style (Allman)
206+
- **Naming:** PascalCase for public members, camelCase for parameters/locals
207+
- **File-scoped namespaces:** Required in C# 10+
208+
- **`var` preferences:** Use for built-in types and when type is obvious
209+
- **Null checks:** Prefer pattern matching (`is null`, `is not null`)
210+
211+
View the complete configuration in [.editorconfig](.editorconfig).
212+
213+
---
214+
44215
## Guidelines
45216

46217
- Follow the coding style used in the project.
47218
- Write clear, concise commit messages.
48219
- Add relevant tests for new features or bug fixes.
49-
- Document any public APIs or significant changes.
220+
- Document any public APIs with XML documentation comments.
221+
- Ensure all analyzer warnings are addressed (they're treated as errors in Release builds).
222+
- Use async/await patterns - no blocking calls allowed.
223+
- Include `CancellationToken` parameters in async methods where appropriate.
224+
225+
---
50226

51227
## Pull Requests
52228

53-
- Ensure your pull request passes all tests.
229+
- Ensure your pull request passes all tests and analyzer checks.
54230
- Respond to review feedback in a timely manner.
55231
- Reference related issues in your pull request description.
232+
- Keep changes focused and atomic - one feature/fix per PR.
233+
- Update documentation if you change public APIs.
234+
235+
---
56236

57237
## Code of Conduct
58238

59-
Please be respectful and considerate in all interactions. See [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) if available.
239+
Please be respectful and considerate in all interactions. See [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) for our community guidelines.
60240

61241
---
62242

0 commit comments

Comments
 (0)