Imported Upstream version 6.6.0.89

Former-commit-id: b39a328747c2f3414dc52e009fb6f0aa80ca2492
This commit is contained in:
Xamarin Public Jenkins (auto-signing) 2019-09-24 08:53:40 +00:00
parent cf815e07e0
commit 95fdb59ea6
2556 changed files with 138145 additions and 47453 deletions

View File

@ -21,11 +21,12 @@ endif
if ENABLE_NETCORE
update_submodules =
SUBDIRS = mk llvm mono runtime netcore
else
update_submodules = update_submodules
SUBDIRS = $(build_with_msvc) mk po $(libgc_dir) llvm mono $(ikvm_native_dir) support data runtime scripts man samples $(tools_dir) $(build_without_msvc) $(docs_dir) acceptance-tests
endif
SUBDIRS = $(build_with_msvc) mk po $(libgc_dir) llvm mono $(ikvm_native_dir) support data runtime scripts man samples $(tools_dir) $(build_without_msvc) $(docs_dir) acceptance-tests
# Keep in sync with SUBDIRS
DIST_SUBDIRS = $(build_with_msvc) m4 mk po $(libgc_dir) llvm mono ikvm-native support data runtime scripts man samples tools $(build_without_msvc) docs acceptance-tests netcore

View File

@ -92,7 +92,11 @@ target_triplet = @target@
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/apple-target.m4 \
$(top_srcdir)/m4/ax_append_flag.m4 \
$(top_srcdir)/m4/ax_append_link_flags.m4 \
$(top_srcdir)/m4/ax_check_compile_flag.m4 \
$(top_srcdir)/m4/ax_check_link_flag.m4 \
$(top_srcdir)/m4/ax_require_defined.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
@ -106,7 +110,8 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno config.status.lineno
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES = mono-uninstalled.pc
CONFIG_CLEAN_FILES = runtime/bin/mono-hang-watchdog \
mono-uninstalled.pc
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
@ -167,9 +172,10 @@ ETAGS = etags
CTAGS = ctags
CSCOPE = cscope
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \
$(srcdir)/mono-uninstalled.pc.in COPYING.LIB NEWS compile \
config.guess config.rpath config.sub install-sh ltmain.sh \
missing mkinstalldirs
$(srcdir)/mono-uninstalled.pc.in \
$(top_srcdir)/runtime/bin/mono-hang-watchdog.in COPYING.LIB \
NEWS compile config.guess config.rpath config.sub install-sh \
ltmain.sh missing mkinstalldirs
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
@ -324,7 +330,6 @@ MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MONO_CORLIB_VERSION = @MONO_CORLIB_VERSION@
MONO_CXXLD = @MONO_CXXLD@
MONO_DL_NEED_USCORE = @MONO_DL_NEED_USCORE@
MONO_JEMALLOC_ASSERT = @MONO_JEMALLOC_ASSERT@
MONO_JEMALLOC_DEFAULT = @MONO_JEMALLOC_DEFAULT@
MONO_JEMALLOC_ENABLED = @MONO_JEMALLOC_ENABLED@
@ -358,6 +363,7 @@ NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
ODBC = @ODBC@
ORDER = @ORDER@
OS = @OS@
OTOOL = @OTOOL@
@ -402,6 +408,7 @@ XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
XINERAMA = @XINERAMA@
XMKMF = @XMKMF@
ZLIB_CFLAGS = @ZLIB_CFLAGS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
@ -495,7 +502,9 @@ MONOTOUCH_SUBDIRS = $(libgc_dir) mono
@ENABLE_MSVC_TRUE@build_without_msvc =
@ENABLE_NETCORE_FALSE@update_submodules = update_submodules
@ENABLE_NETCORE_TRUE@update_submodules =
SUBDIRS = $(build_with_msvc) mk po $(libgc_dir) llvm mono $(ikvm_native_dir) support data runtime scripts man samples $(tools_dir) $(build_without_msvc) $(docs_dir) acceptance-tests
@ENABLE_NETCORE_FALSE@SUBDIRS = $(build_with_msvc) mk po $(libgc_dir) llvm mono $(ikvm_native_dir) support data runtime scripts man samples $(tools_dir) $(build_without_msvc) $(docs_dir) acceptance-tests
@ENABLE_NETCORE_TRUE@SUBDIRS = mk llvm mono runtime netcore
# Keep in sync with SUBDIRS
DIST_SUBDIRS = $(build_with_msvc) m4 mk po $(libgc_dir) llvm mono ikvm-native support data runtime scripts man samples tools $(build_without_msvc) docs acceptance-tests netcore
EXTRA_DIST = \
@ -568,6 +577,8 @@ $(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
distclean-hdr:
-rm -f config.h stamp-h1
runtime/bin/mono-hang-watchdog: $(top_builddir)/config.status $(top_srcdir)/runtime/bin/mono-hang-watchdog.in
cd $(top_builddir) && $(SHELL) ./config.status $@
mono-uninstalled.pc: $(top_builddir)/config.status $(srcdir)/mono-uninstalled.pc.in
cd $(top_builddir) && $(SHELL) ./config.status $@

View File

@ -30,7 +30,8 @@ The Mono project is part of the [.NET Foundation](https://www.dotnetfoundation.o
| Windows | i386 | [![windows-i386][17]][18] |
| CentOS | s390x (cs) | [![centos-s390x][19]][20] |
| Debian 9 | ppc64el (cs) | [![debian-9-ppc64el][21]][22]|
| AIX | ppc64 (cs) | [![aix-ppc64][23]][24] |
| AIX 6.1 | ppc64 (cs) | [![aix-ppc64][23]][24] |
| FreeBSD 12 | amd64 (cs) | [![freebsd-amd64][25]][26] |
_(cs) = community supported architecture_
@ -58,6 +59,8 @@ _(cs) = community supported architecture_
[22]: https://jenkins.mono-project.com/job/test-mono-mainline-community-chroot/label=debian-9-ppc64el
[23]: https://jenkins.mono-project.com/job/test-mono-mainline-community/label=aix-ppc64/badge/icon
[24]: https://jenkins.mono-project.com/job/test-mono-mainline-community/label=aix-ppc64
[25]: https://jenkins.mono-project.com/job/test-mono-mainline-community/label=freebsd-12-amd64/badge/icon
[26]: https://jenkins.mono-project.com/job/test-mono-mainline-community/label=freebsd-12-amd64
Compilation and Installation
============================

View File

@ -1 +1 @@
f52b3c52f452b58b3574d18627f00353ac002e09
472b93a07fd7c07ed8c5b43beb68961486a1f729

4
aclocal.m4 vendored
View File

@ -1224,7 +1224,11 @@ AC_SUBST([am__untar])
]) # _AM_PROG_TAR
m4_include([m4/apple-target.m4])
m4_include([m4/ax_append_flag.m4])
m4_include([m4/ax_append_link_flags.m4])
m4_include([m4/ax_check_compile_flag.m4])
m4_include([m4/ax_check_link_flag.m4])
m4_include([m4/ax_require_defined.m4])
m4_include([m4/libtool.m4])
m4_include([m4/ltoptions.m4])
m4_include([m4/ltsugar.m4])

View File

@ -45,6 +45,9 @@
/* Disable desktop assembly loader semantics. */
#undef DISABLE_DESKTOP_LOADER
/* Disable GAC */
#undef DISABLE_GAC
/* Disable generics support */
#undef DISABLE_GENERICS
@ -155,6 +158,9 @@
/* Enable cooperative stop-the-world garbage collection. */
#undef ENABLE_COOP_SUSPEND
/* Enable copy_stack_data feature for hybrid/cooperative suspend scenarios */
#undef ENABLE_COPY_STACK_DATA
/* Enable DTrace probes */
#undef ENABLE_DTRACE
@ -318,30 +324,6 @@
/* Define to 1 if you have the <curses.h> header file. */
#undef HAVE_CURSES_H
/* Define to 1 if you have the declaration of `InterlockedAdd', and to 0 if
you don't. */
#undef HAVE_DECL_INTERLOCKEDADD
/* Define to 1 if you have the declaration of `InterlockedAdd64', and to 0 if
you don't. */
#undef HAVE_DECL_INTERLOCKEDADD64
/* Define to 1 if you have the declaration of `InterlockedCompareExchange64',
and to 0 if you don't. */
#undef HAVE_DECL_INTERLOCKEDCOMPAREEXCHANGE64
/* Define to 1 if you have the declaration of `InterlockedDecrement64', and to
0 if you don't. */
#undef HAVE_DECL_INTERLOCKEDDECREMENT64
/* Define to 1 if you have the declaration of `InterlockedExchange64', and to
0 if you don't. */
#undef HAVE_DECL_INTERLOCKEDEXCHANGE64
/* Define to 1 if you have the declaration of `InterlockedIncrement64', and to
0 if you don't. */
#undef HAVE_DECL_INTERLOCKEDINCREMENT64
/* Define to 1 if you have the declaration of `pthread_mutexattr_setprotocol',
and to 0 if you don't. */
#undef HAVE_DECL_PTHREAD_MUTEXATTR_SETPROTOCOL
@ -350,10 +332,6 @@
don't. */
#undef HAVE_DECL_STRERROR_R
/* Define to 1 if you have the declaration of `__readfsdword', and to 0 if you
don't. */
#undef HAVE_DECL___READFSDWORD
/* Support for the deprecated attribute */
#undef HAVE_DEPRECATED
@ -372,9 +350,6 @@
/* Define to 1 if you have the `dl_iterate_phdr' function. */
#undef HAVE_DL_ITERATE_PHDR
/* dlopen-based dynamic loader available */
#undef HAVE_DL_LOADER
/* ECHO */
#undef HAVE_ECHO
@ -783,6 +758,9 @@
/* Define to 1 if you have the <poll.h> header file. */
#undef HAVE_POLL_H
/* Define to 1 if you have the `popen' function. */
#undef HAVE_POPEN
/* posix_fadvise */
#undef HAVE_POSIX_ADVISE
@ -859,6 +837,9 @@
/* Define to 1 if you have the `pwritev' function. */
#undef HAVE_PWRITEV
/* Qp2getifaddrs */
#undef HAVE_QP2GETIFADDRS
/* readdir_r */
#undef HAVE_READDIR_R
@ -982,6 +963,9 @@
/* struct statfs.f_fstypename */
#undef HAVE_STATFS_FSTYPENAME
/* Use static zlib */
#undef HAVE_STATIC_ZLIB
/* Define to 1 if you have the `statvfs' function. */
#undef HAVE_STATVFS
@ -1252,7 +1236,7 @@
/* Define to 1 if you have the <sys/xattr.h> header file. */
#undef HAVE_SYS_XATTR_H
/* Have system zlib */
/* Use OS-provided zlib */
#undef HAVE_SYS_ZLIB
/* tcgetattr */
@ -1354,9 +1338,6 @@
/* Define to 1 if you have the `writev' function. */
#undef HAVE_WRITEV
/* Have system zlib */
#undef HAVE_ZLIB
/* ... */
#undef HOST_AMD64
@ -1467,6 +1448,9 @@
/* The runtime is compiled for cross-compiling mode */
#undef MONO_CROSS_COMPILE
/* Does dlsym require leading underscore. */
#undef MONO_DL_NEED_USCORE
/* Disable banned functions from being used by the runtime */
#undef MONO_INSIDE_RUNTIME

View File

@ -1 +1 @@
b0cee2f7362511995b7f2ab23962907043749fe4
7926a792648f1baf888528635a4c8e86e3999cc8

View File

@ -1 +1 @@
9de3050b9dda4326e31ba2f2e950969c6b57020c
6c62eb854febb497f6a00b1d119dc74f32b6152d

View File

@ -92,7 +92,11 @@ target_triplet = @target@
subdir = data
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/apple-target.m4 \
$(top_srcdir)/m4/ax_append_flag.m4 \
$(top_srcdir)/m4/ax_append_link_flags.m4 \
$(top_srcdir)/m4/ax_check_compile_flag.m4 \
$(top_srcdir)/m4/ax_check_link_flag.m4 \
$(top_srcdir)/m4/ax_require_defined.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
@ -348,7 +352,6 @@ MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MONO_CORLIB_VERSION = @MONO_CORLIB_VERSION@
MONO_CXXLD = @MONO_CXXLD@
MONO_DL_NEED_USCORE = @MONO_DL_NEED_USCORE@
MONO_JEMALLOC_ASSERT = @MONO_JEMALLOC_ASSERT@
MONO_JEMALLOC_DEFAULT = @MONO_JEMALLOC_DEFAULT@
MONO_JEMALLOC_ENABLED = @MONO_JEMALLOC_ENABLED@
@ -382,6 +385,7 @@ NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
ODBC = @ODBC@
ORDER = @ORDER@
OS = @OS@
OTOOL = @OTOOL@
@ -426,6 +430,7 @@ XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
XINERAMA = @XINERAMA@
XMKMF = @XMKMF@
ZLIB_CFLAGS = @ZLIB_CFLAGS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@

View File

@ -6,7 +6,7 @@
<dllmap dll="libintl" name="bind_textdomain_codeset" target="@LIBC@" os="solaris"/>
<dllmap dll="libintl" target="@INTL@" os="!windows"/>
<dllmap dll="i:libxslt.dll" target="libxslt@libsuffix@" os="!windows"/>
<dllmap dll="i:odbc32.dll" target="libodbc@libsuffix@" os="!windows"/>
<dllmap dll="i:odbc32.dll" target="@ODBC@" os="!windows"/>
<dllmap dll="i:odbc32.dll" target="libiodbc.dylib" os="osx"/>
<dllmap dll="oci" target="libclntsh@libsuffix@" os="!windows"/>
<dllmap dll="db2cli" target="libdb2_36@libsuffix@" os="!windows"/>

View File

@ -92,7 +92,11 @@ target_triplet = @target@
subdir = data/net_2_0/Browsers
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/apple-target.m4 \
$(top_srcdir)/m4/ax_append_flag.m4 \
$(top_srcdir)/m4/ax_append_link_flags.m4 \
$(top_srcdir)/m4/ax_check_compile_flag.m4 \
$(top_srcdir)/m4/ax_check_link_flag.m4 \
$(top_srcdir)/m4/ax_require_defined.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
@ -269,7 +273,6 @@ MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MONO_CORLIB_VERSION = @MONO_CORLIB_VERSION@
MONO_CXXLD = @MONO_CXXLD@
MONO_DL_NEED_USCORE = @MONO_DL_NEED_USCORE@
MONO_JEMALLOC_ASSERT = @MONO_JEMALLOC_ASSERT@
MONO_JEMALLOC_DEFAULT = @MONO_JEMALLOC_DEFAULT@
MONO_JEMALLOC_ENABLED = @MONO_JEMALLOC_ENABLED@
@ -303,6 +306,7 @@ NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
ODBC = @ODBC@
ORDER = @ORDER@
OS = @OS@
OTOOL = @OTOOL@
@ -347,6 +351,7 @@ XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
XINERAMA = @XINERAMA@
XMKMF = @XMKMF@
ZLIB_CFLAGS = @ZLIB_CFLAGS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@

View File

@ -92,7 +92,11 @@ target_triplet = @target@
subdir = data/net_2_0
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/apple-target.m4 \
$(top_srcdir)/m4/ax_append_flag.m4 \
$(top_srcdir)/m4/ax_append_link_flags.m4 \
$(top_srcdir)/m4/ax_check_compile_flag.m4 \
$(top_srcdir)/m4/ax_check_link_flag.m4 \
$(top_srcdir)/m4/ax_require_defined.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
@ -329,7 +333,6 @@ MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MONO_CORLIB_VERSION = @MONO_CORLIB_VERSION@
MONO_CXXLD = @MONO_CXXLD@
MONO_DL_NEED_USCORE = @MONO_DL_NEED_USCORE@
MONO_JEMALLOC_ASSERT = @MONO_JEMALLOC_ASSERT@
MONO_JEMALLOC_DEFAULT = @MONO_JEMALLOC_DEFAULT@
MONO_JEMALLOC_ENABLED = @MONO_JEMALLOC_ENABLED@
@ -363,6 +366,7 @@ NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
ODBC = @ODBC@
ORDER = @ORDER@
OS = @OS@
OTOOL = @OTOOL@
@ -407,6 +411,7 @@ XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
XINERAMA = @XINERAMA@
XMKMF = @XMKMF@
ZLIB_CFLAGS = @ZLIB_CFLAGS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@

View File

@ -92,7 +92,11 @@ target_triplet = @target@
subdir = data/net_4_0/Browsers
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/apple-target.m4 \
$(top_srcdir)/m4/ax_append_flag.m4 \
$(top_srcdir)/m4/ax_append_link_flags.m4 \
$(top_srcdir)/m4/ax_check_compile_flag.m4 \
$(top_srcdir)/m4/ax_check_link_flag.m4 \
$(top_srcdir)/m4/ax_require_defined.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
@ -269,7 +273,6 @@ MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MONO_CORLIB_VERSION = @MONO_CORLIB_VERSION@
MONO_CXXLD = @MONO_CXXLD@
MONO_DL_NEED_USCORE = @MONO_DL_NEED_USCORE@
MONO_JEMALLOC_ASSERT = @MONO_JEMALLOC_ASSERT@
MONO_JEMALLOC_DEFAULT = @MONO_JEMALLOC_DEFAULT@
MONO_JEMALLOC_ENABLED = @MONO_JEMALLOC_ENABLED@
@ -303,6 +306,7 @@ NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
ODBC = @ODBC@
ORDER = @ORDER@
OS = @OS@
OTOOL = @OTOOL@
@ -347,6 +351,7 @@ XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
XINERAMA = @XINERAMA@
XMKMF = @XMKMF@
ZLIB_CFLAGS = @ZLIB_CFLAGS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@

View File

@ -92,7 +92,11 @@ target_triplet = @target@
subdir = data/net_4_0
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/apple-target.m4 \
$(top_srcdir)/m4/ax_append_flag.m4 \
$(top_srcdir)/m4/ax_append_link_flags.m4 \
$(top_srcdir)/m4/ax_check_compile_flag.m4 \
$(top_srcdir)/m4/ax_check_link_flag.m4 \
$(top_srcdir)/m4/ax_require_defined.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
@ -329,7 +333,6 @@ MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MONO_CORLIB_VERSION = @MONO_CORLIB_VERSION@
MONO_CXXLD = @MONO_CXXLD@
MONO_DL_NEED_USCORE = @MONO_DL_NEED_USCORE@
MONO_JEMALLOC_ASSERT = @MONO_JEMALLOC_ASSERT@
MONO_JEMALLOC_DEFAULT = @MONO_JEMALLOC_DEFAULT@
MONO_JEMALLOC_ENABLED = @MONO_JEMALLOC_ENABLED@
@ -363,6 +366,7 @@ NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
ODBC = @ODBC@
ORDER = @ORDER@
OS = @OS@
OTOOL = @OTOOL@
@ -407,6 +411,7 @@ XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
XINERAMA = @XINERAMA@
XMKMF = @XMKMF@
ZLIB_CFLAGS = @ZLIB_CFLAGS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@

View File

@ -92,7 +92,11 @@ target_triplet = @target@
subdir = data/net_4_5/Browsers
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/apple-target.m4 \
$(top_srcdir)/m4/ax_append_flag.m4 \
$(top_srcdir)/m4/ax_append_link_flags.m4 \
$(top_srcdir)/m4/ax_check_compile_flag.m4 \
$(top_srcdir)/m4/ax_check_link_flag.m4 \
$(top_srcdir)/m4/ax_require_defined.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
@ -269,7 +273,6 @@ MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MONO_CORLIB_VERSION = @MONO_CORLIB_VERSION@
MONO_CXXLD = @MONO_CXXLD@
MONO_DL_NEED_USCORE = @MONO_DL_NEED_USCORE@
MONO_JEMALLOC_ASSERT = @MONO_JEMALLOC_ASSERT@
MONO_JEMALLOC_DEFAULT = @MONO_JEMALLOC_DEFAULT@
MONO_JEMALLOC_ENABLED = @MONO_JEMALLOC_ENABLED@
@ -303,6 +306,7 @@ NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
ODBC = @ODBC@
ORDER = @ORDER@
OS = @OS@
OTOOL = @OTOOL@
@ -347,6 +351,7 @@ XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
XINERAMA = @XINERAMA@
XMKMF = @XMKMF@
ZLIB_CFLAGS = @ZLIB_CFLAGS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@

View File

@ -92,7 +92,11 @@ target_triplet = @target@
subdir = data/net_4_5
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/apple-target.m4 \
$(top_srcdir)/m4/ax_append_flag.m4 \
$(top_srcdir)/m4/ax_append_link_flags.m4 \
$(top_srcdir)/m4/ax_check_compile_flag.m4 \
$(top_srcdir)/m4/ax_check_link_flag.m4 \
$(top_srcdir)/m4/ax_require_defined.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
@ -329,7 +333,6 @@ MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MONO_CORLIB_VERSION = @MONO_CORLIB_VERSION@
MONO_CXXLD = @MONO_CXXLD@
MONO_DL_NEED_USCORE = @MONO_DL_NEED_USCORE@
MONO_JEMALLOC_ASSERT = @MONO_JEMALLOC_ASSERT@
MONO_JEMALLOC_DEFAULT = @MONO_JEMALLOC_DEFAULT@
MONO_JEMALLOC_ENABLED = @MONO_JEMALLOC_ENABLED@
@ -363,6 +366,7 @@ NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
ODBC = @ODBC@
ORDER = @ORDER@
OS = @OS@
OTOOL = @OTOOL@
@ -407,6 +411,7 @@ XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
XINERAMA = @XINERAMA@
XMKMF = @XMKMF@
ZLIB_CFLAGS = @ZLIB_CFLAGS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@

View File

@ -92,7 +92,11 @@ target_triplet = @target@
subdir = docs
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/apple-target.m4 \
$(top_srcdir)/m4/ax_append_flag.m4 \
$(top_srcdir)/m4/ax_append_link_flags.m4 \
$(top_srcdir)/m4/ax_check_compile_flag.m4 \
$(top_srcdir)/m4/ax_check_link_flag.m4 \
$(top_srcdir)/m4/ax_require_defined.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
@ -270,7 +274,6 @@ MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MONO_CORLIB_VERSION = @MONO_CORLIB_VERSION@
MONO_CXXLD = @MONO_CXXLD@
MONO_DL_NEED_USCORE = @MONO_DL_NEED_USCORE@
MONO_JEMALLOC_ASSERT = @MONO_JEMALLOC_ASSERT@
MONO_JEMALLOC_DEFAULT = @MONO_JEMALLOC_DEFAULT@
MONO_JEMALLOC_ENABLED = @MONO_JEMALLOC_ENABLED@
@ -304,6 +307,7 @@ NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
ODBC = @ODBC@
ORDER = @ORDER@
OS = @OS@
OTOOL = @OTOOL@
@ -348,6 +352,7 @@ XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
XINERAMA = @XINERAMA@
XMKMF = @XMKMF@
ZLIB_CFLAGS = @ZLIB_CFLAGS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@

View File

@ -384,7 +384,9 @@ mono_domain_free (MonoDomain *domain, gboolean force)
<p />
This releases the resources associated with the specific domain.
This is a low-level function that is invoked by the AppDomain infrastructure
when necessary.</div>
when necessary.
<p />
In theory, this is dead code on netcore and thus does not need to be ALC-aware.</div>
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->

View File

@ -634,6 +634,7 @@ mono_config_is_server_mode (void)
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">void
mono_config_parse (const char *filename)
</div>
<p />
<div class="mapi-section">Parameters</div>

View File

@ -629,6 +629,11 @@ mono_image_loaded_by_guid (const char *guid)
</div>
<p />
<div class="mapi-section">Description</div>
<div>
<p />
Looks only in the global loaded images hash, will miss assemblies loaded
into an AssemblyLoadContext.</div>
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
@ -1051,6 +1056,11 @@ mono_image_loaded_by_guid_full (const char *guid, gboolean refonly)
</div>
<p />
<div class="mapi-section">Description</div>
<div>
<p />
Looks only in the global loaded images hash, will miss assemblies loaded
into an AssemblyLoadContext.</div>
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->

View File

@ -330,7 +330,7 @@ mono_thread_get_name_utf8 (MonoThread *thread)
<div> the name of the thread in UTF-8.
Return <code>NULL</code> if the thread has no name.
The returned memory is owned by the caller.</div>
The returned memory is owned by the caller (g_free it).</div>
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->

View File

@ -18,6 +18,27 @@ convert.exe: $(srcdir)/convert.cs AgilityPack.dll
AgilityPack.dll:
$(CSCOMPILE) -r:$(topdir)/class/lib/$(PROFILE)/mscorlib.dll -r:$(topdir)/class/lib/$(PROFILE)/System.dll -r:$(topdir)/class/lib/$(PROFILE)/System.Xml.dll -target:library -out:$@ $(srcdir)/HtmlAgilityPack/*.cs
ifdef MCS_MODE
monoapi.zip:
touch $@
monoapi.tree: monoapi.zip
touch $@
mono-tools.zip:
touch $@
mono-tools.tree: mono-tools.zip
touch $@
mono-file-formats.zip:
touch $@
mono-file-formats.tree: mono-file-formats.zip
touch $@
else
monoapi.zip: monoapi.tree
@test -f $@ || { rm -f $< && $(MAKE) $<; }
@ -36,5 +57,7 @@ mono-file-formats.zip: mono-file-formats.tree
mono-file-formats.tree: $(srcdir)/mono-file-formats.config $(srcdir)/docs.make
$(MDOC) assemble -o mono-file-formats -f man $<
endif
.doc-stamp:

View File

@ -10,3 +10,18 @@ TestResult.xml
*.user
bin
obj
.vs
*.metagen
*.pdb
*.psess
*.vspx
mdoc/Test/actual_statistics.txt
mdoc/Test/test-overwrite-attribute/SomeClass.xml
mdoc/Test/test-overwrite-attribute/SomeClass.dll
mdoc/Test/test-generic-ignored-namespace/ReadOnlySpan.dll
mdoc/Test/test-nuget-information/input_data/
/Debug/UwpTestWinRtComponentCpp
Debug
/mdoc/mdoc.Test/UwpTestWinRtComponentCpp/x64/Release
/mdoc.Test.Cplusplus/x64/Release
/x64/Release/UwpTestWinRtComponentCpp

71
external/api-doc-tools/CONTRIBUTING.md vendored Normal file
View File

@ -0,0 +1,71 @@
# How to contribute
Your feedback and contributions are greatly appreciated, and improve the quality of mdoc, monodoc, and related tools. Please read the following contribution guidelines to ensure a quick and timely review and acceptance of your patches. As an overview, the following are the contribution guidelines, and any deviations from the norm should be discussed in a github issue.
- All code must be written in **C#**
- We are currently targeting **.NET Framework 4.5** ... we will be transitioning to .NET Standard 2 in the future, and supporting other targets such as dotnet core.
- All projects and solutions created must load and compile in **Visual Studio 2017** and **Visual Studio for Mac**.
- New dependencies (such as nuget references) must be _discussed and reviewed_. _mdoc_ is distributed via the Mono project, and as such we must be careful with what dependencies we distribute.
- **NUnit** is used to write unit tests.
- Integration tests use **Make** on **Bash**.
- This project uses **Git** hosted on **GitHub** as the central repository host.
- All pull requests should pass all unit tests successfully (which means being able to run the CLI build via `make`).
## Bug Reports and Feature Requests
We love bug reports and feature requests! It is through feedback from our wonderful customers that we know how to prioritize our time. Please file issues and requests on [github issues](https://github.com/mono/api-doc-tools/issues/new).
For problems, please try to include a reproducible example … ideally in the form of an assembly (or compilable source code), and related script to reproduce the issue.
For feature requests, please include all relevant details including input, output, and ideal file formats.
## Contribution Workflow
When contributing bug fixes and enhancements, please follow this workflow and guidelines.
### Coding Standards
This project is currently in transition. Historically, it has used the [Mono coding guidelines](http://www.mono-project.com/community/contributing/coding-guidelines/); and indeed, most of the code is currently still using this.
However, starting with the `MDocUpdater` class and related entities, we are changing to a new coding standard, based on the default formatting options available in _Visual Studio_ and _Visual Studio for Mac_. This is meant to simplify contributions, so that the IDE does not work against you without changes to the default format settings.
Additionally, many areas of the code contain multiple classes in the same file. While theres nothing wrong in general with this approach, going forward we will maintain each class in a separate `.cs` file, and organize functionality into better namespaces.
If you are working in an area of the code that has transitioned to the new coding standard, please use that. If you are working with code that is still using the mono coding guidelines, and the change is small, just stick the existing format … otherwise, file a separate GitHub issue to request that the target code be reformatted. I would like to keep those formatting changes in a standalone commit (ie. no feature/functionality changes).
### Commits
This project tries to avoid chatty in-progress commits that are common during development. Once youve completed your development and are ready to move to the next stage of the contribution workflow, collapse your changes into as few feature-scoped commits as possible. Ideally if possible, every commit should pass all unit tests and be standalone.
You can do so either by using an interactive rebase of your branch if you need multiple commits, or simply doing a soft reset `git reset origin/master —soft` … which will stage all of your changes and let you create a new single commit that contains all changes.
The commit message should be verbose enough to explain what behavior is changing, bug is being fixed, or feature being added. It should also contain a reference to the github issue being resolved, as [described here](https://github.com/blog/1386-closing-issues-via-commit-messages).
### Tests
Your commit should introduce no regressions. While we do not require 100% code coverage, every newly-introduced feature should have a new unit or integration test written. You can make sure to run all unit tests locally by using the [instructions here](https://github.com/mono/api-doc-tools#cli). There are two kinds of tests:
#### Unit Tests
Written with _NUnit_, there are two unit test projects: *mdoc.Test*, and *Monodoc.Test*. _Visual Studio for Mac_ has built-in support for _NUnit_, and on Windows, you can install the [_NUnit 3 Test Adapter_](https://marketplace.visualstudio.com/items?itemName=NUnitDevelopers.NUnit3TestAdapter)
#### Integration Tests
_mdoc_ has integration tests implemented as [`make` targets](mdoc/Makefile). You can look at the existing tests to see how they are structured, but generally speaking:
- It usually involves a sample code file, such as [/mdoc/Test/DocTest-InternalInterface.cs](mdoc/Test/DocTest-InternalInterface.cs).
- A target (such as `Test/DocTest-InternalInterface.dll`) to build/comple the test assembly.
- A target to execute the scenario (such as `check-monodocer-import-fx`), which itself depends on the above target.
- Usually, this setup involves deleting the `Test/en.actual` folder (which serves as the output)
- the execution of an `mdoc` subcommand, using `$(MONO) $(PROGRAM) <the subcommand> <args>`.
- The assertion, using `$(DIFF)`, against an existing expected form of the output (which is committed to git, such as `Test/en.expected-fx-import`).
Depending on the change that you're making, it might cause the output to change (for example, if changing a formatter to reflect a new language feature); in those cases, when you make that change and run the integration tests, you will get a number of failures ... you will have to update the test xml files to reflect the new file changes.
### Pull Request
Create a fork against the [api-doc-tools](https://github.com/mono/api-doc-tools/pulls) repository. As mentioned previously, all tests should pass, and the code will be reviewed, discussed, and merged from there. *Please be ready to address any issues* brought up during code review.
## Legal
This software is licensed under [The MIT License](LICENSE.md).

21
external/api-doc-tools/LICENSE.md vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2013 Xamarin, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -8,20 +8,24 @@ all: build
build: $(MDOC)
$(MDOC):
$(MSBUILD) apidoctools.sln /p:Configuration=$(CONFIGURATION)
$(MSBUILD) apidoctools.sln /p:Configuration=$(CONFIGURATION);
prepare:
git submodule update --init --recursive
nuget restore apidoctools.sln
nuget install NUnit.Console -version 3.6.0 -NoCache -o packages
clean:
$(MSBUILD) apidoctools.sln /t:clean
#$(MSBUILD) apidoctools.sln /t:clean
rm -rf bin/$(CONFIGURATION)
check: build check-monodoc check-mdoc
check-mdoc:
cd mdoc; $(MAKE) check
cd mdoc; $(MAKE) check -B
nuget:
nuget pack mdoc/mdoc.nuspec -outputdirectory bin/Nuget
check-monodoc:
cd monodoc; $(MAKE) check
cd monodoc; $(MAKE) check -B

View File

@ -1,11 +1,28 @@
# `mdoc` and `monodoc`
# `mdoc`
This repository contains the source for Mono's [documentation toolchain](http://www.mono-project.com/docs/tools+libraries/tools/monodoc/generating-documentation/).
This repository contains the source for the .NET API Reference toolchain ([used
by docs.microsoft.com](https://docs.microsoft.com/en-us/teamblog/announcing-unified-dotnet-experience-on-docs#built-with-open-source-in-mind))
## Contribution Guide
You can read the [contribution guide](CONTRIBUTING.md) for information about coding standards, and (perhaps most importantly), information about writing [unit and integration tests](CONTRIBUTING.md#tests).
## Compiling
### Dependencies
This repository uses submodules, so firstly, you have several options:
- You can include all submodules when you initially clone: `git clone --recursive https://github.com/mono/api-doc-tools.git`
- If you already have it local, you can use `git submodule update --init --recursive`
- If you have all CLI dependencies (see below), you can `make prepare`
### Visual Studio
On windows, you can build and compile [`apidoctools.sln`](apidoctools.sln). And you can run unit tests if you have NUnit installed. If you use [Visual Studio for Mac](https://www.visualstudio.com/vs/visual-studio-mac/), you can use its built-in support for NUnit tests to also run tests.
### CLI
If you've got `make` installed, you can run `make prepare all check`. The available targets are:
If you've got `make` and `mono` installed, you can run `make prepare all check` in a _bash_ prompt to do a release build and run the full test suite (which for mdoc includes more than just the nunit tests). The available targets are:
- `prepare`: initializes the submodules, and restores the nuget dependency of NUnit
- `all`: compiles everything
@ -17,6 +34,48 @@ You can also control some parameters from the command line:
If you want to compile in debug mode: `make all CONFIGURATION=Debug`
### Visual Studio
Once you run `make prepare all` at least once (to restore submodules), you can open the solution in
_Visual Studio_ to compile and debug.
Feel free to open a pull request early in order to make it easy to ask questions during development, and for the maintainers to offer feedback.
## Troubleshooting
### Forcing Changes
When you make certain kinds of changes, it can confuse _Make_'s dependency ... if you're running the test suite and it doesn't seem to be reflecting your changes, add the `-B` parameter to the `make` invocation, and it will force a rebuild of all targets.
### WSL
Make sure you are at least on 16.04 (Xenial). You can check which version is currently installed by running the command `lsb_release -a`.
If you are running an older version (for example, if you originally installed WSL before the creator's update) and need to upgrade, you can run the following commands:
- `sudo do-release-upgrade` ... this updates the version of Ubuntu. _Please note_, this will likely disable any external package sources, such as the one added when installing Mono.
- Once you're done with that, then you just need to update `apt-get`
- Add back Mono's package repository source, as described in [the download instructions](www.mono-project.com/download/#download-lin-ubuntu).
- `sudo apt-get update`
- `sudo apt-get upgrade`
- `sudo apt-get dist-upgrade`
With that run ... you should be able to run the build locally.
### Linux
The following script will prepare, clone, and run a full build with tests of `mdoc` on an unbuntu docker container.
```
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/ubuntu trusty main" | tee /etc/apt/sources.list.d/mono-official.list
apt-get update
apt-get install tzdata nuget -y --allow-unauthenticated
apt-get install git make mono-devel mono-vbnc ca-certificates-mono wget fsharp -y
wget -q 'http://mxr.mozilla.org/seamonkey/source/security/nss/lib/ckfw/builtins/certdata.txt?raw=1' -O "/tmp/certdata.txt"
mozroots --import --ask-remove --file /tmp/certdata.txt
git clone https://github.com/mono/api-doc-tools
cd api-doc-tools
make prepare all check
```
Please review [mono's installation guide](http://www.mono-project.com/download/#download-lin) if you are using a different flavor of linux.

View File

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26206.0
VisualStudioVersion = 15.0.27130.2020
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mdoc", "mdoc\mdoc.csproj", "{7DA7CD97-614F-4BCD-A2FA-B379590CEA48}"
EndProject
@ -11,50 +11,125 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Monodoc.Test", "monodoc\Tes
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpZipLib", "external\SharpZipLib\ICSharpCode.SharpZipLib.NET45\ICSharpCode.SharpZipLib.csproj", "{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mdoc.Test", "mdoc\mdoc.Test\mdoc.Test.csproj", "{5ADDEFB6-930C-46BC-8B2B-FDE5C7E3B5AD}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "mdoc.Test.FSharp", "mdoc\mdoc.Test\mdoc.Test.FSharp\mdoc.Test.FSharp.fsproj", "{979F9F80-12FE-4236-9E93-6D554AB13701}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7DA7CD97-614F-4BCD-A2FA-B379590CEA48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7DA7CD97-614F-4BCD-A2FA-B379590CEA48}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7DA7CD97-614F-4BCD-A2FA-B379590CEA48}.Debug|ARM.ActiveCfg = Debug|Any CPU
{7DA7CD97-614F-4BCD-A2FA-B379590CEA48}.Debug|ARM.Build.0 = Debug|Any CPU
{7DA7CD97-614F-4BCD-A2FA-B379590CEA48}.Debug|x64.ActiveCfg = Debug|Any CPU
{7DA7CD97-614F-4BCD-A2FA-B379590CEA48}.Debug|x64.Build.0 = Debug|Any CPU
{7DA7CD97-614F-4BCD-A2FA-B379590CEA48}.Debug|x86.ActiveCfg = Debug|Any CPU
{7DA7CD97-614F-4BCD-A2FA-B379590CEA48}.Debug|x86.Build.0 = Debug|Any CPU
{7DA7CD97-614F-4BCD-A2FA-B379590CEA48}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7DA7CD97-614F-4BCD-A2FA-B379590CEA48}.Release|Any CPU.Build.0 = Release|Any CPU
{7DA7CD97-614F-4BCD-A2FA-B379590CEA48}.Release|ARM.ActiveCfg = Release|Any CPU
{7DA7CD97-614F-4BCD-A2FA-B379590CEA48}.Release|ARM.Build.0 = Release|Any CPU
{7DA7CD97-614F-4BCD-A2FA-B379590CEA48}.Release|x64.ActiveCfg = Release|Any CPU
{7DA7CD97-614F-4BCD-A2FA-B379590CEA48}.Release|x64.Build.0 = Release|Any CPU
{7DA7CD97-614F-4BCD-A2FA-B379590CEA48}.Release|x86.ActiveCfg = Release|Any CPU
{7DA7CD97-614F-4BCD-A2FA-B379590CEA48}.Release|x86.Build.0 = Release|Any CPU
{6E644802-B579-4037-9809-9CF4C7172C9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6E644802-B579-4037-9809-9CF4C7172C9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6E644802-B579-4037-9809-9CF4C7172C9D}.Debug|ARM.ActiveCfg = Debug|Any CPU
{6E644802-B579-4037-9809-9CF4C7172C9D}.Debug|ARM.Build.0 = Debug|Any CPU
{6E644802-B579-4037-9809-9CF4C7172C9D}.Debug|x64.ActiveCfg = Debug|Any CPU
{6E644802-B579-4037-9809-9CF4C7172C9D}.Debug|x64.Build.0 = Debug|Any CPU
{6E644802-B579-4037-9809-9CF4C7172C9D}.Debug|x86.ActiveCfg = Debug|Any CPU
{6E644802-B579-4037-9809-9CF4C7172C9D}.Debug|x86.Build.0 = Debug|Any CPU
{6E644802-B579-4037-9809-9CF4C7172C9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6E644802-B579-4037-9809-9CF4C7172C9D}.Release|Any CPU.Build.0 = Release|Any CPU
{6E644802-B579-4037-9809-9CF4C7172C9D}.Release|ARM.ActiveCfg = Release|Any CPU
{6E644802-B579-4037-9809-9CF4C7172C9D}.Release|ARM.Build.0 = Release|Any CPU
{6E644802-B579-4037-9809-9CF4C7172C9D}.Release|x64.ActiveCfg = Release|Any CPU
{6E644802-B579-4037-9809-9CF4C7172C9D}.Release|x64.Build.0 = Release|Any CPU
{6E644802-B579-4037-9809-9CF4C7172C9D}.Release|x86.ActiveCfg = Release|Any CPU
{6E644802-B579-4037-9809-9CF4C7172C9D}.Release|x86.Build.0 = Release|Any CPU
{1EE70E2C-A289-4C36-AD0A-3D0C6CE56615}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1EE70E2C-A289-4C36-AD0A-3D0C6CE56615}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1EE70E2C-A289-4C36-AD0A-3D0C6CE56615}.Debug|ARM.ActiveCfg = Debug|Any CPU
{1EE70E2C-A289-4C36-AD0A-3D0C6CE56615}.Debug|ARM.Build.0 = Debug|Any CPU
{1EE70E2C-A289-4C36-AD0A-3D0C6CE56615}.Debug|x64.ActiveCfg = Debug|Any CPU
{1EE70E2C-A289-4C36-AD0A-3D0C6CE56615}.Debug|x64.Build.0 = Debug|Any CPU
{1EE70E2C-A289-4C36-AD0A-3D0C6CE56615}.Debug|x86.ActiveCfg = Debug|Any CPU
{1EE70E2C-A289-4C36-AD0A-3D0C6CE56615}.Debug|x86.Build.0 = Debug|Any CPU
{1EE70E2C-A289-4C36-AD0A-3D0C6CE56615}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1EE70E2C-A289-4C36-AD0A-3D0C6CE56615}.Release|Any CPU.Build.0 = Release|Any CPU
{1EE70E2C-A289-4C36-AD0A-3D0C6CE56615}.Release|ARM.ActiveCfg = Release|Any CPU
{1EE70E2C-A289-4C36-AD0A-3D0C6CE56615}.Release|ARM.Build.0 = Release|Any CPU
{1EE70E2C-A289-4C36-AD0A-3D0C6CE56615}.Release|x64.ActiveCfg = Release|Any CPU
{1EE70E2C-A289-4C36-AD0A-3D0C6CE56615}.Release|x64.Build.0 = Release|Any CPU
{1EE70E2C-A289-4C36-AD0A-3D0C6CE56615}.Release|x86.ActiveCfg = Release|Any CPU
{1EE70E2C-A289-4C36-AD0A-3D0C6CE56615}.Release|x86.Build.0 = Release|Any CPU
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Debug|ARM.ActiveCfg = Debug|Any CPU
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Debug|ARM.Build.0 = Debug|Any CPU
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Debug|x64.ActiveCfg = Debug|Any CPU
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Debug|x64.Build.0 = Debug|Any CPU
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Debug|x86.ActiveCfg = Debug|Any CPU
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Debug|x86.Build.0 = Debug|Any CPU
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Release|Any CPU.Build.0 = Release|Any CPU
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Release|ARM.ActiveCfg = Release|Any CPU
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Release|ARM.Build.0 = Release|Any CPU
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Release|x64.ActiveCfg = Release|Any CPU
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Release|x64.Build.0 = Release|Any CPU
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Release|x86.ActiveCfg = Release|Any CPU
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Release|x86.Build.0 = Release|Any CPU
{5ADDEFB6-930C-46BC-8B2B-FDE5C7E3B5AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5ADDEFB6-930C-46BC-8B2B-FDE5C7E3B5AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5ADDEFB6-930C-46BC-8B2B-FDE5C7E3B5AD}.Debug|ARM.ActiveCfg = Debug|Any CPU
{5ADDEFB6-930C-46BC-8B2B-FDE5C7E3B5AD}.Debug|ARM.Build.0 = Debug|Any CPU
{5ADDEFB6-930C-46BC-8B2B-FDE5C7E3B5AD}.Debug|x64.ActiveCfg = Debug|Any CPU
{5ADDEFB6-930C-46BC-8B2B-FDE5C7E3B5AD}.Debug|x64.Build.0 = Debug|Any CPU
{5ADDEFB6-930C-46BC-8B2B-FDE5C7E3B5AD}.Debug|x86.ActiveCfg = Debug|Any CPU
{5ADDEFB6-930C-46BC-8B2B-FDE5C7E3B5AD}.Debug|x86.Build.0 = Debug|Any CPU
{5ADDEFB6-930C-46BC-8B2B-FDE5C7E3B5AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5ADDEFB6-930C-46BC-8B2B-FDE5C7E3B5AD}.Release|Any CPU.Build.0 = Release|Any CPU
{5ADDEFB6-930C-46BC-8B2B-FDE5C7E3B5AD}.Release|ARM.ActiveCfg = Release|Any CPU
{5ADDEFB6-930C-46BC-8B2B-FDE5C7E3B5AD}.Release|ARM.Build.0 = Release|Any CPU
{5ADDEFB6-930C-46BC-8B2B-FDE5C7E3B5AD}.Release|x64.ActiveCfg = Release|Any CPU
{5ADDEFB6-930C-46BC-8B2B-FDE5C7E3B5AD}.Release|x64.Build.0 = Release|Any CPU
{5ADDEFB6-930C-46BC-8B2B-FDE5C7E3B5AD}.Release|x86.ActiveCfg = Release|Any CPU
{5ADDEFB6-930C-46BC-8B2B-FDE5C7E3B5AD}.Release|x86.Build.0 = Release|Any CPU
{979F9F80-12FE-4236-9E93-6D554AB13701}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{979F9F80-12FE-4236-9E93-6D554AB13701}.Debug|Any CPU.Build.0 = Debug|Any CPU
{979F9F80-12FE-4236-9E93-6D554AB13701}.Debug|ARM.ActiveCfg = Debug|Any CPU
{979F9F80-12FE-4236-9E93-6D554AB13701}.Debug|ARM.Build.0 = Debug|Any CPU
{979F9F80-12FE-4236-9E93-6D554AB13701}.Debug|x64.ActiveCfg = Debug|Any CPU
{979F9F80-12FE-4236-9E93-6D554AB13701}.Debug|x64.Build.0 = Debug|Any CPU
{979F9F80-12FE-4236-9E93-6D554AB13701}.Debug|x86.ActiveCfg = Debug|Any CPU
{979F9F80-12FE-4236-9E93-6D554AB13701}.Debug|x86.Build.0 = Debug|Any CPU
{979F9F80-12FE-4236-9E93-6D554AB13701}.Release|Any CPU.ActiveCfg = Release|Any CPU
{979F9F80-12FE-4236-9E93-6D554AB13701}.Release|Any CPU.Build.0 = Release|Any CPU
{979F9F80-12FE-4236-9E93-6D554AB13701}.Release|ARM.ActiveCfg = Release|Any CPU
{979F9F80-12FE-4236-9E93-6D554AB13701}.Release|ARM.Build.0 = Release|Any CPU
{979F9F80-12FE-4236-9E93-6D554AB13701}.Release|x64.ActiveCfg = Release|Any CPU
{979F9F80-12FE-4236-9E93-6D554AB13701}.Release|x64.Build.0 = Release|Any CPU
{979F9F80-12FE-4236-9E93-6D554AB13701}.Release|x86.ActiveCfg = Release|Any CPU
{979F9F80-12FE-4236-9E93-6D554AB13701}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6D6A6927-89D3-42DF-A416-294A841822A9}
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = mdoc.csproj
EndGlobalSection

View File

@ -0,0 +1,6 @@
cd ../..
cp external/Windows/Windows.Foundation.FoundationContract.winmd bin/$1
cp external/Windows/Windows.Foundation.UniversalApiContract.winmd bin/$1
cp external/Windows/Windows.WinMD bin/$1
sleep 5

View File

@ -0,0 +1,9 @@
cd ../../../..
cp external/Windows/Windows.Foundation.UniversalApiContract.winmd mdoc/mdoc.Test/bin/$1
cp external/Windows/Windows.WinMD mdoc/mdoc.Test/bin/$1
cp external/Windows/Windows.Foundation.FoundationContract.winmd mdoc/mdoc.Test/bin/$1
cp external/Test/UwpTestWinRtComponentCpp.dll mdoc/mdoc.Test/bin/$1
cp external/Test/UwpTestWinRtComponentCpp.winmd mdoc/mdoc.Test/bin/$1
cp external/Test/CSharpExample.dll mdoc/mdoc.Test/bin/$1
sleep 5

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,10 @@
The files in this directory are used as test inputs for explicit assembly testing.
|Assembly|Visual Studio Project Location|
|---|---|
|CSharpExample.dll|TBD|
|mdoc.Test.Cplusplus.dll|../../mdoc/mdoc.Test.Cplusplus|
|UWPTestComponentCSharp.winmd|../../mdoc/mdoc.Test/UWPTestComponentCSharp|
|UwpTestWinRtComponentCpp.dll|../../mdoc/mdoc.Test/UwpTestWinRtComponentCpp|
|UwpTestWinRtComponentCpp.winmd|../../mdoc/mdoc.Test/UwpTestWinRtComponentCpp|

View File

@ -0,0 +1 @@
ab5d413e80a93c9afdc42621ef47e4ed00f0a296

View File

@ -0,0 +1 @@
1fc67192ee09e4dd5a935fb74f7dba51a27dd49e

View File

@ -0,0 +1,38 @@
#include "stdafx.h"
using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::CompilerServices;
using namespace System::Runtime::InteropServices;
using namespace System::Security::Permissions;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly:AssemblyTitleAttribute(L"mdocTestCplusplus")];
[assembly:AssemblyDescriptionAttribute(L"")];
[assembly:AssemblyConfigurationAttribute(L"")];
[assembly:AssemblyCompanyAttribute(L"EPAM Systems")];
[assembly:AssemblyProductAttribute(L"mdocTestCplusplus")];
[assembly:AssemblyCopyrightAttribute(L"Copyright (c) EPAM Systems 2017")];
[assembly:AssemblyTrademarkAttribute(L"")];
[assembly:AssemblyCultureAttribute(L"")];
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the value or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly:AssemblyVersionAttribute("1.0.*")];
[assembly:ComVisible(false)];
[assembly:CLSCompliantAttribute(true)];

View File

@ -0,0 +1,38 @@
========================================================================
DYNAMIC LINK LIBRARY : mdoc.Test.Cplusplus Project Overview
========================================================================
AppWizard has created this mdoc.Test.Cplusplus DLL for you.
This file contains a summary of what you will find in each of the files that
make up your mdoc.Test.Cplusplus application.
mdoc.Test.Cplusplus.vcxproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.
mdoc.Test.Cplusplus.vcxproj.filters
This is the filters file for VC++ projects generated using an Application Wizard.
It contains information about the association between the files in your project
and the filters. This association is used in the IDE to show grouping of files with
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
"Source Files" filter).
mdoc.Test.Cplusplus.cpp
This is the main DLL source file.
mdoc.Test.Cplusplus.h
This file contains a class declaration.
AssemblyInfo.cpp
Contains custom attributes for modifying assembly metadata.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" to indicate parts of the source code you
should add to or customize.
/////////////////////////////////////////////////////////////////////////////

View File

@ -0,0 +1,5 @@
// stdafx.cpp : source file that includes just the standard includes
// mdoc.Test.Cplusplus.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

View File

@ -0,0 +1,7 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once

View File

@ -0,0 +1,647 @@
#include "stdafx.h"
#include "TestClass.h"
#include <string>
#include <vector>
using namespace std;
using namespace cli;
using namespace System::Collections::ObjectModel;
using namespace System;
using namespace Runtime::InteropServices;
using namespace System::Runtime::InteropServices;
namespace Generic1 = System::Collections::Generic;
using namespace System::Runtime::CompilerServices;
//using namespace System::att;
TestClass::TestClass()
{
}
TestClass::~TestClass()
{
}
/// <summary>Namespace Test: [<see cref="N:Mono.DocTest" />] <see href="http://www.mono-project.com/">Mono Project</see></summary>
/// <remarks><c>T:NoNamespace</c></remarks>
public ref class NoNamespace {};
namespace System {
/// <remarks><c>T:System.Action`1</c></remarks>
generic<typename T>
[SerializableAttribute]
public delegate void Action(T obj);
//TODO: Env1 name as not supported
/// <remarks><c>T:System.Environment</c></remarks>
public ref class Environment1 abstract sealed {
//public: Environment1() {};
public:
/// <remarks><c>T:System.Environment+SpecialFolder</c></remarks>
enum class SpecialFolder {};
/// <param name="folder">
/// A <see cref="T:System.Environment+SpecialFolder" /> instance.
/// </param>
/// <remarks>
/// <c>M:System.Environment.GetFolderPath(System.Environment+SpecialFolder)</c>
/// </remarks>
public:
static SpecialFolder GetFolderPath(SpecialFolder folder) {
//throw std::runtime_error("error");
return folder;
};
// Testing whether this extension method shows up for System.Array
public:
generic<typename T>
where T : value class
[System::Runtime::CompilerServices::Extension]
static bool IsAligned(cli::array<T>^ vect, int index)
{
return false;
};
};
// to test ECMA doc importing...
//todo: array1 instad real name
public ref class Array1 {
// the ECMA docs have a different return type than .NET -- skip.
public:
//todo: cli::array or std::array
generic<typename T>
static ReadOnlyCollection<T> ^ AsReadOnly(cli::array<T>^ array)
{
throw gcnew NotImplementedException();
}
// ECMA docs use <T,U> instead of <TInput,TOutput> --> map them.
public:
generic<typename TInput, typename TOutput>
static cli::array<TOutput>^ ConvertAll(cli::array<TInput>^ array, Converter<TInput, TOutput>^ converter)
{
throw gcnew InvalidOperationException();
};
// ECMA docs *incorrectly* document parameter -- skip
public:
generic<typename T>
static void Resize(cli::array<T> ^ % array, int newSize)
{
throw gcnew Exception();
}
};
// to test ECMA doc importing...
//public delegate void AsyncCallback(IAsyncResult^ ar);
}
//todo: no dot in namespace name
namespace Mono_DocTest {
//todo: no internal modifier
class Internal {
class ShouldNotBeDocumented {
};
};
//todo: no internal modifier
ref class MonoTODOAttribute : public System::Attribute {
};
public ref class CustomException : System::Exception {
protected: System::ArgumentNullException ArgumentNullExceptionField;
};
public delegate void DelegateWithNetSystemType(System::Exception parameter);
generic<typename T>
[SerializableAttribute]
public delegate void Action22(T obj);
/// <remarks>
/// <para>
/// cref=<c>T:Mono.DocTest.DocAttribute</c>.
/// </para>
/// <format type="text/html">
/// <table width="100%">
/// <tr>
/// <td style="color:red">red</td>
/// <td style="color:blue">blue</td>
/// <td style="color:green">green</td>
/// </tr>
/// </table>
/// </format>
/// <code lang="C#" src="../DocTest.cs#DocAttribute Example" />
/// </remarks>
[AttributeUsageAttribute(AttributeTargets::All)]
public ref class DocAttribute : Attribute {
/// <remarks><c>C:Mono.DocTest.DocAttribute(System.String)</c></remarks>
public: DocAttribute(String ^ docs)
{
if (String::IsNullOrEmpty(docs))
throw gcnew ArgumentNullException();
};
private:
Type^ quantity;
/// <remarks><c>P:Mono.DocTest.DocAttribute.Property</c></remarks>
public:
property Type^ Property {
Type^ get() { return quantity; }
void set(Type^ value)
{
quantity = value;
}};
/// <remarks><c>F:Mono.DocTest.DocAttribute.Field</c></remarks>
bool Field;
/// <remarks><c>F:Mono.DocTest.DocAttribute.FlagsEnum</c></remarks>
ConsoleModifiers FlagsEnum;
/// <remarks><c>F:Mono.DocTest.DocAttribute.NonFlagsEnum</c></remarks>
Color NonFlagsEnum;
};
/// <summary>Possible colors</summary>
/// <remarks>
/// <see cref="T:Mono.DocTest.Color"/>.
/// Namespace Test: [<see cref="N:Mono.DocTest" />]
/// </remarks>
/*[MonoTODO]
public enum Color {
/// <summary>Insert Red summary here</summary>
///<remarks><c>F:Mono.DocTest.Color.Red</c>.</remarks>
Red,
///<summary>Insert Blue summary here</summary>
///<remarks><c>F:Mono.DocTest.Color.Blue</c>.</remarks>
Blue,
///<summary>Insert Green summary here</summary>
///<remarks><c>F:Mono.DocTest.Color.Green</c>.</remarks>
Green,
AnotherGreen = Green,
};*/
/// <summary>Process interface</summary>
/// <remarks><c>T:Mono.DocTest.IProcess</c>.</remarks>
public interface class IProcess
{
};
/// <summary>Process interface</summary>
/// <remarks><c>T:Mono.DocTest.DocValueType</c>.</remarks>
public value class DocValueType : IProcess {
public:
/// <remarks><c>F:Mono.DocTest.DocValueType.total</c>.</remarks>
int total;
public:
/// <param name="i">A <see cref="T:System.Int32" />.</param>
/// <remarks><see cref="M:Mono.DocTest.DocValueType.M(System.Int32)"/>.</remarks>
void M(int i)
{
if (((gcnew Random())->Next() % 2) == 0)
throw gcnew SystemException();
throw gcnew ApplicationException();
}
};
public value class ValueClassSpecificField {
public: DocValueType ExceptionField;
};
/// <remarks><c>T:Mono.DocTest.D</c></remarks>
public delegate Object ^ D(Func<String ^ , Object ^ , Object ^ > ^ value );
/// <remarks><c>T:Mono.DocTest.Widget</c>.</remarks>
/// <seealso cref="P:Mono.DocTest.Widget.Item(System.Int32)" />
/// <extra>Some extra tag value</extra>
public ref class Widget : IProcess {
//public: virtual double getVolume() { return 0; };
/// <remarks><c>T:Mono.DocTest.Widget.NestedClass</c>.</remarks>
public: ref class NestedClass {
/// <remarks><c>F:Mono.DocTest.Widget.NestedClass.value</c>.</remarks>
public: int value;
/// <param name="i">Some <see cref="T:System.Int32" />.</param>
/// <remarks><c>M:Mono.DocTest.Widget.NestedClass.M(System.Int32)</c>.</remarks>
void M(int i) {};
/// <remarks><c>T:Mono.DocTest.Widget.NestedClass.Double</c>.</remarks>
ref class Double {
/// <remarks><c>T:Mono.DocTest.Widget.NestedClass.Double.Triple</c>.</remarks>
public: ref class Triple {
/// <remarks><c>T:Mono.DocTest.Widget.NestedClass.Double.Triple.Quadruple</c>.</remarks>
public: ref class Quadruple {};// for good measure
};
};
};
public: enum class NestedEnum { Value1, Value2};
/// <remarks><c>T:Mono.DocTest.Widget.NestedClass`1</c>.</remarks>
public:
//todo: cannot use the same class name here with generic par-r
generic<typename T>
ref class NestedClass1 {
/// <remarks><c>F:Mono.DocTest.Widget.NestedClass`1.value</c>.</remarks>
public: int value;
/// <param name="i">Another <see cref="T:System.Int32" />.</param>
/// <remarks><c>M:Mono.DocTest.Widget.NestedClass`1.M(System.Int32)</c>.</remarks>
public: void M(int i) {};
};
/// <remarks><c>F:Mono.DocTest.Widget.classCtorError</c>.</remarks>
public: static initonly cli::array<String^>^ classCtorError = CreateArray();
private: static cli::array<String^>^ CreateArray()
{
throw gcnew NotSupportedException();
};
/// <remarks><c>F:Mono.DocTest.Widget.message</c>.</remarks>
public: String^ message;
/// <remarks><c>F:Mono.DocTest.Widget.defaultColor</c>.</remarks>
protected: static Color defaultColor;
/// <remarks><c>F:Mono.DocTest.Widget.PI</c>.</remarks>
//TODO: no internal
protected: const double PI = 3.14159;
/// <remarks><c>F:Mono.DocTest.Widget.monthlyAverage</c>.</remarks>
protected public: initonly double monthlyAverage;
/// <remarks><c>F:Mono.DocTest.Widget.array1</c>.</remarks>
public: cli::array<long^>^ array1;
/// <remarks><c>F:Mono.DocTest.Widget.array2</c>.</remarks>
//todo: check if works correctly
public: cli::array<Widget^, 2> ^ array2;
//TODO: no possibiiti for unsafe
/// <remarks><c>F:Mono.DocTest.Widget.pCount</c>.</remarks>
public: int *pCount;
//TODO: no possibiiti for unsafe
/// <remarks><c>F:Mono.DocTest.Widget.ppValues</c>.</remarks>
public: float** ppValues;
/// <remarks><c>T:Mono.DocTest.Widget.IMenuItem</c>.</remarks>
public: interface class IMenuItem {
/// <remarks><c>M:Mono.DocTest.Widget.IMenuItem.A</c>.</remarks>
void A();
/// <remarks><c>P:Mono.DocTest.Widget.IMenuItem.P</c>.</remarks>
property int B {
int get();
void set(int value);
};
};
/// <remarks><c>T:Mono.DocTest.Widget.Del</c>.</remarks>
public: delegate void Del(int i);
/// <remarks><c>T:Mono.DocTest.Widget.Direction</c>.</remarks>
//todo: no internal
protected:
[FlagsAttribute]
/*internal*/ enum class Direction {
/// <remarks><c>T:Mono.DocTest.Widget.Direction.North</c>.</remarks>
North,
/// <remarks><c>T:Mono.DocTest.Widget.Direction.South</c>.</remarks>
South,
/// <remarks><c>T:Mono.DocTest.Widget.Direction.East</c>.</remarks>
East,
/// <remarks><c>T:Mono.DocTest.Widget.Direction.West</c>.</remarks>
West,
};
/// <remarks>
/// <para><c>C:Mono.DocTest.Widget</c>.</para>
/// <para><c>M:Mono.DocTest.Widget.#ctor</c>.</para>
/// <para><see cref="C:Mono.DocTest.Widget(System.String)" /></para>
/// <para><see cref="C:Mono.DocTest.Widget(System.Converter{System.String,System.String})" /></para>
/// </remarks>
public: Widget() {};
/// <param name="s">A <see cref="T:System.String" />.</param>
/// <remarks>
/// <para><c>C:Mono.DocTest.Widget(System.String)</c>.</para>
/// <para><c>M:Mono.DocTest.Widget.#ctor(System.String)</c>.</para>
/// </remarks>
public: Widget(String^ s) {};
/// <param name="c">A <see cref="T:System.Converter{System.String,System.String}" />.</param>
/// <remarks>
/// <para><c>C:Mono.DocTest.Widget(System.Converter{System.String,System.String})</c>.</para>
/// </remarks>
public: Widget(Converter<String^, String^>^ c) {};
/// <remarks><c>M:Mono.DocTest.Widget.M0</c>.</remarks>
public: static void M0() {};
/// <param name="c">A <see cref="T:System.Char" />.</param>
/// <param name="f">A <see cref="T:System.Single" />.</param>
/// <param name="v">A <see cref="T:Mono.DocTest.DocValueType" />.</param>
/// <remarks><c>M:Mono.DocTest.Widget.M1(System.Char,System.Signle@,Mono.DocTest.DocValueType@)</c>.</remarks>
/// //TODO: doc attribute is not working
public:
[DocAttribute("normal DocAttribute", Field = true)]
//[return:Doc("return:DocAttribute", Property = typeof(Widget))]
void M1([Doc("c", FlagsEnum = ConsoleModifiers::Alt | ConsoleModifiers::Control)] long c,
[Doc("f", NonFlagsEnum = Color::Red)][Runtime::InteropServices::Out] float % f,
[DocAttribute("v")] DocValueType % v) {
f = 0;
};
/// <param name="x1">A <see cref="T:System.Int16" /> array.</param>
/// <param name="x2">A <see cref="T:System.Int32" /> array.</param>
/// <param name="x3">A <see cref="T:System.Int64" /> array.</param>
/// <remarks><c>M:Mono.DocTest.Widget.M2(System.Int16[],System.Int32[0:,0:],System.Int64[][])</c>.</remarks>
public: void M2(cli::array<short>^ x1, cli::array<int, 2>^ x2, cli::array<cli::array<long >^ >^ x3) {};
/// <param name="x3">Another <see cref="T:System.Int64" /> array.</param>
/// <param name="x4">A <see cref="T:Mono.DocTest.Widget" /> array.</param>
/// <remarks><c>M:Mono.DocTest.Widget.M3(System.Int64[][],Mono.DocTest.Widget[0:,0:,0:][])</c>.</remarks>
protected: void M3(cli::array<cli::array<long >^ >^ x3, cli::array<cli::array<Widget^, 3>^>^ x4) {};
//TODO: no unsafe
/// <param name="pc">A <see cref="T:System.Char" /> pointer.</param>
/// <param name="ppf">A <see cref="T:Mono.DocTest.Color" /> pointer.</param>
/// <remarks><c>M:Mono.DocTest.Widget.M4(System.Char*,Mono.DocTest.Color**)</c>.</remarks>
protected: void M4(char *pc, Color **ppf) {};
//TODO: no unsafe
/// <param name="pv">A <see cref="T:System.Void" /> pointer.</param>
/// <param name="pd">A <see cref="T:System.Double" /> array.</param>
/// <remarks><c>M:Mono.DocTest.Widget.M5(System.Void*,System.Double*[0:,0:][])</c>.</remarks>
protected: void M5(void *pv, cli::array<cli::array<double, 2>^>^*pd) {};
protected: void M55(void *pv, System::String ^ *pd) {};
/// <param name="i">Yet another <see cref="T:System.Int32" />.</param>
/// <param name="args">An <see cref="T:System.Object" /> array.</param>
/// <remarks><c>M:Mono.DocTest.Widget.M6(System.Int32,System.Object[])</c>.</remarks>
protected: void M6(int i, ... cli::array<Object^>^ args) {};
/// <remarks><c>M:Mono.DocTest.Widget.M7(Mono.DocTest.Widget.NestedClass.Double.Triple.Quadruple)</c>.</remarks>
public: void M7(Widget::NestedClass::Double::Triple::Quadruple ^ a) {};
/// <value>A <see cref="T:System.Int32" /> value...</value>
/// <remarks><c>P:Mono.DocTest.Widget.Width</c>.</remarks>
public:
[DocAttribute("Width property")]
property int Width {
[Doc("Width get accessor")]
int get() { return 0; };
protected:
[Doc("Width set accessor")]
void set(int value) {};
};
/// <value>A <see cref="T:System.Int64" /> value...</value>
/// <remarks><c>P:Mono.DocTest.Widget.Height</c>.</remarks>
protected:
[Doc("Height property")]
property long Height { long get() { return 0; }; };
/// <value>A <see cref="T:System.Int16" /> value...</value>
/// <remarks><c>P:Mono.DocTest.Widget.X</c>.</remarks>
//todo: no internal (protected internal)
protected: property short X { void set(short value) {}; };
/// <value>A <see cref="T:System.Double" /> value...</value>
/// <remarks><c>P:Mono.DocTest.Widget.Y</c>.</remarks>
//todo: no internal(protected internal)
protected: property double Y {
double get() { return 0; };
void set(double value) {};
};
/// <param name="i">TODO</param>
/// <remarks><c>P:Mono.DocTest.Widget.Item(System.Int32)</c>.</remarks>
/// <value>A <see cref="T:System.Int32" /> instance.</value>
public:
[DocAttribute("Item property")]
property int default[int]{
int get(int index) { return 0; };
[Doc("Item property set accessor")]
void set(int index, int value) {};
};
public:
[DocAttribute("Item property")]
property long indexedProperty[long]{
long get(long index) { return 0; };
[Doc("Item property set accessor")]
void set(long index, long value) {};
};
/// <param name="s">Some <see cref="T:System.String" />.</param>
/// <param name="i">I love <see cref="T:System.Int32" />s.</param>
/// <remarks><c>P:Mono.DocTest.Widget.Item(System.String,System.Int32)</c>.</remarks>
/// <value>A <see cref="T:System.Int32" /> instance.</value>
public:
property int default[System::String ^, int]
{ int get(System::String ^ s, int i) { return 0; }
void set(System::String ^ s, int i, int value) {};
};
/// <remarks><c>E:Mono.DocTest.Widget.AnEvent</c>.</remarks>
public:
[Doc("Del event")]
event Del^ AnEvent {
[Doc("Del add accessor")]
void add(Del^ name) {};
[Doc("Del remove accessor")]
void remove(Del^ name) {};
void raise(int i) {};
};
/// <remarks><c>E:Mono.DocTest.Widget.AnotherEvent</c>.</remarks>
protected: event Del^ AnotherEvent;
/// <param name="x">Another <see cref="T:Mono.DocTest.Widget" />.</param>
/// <remarks><c>M:Mono.DocTest.Widget.op_UnaryPlus(Mono.DocTest.Widget)</c>.</remarks>
/// <returns>A <see cref="T:Mono.DocTest.Widget" /> instance.</returns>
public: static Widget^ operator + (Widget x) { return nullptr; }
/// <remarks><c>M:Mono.DocTest.Widget.op_Division</c>.</remarks>
/// <returns>A <see cref="T:Mono.DocTest.Widget" /> instance.</returns>
//todo": added 1 to compile
public: static Widget^ op_Division1 = nullptr;
/// <param name="x1">Yet Another <see cref="T:Mono.DocTest.Widget" />.</param>
/// <param name="x2">Yay, <see cref="T:Mono.DocTest.Widget" />s.</param>
/// <remarks><c>M:Mono.DocTest.Widget.op_Addition(Mono.DocTest.Widget,Mono.DocTest.Widget)</c>.</remarks>
/// <returns>A <see cref="T:Mono.DocTest.Widget" /> instance (2).</returns>
public: static Widget^ operator+ (Widget x1, Widget x2) { return nullptr; }
/// <param name="x"><see cref="T:Mono.DocTest.Widget" />s are fun!.</param>
/// <remarks><c>M:Mono.DocTest.Widget.op_Explicit(Mono.DocTest.Widget)~System.Int32</c>.</remarks>
/// <returns>A <see cref="T:System.Int32" /> instance.</returns>
public: static explicit operator int(Widget^ x) { return 0; }
/// <param name="x"><c>foo</c>; <see cref="T:Mono.DocTest.Widget" />.</param>
/// <remarks><c>M:Mono.DocTest.Widget.op_Implicit(Mono.DocTest.Widget)~System.Int64</c>.</remarks>
/// <returns>A <see cref="T:System.Int64" /> instance.</returns>
//todo: no implicit(default behavior)
public: static operator long(Widget x) { return 0; }
/// <remarks><c>M:Mono.DocTest.Widget.Default(System.Int32,System.Int32)</c></remarks>c
//todo: no default value
public: void Default(
[System::Runtime::InteropServices::Optional]
/*[System::Runtime::InteropServices::DefaultParameterValueAttribute(1)]*/int a,
[System::Runtime::InteropServices::Optional]
/*[System::Runtime::InteropServices::DefaultParameterValueAttribute(2)]*/int b) {};
/// <remarks><c>M:Mono.DocTest.Widget.Default(System.String,System.Char)</c></remarks>
//todo: no default value
public: void Default(/*[System::Runtime::InteropServices::DefaultParameterValueAttribute("a")]*/string a, /*[System::Runtime::InteropServices::DefaultParameterValueAttribute('b')]*/char b) {};
//TODO: no dynamics - use Object instead/ + no + operator
/// <remarks><c>M:Mono.DocTest.Widget.Dynamic0(System.Object,System.Object)</c></remarks>
public: Object^ Dynamic0(Object^ a, Object^ b) { return gcnew Object(); }
//TODO: no dynamics - use Object instead
/// <remarks><c>M:Mono.DocTest.Widget.Dynamic1(System.Collections.Generic.Dictionary{System.Object,System.Object})</c></remarks>
public: Generic1::Dictionary<Object^, System::String^> ^ Dynamic1(Generic1::Dictionary<Object^, System::String^>^ value) { return value; };
//TODO: no dynamics - use Object instead
/// <remarks><c>M:Mono.DocTest.Widget.Dynamic2(System.Func{System.String,System.Object})</c></remarks>
public: Func<String^, Object^>^ Dynamic2(Func<String^, Object^>^ value) { return value; };
//TODO: no dynamics - use Object instead
/// <remarks><c>M:Mono.DocTest.Widget.Dynamic3(System.Func{System.Func{System.String,System.Object},System.Func{System.Object,System.String}})</c></remarks>
public: Func<Func<String^, Object^>^, Func< Object^, String^>^>^ Dynamic3(
Func<Func<String^, Object^>^, Func< Object^, String^>^>^ value) {
return value;
};
//TODO: no dynamics - use Object instead
/// <remarks><c>P:Mono.DocTest.Widget.DynamicP</c></remarks>
/*public: property Func<Func<String^, Object^, String^>^, Func<Object^, Func<Object^>, String^>^> ^DynamicP{
Func<Func<String^, Object^, String^>^, Func<Object^, Func<Object^>, String^>^> get(){ return nullptr; };
};*/
//TODO: no dynamics - use Object instead
/// <remarks><c>F:Mono.DocTest.Widget.DynamicF</c></remarks>
public: Func<Func<String^, Object^, String^>^, Func<Object^, Func<Object^>^, String^>^> ^DynamicF;
//TODO: no dynamics - use Object instead + use delegate as pure Func cannot be used
/// <remarks><c>E:Mono.DocTest.Widget.DynamicE1</c></remarks>
public: [Obsolete("why not")] event Func<Object^>^ DynamicE1;
//TODO: no dynamics - use Object instead
/// <remarks><c>E:Mono.DocTest.Widget.DynamicE2</c></remarks>
public: event Func<Object^>^ DynamicE2 {
[Doc("Del add accessor")]
void add(Func<Object^>^ name) {};
[Doc("Del remove accessor")]
void remove(Func<Object^>^ name) {};
Object^ raise() { return gcnew Object(); };
};
};
/// <remarks><c>T:Mono.DocTest.UseLists</c>.</remarks>
public ref class UseLists
{
/// <param name="list">A <see cref="T:Mono.DocTest.Generic.MyList{System.Int32}" />.</param>
/// <remarks><c>M:Mono.DocTest.UseLists.Process(Mono.DocTest.MyList{System.Int32})</c>.</remarks>
public: void Process(Mono_DocTest_Generic::MyList<int> ^ list) {};
/// <param name="value">A <c>T</c>.</param>
/// <typeparam name="T">Something</typeparam>
/// <remarks><c>M:Mono.DocTest.UseLists.GetValues``1(``0)</c>.</remarks>
/// <returns>A <see cref="T:Mono.DocTest.Generic.MyList`1" /> instance.</returns>
public:
generic<typename T>
where T : value class
Mono_DocTest_Generic::MyList<T>^ GetValues(T value) { return nullptr; };
/// <param name="list">Another <see cref="T:Mono.DocTest.Generic.MyList{System.Int32}" />.</param>
/// <remarks>
/// <para><c>M:Mono.DocTest.UseLists.Process(System.Collections.Generic.List{System.Int32})</c>.</para>
/// <para><see cref="M:System.Collections.Generic.List{System.Int32}.Remove(`0)" /></para>
/// </remarks>
/// <exception name="Whatever">text!</exception>
/// <exception invalid="foo">text!</exception>
public: void Process(Generic1::List<int> list)
{
// Bug: only creation is looked for, so this generates an <exception/>
// node:
gcnew Exception();
// Bug? We only look at "static" types, so we can't follow
// delegates/interface calls:
//todo:uncomment
/*Func<int, int>^ a = x = > {throw gcnew InvalidOperationException(); };
a(1);*/
// Multi-dimensional arrays have "phantom" methods that Cecil can't
// resolve, as they're provided by the runtime. These should be
// ignored.
cli::array<int, 2>^ array = gcnew cli::array<int, 2>(1, 1);
array[0, 0] = 42;
};
/// <param name="list">A <see cref="T:Mono.DocTest.Generic.MyList{System.Predicate{System.Int32}}" />.</param>
/// <remarks><c>M:Mono.DocTest.UseLists.Process(System.Collections.Generic.List{System.Predicate{System.Int32}})</c>.</remarks>
public: void Process(Generic1::List<Predicate<int>^>^ list)
{
if (list == nullptr)
throw gcnew ArgumentNullException("list");
Process<int>(list);
};
/// <param name="list">A <see cref="T:Mono.DocTest.Generic.MyList{System.Predicate{``0}}" />.</param>
/// <typeparam name="T">Something Else</typeparam>
/// <remarks><c>M:Mono.DocTest.UseLists.Process``1(System.Collections.Generic.List{System.Predicate{``0}})</c>.</remarks>
public:
generic<typename T>
void Process(Generic1::List<Predicate<T>^>^ list)
{
if (list->Contains(nullptr))
throw gcnew ArgumentException("predicate null");
};
/// <param name="helper">A <see cref="T:Mono.DocTest.Generic.MyList{``0}.Helper{``1,``2}" />.</param>
/// <typeparam name="T"><c>T</c></typeparam>
/// <typeparam name="U"><c>U</c></typeparam>
/// <typeparam name="V"><c>V</c></typeparam>
/// <remarks><c>M:Mono.DocTest.UseLists.UseHelper``3(Mono.DocTest.Generic.MyList{``0}.Helper{``1,``2})</c>.</remarks>
public:
generic<typename T, typename U, typename V>
void UseHelper(Mono_DocTest_Generic::MyList<T>::Helper<U, V>^ helper) {};
};
};

View File

@ -0,0 +1,400 @@
#pragma once
#pragma once
namespace Generic1 = System::Collections::Generic;
class TestClass
{
public:
TestClass();
~TestClass();
};
public enum class Color {
/// <summary>Insert Red summary here</summary>
/// <remarks><c>F:Mono.DocTest.Color.Red</c>.</remarks>
Red,
/// <summary>Insert Blue summary here</summary>
/// <remarks><c>F:Mono.DocTest.Color.Blue</c>.</remarks>
Blue,
/// <summary>Insert Green summary here</summary>
/// <remarks><c>F:Mono.DocTest.Color.Green</c>.</remarks>
Green,
AnotherGreen = Green,
};
/// <typeparam name="T">T generic param</typeparam>
/// <remarks><c>T:Mono.DocTest.IFoo`1</c>.</remarks>
generic<typename T>
public interface class IFoo {
/// <typeparam name="U">U generic param</typeparam>
/// <remarks><c>T:Mono.DocTest.IFoo`1.Method``1(`0,``0)</c>.</remarks>
generic<typename U>
T Method(T t, U u);
};
namespace Mono_DocTest_Generic {
using namespace System;
using namespace System::Collections;
generic<typename T>
where T: value class
public interface class IFooNew {
/// <typeparam name="U">U generic param</typeparam>
/// <remarks><c>T:Mono.DocTest.IFoo`1.Method``1(`0,``0)</c>.</remarks>
generic<typename U>
T Method(T t, U u);
};
/// <summary>extension methods!</summary>
/// <remarks><c>T:Mono.DocTest.Generic.Extensions</c></remarks>
//todo: do need attribute on class??
[System::Runtime::CompilerServices::Extension]
public ref class Extensions abstract sealed {
/// <summary><c>System.Object</c> extension method</summary>
/// <remarks><c>M:Mono.DocTest.Generic.Extensions.ToEnumerable``1</c></remarks>
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static Generic1::IEnumerable<T> ^ ToEnumerable(T self)
{
//todo: no yield
//yield return self;
return gcnew Generic1::List<T>();
};
/// <summary><see cref="T:System.Collections.Generic.IEnumerable`1" /> extension method</summary>
/// <remarks><c>M:Mono.DocTest.Generic.Extensions.ForEach``1</c></remarks>
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static void ForEach(Generic1::IEnumerable<T> ^ self, Action<T> ^ a)
{
};
/// <summary><see cref="T:Mono.DocTest.Generic.IFoo`1" /> extension method</summary>
/// <remarks><c>M:Mono.DocTest.Generic.Extensions.Bar``1</c></remarks>
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static void Bar(IFoo<T>^ self, String ^ s)
{
};
/// <summary>
/// <see cref="T:System.Collections.Generic.IEnumerable{System.Int32}" />
/// extension method.
/// </summary>
/// <remarks><c>M:Mono.DocTest.Generic.Extensions.ToDouble</c></remarks>
public:
[System::Runtime::CompilerServices::Extension]
static Generic1::IEnumerable<double>^ ToDouble(Generic1::IEnumerable<int>^ list)
{
return nullptr;
};
/// <summary>
/// <see cref="T:Mono.DocTest.Generic.IFoo`1" /> extension method.
/// </summary>
/// <remarks><c>M:Mono.DocTest.Generic.Extensions.ToDouble</c></remarks>
public:
generic <typename T>
where T : IFoo<T>
[System::Runtime::CompilerServices::Extension]
static double ToDouble(T val)
{
// the target type is T:...IFoo<T>, NOT T:System.Object.
return 0.0;
};
};
/// <typeparam name="U">Insert <c>text</c> here.</typeparam>
/// <remarks><c>T:Mono.DocTest.Generic.GenericBase`1</c>.</remarks>
generic <typename U>
public ref class GenericBase {
/// <param name="genericParameter">Something</param>
/// <typeparam name="S">Insert more <c>text</c> here.</typeparam>
/// <remarks><c>M:Mono.DocTest.GenericBase`1.BaseMethod``1(``0)</c>.</remarks>
/// <returns>The default value.</returns>
//todo: done for default keyword
private: U member;
//todo: done for default keyword
public: GenericBase() : member()
{
};
//todo: done for default keyword
GenericBase(GenericBase^ c)
{
member = c->member;
};
public:
generic <typename S>
U BaseMethod(/*[Doc("S")]*/S genericParameter) {
return member;
};
U BaseMethod2(GenericBase<U> genericParameter) {
return member;
};
/// <remarks><c>F:Mono.DocTest.GenericBase`1.StaticField1</c></remarks>
public:
static initonly GenericBase<U> ^ StaticField1 = gcnew GenericBase<U>();
/// <remarks><c>F:Mono.DocTest.GenericBase`1.ConstField1</c></remarks>
public: const int ConstInt = 1;
public: const long ConstLong = 2;
public: const Decimal ConstDecimal;
public: const short ConstShort = 4;
public: const UInt16 ConstUint16 = 2 ;
public: const UInt32 ConstUint32 = 3;
public: const UInt64 ConstUint64 = 4;
public: const float ConstFloat = 2.4;
public: const bool ConstBool = true;
public: const char ConstChar = 't';
public: const Object^ ConstObject;
public: const String^ ConstString;
/// <param name="list">Insert description here</param>
/// <remarks><c>M:Mono.DocTest.GenericBase`1.op_Explicit(Mono.DocTest.GenericBase{`0})~`0</c></remarks>
/// <returns>The default value for <typeparamref name="U"/>.</returns>
//public: static explicit operator U(GenericBase<U> list) { /*return 0;*/ return nullptr; };
/// <remarks>T:Mono.DocTest.Generic.GenericBase`1.FooEventArgs</remarks>
public: ref class FooEventArgs : EventArgs {
};
/// <remarks>E:Mono.DocTest.Generic.GenericBase`1.MyEvent</remarks>
public: event EventHandler<FooEventArgs ^ > ^ MyEvent;
/// <remarks>E:Mono.DocTest.Generic.GenericBase`1.ItemChanged</remarks>
//todo: uncomment
//public: event Action<Mono_DocTest_Generic::MyList<U>^, Mono_DocTest_Generic::MyList<U>::Helper<U, U>^> ItemChanged;
/// <remarks>T:Mono.DocTest.Generic.GenericBase`1.NestedCollection</remarks>
public: ref class NestedCollection {
//todo: no internal
/// <remarks>T:Mono.DocTest.Generic.GenericBase`1.NestedCollection.Enumerator</remarks>
protected: value struct Enumerator {
};
};
};
/// <typeparam name="T">I'm Dying Here!</typeparam>
/// <remarks><c>T:Mono.DocTest.Generic.MyList`1</c>.</remarks>
//todo: on generic par-r [Mono.DocTest.Doc("Type Parameter!")]
generic <typename T>
public ref class MyList : GenericBase<T>, Generic1::IEnumerable<cli::array <int> ^ >
{
/// <typeparam name="U">Seriously!</typeparam>
/// <typeparam name="V">Too <c>many</c> docs!</typeparam>
/// <remarks><c>T:Mono.DocTest.MyList`1.Helper`2</c>.</remarks>
public:
generic<typename U, typename V>
ref class Helper {
/// <param name="a">Ako</param>
/// <param name="b">bko</param>
/// <param name="c">cko</param>
/// <remarks><c>M:Mono.DocTest.MyList`1.Helper`2.UseT(`0,`1,`2)</c>.</remarks>
public: void UseT(T a, U b, V c) { };
};
/// <param name="t">tko</param>
/// <remarks><c>M:Mono.DocTest.MyList`1.Test(`0)</c>.</remarks>
public: void Test(T t) { auto a = gcnew MyList::Helper<int, String^>(); };
/// <param name="t">Class generic type</param>
/// <param name="u">Method generic type</param>
/// <typeparam name="U">Method generic parameter</typeparam>
/// <remarks><c>M:Mono.DocTest.MyList`1.Method``1(`0,``0)</c>.</remarks>
public:
generic<typename U>
void Method(T t, U u) {};
// mcs "crashes" (CS1569) on this method; exclude it for now.
// <remarks><c>M:Mono.DocTest.MyList`1.RefMethod``1(`0@,``0@)</c>.</remarks>
public:
generic<typename U>
void RefMethod(T% t, U% u) {};
/// <param name="helper">A <see cref="T:Mono.DocTest.Generic.MyList`1.Helper`2" />.</param>
/// <typeparam name="U">Argh!</typeparam>
/// <typeparam name="V">Foo Argh!</typeparam>
/// <remarks><c>M:Mono.DocTest.Generic.MyList`1.UseHelper``2(Mono.DocTest.Generic.MyList{``0}.Helper{``1,``2})</c>.</remarks>
public:
generic<typename U, typename V>
void UseHelper(Helper helper) {};
/// <remarks><c>M:Mono.DocTest.Generic.MyList`1.GetHelper``2</c>.</remarks>
/// <returns><see langword="null" />.</returns>
public:
generic<typename U, typename V>
Helper^ GetHelper() { return nullptr; };
/// <remarks><c>M:Mono.DocTest.MyList`1.System#Collections#GetEnumerator</c>.</remarks>
public: virtual IEnumerator^ GetEnumerator1() = IEnumerable::GetEnumerator{
return nullptr;
};
/// <remarks><c>M:Mono.DocTest.MyList`1.GetEnumerator</c>.</remarks>
public: virtual Generic1::IEnumerator<cli::array<int>^>^ GetEnumerator() = Generic1::IEnumerable<cli::array<int>^>::GetEnumerator{
return nullptr;
};
};
/// <typeparam name="T">T generic param</typeparam>
/// <remarks><c>T:Mono.DocTest.IFoo`1</c>.</remarks>
generic <typename T>
public interface class IFoo {
/// <typeparam name="U">U generic param</typeparam>
/// <remarks><c>T:Mono.DocTest.IFoo`1.Method``1(`0,``0)</c>.</remarks>
generic<typename U>
T Method(T t, U u);
};
generic <typename T>
where T: gcnew()
public ref class GenericConstraintClass {
};
/// <typeparam name="A">Ako generic param</typeparam>
/// <typeparam name="B">Bko generic param</typeparam>
/// <remarks><c>T:Mono.DocTest.MyList`2</c>.</remarks>
generic <typename A, typename B>
//where A : class, IList<B>, gcnew()
//where B : class, A
public ref class MyList1 : Generic1::ICollection<A>,
Generic1::IEnumerable<A>, Generic1::IEnumerator<A>,
IFoo<A>
, GenericBase<Generic1::Dictionary<A,B>^ >/*<>*/
{
~MyList1() {};
// IEnumerator
// shown?
//todo: uncomment
//property Object^ IEnumerator::Current { Object^ get() { return nullptr; } }
/// <remarks><c>M:Mono.DocTest.MyList`2.MoveNext</c>.</remarks>
/// <returns><see cref="T:System.Boolean" /></returns>
public:
virtual bool MoveNext() { return false; };
/// <remarks><c>M:Mono.DocTest.MyList`2.Reset</c>.</remarks>
public:
virtual void Reset() {};
virtual property Object^ Current3 {
Object^ get() = IEnumerator::Current::get{ return nullptr; }
};
// IEnumerator<T>
/// <remarks><c>P:Mono.DocTest.MyList`2.Current</c>.</remarks>
/// <value>The current value.</value>
public:
property A Current1 {
A get() { return Current2; /*default(A);*/ }
};
/// <remarks><c>P:Mono.DocTest.MyList`2.Current</c>.</remarks>
/// <value>The current value.</value>
virtual property A Current2 {
A get() sealed = Generic1::IEnumerator<A>::Current::get{ return Current1; /*default(A);*/ };// { return default(A); }
};
/// <remarks><c>M:Mono.DocTest.MyList`2.System#Collections#GetEnumerator</c>.</remarks>
public: virtual System::Collections::IEnumerator^ GetEnumerator1() = System::Collections::IEnumerable::GetEnumerator{
return nullptr;
};
// IEnumerable<T>
/// <remarks><c>M:Mono.DocTest.MyList`2.System#Collections#Generic#IEnumerable{A}#GetEnumerator</c>.</remarks>
/// <returns>A <see cref="T:System.Collections.Generic.IEnumerator{`0}" />.</returns>
virtual Generic1::IEnumerator<A>^ GetEnumerator() = Generic1::IEnumerable<A>::GetEnumerator{ return nullptr; };
public: Generic1::List<A>::Enumerator^ GetEnumerator3() { return gcnew Generic1::List<A>::Enumerator(); };
// ICollection<T>
/// <remarks><c>P:Mono.DocTest.MyList`2.Count</c>.</remarks>
/// <value>A <see cref="T:System.Int32" />.</value>
public:
virtual property int Count {
int get() { return 0; }
};
/// <remarks><c>P:Mono.DocTest.MyList`2.System#Collections#Generic#ICollection{A}#IsReadOnly</c>.</remarks>
/// <value>A <see cref="T:System.Boolean" />.</value>
public:
virtual property bool IsReadOnly {
bool get() { return false; }
};
/// <param name="item">The item to add.</param>
/// <remarks><c>M:Mono.DocTest.MyList`2.System#Collections#Generic#ICollection{A}#Add(`0)</c>.</remarks>
virtual void Add(A item) = Generic1::ICollection<A>::Add{};
/// <remarks><c>M:Mono.DocTest.MyList`2.System#Collections#Generic#ICollection{A}#Clear</c>.</remarks>
virtual void Clear() = Generic1::ICollection<A>::Clear{};
/// <param name="item">The item to check for</param>
/// <remarks><c>M:Mono.DocTest.MyList`2.System#Collections#Generic#ICollection{A}.Contains(`0)</c>.</remarks>
/// <returns>A <see cref="T:System.Boolean" /> instance (<see langword="false" />).</returns>
virtual bool Contains(A item) = Generic1::ICollection<A>::Contains{ return false; };
/// <param name="array">Where to copy elements to</param>
/// <param name="arrayIndex">Where to start copyingto</param>
/// <remarks><c>M:Mono.DocTest.MyList`2.CopyTo(`0[],System.Int32)</c>.</remarks>
public: virtual void CopyTo(cli::array<A>^ arrayPar, int arrayIndex) = Generic1::ICollection<A>::CopyTo{};
/// <param name="item">the item to remove</param>
/// <remarks><c>M:Mono.DocTest.MyList`2.System#Collections#Generic#ICollection{A}#Remove(`0)</c>.</remarks>
/// <returns>Whether the item was removed.</returns>
virtual bool Remove(A item) = Generic1::ICollection<A>::Remove{ return false; };
/// <remarks>M:Mono.DocTest.Generic.MyList`2.Foo</remarks>
public:
generic<typename AA, typename BB>
where AA : Generic1::IEnumerable<A>
where BB : Generic1::IEnumerable<B>
Generic1::KeyValuePair<AA, BB>^ Foo()
{
return gcnew Generic1::KeyValuePair<AA, BB>();
};
// IFoo members
/// <typeparam name="U">U generic param on MyList`2</typeparam>
/// <remarks><c>M:Mono.DocTest.Generic.MyList`2.Mono#DocTest#Generic#IFoo{A}#Method``1(`0,``0)</c>.</remarks>
generic<typename U>
virtual A Method(A a, U u) = IFoo<A>::Method
{
return Current2; /*default(A);*/
};
};
}

View File

@ -0,0 +1,6 @@
// This is the main DLL file.
#include "stdafx.h"
#include "mdoc.Test.Cplusplus.h"

View File

@ -0,0 +1,15 @@
// mdoc.Test.Cplusplus.h
#pragma once
using namespace System;
namespace mdocTestCplusplus {
public ref class Class1
{
// TODO: Add your methods for this class here.
public:
int t;
};
}

View File

@ -0,0 +1,158 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{9398D4E3-1779-44FD-AF8C-BB46562DCD88}</ProjectGuid>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<Keyword>ManagedCProj</Keyword>
<RootNamespace>mdocTestCplusplus</RootNamespace>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>Use</PrecompiledHeader>
</ClCompile>
<Link>
<AdditionalDependencies />
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>Use</PrecompiledHeader>
</ClCompile>
<Link>
<AdditionalDependencies />
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>Use</PrecompiledHeader>
</ClCompile>
<Link>
<AdditionalDependencies />
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>Use</PrecompiledHeader>
</ClCompile>
<Link>
<AdditionalDependencies />
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="mdoc.Test.Cplusplus.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="Stdafx.h" />
<ClInclude Include="TestClass.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="AssemblyInfo.cpp" />
<ClCompile Include="mdoc.Test.Cplusplus.cpp" />
<ClCompile Include="Stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="TestClass.cpp" />
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="mdoc.Test.Cplusplus.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="TestClass.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="mdoc.Test.Cplusplus.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="AssemblyInfo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="TestClass.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,3 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by app.rc

View File

@ -3,5 +3,8 @@
/Test/DocTest.*
/Test/*.dll*
/Test/FrameworkTestData*
/Test/fx-import
Test/DocTest-DropNS-classic.xml
/.v2.txt
/.v0.txt
/.v0.txt
/Test/test-nuget-information

View File

@ -3,6 +3,35 @@ namespace Mono.Documentation
{
public static class Consts
{
public static string MonoVersion = "5.0.0.14";
}
public static string MonoVersion = "5.7.4.9";
public const string DocId = "DocId";
public const string CppCli = "C++ CLI";
public const string CppCx = "C++ CX";
public const string CppWinRt = "C++ WINRT";
public const string VbNet = "VB.NET";
public const string DocIdLowCase = "docid";
public const string VbNetLowCase = "vb.net";
public const string CppCliLowCase = "c++/cli";
public const string CppCxLowCase = "c++/cx";
public const string CppWinRtLowCase = "c++/winrt";
public const string Tab = " ";
public const string FSharp = "F#";
public const string FSharpLowCase = "f#";
public const string Javascript = "JavaScript";
public const string JavascriptLowCase = "javascript";
public const string DependencyPropertyFullName = "System.Windows.DependencyProperty";
public const string DependencyPropertyFullNameXaml = "Windows.UI.Xaml.DependencyProperty";
public const string DependencyObjectFullName = "System.Windows.DependencyObject";
public const string DependencyObjectFullNameXaml = "Windows.UI.Xaml.DependencyObject";
public const string VoidFullName = "System.Void";
public const string RefTypeObsoleteString = "Types with embedded references are not supported in this version of your compiler.";
public const string FrameworksIndexFolderName = "FrameworksIndex";
public const string CompilerGeneratedAttribute = "System.Runtime.CompilerServices.CompilerGeneratedAttribute";
public const string CompilationMappingAttribute = "Microsoft.FSharp.Core.CompilationMappingAttribute";
public const string FrameworksIndex = "FrameworksIndex";
public const string FrameworkAlternate = "FrameworkAlternate";
public const string Index = "Index";
}
}

View File

@ -0,0 +1,8 @@

// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage ("Potential Code Quality Issues", "RECS0022:A catch clause that catches System.Exception and has an empty body", Justification = "<Pending>", Scope = "member", Target = "~M:Mono.Documentation.Updater.Frameworks.FrameworkTypeEntry.ProcessMember(Mono.Cecil.MemberReference)")]

View File

@ -2,6 +2,7 @@ CONFIGURATION = Release
PROGRAM = ../bin/$(CONFIGURATION)/mdoc.exe
MONO = mono
CSCOMPILE = mcs
VBCOMPILE = vbnc
TEST_CSCFLAGS = -target:library
MDOC_COMMON_FLAGS = \
@ -55,6 +56,12 @@ endif
cleanup:
-rm -Rf Test/en.actual Test/html.actual
nunit:
mono ../packages/NUnit.ConsoleRunner.3.6.0/tools/nunit3-console.exe mdoc.Test/bin/$(CONFIGURATION)/mdoc.Test.dll
Test/DocTest-VB-Eii.dll:
$(VBCOMPILE) -out:Test/DocTest-VB-Eii.dll Test/ClassEnumerator.vb
Test/DocTest-addNonGeneric.dll:
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-addNonGeneric.cs
@ -63,11 +70,11 @@ Test/DocTest-addNonGeneric-v2.dll:
Test/DocTest-DropNS-classic-secondary.dll:
@echo $(value @)
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-DropNS-classic-secondary.cs
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-DropNS-classic-secondary.cs -doc:Test/DocTest-DropNS-classic-secondary.xml
Test/DocTest-DropNS-classic.dll:
@echo $(value @)
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-DropNS-classic.cs
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-DropNS-classic.cs -doc:Test/DocTest-DropNS-classic.xml
Test/DocTest-DropNS-unified.dll:
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-DropNS-unified.cs
@ -123,7 +130,22 @@ Test/DocTest.dll-v2:
Test/DocTest-enumerations.dll:
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-enumerations.cs
Test/DocTest-embedded-type.dll:
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-embedded-type.cs
Test/DocTest-typeForwards-First.dll:
rm -f $@
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-typeForwards.cs /define:FIRST
.PHONY: Test/DocTest-typeForwards-Second.dll
Test/DocTest-typeForwards-Second.dll:
rm -f $@
rm -f Test/DocTest-typeForwards-Second-First.dll
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-typeForwards.cs /define:FIRST
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:Test/DocTest-typeForwards-Second-First.dll /reference:$@ Test/DocTest-typeForwards.cs /define:SECOND
.PHONY: Test/FrameworkTestData
Test/FrameworkTestData: Test/DocTest-addNonGeneric.dll Test/DocTest-DropNS-classic.dll Test/DocTest-DropNS-classic-secondary.dll
rm -rf Test/FrameworkTestData
mkdir Test/FrameworkTestData
@ -144,6 +166,26 @@ Test/FrameworkTestData-fx-inheritance: Test/DocTest-framework-inheritance-one.dl
cp Test/DocTest-framework-inheritance-two.dll Test/FrameworkTestData-fx-inheritance/Two/
$(MONO) $(PROGRAM) fx-bootstrap Test/FrameworkTestData-fx-inheritance
.PHONY: check-monodocer-typeForwards
check-monodocer-typeForwards : Test/DocTest-typeForwards-First.dll Test/DocTest-typeForwards-Second.dll
-rm -Rf Test/en.actual
# set up the fx test data
-rm -Rf Test/FrameworkTestData-fx-typeForwards
mkdir Test/FrameworkTestData-fx-typeForwards
mkdir Test/FrameworkTestData-fx-typeForwards/One
mkdir Test/FrameworkTestData-fx-typeForwards/Two
mkdir Test/FrameworkTestData-fx-typeForwards/dependencies
mkdir Test/FrameworkTestData-fx-typeForwards/dependencies/Two
cp Test/DocTest-typeForwards-First.dll Test/FrameworkTestData-fx-typeForwards/One
cp Test/DocTest-typeForwards-Second-First.dll Test/FrameworkTestData-fx-typeForwards/Two
cp Test/DocTest-typeForwards-Second.dll Test/FrameworkTestData-fx-typeForwards/dependencies/Two
$(MONO) $(PROGRAM) fx-bootstrap Test/FrameworkTestData-fx-typeForwards
# now run mdoc update
$(MONO) $(PROGRAM) update -o Test/en.actual -frameworks Test/FrameworkTestData-fx-typeForwards
$(DIFF) Test/en.expected.typeForwards Test/en.actual
check-monodocer-frameworks: Test/FrameworkTestData
-rm -Rf Test/en.actual
$(MONO) $(PROGRAM) update -o Test/en.actual -frameworks Test/FrameworkTestData
@ -153,29 +195,116 @@ check-monodocer-frameworks-inheritance: Test/FrameworkTestData-fx-inheritance
-rm -Rf Test/en.actual
$(MONO) $(PROGRAM) update -o Test/en.actual -frameworks Test/FrameworkTestData-fx-inheritance
$(DIFF) Test/en.expected-frameworks-inheritance Test/en.actual
check-monodocer-frameworks-with-nuget:
-rm -Rf Test/en.actual
-rm -rf Test/test-nuget-information/input_data
mkdir Test/test-nuget-information/input_data
mkdir Test/test-nuget-information/input_data/One
mkdir Test/test-nuget-information/input_data/Two
cp Test/DocTest-addNonGeneric.dll Test/test-nuget-information/input_data/One/
cp Test/DocTest-DropNS-classic.dll Test/test-nuget-information/input_data/One/
cp Test/DocTest-addNonGeneric.dll Test/test-nuget-information/input_data/Two/
cp Test/DocTest-DropNS-classic-secondary.dll Test/test-nuget-information/input_data/Two/
cp Test/frameworks.xml Test/test-nuget-information/input_data/
$(MONO) $(PROGRAM) update -o Test/en.actual -frameworks Test/test-nuget-information/input_data
$(DIFF) Test/test-nuget-information/en.expected-frameworks-with-nuget-information Test/en.actual
check-monodocer-docid: Test/FrameworkTestData
-rm -Rf Test/en.actual
$(MONO) $(PROGRAM) update -use-docid -o Test/en.actual -frameworks Test/FrameworkTestData
$(DIFF) Test/en.expected-docid Test/en.actual
check-monodocer-vbnet: Test/FrameworkTestData
-rm -Rf Test/en.actual
$(MONO) $(PROGRAM) update -lang vb.net -o Test/en.actual -frameworks Test/FrameworkTestData
$(DIFF) Test/en.expected-vbnet Test/en.actual
check-monodocer-Eii:
-rm -Rf Test/en.actual
$(MAKE) Test/DocTest-VB-Eii.dll
$(MONO) $(PROGRAM) update -o Test/en.actual Test/DocTest-VB-Eii.dll -lang vb.net -lang fsharp -lang javascript -lang c++/cli -lang c++/cx -lang c++/winrt
$(DIFF) Test/en.expected-eii-implementation Test/en.actual
check-monodocer-Eii-importecmadoc-oldNames:
-rm -Rf Test/en.actual
$(MAKE) Test/DocTest-VB-Eii.dll
$(MONO) $(PROGRAM) update -o Test/en.actual Test/DocTest-VB-Eii.dll -lang vb.net -lang fsharp -lang javascript -lang c++/cli -lang c++/cx -lang c++/winrt -import Test/ClassEnumeratorECMA.xml
$(DIFF) Test/en.expected-eii-implementation-ecmadoc Test/en.actual
check-monodocer-Eii-importslashdoc:
-rm -Rf Test/en.actual
$(MAKE) Test/DocTest-VB-Eii.dll
$(MONO) $(PROGRAM) update -o Test/en.actual Test/DocTest-VB-Eii.dll -lang vb.net -lang fsharp -lang javascript -lang c++/cli -lang c++/cx -lang c++/winrt -import Test/ClassEnumeratorSlashDoc.xml
$(DIFF) Test/en.expected-eii-implementation-slashdoc Test/en.actual
check-monodocer-cppcli: Test/FrameworkTestData
-rm -Rf Test/en.actual
$(MONO) $(PROGRAM) update -lang c++/cli -o Test/en.actual -frameworks Test/FrameworkTestData
$(DIFF) Test/en.expected-cppcli Test/en.actual
check-monodocer-cppwinrtUwp:
-rm -Rf Test/en.actual
$(MONO) $(PROGRAM) update -lib ../external/Windows --lang c++/winrt -o Test/en.actual Test/UwpTestWinRtComponentCpp.winmd
$(DIFF) Test/ex.expected-cppwinrtuwp Test/en.actual
check-monodocer-cppcx: Test/FrameworkTestData
-rm -Rf Test/en.actual
$(MONO) $(PROGRAM) update -lang c++/cx -o Test/en.actual -frameworks Test/FrameworkTestData
$(DIFF) Test/en.expected-cppcx Test/en.actual
check-monodocer-cppcxDocTest: Test/DocTest.dll
-rm -Rf Test/en.actual
$(MONO) $(PROGRAM) update -lang c++/cx -o Test/en.actual Test/DocTest.dll
$(DIFF) Test/en.expected-cppcx2 Test/en.actual
check-monodocer-cppwinrt: Test/FrameworkTestData
-rm -Rf Test/en.actual
$(MONO) $(PROGRAM) update -lang c++/winrt -o Test/en.actual -frameworks Test/FrameworkTestData
$(DIFF) Test/en.expected-cppwinrt Test/en.actual
check-monodocer-cppwinrtDocTest: Test/DocTest.dll
-rm -Rf Test/en.actual
$(MONO) $(PROGRAM) update -lang c++/winrt -o Test/en.actual Test/DocTest.dll
$(DIFF) Test/en.expected-cppwinrt2 Test/en.actual
check-monodocer-vbnet2:
-rm -Rf Test/en.actual
$(MAKE) Test/DocTest.dll-v1
$(MONO) $(PROGRAM) update -lang vb.net -o Test/en.actual Test/DocTest.dll
$(DIFF) Test/en.expected-vbnet2 Test/en.actual
check-monodocer-javascript:
-rm -Rf Test/en.actual
$(MAKE) Test/DocTest.dll-v1
$(MONO) $(PROGRAM) update -lang javascript -o Test/en.actual Test/DocTest.dll
$(DIFF) Test/en.expected-javascript Test/en.actual
check-monodocer-embedded-type:
-rm -Rf Test/en.actual
$(MAKE) Test/DocTest-embedded-type.dll
$(MONO) $(PROGRAM) update -o Test/en.actual Test/DocTest-embedded-type.dll
$(DIFF) Test/en.expected-embedded-type Test/en.actual
check-monodocer-addNonGeneric:
-rm -Rf Test/en.actual
# first, make a docset with the generic method
$(MAKE) Test/DocTest-addNonGeneric.dll
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-addNonGeneric.dll
$(MONO) $(PROGRAM) update -o Test/en.actual Test/DocTest-addNonGeneric.dll
# now add a non-generic version of the method and update several times
$(MAKE) Test/DocTest-addNonGeneric-v2.dll
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-addNonGeneric-v2.dll
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-addNonGeneric-v2.dll
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-addNonGeneric-v2.dll
$(MONO) $(PROGRAM) update -o Test/en.actual Test/DocTest-addNonGeneric-v2.dll
$(MONO) $(PROGRAM) update -o Test/en.actual Test/DocTest-addNonGeneric-v2.dll
$(MONO) $(PROGRAM) update -o Test/en.actual Test/DocTest-addNonGeneric-v2.dll
$(DIFF) Test/en.expected-addNonGeneric Test/en.actual
check-monodocer-membergroup: Test/DocTest-addNonGeneric-v2.dll Test/DocTest-addNonGeneric.dll
-rm -Rf Test/en.actual
cp -r Test/en.expected-membergroup Test/en.actual
$(MONO) $(PROGRAM) update --debug --exceptions=all -o Test/en.actual Test/DocTest-addNonGeneric-v2.dll
$(MONO) $(PROGRAM) update --debug -o Test/en.actual Test/DocTest-addNonGeneric-v2.dll
$(DIFF) Test/en.expected-membergroup Test/en.actual
$(MONO) $(PROGRAM) validate -f ecma Test/en.actual
@ -183,7 +312,7 @@ check-monodocer-dropns-classic:
# tests the simplest --dropns case, a single class where the root namespace was dropped.
-rm -Rf Test/en.actual
$(MAKE) Test/DocTest-DropNS-classic.dll
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic.dll --api-style=classic
$(MONO) $(PROGRAM) update -o Test/en.actual Test/DocTest-DropNS-classic.dll --api-style=classic
$(MAKE) update-monodocer-dropns-unified
$(DIFF) Test/en.expected-dropns-classic-v1 Test/en.actual
@ -195,12 +324,12 @@ check-monodocer-dropns-multi:
$(MAKE) Test/DocTest-DropNS-unified-multitest.dll
# mdoc update for both classic and unified
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual $(MULTI-CLASSIC) --api-style=classic
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual $(MULTI-UNIFIED) --api-style=unified --dropns Test/DocTest-DropNS-unified.dll=MyFramework --dropns Test/DocTest-DropNS-unified-multitest.dll=MyFramework
$(MONO) $(PROGRAM) update -o Test/en.actual $(MULTI-CLASSIC) --api-style=classic
$(MONO) $(PROGRAM) update -o Test/en.actual $(MULTI-UNIFIED) --api-style=unified --dropns Test/DocTest-DropNS-unified.dll=MyFramework --dropns Test/DocTest-DropNS-unified-multitest.dll=MyFramework
# now run it again to verify idempotency
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual $(MULTI-CLASSIC) --api-style=classic
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual $(MULTI-UNIFIED) --api-style=unified --dropns Test/DocTest-DropNS-unified.dll=MyFramework --dropns Test/DocTest-DropNS-unified-multitest.dll=MyFramework
$(MONO) $(PROGRAM) update -o Test/en.actual $(MULTI-CLASSIC) --api-style=classic
$(MONO) $(PROGRAM) update -o Test/en.actual $(MULTI-UNIFIED) --api-style=unified --dropns Test/DocTest-DropNS-unified.dll=MyFramework --dropns Test/DocTest-DropNS-unified-multitest.dll=MyFramework
$(DIFF) Test/en.expected-dropns-multi Test/en.actual
@ -213,111 +342,113 @@ check-monodocer-dropns-multi-withexisting:
$(MAKE) Test/DocTest-DropNS-unified-multitest.dll
# mdoc update to show a pre-existing set of documents
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic.dll --api-style=classic
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-unified.dll --api-style=unified --dropns Test/DocTest-DropNS-unified.dll=MyFramework
$(MONO) $(PROGRAM) update -o Test/en.actual Test/DocTest-DropNS-classic.dll --api-style=classic
$(MONO) $(PROGRAM) update -o Test/en.actual Test/DocTest-DropNS-unified.dll --api-style=unified --dropns Test/DocTest-DropNS-unified.dll=MyFramework
# mdoc update for both classic and unified
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual $(MULTI-CLASSIC) --api-style=classic
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual $(MULTI-UNIFIED) --api-style=unified --dropns Test/DocTest-DropNS-unified.dll=MyFramework --dropns Test/DocTest-DropNS-unified-multitest.dll=MyFramework
$(MONO) $(PROGRAM) update -o Test/en.actual $(MULTI-CLASSIC) --api-style=classic
$(MONO) $(PROGRAM) update -o Test/en.actual $(MULTI-UNIFIED) --api-style=unified --dropns Test/DocTest-DropNS-unified.dll=MyFramework --dropns Test/DocTest-DropNS-unified-multitest.dll=MyFramework
$(DIFF) Test/en.expected-dropns-multi-withexisting Test/en.actual
check-monodocer-dropns-delete:
-rm -Rf Test/en.actual
-rm -Rf Test/actual_statistics.txt
rm -Rf Test/DocTest-DropNS-classic-deletetest.dll
rm -Rf Test/DocTest-DropNS-unified-deletetest.dll
$(MAKE) Test/DocTest-DropNS-classic-deletetest.dll
$(MONO) $(PROGRAM) update --delete --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic-deletetest.dll --api-style=classic
$(MONO) $(PROGRAM) update --delete -o Test/en.actual Test/DocTest-DropNS-classic-deletetest.dll --api-style=classic
$(MAKE) Test/DocTest-DropNS-unified-deletetest.dll
$(MONO) $(PROGRAM) update --delete --exceptions=all -o Test/en.actual Test/DocTest-DropNS-unified-deletetest.dll --api-style=unified --dropns Test/DocTest-DropNS-unified-deletetest.dll=MyFramework
$(MONO) $(PROGRAM) update --delete -o Test/en.actual Test/DocTest-DropNS-unified-deletetest.dll --api-style=unified --dropns Test/DocTest-DropNS-unified-deletetest.dll=MyFramework
$(MAKE) Test/DocTest-DropNS-classic-deletetest-V2.dll
$(MONO) $(PROGRAM) update --delete --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic-deletetest.dll --api-style=classic
$(MONO) $(PROGRAM) update --delete -o Test/en.actual Test/DocTest-DropNS-classic-deletetest.dll --api-style=classic
$(MAKE) Test/DocTest-DropNS-unified-deletetest-V2.dll
$(MONO) $(PROGRAM) update --delete --exceptions=all -o Test/en.actual Test/DocTest-DropNS-unified-deletetest.dll --api-style=unified --dropns Test/DocTest-DropNS-unified-deletetest.dll=MyFramework
$(MONO) $(PROGRAM) update --delete -o Test/en.actual Test/DocTest-DropNS-unified-deletetest.dll --api-style=unified --dropns Test/DocTest-DropNS-unified-deletetest.dll=MyFramework -statistics Test/actual_statistics.txt
$(DIFF) Test/en.expected-dropns-delete Test/en.actual
$(DIFF) Test/expected_remove_statistics.txt Test/actual_statistics.txt
check-monodocer-dropns-classic-withsecondary:
# tests case where a secondary assembly is included with a --dropns parameter
-rm -Rf Test/en.actual
$(MAKE) Test/DocTest-DropNS-classic.dll
$(MAKE) Test/DocTest-DropNS-classic-secondary.dll
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic.dll Test/DocTest-DropNS-classic-secondary.dll --api-style=classic
$(MONO) $(PROGRAM) update -o Test/en.actual Test/DocTest-DropNS-classic.dll Test/DocTest-DropNS-classic-secondary.dll --api-style=classic
$(MAKE) update-monodocer-dropns-unified-withsecondary
$(DIFF) Test/en.expected-dropns-classic-withsecondary Test/en.actual
update-monodocer-dropns-unified:
$(MAKE) Test/DocTest-DropNS-unified.dll
$(MONO) $(PROGRAM) update --debug --exceptions=all -o Test/en.actual Test/DocTest-DropNS-unified.dll --api-style=unified --dropns Test/DocTest-DropNS-unified.dll=MyFramework
$(MONO) $(PROGRAM) update --debug -o Test/en.actual Test/DocTest-DropNS-unified.dll --api-style=unified --dropns Test/DocTest-DropNS-unified.dll=MyFramework
update-monodocer-dropns-unified-withsecondary:
$(MAKE) Test/DocTest-DropNS-unified.dll
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-unified.dll Test/DocTest-DropNS-classic-secondary.dll --api-style=unified --dropns Test/DocTest-DropNS-unified.dll=MyFramework
$(MONO) $(PROGRAM) update -o Test/en.actual Test/DocTest-DropNS-unified.dll Test/DocTest-DropNS-classic-secondary.dll --api-style=unified --dropns Test/DocTest-DropNS-unified.dll=MyFramework
update-monodocer-dropns-classic-secondary:
$(MAKE) Test/DocTest-DropNS-classic-secondary.dll
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic-secondary.dll --api-style=classic
$(MONO) $(PROGRAM) update -o Test/en.actual Test/DocTest-DropNS-classic-secondary.dll --api-style=classic
check-monodocer-internal-interface:
# Tests to make sure internal interfaces that are explicitly implemented are not documented
-rm -Rf Test/en.actual
$(MAKE) Test/DocTest-InternalInterface.dll
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-InternalInterface.dll
$(MONO) $(PROGRAM) update -o Test/en.actual Test/DocTest-InternalInterface.dll -lang VB.NET
$(DIFF) Test/en.expected-internal-interface Test/en.actual
check-monodocer-enumerations:
-rm -Rf Test/en.actual
$(MAKE) Test/DocTest-enumerations.dll
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-enumerations.dll
$(MONO) $(PROGRAM) update -o Test/en.actual Test/DocTest-enumerations.dll
$(DIFF) Test/en.expected-enumerations Test/en.actual
check-monodocer-update:
find Test/en.expected -name \*.xml -exec rm "{}" \;
$(MAKE) Test/DocTest.dll-v1
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.expected Test/DocTest.dll
$(MONO) $(PROGRAM) update -o Test/en.expected Test/DocTest.dll -lang docid -lang vb.net -lang fsharp -lang javascript -lang c++/cli -lang c++/cx -lang c++/winrt
check-monodocer:
-rm -Rf Test/en.actual
$(MAKE) Test/DocTest.dll-v1
$(MONO) $(PROGRAM) update --debug --exceptions=all -o Test/en.actual Test/DocTest.dll
$(MONO) $(PROGRAM) update --debug -o Test/en.actual Test/DocTest.dll -lang docid -lang vb.net -lang fsharp -lang javascript -lang c++/cli -lang c++/cx -lang c++/winrt
$(DIFF) Test/en.expected Test/en.actual
$(MONO) $(PROGRAM) update --debug --exceptions=all -o Test/en.actual Test/DocTest.dll
$(MONO) $(PROGRAM) update --debug -o Test/en.actual Test/DocTest.dll -lang docid -lang vb.net -lang fsharp -lang javascript -lang c++/cli -lang c++/cx -lang c++/winrt
$(DIFF) Test/en.expected Test/en.actual
check-monodocer-since-update:
find Test/en.expected.since -name \*.xml -exec rm "{}" \;
$(MAKE) Test/DocTest.dll-v1
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.expected.since Test/DocTest.dll
$(MONO) $(PROGRAM) update -o Test/en.expected.since Test/DocTest.dll
$(MAKE) Test/DocTest.dll-v2
$(MONO) $(PROGRAM) update --exceptions=all --since="Version 2.0" \
$(MONO) $(PROGRAM) update --since="Version 2.0" \
-o Test/en.expected.since Test/DocTest.dll
check-monodocer-since:
rm -Rf Test/en.actual
$(MAKE) Test/DocTest.dll-v1
$(MONO) $(PROGRAM) --debug update --exceptions=all -o Test/en.actual Test/DocTest.dll
$(MONO) $(PROGRAM) --debug update -o Test/en.actual Test/DocTest.dll
$(MAKE) Test/DocTest.dll-v2
$(MONO) $(PROGRAM) --debug update --exceptions=all --since="Version 2.0" \
$(MONO) $(PROGRAM) --debug update --since="Version 2.0" \
-o Test/en.actual Test/DocTest.dll
$(DIFF) Test/en.expected.since Test/en.actual
check-monodocer-delete-update:
find Test/en.expected.delete -type f -exec rm "{}" \;
$(MAKE) Test/DocTest.dll-v1
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.expected.delete Test/DocTest.dll
$(MONO) $(PROGRAM) update -o Test/en.expected.delete Test/DocTest.dll
$(MAKE) Test/DocTest.dll-v2
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.expected.delete Test/DocTest.dll
$(MONO) $(PROGRAM) update -o Test/en.expected.delete Test/DocTest.dll
$(MAKE) Test/DocTest.dll-v1
$(MONO) $(PROGRAM) update -fno-assembly-versions --delete --exceptions=all \
$(MONO) $(PROGRAM) update -fno-assembly-versions --delete \
-o Test/en.expected.delete Test/DocTest.dll
check-monodocer-delete:
rm -Rf Test/en.actual
$(MAKE) Test/DocTest.dll-v1
$(MONO) $(PROGRAM) --debug update --exceptions=all -o Test/en.actual Test/DocTest.dll
$(MONO) $(PROGRAM) --debug update -o Test/en.actual Test/DocTest.dll
$(MAKE) Test/DocTest.dll-v2
$(MONO) $(PROGRAM) --debug update --exceptions=all -o Test/en.actual Test/DocTest.dll
$(MONO) $(PROGRAM) --debug update -o Test/en.actual Test/DocTest.dll
$(MAKE) Test/DocTest.dll-v1
$(MONO) $(PROGRAM) --debug update -fno-assembly-versions --delete --exceptions=all -o Test/en.actual Test/DocTest.dll
$(MONO) $(PROGRAM) --debug update -fno-assembly-versions --delete -o Test/en.actual Test/DocTest.dll
$(DIFF) Test/en.expected.delete Test/en.actual
check-monodocer-ignore-invalid-assemblies: Test/DocTest-addNonGeneric.dll Test/DocTest-addNonGeneric-v2.dll
@ -330,20 +461,30 @@ check-monodocer-ignore-invalid-assemblies: Test/DocTest-addNonGeneric.dll Test/D
check-monodocer-importslashdoc-update:
find Test/en.expected.importslashdoc -name \*.xml -exec rm "{}" \;
$(MAKE) Test/DocTest.dll-v1 TEST_CSCFLAGS=-doc:Test/DocTest.xml
$(MONO) $(PROGRAM) --debug update --exceptions=all -i Test/DocTest.xml \
$(MONO) $(PROGRAM) --debug update -i Test/DocTest.xml \
-o Test/en.expected.importslashdoc Test/DocTest.dll
check-monodocer-importslashdoc:
rm -Rf Test/en.actual
$(MAKE) Test/DocTest.dll-v1 TEST_CSCFLAGS=-doc:Test/DocTest.xml
$(MONO) $(PROGRAM) --debug update --exceptions=all -i Test/DocTest.xml \
$(MONO) $(PROGRAM) --debug update -i Test/DocTest.xml \
-o Test/en.actual Test/DocTest.dll
$(DIFF) Test/en.expected.importslashdoc Test/en.actual
check-multiple-mdoc:
rm -Rf Test/en.actual
$(CSCOMPILE) -debug -optimize -unsafe -target:library Test/DocTest.cs -doc:Test/DocTest.xml
$(MONO) $(PROGRAM) --debug update --exceptions=asm -i Test/DocTest.xml \
-o Test/en.actual Test/DocTest.dll
cp Test/test-multiple-mdoc/Widget.xml Test/en.actual/Mono.DocTest/Widget.xml
$(MONO) $(PROGRAM) --debug update --exceptions=asm -i Test/DocTest.xml \
-o Test/en.actual Test/DocTest.dll
$(DIFF) Test/test-multiple-mdoc/en.expected.test.multiple.mdoc Test/en.actual
check-monodocer-importecmadoc-update:
find Test/en.expected.importecmadoc -name \*.xml -exec rm "{}" \;
$(MAKE) Test/DocTest.dll-v1
$(MONO) $(PROGRAM) --debug update --exceptions=all -i Test/TestEcmaDocs.xml \
$(MONO) $(PROGRAM) --debug update -i Test/TestEcmaDocs.xml \
'--type=System.Action`1' --type=System.AsyncCallback \
--type=System.Environment --type=System.Array \
-o Test/en.expected.importecmadoc Test/DocTest.dll
@ -351,12 +492,172 @@ check-monodocer-importecmadoc-update:
check-monodocer-importecmadoc:
rm -Rf Test/en.actual
$(MAKE) Test/DocTest.dll-v1
$(MONO) $(PROGRAM) --debug update --exceptions=all -i Test/TestEcmaDocs.xml \
$(MONO) $(PROGRAM) --debug update -i Test/TestEcmaDocs.xml \
'--type=System.Action`1' --type=System.AsyncCallback \
--type=System.Environment --type=System.Array \
-o Test/en.actual Test/DocTest.dll
$(DIFF) Test/en.expected.importecmadoc Test/en.actual
.PHONY: check-monodocer-import-fx-work
check-monodocer-import-fx-work: Test/DocTest.dll-v1 Test/DocTest-DropNS-classic-secondary.dll Test/DocTest-DropNS-classic.dll
rm -Rf Test/en.actual
rm -Rf Test/fx-import
rm -Rf Test/actual_statistics.txt
mkdir Test/fx-import
mkdir Test/fx-import/one
mkdir Test/fx-import/two
cp Test/DocTest.dll Test/fx-import/one
cp Test/DocTest-DropNS-classic-secondary.dll Test/fx-import/two
cp Test/DocTest-DropNS-classic.dll Test/fx-import/two
cp Test/DocTest-DropNS-classic-secondary.xml Test/fx-import/TestEcmaDocs2.xml
cp Test/DocTest-DropNS-classic.xml Test/fx-import/DocTest-DropNS-classic.xml
cp Test/DocTest.xml Test/fx-import/TestEcmaDocs.xml
cp Test/CLILibraryTypes.dtd Test/fx-import/
cp Test/fx-import-configuration.xml Test/fx-import/frameworks.xml
$(MONO) $(PROGRAM) update -o Test/en.actual -frameworks Test/fx-import -statistics Test/actual_statistics.txt
$(DIFF) Test/expected_statistics.txt Test/actual_statistics.txt
.PHONY: check-monodocer-fx-statistics-remove
check-monodocer-fx-statistics-remove:
rm -Rf Test/en.actual
rm -Rf Test/fx-import
rm -Rf Test/actual_statistics.txt
mkdir Test/fx-import
mkdir Test/fx-import/one
cp Test/fx-statistics-remove-configuration.xml Test/fx-import/frameworks.xml
rm -Rf Test/DocTest-DropNS-unified-deletetest.dll
$(MAKE) Test/DocTest-DropNS-unified-deletetest.dll
cp Test/DocTest-DropNS-unified-deletetest.dll Test/fx-import/one/DocTest.dll
$(MONO) $(PROGRAM) update -o Test/en.actual -frameworks Test/fx-import
rm -Rf Test/DocTest-DropNS-unified.dll
$(MAKE) Test/DocTest-DropNS-unified.dll
rm -rf Test/fx-import/one/DocTest.dll
cp Test/DocTest-DropNS-unified.dll Test/fx-import/one/DocTest.dll
$(MONO) $(PROGRAM) update -o Test/en.actual -frameworks Test/fx-import -statistics Test/actual_statistics.txt
$(DIFF) Test/expected_fx_remove_statistics.txt Test/actual_statistics.txt
check-monodocer-fsharp:
-rm -Rf Test/en.actual
msbuild ../mdoc/mdoc.Test/mdoc.Test.FSharp/mdoc.Test.FSharp.fsproj -property:Configuration=Release
$(MONO) $(PROGRAM) update -lang fsharp -o Test/en.actual ../mdoc/mdoc.Test/mdoc.Test.FSharp/bin/Release/mdoc.Test.FSharp.dll
$(DIFF) Test/en.expected-fsharp Test/en.actual
check-monodocer-members-implementation:
-rm -Rf Test/en.actual
msbuild ../mdoc/Test/TestInterfaceImplementation/TestInterfaceImplementation.csproj -property:Configuration=Release
$(MONO) $(PROGRAM) update -o Test/en.actual Test/TestInterfaceImplementation/bin/Release/TestInterfaceImplementation.dll
$(DIFF) Test/en.expected.members-implementation Test/en.actual
# ------- Framework Alternate Test(s) -------
.PHONY: Test/FrameworkTestData-frameworkalternate
Test/FrameworkTestData-frameworkalternate: Test/DocTest-frameworkalternate-one.dll Test/DocTest-frameworkalternate-two.dll
rm -rf Test/FrameworkTestData-frameworkalternate
mkdir Test/FrameworkTestData-frameworkalternate
mkdir Test/FrameworkTestData-frameworkalternate/One
mkdir Test/FrameworkTestData-frameworkalternate/Two
mkdir Test/FrameworkTestData-frameworkalternate/Three
cp Test/DocTest-frameworkalternate-one.dll Test/FrameworkTestData-frameworkalternate/One/
cp Test/DocTest-frameworkalternate-two.dll Test/FrameworkTestData-frameworkalternate/Two/
cp Test/DocTest-frameworkalternate-one.dll Test/FrameworkTestData-frameworkalternate/Three/
$(MONO) $(PROGRAM) fx-bootstrap Test/FrameworkTestData-frameworkalternate
.PHONY: Test/FrameworkTestData-frameworkalternate-fromold
Test/FrameworkTestData-frameworkalternate-fromold: Test/DocTest-frameworkalternate-one.dll Test/DocTest-frameworkalternate-two.dll
rm -rf Test/FrameworkTestData-frameworkalternate-fromold
mkdir Test/FrameworkTestData-frameworkalternate-fromold
mkdir Test/FrameworkTestData-frameworkalternate-fromold/One
mkdir Test/FrameworkTestData-frameworkalternate-fromold/Two
mkdir Test/FrameworkTestData-frameworkalternate-fromold/Three
cp Test/DocTest-frameworkalternate-one.dll Test/FrameworkTestData-frameworkalternate-fromold/One/
cp Test/DocTest-frameworkalternate-two.dll Test/FrameworkTestData-frameworkalternate-fromold/Two/
cp Test/DocTest-frameworkalternate-one.dll Test/FrameworkTestData-frameworkalternate-fromold/Three/
$(MONO) $(PROGRAM) fx-bootstrap Test/FrameworkTestData-frameworkalternate-fromold
Test/DocTest-frameworkalternate-one.dll:
$(CSCOMPILE) $(TEST_CSCFLAGS) -debug -target:library -out:$@ Test/DocTest-frameworkalternate.cs /define:FXONE
Test/DocTest-frameworkalternate-two.dll:
$(CSCOMPILE) $(TEST_CSCFLAGS) -debug -target:library -out:$@ Test/DocTest-frameworkalternate.cs /define:FXTWO
.PHONY: check-monodocer-frameworkalternate
check-monodocer-frameworkalternate: Test/FrameworkTestData-frameworkalternate
-rm -Rf Test/en.actual
# Run Test
echo "First run"
$(MONO) $(PROGRAM) update -o Test/en.actual -frameworks Test/FrameworkTestData-frameworkalternate
$(DIFF) Test/en.expected-frameworkalternate Test/en.actual
# run test again to make sure subsequent runs maintain data
echo "Second run"
$(MONO) $(PROGRAM) update -o Test/en.actual -frameworks Test/FrameworkTestData-frameworkalternate
$(DIFF) Test/en.expected-frameworkalternate Test/en.actual
# Test Future FX Alignment ...
echo "compile new version of 'two' that looks like 'one'"
rm Test/DocTest-frameworkalternate-two.dll
$(CSCOMPILE) $(TEST_CSCFLAGS) -debug -target:library -out:Test/DocTest-frameworkalternate-two.dll Test/DocTest-frameworkalternate.cs /define:FXONE
yes | cp Test/DocTest-frameworkalternate-two.dll Test/FrameworkTestData-frameworkalternate/Two/DocTest-frameworkalternate-two.dll
# mdoc update fxmode again
$(MONO) $(PROGRAM) update -o Test/en.actual -frameworks Test/FrameworkTestData-frameworkalternate
# diff against aligned but with FrameworkAlternate="one;two;three"
$(DIFF) Test/en.expected-frameworkalternate-aligned Test/en.actual
.PHONY: check-monodocer-frameworkalternate-fromold
check-monodocer-frameworkalternate-fromold: Test/FrameworkTestData-frameworkalternate-fromold
-rm -Rf Test/en.actual
# synchronize all frameworks
yes | cp Test/DocTest-frameworkalternate-one.dll Test/FrameworkTestData-frameworkalternate-fromold/Two/DocTest-frameworkalternate-two.dll
$(MONO) $(PROGRAM) update -o Test/en.actual -frameworks Test/FrameworkTestData-frameworkalternate-fromold
yes | cp Test/DocTest-frameworkalternate-two.dll Test/FrameworkTestData-frameworkalternate-fromold/Two/DocTest-frameworkalternate-two.dll
$(MONO) $(PROGRAM) update -o Test/en.actual -frameworks Test/FrameworkTestData-frameworkalternate-fromold
$(DIFF) Test/en.expected-frameworkalternate Test/en.actual
# ------- Framework Alternate Test(s) -------
.PHONY: check-monodocer-import-fx
check-monodocer-import-fx: check-monodocer-import-fx-work
$(DIFF) Test/en.expected-fx-import Test/en.actual
.PHONY: check-monodocer-import-fx-update
check-monodocer-import-fx-update: check-monodocer-import-fx-work
rm -Rf Test/en.expected-fx-import
mv Test/en.actual Test/en.expected-fx-import
check-monodocer-attached-entities:
-rm -Rf Test/en.actual
msbuild ../mdoc/Test/AttachedEventsAndProperties/AttachedEventsAndProperties.csproj -property:Configuration=Release
$(MONO) $(PROGRAM) update --debug -o Test/en.actual Test/AttachedEventsAndProperties/bin/Release/AttachedEventsAndProperties.dll -lang docid -lang vb.net -lang fsharp -lang javascript -lang c++/cli -lang c++/cx -lang c++/winrt
$(DIFF) Test/en.expected-attached-entities Test/en.actual
# now make sure it will delete a previously run/duplicated attachedproperty/property
cp Test/AttachedEventsAndProperties/AttachedPropertyExample.xml Test/en.actual/AttachedEventsAndProperties/
$(MONO) $(PROGRAM) update -o Test/en.actual Test/AttachedEventsAndProperties/bin/Release/AttachedEventsAndProperties.dll -lang docid -lang vb.net -lang fsharp -lang javascript -lang c++/cli -lang c++/cx -lang c++/winrt
$(DIFF) Test/en.expected-attached-entities Test/en.actual
Test/TestClass.dll:
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ mdoc.Test/SampleClasses/Test*.cs
.PHONY: check-monodocer-operators-work
check-monodocer-operators-work: Test/TestClass.dll
rm -Rf Test/en.actual
$(MONO) $(PROGRAM) update Test/TestClass.dll -o Test/en.actual
cp mdoc.Test/SampleClasses/TestClass-OldOpSig.xml Test/en.actual/mdoc.Test.SampleClasses/TestClass.xml
$(MONO) $(PROGRAM) update Test/TestClass.dll -o Test/en.actual
.PHONY: check-monodocer-operators
check-monodocer-operators: check-monodocer-operators-work
$(DIFF) Test/en.expected-operators Test/en.actual
.PHONY: check-monodocer-operators-update
check-monodocer-operators-update: check-monodocer-operators-work
rm -Rf Test/en.expected-operators
mv Test/en.actual Test/en.expected-operators
check-mdoc-export-html-update:
find Test/html.expected -name \*.html -exec rm "{}" \;
$(MONO) $(PROGRAM) export-html -o Test/html.expected \
@ -396,7 +697,7 @@ check-mdoc-export-msxdoc-update:
check-mdoc-export-msxdoc:
$(MONO) $(PROGRAM) export-msxdoc -o - Test/en.expected.importslashdoc \
| $(DIFF_QUIET) - Test/msxdoc-expected.importslashdoc.xml
| $(DIFF) - Test/msxdoc-expected.importslashdoc.xml
my_abs_top_srcdir = $(shell cd . && pwd)
@ -421,14 +722,35 @@ check-mdoc-validate:
$(MONO) $(PROGRAM) validate -f ecma Test/en.expected.since 2>&1 | \
sed 's#file://$(my_abs_top_srcdir)/##g' | \
$(DIFF_QUIET) - Test/validate.check.monodocer.since
check-overwrite-attribute:
rm -Rf Test/en.actual
$(CSCOMPILE) $(TEST_CSCFLAGS) -target:library Test/test-overwrite-attribute/SomeClass.cs -doc:Test/test-overwrite-attribute/SomeClass.xml
$(MONO) $(PROGRAM) update Test/test-overwrite-attribute/SomeClass.dll -o Test/en.actual/ -import Test/test-overwrite-attribute/SomeClass.xml
cp Test/test-overwrite-attribute/Input_SomeClass.xml Test/en.actual/SomeClass.xml
$(MONO) $(PROGRAM) update Test/test-overwrite-attribute/SomeClass.dll -o Test/en.actual/ -import Test/test-overwrite-attribute/SomeClass.xml
$(DIFF) Test/test-overwrite-attribute/Expected_SomeClass.xml Test/en.actual/SomeClass.xml
check-ignored-namespace-generic:
rm -Rf Test/en.actual
-rm -f Test/test-generic-ignored-namespace/ReadOnlySpan.dll
$(CSCOMPILE) $(TEST_CSCFLAGS) -target:library Test/test-generic-ignored-namespace/ReadOnlySpan.cs
$(MONO) $(PROGRAM) update Test/test-generic-ignored-namespace/ReadOnlySpan.dll -o Test/en.actual/
$(DIFF) Test/test-generic-ignored-namespace/en.expected-generic-ignored-namespace Test/en.actual/
run-test-local: check-doc-tools
run-test-update : check-doc-tools-update
check-doc-tools: check-monodocer-since \
check-doc-tools: \
check-monodocer-typeForwards \
check-monodocer-Eii-importslashdoc \
check-monodocer-Eii-importecmadoc-oldNames \
check-monodocer-Eii \
check-monodocer-since \
check-monodocer-importecmadoc \
check-monodocer-importslashdoc \
check-monodocer-import-fx \
check-monodocer \
check-monodocer-delete \
check-mdoc-export-html \
@ -438,7 +760,6 @@ check-doc-tools: check-monodocer-since \
check-mdoc-validate \
check-monodocer-dropns-classic \
check-monodocer-dropns-classic-withsecondary \
check-monodocer-dropns-delete \
check-monodocer-internal-interface \
check-monodocer-addNonGeneric \
check-monodocer-membergroup \
@ -448,8 +769,30 @@ check-doc-tools: check-monodocer-since \
check-monodocer-dropns-multi-withexisting \
check-monodocer-frameworks \
check-monodocer-frameworks-inheritance \
check-monodocer-docid
check-monodocer-docid \
check-monodocer-operators \
check-monodocer-fx-statistics-remove \
check-overwrite-attribute \
check-monodocer-vbnet \
check-monodocer-vbnet2 \
check-monodocer-javascript \
check-monodocer-frameworks-with-nuget\
check-monodocer-fsharp \
check-monodocer-attached-entities \
check-monodocer-members-implementation \
check-monodocer-cppcli \
check-monodocer-cppcxDocTest\
check-monodocer-cppcx\
check-monodocer-cppwinrtDocTest\
check-monodocer-cppwinrt\
check-monodocer-cppwinrtUwp\
check-monodocer-frameworkalternate-fromold \
check-monodocer-frameworkalternate \
check-monodocer-embedded-type \
check-ignored-namespace-generic \
check-multiple-mdoc \
#check-monodocer-dropns-delete
check-doc-tools-update: check-monodocer-since-update \
check-monodocer-importecmadoc-update \
check-monodocer-importslashdoc-update \
@ -459,5 +802,5 @@ check-doc-tools-update: check-monodocer-since-update \
check-mdoc-export-msxdoc-update \
check-mdoc-validate-update
check: check-doc-tools
check: nunit check-doc-tools
@echo "mdoc Tests Complete!"

View File

@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Xml;
using System.Xml.Linq;
namespace Mono.Documentation.Framework
{
public static class FrameworkIndexHelper
{
public static Dictionary<string, FrameworkNamespaceModel> CreateFrameworkIndex(string path, string frameworkName)
{
string frameworkFilePath = GetFrameworkFilePath(path, frameworkName);
if (!File.Exists(frameworkFilePath))
{
throw new ArgumentException($"Can't find framework file: {frameworkFilePath}");
}
using (XmlReader xmlReader = XmlReader.Create(frameworkFilePath))
{
return ReadFrameworkIndex(xmlReader);
}
}
public static Dictionary<string, FrameworkNamespaceModel> ReadFrameworkIndex(XmlReader xmlReader)
{
var dict = new Dictionary<string, FrameworkNamespaceModel>();
xmlReader.ReadToFollowing("Framework");
xmlReader.ReadToDescendant("Namespace");
while (xmlReader.NodeType != XmlNodeType.EndElement)
{
XNode node = XNode.ReadFrom(xmlReader);
XElement element = node as XElement;
if (element == null) continue;
var ns = new FrameworkNamespaceModel(node);
dict.Add(ns.Name, ns);
}
return dict;
}
private static string GetFrameworkFilePath(string path, string frameworkName)
{
string docsRoot = Path.GetDirectoryName(path) ?? "";
string frameworksIndexPath = Path.Combine(docsRoot, Consts.FrameworksIndexFolderName);
foreach (string frameworkIndexFilePath in Directory.EnumerateFiles(frameworksIndexPath))
{
using (XmlReader xmlReader = XmlReader.Create(frameworkIndexFilePath))
{
bool isFrameworkNodeFound = xmlReader.ReadToFollowing("Framework");
if (!isFrameworkNodeFound)
{
throw new InvalidOperationException($"Invalid framework file format in {frameworkIndexFilePath}");
}
var frameworkNameInFile = xmlReader.GetAttribute("Name");
if (frameworkNameInFile == frameworkName)
{
return frameworkIndexFilePath;
}
}
}
throw new InvalidEnumArgumentException($"Can't find file for frameworkName = {frameworkName}");
}
}
}

View File

@ -0,0 +1,23 @@
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
namespace Mono.Documentation.Framework
{
public class FrameworkNamespaceModel
{
public string Name { get; }
public List<FrameworkTypeModel> Types { get; } = new List<FrameworkTypeModel>();
public FrameworkNamespaceModel(XNode node)
{
var element = node as XElement;
Name = element.Attributes(XName.Get("Name")).First().Value;
var children = element.Elements();
foreach (XElement rawType in children)
{
Types.Add(new FrameworkTypeModel(rawType));
}
}
}
}

View File

@ -0,0 +1,25 @@
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
namespace Mono.Documentation.Framework
{
public class FrameworkTypeModel
{
public string Name { get; }
public string Id { get; }
public List<string> Members { get; } = new List<string>();
public FrameworkTypeModel(XElement element)
{
Name = element.Attributes(XName.Get("Name")).First().Value;
Id = element.Attributes(XName.Get("Id")).First().Value;
var children = element.Elements();
foreach (XElement rawMember in children)
{
Members.Add(rawMember.Attributes(XName.Get("Id")).First().Value);
}
}
}
}

View File

@ -1,85 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Mono.Cecil;
namespace Mono.Documentation
{
/// <summary>
/// Represents a set of assemblies that we want to document
/// </summary>
class AssemblySet : IDisposable
{
readonly DefaultAssemblyResolver resolver = new DefaultAssemblyResolver ();
HashSet<string> assemblyPaths = new HashSet<string> ();
HashSet<string> assemblySearchPaths = new HashSet<string> ();
HashSet<string> forwardedTypes = new HashSet<string> ();
public AssemblySet (string path) : this (new string[] { path }) { }
public AssemblySet (IEnumerable<string> paths) : this ("Default", paths, new string[0]) { }
public AssemblySet (string name, IEnumerable<string> paths, IEnumerable<string> resolverSearchPaths)
{
Name = name;
foreach (var path in paths)
assemblyPaths.Add (path);
// add default search paths
var assemblyDirectories = paths
.Where (p => p.Contains (Path.DirectorySeparatorChar))
.Select (p => Path.GetDirectoryName (p));
foreach (var searchPath in resolverSearchPaths.Union(assemblyDirectories))
assemblySearchPaths.Add (searchPath);
char oppositeSeparator = Path.DirectorySeparatorChar == '/' ? '\\' : '/';
Func<string, string> sanitize = p =>
p.Replace (oppositeSeparator, Path.DirectorySeparatorChar);
foreach (var searchPath in assemblySearchPaths.Select(sanitize))
resolver.AddSearchDirectory (searchPath);
}
public string Name { get; private set; }
public IEnumerable<AssemblyDefinition> Assemblies { get { return this.LoadAllAssemblies ().Where(a => a != null); } }
public IEnumerable<string> AssemblyPaths { get { return this.assemblyPaths; } }
/// <returns><c>true</c>, if in set was contained in the set of assemblies, <c>false</c> otherwise.</returns>
/// <param name="name">An assembly file name</param>
public bool Contains (string name)
{
return assemblyPaths.Any (p => Path.GetFileName (p) == name);
}
/// <summary>Tells whether an already enumerated AssemblyDefinition, contains the type.</summary>
/// <param name="name">Type name</param>
public bool ContainsForwardedType (string name)
{
return forwardedTypes.Contains (name);
}
public void Dispose () => resolver.Dispose ();
public override string ToString ()
{
return string.Format ("[AssemblySet: Name={0}, Assemblies={1}]", Name, assemblyPaths.Count);
}
IEnumerable<AssemblyDefinition> LoadAllAssemblies ()
{
foreach (var path in this.assemblyPaths) {
var assembly = MDocUpdater.Instance.LoadAssembly (path, this.resolver);
if (assembly != null) {
foreach (var type in assembly.MainModule.ExportedTypes.Where (t => t.IsForwarder).Select (t => t.FullName))
forwardedTypes.Add (type);
}
yield return assembly;
}
}
}
}

View File

@ -1,50 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Mono.Cecil;
using Mono.Cecil.Rocks;
namespace Mono.Documentation
{
class FrameworkEntry
{
SortedSet<FrameworkTypeEntry> types = new SortedSet<FrameworkTypeEntry> ();
List<FrameworkEntry> allframeworks;
public FrameworkEntry (List<FrameworkEntry> frameworks)
{
allframeworks = frameworks;
if (allframeworks == null)
allframeworks = new List<FrameworkEntry> (0);
}
public string Name { get; set; }
public ISet<FrameworkTypeEntry> Types { get { return this.types; } }
public IEnumerable<FrameworkEntry> Frameworks { get { return this.allframeworks; } }
public static readonly FrameworkEntry Empty = new EmptyFrameworkEntry () { Name = "Empty" };
public virtual FrameworkTypeEntry ProcessType (TypeDefinition type)
{
var entry = types.FirstOrDefault (t => t.Name.Equals (type.FullName));
if (entry == null) {
var docid = DocCommentId.GetDocCommentId (type);
entry = new FrameworkTypeEntry (this) { Id = docid, Name = type.FullName, Namespace = type.Namespace };
types.Add (entry);
}
return entry;
}
public override string ToString () => this.Name;
class EmptyFrameworkEntry : FrameworkEntry
{
public EmptyFrameworkEntry () : base (null) { }
public override FrameworkTypeEntry ProcessType (TypeDefinition type) { return FrameworkTypeEntry.Empty; }
}
}
}

View File

@ -1,89 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
using Mono.Cecil;
namespace Mono.Documentation
{
class FrameworkIndex
{
List<FrameworkEntry> frameworks = new List<FrameworkEntry> ();
string path;
public FrameworkIndex (string pathToFrameworks)
{
path = pathToFrameworks;
}
public IList<FrameworkEntry> Frameworks {
get {
return this.frameworks;
}
}
public FrameworkEntry StartProcessingAssembly (AssemblyDefinition assembly)
{
if (string.IsNullOrWhiteSpace (this.path))
return FrameworkEntry.Empty;
string assemblyPath = assembly.MainModule.FileName;
string relativePath = assemblyPath.Replace (this.path, string.Empty);
string shortPath = Path.GetDirectoryName (relativePath);
if (shortPath.StartsWith (Path.DirectorySeparatorChar.ToString (), StringComparison.InvariantCultureIgnoreCase))
shortPath = shortPath.Substring (1, shortPath.Length - 1);
var entry = frameworks.FirstOrDefault (f => f.Name.Equals (shortPath));
if (entry == null) {
entry = new FrameworkEntry (frameworks) { Name = shortPath };
frameworks.Add (entry);
}
return entry;
}
/// <summary>Writes the framework indices to disk.</summary>
/// <param name="path">The folder where one file for every FrameworkEntry will be written.</param>
public void WriteToDisk (string path)
{
if (string.IsNullOrWhiteSpace (this.path))
return;
string outputPath = Path.Combine (path, "FrameworksIndex");
if (!Directory.Exists (outputPath))
Directory.CreateDirectory (outputPath);
foreach (var fx in this.frameworks) {
XDocument doc = new XDocument (
new XElement("Framework",
new XAttribute ("Name", fx.Name),
fx.Types
.GroupBy(t => t.Namespace)
.Select(g => new XElement("Namespace",
new XAttribute("Name", g.Key),
g.Select (t => new XElement ("Type",
new XAttribute ("Name", t.Name),
new XAttribute("Id", t.Id),
t.Members.Select (m =>
new XElement ("Member",
new XAttribute ("Id", m)))))))));
// now save the document
string filePath = Path.Combine (outputPath, fx.Name + ".xml");
if (File.Exists (filePath))
File.Delete (filePath);
var settings = new XmlWriterSettings { Indent = true };
using (var writer = XmlWriter.Create (filePath, settings)) {
doc.WriteTo (writer);
}
}
}
}
}

View File

@ -1,80 +0,0 @@
using System;
using System.Collections.Generic;
using Mono.Cecil;
using Mono.Cecil.Rocks;
namespace Mono.Documentation
{
class FrameworkTypeEntry : IComparable<FrameworkTypeEntry>
{
SortedSet<string> members = new SortedSet<string> ();
SortedSet<string> memberscsharpsig = new SortedSet<string> ();
ILFullMemberFormatter formatter = new ILFullMemberFormatter ();
FrameworkEntry fx;
public static FrameworkTypeEntry Empty = new EmptyTypeEntry (FrameworkEntry.Empty) { Name = "Empty" };
public FrameworkTypeEntry (FrameworkEntry fx)
{
this.fx = fx;
}
public string Id { get; set; }
public string Name { get; set; }
public string Namespace { get; set; }
public FrameworkEntry Framework { get { return fx; } }
public ISet<string> Members {
get {
return this.members;
}
}
public virtual void ProcessMember (MemberReference member)
{
var resolvedMember = member.Resolve ();
if (resolvedMember != null) {
var docid = DocCommentId.GetDocCommentId (resolvedMember);
members.Add (docid);
}
else
members.Add (member.FullName);
// this is for lookup purposes
try {
memberscsharpsig.Add(formatter.GetDeclaration(member));
}
catch {}
}
public bool ContainsCSharpSig (string sig)
{
return memberscsharpsig.Contains (sig);
}
public override string ToString () => $"{this.Name} in {this.fx.Name}";
public int CompareTo (FrameworkTypeEntry other)
{
if (other == null) return -1;
if (this.Name == null) return 1;
return string.Compare (this.Name, other.Name, StringComparison.CurrentCulture);
}
public override bool Equals (object obj)
{
FrameworkTypeEntry other = obj as FrameworkTypeEntry;
if (other == null) return false;
return this.Name.Equals (other.Name);
}
class EmptyTypeEntry : FrameworkTypeEntry
{
public EmptyTypeEntry (FrameworkEntry fx) : base (fx) { }
public override void ProcessMember (MemberReference member) { }
}
}
}

View File

@ -0,0 +1,46 @@
using System;
using System.Runtime.Serialization;
namespace Mono.Documentation
{
[Serializable]
internal class MDocException : Exception
{
public MDocException()
{
}
public MDocException(string message) : base(message)
{
}
public MDocException(string message, Exception innerException) : base(message, innerException)
{
}
protected MDocException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
[Serializable]
internal class MDocAssemblyException : Exception
{
public string AssemblyName { get; set; }
public MDocAssemblyException(string assemblyName, string message) : base(message)
{
this.AssemblyName = assemblyName;
}
public MDocAssemblyException(string assemblyName, string message, Exception innerException) : base(message, innerException)
{
this.AssemblyName = assemblyName;
}
protected MDocAssemblyException(string assemblyName, SerializationInfo info, StreamingContext context) : base(info, context)
{
this.AssemblyName = assemblyName;
}
}
}

View File

@ -0,0 +1 @@
31df07b0ecd44b6f17de5743fa17e8c2bb96fe78

View File

@ -0,0 +1,156 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Xml;
using System.Xml.Schema;
using Mono.Options;
namespace Mono.Documentation
{
public class MDocValidator : MDocCommand
{
XmlReaderSettings settings;
long errors = 0;
public override void Run (IEnumerable<string> args)
{
string[] validFormats = {
"ecma",
};
string format = "ecma";
var p = new OptionSet () {
{ "f|format=",
"The documentation {0:FORMAT} used within PATHS. " +
"Valid formats include:\n " +
string.Join ("\n ", validFormats) + "\n" +
"If no format provided, `ecma' is used.",
v => format = v },
};
List<string> files = Parse (p, args, "validate",
"[OPTIONS]+ PATHS",
"Validate PATHS against the specified format schema.");
if (files == null)
return;
if (Array.IndexOf (validFormats, format) < 0)
Error ("Invalid documentation format: {0}.", format);
Run (format, files);
}
public void Run (string format, IEnumerable<string> files)
{
InitializeSchema (format);
// skip args[0] because it is the provider name
foreach (string arg in files)
{
if (IsMonodocFile (arg))
ValidateFile (arg);
if (Directory.Exists (arg))
{
RecurseDirectory (arg);
}
}
Message (errors == 0 ? TraceLevel.Info : TraceLevel.Error,
"Total validation errors: {0}", errors);
}
public void InitializeSchema (string format, ValidationEventHandler extraHandler = null)
{
Stream s = null;
switch (format)
{
case "ecma":
s = Assembly.GetExecutingAssembly ().GetManifestResourceStream ("monodoc-ecma.xsd");
break;
default:
throw new NotSupportedException (string.Format ("The format `{0}' is not suppoted.", format));
}
if (s == null)
throw new NotSupportedException (string.Format ("The schema for `{0}' was not found.", format));
settings = new XmlReaderSettings ();
settings.Schemas.Add (XmlSchema.Read (s, null));
settings.Schemas.Compile ();
settings.ValidationType = ValidationType.Schema;
settings.ValidationEventHandler += OnValidationEvent;
if (extraHandler != null)
settings.ValidationEventHandler += extraHandler;
}
public void ValidateFile (string file)
{
if (settings == null) InitializeSchema ("ecma");
try
{
using (var reader = XmlReader.Create (new XmlTextReader (file), settings))
{
while (reader.Read ())
{
// do nothing
}
}
}
catch (Exception e)
{
Message (TraceLevel.Error, "mdoc: {0}", e.ToString ());
}
}
public void ValidateFile (TextReader textReader)
{
if (settings == null) InitializeSchema ("ecma");
try
{
using (var xmlReader = XmlReader.Create (textReader, settings))
while (xmlReader.Read ()) {}
}
catch (Exception e)
{
Message (TraceLevel.Error, "mdoc: {0}", e.ToString ());
}
}
void RecurseDirectory (string dir)
{
string[] files = Directory.GetFiles (dir, "*.xml");
foreach (string f in files)
{
if (IsMonodocFile (f))
ValidateFile (f);
}
string[] dirs = Directory.GetDirectories (dir);
foreach (string d in dirs)
RecurseDirectory (d);
}
void OnValidationEvent (object sender, ValidationEventArgs a)
{
errors++;
Message (TraceLevel.Error, "mdoc: {0}", a.Message);
}
static bool IsMonodocFile (string file)
{
var dpath = Path.GetDirectoryName (file);
var dname = Path.GetFileName (dpath);
if (File.Exists (file) && Path.GetExtension (file).ToLower () == ".xml" && !dname.Equals(Consts.FrameworksIndex))
return true;
else
return false;
}
}
}

View File

@ -52,7 +52,7 @@ namespace Mono.Documentation {
}
if (move) {
File.Delete (file);
DeleteFile (file);
File.Move (temp, file);
}
}
@ -62,6 +62,26 @@ namespace Mono.Documentation {
}
}
public static void DeleteFile (string fileToDelete, int retries = 10)
{
var startRetries = retries;
var fi = new FileInfo(fileToDelete);
if (fi.Exists) {
fi.Delete ();
fi.Refresh ();
while (fi.Exists && retries-- > 0) {
System.Threading.Thread.Sleep (100);
fi.Refresh ();
}
fi.Refresh ();
if (fi.Exists)
throw new IOException ($"Unable to delete file '{fileToDelete}' after {startRetries} attempts.");
}
}
static bool FileContentsIdentical (Stream a, Stream b)
{
byte[] ba = new byte[4096];

View File

@ -0,0 +1,680 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using Mono.Cecil;
using Mono.Collections.Generic;
using Mono.Documentation.Util;
namespace Mono.Documentation.Updater
{
public static class DocUtils
{
public static bool DoesNotHaveApiStyle (this XmlElement element, ApiStyle style)
{
string styleString = style.ToString ().ToLowerInvariant ();
string apistylevalue = element.GetAttribute ("apistyle");
return apistylevalue != styleString || string.IsNullOrWhiteSpace (apistylevalue);
}
public static bool HasApiStyle (this XmlElement element, ApiStyle style)
{
string styleString = style.ToString ().ToLowerInvariant ();
return element.GetAttribute ("apistyle") == styleString;
}
public static bool HasApiStyle (this XmlNode node, ApiStyle style)
{
var attribute = node.Attributes["apistyle"];
return attribute != null && attribute.Value == style.ToString ().ToLowerInvariant ();
}
public static void AddApiStyle (this XmlElement element, ApiStyle style)
{
string styleString = style.ToString ().ToLowerInvariant ();
var existingValue = element.GetAttribute ("apistyle");
if (string.IsNullOrWhiteSpace (existingValue) || existingValue != styleString)
{
element.SetAttribute ("apistyle", styleString);
}
// Propagate the API style up to the membernode if necessary
if (element.LocalName == "AssemblyInfo" && element.ParentNode != null && element.ParentNode.LocalName == "Member")
{
var member = element.ParentNode;
var unifiedAssemblyNode = member.SelectSingleNode ("AssemblyInfo[@apistyle='unified']");
var classicAssemblyNode = member.SelectSingleNode ("AssemblyInfo[not(@apistyle) or @apistyle='classic']");
var parentAttribute = element.ParentNode.Attributes["apistyle"];
Action removeStyle = () => element.ParentNode.Attributes.Remove (parentAttribute);
Action propagateStyle = () =>
{
if (parentAttribute == null)
{
// if it doesn't have the attribute, then add it
parentAttribute = element.OwnerDocument.CreateAttribute ("apistyle");
parentAttribute.Value = styleString;
element.ParentNode.Attributes.Append (parentAttribute);
}
};
if ((style == ApiStyle.Classic && unifiedAssemblyNode != null) || (style == ApiStyle.Unified && classicAssemblyNode != null))
removeStyle ();
else
propagateStyle ();
}
}
public static string GetFormattedTypeName(string name)
{
int index = name.IndexOf("`", StringComparison.Ordinal);
if (index >= 0)
return name.Substring(0, index);
return name;
}
public static void AddApiStyle (this XmlNode node, ApiStyle style)
{
string styleString = style.ToString ().ToLowerInvariant ();
var existingAttribute = node.Attributes["apistyle"];
if (existingAttribute == null)
{
existingAttribute = node.OwnerDocument.CreateAttribute ("apistyle");
node.Attributes.Append (existingAttribute);
}
existingAttribute.Value = styleString;
}
public static void RemoveApiStyle (this XmlElement element, ApiStyle style)
{
string styleString = style.ToString ().ToLowerInvariant ();
string existingValue = element.GetAttribute ("apistyle");
if (string.IsNullOrWhiteSpace (existingValue) || existingValue == styleString)
{
element.RemoveAttribute ("apistyle");
}
}
public static void RemoveApiStyle (this XmlNode node, ApiStyle style)
{
var styleAttribute = node.Attributes["apistyle"];
if (styleAttribute != null && styleAttribute.Value == style.ToString ().ToLowerInvariant ())
{
node.Attributes.Remove (styleAttribute);
}
}
public static IEnumerable<T> SafeCast<T> (this System.Collections.IEnumerable list)
{
if (list == null) yield break;
foreach (object item in list)
{
if (item is T castedItem)
{
yield return castedItem;
}
}
}
public static bool IsExplicitlyImplemented (MethodDefinition method)
{
return method != null && method.IsPrivate && method.IsFinal && method.IsVirtual;
}
public static string GetTypeDotMember (string name)
{
int startType, startMethod;
startType = startMethod = -1;
for (int i = 0; i < name.Length; ++i)
{
if (name[i] == '.')
{
startType = startMethod;
startMethod = i;
}
}
return name.Substring (startType + 1);
}
public static string GetMember(string name)
{
int i = name.LastIndexOf('.');
var memberName = i == -1 ? name : name.Substring(i + 1);
return memberName;
}
public static string GetMemberForProperty(string name)
{
int i = name.LastIndexOf('.');
var memberName = i == -1 ? name : name.Substring(i + 1);
if (memberName.StartsWith("get_") || memberName.StartsWith("set_") || memberName.StartsWith("put_"))
{
var index = memberName.IndexOf("_", StringComparison.InvariantCulture);
if (index > 0)
//remove get/set prefix from method name
memberName = memberName.Substring(index + 1);
}
return memberName;
}
public static void GetInfoForExplicitlyImplementedMethod (
MethodDefinition method, out TypeReference iface, out MethodReference ifaceMethod)
{
iface = null;
ifaceMethod = null;
if (method.Overrides.Count != 1)
throw new InvalidOperationException ("Could not determine interface type for explicitly-implemented interface member " + method.Name);
iface = method.Overrides[0].DeclaringType;
ifaceMethod = method.Overrides[0];
}
public static bool IsPublic (TypeDefinition type)
{
TypeDefinition decl = type;
while (decl != null)
{
if (!(decl.IsPublic || decl.IsNestedPublic ||
decl.IsNestedFamily || decl.IsNestedFamily || decl.IsNestedFamilyOrAssembly))
{
return false;
}
decl = (TypeDefinition)decl.DeclaringType;
}
return true;
}
public static string GetPropertyName (PropertyDefinition pi, string delimeter = ".")
{
// Issue: (g)mcs-generated assemblies that explicitly implement
// properties don't specify the full namespace, just the
// TypeName.Property; .NET uses Full.Namespace.TypeName.Property.
MethodDefinition method = pi.GetMethod ?? pi.SetMethod;
bool isExplicitlyImplemented = IsExplicitlyImplemented(method);
if (!isExplicitlyImplemented)
return pi.Name;
// Need to determine appropriate namespace for this member.
GetInfoForExplicitlyImplementedMethod (method, out var iface, out var ifaceMethod);
var stringifyIface = DocTypeFullMemberFormatter.Default.GetName(iface).Replace(".", delimeter);
return string.Join (delimeter, new string[]{
stringifyIface,
GetMemberForProperty (ifaceMethod.Name)});
}
public static string GetNamespace (TypeReference type, string delimeter = null)
{
if (type == null)
return string.Empty;
if (type.GetElementType ().IsNested)
type = type.GetElementType ();
while (type != null && type.IsNested && !type.IsGenericParameter)
type = type.DeclaringType;
if (type == null)
return string.Empty;
string typeNS = type.Namespace;
if (!string.IsNullOrEmpty(delimeter))
{
typeNS = typeNS.Replace(".", delimeter);
}
// first, make sure this isn't a type reference to another assembly/module
bool isInAssembly = MDocUpdater.IsInAssemblies (type.Module.Name);
if (isInAssembly && !typeNS.StartsWith ("System") && MDocUpdater.HasDroppedNamespace (type))
{
typeNS = string.Format ("{0}{1}{2}", MDocUpdater.droppedNamespace, delimeter ?? ".", typeNS);
}
return typeNS;
}
public static string PathCombine (string dir, string path)
{
if (dir == null)
dir = "";
if (path == null)
path = "";
return Path.Combine (dir, path);
}
public static bool IsExtensionMethod (MethodDefinition method)
{
return
method.CustomAttributes
.Any (m => m.AttributeType.FullName == "System.Runtime.CompilerServices.ExtensionAttribute")
&& method.DeclaringType.CustomAttributes
.Any (m => m.AttributeType.FullName == "System.Runtime.CompilerServices.ExtensionAttribute");
}
public static bool IsDelegate (TypeDefinition type)
{
TypeReference baseRef = type.BaseType;
if (baseRef == null)
return false;
return !type.IsAbstract && baseRef.FullName == "System.Delegate" || // FIXME
baseRef.FullName == "System.MulticastDelegate";
}
public static bool NeedsOverwrite(XmlElement element)
{
return element != null &&
!(element.HasAttribute("overwrite") &&
element.Attributes["overwrite"].Value.Equals("false", StringComparison.InvariantCultureIgnoreCase));
}
public static List<TypeReference> GetDeclaringTypes (TypeReference type)
{
List<TypeReference> decls = new List<TypeReference> ();
decls.Add (type);
while (type.DeclaringType != null)
{
decls.Add (type.DeclaringType);
type = type.DeclaringType;
}
decls.Reverse ();
return decls;
}
public static int GetGenericArgumentCount (TypeReference type)
{
GenericInstanceType inst = type as GenericInstanceType;
return inst != null
? inst.GenericArguments.Count
: type.GenericParameters.Count;
}
class TypeEquality : IEqualityComparer<TypeReference>
{
bool IEqualityComparer<TypeReference>.Equals (TypeReference x, TypeReference y)
{
if (x is null && y is null) return true;
if (x is null || y is null) return false;
return x.FullName == y.FullName;
}
int IEqualityComparer<TypeReference>.GetHashCode (TypeReference obj)
{
return obj.GetHashCode ();
}
}
static TypeEquality typeEqualityComparer = new TypeEquality ();
public static IEnumerable<TypeReference> GetAllPublicInterfaces (TypeDefinition type)
{
return GetAllInterfacesFromType (type)
.Where (i => IsPublic (i.Resolve ()))
.Distinct (typeEqualityComparer);
}
private static IEnumerable<TypeReference> GetAllInterfacesFromType(TypeDefinition type)
{
if (type is null)
yield break;
foreach(var i in type.Interfaces)
{
yield return i.InterfaceType;
foreach(var ii in GetAllInterfacesFromType(i.InterfaceType.Resolve()))
{
yield return ii;
}
}
}
public static IEnumerable<TypeReference> GetUserImplementedInterfaces (TypeDefinition type)
{
HashSet<string> inheritedInterfaces = GetInheritedInterfaces (type);
List<TypeReference> userInterfaces = new List<TypeReference> ();
foreach (var ii in type.Interfaces)
{
var iface = ii.InterfaceType;
TypeReference lookup = iface.Resolve () ?? iface;
if (!inheritedInterfaces.Contains (GetQualifiedTypeName (lookup)))
userInterfaces.Add (iface);
}
return userInterfaces.Where (i => IsPublic (i.Resolve ()));
}
private static string GetQualifiedTypeName (TypeReference type)
{
return "[" + type.Scope.Name + "]" + type.FullName;
}
private static HashSet<string> GetInheritedInterfaces (TypeDefinition type)
{
HashSet<string> inheritedInterfaces = new HashSet<string> ();
Action<TypeDefinition> a = null;
a = t =>
{
if (t == null) return;
foreach (var r in t.Interfaces)
{
inheritedInterfaces.Add (GetQualifiedTypeName (r.InterfaceType));
a (r.InterfaceType.Resolve ());
}
};
TypeReference baseRef = type.BaseType;
while (baseRef != null)
{
TypeDefinition baseDef = baseRef.Resolve ();
if (baseDef != null)
{
a (baseDef);
baseRef = baseDef.BaseType;
}
else
baseRef = null;
}
foreach (var r in type.Interfaces)
a (r.InterfaceType.Resolve ());
return inheritedInterfaces;
}
public static void AppendFieldValue(StringBuilder buf, FieldDefinition field)
{
// enums have a value__ field, which we ignore
if (((TypeDefinition)field.DeclaringType).IsEnum ||
field.DeclaringType.IsGenericType())
return;
if (field.HasConstant && field.IsLiteral)
{
object val = null;
try
{
val = field.Constant;
}
catch
{
return;
}
if (val == null)
buf.Append(" = ").Append("null");
else if (val is Enum)
buf.Append(" = ").Append(val.ToString());
else if (val is IFormattable)
{
string value = ((IFormattable)val).ToString(null, CultureInfo.InvariantCulture);
if (val is string)
value = "\"" + value + "\"";
buf.Append(" = ").Append(value);
}
}
}
/// <summary>
/// XPath is invalid if it containt '-symbol inside '...'.
/// So, put string which contains '-symbol inside "...", and vice versa
/// </summary>
public static string GetStringForXPath(string input)
{
if (!input.Contains("'"))
return $"\'{input}\'";
if (!input.Contains("\""))
return $"\"{input}\"";
return input;
}
/// <summary>
/// No documentation for property/event accessors.
/// </summary>
public static bool IsIgnored(MemberReference mi)
{
if (IsCompilerGenerated(mi))
{
if (mi.Name.StartsWith("get_", StringComparison.Ordinal)) return true;
if (mi.Name.StartsWith("set_", StringComparison.Ordinal)) return true;
if (mi.Name.StartsWith("put_", StringComparison.Ordinal)) return true;
if (mi.Name.StartsWith("add_", StringComparison.Ordinal)) return true;
if (mi.Name.StartsWith("remove_", StringComparison.Ordinal)) return true;
if (mi.Name.StartsWith("raise_", StringComparison.Ordinal)) return true;
}
return false;
}
private static bool IsCompilerGenerated(MemberReference mi)
{
IMemberDefinition memberDefinition = mi.Resolve();
return memberDefinition.IsSpecialName
|| memberDefinition.CustomAttributes.Any(i =>
i.AttributeType.FullName == Consts.CompilerGeneratedAttribute
|| i.AttributeType.FullName == Consts.CompilationMappingAttribute
);
}
public static bool IsAvailablePropertyMethod(MethodDefinition method)
{
return method != null
&& (IsExplicitlyImplemented(method)
|| (!method.IsPrivate && !method.IsAssembly && !method.IsFamilyAndAssembly));
}
/// <summary>
/// Get all members of implemented interfaces as Dictionary [fingerprint string] -> MemberReference
/// </summary>
public static Dictionary<string, List<MemberReference>> GetImplementedMembersFingerprintLookup(TypeDefinition type)
{
var lookup = new Dictionary<string, List<MemberReference>>();
List<TypeDefinition> previousInterfaces = new List<TypeDefinition>();
foreach (var implementedInterface in type.Interfaces)
{
var interfaceType = implementedInterface.InterfaceType.Resolve();
if (interfaceType == null)
continue;
//Don't add duplicates of members which appear because of inheritance of interfaces
bool addDuplicates = !previousInterfaces.Any(
i => i.Interfaces.Any(
j => j.InterfaceType.FullName == interfaceType.FullName));
var genericInstanceType = implementedInterface.InterfaceType as GenericInstanceType;
foreach (var memberReference in interfaceType.GetMembers())
{
// pass genericInstanceType to resolve generic types if they are explicitly specified in the interface implementation code
var fingerprint = GetFingerprint(memberReference, genericInstanceType);
if (!lookup.ContainsKey(fingerprint))
lookup[fingerprint] = new List<MemberReference>();
// if it's going to be the first element with this fingerprint, add it anyway.
// otherwise, check addDuplicates flag
if (!lookup[fingerprint].Any() || addDuplicates)
lookup[fingerprint].Add(memberReference);
}
previousInterfaces.Add(interfaceType);
}
return lookup;
}
/// <summary>
/// Get fingerprint of MemberReference. If fingerprints are equal, members can be implementations of each other
/// </summary>
/// <param name="memberReference">Type member which fingerprint is returned</param>
/// <param name="genericInterface">GenericInstanceType instance to resolve generic types if they are explicitly specified in the interface implementation code</param>
/// <remarks>Any existing MemberFormatter can't be used for generation of fingerprint because none of them generate equal signatures
/// for an interface member and its implementation in the following cases:
/// 1. Explicitly implemented members
/// 2. Different names of generic arguments in interface and in implementing type
/// 3. Implementation of interface with generic type parameters
/// The last point is especially interesting because it makes GetFingerprint method context-sensitive:
/// it returns signatures of interface members depending on generic parameters of the implementing type (GenericInstanceType parameter).</remarks>
public static string GetFingerprint(MemberReference memberReference, GenericInstanceType genericInterface = null)
{
// An interface contains only the signatures of methods, properties, events or indexers.
StringBuilder buf = new StringBuilder();
var unifiedTypeNames = new Dictionary<string, string>();
FillUnifiedMemberTypeNames(unifiedTypeNames, memberReference as IGenericParameterProvider);// Fill the member generic parameters unified names as M0, M1....
FillUnifiedTypeNames(unifiedTypeNames, memberReference.DeclaringType, genericInterface);// Fill the type generic parameters unified names as T0, T1....
switch (memberReference)
{
case IMethodSignature methodSignature:
buf.Append(GetUnifiedTypeName(methodSignature.ReturnType, unifiedTypeNames)).Append(" ");
buf.Append(SimplifyName(memberReference.Name)).Append(" ");
AppendParameters(buf, methodSignature.Parameters, unifiedTypeNames);
break;
case PropertyDefinition propertyReference:
buf.Append(GetUnifiedTypeName(propertyReference.PropertyType, unifiedTypeNames)).Append(" ");
if (propertyReference.GetMethod != null)
buf.Append("get").Append(" ");
if (propertyReference.SetMethod != null)
buf.Append("set").Append(" ");
buf.Append(SimplifyName(memberReference.Name)).Append(" ");
AppendParameters(buf, propertyReference.Parameters, unifiedTypeNames);
break;
case EventDefinition eventReference:
buf.Append(GetUnifiedTypeName(eventReference.EventType, unifiedTypeNames)).Append(" ");
buf.Append(SimplifyName(memberReference.Name)).Append(" ");
break;
}
var memberUnifiedTypeNames = new Dictionary<string, string>();
FillUnifiedMemberTypeNames(memberUnifiedTypeNames, memberReference as IGenericParameterProvider);
if (memberUnifiedTypeNames.Any())// Add generic arguments to the fingerprint. SomeMethod<T>() != SomeMethod()
{
buf.Append(" ").Append(string.Join(" ", memberUnifiedTypeNames.Values));
}
return buf.ToString();
}
/// <summary>
/// If it's the name of explicitly implemented member return only short name
/// </summary>
private static string SimplifyName(string memberName)
{
int nameBorder = memberName.LastIndexOf(".", StringComparison.InvariantCulture);
if (nameBorder > 0)
{
return memberName.Substring(nameBorder + 1, memberName.Length - nameBorder - 1);
}
return memberName;
}
/// <summary>
/// Resolve generic type names of the type type based on interface implementation details
/// </summary>
private static void FillUnifiedTypeNames(Dictionary<string, string> unifiedTypeNames,
IGenericParameterProvider type,
GenericInstanceType genericInterface)
{
if (type == null)
return;
int i = 0;
foreach (var genericParameter in type.GenericParameters)
{
if (unifiedTypeNames.ContainsKey(genericParameter.Name))
continue;
// if generic type can be resolved with interface implementation parameters
if (genericInterface != null
&& i < genericInterface.GenericArguments.Count)
{
unifiedTypeNames[genericParameter.Name] = genericInterface.GenericArguments[i].FullName;
}
else
{
unifiedTypeNames[genericParameter.Name] = genericParameter.Name;
}
++i;
}
}
/// <summary>
/// Resolve generic type names of the member based on the order of generic arguments
/// </summary>
private static void FillUnifiedMemberTypeNames(Dictionary<string, string> unifiedTypeNames,
IGenericParameterProvider member)
{
if (member == null)
return;
int i = 0;
foreach (var genericParameter in member.GenericParameters)
{
if (unifiedTypeNames.ContainsKey(genericParameter.Name))
continue;
unifiedTypeNames[genericParameter.Name] = "MemberGenericType" + i;
++i;
}
}
private static void AppendParameters(StringBuilder buf, Collection<ParameterDefinition> parameters, Dictionary<string, string> genericTypes)
{
buf.Append("(");
foreach (var parameterDefinition in parameters)
{
buf.Append(GetUnifiedTypeName(parameterDefinition.ParameterType, genericTypes)).Append(", ");
}
buf.Append(")");
}
private static string GetUnifiedTypeName(TypeReference type, Dictionary<string, string> genericTypes)
{
var genericInstance = type as IGenericInstance;
if (genericInstance != null && genericInstance.HasGenericArguments)
{
return
$"{type.Namespace}.{type.Name}<{string.Join(",", genericInstance.GenericArguments.Select(i => GetUnifiedTypeName(i, genericTypes)))}>";
}
return genericTypes.ContainsKey(type.Name)
? genericTypes[type.Name]
: type.FullName;
}
public static string GetExplicitTypeName(MemberReference memberReference)
{
var overrides = GetOverrides(memberReference);
if (overrides == null)
{
throw new ArgumentException("Unsupported explicitly implemented member");
}
var declaringType = overrides.First().DeclaringType;
return declaringType.GetElementType().FullName;
}
public static bool IsExplicitlyImplemented(MemberReference memberReference)
{
var overrides = GetOverrides(memberReference);
return overrides?.Count > 0;
}
/// <summary>
/// Get which members are overriden by memberReference
/// </summary>
private static Collection<MethodReference> GetOverrides(MemberReference memberReference)
{
switch (memberReference)
{
case MethodDefinition methodDefinition:
return methodDefinition.Overrides;
case PropertyDefinition propertyDefinition:
return (propertyDefinition.GetMethod ?? propertyDefinition.SetMethod)?.Overrides;
case EventDefinition evendDefinition:
return evendDefinition.AddMethod.Overrides;
}
return null;
}
public static bool IsDestructor(MethodDefinition method)
{
return method.IsFamily
&& method.Name == "Finalize"
&& method.Overrides.Count == 1
&& method.Overrides[0].DeclaringType.FullName == "System.Object";
}
public static bool IsOperator(MethodReference method)
{
return method.Name.StartsWith("op_", StringComparison.Ordinal);
}
}
}

View File

@ -0,0 +1,105 @@
using System;
using System.Collections.Generic;
using System.Xml;
using Mono.Cecil;
using Mono.Documentation.Util;
namespace Mono.Documentation.Updater
{
public class DocsNodeInfo
{
public DocsNodeInfo (XmlElement node)
{
this.Node = node;
}
public DocsNodeInfo (XmlElement node, TypeDefinition type)
: this (node)
{
SetType (type);
}
public DocsNodeInfo (XmlElement node, MemberReference member)
: this (node)
{
SetMemberInfo (member);
}
void SetType (TypeDefinition type)
{
if (type == null)
throw new ArgumentNullException ("type");
Type = type;
GenericParameters = new List<GenericParameter> (type.GenericParameters);
List<TypeReference> declTypes = DocUtils.GetDeclaringTypes (type);
int maxGenArgs = DocUtils.GetGenericArgumentCount (type);
for (int i = 0; i < declTypes.Count - 1; ++i)
{
int remove = System.Math.Min (maxGenArgs,
DocUtils.GetGenericArgumentCount (declTypes[i]));
maxGenArgs -= remove;
while (remove-- > 0)
GenericParameters.RemoveAt (0);
}
if (DocUtils.IsDelegate (type))
{
Parameters = type.GetMethod ("Invoke").Parameters;
ReturnType = type.GetMethod ("Invoke").ReturnType;
ReturnIsReturn = true;
}
}
void SetMemberInfo (MemberReference member)
{
if (member == null)
throw new ArgumentNullException ("member");
ReturnIsReturn = true;
AddRemarks = true;
Member = member;
if (member is MethodReference)
{
MethodReference mr = (MethodReference)member;
Parameters = mr.Parameters;
if (mr.IsGenericMethod ())
{
GenericParameters = new List<GenericParameter> (mr.GenericParameters);
}
}
else if (member is PropertyDefinition)
{
Parameters = ((PropertyDefinition)member).Parameters;
}
if (member is MethodDefinition)
{
ReturnType = ((MethodDefinition)member).ReturnType;
}
else if (member is PropertyDefinition)
{
ReturnType = ((PropertyDefinition)member).PropertyType;
ReturnIsReturn = false;
}
// no remarks section for enum members
if (member.DeclaringType != null && ((TypeDefinition)member.DeclaringType).IsEnum)
AddRemarks = false;
}
public TypeReference ReturnType;
public List<GenericParameter> GenericParameters;
public IList<ParameterDefinition> Parameters;
public bool ReturnIsReturn;
public XmlElement Node;
public bool AddRemarks = true;
public MemberReference Member;
public TypeDefinition Type;
public override string ToString ()
{
return string.Format ("{0} - {1} - {2}", Type, Member, Node == null ? "no xml" : "with xml");
}
}
}

View File

@ -0,0 +1,426 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using Mono.Cecil;
using StringList = System.Collections.Generic.List<string>;
using Mono.Documentation.Util;
using Mono.Documentation.Updater.Frameworks;
namespace Mono.Documentation.Updater
{
public class DocumentationEnumerator
{
public virtual IEnumerable<TypeDefinition> GetDocumentationTypes (AssemblyDefinition assembly, List<string> forTypes)
{
return GetDocumentationTypes (assembly, forTypes, null);
}
protected IEnumerable<TypeDefinition> GetDocumentationTypes (AssemblyDefinition assembly, List<string> forTypes, HashSet<string> seen)
{
foreach (TypeDefinition type in assembly.GetTypes ())
{
if (forTypes != null && forTypes.BinarySearch (type.FullName) < 0)
continue;
if (seen != null && seen.Contains (type.FullName))
continue;
yield return type;
}
}
public virtual IEnumerable<DocsNodeInfo> GetDocumentationMembers (XmlDocument basefile, TypeDefinition type, FrameworkTypeEntry typeEntry)
{
foreach (XmlElement oldmember in basefile.SelectNodes ("Type/Members/Member"))
{
if (oldmember.GetAttribute ("__monodocer-seen__") == "true")
{
oldmember.RemoveAttribute ("__monodocer-seen__");
continue;
}
if (oldmember.ParentNode == null)
continue;
MemberReference m = GetMember (type, new DocumentationMember (oldmember, typeEntry));
if (m == null)
{
yield return new DocsNodeInfo (oldmember);
}
else
{
yield return new DocsNodeInfo (oldmember, m);
}
}
}
public static MemberReference GetMember (TypeDefinition type, DocumentationMember member)
{
string membertype = member.MemberType;
string returntype = member.ReturnType;
string docName = member.MemberName;
string[] docTypeParams = GetTypeParameters (docName, member.TypeParameters);
// If we're using 'magic types', then we might get false positives ... in those cases, we keep searching
MemberReference likelyCandidate = null;
// Loop through all members in this type with the same name
var reflectedMembers = GetReflectionMembers (type, docName, membertype).ToArray ();
foreach (MemberReference mi in reflectedMembers)
{
bool matchedMagicType = false;
if (mi is TypeDefinition) continue;
if (MDocUpdater.GetMemberType (mi) != membertype) continue;
if (MDocUpdater.IsPrivate (mi))
continue;
IList<ParameterDefinition> pis = null;
string[] typeParams = null;
if (mi is MethodDefinition)
{
MethodDefinition mb = (MethodDefinition)mi;
pis = mb.Parameters;
if (mb.IsGenericMethod ())
{
IList<GenericParameter> args = mb.GenericParameters;
typeParams = args.Select (p => p.Name).ToArray ();
}
}
else if (mi is PropertyDefinition)
pis = ((PropertyDefinition)mi).Parameters;
// check type parameters
int methodTcount = member.TypeParameters == null ? 0 : member.TypeParameters.Count;
int reflectionTcount = typeParams == null ? 0 : typeParams.Length;
if (methodTcount != reflectionTcount)
continue;
// check member parameters
int mcount = member.Parameters == null ? 0 : member.Parameters.Count;
int pcount = pis == null ? 0 : pis.Count;
if (mcount != pcount)
continue;
MethodDefinition mDef = mi as MethodDefinition;
if (mDef != null && !mDef.IsConstructor)
{
// Casting operators can overload based on return type.
string rtype = GetReplacedString (
MDocUpdater.GetDocTypeFullName (((MethodDefinition)mi).ReturnType),
typeParams, docTypeParams);
string originalRType = rtype;
if (MDocUpdater.SwitchingToMagicTypes)
{
rtype = NativeTypeManager.ConvertFromNativeType (rtype);
}
if ((returntype != rtype && originalRType == rtype) ||
(MDocUpdater.SwitchingToMagicTypes && returntype != originalRType && returntype != rtype && originalRType != rtype))
{
continue;
}
if (originalRType != rtype)
matchedMagicType = true;
}
if (pcount == 0)
return mi;
bool good = true;
for (int i = 0; i < pis.Count; i++)
{
bool isRefType = pis[i].ParameterType is ByReferenceType;
string paramType = GetReplacedString (
MDocUpdater.GetDocParameterType (pis[i].ParameterType),
typeParams, docTypeParams);
// if magictypes, replace paramType to "classic value" ... so the comparison works
string originalParamType = paramType;
if (MDocUpdater.SwitchingToMagicTypes)
{
paramType = NativeTypeManager.ConvertFromNativeType (paramType);
}
string xmlMemberType = member.Parameters[i];
bool xmlIsRefType = xmlMemberType.Contains ('&');
bool refTypesMatch = isRefType == xmlIsRefType;
if (!refTypesMatch) {
good = false;
break;
}
xmlMemberType = xmlIsRefType ? xmlMemberType.Substring (0, xmlMemberType.Length - 1) : xmlMemberType;
if ((!paramType.Equals (xmlMemberType) && paramType.Equals (originalParamType)) ||
(MDocUpdater.SwitchingToMagicTypes && !originalParamType.Equals (xmlMemberType) && !paramType.Equals (xmlMemberType) && !paramType.Equals (originalParamType)))
{
// did not match ... if we're dropping the namespace, and the paramType has the dropped
// namespace, we should see if it matches when added
bool stillDoesntMatch = true;
if (MDocUpdater.HasDroppedNamespace (type) && paramType.StartsWith (MDocUpdater.droppedNamespace))
{
string withDroppedNs = string.Format ("{0}.{1}", MDocUpdater.droppedNamespace, xmlMemberType);
stillDoesntMatch = withDroppedNs != paramType;
}
if (stillDoesntMatch)
{
good = false;
break;
}
}
if (originalParamType != paramType)
matchedMagicType = true;
}
if (!good) continue;
if (MDocUpdater.SwitchingToMagicTypes && likelyCandidate == null && matchedMagicType)
{
// we matched this on a magic type conversion ... let's keep going to see if there's another one we should look at that matches more closely
likelyCandidate = mi;
continue;
}
return mi;
}
return likelyCandidate;
}
static string[] GetTypeParameters (string docName, IEnumerable<string> knownParameters)
{
if (docName[docName.Length - 1] != '>')
return null;
StringList types = new StringList ();
int endToken = docName.Length - 2;
int i = docName.Length - 2;
do
{
if (docName[i] == ',' || docName[i] == '<')
{
types.Add (docName.Substring (i + 1, endToken - i));
endToken = i - 1;
}
if (docName[i] == '<')
break;
} while (--i >= 0);
types.Reverse ();
var arrayTypes = types.ToArray ();
if (knownParameters != null && knownParameters.Any () && arrayTypes.Length != knownParameters.Count ())
return knownParameters.ToArray ();
else
return arrayTypes;
}
public static IEnumerable<MemberReference> GetReflectionMembers (TypeDefinition type, string docName, string memberType)
{
return GetReflectionMembersCore (type, docName, memberType)
.Distinct ();
}
private static IEnumerable<MemberReference> GetReflectionMembersCore (TypeDefinition type, string docName, string memberType)
{
// In case of dropping the namespace, we have to remove the dropped NS
// so that docName will match what's in the assembly/type
if (MDocUpdater.HasDroppedNamespace (type) && docName.StartsWith (MDocUpdater.droppedNamespace + "."))
{
int droppedNsLength = MDocUpdater.droppedNamespace.Length;
docName = docName.Substring (droppedNsLength + 1, docName.Length - droppedNsLength - 1);
}
// need to worry about 4 forms of //@MemberName values:
// 1. "Normal" (non-generic) member names: GetEnumerator
// - Lookup as-is.
// 2. Explicitly-implemented interface member names: System.Collections.IEnumerable.Current
// - try as-is, and try type.member (due to "kludge" for property
// support.
// 3. "Normal" Generic member names: Sort<T> (CSC)
// - need to remove generic parameters --> "Sort"
// 4. Explicitly-implemented interface members for generic interfaces:
// -- System.Collections.Generic.IEnumerable<T>.Current
// - Try as-is, and try type.member, *keeping* the generic parameters.
// --> System.Collections.Generic.IEnumerable<T>.Current, IEnumerable<T>.Current
// 5. As of 2008-01-02, gmcs will do e.g. 'IFoo`1[A].Method' instead of
// 'IFoo<A>.Method' for explicitly implemented methods; don't interpret
// this as (1) or (2).
if (docName.IndexOf ('<') == -1 && docName.IndexOf ('[') == -1)
{
int memberCount = 0;
// Cases 1 & 2
foreach (MemberReference mi in type.GetMembers (docName))
{
memberCount++;
yield return mi;
}
if (memberCount == 0 && CountChars (docName, '.') > 0)
{
Func<MemberReference, bool> verifyInterface = (member) =>
{
var meth = member as MethodDefinition;
if (meth == null && member is PropertyReference)
{
var propertyDefinition = ((PropertyReference)member).Resolve ();
meth = propertyDefinition.GetMethod ?? propertyDefinition.SetMethod;
}
return meth != null && (member.Name.Equals (".ctor") || DocUtils.IsExplicitlyImplemented (meth));
};
// might be a property; try only type.member instead of
// namespace.type.member.
var typeMember = DocUtils.GetTypeDotMember (docName);
var memberName = DocUtils.GetMember (docName);
foreach (MemberReference mi in
type.GetMembers (typeMember).Where (verifyInterface))
{
memberCount++;
yield return mi;
}
// some VB libraries use just the member name
foreach (MemberReference mi in
type.GetMembers (memberName).Where (verifyInterface))
{
memberCount++;
yield return mi;
}
// some VB libraries use a `typemember` naming convention
foreach (MemberReference mi in
type.GetMembers (typeMember.Replace (".", "")).Where (verifyInterface))
{
memberCount++;
yield return mi;
}
// if we still haven't found the member, there are some VB libraries
// that use a different interface name for implementation.
if (memberCount == 0)
{
foreach (MemberReference mi in
type
.GetMembers()
.Where(m => m.Name.StartsWith("I", StringComparison.InvariantCultureIgnoreCase) &&
m.Name.EndsWith(memberName, StringComparison.InvariantCultureIgnoreCase))
.Where(verifyInterface))
{
memberCount++;
yield return mi;
}
}
if (memberCount == 0 && memberType == "Property")
{
foreach (MemberReference mr in type.GetMembers().Where(x => x is PropertyDefinition))
{
var method = ((PropertyDefinition) mr).GetMethod ?? ((PropertyDefinition) mr).SetMethod;
if (method?.Overrides != null && method.Overrides.Any())
{
DocUtils.GetInfoForExplicitlyImplementedMethod(method, out var iface, out var ifaceMethod);
var newName = DocUtils.GetMemberForProperty(ifaceMethod.Name);
if (newName == memberName && verifyInterface(mr) && docName.Contains (iface.Name))
yield return mr;
}
}
}
}
yield break;
}
// cases 3 & 4
int numLt = 0;
int numDot = 0;
int startLt, startType, startMethod;
startLt = startType = startMethod = -1;
for (int i = 0; i < docName.Length; ++i)
{
switch (docName[i])
{
case '<':
if (numLt == 0)
{
startLt = i;
}
++numLt;
break;
case '>':
--numLt;
if (numLt == 0 && (i + 1) < docName.Length)
// there's another character in docName, so this <...> sequence is
// probably part of a generic type -- case 4.
startLt = -1;
break;
case '.':
startType = startMethod;
startMethod = i;
++numDot;
break;
}
}
string refName = startLt == -1 ? docName : docName.Substring (0, startLt);
// case 3
foreach (MemberReference mi in type.GetMembers (refName))
yield return mi;
// case 4
foreach (MemberReference mi in type.GetMembers (refName.Substring (startType + 1)))
yield return mi;
// If we _still_ haven't found it, we've hit another generic naming issue:
// post Mono 1.1.18, gmcs generates [[FQTN]] instead of <TypeName> for
// explicitly-implemented METHOD names (not properties), e.g.
// "System.Collections.Generic.IEnumerable`1[[Foo, test, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]].GetEnumerator"
// instead of "System.Collections.Generic.IEnumerable<Foo>.GetEnumerator",
// which the XML docs will contain.
//
// Alas, we can't derive the Mono name from docName, so we need to iterate
// over all member names, convert them into CSC format, and compare... :-(
if (numDot == 0)
yield break;
foreach (MemberReference mi in type.GetMembers ())
{
if (MDocUpdater.GetMemberName (mi) == docName)
yield return mi;
}
}
static string GetReplacedString (string typeName, string[] from, string[] to)
{
if (from == null)
return typeName;
for (int i = 0; i < from.Length; ++i)
typeName = typeName.Replace (from[i], to[i]);
return typeName;
}
private static int CountChars (string s, char c)
{
int count = 0;
for (int i = 0; i < s.Length; ++i)
{
if (s[i] == c)
++count;
}
return count;
}
}
}

View File

@ -0,0 +1,8 @@
namespace Mono.Documentation.Updater
{
public abstract class DocumentationImporter
{
public abstract void ImportDocumentation (DocsNodeInfo info);
}
}

View File

@ -0,0 +1,201 @@
using System;
using System.Xml;
using System.Linq;
using StringList = System.Collections.Generic.List<string>;
using StringToStringMap = System.Collections.Generic.Dictionary<string, string>;
using Mono.Documentation.Updater.Frameworks;
namespace Mono.Documentation.Updater
{
public class DocumentationMember
{
public StringToStringMap MemberSignatures = new StringToStringMap ();
public string ReturnType;
public StringList Parameters;
public StringList TypeParameters;
public string MemberName;
public string MemberType;
/// <summary>Removes modreq and modopt from ReturnType, Parameters, and TypeParameters</summary>
private void CleanTypes ()
{
ReturnType = MemberFormatter.RemoveMod (ReturnType);
MemberType = MemberFormatter.RemoveMod (MemberType);
if (Parameters != null)
{
for (var i = 0; i < Parameters.Count; i++)
Parameters[i] = MemberFormatter.RemoveMod (Parameters[i]);
}
if (TypeParameters != null)
{
for (var i = 0; i < TypeParameters.Count; i++)
TypeParameters[i] = MemberFormatter.RemoveMod (TypeParameters[i]);
}
}
public DocumentationMember (XmlReader reader)
{
MemberName = reader.GetAttribute ("MemberName");
int depth = reader.Depth;
bool go = true;
StringList p = new StringList ();
StringList tp = new StringList ();
do
{
if (reader.NodeType != XmlNodeType.Element)
continue;
bool shouldUse = true;
try
{
string apistyle = reader.GetAttribute ("apistyle");
shouldUse = string.IsNullOrWhiteSpace (apistyle) || apistyle == "classic"; // only use this tag if it's an 'classic' style node
}
catch (Exception) { }
switch (reader.Name)
{
case "MemberSignature":
if (shouldUse)
{
MemberSignatures[reader.GetAttribute ("Language")] = reader.GetAttribute ("Value");
}
break;
case "MemberType":
MemberType = reader.ReadElementString ();
break;
case "ReturnType":
if (reader.Depth == depth + 2 && shouldUse)
ReturnType = reader.ReadElementString ();
break;
case "Parameter":
if (reader.Depth == depth + 2 && shouldUse)
{
var ptype = reader.GetAttribute ("Type");
var reftypeAttribute = reader.GetAttribute ("RefType");
if (!ptype.EndsWith("&", StringComparison.Ordinal) &&
(reftypeAttribute == "out" || reftypeAttribute == "ref"))
{
// let's add the `&` back, for comparisons
ptype += '&';
}
p.Add (ptype);
}
break;
case "TypeParameter":
if (reader.Depth == depth + 2 && shouldUse)
tp.Add (reader.GetAttribute ("Name"));
break;
case "Docs":
if (reader.Depth == depth + 1)
go = false;
break;
}
} while (go && reader.Read () && reader.Depth >= depth);
if (p.Count > 0)
{
Parameters = p;
}
if (tp.Count > 0)
{
TypeParameters = tp;
}
else
{
DiscernTypeParameters ();
}
CleanTypes ();
}
public DocumentationMember (XmlNode node, FrameworkTypeEntry typeEntry)
{
MemberName = node.Attributes["MemberName"].Value;
foreach (XmlNode n in node.SelectNodes ("MemberSignature"))
{
XmlAttribute l = n.Attributes["Language"];
XmlAttribute v = n.Attributes["Value"];
XmlAttribute apistyle = n.Attributes["apistyle"];
bool shouldUse = apistyle == null || apistyle.Value == "classic";
if (l != null && v != null && shouldUse)
MemberSignatures[l.Value] = v.Value;
}
MemberType = node.SelectSingleNode ("MemberType").InnerText;
XmlNode rt = node.SelectSingleNode ("ReturnValue/ReturnType[not(@apistyle) or @apistyle='classic']");
if (rt != null)
ReturnType = rt.InnerText;
var p = node.SelectNodes ("Parameters/Parameter[not(@apistyle) or @apistyle='classic']").Cast<XmlElement>().ToArray ();
if (p.Length > 0)
{
Func<string, string, string> processType = (reftype, typename) =>
!typename.EndsWith("&", StringComparison.Ordinal) && (reftype == "ref" || reftype == "out") ? typename + '&' : typename;
if (p.Any (para => para.HasAttribute ("Index")))
{
var pgroup = p
.Select (para => new
{
Index = para.GetAttribute ("Index"),
Type = para.GetAttribute ("Type"),
RefType = para.GetAttribute ("RefType")
})
.GroupBy (para => new
{
para.Index,
Type = processType (para.RefType, para.Type)
})
.ToArray ();
Parameters = new StringList (pgroup.Length);
Parameters.AddRange (pgroup.Select (pg => pg.Key.Type));
}
else {
var ptypes = p
.Select (para => new
{
Type = para.GetAttribute ("Type"),
RefType = para.GetAttribute ("RefType")
})
.Select (para => processType(para.RefType, para.Type))
.ToArray ();
Parameters = new StringList (ptypes);
}
}
XmlNodeList tp = node.SelectNodes ("TypeParameters/TypeParameter[not(@apistyle) or @apistyle='classic']");
if (tp.Count > 0)
{
TypeParameters = new StringList (tp.Count);
for (int i = 0; i < tp.Count; ++i)
TypeParameters.Add (tp[i].Attributes["Name"].Value);
}
else
{
DiscernTypeParameters ();
}
CleanTypes ();
}
void DiscernTypeParameters ()
{
// see if we can discern the param list from the name
if (MemberName.Contains ("<") && MemberName.EndsWith (">"))
{
var starti = MemberName.IndexOf ("<") + 1;
var endi = MemberName.LastIndexOf (">");
var paramlist = MemberName.Substring (starti, endi - starti);
var tparams = paramlist.Split (new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
TypeParameters = new StringList (tparams);
}
}
public override string ToString ()
{
if (MemberSignatures.Count > 0)
return MemberSignatures.Values.First ();
else
return $"{MemberType}{ReturnType} {MemberName}<{TypeParameters.Count}> ({Parameters.Count})";
}
}
}

View File

@ -0,0 +1,30 @@
using System.Collections.ObjectModel;
using System.Linq;
using Mono.Cecil;
using Mono.Documentation.Util;
namespace Mono.Documentation.Updater
{
public class DynamicParserContext
{
public ReadOnlyCollection<bool> TransformFlags;
public int TransformIndex;
public DynamicParserContext (ICustomAttributeProvider provider)
{
CustomAttribute da;
if (provider.HasCustomAttributes &&
(da = (provider.CustomAttributes.SafeCast<CustomAttribute> ()
.SingleOrDefault (ca => ca.GetDeclaringType () == "System.Runtime.CompilerServices.DynamicAttribute"))) != null)
{
CustomAttributeArgument[] values = da.ConstructorArguments.Count == 0
? new CustomAttributeArgument[0]
: (CustomAttributeArgument[])da.ConstructorArguments[0].Value;
TransformFlags = new ReadOnlyCollection<bool> (values.Select (t => (bool)t.Value).ToArray ());
}
}
}
}

View File

@ -0,0 +1,169 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using Mono.Cecil;
using Mono.Documentation.Updater.Frameworks;
using Mono.Documentation.Util;
namespace Mono.Documentation.Updater
{
class EcmaDocumentationEnumerator : DocumentationEnumerator
{
XmlReader ecmadocs;
MDocUpdater app;
public EcmaDocumentationEnumerator (MDocUpdater app, XmlReader ecmaDocs)
{
this.app = app;
this.ecmadocs = ecmaDocs;
}
public override IEnumerable<TypeDefinition> GetDocumentationTypes (AssemblyDefinition assembly, List<string> forTypes)
{
HashSet<string> seen = new HashSet<string> ();
return GetDocumentationTypes (assembly, forTypes, seen)
.Concat (base.GetDocumentationTypes (assembly, forTypes, seen));
}
new IEnumerable<TypeDefinition> GetDocumentationTypes (AssemblyDefinition assembly, List<string> forTypes, HashSet<string> seen)
{
int typeDepth = -1;
while (ecmadocs.Read ())
{
switch (ecmadocs.Name)
{
case "Type":
{
if (typeDepth == -1)
typeDepth = ecmadocs.Depth;
if (ecmadocs.NodeType != XmlNodeType.Element)
continue;
if (typeDepth != ecmadocs.Depth) // nested <TypeDefinition/> element?
continue;
string typename = ecmadocs.GetAttribute ("FullName");
string typename2 = MDocUpdater.GetTypeFileName (typename);
if (forTypes != null &&
forTypes.BinarySearch (typename) < 0 &&
typename != typename2 &&
forTypes.BinarySearch (typename2) < 0)
continue;
TypeDefinition t;
if ((t = assembly.GetType (typename)) == null &&
(t = assembly.GetType (typename2)) == null)
continue;
seen.Add (typename);
if (typename != typename2)
seen.Add (typename2);
Console.WriteLine (" Import: {0}", t.FullName);
if (ecmadocs.Name != "Docs")
{
int depth = ecmadocs.Depth;
while (ecmadocs.Read ())
{
if (ecmadocs.Name == "Docs" && ecmadocs.Depth == depth + 1)
break;
}
}
if (!ecmadocs.IsStartElement ("Docs"))
throw new InvalidOperationException ("Found " + ecmadocs.Name + "; expecting <Docs/>!");
yield return t;
break;
}
default:
break;
}
}
}
public override IEnumerable<DocsNodeInfo> GetDocumentationMembers (XmlDocument basefile, TypeDefinition type, FrameworkTypeEntry typeEntry)
{
return GetMembers (basefile, type, typeEntry)
.Concat (base.GetDocumentationMembers (basefile, type, typeEntry));
}
private IEnumerable<DocsNodeInfo> GetMembers (XmlDocument basefile, TypeDefinition type, FrameworkTypeEntry typeEntry)
{
while (ecmadocs.Name != "Members" && ecmadocs.Read ())
{
// do nothing
}
if (ecmadocs.IsEmptyElement)
yield break;
int membersDepth = ecmadocs.Depth;
bool go = true;
while (go && ecmadocs.Read ())
{
switch (ecmadocs.Name)
{
case "Member":
{
if (membersDepth != ecmadocs.Depth - 1 || ecmadocs.NodeType != XmlNodeType.Element)
continue;
DocumentationMember dm = new DocumentationMember (ecmadocs);
string xp = MDocUpdater.GetXPathForMember (dm);
XmlElement oldmember = (XmlElement)basefile.SelectSingleNode (xp);
MemberReference m;
if (oldmember == null)
{
m = GetMember (type, dm);
if (m == null)
{
app.Warning ("Could not import ECMA docs for `{0}'s `{1}': Member not found.",
type.FullName, dm.MemberSignatures["C#"]);
// SelectSingleNode (ecmaDocsMember, "MemberSignature[@Language=\"C#\"]/@Value").Value);
continue;
}
// oldmember lookup may have failed due to type parameter renames.
// Try again.
oldmember = (XmlElement)basefile.SelectSingleNode (MDocUpdater.GetXPathForMember (m)); //todo: why always null???
if (oldmember == null)
{
XmlElement members = MDocUpdater.WriteElement (basefile.DocumentElement, "Members");
oldmember = basefile.CreateElement ("Member");
oldmember.SetAttribute ("MemberName", dm.MemberName);
members.AppendChild (oldmember);
foreach (string key in MDocUpdater.Sort (dm.MemberSignatures.Keys))
{
XmlElement ms = basefile.CreateElement ("MemberSignature");
ms.SetAttribute ("Language", key);
ms.SetAttribute ("Value", (string)dm.MemberSignatures[key]);
oldmember.AppendChild (ms);
}
oldmember.SetAttribute ("__monodocer-seen__", "true");
Console.WriteLine ("Member Added: {0}", oldmember.SelectSingleNode ("MemberSignature[@Language='C#']/@Value").InnerText);
app.additions++;
}
}
else
{
m = GetMember (type, new DocumentationMember (oldmember, typeEntry));
if (m == null)
{
app.Warning ("Could not import ECMA docs for `{0}'s `{1}': Member not found.",
type.FullName, dm.MemberSignatures["C#"]);
continue;
}
oldmember.SetAttribute ("__monodocer-seen__", "true");
}
DocsNodeInfo node = new DocsNodeInfo (oldmember, m);
if (ecmadocs.Name != "Docs")
throw new InvalidOperationException ("Found " + ecmadocs.Name + "; expected <Docs/>!");
yield return node;
break;
}
case "Members":
if (membersDepth == ecmadocs.Depth && ecmadocs.NodeType == XmlNodeType.EndElement)
{
go = false;
}
break;
}
}
}
}
}

View File

@ -0,0 +1,118 @@
using System;
using System.Xml;
using StringList = System.Collections.Generic.List<string>;
namespace Mono.Documentation.Updater
{
class EcmaDocumentationImporter : DocumentationImporter
{
XmlReader ecmadocs;
public EcmaDocumentationImporter (XmlReader ecmaDocs)
{
this.ecmadocs = ecmaDocs;
}
public override void ImportDocumentation (DocsNodeInfo info)
{
if (!ecmadocs.IsStartElement ("Docs"))
{
return;
}
XmlElement e = info.Node;
int depth = ecmadocs.Depth;
ecmadocs.ReadStartElement ("Docs");
while (ecmadocs.Read ())
{
if (ecmadocs.Name == "Docs")
{
if (ecmadocs.Depth == depth && ecmadocs.NodeType == XmlNodeType.EndElement)
break;
else
throw new InvalidOperationException ("Skipped past current <Docs/> element!");
}
if (!ecmadocs.IsStartElement ())
continue;
switch (ecmadocs.Name)
{
case "param":
case "typeparam":
{
string name = ecmadocs.GetAttribute ("name");
if (name == null)
break;
XmlNode doc = e.SelectSingleNode (
ecmadocs.Name + "[@name='" + name + "']");
string value = ecmadocs.ReadInnerXml ();
if (doc != null)
doc.InnerXml = value.Replace ("\r", "");
break;
}
case "altmember":
case "exception":
case "permission":
case "seealso":
{
string name = ecmadocs.Name;
string cref = ecmadocs.GetAttribute ("cref");
if (cref == null)
break;
XmlNode doc = e.SelectSingleNode (
ecmadocs.Name + "[@cref='" + cref + "']");
string value = ecmadocs.ReadInnerXml ().Replace ("\r", "");
if (doc != null)
doc.InnerXml = value;
else
{
XmlElement n = e.OwnerDocument.CreateElement (name);
n.SetAttribute ("cref", cref);
n.InnerXml = value;
e.AppendChild (n);
}
break;
}
default:
{
string name = ecmadocs.Name;
string xpath = ecmadocs.Name;
StringList attributes = new StringList (ecmadocs.AttributeCount);
if (ecmadocs.MoveToFirstAttribute ())
{
do
{
attributes.Add ("@" + ecmadocs.Name + "=\"" + ecmadocs.Value + "\"");
} while (ecmadocs.MoveToNextAttribute ());
ecmadocs.MoveToContent ();
}
if (attributes.Count > 0)
{
xpath += "[" + string.Join (" and ", attributes.ToArray ()) + "]";
}
XmlNode doc = e.SelectSingleNode (xpath);
string value = ecmadocs.ReadInnerXml ().Replace ("\r", "");
if (doc != null)
{
doc.InnerXml = value;
}
else
{
XmlElement n = e.OwnerDocument.CreateElement (name);
n.InnerXml = value;
foreach (string a in attributes)
{
int eq = a.IndexOf ('=');
n.SetAttribute (a.Substring (1, eq - 1), a.Substring (eq + 2, a.Length - eq - 3));
}
e.AppendChild (n);
}
break;
}
}
}
}
}
}

View File

@ -0,0 +1,95 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Mono.Cecil;
namespace Mono.Documentation.Updater
{
/// <summary>A custom formatter for the ObjCRuntime.Platform enumeration.</summary>
class ApplePlatformEnumFormatter : AttributeValueFormatter
{
public override bool TryFormatValue (object v, ResolvedTypeInfo type, out string returnvalue)
{
TypeReference valueType = type.Reference;
string typename = MDocUpdater.GetDocTypeFullName (valueType);
TypeDefinition valueDef = type.Definition;
if (typename.Contains ("ObjCRuntime.Platform") && valueDef.CustomAttributes.Any (ca => ca.AttributeType.FullName == "System.FlagsAttribute"))
{
var values = MDocUpdater.GetEnumerationValues (valueDef);
long c = MDocUpdater.ToInt64 (v);
returnvalue = Format (c, values, typename);
return true;
}
returnvalue = null;
return false;
}
string Format (long c, IDictionary<long, string> values, string typename)
{
int iosarch, iosmajor, iosminor, iossubminor;
int macarch, macmajor, macminor, macsubminor;
GetEncodingiOS (c, out iosarch, out iosmajor, out iosminor, out iossubminor);
GetEncodingMac ((ulong)c, out macarch, out macmajor, out macminor, out macsubminor);
if (iosmajor == 0 & iosminor == 0 && iossubminor == 0)
{
return FormatValues ("Mac", macarch, macmajor, macminor, macsubminor);
}
if (macmajor == 0 & macminor == 0 && macsubminor == 0)
{
return FormatValues ("iOS", iosarch, iosmajor, iosminor, iossubminor);
}
return string.Format ("(Platform){0}", c);
}
string FormatValues (string plat, int arch, int major, int minor, int subminor)
{
string archstring = "";
switch (arch)
{
case 1:
archstring = "32";
break;
case 2:
archstring = "64";
break;
}
return string.Format ("Platform.{4}_{0}_{1}{2} | Platform.{4}_Arch{3}",
major,
minor,
subminor == 0 ? "" : "_" + subminor.ToString (),
archstring,
plat
);
}
void GetEncodingiOS (long entireLong, out int archindex, out int major, out int minor, out int subminor)
{
long lowerBits = entireLong & 0xffffffff;
int lowerBitsAsInt = (int)lowerBits;
GetEncoding (lowerBitsAsInt, out archindex, out major, out minor, out subminor);
}
void GetEncodingMac (ulong entireLong, out int archindex, out int major, out int minor, out int subminor)
{
ulong higherBits = entireLong & 0xffffffff00000000;
int higherBitsAsInt = (int)((higherBits) >> 32);
GetEncoding (higherBitsAsInt, out archindex, out major, out minor, out subminor);
}
void GetEncoding (Int32 encodedBits, out int archindex, out int major, out int minor, out int subminor)
{
// format is AAJJNNSS
archindex = (int)((encodedBits & 0xFF000000) >> 24);
major = (int)((encodedBits & 0x00FF0000) >> 16);
minor = (int)((encodedBits & 0x0000FF00) >> 8);
subminor = (int)((encodedBits & 0x000000FF) >> 0);
}
}
}

View File

@ -0,0 +1,66 @@
using System;
using Mono.Cecil;
using Mono.Documentation.Util;
namespace Mono.Documentation.Updater
{
/// <summary>Formats attribute values. Should return true if it is able to format the value.</summary>
class AttributeValueFormatter
{
public virtual bool TryFormatValue (object v, ResolvedTypeInfo type, out string returnvalue)
{
TypeReference valueType = type.Reference;
if (v == null)
{
returnvalue = "null";
return true;
}
if (valueType.FullName == "System.Type")
{
var vTypeRef = v as TypeReference;
if (vTypeRef != null)
returnvalue = "typeof(" + NativeTypeManager.GetTranslatedName (vTypeRef) + ")"; // TODO: drop NS handling
else
returnvalue = "typeof(" + v.ToString () + ")";
return true;
}
if (valueType.FullName == "System.String")
{
returnvalue = "\"" + MDocUpdater.FilterSpecialChars (v.ToString ()) + "\"";
return true;
}
if (valueType.FullName == "System.Char")
{
returnvalue = "'" + MDocUpdater.FilterSpecialChars (v.ToString ()) + "'";
return true;
}
if (v is Boolean)
{
returnvalue = (bool)v ? "true" : "false";
return true;
}
TypeDefinition valueDef = type.Definition;
if (valueDef == null || !valueDef.IsEnum)
{
returnvalue = v.ToString ();
return true;
}
string typename = MDocUpdater.GetDocTypeFullName (valueType);
var values = MDocUpdater.GetEnumerationValues (valueDef);
long c = MDocUpdater.ToInt64 (v);
if (values.ContainsKey (c))
{
returnvalue = typename + "." + values[c];
return true;
}
returnvalue = null;
return false;
}
}
}

View File

@ -0,0 +1,668 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using Mono.Cecil;
using Mono.Documentation.Util;
namespace Mono.Documentation.Updater
{
public class CSharpFullMemberFormatter : MemberFormatter
{
public override string Language
{
get { return "C#"; }
}
protected override StringBuilder AppendNamespace (StringBuilder buf, TypeReference type)
{
string ns = DocUtils.GetNamespace (type);
if (GetCSharpType (type.FullName) == null && ns != null && ns.Length > 0 && ns != "System")
buf.Append (ns).Append ('.');
return buf;
}
protected virtual string GetCSharpType (string t)
{
// make sure there are no modifiers in the type string (add them back before returning)
string typeToCompare = t;
string[] splitType = null;
if (t.Contains (' '))
{
splitType = t.Split (' ');
typeToCompare = splitType[0];
}
switch (typeToCompare)
{
case "System.Byte": typeToCompare = "byte"; break;
case "System.SByte": typeToCompare = "sbyte"; break;
case "System.Int16": typeToCompare = "short"; break;
case "System.Int32": typeToCompare = "int"; break;
case "System.Int64": typeToCompare = "long"; break;
case "System.UInt16": typeToCompare = "ushort"; break;
case "System.UInt32": typeToCompare = "uint"; break;
case "System.UInt64": typeToCompare = "ulong"; break;
case "System.Single": typeToCompare = "float"; break;
case "System.Double": typeToCompare = "double"; break;
case "System.Decimal": typeToCompare = "decimal"; break;
case "System.Boolean": typeToCompare = "bool"; break;
case "System.Char": typeToCompare = "char"; break;
case "System.Void": typeToCompare = "void"; break;
case "System.String": typeToCompare = "string"; break;
case "System.Object": typeToCompare = "object"; break;
}
if (splitType != null)
{
// re-add modreq/modopt if it was there
splitType[0] = typeToCompare;
typeToCompare = string.Join (" ", splitType);
}
return typeToCompare == t ? null : typeToCompare;
}
protected override StringBuilder AppendTypeName (StringBuilder buf, TypeReference type, DynamicParserContext context)
{
if (context != null && context.TransformFlags != null &&
(context.TransformFlags.Count == 0 || context.TransformFlags[context.TransformIndex]))
{
context.TransformIndex++;
return buf.Append ("dynamic");
}
if (type is GenericParameter)
return AppendGenericParameterConstraints (buf, (GenericParameter)type, context).Append (type.Name);
string t = type.FullName;
if (!t.StartsWith ("System."))
{
return base.AppendTypeName (buf, type, context);
}
string s = GetCSharpType (t);
if (s != null)
{
if (context != null)
context.TransformIndex++;
return buf.Append (s);
}
return base.AppendTypeName (buf, type, context);
}
private StringBuilder AppendGenericParameterConstraints (StringBuilder buf, GenericParameter type, DynamicParserContext context)
{
if (MemberFormatterState != MemberFormatterState.WithinGenericTypeParameters)
return buf;
GenericParameterAttributes attrs = type.Attributes;
bool isout = (attrs & GenericParameterAttributes.Covariant) != 0;
bool isin = (attrs & GenericParameterAttributes.Contravariant) != 0;
if (isin)
buf.Append ("in ");
else if (isout)
buf.Append ("out ");
return buf;
}
protected override string GetTypeDeclaration (TypeDefinition type)
{
string visibility = GetTypeVisibility (type.Attributes);
if (visibility == null)
return null;
StringBuilder buf = new StringBuilder ();
buf.Append (visibility);
buf.Append (" ");
MemberFormatter full = new CSharpFullMemberFormatter ();
if (DocUtils.IsDelegate (type))
{
buf.Append ("delegate ");
MethodDefinition invoke = type.GetMethod ("Invoke");
buf.Append (full.GetName (invoke.ReturnType, new DynamicParserContext (invoke.MethodReturnType))).Append (" ");
buf.Append (GetName (type));
AppendParameters (buf, invoke, invoke.Parameters);
AppendGenericTypeConstraints (buf, type);
buf.Append (";");
return buf.ToString ();
}
if (type.IsAbstract && !type.IsInterface)
buf.Append ("abstract ");
if (type.IsSealed && !DocUtils.IsDelegate (type) && !type.IsValueType)
buf.Append ("sealed ");
buf.Replace ("abstract sealed", "static");
buf.Append (GetTypeKind (type));
buf.Append (" ");
buf.Append (GetCSharpType (type.FullName) == null
? GetName (type)
: type.Name);
if (!type.IsEnum)
{
TypeReference basetype = type.BaseType;
if (basetype != null && basetype.FullName == "System.Object" || type.IsValueType) // FIXME
basetype = null;
List<string> interface_names = DocUtils.GetUserImplementedInterfaces (type)
.Select (iface => full.GetName (iface))
.OrderBy (s => s)
.ToList ();
if (basetype != null || interface_names.Count > 0)
buf.Append (" : ");
if (basetype != null)
{
buf.Append (full.GetName (basetype));
if (interface_names.Count > 0)
buf.Append (", ");
}
for (int i = 0; i < interface_names.Count; i++)
{
if (i != 0)
buf.Append (", ");
buf.Append (interface_names[i]);
}
AppendGenericTypeConstraints (buf, type);
}
return buf.ToString ();
}
static string GetTypeKind (TypeDefinition t)
{
if (t.IsEnum)
return "enum";
if (t.IsValueType)
return "struct";
if (t.IsClass || t.FullName == "System.Enum")
return "class";
if (t.IsInterface)
return "interface";
throw new ArgumentException (t.FullName);
}
static string GetTypeVisibility (TypeAttributes ta)
{
switch (ta & TypeAttributes.VisibilityMask)
{
case TypeAttributes.Public:
case TypeAttributes.NestedPublic:
return "public";
case TypeAttributes.NestedFamily:
return "protected";
case TypeAttributes.NestedFamORAssem:
return "protected internal";
default:
return null;
}
}
protected override StringBuilder AppendGenericTypeConstraints (StringBuilder buf, TypeReference type)
{
if (type.GenericParameters.Count == 0)
return buf;
return AppendConstraints (buf, type.GenericParameters);
}
private StringBuilder AppendConstraints (StringBuilder buf, IList<GenericParameter> genArgs)
{
foreach (GenericParameter genArg in genArgs)
{
GenericParameterAttributes attrs = genArg.Attributes;
#if NEW_CECIL
Mono.Collections.Generic.Collection<GenericParameterConstraint> constraints = genArg.Constraints;
#else
IList<TypeReference> constraints = genArg.Constraints;
#endif
if (attrs == GenericParameterAttributes.NonVariant && constraints.Count == 0)
continue;
bool isref = (attrs & GenericParameterAttributes.ReferenceTypeConstraint) != 0;
bool isvt = (attrs & GenericParameterAttributes.NotNullableValueTypeConstraint) != 0;
bool isnew = (attrs & GenericParameterAttributes.DefaultConstructorConstraint) != 0;
bool comma = false;
if (!isref && !isvt && !isnew && constraints.Count == 0)
continue;
buf.Append (" where ").Append (genArg.Name).Append (" : ");
if (isref)
{
buf.Append ("class");
comma = true;
}
else if (isvt)
{
buf.Append ("struct");
comma = true;
}
if (constraints.Count > 0 && !isvt)
{
if (comma)
buf.Append (", ");
#if NEW_CECIL
buf.Append (GetTypeName (constraints[0].ConstraintType));
for (int i = 1; i < constraints.Count; ++i)
buf.Append (", ").Append (GetTypeName (constraints[i].ConstraintType));
#else
buf.Append (GetTypeName (constraints[0]));
for (int i = 1; i < constraints.Count; ++i)
buf.Append (", ").Append (GetTypeName (constraints[i]));
#endif
}
if (isnew && !isvt)
{
if (comma)
buf.Append (", ");
buf.Append ("new()");
}
}
return buf;
}
protected override string GetConstructorDeclaration (MethodDefinition constructor)
{
StringBuilder buf = new StringBuilder ();
AppendVisibility (buf, constructor);
if (buf.Length == 0)
return null;
buf.Append (' ');
base.AppendTypeName (buf, constructor.DeclaringType.Name).Append (' ');
AppendParameters (buf, constructor, constructor.Parameters);
buf.Append (';');
return buf.ToString ();
}
protected override string GetMethodDeclaration (MethodDefinition method)
{
string decl = base.GetMethodDeclaration (method);
if (decl != null)
return decl + ";";
return null;
}
protected override StringBuilder AppendMethodName (StringBuilder buf, MethodDefinition method)
{
if (DocUtils.IsExplicitlyImplemented (method))
{
TypeReference iface;
MethodReference ifaceMethod;
DocUtils.GetInfoForExplicitlyImplementedMethod (method, out iface, out ifaceMethod);
return buf.Append (new CSharpMemberFormatter ().GetName (iface))
.Append ('.')
.Append (ifaceMethod.Name);
}
if (method.Name.StartsWith ("op_", StringComparison.Ordinal))
{
// this is an operator
switch (method.Name)
{
case "op_Implicit":
case "op_Explicit":
buf.Length--; // remove the last space, which assumes a member name is coming
return buf;
case "op_Addition":
case "op_UnaryPlus":
return buf.Append ("operator +");
case "op_Subtraction":
case "op_UnaryNegation":
return buf.Append ("operator -");
case "op_Division":
return buf.Append ("operator /");
case "op_Multiply":
return buf.Append ("operator *");
case "op_Modulus":
return buf.Append ("operator %");
case "op_BitwiseAnd":
return buf.Append ("operator &");
case "op_BitwiseOr":
return buf.Append ("operator |");
case "op_ExclusiveOr":
return buf.Append ("operator ^");
case "op_LeftShift":
return buf.Append ("operator <<");
case "op_RightShift":
return buf.Append ("operator >>");
case "op_LogicalNot":
return buf.Append ("operator !");
case "op_OnesComplement":
return buf.Append ("operator ~");
case "op_Decrement":
return buf.Append ("operator --");
case "op_Increment":
return buf.Append ("operator ++");
case "op_True":
return buf.Append ("operator true");
case "op_False":
return buf.Append ("operator false");
case "op_Equality":
return buf.Append ("operator ==");
case "op_Inequality":
return buf.Append ("operator !=");
case "op_LessThan":
return buf.Append ("operator <");
case "op_LessThanOrEqual":
return buf.Append ("operator <=");
case "op_GreaterThan":
return buf.Append ("operator >");
case "op_GreaterThanOrEqual":
return buf.Append ("operator >=");
default:
return base.AppendMethodName (buf, method);
}
}
else
return base.AppendMethodName (buf, method);
}
protected override StringBuilder AppendGenericMethodConstraints (StringBuilder buf, MethodDefinition method)
{
if (method.GenericParameters.Count == 0)
return buf;
return AppendConstraints (buf, method.GenericParameters);
}
protected override string RefTypeModifier
{
get { return ""; }
}
protected override string GetFinalizerName (MethodDefinition method)
{
StringBuilder buf = new StringBuilder();
base.AppendTypeName(buf, method.DeclaringType.Name);
return $"~{buf} ()";
}
protected override StringBuilder AppendVisibility (StringBuilder buf, MethodDefinition method)
{
if (method == null)
return buf;
if (method.IsPublic)
return buf.Append ("public");
if (method.IsFamily)
return buf.Append ("protected");
if (method.IsFamilyOrAssembly)
return buf.Append("protected internal");
return buf;
}
protected override StringBuilder AppendModifiers (StringBuilder buf, MethodDefinition method)
{
string modifiers = String.Empty;
if (method.IsStatic) modifiers += " static";
if (method.IsVirtual && !method.IsAbstract)
{
if ((method.Attributes & MethodAttributes.NewSlot) != 0) modifiers += " virtual";
else modifiers += " override";
}
TypeDefinition declType = (TypeDefinition)method.DeclaringType;
if (method.IsAbstract && !declType.IsInterface) modifiers += " abstract";
if (method.IsFinal) modifiers += " sealed";
if (modifiers == " virtual sealed") modifiers = "";
if ((method.ReturnType.IsRequiredModifier
&& ((RequiredModifierType)method.ReturnType).ElementType.IsByReference)
|| method.ReturnType.IsByReference)
{
modifiers += " ref";
}
if (method.ReturnType.IsRequiredModifier
&& method.MethodReturnType.CustomAttributes.Any(attr => attr.AttributeType.FullName == "System.Runtime.CompilerServices.IsReadOnlyAttribute"))
{
modifiers += " readonly";
}
switch (method.Name)
{
case "op_Implicit":
modifiers += " implicit operator";
break;
case "op_Explicit":
modifiers += " explicit operator";
break;
}
return buf.Append (modifiers);
}
protected override StringBuilder AppendGenericMethod (StringBuilder buf, MethodDefinition method)
{
if (method.IsGenericMethod ())
{
IList<GenericParameter> args = method.GenericParameters;
if (args.Count > 0)
{
buf.Append ("<");
buf.Append (args[0].Name);
for (int i = 1; i < args.Count; ++i)
buf.Append (",").Append (args[i].Name);
buf.Append (">");
}
}
return buf;
}
protected override StringBuilder AppendParameters (StringBuilder buf, MethodDefinition method, IList<ParameterDefinition> parameters)
{
return AppendParameters (buf, method, parameters, '(', ')');
}
private StringBuilder AppendParameters (StringBuilder buf, MethodDefinition method, IList<ParameterDefinition> parameters, char begin, char end)
{
buf.Append (begin);
if (parameters.Count > 0)
{
if (DocUtils.IsExtensionMethod (method))
buf.Append ("this ");
AppendParameter (buf, parameters[0]);
for (int i = 1; i < parameters.Count; ++i)
{
buf.Append (", ");
AppendParameter (buf, parameters[i]);
}
}
return buf.Append (end);
}
private StringBuilder AppendParameter (StringBuilder buf, ParameterDefinition parameter)
{
if (parameter.ParameterType is ByReferenceType)
{
if (parameter.IsOut)
buf.Append ("out ");
else
buf.Append ("ref ");
}
if (parameter.HasCustomAttributes)
{
var isParams = parameter.CustomAttributes.Any (ca => ca.AttributeType.Name == "ParamArrayAttribute");
if (isParams)
buf.AppendFormat ("params ");
}
buf.Append (GetTypeName (parameter.ParameterType, new DynamicParserContext (parameter))).Append (" ");
buf.Append (parameter.Name);
if (parameter.HasDefault && parameter.IsOptional && parameter.HasConstant)
{
buf.AppendFormat (" = {0}", MDocUpdater.MakeAttributesValueString (parameter.Constant, parameter.ParameterType));
}
return buf;
}
protected override string GetPropertyDeclaration (PropertyDefinition property)
{
MethodDefinition method;
string get_visible = null;
if ((method = property.GetMethod) != null &&
(DocUtils.IsExplicitlyImplemented (method) ||
(!method.IsPrivate && !method.IsAssembly && !method.IsFamilyAndAssembly)))
get_visible = AppendVisibility (new StringBuilder (), method).ToString ();
string set_visible = null;
if ((method = property.SetMethod) != null &&
(DocUtils.IsExplicitlyImplemented (method) ||
(!method.IsPrivate && !method.IsAssembly && !method.IsFamilyAndAssembly)))
set_visible = AppendVisibility (new StringBuilder (), method).ToString ();
if ((set_visible == null) && (get_visible == null))
return null;
string visibility;
StringBuilder buf = new StringBuilder ();
if (get_visible != null && (set_visible == null || (set_visible != null && get_visible == set_visible)))
buf.Append (visibility = get_visible);
else if (set_visible != null && get_visible == null)
buf.Append (visibility = set_visible);
else
buf.Append (visibility = "public");
// Pick an accessor to use for static/virtual/override/etc. checks.
method = property.SetMethod;
if (method == null)
method = property.GetMethod;
string modifiers = String.Empty;
if (method.IsStatic) modifiers += " static";
if (method.IsVirtual && !method.IsAbstract)
{
if ((method.Attributes & MethodAttributes.NewSlot) != 0)
modifiers += " virtual";
else
modifiers += " override";
}
TypeDefinition declDef = (TypeDefinition)method.DeclaringType;
if (method.IsAbstract && !declDef.IsInterface)
modifiers += " abstract";
if (method.IsFinal)
modifiers += " sealed";
if (modifiers == " virtual sealed")
modifiers = "";
buf.Append (modifiers).Append (' ');
buf.Append (GetTypeName (property.PropertyType, new DynamicParserContext (property))).Append (' ');
IEnumerable<MemberReference> defs = property.DeclaringType.GetDefaultMembers ();
string name = property.Name;
foreach (MemberReference mi in defs)
{
if (mi == property)
{
name = "this";
break;
}
}
buf.Append (name == "this" ? name : DocUtils.GetPropertyName (property, NestedTypeSeparator));
if (property.Parameters.Count != 0)
{
AppendParameters (buf, method, property.Parameters, '[', ']');
}
buf.Append (" {");
if (get_visible != null)
{
if (get_visible != visibility)
buf.Append (' ').Append (get_visible);
buf.Append (" get;");
}
if (set_visible != null)
{
if (set_visible != visibility)
buf.Append (' ').Append (set_visible);
buf.Append (" set;");
}
buf.Append (" }");
return buf[0] != ' ' ? buf.ToString () : buf.ToString (1, buf.Length - 1);
}
protected override string GetFieldDeclaration (FieldDefinition field)
{
TypeDefinition declType = (TypeDefinition)field.DeclaringType;
if (declType.IsEnum && field.Name == "value__")
return null; // This member of enums aren't documented.
StringBuilder buf = new StringBuilder ();
AppendFieldVisibility (buf, field);
if (buf.Length == 0)
return null;
if (declType.IsEnum)
return field.Name;
if (field.IsStatic && !field.IsLiteral)
buf.Append (" static");
if (field.IsInitOnly)
buf.Append (" readonly");
if (field.IsLiteral)
buf.Append (" const");
buf.Append (' ').Append (GetTypeName (field.FieldType, new DynamicParserContext (field))).Append (' ');
buf.Append (field.Name);
DocUtils.AppendFieldValue (buf, field);
buf.Append (';');
return buf.ToString ();
}
static void AppendFieldVisibility (StringBuilder buf, FieldDefinition field)
{
if (field.IsPublic)
{
buf.Append("public");
return;
}
if (field.IsFamily)
{
buf.Append("protected");
}
if ( field.IsFamilyOrAssembly)
{
buf.Append("protected internal");
}
}
protected override string GetEventDeclaration (EventDefinition e)
{
StringBuilder buf = new StringBuilder ();
if (AppendVisibility (buf, e.AddMethod).Length == 0 && !IsPublicEII (e))
{
return null;
}
if (e.DeclaringType.IsInterface)
buf.Clear ();
AppendModifiers (buf, e.AddMethod);
buf.Append (buf.Length == 0 ? "event " : " event ");
buf.Append (GetTypeName (e.EventType, new DynamicParserContext (e.AddMethod.Parameters[0]))).Append (' ');
buf.Append (e.Name).Append (';');
return buf.ToString ();
}
}
}

View File

@ -0,0 +1,14 @@
using System.Text;
using Mono.Cecil;
namespace Mono.Documentation.Updater
{
public class CSharpMemberFormatter : CSharpFullMemberFormatter
{
protected override StringBuilder AppendNamespace (StringBuilder buf, TypeReference type)
{
return buf;
}
}
}

View File

@ -0,0 +1,26 @@
namespace Mono.Documentation.Updater
{
class CSharpNativeTypeMemberFormatter : CSharpFullMemberFormatter
{
protected override string GetCSharpType (string t)
{
string moddedType = base.GetCSharpType (t);
switch (moddedType)
{
case "int": return "nint";
case "uint":
return "nuint";
case "float":
return "nfloat";
case "System.Drawing.SizeF":
return "CoreGraphics.CGSize";
case "System.Drawing.PointF":
return "CoreGraphics.CGPoint";
case "System.Drawing.RectangleF":
return "CoreGraphics.CGPoint";
}
return null;
}
}
}

View File

@ -0,0 +1,576 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Mono.Cecil;
using Mono.Documentation.Util;
namespace Mono.Documentation.Updater.Formatters.CppFormatters
{
public class CppCxFullMemberFormatter : CppFullMemberFormatter
{
public override string Language => Consts.CppCx;
protected override string RefTypeModifier => " & ";
protected readonly IEnumerable<string> ValueClassPropertyTypeAllowed = new List<string>()
{
"System.String",
"Platform.IBox<T>",
//fundamental numeric types
"System.SByte",
"System.Byte",
"System.Int16",
"System.UInt16",
"System.Int32",
"System.UInt32",
"System.Int64",
"System.UInt64",
"System.Single",
"System.Double",
"System.Decimal"
};
protected readonly IEnumerable<string> CustomAttributesFieldTypesAllowed = new List<string>()
{
"System.Int32",
"System.UInt32",
"System.Boolean",
"System.String",
"Windows.Foundation.HResult",
"Platform.Type"
};
protected static readonly IEnumerable<string> AllowedFundamentalTypes = new List<string>()
{
//fundamental numeric types
"System.Byte",
"System.Int16",
"System.UInt16",
"System.Int32",
"System.UInt32",
"System.Int64",
"System.UInt64",
"System.Single",
"System.Double",
"System.SByte",
//other fundamental types
"System.Object",
"System.Boolean",
"System.Char",
"System.Void",
"System.String",
"System.ValueType",
"System.Enum",
};
protected virtual IList<string> GetAllowedTypes()
{
return new List<string>(AllowedFundamentalTypes)
{
"System.Delegate",
"System.MulticastDelegate",
"System.Type",
"System.Attribute"
};
}
protected readonly IEnumerable<string> CppCxSpecificNamespases = new List<string>()
{
"Platform",
"Platform.Collections",
"Platform.Collections.Details",
"Platform.Details",
"Platform.Metadata",
"Platform.Runtime.CompilerServices",
"Platform.Runtime.InteropServices",
"Windows.Foundation.Collections"
};
protected override StringBuilder AppendNamespace(StringBuilder buf, TypeReference type)
{
string ns = DocUtils.GetNamespace(type, NestedTypeSeparator);
if (GetCppType(type.FullName) == null && !string.IsNullOrEmpty(ns) && ns != "System")
buf.Append(ns).Append(NestedTypeSeparator);
return buf;
}
protected override string GetCppType(string t)
{
// make sure there are no modifiers in the type string (add them back before returning)
string typeToCompare = t;
string[] splitType = null;
if (t.Contains(' '))
{
splitType = t.Split(' ');
typeToCompare = splitType[0];
}
switch (typeToCompare)
{
case "System.Byte": typeToCompare = "byte"; break;
case "System.Int16": typeToCompare = "short"; break;
case "System.Int32": typeToCompare = "int"; break;
case "System.Int64": typeToCompare = "long long"; break;
case "System.UInt16": typeToCompare = "unsigned short"; break;
case "System.UInt32": typeToCompare = "unsigned int"; break;
case "System.UInt64": typeToCompare = "unsigned long long"; break;
case "System.Single": typeToCompare = "float"; break;
case "System.Double": typeToCompare = "double"; break;
case "System.Boolean": typeToCompare = "bool"; break;
case "System.Char": typeToCompare = "char16"; break;
case "System.Void": typeToCompare = "void"; break;
case "System.String": typeToCompare = "Platform::String"; break;
case "System.Object": typeToCompare = "Platform::Object"; break;
case "System.Type": typeToCompare = "Platform::Type"; break;
case "System.Attribute": typeToCompare = "Platform::Metadata::Attribute"; break;
}
if (splitType != null)
{
// re-add modreq/modopt if it was there
splitType[0] = typeToCompare;
typeToCompare = string.Join(" ", splitType);
}
return typeToCompare == t ? null : typeToCompare;
}
protected override StringBuilder AppendArrayTypeName(StringBuilder buf, TypeReference type,
DynamicParserContext context)
{
buf.Append("Platform::Array <");
var item = type is TypeSpecification spec ? spec.ElementType : type.GetElementType();
_AppendTypeName(buf, item, context);
AppendHat(buf, item);
if (type is ArrayType arrayType)
{
int rank = arrayType.Rank;
if (rank > 1)
{
buf.AppendFormat(", {0}", rank);
}
}
buf.Append(">");
return buf;
}
protected override string GetTypeDeclaration(TypeDefinition type)
{
string visibility = GetTypeVisibility(type.Attributes);
if (visibility == null)
return null;
StringBuilder buf = new StringBuilder();
if (!visibility.Contains(":"))
{
AppendWebHostHiddenAttribute(buf, type);
}
buf.Append(visibility);
buf.Append(" ");
if (visibility.Contains(":"))
{
AppendWebHostHiddenAttribute(buf, type);
}
CppFullMemberFormatter full = new CppCxFullMemberFormatter();
if (DocUtils.IsDelegate(type))
{
buf.Append("delegate ");
MethodDefinition invoke = type.GetMethod("Invoke");
buf.Append(full.GetNameWithOptions(invoke.ReturnType)).Append(" ");
buf.Append(GetNameWithOptions(type, false, false));
AppendParameters(buf, invoke, invoke.Parameters);
buf.Append(";");
return buf.ToString();
}
buf.Append(GetTypeKind(type));
buf.Append(" ");
buf.Append(GetCppType(type.FullName) == null
? GetNameWithOptions(type, false, false)
: type.Name);
if (type.IsAbstract && !type.IsInterface)
buf.Append(" abstract");
if (type.IsSealed && !DocUtils.IsDelegate(type) && !type.IsValueType)
buf.Append(" sealed");
if (!type.IsEnum)
{
TypeReference basetype = type.BaseType;
if (basetype != null && basetype.FullName == "System.Object" || type.IsValueType) // FIXME
basetype = null;
List<string> interfaceNames;
try
{
//for c++/cx Resolve() can fail as Cecil understands CX types as .net (eg, "System.Attribute" instead of "Platform::Metadata::Attribute")
interfaceNames = DocUtils.GetUserImplementedInterfaces(type)
.Select(iface => full.GetNameWithOptions(iface, true, false))
.OrderBy(s => s)
.ToList();
}
catch
{
interfaceNames = null;
}
if (basetype != null || interfaceNames?.Count > 0)
buf.Append(" : ");
if (basetype != null)
{
var appendValue = GetCppType(basetype.FullName);
buf.Append(appendValue ?? full.GetNameWithOptions(basetype, true, false));
if (interfaceNames?.Count > 0)
buf.Append(", ");
}
for (int i = 0; i < interfaceNames?.Count; i++)
{
if (i != 0)
buf.Append(", ");
buf.Append(interfaceNames?[i]);
}
}
return buf.ToString();
}
public void AppendWebHostHiddenAttribute(StringBuilder buf, TypeDefinition typeDef)
{
//public unsealed ref class needs to be marked with attribute
//to ensure that is not visible to UWP apps that are written in JavaScript
if (typeDef.IsClass && !typeDef.IsSealed && (typeDef.IsPublic || typeDef.IsNestedPublic) && typeDef.CustomAttributes.All(x => x.GetDeclaringType() != "Windows.Foundation.Metadata.WebHostHiddenAttribute"))
{
buf.Append("[Windows::Foundation::Metadata::WebHostHidden]").Append(GetLineEnding());
}
}
protected override StringBuilder AppendExplisitImplementationMethod(StringBuilder buf, MethodDefinition method)
{
if(IsExplicitlyImplemented(method))
{
buf.Append(" = ");
var interfaceMethodReference = method.Overrides.FirstOrDefault();
buf.Append(GetTypeNameWithOptions(interfaceMethodReference?.DeclaringType, !AppendHatOnReturn, true))
.Append(NestedTypeSeparator);
buf.Append(interfaceMethodReference?.Name);
}
return buf;
}
protected override string AppendSealedModifiers(string modifiersString, MethodDefinition method)
{
if (!IsExplicitlyImplemented(method))
{
if (method.IsFinal) modifiersString += " sealed";
if (modifiersString == " virtual sealed") modifiersString = "";
}
return modifiersString;
}
private bool IsExplicitlyImplemented(MethodDefinition method)
{
if (!method.HasOverrides) return false;
//apply logic for explicit implementation of interface methods
var interfaceMethodReference = method.Overrides.FirstOrDefault();
if (interfaceMethodReference != null
//need to filter UWP specific interfaces, generated by default
//eg from decompile, public sealed class Class1 : __IClass1PublicNonVirtuals, __IClass1ProtectedNonVirtuals
&& !Regex.IsMatch(interfaceMethodReference.DeclaringType.Name,
$"^.*{method.DeclaringType.Name}.*Virtual.*$"))
{
return true;
}
return false;
}
public override bool IsSupported(TypeReference tref)
{
if (HasNestedClassesDuplicateNames(tref))
return false;
var allowedTypes = GetAllowedTypes();
//no support of jagged arrays
if (tref is ArrayType)
{
var typeOfArray= tref is TypeSpecification spec ? spec.ElementType : tref.GetElementType();
if (typeOfArray is ArrayType)
{
return false;
}
if (allowedTypes.Contains(typeOfArray.FullName) ||
CppCxSpecificNamespases.Contains(typeOfArray.Namespace))
{
return true;
}
}
if (allowedTypes.Contains(tref.FullName.Split(' ')[0]) || CppCxSpecificNamespases.Contains(tref.Namespace))
{
return true;
}
var ns = DocUtils.GetNamespace(tref);
var typedef = tref.Resolve();
if (typedef != null)
{
if (DocUtils.IsDelegate(typedef))
{
if (typedef.HasGenericParameters && typedef.IsPublic)
//generic delegates cannot be declared as public
return false;
return
//check types of delegate signature
IsSupported(typedef.GetMethod("Invoke"))
//check type
&& base.IsSupported(tref) && ! (ns.StartsWith("System.") || ns.StartsWith("System"));
}
if (typedef.IsInterface && typedef.HasGenericParameters &&
typedef.GenericParameters.Any(x => x.HasConstraints
|| x.HasReferenceTypeConstraint
|| x.HasDefaultConstructorConstraint
|| x.HasNotNullableValueTypeConstraint)
)
{
//generic interface - Type parameters cannot be constrained
return false;
}
if (HasUnsupportedParent(typedef))
{
return false;
}
var typeVisibility = typedef.Attributes & TypeAttributes.VisibilityMask;
if (typeVisibility == TypeAttributes.Public
//all public types, including those in your own code, must be declared in a namespace
&& (string.IsNullOrEmpty(ns)
//public standard C++ types are not allowed
|| ns.StartsWith("std") || ns.StartsWith("cli"))
)
{
return false;
}
if (typeVisibility == TypeAttributes.NestedPublic
&& (typedef.IsEnum || typedef.IsClass)
)
{
//no support of nested public classes/enums
return false;
}
if (typedef.IsClass && typeVisibility == TypeAttributes.Public && typedef.HasGenericParameters)
{
//Public ref classes that have type parameters (generics) are not permitted.
return false;
}
if (typedef.IsClass && typeVisibility == TypeAttributes.Public)
{
//A public ref class that has a public constructor must also be declared as sealed
//to prevent further derivation through the application binary interface (ABI).
if (typedef.Methods.Any(x => x.IsConstructor && x.IsPublic) && !typedef.IsSealed)
{
return false;
}
}
if (typedef.IsValueType && !typedef.IsEnum && typedef.Fields.Any(x =>
!ValueClassPropertyTypeAllowed.Contains(x.FieldType.FullName) && !(x.FieldType.Resolve() != null && x.FieldType.Resolve().IsEnum)))
{
//A value struct or value class can contain as fields only
//fundamental numeric types, enum classes, Platform::String^, or Platform::IBox <T>^
return false;
}
bool condition;
try
{
//custom attribute can contain only public fields and only with allowed types or enums
condition = IsCustomAttribute(typedef)
&& (typedef.Fields.Any(z =>
!CustomAttributesFieldTypesAllowed.Contains(z.FieldType.FullName)
&& !(z.FieldType.Resolve() != null && z.FieldType.Resolve().IsEnum)
)
|| typedef.Properties.Count != 0
|| typedef.Methods.Count(x => !x.IsConstructor) != 0
|| typedef.Events.Count != 0
);
}
catch
{
condition = false;
}
if (condition)
{
//custom attribute can contain only public fields and only with allowed types or enums
return false;
}
}
//cannot support .Net types
return !ns.StartsWith("System.") && !ns.Equals("System") && base.IsSupported(tref);
}
protected bool HasUnsupportedParent(TypeDefinition typedef)
{
var collect = new List<TypeDefinition>();
TypeReference baseTypeReference = typedef.BaseType;
TypeDefinition basetypeDefenition = null;
var allowedTypes = GetAllowedTypes();
try
{
//iterate through all classes in in inheritance hierarhy to exclude usage of .net types
basetypeDefenition = baseTypeReference?.Resolve();
while (basetypeDefenition != null)
{
if (allowedTypes.Contains(basetypeDefenition.FullName) || basetypeDefenition.BaseType == null)
{
break;
}
collect.Add(basetypeDefenition);
//needs to call Resolve to grab all base classes
basetypeDefenition = basetypeDefenition.BaseType?.Resolve();
}
}
catch (Exception)
{
//for c++/cx Resolve() can fail as Cecil understands types as .net (eg, "System.Attribute" instead of "Platform::Metadata::Attribute")
//needs to ignore those errors
baseTypeReference = basetypeDefenition?.BaseType ?? baseTypeReference;
}
if (collect.Any(x => DocUtils.GetNamespace(x).StartsWith("System.") || DocUtils.GetNamespace(x).Equals("System"))
|| !allowedTypes.Contains(baseTypeReference?.FullName)
&& (
DocUtils.GetNamespace(baseTypeReference).StartsWith("System.")
|| DocUtils.GetNamespace(baseTypeReference).Equals("System")
)
)
//can only be Windows Runtime types(no support for .net types)
return true;
try
{
IEnumerable<TypeReference> interfaceNames = DocUtils.GetUserImplementedInterfaces(typedef).ToList();
if (interfaceNames.Any(x => DocUtils.GetNamespace(x).StartsWith("System.") || DocUtils.GetNamespace(x).Equals("System")))
{
//can only be Windows Runtime types(no support for .net types)
return true;
}
}
catch
{
//for c++/cx Resolve() can fail as Cecil understands types as .net (eg, "System.Attribute" instead of "Platform::Metadata::Attribute")
//needs to ignore those errors
}
return false;
}
public override bool IsSupportedField(FieldDefinition fdef)
{
bool isEnumFieldType;
try
{
var typedef = fdef.FieldType.Resolve();
if (typedef != null)
isEnumFieldType = typedef.IsEnum;
else
isEnumFieldType = false;
}
catch
{
//for c++/cx Resolve() can fail as Cecil understands types as .net (eg, "System.Attribute" instead of "Platform::Metadata::Attribute")
//needs to ignore those errors
isEnumFieldType = false;
}
if (IsCustomAttribute(fdef.DeclaringType))
{
return !CustomAttributesFieldTypesAllowed.Contains(fdef.FieldType.FullName) ||
!isEnumFieldType;
}
if (fdef.IsPublic && fdef.DeclaringType.IsClass && !fdef.DeclaringType.IsValueType && !fdef.DeclaringType.IsEnum)
{
//Public fields are not allowed in ref class
return false;
}
//todo: no const members - which can be??
//const member functions + pointers
return base.IsSupportedField(fdef);
}
public override bool IsSupportedProperty(PropertyDefinition pdef)
{
var propVisibility = GetPropertyVisibility(pdef, out _, out _);
if ((propVisibility.Contains("public:")
|| propVisibility.Contains("protected:"))
&& pdef.Parameters.Count > 0)
//no support of public indexed property
return false;
return base.IsSupportedProperty(pdef);
}
public override bool IsSupportedMethod(MethodDefinition mdef)
{
if (mdef.Parameters.Any(IsParamsParameter))
{
return false;
}
return base.IsSupportedMethod(mdef);
}
private bool IsCustomAttribute(TypeDefinition typedef)
{
var containingTypeNamespace = DocUtils.GetNamespace(typedef);
if (typedef.BaseType?.FullName == "System.Attribute" && !containingTypeNamespace.StartsWith("System.") && !containingTypeNamespace.StartsWith("System"))
{
return true;
}
return false;
}
}
}

View File

@ -0,0 +1,13 @@
using System.Text;
using Mono.Cecil;
namespace Mono.Documentation.Updater.Formatters.CppFormatters
{
public class CppCxMemberFormatter : CppCxFullMemberFormatter
{
protected override StringBuilder AppendNamespace (StringBuilder buf, TypeReference type)
{
return buf;
}
}
}

View File

@ -0,0 +1,14 @@
using System.Text;
using Mono.Cecil;
using Mono.Documentation.Updater.CppFormatters;
namespace Mono.Documentation.Updater.Formatters.CppFormatters
{
public class CppMemberFormatter : CppFullMemberFormatter
{
protected override StringBuilder AppendNamespace (StringBuilder buf, TypeReference type)
{
return buf;
}
}
}

View File

@ -0,0 +1,348 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mono.Cecil;
using Mono.Documentation.Updater.Formatters.CppFormatters;
namespace Mono.Documentation.Updater.CppFormatters
{
public class CppWinRtFullMemberFormatter : CppCxFullMemberFormatter
{
protected override bool AppendHatOnReturn => false;
protected override string HatModifier => $" const{RefTypeModifier}";
public override string Language => Consts.CppWinRt;
protected override string RefTypeModifier => " &";
protected override IList<string> GetAllowedTypes()
{
return new List<string>(AllowedFundamentalTypes);
}
protected override StringBuilder AppendNamespace(StringBuilder buf, TypeReference type)
{
var @namespace=base.AppendNamespace(buf, type);
if (@namespace.ToString().StartsWith($"Windows{NestedTypeSeparator}"))
{
buf.Insert(0, $"winrt{NestedTypeSeparator}");
}
return @namespace;
}
protected override string GetCppType(string t)
{
// make sure there are no modifiers in the type string (add them back before returning)
string typeToCompare = t;
string[] splitType = null;
if (t.Contains(' '))
{
splitType = t.Split(' ');
typeToCompare = splitType[0];
foreach (var str in splitType)
{
if (str == "modopt(System.Runtime.CompilerServices.IsLong)" && typeToCompare == "System.Int32")
return "long";
if (str == "modopt(System.Runtime.CompilerServices.IsSignUnspecifiedByte)" &&
typeToCompare == "System.SByte")
return "char";
}
}
switch (typeToCompare)
{
case "System.Byte": typeToCompare = "byte"; break;
case "System.Int16": typeToCompare = "short"; break;
case "System.Int32": typeToCompare = "int"; break;
case "System.Int64": typeToCompare = "long"; break;
case "System.UInt16": typeToCompare = "unsigned short"; break;
case "System.UInt32": typeToCompare = "unsigned int"; break;
case "System.UInt64": typeToCompare = "unsigned long";break;
case "System.Single": typeToCompare = "float"; break;
case "System.Double": typeToCompare = "double"; break;
case "System.Boolean": typeToCompare = "bool"; break;
case "System.Char": typeToCompare = "char"; break;
case "System.Void": typeToCompare = "void"; break;
//API specific type is "winrt::hstring"; but c++ in built type is better variant
case "System.String": typeToCompare = "std::wstring"; break;
case "System.Object": typeToCompare = "winrt::Windows::Foundation::IInspectable"; break;
}
if (splitType != null)
{
// re-add modreq/modopt if it was there
splitType[0] = typeToCompare;
typeToCompare = string.Join(" ", splitType);
}
return typeToCompare == t ? null : typeToCompare;
}
protected override StringBuilder AppendParameter(StringBuilder buf, ParameterDefinition parameter)
{
if (parameter.ParameterType is ByReferenceType && parameter.IsOut)
{
//no notion of out -> mark with attribute to distinguish in other languages
buf.Append("[Runtime::InteropServices::Out] ");
}
if (parameter.HasCustomAttributes)
{
var isParams = parameter.CustomAttributes.Any(ca => ca.AttributeType.Name == "ParamArrayAttribute");
if (isParams)
buf.AppendFormat("... ");
}
buf.Append(GetTypeNameWithOptions(parameter.ParameterType, !AppendHatOnReturn)).Append(" ");
buf.Append(parameter.Name);
if (parameter.HasDefault && parameter.IsOptional && parameter.HasConstant)
{
buf.AppendFormat(" = {0}", MDocUpdater.MakeAttributesValueString(parameter.Constant, parameter.ParameterType));
}
return buf;
}
protected override string GetTypeKind(TypeDefinition t)
{
if (t.IsEnum || t.FullName == "System.Enum")
return "enum";
if (t.IsValueType)
return "struct";
if (t.IsClass)
return "class";
if (t.IsInterface)
return "__interface";
throw new ArgumentException(t.FullName);
}
protected override StringBuilder AppendArrayTypeName(StringBuilder buf, TypeReference type,
DynamicParserContext context)
{
buf.Append("std::Array <");
var item = type is TypeSpecification spec ? spec.ElementType : type.GetElementType();
_AppendTypeName(buf, item, context);
AppendHat(buf, item);
if (type is ArrayType arrayType)
{
int rank = arrayType.Rank;
if (rank > 1)
{
buf.AppendFormat(", {0}", rank);
}
}
buf.Append(">");
return buf;
}
protected override StringBuilder AppendExplisitImplementationMethod(StringBuilder buf, MethodDefinition method)
{
//no need to add additional syntax
return buf;
}
protected override string GetTypeDeclaration(TypeDefinition type)
{
StringBuilder buf = new StringBuilder();
var genericParamList = GetTypeSpecifiGenericParameters(type);
AppendGenericItem(buf, genericParamList);
AppendGenericTypeConstraints(buf, type);
AppendWebHostHiddenAttribute(buf, type);
buf.Append(GetTypeKind(type));
buf.Append(" ");
buf.Append(GetCppType(type.FullName) == null
? GetNameWithOptions(type, false, false)
: type.Name);
if (type.IsAbstract && !type.IsInterface)
buf.Append(" abstract");
if (type.IsSealed && !DocUtils.IsDelegate(type) && !type.IsValueType)
buf.Append(" sealed");
CppWinRtFullMemberFormatter full = new CppWinRtFullMemberFormatter();
if (!type.IsEnum)
{
TypeReference basetype = type.BaseType;
if (basetype != null && basetype.FullName == "System.Object" || type.IsValueType) // FIXME
basetype = null;
List<string> interfaceNames;
try
{
//for winRt Resolve() can fail as Cecil understands winRt types as .net (eg, "System.Object" cannot be resolved)
interfaceNames = DocUtils.GetUserImplementedInterfaces(type)
.Select(iface => full.GetNameWithOptions(iface, true, false))
.OrderBy(s => s)
.ToList();
}
catch
{
interfaceNames = null;
}
if (basetype != null || interfaceNames?.Count > 0)
buf.Append(" : ");
if (basetype != null)
{
buf.Append(full.GetNameWithOptions(basetype, true, false));
if (interfaceNames?.Count > 0)
buf.Append(", ");
}
for (int i = 0; i < interfaceNames?.Count; i++)
{
if (i != 0)
buf.Append(", ");
buf.Append(interfaceNames?[i]);
}
}
return buf.ToString();
}
protected override string GetTypeVisibility(TypeAttributes ta)
{
//Cannot have pubic/protected visibility since it uses native C++ which cannot be exposed
return string.Empty;
}
protected override StringBuilder AppendVisibility(StringBuilder buf, MethodDefinition method)
{
//Cannot have pubic/protected visibility since it uses native C++ which cannot be exposed
return buf;
}
protected override StringBuilder AppendFieldVisibility(StringBuilder buf, FieldDefinition field)
{
//Cannot have pubic/protected visibility since it uses native C++ which cannot be exposed
return buf;
}
protected override StringBuilder AppendGenericItem(StringBuilder buf, IList<GenericParameter> args)
{
if (args != null && args.Any())
{
buf.Append("template <typename ");
buf.Append(args[0].Name);
for (int i = 1; i < args.Count; ++i)
buf.Append(", typename ").Append(args[i].Name);
buf.Append(">");
buf.Append(GetLineEnding());
}
return buf;
}
protected override string AppendSealedModifiers(string modifiersString, MethodDefinition method)
{
if (method.IsFinal) modifiersString += " sealed";
if (modifiersString == " virtual sealed") modifiersString = "";
return modifiersString;
}
public override bool IsSupported(TypeReference tref)
{
if (HasNestedClassesDuplicateNames(tref))
return false;
var ns = DocUtils.GetNamespace(tref);
var allowedTypes = GetAllowedTypes();
if (allowedTypes.Contains(tref.FullName.Split(' ')[0])
//winRt specific namespaces so no need for further check
|| ns.StartsWith("Windows.")
)
{
return true;
}
TypeDefinition typedef = null;
try
{
typedef = tref.Resolve();
}
catch
{
//for winRt Resolve() can fail as Cecil understands winRt types as .net (eg, "System.Object" cannot be resolved)
}
if (typedef != null)
{
if(allowedTypes.Contains(typedef.FullName))
//to check type of array
return true;
if (DocUtils.IsDelegate(typedef))
{
//delegates can be used only in managed context
return false;
}
if (typedef.HasGenericParameters &&
typedef.GenericParameters.Any(x => x.HasConstraints
|| x.HasReferenceTypeConstraint
|| x.HasDefaultConstructorConstraint
|| x.HasNotNullableValueTypeConstraint)
)
{
//Type parameters cannot be constrained
return false;
}
if (HasUnsupportedParent(typedef))
{
return false;
}
}
return IsSupportedGenericParameter(tref)
&& !ns.StartsWith("System.") && !ns.Equals("System");
}
public override bool IsSupportedProperty(PropertyDefinition pdef)
{
//properties can be used only in managed context
return false;
}
public override bool IsSupportedEvent(EventDefinition edef)
{
//events can be used only in managed context
return false;
}
public override bool IsSupportedField(FieldDefinition fdef)
{
return IsSupported(fdef.FieldType);
}
public override bool IsSupportedMethod(MethodDefinition mdef)
{
if (DocUtils.IsExtensionMethod(mdef)
//no support of 'params';
//can be substituted with 'Variadic functions' hovewer it's not full equivalent(not type safe + specific mechanism for reading)
|| mdef.Parameters.Any(IsParamsParameter)
)
{
return false;
}
return
IsSupported(mdef.ReturnType)
&& mdef.Parameters.All(i => IsSupported(i.ParameterType));
}
}
}

View File

@ -0,0 +1,14 @@
using System.Text;
using Mono.Cecil;
using Mono.Documentation.Updater.CppFormatters;
namespace Mono.Documentation.Updater.Formatters.CppFormatters
{
public class CppWinRtMemberFormatter : CppWinRtFullMemberFormatter
{
protected override StringBuilder AppendNamespace(StringBuilder buf, TypeReference type)
{
return buf;
}
}
}

View File

@ -0,0 +1,13 @@
namespace Mono.Documentation.Updater
{
/// <summary>The final value formatter in the pipeline ... if no other formatter formats the value,
/// then this one will serve as the default implementation.</summary>
class DefaultAttributeValueFormatter : AttributeValueFormatter
{
public override bool TryFormatValue (object v, ResolvedTypeInfo type, out string returnvalue)
{
returnvalue = "(" + MDocUpdater.GetDocTypeFullName (type.Reference) + ") " + MDocUpdater.FilterSpecialChars(v.ToString ());
return true;
}
}
}

View File

@ -0,0 +1,27 @@

using Mono.Cecil;
using Mono.Cecil.Rocks;
using Mono.Documentation.Util;
namespace Mono.Documentation.Updater
{
class DocIdFormatter : MemberFormatter
{
public override string Language => Consts.DocId;
private SlashDocMemberFormatter slashDocMemberFormatter = new SlashDocMemberFormatter();
public override string GetDeclaration (TypeReference tref)
{
return DocCommentId.GetDocCommentId (tref.Resolve ());
}
public override string GetDeclaration (MemberReference mreference)
{
if (mreference is AttachedEventReference || mreference is AttachedPropertyReference)
{
return slashDocMemberFormatter.GetDeclaration(mreference);
}
return DocCommentId.GetDocCommentId (mreference.Resolve ());
}
}
}

View File

@ -0,0 +1,12 @@
namespace Mono.Documentation.Updater
{
class DocTypeFullMemberFormatter : MemberFormatter
{
public static readonly MemberFormatter Default = new DocTypeFullMemberFormatter ();
protected override string NestedTypeSeparator
{
get { return "+"; }
}
}
}

View File

@ -0,0 +1,14 @@
using System.Text;
using Mono.Cecil;
namespace Mono.Documentation.Updater
{
class DocTypeMemberFormatter : DocTypeFullMemberFormatter
{
protected override StringBuilder AppendNamespace (StringBuilder buf, TypeReference type)
{
return buf;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,21 @@
using System.Text;
using Mono.Cecil;
namespace Mono.Documentation.Updater
{
public class FSharpFullMemberFormatter : FSharpFormatter
{
public override string Language => Consts.FSharp;
private readonly MemberFormatter usageFormatter = new FSharpUsageFormatter();
public override MemberFormatter UsageFormatter => usageFormatter;
protected override StringBuilder AppendNamespace(StringBuilder buf, TypeReference type)
{
string ns = DocUtils.GetNamespace(type);
if (GetFSharpType(type) == null && !string.IsNullOrEmpty(ns) && ns != "System")
buf.Append(ns).Append('.');
return buf;
}
}
}

View File

@ -0,0 +1,13 @@
using System.Text;
using Mono.Cecil;
namespace Mono.Documentation.Updater
{
public class FSharpMemberFormatter : FSharpFullMemberFormatter
{
protected override StringBuilder AppendNamespace(StringBuilder buf, TypeReference type)
{
return buf;
}
}
}

View File

@ -0,0 +1,175 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mono.Cecil;
namespace Mono.Documentation.Updater
{
public class FSharpUsageFormatter : FSharpFormatter
{
private static readonly Dictionary<string, string> operatorsUsage = new Dictionary<string, string>()
{
{"~-", "-"},
{"~+", "+"},
};
protected override string GetMethodDeclaration(MethodDefinition method)
{
var buf = new StringBuilder();
var operatorBuf = new StringBuilder();
if (TryAppendOperatorName(operatorBuf, method))
{
return GetOperatorUsage(buf, method, operatorBuf.ToString());
}
if (method.IsStatic)
{
buf.Append($"{GetName(method.DeclaringType)}.{method.Name} ");
}
else
{
var typeName = AppendTypeName(new StringBuilder(), method.DeclaringType, null).ToString();
buf.Append($"{CamelCase(typeName)}.{method.Name} ");
}
AppendParameters(buf, method);
return buf.ToString();
}
private void AppendParameters(StringBuilder buf, MethodDefinition method)
{
var parameters = new List<string>();
var curryBorders = GetCurryBorders(method);
bool isExtensionMethod = IsExtensionMethod(method);
for (var i = 0; i < method.Parameters.Count; i++)
{
if (isExtensionMethod && i == 0)
continue;
if (curryBorders.Contains(i) && parameters.Count > 0)
{
AppendTupleUsage(buf, parameters);
parameters.Clear();
buf.Append(" ");
}
var parameterDefinition = method.Parameters[i];
parameters.Add(GetParameterUsage(parameterDefinition));
}
AppendTupleUsage(buf, parameters);
}
private string GetOperatorUsage(StringBuilder buf, MethodDefinition method, string operatorName)
{
var operatorMembers = operatorName.Split(' ').Skip(1).ToList();
operatorMembers = operatorMembers.Take(operatorMembers.Count - 1).ToList();// Remove '(' and ')'
for (var i = 0; i < operatorMembers.Count; i++)
{
if (operatorsUsage.ContainsKey(operatorMembers[i]))
{
operatorMembers[i] = operatorsUsage[operatorMembers[i]];
}
}
var curryBorders = GetCurryBorders(method);
var parameters = new List<string>();
if (curryBorders.Count > 0)
{// if parameters are curried
int operatorIndex = 0;
for (var i = 0; i < method.Parameters.Count; i++)
{
if (curryBorders.Contains(i))
{
AppendTupleUsage(buf, parameters);
parameters.Clear();
buf.Append(" ");
if (operatorIndex < operatorMembers.Count)
{
buf.Append(operatorMembers[operatorIndex]);
++operatorIndex;
}
buf.Append(" ");
}
var parameterDefinition = method.Parameters[i];
parameters.Add(GetParameterUsage(parameterDefinition));
}
AppendTupleUsage(buf, parameters);
}
else
{
var members = new List<string>();
for (var i = 0; i < method.Parameters.Count; i++)
{
if (method.Parameters.Count <= operatorMembers.Count)
{
if (i < operatorMembers.Count)
{
members.Add(operatorMembers[i]);
}
}
var parameterDefinition = method.Parameters[i];
members.Add(GetParameterUsage(parameterDefinition));
if (method.Parameters.Count > operatorMembers.Count)
{
if (i < operatorMembers.Count)
{
members.Add(operatorMembers[i]);
}
}
}
buf.Append(string.Join(" ", members));
}
return buf.ToString();
}
private void AppendTupleUsage(StringBuilder buf, List<string> parameters)
{
if (parameters.Count == 0)
return;
if (parameters.Count == 1)
{
buf.Append(parameters[0]);
return;
}
buf.Append($"({string.Join(", ", parameters)})");
}
private string GetParameterUsage(ParameterDefinition parameterDefinition)
{
return parameterDefinition.Name;
}
protected override string GetPropertyDeclaration(PropertyDefinition property)
{
if (DocUtils.IsExplicitlyImplemented(property))
return DocUtils.GetPropertyName(property, NestedTypeSeparator);
return $"{GetName(property.DeclaringType)}.{property.Name}";
}
protected override string GetConstructorDeclaration(MethodDefinition constructor)
{
StringBuilder buf = new StringBuilder();
if (constructor.Parameters.Count == 0)
return null;
if (AppendVisibility(buf, constructor) == null)
return null;
buf.Append("new ");
buf.Append(GetTypeName(constructor.DeclaringType));
buf.Append(" ");
AppendParameters(buf, constructor);
return buf.ToString();
}
protected override string GetFieldDeclaration(FieldDefinition field)
{
return $"{GetName(field.DeclaringType)}.{field.Name}";
}
public override bool IsSupported(TypeReference tref) => false;
}
}

View File

@ -0,0 +1,19 @@
using System.Text;
using Mono.Cecil;
namespace Mono.Documentation.Updater
{
class FileNameMemberFormatter : SlashDocMemberFormatter
{
protected override StringBuilder AppendNamespace (StringBuilder buf, TypeReference type)
{
return buf;
}
protected override string NestedTypeSeparator
{
get { return "+"; }
}
}
}

View File

@ -0,0 +1,590 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using Mono.Cecil;
using Mono.Documentation.Util;
namespace Mono.Documentation.Updater
{
public class ILFullMemberFormatter : MemberFormatter
{
public override string Language
{
get { return "ILAsm"; }
}
protected override string NestedTypeSeparator
{
get
{
return "/";
}
}
protected override StringBuilder AppendNamespace (StringBuilder buf, TypeReference type)
{
if (GetBuiltinType (type.FullName) != null)
return buf;
string ns = DocUtils.GetNamespace (type);
if (ns != null && ns.Length > 0)
{
if (type.IsValueType)
buf.Append ("valuetype ");
else
buf.Append ("class ");
buf.Append (ns).Append ('.');
}
return buf;
}
protected static string GetBuiltinType (string t)
{
switch (t)
{
case "System.Byte": return "unsigned int8";
case "System.SByte": return "int8";
case "System.Int16": return "int16";
case "System.Int32": return "int32";
case "System.Int64": return "int64";
case "System.IntPtr": return "native int";
case "System.UInt16": return "unsigned int16";
case "System.UInt32": return "unsigned int32";
case "System.UInt64": return "unsigned int64";
case "System.UIntPtr": return "native unsigned int";
case "System.Single": return "float32";
case "System.Double": return "float64";
case "System.Boolean": return "bool";
case "System.Char": return "char";
case "System.Void": return "void";
case "System.String": return "string";
case "System.Object": return "object";
}
return null;
}
protected override StringBuilder AppendTypeName (StringBuilder buf, string typename)
{
return buf.Append (typename);
}
protected override StringBuilder AppendTypeName (StringBuilder buf, TypeReference type, DynamicParserContext context)
{
if (type is GenericParameter)
{
AppendGenericParameterConstraints (buf, (GenericParameter)type).Append (type.Name);
return buf;
}
string s = GetBuiltinType (type.FullName);
if (s != null)
{
return buf.Append (s);
}
return base.AppendTypeName (buf, type, context);
}
private StringBuilder AppendGenericParameterConstraints (StringBuilder buf, GenericParameter type)
{
if (MemberFormatterState != MemberFormatterState.WithinGenericTypeParameters)
{
return buf.Append (type.Owner is TypeReference ? "!" : "!!");
}
GenericParameterAttributes attrs = type.Attributes;
if ((attrs & GenericParameterAttributes.ReferenceTypeConstraint) != 0)
buf.Append ("class ");
if ((attrs & GenericParameterAttributes.NotNullableValueTypeConstraint) != 0)
buf.Append ("struct ");
if ((attrs & GenericParameterAttributes.DefaultConstructorConstraint) != 0)
buf.Append (".ctor ");
MemberFormatterState = 0;
#if NEW_CECIL
Mono.Collections.Generic.Collection<GenericParameterConstraint> constraints = type.Constraints;
if (constraints.Count > 0)
{
var full = new ILFullMemberFormatter ();
buf.Append ("(").Append (full.GetName (constraints[0].ConstraintType));
for (int i = 1; i < constraints.Count; ++i)
{
buf.Append (", ").Append (full.GetName (constraints[i].ConstraintType));
}
buf.Append (") ");
}
#else
IList<TypeReference> constraints = type.Constraints;
if (constraints.Count > 0)
{
var full = new ILFullMemberFormatter ();
buf.Append ("(").Append (full.GetName (constraints[0]));
for (int i = 1; i < constraints.Count; ++i)
{
buf.Append (", ").Append (full.GetName (constraints[i]));
}
buf.Append (") ");
}
#endif
MemberFormatterState = MemberFormatterState.WithinGenericTypeParameters;
if ((attrs & GenericParameterAttributes.Covariant) != 0)
buf.Append ("+ ");
if ((attrs & GenericParameterAttributes.Contravariant) != 0)
buf.Append ("- ");
return buf;
}
protected override string GetTypeDeclaration (TypeDefinition type)
{
string visibility = GetTypeVisibility (type.Attributes);
if (visibility == null)
return null;
StringBuilder buf = new StringBuilder ();
buf.Append (".class ");
if (type.IsNested)
buf.Append ("nested ");
buf.Append (visibility).Append (" ");
if (type.IsInterface)
buf.Append ("interface ");
if (type.IsSequentialLayout)
buf.Append ("sequential ");
if (type.IsAutoLayout)
buf.Append ("auto ");
if (type.IsAnsiClass)
buf.Append ("ansi ");
if (type.IsAbstract)
buf.Append ("abstract ");
if (type.IsSerializable)
buf.Append ("serializable ");
if (type.IsSealed)
buf.Append ("sealed ");
if (type.IsBeforeFieldInit)
buf.Append ("beforefieldinit ");
var state = MemberFormatterState;
MemberFormatterState = MemberFormatterState.WithinGenericTypeParameters;
buf.Append (GetName (type));
MemberFormatterState = state;
var full = new ILFullMemberFormatter ();
if (type.BaseType != null)
{
buf.Append (" extends ");
if (type.BaseType.FullName == "System.Object")
buf.Append ("System.Object");
else
buf.Append (full.GetName (type.BaseType).Substring ("class ".Length));
}
bool first = true;
foreach (var name in type.Interfaces.Where (i => MDocUpdater.IsPublic (i.InterfaceType.Resolve ()))
.Select (i => full.GetName (i.InterfaceType))
.OrderBy (n => n))
{
if (first)
{
buf.Append (" implements ");
first = false;
}
else
{
buf.Append (", ");
}
buf.Append (name);
}
return buf.ToString ();
}
protected override StringBuilder AppendGenericType (StringBuilder buf, TypeReference type, DynamicParserContext context, bool appendGeneric = true)
{
List<TypeReference> decls = DocUtils.GetDeclaringTypes (
type is GenericInstanceType ? type.GetElementType () : type);
bool first = true;
foreach (var decl in decls)
{
TypeReference declDef = decl.Resolve () ?? decl;
if (!first)
{
buf.Append (NestedTypeSeparator);
}
first = false;
AppendTypeName (buf, declDef, context);
}
buf.Append ('<');
first = true;
foreach (TypeReference arg in GetGenericArguments (type))
{
if (!first)
buf.Append (", ");
first = false;
_AppendTypeName (buf, arg, context);
}
buf.Append ('>');
return buf;
}
static string GetTypeVisibility (TypeAttributes ta)
{
switch (ta & TypeAttributes.VisibilityMask)
{
case TypeAttributes.Public:
case TypeAttributes.NestedPublic:
return "public";
case TypeAttributes.NestedFamily:
case TypeAttributes.NestedFamORAssem:
return "protected";
default:
return null;
}
}
protected override string GetConstructorDeclaration (MethodDefinition constructor)
{
return GetMethodDeclaration (constructor);
}
protected override string GetMethodDeclaration (MethodDefinition method)
{
if (method.IsPrivate && !DocUtils.IsExplicitlyImplemented (method))
return null;
var buf = new StringBuilder ();
buf.Append (".method ");
AppendVisibility (buf, method);
if (method.IsStatic)
buf.Append ("static ");
if (method.IsHideBySig)
buf.Append ("hidebysig ");
if (method.IsPInvokeImpl && method.PInvokeInfo != null)
{
var info = method.PInvokeInfo;
buf.Append ("pinvokeimpl (\"")
.Append (info.Module.Name)
.Append ("\" as \"")
.Append (info.EntryPoint)
.Append ("\"");
if (info.IsCharSetAuto)
buf.Append (" auto");
if (info.IsCharSetUnicode)
buf.Append (" unicode");
if (info.IsCharSetAnsi)
buf.Append (" ansi");
if (info.IsCallConvCdecl)
buf.Append (" cdecl");
if (info.IsCallConvStdCall)
buf.Append (" stdcall");
if (info.IsCallConvWinapi)
buf.Append (" winapi");
if (info.IsCallConvThiscall)
buf.Append (" thiscall");
if (info.SupportsLastError)
buf.Append (" lasterr");
buf.Append (")");
}
if (method.IsSpecialName)
buf.Append ("specialname ");
if (method.IsRuntimeSpecialName)
buf.Append ("rtspecialname ");
if (method.IsNewSlot)
buf.Append ("newslot ");
if (method.IsVirtual)
buf.Append ("virtual ");
if (!method.IsStatic)
buf.Append ("instance ");
_AppendTypeName (buf, method.ReturnType, new DynamicParserContext (method.MethodReturnType));
buf.Append (' ')
.Append (method.Name);
if (method.IsGenericMethod ())
{
var state = MemberFormatterState;
MemberFormatterState = MemberFormatterState.WithinGenericTypeParameters;
IList<GenericParameter> args = method.GenericParameters;
if (args.Count > 0)
{
buf.Append ("<");
_AppendTypeName (buf, args[0], null);
for (int i = 1; i < args.Count; ++i)
_AppendTypeName (buf.Append (", "), args[i], null);
buf.Append (">");
}
MemberFormatterState = state;
}
buf.Append ('(');
bool first = true;
for (int i = 0; i < method.Parameters.Count; ++i)
{
var param = method.Parameters[i];
if (!first)
buf.Append (", ");
first = false;
if (param.IsOut) buf.Append ("[out] ");
else if (param.IsIn) buf.Append ("[in]");
_AppendTypeName (buf, param.ParameterType, new DynamicParserContext (param));
if (param.ParameterType.IsByReference) buf.Append ("&");
buf.Append (' ');
buf.Append (param.Name);
}
buf.Append (')');
if (method.IsIL)
buf.Append (" cil");
if (method.IsRuntime)
buf.Append (" runtime");
if (method.IsManaged)
buf.Append (" managed");
return buf.ToString ();
}
protected override StringBuilder AppendMethodName (StringBuilder buf, MethodDefinition method)
{
if (DocUtils.IsExplicitlyImplemented (method))
{
TypeReference iface;
MethodReference ifaceMethod;
DocUtils.GetInfoForExplicitlyImplementedMethod (method, out iface, out ifaceMethod);
return buf.Append (new CSharpMemberFormatter ().GetName (iface))
.Append ('.')
.Append (ifaceMethod.Name);
}
return base.AppendMethodName (buf, method);
}
protected override string RefTypeModifier
{
get { return ""; }
}
protected override StringBuilder AppendVisibility (StringBuilder buf, MethodDefinition method)
{
if (method.IsPublic)
return buf.Append ("public ");
if (method.IsFamilyAndAssembly)
return buf.Append ("familyandassembly");
if (method.IsFamilyOrAssembly)
return buf.Append ("familyorassembly");
if (method.IsFamily)
return buf.Append ("family");
return buf;
}
protected override StringBuilder AppendModifiers (StringBuilder buf, MethodDefinition method)
{
string modifiers = String.Empty;
if (method.IsStatic) modifiers += " static";
if (method.IsVirtual && !method.IsAbstract)
{
if ((method.Attributes & MethodAttributes.NewSlot) != 0) modifiers += " virtual";
else modifiers += " override";
}
TypeDefinition declType = (TypeDefinition)method.DeclaringType;
if (method.IsAbstract && !declType.IsInterface) modifiers += " abstract";
if (method.IsFinal) modifiers += " sealed";
if (modifiers == " virtual sealed") modifiers = "";
return buf.Append (modifiers);
}
protected override StringBuilder AppendGenericMethod (StringBuilder buf, MethodDefinition method)
{
if (method.IsGenericMethod ())
{
IList<GenericParameter> args = method.GenericParameters;
if (args.Count > 0)
{
buf.Append ("<");
buf.Append (args[0].Name);
for (int i = 1; i < args.Count; ++i)
buf.Append (",").Append (args[i].Name);
buf.Append (">");
}
}
return buf;
}
protected override StringBuilder AppendParameters (StringBuilder buf, MethodDefinition method, IList<ParameterDefinition> parameters)
{
return AppendParameters (buf, method, parameters, '(', ')');
}
private StringBuilder AppendParameters (StringBuilder buf, MethodDefinition method, IList<ParameterDefinition> parameters, char begin, char end)
{
buf.Append (begin);
if (parameters.Count > 0)
{
if (DocUtils.IsExtensionMethod (method))
buf.Append ("this ");
AppendParameter (buf, parameters[0]);
for (int i = 1; i < parameters.Count; ++i)
{
buf.Append (", ");
AppendParameter (buf, parameters[i]);
}
}
return buf.Append (end);
}
private StringBuilder AppendParameter (StringBuilder buf, ParameterDefinition parameter)
{
if (parameter.ParameterType is ByReferenceType)
{
if (parameter.IsOut)
buf.Append ("out ");
else
buf.Append ("ref ");
}
buf.Append (GetName (parameter.ParameterType)).Append (" ");
return buf.Append (parameter.Name);
}
protected override string GetPropertyDeclaration (PropertyDefinition property)
{
MethodDefinition gm = null, sm = null;
string get_visible = null;
if ((gm = property.GetMethod) != null &&
(DocUtils.IsExplicitlyImplemented (gm) ||
(!gm.IsPrivate && !gm.IsAssembly && !gm.IsFamilyAndAssembly)))
get_visible = AppendVisibility (new StringBuilder (), gm).ToString ();
string set_visible = null;
if ((sm = property.SetMethod) != null &&
(DocUtils.IsExplicitlyImplemented (sm) ||
(!sm.IsPrivate && !sm.IsAssembly && !sm.IsFamilyAndAssembly)))
set_visible = AppendVisibility (new StringBuilder (), sm).ToString ();
if ((set_visible == null) && (get_visible == null))
return null;
StringBuilder buf = new StringBuilder ()
.Append (".property ");
if (!(gm ?? sm).IsStatic)
buf.Append ("instance ");
_AppendTypeName (buf, property.PropertyType, new DynamicParserContext (property));
buf.Append (' ').Append (property.Name);
if (!property.HasParameters || property.Parameters.Count == 0)
return buf.ToString ();
buf.Append ('(');
bool first = true;
foreach (ParameterDefinition p in property.Parameters)
{
if (!first)
buf.Append (", ");
first = false;
_AppendTypeName (buf, p.ParameterType, new DynamicParserContext (p));
}
buf.Append (')');
return buf.ToString ();
}
protected override string GetFieldDeclaration (FieldDefinition field)
{
TypeDefinition declType = (TypeDefinition)field.DeclaringType;
if (declType.IsEnum && field.Name == "value__")
return null; // This member of enums aren't documented.
StringBuilder buf = new StringBuilder ();
AppendFieldVisibility (buf, field);
if (buf.Length == 0)
return null;
buf.Insert (0, ".field ");
if (field.IsStatic)
buf.Append ("static ");
if (field.IsInitOnly)
buf.Append ("initonly ");
if (field.IsLiteral)
buf.Append ("literal ");
_AppendTypeName (buf, field.FieldType, new DynamicParserContext (field));
buf.Append (' ').Append (field.Name);
AppendFieldValue (buf, field);
return buf.ToString ();
}
static StringBuilder AppendFieldVisibility (StringBuilder buf, FieldDefinition field)
{
if (field.IsPublic)
return buf.Append ("public ");
if (field.IsFamilyAndAssembly)
return buf.Append ("familyandassembly ");
if (field.IsFamilyOrAssembly)
return buf.Append ("familyorassembly ");
if (field.IsFamily)
return buf.Append ("family ");
return buf;
}
static StringBuilder AppendFieldValue (StringBuilder buf, FieldDefinition field)
{
// enums have a value__ field, which we ignore
if (field.DeclaringType.IsGenericType ())
return buf;
if (field.HasConstant && field.IsLiteral)
{
object val = null;
try
{
val = field.Constant;
}
catch
{
return buf;
}
if (val == null)
buf.Append (" = ").Append ("null");
else if (val is Enum)
buf.Append (" = ")
.Append (GetBuiltinType (field.DeclaringType.GetUnderlyingType ().FullName))
.Append ('(')
.Append (val.ToString ())
.Append (')');
else if (val is IFormattable)
{
string value = ((IFormattable)val).ToString (null, CultureInfo.InvariantCulture);
buf.Append (" = ");
if (val is string)
buf.Append ("\"" + value + "\"");
else
buf.Append (GetBuiltinType (field.DeclaringType.GetUnderlyingType ().FullName))
.Append ('(')
.Append (value)
.Append (')');
}
}
return buf;
}
protected override string GetEventDeclaration (EventDefinition e)
{
StringBuilder buf = new StringBuilder ();
if (AppendVisibility (buf, e.AddMethod).Length == 0 && !IsPublicEII (e))
{
return null;
}
buf.Length = 0;
buf.Append (".event ")
.Append (GetName (e.EventType))
.Append (' ')
.Append (e.Name);
return buf.ToString ();
}
}
}

View File

@ -0,0 +1,14 @@
using System.Text;
using Mono.Cecil;
namespace Mono.Documentation.Updater
{
public class ILMemberFormatter : ILFullMemberFormatter
{
protected override StringBuilder AppendNamespace (StringBuilder buf, TypeReference type)
{
return buf;
}
}
}

View File

@ -0,0 +1,10 @@
namespace Mono.Documentation.Updater
{
class ILNativeTypeMemberFormatter : ILFullMemberFormatter
{
protected static string _GetBuiltinType (string t)
{
return null;
}
}
}

View File

@ -0,0 +1,169 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mono.Cecil;
using Mono.Cecil.Rocks;
using Mono.Collections.Generic;
using Mono.Documentation.Updater;
using Mono.Documentation.Util;
namespace mdoc.Mono.Documentation.Updater.Formatters
{
public class JsFormatter : MemberFormatter
{
// For the V1 Pri1 implementation, we will not implement custom “retrievers”.
// If a non-static class doesnt have a public constructor
// (in other words, it is not possible to automatically determine the call to instantiate an instance of the class),
// the Javascript syntax should either:
//
// show a standard disclaimer such as:
// “This class does not provide a public constructor” or
// “See the remarks section for information on obtaining an instance of this class”
// Give a degenerate declarative syntax, such as simply: “Windows.System.FolderLauncherOptions” for the FolderLauncherOptions class.
// The specific solution to use here is still TBD. If youre blocked, pick A1 for now.
// We will investigate whether a Pri 2 feature to modify the syntax block with custom syntax is necessary.
public override bool IsSupported(TypeReference tref)
{
var type = tref.Resolve();
if (type == null
|| type.IsAbstract
|| type.IsInterface// Interfaces: You cannot implement a Windows Runtime interface in JavaScript.
|| type.HasGenericParameters
|| !IsSupported(type.CustomAttributes)
|| type.DeclaringType != null)//WinRT type can not be nested
{
return false;
}
if (type.IsEnum ||
type.IsValueType ||
DocUtils.IsDelegate(type))
{
if (type.IsEnum && !IsEnumSupported(type)) return false;
return true;
}
// Windows Runtime types cannot have multiple constructors with same number of arguments
var publicConstructors = type.GetConstructors().Where(i => i.IsPublic).ToList();
if (!publicConstructors.Any())
return false;
var constructorsWithEqualNumberOfArguments = publicConstructors.GroupBy(x => x.Parameters.Count)
.Where(g => g.Count() > 1)
.Select(y => y.Key)
.ToList();
return constructorsWithEqualNumberOfArguments.Count == 0;
}
protected virtual bool IsEnumSupported(TypeDefinition type)
{
return type.GetMembers().Skip(1).Any();//skip "__value element"
}
public override bool IsSupported(MemberReference mref)
{
switch (mref)
{
case PropertyDefinition propertyDefinition:
if (!IsPropertySupported(propertyDefinition))
return false;
break;
case MethodDefinition methodDefinition:
if (!IsMethodSupported(methodDefinition))
return false;
break;
case FieldDefinition _:
return false;// In WinRT fields can be exposed only by structures.
case AttachedEventDefinition _:
return false;
case AttachedPropertyDefinition _:
return false;
}
var member = mref.Resolve();
return member != null
&& !member.DeclaringType.HasGenericParameters
&& !(mref is IGenericParameterProvider genericParameterProvider && genericParameterProvider.HasGenericParameters)
&& !(mref is IMethodSignature methodSignature && methodSignature.Parameters.Any(i => i.ParameterType is GenericParameter))
&& mref.DeclaringType.DeclaringType == null//WinRT type can not be nested
&& IsSupported(member.CustomAttributes);
}
private bool IsMethodSupported(MethodDefinition methodDefinition)
{
bool isDestructor = DocUtils.IsDestructor(methodDefinition);
return
!DocUtils.IsOperator(methodDefinition)
&& (!isDestructor || methodDefinition.DeclaringType.Interfaces.Any(i => i.InterfaceType.FullName == "Windows.Foundation.IClosable"))
&& methodDefinition.Parameters.All(i => IsSupported(i.CustomAttributes) && !(i.ParameterType is ByReferenceType))
&& IsSupported(methodDefinition.MethodReturnType.CustomAttributes);
}
// How to determine if an API supports JavaScript
// Use the WebHostHidden attribute. If WebHostHidden is present, the API doesnt support JavaScript.
// None of the APIs in the “XAML” namespaces support JavaScript.
protected bool IsSupported(Collection<CustomAttribute> memberCustomAttributes)
{
return
memberCustomAttributes.All(
i => i.AttributeType.FullName != "Windows.Foundation.Metadata.WebHostHiddenAttribute");
}
protected virtual bool IsPropertySupported(PropertyDefinition property)
{
bool getVisible = property.GetMethod != null && property.GetMethod.IsPublic;
bool setVisible = property.SetMethod != null && property.SetMethod.IsPublic;
if (!setVisible && !getVisible)
return false;
IEnumerable<MemberReference> defs = property.DeclaringType.GetDefaultMembers();
foreach (MemberReference mi in defs)
{
if (mi == property)
{
return false;
}
}
return property.Parameters.Count == 0;
}
protected override StringBuilder AppendParameters(StringBuilder buf, MethodDefinition method, IList<ParameterDefinition> parameters)
{
return buf.Append(string.Join(", ", parameters.Select(i => i.Name)));
}
protected MethodDefinition GetConstructor(TypeDefinition type)
{
return type.GetConstructors()
.Where(i => i.IsPublic)
.OrderByDescending(i => i.Parameters.Count)
.First();
}
protected override string GetMethodName(MethodReference method)
{
if (DocUtils.IsDestructor(method.Resolve()))
return "Close";
return CamelCase(method.Name);
}
protected override string GetTypeName(TypeReference type, DynamicParserContext context, bool appendGeneric = true)
{
int n = type.Name.IndexOf("`");
if (n >= 0)
return type.Name.Substring(0, n);
return type.Name;
}
protected string ProcessFullName(string fullName)
{
int n = fullName.IndexOf("`");
if (n >= 0)
return fullName.Substring(0, n);
return fullName;
}
}
}

View File

@ -0,0 +1,80 @@
using System.Text;
using Mono.Cecil;
using Mono.Documentation;
using Mono.Documentation.Updater;
namespace mdoc.Mono.Documentation.Updater.Formatters
{
public class JsMemberFormatter : JsFormatter
{
public override string Language => Consts.Javascript;
private readonly MemberFormatter usageFormatter = new JsUsageFormatter();
public override MemberFormatter UsageFormatter => usageFormatter;
protected override string GetMethodDeclaration(MethodDefinition method)
{
var buf = new StringBuilder();
buf.Append("function ");
buf.Append(GetMethodName(method));
buf.Append("(");
AppendParameters(buf, method, method.Parameters);
buf.Append(")");
return buf.ToString();
}
protected override string GetTypeDeclaration(TypeDefinition type)
{
// What version of ES/JS is supported? For example, we need to know what kind of syntax to use to declare a type
// [RP] This depends on your target platform.
// In UWP, its the same “version” of ES that is currently supported by the Edge browser.
// For Windows 8.0, this was IE10, and for Windows 8.1, this was IE11.
// Since Windows 10 and Edge, the browser has been evergreen, and is well into the ES2015+ versions.
var publicConstructor = GetConstructor(type);
return GetDeclaration(publicConstructor);
}
protected override string GetConstructorDeclaration(MethodDefinition constructor)
{
var buf = new StringBuilder();
buf.Append("function ");
AppendTypeName(buf, constructor.DeclaringType.Name);
buf.Append("(");
AppendParameters(buf, constructor, constructor.Parameters);
buf.Append(")");
return buf.ToString();
}
public override bool IsSupported(MemberReference mref)
{
switch (mref)
{
case PropertyDefinition _:
return false;
case EventDefinition _:
return false;
}
return base.IsSupported(mref);
}
public override bool IsSupported(TypeReference tref)
{
var type = tref.Resolve();
if (type == null)
return false;
if (type.IsEnum ||
type.IsValueType ||
DocUtils.IsDelegate(type))
return false;
return base.IsSupported(tref);
}
}
}

View File

@ -0,0 +1,246 @@
using System.Linq;
using System.Text;
using Mono.Cecil;
using Mono.Documentation;
using Mono.Documentation.Updater;
using Mono.Documentation.Util;
namespace mdoc.Mono.Documentation.Updater.Formatters
{
public class JsUsageFormatter : JsFormatter
{
public override string Language => "JavaScript (usage)";
protected override string GetPropertyDeclaration(PropertyDefinition property)
{
bool getVisible = property.GetMethod != null && property.GetMethod.IsPublic;
bool setVisible = property.SetMethod != null && property.SetMethod.IsPublic;
var method = property.SetMethod ?? property.GetMethod;
// https://github.com/mono/api-doc-tools/issues/133
// var [property value type, camel-cased] = [typename, camel-cased].[property name, camel-cased];
// [typename, camel-cased].[property name, camel-cased] = [property value type, camel-cased];
// Static properties
// var [property value type, camel-cased] = [typename].[property name, camel-cased];
// [typename].[property name, camel-cased] = [property value type, camel-cased];
var buf = new StringBuilder();
var propertyValueType = CamelCase(GetName(property.PropertyType));
var propertyName = DocUtils.GetPropertyName(property, NestedTypeSeparator);
var propertyNameCamelCased = CamelCase(propertyName);
var typeName = GetName(property.DeclaringType);
if (!method.IsStatic)
typeName = CamelCase(typeName);
if (getVisible)
{
buf.Append("var ");
buf.Append(propertyValueType);
buf.Append(" = ");
buf.Append(typeName);
buf.Append(".");
buf.Append(propertyNameCamelCased);
buf.Append(";");
}
if (setVisible)
{
if (getVisible)
buf.Append(GetLineEnding());
buf.Append(typeName);
buf.Append(".");
buf.Append(propertyNameCamelCased);
buf.Append(" = ");
buf.Append(propertyValueType);
buf.Append(";");
}
return buf.ToString();
}
protected override string GetTypeDeclaration(TypeDefinition type)
{
var buf = new StringBuilder();
if (type.IsEnum)
{
// var value = [fully qualified type].[camel-cased name of first enum value];
var firstElement = type.GetMembers().Skip(1).First();//skip "__value element"
buf.Append("var value = ");
buf.Append(ProcessFullName(type.FullName));
buf.Append(".");
buf.Append(CamelCase(firstElement.Name));
return buf.ToString();
}
if (type.IsValueType)
{
//Structures: Windows Runtime structures are objects in JavaScript.
// If you want to pass a Windows Runtime structure to a Windows Runtime method,
// don't instantiate the structure with the new keyword. Instead, create an object
// and add the relevant members and their values. The names of the members should be in camel case:
// SomeStruct.firstMember.
// var [struct name, camel cased] = {
// [fieldname, came cased] : /* Your value */
buf.Append("var ");
buf.Append(CamelCase(GetName(type)));
buf.Append(" = {");
buf.Append(GetLineEnding());
buf.Append(string.Join("," + GetLineEnding(),
type.Fields.Select(i => CamelCase(i.Name) + " : /* Your value */")));
buf.Append(GetLineEnding());
buf.Append("}");
return buf.ToString();
}
if (DocUtils.IsDelegate(type))
{
// var [delegateName, camel-cased]Handler = function([parameter name list, camel cased]){
// /* Your code */
// }
MethodDefinition invoke = type.GetMethod("Invoke");
buf.Append("var ");
buf.Append(CamelCase(GetName(type)));
buf.Append("Handler = function(");
AppendParameters(buf, invoke, invoke.Parameters);
buf.Append("){");
buf.Append(GetLineEnding());
buf.Append("/* Your code */");
buf.Append(GetLineEnding());
buf.Append("}");
return buf.ToString();
}
var publicConstructor = GetConstructor(type);
return GetDeclaration(publicConstructor);
}
protected override string GetMethodDeclaration(MethodDefinition method)
{
var buf = new StringBuilder();
if (IsAsync(method))
{
// Async Methods
// (For static methods, use the fully-qualified class name. For non-static,
// use the class name without qualification and camel-cased.)
// [fully qualified type name].[camel-cased method name]([parameter names]).done( /* Your success and error handlers */ );
var typeName = CamelCase(GetName(method.DeclaringType));
if (method.IsStatic)
typeName = ProcessFullName(method.DeclaringType.FullName);
buf.Append(typeName);
buf.Append(".");
buf.Append(GetMethodName(method));
buf.Append("(");
AppendParameters(buf, method, method.Parameters);
buf.Append(").done( /* Your success and error handlers */ )");
return buf.ToString();
}
// For static and non-static method generate different signatures:
// 1) Non-static
// Usage (not void)
// var [return type, camel-cased] = [class-name, camel-cased].[method-name, camel-cased]([parameter name list]);
// Usage (void)
// [class-name, camel-cased].[method-name, camel cased]([parameter name list]);
// 2) Static
// Usage (not void)
// var [return type, camel-cased] = [fully-qualified class-name].[method-name, camel-cased]([parameter n
// Usage (void)
// [fully-qualified class name].[method-name, camel cased]([parameter name list]);
if (method.ReturnType != null && ProcessFullName(method.ReturnType.FullName) != Consts.VoidFullName)
{
buf.Append("var ");
buf.Append(CamelCase(GetName(method.ReturnType)));
buf.Append(" = ");
}
var className = method.IsStatic ? ProcessFullName(method.DeclaringType.FullName) : CamelCase(GetName(method.DeclaringType));
buf.Append(className);
buf.Append(".");
buf.Append(CamelCase(method.Name));
buf.Append("(");
AppendParameters(buf, method, method.Parameters);
buf.Append(")");
return buf.ToString();
}
protected override string GetConstructorDeclaration(MethodDefinition constructor)
{
var buf = new StringBuilder();
var typeName = GetName(constructor.DeclaringType);
buf.Append("var ");
buf.Append(CamelCase(typeName));
buf.Append(" = new ");
buf.Append(typeName);
buf.Append("(");
AppendParameters(buf, constructor, constructor.Parameters);
buf.Append(");");
return buf.ToString();
}
private bool IsAsync(MethodDefinition method)
{
return method.CustomAttributes.Any(i => i.AttributeType.FullName == "System.Runtime.CompilerServices.AsyncStateMachineAttribute");
}
protected override StringBuilder AppendNamespace(StringBuilder buf, TypeReference type)
{
return buf;
}
protected override string GetEventDeclaration(EventDefinition e)
{
// Usage:
//function on[EventName](eventArgs){/* Your code */}
//[class name, camel cased].addEventListener(“[event name, all lower-case]”, on[EventName]);
//[class name, camel cased].removeEventListener(“[event name, all lower-case]”, on[EventName]);
// If the event supports property syntax (it has a corresponding EventName property), add this:
// - or -
//[class name, camel cased].on[event name, all lower-case] = on[EventName];
if (!e.AddMethod.IsPublic)
return null;
var className = e.AddMethod.IsStatic ? ProcessFullName(e.DeclaringType.FullName) : CamelCase(GetName(e.DeclaringType));
var eventName = e.Name;
var eventNameLowerCased = eventName.ToLower();
var buf = new StringBuilder();
buf.Append("function on");
buf.Append(e.Name);
buf.Append("(");
buf.Append("eventArgs");
buf.Append(") { /* Your code */ }");
buf.Append(GetLineEnding());
buf.Append(className);
buf.Append(".addEventListener(\"");
buf.Append(eventNameLowerCased);
buf.Append("\", on");
buf.Append(eventName);
buf.Append(");");
buf.Append(GetLineEnding());
buf.Append(className);
buf.Append(".removeEventListener(\"");
buf.Append(eventNameLowerCased);
buf.Append("\", on");
buf.Append(eventName);
buf.Append(");");
buf.Append(GetLineEnding());
buf.Append("- or -");
buf.Append(GetLineEnding());
buf.Append(className);
buf.Append(".on");
buf.Append(eventNameLowerCased);
buf.Append(" = on");
buf.Append(eventName);
buf.Append(";");
return buf.ToString();
}
}
}

View File

@ -0,0 +1,510 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mono.Documentation.Util;
using Mono.Cecil;
namespace Mono.Documentation.Updater
{
public abstract class MemberFormatter
{
public virtual string Language
{
get { return ""; }
}
public string GetName (MemberReference member, bool appendGeneric = true)
{
return GetName (member, null, appendGeneric);
}
public virtual string GetName (MemberReference member, DynamicParserContext context, bool appendGeneric = true)
{
TypeReference type = member as TypeReference;
if (type != null)
return GetTypeName (type, context, appendGeneric);
MethodReference method = member as MethodReference;
if (method != null && method.Name == ".ctor") // method.IsConstructor
return GetConstructorName (method);
if (method != null)
return GetMethodName (method);
PropertyReference prop = member as PropertyReference;
if (prop != null)
return GetPropertyName (prop);
FieldReference field = member as FieldReference;
if (field != null)
return GetFieldName (field);
EventReference e = member as EventReference;
if (e != null)
return GetEventName (e);
throw new NotSupportedException ("Can't handle: " +
(member == null ? "null" : member.GetType ().ToString ()));
}
protected virtual string GetTypeName (TypeReference type, bool appendGeneric = true)
{
return GetTypeName (type, null, appendGeneric);
}
protected virtual string GetTypeName (TypeReference type, DynamicParserContext context, bool appendGeneric=true)
{
if (type == null)
throw new ArgumentNullException (nameof (type));
var typeName = _AppendTypeName (new StringBuilder (type.Name.Length), type, context, appendGeneric).ToString ();
typeName = RemoveMod (typeName);
return typeName;
}
public static string RemoveMod (string typeName)
{
if (string.IsNullOrWhiteSpace (typeName)) return typeName;
// For custom modifiers (modopt/modreq), we are just excising them
// via string manipulation for simplicity; since these cannot be
// expressed in C#. If finer control is needed in the future, you can
// use IModifierType, PointerType, ByReferenceType, etc.
int modIndex = System.Math.Max (typeName.LastIndexOf ("modopt(", StringComparison.Ordinal), typeName.LastIndexOf ("modreq(", StringComparison.Ordinal));
if (modIndex > 0)
{
var tname = typeName.Substring (0, modIndex - 1);
var parenIndex = typeName.LastIndexOf (')');
if (parenIndex == typeName.Length - 2)
{ // see if there's metadata like a pointer
tname += typeName.Last ();
}
typeName = tname;
}
modIndex = System.Math.Max (typeName.LastIndexOf ("modopt(", StringComparison.Ordinal), typeName.LastIndexOf ("modreq(", StringComparison.Ordinal));
if (modIndex >= 0)
return RemoveMod (typeName);
else
return typeName;
}
protected virtual char[] ArrayDelimeters
{
get { return new char[] { '[', ']' }; }
}
protected virtual MemberFormatterState MemberFormatterState { get; set; }
protected virtual StringBuilder AppendArrayTypeName(StringBuilder buf, TypeReference type, DynamicParserContext context)
{
TypeSpecification spec = type as TypeSpecification;
_AppendTypeName(buf, spec != null ? spec.ElementType : type.GetElementType(), context);
return AppendArrayModifiers(buf, (ArrayType)type);
}
protected StringBuilder _AppendTypeName (StringBuilder buf, TypeReference type, DynamicParserContext context, bool appendGeneric = true)
{
if (type == null)
return buf;
if (type is ArrayType)
{
return AppendArrayTypeName(buf, type, context);
}
if (type is ByReferenceType)
{
return AppendRefTypeName (buf, type, context);
}
if (type is PointerType)
{
return AppendPointerTypeName (buf, type, context);
}
if (type is GenericParameter)
{
return AppendTypeName (buf, type, context);
}
AppendNamespace (buf, type);
GenericInstanceType genInst = type as GenericInstanceType;
if (type.IsRequiredModifier)
{
try
{
var rtype = type.Resolve ();
if (rtype != null)
type = rtype;
}
catch (Exception)
{
// Suppress resolving error for UWP libraries.
// It seems, they never have `type.IsRequiredModifier == true`, but just in case.
}
}
if (type.GenericParameters.Count == 0 &&
(genInst == null ? true : genInst.GenericArguments.Count == 0))
{
return AppendFullTypeName (buf, type, context);
}
return AppendGenericType (buf, type, context, appendGeneric);
}
protected virtual StringBuilder AppendNamespace (StringBuilder buf, TypeReference type)
{
string ns = DocUtils.GetNamespace (type);
if (ns != null && ns.Length > 0)
buf.Append (ns).Append ('.');
return buf;
}
protected virtual StringBuilder AppendFullTypeName (StringBuilder buf, TypeReference type, DynamicParserContext context)
{
if (type.DeclaringType != null)
AppendFullTypeName (buf, type.DeclaringType, context).Append (NestedTypeSeparator);
return AppendTypeName (buf, type, context);
}
protected virtual StringBuilder AppendTypeName (StringBuilder buf, TypeReference type, DynamicParserContext context)
{
if (context != null)
context.TransformIndex++;
return AppendTypeName (buf, type.Name);
}
protected virtual StringBuilder AppendTypeName (StringBuilder buf, string typename)
{
int n = typename.IndexOf ("`");
if (n >= 0)
return buf.Append (typename.Substring (0, n));
return buf.Append (typename);
}
protected virtual StringBuilder AppendArrayModifiers (StringBuilder buf, ArrayType array)
{
buf.Append (ArrayDelimeters[0]);
int rank = array.Rank;
if (rank > 1)
buf.Append (new string (',', rank - 1));
return buf.Append (ArrayDelimeters[1]);
}
protected virtual string RefTypeModifier
{
get { return "@"; }
}
protected virtual StringBuilder AppendRefTypeName (StringBuilder buf, TypeReference type, DynamicParserContext context)
{
TypeSpecification spec = type as TypeSpecification;
return _AppendTypeName(buf, spec != null ? spec.ElementType : type.GetElementType(), context);
}
protected virtual string PointerModifier
{
get { return "*"; }
}
protected virtual StringBuilder AppendPointerTypeName (StringBuilder buf, TypeReference type, DynamicParserContext context)
{
TypeSpecification spec = type as TypeSpecification;
return _AppendTypeName (buf, spec != null ? spec.ElementType : type.GetElementType (), context)
.Append (PointerModifier);
}
protected virtual string[] GenericTypeContainer
{
get { return new string[] { "<", ">" }; }
}
protected virtual string NestedTypeSeparator
{
get { return "."; }
}
protected virtual StringBuilder AppendGenericType (StringBuilder buf, TypeReference type, DynamicParserContext context, bool appendGeneric = true)
{
List<TypeReference> decls = DocUtils.GetDeclaringTypes (
type is GenericInstanceType ? type.GetElementType () : type);
List<TypeReference> genArgs = GetGenericArguments (type);
int argIdx = 0;
int prev = 0;
bool insertNested = false;
foreach (var decl in decls)
{
TypeReference declDef = decl.Resolve () ?? decl;
if (insertNested)
{
buf.Append (NestedTypeSeparator);
}
insertNested = true;
AppendTypeName (buf, declDef, context);
int ac = DocUtils.GetGenericArgumentCount (declDef);
int c = ac - prev;
prev = ac;
if ( appendGeneric && c > 0)
{
buf.Append (GenericTypeContainer[0]);
var origState = MemberFormatterState;
MemberFormatterState = MemberFormatterState.WithinGenericTypeParameters;
_AppendTypeName (buf, genArgs[argIdx++], context);
for (int i = 1; i < c; ++i)
{
_AppendTypeName (buf.Append (","), genArgs[argIdx++], context);
}
MemberFormatterState = origState;
buf.Append (GenericTypeContainer[1]);
}
}
return buf;
}
protected List<TypeReference> GetGenericArguments (TypeReference type)
{
var args = new List<TypeReference> ();
GenericInstanceType inst = type as GenericInstanceType;
if (inst != null)
args.AddRange (inst.GenericArguments);
else
args.AddRange (type.GenericParameters);
return args;
}
protected virtual StringBuilder AppendGenericTypeConstraints (StringBuilder buf, TypeReference type)
{
return buf;
}
protected virtual string GetConstructorName (MethodReference constructor)
{
return constructor.Name;
}
protected virtual string GetMethodName (MethodReference method)
{
return method.Name;
}
protected virtual string GetPropertyName (PropertyReference property)
{
return property.Name;
}
protected virtual string GetFieldName (FieldReference field)
{
return field.Name;
}
protected virtual string GetEventName (EventReference e)
{
return e.Name;
}
public virtual string GetDeclaration (TypeReference tref)
{
if (!IsSupported(tref))
return null;
var typeSpec = tref as TypeSpecification;
if (typeSpec != null && typeSpec.Resolve () == null && typeSpec.IsArray && typeSpec.ContainsGenericParameter)
{
//HACK: there's really no good reference for a generic parameter array, so we're going to use object
return "T:System.Array";
}
TypeDefinition def = tref.Resolve ();
if (def != null)
return GetTypeDeclaration (def);
else
return GetTypeName (tref);
}
public virtual string GetDeclaration (MemberReference mreference)
{
if (!IsSupported(mreference))
return null;
return GetDeclaration (mreference.Resolve ());
}
string GetDeclaration (IMemberDefinition member)
{
if (member == null)
throw new ArgumentNullException ("member");
TypeDefinition type = member as TypeDefinition;
if (type != null)
return GetTypeDeclaration (type);
MethodDefinition method = member as MethodDefinition;
if (method != null && method.IsConstructor)
return GetConstructorDeclaration (method);
if (method != null)
return GetMethodDeclaration (method);
PropertyDefinition prop = member as PropertyDefinition;
if (prop != null)
return GetPropertyDeclaration (prop);
FieldDefinition field = member as FieldDefinition;
if (field != null)
return GetFieldDeclaration (field);
EventDefinition e = member as EventDefinition;
if (e != null)
return GetEventDeclaration (e);
AttachedEventDefinition ae = member as AttachedEventDefinition;
if (ae != null)
return GetAttachedEventDeclaration (ae);
AttachedPropertyDefinition ap = member as AttachedPropertyDefinition;
if (ap != null)
return GetAttachedPropertyDeclaration (ap);
throw new NotSupportedException ("Can't handle: " + member.GetType ().ToString ());
}
protected virtual string GetTypeDeclaration (TypeDefinition type)
{
if (type == null)
throw new ArgumentNullException ("type");
StringBuilder buf = new StringBuilder (type.Name.Length);
_AppendTypeName (buf, type, null);
AppendGenericTypeConstraints (buf, type);
return buf.ToString ();
}
protected virtual string GetConstructorDeclaration (MethodDefinition constructor)
{
return GetConstructorName (constructor);
}
protected virtual string GetMethodDeclaration (MethodDefinition method)
{
if (method.HasCustomAttributes && method.CustomAttributes.Cast<CustomAttribute> ().Any (
ca => ca.GetDeclaringType () == "System.Diagnostics.Contracts.ContractInvariantMethodAttribute"))
return null;
// Special signature for destructors.
if (method.Name == "Finalize" && method.Parameters.Count == 0)
return GetFinalizerName (method);
StringBuilder buf = new StringBuilder ();
AppendVisibility (buf, method);
if (buf.Length == 0 &&
!(DocUtils.IsExplicitlyImplemented (method) && !method.IsSpecialName))
return null;
AppendModifiers (buf, method);
if (buf.Length != 0)
buf.Append (" ");
buf.Append (GetTypeName (method.ReturnType, new DynamicParserContext (method.MethodReturnType))).Append (" ");
AppendMethodName (buf, method);
AppendGenericMethod (buf, method).Append (" ");
AppendParameters (buf, method, method.Parameters);
AppendGenericMethodConstraints (buf, method);
return buf.ToString ();
}
protected virtual StringBuilder AppendMethodName (StringBuilder buf, MethodDefinition method)
{
return buf.Append (method.Name);
}
protected virtual string GetFinalizerName (MethodDefinition method)
{
return "Finalize";
}
protected virtual StringBuilder AppendVisibility (StringBuilder buf, MethodDefinition method)
{
return buf;
}
protected virtual StringBuilder AppendModifiers (StringBuilder buf, MethodDefinition method)
{
return buf;
}
protected virtual StringBuilder AppendGenericMethod (StringBuilder buf, MethodDefinition method)
{
return buf;
}
protected virtual StringBuilder AppendParameters (StringBuilder buf, MethodDefinition method, IList<ParameterDefinition> parameters)
{
return buf;
}
protected virtual StringBuilder AppendGenericMethodConstraints (StringBuilder buf, MethodDefinition method)
{
return buf;
}
protected virtual string GetPropertyDeclaration (PropertyDefinition property)
{
return GetPropertyName (property);
}
protected virtual string GetFieldDeclaration (FieldDefinition field)
{
return GetFieldName (field);
}
protected virtual string GetEventDeclaration (EventDefinition e)
{
return GetEventName (e);
}
protected virtual string GetAttachedEventDeclaration(Mono.Documentation.Util.AttachedEventDefinition e)
{
return $"see Add{e.Name}Handler, and Remove{e.Name}Handler";
}
protected virtual string GetAttachedPropertyDeclaration(AttachedPropertyDefinition a)
{
// check get and set member and craft string according
string getter = $"Get{a.Name}";
string setter = $"Set{a.Name}";
var get = a.GetMethod;
var set = a.SetMethod;
if (get != null && set == null)
return $"see {getter}";
else if (set != null && get == null)
return $"see {setter}";
else
return $"see {getter}, and {setter}";
}
public virtual bool IsSupported(TypeReference tref) => true;
public virtual bool IsSupported(MemberReference mref) => true;
protected static bool IsPublicEII (EventDefinition e)
{
bool isPublicEII = false;
if (e.AddMethod.HasOverrides)
{
var resolvedAddMethod = e.AddMethod.Overrides[0].Resolve ();
var resolvedInterface = e.AddMethod.Overrides[0].DeclaringType.Resolve ();
if (DocUtils.IsPublic (resolvedInterface) && resolvedAddMethod != null && resolvedAddMethod.IsPublic)
{
isPublicEII = true;
}
}
return isPublicEII;
}
public virtual MemberFormatter UsageFormatter { get; protected set; }
public static string GetLineEnding()
{
return "\n";
}
protected string CamelCase(string name)
{
return Char.ToLowerInvariant(name[0]) + name.Substring(1);
}
}
}

View File

@ -0,0 +1,14 @@
using System.Text;
using Mono.Cecil;
namespace Mono.Documentation.Updater
{
class MsxdocSlashDocMemberFormatter : SlashDocMemberFormatter
{
protected override StringBuilder AppendRefTypeName(StringBuilder buf, TypeReference type, DynamicParserContext context)
{
TypeSpecification spec = type as TypeSpecification;
return _AppendTypeName(buf, spec != null ? spec.ElementType : type.GetElementType(), context).Append(RefTypeModifier);
}
}
}

View File

@ -0,0 +1,38 @@
using System.Collections.Generic;
using System.Text;
using Mono.Cecil;
namespace Mono.Documentation.Updater
{
class SlashDocCSharpMemberFormatter : MsxdocSlashDocMemberFormatter
{
/// <summary>
/// C# compiler uses complecated logic to generate docIds for Eii properties. Need to have special logic here.
/// </summary>
/// <param name="property">Value to process</param>
/// <returns>DocId for property member wchich needs to be equal to docId generated by compiler's /doc flag </returns>
protected override string EiiPropertyProcessing(PropertyReference property)
{
string name;
PropertyDefinition propertyDef = property as PropertyDefinition;
MethodDefinition method = null;
if (propertyDef != null)
method = propertyDef.GetMethod ?? propertyDef.SetMethod;
if (method != null && !DocUtils.IsExplicitlyImplemented(method))
name = property.Name;
else
{
DocUtils.GetInfoForExplicitlyImplementedMethod(method, out var iface, out var ifaceMethod);
AddTypeCount = false;
name = string.Join("#", new string[]{
GetTypeName (iface).Replace (".", "#"),
DocUtils.GetMember (property.Name)
});
AddTypeCount = true;
}
return name;
}
}
}

View File

@ -0,0 +1,327 @@
using System;
using System.Collections.Generic;
using System.Text;
using Mono.Cecil;
using Mono.Documentation.Util;
namespace Mono.Documentation.Updater
{
class SlashDocMemberFormatter : MemberFormatter
{
protected override string[] GenericTypeContainer
{
get { return new string[] { "{", "}" }; }
}
protected bool AddTypeCount = true;
protected TypeReference genDeclType;
protected MethodReference genDeclMethod;
protected override StringBuilder AppendTypeName (StringBuilder buf, TypeReference type, DynamicParserContext context)
{
if (type is GenericParameter)
{
int l = buf.Length;
if (genDeclType != null)
{
IList<GenericParameter> genArgs = genDeclType.GenericParameters;
for (int i = 0; i < genArgs.Count; ++i)
{
if (genArgs[i].Name == type.Name)
{
buf.Append ('`').Append (i);
break;
}
}
}
if (genDeclMethod != null)
{
IList<GenericParameter> genArgs = null;
if (genDeclMethod.IsGenericMethod ())
{
genArgs = genDeclMethod.GenericParameters;
for (int i = 0; i < genArgs.Count; ++i)
{
if (genArgs[i].Name == type.Name)
{
buf.Append ("``").Append (i);
break;
}
}
}
}
if ((genDeclType == null && genDeclMethod == null) || buf.Length == l)
{
// Probably from within an explicitly implemented interface member,
// where CSC uses parameter names instead of indices (why?), e.g.
// MyList`2.Mono#DocTest#Generic#IFoo{A}#Method``1(`0,``0) instead of
// MyList`2.Mono#DocTest#Generic#IFoo{`0}#Method``1(`0,``0).
buf.Append (type.Name);
}
}
else
{
base.AppendTypeName (buf, type, context);
if (AddTypeCount)
{
int numArgs = type.GenericParameters.Count;
if (type.DeclaringType != null)
numArgs -= type.GenericParameters.Count;
if (numArgs > 0)
{
buf.Append ('`').Append (numArgs);
}
}
}
return buf;
}
protected override StringBuilder AppendRefTypeName (StringBuilder buf, TypeReference type, DynamicParserContext context)
{
return base.AppendRefTypeName (buf, type, context).Append (RefTypeModifier);
}
protected override StringBuilder AppendArrayModifiers (StringBuilder buf, ArrayType array)
{
buf.Append (ArrayDelimeters[0]);
int rank = array.Rank;
if (rank > 1)
{
buf.Append ("0:");
for (int i = 1; i < rank; ++i)
{
buf.Append (",0:");
}
}
return buf.Append (ArrayDelimeters[1]);
}
protected override StringBuilder AppendGenericType (StringBuilder buf, TypeReference type, DynamicParserContext context, bool appendGeneric = true)
{
if (!AddTypeCount)
base.AppendGenericType (buf, type, context);
else
AppendType (buf, type, context);
return buf;
}
private StringBuilder AppendType (StringBuilder buf, TypeReference type, DynamicParserContext context)
{
List<TypeReference> decls = DocUtils.GetDeclaringTypes (type);
bool insertNested = false;
int prevParamCount = 0;
foreach (var decl in decls)
{
if (insertNested)
buf.Append (NestedTypeSeparator);
insertNested = true;
base.AppendTypeName (buf, decl, context);
int argCount = DocUtils.GetGenericArgumentCount (decl);
int numArgs = argCount - prevParamCount;
prevParamCount = argCount;
if (numArgs > 0)
buf.Append ('`').Append (numArgs);
}
return buf;
}
protected override string GetConstructorName (MethodReference constructor)
{
return GetMethodDefinitionName (constructor, "#ctor");
}
protected override string GetMethodName (MethodReference method)
{
string name = null;
MethodDefinition methodDef = method as MethodDefinition;
if (methodDef == null || !DocUtils.IsExplicitlyImplemented (methodDef))
name = method.Name;
else
{
TypeReference iface;
MethodReference ifaceMethod;
DocUtils.GetInfoForExplicitlyImplementedMethod (methodDef, out iface, out ifaceMethod);
AddTypeCount = false;
name = GetTypeName (iface) + "." + ifaceMethod.Name;
AddTypeCount = true;
}
return GetMethodDefinitionName (method, name);
}
private string GetMethodDefinitionName (MethodReference method, string name)
{
StringBuilder buf = new StringBuilder ();
buf.Append (GetTypeName (method.DeclaringType));
buf.Append ('.');
buf.Append (name.Replace (".", "#"));
if (method.IsGenericMethod ())
{
IList<GenericParameter> genArgs = method.GenericParameters;
if (genArgs.Count > 0)
buf.Append ("``").Append (genArgs.Count);
}
IList<ParameterDefinition> parameters = method.Parameters;
try
{
genDeclType = method.DeclaringType;
genDeclMethod = method;
AppendParameters (buf, method.DeclaringType.GenericParameters, parameters);
}
finally
{
genDeclType = null;
genDeclMethod = null;
}
return buf.ToString ();
}
private StringBuilder AppendParameters (StringBuilder buf, IList<GenericParameter> genArgs, IList<ParameterDefinition> parameters)
{
if (parameters.Count == 0)
return buf;
buf.Append ('(');
AppendParameter (buf, genArgs, parameters[0]);
for (int i = 1; i < parameters.Count; ++i)
{
buf.Append (',');
AppendParameter (buf, genArgs, parameters[i]);
}
return buf.Append (')');
}
private StringBuilder AppendParameter (StringBuilder buf, IList<GenericParameter> genArgs, ParameterDefinition parameter)
{
AddTypeCount = false;
buf.Append (GetTypeName (parameter.ParameterType));
AddTypeCount = true;
return buf;
}
protected override string GetPropertyName (PropertyReference property)
{
string name = EiiPropertyProcessing(property);
StringBuilder buf = new StringBuilder ();
buf.Append (GetName (property.DeclaringType));
buf.Append ('.');
buf.Append (name);
IList<ParameterDefinition> parameters = property.Parameters;
if (parameters.Count > 0)
{
genDeclType = property.DeclaringType;
buf.Append ('(');
IList<GenericParameter> genArgs = property.DeclaringType.GenericParameters;
AppendParameter (buf, genArgs, parameters[0]);
for (int i = 1; i < parameters.Count; ++i)
{
buf.Append (',');
AppendParameter (buf, genArgs, parameters[i]);
}
buf.Append (')');
genDeclType = null;
}
return buf.ToString ();
}
/// <summary>
/// Vb, Cpp and F# compilers uses simple logic to generate docIds for Eii properties. No need to have special logic here.
/// </summary>
/// <param name="property">Value to process</param>
/// <returns>DocId for property member wchich needs to be equal to docId generated by compiler's /doc flag </returns>
protected virtual string EiiPropertyProcessing(PropertyReference property)
{
return property.Name;
}
protected override string GetFieldName (FieldReference field)
{
return string.Format ("{0}.{1}",
GetName (field.DeclaringType), field.Name);
}
protected override string GetEventName (EventReference e)
{
return string.Format ("{0}.{1}",
GetName (e.DeclaringType), e.Name);
}
protected override string GetTypeDeclaration (TypeDefinition type)
{
string name = GetName (type);
if (type == null)
return null;
return "T:" + name;
}
protected override string GetConstructorDeclaration (MethodDefinition constructor)
{
string name = GetName (constructor);
if (name == null)
return null;
return "M:" + name;
}
protected override string GetMethodDeclaration (MethodDefinition method)
{
string name = GetName (method);
if (name == null)
return null;
if (method.Name == "op_Implicit" || method.Name == "op_Explicit")
{
genDeclType = method.DeclaringType;
genDeclMethod = method;
name += "~" + GetName (method.ReturnType);
genDeclType = null;
genDeclMethod = null;
}
return "M:" + name;
}
protected override string GetPropertyDeclaration (PropertyDefinition property)
{
string name = GetName (property);
if (name == null)
return null;
return "P:" + name;
}
protected override string GetFieldDeclaration (FieldDefinition field)
{
string name = GetName (field);
if (name == null)
return null;
return "F:" + name;
}
protected override string GetEventDeclaration (EventDefinition e)
{
string name = GetName (e);
if (name == null)
return null;
return "E:" + name;
}
protected override string GetAttachedEventDeclaration(AttachedEventDefinition e)
{
string name = GetName(e);
if (name == null)
return null;
return "E:" + name;
}
protected override string GetAttachedPropertyDeclaration(AttachedPropertyDefinition a)
{
string name = GetName(a);
if (name == null)
return null;
return "P:" + name;
}
}
}

Some files were not shown because too many files have changed in this diff Show More