From 90344969be4457f6a3cf31c70c1572ca2e47d7d4 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 13 Sep 2022 17:18:44 +0200 Subject: [PATCH 01/11] #74642 changed isolatedstorage path --- .../src/System/IO/IsolatedStorage/Helper.Win32Unix.cs | 9 +++------ .../src/System/IO/IsolatedStorage/IsolatedStorage.cs | 10 +--------- .../System/IO/IsolatedStorage/IsolatedStorageFile.cs | 3 --- .../tests/System/IO/IsolatedStorage/HelperTests.cs | 11 ++--------- .../tests/System/IO/IsolatedStorage/TestHelper.cs | 7 +++---- 5 files changed, 9 insertions(+), 31 deletions(-) diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.Win32Unix.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.Win32Unix.cs index 5a55e866789ee1..8da46b92c98e88 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.Win32Unix.cs +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.Win32Unix.cs @@ -30,7 +30,7 @@ internal static string GetDataDirectory(IsolatedStorageScope scope) [UnconditionalSuppressMessage("SingleFile", "IL3000:Avoid accessing Assembly file path when publishing as a single file", Justification = "Code handles single-file deployment by using the information of the .exe file")] - internal static void GetDefaultIdentityAndHash(out object identity, out string hash, char separator) + internal static void GetDefaultIdentityAndHash(out object identity, char separator) { // In .NET Framework IsolatedStorage uses identity from System.Security.Policy.Evidence to build // the folder structure on disk. It would use the "best" available evidence in this order: @@ -56,10 +56,9 @@ internal static void GetDefaultIdentityAndHash(out object identity, out string h { AssemblyName assemblyName = assembly.GetName(); - hash = IdentityHelper.GetNormalizedStrongNameHash(assemblyName)!; + string hash = IdentityHelper.GetNormalizedStrongNameHash(assemblyName)!; if (hash != null) { - hash = "StrongName" + separator + hash; identity = assemblyName; return; } @@ -74,9 +73,7 @@ internal static void GetDefaultIdentityAndHash(out object identity, out string h location = Environment.ProcessPath; if (string.IsNullOrEmpty(location)) throw new IsolatedStorageException(SR.IsolatedStorage_Init); - Uri locationUri = new Uri(location); - hash = "Url" + separator + IdentityHelper.GetNormalizedUriHash(locationUri); - identity = locationUri; + identity = new Uri(location); } internal static string GetRandomDirectory(string rootDirectory, IsolatedStorageScope scope) diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorage.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorage.cs index 78dab308838122..1cf23777ad4486 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorage.cs +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorage.cs @@ -127,11 +127,6 @@ public virtual bool IncreaseQuotaTo(long newQuotaSize) public abstract void Remove(); - internal string? IdentityHash - { - get; private set; - } - protected void InitStore(IsolatedStorageScope scope, Type appEvidenceType) { InitStore(scope, null, appEvidenceType); @@ -142,7 +137,7 @@ protected void InitStore(IsolatedStorageScope scope, Type? domainEvidenceType, T VerifyScope(scope); Scope = scope; - Helper.GetDefaultIdentityAndHash(out object identity, out string hash, SeparatorInternal); + Helper.GetDefaultIdentityAndHash(out object identity, SeparatorInternal); if (Helper.IsApplication(scope)) { @@ -153,13 +148,10 @@ protected void InitStore(IsolatedStorageScope scope, Type? domainEvidenceType, T if (Helper.IsDomain(scope)) { _domainIdentity = identity; - hash = string.Create(null, stackalloc char[128], $"{hash}{SeparatorExternal}{hash}"); } _assemblyIdentity = identity; } - - IdentityHash = hash; } private static void VerifyScope(IsolatedStorageScope scope) diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.cs index 0f024ca64fb23f..cc64b3771b8dad 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.cs +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.cs @@ -40,13 +40,10 @@ internal IsolatedStorageFile(IsolatedStorageScope scope) // Evidence isn't currently available: https://github.com/dotnet/runtime/issues/18208 // public static IsolatedStorageFile GetStore(IsolatedStorageScope scope, Evidence domainEvidence, Type domainEvidenceType, Evidence assemblyEvidence, Type assemblyEvidenceType) { return default(IsolatedStorageFile); } - // InitStore will set up the IdentityHash InitStore(scope, null, null); StringBuilder sb = new StringBuilder(Helper.GetRootDirectory(scope)); sb.Append(SeparatorExternal); - sb.Append(IdentityHash); - sb.Append(SeparatorExternal); if (Helper.IsApplication(scope)) { diff --git a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/HelperTests.cs b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/HelperTests.cs index 2fe50e59055320..bdf9771d1f73f1 100644 --- a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/HelperTests.cs +++ b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/HelperTests.cs @@ -12,23 +12,16 @@ public partial class HelperTests public void GetDefaultIdentityAndHash() { object identity; - string hash; - Helper.GetDefaultIdentityAndHash(out identity, out hash, '.'); + Helper.GetDefaultIdentityAndHash(out identity, '.'); Assert.NotNull(identity); - Assert.NotNull(hash); // We lie about the identity type when creating the folder structure as we're emulating the Evidence types // we don't have available in .NET Standard. We don't serialize the actual identity object, so the desktop // implementation will work with locations built off the hash. - if (identity.GetType() == typeof(Uri)) - { - Assert.StartsWith(@"Url.", hash); - } - else + if (identity.GetType() != typeof(Uri)) { Assert.IsType(identity); - Assert.StartsWith(@"StrongName.", hash); } } diff --git a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.cs b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.cs index e3e7f423a7b734..4589992802c7f3 100644 --- a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.cs +++ b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.cs @@ -19,16 +19,15 @@ static TestHelper() s_roots = new List(); - string hash; object identity; - Helper.GetDefaultIdentityAndHash(out identity, out hash, '.'); + Helper.GetDefaultIdentityAndHash(out identity, '.'); string userRoot = Helper.GetDataDirectory(IsolatedStorageScope.User); string randomUserRoot = Helper.GetRandomDirectory(userRoot, IsolatedStorageScope.User); - s_roots.Add(Path.Combine(randomUserRoot, hash)); + s_roots.Add(randomUserRoot); // Application scope doesn't go under a random dir - s_roots.Add(Path.Combine(userRoot, hash)); + s_roots.Add(userRoot); // https://github.com/dotnet/runtime/issues/2092 // https://github.com/dotnet/runtime/issues/21742 From b5fd07f6830c9eca0fef2892fb4b19e22b86482c Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Fri, 16 Sep 2022 11:20:02 +0200 Subject: [PATCH 02/11] #74642 Refactored and changed root only for mobile --- .../src/System.IO.IsolatedStorage.csproj | 6 ++- .../IO/IsolatedStorage/Helper.Win32Unix.cs | 9 ++-- .../IO/IsolatedStorage/IsolatedStorage.cs | 10 ++++- .../IsolatedStorageFile.AnyMobile.cs | 13 ++++++ .../IsolatedStorageFile.NonMobile.cs | 19 ++++++++ .../IO/IsolatedStorage/IsolatedStorageFile.cs | 3 +- .../System.IO.IsolatedStorage.Tests.csproj | 4 ++ .../System/IO/IsolatedStorage/HelperTests.cs | 11 ++++- .../IsolatedStorage/TestHelper.AnyMobile.cs | 40 +++++++++++++++++ .../IsolatedStorage/TestHelper.NonMobile.cs | 43 +++++++++++++++++++ .../System/IO/IsolatedStorage/TestHelper.cs | 30 +------------ 11 files changed, 151 insertions(+), 37 deletions(-) create mode 100644 src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.AnyMobile.cs create mode 100644 src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.NonMobile.cs create mode 100644 src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.AnyMobile.cs create mode 100644 src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.NonMobile.cs diff --git a/src/libraries/System.IO.IsolatedStorage/src/System.IO.IsolatedStorage.csproj b/src/libraries/System.IO.IsolatedStorage/src/System.IO.IsolatedStorage.csproj index 9b5284960f9ae3..48296439379db8 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System.IO.IsolatedStorage.csproj +++ b/src/libraries/System.IO.IsolatedStorage/src/System.IO.IsolatedStorage.csproj @@ -10,9 +10,13 @@ + + - + diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.Win32Unix.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.Win32Unix.cs index 8da46b92c98e88..5a55e866789ee1 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.Win32Unix.cs +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.Win32Unix.cs @@ -30,7 +30,7 @@ internal static string GetDataDirectory(IsolatedStorageScope scope) [UnconditionalSuppressMessage("SingleFile", "IL3000:Avoid accessing Assembly file path when publishing as a single file", Justification = "Code handles single-file deployment by using the information of the .exe file")] - internal static void GetDefaultIdentityAndHash(out object identity, char separator) + internal static void GetDefaultIdentityAndHash(out object identity, out string hash, char separator) { // In .NET Framework IsolatedStorage uses identity from System.Security.Policy.Evidence to build // the folder structure on disk. It would use the "best" available evidence in this order: @@ -56,9 +56,10 @@ internal static void GetDefaultIdentityAndHash(out object identity, char separat { AssemblyName assemblyName = assembly.GetName(); - string hash = IdentityHelper.GetNormalizedStrongNameHash(assemblyName)!; + hash = IdentityHelper.GetNormalizedStrongNameHash(assemblyName)!; if (hash != null) { + hash = "StrongName" + separator + hash; identity = assemblyName; return; } @@ -73,7 +74,9 @@ internal static void GetDefaultIdentityAndHash(out object identity, char separat location = Environment.ProcessPath; if (string.IsNullOrEmpty(location)) throw new IsolatedStorageException(SR.IsolatedStorage_Init); - identity = new Uri(location); + Uri locationUri = new Uri(location); + hash = "Url" + separator + IdentityHelper.GetNormalizedUriHash(locationUri); + identity = locationUri; } internal static string GetRandomDirectory(string rootDirectory, IsolatedStorageScope scope) diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorage.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorage.cs index 1cf23777ad4486..78dab308838122 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorage.cs +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorage.cs @@ -127,6 +127,11 @@ public virtual bool IncreaseQuotaTo(long newQuotaSize) public abstract void Remove(); + internal string? IdentityHash + { + get; private set; + } + protected void InitStore(IsolatedStorageScope scope, Type appEvidenceType) { InitStore(scope, null, appEvidenceType); @@ -137,7 +142,7 @@ protected void InitStore(IsolatedStorageScope scope, Type? domainEvidenceType, T VerifyScope(scope); Scope = scope; - Helper.GetDefaultIdentityAndHash(out object identity, SeparatorInternal); + Helper.GetDefaultIdentityAndHash(out object identity, out string hash, SeparatorInternal); if (Helper.IsApplication(scope)) { @@ -148,10 +153,13 @@ protected void InitStore(IsolatedStorageScope scope, Type? domainEvidenceType, T if (Helper.IsDomain(scope)) { _domainIdentity = identity; + hash = string.Create(null, stackalloc char[128], $"{hash}{SeparatorExternal}{hash}"); } _assemblyIdentity = identity; } + + IdentityHash = hash; } private static void VerifyScope(IsolatedStorageScope scope) diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.AnyMobile.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.AnyMobile.cs new file mode 100644 index 00000000000000..24fbee531be1c0 --- /dev/null +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.AnyMobile.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.IO.IsolatedStorage +{ + public sealed partial class IsolatedStorageFile : IsolatedStorage, IDisposable + { + private string GetIsolatesStorageRoot() + { + return Helper.GetRootDirectory(Scope); + } + } +} diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.NonMobile.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.NonMobile.cs new file mode 100644 index 00000000000000..d8a5610a058162 --- /dev/null +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.NonMobile.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Text; + +namespace System.IO.IsolatedStorage +{ + public sealed partial class IsolatedStorageFile : IsolatedStorage, IDisposable + { + private string GetIsolatesStorageRoot() + { + StringBuilder root = new StringBuilder(Helper.GetRootDirectory(Scope)); + root.Append(SeparatorExternal); + root.Append(IdentityHash); + + return root.ToString(); + } + } +} diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.cs index cc64b3771b8dad..5c53462dd08bf6 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.cs +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.cs @@ -40,9 +40,10 @@ internal IsolatedStorageFile(IsolatedStorageScope scope) // Evidence isn't currently available: https://github.com/dotnet/runtime/issues/18208 // public static IsolatedStorageFile GetStore(IsolatedStorageScope scope, Evidence domainEvidence, Type domainEvidenceType, Evidence assemblyEvidence, Type assemblyEvidenceType) { return default(IsolatedStorageFile); } + // InitStore will set up the IdentityHash InitStore(scope, null, null); - StringBuilder sb = new StringBuilder(Helper.GetRootDirectory(scope)); + StringBuilder sb = new StringBuilder(GetIsolatesStorageRoot()); sb.Append(SeparatorExternal); if (Helper.IsApplication(scope)) diff --git a/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj b/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj index b075376fa8bf89..6e1c166dd8c0a5 100644 --- a/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj +++ b/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj @@ -51,6 +51,10 @@ + + diff --git a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/HelperTests.cs b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/HelperTests.cs index bdf9771d1f73f1..569f820df424fc 100644 --- a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/HelperTests.cs +++ b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/HelperTests.cs @@ -12,16 +12,23 @@ public partial class HelperTests public void GetDefaultIdentityAndHash() { object identity; - Helper.GetDefaultIdentityAndHash(out identity, '.'); + string hash; + Helper.GetDefaultIdentityAndHash(out identity, out hash, '.'); Assert.NotNull(identity); + Assert.NotNull(hash); // We lie about the identity type when creating the folder structure as we're emulating the Evidence types // we don't have available in .NET Standard. We don't serialize the actual identity object, so the desktop // implementation will work with locations built off the hash. - if (identity.GetType() != typeof(Uri)) + if (identity.GetType() == typeof(Uri)) + { + Assert.StartsWith(@"Url.", hash); + } + else if (identity.GetType() != typeof(Uri)) { Assert.IsType(identity); + Assert.StartsWith(@"StrongName.", hash); } } diff --git a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.AnyMobile.cs b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.AnyMobile.cs new file mode 100644 index 00000000000000..296eb74f071a6f --- /dev/null +++ b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.AnyMobile.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Reflection; +using System.Collections.Generic; + +namespace System.IO.IsolatedStorage +{ + public static partial class TestHelper + { + static TestHelper() + { + s_rootDirectoryProperty = typeof(IsolatedStorageFile).GetProperty("RootDirectory", BindingFlags.NonPublic | BindingFlags.Instance); + + s_roots = new List(); + + string hash; + object identity; + Helper.GetDefaultIdentityAndHash(out identity, out hash, '.'); + + string userRoot = Helper.GetDataDirectory(IsolatedStorageScope.User); + string randomUserRoot = Helper.GetRandomDirectory(userRoot, IsolatedStorageScope.User); + s_roots.Add(randomUserRoot); + + // Application scope doesn't go under a random dir + s_roots.Add(userRoot); + + // https://github.com/dotnet/runtime/issues/2092 + // https://github.com/dotnet/runtime/issues/21742 + if (OperatingSystem.IsWindows() + && !PlatformDetection.IsInAppContainer) + { + s_roots.Add(Helper.GetDataDirectory(IsolatedStorageScope.Machine)); + } + + // We don't expose Roaming yet + // Helper.GetDataDirectory(IsolatedStorageScope.Roaming); + } + } +} diff --git a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.NonMobile.cs b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.NonMobile.cs new file mode 100644 index 00000000000000..b1ab37f6ff0ec3 --- /dev/null +++ b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.NonMobile.cs @@ -0,0 +1,43 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Reflection; +using System.Collections.Generic; + +namespace System.IO.IsolatedStorage +{ + public static partial class TestHelper + { + static TestHelper() + { + s_rootDirectoryProperty = typeof(IsolatedStorageFile).GetProperty("RootDirectory", BindingFlags.NonPublic | BindingFlags.Instance); + + s_roots = new List(); + + string hash; + object identity; + Helper.GetDefaultIdentityAndHash(out identity, out hash, '.'); + + string userRoot = Helper.GetDataDirectory(IsolatedStorageScope.User); + string randomUserRoot = Helper.GetRandomDirectory(userRoot, IsolatedStorageScope.User); + s_roots.Add(Path.Combine(randomUserRoot, hash)); + s_roots.Add(randomUserRoot); + + // Application scope doesn't go under a random dir + s_roots.Add(Path.Combine(userRoot, hash)); + s_roots.Add(userRoot); + + // https://github.com/dotnet/runtime/issues/2092 + // https://github.com/dotnet/runtime/issues/21742 + if (OperatingSystem.IsWindows() + && !PlatformDetection.IsInAppContainer) + { + s_roots.Add(Helper.GetDataDirectory(IsolatedStorageScope.Machine)); + } + + // We don't expose Roaming yet + // Helper.GetDataDirectory(IsolatedStorageScope.Roaming); + } + } +} + \ No newline at end of file diff --git a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.cs b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.cs index 4589992802c7f3..65fe579a15f47e 100644 --- a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.cs +++ b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.cs @@ -8,39 +8,11 @@ namespace System.IO.IsolatedStorage { - public static class TestHelper + public static partial class TestHelper { private static PropertyInfo s_rootDirectoryProperty; private static List s_roots; - static TestHelper() - { - s_rootDirectoryProperty = typeof(IsolatedStorageFile).GetProperty("RootDirectory", BindingFlags.NonPublic | BindingFlags.Instance); - - s_roots = new List(); - - object identity; - Helper.GetDefaultIdentityAndHash(out identity, '.'); - - string userRoot = Helper.GetDataDirectory(IsolatedStorageScope.User); - string randomUserRoot = Helper.GetRandomDirectory(userRoot, IsolatedStorageScope.User); - s_roots.Add(randomUserRoot); - - // Application scope doesn't go under a random dir - s_roots.Add(userRoot); - - // https://github.com/dotnet/runtime/issues/2092 - // https://github.com/dotnet/runtime/issues/21742 - if (OperatingSystem.IsWindows() - && !PlatformDetection.IsInAppContainer) - { - s_roots.Add(Helper.GetDataDirectory(IsolatedStorageScope.Machine)); - } - - // We don't expose Roaming yet - // Helper.GetDataDirectory(IsolatedStorageScope.Roaming); - } - /// /// Where the user's files go /// From 5732db6e425de675a9de6188fc4311a1f2de2ed2 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Fri, 16 Sep 2022 11:24:10 +0200 Subject: [PATCH 03/11] #74642 minor changes --- .../src/System.IO.IsolatedStorage.csproj | 2 +- .../System/IO/IsolatedStorage/IsolatedStorageFile.AnyMobile.cs | 2 +- .../System/IO/IsolatedStorage/IsolatedStorageFile.NonMobile.cs | 2 +- .../src/System/IO/IsolatedStorage/IsolatedStorageFile.cs | 2 +- .../tests/System/IO/IsolatedStorage/HelperTests.cs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libraries/System.IO.IsolatedStorage/src/System.IO.IsolatedStorage.csproj b/src/libraries/System.IO.IsolatedStorage/src/System.IO.IsolatedStorage.csproj index 48296439379db8..a7d77006e8c604 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System.IO.IsolatedStorage.csproj +++ b/src/libraries/System.IO.IsolatedStorage/src/System.IO.IsolatedStorage.csproj @@ -16,7 +16,7 @@ Include="System\IO\IsolatedStorage\IsolatedStorageFile.NonMobile.cs" /> - + diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.AnyMobile.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.AnyMobile.cs index 24fbee531be1c0..69a2f706779084 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.AnyMobile.cs +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.AnyMobile.cs @@ -5,7 +5,7 @@ namespace System.IO.IsolatedStorage { public sealed partial class IsolatedStorageFile : IsolatedStorage, IDisposable { - private string GetIsolatesStorageRoot() + private string GetIsolatedStorageRoot() { return Helper.GetRootDirectory(Scope); } diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.NonMobile.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.NonMobile.cs index d8a5610a058162..4f547d55cff2f6 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.NonMobile.cs +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.NonMobile.cs @@ -7,7 +7,7 @@ namespace System.IO.IsolatedStorage { public sealed partial class IsolatedStorageFile : IsolatedStorage, IDisposable { - private string GetIsolatesStorageRoot() + private string GetIsolatedStorageRoot() { StringBuilder root = new StringBuilder(Helper.GetRootDirectory(Scope)); root.Append(SeparatorExternal); diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.cs index 5c53462dd08bf6..4afd6468ceaa3c 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.cs +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.cs @@ -43,7 +43,7 @@ internal IsolatedStorageFile(IsolatedStorageScope scope) // InitStore will set up the IdentityHash InitStore(scope, null, null); - StringBuilder sb = new StringBuilder(GetIsolatesStorageRoot()); + StringBuilder sb = new StringBuilder(GetIsolatedStorageRoot()); sb.Append(SeparatorExternal); if (Helper.IsApplication(scope)) diff --git a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/HelperTests.cs b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/HelperTests.cs index 569f820df424fc..2fe50e59055320 100644 --- a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/HelperTests.cs +++ b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/HelperTests.cs @@ -25,7 +25,7 @@ public void GetDefaultIdentityAndHash() { Assert.StartsWith(@"Url.", hash); } - else if (identity.GetType() != typeof(Uri)) + else { Assert.IsType(identity); Assert.StartsWith(@"StrongName.", hash); From 254242f1269eb6c92e313b02ee47c991ad7d84f0 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Fri, 16 Sep 2022 11:52:12 +0200 Subject: [PATCH 04/11] #74642 removed redundunt code --- .../IsolatedStorage/TestHelper.AnyMobile.cs | 26 +++---------------- .../IsolatedStorage/TestHelper.NonMobile.cs | 21 +++++---------- .../System/IO/IsolatedStorage/TestHelper.cs | 10 +++++++ 3 files changed, 21 insertions(+), 36 deletions(-) diff --git a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.AnyMobile.cs b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.AnyMobile.cs index 296eb74f071a6f..62c37935dfdd21 100644 --- a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.AnyMobile.cs +++ b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.AnyMobile.cs @@ -8,33 +8,15 @@ namespace System.IO.IsolatedStorage { public static partial class TestHelper { - static TestHelper() + private static List GetRoots() { - s_rootDirectoryProperty = typeof(IsolatedStorageFile).GetProperty("RootDirectory", BindingFlags.NonPublic | BindingFlags.Instance); - - s_roots = new List(); - - string hash; - object identity; - Helper.GetDefaultIdentityAndHash(out identity, out hash, '.'); - + List roots = new List(); string userRoot = Helper.GetDataDirectory(IsolatedStorageScope.User); string randomUserRoot = Helper.GetRandomDirectory(userRoot, IsolatedStorageScope.User); - s_roots.Add(randomUserRoot); + roots.Add(randomUserRoot); // Application scope doesn't go under a random dir - s_roots.Add(userRoot); - - // https://github.com/dotnet/runtime/issues/2092 - // https://github.com/dotnet/runtime/issues/21742 - if (OperatingSystem.IsWindows() - && !PlatformDetection.IsInAppContainer) - { - s_roots.Add(Helper.GetDataDirectory(IsolatedStorageScope.Machine)); - } - - // We don't expose Roaming yet - // Helper.GetDataDirectory(IsolatedStorageScope.Roaming); + roots.Add(userRoot); } } } diff --git a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.NonMobile.cs b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.NonMobile.cs index b1ab37f6ff0ec3..e0217dc241a5a9 100644 --- a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.NonMobile.cs +++ b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.NonMobile.cs @@ -8,35 +8,28 @@ namespace System.IO.IsolatedStorage { public static partial class TestHelper { - static TestHelper() + private static List GetRoots() { - s_rootDirectoryProperty = typeof(IsolatedStorageFile).GetProperty("RootDirectory", BindingFlags.NonPublic | BindingFlags.Instance); - - s_roots = new List(); - string hash; object identity; Helper.GetDefaultIdentityAndHash(out identity, out hash, '.'); - + List roots = new List(); string userRoot = Helper.GetDataDirectory(IsolatedStorageScope.User); string randomUserRoot = Helper.GetRandomDirectory(userRoot, IsolatedStorageScope.User); - s_roots.Add(Path.Combine(randomUserRoot, hash)); - s_roots.Add(randomUserRoot); - + + roots.Add(Path.Combine(randomUserRoot, hash)); // Application scope doesn't go under a random dir - s_roots.Add(Path.Combine(userRoot, hash)); - s_roots.Add(userRoot); + roots.Add(Path.Combine(userRoot, hash)); // https://github.com/dotnet/runtime/issues/2092 // https://github.com/dotnet/runtime/issues/21742 if (OperatingSystem.IsWindows() && !PlatformDetection.IsInAppContainer) { - s_roots.Add(Helper.GetDataDirectory(IsolatedStorageScope.Machine)); + roots.Add(Helper.GetDataDirectory(IsolatedStorageScope.Machine)); } - // We don't expose Roaming yet - // Helper.GetDataDirectory(IsolatedStorageScope.Roaming); + return roots; } } } diff --git a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.cs b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.cs index 65fe579a15f47e..06339504237ddd 100644 --- a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.cs +++ b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.cs @@ -13,6 +13,16 @@ public static partial class TestHelper private static PropertyInfo s_rootDirectoryProperty; private static List s_roots; + static TestHelper() + { + s_rootDirectoryProperty = typeof(IsolatedStorageFile).GetProperty("RootDirectory", BindingFlags.NonPublic | BindingFlags.Instance); + + s_roots = GetRoots(); + + // We don't expose Roaming yet + // Helper.GetDataDirectory(IsolatedStorageScope.Roaming); + } + /// /// Where the user's files go /// From b82803278ea92182d2c9ac19cc5f4b6d40adb24b Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Fri, 16 Sep 2022 15:52:45 +0200 Subject: [PATCH 05/11] #74642 rename IsolatedStorageDirectoryName --- .../src/System/IO/IsolatedStorage/Helper.Win32Unix.cs | 2 +- .../src/System/IO/IsolatedStorage/Helper.cs | 4 ++-- .../tests/System/IO/IsolatedStorage/HelperTests.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.Win32Unix.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.Win32Unix.cs index 5a55e866789ee1..b3644c7b8adada 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.Win32Unix.cs +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.Win32Unix.cs @@ -12,7 +12,7 @@ internal static partial class Helper { internal static string GetDataDirectory(IsolatedStorageScope scope) { - // This is the relevant special folder for the given scope plus "IsolatedStorage". + // This is the relevant special folder for the given scope plus ".isolated-storage". // It is meant to replicate the behavior of the VM ComIsolatedStorage::GetRootDir(). // (note that Silverlight used "CoreIsolatedStorage" for a directory name and did not support machine scope) diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.cs index 3b5d6b6afbc7c5..5d00b5ef6fe67c 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.cs +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.cs @@ -5,14 +5,14 @@ namespace System.IO.IsolatedStorage { internal static partial class Helper { - private const string IsolatedStorageDirectoryName = "IsolatedStorage"; + private const string IsolatedStorageDirectoryName = ".isolated-storage"; private static string? s_machineRootDirectory; private static string? s_roamingUserRootDirectory; private static string? s_userRootDirectory; /// - /// The full root directory is the relevant special folder from Environment.GetFolderPath() plus "IsolatedStorage" + /// The full root directory is the relevant special folder from Environment.GetFolderPath() plus ".isolated-storage" /// 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.) /// diff --git a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/HelperTests.cs b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/HelperTests.cs index 2fe50e59055320..69cee4db686405 100644 --- a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/HelperTests.cs +++ b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/HelperTests.cs @@ -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)); } } } From 37140e3eaef1051ecca181c61dbc34c0060dae9e Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Fri, 16 Sep 2022 15:53:17 +0200 Subject: [PATCH 06/11] #74642 change also in comments --- .../src/System/IO/IsolatedStorage/Helper.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.cs index 5d00b5ef6fe67c..197cd50437e58f 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.cs +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.cs @@ -19,8 +19,8 @@ internal static partial class Helper /// 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\" + /// Machine: @"C:\ProgramData\.isolated-storage\nin03cyc.wr0\o3j0urs3.0sn\" /// /// Identity for the current store gets tacked on after this. /// From ff6cadb263a6e6d345eb5eeecdf415d205fb6992 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 20 Sep 2022 10:41:12 +0200 Subject: [PATCH 07/11] #74642 changed IsolatedStorageDirectoryName for only mobile --- .../src/System.IO.IsolatedStorage.csproj | 4 ++-- .../src/System/IO/IsolatedStorage/Helper.cs | 10 ++++++---- .../IsolatedStorage/IsolatedStorageFile.AnyMobile.cs | 6 ++++++ .../IsolatedStorage/IsolatedStorageFile.NonMobile.cs | 5 +++++ .../System/IO/IsolatedStorage/IsolatedStorageFile.cs | 5 ++++- .../tests/System.IO.IsolatedStorage.Tests.csproj | 4 ++-- .../tests/System/IO/IsolatedStorage/HelperTests.cs | 3 ++- .../System/IO/IsolatedStorage/TestHelper.AnyMobile.cs | 2 ++ 8 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/libraries/System.IO.IsolatedStorage/src/System.IO.IsolatedStorage.csproj b/src/libraries/System.IO.IsolatedStorage/src/System.IO.IsolatedStorage.csproj index a7d77006e8c604..bbe569e513958c 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System.IO.IsolatedStorage.csproj +++ b/src/libraries/System.IO.IsolatedStorage/src/System.IO.IsolatedStorage.csproj @@ -1,6 +1,6 @@ - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-MacCatalyst;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent) @@ -26,7 +26,7 @@ - + diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.cs index 197cd50437e58f..89667b707887dd 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.cs +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.cs @@ -5,22 +5,24 @@ namespace System.IO.IsolatedStorage { internal static partial class Helper { - private const string IsolatedStorageDirectoryName = ".isolated-storage"; + public static string IsolatedStorageDirectoryName { get; set;} = "IsolatedStorage"; private static string? s_machineRootDirectory; private static string? s_roamingUserRootDirectory; private static string? s_userRootDirectory; /// - /// The full root directory is the relevant special folder from Environment.GetFolderPath() plus ".isolated-storage" + /// The full root directory is the relevant special folder from Environment.GetFolderPath() plus IsolatedStorageDirectoryName /// 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\.isolated-storage\" - /// Machine: @"C:\ProgramData\.isolated-storage\nin03cyc.wr0\o3j0urs3.0sn\" + /// User|Roaming: @"C:\Users\jerem\AppData\Roaming\IsolatedStorage\" + /// Machine: @"C:\ProgramData\IsolatedStorage\nin03cyc.wr0\o3j0urs3.0sn\" + /// Android path: "/data/user/0/net.dot.System.IO.IsolatedStorage.Tests/files/.config/.isolated-storage/" + /// iOS path: "/var/mobile/Containers/Data/Application/A323CBB9-A2B3-4432-9449-48CC20C07A7D/Documents/.config/.isolated-storage/" /// /// Identity for the current store gets tacked on after this. /// diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.AnyMobile.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.AnyMobile.cs index 69a2f706779084..204e1876c4e6ab 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.AnyMobile.cs +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.AnyMobile.cs @@ -5,6 +5,12 @@ namespace System.IO.IsolatedStorage { public sealed partial class IsolatedStorageFile : IsolatedStorage, IDisposable { + + private static void InitializeIsoStorageDirectoryName() + { + Helper.IsolatedStorageDirectoryName = ".isolated-storage"; + } + private string GetIsolatedStorageRoot() { return Helper.GetRootDirectory(Scope); diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.NonMobile.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.NonMobile.cs index 4f547d55cff2f6..d410f64adc3d0e 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.NonMobile.cs +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.NonMobile.cs @@ -7,6 +7,11 @@ namespace System.IO.IsolatedStorage { public sealed partial class IsolatedStorageFile : IsolatedStorage, IDisposable { + private static void InitializeIsoStorageDirectoryName() + { + Helper.IsolatedStorageDirectoryName = "IsolatedStorage"; + } + private string GetIsolatedStorageRoot() { StringBuilder root = new StringBuilder(Helper.GetRootDirectory(Scope)); diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.cs index 4afd6468ceaa3c..e8c4522637b77e 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.cs +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.cs @@ -40,7 +40,10 @@ internal IsolatedStorageFile(IsolatedStorageScope scope) // Evidence isn't currently available: https://github.com/dotnet/runtime/issues/18208 // public static IsolatedStorageFile GetStore(IsolatedStorageScope scope, Evidence domainEvidence, Type domainEvidenceType, Evidence assemblyEvidence, Type assemblyEvidenceType) { return default(IsolatedStorageFile); } - // InitStore will set up the IdentityHash + // for non mobile platforms IsolatedStorageDirectoryName is "IsolatedStorage", for mobile platforms ".isolated-storage" + InitializeIsoStorageDirectoryName(); + + // InitStore will set up the IdentityHash InitStore(scope, null, null); StringBuilder sb = new StringBuilder(GetIsolatedStorageRoot()); diff --git a/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj b/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj index 6e1c166dd8c0a5..7fe0785f898c1c 100644 --- a/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj +++ b/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj @@ -1,6 +1,6 @@ - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-MacCatalyst;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Android true @@ -17,7 +17,7 @@ - + diff --git a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/HelperTests.cs b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/HelperTests.cs index 69cee4db686405..01f5f968c8245d 100644 --- a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/HelperTests.cs +++ b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/HelperTests.cs @@ -13,6 +13,7 @@ public void GetDefaultIdentityAndHash() { object identity; string hash; + //TestHelper.InitHelper(out identity,out hash); Helper.GetDefaultIdentityAndHash(out identity, out hash, '.'); Assert.NotNull(identity); @@ -45,7 +46,7 @@ public void GetDataDirectory(IsolatedStorageScope scope) return; string path = Helper.GetDataDirectory(scope); - Assert.Equal(".isolated-storage", Path.GetFileName(path)); + Assert.Equal(Helper.IsolatedStorageDirectoryName, Path.GetFileName(path)); } } } diff --git a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.AnyMobile.cs b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.AnyMobile.cs index 62c37935dfdd21..b622356e0022f2 100644 --- a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.AnyMobile.cs +++ b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.AnyMobile.cs @@ -11,12 +11,14 @@ public static partial class TestHelper private static List GetRoots() { List roots = new List(); + Helper.IsolatedStorageDirectoryName = ".isolated-storage"; string userRoot = Helper.GetDataDirectory(IsolatedStorageScope.User); string randomUserRoot = Helper.GetRandomDirectory(userRoot, IsolatedStorageScope.User); roots.Add(randomUserRoot); // Application scope doesn't go under a random dir roots.Add(userRoot); + return roots; } } } From 3bf593aa5ddd7d1c88c717fa76a4202748bab025 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 20 Sep 2022 10:54:45 +0200 Subject: [PATCH 08/11] #74642 done minor changes --- .../src/System/IO/IsolatedStorage/Helper.Win32Unix.cs | 2 +- .../src/System/IO/IsolatedStorage/IsolatedStorageFile.cs | 2 +- .../tests/System/IO/IsolatedStorage/HelperTests.cs | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.Win32Unix.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.Win32Unix.cs index b3644c7b8adada..7577ea7ee0495b 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.Win32Unix.cs +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.Win32Unix.cs @@ -12,7 +12,7 @@ internal static partial class Helper { internal static string GetDataDirectory(IsolatedStorageScope scope) { - // This is the relevant special folder for the given scope plus ".isolated-storage". + // This is the relevant special folder for the given scope plus IsolatedStorageDirectoryName. // It is meant to replicate the behavior of the VM ComIsolatedStorage::GetRootDir(). // (note that Silverlight used "CoreIsolatedStorage" for a directory name and did not support machine scope) diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.cs index e8c4522637b77e..c72da4b57dc35c 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.cs +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.cs @@ -43,7 +43,7 @@ internal IsolatedStorageFile(IsolatedStorageScope scope) // for non mobile platforms IsolatedStorageDirectoryName is "IsolatedStorage", for mobile platforms ".isolated-storage" InitializeIsoStorageDirectoryName(); - // InitStore will set up the IdentityHash + // InitStore will set up the IdentityHash InitStore(scope, null, null); StringBuilder sb = new StringBuilder(GetIsolatedStorageRoot()); diff --git a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/HelperTests.cs b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/HelperTests.cs index 01f5f968c8245d..60d65949da7ee2 100644 --- a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/HelperTests.cs +++ b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/HelperTests.cs @@ -13,7 +13,6 @@ public void GetDefaultIdentityAndHash() { object identity; string hash; - //TestHelper.InitHelper(out identity,out hash); Helper.GetDefaultIdentityAndHash(out identity, out hash, '.'); Assert.NotNull(identity); From d5b24147b510790e1f29ff4a8b378f0654710c19 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 26 Sep 2022 10:45:54 +0200 Subject: [PATCH 09/11] #74642 made IsolatedStorageDirectoryName const --- .../src/System.IO.IsolatedStorage.csproj | 14 +++++++++----- .../System/IO/IsolatedStorage/Helper.AnyMobile.cs | 10 ++++++++++ .../System/IO/IsolatedStorage/Helper.NonMobile.cs | 10 ++++++++++ .../src/System/IO/IsolatedStorage/Helper.cs | 2 -- .../IsolatedStorageFile.AnyMobile.cs | 6 ------ .../IsolatedStorageFile.NonMobile.cs | 5 ----- .../IO/IsolatedStorage/IsolatedStorageFile.cs | 3 --- .../tests/System.IO.IsolatedStorage.Tests.csproj | 14 +++++++++----- .../IO/IsolatedStorage/TestHelper.AnyMobile.cs | 1 - 9 files changed, 38 insertions(+), 27 deletions(-) create mode 100644 src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.AnyMobile.cs create mode 100644 src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.NonMobile.cs diff --git a/src/libraries/System.IO.IsolatedStorage/src/System.IO.IsolatedStorage.csproj b/src/libraries/System.IO.IsolatedStorage/src/System.IO.IsolatedStorage.csproj index bbe569e513958c..a6044a70f5e324 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System.IO.IsolatedStorage.csproj +++ b/src/libraries/System.IO.IsolatedStorage/src/System.IO.IsolatedStorage.csproj @@ -9,11 +9,7 @@ - - - + @@ -23,6 +19,14 @@ + + + + + + + + diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.AnyMobile.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.AnyMobile.cs new file mode 100644 index 00000000000000..4121814515fe67 --- /dev/null +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.AnyMobile.cs @@ -0,0 +1,10 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.IO.IsolatedStorage +{ + internal static partial class Helper + { + public const string IsolatedStorageDirectoryName = ".isolated-storage"; + } +} diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.NonMobile.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.NonMobile.cs new file mode 100644 index 00000000000000..cde27b6c5e27c4 --- /dev/null +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.NonMobile.cs @@ -0,0 +1,10 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.IO.IsolatedStorage +{ + internal static partial class Helper + { + public const string IsolatedStorageDirectoryName = "IsolatedStorage"; + } +} diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.cs index 89667b707887dd..984eeed4046067 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.cs +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/Helper.cs @@ -5,8 +5,6 @@ namespace System.IO.IsolatedStorage { internal static partial class Helper { - public static string IsolatedStorageDirectoryName { get; set;} = "IsolatedStorage"; - private static string? s_machineRootDirectory; private static string? s_roamingUserRootDirectory; private static string? s_userRootDirectory; diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.AnyMobile.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.AnyMobile.cs index 204e1876c4e6ab..69a2f706779084 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.AnyMobile.cs +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.AnyMobile.cs @@ -5,12 +5,6 @@ namespace System.IO.IsolatedStorage { public sealed partial class IsolatedStorageFile : IsolatedStorage, IDisposable { - - private static void InitializeIsoStorageDirectoryName() - { - Helper.IsolatedStorageDirectoryName = ".isolated-storage"; - } - private string GetIsolatedStorageRoot() { return Helper.GetRootDirectory(Scope); diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.NonMobile.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.NonMobile.cs index d410f64adc3d0e..4f547d55cff2f6 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.NonMobile.cs +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.NonMobile.cs @@ -7,11 +7,6 @@ namespace System.IO.IsolatedStorage { public sealed partial class IsolatedStorageFile : IsolatedStorage, IDisposable { - private static void InitializeIsoStorageDirectoryName() - { - Helper.IsolatedStorageDirectoryName = "IsolatedStorage"; - } - private string GetIsolatedStorageRoot() { StringBuilder root = new StringBuilder(Helper.GetRootDirectory(Scope)); diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.cs index c72da4b57dc35c..4afd6468ceaa3c 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.cs +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.cs @@ -40,9 +40,6 @@ internal IsolatedStorageFile(IsolatedStorageScope scope) // Evidence isn't currently available: https://github.com/dotnet/runtime/issues/18208 // public static IsolatedStorageFile GetStore(IsolatedStorageScope scope, Evidence domainEvidence, Type domainEvidenceType, Evidence assemblyEvidence, Type assemblyEvidenceType) { return default(IsolatedStorageFile); } - // for non mobile platforms IsolatedStorageDirectoryName is "IsolatedStorage", for mobile platforms ".isolated-storage" - InitializeIsoStorageDirectoryName(); - // InitStore will set up the IdentityHash InitStore(scope, null, null); diff --git a/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj b/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj index 7fe0785f898c1c..21e81c2185b2ca 100644 --- a/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj +++ b/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj @@ -50,12 +50,16 @@ - - - + + + + + + + + + diff --git a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.AnyMobile.cs b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.AnyMobile.cs index b622356e0022f2..63709fd41ab837 100644 --- a/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.AnyMobile.cs +++ b/src/libraries/System.IO.IsolatedStorage/tests/System/IO/IsolatedStorage/TestHelper.AnyMobile.cs @@ -11,7 +11,6 @@ public static partial class TestHelper private static List GetRoots() { List roots = new List(); - Helper.IsolatedStorageDirectoryName = ".isolated-storage"; string userRoot = Helper.GetDataDirectory(IsolatedStorageScope.User); string randomUserRoot = Helper.GetRandomDirectory(userRoot, IsolatedStorageScope.User); roots.Add(randomUserRoot); From 4f2e3fdcf9e33b92c39dee09b4a833df751fa229 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 26 Sep 2022 10:49:40 +0200 Subject: [PATCH 10/11] #74642 removed whitespaces --- .../src/System.IO.IsolatedStorage.csproj | 2 +- .../tests/System.IO.IsolatedStorage.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.IO.IsolatedStorage/src/System.IO.IsolatedStorage.csproj b/src/libraries/System.IO.IsolatedStorage/src/System.IO.IsolatedStorage.csproj index a6044a70f5e324..38d52a6d6ffe21 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System.IO.IsolatedStorage.csproj +++ b/src/libraries/System.IO.IsolatedStorage/src/System.IO.IsolatedStorage.csproj @@ -9,7 +9,7 @@ - + diff --git a/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj b/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj index 21e81c2185b2ca..e8a80dc726f96c 100644 --- a/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj +++ b/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj @@ -50,7 +50,7 @@ - + From 0f8c243fbecea0b5fed9f1dd62ebeea41356a57c Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 26 Sep 2022 13:49:27 +0200 Subject: [PATCH 11/11] #74642 fix csproj for linux --- .../src/System.IO.IsolatedStorage.csproj | 2 +- .../tests/System.IO.IsolatedStorage.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.IO.IsolatedStorage/src/System.IO.IsolatedStorage.csproj b/src/libraries/System.IO.IsolatedStorage/src/System.IO.IsolatedStorage.csproj index 38d52a6d6ffe21..2309a8c007ab3f 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System.IO.IsolatedStorage.csproj +++ b/src/libraries/System.IO.IsolatedStorage/src/System.IO.IsolatedStorage.csproj @@ -23,7 +23,7 @@ - + diff --git a/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj b/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj index e8a80dc726f96c..0410513c46ceb1 100644 --- a/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj +++ b/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj @@ -57,7 +57,7 @@ - +