mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-16 11:21:08 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce3b0b7564 | ||
|
|
a9777b31fc | ||
|
|
7dcacbb5bf | ||
|
|
5f8f48145d | ||
|
|
b8052728ea | ||
|
|
3f823404fc | ||
|
|
e3658fe73e | ||
|
|
3f43883b30 | ||
|
|
c9f2555f4a | ||
|
|
8fa55bb406 | ||
|
|
ea78b00406 | ||
|
|
fb2c69e852 | ||
|
|
26536ad29f | ||
|
|
24702d5e64 | ||
|
|
79bf69008d | ||
|
|
0d20226656 | ||
|
|
e4f59e1fa0 | ||
|
|
bf77046abc | ||
|
|
985f57d2b4 | ||
|
|
aca8c70648 | ||
|
|
be8a6afd4a | ||
|
|
b313b63718 | ||
|
|
80238cef2f | ||
|
|
776a4cb2b5 | ||
|
|
a96c5dd131 | ||
|
|
c79e051d35 | ||
|
|
0adb5a6dbf | ||
|
|
64ba822460 | ||
|
|
db59c744af | ||
|
|
d0ecf17cec | ||
|
|
86b0b2afed | ||
|
|
db9d1fffba | ||
|
|
c5c488ec9d | ||
|
|
11cee69b5f | ||
|
|
0dd62ba176 | ||
|
|
40f9aba00f | ||
|
|
643148f131 | ||
|
|
099d0f0e34 | ||
|
|
9187dbc0d9 | ||
|
|
a9c68584df | ||
|
|
50dadb263b | ||
|
|
1106b9be5f | ||
|
|
ec6e3150f8 | ||
|
|
824336a958 | ||
|
|
5a414980ea | ||
|
|
7215e2b879 | ||
|
|
12d359a6c4 | ||
|
|
182883c4ba | ||
|
|
1ed5a802a9 | ||
|
|
b0a314db2c | ||
|
|
4234f30930 | ||
|
|
12de169c29 | ||
|
|
cafcafe8d7 | ||
|
|
9dd0c9aaa0 | ||
|
|
8e5e7a293e | ||
|
|
e430abe428 | ||
|
|
8ed33a951d | ||
|
|
ef74fcb6bb | ||
|
|
98cf1c90d4 | ||
|
|
aacbe2f237 | ||
|
|
7ac57f726f | ||
|
|
89fee7d373 | ||
|
|
3d56703e92 | ||
|
|
53523879e8 | ||
|
|
7290370f37 | ||
|
|
5923bba0bf | ||
|
|
c8a824af78 | ||
|
|
bb3e8d2323 | ||
|
|
2c74b21642 | ||
|
|
3e7bd993d8 | ||
|
|
ffbdeac062 | ||
|
|
e72666919a | ||
|
|
e57e16fee4 | ||
|
|
af23f3ee26 | ||
|
|
1e137b7fcb | ||
|
|
5340b41cd1 | ||
|
|
11c5664fb4 | ||
|
|
59d034e8a7 | ||
|
|
b178109c1e | ||
|
|
a2a78ecc5d | ||
|
|
c540e335c3 | ||
|
|
b7aaf47762 | ||
|
|
b80dca6c9b | ||
|
|
3dd79d0752 | ||
|
|
a8cb34edbf | ||
|
|
812ee3308e | ||
|
|
53c2bea069 | ||
|
|
e56d2c760b | ||
|
|
3e9df709c8 | ||
|
|
1bd073b713 | ||
|
|
e60acb3ab0 | ||
|
|
6c94fea797 | ||
|
|
a4ae5ad77a | ||
|
|
a8ef691b71 | ||
|
|
047b8446d4 | ||
|
|
66b152ffe0 | ||
|
|
7f3f7f3d28 | ||
|
|
fcd76072e0 | ||
|
|
b4e8b39a6e | ||
|
|
e22f04bbdc | ||
|
|
ebab6e9fad | ||
|
|
fe220bb14f | ||
|
|
2af17e6d19 | ||
|
|
5bbd6c23f8 | ||
|
|
320abe5356 | ||
|
|
cee9574eec | ||
|
|
6cc6d1f172 | ||
|
|
fd0bfb7e2e | ||
|
|
8f8e0a9b6e | ||
|
|
71f131be40 | ||
|
|
c96c5db231 | ||
|
|
4e0819daab | ||
|
|
07ddd5f698 | ||
|
|
9ec474d427 | ||
|
|
0810ccda41 | ||
|
|
f7a4dbc112 | ||
|
|
a247e53faa | ||
|
|
c86ebb4da5 | ||
|
|
b225c4736c | ||
|
|
992872bb5d | ||
|
|
a4d5c71207 | ||
|
|
958ce2ba14 | ||
|
|
82e0de5779 | ||
|
|
6e20527322 | ||
|
|
9c4c7d85e0 | ||
|
|
c52ce4b572 | ||
|
|
5b9892f071 | ||
|
|
60f34bbaed | ||
|
|
ff39c58bac | ||
|
|
249e6665eb | ||
|
|
3cd7aaf9c8 | ||
|
|
40d02e9a1d | ||
|
|
725ac8d811 | ||
|
|
b34102015d | ||
|
|
b311360048 | ||
|
|
20808baa2c | ||
|
|
b78ad6ad48 | ||
|
|
b93091c617 | ||
|
|
d6b8fed5be | ||
|
|
f12d23c5cc | ||
|
|
f7bbde7bb5 | ||
|
|
0e15d77a17 | ||
|
|
4e01dad1f8 | ||
|
|
406d680f31 | ||
|
|
7bde20118b | ||
|
|
3a7370aefc | ||
|
|
2087d7c1a1 | ||
|
|
ed57d90570 | ||
|
|
fc3f496d1b | ||
|
|
39ece5f8c7 | ||
|
|
b5b8d4a42e | ||
|
|
792bd0b4e3 | ||
|
|
e8e244f839 | ||
|
|
bb58f668b3 | ||
|
|
ecdf344983 | ||
|
|
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
+22
-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.2)
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
API_VER=2.0
|
||||
@@ -1560,6 +1560,12 @@ if test x$target_win32 = xno; then
|
||||
AC_DEFINE(HAVE_EPOLL, 1, [epoll supported])
|
||||
fi
|
||||
|
||||
havekqueue=no
|
||||
AC_CHECK_FUNCS(kqueue, , AC_MSG_CHECKING(for kqueue in sys/event.h)
|
||||
AC_TRY_LINK([#include <sys/event.h>],
|
||||
[ kqueue(); ],
|
||||
AC_DEFINE(HAVE_KQUEUE, 1, [Have kqueue]) AC_MSG_RESULT(yes),
|
||||
AC_MSG_RESULT(no)))
|
||||
dnl ******************************
|
||||
dnl *** Checks for SIOCGIFCONF ***
|
||||
dnl ******************************
|
||||
@@ -2262,8 +2268,10 @@ 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
|
||||
# libgc's gc_locks.h depends on this
|
||||
NESTED_LIBGC_FLAGS="$NESTED_LIBGC_FLAGS -DHAVE_ARMV6"
|
||||
sgen_supported=true
|
||||
;;
|
||||
arm*-linux*)
|
||||
@@ -2561,6 +2569,18 @@ 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")
|
||||
# libgc's gc_locks.h depends on this
|
||||
NESTED_LIBGC_FLAGS="$NESTED_LIBGC_FLAGS -DHAVE_ARMV6"
|
||||
fi
|
||||
fi
|
||||
|
||||
if test ${TARGET} = unknown; then
|
||||
|
||||
@@ -3,3 +3,5 @@
|
||||
/config
|
||||
/.cvsignore
|
||||
/*.pc
|
||||
/gdb/mono-sgen-gdb.py
|
||||
/mono-sgen-gdb.py
|
||||
+8
-2
@@ -21,8 +21,10 @@ pkgconfigdir = $(libdir)/pkgconfig
|
||||
|
||||
if SUPPORT_SGEN
|
||||
SGENPCFILE=monosgen-2.pc
|
||||
SGENGDBFILE=mono-sgen-gdb.py
|
||||
else
|
||||
SGENPCFILE=
|
||||
SGENGDBFILE=
|
||||
endif
|
||||
|
||||
if JIT_SUPPORTED
|
||||
@@ -38,11 +40,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 monosgen-2.pc 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 $(SGENGDBFILE)
|
||||
|
||||
+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
|
||||
@@ -62,8 +62,6 @@ typedef int pid_t;
|
||||
#undef G_HAVE_STRNDUP
|
||||
#define G_HAVE_GETOPT_H 1
|
||||
|
||||
int vasprintf(char **ret, const char *fmt, va_list ap);
|
||||
|
||||
/* disable the following warnings
|
||||
* C4100: The formal parameter is not referenced in the body of the function. The unreferenced parameter is ignored.
|
||||
* C4127: conditional expression is constant
|
||||
@@ -71,4 +69,5 @@ int vasprintf(char **ret, const char *fmt, va_list ap);
|
||||
#pragma warning(disable:4100 4127)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
typedef void * GPid;
|
||||
#endif
|
||||
@@ -47,14 +47,14 @@ g_dir_open (const gchar *path, guint flags, GError **error)
|
||||
GDir *dir;
|
||||
gunichar2* path_utf16;
|
||||
gunichar2* path_utf16_search;
|
||||
WIN32_FIND_DATA find_data;
|
||||
WIN32_FIND_DATAW find_data;
|
||||
|
||||
g_return_val_if_fail (path != NULL, NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
||||
dir = g_new0 (GDir, 1);
|
||||
path_utf16 = u8to16 (path);
|
||||
path_utf16_search = g_malloc ((wcslen(path_utf16) + 3)*sizeof(gunichar2));
|
||||
path_utf16_search = g_malloc ((wcslen((wchar_t *) path_utf16) + 3)*sizeof(gunichar2));
|
||||
wcscpy (path_utf16_search, path_utf16);
|
||||
wcscat (path_utf16_search, L"\\*");
|
||||
|
||||
@@ -72,7 +72,7 @@ g_dir_open (const gchar *path, guint flags, GError **error)
|
||||
g_free (path_utf16_search);
|
||||
g_free (path_utf16);
|
||||
|
||||
while ((wcscmp (find_data.cFileName, L".") == 0) || (wcscmp (find_data.cFileName, L"..") == 0)) {
|
||||
while ((wcscmp ((wchar_t *) find_data.cFileName, L".") == 0) || (wcscmp ((wchar_t *) find_data.cFileName, L"..") == 0)) {
|
||||
if (!FindNextFileW (dir->handle, &find_data)) {
|
||||
if (error) {
|
||||
gint err = errno;
|
||||
@@ -91,7 +91,7 @@ g_dir_open (const gchar *path, guint flags, GError **error)
|
||||
const gchar *
|
||||
g_dir_read_name (GDir *dir)
|
||||
{
|
||||
WIN32_FIND_DATA find_data;
|
||||
WIN32_FIND_DATAW find_data;
|
||||
|
||||
g_return_val_if_fail (dir != NULL && dir->handle != 0, NULL);
|
||||
|
||||
@@ -111,7 +111,7 @@ g_dir_read_name (GDir *dir)
|
||||
dir->next = NULL;
|
||||
return dir->current;
|
||||
}
|
||||
} while ((wcscmp (find_data.cFileName, L".") == 0) || (wcscmp (find_data.cFileName, L"..") == 0));
|
||||
} while ((wcscmp ((wchar_t *) find_data.cFileName, L".") == 0) || (wcscmp ((wchar_t *) find_data.cFileName, L"..") == 0));
|
||||
|
||||
dir->next = u16to8 (find_data.cFileName);
|
||||
return dir->current;
|
||||
|
||||
@@ -33,9 +33,14 @@
|
||||
#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>
|
||||
#endif
|
||||
#ifdef G_OS_WIN32
|
||||
int mkstemp (char *tmp_template);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -39,9 +39,13 @@
|
||||
#ifdef G_OS_WIN32
|
||||
#include <io.h>
|
||||
#define open _open
|
||||
#ifndef S_ISREG
|
||||
#define S_ISREG(x) ((x & _S_IFMT) == _S_IFREG)
|
||||
#endif
|
||||
#ifndef S_ISDIR
|
||||
#define S_ISDIR(x) ((x & _S_IFMT) == _S_IFDIR)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int mkstemp (char *tmp_template)
|
||||
{
|
||||
|
||||
+7
-11
@@ -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>
|
||||
@@ -48,6 +40,12 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
/* MSC and Cross-compilatin will use this */
|
||||
int vasprintf (char **strp, const char *fmt, va_list ap);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Basic data types
|
||||
*/
|
||||
@@ -677,7 +675,7 @@ gunichar *g_utf16_to_ucs4 (const gunichar2 *str, glong len, glong *items_read,
|
||||
#define u8to16(str) g_utf8_to_utf16(str, (glong)strlen(str), NULL, NULL, NULL)
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#define u16to8(str) g_utf16_to_utf8(str, (glong)wcslen(str), NULL, NULL, NULL)
|
||||
#define u16to8(str) g_utf16_to_utf8((gunichar2 *) (str), (glong)wcslen((wchar_t *) (str)), NULL, NULL, NULL)
|
||||
#else
|
||||
#define u16to8(str) g_utf16_to_utf8(str, (glong)strlen(str), NULL, NULL, NULL)
|
||||
#endif
|
||||
@@ -720,8 +718,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);
|
||||
|
||||
@@ -80,7 +80,7 @@ g_unsetenv(const gchar *variable)
|
||||
{
|
||||
gunichar2 *var;
|
||||
var = u8to16(variable);
|
||||
SetEnvironmentVariableW(var, TEXT(""));
|
||||
SetEnvironmentVariableW(var, L"");
|
||||
g_free(var);
|
||||
}
|
||||
|
||||
@@ -98,14 +98,15 @@ g_path_is_absolute (const char *filename)
|
||||
{
|
||||
g_return_val_if_fail (filename != NULL, FALSE);
|
||||
|
||||
if (filename[0] != '\0' && filename[1] != '\0')
|
||||
if (filename[1] == ':' && filename[2] != '\0' &&
|
||||
if (filename[0] != '\0' && filename[1] != '\0') {
|
||||
if (filename[1] == ':' && filename[2] != '\0' &&
|
||||
(filename[2] == '\\' || filename[2] == '/'))
|
||||
return TRUE;
|
||||
/* UNC paths */
|
||||
else if (filename[0] == '\\' && filename[1] == '\\' &&
|
||||
filename[2] != '\0')
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ g_module_open (const gchar *file, GModuleFlags flags)
|
||||
gunichar2 *file16;
|
||||
file16 = u8to16(file);
|
||||
module->main_module = FALSE;
|
||||
module->handle = LoadLibrary (file16);
|
||||
module->handle = LoadLibraryW (file16);
|
||||
g_free(file16);
|
||||
if (!module->handle) {
|
||||
g_free (module);
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ split_cmdline (const gchar *cmdline, GPtrArray *array, GError **error)
|
||||
} else if (quote_char) {
|
||||
if (c == quote_char) {
|
||||
quote_char = '\0';
|
||||
if (fresh && g_ascii_isspace (*ptr)){
|
||||
if (fresh && (g_ascii_isspace (*ptr) || *ptr == '\0')){
|
||||
g_ptr_array_add (array, g_string_free (str, FALSE));
|
||||
str = g_string_new ("");
|
||||
}
|
||||
|
||||
+2
-1
@@ -79,6 +79,7 @@ gchar ***_NSGetEnviron();
|
||||
extern char **environ;
|
||||
#endif
|
||||
|
||||
#ifndef G_OS_WIN32
|
||||
static int
|
||||
safe_read (int fd, gchar *buffer, gint count, GError **error)
|
||||
{
|
||||
@@ -185,7 +186,7 @@ create_pipe (int *fds, GError **error)
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif /* G_OS_WIN32 */
|
||||
gboolean
|
||||
g_spawn_command_line_sync (const gchar *command_line,
|
||||
gchar **standard_output,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -71,7 +71,7 @@ utf8_to_utf16_len (const gchar *str, glong len, glong *items_read, GError **erro
|
||||
ret = 0;
|
||||
|
||||
/* Common case */
|
||||
for (in_pos = 0; in_pos < len && str [in_pos] < 0x80; in_pos++)
|
||||
for (in_pos = 0; in_pos < len && (guchar) str [in_pos] < 0x80; in_pos++)
|
||||
ret ++;
|
||||
|
||||
if (in_pos == len) {
|
||||
@@ -338,6 +338,7 @@ g_utf16_to_utf8 (const gunichar2 *str, glong len, glong *items_read, glong *item
|
||||
} else {
|
||||
surrogate = 0;
|
||||
/* invalid surrogate pair */
|
||||
++in_pos;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
@@ -354,6 +355,7 @@ g_utf16_to_utf8 (const gunichar2 *str, glong len, glong *items_read, glong *item
|
||||
else if (ch >= 0xD800 && ch <= 0xDBFF)
|
||||
surrogate = ch;
|
||||
else if (ch >= 0xDC00 && ch <= 0xDFFF) {
|
||||
++in_pos;
|
||||
/* invalid surrogate pair */
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ int vasprintf(char **ret, const char *fmt, va_list ap)
|
||||
len = vsnprintf(NULL, 0, fmt, ap2);
|
||||
#endif
|
||||
|
||||
if (len > 0 && (buf = malloc((buflen = (size_t) (len + 1)))) != NULL) {
|
||||
if (len >= 0 && (buf = malloc ((buflen = (size_t) (len + 1)))) != NULL) {
|
||||
len = vsnprintf(buf, buflen, fmt, ap);
|
||||
*ret = buf;
|
||||
} else {
|
||||
@@ -28,3 +28,4 @@ int vasprintf(char **ret, const char *fmt, va_list ap)
|
||||
va_end(ap2);
|
||||
return len;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ RESULT
|
||||
test_buildpath ()
|
||||
{
|
||||
char *s;
|
||||
char *buffer = "var/private";
|
||||
char *dir = "/";
|
||||
|
||||
s = g_build_path ("/", "hola///", "//mundo", NULL);
|
||||
if (strcmp (s, "hola/mundo") != 0)
|
||||
@@ -99,6 +101,16 @@ test_buildpath ()
|
||||
return FAILED ("must get a non-NULL return");
|
||||
if (s [0] != 0)
|
||||
return FAILED ("must get an empty string");
|
||||
|
||||
// This is to test the regression introduced by Levi for the Windows support
|
||||
// that code errouneously read below the allowed area (in this case dir [-1]).
|
||||
// and caused all kinds of random errors.
|
||||
dir = "//";
|
||||
dir++;
|
||||
s = g_build_filename (dir, buffer, NULL);
|
||||
if (s [0] != '/')
|
||||
return FAILED ("Must have a '/' at the start");
|
||||
|
||||
g_free (s);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -250,6 +250,14 @@
|
||||
#endif
|
||||
}
|
||||
# define GC_TEST_AND_SET_DEFINED
|
||||
inline static void GC_clear(volatile unsigned int *addr) {
|
||||
#ifdef HAVE_ARMV6
|
||||
/* Memory barrier */
|
||||
__asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r" (0) : "memory");
|
||||
#endif
|
||||
*(addr) = 0;
|
||||
}
|
||||
# define GC_CLEAR_DEFINED
|
||||
# endif /* ARM32 */
|
||||
# ifdef CRIS
|
||||
inline static int GC_test_and_set(volatile unsigned int *addr) {
|
||||
|
||||
+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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -654,6 +654,11 @@ namespace System.Windows.Forms
|
||||
|
||||
public int Init ()
|
||||
{
|
||||
int p = (int) Environment.OSVersion.Platform;
|
||||
if ((p != 4) && (p != 6) && (p != 128))
|
||||
// Not running on Unix.
|
||||
return -1;
|
||||
|
||||
CheckFDOMimePaths ();
|
||||
|
||||
if (!fdo_mime_available)
|
||||
|
||||
@@ -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)
|
||||
|
||||
+73
@@ -23,7 +23,9 @@
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Web;
|
||||
using System.Web.Util;
|
||||
|
||||
@@ -43,6 +45,42 @@ namespace Microsoft.Web.Infrastructure.DynamicValidationHelper
|
||||
this.wrapped = wrapped;
|
||||
}
|
||||
|
||||
public new string this [int index] {
|
||||
get { return Get (index); }
|
||||
}
|
||||
|
||||
public new string this [string name] {
|
||||
get { return Get (name); }
|
||||
set{ Set (name,value); }
|
||||
}
|
||||
|
||||
public override string[] AllKeys {
|
||||
get { return wrapped.AllKeys; }
|
||||
}
|
||||
|
||||
public override int Count {
|
||||
get { return wrapped.Count; }
|
||||
}
|
||||
|
||||
public override NameObjectCollectionBase.KeysCollection Keys {
|
||||
get { return wrapped.Keys; }
|
||||
}
|
||||
|
||||
public new void Add (NameValueCollection c)
|
||||
{
|
||||
wrapped.Add (c);
|
||||
}
|
||||
|
||||
public override void Add (string name, string val)
|
||||
{
|
||||
wrapped.Add (name, val);
|
||||
}
|
||||
|
||||
public override void Clear ()
|
||||
{
|
||||
wrapped.Clear ();
|
||||
}
|
||||
|
||||
public override string Get (string name)
|
||||
{
|
||||
return Validate (name, wrapped.Get (name));
|
||||
@@ -53,6 +91,41 @@ namespace Microsoft.Web.Infrastructure.DynamicValidationHelper
|
||||
return Validate (wrapped.GetKey (index), wrapped.Get (index));
|
||||
}
|
||||
|
||||
public override void GetObjectData (SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
wrapped.GetObjectData (info, context);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public override void OnDeserialization (object sender)
|
||||
{
|
||||
wrapped.OnDeserialization (sender);
|
||||
}
|
||||
|
||||
public override void Set (string name, string value)
|
||||
{
|
||||
wrapped.Set (name, value);
|
||||
}
|
||||
|
||||
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
|
||||
@@ -1,56 +1,18 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
//
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
//
|
||||
// General Information about the assembly
|
||||
|
||||
[assembly: AssemblyTitle("Mono.WebBrowser")]
|
||||
[assembly: AssemblyDescription("Managed Wrapper for xulrunner engine, to support WebBrowser")]
|
||||
[assembly: AssemblyConfiguration("Development version")]
|
||||
[assembly: AssemblyCompany("MONO development team")]
|
||||
|
||||
[assembly: AssemblyProduct("Mono.WebBrowser")]
|
||||
[assembly: AssemblyCopyright("(c) 2007, 2008 Andreia Gaita")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
|
||||
//
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion (Consts.FxVersion)]
|
||||
[assembly: AssemblyInformationalVersion (Consts.FxFileVersion)]
|
||||
[assembly: AssemblyFileVersion (Consts.FxFileVersion)]
|
||||
|
||||
[assembly: AssemblyVersion("0.5.0.0")]
|
||||
|
||||
//
|
||||
// In order to sign your assembly you must specify a key to use. Refer to the
|
||||
// Microsoft .NET Framework documentation for more information on assembly signing.
|
||||
//
|
||||
// Use the attributes below to control which key is used for signing.
|
||||
//
|
||||
// Notes:
|
||||
// (*) If no key is specified, the assembly is not signed.
|
||||
// (*) KeyName refers to a key that has been installed in the Crypto Service
|
||||
// Provider (CSP) on your machine. KeyFile refers to a file which contains
|
||||
// a key.
|
||||
// (*) If the KeyFile and the KeyName values are both specified, the
|
||||
// following processing occurs:
|
||||
// (1) If the KeyName can be found in the CSP, that key is used.
|
||||
// (2) If the KeyName does not exist and the KeyFile does exist, the key
|
||||
// in the KeyFile is installed into the CSP and used.
|
||||
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
|
||||
// When specifying the KeyFile, the location of the KeyFile should be
|
||||
// relative to the project output directory which is
|
||||
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
|
||||
// located in the project directory, you would specify the AssemblyKeyFile
|
||||
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
|
||||
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
|
||||
// documentation for more information on this.
|
||||
//
|
||||
[assembly: AssemblyDelaySign(true)]
|
||||
[assembly: AssemblyKeyFile("../mono.snk")]
|
||||
+83
-7
@@ -2,9 +2,9 @@
|
||||
// CustomValidationAttribute.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Habersack <[email protected]>
|
||||
// Marek Habersack <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2010 Novell Inc. (http://novell.com)
|
||||
// Copyright (C) 2010-2011 Novell Inc. (http://novell.com)
|
||||
//
|
||||
|
||||
//
|
||||
@@ -30,35 +30,111 @@
|
||||
#if NET_4_0
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace System.ComponentModel.DataAnnotations
|
||||
{
|
||||
[AttributeUsage (AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = true)]
|
||||
public sealed class CustomValidationAttribute : ValidationAttribute
|
||||
{
|
||||
Tuple <string, Type> typeId;
|
||||
MethodInfo validationMethod;
|
||||
bool validationMethodChecked;
|
||||
bool validationMethodSignatureValid;
|
||||
int validationMethodParamCount;
|
||||
|
||||
public string Method { get; private set; }
|
||||
|
||||
public override object TypeId {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
get { return typeId; }
|
||||
}
|
||||
|
||||
public Type ValidatorType { get; private set; }
|
||||
|
||||
public CustomValidationAttribute (Type validatorType, string method)
|
||||
{
|
||||
this.ValidatorType = validatorType;
|
||||
this.Method = method;
|
||||
this.typeId = new Tuple <string, Type> (method, validatorType);
|
||||
}
|
||||
|
||||
public override string FormatErrorMessage (string name)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
ThrowIfAttributeNotWellFormed ();
|
||||
return String.Format ("{0} is not valid.", name);
|
||||
}
|
||||
|
||||
// LAMESPEC: MSDN doesn't document it at all, but corcompare shows it in the type
|
||||
protected override ValidationResult IsValid (object value, ValidationContext validationContext)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
ThrowIfAttributeNotWellFormed ();
|
||||
object[] p;
|
||||
|
||||
if (validationMethodParamCount == 2)
|
||||
p = new object [] {value, validationContext};
|
||||
else
|
||||
p = new object [] {value};
|
||||
try {
|
||||
return validationMethod.Invoke (null, p) as ValidationResult;
|
||||
} catch (TargetInvocationException ex) {
|
||||
if (ex.InnerException != null)
|
||||
throw ex.InnerException;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void ThrowIfAttributeNotWellFormed ()
|
||||
{
|
||||
Type type = ValidatorType;
|
||||
if (type == null)
|
||||
throw new InvalidOperationException ("The CustomValidationAttribute.ValidatorType was not specified.");
|
||||
|
||||
if (type.IsNotPublic)
|
||||
throw new InvalidOperationException (String.Format ("The custom validation type '{0}' must be public.", type.Name));
|
||||
|
||||
string method = Method;
|
||||
if (String.IsNullOrEmpty (method))
|
||||
throw new InvalidOperationException ("The CustomValidationAttribute.Method was not specified.");
|
||||
|
||||
if (validationMethod == null) {
|
||||
if (!validationMethodChecked) {
|
||||
validationMethod = type.GetMethod (method, BindingFlags.Public | BindingFlags.Static);
|
||||
validationMethodChecked = true;
|
||||
}
|
||||
|
||||
if (validationMethod == null)
|
||||
throw new InvalidOperationException (
|
||||
String.Format ("The CustomValidationAttribute method '{0}' does not exist in type '{1}' or is not public and static.",
|
||||
method, type.Name));
|
||||
|
||||
if (!typeof (ValidationResult).IsAssignableFrom (validationMethod.ReturnType))
|
||||
throw new InvalidOperationException (String.Format ("The CustomValidationAttribute method '{0}' in type '{1}' must return System.ComponentModel.DataAnnotations.ValidationResult. Use System.ComponentModel.DataAnnotations.ValidationResult.Success to represent success.", method, type.Name));
|
||||
|
||||
validationMethodSignatureValid = true;
|
||||
ParameterInfo[] parameters = validationMethod.GetParameters ();
|
||||
if (parameters == null)
|
||||
validationMethodSignatureValid = false;
|
||||
else {
|
||||
validationMethodParamCount = parameters.Length;
|
||||
switch (validationMethodParamCount) {
|
||||
case 1:
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (parameters [1].ParameterType != typeof (ValidationContext))
|
||||
validationMethodSignatureValid = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
validationMethodSignatureValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!validationMethodSignatureValid)
|
||||
throw new InvalidOperationException (String.Format ("The CustomValidationAttribute method '{0}' in type '{1}' must match the expected signature: public static ValidationResult MethodTwo(object value, ValidationContext context). The value can be strongly typed. The ValidationContext parameter is optional.", method, type.Name));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+42
-9
@@ -37,7 +37,10 @@ namespace System.ComponentModel.DataAnnotations
|
||||
public abstract class ValidationAttribute : Attribute
|
||||
{
|
||||
const string DEFAULT_ERROR_MESSAGE = "The field {0} is invalid.";
|
||||
#if !NET_4_0
|
||||
#if NET_4_0
|
||||
object nestedCallLock = new object ();
|
||||
bool nestedCall;
|
||||
#else
|
||||
string errorMessageResourceName;
|
||||
string errorMessageString;
|
||||
Type errorMessageResourceType;
|
||||
@@ -127,20 +130,50 @@ namespace System.ComponentModel.DataAnnotations
|
||||
get { return GetStringFromResourceAccessor (); }
|
||||
}
|
||||
#if NET_4_0
|
||||
NotImplementedException NestedNIEX ()
|
||||
{
|
||||
return new NotImplementedException ("IsValid(object value) has not been implemented by this class. The preferred entry point is GetValidationResult() and classes should override IsValid(object value, ValidationContext context).");
|
||||
}
|
||||
|
||||
//
|
||||
// This is the weirdest (to be gentle) idea ever... The IsValid (object) overload
|
||||
// throws the NIEX when it is called from the default IsValid (object,
|
||||
// ValidationContext) overload, but not when directly. And the reverse situation is
|
||||
// true as well. That means, the calls detect the "nested" calls and that we need to
|
||||
// protect the nestedCall flag... ugh
|
||||
//
|
||||
public virtual bool IsValid (object value)
|
||||
{
|
||||
throw new NotImplementedException ("IsValid(object value) has not been implemented by this class. The preferred entry point is GetValidationResult() and classes should override IsValid(object value, ValidationContext context).");
|
||||
lock (nestedCallLock) {
|
||||
if (nestedCall)
|
||||
throw NestedNIEX ();
|
||||
try {
|
||||
nestedCall = true;
|
||||
return IsValid (value, null) == ValidationResult.Success;
|
||||
} finally {
|
||||
nestedCall = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual ValidationResult IsValid (object value, ValidationContext validationContext)
|
||||
{
|
||||
// .NET emulation
|
||||
if (validationContext == null)
|
||||
throw new NullReferenceException (".NET emulation.");
|
||||
|
||||
if (!IsValid (value)) {
|
||||
string memberName = validationContext.MemberName;
|
||||
return new ValidationResult (FormatErrorMessage (validationContext.DisplayName), memberName != null ? new string[] { memberName } : new string[] {});
|
||||
lock (nestedCallLock) {
|
||||
if (nestedCall)
|
||||
throw NestedNIEX ();
|
||||
|
||||
try {
|
||||
nestedCall = true;
|
||||
if (!IsValid (value)) {
|
||||
// .NET emulation
|
||||
if (validationContext == null)
|
||||
throw new NullReferenceException (".NET emulation.");
|
||||
string memberName = validationContext.MemberName;
|
||||
return new ValidationResult (FormatErrorMessage (validationContext.DisplayName), memberName != null ? new string[] { memberName } : new string[] {});
|
||||
}
|
||||
} finally {
|
||||
nestedCall = false;
|
||||
}
|
||||
}
|
||||
|
||||
return ValidationResult.Success;
|
||||
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// Authors:
|
||||
// Marek Habersack <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2011 Novell Inc. http://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 System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace System.ComponentModel.DataAnnotations
|
||||
{
|
||||
static class ValidationAttributeCollectionExtensions
|
||||
{
|
||||
public static void Validate <TAttribute> (this AttributeCollection attributes, object value, ValidationContext validationContext,
|
||||
ICollection <ValidationResult> validationResults, ref bool valid)
|
||||
where TAttribute: ValidationAttribute
|
||||
{
|
||||
if (attributes == null || attributes == AttributeCollection.Empty || attributes.Count <= 0)
|
||||
return;
|
||||
|
||||
ValidationResult result;
|
||||
foreach (TAttribute attr in attributes.OfType <TAttribute> ()) {
|
||||
result = attr.GetValidationResult (value, validationContext);
|
||||
if (result != ValidationResult.Success) {
|
||||
valid = false;
|
||||
if (validationResults != null)
|
||||
validationResults.Add (result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void ValidateExcept <TAttribute> (this AttributeCollection attributes, object value, ValidationContext validationContext,
|
||||
ICollection <ValidationResult> validationResults, ref bool valid)
|
||||
where TAttribute: ValidationAttribute
|
||||
{
|
||||
if (attributes == null || attributes == AttributeCollection.Empty || attributes.Count <= 0)
|
||||
return;
|
||||
|
||||
ValidationResult result;
|
||||
ValidationAttribute vattr;
|
||||
foreach (Attribute attr in attributes) {
|
||||
if (attr is TAttribute)
|
||||
continue;
|
||||
vattr = attr as ValidationAttribute;
|
||||
if (vattr == null)
|
||||
continue;
|
||||
|
||||
result = vattr.GetValidationResult (value, validationContext);
|
||||
if (result != ValidationResult.Success) {
|
||||
valid = false;
|
||||
if (validationResults != null)
|
||||
validationResults.Add (result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-1
@@ -4,7 +4,7 @@
|
||||
// Author:
|
||||
// Atsushi Enomoto <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2008 Novell Inc. http://novell.com
|
||||
// Copyright (C) 2008-2011 Novell Inc. http://novell.com
|
||||
//
|
||||
|
||||
//
|
||||
@@ -63,8 +63,12 @@ namespace System.ComponentModel.DataAnnotations
|
||||
}
|
||||
#if NET_4_0
|
||||
public ValidationException (ValidationResult validationResult, ValidationAttribute validatingAttribute, object value)
|
||||
: this (validationResult != null ? validationResult.ErrorMessage : null, validatingAttribute, value)
|
||||
{
|
||||
this.ValidationResult = validationResult;
|
||||
}
|
||||
|
||||
public ValidationResult ValidationResult { get; private set; }
|
||||
#endif
|
||||
public ValidationAttribute ValidationAttribute { get; private set; }
|
||||
public object Value { get; private set; }
|
||||
|
||||
+211
@@ -0,0 +1,211 @@
|
||||
//
|
||||
// Authors:
|
||||
// Marek Habersack <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2011 Novell Inc. http://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 System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace System.ComponentModel.DataAnnotations
|
||||
{
|
||||
// TODO: we could probably use some kind of type cache here
|
||||
public static class Validator
|
||||
{
|
||||
public static bool TryValidateObject (object instance, ValidationContext validationContext, ICollection <ValidationResult> validationResults)
|
||||
{
|
||||
return TryValidateObject (instance, validationContext, validationResults, false);
|
||||
}
|
||||
|
||||
public static bool TryValidateObject (object instance, ValidationContext validationContext, ICollection <ValidationResult> validationResults, bool validateAllProperties)
|
||||
{
|
||||
if (instance == null)
|
||||
throw new ArgumentNullException ("instance");
|
||||
|
||||
if (validationContext == null)
|
||||
throw new ArgumentNullException ("validationContext");
|
||||
|
||||
if (!Object.ReferenceEquals (instance, validationContext.ObjectInstance))
|
||||
throw new ArgumentException ("The instance provided must match the ObjectInstance on the ValidationContext supplied.", "instance");
|
||||
|
||||
ValidationResult result;
|
||||
bool valid = true;
|
||||
Type instanceType = instance.GetType ();
|
||||
TypeDescriptor.GetAttributes (instanceType).Validate <ValidationAttribute> (instance, validationContext, validationResults, ref valid);
|
||||
|
||||
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties (instance);
|
||||
if (properties != PropertyDescriptorCollection.Empty && properties.Count > 0) {
|
||||
foreach (PropertyDescriptor pdesc in properties) {
|
||||
object value = pdesc.GetValue (instance);
|
||||
ValidateProperty (pdesc, value, validationContext, validationResults, validateAllProperties, ref valid);
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
static void ValidateProperty (PropertyDescriptor pdesc, object value, ValidationContext validationContext, ICollection <ValidationResult> validationResults,
|
||||
bool validateAll, ref bool valid)
|
||||
{
|
||||
AttributeCollection attributes = pdesc.Attributes;
|
||||
attributes.Validate <RequiredAttribute> (value, validationContext, validationResults, ref valid);
|
||||
if (validateAll)
|
||||
attributes.ValidateExcept <RequiredAttribute> (value, validationContext, validationResults, ref valid);
|
||||
}
|
||||
|
||||
static PropertyDescriptor GetProperty (Type type, string propertyName, object value)
|
||||
{
|
||||
if (String.IsNullOrEmpty (propertyName))
|
||||
throw new ArgumentNullException ("propertyName");
|
||||
|
||||
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties (type);
|
||||
PropertyDescriptor pdesc = null;
|
||||
if (properties != PropertyDescriptorCollection.Empty && properties.Count > 0)
|
||||
pdesc = properties.Find (propertyName, false);
|
||||
|
||||
if (pdesc == null)
|
||||
throw new ArgumentException (String.Format ("The type '{0}' does not contain a public property named '{1}'.", type.Name, propertyName), "propertyName");
|
||||
|
||||
Type valueType = value == null ? null : value.GetType ();
|
||||
Type propertyType = pdesc.PropertyType;
|
||||
bool invalidType = false;
|
||||
|
||||
Console.WriteLine ("valueType == {0}; propertyType == {1} (reference? {2})", valueType == null ? "<null>" : valueType.FullName,
|
||||
propertyType, !propertyType.IsValueType || (Nullable.GetUnderlyingType (propertyType) != null));
|
||||
if (valueType == null)
|
||||
invalidType = !(!propertyType.IsValueType || (Nullable.GetUnderlyingType (propertyType) != null));
|
||||
else if (propertyType != valueType)
|
||||
invalidType = true;
|
||||
|
||||
if (invalidType)
|
||||
throw new ArgumentException (String.Format ("The value of property '{0}' must be of type '{1}'.", propertyName, type.FullName), "propertyName");
|
||||
|
||||
return pdesc;
|
||||
}
|
||||
|
||||
public static bool TryValidateProperty (object value, ValidationContext validationContext, ICollection <ValidationResult> validationResults)
|
||||
{
|
||||
// LAMESPEC: value can be null, validationContext must not
|
||||
if (validationContext == null)
|
||||
throw new ArgumentNullException ("validationContext");
|
||||
|
||||
PropertyDescriptor pdesc = GetProperty (validationContext.ObjectType, validationContext.MemberName, value);
|
||||
if (value == null)
|
||||
return true;
|
||||
|
||||
bool valid = true;
|
||||
ValidateProperty (pdesc, value, validationContext, validationResults, true, ref valid);
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
public static bool TryValidateValue (object value, ValidationContext validationContext, ICollection<ValidationResult> validationResults,
|
||||
IEnumerable <ValidationAttribute> validationAttributes)
|
||||
{
|
||||
if (validationContext == null)
|
||||
throw new ArgumentNullException ("validationContext");
|
||||
|
||||
ValidationResult result;
|
||||
|
||||
// It appears .NET makes this call before checking whether
|
||||
// validationAttributes is null...
|
||||
ValidationAttribute vattr = validationAttributes.FirstOrDefault <ValidationAttribute> (attr => attr is RequiredAttribute);
|
||||
if (vattr != null) {
|
||||
result = vattr.GetValidationResult (value, validationContext);
|
||||
if (result != ValidationResult.Success) {
|
||||
if (validationResults != null)
|
||||
validationResults.Add (result);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (validationAttributes == null)
|
||||
return true;
|
||||
|
||||
bool valid = true;
|
||||
foreach (ValidationAttribute attr in validationAttributes) {
|
||||
if (attr == null || (attr is RequiredAttribute))
|
||||
continue;
|
||||
|
||||
result = attr.GetValidationResult (value, validationContext);
|
||||
if (result != ValidationResult.Success) {
|
||||
valid = false;
|
||||
if (validationResults != null)
|
||||
validationResults.Add (result);
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
public static void ValidateObject (object instance, ValidationContext validationContext)
|
||||
{
|
||||
ValidateObject (instance, validationContext, false);
|
||||
}
|
||||
|
||||
public static void ValidateObject (object instance, ValidationContext validationContext, bool validateAllProperties)
|
||||
{
|
||||
if (instance == null)
|
||||
throw new ArgumentNullException ("instance");
|
||||
if (validationContext == null)
|
||||
throw new ArgumentNullException ("validationContext");
|
||||
|
||||
var validationResults = new List <ValidationResult> ();
|
||||
if (TryValidateObject (instance, validationContext, validationResults, validateAllProperties))
|
||||
return;
|
||||
|
||||
ValidationResult result = validationResults.Count > 0 ? validationResults [0] : null;
|
||||
throw new ValidationException (result, null, instance);
|
||||
}
|
||||
|
||||
public static void ValidateProperty (object value, ValidationContext validationContext)
|
||||
{
|
||||
if (validationContext == null)
|
||||
throw new ArgumentNullException ("validationContext");
|
||||
|
||||
var validationResults = new List <ValidationResult> ();
|
||||
if (TryValidateProperty (value, validationContext, validationResults))
|
||||
return;
|
||||
|
||||
ValidationResult result = validationResults.Count > 0 ? validationResults [0] : null;
|
||||
throw new ValidationException (result, null, value);
|
||||
}
|
||||
|
||||
public static void ValidateValue (object value, ValidationContext validationContext, IEnumerable <ValidationAttribute> validationAttributes)
|
||||
{
|
||||
if (validationContext == null)
|
||||
throw new ArgumentNullException ("validationContext");
|
||||
|
||||
var validationResults = new List <ValidationResult> ();
|
||||
if (TryValidateValue (value, validationContext, validationResults, validationAttributes))
|
||||
return;
|
||||
|
||||
ValidationResult result = validationResults.Count > 0 ? validationResults [0] : null;
|
||||
throw new ValidationException (result, null, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
@@ -1,6 +1,7 @@
|
||||
../../System.Web.DynamicData/Test/Common/AssertExtensions.cs
|
||||
System.ComponentModel.DataAnnotations/AssociatedMetadataTypeTypeDescriptionProviderTests.cs
|
||||
System.ComponentModel.DataAnnotations/AssociationAttributeTest.cs
|
||||
System.ComponentModel.DataAnnotations/CustomValidationAttributeTest.cs
|
||||
System.ComponentModel.DataAnnotations/DisplayAttributeTest.cs
|
||||
System.ComponentModel.DataAnnotations/EnumDataTypeAttributeTest.cs
|
||||
System.ComponentModel.DataAnnotations/RangeAttributeTest.cs
|
||||
@@ -9,4 +10,5 @@ System.ComponentModel.DataAnnotations/StringLengthAttributeTest.cs
|
||||
System.ComponentModel.DataAnnotations/ValidationAttributeTest.cs
|
||||
System.ComponentModel.DataAnnotations/ValidationContextTest.cs
|
||||
System.ComponentModel.DataAnnotations/ValidationResultTest.cs
|
||||
System.ComponentModel.DataAnnotations/ValidatorTest.cs
|
||||
System.ComponentModel.DataAnnotations/RegularExpressionAttributeTest.cs
|
||||
+332
@@ -0,0 +1,332 @@
|
||||
//
|
||||
// Authors:
|
||||
// Marek Habersack <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2011 Novell, Inc. (http://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 System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Text;
|
||||
|
||||
using NUnit.Framework;
|
||||
using MonoTests.Common;
|
||||
|
||||
namespace MonoTests.System.ComponentModel.DataAnnotations
|
||||
{
|
||||
#if NET_4_0
|
||||
[TestFixture]
|
||||
public class CustomValidationAttributeTest
|
||||
{
|
||||
[Test]
|
||||
public void Constructor ()
|
||||
{
|
||||
var attr = new CustomValidationAttribute (null, "MyMethod");
|
||||
Assert.IsNull (attr.ValidatorType, "#A1-1");
|
||||
Assert.AreEqual ("MyMethod", attr.Method, "#A1-2");
|
||||
|
||||
attr = new CustomValidationAttribute (typeof (string), null);
|
||||
Assert.AreEqual (typeof (string), attr.ValidatorType, "#A2-1");
|
||||
Assert.IsNull (attr.Method, "#A2-2");
|
||||
|
||||
attr = new CustomValidationAttribute (null, null);
|
||||
Assert.IsNull (attr.ValidatorType, "#A3-1");
|
||||
Assert.IsNull (attr.Method, "#A3-2");
|
||||
|
||||
attr = new CustomValidationAttribute (typeof (string), "NoSuchMethod");
|
||||
Assert.AreEqual (typeof (string), attr.ValidatorType, "#A5-1");
|
||||
Assert.AreEqual ("NoSuchMethod", attr.Method, "#A5-2");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TypeId ()
|
||||
{
|
||||
var attr = new CustomValidationAttribute (null, "MyMethod");
|
||||
Assert.IsNotNull (attr.TypeId, "#A1-1");
|
||||
Assert.AreEqual (typeof (Tuple<string, Type>), attr.TypeId.GetType (), "#A1-2");
|
||||
|
||||
var typeid = attr.TypeId as Tuple <string, Type>;
|
||||
Assert.IsNotNull (typeid.Item1, "#A2-1");
|
||||
Assert.AreEqual ("MyMethod", typeid.Item1, "#A2-2");
|
||||
Assert.IsNull (typeid.Item2, "#A2-3");
|
||||
|
||||
attr = new CustomValidationAttribute (typeof (CustomValidationAttributeTest), "MyMethod");
|
||||
typeid = attr.TypeId as Tuple<string, Type>;
|
||||
Assert.IsNotNull (typeid.Item1, "#A3-1");
|
||||
Assert.AreEqual ("MyMethod", typeid.Item1, "#A3-2");
|
||||
Assert.IsNotNull (typeid.Item2, "#A3-3");
|
||||
Assert.AreEqual (typeof (CustomValidationAttributeTest), typeid.Item2, "#A3-4");
|
||||
|
||||
var typeid2 = attr.TypeId as Tuple<string, Type>;
|
||||
Assert.IsTrue (Object.ReferenceEquals (typeid, typeid2), "#A4");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FormatErrorMessage ()
|
||||
{
|
||||
var attr = new CustomValidationAttribute (null, null);
|
||||
string msg = null;
|
||||
|
||||
AssertExtensions.Throws<InvalidOperationException> (() => {
|
||||
// MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage:
|
||||
// System.InvalidOperationException : The CustomValidationAttribute.ValidatorType was not specified.
|
||||
//
|
||||
// at System.ComponentModel.DataAnnotations.CustomValidationAttribute.ThrowIfAttributeNotWellFormed()
|
||||
// at System.ComponentModel.DataAnnotations.CustomValidationAttribute.FormatErrorMessage(String name)
|
||||
// at MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage() in C:\Users\grendel\Documents\Visual Studio 2010\Projects\System.Web.Test\System.Web.Test\System.ComponentModel.DataAnnotations\CustomValidationAttributeTest.cs:line 88
|
||||
|
||||
msg = attr.FormatErrorMessage (null);
|
||||
}, "#A1");
|
||||
|
||||
attr = new CustomValidationAttribute (typeof (string), null);
|
||||
AssertExtensions.Throws<InvalidOperationException> (() => {
|
||||
// MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage:
|
||||
// System.InvalidOperationException : The CustomValidationAttribute.Method was not specified.
|
||||
//
|
||||
// at System.ComponentModel.DataAnnotations.CustomValidationAttribute.ThrowIfAttributeNotWellFormed()
|
||||
// at System.ComponentModel.DataAnnotations.CustomValidationAttribute.FormatErrorMessage(String name)
|
||||
// at MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage() in C:\Users\grendel\Documents\Visual Studio 2010\Projects\System.Web.Test\System.Web.Test\System.ComponentModel.DataAnnotations\CustomValidationAttributeTest.cs:line 102
|
||||
|
||||
msg = attr.FormatErrorMessage (null);
|
||||
}, "#A2");
|
||||
|
||||
attr = new CustomValidationAttribute (typeof (string), String.Empty);
|
||||
AssertExtensions.Throws<InvalidOperationException> (() => {
|
||||
// MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage:
|
||||
// System.InvalidOperationException : The CustomValidationAttribute.Method was not specified.
|
||||
//
|
||||
// at System.ComponentModel.DataAnnotations.CustomValidationAttribute.ThrowIfAttributeNotWellFormed()
|
||||
// at System.ComponentModel.DataAnnotations.CustomValidationAttribute.FormatErrorMessage(String name)
|
||||
// at MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage() in C:\Users\grendel\Documents\Visual Studio 2010\Projects\System.Web.Test\System.Web.Test\System.ComponentModel.DataAnnotations\CustomValidationAttributeTest.cs:line 117
|
||||
|
||||
msg = attr.FormatErrorMessage (null);
|
||||
}, "#A3");
|
||||
|
||||
attr = new CustomValidationAttribute (typeof (string), "NoSuchMethod");
|
||||
AssertExtensions.Throws<InvalidOperationException> (() => {
|
||||
// MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage:
|
||||
// System.InvalidOperationException : The CustomValidationAttribute method 'NoSuchMethod' does not exist in type 'String' or is not public and static.
|
||||
//
|
||||
// at System.ComponentModel.DataAnnotations.CustomValidationAttribute.ThrowIfAttributeNotWellFormed()
|
||||
// at System.ComponentModel.DataAnnotations.CustomValidationAttribute.FormatErrorMessage(String name)
|
||||
// at MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage() in C:\Users\grendel\Documents\Visual Studio 2010\Projects\System.Web.Test\System.Web.Test\System.ComponentModel.DataAnnotations\CustomValidationAttributeTest.cs:line 126
|
||||
|
||||
msg = attr.FormatErrorMessage (null);
|
||||
}, "#A4");
|
||||
|
||||
attr = new CustomValidationAttribute (typeof (PrivateValidatorMethodContainer), "MethodOne");
|
||||
AssertExtensions.Throws<InvalidOperationException> (() => {
|
||||
// MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage:
|
||||
// System.InvalidOperationException : The custom validation type 'PrivateValidatorMethodContainer' must be public.
|
||||
//
|
||||
// at System.ComponentModel.DataAnnotations.CustomValidationAttribute.ThrowIfAttributeNotWellFormed()
|
||||
// at System.ComponentModel.DataAnnotations.CustomValidationAttribute.FormatErrorMessage(String name)
|
||||
// at MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage() in C:\Users\grendel\Documents\Visual Studio 2010\Projects\System.Web.Test\System.Web.Test\System.ComponentModel.DataAnnotations\CustomValidationAttributeTest.cs:line 138
|
||||
|
||||
msg = attr.FormatErrorMessage (null);
|
||||
}, "#A5");
|
||||
|
||||
attr = new CustomValidationAttribute (typeof (PublicValidatorMethodContainer), "MethodOne");
|
||||
AssertExtensions.Throws<InvalidOperationException> (() => {
|
||||
// MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage:
|
||||
// System.InvalidOperationException : The CustomValidationAttribute method 'MethodOne' in type 'PublicValidatorMethodContainer'
|
||||
// must return System.ComponentModel.DataAnnotations.ValidationResult. Use System.ComponentModel.DataAnnotations.ValidationResult.Success
|
||||
// to represent success.
|
||||
//
|
||||
// at System.ComponentModel.DataAnnotations.CustomValidationAttribute.ThrowIfAttributeNotWellFormed()
|
||||
// at System.ComponentModel.DataAnnotations.CustomValidationAttribute.FormatErrorMessage(String name)
|
||||
// at MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage() in C:\Users\grendel\Documents\Visual Studio 2010\Projects\System.Web.Test\System.Web.Test\System.ComponentModel.DataAnnotations\CustomValidationAttributeTest.cs:line 150
|
||||
msg = attr.FormatErrorMessage (null);
|
||||
}, "#A6");
|
||||
|
||||
attr = new CustomValidationAttribute (typeof (PublicValidatorMethodContainer), "MethodTwo");
|
||||
AssertExtensions.Throws<InvalidOperationException> (() => {
|
||||
// MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage:
|
||||
// System.InvalidOperationException : The CustomValidationAttribute method 'MethodTwo' in type 'PublicValidatorMethodContainer' must match the expected signature: public static ValidationResult MethodTwo(object value, ValidationContext context). The value can be strongly typed. The ValidationContext parameter is optional.
|
||||
//
|
||||
// at System.ComponentModel.DataAnnotations.CustomValidationAttribute.ThrowIfAttributeNotWellFormed()
|
||||
// at System.ComponentModel.DataAnnotations.CustomValidationAttribute.FormatErrorMessage(String name)
|
||||
// at MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage() in C:\Users\grendel\Documents\Visual Studio 2010\Projects\System.Web.Test\System.Web.Test\System.ComponentModel.DataAnnotations\CustomValidationAttributeTest.cs:line 163
|
||||
msg = attr.FormatErrorMessage (null);
|
||||
}, "#A7");
|
||||
|
||||
attr = new CustomValidationAttribute (typeof (PublicValidatorMethodContainer), "MethodThree");
|
||||
msg = attr.FormatErrorMessage (null);
|
||||
Assert.IsNotNull (msg, "#A8-1");
|
||||
Assert.IsTrue (msg.Length > 0, "#A8-2");
|
||||
Assert.AreEqual (" is not valid.", msg, "#A8-3");
|
||||
|
||||
attr = new CustomValidationAttribute (typeof (PublicValidatorMethodContainer), "MethodFour");
|
||||
msg = attr.FormatErrorMessage ("test");
|
||||
Assert.IsNotNull (msg, "#A9-1");
|
||||
Assert.IsTrue (msg.Length > 0, "#A9-2");
|
||||
Assert.AreEqual ("test is not valid.", msg, "#A9-3");
|
||||
|
||||
attr = new CustomValidationAttribute (typeof (PublicValidatorMethodContainer), "MethodFive");
|
||||
AssertExtensions.Throws<InvalidOperationException> (() => {
|
||||
// MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage:
|
||||
// System.InvalidOperationException : The CustomValidationAttribute method 'MethodFive' in type 'PublicValidatorMethodContainer' must match the expected signature: public static ValidationResult MethodFive(object value, ValidationContext context). The value can be strongly typed. The ValidationContext parameter is optional.
|
||||
//
|
||||
// at System.ComponentModel.DataAnnotations.CustomValidationAttribute.ThrowIfAttributeNotWellFormed()
|
||||
// at System.ComponentModel.DataAnnotations.CustomValidationAttribute.FormatErrorMessage(String name)
|
||||
// at MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage() in C:\Users\grendel\Documents\Visual Studio 2010\Projects\System.Web.Test\System.Web.Test\System.ComponentModel.DataAnnotations\CustomValidationAttributeTest.cs:line 180
|
||||
msg = attr.FormatErrorMessage (null);
|
||||
}, "#A10");
|
||||
|
||||
attr = new CustomValidationAttribute (typeof (PublicValidatorMethodContainer), "MethodSix");
|
||||
AssertExtensions.Throws<InvalidOperationException> (() => {
|
||||
// MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage:
|
||||
// System.InvalidOperationException : The CustomValidationAttribute method 'MethodSix' in type 'PublicValidatorMethodContainer' must match the expected signature: public static ValidationResult MethodSix(object value, ValidationContext context). The value can be strongly typed. The ValidationContext parameter is optional.
|
||||
//
|
||||
// at System.ComponentModel.DataAnnotations.CustomValidationAttribute.ThrowIfAttributeNotWellFormed()
|
||||
// at System.ComponentModel.DataAnnotations.CustomValidationAttribute.FormatErrorMessage(String name)
|
||||
// at MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage() in C:\Users\grendel\Documents\Visual Studio 2010\Projects\System.Web.Test\System.Web.Test\System.ComponentModel.DataAnnotations\CustomValidationAttributeTest.cs:line 191
|
||||
msg = attr.FormatErrorMessage (null);
|
||||
}, "#A11");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsValid ()
|
||||
{
|
||||
var attr = new CustomValidationAttribute (null, null);
|
||||
|
||||
AssertExtensions.Throws<InvalidOperationException> (() => {
|
||||
attr.IsValid ("test");
|
||||
}, "#A1");
|
||||
|
||||
attr = new CustomValidationAttribute (typeof (string), null);
|
||||
AssertExtensions.Throws<InvalidOperationException> (() => {
|
||||
attr.IsValid ("test");
|
||||
}, "#A2");
|
||||
|
||||
attr = new CustomValidationAttribute (typeof (string), String.Empty);
|
||||
AssertExtensions.Throws<InvalidOperationException> (() => {
|
||||
attr.IsValid ("test");
|
||||
}, "#A3");
|
||||
|
||||
attr = new CustomValidationAttribute (typeof (string), "NoSuchMethod");
|
||||
AssertExtensions.Throws<InvalidOperationException> (() => {
|
||||
attr.IsValid ("test");
|
||||
}, "#A4");
|
||||
|
||||
attr = new CustomValidationAttribute (typeof (PrivateValidatorMethodContainer), "MethodOne");
|
||||
AssertExtensions.Throws<InvalidOperationException> (() => {
|
||||
attr.IsValid ("test");
|
||||
}, "#A5");
|
||||
|
||||
attr = new CustomValidationAttribute (typeof (PublicValidatorMethodContainer), "MethodOne");
|
||||
AssertExtensions.Throws<InvalidOperationException> (() => {
|
||||
attr.IsValid ("test");
|
||||
}, "#A6");
|
||||
|
||||
attr = new CustomValidationAttribute (typeof (PublicValidatorMethodContainer), "MethodTwo");
|
||||
AssertExtensions.Throws<InvalidOperationException> (() => {
|
||||
attr.IsValid ("test");
|
||||
}, "#A7");
|
||||
|
||||
attr = new CustomValidationAttribute (typeof (PublicValidatorMethodContainer), "MethodThree");
|
||||
bool valid = attr.IsValid ("test");
|
||||
Assert.IsTrue (valid, "#A8-1");
|
||||
valid = attr.IsValid (null);
|
||||
Assert.IsFalse (valid, "#A8-2");
|
||||
valid = attr.IsValid ("failTest");
|
||||
Assert.IsFalse (valid, "#A8-3");
|
||||
|
||||
attr = new CustomValidationAttribute (typeof (PublicValidatorMethodContainer), "MethodFour");
|
||||
valid = attr.IsValid ("test");
|
||||
Assert.IsTrue (valid, "#A9-1");
|
||||
valid = attr.IsValid (null);
|
||||
Assert.IsFalse (valid, "#A9-2");
|
||||
valid = attr.IsValid ("failTest");
|
||||
Assert.IsFalse (valid, "#A9-3");
|
||||
|
||||
attr = new CustomValidationAttribute (typeof (PublicValidatorMethodContainer), "MethodFive");
|
||||
AssertExtensions.Throws<InvalidOperationException> (() => {
|
||||
attr.IsValid ("test");
|
||||
}, "#A10");
|
||||
|
||||
attr = new CustomValidationAttribute (typeof (PublicValidatorMethodContainer), "MethodSix");
|
||||
AssertExtensions.Throws<InvalidOperationException> (() => {
|
||||
attr.IsValid ("test");
|
||||
}, "#A11");
|
||||
|
||||
attr = new CustomValidationAttribute (typeof (PublicValidatorMethodContainer), "MethodSeven");
|
||||
AssertExtensions.Throws<ApplicationException> (() => {
|
||||
attr.IsValid ("test");
|
||||
}, "#A12");
|
||||
}
|
||||
|
||||
class PrivateValidatorMethodContainer
|
||||
{
|
||||
public static void MethodOne ()
|
||||
{ }
|
||||
}
|
||||
|
||||
public class PublicValidatorMethodContainer
|
||||
{
|
||||
public static void MethodOne ()
|
||||
{ }
|
||||
|
||||
public static ValidationResult MethodTwo ()
|
||||
{
|
||||
return ValidationResult.Success;
|
||||
}
|
||||
|
||||
public static ValidationResult MethodThree (object o)
|
||||
{
|
||||
if (o == null)
|
||||
return new ValidationResult ("Object cannot be null");
|
||||
string s = o as string;
|
||||
if (s == null || s != "failTest")
|
||||
return ValidationResult.Success;
|
||||
return new ValidationResult ("Test failed as requested");
|
||||
}
|
||||
|
||||
public static ValidationResult MethodFour (object o, ValidationContext ctx)
|
||||
{
|
||||
if (o == null)
|
||||
return new ValidationResult ("Object cannot be null");
|
||||
string s = o as string;
|
||||
if (s == null || s != "failTest")
|
||||
return ValidationResult.Success;
|
||||
return new ValidationResult ("Test failed as requested");
|
||||
}
|
||||
|
||||
public static ValidationResult MethodFive (object o, string s)
|
||||
{
|
||||
return ValidationResult.Success;
|
||||
}
|
||||
|
||||
public static ValidationResult MethodSix (object o, ValidationContext ctx, string s)
|
||||
{
|
||||
return ValidationResult.Success;
|
||||
}
|
||||
|
||||
public static ValidationResult MethodSeven (object o, ValidationContext ctx)
|
||||
{
|
||||
throw new ApplicationException ("SNAFU");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
+69
-17
@@ -31,6 +31,7 @@ using System.ComponentModel.DataAnnotations;
|
||||
using System.Text;
|
||||
|
||||
using NUnit.Framework;
|
||||
using MonoTests.Common;
|
||||
|
||||
namespace MonoTests.System.ComponentModel.DataAnnotations
|
||||
{
|
||||
@@ -446,19 +447,19 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
|
||||
{
|
||||
var attr = new ValidateFooAttribute ();
|
||||
|
||||
try {
|
||||
AssertExtensions.Throws <NotImplementedException> (() => {
|
||||
// It calls IsValid (object, validationContext) which throws the NIEX, but when that overload is called directly, there's
|
||||
// no exception.
|
||||
//
|
||||
// at System.ComponentModel.DataAnnotations.ValidationAttribute.IsValid(Object value, ValidationContext validationContext)
|
||||
// at System.ComponentModel.DataAnnotations.ValidationAttribute.IsValid(Object value)
|
||||
// at MonoTests.System.ComponentModel.DataAnnotations.ValidationAttributeTest.IsValid_Object() in C:\Users\grendel\Documents\Visual Studio 2010\Projects\System.Web.Test\System.Web.Test\System.ComponentModel.DataAnnotations\ValidationAttributeTest.cs:line 450
|
||||
attr.IsValid (null);
|
||||
Assert.Fail ("#A1-1");
|
||||
} catch (NotImplementedException) {
|
||||
// success
|
||||
}
|
||||
|
||||
try {
|
||||
}, "#A1-1");
|
||||
|
||||
AssertExtensions.Throws <NotImplementedException> (() => {
|
||||
attr.IsValid ("stuff");
|
||||
Assert.Fail ("#A1-2");
|
||||
} catch (NotImplementedException) {
|
||||
// success
|
||||
}
|
||||
}, "#A1-2");
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -466,13 +467,9 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
|
||||
{
|
||||
var attr = new ValidateBarAttribute ();
|
||||
|
||||
try {
|
||||
// ...
|
||||
AssertExtensions.Throws <NullReferenceException> (() => {
|
||||
attr.CallIsValid (null, null);
|
||||
Assert.Fail ("#A1");
|
||||
} catch (NullReferenceException) {
|
||||
// success
|
||||
}
|
||||
}, "#A1");
|
||||
|
||||
var vc = new ValidationContext ("stuff", null, null);
|
||||
var vr = attr.CallIsValid (null, vc);
|
||||
@@ -500,6 +497,41 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
|
||||
Assert.AreEqual ("SomeMember", list [0], "#A3-6");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsValid_Object_ValidationContext_CrossCallsWithNIEX ()
|
||||
{
|
||||
var attr = new ValidateSomethingAttribute ();
|
||||
|
||||
AssertExtensions.Throws<NotImplementedException> (() => {
|
||||
// Thrown from the IsValid (object, ValidationContext) overload!
|
||||
//
|
||||
// MonoTests.System.ComponentModel.DataAnnotations.ValidationAttributeTest.IsValid_Object_ValidationContext_02:
|
||||
// System.NotImplementedException : IsValid(object value) has not been implemented by this class. The preferred entry point is GetValidationResult() and classes should override IsValid(object value, ValidationContext context).
|
||||
//
|
||||
// at System.ComponentModel.DataAnnotations.ValidationAttribute.IsValid(Object value, ValidationContext validationContext)
|
||||
// at MonoTests.System.ComponentModel.DataAnnotations.ValidateSomethingAttribute.IsValid(Object value) in C:\Users\grendel\Documents\Visual Studio 2010\Projects\System.Web.Test\System.Web.Test\System.ComponentModel.DataAnnotations\ValidationAttributeTest.cs:line 639
|
||||
// at System.ComponentModel.DataAnnotations.ValidationAttribute.IsValid(Object value, ValidationContext validationContext)
|
||||
// at MonoTests.System.ComponentModel.DataAnnotations.ValidateSomethingAttribute.IsValid(Object value) in C:\Users\grendel\Documents\Visual Studio 2010\Projects\System.Web.Test\System.Web.Test\System.ComponentModel.DataAnnotations\ValidationAttributeTest.cs:line 639
|
||||
// at MonoTests.System.ComponentModel.DataAnnotations.ValidationAttributeTest.IsValid_Object_ValidationContext_02() in C:\Users\grendel\Documents\Visual Studio 2010\Projects\System.Web.Test\System.Web.Test\System.ComponentModel.DataAnnotations\ValidationAttributeTest.cs:line 514
|
||||
attr.IsValid ("stuff");
|
||||
}, "#A1");
|
||||
|
||||
AssertExtensions.Throws<NotImplementedException> (() => {
|
||||
// And this one is thrown from the IsValid (object) overload!
|
||||
//
|
||||
// MonoTests.System.ComponentModel.DataAnnotations.ValidationAttributeTest.IsValid_Object_ValidationContext_CrossCallsWithNIEX:
|
||||
// System.NotImplementedException : IsValid(object value) has not been implemented by this class. The preferred entry point is GetValidationResult() and classes should override IsValid(object value, ValidationContext context).
|
||||
//
|
||||
// at System.ComponentModel.DataAnnotations.ValidationAttribute.IsValid(Object value)
|
||||
// at MonoTests.System.ComponentModel.DataAnnotations.ValidateSomethingAttribute.IsValid(Object value, ValidationContext validationContext) in C:\Users\grendel\Documents\Visual Studio 2010\Projects\System.Web.Test\System.Web.Test\System.ComponentModel.DataAnnotations\ValidationAttributeTest.cs:line 660
|
||||
// at System.ComponentModel.DataAnnotations.ValidationAttribute.IsValid(Object value)
|
||||
// at MonoTests.System.ComponentModel.DataAnnotations.ValidateSomethingAttribute.IsValid(Object value, ValidationContext validationContext) in C:\Users\grendel\Documents\Visual Studio 2010\Projects\System.Web.Test\System.Web.Test\System.ComponentModel.DataAnnotations\ValidationAttributeTest.cs:line 660
|
||||
// at MonoTests.System.ComponentModel.DataAnnotations.ValidateSomethingAttribute.CallIsValid(Object value, ValidationContext validationContext) in C:\Users\grendel\Documents\Visual Studio 2010\Projects\System.Web.Test\System.Web.Test\System.ComponentModel.DataAnnotations\ValidationAttributeTest.cs:line 667
|
||||
// at MonoTests.System.ComponentModel.DataAnnotations.ValidationAttributeTest.IsValid_Object_ValidationContext_CrossCallsWithNIEX() in C:\Users\grendel\Documents\Visual Studio 2010\Projects\System.Web.Test\System.Web.Test\System.ComponentModel.DataAnnotations\ValidationAttributeTest.cs:line 530
|
||||
|
||||
attr.CallIsValid ("stuff", null);
|
||||
}, "#A2");
|
||||
}
|
||||
[Test]
|
||||
public void Validate_Object_ValidationContext ()
|
||||
{
|
||||
@@ -618,7 +650,27 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
|
||||
return base.FormatErrorMessage (name);
|
||||
}
|
||||
}
|
||||
#if NET_4_0
|
||||
class ValidateSomethingAttribute : ValidationAttribute
|
||||
{
|
||||
public override bool IsValid (object value)
|
||||
{
|
||||
return base.IsValid (value, null) == ValidationResult.Success;
|
||||
}
|
||||
|
||||
protected override ValidationResult IsValid (object value, ValidationContext validationContext)
|
||||
{
|
||||
if (base.IsValid (value))
|
||||
return ValidationResult.Success;
|
||||
return new ValidationResult ("failed to validate in base class");
|
||||
}
|
||||
|
||||
public ValidationResult CallIsValid (object value, ValidationContext validationContext)
|
||||
{
|
||||
return IsValid (value, validationContext);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
class FooErrorMessageProvider
|
||||
{
|
||||
public static string ErrorProperty1
|
||||
|
||||
+1120
File diff suppressed because it is too large.
Load diff
+2
@@ -1,4 +1,6 @@
|
||||
#include System.ComponentModel.DataAnnotations.dll.sources
|
||||
|
||||
System.ComponentModel.DataAnnotations/ValidationAttributeCollectionExtensions.cs
|
||||
System.ComponentModel.DataAnnotations/ValidationContext.cs
|
||||
System.ComponentModel.DataAnnotations/ValidationResult.cs
|
||||
System.ComponentModel.DataAnnotations/Validator.cs
|
||||
@@ -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;
|
||||
|
||||
@@ -123,6 +123,12 @@ namespace System.Threading {
|
||||
}
|
||||
|
||||
public bool TryEnterReadLock (int millisecondsTimeout)
|
||||
{
|
||||
bool dummy = false;
|
||||
return TryEnterReadLock (millisecondsTimeout, ref dummy);
|
||||
}
|
||||
|
||||
public bool TryEnterReadLock (int millisecondsTimeout, ref bool success)
|
||||
{
|
||||
ThreadLockState ctstate = CurrentThreadState;
|
||||
|
||||
@@ -152,7 +158,6 @@ namespace System.Threading {
|
||||
++numReadWaiters;
|
||||
int val = 0;
|
||||
long start = millisecondsTimeout == -1 ? 0 : sw.ElapsedMilliseconds;
|
||||
bool success = false;
|
||||
|
||||
do {
|
||||
/* Check if a writer is present (RwWrite) or if there is someone waiting to
|
||||
@@ -361,34 +366,51 @@ namespace System.Threading {
|
||||
|
||||
++numUpgradeWaiters;
|
||||
long start = millisecondsTimeout == -1 ? 0 : sw.ElapsedMilliseconds;
|
||||
bool taken = false;
|
||||
bool success = false;
|
||||
|
||||
// We first try to obtain the upgradeable right
|
||||
while (!upgradableEvent.IsSet () || !upgradableTaken.TryRelaxedSet ()) {
|
||||
if (millisecondsTimeout != -1 && (sw.ElapsedMilliseconds - start) > millisecondsTimeout) {
|
||||
--numUpgradeWaiters;
|
||||
return false;
|
||||
try {
|
||||
while (!upgradableEvent.IsSet () || !taken) {
|
||||
try {}
|
||||
finally {
|
||||
taken = upgradableTaken.TryRelaxedSet ();
|
||||
}
|
||||
if (taken)
|
||||
break;
|
||||
if (millisecondsTimeout != -1 && (sw.ElapsedMilliseconds - start) > millisecondsTimeout) {
|
||||
--numUpgradeWaiters;
|
||||
return false;
|
||||
}
|
||||
|
||||
upgradableEvent.Wait (ComputeTimeout (millisecondsTimeout, start));
|
||||
}
|
||||
|
||||
upgradableEvent.Wait (ComputeTimeout (millisecondsTimeout, start));
|
||||
}
|
||||
upgradableEvent.Reset ();
|
||||
|
||||
upgradableEvent.Reset ();
|
||||
RuntimeHelpers.PrepareConstrainedRegions ();
|
||||
try {
|
||||
// Then it's a simple reader lock acquiring
|
||||
TryEnterReadLock (ComputeTimeout (millisecondsTimeout, start), ref success);
|
||||
} finally {
|
||||
if (success) {
|
||||
ctstate.LockState = LockState.Upgradable;
|
||||
--ctstate.ReaderRecursiveCount;
|
||||
++ctstate.UpgradeableRecursiveCount;
|
||||
} else {
|
||||
upgradableTaken.Value = false;
|
||||
upgradableEvent.Set ();
|
||||
}
|
||||
}
|
||||
|
||||
// Then it's a simple reader lock acquiring
|
||||
if (TryEnterReadLock (ComputeTimeout (millisecondsTimeout, start))) {
|
||||
ctstate.LockState = LockState.Upgradable;
|
||||
--numUpgradeWaiters;
|
||||
--ctstate.ReaderRecursiveCount;
|
||||
++ctstate.UpgradeableRecursiveCount;
|
||||
return true;
|
||||
} catch {
|
||||
// An async exception occured, if we had taken the upgradable mode, release it
|
||||
if (taken && !success)
|
||||
upgradableTaken.Value = false;
|
||||
}
|
||||
|
||||
upgradableTaken.Value = false;
|
||||
upgradableEvent.Set ();
|
||||
|
||||
--numUpgradeWaiters;
|
||||
|
||||
return false;
|
||||
return success;
|
||||
}
|
||||
|
||||
public bool TryEnterUpgradeableReadLock (TimeSpan timeout)
|
||||
|
||||
@@ -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,10 @@
|
||||
2011-03-22 Veerapuram Varadhan <[email protected]>
|
||||
|
||||
** Fixes #676368 - Patch by [email protected]
|
||||
* OdbcConnection.cs: Make linking/unlinking of OdbcCommands thread safe.
|
||||
* OdbcCommand.cs: Check generation object from connection in order to
|
||||
free the associated statement handle.
|
||||
|
||||
2010-12-07 Veerapuram Varadhan <[email protected]>
|
||||
|
||||
** Fixes #456234 - Patch by [email protected]
|
||||
|
||||
@@ -67,6 +67,7 @@ namespace System.Data.Odbc
|
||||
bool designTimeVisible;
|
||||
bool prepared;
|
||||
IntPtr hstmt = IntPtr.Zero;
|
||||
object generation = null; // validity of hstmt
|
||||
|
||||
bool disposed;
|
||||
|
||||
@@ -353,10 +354,11 @@ namespace System.Data.Odbc
|
||||
OdbcReturn ret;
|
||||
|
||||
if (hstmt != IntPtr.Zero)
|
||||
// Free the existing hstmt. Also unlinks from the connection.
|
||||
FreeStatement ();
|
||||
else
|
||||
Connection.Link (this);
|
||||
|
||||
// Link this command to the connection. The hstmt created below
|
||||
// only remains valid while generation == Connection.generation.
|
||||
generation = Connection.Link (this);
|
||||
ret = libodbc.SQLAllocHandle (OdbcHandleType.Stmt, Connection.hDbc, ref hstmt);
|
||||
if (ret != OdbcReturn.Success && ret != OdbcReturn.SuccessWithInfo)
|
||||
throw connection.CreateOdbcException (OdbcHandleType.Dbc, Connection.hDbc);
|
||||
@@ -376,18 +378,29 @@ namespace System.Data.Odbc
|
||||
if (hstmt == IntPtr.Zero)
|
||||
return;
|
||||
|
||||
// Normally the command is unlinked from the connection, but during
|
||||
// OdbcConnection.Close() this would be pointless and (quadratically)
|
||||
// slow.
|
||||
if (unlink)
|
||||
Connection.Unlink (this);
|
||||
|
||||
// free previously allocated handle.
|
||||
OdbcReturn ret = libodbc.SQLFreeStmt (hstmt, libodbc.SQLFreeStmtOptions.Close);
|
||||
if ((ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo))
|
||||
throw connection.CreateOdbcException (OdbcHandleType.Stmt, hstmt);
|
||||
// Serialize with respect to the connection's own destruction
|
||||
lock(Connection) {
|
||||
// If the connection has already called SQLDisconnect then hstmt
|
||||
// may have already been freed, in which case it is not safe to
|
||||
// use. Thus the generation check.
|
||||
if(Connection.Generation == generation) {
|
||||
// free previously allocated handle.
|
||||
OdbcReturn ret = libodbc.SQLFreeStmt (hstmt, libodbc.SQLFreeStmtOptions.Close);
|
||||
if ((ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo))
|
||||
throw connection.CreateOdbcException (OdbcHandleType.Stmt, hstmt);
|
||||
|
||||
ret = libodbc.SQLFreeHandle ((ushort) OdbcHandleType.Stmt, hstmt);
|
||||
if (ret != OdbcReturn.Success && ret != OdbcReturn.SuccessWithInfo)
|
||||
throw connection.CreateOdbcException (OdbcHandleType.Stmt, hstmt);
|
||||
hstmt = IntPtr.Zero;
|
||||
ret = libodbc.SQLFreeHandle ((ushort) OdbcHandleType.Stmt, hstmt);
|
||||
if (ret != OdbcReturn.Success && ret != OdbcReturn.SuccessWithInfo)
|
||||
throw connection.CreateOdbcException (OdbcHandleType.Stmt, hstmt);
|
||||
}
|
||||
hstmt = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
private void ExecSQL (CommandBehavior behavior, bool createReader, string sql)
|
||||
|
||||
@@ -82,6 +82,14 @@ namespace System.Data.Odbc
|
||||
get { return hdbc; }
|
||||
}
|
||||
|
||||
internal object Generation {
|
||||
// We use the linkedCommands array as a generation indicator for statement
|
||||
// handles allocated in our subsiduary OdbcCommands. The rule is that the
|
||||
// statement handles are only valid if the generation matches the one
|
||||
// returned when the command was linked to the connection.
|
||||
get { return linkedCommands; }
|
||||
}
|
||||
|
||||
[OdbcCategoryAttribute ("DataCategory_Data")]
|
||||
[DefaultValue ("")]
|
||||
[OdbcDescriptionAttribute ("Information used to connect to a Data Source")]
|
||||
@@ -261,21 +269,31 @@ namespace System.Data.Odbc
|
||||
{
|
||||
OdbcReturn ret = OdbcReturn.Error;
|
||||
if (State == ConnectionState.Open) {
|
||||
// close any associated commands
|
||||
if (linkedCommands != null) {
|
||||
for (int i = 0; i < linkedCommands.Count; i++) {
|
||||
WeakReference wr = (WeakReference) linkedCommands [i];
|
||||
if (wr == null)
|
||||
continue;
|
||||
OdbcCommand c = (OdbcCommand) wr.Target;
|
||||
if (c != null)
|
||||
c.Unlink ();
|
||||
lock(this) {
|
||||
// close any associated commands
|
||||
// NOTE: we may 'miss' some if the garbage collector has
|
||||
// already started to destroy them.
|
||||
if (linkedCommands != null) {
|
||||
for (int i = 0; i < linkedCommands.Count; i++) {
|
||||
WeakReference wr = (WeakReference) linkedCommands [i];
|
||||
if (wr == null)
|
||||
continue;
|
||||
OdbcCommand c = (OdbcCommand) wr.Target;
|
||||
if (c != null)
|
||||
c.Unlink ();
|
||||
}
|
||||
linkedCommands = null;
|
||||
}
|
||||
linkedCommands = null;
|
||||
}
|
||||
|
||||
// disconnect
|
||||
ret = libodbc.SQLDisconnect (hdbc);
|
||||
// disconnect
|
||||
ret = libodbc.SQLDisconnect (hdbc);
|
||||
|
||||
}
|
||||
// There could be OdbcCommands outstanding (see NOTE above); their
|
||||
// hstmts will have been freed and therefore will be invalid.
|
||||
// However, they will find that their definition of Generation
|
||||
// does not match the connection's, so they won't try and free
|
||||
// those hstmt.
|
||||
if ((ret != OdbcReturn.Success) && (ret != OdbcReturn.SuccessWithInfo))
|
||||
throw CreateOdbcException (OdbcHandleType.Dbc, hdbc);
|
||||
|
||||
@@ -580,27 +598,33 @@ namespace System.Data.Odbc
|
||||
return value.TrimEnd ('\0');
|
||||
}
|
||||
|
||||
internal void Link (OdbcCommand cmd)
|
||||
internal object Link (OdbcCommand cmd)
|
||||
{
|
||||
if (linkedCommands == null)
|
||||
linkedCommands = new ArrayList ();
|
||||
linkedCommands.Add (new WeakReference (cmd));
|
||||
lock(this) {
|
||||
if (linkedCommands == null)
|
||||
linkedCommands = new ArrayList ();
|
||||
linkedCommands.Add (new WeakReference (cmd));
|
||||
return linkedCommands;
|
||||
}
|
||||
}
|
||||
|
||||
internal void Unlink (OdbcCommand cmd)
|
||||
internal object Unlink (OdbcCommand cmd)
|
||||
{
|
||||
if (linkedCommands == null)
|
||||
return;
|
||||
lock(this) {
|
||||
if (linkedCommands == null)
|
||||
return null;
|
||||
|
||||
for (int i = 0; i < linkedCommands.Count; i++) {
|
||||
WeakReference wr = (WeakReference) linkedCommands [i];
|
||||
if (wr == null)
|
||||
continue;
|
||||
OdbcCommand c = (OdbcCommand) wr.Target;
|
||||
if (c == cmd) {
|
||||
linkedCommands [i] = null;
|
||||
break;
|
||||
for (int i = 0; i < linkedCommands.Count; i++) {
|
||||
WeakReference wr = (WeakReference) linkedCommands [i];
|
||||
if (wr == null)
|
||||
continue;
|
||||
OdbcCommand c = (OdbcCommand) wr.Target;
|
||||
if (c == cmd) {
|
||||
linkedCommands [i] = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return linkedCommands;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
Loaded 100 of 501 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user