4.4 KiB
4.4 KiB
sessionId
| 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.csto load the galaxy map background image stream via the MAUI GraphicsPlatformImage.FromStream(buffer)factory instead of the invalid two-parameter constructorPlatformImage(ICanvasResourceCreator, CanvasBitmap). - Resolve
CS8604nullability warnings inZeroSpace.MapEditor/Views/MapEditorPage.xaml.csforPopulateInspectorcalls. - 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.MapEditorand the entireZeroSpace.slnsolution to build cleanly without compile errors so that the Map Editor and all companion projects can be built, debugged, and run reliably.
Functional Requirements
- PlatformImage Factory:
MapBackground.LoadAsync()must use the platform-compatible image stream loader (Microsoft.Maui.Graphics.Platform.PlatformImage.FromStream(buffer)) returningIImage?. - Graceful Exception Fallback: Maintain existing
try-catchexception handling so the editor runs cleanly even if the background asset cannot be loaded or is absent. - Null-Safety in MapEditorPage: Ensure
PopulateInspector(MapNode node)receives a guaranteed non-nullMapNodereference across all selection and marquee interaction paths.
Technical Design
Current Implementation
ZeroSpace.MapEditor/Services/MapBackground.csattemptsnew Microsoft.Maui.Graphics.Platform.PlatformImage(buffer)which fails withCS7036: 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),PlatformImageinstances from byte streams are instantiated viaPlatformImage.FromStream(Stream stream, ImageFormat format = ImageFormat.Png)orPlatformImageService.Instance.FromStream(stream). MapEditorPage.xaml.cshas 3 occurrences ofCS8604possible null reference arguments where_selectedis passed toPopulateInspector(MapNode node)right afterSetActiveNode(_pressNode)or in multi-node selection resolution.
Key Decisions
- Use
PlatformImage.FromStreamFactory:- Chosen Approach: Replace direct
new PlatformImage(buffer)constructor calls withMicrosoft.Maui.Graphics.Platform.PlatformImage.FromStream(buffer). - Rationale:
PlatformImage.FromStreamis the standard cross-platform MAUI Graphics factory method for creatingIImageinstances from stream buffers on Windows and MacCatalyst.
- Chosen Approach: Replace direct
- Explicit Non-Null Variable Passing in
MapEditorPage:- Chosen Approach: Pass
_pressNodeor computed non-nullactivenode directly toPopulateInspector(node). - Rationale: Eliminates nullable warnings cleanly without suppressing diagnostics or adding runtime overhead.
- Chosen Approach: Pass
Proposed Changes
ZeroSpace.MapEditor/Services/MapBackground.cs:- Replace
new Microsoft.Maui.Graphics.Platform.PlatformImage(buffer)withMicrosoft.Maui.Graphics.Platform.PlatformImage.FromStream(buffer).
- Replace
ZeroSpace.MapEditor/Views/MapEditorPage.xaml.cs:- Pass
_pressNodein selection click handlers and pass local non-nullactivenode in multi-select resolution before callingPopulateInspector.
- Pass
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.slnto verify all projects compile with 0 errors. - Verify
ZeroSpace.MapEditor.csprojcompiles cleanly fornet10.0-windows10.0.19041.0.
Key Scenarios
- MapBackground Image Stream Loading: Confirm
MapBackground.LoadAsync()builds cleanly withPlatformImage.FromStream. - Full Solution Compilation: Confirm
ZeroSpace.slncompletes with 0 errors and 0 blocking warnings.