docs: Updates CLAUDE dev-docs/skills for serialization (#2372)

This commit is contained in:
Kamron Batman 2026-03-15 01:05:03 -07:00 committed by GitHub
parent ff10811d3d
commit af35c25ca2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 342 additions and 79 deletions

View file

@ -43,6 +43,44 @@ This document defines the coding conventions and standards for ModernUO content
var damage = Utility.RandomMinMax(10, 20);
```
### Brace Style
ALL control flow statements (`if`, `else`, `for`, `foreach`, `while`, `do`, `switch`) **must** have braces, even for single-line bodies. This reduces merge conflicts and diff sizes.
```csharp
// BAD
if (condition)
DoSomething();
// GOOD
if (condition)
{
DoSomething();
}
```
### Switch Patterns
Prefer switch expressions and switch-when pattern matching where they improve readability and enable JIT/PGO optimization. Skip if code becomes unreadable or is on a cold path.
```csharp
// Prefer switch expression for value mapping
private static string GetName(GemType type) => type switch
{
GemType.StarSapphire => "star sapphire",
GemType.Emerald => "emerald",
_ => "gem"
};
// Prefer switch-when for performance (compiler hints to JIT/PGO)
switch (item)
{
case Sword { Quality: >= ItemQuality.Exceptional } when Core.AOS:
{
bonus = 10;
break;
}
}
```
### Legacy Code
Older code uses `m_` prefix for private fields (e.g., `m_Amount`). Do not change existing `m_` fields, but always use `_` prefix for new code.
@ -332,7 +370,7 @@ Available spatial queries (on `Map`):
### Partial Classes
Any class with `[SerializationGenerator]` **must** be declared `partial`:
```csharp
[SerializationGenerator(0, false)]
[SerializationGenerator(0)]
public partial class MyItem : Item // MUST be partial
{
}