From 14d755f8bba4ba01d8e5db0fafe62374a12a0c52 Mon Sep 17 00:00:00 2001 From: Gerwin Kuijntjes Date: Mon, 6 Apr 2026 09:32:26 +0200 Subject: [PATCH] Enable compiled XAML bindings and fix MAUI deprecation warnings Add x:DataType to all pages and controls for compiled bindings, migrate from deprecated Application.Current.MainPage to Windows[0].Page API, suppress expected analyzer warnings (XC0023, CS0618, CA1422), and add Newtonsoft.Json dependency. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Xamarin.Neo4j.Android/MainActivity.cs | 4 +++- .../Services/VersionService.cs | 4 ++-- .../Xamarin.Neo4j/Xamarin.Neo4j/App.xaml.cs | 4 +++- .../Controls/ConnectionCell.xaml | 2 ++ .../Controls/ConnectionCell.xaml.cs | 1 + .../Xamarin.Neo4j/Controls/LicenseCell.xaml | 6 +++++- .../Controls/LicenseCell.xaml.cs | 1 + .../Controls/QueryResultView.xaml | 5 ++++- .../Xamarin.Neo4j/Fonts/FontAwesomeSolid.cs | 2 +- .../Xamarin.Neo4j/Models/Database.cs | 2 ++ .../Pages/AddConnectionPage.xaml | 2 ++ .../Xamarin.Neo4j/Pages/ConnectionsPage.xaml | 11 +++++++---- .../Xamarin.Neo4j/Pages/GraphPage.xaml | 2 ++ .../Xamarin.Neo4j/Pages/LicensesPage.xaml | 2 ++ .../Xamarin.Neo4j/Pages/QueriesPage.xaml | 7 +++++-- .../Xamarin.Neo4j/Pages/SessionPage.xaml | 19 +++++++++++-------- .../Xamarin.Neo4j/Pages/SettingsPage.xaml | 2 ++ .../ViewModels/AddConnectionViewModel.cs | 4 ++-- .../ViewModels/QueriesViewModel.cs | 2 +- .../ViewModels/SessionViewModel.cs | 6 +++--- .../ViewModels/SettingsViewModel.cs | 6 +++--- .../Xamarin.Neo4j/Xamarin.Neo4j.csproj | 10 ++++++++++ 22 files changed, 74 insertions(+), 30 deletions(-) diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.Android/MainActivity.cs b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.Android/MainActivity.cs index b6b5910..131a504 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.Android/MainActivity.cs +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.Android/MainActivity.cs @@ -38,7 +38,9 @@ namespace Xamarin.Neo4j.Android var statusBarColor = isDark ? AColor.ParseColor("#0c0c0c") : AColor.ParseColor("#f5f5f5"); +#pragma warning disable CA1422 Window.SetStatusBarColor(statusBarColor); +#pragma warning restore CA1422 var controller = new WindowInsetsControllerCompat(Window, Window.DecorView); controller.AppearanceLightStatusBars = !isDark; @@ -58,7 +60,7 @@ namespace Xamarin.Neo4j.Android // MAUI creates its toolbar programmatically so theme-based tinting doesn't reach // the overflow icon. Walk the view tree and apply the tint directly. - private static void TintToolbarIcons(ViewGroup? parent) + private static void TintToolbarIcons(ViewGroup parent) { if (parent == null) return; for (var i = 0; i < parent.ChildCount; i++) diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.Android/Services/VersionService.cs b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.Android/Services/VersionService.cs index 516b8a8..57b2eda 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.Android/Services/VersionService.cs +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.Android/Services/VersionService.cs @@ -22,11 +22,11 @@ namespace Xamarin.Neo4j.Android.Services { var context = global::Android.App.Application.Context; var info = context.PackageManager.GetPackageInfo(context.PackageName, 0); -#pragma warning disable CS0618 +#pragma warning disable CS0618, CA1416, CA1422 return Build.VERSION.SdkInt >= BuildVersionCodes.P ? info.LongVersionCode.ToString() : info.VersionCode.ToString(); -#pragma warning restore CS0618 +#pragma warning restore CS0618, CA1416, CA1422 } } } diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/App.xaml.cs b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/App.xaml.cs index 16875ae..aaa2817 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/App.xaml.cs +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/App.xaml.cs @@ -21,7 +21,9 @@ namespace Xamarin.Neo4j SetTheme(Current.RequestedTheme); RequestedThemeChanged += (s, e) => SetTheme(e.RequestedTheme); +#pragma warning disable CS0618 MainPage = new NavigationPage(new ConnectionsPage()); +#pragma warning restore CS0618 // SetTheme ran before MainPage was assigned, so apply bar colours now. ApplyNavBarColors(); @@ -47,7 +49,7 @@ namespace Xamarin.Neo4j // theme changes while the app is backgrounded are picked up on return. public void ApplyNavBarColors() { - if (MainPage is NavigationPage navPage) + if (Windows.Count > 0 && Windows[0].Page is NavigationPage navPage) { if (Resources.TryGetValue("NavigationBarColor", out var navColor) && navColor is Color color) navPage.BarBackgroundColor = color; diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Controls/ConnectionCell.xaml b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Controls/ConnectionCell.xaml index 1219f18..897a380 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Controls/ConnectionCell.xaml +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Controls/ConnectionCell.xaml @@ -3,6 +3,8 @@ diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Controls/ConnectionCell.xaml.cs b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Controls/ConnectionCell.xaml.cs index 1ab5a8c..c882330 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Controls/ConnectionCell.xaml.cs +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Controls/ConnectionCell.xaml.cs @@ -10,6 +10,7 @@ using Microsoft.Maui.Controls.Xaml; namespace Xamarin.Neo4j.Controls { [XamlCompilation(XamlCompilationOptions.Compile)] +#pragma warning disable CS0618 public partial class ConnectionCell : ViewCell { public ConnectionCell() diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Controls/LicenseCell.xaml b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Controls/LicenseCell.xaml index b952c54..ef16e86 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Controls/LicenseCell.xaml +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Controls/LicenseCell.xaml @@ -1,5 +1,9 @@ - +