mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-16 01:41:18 -10:00
Compare commits
299
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84570ffb93 | ||
|
|
1d44ba22a5 | ||
|
|
057a9ed68d | ||
|
|
52f09e41d0 | ||
|
|
bcdd136b2d | ||
|
|
b30f057280 | ||
|
|
27a9c4a5d0 | ||
|
|
5e0ee04d51 | ||
|
|
851ab61b7a | ||
|
|
a4083fe77d | ||
|
|
e660bf8aca | ||
|
|
2b3d9079e2 | ||
|
|
a4d064ed4e | ||
|
|
53d9fc14ad | ||
|
|
ed14894a33 | ||
|
|
14fdf85cbd | ||
|
|
f388ef6c2c | ||
|
|
04961930be | ||
|
|
e684bbfe57 | ||
|
|
248aeba2c7 | ||
|
|
78604dca27 | ||
|
|
6bae1bb5c3 | ||
|
|
f7c769111a | ||
|
|
2a332a7951 | ||
|
|
c330e594e4 | ||
|
|
0f1268df35 | ||
|
|
49310de53e | ||
|
|
a19d806bb1 | ||
|
|
ddbc3e479b | ||
|
|
2aa5af6c2f | ||
|
|
1fe06b40e8 | ||
|
|
b78eb3caad | ||
|
|
c84551fd73 | ||
|
|
25b0805e20 | ||
|
|
a3a68d4083 | ||
|
|
776a60617a | ||
|
|
095322953b | ||
|
|
3a5f48bced | ||
|
|
b598aee4dc | ||
|
|
98ff1ec075 | ||
|
|
c5f5d263d7 | ||
|
|
4d06d66e19 | ||
|
|
487e9a1f0a | ||
|
|
c9316a0bcc | ||
|
|
3a40dfbb24 | ||
|
|
2ff17cce11 | ||
|
|
ff738c616f | ||
|
|
6f76bef3f9 | ||
|
|
d17d1101a4 | ||
|
|
7954648dbe | ||
|
|
96bc53e927 | ||
|
|
d5c12cf568 | ||
|
|
92dd07a485 | ||
|
|
0d7102d039 | ||
|
|
fa30544d3c | ||
|
|
b44bd65f75 | ||
|
|
f7d12c2b05 | ||
|
|
7288206bdf | ||
|
|
bb874a687b | ||
|
|
5df3e05e0e | ||
|
|
6fdae5d654 | ||
|
|
bdabf74a88 | ||
|
|
fd42bcd36c | ||
|
|
b26531ebba | ||
|
|
2a3bedbf8c | ||
|
|
e61d54040f | ||
|
|
870f4582ab | ||
|
|
06c93cd2cf | ||
|
|
5da7907603 | ||
|
|
68f5d0926d | ||
|
|
c9f58f07fe | ||
|
|
dc671b1b4a | ||
|
|
44f95d3311 | ||
|
|
e10b6ddad7 | ||
|
|
65292a69c8 | ||
|
|
7890fd60c5 | ||
|
|
d8096023f2 | ||
|
|
79d5f2e009 | ||
|
|
7628c67ef8 | ||
|
|
b6b047eed9 | ||
|
|
4cb8b2e6f3 | ||
|
|
237cee6dc6 | ||
|
|
e1d8ee37b1 | ||
|
|
84bf2fd468 | ||
|
|
d945da7eeb | ||
|
|
85b7cae565 | ||
|
|
26ee955aca | ||
|
|
b509f42a7e | ||
|
|
717982c7cf | ||
|
|
931e044108 | ||
|
|
e171f51df0 | ||
|
|
d326d51789 | ||
|
|
ffd50c266e | ||
|
|
63c0a5d6d2 | ||
|
|
06205b5084 | ||
|
|
1bbc6a8a1b | ||
|
|
d106cf2a5a | ||
|
|
ded054284e | ||
|
|
4ed8473ce9 | ||
|
|
e30361a696 | ||
|
|
6b51a1df2f | ||
|
|
3aed7ab3c9 | ||
|
|
9d534c9413 | ||
|
|
adb66a513a | ||
|
|
c11559c7ef | ||
|
|
32e235d68b | ||
|
|
ba625becd6 | ||
|
|
5588a6f078 | ||
|
|
5d600522ed | ||
|
|
2427b2b861 | ||
|
|
11aeecfa3a | ||
|
|
e27b81a652 | ||
|
|
8f3f18568c | ||
|
|
f886d89ef7 | ||
|
|
44ea00024a | ||
|
|
4aabcf3455 | ||
|
|
a22f24834e | ||
|
|
cea5d2223b | ||
|
|
bc1373c0d8 | ||
|
|
c8d96f618a | ||
|
|
c530931921 | ||
|
|
e373b1cf49 | ||
|
|
ba5de9d036 | ||
|
|
a51e35bbec | ||
|
|
681aff17d2 | ||
|
|
d1703c40ef | ||
|
|
c53bce8e0a | ||
|
|
3aad88e828 | ||
|
|
2037a51576 | ||
|
|
8d8cae9016 | ||
|
|
4106e07cca | ||
|
|
963f28f38b | ||
|
|
bd045fc008 | ||
|
|
cff2890d8d | ||
|
|
101eaf3215 | ||
|
|
5cfa597a30 | ||
|
|
84be0b20e5 | ||
|
|
e7de26c774 | ||
|
|
8a31a4b263 | ||
|
|
06e2e82bb0 | ||
|
|
47429fb521 | ||
|
|
42459678e9 | ||
|
|
44dc98ddd1 | ||
|
|
32832e39bb | ||
|
|
de60018067 | ||
|
|
06e3b0379b | ||
|
|
2626e53a2e | ||
|
|
5015ec260b | ||
|
|
91f700f9d4 | ||
|
|
63f589c152 | ||
|
|
c223d5999b | ||
|
|
6d8bafaa07 | ||
|
|
5625f3afe8 | ||
|
|
59959cefb2 | ||
|
|
217ec2ce11 | ||
|
|
4f47316df0 | ||
|
|
589a83dfa4 | ||
|
|
b54ac46230 | ||
|
|
7c22cb0135 | ||
|
|
8e890a3bf8 | ||
|
|
b80ffc9882 | ||
|
|
61c8b99b3f | ||
|
|
4a60b3f3fa | ||
|
|
d2bb6fe8e1 | ||
|
|
9f384277cd | ||
|
|
10b7c361bb | ||
|
|
1e535e61d3 | ||
|
|
fb42e1e12b | ||
|
|
7358969934 | ||
|
|
89c7bb82d4 | ||
|
|
c28b4ea9d7 | ||
|
|
b80d1ca6eb | ||
|
|
5f80fd9448 | ||
|
|
e53a4c3776 | ||
|
|
69a95ff53d | ||
|
|
5025f28490 | ||
|
|
e3c340f1c1 | ||
|
|
2fdbdc2bc0 | ||
|
|
2875496241 | ||
|
|
f98dc57542 | ||
|
|
905e43efe2 | ||
|
|
b6a25dfdd2 | ||
|
|
16c125bc9b | ||
|
|
33d466d421 | ||
|
|
4b0101dd80 | ||
|
|
84e9b39b17 | ||
|
|
8a5647b1d6 | ||
|
|
733d3f45d1 | ||
|
|
29ffd5258c | ||
|
|
e845f96a79 | ||
|
|
51e0ca445a | ||
|
|
f95ed5726f | ||
|
|
03af9e4c5d | ||
|
|
921a0951d8 | ||
|
|
c6ee6980ce | ||
|
|
429c26b022 | ||
|
|
5b4ab167be | ||
|
|
58e8a395c4 | ||
|
|
0e93173683 | ||
|
|
20f6a72044 | ||
|
|
552a1f5c7e | ||
|
|
d3b4997ff1 | ||
|
|
722e143cc0 | ||
|
|
0875d61ca2 | ||
|
|
0d8e8f7df9 | ||
|
|
135e5eb0df | ||
|
|
b2ba1f46f7 | ||
|
|
15e954d508 | ||
|
|
86bc7170e5 | ||
|
|
3779a70dcc | ||
|
|
160cf6a24e | ||
|
|
1cd68dd08c | ||
|
|
0ee4f2dbd1 | ||
|
|
44d00f87d5 | ||
|
|
b214e1e693 | ||
|
|
cda5880b42 | ||
|
|
e97de6b450 | ||
|
|
d8034534d0 | ||
|
|
b49c845d35 | ||
|
|
b6a60964d8 | ||
|
|
3b5c655c05 | ||
|
|
3b6f5c3308 | ||
|
|
579a0ca72b | ||
|
|
577dfd5d78 | ||
|
|
57dae7a311 | ||
|
|
a21c08a924 | ||
|
|
e763cd5010 | ||
|
|
964d3433d8 | ||
|
|
89f92560a1 | ||
|
|
b1752875e8 | ||
|
|
2a308efd0a | ||
|
|
bff2b8d6c4 | ||
|
|
9f2d34d689 | ||
|
|
37edaa18f7 | ||
|
|
77d12442c4 | ||
|
|
3ad4bb8e3d | ||
|
|
67c7faf279 | ||
|
|
7757931e8e | ||
|
|
5a55034e93 | ||
|
|
bab18ab6d2 | ||
|
|
4c601b8522 | ||
|
|
36e827b0be | ||
|
|
e137468dc6 | ||
|
|
aa92238b98 | ||
|
|
093a537205 | ||
|
|
fe1653eae0 | ||
|
|
58f029f2d1 | ||
|
|
f16036819a | ||
|
|
784d21f5fd | ||
|
|
c101a18be3 | ||
|
|
f038e86294 | ||
|
|
ef47ac3d22 | ||
|
|
95617646ba | ||
|
|
652ff412d2 | ||
|
|
8ca77a27fa | ||
|
|
3b8eeb54d3 | ||
|
|
6e23108f39 | ||
|
|
052fd53f21 | ||
|
|
164ba0d204 | ||
|
|
8853b1acb3 | ||
|
|
d2bc3285b1 | ||
|
|
019cca88ce | ||
|
|
b2ac405dbb | ||
|
|
24ef405181 | ||
|
|
e2aecacc87 | ||
|
|
d6038fc397 | ||
|
|
0d7b33cbc9 | ||
|
|
f40fc6829d | ||
|
|
eb12be05d9 | ||
|
|
f68a0cd137 | ||
|
|
815ec755b4 | ||
|
|
f751095363 | ||
|
|
30f3260cc1 | ||
|
|
50a2d76b29 | ||
|
|
006d9f248d | ||
|
|
f16e13ead3 | ||
|
|
904b7563aa | ||
|
|
05378ccef9 | ||
|
|
911929eed1 | ||
|
|
ae557e488d | ||
|
|
d88e223dd4 | ||
|
|
1867fd1486 | ||
|
|
1f42b9026c | ||
|
|
4b649e0805 | ||
|
|
2ce8ebda5f | ||
|
|
3b7c1f8741 | ||
|
|
faa1dd5646 | ||
|
|
21b9ee9deb | ||
|
|
db99cebd57 | ||
|
|
a8c3708337 | ||
|
|
b40cb0cc14 | ||
|
|
5640b0a889 | ||
|
|
693cbe7207 | ||
|
|
93d6cc3bf9 | ||
|
|
0474947f86 | ||
|
|
0013378bfa | ||
|
|
0e5aff05c4 | ||
|
|
38a79cb7b8 | ||
|
|
fc767570a8 |
No files matched your search
+2
-1
@@ -37,7 +37,8 @@ DISTCLEANFILES= mono-uninstalled.pc
|
||||
# building with monolite
|
||||
mcslib = $(mcs_topdir)/class/lib
|
||||
monolite = $(mcslib)/monolite
|
||||
monolite_url = http://mono.ximian.com/daily/monolite-latest.tar.gz
|
||||
mono_corlib_version = $(shell sed -n "s/\#define MONO_CORLIB_VERSION //p" $(srcdir)/mono/metadata/appdomain.c)
|
||||
monolite_url = http://mono.ximian.com/daily/monolite-$(mono_corlib_version)-latest.tar.gz
|
||||
.PHONY: get-monolite-latest
|
||||
get-monolite-latest:
|
||||
-rm -fr $(mcslib)/monolite-*
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ AC_CANONICAL_SYSTEM
|
||||
m4_ifdef([_A][M_PROG_TAR],[_A][M_SET_OPTION([tar-ustar])])
|
||||
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
AM_INIT_AUTOMAKE(mono,2.8.1)
|
||||
AM_INIT_AUTOMAKE(mono,2.8.2)
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
API_VER=2.0
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<dllmap dll="libX11" target="@X11@" os="!windows" />
|
||||
<dllmap dll="libcairo-2.dll" target="libcairo.so.2" os="!windows"/>
|
||||
<dllmap dll="libcups" target="libcups.so.2" os="!windows"/>
|
||||
<dllmap dll="libcups" target="libcups.dylib" os="osx"/>
|
||||
<dllmap dll="i:kernel32.dll">
|
||||
<dllentry dll="__Internal" name="CopyMemory" target="mono_win32_compat_CopyMemory"/>
|
||||
<dllentry dll="__Internal" name="FillMemory" target="mono_win32_compat_FillMemory"/>
|
||||
|
||||
@@ -474,10 +474,15 @@ private CodeDomProvider GetProvider(string langId)
|
||||
//
|
||||
// Document generation
|
||||
//
|
||||
class UTF8StringWriter : StringWriter {
|
||||
public override Encoding Encoding {
|
||||
get { return Encoding.UTF8; }
|
||||
}
|
||||
}
|
||||
|
||||
string GenerateDocument ()
|
||||
{
|
||||
StringWriter sw = new StringWriter ();
|
||||
UTF8StringWriter sw = new UTF8StringWriter ();
|
||||
|
||||
if (CurrentDocType == "wsdl")
|
||||
descriptions [CurrentDocInd].Write (sw);
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -4,9 +4,11 @@ monodir = $(sysconfdir)/mono/4.0
|
||||
|
||||
EXTRA_DIST = machine.config \
|
||||
web.config \
|
||||
DefaultWsdlHelpGenerator.aspx \
|
||||
settings.map
|
||||
|
||||
mono_DATA = machine.config \
|
||||
web.config \
|
||||
DefaultWsdlHelpGenerator.aspx \
|
||||
settings.map
|
||||
|
||||
@@ -62,6 +62,17 @@
|
||||
</sectionGroup>
|
||||
<section name="monoSettings" type="System.Web.Configuration.MonoSettingsSection, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
</sectionGroup>
|
||||
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
|
||||
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
|
||||
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
|
||||
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
|
||||
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
|
||||
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
|
||||
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
|
||||
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
|
||||
</sectionGroup>
|
||||
</sectionGroup>
|
||||
</sectionGroup>
|
||||
<sectionGroup name="system.net" type="System.Net.Configuration.NetSectionGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<section name="authenticationModules" type="System.Net.Configuration.AuthenticationModulesSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<section name="connectionManagement" type="System.Net.Configuration.ConnectionManagementSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
<!--
|
||||
<add path="*.svc" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="False"/>
|
||||
-->
|
||||
<add verb="*" path="*.svc" type="System.ServiceModel.Channels.SvcHttpHandlerFactory, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<add path="*.rules" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/>
|
||||
<!--
|
||||
<add path="*.xoml" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="False"/>
|
||||
|
||||
+1
-1
@@ -8,5 +8,5 @@ SUBDIRS = src test
|
||||
endif
|
||||
endif
|
||||
|
||||
EXTRA_DIST = autogen.sh README NEWS AUTHORS ChangeLog
|
||||
EXTRA_DIST = autogen.sh README NEWS AUTHORS ChangeLog winconfig.h
|
||||
|
||||
+2
-3
@@ -14,9 +14,8 @@ BREAKPOINT="G_STMT_START { raise (SIGTRAP); } G_STMT_END"
|
||||
if test x$GCC = xyes; then
|
||||
GNUC_UNUSED='__attribute__((__unused__))'
|
||||
GNUC_NORETURN='__attribute__((__noreturn__))'
|
||||
echo target_cpu=$target_cpu
|
||||
case $target_cpu in
|
||||
i*86) BREAKPOINT="G_STMT_START { __asm__ (\"int \$03\"); } G_STMT_END" ;;
|
||||
i*86|x86_64) BREAKPOINT="G_STMT_START { __asm__ (\"int \$03\"); } G_STMT_END" ;;
|
||||
esac
|
||||
fi
|
||||
AC_SUBST(GNUC_PRETTY)
|
||||
@@ -110,7 +109,7 @@ if test "x$have_iso_varargs" = "xyes"; then
|
||||
fi
|
||||
AC_SUBST(G_HAVE_ISO_VARARGS)
|
||||
|
||||
AC_CHECK_HEADERS(getopt.h sys/time.h sys/wait.h pwd.h langinfo.h iconv.h)
|
||||
AC_CHECK_HEADERS(getopt.h sys/time.h sys/wait.h pwd.h langinfo.h iconv.h localcharset.h)
|
||||
|
||||
if test $ac_cv_sizeof_void_p != $ac_cv_sizeof_int; then
|
||||
GPOINTER_TO_INT="((gint)(long) (ptr))"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
noinst_LTLIBRARIES = libeglib.la libeglib-static.la
|
||||
|
||||
win_files = \
|
||||
eglib-config.hw \
|
||||
gdate-win32.c gdir-win32.c gfile-win32.c gmisc-win32.c \
|
||||
gmodule-win32.c gtimer-win32.c
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
#define g_hash_table_new_full monoeg_g_hash_table_new_full
|
||||
#define g_hash_table_remove monoeg_g_hash_table_remove
|
||||
#define g_hash_table_size monoeg_g_hash_table_size
|
||||
#define g_hash_table_print_stats monoeg_g_hash_table_print_stats
|
||||
#define g_int_equal monoeg_g_int_equal
|
||||
#define g_int_hash monoeg_g_int_hash
|
||||
#define g_list_alloc monoeg_g_list_alloc
|
||||
@@ -99,6 +100,7 @@
|
||||
#define g_pattern_spec_new monoeg_g_pattern_spec_new
|
||||
#define g_print monoeg_g_print
|
||||
#define g_printf monoeg_g_printf
|
||||
#define g_printerr monoeg_g_printerr
|
||||
#define g_propagate_error monoeg_g_propagate_error
|
||||
#define g_ptr_array_add monoeg_g_ptr_array_add
|
||||
#define g_ptr_array_foreach monoeg_g_ptr_array_foreach
|
||||
@@ -166,6 +168,7 @@
|
||||
#define g_strerror monoeg_g_strerror
|
||||
#define g_strescape monoeg_g_strescape
|
||||
#define g_strfreev monoeg_g_strfreev
|
||||
#define g_strdupv monoeg_g_strdupv
|
||||
#define g_string_append monoeg_g_string_append
|
||||
#define g_string_append_c monoeg_g_string_append_c
|
||||
#define g_string_append_len monoeg_g_string_append_len
|
||||
|
||||
+10
-16
@@ -51,46 +51,40 @@ g_dir_open (const gchar *path, guint flags, GError **error)
|
||||
|
||||
g_return_val_if_fail (path != NULL, NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
||||
dir = g_new0 (GDir, 1);
|
||||
|
||||
path_utf16 = u8to16 (path);
|
||||
path_utf16_search = g_malloc ((wcslen(path_utf16) + 3)*sizeof(gunichar2));
|
||||
wcscpy (path_utf16_search, path_utf16);
|
||||
wcscat (path_utf16_search, L"\\*");
|
||||
|
||||
dir->handle = FindFirstFile (path_utf16, &find_data);
|
||||
dir->handle = FindFirstFileW (path_utf16_search, &find_data);
|
||||
if (dir->handle == INVALID_HANDLE_VALUE) {
|
||||
if (error) {
|
||||
gint err = errno;
|
||||
*error = g_error_new (G_LOG_DOMAIN, g_file_error_from_errno (err), strerror (err));
|
||||
}
|
||||
g_free (dir);
|
||||
g_free (path_utf16_search);
|
||||
g_free (path_utf16);
|
||||
g_free (dir);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* now get files */
|
||||
FindClose (dir->handle);
|
||||
path_utf16_search = g_malloc ((wcslen(path_utf16) + 3)*sizeof(gunichar2));
|
||||
wcscpy (path_utf16_search, path_utf16);
|
||||
wcscat (path_utf16_search, L"\\*");
|
||||
|
||||
dir->handle = FindFirstFile (path_utf16_search, &find_data);
|
||||
g_free (path_utf16_search);
|
||||
g_free (path_utf16);
|
||||
|
||||
while ((wcscmp (find_data.cFileName, L".") == 0) || (wcscmp (find_data.cFileName, L"..") == 0)) {
|
||||
if (!FindNextFile (dir->handle, &find_data)) {
|
||||
if (!FindNextFileW (dir->handle, &find_data)) {
|
||||
if (error) {
|
||||
gint err = errno;
|
||||
*error = g_error_new (G_LOG_DOMAIN, g_file_error_from_errno (err), strerror (err));
|
||||
}
|
||||
g_free (dir);
|
||||
g_free (path_utf16);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
dir->current = NULL;
|
||||
dir->next = u16to8 (find_data.cFileName);
|
||||
|
||||
g_free (path_utf16);
|
||||
return dir;
|
||||
}
|
||||
|
||||
@@ -113,7 +107,7 @@ g_dir_read_name (GDir *dir)
|
||||
dir->next = NULL;
|
||||
|
||||
do {
|
||||
if (!FindNextFile (dir->handle, &find_data)) {
|
||||
if (!FindNextFileW (dir->handle, &find_data)) {
|
||||
dir->next = NULL;
|
||||
return dir->current;
|
||||
}
|
||||
|
||||
+39
-21
@@ -72,39 +72,57 @@ g_path_is_absolute (const char *filename)
|
||||
return (*filename == '/');
|
||||
}
|
||||
|
||||
static pthread_mutex_t home_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_mutex_t pw_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static const gchar *home_dir;
|
||||
static const gchar *user_name;
|
||||
|
||||
static void
|
||||
get_pw_data (void)
|
||||
{
|
||||
#ifdef HAVE_GETPWUID_R
|
||||
struct passwd pw;
|
||||
struct passwd *result;
|
||||
char buf [4096];
|
||||
#endif
|
||||
|
||||
if (user_name != NULL)
|
||||
return;
|
||||
|
||||
pthread_mutex_lock (&pw_lock);
|
||||
if (user_name != NULL) {
|
||||
pthread_mutex_unlock (&pw_lock);
|
||||
return;
|
||||
}
|
||||
#ifdef HAVE_GETPWUID_R
|
||||
if (getpwuid_r (getuid (), &pw, buf, 4096, &result) == 0) {
|
||||
home_dir = g_strdup (pw.pw_dir);
|
||||
user_name = g_strdup (pw.pw_name);
|
||||
}
|
||||
#endif
|
||||
if (home_dir == NULL)
|
||||
home_dir = g_getenv ("HOME");
|
||||
|
||||
if (user_name == NULL) {
|
||||
user_name = g_getenv ("USER");
|
||||
if (user_name == NULL)
|
||||
user_name = "somebody";
|
||||
}
|
||||
pthread_mutex_unlock (&pw_lock);
|
||||
}
|
||||
|
||||
/* Give preference to /etc/passwd than HOME */
|
||||
const gchar *
|
||||
g_get_home_dir (void)
|
||||
{
|
||||
if (home_dir == NULL){
|
||||
pthread_mutex_lock (&home_lock);
|
||||
if (home_dir == NULL){
|
||||
#ifdef HAVE_GETPWUID_R
|
||||
struct passwd pw;
|
||||
struct passwd *result;
|
||||
char buf [4096];
|
||||
|
||||
if (getpwuid_r (getuid (), &pw, buf, 4096, &result) == 0)
|
||||
home_dir = g_strdup (pw.pw_dir);
|
||||
#endif
|
||||
if (home_dir == NULL)
|
||||
home_dir = g_getenv ("HOME");
|
||||
}
|
||||
pthread_mutex_unlock (&home_lock);
|
||||
}
|
||||
get_pw_data ();
|
||||
return home_dir;
|
||||
}
|
||||
|
||||
const char *
|
||||
g_get_user_name (void)
|
||||
{
|
||||
const char *retName = g_getenv ("USER");
|
||||
if (!retName)
|
||||
retName = "somebody";
|
||||
return retName;
|
||||
get_pw_data ();
|
||||
return user_name;
|
||||
}
|
||||
|
||||
static const char *tmp_dir;
|
||||
|
||||
+17
-9
@@ -33,7 +33,6 @@ split_cmdline (const gchar *cmdline, GPtrArray *array, GError **error)
|
||||
{
|
||||
gchar *ptr;
|
||||
gchar c;
|
||||
gboolean in_quote = FALSE;
|
||||
gboolean escaped = FALSE;
|
||||
gchar quote_char = '\0';
|
||||
GString *str;
|
||||
@@ -42,18 +41,28 @@ split_cmdline (const gchar *cmdline, GPtrArray *array, GError **error)
|
||||
ptr = (gchar *) cmdline;
|
||||
while ((c = *ptr++) != '\0') {
|
||||
if (escaped) {
|
||||
escaped = FALSE;
|
||||
if (!g_ascii_isspace (c))
|
||||
/*
|
||||
* \CHAR is only special inside a double quote if CHAR is
|
||||
* one of: $`"\ and newline
|
||||
*/
|
||||
if (quote_char == '\"'){
|
||||
if (!(c == '$' || c == '`' || c == '"' || c == '\\'))
|
||||
g_string_append_c (str, '\\');
|
||||
g_string_append_c (str, c);
|
||||
} else if (in_quote) {
|
||||
} else {
|
||||
if (!g_ascii_isspace (c))
|
||||
g_string_append_c (str, c);
|
||||
}
|
||||
escaped = FALSE;
|
||||
} else if (quote_char) {
|
||||
if (c == quote_char) {
|
||||
in_quote = FALSE;
|
||||
quote_char = '\0';
|
||||
g_ptr_array_add (array, g_string_free (str, FALSE));
|
||||
str = g_string_new ("");
|
||||
} else {
|
||||
} else if (c == '\\'){
|
||||
escaped = TRUE;
|
||||
} else
|
||||
g_string_append_c (str, c);
|
||||
}
|
||||
} else if (g_ascii_isspace (c)) {
|
||||
if (str->len > 0) {
|
||||
g_ptr_array_add (array, g_string_free (str, FALSE));
|
||||
@@ -62,7 +71,6 @@ split_cmdline (const gchar *cmdline, GPtrArray *array, GError **error)
|
||||
} else if (c == '\\') {
|
||||
escaped = TRUE;
|
||||
} else if (c == '\'' || c == '"') {
|
||||
in_quote = TRUE;
|
||||
quote_char = c;
|
||||
} else {
|
||||
g_string_append_c (str, c);
|
||||
@@ -76,7 +84,7 @@ split_cmdline (const gchar *cmdline, GPtrArray *array, GError **error)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (in_quote) {
|
||||
if (quote_char) {
|
||||
if (error)
|
||||
*error = g_error_new (G_LOG_DOMAIN, 0, "Unfinished quote.");
|
||||
g_string_free (str, TRUE);
|
||||
|
||||
+10
-3
@@ -53,6 +53,9 @@
|
||||
# ifdef HAVE_ICONV_H
|
||||
# include <iconv.h>
|
||||
# endif
|
||||
# ifdef HAVE_LOCALCHARSET_H
|
||||
# include <localcharset.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
static char *my_charset;
|
||||
@@ -217,8 +220,10 @@ g_convert (const gchar *str, gssize len,
|
||||
|
||||
convertor = iconv_open (to_codeset, from_codeset);
|
||||
if (convertor == (iconv_t) -1){
|
||||
*bytes_written = 0;
|
||||
*bytes_read = 0;
|
||||
if (bytes_written)
|
||||
*bytes_written = 0;
|
||||
if (bytes_read)
|
||||
*bytes_read = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -303,7 +308,9 @@ g_get_charset (G_CONST_RETURN char **charset)
|
||||
#else
|
||||
if (my_charset == NULL){
|
||||
/* These shouldn't be heap allocated */
|
||||
#if HAVE_LANGINFO_H
|
||||
#if HAVE_LOCALCHARSET_H
|
||||
my_charset = locale_charset ();
|
||||
#elif defined(HAVE_LANGINFO_H)
|
||||
my_charset = nl_langinfo (CODESET);
|
||||
#else
|
||||
my_charset = "UTF-8";
|
||||
|
||||
+8
-1
@@ -74,8 +74,11 @@ utf8_to_utf16_len (const gchar *str, glong len, glong *items_read, GError **erro
|
||||
for (in_pos = 0; in_pos < len && str [in_pos] < 0x80; in_pos++)
|
||||
ret ++;
|
||||
|
||||
if (in_pos == len)
|
||||
if (in_pos == len) {
|
||||
if (items_read)
|
||||
*items_read = in_pos;
|
||||
return ret;
|
||||
}
|
||||
|
||||
mb_size = 0;
|
||||
mb_remain = 0;
|
||||
@@ -214,6 +217,8 @@ g_utf8_to_utf16 (const gchar *str, glong len, glong *items_read, glong *items_wr
|
||||
if (len < 0)
|
||||
len = strlen (str);
|
||||
|
||||
if (items_read)
|
||||
*items_read = 0;
|
||||
if (items_written)
|
||||
*items_written = 0;
|
||||
utf16_len = utf8_to_utf16_len (str, len, items_read, error);
|
||||
@@ -311,6 +316,8 @@ g_utf16_to_utf8 (const gunichar2 *str, glong len, glong *items_read, glong *item
|
||||
out_pos = 0;
|
||||
surrogate = FALSE;
|
||||
|
||||
if (items_read)
|
||||
*items_read = 0;
|
||||
if (items_written)
|
||||
*items_written = 0;
|
||||
utf8_len = utf16_to_utf8_len (str, len, items_read, error);
|
||||
|
||||
@@ -226,6 +226,39 @@ test_shell_argv3 ()
|
||||
return OK;
|
||||
}
|
||||
|
||||
// This was the 2.8 showstopper error
|
||||
RESULT
|
||||
test_shell_argv4 ()
|
||||
{
|
||||
GError *error;
|
||||
gint argc;
|
||||
gchar **argv;
|
||||
gboolean ret;
|
||||
char *str = "'/usr/bin/gnome-terminal' -e \"bash -c 'read -p \\\"Press any key to continue...\\\" -n1;'\"";
|
||||
|
||||
argv = NULL;
|
||||
argc = 0;
|
||||
error = NULL;
|
||||
ret = g_shell_parse_argv (str, &argc, &argv, &error);
|
||||
if (!ret)
|
||||
return FAILED ("1. It should return TRUE");
|
||||
if (argc != 3)
|
||||
return FAILED ("2. argc was %d", argc);
|
||||
if (argv == NULL)
|
||||
return FAILED ("3. argv[0] was NULL");
|
||||
if (error != NULL)
|
||||
return FAILED ("4. error was set");
|
||||
|
||||
if (strcmp (argv [0], "/usr/bin/gnome-terminal"))
|
||||
return FAILED ("5. Expected /usr/bin/gnome-terminal got %s", argv [0]);
|
||||
if (strcmp (argv [1], "-e"))
|
||||
return FAILED ("6. Expected -e, got: %s", argv [1]);
|
||||
if (strcmp (argv [2], "bash -c 'read -p \"Press any key to continue...\" -n1;'"))
|
||||
return FAILED ("7. Got unexpected result: %s\n", argv [2]);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
RESULT
|
||||
test_quote ()
|
||||
{
|
||||
@@ -244,6 +277,7 @@ static Test shell_tests [] = {
|
||||
{"g_shell_parse_argv1", test_shell_argv1},
|
||||
{"g_shell_parse_argv2", test_shell_argv2},
|
||||
{"g_shell_parse_argv3", test_shell_argv3},
|
||||
{"g_shell_parse_argv4", test_shell_argv4},
|
||||
{"g_shell_quote", test_quote},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ obj_map.c os_dep.c pcr_interface.c ptr_chck.c real_malloc.c reclaim.c \
|
||||
solaris_pthreads.c solaris_threads.c specific.c stubborn.c typd_mlc.c \
|
||||
backgraph.c win32_threads.c \
|
||||
pthread_support.c pthread_stop_world.c darwin_stop_world.c \
|
||||
$(asm_libgc_sources)
|
||||
openbsd_stop_world.c $(asm_libgc_sources)
|
||||
|
||||
# Include THREADDLLIBS here to ensure that the correct versions of
|
||||
# linuxthread semaphore functions get linked:
|
||||
|
||||
@@ -147,6 +147,13 @@ case "$THREADS" in
|
||||
fi
|
||||
AC_DEFINE(THREAD_LOCAL_ALLOC)
|
||||
;;
|
||||
*-*-openbsd*)
|
||||
AC_DEFINE(GC_OPENBSD_THREADS)
|
||||
if test "${enable_parallel_mark}" = yes; then
|
||||
AC_DEFINE(PARALLEL_MARK)
|
||||
fi
|
||||
AC_DEFINE(THREAD_LOCAL_ALLOC)
|
||||
;;
|
||||
*-*-osf*)
|
||||
AC_DEFINE(GC_OSF1_THREADS)
|
||||
if test "${enable_parallel_mark}" = yes; then
|
||||
|
||||
+8
-1
@@ -57,6 +57,7 @@
|
||||
!defined(HPUX) && !(defined(LINUX) && defined(__ELF__)) && \
|
||||
!defined(RS6000) && !defined(SCO_ELF) && !defined(DGUX) && \
|
||||
!(defined(FREEBSD) && defined(__ELF__)) && \
|
||||
!(defined(OPENBSD) && (defined(__ELF__) || defined(M68K))) && \
|
||||
!(defined(NETBSD) && defined(__ELF__)) && !defined(HURD) && \
|
||||
!defined(DARWIN)
|
||||
--> We only know how to find data segments of dynamic libraries for the
|
||||
@@ -92,9 +93,12 @@
|
||||
|
||||
#if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF) || \
|
||||
(defined(FREEBSD) && defined(__ELF__)) || defined(DGUX) || \
|
||||
(defined(OPENBSD) && defined(__ELF__)) || \
|
||||
(defined(NETBSD) && defined(__ELF__)) || defined(HURD)
|
||||
# include <stddef.h>
|
||||
# if !defined(OPENBSD)
|
||||
# include <elf.h>
|
||||
# endif
|
||||
# include <link.h>
|
||||
#endif
|
||||
|
||||
@@ -295,6 +299,7 @@ void GC_register_dynamic_libraries()
|
||||
|
||||
#if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF) || \
|
||||
(defined(FREEBSD) && defined(__ELF__)) || defined(DGUX) || \
|
||||
(defined(OPENBSD) && defined(__ELF__)) || \
|
||||
(defined(NETBSD) && defined(__ELF__)) || defined(HURD)
|
||||
|
||||
|
||||
@@ -473,8 +478,10 @@ GC_bool GC_register_main_static_data()
|
||||
/* This doesn't necessarily work in all cases, e.g. with preloaded
|
||||
* dynamic libraries. */
|
||||
|
||||
#if defined(NETBSD)
|
||||
#if defined(NETBSD) || defined(OPENBSD)
|
||||
# if !defined(OPENBSD)
|
||||
# include <sys/exec_elf.h>
|
||||
# endif
|
||||
/* for compatibility with 1.4.x */
|
||||
# ifndef DT_DEBUG
|
||||
# define DT_DEBUG 21
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
defined(GC_HPUX_THREADS) || defined(GC_OSF1_THREADS) || \
|
||||
defined(GC_DGUX386_THREADS) || defined(GC_DARWIN_THREADS) || \
|
||||
defined(GC_AIX_THREADS) || defined(GC_NETBSD_THREADS) || \
|
||||
defined(GC_OPENBSD_THREADS) || \
|
||||
(defined(GC_WIN32_THREADS) && defined(__CYGWIN32__))
|
||||
# define GC_PTHREADS
|
||||
# endif
|
||||
@@ -87,6 +88,10 @@
|
||||
# define GC_DARWIN_THREADS
|
||||
# define GC_PTHREADS
|
||||
# endif
|
||||
# if !defined(GC_PTHREADS) && defined(__OpenBSD__)
|
||||
# define GC_OPENBSD_THREADS
|
||||
# define GC_PTHREADS
|
||||
# endif
|
||||
# if !defined(GC_PTHREADS) && defined(__FreeBSD__)
|
||||
# define GC_FREEBSD_THREADS
|
||||
# define GC_PTHREADS
|
||||
|
||||
@@ -231,6 +231,10 @@
|
||||
# define I386
|
||||
# define mach_type_known
|
||||
# endif
|
||||
# if defined(OPENBSD) && defined(__amd64__)
|
||||
# define X86_64
|
||||
# define mach_type_known
|
||||
# endif
|
||||
# if defined(LINUX) && defined(__x86_64__)
|
||||
# define X86_64
|
||||
# define mach_type_known
|
||||
@@ -1304,6 +1308,18 @@
|
||||
# endif
|
||||
# ifdef OPENBSD
|
||||
# define OS_TYPE "OPENBSD"
|
||||
# ifdef GC_OPENBSD_THREADS
|
||||
# define UTHREAD_SP_OFFSET 192
|
||||
# else
|
||||
# include <sys/param.h>
|
||||
# include <uvm/uvm_extern.h>
|
||||
# define STACKBOTTOM USRSTACK
|
||||
# endif
|
||||
extern int __data_start[];
|
||||
# define DATASTART ((ptr_t)(__data_start))
|
||||
extern char _end[];
|
||||
# define DATAEND ((ptr_t)(&_end))
|
||||
# define DYNAMIC_LOADING
|
||||
# endif
|
||||
# ifdef FREEBSD
|
||||
# define OS_TYPE "FREEBSD"
|
||||
@@ -2086,6 +2102,22 @@
|
||||
extern char etext[];
|
||||
# define SEARCH_FOR_DATA_START
|
||||
# endif
|
||||
# ifdef OPENBSD
|
||||
# define OS_TYPE "OPENBSD"
|
||||
# define ELF_CLASS ELFCLASS64
|
||||
# ifdef GC_OPENBSD_THREADS
|
||||
# define UTHREAD_SP_OFFSET 400
|
||||
# else
|
||||
# include <sys/param.h>
|
||||
# include <uvm/uvm_extern.h>
|
||||
# define STACKBOTTOM USRSTACK
|
||||
# endif
|
||||
extern int __data_start[];
|
||||
# define DATASTART ((ptr_t)(__data_start))
|
||||
extern char _end[];
|
||||
# define DATAEND ((ptr_t)(&_end))
|
||||
# define DYNAMIC_LOADING
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#if defined(LINUX) && defined(USE_MMAP)
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef GC_OPENBSD_STOP_WORLD_H
|
||||
#define GC_OPENBSD_STOP_WORLD_H
|
||||
|
||||
#if !defined(GC_OPENBSD_THREADS)
|
||||
#error openbsd_stop_world.h included without GC_OPENBSD_THREADS defined
|
||||
#endif
|
||||
|
||||
struct thread_stop_info {
|
||||
ptr_t stack_ptr; /* Valid only when stopped. */
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#if defined(GC_DARWIN_THREADS)
|
||||
# include "private/darwin_stop_world.h"
|
||||
#elif defined(GC_OPENBSD_THREADS)
|
||||
# include "private/openbsd_stop_world.h"
|
||||
#else
|
||||
# include "private/pthread_stop_world.h"
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -492,7 +492,7 @@ ptr_t cold_gc_frame;
|
||||
/* the stack. Return sp. */
|
||||
# ifdef SPARC
|
||||
asm(" .seg \"text\"");
|
||||
# if defined(SVR4) || defined(NETBSD) || defined(FREEBSD)
|
||||
# if defined(SVR4) || defined(NETBSD) || defined(FREEBSD) || defined(OPENBSD)
|
||||
asm(" .globl GC_save_regs_in_stack");
|
||||
asm("GC_save_regs_in_stack:");
|
||||
asm(" .type GC_save_regs_in_stack,#function");
|
||||
|
||||
+2
-2
@@ -473,7 +473,7 @@ size_t GC_get_total_bytes GC_PROTO(())
|
||||
|
||||
int GC_get_suspend_signal GC_PROTO(())
|
||||
{
|
||||
#if defined(SIG_SUSPEND) && defined(GC_PTHREADS) && !defined(GC_MACOSX_THREADS)
|
||||
#if defined(SIG_SUSPEND) && defined(GC_PTHREADS) && !defined(GC_MACOSX_THREADS) && !defined(GC_OPENBSD_THREADS)
|
||||
return SIG_SUSPEND;
|
||||
#else
|
||||
return -1;
|
||||
@@ -684,7 +684,7 @@ void GC_init_inner()
|
||||
# if defined(SEARCH_FOR_DATA_START)
|
||||
GC_init_linux_data_start();
|
||||
# endif
|
||||
# if (defined(NETBSD) || defined(OPENBSD)) && defined(__ELF__)
|
||||
# if defined(NETBSD) && defined(__ELF__)
|
||||
GC_init_netbsd_elf();
|
||||
# endif
|
||||
# if defined(GC_PTHREADS) || defined(GC_SOLARIS_THREADS) \
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
#include "private/pthread_support.h"
|
||||
|
||||
/* derived from pthread_stop_world.c */
|
||||
|
||||
# if defined(GC_OPENBSD_THREADS)
|
||||
|
||||
#define THREAD_EQUAL(id1, id2) pthread_equal(id1, id2)
|
||||
|
||||
/* We hold allocation lock. Should do exactly the right thing if the */
|
||||
/* world is stopped. Should not fail if it isn't. */
|
||||
void GC_push_all_stacks()
|
||||
{
|
||||
GC_bool found_me = FALSE;
|
||||
size_t nthreads = 0;
|
||||
int i;
|
||||
GC_thread p;
|
||||
ptr_t lo, hi;
|
||||
pthread_t me = pthread_self();
|
||||
|
||||
if (!GC_thr_initialized) GC_thr_init();
|
||||
# if DEBUG_THREADS
|
||||
GC_printf("Pushing stacks from thread 0x%x\n", (unsigned) me);
|
||||
# endif
|
||||
for (i = 0; i < THREAD_TABLE_SZ; i++) {
|
||||
for (p = GC_threads[i]; p != 0; p = p -> next) {
|
||||
if (p -> flags & FINISHED) continue;
|
||||
++nthreads;
|
||||
if (THREAD_EQUAL(p -> id, me)) {
|
||||
# ifdef SPARC
|
||||
lo = (ptr_t)GC_save_regs_in_stack();
|
||||
# else
|
||||
lo = GC_approx_sp();
|
||||
# endif
|
||||
found_me = TRUE;
|
||||
} else {
|
||||
lo = p -> stop_info.stack_ptr;
|
||||
}
|
||||
if ((p -> flags & MAIN_THREAD) == 0) {
|
||||
hi = p -> stack_end;
|
||||
} else {
|
||||
/* The original stack. */
|
||||
hi = GC_stackbottom;
|
||||
}
|
||||
# if DEBUG_THREADS
|
||||
GC_printf("Stack for thread 0x%x = [%p,%p)\n",
|
||||
(unsigned)(p -> id), lo, hi);
|
||||
# endif
|
||||
if (0 == lo) ABORT("GC_push_all_stacks: sp not set!\n");
|
||||
# ifdef STACK_GROWS_UP
|
||||
/* We got them backwards! */
|
||||
GC_push_all_stack(hi, lo);
|
||||
# else
|
||||
GC_push_all_stack(lo, hi);
|
||||
# endif
|
||||
}
|
||||
}
|
||||
if (!found_me && !GC_in_thread_creation)
|
||||
ABORT("Collecting from unknown thread.");
|
||||
}
|
||||
|
||||
/* We hold the allocation lock. Suspend all threads that might */
|
||||
/* still be running. */
|
||||
void GC_suspend_all()
|
||||
{
|
||||
int i;
|
||||
GC_thread p;
|
||||
int result;
|
||||
pthread_t my_thread = pthread_self();
|
||||
|
||||
for (i = 0; i < THREAD_TABLE_SZ; i++) {
|
||||
for (p = GC_threads[i]; p != 0; p = p -> next) {
|
||||
if (!THREAD_EQUAL(p -> id, my_thread)) {
|
||||
if (p -> flags & FINISHED) continue;
|
||||
if (p -> thread_blocked) /* Will wait */ continue;
|
||||
# if DEBUG_THREADS
|
||||
GC_printf("Suspending thread 0x%x\n",
|
||||
(unsigned)(p -> id));
|
||||
# endif
|
||||
|
||||
if (pthread_suspend_np(p -> id) != 0)
|
||||
ABORT("pthread_suspend_np failed");
|
||||
|
||||
/*
|
||||
* This will only work for userland pthreads. It will
|
||||
* fail badly on rthreads. Perhaps we should consider
|
||||
* a pthread_sp_np() function that returns the stack
|
||||
* pointer for a suspended thread and implement in
|
||||
* both pthreads and rthreads.
|
||||
*/
|
||||
p -> stop_info.stack_ptr = *(ptr_t*)((char *)p -> id + UTHREAD_SP_OFFSET);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GC_stop_world()
|
||||
{
|
||||
int i;
|
||||
|
||||
GC_ASSERT(I_HOLD_LOCK());
|
||||
# if DEBUG_THREADS
|
||||
GC_printf("Stopping the world from 0x%x\n", (unsigned)pthread_self());
|
||||
# endif
|
||||
|
||||
/* Make sure all free list construction has stopped before we start. */
|
||||
/* No new construction can start, since free list construction is */
|
||||
/* required to acquire and release the GC lock before it starts, */
|
||||
/* and we have the lock. */
|
||||
# ifdef PARALLEL_MARK
|
||||
GC_acquire_mark_lock();
|
||||
GC_ASSERT(GC_fl_builder_count == 0);
|
||||
/* We should have previously waited for it to become zero. */
|
||||
# endif /* PARALLEL_MARK */
|
||||
|
||||
GC_suspend_all();
|
||||
|
||||
# ifdef PARALLEL_MARK
|
||||
GC_release_mark_lock();
|
||||
# endif
|
||||
#if DEBUG_THREADS
|
||||
GC_printf("World stopped from 0x%x\n", (unsigned)pthread_self());
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Caller holds allocation lock, and has held it continuously since */
|
||||
/* the world stopped. */
|
||||
void GC_start_world()
|
||||
{
|
||||
pthread_t my_thread = pthread_self();
|
||||
register int i;
|
||||
register GC_thread p;
|
||||
register int result;
|
||||
|
||||
# if DEBUG_THREADS
|
||||
GC_printf("World starting\n");
|
||||
# endif
|
||||
|
||||
for (i = 0; i < THREAD_TABLE_SZ; i++) {
|
||||
for (p = GC_threads[i]; p != 0; p = p -> next) {
|
||||
if (!THREAD_EQUAL(p -> id, my_thread)) {
|
||||
if (p -> flags & FINISHED) continue;
|
||||
if (p -> thread_blocked) continue;
|
||||
#if DEBUG_THREADS
|
||||
GC_printf("Resuming thread 0x%x\n",
|
||||
(unsigned)(p -> id));
|
||||
#endif
|
||||
|
||||
if (pthread_resume_np(p -> id) != 0)
|
||||
ABORT("pthread_kill failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
# if DEBUG_THREADS
|
||||
GC_printf("World started\n");
|
||||
# endif
|
||||
}
|
||||
|
||||
void GC_stop_init() {
|
||||
}
|
||||
|
||||
#endif
|
||||
+144
-2
@@ -392,7 +392,7 @@ static void *tiny_sbrk(ptrdiff_t increment)
|
||||
#define sbrk tiny_sbrk
|
||||
# endif /* ECOS */
|
||||
|
||||
#if (defined(NETBSD) || defined(OPENBSD)) && defined(__ELF__)
|
||||
#if defined(NETBSD) && defined(__ELF__)
|
||||
ptr_t GC_data_start;
|
||||
|
||||
void GC_init_netbsd_elf()
|
||||
@@ -405,6 +405,102 @@ static void *tiny_sbrk(ptrdiff_t increment)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(OPENBSD)
|
||||
static struct sigaction old_segv_act;
|
||||
sigjmp_buf GC_jmp_buf_openbsd;
|
||||
|
||||
# if defined(GC_OPENBSD_THREADS)
|
||||
# include <sys/syscall.h>
|
||||
sigset_t __syscall(quad_t, ...);
|
||||
# endif
|
||||
|
||||
/*
|
||||
* Dont use GC_find_limit() because siglongjmp out of the
|
||||
* signal handler by-passes our userland pthreads lib, leaving
|
||||
* SIGSEGV and SIGPROF masked. Instead use this custom one
|
||||
* that works-around the issues.
|
||||
*/
|
||||
|
||||
/*ARGSUSED*/
|
||||
void GC_fault_handler_openbsd(int sig)
|
||||
{
|
||||
siglongjmp(GC_jmp_buf_openbsd, 1);
|
||||
}
|
||||
|
||||
/* Return the first nonaddressible location > p or bound */
|
||||
/* Requires allocation lock. */
|
||||
ptr_t GC_find_limit_openbsd(ptr_t p, ptr_t bound)
|
||||
{
|
||||
static volatile ptr_t result;
|
||||
/* Safer if static, since otherwise it may not be */
|
||||
/* preserved across the longjmp. Can safely be */
|
||||
/* static since it's only called with the */
|
||||
/* allocation lock held. */
|
||||
struct sigaction act;
|
||||
size_t pgsz = (size_t)sysconf(_SC_PAGESIZE);
|
||||
|
||||
GC_ASSERT(I_HOLD_LOCK());
|
||||
|
||||
act.sa_handler = GC_fault_handler_openbsd;
|
||||
sigemptyset(&act.sa_mask);
|
||||
act.sa_flags = SA_NODEFER | SA_RESTART;
|
||||
sigaction(SIGSEGV, &act, &old_segv_act);
|
||||
|
||||
if (sigsetjmp(GC_jmp_buf_openbsd, 1) == 0) {
|
||||
result = (ptr_t)(((word)(p)) & ~(pgsz-1));
|
||||
for (;;) {
|
||||
result += pgsz;
|
||||
if (result >= bound) {
|
||||
result = bound;
|
||||
break;
|
||||
}
|
||||
GC_noop1((word)(*result));
|
||||
}
|
||||
}
|
||||
|
||||
# if defined(GC_OPENBSD_THREADS)
|
||||
/* due to the siglongjump we need to manually unmask SIGPROF */
|
||||
__syscall(SYS_sigprocmask, SIG_UNBLOCK, sigmask(SIGPROF));
|
||||
# endif
|
||||
|
||||
sigaction(SIGSEGV, &old_segv_act, 0);
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
/* Return first addressable location > p or bound */
|
||||
/* Requires allocation lock. */
|
||||
ptr_t GC_skip_hole_openbsd(ptr_t p, ptr_t bound)
|
||||
{
|
||||
static volatile ptr_t result;
|
||||
struct sigaction act;
|
||||
size_t pgsz = (size_t)sysconf(_SC_PAGESIZE);
|
||||
static volatile int firstpass;
|
||||
|
||||
GC_ASSERT(I_HOLD_LOCK());
|
||||
|
||||
act.sa_handler = GC_fault_handler_openbsd;
|
||||
sigemptyset(&act.sa_mask);
|
||||
act.sa_flags = SA_NODEFER | SA_RESTART;
|
||||
sigaction(SIGSEGV, &act, &old_segv_act);
|
||||
|
||||
firstpass = 1;
|
||||
result = (ptr_t)(((word)(p)) & ~(pgsz-1));
|
||||
if (sigsetjmp(GC_jmp_buf_openbsd, 1) != 0 || firstpass) {
|
||||
firstpass = 0;
|
||||
result += pgsz;
|
||||
if (result >= bound) {
|
||||
result = bound;
|
||||
} else
|
||||
GC_noop1((word)(*result));
|
||||
}
|
||||
|
||||
sigaction(SIGSEGV, &old_segv_act, 0);
|
||||
|
||||
return(result);
|
||||
}
|
||||
#endif
|
||||
|
||||
# ifdef OS2
|
||||
|
||||
# include <stddef.h>
|
||||
@@ -1021,7 +1117,8 @@ void *GC_set_stackbottom = NULL;
|
||||
#endif /* FREEBSD_STACKBOTTOM */
|
||||
|
||||
#if !defined(BEOS) && !defined(AMIGA) && !defined(MSWIN32) \
|
||||
&& !defined(MSWINCE) && !defined(OS2) && !defined(NOSYS) && !defined(ECOS)
|
||||
&& !defined(MSWINCE) && !defined(OS2) && !defined(NOSYS) && !defined(ECOS) \
|
||||
&& !defined(GC_OPENBSD_THREADS)
|
||||
|
||||
ptr_t GC_get_stack_base()
|
||||
{
|
||||
@@ -1081,6 +1178,25 @@ ptr_t GC_get_stack_base()
|
||||
|
||||
# endif /* ! AMIGA, !OS 2, ! MS Windows, !BEOS, !NOSYS, !ECOS */
|
||||
|
||||
#if defined(GC_OPENBSD_THREADS)
|
||||
|
||||
/* Find the stack using pthread_stackseg_np() */
|
||||
|
||||
# include <sys/signal.h>
|
||||
# include <pthread.h>
|
||||
# include <pthread_np.h>
|
||||
|
||||
#define HAVE_GET_STACK_BASE
|
||||
|
||||
ptr_t GC_get_stack_base()
|
||||
{
|
||||
stack_t stack;
|
||||
pthread_stackseg_np(pthread_self(), &stack);
|
||||
return stack.ss_sp;
|
||||
}
|
||||
|
||||
#endif /* GC_OPENBSD_THREADS */
|
||||
|
||||
/*
|
||||
* Register static data segment(s) as roots.
|
||||
* If more data segments are added later then they need to be registered
|
||||
@@ -1445,6 +1561,31 @@ int * etext_addr;
|
||||
|
||||
#else /* !OS2 && !Windows && !AMIGA */
|
||||
|
||||
#if defined(OPENBSD)
|
||||
|
||||
/*
|
||||
* Depending on arch alignment there can be multiple holes
|
||||
* between DATASTART & DATAEND. Scan from DATASTART - DATAEND
|
||||
* and register each region.
|
||||
*/
|
||||
void GC_register_data_segments(void)
|
||||
{
|
||||
ptr_t region_start, region_end;
|
||||
|
||||
region_start = DATASTART;
|
||||
|
||||
for(;;) {
|
||||
region_end = GC_find_limit_openbsd(region_start, DATAEND);
|
||||
GC_add_roots_inner(region_start, region_end, FALSE);
|
||||
if (region_end < DATAEND)
|
||||
region_start = GC_skip_hole_openbsd(region_end, DATAEND);
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
# else /* !OS2 && !Windows && !AMIGA && !OPENBSD */
|
||||
|
||||
void GC_register_data_segments()
|
||||
{
|
||||
# if !defined(PCR) && !defined(SRC_M3) && !defined(MACOS)
|
||||
@@ -1504,6 +1645,7 @@ void GC_register_data_segments()
|
||||
/* change. */
|
||||
}
|
||||
|
||||
# endif /* ! OPENBSD */
|
||||
# endif /* ! AMIGA */
|
||||
# endif /* ! MSWIN32 && ! MSWINCE*/
|
||||
# endif /* ! OS2 */
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
#if defined(GC_PTHREADS) && !defined(GC_SOLARIS_THREADS) \
|
||||
&& !defined(GC_IRIX_THREADS) && !defined(GC_WIN32_THREADS) \
|
||||
&& !defined(GC_DARWIN_THREADS) && !defined(GC_AIX_THREADS)
|
||||
&& !defined(GC_DARWIN_THREADS) && !defined(GC_AIX_THREADS) \
|
||||
&& !defined(GC_OPENBSD_THREADS)
|
||||
|
||||
#include <signal.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
@@ -68,7 +68,8 @@
|
||||
|
||||
# if (defined(GC_DGUX386_THREADS) || defined(GC_OSF1_THREADS) || \
|
||||
defined(GC_DARWIN_THREADS) || defined(GC_AIX_THREADS)) || \
|
||||
defined(GC_NETBSD_THREADS) && !defined(USE_PTHREAD_SPECIFIC)
|
||||
defined(GC_NETBSD_THREADS) && !defined(USE_PTHREAD_SPECIFIC) || \
|
||||
defined(GC_OPENBSD_THREADS)
|
||||
# define USE_PTHREAD_SPECIFIC
|
||||
# endif
|
||||
|
||||
@@ -129,7 +130,7 @@
|
||||
# include <sys/sysctl.h>
|
||||
#endif /* GC_DARWIN_THREADS */
|
||||
|
||||
#if defined(GC_NETBSD_THREADS)
|
||||
#if defined(GC_NETBSD_THREADS) || defined(GC_OPENBSD_THREADS)
|
||||
# include <sys/param.h>
|
||||
# include <sys/sysctl.h>
|
||||
#endif
|
||||
@@ -1037,7 +1038,7 @@ void GC_thr_init()
|
||||
GC_nprocs = sysconf(_SC_NPROC_ONLN);
|
||||
if (GC_nprocs <= 0) GC_nprocs = 1;
|
||||
# endif
|
||||
# if defined(GC_DARWIN_THREADS) || defined(GC_FREEBSD_THREADS) || defined(GC_NETBSD_THREADS)
|
||||
# if defined(GC_DARWIN_THREADS) || defined(GC_FREEBSD_THREADS) || defined(GC_NETBSD_THREADS) || defined(GC_OPENBSD_THREADS)
|
||||
int ncpus = 1;
|
||||
size_t len = sizeof(ncpus);
|
||||
sysctl((int[2]) {CTL_HW, HW_NCPU}, 2, &ncpus, &len, NULL, 0);
|
||||
@@ -1113,7 +1114,7 @@ void GC_init_parallel()
|
||||
}
|
||||
|
||||
|
||||
#if !defined(GC_DARWIN_THREADS)
|
||||
#if !defined(GC_DARWIN_THREADS) && !defined(GC_OPENBSD_THREADS)
|
||||
int WRAP_FUNC(pthread_sigmask)(int how, const sigset_t *set, sigset_t *oset)
|
||||
{
|
||||
sigset_t fudged_set;
|
||||
@@ -1341,7 +1342,8 @@ void * GC_start_routine_head(void * arg, void *base_addr,
|
||||
if (start) *start = si -> start_routine;
|
||||
if (start_arg) *start_arg = si -> arg;
|
||||
|
||||
sem_post(&(si -> registered)); /* Last action on si. */
|
||||
if (!(si->flags & FOREIGN_THREAD))
|
||||
sem_post(&(si -> registered)); /* Last action on si. */
|
||||
/* OK to deallocate. */
|
||||
# if defined(THREAD_LOCAL_ALLOC) && !defined(DBG_HDRS_ALL)
|
||||
LOCK();
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ int main()
|
||||
|| defined(GC_DARWIN_THREADS) || defined(GC_AIX_THREADS)
|
||||
printf("-lpthread\n");
|
||||
# endif
|
||||
# if defined(GC_FREEBSD_THREADS)
|
||||
# if defined(GC_FREEBSD_THREADS) || defined(GC_OPENBSD_THREADS)
|
||||
# if (__FREEBSD_version >= 500000)
|
||||
printf("-lpthread\n");
|
||||
# else
|
||||
|
||||
@@ -220,6 +220,13 @@ Specifies the diagnostics log level for
|
||||
.Sp
|
||||
Used to specify the file where the log will be stored, it defaults to
|
||||
standard output.
|
||||
.TP
|
||||
.I server=[y/n]
|
||||
Defaults to no, with the default option Mono will actively connect to the
|
||||
host/port configured with the \fBaddress\fR option. If you set it to 'y', it
|
||||
instructs the Mono runtime to start debugging in server mode, where Mono
|
||||
actively waits for the debugger front end to connect to the Mono process.
|
||||
Mono will print out to stdout the IP address and port where it is listening.
|
||||
.ne
|
||||
.RE
|
||||
.TP
|
||||
|
||||
@@ -23,6 +23,15 @@ Set or override project properties
|
||||
.B \//logger:<logger>
|
||||
Custom logger to log build events
|
||||
.TP
|
||||
.B \//toolsversion:version , /tv:version
|
||||
Specify the toolset version to use.
|
||||
|
||||
Eg. /tv:4.0
|
||||
This would cause 4.0 version of the Microsoft.Common.targets (among others) to be used. This overrides
|
||||
the value specified in a project file.
|
||||
|
||||
Valid values: 2.0, 3.0, 3.5 and 4.0
|
||||
.TP
|
||||
.B \//verbosity:<level>
|
||||
Logger verbosity level : quiet, minimal, normal, detailed, diagnostic
|
||||
.TP
|
||||
|
||||
@@ -37,24 +37,14 @@ using System.Diagnostics;
|
||||
[assembly: AssemblyDelaySign (true)]
|
||||
[assembly: AssemblyKeyFile("../ecma.pub")]
|
||||
|
||||
#if NET_2_0
|
||||
[assembly: AssemblyFileVersion (Consts.FxFileVersion)]
|
||||
[assembly: Debuggable (DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
|
||||
[assembly: CompilationRelaxations (CompilationRelaxations.NoStringInterning)]
|
||||
[assembly: Dependency ("System.Drawing,", LoadHint.Always)]
|
||||
[assembly: Dependency ("System,", LoadHint.Always)]
|
||||
[assembly: StringFreezing]
|
||||
[assembly: ComCompatibleVersion (1, 0, 3300, 0)]
|
||||
#elif NET_1_1
|
||||
[assembly: AssemblyTrademark ("")]
|
||||
[assembly: AssemblyConfiguration ("")]
|
||||
[assembly: ComCompatibleVersion (1, 0, 3300, 0)]
|
||||
[assembly: TypeLibVersion (1, 10)]
|
||||
#elif NET_1_0
|
||||
[assembly: AssemblyTrademark ("")]
|
||||
[assembly: AssemblyConfiguration ("")]
|
||||
#endif
|
||||
[assembly: AssemblyFileVersion (Consts.FxFileVersion)]
|
||||
[assembly: Debuggable (DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
|
||||
[assembly: CompilationRelaxations (CompilationRelaxations.NoStringInterning)]
|
||||
[assembly: Dependency ("System.Drawing,", LoadHint.Always)]
|
||||
[assembly: Dependency ("System,", LoadHint.Always)]
|
||||
[assembly: StringFreezing]
|
||||
[assembly: ComCompatibleVersion (1, 0, 3300, 0)]
|
||||
|
||||
[assembly: InternalsVisibleTo("UIAutomationWinforms, PublicKey=00240000048000009400000006020000002400005253413100040000110000004bb98b1af6c1df0df8c02c380e116b7a7f0c8c827aecfccddc6e29b7c754cd608b49dfcef4df9699ad182e50f66afa4e68dabc7b6aeeec0aa4719a5f8e0aae8c193080a706adc3443a8356b1f254142034995532ac176398e12a30f6a74a119a89ac47672c9ae24d7e90de686557166e3b873cd707884431a0451d9d6f7fe795")]
|
||||
[assembly: InternalsVisibleTo("Mono.WinformsSupport, PublicKey=00240000048000009400000006020000002400005253413100040000110000004bb98b1af6c1df0df8c02c380e116b7a7f0c8c827aecfccddc6e29b7c754cd608b49dfcef4df9699ad182e50f66afa4e68dabc7b6aeeec0aa4719a5f8e0aae8c193080a706adc3443a8356b1f254142034995532ac176398e12a30f6a74a119a89ac47672c9ae24d7e90de686557166e3b873cd707884431a0451d9d6f7fe795")]
|
||||
|
||||
#if NET_2_0
|
||||
[assembly: InternalsVisibleTo("UIAutomationWinforms, PublicKey=00240000048000009400000006020000002400005253413100040000110000004bb98b1af6c1df0df8c02c380e116b7a7f0c8c827aecfccddc6e29b7c754cd608b49dfcef4df9699ad182e50f66afa4e68dabc7b6aeeec0aa4719a5f8e0aae8c193080a706adc3443a8356b1f254142034995532ac176398e12a30f6a74a119a89ac47672c9ae24d7e90de686557166e3b873cd707884431a0451d9d6f7fe795")]
|
||||
#endif
|
||||
@@ -50,7 +50,11 @@ namespace System.Windows.Forms.CarbonInternal {
|
||||
private static DragTrackingDelegate DragTrackingHandler = new DragTrackingDelegate (TrackingCallback);
|
||||
|
||||
static Dnd () {
|
||||
InstallTrackingHandler (DragTrackingHandler, IntPtr.Zero, IntPtr.Zero);
|
||||
try {
|
||||
InstallTrackingHandler (DragTrackingHandler, IntPtr.Zero, IntPtr.Zero);
|
||||
} catch (EntryPointNotFoundException) {
|
||||
// it is deprecated in 10.6 and does not exist anymore.
|
||||
}
|
||||
}
|
||||
|
||||
internal Dnd () {
|
||||
|
||||
@@ -410,7 +410,7 @@ namespace System.Windows.Forms {
|
||||
else if (e.NewIndex <= listposition) {
|
||||
/* the deleted row was either the current one, or one earlier in the list.
|
||||
Update the index and emit PositionChanged, CurrentChanged, and ItemChanged. */
|
||||
ChangeRecordState (e.NewIndex,
|
||||
ChangeRecordState (listposition+1,
|
||||
false, false, e.NewIndex != listposition, false);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -6272,7 +6272,7 @@ namespace System.Windows.Forms {
|
||||
if (disp_x == Columns.Count - 1)
|
||||
delta_x = horizontalScrollBar.Maximum - horizontalScrollBar.Value;
|
||||
else
|
||||
for (int i = first_col_index + displayedColumnsCount - 1; i < disp_x; i++)
|
||||
for (int i = first_col_index + displayedColumnsCount - 1; i < disp_x && i != -1; i++)
|
||||
delta_x += Columns[ColumnDisplayIndexToIndex (i)].Width;
|
||||
|
||||
horizontalScrollBar.SafeValueSet (horizontalScrollBar.Value + delta_x);
|
||||
|
||||
@@ -103,6 +103,10 @@ namespace System.Windows.Forms {
|
||||
private Rectangle restore_bounds;
|
||||
private bool autoscale_base_size_set;
|
||||
#endif
|
||||
|
||||
internal ArrayList disabled_by_showdialog = new ArrayList();
|
||||
internal static ArrayList modal_dialogs = new ArrayList();
|
||||
|
||||
#endregion // Local Variables
|
||||
|
||||
#region Private & Internal Methods
|
||||
@@ -1787,6 +1791,16 @@ namespace System.Windows.Forms {
|
||||
XplatUI.UngrabWindow(capture_window);
|
||||
}
|
||||
|
||||
foreach (Form form in Application.OpenForms)
|
||||
{
|
||||
if (form.Enabled == true)
|
||||
{
|
||||
disabled_by_showdialog.Add(form);
|
||||
form.Enabled = false;
|
||||
}
|
||||
}
|
||||
modal_dialogs.Add(this);
|
||||
|
||||
#if not
|
||||
// Commented out; we instead let the Visible=true inside the runloop create the control
|
||||
// otherwise setting DialogResult inside any of the events that are triggered by the
|
||||
@@ -2660,6 +2674,9 @@ namespace System.Windows.Forms {
|
||||
|
||||
private void WmClose (ref Message m)
|
||||
{
|
||||
if (this.Enabled == false)
|
||||
return; // prevent closing a disabled form.
|
||||
|
||||
Form act = Form.ActiveForm;
|
||||
// Don't close this form if there's another modal form visible.
|
||||
if (act != null && act != this && act.Modal == true) {
|
||||
@@ -2744,6 +2761,12 @@ namespace System.Windows.Forms {
|
||||
#endif
|
||||
private void WmActivate (ref Message m)
|
||||
{
|
||||
if (!this.Enabled && modal_dialogs.Count > 0)
|
||||
{
|
||||
(modal_dialogs[modal_dialogs.Count -1] as Form).Activate ();
|
||||
return; // prevent Activating of disabled form.
|
||||
}
|
||||
|
||||
if (m.WParam != (IntPtr)WindowActiveFlags.WA_INACTIVE) {
|
||||
if (is_loaded) {
|
||||
SelectActiveControl ();
|
||||
@@ -3241,6 +3264,14 @@ namespace System.Windows.Forms {
|
||||
FormClosedEventHandler eh = (FormClosedEventHandler)(Events[FormClosedEvent]);
|
||||
if (eh != null)
|
||||
eh (this, e);
|
||||
|
||||
foreach (Form form in disabled_by_showdialog)
|
||||
{
|
||||
form.Enabled = true;
|
||||
}
|
||||
disabled_by_showdialog.Clear();
|
||||
if (modal_dialogs.Contains(this))
|
||||
modal_dialogs.Remove(this);
|
||||
}
|
||||
|
||||
// Consider calling FireClosingEvents instead of calling this directly.
|
||||
|
||||
@@ -1153,7 +1153,8 @@ namespace System.Windows.Forms
|
||||
break;
|
||||
case 2: // Marquee
|
||||
int ms_diff = (int)(DateTime.Now - ctrl.start).TotalMilliseconds;
|
||||
double percent_done = (double)ms_diff % (double)ctrl.MarqueeAnimationSpeed / (double)ctrl.MarqueeAnimationSpeed;
|
||||
double percent_done = (double) ms_diff / ProgressBarMarqueeSpeedScaling
|
||||
% (double)ctrl.MarqueeAnimationSpeed / (double)ctrl.MarqueeAnimationSpeed;
|
||||
max_blocks = 5;
|
||||
start_pixel = client_area.X + (int)(client_area.Width * percent_done);
|
||||
goto default;
|
||||
|
||||
@@ -4287,7 +4287,8 @@ namespace System.Windows.Forms
|
||||
case 2: // Marquee
|
||||
if (XplatUI.ThemesEnabled) {
|
||||
int ms_diff = (int) (DateTime.Now - ctrl.start).TotalMilliseconds;
|
||||
double percent_done = (double) ms_diff % (double)ctrl.MarqueeAnimationSpeed / (double)ctrl.MarqueeAnimationSpeed;
|
||||
double percent_done = (double) ms_diff / ProgressBarMarqueeSpeedScaling
|
||||
% (double)ctrl.MarqueeAnimationSpeed / (double)ctrl.MarqueeAnimationSpeed;
|
||||
max_blocks = 5;
|
||||
start_pixel = client_area.X + (int) (client_area.Width * percent_done);
|
||||
}
|
||||
@@ -4353,6 +4354,8 @@ namespace System.Windows.Forms
|
||||
}
|
||||
}
|
||||
|
||||
public const double ProgressBarMarqueeSpeedScaling = 15;
|
||||
|
||||
#endregion // ProgressBar
|
||||
|
||||
#region RadioButton
|
||||
|
||||
@@ -449,20 +449,20 @@ namespace System.Windows.Forms
|
||||
direction = ToolStripDropDownDirection.BelowRight;
|
||||
break;
|
||||
case ToolStripDropDownDirection.BelowLeft:
|
||||
if (show_point.Y + this.Height > max_screen.Y)
|
||||
if (show_point.Y + this.Height > max_screen.Y && show_point.Y - this.Height > 0)
|
||||
direction = ToolStripDropDownDirection.AboveLeft;
|
||||
break;
|
||||
case ToolStripDropDownDirection.BelowRight:
|
||||
case ToolStripDropDownDirection.Default:
|
||||
if (show_point.Y + this.Height > max_screen.Y)
|
||||
if (show_point.Y + this.Height > max_screen.Y && show_point.Y - this.Height > 0)
|
||||
direction = ToolStripDropDownDirection.AboveRight;
|
||||
break;
|
||||
case ToolStripDropDownDirection.Left:
|
||||
if (show_point.Y + this.Height > max_screen.Y)
|
||||
if (show_point.Y + this.Height > max_screen.Y && show_point.Y - this.Height > 0)
|
||||
direction = ToolStripDropDownDirection.AboveLeft;
|
||||
break;
|
||||
case ToolStripDropDownDirection.Right:
|
||||
if (show_point.Y + this.Height > max_screen.Y)
|
||||
if (show_point.Y + this.Height > max_screen.Y && show_point.Y - this.Height > 0)
|
||||
direction = ToolStripDropDownDirection.AboveRight;
|
||||
break;
|
||||
}
|
||||
@@ -486,12 +486,18 @@ namespace System.Windows.Forms
|
||||
break;
|
||||
}
|
||||
|
||||
// Fix offscreen positions
|
||||
// Fix offscreen horizontal positions
|
||||
if ((show_point.X + this.Width) > max_screen.X)
|
||||
show_point.X = max_screen.X - this.Width;
|
||||
if (show_point.X < 0)
|
||||
show_point.X = 0;
|
||||
|
||||
|
||||
// Fix offscreen vertical positions
|
||||
if ((show_point.Y + this.Height) > max_screen.Y)
|
||||
show_point.Y = max_screen.Y - this.Height;
|
||||
if (show_point.Y < 0)
|
||||
show_point.Y = 0;
|
||||
|
||||
if (this.Location != show_point)
|
||||
this.Location = show_point;
|
||||
|
||||
|
||||
@@ -30,9 +30,19 @@ using System;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System.Windows.Forms {
|
||||
#if PUBLIC_TYPES
|
||||
namespace Mono.Winforms
|
||||
#else
|
||||
namespace System.Windows.Forms
|
||||
#endif
|
||||
{
|
||||
[Flags]
|
||||
internal enum WindowStyles : int {
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
enum WindowStyles : int {
|
||||
WS_OVERLAPPED = 0x00000000,
|
||||
WS_POPUP = unchecked((int)0x80000000),
|
||||
WS_CHILD = 0x40000000,
|
||||
@@ -63,7 +73,12 @@ namespace System.Windows.Forms {
|
||||
}
|
||||
|
||||
[Flags]
|
||||
internal enum WindowExStyles : int {
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
enum WindowExStyles : int {
|
||||
// Extended Styles
|
||||
WS_EX_DLGMODALFRAME = 0x00000001,
|
||||
WS_EX_DRAGDETECT = 0x00000002,
|
||||
@@ -99,14 +114,24 @@ namespace System.Windows.Forms {
|
||||
}
|
||||
|
||||
[Flags]
|
||||
internal enum ToolBarStyles : int {
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
enum ToolBarStyles : int {
|
||||
TBSTYLE_TOOLTIPS = 0x100,
|
||||
TBSTYLE_FLAT = 0x800,
|
||||
TBSTYLE_LIST = 0x1000,
|
||||
TBSTYLE_TRANSPARENT = 0x8000
|
||||
}
|
||||
|
||||
internal enum Msg {
|
||||
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
enum Msg {
|
||||
WM_NULL = 0x0000,
|
||||
WM_CREATE = 0x0001,
|
||||
WM_DESTROY = 0x0002,
|
||||
@@ -358,7 +383,12 @@ namespace System.Windows.Forms {
|
||||
NIN_BALLOONUSERCLICK = WM_USER + 0x0005
|
||||
}
|
||||
|
||||
internal enum MsgButtons {
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
enum MsgButtons {
|
||||
MK_LBUTTON = 0x0001,
|
||||
MK_RBUTTON = 0x0002,
|
||||
MK_SHIFT = 0x0004,
|
||||
@@ -367,8 +397,13 @@ namespace System.Windows.Forms {
|
||||
MK_XBUTTON1 = 0x0020,
|
||||
MK_XBUTTON2 = 0x0040,
|
||||
}
|
||||
|
||||
internal enum MsgUIState {
|
||||
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
enum MsgUIState {
|
||||
UIS_SET = 1,
|
||||
UIS_CLEAR = 2,
|
||||
UIS_INITIALIZE = 3,
|
||||
@@ -378,17 +413,22 @@ namespace System.Windows.Forms {
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct POINT {
|
||||
internal int x;
|
||||
internal int y;
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
struct POINT {
|
||||
public int x;
|
||||
public int y;
|
||||
|
||||
internal POINT (int x, int y)
|
||||
public POINT (int x, int y)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
internal Point ToPoint ()
|
||||
public Point ToPoint ()
|
||||
{
|
||||
return new Point (x, y);
|
||||
}
|
||||
@@ -400,7 +440,12 @@ namespace System.Windows.Forms {
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct MSG {
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
struct MSG {
|
||||
internal IntPtr hwnd;
|
||||
internal Msg message;
|
||||
internal IntPtr wParam;
|
||||
@@ -416,26 +461,46 @@ namespace System.Windows.Forms {
|
||||
}
|
||||
|
||||
[Flags]
|
||||
internal enum TransparencySupport {
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
enum TransparencySupport {
|
||||
None = 0x00,
|
||||
Get = 0x01,
|
||||
Set = 0x02,
|
||||
GetSet = 0x03
|
||||
}
|
||||
|
||||
internal enum WindowActiveFlags {
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
enum WindowActiveFlags {
|
||||
WA_INACTIVE = 0,
|
||||
WA_ACTIVE = 1,
|
||||
WA_CLICKACTIVE = 2
|
||||
}
|
||||
|
||||
internal enum KeybdEventFlags {
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
enum KeybdEventFlags {
|
||||
None = 0,
|
||||
ExtendedKey = 0x0001,
|
||||
KeyUp = 0x0002
|
||||
}
|
||||
|
||||
internal enum VirtualKeys {
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
enum VirtualKeys {
|
||||
VK_LBUTTON = 0x01,
|
||||
VK_RBUTTON = 0x02,
|
||||
VK_CANCEL = 0x03,
|
||||
@@ -590,7 +655,12 @@ namespace System.Windows.Forms {
|
||||
VK_OEM_CLEAR = 0xFE,
|
||||
}
|
||||
|
||||
internal enum TtyKeys {
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
enum TtyKeys {
|
||||
XK_BackSpace = 0xff08, /* Back space, back char */
|
||||
XK_Tab = 0xff09,
|
||||
XK_Linefeed = 0xff0a, /* Linefeed, LF */
|
||||
@@ -603,7 +673,12 @@ namespace System.Windows.Forms {
|
||||
XK_Delete = 0xffff /* Delete, rubout */
|
||||
}
|
||||
|
||||
internal enum MiscKeys {
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
enum MiscKeys {
|
||||
XK_ISO_Lock = 0xfe01,
|
||||
XK_ISO_Last_Group_Lock = 0xfe0f,
|
||||
XK_Select = 0xff60,
|
||||
@@ -622,7 +697,12 @@ namespace System.Windows.Forms {
|
||||
XK_Num_Lock = 0xff7f
|
||||
}
|
||||
|
||||
internal enum KeypadKeys {
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
enum KeypadKeys {
|
||||
XK_KP_Space = 0xff80,
|
||||
XK_KP_Tab = 0xff89,
|
||||
XK_KP_Enter = 0xff8d, /* Enter */
|
||||
@@ -663,7 +743,12 @@ namespace System.Windows.Forms {
|
||||
XK_KP_9 = 0xffb9
|
||||
}
|
||||
|
||||
internal enum DeadKeys {
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
enum DeadKeys {
|
||||
XK_dead_grave = 0xfe50,
|
||||
XK_dead_acute = 0xfe51,
|
||||
XK_dead_circumflex = 0xfe52,
|
||||
@@ -687,7 +772,12 @@ namespace System.Windows.Forms {
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct HELPINFO {
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
struct HELPINFO {
|
||||
internal uint cbSize;
|
||||
internal int iContextType;
|
||||
internal int iCtrlId;
|
||||
@@ -696,13 +786,23 @@ namespace System.Windows.Forms {
|
||||
internal POINT MousePos;
|
||||
}
|
||||
|
||||
internal enum PeekMessageFlags {
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
enum PeekMessageFlags {
|
||||
PM_NOREMOVE = 0x00000000,
|
||||
PM_REMOVE = 0x00000001,
|
||||
PM_NOYIELD = 0x00000002
|
||||
}
|
||||
|
||||
internal enum StdCursor {
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
enum StdCursor {
|
||||
Default = 0,
|
||||
AppStarting = 1,
|
||||
Arrow = 2,
|
||||
@@ -733,7 +833,12 @@ namespace System.Windows.Forms {
|
||||
WaitCursor = 27
|
||||
}
|
||||
|
||||
internal enum HitTest {
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
enum HitTest {
|
||||
HTERROR = -2,
|
||||
HTTRANSPARENT = -1,
|
||||
HTNOWHERE = 0,
|
||||
@@ -765,14 +870,24 @@ namespace System.Windows.Forms {
|
||||
HTHELP = 21
|
||||
}
|
||||
|
||||
internal enum TitleStyle {
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
enum TitleStyle {
|
||||
None = 0,
|
||||
Normal = 1,
|
||||
Tool = 2
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct BITMAPINFOHEADER {
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
struct BITMAPINFOHEADER {
|
||||
internal uint biSize;
|
||||
internal int biWidth;
|
||||
internal int biHeight;
|
||||
@@ -786,7 +901,12 @@ namespace System.Windows.Forms {
|
||||
internal uint biClrImportant;
|
||||
}
|
||||
|
||||
internal enum ClipboardFormats : ushort {
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
enum ClipboardFormats : ushort {
|
||||
CF_TEXT = 1,
|
||||
CF_BITMAP = 2,
|
||||
CF_METAFILEPICT = 3,
|
||||
@@ -807,7 +927,12 @@ namespace System.Windows.Forms {
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
|
||||
internal struct MINMAXINFO {
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
struct MINMAXINFO {
|
||||
internal POINT ptReserved;
|
||||
internal POINT ptMaxSize;
|
||||
internal POINT ptMaxPosition;
|
||||
@@ -816,7 +941,12 @@ namespace System.Windows.Forms {
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
|
||||
internal struct KeyFilterData {
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
struct KeyFilterData {
|
||||
internal bool Down;
|
||||
internal int keycode;
|
||||
internal int keysym;
|
||||
@@ -824,7 +954,12 @@ namespace System.Windows.Forms {
|
||||
internal String str;
|
||||
}
|
||||
|
||||
internal enum ScrollBarCommands {
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
enum ScrollBarCommands {
|
||||
SB_LINEUP = 0,
|
||||
SB_LINELEFT = 0,
|
||||
SB_LINEDOWN = 1,
|
||||
@@ -842,7 +977,12 @@ namespace System.Windows.Forms {
|
||||
SB_ENDSCROLL = 8
|
||||
}
|
||||
|
||||
internal enum ClipCombineMode {
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
enum ClipCombineMode {
|
||||
RGN_AND = 1,
|
||||
RGN_OR,
|
||||
RGN_XOR,
|
||||
@@ -853,7 +993,12 @@ namespace System.Windows.Forms {
|
||||
RGN_MAX = RGN_COPY
|
||||
}
|
||||
|
||||
internal enum SystemCommands {
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
enum SystemCommands {
|
||||
SC_SIZE = 0xF000,
|
||||
SC_MOVE = 0xF010,
|
||||
SC_MINIMIZE = 0xF020,
|
||||
@@ -875,7 +1020,12 @@ namespace System.Windows.Forms {
|
||||
SC_CONTEXTHELP = 0xF180
|
||||
}
|
||||
|
||||
internal enum AlertType {
|
||||
#if PUBLIC_TYPES
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
enum AlertType {
|
||||
Default = 1,
|
||||
Error = 2,
|
||||
Question = 3,
|
||||
|
||||
@@ -1648,6 +1648,10 @@ namespace System.Windows.Forms {
|
||||
}
|
||||
|
||||
private void UpdateMessageQueue (XEventQueue queue) {
|
||||
UpdateMessageQueue(queue, true);
|
||||
}
|
||||
|
||||
private void UpdateMessageQueue (XEventQueue queue, bool allowIdle) {
|
||||
DateTime now;
|
||||
int pending;
|
||||
Hwnd hwnd;
|
||||
@@ -1658,7 +1662,7 @@ namespace System.Windows.Forms {
|
||||
pending = XPending (DisplayHandle);
|
||||
}
|
||||
|
||||
if (pending == 0) {
|
||||
if (pending == 0 && allowIdle) {
|
||||
if ((queue == null || queue.DispatchIdle) && Idle != null) {
|
||||
Idle (this, EventArgs.Empty);
|
||||
}
|
||||
@@ -2679,7 +2683,7 @@ namespace System.Windows.Forms {
|
||||
|
||||
Clipboard.Enumerating = true;
|
||||
while (Clipboard.Enumerating) {
|
||||
UpdateMessageQueue(null);
|
||||
UpdateMessageQueue(null, false);
|
||||
}
|
||||
f = f.Next;
|
||||
}
|
||||
@@ -2740,7 +2744,7 @@ namespace System.Windows.Forms {
|
||||
|
||||
Clipboard.Retrieving = true;
|
||||
while (Clipboard.Retrieving) {
|
||||
UpdateMessageQueue(null);
|
||||
UpdateMessageQueue(null, false);
|
||||
}
|
||||
|
||||
return Clipboard.Item;
|
||||
@@ -4444,8 +4448,8 @@ namespace System.Windows.Forms {
|
||||
}
|
||||
goto ProcessNextMessage;
|
||||
}
|
||||
SendMessage(FocusWindow, Msg.WM_SETFOCUS, IntPtr.Zero, IntPtr.Zero);
|
||||
Keyboard.FocusIn (FocusWindow);
|
||||
SendMessage(FocusWindow, Msg.WM_SETFOCUS, IntPtr.Zero, IntPtr.Zero);
|
||||
goto ProcessNextMessage;
|
||||
}
|
||||
|
||||
@@ -5607,9 +5611,9 @@ namespace System.Windows.Forms {
|
||||
|
||||
if (prev_focus_window != IntPtr.Zero) {
|
||||
SendMessage(prev_focus_window, Msg.WM_KILLFOCUS, FocusWindow, IntPtr.Zero);
|
||||
}
|
||||
SendMessage(FocusWindow, Msg.WM_SETFOCUS, prev_focus_window, IntPtr.Zero);
|
||||
}
|
||||
Keyboard.FocusIn (FocusWindow);
|
||||
SendMessage(FocusWindow, Msg.WM_SETFOCUS, prev_focus_window, IntPtr.Zero);
|
||||
|
||||
//XSetInputFocus(DisplayHandle, Hwnd.ObjectFromHandle(handle).client_window, RevertTo.None, IntPtr.Zero);
|
||||
}
|
||||
|
||||
@@ -4,15 +4,11 @@ include ../../build/rules.make
|
||||
|
||||
LIBRARY = Microsoft.Build.Engine.dll
|
||||
|
||||
ifeq (1.0, $(FRAMEWORK_VERSION))
|
||||
LIBRARY_NAME = dummy-Microsoft.Build.Engine.dll
|
||||
NO_INSTALL = yes
|
||||
NO_TEST = yes
|
||||
NO_SIGN_ASSEMBLY = yes
|
||||
endif
|
||||
BUILD_FRAMEWORK = Microsoft.Build.Framework.dll
|
||||
|
||||
ifeq (3.5, $(FRAMEWORK_VERSION))
|
||||
NAME_SUFFIX = .v3.5
|
||||
BUILD_FRAMEWORK := $(topdir)/class/lib/$(PROFILE)/$(BUILD_FRAMEWORK)
|
||||
else
|
||||
ifeq (4.0, $(FRAMEWORK_VERSION))
|
||||
NAME_SUFFIX = .v4.0
|
||||
@@ -24,11 +20,11 @@ LIB_MCS_FLAGS = \
|
||||
/r:System.dll \
|
||||
/r:System.Core.dll \
|
||||
/r:System.Xml.dll \
|
||||
/r:Microsoft.Build.Framework.dll \
|
||||
/r:$(BUILD_FRAMEWORK) \
|
||||
/r:Microsoft.Build.Utilities$(NAME_SUFFIX).dll
|
||||
|
||||
TEST_MCS_FLAGS = \
|
||||
/r:Microsoft.Build.Framework.dll \
|
||||
/r:$(BUILD_FRAMEWORK) \
|
||||
/r:Microsoft.Build.Utilities$(NAME_SUFFIX).dll
|
||||
|
||||
EXTRA_DISTFILES = \
|
||||
|
||||
@@ -84,36 +84,38 @@ namespace Microsoft.Build.BuildEngine {
|
||||
[MonoTODO]
|
||||
public bool Execute ()
|
||||
{
|
||||
bool result;
|
||||
bool result = false;
|
||||
TaskEngine taskEngine;
|
||||
|
||||
LogTaskStarted ();
|
||||
ITask task = null;
|
||||
|
||||
try {
|
||||
task = InitializeTask ();
|
||||
} catch (Exception e) {
|
||||
LogError ("Error initializing task {0}: {1}", taskElement.LocalName, e.Message);
|
||||
LogMessage (MessageImportance.Low, "Error initializing task {0}: {1}",
|
||||
taskElement.LocalName, e.ToString ());
|
||||
return false;
|
||||
try {
|
||||
task = InitializeTask ();
|
||||
} catch (Exception e) {
|
||||
LogError ("Error initializing task {0}: {1}", taskElement.LocalName, e.Message);
|
||||
LogMessage (MessageImportance.Low, "Error initializing task {0}: {1}",
|
||||
taskElement.LocalName, e.ToString ());
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
taskEngine = new TaskEngine (parentTarget.Project);
|
||||
taskEngine.Prepare (task, this.taskElement, GetParameters (), this.Type);
|
||||
result = taskEngine.Execute ();
|
||||
if (result)
|
||||
taskEngine.PublishOutput ();
|
||||
} catch (Exception e) {
|
||||
task_logger.LogError ("Error executing task {0}: {1}", taskElement.LocalName, e.Message);
|
||||
task_logger.LogMessage (MessageImportance.Low,
|
||||
"Error executing task {0}: {1}", taskElement.LocalName, e.ToString ());
|
||||
result = false;
|
||||
}
|
||||
} finally {
|
||||
LogTaskFinished (result);
|
||||
}
|
||||
|
||||
try {
|
||||
taskEngine = new TaskEngine (parentTarget.Project);
|
||||
taskEngine.Prepare (task, this.taskElement, GetParameters (), this.Type);
|
||||
result = taskEngine.Execute ();
|
||||
if (result)
|
||||
taskEngine.PublishOutput ();
|
||||
} catch (Exception e) {
|
||||
task_logger.LogError ("Error executing task {0}: {1}", taskElement.LocalName, e.Message);
|
||||
task_logger.LogMessage (MessageImportance.Low,
|
||||
"Error executing task {0}: {1}", taskElement.LocalName, e.ToString ());
|
||||
result = false;
|
||||
}
|
||||
|
||||
LogTaskFinished (result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,10 +55,11 @@ namespace Microsoft.Build.BuildEngine {
|
||||
ConsoleColor errorColor, warningColor, eventColor, messageColor, highMessageColor;
|
||||
ColorSetter colorSet;
|
||||
ColorResetter colorReset;
|
||||
IEventSource eventSource;
|
||||
bool no_message_color, use_colors;
|
||||
bool noItemAndPropertyList;
|
||||
|
||||
List<BuildStatusEventArgs> events;
|
||||
List<BuildEvent> events;
|
||||
Dictionary<string, List<string>> errorsTable;
|
||||
Dictionary<string, List<string>> warningsTable;
|
||||
SortedDictionary<string, PerfInfo> targetPerfTable, tasksPerfTable;
|
||||
@@ -95,7 +96,7 @@ namespace Microsoft.Build.BuildEngine {
|
||||
this.colorSet = colorSet;
|
||||
this.colorReset = colorReset;
|
||||
|
||||
events = new List<BuildStatusEventArgs> ();
|
||||
events = new List<BuildEvent> ();
|
||||
errorsTable = new Dictionary<string, List<string>> ();
|
||||
warningsTable = new Dictionary<string, List<string>> ();
|
||||
targetPerfTable = new SortedDictionary<string, PerfInfo> ();
|
||||
@@ -202,19 +203,25 @@ namespace Microsoft.Build.BuildEngine {
|
||||
|
||||
public virtual void Initialize (IEventSource eventSource)
|
||||
{
|
||||
eventSource.BuildStarted += new BuildStartedEventHandler (BuildStartedHandler);
|
||||
eventSource.BuildFinished += new BuildFinishedEventHandler (BuildFinishedHandler);
|
||||
eventSource.ProjectStarted += new ProjectStartedEventHandler (ProjectStartedHandler);
|
||||
eventSource.ProjectFinished += new ProjectFinishedEventHandler (ProjectFinishedHandler);
|
||||
eventSource.TargetStarted += new TargetStartedEventHandler (TargetStartedHandler);
|
||||
eventSource.TargetFinished += new TargetFinishedEventHandler (TargetFinishedHandler);
|
||||
eventSource.TaskStarted += new TaskStartedEventHandler (TaskStartedHandler);
|
||||
eventSource.TaskFinished += new TaskFinishedEventHandler (TaskFinishedHandler);
|
||||
eventSource.MessageRaised += new BuildMessageEventHandler (MessageHandler);
|
||||
eventSource.WarningRaised += new BuildWarningEventHandler (WarningHandler);
|
||||
eventSource.ErrorRaised += new BuildErrorEventHandler (ErrorHandler);
|
||||
this.eventSource = eventSource;
|
||||
|
||||
eventSource.BuildStarted += BuildStartedHandler;
|
||||
eventSource.BuildFinished += BuildFinishedHandler;
|
||||
|
||||
eventSource.ProjectStarted += PushEvent;
|
||||
eventSource.ProjectFinished += PopEvent;
|
||||
|
||||
eventSource.TargetStarted += PushEvent;
|
||||
eventSource.TargetFinished += PopEvent;
|
||||
|
||||
eventSource.TaskStarted += PushEvent;
|
||||
eventSource.TaskFinished += PopEvent;
|
||||
|
||||
eventSource.MessageRaised += MessageHandler;
|
||||
eventSource.WarningRaised += WarningHandler;
|
||||
eventSource.ErrorRaised += ErrorHandler;
|
||||
}
|
||||
|
||||
|
||||
public void BuildStartedHandler (object sender, BuildStartedEventArgs args)
|
||||
{
|
||||
if (IsVerbosityGreaterOrEqual (LoggerVerbosity.Normal)) {
|
||||
@@ -228,9 +235,28 @@ namespace Microsoft.Build.BuildEngine {
|
||||
}
|
||||
|
||||
public void BuildFinishedHandler (object sender, BuildFinishedEventArgs args)
|
||||
{
|
||||
BuildFinishedHandlerActual (args);
|
||||
|
||||
// Reset
|
||||
events.Clear ();
|
||||
errorsTable.Clear ();
|
||||
warningsTable.Clear ();
|
||||
targetPerfTable.Clear ();
|
||||
tasksPerfTable.Clear ();
|
||||
errors.Clear ();
|
||||
warnings.Clear ();
|
||||
|
||||
indent = 0;
|
||||
errorCount = 0;
|
||||
warningCount = 0;
|
||||
projectFailed = false;
|
||||
}
|
||||
|
||||
void BuildFinishedHandlerActual (BuildFinishedEventArgs args)
|
||||
{
|
||||
if (!IsVerbosityGreaterOrEqual (LoggerVerbosity.Normal)) {
|
||||
PopEvent ();
|
||||
PopEvent (args);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -285,8 +311,9 @@ namespace Microsoft.Build.BuildEngine {
|
||||
WriteLine (String.Format ("\t {0} Error(s)", errorCount));
|
||||
WriteLine (String.Empty);
|
||||
WriteLine (String.Format ("Time Elapsed {0}", timeElapsed));
|
||||
}
|
||||
PopEvent ();
|
||||
}
|
||||
|
||||
PopEvent (args);
|
||||
}
|
||||
|
||||
public void ProjectStartedHandler (object sender, ProjectStartedEventArgs args)
|
||||
@@ -296,11 +323,9 @@ namespace Microsoft.Build.BuildEngine {
|
||||
WriteLine (String.Format ("Project \"{0}\" ({1} target(s)):", args.ProjectFile,
|
||||
String.IsNullOrEmpty (args.TargetNames) ? "default" : args.TargetNames));
|
||||
ResetColor ();
|
||||
WriteLine (String.Empty);
|
||||
DumpProperties (args.Properties);
|
||||
DumpItems (args.Items);
|
||||
}
|
||||
PushEvent (args);
|
||||
}
|
||||
|
||||
public void ProjectFinishedHandler (object sender, ProjectFinishedEventArgs args)
|
||||
@@ -317,8 +342,6 @@ namespace Microsoft.Build.BuildEngine {
|
||||
if (!projectFailed)
|
||||
// no project has failed yet, so update the flag
|
||||
projectFailed = !args.Succeeded;
|
||||
|
||||
PopEvent ();
|
||||
}
|
||||
|
||||
public void TargetStartedHandler (object sender, TargetStartedEventArgs args)
|
||||
@@ -326,10 +349,10 @@ namespace Microsoft.Build.BuildEngine {
|
||||
if (IsVerbosityGreaterOrEqual (LoggerVerbosity.Normal)) {
|
||||
indent++;
|
||||
SetColor (eventColor);
|
||||
WriteLine (String.Empty);
|
||||
WriteLine (String.Format ("Target {0}:",args.TargetName));
|
||||
ResetColor ();
|
||||
}
|
||||
PushEvent (args);
|
||||
}
|
||||
|
||||
public void TargetFinishedHandler (object sender, TargetFinishedEventArgs args)
|
||||
@@ -344,19 +367,16 @@ namespace Microsoft.Build.BuildEngine {
|
||||
WriteLine (String.Empty);
|
||||
}
|
||||
indent--;
|
||||
|
||||
PopEvent ();
|
||||
}
|
||||
|
||||
public void TaskStartedHandler (object sender, TaskStartedEventArgs args)
|
||||
{
|
||||
if (this.verbosity == LoggerVerbosity.Detailed) {
|
||||
if (IsVerbosityGreaterOrEqual (LoggerVerbosity.Detailed)) {
|
||||
SetColor (eventColor);
|
||||
WriteLine (String.Format ("Task \"{0}\"",args.TaskName));
|
||||
ResetColor ();
|
||||
}
|
||||
indent++;
|
||||
PushEvent (args);
|
||||
}
|
||||
|
||||
public void TaskFinishedHandler (object sender, TaskFinishedEventArgs args)
|
||||
@@ -371,15 +391,16 @@ namespace Microsoft.Build.BuildEngine {
|
||||
WriteLine (String.Format ("Task \"{0}\" execution -- FAILED", args.TaskName));
|
||||
ResetColor ();
|
||||
}
|
||||
PopEvent ();
|
||||
}
|
||||
|
||||
public void MessageHandler (object sender, BuildMessageEventArgs args)
|
||||
{
|
||||
if (IsMessageOk (args)) {
|
||||
if (no_message_color) {
|
||||
ExecutePendingEventHandlers ();
|
||||
WriteLine (args.Message);
|
||||
} else {
|
||||
ExecutePendingEventHandlers ();
|
||||
SetColor (args.Importance == MessageImportance.High ? highMessageColor : messageColor);
|
||||
WriteLine (args.Message);
|
||||
ResetColor ();
|
||||
@@ -391,6 +412,7 @@ namespace Microsoft.Build.BuildEngine {
|
||||
{
|
||||
string msg = FormatWarningEvent (args);
|
||||
if (IsVerbosityGreaterOrEqual (LoggerVerbosity.Quiet)) {
|
||||
ExecutePendingEventHandlers ();
|
||||
SetColor (warningColor);
|
||||
WriteLineWithoutIndent (msg);
|
||||
ResetColor ();
|
||||
@@ -409,6 +431,7 @@ namespace Microsoft.Build.BuildEngine {
|
||||
{
|
||||
string msg = FormatErrorEvent (args);
|
||||
if (IsVerbosityGreaterOrEqual (LoggerVerbosity.Quiet)) {
|
||||
ExecutePendingEventHandlers ();
|
||||
SetColor (errorColor);
|
||||
WriteLineWithoutIndent (msg);
|
||||
ResetColor ();
|
||||
@@ -441,16 +464,36 @@ namespace Microsoft.Build.BuildEngine {
|
||||
}
|
||||
}
|
||||
|
||||
void PushEvent (BuildStatusEventArgs args)
|
||||
void PushEvent<T> (object sender, T args) where T: BuildStatusEventArgs
|
||||
{
|
||||
events.Add (args);
|
||||
PushEvent (args);
|
||||
}
|
||||
|
||||
void PushEvent<T> (T args) where T: BuildStatusEventArgs
|
||||
{
|
||||
BuildEvent be = new BuildEvent {
|
||||
EventArgs = args,
|
||||
StartHandlerHasExecuted = false,
|
||||
ConsoleLogger = this
|
||||
};
|
||||
|
||||
events.Add (be);
|
||||
current_events_string = null;
|
||||
}
|
||||
|
||||
void PopEvent ()
|
||||
void PopEvent<T> (object sender, T finished_args) where T: BuildStatusEventArgs
|
||||
{
|
||||
PopEvent (finished_args);
|
||||
}
|
||||
|
||||
void PopEvent<T> (T finished_args) where T: BuildStatusEventArgs
|
||||
{
|
||||
if (events.Count == 0)
|
||||
throw new InvalidOperationException ("INTERNAL ERROR: Trying to pop from an empty events stack");
|
||||
|
||||
BuildEvent be = events [events.Count - 1];
|
||||
if (performanceSummary || verbosity == LoggerVerbosity.Diagnostic) {
|
||||
var args = events [events.Count - 1];
|
||||
var args = be.EventArgs;
|
||||
TargetStartedEventArgs tgt_args = args as TargetStartedEventArgs;
|
||||
if (tgt_args != null) {
|
||||
AddPerfInfo (tgt_args.TargetName, args.Timestamp, targetPerfTable);
|
||||
@@ -461,17 +504,24 @@ namespace Microsoft.Build.BuildEngine {
|
||||
}
|
||||
}
|
||||
|
||||
be.ExecuteFinishedHandler (finished_args);
|
||||
events.RemoveAt (events.Count - 1);
|
||||
current_events_string = null;
|
||||
}
|
||||
|
||||
void ExecutePendingEventHandlers ()
|
||||
{
|
||||
foreach (var be in events)
|
||||
be.ExecuteStartedHandler ();
|
||||
}
|
||||
|
||||
string EventsToString ()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder ();
|
||||
|
||||
string last_imported_target_file = String.Empty;
|
||||
for (int i = 0; i < events.Count; i ++) {
|
||||
var args = events [i];
|
||||
var args = events [i].EventArgs;
|
||||
ProjectStartedEventArgs pargs = args as ProjectStartedEventArgs;
|
||||
if (pargs != null) {
|
||||
sb.AppendFormat ("{0} ({1}) ->\n", pargs.ProjectFile,
|
||||
@@ -574,6 +624,24 @@ namespace Microsoft.Build.BuildEngine {
|
||||
|
||||
public virtual void Shutdown ()
|
||||
{
|
||||
if (eventSource == null)
|
||||
return;
|
||||
|
||||
eventSource.BuildStarted -= BuildStartedHandler;
|
||||
eventSource.BuildFinished -= BuildFinishedHandler;
|
||||
|
||||
eventSource.ProjectStarted -= PushEvent;
|
||||
eventSource.ProjectFinished -= PopEvent;
|
||||
|
||||
eventSource.TargetStarted -= PushEvent;
|
||||
eventSource.TargetFinished -= PopEvent;
|
||||
|
||||
eventSource.TaskStarted -= PushEvent;
|
||||
eventSource.TaskFinished -= PopEvent;
|
||||
|
||||
eventSource.MessageRaised -= MessageHandler;
|
||||
eventSource.WarningRaised -= WarningHandler;
|
||||
eventSource.ErrorRaised -= ErrorHandler;
|
||||
}
|
||||
|
||||
static bool InEmacs = Environment.GetEnvironmentVariable ("EMACS") == "t";
|
||||
@@ -656,7 +724,7 @@ namespace Microsoft.Build.BuildEngine {
|
||||
return;
|
||||
|
||||
SetColor (eventColor);
|
||||
WriteLine ("\n");
|
||||
WriteLine (String.Empty);
|
||||
WriteLine ("Initial Properties:");
|
||||
ResetColor ();
|
||||
|
||||
@@ -669,7 +737,6 @@ namespace Microsoft.Build.BuildEngine {
|
||||
|
||||
foreach (KeyValuePair<string, string> pair in dict)
|
||||
WriteLine (String.Format ("{0} = {1}", pair.Key, pair.Value));
|
||||
WriteLine ("\n");
|
||||
}
|
||||
|
||||
void DumpItems (IEnumerable items)
|
||||
@@ -678,7 +745,7 @@ namespace Microsoft.Build.BuildEngine {
|
||||
return;
|
||||
|
||||
SetColor (eventColor);
|
||||
WriteLine ("\n");
|
||||
WriteLine (String.Empty);
|
||||
WriteLine ("Initial Items:");
|
||||
ResetColor ();
|
||||
if (items == null)
|
||||
@@ -700,7 +767,6 @@ namespace Microsoft.Build.BuildEngine {
|
||||
WriteLine (item.ItemSpec);
|
||||
indent--;
|
||||
}
|
||||
WriteLine ("\n");
|
||||
}
|
||||
|
||||
public string Parameters {
|
||||
@@ -745,6 +811,44 @@ namespace Microsoft.Build.BuildEngine {
|
||||
}
|
||||
}
|
||||
|
||||
class BuildEvent {
|
||||
public BuildStatusEventArgs EventArgs;
|
||||
public bool StartHandlerHasExecuted;
|
||||
public ConsoleLogger ConsoleLogger;
|
||||
|
||||
public void ExecuteStartedHandler ()
|
||||
{
|
||||
if (StartHandlerHasExecuted)
|
||||
return;
|
||||
|
||||
if (EventArgs is ProjectStartedEventArgs)
|
||||
ConsoleLogger.ProjectStartedHandler (null, (ProjectStartedEventArgs)EventArgs);
|
||||
else if (EventArgs is TargetStartedEventArgs)
|
||||
ConsoleLogger.TargetStartedHandler (null, (TargetStartedEventArgs)EventArgs);
|
||||
else if (EventArgs is TaskStartedEventArgs)
|
||||
ConsoleLogger.TaskStartedHandler (null, (TaskStartedEventArgs)EventArgs);
|
||||
else if (!(EventArgs is BuildStartedEventArgs))
|
||||
throw new InvalidOperationException ("Unexpected event on the stack, type: " + EventArgs.GetType ());
|
||||
|
||||
StartHandlerHasExecuted = true;
|
||||
}
|
||||
|
||||
public void ExecuteFinishedHandler (BuildStatusEventArgs finished_args)
|
||||
{
|
||||
if (!StartHandlerHasExecuted)
|
||||
return;
|
||||
|
||||
if (EventArgs is ProjectStartedEventArgs)
|
||||
ConsoleLogger.ProjectFinishedHandler (null, finished_args as ProjectFinishedEventArgs);
|
||||
else if (EventArgs is TargetStartedEventArgs)
|
||||
ConsoleLogger.TargetFinishedHandler (null, finished_args as TargetFinishedEventArgs);
|
||||
else if (EventArgs is TaskStartedEventArgs)
|
||||
ConsoleLogger.TaskFinishedHandler (null, finished_args as TaskFinishedEventArgs);
|
||||
else if (!(EventArgs is BuildStartedEventArgs))
|
||||
throw new InvalidOperationException ("Unexpected event on the stack, type: " + EventArgs.GetType ());
|
||||
}
|
||||
}
|
||||
|
||||
class PerfInfo {
|
||||
public TimeSpan Time;
|
||||
public int NumberOfCalls;
|
||||
|
||||
@@ -126,6 +126,7 @@ namespace Microsoft.Build.BuildEngine {
|
||||
{
|
||||
if (project == null)
|
||||
throw new ArgumentException ("project");
|
||||
builtTargetsOutputByName.Clear ();
|
||||
return project.Build ();
|
||||
}
|
||||
|
||||
@@ -164,6 +165,9 @@ namespace Microsoft.Build.BuildEngine {
|
||||
if (targetNames == null)
|
||||
return false;
|
||||
|
||||
if ((buildFlags & BuildSettings.DoNotResetPreviouslyBuiltTargets) != BuildSettings.DoNotResetPreviouslyBuiltTargets)
|
||||
builtTargetsOutputByName.Clear ();
|
||||
|
||||
if (defaultToolsVersion != null)
|
||||
// it has been explicitly set, xbuild does this..
|
||||
project.ToolsVersion = defaultToolsVersion;
|
||||
@@ -224,6 +228,9 @@ namespace Microsoft.Build.BuildEngine {
|
||||
IDictionary targetOutputs,
|
||||
BuildSettings buildFlags, string toolsVersion)
|
||||
{
|
||||
if ((buildFlags & BuildSettings.DoNotResetPreviouslyBuiltTargets) != BuildSettings.DoNotResetPreviouslyBuiltTargets)
|
||||
builtTargetsOutputByName.Clear ();
|
||||
|
||||
Project project;
|
||||
|
||||
bool newProject = false;
|
||||
|
||||
@@ -241,8 +241,10 @@ namespace Microsoft.Build.BuildEngine {
|
||||
void LogTargetSkipped (Target target, string reason)
|
||||
{
|
||||
BuildMessageEventArgs bmea;
|
||||
bmea = new BuildMessageEventArgs (reason ?? String.Format ("Skipping target \"{0}\" because its outputs are up-to-date.", target.Name),
|
||||
null, "MSBuild", MessageImportance.Normal);
|
||||
bmea = new BuildMessageEventArgs (String.IsNullOrEmpty (reason)
|
||||
? String.Format ("Skipping target \"{0}\" because its outputs are up-to-date.", target.Name)
|
||||
: reason,
|
||||
null, "MSBuild", MessageImportance.Normal);
|
||||
target.Engine.EventSource.FireMessageRaised (this, bmea);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,17 +3,13 @@ SUBDIRS =
|
||||
include ../../build/rules.make
|
||||
|
||||
LIBRARY = Microsoft.Build.Tasks.dll
|
||||
ifeq (1.0, $(FRAMEWORK_VERSION))
|
||||
|
||||
LIBRARY_NAME = dummy-Microsoft.Build.Tasks.dll
|
||||
NO_INSTALL = yes
|
||||
NO_TEST = yes
|
||||
NO_SIGN_ASSEMBLY = yes
|
||||
|
||||
else
|
||||
BUILD_FRAMEWORK = Microsoft.Build.Framework.dll
|
||||
BUILD_ENGINE = Microsoft.Build.Engine.dll
|
||||
|
||||
ifeq (3.5, $(FRAMEWORK_VERSION))
|
||||
NAME_SUFFIX = .v3.5
|
||||
BUILD_FRAMEWORK := $(topdir)/class/lib/$(PROFILE)/$(BUILD_FRAMEWORK)
|
||||
BUILD_ENGINE := $(topdir)/class/lib/$(PROFILE)/$(BUILD_ENGINE)
|
||||
else
|
||||
ifeq (4.0, $(FRAMEWORK_VERSION))
|
||||
NAME_SUFFIX = .v4.0
|
||||
@@ -22,8 +18,6 @@ endif
|
||||
|
||||
LIBRARY_NAME = Microsoft.Build.Tasks$(NAME_SUFFIX).dll
|
||||
|
||||
endif
|
||||
|
||||
LIB_MCS_FLAGS = \
|
||||
/r:$(corlib) \
|
||||
/r:System.dll \
|
||||
@@ -31,12 +25,12 @@ LIB_MCS_FLAGS = \
|
||||
/r:System.Xml.dll \
|
||||
/r:System.Windows.Forms.dll \
|
||||
/r:Microsoft.Build.Utilities$(NAME_SUFFIX).dll \
|
||||
/r:Microsoft.Build.Framework.dll \
|
||||
/r:Microsoft.Build.Engine.dll
|
||||
/r:$(BUILD_FRAMEWORK) \
|
||||
/r:$(BUILD_ENGINE)
|
||||
|
||||
TEST_MCS_FLAGS = \
|
||||
/r:Microsoft.Build.Engine.dll \
|
||||
/r:Microsoft.Build.Framework.dll \
|
||||
/r:$(BUILD_ENGINE) \
|
||||
/r:$(BUILD_FRAMEWORK) \
|
||||
/r:Microsoft.Build.Utilities$(NAME_SUFFIX).dll
|
||||
|
||||
EXTRA_DISTFILES = \
|
||||
|
||||
@@ -5,8 +5,11 @@
|
||||
// Marek Sieradzki ([email protected])
|
||||
// Paolo Molaro ([email protected])
|
||||
// Gonzalo Paniagua Javier ([email protected])
|
||||
// Lluis Sanchez Gual <[email protected]>
|
||||
// Ankit Jain <[email protected]>
|
||||
//
|
||||
// (C) 2005 Marek Sieradzki
|
||||
// Copyright 2010 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
@@ -36,6 +39,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Resources;
|
||||
using System.Reflection;
|
||||
using System.Xml;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
using Mono.XBuild.Tasks.GenerateResourceInternal;
|
||||
@@ -73,7 +77,8 @@ namespace Microsoft.Build.Tasks {
|
||||
string sourceFile = source.ItemSpec;
|
||||
string outputFile = Path.ChangeExtension (sourceFile, "resources");
|
||||
|
||||
result &= CompileResourceFile (sourceFile, outputFile);
|
||||
if (IsResgenRequired (sourceFile, outputFile))
|
||||
result &= CompileResourceFile (sourceFile, outputFile);
|
||||
|
||||
ITaskItem newItem = new TaskItem (source);
|
||||
source.ItemSpec = outputFile;
|
||||
@@ -93,7 +98,8 @@ namespace Microsoft.Build.Tasks {
|
||||
continue;
|
||||
}
|
||||
|
||||
result &= CompileResourceFile (sources [i].ItemSpec, outputResources [i].ItemSpec);
|
||||
if (IsResgenRequired (sources [i].ItemSpec, outputResources [i].ItemSpec))
|
||||
result &= CompileResourceFile (sources [i].ItemSpec, outputResources [i].ItemSpec);
|
||||
temporaryFilesWritten.Add (outputResources [i]);
|
||||
}
|
||||
}
|
||||
@@ -103,6 +109,78 @@ namespace Microsoft.Build.Tasks {
|
||||
return result;
|
||||
}
|
||||
|
||||
// true if the resx file or any file referenced
|
||||
// by the resx is newer than the .resources file
|
||||
//
|
||||
// Code taken from monodevelop
|
||||
// main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MD1/MD1DotNetProjectHandler.cs
|
||||
bool IsResgenRequired (string resx_filename, string resources_filename)
|
||||
{
|
||||
if (IsFileNewerThan (resx_filename, resources_filename)) {
|
||||
Log.LogMessage (MessageImportance.Low,
|
||||
"Resource file '{0}' is newer than the source file '{1}', skipping.",
|
||||
resources_filename, resx_filename);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (String.Compare (Path.GetExtension (resx_filename), ".resx", true) != 0)
|
||||
return true;
|
||||
|
||||
// resx file, check for files referenced from there
|
||||
XmlTextReader xr = null;
|
||||
try {
|
||||
// look for
|
||||
// <data type="System.Resources.ResXFileRef, System.Windows.Forms" ..>
|
||||
// <value>... filename;.. </value>
|
||||
// </data>
|
||||
xr = new XmlTextReader (resx_filename);
|
||||
string basepath = Path.GetDirectoryName (resx_filename);
|
||||
while (xr.Read ()) {
|
||||
if (xr.NodeType != XmlNodeType.Element ||
|
||||
String.Compare (xr.LocalName, "data") != 0)
|
||||
continue;
|
||||
|
||||
string type = xr.GetAttribute ("type");
|
||||
if (String.IsNullOrEmpty (type))
|
||||
continue;
|
||||
|
||||
if (String.Compare (type, "System.Resources.ResXFileRef, System.Windows.Forms") != 0)
|
||||
continue;
|
||||
|
||||
xr.ReadToDescendant ("value");
|
||||
if (xr.NodeType != XmlNodeType.Element)
|
||||
continue;
|
||||
|
||||
string value = xr.ReadElementContentAsString ();
|
||||
|
||||
string [] parts = value.Split (';');
|
||||
if (parts.Length > 0) {
|
||||
string referenced_filename = Utilities.FromMSBuildPath (
|
||||
Path.Combine (basepath, parts [0]).Trim ());
|
||||
if (File.Exists (referenced_filename) &&
|
||||
IsFileNewerThan (referenced_filename, resources_filename))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (XmlException) {
|
||||
// Ignore xml errors, let resgen handle it
|
||||
return true;
|
||||
} finally {
|
||||
if (xr != null)
|
||||
xr.Close ();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// true if first is newer than second
|
||||
static bool IsFileNewerThan (string first, string second)
|
||||
{
|
||||
FileInfo finfo_first = new FileInfo (first);
|
||||
FileInfo finfo_second = new FileInfo (second);
|
||||
return finfo_first.LastWriteTime > finfo_second.LastWriteTime;
|
||||
}
|
||||
|
||||
#if false
|
||||
private IResourceReader GetReader (Stream stream, string name)
|
||||
{
|
||||
@@ -154,13 +232,6 @@ namespace Microsoft.Build.Tasks {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (File.GetLastWriteTime (sname) <= File.GetLastWriteTime (dname)) {
|
||||
Log.LogMessage (MessageImportance.Low,
|
||||
"Resource file '{0}' is newer than the source file '{1}', skipping.",
|
||||
dname, sname);
|
||||
return true;
|
||||
}
|
||||
|
||||
Resgen resgen = new Resgen ();
|
||||
resgen.BuildEngine = this.BuildEngine;
|
||||
resgen.UseSourcePath = true;
|
||||
@@ -298,7 +369,7 @@ namespace Microsoft.Build.Tasks {
|
||||
public override bool Execute ()
|
||||
{
|
||||
if (String.IsNullOrEmpty (Environment.GetEnvironmentVariable ("MONO_IOMAP")))
|
||||
EnvironmentOverride ["MONO_IOMAP"] = "drive";
|
||||
EnvironmentVariables = new string [] { "MONO_IOMAP=drive" };
|
||||
return base.Execute ();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#if NET_2_0
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Microsoft.Build.Tasks {
|
||||
internal static class Utilities {
|
||||
@@ -42,6 +43,68 @@ namespace Microsoft.Build.Tasks {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal static string FromMSBuildPath (string relPath)
|
||||
{
|
||||
if (relPath == null || relPath.Length == 0)
|
||||
return null;
|
||||
|
||||
bool is_windows = Path.DirectorySeparatorChar == '\\';
|
||||
string path = relPath;
|
||||
if (!is_windows)
|
||||
path = path.Replace ("\\", "/");
|
||||
|
||||
// a path with drive letter is invalid/unusable on non-windows
|
||||
if (!is_windows && char.IsLetter (path [0]) && path.Length > 1 && path[1] == ':')
|
||||
return null;
|
||||
|
||||
if (System.IO.File.Exists (path)){
|
||||
return Path.GetFullPath (path);
|
||||
}
|
||||
|
||||
if (Path.IsPathRooted (path)) {
|
||||
|
||||
// Windows paths are case-insensitive. When mapping an absolute path
|
||||
// we can try to find the correct case for the path.
|
||||
|
||||
string[] names = path.Substring (1).Split ('/');
|
||||
string part = "/";
|
||||
|
||||
for (int n=0; n<names.Length; n++) {
|
||||
string[] entries;
|
||||
|
||||
if (names [n] == ".."){
|
||||
if (part == "/")
|
||||
return ""; // Can go further back. It's not an existing file
|
||||
part = Path.GetFullPath (part + "/..");
|
||||
continue;
|
||||
}
|
||||
|
||||
entries = Directory.GetFileSystemEntries (part);
|
||||
|
||||
string fpath = null;
|
||||
foreach (string e in entries) {
|
||||
if (string.Compare (Path.GetFileName (e), names[n], true) == 0) {
|
||||
fpath = e;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (fpath == null) {
|
||||
// Part of the path does not exist. Can't do any more checking.
|
||||
part = Path.GetFullPath (part);
|
||||
for (; n < names.Length; n++)
|
||||
part += "/" + names[n];
|
||||
return part;
|
||||
}
|
||||
|
||||
part = fpath;
|
||||
}
|
||||
return Path.GetFullPath (part);
|
||||
} else {
|
||||
return Path.GetFullPath (path);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,15 +3,11 @@ SUBDIRS =
|
||||
include ../../build/rules.make
|
||||
|
||||
LIBRARY = Microsoft.Build.Utilities.dll
|
||||
ifeq (1.0, $(FRAMEWORK_VERSION))
|
||||
LIBRARY_NAME = dummy-Microsoft.Build.Utilities.dll
|
||||
NO_INSTALL = yes
|
||||
NO_TEST = yes
|
||||
NO_SIGN_ASSEMBLY = yes
|
||||
endif
|
||||
BUILD_FRAMEWORK = Microsoft.Build.Framework.dll
|
||||
|
||||
ifeq (3.5, $(FRAMEWORK_VERSION))
|
||||
LIBRARY_NAME = Microsoft.Build.Utilities.v3.5.dll
|
||||
BUILD_FRAMEWORK := $(topdir)/class/lib/$(PROFILE)/$(BUILD_FRAMEWORK)
|
||||
else
|
||||
ifeq (4.0, $(FRAMEWORK_VERSION))
|
||||
LIBRARY_NAME = Microsoft.Build.Utilities.v4.0.dll
|
||||
@@ -21,9 +17,9 @@ endif
|
||||
LIB_MCS_FLAGS = \
|
||||
/r:$(corlib) \
|
||||
/r:System.dll \
|
||||
/r:Microsoft.Build.Framework.dll
|
||||
/r:$(BUILD_FRAMEWORK)
|
||||
|
||||
TEST_MCS_FLAGS = /r:Microsoft.Build.Framework.dll
|
||||
TEST_MCS_FLAGS = /r:$(BUILD_FRAMEWORK)
|
||||
|
||||
export TESTING_MONO=a
|
||||
XBUILD_DIR=../../tools/xbuild
|
||||
|
||||
@@ -46,7 +46,6 @@ namespace Microsoft.Build.Utilities
|
||||
{
|
||||
public abstract class ToolTask : Task
|
||||
{
|
||||
SCS.ProcessStringDictionary environmentOverride;
|
||||
int exitCode;
|
||||
int timeout;
|
||||
string toolPath, toolExe;
|
||||
@@ -76,7 +75,6 @@ namespace Microsoft.Build.Utilities
|
||||
this.toolPath = MonoLocationHelper.GetBinDir ();
|
||||
this.responseFileEncoding = Encoding.UTF8;
|
||||
this.timeout = Int32.MaxValue;
|
||||
this.environmentOverride = new SCS.ProcessStringDictionary ();
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
@@ -111,11 +109,8 @@ namespace Microsoft.Build.Utilities
|
||||
if (pathToTool == null)
|
||||
throw new ArgumentNullException ("pathToTool");
|
||||
|
||||
string output, error, responseFileName;
|
||||
StreamWriter outwr, errwr;
|
||||
|
||||
outwr = errwr = null;
|
||||
responseFileName = output = error = null;
|
||||
string responseFileName;
|
||||
responseFileName = null;
|
||||
toolOutput = new StringBuilder ();
|
||||
|
||||
try {
|
||||
@@ -129,11 +124,6 @@ namespace Microsoft.Build.Utilities
|
||||
LogToolCommand (String.Format ("Tool {0} execution started with arguments: {1} {2}",
|
||||
pathToTool, commandLineCommands, responseFileCommands));
|
||||
|
||||
output = Path.GetTempFileName ();
|
||||
error = Path.GetTempFileName ();
|
||||
outwr = new StreamWriter (output);
|
||||
errwr = new StreamWriter (error);
|
||||
|
||||
ProcessStartInfo pinfo = new ProcessStartInfo (pathToTool, arguments);
|
||||
pinfo.WorkingDirectory = GetWorkingDirectory () ?? Environment.CurrentDirectory;
|
||||
|
||||
@@ -141,15 +131,27 @@ namespace Microsoft.Build.Utilities
|
||||
pinfo.RedirectStandardOutput = true;
|
||||
pinfo.RedirectStandardError = true;
|
||||
|
||||
var pendingLineFragmentOutput = new StringBuilder ();
|
||||
var pendingLineFragmentError = new StringBuilder ();
|
||||
var environmentOverride = GetAndLogEnvironmentVariables ();
|
||||
try {
|
||||
ProcessWrapper pw = ProcessService.StartProcess (pinfo, outwr, errwr, null, environmentOverride);
|
||||
pw.OutputStreamChanged += delegate (object o, string msg) { ProcessLine (msg, StandardOutputLoggingImportance); };
|
||||
pw.ErrorStreamChanged += delegate (object o, string msg) { ProcessLine (msg, StandardErrorLoggingImportance); };
|
||||
// When StartProcess returns, the process has already .Start()'ed
|
||||
// If we subscribe to the events after that, then for processes that
|
||||
// finish executing before we can subscribe, we won't get the output/err
|
||||
// events at all!
|
||||
ProcessWrapper pw = ProcessService.StartProcess (pinfo,
|
||||
(_, msg) => ProcessLine (pendingLineFragmentOutput, msg, StandardOutputLoggingImportance),
|
||||
(_, msg) => ProcessLine (pendingLineFragmentError, msg, StandardErrorLoggingImportance),
|
||||
null,
|
||||
environmentOverride);
|
||||
|
||||
pw.WaitForOutput (timeout == Int32.MaxValue ? Int32.MaxValue : timeout);
|
||||
|
||||
// Process any remaining line
|
||||
ProcessLine (pendingLineFragmentOutput, StandardOutputLoggingImportance, true);
|
||||
ProcessLine (pendingLineFragmentError, StandardErrorLoggingImportance, true);
|
||||
|
||||
pw.WaitForOutput (timeout == Int32.MaxValue ? -1 : timeout);
|
||||
exitCode = pw.ExitCode;
|
||||
outwr.Close();
|
||||
errwr.Close();
|
||||
pw.Dispose ();
|
||||
} catch (System.ComponentModel.Win32Exception e) {
|
||||
Log.LogError ("Error executing tool '{0}': {1}", pathToTool, e.Message);
|
||||
@@ -159,17 +161,13 @@ namespace Microsoft.Build.Utilities
|
||||
if (typeLoadException)
|
||||
ProcessTypeLoadException ();
|
||||
|
||||
pendingLineFragmentOutput.Length = 0;
|
||||
pendingLineFragmentError.Length = 0;
|
||||
|
||||
Log.LogMessage (MessageImportance.Low, "Tool {0} execution finished.", pathToTool);
|
||||
return exitCode;
|
||||
} finally {
|
||||
DeleteTempFile (responseFileName);
|
||||
if (outwr != null)
|
||||
outwr.Dispose ();
|
||||
if (errwr != null)
|
||||
errwr.Dispose ();
|
||||
|
||||
DeleteTempFile (output);
|
||||
DeleteTempFile (error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,9 +190,39 @@ namespace Microsoft.Build.Utilities
|
||||
Log.LogError (output_str);
|
||||
}
|
||||
|
||||
void ProcessLine (string line, MessageImportance importance)
|
||||
void ProcessLine (StringBuilder outputBuilder, MessageImportance importance, bool isLastLine)
|
||||
{
|
||||
foreach (string singleLine in line.Split (new string [] {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)) {
|
||||
if (outputBuilder.Length == 0)
|
||||
return;
|
||||
|
||||
if (isLastLine && !outputBuilder.ToString ().EndsWith (Environment.NewLine))
|
||||
// last line, but w/o an trailing newline, so add that
|
||||
outputBuilder.Append (Environment.NewLine);
|
||||
|
||||
ProcessLine (outputBuilder, null, importance);
|
||||
}
|
||||
|
||||
void ProcessLine (StringBuilder outputBuilder, string line, MessageImportance importance)
|
||||
{
|
||||
// Add to any line fragment from previous call
|
||||
if (line != null)
|
||||
outputBuilder.Append (line);
|
||||
|
||||
// Don't remove empty lines!
|
||||
var lines = outputBuilder.ToString ().Split (new string [] {Environment.NewLine}, StringSplitOptions.None);
|
||||
|
||||
// Clear the builder. If any incomplete line is found,
|
||||
// then it will get added back
|
||||
outputBuilder.Length = 0;
|
||||
for (int i = 0; i < lines.Length; i ++) {
|
||||
string singleLine = lines [i];
|
||||
if (i == lines.Length - 1 && !singleLine.EndsWith (Environment.NewLine)) {
|
||||
// Last line doesn't end in newline, could be part of
|
||||
// a bigger line. Save for later processing
|
||||
outputBuilder.Append (singleLine);
|
||||
continue;
|
||||
}
|
||||
|
||||
toolOutput.AppendLine (singleLine);
|
||||
|
||||
// in case of typeLoadException, collect all the output
|
||||
@@ -206,9 +234,10 @@ namespace Microsoft.Build.Utilities
|
||||
|
||||
protected virtual void LogEventsFromTextOutput (string singleLine, MessageImportance importance)
|
||||
{
|
||||
singleLine = singleLine.Trim ();
|
||||
if (singleLine.Length == 0)
|
||||
if (singleLine.Length == 0) {
|
||||
Log.LogMessage (singleLine, importance);
|
||||
return;
|
||||
}
|
||||
|
||||
if (singleLine.StartsWith ("Unhandled Exception: System.TypeLoadException") ||
|
||||
singleLine.StartsWith ("Unhandled Exception: System.IO.FileNotFoundException")) {
|
||||
@@ -319,11 +348,50 @@ namespace Microsoft.Build.Utilities
|
||||
}
|
||||
}
|
||||
|
||||
// If EnvironmentVariables is defined, then merge EnvironmentOverride
|
||||
// EnvironmentOverride is Obsolete'd in 4.0
|
||||
//
|
||||
// Returns the final set of environment variables and logs them
|
||||
SCS.StringDictionary GetAndLogEnvironmentVariables ()
|
||||
{
|
||||
var env_vars = GetEnvironmentVariables ();
|
||||
if (env_vars == null)
|
||||
return env_vars;
|
||||
|
||||
Log.LogMessage (MessageImportance.Low, "Environment variables being passed to the tool:");
|
||||
foreach (DictionaryEntry entry in env_vars)
|
||||
Log.LogMessage (MessageImportance.Low, "\t{0}={1}", (string)entry.Key, (string)entry.Value);
|
||||
|
||||
return env_vars;
|
||||
}
|
||||
|
||||
SCS.StringDictionary GetEnvironmentVariables ()
|
||||
{
|
||||
if (EnvironmentVariables == null || EnvironmentVariables.Length == 0)
|
||||
return EnvironmentOverride;
|
||||
|
||||
var env_vars = new SCS.ProcessStringDictionary ();
|
||||
foreach (string pair in EnvironmentVariables) {
|
||||
string [] key_value = pair.Split ('=');
|
||||
if (!String.IsNullOrEmpty (key_value [0]))
|
||||
env_vars [key_value [0]] = key_value.Length > 1 ? key_value [1] : String.Empty;
|
||||
}
|
||||
|
||||
if (EnvironmentOverride != null)
|
||||
foreach (DictionaryEntry entry in EnvironmentOverride)
|
||||
env_vars [(string)entry.Key] = (string)entry.Value;
|
||||
|
||||
return env_vars;
|
||||
}
|
||||
|
||||
protected virtual StringDictionary EnvironmentOverride
|
||||
{
|
||||
get { return environmentOverride; }
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
|
||||
// Ignore EnvironmentOverride if this is set
|
||||
public string[] EnvironmentVariables { get; set; }
|
||||
|
||||
[Output]
|
||||
public int ExitCode {
|
||||
get { return exitCode; }
|
||||
|
||||
@@ -158,20 +158,6 @@ namespace Microsoft.CSharp.RuntimeBinder
|
||||
IgnorePrivateMembers = false
|
||||
};
|
||||
|
||||
var core_types = Compiler.TypeManager.InitCoreTypes ();
|
||||
importer.Initialize ();
|
||||
|
||||
// I don't think dynamically loaded assemblies can be used as dynamic
|
||||
// expression without static type to be loaded first
|
||||
// AppDomain.CurrentDomain.AssemblyLoad += (sender, e) => { throw new NotImplementedException (); };
|
||||
|
||||
// Import all currently loaded assemblies
|
||||
var ns = Compiler.GlobalRootNamespace.Instance;
|
||||
foreach (System.Reflection.Assembly a in AppDomain.CurrentDomain.GetAssemblies ()) {
|
||||
ns.AddAssemblyReference (a);
|
||||
importer.ImportAssembly (a, ns);
|
||||
}
|
||||
|
||||
var reporter = new Compiler.Report (ErrorPrinter.Instance) {
|
||||
WarningLevel = 0
|
||||
};
|
||||
@@ -180,8 +166,29 @@ namespace Microsoft.CSharp.RuntimeBinder
|
||||
IsRuntimeBinder = true
|
||||
};
|
||||
|
||||
Compiler.TypeManager.InitCoreTypes (cc, core_types);
|
||||
Compiler.TypeManager.InitOptionalCoreTypes (cc);
|
||||
IList<Compiler.PredefinedTypeSpec> core_types = null;
|
||||
// HACK: To avoid re-initializing static TypeManager types, like string_type
|
||||
if (!Compiler.RootContext.EvalMode) {
|
||||
core_types = Compiler.TypeManager.InitCoreTypes ();
|
||||
}
|
||||
|
||||
importer.Initialize ();
|
||||
|
||||
// I don't think dynamically loaded assemblies can be used as dynamic
|
||||
// expression without static type to be loaded first
|
||||
// AppDomain.CurrentDomain.AssemblyLoad += (sender, e) => { throw new NotImplementedException (); };
|
||||
|
||||
// Import all currently loaded assemblies
|
||||
var ns = cc.GlobalRootNamespace;
|
||||
foreach (System.Reflection.Assembly a in AppDomain.CurrentDomain.GetAssemblies ()) {
|
||||
ns.AddAssemblyReference (a);
|
||||
importer.ImportAssembly (a, ns);
|
||||
}
|
||||
|
||||
if (!Compiler.RootContext.EvalMode) {
|
||||
Compiler.TypeManager.InitCoreTypes (cc, core_types);
|
||||
Compiler.TypeManager.InitOptionalCoreTypes (cc);
|
||||
}
|
||||
|
||||
dc = new DynamicContext (cc);
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ namespace Mono.Debugger.Soft
|
||||
* with newer runtimes, and vice versa.
|
||||
*/
|
||||
public const int MAJOR_VERSION = 2;
|
||||
public const int MINOR_VERSION = 1;
|
||||
public const int MINOR_VERSION = 2;
|
||||
|
||||
enum WPSuspendPolicy {
|
||||
NONE = 0,
|
||||
@@ -678,32 +678,48 @@ namespace Mono.Debugger.Soft
|
||||
int offset;
|
||||
|
||||
public PacketWriter () {
|
||||
// FIXME:
|
||||
data = new byte [1024];
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
void MakeRoom (int size) {
|
||||
if (offset + size >= data.Length) {
|
||||
int new_len = data.Length * 2;
|
||||
while (new_len < offset + size) {
|
||||
new_len *= 2;
|
||||
}
|
||||
byte[] new_data = new byte [new_len];
|
||||
Array.Copy (data, new_data, data.Length);
|
||||
data = new_data;
|
||||
}
|
||||
}
|
||||
|
||||
public PacketWriter WriteByte (byte val) {
|
||||
MakeRoom (1);
|
||||
encode_byte (data, val, ref offset);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PacketWriter WriteInt (int val) {
|
||||
MakeRoom (4);
|
||||
encode_int (data, val, ref offset);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PacketWriter WriteId (long id) {
|
||||
MakeRoom (8);
|
||||
encode_id (data, id, ref offset);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PacketWriter WriteLong (long val) {
|
||||
MakeRoom (8);
|
||||
encode_long (data, val, ref offset);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PacketWriter WriteFloat (float f) {
|
||||
MakeRoom (8);
|
||||
byte[] b = DataConverter.GetBytesBE (f);
|
||||
for (int i = 0; i < 4; ++i)
|
||||
data [offset + i] = b [i];
|
||||
@@ -712,6 +728,7 @@ namespace Mono.Debugger.Soft
|
||||
}
|
||||
|
||||
public PacketWriter WriteDouble (double d) {
|
||||
MakeRoom (8);
|
||||
byte[] b = DataConverter.GetBytesBE (d);
|
||||
for (int i = 0; i < 8; ++i)
|
||||
data [offset + i] = b [i];
|
||||
@@ -734,6 +751,7 @@ namespace Mono.Debugger.Soft
|
||||
public PacketWriter WriteString (string s) {
|
||||
encode_int (data, s.Length, ref offset);
|
||||
byte[] b = Encoding.UTF8.GetBytes (s);
|
||||
MakeRoom (b.Length);
|
||||
Buffer.BlockCopy (b, 0, data, offset, b.Length);
|
||||
offset += b.Length;
|
||||
return this;
|
||||
|
||||
@@ -189,8 +189,11 @@ namespace Mono.Debugger.Soft
|
||||
}
|
||||
|
||||
public void EnableEvents (params EventType[] events) {
|
||||
foreach (EventType etype in events)
|
||||
foreach (EventType etype in events) {
|
||||
if (etype == EventType.Breakpoint)
|
||||
throw new ArgumentException ("Breakpoint events cannot be requested using EnableEvents", "events");
|
||||
conn.EnableEvent (etype, SuspendPolicy.All, null);
|
||||
}
|
||||
}
|
||||
|
||||
public BreakpointEventRequest SetBreakpoint (MethodMirror method, long il_offset) {
|
||||
|
||||
@@ -243,6 +243,7 @@ public class Tests : TestsBase
|
||||
ss6 (true);
|
||||
} catch {
|
||||
}
|
||||
ss_regress_654694 ();
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.NoInlining)]
|
||||
@@ -409,7 +410,7 @@ public class Tests : TestsBase
|
||||
[MethodImplAttribute (MethodImplOptions.NoInlining)]
|
||||
public static void locals () {
|
||||
locals1 (null);
|
||||
locals2 (null, 5);
|
||||
locals2<string> (null, 5, "ABC");
|
||||
locals3 ();
|
||||
}
|
||||
|
||||
@@ -423,13 +424,15 @@ public class Tests : TestsBase
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.NoInlining)]
|
||||
public static void locals2 (string[] args, int arg) {
|
||||
public static void locals2<T> (string[] args, int arg, T t) {
|
||||
long i = 42;
|
||||
string s = "AB";
|
||||
|
||||
for (int j = 0; j < 10; ++j) {
|
||||
if (s != null)
|
||||
i ++;
|
||||
if (t != null)
|
||||
i ++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -618,6 +621,23 @@ public class Tests : TestsBase
|
||||
o.GetType ();
|
||||
} catch (Exception) {
|
||||
}
|
||||
|
||||
try {
|
||||
exceptions2 ();
|
||||
} catch (Exception) {
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.NoInlining)]
|
||||
public static bool return_true () {
|
||||
return true;
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.NoInlining)]
|
||||
public static void exceptions2 () {
|
||||
if (return_true ())
|
||||
throw new Exception ();
|
||||
Console.WriteLine ();
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.NoInlining)]
|
||||
@@ -706,6 +726,18 @@ public class Tests : TestsBase
|
||||
public static void frames_in_native () {
|
||||
Thread.Sleep (500);
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.NoInlining)]
|
||||
public static void string_call (string s) {
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.NoInlining)]
|
||||
public static void ss_regress_654694 () {
|
||||
if (true) {
|
||||
string h = "hi";
|
||||
string_call (h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CrossDomain : MarshalByRefObject
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Mono.Cecil.Cil;
|
||||
using Mono.Debugger.Soft;
|
||||
using Diag = System.Diagnostics;
|
||||
@@ -93,7 +94,7 @@ public class DebuggerTests
|
||||
}
|
||||
|
||||
Assert.IsInstanceOfType (typeof (BreakpointEvent), e);
|
||||
Assert.AreEqual (m, (e as BreakpointEvent).Method);
|
||||
Assert.AreEqual (m.Name, (e as BreakpointEvent).Method.Name);
|
||||
|
||||
return (e as BreakpointEvent);
|
||||
}
|
||||
@@ -885,7 +886,6 @@ public class DebuggerTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("only")]
|
||||
public void Type_SetValue () {
|
||||
var e = run_until ("o1");
|
||||
var frame = e.Thread.GetFrames () [0];
|
||||
@@ -1319,8 +1319,8 @@ public class DebuggerTests
|
||||
StackFrame frame = e.Thread.GetFrames () [0];
|
||||
|
||||
var locals = frame.Method.GetLocals ();
|
||||
Assert.AreEqual (5, locals.Length);
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
Assert.AreEqual (6, locals.Length);
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
if (locals [i].Name == "args") {
|
||||
Assert.IsTrue (locals [i].IsArg);
|
||||
Assert.AreEqual ("String[]", locals [i].Type.Name);
|
||||
@@ -1336,6 +1336,10 @@ public class DebuggerTests
|
||||
} else if (locals [i].Name == "s") {
|
||||
Assert.IsFalse (locals [i].IsArg);
|
||||
Assert.AreEqual ("String", locals [i].Type.Name);
|
||||
} else if (locals [i].Name == "t") {
|
||||
// gshared
|
||||
Assert.IsTrue (locals [i].IsArg);
|
||||
Assert.AreEqual ("String", locals [i].Type.Name);
|
||||
} else {
|
||||
Assert.Fail ();
|
||||
}
|
||||
@@ -1343,6 +1347,7 @@ public class DebuggerTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("only")]
|
||||
public void Locals () {
|
||||
var be = run_until ("locals1");
|
||||
|
||||
@@ -1385,6 +1390,8 @@ public class DebuggerTests
|
||||
AssertValue (42, vals [i]);
|
||||
if (locals [i].Name == "s")
|
||||
AssertValue ("AB", vals [i]);
|
||||
if (locals [i].Name == "t")
|
||||
AssertValue ("ABC", vals [i]);
|
||||
}
|
||||
|
||||
// Argument checking
|
||||
@@ -1654,6 +1661,12 @@ public class DebuggerTests
|
||||
Assert.AreEqual ("ABC", s.Value);
|
||||
Assert.AreEqual (vm.RootDomain, s.Domain);
|
||||
|
||||
// Long strings
|
||||
StringBuilder sb = new StringBuilder ();
|
||||
for (int i = 0; i < 1024; ++i)
|
||||
sb.Append ('A');
|
||||
s = vm.RootDomain.CreateString (sb.ToString ());
|
||||
|
||||
// Argument checking
|
||||
AssertThrows <ArgumentNullException> (delegate () {
|
||||
s = vm.RootDomain.CreateString (null);
|
||||
@@ -1661,7 +1674,6 @@ public class DebuggerTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("only")]
|
||||
public void CreateBoxedValue () {
|
||||
ObjectMirror o = vm.RootDomain.CreateBoxedValue (new PrimitiveValue (vm, 42));
|
||||
|
||||
@@ -1975,6 +1987,7 @@ public class DebuggerTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("only")]
|
||||
public void Frame_SetValue () {
|
||||
Event e = run_until ("locals2");
|
||||
|
||||
@@ -2000,6 +2013,11 @@ public class DebuggerTests
|
||||
frame.SetValue (p, vm.CreateValue (7));
|
||||
AssertValue (7, frame.GetValue (p));
|
||||
|
||||
// gshared
|
||||
p = frame.Method.GetParameters ()[2];
|
||||
frame.SetValue (p, vm.RootDomain.CreateString ("DEF"));
|
||||
AssertValue ("DEF", frame.GetValue (p));
|
||||
|
||||
// argument checking
|
||||
|
||||
// variable null
|
||||
@@ -2117,6 +2135,31 @@ public class DebuggerTests
|
||||
Assert.AreEqual ("NullReferenceException", (e as ExceptionEvent).Exception.Type.Name);
|
||||
req.Disable ();
|
||||
|
||||
// Single stepping after an exception
|
||||
req = vm.CreateExceptionRequest (null);
|
||||
req.Enable ();
|
||||
|
||||
vm.Resume ();
|
||||
|
||||
e = vm.GetNextEvent ();
|
||||
Assert.IsInstanceOfType (typeof (ExceptionEvent), e);
|
||||
Assert.AreEqual ("Exception", (e as ExceptionEvent).Exception.Type.Name);
|
||||
frames = e.Thread.GetFrames ();
|
||||
Assert.AreEqual ("exceptions2", frames [0].Method.Name);
|
||||
req.Disable ();
|
||||
|
||||
var sreq = vm.CreateStepRequest (e.Thread);
|
||||
sreq.Depth = StepDepth.Over;
|
||||
sreq.Size = StepSize.Line;
|
||||
sreq.Enable ();
|
||||
|
||||
vm.Resume ();
|
||||
e = vm.GetNextEvent ();
|
||||
Assert.IsInstanceOfType (typeof (StepEvent), e);
|
||||
frames = e.Thread.GetFrames ();
|
||||
Assert.AreEqual ("exceptions", frames [0].Method.Name);
|
||||
sreq.Disable ();
|
||||
|
||||
// Argument checking
|
||||
AssertThrows<ArgumentException> (delegate {
|
||||
vm.CreateExceptionRequest (e.Thread.Type);
|
||||
@@ -2385,4 +2428,43 @@ public class DebuggerTests
|
||||
vm.CreateEnumMirror (enumType, vm.CreateValue ((long)1));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void VirtualMachine_EnableEvents_Breakpoint () {
|
||||
AssertThrows<ArgumentException> (delegate () {
|
||||
vm.EnableEvents (EventType.Breakpoint);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SingleStepRegress654694 () {
|
||||
int il_offset = -1;
|
||||
|
||||
MethodMirror m = entry_point.DeclaringType.GetMethod ("ss_regress_654694");
|
||||
foreach (Location l in m.Locations) {
|
||||
if (l.ILOffset > 0 && il_offset == -1)
|
||||
il_offset = l.ILOffset;
|
||||
}
|
||||
|
||||
Event e = run_until ("ss_regress_654694");
|
||||
|
||||
Assert.IsNotNull (m);
|
||||
vm.SetBreakpoint (m, il_offset);
|
||||
|
||||
vm.Resume ();
|
||||
|
||||
e = vm.GetNextEvent ();
|
||||
Assert.IsTrue (e is BreakpointEvent);
|
||||
|
||||
var req = vm.CreateStepRequest (e.Thread);
|
||||
req.Depth = StepDepth.Over;
|
||||
req.Size = StepSize.Line;
|
||||
req.Enable ();
|
||||
|
||||
vm.Resume ();
|
||||
|
||||
e = vm.GetNextEvent ();
|
||||
Assert.IsTrue (e is StepEvent);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1165,10 +1165,18 @@ namespace Mono.Unix.Native {
|
||||
EPOLL_CTL_MOD = 3,
|
||||
}
|
||||
|
||||
[StructLayout (LayoutKind.Sequential, Pack = 1)]
|
||||
[StructLayout (LayoutKind.Explicit, Size=12, Pack=1)]
|
||||
public struct EpollEvent {
|
||||
[FieldOffset (0)]
|
||||
public EpollEvents events;
|
||||
public IntPtr fd;
|
||||
[FieldOffset (4)]
|
||||
public int fd;
|
||||
[FieldOffset (4)]
|
||||
public IntPtr ptr;
|
||||
[FieldOffset (4)]
|
||||
public uint u32;
|
||||
[FieldOffset (4)]
|
||||
public ulong u64;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -2669,7 +2677,7 @@ namespace Mono.Unix.Native {
|
||||
return sys_epoll_create1 (flags);
|
||||
}
|
||||
|
||||
public static int epoll_ctl (int epfd, EpollOp op, IntPtr fd, EpollEvents events)
|
||||
public static int epoll_ctl (int epfd, EpollOp op, int fd, EpollEvents events)
|
||||
{
|
||||
EpollEvent ee = new EpollEvent ();
|
||||
ee.events = events;
|
||||
@@ -2693,7 +2701,7 @@ namespace Mono.Unix.Native {
|
||||
private static extern int sys_epoll_create1 (EpollFlags flags);
|
||||
|
||||
[DllImport (LIBC, SetLastError=true, EntryPoint="epoll_ctl")]
|
||||
private static extern int sys_epoll_ctl (int epfd, EpollOp op, IntPtr fd, ref EpollEvent ee);
|
||||
private static extern int sys_epoll_ctl (int epfd, EpollOp op, int fd, ref EpollEvent ee);
|
||||
|
||||
[DllImport (LIBC, SetLastError=true, EntryPoint="epoll_wait")]
|
||||
private static extern int sys_epoll_wait (int epfd, EpollEvent [] ee, int maxevents, int timeout);
|
||||
|
||||
@@ -75,6 +75,13 @@ namespace Mono.Unix
|
||||
throw new ArgumentException ("socketAddress is not a unix socket address.");
|
||||
*/
|
||||
|
||||
if (socketAddress.Size == 2) {
|
||||
// Empty filename.
|
||||
// Probably from RemoteEndPoint which on linux does not return the file name.
|
||||
UnixEndPoint uep = new UnixEndPoint ("a");
|
||||
uep.filename = "";
|
||||
return uep;
|
||||
}
|
||||
byte [] bytes = new byte [socketAddress.Size - 2 - 1];
|
||||
for (int i = 0; i < bytes.Length; i++) {
|
||||
bytes [i] = socketAddress [i + 2];
|
||||
|
||||
@@ -150,6 +150,10 @@ namespace Mono.Unix {
|
||||
return;
|
||||
|
||||
if (disposing) {
|
||||
try {
|
||||
File.Delete (((UnixEndPoint) savedEP).Filename);
|
||||
} catch {
|
||||
}
|
||||
if (server != null)
|
||||
server.Close ();
|
||||
|
||||
|
||||
+21
-1
@@ -39,9 +39,19 @@ namespace System.Configuration {
|
||||
|
||||
bool modified;
|
||||
bool readOnly;
|
||||
int originalStringHash = 0;
|
||||
|
||||
public bool IsModified {
|
||||
get { return modified; }
|
||||
get {
|
||||
if (modified)
|
||||
return true;
|
||||
|
||||
string str = ToString ();
|
||||
if (str == null)
|
||||
return false;
|
||||
|
||||
return str.GetHashCode () != originalStringHash;
|
||||
}
|
||||
}
|
||||
|
||||
public new bool IsReadOnly {
|
||||
@@ -89,6 +99,7 @@ namespace System.Configuration {
|
||||
CopyTo (contents, 0);
|
||||
|
||||
col.AddRange (contents);
|
||||
col.originalStringHash = originalStringHash;
|
||||
|
||||
return col;
|
||||
}
|
||||
@@ -125,6 +136,15 @@ namespace System.Configuration {
|
||||
|
||||
return String.Join (",", contents);
|
||||
}
|
||||
|
||||
internal void UpdateStringHash ()
|
||||
{
|
||||
string str = ToString ();
|
||||
if (str == null)
|
||||
originalStringHash = 0;
|
||||
else
|
||||
originalStringHash = str.GetHashCode ();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
@@ -48,6 +48,7 @@ namespace System.Configuration
|
||||
foreach (string datum in datums)
|
||||
col.Add (datum.Trim());
|
||||
|
||||
col.UpdateStringHash ();
|
||||
return col;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace System.Configuration {
|
||||
if (relativePath.StartsWith (relConfigPath, StringComparison.Ordinal))
|
||||
relativePath = relativePath.Substring (relConfigPath.Length);
|
||||
|
||||
ConfigurationLocation loc = Locations.Find (relativePath);
|
||||
ConfigurationLocation loc = Locations.FindBest (relativePath);
|
||||
if (loc == null)
|
||||
return parentConfig;
|
||||
|
||||
|
||||
@@ -107,6 +107,9 @@ namespace System.Configuration {
|
||||
|
||||
internal void SetParentConfiguration (Configuration parent)
|
||||
{
|
||||
if (parentResolved)
|
||||
return;
|
||||
|
||||
parentResolved = true;
|
||||
this.parent = parent;
|
||||
if (configuration != null)
|
||||
|
||||
+36
-1
@@ -54,7 +54,42 @@ namespace System.Configuration {
|
||||
return loc;
|
||||
return null;
|
||||
}
|
||||
|
||||
internal ConfigurationLocation FindBest (string location)
|
||||
{
|
||||
if(String.IsNullOrEmpty (location))
|
||||
return null;
|
||||
|
||||
ConfigurationLocation bestMatch = null;
|
||||
int locationlen = location.Length;
|
||||
int bestmatchlen = 0;
|
||||
|
||||
foreach (ConfigurationLocation loc in InnerList) {
|
||||
string lpath = loc.Path;
|
||||
if (String.IsNullOrEmpty (lpath))
|
||||
continue;
|
||||
|
||||
int lpathlen = lpath.Length;
|
||||
if (location.StartsWith (lpath, StringComparison.OrdinalIgnoreCase)) {
|
||||
// Exact match always takes precedence
|
||||
if (locationlen == lpathlen)
|
||||
return loc;
|
||||
|
||||
// ensure path based comparisons consider full directory names (i.e. so 'admin' does not match an 'administration' path)
|
||||
if(locationlen > lpathlen && location [lpathlen] != '/')
|
||||
continue;
|
||||
|
||||
if(bestMatch == null)
|
||||
bestMatch = loc;
|
||||
else if (bestmatchlen < lpathlen) {
|
||||
bestMatch = loc;
|
||||
bestmatchlen = lpathlen;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bestMatch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -85,6 +85,8 @@ System.Threading/LockRecursionException.cs
|
||||
System.Threading/LockRecursionPolicy.cs
|
||||
System.Threading/ReaderWriterLockSlim.cs
|
||||
../corlib/System.Threading/AtomicBoolean.cs
|
||||
System.Threading/ThreadLockState.cs
|
||||
System.Threading/ReaderWriterLockSlimExtensions.cs
|
||||
Microsoft.Win32.SafeHandles/SafePipeHandle.cs
|
||||
System.IO.Pipes/AnonymousPipeClientStream.cs
|
||||
System.IO.Pipes/AnonymousPipeServerStream.cs
|
||||
|
||||
@@ -871,6 +871,8 @@ namespace System.Linq.Expressions {
|
||||
return AddChecked (left, right, method);
|
||||
case ExpressionType.AndAlso:
|
||||
return AndAlso (left, right);
|
||||
case ExpressionType.ArrayIndex:
|
||||
return ArrayIndex (left, right);
|
||||
case ExpressionType.Coalesce:
|
||||
return Coalesce (left, right, conversion);
|
||||
case ExpressionType.Divide:
|
||||
|
||||
@@ -53,11 +53,17 @@ namespace System.Linq.Expressions {
|
||||
return self == typeof (Expression) || self.IsSubclassOf (typeof (Expression));
|
||||
}
|
||||
|
||||
public static bool IsGenericImplementationOf (this Type self, Type type)
|
||||
public static bool IsGenericImplementationOf (this Type self, Type type, out Type generic_iface)
|
||||
{
|
||||
foreach (Type iface in self.GetInterfaces ())
|
||||
if (iface.IsGenericInstanceOf (type))
|
||||
return true;
|
||||
foreach (var iface in self.GetInterfaces ()) {
|
||||
if (!iface.IsGenericInstanceOf (type))
|
||||
continue;
|
||||
|
||||
generic_iface = iface;
|
||||
return true;
|
||||
}
|
||||
|
||||
generic_iface = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -86,23 +86,17 @@ namespace System.Linq.Parallel.QueryNodes
|
||||
internal override IList<IEnumerable<KeyValuePair<long, TResult>>> GetOrderedEnumerables (QueryOptions options)
|
||||
{
|
||||
var source = Parent.GetOrderedEnumerables (options);
|
||||
var sizeRequests = new Tuple<long, int, IEnumerable<TCollection>> [options.PartitionCount];
|
||||
if (collectionSelectorIndexed == null)
|
||||
collectionSelectorIndexed = (e, i) => collectionSelector (e);
|
||||
var sizeRequests = new SizeRequest[source.Count];
|
||||
long deviation = 0;
|
||||
|
||||
Barrier barrier = new Barrier (options.PartitionCount, delegate {
|
||||
Array.Sort (sizeRequests, (e1, e2) => e1.Item1.CompareTo (e2.Item1));
|
||||
long newDeviation = deviation;
|
||||
for (int i = sizeRequests.Length - 1; i >= 0; i--) {
|
||||
var reqi = sizeRequests[i];
|
||||
long newIndex = reqi.Item1 + deviation;
|
||||
newDeviation += reqi.Item2 - 1;
|
||||
for (int j = i - 1; j >= 0; j--)
|
||||
newIndex += sizeRequests[j].Item2 - 1;
|
||||
sizeRequests[i] = Tuple.Create (newIndex, reqi.Item2, reqi.Item3);
|
||||
Barrier barrier = new Barrier (source.Count, delegate (Barrier b) {
|
||||
Array.Sort (sizeRequests, KeyComparator);
|
||||
for (int i = 0; i < b.ParticipantCount; ++i) {
|
||||
if (sizeRequests[i].Key == -1)
|
||||
continue;
|
||||
sizeRequests[i].Key = deviation;
|
||||
deviation += sizeRequests[i].Size;
|
||||
}
|
||||
deviation = newDeviation;
|
||||
});
|
||||
|
||||
return source
|
||||
@@ -120,25 +114,46 @@ namespace System.Linq.Parallel.QueryNodes
|
||||
}
|
||||
|
||||
IEnumerable<KeyValuePair<long, TResult>> GetOrderedEnumerableInternal (IEnumerable<KeyValuePair<long, TSource>> source,
|
||||
Tuple<long, int, IEnumerable<TCollection>>[] sizeRequests,
|
||||
SizeRequest[] sizeRequests,
|
||||
int index,
|
||||
Barrier barrier)
|
||||
{
|
||||
IEnumerator<KeyValuePair<long, TSource>> enumerator = source.GetEnumerator ();
|
||||
bool isIndexed = IsIndexed;
|
||||
|
||||
try {
|
||||
foreach (KeyValuePair<long, TSource> element in source) {
|
||||
IEnumerable<TCollection> collection = collectionSelectorIndexed (element.Value, (int)element.Key);
|
||||
sizeRequests[index] = Tuple.Create (element.Key, GetCount (ref collection), collection);
|
||||
while (true) {
|
||||
KeyValuePair<long, TSource> element;
|
||||
IEnumerable<TCollection> collection;
|
||||
|
||||
if (enumerator.MoveNext ()) {
|
||||
element = enumerator.Current;
|
||||
collection = isIndexed ?
|
||||
collectionSelectorIndexed (element.Value, (int)element.Key) :
|
||||
collectionSelector (element.Value);
|
||||
|
||||
var count = GetCount (ref collection);
|
||||
|
||||
sizeRequests[index].Update (element.Key, count, collection, element.Value);
|
||||
}
|
||||
|
||||
barrier.SignalAndWait ();
|
||||
|
||||
long i = sizeRequests[index].Item1;
|
||||
collection = sizeRequests[index].Item3;
|
||||
long i = sizeRequests[index].Key;
|
||||
collection = sizeRequests[index].Collection;
|
||||
var elementValue = sizeRequests[index].ElementValue;
|
||||
|
||||
sizeRequests[index].Clear ();
|
||||
|
||||
if (i == -1)
|
||||
break;
|
||||
|
||||
foreach (TCollection item in collection)
|
||||
yield return new KeyValuePair<long, TResult> (i++, resultSelector (element.Value, item));
|
||||
yield return new KeyValuePair<long, TResult> (i++, resultSelector (elementValue, item));
|
||||
}
|
||||
} finally {
|
||||
barrier.RemoveParticipant ();
|
||||
enumerator.Dispose ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,6 +172,35 @@ namespace System.Linq.Parallel.QueryNodes
|
||||
|
||||
return foo.Count;
|
||||
}
|
||||
|
||||
static int KeyComparator (SizeRequest e1, SizeRequest e2)
|
||||
{
|
||||
return e1.Key.CompareTo (e2.Key);
|
||||
}
|
||||
|
||||
struct SizeRequest
|
||||
{
|
||||
public long Key;
|
||||
public int Size;
|
||||
public IEnumerable<TCollection> Collection;
|
||||
public TSource ElementValue;
|
||||
|
||||
public void Update (long k, int s, IEnumerable<TCollection> c, TSource ev)
|
||||
{
|
||||
Key = k;
|
||||
Size = s;
|
||||
Collection = c;
|
||||
ElementValue = ev;
|
||||
}
|
||||
|
||||
public void Clear ()
|
||||
{
|
||||
Key = -1;
|
||||
Size = 0;
|
||||
Collection = null;
|
||||
ElementValue = default (TSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,19 @@ namespace System.Linq.Parallel.QueryNodes
|
||||
this.customPartitioner = custom;
|
||||
}
|
||||
|
||||
// If possible, this property will return the number of element the query
|
||||
// is going to process. If that number if pretty low, executing the query
|
||||
// sequentially is better
|
||||
internal int Count {
|
||||
get {
|
||||
if (source == null)
|
||||
return -1;
|
||||
|
||||
ICollection coll = source as ICollection;
|
||||
return coll == null ? -1 : coll.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Visit (INodeVisitor visitor)
|
||||
{
|
||||
visitor.Visit<T> (this);
|
||||
|
||||
@@ -63,14 +63,14 @@ namespace System.Linq.Parallel.QueryNodes
|
||||
internal override IList<IEnumerable<TSource>> GetEnumerablesIndexed (QueryOptions options)
|
||||
{
|
||||
return Parent.GetOrderedEnumerables (options)
|
||||
.Select ((i) => i.Where ((e) => indexedPredicate (e.Value, (int)e.Key)).Select ((e) => e.Value))
|
||||
.Select (i => i.Where (e => indexedPredicate (e.Value, (int)e.Key)).Select (e => e.Value))
|
||||
.ToList ();
|
||||
}
|
||||
|
||||
internal override IList<IEnumerable<TSource>> GetEnumerablesNonIndexed (QueryOptions options)
|
||||
{
|
||||
return Parent.GetEnumerables (options)
|
||||
.Select ((i) => i.Where (predicate))
|
||||
.Select (i => i.Where (predicate))
|
||||
.ToList ();
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace System.Linq.Parallel.QueryNodes
|
||||
{
|
||||
IList<IEnumerable<KeyValuePair<long, TSource>>> sources = Parent.GetOrderedEnumerables (options);
|
||||
|
||||
Tuple<TSource, long, bool>[] store = new Tuple<TSource, long, bool>[sources.Count];
|
||||
ProcessingSlot[] store = new ProcessingSlot[sources.Count];
|
||||
long lastIndex = 0;
|
||||
|
||||
Barrier barrier = new Barrier (sources.Count, delegate (Barrier b) {
|
||||
@@ -87,11 +87,8 @@ namespace System.Linq.Parallel.QueryNodes
|
||||
|
||||
// Reassign a good index
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < store.Length && store[i].Item3; i++) {
|
||||
Tuple<TSource, long, bool> old = store[i];
|
||||
store[i] = Tuple.Create (old.Item1, lastIndex + i, old.Item3);
|
||||
}
|
||||
for (i = 0; i < store.Length && store[i].IsValid; ++i)
|
||||
store[i].Index = lastIndex + i;
|
||||
|
||||
// Update lastIndex for next round
|
||||
lastIndex += i;
|
||||
@@ -102,43 +99,42 @@ namespace System.Linq.Parallel.QueryNodes
|
||||
.ToList ();
|
||||
}
|
||||
|
||||
static int ArraySortMethod (Tuple<TSource, long, bool> lhs, Tuple<TSource, long, bool> rhs)
|
||||
static int ArraySortMethod (ProcessingSlot lhs, ProcessingSlot rhs)
|
||||
{
|
||||
if (lhs.Item3 && !rhs.Item3)
|
||||
if (lhs.IsValid && !rhs.IsValid)
|
||||
return -1;
|
||||
if (!lhs.Item3 && rhs.Item3)
|
||||
if (!lhs.IsValid && rhs.IsValid)
|
||||
return 1;
|
||||
if (!lhs.Item3 && !rhs.Item3)
|
||||
if (!lhs.IsValid && !rhs.IsValid)
|
||||
return 0;
|
||||
|
||||
return (lhs.Item2 < rhs.Item2) ? -1 : 1;
|
||||
return lhs.Index < rhs.Index ? -1 : 1;
|
||||
}
|
||||
|
||||
IEnumerable<KeyValuePair<long, TSource>> GetEnumerator (IEnumerable<KeyValuePair<long, TSource>> source,
|
||||
Barrier barrier,
|
||||
CancellationToken token,
|
||||
Tuple<TSource, long, bool>[] store, int index)
|
||||
ProcessingSlot[] store, int index)
|
||||
{
|
||||
IEnumerator<KeyValuePair<long, TSource>> current = source.GetEnumerator ();
|
||||
bool result;
|
||||
Tuple<TSource, long, bool> reset = Tuple.Create (default (TSource), long.MaxValue, false);
|
||||
bool isIndexed = IsIndexed;
|
||||
|
||||
try {
|
||||
while (current.MoveNext ()) {
|
||||
KeyValuePair<long, TSource> curr = current.Current;
|
||||
|
||||
result = IsIndexed ? indexedPredicate (curr.Value, (int)curr.Key) : predicate (curr.Value);
|
||||
store[index] = Tuple.Create (curr.Value, curr.Key, result);
|
||||
bool result = isIndexed ? indexedPredicate (curr.Value, (int)curr.Key) : predicate (curr.Value);
|
||||
store[index].Update (curr.Value, curr.Key, result);
|
||||
|
||||
barrier.SignalAndWait (token);
|
||||
|
||||
Tuple<TSource, long, bool> value = store [index];
|
||||
var value = store [index];
|
||||
|
||||
if (value.Item3)
|
||||
yield return new KeyValuePair<long, TSource> (value.Item2, value.Item1);
|
||||
if (value.IsValid)
|
||||
yield return new KeyValuePair<long, TSource> (value.Index, value.Value);
|
||||
|
||||
// Reset
|
||||
store[index] = reset;
|
||||
store[index].Clear ();
|
||||
}
|
||||
} finally {
|
||||
// Remove our participation
|
||||
@@ -146,6 +142,25 @@ namespace System.Linq.Parallel.QueryNodes
|
||||
current.Dispose ();
|
||||
}
|
||||
}
|
||||
|
||||
struct ProcessingSlot
|
||||
{
|
||||
public TSource Value;
|
||||
public long Index;
|
||||
public bool IsValid;
|
||||
|
||||
public void Update (TSource v, long i, bool t)
|
||||
{
|
||||
Value = v;
|
||||
Index = i;
|
||||
IsValid = t;
|
||||
}
|
||||
|
||||
public void Clear ()
|
||||
{
|
||||
Update (default (TSource), long.MaxValue, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -37,13 +37,15 @@ namespace System.Linq.Parallel
|
||||
{
|
||||
internal class SlotBucket
|
||||
{
|
||||
ConcurrentDictionary<long, T> temporaryArea = new ConcurrentDictionary<long, T> ();
|
||||
KeyValuePair<long, T>?[] stagingArea;
|
||||
readonly ConcurrentDictionary<long, T> temporaryArea = new ConcurrentDictionary<long, T> ();
|
||||
readonly KeyValuePair<long, T>[] stagingArea;
|
||||
|
||||
long currentIndex;
|
||||
readonly int count;
|
||||
|
||||
CountdownEvent stagingCount;
|
||||
CountdownEvent participantCount;
|
||||
|
||||
CancellationTokenSource src = new CancellationTokenSource ();
|
||||
CancellationToken mergedToken;
|
||||
|
||||
@@ -52,7 +54,7 @@ namespace System.Linq.Parallel
|
||||
this.count = count;
|
||||
stagingCount = new CountdownEvent (count);
|
||||
participantCount = new CountdownEvent (count);
|
||||
stagingArea = new KeyValuePair<long, T>?[count];
|
||||
stagingArea = new KeyValuePair<long, T>[count];
|
||||
currentIndex = -count;
|
||||
mergedToken = CancellationTokenSource.CreateLinkedTokenSource (src.Token, token).Token;
|
||||
}
|
||||
@@ -89,31 +91,36 @@ namespace System.Linq.Parallel
|
||||
src.Cancel ();
|
||||
}
|
||||
|
||||
void Skim ()
|
||||
bool Skim ()
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
T temp;
|
||||
int index = i + (int)currentIndex;
|
||||
|
||||
if (stagingArea[index % count].HasValue)
|
||||
if (stagingArea[i].Key != -1)
|
||||
continue;
|
||||
|
||||
if (!temporaryArea.TryRemove (index, out temp))
|
||||
continue;
|
||||
|
||||
stagingArea [index % count] = new KeyValuePair<long, T> (index, temp);
|
||||
|
||||
result = true;
|
||||
stagingArea [i] = new KeyValuePair<long, T> (index, temp);
|
||||
if (stagingCount.Signal ())
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void Clean ()
|
||||
{
|
||||
for (int i = 0; i < stagingArea.Length; i++)
|
||||
stagingArea[i] = new Nullable<KeyValuePair<long, T>> ();
|
||||
stagingArea[i] = new KeyValuePair<long, T> (-1, default (T));
|
||||
}
|
||||
|
||||
public IEnumerator<KeyValuePair<long, T>?> Wait ()
|
||||
public KeyValuePair<long, T>[] Wait ()
|
||||
{
|
||||
Clean ();
|
||||
stagingCount.Reset ();
|
||||
@@ -123,35 +130,36 @@ namespace System.Linq.Parallel
|
||||
Skim ();
|
||||
|
||||
while (!stagingCount.IsSet) {
|
||||
if (!participantCount.IsSet)
|
||||
if (!participantCount.IsSet) {
|
||||
try {
|
||||
stagingCount.Wait (mergedToken);
|
||||
} catch {
|
||||
Skim ();
|
||||
}
|
||||
}
|
||||
|
||||
if (participantCount.IsSet) {
|
||||
if (Skim ())
|
||||
continue;
|
||||
// Totally finished
|
||||
if (stagingArea[0].HasValue)
|
||||
if (stagingArea[0].Key != -1)
|
||||
break;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return ((IEnumerable<KeyValuePair<long, T>?>)stagingArea).GetEnumerator ();
|
||||
|
||||
return stagingArea;
|
||||
}
|
||||
}
|
||||
|
||||
readonly int num;
|
||||
SlotBucket slotBucket;
|
||||
|
||||
IEnumerator<KeyValuePair<long, T>?> currEnum;
|
||||
KeyValuePair<long, T> curr;
|
||||
KeyValuePair<long, T>[] slot;
|
||||
int current;
|
||||
|
||||
internal OrderingEnumerator (int num, CancellationToken token)
|
||||
{
|
||||
this.num = num;
|
||||
slotBucket = new SlotBucket (num, token);
|
||||
}
|
||||
|
||||
@@ -168,28 +176,25 @@ namespace System.Linq.Parallel
|
||||
public bool MoveNext ()
|
||||
{
|
||||
do {
|
||||
while (currEnum == null || !currEnum.MoveNext ()) {
|
||||
if (currEnum != null)
|
||||
currEnum.Dispose ();
|
||||
if ((currEnum = slotBucket.Wait ()) == null)
|
||||
if (slot == null || ++current >= slot.Length) {
|
||||
if ((slot = slotBucket.Wait ()) == null)
|
||||
return false;
|
||||
current = 0;
|
||||
}
|
||||
} while (!currEnum.Current.HasValue);
|
||||
|
||||
curr = currEnum.Current.Value;
|
||||
} while (slot[current].Key == -1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public T Current {
|
||||
get {
|
||||
return curr.Value;
|
||||
return slot[current].Value;
|
||||
}
|
||||
}
|
||||
|
||||
object IEnumerator.Current {
|
||||
get {
|
||||
return curr.Value;
|
||||
return slot[current].Value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,26 +93,30 @@ namespace System.Linq.Parallel
|
||||
Action endAction,
|
||||
QueryOptions options)
|
||||
{
|
||||
CancellationTokenSource src
|
||||
= CancellationTokenSource.CreateLinkedTokenSource (options.ImplementerToken, options.Token);
|
||||
|
||||
IList<IEnumerable<TElement>> enumerables = acquisitionFunc (node, options);
|
||||
|
||||
Task[] tasks = new Task[enumerables.Count];
|
||||
CancellationTokenSource src
|
||||
= CancellationTokenSource.CreateLinkedTokenSource (options.ImplementerToken, options.Token);
|
||||
|
||||
for (int i = 0; i < tasks.Length; i++) {
|
||||
int index = i;
|
||||
tasks[i] = Task.Factory.StartNew (() => {
|
||||
foreach (TElement item in enumerables[index]) {
|
||||
// This is from specific operators
|
||||
if (options.ImplementerToken.IsCancellationRequested)
|
||||
break;
|
||||
if (options.Token.IsCancellationRequested)
|
||||
throw new OperationCanceledException (options.Token);
|
||||
try {
|
||||
foreach (TElement item in enumerables[index]) {
|
||||
// This is from specific operators
|
||||
if (options.ImplementerToken.IsCancellationRequested)
|
||||
break;
|
||||
if (options.Token.IsCancellationRequested)
|
||||
throw new OperationCanceledException (options.Token);
|
||||
|
||||
call (item, src.Token);
|
||||
call (item, src.Token);
|
||||
}
|
||||
} finally {
|
||||
if (endAction != null)
|
||||
endAction ();
|
||||
}
|
||||
if (endAction != null)
|
||||
endAction ();
|
||||
}, options.Token);
|
||||
}
|
||||
|
||||
@@ -165,28 +169,14 @@ namespace System.Linq.Parallel
|
||||
}
|
||||
|
||||
for (int i = 0; i < tasks.Length; i++) {
|
||||
int index = i;
|
||||
bool firstRun = true;
|
||||
var procSlot = new AggregateProcessSlot<T, U> (options,
|
||||
i,
|
||||
enumerables[i].GetEnumerator (),
|
||||
locals,
|
||||
localCall,
|
||||
seedFunc);
|
||||
|
||||
tasks[i] = Task.Factory.StartNew (() => {
|
||||
foreach (T item in enumerables[index]) {
|
||||
// This is from specific operators
|
||||
if (options.ImplementerToken.IsCancellationRequested)
|
||||
break;
|
||||
if (options.Token.IsCancellationRequested)
|
||||
throw new OperationCanceledException (options.Token);
|
||||
|
||||
if (firstRun && seedFunc == null) {
|
||||
firstRun = false;
|
||||
// HACK: TODO: omgwtfitsuckssomuch
|
||||
locals[index] = (U)(object)item;
|
||||
continue;
|
||||
}
|
||||
|
||||
U acc = locals[index];
|
||||
locals[index] = localCall (acc, item);
|
||||
}
|
||||
}, options.Token);
|
||||
tasks[i] = Task.Factory.StartNew (procSlot.Process, options.Token);
|
||||
}
|
||||
|
||||
Task.WaitAll (tasks, options.Token);
|
||||
@@ -194,6 +184,54 @@ namespace System.Linq.Parallel
|
||||
if (call != null)
|
||||
call (locals);
|
||||
}
|
||||
|
||||
class AggregateProcessSlot<T, U>
|
||||
{
|
||||
readonly QueryOptions options;
|
||||
readonly int index;
|
||||
readonly IEnumerator<T> enumerator;
|
||||
readonly U[] locals;
|
||||
readonly Func<U, T, U> localCall;
|
||||
readonly Func<U> seedFunc;
|
||||
|
||||
public AggregateProcessSlot (QueryOptions options,
|
||||
int index,
|
||||
IEnumerator<T> enumerator,
|
||||
U[] locals,
|
||||
Func<U, T, U> localCall,
|
||||
Func<U> seedFunc)
|
||||
{
|
||||
this.options = options;
|
||||
this.index = index;
|
||||
this.enumerator = enumerator;
|
||||
this.locals = locals;
|
||||
this.localCall = localCall;
|
||||
this.seedFunc = seedFunc;
|
||||
}
|
||||
|
||||
public void Process ()
|
||||
{
|
||||
var token = options.Token;
|
||||
var implementerToken = options.ImplementerToken;
|
||||
|
||||
try {
|
||||
if (seedFunc == null) {
|
||||
if (!enumerator.MoveNext ())
|
||||
return;
|
||||
locals[index] = (U)(object)enumerator.Current;
|
||||
}
|
||||
|
||||
while (enumerator.MoveNext ()) {
|
||||
if (implementerToken.IsCancellationRequested)
|
||||
break;
|
||||
token.ThrowIfCancellationRequested ();
|
||||
locals[index] = localCall (locals[index], enumerator.Current);
|
||||
}
|
||||
} finally {
|
||||
enumerator.Dispose ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -24,11 +24,12 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#if NET_4_0
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
#if NET_4_0
|
||||
using System.Collections.Concurrent.Partitioners;
|
||||
|
||||
namespace System.Linq.Parallel
|
||||
{
|
||||
|
||||
@@ -50,24 +50,30 @@ namespace System.Linq.Parallel
|
||||
internal ParallelQueryEnumerator (QueryBaseNode<T> node)
|
||||
{
|
||||
this.options = ParallelExecuter.CheckQuery (node);
|
||||
Setup ();
|
||||
|
||||
// Launch adding to the buffer asynchronously via Tasks
|
||||
if (options.BehindOrderGuard.Value) {
|
||||
waitAction = ParallelExecuter.ProcessAndCallback (node,
|
||||
ordEnumerator.Add,
|
||||
ordEnumerator.EndParticipation,
|
||||
ordEnumerator.Stop,
|
||||
options);
|
||||
if (options.ShouldBeSequential && options.Mode != ParallelExecutionMode.ForceParallelism) {
|
||||
IEnumerable<T> buffer = node.GetSequential ();
|
||||
loader = buffer.GetEnumerator ();
|
||||
} else {
|
||||
waitAction = ParallelExecuter.ProcessAndCallback (node,
|
||||
buffer.Add,
|
||||
buffer.CompleteAdding,
|
||||
options);
|
||||
}
|
||||
Setup ();
|
||||
|
||||
if (options.Options.HasValue && options.Options.Value == ParallelMergeOptions.FullyBuffered)
|
||||
waitAction ();
|
||||
// Launch adding to the buffer asynchronously via Tasks
|
||||
if (options.BehindOrderGuard.Value) {
|
||||
waitAction = ParallelExecuter.ProcessAndCallback (node,
|
||||
ordEnumerator.Add,
|
||||
ordEnumerator.EndParticipation,
|
||||
ordEnumerator.Stop,
|
||||
options);
|
||||
} else {
|
||||
waitAction = ParallelExecuter.ProcessAndCallback (node,
|
||||
buffer.Add,
|
||||
buffer.CompleteAdding,
|
||||
options);
|
||||
}
|
||||
|
||||
if (options.Options.HasValue && options.Options.Value == ParallelMergeOptions.FullyBuffered)
|
||||
waitAction ();
|
||||
}
|
||||
}
|
||||
|
||||
void Setup ()
|
||||
|
||||
@@ -35,6 +35,8 @@ namespace System.Linq.Parallel
|
||||
|
||||
internal class QueryCheckerVisitor : INodeVisitor
|
||||
{
|
||||
const int minSequentialThreshold = 20;
|
||||
|
||||
// Information gathering
|
||||
ParallelMergeOptions? options = null;
|
||||
ParallelExecutionMode? mode = null;
|
||||
@@ -75,6 +77,10 @@ namespace System.Linq.Parallel
|
||||
behindOrderGuard = false;
|
||||
if (degreeOfParallelism != null)
|
||||
partitionCount = degreeOfParallelism.Value;
|
||||
|
||||
int count;
|
||||
if ((count = node.Count) != -1 && count < minSequentialThreshold)
|
||||
ShouldBeSequential = true;
|
||||
}
|
||||
|
||||
public void Visit<T, TParent> (QueryStreamNode<T, TParent> node)
|
||||
@@ -117,7 +123,7 @@ namespace System.Linq.Parallel
|
||||
internal QueryOptions Options {
|
||||
get {
|
||||
return new QueryOptions (options, mode, token == null ? CancellationToken.None : token.Value,
|
||||
UseStrip, behindOrderGuard, partitionCount, implementerToken);
|
||||
UseStrip, behindOrderGuard, partitionCount, implementerToken, ShouldBeSequential);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,9 +32,20 @@ namespace System.Linq.Parallel
|
||||
{
|
||||
internal class QueryOptions
|
||||
{
|
||||
public ParallelMergeOptions? Options;
|
||||
public ParallelExecutionMode? Mode;
|
||||
public CancellationToken Token;
|
||||
public ParallelMergeOptions? Options {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public ParallelExecutionMode? Mode {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public CancellationToken Token {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
/* This token is to be used by some operator (like Take) to tell that
|
||||
* the execution of the query can be prematurly stopped
|
||||
*
|
||||
@@ -43,11 +54,40 @@ namespace System.Linq.Parallel
|
||||
* set. Operator may chain up multiple cancellation token that way.
|
||||
* When checking for this token, the task body should simply return.
|
||||
*/
|
||||
public CancellationToken ImplementerToken;
|
||||
public bool UseStrip;
|
||||
public bool? BehindOrderGuard;
|
||||
public int PartitionCount;
|
||||
public Tuple<bool, bool, bool> PartitionerSettings;
|
||||
public CancellationToken ImplementerToken {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public bool UseStrip {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public bool? BehindOrderGuard {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public int PartitionCount {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public Tuple<bool, bool, bool> PartitionerSettings {
|
||||
get;
|
||||
internal set;
|
||||
}
|
||||
|
||||
public CancellationToken MergedToken {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public bool ShouldBeSequential {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public QueryOptions (ParallelMergeOptions? options,
|
||||
ParallelExecutionMode? mode,
|
||||
@@ -55,7 +95,8 @@ namespace System.Linq.Parallel
|
||||
bool useStrip,
|
||||
bool? behindOrderGuard,
|
||||
int partitionCount,
|
||||
CancellationToken implementerToken)
|
||||
CancellationToken implementerToken,
|
||||
bool shouldBeSequential)
|
||||
{
|
||||
Options = options;
|
||||
Mode = mode;
|
||||
@@ -65,6 +106,7 @@ namespace System.Linq.Parallel
|
||||
PartitionCount = partitionCount;
|
||||
PartitionerSettings = null;
|
||||
ImplementerToken = implementerToken;
|
||||
ShouldBeSequential = shouldBeSequential;
|
||||
|
||||
MergeTokens (token, implementerToken);
|
||||
}
|
||||
@@ -82,11 +124,6 @@ namespace System.Linq.Parallel
|
||||
else
|
||||
MergedToken = CancellationToken.None;
|
||||
}
|
||||
|
||||
public CancellationToken MergedToken {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -48,12 +48,12 @@ namespace System.Linq
|
||||
return (new RangeList (start, count)).AsParallel ();
|
||||
}
|
||||
|
||||
public static ParallelQuery<TResult> Repeat<TResult> (TResult obj, int count)
|
||||
public static ParallelQuery<TResult> Repeat<TResult> (TResult element, int count)
|
||||
{
|
||||
if (count < 0)
|
||||
throw new ArgumentOutOfRangeException ("count", "count is less than 0");
|
||||
|
||||
return (new RepeatList<TResult> (obj, count)).AsParallel ();
|
||||
return (new RepeatList<TResult> (element, count)).AsParallel ();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -70,7 +70,12 @@ namespace System.Linq
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
|
||||
return new ParallelQuery<TSource> (new QueryStartNode<TSource> (source));
|
||||
/* Someone might be trying to use AsParallel a bit too much, if the query was in fact
|
||||
* already a ParallelQuery, just cast it
|
||||
*/
|
||||
ParallelQuery<TSource> query = source as ParallelQuery<TSource>;
|
||||
|
||||
return query ?? new ParallelQuery<TSource> (new QueryStartNode<TSource> (source));
|
||||
}
|
||||
|
||||
public static ParallelQuery<TSource> AsParallel<TSource> (this Partitioner<TSource> source)
|
||||
@@ -78,7 +83,12 @@ namespace System.Linq
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
|
||||
return new ParallelQuery<TSource> (new QueryStartNode<TSource> (source));
|
||||
/* Someone might be trying to use AsParallel a bit too much, if the query was in fact
|
||||
* already a ParallelQuery, just cast it
|
||||
*/
|
||||
ParallelQuery<TSource> query = source as ParallelQuery<TSource>;
|
||||
|
||||
return query ?? new ParallelQuery<TSource> (new QueryStartNode<TSource> (source));
|
||||
}
|
||||
|
||||
public static ParallelQuery AsParallel (this IEnumerable source)
|
||||
@@ -86,7 +96,12 @@ namespace System.Linq
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
|
||||
return new ParallelQuery<object> (new QueryStartNode<object> (source.Cast<object> ()));
|
||||
/* Someone might be trying to use AsParallel a bit too much, if the query was in fact
|
||||
* already a ParallelQuery, just cast it
|
||||
*/
|
||||
ParallelQuery query = source as ParallelQuery;
|
||||
|
||||
return query ?? new ParallelQuery<object> (new QueryStartNode<object> (source.Cast<object> ()));
|
||||
}
|
||||
|
||||
public static IEnumerable<TSource> AsEnumerable<TSource> (this ParallelQuery<TSource> source)
|
||||
@@ -161,14 +176,14 @@ namespace System.Linq
|
||||
}
|
||||
|
||||
public static ParallelQuery<TSource> WithDegreeOfParallelism<TSource> (this ParallelQuery<TSource> source,
|
||||
int degreeParallelism)
|
||||
int degreeOfParallelism)
|
||||
{
|
||||
if (degreeParallelism < 1 || degreeParallelism > 63)
|
||||
throw new ArgumentException ("degreeOfParallelism is less than 1 or greater than 63", "degreeParallelism");
|
||||
if (degreeOfParallelism < 1 || degreeOfParallelism > 63)
|
||||
throw new ArgumentException ("degreeOfParallelism is less than 1 or greater than 63", "degreeOfParallelism");
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
|
||||
return new ParallelQuery<TSource> (new DegreeOfParallelismNode<TSource> (degreeParallelism, source.Node));
|
||||
return new ParallelQuery<TSource> (new DegreeOfParallelismNode<TSource> (degreeOfParallelism, source.Node));
|
||||
}
|
||||
|
||||
internal static ParallelQuery<TSource> WithImplementerToken<TSource> (this ParallelQuery<TSource> source,
|
||||
@@ -319,15 +334,15 @@ namespace System.Linq
|
||||
}
|
||||
|
||||
public static TResult Aggregate<TSource, TAccumulate, TResult> (this ParallelQuery<TSource> source,
|
||||
Func<TAccumulate> seedFunc,
|
||||
Func<TAccumulate> seedFactory,
|
||||
Func<TAccumulate, TSource, TAccumulate> updateAccumulatorFunc,
|
||||
Func<TAccumulate, TAccumulate, TAccumulate> combineAccumulatorsFunc,
|
||||
Func<TAccumulate, TResult> resultSelector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (seedFunc == null)
|
||||
throw new ArgumentNullException ("seedFunc");
|
||||
if (seedFactory == null)
|
||||
throw new ArgumentNullException ("seedFactory");
|
||||
if (updateAccumulatorFunc == null)
|
||||
throw new ArgumentNullException ("updateAccumulatorFunc");
|
||||
if (combineAccumulatorsFunc == null)
|
||||
@@ -337,7 +352,7 @@ namespace System.Linq
|
||||
|
||||
TAccumulate accumulator = default (TAccumulate);
|
||||
|
||||
ParallelExecuter.ProcessAndAggregate<TSource, TAccumulate> (source.Node, seedFunc, updateAccumulatorFunc, (list) => {
|
||||
ParallelExecuter.ProcessAndAggregate<TSource, TAccumulate> (source.Node, seedFactory, updateAccumulatorFunc, (list) => {
|
||||
accumulator = list [0];
|
||||
for (int i = 1; i < list.Count; i++)
|
||||
accumulator = combineAccumulatorsFunc (accumulator, list[i]);
|
||||
@@ -1200,104 +1215,104 @@ namespace System.Linq
|
||||
return source.Select ((e) => e.HasValue ? e.Value : 0).Average ();
|
||||
}
|
||||
|
||||
public static double Average<TSource> (this ParallelQuery<TSource> source, Func<TSource, int> func)
|
||||
public static double Average<TSource> (this ParallelQuery<TSource> source, Func<TSource, int> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Average ();
|
||||
return source.Select (selector).Average ();
|
||||
}
|
||||
|
||||
public static double Average<TSource> (this ParallelQuery<TSource> source, Func<TSource, long> func)
|
||||
public static double Average<TSource> (this ParallelQuery<TSource> source, Func<TSource, long> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Average ();
|
||||
return source.Select (selector).Average ();
|
||||
}
|
||||
|
||||
public static float Average<TSource> (this ParallelQuery<TSource> source, Func<TSource, float> func)
|
||||
public static float Average<TSource> (this ParallelQuery<TSource> source, Func<TSource, float> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Average ();
|
||||
return source.Select (selector).Average ();
|
||||
}
|
||||
|
||||
public static double Average<TSource> (this ParallelQuery<TSource> source, Func<TSource, double> func)
|
||||
public static double Average<TSource> (this ParallelQuery<TSource> source, Func<TSource, double> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Average ();
|
||||
return source.Select (selector).Average ();
|
||||
}
|
||||
|
||||
public static decimal Average<TSource> (this ParallelQuery<TSource> source, Func<TSource, decimal> func)
|
||||
public static decimal Average<TSource> (this ParallelQuery<TSource> source, Func<TSource, decimal> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Average ();
|
||||
return source.Select (selector).Average ();
|
||||
}
|
||||
|
||||
public static double? Average<TSource> (this ParallelQuery<TSource> source, Func<TSource, int?> func)
|
||||
public static double? Average<TSource> (this ParallelQuery<TSource> source, Func<TSource, int?> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Average ();
|
||||
return source.Select (selector).Average ();
|
||||
}
|
||||
|
||||
public static double? Average<TSource> (this ParallelQuery<TSource> source, Func<TSource, long?> func)
|
||||
public static double? Average<TSource> (this ParallelQuery<TSource> source, Func<TSource, long?> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Average ();
|
||||
return source.Select (selector).Average ();
|
||||
}
|
||||
|
||||
public static float? Average<TSource> (this ParallelQuery<TSource> source, Func<TSource, float?> func)
|
||||
public static float? Average<TSource> (this ParallelQuery<TSource> source, Func<TSource, float?> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Average ();
|
||||
return source.Select (selector).Average ();
|
||||
}
|
||||
|
||||
public static double? Average<TSource> (this ParallelQuery<TSource> source, Func<TSource, double?> func)
|
||||
public static double? Average<TSource> (this ParallelQuery<TSource> source, Func<TSource, double?> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Average ();
|
||||
return source.Select (selector).Average ();
|
||||
}
|
||||
|
||||
public static decimal? Average<TSource> (this ParallelQuery<TSource> source, Func<TSource, decimal?> func)
|
||||
public static decimal? Average<TSource> (this ParallelQuery<TSource> source, Func<TSource, decimal?> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Average ();
|
||||
return source.Select (selector).Average ();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -1379,104 +1394,104 @@ namespace System.Linq
|
||||
return source.Select ((e) => e.HasValue ? e.Value : 0).Sum ();
|
||||
}
|
||||
|
||||
public static int Sum<TSource> (this ParallelQuery<TSource> source, Func<TSource, int> func)
|
||||
public static int Sum<TSource> (this ParallelQuery<TSource> source, Func<TSource, int> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Sum ();
|
||||
return source.Select (selector).Sum ();
|
||||
}
|
||||
|
||||
public static long Sum<TSource> (this ParallelQuery<TSource> source, Func<TSource, long> func)
|
||||
public static long Sum<TSource> (this ParallelQuery<TSource> source, Func<TSource, long> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Sum ();
|
||||
return source.Select (selector).Sum ();
|
||||
}
|
||||
|
||||
public static decimal Sum<TSource> (this ParallelQuery<TSource> source, Func<TSource, decimal> func)
|
||||
public static decimal Sum<TSource> (this ParallelQuery<TSource> source, Func<TSource, decimal> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Sum ();
|
||||
return source.Select (selector).Sum ();
|
||||
}
|
||||
|
||||
public static float Sum<TSource> (this ParallelQuery<TSource> source, Func<TSource, float> func)
|
||||
public static float Sum<TSource> (this ParallelQuery<TSource> source, Func<TSource, float> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Sum ();
|
||||
return source.Select (selector).Sum ();
|
||||
}
|
||||
|
||||
public static double Sum<TSource> (this ParallelQuery<TSource> source, Func<TSource, double> func)
|
||||
public static double Sum<TSource> (this ParallelQuery<TSource> source, Func<TSource, double> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Sum ();
|
||||
return source.Select (selector).Sum ();
|
||||
}
|
||||
|
||||
public static int? Sum<TSource> (this ParallelQuery<TSource> source, Func<TSource, int?> func)
|
||||
public static int? Sum<TSource> (this ParallelQuery<TSource> source, Func<TSource, int?> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Sum ();
|
||||
return source.Select (selector).Sum ();
|
||||
}
|
||||
|
||||
public static long? Sum<TSource> (this ParallelQuery<TSource> source, Func<TSource, long?> func)
|
||||
public static long? Sum<TSource> (this ParallelQuery<TSource> source, Func<TSource, long?> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Sum ();
|
||||
return source.Select (selector).Sum ();
|
||||
}
|
||||
|
||||
public static decimal? Sum<TSource> (this ParallelQuery<TSource> source, Func<TSource, decimal?> func)
|
||||
public static decimal? Sum<TSource> (this ParallelQuery<TSource> source, Func<TSource, decimal?> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Sum ();
|
||||
return source.Select (selector).Sum ();
|
||||
}
|
||||
|
||||
public static float? Sum<TSource> (this ParallelQuery<TSource> source, Func<TSource, float?> func)
|
||||
public static float? Sum<TSource> (this ParallelQuery<TSource> source, Func<TSource, float?> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Sum ();
|
||||
return source.Select (selector).Sum ();
|
||||
}
|
||||
|
||||
public static double? Sum<TSource> (this ParallelQuery<TSource> source, Func<TSource, double?> func)
|
||||
public static double? Sum<TSource> (this ParallelQuery<TSource> source, Func<TSource, double?> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Sum ();
|
||||
return source.Select (selector).Sum ();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -1527,14 +1542,14 @@ namespace System.Linq
|
||||
return BestOrder (source, (first, second) => comparer.Compare (first, second) < 0, default (TSource));
|
||||
}
|
||||
|
||||
public static TResult Min<TSource, TResult> (this ParallelQuery<TSource> source, Func<TSource, TResult> func)
|
||||
public static TResult Min<TSource, TResult> (this ParallelQuery<TSource> source, Func<TSource, TResult> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Min ();
|
||||
return source.Select (selector).Min ();
|
||||
}
|
||||
|
||||
public static int? Min (this ParallelQuery<int?> source)
|
||||
@@ -1577,104 +1592,104 @@ namespace System.Linq
|
||||
return source.Select ((e) => e.HasValue ? e.Value : decimal.MaxValue).Min ();
|
||||
}
|
||||
|
||||
public static int Min<TSource> (this ParallelQuery<TSource> source, Func<TSource, int> func)
|
||||
public static int Min<TSource> (this ParallelQuery<TSource> source, Func<TSource, int> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Min ();
|
||||
return source.Select (selector).Min ();
|
||||
}
|
||||
|
||||
public static long Min<TSource> (this ParallelQuery<TSource> source, Func<TSource, long> func)
|
||||
public static long Min<TSource> (this ParallelQuery<TSource> source, Func<TSource, long> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Min ();
|
||||
return source.Select (selector).Min ();
|
||||
}
|
||||
|
||||
public static float Min<TSource> (this ParallelQuery<TSource> source, Func<TSource, float> func)
|
||||
public static float Min<TSource> (this ParallelQuery<TSource> source, Func<TSource, float> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Min ();
|
||||
return source.Select (selector).Min ();
|
||||
}
|
||||
|
||||
public static double Min<TSource> (this ParallelQuery<TSource> source, Func<TSource, double> func)
|
||||
public static double Min<TSource> (this ParallelQuery<TSource> source, Func<TSource, double> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Min ();
|
||||
return source.Select (selector).Min ();
|
||||
}
|
||||
|
||||
public static decimal Min<TSource> (this ParallelQuery<TSource> source, Func<TSource, decimal> func)
|
||||
public static decimal Min<TSource> (this ParallelQuery<TSource> source, Func<TSource, decimal> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Min ();
|
||||
return source.Select (selector).Min ();
|
||||
}
|
||||
|
||||
public static int? Min<TSource> (this ParallelQuery<TSource> source, Func<TSource, int?> func)
|
||||
public static int? Min<TSource> (this ParallelQuery<TSource> source, Func<TSource, int?> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Min ();
|
||||
return source.Select (selector).Min ();
|
||||
}
|
||||
|
||||
public static long? Min<TSource> (this ParallelQuery<TSource> source, Func<TSource, long?> func)
|
||||
public static long? Min<TSource> (this ParallelQuery<TSource> source, Func<TSource, long?> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Min ();
|
||||
return source.Select (selector).Min ();
|
||||
}
|
||||
|
||||
public static float? Min<TSource> (this ParallelQuery<TSource> source, Func<TSource, float?> func)
|
||||
public static float? Min<TSource> (this ParallelQuery<TSource> source, Func<TSource, float?> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Min ();
|
||||
return source.Select (selector).Min ();
|
||||
}
|
||||
|
||||
public static double? Min<TSource> (this ParallelQuery<TSource> source, Func<TSource, double?> func)
|
||||
public static double? Min<TSource> (this ParallelQuery<TSource> source, Func<TSource, double?> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Min ();
|
||||
return source.Select (selector).Min ();
|
||||
}
|
||||
|
||||
public static decimal? Min<TSource> (this ParallelQuery<TSource> source, Func<TSource, decimal?> func)
|
||||
public static decimal? Min<TSource> (this ParallelQuery<TSource> source, Func<TSource, decimal?> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Min ();
|
||||
return source.Select (selector).Min ();
|
||||
}
|
||||
|
||||
public static int Max (this ParallelQuery<int> source)
|
||||
@@ -1709,14 +1724,14 @@ namespace System.Linq
|
||||
return BestOrder (source, (first, second) => comparer.Compare (first, second) > 0, default (TSource));
|
||||
}
|
||||
|
||||
public static TResult Max<TSource, TResult> (this ParallelQuery<TSource> source, Func<TSource, TResult> func)
|
||||
public static TResult Max<TSource, TResult> (this ParallelQuery<TSource> source, Func<TSource, TResult> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Max ();
|
||||
return source.Select (selector).Max ();
|
||||
}
|
||||
|
||||
public static int? Max (this ParallelQuery<int?> source)
|
||||
@@ -1759,104 +1774,104 @@ namespace System.Linq
|
||||
return source.Select ((e) => e.HasValue ? e.Value : decimal.MinValue).Max ();
|
||||
}
|
||||
|
||||
public static int Max<TSource> (this ParallelQuery<TSource> source, Func<TSource, int> func)
|
||||
public static int Max<TSource> (this ParallelQuery<TSource> source, Func<TSource, int> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Max ();
|
||||
return source.Select (selector).Max ();
|
||||
}
|
||||
|
||||
public static long Max<TSource> (this ParallelQuery<TSource> source, Func<TSource, long> func)
|
||||
public static long Max<TSource> (this ParallelQuery<TSource> source, Func<TSource, long> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Max ();
|
||||
return source.Select (selector).Max ();
|
||||
}
|
||||
|
||||
public static float Max<TSource> (this ParallelQuery<TSource> source, Func<TSource, float> func)
|
||||
public static float Max<TSource> (this ParallelQuery<TSource> source, Func<TSource, float> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Max ();
|
||||
return source.Select (selector).Max ();
|
||||
}
|
||||
|
||||
public static double Max<TSource> (this ParallelQuery<TSource> source, Func<TSource, double> func)
|
||||
public static double Max<TSource> (this ParallelQuery<TSource> source, Func<TSource, double> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Max ();
|
||||
return source.Select (selector).Max ();
|
||||
}
|
||||
|
||||
public static decimal Max<TSource> (this ParallelQuery<TSource> source, Func<TSource, decimal> func)
|
||||
public static decimal Max<TSource> (this ParallelQuery<TSource> source, Func<TSource, decimal> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Max ();
|
||||
return source.Select (selector).Max ();
|
||||
}
|
||||
|
||||
public static int? Max<TSource> (this ParallelQuery<TSource> source, Func<TSource, int?> func)
|
||||
public static int? Max<TSource> (this ParallelQuery<TSource> source, Func<TSource, int?> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Max ();
|
||||
return source.Select (selector).Max ();
|
||||
}
|
||||
|
||||
public static long? Max<TSource> (this ParallelQuery<TSource> source, Func<TSource, long?> func)
|
||||
public static long? Max<TSource> (this ParallelQuery<TSource> source, Func<TSource, long?> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Max ();
|
||||
return source.Select (selector).Max ();
|
||||
}
|
||||
|
||||
public static float? Max<TSource> (this ParallelQuery<TSource> source, Func<TSource, float?> func)
|
||||
public static float? Max<TSource> (this ParallelQuery<TSource> source, Func<TSource, float?> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Max ();
|
||||
return source.Select (selector).Max ();
|
||||
}
|
||||
|
||||
public static double? Max<TSource> (this ParallelQuery<TSource> source, Func<TSource, double?> func)
|
||||
public static double? Max<TSource> (this ParallelQuery<TSource> source, Func<TSource, double?> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Max ();
|
||||
return source.Select (selector).Max ();
|
||||
}
|
||||
|
||||
public static decimal? Max<TSource> (this ParallelQuery<TSource> source, Func<TSource, decimal?> func)
|
||||
public static decimal? Max<TSource> (this ParallelQuery<TSource> source, Func<TSource, decimal?> selector)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
if (func == null)
|
||||
throw new ArgumentNullException ("func");
|
||||
if (selector == null)
|
||||
throw new ArgumentNullException ("selector");
|
||||
|
||||
return source.Select (func).Max ();
|
||||
return source.Select (selector).Max ();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -158,13 +158,12 @@ namespace System.Linq {
|
||||
if (queryable != null)
|
||||
return queryable;
|
||||
|
||||
var type = source.GetType ();
|
||||
|
||||
if (!type.IsGenericImplementationOf (typeof (IEnumerable<>)))
|
||||
Type ienumerable;
|
||||
if (!source.GetType ().IsGenericImplementationOf (typeof (IEnumerable<>), out ienumerable))
|
||||
throw new ArgumentException ("source is not IEnumerable<>");
|
||||
|
||||
return (IQueryable) Activator.CreateInstance (
|
||||
typeof (QueryableEnumerable<>).MakeGenericType (type.GetFirstGenericArgument ()), source);
|
||||
typeof (QueryableEnumerable<>).MakeGenericType (ienumerable.GetFirstGenericArgument ()), source);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
//
|
||||
// TaskExtensions.cs
|
||||
//
|
||||
// Author:
|
||||
// Jérémie "Garuma" Laval <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2010 Jérémie "Garuma" Laval
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if NET_4_0 && !BOOTSTRAP_NET_4_0
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace System.Threading.Tasks
|
||||
{
|
||||
public static class TaskExtensions
|
||||
{
|
||||
const TaskContinuationOptions opt = TaskContinuationOptions.ExecuteSynchronously;
|
||||
|
||||
public static Task<TResult> Unwrap<TResult> (this Task<Task<TResult>> task)
|
||||
{
|
||||
if (task == null)
|
||||
throw new ArgumentNullException ("task");
|
||||
|
||||
TaskCompletionSource<TResult> src = new TaskCompletionSource<TResult> ();
|
||||
|
||||
task.ContinueWith (t1 => CopyCat (t1, src, () => t1.Result.ContinueWith (t2 => CopyCat (t2, src, () => src.SetResult (t2.Result)), opt)), opt);
|
||||
|
||||
return src.Task;
|
||||
}
|
||||
|
||||
public static Task Unwrap (this Task<Task> task)
|
||||
{
|
||||
if (task == null)
|
||||
throw new ArgumentNullException ("task");
|
||||
|
||||
TaskCompletionSource<object> src = new TaskCompletionSource<object> ();
|
||||
|
||||
task.ContinueWith (t1 => CopyCat (t1, src, () => t1.Result.ContinueWith (t2 => CopyCat (t2, src, () => src.SetResult (null)), opt)), opt);
|
||||
|
||||
return src.Task;
|
||||
}
|
||||
|
||||
static void CopyCat<TResult> (Task source,
|
||||
TaskCompletionSource<TResult> dest,
|
||||
Action normalAction)
|
||||
{
|
||||
if (source.IsCanceled)
|
||||
dest.SetCanceled ();
|
||||
else if (source.IsFaulted)
|
||||
dest.SetException (source.Exception.InnerExceptions);
|
||||
else
|
||||
normalAction ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -35,43 +35,6 @@ using System.Threading;
|
||||
|
||||
namespace System.Threading {
|
||||
|
||||
[Flags]
|
||||
internal enum ThreadLockState
|
||||
{
|
||||
None = 0,
|
||||
Read = 1,
|
||||
Write = 2,
|
||||
Upgradable = 4,
|
||||
UpgradedRead = 5,
|
||||
UpgradedWrite = 6
|
||||
}
|
||||
|
||||
internal static class ReaderWriterLockSlimExtensions
|
||||
{
|
||||
internal static bool Has (this ThreadLockState state, ThreadLockState value)
|
||||
{
|
||||
return (state & value) > 0;
|
||||
}
|
||||
|
||||
#if !NET_4_0 && !NET_4_0_BOOTSTRAP
|
||||
internal static bool Wait (this ManualResetEvent self, int timeout)
|
||||
{
|
||||
return self.WaitOne (timeout);
|
||||
}
|
||||
|
||||
internal static bool IsSet (this ManualResetEvent self)
|
||||
{
|
||||
return self.WaitOne (0);
|
||||
}
|
||||
#else
|
||||
internal static bool IsSet (this ManualResetEventSlim self)
|
||||
{
|
||||
return self.IsSet;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
[HostProtectionAttribute(SecurityAction.LinkDemand, MayLeakOnAbort = true)]
|
||||
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true, ExternalThreading = true)]
|
||||
public class ReaderWriterLockSlim : IDisposable
|
||||
@@ -104,8 +67,11 @@ namespace System.Threading {
|
||||
int numReadWaiters, numUpgradeWaiters, numWriteWaiters;
|
||||
bool disposed;
|
||||
|
||||
static int idPool = int.MinValue;
|
||||
readonly int id = Interlocked.Increment (ref idPool);
|
||||
|
||||
[ThreadStatic]
|
||||
static IDictionary<ReaderWriterLockSlim, ThreadLockState> currentThreadState;
|
||||
static IDictionary<int, ThreadLockState> currentThreadState;
|
||||
|
||||
public ReaderWriterLockSlim () : this (LockRecursionPolicy.NoRecursion)
|
||||
{
|
||||
@@ -123,23 +89,30 @@ namespace System.Threading {
|
||||
|
||||
public bool TryEnterReadLock (int millisecondsTimeout)
|
||||
{
|
||||
if (CheckState (millisecondsTimeout, ThreadLockState.Read))
|
||||
ThreadLockState ctstate = CurrentThreadState;
|
||||
|
||||
if (CheckState (millisecondsTimeout, LockState.Read)) {
|
||||
ctstate.ReaderRecursiveCount++;
|
||||
return true;
|
||||
}
|
||||
|
||||
// This is downgrading from upgradable, no need for check since
|
||||
// we already have a sort-of read lock that's going to disappear
|
||||
// after user calls ExitUpgradeableReadLock.
|
||||
// Same idea when recursion is allowed and a write thread wants to
|
||||
// go for a Read too.
|
||||
if (CurrentThreadState.Has (ThreadLockState.Upgradable)
|
||||
|| recursionPolicy == LockRecursionPolicy.SupportsRecursion) {
|
||||
if (CurrentLockState.Has (LockState.Upgradable)
|
||||
|| (recursionPolicy == LockRecursionPolicy.SupportsRecursion && ctstate.LockState.Has (LockState.Write))) {
|
||||
Interlocked.Add (ref rwlock, RwRead);
|
||||
CurrentThreadState = CurrentThreadState ^ ThreadLockState.Read;
|
||||
ctstate.LockState ^= LockState.Read;
|
||||
ctstate.ReaderRecursiveCount++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Stopwatch sw = Stopwatch.StartNew ();
|
||||
Interlocked.Increment (ref numReadWaiters);
|
||||
int val = 0;
|
||||
|
||||
while (millisecondsTimeout == -1 || sw.ElapsedMilliseconds < millisecondsTimeout) {
|
||||
if ((rwlock & 0x7) > 0) {
|
||||
@@ -147,11 +120,20 @@ namespace System.Threading {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((Interlocked.Add (ref rwlock, RwRead) & 0x7) == 0) {
|
||||
CurrentThreadState = CurrentThreadState ^ ThreadLockState.Read;
|
||||
Interlocked.Decrement (ref numReadWaiters);
|
||||
if (readerDoneEvent.IsSet ())
|
||||
/* Optimistically try to add ourselves to the reader value
|
||||
* if the adding was too late and another writer came in between
|
||||
* we revert the operation.
|
||||
*/
|
||||
if (((val = Interlocked.Add (ref rwlock, RwRead)) & 0x7) == 0) {
|
||||
/* If we are the first reader, reset the event to let other threads
|
||||
* sleep correctly if they try to acquire write lock
|
||||
*/
|
||||
if (val >> RwReadBit == 1)
|
||||
readerDoneEvent.Reset ();
|
||||
|
||||
ctstate.LockState ^= LockState.Read;
|
||||
ctstate.ReaderRecursiveCount++;
|
||||
Interlocked.Decrement (ref numReadWaiters);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -171,12 +153,16 @@ namespace System.Threading {
|
||||
|
||||
public void ExitReadLock ()
|
||||
{
|
||||
if (!CurrentThreadState.Has (ThreadLockState.Read))
|
||||
ThreadLockState ctstate = CurrentThreadState;
|
||||
|
||||
if (!ctstate.LockState.Has (LockState.Read))
|
||||
throw new SynchronizationLockException ("The current thread has not entered the lock in read mode");
|
||||
|
||||
CurrentThreadState = ThreadLockState.None;
|
||||
if (Interlocked.Add (ref rwlock, -RwRead) >> RwReadBit == 0)
|
||||
readerDoneEvent.Set ();
|
||||
if (--ctstate.ReaderRecursiveCount == 0) {
|
||||
ctstate.LockState ^= LockState.Read;
|
||||
if (Interlocked.Add (ref rwlock, -RwRead) >> RwReadBit == 0)
|
||||
readerDoneEvent.Set ();
|
||||
}
|
||||
}
|
||||
|
||||
public void EnterWriteLock ()
|
||||
@@ -186,39 +172,54 @@ namespace System.Threading {
|
||||
|
||||
public bool TryEnterWriteLock (int millisecondsTimeout)
|
||||
{
|
||||
bool isUpgradable = CurrentThreadState.Has (ThreadLockState.Upgradable);
|
||||
if (CheckState (millisecondsTimeout, isUpgradable ? ThreadLockState.UpgradedWrite : ThreadLockState.Write))
|
||||
ThreadLockState ctstate = CurrentThreadState;
|
||||
|
||||
if (CheckState (millisecondsTimeout, LockState.Write)) {
|
||||
ctstate.WriterRecursiveCount++;
|
||||
return true;
|
||||
}
|
||||
|
||||
Stopwatch sw = Stopwatch.StartNew ();
|
||||
Interlocked.Increment (ref numWriteWaiters);
|
||||
bool isUpgradable = ctstate.LockState.Has (LockState.Upgradable);
|
||||
|
||||
// If the code goes there that means we had a read lock beforehand
|
||||
/* If the code goes there that means we had a read lock beforehand
|
||||
* that need to be suppressed, we also take the opportunity to register
|
||||
* our interest in the write lock to avoid other write wannabe process
|
||||
* coming in the middle
|
||||
*/
|
||||
if (isUpgradable && rwlock >= RwRead)
|
||||
Interlocked.Add (ref rwlock, -RwRead);
|
||||
if (Interlocked.Add (ref rwlock, RwWaitUpgrade - RwRead) >> RwReadBit == 0)
|
||||
readerDoneEvent.Set ();
|
||||
|
||||
int stateCheck = isUpgradable ? RwWaitUpgrade : RwWait;
|
||||
int appendValue = RwWait | (isUpgradable ? RwWaitUpgrade : 0);
|
||||
|
||||
while (millisecondsTimeout < 0 || sw.ElapsedMilliseconds < millisecondsTimeout) {
|
||||
int state = rwlock;
|
||||
|
||||
if (state <= stateCheck) {
|
||||
if (Interlocked.CompareExchange (ref rwlock, RwWrite, state) == state) {
|
||||
CurrentThreadState = isUpgradable ? ThreadLockState.UpgradedWrite : ThreadLockState.Write;
|
||||
writerDoneEvent.Reset ();
|
||||
ctstate.LockState ^= LockState.Write;
|
||||
ctstate.WriterRecursiveCount++;
|
||||
Interlocked.Decrement (ref numWriteWaiters);
|
||||
if (writerDoneEvent.IsSet ())
|
||||
writerDoneEvent.Reset ();
|
||||
return true;
|
||||
}
|
||||
state = rwlock;
|
||||
}
|
||||
|
||||
while ((state & RwWait) == 0 && Interlocked.CompareExchange (ref rwlock, state | appendValue, state) == state)
|
||||
state = rwlock;
|
||||
// We register our interest in taking the Write lock (if upgradeable it's already done)
|
||||
if (!isUpgradable)
|
||||
while ((state & RwWait) == 0 && Interlocked.CompareExchange (ref rwlock, state | RwWait, state) == state)
|
||||
state = rwlock;
|
||||
|
||||
while (rwlock > stateCheck && (millisecondsTimeout < 0 || sw.ElapsedMilliseconds < millisecondsTimeout))
|
||||
readerDoneEvent.Wait (ComputeTimeout (millisecondsTimeout, sw));
|
||||
// Before falling to sleep
|
||||
while (rwlock > stateCheck && (millisecondsTimeout < 0 || sw.ElapsedMilliseconds < millisecondsTimeout)) {
|
||||
if ((rwlock & RwWrite) != 0)
|
||||
writerDoneEvent.Wait (ComputeTimeout (millisecondsTimeout, sw));
|
||||
else if ((rwlock >> RwReadBit) > 0)
|
||||
readerDoneEvent.Wait (ComputeTimeout (millisecondsTimeout, sw));
|
||||
}
|
||||
}
|
||||
|
||||
Interlocked.Decrement (ref numWriteWaiters);
|
||||
@@ -232,12 +233,20 @@ namespace System.Threading {
|
||||
|
||||
public void ExitWriteLock ()
|
||||
{
|
||||
if (!CurrentThreadState.Has (ThreadLockState.Write))
|
||||
ThreadLockState ctstate = CurrentThreadState;
|
||||
|
||||
if (!ctstate.LockState.Has (LockState.Write))
|
||||
throw new SynchronizationLockException ("The current thread has not entered the lock in write mode");
|
||||
|
||||
CurrentThreadState = CurrentThreadState ^ ThreadLockState.Write;
|
||||
Interlocked.Add (ref rwlock, -RwWrite);
|
||||
writerDoneEvent.Set ();
|
||||
if (--ctstate.WriterRecursiveCount == 0) {
|
||||
bool isUpgradable = ctstate.LockState.Has (LockState.Upgradable);
|
||||
ctstate.LockState ^= LockState.Write;
|
||||
|
||||
int value = Interlocked.Add (ref rwlock, isUpgradable ? RwRead - RwWrite : -RwWrite);
|
||||
writerDoneEvent.Set ();
|
||||
if (isUpgradable && value >> RwReadBit == 1)
|
||||
readerDoneEvent.Reset ();
|
||||
}
|
||||
}
|
||||
|
||||
public void EnterUpgradeableReadLock ()
|
||||
@@ -251,10 +260,14 @@ namespace System.Threading {
|
||||
//
|
||||
public bool TryEnterUpgradeableReadLock (int millisecondsTimeout)
|
||||
{
|
||||
if (CheckState (millisecondsTimeout, ThreadLockState.Upgradable))
|
||||
return true;
|
||||
ThreadLockState ctstate = CurrentThreadState;
|
||||
|
||||
if (CurrentThreadState.Has (ThreadLockState.Read))
|
||||
if (CheckState (millisecondsTimeout, LockState.Upgradable)) {
|
||||
ctstate.UpgradeableRecursiveCount++;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ctstate.LockState.Has (LockState.Read))
|
||||
throw new LockRecursionException ("The current thread has already entered read mode");
|
||||
|
||||
Stopwatch sw = Stopwatch.StartNew ();
|
||||
@@ -272,8 +285,10 @@ namespace System.Threading {
|
||||
upgradableEvent.Reset ();
|
||||
|
||||
if (TryEnterReadLock (ComputeTimeout (millisecondsTimeout, sw))) {
|
||||
CurrentThreadState = ThreadLockState.Upgradable;
|
||||
ctstate.LockState = LockState.Upgradable;
|
||||
Interlocked.Decrement (ref numUpgradeWaiters);
|
||||
ctstate.ReaderRecursiveCount--;
|
||||
ctstate.UpgradeableRecursiveCount++;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -292,14 +307,16 @@ namespace System.Threading {
|
||||
|
||||
public void ExitUpgradeableReadLock ()
|
||||
{
|
||||
if (!CurrentThreadState.Has (ThreadLockState.Upgradable | ThreadLockState.Read))
|
||||
throw new SynchronizationLockException ("The current thread has not entered the lock in upgradable mode");
|
||||
|
||||
upgradableTaken.Value = false;
|
||||
upgradableEvent.Set ();
|
||||
ThreadLockState ctstate = CurrentThreadState;
|
||||
|
||||
CurrentThreadState = CurrentThreadState ^ ThreadLockState.Upgradable;
|
||||
Interlocked.Add (ref rwlock, -RwRead);
|
||||
if (--ctstate.UpgradeableRecursiveCount == 0) {
|
||||
upgradableTaken.Value = false;
|
||||
upgradableEvent.Set ();
|
||||
|
||||
ctstate.LockState ^= LockState.Upgradable;
|
||||
if (Interlocked.Add (ref rwlock, -RwRead) >> RwReadBit == 0)
|
||||
readerDoneEvent.Set ();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
@@ -309,43 +326,43 @@ namespace System.Threading {
|
||||
|
||||
public bool IsReadLockHeld {
|
||||
get {
|
||||
return rwlock >= RwRead;
|
||||
return rwlock >= RwRead && CurrentThreadState.LockState.Has (LockState.Read);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsWriteLockHeld {
|
||||
get {
|
||||
return (rwlock & RwWrite) > 0;
|
||||
return (rwlock & RwWrite) > 0 && CurrentThreadState.LockState.Has (LockState.Write);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsUpgradeableReadLockHeld {
|
||||
get {
|
||||
return upgradableTaken.Value;
|
||||
return upgradableTaken.Value && CurrentThreadState.LockState.Has (LockState.Upgradable);
|
||||
}
|
||||
}
|
||||
|
||||
public int CurrentReadCount {
|
||||
get {
|
||||
return (rwlock >> RwReadBit) - (IsUpgradeableReadLockHeld ? 1 : 0);
|
||||
return (rwlock >> RwReadBit) - (upgradableTaken.Value ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
public int RecursiveReadCount {
|
||||
get {
|
||||
return IsReadLockHeld ? IsUpgradeableReadLockHeld ? 0 : 1 : 0;
|
||||
return CurrentThreadState.ReaderRecursiveCount;
|
||||
}
|
||||
}
|
||||
|
||||
public int RecursiveUpgradeCount {
|
||||
get {
|
||||
return IsUpgradeableReadLockHeld ? 1 : 0;
|
||||
return CurrentThreadState.UpgradeableRecursiveCount;
|
||||
}
|
||||
}
|
||||
|
||||
public int RecursiveWriteCount {
|
||||
get {
|
||||
return IsWriteLockHeld ? 1 : 0;
|
||||
return CurrentThreadState.WriterRecursiveCount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,28 +389,30 @@ namespace System.Threading {
|
||||
return recursionPolicy;
|
||||
}
|
||||
}
|
||||
|
||||
ThreadLockState CurrentThreadState {
|
||||
|
||||
LockState CurrentLockState {
|
||||
get {
|
||||
// TODO: provide a IEqualityComparer thingie to have better hashes
|
||||
if (currentThreadState == null)
|
||||
currentThreadState = new Dictionary<ReaderWriterLockSlim, ThreadLockState> ();
|
||||
|
||||
ThreadLockState state;
|
||||
if (!currentThreadState.TryGetValue (this, out state))
|
||||
currentThreadState[this] = state = ThreadLockState.None;
|
||||
|
||||
return state;
|
||||
return CurrentThreadState.LockState;
|
||||
}
|
||||
set {
|
||||
if (currentThreadState == null)
|
||||
currentThreadState = new Dictionary<ReaderWriterLockSlim, ThreadLockState> ();
|
||||
|
||||
currentThreadState[this] = value;
|
||||
CurrentThreadState.LockState = value;
|
||||
}
|
||||
}
|
||||
|
||||
bool CheckState (int millisecondsTimeout, ThreadLockState validState)
|
||||
ThreadLockState CurrentThreadState {
|
||||
get {
|
||||
if (currentThreadState == null)
|
||||
currentThreadState = new Dictionary<int, ThreadLockState> ();
|
||||
|
||||
ThreadLockState state;
|
||||
if (!currentThreadState.TryGetValue (id, out state))
|
||||
currentThreadState[id] = state = new ThreadLockState ();
|
||||
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
bool CheckState (int millisecondsTimeout, LockState validState)
|
||||
{
|
||||
if (disposed)
|
||||
throw new ObjectDisposedException ("ReaderWriterLockSlim");
|
||||
@@ -402,15 +421,15 @@ namespace System.Threading {
|
||||
throw new ArgumentOutOfRangeException ("millisecondsTimeout");
|
||||
|
||||
// Detect and prevent recursion
|
||||
ThreadLockState ctstate = CurrentThreadState;
|
||||
LockState ctstate = CurrentLockState;
|
||||
|
||||
if (recursionPolicy == LockRecursionPolicy.NoRecursion)
|
||||
if ((ctstate != ThreadLockState.None && ctstate != ThreadLockState.Upgradable)
|
||||
|| (ctstate == ThreadLockState.Upgradable && validState == ThreadLockState.Upgradable))
|
||||
if ((ctstate != LockState.None && ctstate != LockState.Upgradable)
|
||||
|| (ctstate == LockState.Upgradable && validState == LockState.Upgradable))
|
||||
throw new LockRecursionException ("The current thread has already a lock and recursion isn't supported");
|
||||
|
||||
// If we already had right lock state, just return
|
||||
if (ctstate == validState)
|
||||
if (ctstate.Has (validState))
|
||||
return true;
|
||||
|
||||
CheckRecursionAuthorization (ctstate, validState);
|
||||
@@ -418,10 +437,10 @@ namespace System.Threading {
|
||||
return false;
|
||||
}
|
||||
|
||||
static void CheckRecursionAuthorization (ThreadLockState ctstate, ThreadLockState desiredState)
|
||||
static void CheckRecursionAuthorization (LockState ctstate, LockState desiredState)
|
||||
{
|
||||
// In read mode you can just enter Read recursively
|
||||
if (ctstate == ThreadLockState.Read)
|
||||
if (ctstate == LockState.Read)
|
||||
throw new LockRecursionException ();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// ReaderWriterLockSlimExtensions.cs
|
||||
//
|
||||
// Author:
|
||||
// Jérémie "Garuma" Laval <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2010 Jérémie "Garuma" Laval
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace System.Threading
|
||||
{
|
||||
internal static class ReaderWriterLockSlimExtensions
|
||||
{
|
||||
internal static bool Has (this LockState state, LockState value)
|
||||
{
|
||||
return (state & value) > 0;
|
||||
}
|
||||
|
||||
#if !NET_4_0 && !NET_4_0_BOOTSTRAP
|
||||
internal static bool Wait (this ManualResetEvent self, int timeout)
|
||||
{
|
||||
return self.WaitOne (timeout);
|
||||
}
|
||||
|
||||
internal static bool IsSet (this ManualResetEvent self)
|
||||
{
|
||||
return self.WaitOne (0);
|
||||
}
|
||||
#else
|
||||
internal static bool IsSet (this ManualResetEventSlim self)
|
||||
{
|
||||
return self.IsSet;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// ThreadLockState.cs
|
||||
//
|
||||
// Author:
|
||||
// Jérémie "Garuma" Laval <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2010 Jérémie "Garuma" Laval
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace System.Threading
|
||||
{
|
||||
[Flags]
|
||||
internal enum LockState
|
||||
{
|
||||
None = 0,
|
||||
Read = 1,
|
||||
Write = 2,
|
||||
Upgradable = 4,
|
||||
UpgradedRead = Upgradable | Read,
|
||||
UpgradedWrite = Upgradable | Write
|
||||
}
|
||||
|
||||
internal class ThreadLockState
|
||||
{
|
||||
public LockState LockState;
|
||||
public int ReaderRecursiveCount;
|
||||
public int WriterRecursiveCount;
|
||||
public int UpgradeableRecursiveCount;
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ using System.Linq;
|
||||
namespace MonoTests.System.Threading
|
||||
{
|
||||
[TestFixture]
|
||||
public class ReaderWriterLockSlim2Test
|
||||
public class ReaderWriterLockSlimTests
|
||||
{
|
||||
[Test]
|
||||
public void DefaultValues ()
|
||||
@@ -452,6 +452,28 @@ namespace MonoTests.System.Threading
|
||||
Assert.IsTrue (v.TryEnterWriteLock (100), "#3");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RecursiveWritePlusReadLockTest ()
|
||||
{
|
||||
var v = new ReaderWriterLockSlim (LockRecursionPolicy.SupportsRecursion);
|
||||
|
||||
Assert.IsTrue (v.TryEnterWriteLock (100), "#1");
|
||||
Assert.AreEqual (1, v.RecursiveWriteCount, "1b");
|
||||
Assert.AreEqual (0, v.RecursiveReadCount, "1c");
|
||||
|
||||
Assert.IsTrue (v.TryEnterReadLock (100), "#2");
|
||||
Assert.AreEqual (1, v.RecursiveWriteCount, "2b");
|
||||
Assert.AreEqual (1, v.RecursiveReadCount, "2c");
|
||||
|
||||
Assert.IsTrue (v.TryEnterReadLock (100), "#3");
|
||||
Assert.AreEqual (1, v.RecursiveWriteCount, "3b");
|
||||
Assert.AreEqual (2, v.RecursiveReadCount, "3c");
|
||||
|
||||
v.ExitReadLock ();
|
||||
Assert.AreEqual (1, v.RecursiveWriteCount, "4b");
|
||||
Assert.AreEqual (1, v.RecursiveReadCount, "4c");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RecursiveUpgradeableReadLockTest ()
|
||||
{
|
||||
@@ -461,5 +483,172 @@ namespace MonoTests.System.Threading
|
||||
Assert.IsTrue (v.TryEnterUpgradeableReadLock (100), "#2");
|
||||
Assert.IsTrue (v.TryEnterUpgradeableReadLock (100), "#3");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RecursiveReadPropertiesTest ()
|
||||
{
|
||||
var v = new ReaderWriterLockSlim (LockRecursionPolicy.SupportsRecursion);
|
||||
|
||||
v.EnterReadLock ();
|
||||
v.EnterReadLock ();
|
||||
|
||||
Assert.AreEqual (true, v.IsReadLockHeld, "#1a");
|
||||
Assert.AreEqual (1, v.CurrentReadCount, "#2a");
|
||||
Assert.AreEqual (2, v.RecursiveReadCount, "#3a");
|
||||
|
||||
bool rLock = true;
|
||||
int cReadCount = -1, rReadCount = -1;
|
||||
|
||||
Thread t = new Thread ((_) => {
|
||||
rLock = v.IsReadLockHeld;
|
||||
cReadCount = v.CurrentReadCount;
|
||||
rReadCount = v.RecursiveReadCount;
|
||||
});
|
||||
|
||||
t.Start ();
|
||||
t.Join ();
|
||||
|
||||
Assert.AreEqual (false, rLock, "#1b");
|
||||
Assert.AreEqual (1, cReadCount, "#2b");
|
||||
Assert.AreEqual (0, rReadCount, "#3b");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RecursiveUpgradePropertiesTest ()
|
||||
{
|
||||
var v = new ReaderWriterLockSlim (LockRecursionPolicy.SupportsRecursion);
|
||||
|
||||
v.EnterUpgradeableReadLock ();
|
||||
v.EnterUpgradeableReadLock ();
|
||||
|
||||
Assert.AreEqual (true, v.IsUpgradeableReadLockHeld, "#1a");
|
||||
Assert.AreEqual (false, v.IsReadLockHeld, "#11a");
|
||||
Assert.AreEqual (0, v.CurrentReadCount, "#2a");
|
||||
Assert.AreEqual (2, v.RecursiveUpgradeCount, "#3a");
|
||||
|
||||
bool upLock = false, rLock = false;
|
||||
int rCount = -1, rUCount = -1;
|
||||
|
||||
Thread t = new Thread ((_) => {
|
||||
upLock = v.IsUpgradeableReadLockHeld;
|
||||
rLock = v.IsReadLockHeld;
|
||||
rCount = v.CurrentReadCount;
|
||||
rUCount = v.RecursiveUpgradeCount;
|
||||
});
|
||||
|
||||
t.Start ();
|
||||
t.Join ();
|
||||
|
||||
Assert.AreEqual (false, upLock, "#1b");
|
||||
Assert.AreEqual (false, rLock, "#11b");
|
||||
Assert.AreEqual (0, rCount, "#2b");
|
||||
Assert.AreEqual (0, rUCount, "#3b");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RecursiveWritePropertiesTest ()
|
||||
{
|
||||
var v = new ReaderWriterLockSlim (LockRecursionPolicy.SupportsRecursion);
|
||||
|
||||
v.EnterWriteLock ();
|
||||
v.EnterWriteLock ();
|
||||
|
||||
Assert.AreEqual (true, v.IsWriteLockHeld, "#1a");
|
||||
Assert.AreEqual (2, v.RecursiveWriteCount, "#3a");
|
||||
|
||||
bool wLock = false;
|
||||
int rWrite = -1;
|
||||
|
||||
Thread t = new Thread ((_) => {
|
||||
wLock = v.IsWriteLockHeld;
|
||||
rWrite = v.RecursiveWriteCount;
|
||||
});
|
||||
|
||||
t.Start ();
|
||||
t.Join ();
|
||||
|
||||
Assert.AreEqual (false, wLock, "#1b");
|
||||
Assert.AreEqual (0, rWrite, "#3b");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RecursiveEnterExitReadTest ()
|
||||
{
|
||||
var v = new ReaderWriterLockSlim (LockRecursionPolicy.SupportsRecursion);
|
||||
|
||||
v.EnterReadLock ();
|
||||
v.EnterReadLock ();
|
||||
v.EnterReadLock ();
|
||||
|
||||
Assert.IsTrue (v.IsReadLockHeld);
|
||||
Assert.AreEqual (3, v.RecursiveReadCount);
|
||||
|
||||
v.ExitReadLock ();
|
||||
|
||||
Assert.IsTrue (v.IsReadLockHeld);
|
||||
Assert.AreEqual (2, v.RecursiveReadCount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RecursiveEnterExitWriteTest ()
|
||||
{
|
||||
var v = new ReaderWriterLockSlim (LockRecursionPolicy.SupportsRecursion);
|
||||
|
||||
v.EnterWriteLock ();
|
||||
v.EnterWriteLock ();
|
||||
v.EnterWriteLock ();
|
||||
|
||||
Assert.IsTrue (v.IsWriteLockHeld);
|
||||
Assert.AreEqual (3, v.RecursiveWriteCount);
|
||||
|
||||
v.ExitWriteLock ();
|
||||
v.ExitWriteLock ();
|
||||
|
||||
Assert.IsTrue (v.IsWriteLockHeld);
|
||||
Assert.AreEqual (1, v.RecursiveWriteCount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RecursiveEnterExitUpgradableTest ()
|
||||
{
|
||||
var v = new ReaderWriterLockSlim (LockRecursionPolicy.SupportsRecursion);
|
||||
|
||||
v.EnterUpgradeableReadLock ();
|
||||
v.EnterUpgradeableReadLock ();
|
||||
v.EnterUpgradeableReadLock ();
|
||||
|
||||
Assert.IsTrue (v.IsUpgradeableReadLockHeld);
|
||||
Assert.AreEqual (3, v.RecursiveUpgradeCount);
|
||||
|
||||
v.ExitUpgradeableReadLock ();
|
||||
|
||||
Assert.IsTrue (v.IsUpgradeableReadLockHeld);
|
||||
Assert.AreEqual (2, v.RecursiveUpgradeCount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RecursiveWriteReadAcquisitionInterleaving ()
|
||||
{
|
||||
var v = new ReaderWriterLockSlim (LockRecursionPolicy.SupportsRecursion);
|
||||
|
||||
v.EnterWriteLock ();
|
||||
Assert.IsTrue (v.IsWriteLockHeld, "#1");
|
||||
|
||||
bool result = true;
|
||||
var t = new Thread (delegate () {
|
||||
result = v.TryEnterReadLock (100);
|
||||
});
|
||||
t.Start ();
|
||||
t.Join ();
|
||||
Assert.IsFalse (result, "#2");
|
||||
|
||||
v.ExitWriteLock ();
|
||||
t = new Thread (delegate () {
|
||||
result = v.TryEnterReadLock (100);
|
||||
});
|
||||
t.Start ();
|
||||
t.Join ();
|
||||
Assert.IsTrue (result, "#3");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,6 +66,9 @@ System.Security.Cryptography/SHA512CryptoServiceProvider.cs
|
||||
System.Threading/LockRecursionException.cs
|
||||
System.Threading/LockRecursionPolicy.cs
|
||||
System.Threading/ReaderWriterLockSlim.cs
|
||||
System.Threading/ThreadLockState.cs
|
||||
System.Threading/ReaderWriterLockSlimExtensions.cs
|
||||
System.Threading.Tasks/TaskExtensions.cs
|
||||
|
||||
System.Linq.Expressions/Extensions.cs
|
||||
System.Linq.Expressions/ExpressionTransformer.cs
|
||||
@@ -254,7 +257,6 @@ System.Linq.Parallel/IVisitableNode.cs
|
||||
System.Linq.Parallel/QueryCheckerVisitor.cs
|
||||
System.Linq.Parallel/QueryIsOrderedVisitor.cs
|
||||
System.Linq.Parallel/QueryOptions.cs
|
||||
../corlib/System.Collections.Concurrent/Partitioners/EnumerablePartitioner.cs
|
||||
../corlib/System.Collections.Concurrent.Partitioners/EnumerablePartitioner.cs
|
||||
../corlib/System.Collections.Concurrent/ConcurrentSkipList.cs
|
||||
../corlib/System.Threading/AtomicBoolean.cs
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
2010-12-07 Veerapuram Varadhan <[email protected]>
|
||||
|
||||
** Fixes #456234 - Patch by [email protected]
|
||||
* OdbcDataReader.cs (GetValue): Handle SQL_NO_TOTAL sanely and
|
||||
use corresponding Decoder.GetChars instead of Encoding.GetString.
|
||||
|
||||
2010-06-15 Jonathan Chambers <[email protected]>
|
||||
|
||||
* OdbcDataReader.cs: Remove unneeded cast on ref parameter
|
||||
|
||||
@@ -732,6 +732,8 @@ namespace System.Data.Odbc
|
||||
bufsize = (col.MaxLength < 127 ? (col.MaxLength*2+1) : 255);
|
||||
buffer = new byte[bufsize]; // According to sqlext.h, use SQL_CHAR for both char and varchar
|
||||
StringBuilder sb = new StringBuilder ();
|
||||
char[] charBuffer = new char[bufsize];
|
||||
Decoder unicodeDecoder = Encoding.Unicode.GetDecoder ();
|
||||
do {
|
||||
ret = libodbc.SQLGetData (hstmt, ColIndex, col.SqlCType, buffer, bufsize, ref outsize);
|
||||
if (ret == OdbcReturn.Error)
|
||||
@@ -740,24 +742,24 @@ namespace System.Data.Odbc
|
||||
if (ret == OdbcReturn.Success && outsize==-1)
|
||||
ret = OdbcReturn.NoData;
|
||||
|
||||
if (ret != OdbcReturn.NoData && outsize > 0) {
|
||||
string value = null;
|
||||
|
||||
if (outsize < bufsize)
|
||||
value = Encoding.Unicode.GetString (buffer, 0, outsize);
|
||||
else
|
||||
value = Encoding.Unicode.GetString (buffer, 0, bufsize);
|
||||
|
||||
sb.Append (RemoveTrailingNullChar (value));
|
||||
if (ret == OdbcReturn.Success || ret == OdbcReturn.SuccessWithInfo) {
|
||||
if (outsize >= bufsize || outsize == (int)OdbcLengthIndicator.NoTotal)
|
||||
outsize = bufsize;
|
||||
int charCount = unicodeDecoder.GetChars (buffer, 0, outsize, charBuffer, 0);
|
||||
string strValue = new String (charBuffer, 0, charCount);
|
||||
sb.Append (RemoveTrailingNullChar (strValue));
|
||||
}
|
||||
} while (ret != OdbcReturn.NoData);
|
||||
DataValue = sb.ToString ();
|
||||
charBuffer = null;
|
||||
break;
|
||||
case OdbcType.Text:
|
||||
case OdbcType.VarChar:
|
||||
bufsize = (col.MaxLength < 255 ? (col.MaxLength+1) : 255);
|
||||
buffer = new byte[bufsize]; // According to sqlext.h, use SQL_CHAR for both char and varchar
|
||||
StringBuilder sb1 = new StringBuilder ();
|
||||
charBuffer = new char[bufsize];
|
||||
Decoder defaultDecoder = Encoding.Default.GetDecoder();
|
||||
do {
|
||||
ret = libodbc.SQLGetData (hstmt, ColIndex, col.SqlCType, buffer, bufsize, ref outsize);
|
||||
if (ret == OdbcReturn.Error)
|
||||
@@ -765,11 +767,11 @@ namespace System.Data.Odbc
|
||||
// Fix for strance ODBC drivers (like psqlODBC)
|
||||
if (ret == OdbcReturn.Success && outsize==-1)
|
||||
ret = OdbcReturn.NoData;
|
||||
if (ret != OdbcReturn.NoData && outsize > 0) {
|
||||
if (outsize < bufsize)
|
||||
sb1.Append (Encoding.Default.GetString (buffer, 0, outsize));
|
||||
else
|
||||
sb1.Append (Encoding.Default.GetString (buffer, 0, bufsize - 1));
|
||||
if (ret == OdbcReturn.Success || ret == OdbcReturn.SuccessWithInfo) {
|
||||
if (outsize >= bufsize || outsize == (int)OdbcLengthIndicator.NoTotal)
|
||||
outsize = bufsize - 1;
|
||||
int charCount = defaultDecoder.GetChars(buffer, 0, outsize, charBuffer, 0);
|
||||
sb1.Append(charBuffer, 0, charCount);
|
||||
}
|
||||
} while (ret != OdbcReturn.NoData);
|
||||
DataValue = sb1.ToString ();
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
2010-12-13 Veerapuram Varadhan <[email protected]>
|
||||
|
||||
** Fixes #582732
|
||||
* DataColumn.cs (Clone): Deep copy the ExtendedProperties collection.
|
||||
* XmlSchemaDataImporter.cs: Support import of extended properties.
|
||||
* XmlSchemaWriter.cs: Fix exception by writing the extended properties
|
||||
before simpletype element.
|
||||
|
||||
2010-07-23 Veerapuram Varadhan <[email protected]>
|
||||
|
||||
** Fixes #623451
|
||||
|
||||
@@ -704,6 +704,13 @@ namespace System.Data {
|
||||
// Use the property to set the expression as it updates compiledExpression, if any.
|
||||
copy.Expression = _expression;
|
||||
//Copy.ExtendedProperties
|
||||
if (_extendedProperties.Count > 0) {
|
||||
Array extPropArray = Array.CreateInstance (typeof (object), _extendedProperties.Count);
|
||||
_extendedProperties.CopyTo (extPropArray, 0);
|
||||
for (var i = 0; i < _extendedProperties.Count; i++)
|
||||
copy.ExtendedProperties.Add (extPropArray.GetValue(i),
|
||||
ExtendedProperties[extPropArray.GetValue(i)]);
|
||||
}
|
||||
copy._maxLength = _maxLength;
|
||||
copy._nameSpace = _nameSpace;
|
||||
copy._prefix = _prefix;
|
||||
@@ -715,7 +722,6 @@ namespace System.Data {
|
||||
if (DataType == typeof (DateTime))
|
||||
copy.DateTimeMode = _datetimeMode;
|
||||
#endif
|
||||
copy._extendedProperties = _extendedProperties;
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
@@ -535,6 +535,13 @@ namespace System.Data
|
||||
attr.NamespaceURI == XmlConstants.MsdataNamespace)
|
||||
useCurrent = true;
|
||||
#endif
|
||||
|
||||
if (attr.NamespaceURI == XmlConstants.MspropNamespace &&
|
||||
!dataset.ExtendedProperties.ContainsKey(attr.Name)) {
|
||||
dataset.ExtendedProperties.Add (attr.Name, attr.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (attr.LocalName == "Locale" &&
|
||||
attr.NamespaceURI == XmlConstants.MsdataNamespace) {
|
||||
CultureInfo ci = new CultureInfo (attr.Value);
|
||||
@@ -593,6 +600,12 @@ namespace System.Data
|
||||
// Find Locale
|
||||
if (el.UnhandledAttributes != null) {
|
||||
foreach (XmlAttribute attr in el.UnhandledAttributes) {
|
||||
|
||||
if (attr.NamespaceURI == XmlConstants.MspropNamespace) {
|
||||
table.ExtendedProperties.Add (attr.Name, attr.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (attr.LocalName == "Locale" &&
|
||||
attr.NamespaceURI == XmlConstants.MsdataNamespace)
|
||||
table.Locale = new CultureInfo (attr.Value);
|
||||
@@ -783,6 +796,11 @@ namespace System.Data
|
||||
{
|
||||
if (obj.UnhandledAttributes != null) {
|
||||
foreach (XmlAttribute attr in obj.UnhandledAttributes) {
|
||||
if (attr.NamespaceURI == XmlConstants.MspropNamespace) {
|
||||
col.ExtendedProperties.Add (attr.Name, attr.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (attr.NamespaceURI != XmlConstants.MsdataNamespace)
|
||||
continue;
|
||||
switch (attr.LocalName) {
|
||||
|
||||
@@ -734,12 +734,12 @@ namespace System.Data
|
||||
// XmlConstants.MsdataNamespace,
|
||||
// col.Ordinal.ToString ());
|
||||
|
||||
AddExtendedPropertyAttributes (col.ExtendedProperties);
|
||||
|
||||
// Write SimpleType if column have MaxLength
|
||||
if (col.MaxLength > -1)
|
||||
WriteSimpleType (col);
|
||||
|
||||
AddExtendedPropertyAttributes (col.ExtendedProperties);
|
||||
|
||||
w.WriteEndElement (); // sequence
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ System.Drawing/BufferedGraphics.cs
|
||||
System.Drawing/BufferedGraphicsManager.cs
|
||||
System.Drawing/BufferedGraphicsContext.cs
|
||||
System.Drawing/CharacterRange.cs
|
||||
System.Drawing/carbonFunctions.cs
|
||||
System.Drawing/macFunctions.cs
|
||||
System.Drawing/ColorConverter.cs
|
||||
System.Drawing/Color.cs
|
||||
System.Drawing/ColorTranslator.cs
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace System.Drawing
|
||||
#endif
|
||||
{
|
||||
internal IntPtr nativeObject = IntPtr.Zero;
|
||||
internal CarbonContext context;
|
||||
internal IMacContext maccontext;
|
||||
private bool disposed = false;
|
||||
private static float defDpiX = 0;
|
||||
private static float defDpiY = 0;
|
||||
@@ -190,6 +190,8 @@ namespace System.Drawing
|
||||
CopyFromScreenX11 (sourceX, sourceY, destinationX, destinationY, blockRegionSize, copyPixelOperation);
|
||||
} else if (GDIPlus.UseCarbonDrawable) {
|
||||
CopyFromScreenMac (sourceX, sourceY, destinationX, destinationY, blockRegionSize, copyPixelOperation);
|
||||
} else if (GDIPlus.UseCocoaDrawable) {
|
||||
CopyFromScreenMac (sourceX, sourceY, destinationX, destinationY, blockRegionSize, copyPixelOperation);
|
||||
} else {
|
||||
CopyFromScreenWin32 (sourceX, sourceY, destinationX, destinationY, blockRegionSize, copyPixelOperation);
|
||||
}
|
||||
@@ -293,11 +295,12 @@ namespace System.Drawing
|
||||
{
|
||||
Status status;
|
||||
if (! disposed) {
|
||||
if (GDIPlus.UseCarbonDrawable && context.ctx != IntPtr.Zero) {
|
||||
if (GDIPlus.UseCarbonDrawable || GDIPlus.UseCocoaDrawable) {
|
||||
Flush ();
|
||||
Carbon.CGContextSynchronize (context.ctx);
|
||||
Carbon.ReleaseContext (context.port, context.ctx);
|
||||
if (maccontext != null)
|
||||
maccontext.Release ();
|
||||
}
|
||||
|
||||
status = GDIPlus.GdipDeleteGraphics (nativeObject);
|
||||
nativeObject = IntPtr.Zero;
|
||||
GDIPlus.CheckStatus (status);
|
||||
@@ -1681,8 +1684,9 @@ namespace System.Drawing
|
||||
|
||||
Status status = GDIPlus.GdipFlush (nativeObject, intention);
|
||||
GDIPlus.CheckStatus (status);
|
||||
if (GDIPlus.UseCarbonDrawable && context.ctx != IntPtr.Zero)
|
||||
Carbon.CGContextSynchronize (context.ctx);
|
||||
|
||||
if (maccontext != null)
|
||||
maccontext.Synchronize ();
|
||||
}
|
||||
|
||||
[EditorBrowsable (EditorBrowsableState.Advanced)]
|
||||
@@ -1714,12 +1718,22 @@ namespace System.Drawing
|
||||
{
|
||||
IntPtr graphics;
|
||||
|
||||
if (GDIPlus.UseCocoaDrawable) {
|
||||
CocoaContext context = MacSupport.GetCGContextForNSView (hwnd);
|
||||
GDIPlus.GdipCreateFromContext_macosx (context.ctx, context.width, context.height, out graphics);
|
||||
|
||||
Graphics g = new Graphics (graphics);
|
||||
g.maccontext = context;
|
||||
|
||||
return g;
|
||||
}
|
||||
|
||||
if (GDIPlus.UseCarbonDrawable) {
|
||||
CarbonContext context = Carbon.GetCGContextForView (hwnd);
|
||||
CarbonContext context = MacSupport.GetCGContextForView (hwnd);
|
||||
GDIPlus.GdipCreateFromContext_macosx (context.ctx, context.width, context.height, out graphics);
|
||||
|
||||
Graphics g = new Graphics (graphics);
|
||||
g.context = context;
|
||||
g.maccontext = context;
|
||||
|
||||
return g;
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ namespace System.Drawing
|
||||
public static IntPtr Display = IntPtr.Zero;
|
||||
public static bool UseX11Drawable = false;
|
||||
public static bool UseCarbonDrawable = false;
|
||||
public static bool UseCocoaDrawable = false;
|
||||
|
||||
#region gdiplus.dll functions
|
||||
|
||||
@@ -138,12 +139,12 @@ namespace System.Drawing
|
||||
|
||||
static public bool RunningOnWindows ()
|
||||
{
|
||||
return !UseX11Drawable && !UseCarbonDrawable;
|
||||
return !UseX11Drawable && !UseCarbonDrawable && !UseCocoaDrawable;
|
||||
}
|
||||
|
||||
static public bool RunningOnUnix ()
|
||||
{
|
||||
return UseX11Drawable || UseCarbonDrawable;
|
||||
return UseX11Drawable || UseCarbonDrawable || UseCocoaDrawable;
|
||||
}
|
||||
|
||||
// Copies a Ptr to an array of Points and releases the memory
|
||||
|
||||
+53
-4
@@ -36,9 +36,9 @@ namespace System.Drawing {
|
||||
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
#if NET_2_0
|
||||
internal static class Carbon {
|
||||
internal static class MacSupport {
|
||||
#else
|
||||
internal sealed class Carbon {
|
||||
internal sealed class MacSupport {
|
||||
#endif
|
||||
internal static Hashtable contextReference = new Hashtable ();
|
||||
internal static object lockobj = new object ();
|
||||
@@ -52,7 +52,7 @@ namespace System.Drawing {
|
||||
internal static int debug_threshold = 1;
|
||||
#endif
|
||||
|
||||
static Carbon () {
|
||||
static MacSupport () {
|
||||
foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies ()) {
|
||||
if (String.Equals (asm.GetName ().Name, "System.Windows.Forms")) {
|
||||
Type driver_type = asm.GetType ("System.Windows.Forms.XplatUICarbon");
|
||||
@@ -63,6 +63,16 @@ namespace System.Drawing {
|
||||
}
|
||||
}
|
||||
|
||||
internal static CocoaContext GetCGContextForNSView (IntPtr handle) {
|
||||
IntPtr graphicsContext = objc_msgSend (objc_getClass ("NSGraphicsContext"), sel_registerName ("currentContext"));
|
||||
IntPtr ctx = objc_msgSend (graphicsContext, sel_registerName ("graphicsPort"));
|
||||
Rect bounds = new Rect ();
|
||||
|
||||
objc_msgSend_stret (ref bounds, handle, sel_registerName ("bounds"));
|
||||
|
||||
return new CocoaContext (ctx, (int) bounds.size.width, (int) bounds.size.height);
|
||||
}
|
||||
|
||||
internal static CarbonContext GetCGContextForView (IntPtr handle) {
|
||||
IntPtr context = IntPtr.Zero;
|
||||
IntPtr port = IntPtr.Zero;
|
||||
@@ -289,7 +299,7 @@ namespace System.Drawing {
|
||||
public short right;
|
||||
}
|
||||
|
||||
internal struct CarbonContext
|
||||
internal struct CarbonContext : IMacContext
|
||||
{
|
||||
public IntPtr port;
|
||||
public IntPtr ctx;
|
||||
@@ -303,5 +313,44 @@ namespace System.Drawing {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public void Synchronize ()
|
||||
{
|
||||
MacSupport.CGContextSynchronize (ctx);
|
||||
}
|
||||
|
||||
public void Release ()
|
||||
{
|
||||
MacSupport.ReleaseContext (port, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
internal struct CocoaContext : IMacContext
|
||||
{
|
||||
public IntPtr ctx;
|
||||
public int width;
|
||||
public int height;
|
||||
|
||||
public CocoaContext (IntPtr ctx, int width, int height)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public void Synchronize ()
|
||||
{
|
||||
MacSupport.CGContextSynchronize (ctx);
|
||||
}
|
||||
|
||||
public void Release ()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
internal interface IMacContext
|
||||
{
|
||||
void Synchronize ();
|
||||
void Release ();
|
||||
}
|
||||
}
|
||||
@@ -66,8 +66,6 @@ namespace System.Json
|
||||
{
|
||||
if (key == null)
|
||||
throw new ArgumentNullException ("key");
|
||||
if (value == null)
|
||||
throw new ArgumentNullException ("value");
|
||||
|
||||
map.Add (key, value);
|
||||
}
|
||||
@@ -143,7 +141,13 @@ namespace System.Json
|
||||
stream.WriteByte ((byte) '"');
|
||||
stream.WriteByte ((byte) ',');
|
||||
stream.WriteByte ((byte) ' ');
|
||||
pair.Value.Save (stream);
|
||||
if (pair.Value == null) {
|
||||
stream.WriteByte ((byte) 'n');
|
||||
stream.WriteByte ((byte) 'u');
|
||||
stream.WriteByte ((byte) 'l');
|
||||
stream.WriteByte ((byte) 'l');
|
||||
} else
|
||||
pair.Value.Save (stream);
|
||||
}
|
||||
stream.WriteByte ((byte) '}');
|
||||
}
|
||||
|
||||
@@ -148,7 +148,10 @@ namespace System.Json
|
||||
w.Write ('\"');
|
||||
w.Write (EscapeString (pair.Key));
|
||||
w.Write ("\": ");
|
||||
pair.Value.SaveInternal (w);
|
||||
if (pair.Value == null)
|
||||
w.Write ("null");
|
||||
else
|
||||
pair.Value.SaveInternal (w);
|
||||
following = true;
|
||||
}
|
||||
w.Write ('}');
|
||||
|
||||
@@ -304,11 +304,7 @@ namespace MonoTests.System.Runtime.Caching
|
||||
// It's probably caused by the code passing a DateTime.MinValue to DateTimeOffset constructor for non-existing entries.
|
||||
// Until this (apparent) bug is fixed, Mono is going to implement the buggy behavior.
|
||||
//
|
||||
#if true
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException> (() => {
|
||||
monitor = mc.CreateCacheEntryChangeMonitor (new string [] { "key1", "doesnotexist" });
|
||||
}, "#A3");
|
||||
#else
|
||||
#if false
|
||||
monitor = mc.CreateCacheEntryChangeMonitor (new string [] { "key1", "doesnotexist" });
|
||||
Assert.IsNotNull (monitor, "#A3-1");
|
||||
Assert.AreEqual ("System.Runtime.Caching.MemoryCacheEntryChangeMonitor", monitor.GetType ().ToString (), "#A3-2");
|
||||
|
||||
Loaded 100 of 377 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user