Repository navigation
fix: handle when WinRT APIs are unavailable - #38612
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to make Microsoft.Data.Sqlite more resilient on Windows-like environments where WinRT APIs exist but are partially unavailable (e.g., Wine), by extending the static initialization logic that attempts to use Windows.Storage.ApplicationData.
Changes:
- Adds exception handling intended to treat
NotImplementedException/NotSupportedExceptionas “WinRT feature unavailable” during WinRT probing inSqliteConnection’s static constructor.
|
@dotnet-policy-service agree |
|
Marking as draft until it's updated |
|
Updating, thank you for reminding me about this! |
|
Hello @AndriySvyryd, is it possible to reconsider this for .NET 11? It would be fantastic to include this modest, low-risk patch for Wine compatibility in the preceding release since it only addresses failure instances and has no effect on successful execution routes or current tests. |
AndriySvyryd
left a comment
There was a problem hiding this comment.
Ok, this barely makes the cut.
Thanks for your contribution!
The change is a small addition to an existing exception filter and doesn't introduce new behavior that requires unit testing. The exceptions being added are already handled conceptually by the existing "feature unavailable" logic.
Motivation
The existing code already catches exceptions from the initial WinRT call (e.g.,
TargetInvocationExceptionandInvalidOperationExceptionfor unpackaged apps). However, Wine partially implements WinRT — it successfully returns aApplicationDataobject from the first call, but then throwsNotImplementedExceptionwhen accessing theLocalFolderproperty. Since this exception isn't caught, the entireSqliteConnectiontype becomes unusable.Note:
System.Data.SQLiteworks fine under Wine because it doesn't attempt this WinRT trick. However, I love Microsoft.Data.Sqlite and I'm a programmer that daily drives Linux and want to test my application under Wine instead of an VM. It'd also fix ShareX's latest versions under Wine too.Fixes #36343