Guidelines for implementing a new WinUI/WinRT API

Implementing a new WinUI/WinRT API generally requires to:

  • Find the generated API source file (e.g. src\Uno.UWP\Generated\\Windows.Data.Pdf\PdfDocument.cs)
  • Copy the file to the non-generated location (e.g. src\Uno.UWP\Data.Pdf\PdfDocument.cs)
  • Keep only the members that need to be implemented in the non-generated location
  • Remove (completely or partially depending on the platforms) the implemented members in the generated file

If your API implementation is for a specific platform:

  • You can use a platform suffix in the source file name (PdfDocument.Android.cs) so the file is built only for this platform
  • Remove the parts that relate to your platform in the NotImplemented attribute:
    #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
      [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
      public  global::Windows.Data.Pdf.PdfPageDimensions Dimensions
    #if false || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
      [global::Uno.NotImplemented("__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
      public  global::Windows.Data.Pdf.PdfPageDimensions Dimensions
    when implemented for Android only.

When implementing a feature, try to place as much code as possible in a common source file (a non-suffixed file), so that it is reused across platforms. Make sure to follow partial classes coding guidelines.

Note that the generated files may be overridden at any point, and placing custom code (aside from changing the NotImplemented values) will be overwritten.