@@ -17,8 +17,10 @@ Spice86 is a .NET 8 cross-platform emulator for reverse engineering real-mode DO
1717The entire emulator is assembled in ` Spice86DependencyInjection.cs ` (~ 600 lines):
1818- Constructor creates the full object graph with explicit dependencies (no IoC container)
1919- Order matters: components are constructed in dependency order
20- - Machine parts are wired together with event handlers and shared state
20+ - Components are wired together with event handlers and shared state
2121- Entry point is ` Program.cs ` which instantiates ` Spice86DependencyInjection `
22+ - ** ` Spice86DependencyInjection ` is the central composition root** - understand its structure when working with dependencies
23+ - The ` Machine ` class is less important - focus on ` Spice86DependencyInjection ` for understanding component relationships
2224
2325### CPU Execution Models
2426Two CPU implementations coexist via ` IInstructionExecutor ` :
@@ -121,7 +123,7 @@ Variants: `MemoryBasedDataStructureWithCsBaseAddress`, `MemoryBasedDataStructure
121123 // Correct
122124 int count = 10 ;
123125 ```
124- - ** No generic catch clauses** : Catch specific exceptions
126+ - ** No generic catch clauses** : Catch specific exceptions only
125127 ``` csharp
126128 // Wrong
127129 try {
@@ -135,12 +137,27 @@ Variants: `MemoryBasedDataStructureWithCsBaseAddress`, `MemoryBasedDataStructure
135137 // code
136138 } catch (IOException ex ) {
137139 // handling
140+ } catch (ArgumentException ex ) {
141+ // handling
142+ }
143+ ```
144+ - ** NEVER use generic ` catch (Exception) ` or empty ` catch ` **
145+ - Each exception type must be caught explicitly
146+
147+ - ** No null-forgiving operator (!)** : The null-forgiving operator is ** BANNED**
148+ ``` csharp
149+ // Wrong - NEVER use !
150+ string value = nullable ! .ToString ();
151+
152+ // Correct
153+ if (nullable != null ) {
154+ string value = nullable .ToString ();
138155 }
156+ // Or
157+ string value = nullable ? .ToString () ?? " default" ;
139158 ```
140- - ** No bad practices with null, bangs (!), or ignored errors** :
141- - Avoid null-forgiving operator (!) unless absolutely necessary
142- - Don't ignore nullable warnings
143- - Properly handle null cases with null checks or null-coalescing operators
159+ - Properly handle null cases with null checks, null-coalescing, or null-conditional operators
160+ - Don't ignore nullable warnings - fix the underlying issue
144161- ** Async usage restrictions** :
145162 - ** Do NOT let async "infect" the ` Spice86.Core ` assembly**
146163 - Keep async code in the UI layer (` Spice86 ` project) only
@@ -158,6 +175,9 @@ Variants: `MemoryBasedDataStructureWithCsBaseAddress`, `MemoryBasedDataStructure
158175 ```
159176- ** Nullable** : Enabled project-wide with ` <WarningsAsErrors>nullable</WarningsAsErrors> `
160177- ** Documentation** : XML comments required (` <GenerateDocumentationFile>true</GenerateDocumentationFile> ` )
178+ - ** No stub implementations** : Create proper real implementations
179+ - Stubs that return hardcoded values or do nothing are not allowed
180+ - magic values are not allowed, define enums or consts with clear names
161181
162182### Testing Patterns
163183- ** Prefer ASM-based tests over unit tests** for testing the emulator
0 commit comments