--- sessionId: session-260928-131223-1ueu --- # Requirements ### Overview & Goals Resolve the compilation error `CS7036` on `PlatformImage` in `ZeroSpace.MapEditor/Services/MapBackground.cs` and resolve compiler nullability warnings in `MapEditorPage.xaml.cs`, ensuring `ZeroSpace.MapEditor` and the entire solution (`ZeroSpace.sln`) compile cleanly with zero errors. ### Scope #### In Scope - Update `ZeroSpace.MapEditor/Services/MapBackground.cs` to load the galaxy map background image stream via the MAUI Graphics `PlatformImage.FromStream(buffer)` factory instead of the invalid two-parameter constructor `PlatformImage(ICanvasResourceCreator, CanvasBitmap)`. - Resolve `CS8604` nullability warnings in `ZeroSpace.MapEditor/Views/MapEditorPage.xaml.cs` for `PopulateInspector` calls. - Verify end-to-end solution build (`dotnet build ZeroSpace\ZeroSpace.sln`) with 0 errors across all projects. #### Out of Scope - Redesigning MapEditor UI layouts or modifying StarSystem data structures. - Altering web pages in `ZeroSpace.Web`. ### User Stories - **As a developer**, I want `ZeroSpace.MapEditor` and the entire `ZeroSpace.sln` solution to build cleanly without compile errors so that the Map Editor and all companion projects can be built, debugged, and run reliably. ### Functional Requirements 1. **PlatformImage Factory**: `MapBackground.LoadAsync()` must use the platform-compatible image stream loader (`Microsoft.Maui.Graphics.Platform.PlatformImage.FromStream(buffer)`) returning `IImage?`. 2. **Graceful Exception Fallback**: Maintain existing `try-catch` exception handling so the editor runs cleanly even if the background asset cannot be loaded or is absent. 3. **Null-Safety in MapEditorPage**: Ensure `PopulateInspector(MapNode node)` receives a guaranteed non-null `MapNode` reference across all selection and marquee interaction paths. --- # Technical Design ### Current Implementation - `ZeroSpace.MapEditor/Services/MapBackground.cs` attempts `new Microsoft.Maui.Graphics.Platform.PlatformImage(buffer)` which fails with `CS7036: There is no argument given that corresponds to the required parameter 'bitmap' of 'PlatformImage.PlatformImage(ICanvasResourceCreator, CanvasBitmap)'`. - In `Microsoft.Maui.Graphics.Platform` (.NET 10 / Windows App SDK / Win2D), `PlatformImage` instances from byte streams are instantiated via `PlatformImage.FromStream(Stream stream, ImageFormat format = ImageFormat.Png)` or `PlatformImageService.Instance.FromStream(stream)`. - `MapEditorPage.xaml.cs` has 3 occurrences of `CS8604` possible null reference arguments where `_selected` is passed to `PopulateInspector(MapNode node)` right after `SetActiveNode(_pressNode)` or in multi-node selection resolution. ### Key Decisions 1. **Use `PlatformImage.FromStream` Factory**: - *Chosen Approach*: Replace direct `new PlatformImage(buffer)` constructor calls with `Microsoft.Maui.Graphics.Platform.PlatformImage.FromStream(buffer)`. - *Rationale*: `PlatformImage.FromStream` is the standard cross-platform MAUI Graphics factory method for creating `IImage` instances from stream buffers on Windows and MacCatalyst. 2. **Explicit Non-Null Variable Passing in `MapEditorPage`**: - *Chosen Approach*: Pass `_pressNode` or computed non-null `active` node directly to `PopulateInspector(node)`. - *Rationale*: Eliminates nullable warnings cleanly without suppressing diagnostics or adding runtime overhead. ### Proposed Changes 1. `ZeroSpace.MapEditor/Services/MapBackground.cs`: - Replace `new Microsoft.Maui.Graphics.Platform.PlatformImage(buffer)` with `Microsoft.Maui.Graphics.Platform.PlatformImage.FromStream(buffer)`. 2. `ZeroSpace.MapEditor/Views/MapEditorPage.xaml.cs`: - Pass `_pressNode` in selection click handlers and pass local non-null `active` node in multi-select resolution before calling `PopulateInspector`. ### File Structure - `ZeroSpace/ZeroSpace.MapEditor/Services/MapBackground.cs` (Modified) - `ZeroSpace/ZeroSpace.MapEditor/Views/MapEditorPage.xaml.cs` (Modified) --- # Testing ### Validation Approach - Execute `dotnet build ZeroSpace\ZeroSpace.sln` to verify all projects compile with 0 errors. - Verify `ZeroSpace.MapEditor.csproj` compiles cleanly for `net10.0-windows10.0.19041.0`. ### Key Scenarios 1. **MapBackground Image Stream Loading**: Confirm `MapBackground.LoadAsync()` builds cleanly with `PlatformImage.FromStream`. 2. **Full Solution Compilation**: Confirm `ZeroSpace.sln` completes with 0 errors and 0 blocking warnings. ---