Thanks for the detailed follow-up @bryhutson, and for spelling out the shared-code scenario so clearly.
Two updates:
Web ContainerControls are now formally on the roadmap. I've logged the feature here: https://feedback.objo.dev/feature/1702. I'll be upfront that this is a significant addition: a reusable web container touches the responsive designer, the browser client and the runtime, so it needs careful planning rather than a quick patch. I do intend to build it, but I can't put a date on it yet.
Better conditional compilation is coming soon. I've also created a feature issue to add compiler-defined target symbols to conditional compilation: https://feedback.objo.dev/feature/1704. You'll be able to write @If TargetDesktop Then or @If TargetWeb Then, and each project's build will automatically select the right branch. That is a much smaller change, so it should reach you well before Web ContainerControls do.
You can work around this today with the conditional compilation Objo already has. @If conditions can read compile-time Const values, and each project compiles your shared code together with its own sources. So the trick is a tiny module in each project, never in Shared Code:
Desktop project:
Module PlatformConfig
Const IS_WEB As Boolean = False
End Module
Web project (same module name, opposite value):
Module PlatformConfig
Const IS_WEB As Boolean = True
End Module
Then guard the desktop-only parts of your shared code:
Sub InspectChildren(container As Control)
If container IsA GroupBox Then
InspectGroupBox(GroupBox(container))
ElseIf container IsA TabPanel Then
InspectTabPanel(TabPanel(container))
@If Not PlatformConfig.IS_WEB Then
ElseIf container IsA ContainerControl Then
InspectContainerControl(ContainerControl(container))
@EndIf
End If
End Sub
When the Web project builds, the inactive @If branch is stripped out before the compiler ever sees it, so ContainerControl is never name-resolved and the unknown-superclass error goes away. The Desktop build compiles it as normal. Two caveats worth knowing:
- The constant module has to live in each project. A constant in Shared Code has the same value in every build, which defeats the point.
- An inactive branch is not compiled at all, so it receives no warnings or errors either; a mistake in the desktop-only branch only surfaces when the Desktop project builds.
The full directive syntax, including the operators conditions support, is documented here: https://docs.objo.dev/#/conditional-compilation