Skip to content

Commit 0be567a

Browse files
authored
Use Environment.SpecialFolder.UserProfile, not SpecialFolder.Personal (#194)
Context: dotnet/runtime#68610 In Mono and .NET prior to .NET 8, the [`System.Environment.SpecialFolder`][0]`.Personal` enum value would refer to `$HOME` on Unix platforms. This will be changing in .NET 8, such that `Environment.SpecialFolder.Personal` will instead refer to `$XDG_DOCUMENTS_DIR` (if set) or `$HOME/Documents`. This is for "semantic compatibility" with .NET on Windows. Replace usage of `Environment.SpecialFolder.Personal` with `Environment.SpecialFolder.UserProfile`, so that our code continues to work as expected under .NET 8. [0]: https://docs.microsoft.com/en-us/dotnet/api/system.environment.specialfolder?view=net-6.0
1 parent 29f11f2 commit 0be567a

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/Xamarin.Android.Tools.AndroidSdk/Jdks/MicrosoftDistJdkLocations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static IEnumerable<string> GetMacOSMicrosoftDistJdkPaths ()
2121
var jdks = AppDomain.CurrentDomain.GetData ($"GetMacOSMicrosoftJdkPaths jdks override! {typeof (JdkInfo).AssemblyQualifiedName}")
2222
?.ToString ();
2323
if (jdks == null) {
24-
var home = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
24+
var home = Environment.GetFolderPath (Environment.SpecialFolder.UserProfile);
2525
jdks = Path.Combine (home, "Library", "Developer", "Xamarin", "jdk");
2626
}
2727
if (!Directory.Exists (jdks))

src/Xamarin.Android.Tools.AndroidSdk/OS.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Runtime.InteropServices;
44
using System.IO;
@@ -69,15 +69,15 @@ static string GetProgramFilesX86 ()
6969
internal static string GetXamarinAndroidCacheDir ()
7070
{
7171
if (IsMac) {
72-
var home = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
72+
var home = Environment.GetFolderPath (Environment.SpecialFolder.UserProfile);
7373
return Path.Combine (home, "Library", "Caches", "Xamarin.Android");
7474
} else if (IsWindows) {
7575
var localAppData = Environment.GetFolderPath (Environment.SpecialFolder.LocalApplicationData);
7676
return Path.Combine (localAppData, "Xamarin.Android", "Cache");
7777
} else {
78-
var home = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
7978
var xdgCacheHome = Environment.GetEnvironmentVariable ("XDG_CACHE_HOME");
8079
if (string.IsNullOrEmpty (xdgCacheHome)) {
80+
var home = Environment.GetFolderPath (Environment.SpecialFolder.UserProfile);
8181
xdgCacheHome = Path.Combine (home, ".cache");
8282
}
8383
return Path.Combine (xdgCacheHome, "Xamarin.Android");

src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkUnix.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Linq;
33
using System.Collections.Generic;
44
using System.Diagnostics;
@@ -111,7 +111,7 @@ protected override IEnumerable<string> GetAllAvailableAndroidSdks ()
111111
}
112112

113113
// Check some hardcoded paths for good measure
114-
var macSdkPath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "Library", "Android", "sdk");
114+
var macSdkPath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.UserProfile), "Library", "Android", "sdk");
115115
yield return macSdkPath;
116116
}
117117

0 commit comments

Comments
 (0)