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.
This commit is contained in:
Paul Schneider 2026-07-07 20:59:26 +01:00
commit 4dc1946c82
2 changed files with 3 additions and 7 deletions

View file

@ -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;
/// <summary>
/// Legacy loopback redirect URI. The post-2026.6 production flow

View file

@ -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<SettingsPage>(),
HomePageViewModel => _services.GetRequiredService<HomePage>(),
SignaturePageViewModel => _services.GetRequiredService<SignaturePage>(),
null => new TextBlock { Text = "No view for <null>" },
_ => 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;
}