Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 12 additions & 17 deletions samples/todoapp/TodoApp.Uno/TodoApp.Uno/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,35 @@
namespace TodoApp.Uno;
public partial class App : Application
{
protected Window? MainWindow { get; private set; }
public IHost? Host { get; private set; }
private Lazy<SqliteConnection> dbConnection = new(() => CreateSqliteConnection());

/// <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 App()
{
this.InitializeComponent();


}

protected Window? MainWindow { get; private set; }
public IHost? Host { get; private set; }
private SqliteConnection DbConnection { get => dbConnection.Value; }

private SqliteConnection dbConnection;
private static SqliteConnection CreateSqliteConnection()
{
SqliteConnection conn = new SqliteConnection("Data Source=:memory:");
conn.Open();
return conn;
}

protected async override void OnLaunched(LaunchActivatedEventArgs args)
{
AppContext.SetSwitch("System.Reflection.NullabilityInfoContext.IsSupported", true);

this.dbConnection = new SqliteConnection("Data Source=:memory:");
this.dbConnection.Open();

var builder = this.CreateBuilder(args)
// Add navigation support for toolkit controls such as TabBar and NavigationView
.UseToolkitNavigation()
.Configure(host => host

Check warning on line 39 in samples/todoapp/TodoApp.Uno/TodoApp.Uno/App.xaml.cs

View workflow job for this annotation

GitHub Actions / todoapp-uno / ios-maccatalyst

Using member 'Uno.Extensions.HostBuilderExtensions.UseNavigation(IHostBuilder, Action<IViewRegistry, IRouteRegistry>, Func<IServiceCollection, IViewRegistry>, Func<IServiceCollection, IRouteRegistry>, Func<NavigationConfiguration, NavigationConfiguration>, Action<HostBuilderContext, IServiceCollection>)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Cannot statically analyze the type of instance so its members may be trimmed.

Check warning on line 39 in samples/todoapp/TodoApp.Uno/TodoApp.Uno/App.xaml.cs

View workflow job for this annotation

GitHub Actions / todoapp-uno / ios-maccatalyst

Using member 'Uno.Extensions.HostBuilderExtensions.UseNavigation(IHostBuilder, Action<IViewRegistry, IRouteRegistry>, Func<IServiceCollection, IViewRegistry>, Func<IServiceCollection, IRouteRegistry>, Func<NavigationConfiguration, NavigationConfiguration>, Action<HostBuilderContext, IServiceCollection>)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Cannot statically analyze the type of instance so its members may be trimmed.
#if DEBUG
// Switch to Development environment when running in DEBUG
.UseEnvironment(Environments.Development)
Expand All @@ -42,12 +44,9 @@

.ConfigureServices((context, services) =>
{
// TODO: Register your services
//services.AddSingleton<IMyService, MyService>();
services.AddDbContext<AppDbContext>(options => options.UseSqlite(this.dbConnection));
services.AddDbContext<AppDbContext>(options => options.UseSqlite(DbConnection));
services.AddScoped<IDbInitializer, DbContextInitializer>();
services.AddTransient<TodoListViewModel>();

})
.UseNavigation(RegisterRoutes)
);
Expand All @@ -58,15 +57,11 @@
#endif
MainWindow.SetWindowIcon();

// We have to build here so that the services are initialized and we can call InitializeDatabase
// before navigating. This enables us to load the data when the page is loaded
Host = builder.Build();

Check warning on line 60 in samples/todoapp/TodoApp.Uno/TodoApp.Uno/App.xaml.cs

View workflow job for this annotation

GitHub Actions / todoapp-uno / ios-maccatalyst

Using member 'Uno.Extensions.Hosting.IApplicationBuilder.Build()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Cannot statically analyze the type of instance so its members may be trimmed.

Check warning on line 60 in samples/todoapp/TodoApp.Uno/TodoApp.Uno/App.xaml.cs

View workflow job for this annotation

GitHub Actions / todoapp-uno / ios-maccatalyst

Using member 'Uno.Extensions.Hosting.IApplicationBuilder.Build()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Cannot statically analyze the type of instance so its members may be trimmed.

InitializeDatabase();

// We still make this navigation call so we use the Uno Navigation extension, which automatically wires
// up view models with their page using the ViewMap and RouteMap below.
Host = await builder.NavigateAsync<Shell>();

Check warning on line 64 in samples/todoapp/TodoApp.Uno/TodoApp.Uno/App.xaml.cs

View workflow job for this annotation

GitHub Actions / todoapp-uno / ios-maccatalyst

Using member 'Uno.Extensions.ApplicationBuilderExtensions.NavigateAsync<TShell>(IApplicationBuilder, Func<IServiceProvider, INavigator, Task>)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Cannot statically analyze the type of instance so its members may be trimmed.

Check warning on line 64 in samples/todoapp/TodoApp.Uno/TodoApp.Uno/App.xaml.cs

View workflow job for this annotation

GitHub Actions / todoapp-uno / ios-maccatalyst

Using member 'Uno.Extensions.ApplicationBuilderExtensions.NavigateAsync<TShell>(IApplicationBuilder, Func<IServiceProvider, INavigator, Task>)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Cannot statically analyze the type of instance so its members may be trimmed.

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace TodoApp.Uno.Database;
public abstract class OfflineClientEntity
{
[System.ComponentModel.DataAnnotations.Key]
public string Id { get; set; }
public string Id { get; set; } = Guid.NewGuid().ToString("N");
public DateTimeOffset? UpdatedAt { get; set; }
public string? Version { get; set; }
public bool Deleted { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ public TodoListPage()
DataContextChanged += DataContextChangedHandler;
}



// on loaded override
private async void DataContextChangedHandler(object sender, DataContextChangedEventArgs e)
{
Expand All @@ -42,7 +40,7 @@ private async void DataContextChangedHandler(object sender, DataContextChangedEv
}
}

internal void PublishNotification(object sender, NotificationEventArgs args)
internal void PublishNotification(object? sender, NotificationEventArgs args)
{
Notification notification = new()
{
Expand Down
12 changes: 0 additions & 12 deletions samples/todoapp/TodoApp.Uno/global.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
{
// To update the version of Uno please update the version of the Uno.Sdk here. See https://aka.platform.uno/upgrade-uno-packages for more information.
// Bumped from 5.6.54 (-> Uno.WinUI 5.6.99) to 6.5.36 (-> Uno.WinUI 6.5.237). See #524:
// this major-version bump resolves the NU1903 (Tmds.DBus 0.16.0, GHSA-xrw6-gwf8-vvr9) advisory
// on the desktop head for free - Uno.WinUI.Runtime.Skia.X11 switches to the patched
// Tmds.DBus.Protocol dependency starting at Uno.WinUI 6.0.465, and 6.5.237 resolves well above
// that floor. It also lifts the Uno.Wasm.Bootstrap net9.0+ TargetFramework guard blocking the
// browserwasm head (Uno.Sdk 6.x implicitly resolves Uno.Wasm.Bootstrap 10.0.96 instead of the
// 5.x line's 8.0.23). See https://platform.uno/docs/articles/migrating-to-uno-6.html for the
// accompanying manual code changes required across heads (Platforms/Desktop/Program.cs,
// Platforms/Android/Main.Android.cs).
// See https://github.com/CommunityToolkit/Datasync/issues/506 and
// https://github.com/CommunityToolkit/Datasync/issues/524.
"msbuild-sdks": {
"Uno.Sdk": "6.5.36"
},
Expand Down
Loading