csharp-best-practices
星标2
分支0
更新时间2026年1月16日 14:23
Directs agents to avoid bad C# practices like magic strings and poor architecture.
安装
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
SKILL.md
readonly菜单
Directs agents to avoid bad C# practices like magic strings and poor architecture.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Verifies DWSIM API usage by cross-referencing against the local source code in libs/dwsim_src.
Directs agents to avoid bad C# practices like magic strings and poor architecture.
Enforces Enerflow's specific Enterprise Worker architecture and DWSIM integration rules.
Verifies DWSIM API usage by cross-referencing against the local source code in libs/dwsim_src.
| name | csharp-best-practices |
| description | Directs agents to avoid bad C# practices like magic strings and poor architecture. |
| license | MIT |
| compatibility | opencode |
| metadata | {"language":"csharp","framework":"dotnet"} |
switch statements) and recommend converting them to strongly-typed Enums.file-scoped namespaces, primary constructors, and records where appropriate for .NET 10+.Guid.NewGuid(). Always use Enerflow.Domain.Common.IdGenerator.NextGuid() (which uses MassTransit's NewId) to ensure database-friendly sequential identifiers.// Bad: Relies on string literals which are prone to typos and hard to refactor
var units = systemOfUnits.ToUpperInvariant() switch
{
"SI" => ...
"CGS" => ...
_ => ...
};
// Good: Uses strict Enum types
public enum SystemOfUnits { SI, CGS, English }
var units = unitType switch
{
SystemOfUnits.SI => ...
SystemOfUnits.CGS => ...
_ => ...
};
// Bad: Domain DTO referencing DWSIM types directly
public class SimulationJob {
public DWSIM.Thermodynamics.PropertyPackage Package { get; set; }
}
// Good: Domain uses its own Enum, Mapper handles the conversion
public class SimulationJob {
public Enerflow.Domain.Enums.PropertyPackage Package { get; set; }
}
// Bad: Random Guids cause database fragmentation
var id = Guid.NewGuid();
// Good: Uses IdGenerator for database-friendly sequential IDs
var id = Enerflow.Domain.Common.IdGenerator.NextGuid();