This repository was archived by the owner on Apr 10, 2026. It is now read-only.
Improve multiple platform support#48
Merged
Jack251970 merged 8 commits intomasterfrom Nov 15, 2025
Merged
Conversation
Refactored the `Open` method to improve error handling and maintainability. Wrapped platform-specific logic in a `try-catch` block to handle exceptions and added logging via `EditorLogger.Error` for better debugging. Introduced a `PlatformNotSupportedException` for unsupported OS cases. Reorganized code for clarity and removed redundant logic.
Enhanced OS and .NET runtime detection to support non-Windows platforms: - Added `GetFullVersion()` for cross-platform OS version reporting. - Replaced `GetFrameworkVersionFromRegistry()` with `GetFrameworkVersion()`. - Introduced CLI and disk-based runtime enumeration for non-Windows. - Improved error handling and logging for runtime/OS detection. Refactored code for readability using regions and helper methods. Updated exception formatting to use new cross-platform methods.
The `ApplicationFileName` constant, which held the value `"Editor.exe"`, was removed from the `Constants` class in the `Editor` namespace. This change was likely made to eliminate unused or redundant code or to refactor how the application file name is managed elsewhere in the codebase.
Updated FontFactory to use platform-specific font families:
- Added `System.Runtime.InteropServices` for platform checks.
- macOS: Fallback to "Helvetica, Arial, sans-serif".
- Linux: Fallback to "Noto Sans, DejaVu Sans, sans-serif".
- Windows: Fallback to "Segoe UI, Arial, sans-serif".
Replaced the default fallback ("Segoe UI") with platform-specific logic.
Added a final fallback to `FontFamily.Default`.
Replaced the hardcoded fallback font `"Segoe UI"` with `FontFamily.Default` in the `FontFactory` class. This change ensures the use of a predefined default font family, improving maintainability and consistency across the application.
Replaced hardcoded roaming data path with a platform-specific method (`GetDefaultDataHome`) to dynamically determine the default data directory based on the operating system. Added caching for `PortableDataLocationInUse` to improve performance and avoid redundant checks. Enhanced error handling and logging for portable data location checks. Introduced `IsDirectoryWritable` to verify directory writability with robust fallback mechanisms. Updated `SettingsDirectory` to a property for dynamic path resolution. Improved overall maintainability and platform compatibility.
Refactored `ClipboardHelper` to introduce platform-specific clipboard handling, supporting both Windows (`ClipboardAvalonia`) and non-Windows platforms (`IClipboard`). Updated methods like `CanPasteFromClipboard` and `SetClipboard` to use asynchronous operations for improved responsiveness. Added `TopLevel` parameter to `StartMonitoring` to tie clipboard operations to the application's top-level window. Enhanced clipboard data handling to support custom XML formats and plain text. Introduced constants for clipboard format consistency. Improved error handling, logging, and null checks to ensure stability. Removed legacy synchronous clipboard handling code. Updated `App.axaml.cs` to pass `TopLevel` to `ClipboardHelper` for proper initialization.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request introduces comprehensive cross-platform support improvements for Windows, macOS, and Linux. The changes enable the application to run reliably across different operating systems by implementing platform-specific handling for clipboard operations, data directory management, font selection, and exception reporting.
Key changes:
- Refactored clipboard operations to use platform-specific APIs (ClipboardAvalonia for Windows, Avalonia's IClipboard for other platforms)
- Implemented OS-aware data directory resolution following platform conventions (AppData on Windows, XDG on Linux, Application Support on macOS)
- Enhanced exception reporting with cross-platform OS version detection and .NET runtime enumeration
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 19 comments.
Show a summary per file
| File | Description |
|---|---|
| Editor/Helper/FontFactory.cs | Adds platform-specific default font families for macOS, Linux, and Windows |
| Editor/Helper/ExceptionFormatter.cs | Implements cross-platform OS version detection and .NET runtime discovery for non-Windows systems |
| Editor/Helper/ClipboardHelper.cs | Refactors clipboard handling to support both Windows (ClipboardAvalonia) and non-Windows (Avalonia IClipboard) platforms |
| Editor/Helper/BrowserHelper.cs | Adds error logging for browser opening failures across platforms |
| Editor/Extensions/DataLocation.cs | Implements platform-aware data directory resolution with caching and writability checks |
| Editor/Constants.cs | Removes unused ApplicationFileName constant |
| Editor/App.axaml.cs | Adds TopLevel parameter for clipboard monitoring initialization |
| Editor.slnx | Reorganizes solution file structure |
| .github/workflows/build.yml | Adds multi-platform CI/CD support with matrix strategy for Windows, Ubuntu, and macOS |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several improvements and refactors across the codebase to enhance cross-platform compatibility, especially for clipboard and data directory handling, as well as error handling and exception reporting. The most significant changes are grouped below.
Cross-platform clipboard and data handling:
ClipboardHelperto support both Windows and non-Windows platforms by using platform-specific clipboard APIs (ClipboardAvaloniafor Windows, Avalonia'sIClipboardfor others). The monitoring and paste logic now adapts to the underlying OS, improving reliability and user experience across platforms. ([[1]](https://github.com/Jack251970/Math-Editor/pull/48/files#diff-b1575595a439c78421141a464b06393756e3f9643303351fcf0f11037672c09cR2-R9),[[2]](https://github.com/Jack251970/Math-Editor/pull/48/files#diff-b1575595a439c78421141a464b06393756e3f9643303351fcf0f11037672c09cR22-R30),[[3]](https://github.com/Jack251970/Math-Editor/pull/48/files#diff-b1575595a439c78421141a464b06393756e3f9643303351fcf0f11037672c09cR50-R58),[[4]](https://github.com/Jack251970/Math-Editor/pull/48/files#diff-b1575595a439c78421141a464b06393756e3f9643303351fcf0f11037672c09cL62-R76),[[5]](https://github.com/Jack251970/Math-Editor/pull/48/files#diff-b1575595a439c78421141a464b06393756e3f9643303351fcf0f11037672c09cL76-R139),[[6]](https://github.com/Jack251970/Math-Editor/pull/48/files#diff-b1575595a439c78421141a464b06393756e3f9643303351fcf0f11037672c09cR157-L124),[[7]](https://github.com/Jack251970/Math-Editor/pull/48/files#diff-b1575595a439c78421141a464b06393756e3f9643303351fcf0f11037672c09cR169-R192),[[8]](https://github.com/Jack251970/Math-Editor/pull/48/files#diff-476d31742b86307aa01ea1e3b11f708de0c4316553fc50bddd9f523d1d873de0R119),[[9]](https://github.com/Jack251970/Math-Editor/pull/48/files#diff-476d31742b86307aa01ea1e3b11f708de0c4316553fc50bddd9f523d1d873de0L141-R142))DataLocationto robustly determine the application data directory based on the operating system, supporting Windows, macOS, and Linux (using XDG_CONFIG_HOME or.config). Added error handling, caching, and directory writability checks for portable mode. ([Editor/Extensions/DataLocation.csR3-R128](https://github.com/Jack251970/Math-Editor/pull/48/files#diff-aad771c1289d5376c6449731794b067481c5bfbb594076cec17f6f63c6dbe9fdR3-R128))Exception handling and reporting:
ExceptionFormatterto provide detailed OS and .NET runtime information on all platforms, including attempts to enumerate installed .NET runtimes on non-Windows systems. Enhanced error handling to avoid crashes during report generation. ([[1]](https://github.com/Jack251970/Math-Editor/pull/48/files#diff-63e6e9e23642cae8294a0745122bb57454f0fff7077a41526e70e1b3f9352199R3-R18),[[2]](https://github.com/Jack251970/Math-Editor/pull/48/files#diff-63e6e9e23642cae8294a0745122bb57454f0fff7077a41526e70e1b3f9352199L64-R76),[[3]](https://github.com/Jack251970/Math-Editor/pull/48/files#diff-63e6e9e23642cae8294a0745122bb57454f0fff7077a41526e70e1b3f9352199R110-R159))[Editor.Desktop/Program.csL45-R52](https://github.com/Jack251970/Math-Editor/pull/48/files#diff-92dd97a4ce599f5f0d868a7f0a356b4824731b96c04951958e379a9f161189e0L45-R52))General robustness and logging:
BrowserHelperto capture failures when opening URLs in the default browser, improving diagnostics. ([[1]](https://github.com/Jack251970/Math-Editor/pull/48/files#diff-0d3efe8ec8e2b00df8642f92f5bb044b4533fba00bfc86812c7f4c8d037f43eaR9-R17),[[2]](https://github.com/Jack251970/Math-Editor/pull/48/files#diff-0d3efe8ec8e2b00df8642f92f5bb044b4533fba00bfc86812c7f4c8d037f43eaR44-R48))ApplicationFileNameconstant. ([Editor/Constants.csL11](https://github.com/Jack251970/Math-Editor/pull/48/files#diff-8bd1b02b9d887f27bb6e1aa3133f52e3d737db89e2369fa9c60f023d8da0ec1aL11))Resolve #21.