mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-16 17:10:20 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
378032bf64 | ||
|
|
a19eb0760b | ||
|
|
5cfc62f415 | ||
|
|
1ed1c4bed1 | ||
|
|
616f648f0d | ||
|
|
4fccd4d599 | ||
|
|
bd4f80e803 | ||
|
|
9e9b3f913d | ||
|
|
a2a168e5f3 | ||
|
|
5f982b1908 | ||
|
|
f00202d3e3 | ||
|
|
b4d4033040 | ||
|
|
68deb6335e | ||
|
|
cb965a9d3a | ||
|
|
86262ef424 | ||
|
|
acfa4856b9 | ||
|
|
be8711a7e6 | ||
|
|
7e6a0ff51e | ||
|
|
c989e10293 | ||
|
|
b04d809478 | ||
|
|
219276c182 | ||
|
|
64ff652330 | ||
|
|
75e3ca80bc | ||
|
|
aa48b6f714 | ||
|
|
2603a2e4fd | ||
|
|
05550e7c66 | ||
|
|
99349445b1 | ||
|
|
d768dd0125 | ||
|
|
e376d9156b | ||
|
|
85349b801f | ||
|
|
41d1be9f34 | ||
|
|
ac19d5bfaf | ||
|
|
ae7d005dfc | ||
|
|
04427d962d | ||
|
|
57bc2f6ffb | ||
|
|
059a6a685b | ||
|
|
4ac77ca819 | ||
|
|
d703e86b4b | ||
|
|
6870a59952 | ||
|
|
721dadd34b | ||
|
|
b7061d3e57 | ||
|
|
2f4099863e | ||
|
|
96e0c59371 | ||
|
|
1e910229a8 | ||
|
|
c74031105a | ||
|
|
279678d726 | ||
|
|
46db32524d | ||
|
|
0563034987 | ||
|
|
0baf32151f | ||
|
|
8bd9eebf1f | ||
|
|
b9a5b85c16 | ||
|
|
c98be1ad12 | ||
|
|
67b1fcec06 | ||
|
|
4643f66d1a | ||
|
|
e3aa857b74 | ||
|
|
350fcbd003 | ||
|
|
c6799b1f41 | ||
|
|
f260ff4299 | ||
|
|
7122b78d60 | ||
|
|
52971cce4c | ||
|
|
5dc77749e7 | ||
|
|
472b3e6fca | ||
|
|
59b4c5bc3d | ||
|
|
f105c6d4e7 | ||
|
|
2e637c4cba | ||
|
|
8d44e61042 | ||
|
|
eac9866b2c | ||
|
|
7ada4aec7b | ||
|
|
dacb11a24c | ||
|
|
5c44041365 | ||
|
|
56b901df8f | ||
|
|
582bd35450 | ||
|
|
6057352d91 | ||
|
|
3b450189bb | ||
|
|
7878c22bbf | ||
|
|
674372dd15 | ||
|
|
af804a9305 | ||
|
|
7e2eff0be7 | ||
|
|
7de999655d | ||
|
|
1b84abfcab | ||
|
|
8286cbf198 | ||
|
|
db7d7c47cb | ||
|
|
9445d6e22c | ||
|
|
209c253e3f | ||
|
|
e449d41158 | ||
|
|
9b4a07a69e | ||
|
|
28766cfe96 | ||
|
|
a95adaf53d | ||
|
|
7ae2112edc | ||
|
|
79b99d358b | ||
|
|
12fedc8ee6 | ||
|
|
27589a4031 | ||
|
|
f12adef20c | ||
|
|
049efb2da8 | ||
|
|
d41b9d61c2 | ||
|
|
71b1f58d41 | ||
|
|
f983186526 | ||
|
|
c726c88f32 | ||
|
|
3cb9ce92bc | ||
|
|
2504797e50 | ||
|
|
67ebb6a498 | ||
|
|
d9e839c91b | ||
|
|
fd65ec9388 | ||
|
|
7a0052ae2f | ||
|
|
ec0e9d7771 | ||
|
|
4325b8151a | ||
|
|
482e406319 | ||
|
|
e421b10a3d | ||
|
|
55c4b01d95 | ||
|
|
a5610cbed1 | ||
|
|
fc9e1be0b3 | ||
|
|
9b9fef57d9 | ||
|
|
99b87f07af | ||
|
|
9a69207087 | ||
|
|
4cfb3889f8 | ||
|
|
0a7f80fb0a | ||
|
|
df66c40aaa | ||
|
|
9b3e4f9034 | ||
|
|
89dad63b0f | ||
|
|
9636231dda | ||
|
|
a2d896ec4e | ||
|
|
66187b25b6 | ||
|
|
f3deab1057 | ||
|
|
5a9f5defc3 | ||
|
|
e43a74ae3f | ||
|
|
06cd95ea65 | ||
|
|
7d088a3f17 | ||
|
|
0ddabfc4ab | ||
|
|
8078626d49 | ||
|
|
ffad7f7365 | ||
|
|
da2f5156b2 | ||
|
|
e3578fe451 | ||
|
|
036c395d3c | ||
|
|
474417efb7 | ||
|
|
23263e537f | ||
|
|
c98cedfc91 | ||
|
|
2228af8148 | ||
|
|
c6bbff5b5e | ||
|
|
1b58ec73aa | ||
|
|
f49164bf76 | ||
|
|
1ae6c346f6 | ||
|
|
45064beb94 | ||
|
|
8bd7d107a8 | ||
|
|
d465c35811 | ||
|
|
fcff387c6a | ||
|
|
513122c74e | ||
|
|
d68521e673 | ||
|
|
c5302ba6b6 | ||
|
|
70352e16a9 | ||
|
|
150ea5489d | ||
|
|
dd4afcfa02 | ||
|
|
a15e2d0bec | ||
|
|
1e7567b332 | ||
|
|
1dba37de1c | ||
|
|
bfdd13a52c | ||
|
|
a26b65f6b3 | ||
|
|
36f12fc250 | ||
|
|
8c253ee6c3 | ||
|
|
fb497cbb65 | ||
|
|
11bacf8e1b | ||
|
|
2599353bc0 | ||
|
|
9f92b788d8 | ||
|
|
c584c82e0d | ||
|
|
aa4803c5a4 | ||
|
|
816556dbb8 | ||
|
|
d9ecc66fb6 | ||
|
|
f333e91d0a | ||
|
|
f87620d145 | ||
|
|
8bd567de14 | ||
|
|
28a61a5d55 | ||
|
|
d25c23dc46 | ||
|
|
481881bdf7 | ||
|
|
44ab43948a | ||
|
|
643c0f0cba | ||
|
|
da0d698fce | ||
|
|
6f1458dea4 | ||
|
|
72e554c612 | ||
|
|
e54a124e71 | ||
|
|
62e6bd03f6 | ||
|
|
be2e765af8 | ||
|
|
c5b95f4bbb | ||
|
|
b8e85ce171 | ||
|
|
a2b093a9a1 | ||
|
|
8481eefe9f | ||
|
|
9f612740f7 | ||
|
|
cb4b62c04b | ||
|
|
c51e257674 | ||
|
|
40ca71a120 | ||
|
|
cc81b58a0e | ||
|
|
70640f232b | ||
|
|
949e910102 | ||
|
|
395aae632d | ||
|
|
ce9ff91f78 | ||
|
|
f1861e5cbe | ||
|
|
79bca55588 | ||
|
|
3e48da364b | ||
|
|
8b88042311 | ||
|
|
352e7d076d | ||
|
|
d4a6887c31 | ||
|
|
6813d3f09b | ||
|
|
81d20479d4 | ||
|
|
1ff53bb1ba | ||
|
|
927a76eb30 | ||
|
|
050abd469f | ||
|
|
127c3bf6e0 | ||
|
|
cbd9da1acf | ||
|
|
71b1425fd5 | ||
|
|
89424f5b25 | ||
|
|
86d31a6e3f | ||
|
|
84265522ed | ||
|
|
662a9ac8f7 | ||
|
|
33068b3d07 | ||
|
|
db9f31cbd1 | ||
|
|
5b3336a997 | ||
|
|
6920d7ce86 | ||
|
|
1da10df16c | ||
|
|
7f2cf89aeb | ||
|
|
3e629f2ac7 | ||
|
|
3c5a13fa39 | ||
|
|
46c26749eb | ||
|
|
a2d8112081 | ||
|
|
bb331ddde1 | ||
|
|
300bc2d4b0 | ||
|
|
f88fba3cbd | ||
|
|
7b58e280a5 | ||
|
|
8dd637646f | ||
|
|
77625cbc89 | ||
|
|
b122da385a | ||
|
|
eac15568e2 | ||
|
|
fb67d391a3 | ||
|
|
7129d57c22 | ||
|
|
9e88fe782a | ||
|
|
91de42214b | ||
|
|
02b82fb567 | ||
|
|
9fc2d82c3b | ||
|
|
1aebe941ef | ||
|
|
9c1b923e99 | ||
|
|
6adda4d4c0 | ||
|
|
5a8f29cbcc | ||
|
|
aa2208afee | ||
|
|
a1e3732cef | ||
|
|
8bb3b4db45 | ||
|
|
240c0124a6 | ||
|
|
52965a2b9d | ||
|
|
bed33dd66b | ||
|
|
c0f3997eaf | ||
|
|
29adf41cc2 | ||
|
|
0f6b274a8e | ||
|
|
34b7d3a84d | ||
|
|
3afbf58c92 | ||
|
|
9193bf8f3f | ||
|
|
2b487789c8 | ||
|
|
6b6ce9bd43 | ||
|
|
fbe4e20182 | ||
|
|
d753eb1861 | ||
|
|
aac2016aa9 | ||
|
|
2ec26f2e77 | ||
|
|
9e48c8a2b0 | ||
|
|
f1ab82a7e8 | ||
|
|
c4a3ecad74 | ||
|
|
844d678cba | ||
|
|
d3c5cc1fe5 | ||
|
|
01cf5ded25 | ||
|
|
399a6c779e | ||
|
|
516cbf29c4 | ||
|
|
63fc3530b9 | ||
|
|
0ae09ac40d | ||
|
|
c9cb0a918b | ||
|
|
c538edd457 | ||
|
|
718f02e0d3 | ||
|
|
f3560b3f22 | ||
|
|
8b18364cfb | ||
|
|
e7ff9bcf14 | ||
|
|
546a888f91 | ||
|
|
b0c3795ac4 | ||
|
|
19f4433ef2 | ||
|
|
b09e63d792 | ||
|
|
5e04bc52bb | ||
|
|
2773f9f10a | ||
|
|
cf183438ee | ||
|
|
c18ad33d44 | ||
|
|
9956130fa2 | ||
|
|
50ad936a80 | ||
|
|
acb4203da5 | ||
|
|
a6e6fbbeb3 | ||
|
|
02e0ab3df8 | ||
|
|
a66df5bf91 | ||
|
|
ef49022f97 | ||
|
|
4d2ff35b88 | ||
|
|
1e08457302 | ||
|
|
59dd3fcfe8 | ||
|
|
35a659b435 | ||
|
|
01fff28591 | ||
|
|
acad9c91d0 | ||
|
|
ea73a5a1e4 | ||
|
|
6c5f273c3f | ||
|
|
512ca45eb9 | ||
|
|
67c3b641c2 | ||
|
|
bb61f41996 | ||
|
|
8dfa7d2c7e | ||
|
|
046ff98055 | ||
|
|
cde89bb093 | ||
|
|
9eb77b093b | ||
|
|
5e40958c3b | ||
|
|
82b1e211f8 | ||
|
|
3fd521bd7d | ||
|
|
cdc0fc4d45 | ||
|
|
43c40b6f3d | ||
|
|
2e5417f5bd | ||
|
|
247cef557f | ||
|
|
0f328b26c0 | ||
|
|
415027eedd | ||
|
|
1223efd9ce | ||
|
|
27e1844bb9 | ||
|
|
054738b20f | ||
|
|
58a60f9e5e | ||
|
|
df413084ff | ||
|
|
b029f4e97e | ||
|
|
4b98bcb536 | ||
|
|
c597bb43ac | ||
|
|
f66017dd16 | ||
|
|
0990c54b02 | ||
|
|
1cf432ed50 | ||
|
|
eb9c5951e6 | ||
|
|
6a1de942e0 | ||
|
|
b62fb2816f | ||
|
|
d3a50832b1 | ||
|
|
d911500226 | ||
|
|
657c31a31b | ||
|
|
851c79f6e6 | ||
|
|
3fedcf496b | ||
|
|
1562106ccd | ||
|
|
90922a746d | ||
|
|
e54906aaf2 | ||
|
|
6f9f05df58 |
No files matched your search
+2
-2
@@ -57,11 +57,11 @@ function setup ()
|
||||
CROSS_DLL_DIR="$CROSS_DIR/bin"
|
||||
PATH=$CROSS_BIN_DIR:$PATH
|
||||
|
||||
MONO_VERSION=`grep AM_INIT_AUTOMAKE configure.in | cut -d ',' -f 2|tr -d '\)'`
|
||||
MONO_VERSION=`grep AM_INIT_AUTOMAKE configure.in | cut -d ',' -f 2|tr -d '\)'|tr -d '\('`
|
||||
|
||||
if [ -d ./.git ]; then
|
||||
MONO_GIT_COMMIT="`git log -1 --format=format:%t`"
|
||||
MONO_GIT_BRANCH="`git branch|grep '\*'|cut -d ' ' -f 2`"
|
||||
MONO_GIT_BRANCH="`git branch|grep '\*'|cut -d ' ' -f 2|tr -d '\)'|tr -d '\('`"
|
||||
MONO_RELEASE="$MONO_VERSION-$MONO_GIT_BRANCH-$MONO_GIT_COMMIT"
|
||||
else
|
||||
MONO_RELEASE="$MONO_VERSION"
|
||||
|
||||
+104
-9
@@ -6,7 +6,7 @@ AC_CANONICAL_SYSTEM
|
||||
m4_ifdef([_A][M_PROG_TAR],[_A][M_SET_OPTION([tar-ustar])])
|
||||
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
AM_INIT_AUTOMAKE(mono,2.10.2)
|
||||
AM_INIT_AUTOMAKE(mono,2.10.6)
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
API_VER=2.0
|
||||
@@ -78,6 +78,7 @@ esac
|
||||
|
||||
host_win32=no
|
||||
target_win32=no
|
||||
platform_android=no
|
||||
case "$host" in
|
||||
*-mingw*|*-*-cygwin*)
|
||||
AC_DEFINE(HOST_WIN32,1,[Host Platform is Win32])
|
||||
@@ -172,6 +173,41 @@ case "$host" in
|
||||
with_sigaltstack=no
|
||||
use_sigposix=yes
|
||||
;;
|
||||
*-*-linux-android*)
|
||||
host_win32=no
|
||||
platform_android=yes
|
||||
AC_DEFINE(PLATFORM_ANDROID,1,[Targeting the Android platform])
|
||||
AC_DEFINE(TARGET_ANDROID,1,[Targeting the Android platform])
|
||||
|
||||
CPPFLAGS="$CPPFLAGS -DGC_LINUX_THREADS -D_GNU_SOURCE -D_REENTRANT -DUSE_MMAP"
|
||||
if test "x$disable_munmap" != "xyes"; then
|
||||
CPPFLAGS="$CPPFLAGS -DUSE_MUNMAP"
|
||||
fi
|
||||
libmono_cflags="-D_REENTRANT"
|
||||
libdl="-ldl"
|
||||
libgc_threads=pthreads
|
||||
use_sigposix=yes
|
||||
|
||||
with_tls=pthread
|
||||
with_sigaltstack=no
|
||||
with_static_mono=no
|
||||
|
||||
# Android doesn't support boehm, as it's missing <link.h>
|
||||
support_boehm=no
|
||||
with_gc=sgen
|
||||
|
||||
# isinf(3) requires -lm; see isinf check below
|
||||
LDFLAGS="$LDFLAGS -lm"
|
||||
|
||||
# Bionic's <pthread.h> sets PTHREAD_STACK_MIN=2*PAGE_SIZE; doesn't define
|
||||
# PAGE_SIZE; breaks mono/io-layer/collection.c
|
||||
# Bionic doesn't provide S_IWRITE; breaks io-layer/io.c
|
||||
CFLAGS="$CFLAGS -DPAGE_SIZE=4096 -DS_IWRITE=S_IWUSR"
|
||||
CXXFLAGS="$CXXFLAGS -DPAGE_SIZE=4096 -DS_IWRITE=S_IWUSR"
|
||||
|
||||
# to bypass the underscore linker check, can't work when cross-compiling
|
||||
mono_cv_uscore=yes
|
||||
;;
|
||||
*-*-linux*)
|
||||
host_win32=no
|
||||
CPPFLAGS="$CPPFLAGS -DGC_LINUX_THREADS -D_GNU_SOURCE -D_REENTRANT -DUSE_MMAP"
|
||||
@@ -248,12 +284,12 @@ case "$host" in
|
||||
if test "x$cross_compiling" = "xyes"; then
|
||||
has_broken_apple_cpp=yes
|
||||
fi
|
||||
dnl Snow Leopard is horribly broken -- it reports itself as i386-apple-darwin10.0.0, but
|
||||
dnl Snow Leopard is horribly broken -- it reports itself as i386-apple-darwin*, but
|
||||
dnl its gcc defaults to 64-bit mode. They have also deprecated the usage of ucontext
|
||||
dnl we need to set some flags to build our 32-bit binaries on 10.6 properly
|
||||
case "$host" in
|
||||
dnl Snow Leopard config.guess reports as this
|
||||
i*86-*-darwin10*)
|
||||
dnl Snow Leopard and newer config.guess reports as this
|
||||
i*86-*-darwin*)
|
||||
BROKEN_DARWIN_FLAGS="-arch i386 -D_XOPEN_SOURCE -mmacosx-version-min=10.5"
|
||||
CPPFLAGS="$CPPFLAGS $BROKEN_DARWIN_FLAGS"
|
||||
CFLAGS="$CFLAGS $BROKEN_DARWIN_FLAGS"
|
||||
@@ -294,6 +330,7 @@ AM_CONDITIONAL(TARGET_WIN32, test x$target_win32 = xyes)
|
||||
AM_CONDITIONAL(PLATFORM_LINUX, echo x$target_os | grep -q linux)
|
||||
AM_CONDITIONAL(PLATFORM_DARWIN, test x$platform_darwin = xyes)
|
||||
AM_CONDITIONAL(PLATFORM_SIGPOSIX, test x$use_sigposix = xyes)
|
||||
AM_CONDITIONAL(PLATFORM_ANDROID, test x$platform_android = xyes)
|
||||
|
||||
AC_CHECK_TOOL(CC, gcc, gcc)
|
||||
AC_PROG_CC
|
||||
@@ -443,6 +480,20 @@ if test x"$GCC" = xyes; then
|
||||
AC_MSG_RESULT(no)
|
||||
CFLAGS=$ORIG_CFLAGS
|
||||
])
|
||||
|
||||
ORIG_CFLAGS=$CFLAGS
|
||||
# Check for the normal version, since gcc ignores unknown -Wno options
|
||||
CFLAGS="$CFLAGS -Wunused-but-set-variable"
|
||||
AC_MSG_CHECKING(for -Wno-unused-but-set-variable option to gcc)
|
||||
AC_TRY_COMPILE([], [
|
||||
void main () { }
|
||||
], [
|
||||
AC_MSG_RESULT(yes)
|
||||
CFLAGS="$ORIG_CFLAGS -Wno-unused-but-set-variable"
|
||||
], [
|
||||
AC_MSG_RESULT(no)
|
||||
CFLAGS=$ORIG_CFLAGS
|
||||
])
|
||||
else
|
||||
# The Sun Forte compiler complains about inline functions that access static variables
|
||||
# so disable all inlining.
|
||||
@@ -657,7 +708,7 @@ DISABLED_FEATURES=none
|
||||
|
||||
AC_ARG_ENABLE(minimal, [ --enable-minimal=LIST drop support for LIST subsystems.
|
||||
LIST is a comma-separated list from: aot, profiler, decimal, pinvoke, debug,
|
||||
reflection_emit, reflection_emit_save, large_code, logging, com, ssa, generics, attach, jit, simd, soft_debug, normalization, assembly_remapping.],
|
||||
reflection_emit, reflection_emit_save, large_code, logging, com, ssa, generics, attach, jit, simd, soft_debug, normalization, assembly_remapping, shared_perfcounters.],
|
||||
[
|
||||
for feature in `echo "$enable_minimal" | sed -e "s/,/ /g"`; do
|
||||
eval "mono_feature_disable_$feature='yes'"
|
||||
@@ -782,6 +833,11 @@ if test "x$mono_feature_disable_assembly_remapping" = "xyes"; then
|
||||
AC_MSG_NOTICE([Disabled Assembly remapping.])
|
||||
fi
|
||||
|
||||
if test "x$mono_feature_disable_shared_perfcounters" = "xyes"; then
|
||||
AC_DEFINE(DISABLE_SHARED_PERFCOUNTERS, 1, [Disable shared perfcounters.])
|
||||
AC_MSG_NOTICE([Disabled Shared perfcounters.])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING(for visibility __attribute__)
|
||||
AC_TRY_COMPILE([], [
|
||||
void __attribute__ ((visibility ("hidden"))) doit (void) {}
|
||||
@@ -813,6 +869,9 @@ if test x$enable_parallel_mark = xyes; then
|
||||
libgc_configure_args="$libgc_configure_args --enable-parallel-mark"
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(boehm, [ --disable-boehm Disable the Boehm GC.], support_boehm=$enableval,support_boehm=${support_boehm:-yes})
|
||||
AM_CONDITIONAL(SUPPORT_BOEHM, test x$support_boehm = xyes)
|
||||
|
||||
dnl
|
||||
dnl Boehm GC configuration
|
||||
dnl
|
||||
@@ -2304,12 +2363,12 @@ case "$host" in
|
||||
esac
|
||||
|
||||
if test "x$host" != "x$target"; then
|
||||
AC_DEFINE(MONO_CROSS_COMPILE,1,[The runtime is compiled for cross-compiling mode])
|
||||
case "$target" in
|
||||
powerpc64-ps3-linux-gnu)
|
||||
TARGET=POWERPC64
|
||||
arch_target=powerpc64
|
||||
AC_DEFINE(TARGET_PS3, 1, [...])
|
||||
AC_DEFINE(MONO_CROSS_COMPILE,1,[The runtime is compiled for cross-compiling mode])
|
||||
# It would be better to just use TARGET_POWERPC64, but lots of code already
|
||||
# uses this define
|
||||
AC_DEFINE(__mono_ppc64__, 1, [...])
|
||||
@@ -2322,7 +2381,6 @@ if test "x$host" != "x$target"; then
|
||||
TARGET=POWERPC64
|
||||
arch_target=powerpc64
|
||||
AC_DEFINE(TARGET_XBOX360, 1, [...])
|
||||
AC_DEFINE(MONO_CROSS_COMPILE,1,[The runtime is compiled for cross-compiling mode])
|
||||
# It would be better to just use TARGET_POWERPC64, but lots of code already
|
||||
# uses this define
|
||||
sizeof_register=8
|
||||
@@ -2332,12 +2390,49 @@ if test "x$host" != "x$target"; then
|
||||
TARGET=AMD64
|
||||
arch_target=amd64
|
||||
AC_DEFINE(TARGET_AMD64, 1, [...])
|
||||
AC_DEFINE(MONO_CROSS_COMPILE,1,[The runtime is compiled for cross-compiling mode])
|
||||
AC_DEFINE(__mono_ilp32__, 1, [64 bit mode with 4 byte longs and pointers])
|
||||
sizeof_register=8
|
||||
;;
|
||||
armv7l-unknown-linux-gnueabi*)
|
||||
# TEGRA
|
||||
TARGET=ARM;
|
||||
arch_target=arm;
|
||||
AC_DEFINE(TARGET_ARM, 1, [...])
|
||||
ACCESS_UNALIGNED="no"
|
||||
JIT_SUPPORTED=yes
|
||||
CPPFLAGS="$CPPFLAGS -DARM_FPU_VFP=1 -D__ARM_EABI__"
|
||||
jit_wanted=true
|
||||
# Can't use tls, since it depends on the runtime detection of tls offsets
|
||||
# in mono-compiler.h
|
||||
with_tls=pthread
|
||||
;;
|
||||
armv5tel-unknown-linux-gnueabi*)
|
||||
TARGET=ARM;
|
||||
arch_target=arm;
|
||||
AC_DEFINE(TARGET_ARM, 1, [...])
|
||||
ACCESS_UNALIGNED="no"
|
||||
JIT_SUPPORTED=yes
|
||||
CPPFLAGS="$CPPFLAGS -D__ARM_EABI__"
|
||||
jit_wanted=true
|
||||
# Can't use tls, since it depends on the runtime detection of tls offsets
|
||||
# in mono-compiler.h
|
||||
with_tls=pthread
|
||||
;;
|
||||
armv5-*-linux-androideabi*)
|
||||
TARGET=ARM;
|
||||
arch_target=arm;
|
||||
AC_DEFINE(TARGET_ARM, 1, [...])
|
||||
AC_DEFINE(TARGET_ANDROID, 1, [...])
|
||||
ACCESS_UNALIGNED="no"
|
||||
JIT_SUPPORTED=yes
|
||||
CPPFLAGS="$CPPFLAGS -D__ARM_EABI__ -DARM_FPU_NONE=1"
|
||||
jit_wanted=true
|
||||
# Can't use tls, since it depends on the runtime detection of tls offset
|
||||
# in mono-compiler.h
|
||||
with_tls=pthread
|
||||
;;
|
||||
*)
|
||||
AC_MSG_WARN([Cross compiling is only supported for targets matching 'powerpc64-{ps3,xbox360}-linux-gnu'])
|
||||
AC_MSG_ERROR([Cross compiling is not supported for target $target])
|
||||
esac
|
||||
fi
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
<dllmap dll="sqlite3" target="@SQLITE3@" os="!windows"/>
|
||||
<dllmap dll="libX11" target="@X11@" os="!windows" />
|
||||
<dllmap dll="libcairo-2.dll" target="libcairo.so.2" os="!windows"/>
|
||||
<dllmap dll="libcairo-2.dll" target="libcairo.2.dylib" os="osx"/>
|
||||
<dllmap dll="libcups" target="libcups.so.2" os="!windows"/>
|
||||
<dllmap dll="libcups" target="libcups.dylib" os="osx"/>
|
||||
<dllmap dll="i:kernel32.dll">
|
||||
|
||||
@@ -40,6 +40,7 @@ AM_CONDITIONAL(CROSS_COMPILING, [test x$cross_compiling = xyes])
|
||||
AC_C_BIGENDIAN([ORDER=G_BIG_ENDIAN],[ORDER=G_LITTLE_ENDIAN])
|
||||
|
||||
platform_darwin=no
|
||||
platform_android=no
|
||||
|
||||
case $host in
|
||||
*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
|
||||
@@ -55,6 +56,14 @@ case $host in
|
||||
OS="UNIX"
|
||||
PIDTYPE='int'
|
||||
;;
|
||||
*-*-linux-android*)
|
||||
platform_android=yes
|
||||
AC_DEFINE(PLATFORM_ANDROID,1,[Targeting the Android platform])
|
||||
PATHSEP='/'
|
||||
SEARCHSEP=':'
|
||||
OS="UNIX"
|
||||
PIDTYPE='int'
|
||||
;;
|
||||
*)
|
||||
PATHSEP='/'
|
||||
SEARCHSEP=':'
|
||||
@@ -91,6 +100,7 @@ AC_SUBST(PIDTYPE)
|
||||
AM_CONDITIONAL(HOST_WIN32, test x$OS = xWIN32)
|
||||
AM_CONDITIONAL(TARGET_WIN32, test x$OS = xWIN32)
|
||||
AM_CONDITIONAL(PLATFORM_DARWIN, test x$platform_darwin = xyes)
|
||||
AM_CONDITIONAL(PLATFORM_ANDROID, test x$platform_android = xyes)
|
||||
|
||||
AC_CHECK_SIZEOF(int)
|
||||
AC_CHECK_SIZEOF(void *)
|
||||
|
||||
@@ -61,6 +61,10 @@ INCLUDES = -I$(srcdir)
|
||||
|
||||
if HOST_WIN32
|
||||
libeglib_la_LIBADD = -lm $(ICONV_LIBS) -lpsapi
|
||||
else
|
||||
if PLATFORM_ANDROID
|
||||
libeglib_la_LIBADD = -llog
|
||||
endif
|
||||
endif
|
||||
|
||||
libeglib_static_la_LIBADD = $(libeglib_la_LIBADD)
|
||||
|
||||
@@ -114,7 +114,9 @@ typedef int32_t gboolean;
|
||||
|
||||
#define G_USEC_PER_SEC 1000000
|
||||
|
||||
#ifndef ABS
|
||||
#define ABS(a) ((a) > 0 ? (a) : -(a))
|
||||
#endif
|
||||
|
||||
#define G_STRUCT_OFFSET(p_type,field) offsetof(p_type,field)
|
||||
|
||||
|
||||
+8
-9
@@ -24,6 +24,7 @@
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <glib.h>
|
||||
@@ -111,28 +112,26 @@ g_log_set_fatal_mask (const gchar *log_domain, GLogLevelFlags fatal_mask)
|
||||
void
|
||||
g_logv (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format, va_list args)
|
||||
{
|
||||
#if PLATFORM_ANDROID
|
||||
__android_log_vprint (to_android_priority (log_level), log_domain, format, args);
|
||||
#else
|
||||
char *msg;
|
||||
|
||||
vasprintf (&msg, format, args);
|
||||
#if PLATFORM_ANDROID
|
||||
__android_log_print (to_android_priority (log_level),
|
||||
/* TODO: provide a proper app name */
|
||||
"mono", "%s%s%s",
|
||||
log_domain != NULL ? log_domain : "",
|
||||
log_domain != NULL ? ": " : "",
|
||||
msg);
|
||||
#else
|
||||
printf ("%s%s%s\n",
|
||||
log_domain != NULL ? log_domain : "",
|
||||
log_domain != NULL ? ": " : "",
|
||||
msg);
|
||||
#endif
|
||||
free (msg);
|
||||
if (log_level & fatal){
|
||||
fflush (stdout);
|
||||
fflush (stderr);
|
||||
abort ();
|
||||
}
|
||||
#endif
|
||||
if (log_level & fatal){
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+3
-1
@@ -68,7 +68,9 @@ g_build_path (const gchar *separator, const gchar *first_element, ...)
|
||||
g_string_append_len (result, s, p - s);
|
||||
|
||||
if (next && *next){
|
||||
if (strncmp (separator, result->str + strlen (result->str) - slen, slen))
|
||||
int reslen = strlen (result->str);
|
||||
|
||||
if (reslen >= slen && strncmp (separator, result->str + reslen - slen, slen))
|
||||
g_string_append (result, separator);
|
||||
|
||||
for (; strncmp (next, separator, slen) == 0; )
|
||||
|
||||
+1
-1
@@ -225,7 +225,7 @@ g_shell_unquote (const gchar *quoted_string, GError **error)
|
||||
}
|
||||
} else if (*p == '\\'){
|
||||
char c = *(++p);
|
||||
if (!(c == '$' || c == '"' || c == '\\' || c == '`' || c == 0))
|
||||
if (!(c == '$' || c == '"' || c == '\\' || c == '`' || c == '\'' || c == 0 ))
|
||||
g_string_append_c (result, '\\');
|
||||
if (c == 0)
|
||||
break;
|
||||
|
||||
@@ -371,6 +371,8 @@ void GC_print_callers GC_PROTO((struct callinfo info[NFRAMES]));
|
||||
# define GC_MACH_THREAD_STATE_FLAVOR PPC_THREAD_STATE
|
||||
# elif defined(I386)
|
||||
# define GC_MACH_THREAD_STATE_FLAVOR i386_THREAD_STATE
|
||||
# elif defined(X86_64)
|
||||
# define GC_MACH_THREAD_STATE_FLAVOR x86_THREAD_STATE64
|
||||
# else
|
||||
# define GC_MACH_THREAD_STATE_FLAVOR MACHINE_THREAD_STATE
|
||||
# endif
|
||||
|
||||
+8
-1
@@ -2131,7 +2131,14 @@ void GC_unmap_gap(ptr_t start1, word bytes1, ptr_t start2, word bytes2)
|
||||
len -= free_len;
|
||||
}
|
||||
# else
|
||||
if (len != 0 && munmap(start_addr, len) != 0) ABORT("munmap failed");
|
||||
if (len != 0) {
|
||||
/* Immediately remap as above. */
|
||||
void * result;
|
||||
result = mmap(start_addr, len, PROT_NONE,
|
||||
MAP_PRIVATE | MAP_FIXED | OPT_MAP_ANON,
|
||||
zero_fd, 0/* offset */);
|
||||
if (result != (void *)start_addr) ABORT("mmap(...PROT_NONE...) failed");
|
||||
}
|
||||
GC_unmapped_bytes += len;
|
||||
# endif
|
||||
}
|
||||
|
||||
@@ -729,7 +729,7 @@ void nacl_shutdown_gc_thread()
|
||||
/* Caller holds allocation lock. */
|
||||
GC_thread GC_new_thread(pthread_t id)
|
||||
{
|
||||
int hv = ((word)id) % THREAD_TABLE_SZ;
|
||||
int hv = ((unsigned long)id) % THREAD_TABLE_SZ;
|
||||
GC_thread result;
|
||||
static GC_bool first_thread_used = FALSE;
|
||||
|
||||
@@ -760,7 +760,7 @@ GC_thread GC_new_thread(pthread_t id)
|
||||
/* Caller holds allocation lock. */
|
||||
void GC_delete_thread(pthread_t id)
|
||||
{
|
||||
int hv = ((word)id) % THREAD_TABLE_SZ;
|
||||
int hv = ((unsigned long)id) % THREAD_TABLE_SZ;
|
||||
register GC_thread p = GC_threads[hv];
|
||||
register GC_thread prev = 0;
|
||||
|
||||
@@ -796,7 +796,7 @@ void GC_delete_thread(pthread_t id)
|
||||
/* This is OK, but we need a way to delete a specific one. */
|
||||
void GC_delete_gc_thread(pthread_t id, GC_thread gc_id)
|
||||
{
|
||||
int hv = ((word)id) % THREAD_TABLE_SZ;
|
||||
int hv = ((unsigned long)id) % THREAD_TABLE_SZ;
|
||||
register GC_thread p = GC_threads[hv];
|
||||
register GC_thread prev = 0;
|
||||
|
||||
@@ -825,7 +825,7 @@ void GC_delete_gc_thread(pthread_t id, GC_thread gc_id)
|
||||
/* return the most recent one. */
|
||||
GC_thread GC_lookup_thread(pthread_t id)
|
||||
{
|
||||
int hv = ((word)id) % THREAD_TABLE_SZ;
|
||||
int hv = ((unsigned long)id) % THREAD_TABLE_SZ;
|
||||
register GC_thread p = GC_threads[hv];
|
||||
|
||||
while (p != 0 && !pthread_equal(p -> id, id)) p = p -> next;
|
||||
|
||||
@@ -1410,6 +1410,9 @@ be used when writing messages like this: Console.Error:MyProgramName.
|
||||
See the System.Diagnostics.DefaultTraceListener documentation for more
|
||||
information.
|
||||
.TP
|
||||
\fBMONO_WCF_TRACE\fR
|
||||
This eases WCF diagnostics functionality by simply outputs all log messages from WCF engine to "stdout", "stderr" or any file passed to this environment variable. The log format is the same as usual diagnostic output.
|
||||
.TP
|
||||
\fBMONO_XEXCEPTIONS\fR
|
||||
This throws an exception when a X11 error is encountered; by default a
|
||||
message is displayed but execution continues
|
||||
|
||||
@@ -26,6 +26,8 @@ PLATFORM_MAKE_CORLIB_CMP = yes
|
||||
PLATFORM_CHANGE_SEPARATOR_CMD=tr '/' '\\\\'
|
||||
PLATFORM_PATH_SEPARATOR = ;
|
||||
|
||||
override CURDIR:=$(shell cygpath -m $(CURDIR))
|
||||
|
||||
## not so simple :-)
|
||||
#PLATFORM_AOT_SUFFIX = .dll
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ EXTRA_DISTFILES = \
|
||||
$(RESOURCE_FILES)
|
||||
|
||||
Commons.Xml.Relaxng.Rnc/RncParser.cs: Commons.Xml.Relaxng.Rnc/RncParser.jay $(topdir)/jay/skeleton.cs
|
||||
$(topdir)/jay/jay -ctv < $(topdir)/jay/skeleton.cs Commons.Xml.Relaxng.Rnc/RncParser.jay > Commons.Xml.Relaxng.Rnc/RncParser.cs
|
||||
$(topdir)/jay/jay -ctv < $(topdir)/jay/skeleton.cs $(CURDIR)/Commons.Xml.Relaxng.Rnc/RncParser.jay > Commons.Xml.Relaxng.Rnc/RncParser.cs
|
||||
|
||||
BUILT_SOURCES = Commons.Xml.Relaxng.Rnc/RncParser.cs
|
||||
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
2011-05-05 Veerapuram Varadhan <[email protected]>
|
||||
|
||||
** Fixes #681916
|
||||
* Tds70.cs (WriteParameterInfo): Handle null value for Image
|
||||
or varbinary(max) parameters as well.
|
||||
|
||||
2010-09-29 Veerapuram Varadhan <[email protected]>
|
||||
|
||||
** Fixes failed test for smallmoney
|
||||
|
||||
@@ -615,7 +615,8 @@ namespace Mono.Data.Tds.Protocol
|
||||
// types if param value is NULL
|
||||
if ((colType == TdsColumnType.BigVarChar ||
|
||||
colType == TdsColumnType.BigNVarChar ||
|
||||
colType == TdsColumnType.BigVarBinary) &&
|
||||
colType == TdsColumnType.BigVarBinary ||
|
||||
colType == TdsColumnType.Image) &&
|
||||
(param.Value == null || param.Value == DBNull.Value))
|
||||
size = -1;
|
||||
else
|
||||
|
||||
@@ -356,7 +356,8 @@ namespace Mono.Debugger.Soft
|
||||
BREAKPOINT = 10,
|
||||
STEP = 11,
|
||||
TYPE_LOAD = 12,
|
||||
EXCEPTION = 13
|
||||
EXCEPTION = 13,
|
||||
KEEPALIVE = 14
|
||||
}
|
||||
|
||||
enum ModifierKind {
|
||||
@@ -377,7 +378,8 @@ namespace Mono.Debugger.Soft
|
||||
DISPOSE = 6,
|
||||
INVOKE_METHOD = 7,
|
||||
SET_PROTOCOL_VERSION = 8,
|
||||
ABORT_INVOKE = 9
|
||||
ABORT_INVOKE = 9,
|
||||
SET_KEEPALIVE = 10
|
||||
}
|
||||
|
||||
enum CmdEvent {
|
||||
@@ -1166,6 +1168,8 @@ namespace Mono.Debugger.Soft
|
||||
long id = r.ReadId ();
|
||||
events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = id };
|
||||
//EventHandler.AppDomainUnload (req_id, thread_id, id);
|
||||
} else if (kind == EventKind.KEEPALIVE) {
|
||||
events [i] = new EventInfo (etype, req_id) { };
|
||||
} else {
|
||||
throw new NotImplementedException ("Unknown event kind: " + kind);
|
||||
}
|
||||
@@ -1381,6 +1385,13 @@ namespace Mono.Debugger.Soft
|
||||
SendReceive (CommandSet.VM, (int)CmdVM.ABORT_INVOKE, new PacketWriter ().WriteId (thread).WriteInt (id));
|
||||
}
|
||||
|
||||
public void SetSocketTimeouts (int send_timeout, int receive_timeout, int keepalive_interval)
|
||||
{
|
||||
socket.SendTimeout = send_timeout;
|
||||
socket.ReceiveTimeout = receive_timeout;
|
||||
SendReceive (CommandSet.VM, (int)CmdVM.SET_KEEPALIVE, new PacketWriter ().WriteId (keepalive_interval));
|
||||
}
|
||||
|
||||
/*
|
||||
* DOMAIN
|
||||
*/
|
||||
|
||||
@@ -17,7 +17,8 @@ namespace Mono.Debugger.Soft
|
||||
Step = 11,
|
||||
TypeLoad = 12,
|
||||
Exception = 13,
|
||||
KeepAlive = 14,
|
||||
// Not part of the wire protocol
|
||||
VMDisconnect = 99
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,6 +160,16 @@ namespace Mono.Debugger.Soft
|
||||
return new EnumMirror (this, type, value);
|
||||
}
|
||||
|
||||
//
|
||||
// Enable send and receive timeouts on the connection and send a keepalive event
|
||||
// every 'keepalive_interval' milliseconds.
|
||||
//
|
||||
|
||||
public void SetSocketTimeouts (int send_timeout, int receive_timeout, int keepalive_interval)
|
||||
{
|
||||
conn.SetSocketTimeouts (send_timeout, receive_timeout, keepalive_interval);
|
||||
}
|
||||
|
||||
//
|
||||
// Methods to create event request objects
|
||||
//
|
||||
|
||||
@@ -39,9 +39,7 @@ namespace Mono.Security.Protocol.Tls
|
||||
|
||||
#region Fields
|
||||
|
||||
static ManualResetEvent record_processing = new ManualResetEvent (true);
|
||||
|
||||
private const int WaitTimeOut = 5 * 60 * 1000;
|
||||
static ManualResetEvent record_processing = new ManualResetEvent (true);
|
||||
|
||||
internal Stream innerStream;
|
||||
internal MemoryStream inputBuffer;
|
||||
@@ -875,7 +873,7 @@ namespace Mono.Security.Protocol.Tls
|
||||
// Always wait until the read is complete
|
||||
if (!asyncResult.IsCompleted)
|
||||
{
|
||||
if (!asyncResult.AsyncWaitHandle.WaitOne (WaitTimeOut, false))
|
||||
if (!asyncResult.AsyncWaitHandle.WaitOne ())
|
||||
throw new TlsException (AlertDescription.InternalError, "Couldn't complete EndRead");
|
||||
}
|
||||
|
||||
@@ -900,7 +898,7 @@ namespace Mono.Security.Protocol.Tls
|
||||
|
||||
if (!asyncResult.IsCompleted)
|
||||
{
|
||||
if (!internalResult.AsyncWaitHandle.WaitOne (WaitTimeOut, false))
|
||||
if (!internalResult.AsyncWaitHandle.WaitOne ())
|
||||
throw new TlsException (AlertDescription.InternalError, "Couldn't complete EndWrite");
|
||||
}
|
||||
|
||||
|
||||
@@ -28,13 +28,13 @@ Mono.Xml.XPath2/XQueryParser.jay: Mono.Xml.XPath2/ParserBase.jay $(SKELETON)
|
||||
Mono.Xml.XPath2/XPath2Parser.cs: Mono.Xml.XPath2/XPath2Parser.jay
|
||||
echo "#define XPATH2_PARSER" > $@
|
||||
echo "#if NET_2_0" >> $@
|
||||
$(topdir)/jay/jay -ct < $(SKELETON) $< >>$@
|
||||
$(topdir)/jay/jay -ct < $(SKELETON) $(CURDIR)/$< >>$@
|
||||
echo "#endif" >> $@
|
||||
|
||||
Mono.Xml.XPath2/XQueryParser.cs: Mono.Xml.XPath2/XQueryParser.jay $(SKELETON)
|
||||
echo "#define XQUERY_PARSER" > $@
|
||||
echo "#if NET_2_0" >> $@
|
||||
$(topdir)/jay/jay -ct < $(SKELETON) $< >>$@
|
||||
$(topdir)/jay/jay -ct < $(SKELETON) $(CURDIR)/$< >>$@
|
||||
echo "#endif" >> $@
|
||||
|
||||
Mono.Xml.XPath2/XPath2Tokenizer.cs: Mono.Xml.XPath2/TokenizerBase.cs
|
||||
|
||||
@@ -38,6 +38,18 @@ using System.IO;
|
||||
|
||||
namespace System.Configuration {
|
||||
|
||||
// For configuration document, use this XmlDocument instead of the standard one. This ignores xmlns attribute for MS.
|
||||
internal class ConfigurationXmlDocument : XmlDocument
|
||||
{
|
||||
public override XmlElement CreateElement (string prefix, string localName, string namespaceURI)
|
||||
{
|
||||
if (namespaceURI == "http://schemas.microsoft.com/.NetConfiguration/v2.0")
|
||||
return base.CreateElement (String.Empty, localName, String.Empty);
|
||||
else
|
||||
return base.CreateElement (prefix, localName, namespaceURI);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class Configuration
|
||||
{
|
||||
Configuration parent;
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace System.Configuration
|
||||
// ignore, it can fail - we deserialize only in order to get
|
||||
// the configSource attribute
|
||||
}
|
||||
XmlDocument doc = new XmlDocument ();
|
||||
XmlDocument doc = new ConfigurationXmlDocument ();
|
||||
doc.LoadXml (RawXml);
|
||||
return SectionHandler.Create (parent, ConfigContext, doc.DocumentElement);
|
||||
}
|
||||
@@ -159,7 +159,7 @@ namespace System.Configuration
|
||||
{
|
||||
if (protection_provider != null) {
|
||||
ProtectedConfigurationProvider prov = ProtectedConfiguration.GetProvider (protection_provider, true);
|
||||
XmlDocument doc = new XmlDocument ();
|
||||
XmlDocument doc = new ConfigurationXmlDocument ();
|
||||
|
||||
reader.MoveToElement ();
|
||||
|
||||
|
||||
+2
-2
@@ -69,7 +69,7 @@ namespace System.Configuration
|
||||
|
||||
internal string EncryptSection (string clearXml, ProtectedConfigurationProvider protectionProvider)
|
||||
{
|
||||
XmlDocument doc = new XmlDocument ();
|
||||
XmlDocument doc = new ConfigurationXmlDocument ();
|
||||
doc.LoadXml (clearXml);
|
||||
|
||||
XmlNode encryptedNode = protectionProvider.Encrypt (doc.DocumentElement);
|
||||
@@ -79,7 +79,7 @@ namespace System.Configuration
|
||||
|
||||
internal string DecryptSection (string encryptedXml, ProtectedConfigurationProvider protectionProvider)
|
||||
{
|
||||
XmlDocument doc = new XmlDocument ();
|
||||
XmlDocument doc = new ConfigurationXmlDocument ();
|
||||
doc.InnerXml = encryptedXml;
|
||||
|
||||
XmlNode decryptedNode = protectionProvider.Decrypt (doc.DocumentElement);
|
||||
|
||||
+2
-2
@@ -66,7 +66,7 @@ namespace System.Configuration
|
||||
[MonoTODO]
|
||||
public override XmlNode Decrypt (XmlNode encrypted_node)
|
||||
{
|
||||
XmlDocument doc = new XmlDocument ();
|
||||
XmlDocument doc = new ConfigurationXmlDocument ();
|
||||
|
||||
doc.Load (new StringReader (encrypted_node.OuterXml));
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace System.Configuration
|
||||
[MonoTODO]
|
||||
public override XmlNode Encrypt (XmlNode node)
|
||||
{
|
||||
XmlDocument doc = new XmlDocument ();
|
||||
XmlDocument doc = new ConfigurationXmlDocument ();
|
||||
|
||||
doc.Load (new StringReader (node.OuterXml));
|
||||
|
||||
|
||||
@@ -59,7 +59,11 @@ namespace System.Linq {
|
||||
if (qe == null)
|
||||
return constant;
|
||||
|
||||
return Expression.Constant (qe.GetEnumerable ());
|
||||
var enumerable = qe.GetEnumerable ();
|
||||
if (enumerable != null)
|
||||
return Expression.Constant (enumerable);
|
||||
|
||||
return Visit (qe.Expression);
|
||||
}
|
||||
|
||||
static bool IsQueryableExtension (MethodInfo method)
|
||||
|
||||
@@ -329,6 +329,9 @@ namespace System
|
||||
#if MONODROID
|
||||
return ZoneInfoDB.GetTimeZone (id);
|
||||
#elif LIBC
|
||||
// Local requires special logic that already exists in the Local property (bug #326)
|
||||
if (id == "Local")
|
||||
return Local;
|
||||
string filepath = Path.Combine (TimeZoneDirectory, id);
|
||||
return FindSystemTimeZoneByFileName (id, filepath);
|
||||
#else
|
||||
|
||||
@@ -540,6 +540,20 @@ namespace MonoTests.System
|
||||
TimeZoneInfo vatican = TimeZoneInfo.FindSystemTimeZoneById ("Europe/Vatican");
|
||||
Assert.IsTrue (rome.HasSameRules (vatican));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FindSystemTimeZoneById_Local_Roundtrip ()
|
||||
{
|
||||
Assert.AreEqual (TimeZoneInfo.Local.Id, TimeZoneInfo.FindSystemTimeZoneById (TimeZoneInfo.Local.Id).Id);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test326 ()
|
||||
{
|
||||
DateTime utc = DateTime.UtcNow;
|
||||
DateTime local = TimeZoneInfo.ConvertTime (utc, TimeZoneInfo.Utc, TimeZoneInfo.FindSystemTimeZoneById (TimeZoneInfo.Local.Id));
|
||||
Assert.AreEqual (local, utc + TimeZoneInfo.Local.GetUtcOffset (utc), "ConvertTime/Local");
|
||||
}
|
||||
|
||||
#if SLOW_TESTS
|
||||
[Test]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// OciCalls.cs
|
||||
//
|
||||
// Part of the Mono class libraries at
|
||||
@@ -464,7 +464,7 @@ namespace System.Data.OracleClient.Oci
|
||||
[MarshalAs (UnmanagedType.U4)] int dstlen,
|
||||
byte [] src,
|
||||
[MarshalAs (UnmanagedType.U4)] int srclen,
|
||||
[MarshalAs (UnmanagedType.U4)] out int rsize);
|
||||
[MarshalAs (UnmanagedType.SysUInt)] ref UIntPtr rsizep);
|
||||
|
||||
[DllImport ("oci")]
|
||||
internal static extern int OCIUnicodeToCharSet (
|
||||
@@ -473,7 +473,7 @@ namespace System.Data.OracleClient.Oci
|
||||
[MarshalAs (UnmanagedType.U4)] int dstlen,
|
||||
[MarshalAs (UnmanagedType.LPWStr)] string src,
|
||||
[MarshalAs (UnmanagedType.U4)] int srclen,
|
||||
[MarshalAs (UnmanagedType.U4)] out int rsize);
|
||||
[MarshalAs (UnmanagedType.SysUInt)] ref UIntPtr rsizep);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -1183,26 +1183,26 @@ namespace System.Data.OracleClient.Oci
|
||||
IntPtr svchp,
|
||||
StringBuilder dst,
|
||||
byte [] src,
|
||||
out int rsize)
|
||||
[MarshalAs (UnmanagedType.SysUInt)] ref UIntPtr rsizep)
|
||||
{
|
||||
#if TRACE
|
||||
Trace.WriteLineIf(traceOci, "OCICharSetToUnicode", "OCI");
|
||||
#endif
|
||||
|
||||
return OciNativeCalls.OCICharSetToUnicode (svchp, dst, dst!=null ? dst.Capacity : 0, src, src.Length, out rsize);
|
||||
return OciNativeCalls.OCICharSetToUnicode (svchp, dst, dst!=null ? dst.Capacity : 0, src, src.Length, ref rsizep);
|
||||
}
|
||||
|
||||
internal static int OCIUnicodeToCharSet (
|
||||
IntPtr svchp,
|
||||
byte [] dst,
|
||||
[MarshalAs (UnmanagedType.LPWStr)] string src,
|
||||
[MarshalAs (UnmanagedType.U4)] out int rsize)
|
||||
[MarshalAs (UnmanagedType.SysUInt)] ref UIntPtr rsizep)
|
||||
{
|
||||
#if TRACE
|
||||
Trace.WriteLineIf(traceOci, "OCIUnicodeToCharSet", "OCI");
|
||||
#endif
|
||||
|
||||
return OciNativeCalls.OCIUnicodeToCharSet (svchp, dst, dst!=null ? dst.Length : 0, src, src.Length, out rsize);
|
||||
return OciNativeCalls.OCIUnicodeToCharSet (svchp, dst, dst!=null ? dst.Length : 0, src, src.Length, ref rsizep);
|
||||
}
|
||||
|
||||
[DllImport ("oci")]
|
||||
|
||||
+6
-4
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// OciDateTimeDescriptor.cs - used for an Oracle TIMESTAMP
|
||||
//
|
||||
// Part of managed C#/.NET library System.Data.OracleClient.dll
|
||||
@@ -64,13 +64,15 @@ namespace System.Data.OracleClient.Oci {
|
||||
byte hour, byte min, byte sec, uint fsec, string timezone)
|
||||
{
|
||||
// Get size of buffer
|
||||
int rsize = 0;
|
||||
int status = OciCalls.OCIUnicodeToCharSet (handle, null, timezone, out rsize);
|
||||
ulong rsize = 0;
|
||||
UIntPtr rsizep = new UIntPtr (rsize);
|
||||
int status = OciCalls.OCIUnicodeToCharSet (handle, null, timezone, ref rsizep);
|
||||
|
||||
// Fill buffer
|
||||
rsize = rsizep.ToUInt64 ();
|
||||
byte[] bytes = new byte[rsize];
|
||||
if (status == 0 && rsize > 0)
|
||||
OciCalls.OCIUnicodeToCharSet (handle, bytes, timezone, out rsize);
|
||||
OciCalls.OCIUnicodeToCharSet (handle, bytes, timezone, ref rsizep);
|
||||
|
||||
if (fsec > 0)
|
||||
fsec = fsec * 1000000;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// OciDefineHandle.cs
|
||||
//
|
||||
// Part of managed C#/.NET library System.Data.OracleClient.dll
|
||||
@@ -516,15 +516,17 @@ namespace System.Data.OracleClient.Oci
|
||||
Marshal.Copy (Value, buffer, 0, Size);
|
||||
|
||||
// Get length of returned string
|
||||
int rsize = 0;
|
||||
ulong rsize = 0;
|
||||
UIntPtr rsizep = new UIntPtr (rsize);
|
||||
//IntPtr env = Parent.Parent; // Parent is statement, grandparent is environment
|
||||
IntPtr env = conn.Environment;
|
||||
int status = OciCalls.OCICharSetToUnicode (env, null, buffer, out rsize);
|
||||
int status = OciCalls.OCICharSetToUnicode (env, null, buffer, ref rsizep);
|
||||
OciErrorHandle.ThrowExceptionIfError (ErrorHandle, status);
|
||||
|
||||
// Get string
|
||||
StringBuilder ret = new StringBuilder(rsize);
|
||||
status = OciCalls.OCICharSetToUnicode (env, ret, buffer, out rsize);
|
||||
rsize = rsizep.ToUInt64 ();
|
||||
StringBuilder ret = new StringBuilder((int)rsize);
|
||||
status = OciCalls.OCICharSetToUnicode (env, ret, buffer, ref rsizep);
|
||||
OciErrorHandle.ThrowExceptionIfError (ErrorHandle, status);
|
||||
|
||||
return ret.ToString ();
|
||||
|
||||
@@ -66,8 +66,9 @@ namespace System.Data.OracleClient.Oci {
|
||||
if (h == null)
|
||||
throw new Exception ("Internal driver error: handle is null.");
|
||||
|
||||
int errbufSize = 4096;
|
||||
IntPtr errbuf = OciCalls.AllocateClear (errbufSize);
|
||||
ulong errbufSize = 4096;
|
||||
UIntPtr errbufSizep = new UIntPtr (errbufSize);
|
||||
IntPtr errbuf = OciCalls.AllocateClear ((int)errbufSize);
|
||||
|
||||
OciCalls.OCIErrorGet (hwnd,
|
||||
1,
|
||||
@@ -78,15 +79,16 @@ namespace System.Data.OracleClient.Oci {
|
||||
OciHandleType.Error);
|
||||
|
||||
byte[] bytea = new byte[errbufSize];
|
||||
Marshal.Copy (errbuf, bytea, 0, errbufSize);
|
||||
Marshal.Copy (errbuf, bytea, 0, (int)errbufSize);
|
||||
errbufSize = 0;
|
||||
|
||||
// first call to OCICharSetToUnicode gets the size
|
||||
OciCalls.OCICharSetToUnicode (h, null, bytea, out errbufSize);
|
||||
StringBuilder str = new StringBuilder (errbufSize);
|
||||
OciCalls.OCICharSetToUnicode (h, null, bytea, ref errbufSizep);
|
||||
errbufSize = errbufSizep.ToUInt64 ();
|
||||
StringBuilder str = new StringBuilder ((int)errbufSize);
|
||||
|
||||
// second call to OCICharSetToUnicode gets the string
|
||||
OciCalls.OCICharSetToUnicode (h, str, bytea, out errbufSize);
|
||||
OciCalls.OCICharSetToUnicode (h, str, bytea, ref errbufSizep);
|
||||
|
||||
string errmsg = String.Empty;
|
||||
if (errbufSize > 0) {
|
||||
@@ -104,8 +106,9 @@ namespace System.Data.OracleClient.Oci {
|
||||
info.ErrorCode = 0;
|
||||
info.ErrorMessage = String.Empty;
|
||||
|
||||
int errbufSize = 4096;
|
||||
IntPtr errbuf = OciCalls.AllocateClear (errbufSize);
|
||||
ulong errbufSize = 4096;
|
||||
UIntPtr errbufSizep = new UIntPtr (errbufSize);
|
||||
IntPtr errbuf = OciCalls.AllocateClear ((int)errbufSize);
|
||||
|
||||
OciCalls.OCIErrorGet (hand,
|
||||
1,
|
||||
@@ -116,7 +119,7 @@ namespace System.Data.OracleClient.Oci {
|
||||
OciHandleType.Error);
|
||||
|
||||
byte[] bytea = new byte[errbufSize];
|
||||
Marshal.Copy (errbuf, bytea, 0, errbufSize);
|
||||
Marshal.Copy (errbuf, bytea, 0, (int)errbufSize);
|
||||
errbufSize = 0;
|
||||
|
||||
OciHandle h = hand.Parent;
|
||||
@@ -126,11 +129,12 @@ namespace System.Data.OracleClient.Oci {
|
||||
throw new Exception ("Internal driver error: handle is null.");
|
||||
|
||||
// first call to OCICharSetToUnicode gets the size
|
||||
OciCalls.OCICharSetToUnicode (h, null, bytea, out errbufSize);
|
||||
StringBuilder str = new StringBuilder (errbufSize);
|
||||
OciCalls.OCICharSetToUnicode (h, null, bytea, ref errbufSizep);
|
||||
errbufSize = errbufSizep.ToUInt64 ();
|
||||
StringBuilder str = new StringBuilder ((int)errbufSize);
|
||||
|
||||
// second call to OCICharSetToUnicode gets the string
|
||||
OciCalls.OCICharSetToUnicode (h, str, bytea, out errbufSize);
|
||||
OciCalls.OCICharSetToUnicode (h, str, bytea, ref errbufSizep);
|
||||
|
||||
string errmsg = String.Empty;
|
||||
if (errbufSize > 0)
|
||||
|
||||
+9
-3
@@ -19,6 +19,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System.Data.OracleClient.Oci {
|
||||
@@ -253,15 +254,20 @@ namespace System.Data.OracleClient.Oci {
|
||||
throw new InvalidOperationException ("StatementHandle is already disposed.");
|
||||
}
|
||||
|
||||
int rsize = 0;
|
||||
ulong rsize = 0;
|
||||
byte [] buffer;
|
||||
|
||||
UIntPtr rsizep = new UIntPtr (rsize);
|
||||
// Get size of buffer
|
||||
OciCalls.OCIUnicodeToCharSet (Parent, null, commandText, out rsize);
|
||||
OciCalls.OCIUnicodeToCharSet (Parent, null, commandText, ref rsizep);
|
||||
rsize = rsizep.ToUInt64 ();
|
||||
|
||||
//rsize = Encoding.UTF8.GetMaxByteCount (commandText.Length+1);
|
||||
|
||||
// Fill buffer
|
||||
buffer = new byte[rsize];
|
||||
OciCalls.OCIUnicodeToCharSet (Parent, buffer, commandText, out rsize);
|
||||
|
||||
OciCalls.OCIUnicodeToCharSet (Parent, buffer, commandText, ref rsizep);
|
||||
|
||||
// Execute statement
|
||||
status = OciCalls.OCIStmtPrepare (this,
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
2011-05-05 Veerapuram Varadhan <[email protected]>
|
||||
|
||||
* OracleConnection.cs (GetOracleVersion, GetNlsInfo):
|
||||
* OracleParameter.cs: Use UIntPtr for referencing size_t
|
||||
parameters to fix 32/64 bit - big/little-endian issues
|
||||
while calling native methods.
|
||||
|
||||
2010-02-14 Veerapuram Varadhan <[email protected]>
|
||||
|
||||
** Fixes 667855
|
||||
|
||||
@@ -220,13 +220,15 @@ namespace System.Data.OracleClient
|
||||
OciCalls.OCIServerVersion (sh, eh, ref buffer, bufflen, OciHandleType.Service);
|
||||
|
||||
// Get length of returned string
|
||||
int rsize = 0;
|
||||
ulong rsize = 0;
|
||||
UIntPtr rsizep = new UIntPtr (rsize);
|
||||
IntPtr env = oci.Environment;
|
||||
OciCalls.OCICharSetToUnicode (env, null, buffer, out rsize);
|
||||
OciCalls.OCICharSetToUnicode (env, null, buffer, ref rsizep);
|
||||
|
||||
// Get string
|
||||
StringBuilder ret = new StringBuilder(rsize);
|
||||
OciCalls.OCICharSetToUnicode (env, ret, buffer, out rsize);
|
||||
rsize = rsizep.ToUInt64 ();
|
||||
StringBuilder ret = new StringBuilder((int)rsize);
|
||||
OciCalls.OCICharSetToUnicode (env, ret, buffer, ref rsizep);
|
||||
|
||||
return ret.ToString ();
|
||||
}
|
||||
@@ -371,12 +373,14 @@ namespace System.Data.OracleClient
|
||||
ref buffer, bufflen, (ushort) item);
|
||||
|
||||
// Get length of returned string
|
||||
int rsize = 0;
|
||||
OciCalls.OCICharSetToUnicode (Environment, null, buffer, out rsize);
|
||||
ulong rsize = 0;
|
||||
UIntPtr rsizep = new UIntPtr (rsize);
|
||||
OciCalls.OCICharSetToUnicode (Environment, null, buffer, ref rsizep);
|
||||
|
||||
// Get string
|
||||
StringBuilder ret = new StringBuilder (rsize);
|
||||
OciCalls.OCICharSetToUnicode (Environment, ret, buffer, out rsize);
|
||||
rsize = rsizep.ToUInt64 ();
|
||||
StringBuilder ret = new StringBuilder ((int)rsize);
|
||||
OciCalls.OCICharSetToUnicode (Environment, ret, buffer, ref rsizep);
|
||||
|
||||
return ret.ToString ();
|
||||
}
|
||||
|
||||
@@ -431,8 +431,9 @@ namespace System.Data.OracleClient
|
||||
object v = value;
|
||||
int status = 0;
|
||||
bindType = ociType;
|
||||
int rsize = 0;
|
||||
|
||||
ulong rsize = 0;
|
||||
UIntPtr rsizep = new UIntPtr (rsize);
|
||||
|
||||
string svalue;
|
||||
string sDate;
|
||||
DateTime dt;
|
||||
@@ -482,10 +483,10 @@ namespace System.Data.OracleClient
|
||||
// in this case using OCIUnicodeToCharSet
|
||||
rsize = 0;
|
||||
// Get size of buffer
|
||||
status = OciCalls.OCIUnicodeToCharSet (statement.Parent, null, svalue, out rsize);
|
||||
|
||||
status = OciCalls.OCIUnicodeToCharSet (statement.Parent, null, svalue, ref rsizep);
|
||||
rsize = rsizep.ToUInt64 ();
|
||||
if (direction == ParameterDirection.Input)
|
||||
bindSize = rsize;
|
||||
bindSize = (int)rsize;
|
||||
else {
|
||||
// this cannot be rsize because you need room for the output after the execute
|
||||
bindSize = Encoding.UTF8.GetMaxByteCount (Size + 1);
|
||||
@@ -495,7 +496,7 @@ namespace System.Data.OracleClient
|
||||
bytes = new byte [bindSize];
|
||||
|
||||
// Fill buffer
|
||||
status = OciCalls.OCIUnicodeToCharSet (statement.Parent, bytes, svalue, out rsize);
|
||||
status = OciCalls.OCIUnicodeToCharSet (statement.Parent, bytes, svalue, ref rsizep);
|
||||
} else {
|
||||
// for Output and ReturnValue parameters, get size in bytes
|
||||
bindSize = Encoding.UTF8.GetMaxByteCount (size + 1);
|
||||
@@ -612,17 +613,17 @@ namespace System.Data.OracleClient
|
||||
|
||||
rsize = 0;
|
||||
// Get size of buffer
|
||||
OciCalls.OCIUnicodeToCharSet (statement.Parent, null, svalue, out rsize);
|
||||
OciCalls.OCIUnicodeToCharSet (statement.Parent, null, svalue, ref rsizep);
|
||||
|
||||
// Fill buffer
|
||||
|
||||
rsize = rsizep.ToUInt64 ();
|
||||
if (direction == ParameterDirection.Input)
|
||||
bindSize = rsize;
|
||||
bindSize = (int)rsize;
|
||||
else
|
||||
bindSize = 30; // need room for output possibly being bigger than the input
|
||||
|
||||
bytes = new byte [bindSize];
|
||||
OciCalls.OCIUnicodeToCharSet (statement.Parent, bytes, svalue, out rsize);
|
||||
OciCalls.OCIUnicodeToCharSet (statement.Parent, bytes, svalue, ref rsizep);
|
||||
} else {
|
||||
// Output and ReturnValue parameters allocate memory
|
||||
bindSize = 30;
|
||||
@@ -672,11 +673,12 @@ namespace System.Data.OracleClient
|
||||
rsize = 0;
|
||||
|
||||
// Get size of buffer
|
||||
OciCalls.OCIUnicodeToCharSet (statement.Parent, null, svalue, out rsize);
|
||||
OciCalls.OCIUnicodeToCharSet (statement.Parent, null, svalue, ref rsizep);
|
||||
|
||||
// Fill buffer
|
||||
rsize = rsizep.ToUInt64 ();
|
||||
bytes = new byte[rsize];
|
||||
OciCalls.OCIUnicodeToCharSet (statement.Parent, bytes, svalue, out rsize);
|
||||
OciCalls.OCIUnicodeToCharSet (statement.Parent, bytes, svalue, ref rsizep);
|
||||
|
||||
bindType = OciDataType.Long;
|
||||
bindSize = bytes.Length;
|
||||
@@ -1245,7 +1247,8 @@ namespace System.Data.OracleClient
|
||||
if (indicator == -1)
|
||||
return;
|
||||
|
||||
int rsize = 0;
|
||||
ulong rsize = 0;
|
||||
UIntPtr rsizep = new UIntPtr (rsize);
|
||||
IntPtr env = IntPtr.Zero;
|
||||
StringBuilder ret = null;
|
||||
|
||||
@@ -1263,11 +1266,12 @@ namespace System.Data.OracleClient
|
||||
// Get length of returned string
|
||||
rsize = 0;
|
||||
env = cmd.Connection.Environment;
|
||||
OciCalls.OCICharSetToUnicode (env, null, bytes, out rsize);
|
||||
OciCalls.OCICharSetToUnicode (env, null, bytes, ref rsizep);
|
||||
|
||||
// Get string
|
||||
ret = new StringBuilder(rsize);
|
||||
OciCalls.OCICharSetToUnicode (env, ret, bytes, out rsize);
|
||||
rsize = rsizep.ToUInt64 ();
|
||||
ret = new StringBuilder((int)rsize);
|
||||
OciCalls.OCICharSetToUnicode (env, ret, bytes, ref rsizep);
|
||||
|
||||
value = ret.ToString ();
|
||||
break;
|
||||
@@ -1312,11 +1316,12 @@ namespace System.Data.OracleClient
|
||||
case OciDataType.Float:
|
||||
rsize = 0;
|
||||
env = cmd.Connection.Environment;
|
||||
OciCalls.OCICharSetToUnicode (env, null, bytes, out rsize);
|
||||
OciCalls.OCICharSetToUnicode (env, null, bytes, ref rsizep);
|
||||
|
||||
// Get string
|
||||
ret = new StringBuilder(rsize);
|
||||
OciCalls.OCICharSetToUnicode (env, ret, bytes, out rsize);
|
||||
rsize = rsizep.ToUInt64 ();
|
||||
ret = new StringBuilder((int)rsize);
|
||||
OciCalls.OCICharSetToUnicode (env, ret, bytes, ref rsizep);
|
||||
|
||||
// if not empty, parse string as a decimal using session format
|
||||
if (ret.Length > 0) {
|
||||
|
||||
@@ -63,7 +63,7 @@ EXTRA_DISTFILES = \
|
||||
BUILT_SOURCES = Mono.Data.SqlExpressions/Parser.cs
|
||||
|
||||
Mono.Data.SqlExpressions/Parser.cs: Mono.Data.SqlExpressions/Parser.jay $(topdir)/jay/skeleton.cs
|
||||
$(topdir)/jay/jay -ct < $(topdir)/jay/skeleton.cs $< >$@
|
||||
$(topdir)/jay/jay -vct < $(topdir)/jay/skeleton.cs $(CURDIR)/$< >$@
|
||||
|
||||
include ../../build/library.make
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// Juraj Skripsky ([email protected])
|
||||
//
|
||||
// (C) 2004 HotFeet GmbH (http://www.hotfeet.ch)
|
||||
// Copyright 2011 Xamarin Inc (http://www.xamarin.com)
|
||||
//
|
||||
|
||||
using System;
|
||||
@@ -190,6 +191,7 @@ LiteralValue
|
||||
| NumberLiteral { $$ = new Literal ($1); }
|
||||
| DateLiteral { $$ = new Literal ($1); }
|
||||
| BoolLiteral
|
||||
| NULL { $$ = new Literal (null); }
|
||||
;
|
||||
|
||||
BoolLiteral
|
||||
@@ -271,28 +273,20 @@ AggFunctionName
|
||||
;
|
||||
|
||||
StringExpr
|
||||
: PAROPEN StringExpr PARCLOSE
|
||||
{
|
||||
$$ = (IExpression)$2;
|
||||
}
|
||||
| SingleColumnValue
|
||||
: SingleColumnValue
|
||||
| StringLiteral { $$ = new Literal ($1); }
|
||||
| StringFunction
|
||||
| Function
|
||||
;
|
||||
|
||||
StringFunction
|
||||
: TRIM PAROPEN StringExpr PARCLOSE
|
||||
: TRIM PAROPEN ArithExpr PARCLOSE
|
||||
{
|
||||
$$ = new TrimFunction ((IExpression)$3);
|
||||
}
|
||||
| SUBSTRING PAROPEN StringExpr COMMA ArithExpr COMMA ArithExpr PARCLOSE
|
||||
| SUBSTRING PAROPEN ArithExpr COMMA ArithExpr COMMA ArithExpr PARCLOSE
|
||||
{
|
||||
$$ = new SubstringFunction ((IExpression)$3, (IExpression)$5, (IExpression)$7);
|
||||
}
|
||||
| StringExpr PLUS StringExpr
|
||||
{
|
||||
$$ = new ConcatFunction ((IExpression)$1, (IExpression)$3);
|
||||
}
|
||||
;
|
||||
|
||||
CalcFunction
|
||||
|
||||
@@ -55,42 +55,6 @@ namespace Mono.Data.SqlExpressions {
|
||||
}
|
||||
}
|
||||
|
||||
internal class ConcatFunction : StringFunction
|
||||
{
|
||||
readonly IExpression _add;
|
||||
public ConcatFunction (IExpression e, IExpression add)
|
||||
: base (e)
|
||||
{
|
||||
_add = add;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!base.Equals (obj))
|
||||
return false;
|
||||
|
||||
if (!(obj is ConcatFunction))
|
||||
return false;
|
||||
|
||||
ConcatFunction other = (ConcatFunction) obj;
|
||||
return _add.Equals (other._add);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
int hashCode = base.GetHashCode ();
|
||||
hashCode ^= _add.GetHashCode ();
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
override public object Eval (DataRow row) {
|
||||
string str = (string) base.Eval (row);
|
||||
string x = (string) _add.Eval (row);
|
||||
|
||||
return str + x;
|
||||
}
|
||||
}
|
||||
|
||||
internal class SubstringFunction : StringFunction {
|
||||
IExpression start;
|
||||
IExpression len;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
2011-05-05 Veerapuram Varadhan <[email protected]>
|
||||
|
||||
** Fixes 688773
|
||||
* RecordCache.cs (CopyRecord): When copying records, assign default value
|
||||
for the columns that does not exist in the row being imported.
|
||||
|
||||
2010-07-23 Veerapuram Varadhan <[email protected]>
|
||||
|
||||
** Fixes #565616 - Based on Patch by Hubert FONGARNAND
|
||||
|
||||
@@ -106,12 +106,13 @@ namespace System.Data.Common
|
||||
recordIndex = NewRecord ();
|
||||
|
||||
try {
|
||||
foreach (DataColumn fromColumn in fromTable.Columns) {
|
||||
DataColumn column = _table.Columns [fromColumn.ColumnName];
|
||||
if (column != null)
|
||||
column.DataContainer.CopyValue (fromColumn.DataContainer, fromRecordIndex, recordIndex);
|
||||
foreach (DataColumn toColumn in _table.Columns) {
|
||||
DataColumn fromColumn = fromTable.Columns [toColumn.ColumnName];
|
||||
if (fromColumn != null)
|
||||
toColumn.DataContainer.CopyValue (fromColumn.DataContainer, fromRecordIndex, recordIndex);
|
||||
else
|
||||
toColumn.DataContainer.CopyValue (_table.DefaultValuesRowIndex, recordIndex);
|
||||
}
|
||||
|
||||
return recordIndex;
|
||||
} catch {
|
||||
if (toRecordIndex == -1)
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
2011-03-22 Veerapuram Varadhan <[email protected]>
|
||||
|
||||
** Fixes 663914 - Patch by Gábor Remete <[email protected]>
|
||||
* DataRow.cs (SetOriginalValue): When setting original value for a column,
|
||||
ensure that original values of other columns are also restored.
|
||||
|
||||
2011-03-15 Veerapuram Varadhan <[email protected]>
|
||||
|
||||
** Fixes 672113
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
//
|
||||
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
|
||||
// Copyright (C) 2011 Xamarin Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
@@ -475,43 +476,53 @@ namespace System.Data {
|
||||
if (value == null)
|
||||
value = String.Empty;
|
||||
|
||||
if (value != String.Empty) {
|
||||
if (AutoIncrement || Unique)
|
||||
throw new ArgumentException ("Cannot create an expression on a column that has AutoIncrement or Unique.");
|
||||
CompileExpression (value);
|
||||
_expression = value;
|
||||
}
|
||||
}
|
||||
|
||||
if (Table != null) {
|
||||
for (int i = 0; i < Table.Constraints.Count; i++) {
|
||||
if (Table.Constraints [i].IsColumnContained (this))
|
||||
throw new ArgumentException (
|
||||
String.Format (
|
||||
"Cannot set Expression property on column {0}, because it is a part of a constraint.",
|
||||
ColumnName));
|
||||
}
|
||||
}
|
||||
internal void CompileExpression ()
|
||||
{
|
||||
CompileExpression (_expression);
|
||||
}
|
||||
|
||||
Parser parser = new Parser ();
|
||||
IExpression compiledExpression = parser.Compile (value);
|
||||
internal void CompileExpression (string expression)
|
||||
{
|
||||
if (expression != String.Empty) {
|
||||
if (AutoIncrement || Unique)
|
||||
throw new ArgumentException ("Cannot create an expression on a column that has AutoIncrement or Unique.");
|
||||
|
||||
if (Table != null) {
|
||||
if (compiledExpression.DependsOn (this))
|
||||
throw new ArgumentException ("Cannot set Expression property due to circular reference in the expression.");
|
||||
// Check if expression is ok
|
||||
if (Table.Rows.Count == 0)
|
||||
compiledExpression.Eval (Table.NewRow ());
|
||||
else
|
||||
compiledExpression.Eval (Table.Rows [0]);
|
||||
}
|
||||
ReadOnly = true;
|
||||
_compiledExpression = compiledExpression;
|
||||
} else {
|
||||
_compiledExpression = null;
|
||||
if (Table != null) {
|
||||
int defaultValuesRowIndex = Table.DefaultValuesRowIndex;
|
||||
if (defaultValuesRowIndex != -1)
|
||||
DataContainer.FillValues (defaultValuesRowIndex);
|
||||
if (Table != null) {
|
||||
for (int i = 0; i < Table.Constraints.Count; i++) {
|
||||
if (Table.Constraints [i].IsColumnContained (this))
|
||||
throw new ArgumentException (
|
||||
String.Format (
|
||||
"Cannot set Expression property on column {0}, because it is a part of a constraint.",
|
||||
ColumnName));
|
||||
}
|
||||
}
|
||||
_expression = value;
|
||||
|
||||
Parser parser = new Parser ();
|
||||
IExpression compiledExpression = parser.Compile (expression);
|
||||
|
||||
if (Table != null) {
|
||||
if (compiledExpression.DependsOn (this))
|
||||
throw new ArgumentException ("Cannot set Expression property due to circular reference in the expression.");
|
||||
// Check if expression is ok
|
||||
if (Table.Rows.Count == 0)
|
||||
compiledExpression.Eval (Table.NewRow ());
|
||||
else
|
||||
compiledExpression.Eval (Table.Rows [0]);
|
||||
}
|
||||
ReadOnly = true;
|
||||
_compiledExpression = compiledExpression;
|
||||
} else {
|
||||
_compiledExpression = null;
|
||||
if (Table != null) {
|
||||
int defaultValuesRowIndex = Table.DefaultValuesRowIndex;
|
||||
if (defaultValuesRowIndex != -1)
|
||||
DataContainer.FillValues (defaultValuesRowIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -701,16 +712,12 @@ namespace System.Data {
|
||||
//Copy.Container
|
||||
copy.DataType = DataType;
|
||||
copy._defaultValue = _defaultValue;
|
||||
// Use the property to set the expression as it updates compiledExpression, if any.
|
||||
copy.Expression = _expression;
|
||||
// Do not use the Expression property to set the expression, the caller of Clone
|
||||
// must explicitly call CompileExpression on the returned DataColumn to update compiledExpression (if any).
|
||||
copy._expression = _expression;
|
||||
//Copy.ExtendedProperties
|
||||
if (_extendedProperties.Count > 0) {
|
||||
Array extPropArray = Array.CreateInstance (typeof (object), _extendedProperties.Count);
|
||||
_extendedProperties.CopyTo (extPropArray, 0);
|
||||
for (var i = 0; i < _extendedProperties.Count; i++)
|
||||
copy.ExtendedProperties.Add (extPropArray.GetValue(i),
|
||||
ExtendedProperties[extPropArray.GetValue(i)]);
|
||||
}
|
||||
foreach (object key in _extendedProperties.Keys)
|
||||
copy.ExtendedProperties.Add (key, ExtendedProperties[key]);
|
||||
copy._maxLength = _maxLength;
|
||||
copy._nameSpace = _nameSpace;
|
||||
copy._prefix = _prefix;
|
||||
|
||||
@@ -586,8 +586,12 @@ namespace System.Data {
|
||||
DataColumn column = _table.Columns [columnName];
|
||||
_table.ChangingDataColumn (this, column, val);
|
||||
|
||||
if (Original < 0 || Original == Current)
|
||||
if (Original < 0 || Original == Current) {
|
||||
Original = Table.RecordCache.NewRecord ();
|
||||
|
||||
foreach (DataColumn col in _table.Columns)
|
||||
col.DataContainer.CopyValue (Table.DefaultValuesRowIndex, Original);
|
||||
}
|
||||
|
||||
CheckValue (val, column);
|
||||
column [Original] = val;
|
||||
|
||||
@@ -880,6 +880,8 @@ namespace System.Data {
|
||||
if (isEmpty || !Copy.Columns.Contains (column.ColumnName))
|
||||
Copy.Columns.Add (column.Clone ());
|
||||
}
|
||||
foreach (DataColumn column in Copy.Columns)
|
||||
column.CompileExpression ();
|
||||
|
||||
CopyConstraints (Copy);
|
||||
// add primary key to the copy
|
||||
|
||||
@@ -54,7 +54,6 @@ namespace System.Data {
|
||||
private DataTable table;
|
||||
private Hashtable DiffGrRows = new Hashtable ();
|
||||
private Hashtable ErrorRows = new Hashtable ();
|
||||
|
||||
#endregion // Fields
|
||||
|
||||
#region ctors
|
||||
@@ -222,7 +221,7 @@ namespace System.Data {
|
||||
|
||||
private void LoadColumnAttributes (DataTable Table, DataRow Row,
|
||||
XmlReader reader, DataRowVersion loadType)
|
||||
{
|
||||
{
|
||||
if (!reader.HasAttributes // this check will be faster
|
||||
|| !reader.MoveToFirstAttribute ())
|
||||
return;
|
||||
@@ -273,8 +272,10 @@ namespace System.Data {
|
||||
{
|
||||
object data = XmlDataLoader.StringToObject (Table.Columns[colName].DataType, reader.ReadString ());
|
||||
|
||||
if (loadType == DataRowVersion.Current) Row [colName] = data;
|
||||
else Row.SetOriginalValue (colName, data);
|
||||
if (loadType == DataRowVersion.Current)
|
||||
Row [colName] = data;
|
||||
else
|
||||
Row.SetOriginalValue (colName, data);
|
||||
reader.Read ();
|
||||
}
|
||||
else
|
||||
@@ -289,7 +290,6 @@ namespace System.Data {
|
||||
reader.Skip ();
|
||||
}
|
||||
}
|
||||
|
||||
reader.ReadEndElement ();
|
||||
}
|
||||
|
||||
@@ -351,6 +351,7 @@ namespace System.Data {
|
||||
|
||||
DataTable GetTable (string name)
|
||||
{
|
||||
name = XmlConvert.DecodeName (name);
|
||||
if (DSet != null)
|
||||
return DSet.Tables [name];
|
||||
else if (name == table.TableName)
|
||||
|
||||
@@ -10,9 +10,10 @@
|
||||
// (C) Copyright 2002 Rodrigo Moya
|
||||
// (C) Copyright 2003 Daniel Morgan
|
||||
// (C) Copyright 2003 Martin Willemoes Hansen
|
||||
//
|
||||
// (C) Copyright 2011 Xamarin Inc
|
||||
|
||||
//
|
||||
// Copyright 2011 Xamarin Inc (http://www.xamarin.com)
|
||||
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
@@ -913,5 +914,46 @@ namespace MonoTests.System.Data
|
||||
Assert.Fail ("SetOrdinalTest failed");
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Xamarin665 ()
|
||||
{
|
||||
var t = new DataTable() ;
|
||||
var c1 = t.Columns.Add ("c1");
|
||||
var c2 = t.Columns.Add ("c2");
|
||||
c2.Expression = "TRIM(ISNULL(c1,' '))";
|
||||
c2.Expression = "SUBSTRING(ISNULL(c1,' '), 1, 10)";
|
||||
}
|
||||
|
||||
DataColumn MakeColumn (string col, string test)
|
||||
{
|
||||
return new DataColumn () {
|
||||
ColumnName = col,
|
||||
Expression = test
|
||||
};
|
||||
}
|
||||
|
||||
#if false
|
||||
// Check Windows output for the row [0] value
|
||||
[Test]
|
||||
public void NullStrings ()
|
||||
{
|
||||
var a = MakeColumn ("nullbar", "null+'bar'");
|
||||
var b = MakeColumn ("barnull", "'bar'+null");
|
||||
var c = MakeColumn ("foobar", "'foo'+'bar'");
|
||||
|
||||
var table = new DataTable();
|
||||
|
||||
table.Columns.Add(a);
|
||||
table.Columns.Add(b);
|
||||
table.Columns.Add(c);
|
||||
|
||||
var row = table.NewRow();
|
||||
table.Rows.Add(row);
|
||||
Assert.AreEqual (row [0], DBNull.Value, "#1");
|
||||
Assert.AreEqual (row [1], DBNull.Value, "#2");
|
||||
Assert.AreEqual (row [2], "foobar", "#3");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -2563,6 +2563,30 @@ namespace MonoTests.System.Data
|
||||
Assert.AreEqual (2, dsLoad.Tables[2].Columns.Count, "T3-Columns");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReadDiff ()
|
||||
{
|
||||
DataSet dsTest = new DataSet ("MonoTouchTest");
|
||||
var dt = new DataTable ("123");
|
||||
dt.Columns.Add (new DataColumn ("Value1"));
|
||||
dt.Columns.Add (new DataColumn ("Value2"));
|
||||
dsTest.Tables.Add (dt);
|
||||
dsTest.ReadXml (new StringReader (@"
|
||||
<diffgr:diffgram
|
||||
xmlns:msdata='urn:schemas-microsoft-com:xml-msdata'
|
||||
xmlns:diffgr='urn:schemas-microsoft-com:xml-diffgram-v1'>
|
||||
<MonoTouchTest>
|
||||
<_x0031_23 diffgr:id='1231' msdata:rowOrder='0'>
|
||||
<Value1>Row1Value1</Value1>
|
||||
<Value2>Row1Value2</Value2>
|
||||
</_x0031_23>
|
||||
</MonoTouchTest>
|
||||
</diffgr:diffgram>
|
||||
"));
|
||||
Assert.AreEqual ("123", dsTest.Tables [0].TableName, "#1");
|
||||
Assert.AreEqual (1, dsTest.Tables [0].Rows.Count, "#2");
|
||||
}
|
||||
|
||||
private void CompareTables (DataSet dsLoad) {
|
||||
Assert.AreEqual (ds.Tables.Count, dsLoad.Tables.Count, "NumTables");
|
||||
for (int tc = 0; tc < dsLoad.Tables.Count; tc++) {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
//
|
||||
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
|
||||
// Copyright (C) 2011 Xamarin Inc. (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
@@ -1043,6 +1044,43 @@ namespace MonoTests.System.Data
|
||||
Assert.AreEqual ("Table#1", copyTable.TableName, "#A30");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CloneExtendedProperties ()
|
||||
{
|
||||
// bug 668
|
||||
DataTable t1 = new DataTable ("t1");
|
||||
DataColumn c1 = t1.Columns.Add ("c1");
|
||||
c1.ExtendedProperties.Add ("Company", "Xamarin");
|
||||
|
||||
DataTable t2 = t1.Clone ();
|
||||
Assert.AreEqual ("Xamarin", t1.Columns["c1"].ExtendedProperties["Company"], "CEP1");
|
||||
Assert.AreEqual ("Xamarin", t2.Columns["c1"].ExtendedProperties["Company"], "CEP2");
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (EvaluateException))]
|
||||
public void CloneExtendedProperties1 ()
|
||||
{
|
||||
// Xamarin bug 666
|
||||
DataTable table1 = new DataTable("Table1") ;
|
||||
|
||||
DataColumn c1 = table1.Columns.Add("c1", typeof(string), "'hello ' + c2") ; /* Should cause an exception */
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CloneExtendedProperties2 ()
|
||||
{
|
||||
// Xamarin bug 666
|
||||
DataTable table1 = new DataTable("Table1") ;
|
||||
|
||||
DataColumn c1 = table1.Columns.Add("c1") ;
|
||||
DataColumn c2 = table1.Columns.Add("c2") ;
|
||||
|
||||
c1.Expression = "'hello ' + c2";
|
||||
|
||||
DataTable t2 = table1.Clone(); // this should not cause an exception
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LoadDataException ()
|
||||
{
|
||||
|
||||
+17
-2
@@ -54,9 +54,24 @@ namespace System.IdentityModel.Tokens
|
||||
#if TARGET_DOTNET
|
||||
throw new NotImplementedException ();
|
||||
#else
|
||||
return new BigInteger (FromBinHex (hexString)).ToString ();
|
||||
// http://tools.ietf.org/html/rfc5280#section-4.1.2.2
|
||||
// We SHOULD support negative numbers
|
||||
var bytes = FromBinHex (hexString);
|
||||
|
||||
var negative = bytes.Length > 0 && bytes [0] >= 0x80;
|
||||
if (negative) {
|
||||
for (int i = 0; i < bytes.Length; i++)
|
||||
bytes [i] = (byte) ~ bytes [i];
|
||||
}
|
||||
|
||||
var big = new BigInteger (bytes);
|
||||
if (negative) {
|
||||
big = big + 1;
|
||||
return "-" + big.ToString ();
|
||||
} else
|
||||
return big.ToString ();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public X509IssuerSerialKeyIdentifierClause (X509Certificate2 certificate)
|
||||
: base (null)
|
||||
|
||||
Binary file not shown.
+10
@@ -40,6 +40,7 @@ namespace MonoTests.System.IdentityModel.Selectors
|
||||
{
|
||||
static readonly X509Certificate2 cert = new X509Certificate2 ("Test/Resources/test.pfx", "mono");
|
||||
static readonly X509Certificate2 cert2 = new X509Certificate2 ("Test/Resources/test2.pfx", "mono");
|
||||
static readonly X509Certificate2 cert3 = new X509Certificate2("Test/Resources/test_neg_serial.cer");
|
||||
|
||||
[Test]
|
||||
public void Properties ()
|
||||
@@ -50,5 +51,14 @@ namespace MonoTests.System.IdentityModel.Selectors
|
||||
Assert.AreEqual ("22491767666218099257720700881460366085", ic.IssuerSerialNumber, "#2");
|
||||
Assert.AreEqual (null, ic.ClauseType, "#3");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NegativeSerialNumber ()
|
||||
{
|
||||
var clause = new X509IssuerSerialKeyIdentifierClause (cert3);
|
||||
Assert.AreEqual ("CN=test, OU=cert, O=test, [email protected]", clause.IssuerName, "#1");
|
||||
Assert.AreEqual ("-168428216848510272180165529369113665228", clause.IssuerSerialNumber, "#2");
|
||||
Assert.AreEqual (null, clause.ClauseType, "#3");
|
||||
}
|
||||
}
|
||||
}
|
||||
+22
-3
@@ -223,16 +223,26 @@ namespace System.Runtime.Serialization
|
||||
known_types.Add (t);
|
||||
}
|
||||
|
||||
RegisterTypeAsKnown (type);
|
||||
}
|
||||
|
||||
void RegisterTypeAsKnown (Type type)
|
||||
{
|
||||
if (known_types.Contains (type))
|
||||
return;
|
||||
|
||||
Type elementType = type;
|
||||
if (type.HasElementType)
|
||||
elementType = type.GetElementType ();
|
||||
|
||||
known_types.Add (elementType);
|
||||
|
||||
/* Get all KnownTypeAttribute-s, including inherited ones */
|
||||
object [] attrs = elementType.GetCustomAttributes (typeof (KnownTypeAttribute), true);
|
||||
for (int i = 0; i < attrs.Length; i ++) {
|
||||
KnownTypeAttribute kt = (KnownTypeAttribute) attrs [i];
|
||||
foreach (var t in kt.GetTypes (elementType))
|
||||
known_types.Add (t);
|
||||
RegisterTypeAsKnown (t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -458,8 +468,7 @@ namespace System.Runtime.Serialization
|
||||
|
||||
if (rootQName == null &&
|
||||
graph.GetType () != type &&
|
||||
!known_types.Contains (graph.GetType ()) &&
|
||||
KnownTypeCollection.GetPrimitiveTypeName (graph.GetType ()) == QName.Empty)
|
||||
IsUnknownType (graph.GetType ()))
|
||||
throw new SerializationException (String.Format ("Type '{0}' is unexpected. The type should either be registered as a known type, or DataContractResolver should be used.", graph.GetType ()));
|
||||
|
||||
QName instName = rootQName;
|
||||
@@ -503,6 +512,16 @@ namespace System.Runtime.Serialization
|
||||
writer.WriteEndAttribute ();
|
||||
*/
|
||||
}
|
||||
|
||||
bool IsUnknownType (Type type)
|
||||
{
|
||||
if (known_types.Contains (type) ||
|
||||
KnownTypeCollection.GetPrimitiveTypeName (type) != QName.Empty)
|
||||
return false;
|
||||
if (type.IsArray)
|
||||
return IsUnknownType (type.GetElementType ());
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void WriteEndObject (XmlDictionaryWriter writer)
|
||||
{
|
||||
|
||||
+60
-2
@@ -115,6 +115,9 @@ namespace System.Runtime.Serialization
|
||||
// not in ms nsURI schema
|
||||
dbnull_type, date_time_offset_type;
|
||||
|
||||
// XmlSchemaType.GetBuiltInPrimitiveType() does not exist in moonlight, so I had to explicitly add them. And now that we have it, it does not make much sense to use #if MOONLIGHT ... #endif for XmlSchemaType anymore :-(
|
||||
static Dictionary<string,Type> xs_predefined_types = new Dictionary<string,Type> ();
|
||||
|
||||
static KnownTypeCollection ()
|
||||
{
|
||||
string s = MSSimpleNamespace;
|
||||
@@ -142,6 +145,55 @@ namespace System.Runtime.Serialization
|
||||
|
||||
dbnull_type = new QName ("DBNull", DefaultClrNamespaceBase + "System");
|
||||
date_time_offset_type = new QName ("DateTimeOffset", DefaultClrNamespaceBase + "System");
|
||||
|
||||
xs_predefined_types.Add ("string", typeof (string));
|
||||
xs_predefined_types.Add ("boolean", typeof (bool));
|
||||
xs_predefined_types.Add ("float", typeof (float));
|
||||
xs_predefined_types.Add ("double", typeof (double));
|
||||
xs_predefined_types.Add ("decimal", typeof (decimal));
|
||||
xs_predefined_types.Add ("duration", typeof (TimeSpan));
|
||||
xs_predefined_types.Add ("dateTime", typeof (DateTime));
|
||||
xs_predefined_types.Add ("date", typeof (DateTime));
|
||||
xs_predefined_types.Add ("time", typeof (DateTime));
|
||||
xs_predefined_types.Add ("gYearMonth", typeof (DateTime));
|
||||
xs_predefined_types.Add ("gYear", typeof (DateTime));
|
||||
xs_predefined_types.Add ("gMonthDay", typeof (DateTime));
|
||||
xs_predefined_types.Add ("gDay", typeof (DateTime));
|
||||
xs_predefined_types.Add ("gMonth", typeof (DateTime));
|
||||
xs_predefined_types.Add ("hexBinary", typeof (byte []));
|
||||
xs_predefined_types.Add ("base64Binary", typeof (byte []));
|
||||
xs_predefined_types.Add ("anyURI", typeof (Uri));
|
||||
xs_predefined_types.Add ("QName", typeof (QName));
|
||||
xs_predefined_types.Add ("NOTATION", typeof (string));
|
||||
|
||||
xs_predefined_types.Add ("normalizedString", typeof (string));
|
||||
xs_predefined_types.Add ("token", typeof (string));
|
||||
xs_predefined_types.Add ("language", typeof (string));
|
||||
xs_predefined_types.Add ("IDREFS", typeof (string []));
|
||||
xs_predefined_types.Add ("ENTITIES", typeof (string []));
|
||||
xs_predefined_types.Add ("NMTOKEN", typeof (string));
|
||||
xs_predefined_types.Add ("NMTOKENS", typeof (string []));
|
||||
xs_predefined_types.Add ("Name", typeof (string));
|
||||
xs_predefined_types.Add ("NCName", typeof (string));
|
||||
xs_predefined_types.Add ("ID", typeof (string));
|
||||
xs_predefined_types.Add ("IDREF", typeof (string));
|
||||
xs_predefined_types.Add ("ENTITY", typeof (string));
|
||||
|
||||
xs_predefined_types.Add ("integer", typeof (decimal));
|
||||
xs_predefined_types.Add ("nonPositiveInteger", typeof (int));
|
||||
xs_predefined_types.Add ("negativeInteger", typeof (int));
|
||||
xs_predefined_types.Add ("long", typeof (long));
|
||||
xs_predefined_types.Add ("int", typeof (int));
|
||||
xs_predefined_types.Add ("short", typeof (short));
|
||||
xs_predefined_types.Add ("byte", typeof (sbyte));
|
||||
xs_predefined_types.Add ("nonNegativeInteger", typeof (decimal));
|
||||
xs_predefined_types.Add ("unsignedLong", typeof (ulong));
|
||||
xs_predefined_types.Add ("unsignedInt", typeof (uint));
|
||||
xs_predefined_types.Add ("unsignedShort", typeof (ushort));
|
||||
xs_predefined_types.Add ("unsignedByte", typeof (byte));
|
||||
xs_predefined_types.Add ("positiveInteger", typeof (decimal));
|
||||
|
||||
xs_predefined_types.Add ("anyType", typeof (object));
|
||||
}
|
||||
|
||||
// FIXME: find out how QName and guid are processed
|
||||
@@ -287,8 +339,8 @@ namespace System.Runtime.Serialization
|
||||
return typeof (DateTimeOffset);
|
||||
}
|
||||
break;
|
||||
// FIXME: xsd types and ms serialization types should be differentiated. (usage problem)
|
||||
case XmlSchema.Namespace:
|
||||
return xs_predefined_types.FirstOrDefault (p => p.Key == name.Name).Value;
|
||||
case MSSimpleNamespace:
|
||||
switch (name.Name) {
|
||||
case "anyURI":
|
||||
@@ -539,6 +591,12 @@ namespace System.Runtime.Serialization
|
||||
{
|
||||
if (name == null)
|
||||
name = GetDefaultName (type);
|
||||
else if (type.IsGenericType) {
|
||||
var args = type.GetGenericArguments ();
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
name = name.Replace ("{" + i + "}", GetStaticQName (args [i]).Name);
|
||||
}
|
||||
|
||||
if (ns == null)
|
||||
ns = GetDefaultNamespace (type);
|
||||
return new QName (name, ns);
|
||||
@@ -604,7 +662,7 @@ namespace System.Runtime.Serialization
|
||||
|
||||
static QName GetSerializableQName (Type type)
|
||||
{
|
||||
#if !NET_2_1
|
||||
#if !MOONLIGHT
|
||||
// First, check XmlSchemaProviderAttribute and try GetSchema() to see if it returns a schema in the expected format.
|
||||
var xpa = type.GetCustomAttribute<XmlSchemaProviderAttribute> (true);
|
||||
if (xpa != null) {
|
||||
|
||||
+7
-8
@@ -440,15 +440,13 @@ namespace System.Runtime.Serialization
|
||||
internal void Initialize ()
|
||||
{
|
||||
Type type = RuntimeType;
|
||||
List <DataMemberInfo> members = new List <DataMemberInfo> ();
|
||||
List <DataMemberInfo> members;
|
||||
object [] atts = type.GetCustomAttributes (
|
||||
typeof (DataContractAttribute), false);
|
||||
IsReference = atts.Length > 0 ? (((DataContractAttribute) atts [0]).IsReference) : false;
|
||||
|
||||
while (type != null) {
|
||||
QName qname = KnownTypes.GetQName (type);
|
||||
|
||||
members = GetMembers (type, qname, true);
|
||||
members = GetMembers (type);
|
||||
members.Sort (DataMemberInfo.DataMemberInfoComparer.Instance);
|
||||
Members.InsertRange (0, members);
|
||||
members.Clear ();
|
||||
@@ -457,12 +455,10 @@ namespace System.Runtime.Serialization
|
||||
}
|
||||
}
|
||||
|
||||
List<DataMemberInfo> GetMembers (Type type, QName qname, bool declared_only)
|
||||
List<DataMemberInfo> GetMembers (Type type)
|
||||
{
|
||||
List<DataMemberInfo> data_members = new List<DataMemberInfo> ();
|
||||
BindingFlags flags = AllInstanceFlags;
|
||||
if (declared_only)
|
||||
flags |= BindingFlags.DeclaredOnly;
|
||||
BindingFlags flags = AllInstanceFlags | BindingFlags.DeclaredOnly;
|
||||
|
||||
foreach (PropertyInfo pi in type.GetProperties (flags)) {
|
||||
DataMemberAttribute dma =
|
||||
@@ -615,6 +611,9 @@ namespace System.Runtime.Serialization
|
||||
public override void SerializeNonReference (object graph,
|
||||
XmlFormatterSerializer serializer)
|
||||
{
|
||||
// output item xmlns in advance so that it does not result in excessive xmlns overwrites.
|
||||
if (XmlName.Namespace != element_qname.Namespace && element_qname.Namespace != KnownTypeCollection.MSSimpleNamespace)
|
||||
serializer.Writer.WriteXmlnsAttribute (null, element_qname.Namespace);
|
||||
|
||||
foreach (object o in (IEnumerable) graph) {
|
||||
serializer.WriteStartElement (element_qname.Name, XmlName.Namespace, CurrentNamespace);
|
||||
|
||||
+1
-1
@@ -152,7 +152,7 @@ namespace System.Runtime.Serialization
|
||||
|
||||
if (isNil) {
|
||||
reader.Skip ();
|
||||
if (!type.IsValueType)
|
||||
if (!type.IsValueType || type == typeof (void))
|
||||
return null;
|
||||
else if (type.IsGenericType && type.GetGenericTypeDefinition () == typeof (Nullable<>))
|
||||
return null;
|
||||
|
||||
+296
-18
@@ -37,9 +37,11 @@ using System.Xml;
|
||||
using System.Xml.Schema;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
using QName = System.Xml.XmlQualifiedName;
|
||||
|
||||
namespace System.Runtime.Serialization
|
||||
{
|
||||
[MonoTODO ("Support ImportXmlType option; support arrays; CanImport is not up to date with Import")]
|
||||
[MonoTODO ("support arrays")]
|
||||
public class XsdDataContractImporter
|
||||
{
|
||||
static readonly XmlQualifiedName qname_anytype = new XmlQualifiedName ("anyType", XmlSchema.Namespace);
|
||||
@@ -71,6 +73,66 @@ namespace System.Runtime.Serialization
|
||||
}
|
||||
}
|
||||
|
||||
void GenerateXmlType (XmlQualifiedName qname)
|
||||
{
|
||||
var cns = GetCodeNamespace (qname.Namespace);
|
||||
var td = new CodeTypeDeclaration () {
|
||||
Name = GetUniqueName (CodeIdentifier.MakeValid (qname.Name), cns),
|
||||
TypeAttributes = GenerateInternal ? TypeAttributes.NotPublic : TypeAttributes.Public,
|
||||
IsPartial = true };
|
||||
cns.Types.Add (td);
|
||||
td.BaseTypes.Add (new CodeTypeReference (typeof (IXmlSerializable)));
|
||||
|
||||
var thisNodes = new CodePropertyReferenceExpression (new CodeThisReferenceExpression (), "Nodes"); // property this.Nodes
|
||||
var xmlSerializableServices = new CodeTypeReferenceExpression (typeof (XmlSerializableServices)); // static XmlSerializableServices.
|
||||
var qnameType = new CodeTypeReference (typeof (XmlQualifiedName));
|
||||
|
||||
// XmlQualifiedName qname = new XmlQualifiedName ({qname.Name}, {qname.Namespace});
|
||||
td.Members.Add (new CodeMemberField () { Name = "qname", Type = qnameType, InitExpression = new CodeObjectCreateExpression (qnameType, new CodePrimitiveExpression (qname.Name), new CodePrimitiveExpression (qname.Namespace)) });
|
||||
|
||||
// public XmlNode[] Nodes { get; set; }
|
||||
td.Members.Add (new CodeMemberProperty () { Name = "Nodes", Type = new CodeTypeReference (typeof (XmlNode [])), Attributes = (GenerateInternal ? MemberAttributes.Assembly : MemberAttributes.Public) | MemberAttributes.Final, HasGet = true, HasSet = true });
|
||||
|
||||
// public void ReadXml(XmlReader reader) {
|
||||
var read = new CodeMemberMethod () { Name = "ReadXml", Attributes = (GenerateInternal ? MemberAttributes.Assembly : MemberAttributes.Public) | MemberAttributes.Final };
|
||||
read.Parameters.Add (new CodeParameterDeclarationExpression (new CodeTypeReference (typeof (XmlReader)), "reader"));
|
||||
// this.Nodes = XmlSerializableServices.ReadXml(reader);
|
||||
read.Statements.Add (
|
||||
new CodeAssignStatement (thisNodes,
|
||||
new CodeMethodInvokeExpression (
|
||||
new CodeMethodReferenceExpression (xmlSerializableServices, "ReadXml"),
|
||||
new CodeArgumentReferenceExpression ("reader"))));
|
||||
// }
|
||||
td.Members.Add (read);
|
||||
|
||||
// public void WriteXml(XmlWriter writer) {
|
||||
var write = new CodeMemberMethod () { Name = "WriteXml",Attributes = (GenerateInternal ? MemberAttributes.Assembly : MemberAttributes.Public) | MemberAttributes.Final };
|
||||
write.Parameters.Add (new CodeParameterDeclarationExpression (new CodeTypeReference (typeof (XmlWriter)), "writer"));
|
||||
// XmlSerializableServices.WriteXml(writer, this.Nodes);
|
||||
write.Statements.Add (
|
||||
new CodeMethodInvokeExpression (
|
||||
new CodeMethodReferenceExpression (xmlSerializableServices, "WriteXml"),
|
||||
new CodeArgumentReferenceExpression ("writer"),
|
||||
thisNodes));
|
||||
// }
|
||||
td.Members.Add (write);
|
||||
|
||||
// public XmlSchema GetSchema () { return null; }
|
||||
var getSchema = new CodeMemberMethod () { Name = "GetSchema", Attributes = (GenerateInternal ? MemberAttributes.Assembly : MemberAttributes.Public) | MemberAttributes.Final, ReturnType = new CodeTypeReference (typeof (XmlSchema)) };
|
||||
getSchema.Statements.Add (new CodeMethodReturnStatement (new CodePrimitiveExpression (null)));
|
||||
td.Members.Add (getSchema);
|
||||
|
||||
// public static XmlQualifiedName ExportSchema (XmlSchemaSet schemas) {
|
||||
var export = new CodeMemberMethod () { Name = "ExportSchema", Attributes = (GenerateInternal ? MemberAttributes.Assembly : MemberAttributes.Public) | MemberAttributes.Final | MemberAttributes.Static, ReturnType = qnameType };
|
||||
export.Parameters.Add (new CodeParameterDeclarationExpression (new CodeTypeReference (typeof (XmlSchemaSet)), "schemas"));
|
||||
// XmlSerializableServices.AddDefaultSchema (schemas);
|
||||
export.Statements.Add (new CodeMethodInvokeExpression (xmlSerializableServices, "AddDefaultSchema", new CodeArgumentReferenceExpression ("schemas")));
|
||||
// return qname;
|
||||
export.Statements.Add (new CodeMethodReturnStatement (new CodeFieldReferenceExpression (new CodeThisReferenceExpression (), "qname")));
|
||||
// }
|
||||
td.Members.Add (export);
|
||||
}
|
||||
|
||||
// CanImport
|
||||
|
||||
public bool CanImport (XmlSchemaSet schemas)
|
||||
@@ -113,23 +175,196 @@ namespace System.Runtime.Serialization
|
||||
if (!schemas.IsCompiled)
|
||||
schemas.Compile ();
|
||||
|
||||
if (!schemas.GlobalTypes.Contains (typeName))
|
||||
throw new InvalidDataContractException (String.Format ("Type {0} is not found in the schemas", typeName));
|
||||
if (IsPredefinedType (typeName))
|
||||
return true; // while it just ignores...
|
||||
|
||||
return CanImport (schemas, schemas.GlobalTypes [typeName] as XmlSchemaComplexType);
|
||||
if (!schemas.GlobalTypes.Contains (typeName))
|
||||
return false;
|
||||
|
||||
return CanImport (schemas, schemas.GlobalTypes [typeName] as XmlSchemaType);
|
||||
}
|
||||
|
||||
public bool CanImport (XmlSchemaSet schemas, XmlSchemaElement element)
|
||||
{
|
||||
if (schemas == null)
|
||||
throw new ArgumentNullException ("schemas");
|
||||
if (element == null)
|
||||
throw new ArgumentNullException ("element");
|
||||
|
||||
if (!schemas.IsCompiled)
|
||||
schemas.Compile ();
|
||||
|
||||
return CanImport (schemas, element.ElementSchemaType as XmlSchemaComplexType);
|
||||
if (element.ElementSchemaType != null)
|
||||
return CanImport (schemas, element.ElementSchemaType as XmlSchemaType);
|
||||
else if (element.SchemaTypeName != null && !element.SchemaTypeName.Equals (QName.Empty))
|
||||
return CanImport (schemas, element.SchemaTypeName);
|
||||
else
|
||||
// anyType
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#if true // new
|
||||
bool CanImport (XmlSchemaSet schemas, XmlSchemaType type)
|
||||
{
|
||||
if (IsPredefinedType (type.QualifiedName))
|
||||
return true;
|
||||
|
||||
var st = type as XmlSchemaSimpleType;
|
||||
if (st != null) {
|
||||
return CanImportSimpleType (schemas, st);
|
||||
} else {
|
||||
var ct = (XmlSchemaComplexType) type;
|
||||
var sc = ct.ContentModel as XmlSchemaSimpleContent;
|
||||
if (sc != null) {
|
||||
if (sc.Content is XmlSchemaSimpleContentExtension)
|
||||
return false;
|
||||
}
|
||||
if (!CanImportComplexType (schemas, ct))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool CanImportSimpleType (XmlSchemaSet schemas, XmlSchemaSimpleType type)
|
||||
{
|
||||
var scl = type.Content as XmlSchemaSimpleTypeList;
|
||||
if (scl != null) {
|
||||
if (scl.ItemType == null)
|
||||
return false;
|
||||
var itemType = scl.ItemType as XmlSchemaSimpleType;
|
||||
var ir = itemType.Content as XmlSchemaSimpleTypeRestriction;
|
||||
if (ir == null)
|
||||
return false;
|
||||
return true; // as enum
|
||||
}
|
||||
var scr = type.Content as XmlSchemaSimpleTypeRestriction;
|
||||
if (scr != null)
|
||||
return true; // as enum
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CanImportComplexType (XmlSchemaSet schemas, XmlSchemaComplexType type)
|
||||
{
|
||||
foreach (XmlSchemaAttribute att in type.AttributeUses.Values)
|
||||
if (att.Use != XmlSchemaUse.Optional || att.QualifiedName.Namespace != KnownTypeCollection.MSSimpleNamespace)
|
||||
return false;
|
||||
|
||||
CodeTypeReference baseClrType = null;
|
||||
var particle = type.Particle;
|
||||
if (type.ContentModel != null) {
|
||||
var xsscr = type.ContentModel.Content as XmlSchemaSimpleContentRestriction;
|
||||
if (xsscr != null) {
|
||||
if (xsscr.BaseType != null) {
|
||||
if (!CanImport (schemas, xsscr.BaseType))
|
||||
return false;
|
||||
} else {
|
||||
if (!CanImport (schemas, xsscr.BaseTypeName))
|
||||
return false;
|
||||
}
|
||||
// The above will result in an error, but make sure to show we don't support it.
|
||||
return false;
|
||||
}
|
||||
var xscce = type.ContentModel.Content as XmlSchemaComplexContentExtension;
|
||||
if (xscce != null) {
|
||||
if (!CanImport (schemas, xscce.BaseTypeName))
|
||||
return false;
|
||||
baseClrType = GetCodeTypeReferenceInternal (xscce.BaseTypeName, false);
|
||||
|
||||
var baseInfo = GetTypeInfo (xscce.BaseTypeName, false);
|
||||
particle = xscce.Particle;
|
||||
}
|
||||
var xsccr = type.ContentModel.Content as XmlSchemaComplexContentRestriction;
|
||||
if (xsccr != null)
|
||||
return false;
|
||||
}
|
||||
|
||||
var seq = particle as XmlSchemaSequence;
|
||||
if (seq == null && particle != null)
|
||||
return false;
|
||||
|
||||
if (seq != null) {
|
||||
|
||||
if (seq.Items.Count == 1 && seq.Items [0] is XmlSchemaAny && type.Parent is XmlSchemaElement) {
|
||||
|
||||
// looks like it is not rejected (which contradicts the error message on .NET). See XsdDataContractImporterTest.ImportTestX32(). Also ImporTestX13() for Parent check.
|
||||
|
||||
} else {
|
||||
|
||||
foreach (var child in seq.Items)
|
||||
if (!(child is XmlSchemaElement))
|
||||
return false;
|
||||
|
||||
bool isDictionary = false;
|
||||
if (type.Annotation != null) {
|
||||
foreach (var ann in type.Annotation.Items) {
|
||||
var ai = ann as XmlSchemaAppInfo;
|
||||
if (ai != null && ai.Markup != null &&
|
||||
ai.Markup.Length > 0 &&
|
||||
ai.Markup [0].NodeType == XmlNodeType.Element &&
|
||||
ai.Markup [0].LocalName == "IsDictionary" &&
|
||||
ai.Markup [0].NamespaceURI == KnownTypeCollection.MSSimpleNamespace)
|
||||
isDictionary = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (seq.Items.Count == 1) {
|
||||
var pt = (XmlSchemaParticle) seq.Items [0];
|
||||
var xe = pt as XmlSchemaElement;
|
||||
if (pt.MaxOccursString == "unbounded") {
|
||||
// import as a collection contract.
|
||||
if (pt is XmlSchemaAny) {
|
||||
} else if (isDictionary) {
|
||||
var kvt = xe.ElementSchemaType as XmlSchemaComplexType;
|
||||
var seq2 = kvt != null ? kvt.Particle as XmlSchemaSequence : null;
|
||||
var k = seq2 != null && seq2.Items.Count == 2 ? seq2.Items [0] as XmlSchemaElement : null;
|
||||
var v = seq2 != null && seq2.Items.Count == 2 ? seq2.Items [1] as XmlSchemaElement : null;
|
||||
if (k == null || v == null)
|
||||
return false;
|
||||
if (!CanImport (schemas, k.ElementSchemaType))
|
||||
return false;
|
||||
if (!CanImport (schemas, v.ElementSchemaType))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
} else if (type.QualifiedName.Namespace == KnownTypeCollection.MSArraysNamespace &&
|
||||
IsPredefinedType (xe.ElementSchemaType.QualifiedName)) {
|
||||
// then this CodeTypeDeclaration is to be removed, and CodeTypeReference to this type should be an array instead.
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if (!CanImport (schemas, xe.ElementSchemaType))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (isDictionary)
|
||||
return false;
|
||||
|
||||
// import as a (normal) contract.
|
||||
var elems = new List<XmlSchemaElement> ();
|
||||
foreach (XmlSchemaElement xe in seq.Items) {
|
||||
if (xe.MaxOccurs != 1)
|
||||
return false;
|
||||
|
||||
if (elems.Any (e => e.QualifiedName.Name == xe.QualifiedName.Name))
|
||||
return false;
|
||||
|
||||
elems.Add (xe);
|
||||
}
|
||||
foreach (var xe in elems) {
|
||||
// import property type in prior.
|
||||
if (!CanImport (schemas, xe.ElementSchemaType.QualifiedName))
|
||||
return false;
|
||||
}
|
||||
|
||||
} // if (seq contains only an xs:any)
|
||||
} // if (seq != 0)
|
||||
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
bool CanImport (XmlSchemaSet schemas, XmlSchemaComplexType type)
|
||||
{
|
||||
if (type == null || type.QualifiedName.Namespace == XmlSchema.Namespace) // xs:anyType -> not supported.
|
||||
@@ -148,6 +383,7 @@ namespace System.Runtime.Serialization
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Import
|
||||
|
||||
@@ -181,6 +417,9 @@ namespace System.Runtime.Serialization
|
||||
if (typeName == null)
|
||||
throw new ArgumentNullException ("typeName");
|
||||
|
||||
if (!schemas.IsCompiled)
|
||||
schemas.Compile ();
|
||||
|
||||
if (IsPredefinedType (typeName))
|
||||
return;
|
||||
|
||||
@@ -199,6 +438,9 @@ namespace System.Runtime.Serialization
|
||||
|
||||
var elname = element.QualifiedName;
|
||||
|
||||
if (IsPredefinedType (element.SchemaTypeName))
|
||||
return elname;
|
||||
|
||||
switch (elname.Namespace) {
|
||||
case KnownTypeCollection.MSSimpleNamespace:
|
||||
switch (elname.Name) {
|
||||
@@ -210,14 +452,35 @@ namespace System.Runtime.Serialization
|
||||
break;
|
||||
}
|
||||
|
||||
if (!CanImport (schemas, element) && Options != null && Options.ImportXmlType) {
|
||||
var qn = element.QualifiedName;
|
||||
GenerateXmlType (qn);
|
||||
return qn;
|
||||
}
|
||||
|
||||
// FIXME: use element to fill nillable and arrays.
|
||||
var qname = element.SchemaType != null ? element.QualifiedName : element.ElementSchemaType.QualifiedName;
|
||||
Import (schemas, element.ElementSchemaType, qname);
|
||||
var qname =
|
||||
elname != null && !elname.Equals (QName.Empty) ? elname :
|
||||
element.ElementSchemaType != null ? element.ElementSchemaType.QualifiedName :
|
||||
qname_anytype;
|
||||
|
||||
if (element.ElementSchemaType != null)
|
||||
Import (schemas, element.ElementSchemaType, qname);
|
||||
else if (element.SchemaTypeName != null && !element.SchemaTypeName.Equals (QName.Empty))
|
||||
Import (schemas, schemas.GlobalTypes [element.SchemaTypeName] as XmlSchemaType, qname);
|
||||
// otherwise it is typeless == anyType.
|
||||
else
|
||||
Import (schemas, XmlSchemaType.GetBuiltInComplexType (qname_anytype), qname);
|
||||
|
||||
return qname;
|
||||
}
|
||||
|
||||
void Import (XmlSchemaSet schemas, XmlSchemaType type)
|
||||
{
|
||||
if (!CanImport (schemas, type) && Options != null && Options.ImportXmlType) {
|
||||
GenerateXmlType (type.QualifiedName);
|
||||
return;
|
||||
}
|
||||
Import (schemas, type, type.QualifiedName);
|
||||
}
|
||||
|
||||
@@ -247,12 +510,13 @@ namespace System.Runtime.Serialization
|
||||
{
|
||||
CodeNamespace cns = null;
|
||||
CodeTypeReference clrRef;
|
||||
cns = GetCodeNamespace (qname);
|
||||
cns = GetCodeNamespace (qname.Namespace);
|
||||
clrRef = new CodeTypeReference (cns.Name.Length > 0 ? cns.Name + "." + qname.Name : qname.Name);
|
||||
|
||||
var td = new CodeTypeDeclaration () {
|
||||
Name = GetUniqueName (CodeIdentifier.MakeValid (qname.Name), cns),
|
||||
TypeAttributes = GenerateInternal ? TypeAttributes.NotPublic : TypeAttributes.Public };
|
||||
TypeAttributes = GenerateInternal ? TypeAttributes.NotPublic : TypeAttributes.Public,
|
||||
IsPartial = true };
|
||||
cns.Types.Add (td);
|
||||
|
||||
var info = new TypeImportInfo () { ClrType = clrRef, XsdType = type, XsdTypeName = qname };
|
||||
@@ -393,7 +657,6 @@ namespace System.Runtime.Serialization
|
||||
}
|
||||
|
||||
// Returns false if it should remove the imported type.
|
||||
// FIXME: also support ImportXmlType
|
||||
bool ImportComplexType (CodeTypeDeclaration td, XmlSchemaSet schemas, XmlSchemaComplexType type, XmlQualifiedName qname)
|
||||
{
|
||||
foreach (XmlSchemaAttribute att in type.AttributeUses.Values)
|
||||
@@ -435,6 +698,12 @@ namespace System.Runtime.Serialization
|
||||
|
||||
if (seq != null) {
|
||||
|
||||
if (seq.Items.Count == 1 && seq.Items [0] is XmlSchemaAny && type.Parent is XmlSchemaElement) {
|
||||
|
||||
// looks like it is not rejected (which contradicts the error message on .NET). See XsdDataContractImporterTest.ImportTestX32(). Also ImporTestX13() for Parent check.
|
||||
|
||||
} else {
|
||||
|
||||
foreach (var child in seq.Items)
|
||||
if (!(child is XmlSchemaElement))
|
||||
throw new InvalidDataContractException (String.Format ("Only local element is allowed as the content of the sequence of the top-level content of a complex type '{0}'. Other particles (sequence, choice, all, any, group ref) are not supported.", qname));
|
||||
@@ -453,10 +722,12 @@ namespace System.Runtime.Serialization
|
||||
}
|
||||
|
||||
if (seq.Items.Count == 1) {
|
||||
var xe = (XmlSchemaElement) seq.Items [0];
|
||||
if (xe.MaxOccursString == "unbounded") {
|
||||
var pt = (XmlSchemaParticle) seq.Items [0];
|
||||
var xe = pt as XmlSchemaElement;
|
||||
if (pt.MaxOccursString == "unbounded") {
|
||||
// import as a collection contract.
|
||||
if (isDictionary) {
|
||||
if (pt is XmlSchemaAny) {
|
||||
} else if (isDictionary) {
|
||||
var kvt = xe.ElementSchemaType as XmlSchemaComplexType;
|
||||
var seq2 = kvt != null ? kvt.Particle as XmlSchemaSequence : null;
|
||||
var k = seq2 != null && seq2.Items.Count == 2 ? seq2.Items [0] as XmlSchemaElement : null;
|
||||
@@ -503,6 +774,7 @@ namespace System.Runtime.Serialization
|
||||
AddProperty (td, xe);
|
||||
}
|
||||
|
||||
} // if (seq contains only an xs:any)
|
||||
} // if (seq != 0)
|
||||
|
||||
AddTypeAttributes (td, type);
|
||||
@@ -542,19 +814,22 @@ namespace System.Runtime.Serialization
|
||||
|
||||
bool IsPredefinedType (XmlQualifiedName qname)
|
||||
{
|
||||
if (qname == null)
|
||||
return false;
|
||||
switch (qname.Namespace) {
|
||||
case KnownTypeCollection.MSSimpleNamespace:
|
||||
case XmlSchema.Namespace:
|
||||
return KnownTypeCollection.GetPrimitiveTypeFromName (qname) != null;
|
||||
case XmlSchema.Namespace:
|
||||
return XmlSchemaType.GetBuiltInSimpleType (qname) != null || XmlSchemaType.GetBuiltInComplexType (qname) != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
CodeNamespace GetCodeNamespace (XmlQualifiedName name)
|
||||
CodeNamespace GetCodeNamespace (string xmlns)
|
||||
{
|
||||
string ns = null;
|
||||
if (Options == null || !Options.Namespaces.TryGetValue (name.Namespace, out ns))
|
||||
ns = GetCodeNamespaceFromXmlns (name.Namespace);
|
||||
if (Options == null || !Options.Namespaces.TryGetValue (xmlns, out ns))
|
||||
ns = GetCodeNamespaceFromXmlns (xmlns);
|
||||
|
||||
foreach (CodeNamespace cns in CodeCompileUnit.Namespaces)
|
||||
if (cns.Name == ns)
|
||||
@@ -615,7 +890,10 @@ namespace System.Runtime.Serialization
|
||||
switch (typeName.Namespace) {
|
||||
case XmlSchema.Namespace:
|
||||
case KnownTypeCollection.MSSimpleNamespace:
|
||||
return new CodeTypeReference (KnownTypeCollection.GetPrimitiveTypeFromName (typeName));
|
||||
var pt = KnownTypeCollection.GetPrimitiveTypeFromName (typeName);
|
||||
if (pt == null)
|
||||
throw new ArgumentException (String.Format ("Invalid type name in a predefined namespace: {0}", typeName));
|
||||
return new CodeTypeReference (pt);
|
||||
}
|
||||
|
||||
var info = GetTypeInfo (typeName, throwError);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
System.Runtime.Serialization/Bug666333Test.cs
|
||||
System.Runtime.Serialization/Bug675144Test.cs
|
||||
System.Runtime.Serialization/Bug695203Test.cs
|
||||
System.Runtime.Serialization/DataContractResolverTest.cs
|
||||
System.Runtime.Serialization/KnownTypeAttributeTest.cs
|
||||
System.Runtime.Serialization/XmlObjectSerializerTest.cs
|
||||
|
||||
@@ -173,6 +173,8 @@ namespace System.Xml
|
||||
return XmlConvert.ToString ((float) TypedValue);
|
||||
case BF.Double:
|
||||
return XmlConvert.ToString ((double) TypedValue);
|
||||
case BF.Decimal:
|
||||
return XmlConvert.ToString ((decimal) TypedValue);
|
||||
case BF.DateTime:
|
||||
return XmlConvert.ToString ((DateTime) TypedValue, XmlDateTimeSerializationMode.RoundtripKind);
|
||||
case BF.TimeSpan:
|
||||
|
||||
@@ -17,6 +17,7 @@ ns10.xsd : contains element with substitutionGroup. E2 is resolved to be
|
||||
ns11.xsd : contains xs:choice as the particle, not supported in WCF(!)
|
||||
ns12.xsd : contains xs:all as the particle, not supported in WCF(!)
|
||||
ns13.xsd : contains xs:any as the content of xs:sequence, not supported in WCF.
|
||||
see also ns33.xsd which contains an xs:element and thus OK.
|
||||
ns14.xsd : contains simple content restriction by enum. Mapped to CLI enum.
|
||||
ns15.xsd : contains simple list by string, not supported in WCF.
|
||||
ns16.xsd : contains simple list by embedded enumeration string type.
|
||||
@@ -38,3 +39,7 @@ ns28.xsd : dictionary collection type.
|
||||
ns29.xsd : variation of ns28, removed Value. Error.
|
||||
ns30.xsd : variation of ns28, customized name. Shown in [DataMember].
|
||||
ns31.xsd : variation of ns28, removed IsDictionary appInfo. Becomes List<T>.
|
||||
ns32.xsd : variation of ns13, moved xs:complexType under xs:element and thus
|
||||
became OK. (despite the error message explicitly prohibits this!)
|
||||
ns33.xsd : variation of ns13, replaced xs:any with xs:element and became OK
|
||||
(despite the error message explicitly prohibits this!)
|
||||
@@ -0,0 +1,10 @@
|
||||
<xs:schema targetNamespace="urn:bar" xmlns="urn:bar"
|
||||
xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
|
||||
<xs:element name="E1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:any />
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
@@ -0,0 +1,9 @@
|
||||
<xs:schema targetNamespace="urn:bar" xmlns="urn:bar"
|
||||
xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
|
||||
<xs:element name="E1" type="T1" />
|
||||
<xs:complexType name="T1">
|
||||
<xs:sequence>
|
||||
<xs:element name="x" />
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:schema>
|
||||
@@ -0,0 +1,19 @@
|
||||
<xs:schema
|
||||
targetNamespace="http://www.onvif.org/ver10/device/wsdl"
|
||||
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:tt="http://www.onvif.org/ver10/schema"
|
||||
xmlns:tds="http://www.onvif.org/ver10/device/wsdl"
|
||||
elementFormDefault="qualified" >
|
||||
<xs:element name="GetSystemDateAndTime">
|
||||
<xs:complexType>
|
||||
<xs:sequence/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="GetSystemDateAndTimeResponse">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="SystemDateAndTime" type="tt:SystemDateTime" />
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
@@ -0,0 +1,21 @@
|
||||
<xs:schema
|
||||
targetNamespace="http://www.onvif.org/ver10/schema"
|
||||
elementFormDefault="qualified"
|
||||
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:tt="http://www.onvif.org/ver10/schema">
|
||||
|
||||
<xs:complexType name="SystemDateTime">
|
||||
<xs:sequence>
|
||||
<xs:element name="foobar" type="xs:string" minOccurs="0" />
|
||||
<xs:element name="Extension" type="tt:SystemDateTimeExtension" minOccurs="0"/>
|
||||
</xs:sequence>
|
||||
<!-- xs:anyAttribute processContents="lax"/ -->
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="SystemDateTimeExtension">
|
||||
<xs:sequence>
|
||||
<xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
|
||||
</xs:schema>
|
||||
@@ -0,0 +1,287 @@
|
||||
<?xml version='1.0'?>
|
||||
<?xml-stylesheet href="../2008/09/xsd.xsl" type="text/xsl"?>
|
||||
<xs:schema targetNamespace="http://www.w3.org/XML/1998/namespace"
|
||||
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns ="http://www.w3.org/1999/xhtml"
|
||||
xml:lang="en">
|
||||
|
||||
<xs:annotation>
|
||||
<xs:documentation>
|
||||
<div>
|
||||
<h1>About the XML namespace</h1>
|
||||
|
||||
<div class="bodytext">
|
||||
<p>
|
||||
This schema document describes the XML namespace, in a form
|
||||
suitable for import by other schema documents.
|
||||
</p>
|
||||
<p>
|
||||
See <a href="http://www.w3.org/XML/1998/namespace.html">
|
||||
http://www.w3.org/XML/1998/namespace.html</a> and
|
||||
<a href="http://www.w3.org/TR/REC-xml">
|
||||
http://www.w3.org/TR/REC-xml</a> for information
|
||||
about this namespace.
|
||||
</p>
|
||||
<p>
|
||||
Note that local names in this namespace are intended to be
|
||||
defined only by the World Wide Web Consortium or its subgroups.
|
||||
The names currently defined in this namespace are listed below.
|
||||
They should not be used with conflicting semantics by any Working
|
||||
Group, specification, or document instance.
|
||||
</p>
|
||||
<p>
|
||||
See further below in this document for more information about <a
|
||||
href="#usage">how to refer to this schema document from your own
|
||||
XSD schema documents</a> and about <a href="#nsversioning">the
|
||||
namespace-versioning policy governing this schema document</a>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
|
||||
<xs:attribute name="lang">
|
||||
<xs:annotation>
|
||||
<xs:documentation>
|
||||
<div>
|
||||
|
||||
<h3>lang (as an attribute name)</h3>
|
||||
<p>
|
||||
denotes an attribute whose value
|
||||
is a language code for the natural language of the content of
|
||||
any element; its value is inherited. This name is reserved
|
||||
by virtue of its definition in the XML specification.</p>
|
||||
|
||||
</div>
|
||||
<div>
|
||||
<h4>Notes</h4>
|
||||
<p>
|
||||
Attempting to install the relevant ISO 2- and 3-letter
|
||||
codes as the enumerated possible values is probably never
|
||||
going to be a realistic possibility.
|
||||
</p>
|
||||
<p>
|
||||
See BCP 47 at <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt">
|
||||
http://www.rfc-editor.org/rfc/bcp/bcp47.txt</a>
|
||||
and the IANA language subtag registry at
|
||||
<a href="http://www.iana.org/assignments/language-subtag-registry">
|
||||
http://www.iana.org/assignments/language-subtag-registry</a>
|
||||
for further information.
|
||||
</p>
|
||||
<p>
|
||||
The union allows for the 'un-declaration' of xml:lang with
|
||||
the empty string.
|
||||
</p>
|
||||
</div>
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:simpleType>
|
||||
<xs:union memberTypes="xs:language">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value=""/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:union>
|
||||
</xs:simpleType>
|
||||
</xs:attribute>
|
||||
|
||||
<xs:attribute name="space">
|
||||
<xs:annotation>
|
||||
<xs:documentation>
|
||||
<div>
|
||||
|
||||
<h3>space (as an attribute name)</h3>
|
||||
<p>
|
||||
denotes an attribute whose
|
||||
value is a keyword indicating what whitespace processing
|
||||
discipline is intended for the content of the element; its
|
||||
value is inherited. This name is reserved by virtue of its
|
||||
definition in the XML specification.</p>
|
||||
|
||||
</div>
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:NCName">
|
||||
<xs:enumeration value="default"/>
|
||||
<xs:enumeration value="preserve"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:attribute>
|
||||
|
||||
<xs:attribute name="base" type="xs:anyURI"> <xs:annotation>
|
||||
<xs:documentation>
|
||||
<div>
|
||||
|
||||
<h3>base (as an attribute name)</h3>
|
||||
<p>
|
||||
denotes an attribute whose value
|
||||
provides a URI to be used as the base for interpreting any
|
||||
relative URIs in the scope of the element on which it
|
||||
appears; its value is inherited. This name is reserved
|
||||
by virtue of its definition in the XML Base specification.</p>
|
||||
|
||||
<p>
|
||||
See <a
|
||||
href="http://www.w3.org/TR/xmlbase/">http://www.w3.org/TR/xmlbase/</a>
|
||||
for information about this attribute.
|
||||
</p>
|
||||
</div>
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
|
||||
<xs:attribute name="id" type="xs:ID">
|
||||
<xs:annotation>
|
||||
<xs:documentation>
|
||||
<div>
|
||||
|
||||
<h3>id (as an attribute name)</h3>
|
||||
<p>
|
||||
denotes an attribute whose value
|
||||
should be interpreted as if declared to be of type ID.
|
||||
This name is reserved by virtue of its definition in the
|
||||
xml:id specification.</p>
|
||||
|
||||
<p>
|
||||
See <a
|
||||
href="http://www.w3.org/TR/xml-id/">http://www.w3.org/TR/xml-id/</a>
|
||||
for information about this attribute.
|
||||
</p>
|
||||
</div>
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
|
||||
<xs:attributeGroup name="specialAttrs">
|
||||
<xs:attribute ref="xml:base"/>
|
||||
<xs:attribute ref="xml:lang"/>
|
||||
<xs:attribute ref="xml:space"/>
|
||||
<xs:attribute ref="xml:id"/>
|
||||
</xs:attributeGroup>
|
||||
|
||||
<xs:annotation>
|
||||
<xs:documentation>
|
||||
<div>
|
||||
|
||||
<h3>Father (in any context at all)</h3>
|
||||
|
||||
<div class="bodytext">
|
||||
<p>
|
||||
denotes Jon Bosak, the chair of
|
||||
the original XML Working Group. This name is reserved by
|
||||
the following decision of the W3C XML Plenary and
|
||||
XML Coordination groups:
|
||||
</p>
|
||||
<blockquote>
|
||||
<p>
|
||||
In appreciation for his vision, leadership and
|
||||
dedication the W3C XML Plenary on this 10th day of
|
||||
February, 2000, reserves for Jon Bosak in perpetuity
|
||||
the XML name "xml:Father".
|
||||
</p>
|
||||
</blockquote>
|
||||
</div>
|
||||
</div>
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
|
||||
<xs:annotation>
|
||||
<xs:documentation>
|
||||
<div xml:id="usage" id="usage">
|
||||
<h2><a name="usage">About this schema document</a></h2>
|
||||
|
||||
<div class="bodytext">
|
||||
<p>
|
||||
This schema defines attributes and an attribute group suitable
|
||||
for use by schemas wishing to allow <code>xml:base</code>,
|
||||
<code>xml:lang</code>, <code>xml:space</code> or
|
||||
<code>xml:id</code> attributes on elements they define.
|
||||
</p>
|
||||
<p>
|
||||
To enable this, such a schema must import this schema for
|
||||
the XML namespace, e.g. as follows:
|
||||
</p>
|
||||
<pre>
|
||||
<schema . . .>
|
||||
. . .
|
||||
<import namespace="http://www.w3.org/XML/1998/namespace"
|
||||
schemaLocation="http://www.w3.org/2001/xml.xsd"/>
|
||||
</pre>
|
||||
<p>
|
||||
or
|
||||
</p>
|
||||
<pre>
|
||||
<import namespace="http://www.w3.org/XML/1998/namespace"
|
||||
schemaLocation="http://www.w3.org/2009/01/xml.xsd"/>
|
||||
</pre>
|
||||
<p>
|
||||
Subsequently, qualified reference to any of the attributes or the
|
||||
group defined below will have the desired effect, e.g.
|
||||
</p>
|
||||
<pre>
|
||||
<type . . .>
|
||||
. . .
|
||||
<attributeGroup ref="xml:specialAttrs"/>
|
||||
</pre>
|
||||
<p>
|
||||
will define a type which will schema-validate an instance element
|
||||
with any of those attributes.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
|
||||
<xs:annotation>
|
||||
<xs:documentation>
|
||||
<div id="nsversioning" xml:id="nsversioning">
|
||||
<h2><a name="nsversioning">Versioning policy for this schema document</a></h2>
|
||||
<div class="bodytext">
|
||||
<p>
|
||||
In keeping with the XML Schema WG's standard versioning
|
||||
policy, this schema document will persist at
|
||||
<a href="http://www.w3.org/2009/01/xml.xsd">
|
||||
http://www.w3.org/2009/01/xml.xsd</a>.
|
||||
</p>
|
||||
<p>
|
||||
At the date of issue it can also be found at
|
||||
<a href="http://www.w3.org/2001/xml.xsd">
|
||||
http://www.w3.org/2001/xml.xsd</a>.
|
||||
</p>
|
||||
<p>
|
||||
The schema document at that URI may however change in the future,
|
||||
in order to remain compatible with the latest version of XML
|
||||
Schema itself, or with the XML namespace itself. In other words,
|
||||
if the XML Schema or XML namespaces change, the version of this
|
||||
document at <a href="http://www.w3.org/2001/xml.xsd">
|
||||
http://www.w3.org/2001/xml.xsd
|
||||
</a>
|
||||
will change accordingly; the version at
|
||||
<a href="http://www.w3.org/2009/01/xml.xsd">
|
||||
http://www.w3.org/2009/01/xml.xsd
|
||||
</a>
|
||||
will not change.
|
||||
</p>
|
||||
<p>
|
||||
Previous dated (and unchanging) versions of this schema
|
||||
document are at:
|
||||
</p>
|
||||
<ul>
|
||||
<li><a href="http://www.w3.org/2009/01/xml.xsd">
|
||||
http://www.w3.org/2009/01/xml.xsd</a></li>
|
||||
<li><a href="http://www.w3.org/2007/08/xml.xsd">
|
||||
http://www.w3.org/2007/08/xml.xsd</a></li>
|
||||
<li><a href="http://www.w3.org/2004/10/xml.xsd">
|
||||
http://www.w3.org/2004/10/xml.xsd</a></li>
|
||||
<li><a href="http://www.w3.org/2001/03/xml.xsd">
|
||||
http://www.w3.org/2001/03/xml.xsd</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
|
||||
</xs:schema>
|
||||
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
using System.Xml.Serialization;
|
||||
using System.Globalization;
|
||||
using System.ComponentModel;
|
||||
using System.ServiceModel;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.ServiceModel.Description;
|
||||
using System.Xml;
|
||||
using System.CodeDom.Compiler;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.System.Runtime.Serialization
|
||||
{
|
||||
[TestFixture]
|
||||
public class Bug695203Test
|
||||
{
|
||||
[Test]
|
||||
public void DoTest ()
|
||||
{
|
||||
using (var mem = new MemoryStream ()) {
|
||||
BaseClass data = new DerivedA1 { Code = "1", CodeA = "A", CodeA1 = "A1" };
|
||||
Serialize (data, mem);
|
||||
mem.Position = 0;
|
||||
var docResult = Deserialize<BaseClass> (mem);
|
||||
}
|
||||
|
||||
using (var mem = new MemoryStream ()) {
|
||||
BaseClass data = new DerivedA2 { Code = "1", CodeA = "A", CodeA2 = "A1" };
|
||||
|
||||
Serialize (data, mem);
|
||||
|
||||
mem.Position = 0;
|
||||
var docResult = Deserialize<BaseClass> (mem);
|
||||
}
|
||||
}
|
||||
|
||||
void Serialize<T> (T instance, Stream destinationStream)
|
||||
{
|
||||
var serializer = new DataContractSerializer (typeof (T), null, int.MaxValue, false, true, null);
|
||||
|
||||
using (var writer = XmlDictionaryWriter.CreateBinaryWriter (destinationStream, null, null, false))
|
||||
serializer.WriteObject (writer, instance);
|
||||
}
|
||||
|
||||
|
||||
public static T Deserialize<T> (Stream sourceStream)
|
||||
{
|
||||
var serializer = new DataContractSerializer (typeof (T), null, int.MaxValue, false, true, null);
|
||||
|
||||
using (var reader = XmlDictionaryReader.CreateBinaryReader(sourceStream, XmlDictionaryReaderQuotas.Max))
|
||||
return (T) serializer.ReadObject (reader);
|
||||
}
|
||||
|
||||
[DataContract]
|
||||
[KnownType (typeof (DerivedA1))]
|
||||
[KnownType (typeof (DerivedA))]
|
||||
public abstract class BaseClass
|
||||
{
|
||||
[DataMember]
|
||||
public string Code { get; set; }
|
||||
}
|
||||
|
||||
|
||||
[DataContract]
|
||||
[KnownType (typeof (DerivedA1))]
|
||||
[KnownType (typeof (DerivedA2))]
|
||||
public abstract class DerivedA : BaseClass
|
||||
{
|
||||
public string CodeA { get; set; }
|
||||
}
|
||||
|
||||
[DataContract]
|
||||
public class DerivedA1 : DerivedA
|
||||
{
|
||||
[DataMember]
|
||||
public string CodeA1 { get; set; }
|
||||
}
|
||||
|
||||
[DataContract]
|
||||
public class DerivedA2 : DerivedA
|
||||
{
|
||||
[DataMember]
|
||||
public string CodeA2 { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+31
@@ -73,6 +73,27 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
Serialize (new Data4 () { X = new Bar () });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GenericTypeNameArgument ()
|
||||
{
|
||||
string expected = "<Foo_KnownTypeAttributeTest.Foo xmlns:i='http://www.w3.org/2001/XMLSchema-instance' xmlns:d1p1='http://schemas.datacontract.org/2004/07/MonoTests.System.Runtime.Serialization' xmlns='urn:foo'><KnownTypeAttributeTest.Foo><d1p1:S>z</d1p1:S></KnownTypeAttributeTest.Foo></Foo_KnownTypeAttributeTest.Foo>".Replace ('\'', '"');
|
||||
var ds = new DataContractSerializer (typeof (MyList<Foo>));
|
||||
var l = new MyList<Foo> ();
|
||||
l.Add (new Foo () { S = "z" });
|
||||
var sw = new StringWriter ();
|
||||
var settings = new XmlWriterSettings () { OmitXmlDeclaration = true };
|
||||
using (var xw = XmlWriter.Create (sw, settings))
|
||||
ds.WriteObject (xw, l);
|
||||
Assert.AreEqual (expected, sw.ToString (), "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (InvalidDataContractException))]
|
||||
public void DataContractOnCollection ()
|
||||
{
|
||||
Serialize (new MyListWrong<Foo> ());
|
||||
}
|
||||
|
||||
public class Foo
|
||||
{
|
||||
public string S { get; set; }
|
||||
@@ -134,6 +155,16 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
yield return typeof (Bar);
|
||||
}
|
||||
}
|
||||
|
||||
[CollectionDataContract (Name = "Foo_{0}", Namespace = "urn:foo")]
|
||||
public class MyList<T> : List<T>
|
||||
{
|
||||
}
|
||||
|
||||
[DataContract (Name = "Foo_{0}", Namespace = "urn:foo")]
|
||||
public class MyListWrong<T> : List<T>
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+11
-2
@@ -315,7 +315,6 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (SerializationException))]
|
||||
[Category ("NotWorking")] // behavior changed in 3.5/SP1
|
||||
public void SerializeSimpleXml ()
|
||||
{
|
||||
DataContractSerializer ser =
|
||||
@@ -980,7 +979,6 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("NotWorking")]
|
||||
public void DeserializeDCWithNullableEnum ()
|
||||
{
|
||||
DCWithNullableEnum dc = Deserialize<DCWithNullableEnum> (
|
||||
@@ -1575,6 +1573,17 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
Assert.AreEqual ("Hello, world!", obj.Content != null ? obj.Content.InnerText : String.Empty, "#2");
|
||||
Assert.AreEqual (2, obj.Nodes != null ? obj.Nodes.Length : -1, "#3");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ArrayAsEnumerableAsRoot ()
|
||||
{
|
||||
var ds = new DataContractSerializer (typeof (IEnumerable<Guid>));
|
||||
var sw = new StringWriter ();
|
||||
using (var xw = XmlWriter.Create (sw, settings))
|
||||
ds.WriteObject (xw, new Guid [] {Guid.Empty});
|
||||
string xml = "<ArrayOfguid xmlns:i='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://schemas.microsoft.com/2003/10/Serialization/Arrays'><guid>00000000-0000-0000-0000-000000000000</guid></ArrayOfguid>".Replace ('\'', '"');
|
||||
Assert.AreEqual (xml, sw.ToString (), "#1");
|
||||
}
|
||||
}
|
||||
|
||||
[DataContract]
|
||||
|
||||
+100
-18
@@ -37,6 +37,7 @@ using System.CodeDom;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.ServiceModel.Description;
|
||||
using System.Xml;
|
||||
@@ -45,6 +46,8 @@ using System.Xml.Serialization;
|
||||
using Microsoft.CSharp;
|
||||
using NUnit.Framework;
|
||||
|
||||
using QName = System.Xml.XmlQualifiedName;
|
||||
|
||||
namespace MonoTests.System.Runtime.Serialization
|
||||
{
|
||||
[TestFixture]
|
||||
@@ -68,6 +71,7 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
if (section.Metadata is XmlSchema)
|
||||
xss.Add (section.Metadata as XmlSchema);
|
||||
|
||||
Assert.AreEqual (3, xss.Schemas ().Count, "#1");
|
||||
return xss;
|
||||
}
|
||||
|
||||
@@ -92,7 +96,6 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (InvalidOperationException))]
|
||||
[Category ("NotWorking")]
|
||||
public void GetCodeTypeReferenceTest ()
|
||||
{
|
||||
XsdDataContractImporter xsdi = GetImporter ();
|
||||
@@ -100,7 +103,6 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("NotWorking")]
|
||||
public void GetCodeTypeReferenceTest2 ()
|
||||
{
|
||||
NewXmlSchemaSet ();
|
||||
@@ -119,7 +121,6 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("NotWorking")]
|
||||
public void CanImportTest ()
|
||||
{
|
||||
NewXmlSchemaSet ();
|
||||
@@ -145,7 +146,6 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("NotWorking")]
|
||||
public void CanImportTest2 ()
|
||||
{
|
||||
NewXmlSchemaSet ();
|
||||
@@ -165,7 +165,6 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentNullException))]
|
||||
[Category ("NotWorking")]
|
||||
public void CanImportNullTest1 ()
|
||||
{
|
||||
XsdDataContractImporter xsdi = GetImporter ();
|
||||
@@ -173,7 +172,6 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("NotWorking")]
|
||||
[ExpectedException (typeof (ArgumentNullException))]
|
||||
public void CanImportNullTest2 ()
|
||||
{
|
||||
@@ -182,7 +180,6 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("NotWorking")]
|
||||
[ExpectedException (typeof (ArgumentNullException))]
|
||||
public void CanImportNullTest3 ()
|
||||
{
|
||||
@@ -239,12 +236,13 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("NotWorking")]
|
||||
[Category ("NotWorking")] // importing almost-invalid element. This test is almost missing the point.
|
||||
public void ImportTest ()
|
||||
{
|
||||
XsdDataContractImporter xsdi = GetImporter ();
|
||||
XmlSchemaElement element = new XmlSchemaElement();
|
||||
//Assert.IsTrue (xsdi.CanImport (xss, element));
|
||||
Assert.IsTrue (xsdi.CanImport (xss, new QName ("dc", "http://schemas.datacontract.org/2004/07/")), "#i01");
|
||||
Assert.IsTrue (xsdi.CanImport (xss, element), "#i01-2");
|
||||
Assert.AreEqual (new XmlQualifiedName ("anyType", XmlSchema.Namespace), xsdi.Import (xss, element), "#i02");
|
||||
|
||||
CodeCompileUnit ccu = xsdi.CodeCompileUnit;
|
||||
@@ -259,7 +257,6 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("NotWorking")]
|
||||
public void ImportDataContract1 ()
|
||||
{
|
||||
NewXmlSchemaSet ();
|
||||
@@ -287,7 +284,6 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("NotWorking")]
|
||||
public void ImportDataContract2 ()
|
||||
{
|
||||
NewXmlSchemaSet ();
|
||||
@@ -316,7 +312,6 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (InvalidDataContractException))]
|
||||
[Category ("NotWorking")]
|
||||
public void ImportMessageEcho ()
|
||||
{
|
||||
XsdDataContractImporter xsdi = GetImporter ();
|
||||
@@ -324,7 +319,6 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("NotWorking")]
|
||||
public void ImportAll ()
|
||||
{
|
||||
NewXmlSchemaSet ();
|
||||
@@ -410,9 +404,16 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
}
|
||||
|
||||
CodeCompileUnit DoImport (params string [] schemaFiles)
|
||||
{
|
||||
return DoImport (false, schemaFiles);
|
||||
}
|
||||
|
||||
CodeCompileUnit DoImport (bool xmlType, params string [] schemaFiles)
|
||||
{
|
||||
var ccu = new CodeCompileUnit ();
|
||||
var xdi = new XsdDataContractImporter (ccu);
|
||||
if (xmlType)
|
||||
xdi.Options = new ImportOptions () { ImportXmlType = true };
|
||||
var xss = new XmlSchemaSet ();
|
||||
foreach (var schemaFile in schemaFiles)
|
||||
xss.Add (null, schemaFile);
|
||||
@@ -421,6 +422,23 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
return ccu;
|
||||
}
|
||||
|
||||
void DoCanImport (bool result, params string [] schemaFiles)
|
||||
{
|
||||
var ccu = new CodeCompileUnit ();
|
||||
var xdi = new XsdDataContractImporter (ccu);
|
||||
var xss = new XmlSchemaSet ();
|
||||
foreach (var schemaFile in schemaFiles)
|
||||
xss.Add (null, schemaFile);
|
||||
Assert.AreEqual (result, xdi.CanImport (xss));
|
||||
}
|
||||
|
||||
string GenerateCode (CodeCompileUnit ccu)
|
||||
{
|
||||
var sw = new StringWriter ();
|
||||
new CSharpCodeProvider ().GenerateCodeFromCompileUnit (ccu, sw, null);
|
||||
return sw.ToString ();
|
||||
}
|
||||
|
||||
// FIXME: this set of tests need further assertion in each test case. Right now it just checks if things import or fail just fine.
|
||||
|
||||
[Test]
|
||||
@@ -429,18 +447,37 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
DoImport ("Test/Resources/Schemas/ns0.xsd");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ImportTestX0_2 ()
|
||||
{
|
||||
var ccu = DoImport (true, "Test/Resources/Schemas/ns0.xsd");
|
||||
Assert.IsTrue (GenerateCode (ccu).IndexOf ("class") < 0, "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ImportTestX1 ()
|
||||
{
|
||||
DoImport ("Test/Resources/Schemas/ns1.xsd");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ImportTestX1_2 ()
|
||||
{
|
||||
Assert.AreEqual (GenerateCode (DoImport ("Test/Resources/Schemas/ns1.xsd")), GenerateCode (DoImport (true, "Test/Resources/Schemas/ns1.xsd")), "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ImportTestX2 ()
|
||||
{
|
||||
DoImport ("Test/Resources/Schemas/ns2.xsd");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ImportTestX2_2 ()
|
||||
{
|
||||
Assert.AreEqual (GenerateCode (DoImport ("Test/Resources/Schemas/ns2.xsd")), GenerateCode (DoImport (true, "Test/Resources/Schemas/ns2.xsd")), "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (InvalidDataContractException))]
|
||||
public void ImportTestX3 ()
|
||||
@@ -448,6 +485,19 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
DoImport ("Test/Resources/Schemas/ns3.xsd");
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("NotWorking")]
|
||||
public void ImportTestX3_2 ()
|
||||
{
|
||||
var ccu = DoImport (true, "Test/Resources/Schemas/ns3.xsd");
|
||||
var code = GenerateCode (ccu);
|
||||
Assert.IsTrue (code.IndexOf ("class T2") > 0, "#1");
|
||||
Assert.IsTrue (code.IndexOf ("IXmlSerializable") > 0, "#2");
|
||||
Assert.IsTrue (code.IndexOf ("WriteXml") > 0, "#3");
|
||||
Assert.IsTrue (code.IndexOf ("XmlRootAttribute(ElementName=\"E2\", Namespace=\"urn:bar\"") > 0, "#4");
|
||||
Assert.IsTrue (code.IndexOf ("XmlSchemaProviderAttribute(\"ExportSchema\")") > 0, "#5");
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (InvalidDataContractException))]
|
||||
public void ImportTestX4 ()
|
||||
@@ -632,6 +682,30 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
DoImport ("Test/Resources/Schemas/ns31.xsd");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ImportTestX32 ()
|
||||
{
|
||||
DoImport ("Test/Resources/Schemas/ns32.xsd");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ImportTestX33 ()
|
||||
{
|
||||
DoImport ("Test/Resources/Schemas/ns33.xsd");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ImportTestX34 ()
|
||||
{
|
||||
DoImport (true, "Test/Resources/Schemas/ns34.xsd", "Test/Resources/Schemas/ns34_2.xsd");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanImportTestX34 ()
|
||||
{
|
||||
DoCanImport (false, "Test/Resources/Schemas/ns34.xsd", "Test/Resources/Schemas/ns34_2.xsd");
|
||||
}
|
||||
|
||||
/* Helper methods */
|
||||
private void CheckDC (CodeTypeDeclaration type, string name, Dictionary<string, string> members, string msg)
|
||||
{
|
||||
@@ -677,16 +751,19 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
|
||||
private void CheckDataContractAttribute (CodeTypeDeclaration type, string msg)
|
||||
{
|
||||
Assert.AreEqual (3, type.CustomAttributes.Count, msg + "a");
|
||||
// DebuggerStepThrouAttribute is insignificant. So, no reason to check the attribute count.
|
||||
// Assert.AreEqual (3, type.CustomAttributes.Count, msg + "a");
|
||||
|
||||
// DebuggerStepThroughAttribute - skip it
|
||||
|
||||
//GeneratedCodeAttribute
|
||||
CodeAttributeDeclaration ca = type.CustomAttributes [1];
|
||||
Assert.AreEqual ("System.CodeDom.Compiler.GeneratedCodeAttribute", ca.Name, msg + "b");
|
||||
var l = new List<CodeAttributeDeclaration> ();
|
||||
foreach (CodeAttributeDeclaration a in type.CustomAttributes)
|
||||
l.Add (a);
|
||||
Assert.IsTrue (l.Any (a => a.Name == "System.CodeDom.Compiler.GeneratedCodeAttribute"), msg + "b");
|
||||
|
||||
ca = type.CustomAttributes [2];
|
||||
Assert.AreEqual ("System.Runtime.Serialization.DataContractAttribute", ca.Name, msg + "c");
|
||||
var ca = l.FirstOrDefault (a => a.Name == "System.Runtime.Serialization.DataContractAttribute");
|
||||
Assert.IsNotNull (ca, msg + "b");
|
||||
Assert.AreEqual (2, ca.Arguments.Count, msg + "d");
|
||||
}
|
||||
|
||||
@@ -698,6 +775,11 @@ namespace MonoTests.System.Runtime.Serialization
|
||||
return null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ImportXsdBuiltInTypes ()
|
||||
{
|
||||
DoImport ("Test/Resources/Schemas/xml.xsd");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,7 +24,9 @@ EXTRA_DISTFILES = \
|
||||
Test/System.Security.Cryptography.Xml/sample.pfx \
|
||||
Test/System.Security.Cryptography.Xml/EncryptedXmlSample1.xml \
|
||||
Test/System.Security.Cryptography.Xml/EncryptedXmlSample2.xml \
|
||||
Test/System.Security.Cryptography.Xml/EncryptedXmlSample3.xml
|
||||
Test/System.Security.Cryptography.Xml/EncryptedXmlSample3.xml \
|
||||
Test/System.Security.Cryptography.Pkcs/detached.data \
|
||||
Test/System.Security.Cryptography.Pkcs/detached.p7
|
||||
|
||||
include ../../build/library.make
|
||||
|
||||
|
||||
@@ -249,7 +249,13 @@ namespace System.Security.Cryptography.Pkcs {
|
||||
|
||||
ASN1 content = sd.ContentInfo.Content;
|
||||
Oid oid = new Oid (sd.ContentInfo.ContentType);
|
||||
_content = new ContentInfo (oid, content[0].Value);
|
||||
|
||||
if (!_detached || _content == null) {
|
||||
if (content[0] == null)
|
||||
throw new ArgumentException ("ContentInfo has no content. Detached signature ?");
|
||||
|
||||
_content = new ContentInfo (oid, content[0].Value);
|
||||
}
|
||||
|
||||
foreach (Mono.Security.X509.X509Certificate x in sd.Certificates) {
|
||||
_certs.Add (new X509Certificate2 (x.RawData));
|
||||
|
||||
@@ -437,6 +437,20 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
|
||||
sp.CheckSignature (true);
|
||||
CheckSignatureProperties (sp, 1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CheckSignatureDetachedSignedCms ()
|
||||
{
|
||||
string path = Path.Combine ("Test", "System.Security.Cryptography.Pkcs");
|
||||
var signedBytes = File.ReadAllBytes (Path.Combine (path, "detached.data"));
|
||||
var bytes = File.ReadAllBytes (Path.Combine (path, "detached.p7"));
|
||||
|
||||
var oid = new Oid ("1.2.840.113549.1.7.2");
|
||||
var contentInfo = new ContentInfo (oid, signedBytes);
|
||||
var signedCms = new SignedCms (contentInfo, true);
|
||||
signedCms.Decode (bytes);
|
||||
signedCms.CheckSignature (true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+5
@@ -120,6 +120,8 @@ namespace System.ServiceModel.Discovery.Udp
|
||||
|
||||
void SendCore (UdpClient cli, Message message, TimeSpan timeout)
|
||||
{
|
||||
Logger.LogMessage (MessageLogSourceKind.TransportSend, ref message, int.MaxValue);
|
||||
|
||||
var ms = new MemoryStream ();
|
||||
message_encoder.WriteMessage (message, ms);
|
||||
// It seems .NET sends the same Message a couple of times so that the receivers don't miss it. So, do the same hack.
|
||||
@@ -195,6 +197,9 @@ namespace System.ServiceModel.Discovery.Udp
|
||||
msg.Properties.Add ("Via", LocalAddress.Uri);
|
||||
msg.Properties.Add ("Encoder", message_encoder);
|
||||
msg.Properties.Add (RemoteEndpointMessageProperty.Name, new RemoteEndpointMessageProperty (ip.Address.ToString (), ip.Port));
|
||||
|
||||
Logger.LogMessage (MessageLogSourceKind.TransportReceive, ref msg, binding_element.MaxReceivedMessageSize);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -80,7 +80,8 @@ namespace System.ServiceModel.Discovery.Version11
|
||||
Channel.EndFind (result);
|
||||
}, null);
|
||||
|
||||
if (!reply_find_handle.WaitOne (InnerChannel.OperationTimeout))
|
||||
var timeout = InnerChannel.OperationTimeout < criteria.Duration ? InnerChannel.OperationTimeout : criteria.Duration;
|
||||
if (!reply_find_handle.WaitOne (timeout))
|
||||
throw new EndpointNotFoundException ("The discovery client could not receive Find operation response within the operation timeout.");
|
||||
try {
|
||||
var ir = find_completed ();
|
||||
@@ -118,7 +119,8 @@ namespace System.ServiceModel.Discovery.Version11
|
||||
Channel.EndResolve (result);
|
||||
}, null);
|
||||
|
||||
if (!reply_resolve_handle.WaitOne (InnerChannel.OperationTimeout))
|
||||
var timeout = InnerChannel.OperationTimeout < criteria.Duration ? InnerChannel.OperationTimeout : criteria.Duration;
|
||||
if (!reply_find_handle.WaitOne (timeout))
|
||||
throw new TimeoutException ();
|
||||
try {
|
||||
var ir = resolve_completed ();
|
||||
|
||||
+4
-2
@@ -80,7 +80,8 @@ namespace System.ServiceModel.Discovery.VersionApril2005
|
||||
Channel.EndFind (result);
|
||||
}, null);
|
||||
|
||||
if (!reply_find_handle.WaitOne (InnerChannel.OperationTimeout))
|
||||
var timeout = InnerChannel.OperationTimeout < criteria.Duration ? InnerChannel.OperationTimeout : criteria.Duration;
|
||||
if (!reply_find_handle.WaitOne (timeout))
|
||||
throw new EndpointNotFoundException ("The discovery client could not receive Find operation response within the operation timeout.");
|
||||
try {
|
||||
var ir = find_completed ();
|
||||
@@ -118,7 +119,8 @@ namespace System.ServiceModel.Discovery.VersionApril2005
|
||||
Channel.EndResolve (result);
|
||||
}, null);
|
||||
|
||||
if (!reply_resolve_handle.WaitOne (InnerChannel.OperationTimeout))
|
||||
var timeout = InnerChannel.OperationTimeout < criteria.Duration ? InnerChannel.OperationTimeout : criteria.Duration;
|
||||
if (!reply_find_handle.WaitOne (timeout))
|
||||
throw new TimeoutException ();
|
||||
try {
|
||||
var ir = resolve_completed ();
|
||||
|
||||
+4
-2
@@ -80,7 +80,8 @@ namespace System.ServiceModel.Discovery.VersionCD1
|
||||
Channel.EndFind (result);
|
||||
}, null);
|
||||
|
||||
if (!reply_find_handle.WaitOne (InnerChannel.OperationTimeout))
|
||||
var timeout = InnerChannel.OperationTimeout < criteria.Duration ? InnerChannel.OperationTimeout : criteria.Duration;
|
||||
if (!reply_find_handle.WaitOne (timeout))
|
||||
throw new EndpointNotFoundException ("The discovery client could not receive Find operation response within the operation timeout.");
|
||||
try {
|
||||
var ir = find_completed ();
|
||||
@@ -118,7 +119,8 @@ namespace System.ServiceModel.Discovery.VersionCD1
|
||||
Channel.EndResolve (result);
|
||||
}, null);
|
||||
|
||||
if (!reply_resolve_handle.WaitOne (InnerChannel.OperationTimeout))
|
||||
var timeout = InnerChannel.OperationTimeout < criteria.Duration ? InnerChannel.OperationTimeout : criteria.Duration;
|
||||
if (!reply_find_handle.WaitOne (timeout))
|
||||
throw new TimeoutException ();
|
||||
try {
|
||||
var ir = resolve_completed ();
|
||||
|
||||
+29
-4
@@ -145,32 +145,57 @@ namespace MonoTests.System.ServiceModel.Discovery
|
||||
Assert.AreEqual (DiscoveryClientBindingElement.DiscoveryEndpointAddress, ch.RemoteAddress, "#1");
|
||||
}
|
||||
|
||||
// This test takes a while, so I in fact don't want to enable it ...
|
||||
class MyDiscoveryEndpointProvider2 : DiscoveryEndpointProvider
|
||||
{
|
||||
public MyDiscoveryEndpointProvider2 (DiscoveryEndpoint endpoint)
|
||||
{
|
||||
this.endpoint = endpoint;
|
||||
}
|
||||
|
||||
DiscoveryEndpoint endpoint;
|
||||
|
||||
public override DiscoveryEndpoint GetDiscoveryEndpoint ()
|
||||
{
|
||||
return endpoint;
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (EndpointNotFoundException))]
|
||||
public void RequestChannelOpenFails ()
|
||||
{
|
||||
var be = new DiscoveryClientBindingElement ();
|
||||
// Note that this explicitly sets shorter timeout than open timeout for the channel.
|
||||
// If it is longer, then TimeoutException will occur instgead,
|
||||
// as the client doesn't expect longer than FindCriteria.Duration.
|
||||
be.FindCriteria.Duration = TimeSpan.FromSeconds (3);
|
||||
|
||||
var bc = new BindingContext (new CustomBinding (be, new HttpTransportBindingElement ()), new BindingParameterCollection ());
|
||||
var cf = be.BuildChannelFactory<IRequestChannel> (bc);
|
||||
cf.Open ();
|
||||
Assert.IsNull (cf.GetProperty<DiscoveryEndpoint> (), "#1");
|
||||
var ch = cf.CreateChannel (DiscoveryClientBindingElement.DiscoveryEndpointAddress);
|
||||
Assert.IsNull (ch.GetProperty<DiscoveryEndpoint> (), "#2");
|
||||
ch.Open (TimeSpan.FromSeconds (80));
|
||||
DateTime start = DateTime.Now;
|
||||
ch.Open (TimeSpan.FromSeconds (5));
|
||||
Assert.IsTrue (DateTime.Now - start < TimeSpan.FromSeconds (15), "It is likely that FindCriteria.Duration is ignored");
|
||||
}
|
||||
|
||||
// This test takes a while, so I in fact don't want to enable it ...
|
||||
[Test]
|
||||
[ExpectedException (typeof (EndpointNotFoundException))]
|
||||
public void RequestChannelOpenFails2 ()
|
||||
{
|
||||
var be = new DiscoveryClientBindingElement ();
|
||||
// (The comment on RequestChannelOpenFails() applies here too.)
|
||||
be.FindCriteria.Duration = TimeSpan.FromSeconds (3);
|
||||
|
||||
var bc = new BindingContext (new CustomBinding (be, new TcpTransportBindingElement ()), new BindingParameterCollection ());
|
||||
var cf = be.BuildChannelFactory<IDuplexSessionChannel> (bc);
|
||||
cf.Open ();
|
||||
var ch = cf.CreateChannel (DiscoveryClientBindingElement.DiscoveryEndpointAddress);
|
||||
ch.Open (TimeSpan.FromSeconds (80));
|
||||
DateTime start = DateTime.Now;
|
||||
ch.Open (TimeSpan.FromSeconds (5));
|
||||
Assert.IsTrue (DateTime.Now - start < TimeSpan.FromSeconds (15), "It is likely that FindCriteria.Duration is ignored");
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
//
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net.Mime;
|
||||
using System.Runtime.Serialization.Json;
|
||||
using System.ServiceModel;
|
||||
using System.ServiceModel.Dispatcher;
|
||||
@@ -84,7 +83,7 @@ namespace System.ServiceModel.Channels
|
||||
contentType = contentType ?? "application/octet-stream";
|
||||
|
||||
Encoding enc = Encoding.UTF8;
|
||||
ContentType ct = new ContentType (contentType);
|
||||
var ct = new System.Net.Mime.ContentType (contentType);
|
||||
if (ct.CharSet != null)
|
||||
enc = Encoding.GetEncoding (ct.CharSet);
|
||||
|
||||
@@ -131,6 +130,7 @@ namespace System.ServiceModel.Channels
|
||||
}
|
||||
if (wp != null)
|
||||
msg.Properties.Add (WebBodyFormatMessageProperty.Name, wp);
|
||||
msg.Properties.Encoder = this;
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
+102
-25
@@ -3,8 +3,10 @@
|
||||
//
|
||||
// Author:
|
||||
// Atsushi Enomoto <[email protected]>
|
||||
// Atsushi Enomoto <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2008,2009 Novell, Inc (http://www.novell.com)
|
||||
// Copyright (C) 2011 Xamarin, Inc (http://xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
@@ -45,6 +47,24 @@ using XmlObjectSerializer = System.Object;
|
||||
|
||||
namespace System.ServiceModel.Dispatcher
|
||||
{
|
||||
// This set of classes is to work as message formatters for
|
||||
// WebHttpBehavior. There are couple of aspects to differentiate
|
||||
// implementations:
|
||||
// - request/reply and client/server
|
||||
// by WebMessageFormatter hierarchy
|
||||
// - WebClientMessageFormatter - for client
|
||||
// - RequestClientFormatter - for request
|
||||
// - ReplyClientFormatter - for response
|
||||
// - WebDispatchMessageFormatter - for server
|
||||
// - RequestDispatchFormatter - for request
|
||||
// - ReplyDispatchFormatter - for response
|
||||
//
|
||||
// FIXME: below items need more work
|
||||
// - HTTP method differences
|
||||
// - GET (WebGet)
|
||||
// - POST (other way)
|
||||
// - output format: Stream, JSON, XML ...
|
||||
|
||||
internal abstract class WebMessageFormatter
|
||||
{
|
||||
OperationDescription operation;
|
||||
@@ -182,6 +202,9 @@ namespace System.ServiceModel.Dispatcher
|
||||
|
||||
protected XmlObjectSerializer GetSerializer (WebContentFormat msgfmt, bool isWrapped, MessagePartDescription part)
|
||||
{
|
||||
if (part.Type == typeof (void))
|
||||
return null; // no serialization should be done.
|
||||
|
||||
switch (msgfmt) {
|
||||
case WebContentFormat.Xml:
|
||||
if (xml_serializer == null)
|
||||
@@ -208,6 +231,9 @@ namespace System.ServiceModel.Dispatcher
|
||||
// FIXME: handle ref/out parameters
|
||||
|
||||
var reader = message.GetReaderAtBodyContents ();
|
||||
reader.MoveToContent ();
|
||||
|
||||
bool wasEmptyElement = reader.IsEmptyElement;
|
||||
|
||||
if (isWrapped) {
|
||||
if (fmt == WebContentFormat.Json)
|
||||
@@ -216,9 +242,9 @@ namespace System.ServiceModel.Dispatcher
|
||||
reader.ReadStartElement (md.Body.WrapperName, md.Body.WrapperNamespace);
|
||||
}
|
||||
|
||||
var ret = ReadObjectBody (serializer, reader);
|
||||
var ret = (serializer == null) ? null : ReadObjectBody (serializer, reader);
|
||||
|
||||
if (isWrapped)
|
||||
if (isWrapped && !wasEmptyElement)
|
||||
reader.ReadEndElement ();
|
||||
|
||||
return ret;
|
||||
@@ -291,6 +317,8 @@ namespace System.ServiceModel.Dispatcher
|
||||
|
||||
internal abstract class WebClientMessageFormatter : WebMessageFormatter, IClientMessageFormatter
|
||||
{
|
||||
IClientMessageFormatter default_formatter;
|
||||
|
||||
protected WebClientMessageFormatter (OperationDescription operation, ServiceEndpoint endpoint, QueryStringConverter converter, WebHttpBehavior behavior)
|
||||
: base (operation, endpoint, converter, behavior)
|
||||
{
|
||||
@@ -306,11 +334,11 @@ namespace System.ServiceModel.Dispatcher
|
||||
|
||||
MessageDescription md = GetMessageDescription (MessageDirection.Input);
|
||||
|
||||
if (parameters.Length != md.Body.Parts.Count)
|
||||
throw new ArgumentException ("Parameter array length does not match the number of message body parts");
|
||||
|
||||
Message ret;
|
||||
Uri to;
|
||||
object msgpart = null;
|
||||
|
||||
|
||||
for (int i = 0; i < parameters.Length; i++) {
|
||||
var p = md.Body.Parts [i];
|
||||
string name = p.Name.ToUpper (CultureInfo.InvariantCulture);
|
||||
@@ -325,10 +353,9 @@ namespace System.ServiceModel.Dispatcher
|
||||
throw new NotImplementedException (String.Format ("More than one parameters including {0} that are not contained in the URI template {1} was found.", p.Name, UriTemplate));
|
||||
}
|
||||
}
|
||||
ret = Message.CreateMessage (messageVersion, (string) null, msgpart);
|
||||
|
||||
Uri to = UriTemplate.BindByName (Endpoint.Address.Uri, c);
|
||||
|
||||
Message ret = Message.CreateMessage (messageVersion, (string) null, msgpart);
|
||||
to = UriTemplate.BindByName (Endpoint.Address.Uri, c);
|
||||
ret.Headers.To = to;
|
||||
|
||||
var hp = new HttpRequestMessageProperty ();
|
||||
@@ -544,18 +571,10 @@ namespace System.ServiceModel.Dispatcher
|
||||
|
||||
var wp = message.Properties [WebBodyFormatMessageProperty.Name] as WebBodyFormatMessageProperty;
|
||||
var fmt = wp != null ? wp.Format : WebContentFormat.Xml;
|
||||
if (fmt == WebContentFormat.Raw) {
|
||||
var rmsg = (RawMessage) message;
|
||||
parameters [0] = rmsg.Stream;
|
||||
return;
|
||||
}
|
||||
|
||||
Uri to = message.Headers.To;
|
||||
UriTemplateMatch match = UriTemplate.Match (Endpoint.Address.Uri, to);
|
||||
if (match == null)
|
||||
// not sure if it could happen
|
||||
throw new SystemException (String.Format ("INTERNAL ERROR: UriTemplate does not match with the request: {0} / {1}", UriTemplate, to));
|
||||
if (iwc != null)
|
||||
UriTemplateMatch match = to == null ? null : UriTemplate.Match (Endpoint.Address.Uri, to);
|
||||
if (match != null && iwc != null)
|
||||
iwc.UriTemplateMatch = match;
|
||||
|
||||
MessageDescription md = GetMessageDescription (MessageDirection.Input);
|
||||
@@ -563,12 +582,20 @@ namespace System.ServiceModel.Dispatcher
|
||||
for (int i = 0; i < parameters.Length; i++) {
|
||||
var p = md.Body.Parts [i];
|
||||
string name = p.Name.ToUpperInvariant ();
|
||||
var str = match.BoundVariables [name];
|
||||
if (str != null)
|
||||
parameters [i] = Converter.ConvertStringToValue (str, p.Type);
|
||||
else {
|
||||
var serializer = GetSerializer (fmt, IsRequestBodyWrapped, p);
|
||||
parameters [i] = DeserializeObject (serializer, message, md, IsRequestBodyWrapped, fmt);
|
||||
if (fmt == WebContentFormat.Raw && p.Type == typeof (Stream)) {
|
||||
var rmsg = (RawMessage) message;
|
||||
parameters [i] = rmsg.Stream;
|
||||
} else {
|
||||
var str = match.BoundVariables [name];
|
||||
if (str != null)
|
||||
parameters [i] = Converter.ConvertStringToValue (str, p.Type);
|
||||
else {
|
||||
if (info.Method != "GET") {
|
||||
var serializer = GetSerializer (fmt, IsRequestBodyWrapped, p);
|
||||
parameters [i] = DeserializeObject (serializer, message, md, IsRequestBodyWrapped, fmt);
|
||||
}
|
||||
// for GET Uri template parameters, there is no <anyType xsi:nil='true' />. So just skip the member.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -604,7 +631,57 @@ namespace System.ServiceModel.Dispatcher
|
||||
|
||||
protected override void OnWriteBodyContents (XmlDictionaryWriter writer)
|
||||
{
|
||||
throw new NotSupportedException ();
|
||||
writer.WriteString ("-- message body is raw binary --");
|
||||
}
|
||||
|
||||
protected override MessageBuffer OnCreateBufferedCopy (int maxBufferSize)
|
||||
{
|
||||
var ms = Stream as MemoryStream;
|
||||
if (ms == null) {
|
||||
ms = new MemoryStream ();
|
||||
#if NET_4_0 || NET_2_1
|
||||
Stream.CopyTo (ms);
|
||||
#else
|
||||
byte [] tmp = new byte [0x1000];
|
||||
int size;
|
||||
do {
|
||||
size = Stream.Read (tmp, 0, tmp.Length);
|
||||
ms.Write (tmp, 0, size);
|
||||
} while (size > 0);
|
||||
#endif
|
||||
this.Stream = ms;
|
||||
}
|
||||
return new RawMessageBuffer (ms.ToArray (), headers, properties);
|
||||
}
|
||||
}
|
||||
|
||||
internal class RawMessageBuffer : MessageBuffer
|
||||
{
|
||||
byte [] buffer;
|
||||
MessageHeaders headers;
|
||||
MessageProperties properties;
|
||||
|
||||
public RawMessageBuffer (byte [] buffer, MessageHeaders headers, MessageProperties properties)
|
||||
{
|
||||
this.buffer = buffer;
|
||||
this.headers = new MessageHeaders (headers);
|
||||
this.properties = new MessageProperties (properties);
|
||||
}
|
||||
|
||||
public override int BufferSize {
|
||||
get { return buffer.Length; }
|
||||
}
|
||||
|
||||
public override void Close ()
|
||||
{
|
||||
}
|
||||
|
||||
public override Message CreateMessage ()
|
||||
{
|
||||
var msg = new RawMessage (new MemoryStream (buffer));
|
||||
msg.Headers.CopyHeadersFrom (headers);
|
||||
msg.Properties.CopyProperties (properties);
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,9 +27,14 @@
|
||||
//
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
#if !NET_2_1
|
||||
using System.Configuration;
|
||||
using System.ServiceModel.Configuration;
|
||||
#endif
|
||||
|
||||
namespace System.ServiceModel
|
||||
{
|
||||
@@ -41,11 +46,34 @@ namespace System.ServiceModel
|
||||
#endif
|
||||
{
|
||||
public WebHttpBinding ()
|
||||
: this (WebHttpSecurityMode.None)
|
||||
: this (String.Empty)
|
||||
{
|
||||
}
|
||||
|
||||
public WebHttpBinding (WebHttpSecurityMode mode)
|
||||
{
|
||||
Initialize (mode);
|
||||
}
|
||||
|
||||
public WebHttpBinding (string configurationName)
|
||||
{
|
||||
#if !NET_2_1
|
||||
BindingsSection bindingsSection = ConfigUtil.BindingsSection;
|
||||
WebHttpBindingElement el = (WebHttpBindingElement) bindingsSection ["webHttpBinding"].ConfiguredBindings.FirstOrDefault (c => c.Name == configurationName);
|
||||
if (el != null) {
|
||||
Initialize (el.Security.Mode); // to initialize Transport correctly.
|
||||
el.ApplyConfiguration (this);
|
||||
}
|
||||
else if (!String.IsNullOrEmpty (configurationName))
|
||||
throw new ConfigurationException (String.Format ("Specified webHttpBinding configuration '{0}' was not found", configurationName));
|
||||
else
|
||||
Initialize (WebHttpSecurityMode.None);
|
||||
#else
|
||||
Initialize (WebHttpSecurityMode.None);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Initialize (WebHttpSecurityMode mode)
|
||||
{
|
||||
security.Mode = mode;
|
||||
// MSDN says that this security mode can be set only
|
||||
@@ -55,12 +83,6 @@ namespace System.ServiceModel
|
||||
t.ManualAddressing = true;
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
public WebHttpBinding (string configurationName)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
WebHttpSecurity security = new WebHttpSecurity ();
|
||||
HttpTransportBindingElement t;
|
||||
// This can be changed only using <synchronousReceive> configuration element.
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace System
|
||||
|
||||
string template;
|
||||
ReadOnlyCollection<string> path, query;
|
||||
string wild_path_name;
|
||||
Dictionary<string,string> query_params = new Dictionary<string,string> ();
|
||||
|
||||
public UriTemplate (string template)
|
||||
@@ -162,6 +163,15 @@ namespace System
|
||||
|
||||
void BindByName (ref int src, StringBuilder sb, ReadOnlyCollection<string> names, NameValueCollection nvc, IDictionary<string,string> dic, bool omitDefaults, bool query)
|
||||
{
|
||||
if (query) {
|
||||
int idx = template.IndexOf ('?', src);
|
||||
if (idx > 0) {
|
||||
sb.Append (template.Substring (src, idx - src));
|
||||
src = idx;
|
||||
// note that it doesn't append '?'. It is added only when there is actual parameter binding.
|
||||
}
|
||||
}
|
||||
|
||||
foreach (string name in names) {
|
||||
int s = template.IndexOf ('{', src);
|
||||
int e = template.IndexOf ('}', s + 1);
|
||||
@@ -172,18 +182,19 @@ namespace System
|
||||
#endif
|
||||
if (dic != null)
|
||||
dic.TryGetValue (name, out value);
|
||||
|
||||
if (query) {
|
||||
if (value != null || (!omitDefaults && Defaults.TryGetValue (name, out value))) {
|
||||
sb.Append (template.Substring (src, s - src));
|
||||
sb.Append (value);
|
||||
}
|
||||
} else
|
||||
if (value == null && (omitDefaults || !Defaults.TryGetValue(name, out value)))
|
||||
throw new ArgumentException(string.Format("The argument name value collection does not contain non-nul vaalue for '{0}'", name), "parameters");
|
||||
else {
|
||||
sb.Append (template.Substring (src, s - src));
|
||||
sb.Append (value);
|
||||
}
|
||||
} else {
|
||||
if (value == null && (omitDefaults || !Defaults.TryGetValue (name, out value)))
|
||||
throw new ArgumentException (string.Format("The argument name value collection does not contain non-null value for '{0}'", name), "parameters");
|
||||
|
||||
sb.Append (template.Substring (src, s - src));
|
||||
sb.Append (value);
|
||||
}
|
||||
src = e + 1;
|
||||
}
|
||||
}
|
||||
@@ -245,9 +256,6 @@ namespace System
|
||||
candidate = new Uri(candidate.GetComponents (UriComponents.SchemeAndServer | UriComponents.Path, UriFormat.Unescaped) + '/' + candidate.Query, candidate.IsAbsoluteUri ? UriKind.Absolute : UriKind.RelativeOrAbsolute);
|
||||
}
|
||||
|
||||
if (Uri.Compare (baseAddress, candidate, UriComponents.StrongAuthority, UriFormat.SafeUnescaped, StringComparison.Ordinal) != 0)
|
||||
return null;
|
||||
|
||||
int i = 0, c = 0;
|
||||
UriTemplateMatch m = new UriTemplateMatch ();
|
||||
m.BaseUri = baseAddress;
|
||||
@@ -255,7 +263,7 @@ namespace System
|
||||
m.RequestUri = candidate;
|
||||
var vc = m.BoundVariables;
|
||||
|
||||
string cp = Uri.UnescapeDataString (baseAddress.MakeRelativeUri (candidate).ToString ());
|
||||
string cp = Uri.UnescapeDataString (baseAddress.MakeRelativeUri (new Uri (baseAddress, candidate.GetComponents (UriComponents.PathAndQuery, UriFormat.Unescaped))).ToString ());
|
||||
if (IgnoreTrailingSlash && cp [cp.Length - 1] == '/')
|
||||
cp = cp.Substring (0, cp.Length - 1);
|
||||
|
||||
@@ -269,6 +277,10 @@ namespace System
|
||||
c++;
|
||||
|
||||
foreach (string name in path) {
|
||||
if (name == wild_path_name) {
|
||||
vc [name] = cp.Substring (c); // all remaining paths.
|
||||
continue;
|
||||
}
|
||||
int n = StringIndexOf (template, '{' + name + '}', i);
|
||||
if (String.CompareOrdinal (cp, c, template, i, n - i) != 0)
|
||||
return null; // doesn't match before current template part.
|
||||
@@ -285,11 +297,12 @@ namespace System
|
||||
c += value.Length;
|
||||
}
|
||||
int tEnd = template.IndexOf ('?');
|
||||
int wildIdx = template.IndexOf ('*');
|
||||
bool wild = wildIdx >= 0;
|
||||
if (tEnd < 0)
|
||||
tEnd = template.Length;
|
||||
bool wild = (template [tEnd - 1] == '*');
|
||||
if (wild)
|
||||
tEnd--;
|
||||
tEnd = wildIdx - 1;
|
||||
if (!wild && (cp.Length - c) != (tEnd - i) ||
|
||||
String.CompareOrdinal (cp, c, template, i, tEnd - i) != 0)
|
||||
return null; // suffix doesn't match
|
||||
@@ -337,8 +350,9 @@ namespace System
|
||||
ReadOnlyCollection<string> ParsePathTemplate (string template, int index, int end)
|
||||
{
|
||||
int widx = template.IndexOf ('*', index, end);
|
||||
if (widx >= 0 && widx != end - 1)
|
||||
throw new FormatException (String.Format ("Wildcard in UriTemplate is valid only if it is placed at the last part of the path: '{0}'", template));
|
||||
if (widx >= 0)
|
||||
if (widx != end - 1 && template.IndexOf ('}', widx) != end - 1)
|
||||
throw new FormatException (String.Format ("Wildcard in UriTemplate is valid only if it is placed at the last part of the path: '{0}'", template));
|
||||
List<string> list = null;
|
||||
int prevEnd = -2;
|
||||
for (int i = index; i <= end; ) {
|
||||
@@ -356,6 +370,8 @@ namespace System
|
||||
i++;
|
||||
string name = template.Substring (i, e - i);
|
||||
string uname = name.ToUpper (CultureInfo.InvariantCulture);
|
||||
if (uname [0] == '*')
|
||||
uname = wild_path_name = uname.Substring (1);
|
||||
if (list.Contains (uname) || (path != null && path.Contains (uname)))
|
||||
throw new InvalidOperationException (String.Format ("The URI template string contains duplicate template item {{'{0}'}}", name));
|
||||
list.Add (uname);
|
||||
|
||||
@@ -0,0 +1,321 @@
|
||||
//
|
||||
// This code was partly auto-generated by slsvcutil, version 4.0.60310.0
|
||||
//
|
||||
namespace DHIWebService
|
||||
{
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
|
||||
[System.Runtime.Serialization.DataContractAttribute(Name="ClientLoginData", Namespace="http://schemas.datacontract.org/2004/07/Domain.Models")]
|
||||
public partial class ClientLoginData : object
|
||||
{
|
||||
|
||||
private int CompanyNumberField;
|
||||
|
||||
private string InstitutionIdField;
|
||||
|
||||
private string PasswordField;
|
||||
|
||||
private string UserNameField;
|
||||
|
||||
[System.Runtime.Serialization.DataMemberAttribute()]
|
||||
public int CompanyNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.CompanyNumberField;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.CompanyNumberField = value;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Runtime.Serialization.DataMemberAttribute()]
|
||||
public string InstitutionId
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.InstitutionIdField;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.InstitutionIdField = value;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)]
|
||||
public string Password
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.PasswordField;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.PasswordField = value;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)]
|
||||
public string UserName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.UserNameField;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.UserNameField = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
|
||||
[System.Runtime.Serialization.DataContractAttribute(Name="Login", Namespace="http://schemas.datacontract.org/2004/07/Domain.Models")]
|
||||
public partial class Login : object
|
||||
{
|
||||
|
||||
private int CompanyNumberField;
|
||||
|
||||
private string InstitutionIdField;
|
||||
|
||||
private string PasswordField;
|
||||
|
||||
private string UserNameField;
|
||||
|
||||
[System.Runtime.Serialization.DataMemberAttribute()]
|
||||
public int CompanyNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.CompanyNumberField;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.CompanyNumberField = value;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Runtime.Serialization.DataMemberAttribute()]
|
||||
public string InstitutionId
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.InstitutionIdField;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.InstitutionIdField = value;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)]
|
||||
public string Password
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.PasswordField;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.PasswordField = value;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)]
|
||||
public string UserName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.UserNameField;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.UserNameField = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
[System.ServiceModel.ServiceContractAttribute(Namespace="IBEWebSvc", ConfigurationName="DHIWebService.IDHIService")]
|
||||
public interface IDHIService
|
||||
{
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="IBEWebSvc/IDHIService/Login", ReplyAction="IBEWebSvc/IDHIService/LoginResponse")]
|
||||
// FIXME: uncommenting this results in cryptic error message. We should tell what could be wrong here.
|
||||
// [System.ServiceModel.Web.WebInvoke(BodyStyle=System.ServiceModel.Web.WebMessageBodyStyle.Wrapped)]
|
||||
System.IAsyncResult BeginLogin(DHIWebService.LoginRequest request, System.AsyncCallback callback, object asyncState);
|
||||
|
||||
DHIWebService.LoginResponse EndLogin(System.IAsyncResult result);
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(Action="IBEWebSvc/IDHIService/Login", ReplyAction="IBEWebSvc/IDHIService/LoginResponse")]
|
||||
[System.ServiceModel.Web.WebInvoke(BodyStyle=System.ServiceModel.Web.WebMessageBodyStyle.Wrapped)]
|
||||
DHIWebService.LoginResponse Login(DHIWebService.LoginRequest request);
|
||||
|
||||
|
||||
}
|
||||
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
[System.ServiceModel.MessageContractAttribute(WrapperName="Login", WrapperNamespace="IBEWebSvc", IsWrapped=true)]
|
||||
public partial class LoginRequest
|
||||
{
|
||||
|
||||
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="IBEWebSvc", Order=0)]
|
||||
public DHIWebService.ClientLoginData clientLoginData;
|
||||
|
||||
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="IBEWebSvc", Order=1)]
|
||||
public DHIWebService.Login credentials;
|
||||
|
||||
public LoginRequest()
|
||||
{
|
||||
}
|
||||
|
||||
public LoginRequest(DHIWebService.ClientLoginData clientLoginData, DHIWebService.Login credentials)
|
||||
{
|
||||
this.clientLoginData = clientLoginData;
|
||||
this.credentials = credentials;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
[System.ServiceModel.MessageContractAttribute(WrapperName="LoginResponse", WrapperNamespace="IBEWebSvc", IsWrapped=true)]
|
||||
public partial class LoginResponse
|
||||
{
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
public interface IDHIServiceChannel : DHIWebService.IDHIService, System.ServiceModel.IClientChannel
|
||||
{
|
||||
}
|
||||
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
public partial class LoginCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
|
||||
{
|
||||
|
||||
private object[] results;
|
||||
|
||||
public LoginCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
|
||||
base(exception, cancelled, userState)
|
||||
{
|
||||
this.results = results;
|
||||
}
|
||||
|
||||
public DHIWebService.LoginResponse Result
|
||||
{
|
||||
get
|
||||
{
|
||||
base.RaiseExceptionIfNecessary();
|
||||
return ((DHIWebService.LoginResponse)(this.results[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
public partial class DHIServiceClient : System.ServiceModel.ClientBase<DHIWebService.IDHIService>, DHIWebService.IDHIService
|
||||
{
|
||||
|
||||
private BeginOperationDelegate onBeginLoginDelegate;
|
||||
|
||||
private EndOperationDelegate onEndLoginDelegate;
|
||||
|
||||
private System.Threading.SendOrPostCallback onLoginCompletedDelegate;
|
||||
|
||||
public DHIServiceClient()
|
||||
{
|
||||
}
|
||||
|
||||
public DHIServiceClient(string endpointConfigurationName) :
|
||||
base(endpointConfigurationName)
|
||||
{
|
||||
}
|
||||
|
||||
public DHIServiceClient(string endpointConfigurationName, string remoteAddress) :
|
||||
base(endpointConfigurationName, remoteAddress)
|
||||
{
|
||||
}
|
||||
|
||||
public DHIServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
|
||||
base(endpointConfigurationName, remoteAddress)
|
||||
{
|
||||
}
|
||||
|
||||
public DHIServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
|
||||
base(binding, remoteAddress)
|
||||
{
|
||||
}
|
||||
|
||||
public event System.EventHandler<LoginCompletedEventArgs> LoginCompleted;
|
||||
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
System.IAsyncResult DHIWebService.IDHIService.BeginLogin(DHIWebService.LoginRequest request, System.AsyncCallback callback, object asyncState)
|
||||
{
|
||||
return base.Channel.BeginLogin(request, callback, asyncState);
|
||||
}
|
||||
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
DHIWebService.LoginResponse DHIWebService.IDHIService.EndLogin(System.IAsyncResult result)
|
||||
{
|
||||
return base.Channel.EndLogin(result);
|
||||
}
|
||||
|
||||
private System.IAsyncResult OnBeginLogin(object[] inValues, System.AsyncCallback callback, object asyncState)
|
||||
{
|
||||
DHIWebService.LoginRequest request = ((DHIWebService.LoginRequest)(inValues[0]));
|
||||
return ((DHIWebService.IDHIService)(this)).BeginLogin(request, callback, asyncState);
|
||||
}
|
||||
|
||||
private object[] OnEndLogin(System.IAsyncResult result)
|
||||
{
|
||||
DHIWebService.LoginResponse retVal = ((DHIWebService.IDHIService)(this)).EndLogin(result);
|
||||
return new object[] {
|
||||
retVal};
|
||||
}
|
||||
|
||||
private void OnLoginCompleted(object state)
|
||||
{
|
||||
if ((this.LoginCompleted != null))
|
||||
{
|
||||
InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
|
||||
this.LoginCompleted(this, new LoginCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
|
||||
}
|
||||
}
|
||||
|
||||
public void LoginAsync(DHIWebService.LoginRequest request)
|
||||
{
|
||||
this.LoginAsync(request, null);
|
||||
}
|
||||
|
||||
public void LoginAsync(DHIWebService.LoginRequest request, object userState)
|
||||
{
|
||||
if ((this.onBeginLoginDelegate == null))
|
||||
{
|
||||
this.onBeginLoginDelegate = new BeginOperationDelegate(this.OnBeginLogin);
|
||||
}
|
||||
if ((this.onEndLoginDelegate == null))
|
||||
{
|
||||
this.onEndLoginDelegate = new EndOperationDelegate(this.OnEndLogin);
|
||||
}
|
||||
if ((this.onLoginCompletedDelegate == null))
|
||||
{
|
||||
this.onLoginCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnLoginCompleted);
|
||||
}
|
||||
base.InvokeAsync(this.onBeginLoginDelegate, new object[] {
|
||||
request}, this.onEndLoginDelegate, this.onLoginCompletedDelegate, userState);
|
||||
}
|
||||
|
||||
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
DHIWebService.LoginResponse DHIWebService.IDHIService.Login (DHIWebService.LoginRequest request)
|
||||
{
|
||||
return base.Channel.Login(request);
|
||||
}
|
||||
}
|
||||
}
|
||||
-1
@@ -241,7 +241,6 @@ namespace MonoTests.System.ServiceModel.Description
|
||||
var se = new ServiceEndpoint (cd, new WebHttpBinding (), new EndpointAddress ("http://localhost:8080/"));
|
||||
var wmebe = new WebMessageEncodingBindingElement ();
|
||||
var wme = wmebe.CreateMessageEncoderFactory ().Encoder;
|
||||
Console.WriteLine (wme.MediaType);
|
||||
var msg = wme.ReadMessage (ms, 100, null); // "application/xml" causes error.
|
||||
var formatter = new WebHttpBehaviorExt ().DoGetRequestDispatchFormatter (od, se);
|
||||
object [] pars = new object [1];
|
||||
|
||||
+1
@@ -256,6 +256,7 @@ namespace MonoTests.System.ServiceModel.Dispatcher
|
||||
{
|
||||
var host = new WebServiceHost (typeof (Hello));
|
||||
host.AddServiceEndpoint (typeof (IHello), new WebHttpBinding (), "http://localhost:37564/");
|
||||
host.Description.Behaviors.Find<ServiceDebugBehavior> ().IncludeExceptionDetailInFaults = true;
|
||||
host.Open ();
|
||||
try {
|
||||
// run client
|
||||
|
||||
@@ -228,6 +228,15 @@ namespace MonoTests.System
|
||||
Assert.AreEqual ("http://localhost/x/value2/value1", u.ToString ());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BindByName3 ()
|
||||
{
|
||||
var t = new UriTemplate ("Login?clientLoginData={clientLoginData}&credentials={credentials}");
|
||||
var n = new NameValueCollection ();
|
||||
var u = t.BindByName (new Uri ("http://localhost"), n);
|
||||
Assert.AreEqual ("http://localhost/Login", u.ToString (), "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BindByNameManySlashes ()
|
||||
{
|
||||
@@ -458,5 +467,13 @@ namespace MonoTests.System
|
||||
Assert.AreEqual ("http://localhost:8080/id-aaa/bbb", uri.ToString ());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NamedWildcard ()
|
||||
{
|
||||
UriTemplate template = new UriTemplate ("{*path}");
|
||||
UriTemplateMatch match = template.Match (new Uri ("http://localhost"), new Uri ("http://localhost/something"));
|
||||
Assert.IsNotNull (match, "#1");
|
||||
Assert.AreEqual ("something", match.BoundVariables ["path"], "#2");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
#if !MOBILE
|
||||
namespace System.Runtime.CompilerServices
|
||||
{
|
||||
// introduced for silverlight sdk compatibility
|
||||
@@ -11,6 +12,7 @@ namespace System.Runtime.CompilerServices
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace System.ServiceModel
|
||||
{
|
||||
@@ -102,6 +104,7 @@ namespace System.ServiceModel.Security
|
||||
{
|
||||
class Dummy {}
|
||||
}
|
||||
#if !MOBILE
|
||||
namespace System.Net.Security
|
||||
{
|
||||
public enum ProtectionLevel {None}
|
||||
@@ -118,4 +121,4 @@ namespace Mono.Xml.XPath
|
||||
{
|
||||
class Dummy {}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -10,6 +10,7 @@ LIBRARY = System.ServiceModel.dll
|
||||
LIB_MCS_FLAGS = \
|
||||
/nowarn:414,169,67,3005,436,219,618 \
|
||||
/unsafe \
|
||||
/d:TRACE \
|
||||
/r:System.dll \
|
||||
/r:System.Xml.dll \
|
||||
/r:System.Core.dll \
|
||||
@@ -44,6 +45,7 @@ TEST_EXTRA_FILES = \
|
||||
System.ServiceModel_test_net_3_0.dll.config \
|
||||
Test/config/* \
|
||||
Test/Resources/* \
|
||||
Test/XmlFiles/* \
|
||||
Test/System.ServiceModel.Description/dump.xml
|
||||
|
||||
EXTRA_DISTFILES = $(RESOURCE_FILES) $(TEST_EXTRA_FILES)
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
using System.ServiceModel.Channels;
|
||||
|
||||
namespace System.IO
|
||||
{
|
||||
public class PipeException : IOException
|
||||
{
|
||||
public PipeException ()
|
||||
{
|
||||
}
|
||||
|
||||
public PipeException (string message): base (message)
|
||||
{
|
||||
}
|
||||
|
||||
protected PipeException (SerializationInfo info, StreamingContext context)
|
||||
: base (info, context)
|
||||
{
|
||||
}
|
||||
|
||||
public PipeException (string message, Exception inner)
|
||||
: base (message, inner)
|
||||
{
|
||||
}
|
||||
|
||||
public PipeException (string message, int errorCode)
|
||||
: base (message, errorCode)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual int ErrorCode {
|
||||
get {
|
||||
// we re-use the HResult for the error code here.
|
||||
return HResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,6 +164,8 @@ namespace System.ServiceModel.Channels.Http
|
||||
public abstract string ContentType { get; }
|
||||
public abstract string HttpMethod { get; }
|
||||
public abstract Stream InputStream { get; }
|
||||
public abstract string ClientIPAddress { get; }
|
||||
public abstract int ClientPort { get; }
|
||||
}
|
||||
|
||||
class HttpStandaloneRequestInfo : HttpRequestInfo
|
||||
@@ -196,6 +198,12 @@ namespace System.ServiceModel.Channels.Http
|
||||
public override Stream InputStream {
|
||||
get { return req.InputStream; }
|
||||
}
|
||||
public override string ClientIPAddress {
|
||||
get { return req.RemoteEndPoint.Address.ToString (); }
|
||||
}
|
||||
public override int ClientPort {
|
||||
get { return req.RemoteEndPoint.Port; }
|
||||
}
|
||||
}
|
||||
|
||||
class AspNetHttpRequestInfo : HttpRequestInfo
|
||||
@@ -228,6 +236,12 @@ namespace System.ServiceModel.Channels.Http
|
||||
public override Stream InputStream {
|
||||
get { return req.InputStream; }
|
||||
}
|
||||
public override string ClientIPAddress {
|
||||
get { return req.UserHostAddress; }
|
||||
}
|
||||
public override int ClientPort {
|
||||
get { return -1; } // cannot retrieve
|
||||
}
|
||||
}
|
||||
|
||||
// Response
|
||||
|
||||
@@ -111,11 +111,7 @@ namespace System.ServiceModel.Channels.Http
|
||||
{
|
||||
var l = new HttpListener ();
|
||||
|
||||
#if false // FIXME: enable this once we found out why this causes problem
|
||||
string uriString = element.HostNameComparisonMode == HostNameComparisonMode.Exact ? uri.ToString () : uri.Scheme + "://*" + uri.GetComponents (UriComponents.Port | UriComponents.Path, UriFormat.SafeUnescaped);
|
||||
#else
|
||||
string uriString = uri.ToString ();
|
||||
#endif
|
||||
if (!uriString.EndsWith ("/", StringComparison.Ordinal))
|
||||
uriString += "/"; // HttpListener requires this mess.
|
||||
|
||||
|
||||
@@ -57,6 +57,10 @@ namespace System.ServiceModel.Channels.Http
|
||||
}
|
||||
}
|
||||
|
||||
internal HttpChannelListener<IReplyChannel> Source {
|
||||
get { return source; }
|
||||
}
|
||||
|
||||
public MessageEncoder Encoder {
|
||||
get { return source.MessageEncoder; }
|
||||
}
|
||||
@@ -176,7 +180,7 @@ namespace System.ServiceModel.Channels.Http
|
||||
msg.Properties.Add ("Via", LocalAddress.Uri);
|
||||
msg.Properties.Add (HttpRequestMessageProperty.Name, CreateRequestProperty (ctxi));
|
||||
|
||||
Logger.LogMessage (MessageLogSourceKind.TransportReceive, ref msg, 0x10000); // FIXME: pass maxMessageSize.
|
||||
Logger.LogMessage (MessageLogSourceKind.TransportReceive, ref msg, source.Source.MaxReceivedMessageSize);
|
||||
|
||||
context = new HttpRequestContext (this, ctxi, msg);
|
||||
reqctx = context;
|
||||
@@ -235,6 +239,7 @@ namespace System.ServiceModel.Channels.Http
|
||||
msg.Headers.Action = action;
|
||||
}
|
||||
}
|
||||
msg.Properties.Add (RemoteEndpointMessageProperty.Name, new RemoteEndpointMessageProperty (ctxi.Request.ClientIPAddress, ctxi.Request.ClientPort));
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
@@ -133,6 +133,8 @@ namespace System.ServiceModel.Channels.Http
|
||||
if (msg == null)
|
||||
throw new ArgumentNullException ("msg");
|
||||
|
||||
Logger.LogMessage (MessageLogSourceKind.TransportSend, ref msg, Channel.Source.Source.MaxReceivedMessageSize);
|
||||
|
||||
MemoryStream ms = new MemoryStream ();
|
||||
Channel.Encoder.WriteMessage (msg, ms);
|
||||
Context.Response.ContentType = Channel.Encoder.ContentType;
|
||||
|
||||
Executable → Regular
+1
@@ -34,6 +34,7 @@ using System.Net;
|
||||
using System.Net.Security;
|
||||
using System.Net.Sockets;
|
||||
using System.ServiceModel;
|
||||
using System.ServiceModel.Channels.NetTcp;
|
||||
using System.ServiceModel.Description;
|
||||
using System.ServiceModel.PeerResolvers;
|
||||
using System.ServiceModel.Security;
|
||||
+1
-1
@@ -38,7 +38,7 @@ using System.Text;
|
||||
using System.Threading;
|
||||
using System.Xml;
|
||||
|
||||
namespace System.ServiceModel.Channels
|
||||
namespace System.ServiceModel.Channels.NetTcp
|
||||
{
|
||||
// seealso: [MC-NMF] Windows Protocol document.
|
||||
class TcpBinaryFrameManager
|
||||
+1
-1
@@ -17,7 +17,7 @@ using System.ServiceModel.Security;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
namespace System.ServiceModel.Channels
|
||||
namespace System.ServiceModel.Channels.NetTcp
|
||||
{
|
||||
internal class TcpChannelInfo
|
||||
{
|
||||
+1
-1
@@ -38,7 +38,7 @@ using System.Text;
|
||||
using System.Threading;
|
||||
using System.Xml;
|
||||
|
||||
namespace System.ServiceModel.Channels
|
||||
namespace System.ServiceModel.Channels.NetTcp
|
||||
{
|
||||
internal class TcpChannelListener<TChannel> : InternalChannelListenerBase<TChannel>
|
||||
where TChannel : class, IChannel
|
||||
+8
-1
@@ -41,7 +41,7 @@ using System.Text;
|
||||
using System.Threading;
|
||||
using System.Xml;
|
||||
|
||||
namespace System.ServiceModel.Channels
|
||||
namespace System.ServiceModel.Channels.NetTcp
|
||||
{
|
||||
internal class TcpDuplexSessionChannel : DuplexChannelBase, IDuplexSessionChannel
|
||||
{
|
||||
@@ -147,6 +147,9 @@ namespace System.ServiceModel.Channels
|
||||
}
|
||||
|
||||
client.SendTimeout = (int) timeout.TotalMilliseconds;
|
||||
|
||||
Logger.LogMessage (MessageLogSourceKind.TransportSend, ref message, info.BindingElement.MaxReceivedMessageSize);
|
||||
|
||||
frame.WriteSizedMessage (message);
|
||||
}
|
||||
|
||||
@@ -164,12 +167,16 @@ namespace System.ServiceModel.Channels
|
||||
if (timeout <= TimeSpan.Zero)
|
||||
throw new ArgumentException (String.Format ("Timeout value must be positive value. It was {0}", timeout));
|
||||
client.ReceiveTimeout = (int) timeout.TotalMilliseconds;
|
||||
|
||||
message = frame.ReadSizedMessage ();
|
||||
// FIXME: this may not be precise, but connection might be reused for some weird socket state transition (that's what happens). So as a workaround, avoid closing the session by sending EndRecord from this channel at OnClose().
|
||||
if (message == null) {
|
||||
session = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
Logger.LogMessage (MessageLogSourceKind.TransportReceive, ref message, info.BindingElement.MaxReceivedMessageSize);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Loaded 100 of 468 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user