@cratis/pi 7.152.0 → 7.152.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package/corpus/harnesses/copilot/instructions/code-quality.csharp.instructions.md +1 -0
- package/package/corpus/harnesses/copilot/instructions/csharp.instructions.md +4 -0
- package/package/corpus/rules/code-quality.csharp.md +1 -0
- package/package/corpus/rules/csharp.md +4 -0
- package/package/corpus/skills/cratis-screenplay-reverse-engineering/scripts/score-fidelity.mjs +14 -9
- package/package.json +1 -1
|
@@ -62,6 +62,7 @@ public class JsonReportFormatter : IReportFormatter { ... }
|
|
|
62
62
|
- Prefer strategy interfaces over `switch`/`if-else` chains that grow over time.
|
|
63
63
|
- Use `IInstancesOf<T>` to discover all implementations by convention — no manual registration needed.
|
|
64
64
|
- Design public APIs as contracts (interfaces/records) rather than concrete implementations.
|
|
65
|
+
- For a closed set of outcomes, prefer a sealed record hierarchy consumed by an exhaustive `switch`. Use `closed` only on NEW types in net11 code, never on an existing public type.
|
|
65
66
|
|
|
66
67
|
## Separation of Concerns
|
|
67
68
|
|
|
@@ -58,6 +58,10 @@ Every rule here reduces noise. `var` avoids redundant type repetition. Expressio
|
|
|
58
58
|
- The `Cratis.Architecture.CodeAnalysis` analyzer package (26 diagnostics, `CRARCH0001`–`CRARCH0026`; verified at `v1.0.2`) enforces these and others: `CRARCH0003` postfixes, `0004` `.Features.` namespaces, `0005` regions, `0006`/`0024` `LoggerMessage`, `0007` `IServiceProvider` injection, `0008` `is null`, `0017` namespace matches folder, `0019` `Async` suffix, `0022` explicit `private`, `0023` typed logger category; `0012` (`async void`) and `0014` (test types in production) are errors. When a repository has the package, a `CRARCH` warning is the house convention, not noise.
|
|
59
59
|
- For types with no implementation body, omit the braces (e.g. `public interface IMyInterface;`).
|
|
60
60
|
- Prefer `record` types for immutable data structures (events, commands, read models, concepts) — they give you value equality, immutability, and concise syntax for free.
|
|
61
|
+
- Set `LangVersion` to `latest` in every repository. Language-only features of newer C# versions are safe on every target of a multi-targeted library; a new runtime or library API needs `#if NET11_0_OR_GREATER` with a net10 fallback.
|
|
62
|
+
- Use collection expression arguments (`[with(capacity: n), .. items]`, `[with(comparer), ..]`) instead of constructor calls, and labeled `break`/`continue` instead of Boolean flags or `goto` in nested loops (IDE0410).
|
|
63
|
+
- Do not introduce `union` types, runtime-async, or the memory-safety preview features, and do not retrofit `closed` onto an existing public type — a public API change is a major version.
|
|
64
|
+
- Keep IDE style rule severities at `suggestion`, never `warning`: Release builds treat warnings as errors.
|
|
61
65
|
|
|
62
66
|
## Nullable Reference Types
|
|
63
67
|
|
|
@@ -61,6 +61,7 @@ public class JsonReportFormatter : IReportFormatter { ... }
|
|
|
61
61
|
- Prefer strategy interfaces over `switch`/`if-else` chains that grow over time.
|
|
62
62
|
- Use `IInstancesOf<T>` to discover all implementations by convention — no manual registration needed.
|
|
63
63
|
- Design public APIs as contracts (interfaces/records) rather than concrete implementations.
|
|
64
|
+
- For a closed set of outcomes, prefer a sealed record hierarchy consumed by an exhaustive `switch`. Use `closed` only on NEW types in net11 code, never on an existing public type.
|
|
64
65
|
|
|
65
66
|
## Separation of Concerns
|
|
66
67
|
|
|
@@ -57,6 +57,10 @@ Every rule here reduces noise. `var` avoids redundant type repetition. Expressio
|
|
|
57
57
|
- The `Cratis.Architecture.CodeAnalysis` analyzer package (26 diagnostics, `CRARCH0001`–`CRARCH0026`; verified at `v1.0.2`) enforces these and others: `CRARCH0003` postfixes, `0004` `.Features.` namespaces, `0005` regions, `0006`/`0024` `LoggerMessage`, `0007` `IServiceProvider` injection, `0008` `is null`, `0017` namespace matches folder, `0019` `Async` suffix, `0022` explicit `private`, `0023` typed logger category; `0012` (`async void`) and `0014` (test types in production) are errors. When a repository has the package, a `CRARCH` warning is the house convention, not noise.
|
|
58
58
|
- For types with no implementation body, omit the braces (e.g. `public interface IMyInterface;`).
|
|
59
59
|
- Prefer `record` types for immutable data structures (events, commands, read models, concepts) — they give you value equality, immutability, and concise syntax for free.
|
|
60
|
+
- Set `LangVersion` to `latest` in every repository. Language-only features of newer C# versions are safe on every target of a multi-targeted library; a new runtime or library API needs `#if NET11_0_OR_GREATER` with a net10 fallback.
|
|
61
|
+
- Use collection expression arguments (`[with(capacity: n), .. items]`, `[with(comparer), ..]`) instead of constructor calls, and labeled `break`/`continue` instead of Boolean flags or `goto` in nested loops (IDE0410).
|
|
62
|
+
- Do not introduce `union` types, runtime-async, or the memory-safety preview features, and do not retrofit `closed` onto an existing public type — a public API change is a major version.
|
|
63
|
+
- Keep IDE style rule severities at `suggestion`, never `warning`: Release builds treat warnings as errors.
|
|
60
64
|
|
|
61
65
|
## Nullable Reference Types
|
|
62
66
|
|
package/package/corpus/skills/cratis-screenplay-reverse-engineering/scripts/score-fidelity.mjs
CHANGED
|
@@ -150,6 +150,19 @@ function parseArguments(args) {
|
|
|
150
150
|
return options;
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
+
function readCatalog(path) {
|
|
154
|
+
try {
|
|
155
|
+
return JSON.parse(readFileSync(path, 'utf8'));
|
|
156
|
+
} catch (error) {
|
|
157
|
+
throw new CatalogError(`cannot read ${path}: ${error.message}`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function writeScore(options) {
|
|
162
|
+
const result = score(readCatalog(options.catalog), options.naming ? readCatalog(options.naming) : undefined);
|
|
163
|
+
console.log(options.json ? JSON.stringify(roundDeep(result)) : format(result));
|
|
164
|
+
}
|
|
165
|
+
|
|
153
166
|
async function main() {
|
|
154
167
|
try {
|
|
155
168
|
const options = parseArguments(process.argv.slice(2));
|
|
@@ -159,15 +172,7 @@ async function main() {
|
|
|
159
172
|
return;
|
|
160
173
|
}
|
|
161
174
|
if (!options.catalog) throw new CatalogError('Usage: node score-fidelity.mjs <catalog.json> [--naming <naming.json>] [--json] | --self-test');
|
|
162
|
-
|
|
163
|
-
try {
|
|
164
|
-
return JSON.parse(readFileSync(path, 'utf8'));
|
|
165
|
-
} catch (error) {
|
|
166
|
-
throw new CatalogError(`cannot read ${path}: ${error.message}`);
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
const result = score(read(options.catalog), options.naming ? read(options.naming) : undefined);
|
|
170
|
-
console.log(options.json ? JSON.stringify(roundDeep(result)) : format(result));
|
|
175
|
+
writeScore(options);
|
|
171
176
|
} catch (error) {
|
|
172
177
|
console.error(`score-fidelity: ${error.message}`);
|
|
173
178
|
process.exitCode = error instanceof CatalogError ? 2 : 1;
|