Warning: observer object was not disposed manually with Dispose() and Missing Dispose call on local IDisposable (cs/local-not-disposed) #26871
Labels
area-architecture
Issues with code structure, SDK structure, implementation details
platform/iOS 🍎
s/triaged
Issue has been reviewed
t/bug
Something isn't working
Milestone
Description
Environment:
.NET MAUI Version: 8.0.93
JetBrains Rider Version: 2024.1.4
CommunityToolkit.Mvvm: 8.3.2
CommunityToolkit.Maui: 9.1.0
Description:
While performing local debugging on both an Android device (Pixel 6 Pro running Android 14) and an iOS simulator (iPhone 15 running iOS 18), I observed the following warning in the logs:
2024-12-30 17:02:11.680874-0600 Mobile[61441:1411563] Warning: observer object was not disposed manually with Dispose()
This warning seems to stem from an ObservableCollection that is loaded after performing a pull-to-refresh operation.
Expected Behavior:
No warnings regarding observer objects not being disposed manually should appear in the logs.
Actual Behavior:
The warning is repeatedly logged, indicating potential resource management issues.
Additional Context:
Observed both in local debugging and Azure DevOps Advanced Security Code Scanning.
Appears linked to ObservableCollection updates after pull-to-refresh.
Missing Dispose call on local IDisposable (cs/local-not-disposed)
Additionally, Azure DevOps Advanced Security Code Scanning is flagging similar warnings in the following generated source files:
Steps to Reproduce
Run the application on an Android Pixel 6 Pro or iOS iPhone 15 Simulator.
Perform a pull-to-refresh action on a screen utilizing an ObservableCollection.
Observe logs in JetBrains Rider or Console.
Link to public reproduction project repository
https://github.com/vikher/testmedia/tree/main/testmedia
Version with bug
8.0.93 SR9.3
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
No response
Affected platforms
iOS, Android
Affected platform versions
Device (Android): Pixel 6 Pro (Android 14) Device (iOS Simulator): iPhone 15 (iOS 18)
Did you find any workaround?
No response
Relevant log output
The text was updated successfully, but these errors were encountered: