Repository navigation
Tech debt: logging reach, test-project abstractions, merger batching (#23, #52, #59) - #61
Conversation
Add AndroidLogcatLoggerProvider so Microsoft.Extensions.Logging output reaches adb logcat on device. AddDebug() does not bridge to logcat on .NET MAUI Android (verified empirically — zero ILogger lines visible in logcat pre-fix despite plenty of output in the file log). Registered under #if ANDROID for all build configs so device diagnostics work in Release too. Framework namespaces stay filtered at Warning to avoid firehose output. Left MainActivity and AiringCheckWorker on Android.Util.Log directly — both run before the DI container is guaranteed to be ready (lifecycle callbacks; post-reboot WorkManager). Added inline comments documenting the convention.
Move FileLoggerProvider registration outside the #if DEBUG block so Release installs also keep a bounded local ring buffer for user-shared diagnostics. Debug preserves current behavior (1 MB × 3 at Debug); Release gets a tighter 256 KB × 3 at Warning so the log cannot grow silently on long-running installs. Sentry still handles the cloud side at Warning+; the file log is the offline/share-by-email fallback. Update AGENTS.md with the full ILogger convention: DI-injected ILogger<T> is the only sanctioned path, the two Android.Util.Log exceptions (MainActivity, AiringCheckWorker) are documented with the pre-DI rationale, and the on-device log file path is called out for anyone grabbing diagnostics from a release build.
…52) PageModels no longer reach for MAUI statics (Shell.Current.GoToAsync, Preferences.Default, MainThread.BeginInvokeOnMainThread) on their state paths — those go through constructor-injected abstractions so the state machines can be exercised without a live MAUI shell. UX-only sites (DisplayAlertAsync, ShowPopupAsync, Browser.Default) stay on MAUI statics; they never run outside a view-attached path and pulling Popup/dialog types into the abstractions would bloat them for no test coverage gain. - New INavigationService abstraction + MauiShellNavigationService adapter. - TimeProvider.System registered via TryAddSingleton so tests can swap in FakeTimeProvider without the app discovering a default. - Test project picks up Microsoft.Maui.Essentials + Microsoft.Maui.Core (IPreferences / IDispatcher resolve on plain net10.0) and NSubstitute 5.3.0. Phase-1 PageModel tests from the umbrella plan are deferred: the PageModel source files transitively reference CommunityToolkit.Maui (Popup) and Microsoft.Maui.Controls (Shell, Keyboard), which don't have net10.0 targets and block link-compile. The abstractions here are the precondition for that work once PageModels are split into non-UX partials or an AniSprinkles.Core class library is extracted.
MediaListSectionsMerger.Merge previously called section mutators one item at a time, each triggering UpdateItems() -> ReplaceItems() -> NotifyCollectionChanged Reset. A bulk scenario (e.g. 20 cross-section status-change moves) fired ~20 Resets per affected section, each forcing RecyclerView to rebind every visible cell. Introduce an IDisposable BeginBulkUpdate() scope on MediaListSection: per-call UpdateItems() is deferred while the scope is alive, and runs once on Dispose (skipped entirely if no mutation actually occurred between Begin and End). Nested scopes are supported via a depth counter; only the outermost Dispose triggers the rebuild. Merge() opens a scope per touched section lazily via ScopeFor(), and disposes them in a finally block. Sections not mutated by a merge pay zero cost. try/finally keeps scopes from leaking if the merge throws. Add 5 tests covering: bulk remove -> one Reset, cross-section move -> one Reset per side, unchanged sections -> zero Resets, nested scopes, and empty-scope no-op.
There was a problem hiding this comment.
Pull request overview
This PR bundles three follow-ups to the pull-to-refresh work: expanding Android logging visibility (logcat + Release file logs), introducing DI-friendly abstractions for PageModel testability, and batching MediaListSection updates during merges to reduce redundant collection Resets.
Changes:
- Add an Android
ILogger→ logcat bridge and enable on-device file logging in Release with tighter rotation/levels. - Introduce
INavigationService(+MauiShellNavigationService) and migrate select PageModels to DI for navigation/preferences/dispatching. - Add a bulk-update scope to
MediaListSection, update the merger to use it, and add tests for batching behavior.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/AniSprinkles.UnitTests/MediaListSectionsMergerTests.cs | Adds 5 new tests validating bulk-update batching/reset coalescing. |
| tests/AniSprinkles.UnitTests/AniSprinkles.UnitTests.csproj | Adds MAUI Core/Essentials + NSubstitute; link-compiles service abstractions. |
| src/Services/Maui/MauiShellNavigationService.cs | Implements INavigationService via Shell.Current.GoToAsync. |
| src/Services/Abstractions/INavigationService.cs | Adds route-based navigation abstraction for PageModels. |
| src/Platforms/Android/MainActivity.cs | Documents why Android lifecycle logging stays on Android.Util.Log. |
| src/Platforms/Android/AndroidLogcatLoggerProvider.cs | New custom logging provider bridging ILogger to logcat. |
| src/Platforms/Android/AiringCheckWorker.cs | Documents why WorkManager path logs directly to logcat pre-DI. |
| src/PageModels/SettingsPageModel.cs | Switches to injected IPreferences/IDispatcher for testability. |
| src/PageModels/MyAnimePageModel.cs | Switches to injected IPreferences/INavigationService. |
| src/PageModels/MediaListSectionsMerger.cs | Uses per-section bulk-update scopes to batch resets during merge. |
| src/PageModels/MediaListSection.cs | Adds BeginBulkUpdate() batching scope with nested-depth + dirty flag. |
| src/PageModels/MediaDetailsPageModel.cs | Switches navigation to injected INavigationService. |
| src/MauiProgram.cs | Wires new logging providers + DI registrations (TimeProvider, INavigationService). |
| src/GlobalUsings.cs | Adds global using for AniSprinkles.Services.Abstractions. |
| AGENTS.md | Updates architecture/docs for logging reach and test project constraints. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fix startup crash from missing IPreferences registration (MAUI exposes it as a static only; DI had no default). Add explicit filter for the logcat provider so app-category logs honor the per-config minimum. Log a warning when Shell.Current is null during navigation instead of silently no-op'ing. Correct XML doc cref that didn't resolve to a type.
Add generic review items that apply to any change: tests, build & test health, dead code, scope discipline, error handling, logging, conventions, public API surface, TODOs, commit-readiness. Scope discipline explicitly carves out tracked issues for half-finished work and unrelated fixups.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 19 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
When the merger creates a brand-new section, seed AddItems/ApplySort/ ApplyFilter inside a narrow using-scope that disposes before existing.Add publishes the section. Previously the section was added to the outer ObservableCollection while its bulk-update scope was still open, exposing an empty visible collection and a stale FilteredCount/DisplayCount until the outer finally block ran.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 19 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Asserts TotalCount, FilteredCount, DisplayCount, and visible Count on the newly-added MediaListSection at the moment it fires Add on the outer ObservableCollection. Fails without the publish-after-scope-dispose fix.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 19 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ertions for section removal
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 19 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…e handling in MediaListSection tests
…llis21/AniSprinkles into chore/logging-tests-batching
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 19 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…agement in MediaListSectionsMerger
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 19 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…23, #52, #59) (#61) * Bridge ILogger to logcat on Android (#23) Add AndroidLogcatLoggerProvider so Microsoft.Extensions.Logging output reaches adb logcat on device. AddDebug() does not bridge to logcat on .NET MAUI Android (verified empirically — zero ILogger lines visible in logcat pre-fix despite plenty of output in the file log). Registered under #if ANDROID for all build configs so device diagnostics work in Release too. Framework namespaces stay filtered at Warning to avoid firehose output. Left MainActivity and AiringCheckWorker on Android.Util.Log directly — both run before the DI container is guaranteed to be ready (lifecycle callbacks; post-reboot WorkManager). Added inline comments documenting the convention. * Enable Release file logging + document ILogger conventions (#23) Move FileLoggerProvider registration outside the #if DEBUG block so Release installs also keep a bounded local ring buffer for user-shared diagnostics. Debug preserves current behavior (1 MB × 3 at Debug); Release gets a tighter 256 KB × 3 at Warning so the log cannot grow silently on long-running installs. Sentry still handles the cloud side at Warning+; the file log is the offline/share-by-email fallback. Update AGENTS.md with the full ILogger convention: DI-injected ILogger<T> is the only sanctioned path, the two Android.Util.Log exceptions (MainActivity, AiringCheckWorker) are documented with the pre-DI rationale, and the on-device log file path is called out for anyone grabbing diagnostics from a release build. * Inject INavigationService, IPreferences, IDispatcher into PageModels (#52) PageModels no longer reach for MAUI statics (Shell.Current.GoToAsync, Preferences.Default, MainThread.BeginInvokeOnMainThread) on their state paths — those go through constructor-injected abstractions so the state machines can be exercised without a live MAUI shell. UX-only sites (DisplayAlertAsync, ShowPopupAsync, Browser.Default) stay on MAUI statics; they never run outside a view-attached path and pulling Popup/dialog types into the abstractions would bloat them for no test coverage gain. - New INavigationService abstraction + MauiShellNavigationService adapter. - TimeProvider.System registered via TryAddSingleton so tests can swap in FakeTimeProvider without the app discovering a default. - Test project picks up Microsoft.Maui.Essentials + Microsoft.Maui.Core (IPreferences / IDispatcher resolve on plain net10.0) and NSubstitute 5.3.0. Phase-1 PageModel tests from the umbrella plan are deferred: the PageModel source files transitively reference CommunityToolkit.Maui (Popup) and Microsoft.Maui.Controls (Shell, Keyboard), which don't have net10.0 targets and block link-compile. The abstractions here are the precondition for that work once PageModels are split into non-UX partials or an AniSprinkles.Core class library is extracted. * Batch MediaListSection mutations during pull-to-refresh merge (#59) MediaListSectionsMerger.Merge previously called section mutators one item at a time, each triggering UpdateItems() -> ReplaceItems() -> NotifyCollectionChanged Reset. A bulk scenario (e.g. 20 cross-section status-change moves) fired ~20 Resets per affected section, each forcing RecyclerView to rebind every visible cell. Introduce an IDisposable BeginBulkUpdate() scope on MediaListSection: per-call UpdateItems() is deferred while the scope is alive, and runs once on Dispose (skipped entirely if no mutation actually occurred between Begin and End). Nested scopes are supported via a depth counter; only the outermost Dispose triggers the rebuild. Merge() opens a scope per touched section lazily via ScopeFor(), and disposes them in a finally block. Sections not mutated by a merge pay zero cost. try/finally keeps scopes from leaking if the merge throws. Add 5 tests covering: bulk remove -> one Reset, cross-section move -> one Reset per side, unchanged sections -> zero Resets, nested scopes, and empty-scope no-op. * CI: Update UI screenshots [skip ci] * Register IPreferences in DI + address PR #61 review feedback Fix startup crash from missing IPreferences registration (MAUI exposes it as a static only; DI had no default). Add explicit filter for the logcat provider so app-category logs honor the per-config minimum. Log a warning when Shell.Current is null during navigation instead of silently no-op'ing. Correct XML doc cref that didn't resolve to a type. * Expand ani-review checklist with engineering hygiene sections Add generic review items that apply to any change: tests, build & test health, dead code, scope discipline, error handling, logging, conventions, public API surface, TODOs, commit-readiness. Scope discipline explicitly carves out tracked issues for half-finished work and unrelated fixups. * CI: Update UI screenshots [skip ci] * Materialize new MediaListSection before publishing to observers When the merger creates a brand-new section, seed AddItems/ApplySort/ ApplyFilter inside a narrow using-scope that disposes before existing.Add publishes the section. Previously the section was added to the outer ObservableCollection while its bulk-update scope was still open, exposing an empty visible collection and a stale FilteredCount/DisplayCount until the outer finally block ran. * CI: Update UI screenshots [skip ci] * Add regression test for new-section materialization Asserts TotalCount, FilteredCount, DisplayCount, and visible Count on the newly-added MediaListSection at the moment it fires Add on the outer ObservableCollection. Fails without the publish-after-scope-dispose fix. * CI: Update UI screenshots [skip ci] * Enhance bulk update handling in MediaListSection and improve test assertions for section removal * CI: Update UI screenshots [skip ci] * Enhance logging in AndroidLogcatLoggerProvider and improve bulk update handling in MediaListSection tests * CI: Update UI screenshots [skip ci] * Enhance documentation for ApplyFilter method and improve resource management in MediaListSectionsMerger * CI: Update UI screenshots [skip ci] --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>



Umbrella branch for three follow-up items from PR #58 (pull-to-refresh fix). Four commits, each green on its own.
Summary
Commit 1 — Bridge ILogger to logcat on Android (#23)
AndroidLogcatLoggerProviderregistered inMauiProgram.cs; allILogger<T>writes now surface inadb logcatin both Debug and Release.MainActivity.cs/AiringCheckWorker.csdocumenting why they still callAndroid.Util.Logdirectly (pre-DI lifecycle).Commit 2 — Release file logging + docs (#23)
FileLoggerProvidernow runs in Release too (256 KB × 3 atLogLevel.Warning); Debug unchanged (1 MB × 3 atLogLevel.Debug)./ani-debugskill updated to document the expanded logging reach.Commit 3 — PageModel DI abstractions (#52, partial)
INavigationService(+MauiShellNavigationServiceadapter); PageModels now depend onIPreferences,IDispatcher,INavigationService/TimeProvidervia ctor DI instead ofShell.Current,Preferences.Default,MainThread.BeginInvokeOnMainThread.Microsoft.Maui.Essentials/Microsoft.Maui.Core/NSubstituteand link-compilesServices/Abstractions/*.cs.Microsoft.Maui.ControlsandCommunityToolkit.Mauihave nonet10.0target, so the PageModels themselves still can't be link-compiled into the unit-test project. Unblocking them requires either splitting PageModels into non-UX partials or extracting anAniSprinkles.Coreclass library — both out of scope for this umbrella. Rationale documented in AGENTS.md.Commit 4 — Merger batching (#59)
IDisposable BeginBulkUpdate()scope onMediaListSection; per-callUpdateItems()is deferred while the scope is alive and runs once onDispose.MediaListSectionsMerger.Mergeopens a scope per touched section lazily and disposes them in afinallyblock — one Reset per affected section instead of one per mutation.Tradeoffs
MediaListSection— callers that don't opt in (cold-pathBuildSections,RefreshVisibleItems) keep the original per-call behavior.Test plan
dotnet build src/AniSprinkles.csproj -c Debug -f net10.0-android— zero errorsdotnet build src/AniSprinkles.csproj -c Release -f net10.0-android— zero errorsdotnet build src/AniSprinkles.csproj -c Debug -f net10.0-android -p:CiBuild=true— zero errorsdotnet test tests/AniSprinkles.UnitTests— 43 / 43 pass (38 existing + 5 new batching tests)/ani-debugafter a status-change burst shows one Reset per affected section (was N per mutation)adb shell run-as com.RainbowSprinkles.AniSprinkles cat files/logs/anisprinkles.logshows warning+ entriesCloses #23
Closes #59
Partially addresses #52 (abstractions landed; PageModel test coverage follow-up)