Skip to content

Commit

Permalink
#74642 changed IsolatedStorageDirectoryName for only mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
mkhamoyan authored and github-actions committed Sep 27, 2022
1 parent b1dcdea commit a36d10d
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)</TargetFrameworks>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-MacCatalyst;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)</TargetFrameworks>
</PropertyGroup>
<!-- DesignTimeBuild requires all the TargetFramework Derived Properties to not be present in the first property group. -->
<PropertyGroup>
Expand All @@ -26,7 +26,7 @@
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'windows'">
<Compile Include="System\IO\IsolatedStorage\Helper.Win32.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'Unix'">
<ItemGroup Condition="'$(TargetPlatformIdentifier)' != 'windows'">
<Compile Include="System\IO\IsolatedStorage\Helper.Unix.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// <summary>
/// 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.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser</TargetFrameworks>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-MacCatalyst;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Android</TargetFrameworks>
<IgnoreForCI Condition="'$(TargetOS)' == 'Browser'">true</IgnoreForCI>
</PropertyGroup>
<ItemGroup>
Expand All @@ -17,7 +17,7 @@
<Compile Include="..\src\System\IO\IsolatedStorage\Helper.Win32.cs"
Link="Internals\Helper.Win32.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'Unix' or '$(TargetPlatformIdentifier)' == 'Browser'">
<ItemGroup Condition="'$(TargetPlatformIdentifier)' != 'windows'">
<Compile Include="..\src\System\IO\IsolatedStorage\Helper.Unix.cs"
Link="Internals\Helper.Unix.cs" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ public static partial class TestHelper
private static List<string> GetRoots()
{
List<string> roots = new List<string>();
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;
}
}
}

0 comments on commit a36d10d

Please sign in to comment.