Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/type safety #1

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
1b3573c
Target .NET 7
nabond251 Mar 14, 2023
e3e2b1d
Install sealed unions
nabond251 Mar 14, 2023
3a6c763
Finish initial Runner3
nabond251 Mar 15, 2023
8af41a7
Test Runner3
nabond251 Mar 15, 2023
b9fe928
Simplify implementation
nabond251 Mar 15, 2023
9a486ac
Wrap main delegate
nabond251 Mar 17, 2023
12a300d
Attempt ungeneric interface
nabond251 Mar 23, 2023
890f377
Revert "Attempt ungeneric interface"
nabond251 Mar 23, 2023
b55ffdc
Make Runner1 from Runner3
nabond251 Mar 23, 2023
c30ec58
Implement demo with obs of tuple
nabond251 Mar 28, 2023
ec88a0d
Remove redundant streams type
nabond251 Mar 28, 2023
603d2ab
Convert tuple to sum type
nabond251 Mar 28, 2023
99a5a47
Add stream adapters
nabond251 Mar 31, 2023
d6cabf3
Replace streams with generic tuple
nabond251 Apr 2, 2023
7bbb5d9
Abstract calling drivers
nabond251 Apr 4, 2023
a8747dd
Move drivers caller
nabond251 Apr 4, 2023
24de546
Move driver call again
nabond251 Apr 4, 2023
35fee2d
Remove redundant types
nabond251 Apr 4, 2023
996d75e
Collapse down to one runner
nabond251 Apr 4, 2023
1ef53ca
Scale arity
nabond251 Apr 5, 2023
f93ea41
Improve typing
nabond251 Apr 5, 2023
c84094b
Revert "Collapse down to one runner"
nabond251 Apr 21, 2023
88125fa
Rename kernel
nabond251 Apr 21, 2023
8a58d91
Improve typing again
nabond251 Apr 21, 2023
3ddb3d0
Add object split/merge
nabond251 Apr 21, 2023
a309320
Implement runner with kernel
nabond251 Apr 21, 2023
55c176d
Test old and new demos alongside
nabond251 Apr 22, 2023
d9872f1
Create runner2 from 3
nabond251 Apr 22, 2023
146c78a
Implement runner2 with kernel
nabond251 Apr 22, 2023
639b318
Remove redundant types
nabond251 Apr 22, 2023
8430fde
Use runner2
nabond251 Apr 22, 2023
79eeacc
Clean up runner2
nabond251 Apr 22, 2023
4dfa7ae
Merge runner2 into runner
nabond251 Apr 22, 2023
a155f25
Merge in runner3
nabond251 Apr 22, 2023
6ca585f
Scale run arity
nabond251 Apr 23, 2023
6a8bf24
Clean up issues
nabond251 Apr 23, 2023
b0ffbfd
Split demos
nabond251 Apr 23, 2023
dfb7041
Add toggle demo
nabond251 Apr 25, 2023
f79ec21
Add demo app project
nabond251 Apr 26, 2023
3f7c7c8
Target .NET 6.0
nabond251 May 5, 2023
7585ddd
Update MAUI
nabond251 May 5, 2023
00e80a5
Add toggle demo
nabond251 May 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ indent_size = 2
dotnet_sort_system_directives_first = true

# Avoid "this." and "Me." if not necessary
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion
dotnet_style_qualification_for_field = true:suggestion
dotnet_style_qualification_for_property = true:suggestion
dotnet_style_qualification_for_method = true:suggestion
dotnet_style_qualification_for_event = true:suggestion

# Use language keywords instead of framework type names for type references
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
Expand All @@ -44,14 +44,14 @@ dotnet_style_explicit_tuple_names = true:suggestion
# CSharp code style settings:
[*.cs]
# Prefer "var" where the type is apparent
csharp_style_var_for_built_in_types = false:suggestion
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = false:suggestion
csharp_style_var_elsewhere = true:suggestion

# Prefer method-like constructs to have a block body
csharp_style_expression_bodied_methods = false:none
csharp_style_expression_bodied_constructors = false:none
csharp_style_expression_bodied_operators = false:none
csharp_style_expression_bodied_methods = true:none
csharp_style_expression_bodied_constructors = true:none
csharp_style_expression_bodied_operators = true:none

# Prefer property-like constructs to have an expression-body
csharp_style_expression_bodied_properties = true:none
Expand Down
6 changes: 5 additions & 1 deletion Cycle.NET.Demo/Cycle.NET.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="SdgApps.Common.DotnetSealedUnions" Version="1.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Cycle.NET\Cycle.NET.csproj" />
</ItemGroup>
Expand Down
6 changes: 4 additions & 2 deletions Cycle.NET.Demo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Cycle.NET.Demo
{
class Program
internal static class Program
{
private static IObservable<object> LogDriver(IObservable<object> sinks)
{
Expand All @@ -15,6 +15,8 @@ private static IObservable<object> LogDriver(IObservable<object> sinks)

private static IObservable<object> KeyInputDriver(IObservable<object> sinks)
{
_ = sinks;

return Observable.Range(20, 5).Select(i => (object)i);
}

Expand All @@ -27,7 +29,7 @@ private static Streams CycleMain(Streams sources)

return sinks;
}
static void Main(string[] args)
static void Main()
{
var drivers = new Drivers
{
Expand Down
14 changes: 14 additions & 0 deletions Cycle.NET.ToggleDemo/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Cycle.NET.ToggleDemo"
x:Class="Cycle.NET.ToggleDemo.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
12 changes: 12 additions & 0 deletions Cycle.NET.ToggleDemo/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Cycle.NET.ToggleDemo
{
public partial class App : Application
{
public App()
{
this.InitializeComponent();

this.MainPage = AppBootstrapper.CreateMainPage();
}
}
}
62 changes: 62 additions & 0 deletions Cycle.NET.ToggleDemo/AppBootstrapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using Cycle.NET.ToggleDemo.ViewModels;
using Cycle.NET.ToggleDemo.Views;
using ReactiveUI;
using Splat;

namespace Cycle.NET.ToggleDemo
{
/// <summary>
/// The app bootstrapper which is used to register everything with the Splat service locator.
/// </summary>
public static class AppBootstrapper
{
/// <summary>
/// Registers everything with the Splat service locator.
/// </summary>
public static MauiAppBuilder UseAppBootstrapper(this MauiAppBuilder builder)
{
var router = new RoutingState();
var screen = new AppBootstrapScreen(router);
Locator.CurrentMutable.RegisterConstant(screen, typeof(IScreen));
Locator.CurrentMutable.Register(() => new ToggleDemoView(), typeof(IViewFor<ToggleDemoViewModel>));

router
.NavigateAndReset
.Execute(new ToggleDemoViewModel())
.Subscribe();

return builder;
}

/// <summary>
/// Creates the first main page used within the application.
/// </summary>
/// <returns>The page generated.</returns>
public static Page CreateMainPage()
{
// NB: This returns the opening page that the platform-specific
// boilerplate code will look for. It will know to find us because
// we've registered our AppBootstrapScreen.
return new ReactiveUI.Maui.RoutedViewHost();
}

/// <summary>
/// The app bootstrap screen is the central location for the RoutingState used for routing between views.
/// </summary>
private sealed class AppBootstrapScreen : ReactiveObject, IScreen
{
/// <summary>
/// Initializes a new instance of the <see cref="AppBootstrapScreen"/> class.
/// </summary>
public AppBootstrapScreen(RoutingState router)
{
this.Router = router;
}

/// <summary>
/// Gets or sets the router which is used to navigate between views.
/// </summary>
public RoutingState Router { get; set; }
}
}
}
60 changes: 60 additions & 0 deletions Cycle.NET.ToggleDemo/Cycle.NET.ToggleDemo.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
<RootNamespace>Cycle.NET.ToggleDemo</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>

<!-- Display name -->
<ApplicationTitle>Cycle.NET.ToggleDemo</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.companyname.cycle.net.toggledemo</ApplicationId>
<ApplicationIdGuid>890c6119-9c69-4ea5-9c90-82044e4cd5d2</ApplicationIdGuid>

<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />

<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />

<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />

<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.756" />
<PackageReference Include="ReactiveUI.Maui" Version="18.4.34" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Cycle.NET\Cycle.NET.csproj" />
</ItemGroup>

</Project>
20 changes: 20 additions & 0 deletions Cycle.NET.ToggleDemo/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace Cycle.NET.ToggleDemo
{
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseAppBootstrapper()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});

return builder.Build();
}
}
}
6 changes: 6 additions & 0 deletions Cycle.NET.ToggleDemo/Platforms/Android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
11 changes: 11 additions & 0 deletions Cycle.NET.ToggleDemo/Platforms/Android/MainActivity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Android.App;
using Android.Content.PM;
using Android.OS;

namespace Cycle.NET.ToggleDemo
{
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
public class MainActivity : MauiAppCompatActivity
{
}
}
16 changes: 16 additions & 0 deletions Cycle.NET.ToggleDemo/Platforms/Android/MainApplication.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Android.App;
using Android.Runtime;

namespace Cycle.NET.ToggleDemo
{
[Application]
public class MainApplication : MauiApplication
{
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
: base(handle, ownership)
{
}

protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#512BD4</color>
<color name="colorPrimaryDark">#2B0B98</color>
<color name="colorAccent">#2B0B98</color>
</resources>
10 changes: 10 additions & 0 deletions Cycle.NET.ToggleDemo/Platforms/MacCatalyst/AppDelegate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Foundation;

namespace Cycle.NET.ToggleDemo
{
[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
}
30 changes: 30 additions & 0 deletions Cycle.NET.ToggleDemo/Platforms/MacCatalyst/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arm64</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/appicon.appiconset</string>
</dict>
</plist>
16 changes: 16 additions & 0 deletions Cycle.NET.ToggleDemo/Platforms/MacCatalyst/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using ObjCRuntime;
using UIKit;

namespace Cycle.NET.ToggleDemo
{
public static class Program
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, typeof(AppDelegate));
}
}
}
17 changes: 17 additions & 0 deletions Cycle.NET.ToggleDemo/Platforms/Tizen/Main.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using Microsoft.Maui;
using Microsoft.Maui.Hosting;

namespace Cycle.NET.ToggleDemo
{
internal class Program : MauiApplication
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();

static void Main(string[] args)
{
var app = new Program();
app.Run(args);
}
}
}
15 changes: 15 additions & 0 deletions Cycle.NET.ToggleDemo/Platforms/Tizen/tizen-manifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="maui-application-id-placeholder" version="0.0.0" api-version="7" xmlns="http://tizen.org/ns/packages">
<profile name="common" />
<ui-application appid="maui-application-id-placeholder" exec="Cycle.NET.ToggleDemo.dll" multiple="false" nodisplay="false" taskmanage="true" type="dotnet" launch_mode="single">
<label>maui-application-title-placeholder</label>
<icon>maui-appicon-placeholder</icon>
<metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />
</ui-application>
<shortcut-list />
<privileges>
<privilege>http://tizen.org/privilege/internet</privilege>
</privileges>
<dependencies />
<provides-appdefined-privileges />
</manifest>
Loading