Fix macOS unit test isolated storage failure with runtime platform detection #1115
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixed an issue where unit tests targeting
net9.0(generic cross-platform) on macOS and Linux fail with "Read-only file system" errors when accessing isolated storage.Problem
When running unit tests that target
net9.0instead of platform-specific frameworks likenet9.0-macos, the conditional compilation symbolsAKAVACHE_MOBILEandAKAVACHE_MOBILE_IOSare not defined. This causes theGetIsolatedCacheDirectorymethod to default to usingIsolatedStorageFile.GetMachineStoreForAssembly()for theLocalMachinecache type.On Unix systems (macOS/Linux), this attempts to write to
/usr/share/IsolatedStorage, which is often read-only, causing unit tests to fail with:Solution
Added runtime platform detection to the cache directory selection logic in
AkavacheBuilderExtensions.cs. When targeting genericnet9.0on Unix systems, the code now falls back to usingGetUserStoreForAssembly()instead ofGetMachineStoreForAssembly()for theLocalMachinecache type.The fix maintains all existing behavior on Windows and mobile platforms while gracefully handling Unix environments where machine-level isolated storage may not be writable.
Changes
GetIsolatedCacheDirectoryto detect Unix platforms at runtimeTesting
This ensures unit tests can run successfully on macOS CI environments and development machines without requiring platform-specific target frameworks.
Fixes #1114.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
definitely-invalid-domain-that-does-not-exist-12345.invalid/home/REDACTED/.dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/Akavache/Akavache/src/Akavache.Tests/bin/Debug/net9.0/Akavache.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/Akavache/Akavache/src/Akavache.Tests/bin/Debug/net9.0/Akavache.Tests.deps.json /home/REDACTED/work/Akavache/Akavache/src/Akavache.Tests/bin/Debug/net9.0/testhost.dll --port 40525 --endpoint 127.0.0.1:040525 --role client --parentprocessid 5577 --telemetryoptedin false(dns block)invalid1.com/home/REDACTED/.dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/Akavache/Akavache/src/Akavache.Tests/bin/Debug/net9.0/Akavache.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/Akavache/Akavache/src/Akavache.Tests/bin/Debug/net9.0/Akavache.Tests.deps.json /home/REDACTED/work/Akavache/Akavache/src/Akavache.Tests/bin/Debug/net9.0/testhost.dll --port 40525 --endpoint 127.0.0.1:040525 --role client --parentprocessid 5577 --telemetryoptedin false(dns block)invalid2.com/home/REDACTED/.dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/Akavache/Akavache/src/Akavache.Tests/bin/Debug/net9.0/Akavache.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/Akavache/Akavache/src/Akavache.Tests/bin/Debug/net9.0/Akavache.Tests.deps.json /home/REDACTED/work/Akavache/Akavache/src/Akavache.Tests/bin/Debug/net9.0/testhost.dll --port 40525 --endpoint 127.0.0.1:040525 --role client --parentprocessid 5577 --telemetryoptedin false(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.