@@ -8,18 +8,18 @@ description: This file contains instructions for C# development. It includes gu
88
99## General
1010
11- * The project MUST use the latest version C#, currently C# 13 features.
12- * MUST follow standard C# coding conventions (naming, indentation, spacing).
13- * MUST implement robust error handling with try-catch blocks and meaningful messages.
14- * MUST write unit tests for all critical functionalities.
15- * MUST always review AI-generated code for correctness, security, and performance.
11+ - The project MUST use the latest version C#, currently C# 13 features.
12+ - MUST follow standard C# coding conventions (naming, indentation, spacing).
13+ - MUST implement robust error handling with try-catch blocks and meaningful messages.
14+ - MUST write unit tests for all critical functionalities.
15+ - MUST always review AI-generated code for correctness, security, and performance.
1616
1717## Code Style
1818
1919Follow these C# coding conventions for consistency across the project.
2020
21- * MUST use ` var ` when the type is obvious from the right side of the assignment.
22- * MUST use appropriate null-checking pattern based on package availability:
21+ - MUST use ` var ` when the type is obvious from the right side of the assignment.
22+ - MUST use appropriate null-checking pattern based on package availability:
2323 - Use ` ArgumentNullException.ThrowIfNull(x) `
2424 - Check ` Directory.Packages.props ` for ` NetEvolve.Arguments ` availability
2525 - Example with NetEvolve.Arguments:
@@ -43,39 +43,42 @@ Follow these C# coding conventions for consistency across the project.
4343
4444Apply code - formatting style defined in `.editorconfig `.
4545
46- * MUST prefer file - scoped namespace declarations and single -line using directives .
47- * MUST insert a newline before the opening curly brace of any code block (e .g ., after `if `, `for `, `while `, `foreach `, `using `, `try `, etc .).
48- * MUST ensure that the final return statement of a method is on its own line .
49- * MUST use pattern matching and switch expressions wherever possible .
50- * MUST use `nameof ` instead of string literals when referring to member names .
51- * MUST ensure that XML doc comments are created for any public APIs . When applicable , include `<inheritdoc />` for derived members .
46+ - MUST prefer file - scoped namespace declarations and single -line using directives .
47+ - MUST insert a newline before the opening curly brace of any code block (e .g ., after `if `, `for `, `while `, `foreach `, `using `, `try `, etc .).
48+ - MUST ensure that the final return statement of a method is on its own line .
49+ - MUST use pattern matching and switch expressions wherever possible .
50+ - MUST use `nameof ` instead of string literals when referring to member names .
51+ - MUST ensure that XML doc comments are created for any public APIs . When applicable , include `<inheritdoc />` for derived members .
5252
5353## Arrays and Collections
5454
55- * MUST prefer `Enumerable .Empty <T >()` or `Array .Empty <T >()` over `null ` returns .
55+ - MUST prefer `Enumerable .Empty <T >()` or `Array .Empty <T >()` over `null ` returns .
5656
5757## Nullable Reference Types
5858
5959Declare variables non -nullable , and check for `null ` at entry points .
6060
61- * MUST always use `is null ` or `is not null ` instead of `== null ` or `!= null `.
62- * MUST trust the C # null annotations and don 't add null checks when the type system says a value cannot be null .
63- * MUST apply `NotNullAttribute ` and other nullable attributes for any public APIs .
61+ - MUST always use `is null ` or `is not null ` instead of `== null ` or `!= null `.
62+ - MUST trust the C # null annotations and don 't add null checks when the type system says a value cannot be null .
63+ - MUST apply `NotNullAttribute ` and other nullable attributes for any public APIs .
6464
6565## Testing
6666
67- * MUST prefer to use [TUnit ](https :// github.com/thomhurst/TUnit) with [Microsoft.Testing.Platform](https://learn.microsoft.com/dotnet/core/testing/microsoft-testing-platform-intro).
68- * If TUnit is not available , MUST use [XUnit ](https :// xunit.net/).
69- * MUST NOT emit `Act `, `Arrange ` or `Assert ` comments .
70- * MUST NOT use any mocking framework at the moment .
71- * MUST copy existing style in nearby files for test method names and capitalization .
67+ - MUST prefer to use [TUnit ](https :// github.com/thomhurst/TUnit) with [Microsoft.Testing.Platform](https://learn.microsoft.com/dotnet/core/testing/microsoft-testing-platform-intro).
68+ - If TUnit is not available , MUST use [XUnit ](https :// xunit.net/).
69+ - MUST NOT emit `Act `, `Arrange ` or `Assert ` comments .
70+ - For mocking purposes , SHOULD use [TUnit .Mocks ](https :// tunit.dev/docs/writing-tests/mocking/) instead of creating test helper classes.
71+ - Replace manually created test doubles (records , classes ) with `Mock <T >` where applicable
72+ - Use `Any ()`, raw values , or inline lambda expressions for argument matching
73+ - Configure mock behavior by calling the method directly on the mock and chaining `.Returns ()`, `.Throws ()`, `.Callback ()`, etc .
74+ - MUST copy existing style in nearby files for test method names and capitalization .
7275
7376## Build and test AI -generated code
7477
75781. Build from the root with `dotnet build <solutionfile >.slnx `.
76792. If that produces errors , fix those errors and build again . Repeat until the build is successful .
77- 3. Run tests with `dotnet test <solutionfile >.slnx `.
80+ 3. Run tests with `dotnet test -- solution <solutionfile >.slnx `.
78814. If tests fail , analyze the failures and fix the code . Do not ignore failing tests .
79825. Verify that all new code has appropriate test coverage .
80836. Run a final build to ensure everything compiles successfully after all changes .
81-
84+ 7. Consider adding new tests to cover any edge cases or scenarios that may not have been previously tested .
0 commit comments