-
Notifications
You must be signed in to change notification settings - Fork 46
SoftwareOSIndependence
DavidFreely edited this page Nov 7, 2025
·
27 revisions
Problem
- UI (***):
- WPF: The user interface (desktop-user-interface-library from WindowsOS)
- API (*):
- WinForms / Microsoft.Win32 / Windows‑APIs: OpenFileDialog, MessageBox, Microsoft.Win32, etc.
- P/Invoke to Kernel32.dll:
- Utils.cs declares DllImport("Kernel32.dll") GetSystemTimePreciseAsFileTime <- Works only on Windows.
- Process.Start
- System.Drawing.Bitmap requires native
libgdipluslibrary on Linux/macOS <- Which is subject to limitations.
- Registry‑Accesses
- Shell‑Conventions
- Paths:
- Hard-coded path/path separator assumptions and backslashes (e.g., sys.path.append(os.getcwd() + "\pythonModules")) <- Windows-centric.
- Hard-coded Windows programs/paths (e.g., the Visual Studio path used to open files)."
- Python interop (pythonnet): code sets Runtime.PythonDLL to e.g. @"python310" <— library names differ on Linux/macOS (e.g., libpython3.x.so / .dylib).
Needed for OS independence
- UI switch
- (Avalonia, .NET MAUI, tkinter, ..)
- Platform‑abstractions:
- Cross-platform .NET APIs: like
Stopwatch.GetTimestamp()instead ofGetSystemTimePreciseAsFileTime. -
Path.CombineorPath.PathSeparatorinstead of backslashes.
- Cross-platform .NET APIs: like
- /Platform-conditionalizing:
- conditional compilation and RuntimeInformation to gate Windows‑specific code:
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { /* win-only */ }
- conditional compilation and RuntimeInformation to gate Windows‑specific code:
- WINE (https://www.winehq.org/) for Linux/MacOS
- (no documentation about it for BS3 yet, your help writing the article is welcome)