Skip to content

Commit

Permalink
Merge pull request #671 from unoplatform/dev/lapr/single-samplecalc
Browse files Browse the repository at this point in the history
SimpleCalc Sample App - Single Project Migration
  • Loading branch information
agneszitte committed Apr 25, 2024
2 parents c31f5a1 + fb8f2b9 commit 7bdb88f
Show file tree
Hide file tree
Showing 339 changed files with 1,787 additions and 6,170 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ csharp_indent_labels = one_less_than_current
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_namespace_declarations = file_scoped:warning
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,5 +399,5 @@ FodyWeavers.xsd

# Single Target Config
solution-config.props
# Windows Publish Profiles
!**/*.Windows/Properties/PublishProfiles/*.pubxml
# Publish Profiles
!**/Properties/PublishProfiles/*.pubxml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"Microsoft.VisualStudio.Component.Merq",
"Component.Xamarin.RemotedSimulator",
"Microsoft.VisualStudio.Component.MonoDebugger",
"Component.Xamarin",
"Microsoft.VisualStudio.ComponentGroup.Maui.All",
"Component.Android.SDK34",
"Component.Android.SDK33",
Expand Down
22 changes: 22 additions & 0 deletions reference/SimpleCalc/CSharp-MVUX/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project>
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>

<!--
Adding NoWarn to remove build warnings
NU1507: Warning when there are multiple package sources when using CPM with no source mapping
NETSDK1201: Warning that specifying RID won't create self containing app
PRI257: Ignore default language (en) not being one of the included resources (eg en-us, en-uk)
-->
<NoWarn>$(NoWarn);NU1507;NETSDK1201;PRI257</NoWarn>
</PropertyGroup>

<PropertyGroup>
<UnoExtensionsVersion>4.1.14</UnoExtensionsVersion>
<UnoToolkitVersion>6.0.18</UnoToolkitVersion>
<UnoThemesVersion>5.0.13</UnoThemesVersion>
<UnoCSharpMarkupVersion>5.2.13</UnoCSharpMarkupVersion>
</PropertyGroup>
</Project>
2 changes: 2 additions & 0 deletions reference/SimpleCalc/CSharp-MVUX/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<Project>
</Project>
16 changes: 16 additions & 0 deletions reference/SimpleCalc/CSharp-MVUX/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project ToolsVersion="15.0">
<!--
To update the version of Uno, you should instead update the Sdk version in the global.json file.
See https://aka.platform.uno/using-uno-sdk for more information.
-->
<ItemGroup>
</ItemGroup>
<ItemGroup>
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageVersion Include="NUnit" Version="4.1.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>
</Project>
113 changes: 113 additions & 0 deletions reference/SimpleCalc/CSharp-MVUX/SimpleCalculator-CSharp-MVUX.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.2.32210.308
MinimumVisualStudioVersion = 15.0.26124.0
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleCalculator", "SimpleCalculator\SimpleCalculator.csproj", "{054215D9-1AEB-4AB7-956B-B083419F4166}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{BADA71DC-7FFD-4EDC-9F28-FB74AEADC713}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
Directory.Packages.props = Directory.Packages.props
global.json = global.json
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleCalculator.Tests", "SimpleCalculator.Tests\SimpleCalculator.Tests.csproj", "{FF6373AF-4A90-40C0-87E8-07B0907425BD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|ARM64 = Debug|ARM64
Debug|iPhone = Debug|iPhone
Debug|iPhoneSimulator = Debug|iPhoneSimulator
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|ARM64 = Release|ARM64
Release|iPhone = Release|iPhone
Release|iPhoneSimulator = Release|iPhoneSimulator
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{054215D9-1AEB-4AB7-956B-B083419F4166}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Debug|Any CPU.Build.0 = Debug|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Debug|ARM.ActiveCfg = Debug|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Debug|ARM.Build.0 = Debug|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Debug|ARM.Deploy.0 = Debug|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Debug|ARM64.Build.0 = Debug|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Debug|ARM64.Deploy.0 = Debug|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Debug|iPhone.Build.0 = Debug|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Debug|iPhone.Deploy.0 = Debug|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Debug|iPhoneSimulator.Deploy.0 = Debug|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Debug|x64.ActiveCfg = Debug|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Debug|x64.Build.0 = Debug|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Debug|x64.Deploy.0 = Debug|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Debug|x86.ActiveCfg = Debug|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Debug|x86.Build.0 = Debug|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Debug|x86.Deploy.0 = Debug|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Release|Any CPU.ActiveCfg = Release|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Release|Any CPU.Build.0 = Release|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Release|Any CPU.Deploy.0 = Release|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Release|ARM.ActiveCfg = Release|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Release|ARM.Build.0 = Release|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Release|ARM.Deploy.0 = Release|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Release|ARM64.ActiveCfg = Release|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Release|ARM64.Build.0 = Release|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Release|ARM64.Deploy.0 = Release|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Release|iPhone.ActiveCfg = Release|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Release|iPhone.Build.0 = Release|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Release|iPhone.Deploy.0 = Release|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Release|iPhoneSimulator.Deploy.0 = Release|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Release|x64.ActiveCfg = Release|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Release|x64.Build.0 = Release|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Release|x64.Deploy.0 = Release|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Release|x86.ActiveCfg = Release|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Release|x86.Build.0 = Release|Any CPU
{054215D9-1AEB-4AB7-956B-B083419F4166}.Release|x86.Deploy.0 = Release|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Debug|ARM.ActiveCfg = Debug|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Debug|ARM.Build.0 = Debug|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Debug|ARM64.Build.0 = Debug|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Debug|iPhone.Build.0 = Debug|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Debug|x64.ActiveCfg = Debug|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Debug|x64.Build.0 = Debug|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Debug|x86.ActiveCfg = Debug|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Debug|x86.Build.0 = Debug|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Release|Any CPU.Build.0 = Release|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Release|ARM.ActiveCfg = Release|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Release|ARM.Build.0 = Release|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Release|ARM64.ActiveCfg = Release|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Release|ARM64.Build.0 = Release|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Release|iPhone.ActiveCfg = Release|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Release|iPhone.Build.0 = Release|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Release|x64.ActiveCfg = Release|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Release|x64.Build.0 = Release|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Release|x86.ActiveCfg = Release|Any CPU
{FF6373AF-4A90-40C0-87E8-07B0907425BD}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9D26FDA9-5EF0-43F9-84AF-B0ADC8EA2AB4}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
global using FluentAssertions;
global using SimpleCalculator;
global using NUnit.Framework;
4 changes: 4 additions & 0 deletions reference/SimpleCalc/CSharp-MVUX/SimpleCalculator/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<Application x:Class="SimpleCalculator.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
</Application>
Original file line number Diff line number Diff line change
@@ -1,40 +1,79 @@
using System;
using Microsoft.Extensions.Logging;
using Microsoft.UI.Xaml;
using Uno.Resizetizer;

namespace SimpleCalculator;

public sealed partial class AppHead : App
public partial class App : Application
{
static AppHead() =>
InitializeLogging();

/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public AppHead()
public App()
{
this.InitializeComponent();
}

/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="args">Details about the launch request and process.</param>
protected Window? MainWindow { get; private set; }

protected override void OnLaunched(LaunchActivatedEventArgs args)
{
base.OnLaunched(args);
// Load WinUI Resources
Resources.Build(r => r.Merged(
new XamlControlsResources()));

// Load Uno.UI.Toolkit and Material Resources
Resources.Build(r => r.Merged(
new MaterialToolkitTheme(
new Styles.ColorPaletteOverride(),
new Styles.MaterialFontsOverride())));
MainWindow = new Window();
#if DEBUG
MainWindow.EnableHotReload();
#endif


// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (MainWindow.Content is not Frame rootFrame)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();

_window.SetWindowIcon();
// Place the frame in the current Window
MainWindow.Content = rootFrame;

rootFrame.NavigationFailed += OnNavigationFailed;
}

if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
rootFrame.Navigate(typeof(MainPage), args.Arguments);
}

MainWindow.SetWindowIcon();
// Ensure the current window is active
MainWindow.Activate();
}

/// <summary>
/// Invoked when Navigation to a certain page fails
/// </summary>
/// <param name="sender">The Frame which failed navigation</param>
/// <param name="e">Details about the navigation failure</param>
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
throw new InvalidOperationException($"Failed to load {e.SourcePageType.FullName}: {e.Exception}");
}

/// <summary>
/// Configures global Uno Platform logging
/// </summary>
private static void InitializeLogging()
public static void InitializeLogging()
{
#if DEBUG
// Logging is disabled by default for release builds, as it incurs a significant
Expand All @@ -50,8 +89,6 @@ private static void InitializeLogging()
builder.AddProvider(new global::Uno.Extensions.Logging.WebAssembly.WebAssemblyConsoleLoggerProvider());
#elif __IOS__ || __MACCATALYST__
builder.AddProvider(new global::Uno.Extensions.Logging.OSLogLoggerProvider());
#elif NETFX_CORE
builder.AddDebug();
#else
builder.AddConsole();
#endif
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
global using System.Collections.Immutable;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Logging;
global using ApplicationExecutionState = Windows.ApplicationModel.Activation.ApplicationExecutionState;
global using Color = Windows.UI.Color;
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private ToggleButton Header(BindableMainModel vm)
.HorizontalAlignment(HorizontalAlignment.Center)
.Background(Theme.Brushes.Surface.Default)
.Style(Theme.ToggleButton.Styles.Icon)
.IsChecked(x => x.Bind(() => vm.IsDark).TwoWay())
.IsChecked(x => x.Binding(() => vm.IsDark).TwoWay())
.Content
(
new PathIcon()
Expand Down Expand Up @@ -198,4 +198,4 @@ public static class AppIcons

public static readonly Resource<Geometry> Light =
StaticResource.Create<Geometry>("SunIcon", LightIcon);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace SimpleCalculator.Droid;
public class Application : Microsoft.UI.Xaml.NativeApplication
{
public Application(IntPtr javaReference, JniHandleOwnership transfer)
: base(() => new AppHead(), javaReference, transfer)
: base(() => new App(), javaReference, transfer)
{
ConfigureUniversalImageLoader();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Uno.UI.Runtime.Skia;

namespace SimpleCalculator;

public class Program
{
[STAThread]
public static void Main(string[] args)
{
App.InitializeLogging();

var host = SkiaHostBuilder.Create()
.App(() => new App())
.UseX11()
.UseLinuxFrameBuffer()
.UseMacOS()
.UseWindows()
.Build();

host.Run();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public 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(AppHead));
UIApplication.Main(args, null, typeof(App));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<linker>
<assembly fullname="SimpleCalculator" />
<assembly fullname="SimpleCalculator.Wasm" />

<!--
Uncomment this section when using JSON.NET
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
namespace SimpleCalculator.Wasm;
namespace SimpleCalculator;

public class Program
{
private static App? _app;

public static int Main(string[] args)
{
Microsoft.UI.Xaml.Application.Start(_ => _app = new AppHead());
Microsoft.UI.Xaml.Application.Start(_ => _app = new App());

return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public 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(AppHead));
UIApplication.Main(args, null, typeof(App));
}
}

0 comments on commit 7bdb88f

Please sign in to comment.