From: Marek Safar Date: Mon, 8 Apr 2013 10:00:28 +0000 (-0700) Subject: Merge pull request #601 from knocte/sock_improvements X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=60979ce4a41d1be8f9d3d4d38162c0803207b4d5;hp=3e401381fe6dbd06002bcb454af3e9c8a2a8846a;p=mono.git Merge pull request #601 from knocte/sock_improvements [System.Net.Sockets] Specify 'timeout' in the exception msg of the Receive(buf) overload --- diff --git a/autogen.sh b/autogen.sh index 3a51ad424c8..8fc51d24df0 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash # Run this to generate all the initial makefiles, etc. # Ripped off from GNOME macros version diff --git a/configure.in b/configure.in index 099c56eecf1..b12e87886cb 100644 --- a/configure.in +++ b/configure.in @@ -1074,6 +1074,8 @@ AC_TRY_COMPILE([ AC_DEFINE_UNQUOTED(MONO_ZERO_LEN_ARRAY, 1, [Length of zero length arrays]) ]) +AC_CHECK_HEADERS(nacl/nacl_dyncode.h) + if test x$target_win32 = xno; then dnl hires monotonic clock support @@ -1784,11 +1786,13 @@ if test x$target_win32 = xno; then dnl ********************************** dnl *** epoll *** dnl ********************************** - AC_CHECK_HEADERS(sys/epoll.h) - haveepoll=no - AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], ) - if test "x$haveepoll" = "xyes" -a "x$ac_cv_header_sys_epoll_h" = "xyes" ; then - AC_DEFINE(HAVE_EPOLL, 1, [epoll supported]) + if test "x$ac_cv_header_nacl_nacl_dyncode_h" = "xno"; then + AC_CHECK_HEADERS(sys/epoll.h) + haveepoll=no + AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], ) + if test "x$haveepoll" = "xyes" -a "x$ac_cv_header_sys_epoll_h" = "xyes"; then + AC_DEFINE(HAVE_EPOLL, 1, [epoll supported]) + fi fi havekqueue=no @@ -1959,6 +1963,9 @@ if test x$target_win32 = xno; then AC_CHECK_FUNCS(lockf) AC_CHECK_FUNCS(swab) AC_CHECK_FUNCS(setusershell endusershell) + AC_CHECK_FUNCS(futimens utimensat) + AC_CHECK_FUNCS(fstatat mknodat readlinkat) + AC_CHECK_FUNCS(readv writev preadv pwritev) AC_CHECK_SIZEOF(size_t) AC_CHECK_TYPES([blksize_t], [AC_DEFINE(HAVE_BLKSIZE_T)], , [#include @@ -1973,6 +1980,8 @@ if test x$target_win32 = xno; then AC_CHECK_TYPES([struct flock], [AC_DEFINE(HAVE_STRUCT_FLOCK)], , [#include #include ]) + AC_CHECK_TYPES([struct iovec], [AC_DEFINE(HAVE_STRUCT_IOVEC)], , + [#include ]) AC_CHECK_TYPES([struct pollfd], [AC_DEFINE(HAVE_STRUCT_POLLFD)], , [#include ]) AC_CHECK_TYPES([struct stat], [AC_DEFINE(HAVE_STRUCT_STAT)], , @@ -2002,6 +2011,11 @@ if test x$target_win32 = xno; then [struct statfs.f_flags],,, [#include #include ]) + AC_CHECK_MEMBERS( + [struct stat.st_atim, struct stat.st_mtim, struct stat.st_ctim],,, + [#include + #include + #include ]) dnl Favour xattr through glibc, but use libattr if we have to AC_CHECK_FUNC(lsetxattr, , @@ -2294,6 +2308,16 @@ AC_ARG_ENABLE(nacl_codegen, [ --enable-nacl-codegen Enable Native Client c AC_ARG_ENABLE(nacl_gc, [ --enable-nacl-gc Enable Native Client garbage collection], enable_nacl_gc=$enableval, enable_nacl_gc=no) AM_CONDITIONAL(NACL_CODEGEN, test x$enable_nacl_codegen != xno) + +dnl +dnl Hack to use system mono for operations in build/install not allowed in NaCl. +dnl +nacl_self_host="" +if test "x$ac_cv_header_nacl_nacl_dyncode_h" = "xyes"; then + nacl_self_host="nacl_self_host" +fi +AC_SUBST(nacl_self_host) + if test "x$enable_nacl_codegen" = "xyes"; then MONO_NACL_ALIGN_MASK_OFF=1 CPPFLAGS="$CPPFLAGS -D__native_client_codegen__" @@ -2462,6 +2486,10 @@ case "$host" in TARGET=AMD64; arch_target=amd64; JIT_SUPPORTED=yes + if test "x$ac_cv_sizeof_void_p" = "x4"; then + AC_DEFINE(__mono_ilp32__, 1, [64 bit mode with 4 byte longs and pointers]) + sizeof_register=8 + fi case $host_os in linux*) sgen_supported=true @@ -2558,6 +2586,15 @@ case "$host" in NESTED_LIBGC_FLAGS="$NESTED_LIBGC_FLAGS -DHAVE_ARMV6" fi ;; +# TODO: make proper support for NaCl host. +# arm*-*nacl) +# TARGET=ARM; +# arch_target=arm; +# ACCESS_UNALIGNED="no" +# JIT_SUPPORTED=yes +# sgen_supported=true +# AOT_SUPPORTED="no" +# ;; s390-*-linux*) TARGET=S390; arch_target=s390; @@ -2622,7 +2659,29 @@ if test "x$host" != "x$target"; then AC_DEFINE(__mono_ilp32__, 1, [64 bit mode with 4 byte longs and pointers]) sizeof_register=8 ;; - *-*-nacl) +# TODO: make proper support for NaCl target. +# arm*-*nacl) +# TARGET=ARM +# arch_target=arm +# AC_DEFINE(TARGET_ARM, 1, [...]) +# ACCESS_UNALIGNED="no" +# JIT_SUPPORTED=yes +# sizeof_register=4 +# CPPFLAGS="$CPPFLAGS \ +# -DARM_FPU_VFP=1 -D__ARM_EABI__ \ +# -D__arm__ \ +# -D__portable_native_client__ \ +# -DARM_FPU_VFP=1 \ +# -Dtimezone=_timezone \ +# -DDISABLE_SOCKETS \ +# -DDISABLE_ATTACH \ +# -DUSE_NEWLIB" +# jit_wanted=true + # Can't use tls, since it depends on the runtime detection of tls offsets + # in mono-compiler.h +# with_tls=pthread +# ;; + i686-*-nacl) TARGET=X86 arch_target=x86 AC_DEFINE(TARGET_X86, 1, [...]) diff --git a/eglib/src/eglib-config.h.in b/eglib/src/eglib-config.h.in index 19e4f4d59e2..ba0f93f9be5 100644 --- a/eglib/src/eglib-config.h.in +++ b/eglib/src/eglib-config.h.in @@ -37,9 +37,6 @@ typedef signed @GSIZE@ gssize; #endif #if defined (__native_client__) -#define sem_trywait(x) sem_wait(x) -#define sem_timedwait(x,y) sem_wait(x) -#define getdtablesize() (32768) #undef G_BREAKPOINT #define G_BREAKPOINT() #endif diff --git a/eglib/src/gfile-posix.c b/eglib/src/gfile-posix.c index 48a9192ab69..d52ad948802 100644 --- a/eglib/src/gfile-posix.c +++ b/eglib/src/gfile-posix.c @@ -154,6 +154,15 @@ g_file_open_tmp (const gchar *tmpl, gchar **name_used, GError **error) gchar * g_get_current_dir (void) { +#ifdef __native_client__ + char *buffer; + if ((buffer = getenv("NACL_PWD"))) { + buffer = g_strdup(buffer); + } else { + buffer = g_strdup("."); + } + return buffer; +#else int s = 32; char *buffer = NULL, *r; gboolean fail; @@ -172,4 +181,5 @@ g_get_current_dir (void) * so we return the buffer here since it has a pointer to the valid string */ return buffer; +#endif } diff --git a/eglib/src/gmodule-unix.c b/eglib/src/gmodule-unix.c index 87eb27aef2a..9dd5eaa3d54 100644 --- a/eglib/src/gmodule-unix.c +++ b/eglib/src/gmodule-unix.c @@ -28,46 +28,12 @@ * 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 + #include #include -#if defined(__native_client__) -GModule * -g_module_open (const gchar *file, GModuleFlags flags) -{ - printf("dlopen() not supported on Native Client.\n"); - return NULL; -} - - -gboolean -g_module_symbol (GModule *module, const gchar *symbol_name, gpointer *symbol) -{ - return FALSE; -} - - -const gchar* -g_module_error(void) -{ - return "dlopen not supported on Native Client."; -} - -gboolean -g_module_close (GModule *module) -{ - return FALSE; -} - -gchar* -g_module_build_path (const gchar *directory, const gchar *module_name) -{ - return NULL; -} - -#else - -#ifdef G_OS_UNIX +#if defined(G_OS_UNIX) && defined(HAVE_DLFCN_H) #include /* For Linux and Solaris, need to add others as we port this */ @@ -322,5 +288,3 @@ g_module_build_path (const gchar *directory, const gchar *module_name) return g_strdup_printf ("%s%s" LIBSUFFIX, lib_prefix, module_name); } -#endif /* __native_client__ */ - diff --git a/eglib/src/goutput.c b/eglib/src/goutput.c index c3dff59d891..aff9f460c57 100644 --- a/eglib/src/goutput.c +++ b/eglib/src/goutput.c @@ -148,6 +148,12 @@ g_logv (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format, if (vasprintf (&msg, format, args) < 0) return; +#ifdef G_OS_WIN32 + printf ("%s%s%s\n", + log_domain != NULL ? log_domain : "", + log_domain != NULL ? ": " : "", + msg); +#else #if MONOTOUCH FILE *target = stderr; #else @@ -158,6 +164,7 @@ g_logv (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format, log_domain != NULL ? log_domain : "", log_domain != NULL ? ": " : "", msg); +#endif free (msg); if (log_level & fatal){ fflush (stdout); diff --git a/external/cecil b/external/cecil index 54e0a50464e..fc76b93e3e0 160000 --- a/external/cecil +++ b/external/cecil @@ -1 +1 @@ -Subproject commit 54e0a50464edbc254b39ea3c885ee91ada730705 +Subproject commit fc76b93e3e0064b2d751796878f9cbe88df1d5f4 diff --git a/ikvm-native/os.c b/ikvm-native/os.c index 65d49e2a2ae..9f2115f712b 100644 --- a/ikvm-native/os.c +++ b/ikvm-native/os.c @@ -95,6 +95,11 @@ JNIEXPORT int JNICALL ikvm_msync(void* address, jint size) { +#if defined(__native_client__) && defined(USE_NEWLIB) + g_assert_not_reached (); + return -1; +#else return msync(address, size, MS_SYNC); +#endif } #endif diff --git a/libgc/dyn_load.c b/libgc/dyn_load.c index e4be3c7d183..ca7ce54f194 100644 --- a/libgc/dyn_load.c +++ b/libgc/dyn_load.c @@ -26,7 +26,7 @@ * None of this is safe with dlclose and incremental collection. * But then not much of anything is safe in the presence of dlclose. */ -#if defined(__linux__) && !defined(_GNU_SOURCE) +#if (defined(__linux__) || defined(__native_client__)) && !defined(_GNU_SOURCE) /* Can't test LINUX, since this must be define before other includes */ # define _GNU_SOURCE #endif @@ -54,7 +54,7 @@ #if !defined(SUNOS4) && !defined(SUNOS5DL) && !defined(IRIX5) && \ !defined(MSWIN32) && !defined(MSWINCE) && \ !(defined(ALPHA) && defined(OSF1)) && \ - !defined(HPUX) && !(defined(LINUX) && defined(__ELF__)) && \ + !defined(HPUX) && !((defined(LINUX) || defined(NACL)) && defined(__ELF__)) && \ !defined(RS6000) && !defined(SCO_ELF) && !defined(DGUX) && \ !(defined(FREEBSD) && defined(__ELF__)) && \ !(defined(OPENBSD) && (defined(__ELF__) || defined(M68K))) && \ @@ -91,7 +91,7 @@ # define ELFSIZE ARCH_ELFSIZE #endif -#if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF) || \ +#if (defined(LINUX) || defined(NACL)) && defined(__ELF__) || defined(SCO_ELF) || \ (defined(FREEBSD) && defined(__ELF__)) || defined(DGUX) || \ (defined(OPENBSD) && defined(__ELF__)) || \ (defined(NETBSD) && defined(__ELF__)) || defined(HURD) @@ -297,7 +297,7 @@ void GC_register_dynamic_libraries() # endif /* !USE_PROC ... */ # endif /* SUNOS */ -#if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF) || \ +#if (defined(LINUX) || defined(NACL)) && defined(__ELF__) || defined(SCO_ELF) || \ (defined(FREEBSD) && defined(__ELF__)) || defined(DGUX) || \ (defined(OPENBSD) && defined(__ELF__)) || \ (defined(NETBSD) && defined(__ELF__)) || defined(HURD) @@ -394,7 +394,7 @@ GC_bool GC_register_main_static_data() /* For glibc 2.2.4+. Unfortunately, it doesn't work for older */ /* versions. Thanks to Jakub Jelinek for most of the code. */ -# if defined(LINUX) /* Are others OK here, too? */ \ +# if (defined(LINUX) || defined(NACL)) /* Are others OK here, too? */ \ && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \ || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG))) diff --git a/libgc/include/private/gc_locks.h b/libgc/include/private/gc_locks.h index 8705d07a1bb..80712fcdf3f 100644 --- a/libgc/include/private/gc_locks.h +++ b/libgc/include/private/gc_locks.h @@ -223,12 +223,22 @@ # define GC_CLEAR_DEFINED # endif /* ALPHA */ # ifdef ARM32 +#ifdef __native_client__ +#define NACL_ALIGN() ".align 4\n" +#define MASK_REGISTER(reg) "bic " reg ", " reg ", #0xc0000000\n" +#else +#define NACL_ALIGN() +#define MASK_REGISTER(reg) +#endif inline static int GC_test_and_set(volatile unsigned int *addr) { #if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7__) int ret, tmp; __asm__ __volatile__ ( "1:\n" + NACL_ALIGN() + MASK_REGISTER("%3") "ldrex %0, [%3]\n" + MASK_REGISTER("%3") "strex %1, %2, [%3]\n" "teq %1, #0\n" "bne 1b\n" @@ -242,7 +252,8 @@ * bus because there are no SMP ARM machines. If/when there are, * this code will likely need to be updated. */ /* See linuxthreads/sysdeps/arm/pt-machine.h in glibc-2.1 */ - __asm__ __volatile__("swp %0, %1, [%2]" + __asm__ __volatile__(MASK_REGISTER("%2") + "swp %0, %1, [%2]" : "=&r"(oldval) : "r"(1), "r"(addr) : "memory"); diff --git a/libgc/include/private/gcconfig.h b/libgc/include/private/gcconfig.h index ec53e3a95ea..88e783800de 100644 --- a/libgc/include/private/gcconfig.h +++ b/libgc/include/private/gcconfig.h @@ -67,12 +67,18 @@ /* Determine the machine type: */ # if defined(__native_client__) # define NACL -# define I386 -# define mach_type_known +# if !defined(__portable_native_client__) +# define I386 +# define mach_type_known +# else + /* Here we will rely upon arch-specific defines. */ +# endif # endif # if defined(__arm__) || defined(__thumb__) # define ARM32 -# if !defined(LINUX) && !defined(NETBSD) && !defined(DARWIN) +# if defined(NACL) +# define mach_type_known +# elif !defined(LINUX) && !defined(NETBSD) && !defined(DARWIN) # define NOSYS # define mach_type_known # endif @@ -928,6 +934,30 @@ # endif # endif + +# ifdef NACL +# define OS_TYPE "NACL" +# if defined(__GLIBC__) +# define DYNAMIC_LOADING +# endif +# define DATASTART ((ptr_t)0x10020000) + extern int _end[]; +# define DATAEND (_end) +# ifdef STACK_GRAN +# undef STACK_GRAN +# endif /* STACK_GRAN */ +# define STACK_GRAN 0x10000 +# define HEURISTIC1 +# define USE_MMAP +# define USE_MUNMAP +# define USE_MMAP_ANON +# ifdef USE_MMAP_FIXED +# undef USE_MMAP_FIXED +# endif +# define GETPAGESIZE() 65536 +# define MAX_NACL_GC_THREADS 1024 +# endif + # ifdef VAX # define MACH_TYPE "VAX" # define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */ @@ -1204,33 +1234,6 @@ # define HEAP_START DATAEND # endif /* USE_MMAP */ # endif /* DGUX */ -# ifdef NACL -# define OS_TYPE "NACL" - extern int etext[]; -//# define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff)) -# define DATASTART ((ptr_t)0x10000000) - extern int _end[]; -# define DATAEND (_end) -# ifdef STACK_GRAN -# undef STACK_GRAN -# endif /* STACK_GRAN */ -# define STACK_GRAN 0x10000 -# define HEURISTIC1 -# ifdef USE_MMAP -# undef USE_MMAP -# endif -# ifdef USE_MUNMAP -# undef USE_MUNMAP -# endif -# ifdef USE_MMAP_ANON -# undef USE_MMAP_ANON -# endif -# ifdef USE_MMAP_FIXED -# undef USE_MMAP_FIXED -# endif -# define GETPAGESIZE() 65536 -# define MAX_NACL_GC_THREADS 1024 -# endif # ifdef LINUX # ifndef __GNUC__ /* The Intel compiler doesn't like inline assembly */ @@ -1925,8 +1928,12 @@ # endif # ifdef ARM32 -# define CPP_WORDSZ 32 +# if defined( NACL ) +# define MACH_TYPE "NACL" +# else # define MACH_TYPE "ARM32" +# endif +# define CPP_WORDSZ 32 # define ALIGNMENT 4 # ifdef NETBSD # define OS_TYPE "NETBSD" diff --git a/libgc/misc.c b/libgc/misc.c index 5b2868d808b..53d47c53dbc 100644 --- a/libgc/misc.c +++ b/libgc/misc.c @@ -1003,7 +1003,11 @@ long a, b, c, d, e, f; buf[1024] = 0x15; (void) sprintf(buf, format, a, b, c, d, e, f); if (buf[1024] != 0x15) ABORT("GC_printf clobbered stack"); +#ifdef NACL + WRITE(GC_stdout, buf, strlen(buf)); +#else if (WRITE(GC_stdout, buf, strlen(buf)) < 0) ABORT("write to stdout failed"); +#endif } void GC_err_printf(format, a, b, c, d, e, f) @@ -1015,13 +1019,21 @@ long a, b, c, d, e, f; buf[1024] = 0x15; (void) sprintf(buf, format, a, b, c, d, e, f); if (buf[1024] != 0x15) ABORT("GC_err_printf clobbered stack"); +#ifdef NACL + WRITE(GC_stderr, buf, strlen(buf)); +#else if (WRITE(GC_stderr, buf, strlen(buf)) < 0) ABORT("write to stderr failed"); +#endif } void GC_err_puts(s) GC_CONST char *s; { +#ifdef NACL + WRITE(GC_stderr, s, strlen(s)); +#else if (WRITE(GC_stderr, s, strlen(s)) < 0) ABORT("write to stderr failed"); +#endif } #if defined(LINUX) && !defined(SMALL_CONFIG) diff --git a/libgc/pthread_stop_world.c b/libgc/pthread_stop_world.c index e6ac64b62a8..fe2ba1a3810 100644 --- a/libgc/pthread_stop_world.c +++ b/libgc/pthread_stop_world.c @@ -24,13 +24,13 @@ #endif #ifdef NACL -int nacl_park_threads_now = 0; +volatile int __nacl_thread_suspension_needed = 0; pthread_t nacl_thread_parker = -1; -int nacl_thread_parked[MAX_NACL_GC_THREADS]; -int nacl_thread_used[MAX_NACL_GC_THREADS]; -int nacl_thread_parking_inited = 0; -int nacl_num_gc_threads = 0; +volatile int nacl_thread_parked[MAX_NACL_GC_THREADS]; +volatile int nacl_thread_used[MAX_NACL_GC_THREADS]; +volatile int nacl_thread_parking_inited = 0; +volatile int nacl_num_gc_threads = 0; pthread_mutex_t nacl_thread_alloc_lock = PTHREAD_MUTEX_INITIALIZER; __thread int nacl_thread_idx = -1; __thread GC_thread nacl_gc_thread_self = NULL; @@ -471,7 +471,7 @@ static void pthread_stop_world() GC_printf1("pthread_stop_world: num_threads %d\n", nacl_num_gc_threads - 1); #endif nacl_thread_parker = pthread_self(); - nacl_park_threads_now = 1; + __nacl_thread_suspension_needed = 1; while (1) { #define NACL_PARK_WAIT_NANOSECONDS 100000 @@ -513,31 +513,46 @@ static void pthread_stop_world() #define NACL_STORE_REGS() \ do { \ - asm("push %rbx");\ - asm("push %rbp");\ - asm("push %r12");\ - asm("push %r13");\ - asm("push %r14");\ - asm("push %r15");\ - asm("mov %%esp, %0" : "=m" (nacl_gc_thread_self->stop_info.stack_ptr));\ + __asm__ __volatile__ ("push %rbx");\ + __asm__ __volatile__ ("push %rbp");\ + __asm__ __volatile__ ("push %r12");\ + __asm__ __volatile__ ("push %r13");\ + __asm__ __volatile__ ("push %r14");\ + __asm__ __volatile__ ("push %r15");\ + __asm__ __volatile__ ("mov %%esp, %0" : "=m" (nacl_gc_thread_self->stop_info.stack_ptr));\ memcpy(nacl_gc_thread_self->stop_info.reg_storage, nacl_gc_thread_self->stop_info.stack_ptr, NACL_GC_REG_STORAGE_SIZE * sizeof(ptr_t));\ - asm("add $48, %esp");\ - asm("add %r15, %rsp");\ + __asm__ __volatile__ ("naclasp $48, %r15");\ } while (0) #elif __i386__ #define NACL_STORE_REGS() \ do { \ - asm("push %ebx");\ - asm("push %ebp");\ - asm("push %esi");\ - asm("push %edi");\ - asm("mov %%esp, %0" : "=m" (nacl_gc_thread_self->stop_info.stack_ptr));\ + __asm__ __volatile__ ("push %ebx");\ + __asm__ __volatile__ ("push %ebp");\ + __asm__ __volatile__ ("push %esi");\ + __asm__ __volatile__ ("push %edi");\ + __asm__ __volatile__ ("mov %%esp, %0" : "=m" (nacl_gc_thread_self->stop_info.stack_ptr));\ memcpy(nacl_gc_thread_self->stop_info.reg_storage, nacl_gc_thread_self->stop_info.stack_ptr, NACL_GC_REG_STORAGE_SIZE * sizeof(ptr_t));\ - asm("add $16, %esp");\ + __asm__ __volatile__ ("add $16, %esp");\ } while (0) +#elif __arm__ + +#define NACL_STORE_REGS() \ + do { \ + __asm__ __volatile__ ("push {r4-r12,lr}");\ + __asm__ __volatile__ ("mov r0, %0" : : "r" (&nacl_gc_thread_self->stop_info.stack_ptr)); \ + __asm__ __volatile__ ("bic r0, r0, #0xc0000000");\ + __asm__ __volatile__ ("str sp, [r0]");\ + memcpy(nacl_gc_thread_self->stop_info.reg_storage, nacl_gc_thread_self->stop_info.stack_ptr, NACL_GC_REG_STORAGE_SIZE * sizeof(ptr_t));\ + __asm__ __volatile__ ("add sp, sp, #40");\ + __asm__ __volatile__ ("bic sp, sp, #0xc0000000");\ + } while (0) +#else + +#error "Please port NACL_STORE_REGS" + #endif void nacl_pre_syscall_hook() @@ -550,6 +565,8 @@ void nacl_pre_syscall_hook() } } +void __nacl_suspend_thread_if_needed(); + void nacl_post_syscall_hook() { /* Calling __nacl_suspend_thread_if_needed() right away should guarantee we don't mutate the GC set. */ @@ -560,7 +577,7 @@ void nacl_post_syscall_hook() } void __nacl_suspend_thread_if_needed() { - if (nacl_park_threads_now) { + if (__nacl_thread_suspension_needed) { pthread_t self = pthread_self(); int local_dummy = 0; /* Don't try to park the thread parker. */ @@ -579,7 +596,7 @@ void __nacl_suspend_thread_if_needed() { nacl_gc_thread_self->stop_info.stack_ptr = (ptr_t)(&local_dummy); } nacl_thread_parked[nacl_thread_idx] = 1; - while (nacl_park_threads_now) + while (__nacl_thread_suspension_needed) ; /* spin */ nacl_thread_parked[nacl_thread_idx] = 0; @@ -689,7 +706,7 @@ static void pthread_start_world() # if DEBUG_THREADS GC_printf0("World starting\n"); # endif - nacl_park_threads_now = 0; + __nacl_thread_suspension_needed = 0; if (GC_notify_event) GC_notify_event (GC_EVENT_POST_START_WORLD); #endif /* NACL */ diff --git a/libgc/pthread_support.c b/libgc/pthread_support.c index ccafb3b1169..b302688a76e 100644 --- a/libgc/pthread_support.c +++ b/libgc/pthread_support.c @@ -687,10 +687,10 @@ void GC_mark_thread_local_free_lists(void) static struct GC_Thread_Rep first_thread; #ifdef NACL -extern int nacl_thread_parked[MAX_NACL_GC_THREADS]; -extern int nacl_thread_used[MAX_NACL_GC_THREADS]; -extern int nacl_thread_parking_inited; -extern int nacl_num_gc_threads; +extern volatile int nacl_thread_parked[MAX_NACL_GC_THREADS]; +extern volatile int nacl_thread_used[MAX_NACL_GC_THREADS]; +extern volatile int nacl_thread_parking_inited; +extern volatile int nacl_num_gc_threads; extern pthread_mutex_t nacl_thread_alloc_lock; extern __thread int nacl_thread_idx; extern __thread GC_thread nacl_gc_thread_self; @@ -699,10 +699,20 @@ extern void nacl_pre_syscall_hook(); extern void nacl_post_syscall_hook(); extern void nacl_register_gc_hooks(void (*pre)(), void (*post)()); +#include + +struct nacl_irt_blockhook { + int (*register_block_hooks)(void (*pre)(void), void (*post)(void)); +}; + +extern size_t nacl_interface_query(const char *interface_ident, + void *table, size_t tablesize); + void nacl_initialize_gc_thread() { int i; - nacl_register_gc_hooks(nacl_pre_syscall_hook, nacl_post_syscall_hook); + static struct nacl_irt_blockhook gc_hook; + pthread_mutex_lock(&nacl_thread_alloc_lock); if (!nacl_thread_parking_inited) { @@ -710,6 +720,10 @@ void nacl_initialize_gc_thread() nacl_thread_used[i] = 0; nacl_thread_parked[i] = 0; } + // TODO: replace with public 'register hook' function when + // available from glibc + nacl_interface_query("nacl-irt-blockhook-0.1", &gc_hook, sizeof(gc_hook)); + gc_hook.register_block_hooks(nacl_pre_syscall_hook, nacl_post_syscall_hook); nacl_thread_parking_inited = 1; } GC_ASSERT(nacl_num_gc_threads <= MAX_NACL_GC_THREADS); @@ -942,6 +956,7 @@ int GC_segment_is_thread_stack(ptr_t lo, ptr_t hi) /* Return the number of processors, or i<= 0 if it can't be determined. */ int GC_get_nprocs() { +#ifndef NACL /* Should be "return sysconf(_SC_NPROCESSORS_ONLN);" but that */ /* appears to be buggy in many cases. */ /* We look for lines "cpu" in /proc/stat. */ @@ -971,6 +986,9 @@ int GC_get_nprocs() } close(f); return result; +#else /* NACL */ + return sysconf(_SC_NPROCESSORS_ONLN); +#endif } #endif /* GC_LINUX_THREADS */ @@ -1362,12 +1380,10 @@ int WRAP_FUNC(pthread_join)(pthread_t thread, void **retval) } #ifdef NACL -/* Native Client doesn't support pthread cleanup functions, */ -/* so wrap pthread_exit and manually cleanup the thread. */ +/* TODO: remove, NaCl glibc now supports pthread cleanup functions. */ void WRAP_FUNC(pthread_exit)(void *status) { - GC_thread_exit_proc(0); REAL_FUNC(pthread_exit)(status); } #endif diff --git a/man/mono.1 b/man/mono.1 index 1afc37ea670..318c0586d0f 100644 --- a/man/mono.1 +++ b/man/mono.1 @@ -1176,6 +1176,11 @@ are allocated (clear-at-gc). The consistency check ensures that there are no major to minor references that are not on the remembered sets. .TP +\fBmod-union-consistency-check\fR +Checks that the mod-union cardtable is consistent before each +finishing major collection pause. This check is only applicable to +concurrent major collectors. +.TP \fBcheck-mark-bits\fR Checks that mark bits in the major heap are consistent at the end of each major collection. Consistent mark bits mean that if an object is diff --git a/mcs/class/Makefile b/mcs/class/Makefile index b36690dc867..997a6202711 100644 --- a/mcs/class/Makefile +++ b/mcs/class/Makefile @@ -246,6 +246,7 @@ net_4_5_dirs := \ System.Net.Http.Formatting \ System.Web.Http \ System.Web.Http.SelfHost \ + System.Web.Http.WebHost \ EntityFramework \ EntityFramework.SqlServer \ Mono.CodeContracts \ diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UpDownBase.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UpDownBase.cs index cad50f13ed2..34cd4095982 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UpDownBase.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UpDownBase.cs @@ -369,8 +369,8 @@ namespace System.Windows.Forms txtView.Dock = DockStyle.Fill; SuspendLayout (); - Controls.Add (txtView); Controls.Add (spnSpinner); + Controls.Add (txtView); ResumeLayout (); Height = PreferredHeight; diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildItem.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildItem.cs index 3421813ce8d..8d67fec080c 100644 --- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildItem.cs +++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildItem.cs @@ -26,6 +26,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. using System; +using System.Linq; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; @@ -50,6 +51,9 @@ namespace Microsoft.Build.BuildEngine { //string recursiveDir; IDictionary evaluatedMetadata; IDictionary unevaluatedMetadata; + bool isDynamic; + bool keepDuplicates = true; + string removeMetadata, keepMetadata; BuildItem () { @@ -90,11 +94,49 @@ namespace Microsoft.Build.BuildEngine { this.parent_item_group = parentItemGroup; this.itemElement = itemElement; - - if (Include == String.Empty) - throw new InvalidProjectFileException (String.Format ("The required attribute \"Include\" is missing from element <{0}>.", Name)); + isDynamic = parentItemGroup.IsDynamic; + + if (IsDynamic) { + if (!string.IsNullOrEmpty (Remove)) { + if (!string.IsNullOrEmpty (Include) || !string.IsNullOrEmpty (Exclude)) + throw new InvalidProjectFileException (string.Format ("The attribute \"Remove\" in element <{0}> is unrecognized.", Name)); + if (itemElement.HasChildNodes) + throw new InvalidProjectFileException ("Children are not allowed below an item remove element."); + } + if (string.IsNullOrEmpty (Include) && !string.IsNullOrEmpty (Exclude)) + throw new InvalidProjectFileException (string.Format ("The attribute \"Exclude\" in element <{0}> is unrecognized.", Name)); + } else { + if (string.IsNullOrEmpty (Include)) + throw new InvalidProjectFileException (string.Format ("The required attribute \"Include\" is missing from element <{0}>.", Name)); + if (!string.IsNullOrEmpty (Remove)) + throw new InvalidProjectFileException (string.Format ("The attribute \"Remove\" in element <{0}> is unrecognized.", Name)); + } + + foreach (XmlAttribute attr in itemElement.Attributes) { + if (attr.Name == "Include" || attr.Name == "Exclude" || attr.Name == "Condition") + continue; + if (!IsDynamic) + throw new InvalidProjectFileException (string.Format ("The attribute \"{0}\" in element <{1}> is unrecognized.", attr.Name, Name)); + + switch (attr.Name) { + case "Remove": + Remove = attr.Value; + break; + case "KeepDuplicates": + KeepDuplicates = bool.Parse (attr.Value); + break; + case "RemoveMetadata": + removeMetadata = attr.Value; + break; + case "KeepMetadata": + keepMetadata = attr.Value; + break; + default: + throw new InvalidProjectFileException (string.Format ("The attribute \"{0}\" in element <{1}> is unrecognized.", attr.Name, Name)); + } + } } - + BuildItem (BuildItem parent) { isImported = parent.isImported; @@ -254,21 +296,39 @@ namespace Microsoft.Build.BuildEngine { this.finalItemSpec = MSBuildUtils.Unescape (Include); return; } - + foreach (XmlNode xn in itemElement.ChildNodes) { XmlElement xe = xn as XmlElement; if (xe != null && ConditionParser.ParseAndEvaluate (xe.GetAttribute ("Condition"), project)) AddMetadata (xe.Name, xe.InnerText); } + if (IsDynamic) { + if (!evaluatedTo) + return; + + if (!string.IsNullOrEmpty (Remove)) { + RemoveItems (project); + return; + } + + if (string.IsNullOrEmpty (Include)) { + UpdateMetadata (project); + return; + } + } + DirectoryScanner directoryScanner; Expression includeExpr, excludeExpr; ITaskItem[] includes, excludes; + var options = IsDynamic ? + ParseOptions.AllowItemsMetadataAndSplit : ParseOptions.AllowItemsNoMetadataAndSplit; + includeExpr = new Expression (); - includeExpr.Parse (Include, ParseOptions.AllowItemsNoMetadataAndSplit); + includeExpr.Parse (Include, options); excludeExpr = new Expression (); - excludeExpr.Parse (Exclude, ParseOptions.AllowItemsNoMetadataAndSplit); + excludeExpr.Parse (Exclude, options); includes = (ITaskItem[]) includeExpr.ConvertTo (project, typeof (ITaskItem[]), ExpressionOptions.ExpandItemRefs); @@ -293,9 +353,123 @@ namespace Microsoft.Build.BuildEngine { foreach (ITaskItem matchedItem in directoryScanner.MatchedItems) AddEvaluatedItem (project, evaluatedTo, matchedItem); } - + + bool CheckCondition (Project project) + { + if (parent_item_group != null && !ConditionParser.ParseAndEvaluate (parent_item_group.Condition, project)) + return false; + if (parent_item != null && !parent_item.CheckCondition (project)) + return false; + return ConditionParser.ParseAndEvaluate (Condition, project); + } + + void UpdateMetadata (Project project) + { + BuildItemGroup group; + if (!project.TryGetEvaluatedItemByNameBatched (Name, out group)) + return; + + foreach (BuildItem item in group) { + if (!item.CheckCondition (project)) + continue; + + foreach (string name in evaluatedMetadata.Keys) { + item.SetMetadata (name, (string)evaluatedMetadata [name]); + } + + AddAndRemoveMetadata (project, item); + } + } + + void AddAndRemoveMetadata (Project project, BuildItem item) + { + if (!string.IsNullOrEmpty (removeMetadata)) { + var removeExpr = new Expression (); + removeExpr.Parse (removeMetadata, ParseOptions.AllowItemsNoMetadataAndSplit); + + var removeSpec = (string[]) removeExpr.ConvertTo ( + project, typeof (string[]), ExpressionOptions.ExpandItemRefs); + + foreach (var remove in removeSpec) { + item.DeleteMetadata (remove); + } + } + + if (!string.IsNullOrEmpty (keepMetadata)) { + var keepExpr = new Expression (); + keepExpr.Parse (keepMetadata, ParseOptions.AllowItemsNoMetadataAndSplit); + + var keepSpec = (string[]) keepExpr.ConvertTo ( + project, typeof (string[]), ExpressionOptions.ExpandItemRefs); + + var metadataNames = new string [item.evaluatedMetadata.Count]; + item.evaluatedMetadata.Keys.CopyTo (metadataNames, 0); + + foreach (string name in metadataNames) { + if (!keepSpec.Contains (name)) + item.DeleteMetadata (name); + } + } + } + + void RemoveItems (Project project) + { + BuildItemGroup group; + if (!project.TryGetEvaluatedItemByNameBatched (Name, out group)) + return; + + var removeExpr = new Expression (); + removeExpr.Parse (Remove, ParseOptions.AllowItemsNoMetadataAndSplit); + + var removes = (ITaskItem[]) removeExpr.ConvertTo ( + project, typeof (ITaskItem[]), ExpressionOptions.ExpandItemRefs); + + var directoryScanner = new DirectoryScanner (); + + directoryScanner.Includes = removes; + + if (project.FullFileName != String.Empty) + directoryScanner.BaseDirectory = new DirectoryInfo (Path.GetDirectoryName (project.FullFileName)); + else + directoryScanner.BaseDirectory = new DirectoryInfo (Directory.GetCurrentDirectory ()); + + directoryScanner.Scan (); + + foreach (ITaskItem matchedItem in directoryScanner.MatchedItems) { + group.RemoveItem (matchedItem); + } + } + + bool ContainsItem (Project project, ITaskItem taskItem) + { + BuildItemGroup group; + if (!project.TryGetEvaluatedItemByNameBatched (Name, out group)) + return false; + + var item = group.FindItem (taskItem); + if (item == null) + return false; + + foreach (string metadataName in evaluatedMetadata.Keys) { + string metadataValue = (string)evaluatedMetadata [metadataName]; + if (!metadataValue.Equals (item.evaluatedMetadata [metadataName])) + return false; + } + + foreach (string metadataName in item.evaluatedMetadata.Keys) { + string metadataValue = (string)item.evaluatedMetadata [metadataName]; + if (!metadataValue.Equals (evaluatedMetadata [metadataName])) + return false; + } + + return true; + } + void AddEvaluatedItem (Project project, bool evaluatedTo, ITaskItem taskitem) { + if (IsDynamic && evaluatedTo && !KeepDuplicates && ContainsItem (project, taskitem)) + return; + BuildItemGroup big; BuildItem bi = new BuildItem (this); bi.finalItemSpec = taskitem.ItemSpec; @@ -328,6 +502,9 @@ namespace Microsoft.Build.BuildEngine { } big.AddItem (bi); + + if (IsDynamic) + AddAndRemoveMetadata (project, bi); } // during item's eval phase, any item refs in this item, have either @@ -488,6 +665,20 @@ namespace Microsoft.Build.BuildEngine { } } + internal bool IsDynamic { + get { return isDynamic; } + } + + internal string Remove { + get; + private set; + } + + internal bool KeepDuplicates { + get { return keepDuplicates; } + private set { keepDuplicates = value; } + } + public bool IsImported { get { return isImported; } } @@ -522,6 +713,10 @@ namespace Microsoft.Build.BuildEngine { internal bool FromXml { get { return itemElement != null; } } + + internal XmlElement XmlElement { + get { return itemElement; } + } internal bool HasParentItem { get { return parent_item != null; } diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildItemGroup.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildItemGroup.cs index 444731a8cee..034ead032b8 100644 --- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildItemGroup.cs +++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildItemGroup.cs @@ -26,6 +26,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. using System; +using System.Linq; using System.Reflection; using System.Collections; using System.Collections.Generic; @@ -42,7 +43,8 @@ namespace Microsoft.Build.BuildEngine { GroupingCollection parentCollection; Project parentProject; bool read_only; - bool evaluated; + bool evaluated; + bool isDynamic; public BuildItemGroup () : this (null, null, null, false) @@ -55,12 +57,18 @@ namespace Microsoft.Build.BuildEngine { } internal BuildItemGroup (XmlElement xmlElement, Project project, ImportedProject importedProject, bool readOnly) + : this (xmlElement, project, importedProject, readOnly, false) + { + } + + internal BuildItemGroup (XmlElement xmlElement, Project project, ImportedProject importedProject, bool readOnly, bool dynamic) { this.buildItems = new List (); this.importedProject = importedProject; this.itemGroupElement = xmlElement; this.parentProject = project; this.read_only = readOnly; + this.isDynamic = dynamic; if (!FromXml) return; @@ -169,6 +177,24 @@ namespace Microsoft.Build.BuildEngine { RemoveItem (item); } + internal BuildItem FindItem (ITaskItem taskItem) + { + return buildItems.FirstOrDefault (i => i.FinalItemSpec == taskItem.ItemSpec); + } + + internal void RemoveItem (ITaskItem itemToRemove) + { + if (itemToRemove == null) + return; + + var item = FindItem (itemToRemove); + if (item == null) + return; + + item.Detach (); + buildItems.Remove (item); + } + public BuildItem[] ToArray () { return buildItems.ToArray (); @@ -239,7 +265,7 @@ namespace Microsoft.Build.BuildEngine { internal void Evaluate () { - if (evaluated) + if (!isDynamic && evaluated) return; foreach (BuildItem bi in buildItems) { if (bi.Condition == String.Empty) @@ -317,5 +343,11 @@ namespace Microsoft.Build.BuildEngine { return itemGroupElement; } } + + internal bool IsDynamic { + get { + return isDynamic; + } + } } } diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildTask.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildTask.cs index 97191e365d2..d0048815a18 100644 --- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildTask.cs +++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildTask.cs @@ -35,7 +35,7 @@ using Microsoft.Build.Framework; using Microsoft.Build.Utilities; namespace Microsoft.Build.BuildEngine { - public class BuildTask { + public class BuildTask : IBuildTask { ITaskHost hostObject; Target parentTarget; @@ -127,7 +127,7 @@ namespace Microsoft.Build.BuildEngine { continue; tempNames.Add (xmlAttribute.Name); } - + return tempNames.ToArray (); } @@ -156,7 +156,7 @@ namespace Microsoft.Build.BuildEngine { else taskElement.SetAttribute (parameterName, parameterValue); } - + void LogTaskStarted () { TaskStartedEventArgs tsea = new TaskStartedEventArgs ("Task started.", null, @@ -266,11 +266,29 @@ namespace Microsoft.Build.BuildEngine { get { return taskElement; } set { taskElement = value; } } - + [MonoTODO] public Type Type { get { return parentTarget.Project.TaskDatabase.GetTypeFromClassName (Name); } } + + public IEnumerable GetAttributes () + { + foreach (XmlAttribute attrib in TaskElement.Attributes) + yield return attrib.Value; + foreach (XmlNode xn in TaskElement.ChildNodes) { + XmlElement xe = xn as XmlElement; + if (xe == null) + continue; + + //FIXME: error on any other child + if (String.Compare (xe.LocalName, "Output", StringComparison.Ordinal) == 0) { + foreach (XmlAttribute attrib in xe.Attributes) + yield return attrib.Value; + } + } + } + } } diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildTaskItemGroup.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildTaskItemGroup.cs new file mode 100644 index 00000000000..9449cd8a35a --- /dev/null +++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildTaskItemGroup.cs @@ -0,0 +1,63 @@ +// +// BuildTaskItemGroup.cs +// +// Author: +// Martin Baulig +// +// Copyright (c) 2013 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 "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Xml; + +namespace Microsoft.Build.BuildEngine { + + internal class BuildTaskItemGroup : BuildItemGroup, IBuildTask { + + public bool ContinueOnError { + get; set; + } + + internal BuildTaskItemGroup (XmlElement element, Target target) + : base (element, target.Project, null, false, true) + { + } + + public bool Execute () + { + Evaluate (); + return true; + } + + public IEnumerable GetAttributes () + { + foreach (XmlAttribute attrib in XmlElement.Attributes) + yield return attrib.Value; + + foreach (BuildItem item in this) { + foreach (XmlAttribute attrib in item.XmlElement.Attributes) + yield return attrib.Value; + } + } + + } +} + diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildTaskPropertyGroup.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildTaskPropertyGroup.cs new file mode 100644 index 00000000000..4df2f780a90 --- /dev/null +++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildTaskPropertyGroup.cs @@ -0,0 +1,59 @@ +// +// BuildTaskPropertyGroup.cs +// +// Author: +// Martin Baulig +// +// Copyright (c) 2013 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 "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +using System; +using System.Collections.Generic; +using System.Xml; + +namespace Microsoft.Build.BuildEngine { + + internal class BuildTaskPropertyGroup : BuildPropertyGroup, IBuildTask { + + public bool ContinueOnError { + get; set; + } + + internal BuildTaskPropertyGroup (XmlElement element, Target target) + : base (element, target.Project, null, false) + { + } + + public bool Execute () + { + Evaluate (); + return true; + } + + public IEnumerable GetAttributes () + { + foreach (XmlAttribute attrib in XmlElement.Attributes) + yield return attrib.Value; + } + + } +} + diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConditionParser.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConditionParser.cs index d7f4ac5c80b..ec538abc29f 100644 --- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConditionParser.cs +++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConditionParser.cs @@ -89,6 +89,11 @@ namespace Microsoft.Build.BuildEngine { { return ParseBooleanAnd (); } + + public static string And (string a, string b) + { + return a + " and " + b; + } ConditionExpression ParseBooleanAnd () { diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/IBuildTask.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/IBuildTask.cs new file mode 100644 index 00000000000..aa182487b64 --- /dev/null +++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/IBuildTask.cs @@ -0,0 +1,44 @@ +// +// IBuildTask.cs +// +// Author: +// Martin Baulig +// +// Copyright (c) 2013 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 "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Collections.Generic; + +namespace Microsoft.Build.BuildEngine { + internal interface IBuildTask { + bool ContinueOnError { + get; set; + } + + string Condition { + get; set; + } + + bool Execute (); + + IEnumerable GetAttributes (); + } +} diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Target.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Target.cs index 378348c1f4a..430ea1daf73 100644 --- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Target.cs +++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Target.cs @@ -26,12 +26,14 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. using System; +using System.Text; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Xml; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; +using Mono.XBuild.Utilities; namespace Microsoft.Build.BuildEngine { public class Target : IEnumerable { @@ -44,7 +46,7 @@ namespace Microsoft.Build.BuildEngine { Project project; XmlElement targetElement; List onErrorElements; - List buildTasks; + List buildTasks; internal Target (XmlElement targetElement, Project project, ImportedProject importedProject) { @@ -62,7 +64,7 @@ namespace Microsoft.Build.BuildEngine { this.onErrorElements = new List (); this.buildState = BuildState.NotStarted; - this.buildTasks = new List (); + this.buildTasks = new List (); this.batchingImpl = new TargetBatchingImpl (project, this.targetElement); bool onErrorFound = false; @@ -77,8 +79,10 @@ namespace Microsoft.Build.BuildEngine { "The element must be last under element . Found element instead."); #if NET_3_5 else if (xe.Name == "ItemGroup") { - //don't blow up for ItemGroups inside Targets in >= 3.5 - // TODO: evaluate them (see https://bugzilla.xamarin.com/show_bug.cgi?id=1862 and test in TargetTest.cs ) + buildTasks.Add (new BuildTaskItemGroup (xe, this)); + continue; + } else if (xe.Name == "PropertyGroup") { + buildTasks.Add (new BuildTaskPropertyGroup (xe, this)); continue; } #endif @@ -379,7 +383,7 @@ namespace Microsoft.Build.BuildEngine { internal List AfterThisTargets { get; set; } #endif - internal List BuildTasks { + internal List BuildTasks { get { return buildTasks; } } diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TargetBatchingImpl.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TargetBatchingImpl.cs index 28ea4c8c69c..3873a93c498 100644 --- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TargetBatchingImpl.cs +++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TargetBatchingImpl.cs @@ -118,7 +118,7 @@ namespace Microsoft.Build.BuildEngine { for (int i = 0; i < target.BuildTasks.Count; i ++) { //FIXME: parsing attributes repeatedly - BuildTask bt = target.BuildTasks [i]; + IBuildTask bt = target.BuildTasks [i]; TaskBatchingImpl batchingImpl = new TaskBatchingImpl (project); bool task_result = batchingImpl.Build (bt, out executeOnErrors); diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TaskBatchingImpl.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TaskBatchingImpl.cs index 65ed711aed5..80e1d5272a1 100644 --- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TaskBatchingImpl.cs +++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TaskBatchingImpl.cs @@ -40,7 +40,7 @@ namespace Microsoft.Build.BuildEngine { { } - public bool Build (BuildTask buildTask, out bool executeOnErrors) + public bool Build (IBuildTask buildTask, out bool executeOnErrors) { executeOnErrors = false; try { @@ -68,7 +68,7 @@ namespace Microsoft.Build.BuildEngine { } } - bool Run (BuildTask buildTask, out bool executeOnErrors) + bool Run (IBuildTask buildTask, out bool executeOnErrors) { executeOnErrors = false; @@ -108,21 +108,10 @@ namespace Microsoft.Build.BuildEngine { // Parse task attributes to get list of referenced metadata and items // to determine batching // - void ParseTaskAttributes (BuildTask buildTask) + void ParseTaskAttributes (IBuildTask buildTask) { - foreach (XmlAttribute attrib in buildTask.TaskElement.Attributes) - ParseAttribute (attrib.Value); - - foreach (XmlNode xn in buildTask.TaskElement.ChildNodes) { - XmlElement xe = xn as XmlElement; - if (xe == null) - continue; - - //FIXME: error on any other child - if (String.Compare (xe.LocalName, "Output", StringComparison.Ordinal) == 0) { - foreach (XmlAttribute attrib in xe.Attributes) - ParseAttribute (attrib.Value); - } + foreach (var attr in buildTask.GetAttributes ()) { + ParseAttribute (attr); } } } diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.Engine.dll.sources b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.Engine.dll.sources index 41ed073a7ab..fa51fafd89f 100644 --- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.Engine.dll.sources +++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.Engine.dll.sources @@ -18,6 +18,8 @@ Microsoft.Build.BuildEngine/BuildPropertyGroupCollection.cs Microsoft.Build.BuildEngine/BuildPropertyGroup.cs Microsoft.Build.BuildEngine/BuildSettings.cs Microsoft.Build.BuildEngine/BuildTask.cs +Microsoft.Build.BuildEngine/BuildTaskItemGroup.cs +Microsoft.Build.BuildEngine/BuildTaskPropertyGroup.cs Microsoft.Build.BuildEngine/BuildWhen.cs Microsoft.Build.BuildEngine/ChangeType.cs Microsoft.Build.BuildEngine/ColorResetter.cs @@ -46,6 +48,7 @@ Microsoft.Build.BuildEngine/ImportCollection.cs Microsoft.Build.BuildEngine/ImportedProject.cs Microsoft.Build.BuildEngine/InternalLoggerException.cs Microsoft.Build.BuildEngine/InvalidProjectFileException.cs +Microsoft.Build.BuildEngine/IBuildTask.cs Microsoft.Build.BuildEngine/IReference.cs Microsoft.Build.BuildEngine/ItemReference.cs Microsoft.Build.BuildEngine/LogExtensions.cs diff --git a/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/BuildItemTest.cs b/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/BuildItemTest.cs index 36f5e52f9b0..e580d358ed0 100644 --- a/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/BuildItemTest.cs +++ b/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/BuildItemTest.cs @@ -95,6 +95,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { // Parameter "itemInclude" cannot have zero length. [Test] + [Category ("NotDotNet")] [ExpectedException (typeof (ArgumentException))] public void TestCtor6 () { diff --git a/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/BuildPropertyGroupTest.cs b/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/BuildPropertyGroupTest.cs index 528ea5f9a56..73df7340741 100644 --- a/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/BuildPropertyGroupTest.cs +++ b/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/BuildPropertyGroupTest.cs @@ -220,6 +220,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { } [Test] + [Category ("NotDotNet")] public void TestGetEnumerator1 () { BuildPropertyGroup bpg = new BuildPropertyGroup (); diff --git a/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/BuildPropertyTest.cs b/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/BuildPropertyTest.cs index 03f46be4183..f5f0472292b 100644 --- a/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/BuildPropertyTest.cs +++ b/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/BuildPropertyTest.cs @@ -349,6 +349,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { } [Test] + [Category ("NotDotNet")] public void TestValueXml () { BuildPropertyGroup [] bpgs = new BuildPropertyGroup [1]; diff --git a/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ConsoleLoggerTest.cs b/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ConsoleLoggerTest.cs index 258e4bb962d..aa0e69d8158 100755 --- a/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ConsoleLoggerTest.cs +++ b/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ConsoleLoggerTest.cs @@ -35,6 +35,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { [TestFixture] public class ConsoleLoggerTest { [Test] + [Category ("NotDotNet")] public void TestAssignment () { ConsoleLogger cl = new ConsoleLogger (); diff --git a/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/EngineTest.cs b/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/EngineTest.cs index d46108b8464..0a9edff4e5d 100755 --- a/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/EngineTest.cs +++ b/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/EngineTest.cs @@ -275,6 +275,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { } [Test] + [Category ("NotDotNet")] [ExpectedException (typeof (ArgumentException))] public void TestBuildProject1 () { @@ -305,6 +306,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { } [Test] + [Category ("NotDotNet")] [ExpectedException (typeof (ArgumentException))] public void TestBuildProjectNull1 () { @@ -313,6 +315,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { } [Test] + [Category ("NotDotNet")] [ExpectedException (typeof (ArgumentException))] public void TestBuildProjectNull2 () { diff --git a/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ProjectTest.cs b/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ProjectTest.cs index 0d07f2c2e04..8a78fad3c8e 100644 --- a/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ProjectTest.cs +++ b/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ProjectTest.cs @@ -1301,6 +1301,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { } [Test] + [Category ("NotDotNet")] public void TestBatchedMetadataRef1 () { //test for multiple items with same metadata also @@ -1341,6 +1342,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { } [Test] + [Category ("NotDotNet")] public void TestBatchedMetadataRef2 () { string projectString = @" @@ -1394,6 +1396,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { } [Test] + [Category ("NotDotNet")] public void TestBatchedMetadataRef3 () { string projectString = @" @@ -1429,6 +1432,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { } [Test] + [Category ("NotDotNet")] public void TestBatchedMetadataRef4 () { string projectString = @" @@ -1457,6 +1461,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { } [Test] + [Category ("NotDotNet")] public void TestBatchedMetadataRef5 () { string projectString = @" @@ -1492,6 +1497,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { } [Test] + [Category ("NotDotNet")] public void TestBatchedMetadataRefInOutput () { string projectString = @" @@ -1831,6 +1837,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { } [Test] + [Category ("NotDotNet")] public void TestMSBuildThisProperties () { Engine engine = new Engine (Consts.BinPath); @@ -2005,6 +2012,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { } [Test] + [Category ("NotDotNet")] public void TestRequiredTask_TaskItemArray1 () { Project p = CheckProjectForRequiredTests ("RequiredTestTask_TaskItems", "@(NonExistant)", @@ -2016,6 +2024,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { } [Test] + [Category ("NotDotNet")] public void TestRequiredTask_TaskItemArray2 () { Project p = CheckProjectForRequiredTests ("RequiredTestTask_TaskItems", "$(NonExistant)", @@ -2027,6 +2036,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { } [Test] + [Category ("NotDotNet")] public void TestRequiredTask_TaskItemArray3 () { Project p = CheckProjectForRequiredTests ("RequiredTestTask_IntArray", "$(NonExistant)", @@ -2038,6 +2048,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { } [Test] + [Category ("NotDotNet")] public void TestRequiredTask_TaskItemArray4 () { Project p = CheckProjectForRequiredTests ("RequiredTestTask_IntArray", "%(NonExistant.Md)", true, "Build failed", "count: 0"); @@ -2048,6 +2059,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { } [Test] + [Category ("NotDotNet")] public void TestRequiredTask_TaskItemArray5 () { // with extra space in prop value Project p = CheckProjectForRequiredTests ("RequiredTestTask_IntArray", " %(NonExistant.Md)", diff --git a/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/TargetTest.cs b/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/TargetTest.cs index 9a40fd342a8..03edf3db2b0 100644 --- a/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/TargetTest.cs +++ b/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/TargetTest.cs @@ -26,14 +26,15 @@ // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - using System; using System.Collections; using Microsoft.Build.BuildEngine; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; +using MonoTests.Microsoft.Build.Tasks; using NUnit.Framework; using System.IO; +using System.Xml; namespace MonoTests.Microsoft.Build.BuildEngine { [TestFixture] @@ -349,38 +350,87 @@ namespace MonoTests.Microsoft.Build.BuildEngine { } #if NET_3_5 - [Test] - public void BuildProjectWithItemGroupInsideTarget() + bool Build (string projectXml, ILogger logger) { - ItemGroupInsideATarget (); + if (Environment.OSVersion.Platform == PlatformID.Win32NT) { + var reader = new StringReader (projectXml); + var xml = XmlReader.Create (reader); + return BuildOnWindows (xml, logger); + } else { + return BuildOnLinux (projectXml, logger); + } } - private MonoTests.Microsoft.Build.Tasks.TestMessageLogger ItemGroupInsideATarget() { - var engine = new Engine(Consts.BinPath); - var project = engine.CreateNewProject(); - var projectXml = GetProjectXmlWithItemGroupInsideATarget (); - project.LoadXml(projectXml); + bool BuildOnWindows (XmlReader reader, ILogger logger) + { + var type = Type.GetType ("Microsoft.Build.Evaluation.ProjectCollection, Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"); + + var prop = type.GetProperty ("GlobalProjectCollection"); + var coll = prop.GetValue (null); + + var loadProject = coll.GetType ().GetMethod ( + "LoadProject", new Type[] { typeof (XmlReader), typeof (string) }); + var proj = loadProject.Invoke (coll, new object[] { reader, "4.0" }); + + var build = proj.GetType ().GetMethod ("Build", new Type[] { typeof (string), typeof (ILogger[]) }); + var ret = (bool)build.Invoke (proj, new object[] { "Main", new ILogger[] { logger }}); + return ret; + } - MonoTests.Microsoft.Build.Tasks.TestMessageLogger logger = - new MonoTests.Microsoft.Build.Tasks.TestMessageLogger (); + bool BuildOnLinux (string projectXml, ILogger logger) + { + var engine = new Engine (Consts.BinPath); + var project = engine.CreateNewProject (); + project.LoadXml (projectXml); + engine.RegisterLogger (logger); + + return project.Build ("Main"); + } - bool result = project.Build("Main"); - if (!result) - { + TestMessageLogger CreateLogger (string projectXml) + { + var logger = new TestMessageLogger (); + var result = Build (projectXml, logger); + + if (!result) { logger.DumpMessages (); - Assert.Fail("Build failed"); + Assert.Fail ("Build failed"); } return logger; } - private string GetProjectXmlWithItemGroupInsideATarget () + void ItemGroupInsideTarget (string xml, params string[] messages) + { + var logger = CreateLogger (xml); + + try + { + Assert.AreEqual(messages.Length, logger.NormalMessageCount, "Expected number of messages"); + for (int i = 0; i < messages.Length; i++) + logger.CheckLoggedMessageHead (messages [i], i.ToString ()); + Assert.AreEqual(0, logger.NormalMessageCount, "Extra messages found"); + + Assert.AreEqual(1, logger.TargetStarted, "TargetStarted count"); + Assert.AreEqual(1, logger.TargetFinished, "TargetFinished count"); + Assert.AreEqual(messages.Length, logger.TaskStarted, "TaskStarted count"); + Assert.AreEqual(messages.Length, logger.TaskFinished, "TaskFinished count"); + } + catch (AssertionException) + { + logger.DumpMessages(); + throw; + } + } + + [Test] + public void BuildProjectWithItemGroupInsideTarget () { - return + ItemGroupInsideTarget ( @" - + @@ -390,35 +440,258 @@ namespace MonoTests.Microsoft.Build.BuildEngine { - "; + ", "apple", "apricot", "raspberry"); } + + [Test] + public void BuildProjectWithItemGroupInsideTarget2 () + { + ItemGroupInsideTarget ( + @" + + + Foo + + + + Bar + + + + + $(Foo);Hello + + + + + + + ", "1;2", "Foo", "Bar;Hello"); + } + [Test] - [Category ("NotWorking")] //https://bugzilla.xamarin.com/show_bug.cgi?id=1862 - public void BuildProjectOutputWithItemGroupInsideTarget() + public void BuildProjectWithPropertyGroupInsideTarget () { - var logger = ItemGroupInsideATarget (); + ItemGroupInsideTarget ( + @" + + Foo + Bar + - try - { - Assert.AreEqual(3, logger.NormalMessageCount, "Expected number of messages"); - logger.CheckLoggedMessageHead("apple", "A1"); - logger.CheckLoggedMessageHead("apricot", "A2"); - logger.CheckLoggedMessageHead("raspberry", "A3"); - Assert.AreEqual(0, logger.NormalMessageCount, "Extra messages found"); + + + + $(B) + + + + ", "Foo", "Bar"); + } - Assert.AreEqual(1, logger.TargetStarted, "TargetStarted count"); - Assert.AreEqual(1, logger.TargetFinished, "TargetFinished count"); - Assert.AreEqual(3, logger.TaskStarted, "TaskStarted count"); - Assert.AreEqual(3, logger.TaskFinished, "TaskFinished count"); + [Test] + public void BuildProjectWithPropertyGroupInsideTarget2 () + { + ItemGroupInsideTarget ( + @" + + Foo + Bar + - } - catch (AssertionException) - { - logger.DumpMessages(); - throw; - } + + + + False + + + $(B) + + + + + Equal + + + + ", "Foo", "Bar", "Bar", "Equal"); } + + [Test] + public void ItemGroupInsideTarget_ModifyMetadata () + { + ItemGroupInsideTarget ( + @" + + + Mono + + + Mono + + + Root + + + + + + + Monkey + + + + + + ", "Server1 : Monkey", "Server2 : Monkey", "Server3 : Root"); + } + + [Test] + public void ItemGroupInsideTarget_RemoveItem () + { + ItemGroupInsideTarget ( + @" + + + + + + + + + + + + ", "A;C;D"); + } + + [Test] + public void ItemGroupInsideTarget_DontKeepDuplicates () + { + ItemGroupInsideTarget ( + @" + + + + World + + + Boston + + + + + + + Boston + + + + + + ", "A;B;C;D;B;C"); + } + + [Test] + public void ItemGroupInsideTarget_RemoveMetadata () + { + ItemGroupInsideTarget ( + @" + + + + World + + + Boston + + + Monkey + + + + Hello + + + + + + + Monkey + + + + + + ", "E"); + } + + [Test] + public void ItemGroupInsideTarget_RemoveMetadata2 () + { + ItemGroupInsideTarget ( + @" + + + + World + + + Boston + + + Monkey + + + + Hello + + + + + + + Monkey + + + + + + ", "E"); + } + + [Test] + public void ItemGroupInsideTarget_KeepMetadata () + { + ItemGroupInsideTarget ( + @" + + + + World + + + Boston + + + Monkey + + + + + + + + Monkey + + + + + + ", "D"); + } + #endif [Test] @@ -542,6 +815,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { #if NET_4_0 [Test] + [Category ("NotDotNet")] public void TestBeforeAndAfterTargets () { Engine engine; diff --git a/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/UsingTaskTest.cs b/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/UsingTaskTest.cs index 4c62d4145cb..82d5e300910 100644 --- a/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/UsingTaskTest.cs +++ b/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/UsingTaskTest.cs @@ -202,6 +202,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { } [Test] + [Category ("NotDotNet")] public void TestDuplicate1 () { string documentString = @" @@ -294,6 +295,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { } [Test] + [Category ("NotDotNet")] public void TestLazyLoad2 () { string documentString = @" diff --git a/mcs/class/Microsoft.Build.Engine/Test/various/Conditions.cs b/mcs/class/Microsoft.Build.Engine/Test/various/Conditions.cs index d3954a2f322..51c3da6cfbf 100644 --- a/mcs/class/Microsoft.Build.Engine/Test/various/Conditions.cs +++ b/mcs/class/Microsoft.Build.Engine/Test/various/Conditions.cs @@ -284,6 +284,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various { } [Test] + [Category ("NotDotNet")] public void TestCondition10 () { Engine engine = new Engine (Consts.BinPath); diff --git a/mcs/class/Microsoft.Build.Engine/Test/various/EvaluationOrder.cs b/mcs/class/Microsoft.Build.Engine/Test/various/EvaluationOrder.cs index 66968658e8a..77b45eb5bc0 100644 --- a/mcs/class/Microsoft.Build.Engine/Test/various/EvaluationOrder.cs +++ b/mcs/class/Microsoft.Build.Engine/Test/various/EvaluationOrder.cs @@ -233,6 +233,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various { } [Test] + [Category ("NotDotNet")] public void TestImportOrder1 () { Engine engine = new Engine (Consts.BinPath); @@ -255,6 +256,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various { } [Test] + [Category ("NotDotNet")] [ExpectedException (typeof (InvalidProjectFileException))] public void TestImportOrder2 () { @@ -326,6 +328,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various { } [Test] + [Category ("NotDotNet")] public void TestImportOrder5 () { Engine engine = new Engine (Consts.BinPath); @@ -348,6 +351,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various { } [Test] + [Category ("NotDotNet")] public void TestImportOrder6 () { Engine engine = new Engine (Consts.BinPath); @@ -370,6 +374,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various { } [Test] + [Category ("NotDotNet")] public void TestImportOrder7 () { Engine engine = new Engine (Consts.BinPath); diff --git a/mcs/class/Microsoft.Build.Engine/Test/various/Items.cs b/mcs/class/Microsoft.Build.Engine/Test/various/Items.cs index 5f6863be075..ee93c4b932d 100755 --- a/mcs/class/Microsoft.Build.Engine/Test/various/Items.cs +++ b/mcs/class/Microsoft.Build.Engine/Test/various/Items.cs @@ -718,6 +718,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various { } [Test] + [Category ("NotDotNet")] public void TestEmptyItemsWithBatching () { string project_xml = @" @@ -799,6 +800,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various { } [Test] + [Category ("NotDotNet")] public void TestItemsInTarget1 () { Engine engine = new Engine (Consts.BinPath); @@ -891,6 +893,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various { } [Test] + [Category ("NotDotNet")] public void TestItemsInTarget3 () { Engine engine = new Engine (Consts.BinPath); @@ -934,6 +937,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various { } [Test] + [Category ("NotDotNet")] //Test with ITaskItem[] public void TestItemsInTarget3a () { @@ -982,6 +986,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various { } [Test] + [Category ("NotDotNet")] //Test with string[] public void TestItemsInTarget3b () { @@ -1024,6 +1029,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various { } [Test] + [Category ("NotDotNet")] //Test with string public void TestItemsInTarget3c () { @@ -1131,6 +1137,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various { } [Test] + [Category ("NotDotNet")] public void TestSingleTaskItem1 () { Project proj = BuildProjectForSingleTaskItem ("$(D)$(C)"); @@ -1138,6 +1145,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various { } [Test] + [Category ("NotDotNet")] public void TestSingleTaskItem2 () { Project proj = BuildProjectForSingleTaskItem ("@(Item1)"); @@ -1145,6 +1153,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various { } [Test] + [Category ("NotDotNet")] public void TestSingleTaskItem3 () { Project proj = BuildProjectForSingleTaskItem ("$(A).foo"); @@ -1152,6 +1161,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various { } [Test] + [Category ("NotDotNet")] public void TestSingleTaskItem4 () { Project proj = BuildProjectForSingleTaskItem ("$(C)"); diff --git a/mcs/class/Microsoft.Build.Engine/Test/various/Properties.cs b/mcs/class/Microsoft.Build.Engine/Test/various/Properties.cs index f5c6bdf307f..70b14ecf9a8 100644 --- a/mcs/class/Microsoft.Build.Engine/Test/various/Properties.cs +++ b/mcs/class/Microsoft.Build.Engine/Test/various/Properties.cs @@ -55,6 +55,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various { } [Test] + [Category ("NotDotNet")] public void TestProperties2 () { Engine engine = new Engine (Consts.BinPath); diff --git a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/CustomAttributeDataMirror.cs b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/CustomAttributeDataMirror.cs index d1ab7e68ce0..8003473c783 100644 --- a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/CustomAttributeDataMirror.cs +++ b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/CustomAttributeDataMirror.cs @@ -119,16 +119,20 @@ namespace Mono.Debugger.Soft { val = CreateArg (vm, arg.value); - if (arg.is_property) { - foreach (var prop in ctor.DeclaringType.GetProperties ()) { - if (prop.Id == arg.id) - named_args [j] = new CustomAttributeNamedArgumentMirror (prop, null, val); - } - } else { - foreach (var field in ctor.DeclaringType.GetFields ()) { - if (field.Id == arg.id) - named_args [j] = new CustomAttributeNamedArgumentMirror (null, field, val); + TypeMirror t = ctor.DeclaringType; + while (named_args [j] == null && t != null) { + if (arg.is_property) { + foreach (var prop in t.GetProperties ()) { + if (prop.Id == arg.id) + named_args [j] = new CustomAttributeNamedArgumentMirror (prop, null, val); + } + } else { + foreach (var field in t.GetFields ()) { + if (field.Id == arg.id) + named_args [j] = new CustomAttributeNamedArgumentMirror (null, field, val); + } } + t = t.BaseType; } if (named_args [j] == null) throw new NotImplementedException (); diff --git a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/MethodMirror.cs b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/MethodMirror.cs index a7a698dfdc3..ac97cb02fb4 100644 --- a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/MethodMirror.cs +++ b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/MethodMirror.cs @@ -240,13 +240,13 @@ namespace Mono.Debugger.Soft public LocalVariable[] GetLocals () { if (locals == null) { - LocalsInfo li = new LocalsInfo (); try { li = vm.conn.Method_GetLocalsInfo (id); } catch (CommandException) { - throw new ArgumentException ("Method doesn't have a body."); + throw new AbsentInformationException (); } + // Add the arguments as well var pi = vm.conn.Method_GetParamInfo (id); diff --git a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs index 61c284dfcfc..d6a2a7896fc 100644 --- a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs +++ b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs @@ -681,9 +681,9 @@ namespace Mono.Debugger.Soft } } - internal class CommandException : Exception { + public class CommandException : Exception { - public CommandException (ErrorCode error_code) : base ("Debuggee returned error code " + error_code + ".") { + internal CommandException (ErrorCode error_code) : base ("Debuggee returned error code " + error_code + ".") { ErrorCode = error_code; } diff --git a/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs b/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs index 1b13d3bbb13..2208c579bf9 100644 --- a/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs +++ b/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs @@ -49,8 +49,17 @@ public static class Tests4 { } } +public class AAttribute : Attribute { + public int afield; +} + +public class BAttribute : AAttribute { + public int bfield; +} + [DebuggerDisplay ("Tests", Name="FOO", Target=typeof (int))] [DebuggerTypeProxy (typeof (Tests))] +[BAttribute (afield = 1, bfield = 2)] public class Tests2 { [DebuggerBrowsableAttribute (DebuggerBrowsableState.Collapsed)] public int field_j; diff --git a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs index ac458762d43..db35c63a773 100644 --- a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs +++ b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs @@ -1091,7 +1091,7 @@ public class DebuggerTests t = frame.Method.GetParameters ()[8].ParameterType; Assert.AreEqual ("Tests2", t.Name); var attrs = t.GetCustomAttributes (true); - Assert.AreEqual (2, attrs.Length); + Assert.AreEqual (3, attrs.Length); foreach (var attr in attrs) { if (attr.Constructor.DeclaringType.Name == "DebuggerDisplayAttribute") { Assert.AreEqual (1, attr.ConstructorArguments.Count); @@ -1106,6 +1106,10 @@ public class DebuggerTests Assert.AreEqual (1, attr.ConstructorArguments.Count); Assert.IsInstanceOfType (typeof (TypeMirror), attr.ConstructorArguments [0].Value); Assert.AreEqual ("Tests", (attr.ConstructorArguments [0].Value as TypeMirror).Name); + } else if (attr.Constructor.DeclaringType.Name == "BAttribute") { + Assert.AreEqual (2, attr.NamedArguments.Count); + Assert.AreEqual ("afield", attr.NamedArguments [0].Field.Name); + Assert.AreEqual ("bfield", attr.NamedArguments [1].Field.Name); } else { Assert.Fail (attr.Constructor.DeclaringType.Name); } diff --git a/mcs/class/Mono.Posix/Mono.Unix.Native/NativeConvert.cs b/mcs/class/Mono.Posix/Mono.Unix.Native/NativeConvert.cs index 7ac5a750f41..4c56a293d51 100644 --- a/mcs/class/Mono.Posix/Mono.Unix.Native/NativeConvert.cs +++ b/mcs/class/Mono.Posix/Mono.Unix.Native/NativeConvert.cs @@ -318,6 +318,22 @@ namespace Mono.Unix.Native { return fopen_mode; } + [DllImport (LIB, EntryPoint="Mono_Posix_FromStat")] + private static extern int FromStat (ref Stat source, IntPtr destination); + + public static bool TryCopy (ref Stat source, IntPtr destination) + { + return FromStat (ref source, destination) == 0; + } + + [DllImport (LIB, EntryPoint="Mono_Posix_ToStat")] + private static extern int ToStat (IntPtr source, out Stat destination); + + public static bool TryCopy (IntPtr source, out Stat destination) + { + return ToStat (source, out destination) == 0; + } + [DllImport (LIB, EntryPoint="Mono_Posix_FromStatvfs")] private static extern int FromStatvfs (ref Statvfs source, IntPtr destination); diff --git a/mcs/class/Mono.Posix/Mono.Unix.Native/NativeConvert.generated.cs b/mcs/class/Mono.Posix/Mono.Unix.Native/NativeConvert.generated.cs index be846a892c1..d9097f8d7a3 100644 --- a/mcs/class/Mono.Posix/Mono.Unix.Native/NativeConvert.generated.cs +++ b/mcs/class/Mono.Posix/Mono.Unix.Native/NativeConvert.generated.cs @@ -54,6 +54,38 @@ namespace Mono.Unix.Native { return rval; } + [DllImport (LIB, EntryPoint="Mono_Posix_FromAtFlags")] + private static extern int FromAtFlags (AtFlags value, out Int32 rval); + + public static bool TryFromAtFlags (AtFlags value, out Int32 rval) + { + return FromAtFlags (value, out rval) == 0; + } + + public static Int32 FromAtFlags (AtFlags value) + { + Int32 rval; + if (FromAtFlags (value, out rval) == -1) + ThrowArgumentException (value); + return rval; + } + + [DllImport (LIB, EntryPoint="Mono_Posix_ToAtFlags")] + private static extern int ToAtFlags (Int32 value, out AtFlags rval); + + public static bool TryToAtFlags (Int32 value, out AtFlags rval) + { + return ToAtFlags (value, out rval) == 0; + } + + public static AtFlags ToAtFlags (Int32 value) + { + AtFlags rval; + if (ToAtFlags (value, out rval) == -1) + ThrowArgumentException (value); + return rval; + } + [DllImport (LIB, EntryPoint="Mono_Posix_FromConfstrName")] private static extern int FromConfstrName (ConfstrName value, out Int32 rval); @@ -294,6 +326,22 @@ namespace Mono.Unix.Native { return ToFlock (source, out destination) == 0; } + [DllImport (LIB, EntryPoint="Mono_Posix_FromIovec")] + private static extern int FromIovec (ref Iovec source, IntPtr destination); + + public static bool TryCopy (ref Iovec source, IntPtr destination) + { + return FromIovec (ref source, destination) == 0; + } + + [DllImport (LIB, EntryPoint="Mono_Posix_ToIovec")] + private static extern int ToIovec (IntPtr source, out Iovec destination); + + public static bool TryCopy (IntPtr source, out Iovec destination) + { + return ToIovec (source, out destination) == 0; + } + [DllImport (LIB, EntryPoint="Mono_Posix_FromLockType")] private static extern int FromLockType (LockType value, out Int16 rval); @@ -790,22 +838,6 @@ namespace Mono.Unix.Native { return rval; } - [DllImport (LIB, EntryPoint="Mono_Posix_FromStat")] - private static extern int FromStat (ref Stat source, IntPtr destination); - - public static bool TryCopy (ref Stat source, IntPtr destination) - { - return FromStat (ref source, destination) == 0; - } - - [DllImport (LIB, EntryPoint="Mono_Posix_ToStat")] - private static extern int ToStat (IntPtr source, out Stat destination); - - public static bool TryCopy (IntPtr source, out Stat destination) - { - return ToStat (source, out destination) == 0; - } - [DllImport (LIB, EntryPoint="Mono_Posix_FromSysconfName")] private static extern int FromSysconfName (SysconfName value, out Int32 rval); diff --git a/mcs/class/Mono.Posix/Mono.Unix.Native/Syscall.cs b/mcs/class/Mono.Posix/Mono.Unix.Native/Syscall.cs index e5ef6c7a93b..27d241539d5 100644 --- a/mcs/class/Mono.Posix/Mono.Unix.Native/Syscall.cs +++ b/mcs/class/Mono.Posix/Mono.Unix.Native/Syscall.cs @@ -149,7 +149,19 @@ namespace Mono.Unix.Native { O_DIRECTORY = 0x00010000, O_DIRECT = 0x00004000, O_ASYNC = 0x00002000, - O_LARGEFILE = 0x00008000 + O_LARGEFILE = 0x00008000, + O_CLOEXEC = 0x00080000, + O_PATH = 0x00200000 + } + + [Map][Flags] + [CLSCompliant (false)] + public enum AtFlags : int { + AT_SYMLINK_NOFOLLOW = 0x00000100, + AT_REMOVEDIR = 0x00000200, + AT_SYMLINK_FOLLOW = 0x00000400, + AT_NO_AUTOMOUNT = 0x00000800, + AT_EMPTY_PATH = 0x00001000 } // mode_t @@ -808,7 +820,7 @@ namespace Mono.Unix.Native { } } - [Map ("struct stat")] + // Use manually written To/From methods to handle fields st_atime_nsec etc. public struct Stat #if NET_2_0 : IEquatable @@ -838,6 +850,39 @@ namespace Mono.Unix.Native { [time_t] public long st_atime; // time of last access [time_t] public long st_mtime; // time of last modification [time_t] public long st_ctime; // time of last status change + public long st_atime_nsec; // Timespec.tv_nsec partner to st_atime + public long st_mtime_nsec; // Timespec.tv_nsec partner to st_mtime + public long st_ctime_nsec; // Timespec.tv_nsec partner to st_ctime + + public Timespec st_atim { + get { + return new Timespec { tv_sec = st_atime, tv_nsec = st_atime_nsec }; + } + set { + st_atime = value.tv_sec; + st_atime_nsec = value.tv_nsec; + } + } + + public Timespec st_mtim { + get { + return new Timespec { tv_sec = st_mtime, tv_nsec = st_mtime_nsec }; + } + set { + st_mtime = value.tv_sec; + st_mtime_nsec = value.tv_nsec; + } + } + + public Timespec st_ctim { + get { + return new Timespec { tv_sec = st_ctime, tv_nsec = st_ctime_nsec }; + } + set { + st_ctime = value.tv_sec; + st_ctime_nsec = value.tv_nsec; + } + } public override int GetHashCode () { @@ -853,7 +898,10 @@ namespace Mono.Unix.Native { st_blocks.GetHashCode () ^ st_atime.GetHashCode () ^ st_mtime.GetHashCode () ^ - st_ctime.GetHashCode (); + st_ctime.GetHashCode () ^ + st_atime_nsec.GetHashCode () ^ + st_mtime_nsec.GetHashCode () ^ + st_ctime_nsec.GetHashCode (); } public override bool Equals (object obj) @@ -873,7 +921,10 @@ namespace Mono.Unix.Native { value.st_blocks == st_blocks && value.st_atime == st_atime && value.st_mtime == st_mtime && - value.st_ctime == st_ctime; + value.st_ctime == st_ctime && + value.st_atime_nsec == st_atime_nsec && + value.st_mtime_nsec == st_mtime_nsec && + value.st_ctime_nsec == st_ctime_nsec; } public bool Equals (Stat value) @@ -890,7 +941,10 @@ namespace Mono.Unix.Native { value.st_blocks == st_blocks && value.st_atime == st_atime && value.st_mtime == st_mtime && - value.st_ctime == st_ctime; + value.st_ctime == st_ctime && + value.st_atime_nsec == st_atime_nsec && + value.st_mtime_nsec == st_mtime_nsec && + value.st_ctime_nsec == st_ctime_nsec; } public static bool operator== (Stat lhs, Stat rhs) @@ -1137,6 +1191,14 @@ namespace Mono.Unix.Native { } } + [Map ("struct iovec")] + public struct Iovec + { + public IntPtr iov_base; // Starting address + [CLSCompliant (false)] + public ulong iov_len; // Number of bytes to transfer + } + [Flags][Map] public enum EpollFlags { EPOLL_CLOEXEC = 02000000, @@ -2005,6 +2067,9 @@ namespace Mono.Unix.Native { [DllImport (LIBC, SetLastError=true)] public static extern int dirfd (IntPtr dir); + + [DllImport (LIBC, SetLastError=true)] + public static extern IntPtr fdopendir (int fd); #endregion #region Declarations @@ -2068,6 +2133,40 @@ namespace Mono.Unix.Native { [DllImport (MPH, SetLastError=true, EntryPoint="Mono_Posix_Syscall_posix_fallocate")] public static extern int posix_fallocate (int fd, long offset, ulong len); + + [DllImport (LIBC, SetLastError=true, + EntryPoint="openat")] + private static extern int sys_openat (int dirfd, + [MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))] + string pathname, int flags); + + // openat(2) + // int openat(int dirfd, const char *pathname, int flags, mode_t mode); + [DllImport (LIBC, SetLastError=true, + EntryPoint="openat")] + private static extern int sys_openat (int dirfd, + [MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))] + string pathname, int flags, uint mode); + + public static int openat (int dirfd, string pathname, OpenFlags flags) + { + int _flags = NativeConvert.FromOpenFlags (flags); + return sys_openat (dirfd, pathname, _flags); + } + + public static int openat (int dirfd, string pathname, OpenFlags flags, FilePermissions mode) + { + int _flags = NativeConvert.FromOpenFlags (flags); + uint _mode = NativeConvert.FromFilePermissions (mode); + return sys_openat (dirfd, pathname, _flags, _mode); + } + + [DllImport (MPH, SetLastError=true, + EntryPoint="Mono_Posix_Syscall_get_at_fdcwd")] + private static extern int get_at_fdcwd (); + + public static readonly int AT_FDCWD = get_at_fdcwd (); + #endregion #region Declarations @@ -2664,6 +2763,12 @@ namespace Mono.Unix.Native { } } + [DllImport (LIBC, SetLastError=true)] + public static extern int renameat (int olddirfd, + [MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))] + string oldpath, int newdirfd, + [MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))] + string newpath); #endregion #region Declarations @@ -2673,6 +2778,16 @@ namespace Mono.Unix.Native { [DllImport (LIBC, SetLastError=true)] public static extern int mkstemp (StringBuilder template); + [DllImport (LIBC, SetLastError=true, EntryPoint="mkdtemp")] + private static extern IntPtr sys_mkdtemp (StringBuilder template); + + public static StringBuilder mkdtemp (StringBuilder template) + { + if (sys_mkdtemp (template) == IntPtr.Zero) + return null; + return template; + } + [DllImport (LIBC, SetLastError=true)] public static extern int ttyslot (); @@ -2980,6 +3095,100 @@ namespace Mono.Unix.Native { return sys_mkfifo (pathname, _mode); } + // fchmodat(2) + // int fchmodat(int dirfd, const char *pathname, mode_t mode, int flags); + [DllImport (LIBC, SetLastError=true, EntryPoint="fchmodat")] + private static extern int sys_fchmodat (int dirfd, + [MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))] + string pathname, uint mode, int flags); + + public static int fchmodat (int dirfd, string pathname, FilePermissions mode, AtFlags flags) + { + uint _mode = NativeConvert.FromFilePermissions (mode); + int _flags = NativeConvert.FromAtFlags (flags); + return sys_fchmodat (dirfd, pathname, _mode, _flags); + } + + [DllImport (MPH, SetLastError=true, + EntryPoint="Mono_Posix_Syscall_fstatat")] + public static extern int fstatat (int dirfd, + [MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))] + string file_name, out Stat buf, AtFlags flags); + + [DllImport (MPH, SetLastError=true, + EntryPoint="Mono_Posix_Syscall_get_utime_now")] + private static extern long get_utime_now (); + + [DllImport (MPH, SetLastError=true, + EntryPoint="Mono_Posix_Syscall_get_utime_omit")] + private static extern long get_utime_omit (); + + public static readonly long UTIME_NOW = get_utime_now (); + + public static readonly long UTIME_OMIT = get_utime_omit (); + + [DllImport (MPH, SetLastError=true, + EntryPoint="Mono_Posix_Syscall_futimens")] + private static extern int sys_futimens (int fd, Timespec[] times); + + public static int futimens (int fd, Timespec[] times) + { + if (times != null && times.Length != 2) { + SetLastError (Errno.EINVAL); + return -1; + } + return sys_futimens (fd, times); + } + + [DllImport (MPH, SetLastError=true, + EntryPoint="Mono_Posix_Syscall_utimensat")] + private static extern int sys_utimensat (int dirfd, + [MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))] + string pathname, Timespec[] times, int flags); + + public static int utimensat (int dirfd, string pathname, Timespec[] times, AtFlags flags) + { + if (times != null && times.Length != 2) { + SetLastError (Errno.EINVAL); + return -1; + } + int _flags = NativeConvert.FromAtFlags (flags); + return sys_utimensat (dirfd, pathname, times, _flags); + } + + // mkdirat(2) + // int mkdirat(int dirfd, const char *pathname, mode_t mode); + [DllImport (LIBC, SetLastError=true, EntryPoint="mkdirat")] + private static extern int sys_mkdirat (int dirfd, + [MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))] + string oldpath, uint mode); + + public static int mkdirat (int dirfd, string oldpath, FilePermissions mode) + { + uint _mode = NativeConvert.FromFilePermissions (mode); + return sys_mkdirat (dirfd, oldpath, _mode); + } + + // mknodat(2) + // int mknodat (int dirfd, const char *pathname, mode_t mode, dev_t dev); + [DllImport (MPH, SetLastError=true, + EntryPoint="Mono_Posix_Syscall_mknodat")] + public static extern int mknodat (int dirfd, + [MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))] + string pathname, FilePermissions mode, ulong dev); + + // mkfifoat(3) + // int mkfifoat(int dirfd, const char *pathname, mode_t mode); + [DllImport (LIBC, SetLastError=true, EntryPoint="mkfifoat")] + private static extern int sys_mkfifoat (int dirfd, + [MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))] + string pathname, uint mode); + + public static int mkfifoat (int dirfd, string pathname, FilePermissions mode) + { + uint _mode = NativeConvert.FromFilePermissions (mode); + return sys_mkfifoat (dirfd, pathname, _mode); + } #endregion #region Declarations @@ -3978,6 +4187,74 @@ namespace Mono.Unix.Native { swab ((IntPtr) from, (IntPtr) to, n); } + [DllImport (LIBC, SetLastError=true, EntryPoint="faccessat")] + private static extern int sys_faccessat (int dirfd, + [MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))] + string pathname, int mode, int flags); + + public static int faccessat (int dirfd, string pathname, AccessModes mode, AtFlags flags) + { + int _mode = NativeConvert.FromAccessModes (mode); + int _flags = NativeConvert.FromAtFlags (flags); + return sys_faccessat (dirfd, pathname, _mode, _flags); + } + + // fchownat(2) + // int fchownat(int dirfd, const char *path, uid_t owner, gid_t group, int flags); + [DllImport (LIBC, SetLastError=true, EntryPoint="fchownat")] + private static extern int sys_fchownat (int dirfd, + [MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))] + string pathname, uint owner, uint group, int flags); + + public static int fchownat (int dirfd, string pathname, uint owner, uint group, AtFlags flags) + { + int _flags = NativeConvert.FromAtFlags (flags); + return sys_fchownat (dirfd, pathname, owner, group, _flags); + } + + [DllImport (LIBC, SetLastError=true, EntryPoint="linkat")] + private static extern int sys_linkat (int olddirfd, + [MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))] + string oldpath, int newdirfd, + [MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))] + string newpath, int flags); + + public static int linkat (int olddirfd, string oldpath, int newdirfd, string newpath, AtFlags flags) + { + int _flags = NativeConvert.FromAtFlags (flags); + return sys_linkat (olddirfd, oldpath, newdirfd, newpath, _flags); + } + + // readlinkat(2) + // int readlinkat(int dirfd, const char *pathname, char *buf, size_t bufsize); + [DllImport (MPH, SetLastError=true, + EntryPoint="Mono_Posix_Syscall_readlinkat")] + public static extern int readlinkat (int dirfd, + [MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))] + string pathname, [Out] StringBuilder buf, ulong bufsiz); + + public static int readlinkat (int dirfd, string pathname, [Out] StringBuilder buf) + { + return readlinkat (dirfd, pathname, buf, (ulong) buf.Capacity); + } + + [DllImport (LIBC, SetLastError=true)] + public static extern int symlinkat ( + [MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))] + string oldpath, int dirfd, + [MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))] + string newpath); + + [DllImport (LIBC, SetLastError=true, EntryPoint="unlinkat")] + private static extern int sys_unlinkat (int dirfd, + [MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))] + string pathname, int flags); + + public static int unlinkat (int dirfd, string pathname, AtFlags flags) + { + int _flags = NativeConvert.FromAtFlags (flags); + return sys_unlinkat (dirfd, pathname, _flags); + } #endregion #region Declarations @@ -4002,6 +4279,56 @@ namespace Mono.Unix.Native { return sys_utime (filename, ref buf, 0); } #endregion + + #region Declarations + // + // -- COMPLETE + // + + // readv(2) + // ssize_t readv(int fd, const struct iovec *iov, int iovcnt); + [DllImport (MPH, SetLastError=true, + EntryPoint="Mono_Posix_Syscall_readv")] + private static extern long sys_readv (int fd, Iovec[] iov, int iovcnt); + + public static long readv (int fd, Iovec[] iov) + { + return sys_readv (fd, iov, iov.Length); + } + + // writev(2) + // ssize_t writev(int fd, const struct iovec *iov, int iovcnt); + [DllImport (MPH, SetLastError=true, + EntryPoint="Mono_Posix_Syscall_writev")] + private static extern long sys_writev (int fd, Iovec[] iov, int iovcnt); + + public static long writev (int fd, Iovec[] iov) + { + return sys_writev (fd, iov, iov.Length); + } + + // preadv(2) + // ssize_t preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset); + [DllImport (MPH, SetLastError=true, + EntryPoint="Mono_Posix_Syscall_preadv")] + private static extern long sys_preadv (int fd, Iovec[] iov, int iovcnt, long offset); + + public static long preadv (int fd, Iovec[] iov, long offset) + { + return sys_preadv (fd, iov, iov.Length, offset); + } + + // pwritev(2) + // ssize_t pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset); + [DllImport (MPH, SetLastError=true, + EntryPoint="Mono_Posix_Syscall_pwritev")] + private static extern long sys_pwritev (int fd, Iovec[] iov, int iovcnt, long offset); + + public static long pwritev (int fd, Iovec[] iov, long offset) + { + return sys_pwritev (fd, iov, iov.Length, offset); + } + #endregion } #endregion diff --git a/mcs/class/System.Core/System.Linq/Enumerable.cs b/mcs/class/System.Core/System.Linq/Enumerable.cs index 89547d0a059..71f392690a4 100644 --- a/mcs/class/System.Core/System.Linq/Enumerable.cs +++ b/mcs/class/System.Core/System.Linq/Enumerable.cs @@ -2885,7 +2885,7 @@ namespace System.Linq collection.CopyTo (array, 0); return array; } - + int pos = 0; array = EmptyOf.Instance; foreach (var element in source) { @@ -3105,6 +3105,11 @@ namespace System.Linq { Check.SourceAndPredicate (source, predicate); + // It cannot be IList because it may break on user implementation + var array = source as TSource[]; + if (array != null) + return CreateWhereIterator (array, predicate); + return CreateWhereIterator (source, predicate); } @@ -3115,14 +3120,27 @@ namespace System.Linq yield return element; } + static IEnumerable CreateWhereIterator (TSource[] source, Func predicate) + { + for (int i = 0; i < source.Length; ++i) { + var element = source [i]; + if (predicate (element)) + yield return element; + } + } + public static IEnumerable Where (this IEnumerable source, Func predicate) { Check.SourceAndPredicate (source, predicate); + var array = source as TSource[]; + if (array != null) + return CreateWhereIterator (array, predicate); + return CreateWhereIterator (source, predicate); } - static IEnumerable CreateWhereIterator (this IEnumerable source, Func predicate) + static IEnumerable CreateWhereIterator (IEnumerable source, Func predicate) { int counter = 0; foreach (TSource element in source) { @@ -3132,6 +3150,15 @@ namespace System.Linq } } + static IEnumerable CreateWhereIterator (TSource[] source, Func predicate) + { + for (int i = 0; i < source.Length; ++i) { + var element = source [i]; + if (predicate (element, i)) + yield return element; + } + } + #endregion internal static ReadOnlyCollection ToReadOnlyCollection (this IEnumerable source) diff --git a/mcs/class/System.Data/System.Data/DataRow.cs b/mcs/class/System.Data/System.Data/DataRow.cs index db4ad0c29c9..c3df83b3b0c 100644 --- a/mcs/class/System.Data/System.Data/DataRow.cs +++ b/mcs/class/System.Data/System.Data/DataRow.cs @@ -1365,7 +1365,7 @@ namespace System.Data { /// public void SetParentRow (DataRow parentRow, DataRelation relation) { - if (_table == null || parentRow.Table == null) + if (_table == null || (parentRow != null && parentRow.Table == null)) throw new RowNotInTableException ("This row has been removed from a table and does not have any data. BeginEdit() will allow creation of new data in this row."); if (parentRow != null && _table.DataSet != parentRow.Table.DataSet) @@ -1378,10 +1378,13 @@ namespace System.Data { BeginEdit(); IEnumerable relations; - if (relation == null) - relations = _table.ParentRelations; - else + if (relation != null) { + if (parentRow != null && relation.ParentColumns [0].Table != parentRow.Table) + throw new InvalidConstraintException (string.Format ("Parent belongs to table {0} but relation is for table {1}", parentRow.Table, relation.ParentColumns [0].Table)); relations = new DataRelation [] { relation }; + } else { + relations = _table.ParentRelations; + } foreach (DataRelation rel in relations) { DataColumn [] childCols = rel.ChildColumns; @@ -1390,7 +1393,7 @@ namespace System.Data { for (int i = 0; i < parentCols.Length; i++) { if (parentRow == null) { childCols [i].DataContainer [Proposed] = DBNull.Value; - } else { + } else if (parentCols [i].Table == parentRow.Table) { int defaultIdx = parentRow.IndexFromVersion (DataRowVersion.Default); childCols [i].DataContainer.CopyValue(parentCols [i].DataContainer, defaultIdx, Proposed); } diff --git a/mcs/class/System.Data/System.Data/DataTableCollection.cs b/mcs/class/System.Data/System.Data/DataTableCollection.cs index 21204a5d568..36e93707be5 100644 --- a/mcs/class/System.Data/System.Data/DataTableCollection.cs +++ b/mcs/class/System.Data/System.Data/DataTableCollection.cs @@ -274,9 +274,9 @@ namespace System.Data int count = 0, match = -1; for (int i = start; i < List.Count; i++) { String name2 = ((DataTable) List[i]).TableName; - if (String.Compare (name, name2, false) == 0) + if (String.Compare (name, name2, false, dataSet.Locale) == 0) return i; - if (String.Compare (name, name2, true) == 0) { + if (String.Compare (name, name2, true, dataSet.Locale) == 0) { match = i; count++; } diff --git a/mcs/class/System.Data/Test/System.Data.Common/DBDataPermissionAttributeTest.cs b/mcs/class/System.Data/Test/System.Data.Common/DBDataPermissionAttributeTest.cs index 7446bb4e626..2a9f7cdada4 100644 --- a/mcs/class/System.Data/Test/System.Data.Common/DBDataPermissionAttributeTest.cs +++ b/mcs/class/System.Data/Test/System.Data.Common/DBDataPermissionAttributeTest.cs @@ -51,6 +51,9 @@ namespace MonoTests.System.Data.Common } [TestFixture] +#if MOBILE + [Ignore ("CAS is not supported and parts will be linked away")] +#endif public class DBDataPermissionAttributeTest { [Test] diff --git a/mcs/class/System.Data/Test/System.Data.Common/DBDataPermissionTest.cs b/mcs/class/System.Data/Test/System.Data.Common/DBDataPermissionTest.cs index 9c2842619f4..ff8bd76f393 100644 --- a/mcs/class/System.Data/Test/System.Data.Common/DBDataPermissionTest.cs +++ b/mcs/class/System.Data/Test/System.Data.Common/DBDataPermissionTest.cs @@ -82,6 +82,9 @@ namespace MonoTests.System.Data.Common { } [TestFixture] +#if MOBILE + [Ignore ("CAS is not supported and parts will be linked away")] +#endif public class DBDataPermissionTest { private const string defaultConnectString = "Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind;"; diff --git a/mcs/class/System.Data/Test/System.Data.SqlClient/SqlClientPermissionAttributeTest.cs b/mcs/class/System.Data/Test/System.Data.SqlClient/SqlClientPermissionAttributeTest.cs index 4923e644ebc..f6d1336ae2e 100644 --- a/mcs/class/System.Data/Test/System.Data.SqlClient/SqlClientPermissionAttributeTest.cs +++ b/mcs/class/System.Data/Test/System.Data.SqlClient/SqlClientPermissionAttributeTest.cs @@ -37,6 +37,9 @@ using System.Security.Permissions; namespace MonoTests.System.Data.SqlClient { [TestFixture] +#if MOBILE + [Ignore ("CAS is not supported and parts will be linked away")] +#endif public class SqlClientPermissionAttributeTest { [Test] diff --git a/mcs/class/System.Data/Test/System.Data.SqlClient/SqlClientPermissionTest.cs b/mcs/class/System.Data/Test/System.Data.SqlClient/SqlClientPermissionTest.cs index da430b1ac2d..5d2602ae500 100644 --- a/mcs/class/System.Data/Test/System.Data.SqlClient/SqlClientPermissionTest.cs +++ b/mcs/class/System.Data/Test/System.Data.SqlClient/SqlClientPermissionTest.cs @@ -39,6 +39,9 @@ namespace MonoTests.System.Data.SqlClient { // NOTE: Most tests are are located in the base class, DBDataPermission [TestFixture] +#if MOBILE + [Ignore ("CAS is not supported and parts will be linked away")] +#endif public class SqlClientPermissionTest { private void Check (string msg, DBDataPermission dbdp, bool blank, bool unrestricted, int count) diff --git a/mcs/class/System.Data/Test/System.Data/DataRowTest.cs b/mcs/class/System.Data/Test/System.Data/DataRowTest.cs index d5bbcf4586a..5b2fd8ca9f3 100644 --- a/mcs/class/System.Data/Test/System.Data/DataRowTest.cs +++ b/mcs/class/System.Data/Test/System.Data/DataRowTest.cs @@ -1007,5 +1007,163 @@ namespace MonoTests.System.Data AssertEquals (DataRowState.Detached, dr.RowState); object o = dr ["col"]; } + + [Test] + public void SetParentRow_Null () + { + DataSet ds = new DataSet(); + + DataTable child = ds.Tables.Add("child"); + child.Columns.Add("column1"); + + DataRow r1 = child.NewRow(); + + r1.SetParentRow(null); + } + + [Test] + public void SetParentRow_DataInheritance () + { + var ds = new DataSet() ; + + var child = ds.Tables.Add("child") ; + + var childColumn1 = child.Columns.Add("column1"); + var childColumn2 = child.Columns.Add("column2"); + + var parent1 = ds.Tables.Add("parent1"); + var parent1Column1 = parent1.Columns.Add("column1"); + var parent1Column2 = parent1.Columns.Add("column2"); + + var parent2 = ds.Tables.Add("parent2"); + var parent2Column1 = parent2.Columns.Add("column1"); + var parent2Column2 = parent2.Columns.Add("column2"); + + var relation1 = ds.Relations.Add("parent1-child", parent1Column1, childColumn1); + ds.Relations.Add("parent2-child", parent2Column2, childColumn2); + + var childRow1 = child.NewRow(); + var parent1Row = parent1.NewRow(); + var parent2Row = parent2.NewRow(); + + parent1Row[parent1Column1] = "p1c1"; + parent1Row[parent1Column2] = "p1c2"; + parent2Row[parent2Column1] = "p2c1"; + parent2Row[parent2Column2] = "p2c2"; + + child.Rows.Add(childRow1); + parent1.Rows.Add(parent1Row); + parent2.Rows.Add(parent2Row); + + childRow1.SetParentRow(parent1Row); + AssertEquals ("p1c1", childRow1[childColumn1]); + AssertEquals (DBNull.Value, childRow1[childColumn2]); + + childRow1.SetParentRow(parent2Row); + AssertEquals ("p1c1", childRow1[childColumn1]); + AssertEquals ("p2c2", childRow1[childColumn2]); + + childRow1.SetParentRow(null); + AssertEquals (DBNull.Value, childRow1[childColumn1]); + AssertEquals (DBNull.Value, childRow1[childColumn2]); + + childRow1.SetParentRow(parent2Row); + AssertEquals (DBNull.Value, childRow1[childColumn1]); + AssertEquals ("p2c2", childRow1[childColumn2]); + } + + [Test] + public void SetParentRow_with_Relation () + { + var ds = new DataSet() ; + + var child = ds.Tables.Add("child") ; + + var childColumn1 = child.Columns.Add("column1"); + var childColumn2 = child.Columns.Add("column2"); + + var parent1 = ds.Tables.Add("parent1"); + var parent1Column1 = parent1.Columns.Add("column1"); + var parent1Column2 = parent1.Columns.Add("column2"); + + var parent2 = ds.Tables.Add("parent2"); + var parent2Column1 = parent2.Columns.Add("column1"); + var parent2Column2 = parent2.Columns.Add("column2"); + + var relation1 = ds.Relations.Add("parent1-child", parent1Column1, childColumn1) ; + var relation2 = ds.Relations.Add("parent2-child", parent2Column2, childColumn2) ; + + var childRow1 = child.NewRow(); + var parent1Row = parent1.NewRow(); + var parent2Row = parent2.NewRow(); + + parent1Row[parent1Column1] = "p1c1"; + parent1Row[parent1Column2] = "p1c2"; + parent2Row[parent2Column1] = "p2c1"; + parent2Row[parent2Column2] = "p2c2"; + + child.Rows.Add(childRow1); + parent1.Rows.Add(parent1Row); + parent2.Rows.Add(parent2Row); + + + childRow1.SetParentRow (null, relation2); + AssertEquals (DBNull.Value, childRow1[childColumn1]); + AssertEquals (DBNull.Value, childRow1[childColumn2]); + + try { + childRow1.SetParentRow(parent1Row, relation2); + Fail ("Must throw InvalidConstaintException"); + } catch (InvalidConstraintException e) { + } + AssertEquals (DBNull.Value, childRow1[childColumn1]); + AssertEquals (DBNull.Value, childRow1[childColumn2]); + + childRow1.SetParentRow(parent1Row, relation1); + AssertEquals ("p1c1", childRow1[childColumn1]); + AssertEquals (DBNull.Value, childRow1[childColumn2]); + + + childRow1.SetParentRow (null, relation2); + AssertEquals ("p1c1", childRow1[childColumn1]); + AssertEquals (DBNull.Value, childRow1[childColumn2]); + + childRow1.SetParentRow (null, relation1); + AssertEquals (DBNull.Value, childRow1[childColumn1]); + AssertEquals (DBNull.Value, childRow1[childColumn2]); + } + + [Test] + public void SetParent_missing_ParentRow () + { + var ds = new DataSet() ; + + var child = ds.Tables.Add("child") ; + + var childColumn1 = child.Columns.Add("column1"); + var childColumn2 = child.Columns.Add("column2"); + + var parent1 = ds.Tables.Add("parent1"); + var parentColumn1 = parent1.Columns.Add("column1"); + + var parent2 = ds.Tables.Add("parent2"); + var parentColumn2 = parent2.Columns.Add("column2"); + + ds.Relations.Add("parent1-child", parentColumn1, childColumn1); + ds.Relations.Add("parent2-child", parentColumn2, childColumn2); + + var childRow = child.NewRow(); + var parentRow = parent2.NewRow(); + + parentRow[parentColumn2] = "value"; + + child.Rows.Add(childRow); + parent2.Rows.Add(parentRow); + + childRow.SetParentRow(parentRow); + AssertEquals (DBNull.Value, childRow[childColumn1]); + AssertEquals ("value", childRow[childColumn2]); + } + } } diff --git a/mcs/class/System.Data/Test/System.Data/DataSetReadXmlTest.cs b/mcs/class/System.Data/Test/System.Data/DataSetReadXmlTest.cs index 6a63a23207e..a8d26bdae3b 100644 --- a/mcs/class/System.Data/Test/System.Data/DataSetReadXmlTest.cs +++ b/mcs/class/System.Data/Test/System.Data/DataSetReadXmlTest.cs @@ -801,13 +801,14 @@ namespace MonoTests.System.Data dataSet1.Tables.Add(table); table.LoadDataRow(new object[]{1, "One"}, false); table.LoadDataRow(new object[]{2, "Two"}, false); + string file = Path.Combine (Path.GetTempPath (), "schemas-test.xml"); try { - dataSet1.WriteXml("Test/System.Data/schemas/test.xml", XmlWriteMode.WriteSchema); + dataSet1.WriteXml (file, XmlWriteMode.WriteSchema); } catch (Exception ex) { Assert.Fail ("DSExtPropTest failed: WriteXml failed with : "+ex.Message); } finally { - File.Delete ("Test/System.Data/schemas/test.xml"); + File.Delete (file); } DataSet dataSet2 = new DataSet(); diff --git a/mcs/class/System.Data/Test/System.Data/DataSetTest2.cs b/mcs/class/System.Data/Test/System.Data/DataSetTest2.cs index fe6701a579e..27df0f58984 100644 --- a/mcs/class/System.Data/Test/System.Data/DataSetTest2.cs +++ b/mcs/class/System.Data/Test/System.Data/DataSetTest2.cs @@ -37,6 +37,7 @@ using MonoTests.System.Data.Utils; using System.Xml; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; +using System.Globalization; namespace MonoTests_System.Data { @@ -985,6 +986,17 @@ namespace MonoTests_System.Data Assert.AreEqual(culInfo , ds.Locale , "DS157"); } + [Test] + [SetCulture ("cs-CZ")] + public void DataSetSpecificCulture () + { + var ds = new DataSet() ; + ds.Locale = CultureInfo.GetCultureInfo (1033); + var dt = ds.Tables.Add ("machine"); + dt.Locale = ds.Locale; + Assert.AreSame (dt, ds.Tables["MACHINE"]); + } + [Test] public void MergeFailed() { EventRaised = false; @@ -2022,7 +2034,7 @@ namespace MonoTests_System.Data [Test] public void ReadXmlSchema_ByFileName() { - string sTempFileName = "tmpDataSet_ReadWriteXml_43899.xml" ; + string sTempFileName = Path.Combine (Path.GetTempPath (), "tmpDataSet_ReadWriteXml_43899.xml"); DataSet ds1 = new DataSet(); ds1.Tables.Add(DataProvider.CreateParentDataTable()); diff --git a/mcs/class/System.Data/Test/System.Data/DataTableTest.cs b/mcs/class/System.Data/Test/System.Data/DataTableTest.cs index d41235ef4b3..d752df4f1ac 100644 --- a/mcs/class/System.Data/Test/System.Data/DataTableTest.cs +++ b/mcs/class/System.Data/Test/System.Data/DataTableTest.cs @@ -3091,8 +3091,8 @@ namespace MonoTests.System.Data [Test] public void ReadWriteXmlSchema_ByFileName () { - string sTempFileName1 = "tmpDataSet_ReadWriteXml_43899-1.xml"; - string sTempFileName2 = "tmpDataSet_ReadWriteXml_43899-2.xml"; + string sTempFileName1 = Path.Combine (Path.GetTempPath (), "tmpDataSet_ReadWriteXml_43899-1.xml"); + string sTempFileName2 = Path.Combine (Path.GetTempPath (), "tmpDataSet_ReadWriteXml_43899-2.xml"); DataSet ds1 = new DataSet (); ds1.Tables.Add (DataProvider.CreateParentDataTable ()); diff --git a/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs b/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs index eb336f70d87..68004b99013 100644 --- a/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs +++ b/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs @@ -308,7 +308,7 @@ namespace System.Net.Http } } - var stream = wrequest.GetRequestStream (); + var stream = await wrequest.GetRequestStreamAsync ().ConfigureAwait (false); await request.Content.CopyToAsync (stream).ConfigureAwait (false); } diff --git a/mcs/class/System.Reactive.Core/Makefile b/mcs/class/System.Reactive.Core/Makefile index e6395385c1b..d56ecc9c089 100644 --- a/mcs/class/System.Reactive.Core/Makefile +++ b/mcs/class/System.Reactive.Core/Makefile @@ -23,12 +23,12 @@ RESOURCES = $(RESX_RESOURCES) PREBUILT = $(RESX_RESOURCES:=.prebuilt) ifeq (2.1, $(FRAMEWORK_VERSION)) -LIB_MCS_FLAGS += -d:NO_TASK_DELAY +LIB_MCS_FLAGS += -d:NO_TASK_DELAY -d:HAS_AWAIT endif NET_4_5 := $(filter 4.5, $(FRAMEWORK_VERSION)) ifdef NET_4_5 -LIB_MCS_FLAGS += -d:HAS_EDI -d:PREFERASYNC -d:PREFER_ASYNC +LIB_MCS_FLAGS += -d:HAS_EDI -d:PREFERASYNC -d:PREFER_ASYNC -d:HAS_AWAIT endif TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) diff --git a/mcs/class/System.Reactive.Debugger/Makefile b/mcs/class/System.Reactive.Debugger/Makefile index 65d30c049ba..8c6dee9af40 100644 --- a/mcs/class/System.Reactive.Debugger/Makefile +++ b/mcs/class/System.Reactive.Debugger/Makefile @@ -12,12 +12,12 @@ LIB_MCS_FLAGS = \ -r:System.Reactive.Linq.dll ifeq (2.1, $(FRAMEWORK_VERSION)) -LIB_MCS_FLAGS += -d:NO_TASK_DELAY +LIB_MCS_FLAGS += -d:NO_TASK_DELAY -d:HAS_AWAIT endif NET_4_5 := $(filter 4.5, $(FRAMEWORK_VERSION)) ifdef NET_4_5 -LIB_MCS_FLAGS += -d:HAS_EDI -d:PREFERASYNC -d:PREFER_ASYNC +LIB_MCS_FLAGS += -d:HAS_EDI -d:PREFERASYNC -d:PREFER_ASYNC -d:HAS_AWAIT endif TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) diff --git a/mcs/class/System.Reactive.Experimental/Makefile b/mcs/class/System.Reactive.Experimental/Makefile index 966b95daff9..e7b128f3813 100644 --- a/mcs/class/System.Reactive.Experimental/Makefile +++ b/mcs/class/System.Reactive.Experimental/Makefile @@ -12,12 +12,12 @@ LIB_MCS_FLAGS = \ -r:System.Reactive.Linq.dll ifeq (2.1, $(FRAMEWORK_VERSION)) -LIB_MCS_FLAGS += -d:NO_TASK_DELAY +LIB_MCS_FLAGS += -d:NO_TASK_DELAY -d:HAS_AWAIT endif NET_4_5 := $(filter 4.5, $(FRAMEWORK_VERSION)) ifdef NET_4_5 -LIB_MCS_FLAGS += -d:HAS_EDI -d:PREFERASYNC -d:PREFER_ASYNC +LIB_MCS_FLAGS += -d:HAS_EDI -d:PREFERASYNC -d:PREFER_ASYNC -d:HAS_AWAIT endif TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) diff --git a/mcs/class/System.Reactive.Interfaces/Makefile b/mcs/class/System.Reactive.Interfaces/Makefile index b001529523d..967a34327de 100644 --- a/mcs/class/System.Reactive.Interfaces/Makefile +++ b/mcs/class/System.Reactive.Interfaces/Makefile @@ -9,12 +9,12 @@ LIB_MCS_FLAGS = \ -r:System.Core.dll ifeq (2.1, $(FRAMEWORK_VERSION)) -LIB_MCS_FLAGS += -d:NO_TASK_DELAY +LIB_MCS_FLAGS += -d:NO_TASK_DELAY -d:HAS_AWAIT endif NET_4_5 := $(filter 4.5, $(FRAMEWORK_VERSION)) ifdef NET_4_5 -LIB_MCS_FLAGS += -d:HAS_EDI -d:PREFERASYNC -d:PREFER_ASYNC +LIB_MCS_FLAGS += -d:HAS_EDI -d:PREFERASYNC -d:PREFER_ASYNC -d:HAS_AWAIT endif TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) diff --git a/mcs/class/System.Reactive.Linq/Makefile b/mcs/class/System.Reactive.Linq/Makefile index 690aa82dbc5..3afa5560431 100644 --- a/mcs/class/System.Reactive.Linq/Makefile +++ b/mcs/class/System.Reactive.Linq/Makefile @@ -24,12 +24,12 @@ RESOURCES = $(RESX_RESOURCES) PREBUILT = $(RESX_RESOURCES:=.prebuilt) ifeq (2.1, $(FRAMEWORK_VERSION)) -LIB_MCS_FLAGS += -d:NO_TASK_DELAY +LIB_MCS_FLAGS += -d:NO_TASK_DELAY -d:HAS_AWAIT endif NET_4_5 := $(filter 4.5, $(FRAMEWORK_VERSION)) ifdef NET_4_5 -LIB_MCS_FLAGS += -d:HAS_EDI -d:PREFERASYNC -d:PREFER_ASYNC +LIB_MCS_FLAGS += -d:HAS_EDI -d:PREFERASYNC -d:PREFER_ASYNC -d:HAS_AWAIT endif TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) diff --git a/mcs/class/System.Reactive.PlatformServices/Makefile b/mcs/class/System.Reactive.PlatformServices/Makefile index e8b78f2d3bb..80e88566ca6 100644 --- a/mcs/class/System.Reactive.PlatformServices/Makefile +++ b/mcs/class/System.Reactive.PlatformServices/Makefile @@ -25,12 +25,12 @@ RESOURCES = $(RESX_RESOURCES) PREBUILT = $(RESX_RESOURCES:=.prebuilt) ifeq (2.1, $(FRAMEWORK_VERSION)) -LIB_MCS_FLAGS += -d:NO_TASK_DELAY +LIB_MCS_FLAGS += -d:NO_TASK_DELAY -d:HAS_AWAIT endif NET_4_5 := $(filter 4.5, $(FRAMEWORK_VERSION)) ifdef NET_4_5 -LIB_MCS_FLAGS += -d:HAS_EDI -d:PREFERASYNC -d:PREFER_ASYNC +LIB_MCS_FLAGS += -d:HAS_EDI -d:PREFERASYNC -d:PREFER_ASYNC -d:HAS_AWAIT endif NO_TASK_DELAY := $(filter 4.5 2.1, $(FRAMEWORK_VERSION)) diff --git a/mcs/class/System.Reactive.Providers/Makefile b/mcs/class/System.Reactive.Providers/Makefile index 44088a17101..06ec402a0df 100644 --- a/mcs/class/System.Reactive.Providers/Makefile +++ b/mcs/class/System.Reactive.Providers/Makefile @@ -25,12 +25,12 @@ RESOURCES = $(RESX_RESOURCES) PREBUILT = $(RESX_RESOURCES:=.prebuilt) ifeq (2.1, $(FRAMEWORK_VERSION)) -LIB_MCS_FLAGS += -d:NO_TASK_DELAY +LIB_MCS_FLAGS += -d:NO_TASK_DELAY -d:HAS_AWAIT endif NET_4_5 := $(filter 4.5, $(FRAMEWORK_VERSION)) ifdef NET_4_5 -LIB_MCS_FLAGS += -d:HAS_EDI -d:PREFERASYNC -d:PREFER_ASYNC +LIB_MCS_FLAGS += -d:HAS_EDI -d:PREFERASYNC -d:PREFER_ASYNC -d:HAS_AWAIT endif TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) diff --git a/mcs/class/System.Reactive.Runtime.Remoting/Makefile b/mcs/class/System.Reactive.Runtime.Remoting/Makefile index deaf483c327..e5fbf287ad2 100644 --- a/mcs/class/System.Reactive.Runtime.Remoting/Makefile +++ b/mcs/class/System.Reactive.Runtime.Remoting/Makefile @@ -17,7 +17,7 @@ endif NET_4_5 := $(filter 4.5, $(FRAMEWORK_VERSION)) ifdef NET_4_5 -LIB_MCS_FLAGS += -d:HAS_EDI -d:PREFERASYNC -d:PREFER_ASYNC +LIB_MCS_FLAGS += -d:HAS_EDI -d:PREFERASYNC -d:PREFER_ASYNC -d:HAS_AWAIT endif TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) diff --git a/mcs/class/System.Reactive.Windows.Forms/Makefile b/mcs/class/System.Reactive.Windows.Forms/Makefile index 63b3fe0f4a5..bc427b92a19 100644 --- a/mcs/class/System.Reactive.Windows.Forms/Makefile +++ b/mcs/class/System.Reactive.Windows.Forms/Makefile @@ -13,12 +13,12 @@ LIB_MCS_FLAGS = \ -r:System.Windows.Forms.dll ifeq (2.1, $(FRAMEWORK_VERSION)) -LIB_MCS_FLAGS += -d:NO_TASK_DELAY +LIB_MCS_FLAGS += -d:NO_TASK_DELAY -d:HAS_AWAIT endif NET_4_5 := $(filter 4.5, $(FRAMEWORK_VERSION)) ifdef NET_4_5 -LIB_MCS_FLAGS += -d:HAS_EDI -d:PREFERASYNC -d:PREFER_ASYNC +LIB_MCS_FLAGS += -d:HAS_EDI -d:PREFERASYNC -d:PREFER_ASYNC -d:HAS_AWAIT endif TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) diff --git a/mcs/class/System.Reactive.Windows.Threading/Makefile b/mcs/class/System.Reactive.Windows.Threading/Makefile index 8e1641a8cb5..dd68cd5a03b 100644 --- a/mcs/class/System.Reactive.Windows.Threading/Makefile +++ b/mcs/class/System.Reactive.Windows.Threading/Makefile @@ -26,12 +26,12 @@ RESOURCES = $(RESX_RESOURCES) PREBUILT = $(RESX_RESOURCES:=.prebuilt) ifeq (2.1, $(FRAMEWORK_VERSION)) -LIB_MCS_FLAGS += -d:NO_TASK_DELAY +LIB_MCS_FLAGS += -d:NO_TASK_DELAY -d:HAS_AWAIT endif NET_4_5 := $(filter 4.5, $(FRAMEWORK_VERSION)) ifdef NET_4_5 -LIB_MCS_FLAGS += -d:HAS_EDI -d:PREFERASYNC -d:PREFER_ASYNC +LIB_MCS_FLAGS += -d:HAS_EDI -d:PREFERASYNC -d:PREFER_ASYNC -d:HAS_AWAIT endif TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) diff --git a/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlObjectSerializer.cs b/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlObjectSerializer.cs index 9c0319d9433..2abb7663fed 100644 --- a/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlObjectSerializer.cs +++ b/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlObjectSerializer.cs @@ -25,10 +25,10 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#if NET_2_0 using System; using System.Collections; using System.IO; +using System.Text; using System.Reflection; using System.Runtime.Serialization.Formatters.Binary; using System.Xml; @@ -61,7 +61,9 @@ namespace System.Runtime.Serialization public virtual object ReadObject (Stream stream) { - return ReadObject (XmlReader.Create (stream)); + var settings = new XmlReaderSettings (); + settings.CheckCharacters = false; + return ReadObject (XmlReader.Create (stream, settings)); } public virtual object ReadObject (XmlReader reader) @@ -86,7 +88,12 @@ namespace System.Runtime.Serialization public virtual void WriteObject (Stream stream, object graph) { - using (XmlWriter xw = XmlDictionaryWriter.CreateTextWriter (stream)) { + var settings = new XmlWriterSettings (); + settings.Encoding = Encoding.UTF8; + settings.CloseOutput = false; + settings.OmitXmlDeclaration = true; + settings.CheckCharacters = false; + using (XmlWriter xw = XmlDictionaryWriter.CreateDictionaryWriter (XmlWriter.Create (stream, settings))) { WriteObject (xw, graph); } } @@ -130,4 +137,3 @@ namespace System.Runtime.Serialization XmlDictionaryWriter writer); } } -#endif diff --git a/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization_test.dll.sources b/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization_test.dll.sources index aa860040ea3..9c52901aa8b 100644 --- a/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization_test.dll.sources +++ b/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization_test.dll.sources @@ -7,6 +7,7 @@ System.Runtime.Serialization/Bug695203Test.cs System.Runtime.Serialization/DataContractResolverTest.cs System.Runtime.Serialization/DataContractSerializerTest_DuplicateQName.cs System.Runtime.Serialization/DataContractSerializerTest_NullableWithDictionary.cs +System.Runtime.Serialization/DataContractSerializerTest_InvalidCharacters.cs System.Runtime.Serialization/KnownTypeAttributeTest.cs System.Runtime.Serialization/XmlObjectSerializerTest.cs System.Runtime.Serialization/XsdDataContractExporterTest.cs diff --git a/mcs/class/System.Runtime.Serialization/Test/System.Runtime.Serialization/DataContractSerializerTest_InvalidCharacters.cs b/mcs/class/System.Runtime.Serialization/Test/System.Runtime.Serialization/DataContractSerializerTest_InvalidCharacters.cs new file mode 100644 index 00000000000..260c3e35d65 --- /dev/null +++ b/mcs/class/System.Runtime.Serialization/Test/System.Runtime.Serialization/DataContractSerializerTest_InvalidCharacters.cs @@ -0,0 +1,71 @@ +// +// DataContractSerializerTest_InvalidCharacters.cs +// +// Author: +// Martin Baulig +// +// Copyright (c) 2013 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 "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using System.IO; +using System.Text; +using System.Runtime.Serialization; + +using NUnit.Framework; + +namespace MonoTests.System.Runtime.Serialization +{ + [TestFixture] + public class DataContractSerializerTest_InvalidCharacters + { + [Serializable] + public class MyData + { + public string Text; + } + + [Test] + public void Test () + { + var data = new MyData + { + Text = "Test " + ASCIIEncoding.ASCII.GetString (new byte[] { 0x06 }) + }; + + var serializer = new DataContractSerializer (typeof(MyData), "MyData", string.Empty); + + string serialized; + using (var ms = new MemoryStream ()) { + serializer.WriteObject (ms, data); + serialized = new string (Encoding.UTF8.GetChars (ms.GetBuffer ())); + + Assert.IsTrue (serialized.Contains ("Test "), "#1"); + + ms.Seek (0, SeekOrigin.Begin); + + var data2 = (MyData)serializer.ReadObject (ms); + Assert.AreEqual (data2.Text.Length, 6, "#2"); + Assert.AreEqual (data2.Text [5], (char)0x06, "#3"); + } + } + + + } +} diff --git a/mcs/class/System.Runtime.Serialization/Test/System.Runtime.Serialization/XmlObjectSerializerTest.cs b/mcs/class/System.Runtime.Serialization/Test/System.Runtime.Serialization/XmlObjectSerializerTest.cs index a2b66f4176d..e25a680e001 100755 --- a/mcs/class/System.Runtime.Serialization/Test/System.Runtime.Serialization/XmlObjectSerializerTest.cs +++ b/mcs/class/System.Runtime.Serialization/Test/System.Runtime.Serialization/XmlObjectSerializerTest.cs @@ -81,7 +81,7 @@ namespace MonoTests.System.Runtime.Serialization public void ConstructorKnownTypesNull () { // null knownTypes is allowed. Though the property is filled. - Assert.IsNotNull (new DataContractSerializer (typeof (Sample1), null).KnownTypes, "#1"); + Assert.IsNotNull (new DataContractSerializer (typeof (Sample1), (IEnumerable)null).KnownTypes, "#1"); Assert.IsNotNull (new DataContractSerializer (typeof (Sample1), "Foo", String.Empty, null).KnownTypes, "#2"); Assert.IsNotNull (new DataContractSerializer (typeof (Sample1), new XmlDictionary ().Add ("Foo"), XmlDictionaryString.Empty, null).KnownTypes, "#3"); } diff --git a/mcs/class/System.ServiceModel.Web/Makefile b/mcs/class/System.ServiceModel.Web/Makefile index f58657f7769..97c88830976 100644 --- a/mcs/class/System.ServiceModel.Web/Makefile +++ b/mcs/class/System.ServiceModel.Web/Makefile @@ -15,7 +15,8 @@ TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) EXTRA_DISTFILES = $(RESOURCE_FILES) \ Test/config/webHttpBinding \ - Test/config/webHttpBinding.config + Test/config/webHttpBinding.config \ + System.Runtime.Serialization.Json/DataContractJsonSerializerSettings.cs VALID_PROFILE := $(filter 2 4, $(FRAMEWORK_VERSION_MAJOR)) ifndef VALID_PROFILE diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpChannelFactory.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpChannelFactory.cs index 0fe6bbfd0d5..50ae808fcbd 100644 --- a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpChannelFactory.cs +++ b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpChannelFactory.cs @@ -38,7 +38,7 @@ namespace System.ServiceModel.Channels { internal class HttpChannelFactory : TransportChannelFactoryBase { -#if NET_2_1 +#if NET_2_1 || NET_4_0 IHttpCookieContainerManager cookie_manager; #endif @@ -50,12 +50,16 @@ namespace System.ServiceModel.Channels MessageEncodingBindingElement mbe = be as MessageEncodingBindingElement; if (mbe != null) { MessageEncoder = CreateEncoder (mbe); - break; + continue; } #if NET_2_1 var cbe = be as HttpCookieContainerBindingElement; if (cbe != null) cookie_manager = cbe.GetProperty (ctx); +#elif NET_4_0 + var tbe = be as HttpTransportBindingElement; + if (tbe != null) + cookie_manager = tbe.GetProperty (ctx); #endif } if (MessageEncoder == null) @@ -109,7 +113,7 @@ namespace System.ServiceModel.Channels public override T GetProperty () { -#if NET_2_1 +#if NET_2_1 || NET_4_0 if (cookie_manager is T) return (T) (object) cookie_manager; #endif diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpCookieContainerBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpCookieContainerBindingElement.cs index d718bfb467a..b9dc0ab748d 100644 --- a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpCookieContainerBindingElement.cs +++ b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpCookieContainerBindingElement.cs @@ -4,6 +4,9 @@ using System.ServiceModel; namespace System.ServiceModel.Channels { +#if NET_4_0 + [Obsolete ("Use AllowCookies.")] +#endif public class HttpCookieContainerBindingElement : BindingElement { HttpCookieContainerManager manager; diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestChannel.cs index ff5d658f39f..e209ec8062b 100644 --- a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestChannel.cs +++ b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestChannel.cs @@ -90,11 +90,11 @@ namespace System.ServiceModel.Channels result.WebRequest = web_request; web_request.Method = "POST"; web_request.ContentType = Encoder.ContentType; -#if NET_2_1 +#if NET_2_1 || NET_4_0 HttpWebRequest hwr = (web_request as HttpWebRequest); - var cmgr = source.GetProperty (); - if (cmgr != null) - hwr.CookieContainer = cmgr.CookieContainer; + var cmgr = source.GetProperty (); + if (cmgr != null) + hwr.CookieContainer = cmgr.CookieContainer; #endif // client authentication (while SL3 has NetworkCredential class, it is not implemented yet. So, it is non-SL only.) diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpTransportBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpTransportBindingElement.cs index 2c6b0828675..84388adcb08 100644 --- a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpTransportBindingElement.cs +++ b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpTransportBindingElement.cs @@ -62,6 +62,9 @@ namespace System.ServiceModel.Channels AuthenticationSchemes proxy_auth_scheme = AuthenticationSchemes.Anonymous; // If you add fields, do not forget them in copy constructor. +#if NET_4_0 + HttpCookieContainerManager cookie_manager; +#endif public HttpTransportBindingElement () { @@ -90,6 +93,7 @@ namespace System.ServiceModel.Channels DecompressionEnabled = other.DecompressionEnabled; LegacyExtendedProtectionPolicy = other.LegacyExtendedProtectionPolicy; ExtendedProtectionPolicy = other.ExtendedProtectionPolicy; + cookie_manager = other.cookie_manager; #endif } @@ -257,6 +261,15 @@ namespace System.ServiceModel.Channels return (T) (object) new HttpBindingProperties (this); if (typeof (T) == typeof (TransferMode)) return (T) (object) TransferMode; +#if NET_4_0 + if (typeof(T) == typeof(IHttpCookieContainerManager)) { + if (!AllowCookies) + return null; + if (cookie_manager == null) + cookie_manager = new HttpCookieContainerManager (); + return (T) (object) cookie_manager; + } +#endif return base.GetProperty (context); } diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IHttpCookieContainer.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IHttpCookieContainer.cs index e016772f0b5..b14d7a2290b 100644 --- a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IHttpCookieContainer.cs +++ b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IHttpCookieContainer.cs @@ -1,3 +1,4 @@ +#if NET_2_1 || NET_4_0 using System; using System.Net; @@ -9,3 +10,4 @@ namespace System.ServiceModel.Channels CookieContainer CookieContainer { get; set; } } } +#endif diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TextMessageEncoder.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TextMessageEncoder.cs index 0ff234382a2..89d971656ff 100644 --- a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TextMessageEncoder.cs +++ b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TextMessageEncoder.cs @@ -66,12 +66,14 @@ namespace System.ServiceModel.Channels { if (bufferManager == null) throw new ArgumentNullException ("bufferManager"); + var settings = new XmlReaderSettings (); + settings.CheckCharacters = false; var ret = Message.CreateMessage ( XmlDictionaryReader.CreateDictionaryReader ( XmlReader.Create (new StreamReader ( new MemoryStream ( buffer.Array, buffer.Offset, - buffer.Count), encoding))), + buffer.Count), encoding), settings)), // FIXME: supply max header size int.MaxValue, version); @@ -84,9 +86,11 @@ namespace System.ServiceModel.Channels { if (stream == null) throw new ArgumentNullException ("stream"); + var settings = new XmlReaderSettings (); + settings.CheckCharacters = false; var ret = Message.CreateMessage ( XmlDictionaryReader.CreateDictionaryReader ( - XmlReader.Create (new StreamReader (stream, encoding))), + XmlReader.Create (new StreamReader (stream, encoding), settings)), maxSizeOfHeaders, version); ret.Properties.Encoder = this; @@ -113,6 +117,7 @@ namespace System.ServiceModel.Channels XmlWriterSettings s = new XmlWriterSettings (); s.Encoding = encoding; + s.CheckCharacters = false; using (XmlWriter w = XmlWriter.Create (stream, s)) { message.WriteMessage ( XmlDictionaryWriter.CreateDictionaryWriter (w)); @@ -131,6 +136,7 @@ namespace System.ServiceModel.Channels messageOffset, maxMessageSize); XmlWriterSettings s = new XmlWriterSettings (); s.Encoding = encoding; + s.CheckCharacters = false; using (XmlWriter w = XmlWriter.Create ( new MemoryStream (seg.Array, seg.Offset, seg.Count), s)) { message.WriteMessage ( diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/BasicHttpBinding.cs b/mcs/class/System.ServiceModel/System.ServiceModel/BasicHttpBinding.cs index 5b0f404f090..4feebc7a115 100644 --- a/mcs/class/System.ServiceModel/System.ServiceModel/BasicHttpBinding.cs +++ b/mcs/class/System.ServiceModel/System.ServiceModel/BasicHttpBinding.cs @@ -98,7 +98,15 @@ namespace System.ServiceModel } #if NET_2_1 - public bool EnableHttpCookieContainer { get; set; } + public bool EnableHttpCookieContainer { + get; set; + } +#elif NET_4_5 + [Obsolete ("Use AllowCookies.")] + public bool EnableHttpCookieContainer { + get { return AllowCookies; } + set { AllowCookies = value; } + } #endif public HostNameComparisonMode HostNameComparisonMode { diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory.cs b/mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory.cs index 5e15c5a72be..442a33113f5 100644 --- a/mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory.cs +++ b/mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory.cs @@ -282,7 +282,7 @@ namespace System.ServiceModel public T GetProperty () where T : class { if (OpenedChannelFactory != null) - OpenedChannelFactory.GetProperty (); + return OpenedChannelFactory.GetProperty (); return null; } diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/WsdlExporterTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/WsdlExporterTest.cs index fafcd01f62b..742c71e6d14 100644 --- a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/WsdlExporterTest.cs +++ b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/WsdlExporterTest.cs @@ -224,6 +224,11 @@ namespace MonoTests.System.ServiceModel.Description } [Test] + [Category ("NotWorking")] + // System.Xml.Schema.XmlSchemaException : XmlSchema error: Named item + // http://schemas.datacontract.org/2004/07/System.Reflection:ArrayOfTypeInfo was already contained + // in the schema object table. Consider setting MONO_STRICT_MS_COMPLIANT to 'yes' to mimic + // MS implementation. Related schema item SourceUri: , Line 0, Position 0. public void ExportMessageContract () { WsdlExporter we = new WsdlExporter (); diff --git a/mcs/class/System.ServiceModel/net_4_0_System.ServiceModel.dll.sources b/mcs/class/System.ServiceModel/net_4_0_System.ServiceModel.dll.sources index f8b48c78c83..9a588704229 100644 --- a/mcs/class/System.ServiceModel/net_4_0_System.ServiceModel.dll.sources +++ b/mcs/class/System.ServiceModel/net_4_0_System.ServiceModel.dll.sources @@ -2,6 +2,9 @@ ../../build/common/MonoTODOAttribute.cs #include System.ServiceModel.dll.sources +System.ServiceModel.Channels/IHttpCookieContainer.cs +System.ServiceModel.Channels/HttpCookieContainerBindingElement.cs + ../System.ServiceModel.Web/System.ServiceModel.Syndication/Atom10FeedFormatter.cs ../System.ServiceModel.Web/System.ServiceModel.Syndication/Atom10FeedFormatter_1.cs ../System.ServiceModel.Web/System.ServiceModel.Syndication/Atom10ItemFormatter.cs diff --git a/mcs/class/System.Web.Http.WebHost/Makefile b/mcs/class/System.Web.Http.WebHost/Makefile new file mode 100644 index 00000000000..0a898cfa44b --- /dev/null +++ b/mcs/class/System.Web.Http.WebHost/Makefile @@ -0,0 +1,23 @@ +thisdir = class/System.Web.Http.WebHost +SUBDIRS = +include ../../build/rules.make + +LIBRARY = System.Web.Http.WebHost.dll + +System.Web.Http.WebHost.Properties.CommonWebApiResources.resources: ../../../external/aspnetwebstack/src/Common/CommonWebApiResources.resx + $(RESGEN) "$<" "$@" + +System.Web.Http.WebHost.Properties.SRResources.resources: ../../../external/aspnetwebstack/src/System.Web.Http.WebHost/Properties/SRResources.resx + $(RESGEN) "$<" "$@" + + +LIB_MCS_FLAGS = -r:System.Core.dll -r:System.dll -r:System.Xml.dll -r:System.Configuration.dll -r:System.Net.Http.dll \ + -r:System.Runtime.Serialization.dll -r:System.ServiceModel.dll -r:System.IdentityModel.dll \ + -r:System.Web.Http.dll -r:System.Net.Http.Formatting.dll -r:System.Web.Routing.dll -r:System.Web.dll \ + -r:Microsoft.Web.Infrastructure.dll \ + -d:ASPNETMVC -keyfile:../winfx.pub -delaysign + +include ../../build/library.make + +$(the_lib): System.Web.Http.WebHost.Properties.CommonWebApiResources.resources \ + System.Web.Http.WebHost.Properties.SRResources.resources diff --git a/mcs/class/System.Web.Http.WebHost/System.Web.Http.WebHost.dll.sources b/mcs/class/System.Web.Http.WebHost/System.Web.Http.WebHost.dll.sources new file mode 100644 index 00000000000..a71b88d7658 --- /dev/null +++ b/mcs/class/System.Web.Http.WebHost/System.Web.Http.WebHost.dll.sources @@ -0,0 +1,32 @@ +../../../external/aspnetwebstack/src/CommonAssemblyInfo.cs +../../../external/aspnetwebstack/src/TransparentCommonAssemblyInfo.cs + +../../../external/aspnetwebstack/src/Common/DictionaryExtensions.cs +../../../external/aspnetwebstack/src/Common/Error.cs +../../../external/aspnetwebstack/src/Common/HttpMethodHelper.cs +../../../external/aspnetwebstack/src/Common/TaskHelpers.cs +../../../external/aspnetwebstack/src/Common/TaskHelpersExtensions.cs +../../../external/aspnetwebstack/src/Common/CommonWebApiResources.Designer.cs + +../../../external/aspnetwebstack/src/System.Web.Http.WebHost/GlobalConfiguration.cs +../../../external/aspnetwebstack/src/System.Web.Http.WebHost/GlobalSuppressions.cs +../../../external/aspnetwebstack/src/System.Web.Http.WebHost/HttpControllerHandler.cs +../../../external/aspnetwebstack/src/System.Web.Http.WebHost/HttpControllerRouteHandler.cs +../../../external/aspnetwebstack/src/System.Web.Http.WebHost/HttpControllerTypeCacheSerializer.cs +../../../external/aspnetwebstack/src/System.Web.Http.WebHost/PreApplicationStartCode.cs +../../../external/aspnetwebstack/src/System.Web.Http.WebHost/Properties/SRResources.Designer.cs +../../../external/aspnetwebstack/src/System.Web.Http.WebHost/Properties/AssemblyInfo.cs +../../../external/aspnetwebstack/src/System.Web.Http.WebHost/RouteCollectionExtensions.cs +../../../external/aspnetwebstack/src/System.Web.Http.WebHost/Routing/HostedHttpRouteCollection.cs +../../../external/aspnetwebstack/src/System.Web.Http.WebHost/Routing/HostedHttpVirtualPathData.cs +../../../external/aspnetwebstack/src/System.Web.Http.WebHost/Routing/HttpContextBaseExtensions.cs +../../../external/aspnetwebstack/src/System.Web.Http.WebHost/Routing/HostedHttpRouteData.cs +../../../external/aspnetwebstack/src/System.Web.Http.WebHost/Routing/HttpRouteExtensions.cs +../../../external/aspnetwebstack/src/System.Web.Http.WebHost/Routing/HttpRouteDataExtensions.cs +../../../external/aspnetwebstack/src/System.Web.Http.WebHost/Routing/HttpWebRoute.cs +../../../external/aspnetwebstack/src/System.Web.Http.WebHost/Routing/HostedHttpRoute.cs +../../../external/aspnetwebstack/src/System.Web.Http.WebHost/SuppressFormsAuthRedirectModule.cs +../../../external/aspnetwebstack/src/System.Web.Http.WebHost/TaskWrapperAsyncResult.cs +../../../external/aspnetwebstack/src/System.Web.Http.WebHost/WebHostAssembliesResolver.cs +../../../external/aspnetwebstack/src/System.Web.Http.WebHost/WebHostHttpControllerTypeResolver.cs + diff --git a/mcs/class/System.Web.Services/Test/System.Web.Services.Description/ServiceDescriptionTest.cs b/mcs/class/System.Web.Services/Test/System.Web.Services.Description/ServiceDescriptionTest.cs index 99fe6c62b0d..a0c0489d701 100644 --- a/mcs/class/System.Web.Services/Test/System.Web.Services.Description/ServiceDescriptionTest.cs +++ b/mcs/class/System.Web.Services/Test/System.Web.Services.Description/ServiceDescriptionTest.cs @@ -59,7 +59,7 @@ namespace MonoTests.System.Web.Services.Description [Test] public void Namespaces () { - FileStream fs = new FileStream ("Test/System.Web.Services.Description/test.wsdl", FileMode.Open); + FileStream fs = new FileStream ("Test/System.Web.Services.Description/test.wsdl", FileMode.Open, FileAccess.Read); XmlTextReader xtr = new XmlTextReader (fs); ServiceDescription sd = ServiceDescription.Read (xtr); @@ -84,7 +84,7 @@ namespace MonoTests.System.Web.Services.Description [Test] public void ExtensibleAttributes () { - FileStream fs = new FileStream("Test/System.Web.Services.Description/test.wsdl", FileMode.Open); + FileStream fs = new FileStream ("Test/System.Web.Services.Description/test.wsdl", FileMode.Open, FileAccess.Read); XmlTextReader xtr = new XmlTextReader(fs); ServiceDescription sd = ServiceDescription.Read(xtr); @@ -105,7 +105,7 @@ namespace MonoTests.System.Web.Services.Description [Test] public void Extensions () { - FileStream fs = new FileStream("Test/System.Web.Services.Description/test.wsdl", FileMode.Open); + FileStream fs = new FileStream("Test/System.Web.Services.Description/test.wsdl", FileMode.Open, FileAccess.Read); XmlTextReader xtr = new XmlTextReader(fs); ServiceDescription sd = ServiceDescription.Read(xtr); diff --git a/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaTests.cs b/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaTests.cs index 779c8bd1e1e..8ae833f9dcc 100644 --- a/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaTests.cs +++ b/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaTests.cs @@ -586,7 +586,7 @@ namespace MonoTests.System.Xml public void TestResolveUri () { XmlSchemaSet schemaSet = new XmlSchemaSet (); - FileStream stream = new FileStream ("Test/XmlFiles/xsd/resolveUriSchema.xsd", FileMode.Open); + FileStream stream = new FileStream ("Test/XmlFiles/xsd/resolveUriSchema.xsd", FileMode.Open, FileAccess.Read); schemaSet.Add ("http://tempuri.org/resolveUriSchema.xsd", new XmlTextReader (stream)); XmlTestResolver resolver = new XmlTestResolver (); diff --git a/mcs/class/System.XML/Test/System.Xml.Serialization/XmlReflectionImporterTests.cs b/mcs/class/System.XML/Test/System.Xml.Serialization/XmlReflectionImporterTests.cs index 751242425cc..9e1c9f2b52e 100644 --- a/mcs/class/System.XML/Test/System.Xml.Serialization/XmlReflectionImporterTests.cs +++ b/mcs/class/System.XML/Test/System.Xml.Serialization/XmlReflectionImporterTests.cs @@ -1639,18 +1639,19 @@ namespace MonoTests.System.XmlSerialization [Test] public void Bug708178Type() { + string file = Path.Combine (Path.GetTempPath (), "Bug708178Type.xml"); XmlSerializer xmlSerializer = new XmlSerializer (typeof(Bug708178Type)); Bug708178Type bugType = new Bug708178Type (); bugType.Foo.Add ("test"); Assert.AreEqual (1, bugType.Foo.Count); //xml Serialize - TextWriter WriteFileStream = new StreamWriter (@"Bug708178Type.xml", false); + TextWriter WriteFileStream = new StreamWriter (file, false); xmlSerializer.Serialize (WriteFileStream, bugType); WriteFileStream.Close (); //xml Deserialize - FileStream ReadFileStream = new FileStream (@"Bug708178Type.xml", FileMode.Open, FileAccess.Read, FileShare.Read); + FileStream ReadFileStream = new FileStream (file, FileMode.Open, FileAccess.Read, FileShare.Read); Bug708178Type bugTypeReload = (Bug708178Type)xmlSerializer.Deserialize (ReadFileStream); //should have deserialized the relationship diff --git a/mcs/class/System.XML/Test/System.Xml.Xsl/XslTransformTests.cs b/mcs/class/System.XML/Test/System.Xml.Xsl/XslTransformTests.cs index 18cef9df486..b276342806c 100644 --- a/mcs/class/System.XML/Test/System.Xml.Xsl/XslTransformTests.cs +++ b/mcs/class/System.XML/Test/System.Xml.Xsl/XslTransformTests.cs @@ -36,10 +36,11 @@ namespace MonoTests.System.Xml.Xsl [Test] public void TestBasicTransform () { + string output = Path.Combine (Path.GetTempPath (), "result.xml"); doc.LoadXml (""); xslt.Load ("Test/XmlFiles/xsl/empty.xsl"); - xslt.Transform ("Test/XmlFiles/xsl/empty.xsl", "Test/XmlFiles/xsl/result.xml"); - result.Load ("Test/XmlFiles/xsl/result.xml"); + xslt.Transform ("Test/XmlFiles/xsl/empty.xsl", output); + result.Load (output); Assert.AreEqual (2, result.ChildNodes.Count, "count"); } diff --git a/mcs/class/System.XML/Test/System.Xml/XmlReaderCommonTests.cs b/mcs/class/System.XML/Test/System.Xml/XmlReaderCommonTests.cs index 8f522a85e56..749e601abda 100644 --- a/mcs/class/System.XML/Test/System.Xml/XmlReaderCommonTests.cs +++ b/mcs/class/System.XML/Test/System.Xml/XmlReaderCommonTests.cs @@ -1540,7 +1540,7 @@ namespace MonoTests.System.Xml // a bit revised version of bug #78706 public void CreateFromUrlClose () { - string file = "Test/XmlFiles/78706.xml"; + string file = Path.Combine (Path.GetTempPath (), "78706.xml"); try { if (!File.Exists (file)) File.Create (file).Close (); @@ -1560,7 +1560,7 @@ namespace MonoTests.System.Xml // a bit revised version of bug #385638 public void CreateFromUrlClose2 () { - string file = "Test/XmlFiles/385638.xml"; + string file = Path.Combine (Path.GetTempPath (), "385638.xml"); try { if (File.Exists (file)) File.Delete (file); diff --git a/mcs/class/System.XML/Test/System.Xml/XmlValidatingReaderTests.cs b/mcs/class/System.XML/Test/System.Xml/XmlValidatingReaderTests.cs index 552060abdff..1dc3d5584ce 100644 --- a/mcs/class/System.XML/Test/System.Xml/XmlValidatingReaderTests.cs +++ b/mcs/class/System.XML/Test/System.Xml/XmlValidatingReaderTests.cs @@ -820,18 +820,20 @@ namespace MonoTests.System.Xml // imported testcase from sys.security which had regression. public void ResolveEntityAndBaseURI () { + string world = Path.Combine (Path.GetTempPath (), "world.txt"); + string dtd = Path.Combine (Path.GetTempPath (), "doc.dtd"); try { - using (TextWriter w = File.CreateText ("world.txt")) { + using (TextWriter w = File.CreateText (world)) { w.WriteLine ("world"); } - using (TextWriter w = File.CreateText ("doc.dtd")) { + using (TextWriter w = File.CreateText (dtd)) { w.WriteLine (""); } - string xml = "\n" + "\n" + - "\n" + + "\n" + "\n" + "\n" + "]>\n" + @@ -839,7 +841,8 @@ namespace MonoTests.System.Xml " &ent1;, &ent2;!\n" + "\n" + "\n" + - "\n"; + "\n", + world, dtd); XmlValidatingReader xvr = new XmlValidatingReader ( @@ -851,10 +854,10 @@ namespace MonoTests.System.Xml doc.Load (xvr); } finally { - if (File.Exists ("world.txt")) - File.Delete ("world.txt"); - if (File.Exists ("doc.dtd")) - File.Delete ("doc.dtd"); + if (File.Exists (world)) + File.Delete (world); + if (File.Exists (dtd)) + File.Delete (dtd); } } diff --git a/mcs/class/System/System.Net/HttpUtility.cs b/mcs/class/System/System.Net/HttpUtility.cs index d5bb836f574..a39768c9a3a 100644 --- a/mcs/class/System/System.Net/HttpUtility.cs +++ b/mcs/class/System/System.Net/HttpUtility.cs @@ -39,7 +39,7 @@ using System.Text; namespace System.Net { - internal sealed class HttpUtility + static class HttpUtility { sealed class HttpQSCollection : NameValueCollection { @@ -58,291 +58,518 @@ namespace System.Net { return sb.ToString (); } } - #region Fields - - static Hashtable entities; - static object lock_ = new object (); - - #endregion // Fields - - static Hashtable Entities { - get { - lock (lock_) { - if (entities == null) - InitEntities (); - - return entities; - } - } - } - - #region Constructors - static void InitEntities () - { - // Build the hash table of HTML entity references. This list comes - // from the HTML 4.01 W3C recommendation. - entities = new Hashtable (); - entities.Add ("nbsp", '\u00A0'); - entities.Add ("iexcl", '\u00A1'); - entities.Add ("cent", '\u00A2'); - entities.Add ("pound", '\u00A3'); - entities.Add ("curren", '\u00A4'); - entities.Add ("yen", '\u00A5'); - entities.Add ("brvbar", '\u00A6'); - entities.Add ("sect", '\u00A7'); - entities.Add ("uml", '\u00A8'); - entities.Add ("copy", '\u00A9'); - entities.Add ("ordf", '\u00AA'); - entities.Add ("laquo", '\u00AB'); - entities.Add ("not", '\u00AC'); - entities.Add ("shy", '\u00AD'); - entities.Add ("reg", '\u00AE'); - entities.Add ("macr", '\u00AF'); - entities.Add ("deg", '\u00B0'); - entities.Add ("plusmn", '\u00B1'); - entities.Add ("sup2", '\u00B2'); - entities.Add ("sup3", '\u00B3'); - entities.Add ("acute", '\u00B4'); - entities.Add ("micro", '\u00B5'); - entities.Add ("para", '\u00B6'); - entities.Add ("middot", '\u00B7'); - entities.Add ("cedil", '\u00B8'); - entities.Add ("sup1", '\u00B9'); - entities.Add ("ordm", '\u00BA'); - entities.Add ("raquo", '\u00BB'); - entities.Add ("frac14", '\u00BC'); - entities.Add ("frac12", '\u00BD'); - entities.Add ("frac34", '\u00BE'); - entities.Add ("iquest", '\u00BF'); - entities.Add ("Agrave", '\u00C0'); - entities.Add ("Aacute", '\u00C1'); - entities.Add ("Acirc", '\u00C2'); - entities.Add ("Atilde", '\u00C3'); - entities.Add ("Auml", '\u00C4'); - entities.Add ("Aring", '\u00C5'); - entities.Add ("AElig", '\u00C6'); - entities.Add ("Ccedil", '\u00C7'); - entities.Add ("Egrave", '\u00C8'); - entities.Add ("Eacute", '\u00C9'); - entities.Add ("Ecirc", '\u00CA'); - entities.Add ("Euml", '\u00CB'); - entities.Add ("Igrave", '\u00CC'); - entities.Add ("Iacute", '\u00CD'); - entities.Add ("Icirc", '\u00CE'); - entities.Add ("Iuml", '\u00CF'); - entities.Add ("ETH", '\u00D0'); - entities.Add ("Ntilde", '\u00D1'); - entities.Add ("Ograve", '\u00D2'); - entities.Add ("Oacute", '\u00D3'); - entities.Add ("Ocirc", '\u00D4'); - entities.Add ("Otilde", '\u00D5'); - entities.Add ("Ouml", '\u00D6'); - entities.Add ("times", '\u00D7'); - entities.Add ("Oslash", '\u00D8'); - entities.Add ("Ugrave", '\u00D9'); - entities.Add ("Uacute", '\u00DA'); - entities.Add ("Ucirc", '\u00DB'); - entities.Add ("Uuml", '\u00DC'); - entities.Add ("Yacute", '\u00DD'); - entities.Add ("THORN", '\u00DE'); - entities.Add ("szlig", '\u00DF'); - entities.Add ("agrave", '\u00E0'); - entities.Add ("aacute", '\u00E1'); - entities.Add ("acirc", '\u00E2'); - entities.Add ("atilde", '\u00E3'); - entities.Add ("auml", '\u00E4'); - entities.Add ("aring", '\u00E5'); - entities.Add ("aelig", '\u00E6'); - entities.Add ("ccedil", '\u00E7'); - entities.Add ("egrave", '\u00E8'); - entities.Add ("eacute", '\u00E9'); - entities.Add ("ecirc", '\u00EA'); - entities.Add ("euml", '\u00EB'); - entities.Add ("igrave", '\u00EC'); - entities.Add ("iacute", '\u00ED'); - entities.Add ("icirc", '\u00EE'); - entities.Add ("iuml", '\u00EF'); - entities.Add ("eth", '\u00F0'); - entities.Add ("ntilde", '\u00F1'); - entities.Add ("ograve", '\u00F2'); - entities.Add ("oacute", '\u00F3'); - entities.Add ("ocirc", '\u00F4'); - entities.Add ("otilde", '\u00F5'); - entities.Add ("ouml", '\u00F6'); - entities.Add ("divide", '\u00F7'); - entities.Add ("oslash", '\u00F8'); - entities.Add ("ugrave", '\u00F9'); - entities.Add ("uacute", '\u00FA'); - entities.Add ("ucirc", '\u00FB'); - entities.Add ("uuml", '\u00FC'); - entities.Add ("yacute", '\u00FD'); - entities.Add ("thorn", '\u00FE'); - entities.Add ("yuml", '\u00FF'); - entities.Add ("fnof", '\u0192'); - entities.Add ("Alpha", '\u0391'); - entities.Add ("Beta", '\u0392'); - entities.Add ("Gamma", '\u0393'); - entities.Add ("Delta", '\u0394'); - entities.Add ("Epsilon", '\u0395'); - entities.Add ("Zeta", '\u0396'); - entities.Add ("Eta", '\u0397'); - entities.Add ("Theta", '\u0398'); - entities.Add ("Iota", '\u0399'); - entities.Add ("Kappa", '\u039A'); - entities.Add ("Lambda", '\u039B'); - entities.Add ("Mu", '\u039C'); - entities.Add ("Nu", '\u039D'); - entities.Add ("Xi", '\u039E'); - entities.Add ("Omicron", '\u039F'); - entities.Add ("Pi", '\u03A0'); - entities.Add ("Rho", '\u03A1'); - entities.Add ("Sigma", '\u03A3'); - entities.Add ("Tau", '\u03A4'); - entities.Add ("Upsilon", '\u03A5'); - entities.Add ("Phi", '\u03A6'); - entities.Add ("Chi", '\u03A7'); - entities.Add ("Psi", '\u03A8'); - entities.Add ("Omega", '\u03A9'); - entities.Add ("alpha", '\u03B1'); - entities.Add ("beta", '\u03B2'); - entities.Add ("gamma", '\u03B3'); - entities.Add ("delta", '\u03B4'); - entities.Add ("epsilon", '\u03B5'); - entities.Add ("zeta", '\u03B6'); - entities.Add ("eta", '\u03B7'); - entities.Add ("theta", '\u03B8'); - entities.Add ("iota", '\u03B9'); - entities.Add ("kappa", '\u03BA'); - entities.Add ("lambda", '\u03BB'); - entities.Add ("mu", '\u03BC'); - entities.Add ("nu", '\u03BD'); - entities.Add ("xi", '\u03BE'); - entities.Add ("omicron", '\u03BF'); - entities.Add ("pi", '\u03C0'); - entities.Add ("rho", '\u03C1'); - entities.Add ("sigmaf", '\u03C2'); - entities.Add ("sigma", '\u03C3'); - entities.Add ("tau", '\u03C4'); - entities.Add ("upsilon", '\u03C5'); - entities.Add ("phi", '\u03C6'); - entities.Add ("chi", '\u03C7'); - entities.Add ("psi", '\u03C8'); - entities.Add ("omega", '\u03C9'); - entities.Add ("thetasym", '\u03D1'); - entities.Add ("upsih", '\u03D2'); - entities.Add ("piv", '\u03D6'); - entities.Add ("bull", '\u2022'); - entities.Add ("hellip", '\u2026'); - entities.Add ("prime", '\u2032'); - entities.Add ("Prime", '\u2033'); - entities.Add ("oline", '\u203E'); - entities.Add ("frasl", '\u2044'); - entities.Add ("weierp", '\u2118'); - entities.Add ("image", '\u2111'); - entities.Add ("real", '\u211C'); - entities.Add ("trade", '\u2122'); - entities.Add ("alefsym", '\u2135'); - entities.Add ("larr", '\u2190'); - entities.Add ("uarr", '\u2191'); - entities.Add ("rarr", '\u2192'); - entities.Add ("darr", '\u2193'); - entities.Add ("harr", '\u2194'); - entities.Add ("crarr", '\u21B5'); - entities.Add ("lArr", '\u21D0'); - entities.Add ("uArr", '\u21D1'); - entities.Add ("rArr", '\u21D2'); - entities.Add ("dArr", '\u21D3'); - entities.Add ("hArr", '\u21D4'); - entities.Add ("forall", '\u2200'); - entities.Add ("part", '\u2202'); - entities.Add ("exist", '\u2203'); - entities.Add ("empty", '\u2205'); - entities.Add ("nabla", '\u2207'); - entities.Add ("isin", '\u2208'); - entities.Add ("notin", '\u2209'); - entities.Add ("ni", '\u220B'); - entities.Add ("prod", '\u220F'); - entities.Add ("sum", '\u2211'); - entities.Add ("minus", '\u2212'); - entities.Add ("lowast", '\u2217'); - entities.Add ("radic", '\u221A'); - entities.Add ("prop", '\u221D'); - entities.Add ("infin", '\u221E'); - entities.Add ("ang", '\u2220'); - entities.Add ("and", '\u2227'); - entities.Add ("or", '\u2228'); - entities.Add ("cap", '\u2229'); - entities.Add ("cup", '\u222A'); - entities.Add ("int", '\u222B'); - entities.Add ("there4", '\u2234'); - entities.Add ("sim", '\u223C'); - entities.Add ("cong", '\u2245'); - entities.Add ("asymp", '\u2248'); - entities.Add ("ne", '\u2260'); - entities.Add ("equiv", '\u2261'); - entities.Add ("le", '\u2264'); - entities.Add ("ge", '\u2265'); - entities.Add ("sub", '\u2282'); - entities.Add ("sup", '\u2283'); - entities.Add ("nsub", '\u2284'); - entities.Add ("sube", '\u2286'); - entities.Add ("supe", '\u2287'); - entities.Add ("oplus", '\u2295'); - entities.Add ("otimes", '\u2297'); - entities.Add ("perp", '\u22A5'); - entities.Add ("sdot", '\u22C5'); - entities.Add ("lceil", '\u2308'); - entities.Add ("rceil", '\u2309'); - entities.Add ("lfloor", '\u230A'); - entities.Add ("rfloor", '\u230B'); - entities.Add ("lang", '\u2329'); - entities.Add ("rang", '\u232A'); - entities.Add ("loz", '\u25CA'); - entities.Add ("spades", '\u2660'); - entities.Add ("clubs", '\u2663'); - entities.Add ("hearts", '\u2665'); - entities.Add ("diams", '\u2666'); - entities.Add ("quot", '\u0022'); - entities.Add ("amp", '\u0026'); - entities.Add ("lt", '\u003C'); - entities.Add ("gt", '\u003E'); - entities.Add ("OElig", '\u0152'); - entities.Add ("oelig", '\u0153'); - entities.Add ("Scaron", '\u0160'); - entities.Add ("scaron", '\u0161'); - entities.Add ("Yuml", '\u0178'); - entities.Add ("circ", '\u02C6'); - entities.Add ("tilde", '\u02DC'); - entities.Add ("ensp", '\u2002'); - entities.Add ("emsp", '\u2003'); - entities.Add ("thinsp", '\u2009'); - entities.Add ("zwnj", '\u200C'); - entities.Add ("zwj", '\u200D'); - entities.Add ("lrm", '\u200E'); - entities.Add ("rlm", '\u200F'); - entities.Add ("ndash", '\u2013'); - entities.Add ("mdash", '\u2014'); - entities.Add ("lsquo", '\u2018'); - entities.Add ("rsquo", '\u2019'); - entities.Add ("sbquo", '\u201A'); - entities.Add ("ldquo", '\u201C'); - entities.Add ("rdquo", '\u201D'); - entities.Add ("bdquo", '\u201E'); - entities.Add ("dagger", '\u2020'); - entities.Add ("Dagger", '\u2021'); - entities.Add ("permil", '\u2030'); - entities.Add ("lsaquo", '\u2039'); - entities.Add ("rsaquo", '\u203A'); - entities.Add ("euro", '\u20AC'); - } + // Must be sorted + static readonly long[] entities = new long[] { + (long)'A' << 56 | (long)'E' << 48 | (long)'l' << 40 | (long)'i' << 32 | (long)'g' << 24, + (long)'A' << 56 | (long)'a' << 48 | (long)'c' << 40 | (long)'u' << 32 | (long)'t' << 24 | (long)'e' << 16, + (long)'A' << 56 | (long)'c' << 48 | (long)'i' << 40 | (long)'r' << 32 | (long)'c' << 24, + (long)'A' << 56 | (long)'g' << 48 | (long)'r' << 40 | (long)'a' << 32 | (long)'v' << 24 | (long)'e' << 16, + (long)'A' << 56 | (long)'l' << 48 | (long)'p' << 40 | (long)'h' << 32 | (long)'a' << 24, + (long)'A' << 56 | (long)'r' << 48 | (long)'i' << 40 | (long)'n' << 32 | (long)'g' << 24, + (long)'A' << 56 | (long)'t' << 48 | (long)'i' << 40 | (long)'l' << 32 | (long)'d' << 24 | (long)'e' << 16, + (long)'A' << 56 | (long)'u' << 48 | (long)'m' << 40 | (long)'l' << 32, + (long)'B' << 56 | (long)'e' << 48 | (long)'t' << 40 | (long)'a' << 32, + (long)'C' << 56 | (long)'c' << 48 | (long)'e' << 40 | (long)'d' << 32 | (long)'i' << 24 | (long)'l' << 16, + (long)'C' << 56 | (long)'h' << 48 | (long)'i' << 40, + (long)'D' << 56 | (long)'a' << 48 | (long)'g' << 40 | (long)'g' << 32 | (long)'e' << 24 | (long)'r' << 16, + (long)'D' << 56 | (long)'e' << 48 | (long)'l' << 40 | (long)'t' << 32 | (long)'a' << 24, + (long)'E' << 56 | (long)'T' << 48 | (long)'H' << 40, + (long)'E' << 56 | (long)'a' << 48 | (long)'c' << 40 | (long)'u' << 32 | (long)'t' << 24 | (long)'e' << 16, + (long)'E' << 56 | (long)'c' << 48 | (long)'i' << 40 | (long)'r' << 32 | (long)'c' << 24, + (long)'E' << 56 | (long)'g' << 48 | (long)'r' << 40 | (long)'a' << 32 | (long)'v' << 24 | (long)'e' << 16, + (long)'E' << 56 | (long)'p' << 48 | (long)'s' << 40 | (long)'i' << 32 | (long)'l' << 24 | (long)'o' << 16 | (long)'n' << 8, + (long)'E' << 56 | (long)'t' << 48 | (long)'a' << 40, + (long)'E' << 56 | (long)'u' << 48 | (long)'m' << 40 | (long)'l' << 32, + (long)'G' << 56 | (long)'a' << 48 | (long)'m' << 40 | (long)'m' << 32 | (long)'a' << 24, + (long)'I' << 56 | (long)'a' << 48 | (long)'c' << 40 | (long)'u' << 32 | (long)'t' << 24 | (long)'e' << 16, + (long)'I' << 56 | (long)'c' << 48 | (long)'i' << 40 | (long)'r' << 32 | (long)'c' << 24, + (long)'I' << 56 | (long)'g' << 48 | (long)'r' << 40 | (long)'a' << 32 | (long)'v' << 24 | (long)'e' << 16, + (long)'I' << 56 | (long)'o' << 48 | (long)'t' << 40 | (long)'a' << 32, + (long)'I' << 56 | (long)'u' << 48 | (long)'m' << 40 | (long)'l' << 32, + (long)'K' << 56 | (long)'a' << 48 | (long)'p' << 40 | (long)'p' << 32 | (long)'a' << 24, + (long)'L' << 56 | (long)'a' << 48 | (long)'m' << 40 | (long)'b' << 32 | (long)'d' << 24 | (long)'a' << 16, + (long)'M' << 56 | (long)'u' << 48, + (long)'N' << 56 | (long)'t' << 48 | (long)'i' << 40 | (long)'l' << 32 | (long)'d' << 24 | (long)'e' << 16, + (long)'N' << 56 | (long)'u' << 48, + (long)'O' << 56 | (long)'E' << 48 | (long)'l' << 40 | (long)'i' << 32 | (long)'g' << 24, + (long)'O' << 56 | (long)'a' << 48 | (long)'c' << 40 | (long)'u' << 32 | (long)'t' << 24 | (long)'e' << 16, + (long)'O' << 56 | (long)'c' << 48 | (long)'i' << 40 | (long)'r' << 32 | (long)'c' << 24, + (long)'O' << 56 | (long)'g' << 48 | (long)'r' << 40 | (long)'a' << 32 | (long)'v' << 24 | (long)'e' << 16, + (long)'O' << 56 | (long)'m' << 48 | (long)'e' << 40 | (long)'g' << 32 | (long)'a' << 24, + (long)'O' << 56 | (long)'m' << 48 | (long)'i' << 40 | (long)'c' << 32 | (long)'r' << 24 | (long)'o' << 16 | (long)'n' << 8, + (long)'O' << 56 | (long)'s' << 48 | (long)'l' << 40 | (long)'a' << 32 | (long)'s' << 24 | (long)'h' << 16, + (long)'O' << 56 | (long)'t' << 48 | (long)'i' << 40 | (long)'l' << 32 | (long)'d' << 24 | (long)'e' << 16, + (long)'O' << 56 | (long)'u' << 48 | (long)'m' << 40 | (long)'l' << 32, + (long)'P' << 56 | (long)'h' << 48 | (long)'i' << 40, + (long)'P' << 56 | (long)'i' << 48, + (long)'P' << 56 | (long)'r' << 48 | (long)'i' << 40 | (long)'m' << 32 | (long)'e' << 24, + (long)'P' << 56 | (long)'s' << 48 | (long)'i' << 40, + (long)'R' << 56 | (long)'h' << 48 | (long)'o' << 40, + (long)'S' << 56 | (long)'c' << 48 | (long)'a' << 40 | (long)'r' << 32 | (long)'o' << 24 | (long)'n' << 16, + (long)'S' << 56 | (long)'i' << 48 | (long)'g' << 40 | (long)'m' << 32 | (long)'a' << 24, + (long)'T' << 56 | (long)'H' << 48 | (long)'O' << 40 | (long)'R' << 32 | (long)'N' << 24, + (long)'T' << 56 | (long)'a' << 48 | (long)'u' << 40, + (long)'T' << 56 | (long)'h' << 48 | (long)'e' << 40 | (long)'t' << 32 | (long)'a' << 24, + (long)'U' << 56 | (long)'a' << 48 | (long)'c' << 40 | (long)'u' << 32 | (long)'t' << 24 | (long)'e' << 16, + (long)'U' << 56 | (long)'c' << 48 | (long)'i' << 40 | (long)'r' << 32 | (long)'c' << 24, + (long)'U' << 56 | (long)'g' << 48 | (long)'r' << 40 | (long)'a' << 32 | (long)'v' << 24 | (long)'e' << 16, + (long)'U' << 56 | (long)'p' << 48 | (long)'s' << 40 | (long)'i' << 32 | (long)'l' << 24 | (long)'o' << 16 | (long)'n' << 8, + (long)'U' << 56 | (long)'u' << 48 | (long)'m' << 40 | (long)'l' << 32, + (long)'X' << 56 | (long)'i' << 48, + (long)'Y' << 56 | (long)'a' << 48 | (long)'c' << 40 | (long)'u' << 32 | (long)'t' << 24 | (long)'e' << 16, + (long)'Y' << 56 | (long)'u' << 48 | (long)'m' << 40 | (long)'l' << 32, + (long)'Z' << 56 | (long)'e' << 48 | (long)'t' << 40 | (long)'a' << 32, + (long)'a' << 56 | (long)'a' << 48 | (long)'c' << 40 | (long)'u' << 32 | (long)'t' << 24 | (long)'e' << 16, + (long)'a' << 56 | (long)'c' << 48 | (long)'i' << 40 | (long)'r' << 32 | (long)'c' << 24, + (long)'a' << 56 | (long)'c' << 48 | (long)'u' << 40 | (long)'t' << 32 | (long)'e' << 24, + (long)'a' << 56 | (long)'e' << 48 | (long)'l' << 40 | (long)'i' << 32 | (long)'g' << 24, + (long)'a' << 56 | (long)'g' << 48 | (long)'r' << 40 | (long)'a' << 32 | (long)'v' << 24 | (long)'e' << 16, + (long)'a' << 56 | (long)'l' << 48 | (long)'e' << 40 | (long)'f' << 32 | (long)'s' << 24 | (long)'y' << 16 | (long)'m' << 8, + (long)'a' << 56 | (long)'l' << 48 | (long)'p' << 40 | (long)'h' << 32 | (long)'a' << 24, + (long)'a' << 56 | (long)'m' << 48 | (long)'p' << 40, + (long)'a' << 56 | (long)'n' << 48 | (long)'d' << 40, + (long)'a' << 56 | (long)'n' << 48 | (long)'g' << 40, + (long)'a' << 56 | (long)'r' << 48 | (long)'i' << 40 | (long)'n' << 32 | (long)'g' << 24, + (long)'a' << 56 | (long)'s' << 48 | (long)'y' << 40 | (long)'m' << 32 | (long)'p' << 24, + (long)'a' << 56 | (long)'t' << 48 | (long)'i' << 40 | (long)'l' << 32 | (long)'d' << 24 | (long)'e' << 16, + (long)'a' << 56 | (long)'u' << 48 | (long)'m' << 40 | (long)'l' << 32, + (long)'b' << 56 | (long)'d' << 48 | (long)'q' << 40 | (long)'u' << 32 | (long)'o' << 24, + (long)'b' << 56 | (long)'e' << 48 | (long)'t' << 40 | (long)'a' << 32, + (long)'b' << 56 | (long)'r' << 48 | (long)'v' << 40 | (long)'b' << 32 | (long)'a' << 24 | (long)'r' << 16, + (long)'b' << 56 | (long)'u' << 48 | (long)'l' << 40 | (long)'l' << 32, + (long)'c' << 56 | (long)'a' << 48 | (long)'p' << 40, + (long)'c' << 56 | (long)'c' << 48 | (long)'e' << 40 | (long)'d' << 32 | (long)'i' << 24 | (long)'l' << 16, + (long)'c' << 56 | (long)'e' << 48 | (long)'d' << 40 | (long)'i' << 32 | (long)'l' << 24, + (long)'c' << 56 | (long)'e' << 48 | (long)'n' << 40 | (long)'t' << 32, + (long)'c' << 56 | (long)'h' << 48 | (long)'i' << 40, + (long)'c' << 56 | (long)'i' << 48 | (long)'r' << 40 | (long)'c' << 32, + (long)'c' << 56 | (long)'l' << 48 | (long)'u' << 40 | (long)'b' << 32 | (long)'s' << 24, + (long)'c' << 56 | (long)'o' << 48 | (long)'n' << 40 | (long)'g' << 32, + (long)'c' << 56 | (long)'o' << 48 | (long)'p' << 40 | (long)'y' << 32, + (long)'c' << 56 | (long)'r' << 48 | (long)'a' << 40 | (long)'r' << 32 | (long)'r' << 24, + (long)'c' << 56 | (long)'u' << 48 | (long)'p' << 40, + (long)'c' << 56 | (long)'u' << 48 | (long)'r' << 40 | (long)'r' << 32 | (long)'e' << 24 | (long)'n' << 16, + (long)'d' << 56 | (long)'A' << 48 | (long)'r' << 40 | (long)'r' << 32, + (long)'d' << 56 | (long)'a' << 48 | (long)'g' << 40 | (long)'g' << 32 | (long)'e' << 24 | (long)'r' << 16, + (long)'d' << 56 | (long)'a' << 48 | (long)'r' << 40 | (long)'r' << 32, + (long)'d' << 56 | (long)'e' << 48 | (long)'g' << 40, + (long)'d' << 56 | (long)'e' << 48 | (long)'l' << 40 | (long)'t' << 32 | (long)'a' << 24, + (long)'d' << 56 | (long)'i' << 48 | (long)'a' << 40 | (long)'m' << 32 | (long)'s' << 24, + (long)'d' << 56 | (long)'i' << 48 | (long)'v' << 40 | (long)'i' << 32 | (long)'d' << 24 | (long)'e' << 16, + (long)'e' << 56 | (long)'a' << 48 | (long)'c' << 40 | (long)'u' << 32 | (long)'t' << 24 | (long)'e' << 16, + (long)'e' << 56 | (long)'c' << 48 | (long)'i' << 40 | (long)'r' << 32 | (long)'c' << 24, + (long)'e' << 56 | (long)'g' << 48 | (long)'r' << 40 | (long)'a' << 32 | (long)'v' << 24 | (long)'e' << 16, + (long)'e' << 56 | (long)'m' << 48 | (long)'p' << 40 | (long)'t' << 32 | (long)'y' << 24, + (long)'e' << 56 | (long)'m' << 48 | (long)'s' << 40 | (long)'p' << 32, + (long)'e' << 56 | (long)'n' << 48 | (long)'s' << 40 | (long)'p' << 32, + (long)'e' << 56 | (long)'p' << 48 | (long)'s' << 40 | (long)'i' << 32 | (long)'l' << 24 | (long)'o' << 16 | (long)'n' << 8, + (long)'e' << 56 | (long)'q' << 48 | (long)'u' << 40 | (long)'i' << 32 | (long)'v' << 24, + (long)'e' << 56 | (long)'t' << 48 | (long)'a' << 40, + (long)'e' << 56 | (long)'t' << 48 | (long)'h' << 40, + (long)'e' << 56 | (long)'u' << 48 | (long)'m' << 40 | (long)'l' << 32, + (long)'e' << 56 | (long)'u' << 48 | (long)'r' << 40 | (long)'o' << 32, + (long)'e' << 56 | (long)'x' << 48 | (long)'i' << 40 | (long)'s' << 32 | (long)'t' << 24, + (long)'f' << 56 | (long)'n' << 48 | (long)'o' << 40 | (long)'f' << 32, + (long)'f' << 56 | (long)'o' << 48 | (long)'r' << 40 | (long)'a' << 32 | (long)'l' << 24 | (long)'l' << 16, + (long)'f' << 56 | (long)'r' << 48 | (long)'a' << 40 | (long)'c' << 32 | (long)'1' << 24 | (long)'2' << 16, + (long)'f' << 56 | (long)'r' << 48 | (long)'a' << 40 | (long)'c' << 32 | (long)'1' << 24 | (long)'4' << 16, + (long)'f' << 56 | (long)'r' << 48 | (long)'a' << 40 | (long)'c' << 32 | (long)'3' << 24 | (long)'4' << 16, + (long)'f' << 56 | (long)'r' << 48 | (long)'a' << 40 | (long)'s' << 32 | (long)'l' << 24, + (long)'g' << 56 | (long)'a' << 48 | (long)'m' << 40 | (long)'m' << 32 | (long)'a' << 24, + (long)'g' << 56 | (long)'e' << 48, + (long)'g' << 56 | (long)'t' << 48, + (long)'h' << 56 | (long)'A' << 48 | (long)'r' << 40 | (long)'r' << 32, + (long)'h' << 56 | (long)'a' << 48 | (long)'r' << 40 | (long)'r' << 32, + (long)'h' << 56 | (long)'e' << 48 | (long)'a' << 40 | (long)'r' << 32 | (long)'t' << 24 | (long)'s' << 16, + (long)'h' << 56 | (long)'e' << 48 | (long)'l' << 40 | (long)'l' << 32 | (long)'i' << 24 | (long)'p' << 16, + (long)'i' << 56 | (long)'a' << 48 | (long)'c' << 40 | (long)'u' << 32 | (long)'t' << 24 | (long)'e' << 16, + (long)'i' << 56 | (long)'c' << 48 | (long)'i' << 40 | (long)'r' << 32 | (long)'c' << 24, + (long)'i' << 56 | (long)'e' << 48 | (long)'x' << 40 | (long)'c' << 32 | (long)'l' << 24, + (long)'i' << 56 | (long)'g' << 48 | (long)'r' << 40 | (long)'a' << 32 | (long)'v' << 24 | (long)'e' << 16, + (long)'i' << 56 | (long)'m' << 48 | (long)'a' << 40 | (long)'g' << 32 | (long)'e' << 24, + (long)'i' << 56 | (long)'n' << 48 | (long)'f' << 40 | (long)'i' << 32 | (long)'n' << 24, + (long)'i' << 56 | (long)'n' << 48 | (long)'t' << 40, + (long)'i' << 56 | (long)'o' << 48 | (long)'t' << 40 | (long)'a' << 32, + (long)'i' << 56 | (long)'q' << 48 | (long)'u' << 40 | (long)'e' << 32 | (long)'s' << 24 | (long)'t' << 16, + (long)'i' << 56 | (long)'s' << 48 | (long)'i' << 40 | (long)'n' << 32, + (long)'i' << 56 | (long)'u' << 48 | (long)'m' << 40 | (long)'l' << 32, + (long)'k' << 56 | (long)'a' << 48 | (long)'p' << 40 | (long)'p' << 32 | (long)'a' << 24, + (long)'l' << 56 | (long)'A' << 48 | (long)'r' << 40 | (long)'r' << 32, + (long)'l' << 56 | (long)'a' << 48 | (long)'m' << 40 | (long)'b' << 32 | (long)'d' << 24 | (long)'a' << 16, + (long)'l' << 56 | (long)'a' << 48 | (long)'n' << 40 | (long)'g' << 32, + (long)'l' << 56 | (long)'a' << 48 | (long)'q' << 40 | (long)'u' << 32 | (long)'o' << 24, + (long)'l' << 56 | (long)'a' << 48 | (long)'r' << 40 | (long)'r' << 32, + (long)'l' << 56 | (long)'c' << 48 | (long)'e' << 40 | (long)'i' << 32 | (long)'l' << 24, + (long)'l' << 56 | (long)'d' << 48 | (long)'q' << 40 | (long)'u' << 32 | (long)'o' << 24, + (long)'l' << 56 | (long)'e' << 48, + (long)'l' << 56 | (long)'f' << 48 | (long)'l' << 40 | (long)'o' << 32 | (long)'o' << 24 | (long)'r' << 16, + (long)'l' << 56 | (long)'o' << 48 | (long)'w' << 40 | (long)'a' << 32 | (long)'s' << 24 | (long)'t' << 16, + (long)'l' << 56 | (long)'o' << 48 | (long)'z' << 40, + (long)'l' << 56 | (long)'r' << 48 | (long)'m' << 40, + (long)'l' << 56 | (long)'s' << 48 | (long)'a' << 40 | (long)'q' << 32 | (long)'u' << 24 | (long)'o' << 16, + (long)'l' << 56 | (long)'s' << 48 | (long)'q' << 40 | (long)'u' << 32 | (long)'o' << 24, + (long)'l' << 56 | (long)'t' << 48, + (long)'m' << 56 | (long)'a' << 48 | (long)'c' << 40 | (long)'r' << 32, + (long)'m' << 56 | (long)'d' << 48 | (long)'a' << 40 | (long)'s' << 32 | (long)'h' << 24, + (long)'m' << 56 | (long)'i' << 48 | (long)'c' << 40 | (long)'r' << 32 | (long)'o' << 24, + (long)'m' << 56 | (long)'i' << 48 | (long)'d' << 40 | (long)'d' << 32 | (long)'o' << 24 | (long)'t' << 16, + (long)'m' << 56 | (long)'i' << 48 | (long)'n' << 40 | (long)'u' << 32 | (long)'s' << 24, + (long)'m' << 56 | (long)'u' << 48, + (long)'n' << 56 | (long)'a' << 48 | (long)'b' << 40 | (long)'l' << 32 | (long)'a' << 24, + (long)'n' << 56 | (long)'b' << 48 | (long)'s' << 40 | (long)'p' << 32, + (long)'n' << 56 | (long)'d' << 48 | (long)'a' << 40 | (long)'s' << 32 | (long)'h' << 24, + (long)'n' << 56 | (long)'e' << 48, + (long)'n' << 56 | (long)'i' << 48, + (long)'n' << 56 | (long)'o' << 48 | (long)'t' << 40, + (long)'n' << 56 | (long)'o' << 48 | (long)'t' << 40 | (long)'i' << 32 | (long)'n' << 24, + (long)'n' << 56 | (long)'s' << 48 | (long)'u' << 40 | (long)'b' << 32, + (long)'n' << 56 | (long)'t' << 48 | (long)'i' << 40 | (long)'l' << 32 | (long)'d' << 24 | (long)'e' << 16, + (long)'n' << 56 | (long)'u' << 48, + (long)'o' << 56 | (long)'a' << 48 | (long)'c' << 40 | (long)'u' << 32 | (long)'t' << 24 | (long)'e' << 16, + (long)'o' << 56 | (long)'c' << 48 | (long)'i' << 40 | (long)'r' << 32 | (long)'c' << 24, + (long)'o' << 56 | (long)'e' << 48 | (long)'l' << 40 | (long)'i' << 32 | (long)'g' << 24, + (long)'o' << 56 | (long)'g' << 48 | (long)'r' << 40 | (long)'a' << 32 | (long)'v' << 24 | (long)'e' << 16, + (long)'o' << 56 | (long)'l' << 48 | (long)'i' << 40 | (long)'n' << 32 | (long)'e' << 24, + (long)'o' << 56 | (long)'m' << 48 | (long)'e' << 40 | (long)'g' << 32 | (long)'a' << 24, + (long)'o' << 56 | (long)'m' << 48 | (long)'i' << 40 | (long)'c' << 32 | (long)'r' << 24 | (long)'o' << 16 | (long)'n' << 8, + (long)'o' << 56 | (long)'p' << 48 | (long)'l' << 40 | (long)'u' << 32 | (long)'s' << 24, + (long)'o' << 56 | (long)'r' << 48, + (long)'o' << 56 | (long)'r' << 48 | (long)'d' << 40 | (long)'f' << 32, + (long)'o' << 56 | (long)'r' << 48 | (long)'d' << 40 | (long)'m' << 32, + (long)'o' << 56 | (long)'s' << 48 | (long)'l' << 40 | (long)'a' << 32 | (long)'s' << 24 | (long)'h' << 16, + (long)'o' << 56 | (long)'t' << 48 | (long)'i' << 40 | (long)'l' << 32 | (long)'d' << 24 | (long)'e' << 16, + (long)'o' << 56 | (long)'t' << 48 | (long)'i' << 40 | (long)'m' << 32 | (long)'e' << 24 | (long)'s' << 16, + (long)'o' << 56 | (long)'u' << 48 | (long)'m' << 40 | (long)'l' << 32, + (long)'p' << 56 | (long)'a' << 48 | (long)'r' << 40 | (long)'a' << 32, + (long)'p' << 56 | (long)'a' << 48 | (long)'r' << 40 | (long)'t' << 32, + (long)'p' << 56 | (long)'e' << 48 | (long)'r' << 40 | (long)'m' << 32 | (long)'i' << 24 | (long)'l' << 16, + (long)'p' << 56 | (long)'e' << 48 | (long)'r' << 40 | (long)'p' << 32, + (long)'p' << 56 | (long)'h' << 48 | (long)'i' << 40, + (long)'p' << 56 | (long)'i' << 48, + (long)'p' << 56 | (long)'i' << 48 | (long)'v' << 40, + (long)'p' << 56 | (long)'l' << 48 | (long)'u' << 40 | (long)'s' << 32 | (long)'m' << 24 | (long)'n' << 16, + (long)'p' << 56 | (long)'o' << 48 | (long)'u' << 40 | (long)'n' << 32 | (long)'d' << 24, + (long)'p' << 56 | (long)'r' << 48 | (long)'i' << 40 | (long)'m' << 32 | (long)'e' << 24, + (long)'p' << 56 | (long)'r' << 48 | (long)'o' << 40 | (long)'d' << 32, + (long)'p' << 56 | (long)'r' << 48 | (long)'o' << 40 | (long)'p' << 32, + (long)'p' << 56 | (long)'s' << 48 | (long)'i' << 40, + (long)'q' << 56 | (long)'u' << 48 | (long)'o' << 40 | (long)'t' << 32, + (long)'r' << 56 | (long)'A' << 48 | (long)'r' << 40 | (long)'r' << 32, + (long)'r' << 56 | (long)'a' << 48 | (long)'d' << 40 | (long)'i' << 32 | (long)'c' << 24, + (long)'r' << 56 | (long)'a' << 48 | (long)'n' << 40 | (long)'g' << 32, + (long)'r' << 56 | (long)'a' << 48 | (long)'q' << 40 | (long)'u' << 32 | (long)'o' << 24, + (long)'r' << 56 | (long)'a' << 48 | (long)'r' << 40 | (long)'r' << 32, + (long)'r' << 56 | (long)'c' << 48 | (long)'e' << 40 | (long)'i' << 32 | (long)'l' << 24, + (long)'r' << 56 | (long)'d' << 48 | (long)'q' << 40 | (long)'u' << 32 | (long)'o' << 24, + (long)'r' << 56 | (long)'e' << 48 | (long)'a' << 40 | (long)'l' << 32, + (long)'r' << 56 | (long)'e' << 48 | (long)'g' << 40, + (long)'r' << 56 | (long)'f' << 48 | (long)'l' << 40 | (long)'o' << 32 | (long)'o' << 24 | (long)'r' << 16, + (long)'r' << 56 | (long)'h' << 48 | (long)'o' << 40, + (long)'r' << 56 | (long)'l' << 48 | (long)'m' << 40, + (long)'r' << 56 | (long)'s' << 48 | (long)'a' << 40 | (long)'q' << 32 | (long)'u' << 24 | (long)'o' << 16, + (long)'r' << 56 | (long)'s' << 48 | (long)'q' << 40 | (long)'u' << 32 | (long)'o' << 24, + (long)'s' << 56 | (long)'b' << 48 | (long)'q' << 40 | (long)'u' << 32 | (long)'o' << 24, + (long)'s' << 56 | (long)'c' << 48 | (long)'a' << 40 | (long)'r' << 32 | (long)'o' << 24 | (long)'n' << 16, + (long)'s' << 56 | (long)'d' << 48 | (long)'o' << 40 | (long)'t' << 32, + (long)'s' << 56 | (long)'e' << 48 | (long)'c' << 40 | (long)'t' << 32, + (long)'s' << 56 | (long)'h' << 48 | (long)'y' << 40, + (long)'s' << 56 | (long)'i' << 48 | (long)'g' << 40 | (long)'m' << 32 | (long)'a' << 24, + (long)'s' << 56 | (long)'i' << 48 | (long)'g' << 40 | (long)'m' << 32 | (long)'a' << 24 | (long)'f' << 16, + (long)'s' << 56 | (long)'i' << 48 | (long)'m' << 40, + (long)'s' << 56 | (long)'p' << 48 | (long)'a' << 40 | (long)'d' << 32 | (long)'e' << 24 | (long)'s' << 16, + (long)'s' << 56 | (long)'u' << 48 | (long)'b' << 40, + (long)'s' << 56 | (long)'u' << 48 | (long)'b' << 40 | (long)'e' << 32, + (long)'s' << 56 | (long)'u' << 48 | (long)'m' << 40, + (long)'s' << 56 | (long)'u' << 48 | (long)'p' << 40, + (long)'s' << 56 | (long)'u' << 48 | (long)'p' << 40 | (long)'1' << 32, + (long)'s' << 56 | (long)'u' << 48 | (long)'p' << 40 | (long)'2' << 32, + (long)'s' << 56 | (long)'u' << 48 | (long)'p' << 40 | (long)'3' << 32, + (long)'s' << 56 | (long)'u' << 48 | (long)'p' << 40 | (long)'e' << 32, + (long)'s' << 56 | (long)'z' << 48 | (long)'l' << 40 | (long)'i' << 32 | (long)'g' << 24, + (long)'t' << 56 | (long)'a' << 48 | (long)'u' << 40, + (long)'t' << 56 | (long)'h' << 48 | (long)'e' << 40 | (long)'r' << 32 | (long)'e' << 24 | (long)'4' << 16, + (long)'t' << 56 | (long)'h' << 48 | (long)'e' << 40 | (long)'t' << 32 | (long)'a' << 24, + (long)'t' << 56 | (long)'h' << 48 | (long)'e' << 40 | (long)'t' << 32 | (long)'a' << 24 | (long)'s' << 16 | (long)'y' << 8 | (long)'m' << 0, + (long)'t' << 56 | (long)'h' << 48 | (long)'i' << 40 | (long)'n' << 32 | (long)'s' << 24 | (long)'p' << 16, + (long)'t' << 56 | (long)'h' << 48 | (long)'o' << 40 | (long)'r' << 32 | (long)'n' << 24, + (long)'t' << 56 | (long)'i' << 48 | (long)'l' << 40 | (long)'d' << 32 | (long)'e' << 24, + (long)'t' << 56 | (long)'i' << 48 | (long)'m' << 40 | (long)'e' << 32 | (long)'s' << 24, + (long)'t' << 56 | (long)'r' << 48 | (long)'a' << 40 | (long)'d' << 32 | (long)'e' << 24, + (long)'u' << 56 | (long)'A' << 48 | (long)'r' << 40 | (long)'r' << 32, + (long)'u' << 56 | (long)'a' << 48 | (long)'c' << 40 | (long)'u' << 32 | (long)'t' << 24 | (long)'e' << 16, + (long)'u' << 56 | (long)'a' << 48 | (long)'r' << 40 | (long)'r' << 32, + (long)'u' << 56 | (long)'c' << 48 | (long)'i' << 40 | (long)'r' << 32 | (long)'c' << 24, + (long)'u' << 56 | (long)'g' << 48 | (long)'r' << 40 | (long)'a' << 32 | (long)'v' << 24 | (long)'e' << 16, + (long)'u' << 56 | (long)'m' << 48 | (long)'l' << 40, + (long)'u' << 56 | (long)'p' << 48 | (long)'s' << 40 | (long)'i' << 32 | (long)'h' << 24, + (long)'u' << 56 | (long)'p' << 48 | (long)'s' << 40 | (long)'i' << 32 | (long)'l' << 24 | (long)'o' << 16 | (long)'n' << 8, + (long)'u' << 56 | (long)'u' << 48 | (long)'m' << 40 | (long)'l' << 32, + (long)'w' << 56 | (long)'e' << 48 | (long)'i' << 40 | (long)'e' << 32 | (long)'r' << 24 | (long)'p' << 16, + (long)'x' << 56 | (long)'i' << 48, + (long)'y' << 56 | (long)'a' << 48 | (long)'c' << 40 | (long)'u' << 32 | (long)'t' << 24 | (long)'e' << 16, + (long)'y' << 56 | (long)'e' << 48 | (long)'n' << 40, + (long)'y' << 56 | (long)'u' << 48 | (long)'m' << 40 | (long)'l' << 32, + (long)'z' << 56 | (long)'e' << 48 | (long)'t' << 40 | (long)'a' << 32, + (long)'z' << 56 | (long)'w' << 48 | (long)'j' << 40, + (long)'z' << 56 | (long)'w' << 48 | (long)'n' << 40 | (long)'j' << 32 + }; + + static readonly char[] entities_values = new char[] { + '\u00C6', + '\u00C1', + '\u00C2', + '\u00C0', + '\u0391', + '\u00C5', + '\u00C3', + '\u00C4', + '\u0392', + '\u00C7', + '\u03A7', + '\u2021', + '\u0394', + '\u00D0', + '\u00C9', + '\u00CA', + '\u00C8', + '\u0395', + '\u0397', + '\u00CB', + '\u0393', + '\u00CD', + '\u00CE', + '\u00CC', + '\u0399', + '\u00CF', + '\u039A', + '\u039B', + '\u039C', + '\u00D1', + '\u039D', + '\u0152', + '\u00D3', + '\u00D4', + '\u00D2', + '\u03A9', + '\u039F', + '\u00D8', + '\u00D5', + '\u00D6', + '\u03A6', + '\u03A0', + '\u2033', + '\u03A8', + '\u03A1', + '\u0160', + '\u03A3', + '\u00DE', + '\u03A4', + '\u0398', + '\u00DA', + '\u00DB', + '\u00D9', + '\u03A5', + '\u00DC', + '\u039E', + '\u00DD', + '\u0178', + '\u0396', + '\u00E1', + '\u00E2', + '\u00B4', + '\u00E6', + '\u00E0', + '\u2135', + '\u03B1', + '\u0026', + '\u2227', + '\u2220', + '\u00E5', + '\u2248', + '\u00E3', + '\u00E4', + '\u201E', + '\u03B2', + '\u00A6', + '\u2022', + '\u2229', + '\u00E7', + '\u00B8', + '\u00A2', + '\u03C7', + '\u02C6', + '\u2663', + '\u2245', + '\u00A9', + '\u21B5', + '\u222A', + '\u00A4', + '\u21D3', + '\u2020', + '\u2193', + '\u00B0', + '\u03B4', + '\u2666', + '\u00F7', + '\u00E9', + '\u00EA', + '\u00E8', + '\u2205', + '\u2003', + '\u2002', + '\u03B5', + '\u2261', + '\u03B7', + '\u00F0', + '\u00EB', + '\u20AC', + '\u2203', + '\u0192', + '\u2200', + '\u00BD', + '\u00BC', + '\u00BE', + '\u2044', + '\u03B3', + '\u2265', + '\u003E', + '\u21D4', + '\u2194', + '\u2665', + '\u2026', + '\u00ED', + '\u00EE', + '\u00A1', + '\u00EC', + '\u2111', + '\u221E', + '\u222B', + '\u03B9', + '\u00BF', + '\u2208', + '\u00EF', + '\u03BA', + '\u21D0', + '\u03BB', + '\u2329', + '\u00AB', + '\u2190', + '\u2308', + '\u201C', + '\u2264', + '\u230A', + '\u2217', + '\u25CA', + '\u200E', + '\u2039', + '\u2018', + '\u003C', + '\u00AF', + '\u2014', + '\u00B5', + '\u00B7', + '\u2212', + '\u03BC', + '\u2207', + '\u00A0', + '\u2013', + '\u2260', + '\u220B', + '\u00AC', + '\u2209', + '\u2284', + '\u00F1', + '\u03BD', + '\u00F3', + '\u00F4', + '\u0153', + '\u00F2', + '\u203E', + '\u03C9', + '\u03BF', + '\u2295', + '\u2228', + '\u00AA', + '\u00BA', + '\u00F8', + '\u00F5', + '\u2297', + '\u00F6', + '\u00B6', + '\u2202', + '\u2030', + '\u22A5', + '\u03C6', + '\u03C0', + '\u03D6', + '\u00B1', + '\u00A3', + '\u2032', + '\u220F', + '\u221D', + '\u03C8', + '\u0022', + '\u21D2', + '\u221A', + '\u232A', + '\u00BB', + '\u2192', + '\u2309', + '\u201D', + '\u211C', + '\u00AE', + '\u230B', + '\u03C1', + '\u200F', + '\u203A', + '\u2019', + '\u201A', + '\u0161', + '\u22C5', + '\u00A7', + '\u00AD', + '\u03C3', + '\u03C2', + '\u223C', + '\u2660', + '\u2282', + '\u2286', + '\u2211', + '\u2283', + '\u00B9', + '\u00B2', + '\u00B3', + '\u2287', + '\u00DF', + '\u03C4', + '\u2234', + '\u03B8', + '\u03D1', + '\u2009', + '\u00FE', + '\u02DC', + '\u00D7', + '\u2122', + '\u21D1', + '\u00FA', + '\u2191', + '\u00FB', + '\u00F9', + '\u00A8', + '\u03D2', + '\u03C5', + '\u00FC', + '\u2118', + '\u03BE', + '\u00FD', + '\u00A5', + '\u00FF', + '\u03B6', + '\u200D', + '\u200C' + }; - public HttpUtility () - { - } - - #endregion // Constructors - #region Methods public static void HtmlAttributeEncode (string s, TextWriter output) @@ -816,6 +1043,36 @@ namespace System.Net { return result.ToArray (); } + static string ConvertKeyToEntity (string key) + { + var token = CalculateKeyValue (key); + if (token == 0) + return key; + + var idx = Array.BinarySearch (entities, token); + if (idx < 0) + return key; + + return entities_values [idx].ToString (); + } + + static long CalculateKeyValue (string s) + { + if (s.Length > 8) + return 0; + + long key = 0; + for (int i = 0; i < s.Length; ++i) { + long ch = s[i]; + if (ch > 'z' || ch < '0') + return 0; + + key |= ch << ((7 - i) * 8); + } + + return key; + } + /// /// Decodes an HTML-encoded string and returns the decoded string. /// @@ -884,8 +1141,10 @@ namespace System.Net { entity.Append (c); if (c == ';') { string key = entity.ToString (); - if (key.Length > 1 && Entities.ContainsKey (key.Substring (1, key.Length - 2))) - key = Entities [key.Substring (1, key.Length - 2)].ToString (); + if (key.Length > 1) { + var skey = key.Substring (1, key.Length - 2); + key = ConvertKeyToEntity (skey); + } output.Append (key); state = 0; diff --git a/mcs/class/System/System.Security.Cryptography.X509Certificates/X500DistinguishedName.cs b/mcs/class/System/System.Security.Cryptography.X509Certificates/X500DistinguishedName.cs index 54f5691ca3e..6130257f88f 100644 --- a/mcs/class/System/System.Security.Cryptography.X509Certificates/X500DistinguishedName.cs +++ b/mcs/class/System/System.Security.Cryptography.X509Certificates/X500DistinguishedName.cs @@ -28,11 +28,13 @@ #if SECURITY_DEP +extern alias MonoSecurity; + using System.Collections; using System.Text; -using Mono.Security; -using MX = Mono.Security.X509; +using MonoSecurity::Mono.Security; +using MX = MonoSecurity::Mono.Security.X509; namespace System.Security.Cryptography.X509Certificates { @@ -91,7 +93,7 @@ namespace System.Security.Cryptography.X509Certificates { RawData = new byte [2] { 0x30, 0x00 }; DecodeRawData (); } else { - ASN1 dn = MX.X501.FromString (distinguishedName); + var dn = MX.X501.FromString (distinguishedName); if ((flag & X500DistinguishedNameFlags.Reversed) != 0) { ASN1 rdn = new ASN1 (0x30); for (int i = dn.Count - 1; i >= 0; i--) diff --git a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension.cs b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension.cs index 59eb0e209a4..1a3eff95e7d 100644 --- a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension.cs +++ b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension.cs @@ -31,9 +31,11 @@ #if SECURITY_DEP +extern alias MonoSecurity; + using System.Text; -using Mono.Security; +using MonoSecurity::Mono.Security; namespace System.Security.Cryptography.X509Certificates { diff --git a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Chain.cs b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Chain.cs index 0cab0a8bdf8..99f40f4d0c1 100644 --- a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Chain.cs +++ b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Chain.cs @@ -893,7 +893,7 @@ namespace System.Security.Cryptography.X509Certificates { string ski = GetSubjectKeyIdentifier (caCertificate); // consider that the LocalMachine directories could not exists... and cannot be created by the user - MX.X509Crl result = (LMCAStore.Store == null) ? null : CheckCrls (subject, ski, LMCAStore.Store.Crls); + var result = (LMCAStore.Store == null) ? null : CheckCrls (subject, ski, LMCAStore.Store.Crls); if (result != null) return result; if (location == StoreLocation.CurrentUser) { diff --git a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509EnhancedKeyUsageExtension.cs b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509EnhancedKeyUsageExtension.cs index efe2abed317..ebc7df34b7e 100644 --- a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509EnhancedKeyUsageExtension.cs +++ b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509EnhancedKeyUsageExtension.cs @@ -28,9 +28,11 @@ #if SECURITY_DEP +extern alias MonoSecurity; + using System.Text; -using Mono.Security; +using MonoSecurity::Mono.Security; namespace System.Security.Cryptography.X509Certificates { diff --git a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509KeyUsageExtension.cs b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509KeyUsageExtension.cs index ce5df95e0b6..ac7e0538751 100644 --- a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509KeyUsageExtension.cs +++ b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509KeyUsageExtension.cs @@ -30,9 +30,11 @@ #if SECURITY_DEP +extern alias MonoSecurity; + using System.Text; -using Mono.Security; +using MonoSecurity::Mono.Security; namespace System.Security.Cryptography.X509Certificates { diff --git a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Store.cs b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Store.cs index b527f34e39f..208754d9fd8 100644 --- a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Store.cs +++ b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Store.cs @@ -29,8 +29,10 @@ #if SECURITY_DEP +extern alias MonoSecurity; + using System.Security.Permissions; -using MX = Mono.Security.X509; +using MX = MonoSecurity::Mono.Security.X509; namespace System.Security.Cryptography.X509Certificates { diff --git a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509SubjectKeyIdentifierExtension.cs b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509SubjectKeyIdentifierExtension.cs index d24e4806bb9..b7a7af852fc 100644 --- a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509SubjectKeyIdentifierExtension.cs +++ b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509SubjectKeyIdentifierExtension.cs @@ -30,10 +30,12 @@ #if SECURITY_DEP +extern alias MonoSecurity; + using System.Text; -using Mono.Security; -using Mono.Security.Cryptography; +using MonoSecurity::Mono.Security; +using MonoSecurity::Mono.Security.Cryptography; namespace System.Security.Cryptography.X509Certificates { diff --git a/mcs/class/System/System.Security.Cryptography/AsnEncodedData.cs b/mcs/class/System/System.Security.Cryptography/AsnEncodedData.cs index b4c17f84103..14b8ccedfab 100644 --- a/mcs/class/System/System.Security.Cryptography/AsnEncodedData.cs +++ b/mcs/class/System/System.Security.Cryptography/AsnEncodedData.cs @@ -29,11 +29,13 @@ #if SECURITY_DEP +extern alias MonoSecurity; + using System.Security.Cryptography.X509Certificates; using System.Text; -using Mono.Security; -using Mono.Security.Cryptography; +using MonoSecurity::Mono.Security; +using MonoSecurity::Mono.Security.Cryptography; namespace System.Security.Cryptography { diff --git a/mcs/class/System/Test/System.ComponentModel.Design.Serialization/InstanceDescriptorTest.cs b/mcs/class/System/Test/System.ComponentModel.Design.Serialization/InstanceDescriptorTest.cs index 7fe4c29dbf3..16d12af943c 100644 --- a/mcs/class/System/Test/System.ComponentModel.Design.Serialization/InstanceDescriptorTest.cs +++ b/mcs/class/System/Test/System.ComponentModel.Design.Serialization/InstanceDescriptorTest.cs @@ -188,6 +188,10 @@ namespace MonoTests.System.ComponentModel.Design.Serialization { [Test] public void Property_Arguments_Mismatch () { +#if MOBILE + // ensure the property is not linked out of the application since it make the test fails + Assert.NotNull (Thread.CurrentPrincipal, "pre-test"); +#endif PropertyInfo pi = typeof (Thread).GetProperty ("CurrentPrincipal"); InstanceDescriptor id = new InstanceDescriptor (pi, new object [] { url }); @@ -207,6 +211,10 @@ namespace MonoTests.System.ComponentModel.Design.Serialization { [Test] public void Property_Arguments_Null () { +#if MOBILE + // ensure the property is not linked out of the application since it make the test fails + Assert.NotNull (Thread.CurrentPrincipal, "pre-test"); +#endif PropertyInfo pi = typeof (Thread).GetProperty ("CurrentPrincipal"); InstanceDescriptor id = new InstanceDescriptor (pi, null); diff --git a/mcs/class/System/Test/System.ComponentModel/TypeDescriptorTests.cs b/mcs/class/System/Test/System.ComponentModel/TypeDescriptorTests.cs index 2fdd8db64d1..a09776a9c00 100644 --- a/mcs/class/System/Test/System.ComponentModel/TypeDescriptorTests.cs +++ b/mcs/class/System/Test/System.ComponentModel/TypeDescriptorTests.cs @@ -1465,6 +1465,10 @@ namespace MonoTests.System.ComponentModel [Test] public void GetProperties_Order () { +#if MOBILE + // Component.Container will be be linked out (when using Link SDK) if unused + Assert.Null (new Component ().Container, "pre-test"); +#endif MyComponent com = new MyComponent (new MyContainer ()); PropertyDescriptorCollection col = TypeDescriptor.GetProperties (com); diff --git a/mcs/class/System/Test/System.Net/WebClientTest.cs b/mcs/class/System/Test/System.Net/WebClientTest.cs index 9917fa9a441..3505926f410 100644 --- a/mcs/class/System/Test/System.Net/WebClientTest.cs +++ b/mcs/class/System/Test/System.Net/WebClientTest.cs @@ -193,10 +193,10 @@ namespace MonoTests.System.Net [Test] // DownloadFile (string, string) public void DownloadFile1_Address_SchemeNotSupported () { + string file = Path.Combine (Path.GetTempPath (), "tmp.out"); WebClient wc = new WebClient (); try { - wc.DownloadFile ("tp://scheme.notsupported", - "tmp.out"); + wc.DownloadFile ("tp://scheme.notsupported", file); Assert.Fail ("#1"); } catch (WebException ex) { // An error occurred performing a WebClient request @@ -212,6 +212,10 @@ namespace MonoTests.System.Net Assert.IsNull (inner.InnerException, "#8"); Assert.IsNotNull (inner.Message, "#9"); } + finally { + if (File.Exists (file)) + File.Delete (file); + } } [Test] // DownloadFile (string, string) @@ -270,10 +274,10 @@ namespace MonoTests.System.Net [Test] // DownloadFile (Uri, string) public void DownloadFile2_Address_SchemeNotSupported () { + string file = Path.Combine (Path.GetTempPath (), "tmp.out"); WebClient wc = new WebClient (); try { - wc.DownloadFile (new Uri ("tp://scheme.notsupported"), - "tmp.out"); + wc.DownloadFile (new Uri ("tp://scheme.notsupported"), file); Assert.Fail ("#1"); } catch (WebException ex) { // An error occurred performing a WebClient request @@ -289,6 +293,10 @@ namespace MonoTests.System.Net Assert.IsNull (inner.InnerException, "#8"); Assert.IsNotNull (inner.Message, "#9"); } + finally { + if (File.Exists (file)) + File.Delete (file); + } } [Test] // DownloadFile (Uri, string) diff --git a/mcs/class/System/Test/System.Net/WebPermissionAttributeTest.cs b/mcs/class/System/Test/System.Net/WebPermissionAttributeTest.cs index 3b940e5fa9c..77c4b75c098 100644 --- a/mcs/class/System/Test/System.Net/WebPermissionAttributeTest.cs +++ b/mcs/class/System/Test/System.Net/WebPermissionAttributeTest.cs @@ -36,6 +36,9 @@ using System.Text.RegularExpressions; namespace MonoTests.System.Net { [TestFixture] +#if MOBILE + [Ignore ("CAS is not supported and parts will be linked away")] +#endif public class WebPermissionAttributeTest { [Test] diff --git a/mcs/class/System/Test/System.Net/WebPermissionTest.cs b/mcs/class/System/Test/System.Net/WebPermissionTest.cs index f2adab01913..39d7045ca0d 100644 --- a/mcs/class/System/Test/System.Net/WebPermissionTest.cs +++ b/mcs/class/System/Test/System.Net/WebPermissionTest.cs @@ -37,6 +37,9 @@ namespace MonoTests.System.Net { [TestFixture] [Category ("CAS")] +#if MOBILE + [Ignore ("CAS is not supported and parts will be linked away")] +#endif public class WebPermissionTest { [Test] diff --git a/mcs/class/System/Test/System.Net/WebUtilityTest.cs b/mcs/class/System/Test/System.Net/WebUtilityTest.cs index 8a4414fb774..92c1a54300b 100644 --- a/mcs/class/System/Test/System.Net/WebUtilityTest.cs +++ b/mcs/class/System/Test/System.Net/WebUtilityTest.cs @@ -180,6 +180,16 @@ namespace MonoTests.System.Net { " + \"&mid=\" + ModuleID + \"&pageindex=\" + Request.Params.Get(\"pageindex\") %>"; Assert.AreEqual (str, WebUtility.HtmlDecode (str)); } + + [Test] + public void EntityEncoding () + { + var expected = "\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u00D0\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7\u00D8\u00D9\u00DA\u00DB\u00DC\u00DD\u00DE\u00DF\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u00FD\u00FE\u00FF\u0192\u0391\u0392\u0393\u0394\u0395\u0396\u0397\u0398\u0399\u039A\u039B\u039C\u039D\u039E\u039F\u03A0\u03A1\u03A3\u03A4\u03A5\u03A6\u03A7\u03A8\u03A9\u03B1\u03B2\u03B3\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9\u03BA\u03BB\u03BC\u03BD\u03BE\u03BF\u03C0\u03C1\u03C2\u03C3\u03C4\u03C5\u03C6\u03C7\u03C8\u03C9\u03D1\u03D2\u03D6\u2022\u2026\u2032\u2033\u203E\u2044\u2118\u2111\u211C\u2122\u2135\u2190\u2191\u2192\u2193\u2194\u21B5\u21D0\u21D1\u21D2\u21D3\u21D4\u2200\u2202\u2203\u2205\u2207\u2208\u2209\u220B\u220F\u2211\u2212\u2217\u221A\u221D\u221E\u2220\u2227\u2228\u2229\u222A\u222B\u2234\u223C\u2245\u2248\u2260\u2261\u2264\u2265\u2282\u2283\u2284\u2286\u2287\u2295\u2297\u22A5\u22C5\u2308\u2309\u230A\u230B\u2329\u232A\u25CA\u2660\u2663\u2665\u2666\u0022\u0026\u003C\u003E\u0152\u0153\u0160\u0161\u0178\u02C6\u02DC\u2002\u2003\u2009\u200C\u200D\u200E\u200F\u2013\u2014\u2018\u2019\u201A\u201C\u201D\u201E\u2020\u2021\u2030\u2039\u203A\u20AC"; + + var htmlDecoded = WebUtility.HtmlDecode (" ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿƒΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖ•…′″‾⁄℘ℑℜ™ℵ←↑→↓↔↵⇐⇑⇒⇓⇔∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌈⌉⌊⌋⟨⟩◊♠♣♥♦"&<>ŒœŠšŸˆ˜   ‌‍‎‏–—‘’‚“”„†‡‰‹›€"); + + Assert.AreEqual (expected, htmlDecoded); + } } } #endif diff --git a/mcs/class/corlib/System.Globalization/CultureInfo.cs b/mcs/class/corlib/System.Globalization/CultureInfo.cs index 1e0cc11cb76..8b740044e34 100644 --- a/mcs/class/corlib/System.Globalization/CultureInfo.cs +++ b/mcs/class/corlib/System.Globalization/CultureInfo.cs @@ -279,8 +279,15 @@ namespace System.Globalization if (parent_culture == null) { if (!constructed) Construct (); - if (parent_lcid == cultureID) + if (parent_lcid == cultureID) { + // + // Parent lcid is same but culture info is not for legacy zh culture + // + if (parent_lcid == 0x7C04 && EnglishName.EndsWith (" Legacy", StringComparison.Ordinal)) + return parent_culture = new CultureInfo ("zh-Hant"); + return null; + } if (parent_lcid == InvariantCultureId) parent_culture = InvariantCulture; diff --git a/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs b/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs index 746e1f6f35f..a3134933a31 100644 --- a/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs +++ b/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs @@ -705,11 +705,16 @@ namespace System.Runtime.InteropServices public static byte ReadByte (IntPtr ptr) { - return ReadByte (ptr, 0); + unsafe { + return *(byte*)ptr; + } } - [MethodImplAttribute(MethodImplOptions.InternalCall)] - public extern static byte ReadByte (IntPtr ptr, int ofs); + public static byte ReadByte (IntPtr ptr, int ofs) { + unsafe { + return *((byte*)ptr + ofs); + } + } [MonoTODO] [SuppressUnmanagedCodeSecurity] @@ -718,13 +723,32 @@ namespace System.Runtime.InteropServices throw new NotImplementedException (); } - public static short ReadInt16 (IntPtr ptr) + public unsafe static short ReadInt16 (IntPtr ptr) { - return ReadInt16 (ptr, 0); + byte *addr = (byte *) ptr; + + // The mono JIT can't inline this due to the hight number of calls + // return ReadInt16 (ptr, 0); + + if (((uint)addr & 1) == 0) + return *(short*)addr; + + short s; + String.memcpy ((byte*)&s, (byte*)ptr, 2); + return s; } - [MethodImplAttribute(MethodImplOptions.InternalCall)] - public extern static short ReadInt16 (IntPtr ptr, int ofs); + public unsafe static short ReadInt16 (IntPtr ptr, int ofs) + { + byte *addr = ((byte *) ptr) + ofs; + + if (((uint) addr & 1) == 0) + return *(short*)addr; + + short s; + String.memcpy ((byte*)&s, addr, 2); + return s; + } [MonoTODO] [SuppressUnmanagedCodeSecurity] @@ -734,14 +758,31 @@ namespace System.Runtime.InteropServices } [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)] - public static int ReadInt32 (IntPtr ptr) + public unsafe static int ReadInt32 (IntPtr ptr) { - return ReadInt32 (ptr, 0); + byte *addr = (byte *) ptr; + + if (((uint)addr & 3) == 0) + return *(int*)addr; + + int s; + String.memcpy ((byte*)&s, addr, 4); + return s; } [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)] - [MethodImplAttribute(MethodImplOptions.InternalCall)] - public extern static int ReadInt32 (IntPtr ptr, int ofs); + public unsafe static int ReadInt32 (IntPtr ptr, int ofs) + { + byte *addr = ((byte *) ptr) + ofs; + + if ((((int) addr) & 3) == 0) + return *(int*)addr; + else { + int s; + String.memcpy ((byte*)&s, addr, 4); + return s; + } + } [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)] [MonoTODO] @@ -752,13 +793,31 @@ namespace System.Runtime.InteropServices } [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)] - public static long ReadInt64 (IntPtr ptr) + public unsafe static long ReadInt64 (IntPtr ptr) { - return ReadInt64 (ptr, 0); + byte *addr = (byte *) ptr; + + // The real alignment might be 4 on some platforms, but this is just an optimization, + // so it doesn't matter. + if (((uint) addr & 7) == 0) + return *(long*)ptr; + + long s; + String.memcpy ((byte*)&s, addr, 8); + return s; } - [MethodImplAttribute(MethodImplOptions.InternalCall)] - public extern static long ReadInt64 (IntPtr ptr, int ofs); + public unsafe static long ReadInt64 (IntPtr ptr, int ofs) + { + byte *addr = ((byte *) ptr) + ofs; + + if (((uint) addr & 7) == 0) + return *(long*)addr; + + long s; + String.memcpy ((byte*)&s, addr, 8); + return s; + } [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)] [MonoTODO] @@ -771,12 +830,20 @@ namespace System.Runtime.InteropServices [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)] public static IntPtr ReadIntPtr (IntPtr ptr) { - return ReadIntPtr (ptr, 0); + if (IntPtr.Size == 4) + return (IntPtr)ReadInt32 (ptr); + else + return (IntPtr)ReadInt64 (ptr); } [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)] - [MethodImplAttribute(MethodImplOptions.InternalCall)] - public extern static IntPtr ReadIntPtr (IntPtr ptr, int ofs); + public static IntPtr ReadIntPtr (IntPtr ptr, int ofs) + { + if (IntPtr.Size == 4) + return (IntPtr)ReadInt32 (ptr, ofs); + else + return (IntPtr)ReadInt64 (ptr, ofs); + } [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)] [MonoTODO] @@ -1009,11 +1076,16 @@ namespace System.Runtime.InteropServices public static void WriteByte (IntPtr ptr, byte val) { - WriteByte (ptr, 0, val); + unsafe { + *(byte*)ptr = val; + } } - [MethodImplAttribute(MethodImplOptions.InternalCall)] - public extern static void WriteByte (IntPtr ptr, int ofs, byte val); + public static void WriteByte (IntPtr ptr, int ofs, byte val) { + unsafe { + *(byte*)(IntPtr.Add (ptr, ofs)) = val; + } + } [MonoTODO] [SuppressUnmanagedCodeSecurity] @@ -1022,13 +1094,26 @@ namespace System.Runtime.InteropServices throw new NotImplementedException (); } - public static void WriteInt16 (IntPtr ptr, short val) + public static unsafe void WriteInt16 (IntPtr ptr, short val) { - WriteInt16 (ptr, 0, val); + byte *addr = (byte *) ptr; + + if (((uint)addr & 1) == 0) + *(short*)addr = val; + else + String.memcpy (addr, (byte*)&val, 2); } - [MethodImplAttribute(MethodImplOptions.InternalCall)] - public extern static void WriteInt16 (IntPtr ptr, int ofs, short val); + public static unsafe void WriteInt16 (IntPtr ptr, int ofs, short val) + { + byte *addr = ((byte *) ptr) + ofs; + + if (((uint)addr & 1) == 0) + *(short*)addr = val; + else { + String.memcpy (addr, (byte*)&val, 2); + } + } [MonoTODO] [SuppressUnmanagedCodeSecurity] @@ -1039,12 +1124,13 @@ namespace System.Runtime.InteropServices public static void WriteInt16 (IntPtr ptr, char val) { - WriteInt16 (ptr, 0, val); + WriteInt16 (ptr, 0, (short)val); } - [MonoTODO] - [MethodImplAttribute(MethodImplOptions.InternalCall)] - public extern static void WriteInt16 (IntPtr ptr, int ofs, char val); + public static void WriteInt16 (IntPtr ptr, int ofs, char val) + { + WriteInt16 (ptr, ofs, (short)val); + } [MonoTODO] public static void WriteInt16([In, Out] object ptr, int ofs, char val) @@ -1052,13 +1138,27 @@ namespace System.Runtime.InteropServices throw new NotImplementedException (); } - public static void WriteInt32 (IntPtr ptr, int val) + public static unsafe void WriteInt32 (IntPtr ptr, int val) { - WriteInt32 (ptr, 0, val); + byte *addr = (byte *) ptr; + + if (((uint)addr & 3) == 0) + *(int*)addr = val; + else { + String.memcpy (addr, (byte*)&val, 4); + } } - [MethodImplAttribute(MethodImplOptions.InternalCall)] - public extern static void WriteInt32 (IntPtr ptr, int ofs, int val); + public unsafe static void WriteInt32 (IntPtr ptr, int ofs, int val) + { + byte *addr = ((byte *) ptr) + ofs; + + if (((uint)addr & 3) == 0) + *(int*)addr = val; + else { + String.memcpy (addr, (byte*)&val, 4); + } + } [MonoTODO] [SuppressUnmanagedCodeSecurity] @@ -1067,13 +1167,29 @@ namespace System.Runtime.InteropServices throw new NotImplementedException (); } - public static void WriteInt64 (IntPtr ptr, long val) + public static unsafe void WriteInt64 (IntPtr ptr, long val) { - WriteInt64 (ptr, 0, val); + byte *addr = (byte *) ptr; + + // The real alignment might be 4 on some platforms, but this is just an optimization, + // so it doesn't matter. + if (((uint)addr & 7) == 0) + *(long*)addr = val; + else + String.memcpy (addr, (byte*)&val, 8); } - [MethodImplAttribute(MethodImplOptions.InternalCall)] - public extern static void WriteInt64 (IntPtr ptr, int ofs, long val); + public static unsafe void WriteInt64 (IntPtr ptr, int ofs, long val) + { + byte *addr = ((byte *) ptr) + ofs; + + // The real alignment might be 4 on some platforms, but this is just an optimization, + // so it doesn't matter. + if (((uint)addr & 7) == 0) + *(long*)addr = val; + else + String.memcpy (addr, (byte*)&val, 8); + } [MonoTODO] [SuppressUnmanagedCodeSecurity] @@ -1084,11 +1200,19 @@ namespace System.Runtime.InteropServices public static void WriteIntPtr (IntPtr ptr, IntPtr val) { - WriteIntPtr (ptr, 0, val); + if (IntPtr.Size == 4) + WriteInt32 (ptr, (int)val); + else + WriteInt64 (ptr, (long)val); } - [MethodImplAttribute(MethodImplOptions.InternalCall)] - public extern static void WriteIntPtr (IntPtr ptr, int ofs, IntPtr val); + public static void WriteIntPtr (IntPtr ptr, int ofs, IntPtr val) + { + if (IntPtr.Size == 4) + WriteInt32 (ptr, ofs, (int)val); + else + WriteInt64 (ptr, ofs, (long)val); + } [MonoTODO] public static void WriteIntPtr([In, Out, MarshalAs(UnmanagedType.AsAny)] object ptr, int ofs, IntPtr val) diff --git a/mcs/class/corlib/System.Threading.Tasks/Task.cs b/mcs/class/corlib/System.Threading.Tasks/Task.cs index cf59c613845..1f6e451c831 100644 --- a/mcs/class/corlib/System.Threading.Tasks/Task.cs +++ b/mcs/class/corlib/System.Threading.Tasks/Task.cs @@ -347,7 +347,7 @@ namespace System.Threading.Tasks continuation.Execute (); } - void RemoveContinuation (IContinuation continuation) + internal void RemoveContinuation (IContinuation continuation) { continuations.Remove (continuation); } diff --git a/mcs/class/corlib/System.Threading.Tasks/TaskContinuation.cs b/mcs/class/corlib/System.Threading.Tasks/TaskContinuation.cs index a48c5cdd5c2..8189df744b8 100644 --- a/mcs/class/corlib/System.Threading.Tasks/TaskContinuation.cs +++ b/mcs/class/corlib/System.Threading.Tasks/TaskContinuation.cs @@ -256,12 +256,13 @@ namespace System.Threading.Tasks { readonly Task owner; readonly IList tasks; - AtomicBooleanValue executed = new AtomicBooleanValue (); + AtomicBooleanValue executed; public WhenAnyContinuation (Task owner, IList tasks) { this.owner = owner; this.tasks = tasks; + executed = new AtomicBooleanValue (); } public void Execute () @@ -269,13 +270,19 @@ namespace System.Threading.Tasks if (!executed.TryRelaxedSet ()) return; + bool owner_notified = false; for (int i = 0; i < tasks.Count; ++i) { var task = tasks[i]; - if (!task.IsCompleted) + if (!task.IsCompleted) { + task.RemoveContinuation (this); + continue; + } + + if (owner_notified) continue; owner.TrySetResult (task); - return; + owner_notified = true; } } } diff --git a/mcs/class/corlib/System/AppDomain.cs b/mcs/class/corlib/System/AppDomain.cs index 99304d33dbc..5ebd4db216e 100644 --- a/mcs/class/corlib/System/AppDomain.cs +++ b/mcs/class/corlib/System/AppDomain.cs @@ -195,6 +195,9 @@ namespace System { public Evidence Evidence { get { +#if MONOTOUCH + return null; +#else // if the host (runtime) hasn't provided it's own evidence... if (_evidence == null) { // ... we will provide our own @@ -215,6 +218,7 @@ namespace System { } } return new Evidence ((Evidence)_evidence); // return a copy +#endif } } diff --git a/mcs/class/corlib/System/Array.cs b/mcs/class/corlib/System/Array.cs index db82bdcf924..2f90fbd131b 100644 --- a/mcs/class/corlib/System/Array.cs +++ b/mcs/class/corlib/System/Array.cs @@ -2808,8 +2808,14 @@ namespace System return; T [] a = new T [newSize]; - if (length != 0) - FastCopy (arr, 0, a, 0, Math.Min (newSize, length)); + int tocopy = Math.Min (newSize, length); + + if (tocopy < 9) { + for (int i = 0; i < tocopy; ++i) + UnsafeStore (a, i, UnsafeLoad (arr, i)); + } else { + FastCopy (arr, 0, a, 0, tocopy); + } array = a; } diff --git a/mcs/class/corlib/System/DateTime.cs b/mcs/class/corlib/System/DateTime.cs index 086f35059ac..6185ae95621 100644 --- a/mcs/class/corlib/System/DateTime.cs +++ b/mcs/class/corlib/System/DateTime.cs @@ -2003,10 +2003,9 @@ namespace System if (format == null || format == String.Empty) format = "G"; - bool useutc = false, use_invariant = false; - if (format.Length == 1) { char fchar = format [0]; + bool use_invariant, useutc; format = DateTimeUtils.GetStandardPattern (fchar, dfi, out useutc, out use_invariant); if (fchar == 'U') return DateTimeUtils.ToString (ToUniversalTime (), format, dfi); @@ -2014,6 +2013,9 @@ namespace System if (format == null) throw new FormatException ("format is not one of the format specifier characters defined for DateTimeFormatInfo"); + + if (use_invariant) + dfi = DateTimeFormatInfo.InvariantInfo; } // Don't convert UTC value. It just adds 'Z' for diff --git a/mcs/class/corlib/System/DateTimeUtils.cs b/mcs/class/corlib/System/DateTimeUtils.cs index 3def45668ad..61bbe7a5db6 100644 --- a/mcs/class/corlib/System/DateTimeUtils.cs +++ b/mcs/class/corlib/System/DateTimeUtils.cs @@ -184,13 +184,6 @@ namespace System { // Add + 10 for cases like mmmm dddd StringBuilder result = new StringBuilder (format.Length + 10); - // For some cases, the output should not use culture dependent calendar - DateTimeFormatInfo inv = DateTimeFormatInfo.InvariantInfo; - if (format == inv.RFC1123Pattern) - dfi = inv; - else if (format == inv.UniversalSortableDateTimePattern) - dfi = inv; - int i = 0; bool saw_day_specifier = false; diff --git a/mcs/class/corlib/System/Delegate.cs b/mcs/class/corlib/System/Delegate.cs index 7610e43dcba..91b02e64a8e 100644 --- a/mcs/class/corlib/System/Delegate.cs +++ b/mcs/class/corlib/System/Delegate.cs @@ -565,7 +565,7 @@ namespace System internal bool IsTransparentProxy () { -#if MONOTOUCH +#if DISABLE_REMOTING return false; #else return RemotingServices.IsTransparentProxy (m_target); diff --git a/mcs/class/corlib/System/Int32.cs b/mcs/class/corlib/System/Int32.cs index b65e3b10696..b78c0a5b14e 100644 --- a/mcs/class/corlib/System/Int32.cs +++ b/mcs/class/corlib/System/Int32.cs @@ -461,10 +461,9 @@ namespace System { int number = 0; int nDigits = 0; - bool decimalPointFound = false; + int decimalPointPos = -1; int digitValue; char hexDigit; - int exponent = 0; // Number stuff do { @@ -474,18 +473,20 @@ namespace System { (FindOther (ref pos, s, nfi.NumberGroupSeparator) || FindOther (ref pos, s, nfi.CurrencyGroupSeparator))) continue; - else - if (!decimalPointFound && AllowDecimalPoint && + + if (AllowDecimalPoint && decimalPointPos < 0 && (FindOther (ref pos, s, nfi.NumberDecimalSeparator) || FindOther (ref pos, s, nfi.CurrencyDecimalSeparator))) { - decimalPointFound = true; + decimalPointPos = nDigits; continue; } break; } + + nDigits++; + if (AllowHexSpecifier) { - nDigits++; hexDigit = s [pos++]; if (Char.IsDigit (hexDigit)) digitValue = (int) (hexDigit - '0'); @@ -503,34 +504,18 @@ namespace System { } else { number = (int)checked (unumber * 16u + (uint)digitValue); } + + continue; } - else if (decimalPointFound) { - nDigits++; - // Allows decimal point as long as it's only - // followed by zeroes. - if (s [pos++] != '0') { - if (!tryParse) - exc = new OverflowException ("Value too large or too " + - "small."); - return false; - } - } - else { - nDigits++; - - try { - // Calculations done as negative - // (abs (MinValue) > abs (MaxValue)) - number = checked ( - number * 10 - - (int) (s [pos++] - '0') - ); - } catch (OverflowException) { - if (!tryParse) - exc = new OverflowException ("Value too large or too " + - "small."); - return false; - } + + try { + // Calculations done as negative + // (abs (MinValue) > abs (MaxValue)) + number = checked (number * 10 - (int) (s [pos++] - '0')); + } catch (OverflowException) { + if (!tryParse) + exc = new OverflowException ("Value too large or too small."); + return false; } } while (pos < s.Length); @@ -541,6 +526,7 @@ namespace System { return false; } + int exponent = 0; if (AllowExponent) if (FindExponent (ref pos, s, ref exponent, tryParse, ref exc) && exc != null) return false; @@ -599,11 +585,28 @@ namespace System { number = checked (-number); } - // result *= 10^exponent - if (exponent > 0) { + if (decimalPointPos >= 0) + exponent = exponent - nDigits + decimalPointPos; + + if (exponent < 0) { + // + // Any non-zero values after decimal point are not allowed + // + int remainder; + number = Math.DivRem (number, (int) Math.Pow (10, -exponent), out remainder); + if (remainder != 0) { + if (!tryParse) + exc = new OverflowException ("Value too large or too small."); + return false; + } + } else if (exponent > 0) { + // + // result *= 10^exponent + // // Reduce the risk of throwing an overflow exc + // double res = checked (Math.Pow (10, exponent) * number); - if (res < Int32.MinValue || res > Int32.MaxValue) { + if (res < MinValue || res > MaxValue) { if (!tryParse) exc = new OverflowException ("Value too large or too small."); return false; diff --git a/mcs/class/corlib/System/Int64.cs b/mcs/class/corlib/System/Int64.cs index b96cfdb7f8a..09538f8ea6e 100644 --- a/mcs/class/corlib/System/Int64.cs +++ b/mcs/class/corlib/System/Int64.cs @@ -293,10 +293,9 @@ namespace System { long number = 0; int nDigits = 0; - bool decimalPointFound = false; + int decimalPointPos = -1; int digitValue; char hexDigit; - int exponent = 0; // Number stuff do { @@ -306,18 +305,20 @@ namespace System { (Int32.FindOther (ref pos, s, nfi.NumberGroupSeparator) || Int32.FindOther (ref pos, s, nfi.CurrencyGroupSeparator))) continue; - else - if (!decimalPointFound && AllowDecimalPoint && + + if (AllowDecimalPoint && decimalPointPos < 0 && (Int32.FindOther (ref pos, s, nfi.NumberDecimalSeparator) || Int32.FindOther (ref pos, s, nfi.CurrencyDecimalSeparator))) { - decimalPointFound = true; + decimalPointPos = nDigits; continue; } break; } + + nDigits++; + if (AllowHexSpecifier) { - nDigits++; hexDigit = s [pos++]; if (Char.IsDigit (hexDigit)) digitValue = (int) (hexDigit - '0'); @@ -336,35 +337,19 @@ namespace System { exc = e; return false; } - } - else if (decimalPointFound) { - nDigits++; - // Allows decimal point as long as it's only - // followed by zeroes. - if (s [pos++] != '0') { - if (!tryParse) - exc = new OverflowException ("Value too large or too " + - "small."); - return false; - } - } - else { - nDigits++; - try { - // Calculations done as negative - // (abs (MinValue) > abs (MaxValue)) - number = checked ( - number * 10 - - (long) (s [pos++] - '0') - ); - } catch (OverflowException) { - if (!tryParse) - exc = new OverflowException ("Value too large or too " + - "small."); - return false; - } + continue; } + + try { + // Calculations done as negative + // (abs (MinValue) > abs (MaxValue)) + number = checked (number * 10 - (long) (s [pos++] - '0')); + } catch (OverflowException) { + if (!tryParse) + exc = new OverflowException ("Value too large or too small."); + return false; + } } while (pos < s.Length); // Post number stuff @@ -374,6 +359,7 @@ namespace System { return false; } + int exponent = 0; if (AllowExponent) if (Int32.FindExponent (ref pos, s, ref exponent, tryParse, ref exc) && exc != null) return false; @@ -431,17 +417,34 @@ namespace System { } } - // result *= 10^exponent - if (exponent > 0) { + if (decimalPointPos >= 0) + exponent = exponent - nDigits + decimalPointPos; + + if (exponent < 0) { + // + // Any non-zero values after decimal point are not allowed + // + long remainder; + number = Math.DivRem (number, (long) Math.Pow (10, -exponent), out remainder); + if (remainder != 0) { + if (!tryParse) + exc = new OverflowException ("Value too large or too small."); + return false; + } + } else if (exponent > 0) { + // + // result *= 10^exponent + // // Reduce the risk of throwing an overflow exc + // double res = checked (Math.Pow (10, exponent) * number); - if (res < Int32.MinValue || res > Int32.MaxValue) { + if (res < MinValue || res > MaxValue) { if (!tryParse) exc = new OverflowException ("Value too large or too small."); return false; } - number = (long) res; + number = (long)res; } result = number; diff --git a/mcs/class/corlib/System/IntPtr.cs b/mcs/class/corlib/System/IntPtr.cs index 1b36f47d372..e8ca505de18 100644 --- a/mcs/class/corlib/System/IntPtr.cs +++ b/mcs/class/corlib/System/IntPtr.cs @@ -224,6 +224,12 @@ namespace System { return (IntPtr) (unchecked (((byte *) pointer) - offset)); } +#else + /* Needed by Marshal.cs */ + internal static IntPtr Add (IntPtr pointer, int offset) + { + return (IntPtr) (unchecked (((byte *) pointer) + offset)); + } #endif } } diff --git a/mcs/class/corlib/System/UInt32.cs b/mcs/class/corlib/System/UInt32.cs index 819970e7568..f78ee9dbab2 100644 --- a/mcs/class/corlib/System/UInt32.cs +++ b/mcs/class/corlib/System/UInt32.cs @@ -271,10 +271,9 @@ namespace System uint number = 0; int nDigits = 0; - bool decimalPointFound = false; + int decimalPointPos = -1; uint digitValue; char hexDigit; - int exponent = 0; // Number stuff // Just the same as Int32, but this one adds instead of substract @@ -285,18 +284,20 @@ namespace System (Int32.FindOther (ref pos, s, nfi.NumberGroupSeparator) || Int32.FindOther (ref pos, s, nfi.CurrencyGroupSeparator))) continue; - else - if (!decimalPointFound && AllowDecimalPoint && + + if (AllowDecimalPoint && decimalPointPos < 0 && (Int32.FindOther (ref pos, s, nfi.NumberDecimalSeparator) || Int32.FindOther (ref pos, s, nfi.CurrencyDecimalSeparator))) { - decimalPointFound = true; + decimalPointPos = nDigits; continue; } break; } + + nDigits++; + if (AllowHexSpecifier) { - nDigits++; hexDigit = s [pos++]; if (Char.IsDigit (hexDigit)) digitValue = (uint) (hexDigit - '0'); @@ -313,28 +314,16 @@ namespace System number = (uint) l; } else number = checked (number * 16 + digitValue); + + continue; } - else if (decimalPointFound) { - nDigits++; - // Allows decimal point as long as it's only - // followed by zeroes. - if (s [pos++] != '0') { - if (!tryParse) - exc = new OverflowException (Locale.GetText ("Value too large or too small.")); - return false; - } - } - else { - nDigits++; - try { - number = checked (number * 10 + (uint) (s [pos++] - '0')); - } - catch (OverflowException) { - if (!tryParse) - exc = new OverflowException (Locale.GetText ("Value too large or too small.")); - return false; - } + try { + number = checked (number * 10 + (uint) (s [pos++] - '0')); + } catch (OverflowException) { + if (!tryParse) + exc = new OverflowException (Locale.GetText ("Value too large or too small.")); + return false; } } while (pos < s.Length); @@ -345,6 +334,7 @@ namespace System return false; } + int exponent = 0; if (AllowExponent) if (Int32.FindExponent (ref pos, s, ref exponent, tryParse, ref exc) && exc != null) return false; @@ -400,21 +390,37 @@ namespace System return false; } - // result *= 10^exponent - if (exponent > 0) { + if (decimalPointPos >= 0) + exponent = exponent - nDigits + decimalPointPos; + + if (exponent < 0) { + // + // Any non-zero values after decimal point are not allowed + // + long remainder; + number = (uint) Math.DivRem (number, (int) Math.Pow (10, -exponent), out remainder); + if (remainder != 0) { + if (!tryParse) + exc = new OverflowException ("Value too large or too small."); + return false; + } + } else if (exponent > 0) { + // + // result *= 10^exponent + // // Reduce the risk of throwing an overflow exc + // double res = checked (Math.Pow (10, exponent) * number); - if (res < Int32.MinValue || res > Int32.MaxValue) { + if (res < MinValue || res > MaxValue) { if (!tryParse) exc = new OverflowException ("Value too large or too small."); return false; } - number = (uint) res; + number = (uint)res; } result = number; - return true; } diff --git a/mcs/class/corlib/System/UInt64.cs b/mcs/class/corlib/System/UInt64.cs index 922e763e0a6..1ac283149a6 100644 --- a/mcs/class/corlib/System/UInt64.cs +++ b/mcs/class/corlib/System/UInt64.cs @@ -294,10 +294,9 @@ namespace System ulong number = 0; int nDigits = 0; - bool decimalPointFound = false; + int decimalPointPos = -1; ulong digitValue; char hexDigit; - int exponent = 0; // Number stuff // Just the same as Int32, but this one adds instead of substract @@ -308,18 +307,20 @@ namespace System (Int32.FindOther (ref pos, s, nfi.NumberGroupSeparator) || Int32.FindOther (ref pos, s, nfi.CurrencyGroupSeparator))) continue; - else - if (!decimalPointFound && AllowDecimalPoint && + + if (AllowDecimalPoint && decimalPointPos < 0 && (Int32.FindOther (ref pos, s, nfi.NumberDecimalSeparator) || Int32.FindOther (ref pos, s, nfi.CurrencyDecimalSeparator))) { - decimalPointFound = true; + decimalPointPos = nDigits; continue; } break; } + + nDigits++; + if (AllowHexSpecifier) { - nDigits++; hexDigit = s [pos++]; if (Char.IsDigit (hexDigit)) digitValue = (ulong) (hexDigit - '0'); @@ -338,28 +339,16 @@ namespace System return false; } else number = checked (number * 16 + digitValue); + + continue; } - else if (decimalPointFound) { - nDigits++; - // Allows decimal point as long as it's only - // followed by zeroes. - if (s [pos++] != '0') { - if (!tryParse) - exc = new OverflowException (Locale.GetText ("Value too large or too small.")); - return false; - } - } - else { - nDigits++; - try { - number = checked (number * 10 + (ulong) (s [pos++] - '0')); - } - catch (OverflowException) { - if (!tryParse) - exc = new OverflowException (Locale.GetText ("Value too large or too small.")); - return false; - } + try { + number = checked (number * 10 + (ulong) (s [pos++] - '0')); + } catch (OverflowException) { + if (!tryParse) + exc = new OverflowException (Locale.GetText ("Value too large or too small.")); + return false; } } while (pos < s.Length); @@ -370,6 +359,7 @@ namespace System return false; } + int exponent = 0; if (AllowExponent) if (Int32.FindExponent (ref pos, s, ref exponent, tryParse, ref exc) && exc != null) return false; @@ -425,17 +415,34 @@ namespace System return false; } - // result *= 10^exponent - if (exponent > 0) { + if (decimalPointPos >= 0) + exponent = exponent - nDigits + decimalPointPos; + + if (exponent < 0) { + // + // Any non-zero values after decimal point are not allowed + // + long remainder; + number = (ulong) Math.DivRem ((long) number, (long) Math.Pow (10, -exponent), out remainder); + if (remainder != 0) { + if (!tryParse) + exc = new OverflowException ("Value too large or too small."); + return false; + } + } else if (exponent > 0) { + // + // result *= 10^exponent + // // Reduce the risk of throwing an overflow exc + // double res = checked (Math.Pow (10, exponent) * number); - if (res < Int32.MinValue || res > Int32.MaxValue) { + if (res < MinValue || res > MaxValue) { if (!tryParse) exc = new OverflowException ("Value too large or too small."); return false; } - number = (ulong) res; + number = (ulong)res; } result = number; diff --git a/mcs/class/corlib/Test/System.Globalization/CultureInfoTest.cs b/mcs/class/corlib/Test/System.Globalization/CultureInfoTest.cs index d84de5b2a07..4a6ac7db8a0 100644 --- a/mcs/class/corlib/Test/System.Globalization/CultureInfoTest.cs +++ b/mcs/class/corlib/Test/System.Globalization/CultureInfoTest.cs @@ -568,6 +568,8 @@ namespace MonoTests.System.Globalization { Assert.AreEqual (31748, new CultureInfo ("zh-Hant").LCID); Assert.AreEqual (31748, CultureInfo.GetCultureInfo ("zh-Hant").LCID); + Assert.AreEqual (31748, new CultureInfo ("zh-CHT").LCID); + Assert.AreEqual (31748, new CultureInfo ("zh-CHT").Parent.LCID); } [Test] diff --git a/mcs/class/corlib/Test/System.Globalization/DateTimeFormatInfoTest.cs b/mcs/class/corlib/Test/System.Globalization/DateTimeFormatInfoTest.cs index 0c6a8e247cb..d3d388f6703 100644 --- a/mcs/class/corlib/Test/System.Globalization/DateTimeFormatInfoTest.cs +++ b/mcs/class/corlib/Test/System.Globalization/DateTimeFormatInfoTest.cs @@ -121,6 +121,14 @@ namespace MonoTests.System.Globalization { var dfi = new CultureInfo ("cs-CZ").DateTimeFormat; Assert.AreEqual ("ledna", dfi.MonthGenitiveNames[0], "#1"); + Assert.AreEqual ("1.", dfi.AbbreviatedMonthGenitiveNames[0], "#2"); + } + + [Test] + public void QuoteInValue () + { + var culture = new CultureInfo("mt-MT"); + Assert.AreEqual ("dddd, d' ta\\' 'MMMM yyyy", culture.DateTimeFormat.LongDatePattern); } #if !TARGET_JVM diff --git a/mcs/class/corlib/Test/System.Runtime.InteropServices/MarshalTest.cs b/mcs/class/corlib/Test/System.Runtime.InteropServices/MarshalTest.cs index bb401e4c6d8..e0fa0691844 100644 --- a/mcs/class/corlib/Test/System.Runtime.InteropServices/MarshalTest.cs +++ b/mcs/class/corlib/Test/System.Runtime.InteropServices/MarshalTest.cs @@ -258,6 +258,61 @@ namespace MonoTests.System.Runtime.InteropServices Assert.AreEqual (19, s.Length, "#2"); } + [Test] + public void ReadIntByte () + { + IntPtr ptr = Marshal.AllocHGlobal (4); + try { + Marshal.WriteByte (ptr, 0, 0x1); + Marshal.WriteByte (ptr, 1, 0x2); + Assert.AreEqual (0x1, Marshal.ReadByte (ptr)); + Assert.AreEqual (0x1, Marshal.ReadByte (ptr, 0)); + Assert.AreEqual (0x2, Marshal.ReadByte (ptr, 1)); + } finally { + Marshal.FreeHGlobal (ptr); + } + } + + [Test] + public void ReadInt16 () + { + IntPtr ptr = Marshal.AllocHGlobal (64); + try { + Marshal.WriteInt16 (ptr, 0, 0x1234); + Marshal.WriteInt16 (ptr, 2, 0x4567); + Marshal.WriteInt16 (ptr, 5, 0x4567); + Assert.AreEqual (0x1234, Marshal.ReadInt16 (ptr)); + Assert.AreEqual (0x1234, Marshal.ReadInt16 (ptr, 0)); + Assert.AreEqual (0x4567, Marshal.ReadInt16 (ptr, 2)); +#if NET_4_5 + Assert.AreEqual (0x4567, Marshal.ReadInt16 ((ptr + 5))); +#endif + Assert.AreEqual (0x4567, Marshal.ReadInt16 (ptr, 5)); + } finally { + Marshal.FreeHGlobal (ptr); + } + } + + [Test] + public void ReadInt32 () + { + IntPtr ptr = Marshal.AllocHGlobal (64); + try { + Marshal.WriteInt32 (ptr, 0, 0x12345678); + Marshal.WriteInt32 (ptr, 4, 0x77654321); + Marshal.WriteInt32 (ptr, 10, 0x77654321); + Assert.AreEqual (0x12345678, Marshal.ReadInt32 (ptr)); + Assert.AreEqual (0x12345678, Marshal.ReadInt32 (ptr, 0)); + Assert.AreEqual (0x77654321, Marshal.ReadInt32 (ptr, 4)); +#if NET_4_5 + Assert.AreEqual (0x77654321, Marshal.ReadInt32 ((ptr + 10))); +#endif + Assert.AreEqual (0x77654321, Marshal.ReadInt32 (ptr, 10)); + } finally { + Marshal.FreeHGlobal (ptr); + } + } + [Test] public void ReadInt32_Endian () { @@ -278,6 +333,21 @@ namespace MonoTests.System.Runtime.InteropServices } } + [Test] + public void ReadInt64 () + { + IntPtr ptr = Marshal.AllocHGlobal (16); + try { + Marshal.WriteInt64 (ptr, 0, 0x12345678ABCDEFL); + Marshal.WriteInt64 (ptr, 8, 0x87654321ABCDEFL); + Assert.AreEqual (0x12345678ABCDEFL, Marshal.ReadInt64 (ptr)); + Assert.AreEqual (0x12345678ABCDEFL, Marshal.ReadInt64 (ptr, 0)); + Assert.AreEqual (0x87654321ABCDEFL, Marshal.ReadInt64 (ptr, 8)); + } finally { + Marshal.FreeHGlobal (ptr); + } + } + [Test] [Category ("MobileNotWorking")] public void BSTR_Roundtrip () @@ -691,6 +761,18 @@ namespace MonoTests.System.Runtime.InteropServices Marshal.FreeHGlobal (p); } } + + [StructLayout (LayoutKind.Sequential)] + public struct SimpleStruct2 { + public int a; + public int b; + } + + [Test] + public void PtrToStructureNull () + { + Assert.IsNull (Marshal.PtrToStructure (IntPtr.Zero, typeof (SimpleStruct2))); + } #if NET_2_0 [Test] diff --git a/mcs/class/corlib/Test/System/DateTimeTest.cs b/mcs/class/corlib/Test/System/DateTimeTest.cs index 05fd44ea528..72da88876a3 100644 --- a/mcs/class/corlib/Test/System/DateTimeTest.cs +++ b/mcs/class/corlib/Test/System/DateTimeTest.cs @@ -2265,6 +2265,10 @@ namespace MonoTests.System Assert.AreEqual ("2000-01-01T00:00:00.0000000Z", DateTime.SpecifyKind (new DateTime (2000, 1, 1), DateTimeKind.Utc).ToString ("o"), "#2"); Assert.AreEqual ("2000-01-01T00:00:00.0000000+09:00".Length, DateTime.SpecifyKind ( new DateTime (2000, 1, 1), DateTimeKind.Local).ToString ("o").Length, "#3"); + + var culture = new CultureInfo ("ps-AF"); + Assert.AreEqual ("1976-06-19T00:00:00.0000000", new DateTime(1976, 6, 19).ToString ("O", culture), "#4"); + Assert.AreEqual ("1976-06-19T00:00:00.0000000", new DateTime(1976, 6, 19).ToString ("o", culture), "#5"); } [Test] diff --git a/mcs/class/corlib/Test/System/DecimalTest.cs b/mcs/class/corlib/Test/System/DecimalTest.cs index b70be0c4239..4339edce397 100644 --- a/mcs/class/corlib/Test/System/DecimalTest.cs +++ b/mcs/class/corlib/Test/System/DecimalTest.cs @@ -1129,6 +1129,13 @@ namespace MonoTests.System } } */ + + [Test] + public void ParseCultureSeparator () + { + Assert.AreEqual (2.2m, decimal.Parse ("2.2", new CultureInfo("es-MX"))); + } + [Test] [Category ("TargetJvmNotWorking")] public void TryParse () diff --git a/mcs/class/corlib/Test/System/DoubleTest.cs b/mcs/class/corlib/Test/System/DoubleTest.cs index edd94252d12..5859f1d6f40 100644 --- a/mcs/class/corlib/Test/System/DoubleTest.cs +++ b/mcs/class/corlib/Test/System/DoubleTest.cs @@ -258,6 +258,15 @@ namespace MonoTests.System } } + [Test] + public void Parse_Infinity () + { + double value; + IFormatProvider german = new CultureInfo ("de-DE"); + var res = double.Parse ("+unendlich", NumberStyles.Float, german); + Assert.AreEqual (double.PositiveInfinity, res); + } + [Test] public void TestToString () { diff --git a/mcs/class/corlib/Test/System/Int32Test.cs b/mcs/class/corlib/Test/System/Int32Test.cs index 60c756a9034..128cc19790d 100644 --- a/mcs/class/corlib/Test/System/Int32Test.cs +++ b/mcs/class/corlib/Test/System/Int32Test.cs @@ -274,6 +274,10 @@ public class Int32Test Assert.AreEqual (2000000, Int32.Parse ("2E6", NumberStyles.AllowExponent), "A#4"); Assert.AreEqual (200, Int32.Parse ("2E+2", NumberStyles.AllowExponent), "A#5"); Assert.AreEqual (2, Int32.Parse ("2", NumberStyles.AllowExponent), "A#6"); + Assert.AreEqual (21, Int32.Parse ("2.1E1", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#7"); + Assert.AreEqual (520, Int32.Parse (".52E3", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#8"); + Assert.AreEqual (32500000, Int32.Parse ("32.5E6", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#9"); + Assert.AreEqual (890, Int32.Parse ("8.9000E2", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#10"); try { Int32.Parse ("2E"); @@ -323,6 +327,12 @@ public class Int32Test Assert.Fail ("B#8"); } catch (FormatException) { } + + try { + Int32.Parse ("2.09E1", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent); + Assert.Fail ("B#9"); + } catch (OverflowException) { + } } [Test] diff --git a/mcs/class/corlib/Test/System/Int64Test.cs b/mcs/class/corlib/Test/System/Int64Test.cs index b1b6b079b40..6ad5e36ce48 100644 --- a/mcs/class/corlib/Test/System/Int64Test.cs +++ b/mcs/class/corlib/Test/System/Int64Test.cs @@ -330,6 +330,10 @@ public class Int64Test Assert.AreEqual (2000000, long.Parse ("2E6", NumberStyles.AllowExponent), "A#4"); Assert.AreEqual (200, long.Parse ("2E+2", NumberStyles.AllowExponent), "A#5"); Assert.AreEqual (2, long.Parse ("2", NumberStyles.AllowExponent), "A#6"); + Assert.AreEqual (21, long.Parse ("2.1E1", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#7"); + Assert.AreEqual (520, long.Parse (".52E3", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#8"); + Assert.AreEqual (32500000, long.Parse ("32.5E6", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#9"); + Assert.AreEqual (890, long.Parse ("8.9000E2", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#10"); try { long.Parse ("2E"); @@ -379,6 +383,12 @@ public class Int64Test Assert.Fail ("B#8"); } catch (FormatException) { } + + try { + long.Parse ("2.09E1", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent); + Assert.Fail ("B#9"); + } catch (OverflowException) { + } } [Test] diff --git a/mcs/class/corlib/Test/System/UInt32Test.cs b/mcs/class/corlib/Test/System/UInt32Test.cs index 24396d72484..20f5a299e36 100644 --- a/mcs/class/corlib/Test/System/UInt32Test.cs +++ b/mcs/class/corlib/Test/System/UInt32Test.cs @@ -214,6 +214,10 @@ public class UInt32Test Assert.AreEqual (2000000, uint.Parse ("2E6", NumberStyles.AllowExponent), "A#4"); Assert.AreEqual (200, uint.Parse ("2E+2", NumberStyles.AllowExponent), "A#5"); Assert.AreEqual (2, uint.Parse ("2", NumberStyles.AllowExponent), "A#6"); + Assert.AreEqual (21, uint.Parse ("2.1E1", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#7"); + Assert.AreEqual (520, uint.Parse (".52E3", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#8"); + Assert.AreEqual (32500000, uint.Parse ("32.5E6", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#9"); + Assert.AreEqual (890, uint.Parse ("8.9000E2", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#10"); try { uint.Parse ("2E"); @@ -263,6 +267,12 @@ public class UInt32Test Assert.Fail ("B#8"); } catch (FormatException) { } + + try { + uint.Parse ("2.09E1", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent); + Assert.Fail ("B#9"); + } catch (OverflowException) { + } } [Test] diff --git a/mcs/class/corlib/Test/System/UInt64Test.cs b/mcs/class/corlib/Test/System/UInt64Test.cs index 335d216a4fc..3fbf591517b 100644 --- a/mcs/class/corlib/Test/System/UInt64Test.cs +++ b/mcs/class/corlib/Test/System/UInt64Test.cs @@ -203,6 +203,10 @@ public class UInt64Test Assert.AreEqual (2000000, ulong.Parse ("2E6", NumberStyles.AllowExponent), "A#4"); Assert.AreEqual (200, ulong.Parse ("2E+2", NumberStyles.AllowExponent), "A#5"); Assert.AreEqual (2, ulong.Parse ("2", NumberStyles.AllowExponent), "A#6"); + Assert.AreEqual (21, ulong.Parse ("2.1E1", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#7"); + Assert.AreEqual (520, ulong.Parse (".52E3", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#8"); + Assert.AreEqual (32500000, ulong.Parse ("32.5E6", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#9"); + Assert.AreEqual (890, ulong.Parse ("8.9000E2", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#10"); try { ulong.Parse ("2E"); @@ -252,6 +256,12 @@ public class UInt64Test Assert.Fail ("B#8"); } catch (FormatException) { } + + try { + ulong.Parse ("2.09E1", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent); + Assert.Fail ("B#9"); + } catch (OverflowException) { + } } [Test] diff --git a/mcs/class/monodoc/Makefile b/mcs/class/monodoc/Makefile index c61e7382c09..9436137d758 100644 --- a/mcs/class/monodoc/Makefile +++ b/mcs/class/monodoc/Makefile @@ -116,7 +116,7 @@ LIB_MCS_FLAGS = \ /r:System.Xml.Linq.dll \ /r:System.Configuration.dll -TEST_MCS_FLAGS = /r:System.Core.dll /r:System.Xml.dll +TEST_MCS_FLAGS = /r:System.dll /r:System.Core.dll /r:System.Xml.dll /r:AgilityPack.dll DOC_SOURCE_DIRS = \ ../../docs \ @@ -130,7 +130,9 @@ $(the_lib): Makefile $(RESOURCE_FILES) all-local: $(the_lib).config Monodoc.Ecma/EcmaUrlParser.cs -test-local: setup-doc-sources +run-test-local: AgilityPack.dll + +test-local: setup-doc-sources AgilityPack.dll dist-local: Monodoc.Ecma/EcmaUrlParser.cs @@ -146,3 +148,6 @@ parser.exe: Monodoc.Ecma/EcmaUrlParser.cs Monodoc.Ecma/EcmaUrlTokenizer.cs Monod setup-doc-sources: $(DOC_SOURCES) mkdir -p ./Test/monodoc_test/sources/ cp $(DOC_SOURCES) ./Test/monodoc_test/sources/ + +AgilityPack.dll: + cp $(topdir)/../docs/$(@) . diff --git a/mcs/class/monodoc/Monodoc.Ecma/EcmaDesc.cs b/mcs/class/monodoc/Monodoc.Ecma/EcmaDesc.cs index 0974b07adf1..c16645971de 100644 --- a/mcs/class/monodoc/Monodoc.Ecma/EcmaDesc.cs +++ b/mcs/class/monodoc/Monodoc.Ecma/EcmaDesc.cs @@ -86,11 +86,26 @@ namespace Monodoc.Ecma set; } + /* This property tells if the above collections only correct value + * is the number of item in it to represent generic arguments + */ + public bool GenericTypeArgumentsIsNumeric { + get { + return GenericTypeArguments != null && GenericTypeArguments.FirstOrDefault () == null; + } + } + public IList GenericMemberArguments { get; set; } + public bool GenericMemberArgumentsIsNumeric { + get { + return GenericMemberArguments != null && GenericMemberArguments.FirstOrDefault () == null; + } + } + public IList MemberArguments { get; set; @@ -304,27 +319,11 @@ namespace Monodoc.Ecma { if (args == null || !args.Any ()) return string.Empty; + // If we only have the number of generic arguments, use ` notation + if (args.First () == null) + return "`" + args.Count (); - IEnumerable argsList = null; - - // HACK: If we don't have fully specified EcmaDesc for generic arguments - // we use the most common names for the argument length configuration - if (args.Any (a => a == null)) { - var argCount = args.Count (); - switch (argCount) { - case 1: - argsList = new string[] { "T" }; - break; - case 2: - argsList = new string[] { "TKey", "TValue" }; - break; - default: - argsList = Enumerable.Range (1, argCount).Select (i => "T" + i); - break; - } - } else { - argsList = args.Select (t => FormatNamespace (t) + t.ToCompleteTypeName ()); - } + IEnumerable argsList = args.Select (t => FormatNamespace (t) + t.ToCompleteTypeName ()); return "<" + string.Join (",", argsList) + ">"; } diff --git a/mcs/class/monodoc/Monodoc.Ecma/EcmaUrlTokenizer.cs b/mcs/class/monodoc/Monodoc.Ecma/EcmaUrlTokenizer.cs index 151192096b1..a4cabd8a7de 100644 --- a/mcs/class/monodoc/Monodoc.Ecma/EcmaUrlTokenizer.cs +++ b/mcs/class/monodoc/Monodoc.Ecma/EcmaUrlTokenizer.cs @@ -80,8 +80,10 @@ namespace Monodoc.Ecma return Token.COMMA; case '.': return Token.DOT; + case '{': case '<': return Token.OP_GENERICS_LT; + case '}': case '>': return Token.OP_GENERICS_GT; case '`': diff --git a/mcs/class/monodoc/Monodoc/providers/EcmaDoc.cs b/mcs/class/monodoc/Monodoc/providers/EcmaDoc.cs index ba1be8a1b6a..e3371d141d0 100644 --- a/mcs/class/monodoc/Monodoc/providers/EcmaDoc.cs +++ b/mcs/class/monodoc/Monodoc/providers/EcmaDoc.cs @@ -212,7 +212,10 @@ namespace Monodoc.Providers currentNode = result; result = null; searchNode.Caption = desc.ToCompleteTypeName (); - index = currentNode.ChildNodes.BinarySearch (searchNode, EcmaTypeNodeComparer.Instance); + if (!desc.GenericTypeArgumentsIsNumeric) + index = currentNode.ChildNodes.BinarySearch (searchNode, EcmaTypeNodeComparer.Instance); + else + index = GenericTypeBacktickSearch (currentNode.ChildNodes, desc); if (index >= 0) result = currentNode.ChildNodes[index]; if ((desc.DescKind == EcmaDesc.Kind.Type && !desc.IsEtc) || index < 0) @@ -249,6 +252,48 @@ namespace Monodoc.Providers return result; } + static int GenericTypeBacktickSearch (IList childNodes, EcmaDesc desc) + { + /* Our strategy is to search for the non-generic variant of the type + * (which in most case should fail) and then use the closest index + * to linearily search for the generic variant with the right generic arg number + */ + var searchNode = new Node () { Caption = desc.TypeName }; + int index = childNodes.BinarySearch (searchNode, EcmaTypeNodeComparer.Instance); + // Place the index in the right start position + if (index < 0) + index = ~index; + + for (int i = index; i < childNodes.Count; i++) { + var currentNode = childNodes[i]; + // Find the index of the generic argument list + int genericIndex = currentNode.Caption.IndexOf ('<'); + // If we are not on the same base type name anymore, there is no point + int captionSlice = genericIndex != -1 ? genericIndex : currentNode.Caption.LastIndexOf (' '); + if (string.Compare (searchNode.Caption, 0, + currentNode.Caption, 0, + Math.Max (captionSlice, searchNode.Caption.Length), + StringComparison.Ordinal) != 0) + break; + + var numGenerics = CountTypeGenericArguments (currentNode.Caption, genericIndex); + if (numGenerics == desc.GenericTypeArguments.Count) { + // Simple comparison if we are not looking for an inner type + if (desc.NestedType == null) + return i; + // If more complicated, we fallback to using EcmaUrlParser + var caption = currentNode.Caption; + caption = "T:" + caption.Substring (0, caption.LastIndexOf (' ')).Replace ('.', '+'); + EcmaDesc otherDesc; + var parser = new EcmaUrlParser (); + if (parser.TryParse (caption, out otherDesc) && desc.NestedType.Equals (otherDesc.NestedType)) + return i; + } + } + + return -1; + } + // This comparer returns the answer straight from caption comparison class EcmaGenericNodeComparer : IComparer { @@ -436,6 +481,33 @@ namespace Monodoc.Providers return null; } + public static int CountTypeGenericArguments (string typeDefinition, int startIndex = 0) + { + int nestedLevel = 0; + int count = 0; + bool started = false; + + foreach (char c in typeDefinition.Skip (startIndex)) { + switch (c) { + case '<': + if (!started) + count = 1; + started = true; + nestedLevel++; + break; + case ',': + if (started && nestedLevel == 1) + count++; + break; + case '>': + nestedLevel--; + break; + } + } + + return count; + } + internal static string MakeOperatorSignature (XElement member, out string memberSignature) { string name = (string)member.Attribute ("MemberName"); diff --git a/mcs/class/monodoc/Test/Monodoc.Ecma/EcmaUrlTests.cs b/mcs/class/monodoc/Test/Monodoc.Ecma/EcmaUrlTests.cs index bcfeac51847..e6872f2ca5d 100644 --- a/mcs/class/monodoc/Test/Monodoc.Ecma/EcmaUrlTests.cs +++ b/mcs/class/monodoc/Test/Monodoc.Ecma/EcmaUrlTests.cs @@ -111,6 +111,7 @@ namespace MonoTests.Monodoc.Ecma AssertValidUrl ("C:Gendarme.Rules.Concurrency.DecorateThreadsRule.DecorateThreadsRule(System.String)"); AssertValidUrl ("C:Gendarme.Framework.Helpers.MethodSignature.MethodSignature(string,string,string[],System.Func)"); AssertValidUrl ("C:System.Collections.Generic.Dictionary+KeyCollection.KeyCollection(System.Collections.Generic.Dictionary)"); + AssertValidUrl ("C:Microsoft.Build.Utilities.TaskItem(System.String,System.Collections.IDictionary)"); } [Test] @@ -175,6 +176,22 @@ namespace MonoTests.Monodoc.Ecma AssertValidUrl ("M:Microsoft.Win32.RegistryKey$System.IDisposable.Dispose"); } + [Test] + public void AspNetSafeUrlValidTest () + { + AssertValidUrl ("M:MonoTouch.UIKit.UICollectionViewLayoutAttributes.CreateForCell{T}"); + } + + [Test] + public void GenericTypeArgsIsNumericTest () + { + var desc = parser.Parse ("T:System.Collections.Generic.Dictionary`2"); + Assert.IsTrue (desc.GenericTypeArgumentsIsNumeric); + Assert.AreEqual (2, desc.GenericTypeArguments.Count); + desc = parser.Parse ("T:System.Collections.Generic.Dictionary"); + Assert.IsFalse (desc.GenericTypeArgumentsIsNumeric); + } + [Test] public void MetaEtcNodeTest () { @@ -224,6 +241,25 @@ namespace MonoTests.Monodoc.Ecma AssertUrlDesc (ast, "T:System.String"); } + [Test] + public void TypeWithOneGenericUrlParseTestUsingAspNetStyleUrl () + { + var generics = new[] { + new EcmaDesc { + DescKind = EcmaDesc.Kind.Type, + Namespace = string.Empty, + TypeName = "T" + } + }; + var ast = new EcmaDesc () { DescKind = EcmaDesc.Kind.Type, + TypeName = "String", + Namespace = "System", + GenericTypeArguments = generics, + }; + + AssertUrlDesc (ast, "T:System.String{T}"); + } + [Test] public void TypeWithNestedGenericUrlParseTest () { diff --git a/mcs/class/monodoc/Test/Monodoc/EcmaDocTests.cs b/mcs/class/monodoc/Test/Monodoc/EcmaDocTests.cs new file mode 100644 index 00000000000..9886846ed4d --- /dev/null +++ b/mcs/class/monodoc/Test/Monodoc/EcmaDocTests.cs @@ -0,0 +1,66 @@ +using System; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Collections.Generic; + +using NUnit.Framework; + +using Monodoc; +using Monodoc.Generators; + +namespace MonoTests.Monodoc +{ + [TestFixture] + public class EcmaDocTest + { + // Because EcmaDoc is internal and we can't use InternalsVisibleTo since test assemblies aren't + // signed/strong-named by the build, we have to resort to reflection + TDelegate GetTestedMethod (string methodName) + { + var ecmaDoc = Type.GetType ("Monodoc.Providers.EcmaDoc, monodoc, PublicKey=0738eb9f132ed756"); + return (TDelegate)(object)Delegate.CreateDelegate (typeof (TDelegate), ecmaDoc.GetMethod (methodName)); + } + + [Test] + public void CountTypeGenericArgumentsTest () + { + var realCountTypeGenericArguments = GetTestedMethod> ("CountTypeGenericArguments"); + // Since we don't use the optional start index parameters, bypass it by wrapping the func + Func countTypeGenericArguments = s => realCountTypeGenericArguments (s, 0); + + Assert.AreEqual (0, countTypeGenericArguments ("T:System.String"), "#0a"); + Assert.AreEqual (0, countTypeGenericArguments ("T:String"), "#0b"); + Assert.AreEqual (0, countTypeGenericArguments ("String"), "#0c"); + + Assert.AreEqual (1, countTypeGenericArguments ("T:System.Collections.Foo"), "#1a"); + Assert.AreEqual (1, countTypeGenericArguments ("T:System.Foo"), "#1b"); + Assert.AreEqual (1, countTypeGenericArguments ("T:Foo"), "#1c"); + Assert.AreEqual (1, countTypeGenericArguments ("Foo"), "#1d"); + + Assert.AreEqual (2, countTypeGenericArguments ("T:System.Collections.Foo"), "#2a"); + Assert.AreEqual (2, countTypeGenericArguments ("T:System.Foo"), "#2b"); + Assert.AreEqual (2, countTypeGenericArguments ("T:Foo"), "#2c"); + Assert.AreEqual (2, countTypeGenericArguments ("Foo"), "#2d"); + + Assert.AreEqual (3, countTypeGenericArguments ("T:System.Collections.Foo"), "#3a"); + Assert.AreEqual (3, countTypeGenericArguments ("T:System.Foo"), "#3b"); + Assert.AreEqual (3, countTypeGenericArguments ("T:Foo"), "#3c"); + Assert.AreEqual (3, countTypeGenericArguments ("Foo"), "#3d"); + } + + [Test] + public void CountTypeGenericArgumentsTest_Nested () + { + var realCountTypeGenericArguments = GetTestedMethod> ("CountTypeGenericArguments"); + // Since we don't use the optional start index parameters, bypass it by wrapping the func + Func countTypeGenericArguments = s => realCountTypeGenericArguments (s, 0); + + Assert.AreEqual (1, countTypeGenericArguments ("T:System.Collections.Foo"), "#1a"); + Assert.AreEqual (1, countTypeGenericArguments ("T:System.Collections.Foo>"), "#1b"); + Assert.AreEqual (2, countTypeGenericArguments ("T:System.Collections.Foo>"), "#2a"); + Assert.AreEqual (2, countTypeGenericArguments ("T:System.Collections.Foo, IEquatable>>"), "#2b"); + Assert.AreEqual (3, countTypeGenericArguments ("T:System.Collections.Foo, IEquatable>"), "#3a"); + } + } +} diff --git a/mcs/class/monodoc/Test/Monodoc/HelpSourceTests.cs b/mcs/class/monodoc/Test/Monodoc/HelpSourceTests.cs index 0dd7b2ccc1f..0e36598fb5b 100644 --- a/mcs/class/monodoc/Test/Monodoc/HelpSourceTests.cs +++ b/mcs/class/monodoc/Test/Monodoc/HelpSourceTests.cs @@ -6,6 +6,9 @@ using System.Collections.Generic; using NUnit.Framework; using Monodoc; +using Monodoc.Generators; + +using HtmlAgilityPack; namespace MonoTests.Monodoc { @@ -110,6 +113,95 @@ namespace MonoTests.Monodoc Assert.IsTrue (rootTree.RenderUrl ("T:System.Collections.Concurrent.IProducerConsumerCollection`1", generator, out result), "#1"); Assert.IsTrue (rootTree.RenderUrl ("T:System.Collections.Generic.Dictionary`2", generator, out result), "#2"); Assert.IsTrue (rootTree.RenderUrl ("T:System.Action`4", generator, out result), "#3"); + Assert.IsTrue (rootTree.RenderUrl ("T:System.EventHandler`1", generator, out result), "#4"); + Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`5", generator, out result), "#5a"); + Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`4", generator, out result), "#5b"); + Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`6", generator, out result), "#5c"); + Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`7", generator, out result), "#5d"); + Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`3", generator, out result), "#5e"); + Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`2", generator, out result), "#5f"); + Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`1", generator, out result), "#5g"); + Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`8", generator, out result), "#5h"); + Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`9", generator, out result), "#5i"); + Assert.IsTrue (rootTree.RenderUrl ("T:System.Action`3", generator, out result), "#6a"); + Assert.IsTrue (rootTree.RenderUrl ("T:System.Action`2", generator, out result), "#6b"); + Assert.IsTrue (rootTree.RenderUrl ("T:System.Action`4", generator, out result), "#6c"); + Assert.IsTrue (rootTree.RenderUrl ("T:System.IComparable`1", generator, out result), "#7"); + Assert.IsTrue (rootTree.RenderUrl ("T:System.Lazy`1", generator, out result), "#8"); + Assert.IsTrue (rootTree.RenderUrl ("T:System.Tuple`1", generator, out result), "#9a"); + Assert.IsTrue (rootTree.RenderUrl ("T:System.Tuple`2", generator, out result), "#9b"); + Assert.IsTrue (rootTree.RenderUrl ("T:System.Tuple`3", generator, out result), "#9c"); + Assert.IsTrue (rootTree.RenderUrl ("T:System.Tuple`4", generator, out result), "#9d"); + Assert.IsTrue (rootTree.RenderUrl ("T:System.Collections.Generic.Dictionary`2+ValueCollection", generator, out result), "#10"); + Assert.IsFalse (rootTree.RenderUrl ("T:System.EventHandler`2", generator, out result), "#11"); + Assert.IsFalse (rootTree.RenderUrl ("T:System.Lazy`2", generator, out result), "#12"); + } + + [Test] + public void AspNetStyleUrlReachabilityTest () + { + var rootTree = RootTree.LoadTree (Path.GetFullPath (BaseDir), false); + Node result; + var generator = new CheckGenerator (); + + Assert.IsTrue (rootTree.RenderUrl ("T:System.Collections.Generic.Dictionary{TKey,TValue}", generator, out result), "#1"); + Assert.IsTrue (rootTree.RenderUrl ("T:System.Action{T1,T2}", generator, out result), "#2"); + Assert.IsTrue (rootTree.RenderUrl ("T:System.EventHandler{TEventArgs}", generator, out result), "#3"); + Assert.IsTrue (rootTree.RenderUrl ("T:System.Func{T1,T2,T3,TResult}", generator, out result), "#4"); + Assert.IsTrue (rootTree.RenderUrl ("T:System.Collections.Generic.Dictionary{TKey,TValue}+ValueCollection", generator, out result), "#5"); + Assert.IsTrue (rootTree.RenderUrl ("T:System.IComparable{T}", generator, out result), "#6"); + } + + [Test, Ignore ("Mono documentation is full of syntax errors so we can't use it reliably for this test")] + public void ReachabilityWithCrefsTest () + { + var rootTree = RootTree.LoadTree (Path.GetFullPath (BaseDir), false); + Node result; + var htmlGenerator = new HtmlGenerator (null); + var crefs = new HashSet (); + var generator = new CheckGenerator (); + int errorCount = 0; + + foreach (var leaf in GetLeaves (rootTree.RootNode)) { + Dictionary context; + string internalId = leaf.Tree.HelpSource.GetInternalIdForUrl (leaf.PublicUrl, out result, out context); + if (leaf.Tree.HelpSource.GetDocumentTypeForId (internalId) != DocumentType.EcmaXml) + continue; + + string content = null; + if (string.IsNullOrEmpty (content = rootTree.RenderUrl (leaf.PublicUrl, htmlGenerator, out result)) || leaf != result) { + Console.WriteLine ("Error: {0} with HelpSource {1} ", leaf.PublicUrl, leaf.Tree.HelpSource.Name); + continue; + } + + HtmlDocument doc = new HtmlDocument(); + try { + doc.LoadHtml (content); + } catch { + Console.WriteLine ("Couldn't load a HTML document for URL {0}", leaf.PublicUrl); + continue; + } + + foreach (HtmlNode link in doc.DocumentNode.SelectNodes("//a[@href]")) { + var newUrl = link.Attributes["href"].Value; + var hashIndex = newUrl.IndexOf ('#'); + if (hashIndex != -1) + newUrl = newUrl.Substring (0, hashIndex); + if (newUrl.Length > 1 && newUrl[1] == ':' && char.IsLetter (newUrl, 0) && char.ToLowerInvariant (newUrl[0]) != 'c') + crefs.Add (newUrl); + } + + foreach (var cref in crefs) { + if (!rootTree.RenderUrl (cref, generator, out result) || result == null) { + Console.WriteLine ("Error with cref: `{0}'", cref); + errorCount++; + } + } + + crefs.Clear (); + } + + Assert.AreEqual (0, errorCount, errorCount + " / " + crefs.Count); } } } diff --git a/mcs/class/monodoc/monodoc_test.dll.sources b/mcs/class/monodoc/monodoc_test.dll.sources index e99ffeae1a4..b806b8fb6e9 100644 --- a/mcs/class/monodoc/monodoc_test.dll.sources +++ b/mcs/class/monodoc/monodoc_test.dll.sources @@ -1,4 +1,5 @@ Monodoc/HelpSourceTests.cs +Monodoc/EcmaDocTests.cs Monodoc/TreeTest.cs Monodoc.Ecma/EcmaUrlTests.cs Monodoc/SettingsTest.cs diff --git a/mcs/errors/cs0012-19.cs b/mcs/errors/cs0012-19.cs new file mode 100644 index 00000000000..304229b5c48 --- /dev/null +++ b/mcs/errors/cs0012-19.cs @@ -0,0 +1,13 @@ +// CS0012: The type `A1' is defined in an assembly that is not referenced. Consider adding a reference to assembly `CS0012-lib-missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' +// Line: 10 +// Compiler options: -r:CS0012-lib.dll + +class Test +{ + public static void Main () + { + var b = new B (); + b.Test (); + b.Test (); + } +} \ No newline at end of file diff --git a/mcs/errors/cs0012-20.cs b/mcs/errors/cs0012-20.cs new file mode 100644 index 00000000000..27475081907 --- /dev/null +++ b/mcs/errors/cs0012-20.cs @@ -0,0 +1,19 @@ +// CS0012: The type `A1' is defined in an assembly that is not referenced. Consider adding a reference to assembly `CS0012-lib-missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' +// Line: 13 +// Compiler options: -r:CS0012-lib.dll + +using System.Threading.Tasks; + +class Test +{ + public static void Main () + { + var b = new B (); + var t = Task.Factory.StartNew (() => { + b.Test (); + b.Test (); + }); + + b.Test (); + } +} \ No newline at end of file diff --git a/mcs/errors/cs0154-5.cs b/mcs/errors/cs0154-5.cs new file mode 100644 index 00000000000..21f55ceae5a --- /dev/null +++ b/mcs/errors/cs0154-5.cs @@ -0,0 +1,19 @@ +// CS0154: The property or indexer `BugReport.MyProperty' cannot be used in this context because it lacks the `get' accessor +// Line: 16 + +static class BugReport +{ + static float MyProperty { + set { } + } + + static void MyExtension (this float val) + { + } + + public static void Main () + { + MyProperty.MyExtension (); + } +} + diff --git a/mcs/errors/cs0162-17.cs b/mcs/errors/cs0162-17.cs new file mode 100644 index 00000000000..821c7418a41 --- /dev/null +++ b/mcs/errors/cs0162-17.cs @@ -0,0 +1,12 @@ +// CS0162: Unreachable code detected +// Line: 10 +// Compiler options: -warnaserror + +public class X +{ + public static void Main () + { + return; + 1+1; + } +} \ No newline at end of file diff --git a/mcs/errors/cs0185-2.cs b/mcs/errors/cs0185-2.cs new file mode 100644 index 00000000000..3fa0fffe69b --- /dev/null +++ b/mcs/errors/cs0185-2.cs @@ -0,0 +1,18 @@ +// CS0185: `method group' is not a reference type as required by the lock statement +// Line: 15 + +class MainClass +{ + public static void Main () + { + lock (Bar.Buzz) { + } + } +} + +class Bar +{ + internal void Buzz () + { + } +} \ No newline at end of file diff --git a/mcs/errors/cs0185.cs b/mcs/errors/cs0185.cs index e678aefccf1..83dfe5e7609 100644 --- a/mcs/errors/cs0185.cs +++ b/mcs/errors/cs0185.cs @@ -1,5 +1,5 @@ // CS0185: `int' is not a reference type as required by the lock statement -// Line: +// Line: 7 class X { static void Main () diff --git a/mcs/errors/cs0761-2.cs b/mcs/errors/cs0761-2.cs new file mode 100644 index 00000000000..09964af492f --- /dev/null +++ b/mcs/errors/cs0761-2.cs @@ -0,0 +1,11 @@ +// CS0761: Partial method declarations of `C.Foo()' have inconsistent constraints for type parameter `U' +// Line: 8 + +partial class C +{ + partial void Foo () where T : new (); + + partial void Foo () + { + } +} diff --git a/mcs/errors/cs0761.cs b/mcs/errors/cs0761.cs new file mode 100644 index 00000000000..72b2744b5fc --- /dev/null +++ b/mcs/errors/cs0761.cs @@ -0,0 +1,11 @@ +// CS0761: Partial method declarations of `C.Foo()' have inconsistent constraints for type parameter `T' +// Line: 8 + +partial class C +{ + partial void Foo (); + + partial void Foo () where T : class + { + } +} diff --git a/mcs/errors/cs1001-8.cs b/mcs/errors/cs1001-8.cs new file mode 100644 index 00000000000..2462ee47d28 --- /dev/null +++ b/mcs/errors/cs1001-8.cs @@ -0,0 +1,10 @@ +// CS1001: Unexpected symbol `,', expecting identifier +// Line: 8 + +static class Converter +{ + static Dictionary options = new Dictionary () + { + { Options., "I am completed!" }, + }; +} \ No newline at end of file diff --git a/mcs/errors/cs1502-17.cs b/mcs/errors/cs1502-17.cs new file mode 100644 index 00000000000..e0235512fff --- /dev/null +++ b/mcs/errors/cs1502-17.cs @@ -0,0 +1,16 @@ +// CS1502: The best overloaded method match for `Foo.Test(int, string)' has some invalid arguments +// Line: 14 + +using System.Runtime.CompilerServices; + +public class Foo +{ + public void Test (int arg, [CallerMemberName] string s = null) + { + } + + void X () + { + Test (""); + } +} \ No newline at end of file diff --git a/mcs/errors/cs1502-18.cs b/mcs/errors/cs1502-18.cs new file mode 100644 index 00000000000..4e1a0dab434 --- /dev/null +++ b/mcs/errors/cs1502-18.cs @@ -0,0 +1,18 @@ +// CS1502: The best overloaded method match for `X.Add(params object[])' has some invalid arguments +// Line: 8 + +class X +{ + public static void Main () + { + Add (Foo (), Foo ()); + } + + public static void Add (params object[] args) + { + } + + static void Foo () + { + } +} \ No newline at end of file diff --git a/mcs/errors/cs1519-5.cs b/mcs/errors/cs1519-5.cs new file mode 100644 index 00000000000..0ebf40667ed --- /dev/null +++ b/mcs/errors/cs1519-5.cs @@ -0,0 +1,7 @@ +// CS1519: Unexpected symbol `}' in class, struct, or interface member declaration +// Line: 7 + +public class Foo +{ + public f +} \ No newline at end of file diff --git a/mcs/errors/cs1525-52.cs b/mcs/errors/cs1525-52.cs new file mode 100644 index 00000000000..d10e85643f2 --- /dev/null +++ b/mcs/errors/cs1525-52.cs @@ -0,0 +1,12 @@ +// CS1525: Unexpected symbol `}', expecting `by' +// Line: 10 + +class C +{ + public static void Main () + { + var somelist = new List(); + var query = from item in somelist + group a + } +} \ No newline at end of file diff --git a/mcs/errors/cs1525-53.cs b/mcs/errors/cs1525-53.cs new file mode 100644 index 00000000000..0c248dab589 --- /dev/null +++ b/mcs/errors/cs1525-53.cs @@ -0,0 +1,7 @@ +// CS1525: Unexpected symbol `}', expecting `(', `,', `.', `:', `::', `]', or `<' +// Line: 6 + +class Foo +{ + [DllImport +} \ No newline at end of file diff --git a/mcs/errors/cs1525-54.cs b/mcs/errors/cs1525-54.cs new file mode 100644 index 00000000000..faf331eaf5b --- /dev/null +++ b/mcs/errors/cs1525-54.cs @@ -0,0 +1,10 @@ +// CS1525: Unexpected symbol `}' +// Line: 8 + +class MainClass +{ + public string Test () + { + return true ? "Hello" : + } +} diff --git a/mcs/errors/cs1997-2.cs b/mcs/errors/cs1997-2.cs new file mode 100644 index 00000000000..9f8c533f51a --- /dev/null +++ b/mcs/errors/cs1997-2.cs @@ -0,0 +1,17 @@ +// CS1997: `System.Func': A return keyword must not be followed by an expression when async delegate returns `Task'. Consider using `Task' return type +// Line: 12 + +using System; +using System.Threading.Tasks; + +class Test +{ + public static void Main() + { + Func t = async delegate { + return null; + }; + + return; + } +} diff --git a/mcs/mcs/anonymous.cs b/mcs/mcs/anonymous.cs index fe16344ae0d..85fa42058ca 100644 --- a/mcs/mcs/anonymous.cs +++ b/mcs/mcs/anonymous.cs @@ -569,6 +569,9 @@ namespace Mono.CSharp { protected virtual void EmitHoistedParameters (EmitContext ec, List hoisted) { foreach (HoistedParameter hp in hoisted) { + if (hp == null) + continue; + // // Parameters could be proxied via local fields for value type storey // @@ -851,6 +854,8 @@ namespace Mono.CSharp { } } + public bool IsAssigned { get; set; } + public ParameterReference Parameter { get { return parameter; @@ -996,12 +1001,12 @@ namespace Mono.CSharp { return delegate_type; ec.Report.Error (835, loc, "Cannot convert `{0}' to an expression tree of non-delegate type `{1}'", - GetSignatureForError (), TypeManager.CSharpName (delegate_type)); + GetSignatureForError (), delegate_type.GetSignatureForError ()); return null; } ec.Report.Error (1660, loc, "Cannot convert `{0}' to non-delegate type `{1}'", - GetSignatureForError (), TypeManager.CSharpName (delegate_type)); + GetSignatureForError (), delegate_type.GetSignatureForError ()); return null; } @@ -1013,7 +1018,7 @@ namespace Mono.CSharp { if (!ec.IsInProbingMode) ec.Report.Error (1661, loc, "Cannot convert `{0}' to delegate type `{1}' since there is a parameter mismatch", - GetSignatureForError (), TypeManager.CSharpName (delegate_type)); + GetSignatureForError (), delegate_type.GetSignatureForError ()); return false; } @@ -1025,7 +1030,7 @@ namespace Mono.CSharp { return false; ec.Report.Error (1593, loc, "Delegate `{0}' does not take `{1}' arguments", - TypeManager.CSharpName (delegate_type), Parameters.Count.ToString ()); + delegate_type.GetSignatureForError (), Parameters.Count.ToString ()); return false; } @@ -1065,8 +1070,8 @@ namespace Mono.CSharp { ec.Report.Error (1678, loc, "Parameter `{0}' is declared as type `{1}' but should be `{2}'", (i+1).ToString (), - TypeManager.CSharpName (Parameters.Types [i]), - TypeManager.CSharpName (invoke_pd.Types [i])); + Parameters.Types [i].GetSignatureForError (), + invoke_pd.Types [i].GetSignatureForError ()); error = true; } } @@ -1370,7 +1375,7 @@ namespace Mono.CSharp { return null; } - b = b.ConvertToAsyncTask (ec, ec.CurrentMemberDefinition.Parent.PartialContainer, p, return_type, loc); + b = b.ConvertToAsyncTask (ec, ec.CurrentMemberDefinition.Parent.PartialContainer, p, return_type, delegate_type, loc); } return CompatibleMethodFactory (return_type ?? InternalType.ErrorType, delegate_type, p, b); @@ -1733,6 +1738,7 @@ namespace Mono.CSharp { // method = DoCreateMethodHost (ec); method.Define (); + method.PrepareEmit (); } bool is_static = (method.ModFlags & Modifiers.STATIC) != 0; @@ -1859,7 +1865,7 @@ namespace Mono.CSharp { public override string GetSignatureForError () { - return TypeManager.CSharpName (type); + return type.GetSignatureForError (); } } @@ -2081,6 +2087,7 @@ namespace Mono.CSharp { equals.Block = equals_block; equals.Define (); + equals.PrepareEmit (); Members.Add (equals); // @@ -2135,6 +2142,7 @@ namespace Mono.CSharp { hashcode_block.AddStatement (new Return (hash_variable, loc)); hashcode.Block = hashcode_top; hashcode.Define (); + hashcode.PrepareEmit (); Members.Add (hashcode); // @@ -2145,6 +2153,7 @@ namespace Mono.CSharp { tostring_block.AddStatement (new Return (string_concat, loc)); tostring.Block = tostring_block; tostring.Define (); + tostring.PrepareEmit (); Members.Add (tostring); return true; diff --git a/mcs/mcs/argument.cs b/mcs/mcs/argument.cs index 22e28eaf729..facb0eb28c0 100644 --- a/mcs/mcs/argument.cs +++ b/mcs/mcs/argument.cs @@ -47,9 +47,6 @@ namespace Mono.CSharp public Argument (Expression expr) { - if (expr == null) - throw new ArgumentNullException (); - this.Expr = expr; } @@ -135,7 +132,7 @@ namespace Mono.CSharp if (Expr.eclass == ExprClass.MethodGroup) return Expr.ExprClassName; - return TypeManager.CSharpName (Expr.Type); + return Expr.Type.GetSignatureForError (); } public bool ResolveMethodGroup (ResolveContext ec) @@ -350,7 +347,7 @@ namespace Mono.CSharp } else if (arg_type.Kind == MemberKind.Void || arg_type == InternalType.Arglist || arg_type.IsPointer) { rc.Report.Error (1978, a.Expr.Location, "An expression of type `{0}' cannot be used as an argument of dynamic operation", - TypeManager.CSharpName (arg_type)); + arg_type.GetSignatureForError ()); } info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags, diff --git a/mcs/mcs/assembly.cs b/mcs/mcs/assembly.cs index fa0a61b1750..6a62af9e22c 100644 --- a/mcs/mcs/assembly.cs +++ b/mcs/mcs/assembly.cs @@ -288,7 +288,7 @@ namespace Mono.CSharp } else if (emitted_forwarders.ContainsKey (t.MemberDefinition)) { Report.SymbolRelatedToPreviousError (emitted_forwarders[t.MemberDefinition].Location, null); Report.Error (739, a.Location, "A duplicate type forward of type `{0}'", - TypeManager.CSharpName (t)); + t.GetSignatureForError ()); return; } @@ -297,13 +297,13 @@ namespace Mono.CSharp if (t.MemberDefinition.DeclaringAssembly == this) { Report.SymbolRelatedToPreviousError (t); Report.Error (729, a.Location, "Cannot forward type `{0}' because it is defined in this assembly", - TypeManager.CSharpName (t)); + t.GetSignatureForError ()); return; } if (t.IsNested) { Report.Error (730, a.Location, "Cannot forward type `{0}' because it is a nested type", - TypeManager.CSharpName (t)); + t.GetSignatureForError ()); return; } diff --git a/mcs/mcs/async.cs b/mcs/mcs/async.cs index 7742126beda..6997d7ca850 100644 --- a/mcs/mcs/async.cs +++ b/mcs/mcs/async.cs @@ -378,6 +378,10 @@ namespace Mono.CSharp } } + public TypeSpec DelegateType { + get; set; + } + public override bool IsIterator { get { return false; diff --git a/mcs/mcs/attribute.cs b/mcs/mcs/attribute.cs index eb998caca39..6bbdb09b174 100644 --- a/mcs/mcs/attribute.cs +++ b/mcs/mcs/attribute.cs @@ -265,7 +265,7 @@ namespace Mono.CSharp { public void Error_AttributeEmitError (string inner) { Report.Error (647, Location, "Error during emitting `{0}' attribute. The reason is `{1}'", - TypeManager.CSharpName (Type), inner); + Type.GetSignatureForError (), inner); } public void Error_InvalidSecurityParent () @@ -368,7 +368,7 @@ namespace Mono.CSharp { public string GetSignatureForError () { if (Type != null) - return TypeManager.CSharpName (Type); + return Type.GetSignatureForError (); return expression.GetSignatureForError (); } @@ -449,7 +449,7 @@ namespace Mono.CSharp { ObsoleteAttribute obsolete_attr = Type.GetAttributeObsolete (); if (obsolete_attr != null) { - AttributeTester.Report_ObsoleteMessage (obsolete_attr, TypeManager.CSharpName (Type), Location, Report); + AttributeTester.Report_ObsoleteMessage (obsolete_attr, Type.GetSignatureForError (), Location, Report); } ResolveContext rc = null; diff --git a/mcs/mcs/class.cs b/mcs/mcs/class.cs index 24a6bf223eb..f33ddc37920 100644 --- a/mcs/mcs/class.cs +++ b/mcs/mcs/class.cs @@ -17,7 +17,6 @@ using System.Collections.Generic; using System.Runtime.InteropServices; using System.Security; using System.Security.Permissions; -using System.Linq; using System.Text; using System.Diagnostics; using Mono.CompilerServices.SymbolWriter; @@ -1260,8 +1259,10 @@ namespace Mono.CSharp all_tp_builders = TypeBuilder.DefineGenericParameters (tparam_names); - if (CurrentTypeParameters != null) - CurrentTypeParameters.Define (all_tp_builders, spec, CurrentTypeParametersStartIndex, this); + if (CurrentTypeParameters != null) { + CurrentTypeParameters.Create (spec, CurrentTypeParametersStartIndex, this); + CurrentTypeParameters.Define (all_tp_builders); + } } return true; @@ -1422,6 +1423,7 @@ namespace Mono.CSharp members.Add (proxy_method); proxy_method.Define (); + proxy_method.PrepareEmit (); hoisted_base_call_proxies.Add (method, proxy_method); } @@ -1604,6 +1606,10 @@ namespace Mono.CSharp foreach (var member in members) { var pm = member as IParametersMember; if (pm != null) { + var mc = member as MethodOrOperator; + if (mc != null) { + mc.PrepareEmit (); + } var p = pm.Parameters; if (p.IsEmpty) @@ -1675,19 +1681,6 @@ namespace Mono.CSharp current_type = null; } - void UpdateTypeParameterConstraints (TypeDefinition part) - { - for (int i = 0; i < CurrentTypeParameters.Count; i++) { - if (CurrentTypeParameters[i].AddPartialConstraints (part, part.MemberName.TypeParameters[i])) - continue; - - Report.SymbolRelatedToPreviousError (Location, ""); - Report.Error (265, part.Location, - "Partial declarations of `{0}' have inconsistent constraints for type parameter `{1}'", - GetSignatureForError (), CurrentTypeParameters[i].GetSignatureForError ()); - } - } - public override void RemoveContainer (TypeContainer cont) { base.RemoveContainer (cont); @@ -1712,7 +1705,7 @@ namespace Mono.CSharp } if (IsPartialPart) { - PartialContainer.UpdateTypeParameterConstraints (this); + PartialContainer.CurrentTypeParameters.UpdateConstraints (this); } return true; @@ -2273,7 +2266,7 @@ namespace Mono.CSharp Report.SymbolRelatedToPreviousError (mb.InterfaceType); Report.Error (540, mb.Location, "`{0}': containing type does not implement interface `{1}'", - mb.GetSignatureForError (), TypeManager.CSharpName (mb.InterfaceType)); + mb.GetSignatureForError (), mb.InterfaceType.GetSignatureForError ()); return false; } @@ -2503,7 +2496,7 @@ namespace Mono.CSharp /// /// Defines the default constructors /// - protected Constructor DefineDefaultConstructor (bool is_static) + protected virtual Constructor DefineDefaultConstructor (bool is_static) { // The default instance constructor is public // If the class is abstract, the default constructor is protected @@ -3024,7 +3017,7 @@ namespace Mono.CSharp Report.SymbolRelatedToPreviousError (iface); Report.Warning (3027, 1, Location, "`{0}' is not CLS-compliant because base interface `{1}' is not CLS-compliant", - GetSignatureForError (), TypeManager.CSharpName (iface)); + GetSignatureForError (), iface.GetSignatureForError ()); } } @@ -3259,10 +3252,10 @@ namespace Mono.CSharp Report.SymbolRelatedToPreviousError (base_member); if (this is PropertyBasedMember) { Report.Error (1715, Location, "`{0}': type must be `{1}' to match overridden member `{2}'", - GetSignatureForError (), TypeManager.CSharpName (base_member_type), TypeManager.CSharpSignature (base_member)); + GetSignatureForError (), base_member_type.GetSignatureForError (), base_member.GetSignatureForError ()); } else { Report.Error (508, Location, "`{0}': return type must be `{1}' to match overridden member `{2}'", - GetSignatureForError (), TypeManager.CSharpName (base_member_type), TypeManager.CSharpSignature (base_member)); + GetSignatureForError (), base_member_type.GetSignatureForError (), base_member.GetSignatureForError ()); } ok = false; } @@ -3336,7 +3329,7 @@ namespace Mono.CSharp if (!InterfaceType.IsInterface) { Report.SymbolRelatedToPreviousError (InterfaceType); Report.Error (538, Location, "The type `{0}' in explicit interface declaration is not an interface", - TypeManager.CSharpName (InterfaceType)); + InterfaceType.GetSignatureForError ()); } else { Parent.PartialContainer.VerifyImplements (this); } @@ -3367,15 +3360,15 @@ namespace Mono.CSharp if (this is Indexer) Report.Error (55, Location, "Inconsistent accessibility: parameter type `{0}' is less accessible than indexer `{1}'", - TypeManager.CSharpName (t), GetSignatureForError ()); + t.GetSignatureForError (), GetSignatureForError ()); else if (this is Operator) Report.Error (57, Location, "Inconsistent accessibility: parameter type `{0}' is less accessible than operator `{1}'", - TypeManager.CSharpName (t), GetSignatureForError ()); + t.GetSignatureForError (), GetSignatureForError ()); else Report.Error (51, Location, "Inconsistent accessibility: parameter type `{0}' is less accessible than method `{1}'", - TypeManager.CSharpName (t), GetSignatureForError ()); + t.GetSignatureForError (), GetSignatureForError ()); error = true; } return !error; @@ -3484,7 +3477,7 @@ namespace Mono.CSharp // replacing predefined names which saves some space and name // is still unique // - return TypeManager.CSharpName (InterfaceType) + "." + name; + return InterfaceType.GetSignatureForError () + "." + name; } public override string GetSignatureForDocumentation () @@ -3523,7 +3516,9 @@ namespace Mono.CSharp { this.Parent = parent; this.type_expr = type; - ModFlags = ModifiersExtensions.Check (allowed_mod, mod, def_mod, Location, Report); + + if (name != MemberName.Null) + ModFlags = ModifiersExtensions.Check (allowed_mod, mod, def_mod, Location, Report); } #region Properties @@ -3582,28 +3577,28 @@ namespace Mono.CSharp if (this is Property) Report.Error (53, Location, "Inconsistent accessibility: property type `" + - TypeManager.CSharpName (MemberType) + "' is less " + + MemberType.GetSignatureForError () + "' is less " + "accessible than property `" + GetSignatureForError () + "'"); else if (this is Indexer) Report.Error (54, Location, "Inconsistent accessibility: indexer return type `" + - TypeManager.CSharpName (MemberType) + "' is less " + + MemberType.GetSignatureForError () + "' is less " + "accessible than indexer `" + GetSignatureForError () + "'"); else if (this is MethodCore) { if (this is Operator) Report.Error (56, Location, "Inconsistent accessibility: return type `" + - TypeManager.CSharpName (MemberType) + "' is less " + + MemberType.GetSignatureForError () + "' is less " + "accessible than operator `" + GetSignatureForError () + "'"); else Report.Error (50, Location, "Inconsistent accessibility: return type `" + - TypeManager.CSharpName (MemberType) + "' is less " + + MemberType.GetSignatureForError () + "' is less " + "accessible than method `" + GetSignatureForError () + "'"); } else { Report.Error (52, Location, "Inconsistent accessibility: field type `" + - TypeManager.CSharpName (MemberType) + "' is less " + + MemberType.GetSignatureForError () + "' is less " + "accessible than field `" + GetSignatureForError () + "'"); } } diff --git a/mcs/mcs/const.cs b/mcs/mcs/const.cs index 7d149aae26c..da41e1ebad5 100644 --- a/mcs/mcs/const.cs +++ b/mcs/mcs/const.cs @@ -100,10 +100,10 @@ namespace Mono.CSharp { { if (t.IsGenericParameter) { Report.Error (1959, loc, - "Type parameter `{0}' cannot be declared const", TypeManager.CSharpName (t)); + "Type parameter `{0}' cannot be declared const", t.GetSignatureForError ()); } else { Report.Error (283, loc, - "The type `{0}' cannot be declared const", TypeManager.CSharpName (t)); + "The type `{0}' cannot be declared const", t.GetSignatureForError ()); } } } diff --git a/mcs/mcs/constant.cs b/mcs/mcs/constant.cs index acfb6a751f8..aceaedf7e7b 100644 --- a/mcs/mcs/constant.cs +++ b/mcs/mcs/constant.cs @@ -64,7 +64,7 @@ namespace Mono.CSharp { BuiltinTypeSpec.IsPrimitiveTypeOrDecimal (target) && BuiltinTypeSpec.IsPrimitiveTypeOrDecimal (type)) { ec.Report.Error (31, loc, "Constant value `{0}' cannot be converted to a `{1}'", - GetValueAsLiteral (), TypeManager.CSharpName (target)); + GetValueAsLiteral (), target.GetSignatureForError ()); } else { base.Error_ValueCannotBeConverted (ec, target, expl); } @@ -100,7 +100,7 @@ namespace Mono.CSharp { // reached, by calling Convert.ImplicitStandardConversionExists // throw new InternalErrorException ("Missing constant conversion between `{0}' and `{1}'", - TypeManager.CSharpName (Type), TypeManager.CSharpName (type)); + Type.GetSignatureForError (), type.GetSignatureForError ()); } return CreateConstantFromValue (type, constant_value, loc); @@ -396,7 +396,7 @@ namespace Mono.CSharp { catch { ec.Report.Error (31, loc, "Constant value `{0}' cannot be converted to a `{1}'", - GetValue ().ToString (), TypeManager.CSharpName (target)); + GetValue ().ToString (), target.GetSignatureForError ()); } } diff --git a/mcs/mcs/cs-parser.jay b/mcs/mcs/cs-parser.jay index 94af264c716..9d2d8db7fe0 100644 --- a/mcs/mcs/cs-parser.jay +++ b/mcs/mcs/cs-parser.jay @@ -139,6 +139,7 @@ namespace Mono.CSharp // LocationsBag lbag; List> mod_locations; + Stack location_stack; %} %token EOF @@ -675,6 +676,7 @@ attribute_sections attribute_section : OPEN_BRACKET { + PushLocation (GetLocation ($1)); lexer.parsing_attribute_section = true; } attribute_section_cont @@ -699,13 +701,43 @@ attribute_section_cont $$ = new List (0); else $$ = $4; - + + lbag.InsertLocation ($$, 0, PopLocation ()); + if ($5 != null) { + lbag.AddLocation ($$, GetLocation ($2), GetLocation ($5), GetLocation ($6)); + } else { + lbag.AddLocation ($$, GetLocation ($2), GetLocation ($6)); + } + current_attr_target = null; lexer.parsing_attribute_section = false; } | attribute_list opt_comma CLOSE_BRACKET { $$ = $1; + + lbag.InsertLocation ($$, 0, PopLocation ()); + if ($2 != null) { + lbag.AddLocation ($$, GetLocation($2), GetLocation ($3)); + } else { + lbag.AddLocation ($$, GetLocation($3)); + } + } + | IDENTIFIER error + { + Error_SyntaxError (yyToken); + + var lt = (Tokenizer.LocatedToken) $1; + var tne = new SimpleName (lt.Value, null, lt.Location); + + $$ = new List () { + new Attribute (null, tne, null, GetLocation ($1), false) + }; + } + | error + { + $$ = CheckAttributeTarget (GetTokenName (yyToken), GetLocation ($1)); + $$ = null; } ; @@ -717,16 +749,6 @@ attribute_target } | EVENT { $$ = "event"; } | RETURN { $$ = "return"; } - | error - { - if (yyToken == Token.IDENTIFIER) { - Error_SyntaxError (yyToken); - $$ = null; - } else { - string name = GetTokenName (yyToken); - $$ = CheckAttributeTarget (name, GetLocation ($1)); - } - } ; attribute_list @@ -737,7 +759,10 @@ attribute_list | attribute_list COMMA attribute { var attrs = (List) $1; - attrs.Add ((Attribute) $3); + if (attrs != null) { + attrs.Add ((Attribute) $3); + lbag.AppendTo (attrs, GetLocation ($2)); + } $$ = attrs; } @@ -819,6 +844,11 @@ positional_or_named_argument $$ = new Argument ((Expression) $1); } | named_argument + | error + { + Error_SyntaxError (yyToken); + $$ = null; + } ; named_attribute_argument @@ -890,13 +920,14 @@ class_member_declaration | destructor_declaration | type_declaration | attributes_without_members + | incomplete_member | error { report.Error (1519, lexer.Location, "Unexpected symbol `{0}' in class, struct, or interface member declaration", GetSymbolName (yyToken)); $$ = null; lexer.parsing_generic_declaration = false; - } + } ; struct_declaration @@ -1311,8 +1342,10 @@ method_header current_type.AddMember (method); - if ($11 != null) - method.SetConstraints ((List) $11); + async_block = (method.ModFlags & Modifiers.ASYNC) != 0; + + if ($12 != null) + method.SetConstraints ((List) $12); if (doc_support) method.DocComment = Lexer.consume_doc_comment (); @@ -2515,6 +2548,23 @@ attributes_without_members lexer.putback ('}'); } ; + +// For full ast try to recover incomplete ambiguous member +// declaration in form on class X { public int } +incomplete_member + : opt_attributes opt_modifiers member_type CLOSE_BRACE + { + report.Error (1519, lexer.Location, "Unexpected symbol `}' in class, struct, or interface member declaration"); + + lexer.putback ('}'); + + lexer.parsing_generic_declaration = false; + FullNamedExpression type = (FullNamedExpression) $3; + current_field = new Field (current_type, type, (Modifiers) $2, MemberName.Null, (Attributes) $1); + current_type.AddField (current_field); + $$ = current_field; + } + ; enum_declaration : opt_attributes @@ -3258,7 +3308,7 @@ member_initializer { report.Error (1920, GetLocation ($1), "An element initializer cannot be empty"); $$ = null; - } + } ; initializer_value @@ -3374,22 +3424,18 @@ element_access ; expression_list - : expression + : expression_or_error { var list = new List (4); list.Add ((Expression) $1); $$ = list; } - | expression_list COMMA expression + | expression_list COMMA expression_or_error { var list = (List) $1; list.Add ((Expression) $3); $$ = list; } - | expression_list error { - Error_SyntaxError (yyToken); - $$ = $1; - } ; expression_list_arguments @@ -4293,6 +4339,14 @@ conditional_expression $$ = new Conditional (new BooleanExpression ((Expression) $1), (Expression) $3, null, GetLocation ($2)); lbag.AddLocation ($$, GetLocation ($4)); } + | null_coalescing_expression INTERR expression COLON CLOSE_BRACE + { + Error_SyntaxError (Token.CLOSE_BRACE); + + $$ = new Conditional (new BooleanExpression ((Expression) $1), (Expression) $3, null, GetLocation ($2)); + lbag.AddLocation ($$, GetLocation ($4)); + lexer.putback ('}'); + } ; assignment_expression @@ -5154,7 +5208,10 @@ block_variable_declaration { $$ = current_variable; current_variable = null; - lbag.AddLocation ($$, GetLocation ($6)); + if ($4 != null) + lbag.AddLocation ($$, PopLocation (), GetLocation ($6)); + else + lbag.AddLocation ($$, GetLocation ($6)); } | CONST variable_type identifier_inside_body { @@ -5176,7 +5233,8 @@ opt_local_variable_initializer | ASSIGN block_variable_initializer { current_variable.Initializer = (Expression) $2; - // TODO: lbag + PushLocation (GetLocation ($1)); + $$ = current_variable; } | error { @@ -5308,7 +5366,6 @@ statement_expression ExpressionStatement s = $1 as ExpressionStatement; if (s == null) { var expr = $1 as Expression; - expr.Error_InvalidExpressionStatement (report); $$ = new StatementErrorExpression (expr); } else { $$ = new StatementExpression (s); @@ -5583,6 +5640,9 @@ for_initializer opt_local_variable_initializer opt_variable_declarators { $$ = current_variable; + if ($4 != null) + lbag.AddLocation (current_variable, PopLocation ()); + current_variable = null; } | statement_expression_list @@ -5798,7 +5858,7 @@ yield_statement FeatureIsNotAvailable (lt.Location, "iterators"); } - current_block.Explicit.RegisterIteratorYield (); + current_block.ParametersBlock.TopBlock.IsIterator = true; $$ = new YieldBreak (lt.Location); lbag.AddStatement ($$, GetLocation ($2), GetLocation ($3)); } @@ -6237,15 +6297,29 @@ select_or_group_clause current_block = new Linq.QueryBlock (current_block, lexer.Location); } - BY expression_or_error + by_expression { - $$ = new Linq.GroupBy ((Linq.QueryBlock)current_block, (Expression)$3, linq_clause_blocks.Pop (), (Expression)$6, GetLocation ($1)); - lbag.AddLocation ($$, GetLocation ($5)); + var obj = (object[]) $5; + + $$ = new Linq.GroupBy ((Linq.QueryBlock)current_block, (Expression)$3, linq_clause_blocks.Pop (), (Expression)obj[0], GetLocation ($1)); + lbag.AddLocation ($$, (Location) obj[1]); current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; } ; + +by_expression + : BY expression_or_error + { + $$ = new object[] { $2, GetLocation ($1) }; + } + | error + { + Error_SyntaxError (yyToken); + $$ = new object[2] { null, Location.Null }; + } + ; query_body_clauses : query_body_clause @@ -6851,6 +6925,23 @@ void StoreModifierLocation (object token, Location loc) mod_locations.Add (Tuple.Create ((Modifiers) token, loc)); } +[System.Diagnostics.Conditional ("FULL_AST")] +void PushLocation (Location loc) +{ + if (location_stack == null) + location_stack = new Stack (); + + location_stack.Push (loc); +} + +Location PopLocation () +{ + if (location_stack == null) + return Location.Null; + + return location_stack.Pop (); +} + string CheckAttributeTarget (string a, Location l) { switch (a) { diff --git a/mcs/mcs/cs-tokenizer.cs b/mcs/mcs/cs-tokenizer.cs index fffe767c633..0dfc0226f29 100644 --- a/mcs/mcs/cs-tokenizer.cs +++ b/mcs/mcs/cs-tokenizer.cs @@ -2819,7 +2819,8 @@ namespace Mono.CSharp } case PreprocessorDirective.Define: if (any_token_seen){ - Error_TokensSeen (); + if (caller_is_taking) + Error_TokensSeen (); return caller_is_taking; } PreProcessDefinition (true, arg, caller_is_taking); @@ -2827,7 +2828,8 @@ namespace Mono.CSharp case PreprocessorDirective.Undef: if (any_token_seen){ - Error_TokensSeen (); + if (caller_is_taking) + Error_TokensSeen (); return caller_is_taking; } PreProcessDefinition (false, arg, caller_is_taking); @@ -2940,6 +2942,7 @@ namespace Mono.CSharp advance_line (); } else if (c == '\\' && !quoted) { + ++col; int surrogate; c = escape (c, out surrogate); if (c == -1) diff --git a/mcs/mcs/decl.cs b/mcs/mcs/decl.cs index a9a67b2d0d3..e7f27aa7d62 100644 --- a/mcs/mcs/decl.cs +++ b/mcs/mcs/decl.cs @@ -937,7 +937,8 @@ namespace Mono.CSharp { InflatedExpressionType = 1 << 19, InflatedNullableType = 1 << 20, GenericIterateInterface = 1 << 21, - GenericTask = 1 << 22 + GenericTask = 1 << 22, + InterfacesImported = 1 << 23, } // @@ -1274,6 +1275,11 @@ namespace Mono.CSharp { void SetIsUsed (); } + public interface IMethodDefinition : IMemberDefinition + { + MethodBase Metadata { get; } + } + public interface IParametersMember : IInterfaceMemberSpec { AParametersCollection Parameters { get; } diff --git a/mcs/mcs/delegate.cs b/mcs/mcs/delegate.cs index a73c9f68c75..13a2a4c7bcf 100644 --- a/mcs/mcs/delegate.cs +++ b/mcs/mcs/delegate.cs @@ -153,7 +153,7 @@ namespace Mono.CSharp { Report.SymbolRelatedToPreviousError (partype); Report.Error (59, Location, "Inconsistent accessibility: parameter type `{0}' is less accessible than delegate `{1}'", - TypeManager.CSharpName (partype), GetSignatureForError ()); + partype.GetSignatureForError (), GetSignatureForError ()); } } @@ -169,7 +169,7 @@ namespace Mono.CSharp { Report.SymbolRelatedToPreviousError (ret_type); Report.Error (58, Location, "Inconsistent accessibility: return type `" + - TypeManager.CSharpName (ret_type) + "' is less " + + ret_type.GetSignatureForError () + "' is less " + "accessible than delegate `" + GetSignatureForError () + "'"); return false; } @@ -297,6 +297,12 @@ namespace Mono.CSharp { if (!Parameters.IsEmpty) { parameters.ResolveDefaultValues (this); } + + InvokeBuilder.PrepareEmit (); + if (BeginInvokeBuilder != null) { + BeginInvokeBuilder.PrepareEmit (); + EndInvokeBuilder.PrepareEmit (); + } } public override void Emit () @@ -522,7 +528,7 @@ namespace Mono.CSharp { TypeSpec e_type = emg.ExtensionExpression.Type; if (TypeSpec.IsValueType (e_type)) { ec.Report.Error (1113, loc, "Extension method `{0}' of value type `{1}' cannot be used to create delegates", - delegate_method.GetSignatureForError (), TypeManager.CSharpName (e_type)); + delegate_method.GetSignatureForError (), e_type.GetSignatureForError ()); } } @@ -586,8 +592,8 @@ namespace Mono.CSharp { ec.Report.SymbolRelatedToPreviousError (method); if (ec.Module.Compiler.Settings.Version == LanguageVersion.ISO_1) { ec.Report.Error (410, loc, "A method or delegate `{0} {1}' parameters and return type must be same as delegate `{2} {3}' parameters and return type", - TypeManager.CSharpName (method.ReturnType), member_name, - TypeManager.CSharpName (invoke_method.ReturnType), Delegate.FullDelegateDesc (invoke_method)); + method.ReturnType.GetSignatureForError (), member_name, + invoke_method.ReturnType.GetSignatureForError (), Delegate.FullDelegateDesc (invoke_method)); return; } @@ -599,7 +605,7 @@ namespace Mono.CSharp { ec.Report.Error (407, loc, "A method or delegate `{0} {1}' return type does not match delegate `{2} {3}' return type", return_type.GetSignatureForError (), member_name, - TypeManager.CSharpName (invoke_method.ReturnType), Delegate.FullDelegateDesc (invoke_method)); + invoke_method.ReturnType.GetSignatureForError (), Delegate.FullDelegateDesc (invoke_method)); } public static bool ImplicitStandardConversionExists (ResolveContext ec, MethodGroupExpr mg, TypeSpec target_type) diff --git a/mcs/mcs/dynamic.cs b/mcs/mcs/dynamic.cs index b9d6967dccf..0246c43a1b6 100644 --- a/mcs/mcs/dynamic.cs +++ b/mcs/mcs/dynamic.cs @@ -447,6 +447,7 @@ namespace Mono.CSharp d.CreateContainer (); d.DefineContainer (); d.Define (); + d.PrepareEmit (); site.AddTypeContainer (d); del_type = new TypeExpression (d.CurrentType, loc); diff --git a/mcs/mcs/ecore.cs b/mcs/mcs/ecore.cs index ee025092c44..185c2e833e1 100644 --- a/mcs/mcs/ecore.cs +++ b/mcs/mcs/ecore.cs @@ -251,7 +251,7 @@ namespace Mono.CSharp { public void Error_ConstantCanBeInitializedWithNullOnly (ResolveContext rc, TypeSpec type, Location loc, string name) { rc.Report.Error (134, loc, "A constant `{0}' of reference type `{1}' can only be initialized with null", - name, TypeManager.CSharpName (type)); + name, type.GetSignatureForError ()); } protected virtual void Error_InvalidExpressionStatement (Report report, Location loc) @@ -282,7 +282,10 @@ namespace Mono.CSharp { protected void Error_ValueCannotBeConvertedCore (ResolveContext ec, Location loc, TypeSpec target, bool expl) { // The error was already reported as CS1660 - if (type == InternalType.AnonymousMethod || type == InternalType.ErrorType) + if (type == InternalType.AnonymousMethod) + return; + + if (type == InternalType.ErrorType || target == InternalType.ErrorType) return; string from_type = type.GetSignatureForError (); @@ -351,7 +354,7 @@ namespace Mono.CSharp { { ec.Report.SymbolRelatedToPreviousError (type); ec.Report.Error (117, loc, "`{0}' does not contain a definition for `{1}'", - TypeManager.CSharpName (type), name); + type.GetSignatureForError (), name); } public virtual void Error_ValueAssignment (ResolveContext rc, Expression rhs) @@ -1475,7 +1478,7 @@ namespace Mono.CSharp { public override string GetSignatureForError() { - return TypeManager.CSharpName (Type); + return Type.GetSignatureForError (); } public override object GetValue () @@ -3244,7 +3247,7 @@ namespace Mono.CSharp { class ExtensionMethodGroupExpr : MethodGroupExpr, OverloadResolver.IErrorHandler { ExtensionMethodCandidates candidates; - public readonly Expression ExtensionExpression; + public Expression ExtensionExpression; public ExtensionMethodGroupExpr (ExtensionMethodCandidates candidates, Expression extensionExpr, Location loc) : base (candidates.Methods.Cast().ToList (), extensionExpr.Type, loc) @@ -3288,6 +3291,10 @@ namespace Mono.CSharp { if (arguments == null) arguments = new Arguments (1); + ExtensionExpression = ExtensionExpression.Resolve (ec); + if (ExtensionExpression == null) + return null; + arguments.Insert (0, new Argument (ExtensionExpression, Argument.AType.ExtensionType)); var res = base.OverloadResolve (ec, ref arguments, ehandler ?? this, restr); @@ -3499,7 +3506,7 @@ namespace Mono.CSharp { public override void Error_ValueCannotBeConverted (ResolveContext ec, TypeSpec target, bool expl) { ec.Report.Error (428, loc, "Cannot convert method group `{0}' to non-delegate type `{1}'. Consider using parentheses to invoke the method", - Name, TypeManager.CSharpName (target)); + Name, target.GetSignatureForError ()); } public static bool IsExtensionMethodArgument (Expression expr) @@ -4551,17 +4558,18 @@ namespace Mono.CSharp { // It can be applicable in expanded form (when not doing exact match like for delegates) // if (score != 0 && (p_mod & Parameter.Modifier.PARAMS) != 0 && (restrictions & Restrictions.CovariantDelegate) == 0) { - if (!params_expanded_form) + if (!params_expanded_form) { pt = ((ElementTypeSpec) pt).Element; + } if (score > 0) score = IsArgumentCompatible (ec, a, Parameter.Modifier.NONE, pt); - if (score == 0) { - params_expanded_form = true; - } else if (score < 0) { + if (score < 0) { params_expanded_form = true; dynamicArgument = true; + } else if (score == 0 || arg_count > pd.Count) { + params_expanded_form = true; } } @@ -5040,14 +5048,14 @@ namespace Mono.CSharp { string index = (idx + 1).ToString (); if (((mod & Parameter.Modifier.RefOutMask) ^ (a.Modifier & Parameter.Modifier.RefOutMask)) != 0) { if ((mod & Parameter.Modifier.RefOutMask) == 0) - ec.Report.Error (1615, loc, "Argument `#{0}' does not require `{1}' modifier. Consider removing `{1}' modifier", + ec.Report.Error (1615, a.Expr.Location, "Argument `#{0}' does not require `{1}' modifier. Consider removing `{1}' modifier", index, Parameter.GetModifierSignature (a.Modifier)); else - ec.Report.Error (1620, loc, "Argument `#{0}' is missing `{1}' modifier", + ec.Report.Error (1620, a.Expr.Location, "Argument `#{0}' is missing `{1}' modifier", index, Parameter.GetModifierSignature (mod)); } else { string p1 = a.GetSignatureForError (); - string p2 = TypeManager.CSharpName (paramType); + string p2 = paramType.GetSignatureForError (); if (p1 == p2) { p1 = a.Type.GetSignatureForErrorIncludingAssemblyName (); diff --git a/mcs/mcs/enum.cs b/mcs/mcs/enum.cs index 7a025bb6c34..1081e0e551e 100644 --- a/mcs/mcs/enum.cs +++ b/mcs/mcs/enum.cs @@ -269,7 +269,7 @@ namespace Mono.CSharp { case BuiltinTypeSpec.Type.ULong: case BuiltinTypeSpec.Type.UShort: Report.Warning (3009, 1, Location, "`{0}': base type `{1}' is not CLS-compliant", - GetSignatureForError (), TypeManager.CSharpName (UnderlyingType)); + GetSignatureForError (), UnderlyingType.GetSignatureForError ()); break; } diff --git a/mcs/mcs/expression.cs b/mcs/mcs/expression.cs index a43e4ab7dc8..5eee6be0fc2 100644 --- a/mcs/mcs/expression.cs +++ b/mcs/mcs/expression.cs @@ -1437,10 +1437,10 @@ namespace Mono.CSharp { if (result) ec.Report.Warning (183, 1, loc, "The given expression is always of the provided (`{0}') type", - TypeManager.CSharpName (probe_type_expr)); + probe_type_expr.GetSignatureForError ()); else ec.Report.Warning (184, 1, loc, "The given expression is never of the provided (`{0}') type", - TypeManager.CSharpName (probe_type_expr)); + probe_type_expr.GetSignatureForError ()); return ReducedExpression.Create (new BoolConstant (ec.BuiltinTypes, result, loc), this); } @@ -1630,7 +1630,7 @@ namespace Mono.CSharp } else { ec.Report.Error (77, loc, "The `as' operator cannot be used with a non-nullable value type `{0}'", - TypeManager.CSharpName (type)); + type.GetSignatureForError ()); } return null; } @@ -1663,7 +1663,7 @@ namespace Mono.CSharp } ec.Report.Error (39, loc, "Cannot convert type `{0}' to `{1}' via a built-in conversion", - TypeManager.CSharpName (etype), TypeManager.CSharpName (type)); + etype.GetSignatureForError (), type.GetSignatureForError ()); return null; } @@ -1702,7 +1702,7 @@ namespace Mono.CSharp return null; if (type.IsStatic) { - ec.Report.Error (716, loc, "Cannot convert to static type `{0}'", TypeManager.CSharpName (type)); + ec.Report.Error (716, loc, "Cannot convert to static type `{0}'", type.GetSignatureForError ()); return null; } @@ -2255,6 +2255,12 @@ namespace Mono.CSharp } } + public override Location StartLocation { + get { + return left.StartLocation; + } + } + #endregion /// @@ -2340,8 +2346,8 @@ namespace Mono.CSharp return; string l, r; - l = TypeManager.CSharpName (left.Type); - r = TypeManager.CSharpName (right.Type); + l = left.Type.GetSignatureForError (); + r = right.Type.GetSignatureForError (); ec.Report.Error (19, loc, "Operator `{0}' cannot be applied to operands of type `{1}' and `{2}'", oper, l, r); @@ -2716,9 +2722,10 @@ namespace Mono.CSharp // FIXME: consider constants + var ltype = lcast != null ? lcast.UnderlyingType : rcast.UnderlyingType; ec.Report.Warning (675, 3, loc, "The operator `|' used on the sign-extended type `{0}'. Consider casting to a smaller unsigned type first", - TypeManager.CSharpName (lcast != null ? lcast.UnderlyingType : rcast.UnderlyingType)); + ltype.GetSignatureForError ()); } public static PredefinedOperator[] CreatePointerOperatorsTable (BuiltinTypes types) @@ -2931,7 +2938,7 @@ namespace Mono.CSharp // FIXME: resolve right expression as unreachable // right.Resolve (ec); - ec.Report.Warning (429, 4, loc, "Unreachable expression code detected"); + ec.Report.Warning (429, 4, right.StartLocation, "Unreachable expression code detected"); return left; } @@ -3557,7 +3564,7 @@ namespace Mono.CSharp if (best_operator == null) { ec.Report.Error (34, loc, "Operator `{0}' is ambiguous on operands of type `{1}' and `{2}'", - OperName (oper), TypeManager.CSharpName (l), TypeManager.CSharpName (r)); + OperName (oper), l.GetSignatureForError (), r.GetSignatureForError ()); best_operator = po; break; @@ -3713,7 +3720,7 @@ namespace Mono.CSharp } catch (OverflowException) { ec.Report.Warning (652, 2, loc, "A comparison between a constant and a variable is useless. The constant is out of the range of the variable type `{0}'", - TypeManager.CSharpName (type)); + type.GetSignatureForError ()); } } } @@ -4273,7 +4280,7 @@ namespace Mono.CSharp if (op_true == null || op_false == null) { ec.Report.Error (218, loc, "The type `{0}' must have operator `true' and operator `false' defined when `{1}' is used as a short circuit operator", - TypeManager.CSharpName (type), oper.GetSignatureForError ()); + type.GetSignatureForError (), oper.GetSignatureForError ()); return null; } @@ -4684,7 +4691,7 @@ namespace Mono.CSharp } else { ec.Report.Error (173, true_expr.Location, "Type of conditional expression cannot be determined because there is no implicit conversion between `{0}' and `{1}'", - TypeManager.CSharpName (true_type), TypeManager.CSharpName (false_type)); + true_type.GetSignatureForError (), false_type.GetSignatureForError ()); return null; } } @@ -5184,6 +5191,9 @@ namespace Mono.CSharp void SetAssigned (ResolveContext ec) { + if (Parameter.HoistedVariant != null) + Parameter.HoistedVariant.IsAssigned = true; + if (HasOutModifier && ec.DoFlowAnalysis) ec.CurrentBranching.SetAssigned (VariableInfo); } @@ -5757,7 +5767,7 @@ namespace Mono.CSharp if (type.IsPointer) { ec.Report.Error (1919, loc, "Unsafe type `{0}' cannot be used in an object creation expression", - TypeManager.CSharpName (type)); + type.GetSignatureForError ()); return null; } @@ -5780,13 +5790,13 @@ namespace Mono.CSharp if ((tparam.SpecialConstraint & (SpecialConstraint.Struct | SpecialConstraint.Constructor)) == 0 && !TypeSpec.IsValueType (tparam)) { ec.Report.Error (304, loc, "Cannot create an instance of the variable type `{0}' because it does not have the new() constraint", - TypeManager.CSharpName (type)); + type.GetSignatureForError ()); } if ((arguments != null) && (arguments.Count != 0)) { ec.Report.Error (417, loc, "`{0}': cannot provide arguments when creating an instance of a variable type", - TypeManager.CSharpName (type)); + type.GetSignatureForError ()); } return this; @@ -5794,7 +5804,7 @@ namespace Mono.CSharp if (type.IsStatic) { ec.Report.SymbolRelatedToPreviousError (type); - ec.Report.Error (712, loc, "Cannot create an instance of the static class `{0}'", TypeManager.CSharpName (type)); + ec.Report.Error (712, loc, "Cannot create an instance of the static class `{0}'", type.GetSignatureForError ()); return null; } @@ -5806,7 +5816,7 @@ namespace Mono.CSharp } ec.Report.SymbolRelatedToPreviousError (type); - ec.Report.Error (144, loc, "Cannot create an instance of the abstract class or interface `{0}'", TypeManager.CSharpName (type)); + ec.Report.Error (144, loc, "Cannot create an instance of the abstract class or interface `{0}'", type.GetSignatureForError ()); return null; } @@ -7794,7 +7804,7 @@ namespace Mono.CSharp if (!ec.IsUnsafe) { ec.Report.Error (233, loc, "`{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context (consider using System.Runtime.InteropServices.Marshal.SizeOf)", - TypeManager.CSharpName (type_queried)); + type_queried.GetSignatureForError ()); } type = ec.BuiltinTypes.Int; @@ -10073,8 +10083,8 @@ namespace Mono.CSharp ec.Report.Error (1922, loc, "A field or property `{0}' cannot be initialized with a collection " + "object initializer because type `{1}' does not implement `{2}' interface", ec.CurrentInitializerVariable.GetSignatureForError (), - TypeManager.CSharpName (ec.CurrentInitializerVariable.Type), - TypeManager.CSharpName (ec.BuiltinTypes.IEnumerable)); + ec.CurrentInitializerVariable.Type.GetSignatureForError (), + ec.BuiltinTypes.IEnumerable.GetSignatureForError ()); return null; } is_collection_initialization = true; @@ -10108,7 +10118,7 @@ namespace Mono.CSharp if (is_collection_initialization) { if (TypeManager.HasElementType (type)) { ec.Report.Error (1925, loc, "Cannot initialize object of type `{0}' with a collection initializer", - TypeManager.CSharpName (type)); + type.GetSignatureForError ()); } } diff --git a/mcs/mcs/field.cs b/mcs/mcs/field.cs index 3b0f76d34ee..ee55bec872a 100644 --- a/mcs/mcs/field.cs +++ b/mcs/mcs/field.cs @@ -482,7 +482,7 @@ namespace Mono.CSharp if (buffer_size > int.MaxValue / type_size) { Report.Error (1664, Location, "Fixed size buffer `{0}' of length `{1}' and type `{2}' exceeded 2^31 limit", - GetSignatureForError (), buffer_size.ToString (), TypeManager.CSharpName (MemberType)); + GetSignatureForError (), buffer_size.ToString (), MemberType.GetSignatureForError ()); return; } @@ -664,7 +664,7 @@ namespace Mono.CSharp if ((ModFlags & Modifiers.VOLATILE) != 0) { if (!CanBeVolatile ()) { Report.Error (677, Location, "`{0}': A volatile field cannot be of the type `{1}'", - GetSignatureForError (), TypeManager.CSharpName (MemberType)); + GetSignatureForError (), MemberType.GetSignatureForError ()); } if ((ModFlags & Modifiers.READONLY) != 0) { diff --git a/mcs/mcs/generic.cs b/mcs/mcs/generic.cs index b8cec0cfff2..3e8d32f8d5f 100644 --- a/mcs/mcs/generic.cs +++ b/mcs/mcs/generic.cs @@ -312,7 +312,7 @@ namespace Mono.CSharp { if (type.IsSealed || !type.IsClass) { context.Module.Compiler.Report.Error (701, loc, "`{0}' is not a valid constraint. A constraint must be an interface, a non-sealed class or a type parameter", - TypeManager.CSharpName (type)); + type.GetSignatureForError ()); continue; } @@ -489,7 +489,7 @@ namespace Mono.CSharp { // // If partial type parameters constraints are not null and we don't // already have constraints they become our constraints. If we already - // have constraints, we must check that they're the same. + // have constraints, we must check that they're same. // public bool AddPartialConstraints (TypeDefinition part, TypeParameter tp) { @@ -545,15 +545,19 @@ namespace Mono.CSharp { // with SRE (by calling `DefineGenericParameters()' on the TypeBuilder / // MethodBuilder). // - public void Define (GenericTypeParameterBuilder type, TypeSpec declaringType, TypeContainer parent) + public void Create (TypeSpec declaringType, TypeContainer parent) { if (builder != null) throw new InternalErrorException (); // Needed to get compiler reference this.Parent = parent; - this.builder = type; spec.DeclaringType = declaringType; + } + + public void Define (GenericTypeParameterBuilder type) + { + this.builder = type; spec.SetMetaInfo (type); } @@ -776,6 +780,8 @@ namespace Mono.CSharp { } } } + } else if (ifaces_defined == null) { + ifaces_defined = ifaces == null ? TypeSpec.EmptyTypes : ifaces.ToArray (); } // @@ -793,9 +799,6 @@ namespace Mono.CSharp { } } - if (ifaces_defined == null) - ifaces_defined = ifaces == null ? TypeSpec.EmptyTypes : ifaces.ToArray (); - state |= StateFlags.InterfacesExpanded; } @@ -2176,13 +2179,13 @@ namespace Mono.CSharp { names.AddRange (tparams.names); } - public void Define (GenericTypeParameterBuilder[] buiders, TypeSpec declaringType, int parentOffset, TypeContainer parent) + public void Create (TypeSpec declaringType, int parentOffset, TypeContainer parent) { types = new TypeParameterSpec[Count]; for (int i = 0; i < types.Length; ++i) { var tp = names[i]; - tp.Define (buiders[i + parentOffset], declaringType, parent); + tp.Create (declaringType, parent); types[i] = tp.Type; types[i].DeclaredPosition = i + parentOffset; @@ -2192,6 +2195,14 @@ namespace Mono.CSharp { } } + public void Define (GenericTypeParameterBuilder[] builders) + { + for (int i = 0; i < types.Length; ++i) { + var tp = names[i]; + tp.Define (builders [types [i].DeclaredPosition]); + } + } + public TypeParameter this[int index] { get { return names [index]; @@ -2231,6 +2242,44 @@ namespace Mono.CSharp { return sb.ToString (); } + + public void CheckPartialConstraints (Method part) + { + var partTypeParameters = part.CurrentTypeParameters; + + for (int i = 0; i < Count; i++) { + var tp_a = names[i]; + var tp_b = partTypeParameters [i]; + if (tp_a.Constraints == null) { + if (tp_b.Constraints == null) + continue; + } else if (tp_b.Constraints != null && tp_a.Type.HasSameConstraintsDefinition (tp_b.Type)) { + continue; + } + + part.Compiler.Report.SymbolRelatedToPreviousError (this[i].CurrentMemberDefinition.Location, ""); + part.Compiler.Report.Error (761, part.Location, + "Partial method declarations of `{0}' have inconsistent constraints for type parameter `{1}'", + part.GetSignatureForError (), partTypeParameters[i].GetSignatureForError ()); + } + } + + public void UpdateConstraints (TypeDefinition part) + { + var partTypeParameters = part.MemberName.TypeParameters; + + for (int i = 0; i < Count; i++) { + var tp = names [i]; + if (tp.AddPartialConstraints (part, partTypeParameters [i])) + continue; + + part.Compiler.Report.SymbolRelatedToPreviousError (this[i].CurrentMemberDefinition); + part.Compiler.Report.Error (265, part.Location, + "Partial declarations of `{0}' have inconsistent constraints for type parameter `{1}'", + part.GetSignatureForError (), tp.GetSignatureForError ()); + } + } + public void VerifyClsCompliance () { foreach (var tp in names) { @@ -2261,7 +2310,7 @@ namespace Mono.CSharp { public override string GetSignatureForError () { - return TypeManager.CSharpName (type); + return type.GetSignatureForError (); } public override TypeSpec ResolveAsType (IMemberContext mc) @@ -2409,7 +2458,7 @@ namespace Mono.CSharp { if (mc != null) { mc.Module.Compiler.Report.Error (452, loc, "The type `{0}' must be a reference type in order to use it as type parameter `{1}' in the generic type or method `{2}'", - TypeManager.CSharpName (atype), tparam.GetSignatureForError (), context.GetSignatureForError ()); + atype.GetSignatureForError (), tparam.GetSignatureForError (), context.GetSignatureForError ()); } return false; @@ -2419,7 +2468,7 @@ namespace Mono.CSharp { if (mc != null) { mc.Module.Compiler.Report.Error (453, loc, "The type `{0}' must be a non-nullable value type in order to use it as type parameter `{1}' in the generic type or method `{2}'", - TypeManager.CSharpName (atype), tparam.GetSignatureForError (), context.GetSignatureForError ()); + atype.GetSignatureForError (), tparam.GetSignatureForError (), context.GetSignatureForError ()); } return false; @@ -2480,7 +2529,7 @@ namespace Mono.CSharp { mc.Module.Compiler.Report.SymbolRelatedToPreviousError (atype); mc.Module.Compiler.Report.Error (310, loc, "The type `{0}' must have a public parameterless constructor in order to use it as parameter `{1}' in the generic type or method `{2}'", - TypeManager.CSharpName (atype), tparam.GetSignatureForError (), context.GetSignatureForError ()); + atype.GetSignatureForError (), tparam.GetSignatureForError (), context.GetSignatureForError ()); } return false; } diff --git a/mcs/mcs/import.cs b/mcs/mcs/import.cs index 6fe8770f6fa..35d32c1d116 100644 --- a/mcs/mcs/import.cs +++ b/mcs/mcs/import.cs @@ -420,7 +420,7 @@ namespace Mono.CSharp } } - IMemberDefinition definition; + IMethodDefinition definition; if (tparams != null) { var gmd = new ImportedGenericMethodDefinition ((MethodInfo) mb, returnType, parameters, tparams, this); foreach (var tp in gmd.TypeParameters) { @@ -429,10 +429,10 @@ namespace Mono.CSharp definition = gmd; } else { - definition = new ImportedParameterMemberDefinition (mb, returnType, parameters, this); + definition = new ImportedMethodDefinition (mb, returnType, parameters, this); } - MethodSpec ms = new MethodSpec (kind, declaringType, definition, returnType, mb, parameters, mod); + MethodSpec ms = new MethodSpec (kind, declaringType, definition, returnType, parameters, mod); if (tparams != null) ms.IsGeneric = true; @@ -1006,58 +1006,6 @@ namespace Mono.CSharp spec.BaseType = base_type; } - MetaType[] ifaces; -#if STATIC - ifaces = type.__GetDeclaredInterfaces (); - if (ifaces.Length != 0) { - foreach (var iface in ifaces) { - var it = CreateType (iface); - if (it == null) - continue; - - spec.AddInterface (it); - - // Unfortunately not all languages expand inherited interfaces - var bifaces = it.Interfaces; - if (bifaces != null) { - foreach (var biface in bifaces) { - spec.AddInterface (biface); - } - } - } - } - - // - // It's impossible to get declared interfaces only using System.Reflection - // hence we need to mimic the behavior with ikvm-reflection too to keep - // our type look-up logic same - // - if (spec.BaseType != null) { - var bifaces = spec.BaseType.Interfaces; - if (bifaces != null) { - // - // Before adding base class interfaces close defined interfaces - // on type parameter - // - var tp = spec as TypeParameterSpec; - if (tp != null && tp.InterfacesDefined == null) { - tp.InterfacesDefined = TypeSpec.EmptyTypes; - } - - foreach (var iface in bifaces) - spec.AddInterface (iface); - } - } -#else - ifaces = type.GetInterfaces (); - - if (ifaces.Length > 0) { - foreach (var iface in ifaces) { - spec.AddInterface (CreateType (iface)); - } - } -#endif - if (spec.MemberDefinition.TypeParametersCount > 0) { foreach (var tp in spec.MemberDefinition.TypeParameters) { ImportTypeParameterTypeConstraints (tp, tp.GetMetaInfo ()); @@ -1735,7 +1683,7 @@ namespace Mono.CSharp { readonly AParametersCollection parameters; - public ImportedParameterMemberDefinition (MethodBase provider, TypeSpec type, AParametersCollection parameters, MetadataImporter importer) + protected ImportedParameterMemberDefinition (MethodBase provider, TypeSpec type, AParametersCollection parameters, MetadataImporter importer) : base (provider, type, importer) { this.parameters = parameters; @@ -1758,7 +1706,21 @@ namespace Mono.CSharp #endregion } - class ImportedGenericMethodDefinition : ImportedParameterMemberDefinition, IGenericMethodDefinition + class ImportedMethodDefinition : ImportedParameterMemberDefinition, IMethodDefinition + { + public ImportedMethodDefinition (MethodBase provider, TypeSpec type, AParametersCollection parameters, MetadataImporter importer) + : base (provider, type, parameters, importer) + { + } + + MethodBase IMethodDefinition.Metadata { + get { + return (MethodBase) provider; + } + } + } + + class ImportedGenericMethodDefinition : ImportedMethodDefinition, IGenericMethodDefinition { readonly TypeParameterSpec[] tparams; @@ -1864,6 +1826,63 @@ namespace Mono.CSharp #endregion + public void DefineInterfaces (TypeSpec spec) + { + var type = (MetaType) provider; + MetaType[] ifaces; +#if STATIC + ifaces = type.__GetDeclaredInterfaces (); + if (ifaces.Length != 0) { + foreach (var iface in ifaces) { + var it = importer.CreateType (iface); + if (it == null) + continue; + + spec.AddInterfaceDefined (it); + + // Unfortunately not all languages expand inherited interfaces + var bifaces = it.Interfaces; + if (bifaces != null) { + foreach (var biface in bifaces) { + spec.AddInterfaceDefined (biface); + } + } + } + } + + // + // It's impossible to get declared interfaces only using System.Reflection + // hence we need to mimic the behavior with ikvm-reflection too to keep + // our type look-up logic same + // + if (spec.BaseType != null) { + var bifaces = spec.BaseType.Interfaces; + if (bifaces != null) { + // + // Before adding base class interfaces close defined interfaces + // on type parameter + // + var tp = spec as TypeParameterSpec; + if (tp != null && tp.InterfacesDefined == null) { + tp.InterfacesDefined = TypeSpec.EmptyTypes; + } + + foreach (var iface in bifaces) + spec.AddInterfaceDefined (iface); + } + } +#else + ifaces = type.GetInterfaces (); + + if (ifaces.Length > 0) { + foreach (var iface in ifaces) { + spec.AddInterface (importer.CreateType (iface)); + } + } +#endif + + } + public static void Error_MissingDependency (IMemberContext ctx, List types, Location loc) { // @@ -1872,33 +1891,36 @@ namespace Mono.CSharp // or referenced from the user core in which case compilation error has to // be reported because compiler cannot continue anyway // + + var report = ctx.Module.Compiler.Report; + for (int i = 0; i < types.Count; ++i) { var t = types [i]; // - // Report missing types only once per type + // Report missing types only once // - if (i > 0 && types.IndexOf (t) < i) + if (report.Printer.MissingTypeReported (t.MemberDefinition)) continue; string name = t.GetSignatureForError (); if (t.MemberDefinition.DeclaringAssembly == ctx.Module.DeclaringAssembly) { - ctx.Module.Compiler.Report.Error (1683, loc, + report.Error (1683, loc, "Reference to type `{0}' claims it is defined in this assembly, but it is not defined in source or any added modules", name); } else if (t.MemberDefinition.DeclaringAssembly.IsMissing) { if (t.MemberDefinition.IsTypeForwarder) { - ctx.Module.Compiler.Report.Error (1070, loc, + report.Error (1070, loc, "The type `{0}' has been forwarded to an assembly that is not referenced. Consider adding a reference to assembly `{1}'", name, t.MemberDefinition.DeclaringAssembly.FullName); } else { - ctx.Module.Compiler.Report.Error (12, loc, + report.Error (12, loc, "The type `{0}' is defined in an assembly that is not referenced. Consider adding a reference to assembly `{1}'", name, t.MemberDefinition.DeclaringAssembly.FullName); } } else { - ctx.Module.Compiler.Report.Error (1684, loc, + report.Error (1684, loc, "Reference to type `{0}' claims it is defined assembly `{1}', but it could not be found", name, t.MemberDefinition.DeclaringAssembly.FullName); } diff --git a/mcs/mcs/iterators.cs b/mcs/mcs/iterators.cs index dcbf10edf72..82ded9174c5 100644 --- a/mcs/mcs/iterators.cs +++ b/mcs/mcs/iterators.cs @@ -245,7 +245,7 @@ namespace Mono.CSharp for (int i = 0; i < host.hoisted_params.Count; ++i) { HoistedParameter hp = host.hoisted_params [i]; - HoistedParameter hp_cp = host.hoisted_params_copy [i]; + HoistedParameter hp_cp = host.hoisted_params_copy [i] ?? hp; FieldExpr from = new FieldExpr (hp_cp.Field, loc); from.InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, loc); @@ -431,6 +431,13 @@ namespace Mono.CSharp get { return hoisted_params; } } + protected override Constructor DefineDefaultConstructor (bool is_static) + { + var ctor = base.DefineDefaultConstructor (is_static); + ctor.ModFlags |= Modifiers.DEBUGGER_HIDDEN; + return ctor; + } + protected override TypeSpec[] ResolveBaseTypes (out FullNamedExpression base_class) { var mtype = Iterator.OriginalIteratorType; @@ -469,17 +476,26 @@ namespace Mono.CSharp current_field = AddCompilerGeneratedField ("$current", iterator_type_expr); disposing_field = AddCompilerGeneratedField ("$disposing", new TypeExpression (Compiler.BuiltinTypes.Bool, Location)); - if (hoisted_params != null) { + if (Iterator.IsEnumerable && hoisted_params != null) { // // Iterators are independent, each GetEnumerator call has to // create same enumerator therefore we have to keep original values // around for re-initialization // - // TODO: Do it for assigned/modified parameters only - // hoisted_params_copy = new List (hoisted_params.Count); foreach (HoistedParameter hp in hoisted_params) { - hoisted_params_copy.Add (new HoistedParameter (hp, "<$>" + hp.Field.Name)); + + // + // Don't create field copy for unmodified captured parameters + // + HoistedParameter hp_copy; + if (hp.IsAssigned) { + hp_copy = new HoistedParameter (hp, "<$>" + hp.Field.Name); + } else { + hp_copy = null; + } + + hoisted_params_copy.Add (hp_copy); } } @@ -565,7 +581,8 @@ namespace Mono.CSharp protected override void EmitHoistedParameters (EmitContext ec, List hoisted) { base.EmitHoistedParameters (ec, hoisted); - base.EmitHoistedParameters (ec, hoisted_params_copy); + if (hoisted_params_copy != null) + base.EmitHoistedParameters (ec, hoisted_params_copy); } } @@ -1101,7 +1118,7 @@ namespace Mono.CSharp "The body of `{0}' cannot be an iterator block " + "because `{1}' is not an iterator interface type", method.GetSignatureForError (), - TypeManager.CSharpName (ret)); + ret.GetSignatureForError ()); return; } diff --git a/mcs/mcs/linq.cs b/mcs/mcs/linq.cs index 9c854a8fe95..a1c5ab2f914 100644 --- a/mcs/mcs/linq.cs +++ b/mcs/mcs/linq.cs @@ -130,7 +130,7 @@ namespace Mono.CSharp.Linq if (!Convert.ImplicitConversionExists (rc, a.Expr, source_type)) { rc.Report.Error (1936, loc, "An implementation of `{0}' query expression pattern for source type `{1}' could not be found", - best.Name, TypeManager.CSharpName (a.Type)); + best.Name, a.Type.GetSignatureForError ()); return true; } } diff --git a/mcs/mcs/literal.cs b/mcs/mcs/literal.cs index bdbd57a4f7d..1af2d0c9e37 100644 --- a/mcs/mcs/literal.cs +++ b/mcs/mcs/literal.cs @@ -61,7 +61,7 @@ namespace Mono.CSharp if (TypeSpec.IsValueType (t)) { ec.Report.Error(37, loc, "Cannot convert null to `{0}' because it is a value type", - TypeManager.CSharpName(t)); + t.GetSignatureForError ()); return; } diff --git a/mcs/mcs/location.cs b/mcs/mcs/location.cs index 85eb26c5a19..10afaa1cc26 100644 --- a/mcs/mcs/location.cs +++ b/mcs/mcs/location.cs @@ -412,11 +412,28 @@ if (checkpoints.Length <= CheckpointIndex) throw new Exception (String.Format (" public class MemberLocations { public readonly IList> Modifiers; - Location[] locations; + List locations; - public MemberLocations (IList> mods, Location[] locs) + public MemberLocations (IList> mods) { Modifiers = mods; + } + + public MemberLocations (IList> mods, Location loc) + : this (mods) + { + AddLocations (loc); + } + + public MemberLocations (IList> mods, Location[] locs) + : this (mods) + { + AddLocations (locs); + } + + public MemberLocations (IList> mods, List locs) + : this (mods) + { locations = locs; } @@ -430,31 +447,50 @@ if (checkpoints.Length <= CheckpointIndex) throw new Exception (String.Format (" public int Count { get { - return locations.Length; + return locations.Count; } } #endregion + public void AddLocations (Location loc) + { + if (locations == null) { + locations = new List (); + } + + locations.Add (loc); + } + public void AddLocations (params Location[] additional) { if (locations == null) { - locations = additional; + locations = new List (additional); } else { - int pos = locations.Length; - Array.Resize (ref locations, pos + additional.Length); - additional.CopyTo (locations, pos); + locations.AddRange (additional); } } } - Dictionary simple_locs = new Dictionary (ReferenceEquality.Default); + Dictionary> simple_locs = new Dictionary> (ReferenceEquality.Default); Dictionary member_locs = new Dictionary (ReferenceEquality.Default); [Conditional ("FULL_AST")] public void AddLocation (object element, params Location[] locations) { - simple_locs.Add (element, locations); + simple_locs.Add (element, new List (locations)); + } + + [Conditional ("FULL_AST")] + public void InsertLocation (object element, int index, Location location) + { + List found; + if (!simple_locs.TryGetValue (element, out found)) { + found = new List (); + simple_locs.Add (element, found); + } + + found.Insert (index, location); } [Conditional ("FULL_AST")] @@ -463,7 +499,19 @@ if (checkpoints.Length <= CheckpointIndex) throw new Exception (String.Format (" if (locations.Length == 0) throw new ArgumentException ("Statement is missing semicolon location"); - simple_locs.Add (element, locations); + AddLocation (element, locations); + } + + [Conditional ("FULL_AST")] + public void AddMember (MemberCore member, IList> modLocations) + { + member_locs.Add (member, new MemberLocations (modLocations)); + } + + [Conditional ("FULL_AST")] + public void AddMember (MemberCore member, IList> modLocations, Location location) + { + member_locs.Add (member, new MemberLocations (modLocations, location)); } [Conditional ("FULL_AST")] @@ -473,13 +521,21 @@ if (checkpoints.Length <= CheckpointIndex) throw new Exception (String.Format (" } [Conditional ("FULL_AST")] - public void AppendTo (object existing, params Location[] locations) + public void AddMember (MemberCore member, IList> modLocations, List locations) { - Location[] locs; - if (simple_locs.TryGetValue (existing, out locs)) { - simple_locs [existing] = locs.Concat (locations).ToArray (); - return; + member_locs.Add (member, new MemberLocations (modLocations, locations)); + } + + [Conditional ("FULL_AST")] + public void AppendTo (object element, Location location) + { + List found; + if (!simple_locs.TryGetValue (element, out found)) { + found = new List (); + simple_locs.Add (element, found); } + + found.Add (location); } [Conditional ("FULL_AST")] @@ -492,9 +548,9 @@ if (checkpoints.Length <= CheckpointIndex) throw new Exception (String.Format (" } } - public Location[] GetLocations (object element) + public List GetLocations (object element) { - Location[] found; + List found; simple_locs.TryGetValue (element, out found); return found; } diff --git a/mcs/mcs/membercache.cs b/mcs/mcs/membercache.cs index cad910e01bc..de1ef82c7fd 100644 --- a/mcs/mcs/membercache.cs +++ b/mcs/mcs/membercache.cs @@ -1445,9 +1445,12 @@ namespace Mono.CSharp { "A partial method declaration and partial method implementation must be both `static' or neither"); } - Report.SymbolRelatedToPreviousError (ce); - Report.Error (764, member.Location, - "A partial method declaration and partial method implementation must be both `unsafe' or neither"); + if ((method_a.ModFlags & Modifiers.UNSAFE) != (method_b.ModFlags & Modifiers.UNSAFE)) { + Report.SymbolRelatedToPreviousError (ce); + Report.Error (764, member.Location, + "A partial method declaration and partial method implementation must be both `unsafe' or neither"); + } + return false; } diff --git a/mcs/mcs/method.cs b/mcs/mcs/method.cs index b571c0c5c4c..22f73d5cef7 100644 --- a/mcs/mcs/method.cs +++ b/mcs/mcs/method.cs @@ -188,7 +188,7 @@ namespace Mono.CSharp { } } - public interface IGenericMethodDefinition : IMemberDefinition + public interface IGenericMethodDefinition : IMethodDefinition { TypeParameterSpec[] TypeParameters { get; } int TypeParametersCount { get; } @@ -198,18 +198,17 @@ namespace Mono.CSharp { public sealed class MethodSpec : MemberSpec, IParametersMember { - MethodBase metaInfo, inflatedMetaInfo; + MethodBase inflatedMetaInfo; AParametersCollection parameters; TypeSpec returnType; TypeSpec[] targs; TypeParameterSpec[] constraints; - public MethodSpec (MemberKind kind, TypeSpec declaringType, IMemberDefinition details, TypeSpec returnType, - MethodBase info, AParametersCollection parameters, Modifiers modifiers) + public MethodSpec (MemberKind kind, TypeSpec declaringType, IMethodDefinition details, TypeSpec returnType, + AParametersCollection parameters, Modifiers modifiers) : base (kind, declaringType, details, modifiers) { - this.metaInfo = info; this.parameters = parameters; this.returnType = returnType; } @@ -237,6 +236,12 @@ namespace Mono.CSharp { } } + public new IMethodDefinition MemberDefinition { + get { + return (IMethodDefinition) definition; + } + } + public IGenericMethodDefinition GenericDefinition { get { return (IGenericMethodDefinition) definition; @@ -322,21 +327,21 @@ namespace Mono.CSharp { if (DeclaringType.IsTypeBuilder) { if (IsConstructor) - inflatedMetaInfo = TypeBuilder.GetConstructor (dt_meta, (ConstructorInfo) metaInfo); + inflatedMetaInfo = TypeBuilder.GetConstructor (dt_meta, (ConstructorInfo) MemberDefinition.Metadata); else - inflatedMetaInfo = TypeBuilder.GetMethod (dt_meta, (MethodInfo) metaInfo); + inflatedMetaInfo = TypeBuilder.GetMethod (dt_meta, (MethodInfo) MemberDefinition.Metadata); } else { #if STATIC // it should not be reached throw new NotImplementedException (); #else - inflatedMetaInfo = MethodInfo.GetMethodFromHandle (metaInfo.MethodHandle, dt_meta.TypeHandle); + inflatedMetaInfo = MethodInfo.GetMethodFromHandle (MemberDefinition.Metadata.MethodHandle, dt_meta.TypeHandle); #endif } state &= ~StateFlags.PendingMetaInflate; } else { - inflatedMetaInfo = metaInfo; + inflatedMetaInfo = MemberDefinition.Metadata; } } @@ -518,19 +523,10 @@ namespace Mono.CSharp { return missing; } - - public void SetMetaInfo (MethodInfo info) - { - if (this.metaInfo != null) - throw new InternalErrorException ("MetaInfo reset"); - - this.metaInfo = info; - } } - public abstract class MethodOrOperator : MethodCore, IMethodData + public abstract class MethodOrOperator : MethodCore, IMethodData, IMethodDefinition { - public MethodBuilder MethodBuilder; ReturnParameter return_attributes; SecurityType declarative_security; protected MethodData MethodData; @@ -583,6 +579,19 @@ namespace Mono.CSharp { } } + MethodBase IMethodDefinition.Metadata { + get { + return MethodData.MethodBuilder; + } + } + + // TODO: Remove and use MethodData abstraction + public MethodBuilder MethodBuilder { + get { + return MethodData.MethodBuilder; + } + } + protected override bool CheckForDuplications () { return Parent.MemberCache.CheckExistingMembersOverloads (this, parameters); @@ -609,41 +618,34 @@ namespace Mono.CSharp { else kind = MemberKind.Method; + string explicit_name; + if (IsPartialDefinition) { caching_flags &= ~Flags.Excluded_Undetected; caching_flags |= Flags.Excluded; // Add to member cache only when a partial method implementation has not been found yet - if ((caching_flags & Flags.PartialDefinitionExists) == 0) { -// MethodBase mb = new PartialMethodDefinitionInfo (this); + if ((caching_flags & Flags.PartialDefinitionExists) != 0) + return true; - spec = new MethodSpec (kind, Parent.Definition, this, ReturnType, null, parameters, ModFlags); - if (MemberName.Arity > 0) { - spec.IsGeneric = true; + if (IsExplicitImpl) + return true; - // TODO: Have to move DefineMethod after Define (ideally to Emit) - throw new NotImplementedException ("Generic partial methods"); - } + explicit_name = null; + } else { + MethodData = new MethodData (this, ModFlags, flags, this, base_method); - Parent.MemberCache.AddMember (spec); - } + if (!MethodData.Define (Parent.PartialContainer, GetFullName (MemberName))) + return false; - return true; + explicit_name = MethodData.MetadataName; } - MethodData = new MethodData ( - this, ModFlags, flags, this, MethodBuilder, base_method); - - if (!MethodData.Define (Parent.PartialContainer, GetFullName (MemberName))) - return false; - - MethodBuilder = MethodData.MethodBuilder; - - spec = new MethodSpec (kind, Parent.Definition, this, ReturnType, MethodBuilder, parameters, ModFlags); + spec = new MethodSpec (kind, Parent.Definition, this, ReturnType, parameters, ModFlags); if (MemberName.Arity > 0) spec.IsGeneric = true; - - Parent.MemberCache.AddMember (this, MethodBuilder.Name, spec); + + Parent.MemberCache.AddMember (this, explicit_name, spec); return true; } @@ -798,6 +800,33 @@ namespace Mono.CSharp { #endregion + public virtual void PrepareEmit () + { + var mb = MethodData.DefineMethodBuilder (Parent); + + if (CurrentTypeParameters != null) { + string[] gnames = new string[CurrentTypeParameters.Count]; + for (int i = 0; i < gnames.Length; ++i) { + gnames[i] = CurrentTypeParameters[i].Name; + } + + var gen_params = MethodBuilder.DefineGenericParameters (gnames); + + for (int i = 0; i < CurrentTypeParameters.Count; ++i) { + var tp = CurrentTypeParameters[i]; + + tp.Define (gen_params[i]); + } + } + + // + // Generic method has been already defined to resolve method parameters + // correctly when they use type parameters + // + mb.SetParameters (parameters.GetMetaInfo ()); + mb.SetReturnType (ReturnType.GetMetaInfo ()); + } + public override void WriteDebugSymbol (MonoSymbolFile file) { if (MethodData != null) @@ -844,7 +873,7 @@ namespace Mono.CSharp { } } -#endregion + #endregion public override void Accept (StructuralVisitor visitor) { @@ -972,10 +1001,9 @@ namespace Mono.CSharp { void CreateTypeParameters () { var tparams = MemberName.TypeParameters; - string[] snames = new string[MemberName.Arity]; var parent_tparams = Parent.TypeParametersAll; - for (int i = 0; i < snames.Length; i++) { + for (int i = 0; i < MemberName.Arity; i++) { string type_argument_name = tparams[i].MemberName.Name; if (block == null) { @@ -1000,12 +1028,9 @@ namespace Mono.CSharp { tparams[i].WarningParentNameConflict (tp); } } - - snames[i] = type_argument_name; } - GenericTypeParameterBuilder[] gen_params = MethodBuilder.DefineGenericParameters (snames); - tparams.Define (gen_params, null, 0, Parent); + tparams.Create (null, 0, Parent); } protected virtual void DefineTypeParameters () @@ -1171,9 +1196,6 @@ namespace Mono.CSharp { "Introducing `Finalize' method can interfere with destructor invocation. Did you intend to declare a destructor?"); } - if (partialMethodImplementation != null && IsPartialDefinition) - MethodBuilder = partialMethodImplementation.MethodBuilder; - if (Compiler.Settings.StdLib && ReturnType.IsSpecialRuntimeType) { Error1599 (Location, ReturnType, Report); return false; @@ -1208,7 +1230,7 @@ namespace Mono.CSharp { Report.Error (1983, Location, "The return type of an async method must be void, Task, or Task"); } - block = (ToplevelBlock) block.ConvertToAsyncTask (this, Parent.PartialContainer, parameters, ReturnType, Location); + block = (ToplevelBlock) block.ConvertToAsyncTask (this, Parent.PartialContainer, parameters, ReturnType, null, Location); ModFlags |= Modifiers.DEBUGGER_HIDDEN; } @@ -1272,6 +1294,22 @@ namespace Mono.CSharp { return true; } + public override void PrepareEmit () + { + if (IsPartialDefinition) { + // + // Use partial method implementation builder for partial method declaration attributes + // + if (partialMethodImplementation != null) { + MethodData = partialMethodImplementation.MethodData; + } + + return; + } + + base.PrepareEmit (); + } + // // Emits the code // @@ -1279,11 +1317,8 @@ namespace Mono.CSharp { { try { if (IsPartialDefinition) { - // - // Use partial method implementation builder for partial method declaration attributes - // - if (partialMethodImplementation != null) { - MethodBuilder = partialMethodImplementation.MethodBuilder; + if (partialMethodImplementation != null && CurrentTypeParameters != null) { + CurrentTypeParameters.CheckPartialConstraints (partialMethodImplementation); } return; @@ -1297,11 +1332,15 @@ namespace Mono.CSharp { if (CurrentTypeParameters != null) { for (int i = 0; i < CurrentTypeParameters.Count; ++i) { var tp = CurrentTypeParameters [i]; + tp.CheckGenericConstraints (false); tp.Emit (); } } + if (IsExplicitImpl) + MethodData.DefineOverride (Parent); + if (block != null && block.StateMachine is AsyncTaskStorey) { var psm = Module.PredefinedAttributes.AsyncStateMachine; @@ -1312,10 +1351,8 @@ namespace Mono.CSharp { Module.PredefinedAttributes.Extension.EmitAttribute (MethodBuilder); base.Emit (); - } catch { - Console.WriteLine ("Internal compiler error at {0}: exception caught while emitting {1}", - Location, MethodBuilder); - throw; + } catch (Exception e) { + throw new InternalErrorException (this, e); } } @@ -1329,13 +1366,12 @@ namespace Mono.CSharp { public static void Error1599 (Location loc, TypeSpec t, Report Report) { - Report.Error (1599, loc, "Method or delegate cannot return type `{0}'", TypeManager.CSharpName (t)); + Report.Error (1599, loc, "Method or delegate cannot return type `{0}'", t.GetSignatureForError ()); } protected override bool ResolveMemberType () { if (CurrentTypeParameters != null) { - MethodBuilder = Parent.TypeBuilder.DefineMethod (GetFullName (MemberName), flags); CreateTypeParameters (); } @@ -1485,7 +1521,7 @@ namespace Mono.CSharp { } } - public class Constructor : MethodCore, IMethodData + public class Constructor : MethodCore, IMethodData, IMethodDefinition { public ConstructorBuilder ConstructorBuilder; public ConstructorInitializer Initializer; @@ -1533,6 +1569,13 @@ namespace Mono.CSharp { } } + + MethodBase IMethodDefinition.Metadata { + get { + return ConstructorBuilder; + } + } + // // Returns true if this is a default constructor // @@ -1620,7 +1663,7 @@ namespace Mono.CSharp { ca, CallingConventions, parameters.GetMetaInfo ()); - spec = new MethodSpec (MemberKind.Constructor, Parent.Definition, this, Compiler.BuiltinTypes.Void, ConstructorBuilder, parameters, ModFlags); + spec = new MethodSpec (MemberKind.Constructor, Parent.Definition, this, Compiler.BuiltinTypes.Void, parameters, ModFlags); Parent.MemberCache.AddMember (spec); @@ -1828,10 +1871,6 @@ namespace Mono.CSharp { // public class MethodData { -#if !STATIC - static FieldInfo methodbuilder_attrs_field; -#endif - public readonly IMethodData method; // @@ -1848,6 +1887,7 @@ namespace Mono.CSharp { protected TypeSpec declaring_type; protected MethodSpec parent_method; SourceMethodBuilder debug_builder; + string full_name; MethodBuilder builder; public MethodBuilder MethodBuilder { @@ -1862,6 +1902,12 @@ namespace Mono.CSharp { } } + public string MetadataName { + get { + return full_name; + } + } + public MethodData (InterfaceMemberBase member, Modifiers modifiers, MethodAttributes flags, IMethodData method) { @@ -1874,11 +1920,10 @@ namespace Mono.CSharp { public MethodData (InterfaceMemberBase member, Modifiers modifiers, MethodAttributes flags, - IMethodData method, MethodBuilder builder, + IMethodData method, MethodSpec parent_method) : this (member, modifiers, flags, method) { - this.builder = builder; this.parent_method = parent_method; } @@ -1896,13 +1941,13 @@ namespace Mono.CSharp { if (member is PropertyBase) { container.Compiler.Report.Error (550, method.Location, "`{0}' is an accessor not found in interface member `{1}{2}'", - method.GetSignatureForError (), TypeManager.CSharpName (member.InterfaceType), + method.GetSignatureForError (), member.InterfaceType.GetSignatureForError (), member.GetSignatureForError ().Substring (member.GetSignatureForError ().LastIndexOf ('.'))); } else { container.Compiler.Report.Error (539, method.Location, "`{0}.{1}' in explicit interface declaration is not a member of interface", - TypeManager.CSharpName (member.InterfaceType), member.ShortName); + member.InterfaceType.GetSignatureForError (), member.ShortName); } return false; } @@ -1910,7 +1955,7 @@ namespace Mono.CSharp { container.Compiler.Report.SymbolRelatedToPreviousError (implementing); container.Compiler.Report.Error (683, method.Location, "`{0}' explicit method implementation cannot implement `{1}' because it is an accessor", - member.GetSignatureForError (), TypeManager.CSharpSignature (implementing)); + member.GetSignatureForError (), implementing.GetSignatureForError ()); return false; } } else { @@ -2033,58 +2078,45 @@ namespace Mono.CSharp { method_full_name = implementing.MemberDefinition.Name; } - DefineMethodBuilder (container, method_full_name, method.ParameterInfo); + full_name = method_full_name; + declaring_type = container.Definition; - if (builder == null) - return false; + return true; + } -// if (container.CurrentType != null) -// declaring_type = container.CurrentType; -// else - declaring_type = container.Definition; + public void DefineOverride (TypeDefinition container) + { + if (implementing == null) + return; - if (implementing != null && member.IsExplicitImpl) { - container.TypeBuilder.DefineMethodOverride (builder, (MethodInfo) implementing.GetMetaInfo ()); - } + if (!member.IsExplicitImpl) + return; - return true; + container.TypeBuilder.DefineMethodOverride (builder, (MethodInfo) implementing.GetMetaInfo ()); } - - /// - /// Create the MethodBuilder for the method - /// - void DefineMethodBuilder (TypeDefinition container, string method_name, ParametersCompiled param) + // + // Creates partial MethodBuilder for the method when has generic parameters used + // as arguments or return type + // + public MethodBuilder DefineMethodBuilder (TypeDefinition container) { - var return_type = method.ReturnType.GetMetaInfo (); - var p_types = param.GetMetaInfo (); + if (builder != null) + throw new InternalErrorException (); - if (builder == null) { - builder = container.TypeBuilder.DefineMethod ( - method_name, flags, method.CallingConventions, - return_type, p_types); - return; - } + builder = container.TypeBuilder.DefineMethod (full_name, flags, method.CallingConventions); + return builder; + } - // - // Generic method has been already defined to resolve method parameters - // correctly when they use type parameters - // - builder.SetParameters (p_types); - builder.SetReturnType (return_type); - if (builder.Attributes != flags) { -#if STATIC - builder.__SetAttributes (flags); -#else - try { - if (methodbuilder_attrs_field == null) - methodbuilder_attrs_field = typeof (MethodBuilder).GetField ("attrs", BindingFlags.NonPublic | BindingFlags.Instance); - methodbuilder_attrs_field.SetValue (builder, flags); - } catch { - container.Compiler.Report.RuntimeMissingSupport (method.Location, "Generic method MethodAttributes"); - } -#endif - } + // + // Creates full MethodBuilder for the method + // + public MethodBuilder DefineMethodBuilder (TypeDefinition container, ParametersCompiled param) + { + DefineMethodBuilder (container); + builder.SetReturnType (method.ReturnType.GetMetaInfo ()); + builder.SetParameters (param.GetMetaInfo ()); + return builder; } // @@ -2092,6 +2124,8 @@ namespace Mono.CSharp { // public void Emit (TypeDefinition parent) { + DefineOverride (parent); + var mc = (IMemberContext) method; method.ParameterInfo.ApplyAttributes (mc, MethodBuilder); @@ -2226,7 +2260,7 @@ namespace Mono.CSharp { // Ooouh Martin, templates are missing here. // When it will be possible move here a lot of child code and template method type. - public abstract class AbstractPropertyEventMethod : MemberCore, IMethodData { + public abstract class AbstractPropertyEventMethod : MemberCore, IMethodData, IMethodDefinition { protected MethodData method_data; protected ToplevelBlock block; protected SecurityType declarative_security; @@ -2292,6 +2326,12 @@ namespace Mono.CSharp { } } + MethodBase IMethodDefinition.Metadata { + get { + return method_data.MethodBuilder; + } + } + public abstract ParametersCompiled ParameterInfo { get ; } public abstract TypeSpec ReturnType { get; } @@ -2302,7 +2342,7 @@ namespace Mono.CSharp { if (a.Type == pa.CLSCompliant || a.Type == pa.Obsolete || a.Type == pa.Conditional) { Report.Error (1667, a.Location, "Attribute `{0}' is not valid on property or event accessors. It is valid on `{1}' declarations only", - TypeManager.CSharpName (a.Type), a.GetValidTargets ()); + a.Type.GetSignatureForError (), a.GetValidTargets ()); return; } diff --git a/mcs/mcs/namespace.cs b/mcs/mcs/namespace.cs index de355945a06..c1cef039164 100644 --- a/mcs/mcs/namespace.cs +++ b/mcs/mcs/namespace.cs @@ -252,7 +252,7 @@ namespace Mono.CSharp { case "System.Windows.Forms": case "System.Windows.Forms.Layout": - assembly = "System.Windows.Name"; + assembly = "System.Windows.Forms"; break; } diff --git a/mcs/mcs/nullable.cs b/mcs/mcs/nullable.cs index 788bbfbeb8e..badf5e1a730 100644 --- a/mcs/mcs/nullable.cs +++ b/mcs/mcs/nullable.cs @@ -320,7 +320,7 @@ namespace Mono.CSharp.Nullable public static Constant CreateFromExpression (ResolveContext ec, Expression e) { ec.Report.Warning (458, 2, e.Location, "The result of the expression is always `null' of type `{0}'", - TypeManager.CSharpName (e.Type)); + e.Type.GetSignatureForError ()); return ReducedExpression.Create (Create (e.Type, e.Location), e); } @@ -592,10 +592,10 @@ namespace Mono.CSharp.Nullable if ((Oper & Operator.EqualityMask) != 0) { ec.Report.Warning (472, 2, loc, "The result of comparing value type `{0}' with null is always `{1}'", - TypeManager.CSharpName (expr.Type), c.GetValueAsLiteral ()); + expr.Type.GetSignatureForError (), c.GetValueAsLiteral ()); } else { ec.Report.Warning (464, 2, loc, "The result of comparing type `{0}' with null is always `{1}'", - TypeManager.CSharpName (expr.Type), c.GetValueAsLiteral ()); + expr.Type.GetSignatureForError (), c.GetValueAsLiteral ()); } return ReducedExpression.Create (c, this); diff --git a/mcs/mcs/parameter.cs b/mcs/mcs/parameter.cs index 75a7bb73db0..69ae1cf839f 100644 --- a/mcs/mcs/parameter.cs +++ b/mcs/mcs/parameter.cs @@ -338,7 +338,7 @@ namespace Mono.CSharp { if (HasOptionalExpression) { a.Report.Error (1745, a.Location, "Cannot specify `{0}' attribute on optional parameter `{1}'", - TypeManager.CSharpName (a.Type).Replace ("Attribute", ""), Name); + a.Type.GetSignatureForError ().Replace ("Attribute", ""), Name); } if (a.Type == pa.DefaultParameterValue) @@ -406,7 +406,7 @@ namespace Mono.CSharp { if ((modFlags & Modifier.This) != 0 && (parameter_type.IsPointer || parameter_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic)) { rc.Module.Compiler.Report.Error (1103, Location, "The extension method cannot be of type `{0}'", - TypeManager.CSharpName (parameter_type)); + parameter_type.GetSignatureForError ()); } return parameter_type; @@ -582,7 +582,7 @@ namespace Mono.CSharp { { string type_name; if (parameter_type != null) - type_name = TypeManager.CSharpName (parameter_type); + type_name = parameter_type.GetSignatureForError (); else type_name = texpr.GetSignatureForError (); @@ -989,11 +989,11 @@ namespace Mono.CSharp { if (types == null || types [pos] == null) return ((Parameter)FixedParameters [pos]).GetSignatureForError (); - string type = TypeManager.CSharpName (types [pos]); + string type = types [pos].GetSignatureForError (); if (FixedParameters [pos].HasExtensionMethodModifier) return "this " + type; - Parameter.Modifier mod = FixedParameters [pos].ModFlags; + var mod = FixedParameters[pos].ModFlags & Parameter.Modifier.ModifierMask; if (mod == 0) return type; diff --git a/mcs/mcs/property.cs b/mcs/mcs/property.cs index 325b8f118f4..327c58c6083 100644 --- a/mcs/mcs/property.cs +++ b/mcs/mcs/property.cs @@ -201,14 +201,14 @@ namespace Mono.CSharp { base.Define (parent); - Spec = new MethodSpec (MemberKind.Method, parent.PartialContainer.Definition, this, ReturnType, null, ParameterInfo, ModFlags); + Spec = new MethodSpec (MemberKind.Method, parent.PartialContainer.Definition, this, ReturnType, ParameterInfo, ModFlags); method_data = new MethodData (method, ModFlags, flags, this); if (!method_data.Define (parent.PartialContainer, method.GetFullName (MemberName))) return null; - Spec.SetMetaInfo (method_data.MethodBuilder); + method_data.DefineMethodBuilder (parent.PartialContainer, ParameterInfo); return method_data.MethodBuilder; } @@ -268,14 +268,14 @@ namespace Mono.CSharp base.Define (parent); - Spec = new MethodSpec (MemberKind.Method, parent.PartialContainer.Definition, this, ReturnType, null, ParameterInfo, ModFlags); + Spec = new MethodSpec (MemberKind.Method, parent.PartialContainer.Definition, this, ReturnType, ParameterInfo, ModFlags); method_data = new MethodData (method, ModFlags, flags, this); if (!method_data.Define (parent.PartialContainer, method.GetFullName (MemberName))) return null; - Spec.SetMetaInfo (method_data.MethodBuilder); + method_data.DefineMethodBuilder (parent.PartialContainer, ParameterInfo); return method_data.MethodBuilder; } @@ -1198,15 +1198,15 @@ namespace Mono.CSharp if (!method_data.Define (parent.PartialContainer, method.GetFullName (MemberName))) return null; + method_data.DefineMethodBuilder (parent.PartialContainer, ParameterInfo); + if (Compiler.Settings.WriteMetadataOnly) block = null; - MethodBuilder mb = method_data.MethodBuilder; - - Spec = new MethodSpec (MemberKind.Method, parent.PartialContainer.Definition, this, ReturnType, mb, ParameterInfo, method.ModFlags); + Spec = new MethodSpec (MemberKind.Method, parent.PartialContainer.Definition, this, ReturnType, ParameterInfo, method.ModFlags); Spec.IsAccessor = true; - return mb; + return method_data.MethodBuilder; } public override TypeSpec ReturnType { diff --git a/mcs/mcs/report.cs b/mcs/mcs/report.cs index bfb82fb9f30..f49a2980d7a 100644 --- a/mcs/mcs/report.cs +++ b/mcs/mcs/report.cs @@ -550,6 +550,8 @@ namespace Mono.CSharp { // public abstract class ReportPrinter { + protected HashSet reported_missing_definitions; + #region Properties public int ErrorsCount { get; protected set; } @@ -605,6 +607,22 @@ namespace Mono.CSharp { } } + // + // Tracks reported missing types. It needs to be session specific + // because we can run in probing mode + // + public bool MissingTypeReported (ITypeDefinition typeDefinition) + { + if (reported_missing_definitions == null) + reported_missing_definitions = new HashSet (); + + if (reported_missing_definitions.Contains (typeDefinition)) + return true; + + reported_missing_definitions.Add (typeDefinition); + return false; + } + public void Reset () { // HACK: Temporary hack for broken repl flow @@ -735,6 +753,11 @@ namespace Mono.CSharp { error_msg |= !msg.IsWarning; } + if (reported_missing_definitions != null) { + foreach (var missing in reported_missing_definitions) + dest.MissingTypeReported (missing); + } + return error_msg; } } diff --git a/mcs/mcs/statement.cs b/mcs/mcs/statement.cs index eec04bb687b..0d27014d5a1 100644 --- a/mcs/mcs/statement.cs +++ b/mcs/mcs/statement.cs @@ -706,6 +706,7 @@ namespace Mono.CSharp { public StatementErrorExpression (Expression expr) { this.expr = expr; + this.loc = expr.StartLocation; } public Expression Expr { @@ -714,6 +715,12 @@ namespace Mono.CSharp { } } + public override bool Resolve (BlockContext bc) + { + expr.Error_InvalidExpressionStatement (bc); + return true; + } + protected override void DoEmit (EmitContext ec) { throw new NotSupportedException (); @@ -903,9 +910,18 @@ namespace Mono.CSharp { if (this is ContextualReturn) return true; - ec.Report.Error (1997, loc, - "`{0}': A return keyword must not be followed by an expression when async method returns `Task'. Consider using `Task' return type", - ec.GetSignatureForError ()); + // Same error code as .NET but better error message + if (async_block.DelegateType != null) { + ec.Report.Error (1997, loc, + "`{0}': A return keyword must not be followed by an expression when async delegate returns `Task'. Consider using `Task' return type", + async_block.DelegateType.GetSignatureForError ()); + } else { + ec.Report.Error (1997, loc, + "`{0}': A return keyword must not be followed by an expression when async method returns `Task'. Consider using `Task' return type", + ec.GetSignatureForError ()); + + } + return false; } @@ -1252,7 +1268,7 @@ namespace Mono.CSharp { if (!Convert.ImplicitStandardConversionExists (c, type)) ec.Report.Warning (469, 2, loc, "The `goto case' value is not implicitly convertible to type `{0}'", - TypeManager.CSharpName (type)); + type.GetSignatureForError ()); } @@ -1607,7 +1623,7 @@ namespace Mono.CSharp { bool eval_global = bc.Module.Compiler.Settings.StatementMode && bc.CurrentBlock is ToplevelBlock; if (eval_global) { CreateEvaluatorVariable (bc, li); - } else { + } else if (type != InternalType.ErrorType) { li.PrepareForFlowAnalysis (bc); } @@ -1621,7 +1637,7 @@ namespace Mono.CSharp { d.Variable.Type = li.Type; if (eval_global) { CreateEvaluatorVariable (bc, d.Variable); - } else { + } else if (type != InternalType.ErrorType) { d.Variable.PrepareForFlowAnalysis (bc); } @@ -2059,7 +2075,8 @@ namespace Mono.CSharp { HasAsyncModifier = 1 << 10, Resolved = 1 << 11, YieldBlock = 1 << 12, - AwaitBlock = 1 << 13 + AwaitBlock = 1 << 13, + Iterator = 1 << 14 } public Block Parent; @@ -2646,6 +2663,7 @@ namespace Mono.CSharp { } storey.Define (); + storey.PrepareEmit (); storey.Parent.PartialContainer.AddCompilerGeneratedClass (storey); } @@ -2664,6 +2682,8 @@ namespace Mono.CSharp { public void RegisterIteratorYield () { + ParametersBlock.TopBlock.IsIterator = true; + var block = this; while ((block.flags & Flags.YieldBlock) == 0) { block.flags |= Flags.YieldBlock; @@ -3112,7 +3132,7 @@ namespace Mono.CSharp { return tlb; } - public ParametersBlock ConvertToAsyncTask (IMemberContext context, TypeDefinition host, ParametersCompiled parameters, TypeSpec returnType, Location loc) + public ParametersBlock ConvertToAsyncTask (IMemberContext context, TypeDefinition host, ParametersCompiled parameters, TypeSpec returnType, TypeSpec delegateType, Location loc) { for (int i = 0; i < parameters.Count; i++) { Parameter p = parameters[i]; @@ -3144,6 +3164,7 @@ namespace Mono.CSharp { var block_type = host.Module.Compiler.BuiltinTypes.Void; var initializer = new AsyncInitializer (this, host, block_type); initializer.Type = block_type; + initializer.DelegateType = delegateType; var stateMachine = new AsyncTaskStorey (this, context, initializer, returnType); @@ -3207,7 +3228,10 @@ namespace Mono.CSharp { public bool IsIterator { get { - return HasYield; + return (flags & Flags.Iterator) != 0; + } + set { + flags = value ? flags | Flags.Iterator : flags & ~Flags.Iterator; } } @@ -4110,10 +4134,13 @@ namespace Mono.CSharp { new_expr = SwitchGoverningType (ec, unwrap); } - if (new_expr == null){ - ec.Report.Error (151, loc, - "A switch expression of type `{0}' cannot be converted to an integral type, bool, char, string, enum or nullable type", - TypeManager.CSharpName (Expr.Type)); + if (new_expr == null) { + if (Expr.Type != InternalType.ErrorType) { + ec.Report.Error (151, loc, + "A switch expression of type `{0}' cannot be converted to an integral type, bool, char, string, enum or nullable type", + Expr.Type.GetSignatureForError ()); + } + return false; } @@ -4512,6 +4539,7 @@ namespace Mono.CSharp { if (finally_host != null) { finally_host.Define (); + finally_host.PrepareEmit (); finally_host.Emit (); // Now it's safe to add, to close it properly and emit sequence points diff --git a/mcs/mcs/typemanager.cs b/mcs/mcs/typemanager.cs index 4a674c4c46a..cefb322eeb5 100644 --- a/mcs/mcs/typemanager.cs +++ b/mcs/mcs/typemanager.cs @@ -984,15 +984,7 @@ namespace Mono.CSharp partial class TypeManager { - /// - /// Returns the C# name of a type if possible, or the full type name otherwise - /// - static public string CSharpName (TypeSpec t) - { - return t.GetSignatureForError (); - } - - static public string CSharpName (IList types) + static public string CSharpName(IList types) { if (types.Count == 0) return string.Empty; @@ -1002,7 +994,7 @@ namespace Mono.CSharp if (i > 0) sb.Append (","); - sb.Append (CSharpName (types [i])); + sb.Append (types [i].GetSignatureForError ()); } return sb.ToString (); } @@ -1090,7 +1082,7 @@ namespace Mono.CSharp rc.Compiler.Report.SymbolRelatedToPreviousError (t); rc.Compiler.Report.Error (208, loc, "Cannot take the address of, get the size of, or declare a pointer to a managed type `{0}'", - CSharpName (t)); + t.GetSignatureForError ()); return false; } diff --git a/mcs/mcs/typespec.cs b/mcs/mcs/typespec.cs index e0d813030ca..2657956a2f5 100644 --- a/mcs/mcs/typespec.cs +++ b/mcs/mcs/typespec.cs @@ -98,6 +98,20 @@ namespace Mono.CSharp // public virtual IList Interfaces { get { + if ((state & StateFlags.InterfacesImported) == 0) { + state |= StateFlags.InterfacesImported; + + // + // Delay interfaces expansion to save memory and once all + // base types has been imported to avoid problems where + // interface references type before its base was imported + // + var imported = MemberDefinition as ImportedTypeDefinition; + if (imported != null && Kind != MemberKind.MissingType) + imported.DefineInterfaces (this); + + } + return ifaces; } set { diff --git a/mcs/tests/gtest-581-lib.cs b/mcs/tests/gtest-581-lib.cs new file mode 100644 index 00000000000..bb1d7a3f542 --- /dev/null +++ b/mcs/tests/gtest-581-lib.cs @@ -0,0 +1,21 @@ +// Compiler options: -t:library + +public interface IA +{ +} + +public interface IB +{ +} + +public abstract class A : IA, IB +{ +} + +public abstract class B : A, IA, IB, IB +{ +} + +public sealed class C : B, IA +{ +} diff --git a/mcs/tests/gtest-581.cs b/mcs/tests/gtest-581.cs new file mode 100644 index 00000000000..5021792e79f --- /dev/null +++ b/mcs/tests/gtest-581.cs @@ -0,0 +1,12 @@ +// Compiler options: -r:gtest-581-lib.dll + +class Program +{ + static void Main() + { + var f1 = (IA) new C(); + var f2 = (IA) new C(); + var f3 = (IB) new C(); + var f4 = (IB) new C(); + } +} \ No newline at end of file diff --git a/mcs/tests/gtest-582-lib.cs b/mcs/tests/gtest-582-lib.cs new file mode 100644 index 00000000000..a5c58fae1b0 --- /dev/null +++ b/mcs/tests/gtest-582-lib.cs @@ -0,0 +1,9 @@ +// Compiler options: -t:library + +public class C : I +{ +} + +interface I +{ +} diff --git a/mcs/tests/gtest-582.cs b/mcs/tests/gtest-582.cs new file mode 100644 index 00000000000..5534de49c19 --- /dev/null +++ b/mcs/tests/gtest-582.cs @@ -0,0 +1,27 @@ +// Compiler options: -r:gtest-582-lib.dll + +using System; +using System.Reflection; + +public class G1 : GC +{ +} + +public class GC where T : C +{ +} + +class Program +{ + public static int Main() + { + var constraints = typeof (GC<>).GetGenericArguments ()[0].GetGenericParameterConstraints (); + if (constraints.Length != 1) + return 1; + if (constraints [0] != typeof (C)) + return 2; + + Console.WriteLine ("ok"); + return 0; + } +} \ No newline at end of file diff --git a/mcs/tests/gtest-partial-06.cs b/mcs/tests/gtest-partial-06.cs new file mode 100644 index 00000000000..3dd2dd398c2 --- /dev/null +++ b/mcs/tests/gtest-partial-06.cs @@ -0,0 +1,23 @@ +partial class Test +{ + static partial void Foo (); + + static partial void Baz (); + + static partial void Baz () + { + } + + static partial void Bar (T t) where T : class; + + static partial void Bar (U u) where U : class + { + } + + public static void Main () + { + Foo (); + Baz (); + Bar (null); + } +} \ No newline at end of file diff --git a/mcs/tests/test-476.cs b/mcs/tests/test-476.cs index 60787efbfa9..e05993a5f03 100644 --- a/mcs/tests/test-476.cs +++ b/mcs/tests/test-476.cs @@ -1,6 +1,8 @@ #if false #line hahaha #error +#define X +#undef X #pragma warning disable 3005 // wrong directive on csc 1.x public class Foo { @@ -16,6 +18,9 @@ public class Test { public static void Main () { + string s = @"Test string + #define + "; } } diff --git a/mcs/tests/test-async-46.cs b/mcs/tests/test-async-46.cs new file mode 100644 index 00000000000..5a0aed352f3 --- /dev/null +++ b/mcs/tests/test-async-46.cs @@ -0,0 +1,16 @@ +using System; +using System.Threading.Tasks; + +partial class X +{ + partial void Foo (); + + async partial void Foo () + { + await Task.FromResult (1); + } + + public static void Main () + { + } +} \ No newline at end of file diff --git a/mcs/tests/test-debug-01-ref.xml b/mcs/tests/test-debug-01-ref.xml index 6d3f12c1846..09f0c57ba8d 100644 --- a/mcs/tests/test-debug-01-ref.xml +++ b/mcs/tests/test-debug-01-ref.xml @@ -5,15 +5,15 @@ - - + - + + diff --git a/mcs/tests/test-debug-02-ref.xml b/mcs/tests/test-debug-02-ref.xml index 98ce07ad2ff..b2fd331bf76 100644 --- a/mcs/tests/test-debug-02-ref.xml +++ b/mcs/tests/test-debug-02-ref.xml @@ -60,15 +60,15 @@ - - + - + + diff --git a/mcs/tests/test-debug-03-ref.xml b/mcs/tests/test-debug-03-ref.xml index 9cc8718343c..5c6423f005c 100644 --- a/mcs/tests/test-debug-03-ref.xml +++ b/mcs/tests/test-debug-03-ref.xml @@ -44,15 +44,15 @@ - - + - + + diff --git a/mcs/tests/test-debug-04-ref.xml b/mcs/tests/test-debug-04-ref.xml index 6216b888614..156d687a7db 100644 --- a/mcs/tests/test-debug-04-ref.xml +++ b/mcs/tests/test-debug-04-ref.xml @@ -30,15 +30,15 @@ - - + - + + diff --git a/mcs/tests/test-debug-05-ref.xml b/mcs/tests/test-debug-05-ref.xml index 0114c98f118..78b7fcc3b6b 100644 --- a/mcs/tests/test-debug-05-ref.xml +++ b/mcs/tests/test-debug-05-ref.xml @@ -6,6 +6,11 @@ + + + + + - + - + - - - - - \ No newline at end of file diff --git a/mcs/tests/test-debug-06-ref.xml b/mcs/tests/test-debug-06-ref.xml index 9714fb693d7..925cb921f89 100644 --- a/mcs/tests/test-debug-06-ref.xml +++ b/mcs/tests/test-debug-06-ref.xml @@ -5,6 +5,11 @@ + + + + + - + - + - + - + - + - - - - - \ No newline at end of file diff --git a/mcs/tests/test-debug-07-ref.xml b/mcs/tests/test-debug-07-ref.xml index faccf800550..15473e5f582 100644 --- a/mcs/tests/test-debug-07-ref.xml +++ b/mcs/tests/test-debug-07-ref.xml @@ -5,6 +5,11 @@ + + + + + - + - + - - - - - \ No newline at end of file diff --git a/mcs/tests/test-debug-08-ref.xml b/mcs/tests/test-debug-08-ref.xml index c8083e9c1fd..e7442c65a8b 100644 --- a/mcs/tests/test-debug-08-ref.xml +++ b/mcs/tests/test-debug-08-ref.xml @@ -5,25 +5,30 @@ + + + + + - + - + - + @@ -33,10 +38,5 @@ - - - - - \ No newline at end of file diff --git a/mcs/tests/test-debug-09-ref.xml b/mcs/tests/test-debug-09-ref.xml index 42d40c79d4b..5e2b972cdc0 100644 --- a/mcs/tests/test-debug-09-ref.xml +++ b/mcs/tests/test-debug-09-ref.xml @@ -15,15 +15,15 @@ - - + - + + diff --git a/mcs/tests/test-debug-10-ref.xml b/mcs/tests/test-debug-10-ref.xml index 925bc031451..4181816941a 100644 --- a/mcs/tests/test-debug-10-ref.xml +++ b/mcs/tests/test-debug-10-ref.xml @@ -5,15 +5,6 @@ - - - - - - - + - + - + - + + + + + + + \ No newline at end of file diff --git a/mcs/tests/test-debug-11-ref.xml b/mcs/tests/test-debug-11-ref.xml index 9a0d0e0d940..5d0b5d1f216 100644 --- a/mcs/tests/test-debug-11-ref.xml +++ b/mcs/tests/test-debug-11-ref.xml @@ -23,6 +23,11 @@ + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - \ No newline at end of file diff --git a/mcs/tests/test-debug-12-ref.xml b/mcs/tests/test-debug-12-ref.xml index 338ebab2372..bc71011e0e5 100644 --- a/mcs/tests/test-debug-12-ref.xml +++ b/mcs/tests/test-debug-12-ref.xml @@ -5,15 +5,15 @@ - - + - + + diff --git a/mcs/tests/test-debug-13-ref.xml b/mcs/tests/test-debug-13-ref.xml index 5125b202491..46631e8e15c 100644 --- a/mcs/tests/test-debug-13-ref.xml +++ b/mcs/tests/test-debug-13-ref.xml @@ -5,15 +5,15 @@ - - + - + + @@ -43,11 +43,6 @@ - - - - - + + + + + @@ -87,11 +87,6 @@ - - - - - + + + + + diff --git a/mcs/tests/test-debug-14-ref.xml b/mcs/tests/test-debug-14-ref.xml index e550e8ecffa..e9d76ccc380 100644 --- a/mcs/tests/test-debug-14-ref.xml +++ b/mcs/tests/test-debug-14-ref.xml @@ -5,6 +5,11 @@ + + + + + - + - + - + - + - - - - - + + + + + - + - + - + - + - + - - - - -