Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Language-specific super-code guidelines for csharp.
.claude/skills/lingxling-csharp/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-13 | ✗→✓ | ▲ Improved | 93% | 0% |
| case-01 | ✓→✓ | = Same ✓ | 63% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 29% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 159% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 292% | 0% |
csharp// ❌ Imperative accumulation var result = new List<string>(); foreach (var item in items) { if (item.IsActive) result.Add(item.Name.ToUpper()); } // ✅ var result = items .Where(i => i.IsActive) .Select(i => i.Name.ToUpper()) .ToList();
csharp// ❌ Manual grouping var grouped = new Dictionary<string, List<Item>>(); foreach (var item in items) { if (!grouped.ContainsKey(item.Category)) grouped[item.Category] = new List<Item>(); grouped[item.Category].Add(item); } // ✅ var grouped = items.GroupBy(i => i.Category) .ToDictionary(g => g.Key, g => g.ToList());
csharp// ❌ Checking Any() then First() if (items.Any(i => i.IsValid)) { var first = items.First(i => i.IsValid); } // ✅ var first = items.FirstOrDefault(i => i.IsValid); if (first is not null) { ... }
Prefer method syntax for chains of 2+ operations. Query syntax is fine for complex joins.
csharp// ❌ Nested null checks string city = null; if (user != null && user.Address != null) { city = user.Address.City; } // ✅ var city = user?.Address?.City;
csharp// ❌ Ternary for null fallback var name = user != null ? user.Name : "Unknown"; // ✅ var name = user?.Name ?? "Unknown";
csharp// ❌ Null check before event invocation if (OnChanged != null) OnChanged(this, args); // ✅ OnChanged?.Invoke(this, args);
csharp// ❌ Throwing ArgumentNullException manually if (name == null) throw new ArgumentNullException(nameof(name)); // ✅ (C# 10+) ArgumentNullException.ThrowIfNull(name);
Enable nullable reference types (<Nullable>enable</Nullable>) project-wide.
csharp// ❌ Blocking on async code var result = GetDataAsync().Result; // deadlock risk // ✅ var result = await GetDataAsync();
csharp// ❌ async void (exceptions are unobservable) async void OnButtonClick() { await DoWork(); } // ✅ — async Task; only async void for event handlers that truly require it async Task OnButtonClick() { await DoWork(); }
csharp// ❌ Sequential awaits for independent work var a = await FetchA(); var b = await FetchB(); // ✅ var (a, b) = (await Task.WhenAll(FetchA(), FetchB())) switch { var r => (r[0], r[1]) }; // or cleaner with ValueTuple: var taskA = FetchA(); var taskB = FetchB(); var a = await taskA; var b = await taskB;
csharp// ❌ Wrapping synchronous code in Task.Run inside a library public Task<int> GetValue() => Task.Run(() => ComputeSync()); // ✅ — let the caller decide; expose sync method public int GetValue() => ComputeSync();
Add ConfigureAwait(false) in library code. Omit in app/UI code.
csharp// ❌ Manual equality, ToString, Deconstruct for data types class Point { public int X { get; init; } public int Y { get; init; } // + Equals, GetHashCode, ToString... } // ✅ (C# 9+) record Point(int X, int Y);
csharp// ❌ if-else chain for type checking if (shape is Circle) { var c = (Circle)shape; return c.Radius * c.Radius * Math.PI; } else if (shape is Rectangle) { ... } // ✅ return shape switch { Circle { Radius: var r } => r * r * Math.PI, Rectangle { Width: var w, Height: var h } => w * h, _ => throw new ArgumentException($"Unknown shape: {shape}") };
csharp// ❌ Range checking with && if (score >= 0 && score <= 100) { ... } // ✅ (C# 9+) if (score is >= 0 and <= 100) { ... }
csharp// ❌ Catching Exception to log and swallow try { Process(); } catch (Exception ex) { logger.LogError(ex, "error"); } // ✅ — catch specific, rethrow if you can't handle try { Process(); } catch (HttpRequestException ex) { throw new ServiceException("upstream failure", ex); }
csharp// ❌ throw ex (resets stack trace) catch (Exception ex) { throw ex; } // ✅ catch (Exception ex) { throw; } // preserves stack trace // or wrap: throw new AppException("context", ex);
csharp// ❌ Exceptions for flow control try { return dict[key]; } catch (KeyNotFoundException) { return defaultValue; } // ✅ return dict.TryGetValue(key, out var value) ? value : defaultValue;
csharp// ❌ Manual Dispose var conn = new SqlConnection(cs); conn.Open(); // ... use conn ... conn.Dispose(); // missed on exception // ✅ using var conn = new SqlConnection(cs); conn.Open(); // disposed at end of scope
csharp// ❌ Verbose using block using (var reader = new StreamReader(path)) { return reader.ReadToEnd(); } // ✅ (C# 8+) using var reader = new StreamReader(path); return reader.ReadToEnd(); // or just: return File.ReadAllText(path);
| Anti-pattern | Preferred | |---|---| | string.Format("{0}", x) | $"{x}" string interpolation | | List<T> as public API return | IReadOnlyList<T> or IEnumerable<T> | | async void | async Task | | .Result / .Wait() on Task | await | | throw ex | throw (preserves stack trace) | | Manual IEquatable on data types | record | | object parameters | generics with constraints | | DateTime.Now | DateTime.UtcNow or DateTimeOffset | | Mutable public fields | properties with { get; set; } or { get; init; } | | catch (Exception) { } (swallow all) | catch specific exceptions, rethrow unknown | | IDisposable without using | using declaration |
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | pass→pass | 9,774 | 3,465 | -65% | 1 | 1 | 0% | 1,473 | 2,402 | +63% | 0 | 0 | — |
case-02 | pass→pass | 12,122 | 5,826 | -52% | 1 | 1 | 0% | 2,216 | 2,868 | +29% | 0 | 0 | — |
case-03 | pass→pass | 6,591 | 4,025 | -39% | 1 | 1 | 0% | 932 | 2,418 | +159% | 0 | 0 | — |
case-04 | pass→pass | 4,127 | 2,740 | -34% | 1 | 1 | 0% | 575 | 2,253 | +292% | 0 | 0 | — |
case-05 | pass→pass | 8,347 | 3,389 | -59% | 1 | 1 | 0% | 1,462 | 2,271 | +55% | 0 | 0 | — |
case-06 | pass→pass | 6,206 | 3,701 | -40% | 1 | 1 | 0% | 920 | 2,471 | +169% | 0 | 0 | — |
case-07 | fail→fail | 6,262 | 3,837 | -39% | 1 | 1 | 0% | 851 | 2,540 | +198% | 0 | 0 | — |
case-08 | pass→pass | 7,114 | 5,798 | -18% | 1 | 1 | 0% | 1,199 | 2,708 | +126% | 0 | 0 | — |
case-09 | pass→pass | 7,245 | 6,577 | -9% | 1 | 1 | 0% | 1,151 | 2,878 | +150% | 0 | 0 | — |
case-10 | pass→pass | 7,480 | 5,575 | -25% | 1 | 1 | 0% | 1,327 | 2,845 | +114% | 0 | 0 | — |
case-11 | pass→pass | 14,274 | 10,197 | -29% | 1 | 1 | 0% | 1,945 | 3,264 | +68% | 0 | 0 | — |
case-12 | pass→pass | 14,168 | 5,679 | -60% | 1 | 1 | 0% | 2,147 | 2,768 | +29% | 0 | 0 | — |
case-13 | fail→pass | 8,157 | 5,166 | -37% | 1 | 1 | 0% | 1,476 | 2,856 | +93% | 0 | 0 | — |
case-14 | pass→pass | 2,995 | 3,073 | +3% | 1 | 1 | 0% | 446 | 2,217 | +397% | 0 | 0 | — |
case-15 | pass→pass | 15,531 | 5,783 | -63% | 1 | 1 | 0% | 2,107 | 2,967 | +41% | 0 | 0 | — |
case-16 | pass→pass | 4,470 | 2,611 | -42% | 1 | 1 | 0% | 553 | 2,223 | +302% | 0 | 0 | — |
case-17 | pass→pass | 6,607 | 4,838 | -27% | 1 | 1 | 0% | 1,112 | 2,461 | +121% | 0 | 0 | — |
case-18 | pass→pass | 5,551 | 4,003 | -28% | 1 | 1 | 0% | 762 | 2,517 | +230% | 0 | 0 | — |
case-19 | pass→pass | 10,609 | 4,761 | -55% | 1 | 1 | 0% | 1,789 | 2,511 | +40% | 0 | 0 | — |
case-20 | pass→pass | 7,887 | 3,665 | -54% | 1 | 1 | 0% | 1,201 | 2,329 | +94% | 0 | 0 | — |
case-21 | pass→pass | 5,954 | 2,523 | -58% | 1 | 1 | 0% | 829 | 2,276 | +175% | 0 | 0 | — |
case-22 | pass→pass | 28,689 | 23,460 | -18% | 1 | 1 | 0% | 4,271 | 6,914 | +62% | 0 | 0 | — |
case-23 | pass→pass | 25,564 | 27,555 | +8% | 1 | 1 | 0% | 4,028 | 6,310 | +57% | 0 | 0 | — |
case-24 | pass→pass | 25,928 | 22,262 | -14% | 1 | 1 | 0% | 4,212 | 5,077 | +21% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 24 cases were attempted. The headline lift of +4 percentage points is the difference between those two pass rates over the 24 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.