Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

74642 change isostorage path #75541

Merged
merged 12 commits into from
Sep 27, 2022

Conversation

mkhamoyan
Copy link
Contributor

@mkhamoyan mkhamoyan commented Sep 13, 2022

The path of a file created by IsolatedStorageFile.GetUserStoreForApplication() changes between Xamarin.iOS and .NET 6, and also changes between different builds of the application under .NET 6.

Switched back to the .isolatedstorage approach we had in legacy mono https://github.com/mono/mono/blob/main/mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorageFile.cs#L304-L327

Fix #74642

@ghost
Copy link

ghost commented Sep 13, 2022

Tagging subscribers to this area: @dotnet/area-system-io
See info in area-owners.md if you want to be subscribed.

Issue Details

null

Author: mkhamoyan
Assignees: -
Labels:

area-System.IO

Milestone: -

@mkhamoyan
Copy link
Contributor Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mkhamoyan
Copy link
Contributor Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mkhamoyan
Copy link
Contributor Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mkhamoyan mkhamoyan marked this pull request as ready for review September 16, 2022 10:25
@mkhamoyan mkhamoyan requested a review from steveisok September 16, 2022 10:25
{
private string GetIsolatedStorageRoot()
{
return Helper.GetRootDirectory(Scope);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the mono implementation you linked the code appends .isolated-storage at the very end and I can't see it anywhere in your PR. Is that done somewhere else?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the latest change will change the behavior of all platforms, not just the mobile ones, right? I'm not sure if that's something we can/should do, because it could lead to the same problem just on different platforms.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does .config get appended to the path on mobile if IsolatedStorageDirectoryName is just .isolated-storage?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in all cases config is appended
( in legacy mono also https://github.com/mono/mono/blob/b40e9939a7d07b30a75625692874f02bcc9be18f/mcs/class/corlib/System/Environment.cs#L623 ). During testing I noticed in some cases there was .config added and I think it was done by GetDataDirectory , it will be included in dataDirectory https://github.com/dotnet/runtime/blob/main/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.Win32Unix.cs#L26

@mkhamoyan
Copy link
Contributor Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -5,22 +5,22 @@ namespace System.IO.IsolatedStorage
{
internal static partial class Helper
{
private const string IsolatedStorageDirectoryName = "IsolatedStorage";
private const string IsolatedStorageDirectoryName = ".isolated-storage";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this change apply to all configurations? If so, we need to make it mobile specific as to not break everyone else.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does seem like this file is used by non-mobile platforms as well. I saw that in the original issue discussion, .config/.isolated-storage was mentioned primarily as a workaround to access legacy files (files created when the App was using Xamarin instead of .net 6) to then call System.IO.File.

Is the change IsolatedStorage -> .isolated-storage to address accessing files created by the App when it was running on legacy code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

/// and a set of random directory names if not roaming. (The random directories aren't created for WinRT as
/// the FolderPath locations for WinRT are app isolated already.)
///
/// Examples:
///
/// User: @"C:\Users\jerem\AppData\Local\IsolatedStorage\10v31ho4.bo2\eeolfu22.f2w\"
/// User|Roaming: @"C:\Users\jerem\AppData\Roaming\IsolatedStorage\"
/// Machine: @"C:\ProgramData\IsolatedStorage\nin03cyc.wr0\o3j0urs3.0sn\"
/// User|Roaming: @"C:\Users\jerem\AppData\Roaming\.isolated-storage\"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would provide an iOS and Android example as opposed to windows paths.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@@ -5,22 +5,22 @@ namespace System.IO.IsolatedStorage
{
internal static partial class Helper
{
private const string IsolatedStorageDirectoryName = "IsolatedStorage";
private const string IsolatedStorageDirectoryName = ".isolated-storage";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does seem like this file is used by non-mobile platforms as well. I saw that in the original issue discussion, .config/.isolated-storage was mentioned primarily as a workaround to access legacy files (files created when the App was using Xamarin instead of .net 6) to then call System.IO.File.

Is the change IsolatedStorage -> .isolated-storage to address accessing files created by the App when it was running on legacy code?

@@ -45,7 +45,7 @@ public void GetDataDirectory(IsolatedStorageScope scope)
return;

string path = Helper.GetDataDirectory(scope);
Assert.Equal("IsolatedStorage", Path.GetFileName(path));
Assert.Equal(".isolated-storage", Path.GetFileName(path));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are keeping IsolatedStorage on non-mobile platforms, we can have different assert expectations for mobile/non-mobile, or a test to be ran on mobile and a test to be ran on non-mobile

Copy link
Contributor Author

@mkhamoyan mkhamoyan Sep 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

s_roots.Add(Helper.GetDataDirectory(IsolatedStorageScope.Machine));
}

s_roots = GetRoots();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What tests are failing if this isn't changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As roots are different for mobile and non mobile platforms I needed to implement differently for them.

@mkhamoyan
Copy link
Contributor Author

/azp run runtime-extra-platforms

@mkhamoyan mkhamoyan requested a review from steveisok September 20, 2022 09:00
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -5,14 +5,14 @@ namespace System.IO.IsolatedStorage
{
internal static partial class Helper
{
private const string IsolatedStorageDirectoryName = "IsolatedStorage";
public static string IsolatedStorageDirectoryName { get; set;} = "IsolatedStorage";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can have a Helper.AnyMobile.cs and a Helper.NonMobile.cs that has the old string const behavior and you would not need to have an Initialize method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Copy link
Member

@steveisok steveisok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outside of my one comment, I think it looks good.

@mkhamoyan
Copy link
Contributor Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mkhamoyan
Copy link
Contributor Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@mdh1418 mdh1418 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we shouldn't just remove the generated hash identity like this (i.e. removing IdentityHash). Thats the Url.j1gfq4nxq1m4zfi31rjvtcuna3umf3fb in the file path of the reported issues' description right? It feels like the identity hash would prevent some sort of collision, but I'm not certain. I'm imagining something like two different applications that just so happen to store their own version of a file file.txt and that the IdentityHash helps distinguish the files so that they wouldn't be unwantedly modified by a different app. If this is the case, then it seems like a bug for iOS that should be fixed (since it was stated that the hash stays the same on Android).

@mkhamoyan mkhamoyan merged commit bc27a6a into dotnet:main Sep 27, 2022
@steveisok
Copy link
Member

I'm imagining something like two different applications that just so happen to store their own version of a file file.txt and that the IdentityHash helps distinguish the files so that they wouldn't be unwantedly modified by a different app. If this is the case, then it seems like a bug for iOS that should be fixed (since it was stated that the hash stays the same on Android).

On disk, each app has it's own directory, so I'm not concerned about collisions between different apps.

@steveisok
Copy link
Member

/backport to release/7.0

@github-actions
Copy link
Contributor

Started backporting to release/7.0: https://github.com/dotnet/runtime/actions/runs/3137018195

@JulieLeeMSFT
Copy link
Member

@mkhamoyan, I am looking at runtime outerloop failures. Have you checked the test failures in

Runtime-extra-platforms tests
-	System.Collections.Immutable.Tests.WorkItemExecution
-	System.Formats.Tar.Tests.WorkItemExecution
-	System.Net.Http.Functional.Tests.WorkItemExecution

@steveisok
Copy link
Member

@mkhamoyan, I am looking at runtime outerloop failures. Have you checked the test failures in

This PR doesn't appear to have anything to do with the suites you listed. Are they tvOS failures? If so, can you provide a link to where you are looking? I believe they may be known intermittent issues with devices and not problems with tests.

@ghost ghost locked as resolved and limited conversation to collaborators Oct 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IsolatedStorageFile.GetUserStoreForApplication path changes between Xamarin.iOS and .NET 6 builds on iOS
6 participants