- Always ask for permission before committing to Git. Keep commits clean and controlled.
- Line Endings: CRLF
- Indentation: 4 spaces
- File-scoped Namespaces: Always use
namespace MyNamespace; - Expression-bodied Members: Prefer for simple properties and methods (e.g.,
public bool IsAvailable => Stock > 0;) - Auto-Properties: Use auto-properties where possible (e.g.,
public int Stock { get; set; }) - var Usage: Use only when type is obvious
- Max Line Length: 100 characters
- Blank Line After Closing Brace: Add blank line after
}UNLESS next line is also} - ✅ Add blank line if code follows:
}\n\nDoSomething(); - ✅ Add blank line between sequential if statements:
}\n\nif (...) - ❌ No blank line if another
}follows:}\n} - No Line Wrapping: Do not wrap long lines - keep them on a single line even if they exceed max length
Example:
// ✅ Correct - blank line between if statements
if (value < 0)
{
throw new ArgumentException("Invalid");
}
if (value > 100)
{
throw new ArgumentException("Too large");
}
// ❌ Incorrect - no blank line between if statements
if (value < 0)
{
throw new ArgumentException("Invalid");
}
if (value > 100)
{
throw new ArgumentException("Too large");
}
// ✅ Correct - no blank line when closing brace follows
if (condition)
{
if (nested)
{
DoSomething();
}
}- Read-only properties (initialized in constructor): Use auto-property with
{ get; }- ✅
public string Name { get; } - ❌ NOT
private readonly string name; public string Name => name;
- ✅
- Mutable properties: Use auto-property with setter
- ✅
public int Stock { get; set; }orpublic int Stock { get; private set; } - ❌ NOT backing field unless validation is needed
- ✅
- Computed properties: Use expression-bodied syntax
- ✅
public bool IsAvailable => Stock > 0; - ✅
public decimal TotalValue => Price * Stock;
- ✅
- Complex properties with logic: Use full property with backing field
- ✅ Use backing field when getter has validation or throws exceptions
- Private Fields: Use camelCase without underscore prefix (e.g.,
value, not_value) - Public Members: PascalCase
- Local Variables: camelCase
Example:
public sealed class Product
{
// ✅ Read-only auto-property (initialized in constructor)
public string Name { get; }
// ✅ Mutable auto-property with private setter
public int Stock { get; private set; }
// ✅ Computed property (expression-bodied)
public bool IsAvailable => Stock > 0;
// ✅ Complex property with validation (needs backing field)
private readonly decimal price;
public decimal Price
{
get
{
if (price < 0)
{
throw new InvalidOperationException("Invalid price");
}
return price;
}
}
}- Nullable: Enabled
- Language Version: latest
- Async Suffix: Prefer
Asyncsuffix for async methods
- Language: English
- Generate XML Doc Comments: Always add XML documentation for public members
- Avoid Redundant Comments: Do not add obvious or meta comments
- Enabled: Yes
- Width: 98 characters (total line width including indentation)
- Character:
= - Prefix:
// - No Space After Prefix: Decorators use
//======format (no space) - Dynamic Indent: Yes (adjust decorator width based on indentation level)
- File-Scoped Namespaces Rule: When using
namespace MyNamespace;(file-scoped):- File Headers: 98 characters (no indentation)
- Class/Interface/Enum Decorators: 98 characters (no indentation, same level as namespace)
- Method/Property/Member Decorators: 94 characters + 4-space indentation = 98 total width
Example (file-scoped namespace):
//==================================================================================================
// File header comment
//==================================================================================================
namespace MyNamespace;
//==================================================================================================
/// <summary>
/// Class-level documentation (98 chars, no indent).
/// </summary>
//==================================================================================================
public sealed class MyClass
{
//==============================================================================================
/// <summary>
/// Method-level documentation (94 chars + 4 space indent = 98 total).
/// </summary>
//==============================================================================================
public bool IsSuccess { get; }
}- Enabled: Yes
- Format: 3-line header (purpose + technical description + decorators)
- Width: 98 characters (full line)
- Character:
= - Prefix:
// - No Space After Prefix: Header decorators use
//======format (no space) - Normal Comments in Header: Use
//with space for content lines - Language: English
- No Date/Author: Headers do not include date or author information (git history provides this)
Example:
//==================================================================================================
// Represents the result of an operation that can be either success or failure.
// Sealed class implementation for Result pattern without value.
//==================================================================================================- Always use space after prefix:
// Comment(not//Comment) - Decorator lines: No space -
//==============================
- Avoid redundant comments
- Avoid obvious comments
- Avoid meta comments
- Suppress explanatory comments when not needed
- Test Framework: xUnit
- Assertions: FluentAssertions
- Naming Convention:
MethodName_Should_ExpectedBehavior
Example:
[Fact]
public void Success_should_create_success_result()
{
var result = Result.Success();
result.IsSuccess.Should().BeTrue();
}When generating or modifying code in this project:
- ✅ Use file-scoped namespaces
- ✅ Add English XML documentation with decorators
- ✅ Prefer auto-properties and expression-bodied members for simple cases
- ✅ Add 3-line file headers (purpose + technical description)
- ✅ Follow 98-character decorator width
- ✅ Normal comments:
//with space - ✅ Decorator lines:
//======without space - ✅ Enable nullable reference types
- ✅ Private fields: camelCase without underscore prefix
- ✅ Use xUnit + FluentAssertions for tests
- ✅ Follow
MethodName_Should_ExpectedBehaviortest naming