Skip to content

Feature: VFP Headless Runtime and UI Provider Architecture#1841

Merged
RobertvanderHulst merged 2 commits intodevfrom
feature/vfp-ui-provider
Mar 7, 2026
Merged

Feature: VFP Headless Runtime and UI Provider Architecture#1841
RobertvanderHulst merged 2 commits intodevfrom
feature/vfp-ui-provider

Conversation

@Irwin1985
Copy link
Contributor

Summary

In this PR I did an important refactor in the XSharp.VFP. The main idea is to make the core runtime headless so I removed the direct dependencies to System.Windows.Forms and System.Drawing and moved anything UI-related behind a provider.

With this, the VFP dialect can run safer in server/non-desktop scenarios (ASP.NET Core, services, Linux/Docker) without hanging threads or crashing because UI stuff is not available.

What changed

1) Core runtime is now UI-free (XSharp.VFP.dll)

  • Added an IVfpUIProvider interface with the methods we need for UI-related (there are more) VFP features.
  • Implemented VfpUIService (service locator). It tries (via reflection) to load XSharp.VFP.UI.dll and create the provider automatically at runtime.
    • If the UI assembly is not there, it falls back to headless provider.
  • HeadlessUIProvider: fallback provider that writes things like MESSAGEBOX / ASSERT to System.Console (so it works in headless/server apps and doesn't block waiting for a dialog).
  • Removed all references to WinForms/Drawing from the core runtime, so is platform-agnostic now.
  • Refactores these to delegate to the provider:
    • MESSAGEBOX(), SYSMETRIC(), ASSERT, GETCOLOR(), GETFONT(), APRINTERS()

2) UI implementation moved to XSharp.VFP.UI

  • All WinForms-specific code lives here now (AutoCloseMessageBox, AssertDialog)
  • VfpUIProvider is the Windows provider that implements IVfpUIProvider using desktop APIs.
  • Isolated Win32 helpers (User32) inside this UI assembly (VfpWin32UI) to keep the core runtime clean.

3) How I tested this

Testes with a FoxPro-dialect Console app in XIDE:

  • UI mode: with XSharp.VFP.UI.dll present, dialogs/metrics work normally.
  • Headless mode: If I remove/rename the XSharp.VFP.UI.dll the fallback kicks in and the app keeps running and doesn't block.

@RobertvanderHulst
Copy link
Member

Nice work. Maybe you can also detect if the app is running in console mode, before even trying to load XSharp.VFP.UI.DLL? Maybe check if System.Windows.Forms .dll is loaded?

@RobertvanderHulst RobertvanderHulst merged commit 3ccc381 into dev Mar 7, 2026
1 check passed
@RobertvanderHulst RobertvanderHulst deleted the feature/vfp-ui-provider branch March 7, 2026 12:18
@Irwin1985
Copy link
Contributor Author

Nice work. Maybe you can also detect if the app is running in console mode, before even trying to load XSharp.VFP.UI.DLL? Maybe check if System.Windows.Forms .dll is loaded?

Oh good that one. I'll do it.

Thanks Robert.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants