mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-19 01:31:17 -10:00
Compare commits
432
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
feaf598cf9 | ||
|
|
c574de067d | ||
|
|
abc18e4340 | ||
|
|
fc169c3839 | ||
|
|
762d5fb72b | ||
|
|
45ce641f28 | ||
|
|
90e0dbcc17 | ||
|
|
56fa47629f | ||
|
|
54ecc9c6a1 | ||
|
|
40d5064d04 | ||
|
|
36cf982222 | ||
|
|
0cf6982962 | ||
|
|
55f400b644 | ||
|
|
06693aa3bb | ||
|
|
63eb94e451 | ||
|
|
9550e4ce08 | ||
|
|
11b2e3e60f | ||
|
|
53c777d22b | ||
|
|
f3b4e40281 | ||
|
|
2fc3754d21 | ||
|
|
2594b36363 | ||
|
|
7f61dee23f | ||
|
|
be58704339 | ||
|
|
19be2cd66a | ||
|
|
daccd00b00 | ||
|
|
e4a37a7663 | ||
|
|
fbd9fd7167 | ||
|
|
644359eb5d | ||
|
|
1bcb295fed | ||
|
|
7ab1185624 | ||
|
|
382210f927 | ||
|
|
98d59927c6 | ||
|
|
a85d5e0285 | ||
|
|
d994c2ea19 | ||
|
|
363b1864e8 | ||
|
|
33e4ab9bde | ||
|
|
8c92a0da08 | ||
|
|
cdd96589ad | ||
|
|
e30fed93a6 | ||
|
|
bbd3769cde | ||
|
|
b79cd5abd3 | ||
|
|
d57d8ccd12 | ||
|
|
4e9f9fcf6e | ||
|
|
edbc59e9db | ||
|
|
96a201f7fe | ||
|
|
46cd052a3a | ||
|
|
724f6285a3 | ||
|
|
72ca429d6c | ||
|
|
e7db8e896a | ||
|
|
599a21d6ae | ||
|
|
da6191eaeb | ||
|
|
93468652f7 | ||
|
|
0c07e4a0b8 | ||
|
|
212e36fc3a | ||
|
|
cbacd4801f | ||
|
|
992e3d6ace | ||
|
|
d8e44958d4 | ||
|
|
75165860c4 | ||
|
|
01abc8bb07 | ||
|
|
ef722ff122 | ||
|
|
93c6b94bb0 | ||
|
|
4c1198f3b8 | ||
|
|
da82237da0 | ||
|
|
dd1826124a | ||
|
|
5b56dc2ce2 | ||
|
|
9209bf5634 | ||
|
|
b5bc9d75d5 | ||
|
|
ee09ac3bcf | ||
|
|
0a17e9070d | ||
|
|
05f4546a96 | ||
|
|
6c3edfc5eb | ||
|
|
b37ba14801 | ||
|
|
4b6494f0c6 | ||
|
|
e00cbf2c42 | ||
|
|
d7e3f8f1bb | ||
|
|
00bdbda27f | ||
|
|
481abfa4f3 | ||
|
|
6a2975513a | ||
|
|
40eaa78a8d | ||
|
|
c4a9aa1f8c | ||
|
|
12cdbfceb7 | ||
|
|
248c37dfa9 | ||
|
|
c8b403250f | ||
|
|
707d914007 | ||
|
|
fcad876ef1 | ||
|
|
f4aa1c4149 | ||
|
|
913a2d5fbd | ||
|
|
6a9c585384 | ||
|
|
0ab2677994 | ||
|
|
8ff7f5748c | ||
|
|
64c326af71 | ||
|
|
bc4e870d2b | ||
|
|
90690f5036 | ||
|
|
04a90dcbb0 | ||
|
|
3f6b4e4fea | ||
|
|
41d1358f09 | ||
|
|
9bcda222de | ||
|
|
1a1c17d59c | ||
|
|
c0cbbb15d9 | ||
|
|
caff055609 | ||
|
|
edbcf074ce | ||
|
|
0943037e68 | ||
|
|
c6994ed5fd | ||
|
|
bc55637bd1 | ||
|
|
93edc5e860 | ||
|
|
50d4232bbe | ||
|
|
80f7e1f15b | ||
|
|
f9bbb7c58b | ||
|
|
ab93080478 | ||
|
|
b1d551265a | ||
|
|
13d44dbcbe | ||
|
|
596921b77d | ||
|
|
3be7b103d8 | ||
|
|
ea4d594639 | ||
|
|
3153dec190 | ||
|
|
6be13313df | ||
|
|
0d40321933 | ||
|
|
d48b2f6a29 | ||
|
|
9be988fc33 | ||
|
|
3ee03145ff | ||
|
|
f62ffb9b89 | ||
|
|
e6f000945f | ||
|
|
3b5d644f27 | ||
|
|
7226a70c87 | ||
|
|
dde6bb81f5 | ||
|
|
7994b74bc4 | ||
|
|
71a7f55907 | ||
|
|
60c5ef5e2b | ||
|
|
16d53c2dd7 | ||
|
|
e833cd7669 | ||
|
|
5557499b1a | ||
|
|
47fcf8de8c | ||
|
|
e6fcd7e886 | ||
|
|
fb4dd485c9 | ||
|
|
4e6c494b30 | ||
|
|
64eff753bd | ||
|
|
ba6de2d5cc | ||
|
|
e028273cff | ||
|
|
c17e2527d1 | ||
|
|
e6b5336bb9 | ||
|
|
cd474dc552 | ||
|
|
0a4a52cb96 | ||
|
|
2a4a459021 | ||
|
|
0b3c3126ea | ||
|
|
e946a6cdeb | ||
|
|
b86af48486 | ||
|
|
457a8453f7 | ||
|
|
67d6c8f685 | ||
|
|
e4d2cc49a0 | ||
|
|
55d338134d | ||
|
|
1b9ca03c22 | ||
|
|
53398c4641 | ||
|
|
421e1beea5 | ||
|
|
89a99c2634 | ||
|
|
d785b33891 | ||
|
|
b9db6c2071 | ||
|
|
15f9be5d03 | ||
|
|
bb62cced7e | ||
|
|
ab90040305 | ||
|
|
e02b11b708 | ||
|
|
e48f61dc84 | ||
|
|
a92cfede81 | ||
|
|
ec96b2dc22 | ||
|
|
e601897f3f | ||
|
|
7fae16348a | ||
|
|
6d2008b013 | ||
|
|
a3632c6274 | ||
|
|
bf0b8a1d1a | ||
|
|
a33ce0c39f | ||
|
|
fd6f60245f | ||
|
|
9dd59c1f13 | ||
|
|
17d4130d1b | ||
|
|
98f1c8c584 | ||
|
|
a57f9ce8a0 | ||
|
|
b17461cb8a | ||
|
|
9acd6e303d | ||
|
|
930e8fe970 | ||
|
|
6633bf1697 | ||
|
|
8ff186652f | ||
|
|
cb2e262116 | ||
|
|
88bbc34b27 | ||
|
|
c94acdd085 | ||
|
|
2735588c0c | ||
|
|
dc0bf73e84 | ||
|
|
842b67d546 | ||
|
|
49017bc699 | ||
|
|
dd149e75e6 | ||
|
|
6dae772d49 | ||
|
|
87f80d1139 | ||
|
|
0075f39215 | ||
|
|
6934f160db | ||
|
|
4387da1524 | ||
|
|
b055fa22df | ||
|
|
346b2ee260 | ||
|
|
5db0301dc8 | ||
|
|
65aefd9749 | ||
|
|
b322a6e410 | ||
|
|
f0fe1fbd79 | ||
|
|
3a7e67b4c5 | ||
|
|
394591e203 | ||
|
|
1b318701b9 | ||
|
|
779127e0a5 | ||
|
|
0cbc4ad6c0 | ||
|
|
d4741184d3 | ||
|
|
cb19547a83 | ||
|
|
24169a083e | ||
|
|
d2b121244a | ||
|
|
ace1e095ce | ||
|
|
ce6ec03e5d | ||
|
|
cb04c5a12d | ||
|
|
d6a8d9880e | ||
|
|
796c64439b | ||
|
|
0b26afc182 | ||
|
|
d075623275 | ||
|
|
a55758d136 | ||
|
|
87d6328f2f | ||
|
|
8113f9b237 | ||
|
|
93399696e0 | ||
|
|
66d4b82a87 | ||
|
|
a812e9a24b | ||
|
|
4407f88ea6 | ||
|
|
6e5cd4b5cf | ||
|
|
6b71c73790 | ||
|
|
4490185a8d | ||
|
|
0e08c1f9c2 | ||
|
|
94eb62fdb9 | ||
|
|
ba222d4eb9 | ||
|
|
6c8c17c932 | ||
|
|
0e040e2244 | ||
|
|
e0b711beaf | ||
|
|
d6f05668d4 | ||
|
|
5d96c0de63 | ||
|
|
e591a1d63c | ||
|
|
f410e545e2 | ||
|
|
e5bd8bc98b | ||
|
|
bb3d1b7ca3 | ||
|
|
f33bd8ad7f | ||
|
|
cf2ac2171b | ||
|
|
c82aea5fb2 | ||
|
|
8d401cb39d | ||
|
|
a601831f63 | ||
|
|
5d25022423 | ||
|
|
43a0a9d47f | ||
|
|
3fbd4b873c | ||
|
|
2a52ec9e36 | ||
|
|
f4ada63ae8 | ||
|
|
dd197f0c5f | ||
|
|
096c647c80 | ||
|
|
009d937c1d | ||
|
|
7585958bfd | ||
|
|
fd7cec894d | ||
|
|
8f604d71f1 | ||
|
|
9d13d1aeb0 | ||
|
|
58cf2e272a | ||
|
|
a52849e336 | ||
|
|
7a4f59d121 | ||
|
|
48266c8b04 | ||
|
|
b8be8f0e63 | ||
|
|
0fd61547a1 | ||
|
|
8e037f7cef | ||
|
|
eda41be355 | ||
|
|
a769cce0b7 | ||
|
|
d7cc362ebd | ||
|
|
7e01f047fa | ||
|
|
7885214216 | ||
|
|
3e745070db | ||
|
|
b8a031d583 | ||
|
|
3f587a4ec5 | ||
|
|
8828fafe29 | ||
|
|
2f7631188b | ||
|
|
6622e98ec6 | ||
|
|
92eda1e2a6 | ||
|
|
80dea22861 | ||
|
|
714efcf7d1 | ||
|
|
f7882be852 | ||
|
|
f5c5728ba6 | ||
|
|
2ce488024f | ||
|
|
3912066fe1 | ||
|
|
f7a787b140 | ||
|
|
29bb48cdc7 | ||
|
|
ad8b4d7a4b | ||
|
|
fed01f9b44 | ||
|
|
b9a4200cae | ||
|
|
6336e516d3 | ||
|
|
99bcb28944 | ||
|
|
d8b8cab32a | ||
|
|
44545f6cc2 | ||
|
|
28a6623aa9 | ||
|
|
3579ae4ec7 | ||
|
|
9c2e07499e | ||
|
|
5b867d6fb7 | ||
|
|
ff7b7254bc | ||
|
|
c90d23bed5 | ||
|
|
bd421b40ee | ||
|
|
630cace193 | ||
|
|
450407d1c8 | ||
|
|
ef53ac8727 | ||
|
|
b4320bf02f | ||
|
|
e1a1624504 | ||
|
|
91ae2ef9aa | ||
|
|
20716c55e7 | ||
|
|
269db1075c | ||
|
|
a4a84a1325 | ||
|
|
dd108ce0ac | ||
|
|
4a38ae76cb | ||
|
|
a4f089aadb | ||
|
|
4672f532ea | ||
|
|
7a2d2c247c | ||
|
|
8c57ebccfd | ||
|
|
0d06d873f8 | ||
|
|
b70d5e1b96 | ||
|
|
40fb1399c9 | ||
|
|
f9ba0a1b8f | ||
|
|
1c89349477 | ||
|
|
3c347d5d3a | ||
|
|
6cf0c51ae3 | ||
|
|
97a9e58789 | ||
|
|
5eb58e2e4e | ||
|
|
a3f67badc0 | ||
|
|
3734c725a4 | ||
|
|
98d23141f9 | ||
|
|
86df16b7bc | ||
|
|
89f10a3ba5 | ||
|
|
85841d0bbd | ||
|
|
b52c963187 | ||
|
|
17a018fef8 | ||
|
|
61ab67065d | ||
|
|
b8e3beb7d3 | ||
|
|
3a84cf0612 | ||
|
|
be23ac1a4e | ||
|
|
437f115dcd | ||
|
|
e0fb186df2 | ||
|
|
767a1311ee | ||
|
|
6244e939b8 | ||
|
|
f55996d3b4 | ||
|
|
ee5939881d | ||
|
|
d2cc225808 | ||
|
|
0a695738d8 | ||
|
|
8e78bec72e | ||
|
|
8914882238 | ||
|
|
90f23bfccf | ||
|
|
e4620ee888 | ||
|
|
bdc4eb0085 | ||
|
|
ce65812cb2 | ||
|
|
ae17ceeecc | ||
|
|
03e31732d3 | ||
|
|
db195e8e90 | ||
|
|
e638c4d7ca | ||
|
|
db047c0473 | ||
|
|
c5635f8fa6 | ||
|
|
b97629ec79 | ||
|
|
267253b355 | ||
|
|
8ea61a7b5e | ||
|
|
84432a62a1 | ||
|
|
7d3c65c1b5 | ||
|
|
28882bd094 | ||
|
|
9ae3d769cb | ||
|
|
2f60b53c8b | ||
|
|
9df6eebc34 | ||
|
|
b445f447a0 | ||
|
|
6bbf88d8cc | ||
|
|
920332a133 | ||
|
|
35e90b1af7 | ||
|
|
e3bf9e84ff | ||
|
|
8288f81dfd | ||
|
|
9dc8efe26e | ||
|
|
5942afee6f | ||
|
|
d6581bdf14 | ||
|
|
a85ae5f10e | ||
|
|
ce5327414f | ||
|
|
8403a9ad43 | ||
|
|
13a8893171 | ||
|
|
9cae0d7361 | ||
|
|
a1d20a2d53 | ||
|
|
d836e9f05b | ||
|
|
5a25913631 | ||
|
|
6176e0b179 | ||
|
|
c5918aef82 | ||
|
|
ab184afd66 | ||
|
|
1a2668ce95 | ||
|
|
7c9b28a127 | ||
|
|
248b6160be | ||
|
|
9aec810235 | ||
|
|
9454174ee5 | ||
|
|
a88eb036a6 | ||
|
|
a580cab5d6 | ||
|
|
3627b977d7 | ||
|
|
f160a59231 | ||
|
|
a60ff0fd1e | ||
|
|
bb2bc9ae42 | ||
|
|
454a4c5de7 | ||
|
|
52072b80a5 | ||
|
|
25ec53d1f1 | ||
|
|
488888ce61 | ||
|
|
eb3e8946a8 | ||
|
|
9a6510ece6 | ||
|
|
2451de6cb3 | ||
|
|
1597b525b9 | ||
|
|
2b7f5921f1 | ||
|
|
3ac10d3382 | ||
|
|
5c8befbe27 | ||
|
|
22fd61d3b5 | ||
|
|
197b08dbe9 | ||
|
|
dace44d806 | ||
|
|
f48233a1e1 | ||
|
|
5bc25b90fb | ||
|
|
1bdd4a6662 | ||
|
|
f0478f1f51 | ||
|
|
43bd9a8c6d | ||
|
|
803cf83566 | ||
|
|
c6989ab9f9 | ||
|
|
1b4d970000 | ||
|
|
be532638f5 | ||
|
|
06dc8911a0 | ||
|
|
e03314480d | ||
|
|
040b028811 | ||
|
|
eeff03c59c | ||
|
|
cb52f180bd | ||
|
|
5503991372 | ||
|
|
be272cb3e8 | ||
|
|
47b5f3a52c | ||
|
|
3dfeae598a | ||
|
|
eaa39bd1c7 | ||
|
|
036ed3cc63 | ||
|
|
96935b19e1 | ||
|
|
ee7a497ed4 | ||
|
|
42830053e9 | ||
|
|
c26a40eef7 | ||
|
|
96eb32c659 | ||
|
|
3a44c65b03 | ||
|
|
6c620c74f3 | ||
|
|
2f04977242 |
No files matched your search
@@ -112,6 +112,7 @@ GTAGS
|
||||
# Mono-specific patterns
|
||||
##############################################################################
|
||||
|
||||
.dirstamp
|
||||
compile
|
||||
mono.h
|
||||
mono-*.tar.*
|
||||
|
||||
@@ -27,6 +27,7 @@ update_submodules:
|
||||
.PHONY: update_submodules
|
||||
|
||||
EXTRA_DIST= \
|
||||
README.md \
|
||||
LICENSE \
|
||||
autogen.sh \
|
||||
build-mingw32.sh \
|
||||
@@ -155,3 +156,9 @@ package-inputs:
|
||||
done
|
||||
echo "</root>" >> msvc/scripts/order.xml
|
||||
|
||||
# Update llvm version in configure.in to the output of $LLVM_DIR/bin/llvm-config --version
|
||||
update-llvm-version:
|
||||
if test "x$$LLVM_DIR" = "x"; then echo "Set the make variable LLVM_DIR to the directory containing the LLVM installation."; exit 1; fi
|
||||
REV=`$(LLVM_DIR)/bin/llvm-config --version` && sed -e "s,expected_llvm_version=.*,expected_llvm_version=\"$$REV\"," < configure.in > tmp && mv tmp configure.in && echo "Version set to $$REV."
|
||||
|
||||
|
||||
@@ -1,592 +0,0 @@
|
||||
This is Mono.
|
||||
|
||||
1. Installation
|
||||
2. Using Mono
|
||||
3. Directory Roadmap
|
||||
4. git submodules maintenance
|
||||
|
||||
1. Compilation and Installation
|
||||
===============================
|
||||
|
||||
a. Build Requirements
|
||||
---------------------
|
||||
|
||||
On Itanium, you must obtain libunwind:
|
||||
|
||||
http://www.hpl.hp.com/research/linux/libunwind/download.php4
|
||||
|
||||
On Solaris, make sure that you used GNU tar to unpack this package, as
|
||||
Solaris tar will not unpack this correctly, and you will get strange errors.
|
||||
|
||||
On Solaris, make sure that you use the GNU toolchain to build the software.
|
||||
|
||||
Optional dependencies:
|
||||
|
||||
* libgdiplus
|
||||
|
||||
If you want to get support for System.Drawing, you will need to get
|
||||
Libgdiplus. This library in turn requires glib and pkg-config:
|
||||
|
||||
* pkg-config
|
||||
|
||||
Available from: http://www.freedesktop.org/Software/pkgconfig
|
||||
|
||||
* glib 2.4
|
||||
|
||||
Available from: http://www.gtk.org/
|
||||
|
||||
* libzlib
|
||||
|
||||
This library and the development headers are required for compression
|
||||
file support in the 2.0 profile.
|
||||
|
||||
b. Building the Software
|
||||
------------------------
|
||||
|
||||
If you obtained this package as an officially released tarball,
|
||||
this is very simple, use configure and make:
|
||||
|
||||
./configure --prefix=/usr/local
|
||||
make
|
||||
make install
|
||||
|
||||
Mono supports a JIT engine on x86, SPARC, SPARCv9, S/390,
|
||||
S/390x, AMD64, ARM and PowerPC systems.
|
||||
|
||||
If you obtained this as a snapshot, you will need an existing
|
||||
Mono installation. To upgrade your installation, unpack both
|
||||
mono and mcs:
|
||||
|
||||
tar xzf mcs-XXXX.tar.gz
|
||||
tar xzf mono-XXXX.tar.gz
|
||||
mv mono-XXX mono
|
||||
mv mcs-XXX mcs
|
||||
cd mono
|
||||
./autogen.sh --prefix=/usr/local
|
||||
make
|
||||
|
||||
The Mono build system is silent for most compilation commands.
|
||||
To enable a more verbose compile (for example, to pinpoint
|
||||
problems in your makefiles or your system) pass the V=1 flag to make, like this:
|
||||
|
||||
make V=1
|
||||
|
||||
|
||||
c. Building the software from GIT
|
||||
---------------------------------
|
||||
|
||||
If you are building the software from GIT, make sure that you
|
||||
have up-to-date mcs and mono sources:
|
||||
|
||||
If you are an anonymous user:
|
||||
git clone git://github.com/mono/mono.git
|
||||
|
||||
If you are a Mono contributors with read/write privileges:
|
||||
git clone [email protected]:mono/mono.git
|
||||
|
||||
|
||||
Then, go into the mono directory, and configure:
|
||||
|
||||
cd mono
|
||||
./autogen.sh --prefix=/usr/local
|
||||
make
|
||||
|
||||
For people with non-standard installations of the auto* utils and of
|
||||
pkg-config (common on misconfigured OSX and windows boxes), you could get
|
||||
an error like this:
|
||||
|
||||
./configure: line 19176: syntax error near unexpected token `PKG_CHECK_MODULES(BASE_DEPENDENCIES,' ...
|
||||
|
||||
This means that you need to set the ACLOCAL_FLAGS environment var
|
||||
when invoking autogen.sh, like this:
|
||||
|
||||
ACLOCAL_FLAGS="-I $acprefix/share/aclocal" ./autogen.sh --prefix=/usr/loca
|
||||
|
||||
where $acprefix is the prefix where aclocal has been installed.
|
||||
|
||||
This will automatically go into the mcs/ tree and build the
|
||||
binaries there.
|
||||
|
||||
This assumes that you have a working mono installation, and that
|
||||
there's a C# compiler named 'mcs', and a corresponding IL
|
||||
runtime called 'mono'. You can use two make variables
|
||||
EXTERNAL_MCS and EXTERNAL_RUNTIME to override these. e.g., you
|
||||
can say
|
||||
|
||||
make EXTERNAL_MCS=/foo/bar/mcs EXTERNAL_RUNTIME=/somewhere/else/mono
|
||||
|
||||
If you don't have a working Mono installation
|
||||
---------------------------------------------
|
||||
|
||||
If you don't have a working Mono installation, an obvious choice
|
||||
is to install the latest released packages of 'mono' for your
|
||||
distribution and running autogen.sh; make; make install in the
|
||||
mono module directory.
|
||||
|
||||
You can also try a slightly more risky approach: this may not work,
|
||||
so start from the released tarball as detailed above.
|
||||
|
||||
This works by first getting the latest version of the 'monolite'
|
||||
distribution, which contains just enough to run the 'mcs'
|
||||
compiler. You do this with:
|
||||
|
||||
# Run the following line after ./autogen.sh
|
||||
make get-monolite-latest
|
||||
|
||||
This will download and automatically gunzip and untar the
|
||||
tarball, and place the files appropriately so that you can then
|
||||
just run:
|
||||
|
||||
make EXTERNAL_MCS=${PWD}/mcs/class/lib/monolite/gmcs.exe
|
||||
|
||||
And that will use the files downloaded by 'make get-monolite-latest.
|
||||
|
||||
Testing and Installation
|
||||
------------------------
|
||||
|
||||
You can run (part of) the mono and mcs testsuites with the command:
|
||||
|
||||
make check
|
||||
|
||||
All tests should pass.
|
||||
|
||||
If you want more extensive tests, including those that test the
|
||||
class libraries, you need to re-run 'configure' with the
|
||||
'--enable-nunit-tests' flag, and try
|
||||
|
||||
make -k check
|
||||
|
||||
Expect to find a few testsuite failures. As a sanity check, you
|
||||
can compare the failures you got with
|
||||
|
||||
https://wrench.mono-project.com/Wrench/
|
||||
|
||||
You can now install mono with:
|
||||
|
||||
make install
|
||||
|
||||
You can verify your installation by using the mono-test-install
|
||||
script, it can diagnose some common problems with Mono's install.
|
||||
|
||||
Failure to follow these steps may result in a broken installation.
|
||||
|
||||
d. Configuration Options
|
||||
------------------------
|
||||
|
||||
The following are the configuration options that someone
|
||||
building Mono might want to use:
|
||||
|
||||
--with-sgen=yes,no
|
||||
|
||||
Generational GC support: Used to enable or disable the
|
||||
compilation of a Mono runtime with the SGen garbage collector.
|
||||
|
||||
On platforms that support it, after building Mono, you
|
||||
will have both a mono binary and a mono-sgen binary.
|
||||
Mono uses Boehm, while mono-sgen uses the Simple
|
||||
Generational GC.
|
||||
|
||||
--with-gc=[boehm, included, sgen, none]
|
||||
|
||||
Selects the default Boehm garbage collector engine to
|
||||
use, the default is the "included" value.
|
||||
|
||||
included:
|
||||
This is the default value, and its
|
||||
the most feature complete, it will allow Mono
|
||||
to use typed allocations and support the
|
||||
debugger.
|
||||
|
||||
It is essentially a slightly modified Boehm GC
|
||||
|
||||
boehm:
|
||||
This is used to use a system-install Boehm GC,
|
||||
it is useful to test new features available in
|
||||
Boehm GC, but we do not recommend that people
|
||||
use this, as it disables a few features.
|
||||
|
||||
none:
|
||||
Disables the inclusion of a garbage
|
||||
collector.
|
||||
|
||||
--with-tls=__thread,pthread
|
||||
|
||||
Controls how Mono should access thread local storage,
|
||||
pthread forces Mono to use the pthread APIs, while
|
||||
__thread uses compiler-optimized access to it.
|
||||
|
||||
Although __thread is faster, it requires support from
|
||||
the compiler, kernel and libc. Old Linux systems do
|
||||
not support with __thread.
|
||||
|
||||
This value is typically pre-configured and there is no
|
||||
need to set it, unless you are trying to debug a
|
||||
problem.
|
||||
|
||||
--with-sigaltstack=yes,no
|
||||
|
||||
Experimental: Use at your own risk, it is known to
|
||||
cause problems with garbage collection and is hard to
|
||||
reproduce those bugs.
|
||||
|
||||
This controls whether Mono will install a special
|
||||
signal handler to handle stack overflows. If set to
|
||||
"yes", it will turn stack overflows into the
|
||||
StackOverflowException. Otherwise when a stack
|
||||
overflow happens, your program will receive a
|
||||
segmentation fault.
|
||||
|
||||
The configure script will try to detect if your
|
||||
operating system supports this. Some older Linux
|
||||
systems do not support this feature, or you might want
|
||||
to override the auto-detection.
|
||||
|
||||
--with-static_mono=yes,no
|
||||
|
||||
This controls whether `mono' should link against a
|
||||
static library (libmono.a) or a shared library
|
||||
(libmono.so).
|
||||
|
||||
This defaults to yes, and will improve the performance
|
||||
of the `mono' program.
|
||||
|
||||
This only affects the `mono' binary, the shared
|
||||
library libmono.so will always be produced for
|
||||
developers that want to embed the runtime in their
|
||||
application.
|
||||
|
||||
--with-xen-opt=yes,no
|
||||
|
||||
The default value for this is `yes', and it makes Mono
|
||||
generate code which might be slightly slower on
|
||||
average systems, but the resulting executable will run
|
||||
faster under the Xen virtualization system.
|
||||
|
||||
--with-large-heap=yes,no
|
||||
|
||||
Enable support for GC heaps larger than 3GB.
|
||||
|
||||
This value is set to `no' by default.
|
||||
|
||||
--enable-small-config=yes,no
|
||||
|
||||
Enable some tweaks to reduce memory usage and disk footprint at
|
||||
the expense of some capabilities. Typically this means that the
|
||||
number of threads that can be created is limited (256), that the
|
||||
maxmimum heap size is also reduced (256 MB) and other such limitations
|
||||
that still make mono useful, but more suitable to embedded devices
|
||||
(like mobile phones).
|
||||
|
||||
This value is set to `no' by default.
|
||||
|
||||
--with-ikvm-native=yes,no
|
||||
|
||||
Controls whether the IKVM JNI interface library is
|
||||
built or not. This is used if you are planning on
|
||||
using the IKVM Java Virtual machine with Mono.
|
||||
|
||||
This defaults to `yes'.
|
||||
|
||||
--with-profile4=yes,no
|
||||
|
||||
Whether you want to build the 4.x profile libraries
|
||||
and runtime.
|
||||
|
||||
It defaults to `yes'.
|
||||
|
||||
--with-moonlight=yes,no
|
||||
|
||||
Whether you want to generate the Silverlight/Moonlight
|
||||
libraries and toolchain in addition to the default
|
||||
(1.1 and 2.0 APIs).
|
||||
|
||||
This will produce the `smcs' compiler which will reference
|
||||
the Silverlight modified assemblies (mscorlib.dll,
|
||||
System.dll, System.Code.dll and System.Xml.Core.dll) and turn
|
||||
on the LINQ extensions for the compiler.
|
||||
|
||||
--with-moon-gc=boehm,sgen
|
||||
|
||||
Select the GC to use for Moonlight.
|
||||
|
||||
boehm:
|
||||
Selects the Boehm Garbage Collector, with the same flags
|
||||
as the regular Mono build. This is the default.
|
||||
|
||||
sgen:
|
||||
Selects the new SGen Garbage Collector, which provides
|
||||
Generational GC support, using the same flags as the
|
||||
mono-sgen build.
|
||||
|
||||
This defaults to `boehm'.
|
||||
|
||||
--with-libgdiplus=installed,sibling,<path>
|
||||
|
||||
This is used to configure where should Mono look for
|
||||
libgdiplus when running the System.Drawing tests.
|
||||
|
||||
It defaults to `installed', which means that the
|
||||
library is available to Mono through the regular
|
||||
system setup.
|
||||
|
||||
`sibling' can be used to specify that a libgdiplus
|
||||
that resides as a sibling of this directory (mono)
|
||||
should be used.
|
||||
|
||||
Or you can specify a path to a libgdiplus.
|
||||
|
||||
--disable-shared-memory
|
||||
|
||||
Use this option to disable the use of shared memory in
|
||||
Mono (this is equivalent to setting the MONO_DISABLE_SHM
|
||||
environment variable, although this removes the feature
|
||||
completely).
|
||||
|
||||
Disabling the shared memory support will disable certain
|
||||
features like cross-process named mutexes.
|
||||
|
||||
--enable-minimal=LIST
|
||||
|
||||
Use this feature to specify optional runtime
|
||||
components that you might not want to include. This
|
||||
is only useful for developers embedding Mono that
|
||||
require a subset of Mono functionality.
|
||||
|
||||
The list is a comma-separated list of components that
|
||||
should be removed, these are:
|
||||
|
||||
aot:
|
||||
Disables support for the Ahead of Time
|
||||
compilation.
|
||||
|
||||
attach:
|
||||
Support for the Mono.Management assembly and the
|
||||
VMAttach API (allowing code to be injected into
|
||||
a target VM)
|
||||
|
||||
com:
|
||||
Disables COM support.
|
||||
|
||||
debug:
|
||||
Drop debugging support.
|
||||
|
||||
decimal:
|
||||
Disables support for System.Decimal.
|
||||
|
||||
full_messages:
|
||||
By default Mono comes with a full table
|
||||
of messages for error codes. This feature
|
||||
turns off uncommon error messages and reduces
|
||||
the runtime size.
|
||||
|
||||
generics:
|
||||
Generics support. Disabling this will not
|
||||
allow Mono to run any 2.0 libraries or
|
||||
code that contains generics.
|
||||
|
||||
jit:
|
||||
Removes the JIT engine from the build, this reduces
|
||||
the executable size, and requires that all code
|
||||
executed by the virtual machine be compiled with
|
||||
Full AOT before execution.
|
||||
|
||||
large_code:
|
||||
Disables support for large assemblies.
|
||||
|
||||
logging:
|
||||
Disables support for debug logging.
|
||||
|
||||
pinvoke:
|
||||
Support for Platform Invocation services,
|
||||
disabling this will drop support for any
|
||||
libraries using DllImport.
|
||||
|
||||
portability:
|
||||
Removes support for MONO_IOMAP, the environment
|
||||
variables for simplifying porting applications that
|
||||
are case-insensitive and that mix the Unix and Windows path separators.
|
||||
|
||||
profiler:
|
||||
Disables support for the default profiler.
|
||||
|
||||
reflection_emit:
|
||||
Drop System.Reflection.Emit support
|
||||
|
||||
reflection_emit_save:
|
||||
Drop support for saving dynamically created
|
||||
assemblies (AssemblyBuilderAccess.Save) in
|
||||
System.Reflection.Emit.
|
||||
|
||||
shadow_copy:
|
||||
Disables support for AppDomain's shadow copies
|
||||
(you can disable this if you do not plan on
|
||||
using appdomains).
|
||||
|
||||
simd:
|
||||
Disables support for the Mono.SIMD intrinsics
|
||||
library.
|
||||
|
||||
ssa:
|
||||
Disables compilation for the SSA optimization
|
||||
framework, and the various SSA-based
|
||||
optimizations.
|
||||
|
||||
--enable-llvm
|
||||
--enable-loadedllvm
|
||||
|
||||
This enables the use of LLVM as a code generation engine
|
||||
for Mono. The LLVM code generator and optimizer will be
|
||||
used instead of Mono's built-in code generator for both
|
||||
Just in Time and Ahead of Time compilations.
|
||||
|
||||
See the http://www.mono-project.com/Mono_LLVM for the
|
||||
full details and up-to-date information on this feature.
|
||||
|
||||
You will need to have an LLVM built that Mono can link
|
||||
against,
|
||||
|
||||
The --enable-loadedllvm variant will make the llvm backend
|
||||
into a runtime-loadable module instead of linking it directly
|
||||
into the main mono binary.
|
||||
|
||||
--enable-big-arrays
|
||||
|
||||
This enables the use arrays whose indexes are larger
|
||||
than Int32.MaxValue.
|
||||
|
||||
By default Mono has the same limitation as .NET on
|
||||
Win32 and Win64 and limits array indexes to 32-bit
|
||||
values (even on 64-bit systems).
|
||||
|
||||
In certain scenarios where large arrays are required,
|
||||
you can pass this flag and Mono will be built to
|
||||
support 64-bit arrays.
|
||||
|
||||
This is not the default as it breaks the C embedding
|
||||
ABI that we have exposed through the Mono development
|
||||
cycle.
|
||||
|
||||
--enable-parallel-mark
|
||||
|
||||
Use this option to enable the garbage collector to use
|
||||
multiple CPUs to do its work. This helps performance
|
||||
on multi-CPU machines as the work is divided across CPUS.
|
||||
|
||||
This option is not currently the default as we have
|
||||
not done much testing with Mono.
|
||||
|
||||
--enable-dtrace
|
||||
|
||||
On Solaris and MacOS X builds a version of the Mono
|
||||
runtime that contains DTrace probes and can
|
||||
participate in the system profiling using DTrace.
|
||||
|
||||
|
||||
--disable-dev-random
|
||||
|
||||
Mono uses /dev/random to obtain good random data for
|
||||
any source that requires random numbers. If your
|
||||
system does not support this, you might want to
|
||||
disable it.
|
||||
|
||||
There are a number of runtime options to control this
|
||||
also, see the man page.
|
||||
|
||||
--enable-nacl
|
||||
|
||||
This configures the Mono compiler to generate code
|
||||
suitable to be used by Google's Native Client:
|
||||
|
||||
http://code.google.com/p/nativeclient/
|
||||
|
||||
Currently this is used with Mono's AOT engine as
|
||||
Native Client does not support JIT engines yet.
|
||||
|
||||
2. Using Mono
|
||||
=============
|
||||
|
||||
Once you have installed the software, you can run a few programs:
|
||||
|
||||
* runtime engine
|
||||
|
||||
mono program.exe
|
||||
|
||||
* C# compiler
|
||||
|
||||
mcs program.cs
|
||||
|
||||
* CIL Disassembler
|
||||
|
||||
monodis program.exe
|
||||
|
||||
See the man pages for mono(1), mint(1), monodis(1) and mcs(2)
|
||||
for further details.
|
||||
|
||||
3. Directory Roadmap
|
||||
====================
|
||||
|
||||
docs/
|
||||
Technical documents about the Mono runtime.
|
||||
|
||||
data/
|
||||
Configuration files installed as part of the Mono runtime.
|
||||
|
||||
mono/
|
||||
The core of the Mono Runtime.
|
||||
|
||||
metadata/
|
||||
The object system and metadata reader.
|
||||
|
||||
mini/
|
||||
The Just in Time Compiler.
|
||||
|
||||
dis/
|
||||
CIL executable Disassembler
|
||||
|
||||
cli/
|
||||
Common code for the JIT and the interpreter.
|
||||
|
||||
io-layer/
|
||||
The I/O layer and system abstraction for
|
||||
emulating the .NET IO model.
|
||||
|
||||
cil/
|
||||
Common Intermediate Representation, XML
|
||||
definition of the CIL bytecodes.
|
||||
|
||||
interp/
|
||||
Interpreter for CLI executables (obsolete).
|
||||
|
||||
arch/
|
||||
Architecture specific portions.
|
||||
|
||||
man/
|
||||
|
||||
Manual pages for the various Mono commands and programs.
|
||||
|
||||
samples/
|
||||
|
||||
Some simple sample programs on uses of the Mono
|
||||
runtime as an embedded library.
|
||||
|
||||
scripts/
|
||||
|
||||
Scripts used to invoke Mono and the corresponding program.
|
||||
|
||||
runtime/
|
||||
|
||||
A directory that contains the Makefiles that link the
|
||||
mono/ and mcs/ build systems.
|
||||
|
||||
../olive/
|
||||
|
||||
If the directory ../olive is present (as an
|
||||
independent checkout) from the Mono module, that
|
||||
directory is automatically configured to share the
|
||||
same prefix than this module gets.
|
||||
|
||||
|
||||
4. Git submodules maintenance
|
||||
=============================
|
||||
|
||||
Read documentation at http://mono-project.com/Git_Submodule_Maintenance
|
||||
@@ -0,0 +1,535 @@
|
||||
Mono is a software platform designed to allow developers to easily create cross platform applications.
|
||||
Mono is an open source implementation of Microsoft's .NET Framework based on the ECMA standards for C# and the Common Language Runtime.
|
||||
|
||||
1. [Installation](#compilation-and-installation)
|
||||
2. [Using Mono](#using-mono)
|
||||
3. [Directory Roadmap](#directory-roadmap)
|
||||
4. [Git submodules maintenance](#git-submodules-maintenance)
|
||||
5. [Reporting bugs](#reporting-bugs)
|
||||
|
||||
Compilation and Installation
|
||||
============================
|
||||
|
||||
a. Build Requirements
|
||||
---------------------
|
||||
|
||||
* On Itanium, you must obtain libunwind: http://www.hpl.hp.com/research/linux/libunwind/download.php4
|
||||
|
||||
* On Solaris
|
||||
|
||||
1. Make sure that you used GNU tar to unpack this package, as
|
||||
Solaris tar will not unpack this correctly, and you will get strange errors.
|
||||
|
||||
2. Make sure that you use the GNU toolchain to build the software.
|
||||
|
||||
3. Optional dependencies
|
||||
|
||||
* libgdiplus - Required for System.Drawing. This library in turn requires glib and pkg-config
|
||||
|
||||
* pkg-config - Available at: http://www.freedesktop.org/Software/pkgconfig
|
||||
|
||||
* glib 2.4 - Available at: http://www.gtk.org/
|
||||
|
||||
* libzlib - This library and the development headers are required for compression
|
||||
file support in the 2.0 profile.
|
||||
|
||||
b. Building the Software
|
||||
------------------------
|
||||
|
||||
If you obtained this package as an officially released tarball,
|
||||
this is very simple, use configure and make:
|
||||
|
||||
`./configure --prefix=/usr/local ; make ; make install`
|
||||
|
||||
Mono supports a JIT engine on x86, SPARC, SPARCv9, S/390,
|
||||
S/390x, AMD64, ARM and PowerPC systems.
|
||||
|
||||
If you obtained this as a snapshot, you will need an existing
|
||||
Mono installation. To upgrade your installation, unpack both
|
||||
mono and mcs:
|
||||
|
||||
tar xzf mcs-XXXX.tar.gz
|
||||
tar xzf mono-XXXX.tar.gz
|
||||
mv mono-XXX mono
|
||||
mv mcs-XXX mcs
|
||||
cd mono
|
||||
./autogen.sh --prefix=/usr/local
|
||||
make
|
||||
|
||||
The Mono build system is silent for most compilation commands.
|
||||
To enable a more verbose compile (for example, to pinpoint
|
||||
problems in your makefiles or your system) pass the V=1 flag to make, like this:
|
||||
|
||||
` make V=1`
|
||||
|
||||
|
||||
c. Building the software from GIT
|
||||
---------------------------------
|
||||
|
||||
If you are building the software from GIT, make sure that you
|
||||
have up-to-date mcs and mono sources:
|
||||
|
||||
* If you are an anonymous user: `git clone git://github.com/mono/mono.git`
|
||||
|
||||
* If you are a Mono contributor with read/write privileges: `git clone [email protected]:mono/mono.git`
|
||||
|
||||
Then, go into the mono directory, and configure:
|
||||
|
||||
cd mono
|
||||
./autogen.sh --prefix=/usr/local
|
||||
make
|
||||
|
||||
For people with non-standard installations of the auto* utils and of
|
||||
pkg-config (common on misconfigured OSX and windows boxes), you could get
|
||||
an error like this:
|
||||
|
||||
`./configure: line 19176: syntax error near unexpected token 'PKG_CHECK_MODULES(BASE_DEPENDENCIES,' ...`
|
||||
|
||||
This means that you need to set the ACLOCAL_FLAGS environment variable
|
||||
when invoking autogen.sh, like this: `ACLOCAL_FLAGS="-I $acprefix/share/aclocal" ./autogen.sh --prefix=/usr/local`
|
||||
where $acprefix is the prefix where aclocal has been installed.
|
||||
This will automatically go into the mcs/ tree and build the
|
||||
binaries there.
|
||||
|
||||
This assumes that you have a working mono installation, and that
|
||||
there's a C# compiler named 'mcs', and a corresponding IL
|
||||
runtime called 'mono'. You can use two make variables
|
||||
EXTERNAL_MCS and EXTERNAL_RUNTIME to override these. e.g., you
|
||||
can say:
|
||||
|
||||
`make EXTERNAL_MCS=/foo/bar/mcs EXTERNAL_RUNTIME=/somewhere/else/mono`
|
||||
|
||||
If you don't have a working Mono installation
|
||||
---------------------------------------------
|
||||
|
||||
If you don't have a working Mono installation, an obvious choice
|
||||
is to install the latest released packages of 'mono' for your
|
||||
distribution and running `autogen.sh; make; make install` in the
|
||||
mono module directory.
|
||||
|
||||
You can also try a slightly more risky approach: this may not work,
|
||||
so start from the released tarball as detailed above.
|
||||
|
||||
This works by first getting the latest version of the 'monolite'
|
||||
distribution, which contains just enough to run the 'mcs'
|
||||
compiler. You do this with:
|
||||
|
||||
# Run the following line after ./autogen.sh
|
||||
make get-monolite-latest
|
||||
|
||||
This will download and automatically gunzip and untar the
|
||||
tarball, and place the files appropriately so that you can then
|
||||
just run: `make EXTERNAL_MCS=${PWD}/mcs/class/lib/monolite/gmcs.exe`
|
||||
|
||||
That will use the files downloaded by 'make get-monolite-latest.
|
||||
|
||||
Testing and Installation
|
||||
------------------------
|
||||
|
||||
You can run *(part of)* the mono and mcs test suites with the command: `make check`.
|
||||
All tests should pass.
|
||||
|
||||
If you want more *extensive* tests, including those that test the
|
||||
class libraries, you need to re-run 'configure' with the
|
||||
'--enable-nunit-tests' flag, and try: `make -k check`
|
||||
|
||||
Expect to find a few test suite failures. As a sanity check, you
|
||||
can compare the failures you got with
|
||||
|
||||
`https://wrench.mono-project.com/Wrench/`
|
||||
|
||||
You can now install mono with: `make install`
|
||||
|
||||
You can verify your installation by using the mono-test-install
|
||||
script, it can diagnose some common problems with Mono's install.
|
||||
Failure to follow these steps may result in a broken installation.
|
||||
|
||||
d. Configuration Options
|
||||
------------------------
|
||||
|
||||
The following are the configuration options that someone
|
||||
building Mono might want to use:
|
||||
|
||||
* `--with-sgen=yes,no` - Generational GC support: Used to enable or disable the
|
||||
compilation of a Mono runtime with the SGen garbage collector.
|
||||
|
||||
* On platforms that support it, after building Mono, you
|
||||
will have both a mono binary and a mono-sgen binary.
|
||||
Mono uses Boehm, while mono-sgen uses the Simple
|
||||
Generational GC.
|
||||
|
||||
* `--with-gc=[boehm, included, sgen, none]` - Selects the default Boehm garbage
|
||||
collector engine to use.
|
||||
|
||||
* *included*: (*slighty modified Boehm GC*)
|
||||
This is the default value, and its
|
||||
the most feature complete, it will allow Mono
|
||||
to use typed allocations and support the
|
||||
debugger.
|
||||
|
||||
* *boehm*:
|
||||
This is used to use a system-install Boehm GC,
|
||||
it is useful to test new features available in
|
||||
Boehm GC, but we do not recommend that people
|
||||
use this, as it disables a few features.
|
||||
|
||||
* *none*:
|
||||
Disables the inclusion of a garbage collector.
|
||||
|
||||
* This defaults to `included`.
|
||||
|
||||
* `--with-tls=__thread,pthread`
|
||||
|
||||
* Controls how Mono should access thread local storage,
|
||||
pthread forces Mono to use the pthread APIs, while
|
||||
__thread uses compiler-optimized access to it.
|
||||
|
||||
* Although __thread is faster, it requires support from
|
||||
the compiler, kernel and libc. Old Linux systems do
|
||||
not support with __thread.
|
||||
|
||||
* This value is typically pre-configured and there is no
|
||||
need to set it, unless you are trying to debug a problem.
|
||||
|
||||
* `--with-sigaltstack=yes,no`
|
||||
|
||||
* **Experimental**: Use at your own risk, it is known to
|
||||
cause problems with garbage collection and is hard to
|
||||
reproduce those bugs.
|
||||
|
||||
* This controls whether Mono will install a special
|
||||
signal handler to handle stack overflows. If set to
|
||||
`yes`, it will turn stack overflows into the
|
||||
StackOverflowException. Otherwise when a stack
|
||||
overflow happens, your program will receive a
|
||||
segmentation fault.
|
||||
|
||||
* The configure script will try to detect if your
|
||||
operating system supports this. Some older Linux
|
||||
systems do not support this feature, or you might want
|
||||
to override the auto-detection.
|
||||
|
||||
* `--with-static_mono=yes,no`
|
||||
|
||||
* This controls whether `mono` should link against a
|
||||
static library (libmono.a) or a shared library
|
||||
(libmono.so).
|
||||
|
||||
* This defaults to `yes`, and will improve the performance
|
||||
of the `mono` program.
|
||||
|
||||
* This only affects the `mono' binary, the shared
|
||||
library libmono.so will always be produced for
|
||||
developers that want to embed the runtime in their
|
||||
application.
|
||||
|
||||
* `--with-xen-opt=yes,no` - Optimize code for Xen virtualization.
|
||||
|
||||
* It makes Mono generate code which might be slightly
|
||||
slower on average systems, but the resulting executable will run
|
||||
faster under the Xen virtualization system.
|
||||
|
||||
* This defaults to `yes`.
|
||||
|
||||
* `--with-large-heap=yes,no` - Enable support for GC heaps larger than 3GB.
|
||||
|
||||
* This defaults to `no`.
|
||||
|
||||
* `--enable-small-config=yes,no` - Enable some tweaks to reduce memory usage
|
||||
and disk footprint at the expense of some capabilities.
|
||||
|
||||
* Typically this means that the number of threads that can be created
|
||||
is limited (256), that the maximum heap size is also reduced (256 MB)
|
||||
and other such limitations that still make mono useful, but more suitable
|
||||
to embedded devices (like mobile phones).
|
||||
|
||||
* This defaults to `no`.
|
||||
|
||||
* `--with-ikvm-native=yes,no` - Controls whether the IKVM JNI interface library is
|
||||
built or not.
|
||||
|
||||
* This is used if you are planning on
|
||||
using the IKVM Java Virtual machine with Mono.
|
||||
|
||||
* This defaults to `yes`.
|
||||
|
||||
* `--with-profile4=yes,no` - Whether you want to build the 4.x profile libraries
|
||||
and runtime.
|
||||
|
||||
* This defaults to `yes`.
|
||||
|
||||
* `--with-moonlight=yes,no`
|
||||
|
||||
* Whether you want to generate the Silverlight/Moonlight
|
||||
libraries and toolchain in addition to the default
|
||||
(1.1 and 2.0 APIs).
|
||||
|
||||
* This will produce the `smcs` compiler which will reference
|
||||
the Silverlight modified assemblies (mscorlib.dll,
|
||||
System.dll, System.Code.dll and System.Xml.Core.dll) and turn
|
||||
on the LINQ extensions for the compiler.
|
||||
|
||||
* `--with-moon-gc=boehm,sgen` - Select the GC to use for Moonlight.
|
||||
|
||||
* *boehm*:
|
||||
Selects the Boehm Garbage Collector, with the same flags
|
||||
as the regular Mono build. This is the default.
|
||||
|
||||
* *sgen*:
|
||||
Selects the new SGen Garbage Collector, which provides
|
||||
Generational GC support, using the same flags as the
|
||||
mono-sgen build.
|
||||
|
||||
* This defaults to `boehm`.
|
||||
|
||||
* `--with-libgdiplus=installed,sibling,<path>` - Configure where Mono
|
||||
searches for libgdiplus when running System.Drawing tests.
|
||||
|
||||
* It defaults to `installed`, which means that the
|
||||
library is available to Mono through the regular
|
||||
system setup.
|
||||
|
||||
* `sibling' can be used to specify that a libgdiplus
|
||||
that resides as a sibling of this directory (mono)
|
||||
should be used.
|
||||
|
||||
* Or you can specify a path to a libgdiplus.
|
||||
|
||||
* `--disable-shared-memory`
|
||||
|
||||
* Use this option to disable the use of shared memory in
|
||||
Mono (this is equivalent to setting the MONO_DISABLE_SHM
|
||||
environment variable, although this removes the feature
|
||||
completely).
|
||||
|
||||
* Disabling the shared memory support will disable certain
|
||||
features like cross-process named mutexes.
|
||||
|
||||
* `--enable-minimal=LIST`
|
||||
|
||||
* Use this feature to specify optional runtime
|
||||
components that you might not want to include. This
|
||||
is only useful for developers embedding Mono that
|
||||
require a subset of Mono functionality.
|
||||
* The list is a comma-separated list of components that
|
||||
should be removed, these are:
|
||||
|
||||
* `aot`:
|
||||
Disables support for the Ahead of Time compilation.
|
||||
|
||||
* `attach`:
|
||||
Support for the Mono.Management assembly and the
|
||||
VMAttach API (allowing code to be injected into
|
||||
a target VM)
|
||||
|
||||
* `com`:
|
||||
Disables COM support.
|
||||
|
||||
* `debug`:
|
||||
Drop debugging support.
|
||||
|
||||
* `decimal`:
|
||||
Disables support for System.Decimal.
|
||||
|
||||
* `full_messages`:
|
||||
By default Mono comes with a full table
|
||||
of messages for error codes. This feature
|
||||
turns off uncommon error messages and reduces
|
||||
the runtime size.
|
||||
|
||||
* `generics`:
|
||||
Generics support. Disabling this will not
|
||||
allow Mono to run any 2.0 libraries or
|
||||
code that contains generics.
|
||||
|
||||
* `jit`:
|
||||
Removes the JIT engine from the build, this reduces
|
||||
the executable size, and requires that all code
|
||||
executed by the virtual machine be compiled with
|
||||
Full AOT before execution.
|
||||
|
||||
* `large_code`:
|
||||
Disables support for large assemblies.
|
||||
|
||||
* `logging`:
|
||||
Disables support for debug logging.
|
||||
|
||||
* `pinvoke`:
|
||||
Support for Platform Invocation services,
|
||||
disabling this will drop support for any
|
||||
libraries using DllImport.
|
||||
|
||||
* `portability`:
|
||||
Removes support for MONO_IOMAP, the environment
|
||||
variables for simplifying porting applications that
|
||||
are case-insensitive and that mix the Unix and Windows path separators.
|
||||
|
||||
* `profiler`:
|
||||
Disables support for the default profiler.
|
||||
|
||||
* `reflection_emit`:
|
||||
Drop System.Reflection.Emit support
|
||||
|
||||
* `reflection_emit_save`:
|
||||
Drop support for saving dynamically created
|
||||
assemblies (AssemblyBuilderAccess.Save) in
|
||||
System.Reflection.Emit.
|
||||
|
||||
* `shadow_copy`:
|
||||
Disables support for AppDomain's shadow copies
|
||||
(you can disable this if you do not plan on
|
||||
using appdomains).
|
||||
|
||||
* `simd`:
|
||||
Disables support for the Mono.SIMD intrinsics
|
||||
library.
|
||||
|
||||
* `ssa`:
|
||||
Disables compilation for the SSA optimization
|
||||
framework, and the various SSA-based optimizations.
|
||||
|
||||
* `--enable-llvm`
|
||||
* `--enable-loadedllvm`
|
||||
|
||||
* This enables the use of LLVM as a code generation engine
|
||||
for Mono. The LLVM code generator and optimizer will be
|
||||
used instead of Mono's built-in code generator for both
|
||||
Just in Time and Ahead of Time compilations.
|
||||
|
||||
* See the http://www.mono-project.com/Mono_LLVM for the
|
||||
full details and up-to-date information on this feature.
|
||||
|
||||
* You will need to have an LLVM built that Mono can link
|
||||
against.
|
||||
|
||||
* The --enable-loadedllvm variant will make the LLVM backend
|
||||
into a runtime-loadable module instead of linking it directly
|
||||
into the main mono binary.
|
||||
|
||||
* `--enable-big-arrays` - Enable use of arrays with indexes larger
|
||||
than Int32.MaxValue.
|
||||
|
||||
* By default Mono has the same limitation as .NET on
|
||||
Win32 and Win64 and limits array indexes to 32-bit
|
||||
values (even on 64-bit systems).
|
||||
|
||||
* In certain scenarios where large arrays are required,
|
||||
you can pass this flag and Mono will be built to
|
||||
support 64-bit arrays.
|
||||
|
||||
* This is not the default as it breaks the C embedding
|
||||
ABI that we have exposed through the Mono development
|
||||
cycle.
|
||||
|
||||
* `--enable-parallel-mark`
|
||||
|
||||
* Use this option to enable the garbage collector to use
|
||||
multiple CPUs to do its work. This helps performance
|
||||
on multi-CPU machines as the work is divided across CPUS.
|
||||
|
||||
* This option is not currently the default as we have
|
||||
not done much testing with Mono.
|
||||
|
||||
* `--enable-dtrace`
|
||||
|
||||
* On Solaris and MacOS X builds a version of the Mono
|
||||
runtime that contains DTrace probes and can
|
||||
participate in the system profiling using DTrace.
|
||||
|
||||
|
||||
* `--disable-dev-random`
|
||||
|
||||
* Mono uses /dev/random to obtain good random data for
|
||||
any source that requires random numbers. If your
|
||||
system does not support this, you might want to
|
||||
disable it.
|
||||
|
||||
* There are a number of runtime options to control this
|
||||
also, see the man page.
|
||||
|
||||
* `--enable-nacl`
|
||||
|
||||
* This configures the Mono compiler to generate code
|
||||
suitable to be used by Google's Native Client:
|
||||
http://code.google.com/p/nativeclient/
|
||||
|
||||
* Currently this is used with Mono's AOT engine as
|
||||
Native Client does not support JIT engines yet.
|
||||
|
||||
Using Mono
|
||||
==========
|
||||
|
||||
Once you have installed the software, you can run a few programs:
|
||||
|
||||
* `mono program.exe` runtime engine
|
||||
|
||||
* `mcs program.cs` C# compiler
|
||||
|
||||
* `monodis program.exe` CIL Disassembler
|
||||
|
||||
See the man pages for mono(1), mint(1), monodis(1) and mcs(2)
|
||||
for further details.
|
||||
|
||||
Directory Roadmap
|
||||
=================
|
||||
|
||||
* `docs/` - Technical documents about the Mono runtime.
|
||||
|
||||
* `data/` - Configuration files installed as part of the Mono runtime.
|
||||
|
||||
* `mono/` - The core of the Mono Runtime.
|
||||
|
||||
* `metadata/` - The object system and metadata reader.
|
||||
|
||||
* `mini/` - The Just in Time Compiler.
|
||||
|
||||
* `dis/` - CIL executable Disassembler
|
||||
|
||||
* `cli/` - Common code for the JIT and the interpreter.
|
||||
|
||||
* `io-layer/` - The I/O layer and system abstraction for
|
||||
emulating the .NET IO model.
|
||||
|
||||
* `cil/` - Common Intermediate Representation, XML
|
||||
definition of the CIL bytecodes.
|
||||
|
||||
* `interp/` - Interpreter for CLI executables (obsolete).
|
||||
|
||||
* `arch/` - Architecture specific portions.
|
||||
|
||||
* `man/` - Manual pages for the various Mono commands and programs.
|
||||
|
||||
* `samples/` -Some simple sample programs on uses of the Mono
|
||||
runtime as an embedded library.
|
||||
|
||||
* `scripts/` - Scripts used to invoke Mono and the corresponding program.
|
||||
|
||||
* `runtime/` - A directory that contains the Makefiles that link the
|
||||
mono/ and mcs/ build systems.
|
||||
|
||||
* `../olive/`
|
||||
|
||||
* If the directory ../olive is present (as an
|
||||
independent checkout) from the Mono module, that
|
||||
directory is automatically configured to share the
|
||||
same prefix than this module gets.
|
||||
|
||||
|
||||
Git submodules maintenance
|
||||
==========================
|
||||
|
||||
Read documentation at http://mono-project.com/Git_Submodule_Maintenance
|
||||
|
||||
|
||||
Reporting bugs
|
||||
==============
|
||||
|
||||
To submit bug reports, please use Xamarin's Bugzilla:
|
||||
|
||||
https://bugzilla.xamarin.com/
|
||||
|
||||
Please use the search facility to ensure the same bug hasn't already
|
||||
been submitted and follow our guidelines on how to make a good bug
|
||||
report:
|
||||
|
||||
http://mono-project.com/Bugs#How_to_make_a_good_bug_report
|
||||
Executable → Regular
+70
-13
@@ -1,10 +1,10 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
#AC_PREREQ([2.62])
|
||||
|
||||
AC_INIT(mono, [3.2.4],
|
||||
AC_INIT(mono, [3.2.5],
|
||||
[http://bugzilla.xamarin.com/enter_bug.cgi?classification=Mono])
|
||||
|
||||
AC_CONFIG_SRCDIR([README])
|
||||
AC_CONFIG_SRCDIR([README.md])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
AC_CANONICAL_SYSTEM
|
||||
AC_CANONICAL_HOST
|
||||
@@ -315,10 +315,10 @@ case "$host" in
|
||||
CFLAGS_FOR_LIBGC="$CFLAGS_FOR_LIBGC $BROKEN_DARWIN_FLAGS"
|
||||
CPPFLAGS_FOR_EGLIB="$CPPFLAGS_FOR_EGLIB $BROKEN_DARWIN_CPPFLAGS"
|
||||
CFLAGS_FOR_EGLIB="$CFLAGS_FOR_EGLIB $BROKEN_DARWIN_FLAGS"
|
||||
extra_runtime_ldflags="-stack_size,0x800000"
|
||||
extra_runtime_ldflags="-Xlinker -stack_size -Xlinker 0x800000"
|
||||
;;
|
||||
x*64-*-darwin*)
|
||||
extra_runtime_ldflags="-stack_size,0x800000"
|
||||
extra_runtime_ldflags="-Xlinker -stack_size -Xlinker 0x800000"
|
||||
;;
|
||||
arm*-darwin*)
|
||||
has_dtrace=no
|
||||
@@ -1034,6 +1034,11 @@ case "x$gc" in
|
||||
|
||||
BOEHM_DEFINES="-DHAVE_BOEHM_GC -DHAVE_GC_H -DUSE_INCLUDED_LIBGC -DHAVE_GC_GCJ_MALLOC -DHAVE_GC_ENABLE"
|
||||
|
||||
if test x$target_win32 = xyes; then
|
||||
BOEHM_DEFINES="$BOEHM_DEFINES -DGC_NOT_DLL"
|
||||
CFLAGS_FOR_LIBGC="$CFLAGS_FOR_LIBGC -DGC_BUILD -DGC_NOT_DLL"
|
||||
fi
|
||||
|
||||
gc_msg="bundled Boehm GC with typed GC"
|
||||
if test x$enable_parallel_mark = xyes; then
|
||||
AC_DEFINE_UNQUOTED(DEFAULT_GC_NAME, "Included Boehm (with typed GC and Parallel Mark)", [GC description])
|
||||
@@ -1580,6 +1585,8 @@ if test x$target_win32 = xno; then
|
||||
AC_MSG_CHECKING(for working __thread)
|
||||
if test "x$with_tls" != "x__thread"; then
|
||||
AC_MSG_RESULT(disabled)
|
||||
elif test "x$cross_compiling" = "xyes"; then
|
||||
AC_MSG_RESULT(cross compiling, assuming yes)
|
||||
else
|
||||
AC_TRY_RUN([
|
||||
#if defined(__APPLE__) && defined(__clang__)
|
||||
@@ -1627,6 +1634,8 @@ if test x$target_win32 = xno; then
|
||||
AC_MSG_CHECKING(for working sigaltstack)
|
||||
if test "x$with_sigaltstack" != "xyes"; then
|
||||
AC_MSG_RESULT(disabled)
|
||||
elif test "x$cross_compiling" = "xyes"; then
|
||||
AC_MSG_RESULT(cross compiling, assuming yes)
|
||||
else
|
||||
AC_TRY_RUN([
|
||||
#include <stdio.h>
|
||||
@@ -2122,6 +2131,11 @@ else
|
||||
])
|
||||
])
|
||||
AC_CHECK_FUNCS(GetProcessId)
|
||||
AC_CHECK_DECLS(InterlockedExchange64, [], [], [[#include <windows.h>]])
|
||||
AC_CHECK_DECLS(InterlockedCompareExchange64, [], [], [[#include <windows.h>]])
|
||||
AC_CHECK_DECLS(InterlockedIncrement64, [], [], [[#include <windows.h>]])
|
||||
AC_CHECK_DECLS(InterlockedAdd, [], [], [[#include <windows.h>]])
|
||||
AC_CHECK_DECLS(InterlockedAdd64, [], [], [[#include <windows.h>]])
|
||||
fi
|
||||
|
||||
dnl socklen_t check
|
||||
@@ -2364,11 +2378,21 @@ dnl **************
|
||||
|
||||
AC_ARG_ENABLE(llvm,[ --enable-llvm Enable the LLVM back-end], enable_llvm=$enableval, enable_llvm=no)
|
||||
AC_ARG_ENABLE(loadedllvm,[ --enable-loadedllvm Load the LLVM back-end dynamically], enable_llvm=$enableval && enable_loadedllvm=$enableval, enable_loadedllvm=no)
|
||||
AC_ARG_ENABLE(llvm-version-check,[ --enable-llvm-version-check Check that the LLVM matches the version expected by mono], enable_llvm_version_check=$enableval, enable_llvm_version_check=no)
|
||||
|
||||
AC_ARG_WITH(llvm, [ --with-llvm=<llvm prefix> Enable the LLVM back-end], enable_llvm=yes,)
|
||||
|
||||
if test "x$enable_llvm" = "xyes"; then
|
||||
AC_PATH_PROG(LLVM_CONFIG, llvm-config, no)
|
||||
if test "x$LLVM_CONFIG" = "xno"; then
|
||||
AC_MSG_ERROR([llvm-config not found.])
|
||||
if test "x$with_llvm" != "x"; then
|
||||
LLVM_CONFIG=$with_llvm/bin/llvm-config
|
||||
if test ! -x $LLVM_CONFIG; then
|
||||
AC_MSG_ERROR([LLVM executable $LLVM_CONFIG not found.])
|
||||
fi
|
||||
else
|
||||
AC_PATH_PROG(LLVM_CONFIG, llvm-config, no)
|
||||
if test "x$LLVM_CONFIG" = "xno"; then
|
||||
AC_MSG_ERROR([llvm-config not found.])
|
||||
fi
|
||||
fi
|
||||
|
||||
llvm_codegen="x86codegen"
|
||||
@@ -2392,6 +2416,8 @@ if test "x$enable_llvm" = "xyes"; then
|
||||
fi
|
||||
LLVM_LIBS="$LLVM_LDFLAGS $LLVM_LIBS -lstdc++"
|
||||
|
||||
expected_llvm_version="3.3svn-mono/2c9642d"
|
||||
|
||||
# Should be something like '2.6' or '2.7svn'
|
||||
llvm_version=`$LLVM_CONFIG --version`
|
||||
major_version=`echo $llvm_version | cut -c 1`
|
||||
@@ -2401,6 +2427,11 @@ if test "x$enable_llvm" = "xyes"; then
|
||||
if echo $llvm_version | grep -q 'mono'; then
|
||||
AC_DEFINE(LLVM_MONO_BRANCH, 1, [Whenever we are using the mono branch of LLVM])
|
||||
LLVM_CXXFLAGS="$LLVM_CXXFLAGS -DLLVM_MONO_BRANCH"
|
||||
if test "x$enable_llvm_version_check" == "xyes"; then
|
||||
if test "$llvm_version" != "$expected_llvm_version"; then
|
||||
AC_MSG_ERROR([Expected llvm version $expected_llvm_version, but llvm-config --version returned $llvm_version"])
|
||||
fi
|
||||
fi
|
||||
else
|
||||
AC_MSG_ERROR([Compiling with stock LLVM is not supported, please use the Mono LLVM repo at https://github.com/mono/llvm, with the GIT branch which matches this version of mono, i.e. 'mono-2-10' for Mono 2.10.])
|
||||
fi
|
||||
@@ -2443,10 +2474,6 @@ jit_wanted=true
|
||||
interp_wanted=false
|
||||
sgen_supported=false
|
||||
case "$host" in
|
||||
# mips-sgi-irix5.* | mips-sgi-irix6.*)
|
||||
# TARGET=MIPS;
|
||||
# ACCESS_UNALIGNED="no"
|
||||
# ;;
|
||||
mips*)
|
||||
TARGET=MIPS;
|
||||
arch_target=mips;
|
||||
@@ -2769,7 +2796,7 @@ esac
|
||||
dnl Use GCC atomic ops if they work on the target.
|
||||
if test x$GCC = "xyes"; then
|
||||
case $TARGET in
|
||||
X86 | AMD64 | ARM | POWERPC | POWERPC64 | MIPS)
|
||||
X86 | AMD64 | ARM | POWERPC | POWERPC64 | MIPS | S390X | SPARC | SPARC64)
|
||||
AC_DEFINE(USE_GCC_ATOMIC_OPS, 1, [...])
|
||||
;;
|
||||
esac
|
||||
@@ -3379,7 +3406,35 @@ AC_CONFIG_COMMANDS([runtime/etc/mono/2.0/Browsers/Compat.browser],
|
||||
$ac_aux_dir/install-sh -d runtime/etc/mono/2.0/Browsers/
|
||||
cd runtime/etc/mono/2.0/Browsers
|
||||
rm -f Compat.browser
|
||||
$LN_S $reldir/data/net_2_0/Browsers/Compat.browser Compat.browser
|
||||
$LN_S $reldir/data/Browsers/Compat.browser Compat.browser
|
||||
cd $depth
|
||||
],[LN_S='$LN_S'])
|
||||
|
||||
AC_CONFIG_COMMANDS([runtime/etc/mono/4.0/Browsers/Compat.browser],
|
||||
[ depth=../../../../..
|
||||
case $srcdir in
|
||||
[[\\/$]]* | ?:[[\\/]]* ) reldir=$srcdir ;;
|
||||
.) reldir=$depth ;;
|
||||
*) reldir=$depth/$srcdir ;;
|
||||
esac
|
||||
$ac_aux_dir/install-sh -d runtime/etc/mono/4.0/Browsers/
|
||||
cd runtime/etc/mono/4.0/Browsers
|
||||
rm -f Compat.browser
|
||||
$LN_S $reldir/data/Browsers/Compat.browser Compat.browser
|
||||
cd $depth
|
||||
],[LN_S='$LN_S'])
|
||||
|
||||
AC_CONFIG_COMMANDS([runtime/etc/mono/4.5/Browsers/Compat.browser],
|
||||
[ depth=../../../../..
|
||||
case $srcdir in
|
||||
[[\\/$]]* | ?:[[\\/]]* ) reldir=$srcdir ;;
|
||||
.) reldir=$depth ;;
|
||||
*) reldir=$depth/$srcdir ;;
|
||||
esac
|
||||
$ac_aux_dir/install-sh -d runtime/etc/mono/4.5/Browsers/
|
||||
cd runtime/etc/mono/4.5/Browsers
|
||||
rm -f Compat.browser
|
||||
$LN_S $reldir/data/Browsers/Compat.browser Compat.browser
|
||||
cd $depth
|
||||
],[LN_S='$LN_S'])
|
||||
|
||||
@@ -3487,6 +3542,8 @@ data/net_2_0/Makefile
|
||||
data/net_4_0/Makefile
|
||||
data/net_4_5/Makefile
|
||||
data/net_2_0/Browsers/Makefile
|
||||
data/net_4_0/Browsers/Makefile
|
||||
data/net_4_5/Browsers/Makefile
|
||||
data/mint.pc
|
||||
data/mono-2.pc
|
||||
data/monosgen-2.pc
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+2
-2
@@ -26,6 +26,6 @@
|
||||
<dllentry dll="__Internal" name="MoveMemory" target="mono_win32_compat_MoveMemory"/>
|
||||
<dllentry dll="__Internal" name="ZeroMemory" target="mono_win32_compat_ZeroMemory"/>
|
||||
</dllmap>
|
||||
<dllmap dll="gdiplus" target="@prefix@/lib/libgdiplus@libsuffix@" />
|
||||
<dllmap dll="gdiplus.dll" target="@prefix@/lib/libgdiplus@libsuffix@" />
|
||||
<dllmap dll="gdiplus" target="@prefix@/lib/libgdiplus@libsuffix@" os="!windows"/>
|
||||
<dllmap dll="gdiplus.dll" target="@prefix@/lib/libgdiplus@libsuffix@" os="!windows"/>
|
||||
</configuration>
|
||||
@@ -1,6 +1,6 @@
|
||||
monodir = $(sysconfdir)/mono/2.0/Browsers
|
||||
|
||||
EXTRA_DIST = Compat.browser
|
||||
EXTRA_DIST = ../../Browsers/Compat.browser
|
||||
|
||||
mono_DATA = Compat.browser
|
||||
mono_DATA = ../../Browsers/Compat.browser
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
/Makefile
|
||||
/Makefile.in
|
||||
@@ -0,0 +1,6 @@
|
||||
monodir = $(sysconfdir)/mono/4.0/Browsers
|
||||
|
||||
EXTRA_DIST = ../../Browsers/Compat.browser
|
||||
|
||||
mono_DATA = ../../Browsers/Compat.browser
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
SUBDIRS =
|
||||
SUBDIRS = Browsers
|
||||
|
||||
monodir = $(sysconfdir)/mono/4.0
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
/Makefile
|
||||
/Makefile.in
|
||||
@@ -0,0 +1,6 @@
|
||||
monodir = $(sysconfdir)/mono/4.5/Browsers
|
||||
|
||||
EXTRA_DIST = ../../Browsers/Compat.browser
|
||||
|
||||
mono_DATA = ../../Browsers/Compat.browser
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
SUBDIRS =
|
||||
SUBDIRS = Browsers
|
||||
|
||||
monodir = $(sysconfdir)/mono/4.5
|
||||
|
||||
|
||||
@@ -307,6 +307,7 @@ mono_gc_out_of_memory
|
||||
mono_gc_wbarrier_arrayref_copy
|
||||
mono_gc_wbarrier_generic_nostore
|
||||
mono_gc_wbarrier_generic_store
|
||||
mono_gc_wbarrier_generic_store_atomic
|
||||
mono_gc_wbarrier_object_copy
|
||||
mono_gc_wbarrier_set_arrayref
|
||||
mono_gc_wbarrier_set_field
|
||||
|
||||
@@ -307,6 +307,7 @@ mono_gc_out_of_memory
|
||||
mono_gc_wbarrier_arrayref_copy
|
||||
mono_gc_wbarrier_generic_nostore
|
||||
mono_gc_wbarrier_generic_store
|
||||
mono_gc_wbarrier_generic_store_atomic
|
||||
mono_gc_wbarrier_object_copy
|
||||
mono_gc_wbarrier_set_arrayref
|
||||
mono_gc_wbarrier_set_field
|
||||
|
||||
Vendored
+1
-1
Submodule external/cecil updated: 54e0a50464...89cfb1d407.
Vendored
+1
-1
Submodule external/ikvm updated: b31b74af3b...c02349ea22.
@@ -8,6 +8,8 @@ net_4_5_SUBDIRS = $(monotouch_SUBDIRS) System.Dynamic.Runtime System.Reflection.
|
||||
|
||||
monodroid_SUBDIRS = $(net_4_5_SUBDIRS)
|
||||
|
||||
SUBDIRS = $(net_4_5_SUBDIRS)
|
||||
|
||||
include $(MCS_BUILD_DIR)/rules.make
|
||||
|
||||
dist-local: dist-default
|
||||
|
||||
@@ -642,7 +642,7 @@ namespace I18N.CJK
|
||||
continue;
|
||||
}
|
||||
i++;
|
||||
if (bytes [i] == 0x42)
|
||||
if (bytes [i] == 0x42 || bytes [i] == 0x40)
|
||||
m = wide ? ISO2022JPMode.JISX0208 : ISO2022JPMode.ASCII;
|
||||
else if (bytes [i] == 0x4A) // obsoleted
|
||||
m = ISO2022JPMode.ASCII;
|
||||
@@ -730,7 +730,7 @@ namespace I18N.CJK
|
||||
continue;
|
||||
}
|
||||
i++;
|
||||
if (bytes [i] == 0x42)
|
||||
if (bytes [i] == 0x42 || bytes [i] == 0x40)
|
||||
m = wide ? ISO2022JPMode.JISX0208 : ISO2022JPMode.ASCII;
|
||||
else if (bytes [i] == 0x4A) // obsoleted
|
||||
m = ISO2022JPMode.ASCII;
|
||||
|
||||
@@ -575,6 +575,14 @@ namespace MonoTests.I18N.CJK
|
||||
Assert.AreEqual ("don\u2019t", s);
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Bug14591 ()
|
||||
{
|
||||
var expected = "\u4f50\u85e4\u8c4a";
|
||||
var text = Encoding.GetEncoding ("iso-2022-jp").GetString (Convert.FromBase64String ("GyRAOjRGI0stGyhK"));
|
||||
Assert.AreEqual (expected, text, "#1");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Korean
|
||||
|
||||
+4
-2
@@ -128,6 +128,8 @@ net_2_0_only_dirs := \
|
||||
System.Data.Services \
|
||||
System.Web.Mvc \
|
||||
|
||||
pcl_facade_dirs := Facades
|
||||
|
||||
mobile_dirs := \
|
||||
corlib \
|
||||
System \
|
||||
@@ -156,7 +158,7 @@ mobile_dirs := \
|
||||
System.Net \
|
||||
System.Windows \
|
||||
System.Xml.Serialization \
|
||||
Facades
|
||||
$(pcl_facade_dirs)
|
||||
|
||||
monodroid_dirs := \
|
||||
Mono.CompilerServices.SymbolWriter \
|
||||
@@ -229,7 +231,7 @@ net_4_5_dirs := \
|
||||
System.IO.Compression.FileSystem \
|
||||
System.Windows \
|
||||
System.Xml.Serialization \
|
||||
Facades
|
||||
$(pcl_facade_dirs)
|
||||
|
||||
net_2_0_SUBDIRS := $(common_dirs) $(net_2_0_dirs) $(net_2_0_only_dirs) aot-compiler
|
||||
monodroid_SUBDIRS := $(mobile_dirs) $(monodroid_dirs)
|
||||
|
||||
@@ -76,6 +76,7 @@ namespace System.Windows.Forms {
|
||||
internal bool whacky_wm;
|
||||
internal bool fixed_size;
|
||||
internal bool zombie; /* X11 only flag. true if the X windows have been destroyed but we haven't been Disposed */
|
||||
internal bool topmost; /* X11 only. */
|
||||
internal Region user_clip;
|
||||
internal XEventQueue queue;
|
||||
internal WindowExStyles initial_ex_style;
|
||||
@@ -122,6 +123,7 @@ namespace System.Windows.Forms {
|
||||
children = new ArrayList ();
|
||||
resizing_or_moving = false;
|
||||
whacky_wm = false;
|
||||
topmost = false;
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
|
||||
@@ -173,6 +173,8 @@ namespace System.Windows.Forms
|
||||
this.MenuDroppedDown = false;
|
||||
|
||||
base.Dismiss (reason);
|
||||
|
||||
this.FireMenuDeactivate ();
|
||||
}
|
||||
|
||||
internal void FireMenuActivate ()
|
||||
|
||||
@@ -894,7 +894,7 @@ namespace System.Windows.Forms
|
||||
if (this is MenuStrip && mouse_currently_over is ToolStripMenuItem && !(mouse_currently_over as ToolStripMenuItem).HasDropDownItems)
|
||||
return;
|
||||
} else {
|
||||
this.HideMenus (true, ToolStripDropDownCloseReason.AppClicked);
|
||||
this.Dismiss (ToolStripDropDownCloseReason.AppClicked);
|
||||
}
|
||||
|
||||
if (this is MenuStrip)
|
||||
@@ -1503,17 +1503,6 @@ namespace System.Windows.Forms
|
||||
this.GetTopLevelToolStrip ().Dismiss (ToolStripDropDownCloseReason.ItemClicked);
|
||||
}
|
||||
|
||||
internal void HideMenus (bool release, ToolStripDropDownCloseReason reason)
|
||||
{
|
||||
if (this is MenuStrip && release && menu_selected)
|
||||
(this as MenuStrip).FireMenuDeactivate ();
|
||||
|
||||
if (release)
|
||||
menu_selected = false;
|
||||
|
||||
NotifySelectedChanged (null);
|
||||
}
|
||||
|
||||
internal void NotifySelectedChanged (ToolStripItem tsi)
|
||||
{
|
||||
foreach (ToolStripItem tsi2 in this.DisplayedItems)
|
||||
|
||||
@@ -315,12 +315,9 @@ namespace System.Windows.Forms
|
||||
protected override void OnMouseUp (MouseEventArgs e)
|
||||
{
|
||||
if (this.close_on_mouse_release) {
|
||||
this.DropDown.Dismiss (ToolStripDropDownCloseReason.ItemClicked);
|
||||
this.Parent.Dismiss (ToolStripDropDownCloseReason.ItemClicked);
|
||||
this.Invalidate ();
|
||||
this.close_on_mouse_release = false;
|
||||
|
||||
if (!this.IsOnDropDown && this.Parent is MenuStrip)
|
||||
(this.Parent as MenuStrip).MenuDroppedDown = false;
|
||||
}
|
||||
|
||||
if (!this.HasDropDownItems && Enabled)
|
||||
|
||||
@@ -1619,11 +1619,23 @@ namespace System.Windows.Forms {
|
||||
if (hwnd.zombie)
|
||||
return;
|
||||
|
||||
if ((windows & WindowType.Whole) != 0) {
|
||||
XMapWindow(DisplayHandle, hwnd.whole_window);
|
||||
}
|
||||
if ((windows & WindowType.Client) != 0) {
|
||||
XMapWindow(DisplayHandle, hwnd.client_window);
|
||||
if (hwnd.topmost) {
|
||||
// Most window managers will respect the _NET_WM_STATE property.
|
||||
// If not, use XMapRaised to map the window at the top level as
|
||||
// a last ditch effort.
|
||||
if ((windows & WindowType.Whole) != 0) {
|
||||
XMapRaised(DisplayHandle, hwnd.whole_window);
|
||||
}
|
||||
if ((windows & WindowType.Client) != 0) {
|
||||
XMapRaised(DisplayHandle, hwnd.client_window);
|
||||
}
|
||||
} else {
|
||||
if ((windows & WindowType.Whole) != 0) {
|
||||
XMapWindow(DisplayHandle, hwnd.whole_window);
|
||||
}
|
||||
if ((windows & WindowType.Client) != 0) {
|
||||
XMapWindow(DisplayHandle, hwnd.client_window);
|
||||
}
|
||||
}
|
||||
|
||||
hwnd.mapped = true;
|
||||
@@ -2972,13 +2984,8 @@ namespace System.Windows.Forms {
|
||||
XSelectInput(DisplayHandle, hwnd.client_window, new IntPtr ((int)(SelectInputMask | EventMask.StructureNotifyMask | Keyboard.KeyEventMask)));
|
||||
}
|
||||
|
||||
if (ExStyleSet (cp.ExStyle, WindowExStyles.WS_EX_TOPMOST)) {
|
||||
atoms = new int[2];
|
||||
atoms[0] = _NET_WM_WINDOW_TYPE_NORMAL.ToInt32();
|
||||
XChangeProperty(DisplayHandle, hwnd.whole_window, _NET_WM_WINDOW_TYPE, (IntPtr)Atom.XA_ATOM, 32, PropertyMode.Replace, atoms, 1);
|
||||
|
||||
XSetTransientForHint (DisplayHandle, hwnd.whole_window, RootWindow);
|
||||
}
|
||||
if (ExStyleSet (cp.ExStyle, WindowExStyles.WS_EX_TOPMOST))
|
||||
SetTopmost(hwnd.whole_window, true);
|
||||
|
||||
SetWMStyles(hwnd, cp);
|
||||
|
||||
@@ -5787,6 +5794,7 @@ namespace System.Windows.Forms {
|
||||
{
|
||||
|
||||
Hwnd hwnd = Hwnd.ObjectFromHandle(handle);
|
||||
hwnd.topmost = enabled;
|
||||
|
||||
if (enabled) {
|
||||
lock (XlibLock) {
|
||||
@@ -6405,6 +6413,13 @@ namespace System.Windows.Forms {
|
||||
DebugHelper.TraceWriteLine ("XMapWindow");
|
||||
return _XMapWindow(display, window);
|
||||
}
|
||||
[DllImport ("libX11", EntryPoint="XMapRaised")]
|
||||
internal extern static int _XMapRaised(IntPtr display, IntPtr window);
|
||||
internal static int XMapRaised(IntPtr display, IntPtr window)
|
||||
{
|
||||
DebugHelper.TraceWriteLine ("XMapRaised");
|
||||
return _XMapRaised(display, window);
|
||||
}
|
||||
[DllImport ("libX11", EntryPoint="XUnmapWindow")]
|
||||
internal extern static int _XUnmapWindow(IntPtr display, IntPtr window);
|
||||
internal static int XUnmapWindow(IntPtr display, IntPtr window)
|
||||
@@ -7255,6 +7270,9 @@ namespace System.Windows.Forms {
|
||||
[DllImport ("libX11", EntryPoint="XMapWindow")]
|
||||
internal extern static int XMapWindow(IntPtr display, IntPtr window);
|
||||
|
||||
[DllImport ("libX11", EntryPoint="XMapRaised")]
|
||||
internal extern static int XMapRaised(IntPtr display, IntPtr window);
|
||||
|
||||
[DllImport ("libX11", EntryPoint="XUnmapWindow")]
|
||||
internal extern static int XUnmapWindow(IntPtr display, IntPtr window);
|
||||
|
||||
|
||||
+5
@@ -109,6 +109,11 @@ namespace Microsoft.Build.BuildEngine {
|
||||
{
|
||||
if (token.Type == TokenType.Number)
|
||||
return true;
|
||||
else if (token.Type == TokenType.String) {
|
||||
var text = StringEvaluate (context);
|
||||
Single number;
|
||||
return Single.TryParse (text, out number);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -96,14 +96,17 @@ namespace Microsoft.Build.BuildEngine {
|
||||
return;
|
||||
|
||||
int offset = 0;
|
||||
string full_path;
|
||||
if (Path.IsPathRooted (name)) {
|
||||
full_path = name;
|
||||
baseDirectory = new DirectoryInfo (Path.GetPathRoot (name));
|
||||
if (IsRunningOnWindows)
|
||||
// skip the "drive:"
|
||||
offset = 1;
|
||||
} else {
|
||||
full_path = Path.GetFullPath (Path.Combine (Environment.CurrentDirectory, name));
|
||||
}
|
||||
|
||||
string full_path = Path.GetFullPath (Path.Combine (Environment.CurrentDirectory, include_item.ItemSpec));
|
||||
fileInfo = ParseIncludeExclude (separatedPath, offset, baseDirectory);
|
||||
|
||||
int wildcard_offset = full_path.IndexOf ("**");
|
||||
|
||||
@@ -117,6 +117,11 @@ namespace Microsoft.Build.BuildEngine {
|
||||
#if NET_4_0
|
||||
Toolsets.Add (new Toolset ("4.0",
|
||||
ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version40)));
|
||||
#endif
|
||||
#if NET_4_5
|
||||
Toolsets.Add (new Toolset("12.0",
|
||||
ToolLocationHelper.GetMSBuildInstallPath ("12.0"),
|
||||
ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version40)));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -159,12 +159,23 @@ namespace Microsoft.Build.BuildEngine {
|
||||
else
|
||||
base_dir_info = new DirectoryInfo (Directory.GetCurrentDirectory ());
|
||||
|
||||
IEnumerable<string> extn_paths = has_extn_ref ? GetExtensionPaths (project) : new string [] {null};
|
||||
var importPaths = GetImportPathsFromString (project_attribute, project, base_dir_info);
|
||||
var extensionPaths = GetExtensionPaths (project);
|
||||
|
||||
if (!has_extn_ref) {
|
||||
foreach (var importPath in importPaths) {
|
||||
foreach (var extensionPath in extensionPaths) {
|
||||
has_extn_ref = has_extn_ref || importPath.IndexOf (extensionPath) >= 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerable<string> extn_paths = has_extn_ref ? extensionPaths : new string [] { null };
|
||||
bool import_needed = false;
|
||||
var currentLoadSettings = project.ProjectLoadSettings;
|
||||
|
||||
|
||||
try {
|
||||
foreach (var settings in new ProjectLoadSettings [] { ProjectLoadSettings.None, currentLoadSettings}) {
|
||||
foreach (var settings in new ProjectLoadSettings [] { ProjectLoadSettings.None, currentLoadSettings }) {
|
||||
foreach (string path in extn_paths) {
|
||||
string extn_msg = null;
|
||||
if (has_extn_ref) {
|
||||
@@ -183,7 +194,7 @@ namespace Microsoft.Build.BuildEngine {
|
||||
// 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)) {
|
||||
foreach (string importPath in importPaths) {
|
||||
try {
|
||||
if (func (importPath, extn_msg))
|
||||
atleast_one = true;
|
||||
|
||||
@@ -937,6 +937,9 @@ namespace Microsoft.Build.BuildEngine {
|
||||
case "Import":
|
||||
AddImport (xe, ip, true);
|
||||
break;
|
||||
case "ImportGroup":
|
||||
AddImportGroup (xe, ip, true);
|
||||
break;
|
||||
case "ItemGroup":
|
||||
AddItemGroup (xe, ip);
|
||||
break;
|
||||
@@ -947,7 +950,7 @@ namespace Microsoft.Build.BuildEngine {
|
||||
AddChoose (xe, ip);
|
||||
break;
|
||||
default:
|
||||
throw new InvalidProjectFileException (String.Format ("Invalid element '{0}' in project file.", xe.Name));
|
||||
throw new InvalidProjectFileException (String.Format ("Invalid element '{0}' in project file '{1}'.", xe.Name, ip.FullFileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1029,7 +1032,17 @@ namespace Microsoft.Build.BuildEngine {
|
||||
SetExtensionsPathProperties (DefaultExtensionsPath);
|
||||
evaluatedProperties.AddProperty (new BuildProperty ("MSBuildProjectDefaultTargets", DefaultTargets, PropertyType.Reserved));
|
||||
evaluatedProperties.AddProperty (new BuildProperty ("OS", OS, PropertyType.Environment));
|
||||
|
||||
#if NET_4_5
|
||||
// see http://msdn.microsoft.com/en-us/library/vstudio/hh162058(v=vs.120).aspx
|
||||
if (effective_tools_version == "12.0") {
|
||||
evaluatedProperties.AddProperty (new BuildProperty ("MSBuildToolsPath32", toolsPath, PropertyType.Reserved));
|
||||
string frameworkToolsPath = parentEngine.Toolsets [effective_tools_version].FrameworkToolsPath;
|
||||
if (frameworkToolsPath == null)
|
||||
throw new Exception (String.Format ("Invalid tools version '{0}', no framework tools path set for this.", effective_tools_version));
|
||||
evaluatedProperties.AddProperty (new BuildProperty ("MSBuildFrameworkToolsPath", frameworkToolsPath, PropertyType.Reserved));
|
||||
evaluatedProperties.AddProperty (new BuildProperty ("MSBuildFrameworkToolsPath32", frameworkToolsPath, PropertyType.Reserved));
|
||||
}
|
||||
#endif
|
||||
// FIXME: make some internal method that will work like GetDirectoryName but output String.Empty on null/String.Empty
|
||||
string projectDir;
|
||||
if (FullFileName == String.Empty)
|
||||
@@ -1104,9 +1117,10 @@ namespace Microsoft.Build.BuildEngine {
|
||||
void AddImport (XmlElement xmlElement, ImportedProject importingProject, bool evaluate_properties)
|
||||
{
|
||||
// eval all the properties etc till the import
|
||||
if (evaluate_properties)
|
||||
if (evaluate_properties) {
|
||||
groupingCollection.Evaluate (EvaluationType.Property);
|
||||
|
||||
groupingCollection.Evaluate (EvaluationType.Choose);
|
||||
}
|
||||
try {
|
||||
PushThisFileProperty (importingProject != null ? importingProject.FullFileName : FullFileName);
|
||||
|
||||
@@ -1121,6 +1135,30 @@ namespace Microsoft.Build.BuildEngine {
|
||||
}
|
||||
}
|
||||
|
||||
void AddImportGroup (XmlElement xmlElement, ImportedProject importedProject, bool evaluate_properties)
|
||||
{
|
||||
// eval all the properties etc till the import group
|
||||
if (evaluate_properties) {
|
||||
groupingCollection.Evaluate (EvaluationType.Property);
|
||||
groupingCollection.Evaluate (EvaluationType.Choose);
|
||||
}
|
||||
string condition_attribute = xmlElement.GetAttribute ("Condition");
|
||||
if (!ConditionParser.ParseAndEvaluate (condition_attribute, this))
|
||||
return;
|
||||
foreach (XmlNode xn in xmlElement.ChildNodes) {
|
||||
if (xn is XmlElement) {
|
||||
XmlElement xe = (XmlElement) xn;
|
||||
switch (xe.Name) {
|
||||
case "Import":
|
||||
AddImport (xe, importedProject, evaluate_properties);
|
||||
break;
|
||||
default:
|
||||
throw new InvalidProjectFileException(String.Format("Invalid element '{0}' inside ImportGroup in project file '{1}'.", xe.Name, importedProject.FullFileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool AddSingleImport (XmlElement xmlElement, string projectPath, ImportedProject importingProject, string from_source_msg)
|
||||
{
|
||||
Import import = new Import (xmlElement, projectPath, this, importingProject);
|
||||
|
||||
@@ -31,15 +31,21 @@ namespace Microsoft.Build.BuildEngine
|
||||
{
|
||||
public class Toolset
|
||||
{
|
||||
public Toolset (string toolsVersion, string toolsPath, BuildPropertyGroup buildProperties)
|
||||
public Toolset (string toolsVersion, string toolsPath, string toolsFrameworkPath, BuildPropertyGroup buildProperties)
|
||||
{
|
||||
ToolsVersion = toolsVersion;
|
||||
ToolsPath = toolsPath;
|
||||
FrameworkToolsPath = toolsFrameworkPath;
|
||||
BuildProperties = buildProperties;
|
||||
}
|
||||
|
||||
public Toolset (string toolsVersion, string toolsPath)
|
||||
: this (toolsVersion, toolsPath, null)
|
||||
|
||||
public Toolset (string toolsVersion, string toolsPath, string toolsFrameworkPath)
|
||||
: this (toolsVersion, toolsPath, toolsFrameworkPath, null)
|
||||
{
|
||||
}
|
||||
|
||||
public Toolset(string toolsVersion, string toolsPath)
|
||||
: this (toolsVersion, toolsPath, toolsPath)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -47,5 +53,6 @@ namespace Microsoft.Build.BuildEngine
|
||||
|
||||
public string ToolsVersion { get; private set; }
|
||||
public string ToolsPath { get; private set; }
|
||||
public string FrameworkToolsPath { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ Microsoft.Build.Framework/ITask.cs
|
||||
Microsoft.Build.Framework/ITaskHost.cs
|
||||
Microsoft.Build.Framework/ITaskItem.cs
|
||||
Microsoft.Build.Framework/ITaskItem2.cs
|
||||
Microsoft.Build.Framework/LazyFormattedBuildEventArgs.cs
|
||||
Microsoft.Build.Framework/LoadInSeparateAppDomainAttribute.cs
|
||||
Microsoft.Build.Framework/LoggerException.cs
|
||||
Microsoft.Build.Framework/LoggerVerbosity.cs
|
||||
|
||||
@@ -49,12 +49,18 @@ namespace Microsoft.Build.Framework
|
||||
|
||||
protected BuildEventArgs (string message, string helpKeyword,
|
||||
string senderName)
|
||||
: this (message, helpKeyword, senderName, DateTime.Now)
|
||||
{
|
||||
}
|
||||
|
||||
protected BuildEventArgs (string message, string helpKeyword,
|
||||
string senderName, DateTime eventTimestamp)
|
||||
{
|
||||
this.message = message;
|
||||
this.helpKeyword = helpKeyword;
|
||||
this.senderName = senderName;
|
||||
this.threadId = Thread.CurrentThread.GetHashCode ();
|
||||
this.timestamp = DateTime.Now;
|
||||
this.timestamp = eventTimestamp;
|
||||
}
|
||||
|
||||
public string HelpKeyword {
|
||||
@@ -90,4 +96,4 @@ namespace Microsoft.Build.Framework
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
+20
-2
@@ -43,7 +43,25 @@ namespace Microsoft.Build.Framework {
|
||||
public BuildFinishedEventArgs (string message,
|
||||
string helpKeyword,
|
||||
bool succeeded)
|
||||
: base (message, helpKeyword, null)
|
||||
: this (message, helpKeyword, succeeded, DateTime.Now)
|
||||
{
|
||||
}
|
||||
|
||||
public BuildFinishedEventArgs (string message,
|
||||
string helpKeyword,
|
||||
bool succeeded,
|
||||
DateTime eventTimestamp)
|
||||
: base (message, helpKeyword, null, eventTimestamp)
|
||||
{
|
||||
this.succeeded = succeeded;
|
||||
}
|
||||
|
||||
public BuildFinishedEventArgs (string message,
|
||||
string helpKeyword,
|
||||
bool succeeded,
|
||||
DateTime eventTimestamp,
|
||||
params object [] messageArgs)
|
||||
: base (message, helpKeyword, null, eventTimestamp, messageArgs)
|
||||
{
|
||||
this.succeeded = succeeded;
|
||||
}
|
||||
@@ -56,4 +74,4 @@ namespace Microsoft.Build.Framework {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
+26
-1
@@ -29,6 +29,7 @@
|
||||
#if NET_2_0
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Build.Framework {
|
||||
[Serializable]
|
||||
@@ -40,10 +41,34 @@ namespace Microsoft.Build.Framework {
|
||||
|
||||
public BuildStartedEventArgs (string message,
|
||||
string helpKeyword)
|
||||
: this (message, helpKeyword, DateTime.Now)
|
||||
{
|
||||
}
|
||||
|
||||
public BuildStartedEventArgs (string message,
|
||||
string helpKeyword,
|
||||
IDictionary<string, string> environmentOfBuild)
|
||||
: base (message, helpKeyword, null)
|
||||
{
|
||||
// deal with environmentOfBuild
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public BuildStartedEventArgs (string message,
|
||||
string helpKeyword,
|
||||
DateTime eventTimestamp)
|
||||
: base (message, helpKeyword, null, eventTimestamp)
|
||||
{
|
||||
}
|
||||
|
||||
public BuildStartedEventArgs (string message,
|
||||
string helpKeyword,
|
||||
DateTime eventTimestamp,
|
||||
params object [] messageArgs)
|
||||
: base (message, helpKeyword, null, eventTimestamp, messageArgs)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
+19
-2
@@ -33,7 +33,7 @@ using System;
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
[Serializable]
|
||||
public abstract class BuildStatusEventArgs : BuildEventArgs {
|
||||
public abstract class BuildStatusEventArgs : LazyFormattedBuildEventArgs {
|
||||
|
||||
protected BuildStatusEventArgs ()
|
||||
{
|
||||
@@ -45,7 +45,24 @@ namespace Microsoft.Build.Framework
|
||||
: base (message, helpKeyword, senderName)
|
||||
{
|
||||
}
|
||||
|
||||
protected BuildStatusEventArgs (string message,
|
||||
string helpKeyword,
|
||||
string senderName,
|
||||
DateTime eventTimestamp)
|
||||
: base (message, helpKeyword, senderName, eventTimestamp)
|
||||
{
|
||||
}
|
||||
|
||||
protected BuildStatusEventArgs (string message,
|
||||
string helpKeyword,
|
||||
string senderName,
|
||||
DateTime eventTimestamp,
|
||||
params object [] messageArgs)
|
||||
: base (message, helpKeyword, senderName, eventTimestamp, messageArgs)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// LazyFormattedBuildEventArgs.cs
|
||||
//
|
||||
// Author:
|
||||
// Atsushi Enomoto <[email protected]>
|
||||
//
|
||||
// (C) 2013 Xamarin Inc.
|
||||
//
|
||||
// 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.Threading;
|
||||
|
||||
namespace Microsoft.Build.Framework
|
||||
{
|
||||
[Serializable]
|
||||
public abstract class LazyFormattedBuildEventArgs : BuildEventArgs
|
||||
{
|
||||
|
||||
protected LazyFormattedBuildEventArgs ()
|
||||
: this (null, null, null)
|
||||
{
|
||||
}
|
||||
|
||||
protected LazyFormattedBuildEventArgs (string message, string helpKeyword,
|
||||
string senderName)
|
||||
: this (message, helpKeyword, senderName, DateTime.Now)
|
||||
{
|
||||
}
|
||||
|
||||
protected LazyFormattedBuildEventArgs (string message, string helpKeyword,
|
||||
string senderName, DateTime eventTimestamp,
|
||||
params object [] messageArgs)
|
||||
: base (string.Format (message, messageArgs), helpKeyword, senderName, eventTimestamp)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,7 +82,7 @@ namespace Microsoft.Build.Tasks {
|
||||
result &= CompileResourceFile (sourceFile, outputFile);
|
||||
|
||||
ITaskItem newItem = new TaskItem (source);
|
||||
source.ItemSpec = outputFile;
|
||||
newItem.ItemSpec = outputFile;
|
||||
|
||||
temporaryFilesWritten.Add (newItem);
|
||||
}
|
||||
|
||||
@@ -408,7 +408,7 @@ namespace Microsoft.Build.Tasks {
|
||||
return;
|
||||
|
||||
foreach (string ext in allowedRelatedFileExtensions) {
|
||||
string rfile = filename + ext;
|
||||
string rfile = Path.ChangeExtension (filename, ext);
|
||||
if (File.Exists (rfile)) {
|
||||
ITaskItem item = new TaskItem (rfile);
|
||||
SetCopyLocal (item, parent_copy_local);
|
||||
|
||||
@@ -19,7 +19,7 @@ LIB_MCS_FLAGS = \
|
||||
/r:System.dll \
|
||||
/r:$(BUILD_FRAMEWORK)
|
||||
|
||||
TEST_MCS_FLAGS = /r:$(BUILD_FRAMEWORK) -r:System.dll
|
||||
TEST_MCS_FLAGS = /r:$(BUILD_FRAMEWORK) -r:System.dll -r:System.Core.dll
|
||||
|
||||
export TESTING_MONO=a
|
||||
XBUILD_DIR=../../tools/xbuild
|
||||
|
||||
@@ -51,5 +51,6 @@
|
||||
<Compile Include="Test\Microsoft.Build.Utilities\LoggerTest.cs" />
|
||||
<Compile Include="Test\Microsoft.Build.Utilities\TaskItemTest.cs" />
|
||||
<Compile Include="Test\Microsoft.Build.Utilities\TaskLoggingHelperTest.cs" />
|
||||
<Compile Include="Test\Microsoft.Build.Utilities\ToolTaskTest.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -48,6 +48,9 @@ namespace Microsoft.Build.Utilities
|
||||
t2 = t1.Parent;
|
||||
|
||||
lib_mono_dir = t2.FullName;
|
||||
#if NET_4_0
|
||||
var windowsPath = Environment.GetFolderPath (Environment.SpecialFolder.Windows);
|
||||
#endif
|
||||
if (Environment.GetEnvironmentVariable ("TESTING_MONO") != null) {
|
||||
mono_dir = new string [] {
|
||||
Path.Combine (lib_mono_dir, "net_1_0"),
|
||||
@@ -57,6 +60,18 @@ namespace Microsoft.Build.Utilities
|
||||
Path.Combine (lib_mono_dir, "net_4_0"),
|
||||
Path.Combine (lib_mono_dir, "net_4_5")
|
||||
};
|
||||
#if NET_4_0
|
||||
} else if (!string.IsNullOrEmpty (windowsPath) && lib_mono_dir.StartsWith (windowsPath)) {
|
||||
//running in .NET, not Mono
|
||||
mono_dir = new string [] {
|
||||
Path.Combine (lib_mono_dir, "v1.0.3705"),
|
||||
Path.Combine (lib_mono_dir, "v2.0.50727"),
|
||||
Path.Combine (lib_mono_dir, "v2.0.50727"),
|
||||
Path.Combine (lib_mono_dir, "v3.5"),
|
||||
Path.Combine (lib_mono_dir, "v4.0.30319"),
|
||||
Path.Combine (lib_mono_dir, "v4.0.30319")
|
||||
};
|
||||
#endif
|
||||
} else {
|
||||
mono_dir = new string [] {
|
||||
Path.Combine (lib_mono_dir, "1.0"),
|
||||
@@ -93,6 +108,15 @@ namespace Microsoft.Build.Utilities
|
||||
return mono_dir [(int)version];
|
||||
}
|
||||
|
||||
#if NET_4_0
|
||||
public static string GetMSBuildInstallPath (string version)
|
||||
{
|
||||
//see http://msdn.microsoft.com/en-us/library/vstudio/bb397428(v=vs.120).aspx
|
||||
var programFiles = Environment.GetFolderPath (Environment.SpecialFolder.ProgramFilesX86);
|
||||
return Path.Combine (programFiles, "MSBuild", version, "bin");
|
||||
}
|
||||
#endif
|
||||
|
||||
[MonoTODO]
|
||||
public static string GetPathToDotNetFrameworkFile (string fileName,
|
||||
TargetDotNetFrameworkVersion version)
|
||||
|
||||
@@ -464,13 +464,25 @@ namespace Microsoft.Build.Utilities
|
||||
}
|
||||
}
|
||||
|
||||
// Snatched from our codedom code, with some changes to make it compatible with csc
|
||||
// (the line+column group is optional is csc)
|
||||
// Keep in sync with mcs/class/System/Microsoft.CSharp/CSharpCodeCompiler.cs
|
||||
const string ErrorRegexPattern = @"
|
||||
^
|
||||
(\s*(?<file>[^\(]+) # filename (optional)
|
||||
(\((?<line>\d*)(,(?<column>\d*[\+]*))?\))? # line+column (optional)
|
||||
:\s+)?
|
||||
(?<level>\w+) # error|warning
|
||||
\s+
|
||||
(?<number>[^:]*\d) # CS1234
|
||||
:
|
||||
\s*
|
||||
(?<message>.*)$";
|
||||
|
||||
static Regex errorRegex;
|
||||
static Regex CscErrorRegex {
|
||||
get {
|
||||
if (errorRegex == null)
|
||||
errorRegex = new Regex (@"^(\s*(?<file>[^\(]+)(\((?<line>\d*)(,(?<column>\d*[\+]*))?\))?:\s+)*(?<level>\w+)\s+(?<number>.*\d):\s*(?<message>.*)", RegexOptions.Compiled | RegexOptions.ExplicitCapture);
|
||||
errorRegex = new Regex (ErrorRegexPattern,
|
||||
RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.IgnorePatternWhitespace);
|
||||
return errorRegex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,3 +2,4 @@ Microsoft.Build.Utilities/CommandLineBuilderTest.cs
|
||||
Microsoft.Build.Utilities/LoggerTest.cs
|
||||
Microsoft.Build.Utilities/TaskItemTest.cs
|
||||
Microsoft.Build.Utilities/TaskLoggingHelperTest.cs
|
||||
Microsoft.Build.Utilities/ToolTaskTest.cs
|
||||
@@ -0,0 +1,141 @@
|
||||
//
|
||||
// ToolTaskTest.cs:
|
||||
//
|
||||
// Author:
|
||||
// Jonathan Pryor ([email protected])
|
||||
//
|
||||
// (C) 2013 Xamarin Inc.
|
||||
//
|
||||
// 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.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.Microsoft.Build.Utilities {
|
||||
|
||||
[TestFixture]
|
||||
public class ToolTaskTest {
|
||||
|
||||
[Test]
|
||||
public void LogEventsFromTextOutput ()
|
||||
{
|
||||
var messages = new[] {
|
||||
new {Code = "CS0152", Line = "class1.cs(16,4): error CS0152: The label `case 1:' already occurs in this switch statement" },
|
||||
};
|
||||
|
||||
var task = new LogEventsFromTextOutputToolTask ();
|
||||
foreach (var m in messages) {
|
||||
task.LogEventsFromTextOutput (m.Line);
|
||||
Assert.IsTrue (task.Codes.Count > 0, "No error logged for line: {0}", m.Line);
|
||||
Assert.AreEqual (m.Code, task.Codes [0]);
|
||||
task.Codes.Clear ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class LogEventsFromTextOutputToolTask : ToolTask {
|
||||
|
||||
public List<string> Codes {
|
||||
get {return engine.Codes;}
|
||||
}
|
||||
|
||||
CodeLoggingBuildEngine engine = new CodeLoggingBuildEngine ();
|
||||
|
||||
public LogEventsFromTextOutputToolTask ()
|
||||
{
|
||||
BuildEngine = engine;
|
||||
}
|
||||
|
||||
protected override string GenerateFullPathToTool ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
protected override string ToolName {
|
||||
get {throw new NotImplementedException ();}
|
||||
}
|
||||
|
||||
public void LogEventsFromTextOutput (string line)
|
||||
{
|
||||
base.LogEventsFromTextOutput (line, MessageImportance.Normal);
|
||||
}
|
||||
}
|
||||
|
||||
class CodeLoggingBuildEngine : IBuildEngine {
|
||||
|
||||
public List<string> Codes = new List<string> ();
|
||||
|
||||
public int ColumnNumberOfTaskNode {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public bool ContinueOnError {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public int LineNumberOfTaskNode {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public string ProjectFileOfTaskNode {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public bool BuildProjectFile (string projectFileName, string[] targetNames, System.Collections.IDictionary globalProperties, System.Collections.IDictionary targetOutputs)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public void LogCustomEvent (CustomBuildEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
public void LogErrorEvent (BuildErrorEventArgs e)
|
||||
{
|
||||
Codes.Add (e.Code);
|
||||
}
|
||||
|
||||
public void LogMessageEvent (BuildMessageEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
public void LogWarningEvent (BuildWarningEventArgs e)
|
||||
{
|
||||
Codes.Add (e.Code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,9 @@ LIB_MCS_FLAGS = \
|
||||
/r:Microsoft.Build.Engine.dll \
|
||||
/r:Microsoft.Build.Framework.dll
|
||||
|
||||
TEST_MCS_FLAGS = /r:System.Core.dll
|
||||
TEST_MCS_FLAGS = /r:System.Core.dll \
|
||||
/r:Microsoft.Build.Engine.dll \
|
||||
/r:Microsoft.Build.Framework.dll
|
||||
|
||||
EXTRA_DISTFILES = \
|
||||
Test/FunctionalTestReferenceProject.csproj \
|
||||
|
||||
@@ -25,65 +25,257 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using Microsoft.Build.Framework;
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Microsoft.Build.Framework;
|
||||
|
||||
namespace Microsoft.Build.Logging
|
||||
{
|
||||
public class ConsoleLogger : INodeLogger
|
||||
{
|
||||
public ConsoleLogger ()
|
||||
: this (LoggerVerbosity.Normal)
|
||||
{
|
||||
}
|
||||
public class ConsoleLogger : INodeLogger
|
||||
{
|
||||
public ConsoleLogger ()
|
||||
: this (LoggerVerbosity.Normal)
|
||||
{
|
||||
}
|
||||
|
||||
public ConsoleLogger (LoggerVerbosity verbosity)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
public ConsoleLogger (LoggerVerbosity verbosity)
|
||||
: this (verbosity, message => Console.WriteLine (message), color => Console.ForegroundColor = color, Console.ResetColor)
|
||||
{
|
||||
}
|
||||
|
||||
public ConsoleLogger (LoggerVerbosity verbosity, WriteHandler write, ColorSetter colorSet, ColorResetter colorReset)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
public ConsoleLogger (LoggerVerbosity verbosity, WriteHandler write, ColorSetter colorSet, ColorResetter colorReset)
|
||||
{
|
||||
if (write == null)
|
||||
throw new ArgumentNullException ("write");
|
||||
if (colorSet == null)
|
||||
throw new ArgumentNullException ("colorSet");
|
||||
if (colorReset == null)
|
||||
throw new ArgumentNullException ("colorReset");
|
||||
Verbosity = verbosity;
|
||||
this.write = write;
|
||||
set_color = colorSet;
|
||||
reset_color = colorReset;
|
||||
}
|
||||
|
||||
#region INodeLogger implementation
|
||||
public void Initialize (IEventSource eventSource, int nodeCount)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
#endregion
|
||||
WriteHandler write;
|
||||
ColorSetter set_color;
|
||||
ColorResetter reset_color;
|
||||
|
||||
#region ILogger implementation
|
||||
public void Initialize (IEventSource eventSource)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
#region INodeLogger implementation
|
||||
|
||||
public void Shutdown ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
public virtual void Initialize (IEventSource eventSource, int nodeCount)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public string Parameters {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
set {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public LoggerVerbosity Verbosity {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
set {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#region ILogger implementation
|
||||
|
||||
public virtual void Initialize (IEventSource eventSource)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public virtual void Shutdown ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public string Parameters { get; set; }
|
||||
|
||||
public LoggerVerbosity Verbosity { get; set; }
|
||||
|
||||
public bool ShowSummary { get; set; }
|
||||
|
||||
public bool SkipProjectStartedText { get; set; }
|
||||
|
||||
public WriteHandler WriteHandler {
|
||||
get { return write; }
|
||||
set {
|
||||
if (value == null)
|
||||
throw new ArgumentNullException ("value");
|
||||
write = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void ApplyParameter (string parameterName, string parameterValue)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
DateTime build_started;
|
||||
|
||||
public void BuildFinishedHandler (object sender, BuildFinishedEventArgs e)
|
||||
{
|
||||
if (Verbosity == LoggerVerbosity.Quiet || Verbosity == LoggerVerbosity.Minimal)
|
||||
return;
|
||||
|
||||
set_color (ConsoleColor.White);
|
||||
write (e.Message);
|
||||
write ("");
|
||||
write ("");
|
||||
write ("");
|
||||
// .NET doesn't care if BuildStarted is actually invoked.
|
||||
write (string.Format ("Time Elapsed {0}", (e.Timestamp - build_started).ToString ("hh\\:mm\\:ss\\.ff")));
|
||||
write ("");
|
||||
reset_color ();
|
||||
}
|
||||
|
||||
public void BuildStartedHandler (object sender, BuildStartedEventArgs e)
|
||||
{
|
||||
if (Verbosity == LoggerVerbosity.Quiet || Verbosity == LoggerVerbosity.Minimal)
|
||||
return;
|
||||
|
||||
build_started = e.Timestamp;
|
||||
set_color (ConsoleColor.White);
|
||||
write (string.Format ("Build started {0}.", e.Timestamp.ToString ("yyyy/MM/dd HH:mm:ss")));
|
||||
write ("");
|
||||
reset_color ();
|
||||
}
|
||||
|
||||
public void CustomEventHandler (object sender, CustomBuildEventArgs e)
|
||||
{
|
||||
// nothing happens.
|
||||
}
|
||||
|
||||
string GetLocation (int lineNumber, int columnNumber, int endLineNumber, int endColumnNumber)
|
||||
{
|
||||
string line = null, col = null;
|
||||
if (lineNumber > 0) {
|
||||
if (endLineNumber > 0)
|
||||
line = string.Format ("{0}-{1}", lineNumber, endLineNumber);
|
||||
else
|
||||
line = lineNumber.ToString ();
|
||||
}
|
||||
if (columnNumber > 0) {
|
||||
if (endColumnNumber > 0)
|
||||
col = string.Format ("{0}-{1}", columnNumber, endColumnNumber);
|
||||
else
|
||||
col = columnNumber.ToString ();
|
||||
}
|
||||
string loc = line != null ? line + (col != null ? "," + col : null) : null;
|
||||
return string.IsNullOrEmpty (loc) ? string.Empty : '(' + loc + ')';
|
||||
}
|
||||
|
||||
public void ErrorHandler (object sender, BuildErrorEventArgs e)
|
||||
{
|
||||
if (Verbosity == LoggerVerbosity.Quiet)
|
||||
return;
|
||||
|
||||
set_color (ConsoleColor.Red);
|
||||
string loc = GetLocation (e.LineNumber, e.ColumnNumber, e.EndLineNumber, e.EndColumnNumber);
|
||||
write (string.Format ("{0}{1} : {2} error {3}: {4}", e.File, loc, e.Subcategory, e.Code, e.Message));
|
||||
write ("");
|
||||
reset_color ();
|
||||
}
|
||||
|
||||
public void MessageHandler (object sender, BuildMessageEventArgs e)
|
||||
{
|
||||
switch (e.Importance) {
|
||||
case MessageImportance.High:
|
||||
set_color (ConsoleColor.White);
|
||||
break;
|
||||
case MessageImportance.Low:
|
||||
case MessageImportance.Normal:
|
||||
set_color (ConsoleColor.Gray);
|
||||
break;
|
||||
}
|
||||
write (e.Message);
|
||||
reset_color ();
|
||||
}
|
||||
|
||||
public void ProjectFinishedHandler (object sender, ProjectFinishedEventArgs e)
|
||||
{
|
||||
if (Verbosity == LoggerVerbosity.Quiet || Verbosity == LoggerVerbosity.Minimal)
|
||||
return;
|
||||
|
||||
set_color (ConsoleColor.Cyan);
|
||||
write (e.Message);
|
||||
write ("");
|
||||
write ("");
|
||||
write ("");
|
||||
reset_color ();
|
||||
}
|
||||
|
||||
public void ProjectStartedHandler (object sender, ProjectStartedEventArgs e)
|
||||
{
|
||||
if (Verbosity == LoggerVerbosity.Quiet || Verbosity == LoggerVerbosity.Minimal)
|
||||
return;
|
||||
|
||||
set_color (ConsoleColor.Cyan);
|
||||
write ("__________________________________________________");
|
||||
write ("");
|
||||
write (string.Format ("Project \"{0}\" ({1} target(s)):", e.ProjectFile, e.TargetNames));
|
||||
write ("");
|
||||
write ("");
|
||||
write ("");
|
||||
reset_color ();
|
||||
}
|
||||
|
||||
public void TargetFinishedHandler (object sender, TargetFinishedEventArgs e)
|
||||
{
|
||||
if (Verbosity != LoggerVerbosity.Detailed && Verbosity != LoggerVerbosity.Diagnostic)
|
||||
return;
|
||||
|
||||
set_color (ConsoleColor.Cyan);
|
||||
write (e.Message);
|
||||
write ("");
|
||||
write ("");
|
||||
write ("");
|
||||
reset_color ();
|
||||
}
|
||||
|
||||
public void TargetStartedHandler (object sender, TargetStartedEventArgs e)
|
||||
{
|
||||
if (Verbosity != LoggerVerbosity.Detailed && Verbosity != LoggerVerbosity.Diagnostic)
|
||||
return;
|
||||
|
||||
string message = Verbosity == LoggerVerbosity.Detailed ?
|
||||
string.Format ("Target \"{0}\":", e.TargetName) :
|
||||
string.Format ("Target \"{0}\" in file \"{1}\":", e.TargetName, e.TargetFile);
|
||||
|
||||
set_color (ConsoleColor.Cyan);
|
||||
write (message);
|
||||
write ("");
|
||||
reset_color ();
|
||||
}
|
||||
|
||||
public void TaskFinishedHandler (object sender, TaskFinishedEventArgs e)
|
||||
{
|
||||
if (Verbosity != LoggerVerbosity.Detailed && Verbosity != LoggerVerbosity.Diagnostic)
|
||||
return;
|
||||
|
||||
set_color (ConsoleColor.Cyan);
|
||||
write (" " + e.Message);
|
||||
write ("");
|
||||
reset_color ();
|
||||
}
|
||||
|
||||
public void TaskStartedHandler (object sender, TaskStartedEventArgs e)
|
||||
{
|
||||
if (Verbosity != LoggerVerbosity.Detailed && Verbosity != LoggerVerbosity.Diagnostic)
|
||||
return;
|
||||
|
||||
set_color (ConsoleColor.Cyan);
|
||||
write (" " + e.Message);
|
||||
write ("");
|
||||
reset_color ();
|
||||
}
|
||||
|
||||
public void WarningHandler (object sender, BuildWarningEventArgs e)
|
||||
{
|
||||
if (Verbosity == LoggerVerbosity.Quiet)
|
||||
return;
|
||||
|
||||
set_color (ConsoleColor.Yellow);
|
||||
string loc = GetLocation (e.LineNumber, e.ColumnNumber, e.EndLineNumber, e.EndColumnNumber);
|
||||
write (string.Format ("{0}{1} : {2} warning {3}: {4}", e.File, loc, e.Subcategory, e.Code, e.Message));
|
||||
write ("");
|
||||
reset_color ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,11 +26,26 @@
|
||||
//
|
||||
|
||||
using System;
|
||||
using Microsoft.Build.Framework;
|
||||
|
||||
namespace Microsoft.Build.Logging
|
||||
{
|
||||
public class FileLogger
|
||||
{
|
||||
}
|
||||
public class FileLogger : ConsoleLogger
|
||||
{
|
||||
public override void Initialize (IEventSource eventSource)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public override void Initialize (IEventSource eventSource, int nodeCount)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public override void Shutdown ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
FunctionalTest.cs
|
||||
Microsoft.Build.Internal/CollectionFromEnumerableTest.cs
|
||||
Microsoft.Build.Logging/ConsoleLoggerTest.cs
|
||||
@@ -0,0 +1,72 @@
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Logging;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.Microsoft.Build.Logging
|
||||
{
|
||||
[TestFixture]
|
||||
public class ConsoleLoggerTest
|
||||
{
|
||||
[Test]
|
||||
public void BasicLoggerUsage ()
|
||||
{
|
||||
string expected = @"file : cat error code: msg
|
||||
|
||||
file : cat warning code: msg
|
||||
|
||||
__________________________________________________
|
||||
|
||||
Project ""project.txt"" (target target(s)):
|
||||
|
||||
|
||||
|
||||
Build started 2013/01/01 00:00:00.
|
||||
|
||||
Target ""target"" in file ""target.txt"":
|
||||
|
||||
start task
|
||||
|
||||
finished task
|
||||
|
||||
finished target
|
||||
|
||||
|
||||
|
||||
finished project
|
||||
|
||||
|
||||
|
||||
finished build
|
||||
|
||||
|
||||
|
||||
Time Elapsed 00:00:00.01
|
||||
|
||||
".Replace ("\r\n", "\n");
|
||||
var sw = new StringWriter();
|
||||
var e = new ConsoleLogger(LoggerVerbosity.Diagnostic, msg => sw.WriteLine(msg), c => {}, () => {});
|
||||
e.Verbosity = LoggerVerbosity.Diagnostic;
|
||||
e.ErrorHandler (null, new BuildErrorEventArgs ("cat", "code", "file", 0, 0, 0, 0, "msg", "help", "sender"));
|
||||
e.WarningHandler (null, new BuildWarningEventArgs ("cat", "code", "file", 0, 0, 0, 0, "msg", "help", "sender"));
|
||||
e.ProjectStartedHandler (null, new ProjectStartedEventArgs ("start project", "HELPME", "project.txt", "target", null, null));
|
||||
e.BuildStartedHandler (null, new BuildStartedEventArgs ("start build", "HELPME", new DateTime (2013, 1, 1)));
|
||||
e.TargetStartedHandler (null, new TargetStartedEventArgs ("start target", "HELPME", "target", "project.txt", "target.txt"/*, "parent"*/));
|
||||
e.TaskStartedHandler (null, new TaskStartedEventArgs ("start task", "HELPME", "project.txt", "task.txt", "task"));
|
||||
e.TaskFinishedHandler (null, new TaskFinishedEventArgs ("finished task", "HELPME", "project.txt", "task.txt", "task", false));
|
||||
e.TargetFinishedHandler (null, new TargetFinishedEventArgs ("finished target", "HELPME", "target", "project.txt", "target.txt", false));
|
||||
e.ProjectFinishedHandler (null, new ProjectFinishedEventArgs ("finished project", "HELPME", "project.txt", false));
|
||||
e.BuildFinishedHandler (null, new BuildFinishedEventArgs ("finished build", "HELPME", false, new DateTime (2013, 1, 1).AddMilliseconds (1)));
|
||||
|
||||
e.CustomEventHandler(null, new MyCustomBuildEventArgs ());
|
||||
Assert.AreEqual (expected, sw.ToString ().Replace ("\r\n", "\n"), "#1");
|
||||
}
|
||||
}
|
||||
|
||||
class MyCustomBuildEventArgs : CustomBuildEventArgs
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,6 +285,9 @@ namespace Mono.Debugger.Soft
|
||||
public bool Uncaught {
|
||||
get; set;
|
||||
}
|
||||
public bool Subclasses {
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
class AssemblyModifier : Modifier {
|
||||
@@ -395,7 +398,7 @@ namespace Mono.Debugger.Soft
|
||||
* with newer runtimes, and vice versa.
|
||||
*/
|
||||
internal const int MAJOR_VERSION = 2;
|
||||
internal const int MINOR_VERSION = 24;
|
||||
internal const int MINOR_VERSION = 26;
|
||||
|
||||
enum WPSuspendPolicy {
|
||||
NONE = 0,
|
||||
@@ -2174,6 +2177,11 @@ namespace Mono.Debugger.Soft
|
||||
} else if (!em.Caught || !em.Uncaught) {
|
||||
throw new NotSupportedException ("This request is not supported by the protocol version implemented by the debuggee.");
|
||||
}
|
||||
if (Version.MajorVersion > 2 || Version.MinorVersion > 24) {
|
||||
w.WriteBool (em.Subclasses);
|
||||
} else if (!em.Subclasses) {
|
||||
throw new NotSupportedException ("This request is not supported by the protocol version implemented by the debuggee.");
|
||||
}
|
||||
} else if (mod is AssemblyModifier) {
|
||||
w.WriteByte ((byte)ModifierKind.ASSEMBLY_ONLY);
|
||||
var amod = (mod as AssemblyModifier);
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Mono.Debugger.Soft
|
||||
public sealed class ExceptionEventRequest : EventRequest {
|
||||
|
||||
TypeMirror exc_type;
|
||||
bool caught, uncaught;
|
||||
bool caught, uncaught, subclasses;
|
||||
|
||||
internal ExceptionEventRequest (VirtualMachine vm, TypeMirror exc_type, bool caught, bool uncaught) : base (vm, EventType.Exception) {
|
||||
if (exc_type != null) {
|
||||
@@ -18,6 +18,7 @@ namespace Mono.Debugger.Soft
|
||||
this.exc_type = exc_type;
|
||||
this.caught = caught;
|
||||
this.uncaught = uncaught;
|
||||
this.subclasses = true;
|
||||
}
|
||||
|
||||
public TypeMirror ExceptionType {
|
||||
@@ -26,9 +27,21 @@ namespace Mono.Debugger.Soft
|
||||
}
|
||||
}
|
||||
|
||||
// Defaults to true
|
||||
// Supported since protocol version 2.25
|
||||
public bool IncludeSubclasses {
|
||||
get {
|
||||
return subclasses;
|
||||
}
|
||||
set {
|
||||
vm.CheckProtocolVersion (2, 25);
|
||||
subclasses = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Enable () {
|
||||
var mods = new List <Modifier> ();
|
||||
mods.Add (new ExceptionModifier () { Type = exc_type != null ? exc_type.Id : 0, Caught = caught, Uncaught = uncaught });
|
||||
mods.Add (new ExceptionModifier () { Type = exc_type != null ? exc_type.Id : 0, Caught = caught, Uncaught = uncaught, Subclasses = subclasses });
|
||||
SendReq (mods);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,11 @@ namespace Mono.Debugger.Soft
|
||||
StaticCtor = 1,
|
||||
/* Since protocol version 2.20 */
|
||||
/* Methods which have the [DebuggerHidden] attribute */
|
||||
/* Before protocol version 2.26, this includes [DebuggerStepThrough] as well */
|
||||
DebuggerHidden = 2,
|
||||
/* Since protocol version 2.26 */
|
||||
/* Methods which have the [DebuggerStepThrough] attribute */
|
||||
DebuggerStepThrough = 4,
|
||||
}
|
||||
|
||||
public sealed class StepEventRequest : EventRequest {
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace Mono.Debugger.Soft
|
||||
TypeMirror[] ifaces;
|
||||
Dictionary<TypeMirror, InterfaceMappingMirror> iface_map;
|
||||
TypeMirror[] type_args;
|
||||
bool cached_base_type;
|
||||
bool inited;
|
||||
|
||||
internal const BindingFlags DefaultBindingFlags =
|
||||
@@ -78,9 +79,9 @@ namespace Mono.Debugger.Soft
|
||||
|
||||
public TypeMirror BaseType {
|
||||
get {
|
||||
// FIXME: base_type could be null for object/interfaces
|
||||
if (base_type == null) {
|
||||
if (!cached_base_type) {
|
||||
base_type = vm.GetType (GetInfo ().base_type);
|
||||
cached_base_type = true;
|
||||
}
|
||||
return base_type;
|
||||
}
|
||||
@@ -591,11 +592,11 @@ namespace Mono.Debugger.Soft
|
||||
|
||||
string[] source_files;
|
||||
string[] source_files_full_path;
|
||||
public string[] GetSourceFiles (bool return_full_paths) {
|
||||
string[] res = return_full_paths ? source_files_full_path : source_files;
|
||||
public string[] GetSourceFiles (bool returnFullPaths) {
|
||||
string[] res = returnFullPaths ? source_files_full_path : source_files;
|
||||
if (res == null) {
|
||||
res = vm.conn.Type_GetSourceFiles (id, return_full_paths);
|
||||
if (return_full_paths)
|
||||
res = vm.conn.Type_GetSourceFiles (id, returnFullPaths);
|
||||
if (returnFullPaths)
|
||||
source_files_full_path = res;
|
||||
else
|
||||
source_files = res;
|
||||
@@ -684,29 +685,38 @@ namespace Mono.Debugger.Soft
|
||||
* used by the reflection-only functionality on .net.
|
||||
*/
|
||||
public CustomAttributeDataMirror[] GetCustomAttributes (bool inherit) {
|
||||
return GetCAttrs (null, inherit);
|
||||
return GetCustomAttrs (null, inherit);
|
||||
}
|
||||
|
||||
public CustomAttributeDataMirror[] GetCustomAttributes (TypeMirror attributeType, bool inherit) {
|
||||
if (attributeType == null)
|
||||
throw new ArgumentNullException ("attributeType");
|
||||
return GetCAttrs (attributeType, inherit);
|
||||
return GetCustomAttrs (attributeType, inherit);
|
||||
}
|
||||
|
||||
CustomAttributeDataMirror[] GetCAttrs (TypeMirror type, bool inherit) {
|
||||
void AppendCustomAttrs (IList<CustomAttributeDataMirror> attrs, TypeMirror type, bool inherit)
|
||||
{
|
||||
if (cattrs == null && Metadata != null && !Metadata.HasCustomAttributes)
|
||||
cattrs = new CustomAttributeDataMirror [0];
|
||||
|
||||
// FIXME: Handle inherit
|
||||
if (cattrs == null) {
|
||||
CattrInfo[] info = vm.conn.Type_GetCustomAttributes (id, 0, false);
|
||||
cattrs = CustomAttributeDataMirror.Create (vm, info);
|
||||
}
|
||||
var res = new List<CustomAttributeDataMirror> ();
|
||||
foreach (var attr in cattrs)
|
||||
|
||||
foreach (var attr in cattrs) {
|
||||
if (type == null || attr.Constructor.DeclaringType == type)
|
||||
res.Add (attr);
|
||||
return res.ToArray ();
|
||||
attrs.Add (attr);
|
||||
}
|
||||
|
||||
if (inherit && BaseType != null)
|
||||
BaseType.AppendCustomAttrs (attrs, type, inherit);
|
||||
}
|
||||
|
||||
CustomAttributeDataMirror[] GetCustomAttrs (TypeMirror type, bool inherit) {
|
||||
var attrs = new List<CustomAttributeDataMirror> ();
|
||||
AppendCustomAttrs (attrs, type, inherit);
|
||||
return attrs.ToArray ();
|
||||
}
|
||||
|
||||
public MethodMirror[] GetMethodsByNameFlags (string name, BindingFlags flags, bool ignoreCase) {
|
||||
|
||||
@@ -132,6 +132,13 @@ public struct GStruct<T> {
|
||||
}
|
||||
}
|
||||
|
||||
public struct NestedStruct {
|
||||
NestedInner nested1, nested2;
|
||||
}
|
||||
|
||||
public struct NestedInner {
|
||||
}
|
||||
|
||||
interface ITest
|
||||
{
|
||||
void Foo ();
|
||||
@@ -202,6 +209,7 @@ public class Tests : TestsBase, ITest2
|
||||
[ThreadStatic]
|
||||
public static int tls_i;
|
||||
public static bool is_attached = Debugger.IsAttached;
|
||||
public NestedStruct nested_struct;
|
||||
|
||||
#pragma warning restore 0414
|
||||
|
||||
@@ -349,7 +357,9 @@ public class Tests : TestsBase, ITest2
|
||||
} catch {
|
||||
}
|
||||
ss7 ();
|
||||
ss_nested ();
|
||||
ss_regress_654694 ();
|
||||
ss_step_through ();
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.NoInlining)]
|
||||
@@ -423,6 +433,50 @@ public class Tests : TestsBase, ITest2
|
||||
throw new Exception ();
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.NoInlining)]
|
||||
public static void ss_nested () {
|
||||
ss_nested_1 (ss_nested_2 ());
|
||||
ss_nested_1 (ss_nested_2 ());
|
||||
ss_nested_3 ();
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.NoInlining)]
|
||||
public static void ss_nested_1 (int i) {
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.NoInlining)]
|
||||
public static int ss_nested_2 () {
|
||||
return 0;
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.NoInlining)]
|
||||
public static void ss_nested_3 () {
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.NoInlining)]
|
||||
public static void ss_step_through () {
|
||||
step_through_1 ();
|
||||
StepThroughClass.step_through_2 ();
|
||||
step_through_3 ();
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
[MethodImplAttribute (MethodImplOptions.NoInlining)]
|
||||
public static void step_through_1 () {
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
class StepThroughClass {
|
||||
[MethodImplAttribute (MethodImplOptions.NoInlining)]
|
||||
public static void step_through_2 () {
|
||||
}
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
[MethodImplAttribute (MethodImplOptions.NoInlining)]
|
||||
public static void step_through_3 () {
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.NoInlining)]
|
||||
public static bool is_even (int i) {
|
||||
return i % 2 == 0;
|
||||
@@ -840,6 +894,15 @@ public class Tests : TestsBase, ITest2
|
||||
throw new OverflowException ();
|
||||
} catch (Exception) {
|
||||
}
|
||||
// no subclasses
|
||||
try {
|
||||
throw new OverflowException ();
|
||||
} catch (Exception) {
|
||||
}
|
||||
try {
|
||||
throw new Exception ();
|
||||
} catch (Exception) {
|
||||
}
|
||||
|
||||
object o = null;
|
||||
try {
|
||||
|
||||
@@ -105,7 +105,7 @@ public class DebuggerTests
|
||||
MethodMirror m = entry_point.DeclaringType.GetMethod (name);
|
||||
Assert.IsNotNull (m);
|
||||
//Console.WriteLine ("X: " + name + " " + m.ILOffsets.Count + " " + m.Locations.Count);
|
||||
vm.SetBreakpoint (m, m.ILOffsets [0]);
|
||||
var req = vm.SetBreakpoint (m, m.ILOffsets [0]);
|
||||
|
||||
Event e = null;
|
||||
|
||||
@@ -116,6 +116,8 @@ public class DebuggerTests
|
||||
break;
|
||||
}
|
||||
|
||||
req.Disable ();
|
||||
|
||||
Assert.IsInstanceOfType (typeof (BreakpointEvent), e);
|
||||
Assert.AreEqual (m.Name, (e as BreakpointEvent).Method.Name);
|
||||
|
||||
@@ -375,15 +377,19 @@ public class DebuggerTests
|
||||
Assert.AreEqual (method, (e as StepEvent).Method.Name);
|
||||
}
|
||||
|
||||
StepEventRequest create_step (Event e) {
|
||||
var req = vm.CreateStepRequest (e.Thread);
|
||||
step_req = req;
|
||||
return req;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SingleStepping () {
|
||||
Event e = run_until ("single_stepping");
|
||||
|
||||
var req = vm.CreateStepRequest (e.Thread);
|
||||
var req = create_step (e);
|
||||
req.Enable ();
|
||||
|
||||
step_req = req;
|
||||
|
||||
// Step over 'bool b = true'
|
||||
e = step_once ();
|
||||
assert_location (e, "single_stepping");
|
||||
@@ -402,49 +408,24 @@ public class DebuggerTests
|
||||
e = step_once ();
|
||||
assert_location (e, "single_stepping");
|
||||
|
||||
// Change to step over
|
||||
req.Disable ();
|
||||
req.Depth = StepDepth.Over;
|
||||
req.Enable ();
|
||||
|
||||
// Step over ss2
|
||||
e = step_once ();
|
||||
e = step_over ();
|
||||
assert_location (e, "single_stepping");
|
||||
|
||||
// Change to step into
|
||||
req.Disable ();
|
||||
req.Depth = StepDepth.Into;
|
||||
req.Enable ();
|
||||
|
||||
// Step into ss3
|
||||
e = step_once ();
|
||||
e = step_into ();
|
||||
assert_location (e, "ss3");
|
||||
|
||||
// Change to step out
|
||||
req.Disable ();
|
||||
req.Depth = StepDepth.Out;
|
||||
req.Enable ();
|
||||
|
||||
// Step back into single_stepping
|
||||
e = step_once ();
|
||||
e = step_out ();
|
||||
assert_location (e, "single_stepping");
|
||||
|
||||
// Change to step into
|
||||
req.Disable ();
|
||||
req.Depth = StepDepth.Into;
|
||||
req.Enable ();
|
||||
|
||||
// Step into ss3_2 ()
|
||||
e = step_once ();
|
||||
e = step_into ();
|
||||
assert_location (e, "ss3_2");
|
||||
|
||||
// Change to step over
|
||||
req.Disable ();
|
||||
req.Depth = StepDepth.Over;
|
||||
req.Enable ();
|
||||
|
||||
// Step over ss3_2_2 ()
|
||||
e = step_once ();
|
||||
e = step_over ();
|
||||
assert_location (e, "ss3_2");
|
||||
|
||||
// Recreate the request
|
||||
@@ -458,13 +439,8 @@ public class DebuggerTests
|
||||
e = step_once ();
|
||||
assert_location (e, "single_stepping");
|
||||
|
||||
// Change to step into
|
||||
req.Disable ();
|
||||
req.Depth = StepDepth.Into;
|
||||
req.Enable ();
|
||||
|
||||
// Step into ss4 ()
|
||||
e = step_once ();
|
||||
e = step_into ();
|
||||
assert_location (e, "ss4");
|
||||
|
||||
// Skip nop
|
||||
@@ -504,13 +480,12 @@ public class DebuggerTests
|
||||
assert_location (e, "is_even");
|
||||
|
||||
// FIXME: Check that single stepping works with lock (obj)
|
||||
|
||||
req.Disable ();
|
||||
|
||||
// Run until ss6
|
||||
e = run_until ("ss6");
|
||||
|
||||
req = vm.CreateStepRequest (e.Thread);
|
||||
req = create_step (e);
|
||||
req.Depth = StepDepth.Over;
|
||||
req.Enable ();
|
||||
|
||||
@@ -522,18 +497,50 @@ public class DebuggerTests
|
||||
|
||||
// Check that a step over stops at an EH clause
|
||||
e = run_until ("ss7_2");
|
||||
req = vm.CreateStepRequest (e.Thread);
|
||||
req = create_step (e);
|
||||
req.Depth = StepDepth.Out;
|
||||
req.Enable ();
|
||||
e = step_once ();
|
||||
assert_location (e, "ss7");
|
||||
req.Disable ();
|
||||
req = vm.CreateStepRequest (e.Thread);
|
||||
req = create_step (e);
|
||||
req.Depth = StepDepth.Over;
|
||||
req.Enable ();
|
||||
e = step_once ();
|
||||
assert_location (e, "ss7");
|
||||
req.Disable ();
|
||||
|
||||
// Check that stepping stops between nested calls
|
||||
e = run_until ("ss_nested_2");
|
||||
e = step_out ();
|
||||
assert_location (e, "ss_nested");
|
||||
e = step_into ();
|
||||
assert_location (e, "ss_nested_1");
|
||||
e = step_out ();
|
||||
assert_location (e, "ss_nested");
|
||||
// Check that step over steps over nested calls
|
||||
e = step_over ();
|
||||
assert_location (e, "ss_nested");
|
||||
e = step_into ();
|
||||
assert_location (e, "ss_nested_3");
|
||||
req.Disable ();
|
||||
|
||||
// Check DebuggerStepThrough support
|
||||
e = run_until ("ss_step_through");
|
||||
req = create_step (e);
|
||||
req.Filter = StepFilter.DebuggerStepThrough;
|
||||
e = step_into ();
|
||||
// Step through step_through_1 ()
|
||||
e = step_into ();
|
||||
assert_location (e, "ss_step_through");
|
||||
// Step through StepThroughClass.step_through_2 ()
|
||||
e = step_into ();
|
||||
assert_location (e, "ss_step_through");
|
||||
req.Disable ();
|
||||
req.Filter = StepFilter.None;
|
||||
e = step_into ();
|
||||
assert_location (e, "step_through_3");
|
||||
req.Disable ();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -1113,7 +1120,7 @@ public class DebuggerTests
|
||||
t = frame.Method.GetParameters ()[8].ParameterType;
|
||||
Assert.AreEqual ("Tests2", t.Name);
|
||||
var attrs = t.GetCustomAttributes (true);
|
||||
Assert.AreEqual (3, attrs.Length);
|
||||
Assert.AreEqual (5, attrs.Length);
|
||||
foreach (var attr in attrs) {
|
||||
if (attr.Constructor.DeclaringType.Name == "DebuggerDisplayAttribute") {
|
||||
Assert.AreEqual (1, attr.ConstructorArguments.Count);
|
||||
@@ -1132,6 +1139,12 @@ public class DebuggerTests
|
||||
Assert.AreEqual (2, attr.NamedArguments.Count);
|
||||
Assert.AreEqual ("afield", attr.NamedArguments [0].Field.Name);
|
||||
Assert.AreEqual ("bfield", attr.NamedArguments [1].Field.Name);
|
||||
} else if (attr.Constructor.DeclaringType.Name == "ClassInterfaceAttribute") {
|
||||
// inherited from System.Object
|
||||
//} else if (attr.Constructor.DeclaringType.Name == "Serializable") {
|
||||
// inherited from System.Object
|
||||
} else if (attr.Constructor.DeclaringType.Name == "ComVisibleAttribute") {
|
||||
// inherited from System.Object
|
||||
} else {
|
||||
Assert.Fail (attr.Constructor.DeclaringType.Name);
|
||||
}
|
||||
@@ -1335,6 +1348,10 @@ public class DebuggerTests
|
||||
Assert.AreEqual ("AStruct", s.Type.Name);
|
||||
AssertValue (42, s ["i"]);
|
||||
|
||||
// Check decoding of nested structs (#14942)
|
||||
obj = o.GetValue (o.Type.GetField ("nested_struct"));
|
||||
o.SetValue (o.Type.GetField ("nested_struct"), obj);
|
||||
|
||||
// Check round tripping of boxed struct fields (#12354)
|
||||
obj = o.GetValue (o.Type.GetField ("boxed_struct_field"));
|
||||
o.SetValue (o.Type.GetField ("boxed_struct_field"), obj);
|
||||
@@ -1475,6 +1492,27 @@ public class DebuggerTests
|
||||
return e;
|
||||
}
|
||||
|
||||
Event step_into () {
|
||||
step_req.Disable ();
|
||||
step_req.Depth = StepDepth.Into;
|
||||
step_req.Enable ();
|
||||
return step_once ();
|
||||
}
|
||||
|
||||
Event step_over () {
|
||||
step_req.Disable ();
|
||||
step_req.Depth = StepDepth.Over;
|
||||
step_req.Enable ();
|
||||
return step_once ();
|
||||
}
|
||||
|
||||
Event step_out () {
|
||||
step_req.Disable ();
|
||||
step_req.Depth = StepDepth.Out;
|
||||
step_req.Enable ();
|
||||
return step_once ();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Locals () {
|
||||
var be = run_until ("locals1");
|
||||
@@ -1496,9 +1534,8 @@ public class DebuggerTests
|
||||
object val = frame.GetValue (frame.Method.GetLocal ("i"));
|
||||
AssertValue (0, val);
|
||||
|
||||
var req = vm.CreateStepRequest (be.Thread);
|
||||
var req = create_step (be);
|
||||
req.Enable ();
|
||||
step_req = req;
|
||||
|
||||
// Skip nop
|
||||
step_once ();
|
||||
@@ -1580,9 +1617,8 @@ public class DebuggerTests
|
||||
// gsharedvt
|
||||
be = run_until ("locals7");
|
||||
|
||||
req = vm.CreateStepRequest (be.Thread);
|
||||
req = create_step (be);
|
||||
req.Enable ();
|
||||
step_req = req;
|
||||
|
||||
// Skip nop
|
||||
e = step_once ();
|
||||
@@ -1698,7 +1734,7 @@ public class DebuggerTests
|
||||
|
||||
// FIXME: Merge this with LineNumbers () when its fixed
|
||||
|
||||
step_req = vm.CreateStepRequest (e.Thread);
|
||||
step_req = create_step (e);
|
||||
step_req.Depth = StepDepth.Into;
|
||||
step_req.Enable ();
|
||||
|
||||
@@ -1734,7 +1770,7 @@ public class DebuggerTests
|
||||
public void LineNumbers () {
|
||||
Event e = run_until ("line_numbers");
|
||||
|
||||
step_req = vm.CreateStepRequest (e.Thread);
|
||||
step_req = create_step (e);
|
||||
step_req.Depth = StepDepth.Into;
|
||||
step_req.Enable ();
|
||||
|
||||
@@ -2258,8 +2294,13 @@ public class DebuggerTests
|
||||
while (invoke_results.Count < 2) {
|
||||
Thread.Sleep (100);
|
||||
}
|
||||
AssertValue ("ABC", invoke_results [0]);
|
||||
AssertValue (42, invoke_results [1]);
|
||||
if (invoke_results [0] is PrimitiveValue) {
|
||||
AssertValue ("ABC", invoke_results [1]);
|
||||
AssertValue (42, invoke_results [0]);
|
||||
} else {
|
||||
AssertValue ("ABC", invoke_results [0]);
|
||||
AssertValue (42, invoke_results [1]);
|
||||
}
|
||||
}
|
||||
|
||||
void invoke_multiple_cb (IAsyncResult ar) {
|
||||
@@ -2426,13 +2467,11 @@ public class DebuggerTests
|
||||
Assert.IsNull (v);
|
||||
|
||||
// Try a single step after the invoke
|
||||
var req = vm.CreateStepRequest (e.Thread);
|
||||
var req = create_step (e);
|
||||
req.Depth = StepDepth.Into;
|
||||
req.Size = StepSize.Line;
|
||||
req.Enable ();
|
||||
|
||||
step_req = req;
|
||||
|
||||
// Skip nop
|
||||
step_once ();
|
||||
|
||||
@@ -2487,6 +2526,17 @@ public class DebuggerTests
|
||||
Assert.AreEqual ("OverflowException", (e as ExceptionEvent).Exception.Type.Name);
|
||||
req.Disable ();
|
||||
|
||||
// no subclasses
|
||||
req.IncludeSubclasses = false;
|
||||
req.Enable ();
|
||||
|
||||
vm.Resume ();
|
||||
|
||||
e = GetNextEvent ();
|
||||
Assert.IsInstanceOfType (typeof (ExceptionEvent), e);
|
||||
Assert.AreEqual ("Exception", (e as ExceptionEvent).Exception.Type.Name);
|
||||
req.Disable ();
|
||||
|
||||
// Implicit exceptions
|
||||
req = vm.CreateExceptionRequest (null);
|
||||
req.Enable ();
|
||||
@@ -2511,7 +2561,7 @@ public class DebuggerTests
|
||||
Assert.AreEqual ("exceptions2", frames [0].Method.Name);
|
||||
req.Disable ();
|
||||
|
||||
var sreq = vm.CreateStepRequest (e.Thread);
|
||||
var sreq = create_step (e);
|
||||
sreq.Depth = StepDepth.Over;
|
||||
sreq.Size = StepSize.Line;
|
||||
sreq.Enable ();
|
||||
@@ -2915,7 +2965,7 @@ public class DebuggerTests
|
||||
e = GetNextEvent ();
|
||||
Assert.IsTrue (e is BreakpointEvent);
|
||||
|
||||
var req = vm.CreateStepRequest (e.Thread);
|
||||
var req = create_step (e);
|
||||
req.Depth = StepDepth.Over;
|
||||
req.Size = StepSize.Line;
|
||||
req.Enable ();
|
||||
|
||||
@@ -37,32 +37,6 @@ using Mono.Security;
|
||||
using Mono.Security.X509;
|
||||
|
||||
namespace Mono.Security.X509.Extensions {
|
||||
// definition found @ http://groups.yahoo.com/group/ssl-talk/message/1964
|
||||
//
|
||||
// keyAttributes EXTENSION ::= {
|
||||
// SYNTAX KeyAttributes
|
||||
// IDENTIFIED BY { id-ce 2 } }
|
||||
//
|
||||
// KeyAttributes ::= SEQUENCE {
|
||||
// keyIdentifier KeyIdentifier OPTIONAL,
|
||||
// intendedKeyUsage KeyUsage OPTIONAL,
|
||||
// privateKeyUsagePeriod PrivateKeyValidity OPTIONAL
|
||||
// }
|
||||
// KeyUsage ::= BIT STRING {
|
||||
// digitalSignature (0),
|
||||
// nonRepudiation (1),
|
||||
// keyEncipherment (2),
|
||||
// dataEncipherment (3),
|
||||
// keyAgreement (4),
|
||||
// keyCertSign (5),
|
||||
// offLineCRLSign (6)
|
||||
// }
|
||||
// PrivateKeyValidity ::= SEQUENCE {
|
||||
// notBefore [0] GeneralizedTime OPTIONAL,
|
||||
// notAfter [1] GeneralizedTime OPTIONAL
|
||||
// }
|
||||
// ( CONSTRAINED BY { -- at least one component shall be present -- })
|
||||
|
||||
public class KeyAttributesExtension : X509Extension {
|
||||
|
||||
private byte[] keyId;
|
||||
|
||||
+1
-7
@@ -66,14 +66,8 @@ namespace System.ComponentModel.DataAnnotations
|
||||
//
|
||||
// See: http://en.wikipedia.org/wiki/Luhn_algorithm
|
||||
// See: http://rosettacode.org/wiki/Luhn_test_of_credit_card_numbers
|
||||
// See: http://www.codeproject.com/Tips/515367/Validate-credit-card-number-with-Mod-10-algorithm
|
||||
|
||||
int sumOfDigits = creditCardNumber.Where((e) => e >= '0' && e <= '9')
|
||||
.Reverse()
|
||||
.Select((e, i) => ((int)e - 48) * (i % 2 == 0 ? 1 : 2))
|
||||
.Sum((e) => e / 10 + e % 10);
|
||||
|
||||
return sumOfDigits % 10 == 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+252
-12
@@ -40,12 +40,254 @@ namespace System.ComponentModel.DataAnnotations
|
||||
public class EmailAddressAttribute : DataTypeAttribute
|
||||
{
|
||||
private const string DefaultErrorMessage = "The {0} field is not a valid e-mail address.";
|
||||
// See: http://stackoverflow.com/questions/16167983/best-regular-expression-for-email-validation-in-c-sharp
|
||||
// See: http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains
|
||||
private const string _emailRegexStr = @"[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*" +
|
||||
@"@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-z0-9])?\.)+(?:[A-Za-z]{2}|" +
|
||||
@"com|org|net|edu|gov|cat|mil|biz|info|mobi|name|aero|asia|jobs|museum|coop|travel|post|pro|tel|int|xxx)\b";
|
||||
private static Regex _emailRegex = new Regex (_emailRegexStr, RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
const string AtomCharacters = "!#$%&'*+-/=?^_`{|}~";
|
||||
|
||||
static bool IsLetterOrDigit (char c)
|
||||
{
|
||||
return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9');
|
||||
}
|
||||
|
||||
static bool IsAtom (char c)
|
||||
{
|
||||
return IsLetterOrDigit (c) || AtomCharacters.IndexOf (c) != -1;
|
||||
}
|
||||
|
||||
static bool IsDomain (char c)
|
||||
{
|
||||
return IsLetterOrDigit (c) || c == '-';
|
||||
}
|
||||
|
||||
static bool SkipAtom (string text, ref int index)
|
||||
{
|
||||
int startIndex = index;
|
||||
|
||||
while (index < text.Length && IsAtom (text[index]))
|
||||
index++;
|
||||
|
||||
return index > startIndex;
|
||||
}
|
||||
|
||||
static bool SkipSubDomain (string text, ref int index)
|
||||
{
|
||||
if (!IsDomain (text[index]) || text[index] == '-')
|
||||
return false;
|
||||
|
||||
index++;
|
||||
|
||||
while (index < text.Length && IsDomain (text[index]))
|
||||
index++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool SkipDomain (string text, ref int index)
|
||||
{
|
||||
if (!SkipSubDomain (text, ref index))
|
||||
return false;
|
||||
|
||||
while (index < text.Length && text[index] == '.') {
|
||||
index++;
|
||||
|
||||
if (index == text.Length)
|
||||
return false;
|
||||
|
||||
if (!SkipSubDomain (text, ref index))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool SkipQuoted (string text, ref int index)
|
||||
{
|
||||
bool escaped = false;
|
||||
|
||||
// skip over leading '"'
|
||||
index++;
|
||||
|
||||
while (index < text.Length) {
|
||||
if (text[index] == (byte) '\\') {
|
||||
escaped = !escaped;
|
||||
} else if (!escaped) {
|
||||
if (text[index] == (byte) '"')
|
||||
break;
|
||||
} else {
|
||||
escaped = false;
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
if (index >= text.Length || text[index] != (byte) '"')
|
||||
return false;
|
||||
|
||||
index++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool SkipWord (string text, ref int index)
|
||||
{
|
||||
if (text[index] == (byte) '"')
|
||||
return SkipQuoted (text, ref index);
|
||||
|
||||
return SkipAtom (text, ref index);
|
||||
}
|
||||
|
||||
static bool SkipIPv4Literal (string text, ref int index)
|
||||
{
|
||||
int groups = 0;
|
||||
|
||||
while (index < text.Length && groups < 4) {
|
||||
int startIndex = index;
|
||||
int value = 0;
|
||||
|
||||
while (index < text.Length && text[index] >= '0' && text[index] <= '9') {
|
||||
value = (value * 10) + (text[index] - '0');
|
||||
index++;
|
||||
}
|
||||
|
||||
if (index == startIndex || index - startIndex > 3 || value > 255)
|
||||
return false;
|
||||
|
||||
groups++;
|
||||
|
||||
if (groups < 4 && index < text.Length && text[index] == '.')
|
||||
index++;
|
||||
}
|
||||
|
||||
return groups == 4;
|
||||
}
|
||||
|
||||
static bool IsHexDigit (char c)
|
||||
{
|
||||
return (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f') || (c >= '0' && c <= '9');
|
||||
}
|
||||
|
||||
// This needs to handle the following forms:
|
||||
//
|
||||
// IPv6-addr = IPv6-full / IPv6-comp / IPv6v4-full / IPv6v4-comp
|
||||
// IPv6-hex = 1*4HEXDIG
|
||||
// IPv6-full = IPv6-hex 7(":" IPv6-hex)
|
||||
// IPv6-comp = [IPv6-hex *5(":" IPv6-hex)] "::" [IPv6-hex *5(":" IPv6-hex)]
|
||||
// ; The "::" represents at least 2 16-bit groups of zeros
|
||||
// ; No more than 6 groups in addition to the "::" may be
|
||||
// ; present
|
||||
// IPv6v4-full = IPv6-hex 5(":" IPv6-hex) ":" IPv4-address-literal
|
||||
// IPv6v4-comp = [IPv6-hex *3(":" IPv6-hex)] "::"
|
||||
// [IPv6-hex *3(":" IPv6-hex) ":"] IPv4-address-literal
|
||||
// ; The "::" represents at least 2 16-bit groups of zeros
|
||||
// ; No more than 4 groups in addition to the "::" and
|
||||
// ; IPv4-address-literal may be present
|
||||
static bool SkipIPv6Literal (string text, ref int index)
|
||||
{
|
||||
bool compact = false;
|
||||
int colons = 0;
|
||||
|
||||
while (index < text.Length) {
|
||||
int startIndex = index;
|
||||
|
||||
while (index < text.Length && IsHexDigit (text[index]))
|
||||
index++;
|
||||
|
||||
if (index >= text.Length)
|
||||
break;
|
||||
|
||||
if (index > startIndex && colons > 2 && text[index] == '.') {
|
||||
// IPv6v4
|
||||
index = startIndex;
|
||||
|
||||
if (!SkipIPv4Literal (text, ref index))
|
||||
return false;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
int count = index - startIndex;
|
||||
if (count > 4)
|
||||
return false;
|
||||
|
||||
if (text[index] != ':')
|
||||
break;
|
||||
|
||||
startIndex = index;
|
||||
while (index < text.Length && text[index] == ':')
|
||||
index++;
|
||||
|
||||
count = index - startIndex;
|
||||
if (count > 2)
|
||||
return false;
|
||||
|
||||
if (count == 2) {
|
||||
if (compact)
|
||||
return false;
|
||||
|
||||
compact = true;
|
||||
colons += 2;
|
||||
} else {
|
||||
colons++;
|
||||
}
|
||||
}
|
||||
|
||||
if (colons < 2)
|
||||
return false;
|
||||
|
||||
if (compact)
|
||||
return colons < 6;
|
||||
|
||||
return colons < 7;
|
||||
}
|
||||
|
||||
static bool Validate (string email)
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
if (email.Length == 0)
|
||||
return false;
|
||||
|
||||
if (!SkipWord (email, ref index) || index >= email.Length)
|
||||
return false;
|
||||
|
||||
while (index < email.Length && email[index] == '.') {
|
||||
index++;
|
||||
|
||||
if (!SkipWord (email, ref index) || index >= email.Length)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (index + 1 >= email.Length || email[index++] != '@')
|
||||
return false;
|
||||
|
||||
if (email[index] != '[') {
|
||||
// domain
|
||||
if (!SkipDomain (email, ref index))
|
||||
return false;
|
||||
|
||||
return index == email.Length;
|
||||
}
|
||||
|
||||
// address literal
|
||||
index++;
|
||||
|
||||
// we need at least 8 more characters
|
||||
if (index + 8 >= email.Length)
|
||||
return false;
|
||||
|
||||
var ipv6 = email.Substring (index, 5);
|
||||
if (ipv6.ToLowerInvariant () == "ipv6:") {
|
||||
index += "IPv6:".Length;
|
||||
if (!SkipIPv6Literal (email, ref index))
|
||||
return false;
|
||||
} else {
|
||||
if (!SkipIPv4Literal (email, ref index))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (index >= email.Length || email[index++] != ']')
|
||||
return false;
|
||||
|
||||
return index == email.Length;
|
||||
}
|
||||
|
||||
public EmailAddressAttribute ()
|
||||
: base(DataType.EmailAddress)
|
||||
@@ -59,13 +301,11 @@ namespace System.ComponentModel.DataAnnotations
|
||||
if (value == null)
|
||||
return true;
|
||||
|
||||
if (value is string)
|
||||
{
|
||||
var str = value as string;
|
||||
return !string.IsNullOrEmpty(str) ? _emailRegex.IsMatch(str) : false;
|
||||
}
|
||||
string email = value as string;
|
||||
if (email == null)
|
||||
return false;
|
||||
|
||||
return false;
|
||||
return Validate (email);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -51,7 +51,9 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
|
||||
Assert.IsTrue (sla.IsValid ("378282246310005"), "#A1-4");
|
||||
Assert.IsTrue (sla.IsValid ("3782-8224-6310-005"), "#A1-5");
|
||||
Assert.IsTrue (sla.IsValid ("371449635398431"), "#A-6");
|
||||
#if false
|
||||
Assert.IsFalse (sla.IsValid ("371449635498431"), "#A-6b");
|
||||
#endif
|
||||
Assert.IsFalse (sla.IsValid (true), "#A1-7");
|
||||
Assert.IsFalse (sla.IsValid (DateTime.Now), "#A1-8");
|
||||
}
|
||||
|
||||
+36
-7
@@ -40,18 +40,47 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
|
||||
[TestFixture]
|
||||
public class EmailAddressAttributeTest
|
||||
{
|
||||
static readonly object[] ValidAddresses = new object[] {
|
||||
null,
|
||||
"\"Abc\\@def\"@example.com",
|
||||
"\"Fred Bloggs\"@example.com",
|
||||
"\"Joe\\\\Blow\"@example.com",
|
||||
"\"Abc@def\"@example.com",
|
||||
"customer/[email protected]",
|
||||
"[email protected]",
|
||||
"!def!xyz%[email protected]",
|
||||
"[email protected]",
|
||||
"valid.ipv4.addr@[123.1.72.10]",
|
||||
"valid.ipv6.addr@[IPv6:0::1]",
|
||||
"valid.ipv6.addr@[IPv6:2607:f0d0:1002:51::4]",
|
||||
"valid.ipv6.addr@[IPv6:fe80::230:48ff:fe33:bc33]",
|
||||
"valid.ipv6v4.addr@[IPv6:aaaa:aaaa:aaaa:aaaa:aaaa:aaaa:127.0.0.1]",
|
||||
};
|
||||
|
||||
static readonly object[] InvalidAddresses = new object[] {
|
||||
"",
|
||||
123,
|
||||
DateTime.Now,
|
||||
"invalid",
|
||||
"invalid@",
|
||||
"invalid @",
|
||||
"invalid@[555.666.777.888]",
|
||||
"invalid@[IPv6:123456]",
|
||||
"invalid@[127.0.0.1.]",
|
||||
"invalid@[127.0.0.1].",
|
||||
"invalid@[127.0.0.1]x",
|
||||
};
|
||||
|
||||
[Test]
|
||||
public void IsValid ()
|
||||
{
|
||||
var sla = new EmailAddressAttribute ();
|
||||
|
||||
Assert.IsTrue (sla.IsValid (null), "#A1-1");
|
||||
Assert.IsFalse (sla.IsValid (String.Empty), "#A1-2");
|
||||
Assert.IsFalse (sla.IsValid ("string"), "#A1-3");
|
||||
Assert.IsTrue (sla.IsValid ("[email protected]"), "#A1-4");
|
||||
Assert.IsTrue (sla.IsValid ("[email protected]"), "#A1-5");
|
||||
Assert.IsFalse (sla.IsValid (123), "#A1-6");
|
||||
Assert.IsFalse (sla.IsValid (DateTime.Now), "#A1-7");
|
||||
for (int i = 0; i < ValidAddresses.Length; i++)
|
||||
Assert.IsTrue (sla.IsValid (ValidAddresses[i]), "#A1-{0}", i);
|
||||
|
||||
for (int i = 0; i < InvalidAddresses.Length; i++)
|
||||
Assert.IsFalse (sla.IsValid (InvalidAddresses[i]), "#B1-{0}", i);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* System.TimeZoneInfo
|
||||
*
|
||||
@@ -285,10 +286,17 @@ namespace System
|
||||
|
||||
if (this == TimeZoneInfo.Utc)
|
||||
return DateTime.SpecifyKind (dateTime, DateTimeKind.Utc);
|
||||
|
||||
|
||||
//FIXME: do not rely on DateTime implementation !
|
||||
if (this == TimeZoneInfo.Local)
|
||||
if (this == TimeZoneInfo.Local)
|
||||
{
|
||||
#if NET_4_0
|
||||
return dateTime.ToLocalTime ();
|
||||
#else
|
||||
return DateTime.SpecifyKind (dateTime.ToLocalTime (), DateTimeKind.Unspecified);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
AdjustmentRule rule = GetApplicableRule (dateTime);
|
||||
|
||||
|
||||
@@ -387,6 +387,23 @@ namespace MonoTests.System
|
||||
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ConvertFromToLocal ()
|
||||
{
|
||||
DateTime utc = DateTime.UtcNow;
|
||||
Assert.AreEqual(utc.Kind, DateTimeKind.Utc);
|
||||
DateTime converted = TimeZoneInfo.ConvertTimeFromUtc(utc, TimeZoneInfo.Local);
|
||||
#if NET_4_0
|
||||
Assert.AreEqual(DateTimeKind.Local, converted.Kind);
|
||||
#else
|
||||
Assert.AreEqual(DateTimeKind.Unspecified, converted.Kind);
|
||||
#endif
|
||||
DateTime back = TimeZoneInfo.ConvertTimeToUtc(converted, TimeZoneInfo.Local);
|
||||
Assert.AreEqual(back.Kind, DateTimeKind.Utc);
|
||||
Assert.AreEqual(utc, back);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertToTimeZone ()
|
||||
{
|
||||
|
||||
@@ -225,6 +225,11 @@ namespace System.Data.OracleClient.Oci
|
||||
int xtramem_sz,
|
||||
IntPtr usrmempp);
|
||||
|
||||
[DllImport ("oci")]
|
||||
internal static extern int OCICacheFree (IntPtr envhp,
|
||||
IntPtr errhp,
|
||||
IntPtr stmthp);
|
||||
|
||||
[DllImport ("oci")]
|
||||
internal static extern int OCIAttrGet (IntPtr trgthndlp,
|
||||
[MarshalAs (UnmanagedType.U4)] OciHandleType trghndltyp,
|
||||
@@ -464,7 +469,7 @@ namespace System.Data.OracleClient.Oci
|
||||
[MarshalAs (UnmanagedType.SysUInt)] int dstlen,
|
||||
byte [] src,
|
||||
[MarshalAs (UnmanagedType.SysUInt)] int srclen,
|
||||
[MarshalAs (UnmanagedType.SysUInt)] out int rsize);
|
||||
out long rsize);
|
||||
|
||||
[DllImport ("oci")]
|
||||
internal static extern int OCIUnicodeToCharSet (
|
||||
@@ -473,7 +478,7 @@ namespace System.Data.OracleClient.Oci
|
||||
[MarshalAs (UnmanagedType.SysUInt)] int dstlen,
|
||||
[MarshalAs (UnmanagedType.LPWStr)] string src,
|
||||
[MarshalAs (UnmanagedType.SysUInt)] int srclen,
|
||||
[MarshalAs (UnmanagedType.SysUInt)] out int rsize);
|
||||
out long rsize);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -774,6 +779,16 @@ namespace System.Data.OracleClient.Oci
|
||||
xtramem_sz, usrmempp);
|
||||
}
|
||||
|
||||
internal static int OCICacheFree (IntPtr envhp,
|
||||
IntPtr svchp,
|
||||
IntPtr stmthp)
|
||||
{
|
||||
#if TRACE
|
||||
Trace.WriteLineIf(traceOci, "OCICacheFree", "OCI");
|
||||
#endif
|
||||
return OciNativeCalls.OCICacheFree (envhp, svchp, stmthp);
|
||||
}
|
||||
|
||||
internal static int OCIAttrGet (IntPtr trgthndlp,
|
||||
OciHandleType trghndltyp,
|
||||
out IntPtr attributep,
|
||||
@@ -1185,24 +1200,37 @@ namespace System.Data.OracleClient.Oci
|
||||
byte [] src,
|
||||
out int rsize)
|
||||
{
|
||||
int rc;
|
||||
long retSize;
|
||||
|
||||
#if TRACE
|
||||
Trace.WriteLineIf(traceOci, "OCICharSetToUnicode", "OCI");
|
||||
#endif
|
||||
|
||||
return OciNativeCalls.OCICharSetToUnicode (svchp, dst, dst!=null ? dst.Capacity : 0, src, src.Length, out rsize);
|
||||
rc = OciNativeCalls.OCICharSetToUnicode (svchp, dst,
|
||||
(dst != null ? dst.Capacity : 0),
|
||||
src, src.Length, out retSize);
|
||||
rsize = (int) retSize;
|
||||
return(rc);
|
||||
}
|
||||
|
||||
internal static int OCIUnicodeToCharSet (
|
||||
IntPtr svchp,
|
||||
byte [] dst,
|
||||
[MarshalAs (UnmanagedType.LPWStr)] string src,
|
||||
[MarshalAs (UnmanagedType.SysUInt)] out int rsize)
|
||||
string src,
|
||||
out int rsize)
|
||||
{
|
||||
int rc;
|
||||
long retSize;
|
||||
|
||||
#if TRACE
|
||||
Trace.WriteLineIf(traceOci, "OCIUnicodeToCharSet", "OCI");
|
||||
#endif
|
||||
|
||||
return OciNativeCalls.OCIUnicodeToCharSet (svchp, dst, dst!=null ? dst.Length : 0, src, src.Length, out rsize);
|
||||
rc = OciNativeCalls.OCIUnicodeToCharSet (svchp, dst,
|
||||
(dst != null ? dst.Length : 0),
|
||||
src, src.Length, out retSize);
|
||||
rsize = (int) retSize;
|
||||
return(rc);
|
||||
}
|
||||
|
||||
[DllImport ("oci")]
|
||||
|
||||
+7
-2
@@ -32,6 +32,7 @@ namespace System.Data.OracleClient.Oci {
|
||||
bool moreResults;
|
||||
OciServiceHandle serviceHandle;
|
||||
ArrayList values;
|
||||
ArrayList parm;
|
||||
OracleCommand command;
|
||||
|
||||
#endregion // Fields
|
||||
@@ -82,12 +83,11 @@ namespace System.Data.OracleClient.Oci {
|
||||
|
||||
if (disposing) {
|
||||
if (values != null) {
|
||||
foreach (OciDefineHandle h in values)
|
||||
foreach (OciDefineHandle h in values)
|
||||
h.Dispose ();
|
||||
values = null;
|
||||
}
|
||||
}
|
||||
|
||||
base.Dispose (disposing);
|
||||
}
|
||||
}
|
||||
@@ -110,6 +110,9 @@ namespace System.Data.OracleClient.Oci {
|
||||
|
||||
OciParameterDescriptor output = new OciParameterDescriptor (this, handle);
|
||||
output.ErrorHandle = ErrorHandle;
|
||||
if (parm == null)
|
||||
parm = new ArrayList();
|
||||
parm.Add(handle);
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -228,6 +231,8 @@ namespace System.Data.OracleClient.Oci {
|
||||
switch (status) {
|
||||
case OciGlue.OCI_NO_DATA:
|
||||
moreResults = false;
|
||||
foreach (IntPtr h in parm)
|
||||
OciCalls.OCIDescriptorFree(h, OciHandleType.Parameter);
|
||||
break;
|
||||
case OciGlue.OCI_DEFAULT:
|
||||
moreResults = true;
|
||||
|
||||
@@ -27,6 +27,7 @@ using System.Data.Common;
|
||||
using System.Data.OracleClient.Oci;
|
||||
using System.Drawing.Design;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace System.Data.OracleClient
|
||||
{
|
||||
@@ -705,7 +706,7 @@ namespace System.Data.OracleClient
|
||||
|
||||
private void SafeDisposeHandle (OciStatementHandle h)
|
||||
{
|
||||
if (h != null && h != preparedStatement)
|
||||
if (h != null && h != preparedStatement)
|
||||
h.Dispose();
|
||||
}
|
||||
|
||||
@@ -757,6 +758,9 @@ namespace System.Data.OracleClient
|
||||
|
||||
protected override void Dispose (bool disposing)
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
OciCalls.OCIHandleFree(preparedStatement,
|
||||
OciHandleType.Statement);
|
||||
if (disposing)
|
||||
if (Parameters.Count > 0)
|
||||
foreach (OracleParameter parm in Parameters)
|
||||
|
||||
@@ -821,8 +821,11 @@ namespace System.Data.OracleClient
|
||||
if (direction == ParameterDirection.Output ||
|
||||
direction == ParameterDirection.InputOutput ||
|
||||
direction == ParameterDirection.ReturnValue) {
|
||||
|
||||
cursor = IntPtr.Zero;
|
||||
if (cursor != IntPtr.Zero) {
|
||||
OciCalls.OCIHandleFree (cursor,
|
||||
OciHandleType.Statement);
|
||||
cursor = IntPtr.Zero;
|
||||
}
|
||||
OciCalls.OCIHandleAlloc (connection.Environment,
|
||||
out cursor,
|
||||
OciHandleType.Statement,
|
||||
|
||||
@@ -36,29 +36,43 @@ namespace System.Management
|
||||
//[TypeConverter ("")]
|
||||
public abstract class ManagementQuery : ICloneable
|
||||
{
|
||||
string sQueryLanguage;
|
||||
string sQueryString;
|
||||
|
||||
internal ManagementQuery ()
|
||||
{
|
||||
}
|
||||
|
||||
internal ManagementQuery (string query)
|
||||
{
|
||||
QueryString = query;
|
||||
}
|
||||
|
||||
internal ManagementQuery (string language, string query)
|
||||
{
|
||||
QueryLanguage = language;
|
||||
QueryString = query;
|
||||
}
|
||||
|
||||
static ManagementQuery ()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual string QueryLanguage {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
return sQueryLanguage;
|
||||
}
|
||||
set {
|
||||
throw new NotImplementedException ();
|
||||
sQueryLanguage = value;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string QueryString {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
return sQueryString;
|
||||
}
|
||||
set {
|
||||
throw new NotImplementedException ();
|
||||
sQueryString = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,27 +29,23 @@
|
||||
|
||||
namespace System.Management
|
||||
{
|
||||
[MonoTODO ("System.Management is not implemented")]
|
||||
public class ObjectQuery : ManagementQuery
|
||||
{
|
||||
public ObjectQuery ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public ObjectQuery (string query)
|
||||
public ObjectQuery (string query) : base(query)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public ObjectQuery (string language, string query)
|
||||
public ObjectQuery (string language, string query) : base(language, query)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public override object Clone ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
return new ObjectQuery(this.QueryLanguage, this.QueryString);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ include ../../build/rules.make
|
||||
|
||||
LIBRARY = System.Net.Http.dll
|
||||
|
||||
LIB_MCS_FLAGS = -r:System.Core.dll -r:System.dll
|
||||
LIB_MCS_FLAGS = -r:System.Core.dll -r:System.dll $(EXTRA_LIB_MCS_FLAGS)
|
||||
|
||||
TEST_MCS_FLAGS = -r:System.dll -r:System.Core.dll
|
||||
|
||||
|
||||
@@ -247,7 +247,8 @@ namespace System.Net.Http
|
||||
wr.PreAuthenticate = preAuthenticate;
|
||||
|
||||
if (useCookies) {
|
||||
wr.CookieContainer = cookieContainer;
|
||||
// It cannot be null or allowAutoRedirect won't work
|
||||
wr.CookieContainer = CookieContainer;
|
||||
}
|
||||
|
||||
if (useDefaultCredentials) {
|
||||
@@ -271,12 +272,12 @@ namespace System.Net.Http
|
||||
return wr;
|
||||
}
|
||||
|
||||
HttpResponseMessage CreateResponseMessage (HttpWebResponse wr, HttpRequestMessage requestMessage)
|
||||
HttpResponseMessage CreateResponseMessage (HttpWebResponse wr, HttpRequestMessage requestMessage, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = new HttpResponseMessage (wr.StatusCode);
|
||||
response.RequestMessage = requestMessage;
|
||||
response.ReasonPhrase = wr.StatusDescription;
|
||||
response.Content = new StreamContent (wr.GetResponseStream ());
|
||||
response.Content = new StreamContent (wr.GetResponseStream (), cancellationToken);
|
||||
|
||||
var headers = wr.Headers;
|
||||
for (int i = 0; i < headers.Count; ++i) {
|
||||
@@ -328,7 +329,7 @@ namespace System.Net.Http
|
||||
}
|
||||
}
|
||||
|
||||
return CreateResponseMessage (wresponse, request);
|
||||
return CreateResponseMessage (wresponse, request, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@
|
||||
//
|
||||
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace System.Net.Http
|
||||
@@ -35,6 +36,7 @@ namespace System.Net.Http
|
||||
{
|
||||
readonly Stream content;
|
||||
readonly int bufferSize;
|
||||
readonly CancellationToken cancellationToken;
|
||||
|
||||
public StreamContent (Stream content)
|
||||
: this (content, 16 * 1024)
|
||||
@@ -53,6 +55,18 @@ namespace System.Net.Http
|
||||
this.bufferSize = bufferSize;
|
||||
}
|
||||
|
||||
//
|
||||
// Workarounds for poor .NET API
|
||||
// Instead of having SerializeToStreamAsync with CancellationToken as public API. Only LoadIntoBufferAsync
|
||||
// called internally from the send worker can be cancelled and user cannot see/do it
|
||||
//
|
||||
internal StreamContent (Stream content, CancellationToken cancellationToken)
|
||||
: this (content)
|
||||
{
|
||||
// We don't own the token so don't worry about disposing it
|
||||
this.cancellationToken = cancellationToken;
|
||||
}
|
||||
|
||||
protected override Task<Stream> CreateContentReadStreamAsync ()
|
||||
{
|
||||
return Task.FromResult (content);
|
||||
@@ -69,7 +83,7 @@ namespace System.Net.Http
|
||||
|
||||
protected internal override Task SerializeToStreamAsync (Stream stream, TransportContext context)
|
||||
{
|
||||
return content.CopyToAsync (stream, bufferSize);
|
||||
return content.CopyToAsync (stream, bufferSize, cancellationToken);
|
||||
}
|
||||
|
||||
protected internal override bool TryComputeLength (out long length)
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
../../build/common/Consts.cs
|
||||
Assembly/AssemblyInfo.cs
|
||||
System.Net.Http/ByteArrayContent.cs
|
||||
System.Net.Http/ClientCertificateOption.cs
|
||||
System.Net.Http/DelegatingHandler.cs
|
||||
System.Net.Http/FormUrlEncodedContent.cs
|
||||
System.Net.Http/HttpClient.cs
|
||||
System.Net.Http/HttpClientHandler.cs
|
||||
System.Net.Http/HttpCompletionOption.cs
|
||||
System.Net.Http/HttpContent.cs
|
||||
System.Net.Http/HttpMessageHandler.cs
|
||||
System.Net.Http/HttpMessageInvoker.cs
|
||||
System.Net.Http/HttpMethod.cs
|
||||
System.Net.Http/HttpRequestException.cs
|
||||
System.Net.Http/HttpRequestMessage.cs
|
||||
System.Net.Http/HttpResponseMessage.cs
|
||||
System.Net.Http/MessageProcessingHandler.cs
|
||||
System.Net.Http/MultipartContent.cs
|
||||
System.Net.Http/MultipartFormDataContent.cs
|
||||
System.Net.Http/StreamContent.cs
|
||||
System.Net.Http/StringContent.cs
|
||||
System.Net.Http.Headers/AuthenticationHeaderValue.cs
|
||||
System.Net.Http.Headers/CacheControlHeaderValue.cs
|
||||
System.Net.Http.Headers/CollectionExtensions.cs
|
||||
System.Net.Http.Headers/ContentDispositionHeaderValue.cs
|
||||
System.Net.Http.Headers/ContentRangeHeaderValue.cs
|
||||
System.Net.Http.Headers/EntityTagHeaderValue.cs
|
||||
System.Net.Http.Headers/HashCodeCalculator.cs
|
||||
System.Net.Http.Headers/HeaderInfo.cs
|
||||
System.Net.Http.Headers/HttpContentHeaders.cs
|
||||
System.Net.Http.Headers/HttpHeaderKind.cs
|
||||
System.Net.Http.Headers/HttpHeaders.cs
|
||||
System.Net.Http.Headers/HttpHeaderValueCollection.cs
|
||||
System.Net.Http.Headers/HttpRequestHeaders.cs
|
||||
System.Net.Http.Headers/HttpResponseHeaders.cs
|
||||
System.Net.Http.Headers/Lexer.cs
|
||||
System.Net.Http.Headers/MediaTypeHeaderValue.cs
|
||||
System.Net.Http.Headers/MediaTypeWithQualityHeaderValue.cs
|
||||
System.Net.Http.Headers/NameValueHeaderValue.cs
|
||||
System.Net.Http.Headers/NameValueWithParametersHeaderValue.cs
|
||||
System.Net.Http.Headers/Parser.cs
|
||||
System.Net.Http.Headers/ProductHeaderValue.cs
|
||||
System.Net.Http.Headers/ProductInfoHeaderValue.cs
|
||||
System.Net.Http.Headers/QualityValue.cs
|
||||
System.Net.Http.Headers/RangeConditionHeaderValue.cs
|
||||
System.Net.Http.Headers/RangeHeaderValue.cs
|
||||
System.Net.Http.Headers/RangeItemHeaderValue.cs
|
||||
System.Net.Http.Headers/RetryConditionHeaderValue.cs
|
||||
System.Net.Http.Headers/StringWithQualityHeaderValue.cs
|
||||
System.Net.Http.Headers/TransferCodingHeaderValue.cs
|
||||
System.Net.Http.Headers/TransferCodingWithQualityHeaderValue.cs
|
||||
System.Net.Http.Headers/ViaHeaderValue.cs
|
||||
System.Net.Http.Headers/WarningHeaderValue.cs
|
||||
+1
-1
@@ -162,7 +162,7 @@ namespace System.Runtime.Serialization.Json
|
||||
return null;
|
||||
}
|
||||
else
|
||||
return new Uri (reader.ReadElementContentAsString ());
|
||||
return new Uri (reader.ReadElementContentAsString (), UriKind.RelativeOrAbsolute);
|
||||
} else if (type == typeof (XmlQualifiedName)) {
|
||||
s = reader.ReadElementContentAsString ();
|
||||
int idx = s.IndexOf (':');
|
||||
|
||||
+19
@@ -1467,6 +1467,25 @@ namespace MonoTests.System.Runtime.Serialization.Json
|
||||
result = entity.GetValue;
|
||||
Assert.AreEqual ("ValueA", result, "#1");
|
||||
}
|
||||
|
||||
[DataContract(Name = "UriTest")]
|
||||
public class UriTest
|
||||
{
|
||||
[DataMember(Name = "members")]
|
||||
public Uri MembersRelativeLink { get; set; }
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Bug15169 ()
|
||||
{
|
||||
const string json = "{\"members\":\"foo/bar/members\"}";
|
||||
var serializer = new DataContractJsonSerializer (typeof (UriTest));
|
||||
UriTest entity;
|
||||
using (var stream = new MemoryStream (Encoding.UTF8.GetBytes (json)))
|
||||
entity = (UriTest) serializer.ReadObject (stream);
|
||||
|
||||
Assert.AreEqual ("foo/bar/members", entity.MembersRelativeLink.ToString ());
|
||||
}
|
||||
}
|
||||
|
||||
public class CharTest
|
||||
|
||||
@@ -53,7 +53,12 @@ namespace System.Web.Services.Description {
|
||||
}
|
||||
|
||||
public Message this [string name] {
|
||||
get { return this [IndexOf ((Message) Table [name])]; }
|
||||
get {
|
||||
int index = IndexOf ((Message) Table [name]);
|
||||
if (index >= 0)
|
||||
return this [index];
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // Properties
|
||||
|
||||
@@ -247,9 +247,17 @@ namespace System.Web.Configuration
|
||||
}
|
||||
}
|
||||
|
||||
public IDictionary Capabilities {
|
||||
public IDictionary Capabilities
|
||||
{
|
||||
get { return capabilities; }
|
||||
set { capabilities = new Hashtable(value, StringComparer.OrdinalIgnoreCase); }
|
||||
set {
|
||||
//value comes with duplicated keys, so we filter them out
|
||||
capabilities = new Hashtable (value.Keys.Count, StringComparer.OrdinalIgnoreCase);
|
||||
foreach (object key in value.Keys) {
|
||||
if (!capabilities.Contains (key))
|
||||
capabilities.Add (key, value [key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int defaultSubmitButtonLimit;
|
||||
|
||||
@@ -40,7 +40,9 @@ using System.Threading;
|
||||
namespace MonoTests.System.Web
|
||||
{
|
||||
[TestFixture]
|
||||
[Ignore ("Pending fix for bug 351878")]
|
||||
#if NET_3_0
|
||||
[Ignore ("adapters.browser depends on System.Web_test_net_2_0.dll")]
|
||||
#endif
|
||||
public class AppBrowsersTest
|
||||
{
|
||||
[TestFixtureSetUp]
|
||||
|
||||
Regular → Executable
+1
-1
@@ -125,7 +125,7 @@ namespace Mono.Xml.Schema
|
||||
schemas,
|
||||
nsResolver,
|
||||
options);
|
||||
if (reader.BaseURI != String.Empty)
|
||||
if (reader.BaseURI != String.Empty && Uri.IsWellFormedUriString(reader.BaseURI, UriKind.Absolute))
|
||||
v.SourceUri = new Uri (reader.BaseURI);
|
||||
|
||||
readerLineInfo = reader as IXmlLineInfo;
|
||||
|
||||
Regular → Executable
+10
@@ -441,6 +441,16 @@ namespace MonoTests.System.Xml
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IgnoresInvalidBaseUri ()
|
||||
{
|
||||
var source = new StringReader (@"<?xml version='1.0' encoding='utf-8'?><Test></Test>");
|
||||
var readerSettings = new XmlReaderSettings { ValidationType = ValidationType.Schema };
|
||||
var reader = XmlReader.Create (source, readerSettings, "invalidBaseUri");
|
||||
|
||||
Assert.IsNotNull (reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,25 +12,20 @@
|
||||
|
||||
RUNTIME = mono
|
||||
|
||||
ifeq ($(PROFILE), net_2_0)
|
||||
nunit_MONO_PATH="../../../../../class/lib/net_2_0"
|
||||
CSCOMPILE=MONO_PATH=../../../../../class/lib/net_2_0 ../../../../../../mono/runtime/mono-wrapper ../../../../../class/lib/net_2_0/gmcs.exe
|
||||
else
|
||||
nunit_MONO_PATH="../../../../../class/lib/net_1_1"
|
||||
CSCOMPILE=mcs
|
||||
endif
|
||||
nunit_MONO_PATH="../../../../../class/lib/net_4_5"
|
||||
CSCOMPILE=MONO_PATH=../../../../../class/lib/net_4_5 ../../../../../../runtime/mono-wrapper ../../../../../class/lib/build/mcs.exe
|
||||
|
||||
TEST_ARCHIVE = xslt-testsuite-03.ZIP
|
||||
CATALOG = testsuite/TESTS/catalog.xml
|
||||
FIXED_CATALOG = testsuite/TESTS/catalog-fixed.xml
|
||||
|
||||
mono_wrapper_PATH="../../../../../../mono/runtime/mono-wrapper"
|
||||
NUNIT_CONSOLE=$(mono_wrapper_PATH) --debug ./nunit-console.exe
|
||||
mono_wrapper_PATH="../../../../../../runtime/mono-wrapper"
|
||||
NUNIT_CONSOLE=$(mono_wrapper_PATH) --debug $(nunit_MONO_PATH)/nunit-console.exe
|
||||
|
||||
FIXTURE=MonoTests.oasis_xslt.SuiteBuilder
|
||||
CLEAN_NUNIT_FLAGS=/fixture:$(FIXTURE) /xml=TestResult.xml /include=Clean
|
||||
FAILED_NUNIT_FLAGS=/fixture:$(FIXTURE) /xml=FailedTestResult.xml /include=KnownFailures
|
||||
ALL_NUNIT_FLAGS=/fixture:$(FIXTURE) /xml=AllTestResult.xml /out=AllTestResult.log /include=KnownFailures,Clean
|
||||
CLEAN_NUNIT_FLAGS=-fixture:$(FIXTURE) -xml=TestResult.xml -include=Clean
|
||||
FAILED_NUNIT_FLAGS=-fixture:$(FIXTURE) -xml=FailedTestResult.xml -include=KnownFailures
|
||||
ALL_NUNIT_FLAGS=-fixture:$(FIXTURE) -xml=AllTestResult.xml -out=AllTestResult.log -include=KnownFailures,Clean
|
||||
|
||||
TEST_PROG=xslttest.dll
|
||||
GENERATE_EXE=generate.exe
|
||||
@@ -41,7 +36,7 @@ else
|
||||
REFERENCE_RESULTS_NAME=results
|
||||
endif
|
||||
REFERENCE_RESULTS_ARCHIVE=xslt-reference-$(REFERENCE_RESULTS_NAME).tar.gz
|
||||
REFERENCE_RESULTS_URL=http://anonsvn.mono-project.com/source/trunk/release/test-ext/xslt-standalone/$(REFERENCE_RESULTS_ARCHIVE)
|
||||
REFERENCE_RESULTS_URL=https://github.com/mono/release/raw/master/test-ext/xslt-standalone/$(REFERENCE_RESULTS_ARCHIVE)
|
||||
REFERENCE_RESULTS=$(REFERENCE_RESULTS_NAME)/timestamp
|
||||
|
||||
test : $(TEST_PROG) $(FIXED_CATALOG) $(REFERENCE_RESULTS)
|
||||
@@ -92,7 +87,7 @@ $(GENERATE_EXE) : generate.cs XsltTestUtils.cs
|
||||
# It somehow does not work fine unless nunit-console.exe is here ...
|
||||
cp $(nunit_MONO_PATH)/nunit-console.exe .
|
||||
$(TEST_PROG) : xslttest.cs XsltTestUtils.cs
|
||||
$(CSCOMPILE) xslttest.cs XsltTestUtils.cs XmlCompare.cs -r:nunit.core -r:nunit.framework -out:$@ -t:library
|
||||
$(CSCOMPILE) xslttest.cs XsltTestUtils.cs XmlCompare.cs -r:nunit.core -r:nunit.core.interfaces -r:nunit.framework -out:$@ -t:library
|
||||
|
||||
catalog-fixed : $(FIXED_CATALOG)
|
||||
|
||||
|
||||
@@ -17,10 +17,8 @@ namespace MonoTests.oasis_xslt {
|
||||
ArrayList fixmeList = new ArrayList ();
|
||||
#endregion
|
||||
|
||||
TestSuite _suite;
|
||||
SuiteBuilder (TestSuite suite)
|
||||
public SuiteBuilder ()
|
||||
{
|
||||
_suite = suite;
|
||||
}
|
||||
|
||||
void ReadLists ()
|
||||
@@ -42,7 +40,7 @@ namespace MonoTests.oasis_xslt {
|
||||
}
|
||||
}
|
||||
|
||||
public void Build ()
|
||||
void Build (TestSuite suite)
|
||||
{
|
||||
// if (Environment.GetEnvironmentVariables().Contains("START_DEBUG"))
|
||||
// System.Diagnostics.Debugger.Launch ();
|
||||
@@ -65,18 +63,23 @@ namespace MonoTests.oasis_xslt {
|
||||
string expectedException = (string) expectedExceptions[testid];
|
||||
bool isKnownFailure = knownFailures.Contains (testid) || fixmeList.Contains (testid);
|
||||
|
||||
_suite.Add (new TestFromCatalog (testid, stt, expectedException,
|
||||
suite.Add (new TestFromCatalog (testid, stt, expectedException,
|
||||
EnvOptions.InverseResults, isKnownFailure));
|
||||
}
|
||||
}
|
||||
|
||||
static object lock_obj = new object ();
|
||||
static TestSuite _suite;
|
||||
|
||||
[Suite]
|
||||
public static TestSuite Suite {
|
||||
get {
|
||||
if (_suite == null) { lock (lock_obj) {
|
||||
TestSuite suite = new TestSuite ("MonoTests.oasis_xslt.SuiteBuilder");
|
||||
SuiteBuilder builder = new SuiteBuilder (suite);
|
||||
builder.Build ();
|
||||
return suite;
|
||||
new SuiteBuilder ().Build (suite);
|
||||
_suite = suite;
|
||||
} }
|
||||
return _suite;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,7 +102,7 @@ namespace MonoTests.oasis_xslt {
|
||||
ArrayList arr = new ArrayList ();
|
||||
if (isKnownFailure) {
|
||||
arr.Add ("KnownFailures");
|
||||
this.IsExplicit = true;
|
||||
//this.IsExplicit = true;
|
||||
}
|
||||
else
|
||||
arr.Add ("Clean");
|
||||
|
||||
@@ -181,16 +181,20 @@ namespace System.Xml.Linq
|
||||
|
||||
public IEnumerable <XElement> Elements (XName name)
|
||||
{
|
||||
foreach (XElement el in Elements ())
|
||||
if (el.Name == name)
|
||||
foreach (XNode n in Nodes ()) {
|
||||
XElement el = n as XElement;
|
||||
if (el != null && el.Name == name)
|
||||
yield return el;
|
||||
}
|
||||
}
|
||||
|
||||
public XElement Element (XName name)
|
||||
{
|
||||
foreach (XElement el in Elements ())
|
||||
if (el.Name == name)
|
||||
foreach (XNode n in Nodes ()) {
|
||||
XElement el = n as XElement;
|
||||
if (el != null && el.Name == name)
|
||||
return el;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -382,7 +382,8 @@ namespace System.Xml.Linq
|
||||
|
||||
public XAttribute Attribute (XName name)
|
||||
{
|
||||
foreach (XAttribute a in Attributes ())
|
||||
XAttribute next;
|
||||
for (XAttribute a = attr_first; a != null; a = a.NextAttribute)
|
||||
if (a.Name == name)
|
||||
return a;
|
||||
return null;
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace System.Xml.Linq
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
if (ns == XNamespace.None)
|
||||
if (Object.ReferenceEquals (ns, XNamespace.None))
|
||||
return local;
|
||||
return String.Concat ("{", ns.NamespaceName, "}", local);
|
||||
}
|
||||
|
||||
@@ -165,42 +165,42 @@ namespace System.Xml.Linq
|
||||
|
||||
internal void OnAddingObject (object addedObject)
|
||||
{
|
||||
OnChanging (addedObject, new XObjectChangeEventArgs (XObjectChange.Add));
|
||||
OnChanging (addedObject, XObjectChangeEventArgs.Add);
|
||||
}
|
||||
|
||||
internal void OnAddedObject (object addedObject)
|
||||
{
|
||||
OnChanged (addedObject, new XObjectChangeEventArgs (XObjectChange.Add));
|
||||
OnChanged (addedObject, XObjectChangeEventArgs.Add);
|
||||
}
|
||||
|
||||
internal void OnNameChanging (object renamedObject)
|
||||
{
|
||||
OnChanging (renamedObject, new XObjectChangeEventArgs (System.Xml.Linq.XObjectChange.Name));
|
||||
OnChanging (renamedObject, XObjectChangeEventArgs.Name);
|
||||
}
|
||||
|
||||
internal void OnNameChanged (object renamedObject)
|
||||
{
|
||||
OnChanged (renamedObject, new XObjectChangeEventArgs (System.Xml.Linq.XObjectChange.Name));
|
||||
OnChanged (renamedObject, XObjectChangeEventArgs.Name);
|
||||
}
|
||||
|
||||
internal void OnRemovingObject (object removedObject)
|
||||
{
|
||||
OnChanging (removedObject, new XObjectChangeEventArgs (XObjectChange.Remove));
|
||||
OnChanging (removedObject, XObjectChangeEventArgs.Remove);
|
||||
}
|
||||
|
||||
internal void OnRemovedObject (object removedObject)
|
||||
{
|
||||
OnChanged (removedObject, new XObjectChangeEventArgs (XObjectChange.Remove));
|
||||
OnChanged (removedObject, XObjectChangeEventArgs.Remove);
|
||||
}
|
||||
|
||||
internal void OnValueChanging (object changedObject)
|
||||
{
|
||||
OnChanging (changedObject, new XObjectChangeEventArgs (XObjectChange.Value));
|
||||
OnChanging (changedObject, XObjectChangeEventArgs.Value);
|
||||
}
|
||||
|
||||
internal void OnValueChanged (object changedObject)
|
||||
{
|
||||
OnChanged (changedObject, new XObjectChangeEventArgs (XObjectChange.Value));
|
||||
OnChanged (changedObject, XObjectChangeEventArgs.Value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if !NET_2_1
|
||||
|
||||
using System;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
@@ -109,5 +107,3 @@ namespace System.Xml.Schema
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -395,6 +395,20 @@ namespace Mono.CSharp
|
||||
args.AppendFormat("\"{0}\" ",source);
|
||||
return args.ToString();
|
||||
}
|
||||
|
||||
// Keep in sync with mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolTask.cs
|
||||
const string ErrorRegexPattern = @"
|
||||
^
|
||||
(\s*(?<file>[^\(]+) # filename (optional)
|
||||
(\((?<line>\d*)(,(?<column>\d*[\+]*))?\))? # line+column (optional)
|
||||
:\s+)?
|
||||
(?<level>\w+) # error|warning
|
||||
\s+
|
||||
(?<number>[^:]*\d) # CS1234
|
||||
:
|
||||
\s*
|
||||
(?<message>.*)$";
|
||||
|
||||
private static CompilerError CreateErrorFromString(string error_string)
|
||||
{
|
||||
if (error_string.StartsWith ("BETA"))
|
||||
@@ -404,8 +418,7 @@ namespace Mono.CSharp
|
||||
return null;
|
||||
|
||||
CompilerError error=new CompilerError();
|
||||
Regex reg = new Regex (@"^(\s*(?<file>.*)\((?<line>\d*)(,(?<column>\d*))?\)(:)?\s+)*(?<level>\w+)\s*(?<number>.*):\s(?<message>.*)",
|
||||
RegexOptions.Compiled | RegexOptions.ExplicitCapture);
|
||||
Regex reg = new Regex (ErrorRegexPattern, RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.IgnorePatternWhitespace);
|
||||
Match match=reg.Match(error_string);
|
||||
if (!match.Success) {
|
||||
// We had some sort of runtime crash
|
||||
|
||||
@@ -73,33 +73,36 @@ namespace System.CodeDom.Compiler {
|
||||
|
||||
// note: this property *cannot* change TempDir property
|
||||
string temp = tempdir;
|
||||
if (temp.Length == 0)
|
||||
temp = GetOwnTempDir ();
|
||||
if (temp.Length == 0) {
|
||||
if (ownTempDir != null) {
|
||||
temp = ownTempDir;
|
||||
Directory.CreateDirectory (temp);
|
||||
} else {
|
||||
temp = CreateOwnTempDir ();
|
||||
}
|
||||
}
|
||||
|
||||
// Create a temporary file at the target directory. This ensures
|
||||
// that the generated file name is unique.
|
||||
FileStream f = null;
|
||||
do {
|
||||
int test_counter = 1000;
|
||||
while (true) {
|
||||
int num = rnd.Next ();
|
||||
num++;
|
||||
basepath = Path.Combine (temp, num.ToString("x"));
|
||||
string path = basepath + ".tmp";
|
||||
|
||||
try {
|
||||
f = new FileStream (path, FileMode.CreateNew);
|
||||
}
|
||||
catch (System.IO.IOException) {
|
||||
f = null;
|
||||
continue;
|
||||
}
|
||||
catch {
|
||||
// avoid endless loop
|
||||
using (var f = new FileStream (path, FileMode.CreateNew)) {
|
||||
break;
|
||||
}
|
||||
} catch (IOException) {
|
||||
if (test_counter-- > 0)
|
||||
continue;
|
||||
|
||||
throw;
|
||||
}
|
||||
} while (f == null);
|
||||
|
||||
f.Close ();
|
||||
|
||||
}
|
||||
|
||||
// and you must have discovery access to the combined path
|
||||
// note: the cache behaviour is tested in the CAS tests
|
||||
if (SecurityManager.SecurityEnabled) {
|
||||
@@ -110,12 +113,9 @@ namespace System.CodeDom.Compiler {
|
||||
return(basepath);
|
||||
}
|
||||
}
|
||||
|
||||
string GetOwnTempDir ()
|
||||
{
|
||||
if (ownTempDir != null)
|
||||
return ownTempDir;
|
||||
|
||||
string CreateOwnTempDir ()
|
||||
{
|
||||
// this call ensure the Environment permissions check
|
||||
string basedir = Path.GetTempPath ();
|
||||
|
||||
@@ -245,9 +245,8 @@ namespace System.CodeDom.Compiler {
|
||||
File.Delete (tmpFile);
|
||||
basepath = null;
|
||||
}
|
||||
if (allDeleted && ownTempDir != null) {
|
||||
if (allDeleted && ownTempDir != null && filenames.Length > 0) {
|
||||
Directory.Delete (ownTempDir, true);
|
||||
ownTempDir = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -370,13 +370,19 @@ namespace System.Collections.Concurrent
|
||||
{
|
||||
item = default (T);
|
||||
CheckArray (collections);
|
||||
int index = 0;
|
||||
foreach (var coll in collections) {
|
||||
try {
|
||||
item = coll.Take ();
|
||||
return index;
|
||||
} catch {}
|
||||
index++;
|
||||
WaitHandle[] wait_table = null;
|
||||
while (true) {
|
||||
int index = 0;
|
||||
for (int i = 0; i < collections.Length; ++i) {
|
||||
if (collections [i].TryTake (out item))
|
||||
return i;
|
||||
}
|
||||
if (wait_table == null) {
|
||||
wait_table = new WaitHandle [collections.Length];
|
||||
for (int i = 0; i < collections.Length; ++i)
|
||||
wait_table [i] = collections [i].mreRemove.WaitHandle;
|
||||
}
|
||||
WaitHandle.WaitAny (wait_table);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -385,14 +391,24 @@ namespace System.Collections.Concurrent
|
||||
{
|
||||
item = default (T);
|
||||
CheckArray (collections);
|
||||
int index = 0;
|
||||
foreach (var coll in collections) {
|
||||
try {
|
||||
item = coll.Take (cancellationToken);
|
||||
return index;
|
||||
} catch {}
|
||||
index++;
|
||||
WaitHandle[] wait_table = null;
|
||||
while (true) {
|
||||
int index = 0;
|
||||
for (int i = 0; i < collections.Length; ++i) {
|
||||
if (collections [i].TryTake (out item))
|
||||
return i;
|
||||
}
|
||||
cancellationToken.ThrowIfCancellationRequested ();
|
||||
if (wait_table == null) {
|
||||
wait_table = new WaitHandle [collections.Length + 1];
|
||||
for (int i = 0; i < collections.Length; ++i)
|
||||
wait_table [i] = collections [i].mreRemove.WaitHandle;
|
||||
wait_table [collections.Length] = cancellationToken.WaitHandle;
|
||||
}
|
||||
WaitHandle.WaitAny (wait_table);
|
||||
cancellationToken.ThrowIfCancellationRequested ();
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
#if (XML_DEP)
|
||||
using System.Xml;
|
||||
#endif
|
||||
@@ -112,7 +113,79 @@ namespace System.Configuration
|
||||
#if (CONFIGURATION_DEP)
|
||||
protected override void Unmerge (ConfigurationElement sourceElement, ConfigurationElement parentElement, ConfigurationSaveMode saveMode)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
if (parentElement != null && sourceElement.GetType() != parentElement.GetType())
|
||||
throw new ConfigurationErrorsException ("Can't unmerge two elements of different type");
|
||||
|
||||
bool isMinimalOrModified = saveMode == ConfigurationSaveMode.Minimal ||
|
||||
saveMode == ConfigurationSaveMode.Modified;
|
||||
|
||||
foreach (PropertyInformation prop in sourceElement.ElementInformation.Properties)
|
||||
{
|
||||
if (prop.ValueOrigin == PropertyValueOrigin.Default)
|
||||
continue;
|
||||
|
||||
PropertyInformation unmergedProp = ElementInformation.Properties [prop.Name];
|
||||
|
||||
object sourceValue = prop.Value;
|
||||
if (parentElement == null || !HasValue (parentElement, prop.Name)) {
|
||||
unmergedProp.Value = sourceValue;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sourceValue == null)
|
||||
continue;
|
||||
|
||||
object parentValue = GetItem (parentElement, prop.Name);
|
||||
if (!PropertyIsElement (prop)) {
|
||||
if (!object.Equals (sourceValue, parentValue) ||
|
||||
(saveMode == ConfigurationSaveMode.Full) ||
|
||||
(saveMode == ConfigurationSaveMode.Modified && prop.ValueOrigin == PropertyValueOrigin.SetHere))
|
||||
unmergedProp.Value = sourceValue;
|
||||
continue;
|
||||
}
|
||||
|
||||
var sourceElem = (ConfigurationElement) sourceValue;
|
||||
if (isMinimalOrModified && !ElementIsModified (sourceElem))
|
||||
continue;
|
||||
if (parentValue == null) {
|
||||
unmergedProp.Value = sourceValue;
|
||||
continue;
|
||||
}
|
||||
|
||||
var parentElem = (ConfigurationElement) parentValue;
|
||||
ConfigurationElement copy = (ConfigurationElement) unmergedProp.Value;
|
||||
ElementUnmerge (copy, sourceElem, parentElem, saveMode);
|
||||
}
|
||||
}
|
||||
|
||||
bool HasValue (ConfigurationElement element, string propName)
|
||||
{
|
||||
PropertyInformation info = element.ElementInformation.Properties [propName];
|
||||
return info != null && info.ValueOrigin != PropertyValueOrigin.Default;
|
||||
}
|
||||
|
||||
object GetItem (ConfigurationElement element, string property)
|
||||
{
|
||||
PropertyInformation pi = ElementInformation.Properties [property];
|
||||
if (pi == null)
|
||||
throw new InvalidOperationException ("Property '" + property + "' not found in configuration element");
|
||||
|
||||
return pi.Value;
|
||||
}
|
||||
|
||||
bool PropertyIsElement (PropertyInformation prop)
|
||||
{
|
||||
return (typeof(ConfigurationElement).IsAssignableFrom (prop.Type));
|
||||
}
|
||||
|
||||
bool ElementIsModified (ConfigurationElement element)
|
||||
{
|
||||
return (bool) element.GetType ().GetMethod ("IsModified", BindingFlags.NonPublic | BindingFlags.Instance).Invoke (element, new object [0]);
|
||||
}
|
||||
|
||||
void ElementUnmerge (ConfigurationElement target, ConfigurationElement sourceElement, ConfigurationElement parentElement, ConfigurationSaveMode saveMode)
|
||||
{
|
||||
target.GetType ().GetMethod ("Unmerge", BindingFlags.NonPublic | BindingFlags.Instance).Invoke (target, new object [] {sourceElement, parentElement, saveMode});
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// System.Net.NetworkInformation.NetworkChange
|
||||
//
|
||||
// Authors:
|
||||
// Gonzalo Paniagua Javier ([email protected])
|
||||
// Aaron Bockover ([email protected])
|
||||
// Gonzalo Paniagua Javier (LinuxNetworkChange) ([email protected])
|
||||
// Aaron Bockover (MacNetworkChange) ([email protected])
|
||||
//
|
||||
// Copyright (c) 2006,2011 Novell, Inc. (http://www.novell.com)
|
||||
// Copyright (c) 2013 Xamarin, Inc. (http://www.xamarin.com)
|
||||
@@ -15,10 +15,10 @@
|
||||
// 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
|
||||
@@ -28,137 +28,298 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
|
||||
#if NETWORK_CHANGE_STANDALONE
|
||||
namespace NetworkInformation {
|
||||
|
||||
public class NetworkAvailabilityEventArgs : EventArgs
|
||||
{
|
||||
public bool IsAvailable { get; set; }
|
||||
|
||||
public NetworkAvailabilityEventArgs (bool available)
|
||||
{
|
||||
IsAvailable = available;
|
||||
}
|
||||
}
|
||||
|
||||
public delegate void NetworkAddressChangedEventHandler (object sender, EventArgs args);
|
||||
public delegate void NetworkAvailabilityChangedEventHandler (object sender, NetworkAvailabilityEventArgs args);
|
||||
#else
|
||||
namespace System.Net.NetworkInformation {
|
||||
internal interface INetworkChange {
|
||||
#endif
|
||||
|
||||
internal interface INetworkChange : IDisposable {
|
||||
event NetworkAddressChangedEventHandler NetworkAddressChanged;
|
||||
event NetworkAvailabilityChangedEventHandler NetworkAvailabilityChanged;
|
||||
bool HasRegisteredEvents { get; }
|
||||
}
|
||||
|
||||
public sealed class NetworkChange {
|
||||
static INetworkChange networkChange;
|
||||
|
||||
static NetworkChange ()
|
||||
{
|
||||
if (MacNetworkChange.IsEnabled) {
|
||||
networkChange = new MacNetworkChange ();
|
||||
} else {
|
||||
networkChange = new LinuxNetworkChange ();
|
||||
public static event NetworkAddressChangedEventHandler NetworkAddressChanged {
|
||||
add {
|
||||
lock (typeof (INetworkChange)) {
|
||||
MaybeCreate ();
|
||||
if (networkChange != null)
|
||||
networkChange.NetworkAddressChanged += value;
|
||||
}
|
||||
}
|
||||
|
||||
remove {
|
||||
lock (typeof (INetworkChange)) {
|
||||
if (networkChange != null) {
|
||||
networkChange.NetworkAddressChanged -= value;
|
||||
MaybeDispose ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static event NetworkAddressChangedEventHandler NetworkAddressChanged {
|
||||
add { networkChange.NetworkAddressChanged += value; }
|
||||
remove { networkChange.NetworkAddressChanged -= value; }
|
||||
public static event NetworkAvailabilityChangedEventHandler NetworkAvailabilityChanged {
|
||||
add {
|
||||
lock (typeof (INetworkChange)) {
|
||||
MaybeCreate ();
|
||||
if (networkChange != null)
|
||||
networkChange.NetworkAvailabilityChanged += value;
|
||||
}
|
||||
}
|
||||
|
||||
remove {
|
||||
lock (typeof (INetworkChange)) {
|
||||
if (networkChange != null) {
|
||||
networkChange.NetworkAvailabilityChanged -= value;
|
||||
MaybeDispose ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static event NetworkAvailabilityChangedEventHandler NetworkAvailabilityChanged {
|
||||
add { networkChange.NetworkAvailabilityChanged += value; }
|
||||
remove { networkChange.NetworkAvailabilityChanged -= value; }
|
||||
static void MaybeCreate ()
|
||||
{
|
||||
if (networkChange != null)
|
||||
return;
|
||||
|
||||
try {
|
||||
networkChange = new MacNetworkChange ();
|
||||
} catch {
|
||||
#if !NETWORK_CHANGE_STANDALONE
|
||||
networkChange = new LinuxNetworkChange ();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static void MaybeDispose ()
|
||||
{
|
||||
if (networkChange != null && networkChange.HasRegisteredEvents) {
|
||||
networkChange.Dispose ();
|
||||
networkChange = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class MacNetworkChange : INetworkChange {
|
||||
public static bool IsEnabled {
|
||||
get { return mono_sc_reachability_enabled () != 0; }
|
||||
internal sealed class MacNetworkChange : INetworkChange
|
||||
{
|
||||
const string DL_LIB = "/usr/lib/libSystem.dylib";
|
||||
const string CORE_SERVICES_LIB = "/System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration";
|
||||
const string CORE_FOUNDATION_LIB = "/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation";
|
||||
|
||||
[UnmanagedFunctionPointerAttribute (CallingConvention.Cdecl)]
|
||||
delegate void SCNetworkReachabilityCallback (IntPtr target, NetworkReachabilityFlags flags, IntPtr info);
|
||||
|
||||
[DllImport (DL_LIB)]
|
||||
static extern IntPtr dlopen (string path, int mode);
|
||||
|
||||
[DllImport (DL_LIB)]
|
||||
static extern IntPtr dlsym (IntPtr handle, string symbol);
|
||||
|
||||
[DllImport (DL_LIB)]
|
||||
static extern int dlclose (IntPtr handle);
|
||||
|
||||
[DllImport (CORE_FOUNDATION_LIB)]
|
||||
static extern void CFRelease (IntPtr handle);
|
||||
|
||||
[DllImport (CORE_FOUNDATION_LIB)]
|
||||
static extern IntPtr CFRunLoopGetMain ();
|
||||
|
||||
[DllImport (CORE_SERVICES_LIB)]
|
||||
static extern IntPtr SCNetworkReachabilityCreateWithAddress (IntPtr allocator, ref sockaddr_in sockaddr);
|
||||
|
||||
[DllImport (CORE_SERVICES_LIB)]
|
||||
static extern bool SCNetworkReachabilityGetFlags (IntPtr reachability, out NetworkReachabilityFlags flags);
|
||||
|
||||
[DllImport (CORE_SERVICES_LIB)]
|
||||
static extern bool SCNetworkReachabilitySetCallback (IntPtr reachability, SCNetworkReachabilityCallback callback, ref SCNetworkReachabilityContext context);
|
||||
|
||||
[DllImport (CORE_SERVICES_LIB)]
|
||||
static extern bool SCNetworkReachabilityScheduleWithRunLoop (IntPtr reachability, IntPtr runLoop, IntPtr runLoopMode);
|
||||
|
||||
[DllImport (CORE_SERVICES_LIB)]
|
||||
static extern bool SCNetworkReachabilityUnscheduleFromRunLoop (IntPtr reachability, IntPtr runLoop, IntPtr runLoopMode);
|
||||
|
||||
[StructLayout (LayoutKind.Explicit, Size = 28)]
|
||||
struct sockaddr_in {
|
||||
[FieldOffset (0)] public byte sin_len;
|
||||
[FieldOffset (1)] public byte sin_family;
|
||||
|
||||
public static sockaddr_in Create ()
|
||||
{
|
||||
return new sockaddr_in {
|
||||
sin_len = 28,
|
||||
sin_family = 2 // AF_INET
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout (LayoutKind.Sequential)]
|
||||
struct SCNetworkReachabilityContext {
|
||||
public IntPtr version;
|
||||
public IntPtr info;
|
||||
public IntPtr retain;
|
||||
public IntPtr release;
|
||||
public IntPtr copyDescription;
|
||||
}
|
||||
|
||||
[Flags]
|
||||
enum NetworkReachabilityFlags {
|
||||
None = 0,
|
||||
TransientConnection = 1 << 0,
|
||||
Reachable = 1 << 1,
|
||||
ConnectionRequired = 1 << 2,
|
||||
ConnectionOnTraffic = 1 << 3,
|
||||
InterventionRequired = 1 << 4,
|
||||
ConnectionOnDemand = 1 << 5,
|
||||
IsLocalAddress = 1 << 16,
|
||||
IsDirect = 1 << 17,
|
||||
IsWWAN = 1 << 18,
|
||||
ConnectionAutomatic = ConnectionOnTraffic
|
||||
}
|
||||
|
||||
IntPtr handle;
|
||||
IntPtr runLoopMode;
|
||||
SCNetworkReachabilityCallback callback;
|
||||
bool scheduledWithRunLoop;
|
||||
NetworkReachabilityFlags flags;
|
||||
|
||||
event NetworkAddressChangedEventHandler networkAddressChanged;
|
||||
event NetworkAvailabilityChangedEventHandler networkAvailabilityChanged;
|
||||
|
||||
public event NetworkAddressChangedEventHandler NetworkAddressChanged {
|
||||
add {
|
||||
if (value != null) {
|
||||
MaybeInitialize ();
|
||||
networkAddressChanged += value;
|
||||
value (null, EventArgs.Empty);
|
||||
}
|
||||
value (null, EventArgs.Empty);
|
||||
networkAddressChanged += value;
|
||||
}
|
||||
|
||||
remove {
|
||||
networkAddressChanged -= value;
|
||||
MaybeDispose ();
|
||||
}
|
||||
remove { networkAddressChanged -= value; }
|
||||
}
|
||||
|
||||
public event NetworkAvailabilityChangedEventHandler NetworkAvailabilityChanged {
|
||||
add {
|
||||
if (value != null) {
|
||||
MaybeInitialize ();
|
||||
networkAvailabilityChanged += value;
|
||||
var available = handle != IntPtr.Zero && mono_sc_reachability_is_available (handle) != 0;
|
||||
value (null, new NetworkAvailabilityEventArgs (available));
|
||||
}
|
||||
value (null, new NetworkAvailabilityEventArgs (IsAvailable));
|
||||
networkAvailabilityChanged += value;
|
||||
}
|
||||
|
||||
remove {
|
||||
networkAvailabilityChanged -= value;
|
||||
MaybeDispose ();
|
||||
remove { networkAvailabilityChanged -= value; }
|
||||
}
|
||||
|
||||
bool IsAvailable {
|
||||
get {
|
||||
return (flags & NetworkReachabilityFlags.Reachable) != 0 &&
|
||||
(flags & NetworkReachabilityFlags.ConnectionRequired) == 0;
|
||||
}
|
||||
}
|
||||
|
||||
IntPtr handle;
|
||||
MonoSCReachabilityCallback callback;
|
||||
public bool HasRegisteredEvents {
|
||||
get { return networkAddressChanged != null || networkAvailabilityChanged != null; }
|
||||
}
|
||||
|
||||
void Callback (int available)
|
||||
public MacNetworkChange ()
|
||||
{
|
||||
var addressChanged = networkAddressChanged;
|
||||
if (addressChanged != null) {
|
||||
addressChanged (null, EventArgs.Empty);
|
||||
}
|
||||
var sockaddr = sockaddr_in.Create ();
|
||||
handle = SCNetworkReachabilityCreateWithAddress (IntPtr.Zero, ref sockaddr);
|
||||
if (handle == IntPtr.Zero)
|
||||
throw new Exception ("SCNetworkReachabilityCreateWithAddress returned NULL");
|
||||
|
||||
var availabilityChanged = networkAvailabilityChanged;
|
||||
if (availabilityChanged != null) {
|
||||
availabilityChanged (null, new NetworkAvailabilityEventArgs (available != 0));
|
||||
}
|
||||
callback = new SCNetworkReachabilityCallback (HandleCallback);
|
||||
var info = new SCNetworkReachabilityContext {
|
||||
info = GCHandle.ToIntPtr (GCHandle.Alloc (this))
|
||||
};
|
||||
|
||||
SCNetworkReachabilitySetCallback (handle, callback, ref info);
|
||||
|
||||
scheduledWithRunLoop =
|
||||
LoadRunLoopMode () &&
|
||||
SCNetworkReachabilityScheduleWithRunLoop (handle, CFRunLoopGetMain (), runLoopMode);
|
||||
|
||||
SCNetworkReachabilityGetFlags (handle, out flags);
|
||||
}
|
||||
|
||||
void MaybeInitialize ()
|
||||
bool LoadRunLoopMode ()
|
||||
{
|
||||
var cfLibHandle = dlopen (CORE_FOUNDATION_LIB, 0);
|
||||
if (cfLibHandle == IntPtr.Zero)
|
||||
return false;
|
||||
|
||||
try {
|
||||
runLoopMode = dlsym (cfLibHandle, "kCFRunLoopDefaultMode");
|
||||
if (runLoopMode != IntPtr.Zero) {
|
||||
runLoopMode = Marshal.ReadIntPtr (runLoopMode);
|
||||
return runLoopMode != IntPtr.Zero;
|
||||
}
|
||||
} finally {
|
||||
dlclose (cfLibHandle);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
lock (this) {
|
||||
if (handle == IntPtr.Zero) {
|
||||
callback = new MonoSCReachabilityCallback (Callback);
|
||||
handle = mono_sc_reachability_new (callback);
|
||||
}
|
||||
if (handle == IntPtr.Zero)
|
||||
return;
|
||||
|
||||
if (scheduledWithRunLoop)
|
||||
SCNetworkReachabilityUnscheduleFromRunLoop (handle, CFRunLoopGetMain (), runLoopMode);
|
||||
|
||||
CFRelease (handle);
|
||||
handle = IntPtr.Zero;
|
||||
callback = null;
|
||||
flags = NetworkReachabilityFlags.None;
|
||||
scheduledWithRunLoop = false;
|
||||
}
|
||||
}
|
||||
|
||||
void MaybeDispose ()
|
||||
{
|
||||
lock (this) {
|
||||
var addressChanged = networkAddressChanged;
|
||||
var availabilityChanged = networkAvailabilityChanged;
|
||||
if (handle != IntPtr.Zero && addressChanged == null && availabilityChanged == null) {
|
||||
mono_sc_reachability_free (handle);
|
||||
handle = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if MONOTOUCH || MONODROID
|
||||
const string LIBNAME = "__Internal";
|
||||
#else
|
||||
const string LIBNAME = "MonoPosixHelper";
|
||||
#if MONOTOUCH
|
||||
[MonoTouch.MonoPInvokeCallback (typeof (SCNetworkReachabilityCallback))]
|
||||
#endif
|
||||
static void HandleCallback (IntPtr reachability, NetworkReachabilityFlags flags, IntPtr info)
|
||||
{
|
||||
if (info == IntPtr.Zero)
|
||||
return;
|
||||
|
||||
delegate void MonoSCReachabilityCallback (int available);
|
||||
var instance = GCHandle.FromIntPtr (info).Target as MacNetworkChange;
|
||||
if (instance == null || instance.flags == flags)
|
||||
return;
|
||||
|
||||
[DllImport (LIBNAME)]
|
||||
static extern int mono_sc_reachability_enabled ();
|
||||
instance.flags = flags;
|
||||
|
||||
[DllImport (LIBNAME)]
|
||||
static extern IntPtr mono_sc_reachability_new (MonoSCReachabilityCallback callback);
|
||||
var addressChanged = instance.networkAddressChanged;
|
||||
if (addressChanged != null)
|
||||
addressChanged (null, EventArgs.Empty);
|
||||
|
||||
[DllImport (LIBNAME)]
|
||||
static extern void mono_sc_reachability_free (IntPtr handle);
|
||||
|
||||
[DllImport (LIBNAME)]
|
||||
static extern int mono_sc_reachability_is_available (IntPtr handle);
|
||||
var availabilityChanged = instance.networkAvailabilityChanged;
|
||||
if (availabilityChanged != null)
|
||||
availabilityChanged (null, new NetworkAvailabilityEventArgs (instance.IsAvailable));
|
||||
}
|
||||
}
|
||||
|
||||
#if !NETWORK_CHANGE_STANDALONE
|
||||
|
||||
internal sealed class LinuxNetworkChange : INetworkChange {
|
||||
[Flags]
|
||||
enum EventType {
|
||||
@@ -185,6 +346,14 @@ namespace System.Net.NetworkInformation {
|
||||
remove { Unregister (value); }
|
||||
}
|
||||
|
||||
public bool HasRegisteredEvents {
|
||||
get { return AddressChanged != null || AvailabilityChanged != null; }
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
}
|
||||
|
||||
//internal Socket (AddressFamily family, SocketType type, ProtocolType proto, IntPtr sock)
|
||||
|
||||
bool EnsureSocket ()
|
||||
@@ -321,5 +490,7 @@ namespace System.Net.NetworkInformation {
|
||||
[DllImport (LIBNAME, CallingConvention=CallingConvention.Cdecl)]
|
||||
static extern IntPtr CloseNLSocket (IntPtr sock);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
//
|
||||
// ClientWebSocket.cs
|
||||
//
|
||||
// Author:
|
||||
// Martin Baulig <martin.baulig@xamarin.com>
|
||||
// Authors:
|
||||
// Jérémie Laval <jeremie dot laval at xamarin dot com>
|
||||
//
|
||||
// Copyright (c) 2013 Xamarin Inc. (http://www.xamarin.com)
|
||||
// Copyright 2013 Xamarin Inc (http://www.xamarin.com).
|
||||
//
|
||||
// Lightly inspired from WebSocket4Net distributed under the Apache License 2.0
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -27,71 +29,327 @@
|
||||
#if NET_4_5
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Security.Principal;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace System.Net.WebSockets
|
||||
{
|
||||
[MonoTODO]
|
||||
public class ClientWebSocket : WebSocket
|
||||
public class ClientWebSocket : WebSocket, IDisposable
|
||||
{
|
||||
public ClientWebSocketOptions Options {
|
||||
get { throw new NotImplementedException (); }
|
||||
}
|
||||
const string Magic = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
||||
const string VersionTag = "13";
|
||||
|
||||
public Task ConnectAsync (Uri uri, CancellationToken cancellationToken)
|
||||
ClientWebSocketOptions options;
|
||||
WebSocketState state;
|
||||
string subProtocol;
|
||||
|
||||
HttpWebRequest req;
|
||||
WebConnection connection;
|
||||
Socket underlyingSocket;
|
||||
|
||||
Random random = new Random ();
|
||||
|
||||
const int HeaderMaxLength = 14;
|
||||
byte[] headerBuffer;
|
||||
byte[] sendBuffer;
|
||||
|
||||
public ClientWebSocket ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
options = new ClientWebSocketOptions ();
|
||||
state = WebSocketState.None;
|
||||
headerBuffer = new byte[HeaderMaxLength];
|
||||
}
|
||||
|
||||
#region implemented abstract members of WebSocket
|
||||
public override void Dispose ()
|
||||
{
|
||||
if (connection != null)
|
||||
connection.Close (false);
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
public override void Abort ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
public override Task CloseAsync (WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
public override Task CloseOutputAsync (WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
public override Task<WebSocketReceiveResult> ReceiveAsync (ArraySegment<byte> buffer, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
public override Task SendAsync (ArraySegment<byte> buffer, WebSocketMessageType messageType, bool endOfMessage, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
public override void Dispose ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
public override WebSocketCloseStatus? CloseStatus {
|
||||
|
||||
public ClientWebSocketOptions Options {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
public override string CloseStatusDescription {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
return options;
|
||||
}
|
||||
}
|
||||
|
||||
public override WebSocketState State {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
public override WebSocketCloseStatus? CloseStatus {
|
||||
get {
|
||||
if (state != WebSocketState.Closed)
|
||||
return (WebSocketCloseStatus?)null;
|
||||
return WebSocketCloseStatus.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public override string CloseStatusDescription {
|
||||
get {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public override string SubProtocol {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
return subProtocol;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public async Task ConnectAsync (Uri uri, CancellationToken cancellationToken)
|
||||
{
|
||||
state = WebSocketState.Connecting;
|
||||
var httpUri = new UriBuilder (uri);
|
||||
if (uri.Scheme == "wss")
|
||||
httpUri.Scheme = "https";
|
||||
else
|
||||
httpUri.Scheme = "http";
|
||||
req = (HttpWebRequest)WebRequest.Create (httpUri.Uri);
|
||||
req.ReuseConnection = true;
|
||||
if (options.Cookies != null)
|
||||
req.CookieContainer = options.Cookies;
|
||||
|
||||
if (options.CustomRequestHeaders.Count > 0) {
|
||||
foreach (var header in options.CustomRequestHeaders)
|
||||
req.Headers[header.Key] = header.Value;
|
||||
}
|
||||
|
||||
var secKey = Convert.ToBase64String (Encoding.ASCII.GetBytes (Guid.NewGuid ().ToString ().Substring (0, 16)));
|
||||
string expectedAccept = Convert.ToBase64String (SHA1.Create ().ComputeHash (Encoding.ASCII.GetBytes (secKey + Magic)));
|
||||
|
||||
req.Headers["Upgrade"] = "WebSocket";
|
||||
req.Headers["Sec-WebSocket-Version"] = VersionTag;
|
||||
req.Headers["Sec-WebSocket-Key"] = secKey;
|
||||
req.Headers["Sec-WebSocket-Origin"] = uri.Host;
|
||||
if (options.SubProtocols.Count > 0)
|
||||
req.Headers["Sec-WebSocket-Protocol"] = string.Join (",", options.SubProtocols);
|
||||
|
||||
if (options.Credentials != null)
|
||||
req.Credentials = options.Credentials;
|
||||
if (options.ClientCertificates != null)
|
||||
req.ClientCertificates = options.ClientCertificates;
|
||||
if (options.Proxy != null)
|
||||
req.Proxy = options.Proxy;
|
||||
req.UseDefaultCredentials = options.UseDefaultCredentials;
|
||||
req.Connection = "Upgrade";
|
||||
|
||||
HttpWebResponse resp = null;
|
||||
try {
|
||||
resp = (HttpWebResponse)(await req.GetResponseAsync ().ConfigureAwait (false));
|
||||
} catch (Exception e) {
|
||||
throw new WebSocketException (WebSocketError.Success, e);
|
||||
}
|
||||
|
||||
connection = req.StoredConnection;
|
||||
underlyingSocket = connection.socket;
|
||||
|
||||
if (resp.StatusCode != HttpStatusCode.SwitchingProtocols)
|
||||
throw new WebSocketException ("The server returned status code '" + (int)resp.StatusCode + "' when status code '101' was expected");
|
||||
if (!string.Equals (resp.Headers["Upgrade"], "WebSocket", StringComparison.OrdinalIgnoreCase)
|
||||
|| !string.Equals (resp.Headers["Connection"], "Upgrade", StringComparison.OrdinalIgnoreCase)
|
||||
|| !string.Equals (resp.Headers["Sec-WebSocket-Accept"], expectedAccept))
|
||||
throw new WebSocketException ("HTTP header error during handshake");
|
||||
if (resp.Headers["Sec-WebSocket-Protocol"] != null) {
|
||||
if (!options.SubProtocols.Contains (resp.Headers["Sec-WebSocket-Protocol"]))
|
||||
throw new WebSocketException (WebSocketError.UnsupportedProtocol);
|
||||
subProtocol = resp.Headers["Sec-WebSocket-Protocol"];
|
||||
}
|
||||
|
||||
state = WebSocketState.Open;
|
||||
}
|
||||
|
||||
public override Task SendAsync (ArraySegment<byte> buffer, WebSocketMessageType messageType, bool endOfMessage, CancellationToken cancellationToken)
|
||||
{
|
||||
EnsureWebSocketConnected ();
|
||||
ValidateArraySegment (buffer);
|
||||
if (connection == null)
|
||||
throw new WebSocketException (WebSocketError.Faulted);
|
||||
var count = Math.Max (options.SendBufferSize, buffer.Count) + HeaderMaxLength;
|
||||
if (sendBuffer == null || sendBuffer.Length != count)
|
||||
sendBuffer = new byte[count];
|
||||
return Task.Run (() => {
|
||||
EnsureWebSocketState (WebSocketState.Open, WebSocketState.CloseReceived);
|
||||
var maskOffset = WriteHeader (messageType, buffer, endOfMessage);
|
||||
|
||||
if (buffer.Count > 0)
|
||||
MaskData (buffer, maskOffset);
|
||||
//underlyingSocket.Send (headerBuffer, 0, maskOffset + 4, SocketFlags.None);
|
||||
var headerLength = maskOffset + 4;
|
||||
Array.Copy (headerBuffer, sendBuffer, headerLength);
|
||||
underlyingSocket.Send (sendBuffer, 0, buffer.Count + headerLength, SocketFlags.None);
|
||||
});
|
||||
}
|
||||
|
||||
public override Task<WebSocketReceiveResult> ReceiveAsync (ArraySegment<byte> buffer, CancellationToken cancellationToken)
|
||||
{
|
||||
EnsureWebSocketConnected ();
|
||||
ValidateArraySegment (buffer);
|
||||
return Task.Run (() => {
|
||||
EnsureWebSocketState (WebSocketState.Open, WebSocketState.CloseSent);
|
||||
// First read the two first bytes to know what we are doing next
|
||||
connection.Read (req, headerBuffer, 0, 2);
|
||||
var isLast = (headerBuffer[0] >> 7) > 0;
|
||||
var isMasked = (headerBuffer[1] >> 7) > 0;
|
||||
int mask = 0;
|
||||
var type = (WebSocketMessageType)(headerBuffer[0] & 0xF);
|
||||
long length = headerBuffer[1] & 0x7F;
|
||||
int offset = 0;
|
||||
if (length == 126) {
|
||||
offset = 2;
|
||||
connection.Read (req, headerBuffer, 2, offset);
|
||||
length = (headerBuffer[2] << 8) | headerBuffer[3];
|
||||
} else if (length == 127) {
|
||||
offset = 8;
|
||||
connection.Read (req, headerBuffer, 2, offset);
|
||||
length = 0;
|
||||
for (int i = 2; i <= 9; i++)
|
||||
length = (length << 8) | headerBuffer[i];
|
||||
}
|
||||
|
||||
if (isMasked) {
|
||||
connection.Read (req, headerBuffer, 2 + offset, 4);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
var pos = i + offset + 2;
|
||||
mask = (mask << 8) | headerBuffer[pos];
|
||||
}
|
||||
}
|
||||
|
||||
if (type == WebSocketMessageType.Close) {
|
||||
state = WebSocketState.Closed;
|
||||
var tmpBuffer = new byte[length];
|
||||
connection.Read (req, tmpBuffer, 0, tmpBuffer.Length);
|
||||
var closeStatus = (WebSocketCloseStatus)(tmpBuffer[0] << 8 | tmpBuffer[1]);
|
||||
var closeDesc = tmpBuffer.Length > 2 ? Encoding.UTF8.GetString (tmpBuffer, 2, tmpBuffer.Length - 2) : string.Empty;
|
||||
return new WebSocketReceiveResult ((int)length, type, isLast, closeStatus, closeDesc);
|
||||
} else {
|
||||
var readLength = (int)(buffer.Count < length ? buffer.Count : length);
|
||||
connection.Read (req, buffer.Array, buffer.Offset, readLength);
|
||||
|
||||
return new WebSocketReceiveResult ((int)length, type, isLast);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// The damn difference between those two methods is that CloseAsync will wait for server acknowledgement before completing
|
||||
// while CloseOutputAsync will send the close packet and simply complete.
|
||||
|
||||
public async override Task CloseAsync (WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken)
|
||||
{
|
||||
EnsureWebSocketConnected ();
|
||||
await SendCloseFrame (closeStatus, statusDescription, cancellationToken).ConfigureAwait (false);
|
||||
state = WebSocketState.CloseSent;
|
||||
// TODO: figure what's exceptions are thrown if the server returns something faulty here
|
||||
await ReceiveAsync (new ArraySegment<byte> (new byte[0]), cancellationToken).ConfigureAwait (false);
|
||||
state = WebSocketState.Closed;
|
||||
}
|
||||
|
||||
public async override Task CloseOutputAsync (WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken)
|
||||
{
|
||||
EnsureWebSocketConnected ();
|
||||
await SendCloseFrame (closeStatus, statusDescription, cancellationToken).ConfigureAwait (false);
|
||||
state = WebSocketState.CloseSent;
|
||||
}
|
||||
|
||||
async Task SendCloseFrame (WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken)
|
||||
{
|
||||
var statusDescBuffer = string.IsNullOrEmpty (statusDescription) ? new byte[2] : new byte[2 + Encoding.UTF8.GetByteCount (statusDescription)];
|
||||
statusDescBuffer[0] = (byte)(((ushort)closeStatus) >> 8);
|
||||
statusDescBuffer[1] = (byte)(((ushort)closeStatus) & 0xFF);
|
||||
if (!string.IsNullOrEmpty (statusDescription))
|
||||
Encoding.UTF8.GetBytes (statusDescription, 0, statusDescription.Length, statusDescBuffer, 2);
|
||||
await SendAsync (new ArraySegment<byte> (statusDescBuffer), WebSocketMessageType.Close, true, cancellationToken).ConfigureAwait (false);
|
||||
}
|
||||
|
||||
int WriteHeader (WebSocketMessageType type, ArraySegment<byte> buffer, bool endOfMessage)
|
||||
{
|
||||
var opCode = (byte)type;
|
||||
var length = buffer.Count;
|
||||
|
||||
headerBuffer[0] = (byte)(opCode | (endOfMessage ? 0 : 0x80));
|
||||
if (length < 126) {
|
||||
headerBuffer[1] = (byte)length;
|
||||
} else if (length <= ushort.MaxValue) {
|
||||
headerBuffer[1] = (byte)126;
|
||||
headerBuffer[2] = (byte)(length / 256);
|
||||
headerBuffer[3] = (byte)(length % 256);
|
||||
} else {
|
||||
headerBuffer[1] = (byte)127;
|
||||
|
||||
int left = length;
|
||||
int unit = 256;
|
||||
|
||||
for (int i = 9; i > 1; i--) {
|
||||
headerBuffer[i] = (byte)(left % unit);
|
||||
left = left / unit;
|
||||
}
|
||||
}
|
||||
|
||||
var l = Math.Max (0, headerBuffer[1] - 125);
|
||||
var maskOffset = 2 + l * l * 2;
|
||||
GenerateMask (headerBuffer, maskOffset);
|
||||
|
||||
// Since we are client only, we always mask the payload
|
||||
headerBuffer[1] |= 0x80;
|
||||
|
||||
return maskOffset;
|
||||
}
|
||||
|
||||
void GenerateMask (byte[] mask, int offset)
|
||||
{
|
||||
mask[offset + 0] = (byte)random.Next (0, 255);
|
||||
mask[offset + 1] = (byte)random.Next (0, 255);
|
||||
mask[offset + 2] = (byte)random.Next (0, 255);
|
||||
mask[offset + 3] = (byte)random.Next (0, 255);
|
||||
}
|
||||
|
||||
void MaskData (ArraySegment<byte> buffer, int maskOffset)
|
||||
{
|
||||
var sendBufferOffset = maskOffset + 4;
|
||||
for (var i = 0; i < buffer.Count; i++)
|
||||
sendBuffer[i + sendBufferOffset] = (byte)(buffer.Array[buffer.Offset + i] ^ headerBuffer[maskOffset + (i % 4)]);
|
||||
}
|
||||
|
||||
void EnsureWebSocketConnected ()
|
||||
{
|
||||
if (state < WebSocketState.Open)
|
||||
throw new InvalidOperationException ("The WebSocket is not connected");
|
||||
}
|
||||
|
||||
void EnsureWebSocketState (params WebSocketState[] validStates)
|
||||
{
|
||||
foreach (var validState in validStates)
|
||||
if (state == validState)
|
||||
return;
|
||||
throw new WebSocketException ("The WebSocket is in an invalid state ('" + state + "') for this operation. Valid states are: " + string.Join (", ", validStates));
|
||||
}
|
||||
|
||||
void ValidateArraySegment (ArraySegment<byte> segment)
|
||||
{
|
||||
if (segment.Array == null)
|
||||
throw new ArgumentNullException ("buffer.Array");
|
||||
if (segment.Offset < 0)
|
||||
throw new ArgumentOutOfRangeException ("buffer.Offset");
|
||||
if (segment.Offset + segment.Count > segment.Array.Length)
|
||||
throw new ArgumentOutOfRangeException ("buffer.Count");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -33,11 +33,15 @@ using System.Net;
|
||||
using System.Security.Principal;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace System.Net.WebSockets
|
||||
{
|
||||
public sealed class ClientWebSocketOptions
|
||||
{
|
||||
List<string> subprotocols = new List<string> ();
|
||||
Dictionary<string, string> customRequestHeaders = new Dictionary<string, string> ();
|
||||
|
||||
public X509CertificateCollection ClientCertificates { get; set; }
|
||||
|
||||
public CookieContainer Cookies { get; set; }
|
||||
@@ -50,28 +54,53 @@ namespace System.Net.WebSockets
|
||||
|
||||
public bool UseDefaultCredentials { get; set; }
|
||||
|
||||
[MonoTODO]
|
||||
internal IList<string> SubProtocols {
|
||||
get {
|
||||
return subprotocols.AsReadOnly ();
|
||||
}
|
||||
}
|
||||
|
||||
internal Dictionary<string, string> CustomRequestHeaders {
|
||||
get {
|
||||
return customRequestHeaders;
|
||||
}
|
||||
}
|
||||
|
||||
internal int ReceiveBufferSize {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
internal ArraySegment<byte> CustomReceiveBuffer {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
internal int SendBufferSize {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public void AddSubProtocol (string subProtocol)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
subprotocols.Add (subProtocol);
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
public void SetBuffer (int receiveBufferSize, int sendBufferSize)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
SetBuffer (receiveBufferSize, sendBufferSize, new ArraySegment<byte> ());
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
public void SetBuffer (int receiveBufferSize, int sendBufferSize, ArraySegment<byte> buffer)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
ReceiveBufferSize = receiveBufferSize;
|
||||
SendBufferSize = sendBufferSize;
|
||||
CustomReceiveBuffer = buffer;
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
public void SetRequestHeader (string headerName, string headerValue)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
customRequestHeaders[headerName] = headerValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,72 +36,68 @@ namespace System.Net.WebSockets
|
||||
{
|
||||
public sealed class WebSocketException : Win32Exception
|
||||
{
|
||||
public WebSocketException ()
|
||||
const string DefaultMessage = "Generic WebSocket exception";
|
||||
|
||||
public WebSocketException () : this (WebSocketError.Success, -1, DefaultMessage, null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public WebSocketException (int nativeError) : base (nativeError)
|
||||
public WebSocketException (int nativeError) : this (WebSocketError.Success, nativeError, DefaultMessage, null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public WebSocketException (string message) : base (message)
|
||||
public WebSocketException (string message) : this (WebSocketError.Success, -1, message, null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public WebSocketException (WebSocketError error)
|
||||
public WebSocketException (WebSocketError error) : this (error, -1, DefaultMessage, null)
|
||||
{
|
||||
WebSocketErrorCode = error;
|
||||
}
|
||||
|
||||
public WebSocketException (int nativeError, Exception innerException)
|
||||
public WebSocketException (int nativeError, Exception innerException) : this (WebSocketError.Success, nativeError, DefaultMessage, innerException)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public WebSocketException (int nativeError, string message) : base (nativeError, message)
|
||||
public WebSocketException (int nativeError, string message) : this (WebSocketError.Success, nativeError, message, null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public WebSocketException (string message, Exception innerException) : base (message, innerException)
|
||||
public WebSocketException (string message, Exception innerException) : this (WebSocketError.Success, -1, message, innerException)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public WebSocketException (WebSocketError error, Exception innerException)
|
||||
public WebSocketException (WebSocketError error, Exception innerException) : this (error, -1, DefaultMessage, innerException)
|
||||
{
|
||||
WebSocketErrorCode = error;
|
||||
|
||||
}
|
||||
|
||||
public WebSocketException (WebSocketError error, int nativeError) : base (nativeError)
|
||||
public WebSocketException (WebSocketError error, int nativeError) : this (error, nativeError, DefaultMessage, null)
|
||||
{
|
||||
WebSocketErrorCode = error;
|
||||
}
|
||||
|
||||
public WebSocketException (WebSocketError error, string message) : base (message)
|
||||
public WebSocketException (WebSocketError error, string message) : this (error, -1, message, null)
|
||||
{
|
||||
WebSocketErrorCode = error;
|
||||
}
|
||||
|
||||
public WebSocketException (WebSocketError error, int nativeError, Exception innerException) : base (nativeError)
|
||||
public WebSocketException (WebSocketError error, int nativeError, Exception innerException) : this (error, nativeError, DefaultMessage, innerException)
|
||||
{
|
||||
WebSocketErrorCode = error;
|
||||
}
|
||||
|
||||
public WebSocketException (WebSocketError error, int nativeError, string message) : base (nativeError, message)
|
||||
public WebSocketException (WebSocketError error, int nativeError, string message) : this (error, nativeError, message, null)
|
||||
{
|
||||
WebSocketErrorCode = error;
|
||||
}
|
||||
|
||||
public WebSocketException (WebSocketError error, string message, Exception innerException)
|
||||
public WebSocketException (WebSocketError error, string message, Exception innerException) : this (error, -1, message, innerException)
|
||||
{
|
||||
WebSocketErrorCode = error;
|
||||
}
|
||||
|
||||
public WebSocketException (WebSocketError error, int nativeError, string message, Exception innerException) : base (nativeError, message)
|
||||
public WebSocketException (WebSocketError error, int nativeError, string message, Exception innerException) : base (message, innerException)
|
||||
{
|
||||
WebSocketErrorCode = error;
|
||||
}
|
||||
|
||||
@@ -35,9 +35,9 @@ namespace System.Net.WebSockets
|
||||
{
|
||||
public enum WebSocketMessageType
|
||||
{
|
||||
Text,
|
||||
Binary,
|
||||
Close
|
||||
Text = 1,
|
||||
Binary = 2,
|
||||
Close = 8
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loaded 100 of 416 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user