refactor(rules): keep WPF index focused
This commit is contained in:
1 parent
c91505a568
commit
ca9f6296d6
3 files changed
+14
-32
No files matched your search
+10
-32
@@ -1,34 +1,12 @@
|
|||||||
# WPF Code Guidelines
|
# WPF Rules
|
||||||
|
|
||||||
* Use modern C# and current .NET/WPF conventions.
|
For WPF, XAML, or MVVM work, open only the focused topic rules relevant to the change.
|
||||||
* Keep UI, application logic and domain logic clearly separated.
|
|
||||||
* Prefer MVVM for non-trivial views.
|
|
||||||
* Keep code-behind minimal.
|
|
||||||
* Use code-behind only for view-specific behavior that does not belong in the ViewModel.
|
|
||||||
* Avoid business logic in views.
|
|
||||||
* Avoid direct service access from controls.
|
|
||||||
* Keep dependencies explicit and testable.
|
|
||||||
* Prefer composition over inheritance.
|
|
||||||
* Avoid unnecessary abstractions and framework wrappers.
|
|
||||||
* Follow the existing project architecture unless there is a strong reason to change it.
|
|
||||||
|
|
||||||
## Safety Rule
|
| Topic | Codex rule | Claude skill |
|
||||||
|
| --- | --- | --- |
|
||||||
* The UI must remain responsive.
|
| MVVM and binding | `references/mvvm-and-binding.md` | `rules-wpf-mvvm-and-binding` |
|
||||||
* Do not block the UI thread with I/O or expensive CPU work.
|
| Commands, async, and threading | `references/commands-and-async.md` | `rules-wpf-commands-and-async` |
|
||||||
* Do not bypass validation or security controls for convenience.
|
| Collections and XAML | `references/collections-and-xaml.md` | `rules-wpf-collections-and-xaml` |
|
||||||
* Do not introduce hidden cross-thread access.
|
| Resources and lifecycle | `references/resources-and-lifecycle.md` | `rules-wpf-resources-and-lifecycle` |
|
||||||
* Prefer predictable, explicit and testable UI behavior.
|
| Security and errors | `references/security-and-errors.md` | `rules-wpf-security-and-errors` |
|
||||||
|
| Architecture, testing, and performance | `references/architecture-and-quality.md` | `rules-wpf-architecture-and-quality` |
|
||||||
## Detailed guidance
|
|
||||||
|
|
||||||
Read the matching reference file before working in that area:
|
|
||||||
|
|
||||||
| Read this reference for... | ...this kind of work |
|
|
||||||
| --- | --- |
|
|
||||||
| `references/mvvm-and-binding.md` | MVVM, data binding, property change notifications, dependency/attached properties |
|
|
||||||
| `references/commands-and-async.md` | Commands, async/threading, UI-thread work, events |
|
|
||||||
| `references/collections-and-xaml.md` | Collections, virtualization, layout, XAML |
|
|
||||||
| `references/resources-and-lifecycle.md` | Resources/styles, windows/dialogs, navigation, memory, images/media |
|
|
||||||
| `references/security-and-errors.md` | Security, file/process access, error handling, logging, validation |
|
|
||||||
| `references/architecture-and-quality.md` | Architecture, DI, testing, code quality, performance |
|
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
## Architecture
|
## Architecture
|
||||||
|
|
||||||
|
* Use modern C# and current WPF conventions. Prefer MVVM for non-trivial views and keep code-behind limited to view-specific behavior.
|
||||||
|
* Keep UI, application, and domain logic separate. Avoid business logic in views and direct service access from controls.
|
||||||
|
* Keep dependencies explicit and testable; prefer composition over inheritance and avoid unnecessary abstractions or framework wrappers.
|
||||||
* Keep presentation, application, domain and infrastructure concerns separated.
|
* Keep presentation, application, domain and infrastructure concerns separated.
|
||||||
* Avoid direct database access from views or ViewModels.
|
* Avoid direct database access from views or ViewModels.
|
||||||
* Avoid direct HTTP access from controls.
|
* Avoid direct HTTP access from controls.
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
## UI Thread
|
## UI Thread
|
||||||
|
|
||||||
* Treat the UI thread as a scarce resource.
|
* Treat the UI thread as a scarce resource.
|
||||||
|
* Keep the interface responsive and do not block the UI thread with I/O or expensive CPU work. Move CPU work off-thread only when needed and marshal UI changes back explicitly.
|
||||||
* Avoid expensive loops, parsing, serialization, database access or network calls on the UI thread.
|
* Avoid expensive loops, parsing, serialization, database access or network calls on the UI thread.
|
||||||
* Avoid excessive Dispatcher invocations.
|
* Avoid excessive Dispatcher invocations.
|
||||||
* Batch UI updates where practical.
|
* Batch UI updates where practical.
|
||||||
|
|||||||
Reference in new issue
Block a user