Junocaen / Pharmacist

Builds observables from events.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom Reactui.Events

The ReactiveUI.Events nuget package is not build for modern uwp application since it is stuc on UAP v10.0.16299. ReactiveUI.Events is nothing more then running the Pharmacist.Console application and serve it in an SKD version.

Generate Event wrapper file with Pharmacist.Console

Pharmacist (Github) does not support a TargetFramework, only hardcoded. This version changed the hardcoded version of 10.0.16299 to 10.0.18362.

To run the Pharmacist.Console tool go to the root of this project and enter this command:

PS F:\dev\ReactiveUiEvents4UAP\Pharmacist\Pharmacist\src\Pharmacist.Console> dotnet run generate-platform --platforms=uwp --output-path="F:/dev/ReactiveUiEvents4UAP/Pharmacist/Generated_Events_CS/" --output-prefix="Events_"

Edit Framework version yourself

Change the version src/Pharmacist.Core/Extractors/PlatformExtractors/UWP.cs for uwp. When editing this, make sure the version is supported in the NuGetFrameworkHelper src/Pharmacist.Core/NuGet/NuGetFrameworkHelper.cs

Add the SDKReferences when using ReactiveUI.Events (uwp) or the Pharmacist generated file

ReactiveUI.Events does not add the neccesarry skd reverences (neither the Pharmacist generated files). Pharmacist generate wrappers of everything in the C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.18362.0\Windows.winmd, so also the Extension SDKs in C:\Program Files (x86)\Windows Kits\10\Extension SDKs. To prevent weird errors, add atlease the following Univeral Windows Extentions (according to the .csproj of ReactiveUI.Events):

  • WindowsDesktop
  • WindowsMobile

To to this either add this to your .csproj

  <ItemGroup>
    <SDKReference Include="WindowsDesktop, Version=10.0.18362.0">
      <Name>Windows Desktop Extensions for the UWP</Name>
    </SDKReference>
    <SDKReference Include="WindowsMobile, Version=10.0.18362.0">
      <Name>Windows Mobile Extensions for the UWP</Name>
    </SDKReference>
  </ItemGroup>

or go in Visual Studio to your project -> righ click on References -> "Add reference..." -> Univeral Windows -> Extentions -> select WindowsMobile and WindowsDesktop with the correct version.

Add the Events_uwp.cs file to your uwp project file

Just use it where ever you like

Build Status Code Coverage

Pharmacist

Builds observables from events.

NuGet Packages

Install the following packages to start using Pharmacist.

Name Platform NuGet
Pharmacist.Core Core - Libary CoreBadge
Pharmacist Global Tool GlobalToolBadge
Pharmacist.MSBuild MSBuild Task MsBuildBadge
Pharmacist.Common Common CommonBadge

What does it do?

Pharmacist will convert events within an assembly and create observable wrappers for them.

It has been called pharmacist since it will generate Reactive Extensions (Rx) Observables for events, so it's a play on word about "Rx" which is short for prescriptions.

It can generate the observables for the following:

  • System Platforms, such as Xamarin (iOS/Android/TVOS), UWP
  • NuGet packages
  • Assemblies.

There is a MSBuild Task version and a global tool version.

How do I use?

MsBuild

Pharmacist can automatically create Observable wrappers for projects for their explicitly included NuGet packages.

In your .csproj file you can add:

<ItemGroup>
    <PackageReference Include="Pharmacist.MsBuild" Version="1.*" PrivateAssets="all" />
    <PackageReference Include="Pharmacist.Common" Version="1.*" />
</ItemGroup>

Pharmacist.MsBuild contains the MsBuild target file and appropriate tasks. Pharmacist.Common includes common source code that is required to invoke the generated observables.

This will generate wrappers only for other included PackageReference's contained within the project file.

For example if you had a inclusion for Xamarin.Forms in the same project that includes Pharmacist it will generate Observable wrappers for the included codes. It will not include any child PackageReference from other projects included via a ProjectReference. You can override that functionality by including <PharmacistGlobalPackages>true</PharmacistGlobalPackages> in a PropertyGroup inside your project.

Also it will only generate the specified ProjectReference and none of it's dependent packages. For example for a ProjectReference inclusion of ReactiveUI, it will not generate dependencies such as System.Reactive. If you want to generate observable wrappers for the dependent NuGet packages you must explicitly include them.

Command Line

Pharmacist comes with a command line version which is useful for generating for a specified platform.

The following values are supported for platforms: Android, iOS, Mac, WPF, UWP, Winforms, TVOS

Install the global tool:

dotnet tool install -g Pharmacist

To generate files:

pharmacist generate-platform -p <Platform> -o c:/directory/for/output --output-prefix="Events"

This would generate a file named Events_<Platform>.cs, where Platform would be the platform specified.

In the near future this will be changing to TargetFramework with /wpf and /winforms options.

Contribute

Pharmacist is developed under an OSI-approved open source license, making it freely usable and distributable, even for commercial use. Because of our Open Collective model for funding and transparency, we are able to funnel support and funds through to our contributors and community. We ❤ the people who are involved in this project, and we’d love to have you on board, especially if you are just getting started or have never contributed to open-source before.

So here's to you, lovely person who wants to join us — this is how you can support us:

About

Builds observables from events.

License:MIT License


Languages

Language:C# 98.2%Language:PowerShell 1.3%Language:Shell 0.5%Language:Batchfile 0.0%