Skip to content

Commit ab6712a

Browse files
Use Environment.SpecialFolder.UserProfile, not SpecialFolder.Personal (#7481)
Context: dotnet/runtime#68610 Context: dotnet/android-tools@0be567a In .NET 8, a test using `SpecialFolder.Personal` failed with: [FAIL] Create table attempt failed! SQLite.SQLiteException: Could not open database file: /data/user/0/com.xamarin.customlinkdescriptionpreserve/files/Documents/TaskDB.db3 (CannotOpen) at SQLite.SQLiteConnection..ctor(SQLiteConnectionString ) at SQLite.SQLiteConnectionWithLock..ctor(SQLiteConnectionString ) at SQLite.SQLiteConnectionPool.Entry..ctor(SQLiteConnectionString ) at SQLite.SQLiteConnectionPool.GetConnectionAndTransactionLock(SQLiteConnectionString , Object& ) at SQLite.SQLiteConnectionPool.GetConnection(SQLiteConnectionString ) at SQLite.SQLiteAsyncConnection.GetConnection() at SQLite.SQLiteAsyncConnection.<>c__DisplayClass33_0`1[[SQLite.CreateTableResult, SQLite-net, Version=1.7.335.0, Culture=neutral, PublicKeyToken=null]].<WriteAsync>b__0() at System.Threading.Tasks.Task`1[[SQLite.CreateTableResult, SQLite-net, Version=1.7.335.0, Culture=neutral, PublicKeyToken=null]].InnerInvoke() at System.Threading.Tasks.Task.<>c.<.cctor>b__273_0(Object ) at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread , ExecutionContext , ContextCallback , Object ) --- End of stack trace from previous location --- at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread , ExecutionContext , ContextCallback , Object ) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& , Thread ) --- End of stack trace from previous location --- at LinkTestLib.Bug35195.AttemptCreateTable() All regression tests completed. In .NET 8+, we should use `SpecialFolder.UserProfile` instead.
1 parent fb63684 commit ab6712a

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public static partial class Defaults
232232
public static partial class Paths
233233
{
234234
// Global, compile-time locations
235-
public static readonly string HomeDir = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
235+
public static readonly string HomeDir = Environment.GetFolderPath (Environment.SpecialFolder.UserProfile);
236236
public static readonly string BootstrapResourcesDir = Path.Combine (BuildPaths.XAPrepareSourceDir, "Resources");
237237
public static readonly string BuildToolsDir = Path.Combine (BuildPaths.XamarinAndroidSourceRoot, "build-tools");
238238
public static readonly string BuildToolsScriptsDir = Path.Combine (BuildToolsDir, "scripts");

src-ThirdParty/NUnitLite/Env.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class Env
5050
#if SILVERLIGHT || PocketPC || WindowsCE || NETCF
5151
public static string DocumentFolder = @"\My Documents";
5252
#else
53-
public static string DocumentFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
53+
public static string DocumentFolder = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
5454
#endif
5555
}
5656
}

tests/MSBuildDeviceIntegration/Resources/LinkDescTest/Bug35195.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public static string AttemptCreateTable ()
1212
try {
1313
// Initialize the database name.
1414
const string sqliteFilename = "TaskDB.db3";
15-
string libraryPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
15+
string libraryPath = Environment.GetFolderPath (Environment.SpecialFolder.UserProfile);
1616
string path = Path.Combine (libraryPath, sqliteFilename);
1717
var db = new SQLiteAsyncConnection (path);
1818
db.CreateTableAsync<TodoTask> ().GetAwaiter ().GetResult ();

tests/Mono.Android-Tests/Mono.Data.Sqlite/SqliteTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static ItemsDb ()
4141

4242
ItemsDb ()
4343
{
44-
dbPath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), fileName);
44+
dbPath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.UserProfile), fileName);
4545
}
4646

4747
SqliteConnection GetConnection ()

0 commit comments

Comments
 (0)