From 4dc1946c8207140e324e1f856f1edca6fdab4a9c Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Tue, 7 Jul 2026 20:59:26 +0100 Subject: [PATCH] PostIt: drop unused Settings.folder + align ViewLocator nullability Two leftover bits of dead code that were just compiler noise: - Settings.folder (IStorageFolder?, never read) plus the three Avalonia / Avalonia.Platform.Storage usings that only existed to type it. The picker-based flow was replaced by a direct file-path read in Settings.Load, so the field has been a CS0414 for a while. Just delete it. - ViewLocator.Build / Match took 'object data' while the IDataTemplate interface expects 'object? data', which is why the compiler was complaining with CS8767 about nullability mismatch on every implementation. Add an explicit null arm in the switch so the default branch doesn't have to dereference a possibly-null data either. --- src/PostIt/PostIt/Settings/Settings.cs | 4 ---- src/PostIt/PostIt/ViewLocator.cs | 6 +++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/PostIt/PostIt/Settings/Settings.cs b/src/PostIt/PostIt/Settings/Settings.cs index e6cc6fef..3cb40e38 100644 --- a/src/PostIt/PostIt/Settings/Settings.cs +++ b/src/PostIt/PostIt/Settings/Settings.cs @@ -1,7 +1,4 @@ using System.Runtime.CompilerServices; -using Avalonia; -using Avalonia.Controls; -using Avalonia.Platform.Storage; using CommunityToolkit.Mvvm.ComponentModel; using IdentityModel.OidcClient; using Microsoft.Extensions.DependencyInjection; @@ -18,7 +15,6 @@ namespace PostIt; public partial class Settings : ObservableObject { const string SettingsFileName = "postit-settings.json"; - IStorageFolder? folder = null; /// /// Legacy loopback redirect URI. The post-2026.6 production flow diff --git a/src/PostIt/PostIt/ViewLocator.cs b/src/PostIt/PostIt/ViewLocator.cs index ba34bf7c..983cf13c 100644 --- a/src/PostIt/PostIt/ViewLocator.cs +++ b/src/PostIt/PostIt/ViewLocator.cs @@ -1,5 +1,4 @@ using System; -using System.Diagnostics.CodeAnalysis; using Avalonia.Controls; using Avalonia.Controls.Templates; using Microsoft.Extensions.DependencyInjection; @@ -21,7 +20,7 @@ public class ViewLocator : IDataTemplate _services = services; } - public Control Build(object data) + public Control Build(object? data) { return data switch { @@ -29,9 +28,10 @@ public class ViewLocator : IDataTemplate SettingsPageViewModel => _services.GetRequiredService(), HomePageViewModel => _services.GetRequiredService(), SignaturePageViewModel => _services.GetRequiredService(), + null => new TextBlock { Text = "No view for " }, _ => new TextBlock { Text = $"No view for {data.GetType().Name}" } }; } - public bool Match(object data) => data is ViewModelBase; + public bool Match(object? data) => data is ViewModelBase; }