[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M699JBGRVRXZ0Y96B50406QY":3,"skill-same:01M699JBGRVRXZ0Y96B50406QY":93},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":18,"categories":19,"keywords":30,"publishedAt":51,"linkOnly":52,"markdownContent":53,"markdownBody":54,"frontMatter":55,"refName":57,"commitSha":58,"skillDirectory":59,"forksCount":60,"repositoryHtmlUrl":61,"repositoryHomepageUrl":17,"ownerHtmlUrl":62,"ownerBlogUrl":63,"ownerDescription":64,"updatedAt":65,"install":66,"resources":78},"01M699JBGRVRXZ0Y96B50406QY","code-quality","C# 代码质量静态检查","Statically check changed C# against the same deterministic rules github-code-quality[bot] runs on pull requests, so a contributor can fix likely findings before opening the PR and keep the bot's inline comments to a minimum. Activate when a contributor asks to \"check code quality\", \"run code quality on my changes\", \"will the code quality bot complain\", \"pre-check before I open the PR\", \"code quality check\", or similar. Scoped to C#. Reads the diff and compares it against the enumerated csharp-code-quality rule set below — no CodeQL download or build required. This is a fast approximation of a dataflow engine, not a reproduction; report accordingly. Does NOT apply fixes unless explicitly asked.","对变更的 C# 代码进行静态检查，采用与 github-code-quality[bot] 在 pull request 上相同的确定性规则，使贡献者能在开启 PR 之前修复可能被发现的问题，并尽量减少对机器人的内联评论。当贡献者要求'检查代码质量'、'对我的变更运行代码质量检查'、'代码质量机器人会报错吗'、'开启 PR 前的预检'、'代码质量检查'或类似请求时激活。仅限 C# 范围。它会读取 diff 并与下面列举的 csharp-code-quality 规则集进行比对——无需下载 CodeQL 或进行构建。这是数据流引擎的快速近似，而非完整复现；请据此报告结果。除非明确要求，否则不应用修复。","microsoft\u002FwinappCli","microsoft","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F6154722?v=4","01M698VYDXZ6JW5WH3CRV650R8","Microsoft","01M699J7Q2FM9V32CFV0Q8VPF9",1381,"MIT",null,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fcode-quality\u002FSKILL.md",[20,25],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BQ6TQZN6R52WBJ9H8NRMQM","软件开发工程师","PROFESSION","适用职业",{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BQJH394GT47X57A9Q8G7HX","测试与质量保障","SCENARIO","使用场景",[31,32,33,34,35,36,37,38,39,40,41,42,5,43,44,45,46,47,48,49,50],"code quality","code","quality","open","when","contributor","run code","inline","my","deterministic","activate","fix","bot","SET","codeql","pull","run","csharp","pull requests","github","2026-11-10 10:12:30",false,"---\nname: code-quality\ndescription: Statically check changed C# against the same deterministic rules github-code-quality[bot] runs on pull requests, so a contributor can fix likely findings before opening the PR and keep the bot's inline comments to a minimum. Activate when a contributor asks to \"check code quality\", \"run code quality on my changes\", \"will the code quality bot complain\", \"pre-check before I open the PR\", \"code quality check\", or similar. Scoped to C#. Reads the diff and compares it against the enumerated csharp-code-quality rule set below — no CodeQL download or build required. This is a fast approximation of a dataflow engine, not a reproduction; report accordingly. Does NOT apply fixes unless explicitly asked.\ninfer: true\n---\n\nYou are the **local code-quality pre-check** for `microsoft\u002Fwinappcli`. On pull\nrequests, `github-code-quality[bot]` runs the deterministic CodeQL\n**`csharp-code-quality`** suite and posts each hit as an inline comment. This\nskill reads the contributor's C# diff and flags lines that are likely to trip\nthose same rules, so they can be cleared before pushing.\n\nScope is **C# only** — the language the bot rule-checks in this repo.\n\n**Be honest about what this is.** The bot runs a deterministic dataflow\u002Ftype\nengine; you are pattern-matching a diff by reading it. You will reliably catch the\nsyntactic rules and miss or over-flag the analysis-heavy ones (marked **†**\nbelow — null-flow, disposal escape analysis, \"value never used\", LINQ shape\ndetection). Treat **†** findings as *lower confidence*, and never claim a clean\nresult guarantees zero bot comments. It does not — it means nothing *obvious* is\nleft. This also does not cover the bot's separate AI-powered pass, or C\u002FC++.\n\nDo **not** activate for a single \"is this line okay\" question — that is a direct\nquestion, not a diff-wide pre-check.\n\n## 1. Scope to the changed C# code\n\nFirst find the merge base, so committed *and* still-uncommitted work both count —\ncall it `\u003Cbase>`: `git merge-base origin\u002Fmain HEAD`.\n\n- **Tracked changes** (branch commits plus any staged\u002Funstaged edits):\n  `git --no-pager diff --name-only \u003Cbase>` — diffing the working tree against the\n  merge base, so a later edit to an already-committed file is still seen.\n- **Untracked new files:** `git ls-files --others --exclude-standard -- \"src\u002F*.cs\"`\n  — `git diff` cannot emit hunks for these; read them directly with `view`.\n\nKeep only `*.cs` under `src\\`, and drop files matching the repo's CodeQL exclusion\n`**\u002F*Tests\u002F*.cs` — a `.cs` file **directly inside** a directory whose name ends in\n`Tests` (e.g. `src\\WinApp.Cli.Tests\\Foo.cs`). Mirror that glob exactly: a file\nnested deeper, such as `src\\...\\WinApp.Cli.Tests\\TestApps\\App.xaml.cs`, does **not**\nmatch it, so the bot may scan it — keep those in scope. If nothing survives, say\nso and stop.\n\nThen read the changed lines. For a tracked file:\n`git --no-pager diff --unified=0 \u003Cbase> -- \u003Cfile>`; for an untracked file the whole\nfile is added, so `view` it. Either way `view` each changed region for context.\n**Only flag code inside the changed hunks** — the bot comments on changed lines,\nand pre-existing debt elsewhere is not this PR's problem.\n\n## 2. Check the diff against the rule set\n\nFor every changed hunk, walk the rule tables below and flag each line that\nmatches. For a match, record the `cs\u002F...` id, the exact `file:line`, the offending\nsnippet, and the smallest fix. Prefer precision over volume: if you cannot point\nat the specific line and say what the bot would say, drop it. Apply extra\nskepticism to **†** rules — only raise one when the trigger is visible in the diff\n(e.g. a `new HttpRequestMessage(...)` with no `using` and no `return`\u002Ffield\nassignment), not on a hunch.\n\n### Exception handling\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Fcatch-of-all-exceptions` | `catch (Exception)` (or bare `catch`) → catch the specific type you can handle |\n| `cs\u002Fcatch-nullreferenceexception` | catching `NullReferenceException` → fix the deref; don't catch it |\n| `cs\u002Fempty-catch-block` | `catch {}` that swallows → handle, log, or let it propagate |\n| `cs\u002Frethrown-exception-variable` | `throw ex;` (resets stack) → `throw;` |\n\n### Null & dereference — **†**\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Fdereferenced-value-may-be-null` **†** | using a value that a prior branch\u002FAPI can leave null → null-check or `?.` |\n| `cs\u002Fdereferenced-value-is-always-null` **†** | dereffing a value provably always null → remove\u002Frepair |\n| `cs\u002Fnull-argument-to-equals` | `x.Equals(null)` → `x is null` |\n\n### Disposal & resources\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Flocal-not-disposed` **†** | a local `IDisposable` you own, never disposed → `using` |\n| `cs\u002Fmissed-using-statement` **†** | `Dispose()` in a `finally` you could express as `using` → `using` |\n\n### Equality & hashing\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Fgethashcode-is-not-defined` | overriding `Equals` without `GetHashCode` → override both |\n| `cs\u002Fuseless-gethashcode-call` | `GetHashCode()` on a small integral type (e.g. `int`, `enum`) — it just returns the value → drop the redundant call |\n| `cs\u002Fequals-on-arrays` | `array.Equals(other)` (reference eq) → `SequenceEqual` |\n| `cs\u002Fequals-on-unrelated-types` | `Equals` across incomparable types → compare compatible types |\n| `cs\u002Funchecked-cast-in-equals` | unchecked cast of the arg in an `Equals` override → `is`\u002F`as` guard |\n| `cs\u002Frecursive-equals-call` | `Equals` calling itself unboundedly → fix the recursion |\n| `cs\u002Freference-equality-on-valuetypes` | `ReferenceEquals` on value types (always false) → `==`\u002F`Equals` |\n| `cs\u002Fequality-on-floats` | `==` on `double`\u002F`float` → compare with a tolerance |\n| `cs\u002Fcomparison-of-identical-expressions` | a comparison operator with identical operands (`x == x`, `a \u003C a`) → remove or fix the typo |\n\n### Dead & useless code\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Fempty-block` | empty `if`\u002Floop body → remove or fill |\n| `cs\u002Fuseless-if-statement` | `if` whose branches do the same thing → collapse |\n| `cs\u002Fconstant-condition` **†** | condition provably always true\u002Ffalse → remove the dead path |\n| `cs\u002Fsimplifiable-boolean-expression` | `x ? true : false`, `!(a == b)` → simplify |\n| `cs\u002Fmissed-ternary-operator` | `if\u002Felse` that only assigns one variable → ternary |\n| `cs\u002Fnested-if-statements` | `if (a) { if (b) … }` with no else → `if (a && b)` |\n| `cs\u002Fuseless-tostring-call` | `.ToString()` on a `string` \u002F in interpolation → drop it |\n| `cs\u002Fcall-to-object-tostring` | default `object.ToString()` (type name) → override or format explicitly |\n| `cs\u002Fself-assignment` | `x = x;` → remove (or fix the intended target) |\n| `cs\u002Funused-label` | a `label:` never targeted → remove |\n| `cs\u002Funused-property-value` **†** | setter that ignores `value` → use it |\n| `cs\u002Fempty-collection` **†** | a collection created empty and then read\u002Fused but never given any elements → add elements or drop the reads |\n| `cs\u002Funused-collection` **†** | a collection filled but never read → remove or use |\n\n### LINQ opportunities — **†**\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Flinq\u002Fmissed-where` **†** | `foreach` with a filtering `if` → `.Where(...)` |\n| `cs\u002Flinq\u002Fmissed-select` **†** | `foreach` that only projects → `.Select(...)` |\n| `cs\u002Flinq\u002Fmissed-all` **†** | loop checking a condition holds for all → `.All(...)` |\n| `cs\u002Flinq\u002Fmissed-cast` **†** | loop casting every element → `.Cast\u003CT>()` |\n| `cs\u002Flinq\u002Fmissed-oftype` **†** | loop filtering by type → `.OfType\u003CT>()` |\n| `cs\u002Flinq\u002Fuseless-select` | `.Select(x => x)` → drop it |\n\n### Collections & indexing\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Finefficient-containskey` | `ContainsKey` then indexer → `TryGetValue` |\n| `cs\u002Ftest-for-negative-container-size` | `Count \u003C 0` \u002F `Length \u003C 0` (never true) → fix the check |\n| `cs\u002Findex-out-of-bounds` **†** | off-by-one vs `Length`\u002F`Count` → use `\u003C Length` |\n| `cs\u002Fnested-loops-with-same-variable` | nested `for`\u002F`foreach` that reuse the same counter (inner loop also updates `i`) → use a distinct loop variable |\n\n### Concurrency & locking\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Flock-this` | `lock (this)` → lock a private `object` |\n| `cs\u002Fempty-lock-statement` | `lock (x) {}` → remove or fill |\n| `cs\u002Funsafe-sync-on-field` | locking a field that is **reassigned inside the lock** (threads then lock different objects) → lock a private `readonly` object |\n| `cs\u002Finconsistent-lock-sequence` **†** | acquiring locks in differing orders → fix ordering |\n| `cs\u002Flocked-wait` **†** | a blocking `.Wait()` (`Task`\u002F`WaitHandle`) while holding a lock — **not** `Monitor.Wait` on the locked object, which correctly requires it → don't block on unrelated waits inside the lock |\n| `cs\u002Fnon-short-circuit` | non-short-circuit `&`\u002F`\\|` on bools whose right operand has a risky access (e.g. a possible null-deref) that `&&`\u002F`\\|\\|` would guard → short-circuit |\n\n### `this`, casts & inheritance\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Fcast-of-this-to-type-parameter` | casting `this` to a type param → rethink the API |\n| `cs\u002Fdowncast-of-this` | downcasting `this` to a derived type → virtual method |\n| `cs\u002Ftype-test-of-this` | `this is DerivedType` → virtual method |\n| `cs\u002Fimpossible-array-cast` | array cast that always fails at runtime → fix the type |\n| `cs\u002Fclass-name-matches-base-class` | subclass named like its base → rename |\n| `cs\u002Ffield-masks-base-field` | field shadowing a base field → rename or reuse |\n| `cs\u002Flocal-shadows-member` | local hiding a field\u002Fproperty\u002Fparam → rename |\n\n### API & design smells\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Fpath-combine` **†** | `Path.Combine(a, b)` where a later arg is rooted (silently drops earlier) → validate segments |\n| `cs\u002Fcall-to-gc` | `GC.Collect()` → remove; let the runtime manage it |\n| `cs\u002Fcall-to-obsolete-method` | calling `[Obsolete]` API → use the replacement |\n| `cs\u002Fcall-to-unmanaged-code`, `cs\u002Funmanaged-code` | P\u002FInvoke \u002F unsafe surface → review necessity (often expected for CsWin32) |\n| `cs\u002Fclass-implements-icloneable` | `ICloneable` (ambiguous deep\u002Fshallow) → a typed clone method |\n| `cs\u002Fexpose-implementation` **†** | returning\u002Fstoring a reference to an internal mutable array\u002Fcollection that is **later modified** through the alias → return a copy or read-only view |\n| `cs\u002Fstatic-field-written-by-instance` | instance method writing a static field → rethink ownership |\n| `cs\u002Fmissed-readonly-modifier` **†** | a private field written only at its declaration and\u002For in the (static) constructor, never elsewhere → `readonly` |\n| `cs\u002Floss-of-precision` | integer division\u002Fmultiplication whose result is converted to `float`\u002F`double`\u002F`decimal` — precision is already lost before the conversion (e.g. `(double)(a \u002F b)`) → cast an operand first |\n| `cs\u002Finvalid-string-formatting` | format string vs args mismatch → fix placeholders |\n| `cs\u002Fstring-concatenation-in-loop` **†** | `s += …` in a loop → `StringBuilder` |\n| `cs\u002Fstringbuilder-creation-in-loop` **†** | `new StringBuilder()` inside a loop → hoist it out **only if** it doesn't escape the iteration, calling `.Clear()` at the start of each pass; otherwise leave it |\n| `cs\u002Fstringbuilder-initialized-with-character` | `new StringBuilder('x')` (that's capacity!) → `.Append('x')` or `\"x\"` |\n| `cs\u002Fasp\u002Fresponse-write` | `Response.Write` of a single block → not relevant to this CLI; skip unless ASP code appears |\n\n## 3. Report\n\nPrint to stdout. No file output and **no fixes** unless asked.\n\n```markdown\n# Code Quality pre-check — \u003Chead> vs origin\u002Fmain (csharp-code-quality, static)\n\n## Verdict\n\u003Cnothing obvious | N likely finding(s)> — \u003Cone plain sentence>\n\n## Likely bot comments\n### \u003Crule id> — \u003Cshort plain title>   \u003Cmark (lower confidence) for † rules>\n- **What it flags:** \u003Cone sentence>\n- **Where:** `\u003Cpath>:\u003Cline>`\n- **Show me:** \u003Cthe snippet from the diff>\n- **Smallest fix:** \u003Cleast-complex change>\n\n\u003CRepeat per finding, or \"None obvious on your changed lines.\">\n\n## Coverage\n- Static pass over \u003Cn> changed C# file(s) against the 69-rule csharp-code-quality set.\n- This approximates a deterministic engine: analysis-heavy (†) rules may be\n  missed or over-flagged, and the bot's AI pass and C\u002FC++ are out of scope. A\n  clean result means nothing obvious remains, not a guarantee of zero comments.\n```\n\n## If asked to fix\n\nApply the **smallest** change that clears each finding on the changed lines, one\nrule at a time. Prefer the subtractive fix (delete the dead code, drop the\nredundant call) over adding structure. Do not touch pre-existing findings unless\nexplicitly asked.\n\n## Maintaining this skill\n\nThe tables above are a **point-in-time snapshot** of the `csharp-code-quality`\nsuite (69 rules). They will drift as CodeQL releases add or retire queries, so\nregenerate rather than hand-edit. With the CodeQL bundle available, the current\nmembership is:\n\n```powershell\ncodeql resolve queries codeql\u002Fcsharp-queries:codeql-suites\u002Fcsharp-code-quality.qls\n# each resolved .ql file's header carries its @id \u002F @name \u002F @precision\n```\n\nIf that list diverges from the tables, reconcile it — add new rules, remove\nretired ones — and keep the **†** markers on the flow\u002Ftype-analysis queries so\ntheir lower confidence stays visible. If the bot's config changes (languages,\nsuite, scanned paths), update the scope note in step 1 too.\n","You are the **local code-quality pre-check** for `microsoft\u002Fwinappcli`. On pull\nrequests, `github-code-quality[bot]` runs the deterministic CodeQL\n**`csharp-code-quality`** suite and posts each hit as an inline comment. This\nskill reads the contributor's C# diff and flags lines that are likely to trip\nthose same rules, so they can be cleared before pushing.\n\nScope is **C# only** — the language the bot rule-checks in this repo.\n\n**Be honest about what this is.** The bot runs a deterministic dataflow\u002Ftype\nengine; you are pattern-matching a diff by reading it. You will reliably catch the\nsyntactic rules and miss or over-flag the analysis-heavy ones (marked **†**\nbelow — null-flow, disposal escape analysis, \"value never used\", LINQ shape\ndetection). Treat **†** findings as *lower confidence*, and never claim a clean\nresult guarantees zero bot comments. It does not — it means nothing *obvious* is\nleft. This also does not cover the bot's separate AI-powered pass, or C\u002FC++.\n\nDo **not** activate for a single \"is this line okay\" question — that is a direct\nquestion, not a diff-wide pre-check.\n\n## 1. Scope to the changed C# code\n\nFirst find the merge base, so committed *and* still-uncommitted work both count —\ncall it `\u003Cbase>`: `git merge-base origin\u002Fmain HEAD`.\n\n- **Tracked changes** (branch commits plus any staged\u002Funstaged edits):\n  `git --no-pager diff --name-only \u003Cbase>` — diffing the working tree against the\n  merge base, so a later edit to an already-committed file is still seen.\n- **Untracked new files:** `git ls-files --others --exclude-standard -- \"src\u002F*.cs\"`\n  — `git diff` cannot emit hunks for these; read them directly with `view`.\n\nKeep only `*.cs` under `src\\`, and drop files matching the repo's CodeQL exclusion\n`**\u002F*Tests\u002F*.cs` — a `.cs` file **directly inside** a directory whose name ends in\n`Tests` (e.g. `src\\WinApp.Cli.Tests\\Foo.cs`). Mirror that glob exactly: a file\nnested deeper, such as `src\\...\\WinApp.Cli.Tests\\TestApps\\App.xaml.cs`, does **not**\nmatch it, so the bot may scan it — keep those in scope. If nothing survives, say\nso and stop.\n\nThen read the changed lines. For a tracked file:\n`git --no-pager diff --unified=0 \u003Cbase> -- \u003Cfile>`; for an untracked file the whole\nfile is added, so `view` it. Either way `view` each changed region for context.\n**Only flag code inside the changed hunks** — the bot comments on changed lines,\nand pre-existing debt elsewhere is not this PR's problem.\n\n## 2. Check the diff against the rule set\n\nFor every changed hunk, walk the rule tables below and flag each line that\nmatches. For a match, record the `cs\u002F...` id, the exact `file:line`, the offending\nsnippet, and the smallest fix. Prefer precision over volume: if you cannot point\nat the specific line and say what the bot would say, drop it. Apply extra\nskepticism to **†** rules — only raise one when the trigger is visible in the diff\n(e.g. a `new HttpRequestMessage(...)` with no `using` and no `return`\u002Ffield\nassignment), not on a hunch.\n\n### Exception handling\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Fcatch-of-all-exceptions` | `catch (Exception)` (or bare `catch`) → catch the specific type you can handle |\n| `cs\u002Fcatch-nullreferenceexception` | catching `NullReferenceException` → fix the deref; don't catch it |\n| `cs\u002Fempty-catch-block` | `catch {}` that swallows → handle, log, or let it propagate |\n| `cs\u002Frethrown-exception-variable` | `throw ex;` (resets stack) → `throw;` |\n\n### Null & dereference — **†**\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Fdereferenced-value-may-be-null` **†** | using a value that a prior branch\u002FAPI can leave null → null-check or `?.` |\n| `cs\u002Fdereferenced-value-is-always-null` **†** | dereffing a value provably always null → remove\u002Frepair |\n| `cs\u002Fnull-argument-to-equals` | `x.Equals(null)` → `x is null` |\n\n### Disposal & resources\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Flocal-not-disposed` **†** | a local `IDisposable` you own, never disposed → `using` |\n| `cs\u002Fmissed-using-statement` **†** | `Dispose()` in a `finally` you could express as `using` → `using` |\n\n### Equality & hashing\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Fgethashcode-is-not-defined` | overriding `Equals` without `GetHashCode` → override both |\n| `cs\u002Fuseless-gethashcode-call` | `GetHashCode()` on a small integral type (e.g. `int`, `enum`) — it just returns the value → drop the redundant call |\n| `cs\u002Fequals-on-arrays` | `array.Equals(other)` (reference eq) → `SequenceEqual` |\n| `cs\u002Fequals-on-unrelated-types` | `Equals` across incomparable types → compare compatible types |\n| `cs\u002Funchecked-cast-in-equals` | unchecked cast of the arg in an `Equals` override → `is`\u002F`as` guard |\n| `cs\u002Frecursive-equals-call` | `Equals` calling itself unboundedly → fix the recursion |\n| `cs\u002Freference-equality-on-valuetypes` | `ReferenceEquals` on value types (always false) → `==`\u002F`Equals` |\n| `cs\u002Fequality-on-floats` | `==` on `double`\u002F`float` → compare with a tolerance |\n| `cs\u002Fcomparison-of-identical-expressions` | a comparison operator with identical operands (`x == x`, `a \u003C a`) → remove or fix the typo |\n\n### Dead & useless code\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Fempty-block` | empty `if`\u002Floop body → remove or fill |\n| `cs\u002Fuseless-if-statement` | `if` whose branches do the same thing → collapse |\n| `cs\u002Fconstant-condition` **†** | condition provably always true\u002Ffalse → remove the dead path |\n| `cs\u002Fsimplifiable-boolean-expression` | `x ? true : false`, `!(a == b)` → simplify |\n| `cs\u002Fmissed-ternary-operator` | `if\u002Felse` that only assigns one variable → ternary |\n| `cs\u002Fnested-if-statements` | `if (a) { if (b) … }` with no else → `if (a && b)` |\n| `cs\u002Fuseless-tostring-call` | `.ToString()` on a `string` \u002F in interpolation → drop it |\n| `cs\u002Fcall-to-object-tostring` | default `object.ToString()` (type name) → override or format explicitly |\n| `cs\u002Fself-assignment` | `x = x;` → remove (or fix the intended target) |\n| `cs\u002Funused-label` | a `label:` never targeted → remove |\n| `cs\u002Funused-property-value` **†** | setter that ignores `value` → use it |\n| `cs\u002Fempty-collection` **†** | a collection created empty and then read\u002Fused but never given any elements → add elements or drop the reads |\n| `cs\u002Funused-collection` **†** | a collection filled but never read → remove or use |\n\n### LINQ opportunities — **†**\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Flinq\u002Fmissed-where` **†** | `foreach` with a filtering `if` → `.Where(...)` |\n| `cs\u002Flinq\u002Fmissed-select` **†** | `foreach` that only projects → `.Select(...)` |\n| `cs\u002Flinq\u002Fmissed-all` **†** | loop checking a condition holds for all → `.All(...)` |\n| `cs\u002Flinq\u002Fmissed-cast` **†** | loop casting every element → `.Cast\u003CT>()` |\n| `cs\u002Flinq\u002Fmissed-oftype` **†** | loop filtering by type → `.OfType\u003CT>()` |\n| `cs\u002Flinq\u002Fuseless-select` | `.Select(x => x)` → drop it |\n\n### Collections & indexing\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Finefficient-containskey` | `ContainsKey` then indexer → `TryGetValue` |\n| `cs\u002Ftest-for-negative-container-size` | `Count \u003C 0` \u002F `Length \u003C 0` (never true) → fix the check |\n| `cs\u002Findex-out-of-bounds` **†** | off-by-one vs `Length`\u002F`Count` → use `\u003C Length` |\n| `cs\u002Fnested-loops-with-same-variable` | nested `for`\u002F`foreach` that reuse the same counter (inner loop also updates `i`) → use a distinct loop variable |\n\n### Concurrency & locking\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Flock-this` | `lock (this)` → lock a private `object` |\n| `cs\u002Fempty-lock-statement` | `lock (x) {}` → remove or fill |\n| `cs\u002Funsafe-sync-on-field` | locking a field that is **reassigned inside the lock** (threads then lock different objects) → lock a private `readonly` object |\n| `cs\u002Finconsistent-lock-sequence` **†** | acquiring locks in differing orders → fix ordering |\n| `cs\u002Flocked-wait` **†** | a blocking `.Wait()` (`Task`\u002F`WaitHandle`) while holding a lock — **not** `Monitor.Wait` on the locked object, which correctly requires it → don't block on unrelated waits inside the lock |\n| `cs\u002Fnon-short-circuit` | non-short-circuit `&`\u002F`\\|` on bools whose right operand has a risky access (e.g. a possible null-deref) that `&&`\u002F`\\|\\|` would guard → short-circuit |\n\n### `this`, casts & inheritance\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Fcast-of-this-to-type-parameter` | casting `this` to a type param → rethink the API |\n| `cs\u002Fdowncast-of-this` | downcasting `this` to a derived type → virtual method |\n| `cs\u002Ftype-test-of-this` | `this is DerivedType` → virtual method |\n| `cs\u002Fimpossible-array-cast` | array cast that always fails at runtime → fix the type |\n| `cs\u002Fclass-name-matches-base-class` | subclass named like its base → rename |\n| `cs\u002Ffield-masks-base-field` | field shadowing a base field → rename or reuse |\n| `cs\u002Flocal-shadows-member` | local hiding a field\u002Fproperty\u002Fparam → rename |\n\n### API & design smells\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Fpath-combine` **†** | `Path.Combine(a, b)` where a later arg is rooted (silently drops earlier) → validate segments |\n| `cs\u002Fcall-to-gc` | `GC.Collect()` → remove; let the runtime manage it |\n| `cs\u002Fcall-to-obsolete-method` | calling `[Obsolete]` API → use the replacement |\n| `cs\u002Fcall-to-unmanaged-code`, `cs\u002Funmanaged-code` | P\u002FInvoke \u002F unsafe surface → review necessity (often expected for CsWin32) |\n| `cs\u002Fclass-implements-icloneable` | `ICloneable` (ambiguous deep\u002Fshallow) → a typed clone method |\n| `cs\u002Fexpose-implementation` **†** | returning\u002Fstoring a reference to an internal mutable array\u002Fcollection that is **later modified** through the alias → return a copy or read-only view |\n| `cs\u002Fstatic-field-written-by-instance` | instance method writing a static field → rethink ownership |\n| `cs\u002Fmissed-readonly-modifier` **†** | a private field written only at its declaration and\u002For in the (static) constructor, never elsewhere → `readonly` |\n| `cs\u002Floss-of-precision` | integer division\u002Fmultiplication whose result is converted to `float`\u002F`double`\u002F`decimal` — precision is already lost before the conversion (e.g. `(double)(a \u002F b)`) → cast an operand first |\n| `cs\u002Finvalid-string-formatting` | format string vs args mismatch → fix placeholders |\n| `cs\u002Fstring-concatenation-in-loop` **†** | `s += …` in a loop → `StringBuilder` |\n| `cs\u002Fstringbuilder-creation-in-loop` **†** | `new StringBuilder()` inside a loop → hoist it out **only if** it doesn't escape the iteration, calling `.Clear()` at the start of each pass; otherwise leave it |\n| `cs\u002Fstringbuilder-initialized-with-character` | `new StringBuilder('x')` (that's capacity!) → `.Append('x')` or `\"x\"` |\n| `cs\u002Fasp\u002Fresponse-write` | `Response.Write` of a single block → not relevant to this CLI; skip unless ASP code appears |\n\n## 3. Report\n\nPrint to stdout. No file output and **no fixes** unless asked.\n\n```markdown\n# Code Quality pre-check — \u003Chead> vs origin\u002Fmain (csharp-code-quality, static)\n\n## Verdict\n\u003Cnothing obvious | N likely finding(s)> — \u003Cone plain sentence>\n\n## Likely bot comments\n### \u003Crule id> — \u003Cshort plain title>   \u003Cmark (lower confidence) for † rules>\n- **What it flags:** \u003Cone sentence>\n- **Where:** `\u003Cpath>:\u003Cline>`\n- **Show me:** \u003Cthe snippet from the diff>\n- **Smallest fix:** \u003Cleast-complex change>\n\n\u003CRepeat per finding, or \"None obvious on your changed lines.\">\n\n## Coverage\n- Static pass over \u003Cn> changed C# file(s) against the 69-rule csharp-code-quality set.\n- This approximates a deterministic engine: analysis-heavy (†) rules may be\n  missed or over-flagged, and the bot's AI pass and C\u002FC++ are out of scope. A\n  clean result means nothing obvious remains, not a guarantee of zero comments.\n```\n\n## If asked to fix\n\nApply the **smallest** change that clears each finding on the changed lines, one\nrule at a time. Prefer the subtractive fix (delete the dead code, drop the\nredundant call) over adding structure. Do not touch pre-existing findings unless\nexplicitly asked.\n\n## Maintaining this skill\n\nThe tables above are a **point-in-time snapshot** of the `csharp-code-quality`\nsuite (69 rules). They will drift as CodeQL releases add or retire queries, so\nregenerate rather than hand-edit. With the CodeQL bundle available, the current\nmembership is:\n\n```powershell\ncodeql resolve queries codeql\u002Fcsharp-queries:codeql-suites\u002Fcsharp-code-quality.qls\n# each resolved .ql file's header carries its @id \u002F @name \u002F @precision\n```\n\nIf that list diverges from the tables, reconcile it — add new rules, remove\nretired ones — and keep the **†** markers on the flow\u002Ftype-analysis queries so\ntheir lower confidence stays visible. If the bot's config changes (languages,\nsuite, scanned paths), update the scope note in step 1 too.\n",{"name":5,"infer":56,"description":7},true,"main","1fe910277860e8dbb38bfbeef7e8bdb039d6ee41",".github\u002Fskills\u002Fcode-quality",96,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli","https:\u002F\u002Fgithub.com\u002Fmicrosoft","https:\u002F\u002Fopensource.microsoft.com","Open source projects and samples from Microsoft","2026-11-14 07:14:37",{"source":9,"skillName":5,"commands":67,"prompt":77,"zipAvailable":56},[68,71,74],{"tool":69,"command":70},"npx","npx skills add microsoft\u002FwinappCli --skill code-quality",{"tool":72,"command":73},"bunx","bunx skills add microsoft\u002FwinappCli --skill code-quality",{"tool":75,"command":76},"pnpm","pnpm dlx skills add microsoft\u002FwinappCli --skill code-quality","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fcode-quality\u002FSKILL.md",[79,85,89],{"path":80,"resourceType":81,"resourceTypeDesc":82,"sizeBytes":83,"sourceHtmlUrl":84},"scripts\u002Fapple_json.py","SCRIPT","脚本",10314,"https:\u002F\u002Fgithub.com\u002Fmattwag05\u002Fmw-plugins\u002Fblob\u002Fmain\u002Fclient-adapters\u002Fclaude-code\u002Fplugins\u002Fdoc-harvest\u002Fskills\u002Fdoc-harvest\u002Fscripts\u002Fapple_json.py",{"path":86,"resourceType":81,"resourceTypeDesc":82,"sizeBytes":87,"sourceHtmlUrl":88},"scripts\u002Fharvest.py",34174,"https:\u002F\u002Fgithub.com\u002Fmattwag05\u002Fmw-plugins\u002Fblob\u002Fmain\u002Fclient-adapters\u002Fclaude-code\u002Fplugins\u002Fdoc-harvest\u002Fskills\u002Fdoc-harvest\u002Fscripts\u002Fharvest.py",{"path":90,"resourceType":81,"resourceTypeDesc":82,"sizeBytes":91,"sourceHtmlUrl":92},"scripts\u002Fscrapling-fetch.sh",4196,"https:\u002F\u002Fgithub.com\u002Fmattwag05\u002Fmw-plugins\u002Fblob\u002Fmain\u002Fclient-adapters\u002Fclaude-code\u002Fplugins\u002Fdoc-harvest\u002Fskills\u002Fdoc-harvest\u002Fscripts\u002Fscrapling-fetch.sh",[94,125,154,181,205,223],{"skillNo":95,"name":96,"nameZh":97,"description":98,"descriptionZh":99,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":100,"categories":101,"keywords":106,"publishedAt":51},"01M699M75MK9AADQV8PQQQ6NEV","winui-wpf-migration","WPF 至 WinUI 3 应用迁移","Migrate or port a WPF app to WinUI 3: namespaces (System.Windows to Microsoft.UI.Xaml), control mapping (DataGrid, WrapPanel, TabControl), Dispatcher to DispatcherQueue, imaging, MVVM with CommunityToolkit.Mvvm, ThemeResource. Use when converting WPF code or fixing migration build errors.","将 WPF 应用迁移或移植到 WinUI 3：命名空间（System.Windows 到 Microsoft.UI.Xaml）、控件映射（DataGrid、WrapPanel、TabControl）、Dispatcher 到 DispatcherQueue、图像处理、使用 CommunityToolkit.Mvvm 的 MVVM、ThemeResource。在转换 WPF 代码或修复迁移构建错误时使用。","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002Fplugins\u002Fwinui\u002Fagent-plugin\u002Fskills\u002Fwinui-wpf-migration\u002FSKILL.md",[102,103],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":104,"categoryName":105,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BT7QVANT4709358VEJK53E","代码实现",[107,108,109,110,10,111,112,32,113,114,115,116,117,118,119,120,121,122,123,124,35],"winui wpf migration","winui","wpf","migration","windows","dispatcher","xaml","ui","migrate","system","use","mvvm","app","mapping","port","imaging","errors","namespaces",{"skillNo":126,"name":127,"nameZh":128,"description":129,"descriptionZh":130,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":131,"categories":132,"keywords":137,"publishedAt":51},"01M699M4W3GKSVVT9CRR1E3KSW","winui-ui-testing","Windows 桌面应用 UI 自动化测试","Write and run automated UI tests for Windows desktop apps (WinUI 3, WPF, WinForms, Win32) with the winapp ui harness: one batch script, assertions, input, file pickers, dialogs, screenshots, locally or in Windows Sandbox. Use when asked for UI tests or to verify a feature end to end.","使用 winapp ui harness 为 Windows 桌面应用（WinUI 3、WPF、WinForms、Win32）编写并运行自动化 UI 测试：一个批处理脚本，支持断言、输入、文件选择器、对话框、截图，可在本地或 Windows Sandbox 中运行。当用户要求 UI 测试或端到端验证某个功能时使用。","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002Fplugins\u002Fwinui\u002Fagent-plugin\u002Fskills\u002Fwinui-ui-testing\u002FSKILL.md",[133,136],{"categoryNo":134,"categoryName":135,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BQGD5WG86P4AQ5GPSSKBFR","测试工程师",{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},[138,139,108,114,140,141,142,111,47,143,144,145,146,147,148,149,150,151,152,153,35],"testing","winui ui testing","ui testing","screenshots","sandbox","win32","harness","batch","write","feature","end","apps","input","winforms","desktop apps","for",{"skillNo":155,"name":156,"nameZh":157,"description":158,"descriptionZh":159,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":160,"categories":161,"keywords":166,"publishedAt":51},"01M699M2KTEYJZBDW7JBHM94K0","winui-setup","WinUI 3 开发环境配置","Install and verify WinUI 3 prerequisites — .NET SDK 8.0.100+, WinApp CLI 0.7+, and Developer Mode; identify additional Native AOT and Windows Sandbox requirements. Use when the user asks to set up or repair the toolchain, or when another WinUI skill finds a missing or outdated prerequisite.","安装并验证 WinUI 3 的先决条件——.NET SDK 8.0.100+、WinApp CLI 0.7+ 以及开发者模式；识别 Native AOT 和 Windows Sandbox 的额外要求。当用户请求设置或修复工具链，或其他 WinUI 技能发现先决条件缺失或过时时使用。","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002Fplugins\u002Fwinui\u002Fagent-plugin\u002Fskills\u002Fwinui-setup\u002FSKILL.md",[162,163],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":164,"categoryName":165,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BSTR9G4A4GZ0VB2DFN9490","开发环境与工具链管理",[167,168,108,169,142,170,111,44,171,172,117,173,174,175,176,177,178,179,180,35],"winui setup","setup","cli","sdk","verify","install","up","repair","requirements","missing","native","toolchain","winapp cli","mode",{"skillNo":182,"name":183,"nameZh":184,"description":185,"descriptionZh":186,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":187,"categories":188,"keywords":193,"publishedAt":51},"01M699KZWEZ84A4J3291E6R65B","winui-packaging","WinUI 3 应用打包与发布","MSIX packaging, signing, and Microsoft Store publishing for WinUI 3 apps with WinApp CLI 0.7+: project packaging, Native AOT, certificates, self-contained deployment, CI\u002FCD. Use when releasing or publishing a WinUI app. Not for WPF, WinForms, or Electron apps that only reference the Windows App SDK.","使用 WinApp CLI 0.7+ 对 WinUI 3 应用进行 MSIX 打包、签名并发布到 Microsoft Store：包括项目打包、Native AOT、证书、自包含部署和 CI\u002FCD。在发布 WinUI 应用时使用。不适用于仅引用 Windows App SDK 的 WPF、WinForms 或 Electron 应用。","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002Fplugins\u002Fwinui\u002Fagent-plugin\u002Fskills\u002Fwinui-packaging\u002FSKILL.md",[189,190],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":191,"categoryName":192,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BQNXPY1AV6BSR5VKHDMWRH","部署与发布管理",[194,108,195,169,170,196,10,197,111,198,199,200,201,202,203,119,149,151,177,204,179,153,35],"winui packaging","packaging","electron","msix","windows app sdk","ci","certificates","only","self","project","CI\u002FCD",{"skillNo":206,"name":207,"nameZh":208,"description":209,"descriptionZh":210,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":211,"categories":212,"keywords":215,"publishedAt":51},"01M699KXTHG9FHK4X3JSZ4SV8J","winui-dev-workflow","WinUI 应用开发工作流","Create, build, run, and fix build errors in WinUI 3 apps (C# or C++) with WinApp CLI 0.7+: winapp new, winapp run, Native AOT, crash diagnosis. Use for a new WinUI app or a WinUI project that fails to build or crashes. Not for WPF, WinForms, or Electron apps that only reference the Windows App SDK.","使用 WinApp CLI 0.7+ 创建、构建、运行 WinUI 3 应用（C# 或 C++）并修复构建错误：winapp new、winapp run、Native AOT、崩溃诊断。适用于新建 WinUI 应用，或构建失败、发生崩溃的 WinUI 项目。不适用于仅引用 Windows App SDK 的 WPF、WinForms 或 Electron 应用。","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002Fplugins\u002Fwinui\u002Fagent-plugin\u002Fskills\u002Fwinui-dev-workflow\u002FSKILL.md",[213,214],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":164,"categoryName":165,"taxonomyType":28,"taxonomyTypeDesc":29},[216,217,108,218,219,169,170,196,111,220,47,42,201,203,119,221,149,151,177,179,123,222],"workflow","winui dev workflow","dev","dev workflow","create","diagnosis","new",{"skillNo":224,"name":225,"nameZh":226,"description":227,"descriptionZh":228,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":229,"categories":230,"keywords":235,"publishedAt":51},"01M699KV0Q6NE5EET5EDBH33NM","winui-design","WinUI XAML 界面设计","Read before writing or changing WinUI 3 XAML: choosing controls, pages and navigation, layout, Fluent Design, theming, accessibility, x:Bind, real samples, and checking that APIs exist with winapp find-api. Not for WPF or WinForms UI, even if the app uses the Windows App SDK.","在编写或更改 WinUI 3 XAML 之前阅读：控件、页面与导航的选择、布局、Fluent Design、主题、可访问性、x:Bind、真实示例，以及使用 winapp find-api 检查 API 是否存在。不适用于 WPF 或 WinForms UI，即使应用使用了 Windows App SDK。","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002Fplugins\u002Fwinui\u002Fagent-plugin\u002Fskills\u002Fwinui-design\u002FSKILL.md",[231,232],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":233,"categoryName":234,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BRASNPVNJVQQJ4KZX8XM5D","前端开发与界面实现",[236,237,108,238,170,239,240,111,198,109,113,114,241,242,243,244,245,119,151,246,153,247],"design","winui design","writing","accessibility","fluent","api","read","layout","pages","bind","controls","fluent design"]