mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-15 17:10:51 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
360dca39d3 | ||
|
|
ae171d5ee6 | ||
|
|
2efd81d9ed |
No files matched your search
@@ -97,8 +97,8 @@ static gboolean no_exec = FALSE;
|
||||
|
||||
#ifdef ENABLE_NETCORE
|
||||
static int n_appctx_props;
|
||||
static char **appctx_keys;
|
||||
static char **appctx_values;
|
||||
static gunichar2 **appctx_keys;
|
||||
static gunichar2 **appctx_values;
|
||||
#endif
|
||||
|
||||
static const char *
|
||||
@@ -3336,12 +3336,12 @@ void
|
||||
mono_runtime_register_appctx_properties (int nprops, const char **keys, const char **values)
|
||||
{
|
||||
n_appctx_props = nprops;
|
||||
appctx_keys = g_new0 (char*, nprops);
|
||||
appctx_values = g_new0 (char*, nprops);
|
||||
appctx_keys = g_new0 (gunichar2*, nprops);
|
||||
appctx_values = g_new0 (gunichar2*, nprops);
|
||||
|
||||
for (int i = 0; i < nprops; ++i) {
|
||||
appctx_keys [i] = g_strdup (keys [i]);
|
||||
appctx_values [i] = g_strdup (values [i]);
|
||||
appctx_keys [i] = g_utf8_to_utf16 (keys [i], strlen (keys [i]), NULL, NULL, NULL);
|
||||
appctx_values [i] = g_utf8_to_utf16 (values [i], strlen (values [i]), NULL, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -146,7 +146,6 @@
|
||||
<Compile Include="src\Mono\MonoDomain.cs" />
|
||||
<Compile Include="src\Mono\MonoDomainSetup.cs" />
|
||||
<Compile Include="src\Mono\RuntimeHandles.cs" />
|
||||
<Compile Include="src\System\AppContext.cs" />
|
||||
<Compile Include="src\System\ArgIterator.cs" />
|
||||
<Compile Include="src\System\Array.cs" />
|
||||
<Compile Include="src\System\Attribute.cs" />
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.ExceptionServices;
|
||||
using System.Runtime.Loader;
|
||||
@@ -13,7 +15,7 @@ namespace System
|
||||
{
|
||||
public static partial class AppContext
|
||||
{
|
||||
private static readonly Dictionary<string, object?> s_dataStore = new Dictionary<string, object?>();
|
||||
private static Dictionary<string, object?>? s_dataStore;
|
||||
private static Dictionary<string, bool>? s_switches;
|
||||
private static string? s_defaultBaseDirectory;
|
||||
|
||||
@@ -33,6 +35,9 @@ namespace System
|
||||
if (name == null)
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
|
||||
if (s_dataStore == null)
|
||||
return null;
|
||||
|
||||
object? data;
|
||||
lock (s_dataStore)
|
||||
{
|
||||
@@ -46,6 +51,11 @@ namespace System
|
||||
if (name == null)
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
|
||||
if (s_dataStore == null)
|
||||
{
|
||||
Interlocked.CompareExchange(ref s_dataStore, new Dictionary<string, object?>(), null);
|
||||
}
|
||||
|
||||
lock (s_dataStore)
|
||||
{
|
||||
s_dataStore[name] = data;
|
||||
@@ -121,5 +131,26 @@ namespace System
|
||||
s_switches[switchName] = isEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
#if !CORERT
|
||||
internal static unsafe void Setup(char** pNames, char** pValues, int count)
|
||||
{
|
||||
Debug.Assert(s_dataStore == null, "s_dataStore is not expected to be inited before Setup is called");
|
||||
s_dataStore = new Dictionary<string, object?>(count);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
s_dataStore.Add(new string(pNames[i]), new string(pValues[i]));
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetBaseDirectoryCore()
|
||||
{
|
||||
// Fallback path for hosts that do not set APP_CONTEXT_BASE_DIRECTORY explicitly
|
||||
string? directory = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);
|
||||
if (directory != null && !Path.EndsInDirectorySeparator(directory))
|
||||
directory += PathInternal.DirectorySeparatorCharAsString;
|
||||
return directory ?? string.Empty;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace System
|
||||
{
|
||||
partial class AppContext
|
||||
{
|
||||
// Called by the runtime
|
||||
internal static unsafe void Setup (char** pNames, char** pValues, int count)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
s_dataStore.Add (new string ((sbyte*)pNames[i]), new string ((sbyte*)pValues[i]));
|
||||
}
|
||||
|
||||
static string GetBaseDirectoryCore ()
|
||||
{
|
||||
// Fallback path for hosts that do not set APP_CONTEXT_BASE_DIRECTORY explicitly
|
||||
var directory = Path.GetDirectoryName (Assembly.GetEntryAssembly()?.Location);
|
||||
if (directory != null && !Path.EndsInDirectorySeparator (directory))
|
||||
directory += Path.DirectorySeparatorChar;
|
||||
|
||||
return directory ?? string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user