TizenFX Refactoring Target Discovery and Issue Registration Pipeline
Overview
A pipeline that scans the TizenFX codebase for .NET 8 and C# 12+ modernization/optimization opportunities, drafts concrete application plans, and automatically registers them as GitHub Issues.
Each created issue explicitly states that it is a refactoring objective.
Repository
- Repo: samsung/TizenFX (GitHub)
- CLI:
gh CLI (authenticated)
Pipeline Flow
① Auto-select target area and scan → ② Optimization feasibility analysis (Self-Reflection)
→ [Pass] ③ Draft refactoring application plan → ④ Auto-register GitHub Issue
→ [Reject] Discard (low ROI / high risk)
Stage ①: Auto-select Target Area and Scan
Automatic directory rotation logic:
Because the scan scope is broad, the scan area is automatically rotated on every run.
- First run
gh repo clone samsung/TizenFX, or git pull the existing clone to sync
- Collect the main namespace directories under
src/:ls -d src/Tizen.*/
- Check which directories have already been analyzed by inspecting existing
ai-task labeled issues:gh issue list --repo samsung/TizenFX --label "ai-task" --state all --json title --jq '.[].title' | grep -oP '\[Scope: [^\]]+\]'
- Prioritize directories that have not yet been scanned, but once every directory has been covered once, re-scan starting with the one scanned longest ago
- Scan only 1–2 directories per run (to allow for in-depth analysis)
Scan Philosophy — 4 Evaluation Lenses (lens-based, not category-based)
Rather than "hunting" for a fixed list of patterns, observe the code through 4 evaluation lenses. A single finding may hit multiple lenses at once; the more it overlaps, the higher its grade.
In priority order:
🚀 Lens 1: Performance (Highest Priority)
The most important lens. Target measurable performance improvements.
- Reduce allocations:
ToList/ToArray in hot paths, new inside loops, boxing/unboxing, closure allocation (lambda capture)
- Buffer handling: opportunities to apply
Span<T>/Memory<T>, ArrayPool<T>, stackalloc (small fixed size)
- New .NET 8 types:
FrozenDictionary/FrozenSet (read-only lookup), SearchValues<T> (char search), CollectionsMarshal
- Task optimization: apply
ValueTask (hot path), use IAsyncEnumerable, remove .Result/.Wait() (also prevents deadlocks)
- LOH / GC pressure: allocation patterns for arrays ≥85KB, short-lived large objects
🆕 Lens 2: .NET 8 / C# 12 Modernization
Modernize with the latest language and runtime features.
- C# 12: Collection expressions
[1, 2, ..x], primary constructors (class/struct), ref readonly parameters
- C# 11:
required members, generic math, raw string literals """..."""
- C# 10~9: file-scoped namespaces,
record struct, switch expression, init accessor
- .NET 8 APIs:
ArgumentException.ThrowIfNull(x), ArgumentOutOfRangeException.ThrowIfNegative, TimeProvider
- Nullable reference types: introduce
#nullable enable, ensure NRT consistency
🧹 Lens 3: Clean Code
Improve readability and maintainability (within internal/private scope).
- Eliminate duplication (DRY), extract common logic
- Split methods that violate single responsibility (one method doing too much)
- Reduce deep nesting / complexity (guard clauses, early return)
- Remove dead code, unused private members
- Improve naming — limited to internal/private only (public API renames forbidden)
📐 Lens 4: .NET Coding Guidelines
Adherence to official guidelines. Based on Microsoft Design Guidelines.
- async/await consistency: remove
.Result, .Wait() (cause deadlocks)
- IDisposable pattern:
using declaration, consistent propagation
- Exception handling: overly broad
catch (Exception), swallowed exceptions, mismatched exception types
- Naming conventions (public APIs are immutable; only internals are in scope)
Lens overlap → grade ↑: if a finding hits both Performance and Modernization, it ranks higher than a single-lens finding (see Stage ②).
Quantitative heuristics (to minimize subjective judgment):
- switch conversion candidates: 5+
case branches, each ≥ 3 lines
- allocation inside loops:
new or LINQ chain inside for/foreach
- heavy methods: cyclomatic complexity ≥ 10, or ≥ 100 lines
Stage ②: Optimization Feasibility Analysis and Grade Assignment
2-1. Safety Gate
For each finding, self-verify against the following criteria:
- Can the Public API Signature be preserved? (no signature changes)
- Can the Public API Behavior be preserved? (no behavior changes)
- For Performance-lens findings, is a meaningful benchmark benefit expected?
- Does it avoid affecting Native Interop / P/Invoke marshalling?
- Does it maintain Tizen API Level 12+ compatibility? (when using new .NET APIs, confirm support per Tizen API Level)
→ Fails even one of these → discard (low ROI / high risk)
2-2. Grade Assignment
For items passing the gate, assign a grade using this matrix.
| Grade |
Condition |
Action |
| 🔴 Critical |
Performance lens + hot path + measurable numerical improvement expected, OR bug risk (async deadlock, missing IDisposable, NullReferenceException path) |
Discover ✓ prioritize PR |
| 🟡 Improvement |
Modernization / Clean Code / Coding Guidelines lens with clear readability/maintainability gains, OR a Performance improvement that is not on a hot path |
Discover ✓ |
| 🟢 Nice-to-have |
Style preference, plain naming taste, marginal theoretical improvement, weak lens match |
Exclude (do not register) |
Grade tie-breaking rules:
- If 🔴 Critical is claimed without measurable numerical evidence → downgrade to 🟡 Improvement
- Two or more overlapping lenses can promote the grade by one step
- e.g., Modernization only → 🟡, but Performance + Modernization → consider 🔴
- Bug risk accompanied (async deadlock, swallowed exception, missing dispose, etc.) → auto-🔴
- When in doubt, classify as 🟢 conservatively (exclude from discovery). Over-discovery is worse than under-discovery.
"Hot path" judgment guide:
- Rendering loops, event handlers, frequently called property getters/setters
- User interaction paths (touch/gesture/layout)
- Initialization paths are not hot paths (avoid applying performance criteria to one-shot code)
Stage ③: Draft Refactoring Application Plan
For items that pass, author a Markdown plan.
Required plan structure:
[Type: Refactoring]
[Scope: {scanned directory name, e.g., src/Tizen.NUI}]
[Priority: 🔴 Critical | 🟡 Improvement]
[Lens: Performance, Modernization, Clean Code, Coding Guidelines] (list all applicable lenses)
## Observation
{Describe the current state of the code and the problem pattern}
## Problem
{Why refactoring is needed — describe from each applicable lens's perspective}
## Proposed Improvement
{Concrete refactoring approach with Before/After code snippets}
### Target Files
- `{file path 1}`
- `{file path 2}`
## Expected Impact (Quantitative Metrics)
{**Required** for 🔴 Critical; write if possible for 🟡 Improvement}
- e.g., `allocation per call: 3 → 0`, `execution time: ~120ns → ~80ns`, `LOH allocations: eliminated`
- For non-Performance lenses: readability/complexity metrics (cyclomatic complexity, LOC, etc.)
## API Compatibility Check
- Public API signature change: none / {description}
- Behavior change: none / {description}
- Tizen API Level floor: {maintained / raise required — specify}
## Impact Scope
- Number of call sites for the modified symbol (measured via rg): `approx. N locations`
- Distinguish impact within the same assembly vs. other assemblies
- If >100 sites, recommend splitting the scope
Important:
- The top of the body must include
[Type: Refactoring], [Priority: ...], and [Lens: ...] so that the downstream agent (refactor-execute) can recognize the mode/priority.
- If 🔴 Critical has no quantitative metric in "Expected Impact", send it back to Stage ② for re-evaluation and downgrade to 🟡.
Stage ④: GitHub Issue Auto-Registration
Duplicate check (required before registration):
gh issue list --repo samsung/TizenFX --label "ai-task" --state open --json title,body --jq '.[] | .title + " " + .body'
→ Skip registration if an issue for the same file/pattern already exists
Issue registration:
gh issue create --repo samsung/TizenFX \
--title "[AI Refactoring] {finding name} [Scope: {directory}]" \
--body-file issue_plan.md \
--label "ai-task"
Constraints
- Create at most 5 issues per run (🔴 Critical first, then 🟡 Improvement)
- 🟢 Nice-to-have items are not registered (excluded at discovery)
- 🔴 Critical grade must include a quantitative metric (expected impact figures). Without one, downgrade to 🟡 or exclude.
- Scan priority: Performance > Modernization > Clean Code > Coding Guidelines (lens order)
- For items hitting multiple lenses, list all applicable lenses in
[Lens: ...] in the issue body
- Public API signature/behavior changes are forbidden (must pass the safety gate)
- Tizen API Level 12+ compatibility must be maintained
- Duplicate issues must not be registered (always verify existing issues before registering)
- Include the scanned directory and date in the issue title so scans can be traced
Reporting
- Scan info: directories scanned in this run, directories scheduled for the next run
- Grade distribution: 🔴 Critical N / 🟡 Improvement M (registered counts)
- Lens distribution: Performance X, Modernization Y, Clean Code Z, Coding Guidelines W (overlap counted)
- Created issue list: number, title, link, grade, lenses
- Discard summary:
- Safety gate failures: N (classified by reason: API signature / behavior / Tizen API Level / interop / negligible impact)
- 🟢 Nice-to-have classifications: M (brief reason)
- Anomalies: number of items that claimed 🔴 Critical but were downgraded to 🟡 due to missing quantitative metrics (if any)
Source: Samsung/TizenFX — distributed by TomeVault.
1---2name: refactor-analysis3description: Automatically scans the TizenFX codebase on a rotating schedule to discover .NET 8 / C# 12+ refactoring targets and register them as GitHub Issues. Use when this capability is needed.4---56## TizenFX Refactoring Target Discovery and Issue Registration Pipeline78### Overview9A pipeline that scans the TizenFX codebase for .NET 8 and C# 12+ modernization/optimization opportunities, drafts concrete application plans, and automatically registers them as GitHub Issues.10Each created issue explicitly states that it is a `refactoring` objective.1112### Repository13- **Repo**: samsung/TizenFX (GitHub)14- **CLI**: `gh` CLI (authenticated)1516---1718### Pipeline Flow1920```21① Auto-select target area and scan → ② Optimization feasibility analysis (Self-Reflection)22 → [Pass] ③ Draft refactoring application plan → ④ Auto-register GitHub Issue23 → [Reject] Discard (low ROI / high risk)24```2526---2728### Stage ①: Auto-select Target Area and Scan2930**Automatic directory rotation logic:**31Because the scan scope is broad, the scan area is automatically rotated on every run.32331. First run `gh repo clone samsung/TizenFX`, or `git pull` the existing clone to sync342. Collect the main namespace directories under `src/`:35 ```bash36 ls -d src/Tizen.*/37 ```383. Check which directories have already been analyzed by inspecting existing `ai-task` labeled issues:39 ```bash40 gh issue list --repo samsung/TizenFX --label "ai-task" --state all --json title --jq '.[].title' | grep -oP '\[Scope: [^\]]+\]'41 ```424. **Prioritize directories that have not yet been scanned**, but once every directory has been covered once, re-scan starting with the one scanned longest ago435. Scan only **1–2 directories per run** (to allow for in-depth analysis)4445**Scan Philosophy — 4 Evaluation Lenses (lens-based, not category-based)**4647Rather than "hunting" for a fixed list of patterns, **observe the code through 4 evaluation lenses**. A single finding may hit multiple lenses at once; the more it overlaps, the higher its grade.4849In priority order:5051#### 🚀 Lens 1: Performance (Highest Priority)52The most important lens. Target measurable performance improvements.53- **Reduce allocations**: `ToList/ToArray` in hot paths, `new` inside loops, boxing/unboxing, closure allocation (lambda capture)54- **Buffer handling**: opportunities to apply `Span<T>`/`Memory<T>`, `ArrayPool<T>`, `stackalloc` (small fixed size)55- **New .NET 8 types**: `FrozenDictionary`/`FrozenSet` (read-only lookup), `SearchValues<T>` (char search), `CollectionsMarshal`56- **Task optimization**: apply `ValueTask` (hot path), use `IAsyncEnumerable`, remove `.Result`/`.Wait()` (also prevents deadlocks)57- **LOH / GC pressure**: allocation patterns for arrays ≥85KB, short-lived large objects5859#### 🆕 Lens 2: .NET 8 / C# 12 Modernization60Modernize with the latest language and runtime features.61- **C# 12**: Collection expressions `[1, 2, ..x]`, primary constructors (class/struct), `ref readonly` parameters62- **C# 11**: `required` members, generic math, raw string literals `"""..."""`63- **C# 10~9**: file-scoped namespaces, `record struct`, switch expression, `init` accessor64- **.NET 8 APIs**: `ArgumentException.ThrowIfNull(x)`, `ArgumentOutOfRangeException.ThrowIfNegative`, `TimeProvider`65- **Nullable reference types**: introduce `#nullable enable`, ensure NRT consistency6667#### 🧹 Lens 3: Clean Code68Improve readability and maintainability (within internal/private scope).69- Eliminate duplication (DRY), extract common logic70- Split methods that violate single responsibility (one method doing too much)71- Reduce deep nesting / complexity (guard clauses, early return)72- Remove dead code, unused private members73- Improve naming — **limited to internal/private only** (public API renames forbidden)7475#### 📐 Lens 4: .NET Coding Guidelines76Adherence to official guidelines. Based on [Microsoft Design Guidelines](https://learn.microsoft.com/dotnet/standard/design-guidelines).77- async/await consistency: remove `.Result`, `.Wait()` (cause deadlocks)78- IDisposable pattern: `using` declaration, consistent propagation79- Exception handling: overly broad `catch (Exception)`, swallowed exceptions, mismatched exception types80- Naming conventions (public APIs are immutable; only internals are in scope)8182**Lens overlap → grade ↑**: if a finding hits both Performance and Modernization, it ranks higher than a single-lens finding (see Stage ②).8384**Quantitative heuristics** (to minimize subjective judgment):85- switch conversion candidates: 5+ `case` branches, each ≥ 3 lines86- allocation inside loops: `new` or LINQ chain inside `for/foreach`87- heavy methods: cyclomatic complexity ≥ 10, or ≥ 100 lines8889---9091### Stage ②: Optimization Feasibility Analysis and Grade Assignment9293#### 2-1. Safety Gate9495For each finding, self-verify against the following criteria:96971. Can the **Public API Signature** be preserved? (no signature changes)982. Can the **Public API Behavior** be preserved? (no behavior changes)993. For Performance-lens findings, is a meaningful benchmark benefit expected?1004. Does it avoid affecting **Native Interop / P/Invoke** marshalling?1015. Does it maintain **Tizen API Level 12+** compatibility? (when using new .NET APIs, confirm support per Tizen API Level)102103→ **Fails even one of these → discard** (low ROI / high risk)104105#### 2-2. Grade Assignment106107For items passing the gate, assign a grade using this matrix.108109| Grade | Condition | Action |110|---|---|---|111| 🔴 **Critical** | Performance lens + hot path + **measurable numerical improvement** expected, OR bug risk (async deadlock, missing IDisposable, NullReferenceException path) | Discover ✓ prioritize PR |112| 🟡 **Improvement** | Modernization / Clean Code / Coding Guidelines lens with clear readability/maintainability gains, OR a Performance improvement that is not on a hot path | Discover ✓ |113| 🟢 **Nice-to-have** | Style preference, plain naming taste, marginal theoretical improvement, weak lens match | **Exclude** (do not register) |114115**Grade tie-breaking rules:**116- If 🔴 Critical is claimed without measurable numerical evidence → **downgrade** to 🟡 Improvement117- **Two or more overlapping lenses** can promote the grade by one step118 - e.g., Modernization only → 🟡, but Performance + Modernization → consider 🔴119- **Bug risk** accompanied (async deadlock, swallowed exception, missing dispose, etc.) → **auto-🔴**120- When in doubt, classify as **🟢 conservatively** (exclude from discovery). Over-discovery is worse than under-discovery.121122**"Hot path" judgment guide:**123- Rendering loops, event handlers, frequently called property getters/setters124- User interaction paths (touch/gesture/layout)125- Initialization paths are *not* hot paths (avoid applying performance criteria to one-shot code)126127---128129### Stage ③: Draft Refactoring Application Plan130131For items that pass, author a Markdown plan.132133**Required plan structure:**134```markdown135[Type: Refactoring]136[Scope: {scanned directory name, e.g., src/Tizen.NUI}]137[Priority: 🔴 Critical | 🟡 Improvement]138[Lens: Performance, Modernization, Clean Code, Coding Guidelines] (list all applicable lenses)139140## Observation141{Describe the current state of the code and the problem pattern}142143## Problem144{Why refactoring is needed — describe from each applicable lens's perspective}145146## Proposed Improvement147{Concrete refactoring approach with Before/After code snippets}148149### Target Files150- `{file path 1}`151- `{file path 2}`152153## Expected Impact (Quantitative Metrics)154{**Required** for 🔴 Critical; write if possible for 🟡 Improvement}155- e.g., `allocation per call: 3 → 0`, `execution time: ~120ns → ~80ns`, `LOH allocations: eliminated`156- For non-Performance lenses: readability/complexity metrics (cyclomatic complexity, LOC, etc.)157158## API Compatibility Check159- Public API signature change: none / {description}160- Behavior change: none / {description}161- Tizen API Level floor: {maintained / raise required — specify}162163## Impact Scope164- Number of call sites for the modified symbol (measured via rg): `approx. N locations`165- Distinguish impact within the same assembly vs. other assemblies166- If >100 sites, recommend splitting the scope167```168169**Important:**170- The top of the body must include `[Type: Refactoring]`, `[Priority: ...]`, and `[Lens: ...]` so that the downstream agent (refactor-execute) can recognize the mode/priority.171- If 🔴 Critical has **no quantitative metric** in "Expected Impact", send it back to Stage ② for re-evaluation and downgrade to 🟡.172173---174175### Stage ④: GitHub Issue Auto-Registration176177**Duplicate check (required before registration):**178```bash179gh issue list --repo samsung/TizenFX --label "ai-task" --state open --json title,body --jq '.[] | .title + " " + .body'180```181→ Skip registration if an issue for the same file/pattern already exists182183**Issue registration:**184```bash185gh issue create --repo samsung/TizenFX \186 --title "[AI Refactoring] {finding name} [Scope: {directory}]" \187 --body-file issue_plan.md \188 --label "ai-task"189```190191---192193### Constraints194- Create at most **5** issues per run (🔴 Critical first, then 🟡 Improvement)195- 🟢 Nice-to-have items are **not registered** (excluded at discovery)196- 🔴 Critical grade **must include a quantitative metric** (expected impact figures). Without one, downgrade to 🟡 or exclude.197- Scan priority: **Performance > Modernization > Clean Code > Coding Guidelines** (lens order)198- For items hitting multiple lenses, **list all applicable lenses** in `[Lens: ...]` in the issue body199- Public API signature/behavior changes are forbidden (must pass the safety gate)200- Tizen API Level 12+ compatibility must be maintained201- Duplicate issues must not be registered (always verify existing issues before registering)202- Include the scanned directory and date in the issue title so scans can be traced203204### Reporting205- **Scan info**: directories scanned in this run, directories scheduled for the next run206- **Grade distribution**: 🔴 Critical N / 🟡 Improvement M (registered counts)207- **Lens distribution**: Performance X, Modernization Y, Clean Code Z, Coding Guidelines W (overlap counted)208- **Created issue list**: number, title, link, grade, lenses209- **Discard summary**:210 - Safety gate failures: N (classified by reason: API signature / behavior / Tizen API Level / interop / negligible impact)211 - 🟢 Nice-to-have classifications: M (brief reason)212- **Anomalies**: number of items that claimed 🔴 Critical but were downgraded to 🟡 due to missing quantitative metrics (if any)213214---215> Source: [Samsung/TizenFX](https://github.com/Samsung/TizenFX) — distributed by [TomeVault](https://tomevault.io).216<!-- tomevault:4.0:skill_md:2026-07-04 -->