mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-17 11:21:39 -10:00
Compare commits
283
Commits
2.10
...
mono-android-1-0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6623fc543d | ||
|
|
1e38c9d065 | ||
|
|
30719eac23 | ||
|
|
be791133e9 | ||
|
|
ba41a4afc3 | ||
|
|
7001015c8a | ||
|
|
cb86a2cae2 | ||
|
|
2023fd51cf | ||
|
|
ee0c82f938 | ||
|
|
f66c15fa4c | ||
|
|
870a168078 | ||
|
|
f1e5ff5830 | ||
|
|
ec56b2399e | ||
|
|
98567347b0 | ||
|
|
d1ef9e9bc0 | ||
|
|
1d15cb6eab | ||
|
|
2f6c884c39 | ||
|
|
3007742461 | ||
|
|
dd02160e29 | ||
|
|
04ceb5cec2 | ||
|
|
4c251cb528 | ||
|
|
f29c6b4014 | ||
|
|
5d3bd4296d | ||
|
|
7b4e9fe3b3 | ||
|
|
e127fbdbc8 | ||
|
|
da38ea1a3c | ||
|
|
80b18e5e78 | ||
|
|
b08fcbf349 | ||
|
|
4448207b46 | ||
|
|
c183437b77 | ||
|
|
0bc62c64f2 | ||
|
|
f9f20656d9 | ||
|
|
1cf96c874c | ||
|
|
2e938cedc3 | ||
|
|
8aae8a860c | ||
|
|
72c9964603 | ||
|
|
045c255762 | ||
|
|
441e34087e | ||
|
|
b754115f2b | ||
|
|
94398a1154 | ||
|
|
cf3968f176 | ||
|
|
6101dfa1e7 | ||
|
|
2bb69090d7 | ||
|
|
32c89f8e51 | ||
|
|
733baa249e | ||
|
|
1fc9d8bd0b | ||
|
|
c596b87264 | ||
|
|
51ede8ef25 | ||
|
|
92d8d69c21 | ||
|
|
7ccc860767 | ||
|
|
a19eee8543 | ||
|
|
f00f059724 | ||
|
|
db74186f65 | ||
|
|
d6b8f09a9b | ||
|
|
be077e583a | ||
|
|
0a8951258f | ||
|
|
adaeb6075b | ||
|
|
be796b9980 | ||
|
|
6c25b86257 | ||
|
|
1d602e9364 | ||
|
|
a8985dc3ec | ||
|
|
1756d9ea31 | ||
|
|
63e2c4a403 | ||
|
|
35c7e0b062 | ||
|
|
e49c454e06 | ||
|
|
1b676d2766 | ||
|
|
a0e8d07f2b | ||
|
|
9aee6ad25d | ||
|
|
f00c5a545b | ||
|
|
7d67acee8b | ||
|
|
30cf8768c4 | ||
|
|
64c827f318 | ||
|
|
f13dcb35bf | ||
|
|
85f294ee2f | ||
|
|
0e091a62fa | ||
|
|
42e4086945 | ||
|
|
7590b8bb30 | ||
|
|
455746a0ce | ||
|
|
371bc51b1c | ||
|
|
badc22bbae | ||
|
|
2d7a5669d2 | ||
|
|
89209acd58 | ||
|
|
9a4bd9308e | ||
|
|
3527ec8621 | ||
|
|
e812234121 | ||
|
|
b8397a6eeb | ||
|
|
be0b6c8933 | ||
|
|
cbd4fef05a | ||
|
|
4f2774fa80 | ||
|
|
cf967de406 | ||
|
|
5167cc3dae | ||
|
|
12ce3d1370 | ||
|
|
fa5e96cdf7 | ||
|
|
18eb35983b | ||
|
|
b80343fd5b | ||
|
|
34f18b6876 | ||
|
|
c690aa95bc | ||
|
|
9f33f58799 | ||
|
|
e30eeacd70 | ||
|
|
3e9fccb813 | ||
|
|
e25503422b | ||
|
|
69e64f8d72 | ||
|
|
1585b98d92 | ||
|
|
c60c84c55d | ||
|
|
1eae886946 | ||
|
|
4b7ca990ad | ||
|
|
aabd50d5ad | ||
|
|
f56f2a679c | ||
|
|
e3ec5dcffb | ||
|
|
b428261ea6 | ||
|
|
7711cbf01a | ||
|
|
ce550ab14b | ||
|
|
6d67acf0d0 | ||
|
|
82f415e01a | ||
|
|
4b9f33b4d5 | ||
|
|
bf997c57b6 | ||
|
|
4395aab675 | ||
|
|
aad5ac41fa | ||
|
|
9a743feb99 | ||
|
|
353b636e4a | ||
|
|
50f46f1fac | ||
|
|
6e597dfd63 | ||
|
|
1a357d9f4e | ||
|
|
12692327a1 | ||
|
|
e166179eb8 | ||
|
|
294900133a | ||
|
|
df939989d8 | ||
|
|
a1c49cd4e9 | ||
|
|
b374152512 | ||
|
|
bbc79f7b41 | ||
|
|
841b593bd9 | ||
|
|
49805cb00d | ||
|
|
0256398770 | ||
|
|
38855bc712 | ||
|
|
017b4ed819 | ||
|
|
d47c02350c | ||
|
|
4b4f74955d | ||
|
|
211be59492 | ||
|
|
55a91737da | ||
|
|
568b8cf74d | ||
|
|
bee257b69b | ||
|
|
36353034c9 | ||
|
|
b4b3b7b978 | ||
|
|
550ca25837 | ||
|
|
5cb757c95b | ||
|
|
c6fb9f9494 | ||
|
|
1c664cbb1e | ||
|
|
dcc8112e68 | ||
|
|
7f8aafbe7d | ||
|
|
837bf42ce7 | ||
|
|
084a76ecea | ||
|
|
3da978e41b | ||
|
|
e8c3443bd3 | ||
|
|
14b494ed61 | ||
|
|
ef214d3a25 | ||
|
|
5038f10bb6 | ||
|
|
fd2b90b73b | ||
|
|
7225ae8eed | ||
|
|
4f8349919a | ||
|
|
0214f7431a | ||
|
|
dbdcec54b4 | ||
|
|
87cc02a04a | ||
|
|
f5bba434cd | ||
|
|
7048e3f49e | ||
|
|
ac1ad54ded | ||
|
|
a1953b3f77 | ||
|
|
b100e0eed6 | ||
|
|
24e787e9ff | ||
|
|
916943ce1a | ||
|
|
93a4e248be | ||
|
|
8494641805 | ||
|
|
82b37d914c | ||
|
|
8c579dfce2 | ||
|
|
95af93f266 | ||
|
|
41b1fe814e | ||
|
|
ac1e8e16a2 | ||
|
|
e8a578407b | ||
|
|
450b0f1c4a | ||
|
|
d2b840c9fc | ||
|
|
ad9ddef21a | ||
|
|
5c1fe2fedb | ||
|
|
268adea870 | ||
|
|
70910f3f04 | ||
|
|
02f2d4dbf7 | ||
|
|
dcec5908af | ||
|
|
85e594b968 | ||
|
|
c08e02bc59 | ||
|
|
a92669fc05 | ||
|
|
0cce6b2bf5 | ||
|
|
9f29e21ade | ||
|
|
93dd831a8b | ||
|
|
b860a9145c | ||
|
|
c69896b97b | ||
|
|
094614ba92 | ||
|
|
2bbbccf106 | ||
|
|
37589e862a | ||
|
|
80890aa751 | ||
|
|
05745bacdf | ||
|
|
26bbac8c8a | ||
|
|
b60927f21f | ||
|
|
a77fdbe8b5 | ||
|
|
81f2bb71ed | ||
|
|
3d1b4715eb | ||
|
|
df12cf48c6 | ||
|
|
4e37530b60 | ||
|
|
95513a6be4 | ||
|
|
8415e77fbe | ||
|
|
3e593ba735 | ||
|
|
ddd9443f26 | ||
|
|
d0c67f7e87 | ||
|
|
b2e391a309 | ||
|
|
3d4f602354 | ||
|
|
2b62b097df | ||
|
|
b816837188 | ||
|
|
c084efc79e | ||
|
|
07791b1406 | ||
|
|
9ba41cadd2 | ||
|
|
ca02c72ecb | ||
|
|
f5b2849d72 | ||
|
|
8c4808fc36 | ||
|
|
ed23f897c4 | ||
|
|
b636b093d2 | ||
|
|
e433c33f9f | ||
|
|
21528f97be | ||
|
|
a7c3c38901 | ||
|
|
5766da53da | ||
|
|
3e6f82d10c | ||
|
|
01e4a9bb55 | ||
|
|
e09f898428 | ||
|
|
1d3ed22ab2 | ||
|
|
abdc66ca35 | ||
|
|
affd549250 | ||
|
|
a98ce10d71 | ||
|
|
432ed84634 | ||
|
|
b2eaffda65 | ||
|
|
78a1ca7417 | ||
|
|
7372ca74ef | ||
|
|
97bc578e86 | ||
|
|
adc1bd510c | ||
|
|
5ef11410bd | ||
|
|
843a59e2ab | ||
|
|
9bd2159a5f | ||
|
|
0b63e96ade | ||
|
|
17a13200f8 | ||
|
|
b48e7b5988 | ||
|
|
ba4c090467 | ||
|
|
b9b1ae5876 | ||
|
|
223d09ec41 | ||
|
|
e72dcebf98 | ||
|
|
980810dc82 | ||
|
|
6d7b16c0d2 | ||
|
|
d8d5da5c30 | ||
|
|
931c55c115 | ||
|
|
dcd3787a52 | ||
|
|
995d298d00 | ||
|
|
582c628f21 | ||
|
|
10e94f0efa | ||
|
|
f45ca2b65e | ||
|
|
c9231c0248 | ||
|
|
b5491e25d9 | ||
|
|
ea0673de2b | ||
|
|
f8d7872cc4 | ||
|
|
ead615dca5 | ||
|
|
4ed4702907 | ||
|
|
be750c099d | ||
|
|
4b82e7b3b2 | ||
|
|
1e17218a2d | ||
|
|
423f895412 | ||
|
|
d6070f1383 | ||
|
|
f1e818a76f | ||
|
|
a28a9520b5 | ||
|
|
6907827b05 | ||
|
|
6ea68b9128 | ||
|
|
7c37c423e1 | ||
|
|
8854623440 | ||
|
|
7b088dc2a4 | ||
|
|
e19f4be52c | ||
|
|
20b58344cc | ||
|
|
c310cd6556 | ||
|
|
fc074bb4fa | ||
|
|
a7bfba4549 | ||
|
|
a65b6c7523 | ||
|
|
7730c00a02 |
No files matched your search
+12
-2
@@ -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.10)
|
||||
AM_INIT_AUTOMAKE(mono,2.10.1)
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
API_VER=2.0
|
||||
@@ -2262,7 +2262,7 @@ case "$host" in
|
||||
arch_target=arm;
|
||||
ACCESS_UNALIGNED="no"
|
||||
JIT_SUPPORTED=yes
|
||||
CPPFLAGS="$CPPFLAGS -DARM_FPU_NONE=1"
|
||||
CPPFLAGS="$CPPFLAGS -DARM_FPU_VFP=1 -D__ARM_EABI__ -DHAVE_ARMV6=1"
|
||||
jit_wanted=true
|
||||
sgen_supported=true
|
||||
;;
|
||||
@@ -2561,6 +2561,16 @@ if test ${TARGET} = ARM && test x$cross_compiling = xno && test x$enable_mcs_bui
|
||||
AC_MSG_RESULT($fpu)
|
||||
CPPFLAGS="$CPPFLAGS -DARM_FPU_$fpu=1"
|
||||
unset fpu
|
||||
|
||||
AC_MSG_CHECKING(for ARMV6)
|
||||
AC_TRY_RUN([
|
||||
int main () { __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r" (0) : "memory"); return 0; }
|
||||
], armv6=yes, armv6=no)
|
||||
|
||||
AC_MSG_RESULT($armv6)
|
||||
if test ${armv6} = yes; then
|
||||
AC_DEFINE(HAVE_ARMV6, 1, "Host supports ARMV6 instructions")
|
||||
fi
|
||||
fi
|
||||
|
||||
if test ${TARGET} = unknown; then
|
||||
|
||||
@@ -3,3 +3,5 @@
|
||||
/config
|
||||
/.cvsignore
|
||||
/*.pc
|
||||
/gdb/mono-sgen-gdb.py
|
||||
/mono-sgen-gdb.py
|
||||
+6
-2
@@ -38,11 +38,15 @@ pkgconfig_DATA= mint.pc mono-nunit.pc mono-cairo.pc mono-options.pc cecil.pc mon
|
||||
endif
|
||||
|
||||
DISTCLEANFILES= mono-2.pc mono.pc mint.pc dotnet.pc dotnet35.pc wcf.pc mono-nunit.pc mono-cairo.pc mono-options.pc cecil.pc monodoc.pc mono-lineeditor.pc system.web.extensions_1.0.pc \
|
||||
system.web.extensions.design_1.0.pc mono.web.pc system.web.mvc.pc system.web.mvc2.pc $(SGENPCFILE)
|
||||
system.web.extensions.design_1.0.pc mono.web.pc system.web.mvc.pc system.web.mvc2.pc $(SGENPCFILE) mono-sgen-gdb.py
|
||||
|
||||
mono_DATA = config \
|
||||
browscap.ini
|
||||
|
||||
gdbdir = $(bindir)
|
||||
|
||||
gdb_DATA = gdb/mono-gdb.py
|
||||
mono-sgen-gdb.py: gdb/mono-gdb.py
|
||||
cp $< $@
|
||||
|
||||
gdb_DATA = gdb/mono-gdb.py mono-sgen-gdb.py
|
||||
|
||||
+27
-10
@@ -46,17 +46,20 @@ case $host in
|
||||
PATHSEP='\\'
|
||||
SEARCHSEP=';'
|
||||
OS="WIN32"
|
||||
PIDTYPE='void *'
|
||||
;;
|
||||
*-*darwin*)
|
||||
platform_darwin=yes
|
||||
PATHSEP='/'
|
||||
SEARCHSEP=':'
|
||||
OS="UNIX"
|
||||
PIDTYPE='int'
|
||||
;;
|
||||
*)
|
||||
PATHSEP='/'
|
||||
SEARCHSEP=':'
|
||||
OS="UNIX"
|
||||
PIDTYPE='int'
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -84,12 +87,15 @@ AC_SUBST(CFLAGS)
|
||||
AC_SUBST(PATHSEP)
|
||||
AC_SUBST(SEARCHSEP)
|
||||
AC_SUBST(OS)
|
||||
AC_SUBST(PIDTYPE)
|
||||
AM_CONDITIONAL(HOST_WIN32, test x$OS = xWIN32)
|
||||
AM_CONDITIONAL(TARGET_WIN32, test x$OS = xWIN32)
|
||||
AM_CONDITIONAL(PLATFORM_DARWIN, test x$platform_darwin = xyes)
|
||||
|
||||
AC_CHECK_SIZEOF(int)
|
||||
AC_CHECK_SIZEOF(void *)
|
||||
AC_CHECK_SIZEOF(long)
|
||||
AC_CHECK_SIZEOF(long long)
|
||||
AC_CHECK_FUNCS(strndup strlcpy getpwuid_r strtok_r rewinddir vasprintf)
|
||||
AM_CONDITIONAL(NEED_VASPRINTF, test x$have_vasprintf = x )
|
||||
AC_CHECK_LIB(iconv, iconv_open, LIBS="$LIBS -liconv")
|
||||
@@ -130,16 +136,7 @@ AC_CHECK_HEADERS(getopt.h sys/time.h sys/wait.h pwd.h langinfo.h iconv.h localch
|
||||
AC_CHECK_HEADER(alloca.h, [HAVE_ALLOCA_H=1], [HAVE_ALLOCA_H=0])
|
||||
AC_SUBST(HAVE_ALLOCA_H)
|
||||
|
||||
if test $ac_cv_sizeof_void_p != $ac_cv_sizeof_int; then
|
||||
GPOINTER_TO_INT="((gint)(long) (ptr))"
|
||||
GPOINTER_TO_UINT="((guint)(long) (ptr))"
|
||||
GINT_TO_POINTER="((gpointer)(glong) (v))"
|
||||
GUINT_TO_POINTER="((gpointer)(gulong) (v))"
|
||||
GSIZE="long"
|
||||
GSIZE_FORMAT='"lu"'
|
||||
G_GUINT64_FORMAT='"lu"'
|
||||
G_GINT64_FORMAT='"ld"'
|
||||
else
|
||||
if test $ac_cv_sizeof_void_p = $ac_cv_sizeof_int; then
|
||||
GPOINTER_TO_INT="((gint) (ptr))"
|
||||
GPOINTER_TO_UINT="((guint) (ptr))"
|
||||
GINT_TO_POINTER="((gpointer) (v))"
|
||||
@@ -148,6 +145,26 @@ else
|
||||
GSIZE_FORMAT='"u"'
|
||||
G_GUINT64_FORMAT='"llu"'
|
||||
G_GINT64_FORMAT='"lld"'
|
||||
elif test $ac_cv_sizeof_void_p = $ac_cv_sizeof_long; then
|
||||
GPOINTER_TO_INT="((gint)(long) (ptr))"
|
||||
GPOINTER_TO_UINT="((guint)(long) (ptr))"
|
||||
GINT_TO_POINTER="((gpointer)(glong) (v))"
|
||||
GUINT_TO_POINTER="((gpointer)(gulong) (v))"
|
||||
GSIZE="long"
|
||||
GSIZE_FORMAT='"lu"'
|
||||
G_GUINT64_FORMAT='"lu"'
|
||||
G_GINT64_FORMAT='"ld"'
|
||||
elif test $ac_cv_sizeof_void_p = $ac_cv_sizeof_long_long; then
|
||||
GPOINTER_TO_INT="((gint)(long long) (ptr))"
|
||||
GPOINTER_TO_UINT="((guint)(unsigned long long) (ptr))"
|
||||
GINT_TO_POINTER="((gpointer)(long long) (v))"
|
||||
GUINT_TO_POINTER="((gpointer)(unsigned long long) (v))"
|
||||
GSIZE="long long"
|
||||
GSIZE_FORMAT='"I64u"'
|
||||
G_GUINT64_FORMAT='"I64u"'
|
||||
G_GINT64_FORMAT='"I64i"'
|
||||
else
|
||||
AC_MSG_ERROR([unsupported pointer size])
|
||||
fi
|
||||
|
||||
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
|
||||
|
||||
@@ -42,4 +42,6 @@ typedef signed @GSIZE@ gssize;
|
||||
#define G_BREAKPOINT()
|
||||
#endif
|
||||
|
||||
typedef @PIDTYPE@ GPid;
|
||||
|
||||
#endif
|
||||
@@ -71,4 +71,6 @@ int vasprintf(char **ret, const char *fmt, va_list ap);
|
||||
#pragma warning(disable:4100 4127)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
typedef void * GPid;
|
||||
|
||||
#endif
|
||||
@@ -33,6 +33,9 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <direct.h>
|
||||
|
||||
@@ -13,14 +13,6 @@
|
||||
#pragma include_alias(<eglib-config.h>, <eglib-config.hw>)
|
||||
#else
|
||||
#include <stdint.h>
|
||||
/* For pid_t */
|
||||
#ifndef WIN32
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <eglib-config.h>
|
||||
@@ -720,8 +712,6 @@ typedef enum {
|
||||
G_SPAWN_FILE_AND_ARGV_ZERO = 1 << 6
|
||||
} GSpawnFlags;
|
||||
|
||||
typedef pid_t GPid;
|
||||
|
||||
typedef void (*GSpawnChildSetupFunc) (gpointer user_data);
|
||||
|
||||
gboolean g_spawn_command_line_sync (const gchar *command_line, gchar **standard_output, gchar **standard_error, gint *exit_status, GError **error);
|
||||
|
||||
+25
-4
@@ -45,6 +45,10 @@ g_build_path (const gchar *separator, const gchar *first_element, ...)
|
||||
const char *s, *p, *next;
|
||||
size_t slen;
|
||||
va_list args;
|
||||
gboolean found;
|
||||
#ifdef G_OS_WIN32
|
||||
const gchar alt_separator = '/';
|
||||
#endif
|
||||
|
||||
g_return_val_if_fail (separator != NULL, NULL);
|
||||
|
||||
@@ -57,24 +61,41 @@ g_build_path (const gchar *separator, const gchar *first_element, ...)
|
||||
|
||||
va_start (args, first_element);
|
||||
for (s = first_element; s != NULL; s = next){
|
||||
found = FALSE;
|
||||
next = va_arg (args, char *);
|
||||
p = (s + strlen (s));
|
||||
|
||||
if (next && p - slen > s){
|
||||
for (; strncmp (p-slen, separator, slen) == 0; ){
|
||||
/* Strip all but one trailing separator */
|
||||
if (next && p - slen >= s){
|
||||
for (; strncmp (p-slen, separator, slen) == 0
|
||||
#ifdef G_OS_WIN32
|
||||
|| alt_separator == *(p-slen)
|
||||
#endif
|
||||
;){
|
||||
found = TRUE;
|
||||
p -= slen;
|
||||
}
|
||||
}
|
||||
if (found) p += slen;
|
||||
|
||||
/* Append path token */
|
||||
g_string_append_len (result, s, p - s);
|
||||
|
||||
if (next && *next){
|
||||
if (strncmp (separator, result->str + strlen (result->str) - slen, slen))
|
||||
/* Append separator if needed */
|
||||
if (!found)
|
||||
g_string_append (result, separator);
|
||||
|
||||
for (; strncmp (next, separator, slen) == 0; )
|
||||
/* Strip multiple contiguous separators */
|
||||
for (; strncmp (next, separator, slen) == 0
|
||||
#ifdef G_OS_WIN32
|
||||
|| alt_separator == *next
|
||||
#endif
|
||||
; )
|
||||
next += slen;
|
||||
}
|
||||
}
|
||||
/* Nul-terminate */
|
||||
g_string_append_c (result, 0);
|
||||
va_end (args);
|
||||
|
||||
|
||||
@@ -300,13 +300,13 @@ g_filename_from_utf8 (const gchar *utf8string, gssize len, gsize *bytes_read, gs
|
||||
gboolean
|
||||
g_get_charset (G_CONST_RETURN char **charset)
|
||||
{
|
||||
if (my_charset == NULL) {
|
||||
#ifdef G_OS_WIN32
|
||||
static char buf[14];
|
||||
sprintf (buf, "CP%u", GetACP ());
|
||||
*charset = buf;
|
||||
is_utf8 = FALSE;
|
||||
static char buf [14];
|
||||
sprintf (buf, "CP%u", GetACP ());
|
||||
my_charset = buf;
|
||||
is_utf8 = FALSE;
|
||||
#else
|
||||
if (my_charset == NULL){
|
||||
/* These shouldn't be heap allocated */
|
||||
#if HAVE_LOCALCHARSET_H
|
||||
my_charset = locale_charset ();
|
||||
@@ -316,12 +316,12 @@ g_get_charset (G_CONST_RETURN char **charset)
|
||||
my_charset = "UTF-8";
|
||||
#endif
|
||||
is_utf8 = strcmp (my_charset, "UTF-8") == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (charset != NULL)
|
||||
*charset = my_charset;
|
||||
|
||||
#endif
|
||||
return is_utf8;
|
||||
}
|
||||
|
||||
|
||||
+8
-1
@@ -1038,7 +1038,7 @@ method. The right option, unfortunately, requires experimentation.
|
||||
When using Mono with the SGen garbage collector this environment
|
||||
variable can be used to turn on various debugging features of the
|
||||
collector. The value of this variable is a comma separated list of
|
||||
words.
|
||||
words. Do not use these options in production.
|
||||
.RS
|
||||
.ne 8
|
||||
.TP
|
||||
@@ -1063,6 +1063,13 @@ This clears the nursery at GC time instead of doing it when the thread
|
||||
local allocation buffer (TLAB) is created. The default is to clear
|
||||
the nursery at TLAB creation time.
|
||||
.TP
|
||||
\fBdisable-minor\fR
|
||||
Don't do minor collections. If the nursery is full, a major collection
|
||||
is triggered instead, unless it, too, is disabled.
|
||||
.TP
|
||||
\fBdisable-major\fR
|
||||
Don't do major collections.
|
||||
.TP
|
||||
\fBconservative-stack-mark\fR
|
||||
Forces the GC to scan the stack conservatively, even if precise
|
||||
scanning is available.
|
||||
|
||||
+72
-5
@@ -41,8 +41,32 @@ Validate the project file against the schema
|
||||
.B \//validate:<schema>
|
||||
Validate the project file against the specified schema
|
||||
.TP
|
||||
.B \//consoleloggerparameters:<params>
|
||||
Parameters for the console logger : PerfomanceSummary, NoSummary, NoItemAndPropertyList
|
||||
.B \//consoleloggerparameters:<params> , /clp:<params>
|
||||
Parameters for the console logger : PerfomanceSummary, Summary, NoSummary, NoItemAndPropertyList, Verbosity
|
||||
.TP
|
||||
.B \//filelogger[n] , /fl[n]
|
||||
Logs the output to a file, named 'msbuild.log' by default. If the optional number 'n' is
|
||||
specified, then it logs to 'msbuild[n].log' . Parameters for this logger, including
|
||||
the log file name can be specified via a corresponding /flp[n] option. Default verbosity
|
||||
for file loggers is 'detailed. 'n' can be between 1-9.
|
||||
.TP
|
||||
.B \//fileloggerparameters[n]:<params> , /flp[n]:<params>
|
||||
Parameters for a file logger. This implies a corresponding /fl[n]. 'n' can be between
|
||||
1-9, and is used to add upto 10 file loggers. Parameters can be, besides the ones available
|
||||
for console logger:
|
||||
.RS
|
||||
.TP
|
||||
.I LogFile=<file>
|
||||
File to which the build log will be written.
|
||||
.TP
|
||||
.I Append
|
||||
If this is used, then the log file is appended to, else a new one will be created.
|
||||
.TP
|
||||
.I Encoding=<encoding>
|
||||
Encoding to use for the log file, eg. UTF-8, ASCII.
|
||||
.TP
|
||||
Eg: xbuild foo.csproj /flp:Verbosity=normal "/flp1:LogFile=build.log;Append;Encoding=ASCII"
|
||||
.RE
|
||||
.TP
|
||||
.B \//nologo
|
||||
Don't show the initial xbuild banner
|
||||
@@ -73,8 +97,8 @@ to $prefix/lib/mono/xbuild . When used in Import, like:
|
||||
|
||||
xbuild tries various values for the msbuild property $(MSBuildExtensionsPath), in order:
|
||||
|
||||
1. /Library/Frameworks/Mono.framework/External/xbuild on Mac OSX.
|
||||
2. Paths specified in the environment variable $MSBuildExtensionsPath.
|
||||
1. Paths specified in the environment variable $MSBuildExtensionsPath.
|
||||
2. /Library/Frameworks/Mono.framework/External/xbuild on Mac OSX.
|
||||
3. $XDG_CONFIG_HOME/xbuild/tasks (or Environment.SpecialFolder.ApplicationData)
|
||||
4. $prefix/lib/mono/xbuild (default location)
|
||||
|
||||
@@ -82,6 +106,49 @@ Anywhere else in the project files, $(MSBuildExtensionsPath) will always resolve
|
||||
location. This is a xbuild-only feature.
|
||||
This is also applicable for the properties $(MSBuildExtensionsPath32) and $(MSBuildExtensionsPath64),
|
||||
and the environment variables have the corresponding names - MSBuildExtensionsPath32/64 .
|
||||
.TP
|
||||
.I "XBUILD_FRAMEWORK_FOLDERS_PATH"
|
||||
With ToolsVersion 4.0, projects can target arbitrary frameworks referenced by TargetFrameworkMoniker,
|
||||
which is of the format:
|
||||
|
||||
Identifier,Version=<version>[,Profile=<profile>]
|
||||
|
||||
Eg. ".NETFramework,Version=v4.0"
|
||||
|
||||
The 3 parts of the moniker are given by the msbuild properties:
|
||||
|
||||
$(TargetFrameworkIdentifier), $(TargetFrameworkVersion) and $(TargetFrameworkProfile)
|
||||
|
||||
This moniker maps to a framework description file on disk:
|
||||
|
||||
<framework_root>/Identifier/Version/[Profile]/RedistList/FrameworkList.xml
|
||||
|
||||
This file is used to determine the path where to find the framework assemblies for this particular framework.
|
||||
|
||||
Framework root here is configurable and is resolved in the following order:
|
||||
|
||||
.nf
|
||||
1. Paths specified in the environment variable $XBUILD_FRAMEWORK_FOLDERS_PATH
|
||||
2. /Library/Frameworks/Mono.framework/External/xbuild-frameworks on Mac OSX.
|
||||
3. MSBuild property $(TargetFrameworkRoot)
|
||||
4. $prefix/lib/mono/xbuild-frameworks (default location)
|
||||
.fi
|
||||
|
||||
XBuild tries the paths given above, in order, till it finds a FrameworkList.xml for the moniker.
|
||||
Running with /v:detailed or higher verbosity will show the various paths that it tries.
|
||||
|
||||
The FrameworkList.xml itself just has a root element like:
|
||||
|
||||
<FileList Name=".NET Framework 3.5" TargetFrameworkDirectory="..\\..\\..\\..\\3.5" IncludeFramework="v3.0">
|
||||
</FileList>
|
||||
|
||||
Here the TargetFrameworkDirectory attribute specifies the directory where the assemblies for
|
||||
this particular framework can be found. If this is not set, then the parent of the folder
|
||||
containing the xml file is taken as the framework directory.
|
||||
|
||||
IncludeFramework attribute specifies the version of a framework (under the *same* $(TargetFrameworkIdentifier))
|
||||
which should be included in the final list of Target framework directories.
|
||||
|
||||
.TP
|
||||
.I "XBUILD_COLORS"
|
||||
If this variable is set, it contains a string of the form
|
||||
@@ -119,7 +186,7 @@ looks in "/Library/Frameworks/Mono.framework/External/pkgconfig" .
|
||||
.SH SEE ALSO
|
||||
.BR mono(1), mcs(1)
|
||||
.SH COPYRIGHT
|
||||
Copyright (C) 2009 Novell, Inc (http://www.novell.com)
|
||||
Copyright (C) 2011 Novell, Inc (http://www.novell.com)
|
||||
.SH MAILING LISTS
|
||||
Visit http://lists.ximian.com/mailman/listinfo/mono-devel-list for details.
|
||||
.SH WEB SITE
|
||||
|
||||
@@ -166,33 +166,21 @@ namespace IKVM.Reflection.Emit
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (x.tryOffset >= y.handlerOffset && x.tryOffset + x.tryLength <= y.handlerOffset + y.handlerLength)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (y.tryOffset >= x.handlerOffset && y.tryOffset + y.tryLength <= x.handlerOffset + x.handlerLength)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (x.tryOffset == y.tryOffset && x.tryLength == y.tryLength)
|
||||
else if (x.tryOffset == y.tryOffset && x.tryLength == y.tryLength)
|
||||
{
|
||||
return x.ordinal < y.ordinal ? -1 : 1;
|
||||
}
|
||||
if (x.tryOffset + x.tryLength <= y.tryOffset)
|
||||
else if (x.tryOffset >= y.tryOffset && x.handlerOffset + x.handlerLength <= y.handlerOffset + y.handlerLength)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (y.tryOffset + y.tryLength <= x.tryOffset)
|
||||
else if (y.tryOffset >= x.tryOffset && y.handlerOffset + y.handlerLength <= x.handlerOffset + x.handlerLength)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (x.tryOffset > y.tryOffset || (x.tryOffset == y.tryOffset && x.tryLength < y.tryLength))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
return x.ordinal < y.ordinal ? -1 : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,14 +35,21 @@ namespace Microsoft.Build.BuildEngine {
|
||||
internal class BuildChoose {
|
||||
|
||||
BuildWhen otherwise;
|
||||
Project project;
|
||||
XmlElement xmlElement;
|
||||
//Project project;
|
||||
//ImportedProject importedProject;
|
||||
//XmlElement xmlElement;
|
||||
List <BuildWhen> whens;
|
||||
|
||||
public BuildChoose (XmlElement xmlElement, Project project)
|
||||
: this (xmlElement, project, null)
|
||||
{
|
||||
this.xmlElement = xmlElement;
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
internal BuildChoose (XmlElement xmlElement, Project project, ImportedProject importedProject)
|
||||
{
|
||||
//this.xmlElement = xmlElement;
|
||||
//this.project = project;
|
||||
//this.importedProject = importedProject;
|
||||
this.whens = new List <BuildWhen> ();
|
||||
|
||||
foreach (XmlNode xn in xmlElement.ChildNodes) {
|
||||
@@ -65,6 +72,9 @@ namespace Microsoft.Build.BuildEngine {
|
||||
otherwise = new BuildWhen (xe, project);
|
||||
}
|
||||
}
|
||||
|
||||
DefinedInFileName = importedProject != null ? importedProject.FullFileName :
|
||||
project != null ? project.FullFileName : null;
|
||||
}
|
||||
|
||||
public void Evaluate ()
|
||||
@@ -85,6 +95,8 @@ namespace Microsoft.Build.BuildEngine {
|
||||
get { return whens; }
|
||||
set { whens = value; }
|
||||
}
|
||||
|
||||
internal string DefinedInFileName { get; private set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,9 @@ namespace Microsoft.Build.BuildEngine {
|
||||
buildItems.Add (bi);
|
||||
project.LastItemGroupContaining [bi.Name] = this;
|
||||
}
|
||||
|
||||
DefinedInFileName = importedProject != null ? importedProject.FullFileName :
|
||||
project != null ? project.FullFileName : null;
|
||||
}
|
||||
|
||||
public BuildItem AddNewItem (string itemName,
|
||||
@@ -303,6 +306,8 @@ namespace Microsoft.Build.BuildEngine {
|
||||
}
|
||||
}
|
||||
|
||||
internal string DefinedInFileName { get; private set; }
|
||||
|
||||
internal bool FromXml {
|
||||
get {
|
||||
return itemGroupElement != null;
|
||||
|
||||
@@ -71,6 +71,9 @@ namespace Microsoft.Build.BuildEngine {
|
||||
}
|
||||
} else
|
||||
this.propertiesByName = new Dictionary <string, BuildProperty> (StringComparer.InvariantCultureIgnoreCase);
|
||||
|
||||
DefinedInFileName = importedProject != null ? importedProject.FullFileName :
|
||||
(project != null ? project.FullFileName : null);
|
||||
}
|
||||
|
||||
public BuildProperty AddNewProperty (string propertyName,
|
||||
@@ -287,7 +290,9 @@ namespace Microsoft.Build.BuildEngine {
|
||||
propertiesByName [propertyName] = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal string DefinedInFileName { get; private set; }
|
||||
|
||||
internal GroupingCollection GroupingCollection {
|
||||
get { return parentCollection; }
|
||||
set { parentCollection = value; }
|
||||
|
||||
@@ -33,13 +33,13 @@ using System.Xml;
|
||||
|
||||
namespace Microsoft.Build.BuildEngine {
|
||||
internal class BuildWhen {
|
||||
Project parentProject;
|
||||
//Project parentProject;
|
||||
GroupingCollection groupingCollection;
|
||||
XmlElement whenElement;
|
||||
|
||||
public BuildWhen (XmlElement whenElement, Project parentProject)
|
||||
{
|
||||
this.parentProject = parentProject;
|
||||
//this.parentProject = parentProject;
|
||||
this.groupingCollection = new GroupingCollection (parentProject);
|
||||
if (whenElement == null)
|
||||
throw new ArgumentNullException ("whenElement");
|
||||
|
||||
+3
-3
@@ -46,7 +46,7 @@ namespace Microsoft.Build.BuildEngine {
|
||||
Type t = typeof (ConditionFunctionExpression);
|
||||
string [] names = new string [] { "Exists", "HasTrailingSlash" };
|
||||
|
||||
functions = new Dictionary <string, MethodInfo> ();
|
||||
functions = new Dictionary <string, MethodInfo> (StringComparer.InvariantCultureIgnoreCase);
|
||||
foreach (string name in names)
|
||||
functions.Add (name, t.GetMethod (name, BindingFlags.NonPublic | BindingFlags.Static));
|
||||
}
|
||||
@@ -60,10 +60,10 @@ namespace Microsoft.Build.BuildEngine {
|
||||
public override bool BoolEvaluate (Project context)
|
||||
{
|
||||
if (!functions.ContainsKey (name))
|
||||
throw new InvalidOperationException ();
|
||||
throw new InvalidOperationException ("Unknown function named: " + name);
|
||||
|
||||
if (functions [name] == null)
|
||||
throw new InvalidOperationException ();
|
||||
throw new InvalidOperationException ("Unknown function named: " + name);
|
||||
|
||||
MethodInfo mi = functions [name];
|
||||
object [] argsArr = new object [args.Count + 1];
|
||||
|
||||
@@ -197,8 +197,68 @@ namespace Microsoft.Build.BuildEngine {
|
||||
public void ApplyParameter (string parameterName,
|
||||
string parameterValue)
|
||||
{
|
||||
// FIXME: what we should do here? in msbuild it isn't
|
||||
// changing "parameters" property
|
||||
switch (parameterName) {
|
||||
case "PerformanceSummary":
|
||||
this.performanceSummary = true;
|
||||
break;
|
||||
case "Summary":
|
||||
this.showSummary = true;
|
||||
break;
|
||||
case "NoSummary":
|
||||
this.showSummary = false;
|
||||
break;
|
||||
case "NoItemAndPropertyList":
|
||||
this.noItemAndPropertyList = true;
|
||||
break;
|
||||
default:
|
||||
if (parameterName.StartsWith ("Verbosity="))
|
||||
ParseVerbosity (parameterName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ParseVerbosity (string s)
|
||||
{
|
||||
string key, value;
|
||||
if (!TrySplitKeyValuePair (s, out key, out value))
|
||||
throw new LoggerException ("Unknown Verbosity, should be set as 'Verbosity=<verbosity>'");
|
||||
|
||||
switch (value) {
|
||||
case "q":
|
||||
case "quiet":
|
||||
Verbosity = LoggerVerbosity.Quiet;
|
||||
break;
|
||||
case "m":
|
||||
case "minimal":
|
||||
Verbosity = LoggerVerbosity.Minimal;
|
||||
break;
|
||||
case "n":
|
||||
case "normal":
|
||||
Verbosity = LoggerVerbosity.Normal;
|
||||
break;
|
||||
case "d":
|
||||
case "detailed":
|
||||
Verbosity = LoggerVerbosity.Detailed;
|
||||
break;
|
||||
case "diag":
|
||||
case "diagnostic":
|
||||
Verbosity = LoggerVerbosity.Diagnostic;
|
||||
break;
|
||||
default:
|
||||
throw new LoggerException (String.Format ("Unknown verbosity - '{0}'", s));
|
||||
}
|
||||
}
|
||||
|
||||
bool TrySplitKeyValuePair (string pair, out string key, out string value)
|
||||
{
|
||||
key = value = null;
|
||||
string[] parts = pair.Split ('=');
|
||||
if (parts.Length != 2)
|
||||
return false;
|
||||
|
||||
key = parts [0];
|
||||
value = parts [1];
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void Initialize (IEventSource eventSource)
|
||||
@@ -220,6 +280,9 @@ namespace Microsoft.Build.BuildEngine {
|
||||
eventSource.MessageRaised += MessageHandler;
|
||||
eventSource.WarningRaised += WarningHandler;
|
||||
eventSource.ErrorRaised += ErrorHandler;
|
||||
|
||||
if (!String.IsNullOrEmpty (parameters))
|
||||
ParseParameters ();
|
||||
}
|
||||
|
||||
public void BuildStartedHandler (object sender, BuildStartedEventArgs args)
|
||||
@@ -607,21 +670,8 @@ namespace Microsoft.Build.BuildEngine {
|
||||
private void ParseParameters ()
|
||||
{
|
||||
string[] splittedParameters = parameters.Split (';');
|
||||
foreach (string s in splittedParameters ) {
|
||||
switch (s) {
|
||||
case "PerformanceSummary":
|
||||
this.performanceSummary = true;
|
||||
break;
|
||||
case "NoSummary":
|
||||
this.showSummary = false;
|
||||
break;
|
||||
case "NoItemAndPropertyList":
|
||||
this.noItemAndPropertyList = true;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException ("Invalid parameter : " + s);
|
||||
}
|
||||
}
|
||||
foreach (string s in splittedParameters )
|
||||
ApplyParameter (s, null);
|
||||
}
|
||||
|
||||
public virtual void Shutdown ()
|
||||
@@ -779,8 +829,6 @@ namespace Microsoft.Build.BuildEngine {
|
||||
if (value == null)
|
||||
throw new ArgumentNullException ();
|
||||
parameters = value;
|
||||
if (parameters != String.Empty)
|
||||
ParseParameters ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,6 @@ namespace Microsoft.Build.BuildEngine {
|
||||
{
|
||||
Dictionary <string, bool> excludedItems;
|
||||
List <ITaskItem> includedItems;
|
||||
string[] splitExclude;
|
||||
|
||||
if (includes == null)
|
||||
throw new ArgumentNullException ("Includes");
|
||||
@@ -84,7 +83,7 @@ namespace Microsoft.Build.BuildEngine {
|
||||
FileInfo[] fileInfo;
|
||||
|
||||
string name = include_item.ItemSpec;
|
||||
if (name.IndexOf ('?') == -1 && name.IndexOf ('*') == -1) {
|
||||
if (!HasWildcard (name)) {
|
||||
if (!excludedItems.ContainsKey (Path.GetFullPath(name)))
|
||||
includedItems.Add (include_item);
|
||||
} else {
|
||||
@@ -211,6 +210,11 @@ namespace Microsoft.Build.BuildEngine {
|
||||
return fi;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool HasWildcard (string expression)
|
||||
{
|
||||
return expression.IndexOf ('?') >= 0 || expression.IndexOf ('*') >= 0;
|
||||
}
|
||||
|
||||
public DirectoryInfo BaseDirectory {
|
||||
get { return baseDirectory; }
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Microsoft.Build.BuildEngine {
|
||||
const string defaultTasksProjectName = "Microsoft.Common.tasks";
|
||||
EventSource eventSource;
|
||||
bool buildStarted;
|
||||
ToolsetDefinitionLocations toolsetLocations;
|
||||
//ToolsetDefinitionLocations toolsetLocations;
|
||||
BuildPropertyGroup global_properties;
|
||||
//IDictionary importedProjects;
|
||||
List <ILogger> loggers;
|
||||
@@ -73,7 +73,7 @@ namespace Microsoft.Build.BuildEngine {
|
||||
public Engine (ToolsetDefinitionLocations locations)
|
||||
: this (ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version20))
|
||||
{
|
||||
toolsetLocations = locations;
|
||||
//toolsetLocations = locations;
|
||||
}
|
||||
|
||||
public Engine (BuildPropertyGroup globalProperties)
|
||||
@@ -86,7 +86,7 @@ namespace Microsoft.Build.BuildEngine {
|
||||
: this (ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version20))
|
||||
{
|
||||
this.global_properties = globalProperties;
|
||||
toolsetLocations = locations;
|
||||
//toolsetLocations = locations;
|
||||
}
|
||||
|
||||
// engine should be invoked with path where binary files are
|
||||
@@ -229,6 +229,33 @@ namespace Microsoft.Build.BuildEngine {
|
||||
IDictionary targetOutputs,
|
||||
BuildSettings buildFlags, string toolsVersion)
|
||||
{
|
||||
bool result = false;
|
||||
try {
|
||||
StartEngineBuild ();
|
||||
result = BuildProjectFileInternal (projectFile, targetNames, globalProperties, targetOutputs, buildFlags, toolsVersion);
|
||||
return result;
|
||||
} catch (InvalidProjectFileException ie) {
|
||||
this.LogErrorWithFilename (projectFile, ie.Message);
|
||||
this.LogMessage (MessageImportance.Low, String.Format ("{0}: {1}", projectFile, ie.ToString ()));
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
if (buildStarted) {
|
||||
this.LogErrorWithFilename (projectFile, e.Message);
|
||||
this.LogMessage (MessageImportance.Low, String.Format ("{0}: {1}", projectFile, e.ToString ()));
|
||||
}
|
||||
throw;
|
||||
} finally {
|
||||
EndEngineBuild (result);
|
||||
}
|
||||
}
|
||||
|
||||
bool BuildProjectFileInternal (string projectFile,
|
||||
string[] targetNames,
|
||||
BuildPropertyGroup globalProperties,
|
||||
IDictionary targetOutputs,
|
||||
BuildSettings buildFlags, string toolsVersion)
|
||||
{
|
||||
|
||||
if ((buildFlags & BuildSettings.DoNotResetPreviouslyBuiltTargets) != BuildSettings.DoNotResetPreviouslyBuiltTargets)
|
||||
builtTargetsOutputByName.Clear ();
|
||||
|
||||
@@ -366,12 +393,25 @@ namespace Microsoft.Build.BuildEngine {
|
||||
loggers.Clear ();
|
||||
}
|
||||
|
||||
internal void StartProjectBuild (Project project, string [] target_names)
|
||||
void StartEngineBuild ()
|
||||
{
|
||||
if (!buildStarted) {
|
||||
LogBuildStarted ();
|
||||
buildStarted = true;
|
||||
}
|
||||
}
|
||||
|
||||
void EndEngineBuild (bool succeeded)
|
||||
{
|
||||
if (buildStarted && currentlyBuildingProjectsStack.Count == 0) {
|
||||
LogBuildFinished (succeeded);
|
||||
buildStarted = false;
|
||||
}
|
||||
}
|
||||
|
||||
internal void StartProjectBuild (Project project, string [] target_names)
|
||||
{
|
||||
StartEngineBuild ();
|
||||
|
||||
if (currentlyBuildingProjectsStack.Count == 0 ||
|
||||
String.Compare (currentlyBuildingProjectsStack.Peek ().FullFileName, project.FullFileName) != 0)
|
||||
@@ -397,10 +437,7 @@ namespace Microsoft.Build.BuildEngine {
|
||||
String.Compare (top_project.FullFileName, currentlyBuildingProjectsStack.Peek ().FullFileName) != 0)
|
||||
LogProjectFinished (top_project, succeeded);
|
||||
|
||||
if (currentlyBuildingProjectsStack.Count == 0) {
|
||||
LogBuildFinished (succeeded);
|
||||
buildStarted = false;
|
||||
}
|
||||
EndEngineBuild (succeeded);
|
||||
}
|
||||
|
||||
internal void ClearBuiltTargetsForProject (Project project)
|
||||
@@ -518,16 +555,14 @@ namespace Microsoft.Build.BuildEngine {
|
||||
|
||||
public string DefaultToolsVersion {
|
||||
get {
|
||||
if (String.IsNullOrEmpty (defaultToolsVersion))
|
||||
#if NET_4_0
|
||||
return "4.0";
|
||||
#elif NET_3_5
|
||||
return "3.5";
|
||||
#else
|
||||
return "2.0";
|
||||
#endif
|
||||
|
||||
return defaultToolsVersion;
|
||||
// This is used as the fall back version if the
|
||||
// project can't find a version to use
|
||||
// Hard-coded to 2.0, so it allows even vs2005 projects
|
||||
// to build correctly, as they won't have a ToolsVersion
|
||||
// set!
|
||||
return String.IsNullOrEmpty (defaultToolsVersion)
|
||||
? "2.0"
|
||||
: defaultToolsVersion;
|
||||
}
|
||||
set {
|
||||
if (Toolsets [value] == null)
|
||||
|
||||
@@ -57,69 +57,87 @@ namespace Microsoft.Build.BuildEngine {
|
||||
{
|
||||
if (customEventRaised != null)
|
||||
customEventRaised (sender, cbea);
|
||||
FireAnyEvent (sender, cbea);
|
||||
}
|
||||
public void FireErrorRaised (object sender, BuildErrorEventArgs beea)
|
||||
{
|
||||
if (errorRaised != null)
|
||||
errorRaised (sender, beea);
|
||||
FireAnyEvent (sender, beea);
|
||||
}
|
||||
public void FireMessageRaised (object sender, BuildMessageEventArgs bmea)
|
||||
{
|
||||
if (messageRaised != null)
|
||||
messageRaised (sender, bmea);
|
||||
FireAnyEvent (sender, bmea);
|
||||
}
|
||||
public void FireWarningRaised (object sender, BuildWarningEventArgs bwea)
|
||||
{
|
||||
if (warningRaised != null)
|
||||
warningRaised (sender, bwea);
|
||||
FireAnyEvent (sender, bwea);
|
||||
}
|
||||
|
||||
public void FireTargetStarted (object sender, TargetStartedEventArgs tsea)
|
||||
{
|
||||
if (targetStarted != null)
|
||||
targetStarted (sender, tsea);
|
||||
FireAnyEvent (sender, tsea);
|
||||
}
|
||||
|
||||
public void FireTargetFinished (object sender, TargetFinishedEventArgs tfea)
|
||||
{
|
||||
if (targetFinished != null)
|
||||
targetFinished (sender, tfea);
|
||||
FireAnyEvent (sender, tfea);
|
||||
}
|
||||
|
||||
public void FireBuildStarted (object sender, BuildStartedEventArgs bsea)
|
||||
{
|
||||
if (buildStarted != null)
|
||||
buildStarted (sender, bsea);
|
||||
FireAnyEvent (sender, bsea);
|
||||
}
|
||||
|
||||
public void FireBuildFinished (object sender, BuildFinishedEventArgs bfea)
|
||||
{
|
||||
if (buildFinished != null)
|
||||
buildFinished (sender, bfea);
|
||||
FireAnyEvent (sender, bfea);
|
||||
}
|
||||
|
||||
public void FireProjectStarted (object sender, ProjectStartedEventArgs psea)
|
||||
{
|
||||
if (projectStarted != null)
|
||||
projectStarted (sender, psea);
|
||||
FireAnyEvent (sender, psea);
|
||||
}
|
||||
|
||||
public void FireProjectFinished (object sender, ProjectFinishedEventArgs pfea)
|
||||
{
|
||||
if (projectFinished != null)
|
||||
projectFinished (sender, pfea);
|
||||
FireAnyEvent (sender, pfea);
|
||||
}
|
||||
|
||||
public void FireTaskStarted (object sender, TaskStartedEventArgs tsea)
|
||||
{
|
||||
if (taskStarted != null)
|
||||
taskStarted (sender, tsea);
|
||||
FireAnyEvent (sender, tsea);
|
||||
}
|
||||
|
||||
public void FireTaskFinished (object sender, TaskFinishedEventArgs tfea)
|
||||
{
|
||||
if (taskFinished != null)
|
||||
taskFinished (sender, tfea);
|
||||
FireAnyEvent (sender, tfea);
|
||||
}
|
||||
|
||||
public void FireAnyEvent (object sender, BuildEventArgs bea)
|
||||
{
|
||||
if (anyEventRaised != null)
|
||||
anyEventRaised (sender, bea);
|
||||
}
|
||||
|
||||
public event AnyEventHandler AnyEventRaised {
|
||||
@@ -283,4 +301,4 @@ namespace Microsoft.Build.BuildEngine {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -66,6 +66,20 @@ namespace Microsoft.Build.BuildEngine {
|
||||
this.expressionCollection = new ExpressionCollection ();
|
||||
}
|
||||
|
||||
public static T ParseAs<T> (string expression, ParseOptions options, Project project)
|
||||
{
|
||||
Expression expr = new Expression ();
|
||||
expr.Parse (expression, options);
|
||||
return (T)expr.ConvertTo (project, typeof (T));
|
||||
}
|
||||
|
||||
public static T ParseAs<T> (string expression, ParseOptions options, Project project, ExpressionOptions exprOptions)
|
||||
{
|
||||
Expression expr = new Expression ();
|
||||
expr.Parse (expression, options);
|
||||
return (T)expr.ConvertTo (project, typeof (T), exprOptions);
|
||||
}
|
||||
|
||||
// Split: Split on ';'
|
||||
// Eg. Property values don't need to be split
|
||||
//
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
//
|
||||
// Author:
|
||||
// Marek Sieradzki ([email protected])
|
||||
// Ankit Jain ([email protected])
|
||||
//
|
||||
// (C) 2005 Marek Sieradzki
|
||||
// Copyright 2011 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
|
||||
@@ -27,23 +29,125 @@
|
||||
|
||||
#if NET_2_0
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Microsoft.Build.Framework;
|
||||
|
||||
namespace Microsoft.Build.BuildEngine {
|
||||
public class FileLogger : ConsoleLogger {
|
||||
StreamWriter sw;
|
||||
string logfile;
|
||||
string encoding = null;
|
||||
IEventSource eventSource;
|
||||
|
||||
public FileLogger ()
|
||||
{
|
||||
base.Verbosity = LoggerVerbosity.Detailed;
|
||||
}
|
||||
|
||||
// FIXME: add our handlers to the events
|
||||
public override void Initialize (IEventSource eventSource)
|
||||
{
|
||||
this.eventSource = eventSource;
|
||||
logfile = "msbuild.log";
|
||||
|
||||
bool append = false;
|
||||
string key, value;
|
||||
string[] splittedParameters = Parameters.Split (new char [] {';'}, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (string s in splittedParameters) {
|
||||
if (String.Compare (s, "Append") == 0) {
|
||||
append = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (s.StartsWith ("Encoding")) {
|
||||
if (!TrySplitKeyValuePair (s, out key, out value))
|
||||
throw new LoggerException ("Encoding should be specified as: Encoding=<encoding>, eg. Encoding=UTF-8");
|
||||
|
||||
if (String.IsNullOrEmpty (value))
|
||||
throw new LoggerException ("Encoding must be non-empty");
|
||||
|
||||
encoding = value;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (s.StartsWith ("LogFile")) {
|
||||
if (!TrySplitKeyValuePair (s, out key, out value))
|
||||
throw new LoggerException ("LogFile should be specified as: LogFile=<encoding>, eg. LogFile=foo.log");
|
||||
|
||||
if (String.IsNullOrEmpty (value))
|
||||
throw new LoggerException ("LogFile value must be non-empty");
|
||||
|
||||
logfile = value;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Attach *our* HandleBuildStarted as the first one,
|
||||
// as it needs to create the writer!
|
||||
eventSource.BuildStarted += HandleBuildStarted;
|
||||
base.Initialize (eventSource);
|
||||
// Attach *our* HandleBuildFinished as the last one,
|
||||
// as it needs to close the writer!
|
||||
eventSource.BuildFinished += HandleBuildFinished;
|
||||
|
||||
CreateWriter (append);
|
||||
}
|
||||
|
||||
void CreateWriter (bool append_to)
|
||||
{
|
||||
if (sw != null)
|
||||
return;
|
||||
|
||||
if (!String.IsNullOrEmpty (encoding))
|
||||
sw = new StreamWriter (logfile, append_to, Encoding.GetEncoding (encoding));
|
||||
else
|
||||
sw = new StreamWriter (logfile, append_to, Encoding.Default);
|
||||
WriteHandler = sw.WriteLine;
|
||||
}
|
||||
|
||||
void HandleBuildStarted (object sender, BuildStartedEventArgs args)
|
||||
{
|
||||
CreateWriter (true);
|
||||
}
|
||||
|
||||
void HandleBuildFinished (object sender, BuildFinishedEventArgs args)
|
||||
{
|
||||
base.WriteHandler = null;
|
||||
if (sw != null) {
|
||||
sw.Close ();
|
||||
sw = null;
|
||||
}
|
||||
}
|
||||
|
||||
bool TrySplitKeyValuePair (string pair, out string key, out string value)
|
||||
{
|
||||
key = value = null;
|
||||
string[] parts = pair.Split ('=');
|
||||
if (parts.Length != 2)
|
||||
return false;
|
||||
|
||||
key = parts [0];
|
||||
value = parts [1];
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Shutdown ()
|
||||
{
|
||||
base.WriteHandler = null;
|
||||
if (sw != null) {
|
||||
sw.Close ();
|
||||
sw = null;
|
||||
}
|
||||
|
||||
if (eventSource != null) {
|
||||
eventSource.BuildStarted -= HandleBuildStarted;
|
||||
eventSource.BuildFinished -= HandleBuildFinished;
|
||||
}
|
||||
|
||||
base.Shutdown ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
+29
-14
@@ -180,8 +180,13 @@ namespace Microsoft.Build.BuildEngine {
|
||||
while (evaluate_iterator != null) {
|
||||
if (evaluate_iterator.Value is BuildPropertyGroup) {
|
||||
bpg = (BuildPropertyGroup) evaluate_iterator.Value;
|
||||
if (ConditionParser.ParseAndEvaluate (bpg.Condition, project))
|
||||
bpg.Evaluate ();
|
||||
project.PushThisFileProperty (bpg.DefinedInFileName);
|
||||
try {
|
||||
if (ConditionParser.ParseAndEvaluate (bpg.Condition, project))
|
||||
bpg.Evaluate ();
|
||||
} finally {
|
||||
project.PopThisFileProperty ();
|
||||
}
|
||||
}
|
||||
|
||||
// if it wasn't moved by adding anything because of evaluating a Import shift it
|
||||
@@ -197,8 +202,13 @@ namespace Microsoft.Build.BuildEngine {
|
||||
while (evaluate_iterator != null) {
|
||||
if (evaluate_iterator.Value is BuildItemGroup) {
|
||||
big = (BuildItemGroup) evaluate_iterator.Value;
|
||||
if (ConditionParser.ParseAndEvaluate (big.Condition, project))
|
||||
big.Evaluate ();
|
||||
project.PushThisFileProperty (big.DefinedInFileName);
|
||||
try {
|
||||
if (ConditionParser.ParseAndEvaluate (big.Condition, project))
|
||||
big.Evaluate ();
|
||||
} finally {
|
||||
project.PopThisFileProperty ();
|
||||
}
|
||||
}
|
||||
|
||||
evaluate_iterator = evaluate_iterator.Next;
|
||||
@@ -210,17 +220,22 @@ namespace Microsoft.Build.BuildEngine {
|
||||
while (evaluate_iterator != null) {
|
||||
if (evaluate_iterator.Value is BuildChoose) {
|
||||
BuildChoose bc = (BuildChoose)evaluate_iterator.Value;
|
||||
bool whenUsed = false;
|
||||
foreach (BuildWhen bw in bc.Whens) {
|
||||
if (ConditionParser.ParseAndEvaluate (bw.Condition, project)) {
|
||||
bw.Evaluate ();
|
||||
whenUsed = true;
|
||||
break;
|
||||
project.PushThisFileProperty (bc.DefinedInFileName);
|
||||
try {
|
||||
bool whenUsed = false;
|
||||
foreach (BuildWhen bw in bc.Whens) {
|
||||
if (ConditionParser.ParseAndEvaluate (bw.Condition, project)) {
|
||||
bw.Evaluate ();
|
||||
whenUsed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!whenUsed && bc.Otherwise != null &&
|
||||
ConditionParser.ParseAndEvaluate (bc.Otherwise.Condition, project)) {
|
||||
bc.Otherwise.Evaluate ();
|
||||
if (!whenUsed && bc.Otherwise != null &&
|
||||
ConditionParser.ParseAndEvaluate (bc.Otherwise.Condition, project)) {
|
||||
bc.Otherwise.Evaluate ();
|
||||
}
|
||||
} finally {
|
||||
project.PopThisFileProperty ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
//
|
||||
// Author:
|
||||
// Marek Sieradzki ([email protected])
|
||||
// Ankit Jain ([email protected])
|
||||
//
|
||||
// (C) 2006 Marek Sieradzki
|
||||
// Copyright 2011 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
|
||||
@@ -28,10 +30,13 @@
|
||||
#if NET_2_0
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
using Mono.XBuild.Utilities;
|
||||
|
||||
namespace Microsoft.Build.BuildEngine {
|
||||
@@ -44,8 +49,14 @@ namespace Microsoft.Build.BuildEngine {
|
||||
static string DotConfigExtensionsPath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData),
|
||||
Path.Combine ("xbuild", "tasks"));
|
||||
const string MacOSXExternalXBuildDir = "/Library/Frameworks/Mono.framework/External/xbuild";
|
||||
static string PathSeparatorAsString = Path.PathSeparator.ToString ();
|
||||
|
||||
internal Import (XmlElement importElement, Project project, ImportedProject originalProject)
|
||||
: this (importElement, null, project, originalProject)
|
||||
{}
|
||||
|
||||
// if @alternateProjectPath is available then that it used as the EvaluatedProjectPath!
|
||||
internal Import (XmlElement importElement, string alternateProjectPath, Project project, ImportedProject originalProject)
|
||||
{
|
||||
if (importElement == null)
|
||||
throw new ArgumentNullException ("importElement");
|
||||
@@ -60,7 +71,8 @@ namespace Microsoft.Build.BuildEngine {
|
||||
throw new InvalidProjectFileException ("The required attribute \"Project\" is missing from element <Import>.");
|
||||
|
||||
if (ConditionParser.ParseAndEvaluate (Condition, project)) {
|
||||
evaluatedProjectPath = EvaluateProjectPath (ProjectPath);
|
||||
evaluatedProjectPath = String.IsNullOrEmpty (alternateProjectPath) ? EvaluateProjectPath (ProjectPath) : alternateProjectPath;
|
||||
|
||||
evaluatedProjectPath = GetFullPath ();
|
||||
if (EvaluatedProjectPath == String.Empty)
|
||||
throw new InvalidProjectFileException ("The required attribute \"Project\" is missing from element <Import>.");
|
||||
@@ -72,9 +84,9 @@ namespace Microsoft.Build.BuildEngine {
|
||||
{
|
||||
string filename = evaluatedProjectPath;
|
||||
// NOTE: it's a hack to transform Microsoft.CSharp.Targets to Microsoft.CSharp.targets
|
||||
if (Path.HasExtension (filename))
|
||||
filename = Path.ChangeExtension (filename, Path.GetExtension (filename));
|
||||
|
||||
if (!File.Exists (filename) && Path.GetFileName (filename) == "Microsoft.CSharp.Targets")
|
||||
filename = Path.ChangeExtension (filename, ".targets");
|
||||
|
||||
if (!File.Exists (filename)) {
|
||||
if (ignoreMissingImports) {
|
||||
project.LogWarning (project.FullFileName, "Could not find project file {0}, to import. Ignoring.", filename);
|
||||
@@ -92,91 +104,148 @@ namespace Microsoft.Build.BuildEngine {
|
||||
|
||||
string EvaluateProjectPath (string file)
|
||||
{
|
||||
string ret;
|
||||
if (EvaluateAsMSBuildExtensionsPath (file, "MSBuildExtensionsPath", out ret) ||
|
||||
EvaluateAsMSBuildExtensionsPath (file, "MSBuildExtensionsPath32", out ret) ||
|
||||
EvaluateAsMSBuildExtensionsPath (file, "MSBuildExtensionsPath64", out ret))
|
||||
return ret;
|
||||
|
||||
return EvaluatePath (file);
|
||||
}
|
||||
|
||||
bool EvaluateAsMSBuildExtensionsPath (string file, string property_name, out string epath)
|
||||
{
|
||||
epath = null;
|
||||
string property_ref = String.Format ("$({0})", property_name);
|
||||
if (file.IndexOf (property_ref) < 0)
|
||||
return false;
|
||||
|
||||
// This is a *HACK* to support multiple paths for
|
||||
// MSBuildExtensionsPath property. Normally it would
|
||||
// get resolved to a single value, but here we special
|
||||
// case it and try ~/.config/xbuild/tasks and any
|
||||
// paths specified in the env var $MSBuildExtensionsPath .
|
||||
//
|
||||
// The property itself will resolve to the default
|
||||
// location though, so you get in any other part of the
|
||||
// project.
|
||||
|
||||
string envvar = Environment.GetEnvironmentVariable (property_name);
|
||||
envvar = String.Join (":", new string [] {
|
||||
// For mac osx, look in the 'External' dir on macosx,
|
||||
// see bug #663180
|
||||
MSBuildUtils.RunningOnMac ? MacOSXExternalXBuildDir : String.Empty,
|
||||
(envvar ?? String.Empty),
|
||||
DotConfigExtensionsPath});
|
||||
|
||||
string [] paths = envvar.Split (new char [] {':'}, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (string path in paths) {
|
||||
if (!Directory.Exists (path)) {
|
||||
project.ParentEngine.LogMessage (MessageImportance.Low, "Extension path '{0}' not found, ignoring.", path);
|
||||
continue;
|
||||
}
|
||||
|
||||
string pfile = Path.GetFullPath (file.Replace ("\\", "/").Replace (
|
||||
property_ref, path + Path.DirectorySeparatorChar));
|
||||
|
||||
var evaluated_path = EvaluatePath (pfile);
|
||||
if (File.Exists (evaluated_path)) {
|
||||
project.ParentEngine.LogMessage (MessageImportance.Low,
|
||||
"{0}: Importing project {1} from extension path {2}", project.FullFileName, evaluated_path, path);
|
||||
epath = pfile;
|
||||
return true;
|
||||
}
|
||||
project.ParentEngine.LogMessage (MessageImportance.Low,
|
||||
"{0}: Couldn't find project {1} for extension path {2}", project.FullFileName, evaluated_path, path);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
string EvaluatePath (string path)
|
||||
{
|
||||
var exp = new Expression ();
|
||||
exp.Parse (path, ParseOptions.Split);
|
||||
return (string) exp.ConvertTo (project, typeof (string));
|
||||
return Expression.ParseAs<string> (file, ParseOptions.Split, project);
|
||||
}
|
||||
|
||||
string GetFullPath ()
|
||||
{
|
||||
string file = EvaluatedProjectPath;
|
||||
if (!Path.IsPathRooted (file) && !String.IsNullOrEmpty (ContainedInProjectFileName))
|
||||
file = Path.Combine (Path.GetDirectoryName (ContainedInProjectFileName), file);
|
||||
|
||||
if (!Path.IsPathRooted (EvaluatedProjectPath)) {
|
||||
string dir = null;
|
||||
if (originalProject == null) {
|
||||
if (project.FullFileName != String.Empty) // Path.GetDirectoryName throws exception on String.Empty
|
||||
dir = Path.GetDirectoryName (project.FullFileName);
|
||||
} else {
|
||||
if (originalProject.FullFileName != String.Empty)
|
||||
dir = Path.GetDirectoryName (originalProject.FullFileName);
|
||||
}
|
||||
if (dir != null)
|
||||
file = Path.Combine (dir, EvaluatedProjectPath);
|
||||
}
|
||||
|
||||
return MSBuildUtils.FromMSBuildPath (file);
|
||||
}
|
||||
|
||||
|
||||
// For every extension path, in order, finds suitable
|
||||
// import filename(s) matching the Import, and calls
|
||||
// @func with them
|
||||
//
|
||||
// func: bool func(importPath, from_source_msg)
|
||||
//
|
||||
// If for an extension path, atleast one file gets imported,
|
||||
// then it stops at that.
|
||||
// So, in case imports like "$(MSBuildExtensionsPath)\foo\*",
|
||||
// for every extension path, it will try to import the "foo\*",
|
||||
// and if atleast one file gets successfully imported, then it
|
||||
// stops at that
|
||||
internal static void ForEachExtensionPathTillFound (XmlElement xmlElement, Project project, ImportedProject importingProject,
|
||||
Func<string, string, bool> func)
|
||||
{
|
||||
string project_attribute = xmlElement.GetAttribute ("Project");
|
||||
string condition_attribute = xmlElement.GetAttribute ("Condition");
|
||||
|
||||
bool has_extn_ref = project_attribute.IndexOf ("$(MSBuildExtensionsPath)") >= 0 ||
|
||||
project_attribute.IndexOf ("$(MSBuildExtensionsPath32)") >= 0 ||
|
||||
project_attribute.IndexOf ("$(MSBuildExtensionsPath64)") >= 0;
|
||||
|
||||
string importingFile = importingProject != null ? importingProject.FullFileName : project.FullFileName;
|
||||
DirectoryInfo base_dir_info = null;
|
||||
if (!String.IsNullOrEmpty (importingFile))
|
||||
base_dir_info = new DirectoryInfo (Path.GetDirectoryName (importingFile));
|
||||
else
|
||||
base_dir_info = new DirectoryInfo (Directory.GetCurrentDirectory ());
|
||||
|
||||
IEnumerable<string> extn_paths = has_extn_ref ? GetExtensionPaths (project) : new string [] {null};
|
||||
try {
|
||||
foreach (string path in extn_paths) {
|
||||
string extn_msg = null;
|
||||
if (has_extn_ref) {
|
||||
project.SetExtensionsPathProperties (path);
|
||||
extn_msg = "from extension path " + path;
|
||||
}
|
||||
|
||||
// do this after setting new Extension properties, as condition might
|
||||
// reference it
|
||||
if (!ConditionParser.ParseAndEvaluate (condition_attribute, project))
|
||||
continue;
|
||||
|
||||
// We stop if atleast one file got imported.
|
||||
// Remaining extension paths are *not* tried
|
||||
bool atleast_one = false;
|
||||
foreach (string importPath in GetImportPathsFromString (project_attribute, project, base_dir_info)) {
|
||||
try {
|
||||
if (func (importPath, extn_msg))
|
||||
atleast_one = true;
|
||||
} catch (Exception e) {
|
||||
throw new InvalidProjectFileException (String.Format (
|
||||
"{0}: Project file could not be imported, it was being imported by " +
|
||||
"{1}: {2}", importPath, importingFile, e.Message), e);
|
||||
}
|
||||
}
|
||||
|
||||
if (atleast_one)
|
||||
return;
|
||||
}
|
||||
} finally {
|
||||
if (has_extn_ref)
|
||||
project.SetExtensionsPathProperties (Project.DefaultExtensionsPath);
|
||||
}
|
||||
}
|
||||
|
||||
// Parses the Project attribute from an Import,
|
||||
// and returns the import filenames that match.
|
||||
// This handles wildcards also
|
||||
static IEnumerable<string> GetImportPathsFromString (string import_string, Project project, DirectoryInfo base_dir_info)
|
||||
{
|
||||
string parsed_import = Expression.ParseAs<string> (import_string, ParseOptions.AllowItemsNoMetadataAndSplit, project);
|
||||
if (parsed_import != null)
|
||||
parsed_import = parsed_import.Trim ();
|
||||
|
||||
if (String.IsNullOrEmpty (parsed_import))
|
||||
throw new InvalidProjectFileException ("The required attribute \"Project\" in Import is empty");
|
||||
|
||||
#if NET_4_0
|
||||
if (DirectoryScanner.HasWildcard (parsed_import)) {
|
||||
var directoryScanner = new DirectoryScanner () {
|
||||
Includes = new ITaskItem [] { new TaskItem (parsed_import) },
|
||||
BaseDirectory = base_dir_info
|
||||
};
|
||||
directoryScanner.Scan ();
|
||||
|
||||
foreach (ITaskItem matchedItem in directoryScanner.MatchedItems)
|
||||
yield return matchedItem.ItemSpec;
|
||||
} else
|
||||
#endif
|
||||
yield return parsed_import;
|
||||
}
|
||||
|
||||
// Gives a list of extensions paths to try for $(MSBuildExtensionsPath),
|
||||
// *in-order*
|
||||
static IEnumerable<string> GetExtensionPaths (Project project)
|
||||
{
|
||||
// This is a *HACK* to support multiple paths for
|
||||
// MSBuildExtensionsPath property. Normally it would
|
||||
// get resolved to a single value, but here we special
|
||||
// case it and try various paths, see the code below
|
||||
//
|
||||
// The property itself will resolve to the default
|
||||
// location though, so you get that in any other part of the
|
||||
// project.
|
||||
|
||||
string envvar = Environment.GetEnvironmentVariable ("MSBuildExtensionsPath");
|
||||
envvar = String.Join (PathSeparatorAsString, new string [] {
|
||||
(envvar ?? String.Empty),
|
||||
// For mac osx, look in the 'External' dir on macosx,
|
||||
// see bug #663180
|
||||
MSBuildUtils.RunningOnMac ? MacOSXExternalXBuildDir : String.Empty,
|
||||
DotConfigExtensionsPath,
|
||||
Project.DefaultExtensionsPath});
|
||||
|
||||
var pathsTable = new Dictionary<string, string> ();
|
||||
foreach (string extn_path in envvar.Split (new char [] {Path.PathSeparator}, StringSplitOptions.RemoveEmptyEntries)) {
|
||||
if (pathsTable.ContainsKey (extn_path))
|
||||
continue;
|
||||
|
||||
if (!Directory.Exists (extn_path)) {
|
||||
project.ParentEngine.LogMessage (MessageImportance.Low, "Extension path '{0}' not found, ignoring.", extn_path);
|
||||
continue;
|
||||
}
|
||||
|
||||
pathsTable [extn_path] = extn_path;
|
||||
yield return extn_path;
|
||||
}
|
||||
}
|
||||
|
||||
public string Condition {
|
||||
get {
|
||||
string s = importElement.GetAttribute ("Condition");
|
||||
@@ -195,6 +264,10 @@ namespace Microsoft.Build.BuildEngine {
|
||||
public string ProjectPath {
|
||||
get { return importElement.GetAttribute ("Project"); }
|
||||
}
|
||||
|
||||
internal string ContainedInProjectFileName {
|
||||
get { return originalProject != null ? originalProject.FullFileName : project.FullFileName; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,19 +37,19 @@ namespace Microsoft.Build.BuildEngine {
|
||||
public class ImportCollection : ICollection, IEnumerable {
|
||||
|
||||
GroupingCollection groupingCollection;
|
||||
Dictionary <string, object> filenames;
|
||||
Dictionary <string, Import> filenames;
|
||||
|
||||
internal ImportCollection (GroupingCollection groupingCollection)
|
||||
{
|
||||
this.groupingCollection = groupingCollection;
|
||||
filenames = new Dictionary <string, object> ();
|
||||
filenames = new Dictionary <string, Import> ();
|
||||
}
|
||||
|
||||
internal void Add (Import import)
|
||||
{
|
||||
if (!filenames.ContainsKey (import.EvaluatedProjectPath)) {
|
||||
groupingCollection.Add (import);
|
||||
filenames.Add (import.EvaluatedProjectPath, null);
|
||||
filenames.Add (import.EvaluatedProjectPath, import);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +77,11 @@ namespace Microsoft.Build.BuildEngine {
|
||||
{
|
||||
return filenames.ContainsKey (import.EvaluatedProjectPath);
|
||||
}
|
||||
|
||||
internal bool TryGetImport (Import keyImport, out Import valueImport)
|
||||
{
|
||||
return filenames.TryGetValue (keyImport.EvaluatedProjectPath, out valueImport);
|
||||
}
|
||||
|
||||
public void CopyTo (Import[] array, int index)
|
||||
{
|
||||
|
||||
@@ -57,9 +57,6 @@ namespace Microsoft.Build.BuildEngine {
|
||||
lastWrite = File.GetLastWriteTime (filename);
|
||||
fullFileName = filename;
|
||||
}
|
||||
catch (Exception) {
|
||||
throw;
|
||||
}
|
||||
finally {
|
||||
sr.Close ();
|
||||
}
|
||||
|
||||
@@ -47,15 +47,21 @@ namespace Microsoft.Build.BuildEngine
|
||||
else
|
||||
return String.Format (unformatted, args);
|
||||
}
|
||||
|
||||
|
||||
public static void LogError (this Engine engine, string message,
|
||||
params object[] messageArgs)
|
||||
{
|
||||
engine.LogErrorWithFilename (null, message, messageArgs);
|
||||
}
|
||||
|
||||
public static void LogErrorWithFilename (this Engine engine, string filename, string message,
|
||||
params object[] messageArgs)
|
||||
{
|
||||
if (message == null)
|
||||
throw new ArgumentNullException ("message");
|
||||
|
||||
BuildErrorEventArgs beea = new BuildErrorEventArgs (
|
||||
null, null, null, 0, 0, 0, 0, FormatString (message, messageArgs),
|
||||
null, null, filename, 0, 0, 0, 0, FormatString (message, messageArgs),
|
||||
null, null);
|
||||
engine.EventSource.FireErrorRaised (engine, beea);
|
||||
}
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
//
|
||||
// Author:
|
||||
// Marek Sieradzki ([email protected])
|
||||
// Ankit Jain ([email protected])
|
||||
//
|
||||
// (C) 2005 Marek Sieradzki
|
||||
// Copyright 2011 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
|
||||
@@ -32,6 +34,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
@@ -76,6 +79,11 @@ namespace Microsoft.Build.BuildEngine {
|
||||
bool building;
|
||||
BuildSettings current_settings;
|
||||
Stack<Batch> batches;
|
||||
|
||||
// This is used to keep track of "current" file,
|
||||
// which is then used to set the reserved properties
|
||||
// $(MSBuildThisFile*)
|
||||
Stack<string> this_file_property_stack;
|
||||
ProjectLoadSettings project_load_settings;
|
||||
|
||||
|
||||
@@ -113,6 +121,7 @@ namespace Microsoft.Build.BuildEngine {
|
||||
initialTargets = new List<string> ();
|
||||
defaultTargets = new string [0];
|
||||
batches = new Stack<Batch> ();
|
||||
this_file_property_stack = new Stack<string> ();
|
||||
|
||||
globalProperties = new BuildPropertyGroup (null, this, null, false);
|
||||
foreach (BuildProperty bp in parentEngine.GlobalProperties)
|
||||
@@ -135,8 +144,7 @@ namespace Microsoft.Build.BuildEngine {
|
||||
if (!String.IsNullOrEmpty (importCondition))
|
||||
importElement.SetAttribute ("Condition", importCondition);
|
||||
|
||||
Import import = new Import (importElement, this, null);
|
||||
imports.Add (import);
|
||||
AddImport (importElement, null, false);
|
||||
MarkProjectAsDirty ();
|
||||
NeedToReevaluate ();
|
||||
}
|
||||
@@ -268,7 +276,7 @@ namespace Microsoft.Build.BuildEngine {
|
||||
{
|
||||
return Build (targetNames, targetOutputs, BuildSettings.None);
|
||||
}
|
||||
|
||||
|
||||
[MonoTODO ("Not tested")]
|
||||
public bool Build (string [] targetNames,
|
||||
IDictionary targetOutputs,
|
||||
@@ -289,6 +297,13 @@ namespace Microsoft.Build.BuildEngine {
|
||||
Directory.SetCurrentDirectory (Path.GetDirectoryName (fullFileName));
|
||||
building = true;
|
||||
result = BuildInternal (targetNames, targetOutputs, buildFlags);
|
||||
} catch (InvalidProjectFileException ie) {
|
||||
ParentEngine.LogErrorWithFilename (fullFileName, ie.Message);
|
||||
ParentEngine.LogMessage (MessageImportance.Low, String.Format ("{0}: {1}", fullFileName, ie.ToString ()));
|
||||
} catch (Exception e) {
|
||||
ParentEngine.LogErrorWithFilename (fullFileName, e.Message);
|
||||
ParentEngine.LogMessage (MessageImportance.Low, String.Format ("{0}: {1}", fullFileName, e.ToString ()));
|
||||
throw;
|
||||
} finally {
|
||||
ParentEngine.EndProjectBuild (this, result);
|
||||
current_settings = BuildSettings.None;
|
||||
@@ -308,7 +323,11 @@ namespace Microsoft.Build.BuildEngine {
|
||||
needToReevaluate = false;
|
||||
Reevaluate ();
|
||||
}
|
||||
|
||||
|
||||
#if NET_4_0
|
||||
ProcessBeforeAndAfterTargets ();
|
||||
#endif
|
||||
|
||||
if (targetNames == null || targetNames.Length == 0) {
|
||||
if (defaultTargets != null && defaultTargets.Length != 0) {
|
||||
targetNames = defaultTargets;
|
||||
@@ -332,9 +351,13 @@ namespace Microsoft.Build.BuildEngine {
|
||||
initialTargetsBuilt = true;
|
||||
}
|
||||
|
||||
foreach (string target in targetNames)
|
||||
foreach (string target in targetNames) {
|
||||
if (target == null)
|
||||
throw new ArgumentNullException ("Target name cannot be null");
|
||||
|
||||
if (!BuildTarget (target.Trim (), targetOutputs))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -382,6 +405,44 @@ namespace Microsoft.Build.BuildEngine {
|
||||
return sb.ToString ();
|
||||
}
|
||||
|
||||
#if NET_4_0
|
||||
void ProcessBeforeAndAfterTargets ()
|
||||
{
|
||||
var beforeTable = Targets.AsIEnumerable ()
|
||||
.SelectMany (target => GetTargetNamesFromString (target.BeforeTargets),
|
||||
(target, before_target) => new {before_target, name = target.Name})
|
||||
.ToLookup (x => x.before_target, x => x.name)
|
||||
.ToDictionary (x => x.Key, x => x.Distinct ().ToList ());
|
||||
|
||||
foreach (var pair in beforeTable) {
|
||||
if (targets.Exists (pair.Key))
|
||||
targets [pair.Key].BeforeThisTargets = pair.Value;
|
||||
else
|
||||
LogWarning (FullFileName, "Target '{0}', not found in the project", pair.Key);
|
||||
}
|
||||
|
||||
var afterTable = Targets.AsIEnumerable ()
|
||||
.SelectMany (target => GetTargetNamesFromString (target.AfterTargets),
|
||||
(target, after_target) => new {after_target, name = target.Name})
|
||||
.ToLookup (x => x.after_target, x => x.name)
|
||||
.ToDictionary (x => x.Key, x => x.Distinct ().ToList ());
|
||||
|
||||
foreach (var pair in afterTable) {
|
||||
if (targets.Exists (pair.Key))
|
||||
targets [pair.Key].AfterThisTargets = pair.Value;
|
||||
else
|
||||
LogWarning (FullFileName, "Target '{0}', not found in the project", pair.Key);
|
||||
}
|
||||
}
|
||||
|
||||
string[] GetTargetNamesFromString (string targets)
|
||||
{
|
||||
Expression expr = new Expression ();
|
||||
expr.Parse (targets, ParseOptions.AllowItemsNoMetadataAndSplit);
|
||||
return (string []) expr.ConvertTo (this, typeof (string []));
|
||||
}
|
||||
#endif
|
||||
|
||||
[MonoTODO]
|
||||
public string [] GetConditionedPropertyValues (string propertyName)
|
||||
{
|
||||
@@ -463,10 +524,12 @@ namespace Microsoft.Build.BuildEngine {
|
||||
"projectFileName");
|
||||
|
||||
this.fullFileName = Utilities.FromMSBuildPath (Path.GetFullPath (projectFileName));
|
||||
PushThisFileProperty (fullFileName);
|
||||
|
||||
string filename = fullFileName;
|
||||
if (String.Compare (Path.GetExtension (fullFileName), ".sln", true) == 0) {
|
||||
Project tmp_project = ParentEngine.CreateNewProject ();
|
||||
tmp_project.FullFileName = filename;
|
||||
SolutionParser sln_parser = new SolutionParser ();
|
||||
sln_parser.ParseSolution (fullFileName, tmp_project, delegate (int errorNumber, string message) {
|
||||
LogWarning (filename, message);
|
||||
@@ -872,7 +935,7 @@ namespace Microsoft.Build.BuildEngine {
|
||||
AddUsingTask (xe, ip);
|
||||
break;
|
||||
case "Import":
|
||||
AddImport (xe, ip);
|
||||
AddImport (xe, ip, true);
|
||||
break;
|
||||
case "ItemGroup":
|
||||
AddItemGroup (xe, ip);
|
||||
@@ -881,7 +944,7 @@ namespace Microsoft.Build.BuildEngine {
|
||||
AddPropertyGroup (xe, ip);
|
||||
break;
|
||||
case "Choose":
|
||||
AddChoose (xe);
|
||||
AddChoose (xe, ip);
|
||||
break;
|
||||
default:
|
||||
throw new InvalidProjectFileException (String.Format ("Invalid element '{0}' in project file.", xe.Name));
|
||||
@@ -922,6 +985,7 @@ namespace Microsoft.Build.BuildEngine {
|
||||
BuildProperty bp;
|
||||
|
||||
evaluatedProperties = new BuildPropertyGroup (null, null, null, true);
|
||||
conditionedProperties = new Dictionary<string, List<string>> ();
|
||||
|
||||
foreach (BuildProperty gp in GlobalProperties) {
|
||||
bp = new BuildProperty (gp.Name, gp.Value, PropertyType.Global);
|
||||
@@ -960,10 +1024,9 @@ namespace Microsoft.Build.BuildEngine {
|
||||
throw new Exception (String.Format ("Invalid tools version '{0}', no tools path set for this.", effective_tools_version));
|
||||
evaluatedProperties.AddProperty (new BuildProperty ("MSBuildBinPath", toolsPath, PropertyType.Reserved));
|
||||
evaluatedProperties.AddProperty (new BuildProperty ("MSBuildToolsPath", toolsPath, PropertyType.Reserved));
|
||||
evaluatedProperties.AddProperty (new BuildProperty ("MSBuildToolsRoot", Path.GetDirectoryName (toolsPath), PropertyType.Reserved));
|
||||
evaluatedProperties.AddProperty (new BuildProperty ("MSBuildToolsVersion", effective_tools_version, PropertyType.Reserved));
|
||||
evaluatedProperties.AddProperty (new BuildProperty ("MSBuildExtensionsPath", ExtensionsPath, PropertyType.Reserved));
|
||||
evaluatedProperties.AddProperty (new BuildProperty ("MSBuildExtensionsPath32", ExtensionsPath, PropertyType.Reserved));
|
||||
evaluatedProperties.AddProperty (new BuildProperty ("MSBuildExtensionsPath64", ExtensionsPath, PropertyType.Reserved));
|
||||
SetExtensionsPathProperties (DefaultExtensionsPath);
|
||||
evaluatedProperties.AddProperty (new BuildProperty ("MSBuildProjectDefaultTargets", DefaultTargets, PropertyType.Reserved));
|
||||
evaluatedProperties.AddProperty (new BuildProperty ("OS", OS, PropertyType.Environment));
|
||||
|
||||
@@ -975,6 +1038,20 @@ namespace Microsoft.Build.BuildEngine {
|
||||
projectDir = Path.GetDirectoryName (FullFileName);
|
||||
|
||||
evaluatedProperties.AddProperty (new BuildProperty ("MSBuildProjectDirectory", projectDir, PropertyType.Reserved));
|
||||
|
||||
if (this_file_property_stack.Count > 0)
|
||||
// Just re-inited the properties, but according to the stack,
|
||||
// we should have a MSBuild*This* property set
|
||||
SetMSBuildThisFileProperties (this_file_property_stack.Peek ());
|
||||
}
|
||||
|
||||
internal void SetExtensionsPathProperties (string extn_path)
|
||||
{
|
||||
if (!String.IsNullOrEmpty (extn_path)) {
|
||||
evaluatedProperties.AddProperty (new BuildProperty ("MSBuildExtensionsPath", extn_path, PropertyType.Reserved));
|
||||
evaluatedProperties.AddProperty (new BuildProperty ("MSBuildExtensionsPath32", extn_path, PropertyType.Reserved));
|
||||
evaluatedProperties.AddProperty (new BuildProperty ("MSBuildExtensionsPath64", extn_path, PropertyType.Reserved));
|
||||
}
|
||||
}
|
||||
|
||||
// precedence:
|
||||
@@ -1023,23 +1100,52 @@ namespace Microsoft.Build.BuildEngine {
|
||||
usingTask = new UsingTask (xmlElement, this, importedProject);
|
||||
UsingTasks.Add (usingTask);
|
||||
}
|
||||
|
||||
void AddImport (XmlElement xmlElement, ImportedProject importingProject)
|
||||
|
||||
void AddImport (XmlElement xmlElement, ImportedProject importingProject, bool evaluate_properties)
|
||||
{
|
||||
// eval all the properties etc till the import
|
||||
groupingCollection.Evaluate (EvaluationType.Property);
|
||||
if (evaluate_properties)
|
||||
groupingCollection.Evaluate (EvaluationType.Property);
|
||||
|
||||
Import import = new Import (xmlElement, this, importingProject);
|
||||
if (!ConditionParser.ParseAndEvaluate (import.Condition, this))
|
||||
return;
|
||||
try {
|
||||
PushThisFileProperty (importingProject != null ? importingProject.FullFileName : FullFileName);
|
||||
|
||||
if (Imports.Contains (import)) {
|
||||
LogWarning (importingProject != null ? importingProject.FullFileName : fullFileName,
|
||||
"A circular reference was found involving the import of {0}. Only" +
|
||||
" the first import of this file will be used, ignoring others.",
|
||||
import.ProjectPath);
|
||||
string project_attribute = xmlElement.GetAttribute ("Project");
|
||||
if (String.IsNullOrEmpty (project_attribute))
|
||||
throw new InvalidProjectFileException ("The required attribute \"Project\" is missing from element <Import>.");
|
||||
|
||||
return;
|
||||
Import.ForEachExtensionPathTillFound (xmlElement, this, importingProject,
|
||||
(importPath, from_source_msg) => AddSingleImport (xmlElement, importPath, importingProject, from_source_msg));
|
||||
} finally {
|
||||
PopThisFileProperty ();
|
||||
}
|
||||
}
|
||||
|
||||
bool AddSingleImport (XmlElement xmlElement, string projectPath, ImportedProject importingProject, string from_source_msg)
|
||||
{
|
||||
Import import = new Import (xmlElement, projectPath, this, importingProject);
|
||||
if (!ConditionParser.ParseAndEvaluate (import.Condition, this)) {
|
||||
ParentEngine.LogMessage (MessageImportance.Low,
|
||||
"Not importing project '{0}' as the condition '{1}' is false",
|
||||
import.ProjectPath, import.Condition);
|
||||
return false;
|
||||
}
|
||||
|
||||
Import existingImport;
|
||||
if (Imports.TryGetImport (import, out existingImport)) {
|
||||
if (importingProject == null)
|
||||
LogWarning (fullFileName,
|
||||
"Cannot import project '{0}' again. It was already imported by " +
|
||||
"'{1}'. Ignoring.",
|
||||
projectPath, existingImport.ContainedInProjectFileName);
|
||||
else
|
||||
LogWarning (importingProject != null ? importingProject.FullFileName : fullFileName,
|
||||
"A circular reference was found involving the import of '{0}'. " +
|
||||
"It was earlier imported by '{1}'. Only " +
|
||||
"the first import of this file will be used, ignoring others.",
|
||||
import.EvaluatedProjectPath, existingImport.ContainedInProjectFileName);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (String.Compare (fullFileName, import.EvaluatedProjectPath) == 0) {
|
||||
@@ -1047,13 +1153,19 @@ namespace Microsoft.Build.BuildEngine {
|
||||
"The main project file was imported here, which creates a circular " +
|
||||
"reference. Ignoring this import.");
|
||||
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
Imports.Add (import);
|
||||
string importingFile = importingProject != null ? importingProject.FullFileName : FullFileName;
|
||||
ParentEngine.LogMessage (MessageImportance.Low,
|
||||
"{0}: Importing project {1} {2}",
|
||||
importingFile, import.EvaluatedProjectPath, from_source_msg);
|
||||
|
||||
import.Evaluate (project_load_settings == ProjectLoadSettings.IgnoreMissingImports);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void AddItemGroup (XmlElement xmlElement, ImportedProject importedProject)
|
||||
{
|
||||
BuildItemGroup big = new BuildItemGroup (xmlElement, this, importedProject, false);
|
||||
@@ -1066,9 +1178,9 @@ namespace Microsoft.Build.BuildEngine {
|
||||
PropertyGroups.Add (bpg);
|
||||
}
|
||||
|
||||
void AddChoose (XmlElement xmlElement)
|
||||
void AddChoose (XmlElement xmlElement, ImportedProject importedProject)
|
||||
{
|
||||
BuildChoose bc = new BuildChoose (xmlElement, this);
|
||||
BuildChoose bc = new BuildChoose (xmlElement, this, importedProject);
|
||||
groupingCollection.Add (bc);
|
||||
}
|
||||
|
||||
@@ -1261,6 +1373,41 @@ namespace Microsoft.Build.BuildEngine {
|
||||
return default (T);
|
||||
}
|
||||
|
||||
// Used for MSBuild*This* set of properties
|
||||
internal void PushThisFileProperty (string full_filename)
|
||||
{
|
||||
string last_file = this_file_property_stack.Count == 0 ? String.Empty : this_file_property_stack.Peek ();
|
||||
this_file_property_stack.Push (full_filename);
|
||||
if (last_file != full_filename)
|
||||
// first time, or different from previous one
|
||||
SetMSBuildThisFileProperties (full_filename);
|
||||
}
|
||||
|
||||
internal void PopThisFileProperty ()
|
||||
{
|
||||
string last_file = this_file_property_stack.Pop ();
|
||||
if (this_file_property_stack.Count > 0 && last_file != this_file_property_stack.Peek ())
|
||||
SetMSBuildThisFileProperties (this_file_property_stack.Peek ());
|
||||
}
|
||||
|
||||
void SetMSBuildThisFileProperties (string full_filename)
|
||||
{
|
||||
if (String.IsNullOrEmpty (full_filename))
|
||||
return;
|
||||
|
||||
evaluatedProperties.AddProperty (new BuildProperty ("MSBuildThisFile", Path.GetFileName (full_filename), PropertyType.Reserved));
|
||||
evaluatedProperties.AddProperty (new BuildProperty ("MSBuildThisFileFullPath", full_filename, PropertyType.Reserved));
|
||||
evaluatedProperties.AddProperty (new BuildProperty ("MSBuildThisFileName", Path.GetFileNameWithoutExtension (full_filename), PropertyType.Reserved));
|
||||
evaluatedProperties.AddProperty (new BuildProperty ("MSBuildThisFileExtension", Path.GetExtension (full_filename), PropertyType.Reserved));
|
||||
|
||||
string project_dir = Path.GetDirectoryName (full_filename) + Path.DirectorySeparatorChar;
|
||||
evaluatedProperties.AddProperty (new BuildProperty ("MSBuildThisFileDirectory", project_dir, PropertyType.Reserved));
|
||||
evaluatedProperties.AddProperty (new BuildProperty ("MSBuildThisFileDirectoryNoRoot",
|
||||
project_dir.Substring (Path.GetPathRoot (project_dir).Length),
|
||||
PropertyType.Reserved));
|
||||
}
|
||||
|
||||
|
||||
internal void LogWarning (string filename, string message, params object[] messageArgs)
|
||||
{
|
||||
BuildWarningEventArgs bwea = new BuildWarningEventArgs (
|
||||
@@ -1278,7 +1425,7 @@ namespace Microsoft.Build.BuildEngine {
|
||||
ParentEngine.EventSource.FireErrorRaised (this, beea);
|
||||
}
|
||||
|
||||
static string ExtensionsPath {
|
||||
internal static string DefaultExtensionsPath {
|
||||
get {
|
||||
if (extensions_path == null) {
|
||||
// NOTE: code from mcs/tools/gacutil/driver.cs
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
@@ -122,6 +123,16 @@ namespace Microsoft.Build.BuildEngine {
|
||||
}
|
||||
|
||||
bool Build (string built_targets_key, out bool executeOnErrors)
|
||||
{
|
||||
project.PushThisFileProperty (TargetFile);
|
||||
try {
|
||||
return BuildActual (built_targets_key, out executeOnErrors);
|
||||
} finally {
|
||||
project.PopThisFileProperty ();
|
||||
}
|
||||
}
|
||||
|
||||
bool BuildActual (string built_targets_key, out bool executeOnErrors)
|
||||
{
|
||||
bool result = false;
|
||||
executeOnErrors = false;
|
||||
@@ -147,14 +158,15 @@ namespace Microsoft.Build.BuildEngine {
|
||||
|
||||
try {
|
||||
buildState = BuildState.Started;
|
||||
result = BuildDependencies (GetDependencies (), out executeOnErrors);
|
||||
|
||||
if (!result && executeOnErrors)
|
||||
ExecuteOnErrors ();
|
||||
|
||||
if (result)
|
||||
// deps built fine, do main build
|
||||
result = DoBuild (out executeOnErrors);
|
||||
#if NET_4_0
|
||||
result = BuildDependencies (out executeOnErrors) &&
|
||||
BuildBeforeThisTargets (out executeOnErrors) &&
|
||||
DoBuild (out executeOnErrors) && // deps & Before targets built fine, do main build
|
||||
BuildAfterThisTargets (out executeOnErrors);
|
||||
#else
|
||||
result = BuildDependencies (out executeOnErrors) && DoBuild (out executeOnErrors);
|
||||
#endif
|
||||
|
||||
buildState = BuildState.Finished;
|
||||
} catch (Exception e) {
|
||||
@@ -164,41 +176,80 @@ namespace Microsoft.Build.BuildEngine {
|
||||
project.PopBatch ();
|
||||
}
|
||||
|
||||
project.ParentEngine.BuiltTargetsOutputByName [built_targets_key] = (ITaskItem[]) Outputs.Clone ();
|
||||
ITaskItem[] outputs = (ITaskItem[]) OutputsAsITaskItems.Clone ();
|
||||
foreach (ITaskItem item in outputs) {
|
||||
item.SetMetadata ("MSBuildProjectFile", TargetFile);
|
||||
item.SetMetadata ("MSBuildTargetName", Name);
|
||||
}
|
||||
project.ParentEngine.BuiltTargetsOutputByName [built_targets_key] = outputs;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
List <Target> GetDependencies ()
|
||||
{
|
||||
List <Target> list = new List <Target> ();
|
||||
Target t;
|
||||
string [] targetNames;
|
||||
Expression deps;
|
||||
|
||||
if (DependsOnTargets != String.Empty) {
|
||||
deps = new Expression ();
|
||||
deps.Parse (DependsOnTargets, ParseOptions.AllowItemsNoMetadataAndSplit);
|
||||
targetNames = (string []) deps.ConvertTo (Project, typeof (string []));
|
||||
foreach (string dep_name in targetNames) {
|
||||
t = project.Targets [dep_name.Trim ()];
|
||||
if (t == null)
|
||||
throw new InvalidProjectFileException (String.Format (
|
||||
"Target '{0}', a dependency of target '{1}', not found.",
|
||||
dep_name.Trim (), Name));
|
||||
list.Add (t);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
bool BuildDependencies (List <Target> deps, out bool executeOnErrors)
|
||||
bool BuildDependencies (out bool executeOnErrors)
|
||||
{
|
||||
executeOnErrors = false;
|
||||
foreach (Target t in deps) {
|
||||
|
||||
if (String.IsNullOrEmpty (DependsOnTargets))
|
||||
return true;
|
||||
|
||||
var expr = new Expression ();
|
||||
expr.Parse (DependsOnTargets, ParseOptions.AllowItemsNoMetadataAndSplit);
|
||||
string [] targetNames = (string []) expr.ConvertTo (Project, typeof (string []));
|
||||
|
||||
bool result = BuildOtherTargets (targetNames,
|
||||
tname => engine.LogError ("Target '{0}', a dependency of target '{1}', not found.",
|
||||
tname, Name),
|
||||
out executeOnErrors);
|
||||
if (!result && executeOnErrors)
|
||||
ExecuteOnErrors ();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#if NET_4_0
|
||||
bool BuildBeforeThisTargets (out bool executeOnErrors)
|
||||
{
|
||||
executeOnErrors = false;
|
||||
bool result = BuildOtherTargets (BeforeThisTargets, null, out executeOnErrors);
|
||||
if (!result && executeOnErrors)
|
||||
ExecuteOnErrors ();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool BuildAfterThisTargets (out bool executeOnErrors)
|
||||
{
|
||||
executeOnErrors = false;
|
||||
//missing_target handler not required as these are picked from actual target's
|
||||
//"Before/AfterTargets attributes!
|
||||
bool result = BuildOtherTargets (AfterThisTargets, null, out executeOnErrors);
|
||||
if (!result && executeOnErrors)
|
||||
ExecuteOnErrors ();
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool BuildOtherTargets (IEnumerable<string> targetNames, Action<string> missing_target, out bool executeOnErrors)
|
||||
{
|
||||
executeOnErrors = false;
|
||||
if (targetNames == null)
|
||||
// nothing to build
|
||||
return true;
|
||||
|
||||
foreach (string target_name in targetNames) {
|
||||
var t = project.Targets [target_name.Trim ()];
|
||||
if (t == null) {
|
||||
if (missing_target != null)
|
||||
missing_target (target_name);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (t.BuildState == BuildState.NotStarted)
|
||||
if (!t.Build (null, out executeOnErrors))
|
||||
return false;
|
||||
|
||||
if (t.BuildState == BuildState.Started)
|
||||
throw new InvalidProjectFileException ("Cycle in target dependencies detected");
|
||||
}
|
||||
@@ -311,6 +362,19 @@ namespace Microsoft.Build.BuildEngine {
|
||||
}
|
||||
}
|
||||
|
||||
#if NET_4_0
|
||||
internal string BeforeTargets {
|
||||
get { return targetElement.GetAttribute ("BeforeTargets"); }
|
||||
}
|
||||
|
||||
internal string AfterTargets {
|
||||
get { return targetElement.GetAttribute ("AfterTargets"); }
|
||||
}
|
||||
|
||||
internal List<string> BeforeThisTargets { get; set; }
|
||||
internal List<string> AfterThisTargets { get; set; }
|
||||
#endif
|
||||
|
||||
internal List<BuildTask> BuildTasks {
|
||||
get { return buildTasks; }
|
||||
}
|
||||
@@ -323,7 +387,12 @@ namespace Microsoft.Build.BuildEngine {
|
||||
get { return buildState; }
|
||||
}
|
||||
|
||||
internal ITaskItem [] Outputs {
|
||||
public string Outputs {
|
||||
get { return targetElement.GetAttribute ("Outputs"); }
|
||||
set { targetElement.SetAttribute ("Outputs", value); }
|
||||
}
|
||||
|
||||
ITaskItem [] OutputsAsITaskItems {
|
||||
get {
|
||||
string outputs = targetElement.GetAttribute ("Outputs");
|
||||
if (outputs == String.Empty)
|
||||
|
||||
@@ -86,6 +86,12 @@ namespace Microsoft.Build.BuildEngine {
|
||||
yield return kvp.Value;
|
||||
}
|
||||
|
||||
internal IEnumerable<Target> AsIEnumerable ()
|
||||
{
|
||||
foreach (KeyValuePair <string, Target> kvp in targetsByName)
|
||||
yield return kvp.Value;
|
||||
}
|
||||
|
||||
public void RemoveTarget (Target targetToRemove)
|
||||
{
|
||||
if (targetToRemove == null)
|
||||
|
||||
@@ -177,10 +177,6 @@ namespace Microsoft.Build.BuildEngine {
|
||||
throw new InvalidProjectFileException ("This is not output property.");
|
||||
|
||||
o = propertyInfo.GetValue (task, null);
|
||||
// FIXME: maybe we should throw an exception here?
|
||||
if (o == null)
|
||||
continue;
|
||||
|
||||
if (itemName != String.Empty) {
|
||||
PublishItemGroup (propertyInfo, o, itemName);
|
||||
} else {
|
||||
@@ -198,6 +194,11 @@ namespace Microsoft.Build.BuildEngine {
|
||||
object o,
|
||||
string propertyName)
|
||||
{
|
||||
if (o == null) {
|
||||
parentProject.EvaluatedProperties.RemoveProperty (propertyName);
|
||||
return;
|
||||
}
|
||||
|
||||
BuildProperty bp;
|
||||
try {
|
||||
bp = ChangeType.ToBuildProperty (o, propertyInfo.PropertyType, propertyName);
|
||||
@@ -214,6 +215,9 @@ namespace Microsoft.Build.BuildEngine {
|
||||
object o,
|
||||
string itemName)
|
||||
{
|
||||
if (o == null)
|
||||
return;
|
||||
|
||||
BuildItemGroup newItems;
|
||||
try {
|
||||
newItems = ChangeType.ToBuildItemGroup (o, propertyInfo.PropertyType, itemName);
|
||||
|
||||
@@ -783,7 +783,6 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
|
||||
logger.DumpMessages ();
|
||||
Assert.Fail ("Build failed");
|
||||
}
|
||||
logger.DumpMessages ();
|
||||
|
||||
CheckMetadata (project, "A", "Meta", new string[] { "@(B)", "" }, "K1");
|
||||
CheckEvaluatedMetadata (project, "A", "Meta", new string[] { "", "" }, "K2");
|
||||
|
||||
+4
-2
@@ -374,9 +374,11 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
|
||||
|
||||
xd = new XmlDocument ();
|
||||
xd.LoadXml (project.Xml);
|
||||
Console.WriteLine(project.Xml);
|
||||
node = xd.SelectSingleNode ("tns:Project/tns:PropertyGroup/tns:XmlProp/tns:XmlStuff", TestNamespaceManager.NamespaceManager);
|
||||
Assert.IsNotNull (node, "A1");
|
||||
if (node == null) {
|
||||
Console.WriteLine (project.Xml);
|
||||
Assert.Fail ("Expected node to be non-null");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -342,6 +342,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
|
||||
bt [0].AddOutputItem ("Property", "ItemName");
|
||||
project.Build ("T");
|
||||
|
||||
Assert.IsNotNull (project.EvaluatedItems [0], "No items found");
|
||||
Assert.AreEqual ("ItemName", project.EvaluatedItems [0].Name, "A1");
|
||||
Assert.AreEqual ("some_text", project.EvaluatedItems [0].FinalItemSpec, "A2");
|
||||
}
|
||||
|
||||
@@ -209,5 +209,62 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
|
||||
project.LoadXml (documentString);
|
||||
}
|
||||
|
||||
#if NET_4_0
|
||||
[Test]
|
||||
public void TestImportWildcard ()
|
||||
{
|
||||
string main_project_xml = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""4.0"">
|
||||
<ItemGroup>
|
||||
<FooItem Include=""From main.proj""/>
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project=""tmp\*""/>
|
||||
|
||||
<Target Name=""Build"">
|
||||
<Message Text=""FooItem: @(FooItem)""/>
|
||||
</Target>
|
||||
</Project>";
|
||||
|
||||
string other_project_xml = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""4.0"">
|
||||
<ItemGroup>
|
||||
<FooItem Include=""From $(MSBuildThisFile)""/>
|
||||
</ItemGroup>
|
||||
</Project>";
|
||||
|
||||
Engine engine = new Engine (Consts.BinPath);
|
||||
MonoTests.Microsoft.Build.Tasks.TestMessageLogger logger =
|
||||
new MonoTests.Microsoft.Build.Tasks.TestMessageLogger ();
|
||||
engine.RegisterLogger (logger);
|
||||
|
||||
string base_dir = Path.GetFullPath (Path.Combine ("Test", "resources")) + Path.DirectorySeparatorChar;
|
||||
string tmp_dir = Path.GetFullPath (Path.Combine (base_dir, "tmp")) + Path.DirectorySeparatorChar;
|
||||
|
||||
string main_project = Path.Combine (base_dir, "main.proj");
|
||||
string first_project = Path.Combine (tmp_dir, "first.proj");
|
||||
string second_project = Path.Combine (tmp_dir, "second.proj");
|
||||
|
||||
Directory.CreateDirectory (tmp_dir);
|
||||
File.WriteAllText (main_project, main_project_xml);
|
||||
File.WriteAllText (first_project, other_project_xml);
|
||||
File.WriteAllText (second_project, other_project_xml);
|
||||
|
||||
Project project = engine.CreateNewProject ();
|
||||
project.Load (main_project);
|
||||
try {
|
||||
Assert.IsTrue (project.Build ("Build"), "Build failed");
|
||||
|
||||
logger.CheckLoggedMessageHead ("FooItem: From main.proj;From first.proj;From second.proj", "A1");
|
||||
Assert.AreEqual (0, logger.NormalMessageCount, "Unexpected extra messages found");
|
||||
} catch {
|
||||
logger.DumpMessages ();
|
||||
throw;
|
||||
} finally {
|
||||
File.Delete (main_project);
|
||||
File.Delete (first_project);
|
||||
File.Delete (second_project);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
@@ -111,7 +111,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
|
||||
Assert.AreEqual (false, project.IsDirty, "A4");
|
||||
Assert.AreEqual (false, project.IsValidated, "A5");
|
||||
Assert.AreEqual (engine, project.ParentEngine, "A6");
|
||||
Console.WriteLine ("time: {0} p.t: {1}", time, project.TimeOfLastDirty);
|
||||
//Console.WriteLine ("time: {0} p.t: {1}", time, project.TimeOfLastDirty);
|
||||
Assert.IsTrue (time <= project.TimeOfLastDirty, "A7");
|
||||
Assert.IsTrue (String.Empty != project.Xml, "A8");
|
||||
return;
|
||||
@@ -1487,7 +1487,6 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
|
||||
logger.DumpMessages ();
|
||||
Assert.Fail ("A1: Build failed");
|
||||
}
|
||||
logger.DumpMessages ();
|
||||
BuildItemGroup include = project.GetEvaluatedItemsByName ("FinalList");
|
||||
Assert.AreEqual (3, include.Count, "A2");
|
||||
}
|
||||
@@ -1831,6 +1830,97 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMSBuildThisProperties ()
|
||||
{
|
||||
Engine engine = new Engine (Consts.BinPath);
|
||||
Project project = engine.CreateNewProject ();
|
||||
|
||||
string base_dir = Path.GetFullPath (Path.Combine ("Test", "resources")) + Path.DirectorySeparatorChar;
|
||||
string tmp_dir = Path.GetFullPath (Path.Combine (base_dir, "tmp")) + Path.DirectorySeparatorChar;
|
||||
|
||||
string first_project = Path.Combine (base_dir, "first.proj");
|
||||
string second_project = Path.Combine (tmp_dir, "second.proj");
|
||||
string third_project = Path.Combine (tmp_dir, "third.proj");
|
||||
|
||||
string first = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" " + Consts.ToolsVersionString + @">
|
||||
<PropertyGroup>
|
||||
<FooInMain>$(MSBuildThisFileDirectory)</FooInMain>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ItemInMain Include=""$(MSBuildThisFileFullPath)"" />
|
||||
</ItemGroup>
|
||||
<Import Project=""tmp\second.proj""/>
|
||||
</Project>";
|
||||
|
||||
string second = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" " + Consts.ToolsVersionString + @">
|
||||
<PropertyGroup>
|
||||
<FooInImport1>$(MSBuildThisFileDirectory)</FooInImport1>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<FooInImport2>$(MSBuildThisFileDirectory)</FooInImport2>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ItemInImport1 Include=""$(MSBuildThisFileFullPath)"" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project=""third.proj""/>
|
||||
</Project>";
|
||||
|
||||
string third = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" " + Consts.ToolsVersionString + @">
|
||||
<PropertyGroup>
|
||||
<FooInTwo>$(MSBuildThisFileFullPath)</FooInTwo>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ItemInTwo Include=""$(MSBuildThisFileFullPath)"" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name=""TargetInTwo"">
|
||||
<Message Text=""FooInMain: $(FooInMain)""/>
|
||||
<Message Text=""FooInImport1: $(FooInImport1)""/>
|
||||
<Message Text=""FooInImport2: $(FooInImport2)""/>
|
||||
<Message Text=""FooInTwo: $(FooInTwo)""/>
|
||||
|
||||
<Message Text=""ItemInMain: %(ItemInMain.Identity)""/>
|
||||
<Message Text=""ItemInImport1: %(ItemInImport1.Identity)""/>
|
||||
<Message Text=""ItemInTwo: %(ItemInTwo.Identity)""/>
|
||||
<Message Text=""Full path: $(MSBuildThisFileFullPath)""/>
|
||||
</Target>
|
||||
</Project>";
|
||||
|
||||
File.WriteAllText (first_project, first);
|
||||
|
||||
Directory.CreateDirectory (Path.Combine (base_dir, "tmp"));
|
||||
File.WriteAllText (second_project, second);
|
||||
File.WriteAllText (third_project, third);
|
||||
|
||||
MonoTests.Microsoft.Build.Tasks.TestMessageLogger logger =
|
||||
new MonoTests.Microsoft.Build.Tasks.TestMessageLogger ();
|
||||
engine.RegisterLogger (logger);
|
||||
|
||||
project.Load (first_project);
|
||||
try {
|
||||
Assert.IsTrue (project.Build (), "Build failed");
|
||||
|
||||
logger.CheckLoggedMessageHead ("FooInMain: " + base_dir, "A1");
|
||||
logger.CheckLoggedMessageHead ("FooInImport1: " + tmp_dir, "A2");
|
||||
logger.CheckLoggedMessageHead ("FooInImport2: " + tmp_dir, "A3");
|
||||
logger.CheckLoggedMessageHead ("FooInTwo: " + third_project, "A4");
|
||||
logger.CheckLoggedMessageHead ("ItemInMain: " + first_project, "A5");
|
||||
logger.CheckLoggedMessageHead ("ItemInImport1: " + second_project, "A6");
|
||||
logger.CheckLoggedMessageHead ("ItemInTwo: " + third_project, "A7");
|
||||
logger.CheckLoggedMessageHead ("Full path: " + third_project, "A8");
|
||||
|
||||
Assert.AreEqual (0, logger.NormalMessageCount, "Unexpected extra messages found");
|
||||
} catch {
|
||||
logger.DumpMessages ();
|
||||
throw;
|
||||
} finally {
|
||||
File.Delete (first_project);
|
||||
File.Delete (second_project);
|
||||
File.Delete (third_project);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRequiredTask_String1 ()
|
||||
@@ -2013,7 +2103,6 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
|
||||
logger.DumpMessages ();
|
||||
Assert.Fail ("A1: Build failed");
|
||||
}
|
||||
logger.DumpMessages ();
|
||||
|
||||
logger.CheckLoggedMessageHead ("Full item: foo;FOO;hmm;bar", "#A2");
|
||||
logger.CheckLoggedMessageHead ("metadata1 :md1 metadata2: md2", "#A3");
|
||||
@@ -2174,7 +2263,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
|
||||
logger.CheckLoggedMessageHead (expected_output_msg, "A");
|
||||
Assert.AreEqual (0, logger.NormalMessageCount, "Unexpected messages found");
|
||||
}
|
||||
} finally {
|
||||
} catch {
|
||||
logger.DumpMessages ();
|
||||
}
|
||||
return project;
|
||||
|
||||
@@ -420,5 +420,61 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
|
||||
Assert.AreEqual (0, logger.NormalMessageCount, "Unexpected extra messages found");
|
||||
}
|
||||
|
||||
#if NET_4_0
|
||||
[Test]
|
||||
public void TestBeforeAndAfterTargets ()
|
||||
{
|
||||
Engine engine;
|
||||
Project project;
|
||||
|
||||
string projectString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""4.0"">
|
||||
<Target Name=""DefaultBeforeTarget1"" BeforeTargets=""Default"">
|
||||
<Message Text=""Hello from DefaultBeforeTarget1""/>
|
||||
</Target>
|
||||
|
||||
<Target Name=""DefaultBeforeTarget2"" BeforeTargets=""Default;Default;NonExistant"">
|
||||
<Message Text=""Hello from DefaultBeforeTarget2""/>
|
||||
</Target>
|
||||
|
||||
|
||||
<Target Name=""DefaultAfterTarget"" AfterTargets=""Default ; Foo"">
|
||||
<Message Text=""Hello from DefaultAfterTarget""/>
|
||||
</Target>
|
||||
|
||||
<Target Name=""Default"" DependsOnTargets=""DefaultDependsOn"">
|
||||
<Message Text=""Hello from Default""/>
|
||||
</Target>
|
||||
|
||||
<Target Name=""DefaultDependsOn"">
|
||||
<Message Text=""Hello from DefaultDependsOn""/>
|
||||
</Target>
|
||||
</Project>";
|
||||
|
||||
engine = new Engine ();
|
||||
project = engine.CreateNewProject ();
|
||||
project.LoadXml (projectString);
|
||||
|
||||
MonoTests.Microsoft.Build.Tasks.TestMessageLogger logger =
|
||||
new MonoTests.Microsoft.Build.Tasks.TestMessageLogger ();
|
||||
engine.RegisterLogger (logger);
|
||||
|
||||
if (!project.Build ("Default")) {
|
||||
logger.DumpMessages ();
|
||||
Assert.Fail ("Build failed");
|
||||
}
|
||||
|
||||
logger.CheckLoggedMessageHead ("Hello from DefaultDependsOn", "A1");
|
||||
logger.CheckLoggedMessageHead ("Hello from DefaultBeforeTarget1", "A1");
|
||||
logger.CheckLoggedMessageHead ("Hello from DefaultBeforeTarget2", "A1");
|
||||
logger.CheckLoggedMessageHead ("Hello from Default", "A1");
|
||||
logger.CheckLoggedMessageHead ("Hello from DefaultAfterTarget", "A1");
|
||||
|
||||
Assert.AreEqual (0, logger.NormalMessageCount, "Unexpected messages found");
|
||||
|
||||
//warnings for referencing unknown targets: NonExistant and Foo
|
||||
Assert.AreEqual (2, logger.WarningsCount, "Expected warnings not raised");
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
@@ -575,7 +575,6 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various {
|
||||
Assert.Fail ("Build failed");
|
||||
}
|
||||
|
||||
logger.DumpMessages ();
|
||||
logger.CheckLoggedMessageHead ("Prop2: File1", "A1");
|
||||
logger.CheckLoggedMessageHead ("Files: File1", "A1");
|
||||
logger.CheckLoggedMessageHead ("Files: File1", "A1");
|
||||
@@ -710,7 +709,6 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various {
|
||||
Assert.Fail ("Build failed");
|
||||
}
|
||||
|
||||
logger.DumpMessages ();
|
||||
logger.CheckLoggedMessageHead ("Item1: Item1OldVal", "A1");
|
||||
logger.CheckLoggedMessageHead ("Item1: Val", "A2");
|
||||
logger.CheckLoggedMessageHead ("Item2: Item2OldVal", "A3");
|
||||
@@ -787,7 +785,6 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various {
|
||||
Assert.Fail ("Build failed");
|
||||
}
|
||||
|
||||
logger.DumpMessages ();
|
||||
logger.CheckLoggedMessageHead ("output1: property: null ## array: null", "A1");
|
||||
logger.CheckLoggedMessageHead ("output2: property: ## array: null", "A2");
|
||||
logger.CheckLoggedMessageHead ("output3: property: null ## array: null", "A3");
|
||||
@@ -1494,7 +1491,6 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various {
|
||||
logger.DumpMessages ();
|
||||
Assert.Fail ("Build failed");
|
||||
}
|
||||
logger.DumpMessages ();
|
||||
|
||||
logger.CheckLoggedMessageHead ("file1: " + Path.Combine ("bar", "foo.dll"), "A1");
|
||||
|
||||
|
||||
@@ -79,6 +79,7 @@ Microsoft.Build.Tasks/GenerateTrustInfo.cs
|
||||
Microsoft.Build.Tasks/GetAssemblyIdentity.cs
|
||||
Microsoft.Build.Tasks/GetFrameworkPath.cs
|
||||
Microsoft.Build.Tasks/GetFrameworkSdkPath.cs
|
||||
Microsoft.Build.Tasks/GetReferenceAssemblyPaths.cs
|
||||
Microsoft.Build.Tasks.Hosting/ICscHostObject.cs
|
||||
Microsoft.Build.Tasks.Hosting/IVbcHostObject.cs
|
||||
Microsoft.Build.Tasks/LC.cs
|
||||
|
||||
@@ -37,8 +37,6 @@ using Mono.XBuild.Utilities;
|
||||
namespace Microsoft.Build.Tasks {
|
||||
public class AL : ToolTaskExtension {
|
||||
|
||||
Process alProcess;
|
||||
|
||||
public AL ()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ namespace Microsoft.Build.Tasks {
|
||||
Dictionary<string, TargetFrameworkAssemblies> target_framework_cache;
|
||||
Dictionary<string, Dictionary<Version, string>> gac;
|
||||
TaskLoggingHelper log;
|
||||
StringWriter sw;
|
||||
List<string> search_log;
|
||||
|
||||
static LibraryPcFileCache cache;
|
||||
@@ -121,7 +120,10 @@ namespace Microsoft.Build.Tasks {
|
||||
if (!Directory.Exists (framework_dir))
|
||||
return null;
|
||||
|
||||
AssemblyName key_aname = new AssemblyName (reference.ItemSpec);
|
||||
AssemblyName key_aname;
|
||||
if (!TryGetAssemblyNameFromFullName (reference.ItemSpec, out key_aname))
|
||||
return null;
|
||||
|
||||
TargetFrameworkAssemblies gac_asm;
|
||||
if (!target_framework_cache.TryGetValue (framework_dir, out gac_asm)) {
|
||||
// fill gac_asm
|
||||
@@ -160,7 +162,9 @@ namespace Microsoft.Build.Tasks {
|
||||
|
||||
// Try as a filename
|
||||
string path = Path.GetFullPath (Path.Combine (directory, filename));
|
||||
AssemblyName aname = specific_version ? new AssemblyName (reference.ItemSpec) : null;
|
||||
AssemblyName aname = null;
|
||||
if (specific_version && !TryGetAssemblyNameFromFullName (reference.ItemSpec, out aname))
|
||||
return null;
|
||||
|
||||
ResolvedReference resolved_ref = ResolveReferenceForPath (path, reference, aname, null, SearchPath.Directory, specific_version);
|
||||
if (resolved_ref != null)
|
||||
@@ -181,8 +185,8 @@ namespace Microsoft.Build.Tasks {
|
||||
ResolvedReference ResolveReferenceForPath (string filename, ITaskItem reference, AssemblyName aname,
|
||||
string error_message, SearchPath spath, bool specific_version)
|
||||
{
|
||||
AssemblyName found_aname = GetAssemblyNameFromFile (filename);
|
||||
if (found_aname == null) {
|
||||
AssemblyName found_aname;
|
||||
if (!TryGetAssemblyNameFromFile (filename, out found_aname)) {
|
||||
if (error_message != null)
|
||||
log.LogMessage (MessageImportance.Low, error_message);
|
||||
return null;
|
||||
@@ -204,8 +208,8 @@ namespace Microsoft.Build.Tasks {
|
||||
{
|
||||
TargetFrameworkAssemblies gac_asm = new TargetFrameworkAssemblies (directory);
|
||||
foreach (string file in Directory.GetFiles (directory, "*.dll")) {
|
||||
AssemblyName aname = GetAssemblyNameFromFile (file);
|
||||
if (aname != null)
|
||||
AssemblyName aname;
|
||||
if (TryGetAssemblyNameFromFile (file, out aname))
|
||||
gac_asm.NameToAssemblyNameCache [aname.Name] =
|
||||
new KeyValuePair<AssemblyName, string> (aname, file);
|
||||
}
|
||||
@@ -215,7 +219,10 @@ namespace Microsoft.Build.Tasks {
|
||||
|
||||
public ResolvedReference ResolveGacReference (ITaskItem reference, bool specific_version)
|
||||
{
|
||||
AssemblyName name = new AssemblyName (reference.ItemSpec);
|
||||
AssemblyName name;
|
||||
if (!TryGetAssemblyNameFromFullName (reference.ItemSpec, out name))
|
||||
return null;
|
||||
|
||||
if (!gac.ContainsKey (name.Name)) {
|
||||
LogSearchMessage ("Considered {0}, but could not find in the GAC.",
|
||||
reference.ItemSpec);
|
||||
@@ -264,7 +271,11 @@ namespace Microsoft.Build.Tasks {
|
||||
return null;
|
||||
}
|
||||
|
||||
ResolvedReference rr = GetResolvedReference (reference, pkg.File, new AssemblyName (pkg.FullName),
|
||||
AssemblyName aname;
|
||||
if (!TryGetAssemblyNameFromFullName (pkg.FullName, out aname))
|
||||
return null;
|
||||
|
||||
ResolvedReference rr = GetResolvedReference (reference, pkg.File, aname,
|
||||
false, SearchPath.PkgConfig);
|
||||
rr.FoundInSearchPathAsString = String.Format ("{{PkgConfig}} provided by package named {0}",
|
||||
pkg.ParentPackage.Name);
|
||||
@@ -291,14 +302,18 @@ namespace Microsoft.Build.Tasks {
|
||||
return null;
|
||||
}
|
||||
|
||||
return ResolveReferenceForPath (hintpath, reference, new AssemblyName (reference.ItemSpec),
|
||||
AssemblyName aname;
|
||||
if (!TryGetAssemblyNameFromFullName (reference.ItemSpec, out aname))
|
||||
return null;
|
||||
|
||||
return ResolveReferenceForPath (hintpath, reference, aname,
|
||||
String.Format ("File at HintPath {0}, is either an invalid assembly or the file does not exist.", hintpath),
|
||||
SearchPath.HintPath, specific_version);
|
||||
}
|
||||
|
||||
public AssemblyName GetAssemblyNameFromFile (string filename)
|
||||
public bool TryGetAssemblyNameFromFile (string filename, out AssemblyName aname)
|
||||
{
|
||||
AssemblyName aname = null;
|
||||
aname = null;
|
||||
filename = Path.GetFullPath (filename);
|
||||
try {
|
||||
aname = AssemblyName.GetAssemblyName (filename);
|
||||
@@ -310,7 +325,19 @@ namespace Microsoft.Build.Tasks {
|
||||
filename);
|
||||
}
|
||||
|
||||
return aname;
|
||||
return aname != null;
|
||||
}
|
||||
|
||||
bool TryGetAssemblyNameFromFullName (string full_name, out AssemblyName aname)
|
||||
{
|
||||
aname = null;
|
||||
try {
|
||||
aname = new AssemblyName (full_name);
|
||||
} catch (FileLoadException) {
|
||||
LogSearchMessage ("Considered '{0}' as an assembly name, but it is invalid.", full_name);
|
||||
}
|
||||
|
||||
return aname != null;
|
||||
}
|
||||
|
||||
internal static bool AssemblyNamesCompatible (AssemblyName a, AssemblyName b, bool specificVersion)
|
||||
@@ -341,11 +368,8 @@ namespace Microsoft.Build.Tasks {
|
||||
bool a_is_empty = (a_bytes == null || a_bytes.Length == 0);
|
||||
bool b_is_empty = (b_bytes == null || b_bytes.Length == 0);
|
||||
|
||||
if (a_is_empty && b_is_empty)
|
||||
return true;
|
||||
|
||||
if (a_is_empty || b_is_empty)
|
||||
return false;
|
||||
return true;
|
||||
|
||||
for (int i = 0; i < a_bytes.Length; i++)
|
||||
if (a_bytes [i] != b_bytes [i])
|
||||
|
||||
@@ -54,24 +54,30 @@ namespace Microsoft.Build.Tasks {
|
||||
assignedFiles = new ITaskItem [files.Length];
|
||||
for (int i = 0; i < files.Length; i ++) {
|
||||
string file = files [i].ItemSpec;
|
||||
string link = files [i].GetMetadata ("Link");
|
||||
string afile = null;
|
||||
//FIXME: Hack!
|
||||
string normalized_root = Path.GetFullPath (rootFolder);
|
||||
|
||||
// cur dir should already be set to
|
||||
// the project dir
|
||||
file = Path.GetFullPath (file);
|
||||
if (String.IsNullOrEmpty (link)) {
|
||||
//FIXME: Hack!
|
||||
string normalized_root = Path.GetFullPath (rootFolder);
|
||||
|
||||
if (file.StartsWith (normalized_root)) {
|
||||
afile = Path.GetFullPath (file).Substring (
|
||||
normalized_root.Length);
|
||||
// skip over "root/"
|
||||
if (afile [0] == '\\' ||
|
||||
afile [0] == '/')
|
||||
afile = afile.Substring (1);
|
||||
// cur dir should already be set to
|
||||
// the project dir
|
||||
file = Path.GetFullPath (file);
|
||||
|
||||
if (file.StartsWith (normalized_root)) {
|
||||
afile = Path.GetFullPath (file).Substring (
|
||||
normalized_root.Length);
|
||||
// skip over "root/"
|
||||
if (afile [0] == '\\' ||
|
||||
afile [0] == '/')
|
||||
afile = afile.Substring (1);
|
||||
|
||||
} else {
|
||||
afile = Path.GetFileName (file);
|
||||
}
|
||||
} else {
|
||||
afile = Path.GetFileName (file);
|
||||
afile = link;
|
||||
}
|
||||
|
||||
assignedFiles [i] = new TaskItem (files [i]);
|
||||
|
||||
@@ -43,7 +43,8 @@ namespace Microsoft.Build.Tasks {
|
||||
public override bool Execute ()
|
||||
{
|
||||
if (Log != null)
|
||||
Log.LogError (null, code, helpKeyword, BuildEngine.ProjectFileOfTaskNode,
|
||||
Log.LogError (null, code, helpKeyword,
|
||||
String.IsNullOrEmpty (File) ? BuildEngine.ProjectFileOfTaskNode : File,
|
||||
BuildEngine.LineNumberOfTaskNode, BuildEngine.ColumnNumberOfTaskNode,
|
||||
BuildEngine.LineNumberOfTaskNode, BuildEngine.ColumnNumberOfTaskNode,
|
||||
text ?? String.Empty, null);
|
||||
@@ -64,6 +65,8 @@ namespace Microsoft.Build.Tasks {
|
||||
get { return text; }
|
||||
set { text = value; }
|
||||
}
|
||||
|
||||
public string File { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ using System.Collections.Specialized;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
@@ -49,6 +50,10 @@ namespace Microsoft.Build.Tasks {
|
||||
string stdOutEncoding;
|
||||
string workingDirectory;
|
||||
string scriptFile;
|
||||
|
||||
#if NET_4_0
|
||||
Func<string, bool> errorMatcher, warningMatcher;
|
||||
#endif
|
||||
|
||||
public Exec ()
|
||||
{
|
||||
@@ -77,6 +82,10 @@ namespace Microsoft.Build.Tasks {
|
||||
string commandLineCommands)
|
||||
{
|
||||
try {
|
||||
#if NET_4_0
|
||||
errorMatcher = GetTryMatchRegexFunc (CustomErrorRegularExpression, true);
|
||||
warningMatcher = GetTryMatchRegexFunc (CustomWarningRegularExpression, false);
|
||||
#endif
|
||||
return base.ExecuteTool (pathToTool, responseFileCommands, commandLineCommands);
|
||||
} finally {
|
||||
if (scriptFile != null)
|
||||
@@ -117,9 +126,48 @@ namespace Microsoft.Build.Tasks {
|
||||
|
||||
protected override void LogEventsFromTextOutput (string singleLine, MessageImportance importance)
|
||||
{
|
||||
Log.LogMessage (importance, singleLine);
|
||||
#if NET_4_0
|
||||
if (IgnoreStandardErrorWarningFormat ||
|
||||
(!errorMatcher (singleLine) && !warningMatcher (singleLine)))
|
||||
#endif
|
||||
Log.LogMessage (importance, singleLine);
|
||||
}
|
||||
|
||||
#if NET_4_0
|
||||
// @is_error_type - log as errors, else warnings
|
||||
Func<string, bool> GetTryMatchRegexFunc (string regex_str, bool is_error_type)
|
||||
{
|
||||
bool is_bad = false;
|
||||
Regex regex = null;
|
||||
return (singleLine) => {
|
||||
if (String.IsNullOrEmpty (regex_str) || is_bad)
|
||||
return false;
|
||||
|
||||
try {
|
||||
if (regex == null)
|
||||
regex = new Regex (regex_str, RegexOptions.Compiled);
|
||||
} catch (ArgumentException ae) {
|
||||
Log.LogError ("The regular expression specified for '{0}' is invalid : {1}",
|
||||
is_error_type ? "errors" : "warnings", ae.Message);
|
||||
Log.LogMessage (MessageImportance.Low, "The regular expression specified for '{0}' is invalid : {1}",
|
||||
is_error_type ? "errors" : "warnings", ae.ToString ());
|
||||
|
||||
is_bad = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!regex.Match (singleLine).Success)
|
||||
return false;
|
||||
|
||||
if (is_error_type)
|
||||
Log.LogError (singleLine);
|
||||
else
|
||||
Log.LogWarning (singleLine);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
[MonoTODO]
|
||||
protected override bool ValidateParameters ()
|
||||
{
|
||||
@@ -162,6 +210,14 @@ namespace Microsoft.Build.Tasks {
|
||||
protected override MessageImportance StandardOutputLoggingImportance {
|
||||
get { return base.StandardOutputLoggingImportance; }
|
||||
}
|
||||
|
||||
#if NET_4_0
|
||||
public bool IgnoreStandardErrorWarningFormat { get; set; }
|
||||
|
||||
public string CustomErrorRegularExpression { get; set; }
|
||||
|
||||
public string CustomWarningRegularExpression { get; set; }
|
||||
#endif
|
||||
|
||||
[MonoTODO]
|
||||
[Output]
|
||||
|
||||
@@ -0,0 +1,273 @@
|
||||
//
|
||||
// GetReferenceAssemblyPaths.cs: Gets the target framework directories corresponding
|
||||
// to target framework moniker
|
||||
//
|
||||
// Author:
|
||||
// Ankit Jain ([email protected])
|
||||
//
|
||||
// Copyright 2011 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
|
||||
// "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;
|
||||
using Microsoft.Build.Framework;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Xml;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Mono.XBuild.Utilities;
|
||||
|
||||
#if NET_4_0
|
||||
|
||||
namespace Microsoft.Build.Tasks
|
||||
{
|
||||
public class GetReferenceAssemblyPaths : TaskExtension
|
||||
{
|
||||
static string framework_base_path;
|
||||
static string PathSeparatorAsString = Path.PathSeparator.ToString ();
|
||||
const string MacOSXExternalXBuildDir = "/Library/Frameworks/Mono.framework/External/xbuild-frameworks";
|
||||
|
||||
public GetReferenceAssemblyPaths ()
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Execute ()
|
||||
{
|
||||
FrameworkMoniker moniker = null;
|
||||
if (!TryParseTargetFrameworkMoniker (TargetFrameworkMoniker, out moniker))
|
||||
return false;
|
||||
|
||||
var framework = GetFrameworkDirectoriesForMoniker (moniker);
|
||||
if (framework == null) {
|
||||
Log.LogWarning ("Unable to find framework corresponding to the target framework moniker '{0}'. " +
|
||||
"Framework assembly references will be resolved from the GAC, which might not be " +
|
||||
"the intended behavior.", TargetFrameworkMoniker);
|
||||
return true;
|
||||
}
|
||||
|
||||
ReferenceAssemblyPaths = FullFrameworkReferenceAssemblyPaths = framework.Directories;
|
||||
TargetFrameworkMonikerDisplayName = framework.DisplayName;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Framework GetFrameworkDirectoriesForMoniker (FrameworkMoniker moniker)
|
||||
{
|
||||
string dirs = String.Join (PathSeparatorAsString, new string [] {
|
||||
Environment.GetEnvironmentVariable ("XBUILD_FRAMEWORK_FOLDERS_PATH") ?? String.Empty,
|
||||
MSBuildUtils.RunningOnMac ? MacOSXExternalXBuildDir : String.Empty,
|
||||
RootPath,
|
||||
DefaultFrameworksBasePath });
|
||||
|
||||
string [] paths = dirs.Split (new char [] {Path.PathSeparator}, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (string path in paths) {
|
||||
var framework = GetFrameworkDirectoriesForMoniker (moniker, path);
|
||||
if (framework != null)
|
||||
return framework;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
//@base_path must be absolute
|
||||
Framework GetFrameworkDirectoriesForMoniker (FrameworkMoniker moniker, string base_path)
|
||||
{
|
||||
if (String.IsNullOrEmpty (base_path)) {
|
||||
Log.LogMessage (MessageImportance.Low, "Invalid *empty* base path, ignoring. " + Environment.StackTrace);
|
||||
return null;
|
||||
}
|
||||
|
||||
Log.LogMessage (MessageImportance.Low, "Looking for framework '{0}' in root path '{1}'",
|
||||
moniker, base_path);
|
||||
string framework_path = Path.Combine (base_path, Path.Combine (moniker.Identifier, moniker.Version));
|
||||
if (!String.IsNullOrEmpty (moniker.Profile))
|
||||
framework_path = Path.Combine (framework_path, moniker.Profile);
|
||||
|
||||
string redistlist_dir = Path.Combine (framework_path, "RedistList");
|
||||
string framework_list = Path.Combine (redistlist_dir, "FrameworkList.xml");
|
||||
if (!File.Exists (framework_list)) {
|
||||
Log.LogMessage (MessageImportance.Low,
|
||||
"Unable to find framework definition file '{0}' for Target Framework Moniker '{1}'",
|
||||
framework_list, moniker);
|
||||
return null;
|
||||
}
|
||||
|
||||
Log.LogMessage (MessageImportance.Low, "Found framework definition list '{0}' for framework '{1}'",
|
||||
framework_list, moniker);
|
||||
XmlReader xr = XmlReader.Create (framework_list);
|
||||
try {
|
||||
xr.MoveToContent ();
|
||||
if (xr.LocalName != "FileList") {
|
||||
Log.LogMessage (MessageImportance.Low, "Invalid frameworklist '{0}', expected a 'FileList' root element.",
|
||||
framework_list);
|
||||
return null;
|
||||
}
|
||||
|
||||
var framework = new Framework ();
|
||||
framework.DisplayName = xr.GetAttribute ("Name");
|
||||
string framework_dir = xr.GetAttribute ("TargetFrameworkDirectory");
|
||||
if (String.IsNullOrEmpty (framework_dir))
|
||||
framework_dir = Path.Combine (redistlist_dir, "..");
|
||||
else
|
||||
framework_dir = Path.Combine (redistlist_dir, framework_dir);
|
||||
|
||||
var directories = new List<string> ();
|
||||
directories.Add (MSBuildUtils.FromMSBuildPath (framework_dir));
|
||||
|
||||
string include = xr.GetAttribute ("IncludeFramework");
|
||||
if (!String.IsNullOrEmpty (include)) {
|
||||
var included_framework = GetFrameworkDirectoriesForMoniker (new FrameworkMoniker (moniker.Identifier, include, null));
|
||||
|
||||
if (included_framework != null && included_framework.Directories != null)
|
||||
directories.AddRange (included_framework.Directories);
|
||||
}
|
||||
|
||||
framework.Directories = directories.ToArray ();
|
||||
|
||||
return framework;
|
||||
} catch (XmlException xe) {
|
||||
Log.LogWarning ("Error reading framework definition file '{0}': {1}", framework_list, xe.Message);
|
||||
Log.LogMessage (MessageImportance.Low, "Error reading framework definition file '{0}': {1}", framework_list,
|
||||
xe.ToString ());
|
||||
return null;
|
||||
} finally {
|
||||
if (xr != null)
|
||||
((IDisposable)xr).Dispose ();
|
||||
}
|
||||
}
|
||||
|
||||
bool TryParseTargetFrameworkMoniker (string moniker_literal, out FrameworkMoniker moniker)
|
||||
{
|
||||
moniker = null;
|
||||
if (String.IsNullOrEmpty (moniker_literal))
|
||||
throw new ArgumentException ("Empty moniker string");
|
||||
|
||||
string [] parts = moniker_literal.Split (new char [] {','}, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if (parts.Length < 2 || parts.Length > 3) {
|
||||
LogInvalidMonikerError (null, moniker_literal);
|
||||
return false;
|
||||
}
|
||||
|
||||
string identifier = parts [0];
|
||||
string version = null;
|
||||
string profile = null;
|
||||
|
||||
if (!parts [1].StartsWith ("Version=")) {
|
||||
LogInvalidMonikerError ("Invalid framework name", moniker_literal);
|
||||
return false;
|
||||
}
|
||||
|
||||
version = parts [1].Substring (8);
|
||||
if (String.IsNullOrEmpty (version)) {
|
||||
LogInvalidMonikerError ("Invalid framework version", moniker_literal);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (parts.Length > 2) {
|
||||
if (!parts [2].StartsWith ("Profile=")) {
|
||||
LogInvalidMonikerError ("Invalid framework version", moniker_literal);
|
||||
return false;
|
||||
}
|
||||
|
||||
profile = parts [2].Substring (8);
|
||||
if (String.IsNullOrEmpty (profile)) {
|
||||
LogInvalidMonikerError ("Invalid framework profile", moniker_literal);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
moniker = new FrameworkMoniker (identifier, version, profile);
|
||||
return true;
|
||||
}
|
||||
|
||||
void LogInvalidMonikerError (string msg, string moniker_literal)
|
||||
{
|
||||
if (msg != null)
|
||||
Log.LogError ("{0} in the Target Framework Moniker '{1}'. Expected format: 'Identifier,Version=<version>[,Profile=<profile>]'. " +
|
||||
"It should have either 2 or 3 comma separated components.", msg, moniker_literal);
|
||||
else
|
||||
Log.LogError ("Invalid Target Framework Moniker '{0}'. Expected format: 'Identifier,Version=<version>[,Profile=<profile>]'. " +
|
||||
"It should have either 2 or 3 comma separated components.", moniker_literal);
|
||||
}
|
||||
|
||||
[Required]
|
||||
public string TargetFrameworkMoniker { get; set; }
|
||||
|
||||
public string RootPath { get; set; }
|
||||
|
||||
public bool BypassFrameworkInstallChecks { get; set; }
|
||||
|
||||
[Output]
|
||||
public string TargetFrameworkMonikerDisplayName { get; set; }
|
||||
|
||||
[Output]
|
||||
public string[] ReferenceAssemblyPaths { get; set; }
|
||||
|
||||
[Output]
|
||||
public string[] FullFrameworkReferenceAssemblyPaths { get; set; }
|
||||
|
||||
static string DefaultFrameworksBasePath {
|
||||
get {
|
||||
if (framework_base_path == null) {
|
||||
// NOTE: code from mcs/tools/gacutil/driver.cs
|
||||
PropertyInfo gac = typeof (System.Environment).GetProperty (
|
||||
"GacPath", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
|
||||
if (gac != null) {
|
||||
MethodInfo get_gac = gac.GetGetMethod (true);
|
||||
string gac_path = (string) get_gac.Invoke (null, null);
|
||||
framework_base_path = Path.GetFullPath (Path.Combine (
|
||||
gac_path, Path.Combine ("..", "xbuild-frameworks")));
|
||||
}
|
||||
}
|
||||
return framework_base_path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class FrameworkMoniker {
|
||||
public readonly string Identifier;
|
||||
public readonly string Version;
|
||||
public readonly string Profile;
|
||||
|
||||
public FrameworkMoniker (string identifier, string version, string profile)
|
||||
{
|
||||
this.Identifier = identifier;
|
||||
this.Version = version;
|
||||
this.Profile = profile;
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
if (String.IsNullOrEmpty (Profile))
|
||||
return String.Format ("{0},Version={1}", Identifier, Version);
|
||||
return String.Format ("{0},Version={1},Profile={2}", Identifier, Version, Profile);
|
||||
}
|
||||
}
|
||||
|
||||
class Framework {
|
||||
public string[] Directories;
|
||||
public string DisplayName;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -99,6 +99,8 @@ namespace Microsoft.Build.Tasks {
|
||||
// nothing to resolve
|
||||
return true;
|
||||
|
||||
LogTaskParameters ();
|
||||
|
||||
assembly_resolver.Log = Log;
|
||||
tempResolvedFiles = new List<ITaskItem> ();
|
||||
tempCopyLocalFiles = new Dictionary<string, ITaskItem> ();
|
||||
@@ -212,8 +214,8 @@ namespace Microsoft.Build.Tasks {
|
||||
resolved = assembly_resolver.ResolveGacReference (item, specific_version);
|
||||
} else if (String.Compare (spath, "{RawFileName}") == 0) {
|
||||
//FIXME: identify assembly names, as extract the name, and try with that?
|
||||
AssemblyName aname = assembly_resolver.GetAssemblyNameFromFile (item.ItemSpec);
|
||||
if (aname != null)
|
||||
AssemblyName aname;
|
||||
if (assembly_resolver.TryGetAssemblyNameFromFile (item.ItemSpec, out aname))
|
||||
resolved = assembly_resolver.GetResolvedReference (item, item.ItemSpec, aname, true,
|
||||
SearchPath.RawFileName);
|
||||
} else if (String.Compare (spath, "{CandidateAssemblyFiles}") == 0) {
|
||||
@@ -280,8 +282,8 @@ namespace Microsoft.Build.Tasks {
|
||||
LogWithPrecedingNewLine (MessageImportance.Low, "Primary Reference from AssemblyFiles {0}", item.ItemSpec);
|
||||
string copy_local;
|
||||
|
||||
AssemblyName aname = assembly_resolver.GetAssemblyNameFromFile (item.ItemSpec);
|
||||
if (aname == null) {
|
||||
AssemblyName aname;
|
||||
if (!assembly_resolver.TryGetAssemblyNameFromFile (item.ItemSpec, out aname)) {
|
||||
Log.LogWarning ("Reference '{0}' not resolved", item.ItemSpec);
|
||||
assembly_resolver.LogSearchLoggerMessages (MessageImportance.Normal);
|
||||
continue;
|
||||
@@ -523,6 +525,19 @@ namespace Microsoft.Build.Tasks {
|
||||
rr.FoundInSearchPath == SearchPath.TargetFrameworkDirectory;
|
||||
}
|
||||
|
||||
void LogTaskParameters ()
|
||||
{
|
||||
Log.LogMessage (MessageImportance.Low, "TargetFrameworkDirectories:");
|
||||
if (TargetFrameworkDirectories != null)
|
||||
foreach (string dir in TargetFrameworkDirectories)
|
||||
Log.LogMessage (MessageImportance.Low, "\t{0}", dir);
|
||||
|
||||
Log.LogMessage (MessageImportance.Low, "SearchPaths:");
|
||||
if (SearchPaths != null)
|
||||
foreach (string path in SearchPaths)
|
||||
Log.LogMessage (MessageImportance.Low, "\t{0}", path);
|
||||
}
|
||||
|
||||
public bool AutoUnify {
|
||||
get { return autoUnify; }
|
||||
set { autoUnify = value; }
|
||||
@@ -644,7 +659,15 @@ namespace Microsoft.Build.Tasks {
|
||||
public ITaskItem[] SuggestedRedirects {
|
||||
get { return suggestedRedirects; }
|
||||
}
|
||||
|
||||
|
||||
#if NET_4_0
|
||||
public string TargetFrameworkMoniker { get; set; }
|
||||
|
||||
public string TargetFrameworkMonikerDisplayName { get; set; }
|
||||
#endif
|
||||
|
||||
public string TargetFrameworkVersion { get; set; }
|
||||
|
||||
public string[] TargetFrameworkDirectories {
|
||||
get { return targetFrameworkDirectories; }
|
||||
set { targetFrameworkDirectories = value; }
|
||||
@@ -655,6 +678,7 @@ namespace Microsoft.Build.Tasks {
|
||||
set { targetProcessorArchitecture = value; }
|
||||
}
|
||||
|
||||
|
||||
static Dictionary<string, string> cultureNamesTable;
|
||||
static Dictionary<string, string> CultureNamesTable {
|
||||
get {
|
||||
|
||||
@@ -183,7 +183,7 @@ namespace Microsoft.Build.Tasks {
|
||||
string col = match.Result ("${column}");
|
||||
int columnNumber = 0;
|
||||
if (!string.IsNullOrEmpty (col))
|
||||
columnNumber = col == "255+" ? -1 : Int32.Parse (col);
|
||||
columnNumber = col.IndexOf ("+") >= 0 ? -1 : Int32.Parse (col);
|
||||
|
||||
string category = match.Result ("${level}");
|
||||
string code = match.Result ("${number}");
|
||||
|
||||
@@ -47,7 +47,8 @@ namespace Microsoft.Build.Tasks {
|
||||
if (String.IsNullOrEmpty (text))
|
||||
return true;
|
||||
|
||||
Log.LogWarning (null, code, helpKeyword, BuildEngine.ProjectFileOfTaskNode,
|
||||
Log.LogWarning (null, code, helpKeyword,
|
||||
String.IsNullOrEmpty (File) ? BuildEngine.ProjectFileOfTaskNode : File,
|
||||
BuildEngine.LineNumberOfTaskNode, BuildEngine.ColumnNumberOfTaskNode,
|
||||
BuildEngine.LineNumberOfTaskNode, BuildEngine.ColumnNumberOfTaskNode,
|
||||
text, null);
|
||||
@@ -68,6 +69,8 @@ namespace Microsoft.Build.Tasks {
|
||||
get { return text; }
|
||||
set { text = value; }
|
||||
}
|
||||
|
||||
public string File { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace MonoTests.Microsoft.Build.Tasks
|
||||
|
||||
string [] files;
|
||||
Project project;
|
||||
Engine engine;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp ()
|
||||
@@ -63,7 +64,7 @@ namespace MonoTests.Microsoft.Build.Tasks
|
||||
"sample.txt", @"bar\sample.txt",
|
||||
"sample.it.png", @"dir\sample.en.png", "sample.inv.txt"};
|
||||
|
||||
Engine engine = new Engine (Consts.BinPath);
|
||||
engine = new Engine (Consts.BinPath);
|
||||
project = engine.CreateNewProject ();
|
||||
}
|
||||
|
||||
@@ -141,7 +142,14 @@ namespace MonoTests.Microsoft.Build.Tasks
|
||||
{
|
||||
string projectText = CreateProjectString (files_list);
|
||||
project.LoadXml (projectText);
|
||||
Assert.IsTrue (project.Build ("1"), "A1 : Error in building");
|
||||
|
||||
TestMessageLogger testLogger = new TestMessageLogger ();
|
||||
engine.RegisterLogger (testLogger);
|
||||
|
||||
if (!project.Build ("1")) {
|
||||
testLogger.DumpMessages ();
|
||||
Assert.Fail ("A1 : Error in building");
|
||||
}
|
||||
}
|
||||
|
||||
void CheckItems (string [] values, string [] cultures, string itemlist_name, string prefix)
|
||||
|
||||
-1
@@ -118,7 +118,6 @@ namespace MonoTests.Microsoft.Build.Tasks
|
||||
|
||||
try {
|
||||
Assert.AreEqual (build_result, project.Build (), "Build " + (build_result ? "failed" : "should've failed"));
|
||||
testLogger.DumpMessages ();
|
||||
if (!build_result || messages == null)
|
||||
// build failed as expected, don't check outputs
|
||||
return;
|
||||
|
||||
@@ -115,6 +115,69 @@ namespace MonoTests.Microsoft.Build.Tasks
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLink ()
|
||||
{
|
||||
string projectText = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
|
||||
<ItemGroup>
|
||||
<FooFiles Include=""xyz.cs"">
|
||||
<Child>Cxyz.cs</Child>
|
||||
<Link>Test\Link\xyz.cs</Link>
|
||||
</FooFiles>
|
||||
<FooFiles Include=""rel\bar.resx"">
|
||||
<Child>Crel\bar.resx</Child>
|
||||
<Link>Test\Link\bar.resx</Link>
|
||||
</FooFiles>
|
||||
<FooFiles Include=""rel\qwe.txt"">
|
||||
<Child>Crel\qwe.txt</Child>
|
||||
<Link>..\Test\Link\qwe.txt</Link>
|
||||
</FooFiles>
|
||||
</ItemGroup>
|
||||
<Target Name=""1"">
|
||||
<AssignTargetPath Files=""@(FooFiles)"" RootFolder=""/"">
|
||||
<Output TaskParameter=""AssignedFiles"" ItemName=""FooPath"" />
|
||||
</AssignTargetPath>
|
||||
</Target>
|
||||
</Project>";
|
||||
Engine engine = new Engine(Consts.BinPath);
|
||||
Project project = engine.CreateNewProject();
|
||||
|
||||
project.LoadXml(projectText);
|
||||
|
||||
string id = "A";
|
||||
Assert.IsTrue(project.Build("1"), id + "1 : Error in building");
|
||||
|
||||
string [] files = new string [] { "xyz.cs", "rel/bar.resx", "rel/qwe.txt"};
|
||||
string [] assignedFiles = new string [] {
|
||||
PathCombine ("Test", "Link", "xyz.cs"),
|
||||
PathCombine ("Test", "Link", "bar.resx"),
|
||||
PathCombine ("..", "Test", "Link", "qwe.txt")
|
||||
};
|
||||
|
||||
BuildItemGroup include = project.GetEvaluatedItemsByName("FooPath");
|
||||
Assert.AreEqual(files.Length, include.Count, id + "2");
|
||||
|
||||
for (int i = 0; i < files.Length; i++) {
|
||||
Assert.AreEqual (files [i], include [i].FinalItemSpec, id + "3, file #" + i);
|
||||
Assert.IsTrue (include[i].HasMetadata ("TargetPath"), id + "4, file #" + i + ", TargetPath metadata missing");
|
||||
Assert.AreEqual (assignedFiles [i], include[i].GetMetadata("TargetPath"), id + "5, file #" + i);
|
||||
Assert.IsTrue (include [i].HasMetadata ("Child"), id + "6, file #" + i + ", Child metadata missing");
|
||||
Assert.AreEqual ("C" + files [i], include [i].GetMetadata ("Child"), id + "7, file #" + i + ", Child metadata value incorrect");
|
||||
}
|
||||
}
|
||||
|
||||
string PathCombine (string path1, params string[] parts)
|
||||
{
|
||||
if (parts == null || parts.Length == 0)
|
||||
return path1;
|
||||
|
||||
string final_path = path1;
|
||||
foreach (string part in parts)
|
||||
final_path = Path.Combine (final_path, part);
|
||||
|
||||
return final_path;
|
||||
}
|
||||
|
||||
void CheckTargetPath(string[] files, string[] assignedFiles, string rootFolder, string id)
|
||||
{
|
||||
Engine engine = new Engine(Consts.BinPath);
|
||||
|
||||
@@ -210,7 +210,6 @@ namespace MonoTests.Microsoft.Build.Tasks {
|
||||
testLogger.DumpMessages ();
|
||||
Assert.Fail ("Build failed");
|
||||
}
|
||||
testLogger.DumpMessages ();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -127,5 +127,45 @@ namespace MonoTests.Microsoft.Build.Tasks {
|
||||
Assert.AreEqual ("@(IG)", project.EvaluatedProperties["C"].FinalValue, "A6");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEmptyPropertyValue ()
|
||||
{
|
||||
Engine engine;
|
||||
Project project;
|
||||
|
||||
string documentString = @"
|
||||
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
|
||||
<PropertyGroup>
|
||||
<A>1</A>
|
||||
</PropertyGroup>
|
||||
<Target Name='1'>
|
||||
<Message Text='Before: $(A)'/>
|
||||
<CreateProperty Value=''>
|
||||
<Output
|
||||
TaskParameter='Value'
|
||||
PropertyName='A'
|
||||
/>
|
||||
</CreateProperty>
|
||||
<Message Text='After: $(A)'/>
|
||||
</Target>
|
||||
</Project>
|
||||
";
|
||||
|
||||
engine = new Engine (Consts.BinPath);
|
||||
|
||||
TestMessageLogger testLogger = new TestMessageLogger ();
|
||||
engine.RegisterLogger (testLogger);
|
||||
|
||||
project = engine.CreateNewProject ();
|
||||
project.LoadXml (documentString);
|
||||
if (!project.Build ("1")) {
|
||||
testLogger.DumpMessages ();
|
||||
Assert.Fail ("Build failed");
|
||||
}
|
||||
|
||||
testLogger.CheckLoggedMessageHead ("Before: 1", "A1");
|
||||
testLogger.CheckLoggedMessageHead ("After: ", "A2");
|
||||
Assert.AreEqual (0, testLogger.NormalMessageCount, "Unexpected messages found");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,6 @@ namespace MonoTests.Microsoft.Build.Tasks {
|
||||
testLogger.DumpMessages ();
|
||||
Assert.Fail ("Build failed");
|
||||
}
|
||||
testLogger.DumpMessages ();
|
||||
|
||||
Assert.AreEqual (1, testLogger.NormalMessageCount, "Expected number of messages");
|
||||
testLogger.CheckLoggedMessageHead (expected, "A1");
|
||||
|
||||
@@ -95,7 +95,6 @@ namespace MonoTests.Microsoft.Build.Tasks {
|
||||
Assert.Fail ("Build should have failed");
|
||||
}
|
||||
|
||||
testLogger.DumpMessages ();
|
||||
Assert.AreEqual (0, testLogger.CheckAny ("Text1", MessageImportance.Low), "A1");
|
||||
Assert.AreEqual (0, testLogger.CheckAny ("Text2", MessageImportance.Normal), "A2");
|
||||
Assert.AreEqual (0, testLogger.CheckAny ("Text3", MessageImportance.High), "A3");
|
||||
@@ -104,7 +103,6 @@ namespace MonoTests.Microsoft.Build.Tasks {
|
||||
Assert.AreEqual (0, testLogger.CheckAny ("Text6", MessageImportance.High), "A6");
|
||||
Assert.AreEqual (0, testLogger.CheckAny ("Text7", MessageImportance.Normal), "A7");
|
||||
Assert.AreEqual (1, testLogger.CheckAny ("Text8", MessageImportance.Normal), "A8");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -905,7 +905,6 @@ namespace MonoTests.Microsoft.Build.Tasks
|
||||
testLogger.DumpMessages ();
|
||||
Assert.Fail ("Build failed");
|
||||
}
|
||||
testLogger.DumpMessages ();
|
||||
|
||||
try {
|
||||
testLogger.CheckLoggedAny ("For md: 3 Item1: Item1Ref: Item2: Three Item2Ref: Three Prop1: Prop1Ref: Prop2: Three Prop2Ref: Three", MessageImportance.Normal, "A1");
|
||||
|
||||
@@ -69,6 +69,9 @@ namespace MonoTests.Microsoft.Build.Tasks
|
||||
set { task_finished = value; }
|
||||
}
|
||||
|
||||
public int WarningsCount { get; set; }
|
||||
public int ErrorsCount { get; set; }
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return messages.Count; }
|
||||
@@ -81,14 +84,19 @@ namespace MonoTests.Microsoft.Build.Tasks
|
||||
public void Initialize (IEventSource eventSource)
|
||||
{
|
||||
eventSource.MessageRaised += new BuildMessageEventHandler (MessageHandler);
|
||||
|
||||
eventSource.ErrorRaised += new BuildErrorEventHandler (AllMessagesHandler);
|
||||
eventSource.ErrorRaised += (e,o) => ErrorsCount ++;
|
||||
|
||||
eventSource.WarningRaised += new BuildWarningEventHandler(AllMessagesHandler);
|
||||
eventSource.WarningRaised += (e,o) => WarningsCount ++;
|
||||
|
||||
eventSource.TargetStarted += delegate { target_started++; };
|
||||
eventSource.TargetFinished += delegate { target_finished++; };
|
||||
eventSource.TaskStarted += delegate { task_started++; };
|
||||
eventSource.TaskFinished += delegate { task_finished++; };
|
||||
eventSource.ProjectStarted += delegate(object sender, ProjectStartedEventArgs args) { project_started++; Console.WriteLine ("Project started: {0}", args.ProjectFile); };
|
||||
eventSource.ProjectFinished += delegate (object sender, ProjectFinishedEventArgs args) { project_finished++; Console.WriteLine ("Project finished: {0}", args.ProjectFile); };
|
||||
eventSource.ProjectStarted += delegate(object sender, ProjectStartedEventArgs args) { project_started++; };
|
||||
eventSource.ProjectFinished += delegate (object sender, ProjectFinishedEventArgs args) { project_finished++; };
|
||||
eventSource.BuildStarted += delegate { build_started ++; };
|
||||
eventSource.BuildFinished += delegate { build_finished++; };
|
||||
}
|
||||
|
||||
@@ -114,22 +114,16 @@ namespace Microsoft.Build.Utilities
|
||||
toolOutput = new StringBuilder ();
|
||||
|
||||
try {
|
||||
string arguments = commandLineCommands;
|
||||
string responseFileSwitch = String.Empty;
|
||||
if (!String.IsNullOrEmpty (responseFileCommands)) {
|
||||
responseFileName = Path.GetTempFileName ();
|
||||
File.WriteAllText (responseFileName, responseFileCommands);
|
||||
arguments = arguments + " " + GetResponseFileSwitch (responseFileName);
|
||||
responseFileSwitch = GetResponseFileSwitch (responseFileName);
|
||||
}
|
||||
|
||||
var pinfo = GetProcessStartInfo (pathToTool, commandLineCommands, responseFileSwitch);
|
||||
LogToolCommand (String.Format ("Tool {0} execution started with arguments: {1} {2}",
|
||||
pathToTool, commandLineCommands, responseFileCommands));
|
||||
|
||||
ProcessStartInfo pinfo = new ProcessStartInfo (pathToTool, arguments);
|
||||
pinfo.WorkingDirectory = GetWorkingDirectory () ?? Environment.CurrentDirectory;
|
||||
|
||||
pinfo.UseShellExecute = false;
|
||||
pinfo.RedirectStandardOutput = true;
|
||||
pinfo.RedirectStandardError = true;
|
||||
pinfo.FileName, commandLineCommands, responseFileCommands));
|
||||
|
||||
var pendingLineFragmentOutput = new StringBuilder ();
|
||||
var pendingLineFragmentError = new StringBuilder ();
|
||||
@@ -264,7 +258,7 @@ namespace Microsoft.Build.Utilities
|
||||
string col = match.Result ("${column}");
|
||||
int columnNumber = 0;
|
||||
if (!string.IsNullOrEmpty (col))
|
||||
columnNumber = col == "255+" ? -1 : Int32.Parse (col);
|
||||
columnNumber = col.IndexOf ("+") >= 0 ? -1 : Int32.Parse (col);
|
||||
|
||||
string category = match.Result ("${level}");
|
||||
string code = match.Result ("${number}");
|
||||
@@ -298,6 +292,18 @@ namespace Microsoft.Build.Utilities
|
||||
return String.Format ("@{0}", responseFilePath);
|
||||
}
|
||||
|
||||
protected virtual ProcessStartInfo GetProcessStartInfo (string pathToTool, string commandLineCommands, string responseFileSwitch)
|
||||
{
|
||||
var pinfo = new ProcessStartInfo (pathToTool, String.Format ("{0} {1}", commandLineCommands, responseFileSwitch));
|
||||
|
||||
pinfo.WorkingDirectory = GetWorkingDirectory () ?? Environment.CurrentDirectory;
|
||||
pinfo.UseShellExecute = false;
|
||||
pinfo.RedirectStandardOutput = true;
|
||||
pinfo.RedirectStandardError = true;
|
||||
|
||||
return pinfo;
|
||||
}
|
||||
|
||||
protected virtual bool HandleTaskExecutionErrors ()
|
||||
{
|
||||
if (!Log.HasLoggedErrors && exitCode != 0)
|
||||
|
||||
+30
@@ -23,6 +23,7 @@
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.Web;
|
||||
using System.Web.Util;
|
||||
@@ -43,6 +44,15 @@ namespace Microsoft.Web.Infrastructure.DynamicValidationHelper
|
||||
this.wrapped = wrapped;
|
||||
}
|
||||
|
||||
public string this [int index] {
|
||||
get { return Get (index); }
|
||||
}
|
||||
|
||||
public string this [string name] {
|
||||
get { return Get (name); }
|
||||
set{ Set (name,value); }
|
||||
}
|
||||
|
||||
public override string Get (string name)
|
||||
{
|
||||
return Validate (name, wrapped.Get (name));
|
||||
@@ -53,6 +63,26 @@ namespace Microsoft.Web.Infrastructure.DynamicValidationHelper
|
||||
return Validate (wrapped.GetKey (index), wrapped.Get (index));
|
||||
}
|
||||
|
||||
public override IEnumerator GetEnumerator ()
|
||||
{
|
||||
return wrapped.GetEnumerator ();
|
||||
}
|
||||
|
||||
public override string GetKey (int index)
|
||||
{
|
||||
return wrapped.GetKey (index);
|
||||
}
|
||||
|
||||
public override string[] GetValues (int index)
|
||||
{
|
||||
return wrapped.GetValues (index);
|
||||
}
|
||||
|
||||
public override string[] GetValues (string name)
|
||||
{
|
||||
return wrapped.GetValues (name);
|
||||
}
|
||||
|
||||
string Validate (string key, string value)
|
||||
{
|
||||
if (String.IsNullOrEmpty (value))
|
||||
|
||||
@@ -85,5 +85,5 @@
|
||||
<Type Name="VMStartEvent" Kind="Class" />
|
||||
</Namespace>
|
||||
</Types>
|
||||
<Title>Mono.Debugger</Title>
|
||||
<Title>Mono.Debugger.Soft</Title>
|
||||
</Overview>
|
||||
@@ -200,8 +200,8 @@ namespace Mono.Debugger.Soft
|
||||
|
||||
public void EnableEvents (params EventType[] events) {
|
||||
foreach (EventType etype in events) {
|
||||
if (etype == EventType.Breakpoint)
|
||||
throw new ArgumentException ("Breakpoint events cannot be requested using EnableEvents", "events");
|
||||
if (etype == EventType.Breakpoint || etype == EventType.Step)
|
||||
throw new ArgumentException ("Breakpoint/Step events cannot be requested using EnableEvents", "events");
|
||||
conn.EnableEvent (etype, SuspendPolicy.All, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,6 +584,14 @@ public class Tests : TestsBase
|
||||
return 42;
|
||||
}
|
||||
|
||||
public int? invoke_return_nullable () {
|
||||
return 42;
|
||||
}
|
||||
|
||||
public int? invoke_return_nullable_null () {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void invoke_type_load () {
|
||||
new Class3 ();
|
||||
}
|
||||
|
||||
@@ -1739,6 +1739,16 @@ public class DebuggerTests
|
||||
v = this_obj.InvokeMethod (e.Thread, m, null);
|
||||
AssertValue (42, v);
|
||||
|
||||
// return nullable
|
||||
m = t.GetMethod ("invoke_return_nullable");
|
||||
v = this_obj.InvokeMethod (e.Thread, m, null);
|
||||
Assert.IsInstanceOfType (typeof (StructMirror), v);
|
||||
|
||||
// return nullable null
|
||||
m = t.GetMethod ("invoke_return_nullable_null");
|
||||
v = this_obj.InvokeMethod (e.Thread, m, null);
|
||||
AssertValue (null, v);
|
||||
|
||||
// pass primitive
|
||||
m = t.GetMethod ("invoke_pass_primitive");
|
||||
Value[] args = new Value [] {
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// MonoTaskScheduler.cs
|
||||
//
|
||||
// Author:
|
||||
// Jérémie "Garuma" Laval <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2011 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
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Mono.Threading.Tasks
|
||||
{
|
||||
public interface IMonoTaskScheduler
|
||||
{
|
||||
void MonoParticipateUntil (Task task);
|
||||
bool MonoParticipateUntil (Task task, ManualResetEventSlim predicateEvt, int millisecondsTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1183,7 +1183,7 @@ namespace System.Linq.Expressions {
|
||||
static bool IsConvertiblePrimitive (Type type)
|
||||
{
|
||||
var t = type.GetNotNullableType ();
|
||||
|
||||
|
||||
if (t == typeof (bool))
|
||||
return false;
|
||||
|
||||
@@ -1221,6 +1221,9 @@ namespace System.Linq.Expressions {
|
||||
if (type.IsInterface || target.IsInterface)
|
||||
return true;
|
||||
|
||||
if (type.IsEnum && target == typeof (Enum))
|
||||
return true;
|
||||
|
||||
if (type.IsValueType || target.IsValueType)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace System.Linq.Parallel
|
||||
|
||||
internal static int GetBestWorkerNumber (bool blocking)
|
||||
{
|
||||
return blocking ? Environment.ProcessorCount + 1 : Environment.ProcessorCount;
|
||||
return blocking && Task.CurrentId == null ? Environment.ProcessorCount + 1 : Environment.ProcessorCount;
|
||||
}
|
||||
|
||||
internal static Task[] Process<TSource, TElement> (QueryBaseNode<TSource> node,
|
||||
@@ -117,7 +117,7 @@ namespace System.Linq.Parallel
|
||||
if (endAction != null)
|
||||
endAction ();
|
||||
}
|
||||
}, options.Token);
|
||||
}, options.Token, TaskCreationOptions.AttachedToParent, TaskScheduler.Default);
|
||||
}
|
||||
|
||||
return tasks;
|
||||
|
||||
@@ -232,7 +232,7 @@ namespace System
|
||||
|
||||
AdjustmentRule rule = GetApplicableRule (dateTime);
|
||||
|
||||
if (IsDaylightSavingTime (DateTime.SpecifyKind (dateTime, DateTimeKind.Utc)))
|
||||
if (rule != null && IsDaylightSavingTime (DateTime.SpecifyKind (dateTime, DateTimeKind.Utc)))
|
||||
return DateTime.SpecifyKind (dateTime + BaseUtcOffset + rule.DaylightDelta , DateTimeKind.Unspecified);
|
||||
else
|
||||
return DateTime.SpecifyKind (dateTime + BaseUtcOffset, DateTimeKind.Unspecified);
|
||||
@@ -282,7 +282,10 @@ namespace System
|
||||
return DateTime.SpecifyKind (dateTime - sourceTimeZone.BaseUtcOffset, DateTimeKind.Utc);
|
||||
else {
|
||||
AdjustmentRule rule = sourceTimeZone.GetApplicableRule (dateTime);
|
||||
return DateTime.SpecifyKind (dateTime - sourceTimeZone.BaseUtcOffset - rule.DaylightDelta, DateTimeKind.Utc);
|
||||
if (rule != null)
|
||||
return DateTime.SpecifyKind (dateTime - sourceTimeZone.BaseUtcOffset - rule.DaylightDelta, DateTimeKind.Utc);
|
||||
else
|
||||
return DateTime.SpecifyKind (dateTime - sourceTimeZone.BaseUtcOffset, DateTimeKind.Utc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -482,7 +485,10 @@ namespace System
|
||||
throw new ArgumentException ("dateTime is not an ambiguous time");
|
||||
|
||||
AdjustmentRule rule = GetApplicableRule (dateTime);
|
||||
return new TimeSpan[] {baseUtcOffset, baseUtcOffset + rule.DaylightDelta};
|
||||
if (rule != null)
|
||||
return new TimeSpan[] {baseUtcOffset, baseUtcOffset + rule.DaylightDelta};
|
||||
else
|
||||
return new TimeSpan[] {baseUtcOffset, baseUtcOffset};
|
||||
}
|
||||
|
||||
public TimeSpan [] GetAmbiguousTimeOffsets (DateTimeOffset dateTimeOffset)
|
||||
@@ -559,7 +565,8 @@ namespace System
|
||||
{
|
||||
if (IsDaylightSavingTime (dateTime)) {
|
||||
AdjustmentRule rule = GetApplicableRule (dateTime);
|
||||
return BaseUtcOffset + rule.DaylightDelta;
|
||||
if (rule != null)
|
||||
return BaseUtcOffset + rule.DaylightDelta;
|
||||
}
|
||||
|
||||
return BaseUtcOffset;
|
||||
@@ -610,9 +617,11 @@ namespace System
|
||||
dateTime = ConvertTime (dateTime, TimeZoneInfo.Local, this);
|
||||
|
||||
AdjustmentRule rule = GetApplicableRule (dateTime);
|
||||
DateTime tpoint = TransitionPoint (rule.DaylightTransitionEnd, dateTime.Year);
|
||||
if (dateTime > tpoint - rule.DaylightDelta && dateTime <= tpoint)
|
||||
return true;
|
||||
if (rule != null) {
|
||||
DateTime tpoint = TransitionPoint (rule.DaylightTransitionEnd, dateTime.Year);
|
||||
if (dateTime > tpoint - rule.DaylightDelta && dateTime <= tpoint)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -667,9 +676,11 @@ namespace System
|
||||
return false;
|
||||
|
||||
AdjustmentRule rule = GetApplicableRule (dateTime);
|
||||
DateTime tpoint = TransitionPoint (rule.DaylightTransitionStart, dateTime.Year);
|
||||
if (dateTime >= tpoint && dateTime < tpoint + rule.DaylightDelta)
|
||||
return true;
|
||||
if (rule != null) {
|
||||
DateTime tpoint = TransitionPoint (rule.DaylightTransitionStart, dateTime.Year);
|
||||
if (dateTime >= tpoint && dateTime < tpoint + rule.DaylightDelta)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
2010-02-14 Veerapuram Varadhan <[email protected]>
|
||||
|
||||
** Fixes 667855
|
||||
* OracleParameter.cs (InferSize): For Raw types, use the appropriate
|
||||
methods to convert value to bytearray and use them to bind.
|
||||
(Bind): Fix index parameters in call to Array.ConstrainedCopy.
|
||||
|
||||
2010-01-30 Veerapuram Varadhan <[email protected]>
|
||||
|
||||
** Fixes #667236 - Based on patch by [email protected]
|
||||
|
||||
@@ -763,7 +763,11 @@ namespace System.Data.OracleClient
|
||||
if (direction == ParameterDirection.Input ||
|
||||
direction == ParameterDirection.InputOutput) {
|
||||
byteCount = 0;
|
||||
byte[] val = v as byte[];
|
||||
byte[] val;
|
||||
if (dbType == DbType.Guid)
|
||||
val = ((Guid)v).ToByteArray();
|
||||
else
|
||||
val = v as byte[];
|
||||
if (val.Length > 0) {
|
||||
byteCount = val.Length;
|
||||
// LONG VARRAW prepends a 4-byte length
|
||||
@@ -771,7 +775,7 @@ namespace System.Data.OracleClient
|
||||
byteArrayLen = BitConverter.GetBytes ((ushort) byteCount);
|
||||
bytes[0] = byteArrayLen[0];
|
||||
bytes[1] = byteArrayLen[1];
|
||||
Array.ConstrainedCopy (val, 2, bytes, 0, byteCount);
|
||||
Array.ConstrainedCopy (val, 0, bytes, 2, byteCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -795,7 +799,7 @@ namespace System.Data.OracleClient
|
||||
bytes[1] = byteArrayLen[1];
|
||||
bytes[2] = byteArrayLen[2];
|
||||
bytes[3] = byteArrayLen[3];
|
||||
Array.ConstrainedCopy (val, 4, bytes, 0, byteCount);
|
||||
Array.ConstrainedCopy (val, 0, bytes, 4, byteCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1022,6 +1026,12 @@ namespace System.Data.OracleClient
|
||||
case OciDataType.RSet: // REF CURSOR
|
||||
newSize = -1;
|
||||
break;
|
||||
case OciDataType.Raw:
|
||||
if (dbType == DbType.Guid)
|
||||
newSize = ((Guid)value).ToByteArray().Length;
|
||||
else
|
||||
newSize = (value as byte[]).Length;
|
||||
break;
|
||||
default:
|
||||
if (value == null || value == DBNull.Value)
|
||||
newSize = 0;
|
||||
@@ -1107,6 +1117,7 @@ namespace System.Data.OracleClient
|
||||
private void SetOracleType (OracleType type, bool inferring)
|
||||
{
|
||||
FreeHandle ();
|
||||
Type valType = value.GetType ();
|
||||
string exception = String.Format ("No mapping exists from OracleType {0} to a known DbType.", type);
|
||||
switch (type) {
|
||||
case OracleType.BFile:
|
||||
@@ -1116,7 +1127,10 @@ namespace System.Data.OracleClient
|
||||
break;
|
||||
case OracleType.LongRaw:
|
||||
case OracleType.Raw:
|
||||
dbType = DbType.Binary;
|
||||
if (valType.FullName == "System.Guid")
|
||||
dbType = DbType.Guid;
|
||||
else
|
||||
dbType = DbType.Binary;
|
||||
ociType = OciDataType.Raw;
|
||||
break;
|
||||
case OracleType.Byte:
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
2011-03-15 Veerapuram Varadhan <[email protected]>
|
||||
|
||||
** Fixes 672113
|
||||
* UniqueConstraint.cs (ctor): Make a copy of columns and columnnames array
|
||||
* ForeignKeyConstraint.cs (ctor): Make a copy of parent and child columns array
|
||||
|
||||
2010-10-01 Veerapuram Varadhan <[email protected]>
|
||||
|
||||
** Fixes #582732 - Patch by Jeffrey Alvarez <[email protected]>
|
||||
|
||||
@@ -102,6 +102,7 @@ namespace System.Data {
|
||||
[Browsable (false)]
|
||||
public ForeignKeyConstraint(string constraintName, string parentTableName, string[] parentColumnNames, string[] childColumnNames, AcceptRejectRule acceptRejectRule, Rule deleteRule, Rule updateRule)
|
||||
{
|
||||
int i;
|
||||
InitInProgress = true;
|
||||
base.ConstraintName = constraintName;
|
||||
|
||||
@@ -112,12 +113,16 @@ namespace System.Data {
|
||||
// Keep reference to parentTableName to resolve later
|
||||
_parentTableName = parentTableName;
|
||||
|
||||
// Keep reference to parentColumnNames to resolve later
|
||||
_parentColumnNames = parentColumnNames;
|
||||
|
||||
// Keep reference to childColumnNames to resolve later
|
||||
_childColumnNames = childColumnNames;
|
||||
|
||||
// Keep a copy of parentColumnNames to resolve later
|
||||
_parentColumnNames = new string [parentColumnNames.Length];
|
||||
for (i = 0; i < parentColumnNames.Length; i++)
|
||||
_parentColumnNames[i] = parentColumnNames[i];
|
||||
|
||||
// Keep a copy of childColumnNames to resolve later
|
||||
_childColumnNames = new string [childColumnNames.Length];
|
||||
for (i = 0; i < childColumnNames.Length; i++)
|
||||
_childColumnNames[i] = childColumnNames[i];
|
||||
|
||||
_acceptRejectRule = acceptRejectRule;
|
||||
_deleteRule = deleteRule;
|
||||
_updateRule = updateRule;
|
||||
@@ -197,15 +202,21 @@ namespace System.Data {
|
||||
DataColumn[] childColumns)
|
||||
{
|
||||
|
||||
int i;
|
||||
//Validate
|
||||
_validateColumns(parentColumns, childColumns);
|
||||
|
||||
//Set Constraint Name
|
||||
base.ConstraintName = constraintName;
|
||||
|
||||
//Keep reference to columns
|
||||
_parentColumns = parentColumns;
|
||||
_childColumns = childColumns;
|
||||
//copy the columns - Do not keep reference #672113
|
||||
_parentColumns = new DataColumn [parentColumns.Length];
|
||||
for (i = 0; i < parentColumns.Length; i++)
|
||||
_parentColumns[i] = parentColumns[i];
|
||||
|
||||
_childColumns = new DataColumn [childColumns.Length];
|
||||
for (i = 0; i < childColumns.Length; i++)
|
||||
_childColumns[i] = childColumns[i];
|
||||
}
|
||||
|
||||
#endregion // Constructors
|
||||
|
||||
@@ -108,6 +108,11 @@ namespace System.Data {
|
||||
InitInProgress = true;
|
||||
|
||||
//keep list of names to resolve later
|
||||
|
||||
_dataColumnNames = new string [columnNames.Length];
|
||||
for (int i = 0; i < columnNames.Length; i++)
|
||||
_dataColumnNames[i] = columnNames[i];
|
||||
|
||||
_dataColumnNames = columnNames;
|
||||
base.ConstraintName = name;
|
||||
_isPrimaryKey = isPrimaryKey;
|
||||
@@ -140,9 +145,9 @@ namespace System.Data {
|
||||
//Set Constraint Name
|
||||
base.ConstraintName = name;
|
||||
|
||||
//keep reference
|
||||
_dataColumns = columns;
|
||||
|
||||
//copy the columns - Do not keep reference #672113
|
||||
//_dataColumns = columns;
|
||||
Columns = columns;
|
||||
//PK?
|
||||
_isPrimaryKey = isPrimaryKey;
|
||||
}
|
||||
@@ -150,7 +155,7 @@ namespace System.Data {
|
||||
#endregion // Constructors
|
||||
|
||||
#region Helpers
|
||||
|
||||
|
||||
private void _validateColumns(DataColumn [] columns)
|
||||
{
|
||||
DataTable table;
|
||||
@@ -302,6 +307,11 @@ namespace System.Data {
|
||||
[ReadOnly (true)]
|
||||
public virtual DataColumn[] Columns {
|
||||
get { return _dataColumns; }
|
||||
internal set {
|
||||
_dataColumns = new DataColumn [value.Length];
|
||||
for (int i = 0; i < value.Length; i++)
|
||||
_dataColumns[i] = value[i];
|
||||
}
|
||||
}
|
||||
|
||||
[DataCategory ("Data")]
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
2011-03-15 Veerapuram Varadhan <[email protected]>
|
||||
|
||||
* DataSetTest2.cs (WriteXmlSchema_Relations_ForeignKeys): Add
|
||||
PrimaryKey before other constraints. Fixes regression of #672113.
|
||||
|
||||
2010-10-01 Veerapuram Varadhan <[email protected]>
|
||||
|
||||
* DataSetReadXmlTest.cs: Added new test for #582732.
|
||||
|
||||
@@ -910,5 +910,49 @@ namespace MonoTests.System.Data
|
||||
} catch (ArgumentOutOfRangeException e) { }
|
||||
}
|
||||
#endif
|
||||
[Category ("NotWorking")]
|
||||
[Test]
|
||||
public void bug672113_MulpleColConstraint ()
|
||||
{
|
||||
DataTable FirstTable = new DataTable ("First Table");
|
||||
DataColumn col0 = new DataColumn ("empno", typeof (int));
|
||||
DataColumn col1 = new DataColumn ("name", typeof (string));
|
||||
DataColumn col2 = new DataColumn ("age", typeof (int));
|
||||
FirstTable.Columns.Add (col0);
|
||||
FirstTable.Columns.Add (col1);
|
||||
FirstTable.Columns.Add (col2);
|
||||
DataColumn[] primkeys = new DataColumn[2];
|
||||
primkeys[0] = FirstTable.Columns[0];
|
||||
primkeys[1] = FirstTable.Columns[1];
|
||||
FirstTable.Constraints.Add("PRIM1",primkeys,true);
|
||||
|
||||
DataTable SecondTable = new DataTable ("Second Table");
|
||||
col0 = new DataColumn ("field1", typeof (int));
|
||||
col1 = new DataColumn ("field2", typeof (int));
|
||||
col2 = new DataColumn ("field3", typeof (int));
|
||||
SecondTable.Columns.Add (col0);
|
||||
SecondTable.Columns.Add (col1);
|
||||
SecondTable.Columns.Add (col2);
|
||||
|
||||
primkeys[0] = SecondTable.Columns[0];
|
||||
primkeys[1] = SecondTable.Columns[1];
|
||||
SecondTable.Constraints.Add("PRIM2",primkeys,true);
|
||||
|
||||
DataRow row1 = FirstTable.NewRow ();
|
||||
row1["empno"] = 1;
|
||||
row1["name"] = "Test";
|
||||
row1["age"] = 32;
|
||||
FirstTable.Rows.Add (row1);
|
||||
FirstTable.AcceptChanges ();
|
||||
Assert.AreEqual (32, FirstTable.Rows[0]["age"], "#1");
|
||||
|
||||
row1 = SecondTable.NewRow ();
|
||||
row1["field1"] = 10000;
|
||||
row1["field2"] = 12000;
|
||||
row1["field3"] = 1000;
|
||||
SecondTable.Rows.Add (row1);
|
||||
SecondTable.AcceptChanges ();
|
||||
Assert.AreEqual (12000, SecondTable.Rows[0]["field2"], "#2");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2864,12 +2864,13 @@ namespace MonoTests_System.Data
|
||||
new DataColumn[] {col1_3, col1_4},
|
||||
new DataColumn[] {col2_3, col2_4},
|
||||
false);
|
||||
|
||||
table1.Constraints.Add ("pk 1", col1_7, true);
|
||||
|
||||
table2.Constraints.Add ("fk 1",
|
||||
new DataColumn[] {col1_5, col1_6},
|
||||
new DataColumn[] {col2_5, col2_6});
|
||||
|
||||
table1.Constraints.Add ("pk 1", col1_7, true);
|
||||
|
||||
ms = new System.IO.MemoryStream();
|
||||
ds1.WriteXmlSchema (ms);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace System.Json
|
||||
{
|
||||
if (stream == null)
|
||||
throw new ArgumentNullException ("stream");
|
||||
return Load (new JavaScriptObjectDeserializer.BufferedStreamReader (stream));
|
||||
return Load (new StreamReader (stream, true));
|
||||
}
|
||||
|
||||
public static JsonValue Load (TextReader textReader)
|
||||
@@ -25,7 +25,7 @@ namespace System.Json
|
||||
if (textReader == null)
|
||||
throw new ArgumentNullException ("textReader");
|
||||
|
||||
var ret = new JavaScriptObjectDeserializer (textReader.ReadToEnd (), true).BasicDeserialize ();
|
||||
var ret = new JavaScriptReader (textReader, true).Read ();
|
||||
|
||||
return ToJsonValue (ret);
|
||||
}
|
||||
|
||||
@@ -1869,7 +1869,7 @@ namespace System.Numerics {
|
||||
return 0;
|
||||
|
||||
if (data.Length > 2)
|
||||
return -sign;
|
||||
return sign;
|
||||
|
||||
if (other < 0)
|
||||
other = -other;
|
||||
|
||||
@@ -65,6 +65,14 @@ using System.Runtime.InteropServices;
|
||||
[assembly: ComCompatibleVersion (1, 0, 3300, 0)]
|
||||
[assembly: Debuggable (DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
|
||||
[assembly: SecurityCritical (SecurityCriticalScope.Explicit)]
|
||||
#if NET_4_0
|
||||
// for SyndicationElementExtension
|
||||
// FIXME: mcs in 2-10 branch breaks System.ServiceModel build on resolving this. So, disabling it so far.
|
||||
// [assembly: InternalsVisibleTo ("System.ServiceModel, PublicKey=00000000000000000400000000000000")]
|
||||
#else
|
||||
// for SyndicationElementExtension
|
||||
[assembly: InternalsVisibleTo ("System.ServiceModel.Web, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
|
||||
#endif
|
||||
#endif
|
||||
|
||||
[assembly: ComVisible (false)]
|
||||
|
||||
+135
-72
@@ -76,11 +76,19 @@ namespace System.Runtime.Serialization
|
||||
*/
|
||||
internal static class TypeExtensions
|
||||
{
|
||||
public static T GetCustomAttribute<T> (this Type type, bool inherit)
|
||||
public static T GetCustomAttribute<T> (this MemberInfo type, bool inherit)
|
||||
{
|
||||
var arr = type.GetCustomAttributes (typeof (T), inherit);
|
||||
return arr != null && arr.Length == 1 ? (T) arr [0] : default (T);
|
||||
}
|
||||
|
||||
public static IEnumerable<Type> GetInterfacesOrSelfInterface (this Type type)
|
||||
{
|
||||
if (type.IsInterface)
|
||||
yield return type;
|
||||
foreach (var t in type.GetInterfaces ())
|
||||
yield return t;
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class KnownTypeCollection : Collection<Type>
|
||||
@@ -91,6 +99,9 @@ namespace System.Runtime.Serialization
|
||||
"http://schemas.microsoft.com/2003/10/Serialization/Arrays";
|
||||
internal const string DefaultClrNamespaceBase =
|
||||
"http://schemas.datacontract.org/2004/07/";
|
||||
internal const string DefaultClrNamespaceSystem =
|
||||
"http://schemas.datacontract.org/2004/07/System";
|
||||
|
||||
|
||||
static QName any_type, bool_type,
|
||||
byte_type, date_type, decimal_type, double_type,
|
||||
@@ -102,14 +113,10 @@ namespace System.Runtime.Serialization
|
||||
// custom in ms nsURI schema
|
||||
char_type, guid_type,
|
||||
// not in ms nsURI schema
|
||||
dbnull_type;
|
||||
dbnull_type, date_time_offset_type;
|
||||
|
||||
static KnownTypeCollection ()
|
||||
{
|
||||
//any_type, bool_type, byte_type, date_type, decimal_type, double_type, float_type, string_type,
|
||||
// short_type, int_type, long_type, ubyte_type, ushort_type, uint_type, ulong_type,
|
||||
// any_uri_type, base64_type, duration_type, qname_type,
|
||||
// char_type, guid_type, dbnull_type;
|
||||
string s = MSSimpleNamespace;
|
||||
any_type = new QName ("anyType", s);
|
||||
any_uri_type = new QName ("anyURI", s);
|
||||
@@ -133,7 +140,8 @@ namespace System.Runtime.Serialization
|
||||
guid_type = new QName ("guid", s);
|
||||
char_type = new QName ("char", s);
|
||||
|
||||
dbnull_type = new QName ("DBNull", MSSimpleNamespace + "System");
|
||||
dbnull_type = new QName ("DBNull", DefaultClrNamespaceBase + "System");
|
||||
date_time_offset_type = new QName ("DateTimeOffset", DefaultClrNamespaceBase + "System");
|
||||
}
|
||||
|
||||
// FIXME: find out how QName and guid are processed
|
||||
@@ -153,6 +161,8 @@ namespace System.Runtime.Serialization
|
||||
return name;
|
||||
if (type == typeof (DBNull))
|
||||
return dbnull_type;
|
||||
if (type == typeof (DateTimeOffset))
|
||||
return date_time_offset_type;
|
||||
return QName.Empty;
|
||||
}
|
||||
|
||||
@@ -266,55 +276,67 @@ namespace System.Runtime.Serialization
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: xsd types and ms serialization types should be differentiated.
|
||||
internal static Type GetPrimitiveTypeFromName (string name)
|
||||
internal static Type GetPrimitiveTypeFromName (QName name)
|
||||
{
|
||||
switch (name) {
|
||||
case "anyURI":
|
||||
return typeof (Uri);
|
||||
case "boolean":
|
||||
return typeof (bool);
|
||||
case "base64Binary":
|
||||
return typeof (byte []);
|
||||
case "dateTime":
|
||||
return typeof (DateTime);
|
||||
case "duration":
|
||||
return typeof (TimeSpan);
|
||||
case "QName":
|
||||
return typeof (QName);
|
||||
case "decimal":
|
||||
return typeof (decimal);
|
||||
case "double":
|
||||
return typeof (double);
|
||||
case "float":
|
||||
return typeof (float);
|
||||
case "byte":
|
||||
return typeof (sbyte);
|
||||
case "short":
|
||||
return typeof (short);
|
||||
case "int":
|
||||
return typeof (int);
|
||||
case "long":
|
||||
return typeof (long);
|
||||
case "unsignedByte":
|
||||
return typeof (byte);
|
||||
case "unsignedShort":
|
||||
return typeof (ushort);
|
||||
case "unsignedInt":
|
||||
return typeof (uint);
|
||||
case "unsignedLong":
|
||||
return typeof (ulong);
|
||||
case "string":
|
||||
return typeof (string);
|
||||
case "anyType":
|
||||
return typeof (object);
|
||||
case "guid":
|
||||
return typeof (Guid);
|
||||
case "char":
|
||||
return typeof (char);
|
||||
default:
|
||||
return null;
|
||||
switch (name.Namespace) {
|
||||
case DefaultClrNamespaceSystem:
|
||||
switch (name.Name) {
|
||||
case "DBNull":
|
||||
return typeof (DBNull);
|
||||
case "DateTimeOffset":
|
||||
return typeof (DateTimeOffset);
|
||||
}
|
||||
break;
|
||||
// FIXME: xsd types and ms serialization types should be differentiated. (usage problem)
|
||||
case XmlSchema.Namespace:
|
||||
case MSSimpleNamespace:
|
||||
switch (name.Name) {
|
||||
case "anyURI":
|
||||
return typeof (Uri);
|
||||
case "boolean":
|
||||
return typeof (bool);
|
||||
case "base64Binary":
|
||||
return typeof (byte []);
|
||||
case "dateTime":
|
||||
return typeof (DateTime);
|
||||
case "duration":
|
||||
return typeof (TimeSpan);
|
||||
case "QName":
|
||||
return typeof (QName);
|
||||
case "decimal":
|
||||
return typeof (decimal);
|
||||
case "double":
|
||||
return typeof (double);
|
||||
case "float":
|
||||
return typeof (float);
|
||||
case "byte":
|
||||
return typeof (sbyte);
|
||||
case "short":
|
||||
return typeof (short);
|
||||
case "int":
|
||||
return typeof (int);
|
||||
case "long":
|
||||
return typeof (long);
|
||||
case "unsignedByte":
|
||||
return typeof (byte);
|
||||
case "unsignedShort":
|
||||
return typeof (ushort);
|
||||
case "unsignedInt":
|
||||
return typeof (uint);
|
||||
case "unsignedLong":
|
||||
return typeof (ulong);
|
||||
case "string":
|
||||
return typeof (string);
|
||||
case "anyType":
|
||||
return typeof (object);
|
||||
case "guid":
|
||||
return typeof (Guid);
|
||||
case "char":
|
||||
return typeof (char);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -386,12 +408,22 @@ namespace System.Runtime.Serialization
|
||||
|
||||
protected override void InsertItem (int index, Type type)
|
||||
{
|
||||
if (!Contains (type) && TryRegister (type))
|
||||
if (ShouldNotRegister (type))
|
||||
return;
|
||||
if (!Contains (type)) {
|
||||
TryRegister (type);
|
||||
base.InsertItem (index, type);
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: it could remove other types' dependencies.
|
||||
protected override void RemoveItem (int index)
|
||||
{
|
||||
lock (this)
|
||||
DoRemoveItem (index);
|
||||
}
|
||||
|
||||
void DoRemoveItem (int index)
|
||||
{
|
||||
Type t = base [index];
|
||||
List<SerializationMap> l = new List<SerializationMap> ();
|
||||
@@ -407,6 +439,13 @@ namespace System.Runtime.Serialization
|
||||
|
||||
protected override void SetItem (int index, Type type)
|
||||
{
|
||||
if (ShouldNotRegister (type))
|
||||
return;
|
||||
|
||||
// Since this collection is not assured to be ordered, it ignores the whole Set operation if the type already exists.
|
||||
if (Contains (type))
|
||||
return;
|
||||
|
||||
if (index != Count)
|
||||
RemoveItem (index);
|
||||
if (TryRegister (type))
|
||||
@@ -415,11 +454,14 @@ namespace System.Runtime.Serialization
|
||||
|
||||
internal SerializationMap FindUserMap (QName qname)
|
||||
{
|
||||
return contracts.FirstOrDefault (c => c.XmlName == qname);
|
||||
lock (this)
|
||||
return contracts.FirstOrDefault (c => c.XmlName == qname);
|
||||
}
|
||||
|
||||
internal Type GetSerializedType (Type type)
|
||||
{
|
||||
if (IsPrimitiveNotEnum (type))
|
||||
return type;
|
||||
Type element = GetCollectionElementType (type);
|
||||
if (element == null)
|
||||
return type;
|
||||
@@ -432,10 +474,12 @@ namespace System.Runtime.Serialization
|
||||
|
||||
internal SerializationMap FindUserMap (Type type)
|
||||
{
|
||||
for (int i = 0; i < contracts.Count; i++)
|
||||
if (type == contracts [i].RuntimeType)
|
||||
return contracts [i];
|
||||
return null;
|
||||
lock (this) {
|
||||
for (int i = 0; i < contracts.Count; i++)
|
||||
if (type == contracts [i].RuntimeType)
|
||||
return contracts [i];
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
internal QName GetQName (Type type)
|
||||
@@ -605,10 +649,22 @@ namespace System.Runtime.Serialization
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ShouldNotRegister (Type type)
|
||||
{
|
||||
return IsPrimitiveNotEnum (type);
|
||||
}
|
||||
|
||||
internal bool TryRegister (Type type)
|
||||
{
|
||||
lock (this) {
|
||||
return DoTryRegister (type);
|
||||
}
|
||||
}
|
||||
|
||||
bool DoTryRegister (Type type)
|
||||
{
|
||||
// exclude predefined maps
|
||||
if (IsPrimitiveNotEnum (type))
|
||||
if (ShouldNotRegister (type))
|
||||
return false;
|
||||
|
||||
if (FindUserMap (type) != null)
|
||||
@@ -645,10 +701,9 @@ namespace System.Runtime.Serialization
|
||||
{
|
||||
if (type.IsArray)
|
||||
return type.GetElementType ();
|
||||
|
||||
Type [] ifaces = type.GetInterfaces ();
|
||||
var ifaces = type.GetInterfacesOrSelfInterface ();
|
||||
foreach (Type i in ifaces)
|
||||
if (i.IsGenericType && i.GetGenericTypeDefinition ().Equals (typeof (ICollection<>)))
|
||||
if (i.IsGenericType && i.GetGenericTypeDefinition ().Equals (typeof (IEnumerable<>)))
|
||||
return i.GetGenericArguments () [0];
|
||||
foreach (Type i in ifaces)
|
||||
if (i == typeof (IList))
|
||||
@@ -676,8 +731,12 @@ namespace System.Runtime.Serialization
|
||||
|
||||
QName qname = GetCollectionContractQName (type);
|
||||
CheckStandardQName (qname);
|
||||
if (FindUserMap (qname) != null)
|
||||
throw new InvalidOperationException (String.Format ("Failed to add type {0} to known type collection. There already is a registered type for XML name {1}", type, qname));
|
||||
var map = FindUserMap (qname);
|
||||
if (map != null) {
|
||||
var cmap = map as CollectionContractTypeMap;
|
||||
if (cmap == null) // The runtime type may still differ (between array and other IList; see bug #670560)
|
||||
throw new InvalidOperationException (String.Format ("Failed to add type {0} to known type collection. There already is a registered type for XML name {1}", type, qname));
|
||||
}
|
||||
|
||||
var ret = new CollectionContractTypeMap (type, cdca, element, qname, this);
|
||||
contracts.Add (ret);
|
||||
@@ -697,7 +756,7 @@ namespace System.Runtime.Serialization
|
||||
var map = FindUserMap (qname);
|
||||
if (map != null) {
|
||||
var cmap = map as CollectionTypeMap;
|
||||
if (cmap == null || cmap.RuntimeType != type)
|
||||
if (cmap == null) // The runtime type may still differ (between array and other IList; see bug #670560)
|
||||
throw new InvalidOperationException (String.Format ("Failed to add type {0} to known type collection. There already is a registered type for XML name {1}", type, qname));
|
||||
return cmap;
|
||||
}
|
||||
@@ -710,7 +769,7 @@ namespace System.Runtime.Serialization
|
||||
|
||||
static bool TypeImplementsIDictionary (Type type)
|
||||
{
|
||||
foreach (var iface in type.GetInterfaces ())
|
||||
foreach (var iface in type.GetInterfacesOrSelfInterface ())
|
||||
if (iface == typeof (IDictionary) || (iface.IsGenericType && iface.GetGenericTypeDefinition () == typeof (IDictionary<,>)))
|
||||
return true;
|
||||
|
||||
@@ -728,13 +787,17 @@ namespace System.Runtime.Serialization
|
||||
DictionaryTypeMap ret =
|
||||
new DictionaryTypeMap (type, cdca, this);
|
||||
|
||||
if (FindUserMap (ret.XmlName) != null)
|
||||
throw new InvalidOperationException (String.Format ("Failed to add type {0} to known type collection. There already is a registered type for XML name {1}", type, ret.XmlName));
|
||||
contracts.Add (ret);
|
||||
|
||||
TryRegister (ret.KeyType);
|
||||
TryRegister (ret.ValueType);
|
||||
|
||||
var map = FindUserMap (ret.XmlName);
|
||||
if (map != null) {
|
||||
var dmap = map as DictionaryTypeMap;
|
||||
if (dmap == null) // The runtime type may still differ (between array and other IList; see bug #670560)
|
||||
throw new InvalidOperationException (String.Format ("Failed to add type {0} to known type collection. There already is a registered type for XML name {1}", type, ret.XmlName));
|
||||
}
|
||||
contracts.Add (ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -62,7 +62,7 @@ namespace System.Runtime.Serialization
|
||||
{
|
||||
public override void ExportSchemaType (XsdDataContractExporter exporter)
|
||||
{
|
||||
exporter.ExportStandardComplexType (RuntimeType.GetCustomAttribute<DataContractAttribute> (false), RuntimeType, Members);
|
||||
exporter.ExportStandardComplexType (RuntimeType.GetCustomAttribute<DataContractAttribute> (false), this, Members);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace System.Runtime.Serialization
|
||||
{
|
||||
public override void ExportSchemaType (XsdDataContractExporter exporter)
|
||||
{
|
||||
exporter.ExportStandardComplexType (null, RuntimeType, Members);
|
||||
exporter.ExportStandardComplexType (null, this, Members);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace System.Runtime.Serialization
|
||||
{
|
||||
public override void ExportSchemaType (XsdDataContractExporter exporter)
|
||||
{
|
||||
exporter.ExportListContractType (a, RuntimeType);
|
||||
exporter.ExportListContractType (a, this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace System.Runtime.Serialization
|
||||
{
|
||||
public override void ExportSchemaType (XsdDataContractExporter exporter)
|
||||
{
|
||||
exporter.ExportListContractType (null, RuntimeType);
|
||||
exporter.ExportListContractType (null, this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace System.Runtime.Serialization
|
||||
{
|
||||
public override void ExportSchemaType (XsdDataContractExporter exporter)
|
||||
{
|
||||
exporter.ExportDictionaryContractType (a, RuntimeType, GetGenericDictionaryInterface (RuntimeType));
|
||||
exporter.ExportDictionaryContractType (a, this, GetGenericDictionaryInterface (RuntimeType));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace System.Runtime.Serialization
|
||||
{
|
||||
public override void ExportSchemaType (XsdDataContractExporter exporter)
|
||||
{
|
||||
exporter.ExportStandardComplexType (null, RuntimeType, Members);
|
||||
exporter.ExportStandardComplexType (null, this, Members);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace System.Runtime.Serialization
|
||||
{
|
||||
public override void ExportSchemaType (XsdDataContractExporter exporter)
|
||||
{
|
||||
exporter.ExportEnumContractType (RuntimeType.GetCustomAttribute<DataContractAttribute> (false), RuntimeType);
|
||||
exporter.ExportEnumContractType (RuntimeType.GetCustomAttribute<DataContractAttribute> (false), this);
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-5
@@ -386,7 +386,7 @@ namespace System.Runtime.Serialization
|
||||
KnownTypes.Add (memberType);
|
||||
QName qname = KnownTypes.GetQName (memberType);
|
||||
|
||||
if (KnownTypeCollection.GetPrimitiveTypeFromName (qname.Name) != null)
|
||||
if (KnownTypeCollection.GetPrimitiveTypeFromName (qname) != null)
|
||||
return new DataMemberInfo (mi, dma, ownerNamespace, null);
|
||||
else
|
||||
return new DataMemberInfo (mi, dma, ownerNamespace, qname.Namespace);
|
||||
@@ -590,8 +590,8 @@ namespace System.Runtime.Serialization
|
||||
|
||||
static Type GetGenericCollectionInterface (Type type)
|
||||
{
|
||||
foreach (var iface in type.GetInterfaces ())
|
||||
if (iface.IsGenericType && iface.GetGenericTypeDefinition () == typeof (ICollection<>))
|
||||
foreach (var iface in type.GetInterfacesOrSelfInterface ())
|
||||
if (iface.IsGenericType && iface.GetGenericTypeDefinition () == typeof (IEnumerable<>))
|
||||
return iface;
|
||||
|
||||
return null;
|
||||
@@ -731,7 +731,7 @@ namespace System.Runtime.Serialization
|
||||
|
||||
static Type GetGenericDictionaryInterface (Type type)
|
||||
{
|
||||
foreach (var iface in type.GetInterfaces ())
|
||||
foreach (var iface in type.GetInterfacesOrSelfInterface ())
|
||||
if (iface.IsGenericType && iface.GetGenericTypeDefinition () == typeof (IDictionary<,>))
|
||||
return iface;
|
||||
|
||||
@@ -858,7 +858,7 @@ namespace System.Runtime.Serialization
|
||||
return DeserializeContent (reader, deserializer, id);
|
||||
}
|
||||
|
||||
public override object DeserializeContent(XmlReader reader, XmlFormatterDeserializer deserializer, string id)
|
||||
public override object DeserializeContent (XmlReader reader, XmlFormatterDeserializer deserializer, string id)
|
||||
{
|
||||
object instance = CreateInstance ();
|
||||
HandleId (id, deserializer, instance);
|
||||
@@ -872,7 +872,9 @@ namespace System.Runtime.Serialization
|
||||
object key = deserializer.Deserialize (key_type, reader);
|
||||
reader.MoveToContent ();
|
||||
object val = deserializer.Deserialize (value_type, reader);
|
||||
reader.MoveToContent ();
|
||||
reader.ReadEndElement (); // of pair
|
||||
reader.MoveToContent ();
|
||||
|
||||
if (instance is IDictionary)
|
||||
((IDictionary)instance).Add (key, val);
|
||||
|
||||
+38
-17
@@ -110,11 +110,11 @@ namespace System.Runtime.Serialization
|
||||
QName graph_qname = types.GetQName (type);
|
||||
string itype = reader.GetAttribute ("type", XmlSchema.InstanceNamespace);
|
||||
if (itype != null) {
|
||||
string[] parts = itype.Split (':');
|
||||
string [] parts = itype.Split (':');
|
||||
if (parts.Length > 1)
|
||||
graph_qname = new QName (parts [1], reader.LookupNamespace (reader.NameTable.Get (parts[0])));
|
||||
graph_qname = new QName (parts [1], reader.LookupNamespace (reader.NameTable.Get (parts [0])));
|
||||
else
|
||||
graph_qname = new QName (itype, reader.NamespaceURI);
|
||||
graph_qname = new QName (itype, reader.LookupNamespace (String.Empty));
|
||||
}
|
||||
|
||||
string label = reader.GetAttribute ("Ref", KnownTypeCollection.MSSimpleNamespace);
|
||||
@@ -149,21 +149,11 @@ namespace System.Runtime.Serialization
|
||||
}
|
||||
}
|
||||
|
||||
if (KnownTypeCollection.GetPrimitiveTypeFromName (graph_qname.Name) != null) {
|
||||
if (KnownTypeCollection.GetPrimitiveTypeFromName (graph_qname) != null) {
|
||||
string id = reader.GetAttribute ("Id", KnownTypeCollection.MSSimpleNamespace);
|
||||
|
||||
string value;
|
||||
if (reader.IsEmptyElement) {
|
||||
reader.Read (); // advance
|
||||
if (type.IsValueType)
|
||||
return Activator.CreateInstance (type);
|
||||
else
|
||||
// FIXME: Workaround for creating empty objects of the correct type.
|
||||
value = String.Empty;
|
||||
}
|
||||
else
|
||||
value = reader.ReadElementContentAsString ();
|
||||
object ret = KnownTypeCollection.PredefinedTypeStringToObject (value, graph_qname.Name, reader);
|
||||
object ret = DeserializePrimitive (type, reader, graph_qname);
|
||||
|
||||
if (id != null) {
|
||||
if (references.ContainsKey (id))
|
||||
throw new InvalidOperationException (String.Format ("Object with Id '{0}' already exists as '{1}'", id, references [id]));
|
||||
@@ -175,6 +165,37 @@ namespace System.Runtime.Serialization
|
||||
return DeserializeByMap (graph_qname, type, reader);
|
||||
}
|
||||
|
||||
object DeserializePrimitive (Type type, XmlReader reader, QName qname)
|
||||
{
|
||||
// It is the only exceptional type that does not serialize to string but serializes into complex element.
|
||||
if (type == typeof (DateTimeOffset)) {
|
||||
if (reader.IsEmptyElement) {
|
||||
reader.Read ();
|
||||
return default (DateTimeOffset);
|
||||
}
|
||||
reader.ReadStartElement ();
|
||||
reader.MoveToContent ();
|
||||
var date = reader.ReadElementContentAsDateTime ("DateTime", KnownTypeCollection.DefaultClrNamespaceSystem);
|
||||
var off = TimeSpan.FromMinutes (reader.ReadElementContentAsInt ("OffsetMinutes", KnownTypeCollection.DefaultClrNamespaceSystem));
|
||||
reader.MoveToContent ();
|
||||
reader.ReadEndElement ();
|
||||
return new DateTimeOffset (DateTime.SpecifyKind (date.ToUniversalTime () + off, DateTimeKind.Unspecified), off);
|
||||
}
|
||||
|
||||
string value;
|
||||
if (reader.IsEmptyElement) {
|
||||
reader.Read (); // advance
|
||||
if (type.IsValueType)
|
||||
return Activator.CreateInstance (type);
|
||||
else
|
||||
// FIXME: Workaround for creating empty objects of the correct type.
|
||||
value = String.Empty;
|
||||
}
|
||||
else
|
||||
value = reader.ReadElementContentAsString ();
|
||||
return KnownTypeCollection.PredefinedTypeStringToObject (value, qname.Name, reader);
|
||||
}
|
||||
|
||||
object DeserializeByMap (QName name, Type type, XmlReader reader)
|
||||
{
|
||||
SerializationMap map = resolved_qnames.ContainsKey (name) ? types.FindUserMap (type) : types.FindUserMap (name); // use type when the name is "resolved" one. Otherwise use name (there are cases that type cannot be resolved by type).
|
||||
@@ -193,7 +214,7 @@ namespace System.Runtime.Serialization
|
||||
|
||||
Type GetTypeFromNamePair (string name, string ns)
|
||||
{
|
||||
Type p = KnownTypeCollection.GetPrimitiveTypeFromName (name); // FIXME: namespace?
|
||||
Type p = KnownTypeCollection.GetPrimitiveTypeFromName (new QName (name, ns));
|
||||
if (p != null)
|
||||
return p;
|
||||
bool makeArray = false;
|
||||
|
||||
+15
-2
@@ -102,7 +102,8 @@ namespace System.Runtime.Serialization
|
||||
// For some collection types, the actual type does not matter. So get nominal serialization type instead.
|
||||
// (The code below also covers the lines above, but I don't remove above lines to avoid extra search cost.)
|
||||
if (map == null) {
|
||||
actualType = types.GetSerializedType (actualType);
|
||||
// FIXME: not sure if type.IsInterface is the correct condition to determine whether items are serialized with i:type or not. (e.g. bug #675144 server response).
|
||||
actualType = types.GetSerializedType (type.IsInterface ? type : actualType);
|
||||
map = types.FindUserMap (actualType);
|
||||
}
|
||||
// If it is still unknown, then register it.
|
||||
@@ -145,7 +146,19 @@ namespace System.Runtime.Serialization
|
||||
// writer.WriteStartAttribute ("type", XmlSchema.InstanceNamespace);
|
||||
// writer.WriteQualifiedName (qname.Name, qname.Namespace);
|
||||
// writer.WriteEndAttribute ();
|
||||
writer.WriteString (KnownTypeCollection.PredefinedTypeObjectToString (graph));
|
||||
|
||||
// It is the only exceptional type that does not serialize to string but serializes into complex element.
|
||||
if (type == typeof (DateTimeOffset)) {
|
||||
var v = (DateTimeOffset) graph;
|
||||
writer.WriteStartElement ("DateTime", KnownTypeCollection.DefaultClrNamespaceSystem);
|
||||
SerializePrimitive (typeof (DateTime), DateTime.SpecifyKind (v.DateTime.Subtract (v.Offset), DateTimeKind.Utc), KnownTypeCollection.GetPredefinedTypeName (typeof (DateTime)));
|
||||
writer.WriteEndElement ();
|
||||
writer.WriteStartElement ("OffsetMinutes", KnownTypeCollection.DefaultClrNamespaceSystem);
|
||||
SerializePrimitive (typeof (int), v.Offset.TotalMinutes, KnownTypeCollection.GetPredefinedTypeName (typeof (int)));
|
||||
writer.WriteEndElement ();
|
||||
}
|
||||
else
|
||||
writer.WriteString (KnownTypeCollection.PredefinedTypeObjectToString (graph));
|
||||
}
|
||||
|
||||
public void WriteStartElement (string memberName, string memberNamespace, string contentNamespace)
|
||||
|
||||
+27
-29
@@ -47,16 +47,6 @@ using QName = System.Xml.XmlQualifiedName;
|
||||
|
||||
namespace System.Runtime.Serialization
|
||||
{
|
||||
static class TypeExtension
|
||||
{
|
||||
public static T GetCustomAttribute<T> (this MemberInfo mi, bool inherit)
|
||||
{
|
||||
foreach (T att in mi.GetCustomAttributes (typeof (T), inherit))
|
||||
return att;
|
||||
return default (T);
|
||||
}
|
||||
}
|
||||
|
||||
public class XsdDataContractExporter
|
||||
{
|
||||
class TypeImportInfo
|
||||
@@ -86,21 +76,14 @@ namespace System.Runtime.Serialization
|
||||
}
|
||||
}
|
||||
|
||||
// Note that this does not handle DBNull and DateTimeOffset
|
||||
// (they are not included in the predefined schema)
|
||||
static Type GetPredefinedTypeFromQName (QName qname)
|
||||
{
|
||||
switch (qname.Namespace) {
|
||||
case XmlSchema.Namespace:
|
||||
return KnownTypeCollection.GetPrimitiveTypeFromName (qname.Name);
|
||||
case KnownTypeCollection.MSSimpleNamespace:
|
||||
switch (qname.Name) {
|
||||
case "char":
|
||||
return typeof (char);
|
||||
case "duration":
|
||||
return typeof (TimeSpan);
|
||||
case "guid":
|
||||
return typeof (Guid);
|
||||
}
|
||||
break;
|
||||
return KnownTypeCollection.GetPrimitiveTypeFromName (qname);
|
||||
}
|
||||
throw new Exception ("Should not happen");
|
||||
}
|
||||
@@ -227,9 +210,10 @@ namespace System.Runtime.Serialization
|
||||
return true;
|
||||
}
|
||||
|
||||
internal void ExportDictionaryContractType (CollectionDataContractAttribute attr, Type type, Type dicType)
|
||||
internal void ExportDictionaryContractType (CollectionDataContractAttribute attr, SerializationMap map, Type dicType)
|
||||
{
|
||||
var qname = GetSchemaTypeName (type);
|
||||
var type = map.RuntimeType;
|
||||
var qname = map.XmlName;
|
||||
|
||||
var typeArgs = dicType.IsGenericType ? dicType.GetGenericArguments () : null;
|
||||
var keyType = typeArgs != null ? typeArgs [0] : typeof (object);
|
||||
@@ -265,9 +249,10 @@ namespace System.Runtime.Serialization
|
||||
dictSeq.Items.Add (new XmlSchemaElement () { Name = valueName, SchemaTypeName = GetSchemaTypeName (valueType), IsNillable = true });
|
||||
}
|
||||
|
||||
internal void ExportListContractType (CollectionDataContractAttribute attr, Type type)
|
||||
internal void ExportListContractType (CollectionDataContractAttribute attr, CollectionTypeMap map)
|
||||
{
|
||||
var qname = attr != null && attr.Name != null ? new QName (attr.Name, attr.Namespace ?? GetXmlNamespace (type)) : GetSchemaTypeName (type);
|
||||
Type type = map.RuntimeType;
|
||||
var qname = map.XmlName;
|
||||
|
||||
var typeArgs = type.IsGenericType ? type.GetGenericArguments () : null;
|
||||
if (typeArgs != null && typeArgs.Length != 1)
|
||||
@@ -299,9 +284,10 @@ namespace System.Runtime.Serialization
|
||||
*/
|
||||
}
|
||||
|
||||
internal void ExportEnumContractType (DataContractAttribute attr, Type type)
|
||||
internal void ExportEnumContractType (DataContractAttribute attr, SerializationMap map)
|
||||
{
|
||||
var qname = attr != null && attr.Name != null ? new QName (attr.Name, attr.Namespace ?? GetXmlNamespace (type)) : GetSchemaTypeName (type);
|
||||
Type type = map.RuntimeType;
|
||||
var qname = map.XmlName;
|
||||
var st = CreateSimpleType (qname, type);
|
||||
if (type.GetCustomAttribute<FlagsAttribute> (false) != null) {
|
||||
var list = new XmlSchemaSimpleTypeList ();
|
||||
@@ -327,9 +313,10 @@ namespace System.Runtime.Serialization
|
||||
return r;
|
||||
}
|
||||
|
||||
internal void ExportStandardComplexType (DataContractAttribute attr, Type type, List<DataMemberInfo> members)
|
||||
internal void ExportStandardComplexType (DataContractAttribute attr, SerializationMap map, List<DataMemberInfo> members)
|
||||
{
|
||||
var qname = attr != null && attr.Name != null ? new QName (attr.Name, attr.Namespace ?? GetXmlNamespace (type)) : GetSchemaTypeName (type);
|
||||
Type type = map.RuntimeType;
|
||||
var qname = map.XmlName;
|
||||
var ct = CreateComplexType (qname, type);
|
||||
|
||||
if (type.BaseType != null && type.BaseType != typeof (object)) {
|
||||
@@ -433,7 +420,11 @@ namespace System.Runtime.Serialization
|
||||
string GetXmlTypeName (Type type)
|
||||
{
|
||||
var qname = KnownTypeCollection.GetPrimitiveTypeName (type);
|
||||
return qname.Equals (QName.Empty) ? type.Name : qname.Name;
|
||||
if (!qname.Equals (QName.Empty))
|
||||
return qname.Name;
|
||||
var ret = type.Name;
|
||||
int idx = ret.IndexOf ('`');
|
||||
return idx < 0 ? ret : ret.Substring (0, idx);
|
||||
}
|
||||
|
||||
string GetXmlNamespace (Type type)
|
||||
@@ -479,6 +470,13 @@ namespace System.Runtime.Serialization
|
||||
if (info != null && info.SchemaTypeName != null)
|
||||
return info.SchemaTypeName;
|
||||
|
||||
known_types.Add (type);
|
||||
var map = known_types.FindUserMap (type);
|
||||
if (map != null)
|
||||
return map.XmlName;
|
||||
|
||||
// The following lines would be mostly redundant (legacy code now that it widely uses SerializationMap.XmlName for consistency...)
|
||||
|
||||
var cdca = type.GetCustomAttribute<CollectionDataContractAttribute> (false);
|
||||
if (cdca != null)
|
||||
return new QName (cdca.Name ?? GetXmlTypeName (type), cdca.Namespace ?? GetXmlNamespace (type));
|
||||
|
||||
+2
-17
@@ -542,18 +542,10 @@ namespace System.Runtime.Serialization
|
||||
|
||||
bool IsPredefinedType (XmlQualifiedName qname)
|
||||
{
|
||||
// FIXME: support char, guid and duration (MSSimpleNamespace); fix GetPrimitiveTypeFromName() first and then this at a time.
|
||||
switch (qname.Namespace) {
|
||||
case KnownTypeCollection.MSSimpleNamespace:
|
||||
switch (qname.Name) {
|
||||
case "char":
|
||||
case "guid":
|
||||
case "duration":
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case XmlSchema.Namespace:
|
||||
return KnownTypeCollection.GetPrimitiveTypeFromName (qname.Name) != null;
|
||||
return KnownTypeCollection.GetPrimitiveTypeFromName (qname) != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -622,15 +614,8 @@ namespace System.Runtime.Serialization
|
||||
|
||||
switch (typeName.Namespace) {
|
||||
case XmlSchema.Namespace:
|
||||
return new CodeTypeReference (KnownTypeCollection.GetPrimitiveTypeFromName (typeName.Name));
|
||||
case KnownTypeCollection.MSSimpleNamespace:
|
||||
switch (typeName.Name) {
|
||||
case "guid":
|
||||
return new CodeTypeReference (typeof (Guid));
|
||||
case "duration":
|
||||
return new CodeTypeReference (typeof (TimeSpan));
|
||||
}
|
||||
break;
|
||||
return new CodeTypeReference (KnownTypeCollection.GetPrimitiveTypeFromName (typeName));
|
||||
}
|
||||
|
||||
var info = GetTypeInfo (typeName, throwError);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
System.Runtime.Serialization/Bug666333Test.cs
|
||||
System.Runtime.Serialization/Bug675144Test.cs
|
||||
System.Runtime.Serialization/DataContractResolverTest.cs
|
||||
System.Runtime.Serialization/XmlObjectSerializerTest.cs
|
||||
System.Runtime.Serialization/XsdDataContractExporterTest.cs
|
||||
|
||||
@@ -185,6 +185,8 @@ namespace System.Xml
|
||||
case BF.Bytes16:
|
||||
case BF.Bytes32:
|
||||
return Convert.ToBase64String ((byte []) TypedValue);
|
||||
case BF.QNameIndex:
|
||||
return Name;
|
||||
default:
|
||||
throw new NotImplementedException ("ValueType " + ValueType + " on node " + NodeType);
|
||||
}
|
||||
@@ -960,6 +962,10 @@ namespace System.Xml
|
||||
node.DictValue = ReadDictName ();
|
||||
node.NodeType = XmlNodeType.Text;
|
||||
break;
|
||||
case BF.QNameIndex:
|
||||
node.Prefix = ((char) (ReadByteOrError () + 'a')).ToString ();
|
||||
node.DictLocalName = ReadDictName();
|
||||
break;
|
||||
default:
|
||||
if (!canSkip)
|
||||
throw new ArgumentException (String.Format ("Unexpected binary XML data at position {1}: {0:X}", ident + (is_next_end_element ? 1 : 0), source.Position));
|
||||
|
||||
+531
@@ -0,0 +1,531 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
using System.ServiceModel;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.ServiceModel.Description;
|
||||
using System.Xml;
|
||||
using WebServiceMoonlightTest.ServiceReference1;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.System.Runtime.Serialization
|
||||
{
|
||||
[TestFixture]
|
||||
public partial class Bug675144Test
|
||||
{
|
||||
[Test]
|
||||
public void ServerSerialization ()
|
||||
{
|
||||
var obj = new DataType2 { Items = new List<DataType1> { new DataType1 { Id = "D" }, new DataType1 { Id = "E" } } };
|
||||
var ds = new DataContractSerializer (typeof (DataType2));
|
||||
var sw = new StringWriter ();
|
||||
using (var xw = XmlWriter.Create (sw))
|
||||
ds.WriteObject (xw, obj);
|
||||
Assert.IsTrue (sw.ToString ().IndexOf ("anyType i:type=\"DataType1\"") > 0, "#1");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.372
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// This code was auto-generated by Microsoft.Silverlight.ServiceReference, version 4.0.50826.0
|
||||
//
|
||||
namespace WebServiceMoonlightTest.ServiceReference1 {
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
|
||||
[System.Runtime.Serialization.DataContractAttribute(Name="DataType1", Namespace="http://mynamespace")]
|
||||
public partial class DataType1 : object, System.ComponentModel.INotifyPropertyChanged {
|
||||
|
||||
private string IdField;
|
||||
|
||||
[System.Runtime.Serialization.DataMemberAttribute()]
|
||||
public string Id {
|
||||
get {
|
||||
return this.IdField;
|
||||
}
|
||||
set {
|
||||
if ((object.ReferenceEquals(this.IdField, value) != true)) {
|
||||
this.IdField = value;
|
||||
this.RaisePropertyChanged("Id");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected void RaisePropertyChanged(string propertyName) {
|
||||
System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
|
||||
if ((propertyChanged != null)) {
|
||||
propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
|
||||
[System.Runtime.Serialization.DataContractAttribute(Name="DataType2", Namespace="http://mynamespace")]
|
||||
[System.Runtime.Serialization.KnownTypeAttribute(typeof(WebServiceMoonlightTest.ServiceReference1.DataType1))]
|
||||
[System.Runtime.Serialization.KnownTypeAttribute(typeof(System.Collections.Generic.IEnumerable<object>))]
|
||||
public partial class DataType2 : object, System.ComponentModel.INotifyPropertyChanged {
|
||||
|
||||
private System.Collections.Generic.IEnumerable<object> ItemsField;
|
||||
|
||||
[System.Runtime.Serialization.DataMemberAttribute()]
|
||||
public System.Collections.Generic.IEnumerable<object> Items {
|
||||
get {
|
||||
return this.ItemsField;
|
||||
}
|
||||
set {
|
||||
if ((object.ReferenceEquals(this.ItemsField, value) != true)) {
|
||||
this.ItemsField = value;
|
||||
this.RaisePropertyChanged("Items");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected void RaisePropertyChanged(string propertyName) {
|
||||
System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
|
||||
if ((propertyChanged != null)) {
|
||||
propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
[System.ServiceModel.ServiceContractAttribute(Namespace="http://mynamespace", ConfigurationName="ServiceReference1.IService1")]
|
||||
public interface IService1 {
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://mynamespace/IService1/GetData", ReplyAction="http://mynamespace/IService1/GetDataResponse")]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(WebServiceMoonlightTest.ServiceReference1.DataType1))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(WebServiceMoonlightTest.ServiceReference1.DataType2))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.IEnumerable<object>))]
|
||||
System.IAsyncResult BeginGetData(System.AsyncCallback callback, object asyncState);
|
||||
|
||||
object EndGetData(System.IAsyncResult result);
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://mynamespace/IService1/GetCollectionData", ReplyAction="http://mynamespace/IService1/GetCollectionDataResponse")]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(WebServiceMoonlightTest.ServiceReference1.DataType1))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(WebServiceMoonlightTest.ServiceReference1.DataType2))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.IEnumerable<object>))]
|
||||
System.IAsyncResult BeginGetCollectionData(System.AsyncCallback callback, object asyncState);
|
||||
|
||||
System.Collections.Generic.IEnumerable<object> EndGetCollectionData(System.IAsyncResult result);
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://mynamespace/IService1/GetNestedData", ReplyAction="http://mynamespace/IService1/GetNestedDataResponse")]
|
||||
System.IAsyncResult BeginGetNestedData(System.AsyncCallback callback, object asyncState);
|
||||
|
||||
WebServiceMoonlightTest.ServiceReference1.DataType2 EndGetNestedData(System.IAsyncResult result);
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
public interface IService1Channel : WebServiceMoonlightTest.ServiceReference1.IService1, System.ServiceModel.IClientChannel {
|
||||
}
|
||||
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
public partial class GetDataCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
|
||||
|
||||
private object[] results;
|
||||
|
||||
public GetDataCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
|
||||
base(exception, cancelled, userState) {
|
||||
this.results = results;
|
||||
}
|
||||
|
||||
public object Result {
|
||||
get {
|
||||
base.RaiseExceptionIfNecessary();
|
||||
return ((object)(this.results[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
public partial class GetCollectionDataCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
|
||||
|
||||
private object[] results;
|
||||
|
||||
public GetCollectionDataCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
|
||||
base(exception, cancelled, userState) {
|
||||
this.results = results;
|
||||
}
|
||||
|
||||
public System.Collections.Generic.IEnumerable<object> Result {
|
||||
get {
|
||||
base.RaiseExceptionIfNecessary();
|
||||
return ((System.Collections.Generic.IEnumerable<object>)(this.results[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
public partial class GetNestedDataCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
|
||||
|
||||
private object[] results;
|
||||
|
||||
public GetNestedDataCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
|
||||
base(exception, cancelled, userState) {
|
||||
this.results = results;
|
||||
}
|
||||
|
||||
public WebServiceMoonlightTest.ServiceReference1.DataType2 Result {
|
||||
get {
|
||||
base.RaiseExceptionIfNecessary();
|
||||
return ((WebServiceMoonlightTest.ServiceReference1.DataType2)(this.results[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
public partial class Service1Client : System.ServiceModel.ClientBase<WebServiceMoonlightTest.ServiceReference1.IService1>, WebServiceMoonlightTest.ServiceReference1.IService1 {
|
||||
|
||||
private BeginOperationDelegate onBeginGetDataDelegate;
|
||||
|
||||
private EndOperationDelegate onEndGetDataDelegate;
|
||||
|
||||
private System.Threading.SendOrPostCallback onGetDataCompletedDelegate;
|
||||
|
||||
private BeginOperationDelegate onBeginGetCollectionDataDelegate;
|
||||
|
||||
private EndOperationDelegate onEndGetCollectionDataDelegate;
|
||||
|
||||
private System.Threading.SendOrPostCallback onGetCollectionDataCompletedDelegate;
|
||||
|
||||
private BeginOperationDelegate onBeginGetNestedDataDelegate;
|
||||
|
||||
private EndOperationDelegate onEndGetNestedDataDelegate;
|
||||
|
||||
private System.Threading.SendOrPostCallback onGetNestedDataCompletedDelegate;
|
||||
|
||||
private BeginOperationDelegate onBeginOpenDelegate;
|
||||
|
||||
private EndOperationDelegate onEndOpenDelegate;
|
||||
|
||||
private System.Threading.SendOrPostCallback onOpenCompletedDelegate;
|
||||
|
||||
private BeginOperationDelegate onBeginCloseDelegate;
|
||||
|
||||
private EndOperationDelegate onEndCloseDelegate;
|
||||
|
||||
private System.Threading.SendOrPostCallback onCloseCompletedDelegate;
|
||||
|
||||
public Service1Client() {
|
||||
}
|
||||
|
||||
public Service1Client(string endpointConfigurationName) :
|
||||
base(endpointConfigurationName) {
|
||||
}
|
||||
|
||||
public Service1Client(string endpointConfigurationName, string remoteAddress) :
|
||||
base(endpointConfigurationName, remoteAddress) {
|
||||
}
|
||||
|
||||
public Service1Client(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
|
||||
base(endpointConfigurationName, remoteAddress) {
|
||||
}
|
||||
|
||||
public Service1Client(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
|
||||
base(binding, remoteAddress) {
|
||||
}
|
||||
|
||||
/*
|
||||
public System.Net.CookieContainer CookieContainer {
|
||||
get {
|
||||
System.ServiceModel.Channels.IHttpCookieContainerManager httpCookieContainerManager = this.InnerChannel.GetProperty<System.ServiceModel.Channels.IHttpCookieContainerManager>();
|
||||
if ((httpCookieContainerManager != null)) {
|
||||
return httpCookieContainerManager.CookieContainer;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
set {
|
||||
System.ServiceModel.Channels.IHttpCookieContainerManager httpCookieContainerManager = this.InnerChannel.GetProperty<System.ServiceModel.Channels.IHttpCookieContainerManager>();
|
||||
if ((httpCookieContainerManager != null)) {
|
||||
httpCookieContainerManager.CookieContainer = value;
|
||||
}
|
||||
else {
|
||||
throw new System.InvalidOperationException("Unable to set the CookieContainer. Please make sure the binding contains an HttpC" +
|
||||
"ookieContainerBindingElement.");
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
public event System.EventHandler<GetDataCompletedEventArgs> GetDataCompleted;
|
||||
|
||||
public event System.EventHandler<GetCollectionDataCompletedEventArgs> GetCollectionDataCompleted;
|
||||
|
||||
public event System.EventHandler<GetNestedDataCompletedEventArgs> GetNestedDataCompleted;
|
||||
|
||||
public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> OpenCompleted;
|
||||
|
||||
public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> CloseCompleted;
|
||||
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
System.IAsyncResult WebServiceMoonlightTest.ServiceReference1.IService1.BeginGetData(System.AsyncCallback callback, object asyncState) {
|
||||
return base.Channel.BeginGetData(callback, asyncState);
|
||||
}
|
||||
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
object WebServiceMoonlightTest.ServiceReference1.IService1.EndGetData(System.IAsyncResult result) {
|
||||
return base.Channel.EndGetData(result);
|
||||
}
|
||||
|
||||
private System.IAsyncResult OnBeginGetData(object[] inValues, System.AsyncCallback callback, object asyncState) {
|
||||
return ((WebServiceMoonlightTest.ServiceReference1.IService1)(this)).BeginGetData(callback, asyncState);
|
||||
}
|
||||
|
||||
private object[] OnEndGetData(System.IAsyncResult result) {
|
||||
object retVal = ((WebServiceMoonlightTest.ServiceReference1.IService1)(this)).EndGetData(result);
|
||||
return new object[] {
|
||||
retVal};
|
||||
}
|
||||
|
||||
private void OnGetDataCompleted(object state) {
|
||||
if ((this.GetDataCompleted != null)) {
|
||||
InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
|
||||
this.GetDataCompleted(this, new GetDataCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
|
||||
}
|
||||
}
|
||||
|
||||
public void GetDataAsync() {
|
||||
this.GetDataAsync(null);
|
||||
}
|
||||
|
||||
public void GetDataAsync(object userState) {
|
||||
if ((this.onBeginGetDataDelegate == null)) {
|
||||
this.onBeginGetDataDelegate = new BeginOperationDelegate(this.OnBeginGetData);
|
||||
}
|
||||
if ((this.onEndGetDataDelegate == null)) {
|
||||
this.onEndGetDataDelegate = new EndOperationDelegate(this.OnEndGetData);
|
||||
}
|
||||
if ((this.onGetDataCompletedDelegate == null)) {
|
||||
this.onGetDataCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnGetDataCompleted);
|
||||
}
|
||||
base.InvokeAsync(this.onBeginGetDataDelegate, null, this.onEndGetDataDelegate, this.onGetDataCompletedDelegate, userState);
|
||||
}
|
||||
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
System.IAsyncResult WebServiceMoonlightTest.ServiceReference1.IService1.BeginGetCollectionData(System.AsyncCallback callback, object asyncState) {
|
||||
return base.Channel.BeginGetCollectionData(callback, asyncState);
|
||||
}
|
||||
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
System.Collections.Generic.IEnumerable<object> WebServiceMoonlightTest.ServiceReference1.IService1.EndGetCollectionData(System.IAsyncResult result) {
|
||||
return base.Channel.EndGetCollectionData(result);
|
||||
}
|
||||
|
||||
private System.IAsyncResult OnBeginGetCollectionData(object[] inValues, System.AsyncCallback callback, object asyncState) {
|
||||
return ((WebServiceMoonlightTest.ServiceReference1.IService1)(this)).BeginGetCollectionData(callback, asyncState);
|
||||
}
|
||||
|
||||
private object[] OnEndGetCollectionData(System.IAsyncResult result) {
|
||||
System.Collections.Generic.IEnumerable<object> retVal = ((WebServiceMoonlightTest.ServiceReference1.IService1)(this)).EndGetCollectionData(result);
|
||||
return new object[] {
|
||||
retVal};
|
||||
}
|
||||
|
||||
private void OnGetCollectionDataCompleted(object state) {
|
||||
if ((this.GetCollectionDataCompleted != null)) {
|
||||
InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
|
||||
this.GetCollectionDataCompleted(this, new GetCollectionDataCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
|
||||
}
|
||||
}
|
||||
|
||||
public void GetCollectionDataAsync() {
|
||||
this.GetCollectionDataAsync(null);
|
||||
}
|
||||
|
||||
public void GetCollectionDataAsync(object userState) {
|
||||
if ((this.onBeginGetCollectionDataDelegate == null)) {
|
||||
this.onBeginGetCollectionDataDelegate = new BeginOperationDelegate(this.OnBeginGetCollectionData);
|
||||
}
|
||||
if ((this.onEndGetCollectionDataDelegate == null)) {
|
||||
this.onEndGetCollectionDataDelegate = new EndOperationDelegate(this.OnEndGetCollectionData);
|
||||
}
|
||||
if ((this.onGetCollectionDataCompletedDelegate == null)) {
|
||||
this.onGetCollectionDataCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnGetCollectionDataCompleted);
|
||||
}
|
||||
base.InvokeAsync(this.onBeginGetCollectionDataDelegate, null, this.onEndGetCollectionDataDelegate, this.onGetCollectionDataCompletedDelegate, userState);
|
||||
}
|
||||
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
System.IAsyncResult WebServiceMoonlightTest.ServiceReference1.IService1.BeginGetNestedData(System.AsyncCallback callback, object asyncState) {
|
||||
return base.Channel.BeginGetNestedData(callback, asyncState);
|
||||
}
|
||||
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
WebServiceMoonlightTest.ServiceReference1.DataType2 WebServiceMoonlightTest.ServiceReference1.IService1.EndGetNestedData(System.IAsyncResult result) {
|
||||
return base.Channel.EndGetNestedData(result);
|
||||
}
|
||||
|
||||
private System.IAsyncResult OnBeginGetNestedData(object[] inValues, System.AsyncCallback callback, object asyncState) {
|
||||
return ((WebServiceMoonlightTest.ServiceReference1.IService1)(this)).BeginGetNestedData(callback, asyncState);
|
||||
}
|
||||
|
||||
private object[] OnEndGetNestedData(System.IAsyncResult result) {
|
||||
WebServiceMoonlightTest.ServiceReference1.DataType2 retVal = ((WebServiceMoonlightTest.ServiceReference1.IService1)(this)).EndGetNestedData(result);
|
||||
return new object[] {
|
||||
retVal};
|
||||
}
|
||||
|
||||
private void OnGetNestedDataCompleted(object state) {
|
||||
if ((this.GetNestedDataCompleted != null)) {
|
||||
InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
|
||||
this.GetNestedDataCompleted(this, new GetNestedDataCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
|
||||
}
|
||||
}
|
||||
|
||||
public void GetNestedDataAsync() {
|
||||
this.GetNestedDataAsync(null);
|
||||
}
|
||||
|
||||
public void GetNestedDataAsync(object userState) {
|
||||
if ((this.onBeginGetNestedDataDelegate == null)) {
|
||||
this.onBeginGetNestedDataDelegate = new BeginOperationDelegate(this.OnBeginGetNestedData);
|
||||
}
|
||||
if ((this.onEndGetNestedDataDelegate == null)) {
|
||||
this.onEndGetNestedDataDelegate = new EndOperationDelegate(this.OnEndGetNestedData);
|
||||
}
|
||||
if ((this.onGetNestedDataCompletedDelegate == null)) {
|
||||
this.onGetNestedDataCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnGetNestedDataCompleted);
|
||||
}
|
||||
base.InvokeAsync(this.onBeginGetNestedDataDelegate, null, this.onEndGetNestedDataDelegate, this.onGetNestedDataCompletedDelegate, userState);
|
||||
}
|
||||
|
||||
private System.IAsyncResult OnBeginOpen(object[] inValues, System.AsyncCallback callback, object asyncState) {
|
||||
return ((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(callback, asyncState);
|
||||
}
|
||||
|
||||
private object[] OnEndOpen(System.IAsyncResult result) {
|
||||
((System.ServiceModel.ICommunicationObject)(this)).EndOpen(result);
|
||||
return null;
|
||||
}
|
||||
|
||||
private void OnOpenCompleted(object state) {
|
||||
if ((this.OpenCompleted != null)) {
|
||||
InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
|
||||
this.OpenCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenAsync() {
|
||||
this.OpenAsync(null);
|
||||
}
|
||||
|
||||
public void OpenAsync(object userState) {
|
||||
if ((this.onBeginOpenDelegate == null)) {
|
||||
this.onBeginOpenDelegate = new BeginOperationDelegate(this.OnBeginOpen);
|
||||
}
|
||||
if ((this.onEndOpenDelegate == null)) {
|
||||
this.onEndOpenDelegate = new EndOperationDelegate(this.OnEndOpen);
|
||||
}
|
||||
if ((this.onOpenCompletedDelegate == null)) {
|
||||
this.onOpenCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnOpenCompleted);
|
||||
}
|
||||
base.InvokeAsync(this.onBeginOpenDelegate, null, this.onEndOpenDelegate, this.onOpenCompletedDelegate, userState);
|
||||
}
|
||||
|
||||
private System.IAsyncResult OnBeginClose(object[] inValues, System.AsyncCallback callback, object asyncState) {
|
||||
return ((System.ServiceModel.ICommunicationObject)(this)).BeginClose(callback, asyncState);
|
||||
}
|
||||
|
||||
private object[] OnEndClose(System.IAsyncResult result) {
|
||||
((System.ServiceModel.ICommunicationObject)(this)).EndClose(result);
|
||||
return null;
|
||||
}
|
||||
|
||||
private void OnCloseCompleted(object state) {
|
||||
if ((this.CloseCompleted != null)) {
|
||||
InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
|
||||
this.CloseCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
|
||||
}
|
||||
}
|
||||
|
||||
public void CloseAsync() {
|
||||
this.CloseAsync(null);
|
||||
}
|
||||
|
||||
public void CloseAsync(object userState) {
|
||||
if ((this.onBeginCloseDelegate == null)) {
|
||||
this.onBeginCloseDelegate = new BeginOperationDelegate(this.OnBeginClose);
|
||||
}
|
||||
if ((this.onEndCloseDelegate == null)) {
|
||||
this.onEndCloseDelegate = new EndOperationDelegate(this.OnEndClose);
|
||||
}
|
||||
if ((this.onCloseCompletedDelegate == null)) {
|
||||
this.onCloseCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnCloseCompleted);
|
||||
}
|
||||
base.InvokeAsync(this.onBeginCloseDelegate, null, this.onEndCloseDelegate, this.onCloseCompletedDelegate, userState);
|
||||
}
|
||||
|
||||
/*
|
||||
protected override WebServiceMoonlightTest.ServiceReference1.IService1 CreateChannel() {
|
||||
return new Service1ClientChannel(this);
|
||||
}
|
||||
|
||||
private class Service1ClientChannel : ChannelBase<WebServiceMoonlightTest.ServiceReference1.IService1>, WebServiceMoonlightTest.ServiceReference1.IService1 {
|
||||
|
||||
public Service1ClientChannel(System.ServiceModel.ClientBase<WebServiceMoonlightTest.ServiceReference1.IService1> client) :
|
||||
base(client) {
|
||||
}
|
||||
|
||||
public System.IAsyncResult BeginGetData(System.AsyncCallback callback, object asyncState) {
|
||||
object[] _args = new object[0];
|
||||
System.IAsyncResult _result = base.BeginInvoke("GetData", _args, callback, asyncState);
|
||||
return _result;
|
||||
}
|
||||
|
||||
public object EndGetData(System.IAsyncResult result) {
|
||||
object[] _args = new object[0];
|
||||
object _result = ((object)(base.EndInvoke("GetData", _args, result)));
|
||||
return _result;
|
||||
}
|
||||
|
||||
public System.IAsyncResult BeginGetCollectionData(System.AsyncCallback callback, object asyncState) {
|
||||
object[] _args = new object[0];
|
||||
System.IAsyncResult _result = base.BeginInvoke("GetCollectionData", _args, callback, asyncState);
|
||||
return _result;
|
||||
}
|
||||
|
||||
public System.Collections.Generic.IEnumerable<object> EndGetCollectionData(System.IAsyncResult result) {
|
||||
object[] _args = new object[0];
|
||||
System.Collections.Generic.IEnumerable<object> _result = ((System.Collections.Generic.IEnumerable<object>)(base.EndInvoke("GetCollectionData", _args, result)));
|
||||
return _result;
|
||||
}
|
||||
|
||||
public System.IAsyncResult BeginGetNestedData(System.AsyncCallback callback, object asyncState) {
|
||||
object[] _args = new object[0];
|
||||
System.IAsyncResult _result = base.BeginInvoke("GetNestedData", _args, callback, asyncState);
|
||||
return _result;
|
||||
}
|
||||
|
||||
public WebServiceMoonlightTest.ServiceReference1.DataType2 EndGetNestedData(System.IAsyncResult result) {
|
||||
object[] _args = new object[0];
|
||||
WebServiceMoonlightTest.ServiceReference1.DataType2 _result = ((WebServiceMoonlightTest.ServiceReference1.DataType2)(base.EndInvoke("GetNestedData", _args, result)));
|
||||
return _result;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
+14
@@ -1533,6 +1533,20 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
Assert.IsTrue (sw.ToString ().IndexOf (expectedPart) > 0, assert);
|
||||
return (T) ds.ReadObject (XmlReader.Create (new StringReader (sw.ToString ())));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DateTimeOffsetSerialization ()
|
||||
{
|
||||
var ds = new DataContractSerializer (typeof (DateTimeOffset));
|
||||
var sw = new StringWriter ();
|
||||
string xml = "<DateTimeOffset xmlns:i='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://schemas.datacontract.org/2004/07/System'><DateTime>2011-03-01T02:05:06.078Z</DateTime><OffsetMinutes>120</OffsetMinutes></DateTimeOffset>".Replace ('\'', '"');
|
||||
var v = new DateTimeOffset (new DateTime (2011, 3, 1, 4, 5, 6, 78), TimeSpan.FromMinutes (120));
|
||||
using (var xw = XmlWriter.Create (sw, settings)) {
|
||||
ds.WriteObject (xw, v);
|
||||
}
|
||||
Assert.AreEqual (xml, sw.ToString (), "#1");
|
||||
Assert.AreEqual (v, ds.ReadObject (XmlReader.Create (new StringReader (sw.ToString ()))), "#2");
|
||||
}
|
||||
}
|
||||
|
||||
[DataContract]
|
||||
|
||||
+15
@@ -45,6 +45,13 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
[TestFixture]
|
||||
public class XsdDataContractExporterTest
|
||||
{
|
||||
internal const string MSSimpleNamespace =
|
||||
"http://schemas.microsoft.com/2003/10/Serialization/";
|
||||
internal const string MSArraysNamespace =
|
||||
"http://schemas.microsoft.com/2003/10/Serialization/Arrays";
|
||||
internal const string DefaultClrNamespaceBase =
|
||||
"http://schemas.datacontract.org/2004/07/";
|
||||
|
||||
[Test]
|
||||
public void Ctor1 ()
|
||||
{
|
||||
@@ -153,6 +160,14 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
CheckDcFull (xdce.Schemas);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetSchemaTypeName ()
|
||||
{
|
||||
var xdce = new XsdDataContractExporter ();
|
||||
// bug #670539
|
||||
Assert.AreEqual (new XmlQualifiedName ("ArrayOfstring", MSArraysNamespace), xdce.GetSchemaTypeName (typeof (IEnumerable<string>)), "#1");
|
||||
}
|
||||
|
||||
//Helper methods
|
||||
|
||||
XmlSchemas GetSchemas (XmlSchemaSet set)
|
||||
|
||||
+51
@@ -329,7 +329,58 @@ namespace MonoTests.System.Xml
|
||||
AssertNode (XmlNodeType.Text, "a", "", "", 2, reader, "#4");
|
||||
Assert.IsFalse (reader.ReadAttributeValue (), "#5");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AttributeWithLocalDictQNameIndex ()
|
||||
{
|
||||
XmlDictionary dic = new XmlDictionary ();
|
||||
dic.Add ("xmlns");
|
||||
dic.Add ("http://www.w3.org/2000/xmlns/");
|
||||
dic.Add ("DictionaryValue");
|
||||
dic.Add ("SomeDictionaryString");
|
||||
dic.Add ("AdditionalDictionaryString");
|
||||
|
||||
// <d a="QNameIndex(0,8)"></d>
|
||||
byte [] bytes = new byte [] { 0x40, 0x01, 0x64, 0x04, 0x01, 0x61, 0xbc, 0x00, 0x08, 0x01 };
|
||||
|
||||
XmlDictionaryReader reader = XmlDictionaryReader.CreateBinaryReader (
|
||||
new MemoryStream (bytes), dic, new XmlDictionaryReaderQuotas ());
|
||||
Assert.IsTrue (reader.Read (), "#1");
|
||||
AssertNode (XmlNodeType.Element, "d", "", "", 0, reader, "#2");
|
||||
reader.MoveToAttribute (0);
|
||||
if (reader.LocalName != "a")
|
||||
reader.MoveToAttribute (1);
|
||||
AssertNode (XmlNodeType.Attribute, "a", "", "a:AdditionalDictionaryString", 1, reader, "#3");
|
||||
Assert.IsTrue (reader.ReadAttributeValue (), "#4");
|
||||
AssertNode (XmlNodeType.Text, "a", "", "a:AdditionalDictionaryString", 2, reader, "#5");
|
||||
Assert.IsFalse (reader.ReadAttributeValue (), "#6");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AttributeWithSessionQNameIndex ()
|
||||
{
|
||||
XmlDictionaryString ds;
|
||||
XmlDictionary dic = new XmlDictionary ();
|
||||
XmlBinaryReaderSession ses = new XmlBinaryReaderSession();
|
||||
ses.Add(0, "SessionLookupValue");
|
||||
|
||||
// <d a="QNameIndex(0x18,1)"></d>
|
||||
byte [] bytes = new byte [] { 0x40, 0x01, 0x64, 0x04, 0x01, 0x61, 0xbc, 0x18, 0x01, 0x01 };
|
||||
|
||||
XmlDictionaryReader reader = XmlDictionaryReader.CreateBinaryReader (
|
||||
new MemoryStream (bytes), dic, new XmlDictionaryReaderQuotas (), ses);
|
||||
Assert.IsTrue (reader.Read (), "#1");
|
||||
AssertNode (XmlNodeType.Element, "d", "", "", 0, reader, "#2");
|
||||
reader.MoveToAttribute (0);
|
||||
if (reader.LocalName != "a")
|
||||
reader.MoveToAttribute (1);
|
||||
AssertNode (XmlNodeType.Attribute, "a", "", "y:SessionLookupValue", 1, reader, "#3");
|
||||
Assert.IsTrue (reader.ReadAttributeValue (), "#4");
|
||||
AssertNode (XmlNodeType.Text, "a", "", "y:SessionLookupValue", 2, reader, "#5");
|
||||
reader.MoveToContent ();
|
||||
Assert.IsFalse (reader.ReadAttributeValue (), "#6");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReadTypedValues ()
|
||||
{
|
||||
|
||||
-8
@@ -50,14 +50,6 @@ namespace System.ServiceModel.Channels
|
||||
this.via = via;
|
||||
}
|
||||
|
||||
protected internal override TimeSpan DefaultCloseTimeout {
|
||||
get { return channel_factory.DefaultCloseTimeout; }
|
||||
}
|
||||
|
||||
protected internal override TimeSpan DefaultOpenTimeout {
|
||||
get { return channel_factory.DefaultOpenTimeout; }
|
||||
}
|
||||
|
||||
public EndpointAddress RemoteAddress {
|
||||
get { return address; }
|
||||
}
|
||||
|
||||
+31
@@ -31,6 +31,7 @@ using System.ServiceModel.Channels;
|
||||
using System.ServiceModel.Description;
|
||||
using System.ServiceModel.Dispatcher;
|
||||
using System.ServiceModel.Discovery;
|
||||
using System.Xml;
|
||||
|
||||
namespace System.ServiceModel.Discovery.Version11
|
||||
{
|
||||
@@ -47,8 +48,16 @@ namespace System.ServiceModel.Discovery.Version11
|
||||
[MessageContract (IsWrapped = false)]
|
||||
public class OnlineAnnouncement
|
||||
{
|
||||
public OnlineAnnouncement ()
|
||||
{
|
||||
Id = new UniqueId ();
|
||||
}
|
||||
|
||||
[MessageHeader (Name = "AppSequence", Namespace = NS)]
|
||||
public DiscoveryMessageSequence11 MessageSequence { get; set; }
|
||||
[MessageHeader (Name = "MessageID", Namespace = "http://www.w3.org/2005/08/addressing")]
|
||||
public UniqueId Id { get; set; }
|
||||
|
||||
[MessageBodyMember (Name = "Hello", Namespace = NS)]
|
||||
public EndpointDiscoveryMetadata11 EndpointDiscoveryMetadata { get; set; }
|
||||
}
|
||||
@@ -56,8 +65,15 @@ namespace System.ServiceModel.Discovery.Version11
|
||||
[MessageContract (IsWrapped = false)]
|
||||
public class OfflineAnnouncement
|
||||
{
|
||||
public OfflineAnnouncement ()
|
||||
{
|
||||
Id = new UniqueId ();
|
||||
}
|
||||
|
||||
[MessageHeader (Name = "AppSequence", Namespace = NS)]
|
||||
public DiscoveryMessageSequence11 MessageSequence { get; set; }
|
||||
[MessageHeader (Name = "MessageID", Namespace = "http://www.w3.org/2005/08/addressing")]
|
||||
public UniqueId Id { get; set; }
|
||||
[MessageBodyMember (Name = "Bye", Namespace = NS)]
|
||||
public EndpointDiscoveryMetadata11 EndpointDiscoveryMetadata { get; set; }
|
||||
}
|
||||
@@ -65,6 +81,14 @@ namespace System.ServiceModel.Discovery.Version11
|
||||
[MessageContract (IsWrapped = false)]
|
||||
public class FindRequest
|
||||
{
|
||||
public FindRequest ()
|
||||
{
|
||||
Id = new UniqueId ();
|
||||
}
|
||||
|
||||
[MessageHeader (Name = "MessageID", Namespace = "http://www.w3.org/2005/08/addressing")]
|
||||
public UniqueId Id { get; set; }
|
||||
|
||||
[MessageBodyMember (Name = "Probe", Namespace = NS)]
|
||||
public FindCriteria11 Body { get; set; }
|
||||
}
|
||||
@@ -86,6 +110,13 @@ namespace System.ServiceModel.Discovery.Version11
|
||||
[MessageContract (IsWrapped = false)]
|
||||
public class ResolveRequest
|
||||
{
|
||||
public ResolveRequest ()
|
||||
{
|
||||
Id = new UniqueId ();
|
||||
}
|
||||
|
||||
[MessageHeader (Name = "MessageID", Namespace = "http://www.w3.org/2005/08/addressing")]
|
||||
public UniqueId Id { get; set; }
|
||||
[MessageBodyMember (Name = "Resolve", Namespace = NS)]
|
||||
public ResolveCriteria11 Body { get; set; }
|
||||
}
|
||||
|
||||
+5
@@ -60,6 +60,11 @@ namespace System.ServiceModel.Discovery.VersionApril2005
|
||||
return new XmlQualifiedName ("AppSequenceType", version.Namespace);
|
||||
}
|
||||
|
||||
// for deserialization
|
||||
DiscoveryMessageSequenceApril2005 ()
|
||||
{
|
||||
}
|
||||
|
||||
internal DiscoveryMessageSequenceApril2005 (DiscoveryMessageSequence source)
|
||||
{
|
||||
this.source = source;
|
||||
|
||||
+30
@@ -31,6 +31,7 @@ using System.ServiceModel.Channels;
|
||||
using System.ServiceModel.Description;
|
||||
using System.ServiceModel.Dispatcher;
|
||||
using System.ServiceModel.Discovery;
|
||||
using System.Xml;
|
||||
|
||||
namespace System.ServiceModel.Discovery.VersionApril2005
|
||||
{
|
||||
@@ -47,8 +48,16 @@ namespace System.ServiceModel.Discovery.VersionApril2005
|
||||
[MessageContract (IsWrapped = false)]
|
||||
public class OnlineAnnouncement
|
||||
{
|
||||
public OnlineAnnouncement ()
|
||||
{
|
||||
Id = new UniqueId ();
|
||||
}
|
||||
|
||||
[MessageHeader (Name = "AppSequence", Namespace = NS)]
|
||||
public DiscoveryMessageSequenceApril2005 MessageSequence { get; set; }
|
||||
[MessageHeader (Name = "MessageID", Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")]
|
||||
public UniqueId Id { get; set; }
|
||||
|
||||
[MessageBodyMember (Name = "Hello", Namespace = NS)]
|
||||
public EndpointDiscoveryMetadataApril2005 EndpointDiscoveryMetadata { get; set; }
|
||||
}
|
||||
@@ -56,8 +65,15 @@ namespace System.ServiceModel.Discovery.VersionApril2005
|
||||
[MessageContract (IsWrapped = false)]
|
||||
public class OfflineAnnouncement
|
||||
{
|
||||
public OfflineAnnouncement ()
|
||||
{
|
||||
Id = new UniqueId ();
|
||||
}
|
||||
|
||||
[MessageHeader (Name = "AppSequence", Namespace = NS)]
|
||||
public DiscoveryMessageSequenceApril2005 MessageSequence { get; set; }
|
||||
[MessageHeader (Name = "MessageID", Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")]
|
||||
public UniqueId Id { get; set; }
|
||||
[MessageBodyMember (Name = "Bye", Namespace = NS)]
|
||||
public EndpointDiscoveryMetadataApril2005 EndpointDiscoveryMetadata { get; set; }
|
||||
}
|
||||
@@ -65,6 +81,13 @@ namespace System.ServiceModel.Discovery.VersionApril2005
|
||||
[MessageContract (IsWrapped = false)]
|
||||
public class FindRequest
|
||||
{
|
||||
public FindRequest ()
|
||||
{
|
||||
Id = new UniqueId ();
|
||||
}
|
||||
|
||||
[MessageHeader (Name = "MessageID", Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")]
|
||||
public UniqueId Id { get; set; }
|
||||
[MessageBodyMember (Name = "Probe", Namespace = NS)]
|
||||
public FindCriteriaApril2005 Body { get; set; }
|
||||
}
|
||||
@@ -86,6 +109,13 @@ namespace System.ServiceModel.Discovery.VersionApril2005
|
||||
[MessageContract (IsWrapped = false)]
|
||||
public class ResolveRequest
|
||||
{
|
||||
public ResolveRequest ()
|
||||
{
|
||||
Id = new UniqueId ();
|
||||
}
|
||||
|
||||
[MessageHeader (Name = "MessageID", Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")]
|
||||
public UniqueId Id { get; set; }
|
||||
[MessageBodyMember (Name = "Resolve", Namespace = NS)]
|
||||
public ResolveCriteriaApril2005 Body { get; set; }
|
||||
}
|
||||
|
||||
+30
@@ -31,6 +31,7 @@ using System.ServiceModel.Channels;
|
||||
using System.ServiceModel.Description;
|
||||
using System.ServiceModel.Dispatcher;
|
||||
using System.ServiceModel.Discovery;
|
||||
using System.Xml;
|
||||
|
||||
namespace System.ServiceModel.Discovery.VersionCD1
|
||||
{
|
||||
@@ -47,8 +48,16 @@ namespace System.ServiceModel.Discovery.VersionCD1
|
||||
[MessageContract (IsWrapped = false)]
|
||||
public class OnlineAnnouncement
|
||||
{
|
||||
public OnlineAnnouncement ()
|
||||
{
|
||||
Id = new UniqueId ();
|
||||
}
|
||||
|
||||
[MessageHeader (Name = "AppSequence", Namespace = NS)]
|
||||
public DiscoveryMessageSequenceCD1 MessageSequence { get; set; }
|
||||
[MessageHeader (Name = "MessageID", Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")]
|
||||
public UniqueId Id { get; set; }
|
||||
|
||||
[MessageBodyMember (Name = "Hello", Namespace = NS)]
|
||||
public EndpointDiscoveryMetadataCD1 EndpointDiscoveryMetadata { get; set; }
|
||||
}
|
||||
@@ -56,8 +65,15 @@ namespace System.ServiceModel.Discovery.VersionCD1
|
||||
[MessageContract (IsWrapped = false)]
|
||||
public class OfflineAnnouncement
|
||||
{
|
||||
public OfflineAnnouncement ()
|
||||
{
|
||||
Id = new UniqueId ();
|
||||
}
|
||||
|
||||
[MessageHeader (Name = "AppSequence", Namespace = NS)]
|
||||
public DiscoveryMessageSequenceCD1 MessageSequence { get; set; }
|
||||
[MessageHeader (Name = "MessageID", Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")]
|
||||
public UniqueId Id { get; set; }
|
||||
[MessageBodyMember (Name = "Bye", Namespace = NS)]
|
||||
public EndpointDiscoveryMetadataCD1 EndpointDiscoveryMetadata { get; set; }
|
||||
}
|
||||
@@ -65,6 +81,13 @@ namespace System.ServiceModel.Discovery.VersionCD1
|
||||
[MessageContract (IsWrapped = false)]
|
||||
public class FindRequest
|
||||
{
|
||||
public FindRequest ()
|
||||
{
|
||||
Id = new UniqueId ();
|
||||
}
|
||||
|
||||
[MessageHeader (Name = "MessageID", Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")]
|
||||
public UniqueId Id { get; set; }
|
||||
[MessageBodyMember (Name = "Probe", Namespace = NS)]
|
||||
public FindCriteriaCD1 Body { get; set; }
|
||||
}
|
||||
@@ -86,6 +109,13 @@ namespace System.ServiceModel.Discovery.VersionCD1
|
||||
[MessageContract (IsWrapped = false)]
|
||||
public class ResolveRequest
|
||||
{
|
||||
public ResolveRequest ()
|
||||
{
|
||||
Id = new UniqueId ();
|
||||
}
|
||||
|
||||
[MessageHeader (Name = "MessageID", Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")]
|
||||
public UniqueId Id { get; set; }
|
||||
[MessageBodyMember (Name = "Resolve", Namespace = NS)]
|
||||
public ResolveCriteriaCD1 Body { get; set; }
|
||||
}
|
||||
|
||||
+3
-3
@@ -84,19 +84,19 @@ namespace System.ServiceModel.Discovery
|
||||
|
||||
public static bool operator == (DiscoveryMessageSequence messageSequence1, DiscoveryMessageSequence messageSequence2)
|
||||
{
|
||||
return messageSequence1 != null ? messageSequence1.Equals (messageSequence2) : messageSequence2 == null;
|
||||
return object.ReferenceEquals (messageSequence1, null) ? object.ReferenceEquals (messageSequence2, null) : messageSequence1.Equals (messageSequence2);
|
||||
}
|
||||
|
||||
public static bool operator != (DiscoveryMessageSequence messageSequence1, DiscoveryMessageSequence messageSequence2)
|
||||
{
|
||||
return messageSequence1 == null ? messageSequence2 != null : !messageSequence1.Equals (messageSequence2);
|
||||
return object.ReferenceEquals (messageSequence1, null) ? !object.ReferenceEquals (messageSequence2, null) : !messageSequence1.Equals (messageSequence2);
|
||||
}
|
||||
|
||||
internal static DiscoveryMessageSequence ReadXml (XmlReader reader, DiscoveryVersion version)
|
||||
{
|
||||
if (reader == null)
|
||||
throw new ArgumentNullException ("reader");
|
||||
if (reader.LocalName != "AppSequenceType" || reader.NamespaceURI != version.Namespace)
|
||||
if (reader.LocalName != "AppSequence" || reader.NamespaceURI != version.Namespace)
|
||||
throw new ArgumentException (String.Format ("AppSequenceType element in namespace '{0}' was expected. Got '{1}' element in '{2}' namespace", version.Namespace, reader.LocalName, reader.NamespaceURI));
|
||||
|
||||
var instId = reader.GetAttribute ("InstanceId");
|
||||
|
||||
+30
-4
@@ -35,12 +35,15 @@ namespace System.ServiceModel.Discovery
|
||||
{
|
||||
internal class DiscoveryViaUriBehavior : IEndpointBehavior
|
||||
{
|
||||
public DiscoveryViaUriBehavior (Uri via)
|
||||
public DiscoveryViaUriBehavior (DiscoveryVersion version, Uri via)
|
||||
{
|
||||
Via = via;
|
||||
this.version = version;
|
||||
this.via = via;
|
||||
}
|
||||
|
||||
Uri Via { get; set; }
|
||||
DiscoveryVersion version;
|
||||
|
||||
Uri via;
|
||||
|
||||
public void AddBindingParameters (ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
|
||||
{
|
||||
@@ -53,7 +56,30 @@ namespace System.ServiceModel.Discovery
|
||||
if (clientRuntime == null)
|
||||
throw new ArgumentNullException ("clientRuntime");
|
||||
|
||||
clientRuntime.Via = Via;
|
||||
clientRuntime.Via = via;
|
||||
clientRuntime.MessageInspectors.Add (new ClientMessageInspector (version));
|
||||
}
|
||||
|
||||
class ClientMessageInspector : IClientMessageInspector
|
||||
{
|
||||
public ClientMessageInspector (DiscoveryVersion version)
|
||||
{
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
DiscoveryVersion version;
|
||||
|
||||
public object BeforeSendRequest (ref Message request, IClientChannel channel)
|
||||
{
|
||||
// overwrite To header with version-specific URN.
|
||||
request.Headers.To = version.AdhocAddress;
|
||||
return null;
|
||||
}
|
||||
|
||||
public void AfterReceiveReply (ref Message reply, object correlationState)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
public void ApplyDispatchBehavior (ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
|
||||
|
||||
Loaded 100 of 348 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user