mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-17 11:21:39 -10:00
Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
40f92d5cb6 | ||
|
|
0895a37089 | ||
|
|
5b8ba7e3ca | ||
|
|
0c35cf5ef0 | ||
|
|
d2a1623a18 | ||
|
|
cb725ff9de | ||
|
|
50f293135f | ||
|
|
11e1a399ac | ||
|
|
61740f8417 |
No files matched your search
@@ -167,9 +167,7 @@ namespace Microsoft.Build.BuildEngine {
|
||||
{
|
||||
if (ReservedNameUtils.IsReservedMetadataName (metadataName)) {
|
||||
string metadata = ReservedNameUtils.GetReservedMetadata (FinalItemSpec, metadataName, evaluatedMetadata);
|
||||
return string.Equals (metadataName, "fullpath", StringComparison.OrdinalIgnoreCase)
|
||||
? MSBuildUtils.Escape (metadata)
|
||||
: metadata;
|
||||
return MSBuildUtils.Unescape (metadata);
|
||||
}
|
||||
|
||||
if (evaluatedMetadata.Contains (metadataName))
|
||||
@@ -181,10 +179,7 @@ namespace Microsoft.Build.BuildEngine {
|
||||
public string GetMetadata (string metadataName)
|
||||
{
|
||||
if (ReservedNameUtils.IsReservedMetadataName (metadataName)) {
|
||||
string metadata = ReservedNameUtils.GetReservedMetadata (FinalItemSpec, metadataName, unevaluatedMetadata);
|
||||
return string.Equals (metadataName, "fullpath", StringComparison.OrdinalIgnoreCase)
|
||||
? MSBuildUtils.Escape (metadata)
|
||||
: metadata;
|
||||
return ReservedNameUtils.GetReservedMetadata (FinalItemSpec, metadataName, unevaluatedMetadata);
|
||||
} else if (unevaluatedMetadata.Contains (metadataName))
|
||||
return (string) unevaluatedMetadata [metadataName];
|
||||
else
|
||||
|
||||
@@ -284,6 +284,40 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
|
||||
Assert.AreEqual (String.Empty, item.GetMetadata ("AccessedTime"), "A13");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetMetadata_UnescapedItemSpec ()
|
||||
{
|
||||
string itemInclude = "a;b;c";
|
||||
string escapedItemInclude = Utilities.Escape (itemInclude);
|
||||
|
||||
item = new BuildItem ("name", itemInclude);
|
||||
Assert.IsTrue (item.GetMetadata ("FullPath").EndsWith (escapedItemInclude), "#1a");
|
||||
Assert.IsTrue (item.GetEvaluatedMetadata ("FullPath").EndsWith (itemInclude), "#1b");
|
||||
|
||||
Assert.AreEqual (itemInclude, item.GetMetadata ("FileName"), "#2b");
|
||||
Assert.AreEqual (itemInclude, item.GetEvaluatedMetadata ("FileName"), "#2b");
|
||||
|
||||
Assert.AreEqual (itemInclude, item.GetMetadata ("Identity"), "#3a");
|
||||
Assert.AreEqual (itemInclude, item.GetEvaluatedMetadata ("Identity"), "#3b");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetMetadata_EscapedItemSpec ()
|
||||
{
|
||||
string itemInclude = "a;b;c";
|
||||
string escapedItemInclude = Utilities.Escape (itemInclude);
|
||||
|
||||
item = new BuildItem ("name", escapedItemInclude);
|
||||
Assert.IsTrue (item.GetMetadata ("FullPath").EndsWith (escapedItemInclude), "#1a");
|
||||
Assert.IsTrue (item.GetEvaluatedMetadata ("FullPath").EndsWith (itemInclude), "#1b");
|
||||
|
||||
Assert.AreEqual (escapedItemInclude, item.GetMetadata ("FileName"), "#2b");
|
||||
Assert.AreEqual (itemInclude, item.GetEvaluatedMetadata ("FileName"), "#2b");
|
||||
|
||||
Assert.AreEqual (escapedItemInclude, item.GetMetadata ("Identity"), "#3a");
|
||||
Assert.AreEqual ("a;b;c", item.GetEvaluatedMetadata ("Identity"), "#3b");
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentNullException))]
|
||||
public void TestGetMetadata2 ()
|
||||
|
||||
@@ -13,7 +13,7 @@ LIB_MCS_FLAGS = \
|
||||
/r:System.dll \
|
||||
/r:$(XBUILD_FRAMEWORK)
|
||||
|
||||
TEST_MCS_FLAGS = /r:$(XBUILD_FRAMEWORK) -r:System.dll -r:System.Core.dll
|
||||
TEST_MCS_FLAGS = /r:$(XBUILD_ENGINE) /r:$(XBUILD_FRAMEWORK) -r:System.dll -r:System.Core.dll
|
||||
|
||||
include $(XBUILD_DIR)/xbuild_test.make
|
||||
include ../../build/library.make
|
||||
@@ -64,7 +64,6 @@ namespace Microsoft.Build.Utilities
|
||||
if (itemSpec == null)
|
||||
throw new ArgumentNullException ("itemSpec");
|
||||
|
||||
this.itemSpec = itemSpec;
|
||||
this.metadata = CollectionsUtil.CreateCaseInsensitiveHashtable ();
|
||||
|
||||
// FIXME: hack
|
||||
@@ -108,9 +107,9 @@ namespace Microsoft.Build.Utilities
|
||||
public string GetMetadata (string metadataName)
|
||||
{
|
||||
if (ReservedNameUtils.IsReservedMetadataName (metadataName))
|
||||
return ReservedNameUtils.GetReservedMetadata (ItemSpec, metadataName, metadata);
|
||||
return MSBuildUtils.Unescape (ReservedNameUtils.GetReservedMetadata (ItemSpec, metadataName, metadata));
|
||||
else if (metadata.Contains (metadataName))
|
||||
return (string) metadata [metadataName];
|
||||
return MSBuildUtils.Unescape ((string)metadata [metadataName]);
|
||||
else
|
||||
return String.Empty;
|
||||
}
|
||||
@@ -153,7 +152,7 @@ namespace Microsoft.Build.Utilities
|
||||
}
|
||||
|
||||
public string ItemSpec {
|
||||
get { return itemSpec; }
|
||||
get { return MSBuildUtils.Unescape (itemSpec); }
|
||||
set { itemSpec = value; }
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,8 @@ namespace Mono.XBuild.Utilities {
|
||||
|
||||
switch (metadataName.ToLowerInvariant ()) {
|
||||
case "fullpath":
|
||||
return Path.GetFullPath (itemSpec);
|
||||
var unescapedItemSpec = MSBuildUtils.Unescape (itemSpec);
|
||||
return MSBuildUtils.Escape (Path.GetFullPath (unescapedItemSpec));
|
||||
case "rootdir":
|
||||
if (Path.IsPathRooted (itemSpec))
|
||||
return Path.GetPathRoot (itemSpec);
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.IO;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
using NUnit.Framework;
|
||||
@@ -115,6 +116,50 @@ namespace MonoTests.Microsoft.Build.Utilities {
|
||||
new TaskItem ("itemspec", null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCtor_EscapedSpecialChar ()
|
||||
{
|
||||
// If we instantiate with the *escaped* metadata, it's unescaped automatically
|
||||
var metadata = "[email protected]";
|
||||
var escapedMetadata = global::Microsoft.Build.BuildEngine.Utilities.Escape ("[email protected]");
|
||||
var item = new TaskItem (escapedMetadata);
|
||||
item.SetMetadata ("mine", escapedMetadata);
|
||||
|
||||
Assert.AreEqual (metadata, item.ItemSpec, "#1");
|
||||
Assert.AreEqual (metadata, item.GetMetadata ("Identity"), "#2");
|
||||
Assert.AreEqual (Path.GetFileNameWithoutExtension (metadata), item.GetMetadata ("FileName"), "#3");
|
||||
Assert.IsTrue (item.GetMetadata ("FullPath").EndsWith (metadata), "#4");
|
||||
Assert.AreEqual (metadata, item.GetMetadata ("mine"), "#5");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCtor_EscapedSpecialChar_BrokenEscaping ()
|
||||
{
|
||||
// This is badly escaped, but MSBuild does not care.
|
||||
var metadata = "foo%[email protected]";
|
||||
var item = new TaskItem (metadata);
|
||||
|
||||
Assert.AreEqual (metadata, item.ItemSpec, "#1");
|
||||
Assert.AreEqual (metadata, item.GetMetadata ("Identity"), "#2");
|
||||
Assert.AreEqual (Path.GetFileNameWithoutExtension (metadata), item.GetMetadata ("FileName"), "#3");
|
||||
Assert.IsTrue (item.GetMetadata ("FullPath").EndsWith (metadata), "#4");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCtor_UnescapedSpecialChar ()
|
||||
{
|
||||
// If we instantiate with unescaped metadata, we get the same value back
|
||||
var metadata = "[email protected]";
|
||||
var item = new TaskItem (metadata);
|
||||
item.SetMetadata ("mine", metadata);
|
||||
|
||||
Assert.AreEqual (metadata, item.ItemSpec, "#1");
|
||||
Assert.AreEqual (metadata, item.GetMetadata ("Identity"), "#2");
|
||||
Assert.AreEqual (Path.GetFileNameWithoutExtension (metadata), item.GetMetadata ("FileName"), "#3");
|
||||
Assert.IsTrue (item.GetMetadata ("FullPath").EndsWith (metadata), "#4");
|
||||
Assert.AreEqual (metadata, item.GetMetadata ("mine"), "#5");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCopyConstructor ()
|
||||
{
|
||||
@@ -240,5 +285,19 @@ namespace MonoTests.Microsoft.Build.Utilities {
|
||||
item = new TaskItem ("lalala");
|
||||
item.SetMetadata ("Identity", "some value");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSetItemSpec ()
|
||||
{
|
||||
var itemSpec = "[email protected]";
|
||||
var escapedItemSpec = global::Microsoft.Build.BuildEngine.Utilities.Escape (itemSpec);
|
||||
|
||||
var item = new TaskItem ("foo");
|
||||
item.ItemSpec = itemSpec;
|
||||
Assert.AreEqual (itemSpec, item.ItemSpec, "#1");
|
||||
|
||||
item.ItemSpec = escapedItemSpec;
|
||||
Assert.AreEqual (itemSpec, item.ItemSpec, "#2");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -918,7 +918,7 @@ namespace System.Diagnostics {
|
||||
IntPtr stderr,
|
||||
ref ProcInfo proc_info);
|
||||
|
||||
private static bool Start_shell (ProcessStartInfo startInfo)
|
||||
private static bool Start_shell (ProcessStartInfo startInfo, Process process)
|
||||
{
|
||||
ProcInfo proc_info=new ProcInfo();
|
||||
bool ret;
|
||||
@@ -945,6 +945,9 @@ namespace System.Diagnostics {
|
||||
throw new Win32Exception (-proc_info.pid);
|
||||
}
|
||||
|
||||
process.process_handle = proc_info.process_handle;
|
||||
process.pid = proc_info.pid;
|
||||
process.StartExitCallbackIfNeeded ();
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@@ -1156,7 +1159,7 @@ namespace System.Diagnostics {
|
||||
if (startInfo.UseShellExecute) {
|
||||
if (!String.IsNullOrEmpty (startInfo.UserName))
|
||||
throw new InvalidOperationException ("UserShellExecute must be false if an explicit UserName is specified when starting a process");
|
||||
return (Start_shell (startInfo));
|
||||
return (Start_shell (startInfo, process));
|
||||
} else {
|
||||
return (Start_noshell (startInfo, process));
|
||||
}
|
||||
@@ -1176,12 +1179,9 @@ namespace System.Diagnostics {
|
||||
if (startInfo == null)
|
||||
throw new ArgumentNullException ("startInfo");
|
||||
|
||||
Process process = null;
|
||||
if (!startInfo.UseShellExecute) {
|
||||
process = new Process();
|
||||
process.StartInfo = startInfo;
|
||||
}
|
||||
if (Start_common(startInfo, process))
|
||||
Process process = new Process();
|
||||
process.StartInfo = startInfo;
|
||||
if (Start_common(startInfo, process) && process.process_handle != IntPtr.Zero)
|
||||
return process;
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -380,6 +380,9 @@ gboolean ShellExecuteEx (WapiShellExecuteInfo *sei)
|
||||
SetLastError (ERROR_INVALID_DATA);
|
||||
return FALSE;
|
||||
}
|
||||
/* Shell exec should not return a process handle when it spawned a GUI thing, like a browser. */
|
||||
CloseHandle (process_info.hProcess);
|
||||
process_info.hProcess = NULL;
|
||||
}
|
||||
|
||||
if (sei->fMask & SEE_MASK_NOCLOSEPROCESS) {
|
||||
|
||||
@@ -2562,16 +2562,23 @@ assembly_binding_info_parsed (MonoAssemblyBindingInfo *info, void *user_data)
|
||||
domain->assembly_bindings = g_slist_append_mempool (domain->mp, domain->assembly_bindings, info_copy);
|
||||
}
|
||||
|
||||
static int
|
||||
get_version_number (int major, int minor)
|
||||
{
|
||||
return major * 256 + minor;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
info_major_minor_in_range (MonoAssemblyBindingInfo *info, MonoAssemblyName *aname)
|
||||
{
|
||||
int aname_version_number = get_version_number (aname->major, aname->minor);
|
||||
if (!info->has_old_version_bottom)
|
||||
return FALSE;
|
||||
|
||||
if (info->old_version_bottom.major > aname->major || info->old_version_bottom.minor > aname->minor)
|
||||
if (get_version_number (info->old_version_bottom.major, info->old_version_bottom.minor) > aname_version_number)
|
||||
return FALSE;
|
||||
|
||||
if (info->has_old_version_top && (info->old_version_top.major < aname->major || info->old_version_top.minor < aname->minor))
|
||||
if (info->has_old_version_top && get_version_number (info->old_version_top.major, info->old_version_top.minor) < aname_version_number)
|
||||
return FALSE;
|
||||
|
||||
/* This is not the nicest way to do it, but it's a by-product of the way parsing is done */
|
||||
|
||||
+17
-1
@@ -604,7 +604,7 @@ MonoBoolean ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal (MonoPr
|
||||
gboolean ret;
|
||||
|
||||
shellex.cbSize = sizeof(SHELLEXECUTEINFO);
|
||||
shellex.fMask = SEE_MASK_FLAG_DDEWAIT | SEE_MASK_UNICODE;
|
||||
shellex.fMask = SEE_MASK_FLAG_DDEWAIT | SEE_MASK_NOCLOSEPROCESS | SEE_MASK_UNICODE;
|
||||
shellex.nShow = proc_start_info->window_style;
|
||||
shellex.nShow = (shellex.nShow == 0) ? 1 : (shellex.nShow == 1 ? 0 : shellex.nShow);
|
||||
|
||||
@@ -634,6 +634,22 @@ MonoBoolean ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal (MonoPr
|
||||
}
|
||||
|
||||
ret = ShellExecuteEx (&shellex);
|
||||
if (ret == FALSE) {
|
||||
process_info->pid = -GetLastError ();
|
||||
} else {
|
||||
process_info->process_handle = shellex.hProcess;
|
||||
process_info->thread_handle = NULL;
|
||||
/* It appears that there's no way to get the pid from a
|
||||
* process handle before windows xp. Really.
|
||||
*/
|
||||
#if defined(HAVE_GETPROCESSID) && !defined(MONO_CROSS_COMPILE)
|
||||
process_info->pid = GetProcessId (shellex.hProcess);
|
||||
#else
|
||||
process_info->pid = 0;
|
||||
#endif
|
||||
process_info->tid = 0;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
||||
@@ -323,9 +323,31 @@ static gboolean handle_remove(MonoInternalThread *thread)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void ensure_synch_cs_set (MonoInternalThread *thread)
|
||||
{
|
||||
CRITICAL_SECTION *synch_cs;
|
||||
|
||||
if (thread->synch_cs != NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
synch_cs = g_new0 (CRITICAL_SECTION, 1);
|
||||
InitializeCriticalSection (synch_cs);
|
||||
|
||||
if (InterlockedCompareExchangePointer ((gpointer *)&thread->synch_cs,
|
||||
synch_cs, NULL) != NULL) {
|
||||
/* Another thread must have installed this CS */
|
||||
DeleteCriticalSection (synch_cs);
|
||||
g_free (synch_cs);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
lock_thread (MonoInternalThread *thread)
|
||||
{
|
||||
if (!thread->synch_cs)
|
||||
ensure_synch_cs_set (thread);
|
||||
|
||||
g_assert (thread->synch_cs);
|
||||
EnterCriticalSection (thread->synch_cs);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1542,7 +1542,7 @@ mono_main (int argc, char* argv[])
|
||||
char *build = mono_get_runtime_build_info ();
|
||||
char *gc_descr;
|
||||
|
||||
g_print ("Mono Runtime Engine version %s\nCopyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com\n", build);
|
||||
g_print ("Mono JIT compiler version %s\nCopyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com\n", build);
|
||||
g_free (build);
|
||||
g_print (info);
|
||||
gc_descr = mono_gc_get_description ();
|
||||
|
||||
+4
-4
@@ -670,9 +670,9 @@ mono_tramp_info_register (MonoTrampInfo *info)
|
||||
copy->code_size = info->code_size;
|
||||
copy->name = g_strdup (info->name);
|
||||
|
||||
mono_loader_lock_if_inited ();
|
||||
mono_jit_lock ();
|
||||
tramp_infos = g_slist_prepend (tramp_infos, copy);
|
||||
mono_loader_unlock_if_inited ();
|
||||
mono_jit_unlock ();
|
||||
|
||||
mono_save_trampoline_xdebug_info (info);
|
||||
|
||||
@@ -7104,6 +7104,8 @@ mini_init (const char *filename, const char *runtime_version)
|
||||
}
|
||||
#endif
|
||||
|
||||
InitializeCriticalSection (&jit_mutex);
|
||||
|
||||
/* Happens when using the embedding interface */
|
||||
if (!default_opt_set)
|
||||
default_opt = mono_parse_default_optimizations (NULL);
|
||||
@@ -7113,8 +7115,6 @@ mini_init (const char *filename, const char *runtime_version)
|
||||
mono_set_generic_sharing_vt_supported (TRUE);
|
||||
#endif
|
||||
|
||||
InitializeCriticalSection (&jit_mutex);
|
||||
|
||||
#ifdef MONO_HAVE_FAST_TLS
|
||||
MONO_FAST_TLS_INIT (mono_jit_tls);
|
||||
MONO_FAST_TLS_INIT (mono_lmf_addr);
|
||||
|
||||
Reference in new issue
Block a user