Vixen
02b45cc4
csharp
public static class DesktopSupplements

Choosing the per-OS supplement for the machine this is running on.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

The dependency points this way round on purpose. Vixen.Platform.Windows, .Linux and .MacOS reference the contracts and nothing else; this assembly references all three and picks one. The alternative — each per-OS assembly registering itself when it loads — reads better and does not work: .NET loads an assembly when something first calls into it, so a module initialiser in an assembly nobody has called into yet has not run, and the registration would depend on whether anything else happened to touch it first.

What it costs a build that will only ever run on one of them. A framework-dependent or portable publish carries all three assemblies, which together are a few tens of kilobytes of IL. A RID-specific publish carries one: OperatingSystem.IsWindows() and its neighbours are substituted with constants by the trimmer when the target platform is known, so the other two branches — and everything only they reach — are removed.

Methods (1)

  • public static IPlatformSupplement? ForCurrentOperatingSystem()

    The supplement for this operating system, or on one that has none.

Used by (2)

  • DesktopPlatformVixen.Platform.Desktop
  • DesktopSupplementTestsVixen.Platform.Desktop.Tests