diff -Nru mono-addins-0.4/aclocal.m4 mono-addins-0.6.1/aclocal.m4 --- mono-addins-0.4/aclocal.m4 2008-11-06 19:52:33.000000000 +0000 +++ mono-addins-0.6.1/aclocal.m4 2011-04-13 09:45:28.000000000 +0000 @@ -13,8 +13,8 @@ m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(AC_AUTOCONF_VERSION, [2.61],, -[m4_warning([this file was generated for autoconf 2.61. +m4_if(AC_AUTOCONF_VERSION, [2.63],, +[m4_warning([this file was generated for autoconf 2.63. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) @@ -460,6 +460,35 @@ rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) +# Add --enable-maintainer-mode option to configure. -*- Autoconf -*- +# From Jim Meyering + +# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + +AC_DEFUN([AM_MAINTAINER_MODE], +[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) + dnl maintainer-mode is disabled by default + AC_ARG_ENABLE(maintainer-mode, +[ --enable-maintainer-mode enable make rules and dependencies not useful + (and sometimes confusing) to the casual installer], + USE_MAINTAINER_MODE=$enableval, + USE_MAINTAINER_MODE=no) + AC_MSG_RESULT([$USE_MAINTAINER_MODE]) + AM_CONDITIONAL(MAINTAINER_MODE, [test $USE_MAINTAINER_MODE = yes]) + MAINT=$MAINTAINER_MODE_TRUE + AC_SUBST(MAINT)dnl +] +) + +AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE]) + # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005 diff -Nru mono-addins-0.4/ChangeLog mono-addins-0.6.1/ChangeLog --- mono-addins-0.4/ChangeLog 2008-11-06 19:52:14.000000000 +0000 +++ mono-addins-0.6.1/ChangeLog 2011-04-13 09:00:29.000000000 +0000 @@ -1,3 +1,196 @@ +2010-06-08 Lluis Sanchez Gual + + * Mono.Addins.sln: Add missing projects. + +2010-06-08 Lluis Sanchez Gual + + * Mono.Addins.sln: Add missing project. + +2010-05-25 Lluis Sanchez Gual + + * Mono.Addins.sln: Fix windows build. + +2010-05-25 Lluis Sanchez Gual + + * Mono.Addins.sln: Add Debug and Release configurations. + +2010-05-25 Lluis Sanchez Gual + + * Samples/Samples.mdw: + * Samples/TextEditorSWF: Added new sample + +2010-03-24 Lluis Sanchez Gual + + * Makefile.am: + * configure.ac: + * Mono.Addins.sln: + * Mono.Addins.mdw: + * Samples/Makefile.am: + * Samples/Samples.mdw: + * Samples/TextEditorLib: + * Samples/TextEditor.Xml: + * Samples/WriterServiceHost: + * Samples/TextEditorLib/gtk-gui: + * Samples/TextEditorLib/Commands: + * Samples/TextEditorLib/ChangeLog: + * Samples/TextEditorLib/Templates: + * Samples/TextEditor.Xml/ChangeLog: + * Samples/WriterServiceHost/Main.cs: + * Samples/TextEditorLib/ICommand.cs: + * Samples/TextEditorLib/Makefile.am: + * Samples/TextEditor.CompilerService: + * Samples/TextEditor.Xml/Makefile.am: + * Samples/WriterServiceHost/ChangeLog: + * Samples/TextEditorLib/MainWindow.cs: + * Samples/TextEditor.Xml/EmptyFile.xml: + * Samples/TextEditorLib/ExtensionNodes: + * Samples/WriterService.SampleExtender: + * Samples/TextEditorLib/AssemblyInfo.cs: + * Samples/WriterServiceHost/Makefile.am: + * Samples/TextEditorLib/TextEditorApp.cs: + * Samples/TextEditor.Xml/AssemblyInfo.cs: + * Samples/TextEditorLib/gtk-gui/gui.stetic: + * Samples/TextEditor.CompilerService.CSharp: + * Samples/WriterServiceHost/AssemblyInfo.cs: + * Samples/TextEditorLib/TextEditorLib.csproj: + * Samples/TextEditorLib/gtk-gui/generated.cs: + * Samples/TextEditor.Xml/FormatXmlCommand.cs: + * Samples/TextEditorLib/OpenFileCondition.cs: + * Samples/TextEditorLib/gtk-gui/MainWindow.cs: + * Samples/TextEditor.CompilerService/ChangeLog: + * Samples/TextEditorLib/Commands/CutCommand.cs: + * Samples/TextEditorLib/Commands/NewCommand.cs: + * Samples/TextEditor.Xml/TextEditor.Xml.csproj: + * Samples/TextEditorLib/Commands/SaveCommand.cs: + * Samples/TextEditorLib/Commands/OpenCommand.cs: + * Samples/TextEditorLib/Commands/ExitCommand.cs: + * Samples/TextEditorLib/Commands/CopyCommand.cs: + * Samples/TextEditorLib/Commands/PasteCommand.cs: + * Samples/TextEditorLib/Templates/WorkReport.txt: + * Samples/TextEditor.CompilerService/Makefile.am: + * Samples/TextEditorLib/Commands/SetupCommand.cs: + * Samples/WriterService.SampleExtender/ChangeLog: + * Samples/TextEditor.CompilerService/ICompiler.cs: + * Samples/TextEditor.Xml/TextEditor.Xml.addin.xml: + * Samples/TextEditorLib/ExtensionNodes/MenuNode.cs: + * Samples/TextEditor.CompilerService/RunCommand.cs: + * Samples/WriterService.SampleExtender/Makefile.am: + * Samples/WriterService.SampleExtender/MyWriter.cs: + * Samples/TextEditor.CompilerService/AssemblyInfo.cs: + * Samples/WriterServiceHost/WriterServiceHost.csproj: + * Samples/TextEditor.CompilerService.CSharp/ChangeLog: + * Samples/TextEditorLib/ExtensionNodes/ToolbarNode.cs: + * Samples/TextEditorLib/ExtensionNodes/SubmenuNode.cs: + * Samples/WriterService.SampleExtender/AssemblyInfo.cs: + * Samples/TextEditorLib/Templates/TextEditor.addin.xml: + * Samples/TextEditorLib/ExtensionNodes/MenuItemNode.cs: + * Samples/TextEditorLib/Templates/DotConfigTemplate.txt: + * Samples/TextEditorLib/Templates/ChangeLogTemplate.txt: + * Samples/TextEditor.CompilerService/CompilerManager.cs: + * Samples/TextEditor.CompilerService.CSharp/Makefile.am: + * Samples/TextEditorLib/ExtensionNodes/ToolButtonNode.cs: + * Samples/TextEditorLib/ExtensionNodes/FileTemplateNode.cs: + * Samples/TextEditorLib/ExtensionNodes/MenuSeparatorNode.cs: + * Samples/TextEditor.CompilerService.CSharp/AssemblyInfo.cs: + * Samples/TextEditorLib/ExtensionNodes/ToolSeparatorNode.cs: + * Samples/TextEditor.CompilerService.CSharp/CSharpCompiler.cs: + * Samples/TextEditorLib/ExtensionNodes/TemplateCategoryNode.cs: + * Samples/WriterService.SampleExtender/SampleExtender.addin.xml: + * Samples/TextEditor.CompilerService/TextEditor.CompilerService.csproj: + * Samples/TextEditor.CompilerService/TextEditor.CompilerService.addin.xml: + * Samples/WriterService.SampleExtender/WriterService.SampleExtender.csproj: + * Samples/TextEditor.CompilerService.CSharp/TextEditor.CompilerService.CSharp.csproj: + Moved samples to its own solution in a Samples workspace. + + * Samples/HelloWorld: + * Samples/HelloWorldWithManifest: Added new samples. + +2009-09-01 Lluis Sanchez Gual + + * configure.ac: Bump Mono.Addins version. + +2009-08-25 Lluis Sanchez Gual + + * Mono.Addins.sln: Disable some projects on windows. + +2009-08-25 Lluis Sanchez Gual + + * Mono.Addins.sln: Fix configuration mapping. + +2009-08-25 Lluis Sanchez Gual + + * Mono.Addins.sln: Added Default configuration. + +2009-08-20 Lluis Sanchez Gual + + * Makefile.am: + * configure.ac: + * Mono.Addins.sln: + * Mono.Addins.MSBuild: Added a new project which Implements an + msbuild task for resolving add-in references. + +2009-05-29 Jonathan Pobst + + * Mono.Addins.sln: Don't build the tests under the DebugWin32 configuration. + +2009-04-15 Mike Kestner + + * */*.csproj: use correct keyfile element for signing. + +2009-03-30 Lluis Sanchez Gual + + * mono-addins-docs.source: Moved to docs. + + * configure.ac: Added option for building the docs. + + * Makefile.am: Added makefile to docs which builds and + installs the documentation. + +2009-03-30 Jonathan Pryor + + * . (svn:ignore): Ignore generated files (mono-addins-docs{.tree,.zip}). + * docs/**/*: Flush (output of doc-update). + * Makefile.am: Add doc-update, doc-assemble, install-docs, + uninstall-docs, clean-docs targets. + * mono-addins-docs.source: Monodoc .source file which specifies where + in the tree the Mono.Addins documentation should be inserted. + +2009-03-12 Mike Kestner + + * Mono.Addins.sln: add new DebugWin32 configuration to disable + the doc project build. + +2009-03-12 Mike Kestner + + * Samples/*.csproj: + * Mono.Addins.Gui/Mono.Addins.Gui.csproj: + add SpecificVersion=false to all the gtk-sharp references. + +2009-03-12 Mike Kestner + + * Mono.Addins/Mono.Addins.csproj: make target=exe since there's + a Main method and -main: argument exposed. + +2009-03-12 Mike Kestner + + * *.csproj: updates to support MSBuild on windows. + kill a few ApplicationIcon elements and update some + gtk-sharp reference versions. + +2009-02-06 Lluis Sanchez Gual + + * Mono.Addins.sln: Updated. + +2008-11-10 Lluis Sanchez Gual + + * configure.ac: Respect custom libdir during ./configure. Fixes bug + #443205. Patch by Diego Pettenò. + +2008-11-10 Lluis Sanchez Gual + + * Makefile.include: Fix building with parallel make jobs (-j8). Fixes + bug #443206. Patch by Diego Pettenò. + 2008-11-04 Lluis Sanchez Gual * configure.ac: Use a tar format with support for more than 99 chars in diff -Nru mono-addins-0.4/configure mono-addins-0.6.1/configure --- mono-addins-0.4/configure 2008-11-06 19:52:37.000000000 +0000 +++ mono-addins-0.6.1/configure 2011-04-13 09:45:30.000000000 +0000 @@ -1,9 +1,9 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.61 for mono-addins 0.4. +# Generated by GNU Autoconf 2.63 for mono-addins 0.6.1. # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## @@ -15,7 +15,7 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST @@ -37,17 +37,45 @@ as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' else - PATH_SEPARATOR=: + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' fi - rm -f conf$$.sh + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } fi # Support unset when possible. @@ -63,8 +91,6 @@ # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) -as_nl=' -' IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. @@ -87,7 +113,7 @@ as_myself=$0 fi if test ! -f "$as_myself"; then - echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 { (exit 1); exit 1; } fi @@ -100,17 +126,10 @@ PS4='+ ' # NLS nuisances. -for as_var in \ - LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ - LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ - LC_TELEPHONE LC_TIME -do - if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then - eval $as_var=C; export $as_var - else - ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var - fi -done +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1 && @@ -132,7 +151,7 @@ $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || -echo X/"$0" | +$as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q @@ -158,7 +177,7 @@ as_have_required=no fi - if test $as_have_required = yes && (eval ": + if test $as_have_required = yes && (eval ": (as_func_return () { (exit \$1) } @@ -240,7 +259,7 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST @@ -261,7 +280,7 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST @@ -341,10 +360,10 @@ if test "x$CONFIG_SHELL" != x; then for as_var in BASH_ENV ENV - do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var - done - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} + do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + done + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} fi @@ -413,9 +432,10 @@ test \$exitcode = 0") || { echo No shell found that supports shell functions. - echo Please tell autoconf@gnu.org about your system, - echo including any error possibly output before this - echo message + echo Please tell bug-autoconf@gnu.org about your system, + echo including any error possibly output before this message. + echo This can help us improve future autoconf versions. + echo Configuration will now proceed without shell functions. } @@ -451,7 +471,7 @@ s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || - { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems @@ -479,7 +499,6 @@ *) ECHO_N='-n';; esac - if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr @@ -492,19 +511,22 @@ rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir - mkdir conf$$.dir + mkdir conf$$.dir 2>/dev/null fi -echo >conf$$.file -if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else as_ln_s='cp -p' -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln + fi else as_ln_s='cp -p' fi @@ -529,10 +551,10 @@ as_test_x=' eval sh -c '\'' if test -d "$1"; then - test -d "$1/."; + test -d "$1/."; else case $1 in - -*)set "./$1";; + -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in ???[sx]*):;;*)false;;esac;fi @@ -572,91 +594,107 @@ # Identity of this package. PACKAGE_NAME='mono-addins' PACKAGE_TARNAME='mono-addins' -PACKAGE_VERSION='0.4' -PACKAGE_STRING='mono-addins 0.4' +PACKAGE_VERSION='0.6.1' +PACKAGE_STRING='mono-addins 0.6.1' PACKAGE_BUGREPORT='' -ac_subst_vars='SHELL -PATH_SEPARATOR -PACKAGE_NAME -PACKAGE_TARNAME -PACKAGE_VERSION -PACKAGE_STRING -PACKAGE_BUGREPORT -exec_prefix -prefix -program_transform_name -bindir -sbindir -libexecdir -datarootdir -datadir -sysconfdir -sharedstatedir -localstatedir -includedir -oldincludedir -docdir -infodir -htmldir -dvidir -pdfdir -psdir -libdir -localedir -mandir -DEFS -ECHO_C -ECHO_N -ECHO_T -LIBS -build_alias -host_alias -target_alias -INSTALL_PROGRAM -INSTALL_SCRIPT -INSTALL_DATA -am__isrc -CYGPATH_W -PACKAGE -VERSION -ACLOCAL -AUTOCONF -AUTOMAKE -AUTOHEADER -MAKEINFO -install_sh -STRIP -INSTALL_STRIP_PROGRAM -mkdir_p -AWK -SET_MAKE -am__leading_dot -AMTAR -am__tar -am__untar -PKG_CONFIG -API_VERSION -POLICY_VERSIONS -MCS -GACUTIL -AL -GACUTIL_FLAGS -GACUTIL_POLICY_FLAGS -ENABLE_GUI_TRUE -ENABLE_GUI_FALSE -ENABLE_TESTS_TRUE -ENABLE_TESTS_FALSE -GTK_SHARP_20_CFLAGS -GTK_SHARP_20_LIBS -MONO_NUNIT_CFLAGS -MONO_NUNIT_LIBS -MONO_ADDINS_DEFAULT_LIB -MONO_ADDINS_GUI_DEFAULT_LIB -MONO_ADDINS_SETUP_DEFAULT_LIB +ac_subst_vars='LTLIBOBJS LIBOBJS -LTLIBOBJS' +MONO_ADDINS_MSBUILD_DEFAULT_LIB +MONO_ADDINS_SETUP_DEFAULT_LIB +MONO_ADDINS_GUI_DEFAULT_LIB +MONO_ADDINS_DEFAULT_LIB +MONODOC_LIBS +MONODOC_CFLAGS +MONO_NUNIT_LIBS +MONO_NUNIT_CFLAGS +GTK_SHARP_20_LIBS +GTK_SHARP_20_CFLAGS +ENABLE_DOCS_FALSE +ENABLE_DOCS_TRUE +ENABLE_TESTS_FALSE +ENABLE_TESTS_TRUE +ENABLE_GUI_FALSE +ENABLE_GUI_TRUE +GACUTIL_POLICY_FLAGS +GACUTIL_FLAGS +AL +GACUTIL +MCS +POLICY_VERSIONS +API_VERSION +PKG_CONFIG +MAINT +MAINTAINER_MODE_FALSE +MAINTAINER_MODE_TRUE +am__untar +am__tar +AMTAR +am__leading_dot +SET_MAKE +AWK +mkdir_p +MKDIR_P +INSTALL_STRIP_PROGRAM +STRIP +install_sh +MAKEINFO +AUTOHEADER +AUTOMAKE +AUTOCONF +ACLOCAL +VERSION +PACKAGE +CYGPATH_W +am__isrc +INSTALL_DATA +INSTALL_SCRIPT +INSTALL_PROGRAM +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' ac_subst_files='' +ac_user_opts=' +enable_option_checking +enable_maintainer_mode +enable_gui +enable_tests +enable_docs +' ac_precious_vars='build_alias host_alias target_alias @@ -664,12 +702,16 @@ GTK_SHARP_20_CFLAGS GTK_SHARP_20_LIBS MONO_NUNIT_CFLAGS -MONO_NUNIT_LIBS' +MONO_NUNIT_LIBS +MONODOC_CFLAGS +MONODOC_LIBS' # Initialize some variables set by options. ac_init_help= ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null @@ -768,13 +810,21 @@ datarootdir=$ac_optarg ;; -disable-* | --disable-*) - ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` - eval enable_$ac_feature=no ;; + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; @@ -787,13 +837,21 @@ dvidir=$ac_optarg ;; -enable-* | --enable-*) - ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` - eval enable_$ac_feature=\$ac_optarg ;; + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ @@ -984,22 +1042,38 @@ ac_init_version=: ;; -with-* | --with-*) - ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid package name: $ac_package" >&2 + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 { (exit 1); exit 1; }; } - ac_package=`echo $ac_package | sed 's/[-.]/_/g'` - eval with_$ac_package=\$ac_optarg ;; + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) - ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid package name: $ac_package" >&2 + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 { (exit 1); exit 1; }; } - ac_package=`echo $ac_package | sed 's/[-.]/_/g'` - eval with_$ac_package=no ;; + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. @@ -1019,7 +1093,7 @@ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; - -*) { echo "$as_me: error: unrecognized option: $ac_option + -*) { $as_echo "$as_me: error: unrecognized option: $ac_option Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; @@ -1028,16 +1102,16 @@ ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { $as_echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. - echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; @@ -1046,22 +1120,38 @@ if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` - { echo "$as_me: error: missing argument to $ac_option" >&2 + { $as_echo "$as_me: error: missing argument to $ac_option" >&2 { (exit 1); exit 1; }; } fi -# Be sure to have absolute directory names. +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) { $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2 + { (exit 1); exit 1; }; } ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac - { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { $as_echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; } done @@ -1076,7 +1166,7 @@ if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe - echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes @@ -1092,10 +1182,10 @@ ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - { echo "$as_me: error: Working directory cannot be determined" >&2 + { $as_echo "$as_me: error: working directory cannot be determined" >&2 { (exit 1); exit 1; }; } test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - { echo "$as_me: error: pwd does not report name of working directory" >&2 + { $as_echo "$as_me: error: pwd does not report name of working directory" >&2 { (exit 1); exit 1; }; } @@ -1103,12 +1193,12 @@ if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. - ac_confdir=`$as_dirname -- "$0" || -$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$0" : 'X\(//\)[^/]' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -echo X"$0" | + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -1135,12 +1225,12 @@ fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { $as_echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 { (exit 1); exit 1; }; } fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 + cd "$srcdir" && test -r "./$ac_unique_file" || { $as_echo "$as_me: error: $ac_msg" >&2 { (exit 1); exit 1; }; } pwd)` # When building in place, set srcdir=. @@ -1167,7 +1257,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures mono-addins 0.4 to adapt to many kinds of systems. +\`configure' configures mono-addins 0.6.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1189,9 +1279,9 @@ Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] + [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] + [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify @@ -1201,25 +1291,25 @@ For better control, use the options below. Fine tuning of the installation directories: - --bindir=DIR user executables [EPREFIX/bin] - --sbindir=DIR system admin executables [EPREFIX/sbin] - --libexecdir=DIR program executables [EPREFIX/libexec] - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] - --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] - --datadir=DIR read-only architecture-independent data [DATAROOTDIR] - --infodir=DIR info documentation [DATAROOTDIR/info] - --localedir=DIR locale-dependent data [DATAROOTDIR/locale] - --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/mono-addins] - --htmldir=DIR html documentation [DOCDIR] - --dvidir=DIR dvi documentation [DOCDIR] - --pdfdir=DIR pdf documentation [DOCDIR] - --psdir=DIR ps documentation [DOCDIR] + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/mono-addins] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF @@ -1233,16 +1323,20 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of mono-addins 0.4:";; + short | recursive ) echo "Configuration of mono-addins 0.6.1:";; esac cat <<\_ACEOF Optional Features: + --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-maintainer-mode enable make rules and dependencies not useful + (and sometimes confusing) to the casual installer --enable-gui enable support for GTK dependent libraries default=yes --enable-tests build unit tests default=no + --enable-docs build documentation default=no Some influential environment variables: PKG_CONFIG path to pkg-config utility @@ -1254,6 +1348,10 @@ C compiler flags for MONO_NUNIT, overriding pkg-config MONO_NUNIT_LIBS linker flags for MONO_NUNIT, overriding pkg-config + MONODOC_CFLAGS + C compiler flags for MONODOC, overriding pkg-config + MONODOC_LIBS + linker flags for MONODOC, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -1265,15 +1363,17 @@ if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d "$ac_dir" || continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; @@ -1309,7 +1409,7 @@ echo && $SHELL "$ac_srcdir/configure" --help=recursive else - echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done @@ -1318,11 +1418,11 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -mono-addins configure 0.4 -generated by GNU Autoconf 2.61 +mono-addins configure 0.6.1 +generated by GNU Autoconf 2.63 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1332,8 +1432,8 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by mono-addins $as_me 0.4, which was -generated by GNU Autoconf 2.61. Invocation command line was +It was created by mono-addins $as_me 0.6.1, which was +generated by GNU Autoconf 2.63. Invocation command line was $ $0 $@ @@ -1369,7 +1469,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - echo "PATH: $as_dir" + $as_echo "PATH: $as_dir" done IFS=$as_save_IFS @@ -1404,7 +1504,7 @@ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) - ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; @@ -1456,11 +1556,12 @@ case $ac_val in #( *${as_nl}*) case $ac_var in #( - *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 -echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) $as_unset $ac_var ;; esac ;; esac @@ -1490,9 +1591,9 @@ do eval ac_val=\$$ac_var case $ac_val in - *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac - echo "$ac_var='\''$ac_val'\''" + $as_echo "$ac_var='\''$ac_val'\''" done | sort echo @@ -1507,9 +1608,9 @@ do eval ac_val=\$$ac_var case $ac_val in - *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac - echo "$ac_var='\''$ac_val'\''" + $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi @@ -1525,8 +1626,8 @@ echo fi test "$ac_signal" != 0 && - echo "$as_me: caught signal $ac_signal" - echo "$as_me: exit $exit_status" + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && @@ -1568,21 +1669,24 @@ # Let the site file select an alternate cache file if it wants to. -# Prefer explicitly selected file to automatically selected ones. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE if test -n "$CONFIG_SITE"; then - set x "$CONFIG_SITE" + ac_site_file1=$CONFIG_SITE elif test "x$prefix" != xNONE; then - set x "$prefix/share/config.site" "$prefix/etc/config.site" + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site else - set x "$ac_default_prefix/share/config.site" \ - "$ac_default_prefix/etc/config.site" + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site fi -shift -for ac_site_file +for ac_site_file in "$ac_site_file1" "$ac_site_file2" do + test "x$ac_site_file" = xNONE && continue if test -r "$ac_site_file"; then - { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 -echo "$as_me: loading site script $ac_site_file" >&6;} + { $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" fi @@ -1592,16 +1696,16 @@ # Some versions of bash will fail to source /dev/null (special # files actually), so we avoid doing that. if test -f "$cache_file"; then - { echo "$as_me:$LINENO: loading cache $cache_file" >&5 -echo "$as_me: loading cache $cache_file" >&6;} + { $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else - { echo "$as_me:$LINENO: creating cache $cache_file" >&5 -echo "$as_me: creating cache $cache_file" >&6;} + { $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi @@ -1615,29 +1719,38 @@ eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) - { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + { $as_echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) - { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 -echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + { $as_echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then - { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 -echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 -echo "$as_me: former value: $ac_old_val" >&2;} - { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 -echo "$as_me: current value: $ac_new_val" >&2;} - ac_cache_corrupted=: + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:$LINENO: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:$LINENO: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:$LINENO: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in - *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in @@ -1647,10 +1760,12 @@ fi done if $ac_cache_corrupted; then - { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 -echo "$as_me: error: changes in the environment can compromise the build" >&2;} - { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 -echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +$as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} { (exit 1); exit 1; }; } fi @@ -1704,8 +1819,8 @@ fi done if test -z "$ac_aux_dir"; then - { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5 -echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;} + { { $as_echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5 +$as_echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;} { (exit 1); exit 1; }; } fi @@ -1731,11 +1846,12 @@ # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. -{ echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 -echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; } +# Reject install programs that cannot install multiple files. +{ $as_echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +$as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if test "${ac_cv_path_install+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH @@ -1764,17 +1880,29 @@ # program-specific install script used by HP pwplus--don't use. : else - ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" - break 3 + rm -rf conftest.one conftest.two conftest.dir + echo one > conftest.one + echo two > conftest.two + mkdir conftest.dir + if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && + test -s conftest.one && test -s conftest.two && + test -s conftest.dir/conftest.one && + test -s conftest.dir/conftest.two + then + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi fi fi done done ;; esac + done IFS=$as_save_IFS +rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then @@ -1787,8 +1915,8 @@ INSTALL=$ac_install_sh fi fi -{ echo "$as_me:$LINENO: result: $INSTALL" >&5 -echo "${ECHO_T}$INSTALL" >&6; } +{ $as_echo "$as_me:$LINENO: result: $INSTALL" >&5 +$as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. @@ -1798,8 +1926,8 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' -{ echo "$as_me:$LINENO: checking whether build environment is sane" >&5 -echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking whether build environment is sane" >&5 +$as_echo_n "checking whether build environment is sane... " >&6; } # Just in case sleep 1 echo timestamp > conftest.file @@ -1822,9 +1950,9 @@ # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". - { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken + { { $as_echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken alias in your environment" >&5 -echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken +$as_echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken alias in your environment" >&2;} { (exit 1); exit 1; }; } fi @@ -1835,26 +1963,23 @@ # Ok. : else - { { echo "$as_me:$LINENO: error: newly created file is older than distributed files! + { { $as_echo "$as_me:$LINENO: error: newly created file is older than distributed files! Check your system clock" >&5 -echo "$as_me: error: newly created file is older than distributed files! +$as_echo "$as_me: error: newly created file is older than distributed files! Check your system clock" >&2;} { (exit 1); exit 1; }; } fi -{ echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } +{ $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" -# Double any \ or $. echo might interpret backslashes. +# Double any \ or $. # By default was `s,x,x', remove it if useless. -cat <<\_ACEOF >conftest.sed -s/[\\$]/&&/g;s/;s,x,x,$// -_ACEOF -program_transform_name=`echo $program_transform_name | sed -f conftest.sed` -rm -f conftest.sed +ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' +program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` @@ -1865,15 +1990,15 @@ am_missing_run="$MISSING --run " else am_missing_run= - { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5 -echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5 +$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi -{ echo "$as_me:$LINENO: checking for a thread-safe mkdir -p" >&5 -echo $ECHO_N "checking for a thread-safe mkdir -p... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for a thread-safe mkdir -p" >&5 +$as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if test "${ac_cv_path_mkdir+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin @@ -1908,8 +2033,8 @@ MKDIR_P="$ac_install_sh -d" fi fi -{ echo "$as_me:$LINENO: result: $MKDIR_P" >&5 -echo "${ECHO_T}$MKDIR_P" >&6; } +{ $as_echo "$as_me:$LINENO: result: $MKDIR_P" >&5 +$as_echo "$MKDIR_P" >&6; } mkdir_p="$MKDIR_P" case $mkdir_p in @@ -1921,10 +2046,10 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_AWK+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. @@ -1937,7 +2062,7 @@ for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AWK="$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -1948,22 +2073,23 @@ fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then - { echo "$as_me:$LINENO: result: $AWK" >&5 -echo "${ECHO_T}$AWK" >&6; } + { $as_echo "$as_me:$LINENO: result: $AWK" >&5 +$as_echo "$AWK" >&6; } else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } fi test -n "$AWK" && break done -{ echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6; } -set x ${MAKE-make}; ac_make=`echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +{ $as_echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh @@ -1980,12 +2106,12 @@ rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then - { echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } SET_MAKE= else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi @@ -2004,8 +2130,8 @@ am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then - { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 -echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} + { { $as_echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 +$as_echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} { (exit 1); exit 1; }; } fi fi @@ -2022,7 +2148,7 @@ # Define the identity of the package. PACKAGE='mono-addins' - VERSION='0.4' + VERSION='0.6.1' cat >>confdefs.h <<_ACEOF @@ -2060,10 +2186,10 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_STRIP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. @@ -2076,7 +2202,7 @@ for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -2087,11 +2213,11 @@ fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then - { echo "$as_me:$LINENO: result: $STRIP" >&5 -echo "${ECHO_T}$STRIP" >&6; } + { $as_echo "$as_me:$LINENO: result: $STRIP" >&5 +$as_echo "$STRIP" >&6; } else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } fi @@ -2100,10 +2226,10 @@ ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. @@ -2116,7 +2242,7 @@ for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -2127,11 +2253,11 @@ fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then - { echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 -echo "${ECHO_T}$ac_ct_STRIP" >&6; } + { $as_echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 +$as_echo "$ac_ct_STRIP" >&6; } else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then @@ -2139,12 +2265,8 @@ else case $cross_compiling:$ac_tool_warned in yes:) -{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&5 -echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&2;} +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP @@ -2163,8 +2285,8 @@ AMTAR=${AMTAR-"${am_missing_run}tar"} -{ echo "$as_me:$LINENO: checking how to create a ustar tar archive" >&5 -echo $ECHO_N "checking how to create a ustar tar archive... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking how to create a ustar tar archive" >&5 +$as_echo_n "checking how to create a ustar tar archive... " >&6; } # Loop over all known methods to create a tar archive until one works. _am_tools='gnutar plaintar pax cpio none' _am_tools=${am_cv_prog_tar_ustar-$_am_tools} @@ -2237,25 +2359,47 @@ rm -rf conftest.dir if test "${am_cv_prog_tar_ustar+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else am_cv_prog_tar_ustar=$_am_tool fi -{ echo "$as_me:$LINENO: result: $am_cv_prog_tar_ustar" >&5 -echo "${ECHO_T}$am_cv_prog_tar_ustar" >&6; } +{ $as_echo "$as_me:$LINENO: result: $am_cv_prog_tar_ustar" >&5 +$as_echo "$am_cv_prog_tar_ustar" >&6; } + + +{ $as_echo "$as_me:$LINENO: checking whether to enable maintainer-specific portions of Makefiles" >&5 +$as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } + # Check whether --enable-maintainer-mode was given. +if test "${enable_maintainer_mode+set}" = set; then + enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval +else + USE_MAINTAINER_MODE=no +fi + + { $as_echo "$as_me:$LINENO: result: $USE_MAINTAINER_MODE" >&5 +$as_echo "$USE_MAINTAINER_MODE" >&6; } + if test $USE_MAINTAINER_MODE = yes; then + MAINTAINER_MODE_TRUE= + MAINTAINER_MODE_FALSE='#' +else + MAINTAINER_MODE_TRUE='#' + MAINTAINER_MODE_FALSE= +fi + + MAINT=$MAINTAINER_MODE_TRUE # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_path_PKG_CONFIG+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in [\\/]* | ?:[\\/]*) @@ -2270,7 +2414,7 @@ for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -2283,23 +2427,23 @@ fi PKG_CONFIG=$ac_cv_path_PKG_CONFIG if test -n "$PKG_CONFIG"; then - { echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5 -echo "${ECHO_T}$PKG_CONFIG" >&6; } + { $as_echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5 +$as_echo "$PKG_CONFIG" >&6; } else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } fi if test "x$PKG_CONFIG" = "xno"; then - { { echo "$as_me:$LINENO: error: You need to install pkg-config" >&5 -echo "$as_me: error: You need to install pkg-config" >&2;} + { { $as_echo "$as_me:$LINENO: error: You need to install pkg-config" >&5 +$as_echo "$as_me: error: You need to install pkg-config" >&2;} { (exit 1); exit 1; }; } fi -API_VERSION=0.4.0.0 +API_VERSION=0.6.0.0 -POLICY_VERSIONS="0.2 0.3" +POLICY_VERSIONS="0.2 0.3 0.4 0.5" # Find a good install program. We prefer a C program (faster), @@ -2315,11 +2459,12 @@ # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. -{ echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 -echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; } +# Reject install programs that cannot install multiple files. +{ $as_echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +$as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if test "${ac_cv_path_install+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH @@ -2348,17 +2493,29 @@ # program-specific install script used by HP pwplus--don't use. : else - ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" - break 3 + rm -rf conftest.one conftest.two conftest.dir + echo one > conftest.one + echo two > conftest.two + mkdir conftest.dir + if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && + test -s conftest.one && test -s conftest.two && + test -s conftest.dir/conftest.one && + test -s conftest.dir/conftest.two + then + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi fi fi done done ;; esac + done IFS=$as_save_IFS +rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then @@ -2371,8 +2528,8 @@ INSTALL=$ac_install_sh fi fi -{ echo "$as_me:$LINENO: result: $INSTALL" >&5 -echo "${ECHO_T}$INSTALL" >&6; } +{ $as_echo "$as_me:$LINENO: result: $INSTALL" >&5 +$as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. @@ -2383,12 +2540,12 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' -# Extract the first word of "mcs", so it can be a program name with args. -set dummy mcs; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +# Extract the first word of "gmcs", so it can be a program name with args. +set dummy gmcs; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_path_MCS+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else case $MCS in [\\/]* | ?:[\\/]*) @@ -2403,7 +2560,7 @@ for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_MCS="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -2416,26 +2573,26 @@ fi MCS=$ac_cv_path_MCS if test -n "$MCS"; then - { echo "$as_me:$LINENO: result: $MCS" >&5 -echo "${ECHO_T}$MCS" >&6; } + { $as_echo "$as_me:$LINENO: result: $MCS" >&5 +$as_echo "$MCS" >&6; } else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } fi if test "x$MCS" = "xno"; then - { { echo "$as_me:$LINENO: error: mcs Not found" >&5 -echo "$as_me: error: mcs Not found" >&2;} + { { $as_echo "$as_me:$LINENO: error: mcs Not found" >&5 +$as_echo "$as_me: error: mcs Not found" >&2;} { (exit 1); exit 1; }; } fi # Extract the first word of "gacutil", so it can be a program name with args. set dummy gacutil; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_path_GACUTIL+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else case $GACUTIL in [\\/]* | ?:[\\/]*) @@ -2450,7 +2607,7 @@ for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_GACUTIL="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -2463,26 +2620,26 @@ fi GACUTIL=$ac_cv_path_GACUTIL if test -n "$GACUTIL"; then - { echo "$as_me:$LINENO: result: $GACUTIL" >&5 -echo "${ECHO_T}$GACUTIL" >&6; } + { $as_echo "$as_me:$LINENO: result: $GACUTIL" >&5 +$as_echo "$GACUTIL" >&6; } else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } fi if test "x$GACUTIL" = "xno" ; then - { { echo "$as_me:$LINENO: error: No gacutil tool found" >&5 -echo "$as_me: error: No gacutil tool found" >&2;} + { { $as_echo "$as_me:$LINENO: error: No gacutil tool found" >&5 +$as_echo "$as_me: error: No gacutil tool found" >&2;} { (exit 1); exit 1; }; } fi # Extract the first word of "al", so it can be a program name with args. set dummy al; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_path_AL+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else case $AL in [\\/]* | ?:[\\/]*) @@ -2497,7 +2654,7 @@ for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_AL="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -2510,22 +2667,22 @@ fi AL=$ac_cv_path_AL if test -n "$AL"; then - { echo "$as_me:$LINENO: result: $AL" >&5 -echo "${ECHO_T}$AL" >&6; } + { $as_echo "$as_me:$LINENO: result: $AL" >&5 +$as_echo "$AL" >&6; } else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } fi if test "x$AL" = "xno" ; then - { { echo "$as_me:$LINENO: error: No al tool found. You need to install either the mono or .Net SDK." >&5 -echo "$as_me: error: No al tool found. You need to install either the mono or .Net SDK." >&2;} + { { $as_echo "$as_me:$LINENO: error: No al tool found. You need to install either the mono or .Net SDK." >&5 +$as_echo "$as_me: error: No al tool found. You need to install either the mono or .Net SDK." >&2;} { (exit 1); exit 1; }; } fi -GACUTIL_FLAGS='/package mono-addins /root $(DESTDIR)$(prefix)/lib' -GACUTIL_POLICY_FLAGS='/root $(DESTDIR)$(prefix)/lib' +GACUTIL_FLAGS='/package mono-addins /root $(DESTDIR)$(libdir)' +GACUTIL_POLICY_FLAGS='/root $(DESTDIR)$(libdir)' @@ -2565,6 +2722,23 @@ fi +# Check whether --enable-docs was given. +if test "${enable_docs+set}" = set; then + enableval=$enable_docs; enable_docs=${enableval} +else + enable_docs=no +fi + + + if test x$enable_docs = xyes; then + ENABLE_DOCS_TRUE= + ENABLE_DOCS_FALSE='#' +else + ENABLE_DOCS_TRUE='#' + ENABLE_DOCS_FALSE= +fi + + if test "x$enable_gui" = "xyes"; then @@ -2572,10 +2746,10 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_path_PKG_CONFIG+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in [\\/]* | ?:[\\/]*) @@ -2590,7 +2764,7 @@ for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -2602,11 +2776,11 @@ fi PKG_CONFIG=$ac_cv_path_PKG_CONFIG if test -n "$PKG_CONFIG"; then - { echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5 -echo "${ECHO_T}$PKG_CONFIG" >&6; } + { $as_echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5 +$as_echo "$PKG_CONFIG" >&6; } else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } fi @@ -2615,10 +2789,10 @@ ac_pt_PKG_CONFIG=$PKG_CONFIG # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in [\\/]* | ?:[\\/]*) @@ -2633,7 +2807,7 @@ for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -2645,11 +2819,11 @@ fi ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG if test -n "$ac_pt_PKG_CONFIG"; then - { echo "$as_me:$LINENO: result: $ac_pt_PKG_CONFIG" >&5 -echo "${ECHO_T}$ac_pt_PKG_CONFIG" >&6; } + { $as_echo "$as_me:$LINENO: result: $ac_pt_PKG_CONFIG" >&5 +$as_echo "$ac_pt_PKG_CONFIG" >&6; } else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } fi if test "x$ac_pt_PKG_CONFIG" = x; then @@ -2657,12 +2831,8 @@ else case $cross_compiling:$ac_tool_warned in yes:) -{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&5 -echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&2;} +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac PKG_CONFIG=$ac_pt_PKG_CONFIG @@ -2674,31 +2844,31 @@ fi if test -n "$PKG_CONFIG"; then _pkg_min_version=0.9.0 - { echo "$as_me:$LINENO: checking pkg-config is at least version $_pkg_min_version" >&5 -echo $ECHO_N "checking pkg-config is at least version $_pkg_min_version... $ECHO_C" >&6; } + { $as_echo "$as_me:$LINENO: checking pkg-config is at least version $_pkg_min_version" >&5 +$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then - { echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } PKG_CONFIG="" fi fi pkg_failed=no -{ echo "$as_me:$LINENO: checking for GTK_SHARP_20" >&5 -echo $ECHO_N "checking for GTK_SHARP_20... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for GTK_SHARP_20" >&5 +$as_echo_n "checking for GTK_SHARP_20... " >&6; } if test -n "$GTK_SHARP_20_CFLAGS"; then pkg_cv_GTK_SHARP_20_CFLAGS="$GTK_SHARP_20_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"gtk-sharp-2.0\"") >&5 + { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"gtk-sharp-2.0\"") >&5 ($PKG_CONFIG --exists --print-errors "gtk-sharp-2.0") 2>&5 ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then pkg_cv_GTK_SHARP_20_CFLAGS=`$PKG_CONFIG --cflags "gtk-sharp-2.0" 2>/dev/null` else @@ -2711,10 +2881,10 @@ pkg_cv_GTK_SHARP_20_LIBS="$GTK_SHARP_20_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"gtk-sharp-2.0\"") >&5 + { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"gtk-sharp-2.0\"") >&5 ($PKG_CONFIG --exists --print-errors "gtk-sharp-2.0") 2>&5 ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then pkg_cv_GTK_SHARP_20_LIBS=`$PKG_CONFIG --libs "gtk-sharp-2.0" 2>/dev/null` else @@ -2741,7 +2911,7 @@ # Put the nasty error message in config.log where it belongs echo "$GTK_SHARP_20_PKG_ERRORS" >&5 - { { echo "$as_me:$LINENO: error: Package requirements (gtk-sharp-2.0) were not met: + { { $as_echo "$as_me:$LINENO: error: Package requirements (gtk-sharp-2.0) were not met: $GTK_SHARP_20_PKG_ERRORS @@ -2752,7 +2922,7 @@ and GTK_SHARP_20_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. " >&5 -echo "$as_me: error: Package requirements (gtk-sharp-2.0) were not met: +$as_echo "$as_me: error: Package requirements (gtk-sharp-2.0) were not met: $GTK_SHARP_20_PKG_ERRORS @@ -2765,7 +2935,9 @@ " >&2;} { (exit 1); exit 1; }; } elif test $pkg_failed = untried; then - { { echo "$as_me:$LINENO: error: The pkg-config script could not be found or is too old. Make sure it + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. @@ -2775,7 +2947,7 @@ To get pkg-config, see . See \`config.log' for more details." >&5 -echo "$as_me: error: The pkg-config script could not be found or is too old. Make sure it +$as_echo "$as_me: error: The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. @@ -2785,12 +2957,12 @@ To get pkg-config, see . See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } + { (exit 1); exit 1; }; }; } else GTK_SHARP_20_CFLAGS=$pkg_cv_GTK_SHARP_20_CFLAGS GTK_SHARP_20_LIBS=$pkg_cv_GTK_SHARP_20_LIBS - { echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } : fi fi @@ -2798,17 +2970,17 @@ if test "x$enable_tests" = "xyes"; then pkg_failed=no -{ echo "$as_me:$LINENO: checking for MONO_NUNIT" >&5 -echo $ECHO_N "checking for MONO_NUNIT... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for MONO_NUNIT" >&5 +$as_echo_n "checking for MONO_NUNIT... " >&6; } if test -n "$MONO_NUNIT_CFLAGS"; then pkg_cv_MONO_NUNIT_CFLAGS="$MONO_NUNIT_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"mono-nunit\"") >&5 + { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"mono-nunit\"") >&5 ($PKG_CONFIG --exists --print-errors "mono-nunit") 2>&5 ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then pkg_cv_MONO_NUNIT_CFLAGS=`$PKG_CONFIG --cflags "mono-nunit" 2>/dev/null` else @@ -2821,10 +2993,10 @@ pkg_cv_MONO_NUNIT_LIBS="$MONO_NUNIT_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"mono-nunit\"") >&5 + { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"mono-nunit\"") >&5 ($PKG_CONFIG --exists --print-errors "mono-nunit") 2>&5 ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then pkg_cv_MONO_NUNIT_LIBS=`$PKG_CONFIG --libs "mono-nunit" 2>/dev/null` else @@ -2851,7 +3023,7 @@ # Put the nasty error message in config.log where it belongs echo "$MONO_NUNIT_PKG_ERRORS" >&5 - { { echo "$as_me:$LINENO: error: Package requirements (mono-nunit) were not met: + { { $as_echo "$as_me:$LINENO: error: Package requirements (mono-nunit) were not met: $MONO_NUNIT_PKG_ERRORS @@ -2862,7 +3034,7 @@ and MONO_NUNIT_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. " >&5 -echo "$as_me: error: Package requirements (mono-nunit) were not met: +$as_echo "$as_me: error: Package requirements (mono-nunit) were not met: $MONO_NUNIT_PKG_ERRORS @@ -2875,7 +3047,9 @@ " >&2;} { (exit 1); exit 1; }; } elif test $pkg_failed = untried; then - { { echo "$as_me:$LINENO: error: The pkg-config script could not be found or is too old. Make sure it + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. @@ -2885,7 +3059,7 @@ To get pkg-config, see . See \`config.log' for more details." >&5 -echo "$as_me: error: The pkg-config script could not be found or is too old. Make sure it +$as_echo "$as_me: error: The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. @@ -2895,12 +3069,124 @@ To get pkg-config, see . See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } + { (exit 1); exit 1; }; }; } else MONO_NUNIT_CFLAGS=$pkg_cv_MONO_NUNIT_CFLAGS MONO_NUNIT_LIBS=$pkg_cv_MONO_NUNIT_LIBS - { echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } + : +fi +fi + +if test "x$enable_docs" = "xyes"; then + +pkg_failed=no +{ $as_echo "$as_me:$LINENO: checking for MONODOC" >&5 +$as_echo_n "checking for MONODOC... " >&6; } + +if test -n "$MONODOC_CFLAGS"; then + pkg_cv_MONODOC_CFLAGS="$MONODOC_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"monodoc\"") >&5 + ($PKG_CONFIG --exists --print-errors "monodoc") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + pkg_cv_MONODOC_CFLAGS=`$PKG_CONFIG --cflags "monodoc" 2>/dev/null` +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$MONODOC_LIBS"; then + pkg_cv_MONODOC_LIBS="$MONODOC_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"monodoc\"") >&5 + ($PKG_CONFIG --exists --print-errors "monodoc") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + pkg_cv_MONODOC_LIBS=`$PKG_CONFIG --libs "monodoc" 2>/dev/null` +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + MONODOC_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "monodoc" 2>&1` + else + MONODOC_PKG_ERRORS=`$PKG_CONFIG --print-errors "monodoc" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$MONODOC_PKG_ERRORS" >&5 + + { { $as_echo "$as_me:$LINENO: error: Package requirements (monodoc) were not met: + +$MONODOC_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables MONODOC_CFLAGS +and MONODOC_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. +" >&5 +$as_echo "$as_me: error: Package requirements (monodoc) were not met: + +$MONODOC_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables MONODOC_CFLAGS +and MONODOC_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. +" >&2;} + { (exit 1); exit 1; }; } +elif test $pkg_failed = untried; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables MONODOC_CFLAGS +and MONODOC_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables MONODOC_CFLAGS +and MONODOC_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } +else + MONODOC_CFLAGS=$pkg_cv_MONODOC_CFLAGS + MONODOC_LIBS=$pkg_cv_MONODOC_LIBS + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } : fi fi @@ -2911,11 +3197,13 @@ MONO_ADDINS_DEFAULT_LIB='Mono.Addins.dll' MONO_ADDINS_SETUP_DEFAULT_LIB='Mono.Addins.Setup.dll' MONO_ADDINS_GUI_DEFAULT_LIB='Mono.Addins.Gui.dll' +MONO_ADDINS_MSBUILD_DEFAULT_LIB='Mono.Addins.MSBuild.dll' -ac_config_files="$ac_config_files ./Mono.Addins/mono-addins.pc ./Mono.Addins.Gui/mono-addins-gui.pc ./Mono.Addins.Setup/mono-addins-setup.pc ./Makefile ./policy.config ./Mono.Addins.Gui/Makefile ./Mono.Addins.Setup/Makefile ./Mono.Addins/Makefile ./Mono.Addins.CecilReflector/Makefile ./mautil/Makefile ./mautil/mautil ./Test/HelloWorldExtension/Makefile ./Test/FileContentExtension/Makefile ./Test/UnitTests/Makefile ./Test/CommandExtension/Makefile ./Test/SystemInfoExtension/Makefile ./Test/FileExtender/Makefile ./Test/Makefile ./Samples/TextEditor.Xml/Makefile ./Samples/TextEditor/Makefile ./Samples/TextEditor.CompilerService/Makefile ./Samples/WriterServiceHost/Makefile ./Samples/TextEditor.CompilerService.CSharp/Makefile ./Samples/WriterService.SampleExtender/Makefile ./Samples/Makefile ./Samples/TextEditorLib/Makefile ./Samples/WriterService/Makefile" + +ac_config_files="$ac_config_files ./mono-addins.spec ./Mono.Addins/mono-addins.pc ./Mono.Addins.Gui/mono-addins-gui.pc ./Mono.Addins.Setup/mono-addins-setup.pc ./Mono.Addins.MSBuild/mono-addins-msbuild.pc ./Makefile ./policy.config ./Mono.Addins.Gui/Makefile ./Mono.Addins.Setup/Makefile ./Mono.Addins/Makefile ./Mono.Addins.CecilReflector/Makefile ./Mono.Addins.MSBuild/Makefile ./mautil/Makefile ./mautil/mautil ./docs/Makefile ./Test/HelloWorldExtension/Makefile ./Test/FileContentExtension/Makefile ./Test/UnitTests/Makefile ./Test/CommandExtension/Makefile ./Test/SystemInfoExtension/Makefile ./Test/FileExtender/Makefile ./Test/Makefile" cat >confcache <<\_ACEOF @@ -2945,11 +3233,12 @@ case $ac_val in #( *${as_nl}*) case $ac_var in #( - *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 -echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) $as_unset $ac_var ;; esac ;; esac @@ -2982,12 +3271,12 @@ if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then test "x$cache_file" != "x/dev/null" && - { echo "$as_me:$LINENO: updating cache $cache_file" >&5 -echo "$as_me: updating cache $cache_file" >&6;} + { $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else - { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 -echo "$as_me: not updating unwritable cache $cache_file" >&6;} + { $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache @@ -3004,6 +3293,12 @@ # take arguments), then branch to the quote section. Otherwise, # look for a macro that doesn't take arguments. ac_script=' +:mline +/\\$/{ + N + s,\\\n,, + b mline +} t clear :clear s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g @@ -3033,7 +3328,7 @@ for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' - ac_i=`echo "$ac_i" | sed "$ac_script"` + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" @@ -3044,27 +3339,42 @@ LTLIBOBJS=$ac_ltlibobjs +if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then + { { $as_echo "$as_me:$LINENO: error: conditional \"MAINTAINER_MODE\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +$as_echo "$as_me: error: conditional \"MAINTAINER_MODE\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi if test -z "${ENABLE_GUI_TRUE}" && test -z "${ENABLE_GUI_FALSE}"; then - { { echo "$as_me:$LINENO: error: conditional \"ENABLE_GUI\" was never defined. + { { $as_echo "$as_me:$LINENO: error: conditional \"ENABLE_GUI\" was never defined. Usually this means the macro was only invoked conditionally." >&5 -echo "$as_me: error: conditional \"ENABLE_GUI\" was never defined. +$as_echo "$as_me: error: conditional \"ENABLE_GUI\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi if test -z "${ENABLE_TESTS_TRUE}" && test -z "${ENABLE_TESTS_FALSE}"; then - { { echo "$as_me:$LINENO: error: conditional \"ENABLE_TESTS\" was never defined. + { { $as_echo "$as_me:$LINENO: error: conditional \"ENABLE_TESTS\" was never defined. Usually this means the macro was only invoked conditionally." >&5 -echo "$as_me: error: conditional \"ENABLE_TESTS\" was never defined. +$as_echo "$as_me: error: conditional \"ENABLE_TESTS\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${ENABLE_DOCS_TRUE}" && test -z "${ENABLE_DOCS_FALSE}"; then + { { $as_echo "$as_me:$LINENO: error: conditional \"ENABLE_DOCS\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +$as_echo "$as_me: error: conditional \"ENABLE_DOCS\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi : ${CONFIG_STATUS=./config.status} +ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 -echo "$as_me: creating $CONFIG_STATUS" >&6;} -cat >$CONFIG_STATUS <<_ACEOF +{ $as_echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. @@ -3077,7 +3387,7 @@ SHELL=\${CONFIG_SHELL-$SHELL} _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## @@ -3087,7 +3397,7 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST @@ -3109,17 +3419,45 @@ as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' else - PATH_SEPARATOR=: + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' fi - rm -f conf$$.sh + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } fi # Support unset when possible. @@ -3135,8 +3473,6 @@ # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) -as_nl=' -' IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. @@ -3159,7 +3495,7 @@ as_myself=$0 fi if test ! -f "$as_myself"; then - echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 { (exit 1); exit 1; } fi @@ -3172,17 +3508,10 @@ PS4='+ ' # NLS nuisances. -for as_var in \ - LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ - LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ - LC_TELEPHONE LC_TIME -do - if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then - eval $as_var=C; export $as_var - else - ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var - fi -done +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1 && @@ -3204,7 +3533,7 @@ $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || -echo X/"$0" | +$as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q @@ -3255,7 +3584,7 @@ s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || - { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems @@ -3283,7 +3612,6 @@ *) ECHO_N='-n';; esac - if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr @@ -3296,19 +3624,22 @@ rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir - mkdir conf$$.dir + mkdir conf$$.dir 2>/dev/null fi -echo >conf$$.file -if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else as_ln_s='cp -p' -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln + fi else as_ln_s='cp -p' fi @@ -3333,10 +3664,10 @@ as_test_x=' eval sh -c '\'' if test -d "$1"; then - test -d "$1/."; + test -d "$1/."; else case $1 in - -*)set "./$1";; + -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in ???[sx]*):;;*)false;;esac;fi @@ -3358,8 +3689,8 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by mono-addins $as_me 0.4, which was -generated by GNU Autoconf 2.61. Invocation command line was +This file was extended by mono-addins $as_me 0.6.1, which was +generated by GNU Autoconf 2.63. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -3372,26 +3703,33 @@ _ACEOF -cat >>$CONFIG_STATUS <<_ACEOF +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. -Usage: $0 [OPTIONS] [FILE]... +Usage: $0 [OPTION]... [FILE]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit - -q, --quiet do not print progress messages + -q, --quiet, --silent + do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE Configuration files: $config_files @@ -3399,13 +3737,13 @@ Report bugs to ." _ACEOF -cat >>$CONFIG_STATUS <<_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_version="\\ -mono-addins config.status 0.4 -configured by $0, generated by GNU Autoconf 2.61, - with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" +mono-addins config.status 0.6.1 +configured by $0, generated by GNU Autoconf 2.63, + with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" -Copyright (C) 2006 Free Software Foundation, Inc. +Copyright (C) 2008 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -3413,11 +3751,12 @@ srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' +AWK='$AWK' +test -n "\$AWK" || AWK=awk _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -# If no file are specified by the user, then we need to provide default -# value. By we need to know if files were specified by the user. +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do @@ -3439,21 +3778,24 @@ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - echo "$ac_cs_version"; exit ;; + $as_echo "$ac_cs_version"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift - CONFIG_FILES="$CONFIG_FILES $ac_optarg" + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + CONFIG_FILES="$CONFIG_FILES '$ac_optarg'" ac_need_defaults=false;; --he | --h | --help | --hel | -h ) - echo "$ac_cs_usage"; exit ;; + $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. - -*) { echo "$as_me: error: unrecognized option: $1 + -*) { $as_echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; @@ -3472,46 +3814,52 @@ fi _ACEOF -cat >>$CONFIG_STATUS <<_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then - echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 - CONFIG_SHELL=$SHELL + set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' export CONFIG_SHELL - exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + exec "\$@" fi _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX - echo "$ac_log" + $as_echo "$ac_log" } >&5 _ACEOF -cat >>$CONFIG_STATUS <<_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in + "./mono-addins.spec") CONFIG_FILES="$CONFIG_FILES ./mono-addins.spec" ;; "./Mono.Addins/mono-addins.pc") CONFIG_FILES="$CONFIG_FILES ./Mono.Addins/mono-addins.pc" ;; "./Mono.Addins.Gui/mono-addins-gui.pc") CONFIG_FILES="$CONFIG_FILES ./Mono.Addins.Gui/mono-addins-gui.pc" ;; "./Mono.Addins.Setup/mono-addins-setup.pc") CONFIG_FILES="$CONFIG_FILES ./Mono.Addins.Setup/mono-addins-setup.pc" ;; + "./Mono.Addins.MSBuild/mono-addins-msbuild.pc") CONFIG_FILES="$CONFIG_FILES ./Mono.Addins.MSBuild/mono-addins-msbuild.pc" ;; "./Makefile") CONFIG_FILES="$CONFIG_FILES ./Makefile" ;; "./policy.config") CONFIG_FILES="$CONFIG_FILES ./policy.config" ;; "./Mono.Addins.Gui/Makefile") CONFIG_FILES="$CONFIG_FILES ./Mono.Addins.Gui/Makefile" ;; "./Mono.Addins.Setup/Makefile") CONFIG_FILES="$CONFIG_FILES ./Mono.Addins.Setup/Makefile" ;; "./Mono.Addins/Makefile") CONFIG_FILES="$CONFIG_FILES ./Mono.Addins/Makefile" ;; "./Mono.Addins.CecilReflector/Makefile") CONFIG_FILES="$CONFIG_FILES ./Mono.Addins.CecilReflector/Makefile" ;; + "./Mono.Addins.MSBuild/Makefile") CONFIG_FILES="$CONFIG_FILES ./Mono.Addins.MSBuild/Makefile" ;; "./mautil/Makefile") CONFIG_FILES="$CONFIG_FILES ./mautil/Makefile" ;; "./mautil/mautil") CONFIG_FILES="$CONFIG_FILES ./mautil/mautil" ;; + "./docs/Makefile") CONFIG_FILES="$CONFIG_FILES ./docs/Makefile" ;; "./Test/HelloWorldExtension/Makefile") CONFIG_FILES="$CONFIG_FILES ./Test/HelloWorldExtension/Makefile" ;; "./Test/FileContentExtension/Makefile") CONFIG_FILES="$CONFIG_FILES ./Test/FileContentExtension/Makefile" ;; "./Test/UnitTests/Makefile") CONFIG_FILES="$CONFIG_FILES ./Test/UnitTests/Makefile" ;; @@ -3519,18 +3867,9 @@ "./Test/SystemInfoExtension/Makefile") CONFIG_FILES="$CONFIG_FILES ./Test/SystemInfoExtension/Makefile" ;; "./Test/FileExtender/Makefile") CONFIG_FILES="$CONFIG_FILES ./Test/FileExtender/Makefile" ;; "./Test/Makefile") CONFIG_FILES="$CONFIG_FILES ./Test/Makefile" ;; - "./Samples/TextEditor.Xml/Makefile") CONFIG_FILES="$CONFIG_FILES ./Samples/TextEditor.Xml/Makefile" ;; - "./Samples/TextEditor/Makefile") CONFIG_FILES="$CONFIG_FILES ./Samples/TextEditor/Makefile" ;; - "./Samples/TextEditor.CompilerService/Makefile") CONFIG_FILES="$CONFIG_FILES ./Samples/TextEditor.CompilerService/Makefile" ;; - "./Samples/WriterServiceHost/Makefile") CONFIG_FILES="$CONFIG_FILES ./Samples/WriterServiceHost/Makefile" ;; - "./Samples/TextEditor.CompilerService.CSharp/Makefile") CONFIG_FILES="$CONFIG_FILES ./Samples/TextEditor.CompilerService.CSharp/Makefile" ;; - "./Samples/WriterService.SampleExtender/Makefile") CONFIG_FILES="$CONFIG_FILES ./Samples/WriterService.SampleExtender/Makefile" ;; - "./Samples/Makefile") CONFIG_FILES="$CONFIG_FILES ./Samples/Makefile" ;; - "./Samples/TextEditorLib/Makefile") CONFIG_FILES="$CONFIG_FILES ./Samples/TextEditorLib/Makefile" ;; - "./Samples/WriterService/Makefile") CONFIG_FILES="$CONFIG_FILES ./Samples/WriterService/Makefile" ;; - *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 -echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac done @@ -3569,144 +3908,143 @@ (umask 077 && mkdir "$tmp") } || { - echo "$me: cannot create a temporary directory in ." >&2 + $as_echo "$as_me: cannot create a temporary directory in ." >&2 { (exit 1); exit 1; } } -# -# Set up the sed scripts for CONFIG_FILES section. -# - -# No need to generate the scripts if there are no CONFIG_FILES. -# This happens for instance when ./config.status config.h +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then -_ACEOF +ac_cr=' ' +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$tmp/subs1.awk" && +_ACEOF +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } +ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do - cat >conf$$subs.sed <<_ACEOF -SHELL!$SHELL$ac_delim -PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim -PACKAGE_NAME!$PACKAGE_NAME$ac_delim -PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim -PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim -PACKAGE_STRING!$PACKAGE_STRING$ac_delim -PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim -exec_prefix!$exec_prefix$ac_delim -prefix!$prefix$ac_delim -program_transform_name!$program_transform_name$ac_delim -bindir!$bindir$ac_delim -sbindir!$sbindir$ac_delim -libexecdir!$libexecdir$ac_delim -datarootdir!$datarootdir$ac_delim -datadir!$datadir$ac_delim -sysconfdir!$sysconfdir$ac_delim -sharedstatedir!$sharedstatedir$ac_delim -localstatedir!$localstatedir$ac_delim -includedir!$includedir$ac_delim -oldincludedir!$oldincludedir$ac_delim -docdir!$docdir$ac_delim -infodir!$infodir$ac_delim -htmldir!$htmldir$ac_delim -dvidir!$dvidir$ac_delim -pdfdir!$pdfdir$ac_delim -psdir!$psdir$ac_delim -libdir!$libdir$ac_delim -localedir!$localedir$ac_delim -mandir!$mandir$ac_delim -DEFS!$DEFS$ac_delim -ECHO_C!$ECHO_C$ac_delim -ECHO_N!$ECHO_N$ac_delim -ECHO_T!$ECHO_T$ac_delim -LIBS!$LIBS$ac_delim -build_alias!$build_alias$ac_delim -host_alias!$host_alias$ac_delim -target_alias!$target_alias$ac_delim -INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim -INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim -INSTALL_DATA!$INSTALL_DATA$ac_delim -am__isrc!$am__isrc$ac_delim -CYGPATH_W!$CYGPATH_W$ac_delim -PACKAGE!$PACKAGE$ac_delim -VERSION!$VERSION$ac_delim -ACLOCAL!$ACLOCAL$ac_delim -AUTOCONF!$AUTOCONF$ac_delim -AUTOMAKE!$AUTOMAKE$ac_delim -AUTOHEADER!$AUTOHEADER$ac_delim -MAKEINFO!$MAKEINFO$ac_delim -install_sh!$install_sh$ac_delim -STRIP!$STRIP$ac_delim -INSTALL_STRIP_PROGRAM!$INSTALL_STRIP_PROGRAM$ac_delim -mkdir_p!$mkdir_p$ac_delim -AWK!$AWK$ac_delim -SET_MAKE!$SET_MAKE$ac_delim -am__leading_dot!$am__leading_dot$ac_delim -AMTAR!$AMTAR$ac_delim -am__tar!$am__tar$ac_delim -am__untar!$am__untar$ac_delim -PKG_CONFIG!$PKG_CONFIG$ac_delim -API_VERSION!$API_VERSION$ac_delim -POLICY_VERSIONS!$POLICY_VERSIONS$ac_delim -MCS!$MCS$ac_delim -GACUTIL!$GACUTIL$ac_delim -AL!$AL$ac_delim -GACUTIL_FLAGS!$GACUTIL_FLAGS$ac_delim -GACUTIL_POLICY_FLAGS!$GACUTIL_POLICY_FLAGS$ac_delim -ENABLE_GUI_TRUE!$ENABLE_GUI_TRUE$ac_delim -ENABLE_GUI_FALSE!$ENABLE_GUI_FALSE$ac_delim -ENABLE_TESTS_TRUE!$ENABLE_TESTS_TRUE$ac_delim -ENABLE_TESTS_FALSE!$ENABLE_TESTS_FALSE$ac_delim -GTK_SHARP_20_CFLAGS!$GTK_SHARP_20_CFLAGS$ac_delim -GTK_SHARP_20_LIBS!$GTK_SHARP_20_LIBS$ac_delim -MONO_NUNIT_CFLAGS!$MONO_NUNIT_CFLAGS$ac_delim -MONO_NUNIT_LIBS!$MONO_NUNIT_LIBS$ac_delim -MONO_ADDINS_DEFAULT_LIB!$MONO_ADDINS_DEFAULT_LIB$ac_delim -MONO_ADDINS_GUI_DEFAULT_LIB!$MONO_ADDINS_GUI_DEFAULT_LIB$ac_delim -MONO_ADDINS_SETUP_DEFAULT_LIB!$MONO_ADDINS_SETUP_DEFAULT_LIB$ac_delim -LIBOBJS!$LIBOBJS$ac_delim -LTLIBOBJS!$LTLIBOBJS$ac_delim -_ACEOF + . ./conf$$subs.sh || + { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 80; then + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then - { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} { (exit 1); exit 1; }; } else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done +rm -f conf$$subs.sh -ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` -if test -n "$ac_eof"; then - ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` - ac_eof=`expr $ac_eof + 1` -fi - -cat >>$CONFIG_STATUS <<_ACEOF -cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end -_ACEOF -sed ' -s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g -s/^/s,@/; s/!/@,|#_!!_#|/ -:n -t n -s/'"$ac_delim"'$/,g/; t -s/$/\\/; p -N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n -' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF -:end -s/|#_!!_#|//g -CEOF$ac_eof +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$tmp/subs1.awk" <<\\_ACAWK && _ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\).*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\).*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ + || { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5 +$as_echo "$as_me: error: could not setup config files machinery" >&2;} + { (exit 1); exit 1; }; } +_ACEOF # VPATH may cause trouble with some makes, so we remove $(srcdir), # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and @@ -3723,19 +4061,21 @@ }' fi -cat >>$CONFIG_STATUS <<\_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" -for ac_tag in :F $CONFIG_FILES +eval set X " :F $CONFIG_FILES " +shift +for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 -echo "$as_me: error: Invalid tag $ac_tag." >&2;} + :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: invalid tag $ac_tag" >&5 +$as_echo "$as_me: error: invalid tag $ac_tag" >&2;} { (exit 1); exit 1; }; };; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; @@ -3764,26 +4104,38 @@ [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 -echo "$as_me: error: cannot find input file: $ac_f" >&2;} + { { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 +$as_echo "$as_me: error: cannot find input file: $ac_f" >&2;} { (exit 1); exit 1; }; };; esac - ac_file_inputs="$ac_file_inputs $ac_f" + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + ac_file_inputs="$ac_file_inputs '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ - configure_input="Generated from "`IFS=: - echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} + { $as_echo "$as_me:$LINENO: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac case $ac_tag in - *:-:* | *:-) cat >"$tmp/stdin";; + *:-:* | *:-) cat >"$tmp/stdin" \ + || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 +$as_echo "$as_me: error: could not create $ac_file" >&2;} + { (exit 1); exit 1; }; } ;; esac ;; esac @@ -3793,7 +4145,7 @@ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || -echo X"$ac_file" | +$as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -3819,7 +4171,7 @@ as_dirs= while :; do case $as_dir in #( - *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" @@ -3828,7 +4180,7 @@ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -echo X"$as_dir" | +$as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -3849,17 +4201,17 @@ test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 -echo "$as_me: error: cannot create directory $as_dir" >&2;} + } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +$as_echo "$as_me: error: cannot create directory $as_dir" >&2;} { (exit 1); exit 1; }; }; } ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; @@ -3904,12 +4256,13 @@ esac _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= -case `sed -n '/datarootdir/ { +ac_sed_dataroot=' +/datarootdir/ { p q } @@ -3918,13 +4271,14 @@ /@infodir@/p /@localedir@/p /@mandir@/p -' $ac_file_inputs` in +' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 -echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF -cat >>$CONFIG_STATUS <<_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g @@ -3938,15 +4292,16 @@ # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? -cat >>$CONFIG_STATUS <<_ACEOF - sed "$ac_vpsub +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub $extrasub _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s&@configure_input@&$configure_input&;t t +s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t @@ -3957,21 +4312,28 @@ s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack -" $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ + || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 +$as_echo "$as_me: error: could not create $ac_file" >&2;} + { (exit 1); exit 1; }; } test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && - { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' + { $as_echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&5 -echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&2;} rm -f "$tmp/stdin" case $ac_file in - -) cat "$tmp/out"; rm -f "$tmp/out";; - *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; - esac + -) cat "$tmp/out" && rm -f "$tmp/out";; + *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; + esac \ + || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 +$as_echo "$as_me: error: could not create $ac_file" >&2;} + { (exit 1); exit 1; }; } ;; @@ -3986,6 +4348,11 @@ chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save +test $ac_write_fail = 0 || + { { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } + # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. @@ -4007,6 +4374,10 @@ # would make configure fail if this is the last instruction. $ac_cs_success || { (exit 1); exit 1; } fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:$LINENO: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi echo "" @@ -4015,6 +4386,7 @@ echo " * Installation prefix = $prefix" echo " * gui support: $enable_gui" echo " * unit tests: $enable_tests" +echo " * documentation: $enable_docs" echo "" diff -Nru mono-addins-0.4/configure.ac mono-addins-0.6.1/configure.ac --- mono-addins-0.4/configure.ac 2008-11-06 19:52:14.000000000 +0000 +++ mono-addins-0.6.1/configure.ac 2011-04-13 09:00:29.000000000 +0000 @@ -1,8 +1,9 @@ dnl Warning: This is an automatically generated file, do not edit! dnl Process this file with autoconf to produce a configure script. AC_PREREQ([2.54]) -AC_INIT([mono-addins], [0.4]) +AC_INIT([mono-addins], [0.6.1]) AM_INIT_AUTOMAKE([foreign tar-ustar]) +AM_MAINTAINER_MODE dnl pkg-config AC_PATH_PROG(PKG_CONFIG, pkg-config, no) @@ -10,14 +11,14 @@ AC_MSG_ERROR([You need to install pkg-config]) fi -API_VERSION=0.4.0.0 +API_VERSION=0.6.0.0 AC_SUBST(API_VERSION) -POLICY_VERSIONS="0.2 0.3" +POLICY_VERSIONS="0.2 0.3 0.4 0.5" AC_SUBST(POLICY_VERSIONS) AC_PROG_INSTALL -AC_PATH_PROG(MCS, mcs, no) +AC_PATH_PROG(MCS, gmcs, no) if test "x$MCS" = "xno"; then AC_MSG_ERROR([mcs Not found]) fi @@ -32,8 +33,8 @@ AC_MSG_ERROR([No al tool found. You need to install either the mono or .Net SDK.]) fi -GACUTIL_FLAGS='/package mono-addins /root $(DESTDIR)$(prefix)/lib' -GACUTIL_POLICY_FLAGS='/root $(DESTDIR)$(prefix)/lib' +GACUTIL_FLAGS='/package mono-addins /root $(DESTDIR)$(libdir)' +GACUTIL_POLICY_FLAGS='/root $(DESTDIR)$(libdir)' AC_SUBST(GACUTIL) AC_SUBST(GACUTIL_FLAGS) @@ -53,6 +54,13 @@ AM_CONDITIONAL(ENABLE_TESTS, test x$enable_tests = xyes) +AC_ARG_ENABLE(docs, + AC_HELP_STRING([--enable-docs], + [build documentation [default=no]]), + enable_docs=${enableval}, enable_docs=no) + +AM_CONDITIONAL(ENABLE_DOCS, test x$enable_docs = xyes) + if test "x$enable_gui" = "xyes"; then PKG_CHECK_MODULES([GTK_SHARP_20], [gtk-sharp-2.0]) fi @@ -61,28 +69,38 @@ PKG_CHECK_MODULES([MONO_NUNIT], [mono-nunit]) fi +if test "x$enable_docs" = "xyes"; then + PKG_CHECK_MODULES([MONODOC], [monodoc]) +fi + AC_SUBST(MONO_NUNIT_LIBS) MONO_ADDINS_DEFAULT_LIB='Mono.Addins.dll' MONO_ADDINS_SETUP_DEFAULT_LIB='Mono.Addins.Setup.dll' MONO_ADDINS_GUI_DEFAULT_LIB='Mono.Addins.Gui.dll' +MONO_ADDINS_MSBUILD_DEFAULT_LIB='Mono.Addins.MSBuild.dll' AC_SUBST(MONO_ADDINS_DEFAULT_LIB) AC_SUBST(MONO_ADDINS_GUI_DEFAULT_LIB) AC_SUBST(MONO_ADDINS_SETUP_DEFAULT_LIB) +AC_SUBST(MONO_ADDINS_MSBUILD_DEFAULT_LIB) AC_CONFIG_FILES([ +./mono-addins.spec ./Mono.Addins/mono-addins.pc ./Mono.Addins.Gui/mono-addins-gui.pc ./Mono.Addins.Setup/mono-addins-setup.pc +./Mono.Addins.MSBuild/mono-addins-msbuild.pc ./Makefile ./policy.config ./Mono.Addins.Gui/Makefile ./Mono.Addins.Setup/Makefile ./Mono.Addins/Makefile ./Mono.Addins.CecilReflector/Makefile +./Mono.Addins.MSBuild/Makefile ./mautil/Makefile ./mautil/mautil +./docs/Makefile ./Test/HelloWorldExtension/Makefile ./Test/FileContentExtension/Makefile ./Test/UnitTests/Makefile @@ -90,15 +108,6 @@ ./Test/SystemInfoExtension/Makefile ./Test/FileExtender/Makefile ./Test/Makefile -./Samples/TextEditor.Xml/Makefile -./Samples/TextEditor/Makefile -./Samples/TextEditor.CompilerService/Makefile -./Samples/WriterServiceHost/Makefile -./Samples/TextEditor.CompilerService.CSharp/Makefile -./Samples/WriterService.SampleExtender/Makefile -./Samples/Makefile -./Samples/TextEditorLib/Makefile -./Samples/WriterService/Makefile ]) @@ -110,6 +119,7 @@ echo " * Installation prefix = $prefix" echo " * gui support: $enable_gui" echo " * unit tests: $enable_tests" +echo " * documentation: $enable_docs" echo "" diff -Nru mono-addins-0.4/debian/changelog mono-addins-0.6.1/debian/changelog --- mono-addins-0.4/debian/changelog 2011-10-16 17:36:54.000000000 +0000 +++ mono-addins-0.6.1/debian/changelog 2011-10-16 17:22:01.000000000 +0000 @@ -1,3 +1,89 @@ +mono-addins (0.6.1-2ubuntu1~natty1) natty; urgency=low + + * Copied from oneiric + * Removed Microsoft.Build.Utilities.v4.0 patches + + -- Cameron White Sun, 16 Oct 2011 13:08:03 -0400 + +mono-addins (0.6.1-2ubuntu1) oneiric; urgency=low + + * Merge from debian unstable. Remaining changes: + - Update Microsoft.Build.Utilities references to + Microsoft.Build.Utilities.v4.0 for the CLR 4.0. Change will arrive in + Debian soon, so we can sync again then. + + -- Julian Taylor Tue, 02 Aug 2011 23:29:15 +0000 + +mono-addins (0.6.1-2) unstable; urgency=high + + * urgency=high for RC bug fix + * [30fe70d] Cherry-pick patch to fix crash when looking for addin description. + Thanks to Andrés G. Aragoneses (Closes: #630590) + * [cba0471] Fix version on debhelper BD to guarantee override support + + -- Iain Lane Tue, 02 Aug 2011 17:30:27 +0100 + +mono-addins (0.6.1-1ubuntu1) oneiric; urgency=low + + * Update Microsoft.Build.Utilities references to + Microsoft.Build.Utilities.v4.0 for the CLR 4.0. Change will arrive in + Debian soon, so we can sync again then. + * Bump minimal debhelper BD to 7.0.50~ for override support + + -- Iain Lane Tue, 12 Jul 2011 18:52:40 +0100 + +mono-addins (0.6.1-1) unstable; urgency=low + + * [bdc09da] Imported Upstream version 0.6.1 + + Correctly initialises adidnInfoInstalled in the addin manager (Closes: + #629152) + * [2832c45] Remove obsolete fix_addin_scan patch from tree + * [297aae5] Remove portion of fix_mono-addins-msbuild.pc.patch applied upstream + * [3d60321] Standards-Version → 3.9.2, no changes required + * [e6c491d] Remove libmono BD + + -- Iain Lane Sun, 05 Jun 2011 11:38:36 +0100 + +mono-addins (0.6-2) unstable; urgency=low + + * Upload to Unstable + + -- Jo Shields Mon, 25 Apr 2011 11:11:33 +0100 + +mono-addins (0.6-1) experimental; urgency=low + + * [fde2323] Imported Upstream version 0.6 + * [23be1be] Update copyright for 0.6 release + * [f814815] Update install files to include new policy files + * [2d74e13] Bump API version to 0.6 + * [bdb2929] Convert to using Quilt via DebSrc 3.0 + * [b151a30] Remove obsolete patch + debian/patches/fix_ExtensionNodeChildAttribute_ctor_r127062.patch + * [c413eee] Remove obsolete patch + debian/patches/fix_gac_policy_filenames.patch + * [29933d9] Bump Standards version to latest (3.9.1) + * [7343f4c] Switch to full DH7, with dh-autoreconf and DebSrc3 for + patching + * [9587aa5] Remove obsolete debian/patches/fix_configure.ac.patch + patch + * [b6f73f9] Add MSBuild task library + * [a28d839] Update debian/patches/configurable_compiler.patch to deal + with changes in upstream build system + * [e5e0f7f] Update debian/patches/fix_mono-addins.pc.patch to reflech + minor changes in upstream build system + * [23db5e0] Update debian/patches/fix_mono-addins-gui.pc.patch to + reflect minor changes to upstream build system + * [2e7ffea] Update debian/patches/fix_mono-addins-setup.pc.patch to + reflech minor changes to upstream build system + * [91108f7] Remove obsolete patch + debian/patches/fix_gac_policy_filenames.patch + * [efc586f] Add new patch debian/patches/fix_mono-addins- + msbuild.pc.patch to debianize pkg-config file for MSBuild assembly + * [af42a84] Include fix from upstream commit 766850a66a22f09911a6 to + prevent fault MSBuild pcfile + + -- Jo Shields Mon, 14 Mar 2011 18:50:01 +0000 + mono-addins (0.4-8) unstable; urgency=medium * Rebuild of 0.4-7 which doesn't introduce a dependency on Mono from diff -Nru mono-addins-0.4/debian/compat mono-addins-0.6.1/debian/compat --- mono-addins-0.4/debian/compat 2011-10-16 17:36:54.000000000 +0000 +++ mono-addins-0.6.1/debian/compat 2011-08-02 16:30:52.000000000 +0000 @@ -1 +1 @@ -5 +7 diff -Nru mono-addins-0.4/debian/control mono-addins-0.6.1/debian/control --- mono-addins-0.4/debian/control 2011-10-16 17:36:54.000000000 +0000 +++ mono-addins-0.6.1/debian/control 2011-08-02 16:30:52.000000000 +0000 @@ -3,21 +3,16 @@ Priority: optional Maintainer: Debian CLI Libraries Team Uploaders: Mirco Bauer , Sebastian Dröge -Build-Depends: debhelper (>= 5), quilt +Build-Depends: debhelper (>= 7.0.50~), dh-autoreconf Build-Depends-Indep: cli-common-dev (>= 0.5.4), - libtool, - autoconf, - automake, - autotools-dev, pkg-config, mono-devel (>= 2.4.3), - libmono-dev, libglib2.0-cil-dev, libgtk2.0-cil-dev -Standards-Version: 3.8.3 +Standards-Version: 3.9.2 Homepage: http://www.mono-project.com/Mono.Addins -Vcs-Svn: svn://svn.debian.org/pkg-cli-libs/packages/mono-addins/trunk -Vcs-Browser: http://svn.debian.org/wsvn/pkg-cli-libs/packages/mono-addins/trunk/ +Vcs-Git: git://git.debian.org/pkg-cli-libs/packages/mono-addins.git +Vcs-Browser: http://git.debian.org/?p=pkg-cli-libs/packages/mono-addins.git;a=summary Package: libmono-addins0.2-cil Architecture: all @@ -83,6 +78,37 @@ This package contains development files relating to the Mono.Addins.Gui library, and should be used for compilation. +Package: libmono-addins-msbuild0.2-cil +Architecture: all +Depends: ${cli:Depends}, ${misc:Depends}, cli-common (>= 0.5.4) +Description: MSBuild task library for Mono.Addins + Mono.Addins is a framework for creating extensible CLI applications, and for + creating libraries which extend those applications. + Mono.Addins has been designed to be easy to use and useful for a wide range + of applications: from simple applications with small extensibility needs, to + complex applications which need support for large add-in structures. + . + This package contains a MSBuild task library for the Mono.Addins + library. + . + This package contains the Mono.Addins.MSBuild library. + +Package: libmono-addins-msbuild-cil-dev +Architecture: all +Depends: libmono-addins-msbuild0.2-cil (= ${binary:Version}), ${misc:Depends} +Description: MSBuild task library for Mono.Addins + Mono.Addins is a framework for creating extensible CLI applications, and for + creating libraries which extend those applications. + Mono.Addins has been designed to be easy to use and useful for a wide range + of applications: from simple applications with small extensibility needs, to + complex applications which need support for large add-in structures. + . + This package contains a MSBuild task library for the Mono.Addins + library. + . + This package contains development files relating to the Mono.Addins.MSBuild + library, and should be used for compilation. + Package: mono-addins-utils Architecture: all Depends: ${cli:Depends}, ${misc:Depends} diff -Nru mono-addins-0.4/debian/copyright mono-addins-0.6.1/debian/copyright --- mono-addins-0.4/debian/copyright 2011-10-16 17:36:54.000000000 +0000 +++ mono-addins-0.6.1/debian/copyright 2011-08-02 16:30:52.000000000 +0000 @@ -6,10 +6,9 @@ svn://anonsvn.mono-project.com/source/trunk/mono-addins Copyright: -Copyright (C) 2007 Novell, Inc (http://www.novell.com) - -Upstream Authors: -Lluis Sanchez Gual +Copyright (C) 2004-2011 Novell, Inc (http://www.novell.com) +Copyright (c) 2008 - 2010 Jb Evain +(C) 2003 Motus Technologies Inc. (http://www.motus.com) License: Permission is hereby granted, free of charge, to any person obtaining diff -Nru mono-addins-0.4/debian/libmono-addins0.2-cil.install mono-addins-0.6.1/debian/libmono-addins0.2-cil.install --- mono-addins-0.4/debian/libmono-addins0.2-cil.install 2011-10-16 17:36:54.000000000 +0000 +++ mono-addins-0.6.1/debian/libmono-addins0.2-cil.install 2011-08-02 16:30:52.000000000 +0000 @@ -3,5 +3,13 @@ usr/lib/mono/gac/Mono.Addins.CecilReflector/*/* /usr/lib/cli/Mono.Addins.CecilReflector-0.2/ usr/lib/mono/gac/policy.0.2.Mono.Addins/*/* /usr/lib/cli/Mono.Addins-0.2/ usr/lib/mono/gac/policy.0.3.Mono.Addins/*/* /usr/lib/cli/Mono.Addins-0.2/ +usr/lib/mono/gac/policy.0.4.Mono.Addins/*/* /usr/lib/cli/Mono.Addins-0.2/ +usr/lib/mono/gac/policy.0.5.Mono.Addins/*/* /usr/lib/cli/Mono.Addins-0.2/ usr/lib/mono/gac/policy.0.2.Mono.Addins.Setup/*/* /usr/lib/cli/Mono.Addins.Setup-0.2/ usr/lib/mono/gac/policy.0.3.Mono.Addins.Setup/*/* /usr/lib/cli/Mono.Addins.Setup-0.2/ +usr/lib/mono/gac/policy.0.4.Mono.Addins.Setup/*/* /usr/lib/cli/Mono.Addins.Setup-0.2/ +usr/lib/mono/gac/policy.0.5.Mono.Addins.Setup/*/* /usr/lib/cli/Mono.Addins.Setup-0.2/ +usr/lib/mono/gac/policy.0.2.Mono.Addins.CecilReflector/*/* /usr/lib/cli/Mono.Addins.CecilReflector-0.2/ +usr/lib/mono/gac/policy.0.3.Mono.Addins.CecilReflector/*/* /usr/lib/cli/Mono.Addins.CecilReflector-0.2/ +usr/lib/mono/gac/policy.0.4.Mono.Addins.CecilReflector/*/* /usr/lib/cli/Mono.Addins.CecilReflector-0.2/ +usr/lib/mono/gac/policy.0.5.Mono.Addins.CecilReflector/*/* /usr/lib/cli/Mono.Addins.CecilReflector-0.2/ diff -Nru mono-addins-0.4/debian/libmono-addins0.2-cil.installcligac mono-addins-0.6.1/debian/libmono-addins0.2-cil.installcligac --- mono-addins-0.4/debian/libmono-addins0.2-cil.installcligac 2011-10-16 17:36:54.000000000 +0000 +++ mono-addins-0.6.1/debian/libmono-addins0.2-cil.installcligac 2011-08-02 16:30:52.000000000 +0000 @@ -3,5 +3,13 @@ /usr/lib/cli/Mono.Addins.CecilReflector-0.2/Mono.Addins.CecilReflector.dll /usr/lib/cli/Mono.Addins-0.2/policy.0.2.Mono.Addins.dll /usr/lib/cli/Mono.Addins-0.2/policy.0.3.Mono.Addins.dll +/usr/lib/cli/Mono.Addins-0.2/policy.0.4.Mono.Addins.dll +/usr/lib/cli/Mono.Addins-0.2/policy.0.5.Mono.Addins.dll /usr/lib/cli/Mono.Addins.Setup-0.2/policy.0.2.Mono.Addins.Setup.dll /usr/lib/cli/Mono.Addins.Setup-0.2/policy.0.3.Mono.Addins.Setup.dll +/usr/lib/cli/Mono.Addins.Setup-0.2/policy.0.4.Mono.Addins.Setup.dll +/usr/lib/cli/Mono.Addins.Setup-0.2/policy.0.5.Mono.Addins.Setup.dll +/usr/lib/cli/Mono.Addins.CecilReflector-0.2/policy.0.2.Mono.Addins.CecilReflector.dll +/usr/lib/cli/Mono.Addins.CecilReflector-0.2/policy.0.3.Mono.Addins.CecilReflector.dll +/usr/lib/cli/Mono.Addins.CecilReflector-0.2/policy.0.4.Mono.Addins.CecilReflector.dll +/usr/lib/cli/Mono.Addins.CecilReflector-0.2/policy.0.5.Mono.Addins.CecilReflector.dll diff -Nru mono-addins-0.4/debian/libmono-addins-gui0.2-cil.install mono-addins-0.6.1/debian/libmono-addins-gui0.2-cil.install --- mono-addins-0.4/debian/libmono-addins-gui0.2-cil.install 2011-10-16 17:36:54.000000000 +0000 +++ mono-addins-0.6.1/debian/libmono-addins-gui0.2-cil.install 2011-08-02 16:30:52.000000000 +0000 @@ -1,3 +1,5 @@ usr/lib/mono/gac/Mono.Addins.Gui/*/* /usr/lib/cli/Mono.Addins.Gui-0.2/ usr/lib/mono/gac/policy.0.2.Mono.Addins.Gui/*/* /usr/lib/cli/Mono.Addins.Gui-0.2/ usr/lib/mono/gac/policy.0.3.Mono.Addins.Gui/*/* /usr/lib/cli/Mono.Addins.Gui-0.2/ +usr/lib/mono/gac/policy.0.4.Mono.Addins.Gui/*/* /usr/lib/cli/Mono.Addins.Gui-0.2/ +usr/lib/mono/gac/policy.0.5.Mono.Addins.Gui/*/* /usr/lib/cli/Mono.Addins.Gui-0.2/ diff -Nru mono-addins-0.4/debian/libmono-addins-gui0.2-cil.installcligac mono-addins-0.6.1/debian/libmono-addins-gui0.2-cil.installcligac --- mono-addins-0.4/debian/libmono-addins-gui0.2-cil.installcligac 2011-10-16 17:36:54.000000000 +0000 +++ mono-addins-0.6.1/debian/libmono-addins-gui0.2-cil.installcligac 2011-08-02 16:30:52.000000000 +0000 @@ -1,3 +1,5 @@ /usr/lib/cli/Mono.Addins.Gui-0.2/Mono.Addins.Gui.dll /usr/lib/cli/Mono.Addins.Gui-0.2/policy.0.2.Mono.Addins.Gui.dll /usr/lib/cli/Mono.Addins.Gui-0.2/policy.0.3.Mono.Addins.Gui.dll +/usr/lib/cli/Mono.Addins.Gui-0.2/policy.0.4.Mono.Addins.Gui.dll +/usr/lib/cli/Mono.Addins.Gui-0.2/policy.0.5.Mono.Addins.Gui.dll diff -Nru mono-addins-0.4/debian/libmono-addins-msbuild0.2-cil.install mono-addins-0.6.1/debian/libmono-addins-msbuild0.2-cil.install --- mono-addins-0.4/debian/libmono-addins-msbuild0.2-cil.install 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/debian/libmono-addins-msbuild0.2-cil.install 2011-08-02 16:30:52.000000000 +0000 @@ -0,0 +1,5 @@ +usr/lib/mono/gac/Mono.Addins.MSBuild/*/* /usr/lib/cli/Mono.Addins.MSBuild-0.2/ +usr/lib/mono/gac/policy.0.2.Mono.Addins.MSBuild/*/* /usr/lib/cli/Mono.Addins.MSBuild-0.2/ +usr/lib/mono/gac/policy.0.3.Mono.Addins.MSBuild/*/* /usr/lib/cli/Mono.Addins.MSBuild-0.2/ +usr/lib/mono/gac/policy.0.4.Mono.Addins.MSBuild/*/* /usr/lib/cli/Mono.Addins.MSBuild-0.2/ +usr/lib/mono/gac/policy.0.5.Mono.Addins.MSBuild/*/* /usr/lib/cli/Mono.Addins.MSBuild-0.2/ diff -Nru mono-addins-0.4/debian/libmono-addins-msbuild0.2-cil.installcligac mono-addins-0.6.1/debian/libmono-addins-msbuild0.2-cil.installcligac --- mono-addins-0.4/debian/libmono-addins-msbuild0.2-cil.installcligac 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/debian/libmono-addins-msbuild0.2-cil.installcligac 2011-08-02 16:30:52.000000000 +0000 @@ -0,0 +1,5 @@ +/usr/lib/cli/Mono.Addins.MSBuild-0.2/Mono.Addins.MSBuild.dll +/usr/lib/cli/Mono.Addins.MSBuild-0.2/policy.0.2.Mono.Addins.MSBuild.dll +/usr/lib/cli/Mono.Addins.MSBuild-0.2/policy.0.3.Mono.Addins.MSBuild.dll +/usr/lib/cli/Mono.Addins.MSBuild-0.2/policy.0.4.Mono.Addins.MSBuild.dll +/usr/lib/cli/Mono.Addins.MSBuild-0.2/policy.0.5.Mono.Addins.MSBuild.dll diff -Nru mono-addins-0.4/debian/libmono-addins-msbuild-cil-dev.install mono-addins-0.6.1/debian/libmono-addins-msbuild-cil-dev.install --- mono-addins-0.4/debian/libmono-addins-msbuild-cil-dev.install 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/debian/libmono-addins-msbuild-cil-dev.install 2011-08-02 16:30:52.000000000 +0000 @@ -0,0 +1 @@ +usr/lib/pkgconfig/mono-addins-msbuild.pc /usr/lib/pkgconfig/ diff -Nru mono-addins-0.4/debian/patches/0001-configurable_compiler.patch.patch mono-addins-0.6.1/debian/patches/0001-configurable_compiler.patch.patch --- mono-addins-0.4/debian/patches/0001-configurable_compiler.patch.patch 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/debian/patches/0001-configurable_compiler.patch.patch 2011-08-02 16:30:52.000000000 +0000 @@ -0,0 +1,84 @@ +From: Debian CLI Libraries Team +Date: Tue, 2 Aug 2011 14:31:49 +0100 +Subject: configurable_compiler.patch + +=================================================================== +--- + Mono.Addins.Gui/Makefile.am | 2 +- + Mono.Addins.MSBuild/Makefile.am | 2 +- + Mono.Addins.Setup/Makefile.am | 2 +- + Mono.Addins/Makefile.am | 2 +- + Test/SystemInfoExtension/Makefile.am | 2 +- + mautil/Makefile.am | 2 +- + 6 files changed, 6 insertions(+), 6 deletions(-) + +diff --git a/Mono.Addins.Gui/Makefile.am b/Mono.Addins.Gui/Makefile.am +index 0705ae4..1f21cd2 100644 +--- a/Mono.Addins.Gui/Makefile.am ++++ b/Mono.Addins.Gui/Makefile.am +@@ -1,6 +1,6 @@ + + KEY_FILE=$(top_srcdir)/mono-addins.snk +-ASSEMBLY_COMPILER_COMMAND = gmcs ++ASSEMBLY_COMPILER_COMMAND = @MCS@ + ASSEMBLY_COMPILER_FLAGS = -unsafe -keyfile:$(KEY_FILE) -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG + ASSEMBLY = ../bin/Mono.Addins.Gui.dll + ASSEMBLY_NAME=Mono.Addins.Gui +diff --git a/Mono.Addins.MSBuild/Makefile.am b/Mono.Addins.MSBuild/Makefile.am +index 6b74000..bc8bc07 100644 +--- a/Mono.Addins.MSBuild/Makefile.am ++++ b/Mono.Addins.MSBuild/Makefile.am +@@ -1,6 +1,6 @@ + + KEY_FILE=$(top_srcdir)/mono-addins.snk +-ASSEMBLY_COMPILER_COMMAND = gmcs ++ASSEMBLY_COMPILER_COMMAND = @MCS@ + ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG + ASSEMBLY = ../bin/Mono.Addins.MSBuild.dll + ASSEMBLY_NAME=Mono.Addins.MSBuild +diff --git a/Mono.Addins.Setup/Makefile.am b/Mono.Addins.Setup/Makefile.am +index 598f62f..f77b391 100644 +--- a/Mono.Addins.Setup/Makefile.am ++++ b/Mono.Addins.Setup/Makefile.am +@@ -1,6 +1,6 @@ + + KEY_FILE=$(top_srcdir)/mono-addins.snk +-ASSEMBLY_COMPILER_COMMAND = gmcs ++ASSEMBLY_COMPILER_COMMAND = @MCS@ + ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG + ASSEMBLY = ../bin/Mono.Addins.Setup.dll + ASSEMBLY_NAME=Mono.Addins.Setup +diff --git a/Mono.Addins/Makefile.am b/Mono.Addins/Makefile.am +index d5c1442..13ebaa8 100644 +--- a/Mono.Addins/Makefile.am ++++ b/Mono.Addins/Makefile.am +@@ -1,6 +1,6 @@ + + KEY_FILE=$(top_srcdir)/mono-addins.snk +-ASSEMBLY_COMPILER_COMMAND = gmcs ++ASSEMBLY_COMPILER_COMMAND = @MCS@ + ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG + ASSEMBLY = ../bin/Mono.Addins.dll + ASSEMBLY_NAME=Mono.Addins +diff --git a/Test/SystemInfoExtension/Makefile.am b/Test/SystemInfoExtension/Makefile.am +index 41aa6a7..f20e289 100644 +--- a/Test/SystemInfoExtension/Makefile.am ++++ b/Test/SystemInfoExtension/Makefile.am +@@ -1,4 +1,4 @@ +-ASSEMBLY_COMPILER_COMMAND = gmcs ++ASSEMBLY_COMPILER_COMMAND = @MCS@ + ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG + ASSEMBLY = ../lib/SystemInfoExtension.dll + COMPILE_TARGET = library +diff --git a/mautil/Makefile.am b/mautil/Makefile.am +index 89c7df6..0e92ef0 100644 +--- a/mautil/Makefile.am ++++ b/mautil/Makefile.am +@@ -1,5 +1,5 @@ + +-ASSEMBLY_COMPILER_COMMAND = gmcs ++ASSEMBLY_COMPILER_COMMAND = @MCS@ + ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG + ASSEMBLY = ../bin/mautil.exe + COMPILE_TARGET = exe +-- diff -Nru mono-addins-0.4/debian/patches/0002-fix_mono-addins.pc.patch.patch mono-addins-0.6.1/debian/patches/0002-fix_mono-addins.pc.patch.patch --- mono-addins-0.4/debian/patches/0002-fix_mono-addins.pc.patch.patch 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/debian/patches/0002-fix_mono-addins.pc.patch.patch 2011-08-02 16:30:52.000000000 +0000 @@ -0,0 +1,34 @@ +From: Debian CLI Libraries Team +Date: Tue, 2 Aug 2011 14:31:49 +0100 +Subject: fix_mono-addins.pc.patch + +#! /bin/sh /usr/share/dpatch/dpatch-run +## fix_mono-addins-gui.pc.dpatch by Mirco Bauer +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: No description. + +@DPATCH@ +--- + Mono.Addins/mono-addins.pc.in | 4 +--- + 1 files changed, 1 insertions(+), 3 deletions(-) + +diff --git a/Mono.Addins/mono-addins.pc.in b/Mono.Addins/mono-addins.pc.in +index 2d098ca..11f4f73 100644 +--- a/Mono.Addins/mono-addins.pc.in ++++ b/Mono.Addins/mono-addins.pc.in +@@ -1,12 +1,10 @@ + prefix=${pcfiledir}/../.. + exec_prefix=${prefix} +-pkglibdir=${prefix}/lib/mono/@PACKAGE@ ++pkglibdir=${prefix}/lib/cli/Mono.Addins-#PACKAGE_ABI_VERSION# + +-Libraries=${pkglibdir}/@MONO_ADDINS_DEFAULT_LIB@ + + Name: Mono.Addins + Description: + Version: @VERSION@ + +-Requires: + Libs: -r:${pkglibdir}/@MONO_ADDINS_DEFAULT_LIB@ +-- diff -Nru mono-addins-0.4/debian/patches/0003-fix_mono-addins-gui.pc.patch.patch mono-addins-0.6.1/debian/patches/0003-fix_mono-addins-gui.pc.patch.patch --- mono-addins-0.4/debian/patches/0003-fix_mono-addins-gui.pc.patch.patch 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/debian/patches/0003-fix_mono-addins-gui.pc.patch.patch 2011-08-02 16:30:52.000000000 +0000 @@ -0,0 +1,35 @@ +From: Debian CLI Libraries Team +Date: Tue, 2 Aug 2011 14:31:49 +0100 +Subject: fix_mono-addins-gui.pc.patch + +#! /bin/sh /usr/share/dpatch/dpatch-run +## fix_mono-addins-gui.pc.dpatch by Mirco Bauer +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: No description. + +@DPATCH@ +--- + Mono.Addins.Gui/mono-addins-gui.pc.in | 5 ++--- + 1 files changed, 2 insertions(+), 3 deletions(-) + +diff --git a/Mono.Addins.Gui/mono-addins-gui.pc.in b/Mono.Addins.Gui/mono-addins-gui.pc.in +index e2857ec..b0a9300 100644 +--- a/Mono.Addins.Gui/mono-addins-gui.pc.in ++++ b/Mono.Addins.Gui/mono-addins-gui.pc.in +@@ -1,12 +1,11 @@ + prefix=${pcfiledir}/../.. + exec_prefix=${prefix} +-pkglibdir=${prefix}/lib/mono/@PACKAGE@ ++pkglibdir=${prefix}/lib/cli/Mono.Addins.Gui-#PACKAGE_ABI_VERSION# + +-Libraries=${pkglibdir}/@MONO_ADDINS_GUI_DEFAULT_LIB@ + + Name: Mono.Addins.Gui + Description: + Version: @VERSION@ + +-Requires: mono-addins ++Requires: gtk-sharp-2.0 mono-addins + Libs: -r:${pkglibdir}/@MONO_ADDINS_GUI_DEFAULT_LIB@ +-- diff -Nru mono-addins-0.4/debian/patches/0004-fix_mono-addins-setup.pc.patch.patch mono-addins-0.6.1/debian/patches/0004-fix_mono-addins-setup.pc.patch.patch --- mono-addins-0.4/debian/patches/0004-fix_mono-addins-setup.pc.patch.patch 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/debian/patches/0004-fix_mono-addins-setup.pc.patch.patch 2011-08-02 16:30:52.000000000 +0000 @@ -0,0 +1,30 @@ +From: Debian CLI Libraries Team +Date: Tue, 2 Aug 2011 14:31:49 +0100 +Subject: fix_mono-addins-setup.pc.patch + +#! /bin/sh /usr/share/dpatch/dpatch-run +## fix_mono-addins-setup.pc.dpatch by Mirco Bauer +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: No description. + +@DPATCH@ +--- + Mono.Addins.Setup/mono-addins-setup.pc.in | 3 +-- + 1 files changed, 1 insertions(+), 2 deletions(-) + +diff --git a/Mono.Addins.Setup/mono-addins-setup.pc.in b/Mono.Addins.Setup/mono-addins-setup.pc.in +index ec6cb95..5a2e61f 100644 +--- a/Mono.Addins.Setup/mono-addins-setup.pc.in ++++ b/Mono.Addins.Setup/mono-addins-setup.pc.in +@@ -1,8 +1,7 @@ + prefix=${pcfiledir}/../.. + exec_prefix=${prefix} +-pkglibdir=${prefix}/lib/mono/@PACKAGE@ ++pkglibdir=${prefix}/lib/cli/Mono.Addins.Setup-#PACKAGE_ABI_VERSION# + +-Libraries=${pkglibdir}/@MONO_ADDINS_SETUP_DEFAULT_LIB@ + + Name: Mono.Addins.Setup + Description: +-- diff -Nru mono-addins-0.4/debian/patches/0005-fix_mono-addins-msbuild.pc.patch.patch mono-addins-0.6.1/debian/patches/0005-fix_mono-addins-msbuild.pc.patch.patch --- mono-addins-0.4/debian/patches/0005-fix_mono-addins-msbuild.pc.patch.patch 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/debian/patches/0005-fix_mono-addins-msbuild.pc.patch.patch 2011-08-02 16:30:52.000000000 +0000 @@ -0,0 +1,24 @@ +From: Debian CLI Libraries Team +Date: Tue, 2 Aug 2011 14:31:49 +0100 +Subject: fix_mono-addins-msbuild.pc.patch + +=================================================================== +--- + Mono.Addins.MSBuild/mono-addins-msbuild.pc.in | 3 +-- + 1 files changed, 1 insertions(+), 2 deletions(-) + +diff --git a/Mono.Addins.MSBuild/mono-addins-msbuild.pc.in b/Mono.Addins.MSBuild/mono-addins-msbuild.pc.in +index c6e146a..f1f1e5d 100644 +--- a/Mono.Addins.MSBuild/mono-addins-msbuild.pc.in ++++ b/Mono.Addins.MSBuild/mono-addins-msbuild.pc.in +@@ -1,8 +1,7 @@ + prefix=${pcfiledir}/../.. + exec_prefix=${prefix} +-pkglibdir=${prefix}/lib/mono/@PACKAGE@ ++pkglibdir=${prefix}/lib/cli/Mono.Addins.MSBuild-#PACKAGE_ABI_VERSION# + +-Libraries=${pkglibdir}/@MONO_ADDINS_MSBUILD_DEFAULT_LIB@ + + Name: Mono.Addins.MSBuild + Description: +-- diff -Nru mono-addins-0.4/debian/patches/0006-Fix-Repair-to-prevent-crashing-when-looking-for-addi.patch mono-addins-0.6.1/debian/patches/0006-Fix-Repair-to-prevent-crashing-when-looking-for-addi.patch --- mono-addins-0.4/debian/patches/0006-Fix-Repair-to-prevent-crashing-when-looking-for-addi.patch 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/debian/patches/0006-Fix-Repair-to-prevent-crashing-when-looking-for-addi.patch 2011-08-02 16:30:52.000000000 +0000 @@ -0,0 +1,66 @@ +From: =?UTF-8?q?"Andr=C3=A9s=20G.=20Aragoneses"?= +Date: Fri, 22 Jul 2011 00:11:12 +0100 +Subject: Fix Repair() to prevent crashing when looking for addin descriptions + +This modification fixes a bug in the Repair method. The bug was very +hard to catch, as a very low rate of banshee users could hit it. +However, since the LatestVersion-checking feature was committed (which +was implemented by commit in +https://github.com/mono/mono-addins/commit/a4f3b3c46e5e798b1378941a2f99bcce1492c903 +and bisected by Iain Lane in +http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=630590), the +bug was exposed as 100% reproducible in debug mode ('banshee --debug'). + +This LatestVersion-feature introduced the possibility that addins could +query the addins collections when asked for their Enabled property (to +find other sibling-addins with different versions), which made the +Repair() method crash, as it firstly removes the AddinCache folders, and +after that it tries to update the database by looking at their content +(and the content was removed by itself). Before the +LatestVersion-feature was introduced, this bug would not be hit so often +because it was less likely to find a non-empty "allSetupInfos" +cache-variable combined with an empty "addinSetupInfos" cache-variable. +Both circumstances happening at the same time would cause an +Addin.ReadFromDescription() call, while iterating over the cached addins +to find if each addin is not root. + +Fixes http://monoaddins.codeplex.com/workitem/6901 . +(cherry picked from commit 2bf0f4b5c56c56473e0a055f0f987309f3dd366a) +--- + Mono.Addins/Mono.Addins.Database/AddinDatabase.cs | 11 +++++++++-- + 1 files changed, 9 insertions(+), 2 deletions(-) + +diff --git a/Mono.Addins/Mono.Addins.Database/AddinDatabase.cs b/Mono.Addins/Mono.Addins.Database/AddinDatabase.cs +index 91dd779..2ce6e85 100644 +--- a/Mono.Addins/Mono.Addins.Database/AddinDatabase.cs ++++ b/Mono.Addins/Mono.Addins.Database/AddinDatabase.cs +@@ -940,12 +940,17 @@ namespace Mono.Addins.Database + } + return lastDomainId.ToString (); + } +- +- internal void ResetCachedData () ++ ++ internal void ResetBasicCachedData () + { + allSetupInfos = null; + addinSetupInfos = null; + rootSetupInfos = null; ++ } ++ ++ internal void ResetCachedData () ++ { ++ ResetBasicCachedData (); + hostIndex = null; + cachedAddinSetupInfos.Clear (); + if (addinEngine != null) +@@ -1001,6 +1006,8 @@ namespace Mono.Addins.Database + monitor.ReportError ("The add-in registry could not be rebuilt. It may be due to lack of write permissions to the directory: " + AddinDbDir, ex); + } + } ++ ResetBasicCachedData (); ++ + Update (monitor, domain); + } + +-- diff -Nru mono-addins-0.4/debian/patches/configurable_compiler.patch mono-addins-0.6.1/debian/patches/configurable_compiler.patch --- mono-addins-0.4/debian/patches/configurable_compiler.patch 2011-10-16 17:36:54.000000000 +0000 +++ mono-addins-0.6.1/debian/patches/configurable_compiler.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,164 +0,0 @@ ---- mono-addins-0.4.orig/Mono.Addins.CecilReflector/Makefile.am -+++ mono-addins-0.4/Mono.Addins.CecilReflector/Makefile.am -@@ -1,6 +1,6 @@ - - KEY_FILE=$(top_srcdir)/mono-addins.snk --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../bin/Mono.Addins.CecilReflector.dll - ASSEMBLY_NAME=Mono.Addins.CecilReflector ---- mono-addins-0.4.orig/Mono.Addins.Gui/Makefile.am -+++ mono-addins-0.4/Mono.Addins.Gui/Makefile.am -@@ -1,6 +1,6 @@ - - KEY_FILE=$(top_srcdir)/mono-addins.snk --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../bin/Mono.Addins.Gui.dll - ASSEMBLY_NAME=Mono.Addins.Gui ---- mono-addins-0.4.orig/Mono.Addins.Setup/Makefile.am -+++ mono-addins-0.4/Mono.Addins.Setup/Makefile.am -@@ -1,6 +1,6 @@ - - KEY_FILE=$(top_srcdir)/mono-addins.snk --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -langversion:ISO-1 -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../bin/Mono.Addins.Setup.dll - ASSEMBLY_NAME=Mono.Addins.Setup ---- mono-addins-0.4.orig/Mono.Addins/Makefile.am -+++ mono-addins-0.4/Mono.Addins/Makefile.am -@@ -1,6 +1,6 @@ - - KEY_FILE=$(top_srcdir)/mono-addins.snk --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -langversion:ISO-1 -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG "-main:Mono.Addins.Database.SetupProcess" - ASSEMBLY = ../bin/Mono.Addins.dll - ASSEMBLY_NAME=Mono.Addins ---- mono-addins-0.4.orig/Samples/TextEditor.CompilerService.CSharp/Makefile.am -+++ mono-addins-0.4/Samples/TextEditor.CompilerService.CSharp/Makefile.am -@@ -1,5 +1,5 @@ - --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../bin/TextEditor.CompilerService.CSharp.dll - COMPILE_TARGET = library ---- mono-addins-0.4.orig/Samples/TextEditor.CompilerService/Makefile.am -+++ mono-addins-0.4/Samples/TextEditor.CompilerService/Makefile.am -@@ -1,5 +1,5 @@ - --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../bin/TextEditor.CompilerService.dll - COMPILE_TARGET = library ---- mono-addins-0.4.orig/Samples/TextEditor.Xml/Makefile.am -+++ mono-addins-0.4/Samples/TextEditor.Xml/Makefile.am -@@ -1,4 +1,4 @@ --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../bin/XmlAddin.dll - COMPILE_TARGET = library ---- mono-addins-0.4.orig/Samples/TextEditor/Makefile.am -+++ mono-addins-0.4/Samples/TextEditor/Makefile.am -@@ -1,5 +1,5 @@ - --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../bin/TextEditor.exe - COMPILE_TARGET = exe ---- mono-addins-0.4.orig/Samples/TextEditorLib/Makefile.am -+++ mono-addins-0.4/Samples/TextEditorLib/Makefile.am -@@ -1,4 +1,4 @@ --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../bin/TextEditorLib.dll - COMPILE_TARGET = library ---- mono-addins-0.4.orig/Samples/WriterService.SampleExtender/Makefile.am -+++ mono-addins-0.4/Samples/WriterService.SampleExtender/Makefile.am -@@ -1,4 +1,4 @@ --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../bin/SampleExtender.dll - COMPILE_TARGET = library ---- mono-addins-0.4.orig/Samples/WriterService/Makefile.am -+++ mono-addins-0.4/Samples/WriterService/Makefile.am -@@ -1,4 +1,4 @@ --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../bin/WriterService.dll - COMPILE_TARGET = library ---- mono-addins-0.4.orig/Samples/WriterServiceHost/Makefile.am -+++ mono-addins-0.4/Samples/WriterServiceHost/Makefile.am -@@ -1,4 +1,4 @@ --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../bin/SampleAddinHost.exe - COMPILE_TARGET = exe ---- mono-addins-0.4.orig/Test/CommandExtension/Makefile.am -+++ mono-addins-0.4/Test/CommandExtension/Makefile.am -@@ -1,4 +1,4 @@ --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../lib/CommandExtension.dll - COMPILE_TARGET = library ---- mono-addins-0.4.orig/Test/FileContentExtension/Makefile.am -+++ mono-addins-0.4/Test/FileContentExtension/Makefile.am -@@ -1,4 +1,4 @@ --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../lib/FileContentExtension.dll - COMPILE_TARGET = library ---- mono-addins-0.4.orig/Test/FileExtender/Makefile.am -+++ mono-addins-0.4/Test/FileExtender/Makefile.am -@@ -1,4 +1,4 @@ --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../lib/extras/FileExtender.dll - COMPILE_TARGET = library ---- mono-addins-0.4.orig/Test/HelloWorldExtension/Makefile.am -+++ mono-addins-0.4/Test/HelloWorldExtension/Makefile.am -@@ -1,4 +1,4 @@ --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../lib/HelloWorldExtension.dll - COMPILE_TARGET = library ---- mono-addins-0.4.orig/Test/SystemInfoExtension/Makefile.am -+++ mono-addins-0.4/Test/SystemInfoExtension/Makefile.am -@@ -1,4 +1,4 @@ --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../lib/SystemInfoExtension.dll - COMPILE_TARGET = library ---- mono-addins-0.4.orig/Test/UnitTests/Makefile.am -+++ mono-addins-0.4/Test/UnitTests/Makefile.am -@@ -1,4 +1,4 @@ --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ./bin/Debug/UnitTests.dll - COMPILE_TARGET = library ---- mono-addins-0.4.orig/mautil/Makefile.am -+++ mono-addins-0.4/mautil/Makefile.am -@@ -1,5 +1,5 @@ - --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../bin/mautil.exe - COMPILE_TARGET = exe diff -Nru mono-addins-0.4/debian/patches/fix_addin_scan.patch mono-addins-0.6.1/debian/patches/fix_addin_scan.patch --- mono-addins-0.4/debian/patches/fix_addin_scan.patch 2011-10-16 17:36:54.000000000 +0000 +++ mono-addins-0.6.1/debian/patches/fix_addin_scan.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -#! /bin/sh /usr/share/dpatch/dpatch-run -## fix_addin_scan.dpatch by Tim Retout -## -## All lines beginning with `## DP:' are a description of the patch. -## DP: Fix from upstream SVN r95443 for addin scan issue. Closes: #459649 - -@DPATCH@ -diff -urNad mono-addins~/Mono.Addins/Mono.Addins.Database/AddinDatabase.cs mono-addins/Mono.Addins/Mono.Addins.Database/AddinDatabase.cs ---- mono-addins~/Mono.Addins/Mono.Addins.Database/AddinDatabase.cs 2008-01-30 22:37:53.000000000 +0000 -+++ mono-addins/Mono.Addins/Mono.Addins.Database/AddinDatabase.cs 2008-03-20 16:46:40.000000000 +0000 -@@ -512,6 +512,8 @@ - string dir = Path.GetDirectoryName (mp); - string pat = Path.GetFileName (mp); - foreach (string fmp in fileDatabase.GetDirectoryFiles (dir, pat)) { -+ if (files.Contains (fmp)) -+ continue; - files.Add (fmp); - string an = Path.GetFileNameWithoutExtension (fmp); - changedAddins [an] = an; diff -Nru mono-addins-0.4/debian/patches/fix_build-system.dpatch mono-addins-0.6.1/debian/patches/fix_build-system.dpatch --- mono-addins-0.4/debian/patches/fix_build-system.dpatch 2011-10-16 17:36:54.000000000 +0000 +++ mono-addins-0.6.1/debian/patches/fix_build-system.dpatch 1970-01-01 00:00:00.000000000 +0000 @@ -1,179 +0,0 @@ -#! /bin/sh /usr/share/dpatch/dpatch-run -## fix_build-system.dpatch by Steve Langasek -## -## All lines beginning with `## DP:' are a description of the patch. -## DP: No description. - -@DPATCH@ -diff -urNad mono-addins-0.3.1~/Mono.Addins/Makefile.am mono-addins-0.3.1/Mono.Addins/Makefile.am ---- mono-addins-0.3.1~/Mono.Addins/Makefile.am 2008-01-30 22:37:53.000000000 +0000 -+++ mono-addins-0.3.1/Mono.Addins/Makefile.am 2008-12-17 17:43:36.000000000 +0000 -@@ -1,6 +1,6 @@ - - KEY_FILE=$(top_srcdir)/mono-addins.snk --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -langversion:ISO-1 -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG "-main:Mono.Addins.Database.SetupProcess" - ASSEMBLY = ../bin/Mono.Addins.dll - ASSEMBLY_NAME=Mono.Addins -diff -urNad mono-addins-0.3.1~/Mono.Addins.Gui/Makefile.am mono-addins-0.3.1/Mono.Addins.Gui/Makefile.am ---- mono-addins-0.3.1~/Mono.Addins.Gui/Makefile.am 2008-01-30 22:37:49.000000000 +0000 -+++ mono-addins-0.3.1/Mono.Addins.Gui/Makefile.am 2008-12-17 17:43:36.000000000 +0000 -@@ -1,6 +1,6 @@ - - KEY_FILE=$(top_srcdir)/mono-addins.snk --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../bin/Mono.Addins.Gui.dll - ASSEMBLY_NAME=Mono.Addins.Gui -diff -urNad mono-addins-0.3.1~/Mono.Addins.Setup/Makefile.am mono-addins-0.3.1/Mono.Addins.Setup/Makefile.am ---- mono-addins-0.3.1~/Mono.Addins.Setup/Makefile.am 2008-01-30 22:37:51.000000000 +0000 -+++ mono-addins-0.3.1/Mono.Addins.Setup/Makefile.am 2008-12-17 17:43:36.000000000 +0000 -@@ -1,6 +1,6 @@ - - KEY_FILE=$(top_srcdir)/mono-addins.snk --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -langversion:ISO-1 -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../bin/Mono.Addins.Setup.dll - ASSEMBLY_NAME=Mono.Addins.Setup -diff -urNad mono-addins-0.3.1~/Samples/TextEditor/Makefile.am mono-addins-0.3.1/Samples/TextEditor/Makefile.am ---- mono-addins-0.3.1~/Samples/TextEditor/Makefile.am 2008-01-30 22:37:50.000000000 +0000 -+++ mono-addins-0.3.1/Samples/TextEditor/Makefile.am 2008-12-17 17:43:36.000000000 +0000 -@@ -1,5 +1,5 @@ - --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../bin/TextEditor.exe - COMPILE_TARGET = exe -diff -urNad mono-addins-0.3.1~/Samples/TextEditor.CompilerService/Makefile.am mono-addins-0.3.1/Samples/TextEditor.CompilerService/Makefile.am ---- mono-addins-0.3.1~/Samples/TextEditor.CompilerService/Makefile.am 2008-01-30 22:37:49.000000000 +0000 -+++ mono-addins-0.3.1/Samples/TextEditor.CompilerService/Makefile.am 2008-12-17 17:43:36.000000000 +0000 -@@ -1,5 +1,5 @@ - --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../bin/TextEditor.CompilerService.dll - COMPILE_TARGET = library -diff -urNad mono-addins-0.3.1~/Samples/TextEditor.CompilerService.CSharp/Makefile.am mono-addins-0.3.1/Samples/TextEditor.CompilerService.CSharp/Makefile.am ---- mono-addins-0.3.1~/Samples/TextEditor.CompilerService.CSharp/Makefile.am 2008-01-30 22:37:49.000000000 +0000 -+++ mono-addins-0.3.1/Samples/TextEditor.CompilerService.CSharp/Makefile.am 2008-12-17 17:43:36.000000000 +0000 -@@ -1,5 +1,5 @@ - --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../bin/TextEditor.CompilerService.CSharp.dll - COMPILE_TARGET = library -diff -urNad mono-addins-0.3.1~/Samples/TextEditor.Xml/Makefile.am mono-addins-0.3.1/Samples/TextEditor.Xml/Makefile.am ---- mono-addins-0.3.1~/Samples/TextEditor.Xml/Makefile.am 2008-01-30 22:37:50.000000000 +0000 -+++ mono-addins-0.3.1/Samples/TextEditor.Xml/Makefile.am 2008-12-17 17:43:36.000000000 +0000 -@@ -1,4 +1,4 @@ --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../bin/XmlAddin.dll - COMPILE_TARGET = library -diff -urNad mono-addins-0.3.1~/Samples/TextEditorLib/Makefile.am mono-addins-0.3.1/Samples/TextEditorLib/Makefile.am ---- mono-addins-0.3.1~/Samples/TextEditorLib/Makefile.am 2008-01-30 22:37:49.000000000 +0000 -+++ mono-addins-0.3.1/Samples/TextEditorLib/Makefile.am 2008-12-17 17:43:36.000000000 +0000 -@@ -1,4 +1,4 @@ --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../bin/TextEditorLib.dll - COMPILE_TARGET = library -diff -urNad mono-addins-0.3.1~/Samples/WriterService/Makefile.am mono-addins-0.3.1/Samples/WriterService/Makefile.am ---- mono-addins-0.3.1~/Samples/WriterService/Makefile.am 2008-01-30 22:37:50.000000000 +0000 -+++ mono-addins-0.3.1/Samples/WriterService/Makefile.am 2008-12-17 17:43:36.000000000 +0000 -@@ -1,4 +1,4 @@ --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../bin/WriterService.dll - COMPILE_TARGET = library -diff -urNad mono-addins-0.3.1~/Samples/WriterService.SampleExtender/Makefile.am mono-addins-0.3.1/Samples/WriterService.SampleExtender/Makefile.am ---- mono-addins-0.3.1~/Samples/WriterService.SampleExtender/Makefile.am 2008-01-30 22:37:50.000000000 +0000 -+++ mono-addins-0.3.1/Samples/WriterService.SampleExtender/Makefile.am 2008-12-17 17:43:36.000000000 +0000 -@@ -1,4 +1,4 @@ --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../bin/SampleExtender.dll - COMPILE_TARGET = library -diff -urNad mono-addins-0.3.1~/Samples/WriterServiceHost/Makefile.am mono-addins-0.3.1/Samples/WriterServiceHost/Makefile.am ---- mono-addins-0.3.1~/Samples/WriterServiceHost/Makefile.am 2008-01-30 22:37:50.000000000 +0000 -+++ mono-addins-0.3.1/Samples/WriterServiceHost/Makefile.am 2008-12-17 17:43:36.000000000 +0000 -@@ -1,4 +1,4 @@ --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../bin/SampleAddinHost.exe - COMPILE_TARGET = exe -diff -urNad mono-addins-0.3.1~/Test/CommandExtension/Makefile.am mono-addins-0.3.1/Test/CommandExtension/Makefile.am ---- mono-addins-0.3.1~/Test/CommandExtension/Makefile.am 2008-01-30 22:37:47.000000000 +0000 -+++ mono-addins-0.3.1/Test/CommandExtension/Makefile.am 2008-12-17 17:43:36.000000000 +0000 -@@ -1,4 +1,4 @@ --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../lib/CommandExtension.dll - COMPILE_TARGET = library -diff -urNad mono-addins-0.3.1~/Test/FileContentExtension/Makefile.am mono-addins-0.3.1/Test/FileContentExtension/Makefile.am ---- mono-addins-0.3.1~/Test/FileContentExtension/Makefile.am 2008-01-30 22:37:47.000000000 +0000 -+++ mono-addins-0.3.1/Test/FileContentExtension/Makefile.am 2008-12-17 17:43:36.000000000 +0000 -@@ -1,4 +1,4 @@ --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../lib/FileContentExtension.dll - COMPILE_TARGET = library -diff -urNad mono-addins-0.3.1~/Test/FileExtender/Makefile.am mono-addins-0.3.1/Test/FileExtender/Makefile.am ---- mono-addins-0.3.1~/Test/FileExtender/Makefile.am 2008-01-30 22:37:48.000000000 +0000 -+++ mono-addins-0.3.1/Test/FileExtender/Makefile.am 2008-12-17 17:43:36.000000000 +0000 -@@ -1,4 +1,4 @@ --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../lib/extras/FileExtender.dll - COMPILE_TARGET = library -diff -urNad mono-addins-0.3.1~/Test/HelloWorldExtension/Makefile.am mono-addins-0.3.1/Test/HelloWorldExtension/Makefile.am ---- mono-addins-0.3.1~/Test/HelloWorldExtension/Makefile.am 2008-01-30 22:37:47.000000000 +0000 -+++ mono-addins-0.3.1/Test/HelloWorldExtension/Makefile.am 2008-12-17 17:43:36.000000000 +0000 -@@ -1,4 +1,4 @@ --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../lib/HelloWorldExtension.dll - COMPILE_TARGET = library -diff -urNad mono-addins-0.3.1~/Test/SystemInfoExtension/Makefile.am mono-addins-0.3.1/Test/SystemInfoExtension/Makefile.am ---- mono-addins-0.3.1~/Test/SystemInfoExtension/Makefile.am 2008-01-30 22:37:47.000000000 +0000 -+++ mono-addins-0.3.1/Test/SystemInfoExtension/Makefile.am 2008-12-17 17:43:36.000000000 +0000 -@@ -1,4 +1,4 @@ --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../lib/SystemInfoExtension.dll - COMPILE_TARGET = library -diff -urNad mono-addins-0.3.1~/Test/UnitTests/Makefile.am mono-addins-0.3.1/Test/UnitTests/Makefile.am ---- mono-addins-0.3.1~/Test/UnitTests/Makefile.am 2008-01-30 22:37:47.000000000 +0000 -+++ mono-addins-0.3.1/Test/UnitTests/Makefile.am 2008-12-17 17:43:36.000000000 +0000 -@@ -1,4 +1,4 @@ --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ./bin/Debug/UnitTests.dll - COMPILE_TARGET = library -diff -urNad mono-addins-0.3.1~/mautil/Makefile.am mono-addins-0.3.1/mautil/Makefile.am ---- mono-addins-0.3.1~/mautil/Makefile.am 2008-01-30 22:37:49.000000000 +0000 -+++ mono-addins-0.3.1/mautil/Makefile.am 2008-12-17 17:43:36.000000000 +0000 -@@ -1,5 +1,5 @@ - --ASSEMBLY_COMPILER_COMMAND = mcs -+ASSEMBLY_COMPILER_COMMAND = @MCS@ - ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG - ASSEMBLY = ../bin/mautil.exe - COMPILE_TARGET = exe diff -Nru mono-addins-0.4/debian/patches/fix_configure.ac.patch mono-addins-0.6.1/debian/patches/fix_configure.ac.patch --- mono-addins-0.4/debian/patches/fix_configure.ac.patch 2011-10-16 17:36:54.000000000 +0000 +++ mono-addins-0.6.1/debian/patches/fix_configure.ac.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -#! /bin/sh /usr/share/dpatch/dpatch-run -## fix_configure.ac.dpatch by Mirco Bauer -## -## All lines beginning with `## DP:' are a description of the patch. -## DP: No description. - -@DPATCH@ ---- mono-addins-0.4.orig/configure.ac -+++ mono-addins-0.4/configure.ac -@@ -72,34 +72,33 @@ - AC_SUBST(MONO_ADDINS_SETUP_DEFAULT_LIB) - - AC_CONFIG_FILES([ --./Mono.Addins/mono-addins.pc --./Mono.Addins.Gui/mono-addins-gui.pc --./Mono.Addins.Setup/mono-addins-setup.pc --./Makefile --./policy.config --./Mono.Addins.Gui/Makefile --./Mono.Addins.Setup/Makefile --./Mono.Addins/Makefile --./Mono.Addins.CecilReflector/Makefile --./mautil/Makefile --./mautil/mautil --./Test/HelloWorldExtension/Makefile --./Test/FileContentExtension/Makefile --./Test/UnitTests/Makefile --./Test/CommandExtension/Makefile --./Test/SystemInfoExtension/Makefile --./Test/FileExtender/Makefile --./Test/Makefile --./Samples/TextEditor.Xml/Makefile --./Samples/TextEditor/Makefile --./Samples/TextEditor.CompilerService/Makefile --./Samples/WriterServiceHost/Makefile --./Samples/TextEditor.CompilerService.CSharp/Makefile --./Samples/WriterService.SampleExtender/Makefile --./Samples/Makefile --./Samples/TextEditorLib/Makefile --./Samples/WriterService/Makefile -- -+Mono.Addins/mono-addins.pc -+Mono.Addins.Gui/mono-addins-gui.pc -+Mono.Addins.Setup/mono-addins-setup.pc -+Makefile -+policy.config -+Mono.Addins.Gui/Makefile -+Mono.Addins.Setup/Makefile -+Mono.Addins/Makefile -+Mono.Addins.CecilReflector/Makefile -+mautil/Makefile -+mautil/mautil -+Test/HelloWorldExtension/Makefile -+Test/FileContentExtension/Makefile -+Test/UnitTests/Makefile -+Test/CommandExtension/Makefile -+Test/SystemInfoExtension/Makefile -+Test/FileExtender/Makefile -+Test/Makefile -+Samples/TextEditor.Xml/Makefile -+Samples/TextEditor/Makefile -+Samples/TextEditor.CompilerService/Makefile -+Samples/WriterServiceHost/Makefile -+Samples/TextEditor.CompilerService.CSharp/Makefile -+Samples/WriterService.SampleExtender/Makefile -+Samples/Makefile -+Samples/TextEditorLib/Makefile -+Samples/WriterService/Makefile - ]) - - AC_OUTPUT diff -Nru mono-addins-0.4/debian/patches/fix_ExtensionNodeChildAttribute_ctor_r127062.patch mono-addins-0.6.1/debian/patches/fix_ExtensionNodeChildAttribute_ctor_r127062.patch --- mono-addins-0.4/debian/patches/fix_ExtensionNodeChildAttribute_ctor_r127062.patch 2011-10-16 17:36:54.000000000 +0000 +++ mono-addins-0.6.1/debian/patches/fix_ExtensionNodeChildAttribute_ctor_r127062.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -Author: lluis -Date: 2009-02-16 14:59:49 -0500 (Mon, 16 Feb 2009) -New Revision: 127062 - -Modified: - trunk/mono-addins/Mono.Addins/ChangeLog - trunk/mono-addins/Mono.Addins/Mono.Addins/ExtensionNodeChildAttribute.cs -Log: -* Mono.Addins/ExtensionNodeChildAttribute.cs: Make sure the - ExtensionNodeTypeName property is set when using the attribute - constructor. - -Modified: trunk/mono-addins/Mono.Addins/Mono.Addins/ExtensionNodeChildAttribute.cs -=================================================================== ---- trunk/mono-addins/Mono.Addins/Mono.Addins/ExtensionNodeChildAttribute.cs 2009-02-16 18:12:54 UTC (rev 127061) -+++ trunk/mono-addins/Mono.Addins/Mono.Addins/ExtensionNodeChildAttribute.cs 2009-02-16 19:59:49 UTC (rev 127062) -@@ -50,7 +50,7 @@ - - public ExtensionNodeChildAttribute (Type extensionNodeType, string nodeName) - { -- this.extensionNodeType = extensionNodeType; -+ ExtensionNodeType = extensionNodeType; - this.nodeName = nodeName; - } - - -_______________________________________________ -Mono-patches maillist - Mono-patches@lists.ximian.com -http://lists.ximian.com/mailman/listinfo/mono-patches - diff -Nru mono-addins-0.4/debian/patches/fix_gac_policy_filenames.patch mono-addins-0.6.1/debian/patches/fix_gac_policy_filenames.patch --- mono-addins-0.4/debian/patches/fix_gac_policy_filenames.patch 2011-10-16 17:36:54.000000000 +0000 +++ mono-addins-0.6.1/debian/patches/fix_gac_policy_filenames.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -#! /bin/sh /usr/share/dpatch/dpatch-run -## fix_gac_policy_filenames.dpatch by Mirco Bauer -## -## All lines beginning with `## DP:' are a description of the patch. -## DP: No description. - -@DPATCH@ ---- mono-addins-0.4.orig/Makefile.include -+++ mono-addins-0.4/Makefile.include -@@ -20,8 +20,8 @@ - $(POLICY_ASSEMBLIES): $(top_builddir)/policy.config $(top_srcdir)/mono-addins.snk - @for i in $(POLICY_VERSIONS); do \ - echo "Creating policy.$$i.$(ASSEMBLY_NAME)"; \ -- sed -e "s/@ASSEMBLY_NAME@/$(ASSEMBLY_NAME)/" -e "s/@POLICY@/$$i/" $(top_builddir)/policy.config > policy.$$i.config; \ -- $(AL) -link:policy.$$i.config -out:policy.$$i.$(ASSEMBLY_NAME).dll -keyfile:$(top_srcdir)/mono-addins.snk; \ -+ sed -e "s/@ASSEMBLY_NAME@/$(ASSEMBLY_NAME)/" -e "s/@POLICY@/$$i/" $(top_builddir)/policy.config > policy.$$i.$(ASSEMBLY_NAME).config; \ -+ $(AL) -link:policy.$$i.$(ASSEMBLY_NAME).config -out:policy.$$i.$(ASSEMBLY_NAME).dll -keyfile:$(top_srcdir)/mono-addins.snk; \ - done - - gac-install: $(POLICY_ASSEMBLIES) diff -Nru mono-addins-0.4/debian/patches/fix_mono-addins-gui.pc.patch mono-addins-0.6.1/debian/patches/fix_mono-addins-gui.pc.patch --- mono-addins-0.4/debian/patches/fix_mono-addins-gui.pc.patch 2011-10-16 17:36:54.000000000 +0000 +++ mono-addins-0.6.1/debian/patches/fix_mono-addins-gui.pc.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -#! /bin/sh /usr/share/dpatch/dpatch-run -## fix_mono-addins-gui.pc.dpatch by Mirco Bauer -## -## All lines beginning with `## DP:' are a description of the patch. -## DP: No description. - -@DPATCH@ -diff -urNad mono-addins-0.3~/Mono.Addins.Gui/mono-addins-gui.pc.in mono-addins-0.3/Mono.Addins.Gui/mono-addins-gui.pc.in ---- mono-addins-0.3~/Mono.Addins.Gui/mono-addins-gui.pc.in 2007-12-18 20:16:23.000000000 +0100 -+++ mono-addins-0.3/Mono.Addins.Gui/mono-addins-gui.pc.in 2007-12-30 14:54:19.000000000 +0100 -@@ -1,11 +1,10 @@ - prefix=@prefix@ - exec_prefix=${prefix} --pkglibdir=@libdir@/mono/@PACKAGE@ --Libraries= ${pkglibdir}/@MONO_ADDINS_GUI_DEFAULT_LIB@ -+pkglibdir=@libdir@/cli/Mono.Addins.Gui-#PACKAGE_ABI_VERSION# - - Name: Mono.Addins.Gui - Description: - Version: @VERSION@ - --Requires: mono-addins --Libs: -r:${pkglibdir}/@MONO_ADDINS_GUI_DEFAULT_LIB@ -\ No newline at end of file -+Requires: gtk-sharp-2.0 mono-addins -+Libs: -r:${pkglibdir}/@MONO_ADDINS_GUI_DEFAULT_LIB@ -\ No newline at end of file diff -Nru mono-addins-0.4/debian/patches/fix_mono-addins.pc.patch mono-addins-0.6.1/debian/patches/fix_mono-addins.pc.patch --- mono-addins-0.4/debian/patches/fix_mono-addins.pc.patch 2011-10-16 17:36:54.000000000 +0000 +++ mono-addins-0.6.1/debian/patches/fix_mono-addins.pc.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -#! /bin/sh /usr/share/dpatch/dpatch-run -## fix_mono-addins-gui.pc.dpatch by Mirco Bauer -## -## All lines beginning with `## DP:' are a description of the patch. -## DP: No description. - -@DPATCH@ -diff -urNad mono-addins-0.3~/Mono.Addins/mono-addins.pc.in mono-addins-0.3/Mono.Addins/mono-addins.pc.in ---- mono-addins-0.3~/Mono.Addins/mono-addins.pc.in 2007-12-30 14:44:58.000000000 +0100 -+++ mono-addins-0.3/Mono.Addins/mono-addins.pc.in 2007-12-30 14:52:37.000000000 +0100 -@@ -1,11 +1,9 @@ - prefix=@prefix@ - exec_prefix=${prefix} --pkglibdir=@libdir@/mono/@PACKAGE@ --Libraries= ${pkglibdir}/@MONO_ADDINS_DEFAULT_LIB@ -+pkglibdir=@libdir@/cli/Mono.Addins-#PACKAGE_ABI_VERSION# - - Name: Mono.Addins - Description: - Version: @VERSION@ - --Requires: --Libs: -r:${pkglibdir}/@MONO_ADDINS_DEFAULT_LIB@ -\ No newline at end of file -+Libs: -r:${pkglibdir}/@MONO_ADDINS_DEFAULT_LIB@ diff -Nru mono-addins-0.4/debian/patches/fix_mono-addins-setup.pc.patch mono-addins-0.6.1/debian/patches/fix_mono-addins-setup.pc.patch --- mono-addins-0.4/debian/patches/fix_mono-addins-setup.pc.patch 2011-10-16 17:36:54.000000000 +0000 +++ mono-addins-0.6.1/debian/patches/fix_mono-addins-setup.pc.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -#! /bin/sh /usr/share/dpatch/dpatch-run -## fix_mono-addins-setup.pc.dpatch by Mirco Bauer -## -## All lines beginning with `## DP:' are a description of the patch. -## DP: No description. - -@DPATCH@ -diff -urNad mono-addins-0.3~/Mono.Addins.Setup/mono-addins-setup.pc.in mono-addins-0.3/Mono.Addins.Setup/mono-addins-setup.pc.in ---- mono-addins-0.3~/Mono.Addins.Setup/mono-addins-setup.pc.in 2007-12-18 20:16:25.000000000 +0100 -+++ mono-addins-0.3/Mono.Addins.Setup/mono-addins-setup.pc.in 2007-12-30 14:55:04.000000000 +0100 -@@ -1,11 +1,10 @@ - prefix=@prefix@ - exec_prefix=${prefix} --pkglibdir=@libdir@/mono/@PACKAGE@ --Libraries= ${pkglibdir}/@MONO_ADDINS_SETUP_DEFAULT_LIB@ -+pkglibdir=@libdir@/cli/Mono.Addins.Setup-#PACKAGE_ABI_VERSION# - - Name: Mono.Addins.Setup - Description: - Version: @VERSION@ - --Requires: mono-addins --Libs: -r:${pkglibdir}/@MONO_ADDINS_SETUP_DEFAULT_LIB@ -+Requires: mono-addins -+Libs: -r:${pkglibdir}/@MONO_ADDINS_SETUP_DEFAULT_LIB@ diff -Nru mono-addins-0.4/debian/patches/series mono-addins-0.6.1/debian/patches/series --- mono-addins-0.4/debian/patches/series 2011-10-16 17:36:54.000000000 +0000 +++ mono-addins-0.6.1/debian/patches/series 2011-10-16 17:07:42.000000000 +0000 @@ -1,7 +1,6 @@ -fix_ExtensionNodeChildAttribute_ctor_r127062.patch -p2 -configurable_compiler.patch -fix_mono-addins.pc.patch -fix_mono-addins-gui.pc.patch -fix_mono-addins-setup.pc.patch -fix_gac_policy_filenames.patch -fix_configure.ac.patch +0001-configurable_compiler.patch.patch +0002-fix_mono-addins.pc.patch.patch +0003-fix_mono-addins-gui.pc.patch.patch +0004-fix_mono-addins-setup.pc.patch.patch +0005-fix_mono-addins-msbuild.pc.patch.patch +0006-Fix-Repair-to-prevent-crashing-when-looking-for-addi.patch diff -Nru mono-addins-0.4/debian/rules mono-addins-0.6.1/debian/rules --- mono-addins-0.4/debian/rules 2011-10-16 17:36:54.000000000 +0000 +++ mono-addins-0.6.1/debian/rules 2011-08-02 16:30:52.000000000 +0000 @@ -3,8 +3,10 @@ #export DH_VERBOSE=1 export MONO_SHARED_DIR=$(CURDIR) +include /usr/share/cli-common/cli.make + DEB_CLI_ABI_VERSION=0.2 -DEB_CLI_API_VERSION=0.4 +DEB_CLI_API_VERSION=0.6 MAKEFILE = $(firstword $(MAKEFILE_LIST)) DEBIAN_DIR = $(dir $(MAKEFILE)) @@ -14,79 +16,16 @@ DEB_SOURCE_NAME = $(shell dpkg-parsechangelog -l$(DEBIAN_DIR)/changelog | grep ^Source | cut -d" " -f2) VERSION = $(shell echo $(DEB_VERSION) | cut -d"-" -f1) -include /usr/share/quilt/quilt.make - -configure: configure-stamp -configure-stamp: $(QUILT_STAMPFN) - dh_testdir - - libtoolize - aclocal - autoconf - automake --add-missing --copy - - ./configure --prefix=/usr \ - --mandir=\$${prefix}/share/man \ - --infodir=\$${prefix}/share/info \ - --enable-tests=no \ - MCS=/usr/bin/mono-csc - touch configure-stamp - -build: build-stamp -build-stamp: configure-stamp - dh_testdir - $(MAKE) - touch build-stamp - -clean: clean-patched unpatch -clean-patched: - dh_testdir - dh_testroot - [ ! -f Makefile ] || $(MAKE) distclean - rm -rf $(CURDIR)/.wapi - rm -f configure-stamp build-stamp - - # delete generated autofoo stuff from above - find . -name "Makefile.in" -delete - rm -f config.status config.sub config.guess configure ltmain.sh - - dh_clean - -install: build - dh_testdir - dh_testroot - dh_clean -k - dh_installdirs - $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp +override_dh_auto_configure: + dh_auto_configure -- --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info --enable-tests=no MCS=/usr/bin/mono-csc +override_dh_install: perl -pe 's/#PACKAGE_ABI_VERSION#/$(DEB_CLI_ABI_VERSION)/g' -i \ $(CURDIR)/debian/tmp/usr/lib/pkgconfig/*.pc + dh_install -binary-indep: build install - dh_testdir - dh_testroot - dh_install -i --sourcedir=debian/tmp - dh_installchangelogs -i - dh_installdocs -i - dh_installexamples -i - dh_installman -i - dh_installcligac -i - dh_link -i - dh_strip -i - dh_clistrip -i - dh_compress -i - dh_fixperms -i - dh_clifixperms -i - dh_installdeb -i +override_dh_makeclilibs: dh_makeclilibs -i -m $(DEB_CLI_API_VERSION) - dh_clideps -i - dh_gencontrol -i - dh_md5sums -i - dh_builddeb -i - -binary-arch: - -binary: binary-arch binary-indep get-orig-source: uscan \ @@ -99,4 +38,5 @@ --rename \ --repack -.PHONY: build clean binary-arch binary-indep binary install configure get-orig-source +%: + dh --with autoreconf $@ diff -Nru mono-addins-0.4/debian/source/format mono-addins-0.6.1/debian/source/format --- mono-addins-0.4/debian/source/format 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/debian/source/format 2011-10-16 17:36:55.000000000 +0000 @@ -0,0 +1 @@ +3.0 (quilt) diff -Nru mono-addins-0.4/docs/ChangeLog mono-addins-0.6.1/docs/ChangeLog --- mono-addins-0.4/docs/ChangeLog 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/docs/ChangeLog 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,76 @@ +2010-03-26 Lluis Sanchez Gual + + * Mono.Addins.Setup/SetupService.xml: Flush. + +2009-03-30 Lluis Sanchez Gual + + * Mono.Addins/Addin.xml: + * Mono.Addins/NodeElement.xml: + * Mono.Addins/AddinManager.xml: + * Mono.Addins/RuntimeAddin.xml: + * Mono.Addins/NodeAttribute.xml: + * Mono.Addins/ConditionType.xml: + * Mono.Addins/AddinRegistry.xml: + * Mono.Addins/ExtensionNode.xml: + * Mono.Addins/AddinEventArgs.xml: + * Mono.Addins/IProgressStatus.xml: + * Mono.Addins/ExtensionChange.xml: + * Mono.Addins/ExtensionContext.xml: + * Mono.Addins/ExtensionNodeList.xml: + * Mono.Addins/TypeExtensionNode.xml: + * Mono.Addins/AddinEventHandler.xml: + * Mono.Addins/ExtensionEventArgs.xml: + * Mono.Addins/AddinRootAttribute.xml: + * Mono.Addins/ExtensionAttribute.xml: + * Mono.Addins/AddinErrorEventArgs.xml: + * Mono.Addins/ExtensionEventHandler.xml: + * Mono.Addins/ConsoleProgressStatus.xml: + * Mono.Addins.Description/Extension.xml: + * Mono.Addins/ExtensionNodeAttribute.xml: + * Mono.Addins/NodeAttributeAttribute.xml: + * Mono.Addins/AddinErrorEventHandler.xml: + * Mono.Addins/ExtensionPointAttribute.xml: + * Mono.Addins/AddinDependencyAttribute.xml: + * Mono.Addins.Description/ExtensionPoint.xml: + * Mono.Addins.Description/AddinDependency.xml: + * Mono.Addins/ExtensionNodeChildAttribute.xml: + * Mono.Addins/TypeExtensionPointAttribute.xml: + * Mono.Addins.Description/ModuleCollection.xml: + * Mono.Addins.Description/ExtensionNodeSet.xml: + * Mono.Addins.Description/AddinDescription.xml: + * Mono.Addins.Description/ModuleDescription.xml: + * Mono.Addins.Description/NodeTypeAttribute.xml: + * Mono.Addins.Description/AssemblyDependency.xml: + * Mono.Addins.Description/ExtensionCollection.xml: + * Mono.Addins.Description/NodeSetIdCollection.xml: + * Mono.Addins.Description/DependencyCollection.xml: + * Mono.Addins.Description/ExtensionNodeDescription.xml: + * Mono.Addins.Description/ExtensionPointCollection.xml: + * Mono.Addins.Description/ConditionTypeDescription.xml: + * Mono.Addins.Description/ExtensionNodeSetCollection.xml: + * Mono.Addins.Description/NodeTypeAttributeCollection.xml: + * Mono.Addins.Description/ObjectDescriptionCollection.xml: + * Mono.Addins.Description/ExtensionNodeDescriptionCollection.xml: + * Mono.Addins.Description/ConditionTypeDescriptionCollection.xml: + Updated documentation. + + * Makefile.am: + * mono-addins-docs.source: Added makefile to docs which builds + and installs the documentation. + +2009/02/06 Lluis Sanchez Gual + + * docs.mdproj: Updated. + +2008-08-22 Lluis Sanchez Gual + + * docs.mdproj: More project file fixes. + +2007-10-29 Lluis Sanchez Gual + + * docs.mdp: Update paths. + +2007-03-30 Lluis Sanchez Gual + + Updated. + diff -Nru mono-addins-0.4/docs/Makefile.am mono-addins-0.6.1/docs/Makefile.am --- mono-addins-0.4/docs/Makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/docs/Makefile.am 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,42 @@ + +DOCFILES = \ + $(top_builddir)/bin/Mono.Addins.dll \ + $(top_builddir)/bin/Mono.Addins.Setup.dll \ + $(top_builddir)/bin/Mono.Addins.Gui.dll + +DOC_ASSEMBLED_FILES = \ + mono-addins-docs.tree \ + mono-addins-docs.zip + +if ENABLE_DOCS + +all: doc-update doc-assemble + +doc-update: + mdoc update --delete $(MDOC_OPTIONS) -o . $(DOCFILES) + +doc-assemble: mono-addins-docs.zip + +mono-addins-docs.zip : mono-addins-docs.tree +mono-addins-docs.tree: + mdoc assemble -o mono-addins-docs . + +install: install-docs + +install-docs: mono-addins-docs.source $(DOC_ASSEMBLED_FILES) + cp $^ `pkg-config monodoc --variable sourcesdir` + +uninstall: uninstall-docs + +uninstall-docs: + -rm `pkg-config monodoc --variable sourcesdir`/mono-addins-docs{.source,.tree,.zip} + +clean: clean-docs + +clean-docs: + -rm -rf $(DOC_ASSEMBLED_FILES) + +EXTRA_DIST = mono-addins-docs.source + +endif + diff -Nru mono-addins-0.4/docs/Makefile.in mono-addins-0.6.1/docs/Makefile.in --- mono-addins-0.4/docs/Makefile.in 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/docs/Makefile.in 2011-04-13 09:45:29.000000000 +0000 @@ -0,0 +1,330 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +subdir = ./docs +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AL = @AL@ +AMTAR = @AMTAR@ +API_VERSION = @API_VERSION@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +GACUTIL = @GACUTIL@ +GACUTIL_FLAGS = @GACUTIL_FLAGS@ +GACUTIL_POLICY_FLAGS = @GACUTIL_POLICY_FLAGS@ +GTK_SHARP_20_CFLAGS = @GTK_SHARP_20_CFLAGS@ +GTK_SHARP_20_LIBS = @GTK_SHARP_20_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MCS = @MCS@ +MKDIR_P = @MKDIR_P@ +MONODOC_CFLAGS = @MONODOC_CFLAGS@ +MONODOC_LIBS = @MONODOC_LIBS@ +MONO_ADDINS_DEFAULT_LIB = @MONO_ADDINS_DEFAULT_LIB@ +MONO_ADDINS_GUI_DEFAULT_LIB = @MONO_ADDINS_GUI_DEFAULT_LIB@ +MONO_ADDINS_MSBUILD_DEFAULT_LIB = @MONO_ADDINS_MSBUILD_DEFAULT_LIB@ +MONO_ADDINS_SETUP_DEFAULT_LIB = @MONO_ADDINS_SETUP_DEFAULT_LIB@ +MONO_NUNIT_CFLAGS = @MONO_NUNIT_CFLAGS@ +MONO_NUNIT_LIBS = @MONO_NUNIT_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +POLICY_VERSIONS = @POLICY_VERSIONS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +am__leading_dot = @am__leading_dot@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host_alias = @host_alias@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +DOCFILES = \ + $(top_builddir)/bin/Mono.Addins.dll \ + $(top_builddir)/bin/Mono.Addins.Setup.dll \ + $(top_builddir)/bin/Mono.Addins.Gui.dll + +DOC_ASSEMBLED_FILES = \ + mono-addins-docs.tree \ + mono-addins-docs.zip + +@ENABLE_DOCS_TRUE@EXTRA_DIST = mono-addins-docs.source +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign ./docs/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign ./docs/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +@ENABLE_DOCS_FALSE@install: install-am +install-exec: install-exec-am +install-data: install-data-am +@ENABLE_DOCS_FALSE@uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +@ENABLE_DOCS_FALSE@clean: clean-am + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic distclean \ + distclean-generic distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am + + +@ENABLE_DOCS_TRUE@all: doc-update doc-assemble + +@ENABLE_DOCS_TRUE@doc-update: +@ENABLE_DOCS_TRUE@ mdoc update --delete $(MDOC_OPTIONS) -o . $(DOCFILES) + +@ENABLE_DOCS_TRUE@doc-assemble: mono-addins-docs.zip + +@ENABLE_DOCS_TRUE@mono-addins-docs.zip : mono-addins-docs.tree +@ENABLE_DOCS_TRUE@mono-addins-docs.tree: +@ENABLE_DOCS_TRUE@ mdoc assemble -o mono-addins-docs . + +@ENABLE_DOCS_TRUE@install: install-docs + +@ENABLE_DOCS_TRUE@install-docs: mono-addins-docs.source $(DOC_ASSEMBLED_FILES) +@ENABLE_DOCS_TRUE@ cp $^ `pkg-config monodoc --variable sourcesdir` + +@ENABLE_DOCS_TRUE@uninstall: uninstall-docs + +@ENABLE_DOCS_TRUE@uninstall-docs: +@ENABLE_DOCS_TRUE@ -rm `pkg-config monodoc --variable sourcesdir`/mono-addins-docs{.source,.tree,.zip} + +@ENABLE_DOCS_TRUE@clean: clean-docs + +@ENABLE_DOCS_TRUE@clean-docs: +@ENABLE_DOCS_TRUE@ -rm -rf $(DOC_ASSEMBLED_FILES) +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff -Nru mono-addins-0.4/Makefile.am mono-addins-0.6.1/Makefile.am --- mono-addins-0.4/Makefile.am 2008-11-06 19:52:14.000000000 +0000 +++ mono-addins-0.6.1/Makefile.am 2011-04-13 09:00:29.000000000 +0000 @@ -1,13 +1,44 @@ -SUBDIRS = Mono.Addins Mono.Addins.CecilReflector Mono.Addins.Setup Mono.Addins.Gui mautil Test Samples +SUBDIRS = Mono.Addins Mono.Addins.CecilReflector Mono.Addins.Setup Mono.Addins.MSBuild Mono.Addins.Gui mautil Test docs -DOCFILES = \ - $(top_builddir)/bin/Mono.Addins.dll \ - $(top_builddir)/bin/Mono.Addins.Setup.dll \ - $(top_builddir)/bin/Mono.Addins.Gui.dll +EXTRA_DIST = COPYING mono-addins.snk -apidocs: - mkdir -p docs - monodocer --delete --pretty $(DOCFILES:%=--assembly:%) --path docs +SRC_PACKAGE_DIR=Mono.Addins-source-@VERSION@ +BIN_PACKAGE_DIR=Mono.Addins-binary-@VERSION@ -EXTRA_DIST = COPYING mono-addins.snk +src-zip: + rm -rf $(SRC_PACKAGE_DIR) + rm -f $(SRC_PACKAGE_DIR).zip + mkdir $(SRC_PACKAGE_DIR) + mdtool project-export Mono.Addins.sln -f:"MSBuild (Visual Studio 2008)" -d:$(SRC_PACKAGE_DIR) -p:mautil -p:Mono.Addins -p:Mono.Addins.CecilReflector -p:Mono.Addins.Setup + mdtool project-export Samples/HelloWorld/HelloWorld.sln -f:"MSBuild (Visual Studio 2008)" -d:$(SRC_PACKAGE_DIR)/Samples/HelloWorld + mdtool project-export Samples/HelloWorldWithManifest/HelloWorldWithManifest.sln -f:"MSBuild (Visual Studio 2008)" -d:$(SRC_PACKAGE_DIR)/Samples/HelloWorldWithManifest + mdtool project-export Samples/TextEditorSWF/TextEditorSWF.sln -f:"MSBuild (Visual Studio 2008)" -d:$(SRC_PACKAGE_DIR)/Samples/TextEditorSWF + cp support/README-src $(SRC_PACKAGE_DIR)/README.txt + cp AUTHORS $(SRC_PACKAGE_DIR)/AUTHORS.txt + cp COPYING $(SRC_PACKAGE_DIR)/COPYING.txt + unix2dos $(SRC_PACKAGE_DIR)/README.txt + unix2dos $(SRC_PACKAGE_DIR)/AUTHORS.txt + unix2dos $(SRC_PACKAGE_DIR)/COPYING.txt + rm -rf $(SRC_PACKAGE_DIR)/Test + rm $(SRC_PACKAGE_DIR)/configure.ac + cd $(SRC_PACKAGE_DIR) && for fi in `find . -name Makefile.am`; do rm $$fi; done + cd $(SRC_PACKAGE_DIR) && zip -r ../$(SRC_PACKAGE_DIR).zip * + +bin-zip: + rm -rf $(BIN_PACKAGE_DIR) + rm -f $(BIN_PACKAGE_DIR).zip + mkdir $(BIN_PACKAGE_DIR) + cp support/README-bin $(BIN_PACKAGE_DIR)/README.txt + cp AUTHORS $(BIN_PACKAGE_DIR)/AUTHORS.txt + cp COPYING $(BIN_PACKAGE_DIR)/COPYING.txt + unix2dos $(BIN_PACKAGE_DIR)/README.txt + unix2dos $(BIN_PACKAGE_DIR)/AUTHORS.txt + unix2dos $(BIN_PACKAGE_DIR)/COPYING.txt + cp bin/mautil.exe $(BIN_PACKAGE_DIR) + cp bin/Mono.Addins.dll $(BIN_PACKAGE_DIR) + cp bin/Mono.Addins.Setup.dll $(BIN_PACKAGE_DIR) + cp bin/Mono.Addins.CecilReflector.dll $(BIN_PACKAGE_DIR) + cp support/ICSharpCode.SharpZipLib.license.txt $(BIN_PACKAGE_DIR) + cp support/ICSharpCode.SharpZipLib.dll $(BIN_PACKAGE_DIR) + cd $(BIN_PACKAGE_DIR) && zip -r ../$(BIN_PACKAGE_DIR).zip * diff -Nru mono-addins-0.4/Makefile.in mono-addins-0.6.1/Makefile.in --- mono-addins-0.4/Makefile.in 2008-11-06 19:52:36.000000000 +0000 +++ mono-addins-0.6.1/Makefile.in 2011-04-13 09:45:29.000000000 +0000 @@ -31,9 +31,9 @@ POST_UNINSTALL = : subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in $(srcdir)/policy.config.in \ - $(top_srcdir)/configure AUTHORS COPYING ChangeLog NEWS \ - install-sh missing + $(srcdir)/Makefile.in $(srcdir)/mono-addins.spec.in \ + $(srcdir)/policy.config.in $(top_srcdir)/configure AUTHORS \ + COPYING ChangeLog NEWS install-sh missing ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ @@ -41,7 +41,7 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = policy.config +CONFIG_CLEAN_FILES = mono-addins.spec policy.config SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ @@ -93,11 +93,15 @@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MCS = @MCS@ MKDIR_P = @MKDIR_P@ +MONODOC_CFLAGS = @MONODOC_CFLAGS@ +MONODOC_LIBS = @MONODOC_LIBS@ MONO_ADDINS_DEFAULT_LIB = @MONO_ADDINS_DEFAULT_LIB@ MONO_ADDINS_GUI_DEFAULT_LIB = @MONO_ADDINS_GUI_DEFAULT_LIB@ +MONO_ADDINS_MSBUILD_DEFAULT_LIB = @MONO_ADDINS_MSBUILD_DEFAULT_LIB@ MONO_ADDINS_SETUP_DEFAULT_LIB = @MONO_ADDINS_SETUP_DEFAULT_LIB@ MONO_NUNIT_CFLAGS = @MONO_NUNIT_CFLAGS@ MONO_NUNIT_LIBS = @MONO_NUNIT_LIBS@ @@ -150,21 +154,19 @@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -SUBDIRS = Mono.Addins Mono.Addins.CecilReflector Mono.Addins.Setup Mono.Addins.Gui mautil Test Samples -DOCFILES = \ - $(top_builddir)/bin/Mono.Addins.dll \ - $(top_builddir)/bin/Mono.Addins.Setup.dll \ - $(top_builddir)/bin/Mono.Addins.Gui.dll - +SUBDIRS = Mono.Addins Mono.Addins.CecilReflector Mono.Addins.Setup Mono.Addins.MSBuild Mono.Addins.Gui mautil Test docs EXTRA_DIST = COPYING mono-addins.snk +SRC_PACKAGE_DIR = Mono.Addins-source-@VERSION@ +BIN_PACKAGE_DIR = Mono.Addins-binary-@VERSION@ all: all-recursive .SUFFIXES: am--refresh: @: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -191,10 +193,12 @@ $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck -$(top_srcdir)/configure: $(am__configure_deps) +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(srcdir) && $(AUTOCONF) -$(ACLOCAL_M4): $(am__aclocal_m4_deps) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) +mono-addins.spec: $(top_builddir)/config.status $(srcdir)/mono-addins.spec.in + cd $(top_builddir) && $(SHELL) ./config.status $@ policy.config: $(top_builddir)/config.status $(srcdir)/policy.config.in cd $(top_builddir) && $(SHELL) ./config.status $@ @@ -581,9 +585,42 @@ tags-recursive uninstall uninstall-am -apidocs: - mkdir -p docs - monodocer --delete --pretty $(DOCFILES:%=--assembly:%) --path docs +src-zip: + rm -rf $(SRC_PACKAGE_DIR) + rm -f $(SRC_PACKAGE_DIR).zip + mkdir $(SRC_PACKAGE_DIR) + mdtool project-export Mono.Addins.sln -f:"MSBuild (Visual Studio 2008)" -d:$(SRC_PACKAGE_DIR) -p:mautil -p:Mono.Addins -p:Mono.Addins.CecilReflector -p:Mono.Addins.Setup + mdtool project-export Samples/HelloWorld/HelloWorld.sln -f:"MSBuild (Visual Studio 2008)" -d:$(SRC_PACKAGE_DIR)/Samples/HelloWorld + mdtool project-export Samples/HelloWorldWithManifest/HelloWorldWithManifest.sln -f:"MSBuild (Visual Studio 2008)" -d:$(SRC_PACKAGE_DIR)/Samples/HelloWorldWithManifest + mdtool project-export Samples/TextEditorSWF/TextEditorSWF.sln -f:"MSBuild (Visual Studio 2008)" -d:$(SRC_PACKAGE_DIR)/Samples/TextEditorSWF + cp support/README-src $(SRC_PACKAGE_DIR)/README.txt + cp AUTHORS $(SRC_PACKAGE_DIR)/AUTHORS.txt + cp COPYING $(SRC_PACKAGE_DIR)/COPYING.txt + unix2dos $(SRC_PACKAGE_DIR)/README.txt + unix2dos $(SRC_PACKAGE_DIR)/AUTHORS.txt + unix2dos $(SRC_PACKAGE_DIR)/COPYING.txt + rm -rf $(SRC_PACKAGE_DIR)/Test + rm $(SRC_PACKAGE_DIR)/configure.ac + cd $(SRC_PACKAGE_DIR) && for fi in `find . -name Makefile.am`; do rm $$fi; done + cd $(SRC_PACKAGE_DIR) && zip -r ../$(SRC_PACKAGE_DIR).zip * + +bin-zip: + rm -rf $(BIN_PACKAGE_DIR) + rm -f $(BIN_PACKAGE_DIR).zip + mkdir $(BIN_PACKAGE_DIR) + cp support/README-bin $(BIN_PACKAGE_DIR)/README.txt + cp AUTHORS $(BIN_PACKAGE_DIR)/AUTHORS.txt + cp COPYING $(BIN_PACKAGE_DIR)/COPYING.txt + unix2dos $(BIN_PACKAGE_DIR)/README.txt + unix2dos $(BIN_PACKAGE_DIR)/AUTHORS.txt + unix2dos $(BIN_PACKAGE_DIR)/COPYING.txt + cp bin/mautil.exe $(BIN_PACKAGE_DIR) + cp bin/Mono.Addins.dll $(BIN_PACKAGE_DIR) + cp bin/Mono.Addins.Setup.dll $(BIN_PACKAGE_DIR) + cp bin/Mono.Addins.CecilReflector.dll $(BIN_PACKAGE_DIR) + cp support/ICSharpCode.SharpZipLib.license.txt $(BIN_PACKAGE_DIR) + cp support/ICSharpCode.SharpZipLib.dll $(BIN_PACKAGE_DIR) + cd $(BIN_PACKAGE_DIR) && zip -r ../$(BIN_PACKAGE_DIR).zip * # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff -Nru mono-addins-0.4/Makefile.include mono-addins-0.6.1/Makefile.include --- mono-addins-0.4/Makefile.include 2008-11-06 19:52:14.000000000 +0000 +++ mono-addins-0.6.1/Makefile.include 2011-04-13 09:00:29.000000000 +0000 @@ -17,12 +17,11 @@ mkdir -p $(dir $@) cp $< $@ -$(POLICY_ASSEMBLIES): $(top_builddir)/policy.config $(top_srcdir)/mono-addins.snk - @for i in $(POLICY_VERSIONS); do \ - echo "Creating policy.$$i.$(ASSEMBLY_NAME)"; \ - sed -e "s/@ASSEMBLY_NAME@/$(ASSEMBLY_NAME)/" -e "s/@POLICY@/$$i/" $(top_builddir)/policy.config > policy.$$i.config; \ - $(AL) -link:policy.$$i.config -out:policy.$$i.$(ASSEMBLY_NAME).dll -keyfile:$(top_srcdir)/mono-addins.snk; \ - done +policy.%.config: $(top_builddir)/policy.config + sed -e "s/@ASSEMBLY_NAME@/$(ASSEMBLY_NAME)/" -e "s/@POLICY@/$*/" $(top_builddir)/policy.config > $@ + +$(POLICY_ASSEMBLIES) : policy.%.$(ASSEMBLY_NAME).dll: policy.%.config $(top_srcdir)/mono-addins.snk + $(AL) -link:policy.$*.config -out:$@ -keyfile:$(top_srcdir)/mono-addins.snk gac-install: $(POLICY_ASSEMBLIES) $(GACUTIL) /i $(ASSEMBLY) /f $(GACUTIL_FLAGS) || exit 1; diff -Nru mono-addins-0.4/mautil/ChangeLog mono-addins-0.6.1/mautil/ChangeLog --- mono-addins-0.4/mautil/ChangeLog 2008-11-06 19:51:59.000000000 +0000 +++ mono-addins-0.6.1/mautil/ChangeLog 2011-04-13 09:00:29.000000000 +0000 @@ -1,3 +1,48 @@ +2010-05-25 Lluis Sanchez Gual + + * mautil.csproj: Add Debug and Release configurations. + +2010-03-26 Lluis Sanchez Gual + + * mautil.csproj: Flush. + +2009-11-13 Lluis Sanchez Gual + + * Main.cs: Allow specifying multiple levels of verbosity. + +2009-08-21 Lluis Sanchez Gual + + * Main.cs: Track api changes. + +2009-08-20 Lluis Sanchez Gual + + * Main.cs: Track api changes. + + * Makefile.am: Build using gmcs. + +2009-08-19 Lluis Sanchez Gual + + * mautil.csproj: Update target framework to 2.0. + +2009-06-17 Lluis Sanchez Gual + + * Main.cs: Added arguments which allows specifying the add-in + registry location using a package name. + +2009/02/06 Lluis Sanchez Gual + + * mautil.csproj: Updated. + +2008-11-10 Lluis Sanchez Gual + + * Makefile.am: Respect custom libdir during ./configure. Fixes bug + #443205. Patch by Diego Pettenò. + +2008-11-10 Lluis Sanchez Gual + + * Makefile.am: Fix building with parallel make jobs (-j8). Fixes bug + #443206. Patch by Diego Pettenò. + 2008-11-04 Lluis Sanchez Gual * Makefile.am: Dist fix. diff -Nru mono-addins-0.4/mautil/Main.cs mono-addins-0.6.1/mautil/Main.cs --- mono-addins-0.4/mautil/Main.cs 2008-11-06 19:51:59.000000000 +0000 +++ mono-addins-0.6.1/mautil/Main.cs 2011-04-13 09:00:29.000000000 +0000 @@ -1,5 +1,6 @@ // project created on 16/07/2006 at 13:33 using System; +using System.Diagnostics; using Mono.Addins; using Mono.Addins.Setup; @@ -14,20 +15,24 @@ Console.WriteLine ("Usage: mautil [options] [arguments]"); Console.WriteLine (); Console.WriteLine ("Options:"); - Console.WriteLine (" --registry (-reg) Specify add-in registry path"); - Console.WriteLine (" --path (-p) Specify startup path"); - Console.WriteLine (" -v Verbose output"); + Console.WriteLine (" --path (-p) Specify the startup path of the application"); + Console.WriteLine (" --registry (-reg) Specify the add-in registry path"); + Console.WriteLine (" --addinspath (-ap) Specify the default add-ins path of the application"); + Console.WriteLine (" The path can be absolute or relative to the registry path"); + Console.WriteLine (" --cachepath (-cp) Specify add-in cache path for the application"); + Console.WriteLine (" The path can be absolute or relative to the registry path"); + Console.WriteLine (" --package (-pkg) Specify the package name of the application"); + Console.WriteLine (" -v Verbose output. Use multiple times to increase log level"); } int ppos = 0; - bool verbose = false; - foreach (string a in args) - if (a == "-v") - verbose = true; - + int verbose = 1; string path = null; string startupPath = null; + string addinsPath = null; + string databasePath = null; + string package = null; bool toolParam = true; while (toolParam && ppos < args.Length) @@ -40,7 +45,7 @@ path = args [ppos + 1]; ppos += 2; } - if (args [ppos] == "-p" || args [ppos] == "--path") { + else if (args [ppos] == "-p" || args [ppos] == "--path") { if (ppos + 1 >= args.Length) { Console.WriteLine ("Startup path not provided."); return 1; @@ -48,20 +53,60 @@ startupPath = args [ppos + 1]; ppos += 2; } + else if (args [ppos] == "-ap" || args [ppos] == "--addinspath") { + if (ppos + 1 >= args.Length) { + Console.WriteLine ("Add-ins path not provided."); + return 1; + } + addinsPath = args [ppos + 1]; + ppos += 2; + } + else if (args [ppos] == "-cp" || args [ppos] == "--cachepath") { + if (ppos + 1 >= args.Length) { + Console.WriteLine ("Add-ins cache path not provided."); + return 1; + } + databasePath = args [ppos + 1]; + ppos += 2; + } + else if (args [ppos] == "-pkg" || args [ppos] == "--package") { + if (ppos + 1 >= args.Length) { + Console.WriteLine ("Package name not provided."); + return 1; + } + package = args [ppos + 1]; + ppos += 2; + } else if (args [ppos] == "-v") { - verbose = true; + verbose++; ppos++; } else toolParam = false; } - if (startupPath == null) - startupPath = Environment.CurrentDirectory; + AddinRegistry reg; + + if (package != null) { + if (startupPath != null || path != null || addinsPath != null || databasePath != null) { + Console.WriteLine ("The --registry, --path, --cachepath and --addinspath options\ncan't be used when --package is specified."); + return 1; + } + Application app = SetupService.GetExtensibleApplication (package); + if (app == null) { + Console.WriteLine ("The package could not be found or does not provide add-in registry information."); + return 1; + } + reg = app.Registry; + } + else { + if (startupPath == null) + startupPath = Environment.CurrentDirectory; + reg = path != null ? new AddinRegistry (path, startupPath, addinsPath, databasePath) : AddinRegistry.GetGlobalRegistry (); + } - AddinRegistry reg = path != null ? new AddinRegistry (path, startupPath) : AddinRegistry.GetGlobalRegistry (); try { SetupTool setupTool = new SetupTool (reg); - setupTool.VerboseOutput = verbose; + setupTool.VerboseOutputLevel = verbose; return setupTool.Run (args, ppos); } catch (Exception ex) { Console.WriteLine (ex); diff -Nru mono-addins-0.4/mautil/Makefile.am mono-addins-0.6.1/mautil/Makefile.am --- mono-addins-0.4/mautil/Makefile.am 2008-11-06 19:51:59.000000000 +0000 +++ mono-addins-0.6.1/mautil/Makefile.am 2011-04-13 09:00:29.000000000 +0000 @@ -1,5 +1,5 @@ -ASSEMBLY_COMPILER_COMMAND = mcs +ASSEMBLY_COMPILER_COMMAND = gmcs ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG ASSEMBLY = ../bin/mautil.exe COMPILE_TARGET = exe @@ -27,14 +27,16 @@ DLL_REFERENCES = -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) +$(ASSEMBLY).mdb: $(ASSEMBLY) + +$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) mkdir -p $(dir $(ASSEMBLY)) $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) include $(top_srcdir)/Makefile.include -pkglibdir = $(prefix)/lib/mono/mono-addins +pkglibdir = $(libdir)/mono/mono-addins pkglib_SCRIPTS = $(ASSEMBLY) $(build_datafiles) man_MANS = mautil.1 diff -Nru mono-addins-0.4/mautil/Makefile.in mono-addins-0.6.1/mautil/Makefile.in --- mono-addins-0.4/mautil/Makefile.in 2008-11-06 19:52:35.000000000 +0000 +++ mono-addins-0.6.1/mautil/Makefile.in 2011-04-13 09:45:29.000000000 +0000 @@ -58,7 +58,7 @@ pkgconfigDATA_INSTALL = $(INSTALL_DATA) DATA = $(pkgconfig_DATA) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -pkglibdir = $(prefix)/lib/mono/mono-addins +pkglibdir = $(libdir)/mono/mono-addins ACLOCAL = @ACLOCAL@ AL = @AL@ AMTAR = @AMTAR@ @@ -85,11 +85,15 @@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MCS = @MCS@ MKDIR_P = @MKDIR_P@ +MONODOC_CFLAGS = @MONODOC_CFLAGS@ +MONODOC_LIBS = @MONODOC_LIBS@ MONO_ADDINS_DEFAULT_LIB = @MONO_ADDINS_DEFAULT_LIB@ MONO_ADDINS_GUI_DEFAULT_LIB = @MONO_ADDINS_GUI_DEFAULT_LIB@ +MONO_ADDINS_MSBUILD_DEFAULT_LIB = @MONO_ADDINS_MSBUILD_DEFAULT_LIB@ MONO_ADDINS_SETUP_DEFAULT_LIB = @MONO_ADDINS_SETUP_DEFAULT_LIB@ MONO_NUNIT_CFLAGS = @MONO_NUNIT_CFLAGS@ MONO_NUNIT_LIBS = @MONO_NUNIT_LIBS@ @@ -142,9 +146,10 @@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -ASSEMBLY_COMPILER_COMMAND = mcs +ASSEMBLY_COMPILER_COMMAND = gmcs ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG ASSEMBLY = ../bin/mautil.exe COMPILE_TARGET = exe @@ -186,7 +191,7 @@ all: all-am .SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.include $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/Makefile.include $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -211,9 +216,9 @@ $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(top_srcdir)/configure: $(am__configure_deps) +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh mautil: $(top_builddir)/config.status $(srcdir)/mautil.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ @@ -459,7 +464,9 @@ all: $(ASSEMBLY) -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) +$(ASSEMBLY).mdb: $(ASSEMBLY) + +$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) mkdir -p $(dir $(ASSEMBLY)) $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) @@ -468,12 +475,11 @@ mkdir -p $(dir $@) cp $< $@ -$(POLICY_ASSEMBLIES): $(top_builddir)/policy.config $(top_srcdir)/mono-addins.snk - @for i in $(POLICY_VERSIONS); do \ - echo "Creating policy.$$i.$(ASSEMBLY_NAME)"; \ - sed -e "s/@ASSEMBLY_NAME@/$(ASSEMBLY_NAME)/" -e "s/@POLICY@/$$i/" $(top_builddir)/policy.config > policy.$$i.config; \ - $(AL) -link:policy.$$i.config -out:policy.$$i.$(ASSEMBLY_NAME).dll -keyfile:$(top_srcdir)/mono-addins.snk; \ - done +policy.%.config: $(top_builddir)/policy.config + sed -e "s/@ASSEMBLY_NAME@/$(ASSEMBLY_NAME)/" -e "s/@POLICY@/$*/" $(top_builddir)/policy.config > $@ + +$(POLICY_ASSEMBLIES) : policy.%.$(ASSEMBLY_NAME).dll: policy.%.config $(top_srcdir)/mono-addins.snk + $(AL) -link:policy.$*.config -out:$@ -keyfile:$(top_srcdir)/mono-addins.snk gac-install: $(POLICY_ASSEMBLIES) $(GACUTIL) /i $(ASSEMBLY) /f $(GACUTIL_FLAGS) || exit 1; diff -Nru mono-addins-0.4/Mono.Addins/AssemblyInfo.cs mono-addins-0.6.1/Mono.Addins/AssemblyInfo.cs --- mono-addins-0.4/Mono.Addins/AssemblyInfo.cs 2008-11-06 19:52:14.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/AssemblyInfo.cs 2011-04-13 09:00:29.000000000 +0000 @@ -17,4 +17,9 @@ // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly: AssemblyVersion("0.4.0.0")] +[assembly: AssemblyVersion("0.6.0.0")] + +[assembly: InternalsVisibleTo ("Mono.Addins.Setup, PublicKey=00240000048000009400000006020000002400005253413100" + + "0400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c" + + "3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4" + + "f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")] diff -Nru mono-addins-0.4/Mono.Addins/ChangeLog mono-addins-0.6.1/Mono.Addins/ChangeLog --- mono-addins-0.4/Mono.Addins/ChangeLog 2008-11-06 19:52:14.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/ChangeLog 2011-04-13 09:00:29.000000000 +0000 @@ -1,3 +1,451 @@ +2010-10-14 Lluis Sanchez Gual + + * AddinScanner.cs: Don't inherit CustomExtension attributes. + The attribute must be explicitly applied to classes to be + marked as extensions. + +2010-07-01 Lluis Sanchez Gual + + * Mono.Addins.csproj: + * Mono.Addins.Description/Extension.cs: + * Mono.Addins.Description/Dependency.cs: + * Mono.Addins.Description/AddinFlags.cs: + * Mono.Addins.Description/ExtensionPoint.cs: + * Mono.Addins.Description/AddinDependency.cs: + * Mono.Addins.Description/AddinDescription.cs: + * Mono.Addins.Description/ExtensionNodeSet.cs: + * Mono.Addins.Description/NativeDependency.cs: + * Mono.Addins.Localization/IAddinLocalizer.cs: + * Mono.Addins.Description/ObjectDescription.cs: + * Mono.Addins.Description/ModuleDescription.cs: + * Mono.Addins.Description/ExtensionNodeType.cs: + * Mono.Addins.Description/NodeTypeAttribute.cs: + * Mono.Addins.Description/AssemblyDependency.cs: + * Mono.Addins.Description/ExtensionCollection.cs: + * Mono.Addins.Description/DependencyCollection.cs: + * Mono.Addins.Localization/IPluralAddinLocalizer.cs: + * Mono.Addins.Localization/IAddinLocalizerFactory.cs: + * Mono.Addins.Description/ExtensionNodeDescription.cs: + * Mono.Addins.Description/ExtensionPointCollection.cs: + * Mono.Addins.Description/ConditionTypeDescription.cs: + * Mono.Addins.Description/ExtensionNodeSetCollection.cs: + * Mono.Addins.Description/ModuleDescriptionCollection.cs: + * Mono.Addins.Description/NodeTypeAttributeCollection.cs: + * Mono.Addins.Description/ExtensionNodeTypeCollection.cs: + * Mono.Addins.Description/ObjectDescriptionCollection.cs: + * Mono.Addins.Description/ExtensionNodeDescriptionCollection.cs: + * Mono.Addins.Description/ConditionTypeDescriptionCollection.cs: + Added documentation. + +2010-06-17 Lluis Sanchez Gual + + * Mono.Addins/NodeElement.cs: + * Mono.Addins/RuntimeAddin.cs: + * Mono.Addins/IProgressStatus.cs: + * Mono.Addins/IAddinInstaller.cs: + * Mono.Addins/TypeExtensionNode.cs: + * Mono.Addins/ExtensionNodeList.cs: + * Mono.Addins/InstanceExtensionNode.cs: + * Mono.Addins/NodeAttributeAttribute.cs: + * Mono.Addins/ExtensionNodeAttribute.cs: + * Mono.Addins/ExtensionPointAttribute.cs: + * Mono.Addins/ImportAddinFileAttribute.cs: + * Mono.Addins/MissingDependencyException.cs: + * Mono.Addins/TypeExtensionPointAttribute.cs: + * Mono.Addins/ExtensionNodeChildAttribute.cs: + * Mono.Addins/ImportAddinAssemblyAttribute.cs: Added some + documentation. + +2010-05-27 Lluis Sanchez Gual + + * Mono.Addins/AddinManager.cs: + * Mono.Addins/ConditionType.cs: + * Mono.Addins/ExtensionNode.cs: + * Mono.Addins/ExtensionContext.cs: + * Mono.Addins/ExtensionAttribute.cs: + * Mono.Addins/AddinRootAttribute.cs: + * Mono.Addins/ConsoleProgressStatus.cs: + * Mono.Addins/CustomExtensionAttribute.cs: + * Mono.Addins/ExtensionAttributeAttribute.cs: More + documentation. + +2010-05-27 Lluis Sanchez Gual + + * Mono.Addins/AddinEngine.cs: + * Mono.Addins/AddinManager.cs: + * Mono.Addins/AddinRegistry.cs: + * Mono.Addins/AddinEventArgs.cs: + * Mono.Addins/AddinLocalizer.cs: + * Mono.Addins/AddinAttribute.cs: + * Mono.Addins/AddinErrorEventArgs.cs: + * Mono.Addins/AddinModuleAttribute.cs: + * Mono.Addins/AddinAuthorAttribute.cs: + * Mono.Addins/AddinDependencyAttribute.cs: + * Mono.Addins/AddinLocalizerGettextAttribute.cs: Added some + API documentation. + +2010-05-25 Lluis Sanchez Gual + + * Mono.Addins.Database/AddinScanResult.cs: Properly resolve + Mono.Addins. + +2010-05-25 Lluis Sanchez Gual + + * Mono.Addins/AddinManager.cs: + * Mono.Addins/ExtensionContext.cs: Added methods for + subscribing type-bound extension points. + +2010-05-25 Lluis Sanchez Gual + + * Mono.Addins.csproj: Add Debug and Release configurations. + + * Mono.Addins.Database/AddinScanner.cs: Fixed node type + parsing issue with TypeExtensionPointAttribute. + +2010-05-21 Lluis Sanchez Gual + + * Mono.Addins.Database/AddinUpdateData.cs: When resolving + extension from an optional module, include dependencies + defined in the main module. + + * Mono.Addins.Database/SetupDomain.cs: Flush. + + * Mono.Addins.Database/AddinScanner.cs: Look for assembly + imports in the main assembly. + +2010-05-21 Lluis Sanchez Gual + + * Mono.Addins/ExtensionNode.cs: + * Mono.Addins/ExtensionTree.cs: Data extension points bound to + an attribute now generate nodes of type + ExtensionNode + + * Mono.Addins/Addin.cs: Added some docs. + + * Mono.Addins.Database/AddinScanner.cs: + * Mono.Addins/ExtensionNodeAttribute.cs: + * Mono.Addins.Database/AddinUpdateData.cs: + * Mono.Addins.Description/ExtensionNodeType.cs: Changed name + of property (for consistency) + + * Mono.Addins/ExtensionPointAttribute.cs: Don't set a default + node name. The default name is assigned while scanning. + + * Mono.Addins.Database/DefaultAssemblyReflector.cs: This class + should not be public. + +2010-05-20 Lluis Sanchez Gual + + * Makefile.am: + * Mono.Addins.csproj: Updated. + + * Mono.Addins/TreeNode.cs: + * Mono.Addins/AddinEngine.cs: + * Mono.Addins/RuntimeAddin.cs: + * Mono.Addins/AddinManager.cs: + * Mono.Addins/ExtensionTree.cs: + * Mono.Addins/ExtensionNode.cs: + * Mono.Addins/ConditionType.cs: + * Mono.Addins/AddinRegistry.cs: + * Mono.Addins/ExtensionContext.cs: + * Mono.Addins/AddinSessionService.cs: + * Mono.Addins.Database/AddinDatabase.cs: + * Mono.Addins.Description/Dependency.cs: + * Mono.Addins.Description/AddinDependency.cs: + * Mono.Addins.Description/NativeDependency.cs: + * Mono.Addins.Description/AssemblyDependency.cs: New + AddinEngine class, which can be used to support several + engines in a single domain. + + * Mono.Addins/AddinAttribute.cs: + * Mono.Addins/AddinModuleAttribute.cs: + * Mono.Addins.Database/AddinScanner.cs: + * Mono.Addins/ImportAddinFileAttribute.cs: + * Mono.Addins/ImportAddinAssemblyAttribute.cs: Added support + for new add-in declaration attributes. + + * Mono.Addins/AddinCategoryAttribute.cs: Removed. + + * Mono.Addins/ExtensionPointAttribute.cs: + * Mono.Addins/TypeExtensionPointAttribute.cs: Use a better + name for the custom attribute type property. + + * Mono.Addins.Database/IAssemblyReflector.cs: + * Mono.Addins.Database/DefaultAssemblyReflector.cs: Added + methods for getting resources from an assembly. + +2010-03-30 Lluis Sanchez Gual + + * Mono.Addins.Serialization/BinaryXmlReader.cs: Properly + detect EOF. + + * Mono.Addins/Addin.cs: If a file is corrupted and can't be + read, delete it so that it can be properly regenerated. + +2010-03-30 Lluis Sanchez Gual + + * Mono.Addins.csproj: csc doesn't like iso-2. + +2010-03-29 Lluis Sanchez Gual + + * Mono.Addins.csproj: + * Mono.Addins/TypeExtensionNode.cs: + * Mono.Addins/AddinAuthorAttribute.cs: + * Mono.Addins.Database/AddinScanner.cs: + * Mono.Addins/CustomExtensionAttribute.cs: + * Mono.Addins.Database/IAssemblyReflector.cs: + * Mono.Addins/ExtensionAttributeAttribute.cs: Make sure the + solution builds on MS.NET 2.0. + +2010-03-26 Lluis Sanchez Gual + + * Mono.Addins.Database/AddinScanner.cs: Fix bug #541661 - + Assemblies with capital .DLL cannot be loaded. + +2010-03-26 Lluis Sanchez Gual + + * Makefile.am: + * Mono.Addins.csproj: + * Mono.Addins/AddinAttribute.cs: + * Mono.Addins/AddinAuthorAttribute.cs: + * Mono.Addins.Database/AddinScanner.cs: + * Mono.Addins/AddinCategoryAttribute.cs: + * Mono.Addins/AddinLocalizerGettextAttribute.cs: Allow + specifying some add-in properties using attribtues. + +2010-03-26 Lluis Sanchez Gual + + * Mono.Addins.Database/AddinScanner.cs: + * Mono.Addins.Description/AddinDescription.cs: Added support + for multiple .addin.xml files in a single assembly. + +2010-03-26 Lluis Sanchez Gual + + * Makefile.am: + * Mono.Addins.csproj: + * Mono.Addins/AddinManager.cs: + * Mono.Addins/ExtensionNode.cs: + * Mono.Addins/ExtensionTree.cs: + * Mono.Addins/ExtensionContext.cs: + * Mono.Addins/TypeExtensionNode.cs: + * Mono.Addins/ExtensionNodeList.cs: + * Mono.Addins/ExtensionAttribute.cs: + * Mono.Addins.Database/AddinScanner.cs: + * Mono.Addins/ExtensionNodeAttribute.cs: + * Mono.Addins/NodeAttributeAttribute.cs: + * Mono.Addins/ExtensionPointAttribute.cs: + * Mono.Addins.Database/AddinUpdateData.cs: + * Mono.Addins/CustomExtensionAttribute.cs: + * Mono.Addins/ExtensionAttributeAttribute.cs: + * Mono.Addins.Database/IAssemblyReflector.cs: + * Mono.Addins/TypeExtensionPointAttribute.cs: + * Mono.Addins.Description/ExtensionNodeType.cs: + * Mono.Addins.Database/DefaultAssemblyReflector.cs: + * Mono.Addins.Description/ExtensionNodeDescription.cs: Allow + using custom attributes for specifying extension node + metadata. + + * Mono.Addins.Database/AddinDatabase.cs: Consolidate + extensions before saving the final add-in descriptions. That + means merging extensions with the same path and making sure + the extension nodes have a correct ordering. + +2010-03-25 Lluis Sanchez Gual + + * Mono.Addins.Database/AddinScanner.cs: Removed special + handling of type references inside add-in roots. Type + references will now be resolved like in the add-ins, when + mapping the extensions. + +2010-03-01 Lluis Sanchez Gual + + * Mono.Addins.Database/AddinDatabase.cs: Let's use app domains + for mono too. + +2010-02-26 Lluis Sanchez Gual + + * Mono.Addins/ExtensionContext.cs: + * Mono.Addins.Description/ExtensionPoint.cs: Use generics. + + * Mono.Addins.Description/ExtensionNodeDescription.cs: Fix bug + in RemoteAttribute. + +2010-02-22 Lluis Sanchez Gual + + * Mono.Addins.csproj: Update. + + * Mono.Addins/TreeNode.cs: + * Mono.Addins/RuntimeAddin.cs: + * Mono.Addins/ExtensionTree.cs: + * Mono.Addins.Description/ModuleDescription.cs: Improved lazy + loading of optional modules. + + * Mono.Addins/AddinManager.cs: + * Mono.Addins/ExtensionContext.cs: + * Mono.Addins/ExtensionNodeList.cs: Added some generic methods + for querying extension points. + + * Mono.Addins/ExtensionNode.cs: Improved lazy loading of + optional modules. Added some generic methods for querying + extension points. + + * Mono.Addins.Description/ObjectDescriptionCollection.cs: + Added Insert method. + +2010-02-12 Lluis Sanchez Gual + + * Mono.Addins/RuntimeAddin.cs: When loading the assemblies of + an add-in, make sure the assemblies of the add-ins on which + it depends are also loaded. + +2010-02-11 Lluis Sanchez Gual + + * Mono.Addins/RuntimeAddin.cs: Remove debug spew. + +2010-02-09 Lluis Sanchez Gual + + * Mono.Addins/RuntimeAddin.cs: + * Mono.Addins/AddinSessionService.cs: Improve delayed loading + of assemblies. + +2010-01-11 Lluis Sanchez Gual + + * Mono.Addins/AddinManager.cs: + * Mono.Addins/AddinRegistry.cs: Update the registry when the + domain of a directory can't be retrieved for some reason + (for example, if the registry has been cleaned) + +2009-11-18 Lluis Sanchez Gual + + * Mono.Addins.Database/AddinDatabase.cs: Add missing null + check. + +2009-11-13 Lluis Sanchez Gual + + * Mono.Addins.Description/Extension.cs: Allow Not condition. + + * Mono.Addins.Database/AddinUpdateData.cs: Added some verbose + logging. + + * Mono.Addins.Database/AddinScanner.cs: + * Mono.Addins.Database/AddinDatabase.cs: + * Mono.Addins.Database/AddinScanResult.cs: Split the + AddinsToUpdateRelation list in two. AddinsToUpdate contains + addins that have been modified and whose extensions have to + be registered again. AddinsToUpdateRelation now contains + addins which have not been directly modified, but which are + dependencies of modified add-ins. The extensions of those + add-ins won't be processed, they will just include the new + extensions from the updated add-ins. + + * Mono.Addins.Database/SetupDomain.cs: Remove debug messages. + +2009-10-05 Lluis Sanchez Gual + + * Mono.Addins/AddinSessionService.cs: Pre-jit the assembly + loader hook. + +2009-09-01 Lluis Sanchez Gual + + * AssemblyInfo.cs: Bump Mono.Addins version. + +2009-08-20 Lluis Sanchez Gual + + * Makefile.am: Added a new project which Implements an msbuild + task for resolving add-in references. + +2009-08-19 Lluis Sanchez Gual + + * Mono.Addins/ExtensionContext.cs: Fix potentiall nullref. + +2009-08-19 Lluis Sanchez Gual + + * Mono.Addins/AddinRegistry.cs: Allow reading add-in manifests + even if the registry is not fully initialized. + +2009-08-19 Lluis Sanchez Gual + + * Mono.Addins.csproj: Update target framework to 2.0. + +2009-07-31 Lluis Sanchez Gual + + * Mono.Addins.Database/AddinScanner.cs: Properly read + InserBefore and InsertAfter attribute properties. Patch by + Levi Bard. + +2009-05-28 Lluis Sanchez Gual + + * Mono.Addins.csproj: Properly sign assemblies. + +2009-05-27 Lluis Sanchez Gual + + * Makefile.am: Remove startup class option. + + * Mono.Addins.Database/SetupProcess.cs: + * Mono.Addins.Database/AddinDatabase.cs: Use a generated + assembly instead of the dll to execute the scanner in a + separate process. + +2009-04-15 Lluis Sanchez Gual + + * Mono.Addins/RuntimeAddin.cs: New overload for GetFilePath. + + * Mono.Addins/AddinSessionService.cs: Improve error reporting + when the description of an add-in can't be loaded. + + * Mono.Addins.Database/Util.cs: + * Mono.Addins/AddinRegistry.cs: Allow using special folder + names in all paths. E.g. [ApplicationData]/MonoDevelop. It + can be used when initializing the add-in engine or in + .addins files. + + * Mono.Addins/Addin.cs: Write errors when loading a + description. + +2009-02-16 Lluis Sanchez Gual + + * Mono.Addins/ExtensionNodeChildAttribute.cs: Make sure the + ExtensionNodeTypeName property is set when using the + attribute constructor. + +2009-02-06 Lluis Sanchez Gual + + * Makefile.am: + * Mono.Addins.csproj: Updated. + + * Mono.Addins.Database/AddinScanner.cs: + * Mono.Addins.Description/AddinDescription.cs: BasePath is now + public. + + * Mono.Addins.Database/Util.cs: Added methods for checking if + the app is running on mono. + + * Mono.Addins.Database/SetupDomain.cs: + * Mono.Addins.Database/SetupProcess.cs: + * Mono.Addins.Database/ISetupHandler.cs: + * Mono.Addins.Database/AddinDatabase.cs: Added support for + scanning the addins in a separate appdomain instead of a + separate process. + +2009-02-06 Lluis Sanchez Gual + + * Mono.Addins/ExtensionNode.cs: Improve error message. + +2009-02-06 Lluis Sanchez Gual + + * Mono.Addins/ConditionType.cs: + * Mono.Addins/ExtensionTree.cs: Add support for Not condition. + +2008-11-10 Lluis Sanchez Gual + + * mono-addins.pc.in: Respect custom libdir during ./configure. Fixes bug + #443205. Patch by Diego Pettenò. + +2008-11-10 Lluis Sanchez Gual + + * Makefile.am: Fix building with parallel make jobs (-j8). Fixes bug + #443206. Patch by Diego Pettenò. + 2008-11-04 Lluis Sanchez Gual * Mono.Addins.csproj: Generate a library, not an exe. diff -Nru mono-addins-0.4/Mono.Addins/Makefile.am mono-addins-0.6.1/Mono.Addins/Makefile.am --- mono-addins-0.4/Mono.Addins/Makefile.am 2008-11-06 19:52:14.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Makefile.am 2011-04-13 09:00:29.000000000 +0000 @@ -1,7 +1,7 @@ KEY_FILE=$(top_srcdir)/mono-addins.snk -ASSEMBLY_COMPILER_COMMAND = mcs -ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -langversion:ISO-1 -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG "-main:Mono.Addins.Database.SetupProcess" +ASSEMBLY_COMPILER_COMMAND = gmcs +ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG ASSEMBLY = ../bin/Mono.Addins.dll ASSEMBLY_NAME=Mono.Addins COMPILE_TARGET = exe @@ -15,6 +15,7 @@ FILES = \ AssemblyInfo.cs \ Mono.Addins.Database/AddinDatabase.cs \ + Mono.Addins.Database/AddinFileSystemExtension.cs \ Mono.Addins.Database/AddinHostIndex.cs \ Mono.Addins.Database/AddinScanFolderInfo.cs \ Mono.Addins.Database/AddinScanner.cs \ @@ -24,12 +25,17 @@ Mono.Addins.Database/DefaultAssemblyReflector.cs \ Mono.Addins.Database/FileDatabase.cs \ Mono.Addins.Database/IAssemblyReflector.cs \ + Mono.Addins.Database/ISetupHandler.cs \ Mono.Addins.Database/ProcessProgressStatus.cs \ + Mono.Addins.Database/SetupDomain.cs \ + Mono.Addins.Database/SetupLocal.cs \ Mono.Addins.Database/SetupProcess.cs \ Mono.Addins.Database/Util.cs \ Mono.Addins.Description/AddinDependency.cs \ Mono.Addins.Description/AddinDescription.cs \ Mono.Addins.Description/AddinFlags.cs \ + Mono.Addins.Description/AddinProperty.cs \ + Mono.Addins.Description/AddinPropertyCollection.cs \ Mono.Addins.Description/AssemblyDependency.cs \ Mono.Addins.Description/ConditionTypeDescription.cs \ Mono.Addins.Description/ConditionTypeDescriptionCollection.cs \ @@ -66,18 +72,27 @@ Mono.Addins.Serialization/IBinaryXmlElement.cs \ Mono.Addins/Addin.cs \ Mono.Addins/AddinAttribute.cs \ + Mono.Addins/AddinAuthorAttribute.cs \ Mono.Addins/AddinDependencyAttribute.cs \ + Mono.Addins/AddinDescriptionAttribute.cs \ + Mono.Addins/AddinEngine.cs \ Mono.Addins/AddinErrorEventArgs.cs \ Mono.Addins/AddinEventArgs.cs \ Mono.Addins/AddinInfo.cs \ Mono.Addins/AddinLocalizer.cs \ + Mono.Addins/AddinLocalizerGettextAttribute.cs \ Mono.Addins/AddinManager.cs \ + Mono.Addins/AddinModuleAttribute.cs \ + Mono.Addins/AddinNameAttribute.cs \ + Mono.Addins/AddinPropertyAttribute.cs \ Mono.Addins/AddinRegistry.cs \ Mono.Addins/AddinRootAttribute.cs \ - Mono.Addins/AddinSessionService.cs \ Mono.Addins/ConditionType.cs \ Mono.Addins/ConsoleProgressStatus.cs \ + Mono.Addins/ContentType.cs \ + Mono.Addins/CustomExtensionAttribute.cs \ Mono.Addins/ExtensionAttribute.cs \ + Mono.Addins/ExtensionAttributeAttribute.cs \ Mono.Addins/ExtensionContext.cs \ Mono.Addins/ExtensionNode.cs \ Mono.Addins/ExtensionNodeAttribute.cs \ @@ -87,6 +102,8 @@ Mono.Addins/ExtensionTree.cs \ Mono.Addins/GettextCatalog.cs \ Mono.Addins/IAddinInstaller.cs \ + Mono.Addins/ImportAddinAssemblyAttribute.cs \ + Mono.Addins/ImportAddinFileAttribute.cs \ Mono.Addins/InstanceExtensionNode.cs \ Mono.Addins/IProgressStatus.cs \ Mono.Addins/MissingDependencyException.cs \ @@ -98,7 +115,7 @@ Mono.Addins/TypeExtensionNode.cs \ Mono.Addins/TypeExtensionPointAttribute.cs -DATA_FILES = Mono.Addins.dll.config +DATA_FILES = RESOURCES = @@ -106,11 +123,14 @@ REFERENCES = \ -r:System \ + -r:System.Core \ -r:System.Xml DLL_REFERENCES = -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) $(POLICY_ASSEMBLIES) +$(ASSEMBLY).mdb: $(ASSEMBLY) + +$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) $(POLICY_ASSEMBLIES) mkdir -p $(dir $(ASSEMBLY)) $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) diff -Nru mono-addins-0.4/Mono.Addins/Makefile.in mono-addins-0.6.1/Mono.Addins/Makefile.in --- mono-addins-0.4/Mono.Addins/Makefile.in 2008-11-06 19:52:35.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Makefile.in 2011-04-13 09:45:29.000000000 +0000 @@ -81,11 +81,15 @@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MCS = @MCS@ MKDIR_P = @MKDIR_P@ +MONODOC_CFLAGS = @MONODOC_CFLAGS@ +MONODOC_LIBS = @MONODOC_LIBS@ MONO_ADDINS_DEFAULT_LIB = @MONO_ADDINS_DEFAULT_LIB@ MONO_ADDINS_GUI_DEFAULT_LIB = @MONO_ADDINS_GUI_DEFAULT_LIB@ +MONO_ADDINS_MSBUILD_DEFAULT_LIB = @MONO_ADDINS_MSBUILD_DEFAULT_LIB@ MONO_ADDINS_SETUP_DEFAULT_LIB = @MONO_ADDINS_SETUP_DEFAULT_LIB@ MONO_NUNIT_CFLAGS = @MONO_NUNIT_CFLAGS@ MONO_NUNIT_LIBS = @MONO_NUNIT_LIBS@ @@ -138,11 +142,12 @@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ KEY_FILE = $(top_srcdir)/mono-addins.snk -ASSEMBLY_COMPILER_COMMAND = mcs -ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -langversion:ISO-1 -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG "-main:Mono.Addins.Database.SetupProcess" +ASSEMBLY_COMPILER_COMMAND = gmcs +ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG ASSEMBLY = ../bin/Mono.Addins.dll ASSEMBLY_NAME = Mono.Addins COMPILE_TARGET = exe @@ -152,6 +157,7 @@ FILES = \ AssemblyInfo.cs \ Mono.Addins.Database/AddinDatabase.cs \ + Mono.Addins.Database/AddinFileSystemExtension.cs \ Mono.Addins.Database/AddinHostIndex.cs \ Mono.Addins.Database/AddinScanFolderInfo.cs \ Mono.Addins.Database/AddinScanner.cs \ @@ -161,12 +167,17 @@ Mono.Addins.Database/DefaultAssemblyReflector.cs \ Mono.Addins.Database/FileDatabase.cs \ Mono.Addins.Database/IAssemblyReflector.cs \ + Mono.Addins.Database/ISetupHandler.cs \ Mono.Addins.Database/ProcessProgressStatus.cs \ + Mono.Addins.Database/SetupDomain.cs \ + Mono.Addins.Database/SetupLocal.cs \ Mono.Addins.Database/SetupProcess.cs \ Mono.Addins.Database/Util.cs \ Mono.Addins.Description/AddinDependency.cs \ Mono.Addins.Description/AddinDescription.cs \ Mono.Addins.Description/AddinFlags.cs \ + Mono.Addins.Description/AddinProperty.cs \ + Mono.Addins.Description/AddinPropertyCollection.cs \ Mono.Addins.Description/AssemblyDependency.cs \ Mono.Addins.Description/ConditionTypeDescription.cs \ Mono.Addins.Description/ConditionTypeDescriptionCollection.cs \ @@ -203,18 +214,27 @@ Mono.Addins.Serialization/IBinaryXmlElement.cs \ Mono.Addins/Addin.cs \ Mono.Addins/AddinAttribute.cs \ + Mono.Addins/AddinAuthorAttribute.cs \ Mono.Addins/AddinDependencyAttribute.cs \ + Mono.Addins/AddinDescriptionAttribute.cs \ + Mono.Addins/AddinEngine.cs \ Mono.Addins/AddinErrorEventArgs.cs \ Mono.Addins/AddinEventArgs.cs \ Mono.Addins/AddinInfo.cs \ Mono.Addins/AddinLocalizer.cs \ + Mono.Addins/AddinLocalizerGettextAttribute.cs \ Mono.Addins/AddinManager.cs \ + Mono.Addins/AddinModuleAttribute.cs \ + Mono.Addins/AddinNameAttribute.cs \ + Mono.Addins/AddinPropertyAttribute.cs \ Mono.Addins/AddinRegistry.cs \ Mono.Addins/AddinRootAttribute.cs \ - Mono.Addins/AddinSessionService.cs \ Mono.Addins/ConditionType.cs \ Mono.Addins/ConsoleProgressStatus.cs \ + Mono.Addins/ContentType.cs \ + Mono.Addins/CustomExtensionAttribute.cs \ Mono.Addins/ExtensionAttribute.cs \ + Mono.Addins/ExtensionAttributeAttribute.cs \ Mono.Addins/ExtensionContext.cs \ Mono.Addins/ExtensionNode.cs \ Mono.Addins/ExtensionNodeAttribute.cs \ @@ -224,6 +244,8 @@ Mono.Addins/ExtensionTree.cs \ Mono.Addins/GettextCatalog.cs \ Mono.Addins/IAddinInstaller.cs \ + Mono.Addins/ImportAddinAssemblyAttribute.cs \ + Mono.Addins/ImportAddinFileAttribute.cs \ Mono.Addins/InstanceExtensionNode.cs \ Mono.Addins/IProgressStatus.cs \ Mono.Addins/MissingDependencyException.cs \ @@ -235,11 +257,12 @@ Mono.Addins/TypeExtensionNode.cs \ Mono.Addins/TypeExtensionPointAttribute.cs -DATA_FILES = Mono.Addins.dll.config +DATA_FILES = RESOURCES = EXTRAS = REFERENCES = \ -r:System \ + -r:System.Core \ -r:System.Xml DLL_REFERENCES = @@ -262,7 +285,7 @@ all: all-am .SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.include $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/Makefile.include $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -287,9 +310,9 @@ $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(top_srcdir)/configure: $(am__configure_deps) +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh mono-addins.pc: $(top_builddir)/config.status $(srcdir)/mono-addins.pc.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ @@ -467,7 +490,9 @@ all: $(ASSEMBLY) -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) $(POLICY_ASSEMBLIES) +$(ASSEMBLY).mdb: $(ASSEMBLY) + +$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) $(POLICY_ASSEMBLIES) mkdir -p $(dir $(ASSEMBLY)) $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) @@ -479,12 +504,11 @@ mkdir -p $(dir $@) cp $< $@ -$(POLICY_ASSEMBLIES): $(top_builddir)/policy.config $(top_srcdir)/mono-addins.snk - @for i in $(POLICY_VERSIONS); do \ - echo "Creating policy.$$i.$(ASSEMBLY_NAME)"; \ - sed -e "s/@ASSEMBLY_NAME@/$(ASSEMBLY_NAME)/" -e "s/@POLICY@/$$i/" $(top_builddir)/policy.config > policy.$$i.config; \ - $(AL) -link:policy.$$i.config -out:policy.$$i.$(ASSEMBLY_NAME).dll -keyfile:$(top_srcdir)/mono-addins.snk; \ - done +policy.%.config: $(top_builddir)/policy.config + sed -e "s/@ASSEMBLY_NAME@/$(ASSEMBLY_NAME)/" -e "s/@POLICY@/$*/" $(top_builddir)/policy.config > $@ + +$(POLICY_ASSEMBLIES) : policy.%.$(ASSEMBLY_NAME).dll: policy.%.config $(top_srcdir)/mono-addins.snk + $(AL) -link:policy.$*.config -out:$@ -keyfile:$(top_srcdir)/mono-addins.snk gac-install: $(POLICY_ASSEMBLIES) $(GACUTIL) /i $(ASSEMBLY) /f $(GACUTIL_FLAGS) || exit 1; diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/AddinAttribute.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinAttribute.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/AddinAttribute.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinAttribute.cs 2011-04-13 09:00:29.000000000 +0000 @@ -28,9 +28,13 @@ using System; +using Mono.Addins.Description; namespace Mono.Addins { + /// + /// Marks an assembly as being an add-in. + /// [AttributeUsage (AttributeTargets.Assembly)] public class AddinAttribute: Attribute { @@ -38,40 +42,107 @@ string version; string ns; string category; - + bool enabledByDefault = true; + AddinFlags flags; + string compatVersion; + string url; + + /// + /// Initializes an add-in marker attribute + /// public AddinAttribute () { } + /// + /// Initializes an add-in marker attribute + /// + /// + /// Identifier of the add-in + /// public AddinAttribute (string id) { this.id = id; } + /// + /// Initializes an add-in marker attribute + /// + /// + /// Identifier of the add-in + /// + /// + /// Version of the add-in + /// public AddinAttribute (string id, string version) { this.id = id; this.version = version; } + /// + /// Identifier of the add-in. + /// public string Id { get { return id != null ? id : string.Empty; } set { id = value; } } + /// + /// Version of the add-in. + /// public string Version { get { return version != null ? version : string.Empty; } set { version = value; } } + /// + /// Version of the add-in with which this add-in is backwards compatible. + /// + public string CompatVersion { + get { return compatVersion != null ? compatVersion : string.Empty; } + set { compatVersion = value; } + } + + /// + /// Namespace of the add-in + /// public string Namespace { get { return ns != null ? ns : string.Empty; } set { ns = value; } } + /// + /// Category of the add-in + /// public string Category { get { return category != null ? category : string.Empty; } set { category = value; } } + + /// + /// Url to a web page with more information about the add-in + /// + public string Url { + get { return url != null ? url : string.Empty; } + set { url = value; } + } + + /// + /// When set to True, the add-in will be automatically enabled after installing. + /// It's True by default. + /// + public bool EnabledByDefault { + get { return this.enabledByDefault; } + set { this.enabledByDefault = value; } + } + + /// + /// Add-in flags + /// + public AddinFlags Flags { + get { return this.flags; } + set { this.flags = value; } + } } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/AddinAuthorAttribute.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinAuthorAttribute.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/AddinAuthorAttribute.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinAuthorAttribute.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,59 @@ +// +// AddinAuthorAttribute.cs +// +// Author: +// Lluis Sanchez Gual +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; + +namespace Mono.Addins +{ + /// + /// Declares an author of the add-in + /// + [AttributeUsage (AttributeTargets.Assembly, AllowMultiple=true)] + public class AddinAuthorAttribute: Attribute + { + string name; + + /// + /// Initializes the attribute + /// + /// + /// Name of the author + /// + public AddinAuthorAttribute (string name) + { + this.name = name; + } + + /// + /// Author name + /// + public string Name { + get { return this.name; } + set { this.name = value; } + } + } +} + diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/Addin.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/Addin.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/Addin.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/Addin.cs 2011-04-13 09:00:29.000000000 +0000 @@ -34,9 +34,13 @@ using System.Collections.Specialized; using Mono.Addins.Description; using Mono.Addins.Database; +using System.Linq; namespace Mono.Addins { + /// + /// An add-in. + /// public class Addin { AddinInfo addin; @@ -44,6 +48,8 @@ string sourceFile; WeakReference desc; AddinDatabase database; + bool? isLatestVersion; + bool? isUserAddin; internal Addin (AddinDatabase database, string file) { @@ -51,6 +57,9 @@ configFile = file; } + /// + /// Full identifier of the add-in, including namespace and version. + /// public string Id { get { if (configFile != null) @@ -59,31 +68,68 @@ } } + /// + /// Namespace of the add-in. + /// public string Namespace { get { return this.AddinInfo.Namespace; } } + /// + /// Identifier of the add-in (without namespace) + /// public string LocalId { get { return this.AddinInfo.LocalId; } } + /// + /// Version of the add-in + /// public string Version { get { return this.AddinInfo.Version; } } + /// + /// Display name of the add-in + /// public string Name { get { return this.AddinInfo.Name; } } + /// + /// Custom properties specified in the add-in header + /// + public AddinPropertyCollection Properties { + get { return this.AddinInfo.Properties; } + } + internal string PrivateDataPath { get { return Path.Combine (database.AddinPrivateDataPath, Path.GetFileNameWithoutExtension (Description.FileName)); } } + /// + /// Checks version compatibility. + /// + /// + /// An add-in version. + /// + /// + /// True if the provided version is compatible with this add-in. + /// + /// + /// This method checks the CompatVersion property to know if the provided version is compatible with the version of this add-in. + /// public bool SupportsVersion (string version) { return AddinInfo.SupportsVersion (version); } - + + /// + /// Returns a that represents the current . + /// + /// + /// A that represents the current . + /// public override string ToString () { return Id; @@ -102,8 +148,23 @@ } } + /// + /// Gets or sets the enabled status of the add-in. + /// + /// + /// This property can be used to enable or disable an add-in. + /// The enabled status of an add-in is stored in the add-in registry, + /// so when an add-in is disabled, it will be disabled for all applications + /// sharing the same registry. + /// When an add-in is enabled or disabled, the extension points currently loaded + /// in memory will be properly updated to include or exclude extensions from the add-in. + /// public bool Enabled { - get { return AddinInfo.IsRoot ? true : database.IsAddinEnabled (Description.Domain, AddinInfo.Id, true); } + get { + if (!IsLatestVersion) + return false; + return AddinInfo.IsRoot ? true : database.IsAddinEnabled (Description.Domain, AddinInfo.Id, true); + } set { if (value) database.EnableAddin (Description.Domain, AddinInfo.Id, true); @@ -112,10 +173,43 @@ } } + internal bool IsLatestVersion { + get { + if (isLatestVersion == null) { + string id, version; + Addin.GetIdParts (AddinInfo.Id, out id, out version); + var addins = database.GetInstalledAddins (null, AddinSearchFlagsInternal.IncludeAll | AddinSearchFlagsInternal.LatestVersionsOnly); + isLatestVersion = addins.Where (a => Addin.GetIdName (a.Id) == id && a.Version == version).Any (); + } + return isLatestVersion.Value; + } + set { + isLatestVersion = value; + } + } + + /// + /// Returns 'true' if the add-in is installed in the user's personal folder + /// public bool IsUserAddin { - get { return configFile.StartsWith (Environment.GetFolderPath (Environment.SpecialFolder.Personal)); } + get { + if (isUserAddin == null) + SetIsUserAddin (Description); + return isUserAddin.Value; + } + } + + void SetIsUserAddin (AddinDescription adesc) + { + string installPath = database.Registry.DefaultAddinsFolder; + if (installPath [installPath.Length - 1] != Path.DirectorySeparatorChar) + installPath += Path.DirectorySeparatorChar; + isUserAddin = adesc != null && Path.GetFullPath (adesc.AddinFile).StartsWith (installPath); } + /// + /// Path to the add-in file (it can be an assembly or a standalone XML manifest) + /// public string AddinFile { get { if (sourceFile == null && addin == null) @@ -137,6 +231,9 @@ } } + /// + /// Description of the add-in + /// public AddinDescription Description { get { if (desc != null) { @@ -146,14 +243,26 @@ } AddinDescription m; - database.ReadAddinDescription (null, configFile, out m); + database.ReadAddinDescription (new ConsoleProgressStatus (true), configFile, out m); - if (m == null) + if (m == null) { + try { + if (File.Exists (configFile)) { + // The file is corrupted. Remove it. + File.Delete (configFile); + } + } catch { + // Ignore + } throw new InvalidOperationException ("Could not read add-in description"); + } if (addin == null) { addin = AddinInfo.ReadFromDescription (m); sourceFile = m.AddinFile; } + SetIsUserAddin (m); + if (!isUserAddin.Value) + m.Flags |= AddinFlags.CantUninstall; desc = new WeakReference (m); return m; } @@ -165,7 +274,18 @@ addin = null; } - // returns -1 if v1 > v2 + /// + /// Compares two add-in versions + /// + /// + /// -1 if v1 is greater than v2, 0 if v1 == v2, 1 if v1 less than v2 + /// + /// + /// A version + /// + /// + /// A version + /// public static int CompareVersions (string v1, string v2) { string[] a1 = v1.Split ('.'); @@ -194,7 +314,22 @@ return 1; return 0; } - + + /// + /// Returns the identifier of an add-in + /// + /// + /// The full identifier. + /// + /// + /// Namespace of the add-in + /// + /// + /// Name of the add-in + /// + /// + /// Version of the add-in + /// public static string GetFullId (string ns, string id, string version) { string res; @@ -210,7 +345,13 @@ else return res; } - + + /// + /// Given a full add-in identifier, returns the namespace and name of the add-in (it removes the version number) + /// + /// + /// Add-in identifier. + /// public static string GetIdName (string addinId) { int i = addinId.IndexOf (','); @@ -220,6 +361,12 @@ return addinId; } + /// + /// Given a full add-in identifier, returns the version the add-in + /// + /// + /// The version. + /// public static string GetIdVersion (string addinId) { int i = addinId.IndexOf (','); @@ -229,6 +376,18 @@ return string.Empty; } + /// + /// Splits a full add-in identifier in name and version + /// + /// + /// Add-in identifier. + /// + /// + /// The resulting name + /// + /// + /// The resulting version + /// public static void GetIdParts (string addinId, out string name, out string version) { int i = addinId.IndexOf (','); diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/AddinDependencyAttribute.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinDependencyAttribute.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/AddinDependencyAttribute.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinDependencyAttribute.cs 2011-04-13 09:00:29.000000000 +0000 @@ -31,22 +31,40 @@ namespace Mono.Addins { + /// + /// Declares a dependency on an add-in or add-in host + /// [AttributeUsage (AttributeTargets.Assembly, AllowMultiple=true)] public class AddinDependencyAttribute: Attribute { string id; string version; + /// + /// Initializes the attribute + /// + /// + /// Identifier of the add-in + /// + /// + /// Version of the add-in + /// public AddinDependencyAttribute (string id, string version) { this.id = id; this.version = version; } + /// + /// Identifier of the add-in + /// public string Id { get { return id; } } + /// + /// Version of the add-in + /// public string Version { get { return version; } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/AddinDescriptionAttribute.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinDescriptionAttribute.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/AddinDescriptionAttribute.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinDescriptionAttribute.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,73 @@ +// +// AddinDescriptionAttribute.cs +// +// Author: +// Lluis Sanchez Gual +// +// Copyright (c) 2011 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; + +namespace Mono.Addins +{ + /// + /// Describes the purpose of an add-in or add-in root + /// + [AttributeUsage (AttributeTargets.Assembly, AllowMultiple = true)] + public class AddinDescriptionAttribute: Attribute + { + /// + /// Initializes a new instance of the class. + /// + /// + /// Description of the add-in + /// + public AddinDescriptionAttribute (string description) + { + Description = description; + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Description of the add-in + /// + /// + /// Locale of the description (for example, 'en-US', or 'en') + /// + public AddinDescriptionAttribute (string description, string locale) + { + Description = description; + Locale = locale; + } + + /// + /// Description of the add-in + /// + public string Description { get; set; } + + /// + /// Locale of the description (for example, 'en-US', or 'en') + /// + public string Locale { get; set; } + } +} + diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/AddinEngine.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinEngine.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/AddinEngine.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinEngine.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,752 @@ +// +// AddinService.cs +// +// Author: +// Lluis Sanchez Gual +// +// Copyright (C) 2007 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + + +using System; +using System.Linq; +using System.Xml; +using System.Collections; +using System.Reflection; + +using Mono.Addins.Description; +using Mono.Addins.Database; +using Mono.Addins.Localization; +using System.Collections.Generic; + +namespace Mono.Addins +{ + /// + /// An add-in engine. + /// + /// + /// This class allows hosting several independent add-in engines in a single application domain. + /// In general, applications use the AddinManager class to query and manage extensions. This class is static, + /// so the API is easily accessible. However, some kind applications may need to use several isolated + /// add-in engines, and in this case the AddinManager class can't be used, because it is bound to a single + /// add-in engine. Those applications can instead create several instances of the AddinEngine class. Each + /// add-in engine can be independently initialized with different add-in registries and extension models. + /// + public class AddinEngine: ExtensionContext + { + bool initialized; + string startupDirectory; + AddinRegistry registry; + IAddinInstaller installer; + + bool checkAssemblyLoadConflicts; + Hashtable loadedAddins = new Hashtable (); + Dictionary nodeSets = new Dictionary (); + Hashtable autoExtensionTypes = new Hashtable (); + Hashtable loadedAssemblies = new Hashtable (); + AddinLocalizer defaultLocalizer; + IProgressStatus defaultProgressStatus = new ConsoleProgressStatus (false); + + /// + /// Raised when there is an error while loading an add-in + /// + public static event AddinErrorEventHandler AddinLoadError; + + /// + /// Raised when an add-in is loaded + /// + public static event AddinEventHandler AddinLoaded; + + /// + /// Raised when an add-in is unloaded + /// + public static event AddinEventHandler AddinUnloaded; + + /// + /// Initializes a new instance of the class. + /// + public AddinEngine () + { + } + + /// + /// Initializes the add-in engine + /// + /// + /// Location of the add-in registry. + /// + /// The add-in engine needs to be initialized before doing any add-in operation. + /// When initialized with this method, it will look for add-in in the add-in registry + /// located in the specified path. + /// + public void Initialize (string configDir) + { + if (initialized) + return; + + Assembly asm = Assembly.GetEntryAssembly (); + if (asm == null) asm = Assembly.GetCallingAssembly (); + Initialize (asm, configDir, null, null); + } + + /// + /// Initializes the add-in engine. + /// + /// + /// Location of the add-in registry. + /// + /// + /// Add-ins directory. If the path is relative, it is considered to be relative + /// to the configDir directory. + /// + /// + /// The add-in engine needs to be initialized before doing any add-in operation. + /// Configuration information about the add-in registry will be stored in the + /// provided location. The add-in engine will look for add-ins in the provided + /// 'addinsDir' directory. + /// + /// When specifying a path, it is possible to use a special folder name as root. + /// For example: [Personal]/.config/MyApp. In this case, [Personal] will be replaced + /// by the location of the Environment.SpecialFolder.Personal folder. Any value + /// of the Environment.SpecialFolder enumeration can be used (always between square + /// brackets) + /// + public void Initialize (string configDir, string addinsDir) + { + if (initialized) + return; + + Assembly asm = Assembly.GetEntryAssembly (); + if (asm == null) asm = Assembly.GetCallingAssembly (); + Initialize (asm, configDir, addinsDir, null); + } + + /// + /// Initializes the add-in engine. + /// + /// + /// Location of the add-in registry. + /// + /// + /// Add-ins directory. If the path is relative, it is considered to be relative + /// to the configDir directory. + /// + /// + /// Location of the add-in database. If the path is relative, it is considered to be relative + /// to the configDir directory. + /// + /// + /// The add-in engine needs to be initialized before doing any add-in operation. + /// Configuration information about the add-in registry will be stored in the + /// provided location. The add-in engine will look for add-ins in the provided + /// 'addinsDir' directory. Cached information about add-ins will be stored in + /// the 'databaseDir' directory. + /// + /// When specifying a path, it is possible to use a special folder name as root. + /// For example: [Personal]/.config/MyApp. In this case, [Personal] will be replaced + /// by the location of the Environment.SpecialFolder.Personal folder. Any value + /// of the Environment.SpecialFolder enumeration can be used (always between square + /// brackets) + /// + public void Initialize (string configDir, string addinsDir, string databaseDir) + { + if (initialized) + return; + + Assembly asm = Assembly.GetEntryAssembly (); + if (asm == null) asm = Assembly.GetCallingAssembly (); + Initialize (asm, configDir, addinsDir, databaseDir); + } + + internal void Initialize (Assembly startupAsm, string configDir, string addinsDir, string databaseDir) + { + if (initialized) + return; + + Initialize (this); + + string asmFile = new Uri (startupAsm.CodeBase).LocalPath; + startupDirectory = System.IO.Path.GetDirectoryName (asmFile); + + string customDir = Environment.GetEnvironmentVariable ("MONO_ADDINS_REGISTRY"); + if (customDir != null && customDir.Length > 0) + configDir = customDir; + + if (configDir == null || configDir.Length == 0) + registry = AddinRegistry.GetGlobalRegistry (this, startupDirectory); + else + registry = new AddinRegistry (this, configDir, startupDirectory, addinsDir, databaseDir); + + if (registry.CreateHostAddinsFile (asmFile) || registry.UnknownDomain) + registry.Update (new ConsoleProgressStatus (false)); + + initialized = true; + + ActivateRoots (); + OnAssemblyLoaded (null, null); + AppDomain.CurrentDomain.AssemblyLoad += new AssemblyLoadEventHandler (OnAssemblyLoaded); + } + + /// + /// Finalizes the add-in engine. + /// + public void Shutdown () + { + initialized = false; + AppDomain.CurrentDomain.AssemblyLoad -= new AssemblyLoadEventHandler (OnAssemblyLoaded); + loadedAddins.Clear (); + loadedAssemblies.Clear (); + registry.Dispose (); + registry = null; + startupDirectory = null; + ClearContext (); + } + + /// + /// Sets the default localizer to be used for this add-in engine + /// + /// + /// The add-in localizer + /// + public void InitializeDefaultLocalizer (IAddinLocalizer localizer) + { + CheckInitialized (); + if (localizer != null) + defaultLocalizer = new AddinLocalizer (localizer); + else + defaultLocalizer = null; + } + + internal string StartupDirectory { + get { return startupDirectory; } + } + + /// + /// Gets whether the add-in engine has been initialized. + /// + public bool IsInitialized { + get { return initialized; } + } + + /// + /// Gets the default add-in installer + /// + /// + /// The default installer is used by the CheckInstalled method to request + /// the installation of missing add-ins. + /// + public IAddinInstaller DefaultInstaller { + get { return installer; } + set { installer = value; } + } + + /// + /// Gets the default localizer for this add-in engine + /// + public AddinLocalizer DefaultLocalizer { + get { + CheckInitialized (); + if (defaultLocalizer != null) + return defaultLocalizer; + else + return NullLocalizer.Instance; + } + } + + internal ExtensionContext DefaultContext { + get { return this; } + } + + /// + /// Gets the localizer for the add-in that is invoking this property + /// + public AddinLocalizer CurrentLocalizer { + get { + CheckInitialized (); + Assembly asm = Assembly.GetCallingAssembly (); + RuntimeAddin addin = GetAddinForAssembly (asm); + if (addin != null) + return addin.Localizer; + else + return DefaultLocalizer; + } + } + + /// + /// Gets a reference to the RuntimeAddin object for the add-in that is invoking this property + /// + public RuntimeAddin CurrentAddin { + get { + CheckInitialized (); + Assembly asm = Assembly.GetCallingAssembly (); + return GetAddinForAssembly (asm); + } + } + + /// + /// Gets the add-in registry bound to this add-in engine + /// + public AddinRegistry Registry { + get { + CheckInitialized (); + return registry; + } + } + + internal RuntimeAddin GetAddinForAssembly (Assembly asm) + { + return (RuntimeAddin) loadedAssemblies [asm]; + } + + /// + /// Checks if the provided add-ins are installed, and requests the installation of those + /// which aren't. + /// + /// + /// Message to show to the user when new add-ins have to be installed. + /// + /// + /// List of IDs of the add-ins to be checked. + /// + /// + /// This method checks if the specified add-ins are installed. + /// If some of the add-ins are not installed, it will use + /// the installer assigned to the DefaultAddinInstaller property + /// to install them. If the installation fails, or if DefaultAddinInstaller + /// is not set, an exception will be thrown. + /// + public void CheckInstalled (string message, params string[] addinIds) + { + ArrayList notInstalled = new ArrayList (); + foreach (string id in addinIds) { + Addin addin = Registry.GetAddin (id, false); + if (addin != null) { + // The add-in is already installed + // If the add-in is disabled, enable it now + if (!addin.Enabled) + addin.Enabled = true; + } else { + notInstalled.Add (id); + } + } + if (notInstalled.Count == 0) + return; + if (installer == null) + throw new InvalidOperationException ("Add-in installer not set"); + + // Install the add-ins + installer.InstallAddins (Registry, message, (string[]) notInstalled.ToArray (typeof(string))); + } + + // Enables or disables conflict checking while loading assemblies. + // Disabling makes loading faster, but less safe. + internal bool CheckAssemblyLoadConflicts { + get { return checkAssemblyLoadConflicts; } + set { checkAssemblyLoadConflicts = value; } + } + + /// + /// Checks if an add-in has been loaded. + /// + /// + /// Full identifier of the add-in. + /// + /// + /// True if the add-in is loaded. + /// + public bool IsAddinLoaded (string id) + { + CheckInitialized (); + return loadedAddins.Contains (Addin.GetIdName (id)); + } + + internal RuntimeAddin GetAddin (string id) + { + return (RuntimeAddin) loadedAddins [Addin.GetIdName (id)]; + } + + internal void ActivateAddin (string id) + { + ActivateAddinExtensions (id); + } + + internal void UnloadAddin (string id) + { + RemoveAddinExtensions (id); + + RuntimeAddin addin = GetAddin (id); + if (addin != null) { + addin.UnloadExtensions (); + loadedAddins.Remove (Addin.GetIdName (id)); + if (addin.AssembliesLoaded) { + foreach (Assembly asm in addin.Assemblies) + loadedAssemblies.Remove (asm); + } + ReportAddinUnload (id); + } + } + + /// + /// Forces the loading of an add-in. + /// + /// + /// Status monitor to keep track of the loading process. + /// + /// + /// Full identifier of the add-in to load. + /// + /// + /// This method loads all assemblies that belong to an add-in in memory. + /// All add-ins on which the specified add-in depends will also be loaded. + /// Notice that in general add-ins don't need to be explicitely loaded using + /// this method, since the add-in engine will load them on demand. + /// + public void LoadAddin (IProgressStatus statusMonitor, string id) + { + CheckInitialized (); + LoadAddin (statusMonitor, id, true); + } + + internal bool LoadAddin (IProgressStatus statusMonitor, string id, bool throwExceptions) + { + try { + if (IsAddinLoaded (id)) + return true; + + if (!Registry.IsAddinEnabled (id)) { + string msg = GettextCatalog.GetString ("Disabled add-ins can't be loaded."); + ReportError (msg, id, null, false); + if (throwExceptions) + throw new InvalidOperationException (msg); + return false; + } + + ArrayList addins = new ArrayList (); + Stack depCheck = new Stack (); + ResolveLoadDependencies (addins, depCheck, id, false); + addins.Reverse (); + + if (statusMonitor != null) + statusMonitor.SetMessage ("Loading Addins"); + + for (int n=0; n 0) { + Type ntype = addin.GetType (nt.ObjectTypeName, true); + RegisterAutoTypeExtensionPoint (ntype, ep.Path); + } + } + } + + bool ResolveLoadDependencies (ArrayList addins, Stack depCheck, string id, bool optional) + { + if (IsAddinLoaded (id)) + return true; + + if (depCheck.Contains (id)) + throw new InvalidOperationException ("A cyclic addin dependency has been detected."); + + depCheck.Push (id); + + Addin iad = Registry.GetAddin (id); + if (iad == null || !iad.Enabled) { + if (optional) + return false; + else if (iad != null && !iad.Enabled) + throw new MissingDependencyException (GettextCatalog.GetString ("The required addin '{0}' is disabled.", id)); + else + throw new MissingDependencyException (GettextCatalog.GetString ("The required addin '{0}' is not installed.", id)); + } + + // If this addin has already been requested, bring it to the head + // of the list, so it is loaded earlier than before. + addins.Remove (iad); + addins.Add (iad); + + foreach (Dependency dep in iad.AddinInfo.Dependencies) { + AddinDependency adep = dep as AddinDependency; + if (adep != null) { + try { + string adepid = Addin.GetFullId (iad.AddinInfo.Namespace, adep.AddinId, adep.Version); + ResolveLoadDependencies (addins, depCheck, adepid, false); + } catch (MissingDependencyException) { + if (optional) + return false; + else + throw; + } + } + } + + if (iad.AddinInfo.OptionalDependencies != null) { + foreach (Dependency dep in iad.AddinInfo.OptionalDependencies) { + AddinDependency adep = dep as AddinDependency; + if (adep != null) { + string adepid = Addin.GetFullId (iad.Namespace, adep.AddinId, adep.Version); + if (!ResolveLoadDependencies (addins, depCheck, adepid, true)) + return false; + } + } + } + + depCheck.Pop (); + return true; + } + + internal void RegisterNodeSet (string addinId, ExtensionNodeSet nset) + { + nset.SourceAddinId = addinId; + nodeSets [nset.Id] = nset; + } + + internal void UnregisterAddinNodeSets (string addinId) + { + foreach (var nset in nodeSets.Values.Where (n => n.SourceAddinId == addinId).ToArray ()) + nodeSets.Remove (nset.Id); + } + + internal string GetNodeTypeAddin (ExtensionNodeSet nset, string type, string callingAddinId) + { + ExtensionNodeType nt = FindType (nset, type, callingAddinId); + if (nt != null) + return nt.AddinId; + else + return null; + } + + internal ExtensionNodeType FindType (ExtensionNodeSet nset, string name, string callingAddinId) + { + if (nset == null) + return null; + + foreach (ExtensionNodeType nt in nset.NodeTypes) { + if (nt.Id == name) + return nt; + } + + foreach (string ns in nset.NodeSets) { + ExtensionNodeSet regSet; + if (!nodeSets.TryGetValue (ns, out regSet)) { + ReportError ("Unknown node set: " + ns, callingAddinId, null, false); + return null; + } + ExtensionNodeType nt = FindType (regSet, name, callingAddinId); + if (nt != null) + return nt; + } + return null; + } + + internal void RegisterAutoTypeExtensionPoint (Type type, string path) + { + autoExtensionTypes [type] = path; + } + + internal void UnregisterAutoTypeExtensionPoint (Type type, string path) + { + autoExtensionTypes.Remove (type); + } + + internal string GetAutoTypeExtensionPoint (Type type) + { + return autoExtensionTypes [type] as string; + } + + void OnAssemblyLoaded (object s, AssemblyLoadEventArgs a) + { + if (a != null) + CheckHostAssembly (a.LoadedAssembly); + } + + internal void ActivateRoots () + { + foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies ()) + CheckHostAssembly (asm); + } + + void CheckHostAssembly (Assembly asm) + { + if (AddinDatabase.RunningSetupProcess || asm is System.Reflection.Emit.AssemblyBuilder) + return; + Uri u; + if (!Uri.TryCreate (asm.CodeBase, UriKind.Absolute, out u)) + return; + string asmFile = u.LocalPath; + Addin ainfo = Registry.GetAddinForHostAssembly (asmFile); + if (ainfo != null && !IsAddinLoaded (ainfo.Id)) { + AddinDescription adesc = null; + try { + adesc = ainfo.Description; + } catch (Exception ex) { + defaultProgressStatus.ReportError ("Add-in description could not be loaded.", ex); + } + if (adesc == null || adesc.FilesChanged ()) { + // If the add-in has changed, update the add-in database. + // We do it here because once loaded, add-in roots can't be + // reloaded like regular add-ins. + Registry.Update (null); + ainfo = Registry.GetAddinForHostAssembly (asmFile); + if (ainfo == null) + return; + } + LoadAddin (null, ainfo.Id, false); + } + } + + /// + /// Creates a new extension context. + /// + /// + /// The new extension context. + /// + /// + /// Extension contexts can be used to query the extension model using particular condition values. + /// + public ExtensionContext CreateExtensionContext () + { + CheckInitialized (); + return CreateChildContext (); + } + + internal void CheckInitialized () + { + if (!initialized) + throw new InvalidOperationException ("Add-in engine not initialized."); + } + + internal void ReportError (string message, string addinId, Exception exception, bool fatal) + { + if (AddinLoadError != null) + AddinLoadError (null, new AddinErrorEventArgs (message, addinId, exception)); + else { + Console.WriteLine (message); + if (exception != null) + Console.WriteLine (exception); + } + } + + internal void ReportAddinLoad (string id) + { + if (AddinLoaded != null) { + try { + AddinLoaded (null, new AddinEventArgs (id)); + } catch { + // Ignore subscriber exceptions + } + } + } + + internal void ReportAddinUnload (string id) + { + if (AddinUnloaded != null) { + try { + AddinUnloaded (null, new AddinEventArgs (id)); + } catch { + // Ignore subscriber exceptions + } + } + } + } + +} diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/AddinErrorEventArgs.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinErrorEventArgs.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/AddinErrorEventArgs.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinErrorEventArgs.cs 2011-04-13 09:00:29.000000000 +0000 @@ -31,23 +31,47 @@ namespace Mono.Addins { + /// + /// Delegate to be used in add-in error subscriptions + /// public delegate void AddinErrorEventHandler (object sender, AddinErrorEventArgs args); + /// + /// Provides information about an add-in loading error. + /// public class AddinErrorEventArgs: AddinEventArgs { Exception exception; string message; - + + /// + /// Initializes a new instance of the class. + /// + /// + /// Error message + /// + /// + /// Add-in identifier. + /// + /// + /// Exception that caused the error. + /// public AddinErrorEventArgs (string message, string addinId, Exception exception): base (addinId) { this.message = message; this.exception = exception; } + /// + /// Exception that caused the error. + /// public Exception Exception { get { return exception; } } + /// + /// Error message + /// public string Message { get { return message; } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/AddinEventArgs.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinEventArgs.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/AddinEventArgs.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinEventArgs.cs 2011-04-13 09:00:29.000000000 +0000 @@ -31,17 +31,32 @@ namespace Mono.Addins { + /// + /// Delegate to be used in add-in engine events + /// public delegate void AddinEventHandler (object sender, AddinEventArgs args); + /// + /// Provides information about an add-in engine event. + /// public class AddinEventArgs: EventArgs { string addinId; - + + /// + /// Initializes a new instance of the class. + /// + /// + /// Add-in identifier. + /// public AddinEventArgs (string addinId) { this.addinId = addinId; } + /// + /// Identifier of the add-in that generated the event. + /// public string AddinId { get { return addinId; } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/AddinInfo.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinInfo.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/AddinInfo.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinInfo.cs 2011-04-13 09:00:29.000000000 +0000 @@ -51,8 +51,9 @@ bool isroot; DependencyCollection dependencies; DependencyCollection optionalDependencies; + AddinPropertyCollection properties; - public AddinInfo () + private AddinInfo () { dependencies = new DependencyCollection (); optionalDependencies = new DependencyCollection (); @@ -62,7 +63,6 @@ get { return Addin.GetFullId (namspace, id, version); } } - [XmlElement ("Id")] public string LocalId { get { return id; } set { id = value; } @@ -80,6 +80,9 @@ public string Name { get { + string s = Properties.GetPropertyValue ("Name"); + if (s.Length > 0) + return s; if (name != null && name.Length > 0) return name; string sid = id; @@ -101,27 +104,52 @@ } public string Author { - get { return author; } + get { + string s = Properties.GetPropertyValue ("Author"); + if (s.Length > 0) + return s; + return author; + } set { author = value; } } public string Copyright { - get { return copyright; } + get { + string s = Properties.GetPropertyValue ("Copyright"); + if (s.Length > 0) + return s; + return copyright; + } set { copyright = value; } } public string Url { - get { return url; } + get { + string s = Properties.GetPropertyValue ("Url"); + if (s.Length > 0) + return s; + return url; + } set { url = value; } } public string Description { - get { return description; } + get { + string s = Properties.GetPropertyValue ("Description"); + if (s.Length > 0) + return s; + return description; + } set { description = value; } } public string Category { - get { return category; } + get { + string s = Properties.GetPropertyValue ("Category"); + if (s.Length > 0) + return s; + return category; + } set { category = value; } } @@ -130,69 +158,16 @@ set { defaultEnabled = value; } } - [XmlArrayItem ("AddinDependency", typeof(AddinDependency))] - [XmlArrayItem ("AssemblyDependency", typeof(AssemblyDependency))] public DependencyCollection Dependencies { get { return dependencies; } } - [XmlArrayItem ("AddinDependency", typeof(AddinDependency))] - [XmlArrayItem ("AssemblyDependency", typeof(AssemblyDependency))] public DependencyCollection OptionalDependencies { get { return optionalDependencies; } } - public static AddinInfo ReadFromAddinFile (StreamReader r) - { - XmlDocument doc = new XmlDocument (); - doc.Load (r); - r.Close (); - - AddinInfo info = new AddinInfo (); - info.id = doc.DocumentElement.GetAttribute ("id"); - info.namspace = doc.DocumentElement.GetAttribute ("namespace"); - info.name = doc.DocumentElement.GetAttribute ("name"); - if (info.id == "") info.id = info.name; - info.version = doc.DocumentElement.GetAttribute ("version"); - info.author = doc.DocumentElement.GetAttribute ("author"); - info.copyright = doc.DocumentElement.GetAttribute ("copyright"); - info.url = doc.DocumentElement.GetAttribute ("url"); - info.description = doc.DocumentElement.GetAttribute ("description"); - info.category = doc.DocumentElement.GetAttribute ("category"); - info.baseVersion = doc.DocumentElement.GetAttribute ("compatVersion"); - - string s = doc.DocumentElement.GetAttribute ("defaultEnabled"); - info.defaultEnabled = s.Length == 0 || s == "true" || s == "yes"; - - s = doc.DocumentElement.GetAttribute ("isRoot"); - if (s.Length == 0) s = doc.DocumentElement.GetAttribute ("isroot"); - info.isroot = s == "true" || s == "yes"; - - ReadDependencies (info.Dependencies, info.OptionalDependencies, doc.DocumentElement); - - return info; - } - - static void ReadDependencies (DependencyCollection deps, DependencyCollection opDeps, XmlElement elem) - { - foreach (XmlElement dep in elem.SelectNodes ("Dependencies/Addin")) { - AddinDependency adep = new AddinDependency (); - adep.AddinId = dep.GetAttribute ("id"); - string v = dep.GetAttribute ("version"); - if (v.Length != 0) - adep.Version = v; - deps.Add (adep); - } - - foreach (XmlElement dep in elem.SelectNodes ("Dependencies/Assembly")) { - AssemblyDependency adep = new AssemblyDependency (); - adep.FullName = dep.GetAttribute ("name"); - adep.Package = dep.GetAttribute ("package"); - deps.Add (adep); - } - - foreach (XmlElement mod in elem.SelectNodes ("Module")) - ReadDependencies (opDeps, opDeps, mod); + public AddinPropertyCollection Properties { + get { return properties; } } internal static AddinInfo ReadFromDescription (AddinDescription description) @@ -218,6 +193,8 @@ foreach (Dependency dep in mod.Dependencies) info.OptionalDependencies.Add (dep); } + info.properties = description.Properties; + return info; } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/AddinLocalizer.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinLocalizer.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/AddinLocalizer.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinLocalizer.cs 2011-04-13 09:00:29.000000000 +0000 @@ -31,6 +31,9 @@ namespace Mono.Addins { + /// + /// Converts message identifiers to localized messages. + /// public class AddinLocalizer { IAddinLocalizer localizer; @@ -41,22 +44,70 @@ this.localizer = localizer; pluralLocalizer = localizer as IPluralAddinLocalizer; } - + + /// + /// Gets a localized message + /// + /// + /// Message identifier + /// + /// + /// The localized message + /// public string GetString (string msgid) { return localizer.GetString (msgid); } + /// + /// Gets a formatted and localized message + /// + /// + /// Message identifier (can contain string format placeholders) + /// + /// + /// Arguments for the string format operation + /// + /// + /// The formatted and localized string + /// public string GetString (string msgid, params string[] args) { return string.Format (localizer.GetString (msgid), args); } + /// + /// Gets a formatted and localized message + /// + /// + /// Message identifier (can contain string format placeholders) + /// + /// + /// Arguments for the string format operation + /// + /// + /// The formatted and localized string + /// public string GetString (string msgid, params object[] args) { return string.Format (localizer.GetString (msgid), args); } - + + /// + /// Gets a localized plural form for a message identifier + /// + /// + /// Message identifier for the singular form + /// + /// + /// Default result message for the plural form + /// + /// + /// Value count. Determines wether to use singular or plural form. + /// + /// + /// The localized message + /// public string GetPluralString (string msgid, string defaultPlural, int n) { // If the localizer does not support plural forms, just use GetString to @@ -69,11 +120,47 @@ return GetString (msgid); } + /// + /// Gets a localized and formatted plural form for a message identifier + /// + /// + /// Message identifier for the singular form (can contain string format placeholders) + /// + /// + /// Default result message for the plural form (can contain string format placeholders) + /// + /// + /// Value count. Determines whether to use singular or plural form. + /// + /// + /// Arguments for the string format operation + /// + /// + /// The localized message + /// public string GetPluralString (string singular, string defaultPlural, int n, params string[] args) { return string.Format (GetPluralString (singular, defaultPlural, n), args); } + /// + /// Gets a localized and formatted plural form for a message identifier + /// + /// + /// Message identifier for the singular form (can contain string format placeholders) + /// + /// + /// Default result message for the plural form (can contain string format placeholders) + /// + /// + /// Value count. Determines whether to use singular or plural form. + /// + /// + /// Arguments for the string format operation + /// + /// + /// The localized message + /// public string GetPluralString (string singular, string defaultPlural, int n, params object[] args) { return string.Format (GetPluralString (singular, defaultPlural, n), args); diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/AddinLocalizerGettextAttribute.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinLocalizerGettextAttribute.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/AddinLocalizerGettextAttribute.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinLocalizerGettextAttribute.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,109 @@ +// +// AddinLocalizerAttribute.cs +// +// Author: +// Lluis Sanchez Gual +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; + +namespace Mono.Addins +{ + /// + /// Declares a Gettext-based localizer for an add-in + /// + [AttributeUsage (AttributeTargets.Assembly)] + public class AddinLocalizerGettextAttribute: Attribute + { + string catalog; + string location; + + /// + /// Initializes a new instance of the class. + /// + public AddinLocalizerGettextAttribute () + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Name of the catalog which contains the strings. + /// + public AddinLocalizerGettextAttribute (string catalog) + { + this.catalog = catalog; + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Name of the catalog which contains the strings. + /// + /// + /// Relative path to the location of the catalog. This path must be relative to the add-in location. + /// + /// + /// The location path must contain a directory structure like this: + /// + /// {language-id}/LC_MESSAGES/{Catalog}.mo + /// + /// For example, the catalog for spanish strings would be located at: + /// + /// locale/es/LC_MESSAGES/some-addin.mo + /// + public AddinLocalizerGettextAttribute (string catalog, string location) + { + this.catalog = catalog; + this.location = location; + } + + /// + /// Name of the catalog which contains the strings. + /// + public string Catalog { + get { return this.catalog; } + set { this.catalog = value; } + } + + /// + /// Relative path to the location of the catalog. This path must be relative to the add-in location. + /// + /// + /// When not specified, the default value of this property is 'locale'. + /// The location path must contain a directory structure like this: + /// + /// {language-id}/LC_MESSAGES/{Catalog}.mo + /// + /// For example, the catalog for spanish strings would be located at: + /// + /// locale/es/LC_MESSAGES/some-addin.mo + /// + public string Location { + get { return this.location; } + set { this.location = value; } + } + } +} + diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/AddinManager.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinManager.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/AddinManager.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinManager.cs 2011-04-13 09:00:29.000000000 +0000 @@ -30,284 +30,810 @@ using System.IO; using System.Reflection; using System.Collections; +using System.Collections.Generic; using Mono.Addins.Localization; namespace Mono.Addins { + /// + /// Provides access to add-in and extension model management operations. + /// public class AddinManager { - static AddinSessionService sessionService; - static AddinRegistry registry; - - static string startupDirectory; - static bool initialized; - static IAddinInstaller installer; - - public static event AddinErrorEventHandler AddinLoadError; - public static event AddinEventHandler AddinLoaded; - public static event AddinEventHandler AddinUnloaded; + static AddinEngine sessionService; private AddinManager () { } + /// + /// Initializes the add-in engine. + /// + /// + /// The add-in engine needs to be initialized before doing any add-in operation. + /// When initialized with this method, it will look for add-ins in the global add-in registry. + /// public static void Initialize () { - Initialize (null); + // Code not shared with the other Initialize since I need to get the calling assembly + Assembly asm = Assembly.GetEntryAssembly (); + if (asm == null) asm = Assembly.GetCallingAssembly (); + AddinEngine.Initialize (asm, null, null, null); } + /// + /// Initializes the add-in engine. + /// + /// + /// Location of the add-in registry. + /// + /// + /// The add-in engine needs to be initialized before doing any add-in operation. + /// Configuration information about the add-in registry will be stored in the + /// provided location. The add-in engine will look for add-ins in an 'addins' + /// subdirectory of the provided directory. + /// + /// When specifying a path, it is possible to use a special folder name as root. + /// For example: [Personal]/.config/MyApp. In this case, [Personal] will be replaced + /// by the location of the Environment.SpecialFolder.Personal folder. Any value + /// of the Environment.SpecialFolder enumeration can be used (always between square + /// brackets) + /// public static void Initialize (string configDir) { - if (initialized) - return; - Assembly asm = Assembly.GetEntryAssembly (); if (asm == null) asm = Assembly.GetCallingAssembly (); - string asmFile = new Uri (asm.CodeBase).LocalPath; - - startupDirectory = Path.GetDirectoryName (asmFile); - - string customDir = Environment.GetEnvironmentVariable ("MONO_ADDINS_REGISTRY"); - if (customDir != null && customDir.Length > 0) - configDir = customDir; - - if (configDir == null || configDir.Length == 0) - registry = AddinRegistry.GetGlobalRegistry (startupDirectory); - else - registry = new AddinRegistry (configDir, startupDirectory); - - if (registry.CreateHostAddinsFile (asmFile)) - registry.Update (new ConsoleProgressStatus (false)); - - initialized = true; - - SessionService.Initialize (); + AddinEngine.Initialize (asm, configDir, null, null); } + /// + /// Initializes the add-in engine. + /// + /// + /// Location of the add-in registry. + /// + /// + /// Add-ins directory. If the path is relative, it is considered to be relative + /// to the configDir directory. + /// + /// + /// The add-in engine needs to be initialized before doing any add-in operation. + /// Configuration information about the add-in registry will be stored in the + /// provided location. The add-in engine will look for add-ins in the provided + /// 'addinsDir' directory. + /// + /// When specifying a path, it is possible to use a special folder name as root. + /// For example: [Personal]/.config/MyApp. In this case, [Personal] will be replaced + /// by the location of the Environment.SpecialFolder.Personal folder. Any value + /// of the Environment.SpecialFolder enumeration can be used (always between square + /// brackets) + /// + public static void Initialize (string configDir, string addinsDir) + { + Assembly asm = Assembly.GetEntryAssembly (); + if (asm == null) asm = Assembly.GetCallingAssembly (); + AddinEngine.Initialize (asm, configDir, addinsDir, null); + } + + /// + /// Initializes the add-in engine. + /// + /// + /// Location of the add-in registry. + /// + /// + /// Add-ins directory. If the path is relative, it is considered to be relative + /// to the configDir directory. + /// + /// + /// Location of the add-in database. If the path is relative, it is considered to be relative + /// to the configDir directory. + /// + /// + /// The add-in engine needs to be initialized before doing any add-in operation. + /// Configuration information about the add-in registry will be stored in the + /// provided location. The add-in engine will look for add-ins in the provided + /// 'addinsDir' directory. Cached information about add-ins will be stored in + /// the 'databaseDir' directory. + /// + /// When specifying a path, it is possible to use a special folder name as root. + /// For example: [Personal]/.config/MyApp. In this case, [Personal] will be replaced + /// by the location of the Environment.SpecialFolder.Personal folder. Any value + /// of the Environment.SpecialFolder enumeration can be used (always between square + /// brackets) + /// + public static void Initialize (string configDir, string addinsDir, string databaseDir) + { + Assembly asm = Assembly.GetEntryAssembly (); + if (asm == null) asm = Assembly.GetCallingAssembly (); + AddinEngine.Initialize (asm, configDir, addinsDir, databaseDir); + } + + /// + /// Finalizes an add-in engine. + /// public static void Shutdown () { - SessionService.Shutdown (); - registry.Dispose (); - registry = null; - startupDirectory = null; - initialized = false; + AddinEngine.Shutdown (); } + /// + /// Sets the default localizer to be used for this add-in engine + /// + /// + /// The add-in localizer + /// public static void InitializeDefaultLocalizer (IAddinLocalizer localizer) { - CheckInitialized (); - SessionService.InitializeDefaultLocalizer (localizer); + AddinEngine.InitializeDefaultLocalizer (localizer); } internal static string StartupDirectory { - get { return startupDirectory; } + get { return AddinEngine.StartupDirectory; } } + /// + /// Gets whether the add-in engine has been initialized. + /// public static bool IsInitialized { - get { return initialized; } + get { return AddinEngine.IsInitialized; } } + /// + /// Gets the default add-in installer + /// + /// + /// The default installer is used by the CheckInstalled method to request + /// the installation of missing add-ins. + /// public static IAddinInstaller DefaultInstaller { - get { return installer; } - set { installer = value; } + get { return AddinEngine.DefaultInstaller; } + set { AddinEngine.DefaultInstaller = value; } } + /// + /// Gets the default localizer for this add-in engine + /// public static AddinLocalizer DefaultLocalizer { get { - CheckInitialized (); - return SessionService.DefaultLocalizer; + return AddinEngine.DefaultLocalizer; } } + /// + /// Gets the localizer for the add-in that is invoking this property + /// public static AddinLocalizer CurrentLocalizer { get { - CheckInitialized (); - RuntimeAddin addin = SessionService.GetAddinForAssembly (Assembly.GetCallingAssembly ()); + AddinEngine.CheckInitialized (); + RuntimeAddin addin = AddinEngine.GetAddinForAssembly (Assembly.GetCallingAssembly ()); if (addin != null) return addin.Localizer; else - return SessionService.DefaultLocalizer; + return AddinEngine.DefaultLocalizer; } } + /// + /// Gets a reference to the RuntimeAddin object for the add-in that is invoking this property + /// public static RuntimeAddin CurrentAddin { get { - CheckInitialized (); - return SessionService.GetAddinForAssembly (Assembly.GetCallingAssembly ()); + AddinEngine.CheckInitialized (); + return AddinEngine.GetAddinForAssembly (Assembly.GetCallingAssembly ()); } } - internal static AddinSessionService SessionService { + /// + /// Gets the default add-in engine + /// + public static AddinEngine AddinEngine { get { if (sessionService == null) - sessionService = new AddinSessionService(); + sessionService = new AddinEngine(); return sessionService; } } + /// + /// Gets the add-in registry bound to the default add-in engine + /// public static AddinRegistry Registry { get { - CheckInitialized (); - return registry; + return AddinEngine.Registry; } } - // This method checks if the specified add-ins are installed. - // If some of the add-ins are not installed, it will use - // the installer assigned to the DefaultAddinInstaller property - // to install them. If the installation fails, or if DefaultAddinInstaller - // is not set, an exception will be thrown. + /// + /// Checks if the provided add-ins are installed, and requests the installation of those + /// which aren't. + /// + /// + /// Message to show to the user when new add-ins have to be installed. + /// + /// + /// List of IDs of the add-ins to be checked. + /// + /// + /// This method checks if the specified add-ins are installed. + /// If some of the add-ins are not installed, it will use + /// the installer assigned to the DefaultAddinInstaller property + /// to install them. If the installation fails, or if DefaultAddinInstaller + /// is not set, an exception will be thrown. + /// public static void CheckInstalled (string message, params string[] addinIds) { - ArrayList notInstalled = new ArrayList (); - foreach (string id in addinIds) { - Addin addin = Registry.GetAddin (id, false); - if (addin != null) { - // The add-in is already installed - // If the add-in is disabled, enable it now - if (!addin.Enabled) - addin.Enabled = true; - } else { - notInstalled.Add (id); - } - } - if (notInstalled.Count == 0) - return; - if (installer == null) - throw new InvalidOperationException ("Add-in installer not set"); - - // Install the add-ins - installer.InstallAddins (Registry, message, (string[]) notInstalled.ToArray (typeof(string))); + AddinEngine.CheckInstalled (message, addinIds); } + /// + /// Checks if an add-in has been loaded. + /// + /// + /// Full identifier of the add-in. + /// + /// + /// True if the add-in is loaded. + /// public static bool IsAddinLoaded (string id) { - CheckInitialized (); - return SessionService.IsAddinLoaded (id); + return AddinEngine.IsAddinLoaded (id); } + /// + /// Forces the loading of an add-in. + /// + /// + /// Status monitor to keep track of the loading process. + /// + /// + /// Full identifier of the add-in to load. + /// + /// + /// This method loads all assemblies that belong to an add-in in memory. + /// All add-ins on which the specified add-in depends will also be loaded. + /// Notice that in general add-ins don't need to be explicitely loaded using + /// this method, since the add-in engine will load them on demand. + /// public static void LoadAddin (IProgressStatus statusMonitor, string id) { - CheckInitialized (); - SessionService.LoadAddin (statusMonitor, id, true); + AddinEngine.LoadAddin (statusMonitor, id); } + /// + /// Creates a new extension context. + /// + /// + /// The new extension context. + /// + /// + /// Extension contexts can be used to query the extension model using particular condition values. + /// public static ExtensionContext CreateExtensionContext () { - CheckInitialized (); - return SessionService.DefaultContext.CreateChildContext (); + return AddinEngine.CreateExtensionContext (); } + /// + /// Returns the extension node in a path + /// + /// + /// Location of the node. + /// + /// + /// The node, or null if not found. + /// public static ExtensionNode GetExtensionNode (string path) { - CheckInitialized (); - return SessionService.DefaultContext.GetExtensionNode (path); + AddinEngine.CheckInitialized (); + return AddinEngine.GetExtensionNode (path); } + /// + /// Returns the extension node in a path + /// + /// + /// Location of the node. + /// + /// + /// The node, or null if not found. + /// + public static T GetExtensionNode (string path) where T:ExtensionNode + { + AddinEngine.CheckInitialized (); + return AddinEngine.GetExtensionNode (path); + } + + /// + /// Gets extension nodes registered in a path. + /// + /// + /// An extension path.> + /// + /// + /// All nodes registered in the provided path. + /// public static ExtensionNodeList GetExtensionNodes (string path) { - CheckInitialized (); - return SessionService.DefaultContext.GetExtensionNodes (path); + AddinEngine.CheckInitialized (); + return AddinEngine.GetExtensionNodes (path); } - public static ExtensionNodeList GetExtensionNodes (string path, Type type) + /// + /// Gets extension nodes registered in a path. + /// + /// + /// An extension path. + /// + /// + /// Expected node type. + /// + /// + /// A list of nodes + /// + /// + /// This method returns all nodes registered under the provided path. + /// It will throw a InvalidOperationException if the type of one of + /// the registered nodes is not assignable to the provided type. + /// + public static ExtensionNodeList GetExtensionNodes (string path, Type expectedNodeType) + { + AddinEngine.CheckInitialized (); + return AddinEngine.GetExtensionNodes (path, expectedNodeType); + } + + /// + /// Gets extension nodes registered in a path. + /// + /// + /// An extension path. + /// + /// + /// A list of nodes + /// + /// + /// This method returns all nodes registered under the provided path. + /// It will throw a InvalidOperationException if the type of one of + /// the registered nodes is not assignable to the provided type. + /// + public static ExtensionNodeList GetExtensionNodes (string path) where T:ExtensionNode { - CheckInitialized (); - return SessionService.DefaultContext.GetExtensionNodes (path, type); + AddinEngine.CheckInitialized (); + return AddinEngine.GetExtensionNodes (path); } - + + /// + /// Gets extension nodes for a type extension point + /// + /// + /// Type defining the extension point + /// + /// + /// A list of nodes + /// + /// + /// This method returns all extension nodes bound to the provided type. + /// + public static ExtensionNodeList GetExtensionNodes (Type instanceType) + { + AddinEngine.CheckInitialized (); + return AddinEngine.GetExtensionNodes (instanceType); + } + + /// + /// Gets extension nodes for a type extension point + /// + /// + /// Type defining the extension point + /// + /// + /// Expected extension node type + /// + /// + /// A list of nodes + /// + /// + /// This method returns all nodes registered for the provided type. + /// It will throw a InvalidOperationException if the type of one of + /// the registered nodes is not assignable to the provided node type. + /// + public static ExtensionNodeList GetExtensionNodes (Type instanceType, Type expectedNodeType) + { + AddinEngine.CheckInitialized (); + return AddinEngine.GetExtensionNodes (instanceType, expectedNodeType); + } + + /// + /// Gets extension nodes for a type extension point + /// + /// + /// Type defining the extension point + /// + /// + /// A list of nodes + /// + /// + /// This method returns all nodes registered for the provided type. + /// It will throw a InvalidOperationException if the type of one of + /// the registered nodes is not assignable to the specified node type argument. + /// + public static ExtensionNodeList GetExtensionNodes (Type instanceType) where T: ExtensionNode + { + AddinEngine.CheckInitialized (); + return AddinEngine.GetExtensionNodes (instanceType); + } + + /// + /// Gets extension objects registered for a type extension point. + /// + /// + /// Type defining the extension point + /// + /// + /// A list of objects + /// public static object[] GetExtensionObjects (Type instanceType) { - CheckInitialized (); - return SessionService.DefaultContext.GetExtensionObjects (instanceType); + AddinEngine.CheckInitialized (); + return AddinEngine.GetExtensionObjects (instanceType); } + /// + /// Gets extension objects registered for a type extension point. + /// + /// + /// A list of objects + /// + /// + /// The type argument of this generic method is the type that defines + /// the extension point. + /// + public static T[] GetExtensionObjects () + { + AddinEngine.CheckInitialized (); + return AddinEngine.GetExtensionObjects (); + } + + /// + /// Gets extension objects registered for a type extension point. + /// + /// + /// Type defining the extension point + /// + /// + /// When set to True, it will return instances created in previous calls. + /// + /// + /// A list of extension objects. + /// public static object[] GetExtensionObjects (Type instanceType, bool reuseCachedInstance) { - CheckInitialized (); - return SessionService.DefaultContext.GetExtensionObjects (instanceType, reuseCachedInstance); + AddinEngine.CheckInitialized (); + return AddinEngine.GetExtensionObjects (instanceType, reuseCachedInstance); } + /// + /// Gets extension objects registered for a type extension point. + /// + /// + /// When set to True, it will return instances created in previous calls. + /// + /// + /// A list of extension objects. + /// + /// + /// The type argument of this generic method is the type that defines + /// the extension point. + /// + public static T[] GetExtensionObjects (bool reuseCachedInstance) + { + AddinEngine.CheckInitialized (); + return AddinEngine.GetExtensionObjects (reuseCachedInstance); + } + + /// + /// Gets extension objects registered in a path + /// + /// + /// An extension path. + /// + /// + /// An array of objects registered in the path. + /// + /// + /// This method can only be used if all nodes in the provided extension path + /// are of type Mono.Addins.TypeExtensionNode. The returned array is composed + /// by all objects created by calling the TypeExtensionNode.CreateInstance() + /// method for each node. + /// public static object[] GetExtensionObjects (string path) { - CheckInitialized (); - return SessionService.DefaultContext.GetExtensionObjects (path); + AddinEngine.CheckInitialized (); + return AddinEngine.GetExtensionObjects (path); } + /// + /// Gets extension objects registered in a path. + /// + /// + /// An extension path. + /// + /// + /// When set to True, it will return instances created in previous calls. + /// + /// + /// An array of objects registered in the path. + /// + /// + /// This method can only be used if all nodes in the provided extension path + /// are of type Mono.Addins.TypeExtensionNode. The returned array is composed + /// by all objects created by calling the TypeExtensionNode.CreateInstance() + /// method for each node (or TypeExtensionNode.GetInstance() if + /// reuseCachedInstance is set to true) + /// public static object[] GetExtensionObjects (string path, bool reuseCachedInstance) { - CheckInitialized (); - return SessionService.DefaultContext.GetExtensionObjects (path, reuseCachedInstance); + AddinEngine.CheckInitialized (); + return AddinEngine.GetExtensionObjects (path, reuseCachedInstance); } + /// + /// Gets extension objects registered in a path. + /// + /// + /// An extension path. + /// + /// + /// Type of the return array elements. + /// + /// + /// An array of objects registered in the path. + /// + /// + /// This method can only be used if all nodes in the provided extension path + /// are of type Mono.Addins.TypeExtensionNode. The returned array is composed + /// by all objects created by calling the TypeExtensionNode.CreateInstance() + /// method for each node. + /// + /// An InvalidOperationException exception is thrown if one of the found + /// objects is not a subclass of the provided type. + /// public static object[] GetExtensionObjects (string path, Type arrayElementType) { - CheckInitialized (); - return SessionService.DefaultContext.GetExtensionObjects (path, arrayElementType); + AddinEngine.CheckInitialized (); + return AddinEngine.GetExtensionObjects (path, arrayElementType); } + /// + /// Gets extension objects registered in a path. + /// + /// + /// An extension path. + /// + /// + /// An array of objects registered in the path. + /// + /// + /// This method can only be used if all nodes in the provided extension path + /// are of type Mono.Addins.TypeExtensionNode. The returned array is composed + /// by all objects created by calling the TypeExtensionNode.CreateInstance() + /// method for each node. + /// + /// An InvalidOperationException exception is thrown if one of the found + /// objects is not a subclass of the provided type. + /// + public static T[] GetExtensionObjects (string path) + { + AddinEngine.CheckInitialized (); + return AddinEngine.GetExtensionObjects (path); + } + + /// + /// Gets extension objects registered in a path. + /// + /// + /// An extension path. + /// + /// + /// Type of the return array elements. + /// + /// + /// When set to True, it will return instances created in previous calls. + /// + /// + /// An array of objects registered in the path. + /// + /// + /// This method can only be used if all nodes in the provided extension path + /// are of type Mono.Addins.TypeExtensionNode. The returned array is composed + /// by all objects created by calling the TypeExtensionNode.CreateInstance() + /// method for each node (or TypeExtensionNode.GetInstance() if + /// reuseCachedInstance is set to true). + /// + /// An InvalidOperationException exception is thrown if one of the found + /// objects is not a subclass of the provided type. + /// public static object[] GetExtensionObjects (string path, Type arrayElementType, bool reuseCachedInstance) { - CheckInitialized (); - return SessionService.DefaultContext.GetExtensionObjects (path, arrayElementType, reuseCachedInstance); + AddinEngine.CheckInitialized (); + return AddinEngine.GetExtensionObjects (path, arrayElementType, reuseCachedInstance); } + /// + /// Gets extension objects registered in a path. + /// + /// + /// An extension path. + /// + /// + /// When set to True, it will return instances created in previous calls. + /// + /// + /// An array of objects registered in the path. + /// + /// + /// This method can only be used if all nodes in the provided extension path + /// are of type Mono.Addins.TypeExtensionNode. The returned array is composed + /// by all objects created by calling the TypeExtensionNode.CreateInstance() + /// method for each node (or TypeExtensionNode.GetInstance() if + /// reuseCachedInstance is set to true). + /// + /// An InvalidOperationException exception is thrown if one of the found + /// objects is not a subclass of the provided type. + /// + public static T[] GetExtensionObjects (string path, bool reuseCachedInstance) + { + AddinEngine.CheckInitialized (); + return AddinEngine.GetExtensionObjects (path, reuseCachedInstance); + } + + /// + /// Extension change event. + /// + /// + /// This event is fired when any extension point in the add-in system changes. + /// The event args object provides the path of the changed extension, although + /// it does not provide information about what changed. Hosts subscribing to + /// this event should get the new list of nodes using a query method such as + /// AddinManager.GetExtensionNodes() and then update whatever needs to be updated. + /// public static event ExtensionEventHandler ExtensionChanged { - add { CheckInitialized(); SessionService.DefaultContext.ExtensionChanged += value; } - remove { CheckInitialized(); SessionService.DefaultContext.ExtensionChanged -= value; } + add { AddinEngine.CheckInitialized(); AddinEngine.ExtensionChanged += value; } + remove { AddinEngine.CheckInitialized(); AddinEngine.ExtensionChanged -= value; } } - + + /// + /// Register a listener of extension node changes. + /// + /// + /// Path of the node. + /// + /// + /// A handler method. + /// + /// + /// Hosts can call this method to be subscribed to an extension change + /// event for a specific path. The event will be fired once for every + /// individual node change. The event arguments include the change type + /// (Add or Remove) and the extension node added or removed. + /// + /// NOTE: The handler will be called for all nodes existing in the path at the moment of registration. + /// public static void AddExtensionNodeHandler (string path, ExtensionNodeEventHandler handler) { - CheckInitialized (); - SessionService.DefaultContext.AddExtensionNodeHandler (path, handler); + AddinEngine.CheckInitialized (); + AddinEngine.AddExtensionNodeHandler (path, handler); } + /// + /// Unregister a listener of extension node changes. + /// + /// + /// Path of the node. + /// + /// + /// A handler method. + /// + /// + /// This method unregisters a delegate from the node change event of a path. + /// public static void RemoveExtensionNodeHandler (string path, ExtensionNodeEventHandler handler) { - CheckInitialized (); - SessionService.DefaultContext.RemoveExtensionNodeHandler (path, handler); - } - - static void CheckInitialized () - { - if (!initialized) - throw new InvalidOperationException ("Add-in manager not initialized."); - } - - internal static void ReportError (string message, string addinId, Exception exception, bool fatal) - { - if (AddinLoadError != null) - AddinLoadError (null, new AddinErrorEventArgs (message, addinId, exception)); - else { - Console.WriteLine (message); - if (exception != null) - Console.WriteLine (exception); - } + AddinEngine.CheckInitialized (); + AddinEngine.RemoveExtensionNodeHandler (path, handler); } - - internal static void ReportAddinLoad (string id) - { - if (AddinLoaded != null) { - try { - AddinLoaded (null, new AddinEventArgs (id)); - } catch { - // Ignore subscriber exceptions - } - } - } - - internal static void ReportAddinUnload (string id) - { - if (AddinUnloaded != null) { + + /// + /// Register a listener of extension node changes. + /// + /// + /// Type defining the extension point + /// + /// + /// A handler method. + /// + /// + /// Hosts can call this method to be subscribed to an extension change + /// event for a specific type extension point. The event will be fired once for every + /// individual node change. The event arguments include the change type + /// (Add or Remove) and the extension node added or removed. + /// + /// NOTE: The handler will be called for all nodes existing in the path at the moment of registration. + /// + public static void AddExtensionNodeHandler (Type instanceType, ExtensionNodeEventHandler handler) + { + AddinEngine.CheckInitialized (); + AddinEngine.AddExtensionNodeHandler (instanceType, handler); + } + + /// + /// Unregister a listener of extension node changes. + /// + /// + /// Type defining the extension point + /// + /// + /// A handler method. + /// + public static void RemoveExtensionNodeHandler (Type instanceType, ExtensionNodeEventHandler handler) + { + AddinEngine.CheckInitialized (); + AddinEngine.RemoveExtensionNodeHandler (instanceType, handler); + } + + /// + /// Add-in loading error event. + /// + /// + /// This event is fired when there is an error when loading the extension + /// of an add-in, or any other kind of error that may happen when querying extension points. + /// + public static event AddinErrorEventHandler AddinLoadError { + add { AddinEngine.AddinLoadError += value; } + remove { AddinEngine.AddinLoadError -= value; } + } + + /// + /// Add-in loaded event. + /// + /// + /// Fired after loading an add-in in memory. + /// + public static event AddinEventHandler AddinLoaded { + add { AddinEngine.AddinLoaded += value; } + remove { AddinEngine.AddinLoaded -= value; } + } + + /// + /// Add-in unload event. + /// + /// + /// Fired when an add-in is unloaded from memory. It may happen an add-in is disabled or uninstalled. + /// + public static event AddinEventHandler AddinUnloaded { + add { AddinEngine.AddinUnloaded += value; } + remove { AddinEngine.AddinUnloaded -= value; } + } + + internal static bool CheckAssembliesLoaded (HashSet files) + { + foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies ()) { + if (asm is System.Reflection.Emit.AssemblyBuilder) + continue; try { - AddinUnloaded (null, new AddinEventArgs (id)); + Uri u; + if (!Uri.TryCreate (asm.CodeBase, UriKind.Absolute, out u)) + continue; + string asmFile = u.LocalPath; + if (files.Contains (Path.GetFullPath (asmFile))) + return true; } catch { - // Ignore subscriber exceptions + // Ignore } } + return false; } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/AddinModuleAttribute.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinModuleAttribute.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/AddinModuleAttribute.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinModuleAttribute.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,58 @@ +// +// AddinModuleAttribute.cs +// +// Author: +// Lluis Sanchez Gual +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; + +namespace Mono.Addins +{ + /// + /// Declares an optional add-in module + /// + public class AddinModuleAttribute: Attribute + { + string assemblyFile; + + /// + /// Initializes the instance. + /// + /// + /// Relative path to the assembly that implements the optional module + /// + public AddinModuleAttribute (string assemblyFile) + { + this.assemblyFile = assemblyFile; + } + + /// + /// Relative path to the assembly that implements the optional module + /// + public string AssemblyFile { + get { return this.assemblyFile ?? string.Empty; } + set { this.assemblyFile = value; } + } + } +} + diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/AddinNameAttribute.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinNameAttribute.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/AddinNameAttribute.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinNameAttribute.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,73 @@ +// +// AddinNameAttribute.cs +// +// Author: +// Lluis Sanchez Gual +// +// Copyright (c) 2011 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; + +namespace Mono.Addins +{ + /// + /// Sets the display name of an add-in + /// + [AttributeUsage (AttributeTargets.Assembly, AllowMultiple = true)] + public class AddinNameAttribute: Attribute + { + /// + /// Initializes a new instance of the class. + /// + /// + /// Name of the add-in + /// + public AddinNameAttribute (string name) + { + Name = name; + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Name of the add-in + /// + /// + /// Locale of the name (for example, 'en-US', or 'en') + /// + public AddinNameAttribute (string name, string locale) + { + Name = name; + Locale = locale; + } + + /// + /// Name of the add-in + /// + public string Name { get; set; } + + /// + /// Locale of the name (for example, 'en-US', or 'en') + /// + public string Locale { get; set; } + } +} + diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/AddinPropertyAttribute.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinPropertyAttribute.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/AddinPropertyAttribute.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinPropertyAttribute.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,84 @@ +// +// AddinPropertyAttribute.cs +// +// Author: +// Lluis Sanchez Gual +// +// Copyright (c) 2011 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; + +namespace Mono.Addins +{ + /// + /// Defines an add-in property + /// + [AttributeUsage (AttributeTargets.Assembly, AllowMultiple=true)] + public class AddinPropertyAttribute: Attribute + { + /// + /// Initializes a new instance of the class. + /// + /// + /// Name of the property + /// + /// + /// Value of the property + /// + public AddinPropertyAttribute (string name, string value): this (name, null, value) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Name of the property + /// + /// + /// Locale of the property. It can be null if the property is not bound to a locale. + /// + /// + /// Value of the property + /// + public AddinPropertyAttribute (string name, string locale, string value) + { + Name = name; + Locale = locale; + Value = value; + } + + /// + /// Name of the property + /// + public string Name { get; set; } + + /// + /// Locale of the property. It can be null if the property is not bound to a locale. + /// + public string Locale { get; set; } + + /// + /// Value of the property + /// + public string Value { get; set; } + } +} + diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/AddinRegistry.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinRegistry.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/AddinRegistry.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinRegistry.cs 2011-04-13 09:00:29.000000000 +0000 @@ -34,9 +34,37 @@ using System.Collections.Specialized; using Mono.Addins.Database; using Mono.Addins.Description; +using System.Collections.Generic; +using System.Linq; namespace Mono.Addins { + /// + /// An add-in registry. + /// + /// + /// An add-in registry is a data structure used by the add-in engine to locate add-ins to load. + /// + /// A registry can be configured to look for add-ins in several directories. However, add-ins + /// copied to those directories won't be detected until an explicit add-in scan is requested. + /// The registry can be updated by an application by calling Registry.Update(), or by a user by + /// running the 'mautil' add-in setup tool. + /// + /// The registry has information about the location of every add-in and a timestamp of the last + /// check, so the Update method will only scan new or modified add-ins. An application can + /// add a call to Registry.Update() in the Main method to detect all new add-ins every time the + /// app is started. + /// + /// Every add-in added to the registry is parsed and validated, and if there is any error it + /// will be rejected. The registry is also in charge of scanning the add-in assemblies and look + /// for extensions and other information declared using custom attributes. That information is + /// merged with the manifest information (if there is one) to create a complete add-in + /// description ready to be used at run-time. + /// + /// Mono.Addins allows sharing an add-in registry among several applications. In this context, + /// all applications sharing the registry share the same extension point model, and it is + /// possible to implement add-ins which extend several hosts. + /// public class AddinRegistry: IDisposable { AddinDatabase database; @@ -44,37 +72,174 @@ string basePath; string currentDomain; string startupDirectory; + string addinsDir; + string databaseDir; - public AddinRegistry (string registryPath): this (registryPath, null) + /// + /// Initializes a new instance. + /// + /// + /// Location of the add-in registry. + /// + /// + /// Creates a new add-in registry located in the provided path. + /// The add-in registry will look for add-ins in an 'addins' + /// subdirectory of the provided registryPath. + /// + /// When specifying a path, it is possible to use a special folder name as root. + /// For example: [Personal]/.config/MyApp. In this case, [Personal] will be replaced + /// by the location of the Environment.SpecialFolder.Personal folder. Any value + /// of the Environment.SpecialFolder enumeration can be used (always between square + /// brackets) + /// + public AddinRegistry (string registryPath): this (null, registryPath, null, null, null) + { + } + + /// + /// Initializes a new instance. + /// + /// + /// Location of the add-in registry. + /// + /// + /// Location of the application. + /// + /// + /// Creates a new add-in registry located in the provided path. + /// The add-in registry will look for add-ins in an 'addins' + /// subdirectory of the provided registryPath. + /// + /// When specifying a path, it is possible to use a special folder name as root. + /// For example: [Personal]/.config/MyApp. In this case, [Personal] will be replaced + /// by the location of the Environment.SpecialFolder.Personal folder. Any value + /// of the Environment.SpecialFolder enumeration can be used (always between square + /// brackets) + /// + public AddinRegistry (string registryPath, string startupDirectory): this (null, registryPath, startupDirectory, null, null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Location of the add-in registry. + /// + /// + /// Location of the application. + /// + /// + /// Add-ins directory. If the path is relative, it is considered to be relative + /// to the configDir directory. + /// + /// + /// Creates a new add-in registry located in the provided path. + /// Configuration information about the add-in registry will be stored in + /// 'registryPath'. The add-in registry will look for add-ins in the provided + /// 'addinsDir' directory. + /// + /// When specifying a path, it is possible to use a special folder name as root. + /// For example: [Personal]/.config/MyApp. In this case, [Personal] will be replaced + /// by the location of the Environment.SpecialFolder.Personal folder. Any value + /// of the Environment.SpecialFolder enumeration can be used (always between square + /// brackets) + /// + public AddinRegistry (string registryPath, string startupDirectory, string addinsDir): this (null, registryPath, startupDirectory, addinsDir, null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Location of the add-in registry. + /// + /// + /// Location of the application. + /// + /// + /// Add-ins directory. If the path is relative, it is considered to be relative + /// to the configDir directory. + /// + /// + /// Location of the add-in database. If the path is relative, it is considered to be relative + /// to the configDir directory. + /// + /// + /// Creates a new add-in registry located in the provided path. + /// Configuration information about the add-in registry will be stored in + /// 'registryPath'. The add-in registry will look for add-ins in the provided + /// 'addinsDir' directory. Cached information about add-ins will be stored in + /// the 'databaseDir' directory. + /// + /// When specifying a path, it is possible to use a special folder name as root. + /// For example: [Personal]/.config/MyApp. In this case, [Personal] will be replaced + /// by the location of the Environment.SpecialFolder.Personal folder. Any value + /// of the Environment.SpecialFolder enumeration can be used (always between square + /// brackets) + /// + public AddinRegistry (string registryPath, string startupDirectory, string addinsDir, string databaseDir): this (null, registryPath, startupDirectory, addinsDir, databaseDir) { } - public AddinRegistry (string registryPath, string startupDirectory) + internal AddinRegistry (AddinEngine engine, string registryPath, string startupDirectory, string addinsDir, string databaseDir) { - basePath = Util.GetFullPath (registryPath); - database = new AddinDatabase (this); + basePath = Path.GetFullPath (Util.NormalizePath (registryPath)); + + if (addinsDir != null) { + addinsDir = Util.NormalizePath (addinsDir); + if (Path.IsPathRooted (addinsDir)) + this.addinsDir = Path.GetFullPath (addinsDir); + else + this.addinsDir = Path.GetFullPath (Path.Combine (basePath, addinsDir)); + } else + this.addinsDir = Path.Combine (basePath, "addins"); + + if (databaseDir != null) { + databaseDir = Util.NormalizePath (databaseDir); + if (Path.IsPathRooted (databaseDir)) + this.databaseDir = Path.GetFullPath (databaseDir); + else + this.databaseDir = Path.GetFullPath (Path.Combine (basePath, databaseDir)); + } + else + this.databaseDir = Path.GetFullPath (basePath); // Look for add-ins in the hosts directory and in the default // addins directory addinDirs = new StringCollection (); addinDirs.Add (DefaultAddinsFolder); + // Initialize the database after all paths have been set + database = new AddinDatabase (engine, this); + // Get the domain corresponding to the startup folder if (startupDirectory != null && startupDirectory.Length > 0) { - this.startupDirectory = startupDirectory; - currentDomain = database.GetFolderDomain (null, startupDirectory); + this.startupDirectory = Util.NormalizePath (startupDirectory); + currentDomain = database.GetFolderDomain (null, this.startupDirectory); } else currentDomain = AddinDatabase.GlobalDomain; } + /// + /// Gets the global registry. + /// + /// + /// The global registry + /// + /// + /// The global add-in registry is created in "~/.config/mono.addins", + /// and it is the default registry used when none is specified. + /// public static AddinRegistry GetGlobalRegistry () { - return GetGlobalRegistry (null); + return GetGlobalRegistry (null, null); } - internal static AddinRegistry GetGlobalRegistry (string startupDirectory) + internal static AddinRegistry GetGlobalRegistry (AddinEngine engine, string startupDirectory) { - AddinRegistry reg = new AddinRegistry (GlobalRegistryPath, startupDirectory); + AddinRegistry reg = new AddinRegistry (engine, GlobalRegistryPath, startupDirectory, null, null); string baseDir; if (Util.IsWindows) baseDir = Environment.GetFolderPath (Environment.SpecialFolder.CommonProgramFiles); @@ -85,57 +250,145 @@ return reg; } + internal bool UnknownDomain { + get { return currentDomain == AddinDatabase.UnknownDomain; } + } + internal static string GlobalRegistryPath { get { string customDir = Environment.GetEnvironmentVariable ("MONO_ADDINS_GLOBAL_REGISTRY"); if (customDir != null && customDir.Length > 0) - return Util.GetFullPath (customDir); + return Path.GetFullPath (Util.NormalizePath (customDir)); string path = Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData); path = Path.Combine (path, "mono.addins"); - return Util.GetFullPath (path); + return Path.GetFullPath (path); } } + internal string CurrentDomain { + get { return currentDomain; } + } + + /// + /// Location of the add-in registry. + /// public string RegistryPath { get { return basePath; } } + /// + /// Disposes the add-in engine. + /// public void Dispose () { database.Shutdown (); } + /// + /// Returns an add-in from the registry. + /// + /// + /// Identifier of the add-in. + /// + /// + /// The add-in, or 'null' if not found. + /// + /// + /// The add-in identifier may optionally include a version number, for example: "TextEditor.Xml,1.2" + /// public Addin GetAddin (string id) { if (currentDomain == AddinDatabase.UnknownDomain) return null; - return database.GetInstalledAddin (currentDomain, id); + Addin ad = database.GetInstalledAddin (currentDomain, id); + if (ad != null && IsRegisteredForUninstall (ad.Id)) + return null; + return ad; } + /// + /// Returns an add-in from the registry. + /// + /// + /// Identifier of the add-in. + /// + /// + /// 'true' if the exact add-in version must be found. + /// + /// + /// The add-in, or 'null' if not found. + /// + /// + /// The add-in identifier may optionally include a version number, for example: "TextEditor.Xml,1.2". + /// In this case, if the exact version is not found and exactVersionMatch is 'false', it will + /// return one than is compatible with the required version. + /// public Addin GetAddin (string id, bool exactVersionMatch) { if (currentDomain == AddinDatabase.UnknownDomain) return null; - return database.GetInstalledAddin (currentDomain, id, exactVersionMatch); + Addin ad = database.GetInstalledAddin (currentDomain, id, exactVersionMatch); + if (ad != null && IsRegisteredForUninstall (ad.Id)) + return null; + return ad; } - public Addin[] GetAddins () + /// + /// Gets all add-ins or add-in roots registered in the registry. + /// + /// + /// The addins. + /// + /// + /// Flags. + /// + public Addin[] GetModules (AddinSearchFlags flags) { if (currentDomain == AddinDatabase.UnknownDomain) return new Addin [0]; - ArrayList list = database.GetInstalledAddins (currentDomain, AddinType.Addin); - return (Addin[]) list.ToArray (typeof(Addin)); + AddinSearchFlagsInternal f = (AddinSearchFlagsInternal)(int)flags; + return database.GetInstalledAddins (currentDomain, f | AddinSearchFlagsInternal.ExcludePendingUninstall).ToArray (); } + /// + /// Gets all add-ins registered in the registry. + /// + /// + /// Add-ins registered in the registry. + /// + public Addin[] GetAddins () + { + return GetModules (AddinSearchFlags.IncludeAddins); + } + + /// + /// Gets all add-in roots registered in the registry. + /// + /// + /// Descriptions of all add-in roots. + /// public Addin[] GetAddinRoots () { - if (currentDomain == AddinDatabase.UnknownDomain) - return new Addin [0]; - ArrayList list = database.GetInstalledAddins (currentDomain, AddinType.Root); - return (Addin[]) list.ToArray (typeof(Addin)); + return GetModules (AddinSearchFlags.IncludeRoots); } + /// + /// Loads an add-in description + /// + /// + /// Progress tracker. + /// + /// + /// Name of the file to load + /// + /// + /// An add-in description + /// + /// + /// This method loads an add-in description from a file. The file can be an XML manifest or an + /// assembly that implements an add-in. + /// public AddinDescription GetAddinDescription (IProgressStatus progressStatus, string file) { if (currentDomain == AddinDatabase.UnknownDomain) @@ -166,16 +419,37 @@ } } + /// + /// Reads an XML add-in manifest + /// + /// + /// Path to the XML file + /// + /// + /// An add-in description + /// public AddinDescription ReadAddinManifestFile (string file) { - if (currentDomain == AddinDatabase.UnknownDomain) - return null; AddinDescription desc = AddinDescription.Read (file); - desc.OwnerDatabase = database; - desc.Domain = currentDomain; + if (currentDomain != AddinDatabase.UnknownDomain) { + desc.OwnerDatabase = database; + desc.Domain = currentDomain; + } return desc; } - + + /// + /// Reads an XML add-in manifest + /// + /// + /// Reader that contains the XML + /// + /// + /// Base path to use to discover add-in files + /// + /// + /// An add-in description + /// public AddinDescription ReadAddinManifestFile (TextReader reader, string baseFile) { if (currentDomain == AddinDatabase.UnknownDomain) @@ -186,6 +460,15 @@ return desc; } + /// + /// Checks whether an add-in is enabled. + /// + /// + /// Identifier of the add-in. + /// + /// + /// 'true' if the add-in is enabled. + /// public bool IsAddinEnabled (string id) { if (currentDomain == AddinDatabase.UnknownDomain) @@ -193,6 +476,16 @@ return database.IsAddinEnabled (currentDomain, id); } + /// + /// Enables an add-in. + /// + /// + /// Identifier of the add-in + /// + /// + /// If the enabled add-in depends on other add-ins which are disabled, + /// those will automatically be enabled too. + /// public void EnableAddin (string id) { if (currentDomain == AddinDatabase.UnknownDomain) @@ -200,18 +493,76 @@ database.EnableAddin (currentDomain, id, true); } + /// + /// Disables an add-in. + /// + /// + /// Identifier of the add-in. + /// + /// + /// When an add-in is disabled, all extension points it defines will be ignored + /// by the add-in engine. Other add-ins which depend on the disabled add-in will + /// also automatically be disabled. + /// public void DisableAddin (string id) { if (currentDomain == AddinDatabase.UnknownDomain) return; database.DisableAddin (currentDomain, id); } - + + /// + /// Registers a set of add-ins for uninstallation. + /// + /// + /// Identifier of the add-in + /// + /// + /// Files to be uninstalled + /// + /// + /// This method can be used to instruct the add-in manager to uninstall + /// an add-in the next time the registry is updated. This is useful + /// when an add-in manager can't delete an add-in because if it is + /// loaded. + /// + public void RegisterForUninstall (string id, IEnumerable files) + { + database.RegisterForUninstall (currentDomain, id, files); + } + + /// + /// Determines whether an add-in is registered for uninstallation + /// + /// + /// true if the add-in is registered for uninstallation + /// + /// + /// Identifier of the add-in + /// + public bool IsRegisteredForUninstall (string addinId) + { + return database.IsRegisteredForUninstall (currentDomain, addinId); + } + + /// + /// Gets a value indicating whether there are pending add-ins to be uninstalled installed + /// + public bool HasPendingUninstalls { + get { return database.HasPendingUninstalls (currentDomain); } + } + + /// + /// Internal use only + /// public void DumpFile (string file) { Mono.Addins.Serialization.BinaryXmlReader.DumpFile (file); } + /// + /// Resets the configuration files of the registry + /// public void ResetConfiguration () { database.ResetConfiguration (); @@ -223,16 +574,85 @@ currentDomain = database.GetFolderDomain (null, startupDirectory); } + /// + /// Updates the add-in registry. + /// + /// + /// This method must be called after modifying, installing or uninstalling add-ins. + /// + /// When calling Update, every add-in added to the registry is parsed and validated, + /// and if there is any error it will be rejected. It will also cache add-in information + /// needed at run-time. + /// + /// If during the update operation the registry finds new add-ins or detects that some + /// add-ins have been deleted, the loaded extension points will be updated to include + /// or exclude extension nodes from those add-ins. + /// + public void Update () + { + Update (new ConsoleProgressStatus (false)); + } + + /// + /// Updates the add-in registry. + /// + /// + /// Progress monitor to keep track of the update operation. + /// + /// + /// This method must be called after modifying, installing or uninstalling add-ins. + /// + /// When calling Update, every add-in added to the registry is parsed and validated, + /// and if there is any error it will be rejected. It will also cache add-in information + /// needed at run-time. + /// + /// If during the update operation the registry finds new add-ins or detects that some + /// add-ins have been deleted, the loaded extension points will be updated to include + /// or exclude extension nodes from those add-ins. + /// public void Update (IProgressStatus monitor) { database.Update (monitor, currentDomain); } + /// + /// Regenerates the cached data of the add-in registry. + /// + /// + /// Progress monitor to keep track of the rebuild operation. + /// public void Rebuild (IProgressStatus monitor) { database.Repair (monitor, currentDomain); } + /// + /// Registers an extension. Only AddinFileSystemExtension extensions are supported right now. + /// + /// + /// The extension to register + /// + public void RegisterExtension (object extension) + { + database.RegisterExtension (extension); + } + + /// + /// Unregisters an extension. + /// + /// + /// The extension to unregister + /// + public void UnregisterExtension (object extension) + { + database.UnregisterExtension (extension); + } + + internal void CopyExtensionsFrom (AddinRegistry other) + { + database.CopyExtensions (other.database); + } + internal Addin GetAddinForHostAssembly (string filePath) { if (currentDomain == AddinDatabase.UnknownDomain) @@ -255,10 +675,22 @@ database.ParseAddin (progressStatus, currentDomain, file, outFile, true); } + /// + /// Gets the default add-ins folder of the registry. + /// + /// + /// For every add-in registry there is an add-in folder where the registry will look for add-ins by default. + /// This folder is an "addins" subdirectory of the directory where the repository is located. In most cases, + /// this folder will only contain .addins files referencing other more convenient locations for add-ins. + /// public string DefaultAddinsFolder { - get { return Path.Combine (basePath, "addins"); } + get { return addinsDir; } } + internal string AddinCachePath { + get { return databaseDir; } + } + internal StringCollection GlobalAddinDirectories { get { return addinDirs; } } @@ -271,7 +703,7 @@ internal bool CreateHostAddinsFile (string hostFile) { - hostFile = Util.GetFullPath (hostFile); + hostFile = Path.GetFullPath (hostFile); string baseName = Path.GetFileNameWithoutExtension (hostFile); if (!Directory.Exists (database.HostsPath)) Directory.CreateDirectory (database.HostsPath); @@ -312,6 +744,8 @@ return true; } +#pragma warning disable 1591 + [Obsolete] public static string[] GetRegisteredStartupFolders (string registryPath) { string dbDir = Path.Combine (registryPath, "addin-db-" + AddinDatabase.VersionTag); @@ -339,5 +773,30 @@ } return (string[]) dirs.ToArray (typeof(string)); } +#pragma warning restore 1591 + } + + /// + /// Addin search flags. + /// + [Flags] + public enum AddinSearchFlags + { + /// + /// Add-ins are included in the search + /// + IncludeAddins = 1, + /// + /// Add-in roots are included in the search + /// + IncludeRoots = 1 << 1, + /// + /// Both add-in and add-in roots are included in the search + /// + IncludeAll = IncludeAddins | IncludeRoots, + /// + /// Only the latest version of every add-in or add-in root is included in the search + /// + LatestVersionsOnly = 1 << 3 } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/AddinRootAttribute.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinRootAttribute.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/AddinRootAttribute.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinRootAttribute.cs 2011-04-13 09:00:29.000000000 +0000 @@ -31,17 +31,41 @@ namespace Mono.Addins { + /// + /// Marks an assembly as being an add-in root. + /// + /// + /// An add-in root is an assemly which can be extended by add-ins. + /// [AttributeUsage (AttributeTargets.Assembly)] public class AddinRootAttribute: AddinAttribute { + /// + /// Initializes a new instance + /// public AddinRootAttribute () { } + /// + /// Initializes a new instance + /// + /// + /// Identifier of the add-in root + /// public AddinRootAttribute (string id): base (id) { } + /// + /// Initializes a new instance + /// + /// + /// Identifier of the add-in root + /// + /// + /// Version of the add-in root + /// public AddinRootAttribute (string id, string version): base (id, version) { } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/AddinSessionService.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinSessionService.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/AddinSessionService.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/AddinSessionService.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,401 +0,0 @@ -// -// AddinService.cs -// -// Author: -// Lluis Sanchez Gual -// -// Copyright (C) 2007 Novell, Inc (http://www.novell.com) -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - - -using System; -using System.Xml; -using System.Collections; -using System.Reflection; - -using Mono.Addins.Description; -using Mono.Addins.Database; -using Mono.Addins.Localization; - -namespace Mono.Addins -{ - internal class AddinSessionService - { - bool checkAssemblyLoadConflicts; - Hashtable loadedAddins = new Hashtable (); - ExtensionContext defaultContext; - Hashtable nodeSets = new Hashtable (); - Hashtable autoExtensionTypes = new Hashtable (); - Hashtable loadedAssemblies = new Hashtable (); - AddinLocalizer defaultLocalizer; - - internal void Initialize () - { - defaultContext = new ExtensionContext (); - ActivateRoots (); - AppDomain.CurrentDomain.AssemblyLoad += new AssemblyLoadEventHandler (OnAssemblyLoaded); - } - - internal void Shutdown () - { - AppDomain.CurrentDomain.AssemblyLoad -= new AssemblyLoadEventHandler (OnAssemblyLoaded); - defaultContext = null; - loadedAddins.Clear (); - loadedAssemblies.Clear (); - } - - public void InitializeDefaultLocalizer (IAddinLocalizer localizer) - { - if (localizer != null) - defaultLocalizer = new AddinLocalizer (localizer); - else - defaultLocalizer = null; - } - - public AddinLocalizer DefaultLocalizer { - get { - if (defaultLocalizer != null) - return defaultLocalizer; - else - return NullLocalizer.Instance; - } - } - - internal ExtensionContext DefaultContext { - get { return defaultContext; } - } - - public AddinLocalizer CurrentLocalizer { - get { - Assembly asm = Assembly.GetCallingAssembly (); - RuntimeAddin addin = GetAddinForAssembly (asm); - if (addin != null) - return addin.Localizer; - else - return DefaultLocalizer; - } - } - - public RuntimeAddin CurrentAddin { - get { - Assembly asm = Assembly.GetCallingAssembly (); - return GetAddinForAssembly (asm); - } - } - - internal RuntimeAddin GetAddinForAssembly (Assembly asm) - { - return (RuntimeAddin) loadedAssemblies [asm]; - } - - // Enables or disables conflict checking while loading assemblies. - // Disabling makes loading faster, but less safe. - public bool CheckAssemblyLoadConflicts { - get { return checkAssemblyLoadConflicts; } - set { checkAssemblyLoadConflicts = value; } - } - - public bool IsAddinLoaded (string id) - { - return loadedAddins.Contains (Addin.GetIdName (id)); - } - - internal RuntimeAddin GetAddin (string id) - { - return (RuntimeAddin) loadedAddins [Addin.GetIdName (id)]; - } - - internal void ActivateAddin (string id) - { - defaultContext.ActivateAddinExtensions (id); - } - - internal void UnloadAddin (string id) - { - defaultContext.RemoveAddinExtensions (id); - - RuntimeAddin addin = GetAddin (id); - if (addin != null) { - addin.UnloadExtensions (); - loadedAddins.Remove (Addin.GetIdName (id)); - foreach (Assembly asm in addin.Assemblies) - loadedAssemblies.Remove (asm); - AddinManager.ReportAddinUnload (id); - } - } - - internal bool LoadAddin (IProgressStatus statusMonitor, string id, bool throwExceptions) - { - try { - if (IsAddinLoaded (id)) - return true; - - if (!AddinManager.Registry.IsAddinEnabled (id)) { - string msg = GettextCatalog.GetString ("Disabled add-ins can't be loaded."); - AddinManager.ReportError (msg, id, null, false); - if (throwExceptions) - throw new InvalidOperationException (msg); - return false; - } - - ArrayList addins = new ArrayList (); - Stack depCheck = new Stack (); - ResolveLoadDependencies (addins, depCheck, id, false); - addins.Reverse (); - - if (statusMonitor != null) - statusMonitor.SetMessage ("Loading Addins"); - - for (int n=0; n 0) { - Type ntype = addin.GetType (nt.ObjectTypeName, true); - RegisterAutoTypeExtensionPoint (ntype, ep.Path); - } - } - } - - bool ResolveLoadDependencies (ArrayList addins, Stack depCheck, string id, bool optional) - { - if (IsAddinLoaded (id)) - return true; - - if (depCheck.Contains (id)) - throw new InvalidOperationException ("A cyclic addin dependency has been detected."); - - depCheck.Push (id); - - Addin iad = AddinManager.Registry.GetAddin (id); - if (iad == null || !iad.Enabled) { - if (optional) - return false; - else if (iad != null && !iad.Enabled) - throw new MissingDependencyException (GettextCatalog.GetString ("The required addin '{0}' is disabled.", id)); - else - throw new MissingDependencyException (GettextCatalog.GetString ("The required addin '{0}' is not installed.", id)); - } - - // If this addin has already been requested, bring it to the head - // of the list, so it is loaded earlier than before. - addins.Remove (iad); - addins.Add (iad); - - foreach (Dependency dep in iad.AddinInfo.Dependencies) { - AddinDependency adep = dep as AddinDependency; - if (adep != null) { - try { - string adepid = Addin.GetFullId (iad.AddinInfo.Namespace, adep.AddinId, adep.Version); - ResolveLoadDependencies (addins, depCheck, adepid, false); - } catch (MissingDependencyException) { - if (optional) - return false; - else - throw; - } - } - } - - if (iad.AddinInfo.OptionalDependencies != null) { - foreach (Dependency dep in iad.AddinInfo.OptionalDependencies) { - AddinDependency adep = dep as AddinDependency; - if (adep != null) { - string adepid = Addin.GetFullId (iad.Namespace, adep.AddinId, adep.Version); - if (!ResolveLoadDependencies (addins, depCheck, adepid, true)) - return false; - } - } - } - - depCheck.Pop (); - return true; - } - - public void RegisterNodeSet (ExtensionNodeSet nset) - { - nodeSets [nset.Id] = nset; - } - - public void UnregisterNodeSet (ExtensionNodeSet nset) - { - nodeSets.Remove (nset.Id); - } - - public string GetNodeTypeAddin (ExtensionNodeSet nset, string type, string callingAddinId) - { - ExtensionNodeType nt = FindType (nset, type, callingAddinId); - if (nt != null) - return nt.AddinId; - else - return null; - } - - internal ExtensionNodeType FindType (ExtensionNodeSet nset, string name, string callingAddinId) - { - if (nset == null) - return null; - - foreach (ExtensionNodeType nt in nset.NodeTypes) { - if (nt.Id == name) - return nt; - } - - foreach (string ns in nset.NodeSets) { - ExtensionNodeSet regSet = (ExtensionNodeSet) nodeSets [ns]; - if (regSet == null) { - AddinManager.ReportError ("Unknown node set: " + ns, callingAddinId, null, false); - return null; - } - ExtensionNodeType nt = FindType (regSet, name, callingAddinId); - if (nt != null) - return nt; - } - return null; - } - - public void RegisterAutoTypeExtensionPoint (Type type, string path) - { - autoExtensionTypes [type] = path; - } - - public void UnregisterAutoTypeExtensionPoint (Type type, string path) - { - autoExtensionTypes.Remove (type); - } - - public string GetAutoTypeExtensionPoint (Type type) - { - return autoExtensionTypes [type] as string; - } - - void OnAssemblyLoaded (object s, AssemblyLoadEventArgs a) - { - CheckHostAssembly (a.LoadedAssembly); - } - - internal void ActivateRoots () - { - foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies ()) - CheckHostAssembly (asm); - } - - void CheckHostAssembly (Assembly asm) - { - if (AddinDatabase.RunningSetupProcess || asm is System.Reflection.Emit.AssemblyBuilder) - return; - string asmFile = new Uri (asm.CodeBase).LocalPath; - Addin ainfo = AddinManager.Registry.GetAddinForHostAssembly (asmFile); - if (ainfo != null && !IsAddinLoaded (ainfo.Id)) { - if (ainfo.Description.FilesChanged ()) { - // If the add-in has changed, update the add-in database. - // We do it here because once loaded, add-in roots can't be - // reloaded like regular add-ins. - AddinManager.Registry.Update (null); - ainfo = AddinManager.Registry.GetAddinForHostAssembly (asmFile); - if (ainfo == null) - return; - } - LoadAddin (null, ainfo.Id, false); - } - } - } - -} diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/ConditionType.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/ConditionType.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/ConditionType.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/ConditionType.cs 2011-04-13 09:00:29.000000000 +0000 @@ -34,13 +34,41 @@ namespace Mono.Addins { + /// + /// A condition evaluator. + /// + /// + /// Add-ins may use conditions to register nodes in an extension point which + /// are only visible under some contexts. For example, an add-in registering + /// a custom menu option to the main menu of a sample text editor might want + /// to make that option visible only for some kind of files. To allow add-ins + /// to do this kind of check, the host application needs to define a new condition. + /// public abstract class ConditionType { internal event EventHandler Changed; string id; + /// + /// Evaluates the condition. + /// + /// + /// Condition node information. + /// + /// + /// 'true' if the condition is satisfied. + /// public abstract bool Evaluate (NodeElement conditionNode); + /// + /// Notifies that the condition has changed, and that it has to be re-evaluated. + /// + /// This method must be called when there is a change in the state that determines + /// the result of the evaluation. When this method is called, all node conditions + /// depending on it are reevaluated and the corresponding events for adding or + /// removing extension nodes are fired. + /// + /// public void NotifyChanged () { if (Changed != null) @@ -135,15 +163,37 @@ cond.GetConditionTypes (listToFill); } } + + class NotCondition: BaseCondition + { + BaseCondition baseCond; + + public NotCondition (BaseCondition baseCond, BaseCondition parent): base (parent) + { + this.baseCond = baseCond; + } + + public override bool Evaluate (ExtensionContext ctx) + { + return !base.Evaluate (ctx); + } + + internal override void GetConditionTypes (System.Collections.ArrayList listToFill) + { + baseCond.GetConditionTypes (listToFill); + } + } internal sealed class Condition: BaseCondition { ExtensionNodeDescription node; string typeId; + AddinEngine addinEngine; - internal Condition (ExtensionNodeDescription element, BaseCondition parent): base (parent) + internal Condition (AddinEngine addinEngine, ExtensionNodeDescription element, BaseCondition parent): base (parent) { + this.addinEngine = addinEngine; typeId = element.GetAttribute ("id"); node = element; } @@ -155,7 +205,7 @@ ConditionType type = ctx.GetCondition (typeId); if (type == null) { - AddinManager.ReportError ("Condition '" + typeId + "' not found in current extension context.", null, null, false); + addinEngine.ReportError ("Condition '" + typeId + "' not found in current extension context.", null, null, false); return false; } @@ -163,7 +213,7 @@ return type.Evaluate (node); } catch (Exception ex) { - AddinManager.ReportError ("Error while evaluating condition '" + typeId + "'", null, ex, false); + addinEngine.ReportError ("Error while evaluating condition '" + typeId + "'", null, ex, false); return false; } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/ConsoleProgressStatus.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/ConsoleProgressStatus.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/ConsoleProgressStatus.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/ConsoleProgressStatus.cs 2011-04-13 09:00:29.000000000 +0000 @@ -31,11 +31,20 @@ namespace Mono.Addins { + /// + /// An IProgressStatus class which writes output to the console. + /// public class ConsoleProgressStatus: MarshalByRefObject, IProgressStatus { bool canceled; int logLevel; + /// + /// Initializes a new instance + /// + /// + /// Set to true to enabled verbose log + /// public ConsoleProgressStatus (bool verboseLog) { if (verboseLog) @@ -44,30 +53,81 @@ logLevel = 1; } + /// + /// Initializes a new instance + /// + /// + /// Verbosity level. 0: not verbose, 1: normal, >1 extra verbose + /// public ConsoleProgressStatus (int logLevel) { this.logLevel = logLevel; } + /// + /// Sets the description of the current operation. + /// + /// + /// A message + /// + /// + /// This method is called by the add-in engine to show a description of the operation being monitorized. + /// public void SetMessage (string msg) { } + /// + /// Sets the progress of the operation. + /// + /// + /// A number between 0 and 1. 0 means no progress, 1 means operation completed. + /// + /// + /// This method is called by the add-in engine to show the progress of the operation being monitorized. + /// public void SetProgress (double progress) { } + /// + /// Writes text to the log. + /// + /// + /// Message to write + /// public void Log (string msg) { Console.WriteLine (msg); } + /// + /// Reports a warning. + /// + /// + /// Warning message + /// + /// + /// This method is called by the add-in engine to report a warning in the operation being monitorized. + /// public void ReportWarning (string message) { if (logLevel > 0) Console.WriteLine ("WARNING: " + message); } + /// + /// Reports an error. + /// + /// + /// Error message + /// + /// + /// Exception that caused the error. It can be null. + /// + /// + /// This method is called by the add-in engine to report an error occurred while executing the operation being monitorized. + /// public void ReportError (string message, Exception exception) { if (logLevel == 0) @@ -90,14 +150,23 @@ } } + /// + /// Returns True when the user requested to cancel this operation + /// public bool IsCanceled { get { return canceled; } } + /// + /// Log level requested by the user: 0: no log, 1: normal log, >1 verbose log + /// public int LogLevel { get { return logLevel; } } + /// + /// Cancels the operation being montorized. + /// public void Cancel () { canceled = true; diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/ContentType.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/ContentType.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/ContentType.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/ContentType.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,53 @@ +// +// ContentType.cs +// +// Author: +// Lluis Sanchez Gual +// +// Copyright (c) 2011 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; + +namespace Mono.Addins +{ + /// + /// Type of the content of a string extension node attribute + /// + public enum ContentType + { + /// + /// Plain text + /// + Text, + /// + /// A class name + /// + Class, + /// + /// A resource name + /// + Resource, + /// + /// A file name + /// + File + } +} + diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/CustomExtensionAttribute.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/CustomExtensionAttribute.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/CustomExtensionAttribute.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/CustomExtensionAttribute.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,88 @@ +// +// CustomExtensionAttribute.cs +// +// Author: +// Lluis Sanchez Gual +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; + +namespace Mono.Addins +{ + /// + /// Base class for custon extension attributes. + /// + /// + /// Custom extension attributes can be used to declare extensions with custom metadata. + /// All custom extension attributes must subclass CustomExtensionAttribute. + /// + public class CustomExtensionAttribute: Attribute + { + string id; + string insertBefore; + string insertAfter; + string path; + + internal const string PathFieldKey = "__path"; + + /// + /// Identifier of the node + /// + [NodeAttributeAttribute ("id")] + public string Id { + get { return id; } + set { id = value; } + } + + /// + /// Identifier of the node before which this node has to be placed + /// + [NodeAttributeAttribute ("insertbefore")] + public string InsertBefore { + get { return insertBefore; } + set { insertBefore = value; } + } + + /// + /// Identifier of the node after which this node has to be placed + /// + [NodeAttributeAttribute ("insertafter")] + public string InsertAfter { + get { return insertAfter; } + set { insertAfter = value; } + } + + /// + /// Path of the extension point being extended. + /// + /// + /// This property is optional and useful only when there are several extension points which allow + /// using this custom attribute to define extensions. + /// + [NodeAttributeAttribute ("__path")] + public string Path { + get { return path; } + set { path = value; } + } + } +} + diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/ExtensionAttributeAttribute.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/ExtensionAttributeAttribute.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/ExtensionAttributeAttribute.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/ExtensionAttributeAttribute.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,137 @@ +// +// ExtensionAttributeAttribute.cs +// +// Author: +// Lluis Sanchez Gual +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; + +namespace Mono.Addins +{ + /// + /// Assigns an attribute value to an extension + /// + /// + /// This attribute can be used together with the [Extenion] attribute to specify + /// a value for an attribute of the extension. + /// + public class ExtensionAttributeAttribute: Attribute + { + Type targetType; + string targetTypeName; + string name; + string val; + string path; + + /// + /// Initializes a new instance of the class. + /// + /// + /// Name of the attribute + /// + /// + /// Value of the attribute + /// + public ExtensionAttributeAttribute (string name, string value) + { + Name = name; + Value = value; + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Type of the extension for which the attribute value is being set + /// + /// + /// Name of the attribute + /// + /// + /// Value of the attribute + /// + public ExtensionAttributeAttribute (Type type, string name, string value) + { + Name = name; + Value = value; + Type = type; + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Path of the extension for which the attribute value is being set + /// + /// + /// Name of the attribute + /// + /// + /// Value of the attribute + /// + public ExtensionAttributeAttribute (string path, string name, string value) + { + Name = name; + Value = value; + Path = path; + } + + /// + /// Name of the attribute + /// + public string Name { + get { return this.name; } + set { this.name = value; } + } + + /// + /// Value of the attribute + /// + public string Value { + get { return this.val; } + set { this.val = value; } + } + + /// + /// Path of the extension for which the attribute value is being set + /// + public string Path { + get { return this.path; } + set { this.path = value; } + } + + /// + /// Type of the extension for which the attribute value is being set + /// + public Type Type { + get { return targetType; } + set { targetType = value; targetTypeName = targetType.FullName; } + } + + internal string TypeName { + get { return targetTypeName ?? string.Empty; } + set { targetTypeName = value; } + } + } +} + diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/ExtensionAttribute.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/ExtensionAttribute.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/ExtensionAttribute.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/ExtensionAttribute.cs 2011-04-13 09:00:29.000000000 +0000 @@ -31,6 +31,13 @@ namespace Mono.Addins { + /// + /// Declares a type extension. + /// + /// + /// When applied to a class, specifies that the class is an extension + /// class to be registered in a matching extension point. + /// [AttributeUsage (AttributeTargets.Class, AllowMultiple=true)] public class ExtensionAttribute: Attribute { @@ -39,39 +46,121 @@ string id; string insertBefore; string insertAfter; - + string typeName; + Type type; + + /// + /// Initializes a new instance of the ExtensionAttribute class. + /// public ExtensionAttribute () { } + /// + /// Initializes a new instance + /// + /// + /// Path of the extension point. + /// + /// The path is only required if there are several extension points defined for the same type. public ExtensionAttribute (string path) { this.path = path; } + /// + /// Initializes a new instance + /// + /// + /// Type defining the extension point being extended + /// + /// + /// This constructor can be used to explicitly specify the type that defines the extension point + /// to be extended. By default, Mono.Addins will try to find any extension point defined in any + /// of the base classes or interfaces. The type parameter can be used when there is more than one + /// base type providing an extension point. + /// + public ExtensionAttribute (Type type) + { + Type = type; + } + + /// + /// Path of the extension point being extended + /// + /// + /// The path is only required if there are several extension points defined for the same type. + /// public string Path { - get { return path != null ? path : string.Empty; } + get { return path ?? string.Empty; } set { path = value; } } - + + /// + /// Name of the extension node + /// + /// + /// Extension points may require extensions to use a specific node name. + /// This is needed when an extension point may contain several different types of nodes. + /// public string NodeName { - get { return nodeName != null && nodeName.Length > 0 ? nodeName : "Type"; } + get { return !string.IsNullOrEmpty (nodeName) ? nodeName : "Type"; } set { nodeName = value; } } + /// + /// Identifier of the extension node. + /// + /// + /// The ExtensionAttribute.InsertAfter and ExtensionAttribute.InsertBefore + /// properties can be used to specify the relative location of a node. The nodes + /// referenced in those properties must be defined either in the add-in host + /// being extended, or in any add-in on which this add-in depends. + /// public string Id { - get { return id != null ? id : string.Empty; } + get { return id ?? string.Empty; } set { id = value; } } - + + /// + /// Identifier of the extension node before which this node has to be added in the extension point. + /// + /// + /// The ExtensionAttribute.InsertAfter and ExtensionAttribute.InsertBefore + /// properties can be used to specify the relative location of a node. The nodes + /// referenced in those properties must be defined either in the add-in host + /// being extended, or in any add-in on which this add-in depends. + /// public string InsertBefore { - get { return insertBefore != null ? insertBefore : string.Empty; } + get { return insertBefore ?? string.Empty; } set { insertBefore = value; } } + /// + /// Identifier of the extension node after which this node has to be added in the extension point. + /// public string InsertAfter { - get { return insertAfter != null ? insertAfter : string.Empty; } + get { return insertAfter ?? string.Empty; } set { insertAfter = value; } } + + /// + /// Type defining the extension point being extended + /// + /// + /// This property can be used to explicitly specify the type that defines the extension point + /// to be extended. By default, Mono.Addins will try to find any extension point defined in any + /// of the base classes or interfaces. This property can be used when there is more than one + /// base type providing an extension point. + /// + public Type Type { + get { return type; } + set { type = value; typeName = type.FullName; } + } + + internal string TypeName { + get { return typeName ?? string.Empty; } + set { typeName = value; } + } } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/ExtensionContext.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/ExtensionContext.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/ExtensionContext.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/ExtensionContext.cs 2011-04-13 09:00:29.000000000 +0000 @@ -29,11 +29,22 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Collections.Specialized; using Mono.Addins.Description; namespace Mono.Addins { + /// + /// An extension context. + /// + /// + /// Extension contexts can be used to query the extension tree + /// using particular condition values. Extension points which + /// declare the availability of a condition type can only be + /// queryed using an extension context which provides an + /// evaluator for that condition. + /// public class ExtensionContext { Hashtable conditionTypes = new Hashtable (); @@ -46,25 +57,66 @@ ArrayList runTimeEnabledAddins; ArrayList runTimeDisabledAddins; + /// + /// Extension change event. + /// + /// + /// This event is fired when any extension point in the add-in system changes. + /// The event args object provides the path of the changed extension, although + /// it does not provide information about what changed. Hosts subscribing to + /// this event should get the new list of nodes using a query method such as + /// AddinManager.GetExtensionNodes() and then update whatever needs to be updated. + /// public event ExtensionEventHandler ExtensionChanged; + /// + /// Releases unmanaged resources and performs other cleanup operations before the + /// ExtensionContext is reclaimed by garbage collection. + /// ~ExtensionContext () { if (parentContext != null) parentContext.DisposeChildContext (this); } - internal ExtensionContext () + internal void Initialize (AddinEngine addinEngine) { - tree = new ExtensionTree (this); + fireEvents = false; + tree = new ExtensionTree (addinEngine, this); + } + +#pragma warning disable 1591 + [ObsoleteAttribute] + protected void Clear () + { + } +#pragma warning restore 1591 + + + internal void ClearContext () + { + conditionTypes.Clear (); + conditionsToNodes.Clear (); + childContexts = null; + parentContext = null; + tree = null; + runTimeEnabledAddins = null; + runTimeDisabledAddins = null; + } + + internal AddinEngine AddinEngine { + get { return tree.AddinEngine; } } - internal void ResetCachedData () + internal virtual void ResetCachedData () { tree.ResetCachedData (); if (childContexts != null) { - foreach (ExtensionContext ctx in childContexts) - ctx.ResetCachedData (); + foreach (WeakReference wref in childContexts) { + ExtensionContext ctx = wref.Target as ExtensionContext; + if (ctx != null) + ctx.ResetCachedData (); + } } } @@ -74,6 +126,7 @@ if (childContexts == null) childContexts = new ArrayList (); ExtensionContext ctx = new ExtensionContext (); + ctx.Initialize (AddinEngine); ctx.parentContext = this; WeakReference wref = new WeakReference (ctx); childContexts.Add (wref); @@ -84,15 +137,31 @@ internal void DisposeChildContext (ExtensionContext ctx) { lock (conditionTypes) { - foreach (WeakReference wref in childContexts) { - if (wref.Target == ctx) { - childContexts.Remove (wref); - return; + if (childContexts != null) { + foreach (WeakReference wref in childContexts) { + if (wref.Target == ctx) { + childContexts.Remove (wref); + return; + } } } } } + /// + /// Registers a new condition in the extension context. + /// + /// + /// Identifier of the condition. + /// + /// + /// Condition evaluator. + /// + /// + /// The registered condition will be particular to this extension context. + /// Any event that might be fired as a result of changes in the condition will + /// only be fired in this context. + /// public void RegisterCondition (string id, ConditionType type) { type.Id = id; @@ -104,6 +173,19 @@ type.Changed += new EventHandler (OnConditionChanged); } + /// + /// Registers a new condition in the extension context. + /// + /// + /// Identifier of the condition. + /// + /// + /// Type of the condition evaluator. Must be a subclass of Mono.Addins.ConditionType. + /// + /// + /// The registered condition will be particular to this extension context. Any event + /// that might be fired as a result of changes in the condition will only be fired in this context. + /// public void RegisterCondition (string id, Type type) { // Allows delayed creation of condition types @@ -197,6 +279,15 @@ } } + /// + /// Returns the extension node in a path + /// + /// + /// Location of the node. + /// + /// + /// The node, or null if not found. + /// public ExtensionNode GetExtensionNode (string path) { TreeNode node = GetNode (path); @@ -209,11 +300,135 @@ return null; } + /// + /// Returns the extension node in a path + /// + /// + /// Location of the node. + /// + /// + /// The node, or null if not found. + /// + public T GetExtensionNode (string path) where T: ExtensionNode + { + return (T) GetExtensionNode (path); + } + + /// + /// Gets extension nodes registered in a path. + /// + /// + /// An extension path.> + /// + /// + /// All nodes registered in the provided path. + /// public ExtensionNodeList GetExtensionNodes (string path) { return GetExtensionNodes (path, null); } + /// + /// Gets extension nodes registered in a path. + /// + /// + /// An extension path. + /// + /// + /// A list of nodes + /// + /// + /// This method returns all nodes registered under the provided path. + /// It will throw a InvalidOperationException if the type of one of + /// the registered nodes is not assignable to the provided type. + /// + public ExtensionNodeList GetExtensionNodes (string path) where T: ExtensionNode + { + ExtensionNodeList nodes = GetExtensionNodes (path, typeof(T)); + return new ExtensionNodeList (nodes.list); + } + + /// + /// Gets extension nodes for a type extension point + /// + /// + /// Type defining the extension point + /// + /// + /// A list of nodes + /// + /// + /// This method returns all extension nodes bound to the provided type. + /// + public ExtensionNodeList GetExtensionNodes (Type instanceType) + { + return GetExtensionNodes (instanceType, typeof(ExtensionNode)); + } + + /// + /// Gets extension nodes for a type extension point + /// + /// + /// Type defining the extension point + /// + /// + /// Expected extension node type + /// + /// + /// A list of nodes + /// + /// + /// This method returns all nodes registered for the provided type. + /// It will throw a InvalidOperationException if the type of one of + /// the registered nodes is not assignable to the provided node type. + /// + public ExtensionNodeList GetExtensionNodes (Type instanceType, Type expectedNodeType) + { + string path = AddinEngine.GetAutoTypeExtensionPoint (instanceType); + if (path == null) + return new ExtensionNodeList (null); + return GetExtensionNodes (path, expectedNodeType); + } + + /// + /// Gets extension nodes for a type extension point + /// + /// + /// Type defining the extension point + /// + /// + /// A list of nodes + /// + /// + /// This method returns all nodes registered for the provided type. + /// It will throw a InvalidOperationException if the type of one of + /// the registered nodes is not assignable to the specified node type argument. + /// + public ExtensionNodeList GetExtensionNodes (Type instanceType) where T: ExtensionNode + { + string path = AddinEngine.GetAutoTypeExtensionPoint (instanceType); + if (path == null) + return new ExtensionNodeList (null); + return new ExtensionNodeList (GetExtensionNodes (path, typeof (T)).list); + } + + /// + /// Gets extension nodes registered in a path. + /// + /// + /// An extension path. + /// + /// + /// Expected node type. + /// + /// + /// A list of nodes + /// + /// + /// This method returns all nodes registered under the provided path. + /// It will throw a InvalidOperationException if the type of one of + /// the registered nodes is not assignable to the provided type. + /// public ExtensionNodeList GetExtensionNodes (string path, Type expectedNodeType) { TreeNode node = GetNode (path); @@ -227,12 +442,12 @@ foreach (ExtensionNode cnode in list) { if (!expectedNodeType.IsInstanceOfType (cnode)) { foundError = true; - AddinManager.ReportError ("Error while getting nodes for path '" + path + "'. Expected subclass of node type '" + expectedNodeType + "'. Found '" + cnode.GetType (), null, null, false); + AddinEngine.ReportError ("Error while getting nodes for path '" + path + "'. Expected subclass of node type '" + expectedNodeType + "'. Found '" + cnode.GetType (), null, null, false); } } if (foundError) { // Create a new list excluding the elements that failed the test - ArrayList newList = new ArrayList (); + List newList = new List (); foreach (ExtensionNode cnode in list) { if (expectedNodeType.IsInstanceOfType (cnode)) newList.Add (cnode); @@ -243,34 +458,224 @@ return list; } + /// + /// Gets extension objects registered for a type extension point. + /// + /// + /// Type defining the extension point + /// + /// + /// A list of objects + /// public object[] GetExtensionObjects (Type instanceType) { return GetExtensionObjects (instanceType, true); } + /// + /// Gets extension objects registered for a type extension point. + /// + /// + /// A list of objects + /// + /// + /// The type argument of this generic method is the type that defines + /// the extension point. + /// + public T[] GetExtensionObjects () + { + return GetExtensionObjects (true); + } + + /// + /// Gets extension objects registered for a type extension point. + /// + /// + /// Type defining the extension point + /// + /// + /// When set to True, it will return instances created in previous calls. + /// + /// + /// A list of extension objects. + /// public object[] GetExtensionObjects (Type instanceType, bool reuseCachedInstance) { - string path = AddinManager.SessionService.GetAutoTypeExtensionPoint (instanceType); + string path = AddinEngine.GetAutoTypeExtensionPoint (instanceType); if (path == null) return (object[]) Array.CreateInstance (instanceType, 0); return GetExtensionObjects (path, instanceType, reuseCachedInstance); } + /// + /// Gets extension objects registered for a type extension point. + /// + /// + /// When set to True, it will return instances created in previous calls. + /// + /// + /// A list of extension objects. + /// + /// + /// The type argument of this generic method is the type that defines + /// the extension point. + /// + public T[] GetExtensionObjects (bool reuseCachedInstance) + { + string path = AddinEngine.GetAutoTypeExtensionPoint (typeof(T)); + if (path == null) + return new T[0]; + return GetExtensionObjects (path, reuseCachedInstance); + } + + /// + /// Gets extension objects registered in a path + /// + /// + /// An extension path. + /// + /// + /// An array of objects registered in the path. + /// + /// + /// This method can only be used if all nodes in the provided extension path + /// are of type Mono.Addins.TypeExtensionNode. The returned array is composed + /// by all objects created by calling the TypeExtensionNode.CreateInstance() + /// method for each node. + /// public object[] GetExtensionObjects (string path) { return GetExtensionObjects (path, typeof(object), true); } + /// + /// Gets extension objects registered in a path. + /// + /// + /// An extension path. + /// + /// + /// When set to True, it will return instances created in previous calls. + /// + /// + /// An array of objects registered in the path. + /// + /// + /// This method can only be used if all nodes in the provided extension path + /// are of type Mono.Addins.TypeExtensionNode. The returned array is composed + /// by all objects created by calling the TypeExtensionNode.CreateInstance() + /// method for each node (or TypeExtensionNode.GetInstance() if + /// reuseCachedInstance is set to true) + /// public object[] GetExtensionObjects (string path, bool reuseCachedInstance) { return GetExtensionObjects (path, typeof(object), reuseCachedInstance); } + /// + /// Gets extension objects registered in a path. + /// + /// + /// An extension path. + /// + /// + /// Type of the return array elements. + /// + /// + /// An array of objects registered in the path. + /// + /// + /// This method can only be used if all nodes in the provided extension path + /// are of type Mono.Addins.TypeExtensionNode. The returned array is composed + /// by all objects created by calling the TypeExtensionNode.CreateInstance() + /// method for each node. + /// + /// An InvalidOperationException exception is thrown if one of the found + /// objects is not a subclass of the provided type. + /// public object[] GetExtensionObjects (string path, Type arrayElementType) { return GetExtensionObjects (path, arrayElementType, true); } + /// + /// Gets extension objects registered in a path. + /// + /// + /// An extension path. + /// + /// + /// An array of objects registered in the path. + /// + /// + /// This method can only be used if all nodes in the provided extension path + /// are of type Mono.Addins.TypeExtensionNode. The returned array is composed + /// by all objects created by calling the TypeExtensionNode.CreateInstance() + /// method for each node. + /// + /// An InvalidOperationException exception is thrown if one of the found + /// objects is not a subclass of the provided type. + /// + public T[] GetExtensionObjects (string path) + { + return GetExtensionObjects (path, true); + } + + /// + /// Gets extension objects registered in a path. + /// + /// + /// An extension path. + /// + /// + /// When set to True, it will return instances created in previous calls. + /// + /// + /// An array of objects registered in the path. + /// + /// + /// This method can only be used if all nodes in the provided extension path + /// are of type Mono.Addins.TypeExtensionNode. The returned array is composed + /// by all objects created by calling the TypeExtensionNode.CreateInstance() + /// method for each node (or TypeExtensionNode.GetInstance() if + /// reuseCachedInstance is set to true). + /// + /// An InvalidOperationException exception is thrown if one of the found + /// objects is not a subclass of the provided type. + /// + public T[] GetExtensionObjects (string path, bool reuseCachedInstance) + { + ExtensionNode node = GetExtensionNode (path); + if (node == null) + throw new InvalidOperationException ("Extension node not found in path: " + path); + return node.GetChildObjects (reuseCachedInstance); + } + + /// + /// Gets extension objects registered in a path. + /// + /// + /// An extension path. + /// + /// + /// Type of the return array elements. + /// + /// + /// When set to True, it will return instances created in previous calls. + /// + /// + /// An array of objects registered in the path. + /// + /// + /// This method can only be used if all nodes in the provided extension path + /// are of type Mono.Addins.TypeExtensionNode. The returned array is composed + /// by all objects created by calling the TypeExtensionNode.CreateInstance() + /// method for each node (or TypeExtensionNode.GetInstance() if + /// reuseCachedInstance is set to true). + /// + /// An InvalidOperationException exception is thrown if one of the found + /// objects is not a subclass of the provided type. + /// public object[] GetExtensionObjects (string path, Type arrayElementType, bool reuseCachedInstance) { ExtensionNode node = GetExtensionNode (path); @@ -279,6 +684,23 @@ return node.GetChildObjects (arrayElementType, reuseCachedInstance); } + /// + /// Register a listener of extension node changes. + /// + /// + /// Path of the node. + /// + /// + /// A handler method. + /// + /// + /// Hosts can call this method to be subscribed to an extension change + /// event for a specific path. The event will be fired once for every + /// individual node change. The event arguments include the change type + /// (Add or Remove) and the extension node added or removed. + /// + /// NOTE: The handler will be called for all nodes existing in the path at the moment of registration. + /// public void AddExtensionNodeHandler (string path, ExtensionNodeEventHandler handler) { ExtensionNode node = GetExtensionNode (path); @@ -287,6 +709,18 @@ node.ExtensionNodeChanged += handler; } + /// + /// Unregister a listener of extension node changes. + /// + /// + /// Path of the node. + /// + /// + /// A handler method. + /// + /// + /// This method unregisters a delegate from the node change event of a path. + /// public void RemoveExtensionNodeHandler (string path, ExtensionNodeEventHandler handler) { ExtensionNode node = GetExtensionNode (path); @@ -295,6 +729,48 @@ node.ExtensionNodeChanged -= handler; } + /// + /// Register a listener of extension node changes. + /// + /// + /// Type defining the extension point + /// + /// + /// A handler method. + /// + /// + /// Hosts can call this method to be subscribed to an extension change + /// event for a specific type extension point. The event will be fired once for every + /// individual node change. The event arguments include the change type + /// (Add or Remove) and the extension node added or removed. + /// + /// NOTE: The handler will be called for all nodes existing in the path at the moment of registration. + /// + public void AddExtensionNodeHandler (Type instanceType, ExtensionNodeEventHandler handler) + { + string path = AddinEngine.GetAutoTypeExtensionPoint (instanceType); + if (path == null) + throw new InvalidOperationException ("Type '" + instanceType + "' not bound to an extension point."); + AddExtensionNodeHandler (path, handler); + } + + /// + /// Unregister a listener of extension node changes. + /// + /// + /// Type defining the extension point + /// + /// + /// A handler method. + /// + public void RemoveExtensionNodeHandler (Type instanceType, ExtensionNodeEventHandler handler) + { + string path = AddinEngine.GetAutoTypeExtensionPoint (instanceType); + if (path == null) + throw new InvalidOperationException ("Type '" + instanceType + "' not bound to an extension point."); + RemoveExtensionNodeHandler (path, handler); + } + void OnConditionChanged (object s, EventArgs a) { ConditionType cond = (ConditionType) s; @@ -380,9 +856,9 @@ try { fireEvents = true; - Addin addin = AddinManager.Registry.GetAddin (id); + Addin addin = AddinEngine.Registry.GetAddin (id); if (addin == null) { - AddinManager.ReportError ("Required add-in not found", id, null, false); + AddinEngine.ReportError ("Required add-in not found", id, null, false); return; } // Take note that this add-in has been enabled at run-time @@ -414,7 +890,7 @@ LoadModuleExtensionNodes (ext, data.AddinId, node.ExtensionNodeSet, loadedNodes); } else - AddinManager.ReportError ("Extension node not found or not extensible: " + ext.Path, id, null, false); + AddinEngine.ReportError ("Extension node not found or not extensible: " + ext.Path, id, null, false); } } } @@ -476,10 +952,14 @@ // The event is called for all extensions, even for those not loaded. This is for coherence, // although that something that it doesn't make much sense to do (subcribing the ExtensionChanged // event without first getting the list of nodes that may change). - Addin addin = AddinManager.Registry.GetAddin (id); + + // We get the runtime add-in because the add-in may already have been deleted from the registry + RuntimeAddin addin = AddinEngine.GetAddin (id); if (addin != null) { ArrayList paths = new ArrayList (); - foreach (ModuleDescription mod in addin.Description.AllModules) { + // Using addin.Module.ParentAddinDescription here because addin.Addin.Description may not + // have a valid reference (the description is lazy loaded and may already have been removed from the registry) + foreach (ModuleDescription mod in addin.Module.ParentAddinDescription.AllModules) { foreach (Extension ext in mod.Extensions) { if (!paths.Contains (ext.Path)) paths.Add (ext.Path); @@ -515,7 +995,7 @@ runTimeDisabledAddins.Remove (addinId); } - internal ICollection GetAddinsForPath (string path, StringCollection col) + internal ICollection GetAddinsForPath (string path, List col) { ArrayList newlist = null; @@ -570,7 +1050,7 @@ bool added = false; for (int n=0; n + /// Delegate to be used in extension point subscriptions + /// public delegate void ExtensionEventHandler (object sender, ExtensionEventArgs args); + + /// + /// Delegate to be used in extension point subscriptions + /// public delegate void ExtensionNodeEventHandler (object sender, ExtensionNodeEventArgs args); + /// + /// Arguments for extension events. + /// public class ExtensionEventArgs: EventArgs { string path; @@ -758,15 +1247,36 @@ { } + /// + /// Creates a new instance. + /// + /// + /// Path of the extension node that has changed. + /// public ExtensionEventArgs (string path) { this.path = path; } + /// + /// Path of the extension node that has changed. + /// public virtual string Path { get { return path; } } + /// + /// Checks if a path has changed. + /// + /// + /// An extension path. + /// + /// + /// 'true' if the path is affected by the extension change event. + /// + /// + /// Checks if the specified path or any of its children paths is affected by the extension change event. + /// public bool PathChanged (string pathToCheck) { if (pathToCheck.EndsWith ("/")) @@ -776,29 +1286,53 @@ } } + /// + /// Arguments for extension node events. + /// public class ExtensionNodeEventArgs: ExtensionEventArgs { ExtensionNode node; ExtensionChange change; + /// + /// Creates a new instance + /// + /// + /// Type of change. + /// + /// + /// Node that has been added or removed. + /// public ExtensionNodeEventArgs (ExtensionChange change, ExtensionNode node) { this.node = node; this.change = change; } + /// + /// Path of the extension that changed. + /// public override string Path { get { return node.Path; } } + /// + /// Type of change. + /// public ExtensionChange Change { get { return change; } } + /// + /// Node that has been added or removed. + /// public ExtensionNode ExtensionNode { get { return node; } } + /// + /// Extension object that has been added or removed. + /// public object ExtensionObject { get { InstanceExtensionNode tnode = node as InstanceExtensionNode; @@ -809,9 +1343,19 @@ } } + /// + /// Type of change in an extension change event. + /// public enum ExtensionChange { + /// + /// An extension node has been added. + /// Add, + + /// + /// An extension node has been removed. + /// Remove } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/ExtensionNodeAttribute.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/ExtensionNodeAttribute.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/ExtensionNodeAttribute.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/ExtensionNodeAttribute.cs 2011-04-13 09:00:29.000000000 +0000 @@ -31,35 +31,80 @@ namespace Mono.Addins { + /// + /// This attribute can be applied to an ExtensionNode subclass to specify the default name and description. + /// + /// + /// This information will be used when an extension point does not define a name or description for a node type. + /// [AttributeUsage (AttributeTargets.Class)] public class ExtensionNodeAttribute: Attribute { string nodeName; string description; + string customAttributeTypeName; + Type customAttributeType; + /// + /// Initializes the attribute + /// public ExtensionNodeAttribute () { } + /// + /// Initializes the attribute + /// + /// + /// Name of the node + /// public ExtensionNodeAttribute (string nodeName) { this.nodeName = nodeName; } + /// + /// Initializes the attribute + /// + /// + /// Name of the node + /// + /// + /// Description of the node + /// public ExtensionNodeAttribute (string nodeName, string description) { this.nodeName = nodeName; this.description = description; } + /// + /// Default name of the extension node + /// public string NodeName { get { return nodeName != null ? nodeName : string.Empty; } set { nodeName = value; } } + /// + /// Default description of the extension node type + /// public string Description { get { return description != null ? description : string.Empty; } set { description = value; } } + + /// + /// Type of a custom attribute which can be used to specify metadata for this extension node type + /// + public Type ExtensionAttributeType { + get { return customAttributeType; } + set { customAttributeType = value; customAttributeTypeName = value.FullName; } + } + + internal string ExtensionAttributeTypeName { + get { return customAttributeTypeName ?? string.Empty; } + set { customAttributeTypeName = value; } + } } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/ExtensionNodeChildAttribute.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/ExtensionNodeChildAttribute.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/ExtensionNodeChildAttribute.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/ExtensionNodeChildAttribute.cs 2011-04-13 09:00:29.000000000 +0000 @@ -31,6 +31,12 @@ namespace Mono.Addins { + /// + /// Declares allowed children of an extension node type. + /// + /// + /// This attribute allows declaring the type of children that an extension node can have. + /// [AttributeUsage (AttributeTargets.Class, AllowMultiple=true)] public class ExtensionNodeChildAttribute: Attribute { @@ -38,27 +44,54 @@ Type extensionNodeType; string extensionNodeTypeName; + /// + /// Initializes a new instance + /// + /// + /// Name of the allowed child extension node. + /// public ExtensionNodeChildAttribute (string nodeName) : this (typeof(TypeExtensionNode), nodeName) { } + /// + /// Initializes a new instance + /// + /// + /// Type of the allowed child extension node. + /// public ExtensionNodeChildAttribute (Type extensionNodeType) : this (extensionNodeType, null) { } + /// + /// Initializes a new instance + /// + /// + /// Type of the allowed child extension node. + /// + /// + /// Name of the allowed child extension node. + /// public ExtensionNodeChildAttribute (Type extensionNodeType, string nodeName) { - this.extensionNodeType = extensionNodeType; + ExtensionNodeType = extensionNodeType; this.nodeName = nodeName; } + /// + /// Name of the allowed child extension node. + /// public string NodeName { get { return nodeName != null ? nodeName : string.Empty; } set { nodeName = value; } } + /// + /// Type of the allowed child extension node. + /// public Type ExtensionNodeType { get { return extensionNodeType; } set { extensionNodeType = value; extensionNodeTypeName = value.FullName; } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/ExtensionNode.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/ExtensionNode.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/ExtensionNode.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/ExtensionNode.cs 2011-04-13 09:00:29.000000000 +0000 @@ -29,12 +29,25 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Xml; using System.Reflection; using Mono.Addins.Description; namespace Mono.Addins { + /// + /// A node of the extension model. + /// + /// + /// An extension node is an element registered by an add-in in an extension point. + /// A host can get nodes registered in an extension point using methods such as + /// AddinManager.GetExtensionNodes(string), which returns a collection of ExtensionNode objects. + /// + /// ExtensionNode will normally be used as a base class of more complex extension point types. + /// The most common subclass is Mono.Addins.TypeExtensionNode, which allows registering a class + /// implemented in an add-in. + /// public class ExtensionNode { bool childrenLoaded; @@ -43,16 +56,37 @@ RuntimeAddin addin; string addinId; ExtensionNodeType nodeType; + ModuleDescription module; + AddinEngine addinEngine; event ExtensionNodeEventHandler extensionNodeChanged; + /// + /// Identifier of the node. + /// + /// + /// It is not mandatory to specify an 'id' for a node. When none is provided, + /// the add-in manager will automatically generate an unique id for the node. + /// The ExtensionNode.HasId property can be used to know if the 'id' has been + /// specified by the developer or not. + /// public string Id { get { return treeNode != null ? treeNode.Id : string.Empty; } } + /// + /// Location of this node in the extension tree. + /// + /// + /// The node path is composed by the path of the extension point where it is defined, + /// the identifiers of its parent nodes, and its own identifier. + /// public string Path { get { return treeNode != null ? treeNode.GetPath () : string.Empty; } } + /// + /// Parent node of this node. + /// public ExtensionNode Parent { get { if (treeNode != null && treeNode.Parent != null) @@ -62,10 +96,22 @@ } } + /// + /// Extension context to which this node belongs + /// public ExtensionContext ExtensionContext { get { return treeNode.Context; } } + /// + /// Specifies whether the extension node has as an Id or not. + /// + /// + /// It is not mandatory to specify an 'id' for a node. When none is provided, + /// the add-in manager will automatically generate an unique id for the node. + /// This property will return true if an 'id' was provided for the node, and + /// false if the id was assigned by the add-in manager. + /// public bool HasId { get { return !Id.StartsWith (ExtensionTree.AutoIdPrefix); } } @@ -75,10 +121,12 @@ treeNode = node; } - internal void SetData (string plugid, ExtensionNodeType nodeType) + internal void SetData (AddinEngine addinEngine, string plugid, ExtensionNodeType nodeType, ModuleDescription module) { + this.addinEngine = addinEngine; this.addinId = plugid; this.nodeType = nodeType; + this.module = module; } internal string AddinId { @@ -89,12 +137,20 @@ get { return treeNode; } } + /// + /// The add-in that registered this extension node. + /// + /// + /// This property provides access to the resources and types of the add-in that created this extension node. + /// public RuntimeAddin Addin { get { if (addin == null && addinId != null) { - if (!AddinManager.SessionService.IsAddinLoaded (addinId)) - AddinManager.SessionService.LoadAddin (null, addinId, true); - addin = AddinManager.SessionService.GetAddin (addinId); + if (!addinEngine.IsAddinLoaded (addinId)) + addinEngine.LoadAddin (null, addinId, true); + addin = addinEngine.GetAddin (addinId); + if (addin != null) + addin = addin.GetModule (module); } if (addin == null) throw new InvalidOperationException ("Add-in '" + addinId + "' could not be loaded."); @@ -102,6 +158,12 @@ } } + /// + /// Notifies that a child node of this node has been added or removed. + /// + /// + /// The first time the event is subscribed, the handler will be called for each existing node. + /// public event ExtensionNodeEventHandler ExtensionNodeChanged { add { extensionNodeChanged += value; @@ -109,7 +171,7 @@ try { value (this, new ExtensionNodeEventArgs (ExtensionChange.Add, node)); } catch (Exception ex) { - AddinManager.ReportError (null, node.Addin != null ? node.Addin.Id : null, ex, false); + addinEngine.ReportError (null, node.Addin != null ? node.Addin.Id : null, ex, false); } } } @@ -118,6 +180,9 @@ } } + /// + /// Child nodes of this extension node. + /// public ExtensionNodeList ChildNodes { get { if (childrenLoaded) @@ -130,14 +195,14 @@ } } catch (Exception ex) { - AddinManager.ReportError (null, null, ex, false); + addinEngine.ReportError (null, null, ex, false); childNodes = ExtensionNodeList.Empty; return childNodes; } finally { childrenLoaded = true; } - ArrayList list = new ArrayList (); + List list = new List (); foreach (TreeNode cn in treeNode.Children) { // For each node check if it is visible for the current context. @@ -147,7 +212,7 @@ if (cn.ExtensionNode != null && cn.IsEnabled) list.Add (cn.ExtensionNode); } catch (Exception ex) { - AddinManager.ReportError (null, null, ex, false); + addinEngine.ReportError (null, null, ex, false); } } if (list.Count > 0) @@ -159,29 +224,130 @@ } } + /// + /// Returns the child objects of a node. + /// + /// + /// An array of child objects. + /// + /// + /// This method only works if all children of this node are of type Mono.Addins.TypeExtensionNode. + /// The returned array is composed by all objects created by calling the + /// TypeExtensionNode.GetInstance() method for each node. + /// public object[] GetChildObjects () { return GetChildObjects (typeof(object), true); } + /// + /// Returns the child objects of a node. + /// + /// + /// True if the method can reuse instances created in previous calls. + /// + /// + /// An array of child objects. + /// + /// + /// This method only works if all children of this node are of type Mono.Addins.TypeExtensionNode. + /// The returned array is composed by all objects created by calling the TypeExtensionNode.CreateInstance() + /// method for each node (or TypeExtensionNode.GetInstance() if reuseCachedInstance is set to true). + /// public object[] GetChildObjects (bool reuseCachedInstance) { return GetChildObjects (typeof(object), reuseCachedInstance); } + /// + /// Returns the child objects of a node (with type check). + /// + /// + /// Type of the return array elements. + /// + /// + /// An array of child objects. + /// + /// + /// This method only works if all children of this node are of type Mono.Addins.TypeExtensionNode. + /// The returned array is composed by all objects created by calling the + /// TypeExtensionNode.GetInstance(Type) method for each node. + /// + /// An InvalidOperationException exception is thrown if one of the found child objects is not a + /// subclass of the provided type. + /// public object[] GetChildObjects (Type arrayElementType) { return GetChildObjects (arrayElementType, true); } + /// + /// Returns the child objects of a node (casting to the specified type) + /// + /// + /// An array of child objects. + /// + /// + /// This method only works if all children of this node are of type Mono.Addins.TypeExtensionNode. + /// The returned array is composed by all objects created by calling the + /// TypeExtensionNode.GetInstance() method for each node. + /// + public T[] GetChildObjects () + { + return (T[]) GetChildObjectsInternal (typeof(T), true); + } + /// + /// Returns the child objects of a node (with type check). + /// + /// + /// Type of the return array elements. + /// + /// + /// True if the method can reuse instances created in previous calls. + /// + /// + /// An array of child objects. + /// + /// + /// This method only works if all children of this node are of type Mono.Addins.TypeExtensionNode. + /// The returned array is composed by all objects created by calling the TypeExtensionNode.CreateInstance(Type) + /// method for each node (or TypeExtensionNode.GetInstance(Type) if reuseCachedInstance is set to true). + /// + /// An InvalidOperationException exception will be thrown if one of the found child objects is not a subclass + /// of the provided type. + /// public object[] GetChildObjects (Type arrayElementType, bool reuseCachedInstance) { + return (object[]) GetChildObjectsInternal (arrayElementType, reuseCachedInstance); + } + + /// + /// Returns the child objects of a node (casting to the specified type). + /// + /// + /// True if the method can reuse instances created in previous calls. + /// + /// + /// An array of child objects. + /// + /// + /// This method only works if all children of this node are of type Mono.Addins.TypeExtensionNode. + /// The returned array is composed by all objects created by calling the TypeExtensionNode.CreateInstance() + /// method for each node (or TypeExtensionNode.GetInstance() if reuseCachedInstance is set to true). + /// + public T[] GetChildObjects (bool reuseCachedInstance) + { + return (T[]) GetChildObjectsInternal (typeof(T), reuseCachedInstance); + } + + Array GetChildObjectsInternal (Type arrayElementType, bool reuseCachedInstance) + { ArrayList list = new ArrayList (ChildNodes.Count); for (int n=0; n + /// Reads the extension node data + /// + /// + /// The element containing the extension data + /// + /// + /// This method can be overriden to provide a custom method for reading extension node data from an element. + /// The default implementation reads the attributes if the element and assigns the values to the fields + /// and properties of the extension node that have the corresponding [NodeAttribute] decoration. + /// internal protected virtual void Read (NodeElement elem) { - if (nodeType == null || nodeType.Fields == null) + if (nodeType == null) return; NodeAttribute[] attributes = elem.Attributes; - Hashtable fields = (Hashtable) nodeType.Fields.Clone (); + ReadObject (this, attributes, nodeType.Fields); + + if (nodeType.CustomAttributeMember != null) { + object att = Activator.CreateInstance (nodeType.CustomAttributeMember.MemberType); + ReadObject (att, attributes, nodeType.CustomAttributeFields); + nodeType.CustomAttributeMember.SetValue (this, att); + } + } + + void ReadObject (object ob, NodeAttribute[] attributes, Dictionary fields) + { + if (fields == null) + return; + + // Make a copy because we are going to remove fields that have been used + fields = new Dictionary (fields); foreach (NodeAttribute at in attributes) { - ExtensionNodeType.FieldData f = (ExtensionNodeType.FieldData) fields [at.name]; - if (f == null) + ExtensionNodeType.FieldData f; + if (!fields.TryGetValue (at.name, out f)) continue; fields.Remove (at.name); object val; + Type memberType = f.MemberType; - if (f.Field.FieldType == typeof(string)) { + if (memberType == typeof(string)) { if (f.Localizable) val = Addin.Localizer.GetString (at.value); else val = at.value; } - else if (f.Field.FieldType == typeof(string[])) { + else if (memberType == typeof(string[])) { string[] ss = at.value.Split (','); if (ss.Length == 0 && ss[0].Length == 0) val = new string [0]; @@ -232,24 +425,24 @@ val = ss; } } - else if (f.Field.FieldType.IsEnum) { - val = Enum.Parse (f.Field.FieldType, at.value); + else if (memberType.IsEnum) { + val = Enum.Parse (memberType, at.value); } else { try { - val = Convert.ChangeType (at.Value, f.Field.FieldType); + val = Convert.ChangeType (at.Value, memberType); } catch (InvalidCastException) { - throw new InvalidOperationException ("Property type not supported by [NodeAttribute]: " + f.Field.DeclaringType + "." + f.Field.Name); + throw new InvalidOperationException ("Property type not supported by [NodeAttribute]: " + f.Member.DeclaringType + "." + f.Member.Name); } } - - f.Field.SetValue (this, val); + + f.SetValue (ob, val); } if (fields.Count > 0) { // Check if one of the remaining fields is mandatory - foreach (DictionaryEntry e in fields) { - ExtensionNodeType.FieldData f = (ExtensionNodeType.FieldData) e.Value; + foreach (KeyValuePair e in fields) { + ExtensionNodeType.FieldData f = e.Value; if (f.Required) throw new InvalidOperationException ("Required attribute '" + e.Key + "' not found."); } @@ -283,34 +476,71 @@ return changed; } - // Called when the add-in that defined this extension node is actually - // loaded in memory. + /// + /// Called when the add-in that defined this extension node is actually loaded in memory. + /// internal protected virtual void OnAddinLoaded () { } - // Called when the add-in that defined this extension node is being - // unloaded from memory. + /// + /// Called when the add-in that defined this extension node is being + /// unloaded from memory. + /// internal protected virtual void OnAddinUnloaded () { } - // Called when the children list of this node has changed. It may be due to add-ins - // being loaded/unloaded, or to conditions being changed. + /// + /// Called when the children list of this node has changed. It may be due to add-ins + /// being loaded/unloaded, or to conditions being changed. + /// protected virtual void OnChildrenChanged () { } + /// + /// Called when a child node is added + /// + /// + /// Added node. + /// protected virtual void OnChildNodeAdded (ExtensionNode node) { if (extensionNodeChanged != null) extensionNodeChanged (this, new ExtensionNodeEventArgs (ExtensionChange.Add, node)); } + /// + /// Called when a child node is removed + /// + /// + /// Removed node. + /// protected virtual void OnChildNodeRemoved (ExtensionNode node) { if (extensionNodeChanged != null) extensionNodeChanged (this, new ExtensionNodeEventArgs (ExtensionChange.Remove, node)); } } + + /// + /// An extension node with custom metadata + /// + /// + /// This is the default type for extension nodes bound to a custom extension attribute. + /// + public class ExtensionNode: ExtensionNode where T:CustomExtensionAttribute + { + T data; + + /// + /// The custom attribute containing the extension metadata + /// + [NodeAttribute] + public T Data { + get { return data; } + internal set { data = value; } + } + } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/ExtensionNodeList.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/ExtensionNodeList.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/ExtensionNodeList.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/ExtensionNodeList.cs 2011-04-13 09:00:29.000000000 +0000 @@ -29,20 +29,30 @@ using System; using System.Collections; +using System.Collections.Generic; namespace Mono.Addins { + /// + /// A list of extension nodes. + /// public class ExtensionNodeList: IEnumerable { - internal ArrayList list; + internal List list; - internal static ExtensionNodeList Empty = new ExtensionNodeList (new ArrayList ()); + internal static ExtensionNodeList Empty = new ExtensionNodeList (new List ()); - internal ExtensionNodeList (ArrayList list) + internal ExtensionNodeList (List list) { this.list = list; } + /// + /// Returns the node in the specified index. + /// + /// + /// The index. + /// public ExtensionNode this [int n] { get { if (list == null) @@ -52,6 +62,12 @@ } } + /// + /// Returns the node with the specified ID. + /// + /// + /// An id. + /// public ExtensionNode this [string id] { get { if (list == null) @@ -64,19 +80,126 @@ } } } - + + /// + /// Gets an enumerator which enumerates all nodes in the list + /// public IEnumerator GetEnumerator () { + if (list == null) + return ((IList)Type.EmptyTypes).GetEnumerator (); + return list.GetEnumerator (); + } + + /// + /// Number of nodes of the collection. + /// + public int Count { + get { return list == null ? 0 : list.Count; } + } + + /// + /// Copies all nodes to an array + /// + /// + /// The target array + /// + /// + /// Initial index where to copy to + /// + public void CopyTo (ExtensionNode[] array, int index) + { + if (list != null) + list.CopyTo (array, index); + } + } + + /// + /// A list of extension nodes. + /// + public class ExtensionNodeList: IEnumerable, IEnumerable where T: ExtensionNode + { + List list; + + internal static ExtensionNodeList Empty = new ExtensionNodeList (new List ()); + + internal ExtensionNodeList (List list) + { + this.list = list; + } + + /// + /// Returns the node in the specified index. + /// + /// + /// The index. + /// + public T this [int n] { + get { + if (list == null) + throw new System.IndexOutOfRangeException (); + else + return (T) list [n]; + } + } + + /// + /// Returns the node with the specified ID. + /// + /// + /// An id. + /// + public T this [string id] { + get { + if (list == null) + return null; + else { + for (int n = list.Count - 1; n >= 0; n--) + if (list [n].Id == id) + return (T) list [n]; + return null; + } + } + } + + /// + /// Gets an enumerator which enumerates all nodes in the list + /// + public IEnumerator GetEnumerator () + { + if (list == null) + yield break; + foreach (ExtensionNode n in list) + yield return (T) n; + } + + IEnumerator IEnumerable.GetEnumerator () + { + if (list == null) + return ((IList)Type.EmptyTypes).GetEnumerator (); return list.GetEnumerator (); } + /// + /// Number of nodes of the collection. + /// public int Count { get { return list == null ? 0 : list.Count; } } - public void CopyTo (Array array, int index) + /// + /// Copies all nodes to an array + /// + /// + /// The target array + /// + /// + /// Initial index where to copy to + /// + public void CopyTo (T[] array, int index) { - list.CopyTo (array, index); + if (list != null) + list.CopyTo (array, index); } } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/ExtensionPointAttribute.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/ExtensionPointAttribute.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/ExtensionPointAttribute.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/ExtensionPointAttribute.cs 2011-04-13 09:00:29.000000000 +0000 @@ -31,6 +31,9 @@ namespace Mono.Addins { + /// + /// Declares an extension point. + /// [AttributeUsage (AttributeTargets.Assembly, AllowMultiple=true)] public class ExtensionPointAttribute: Attribute { @@ -42,22 +45,54 @@ Type objectType; string nodeTypeName; string objectTypeName; + Type customAttributeType; + string customAttributeTypeName; + /// + /// Initializes a new instance + /// public ExtensionPointAttribute () { } + /// + /// Initializes a new instance + /// + /// + /// Extension path that identifies the extension point + /// public ExtensionPointAttribute (string path) { this.path = path; } + /// + /// Initializes a new instance + /// + /// + /// Extension path that identifies the extension point + /// + /// + /// Type of the extension node to be created for extensions + /// public ExtensionPointAttribute (string path, Type nodeType) { this.path = path; this.nodeType = nodeType; } + /// + /// Initializes a new instance + /// + /// + /// Extension path that identifies the extension point + /// + /// + /// Element name to be used when defining an extension in an XML manifest. + /// + /// + /// Type of the extension node to be created for extensions + /// public ExtensionPointAttribute (string path, string nodeName, Type nodeType) { this.path = path; @@ -65,21 +100,33 @@ this.nodeName = nodeName; } + /// + /// Extension path that identifies the extension point + /// public string Path { get { return path != null ? path : string.Empty; } set { path = value; } } + /// + /// Long description of the extension point. + /// public string Description { get { return desc != null ? desc : string.Empty; } set { desc = value; } } + /// + /// Type of the extension node to be created for extensions + /// public Type NodeType { get { return nodeType != null ? nodeType : typeof(TypeExtensionNode); } set { nodeType = value; nodeTypeName = value.FullName; } } + /// + /// Expected extension object type (when nodes are of type TypeExtensionNode) + /// public Type ObjectType { get { return objectType; } set { objectType = value; objectTypeName = value.FullName; } @@ -95,14 +142,33 @@ set { objectTypeName = value; } } + /// + /// Element name to be used when defining an extension in an XML manifest. The default name is "Type". + /// public string NodeName { - get { return nodeName != null && nodeName.Length > 0 ? nodeName : "Type"; } + get { return nodeName != null && nodeName.Length > 0 ? nodeName : string.Empty; } set { nodeName = value; } } + /// + /// Display name of the extension point. + /// public string Name { get { return name != null ? name : string.Empty; } set { name = value; } } + + /// + /// Type of the custom attribute to be used to specify metadata for the extension point + /// + public Type ExtensionAttributeType { + get { return this.customAttributeType; } + set { this.customAttributeType = value; customAttributeTypeName = value.FullName; } + } + + internal string ExtensionAttributeTypeName { + get { return this.customAttributeTypeName; } + set { this.customAttributeTypeName = value; } + } } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/ExtensionTree.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/ExtensionTree.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/ExtensionTree.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/ExtensionTree.cs 2011-04-13 09:00:29.000000000 +0000 @@ -32,6 +32,7 @@ using System.Reflection; using System.Xml; using Mono.Addins.Description; +using System.Collections.Generic; namespace Mono.Addins { @@ -41,7 +42,7 @@ internal const string AutoIdPrefix = "__nid_"; ExtensionContext context; - public ExtensionTree (ExtensionContext context): base ("") + public ExtensionTree (AddinEngine addinEngine, ExtensionContext context): base (addinEngine, "") { this.context = context; } @@ -55,15 +56,15 @@ { TreeNode tnode = GetNode (extension.Path); if (tnode == null) { - AddinManager.ReportError ("Can't load extensions for path '" + extension.Path + "'. Extension point not defined.", addin, null, false); + addinEngine.ReportError ("Can't load extensions for path '" + extension.Path + "'. Extension point not defined.", addin, null, false); return; } int curPos = tnode.ChildCount; - LoadExtensionElement (tnode, addin, extension.ExtensionNodes, ref curPos, tnode.Condition, false, addedNodes); + LoadExtensionElement (tnode, addin, extension.ExtensionNodes, (ModuleDescription) extension.Parent, ref curPos, tnode.Condition, false, addedNodes); } - void LoadExtensionElement (TreeNode tnode, string addin, ExtensionNodeDescriptionCollection extension, ref int curPos, BaseCondition parentCondition, bool inComplextCondition, ArrayList addedNodes) + void LoadExtensionElement (TreeNode tnode, string addin, ExtensionNodeDescriptionCollection extension, ModuleDescription module, ref int curPos, BaseCondition parentCondition, bool inComplextCondition, ArrayList addedNodes) { foreach (ExtensionNodeDescription elem in extension) { @@ -74,13 +75,13 @@ } if (elem.NodeName == "ComplexCondition") { - LoadExtensionElement (tnode, addin, elem.ChildNodes, ref curPos, parentCondition, true, addedNodes); + LoadExtensionElement (tnode, addin, elem.ChildNodes, module, ref curPos, parentCondition, true, addedNodes); continue; } if (elem.NodeName == "Condition") { - Condition cond = new Condition (elem, parentCondition); - LoadExtensionElement (tnode, addin, elem.ChildNodes, ref curPos, cond, false, addedNodes); + Condition cond = new Condition (AddinEngine, elem, parentCondition); + LoadExtensionElement (tnode, addin, elem.ChildNodes, module, ref curPos, cond, false, addedNodes); continue; } @@ -98,10 +99,10 @@ } // Find the type of the node in this extension - ExtensionNodeType ntype = AddinManager.SessionService.FindType (tnode.ExtensionNodeSet, elem.NodeName, addin); + ExtensionNodeType ntype = addinEngine.FindType (tnode.ExtensionNodeSet, elem.NodeName, addin); if (ntype == null) { - AddinManager.ReportError ("Node '" + elem.NodeName + "' not allowed in extension: " + tnode.GetPath (), addin, null, false); + addinEngine.ReportError ("Node '" + elem.NodeName + "' not allowed in extension: " + tnode.GetPath (), addin, null, false); continue; } @@ -109,9 +110,9 @@ if (id.Length == 0) id = AutoIdPrefix + (++internalId); - TreeNode cnode = new TreeNode (id); + TreeNode cnode = new TreeNode (addinEngine, id); - ExtensionNode enode = ReadNode (cnode, addin, ntype, elem); + ExtensionNode enode = ReadNode (cnode, addin, ntype, elem, module); if (enode == null) continue; @@ -126,7 +127,7 @@ // Load children if (elem.ChildNodes.Count > 0) { int cp = 0; - LoadExtensionElement (cnode, addin, elem.ChildNodes, ref cp, parentCondition, false, addedNodes); + LoadExtensionElement (cnode, addin, elem.ChildNodes, module, ref cp, parentCondition, false, addedNodes); } curPos++; @@ -137,24 +138,31 @@ BaseCondition ReadComplexCondition (ExtensionNodeDescription elem, BaseCondition parentCondition) { - if (elem.NodeName == "Or" || elem.NodeName == "And") { + if (elem.NodeName == "Or" || elem.NodeName == "And" || elem.NodeName == "Not") { ArrayList conds = new ArrayList (); foreach (ExtensionNodeDescription celem in elem.ChildNodes) { conds.Add (ReadComplexCondition (celem, null)); } if (elem.NodeName == "Or") return new OrCondition ((BaseCondition[]) conds.ToArray (typeof(BaseCondition)), parentCondition); - else + else if (elem.NodeName == "And") return new AndCondition ((BaseCondition[]) conds.ToArray (typeof(BaseCondition)), parentCondition); + else { + if (conds.Count != 1) { + addinEngine.ReportError ("Invalid complex condition element '" + elem.NodeName + "'. 'Not' condition can only have one parameter.", null, null, false); + return new NullCondition (); + } + return new NotCondition ((BaseCondition) conds [0], parentCondition); + } } if (elem.NodeName == "Condition") { - return new Condition (elem, parentCondition); + return new Condition (AddinEngine, elem, parentCondition); } - AddinManager.ReportError ("Invalid complex condition element '" + elem.NodeName + "'.", null, null, false); + addinEngine.ReportError ("Invalid complex condition element '" + elem.NodeName + "'.", null, null, false); return new NullCondition (); } - public ExtensionNode ReadNode (TreeNode tnode, string addin, ExtensionNodeType ntype, ExtensionNodeDescription elem) + public ExtensionNode ReadNode (TreeNode tnode, string addin, ExtensionNodeType ntype, ExtensionNodeDescription elem, ModuleDescription module) { try { if (ntype.Type == null) { @@ -165,76 +173,134 @@ ExtensionNode node; node = Activator.CreateInstance (ntype.Type) as ExtensionNode; if (node == null) { - AddinManager.ReportError ("Extension node type '" + ntype.Type + "' must be a subclass of ExtensionNode", addin, null, false); + addinEngine.ReportError ("Extension node type '" + ntype.Type + "' must be a subclass of ExtensionNode", addin, null, false); return null; } tnode.AttachExtensionNode (node); - node.SetData (addin, ntype); + node.SetData (addinEngine, addin, ntype, module); node.Read (elem); return node; } catch (Exception ex) { - AddinManager.ReportError ("Could not read extension node of type '" + ntype.Type + "' from extension path '" + tnode.GetPath() + "'", addin, ex, false); + addinEngine.ReportError ("Could not read extension node of type '" + ntype.Type + "' from extension path '" + tnode.GetPath() + "'", addin, ex, false); return null; } } bool InitializeNodeType (ExtensionNodeType ntype) { - RuntimeAddin p = AddinManager.SessionService.GetAddin (ntype.AddinId); + RuntimeAddin p = addinEngine.GetAddin (ntype.AddinId); if (p == null) { - if (!AddinManager.SessionService.IsAddinLoaded (ntype.AddinId)) { - if (!AddinManager.SessionService.LoadAddin (null, ntype.AddinId, false)) + if (!addinEngine.IsAddinLoaded (ntype.AddinId)) { + if (!addinEngine.LoadAddin (null, ntype.AddinId, false)) return false; - p = AddinManager.SessionService.GetAddin (ntype.AddinId); + p = addinEngine.GetAddin (ntype.AddinId); if (p == null) { - AddinManager.ReportError ("Add-in not found", ntype.AddinId, null, false); + addinEngine.ReportError ("Add-in not found", ntype.AddinId, null, false); return false; } } } // If no type name is provided, use TypeExtensionNode by default - if (ntype.TypeName == null || ntype.TypeName.Length == 0) { - ntype.Type = typeof(TypeExtensionNode); - return true; + if (ntype.TypeName == null || ntype.TypeName.Length == 0 || ntype.TypeName == typeof(TypeExtensionNode).FullName) { + // If it has a custom attribute, use the generic version of TypeExtensionNode + if (ntype.ExtensionAttributeTypeName.Length > 0) { + Type attType = p.GetType (ntype.ExtensionAttributeTypeName, false); + if (attType == null) { + addinEngine.ReportError ("Custom attribute type '" + ntype.ExtensionAttributeTypeName + "' not found.", ntype.AddinId, null, false); + return false; + } + if (ntype.ObjectTypeName.Length > 0) + ntype.Type = typeof(TypeExtensionNode<>).MakeGenericType (attType); + else + ntype.Type = typeof(ExtensionNode<>).MakeGenericType (attType); + } else { + ntype.Type = typeof(TypeExtensionNode); + return true; + } + } + else { + ntype.Type = p.GetType (ntype.TypeName, false); + if (ntype.Type == null) { + addinEngine.ReportError ("Extension node type '" + ntype.TypeName + "' not found.", ntype.AddinId, null, false); + return false; + } } - ntype.Type = p.GetType (ntype.TypeName, false); - if (ntype.Type == null) { - AddinManager.ReportError ("Extension node type '" + ntype.TypeName + "' not found.", ntype.AddinId, null, false); - return false; + // Check if the type has NodeAttribute attributes applied to fields. + ExtensionNodeType.FieldData boundAttributeType = null; + Dictionary fields = GetMembersMap (ntype.Type, out boundAttributeType); + ntype.CustomAttributeMember = boundAttributeType; + if (fields.Count > 0) + ntype.Fields = fields; + + // If the node type is bound to a custom attribute and there is a member bound to that attribute, + // get the member map for the attribute. + + if (boundAttributeType != null) { + if (ntype.ExtensionAttributeTypeName.Length == 0) + throw new InvalidOperationException ("Extension node not bound to a custom attribute."); + if (ntype.ExtensionAttributeTypeName != boundAttributeType.MemberType.FullName) + throw new InvalidOperationException ("Incorrect custom attribute type declaration in " + ntype.Type + ". Expected '" + ntype.ExtensionAttributeTypeName + "' found '" + boundAttributeType.MemberType.FullName + "'"); + + fields = GetMembersMap (boundAttributeType.MemberType, out boundAttributeType); + if (fields.Count > 0) + ntype.CustomAttributeFields = fields; } - Hashtable fields = new Hashtable (); + return true; + } + + Dictionary GetMembersMap (Type type, out ExtensionNodeType.FieldData boundAttributeType) + { + string fname; + Dictionary fields = new Dictionary (); + boundAttributeType = null; - // Check if the type has NodeAttribute attributes applied to fields. - Type type = ntype.Type; while (type != typeof(object) && type != null) { foreach (FieldInfo field in type.GetFields (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)) { NodeAttributeAttribute at = (NodeAttributeAttribute) Attribute.GetCustomAttribute (field, typeof(NodeAttributeAttribute), true); if (at != null) { - ExtensionNodeType.FieldData fdata = new ExtensionNodeType.FieldData (); - fdata.Field = field; - fdata.Required = at.Required; - fdata.Localizable = at.Localizable; - - string name; - if (at.Name != null && at.Name.Length > 0) - name = at.Name; - else - name = field.Name; - - fields [name] = fdata; + ExtensionNodeType.FieldData fd = CreateFieldData (field, at, out fname, ref boundAttributeType); + if (fd != null) + fields [fname] = fd; + } + } + foreach (PropertyInfo prop in type.GetProperties (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)) { + NodeAttributeAttribute at = (NodeAttributeAttribute) Attribute.GetCustomAttribute (prop, typeof(NodeAttributeAttribute), true); + if (at != null) { + ExtensionNodeType.FieldData fd = CreateFieldData (prop, at, out fname, ref boundAttributeType); + if (fd != null) + fields [fname] = fd; } } type = type.BaseType; } - if (fields.Count > 0) - ntype.Fields = fields; - - return true; + return fields; + } + + ExtensionNodeType.FieldData CreateFieldData (MemberInfo member, NodeAttributeAttribute at, out string name, ref ExtensionNodeType.FieldData boundAttributeType) + { + ExtensionNodeType.FieldData fdata = new ExtensionNodeType.FieldData (); + fdata.Member = member; + fdata.Required = at.Required; + fdata.Localizable = at.Localizable; + + if (at.Name != null && at.Name.Length > 0) + name = at.Name; + else + name = member.Name; + + if (typeof(CustomExtensionAttribute).IsAssignableFrom (fdata.MemberType)) { + if (boundAttributeType != null) + throw new InvalidOperationException ("Type '" + member.DeclaringType + "' has two members bound to a custom attribute. There can be only one."); + boundAttributeType = fdata; + return null; + } + + return fdata; } } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/IAddinInstaller.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/IAddinInstaller.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/IAddinInstaller.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/IAddinInstaller.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,8 +4,23 @@ namespace Mono.Addins { + /// + /// An add-in installation handler + /// public interface IAddinInstaller { + /// + /// Installs a set of add-ins + /// + /// + /// Registry where to install + /// + /// + /// Message to show to the user when new add-ins have to be installed. + /// + /// + /// List of IDs of the add-ins to be installed. + /// void InstallAddins (AddinRegistry reg, string message, string[] addinIds); } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/ImportAddinAssemblyAttribute.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/ImportAddinAssemblyAttribute.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/ImportAddinAssemblyAttribute.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/ImportAddinAssemblyAttribute.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,79 @@ +// +// ImportAddinAssemblyAttribute.cs +// +// Author: +// Lluis Sanchez Gual +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; + +namespace Mono.Addins +{ + /// + /// Declares an add-in assembly import + /// + /// + /// An add-in may be composed by several assemblies and data files. + /// Assemblies must be declared in the main assembly using this attribute, or in the XML manifest. + /// + /// It is important to properly declare all files used by an add-in. + /// For example, when a type from the add-in is required (e.g. an ICommand implementation), + /// only properly declared assemblies will be checked. + /// This information is also used by setup tools to know exactly what needs to be packaged when creating + /// an add-in package, or to know what needs to be deleted when removing an add-in. + /// + [AttributeUsage (AttributeTargets.Assembly, AllowMultiple = true)] + public class ImportAddinAssemblyAttribute: Attribute + { + string filePath; + bool scan = true; + + /// + /// Initializes a new instance + /// + /// + /// Path to the assembly. Must be relative to the assembly declaring this attribute. + /// + public ImportAddinAssemblyAttribute (string filePath) + { + this.filePath = filePath; + } + + /// + /// Path to the assembly. Must be relative to the assembly declaring this attribute. + /// + public string FilePath { + get { return filePath; } + set { filePath = value; } + } + + /// + /// When set to true (the default), the included assembly will be scanned + /// looking for extension point declarations. + /// + public bool Scan { + get { return this.scan; } + set { this.scan = value; } + } + } +} + diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/ImportAddinFileAttribute.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/ImportAddinFileAttribute.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/ImportAddinFileAttribute.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/ImportAddinFileAttribute.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,67 @@ +// +// ImportAddinFileAttribute.cs +// +// Author: +// Lluis Sanchez Gual +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; + +namespace Mono.Addins +{ + /// + /// Declares an add-in file import + /// + /// + /// An add-in may be composed by several assemblies and data files. + /// Data files must be declared in the main assembly using this attribute, or in the XML manifest. + /// + /// It is important to properly declare all files used by an add-in. + /// This information is used by setup tools to know exactly what needs to be packaged when creating + /// an add-in package, or to know what needs to be deleted when removing an add-in. + /// + [AttributeUsage (AttributeTargets.Assembly, AllowMultiple = true)] + public class ImportAddinFileAttribute: Attribute + { + string filePath; + + /// + /// Initializes a new instance + /// + /// + /// Path to the file. Must be relative to the assembly declaring this attribute. + /// + public ImportAddinFileAttribute (string filePath) + { + this.filePath = filePath; + } + + /// + /// Path to the file. Must be relative to the assembly declaring this attribute. + /// + public string FilePath { + get { return filePath; } + set { filePath = value; } + } + } +} + diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/InstanceExtensionNode.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/InstanceExtensionNode.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/InstanceExtensionNode.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/InstanceExtensionNode.cs 2011-04-13 09:00:29.000000000 +0000 @@ -31,10 +31,25 @@ namespace Mono.Addins { + /// + /// Base class for extension nodes which create extension objects + /// public abstract class InstanceExtensionNode: ExtensionNode { object cachedInstance; + /// + /// Gets the extension object declared by this node + /// + /// + /// Expected object type. An exception will be thrown if the object is not an instance of the specified type. + /// + /// + /// The extension object + /// + /// + /// The extension object is cached and the same instance will be returned at every call. + /// public object GetInstance (Type expectedType) { object ob = GetInstance (); @@ -43,13 +58,31 @@ return ob; } + /// + /// Gets the extension object declared by this node + /// + /// + /// The extension object + /// + /// + /// The extension object is cached and the same instance will be returned at every call. + /// public object GetInstance () { if (cachedInstance == null) cachedInstance = CreateInstance (); return cachedInstance; } - + + /// + /// Creates a new extension object + /// + /// + /// Expected object type. An exception will be thrown if the object is not an instance of the specified type. + /// + /// + /// The extension object + /// public object CreateInstance (Type expectedType) { object ob = CreateInstance (); @@ -58,6 +91,12 @@ return ob; } + /// + /// Creates a new extension object + /// + /// + /// The extension object + /// public abstract object CreateInstance (); } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/IProgressStatus.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/IProgressStatus.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/IProgressStatus.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/IProgressStatus.cs 2011-04-13 09:00:29.000000000 +0000 @@ -31,18 +31,79 @@ namespace Mono.Addins { + /// + /// Progress status listener. + /// public interface IProgressStatus { + /// + /// Sets the description of the current operation. + /// + /// + /// A message + /// + /// + /// This method is called by the add-in engine to show a description of the operation being monitorized. + /// void SetMessage (string msg); + + /// + /// Sets the progress of the operation. + /// + /// + /// A number between 0 and 1. 0 means no progress, 1 means operation completed. + /// + /// + /// This method is called by the add-in engine to show the progress of the operation being monitorized. + /// void SetProgress (double progress); + /// + /// Writes text to the log. + /// + /// + /// Message to write + /// void Log (string msg); - int LogLevel { get; } // 0: no log, 1: normal log, >1 verbose log + /// + /// Log level requested by the user: 0: no log, 1: normal log, >1 verbose log + /// + int LogLevel { get; } + + /// + /// Reports a warning. + /// + /// + /// Warning message + /// + /// + /// This method is called by the add-in engine to report a warning in the operation being monitorized. + /// void ReportWarning (string message); + + /// + /// Reports an error. + /// + /// + /// Error message + /// + /// + /// Exception that caused the error. It can be null. + /// + /// + /// This method is called by the add-in engine to report an error occurred while executing the operation being monitorized. + /// void ReportError (string message, Exception exception); + /// + /// Returns True when the user requested to cancel this operation + /// bool IsCanceled { get; } + + /// + /// Cancels the operation being montorized. + /// void Cancel (); } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/MissingDependencyException.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/MissingDependencyException.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/MissingDependencyException.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/MissingDependencyException.cs 2011-04-13 09:00:29.000000000 +0000 @@ -32,6 +32,9 @@ namespace Mono.Addins { + /// + /// Exception thrown when the add-in engine can't find a required add-in dependency + /// [Serializable] internal class MissingDependencyException: Exception { diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/NodeAttributeAttribute.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/NodeAttributeAttribute.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/NodeAttributeAttribute.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/NodeAttributeAttribute.cs 2011-04-13 09:00:29.000000000 +0000 @@ -31,7 +31,10 @@ namespace Mono.Addins { - [AttributeUsage (AttributeTargets.Class | AttributeTargets.Field, AllowMultiple=true)] + /// + /// Indicates that a field or property is bound to a node attribute + /// + [AttributeUsage (AttributeTargets.Class | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple=true)] public class NodeAttributeAttribute: Attribute { string name; @@ -41,25 +44,64 @@ string typeName; string description; + /// + /// Initializes a new instance + /// public NodeAttributeAttribute () { } + /// + /// Initializes a new instance + /// + /// + /// XML name of the attribute. + /// public NodeAttributeAttribute (string name) :this (name, false, null) { } + /// + /// Initializes a new instance + /// + /// + /// XML name of the attribute. + /// + /// + /// Description of the attribute. + /// public NodeAttributeAttribute (string name, string description) :this (name, false, description) { } + /// + /// Initializes a new instance + /// + /// + /// XML name of the attribute. + /// + /// + /// Indicates whether the attribute is required or not. + /// public NodeAttributeAttribute (string name, bool required) : this (name, required, null) { } + /// + /// Initializes a new instance + /// + /// + /// XML name of the attribute. + /// + /// + /// Indicates whether the attribute is required or not. + /// + /// + /// Description of the attribute. + /// public NodeAttributeAttribute (string name, bool required, string description) { this.name = name; @@ -67,21 +109,85 @@ this.description = description; } + /// + /// Initializes a new instance + /// + /// + /// XML name of the attribute. + /// + /// + /// Type of the extension node attribute. + /// + /// + /// The type of the attribute is only required when applying this attribute at class level. + /// It is not required when it is applied to a field, since the attribute type will be the type of the field. + /// public NodeAttributeAttribute (string name, Type type) : this (name, type, false, null) { } + /// + /// Initializes a new instance + /// + /// + /// XML name of the attribute. + /// + /// + /// Type of the extension node attribute. + /// + /// + /// Description of the attribute. + /// + /// + /// The type of the attribute is only required when applying this attribute at class level. + /// It is not required when it is applied to a field, since the attribute type will be the type of the field. + /// public NodeAttributeAttribute (string name, Type type, string description) : this (name, type, false, description) { } + /// + /// Initializes a new instance + /// + /// + /// XML name of the attribute. + /// + /// + /// Type of the extension node attribute. + /// + /// + /// Indicates whether the attribute is required or not. + /// + /// + /// The type of the attribute is only required when applying this attribute at class level. + /// It is not required when it is applied to a field, since the attribute type will be the type of the field. + /// public NodeAttributeAttribute (string name, Type type, bool required) : this (name, type, false, null) { } + /// + /// Initializes a new instance + /// + /// + /// XML name of the attribute. + /// + /// + /// Type of the extension node attribute. + /// + /// + /// Indicates whether the attribute is required or not. + /// + /// + /// Description of the attribute. + /// + /// + /// The type of the attribute is only required when applying this attribute at class level. + /// It is not required when it is applied to a field, since the attribute type will be the type of the field. + /// public NodeAttributeAttribute (string name, Type type, bool required, string description) { this.name = name; @@ -90,16 +196,34 @@ this.description = description; } + /// + /// XML name of the attribute. + /// + /// + /// If the name is not specified, the field name to which the [NodeAttribute] + /// is applied will be used as name. Providing a name is mandatory when applying + /// [NodeAttribute] at class level. + /// public string Name { get { return name != null ? name : string.Empty; } set { name = value; } } + /// + /// Indicates whether the attribute is required or not. + /// public bool Required { get { return required; } set { required = value; } } + /// + /// Type of the extension node attribute. + /// + /// + /// To be used only when applying [NodeAttribute] at class level. It is not required when it + /// is applied to a field, since the attribute type will be the type of the field. + /// public Type Type { get { return type; } set { type = value; typeName = type.FullName; } @@ -110,14 +234,33 @@ set { typeName = value; type = null; } } + /// + /// Description of the attribute. + /// + /// + /// To be used in the extension point documentation. + /// public string Description { get { return description != null ? description : string.Empty; } set { description = value; } } + /// + /// When set to True, the value of the field or property is expected to be a string id which + /// will be localized by the add-in engine + /// public bool Localizable { get { return localizable; } set { localizable = value; } } + + /// + /// Gets or sets the type of the content. + /// + /// + /// Allows specifying the type of the content of a string attribute. + /// This value is for documentation purposes only. + /// + public ContentType ContentType { get; set; } } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/NodeElement.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/NodeElement.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/NodeElement.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/NodeElement.cs 2011-04-13 09:00:29.000000000 +0000 @@ -32,14 +32,45 @@ namespace Mono.Addins { + /// + /// An extension node element. + /// + /// + /// A raw representation of an extension node. Contains the basic information + /// needed to create ExtensionNode instances. + /// public interface NodeElement { + /// + /// Name of the node element. + /// string NodeName { get; } + + /// + /// Gets element attributes. + /// + /// + /// Name of the attribute + /// + /// + /// The value of the attribute + /// string GetAttribute (string key); + + /// + /// Gets all attributes defined in the element. + /// NodeAttribute[] Attributes { get; } + + /// + /// Gets child nodes of this node + /// NodeElementCollection ChildNodes { get; } } + /// + /// Attribute of a NodeElement. + /// public class NodeAttribute { internal string name; @@ -49,17 +80,32 @@ { } + /// + /// Name of the attribute. + /// public string Name { get { return name; } } + /// + /// Value of the attribute. + /// public string Value { get { return value; } } } + /// + /// A collection of NodeElement objects + /// public interface NodeElementCollection: IList, ICollection, IEnumerable { + /// + /// Gets the at the specified index + /// + /// + /// Index + /// new NodeElement this [int n] { get; } } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/RuntimeAddin.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/RuntimeAddin.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/RuntimeAddin.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/RuntimeAddin.cs 2011-04-13 09:00:29.000000000 +0000 @@ -30,6 +30,7 @@ using System; using System.Collections; +using System.Collections.Generic; using System.IO; using System.Reflection; using System.Xml; @@ -41,30 +42,63 @@ namespace Mono.Addins { + /// + /// Run-time representation of an add-in. + /// public class RuntimeAddin { string id; string baseDirectory; string privatePath; Addin ainfo; + RuntimeAddin parentAddin; Assembly[] assemblies; RuntimeAddin[] depAddins; ResourceManager[] resourceManagers; AddinLocalizer localizer; + ModuleDescription module; + AddinEngine addinEngine; - internal RuntimeAddin() + internal RuntimeAddin (AddinEngine addinEngine) { + this.addinEngine = addinEngine; + } + + internal RuntimeAddin (AddinEngine addinEngine, RuntimeAddin parentAddin, ModuleDescription module) + { + this.addinEngine = addinEngine; + this.parentAddin = parentAddin; + this.module = module; + id = parentAddin.id; + baseDirectory = parentAddin.baseDirectory; + privatePath = parentAddin.privatePath; + ainfo = parentAddin.ainfo; + localizer = parentAddin.localizer; + module.RuntimeAddin = this; + } + + internal ModuleDescription Module { + get { return module; } } internal Assembly[] Assemblies { - get { return assemblies; } + get { + EnsureAssembliesLoaded (); + return assemblies; + } } + /// + /// Identifier of the add-in. + /// public string Id { get { return Addin.GetIdName (id); } } + /// + /// Version of the add-in. + /// public string Version { get { return Addin.GetIdVersion (id); } } @@ -72,14 +106,24 @@ internal Addin Addin { get { return ainfo; } } - + + /// + /// Returns a string that represents the current RuntimeAddin. + /// + /// + /// A string that represents the current RuntimeAddin. + /// public override string ToString () { return ainfo.ToString (); } - void CreateResourceManagers () + ResourceManager[] GetResourceManagers () { + if (resourceManagers != null) + return resourceManagers; + + EnsureAssembliesLoaded (); ArrayList managersList = new ArrayList (); // Search for embedded resource files @@ -91,50 +135,135 @@ } } - resourceManagers = (ResourceManager[]) managersList.ToArray (typeof(ResourceManager)); + return resourceManagers = (ResourceManager[]) managersList.ToArray (typeof(ResourceManager)); } + /// + /// Gets a resource string + /// + /// + /// Name of the resource + /// + /// + /// The value of the resource string, or null if the resource can't be found. + /// + /// + /// The add-in engine will look for resources in the main add-in assembly and in all included add-in assemblies. + /// public string GetResourceString (string name) { return (string) GetResourceObject (name, true, null); } + /// + /// Gets a resource string + /// + /// + /// Name of the resource + /// + /// + /// When set to true, an exception will be thrown if the resource is not found. + /// + /// + /// The value of the resource string + /// + /// + /// The add-in engine will look for resources in the main add-in assembly and in all included add-in assemblies. + /// public string GetResourceString (string name, bool throwIfNotFound) { return (string) GetResourceObject (name, throwIfNotFound, null); } + /// + /// Gets a resource string + /// + /// + /// Name of the resource + /// + /// + /// When set to true, an exception will be thrown if the resource is not found. + /// + /// + /// Culture of the resource + /// + /// + /// The value of the resource string + /// + /// + /// The add-in engine will look for resources in the main add-in assembly and in all included add-in assemblies. + /// public string GetResourceString (string name, bool throwIfNotFound, CultureInfo culture) { return (string) GetResourceObject (name, throwIfNotFound, culture); } + /// + /// Gets a resource object + /// + /// + /// Name of the resource + /// + /// + /// Value of the resource + /// + /// + /// The add-in engine will look for resources in the main add-in assembly and in all included add-in assemblies. + /// public object GetResourceObject (string name) { return GetResourceObject (name, true, null); } + /// + /// Gets a resource object + /// + /// + /// Name of the resource + /// + /// + /// When set to true, an exception will be thrown if the resource is not found. + /// + /// + /// Value of the resource + /// + /// + /// The add-in engine will look for resources in the main add-in assembly and in all included add-in assemblies. + /// public object GetResourceObject (string name, bool throwIfNotFound) { return GetResourceObject (name, throwIfNotFound, null); } + /// + /// Gets a resource object + /// + /// + /// Name of the resource + /// + /// + /// When set to true, an exception will be thrown if the resource is not found. + /// + /// + /// Culture of the resource + /// + /// + /// Value of the resource + /// + /// + /// The add-in engine will look for resources in the main add-in assembly and in all included add-in assemblies. + /// public object GetResourceObject (string name, bool throwIfNotFound, CultureInfo culture) { - if (resourceManagers == null) - CreateResourceManagers (); - // Look in resources of this add-in - foreach (ResourceManager manager in resourceManagers) - { + foreach (ResourceManager manager in GetAllResourceManagers ()) { object t = manager.GetObject (name, culture); if (t != null) return t; } // Look in resources of dependent add-ins - foreach (RuntimeAddin addin in depAddins) - { + foreach (RuntimeAddin addin in GetAllDependencies ()) { object t = addin.GetResourceObject (name, false, culture); if (t != null) return t; @@ -146,28 +275,63 @@ return null; } - + /// + /// Gets a type defined in the add-in + /// + /// + /// Full name of the type + /// + /// + /// A type. + /// + /// + /// The type will be looked up in the assemblies that implement the add-in, + /// and recursivelly in all add-ins on which it depends. + /// + /// This method throws an InvalidOperationException if the type can't be found. + /// public Type GetType (string typeName) { return GetType (typeName, true); } + /// + /// Gets a type defined in the add-in + /// + /// + /// Full name of the type + /// + /// + /// Indicates whether the method should throw an exception if the type can't be found. + /// + /// + /// A + /// + /// + /// The type will be looked up in the assemblies that implement the add-in, + /// and recursivelly in all add-ins on which it depends. + /// + /// If the type can't be found, this method throw a InvalidOperationException if + /// 'throwIfNotFound' is 'true', or 'null' otherwise. + /// public Type GetType (string typeName, bool throwIfNotFound) { + EnsureAssembliesLoaded (); + // Look in the addin assemblies Type at = Type.GetType (typeName, false); if (at != null) return at; - foreach (Assembly asm in assemblies) { + foreach (Assembly asm in GetAllAssemblies ()) { Type t = asm.GetType (typeName, false); if (t != null) return t; } // Look in the dependent add-ins - foreach (RuntimeAddin addin in depAddins) { + foreach (RuntimeAddin addin in GetAllDependencies ()) { Type t = addin.GetType (typeName, false); if (t != null) return t; @@ -178,11 +342,86 @@ return null; } + IEnumerable GetAllResourceManagers () + { + foreach (ResourceManager rm in GetResourceManagers ()) + yield return rm; + + if (parentAddin != null) { + foreach (ResourceManager rm in parentAddin.GetResourceManagers ()) + yield return rm; + } + } + + IEnumerable GetAllAssemblies () + { + foreach (Assembly asm in Assemblies) + yield return asm; + + // Look in the parent addin assemblies + + if (parentAddin != null) { + foreach (Assembly asm in parentAddin.Assemblies) + yield return asm; + } + } + + IEnumerable GetAllDependencies () + { + // Look in the dependent add-ins + foreach (RuntimeAddin addin in GetDepAddins ()) + yield return addin; + + if (parentAddin != null) { + // Look in the parent dependent add-ins + foreach (RuntimeAddin addin in parentAddin.GetDepAddins ()) + yield return addin; + } + } + + /// + /// Creates an instance of a type defined in the add-in + /// + /// + /// Name of the type. + /// + /// + /// A new instance of the type + /// + /// + /// The type will be looked up in the assemblies that implement the add-in, + /// and recursivelly in all add-ins on which it depends. + /// + /// This method throws an InvalidOperationException if the type can't be found. + /// + /// The specified type must have a default constructor. + /// public object CreateInstance (string typeName) { return CreateInstance (typeName, true); } + /// + /// Creates an instance of a type defined in the add-in + /// + /// + /// Name of the type. + /// + /// + /// Indicates whether the method should throw an exception if the type can't be found. + /// + /// + /// A new instance of the type + /// + /// + /// The type will be looked up in the assemblies that implement the add-in, + /// and recursivelly in all add-ins on which it depends. + /// + /// If the type can't be found, this method throw a InvalidOperationException if + /// 'throwIfNotFound' is 'true', or 'null' otherwise. + /// + /// The specified type must have a default constructor. + /// public object CreateInstance (string typeName, bool throwIfNotFound) { Type type = GetType (typeName, throwIfNotFound); @@ -192,11 +431,43 @@ return Activator.CreateInstance (type, true); } + /// + /// Gets the path of an add-in file + /// + /// + /// Relative path of the file + /// + /// + /// Full path of the file + /// + /// + /// This method can be used to get the full path of a data file deployed together with the add-in. + /// public string GetFilePath (string fileName) { return Path.Combine (baseDirectory, fileName); } - + + /// + /// Gets the path of an add-in file + /// + /// + /// Components of the file path + /// + /// + /// Full path of the file + /// + /// + /// This method can be used to get the full path of a data file deployed together with the add-in. + /// + public string GetFilePath (params string[] filePath) + { + return Path.Combine (baseDirectory, string.Join ("" + Path.DirectorySeparatorChar, filePath)); + } + + /// + /// Path to a directory where add-ins can store private configuration or status data + /// public string PrivateDataPath { get { if (privatePath == null) { @@ -208,23 +479,52 @@ } } + /// + /// Gets the content of a resource + /// + /// + /// Name of the resource + /// + /// + /// Content of the resource, or null if not found + /// + /// + /// The add-in engine will look for resources in the main add-in assembly and in all included add-in assemblies. + /// public Stream GetResource (string resourceName) { return GetResource (resourceName, false); } + /// + /// Gets the content of a resource + /// + /// + /// Name of the resource + /// + /// + /// When set to true, an exception will be thrown if the resource is not found. + /// + /// + /// Content of the resource. + /// + /// + /// The add-in engine will look for resources in the main add-in assembly and in all included add-in assemblies. + /// public Stream GetResource (string resourceName, bool throwIfNotFound) { + EnsureAssembliesLoaded (); + // Look in the addin assemblies - foreach (Assembly asm in assemblies) { + foreach (Assembly asm in GetAllAssemblies ()) { Stream res = asm.GetManifestResourceStream (resourceName); if (res != null) return res; } // Look in the dependent add-ins - foreach (RuntimeAddin addin in depAddins) { + foreach (RuntimeAddin addin in GetAllDependencies ()) { Stream res = addin.GetResource (resourceName); if (res != null) return res; @@ -236,43 +536,50 @@ return null; } + /// + /// Localizer which can be used to localize strings defined in this add-in + /// public AddinLocalizer Localizer { get { if (localizer != null) return localizer; else - return AddinManager.DefaultLocalizer; + return addinEngine.DefaultLocalizer; } } + internal RuntimeAddin GetModule (ModuleDescription module) + { + // If requesting the root module, return this + if (module == module.ParentAddinDescription.MainModule) + return this; + + if (module.RuntimeAddin != null) + return module.RuntimeAddin; + + RuntimeAddin addin = new RuntimeAddin (addinEngine, this, module); + return addin; + } + internal AddinDescription Load (Addin iad) { ainfo = iad; - ArrayList plugList = new ArrayList (); - ArrayList asmList = new ArrayList (); - AddinDescription description = iad.Description; id = description.AddinId; baseDirectory = description.BasePath; - - // Load the main modules - LoadModule (description.MainModule, description.Namespace, plugList, asmList); - - // Load the optional modules, if the dependencies are present - foreach (ModuleDescription module in description.OptionalModules) { - if (CheckAddinDependencies (module)) - LoadModule (module, description.Namespace, plugList, asmList); - } - - depAddins = (RuntimeAddin[]) plugList.ToArray (typeof(RuntimeAddin)); - assemblies = (Assembly[]) asmList.ToArray (typeof(Assembly)); + module = description.MainModule; + module.RuntimeAddin = this; if (description.Localizer != null) { string cls = description.Localizer.GetAttribute ("type"); // First try getting one of the stock localizers. If none of found try getting the type. - object fob = CreateInstance ("Mono.Addins.Localization." + cls + "Localizer", false); + object fob = null; + Type t = Type.GetType ("Mono.Addins.Localization." + cls + "Localizer, " + GetType().Assembly.FullName, false); + if (t != null) + fob = Activator.CreateInstance (t); + if (fob == null) fob = CreateInstance (cls, true); @@ -285,7 +592,29 @@ return description; } - void LoadModule (ModuleDescription module, string ns, ArrayList plugList, ArrayList asmList) + RuntimeAddin[] GetDepAddins () + { + if (depAddins != null) + return depAddins; + + ArrayList plugList = new ArrayList (); + string ns = ainfo.Description.Namespace; + + // Collect dependent ids + foreach (Dependency dep in module.Dependencies) { + AddinDependency pdep = dep as AddinDependency; + if (pdep != null) { + RuntimeAddin adn = addinEngine.GetAddin (Addin.GetFullId (ns, pdep.AddinId, pdep.Version)); + if (adn != null) + plugList.Add (adn); + else + addinEngine.ReportError ("Add-in dependency not loaded: " + pdep.FullAddinId, module.ParentAddinDescription.AddinId, null, false); + } + } + return depAddins = (RuntimeAddin[]) plugList.ToArray (typeof(RuntimeAddin)); + } + + void LoadModule (ModuleDescription module, ArrayList asmList) { // Load the assemblies foreach (string s in module.Assemblies) { @@ -300,10 +629,14 @@ if (a is System.Reflection.Emit.AssemblyBuilder) { continue; } - - if (a.Location == asmPath) { - asm = a; - break; + + try { + if (a.Location == asmPath) { + asm = a; + break; + } + } catch (NotSupportedException) { + // Some assemblies don't have a location } } @@ -313,38 +646,44 @@ asmList.Add (asm); } - - // Collect dependent ids - foreach (Dependency dep in module.Dependencies) { - AddinDependency pdep = dep as AddinDependency; - if (pdep != null) { - RuntimeAddin adn = AddinManager.SessionService.GetAddin (Addin.GetFullId (ns, pdep.AddinId, pdep.Version)); - if (adn != null) - plugList.Add (adn); - else - AddinManager.ReportError ("Add-in dependency not loaded: " + pdep.FullAddinId, module.ParentAddinDescription.AddinId, null, false); - } - } } internal void UnloadExtensions () { - // Create the extension points (but do not load them) - AddinDescription emap = Addin.Description; - if (emap == null) return; - - foreach (ExtensionNodeSet rel in emap.ExtensionNodeSets) - AddinManager.SessionService.UnregisterNodeSet (rel); + addinEngine.UnregisterAddinNodeSets (id); } - bool CheckAddinDependencies (ModuleDescription module) + bool CheckAddinDependencies (ModuleDescription module, bool forceLoadAssemblies) { foreach (Dependency dep in module.Dependencies) { AddinDependency pdep = dep as AddinDependency; - if (pdep != null && !AddinManager.SessionService.IsAddinLoaded (pdep.FullAddinId)) + if (pdep == null) + continue; + if (!addinEngine.IsAddinLoaded (pdep.FullAddinId)) return false; + if (forceLoadAssemblies) + addinEngine.GetAddin (pdep.FullAddinId).EnsureAssembliesLoaded (); } return true; } + + internal bool AssembliesLoaded { + get { return assemblies != null; } + } + + void EnsureAssembliesLoaded () + { + if (assemblies != null) + return; + + ArrayList asmList = new ArrayList (); + + // Load the assemblies of the module + CheckAddinDependencies (module, true); + LoadModule (module, asmList); + + assemblies = (Assembly[]) asmList.ToArray (typeof(Assembly)); + addinEngine.RegisterAssemblies (this); + } } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/TreeNode.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/TreeNode.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/TreeNode.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/TreeNode.cs 2011-04-13 09:00:29.000000000 +0000 @@ -45,16 +45,22 @@ ExtensionNodeSet nodeTypes; ExtensionPoint extensionPoint; BaseCondition condition; + protected AddinEngine addinEngine; - public TreeNode (string id) + public TreeNode (AddinEngine addinEngine, string id) { this.id = id; + this.addinEngine = addinEngine; // Root node if (id.Length == 0) childrenLoaded = true; } + public AddinEngine AddinEngine { + get { return addinEngine; } + } + internal void AttachExtensionNode (ExtensionNode enode) { this.extensionNode = enode; @@ -70,7 +76,7 @@ get { if (extensionNode == null && extensionPoint != null) { extensionNode = new ExtensionNode (); - extensionNode.SetData (extensionPoint.RootAddin, null); + extensionNode.SetData (addinEngine, extensionPoint.RootAddin, null, null); AttachExtensionNode (extensionNode); } return extensionNode; @@ -187,7 +193,7 @@ } if (buildPath) { - TreeNode newNode = new TreeNode (part); + TreeNode newNode = new TreeNode (addinEngine, part); curNode.AddChildNode (newNode); curNode = newNode; } else @@ -287,7 +293,7 @@ if (extensionPoint != null) { foreach (ExtensionNodeType nt in extensionPoint.NodeSet.NodeTypes) { if (nt.ObjectTypeName.Length > 0 && (nodeName.Length == 0 || nodeName == nt.Id)) { - RuntimeAddin addin = AddinManager.SessionService.GetAddin (extensionPoint.RootAddin); + RuntimeAddin addin = addinEngine.GetAddin (extensionPoint.RootAddin); Type ot = addin.GetType (nt.ObjectTypeName); if (ot != null) { if (ot.IsAssignableFrom (type)) { @@ -334,7 +340,7 @@ { if (extensionPoint != null) { string aid = Addin.GetIdName (extensionPoint.ParentAddinDescription.AddinId); - RuntimeAddin ad = AddinManager.SessionService.GetAddin (aid); + RuntimeAddin ad = addinEngine.GetAddin (aid); if (ad != null) extensionPoint = ad.Addin.Description.ExtensionPoints [GetPath ()]; } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/TypeExtensionNode.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/TypeExtensionNode.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/TypeExtensionNode.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/TypeExtensionNode.cs 2011-04-13 09:00:29.000000000 +0000 @@ -32,13 +32,46 @@ namespace Mono.Addins { + /// + /// An extension node which specifies a type. + /// + /// + /// This class is a kind of Mono.Addins.ExtensionNode which can be used to register + /// types in an extension point. This is a very common case: a host application + /// defines an interface, and add-ins create classes that implement that interface. + /// The host will define an extension point which will use TypeExtensionNode as node + /// type. Add-ins will register the classes they implement in that extension point. + /// + /// When the nodes of an extension point are of type TypeExtensionNode it is then + /// possible to use query methods such as AddinManager.GetExtensionObjects(string), + /// which will get all nodes in the provided extension path and will create an object + /// for each node. + /// + /// When declaring extension nodes in an add-in manifest, the class names can be + /// specified using the 'class' or 'type' attribute. If none of those attributes is + /// provided, the class name will be taken from the 'id' attribute. + /// + /// TypeExtensionNode is the default extension type used when no type is provided + /// in the definition of an extension point. + /// [ExtensionNode ("Type", Description="Specifies a class that will be used to create an extension object.")] - [NodeAttribute ("class", typeof(Type), false, Description="Name of the class. If a value is not provided, the class name will be taken from the 'id' attribute")] + [NodeAttribute ("class", typeof(Type), false, ContentType = ContentType.Class, Description="Name of the class. If a value is not provided, the class name will be taken from the 'id' attribute")] public class TypeExtensionNode: InstanceExtensionNode { string typeName; Type type; + /// + /// Reads the extension node data + /// + /// + /// The element containing the extension data + /// + /// + /// This method can be overriden to provide a custom method for reading extension node data from an element. + /// The default implementation reads the attributes if the element and assigns the values to the fields + /// and properties of the extension node that have the corresponding [NodeAttribute] decoration. + /// internal protected override void Read (NodeElement elem) { base.Read (elem); @@ -49,11 +82,20 @@ typeName = elem.GetAttribute ("id"); } + /// + /// Creates a new extension object + /// + /// + /// The extension object + /// public override object CreateInstance () { return Activator.CreateInstance (Type); } - + + /// + /// Type of the object that this node creates + /// public Type Type { get { if (type == null) { @@ -65,4 +107,24 @@ } } } + + /// + /// An extension node which specifies a type with custom extension metadata + /// + /// + /// This is the default type for type extension nodes bound to a custom extension attribute. + /// + public class TypeExtensionNode: TypeExtensionNode where T:CustomExtensionAttribute + { + T data; + + /// + /// The custom attribute containing the extension metadata + /// + [NodeAttribute] + public T Data { + get { return data; } + internal set { data = value; } + } + } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins/TypeExtensionPointAttribute.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins/TypeExtensionPointAttribute.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins/TypeExtensionPointAttribute.cs 2008-11-06 19:52:12.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins/TypeExtensionPointAttribute.cs 2011-04-13 09:00:29.000000000 +0000 @@ -31,6 +31,9 @@ namespace Mono.Addins { + /// + /// Declares an extension point bound to a type + /// [AttributeUsage (AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple=true)] public class TypeExtensionPointAttribute: Attribute { @@ -40,36 +43,62 @@ string nodeTypeName; string desc; string name; + Type customAttributeType; + string customAttributeTypeName; + /// + /// Initializes a new instance + /// public TypeExtensionPointAttribute () { } + /// + /// Initializes a new instance + /// + /// + /// Path that identifies the extension point + /// public TypeExtensionPointAttribute (string path) { this.path = path; } + /// + /// Path that identifies the extension point + /// public string Path { get { return path != null ? path : string.Empty; } set { path = value; } } + /// + /// Description of the extension point. + /// public string Description { get { return desc != null ? desc : string.Empty; } set { desc = value; } } + /// + /// Element name to be used when defining an extension in an XML manifest. The default name is "Type". + /// public string NodeName { get { return nodeName != null && nodeName.Length > 0 ? nodeName : "Type"; } set { nodeName = value; } } + /// + /// Display name of the extension point. + /// public string Name { get { return name != null ? name : string.Empty; } set { name = value; } } + /// + /// Type of the extension node to be created for extensions + /// public Type NodeType { get { return nodeType != null ? nodeType : typeof(TypeExtensionNode); } set { nodeType = value; nodeTypeName = value.FullName; } @@ -79,5 +108,18 @@ get { return nodeTypeName != null ? nodeTypeName : typeof(TypeExtensionNode).FullName; } set { nodeTypeName = value; nodeType = null; } } -} + + /// + /// Type of the custom attribute to be used to specify metadata for the extension point + /// + public Type ExtensionAttributeType { + get { return this.customAttributeType; } + set { this.customAttributeType = value; customAttributeTypeName = value.FullName; } + } + + internal string ExtensionAttributeTypeName { + get { return this.customAttributeTypeName; } + set { this.customAttributeTypeName = value; } + } + } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Database/AddinDatabase.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Database/AddinDatabase.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Database/AddinDatabase.cs 2008-11-06 19:52:14.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Database/AddinDatabase.cs 2011-04-13 09:00:29.000000000 +0000 @@ -35,6 +35,8 @@ using System.Xml; using System.Reflection; using Mono.Addins.Description; +using System.Collections.Generic; +using System.Linq; namespace Mono.Addins.Database { @@ -45,9 +47,9 @@ public const string VersionTag = "001"; - ArrayList allSetupInfos; - ArrayList addinSetupInfos; - ArrayList rootSetupInfos; + List allSetupInfos; + List addinSetupInfos; + List rootSetupInfos; internal static bool RunningSetupProcess; bool fatalDatabseError; Hashtable cachedAddinSetupInfos = new Hashtable (); @@ -58,11 +60,15 @@ DatabaseConfiguration config = null; AddinRegistry registry; int lastDomainId; + AddinEngine addinEngine; + AddinFileSystemExtension fs = new AddinFileSystemExtension (); + List extensions = new List (); - public AddinDatabase (AddinRegistry registry) + public AddinDatabase (AddinEngine addinEngine, AddinRegistry registry) { + this.addinEngine = addinEngine; this.registry = registry; - addinDbDir = Path.Combine (registry.RegistryPath, "addin-db-" + VersionTag); + addinDbDir = Path.Combine (registry.AddinCachePath, "addin-db-" + VersionTag); fileDatabase = new FileDatabase (AddinDbDir); } @@ -70,6 +76,10 @@ get { return addinDbDir; } } + public AddinFileSystemExtension FileSystem { + get { return fs; } + } + public string AddinCachePath { get { return Path.Combine (AddinDbDir, "addin-data"); } } @@ -100,6 +110,12 @@ } } + public AddinRegistry Registry { + get { + return this.registry; + } + } + public void Clear () { if (Directory.Exists (AddinCachePath)) @@ -108,6 +124,30 @@ Directory.Delete (AddinFolderCachePath, true); } + public void CopyExtensions (AddinDatabase other) + { + foreach (object o in other.extensions) + RegisterExtension (o); + } + + public void RegisterExtension (object extension) + { + extensions.Add (extension); + if (extension is AddinFileSystemExtension) + fs = (AddinFileSystemExtension) extension; + else + throw new NotSupportedException (); + } + + public void UnregisterExtension (object extension) + { + extensions.Remove (extension); + if ((extension as AddinFileSystemExtension) == fs) + fs = new AddinFileSystemExtension (); + else + throw new InvalidOperationException (); + } + public ExtensionNodeSet FindNodeSet (string domain, string addinId, string id) { return FindNodeSet (domain, addinId, id, new Hashtable ()); @@ -142,53 +182,75 @@ return null; } - public ArrayList GetInstalledAddins (string domain, AddinType type) + public IEnumerable GetInstalledAddins (string domain, AddinSearchFlagsInternal flags) { - if (type == AddinType.All) { + if (domain == null) + domain = registry.CurrentDomain; + + // Get the cached list if the add-in list has already been loaded. + // The domain doesn't have to be checked again, since it is always the same + + IEnumerable result = null; + + if ((flags & AddinSearchFlagsInternal.IncludeAll) == AddinSearchFlagsInternal.IncludeAll) { if (allSetupInfos != null) - return allSetupInfos; + result = allSetupInfos; } - else if (type == AddinType.Addin) { + else if ((flags & AddinSearchFlagsInternal.IncludeAddins) == AddinSearchFlagsInternal.IncludeAddins) { if (addinSetupInfos != null) - return addinSetupInfos; + result = addinSetupInfos; } else { if (rootSetupInfos != null) - return rootSetupInfos; + result = rootSetupInfos; } - - InternalCheck (domain); - using (fileDatabase.LockRead ()) { - return InternalGetInstalledAddins (domain, null, type); + if (result == null) { + InternalCheck (domain); + using (fileDatabase.LockRead ()) { + result = InternalGetInstalledAddins (domain, null, flags & ~AddinSearchFlagsInternal.LatestVersionsOnly); + } } + + if ((flags & AddinSearchFlagsInternal.LatestVersionsOnly) == AddinSearchFlagsInternal.LatestVersionsOnly) + result = result.Where (a => a.IsLatestVersion); + + if ((flags & AddinSearchFlagsInternal.ExcludePendingUninstall) == AddinSearchFlagsInternal.ExcludePendingUninstall) + result = result.Where (a => !IsRegisteredForUninstall (a.Description.Domain, a.Id)); + + return result; } - ArrayList InternalGetInstalledAddins (string domain, AddinType type) + IEnumerable InternalGetInstalledAddins (string domain, AddinSearchFlagsInternal type) { return InternalGetInstalledAddins (domain, null, type); } - ArrayList InternalGetInstalledAddins (string domain, string idFilter, AddinType type) + IEnumerable InternalGetInstalledAddins (string domain, string idFilter, AddinSearchFlagsInternal type) { + if ((type & AddinSearchFlagsInternal.LatestVersionsOnly) != 0) + throw new InvalidOperationException ("LatestVersionsOnly flag not supported here"); + if (allSetupInfos == null) { - ArrayList alist = new ArrayList (); + Dictionary adict = new Dictionary (); // Global add-ins are valid for any private domain if (domain != AddinDatabase.GlobalDomain) - FindInstalledAddins (alist, AddinDatabase.GlobalDomain, idFilter); + FindInstalledAddins (adict, AddinDatabase.GlobalDomain, idFilter); - FindInstalledAddins (alist, domain, idFilter); + FindInstalledAddins (adict, domain, idFilter); + List alist = new List (adict.Values); + UpdateLastVersionFlags (alist); if (idFilter != null) return alist; allSetupInfos = alist; } - if (type == AddinType.All) + if ((type & AddinSearchFlagsInternal.IncludeAll) == AddinSearchFlagsInternal.IncludeAll) return FilterById (allSetupInfos, idFilter); - if (type == AddinType.Addin) { + if ((type & AddinSearchFlagsInternal.IncludeAddins) == AddinSearchFlagsInternal.IncludeAddins) { if (addinSetupInfos == null) { - addinSetupInfos = new ArrayList (); + addinSetupInfos = new List (); foreach (Addin adn in allSetupInfos) if (!adn.Description.IsRoot) addinSetupInfos.Add (adn); @@ -197,7 +259,7 @@ } else { if (rootSetupInfos == null) { - rootSetupInfos = new ArrayList (); + rootSetupInfos = new List (); foreach (Addin adn in allSetupInfos) if (adn.Description.IsRoot) rootSetupInfos.Add (adn); @@ -206,19 +268,14 @@ } } - ArrayList FilterById (ArrayList addins, string id) + IEnumerable FilterById (List addins, string id) { if (id == null) return addins; - ArrayList list = new ArrayList (); - foreach (Addin adn in addins) { - if (Addin.GetIdName (adn.Id) == id) - list.Add (adn); - } - return list; + return addins.Where (a => Addin.GetIdName (a.Id) == id); } - void FindInstalledAddins (ArrayList result, string domain, string idFilter) + void FindInstalledAddins (Dictionary result, string domain, string idFilter) { if (idFilter == null) idFilter = "*"; @@ -226,10 +283,31 @@ if (Directory.Exists (dir)) { foreach (string file in fileDatabase.GetDirectoryFiles (dir, idFilter + ",*.maddin")) { string id = Path.GetFileNameWithoutExtension (file); - result.Add (GetInstalledDomainAddin (domain, id, true, false, false)); + if (!result.ContainsKey (id)) { + var adesc = GetInstalledDomainAddin (domain, id, true, false, false); + if (adesc != null) + result.Add (id, adesc); + } } } } + + void UpdateLastVersionFlags (List addins) + { + Dictionary versions = new Dictionary (); + foreach (Addin a in addins) { + string last; + string id, version; + Addin.GetIdParts (a.Id, out id, out version); + if (!versions.TryGetValue (id, out last) || Addin.CompareVersions (last, version) > 0) + versions [id] = version; + } + foreach (Addin a in addins) { + string id, version; + Addin.GetIdParts (a.Id, out id, out version); + a.IsLatestVersion = versions [id] == version; + } + } public Addin GetInstalledAddin (string domain, string id) { @@ -295,7 +373,7 @@ string version, name, bestVersion = null; Addin.GetIdParts (id, out name, out version); - foreach (Addin ia in InternalGetInstalledAddins (domain, name, AddinType.All)) + foreach (Addin ia in InternalGetInstalledAddins (domain, name, AddinSearchFlagsInternal.IncludeAll)) { if ((!enabledOnly || ia.Enabled) && (version.Length == 0 || ia.SupportsVersion (version)) && @@ -395,8 +473,8 @@ Configuration.SetStatus (id, true, ainfo.AddinInfo.EnabledByDefault); SaveConfiguration (); - if (AddinManager.IsInitialized && AddinManager.Registry.RegistryPath == registry.RegistryPath) - AddinManager.SessionService.ActivateAddin (id); + if (addinEngine != null && addinEngine.IsInitialized) + addinEngine.ActivateAddin (id); } public void DisableAddin (string domain, string id) @@ -416,7 +494,7 @@ try { string idName = Addin.GetIdName (id); - foreach (Addin ainfo in GetInstalledAddins (domain, AddinType.Addin)) { + foreach (Addin ainfo in GetInstalledAddins (domain, AddinSearchFlagsInternal.IncludeAddins)) { foreach (Dependency dep in ainfo.AddinInfo.Dependencies) { AddinDependency adep = dep as AddinDependency; if (adep == null) @@ -446,10 +524,27 @@ throw; } - if (AddinManager.IsInitialized && AddinManager.Registry.RegistryPath == registry.RegistryPath) - AddinManager.SessionService.UnloadAddin (id); - } + if (addinEngine != null && addinEngine.IsInitialized) + addinEngine.UnloadAddin (id); + } + + public void RegisterForUninstall (string domain, string id, IEnumerable files) + { + DisableAddin (domain, id); + Configuration.RegisterForUninstall (id, files); + SaveConfiguration (); + } + public bool IsRegisteredForUninstall (string domain, string addinId) + { + return Configuration.IsRegisteredForUninstall (addinId); + } + + internal bool HasPendingUninstalls (string domain) + { + return Configuration.HasPendingUninstalls; + } + internal string GetDescriptionPath (string domain, string id) { return Path.Combine (Path.Combine (AddinCachePath, domain), id + ".maddin"); @@ -471,7 +566,7 @@ Update (null, domain); } - void GenerateAddinExtensionMapsInternal (IProgressStatus monitor, ArrayList addinsToUpdate, ArrayList removedAddins) + void GenerateAddinExtensionMapsInternal (IProgressStatus monitor, List addinsToUpdate, List addinsToUpdateRelations, List removedAddins) { AddinUpdateData updateData = new AddinUpdateData (this, monitor); @@ -496,33 +591,43 @@ if (partialGeneration) { changedAddins = new Hashtable (); - foreach (string sa in addinsToUpdate) { + + if (monitor.LogLevel > 2) + monitor.Log ("Doing a partial registry update.\nAdd-ins to be updated:"); + // Get the files and ids of all add-ins that have to be updated + // Include removed add-ins: if there are several instances of the same add-in, removing one of + // them will make other instances to show up. If there is a single instance, its files are + // already removed. + foreach (string sa in addinsToUpdate.Union (removedAddins)) { changedAddins [sa] = sa; - - // Look for all versions of the add-in, because this id may be the id of a reference, - // and the exact reference version may not be installed. - string s = sa; - int i = s.LastIndexOf (','); - if (i != -1) - s = s.Substring (0, i); - s += ",*"; - - // Look for the add-in in any of the existing folders - foreach (string domain in domains) { - string mp = GetDescriptionPath (domain, s); - string dir = Path.GetDirectoryName (mp); - string pat = Path.GetFileName (mp); - foreach (string fmp in fileDatabase.GetDirectoryFiles (dir, pat)) { - if (files.Contains (fmp)) - continue; - files.Add (fmp); - string an = Path.GetFileNameWithoutExtension (fmp); + if (monitor.LogLevel > 2) + monitor.Log (" - " + sa); + foreach (string file in GetAddinFiles (sa, domains)) { + if (!files.Contains (file)) { + files.Add (file); + string an = Path.GetFileNameWithoutExtension (file); changedAddins [an] = an; + if (monitor.LogLevel > 2 && an != sa) + monitor.Log (" - " + an); + } + } + } + + if (monitor.LogLevel > 2) + monitor.Log ("Add-ins whose relations have to be updated:"); + + // Get the files and ids of all add-ins whose relations have to be updated + foreach (string sa in addinsToUpdateRelations) { + foreach (string file in GetAddinFiles (sa, domains)) { + if (!files.Contains (file)) { + if (monitor.LogLevel > 2) { + string an = Path.GetFileNameWithoutExtension (file); + monitor.Log (" - " + an); + } + files.Add (file); } } } - foreach (string s in removedAddins) - changedAddins [s] = s; } else { foreach (string dom in domains) @@ -539,13 +644,13 @@ } // If the original file does not exist, the description can be deleted - if (!File.Exists (conf.AddinFile)) { + if (!fs.FileExists (conf.AddinFile)) { SafeDelete (monitor, file); continue; } - // Remove old data from the description. If changedAddins==null, removes all data. - // Otherwise, removes data only from the addins in the table. + // Remove old data from the description. Remove the data of the add-ins that + // have changed. This data will be re-added later. conf.UnmergeExternalData (changedAddins); descriptionsToSave.Add (conf); @@ -555,19 +660,30 @@ // Sort the add-ins, to make sure add-ins are processed before // all their dependencies - ArrayList sorted = addinHash.GetSortedAddins (); - + + var sorted = addinHash.GetSortedAddins (); + // Register extension points and node sets foreach (AddinDescription conf in sorted) CollectExtensionPointData (conf, updateData); + if (monitor.LogLevel > 2) + monitor.Log ("Registering new extensions:"); + // Register extensions - foreach (AddinDescription conf in sorted) - CollectExtensionData (conf, updateData); + foreach (AddinDescription conf in sorted) { + if (changedAddins == null || changedAddins.ContainsKey (conf.AddinId)) { + if (monitor.LogLevel > 2) + monitor.Log ("- " + conf.AddinId + " (" + conf.Domain + ")"); + CollectExtensionData (monitor, addinHash, conf, updateData); + } + } // Save the maps - foreach (AddinDescription conf in descriptionsToSave) + foreach (AddinDescription conf in descriptionsToSave) { + ConsolidateExtensions (conf); conf.SaveBinary (fileDatabase); + } if (monitor.LogLevel > 1) { monitor.Log ("Addin relation map generated."); @@ -579,6 +695,135 @@ } } + void ConsolidateExtensions (AddinDescription conf) + { + // Merges extensions with the same path + + foreach (ModuleDescription module in conf.AllModules) { + Dictionary extensions = new Dictionary (); + foreach (Extension ext in module.Extensions) { + Extension mainExt; + if (extensions.TryGetValue (ext.Path, out mainExt)) { + ArrayList list = new ArrayList (); + EnsureInsertionsSorted (ext.ExtensionNodes); + list.AddRange (ext.ExtensionNodes); + int pos = -1; + foreach (ExtensionNodeDescription node in list) { + ext.ExtensionNodes.Remove (node); + AddNodeSorted (mainExt.ExtensionNodes, node, ref pos); + } + } else { + extensions [ext.Path] = ext; + EnsureInsertionsSorted (ext.ExtensionNodes); + } + } + + // Sort the nodes + } + } + + void EnsureInsertionsSorted (ExtensionNodeDescriptionCollection list) + { + // Makes sure that the nodes in the collections are properly sorted wrt insertafter and insertbefore attributes + Dictionary added = new Dictionary (); + List halfSorted = new List (); + bool orderChanged = false; + + for (int n = list.Count - 1; n >= 0; n--) { + ExtensionNodeDescription node = list [n]; + if (node.Id.Length > 0) + added [node.Id] = node; + if (node.InsertAfter.Length > 0) { + ExtensionNodeDescription relNode; + if (added.TryGetValue (node.InsertAfter, out relNode)) { + // Out of order. Move it before the referenced node + int i = halfSorted.IndexOf (relNode); + halfSorted.Insert (i, node); + orderChanged = true; + } else { + halfSorted.Add (node); + } + } else + halfSorted.Add (node); + } + halfSorted.Reverse (); + List fullSorted = new List (); + added.Clear (); + + foreach (ExtensionNodeDescription node in halfSorted) { + if (node.Id.Length > 0) + added [node.Id] = node; + if (node.InsertBefore.Length > 0) { + ExtensionNodeDescription relNode; + if (added.TryGetValue (node.InsertBefore, out relNode)) { + // Out of order. Move it before the referenced node + int i = fullSorted.IndexOf (relNode); + fullSorted.Insert (i, node); + orderChanged = true; + } else { + fullSorted.Add (node); + } + } else + fullSorted.Add (node); + } + if (orderChanged) { + list.Clear (); + foreach (ExtensionNodeDescription node in fullSorted) + list.Add (node); + } + } + + void AddNodeSorted (ExtensionNodeDescriptionCollection list, ExtensionNodeDescription node, ref int curPos) + { + // Adds the node at the correct position, taking into account insertbefore and insertafter + + if (node.InsertAfter.Length > 0) { + string afterId = node.InsertAfter; + for (int n=0; n 0) { + string beforeId = node.InsertBefore; + for (int n=0; n missingDeps = addinHash.GetMissingDependencies (conf, conf.MainModule); + if (missingDeps.Any ()) { + string w = "The add-in '" + conf.AddinId + "' could not be updated because some of its dependencies are missing or not compatible:"; + w += BuildMissingAddinsList (addinHash, conf, missingDeps); + monitor.ReportWarning (w); + return; + } + + CollectModuleExtensionData (conf, conf.MainModule, updateData); + + foreach (ModuleDescription module in conf.OptionalModules) { + missingDeps = addinHash.GetMissingDependencies (conf, module); + if (missingDeps.Any ()) { + if (monitor.LogLevel > 1) { + string w = "An optional module of the add-in '" + conf.AddinId + "' could not be updated because some of its dependencies are missing or not compatible:"; + w += BuildMissingAddinsList (addinHash, conf, missingDeps); + } } + else + CollectModuleExtensionData (conf, module, updateData); + } + } + + string BuildMissingAddinsList (AddinIndex addinHash, AddinDescription conf, IEnumerable missingDeps) + { + string w = ""; + foreach (string dep in missingDeps) { + var found = addinHash.GetSimilarExistingAddin (conf, dep); + if (found == null) + w += "\n missing: " + dep; + else + w += "\n required: " + dep + ", found: " + found.AddinId; + } + return w; + } + + void CollectModuleExtensionData (AddinDescription conf, ModuleDescription module, AddinUpdateData updateData) + { + foreach (Extension ext in module.Extensions) { + updateData.RelExtensions++; + updateData.RegisterExtension (conf, module, ext); + AddChildExtensions (conf, module, updateData, ext.Path, ext.ExtensionNodes, false); } } @@ -667,12 +948,24 @@ rootSetupInfos = null; hostIndex = null; cachedAddinSetupInfos.Clear (); - AddinManager.SessionService.ResetCachedData (); + if (addinEngine != null) + addinEngine.ResetCachedData (); } public bool AddinDependsOn (string domain, string id1, string id2) { + Hashtable visited = new Hashtable (); + return AddinDependsOn (visited, domain, id1, id2); + } + + bool AddinDependsOn (Hashtable visited, string domain, string id1, string id2) + { + if (visited.Contains (id1)) + return false; + + visited.Add (id1, id1); + Addin addin1 = GetInstalledAddin (domain, id1, false); // We can assumbe that if the add-in is not returned here, it may be a root addin. @@ -687,7 +980,7 @@ string depid = Addin.GetFullId (addin1.AddinInfo.Namespace, adep.AddinId, null); if (depid == id2) return true; - else if (AddinDependsOn (domain, depid, id2)) + else if (AddinDependsOn (visited, domain, depid, id2)) return true; } return false; @@ -723,6 +1016,8 @@ DateTime tim = DateTime.Now; + RunPendingUninstalls (monitor); + Hashtable installed = new Hashtable (); bool changesFound = CheckFolders (monitor, domain); @@ -738,8 +1033,7 @@ if (domain != null) { using (fileDatabase.LockRead ()) { - // Don't use AddinType.Addin here because it is too expensive - foreach (Addin ainfo in InternalGetInstalledAddins (domain, AddinType.All)) { + foreach (Addin ainfo in InternalGetInstalledAddins (domain, AddinSearchFlagsInternal.IncludeAddins)) { installed [ainfo.Id] = ainfo.Id; } } @@ -756,44 +1050,89 @@ monitor.ReportError ("The add-in database could not be updated. It may be due to file corruption. Try running the setup repair utility", null); // Update the currently loaded add-ins - if (changesFound && domain != null && AddinManager.IsInitialized && AddinManager.Registry.RegistryPath == registry.RegistryPath) { + if (changesFound && domain != null && addinEngine != null && addinEngine.IsInitialized) { Hashtable newInstalled = new Hashtable (); - foreach (Addin ainfo in GetInstalledAddins (domain, AddinType.All)) { + foreach (Addin ainfo in GetInstalledAddins (domain, AddinSearchFlagsInternal.IncludeAddins)) { newInstalled [ainfo.Id] = ainfo.Id; } foreach (string aid in installed.Keys) { - if (!newInstalled.Contains (aid)) { - if (AddinManager.SessionService.IsAddinLoaded (aid)) { - RuntimeAddin ra = AddinManager.SessionService.GetAddin (aid); - if (!ra.Addin.Description.IsRoot) - AddinManager.SessionService.UnloadAddin (aid); - } - } + // Always try to unload, event if the add-in was not currently loaded. + // Required since the add-ins has to be marked as 'disabled', to avoid + // extensions from this add-in to be loaded + if (!newInstalled.Contains (aid)) + addinEngine.UnloadAddin (aid); } foreach (string aid in newInstalled.Keys) { if (!installed.Contains (aid)) { - Addin addin = AddinManager.Registry.GetAddin (aid); - if (addin != null && !addin.Description.IsRoot) - AddinManager.SessionService.ActivateAddin (aid); + Addin addin = addinEngine.Registry.GetAddin (aid); + if (addin != null) + addinEngine.ActivateAddin (aid); + } + } + } + } + + void RunPendingUninstalls (IProgressStatus monitor) + { + bool changesDone = false; + + foreach (var adn in Configuration.GetPendingUninstalls ()) { + HashSet files = new HashSet (adn.Files); + if (AddinManager.CheckAssembliesLoaded (files)) + continue; + + if (monitor.LogLevel > 1) + monitor.Log ("Uninstalling " + adn.AddinId); + + // Make sure all files can be deleted before doing so + bool canUninstall = true; + foreach (string f in adn.Files) { + if (!File.Exists (f)) + continue; + try { + File.OpenWrite (f).Close (); + } catch { + canUninstall = false; + break; + } + } + + if (!canUninstall) + continue; + + foreach (string f in adn.Files) { + try { + if (File.Exists (f)) + File.Delete (f); + } catch { + canUninstall = false; } } + + if (canUninstall) { + Configuration.UnregisterForUninstall (adn.AddinId); + changesDone = true; + } } + if (changesDone) + SaveConfiguration (); } void RunScannerProcess (IProgressStatus monitor) { + ISetupHandler setup = GetSetupHandler (); + IProgressStatus scanMonitor = monitor; ArrayList pparams = new ArrayList (); - pparams.Add (null); // scan folder bool retry = false; do { try { if (monitor.LogLevel > 1) monitor.Log ("Looking for addins"); - SetupProcess.ExecuteCommand (scanMonitor, registry.RegistryPath, registry.StartupDirectory, "scan", (string[]) pparams.ToArray (typeof(string))); + setup.Scan (scanMonitor, registry, null, (string[]) pparams.ToArray (typeof(string))); retry = false; } catch (Exception ex) { @@ -937,6 +1276,16 @@ void InternalScanFolders (IProgressStatus monitor, AddinScanResult scanResult) { + try { + fs.ScanStarted (); + InternalScanFolders2 (monitor, scanResult); + } finally { + fs.ScanFinished (); + } + } + + void InternalScanFolders2 (IProgressStatus monitor, AddinScanResult scanResult) + { DateTime tim = DateTime.Now; DatabaseInfrastructureCheck (monitor); @@ -963,7 +1312,7 @@ AddinScanFolderInfo folderInfo; bool res = ReadFolderInfo (monitor, file, out folderInfo); bool validForDomain = scanResult.Domain == null || folderInfo.Domain == GlobalDomain || folderInfo.Domain == scanResult.Domain; - if (!res || (validForDomain && !Directory.Exists (folderInfo.Folder))) { + if (!res || (validForDomain && !fs.DirectoryExists (folderInfo.Folder))) { if (res) { // Folder has been deleted. Remove the add-ins it had. scanner.UpdateDeletedAddins (monitor, folderInfo, scanResult); @@ -1001,7 +1350,7 @@ scanner.ScanFolderRec (monitor, dir, GlobalDomain, scanResult); } - if (scanResult.CheckOnly) + if (scanResult.CheckOnly || !scanResult.ChangesFound) return; // Scan the files which have been modified @@ -1033,10 +1382,11 @@ if (scanResult.RegenerateRelationData) { if (monitor.LogLevel > 1) monitor.Log ("Regenerating all add-in relations."); + scanResult.AddinsToUpdate = null; scanResult.AddinsToUpdateRelations = null; } - GenerateAddinExtensionMapsInternal (monitor, scanResult.AddinsToUpdateRelations, scanResult.RemovedAddins); + GenerateAddinExtensionMapsInternal (monitor, scanResult.AddinsToUpdate, scanResult.AddinsToUpdateRelations, scanResult.RemovedAddins); } catch (Exception ex) { fatalDatabseError = true; @@ -1052,7 +1402,8 @@ public void ParseAddin (IProgressStatus progressStatus, string domain, string file, string outFile, bool inProcess) { if (!inProcess) { - SetupProcess.ExecuteCommand (progressStatus, registry.RegistryPath, registry.StartupDirectory, "get-desc", Path.GetFullPath (file), outFile); + ISetupHandler setup = GetSetupHandler (); + setup.GetAddinDescription (progressStatus, registry, Path.GetFullPath (file), outFile); return; } @@ -1064,7 +1415,7 @@ AddinFileInfo afi = finfo.GetAddinFileInfo (file); if (afi != null && afi.IsAddin) { AddinDescription adesc; - GetAddinDescription (progressStatus, afi.Domain, afi.AddinId, out adesc); + GetAddinDescription (progressStatus, afi.Domain, afi.AddinId, file, out adesc); if (adesc != null) adesc.Save (outFile); return; @@ -1110,7 +1461,8 @@ if (file != null) return Util.LoadAssemblyForReflection (file); else { - Console.WriteLine ("Assembly not found: " + args.Name); + if (!args.Name.StartsWith ("Mono.Addins.CecilReflector")) + Console.WriteLine ("Assembly not found: " + args.Name); return null; } } @@ -1127,36 +1479,104 @@ return Path.Combine (AddinFolderCachePath, s + ".data"); } - internal void UninstallAddin (IProgressStatus monitor, string domain, string addinId, AddinScanResult scanResult) + internal void UninstallAddin (IProgressStatus monitor, string domain, string addinId, string addinFile, AddinScanResult scanResult) { - scanResult.AddRemovedAddin (addinId); - string file = GetDescriptionPath (domain, addinId); - if (!fileDatabase.Exists (file)) { + AddinDescription desc; + + if (!GetAddinDescription (monitor, domain, addinId, addinFile, out desc)) { + // If we can't get information about the old assembly, just regenerate all relation data + scanResult.RegenerateRelationData = true; return; } - // Add-in already existed. The dependencies of the old add-in need to be re-analized + scanResult.AddRemovedAddin (addinId); + + // If the add-in didn't exist, there is nothing left to do + + if (desc == null) + return; + + // If the add-in already existed, the dependencies of the old add-in need to be re-analized + + Util.AddDependencies (desc, scanResult); + if (desc.IsRoot) + scanResult.HostIndex.RemoveHostData (desc.AddinId, desc.AddinFile); - AddinDescription desc; - if (ReadAddinDescription (monitor, file, out desc)) { - Util.AddDependencies (desc, scanResult); - if (desc.IsRoot) - scanResult.HostIndex.RemoveHostData (desc.AddinId, desc.AddinFile); - } else - // If we can't get information about the old assembly, just regenerate all relation data - scanResult.RegenerateRelationData = true; + RemoveAddinDescriptionFile (monitor, desc.FileName); + } + + public bool GetAddinDescription (IProgressStatus monitor, string domain, string addinId, string addinFile, out AddinDescription description) + { + // If the same add-in is installed in different folders (in the same domain) there will be several .maddin files for it, + // using the suffix "_X" where X is a number > 1 (for example: someAddin,1.0.maddin, someAddin,1.0.maddin_2, someAddin,1.0.maddin_3, ...) + // We need to return the .maddin whose AddinFile matches the one being requested + + addinFile = Path.GetFullPath (addinFile); + int altNum = 1; + string baseFile = GetDescriptionPath (domain, addinId); + string file = baseFile; + bool failed = false; + + do { + if (!ReadAddinDescription (monitor, file, out description)) { + // Remove the AddinDescription here since it is corrupted. + // Avoids creating alternate versions of corrupted files when later calling SaveDescription. + RemoveAddinDescriptionFile (monitor, file); + failed = true; + continue; + } + if (description == null) + break; + if (Path.GetFullPath (description.AddinFile) == addinFile) + return true; + file = baseFile + "_" + (++altNum); + } + while (fileDatabase.Exists (file)); + + // File not found. Return false only if there has been any read error. + description = null; + return failed; + } + + bool RemoveAddinDescriptionFile (IProgressStatus monitor, string file) + { + // Removes an add-in description and shifts up alternate instances of the description file + // (so xxx,1.0.maddin_2 will become xxx,1.0.maddin, xxx,1.0.maddin_3 -> xxx,1.0.maddin_2, etc) + + if (!SafeDelete (monitor, file)) + return false; + + int dversion; + if (file.EndsWith (".maddin")) + dversion = 2; + else { + int i = file.LastIndexOf ('_'); + dversion = 1 + int.Parse (file.Substring (i + 1)); + file = file.Substring (0, i); + } - SafeDelete (monitor, file); + while (fileDatabase.Exists (file + "_" + dversion)) { + string newFile = dversion == 2 ? file : file + "_" + (dversion-1); + try { + fileDatabase.Rename (file + "_" + dversion, newFile); + } catch (Exception ex) { + if (monitor.LogLevel > 1) { + monitor.Log ("Could not rename file '" + file + "_" + dversion + "' to '" + newFile + "'"); + monitor.Log (ex.ToString ()); + } + } + dversion++; + } string dir = Path.GetDirectoryName (file); if (fileDatabase.DirectoryIsEmpty (dir)) SafeDeleteDir (monitor, dir); - SafeDeleteDir (monitor, Path.Combine (AddinPrivateDataPath, Path.GetFileNameWithoutExtension (file))); - } - - public bool GetAddinDescription (IProgressStatus monitor, string domain, string addinId, out AddinDescription description) - { - string file = GetDescriptionPath (domain, addinId); - return ReadAddinDescription (monitor, file, out description); + + if (dversion == 2) { + // All versions of the add-in removed. + SafeDeleteDir (monitor, Path.Combine (AddinPrivateDataPath, Path.GetFileNameWithoutExtension (file))); + } + + return true; } public bool ReadAddinDescription (IProgressStatus monitor, string file, out AddinDescription description) @@ -1186,6 +1606,14 @@ string dir = Path.GetDirectoryName (file); if (!fileDatabase.DirExists (dir)) fileDatabase.CreateDir (dir); + if (fileDatabase.Exists (file)) { + // Another AddinDescription already exists with the same name. + // Create an alternate AddinDescription file + int altNum = 2; + while (fileDatabase.Exists (file + "_" + altNum)) + altNum++; + file = file + "_" + altNum; + } desc.SaveBinary (fileDatabase, file); } return true; @@ -1328,10 +1756,23 @@ return false; } + ISetupHandler GetSetupHandler () + { +// if (Util.IsMono) +// return new SetupProcess (); +// else + if (fs.RequiresIsolation) + return new SetupDomain (); + else + return new SetupLocal (); + } + public void ResetConfiguration () { if (File.Exists (ConfigFile)) File.Delete (ConfigFile); + config = null; + ResetCachedData (); } DatabaseConfiguration Configuration { @@ -1394,29 +1835,27 @@ class AddinIndex { - Hashtable addins = new Hashtable (); + Dictionary> addins = new Dictionary> (); public void Add (AddinDescription desc) { string id = Addin.GetFullId (desc.Namespace, desc.LocalId, null); - ArrayList list = (ArrayList) addins [id]; - if (list == null) { - list = new ArrayList (); - addins [id] = list; - } + List list; + if (!addins.TryGetValue (id, out list)) + addins [id] = list = new List (); list.Add (desc); } - ArrayList FindDescriptions (string domain, string fullid) + List FindDescriptions (string domain, string fullid) { // Returns all registered add-ins which are compatible with the provided // fullid. Compatible means that the id is the same and the version is within // the range of compatible versions of the add-in. - ArrayList res = new ArrayList (); + var res = new List (); string id = Addin.GetIdName (fullid); - ArrayList list = (ArrayList) addins [id]; - if (list == null) + List list; + if (!addins.TryGetValue (id, out list)) return res; string version = Addin.GetIdVersion (fullid); foreach (AddinDescription desc in list) { @@ -1426,12 +1865,38 @@ return res; } - public ArrayList GetSortedAddins () + public IEnumerable GetMissingDependencies (AddinDescription desc, ModuleDescription mod) { - Hashtable inserted = new Hashtable (); - Hashtable lists = new Hashtable (); + foreach (Dependency dep in mod.Dependencies) { + AddinDependency adep = dep as AddinDependency; + if (adep == null) + continue; + var descs = FindDescriptions (desc.Domain, adep.FullAddinId); + if (descs.Count == 0) + yield return adep.FullAddinId; + } + } + + public AddinDescription GetSimilarExistingAddin (AddinDescription conf, string addinId) + { + string domain = conf.Domain; + List list; + if (!addins.TryGetValue (Addin.GetIdName (addinId), out list)) + return null; + string version = Addin.GetIdVersion (addinId); + foreach (AddinDescription desc in list) { + if ((desc.Domain == domain || domain == AddinDatabase.GlobalDomain) && !desc.SupportsVersion (version)) + return desc; + } + return null; + } + + public List GetSortedAddins () + { + var inserted = new HashSet (); + var lists = new Dictionary> (); - foreach (ArrayList dlist in addins.Values) { + foreach (List dlist in addins.Values) { foreach (AddinDescription desc in dlist) InsertSortedAddin (inserted, lists, desc); } @@ -1439,53 +1904,53 @@ // Merge all domain lists into a single list. // Make sure the global domain is inserted the last - ArrayList global = (ArrayList) lists [AddinDatabase.GlobalDomain]; + List global; + lists.TryGetValue (AddinDatabase.GlobalDomain, out global); lists.Remove (AddinDatabase.GlobalDomain); - ArrayList list = new ArrayList (); - foreach (ArrayList dl in lists.Values) { - list.AddRange (dl); + List sortedAddins = new List (); + foreach (var dl in lists.Values) { + sortedAddins.AddRange (dl); } if (global != null) - list.AddRange (global); - return list; + sortedAddins.AddRange (global); + return sortedAddins; } - void InsertSortedAddin (Hashtable inserted, Hashtable lists, AddinDescription desc) + void InsertSortedAddin (HashSet inserted, Dictionary> lists, AddinDescription desc) { string sid = desc.AddinId + " " + desc.Domain; - if (inserted.ContainsKey (sid)) + if (!inserted.Add (sid)) return; - inserted [sid] = desc; + foreach (ModuleDescription mod in desc.AllModules) { foreach (Dependency dep in mod.Dependencies) { AddinDependency adep = dep as AddinDependency; if (adep == null) continue; - ArrayList descs = FindDescriptions (desc.Domain, adep.FullAddinId); + var descs = FindDescriptions (desc.Domain, adep.FullAddinId); if (descs.Count > 0) { foreach (AddinDescription sd in descs) InsertSortedAddin (inserted, lists, sd); } -// else -// Console.WriteLine ("NOT FOUND: " + adep.FullAddinId + " " + desc.Domain + " from " + sid); } } - ArrayList list = (ArrayList) lists [desc.Domain]; - if (list == null) { - list = new ArrayList (); - lists [desc.Domain] = list; - } + List list; + if (!lists.TryGetValue (desc.Domain, out list)) + lists [desc.Domain] = list = new List (); list.Add (desc); } } - enum AddinType + // Keep in sync with AddinSearchFlags + enum AddinSearchFlagsInternal { - Addin, - Root, - All + IncludeAddins = 1, + IncludeRoots = 1 << 1, + IncludeAll = IncludeAddins | IncludeRoots, + LatestVersionsOnly = 1 << 3, + ExcludePendingUninstall = 1 << 4 } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Database/AddinFileSystemExtension.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Database/AddinFileSystemExtension.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Database/AddinFileSystemExtension.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Database/AddinFileSystemExtension.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,205 @@ +// +// AddinFileSystemExtension.cs +// +// Author: +// Lluis Sanchez Gual +// +// Copyright (c) 2011 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using System.IO; +using System.Reflection; + +namespace Mono.Addins.Database +{ + /// + /// An add-in file system extension. + /// + /// + /// File system extensions can override the behavior of the add-in scanner and provide custom rules for + /// locating and scanning assemblies. + /// + public class AddinFileSystemExtension + { + IAssemblyReflector reflector; + + /// + /// Called when the add-in scan is about to start + /// + public virtual void ScanStarted () + { + } + + /// + /// Called when the add-in scan has finished + /// + public virtual void ScanFinished () + { + } + + /// + /// Checks if a directory exists + /// + /// + /// 'true' if the directory exists + /// + /// + /// Directory path + /// + public virtual bool DirectoryExists (string path) + { + return Directory.Exists (path); + } + + /// + /// Checks if a file exists + /// + /// + /// 'true' if the file exists + /// + /// + /// Path to the file + /// + public virtual bool FileExists (string path) + { + return File.Exists (path); + } + + /// + /// Gets the files in a directory + /// + /// + /// The full path of the files in the directory + /// + /// + /// Directory path + /// + public virtual System.Collections.Generic.IEnumerable GetFiles (string path) + { + return Directory.GetFiles (path); + } + + /// + /// Gets the subdirectories of a directory + /// + /// + /// The subdirectories. + /// + /// + /// The directory + /// + public virtual System.Collections.Generic.IEnumerable GetDirectories (string path) + { + return Directory.GetDirectories (path); + } + + /// + /// Gets the last write time of a file + /// + /// + /// The last write time. + /// + /// + /// File path. + /// + public virtual DateTime GetLastWriteTime (string filePath) + { + return File.GetLastWriteTime (filePath); + } + + /// + /// Opens a text file + /// + /// + /// The text file stream + /// + /// + /// File path. + /// + public virtual System.IO.StreamReader OpenTextFile (string path) + { + return new StreamReader (path); + } + + /// + /// Opens a file. + /// + /// + /// The file stream. + /// + /// + /// The file path. + /// + public virtual System.IO.Stream OpenFile (string path) + { + return File.OpenRead (path); + } + + /// + /// Gets an assembly reflector for a file. + /// + /// + /// The reflector for the file. + /// + /// + /// An assembly locator + /// + /// + /// A file path + /// + public virtual IAssemblyReflector GetReflectorForFile (IAssemblyLocator locator, string path) + { + if (reflector != null) + return reflector; + + // If there is a local copy of the cecil reflector, use it instead of the one in the gac + Type t; + string asmFile = Path.Combine (Path.GetDirectoryName (GetType().Assembly.Location), "Mono.Addins.CecilReflector.dll"); + if (File.Exists (asmFile)) { + Assembly asm = Assembly.LoadFrom (asmFile); + t = asm.GetType ("Mono.Addins.CecilReflector.Reflector"); + } + else { + string refName = GetType().Assembly.FullName; + int i = refName.IndexOf (','); + refName = "Mono.Addins.CecilReflector.Reflector, Mono.Addins.CecilReflector" + refName.Substring (i); + t = Type.GetType (refName, false); + } + if (t != null) + reflector = (IAssemblyReflector) Activator.CreateInstance (t); + else + reflector = new DefaultAssemblyReflector (); + + reflector.Initialize (locator); + return reflector; + } + + /// + /// Gets a value indicating whether this needs to be isolated from the main execution process + /// + /// + /// true if requires isolation; otherwise, false. + /// + public virtual bool RequiresIsolation { + get { return true; } + } + } +} + diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Database/AddinHostIndex.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Database/AddinHostIndex.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Database/AddinHostIndex.cs 2008-11-06 19:52:14.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Database/AddinHostIndex.cs 2011-04-13 09:00:29.000000000 +0000 @@ -30,6 +30,7 @@ using System; using System.Collections; using Mono.Addins.Serialization; +using System.IO; namespace Mono.Addins.Database { @@ -42,13 +43,13 @@ public void RegisterAssembly (string assemblyLocation, string addinId, string addinLocation, string domain) { assemblyLocation = NormalizeFileName (assemblyLocation); - index [Util.GetFullPath (assemblyLocation)] = addinId + " " + addinLocation + " " + domain; + index [Path.GetFullPath (assemblyLocation)] = addinId + " " + addinLocation + " " + domain; } public bool GetAddinForAssembly (string assemblyLocation, out string addinId, out string addinLocation, out string domain) { assemblyLocation = NormalizeFileName (assemblyLocation); - string s = index [Util.GetFullPath (assemblyLocation)] as string; + string s = index [Path.GetFullPath (assemblyLocation)] as string; if (s == null) { addinId = null; addinLocation = null; @@ -67,7 +68,7 @@ public void RemoveHostData (string addinId, string addinLocation) { - string loc = addinId + " " + Util.GetFullPath (addinLocation) + " "; + string loc = addinId + " " + Path.GetFullPath (addinLocation) + " "; ArrayList todelete = new ArrayList (); foreach (DictionaryEntry e in index) { if (((string)e.Value).StartsWith (loc)) diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Database/AddinScanFolderInfo.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Database/AddinScanFolderInfo.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Database/AddinScanFolderInfo.cs 2008-11-06 19:52:14.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Database/AddinScanFolderInfo.cs 2011-04-13 09:00:29.000000000 +0000 @@ -72,7 +72,7 @@ public static AddinScanFolderInfo Read (FileDatabase filedb, string basePath, string folderPath) { string fileName; - AddinScanFolderInfo finfo = (AddinScanFolderInfo) filedb.ReadSharedObject (basePath, GetDomain (folderPath), ".data", Util.GetFullPath (folderPath), typeMap, out fileName); + AddinScanFolderInfo finfo = (AddinScanFolderInfo) filedb.ReadSharedObject (basePath, GetDomain (folderPath), ".data", Path.GetFullPath (folderPath), typeMap, out fileName); if (finfo != null) finfo.fileName = fileName; return finfo; @@ -80,7 +80,7 @@ static string GetDomain (string path) { - path = Util.GetFullPath (path); + path = Path.GetFullPath (path); string s = path.Replace (Path.DirectorySeparatorChar, '_'); s = s.Replace (Path.AltDirectorySeparatorChar, '_'); s = s.Replace (Path.VolumeSeparatorChar, '_'); @@ -90,7 +90,7 @@ public void Write (FileDatabase filedb, string basePath) { - filedb.WriteSharedObject (basePath, GetDomain (folder), ".data", Util.GetFullPath (folder), fileName, typeMap, this); + filedb.WriteSharedObject (basePath, GetDomain (folder), ".data", Path.GetFullPath (folder), fileName, typeMap, this); } public string GetExistingLocalDomain () @@ -178,11 +178,11 @@ return info; } - public ArrayList GetMissingAddins () + public ArrayList GetMissingAddins (AddinFileSystemExtension fs) { ArrayList missing = new ArrayList (); - if (!Directory.Exists (folder)) { + if (!fs.DirectoryExists (folder)) { // All deleted foreach (AddinFileInfo info in files.Values) { if (info.IsAddin) @@ -193,7 +193,7 @@ } ArrayList toDelete = new ArrayList (); foreach (AddinFileInfo info in files.Values) { - if (!File.Exists (info.File)) { + if (!fs.FileExists (info.File)) { if (info.IsAddin) missing.Add (info); toDelete.Add (info.File); diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Database/AddinScanner.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Database/AddinScanner.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Database/AddinScanner.cs 2008-11-06 19:52:14.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Database/AddinScanner.cs 2011-04-13 09:00:29.000000000 +0000 @@ -29,6 +29,7 @@ using System; using System.Collections; +using System.Collections.Generic; using System.IO; using System.Text; using System.Reflection; @@ -43,32 +44,18 @@ class AddinScanner: MarshalByRefObject { AddinDatabase database; - IAssemblyReflector reflector; - object coreAssembly; + AddinFileSystemExtension fs; + Dictionary coreAssemblies = new Dictionary (); public AddinScanner (AddinDatabase database, AddinScanResult scanResult, IProgressStatus monitor) { this.database = database; - if (!scanResult.CheckOnly) { - string refName = GetType().Assembly.FullName; - int i = refName.IndexOf (','); - refName = "Mono.Addins.CecilReflector.Reflector, Mono.Addins.CecilReflector" + refName.Substring (i); - Type t = Type.GetType (refName, false); - if (t != null) - reflector = (IAssemblyReflector) Activator.CreateInstance (t); - else - reflector = new DefaultAssemblyReflector (); - - if (monitor.LogLevel > 1) - monitor.Log ("Using assembly reflector: " + reflector.GetType ()); - reflector.Initialize (scanResult); - coreAssembly = reflector.LoadAssembly (GetType().Assembly.Location); - } + fs = database.FileSystem; } public void ScanFolder (IProgressStatus monitor, string path, string domain, AddinScanResult scanResult) { - path = Util.GetFullPath (path); + path = Path.GetFullPath (path); // Avoid folders including each other if (!scanResult.VisitFolder (path)) @@ -78,11 +65,11 @@ if (!database.GetFolderInfoForPath (monitor, path, out folderInfo)) { // folderInfo file was corrupt. // Just in case, we are going to regenerate all relation data. - if (!Directory.Exists (path)) + if (!fs.DirectoryExists (path)) scanResult.RegenerateRelationData = true; } else { // Directory is included but it doesn't exist. Ignore it. - if (folderInfo == null && !Directory.Exists (path)) + if (folderInfo == null && !fs.DirectoryExists (path)) return; } @@ -133,9 +120,9 @@ if (monitor.LogLevel > 1 && !scanResult.LocateAssembliesOnly) monitor.Log ("Checking: " + path); - if (Directory.Exists (path)) + if (fs.DirectoryExists (path)) { - string[] files = Directory.GetFiles (path); + IEnumerable files = fs.GetFiles (path); // First of all, look for .addin files. Addin files must be processed before // assemblies, because they may add files to the ignore list (i.e., assemblies @@ -183,16 +170,16 @@ public void UpdateDeletedAddins (IProgressStatus monitor, AddinScanFolderInfo folderInfo, AddinScanResult scanResult) { - ArrayList missing = folderInfo.GetMissingAddins (); + ArrayList missing = folderInfo.GetMissingAddins (fs); if (missing.Count > 0) { - if (Directory.Exists (folderInfo.Folder)) + if (fs.DirectoryExists (folderInfo.Folder)) scanResult.RegisterModifiedFolderInfo (folderInfo); scanResult.ChangesFound = true; if (scanResult.CheckOnly) return; foreach (AddinFileInfo info in missing) { - database.UninstallAddin (monitor, info.Domain, info.AddinId, scanResult); + database.UninstallAddin (monitor, info.Domain, info.AddinId, info.File, scanResult); } } } @@ -205,7 +192,7 @@ AddinFileInfo finfo = folderInfo.GetAddinFileInfo (file); bool added = false; - if (finfo != null && (!finfo.IsAddin || finfo.Domain == folderInfo.GetDomain (finfo.IsRoot)) && File.GetLastWriteTime (file) == finfo.LastScan && !scanResult.RegenerateAllData) { + if (finfo != null && (!finfo.IsAddin || finfo.Domain == folderInfo.GetDomain (finfo.IsRoot)) && fs.GetLastWriteTime (file) == finfo.LastScan && !scanResult.RegenerateAllData) { if (finfo.ScanError) { // Always schedule the file for scan if there was an error in a previous scan. // However, don't set ChangesFound=true, in this way if there isn't any other @@ -238,7 +225,7 @@ // The file must be ignored. Maybe it caused a crash in a previous scan, or it // might be included by a .addin file (in which case it will be scanned when processing // the .addin file). - folderInfo.SetLastScanTime (file, null, false, File.GetLastWriteTime (file), true); + folderInfo.SetLastScanTime (file, null, false, fs.GetLastWriteTime (file), true); return; } @@ -255,7 +242,7 @@ AddinDescription config = null; try { - string ext = Path.GetExtension (file); + string ext = Path.GetExtension (file).ToLower (); if (ext == ".dll" || ext == ".exe") scanSuccessful = ScanAssembly (monitor, file, scanResult, out config); @@ -278,7 +265,7 @@ } // Check errors in the description - StringCollection errors = config.Verify (); + StringCollection errors = config.Verify (fs); if (database.IsGlobalRegistry && config.AddinId.IndexOf ('.') == -1) { errors.Add ("Add-ins registered in the global registry must have a namespace."); @@ -301,7 +288,7 @@ // Also, the dependencies of the old add-in need to be re-analized AddinDescription existingDescription = null; - bool res = database.GetAddinDescription (monitor, folderInfo.Domain, config.AddinId, out existingDescription); + bool res = database.GetAddinDescription (monitor, folderInfo.Domain, config.AddinId, config.AddinFile, out existingDescription); // If we can't get information about the old assembly, just regenerate all relation data if (!res) @@ -319,7 +306,7 @@ // If the scanned file results in an add-in version different from the one obtained from // previous scans, the old add-in needs to be uninstalled. if (fi != null && fi.IsAddin && fi.AddinId != config.AddinId) { - database.UninstallAddin (monitor, folderInfo.Domain, fi.AddinId, scanResult); + database.UninstallAddin (monitor, folderInfo.Domain, fi.AddinId, fi.File, scanResult); // If the add-in version has changed, regenerate everything again since old data can't be reused if (Addin.GetIdName (fi.AddinId) == Addin.GetIdName (config.AddinId)) @@ -354,7 +341,7 @@ if (database.SaveDescription (monitor, config, replaceFileName)) { // The new dependencies also have to be updated Util.AddDependencies (config, scanResult); - scanResult.AddAddinToUpdateRelations (config.AddinId); + scanResult.AddAddinToUpdate (config.AddinId); scannedAddinId = config.AddinId; scannedIsRoot = config.IsRoot; return; @@ -366,13 +353,13 @@ monitor.ReportError ("Unexpected error while scanning file: " + file, ex); } finally { - AddinFileInfo ainfo = folderInfo.SetLastScanTime (file, scannedAddinId, scannedIsRoot, File.GetLastWriteTime (file), !scanSuccessful); + AddinFileInfo ainfo = folderInfo.SetLastScanTime (file, scannedAddinId, scannedIsRoot, fs.GetLastWriteTime (file), !scanSuccessful); if (scanSuccessful && config != null) { // Update the ignore list in the folder info object. To be used in the next scan foreach (string df in config.AllIgnorePaths) { string path = Path.Combine (config.BasePath, df); - ainfo.AddPathToIgnore (Util.GetFullPath (path)); + ainfo.AddPathToIgnore (Path.GetFullPath (path)); } } @@ -390,7 +377,7 @@ monitor.Log ("plog:scan:" + file); try { - string ext = Path.GetExtension (file); + string ext = Path.GetExtension (file).ToLower (); bool scanSuccessful; if (ext == ".dll" || ext == ".exe") @@ -426,7 +413,7 @@ string basePath = Path.GetDirectoryName (file); try { - r = new XmlTextReader (new StreamReader (file)); + r = new XmlTextReader (fs.OpenTextFile (file)); r.MoveToContent (); if (r.IsEmptyElement) return; @@ -470,7 +457,7 @@ path = Util.NormalizePath (path); if (!Path.IsPathRooted (path)) path = Path.Combine (basePath, path); - scanResult.AddPathToIgnore (Util.GetFullPath (path)); + scanResult.AddPathToIgnore (Path.GetFullPath (path)); } } else @@ -503,10 +490,10 @@ { ScanFolder (monitor, dir, domain, scanResult); - if (!Directory.Exists (dir)) + if (!fs.DirectoryExists (dir)) return; - foreach (string sd in Directory.GetDirectories (dir)) + foreach (string sd in fs.GetDirectories (dir)) ScanFolderRec (monitor, sd, domain, scanResult); } @@ -515,13 +502,18 @@ config = null; try { + IAssemblyReflector reflector = GetReflector (monitor, scanResult, filePath); + string basePath = Path.GetDirectoryName (filePath); - config = AddinDescription.Read (filePath); - config.BasePath = basePath; + using (var s = fs.OpenFile (filePath)) { + config = AddinDescription.Read (s, basePath); + } + config.FileName = filePath; + config.SetBasePath (basePath); config.AddinFile = filePath; - return ScanDescription (monitor, config, null, scanResult); + return ScanDescription (monitor, reflector, config, null, scanResult); } catch (Exception ex) { // Something went wrong while scanning the assembly. We'll ignore it for now. @@ -530,47 +522,64 @@ } } + IAssemblyReflector GetReflector (IProgressStatus monitor, AddinScanResult scanResult, string filePath) + { + IAssemblyReflector reflector = fs.GetReflectorForFile (scanResult, filePath); + object coreAssembly; + if (!coreAssemblies.TryGetValue (reflector, out coreAssembly)) { + if (monitor.LogLevel > 1) + monitor.Log ("Using assembly reflector: " + reflector.GetType ()); + coreAssemblies [reflector] = coreAssembly = reflector.LoadAssembly (GetType().Assembly.Location); + } + return reflector; + } + bool ScanAssembly (IProgressStatus monitor, string filePath, AddinScanResult scanResult, out AddinDescription config) { config = null; try { - Assembly asm = Util.LoadAssemblyForReflection (filePath); + IAssemblyReflector reflector = GetReflector (monitor, scanResult, filePath); + object asm = reflector.LoadAssembly (filePath); + if (asm == null) + throw new Exception ("Could not load assembly: " + filePath); // Get the config file from the resources, if there is one - string configFile = null; - foreach (string res in asm.GetManifestResourceNames ()) { + foreach (string res in reflector.GetResourceNames (asm)) { if (res.EndsWith (".addin") || res.EndsWith (".addin.xml")) { - configFile = res; - break; + using (Stream s = reflector.GetResourceStream (asm, res)) { + AddinDescription ad = AddinDescription.Read (s, Path.GetDirectoryName (filePath)); + if (config != null) { + if (!config.IsExtensionModel && !ad.IsExtensionModel) { + // There is more than one add-in definition + monitor.ReportError ("Duplicate add-in definition found in assembly: " + filePath, null); + return false; + } + config = AddinDescription.Merge (config, ad); + } else + config = ad; + } } } - if (configFile != null) { - using (Stream s = asm.GetManifestResourceStream (configFile)) { - string asmFile = new Uri (asm.CodeBase).LocalPath; - config = AddinDescription.Read (s, Path.GetDirectoryName (asmFile)); - } - } - else { - // On this case, only scan the assembly if it has the Addin attribute. - AddinAttribute att = (AddinAttribute) Attribute.GetCustomAttribute (asm, typeof(AddinAttribute), false); - if (att == null) { - config = null; + if (config == null) { + // In this case, only scan the assembly if it has the Addin attribute. + AddinAttribute att = (AddinAttribute) reflector.GetCustomAttribute (asm, typeof(AddinAttribute), false); + if (att == null) return true; - } + config = new AddinDescription (); } - config.BasePath = Path.GetDirectoryName (filePath); + config.SetBasePath (Path.GetDirectoryName (filePath)); config.AddinFile = filePath; string rasmFile = Path.GetFileName (filePath); if (!config.MainModule.Assemblies.Contains (rasmFile)) config.MainModule.Assemblies.Add (rasmFile); - return ScanDescription (monitor, config, asm, scanResult); + return ScanDescription (monitor, reflector, config, asm, scanResult); } catch (Exception ex) { // Something went wrong while scanning the assembly. We'll ignore it for now. @@ -579,37 +588,47 @@ } } - bool ScanDescription (IProgressStatus monitor, AddinDescription config, Assembly rootAssembly, AddinScanResult scanResult) + bool ScanDescription (IProgressStatus monitor, IAssemblyReflector reflector, AddinDescription config, object rootAssembly, AddinScanResult scanResult) { // First of all scan the main module ArrayList assemblies = new ArrayList (); - ArrayList asmFiles = new ArrayList (); - ArrayList hostExtensionClasses = new ArrayList (); try { + string rootAsmFile = null; + + if (rootAssembly != null) { + ScanAssemblyAddinHeaders (reflector, config, rootAssembly, scanResult); + ScanAssemblyImports (reflector, config.MainModule, rootAssembly); + assemblies.Add (rootAssembly); + rootAsmFile = Path.GetFileName (config.AddinFile); + } + + // The assembly list may be modified while scanning the headears, so + // we use a for loop instead of a foreach + for (int n=0; n 0) config.Category = att.Category; + if (att.CompatVersion.Length > 0) + config.CompatVersion = att.CompatVersion; + if (att.Url.Length > 0) + config.Url = att.Url; config.IsRoot = att is AddinRootAttribute; + config.EnabledByDefault = att.EnabledByDefault; + config.Flags = att.Flags; + } + + // Author attributes + + object[] atts = reflector.GetCustomAttributes (asm, typeof(AddinAuthorAttribute), false); + foreach (AddinAuthorAttribute author in atts) { + if (config.Author.Length == 0) + config.Author = author.Name; + else + config.Author += ", " + author.Name; + } + + // Name + + atts = reflector.GetCustomAttributes (asm, typeof(AddinNameAttribute), false); + foreach (AddinNameAttribute at in atts) { + if (string.IsNullOrEmpty (at.Locale)) + config.Name = at.Name; + else + config.Properties.SetPropertyValue ("Name", at.Name, at.Locale); + } + + // Description + + object catt = reflector.GetCustomAttribute (asm, typeof(AssemblyDescriptionAttribute), false); + if (catt != null && config.Description.Length == 0) + config.Description = ((AssemblyDescriptionAttribute)catt).Description; + + atts = reflector.GetCustomAttributes (asm, typeof(AddinDescriptionAttribute), false); + foreach (AddinDescriptionAttribute at in atts) { + if (string.IsNullOrEmpty (at.Locale)) + config.Description = at.Description; + else + config.Properties.SetPropertyValue ("Description", at.Description, at.Locale); + } + + // Copyright + + catt = reflector.GetCustomAttribute (asm, typeof(AssemblyCopyrightAttribute), false); + if (catt != null && config.Copyright.Length == 0) + config.Copyright = ((AssemblyCopyrightAttribute)catt).Copyright; + + // Localizer + + AddinLocalizerGettextAttribute locat = (AddinLocalizerGettextAttribute) reflector.GetCustomAttribute (asm, typeof(AddinLocalizerGettextAttribute), false); + if (locat != null) { + ExtensionNodeDescription node = new ExtensionNodeDescription (); + if (!string.IsNullOrEmpty (locat.Catalog)) + node.SetAttribute ("catalog", locat.Catalog); + if (!string.IsNullOrEmpty (locat.Location)) + node.SetAttribute ("location", locat.Catalog); + config.Localizer = node; + } + + // Optional modules + + atts = reflector.GetCustomAttributes (asm, typeof(AddinModuleAttribute), false); + foreach (AddinModuleAttribute mod in atts) { + if (mod.AssemblyFile.Length > 0) { + ModuleDescription module = new ModuleDescription (); + module.Assemblies.Add (mod.AssemblyFile); + config.OptionalModules.Add (module); + } + } + } + + void ScanAssemblyImports (IAssemblyReflector reflector, ModuleDescription module, object asm) + { + object[] atts = reflector.GetCustomAttributes (asm, typeof(ImportAddinAssemblyAttribute), false); + foreach (ImportAddinAssemblyAttribute import in atts) { + if (!string.IsNullOrEmpty (import.FilePath)) { + module.Assemblies.Add (import.FilePath); + if (!import.Scan) + module.IgnorePaths.Add (import.FilePath); + } + } + atts = reflector.GetCustomAttributes (asm, typeof(ImportAddinFileAttribute), false); + foreach (ImportAddinFileAttribute import in atts) { + if (!string.IsNullOrEmpty (import.FilePath)) + module.DataFiles.Add (import.FilePath); } } - void ScanAssemblyContents (AddinDescription config, object asm, ArrayList hostExtensionClasses, AddinScanResult scanResult) + void ScanAssemblyContents (IAssemblyReflector reflector, AddinDescription config, ModuleDescription module, object asm, AddinScanResult scanResult) { + bool isMainModule = module == config.MainModule; + // Get dependencies object[] deps = reflector.GetCustomAttributes (asm, typeof(AddinDependencyAttribute), false); @@ -708,51 +824,68 @@ AddinDependency adep = new AddinDependency (); adep.AddinId = dep.Id; adep.Version = dep.Version; - config.MainModule.Dependencies.Add (adep); + module.Dependencies.Add (adep); } - // Get extension points + if (isMainModule) { + + // Get properties + + object[] props = reflector.GetCustomAttributes (asm, typeof(AddinPropertyAttribute), false); + foreach (AddinPropertyAttribute prop in props) + config.Properties.SetPropertyValue (prop.Name, prop.Value, prop.Locale); - object[] extPoints = reflector.GetCustomAttributes (asm, typeof(ExtensionPointAttribute), false); - foreach (ExtensionPointAttribute ext in extPoints) { - ExtensionPoint ep = config.AddExtensionPoint (ext.Path); - ep.Description = ext.Description; - ep.Name = ext.Name; - ep.AddExtensionNode (ext.NodeName, ext.NodeTypeName); + // Get extension points + + object[] extPoints = reflector.GetCustomAttributes (asm, typeof(ExtensionPointAttribute), false); + foreach (ExtensionPointAttribute ext in extPoints) { + ExtensionPoint ep = config.AddExtensionPoint (ext.Path); + ep.Description = ext.Description; + ep.Name = ext.Name; + ExtensionNodeType nt = ep.AddExtensionNode (ext.NodeName, ext.NodeTypeName); + nt.ExtensionAttributeTypeName = ext.ExtensionAttributeTypeName; + } } + // Look for extension nodes declared using assembly attributes + + foreach (CustomAttribute att in reflector.GetRawCustomAttributes (asm, typeof(CustomExtensionAttribute), true)) + AddCustomAttributeExtension (module, att, "Type"); + + // Get extensions or extension points applied to types + foreach (object t in reflector.GetAssemblyTypes (asm)) { string typeFullName = reflector.GetTypeFullName (t); + // Look for extensions + object[] extensionAtts = reflector.GetCustomAttributes (t, typeof(ExtensionAttribute), false); if (extensionAtts.Length > 0) { + Dictionary nodes = new Dictionary (); + ExtensionNodeDescription uniqueNode = null; foreach (ExtensionAttribute eatt in extensionAtts) { string path; - string nodeName; + string nodeName = eatt.NodeName; - if (eatt.Path.Length == 0) { - if (config.IsRoot) { - // The extension point must be one of the defined by the assembly - // Look for it later, when the assembly has been fully scanned. - hostExtensionClasses.Add (t); - continue; - } - else { - path = GetBaseTypeNameList (t); - if (path == "$") { - // The type does not implement any interface and has no superclass. - // Will be reported later as an error. - path = "$" + typeFullName; - } - nodeName = "Type"; + if (eatt.TypeName.Length > 0) { + path = "$" + eatt.TypeName; + } + else if (eatt.Path.Length == 0) { + path = GetBaseTypeNameList (reflector, t); + if (path == "$") { + // The type does not implement any interface and has no superclass. + // Will be reported later as an error. + path = "$" + typeFullName; } } else { path = eatt.Path; - nodeName = eatt.NodeName; } - - ExtensionNodeDescription elem = config.MainModule.AddExtensionNode (path, nodeName); + + ExtensionNodeDescription elem = module.AddExtensionNode (path, nodeName); + nodes [path] = elem; + uniqueNode = elem; + if (eatt.Id.Length > 0) { elem.SetAttribute ("id", eatt.Id); elem.SetAttribute ("type", typeFullName); @@ -762,46 +895,93 @@ if (eatt.InsertAfter.Length > 0) elem.SetAttribute ("insertafter", eatt.InsertAfter); if (eatt.InsertBefore.Length > 0) - elem.SetAttribute ("insertbefore", eatt.InsertAfter); + elem.SetAttribute ("insertbefore", eatt.InsertBefore); + } + + // Get the node attributes + + foreach (ExtensionAttributeAttribute eat in reflector.GetCustomAttributes (t, typeof(ExtensionAttributeAttribute), false)) { + ExtensionNodeDescription node; + if (!string.IsNullOrEmpty (eat.Path)) + nodes.TryGetValue (eat.Path, out node); + else if (eat.TypeName.Length > 0) + nodes.TryGetValue ("$" + eat.TypeName, out node); + else { + if (nodes.Count > 1) + throw new Exception ("Missing type or extension path value in ExtensionAttribute for type '" + typeFullName + "'."); + node = uniqueNode; + } + if (node == null) + throw new Exception ("Invalid type or path value in ExtensionAttribute for type '" + typeFullName + "'."); + + node.SetAttribute (eat.Name ?? string.Empty, eat.Value ?? string.Empty); } } else { - foreach (TypeExtensionPointAttribute epa in reflector.GetCustomAttributes (t, typeof(TypeExtensionPointAttribute), false)) { - ExtensionPoint ep; - - ExtensionNodeType nt = new ExtensionNodeType (); - - if (epa.Path.Length > 0) { - ep = config.AddExtensionPoint (epa.Path); + // Look for extension points + + extensionAtts = reflector.GetCustomAttributes (t, typeof(TypeExtensionPointAttribute), false); + if (extensionAtts.Length > 0 && isMainModule) { + foreach (TypeExtensionPointAttribute epa in extensionAtts) { + ExtensionPoint ep; + + ExtensionNodeType nt = new ExtensionNodeType (); + + if (epa.Path.Length > 0) { + ep = config.AddExtensionPoint (epa.Path); + } + else { + ep = config.AddExtensionPoint (GetDefaultTypeExtensionPath (config, typeFullName)); + nt.ObjectTypeName = typeFullName; + } + nt.Id = epa.NodeName; + nt.TypeName = epa.NodeTypeName; + nt.ExtensionAttributeTypeName = epa.ExtensionAttributeTypeName; + ep.NodeSet.NodeTypes.Add (nt); + ep.Description = epa.Description; + ep.Name = epa.Name; + ep.RootAddin = config.AddinId; + ep.SetExtensionsAddinId (config.AddinId); } - else { - ep = config.AddExtensionPoint (GetDefaultTypeExtensionPath (config, typeFullName)); - nt.ObjectTypeName = typeFullName; + } + else { + // Look for custom extension attribtues + foreach (CustomAttribute att in reflector.GetRawCustomAttributes (t, typeof(CustomExtensionAttribute), false)) { + ExtensionNodeDescription elem = AddCustomAttributeExtension (module, att, "Type"); + elem.SetAttribute ("type", typeFullName); + if (string.IsNullOrEmpty (elem.GetAttribute ("id"))) + elem.SetAttribute ("id", typeFullName); } - nt.Id = epa.NodeName; - nt.TypeName = epa.NodeType.FullName; - ep.NodeSet.NodeTypes.Add (nt); - ep.Description = epa.Description; - ep.Name = epa.Name; - ep.RootAddin = config.AddinId; - ep.SetExtensionsAddinId (config.AddinId); } } } } - void ScanNodeSet (AddinDescription config, ExtensionNodeSet nset, ArrayList assemblies, Hashtable internalNodeSets) + ExtensionNodeDescription AddCustomAttributeExtension (ModuleDescription module, CustomAttribute att, string nameName) + { + string path; + if (!att.TryGetValue (CustomExtensionAttribute.PathFieldKey, out path)) + path = "%" + att.TypeName; + ExtensionNodeDescription elem = module.AddExtensionNode (path, nameName); + foreach (KeyValuePair prop in att) { + if (prop.Key != CustomExtensionAttribute.PathFieldKey) + elem.SetAttribute (prop.Key, prop.Value); + } + return elem; + } + + void ScanNodeSet (IAssemblyReflector reflector, AddinDescription config, ExtensionNodeSet nset, ArrayList assemblies, Hashtable internalNodeSets) { foreach (ExtensionNodeType nt in nset.NodeTypes) - ScanNodeType (config, nt, assemblies, internalNodeSets); + ScanNodeType (reflector, config, nt, assemblies, internalNodeSets); } - void ScanNodeType (AddinDescription config, ExtensionNodeType nt, ArrayList assemblies, Hashtable internalNodeSets) + void ScanNodeType (IAssemblyReflector reflector, AddinDescription config, ExtensionNodeType nt, ArrayList assemblies, Hashtable internalNodeSets) { if (nt.TypeName.Length == 0) nt.TypeName = "Mono.Addins.TypeExtensionNode"; - object ntype = FindAddinType (nt.TypeName, assemblies); + object ntype = FindAddinType (reflector, nt.TypeName, assemblies); if (ntype == null) return; @@ -812,6 +992,8 @@ nt.Id = nodeAtt.NodeName; if (nt.Description.Length == 0 && nodeAtt.Description.Length > 0) nt.Description = nodeAtt.Description; + if (nt.ExtensionAttributeTypeName.Length == 0 && nodeAtt.ExtensionAttributeTypeName.Length > 0) + nt.ExtensionAttributeTypeName = nodeAtt.ExtensionAttributeTypeName; } else { // Use the node type name as default name if (nt.Id.Length == 0) @@ -874,7 +1056,7 @@ // same internal set. internalNodeSets [nt.TypeName] = internalSet.Id; internalNodeSets [reflector.GetTypeAssemblyQualifiedName (ntype)] = internalSet.Id; - ScanNodeSet (config, internalSet, assemblies, internalNodeSets); + ScanNodeSet (reflector, config, internalSet, assemblies, internalNodeSets); } } else { @@ -888,10 +1070,10 @@ return; } - ScanNodeSet (config, nt, assemblies, internalNodeSets); + ScanNodeSet (reflector, config, nt, assemblies, internalNodeSets); } - string GetBaseTypeNameList (object type) + string GetBaseTypeNameList (IAssemblyReflector reflector, object type) { StringBuilder sb = new StringBuilder ("$"); foreach (string tn in reflector.GetBaseTypeFullNameList (type)) @@ -901,30 +1083,10 @@ return sb.ToString (); } - void RegisterHostTypeNode (AddinDescription config, object t, ArrayList assemblies) - { - foreach (ExtensionAttribute eatt in reflector.GetCustomAttributes (t, typeof(ExtensionAttribute), false)) { - if (eatt.Path.Length > 0) - continue; - - foreach (ExtensionPoint ep in config.ExtensionPoints) { - foreach (ExtensionNodeType nt in ep.NodeSet.NodeTypes) { - if (nt.ObjectTypeName.Length == 0) - continue; - object etype = FindAddinType (nt.ObjectTypeName, assemblies); - if (etype != null && reflector.TypeIsAssignableFrom (etype, t)) { - RegisterTypeNode (config, eatt, ep.Path, nt.Id, reflector.GetTypeFullName (t)); - return; - } - } - } - } - } - - object FindAddinType (string typeName, ArrayList assemblies) + object FindAddinType (IAssemblyReflector reflector, string typeName, ArrayList assemblies) { // Look in the current assembly - object etype = reflector.GetType (coreAssembly, typeName); + object etype = reflector.GetType (coreAssemblies [reflector], typeName); if (etype != null) return etype; @@ -966,7 +1128,7 @@ if (eatt.InsertAfter.Length > 0) elem.SetAttribute ("insertafter", eatt.InsertAfter); if (eatt.InsertBefore.Length > 0) - elem.SetAttribute ("insertbefore", eatt.InsertAfter); + elem.SetAttribute ("insertbefore", eatt.InsertBefore); } internal string GetDefaultTypeExtensionPath (AddinDescription desc, string typeFullName) diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Database/AddinScanResult.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Database/AddinScanResult.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Database/AddinScanResult.cs 2008-11-06 19:52:14.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Database/AddinScanResult.cs 2011-04-13 09:00:29.000000000 +0000 @@ -28,23 +28,23 @@ using System; -using System.Reflection; -using System.IO; using System.Collections; -using System.Collections.Specialized; -using Mono.Addins.Description; +using System.Collections.Generic; +using System.IO; +using System.Reflection; namespace Mono.Addins.Database { internal class AddinScanResult: MarshalByRefObject, IAssemblyLocator { internal ArrayList AddinsToScan = new ArrayList (); - internal ArrayList AddinsToUpdateRelations = new ArrayList (); + internal List AddinsToUpdateRelations = new List (); + internal List AddinsToUpdate = new List (); internal ArrayList FilesToScan = new ArrayList (); internal ArrayList ModifiedFolderInfos = new ArrayList (); internal ArrayList FilesWithScanFailure = new ArrayList (); internal AddinHostIndex HostIndex; - internal ArrayList RemovedAddins = new ArrayList (); + internal List RemovedAddins = new List (); Hashtable visitedFolders = new Hashtable (); Hashtable assemblyLocations = new Hashtable (); @@ -148,6 +148,12 @@ AddinsToUpdateRelations.Add (addinId); } + public void AddAddinToUpdate (string addinId) + { + if (!AddinsToUpdate.Contains (addinId)) + AddinsToUpdate.Add (addinId); + } + public void AddAssemblyLocation (string file) { string name = Path.GetFileNameWithoutExtension (file); @@ -167,6 +173,8 @@ int i = fullName.IndexOf (','); string name = fullName.Substring (0,i); + if (name == "Mono.Addins") + return GetType ().Assembly.Location; ArrayList list = assemblyLocations [name] as ArrayList; if (list == null) return null; diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Database/AddinUpdateData.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Database/AddinUpdateData.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Database/AddinUpdateData.cs 2008-11-06 19:52:14.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Database/AddinUpdateData.cs 2011-04-13 09:00:29.000000000 +0000 @@ -30,21 +30,24 @@ using System; using System.Collections; using Mono.Addins.Description; +using System.Collections.Generic; namespace Mono.Addins.Database { class AddinUpdateData { - // This table collects information about extensions. For each path (key) - // has a ExtensionInfo object with information about the addin that + // This table collects information about extensions. Each path (key) + // has a RootExtensionPoint object with information about the addin that // defines the extension point and the addins which extend it - Hashtable pathHash = new Hashtable (); + Dictionary> pathHash = new Dictionary> (); // Collects globally defined node sets. Key is node set name. Value is - // a ExtensionInfo - Hashtable nodeSetHash = new Hashtable (); + // a RootExtensionPoint + Dictionary> nodeSetHash = new Dictionary> (); - Hashtable objectTypeExtensions = new Hashtable (); + Dictionary> objectTypeExtensions = new Dictionary> (); + + Dictionary> customAttributeTypeExtensions = new Dictionary> (); internal int RelExtensionPoints; internal int RelExtensions; @@ -66,10 +69,10 @@ public void RegisterNodeSet (AddinDescription description, ExtensionNodeSet nset) { - ArrayList extensions = (ArrayList) nodeSetHash [nset.Id]; - if (extensions != null) { + List extensions; + if (nodeSetHash.TryGetValue (nset.Id, out extensions)) { // Extension point already registered - ArrayList compatExtensions = GetCompatibleExtensionPoints (nset.Id, description, description.MainModule, extensions); + List compatExtensions = GetCompatibleExtensionPoints (nset.Id, description, description.MainModule, extensions); if (compatExtensions.Count > 0) { foreach (ExtensionPoint einfo in compatExtensions) einfo.NodeSet.MergeWith (null, nset); @@ -84,7 +87,7 @@ rep.ExtensionPoint.Path = nset.Id; rep.Description = description; if (extensions == null) { - extensions = new ArrayList (); + extensions = new List (); nodeSetHash [nset.Id] = extensions; } extensions.Add (rep); @@ -92,10 +95,10 @@ public void RegisterExtensionPoint (AddinDescription description, ExtensionPoint ep) { - ArrayList extensions = (ArrayList) pathHash [ep.Path]; - if (extensions != null) { + List extensions; + if (pathHash.TryGetValue (ep.Path, out extensions)) { // Extension point already registered - ArrayList compatExtensions = GetCompatibleExtensionPoints (ep.Path, description, description.MainModule, extensions); + List compatExtensions = GetCompatibleExtensionPoints (ep.Path, description, description.MainModule, extensions); if (compatExtensions.Count > 0) { foreach (ExtensionPoint einfo in compatExtensions) einfo.MergeWith (null, ep); @@ -109,7 +112,7 @@ rep.ExtensionPoint.RootAddin = description.AddinId; rep.Description = description; if (extensions == null) { - extensions = new ArrayList (); + extensions = new List (); pathHash [ep.Path] = extensions; } extensions.Add (rep); @@ -122,13 +125,21 @@ foreach (ExtensionNodeType nt in ep.NodeSet.NodeTypes) { if (nt.ObjectTypeName.Length > 0) { - ArrayList list = (ArrayList) objectTypeExtensions [nt.ObjectTypeName]; - if (list == null) { - list = new ArrayList (); + List list; + if (!objectTypeExtensions.TryGetValue (nt.ObjectTypeName, out list)) { + list = new List (); objectTypeExtensions [nt.ObjectTypeName] = list; } list.Add (ep); } + if (nt.ExtensionAttributeTypeName.Length > 0) { + List list; + if (!customAttributeTypeExtensions.TryGetValue (nt.ExtensionAttributeTypeName, out list)) { + list = new List (); + customAttributeTypeExtensions [nt.ExtensionAttributeTypeName] = list; + } + list.Add (nt); + } } } @@ -138,8 +149,8 @@ string[] objectTypes = extension.Path.Substring (1).Split (','); bool found = false; foreach (string s in objectTypes) { - ArrayList list = (ArrayList) objectTypeExtensions [s]; - if (list != null) { + List list; + if (objectTypeExtensions.TryGetValue (s, out list)) { found = true; foreach (ExtensionPoint ep in list) { if (IsAddinCompatible (ep.ParentAddinDescription, description, module)) { @@ -152,12 +163,33 @@ if (!found) monitor.ReportWarning ("The add-in '" + description.AddinId + "' is trying to register the class '" + extension.Path.Substring (1) + "', but there isn't any add-in defining a suitable extension point"); } + else if (extension.Path.StartsWith ("%")) { + string[] objectTypes = extension.Path.Substring (1).Split (','); + bool found = false; + foreach (string s in objectTypes) { + List list; + if (customAttributeTypeExtensions.TryGetValue (s, out list)) { + found = true; + foreach (ExtensionNodeType nt in list) { + ExtensionPoint ep = (ExtensionPoint) ((ExtensionNodeSet)nt.Parent).Parent; + if (IsAddinCompatible (ep.ParentAddinDescription, description, module)) { + extension.Path = ep.Path; + foreach (ExtensionNodeDescription node in extension.ExtensionNodes) + node.NodeName = nt.NodeName; + RegisterExtension (description, module, ep.Path); + } + } + } + } + if (!found) + monitor.ReportWarning ("The add-in '" + description.AddinId + "' is trying to register the class '" + extension.Path.Substring (1) + "', but there isn't any add-in defining a suitable extension point"); + } } public void RegisterExtension (AddinDescription description, ModuleDescription module, string path) { - ArrayList extensions = (ArrayList) pathHash [path]; - if (extensions == null) { + List extensions; + if (!pathHash.TryGetValue (path, out extensions)) { // Root add-in extension points are registered before any other kind of extension, // so we should find it now. extensions = GetParentExtensionInfo (path); @@ -173,15 +205,18 @@ if (!einfo.ExtensionPoint.Addins.Contains (description.AddinId)) einfo.ExtensionPoint.Addins.Add (description.AddinId); found = true; + if (monitor.LogLevel > 2) { + monitor.Log (" * " + einfo.Description.AddinId + "(" + einfo.Description.Domain + ") <- " + path); + } } } if (!found) monitor.ReportWarning ("The add-in '" + description.AddinId + "' is trying to extend '" + path + "', but there isn't any compatible add-in defining this extension point"); } - ArrayList GetCompatibleExtensionPoints (string path, AddinDescription description, ModuleDescription module, ArrayList rootExtensionPoints) + List GetCompatibleExtensionPoints (string path, AddinDescription description, ModuleDescription module, List rootExtensionPoints) { - ArrayList list = new ArrayList (); + List list = new List (); foreach (RootExtensionPoint rep in rootExtensionPoints) { // Find an extension point defined in a root add-in which is compatible with the version of the extender dependency @@ -191,14 +226,14 @@ return list; } - ArrayList GetParentExtensionInfo (string path) + List GetParentExtensionInfo (string path) { int i = path.LastIndexOf ('/'); if (i == -1) return null; string np = path.Substring (0, i); - ArrayList ep = (ArrayList) pathHash [np]; - if (ep != null) + List ep; + if (pathHash.TryGetValue (np, out ep)) return ep; else return GetParentExtensionInfo (np); @@ -217,8 +252,17 @@ string addinId = Addin.GetFullId (installedDescription.Namespace, installedDescription.LocalId, null); string requiredVersion = null; - for (int n = module.Dependencies.Count - 1; n >= 0; n--) { - AddinDependency adep = module.Dependencies [n] as AddinDependency; + IEnumerable deps; + if (module == description.MainModule) + deps = module.Dependencies; + else { + ArrayList list = new ArrayList (); + list.AddRange (module.Dependencies); + list.AddRange (description.MainModule.Dependencies); + deps = list; + } + foreach (object dep in deps) { + AddinDependency adep = dep as AddinDependency; if (adep != null && Addin.GetFullId (description.Namespace, adep.AddinId, null) == addinId) { requiredVersion = adep.Version; break; diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Database/DatabaseConfiguration.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Database/DatabaseConfiguration.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Database/DatabaseConfiguration.cs 2008-11-06 19:52:14.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Database/DatabaseConfiguration.cs 2011-04-13 09:00:29.000000000 +0000 @@ -28,84 +28,118 @@ using System; +using System.Linq; using System.IO; using System.Collections; +using System.Collections.Generic; using System.Xml; namespace Mono.Addins.Database { internal class DatabaseConfiguration { - Hashtable addinStatus = new Hashtable (); + Dictionary addinStatus = new Dictionary (); + + internal class AddinStatus + { + public AddinStatus (string addinId) + { + this.AddinId = addinId; + } + + public string AddinId; + public bool Enabled; + public bool Uninstalled; + public List Files; + } public bool IsEnabled (string addinId, bool defaultValue) { - if (addinStatus.Contains (addinId)) - return addinStatus [addinId] != null; + AddinStatus s; + if (addinStatus.TryGetValue (addinId, out s)) + return s.Enabled && !s.Uninstalled; else return defaultValue; } public void SetStatus (string addinId, bool enabled, bool defaultValue) { - if (enabled == defaultValue) + AddinStatus s; + addinStatus.TryGetValue (addinId, out s); + + if (s != null && s.Uninstalled) + return; + + if (enabled == defaultValue) { addinStatus.Remove (addinId); - else if (enabled) - addinStatus [addinId] = this; + return; + } + if (s == null) + s = addinStatus [addinId] = new AddinStatus (addinId); + s.Enabled = enabled; + } + + public void RegisterForUninstall (string addinId, IEnumerable files) + { + AddinStatus s; + if (!addinStatus.TryGetValue (addinId, out s)) + s = addinStatus [addinId] = new AddinStatus (addinId); + + s.Enabled = false; + s.Uninstalled = true; + s.Files = new List (files); + } + + public void UnregisterForUninstall (string addinId) + { + addinStatus.Remove (addinId); + } + + public bool IsRegisteredForUninstall (string addinId) + { + AddinStatus s; + if (addinStatus.TryGetValue (addinId, out s)) + return s.Uninstalled; else - addinStatus [addinId] = null; + return false; + } + + public bool HasPendingUninstalls { + get { return addinStatus.Values.Where (s => s.Uninstalled).Any (); } + } + + public AddinStatus[] GetPendingUninstalls () + { + return addinStatus.Values.Where (s => s.Uninstalled).ToArray (); } public static DatabaseConfiguration Read (string file) { DatabaseConfiguration config = new DatabaseConfiguration (); + XmlDocument doc = new XmlDocument (); + doc.Load (file); - StreamReader s = new StreamReader (file); - using (s) { - XmlTextReader tr = new XmlTextReader (s); - tr.MoveToContent (); - if (tr.IsEmptyElement) - return config; - - tr.ReadStartElement ("Configuration"); - tr.MoveToContent (); - - while (tr.NodeType != XmlNodeType.EndElement) { - - if (tr.NodeType != XmlNodeType.Element || tr.IsEmptyElement) { - tr.Skip (); - } - else if (tr.LocalName == "DisabledAddins") { - // For back compatibility - tr.ReadStartElement (); - tr.MoveToContent (); - while (tr.NodeType != XmlNodeType.EndElement) { - if (tr.NodeType == XmlNodeType.Element && tr.LocalName == "Addin") - config.addinStatus [tr.ReadElementString ()] = null; - else - tr.Skip (); - tr.MoveToContent (); - } - tr.ReadEndElement (); - } - else if (tr.LocalName == "AddinStatus") { - tr.ReadStartElement (); - tr.MoveToContent (); - while (tr.NodeType != XmlNodeType.EndElement) { - if (tr.NodeType == XmlNodeType.Element && tr.LocalName == "Addin") { - string aid = tr.GetAttribute ("id"); - string senabled = tr.GetAttribute ("enabled"); - if (senabled.Length == 0 || senabled == "True") - config.addinStatus [aid] = config; - else - config.addinStatus [aid] = null; - } - tr.Skip (); - tr.MoveToContent (); - } - tr.ReadEndElement (); + XmlElement disabledElem = (XmlElement) doc.DocumentElement.SelectSingleNode ("DisabledAddins"); + if (disabledElem != null) { + // For back compatibility + foreach (XmlElement elem in disabledElem.SelectNodes ("Addin")) + config.SetStatus (elem.InnerText, false, true); + return config; + } + + XmlElement statusElem = (XmlElement) doc.DocumentElement.SelectSingleNode ("AddinStatus"); + if (statusElem != null) { + foreach (XmlElement elem in statusElem.SelectNodes ("Addin")) { + AddinStatus status = new AddinStatus (elem.GetAttribute ("id")); + string senabled = elem.GetAttribute ("enabled"); + status.Enabled = senabled.Length == 0 || senabled == "True"; + status.Uninstalled = elem.GetAttribute ("uninstalled") == "True"; + config.addinStatus [status.AddinId] = status; + foreach (XmlElement fileElem in elem.SelectNodes ("File")) { + if (status.Files == null) + status.Files = new List (); + status.Files.Add (fileElem.InnerText); } - tr.MoveToContent (); } } return config; @@ -118,15 +152,22 @@ XmlTextWriter tw = new XmlTextWriter (s); tw.Formatting = Formatting.Indented; tw.WriteStartElement ("Configuration"); + tw.WriteStartElement ("AddinStatus"); - foreach (DictionaryEntry e in addinStatus) { + foreach (AddinStatus e in addinStatus.Values) { tw.WriteStartElement ("Addin"); - tw.WriteAttributeString ("id", (string)e.Key); - tw.WriteAttributeString ("enabled", (e.Value != null).ToString ()); + tw.WriteAttributeString ("id", e.AddinId); + tw.WriteAttributeString ("enabled", e.Enabled.ToString ()); + if (e.Uninstalled) + tw.WriteAttributeString ("uninstalled", "True"); + if (e.Files != null && e.Files.Count > 0) { + foreach (var f in e.Files) + tw.WriteElementString ("File", f); + } tw.WriteEndElement (); } - tw.WriteEndElement (); - tw.WriteEndElement (); + tw.WriteEndElement (); // AddinStatus + tw.WriteEndElement (); // Configuration } } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Database/DefaultAssemblyReflector.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Database/DefaultAssemblyReflector.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Database/DefaultAssemblyReflector.cs 2008-11-06 19:52:14.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Database/DefaultAssemblyReflector.cs 2011-04-13 09:00:29.000000000 +0000 @@ -28,12 +28,11 @@ using System; using System.Reflection; using System.Collections; +using System.Collections.Generic; namespace Mono.Addins.Database { - - - public class DefaultAssemblyReflector: IAssemblyReflector + class DefaultAssemblyReflector: IAssemblyReflector { public void Initialize (IAssemblyLocator locator) { @@ -43,6 +42,16 @@ { return Util.LoadAssemblyForReflection (file); } + + public string[] GetResourceNames (object asm) + { + return ((Assembly)asm).GetManifestResourceNames (); + } + + public System.IO.Stream GetResourceStream (object asm, string resourceName) + { + return ((Assembly)asm).GetManifestResourceStream (resourceName); + } public object[] GetCustomAttributes (object obj, Type type, bool inherit) { @@ -60,7 +69,49 @@ return att; return null; } - + + public List GetRawCustomAttributes (object obj, Type type, bool inherit) + { + ICustomAttributeProvider aprov = obj as ICustomAttributeProvider; + List atts = new List (); + if (aprov == null) + return atts; + + foreach (object at in aprov.GetCustomAttributes (type, inherit)) + atts.Add (ConvertAttribute (at)); + + return atts; + } + + CustomAttribute ConvertAttribute (object ob) + { + CustomAttribute at = new CustomAttribute (); + Type type = ob.GetType (); + at.TypeName = type.FullName; + + foreach (PropertyInfo prop in type.GetProperties (BindingFlags.Public | BindingFlags.Instance)) { + object val = prop.GetValue (ob, null); + if (val != null) { + NodeAttributeAttribute bt = (NodeAttributeAttribute) Attribute.GetCustomAttribute (prop, typeof(NodeAttributeAttribute), true); + if (bt != null) { + string name = string.IsNullOrEmpty (bt.Name) ? prop.Name : bt.Name; + at [name] = Convert.ToString (val, System.Globalization.CultureInfo.InvariantCulture); + } + } + } + foreach (FieldInfo field in type.GetFields (BindingFlags.Public | BindingFlags.Instance)) { + object val = field.GetValue (ob); + if (val != null) { + NodeAttributeAttribute bt = (NodeAttributeAttribute) Attribute.GetCustomAttribute (field, typeof(NodeAttributeAttribute), true); + if (bt != null) { + string name = string.IsNullOrEmpty (bt.Name) ? field.Name : bt.Name; + at [name] = Convert.ToString (val, System.Globalization.CultureInfo.InvariantCulture); + } + } + } + return at; + } + public string GetTypeName (object type) { return ((Type)type).Name; diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Database/FileDatabase.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Database/FileDatabase.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Database/FileDatabase.cs 2008-11-06 19:52:14.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Database/FileDatabase.cs 2011-04-13 09:00:29.000000000 +0000 @@ -145,6 +145,7 @@ { if (inTransaction) { deletedFiles.Remove (fileName); + deletedDirs.Remove (Path.GetDirectoryName (fileName)); foldersToUpdate [Path.GetDirectoryName (fileName)] = null; return File.Create (fileName + ".new"); } @@ -152,6 +153,20 @@ return File.Create (fileName); } + public void Rename (string fileName, string newName) + { + if (inTransaction) { + deletedFiles.Remove (newName); + deletedDirs.Remove (Path.GetDirectoryName (newName)); + foldersToUpdate [Path.GetDirectoryName (newName)] = null; + string s = File.Exists (fileName + ".new") ? fileName + ".new" : fileName; + File.Copy (s, newName + ".new"); + Delete (fileName); + } + else + File.Move (fileName, newName); + } + public Stream OpenRead (string fileName) { if (inTransaction) { diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Database/IAssemblyReflector.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Database/IAssemblyReflector.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Database/IAssemblyReflector.cs 2008-11-06 19:52:14.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Database/IAssemblyReflector.cs 2011-04-13 09:00:29.000000000 +0000 @@ -27,35 +27,286 @@ using System; using System.Collections; +using System.Collections.Generic; +using System.IO; namespace Mono.Addins.Database { + /// + /// An assembly reflector + /// + /// + /// This interface can be implemented to provide a custom method for getting information about assemblies. + /// public interface IAssemblyReflector { + /// + /// Called to initialize the assembly reflector + /// + /// + /// IAssemblyLocator instance which can be used to locate referenced assemblies. + /// void Initialize (IAssemblyLocator locator); + /// + /// Gets a list of custom attributes + /// + /// + /// The custom attributes. + /// + /// + /// An assembly, class or class member + /// + /// + /// Type of the attribute to be returned. It will always be one of the attribute types + /// defined in Mono.Addins. + /// + /// + /// 'true' if inherited attributes must be returned + /// object[] GetCustomAttributes (object obj, Type type, bool inherit); + /// + /// Gets a list of custom attributes + /// + /// + /// The attributes. + /// + /// + /// An assembly, class or class member + /// + /// + /// Base type of the attribute to be returned + /// + /// + /// 'true' if inherited attributes must be returned + /// + List GetRawCustomAttributes (object obj, Type type, bool inherit); + + /// + /// Loads an assembly. + /// + /// + /// The loaded assembly + /// + /// + /// Path of the assembly. + /// object LoadAssembly (string file); + + /// + /// Loads the assembly specified in an assembly reference + /// + /// + /// The assembly + /// + /// + /// An assembly reference + /// object LoadAssemblyFromReference (object asmReference); + + /// + /// Gets the names of all resources embedded in an assembly + /// + /// + /// The names of the resources + /// + /// + /// An assembly + /// + string[] GetResourceNames (object asm); + + /// + /// Gets the data stream of a resource + /// + /// + /// The stream. + /// + /// + /// An assembly + /// + /// + /// The name of a resource + /// + Stream GetResourceStream (object asm, string resourceName); + + /// + /// Gets all types defined in an assembly + /// + /// + /// The types + /// + /// + /// An assembly + /// IEnumerable GetAssemblyTypes (object asm); + + /// + /// Gets all assembly references of an assembly + /// + /// + /// A list of assembly references + /// + /// + /// An assembly + /// IEnumerable GetAssemblyReferences (object asm); + /// + /// Looks for a type in an assembly + /// + /// + /// The type. + /// + /// + /// An assembly + /// + /// + /// Name of the type + /// object GetType (object asm, string typeName); + + + /// + /// Gets a custom attribute + /// + /// + /// The custom attribute. + /// + /// + /// An assembly, class or class member + /// + /// + /// Base type of the attribute to be returned. It will always be one of the attribute types + /// defined in Mono.Addins. + /// + /// + /// 'true' if inherited attributes must be returned + /// object GetCustomAttribute (object obj, Type type, bool inherit); + + /// + /// Gets the name of a type (not including namespace) + /// + /// + /// The type name. + /// + /// + /// A type + /// string GetTypeName (object type); + + /// + /// Gets the full name of a type (including namespace) + /// + /// + /// The full name of the type + /// + /// + /// A type + /// string GetTypeFullName (object type); + + /// + /// Gets the assembly qualified name of a type + /// + /// + /// The assembly qualified type name + /// + /// + /// A type + /// string GetTypeAssemblyQualifiedName (object type); + + /// + /// Gets a list of all base types (including interfaces) of a type + /// + /// + /// An enumeration of the full name of all base types of the type + /// + /// + /// A type + /// IEnumerable GetBaseTypeFullNameList (object type); + + /// + /// Checks if a type is assignable to another type + /// + /// + /// 'true' if the type is assignable + /// + /// + /// Expected base type. + /// + /// + /// A type. + /// bool TypeIsAssignableFrom (object baseType, object type); + /// + /// Gets the fields of a type + /// + /// + /// The fields. + /// + /// + /// A type + /// IEnumerable GetFields (object type); + + /// + /// Gets the name of a field. + /// + /// + /// The field name. + /// + /// + /// A field. + /// string GetFieldName (object field); + + /// + /// Gets the full name of the type of a field + /// + /// + /// The full type name + /// + /// + /// A field. + /// string GetFieldTypeFullName (object field); } + /// + /// Allows finding assemblies in the file system + /// public interface IAssemblyLocator { + /// + /// Locates an assembly + /// + /// + /// The full path to the assembly, or null if not found + /// + /// + /// Full name of the assembly + /// string GetAssemblyLocation (string fullName); } + + /// + /// A custom attribute + /// + public class CustomAttribute: Dictionary + { + string typeName; + + /// + /// Full name of the type of the custom attribute + /// + public string TypeName { + get { return typeName; } + set { typeName = value; } + } + } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Database/ISetupHandler.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Database/ISetupHandler.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Database/ISetupHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Database/ISetupHandler.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,36 @@ +// +// ISetupHandler.cs +// +// Author: +// Lluis Sanchez Gual +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; + +namespace Mono.Addins.Database +{ + internal interface ISetupHandler + { + void Scan (IProgressStatus monitor, AddinRegistry registry, string scanFolder, string[] filesToIgnore); + void GetAddinDescription (IProgressStatus monitor, AddinRegistry registry, string file, string outFile); + } +} diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Database/SetupDomain.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Database/SetupDomain.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Database/SetupDomain.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Database/SetupDomain.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,178 @@ +// +// SetupDomain.cs +// +// Author: +// Lluis Sanchez Gual +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Collections.Specialized; + +namespace Mono.Addins.Database +{ + class SetupDomain: ISetupHandler + { + AppDomain domain; + RemoteSetupDomain remoteSetupDomain; + int useCount; + + public void Scan (IProgressStatus monitor, AddinRegistry registry, string scanFolder, string[] filesToIgnore) + { + RemoteProgressStatus remMonitor = new RemoteProgressStatus (monitor); + try { + RemoteSetupDomain rsd = GetDomain (); + rsd.Scan (remMonitor, registry.RegistryPath, registry.StartupDirectory, registry.DefaultAddinsFolder, registry.AddinCachePath, scanFolder, filesToIgnore); + } catch (Exception ex) { + throw new ProcessFailedException (remMonitor.ProgessLog, ex); + } finally { + System.Runtime.Remoting.RemotingServices.Disconnect (remMonitor); + ReleaseDomain (); + } + } + + public void GetAddinDescription (IProgressStatus monitor, AddinRegistry registry, string file, string outFile) + { + RemoteProgressStatus remMonitor = new RemoteProgressStatus (monitor); + try { + RemoteSetupDomain rsd = GetDomain (); + rsd.GetAddinDescription (remMonitor, registry.RegistryPath, registry.StartupDirectory, registry.DefaultAddinsFolder, registry.AddinCachePath, file, outFile); + } catch (Exception ex) { + throw new ProcessFailedException (remMonitor.ProgessLog, ex); + } finally { + System.Runtime.Remoting.RemotingServices.Disconnect (remMonitor); + ReleaseDomain (); + } + } + + RemoteSetupDomain GetDomain () + { + lock (this) { + if (useCount++ == 0) { + domain = AppDomain.CreateDomain ("SetupDomain", null, AppDomain.CurrentDomain.SetupInformation); + remoteSetupDomain = (RemoteSetupDomain) domain.CreateInstanceFromAndUnwrap (typeof(RemoteSetupDomain).Assembly.Location, typeof(RemoteSetupDomain).FullName); + } + return remoteSetupDomain; + } + } + + void ReleaseDomain () + { + lock (this) { + if (--useCount == 0) { + AppDomain.Unload (domain); + domain = null; + remoteSetupDomain = null; + } + } + } + } + + class RemoteSetupDomain: MarshalByRefObject + { + public override object InitializeLifetimeService () + { + return null; + } + + public void Scan (IProgressStatus monitor, string registryPath, string startupDir, string addinsDir, string databaseDir, string scanFolder, string[] filesToIgnore) + { + AddinDatabase.RunningSetupProcess = true; + AddinRegistry reg = new AddinRegistry (registryPath, startupDir, addinsDir, databaseDir); + StringCollection files = new StringCollection (); + for (int n=0; n +// +// Copyright (c) 2011 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using System.Collections.Specialized; + +namespace Mono.Addins.Database +{ + class SetupLocal: ISetupHandler + { + public void Scan (IProgressStatus monitor, AddinRegistry registry, string scanFolder, string[] filesToIgnore) + { + AddinRegistry reg = new AddinRegistry (registry.RegistryPath, registry.StartupDirectory, registry.DefaultAddinsFolder, registry.AddinCachePath); + reg.CopyExtensionsFrom (registry); + StringCollection files = new StringCollection (); + for (int n=0; n 2 && path [0] == '[') { + int i = path.IndexOf (']', 1); + if (i != -1) { + try { + string fname = path.Substring (1, i - 1); + Environment.SpecialFolder sf = (Environment.SpecialFolder) Enum.Parse (typeof(Environment.SpecialFolder), fname, true); + path = Environment.GetFolderPath (sf) + path.Substring (i + 1); + } catch { + // Ignore + } + } + } if (IsWindows) return path.Replace ('/','\\'); else return path.Replace ('\\','/'); } - // Works like Path.GetFullPath, but it does not require the path to exist - public static string GetFullPath (string path) - { - if (path == null) - throw new ArgumentNullException ("path"); - - path = NormalizePath (path); - - if (!Path.IsPathRooted (path)) - path = Path.Combine (Environment.CurrentDirectory, path); - - string root = Path.GetPathRoot (path); - path = path.Substring (root.Length); - - string[] parts = path.Split (Path.DirectorySeparatorChar); - string[] newParts = new string [parts.Length]; - int i = 0; - for (int n=0; n 0) - i--; - } else { - newParts [i++] = p; - } - } - return root + string.Join (new string (Path.DirectorySeparatorChar, 1), newParts, 0, i); - } - // A private hash calculation method is used to be able to get consistent // results across different .NET versions and implementations. public static int GetStringHashCode (string s) diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Description/AddinDependency.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/AddinDependency.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Description/AddinDependency.cs 2008-11-06 19:52:13.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/AddinDependency.cs 2011-04-13 09:00:29.000000000 +0000 @@ -35,22 +35,43 @@ namespace Mono.Addins.Description { + /// + /// Definition of a dependency of an add-in on another add-in. + /// [XmlType ("AddinReference")] public class AddinDependency: Dependency { string id; string version; + /// + /// Initializes a new instance of the class. + /// public AddinDependency () { } + /// + /// Initializes a new instance of the class. + /// + /// + /// Full identifier of the add-in (includes version) + /// public AddinDependency (string fullId) { Addin.GetIdParts (fullId, out id, out version); id = "::" + id; } + /// + /// Initializes a new instance of the class. + /// + /// + /// Identifier of the add-in. + /// + /// + /// Version of the add-in. + /// public AddinDependency (string id, string version) { this.id = id; @@ -76,6 +97,15 @@ Element.SetAttribute ("version", Version); } + /// + /// Gets the full addin identifier. + /// + /// + /// The full addin identifier. + /// + /// + /// Includes namespace and version number. For example: MonoDevelop.TextEditor,1.0 + /// public string FullAddinId { get { AddinDescription desc = ParentAddinDescription; @@ -86,23 +116,41 @@ } } + /// + /// Gets or sets the addin identifier. + /// + /// + /// The addin identifier. + /// public string AddinId { get { return id != null ? id : string.Empty; } set { id = value; } } + /// + /// Gets or sets the version. + /// + /// + /// The version. + /// public string Version { get { return version != null ? version : string.Empty; } set { version = value; } } + /// + /// Display name of the dependency. + /// + /// + /// The name. + /// public override string Name { get { return AddinId + " v" + version; } } - internal override bool CheckInstalled () + internal override bool CheckInstalled (AddinRegistry registry) { - Addin[] addins = AddinManager.Registry.GetAddins (); + Addin[] addins = registry.GetAddins (); foreach (Addin addin in addins) { if (addin.Id == id && addin.SupportsVersion (version)) { return true; diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Description/AddinDescription.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/AddinDescription.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Description/AddinDescription.cs 2008-11-06 19:52:13.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/AddinDescription.cs 2011-04-13 09:00:29.000000000 +0000 @@ -28,6 +28,7 @@ using System; using System.Collections; +using System.Collections.Generic; using System.IO; using System.Xml; using System.Xml.Serialization; @@ -37,8 +38,13 @@ namespace Mono.Addins.Description { - // This class represent an add-in configuration file. It has properties for getting - // all information, and methods for loading and saving files. + /// + /// An add-in description + /// + /// + /// This class represent an add-in manifest. It has properties for getting + /// all information, and methods for loading and saving files. + /// public class AddinDescription: IBinaryXmlElement { XmlDocument configDoc; @@ -63,7 +69,7 @@ bool defaultEnabled = true; AddinFlags flags = AddinFlags.None; string domain; - + ModuleDescription mainModule; ModuleCollection optionalModules; ExtensionNodeSetCollection nodeSets; @@ -72,6 +78,8 @@ ExtensionNodeDescription localizer; object[] fileInfo; + AddinPropertyCollectionImpl properties; + internal static BinaryXmlTypeMap typeMap; static AddinDescription () @@ -90,6 +98,7 @@ typeMap.RegisterType (typeof(AssemblyDependency), "AssemblyDependency"); typeMap.RegisterType (typeof(NodeTypeAttribute), "NodeTypeAttribute"); typeMap.RegisterType (typeof(AddinFileInfo), "FileInfo"); + typeMap.RegisterType (typeof(AddinProperty), "Property"); } internal AddinDatabase OwnerDatabase { @@ -97,27 +106,63 @@ set { ownerDatabase = value; } } + /// + /// Gets or sets the path to the main addin file. + /// + /// + /// The addin file. + /// + /// + /// The add-in file can be either the main assembly of an add-in or an xml manifest. + /// public string AddinFile { get { return sourceAddinFile; } set { sourceAddinFile = value; } } + /// + /// Gets the addin identifier. + /// + /// + /// The addin identifier. + /// public string AddinId { get { return Addin.GetFullId (Namespace, LocalId, Version); } } + /// + /// Gets or sets the local identifier. + /// + /// + /// The local identifier. + /// public string LocalId { get { return id != null ? id : string.Empty; } set { id = value; hasUserId = true; } } + /// + /// Gets or sets the namespace. + /// + /// + /// The namespace. + /// public string Namespace { get { return ns != null ? ns : string.Empty; } set { ns = value; } } + /// + /// Gets or sets the display name of the add-in. + /// + /// + /// The name. + /// public string Name { get { + string val = Properties.GetPropertyValue ("Name"); + if (val.Length > 0) + return val; if (name != null && name.Length > 0) return name; if (HasUserId) @@ -129,57 +174,152 @@ } set { name = value; } } - + + /// + /// Gets or sets the version. + /// + /// + /// The version. + /// public string Version { get { return version != null ? version : string.Empty; } set { version = value; } } + /// + /// Gets or sets the version of the add-in with which this add-in is backwards compatible. + /// + /// + /// The compat version. + /// public string CompatVersion { get { return compatVersion != null ? compatVersion : string.Empty; } set { compatVersion = value; } } + /// + /// Gets or sets the author. + /// + /// + /// The author. + /// public string Author { - get { return author != null ? author : string.Empty; } + get { + string val = Properties.GetPropertyValue ("Author"); + if (val.Length > 0) + return val; + return author ?? string.Empty; + } set { author = value; } } + /// + /// Gets or sets the Url where more information about the add-in can be found. + /// + /// + /// The URL. + /// public string Url { - get { return url != null ? url : string.Empty; } + get { + string val = Properties.GetPropertyValue ("Url"); + if (val.Length > 0) + return val; + return url ?? string.Empty; + } set { url = value; } } + /// + /// Gets or sets the copyright. + /// + /// + /// The copyright. + /// public string Copyright { - get { return copyright != null ? copyright : string.Empty; } + get { + string val = Properties.GetPropertyValue ("Copyright"); + if (val.Length > 0) + return val; + return copyright ?? string.Empty; + } set { copyright = value; } } + /// + /// Gets or sets the description of the add-in. + /// + /// + /// The description. + /// public string Description { - get { return description != null ? description : string.Empty; } + get { + string val = Properties.GetPropertyValue ("Description"); + if (val.Length > 0) + return val; + return description ?? string.Empty; + } set { description = value; } } + /// + /// Gets or sets the category of the add-in. + /// + /// + /// The category. + /// public string Category { - get { return category != null ? category : string.Empty; } + get { + string val = Properties.GetPropertyValue ("Category"); + if (val.Length > 0) + return val; + return category ?? string.Empty; + } set { category = value; } } - internal string BasePath { + /// + /// Gets the base path for locating external files relative to the add-in. + /// + /// + /// The base path. + /// + public string BasePath { get { return basePath != null ? basePath : string.Empty; } - set { basePath = value; } } + internal void SetBasePath (string path) + { + basePath = path; + } + + /// + /// Gets or sets a value indicating whether this instance is an add-in root. + /// + /// + /// true if this instance is an add-in root; otherwise, false. + /// public bool IsRoot { get { return isroot; } set { isroot = value; } } + /// + /// Gets or sets a value indicating whether this add-in is enabled by default. + /// + /// + /// true if enabled by default; otherwise, false. + /// public bool EnabledByDefault { get { return defaultEnabled; } set { defaultEnabled = value; } } + /// + /// Gets or sets the add-in flags. + /// + /// + /// The flags. + /// public AddinFlags Flags { get { return flags; } set { flags = value; } @@ -190,14 +330,32 @@ set { hasUserId = value; } } + /// + /// Gets a value indicating whether this add-in can be disabled. + /// + /// + /// true if this add-in can be disabled; otherwise, false. + /// public bool CanDisable { get { return (flags & AddinFlags.CantDisable) == 0 && !IsHidden; } } + /// + /// Gets a value indicating whether this add-in can be uninstalled. + /// + /// + /// true if this instance can be uninstalled; otherwise, false. + /// public bool CanUninstall { get { return (flags & AddinFlags.CantUninstall) == 0 && !IsHidden; } } + /// + /// Gets a value indicating whether this add-in is hidden. + /// + /// + /// true if this add-in is hidden; otherwise, false. + /// public bool IsHidden { get { return (flags & AddinFlags.Hidden) != 0; } } @@ -208,6 +366,15 @@ (CompatVersion.Length == 0 || Addin.CompareVersions (ver, CompatVersion) <= 0); } + /// + /// Gets all external files + /// + /// + /// All files. + /// + /// + /// External files are data files and assemblies explicitly referenced in the Runtime section of the add-in manifest. + /// public StringCollection AllFiles { get { StringCollection col = new StringCollection (); @@ -222,6 +389,12 @@ } } + /// + /// Gets all paths to be ignored by the add-in scanner. + /// + /// + /// All paths to be ignored. + /// public StringCollection AllIgnorePaths { get { StringCollection col = new StringCollection (); @@ -236,6 +409,12 @@ } } + /// + /// Gets the main module. + /// + /// + /// The main module. + /// public ModuleDescription MainModule { get { if (mainModule == null) { @@ -249,6 +428,17 @@ } } + /// + /// Gets the optional modules. + /// + /// + /// The optional modules. + /// + /// + /// Optional modules can be used to declare extensions which will be registered only if some specified + /// add-in dependencies can be satisfied. Dependencies specified in optional modules are 'soft dependencies', + /// which means that they don't need to be satisfied in order to load the add-in. + /// public ModuleCollection OptionalModules { get { if (optionalModules == null) { @@ -262,6 +452,12 @@ } } + /// + /// Gets all modules (including the main module and all optional modules) + /// + /// + /// All modules. + /// public ModuleCollection AllModules { get { ModuleCollection col = new ModuleCollection (this); @@ -272,6 +468,12 @@ } } + /// + /// Gets the extension node sets. + /// + /// + /// The extension node sets. + /// public ExtensionNodeSetCollection ExtensionNodeSets { get { if (nodeSets == null) { @@ -285,6 +487,12 @@ } } + /// + /// Gets the extension points. + /// + /// + /// The extension points. + /// public ExtensionPointCollection ExtensionPoints { get { if (extensionPoints == null) { @@ -298,6 +506,12 @@ } } + /// + /// Gets the condition types. + /// + /// + /// The condition types. + /// public ConditionTypeDescriptionCollection ConditionTypes { get { if (conditionTypes == null) { @@ -311,11 +525,37 @@ } } + /// + /// Gets or sets the add-in localizer. + /// + /// + /// The description of the add-in localizer for this add-in. + /// public ExtensionNodeDescription Localizer { get { return localizer; } set { localizer = value; } } + /// + /// Custom properties specified in the add-in header + /// + public AddinPropertyCollection Properties { + get { + if (properties == null) + properties = new AddinPropertyCollectionImpl (); + return properties; + } + } + + /// + /// Adds an extension point. + /// + /// + /// The extension point. + /// + /// + /// Path that identifies the new extension point. + /// public ExtensionPoint AddExtensionPoint (string path) { ExtensionPoint ep = new ExtensionPoint (); @@ -372,6 +612,12 @@ } } + /// + /// Gets or sets file where this description is stored + /// + /// + /// The file path. + /// public string FileName { get { return configFile; } set { configFile = value; } @@ -412,12 +658,64 @@ return false; } + void TransferCoreProperties (bool removeProperties) + { + if (properties == null) + return; + + string val = properties.ExtractCoreProperty ("Id", removeProperties); + if (val != null) + id = val; + + val = properties.ExtractCoreProperty ("Namespace", removeProperties); + if (val != null) + ns = val; + + val = properties.ExtractCoreProperty ("Version", removeProperties); + if (val != null) + version = val; + + val = properties.ExtractCoreProperty ("CompatVersion", removeProperties); + if (val != null) + compatVersion = val; + + val = properties.ExtractCoreProperty ("DefaultEnabled", removeProperties); + if (val != null) + defaultEnabled = GetBool (val, true); + + val = properties.ExtractCoreProperty ("IsRoot", removeProperties); + if (val != null) + isroot = GetBool (val, true); + + val = properties.ExtractCoreProperty ("Flags", removeProperties); + if (val != null) + flags = (AddinFlags) Enum.Parse (typeof(AddinFlags), val); + } + + /// + /// Saves the add-in description. + /// + /// + /// File name where to save this instance + /// + /// + /// Saves the add-in description to the specified file and sets the FileName property. + /// public void Save (string fileName) { configFile = fileName; Save (); } + /// + /// Saves the add-in description. + /// + /// + /// It is thrown if FileName is not set + /// + /// + /// The description is saved to the file specified in the FileName property. + /// public void Save () { if (configFile == null) @@ -432,6 +730,12 @@ } } + /// + /// Generates an XML representation of the add-in description + /// + /// + /// An XML manifest. + /// public XmlDocument SaveToXml () { SaveXml (); @@ -452,39 +756,20 @@ elem = configDoc.DocumentElement; - if (HasUserId) - elem.SetAttribute ("id", id); - else - elem.RemoveAttribute ("id"); - - elem.SetAttribute ("version", version); - elem.SetAttribute ("namespace", ns); - - if (isroot) - elem.SetAttribute ("isroot", "true"); - else - elem.RemoveAttribute ("isroot"); + SaveCoreProperty (elem, HasUserId ? id : null, "id", "Id"); + SaveCoreProperty (elem, version, "version", "Version"); + SaveCoreProperty (elem, ns, "namespace", "Namespace"); + SaveCoreProperty (elem, isroot ? "true" : null, "isroot", "IsRoot"); // Name will return the file name when HasUserId=false - if (Name.Length > 0) - elem.SetAttribute ("name", Name); + if (!string.IsNullOrEmpty (name)) + elem.SetAttribute ("name", name); else elem.RemoveAttribute ("name"); - if (compatVersion != null && compatVersion.Length > 0) - elem.SetAttribute ("compatVersion", compatVersion); - else - elem.RemoveAttribute ("compatVersion"); - - if (defaultEnabled) - elem.RemoveAttribute ("defaultEnabled"); - else - elem.SetAttribute ("defaultEnabled", "false"); - - if (flags != AddinFlags.None) - elem.RemoveAttribute ("flags"); - else - elem.SetAttribute ("flags", flags.ToString ()); + SaveCoreProperty (elem, compatVersion, "compatVersion", "CompatVersion"); + SaveCoreProperty (elem, defaultEnabled ? null : "false", "defaultEnabled", "DefaultEnabled"); + SaveCoreProperty (elem, flags != AddinFlags.None ? flags.ToString () : null, "flags", "Flags"); if (author != null && author.Length > 0) elem.SetAttribute ("author", author); @@ -533,9 +818,53 @@ if (extensionPoints != null) extensionPoints.SaveXml (elem); + + XmlElement oldHeader = (XmlElement) elem.SelectSingleNode ("Header"); + if (properties == null || properties.Count == 0) { + if (oldHeader != null) + elem.RemoveChild (oldHeader); + } else { + if (oldHeader == null) { + oldHeader = elem.OwnerDocument.CreateElement ("Header"); + if (elem.FirstChild != null) + elem.InsertBefore (oldHeader, elem.FirstChild); + else + elem.AppendChild (oldHeader); + } + else + oldHeader.RemoveAll (); + foreach (var prop in properties) { + XmlElement propElem = elem.OwnerDocument.CreateElement (prop.Name); + if (!string.IsNullOrEmpty (prop.Locale)) + propElem.SetAttribute ("locale", prop.Locale); + propElem.InnerText = prop.Value ?? string.Empty; + oldHeader.AppendChild (propElem); + } + } + } + + void SaveCoreProperty (XmlElement elem, string val, string attr, string prop) + { + if (properties != null && properties.HasProperty (prop)) { + elem.RemoveAttribute (attr); + if (!string.IsNullOrEmpty (val)) + properties.SetPropertyValue (prop, val); + else + properties.RemoveProperty (prop); + } + else if (string.IsNullOrEmpty (val)) + elem.RemoveAttribute (attr); + else + elem.SetAttribute (attr, val); } + /// + /// Load an add-in description from a file + /// + /// + /// The file. + /// public static AddinDescription Read (string configFile) { AddinDescription config; @@ -546,11 +875,29 @@ return config; } + /// + /// Load an add-in description from a stream + /// + /// + /// The stream + /// + /// + /// The path to be used to resolve relative file paths. + /// public static AddinDescription Read (Stream stream, string basePath) { return Read (new StreamReader (stream), basePath); } + /// + /// Load an add-in description from a text reader + /// + /// + /// The text reader + /// + /// + /// The path to be used to resolve relative file paths. + /// public static AddinDescription Read (TextReader reader, string basePath) { AddinDescription config = new AddinDescription (); @@ -563,6 +910,9 @@ } XmlElement elem = config.configDoc.DocumentElement; + if (elem.LocalName == "ExtensionModel") + return config; + config.id = elem.GetAttribute ("id"); config.ns = elem.GetAttribute ("namespace"); config.name = elem.GetAttribute ("name"); @@ -592,6 +942,18 @@ if (localizerElem != null) config.localizer = new ExtensionNodeDescription (localizerElem); + XmlElement headerElem = (XmlElement) elem.SelectSingleNode ("Header"); + if (headerElem != null) { + foreach (XmlNode node in headerElem.ChildNodes) { + XmlElement prop = node as XmlElement; + if (prop == null) + continue; + config.Properties.SetPropertyValue (prop.LocalName, prop.InnerText, prop.GetAttribute ("locale")); + } + } + + config.TransferCoreProperties (false); + if (config.id.Length > 0) config.hasUserId = true; @@ -630,8 +992,20 @@ // BinaryXmlReader.DumpFile (configFile); } + /// + /// Verify this instance. + /// + /// + /// This method checks all the definitions in the description and returns a list of errors. + /// If the returned list is empty, it means that the description is valid. + /// public StringCollection Verify () { + return Verify (new AddinFileSystemExtension ()); + } + + internal StringCollection Verify (AddinFileSystemExtension fs) + { StringCollection errors = new StringCollection (); if (IsRoot) { @@ -666,7 +1040,7 @@ if (bp != null) { foreach (string file in AllFiles) { string asmFile = Path.Combine (bp, file); - if (!File.Exists (asmFile)) + if (!fs.FileExists (asmFile)) errors.Add ("The file '" + asmFile + "' referenced in the manifest could not be found."); } } @@ -675,6 +1049,16 @@ errors.Add ("The attribute 'type' in the Location element is required."); } + // Ensure that there are no duplicated properties + + if (properties != null) { + HashSet props = new HashSet (); + foreach (var prop in properties) { + if (!props.Add (prop.Name + " " + prop.Locale)) + errors.Add (string.Format ("Property {0} specified more than once", prop.Name + (prop.Locale != null ? " (" + prop.Locale + ")" : ""))); + } + } + return errors; } @@ -713,8 +1097,33 @@ } } + internal bool IsExtensionModel { + get { return RootElement.LocalName == "ExtensionModel"; } + } + + internal static AddinDescription Merge (AddinDescription desc1, AddinDescription desc2) + { + if (!desc2.IsExtensionModel) { + AddinDescription tmp = desc1; + desc1 = desc2; desc2 = tmp; + } + ((AddinPropertyCollectionImpl)desc1.Properties).AddRange (desc2.Properties); + desc1.ExtensionPoints.AddRange (desc2.ExtensionPoints); + desc1.ExtensionNodeSets.AddRange (desc2.ExtensionNodeSets); + desc1.ConditionTypes.AddRange (desc2.ConditionTypes); + desc1.OptionalModules.AddRange (desc2.OptionalModules); + foreach (string s in desc2.MainModule.Assemblies) + desc1.MainModule.Assemblies.Add (s); + foreach (string s in desc2.MainModule.DataFiles) + desc1.MainModule.DataFiles.Add (s); + desc1.MainModule.Dependencies.AddRange (desc2.MainModule.Dependencies); + desc1.MainModule.Extensions.AddRange (desc2.MainModule.Extensions); + return desc1; + } + void IBinaryXmlElement.Write (BinaryXmlWriter writer) { + TransferCoreProperties (true); writer.WriteValue ("id", id); writer.WriteValue ("ns", ns); writer.WriteValue ("isroot", isroot); @@ -739,6 +1148,7 @@ writer.WriteValue ("FilesInfo", fileInfo); writer.WriteValue ("Localizer", localizer); writer.WriteValue ("flags", (int)flags); + writer.WriteValue ("Properties", properties); } void IBinaryXmlElement.Read (BinaryXmlReader reader) @@ -767,6 +1177,7 @@ fileInfo = (object[]) reader.ReadValue ("FilesInfo", null); localizer = (ExtensionNodeDescription) reader.ReadValue ("Localizer"); flags = (AddinFlags) reader.ReadInt32Value ("flags"); + properties = (AddinPropertyCollectionImpl) reader.ReadValue ("Properties", new AddinPropertyCollectionImpl ()); if (mainModule != null) mainModule.SetParent (this); diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Description/AddinFlags.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/AddinFlags.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Description/AddinFlags.cs 2008-11-06 19:52:13.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/AddinFlags.cs 2011-04-13 09:00:29.000000000 +0000 @@ -29,11 +29,27 @@ namespace Mono.Addins.Description { + /// + /// Add-in flags + /// + [Flags] public enum AddinFlags { + /// + /// No flags + /// None = 0, + /// + /// The add-in can't be uninstalled + /// CantUninstall = 1, + /// + /// The add-in can't be disabled + /// CantDisable = 2, + /// + /// The add-in is not visible to end users + /// Hidden = 4 } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Description/AddinPropertyCollection.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/AddinPropertyCollection.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Description/AddinPropertyCollection.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/AddinPropertyCollection.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,242 @@ +// +// AddinPropertyCollection.cs +// +// Author: +// Lluis Sanchez Gual +// +// Copyright (c) 2011 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using System.Linq; +using System.Collections.Generic; + +namespace Mono.Addins.Description +{ + /// + /// A collection of add-in properties + /// + public interface AddinPropertyCollection: IEnumerable + { + /// + /// Gets the value of a property + /// + /// + /// The property value. + /// + /// + /// Name of the property. + /// + /// + /// If the property is localized, it will return the value for the current language if exists, or the + /// default value if it doesn't. + /// + string GetPropertyValue (string name); + + /// + /// Gets the value of a property + /// + /// + /// The property value. + /// + /// + /// Name of the property. + /// + /// + /// Locale for which the value must be returned. + /// + string GetPropertyValue (string name, string locale); + + /// + /// Sets the value of a property + /// + /// + /// Name of the property + /// + /// + /// New value. + /// + void SetPropertyValue (string name, string value); + + /// + /// Sets the value of a property for a specific locale + /// + /// + /// Name of the property. + /// + /// + /// New value. + /// + /// + /// Locale of the property to be set. + /// + void SetPropertyValue (string name, string value, string locale); + + /// + /// Removes a property. + /// + /// + /// Name of the property. + /// + /// + /// This method only removes properties which have no locale set. + /// + void RemoveProperty (string name); + + /// + /// Removes a property with a specified locale + /// + /// + /// Name of the property + /// + /// + /// Locale of the property + /// + void RemoveProperty (string name, string locale); + } + + class AddinPropertyCollectionImpl: List, AddinPropertyCollection + { + public AddinPropertyCollectionImpl () + { + } + + public AddinPropertyCollectionImpl (AddinPropertyCollection col) + { + AddRange (col); + } + + public string GetPropertyValue (string name) + { + return GetPropertyValue (name, System.Threading.Thread.CurrentThread.CurrentCulture.ToString ()); + } + + public string GetPropertyValue (string name, string locale) + { + locale = NormalizeLocale (locale); + string lang = GetLocaleLang (locale); + AddinProperty sameLangDifCountry = null; + AddinProperty sameLang = null; + AddinProperty defaultLoc = null; + + foreach (var p in this) { + if (p.Name == name) { + if (p.Locale == locale) + return p.Value; + string plang = GetLocaleLang (p.Locale); + if (plang == p.Locale && plang == lang) // No country specified + sameLang = p; + else if (plang == lang) + sameLangDifCountry = p; + else if (p.Locale == null) + defaultLoc = p; + } + } + if (sameLang != null) + return sameLang.Value; + else if (sameLangDifCountry != null) + return sameLangDifCountry.Value; + else if (defaultLoc != null) + return defaultLoc.Value; + else + return string.Empty; + } + + string NormalizeLocale (string loc) + { + if (string.IsNullOrEmpty (loc)) + return null; + return loc.Replace ('_','-'); + } + + string GetLocaleLang (string loc) + { + if (loc == null) + return null; + int i = loc.IndexOf ('-'); + if (i != -1) + return loc.Substring (0, i); + else + return loc; + } + + public void SetPropertyValue (string name, string value) + { + SetPropertyValue (name, value, null); + } + + public void SetPropertyValue (string name, string value, string locale) + { + if (string.IsNullOrEmpty (name)) + throw new ArgumentException ("name can't be null or empty"); + + if (value == null) + throw new ArgumentNullException ("value"); + + locale = NormalizeLocale (locale); + + foreach (var p in this) { + if (p.Name == name && p.Locale == locale) { + p.Value = value; + return; + } + } + AddinProperty prop = new AddinProperty (); + prop.Name = name; + prop.Value = value; + prop.Locale = locale; + Add (prop); + } + + public void RemoveProperty (string name) + { + RemoveProperty (name, null); + } + + public void RemoveProperty (string name, string locale) + { + locale = NormalizeLocale (locale); + + foreach (var p in this) { + if (p.Name == name && p.Locale == locale) { + Remove (p); + return; + } + } + } + + internal bool HasProperty (string name) + { + return this.Any (p => p.Name == name); + } + + internal string ExtractCoreProperty (string name, bool removeProperty) + { + foreach (var p in this) { + if (p.Name == name && p.Locale == null) { + if (removeProperty) + Remove (p); + return p.Value; + } + } + return null; + } + } +} + diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Description/AddinProperty.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/AddinProperty.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Description/AddinProperty.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/AddinProperty.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,70 @@ +// +// AddinProperty.cs +// +// Author: +// Lluis Sanchez Gual +// +// Copyright (c) 2011 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using System.Xml.Serialization; +using Mono.Addins.Serialization; + +namespace Mono.Addins.Description +{ + /// + /// An add-in property. + /// + public class AddinProperty: IBinaryXmlElement + { + /// + /// Name of the property + /// + [XmlAttribute ("name")] + public string Name { get; set; } + + /// + /// Locale of the property. It is null if the property is not localized. + /// + [XmlAttribute ("locale")] + public string Locale { get; set; } + + /// + /// Value of the property. + /// + [XmlText] + public string Value { get; set; } + + void IBinaryXmlElement.Read (BinaryXmlReader reader) + { + Name = reader.ReadStringValue ("name"); + Locale = reader.ReadStringValue ("locale"); + Value = reader.ReadStringValue ("value"); + } + + void IBinaryXmlElement.Write (BinaryXmlWriter writer) + { + writer.WriteValue ("name", Name); + writer.WriteValue ("locale", Locale); + writer.WriteValue ("value", Value); + } + } +} + diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Description/AssemblyDependency.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/AssemblyDependency.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Description/AssemblyDependency.cs 2008-11-06 19:52:13.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/AssemblyDependency.cs 2011-04-13 09:00:29.000000000 +0000 @@ -35,12 +35,18 @@ namespace Mono.Addins.Description { + /// + /// Definition of a dependency of an add-in on an assembly. + /// [XmlType ("AssemblyDependency")] public class AssemblyDependency: Dependency { string fullName; string package; + /// + /// Initializes a new instance of the class. + /// public AssemblyDependency () { } @@ -63,16 +69,34 @@ Element.SetAttribute ("package", Package); } + /// + /// Gets or sets the full name of the assembly + /// + /// + /// The full name of the assembly. + /// public string FullName { get { return fullName != null ? fullName : string.Empty; } set { fullName = value; } } + /// + /// Gets or sets the name of the package that provides the assembly. + /// + /// + /// The name of the package that provides the assembly. + /// public string Package { get { return package != null ? package : string.Empty; } set { package = value; } } + /// + /// Display name of the dependency + /// + /// + /// The name. + /// public override string Name { get { if (Package.Length > 0) @@ -82,7 +106,7 @@ } } - internal override bool CheckInstalled () + internal override bool CheckInstalled (AddinRegistry registry) { // TODO return true; diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Description/ConditionTypeDescriptionCollection.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/ConditionTypeDescriptionCollection.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Description/ConditionTypeDescriptionCollection.cs 2008-11-06 19:52:13.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/ConditionTypeDescriptionCollection.cs 2011-04-13 09:00:29.000000000 +0000 @@ -31,8 +31,14 @@ namespace Mono.Addins.Description { + /// + /// A collection of condition types + /// public class ConditionTypeDescriptionCollection: ObjectDescriptionCollection { + /// + /// Initializes a new instance of the class. + /// public ConditionTypeDescriptionCollection () { } @@ -41,6 +47,15 @@ { } + /// + /// Gets the at the specified index. + /// + /// + /// Index. + /// + /// + /// The condition. + /// public ConditionTypeDescription this [int n] { get { return (ConditionTypeDescription) List [n]; } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Description/ConditionTypeDescription.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/ConditionTypeDescription.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Description/ConditionTypeDescription.cs 2008-11-06 19:52:13.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/ConditionTypeDescription.cs 2011-04-13 09:00:29.000000000 +0000 @@ -34,6 +34,9 @@ namespace Mono.Addins.Description { + /// + /// A condition type definition. + /// public sealed class ConditionTypeDescription: ObjectDescription { string id; @@ -41,6 +44,9 @@ string addinId; string description; + /// + /// Initializes a new instance of the class. + /// public ConditionTypeDescription () { } @@ -52,6 +58,12 @@ description = ReadXmlDescription (); } + /// + /// Copies data from another condition type definition + /// + /// + /// Condition from which to copy + /// public void CopyFrom (ConditionTypeDescription cond) { id = cond.id; @@ -66,16 +78,34 @@ VerifyNotEmpty (location + "ConditionType (" + Id + ")", errors, TypeName, "type"); } + /// + /// Gets or sets the identifier of the condition type + /// + /// + /// The identifier. + /// public string Id { get { return id != null ? id : string.Empty; } set { id = value; } } + /// + /// Gets or sets the name of the type that implements the condition + /// + /// + /// The name of the type. + /// public string TypeName { get { return typeName != null ? typeName : string.Empty; } set { typeName = value; } } + /// + /// Gets or sets the description of the condition. + /// + /// + /// The description. + /// public string Description { get { return description != null ? description : string.Empty; } set { description = value; } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Description/DependencyCollection.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/DependencyCollection.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Description/DependencyCollection.cs 2008-11-06 19:52:13.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/DependencyCollection.cs 2011-04-13 09:00:29.000000000 +0000 @@ -31,8 +31,14 @@ namespace Mono.Addins.Description { + /// + /// A collection of dependency definitions. + /// public class DependencyCollection: ObjectDescriptionCollection { + /// + /// Initializes a new instance of the class. + /// public DependencyCollection () { } @@ -41,15 +47,33 @@ { } + /// + /// Gets the at the specified index. + /// + /// + /// The idnex. + /// public Dependency this [int n] { get { return (Dependency) List [n]; } } + /// + /// Adds a dependency to the collection + /// + /// + /// The dependency to add. + /// public void Add (Dependency dep) { List.Add (dep); } + /// + /// Remove the specified dependency. + /// + /// + /// Dependency to remove. + /// public void Remove (Dependency dep) { List.Remove (dep); diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Description/Dependency.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/Dependency.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Description/Dependency.cs 2008-11-06 19:52:13.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/Dependency.cs 2011-04-13 09:00:29.000000000 +0000 @@ -33,6 +33,9 @@ namespace Mono.Addins.Description { + /// + /// Definition of an add-in dependency. + /// [XmlInclude (typeof(AddinDependency))] public abstract class Dependency: ObjectDescription { @@ -44,7 +47,13 @@ { } + /// + /// Gets the display name of the dependency. + /// + /// + /// The name. + /// public abstract string Name { get; } - internal abstract bool CheckInstalled (); + internal abstract bool CheckInstalled (AddinRegistry registry); } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Description/ExtensionCollection.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/ExtensionCollection.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Description/ExtensionCollection.cs 2008-11-06 19:52:13.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/ExtensionCollection.cs 2011-04-13 09:00:29.000000000 +0000 @@ -32,8 +32,14 @@ namespace Mono.Addins.Description { + /// + /// A collection of extensions + /// public class ExtensionCollection: ObjectDescriptionCollection { + /// + /// Initializes a new instance of the class. + /// public ExtensionCollection () { } @@ -42,6 +48,12 @@ { } + /// + /// Gets the at the specified index. + /// + /// + /// The index. + /// public Extension this [int n] { get { return (Extension) List [n]; } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Description/Extension.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/Extension.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Description/Extension.cs 2008-11-06 19:52:13.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/Extension.cs 2011-04-13 09:00:29.000000000 +0000 @@ -34,22 +34,47 @@ namespace Mono.Addins.Description { + /// + /// An extension definition. + /// + /// + /// An Extension is a collection of nodes which have to be registered in an extension point. + /// The target extension point is specified in the .Path property. + /// public class Extension: ObjectDescription, IComparable { string path; ExtensionNodeDescriptionCollection nodes; + /// + /// Initializes a new instance of the class. + /// public Extension () { } + /// + /// Initializes a new instance of the class. + /// + /// + /// Path that identifies the extension point being extended + /// public Extension (string path) { this.path = path; } - // Returns the object extended by this Extension. It can be an ExtensionPoint or - // an ExtensionNodeDescription. + /// + /// Gets the object extended by this extension + /// + /// + /// The extended object can be an or + /// an . + /// + /// + /// This method only works when the add-in description to which the extension belongs has been + /// loaded from an add-in registry. + /// public ObjectDescription GetExtendedObject () { AddinDescription desc = ParentAddinDescription; @@ -80,6 +105,16 @@ return null; } + /// + /// Gets the node types allowed in this extension. + /// + /// + /// The allowed node types. + /// + /// + /// This method only works when the add-in description to which the extension belongs has been + /// loaded from an add-in registry. + /// public ExtensionNodeTypeCollection GetAllowedNodeTypes () { ObjectDescription ob = GetExtendedObject (); @@ -138,7 +173,7 @@ void VerifyConditionNode (string location, ExtensionNodeDescription node, StringCollection errors) { string nodeName = node.NodeName; - if (nodeName != "Or" && nodeName != "And" && nodeName != "Condition") { + if (nodeName != "Or" && nodeName != "And" && nodeName != "Not" && nodeName != "Condition") { errors.Add (location + "ComplexCondition: Invalid condition element: " + nodeName); return; } @@ -146,12 +181,24 @@ VerifyConditionNode (location, cnode, errors); } + /// + /// Initializes a new instance of the class. + /// + /// + /// XML that describes the extension. + /// public Extension (XmlElement element) { Element = element; path = element.GetAttribute ("path"); } + /// + /// Gets or sets the path that identifies the extension point being extended. + /// + /// + /// The path. + /// public string Path { get { return path; } set { path = value; } @@ -168,6 +215,12 @@ nodes.SaveXml (Element); } + /// + /// Gets the extension nodes. + /// + /// + /// The extension nodes. + /// public ExtensionNodeDescriptionCollection ExtensionNodes { get { if (nodes == null) { diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Description/ExtensionNodeDescriptionCollection.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/ExtensionNodeDescriptionCollection.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Description/ExtensionNodeDescriptionCollection.cs 2008-11-06 19:52:13.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/ExtensionNodeDescriptionCollection.cs 2011-04-13 09:00:29.000000000 +0000 @@ -32,8 +32,14 @@ namespace Mono.Addins.Description { + /// + /// A collection of extension nodes + /// public class ExtensionNodeDescriptionCollection: ObjectDescriptionCollection, NodeElementCollection { + /// + /// Initializes a new instance of the class. + /// public ExtensionNodeDescriptionCollection () { } @@ -42,10 +48,22 @@ { } + /// + /// Gets the at the specified index. + /// + /// + /// The index. + /// public ExtensionNodeDescription this [int n] { get { return (ExtensionNodeDescription) List [n]; } } + /// + /// Gets the with the specified identifier. + /// + /// + /// Identifier. + /// public ExtensionNodeDescription this [string id] { get { foreach (ExtensionNodeDescription node in List) diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Description/ExtensionNodeDescription.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/ExtensionNodeDescription.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Description/ExtensionNodeDescription.cs 2008-11-06 19:52:13.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/ExtensionNodeDescription.cs 2011-04-13 09:00:29.000000000 +0000 @@ -34,12 +34,21 @@ namespace Mono.Addins.Description { + /// + /// An extension node definition. + /// public class ExtensionNodeDescription: ObjectDescription, NodeElement { ExtensionNodeDescriptionCollection childNodes; string[] attributes; string nodeName; + /// + /// Initializes a new instance of the class. + /// + /// + /// Node name. + /// public ExtensionNodeDescription (string nodeName) { this.nodeName = nodeName; @@ -55,6 +64,16 @@ { } + /// + /// Gets the type of the node. + /// + /// + /// The node type. + /// + /// + /// This method only works when the add-in description to which the node belongs has been + /// loaded from an add-in registry. + /// public ExtensionNodeType GetNodeType () { if (Parent is Extension) { @@ -78,6 +97,16 @@ return null; } + /// + /// Gets the extension path under which this node is registered + /// + /// + /// The parent path. + /// + /// + /// For example, if the id of the node is 'ThisNode', and the node is a child of another node with id 'ParentNode', and + /// that parent node is defined in an extension with the path '/Core/MainExtension', then the parent path is 'Core/MainExtension/ParentNode'. + /// public string GetParentPath () { if (Parent is Extension) @@ -97,15 +126,38 @@ ChildNodes.Verify (location + NodeName + "/", errors); } + /// + /// Gets or sets the name of the node. + /// + /// + /// The name of the node. + /// public string NodeName { get { return nodeName; } + internal set { + if (Element != null) + throw new InvalidOperationException ("Can't change node name of xml element"); + nodeName = value; + } } + /// + /// Gets or sets the identifier of the node. + /// + /// + /// The identifier. + /// public string Id { get { return GetAttribute ("id"); } set { SetAttribute ("id", value); } } + /// + /// Gets or sets the identifier of the node after which this node has to be inserted + /// + /// + /// The identifier of the reference node + /// public string InsertAfter { get { return GetAttribute ("insertafter"); } set { @@ -116,6 +168,12 @@ } } + /// + /// Gets or sets the identifier of the node before which this node has to be inserted + /// + /// + /// The identifier of the reference node + /// public string InsertBefore { get { return GetAttribute ("insertbefore"); } set { @@ -126,6 +184,12 @@ } } + /// + /// Gets a value indicating whether this node is a condition. + /// + /// + /// true if this node is a condition; otherwise, false. + /// public bool IsCondition { get { return nodeName == "Condition" || nodeName == "ComplexCondition"; } } @@ -143,6 +207,15 @@ } } + /// + /// Gets the value of an attribute. + /// + /// + /// The value of the attribute, or an empty string if the attribute is not defined. + /// + /// + /// Name of the attribute. + /// public string GetAttribute (string key) { if (Element != null) @@ -157,6 +230,15 @@ return string.Empty; } + /// + /// Sets the value of an attribute. + /// + /// + /// Name of the attribute + /// + /// + /// The value. + /// public void SetAttribute (string key, string value) { if (Element != null) { @@ -187,6 +269,12 @@ attributes [attributes.Length - 1] = value; } + /// + /// Removes an attribute. + /// + /// + /// Name of the attribute to remove. + /// public void RemoveAttribute (string name) { if (Element != null) { @@ -202,11 +290,18 @@ string[] newar = new string [attributes.Length - 2]; Array.Copy (attributes, 0, newar, 0, n); Array.Copy (attributes, n+2, newar, n, attributes.Length - n - 2); + attributes = newar; break; } } } + /// + /// Gets the attributes of the node. + /// + /// + /// The attributes. + /// public NodeAttribute[] Attributes { get { if (Element != null) @@ -224,6 +319,12 @@ } } + /// + /// Gets the child nodes. + /// + /// + /// The child nodes. + /// public ExtensionNodeDescriptionCollection ChildNodes { get { if (childNodes == null) { diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Description/ExtensionNodeSetCollection.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/ExtensionNodeSetCollection.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Description/ExtensionNodeSetCollection.cs 2008-11-06 19:52:13.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/ExtensionNodeSetCollection.cs 2011-04-13 09:00:29.000000000 +0000 @@ -32,8 +32,14 @@ namespace Mono.Addins.Description { + /// + /// A collection of node sets. + /// public class ExtensionNodeSetCollection: ObjectDescriptionCollection { + /// + /// Initializes a new instance of the class. + /// public ExtensionNodeSetCollection () { } @@ -42,10 +48,22 @@ { } + /// + /// Gets the at the specified index. + /// + /// + /// The index. + /// public ExtensionNodeSet this [int n] { get { return (ExtensionNodeSet) List [n]; } } + /// + /// Gets the with the specified id. + /// + /// + /// Identifier. + /// public ExtensionNodeSet this [string id] { get { for (int n=0; n + /// An extension node set definition. + /// + /// + /// Node sets allow grouping a set of extension node declarations and give an identifier to that group + /// (the node set). Once a node set is declared, it can be referenced from several extension points + /// which use the same extension node structure. Extension node sets also allow declaring recursive + /// extension nodes, that is, extension nodes with a tree structure. + /// public class ExtensionNodeSet: ObjectDescription { string id; @@ -43,12 +52,20 @@ bool missingNodeSetId; ExtensionNodeTypeCollection cachedAllowedTypes; + internal string SourceAddinId { get; set; } + internal ExtensionNodeSet (XmlElement element) { Element = element; id = element.GetAttribute (IdAttribute); } + /// + /// Copies data from another node set + /// + /// + /// Node set from which to copy + /// public void CopyFrom (ExtensionNodeSet nset) { id = nset.id; @@ -105,10 +122,19 @@ } } + /// + /// Initializes a new instance of the class. + /// public ExtensionNodeSet () { } + /// + /// Gets or sets the identifier of the node set. + /// + /// + /// The identifier. + /// public string Id { get { return id != null ? id : string.Empty; } set { id = value; } @@ -118,6 +144,12 @@ get { return "id"; } } + /// + /// Gets the node types allowed in this node set. + /// + /// + /// The node types. + /// public ExtensionNodeTypeCollection NodeTypes { get { if (nodeTypes == null) { @@ -130,6 +162,12 @@ } } + /// + /// Gets a list of other node sets included in this node set. + /// + /// + /// The node sets. + /// public NodeSetIdCollection NodeSets { get { if (nodeSets == null) { @@ -142,11 +180,18 @@ } } + /// + /// Gets all the allowed node types. + /// + /// + /// The allowed node types. + /// + /// + /// Gets all allowed node types, including those defined in included node sets. + /// This method only works for descriptions loaded from a registry. + /// public ExtensionNodeTypeCollection GetAllowedNodeTypes () { - // Gets all allowed node types, including those defined in node sets - // It only works for descriptions generated from a registry - if (cachedAllowedTypes == null) { cachedAllowedTypes = new ExtensionNodeTypeCollection (); GetAllowedNodeTypes (new Hashtable (), cachedAllowedTypes); @@ -260,20 +305,41 @@ } } + /// + /// A collection of node set identifiers + /// public class NodeSetIdCollection: IEnumerable { // A list of string[2]. Item 0 is the node set id, item 1 is the addin that defines it. ArrayList list = new ArrayList (); + /// + /// Gets the node set identifier at the specified index. + /// + /// + /// An index. + /// public string this [int n] { - get { return (string) list [n]; } + get { return ((string[])list [n])[0]; } } + /// + /// Gets the item count. + /// + /// + /// The count. + /// public int Count { get { return list.Count; } } + /// + /// Gets the collection enumerator. + /// + /// + /// The enumerator. + /// public IEnumerator GetEnumerator () { ArrayList ll = new ArrayList (list.Count); @@ -282,12 +348,24 @@ return ll.GetEnumerator (); } + /// + /// Add the specified node set identifier. + /// + /// + /// Node set identifier. + /// public void Add (string nodeSetId) { if (!Contains (nodeSetId)) list.Add (new string [] { nodeSetId, null }); } + /// + /// Remove a node set identifier + /// + /// + /// Node set identifier. + /// public void Remove (string nodeSetId) { int i = IndexOf (nodeSetId); @@ -295,16 +373,34 @@ list.RemoveAt (i); } + /// + /// Clears the collection + /// public void Clear () { list.Clear (); } + /// + /// Checks if the specified identifier is present in the collection + /// + /// + /// true if the node set identifier is present. + /// public bool Contains (string nodeSetId) { return IndexOf (nodeSetId) != -1; } + /// + /// Returns the index of the specified node set identifier + /// + /// + /// The index. + /// + /// + /// A node set identifier. + /// public int IndexOf (string nodeSetId) { for (int n=0; n + /// A collection of node types. + /// public class ExtensionNodeTypeCollection: ObjectDescriptionCollection { + /// + /// Initializes a new instance of the class. + /// public ExtensionNodeTypeCollection () { } @@ -42,10 +48,22 @@ { } + /// + /// Gets the at the specified index. + /// + /// + /// The index. + /// public ExtensionNodeType this [int n] { get { return (ExtensionNodeType) List [n]; } } + /// + /// Gets the with the specified id. + /// + /// + /// Identifier. + /// public ExtensionNodeType this [string id] { get { for (int n=0; n + /// An extension node type definition. + /// public sealed class ExtensionNodeType: ExtensionNodeSet { string typeName; @@ -43,6 +47,7 @@ string description; string addinId; NodeTypeAttributeCollection attributes; + string customAttributeTypeName; // Cached clr type [NonSerialized] @@ -50,12 +55,33 @@ // Cached serializable fields [NonSerialized] - internal Hashtable Fields; + internal Dictionary Fields; + + // Cached serializable fields for the custom attribute + [NonSerialized] + internal Dictionary CustomAttributeFields; + + [NonSerialized] + internal FieldData CustomAttributeMember; internal class FieldData { - public FieldInfo Field; + public MemberInfo Member; public bool Required; public bool Localizable; + + public void SetValue (object target, object val) + { + if (Member is FieldInfo) + ((FieldInfo)Member).SetValue (target, val); + else + ((PropertyInfo)Member).SetValue (target, val, null); + } + + public Type MemberType { + get { + return (Member is FieldInfo) ? ((FieldInfo)Member).FieldType : ((PropertyInfo)Member).PropertyType; + } + } } // Addin where this extension type is implemented @@ -64,29 +90,55 @@ set { addinId = value; } } - // Type of the extension node + /// + /// Type that implements the extension node. + /// + /// + /// The full name of the type. + /// public string TypeName { get { return typeName != null ? typeName : string.Empty; } set { typeName = value; } } + /// + /// Element name to be used when defining an extension in an XML manifest. The default name is "Type". + /// + /// + /// The name of the node. + /// public string NodeName { get { return Id; } set { Id = value; } } - // Type of the object that the extension creates (only valid for TypeNodeExtension). + /// + /// Type of the object that the extension creates (only valid for TypeNodeExtension). + /// public string ObjectTypeName { get { return objectTypeName != null ? objectTypeName : string.Empty; } set { objectTypeName = value; } } - // The description + /// + /// Name of the custom attribute that can be used to declare nodes of this type + /// + public string ExtensionAttributeTypeName { + get { return customAttributeTypeName ?? string.Empty; } + set { customAttributeTypeName = value; } + } + + /// + /// Long description of the node type + /// public string Description { get { return description != null ? description : string.Empty; } set { description = value; } } + /// + /// Attributes supported by the extension node type. + /// public NodeTypeAttributeCollection Attributes { get { if (attributes == null) { @@ -114,15 +166,24 @@ at = element.Attributes ["objectType"]; if (at != null) objectTypeName = at.Value; + at = element.Attributes ["customAttributeType"]; + if (at != null) + customAttributeTypeName = at.Value; XmlElement de = element ["Description"]; if (de != null) description = de.InnerText; } + /// + /// Initializes a new instance of the class. + /// public ExtensionNodeType () { } + /// + /// Copies data from another node set + /// public void CopyFrom (ExtensionNodeType ntype) { base.CopyFrom (ntype); @@ -172,6 +233,11 @@ Element.SetAttribute ("objectType", ObjectTypeName); else Element.RemoveAttribute ("objectType"); + + if (ExtensionAttributeTypeName.Length > 0) + Element.SetAttribute ("customAttributeType", ExtensionAttributeTypeName); + else + Element.RemoveAttribute ("customAttributeType"); SaveXmlDescription (Description); } @@ -188,6 +254,7 @@ writer.WriteValue ("description", description); writer.WriteValue ("addinId", addinId); writer.WriteValue ("Attributes", attributes); + writer.WriteValue ("customAttributeType", customAttributeTypeName); } internal override void Read (BinaryXmlReader reader) @@ -200,6 +267,7 @@ addinId = reader.ReadStringValue ("addinId"); if (!reader.IgnoreDescriptionData) attributes = (NodeTypeAttributeCollection) reader.ReadValue ("Attributes", new NodeTypeAttributeCollection (this)); + customAttributeTypeName = reader.ReadStringValue ("customAttributeType"); } } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Description/ExtensionPointCollection.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/ExtensionPointCollection.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Description/ExtensionPointCollection.cs 2008-11-06 19:52:13.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/ExtensionPointCollection.cs 2011-04-13 09:00:29.000000000 +0000 @@ -32,8 +32,14 @@ namespace Mono.Addins.Description { + /// + /// A collection of extension point definitions. + /// public class ExtensionPointCollection: ObjectDescriptionCollection { + /// + /// Initializes a new instance of the class. + /// public ExtensionPointCollection () { } @@ -42,10 +48,22 @@ { } + /// + /// Gets the at the specified index. + /// + /// + /// The index. + /// public ExtensionPoint this [int n] { get { return (ExtensionPoint) List [n]; } } + /// + /// Gets the with the specified path. + /// + /// + /// Path. + /// public ExtensionPoint this [string path] { get { for (int n=0; n + /// An extension point definition. + /// public sealed class ExtensionPoint: ObjectDescription { string path; @@ -45,8 +49,8 @@ // Information gathered from others addins: - StringCollection addins; // Add-ins which extend this extension point - string rootAddin; // Add-in which defines this extension point + List addins; // Add-ins which extend this extension point + string rootAddin; // Add-in which defines this extension point internal ExtensionPoint (XmlElement elem): base (elem) { @@ -55,10 +59,19 @@ description = ReadXmlDescription (); } + /// + /// Initializes a new instance of the class. + /// public ExtensionPoint () { } + /// + /// Copies another extension point. + /// + /// + /// Extension point from which to copy. + /// public void CopyFrom (ExtensionPoint ep) { path = ep.path; @@ -154,25 +167,55 @@ } } + /// + /// Gets or sets the path that identifies the extension point. + /// + /// + /// The path. + /// public string Path { get { return path != null ? path : string.Empty; } set { path = value; } } + /// + /// Gets or sets the display name of the extension point. + /// + /// + /// The name. + /// public string Name { get { return name != null ? name : string.Empty; } set { name = value; } } + /// + /// Gets or sets the description of the extension point. + /// + /// + /// The description. + /// public string Description { get { return description != null ? description : string.Empty; } set { description = value; } } - internal StringCollection Addins { + /// + /// Gets a list of add-ins that extend this extension point. + /// + /// + /// This value is only available when the add-in description is loaded from an add-in registry. + /// + public string[] ExtenderAddins { + get { + return Addins.ToArray (); + } + } + + internal List Addins { get { if (addins == null) - addins = new StringCollection (); + addins = new List (); return addins; } } @@ -182,6 +225,12 @@ set { rootAddin = value; } } + /// + /// A node set which specifies the node types allowed in this extension point. + /// + /// + /// The node set. + /// public ExtensionNodeSet NodeSet { get { if (nodeSet == null) { @@ -202,6 +251,12 @@ nodeSet.SetParent (this); } + /// + /// Gets the conditions available in this node set. + /// + /// + /// The conditions. + /// public ConditionTypeDescriptionCollection Conditions { get { if (conditions == null) { @@ -215,6 +270,21 @@ } } + /// + /// Adds an extension node type. + /// + /// + /// The extension node type. + /// + /// + /// Name of the node + /// + /// + /// Name of the type that implements the extension node. + /// + /// + /// This method can be used to register a new allowed node type for the extension point. + /// public ExtensionNodeType AddExtensionNode (string name, string typeName) { ExtensionNodeType ntype = new ExtensionNodeType (); @@ -242,7 +312,7 @@ if (!reader.IgnoreDescriptionData) description = reader.ReadStringValue ("description"); rootAddin = reader.ReadStringValue ("rootAddin"); - addins = (StringCollection) reader.ReadValue ("addins", new StringCollection ()); + addins = (List) reader.ReadValue ("addins", new List ()); nodeSet = (ExtensionNodeSet) reader.ReadValue ("NodeSet"); conditions = (ConditionTypeDescriptionCollection) reader.ReadValue ("Conditions", new ConditionTypeDescriptionCollection (this)); if (nodeSet != null) diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Description/ModuleDescriptionCollection.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/ModuleDescriptionCollection.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Description/ModuleDescriptionCollection.cs 2008-11-06 19:52:13.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/ModuleDescriptionCollection.cs 2011-04-13 09:00:29.000000000 +0000 @@ -31,8 +31,14 @@ namespace Mono.Addins.Description { + /// + /// A collection of module descriptions + /// public class ModuleCollection: ObjectDescriptionCollection { + /// + /// Initializes a new instance of the class. + /// public ModuleCollection () { } @@ -41,6 +47,12 @@ { } + /// + /// Gets the at the specified index. + /// + /// + /// The index. + /// public ModuleDescription this [int n] { get { return (ModuleDescription) List [n]; } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Description/ModuleDescription.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/ModuleDescription.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Description/ModuleDescription.cs 2008-11-06 19:52:13.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/ModuleDescription.cs 2011-04-13 09:00:29.000000000 +0000 @@ -36,6 +36,13 @@ namespace Mono.Addins.Description { + /// + /// A module definition. + /// + /// + /// Optional modules can be used to declare extensions which will be registered only if some + /// specified add-in dependencies can be satisfied. + /// public class ModuleDescription: ObjectDescription { StringCollection assemblies; @@ -44,15 +51,30 @@ DependencyCollection dependencies; ExtensionCollection extensions; + // Used only at run time + internal RuntimeAddin RuntimeAddin; + internal ModuleDescription (XmlElement element) { Element = element; } + /// + /// Initializes a new instance of the class. + /// public ModuleDescription () { } + /// + /// Checks if this module depends on the specified add-in. + /// + /// + /// true if there is a dependency. + /// + /// + /// Identifier of the add-in + /// public bool DependsOnAddin (string addinId) { AddinDescription desc = Parent as AddinDescription; @@ -68,6 +90,9 @@ return false; } + /// + /// Gets the list of paths to be ignored by the add-in scanner. + /// public StringCollection IgnorePaths { get { if (ignorePaths == null) @@ -76,6 +101,15 @@ } } + /// + /// Gets all external files + /// + /// + /// All files. + /// + /// + /// External files are data files and assemblies explicitly referenced in the Runtime section of the add-in manifest. + /// public StringCollection AllFiles { get { StringCollection col = new StringCollection (); @@ -89,6 +123,9 @@ } } + /// + /// Gets the list of external assemblies used by this module. + /// public StringCollection Assemblies { get { if (assemblies == null) { @@ -101,6 +138,9 @@ } } + /// + /// Gets the list of external data files used by this module + /// public StringCollection DataFiles { get { if (dataFiles == null) { @@ -113,6 +153,9 @@ } } + /// + /// Gets the dependencies of this module + /// public DependencyCollection Dependencies { get { if (dependencies == null) { @@ -138,6 +181,9 @@ } } + /// + /// Gets the extensions of this module + /// public ExtensionCollection Extensions { get { if (extensions == null) { @@ -151,6 +197,21 @@ } } + /// + /// Adds an extension node to the module. + /// + /// + /// The extension node. + /// + /// + /// Path that identifies the extension point. + /// + /// + /// Node name. + /// + /// + /// This method creates a new Extension object for the provided path if none exist. + /// public ExtensionNodeDescription AddExtensionNode (string path, string nodeName) { ExtensionNodeDescription node = new ExtensionNodeDescription (nodeName); @@ -158,6 +219,18 @@ return node; } + /// + /// Gets an extension instance. + /// + /// + /// The extension instance. + /// + /// + /// Path that identifies the extension point that the extension extends. + /// + /// + /// This method creates a new Extension object for the provided path if none exist. + /// public Extension GetExtension (string path) { foreach (Extension e in Extensions) { @@ -215,6 +288,15 @@ } } + /// + /// Adds an add-in reference (there is a typo in the method name) + /// + /// + /// Identifier of the add-in. + /// + /// + /// Version of the add-in. + /// public void AddAssemblyReference (string id, string version) { XmlElement deps = GetDependenciesElement (); diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Description/NativeDependency.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/NativeDependency.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Description/NativeDependency.cs 2008-11-06 19:52:13.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/NativeDependency.cs 2011-04-13 09:00:29.000000000 +0000 @@ -34,6 +34,8 @@ namespace Mono.Addins.Description { +#pragma warning disable 1591 + [Obsolete] [XmlType ("NativeReference")] public class NativeDependency: Dependency { @@ -41,9 +43,10 @@ get { return "Native dependency"; } } - internal override bool CheckInstalled () + internal override bool CheckInstalled (AddinRegistry registry) { return false; } } +#pragma warning restore 1591 } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Description/NodeTypeAttributeCollection.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/NodeTypeAttributeCollection.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Description/NodeTypeAttributeCollection.cs 2008-11-06 19:52:13.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/NodeTypeAttributeCollection.cs 2011-04-13 09:00:29.000000000 +0000 @@ -31,8 +31,14 @@ namespace Mono.Addins.Description { + /// + /// A collection of node attributes + /// public class NodeTypeAttributeCollection: ObjectDescriptionCollection { + /// + /// Initializes a new instance of the class. + /// public NodeTypeAttributeCollection () { } @@ -41,6 +47,12 @@ { } + /// + /// Gets the at the specified index. + /// + /// + /// The index. + /// public NodeTypeAttribute this [int n] { get { return (NodeTypeAttribute) List [n]; } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Description/NodeTypeAttribute.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/NodeTypeAttribute.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Description/NodeTypeAttribute.cs 2008-11-06 19:52:13.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/NodeTypeAttribute.cs 2011-04-13 09:00:29.000000000 +0000 @@ -34,6 +34,9 @@ namespace Mono.Addins.Description { + /// + /// Description of the attribute of a node type. + /// public sealed class NodeTypeAttribute: ObjectDescription { string name; @@ -42,10 +45,19 @@ bool localizable; string description; + /// + /// Initializes a new instance of the class. + /// public NodeTypeAttribute() { } + /// + /// Copies data from another node attribute. + /// + /// + /// The attribute from which to copy. + /// public void CopyFrom (NodeTypeAttribute att) { name = att.name; @@ -55,31 +67,71 @@ description = att.description; } + /// + /// Gets or sets the name of the attribute. + /// + /// + /// The name. + /// public string Name { get { return name != null ? name : string.Empty; } set { name = value; } } + /// + /// Gets or sets a value indicating whether this is required. + /// + /// + /// true if required; otherwise, false. + /// public bool Required { get { return required; } set { required = value; } } + /// + /// Gets or sets a value indicating whether this is localizable. + /// + /// + /// true if localizable; otherwise, false. + /// public bool Localizable { get { return localizable; } set { localizable = value; } } + /// + /// Gets or sets the type of the attribute. + /// + /// + /// The type. + /// public string Type { get { return type != null ? type : string.Empty; } set { type = value; } } + /// + /// Gets or sets the description of the attribute. + /// + /// + /// The description. + /// public string Description { get { return description != null ? description : string.Empty; } set { description = value; } } + /// + /// Gets or sets the type of the content. + /// + /// + /// Allows specifying the type of the content of a string attribute. + /// The value of this property is only informative, and it doesn't + /// have any effect on how add-ins are packaged or loaded. + /// + public ContentType ContentType { get; set; } + internal override void Verify (string location, StringCollection errors) { VerifyNotEmpty (location + "Attribute", errors, Name, "name"); @@ -91,6 +143,9 @@ type = elem.GetAttribute ("type"); required = elem.GetAttribute ("required").ToLower () == "true"; localizable = elem.GetAttribute ("localizable").ToLower () == "true"; + string ct = elem.GetAttribute ("contentType"); + if (!string.IsNullOrEmpty (ct)) + ContentType = (ContentType) Enum.Parse (typeof(ContentType), ct); description = ReadXmlDescription (); } @@ -114,6 +169,11 @@ else Element.RemoveAttribute ("localizable"); + if (ContentType != ContentType.Text) + Element.SetAttribute ("contentType", ContentType.ToString ()); + else + Element.RemoveAttribute ("contentType"); + SaveXmlDescription (description); } @@ -124,6 +184,7 @@ writer.WriteValue ("required", required); writer.WriteValue ("description", description); writer.WriteValue ("localizable", localizable); + writer.WriteValue ("contentType", ContentType.ToString ()); } internal override void Read (BinaryXmlReader reader) @@ -134,6 +195,12 @@ if (!reader.IgnoreDescriptionData) description = reader.ReadStringValue ("description"); localizable = reader.ReadBooleanValue ("localizable"); + string ct = reader.ReadStringValue ("contentType"); + try { + ContentType = (ContentType) Enum.Parse (typeof(ContentType), ct); + } catch { + ContentType = ContentType.Text; + } } } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Description/ObjectDescriptionCollection.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/ObjectDescriptionCollection.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Description/ObjectDescriptionCollection.cs 2008-11-06 19:52:13.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/ObjectDescriptionCollection.cs 2011-04-13 09:00:29.000000000 +0000 @@ -34,6 +34,9 @@ namespace Mono.Addins.Description { + /// + /// Base class for add-in description collections. + /// public class ObjectDescriptionCollection: CollectionBase { object owner; @@ -43,31 +46,73 @@ this.owner = owner; } + /// + /// Initializes a new instance of the class. + /// public ObjectDescriptionCollection () { } + /// + /// Add an object. + /// + /// + /// The object. + /// public void Add (ObjectDescription ep) { List.Add (ep); } + /// + /// Adds a collection of objects. + /// + /// + /// The objects to add. + /// public void AddRange (ObjectDescriptionCollection collection) { foreach (ObjectDescription ob in collection) Add (ob); } + /// + /// Insert an object. + /// + /// + /// Insertion index. + /// + /// + /// The object. + /// + public void Insert (int index, ObjectDescription ep) + { + List.Insert (index, ep); + } + + /// + /// Removes an object. + /// + /// + /// Object to remove. + /// public void Remove (ObjectDescription ep) { List.Remove (ep); } + /// + /// Checks if an object is present in the collection. + /// + /// + /// Objecect to check. + /// public bool Contains (ObjectDescription ob) { return List.Contains (ob); } +#pragma warning disable 1591 protected override void OnRemove (int index, object value) { ObjectDescription ep = (ObjectDescription) value; @@ -100,6 +145,7 @@ ob.SetParent (null); } } +#pragma warning restore 1591 internal void SaveXml (XmlElement parent) diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Description/ObjectDescription.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/ObjectDescription.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Description/ObjectDescription.cs 2008-11-06 19:52:13.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Description/ObjectDescription.cs 2011-04-13 09:00:29.000000000 +0000 @@ -34,6 +34,9 @@ namespace Mono.Addins.Description { + /// + /// Base class for add-in description definitions. + /// public class ObjectDescription: IBinaryXmlElement { internal XmlElement Element; @@ -48,10 +51,22 @@ { } + /// + /// Gets the parent object. + /// + /// + /// The parent object. + /// public object Parent { get { return parent; } } + /// + /// Gets the parent add-in description. + /// + /// + /// The parent add-in description. + /// public AddinDescription ParentAddinDescription { get { if (parent is AddinDescription) diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.dll.config mono-addins-0.6.1/Mono.Addins/Mono.Addins.dll.config --- mono-addins-0.4/Mono.Addins/Mono.Addins.dll.config 2008-11-06 19:52:14.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.dll.config 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ - - - - - - diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Localization/IAddinLocalizer.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Localization/IAddinLocalizer.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Localization/IAddinLocalizer.cs 2008-11-06 19:52:10.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Localization/IAddinLocalizer.cs 2011-04-13 09:00:29.000000000 +0000 @@ -30,8 +30,24 @@ namespace Mono.Addins.Localization { + /// + /// An add-in localizer. + /// + /// + /// Add-in localizers which want to provide support for localization of plural forms + /// can additionally implement . + /// public interface IAddinLocalizer { + /// + /// Gets a localized message. + /// + /// + /// The localized message. + /// + /// + /// The message identifier. + /// string GetString (string msgid); } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Localization/IAddinLocalizerFactory.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Localization/IAddinLocalizerFactory.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Localization/IAddinLocalizerFactory.cs 2008-11-06 19:52:10.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Localization/IAddinLocalizerFactory.cs 2011-04-13 09:00:29.000000000 +0000 @@ -30,8 +30,23 @@ namespace Mono.Addins.Localization { + /// + /// A localizer factory. + /// public interface IAddinLocalizerFactory { + /// + /// Creates a localizer for an add-in. + /// + /// + /// The localizer. + /// + /// + /// The add-in for which to create the localizer. + /// + /// + /// Localizer parameters. + /// IAddinLocalizer CreateLocalizer (RuntimeAddin addin, NodeElement element); } } diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Localization/IPluralAddinLocalizer.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Localization/IPluralAddinLocalizer.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Localization/IPluralAddinLocalizer.cs 2008-11-06 19:52:10.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Localization/IPluralAddinLocalizer.cs 2011-04-13 09:00:29.000000000 +0000 @@ -29,8 +29,30 @@ namespace Mono.Addins.Localization { + /// + /// A localizer that supports localization of plural forms. + /// + /// + /// This interface can be implemented by add-in localizers which want to provide + /// support plural forms. + /// public interface IPluralAddinLocalizer { + /// + /// Gets a localized message which may contain plural forms. + /// + /// + /// The localized message. + /// + /// + /// Message identifier to use when the specified count is 1. + /// + /// + /// Default message identifier to use when the specified count is not 1. + /// + /// + /// The count that determines which plural form to use. + /// string GetPluralString (string singular, String defaultPlural, int n); } } diff -Nru mono-addins-0.4/Mono.Addins/mono-addins.pc.in mono-addins-0.6.1/Mono.Addins/mono-addins.pc.in --- mono-addins-0.4/Mono.Addins/mono-addins.pc.in 2008-11-06 19:52:14.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/mono-addins.pc.in 2011-04-13 09:00:29.000000000 +0000 @@ -1,11 +1,12 @@ -prefix=@prefix@ +prefix=${pcfiledir}/../.. exec_prefix=${prefix} -pkglibdir=@libdir@/mono/@PACKAGE@ -Libraries= ${pkglibdir}/@MONO_ADDINS_DEFAULT_LIB@ +pkglibdir=${prefix}/lib/mono/@PACKAGE@ + +Libraries=${pkglibdir}/@MONO_ADDINS_DEFAULT_LIB@ Name: Mono.Addins Description: Version: @VERSION@ Requires: -Libs: -r:${pkglibdir}/@MONO_ADDINS_DEFAULT_LIB@ \ No newline at end of file +Libs: -r:${pkglibdir}/@MONO_ADDINS_DEFAULT_LIB@ diff -Nru mono-addins-0.4/Mono.Addins/Mono.Addins.Serialization/BinaryXmlReader.cs mono-addins-0.6.1/Mono.Addins/Mono.Addins.Serialization/BinaryXmlReader.cs --- mono-addins-0.4/Mono.Addins/Mono.Addins.Serialization/BinaryXmlReader.cs 2008-11-06 19:52:10.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins/Mono.Addins.Serialization/BinaryXmlReader.cs 2011-04-13 09:00:29.000000000 +0000 @@ -38,6 +38,7 @@ { BinaryReader reader; + internal const byte TagEndOfFile = 0; internal const byte TagBeginElement = 1; internal const byte TagEndElement = 2; internal const byte TagValue = 4; @@ -81,7 +82,7 @@ { int b = reader.BaseStream.ReadByte (); if (b == -1) { - currentType = TagBeginElement; + currentType = TagEndOfFile; return; } currentType = (byte) b; diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/AssemblyInfo.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/AssemblyInfo.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/AssemblyInfo.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/AssemblyInfo.cs 2011-04-13 09:00:29.000000000 +0000 @@ -17,4 +17,4 @@ // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly: AssemblyVersion("0.4.0.0")] +[assembly: AssemblyVersion("0.6.0.0")] diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/ChangeLog mono-addins-0.6.1/Mono.Addins.CecilReflector/ChangeLog --- mono-addins-0.4/Mono.Addins.CecilReflector/ChangeLog 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/ChangeLog 2011-04-13 09:00:29.000000000 +0000 @@ -1,3 +1,62 @@ +2010-05-25 Lluis Sanchez Gual + + * Mono.Addins.CecilReflector.csproj: Fix output directory for + the Release configuration. + +2010-05-25 Lluis Sanchez Gual + + * Mono.Addins.CecilReflector/Reflector.cs: When resolving + custom attribute properties and fields look it base classes. + +2010-05-20 Lluis Sanchez Gual + + * Mono.Addins.CecilReflector/Reflector.cs: Added methods for + getting resources from an assembly. + +2010-03-30 Lluis Sanchez Gual + + * Mono.Addins.CecilReflector.csproj: csc doesn't like iso-2. + +2010-03-29 Lluis Sanchez Gual + + * Mono.Addins.CecilReflector.csproj: Make sure the solution + builds on MS.NET 2.0. + +2010-03-26 Lluis Sanchez Gual + + * Mono.Addins.CecilReflector/Reflector.cs: Fix potential NRE. + +2010-03-26 Lluis Sanchez Gual + + * Mono.Addins.CecilReflector.csproj: Flush. + +2010-03-26 Lluis Sanchez Gual + + * Mono.Addins.CecilReflector/Reflector.cs: Implement + GetRawCustomAttributes. + +2009-09-01 Lluis Sanchez Gual + + * AssemblyInfo.cs: Bump Mono.Addins version. + +2009-08-19 Lluis Sanchez Gual + + * Mono.Addins.CecilReflector.csproj: Update target framework + to 2.0. + +2009-05-28 Lluis Sanchez Gual + + * Mono.Addins.CecilReflector.csproj: Properly sign assemblies. + +2009/02/06 Lluis Sanchez Gual + + * Mono.Addins.CecilReflector.csproj: Updated. + +2008-11-10 Lluis Sanchez Gual + + * Makefile.am: Fix building with parallel make jobs (-j8). Fixes bug + #443206. Patch by Diego Pettenò. + 2008-08-22 Lluis Sanchez Gual * Mono.Addins.CecilReflector.csproj, Mono.Addins.CecilReflector.mdp: diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Makefile.am mono-addins-0.6.1/Mono.Addins.CecilReflector/Makefile.am --- mono-addins-0.4/Mono.Addins.CecilReflector/Makefile.am 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Makefile.am 2011-04-13 09:00:29.000000000 +0000 @@ -1,7 +1,7 @@ KEY_FILE=$(top_srcdir)/mono-addins.snk -ASSEMBLY_COMPILER_COMMAND = mcs -ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG +ASSEMBLY_COMPILER_COMMAND = @MCS@ +ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG -d:READ_ONLY -d:NET_3_5 ASSEMBLY = ../bin/Mono.Addins.CecilReflector.dll ASSEMBLY_NAME=Mono.Addins.CecilReflector COMPILE_TARGET = library @@ -14,263 +14,90 @@ FILES = \ AssemblyInfo.cs \ Mono.Addins.CecilReflector/Reflector.cs \ - Mono.Cecil/Mono.Cecil.Binary/BaseImageVisitor.cs \ - Mono.Cecil/Mono.Cecil.Binary/CLIHeader.cs \ - Mono.Cecil/Mono.Cecil.Binary/CopyImageVisitor.cs \ - Mono.Cecil/Mono.Cecil.Binary/DataDirectory.cs \ - Mono.Cecil/Mono.Cecil.Binary/DebugHeader.cs \ - Mono.Cecil/Mono.Cecil.Binary/DebugStoreType.cs \ - Mono.Cecil/Mono.Cecil.Binary/DOSHeader.cs \ - Mono.Cecil/Mono.Cecil.Binary/ExportTable.cs \ - Mono.Cecil/Mono.Cecil.Binary/IBinaryVisitable.cs \ - Mono.Cecil/Mono.Cecil.Binary/IBinaryVisitor.cs \ - Mono.Cecil/Mono.Cecil.Binary/IHeader.cs \ - Mono.Cecil/Mono.Cecil.Binary/Image.cs \ - Mono.Cecil/Mono.Cecil.Binary/ImageCharacteristics.cs \ - Mono.Cecil/Mono.Cecil.Binary/ImageFormatException.cs \ - Mono.Cecil/Mono.Cecil.Binary/ImageInitializer.cs \ - Mono.Cecil/Mono.Cecil.Binary/ImageReader.cs \ - Mono.Cecil/Mono.Cecil.Binary/ImageWriter.cs \ - Mono.Cecil/Mono.Cecil.Binary/Imports.cs \ - Mono.Cecil/Mono.Cecil.Binary/MemoryBinaryWriter.cs \ - Mono.Cecil/Mono.Cecil.Binary/PEFileHeader.cs \ - Mono.Cecil/Mono.Cecil.Binary/PEOptionalHeader.cs \ - Mono.Cecil/Mono.Cecil.Binary/ResourceDataEntry.cs \ - Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryEntry.cs \ - Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryString.cs \ - Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryTable.cs \ - Mono.Cecil/Mono.Cecil.Binary/ResourceNode.cs \ - Mono.Cecil/Mono.Cecil.Binary/ResourceReader.cs \ - Mono.Cecil/Mono.Cecil.Binary/ResourceWriter.cs \ - Mono.Cecil/Mono.Cecil.Binary/RuntimeImage.cs \ - Mono.Cecil/Mono.Cecil.Binary/RVA.cs \ - Mono.Cecil/Mono.Cecil.Binary/Section.cs \ - Mono.Cecil/Mono.Cecil.Binary/SectionCharacteristics.cs \ - Mono.Cecil/Mono.Cecil.Binary/SectionCollection.cs \ - Mono.Cecil/Mono.Cecil.Binary/SubSystem.cs \ - Mono.Cecil/Mono.Cecil.Cil/BaseCodeVisitor.cs \ - Mono.Cecil/Mono.Cecil.Cil/CilWorker.cs \ Mono.Cecil/Mono.Cecil.Cil/Code.cs \ Mono.Cecil/Mono.Cecil.Cil/CodeReader.cs \ Mono.Cecil/Mono.Cecil.Cil/CodeWriter.cs \ Mono.Cecil/Mono.Cecil.Cil/Document.cs \ - Mono.Cecil/Mono.Cecil.Cil/DocumentHashAlgorithm.cs \ - Mono.Cecil/Mono.Cecil.Cil/DocumentLanguage.cs \ - Mono.Cecil/Mono.Cecil.Cil/DocumentLanguageVendor.cs \ - Mono.Cecil/Mono.Cecil.Cil/DocumentType.cs \ Mono.Cecil/Mono.Cecil.Cil/ExceptionHandler.cs \ - Mono.Cecil/Mono.Cecil.Cil/ExceptionHandlerCollection.cs \ - Mono.Cecil/Mono.Cecil.Cil/ExceptionHandlerType.cs \ - Mono.Cecil/Mono.Cecil.Cil/FlowControl.cs \ - Mono.Cecil/Mono.Cecil.Cil/GuidAttribute.cs \ - Mono.Cecil/Mono.Cecil.Cil/ICodeVisitable.cs \ - Mono.Cecil/Mono.Cecil.Cil/ICodeVisitor.cs \ + Mono.Cecil/Mono.Cecil.Cil/ILProcessor.cs \ Mono.Cecil/Mono.Cecil.Cil/Instruction.cs \ - Mono.Cecil/Mono.Cecil.Cil/InstructionCollection.cs \ - Mono.Cecil/Mono.Cecil.Cil/IScopeProvider.cs \ - Mono.Cecil/Mono.Cecil.Cil/ISymbolReader.cs \ - Mono.Cecil/Mono.Cecil.Cil/ISymbolStoreFactory.cs \ - Mono.Cecil/Mono.Cecil.Cil/ISymbolWriter.cs \ - Mono.Cecil/Mono.Cecil.Cil/IVariableDefinitionProvider.cs \ Mono.Cecil/Mono.Cecil.Cil/MethodBody.cs \ - Mono.Cecil/Mono.Cecil.Cil/MethodDataSection.cs \ - Mono.Cecil/Mono.Cecil.Cil/MethodHeader.cs \ Mono.Cecil/Mono.Cecil.Cil/OpCode.cs \ Mono.Cecil/Mono.Cecil.Cil/OpCodes.cs \ - Mono.Cecil/Mono.Cecil.Cil/OpCodeType.cs \ - Mono.Cecil/Mono.Cecil.Cil/OperandType.cs \ - Mono.Cecil/Mono.Cecil.Cil/Scope.cs \ - Mono.Cecil/Mono.Cecil.Cil/ScopeCollection.cs \ Mono.Cecil/Mono.Cecil.Cil/SequencePoint.cs \ - Mono.Cecil/Mono.Cecil.Cil/StackBehaviour.cs \ - Mono.Cecil/Mono.Cecil.Cil/SymbolStoreHelper.cs \ + Mono.Cecil/Mono.Cecil.Cil/Symbols.cs \ Mono.Cecil/Mono.Cecil.Cil/VariableDefinition.cs \ - Mono.Cecil/Mono.Cecil.Cil/VariableDefinitionCollection.cs \ Mono.Cecil/Mono.Cecil.Cil/VariableReference.cs \ - Mono.Cecil/Mono.Cecil.Metadata/Assembly.cs \ - Mono.Cecil/Mono.Cecil.Metadata/AssemblyOS.cs \ - Mono.Cecil/Mono.Cecil.Metadata/AssemblyProcessor.cs \ - Mono.Cecil/Mono.Cecil.Metadata/AssemblyRef.cs \ - Mono.Cecil/Mono.Cecil.Metadata/AssemblyRefOS.cs \ - Mono.Cecil/Mono.Cecil.Metadata/AssemblyRefProcessor.cs \ - Mono.Cecil/Mono.Cecil.Metadata/BaseMetadataVisitor.cs \ Mono.Cecil/Mono.Cecil.Metadata/BlobHeap.cs \ - Mono.Cecil/Mono.Cecil.Metadata/ClassLayout.cs \ + Mono.Cecil/Mono.Cecil.Metadata/Buffers.cs \ Mono.Cecil/Mono.Cecil.Metadata/CodedIndex.cs \ - Mono.Cecil/Mono.Cecil.Metadata/Constant.cs \ - Mono.Cecil/Mono.Cecil.Metadata/CultureUtils.cs \ - Mono.Cecil/Mono.Cecil.Metadata/CustomAttribute.cs \ - Mono.Cecil/Mono.Cecil.Metadata/DeclSecurity.cs \ Mono.Cecil/Mono.Cecil.Metadata/ElementType.cs \ - Mono.Cecil/Mono.Cecil.Metadata/Event.cs \ - Mono.Cecil/Mono.Cecil.Metadata/EventMap.cs \ - Mono.Cecil/Mono.Cecil.Metadata/EventPtr.cs \ - Mono.Cecil/Mono.Cecil.Metadata/ExportedType.cs \ - Mono.Cecil/Mono.Cecil.Metadata/Field.cs \ - Mono.Cecil/Mono.Cecil.Metadata/FieldLayout.cs \ - Mono.Cecil/Mono.Cecil.Metadata/FieldMarshal.cs \ - Mono.Cecil/Mono.Cecil.Metadata/FieldPtr.cs \ - Mono.Cecil/Mono.Cecil.Metadata/FieldRVA.cs \ - Mono.Cecil/Mono.Cecil.Metadata/File.cs \ - Mono.Cecil/Mono.Cecil.Metadata/GenericParam.cs \ - Mono.Cecil/Mono.Cecil.Metadata/GenericParamConstraint.cs \ Mono.Cecil/Mono.Cecil.Metadata/GuidHeap.cs \ - Mono.Cecil/Mono.Cecil.Metadata/IMetadataRow.cs \ - Mono.Cecil/Mono.Cecil.Metadata/IMetadataTable.cs \ - Mono.Cecil/Mono.Cecil.Metadata/IMetadataVisitable.cs \ - Mono.Cecil/Mono.Cecil.Metadata/IMetadataVisitor.cs \ - Mono.Cecil/Mono.Cecil.Metadata/ImplMap.cs \ - Mono.Cecil/Mono.Cecil.Metadata/InterfaceImpl.cs \ - Mono.Cecil/Mono.Cecil.Metadata/ManifestResource.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MemberRef.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MetadataFormatException.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MetadataHeap.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MetadataInitializer.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MetadataReader.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MetadataRoot.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MetadataRowReader.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MetadataRowWriter.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MetadataStream.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MetadataStreamCollection.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MetadataTableReader.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MetadataTableWriter.cs \ + Mono.Cecil/Mono.Cecil.Metadata/Heap.cs \ Mono.Cecil/Mono.Cecil.Metadata/MetadataToken.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MetadataWriter.cs \ - Mono.Cecil/Mono.Cecil.Metadata/Method.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MethodImpl.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MethodPtr.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MethodSemantics.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MethodSpec.cs \ - Mono.Cecil/Mono.Cecil.Metadata/Module.cs \ - Mono.Cecil/Mono.Cecil.Metadata/ModuleRef.cs \ - Mono.Cecil/Mono.Cecil.Metadata/NestedClass.cs \ - Mono.Cecil/Mono.Cecil.Metadata/Param.cs \ - Mono.Cecil/Mono.Cecil.Metadata/ParamPtr.cs \ - Mono.Cecil/Mono.Cecil.Metadata/Property.cs \ - Mono.Cecil/Mono.Cecil.Metadata/PropertyMap.cs \ - Mono.Cecil/Mono.Cecil.Metadata/PropertyPtr.cs \ - Mono.Cecil/Mono.Cecil.Metadata/RowCollection.cs \ - Mono.Cecil/Mono.Cecil.Metadata/StandAloneSig.cs \ - Mono.Cecil/Mono.Cecil.Metadata/StringsHeap.cs \ - Mono.Cecil/Mono.Cecil.Metadata/TableCollection.cs \ - Mono.Cecil/Mono.Cecil.Metadata/TablesHeap.cs \ + Mono.Cecil/Mono.Cecil.Metadata/Row.cs \ + Mono.Cecil/Mono.Cecil.Metadata/StringHeap.cs \ + Mono.Cecil/Mono.Cecil.Metadata/TableHeap.cs \ Mono.Cecil/Mono.Cecil.Metadata/TokenType.cs \ - Mono.Cecil/Mono.Cecil.Metadata/TypeDef.cs \ - Mono.Cecil/Mono.Cecil.Metadata/TypeRef.cs \ - Mono.Cecil/Mono.Cecil.Metadata/TypeSpec.cs \ - Mono.Cecil/Mono.Cecil.Metadata/UserStringsHeap.cs \ + Mono.Cecil/Mono.Cecil.Metadata/UserStringHeap.cs \ Mono.Cecil/Mono.Cecil.Metadata/Utilities.cs \ - Mono.Cecil/Mono.Cecil.Signatures/Array.cs \ - Mono.Cecil/Mono.Cecil.Signatures/ArrayShape.cs \ - Mono.Cecil/Mono.Cecil.Signatures/BaseSignatureVisitor.cs \ - Mono.Cecil/Mono.Cecil.Signatures/Class.cs \ - Mono.Cecil/Mono.Cecil.Signatures/Constraint.cs \ - Mono.Cecil/Mono.Cecil.Signatures/CustomAttrib.cs \ - Mono.Cecil/Mono.Cecil.Signatures/CustomMod.cs \ - Mono.Cecil/Mono.Cecil.Signatures/FieldSig.cs \ - Mono.Cecil/Mono.Cecil.Signatures/FnPtr.cs \ - Mono.Cecil/Mono.Cecil.Signatures/GenericArg.cs \ - Mono.Cecil/Mono.Cecil.Signatures/GenericInst.cs \ - Mono.Cecil/Mono.Cecil.Signatures/GenericInstSignature.cs \ - Mono.Cecil/Mono.Cecil.Signatures/InputOutputItem.cs \ - Mono.Cecil/Mono.Cecil.Signatures/ISignatureVisitable.cs \ - Mono.Cecil/Mono.Cecil.Signatures/ISignatureVisitor.cs \ - Mono.Cecil/Mono.Cecil.Signatures/LocalVarSig.cs \ - Mono.Cecil/Mono.Cecil.Signatures/MarshalSig.cs \ - Mono.Cecil/Mono.Cecil.Signatures/MethodDefSig.cs \ - Mono.Cecil/Mono.Cecil.Signatures/MethodRefSig.cs \ - Mono.Cecil/Mono.Cecil.Signatures/MethodSig.cs \ - Mono.Cecil/Mono.Cecil.Signatures/MethodSpec.cs \ - Mono.Cecil/Mono.Cecil.Signatures/MVar.cs \ - Mono.Cecil/Mono.Cecil.Signatures/Param.cs \ - Mono.Cecil/Mono.Cecil.Signatures/PropertySig.cs \ - Mono.Cecil/Mono.Cecil.Signatures/Ptr.cs \ - Mono.Cecil/Mono.Cecil.Signatures/RetType.cs \ - Mono.Cecil/Mono.Cecil.Signatures/Signature.cs \ - Mono.Cecil/Mono.Cecil.Signatures/SignatureReader.cs \ - Mono.Cecil/Mono.Cecil.Signatures/SignatureWriter.cs \ - Mono.Cecil/Mono.Cecil.Signatures/SigType.cs \ - Mono.Cecil/Mono.Cecil.Signatures/SzArray.cs \ - Mono.Cecil/Mono.Cecil.Signatures/TypeSpec.cs \ - Mono.Cecil/Mono.Cecil.Signatures/ValueType.cs \ - Mono.Cecil/Mono.Cecil.Signatures/Var.cs \ - Mono.Cecil/Mono.Cecil/AggressiveReflectionReader.cs \ - Mono.Cecil/Mono.Cecil/ArrayDimension.cs \ - Mono.Cecil/Mono.Cecil/ArrayDimensionCollection.cs \ + Mono.Cecil/Mono.Cecil.PE/BinaryStreamReader.cs \ + Mono.Cecil/Mono.Cecil.PE/BinaryStreamWriter.cs \ + Mono.Cecil/Mono.Cecil.PE/ByteBuffer.cs \ + Mono.Cecil/Mono.Cecil.PE/ByteBufferEqualityComparer.cs \ + Mono.Cecil/Mono.Cecil.PE/DataDirectory.cs \ + Mono.Cecil/Mono.Cecil.PE/Image.cs \ + Mono.Cecil/Mono.Cecil.PE/ImageReader.cs \ + Mono.Cecil/Mono.Cecil.PE/ImageWriter.cs \ + Mono.Cecil/Mono.Cecil.PE/Section.cs \ + Mono.Cecil/Mono.Cecil.PE/TextMap.cs \ Mono.Cecil/Mono.Cecil/ArrayType.cs \ Mono.Cecil/Mono.Cecil/AssemblyDefinition.cs \ - Mono.Cecil/Mono.Cecil/AssemblyFactory.cs \ Mono.Cecil/Mono.Cecil/AssemblyFlags.cs \ Mono.Cecil/Mono.Cecil/AssemblyHashAlgorithm.cs \ - Mono.Cecil/Mono.Cecil/AssemblyKind.cs \ Mono.Cecil/Mono.Cecil/AssemblyLinkedResource.cs \ Mono.Cecil/Mono.Cecil/AssemblyNameDefinition.cs \ Mono.Cecil/Mono.Cecil/AssemblyNameReference.cs \ - Mono.Cecil/Mono.Cecil/AssemblyNameReferenceCollection.cs \ + Mono.Cecil/Mono.Cecil/AssemblyReader.cs \ + Mono.Cecil/Mono.Cecil/AssemblyWriter.cs \ Mono.Cecil/Mono.Cecil/BaseAssemblyResolver.cs \ - Mono.Cecil/Mono.Cecil/BaseReflectionReader.cs \ - Mono.Cecil/Mono.Cecil/BaseReflectionVisitor.cs \ - Mono.Cecil/Mono.Cecil/BaseStructureVisitor.cs \ Mono.Cecil/Mono.Cecil/CallSite.cs \ - Mono.Cecil/Mono.Cecil/CompactFrameworkCompatibility.cs \ - Mono.Cecil/Mono.Cecil/Constants.cs \ - Mono.Cecil/Mono.Cecil/ConstraintCollection.cs \ - Mono.Cecil/Mono.Cecil/ConstructorCollection.cs \ Mono.Cecil/Mono.Cecil/CustomAttribute.cs \ - Mono.Cecil/Mono.Cecil/CustomAttributeCollection.cs \ Mono.Cecil/Mono.Cecil/DefaultAssemblyResolver.cs \ - Mono.Cecil/Mono.Cecil/DefaultImporter.cs \ Mono.Cecil/Mono.Cecil/EmbeddedResource.cs \ Mono.Cecil/Mono.Cecil/EventAttributes.cs \ Mono.Cecil/Mono.Cecil/EventDefinition.cs \ - Mono.Cecil/Mono.Cecil/EventDefinitionCollection.cs \ Mono.Cecil/Mono.Cecil/EventReference.cs \ - Mono.Cecil/Mono.Cecil/ExternTypeCollection.cs \ + Mono.Cecil/Mono.Cecil/ExportedType.cs \ Mono.Cecil/Mono.Cecil/FieldAttributes.cs \ Mono.Cecil/Mono.Cecil/FieldDefinition.cs \ - Mono.Cecil/Mono.Cecil/FieldDefinitionCollection.cs \ Mono.Cecil/Mono.Cecil/FieldReference.cs \ Mono.Cecil/Mono.Cecil/FileAttributes.cs \ Mono.Cecil/Mono.Cecil/FunctionPointerType.cs \ - Mono.Cecil/Mono.Cecil/GenericArgumentCollection.cs \ - Mono.Cecil/Mono.Cecil/GenericContext.cs \ Mono.Cecil/Mono.Cecil/GenericInstanceMethod.cs \ Mono.Cecil/Mono.Cecil/GenericInstanceType.cs \ Mono.Cecil/Mono.Cecil/GenericParameter.cs \ Mono.Cecil/Mono.Cecil/GenericParameterAttributes.cs \ - Mono.Cecil/Mono.Cecil/GenericParameterCollection.cs \ - Mono.Cecil/Mono.Cecil/HashCodeProvider.cs \ - Mono.Cecil/Mono.Cecil/IAnnotationProvider.cs \ - Mono.Cecil/Mono.Cecil/IAssemblyResolver.cs \ + Mono.Cecil/Mono.Cecil/IConstantProvider.cs \ Mono.Cecil/Mono.Cecil/ICustomAttributeProvider.cs \ - Mono.Cecil/Mono.Cecil/IDetailReader.cs \ Mono.Cecil/Mono.Cecil/IGenericInstance.cs \ Mono.Cecil/Mono.Cecil/IGenericParameterProvider.cs \ - Mono.Cecil/Mono.Cecil/IHasConstant.cs \ - Mono.Cecil/Mono.Cecil/IHasMarshalSpec.cs \ - Mono.Cecil/Mono.Cecil/IHasSecurity.cs \ - Mono.Cecil/Mono.Cecil/IImporter.cs \ + Mono.Cecil/Mono.Cecil/IMarshalInfoProvider.cs \ Mono.Cecil/Mono.Cecil/IMemberDefinition.cs \ - Mono.Cecil/Mono.Cecil/IMemberReference.cs \ Mono.Cecil/Mono.Cecil/IMetadataScope.cs \ Mono.Cecil/Mono.Cecil/IMetadataTokenProvider.cs \ Mono.Cecil/Mono.Cecil/IMethodSignature.cs \ - Mono.Cecil/Mono.Cecil/ImportContext.cs \ - Mono.Cecil/Mono.Cecil/InterfaceCollection.cs \ - Mono.Cecil/Mono.Cecil/IReflectionStructureVisitable.cs \ - Mono.Cecil/Mono.Cecil/IReflectionStructureVisitor.cs \ - Mono.Cecil/Mono.Cecil/IReflectionVisitable.cs \ - Mono.Cecil/Mono.Cecil/IReflectionVisitor.cs \ - Mono.Cecil/Mono.Cecil/IRequireResolving.cs \ + Mono.Cecil/Mono.Cecil/Import.cs \ Mono.Cecil/Mono.Cecil/LinkedResource.cs \ Mono.Cecil/Mono.Cecil/ManifestResourceAttributes.cs \ - Mono.Cecil/Mono.Cecil/MarshalSpec.cs \ + Mono.Cecil/Mono.Cecil/MarshalInfo.cs \ + Mono.Cecil/Mono.Cecil/MemberDefinitionCollection.cs \ Mono.Cecil/Mono.Cecil/MemberReference.cs \ - Mono.Cecil/Mono.Cecil/MemberReferenceCollection.cs \ + Mono.Cecil/Mono.Cecil/MetadataResolver.cs \ + Mono.Cecil/Mono.Cecil/MetadataSystem.cs \ Mono.Cecil/Mono.Cecil/MethodAttributes.cs \ Mono.Cecil/Mono.Cecil/MethodCallingConvention.cs \ Mono.Cecil/Mono.Cecil/MethodDefinition.cs \ - Mono.Cecil/Mono.Cecil/MethodDefinitionCollection.cs \ Mono.Cecil/Mono.Cecil/MethodImplAttributes.cs \ Mono.Cecil/Mono.Cecil/MethodReference.cs \ Mono.Cecil/Mono.Cecil/MethodReturnType.cs \ @@ -278,13 +105,9 @@ Mono.Cecil/Mono.Cecil/MethodSpecification.cs \ Mono.Cecil/Mono.Cecil/Modifiers.cs \ Mono.Cecil/Mono.Cecil/ModuleDefinition.cs \ - Mono.Cecil/Mono.Cecil/ModuleDefinitionCollection.cs \ + Mono.Cecil/Mono.Cecil/ModuleKind.cs \ Mono.Cecil/Mono.Cecil/ModuleReference.cs \ - Mono.Cecil/Mono.Cecil/ModuleReferenceCollection.cs \ Mono.Cecil/Mono.Cecil/NativeType.cs \ - Mono.Cecil/Mono.Cecil/NestedTypeCollection.cs \ - Mono.Cecil/Mono.Cecil/NullReferenceImporter.cs \ - Mono.Cecil/Mono.Cecil/OverrideCollection.cs \ Mono.Cecil/Mono.Cecil/ParameterAttributes.cs \ Mono.Cecil/Mono.Cecil/ParameterDefinition.cs \ Mono.Cecil/Mono.Cecil/ParameterDefinitionCollection.cs \ @@ -295,35 +118,27 @@ Mono.Cecil/Mono.Cecil/PointerType.cs \ Mono.Cecil/Mono.Cecil/PropertyAttributes.cs \ Mono.Cecil/Mono.Cecil/PropertyDefinition.cs \ - Mono.Cecil/Mono.Cecil/PropertyDefinitionCollection.cs \ Mono.Cecil/Mono.Cecil/PropertyReference.cs \ Mono.Cecil/Mono.Cecil/ReferenceType.cs \ - Mono.Cecil/Mono.Cecil/ReflectionController.cs \ - Mono.Cecil/Mono.Cecil/ReflectionException.cs \ - Mono.Cecil/Mono.Cecil/ReflectionHelper.cs \ - Mono.Cecil/Mono.Cecil/ReflectionReader.cs \ - Mono.Cecil/Mono.Cecil/ReflectionWriter.cs \ Mono.Cecil/Mono.Cecil/Resource.cs \ - Mono.Cecil/Mono.Cecil/ResourceCollection.cs \ - Mono.Cecil/Mono.Cecil/SecurityAction.cs \ Mono.Cecil/Mono.Cecil/SecurityDeclaration.cs \ - Mono.Cecil/Mono.Cecil/SecurityDeclarationCollection.cs \ - Mono.Cecil/Mono.Cecil/SecurityDeclarationReader.cs \ Mono.Cecil/Mono.Cecil/SentinelType.cs \ - Mono.Cecil/Mono.Cecil/StructureReader.cs \ - Mono.Cecil/Mono.Cecil/StructureWriter.cs \ - Mono.Cecil/Mono.Cecil/TableComparers.cs \ Mono.Cecil/Mono.Cecil/TargetRuntime.cs \ Mono.Cecil/Mono.Cecil/TypeAttributes.cs \ Mono.Cecil/Mono.Cecil/TypeDefinition.cs \ Mono.Cecil/Mono.Cecil/TypeDefinitionCollection.cs \ + Mono.Cecil/Mono.Cecil/TypeParser.cs \ Mono.Cecil/Mono.Cecil/TypeReference.cs \ - Mono.Cecil/Mono.Cecil/TypeReferenceCollection.cs \ Mono.Cecil/Mono.Cecil/TypeSpecification.cs \ + Mono.Cecil/Mono.Cecil/TypeSystem.cs \ Mono.Cecil/Mono.Cecil/VariantType.cs \ - Mono.Cecil/Mono.Xml/MiniParser.cs \ - Mono.Cecil/Mono.Xml/SecurityParser.cs \ - Mono.Cecil/Mono.Xml/SmallXmlParser.cs + Mono.Cecil/Mono.Collections.Generic/Collection.cs \ + Mono.Cecil/Mono.Security.Cryptography/CryptoConvert.cs \ + Mono.Cecil/Mono.Security.Cryptography/CryptoService.cs \ + Mono.Cecil/Mono/Actions.cs \ + Mono.Cecil/Mono/Empty.cs \ + Mono.Cecil/Mono/Funcs.cs \ + Mono.Cecil/System.Runtime.CompilerServices/ExtensionAttribute.cs DATA_FILES = @@ -333,11 +148,13 @@ REFERENCES = \ -r:../bin/Mono.Addins.dll \ - -r:System + -r:System.Core DLL_REFERENCES = -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) $(POLICY_ASSEMBLIES) +$(ASSEMBLY).mdb: $(ASSEMBLY) + +$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) $(POLICY_ASSEMBLIES) mkdir -p $(dir $(ASSEMBLY)) $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Makefile.in mono-addins-0.6.1/Mono.Addins.CecilReflector/Makefile.in --- mono-addins-0.4/Mono.Addins.CecilReflector/Makefile.in 2008-11-06 19:52:35.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Makefile.in 2011-04-13 09:45:29.000000000 +0000 @@ -80,11 +80,15 @@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MCS = @MCS@ MKDIR_P = @MKDIR_P@ +MONODOC_CFLAGS = @MONODOC_CFLAGS@ +MONODOC_LIBS = @MONODOC_LIBS@ MONO_ADDINS_DEFAULT_LIB = @MONO_ADDINS_DEFAULT_LIB@ MONO_ADDINS_GUI_DEFAULT_LIB = @MONO_ADDINS_GUI_DEFAULT_LIB@ +MONO_ADDINS_MSBUILD_DEFAULT_LIB = @MONO_ADDINS_MSBUILD_DEFAULT_LIB@ MONO_ADDINS_SETUP_DEFAULT_LIB = @MONO_ADDINS_SETUP_DEFAULT_LIB@ MONO_NUNIT_CFLAGS = @MONO_NUNIT_CFLAGS@ MONO_NUNIT_LIBS = @MONO_NUNIT_LIBS@ @@ -137,11 +141,12 @@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ KEY_FILE = $(top_srcdir)/mono-addins.snk -ASSEMBLY_COMPILER_COMMAND = mcs -ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG +ASSEMBLY_COMPILER_COMMAND = @MCS@ +ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG -d:READ_ONLY -d:NET_3_5 ASSEMBLY = ../bin/Mono.Addins.CecilReflector.dll ASSEMBLY_NAME = Mono.Addins.CecilReflector COMPILE_TARGET = library @@ -150,263 +155,90 @@ FILES = \ AssemblyInfo.cs \ Mono.Addins.CecilReflector/Reflector.cs \ - Mono.Cecil/Mono.Cecil.Binary/BaseImageVisitor.cs \ - Mono.Cecil/Mono.Cecil.Binary/CLIHeader.cs \ - Mono.Cecil/Mono.Cecil.Binary/CopyImageVisitor.cs \ - Mono.Cecil/Mono.Cecil.Binary/DataDirectory.cs \ - Mono.Cecil/Mono.Cecil.Binary/DebugHeader.cs \ - Mono.Cecil/Mono.Cecil.Binary/DebugStoreType.cs \ - Mono.Cecil/Mono.Cecil.Binary/DOSHeader.cs \ - Mono.Cecil/Mono.Cecil.Binary/ExportTable.cs \ - Mono.Cecil/Mono.Cecil.Binary/IBinaryVisitable.cs \ - Mono.Cecil/Mono.Cecil.Binary/IBinaryVisitor.cs \ - Mono.Cecil/Mono.Cecil.Binary/IHeader.cs \ - Mono.Cecil/Mono.Cecil.Binary/Image.cs \ - Mono.Cecil/Mono.Cecil.Binary/ImageCharacteristics.cs \ - Mono.Cecil/Mono.Cecil.Binary/ImageFormatException.cs \ - Mono.Cecil/Mono.Cecil.Binary/ImageInitializer.cs \ - Mono.Cecil/Mono.Cecil.Binary/ImageReader.cs \ - Mono.Cecil/Mono.Cecil.Binary/ImageWriter.cs \ - Mono.Cecil/Mono.Cecil.Binary/Imports.cs \ - Mono.Cecil/Mono.Cecil.Binary/MemoryBinaryWriter.cs \ - Mono.Cecil/Mono.Cecil.Binary/PEFileHeader.cs \ - Mono.Cecil/Mono.Cecil.Binary/PEOptionalHeader.cs \ - Mono.Cecil/Mono.Cecil.Binary/ResourceDataEntry.cs \ - Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryEntry.cs \ - Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryString.cs \ - Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryTable.cs \ - Mono.Cecil/Mono.Cecil.Binary/ResourceNode.cs \ - Mono.Cecil/Mono.Cecil.Binary/ResourceReader.cs \ - Mono.Cecil/Mono.Cecil.Binary/ResourceWriter.cs \ - Mono.Cecil/Mono.Cecil.Binary/RuntimeImage.cs \ - Mono.Cecil/Mono.Cecil.Binary/RVA.cs \ - Mono.Cecil/Mono.Cecil.Binary/Section.cs \ - Mono.Cecil/Mono.Cecil.Binary/SectionCharacteristics.cs \ - Mono.Cecil/Mono.Cecil.Binary/SectionCollection.cs \ - Mono.Cecil/Mono.Cecil.Binary/SubSystem.cs \ - Mono.Cecil/Mono.Cecil.Cil/BaseCodeVisitor.cs \ - Mono.Cecil/Mono.Cecil.Cil/CilWorker.cs \ Mono.Cecil/Mono.Cecil.Cil/Code.cs \ Mono.Cecil/Mono.Cecil.Cil/CodeReader.cs \ Mono.Cecil/Mono.Cecil.Cil/CodeWriter.cs \ Mono.Cecil/Mono.Cecil.Cil/Document.cs \ - Mono.Cecil/Mono.Cecil.Cil/DocumentHashAlgorithm.cs \ - Mono.Cecil/Mono.Cecil.Cil/DocumentLanguage.cs \ - Mono.Cecil/Mono.Cecil.Cil/DocumentLanguageVendor.cs \ - Mono.Cecil/Mono.Cecil.Cil/DocumentType.cs \ Mono.Cecil/Mono.Cecil.Cil/ExceptionHandler.cs \ - Mono.Cecil/Mono.Cecil.Cil/ExceptionHandlerCollection.cs \ - Mono.Cecil/Mono.Cecil.Cil/ExceptionHandlerType.cs \ - Mono.Cecil/Mono.Cecil.Cil/FlowControl.cs \ - Mono.Cecil/Mono.Cecil.Cil/GuidAttribute.cs \ - Mono.Cecil/Mono.Cecil.Cil/ICodeVisitable.cs \ - Mono.Cecil/Mono.Cecil.Cil/ICodeVisitor.cs \ + Mono.Cecil/Mono.Cecil.Cil/ILProcessor.cs \ Mono.Cecil/Mono.Cecil.Cil/Instruction.cs \ - Mono.Cecil/Mono.Cecil.Cil/InstructionCollection.cs \ - Mono.Cecil/Mono.Cecil.Cil/IScopeProvider.cs \ - Mono.Cecil/Mono.Cecil.Cil/ISymbolReader.cs \ - Mono.Cecil/Mono.Cecil.Cil/ISymbolStoreFactory.cs \ - Mono.Cecil/Mono.Cecil.Cil/ISymbolWriter.cs \ - Mono.Cecil/Mono.Cecil.Cil/IVariableDefinitionProvider.cs \ Mono.Cecil/Mono.Cecil.Cil/MethodBody.cs \ - Mono.Cecil/Mono.Cecil.Cil/MethodDataSection.cs \ - Mono.Cecil/Mono.Cecil.Cil/MethodHeader.cs \ Mono.Cecil/Mono.Cecil.Cil/OpCode.cs \ Mono.Cecil/Mono.Cecil.Cil/OpCodes.cs \ - Mono.Cecil/Mono.Cecil.Cil/OpCodeType.cs \ - Mono.Cecil/Mono.Cecil.Cil/OperandType.cs \ - Mono.Cecil/Mono.Cecil.Cil/Scope.cs \ - Mono.Cecil/Mono.Cecil.Cil/ScopeCollection.cs \ Mono.Cecil/Mono.Cecil.Cil/SequencePoint.cs \ - Mono.Cecil/Mono.Cecil.Cil/StackBehaviour.cs \ - Mono.Cecil/Mono.Cecil.Cil/SymbolStoreHelper.cs \ + Mono.Cecil/Mono.Cecil.Cil/Symbols.cs \ Mono.Cecil/Mono.Cecil.Cil/VariableDefinition.cs \ - Mono.Cecil/Mono.Cecil.Cil/VariableDefinitionCollection.cs \ Mono.Cecil/Mono.Cecil.Cil/VariableReference.cs \ - Mono.Cecil/Mono.Cecil.Metadata/Assembly.cs \ - Mono.Cecil/Mono.Cecil.Metadata/AssemblyOS.cs \ - Mono.Cecil/Mono.Cecil.Metadata/AssemblyProcessor.cs \ - Mono.Cecil/Mono.Cecil.Metadata/AssemblyRef.cs \ - Mono.Cecil/Mono.Cecil.Metadata/AssemblyRefOS.cs \ - Mono.Cecil/Mono.Cecil.Metadata/AssemblyRefProcessor.cs \ - Mono.Cecil/Mono.Cecil.Metadata/BaseMetadataVisitor.cs \ Mono.Cecil/Mono.Cecil.Metadata/BlobHeap.cs \ - Mono.Cecil/Mono.Cecil.Metadata/ClassLayout.cs \ + Mono.Cecil/Mono.Cecil.Metadata/Buffers.cs \ Mono.Cecil/Mono.Cecil.Metadata/CodedIndex.cs \ - Mono.Cecil/Mono.Cecil.Metadata/Constant.cs \ - Mono.Cecil/Mono.Cecil.Metadata/CultureUtils.cs \ - Mono.Cecil/Mono.Cecil.Metadata/CustomAttribute.cs \ - Mono.Cecil/Mono.Cecil.Metadata/DeclSecurity.cs \ Mono.Cecil/Mono.Cecil.Metadata/ElementType.cs \ - Mono.Cecil/Mono.Cecil.Metadata/Event.cs \ - Mono.Cecil/Mono.Cecil.Metadata/EventMap.cs \ - Mono.Cecil/Mono.Cecil.Metadata/EventPtr.cs \ - Mono.Cecil/Mono.Cecil.Metadata/ExportedType.cs \ - Mono.Cecil/Mono.Cecil.Metadata/Field.cs \ - Mono.Cecil/Mono.Cecil.Metadata/FieldLayout.cs \ - Mono.Cecil/Mono.Cecil.Metadata/FieldMarshal.cs \ - Mono.Cecil/Mono.Cecil.Metadata/FieldPtr.cs \ - Mono.Cecil/Mono.Cecil.Metadata/FieldRVA.cs \ - Mono.Cecil/Mono.Cecil.Metadata/File.cs \ - Mono.Cecil/Mono.Cecil.Metadata/GenericParam.cs \ - Mono.Cecil/Mono.Cecil.Metadata/GenericParamConstraint.cs \ Mono.Cecil/Mono.Cecil.Metadata/GuidHeap.cs \ - Mono.Cecil/Mono.Cecil.Metadata/IMetadataRow.cs \ - Mono.Cecil/Mono.Cecil.Metadata/IMetadataTable.cs \ - Mono.Cecil/Mono.Cecil.Metadata/IMetadataVisitable.cs \ - Mono.Cecil/Mono.Cecil.Metadata/IMetadataVisitor.cs \ - Mono.Cecil/Mono.Cecil.Metadata/ImplMap.cs \ - Mono.Cecil/Mono.Cecil.Metadata/InterfaceImpl.cs \ - Mono.Cecil/Mono.Cecil.Metadata/ManifestResource.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MemberRef.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MetadataFormatException.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MetadataHeap.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MetadataInitializer.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MetadataReader.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MetadataRoot.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MetadataRowReader.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MetadataRowWriter.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MetadataStream.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MetadataStreamCollection.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MetadataTableReader.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MetadataTableWriter.cs \ + Mono.Cecil/Mono.Cecil.Metadata/Heap.cs \ Mono.Cecil/Mono.Cecil.Metadata/MetadataToken.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MetadataWriter.cs \ - Mono.Cecil/Mono.Cecil.Metadata/Method.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MethodImpl.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MethodPtr.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MethodSemantics.cs \ - Mono.Cecil/Mono.Cecil.Metadata/MethodSpec.cs \ - Mono.Cecil/Mono.Cecil.Metadata/Module.cs \ - Mono.Cecil/Mono.Cecil.Metadata/ModuleRef.cs \ - Mono.Cecil/Mono.Cecil.Metadata/NestedClass.cs \ - Mono.Cecil/Mono.Cecil.Metadata/Param.cs \ - Mono.Cecil/Mono.Cecil.Metadata/ParamPtr.cs \ - Mono.Cecil/Mono.Cecil.Metadata/Property.cs \ - Mono.Cecil/Mono.Cecil.Metadata/PropertyMap.cs \ - Mono.Cecil/Mono.Cecil.Metadata/PropertyPtr.cs \ - Mono.Cecil/Mono.Cecil.Metadata/RowCollection.cs \ - Mono.Cecil/Mono.Cecil.Metadata/StandAloneSig.cs \ - Mono.Cecil/Mono.Cecil.Metadata/StringsHeap.cs \ - Mono.Cecil/Mono.Cecil.Metadata/TableCollection.cs \ - Mono.Cecil/Mono.Cecil.Metadata/TablesHeap.cs \ + Mono.Cecil/Mono.Cecil.Metadata/Row.cs \ + Mono.Cecil/Mono.Cecil.Metadata/StringHeap.cs \ + Mono.Cecil/Mono.Cecil.Metadata/TableHeap.cs \ Mono.Cecil/Mono.Cecil.Metadata/TokenType.cs \ - Mono.Cecil/Mono.Cecil.Metadata/TypeDef.cs \ - Mono.Cecil/Mono.Cecil.Metadata/TypeRef.cs \ - Mono.Cecil/Mono.Cecil.Metadata/TypeSpec.cs \ - Mono.Cecil/Mono.Cecil.Metadata/UserStringsHeap.cs \ + Mono.Cecil/Mono.Cecil.Metadata/UserStringHeap.cs \ Mono.Cecil/Mono.Cecil.Metadata/Utilities.cs \ - Mono.Cecil/Mono.Cecil.Signatures/Array.cs \ - Mono.Cecil/Mono.Cecil.Signatures/ArrayShape.cs \ - Mono.Cecil/Mono.Cecil.Signatures/BaseSignatureVisitor.cs \ - Mono.Cecil/Mono.Cecil.Signatures/Class.cs \ - Mono.Cecil/Mono.Cecil.Signatures/Constraint.cs \ - Mono.Cecil/Mono.Cecil.Signatures/CustomAttrib.cs \ - Mono.Cecil/Mono.Cecil.Signatures/CustomMod.cs \ - Mono.Cecil/Mono.Cecil.Signatures/FieldSig.cs \ - Mono.Cecil/Mono.Cecil.Signatures/FnPtr.cs \ - Mono.Cecil/Mono.Cecil.Signatures/GenericArg.cs \ - Mono.Cecil/Mono.Cecil.Signatures/GenericInst.cs \ - Mono.Cecil/Mono.Cecil.Signatures/GenericInstSignature.cs \ - Mono.Cecil/Mono.Cecil.Signatures/InputOutputItem.cs \ - Mono.Cecil/Mono.Cecil.Signatures/ISignatureVisitable.cs \ - Mono.Cecil/Mono.Cecil.Signatures/ISignatureVisitor.cs \ - Mono.Cecil/Mono.Cecil.Signatures/LocalVarSig.cs \ - Mono.Cecil/Mono.Cecil.Signatures/MarshalSig.cs \ - Mono.Cecil/Mono.Cecil.Signatures/MethodDefSig.cs \ - Mono.Cecil/Mono.Cecil.Signatures/MethodRefSig.cs \ - Mono.Cecil/Mono.Cecil.Signatures/MethodSig.cs \ - Mono.Cecil/Mono.Cecil.Signatures/MethodSpec.cs \ - Mono.Cecil/Mono.Cecil.Signatures/MVar.cs \ - Mono.Cecil/Mono.Cecil.Signatures/Param.cs \ - Mono.Cecil/Mono.Cecil.Signatures/PropertySig.cs \ - Mono.Cecil/Mono.Cecil.Signatures/Ptr.cs \ - Mono.Cecil/Mono.Cecil.Signatures/RetType.cs \ - Mono.Cecil/Mono.Cecil.Signatures/Signature.cs \ - Mono.Cecil/Mono.Cecil.Signatures/SignatureReader.cs \ - Mono.Cecil/Mono.Cecil.Signatures/SignatureWriter.cs \ - Mono.Cecil/Mono.Cecil.Signatures/SigType.cs \ - Mono.Cecil/Mono.Cecil.Signatures/SzArray.cs \ - Mono.Cecil/Mono.Cecil.Signatures/TypeSpec.cs \ - Mono.Cecil/Mono.Cecil.Signatures/ValueType.cs \ - Mono.Cecil/Mono.Cecil.Signatures/Var.cs \ - Mono.Cecil/Mono.Cecil/AggressiveReflectionReader.cs \ - Mono.Cecil/Mono.Cecil/ArrayDimension.cs \ - Mono.Cecil/Mono.Cecil/ArrayDimensionCollection.cs \ + Mono.Cecil/Mono.Cecil.PE/BinaryStreamReader.cs \ + Mono.Cecil/Mono.Cecil.PE/BinaryStreamWriter.cs \ + Mono.Cecil/Mono.Cecil.PE/ByteBuffer.cs \ + Mono.Cecil/Mono.Cecil.PE/ByteBufferEqualityComparer.cs \ + Mono.Cecil/Mono.Cecil.PE/DataDirectory.cs \ + Mono.Cecil/Mono.Cecil.PE/Image.cs \ + Mono.Cecil/Mono.Cecil.PE/ImageReader.cs \ + Mono.Cecil/Mono.Cecil.PE/ImageWriter.cs \ + Mono.Cecil/Mono.Cecil.PE/Section.cs \ + Mono.Cecil/Mono.Cecil.PE/TextMap.cs \ Mono.Cecil/Mono.Cecil/ArrayType.cs \ Mono.Cecil/Mono.Cecil/AssemblyDefinition.cs \ - Mono.Cecil/Mono.Cecil/AssemblyFactory.cs \ Mono.Cecil/Mono.Cecil/AssemblyFlags.cs \ Mono.Cecil/Mono.Cecil/AssemblyHashAlgorithm.cs \ - Mono.Cecil/Mono.Cecil/AssemblyKind.cs \ Mono.Cecil/Mono.Cecil/AssemblyLinkedResource.cs \ Mono.Cecil/Mono.Cecil/AssemblyNameDefinition.cs \ Mono.Cecil/Mono.Cecil/AssemblyNameReference.cs \ - Mono.Cecil/Mono.Cecil/AssemblyNameReferenceCollection.cs \ + Mono.Cecil/Mono.Cecil/AssemblyReader.cs \ + Mono.Cecil/Mono.Cecil/AssemblyWriter.cs \ Mono.Cecil/Mono.Cecil/BaseAssemblyResolver.cs \ - Mono.Cecil/Mono.Cecil/BaseReflectionReader.cs \ - Mono.Cecil/Mono.Cecil/BaseReflectionVisitor.cs \ - Mono.Cecil/Mono.Cecil/BaseStructureVisitor.cs \ Mono.Cecil/Mono.Cecil/CallSite.cs \ - Mono.Cecil/Mono.Cecil/CompactFrameworkCompatibility.cs \ - Mono.Cecil/Mono.Cecil/Constants.cs \ - Mono.Cecil/Mono.Cecil/ConstraintCollection.cs \ - Mono.Cecil/Mono.Cecil/ConstructorCollection.cs \ Mono.Cecil/Mono.Cecil/CustomAttribute.cs \ - Mono.Cecil/Mono.Cecil/CustomAttributeCollection.cs \ Mono.Cecil/Mono.Cecil/DefaultAssemblyResolver.cs \ - Mono.Cecil/Mono.Cecil/DefaultImporter.cs \ Mono.Cecil/Mono.Cecil/EmbeddedResource.cs \ Mono.Cecil/Mono.Cecil/EventAttributes.cs \ Mono.Cecil/Mono.Cecil/EventDefinition.cs \ - Mono.Cecil/Mono.Cecil/EventDefinitionCollection.cs \ Mono.Cecil/Mono.Cecil/EventReference.cs \ - Mono.Cecil/Mono.Cecil/ExternTypeCollection.cs \ + Mono.Cecil/Mono.Cecil/ExportedType.cs \ Mono.Cecil/Mono.Cecil/FieldAttributes.cs \ Mono.Cecil/Mono.Cecil/FieldDefinition.cs \ - Mono.Cecil/Mono.Cecil/FieldDefinitionCollection.cs \ Mono.Cecil/Mono.Cecil/FieldReference.cs \ Mono.Cecil/Mono.Cecil/FileAttributes.cs \ Mono.Cecil/Mono.Cecil/FunctionPointerType.cs \ - Mono.Cecil/Mono.Cecil/GenericArgumentCollection.cs \ - Mono.Cecil/Mono.Cecil/GenericContext.cs \ Mono.Cecil/Mono.Cecil/GenericInstanceMethod.cs \ Mono.Cecil/Mono.Cecil/GenericInstanceType.cs \ Mono.Cecil/Mono.Cecil/GenericParameter.cs \ Mono.Cecil/Mono.Cecil/GenericParameterAttributes.cs \ - Mono.Cecil/Mono.Cecil/GenericParameterCollection.cs \ - Mono.Cecil/Mono.Cecil/HashCodeProvider.cs \ - Mono.Cecil/Mono.Cecil/IAnnotationProvider.cs \ - Mono.Cecil/Mono.Cecil/IAssemblyResolver.cs \ + Mono.Cecil/Mono.Cecil/IConstantProvider.cs \ Mono.Cecil/Mono.Cecil/ICustomAttributeProvider.cs \ - Mono.Cecil/Mono.Cecil/IDetailReader.cs \ Mono.Cecil/Mono.Cecil/IGenericInstance.cs \ Mono.Cecil/Mono.Cecil/IGenericParameterProvider.cs \ - Mono.Cecil/Mono.Cecil/IHasConstant.cs \ - Mono.Cecil/Mono.Cecil/IHasMarshalSpec.cs \ - Mono.Cecil/Mono.Cecil/IHasSecurity.cs \ - Mono.Cecil/Mono.Cecil/IImporter.cs \ + Mono.Cecil/Mono.Cecil/IMarshalInfoProvider.cs \ Mono.Cecil/Mono.Cecil/IMemberDefinition.cs \ - Mono.Cecil/Mono.Cecil/IMemberReference.cs \ Mono.Cecil/Mono.Cecil/IMetadataScope.cs \ Mono.Cecil/Mono.Cecil/IMetadataTokenProvider.cs \ Mono.Cecil/Mono.Cecil/IMethodSignature.cs \ - Mono.Cecil/Mono.Cecil/ImportContext.cs \ - Mono.Cecil/Mono.Cecil/InterfaceCollection.cs \ - Mono.Cecil/Mono.Cecil/IReflectionStructureVisitable.cs \ - Mono.Cecil/Mono.Cecil/IReflectionStructureVisitor.cs \ - Mono.Cecil/Mono.Cecil/IReflectionVisitable.cs \ - Mono.Cecil/Mono.Cecil/IReflectionVisitor.cs \ - Mono.Cecil/Mono.Cecil/IRequireResolving.cs \ + Mono.Cecil/Mono.Cecil/Import.cs \ Mono.Cecil/Mono.Cecil/LinkedResource.cs \ Mono.Cecil/Mono.Cecil/ManifestResourceAttributes.cs \ - Mono.Cecil/Mono.Cecil/MarshalSpec.cs \ + Mono.Cecil/Mono.Cecil/MarshalInfo.cs \ + Mono.Cecil/Mono.Cecil/MemberDefinitionCollection.cs \ Mono.Cecil/Mono.Cecil/MemberReference.cs \ - Mono.Cecil/Mono.Cecil/MemberReferenceCollection.cs \ + Mono.Cecil/Mono.Cecil/MetadataResolver.cs \ + Mono.Cecil/Mono.Cecil/MetadataSystem.cs \ Mono.Cecil/Mono.Cecil/MethodAttributes.cs \ Mono.Cecil/Mono.Cecil/MethodCallingConvention.cs \ Mono.Cecil/Mono.Cecil/MethodDefinition.cs \ - Mono.Cecil/Mono.Cecil/MethodDefinitionCollection.cs \ Mono.Cecil/Mono.Cecil/MethodImplAttributes.cs \ Mono.Cecil/Mono.Cecil/MethodReference.cs \ Mono.Cecil/Mono.Cecil/MethodReturnType.cs \ @@ -414,13 +246,9 @@ Mono.Cecil/Mono.Cecil/MethodSpecification.cs \ Mono.Cecil/Mono.Cecil/Modifiers.cs \ Mono.Cecil/Mono.Cecil/ModuleDefinition.cs \ - Mono.Cecil/Mono.Cecil/ModuleDefinitionCollection.cs \ + Mono.Cecil/Mono.Cecil/ModuleKind.cs \ Mono.Cecil/Mono.Cecil/ModuleReference.cs \ - Mono.Cecil/Mono.Cecil/ModuleReferenceCollection.cs \ Mono.Cecil/Mono.Cecil/NativeType.cs \ - Mono.Cecil/Mono.Cecil/NestedTypeCollection.cs \ - Mono.Cecil/Mono.Cecil/NullReferenceImporter.cs \ - Mono.Cecil/Mono.Cecil/OverrideCollection.cs \ Mono.Cecil/Mono.Cecil/ParameterAttributes.cs \ Mono.Cecil/Mono.Cecil/ParameterDefinition.cs \ Mono.Cecil/Mono.Cecil/ParameterDefinitionCollection.cs \ @@ -431,42 +259,34 @@ Mono.Cecil/Mono.Cecil/PointerType.cs \ Mono.Cecil/Mono.Cecil/PropertyAttributes.cs \ Mono.Cecil/Mono.Cecil/PropertyDefinition.cs \ - Mono.Cecil/Mono.Cecil/PropertyDefinitionCollection.cs \ Mono.Cecil/Mono.Cecil/PropertyReference.cs \ Mono.Cecil/Mono.Cecil/ReferenceType.cs \ - Mono.Cecil/Mono.Cecil/ReflectionController.cs \ - Mono.Cecil/Mono.Cecil/ReflectionException.cs \ - Mono.Cecil/Mono.Cecil/ReflectionHelper.cs \ - Mono.Cecil/Mono.Cecil/ReflectionReader.cs \ - Mono.Cecil/Mono.Cecil/ReflectionWriter.cs \ Mono.Cecil/Mono.Cecil/Resource.cs \ - Mono.Cecil/Mono.Cecil/ResourceCollection.cs \ - Mono.Cecil/Mono.Cecil/SecurityAction.cs \ Mono.Cecil/Mono.Cecil/SecurityDeclaration.cs \ - Mono.Cecil/Mono.Cecil/SecurityDeclarationCollection.cs \ - Mono.Cecil/Mono.Cecil/SecurityDeclarationReader.cs \ Mono.Cecil/Mono.Cecil/SentinelType.cs \ - Mono.Cecil/Mono.Cecil/StructureReader.cs \ - Mono.Cecil/Mono.Cecil/StructureWriter.cs \ - Mono.Cecil/Mono.Cecil/TableComparers.cs \ Mono.Cecil/Mono.Cecil/TargetRuntime.cs \ Mono.Cecil/Mono.Cecil/TypeAttributes.cs \ Mono.Cecil/Mono.Cecil/TypeDefinition.cs \ Mono.Cecil/Mono.Cecil/TypeDefinitionCollection.cs \ + Mono.Cecil/Mono.Cecil/TypeParser.cs \ Mono.Cecil/Mono.Cecil/TypeReference.cs \ - Mono.Cecil/Mono.Cecil/TypeReferenceCollection.cs \ Mono.Cecil/Mono.Cecil/TypeSpecification.cs \ + Mono.Cecil/Mono.Cecil/TypeSystem.cs \ Mono.Cecil/Mono.Cecil/VariantType.cs \ - Mono.Cecil/Mono.Xml/MiniParser.cs \ - Mono.Cecil/Mono.Xml/SecurityParser.cs \ - Mono.Cecil/Mono.Xml/SmallXmlParser.cs + Mono.Cecil/Mono.Collections.Generic/Collection.cs \ + Mono.Cecil/Mono.Security.Cryptography/CryptoConvert.cs \ + Mono.Cecil/Mono.Security.Cryptography/CryptoService.cs \ + Mono.Cecil/Mono/Actions.cs \ + Mono.Cecil/Mono/Empty.cs \ + Mono.Cecil/Mono/Funcs.cs \ + Mono.Cecil/System.Runtime.CompilerServices/ExtensionAttribute.cs DATA_FILES = RESOURCES = EXTRAS = REFERENCES = \ -r:../bin/Mono.Addins.dll \ - -r:System + -r:System.Core DLL_REFERENCES = build_sources = $(addprefix $(srcdir)/, $(FILES) $(GENERATED_FILES)) @@ -488,7 +308,7 @@ all: all-am .SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.include $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/Makefile.include $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -513,9 +333,9 @@ $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(top_srcdir)/configure: $(am__configure_deps) +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh install-binSCRIPTS: $(bin_SCRIPTS) @$(NORMAL_INSTALL) @@ -691,7 +511,9 @@ all: $(ASSEMBLY) -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) $(POLICY_ASSEMBLIES) +$(ASSEMBLY).mdb: $(ASSEMBLY) + +$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) $(POLICY_ASSEMBLIES) mkdir -p $(dir $(ASSEMBLY)) $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) @@ -703,12 +525,11 @@ mkdir -p $(dir $@) cp $< $@ -$(POLICY_ASSEMBLIES): $(top_builddir)/policy.config $(top_srcdir)/mono-addins.snk - @for i in $(POLICY_VERSIONS); do \ - echo "Creating policy.$$i.$(ASSEMBLY_NAME)"; \ - sed -e "s/@ASSEMBLY_NAME@/$(ASSEMBLY_NAME)/" -e "s/@POLICY@/$$i/" $(top_builddir)/policy.config > policy.$$i.config; \ - $(AL) -link:policy.$$i.config -out:policy.$$i.$(ASSEMBLY_NAME).dll -keyfile:$(top_srcdir)/mono-addins.snk; \ - done +policy.%.config: $(top_builddir)/policy.config + sed -e "s/@ASSEMBLY_NAME@/$(ASSEMBLY_NAME)/" -e "s/@POLICY@/$*/" $(top_builddir)/policy.config > $@ + +$(POLICY_ASSEMBLIES) : policy.%.$(ASSEMBLY_NAME).dll: policy.%.config $(top_srcdir)/mono-addins.snk + $(AL) -link:policy.$*.config -out:$@ -keyfile:$(top_srcdir)/mono-addins.snk gac-install: $(POLICY_ASSEMBLIES) $(GACUTIL) /i $(ASSEMBLY) /f $(GACUTIL_FLAGS) || exit 1; diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Addins.CecilReflector/Reflector.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Addins.CecilReflector/Reflector.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Addins.CecilReflector/Reflector.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Addins.CecilReflector/Reflector.cs 2011-04-13 09:00:29.000000000 +0000 @@ -31,6 +31,9 @@ using Mono.Addins; using Mono.Addins.Database; using Mono.Cecil; +using CustomAttribute = Mono.Cecil.CustomAttribute; +using MA = Mono.Addins.Database; +using System.Collections.Generic; namespace Mono.Addins.CecilReflector { @@ -76,14 +79,14 @@ object ob; - if (att.ConstructorParameters.Count > 0) { - object[] cargs = new object [att.ConstructorParameters.Count]; - att.ConstructorParameters.CopyTo (cargs, 0); + if (att.ConstructorArguments.Count > 0) { + object[] cargs = new object [att.ConstructorArguments.Count]; ArrayList typeParameters = null; // Constructor parameters of type System.Type can't be set because types from the assembly // can't be loaded. The parameter value will be set later using a type name property. for (int n=0; n GetRawCustomAttributes (object obj, Type type, bool inherit) + { + List atts = new List (); + Mono.Cecil.ICustomAttributeProvider aprov = obj as Mono.Cecil.ICustomAttributeProvider; + if (aprov == null) + return atts; + + foreach (CustomAttribute att in aprov.CustomAttributes) { + MA.CustomAttribute catt = ConvertToRawAttribute (att, type.FullName); + if (catt != null) + atts.Add (catt); + } + if (inherit && (obj is TypeDefinition)) { + TypeDefinition td = (TypeDefinition) obj; + if (td.BaseType != null && td.BaseType.FullName != "System.Object") { + TypeDefinition bt = FindTypeDefinition (td.Module.Assembly, td.BaseType); + if (bt != null) + atts.AddRange (GetRawCustomAttributes (bt, type, true)); + } + } + return atts; + } + + MA.CustomAttribute ConvertToRawAttribute (CustomAttribute att, string expectedType) + { + TypeDefinition attType = FindTypeDefinition (att.Constructor.DeclaringType.Module.Assembly, att.Constructor.DeclaringType); + + if (attType == null || !TypeIsAssignableFrom (expectedType, attType)) + return null; + + MA.CustomAttribute mat = new MA.CustomAttribute (); + mat.TypeName = att.Constructor.DeclaringType.FullName; + + if (att.ConstructorArguments.Count > 0) { + var arguments = att.ConstructorArguments; + + MethodReference constructor = FindConstructor (att); + if (constructor == null) + throw new InvalidOperationException ("Custom attribute constructor not found"); + + for (int n=0; n (ICollection members, string name) where TMember : class, IMemberDefinition + { + foreach (var member in members) + if (member.Name == name) + return member; + + return null; + } + + IEnumerable GetInheritanceChain (TypeDefinition td) + { + yield return td; + while (td != null && td.BaseType != null && td.BaseType.FullName != "System.Object") { + td = FindTypeDefinition (td.Module.Assembly, td.BaseType); + if (td != null) + yield return td; + } + } + + MethodReference FindConstructor (CustomAttribute att) + { + // The constructor provided by CustomAttribute.Constructor is lacking some information, such as the parameter + // name and custom attributes. Since we need the full info, we have to look it up in the declaring type. + + TypeDefinition atd = FindTypeDefinition (att.Constructor.DeclaringType.Module.Assembly, att.Constructor.DeclaringType); + foreach (MethodReference met in atd.Methods) { + if (met.Name != ".ctor") + continue; + + if (met.Parameters.Count == att.Constructor.Parameters.Count) { + for (int n = met.Parameters.Count - 1; n >= 0; n--) { + if (met.Parameters[n].ParameterType.FullName != att.Constructor.Parameters[n].ParameterType.FullName) + break; + if (n == 0) + return met; + } + } + } + return null; } public object LoadAssembly (string file) @@ -145,11 +286,33 @@ AssemblyDefinition adef = (AssemblyDefinition) cachedAssemblies [file]; if (adef != null) return adef; - adef = AssemblyFactory.GetAssembly (file); + adef = AssemblyDefinition.ReadAssembly (file); if (adef != null && cache) cachedAssemblies [file] = adef; return adef; } + + public string[] GetResourceNames (object asm) + { + AssemblyDefinition adef = (AssemblyDefinition) asm; + List names = new List (adef.MainModule.Resources.Count); + foreach (Resource res in adef.MainModule.Resources) { + if (res is EmbeddedResource) + names.Add (res.Name); + } + return names.ToArray (); + } + + public System.IO.Stream GetResourceStream (object asm, string resourceName) + { + AssemblyDefinition adef = (AssemblyDefinition) asm; + foreach (Resource res in adef.MainModule.Resources) { + EmbeddedResource r = res as EmbeddedResource; + if (r != null && r.Name == resourceName) + return r.GetResourceStream (); + } + throw new InvalidOperationException ("Resource not found: " + resourceName); + } public object LoadAssemblyFromReference (object asmReference) { @@ -163,10 +326,7 @@ public System.Collections.IEnumerable GetAssemblyTypes (object asm) { - TypeDefinitionCollection types = ((AssemblyDefinition)asm).MainModule.Types; - foreach (IAnnotationProvider t in types) - t.Annotations [typeof(AssemblyDefinition)] = asm; - return types; + return ((AssemblyDefinition)asm).MainModule.Types; } public System.Collections.IEnumerable GetAssemblyReferences (object asm) @@ -176,12 +336,19 @@ public object GetType (object asm, string typeName) { - IAnnotationProvider t = ((AssemblyDefinition)asm).MainModule.Types [typeName]; + if (typeName.IndexOf ('`') != -1) { + foreach (TypeDefinition td in ((AssemblyDefinition)asm).MainModule.Types) { + if (td.FullName == typeName) { + return td; + } + } + } + TypeDefinition t = ((AssemblyDefinition)asm).MainModule.GetType (typeName); if (t != null) { - t.Annotations [typeof(AssemblyDefinition)] = asm; return t; - } else + } else { return null; + } } public object GetCustomAttribute (object obj, Type type, bool inherit) @@ -210,8 +377,7 @@ AssemblyDefinition GetAssemblyDefinition (TypeDefinition t) { - IAnnotationProvider aprov = (IAnnotationProvider) t; - return (AssemblyDefinition) aprov.Annotations [typeof(AssemblyDefinition)]; + return t.Module.Assembly; } public System.Collections.IEnumerable GetBaseTypeFullNameList (object type) @@ -256,6 +422,13 @@ TypeDefinition td = GetType (referencer, name) as TypeDefinition; if (td != null) return td; + int i = name.IndexOf ('<'); + if (i != -1) { + name = name.Substring (0, i); + td = GetType (referencer, name) as TypeDefinition; + if (td != null) + return td; + } foreach (AssemblyNameReference aref in referencer.MainModule.AssemblyReferences) { string loc = locator.GetAssemblyLocation (aref.FullName); @@ -278,6 +451,14 @@ return false; } + public bool TypeIsAssignableFrom (string baseTypeName, object type) + { + foreach (string bt in GetBaseTypeFullNameList (type)) + if (bt == baseTypeName) + return true; + return false; + } + public IEnumerable GetFields (object type) { return ((TypeDefinition)type).Fields; @@ -292,6 +473,5 @@ { return ((FieldDefinition)field).FieldType.FullName; } - } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono/Actions.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono/Actions.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono/Actions.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono/Actions.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,38 @@ +// +// Actions.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +#if !NET_3_5 && !NET_4_0 + +namespace Mono { + //delegate void Action (); + //delegate void Action (T1 arg1, T2 arg2); + //delegate void Action (T1 arg1, T2 arg2, T3 arg3); + //delegate void Action (T1 arg1, T2 arg2, T3 arg3, T4 arg4); +} + +#endif diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono/Empty.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono/Empty.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono/Empty.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono/Empty.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,55 @@ +// +// Empty.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Mono { + + static class Empty { + + public static readonly T [] Array = new T [0]; + } +} + +namespace Mono.Cecil { + + static partial class Mixin { + + public static bool IsNullOrEmpty (this T [] self) + { + return self == null || self.Length == 0; + } + + public static bool IsNullOrEmpty (this ICollection self) + { + return self == null || self.Count == 0; + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono/Funcs.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono/Funcs.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono/Funcs.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono/Funcs.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,39 @@ +// +// Funcs.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +#if !NET_3_5 && !NET_4_0 + +namespace Mono { + delegate TResult Func (); + delegate TResult Func (T arg1); + delegate TResult Func (T1 arg1, T2 arg2); + //delegate TResult Func (T1 arg1, T2 arg2, T3 arg3); + //delegate TResult Func (T1 arg1, T2 arg2, T3 arg3, T4 arg4); +} + +#endif diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AggressiveReflectionReader.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AggressiveReflectionReader.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AggressiveReflectionReader.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AggressiveReflectionReader.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,452 +0,0 @@ -// -// AggressiveRefletionReader.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - - using Mono.Cecil.Metadata; - using Mono.Cecil.Signatures; - - internal sealed class AggressiveReflectionReader : ReflectionReader { - - public AggressiveReflectionReader (ModuleDefinition module) : base (module) - { - } - - public override void VisitTypeDefinitionCollection (TypeDefinitionCollection types) - { - base.VisitTypeDefinitionCollection (types); - - ReadGenericParameterConstraints (); - ReadClassLayoutInfos (); - ReadFieldLayoutInfos (); - ReadPInvokeInfos (); - ReadProperties (); - ReadEvents (); - ReadSemantics (); - ReadInterfaces (); - ReadOverrides (); - ReadSecurityDeclarations (); - ReadCustomAttributes (); - ReadConstants (); - ReadExternTypes (); - ReadMarshalSpecs (); - ReadInitialValues (); - - m_events = null; - m_properties = null; - m_parameters = null; - } - - void ReadGenericParameterConstraints () - { - if (!m_tHeap.HasTable (GenericParamConstraintTable.RId)) - return; - - GenericParamConstraintTable gpcTable = m_tableReader.GetGenericParamConstraintTable (); - for (int i = 0; i < gpcTable.Rows.Count; i++) { - GenericParamConstraintRow gpcRow = gpcTable [i]; - GenericParameter gp = GetGenericParameterAt (gpcRow.Owner); - - gp.Constraints.Add (GetTypeDefOrRef (gpcRow.Constraint, new GenericContext (gp.Owner))); - } - } - - void ReadClassLayoutInfos () - { - if (!m_tHeap.HasTable (ClassLayoutTable.RId)) - return; - - ClassLayoutTable clTable = m_tableReader.GetClassLayoutTable (); - for (int i = 0; i < clTable.Rows.Count; i++) { - ClassLayoutRow clRow = clTable [i]; - TypeDefinition type = GetTypeDefAt (clRow.Parent); - type.PackingSize = clRow.PackingSize; - type.ClassSize = clRow.ClassSize; - } - } - - void ReadFieldLayoutInfos () - { - if (!m_tHeap.HasTable (FieldLayoutTable.RId)) - return; - - FieldLayoutTable flTable = m_tableReader.GetFieldLayoutTable (); - for (int i = 0; i < flTable.Rows.Count; i++) { - FieldLayoutRow flRow = flTable [i]; - FieldDefinition field = GetFieldDefAt (flRow.Field); - field.Offset = flRow.Offset; - } - } - - void ReadPInvokeInfos () - { - if (!m_tHeap.HasTable (ImplMapTable.RId)) - return; - - ImplMapTable imTable = m_tableReader.GetImplMapTable (); - for (int i = 0; i < imTable.Rows.Count; i++) { - ImplMapRow imRow = imTable [i]; - if (imRow.MemberForwarded.TokenType == TokenType.Method) { // should always be true - MethodDefinition meth = GetMethodDefAt (imRow.MemberForwarded.RID); - meth.PInvokeInfo = new PInvokeInfo ( - meth, imRow.MappingFlags, MetadataRoot.Streams.StringsHeap [imRow.ImportName], - Module.ModuleReferences [(int) imRow.ImportScope - 1]); - } - } - } - - void ReadProperties () - { - if (!m_tHeap.HasTable (PropertyTable.RId)) - return; - - PropertyTable propsTable = m_tableReader.GetPropertyTable (); - PropertyMapTable pmapTable = m_tableReader.GetPropertyMapTable (); - m_properties = new PropertyDefinition [propsTable.Rows.Count]; - for (int i = 0; i < pmapTable.Rows.Count; i++) { - PropertyMapRow pmapRow = pmapTable [i]; - if (pmapRow.Parent == 0) - continue; - - TypeDefinition owner = GetTypeDefAt (pmapRow.Parent); - - GenericContext context = new GenericContext (owner); - - int start = (int) pmapRow.PropertyList, last = propsTable.Rows.Count + 1, end; - if (i < pmapTable.Rows.Count - 1) - end = (int) pmapTable [i + 1].PropertyList; - else - end = last; - - if (end > last) - end = last; - - for (int j = start; j < end; j++) { - PropertyRow prow = propsTable [j - 1]; - PropertySig psig = m_sigReader.GetPropSig (prow.Type); - PropertyDefinition pdef = new PropertyDefinition ( - m_root.Streams.StringsHeap [prow.Name], - GetTypeRefFromSig (psig.Type, context), - prow.Flags); - pdef.MetadataToken = MetadataToken.FromMetadataRow (TokenType.Property, j - 1); - - pdef.PropertyType = GetModifierType (psig.CustomMods, pdef.PropertyType); - - if (!IsDeleted (pdef)) - owner.Properties.Add (pdef); - - m_properties [j - 1] = pdef; - } - } - } - - void ReadEvents () - { - if (!m_tHeap.HasTable (EventTable.RId)) - return; - - EventTable evtTable = m_tableReader.GetEventTable (); - EventMapTable emapTable = m_tableReader.GetEventMapTable (); - m_events = new EventDefinition [evtTable.Rows.Count]; - for (int i = 0; i < emapTable.Rows.Count; i++) { - EventMapRow emapRow = emapTable [i]; - if (emapRow.Parent == 0) - continue; - - TypeDefinition owner = GetTypeDefAt (emapRow.Parent); - GenericContext context = new GenericContext (owner); - - int start = (int) emapRow.EventList, last = evtTable.Rows.Count + 1, end; - if (i < (emapTable.Rows.Count - 1)) - end = (int) emapTable [i + 1].EventList; - else - end = last; - - if (end > last) - end = last; - - for (int j = start; j < end; j++) { - EventRow erow = evtTable [j - 1]; - EventDefinition edef = new EventDefinition ( - m_root.Streams.StringsHeap [erow.Name], - GetTypeDefOrRef (erow.EventType, context), erow.EventFlags); - edef.MetadataToken = MetadataToken.FromMetadataRow (TokenType.Event, j - 1); - - if (!IsDeleted (edef)) - owner.Events.Add (edef); - - m_events [j - 1] = edef; - } - } - } - - void ReadSemantics () - { - if (!m_tHeap.HasTable (MethodSemanticsTable.RId)) - return; - - MethodSemanticsTable semTable = m_tableReader.GetMethodSemanticsTable (); - for (int i = 0; i < semTable.Rows.Count; i++) { - MethodSemanticsRow semRow = semTable [i]; - MethodDefinition semMeth = GetMethodDefAt (semRow.Method); - semMeth.SemanticsAttributes = semRow.Semantics; - switch (semRow.Association.TokenType) { - case TokenType.Event : - EventDefinition evt = GetEventDefAt (semRow.Association.RID); - if ((semRow.Semantics & MethodSemanticsAttributes.AddOn) != 0) - evt.AddMethod = semMeth; - else if ((semRow.Semantics & MethodSemanticsAttributes.Fire) != 0) - evt.InvokeMethod = semMeth; - else if ((semRow.Semantics & MethodSemanticsAttributes.RemoveOn) != 0) - evt.RemoveMethod = semMeth; - break; - case TokenType.Property : - PropertyDefinition prop = GetPropertyDefAt (semRow.Association.RID); - if ((semRow.Semantics & MethodSemanticsAttributes.Getter) != 0) - prop.GetMethod = semMeth; - else if ((semRow.Semantics & MethodSemanticsAttributes.Setter) != 0) - prop.SetMethod = semMeth; - break; - } - } - } - - void ReadInterfaces () - { - if (!m_tHeap.HasTable (InterfaceImplTable.RId)) - return; - - InterfaceImplTable intfsTable = m_tableReader.GetInterfaceImplTable (); - for (int i = 0; i < intfsTable.Rows.Count; i++) { - InterfaceImplRow intfsRow = intfsTable [i]; - TypeDefinition owner = GetTypeDefAt (intfsRow.Class); - owner.Interfaces.Add (GetTypeDefOrRef (intfsRow.Interface, new GenericContext (owner))); - } - } - - void ReadOverrides () - { - if (!m_tHeap.HasTable (MethodImplTable.RId)) - return; - - MethodImplTable implTable = m_tableReader.GetMethodImplTable (); - for (int i = 0; i < implTable.Rows.Count; i++) { - MethodImplRow implRow = implTable [i]; - if (implRow.MethodBody.TokenType == TokenType.Method) { - MethodDefinition owner = GetMethodDefAt (implRow.MethodBody.RID); - switch (implRow.MethodDeclaration.TokenType) { - case TokenType.Method : - owner.Overrides.Add ( - GetMethodDefAt (implRow.MethodDeclaration.RID)); - break; - case TokenType.MemberRef : - owner.Overrides.Add ( - (MethodReference) GetMemberRefAt ( - implRow.MethodDeclaration.RID, new GenericContext (owner))); - break; - } - } - } - } - - void ReadSecurityDeclarations () - { - if (!m_tHeap.HasTable (DeclSecurityTable.RId)) - return; - - DeclSecurityTable dsTable = m_tableReader.GetDeclSecurityTable (); - for (int i = 0; i < dsTable.Rows.Count; i++) { - DeclSecurityRow dsRow = dsTable [i]; - SecurityDeclaration dec = BuildSecurityDeclaration (dsRow); - - if (dsRow.Parent.RID == 0) - continue; - - IHasSecurity owner = null; - switch (dsRow.Parent.TokenType) { - case TokenType.Assembly : - owner = this.Module.Assembly; - break; - case TokenType.TypeDef : - owner = GetTypeDefAt (dsRow.Parent.RID); - break; - case TokenType.Method : - owner = GetMethodDefAt (dsRow.Parent.RID); - break; - } - - owner.SecurityDeclarations.Add (dec); - } - } - - void ReadCustomAttributes () - { - if (!m_tHeap.HasTable (CustomAttributeTable.RId)) - return; - - CustomAttributeTable caTable = m_tableReader.GetCustomAttributeTable (); - for (int i = 0; i < caTable.Rows.Count; i++) { - CustomAttributeRow caRow = caTable [i]; - MethodReference ctor; - - if (caRow.Type.RID == 0) - continue; - - if (caRow.Type.TokenType == TokenType.Method) - ctor = GetMethodDefAt (caRow.Type.RID); - else - ctor = GetMemberRefAt (caRow.Type.RID, new GenericContext ()) as MethodReference; - - CustomAttrib ca = m_sigReader.GetCustomAttrib (caRow.Value, ctor); - CustomAttribute cattr; - if (!ca.Read) { - cattr = new CustomAttribute (ctor); - cattr.Resolved = false; - cattr.Blob = m_root.Streams.BlobHeap.Read (caRow.Value); - } else - cattr = BuildCustomAttribute (ctor, ca); - - if (caRow.Parent.RID == 0) - continue; - - ICustomAttributeProvider owner = null; - switch (caRow.Parent.TokenType) { - case TokenType.Assembly : - owner = this.Module.Assembly; - break; - case TokenType.Module : - owner = this.Module; - break; - case TokenType.TypeDef : - owner = GetTypeDefAt (caRow.Parent.RID); - break; - case TokenType.TypeRef : - owner = GetTypeRefAt (caRow.Parent.RID); - break; - case TokenType.Field : - owner = GetFieldDefAt (caRow.Parent.RID); - break; - case TokenType.Method : - owner = GetMethodDefAt (caRow.Parent.RID); - break; - case TokenType.Property : - owner = GetPropertyDefAt (caRow.Parent.RID); - break; - case TokenType.Event : - owner = GetEventDefAt (caRow.Parent.RID); - break; - case TokenType.Param : - owner = GetParamDefAt (caRow.Parent.RID); - break; - case TokenType.GenericParam : - owner = GetGenericParameterAt (caRow.Parent.RID); - break; - default : - //TODO: support other ? - break; - } - - if (owner != null) - owner.CustomAttributes.Add (cattr); - } - } - - void ReadConstants () - { - if (!m_tHeap.HasTable (ConstantTable.RId)) - return; - - ConstantTable csTable = m_tableReader.GetConstantTable (); - for (int i = 0; i < csTable.Rows.Count; i++) { - ConstantRow csRow = csTable [i]; - - object constant = GetConstant (csRow.Value, csRow.Type); - - IHasConstant owner = null; - switch (csRow.Parent.TokenType) { - case TokenType.Field : - owner = GetFieldDefAt (csRow.Parent.RID); - break; - case TokenType.Property : - owner = GetPropertyDefAt (csRow.Parent.RID); - break; - case TokenType.Param : - owner = GetParamDefAt (csRow.Parent.RID); - break; - } - - owner.Constant = constant; - } - } - - void ReadExternTypes () - { - base.VisitExternTypeCollection (Module.ExternTypes); - } - - void ReadMarshalSpecs () - { - if (!m_tHeap.HasTable (FieldMarshalTable.RId)) - return; - - FieldMarshalTable fmTable = m_tableReader.GetFieldMarshalTable (); - for (int i = 0; i < fmTable.Rows.Count; i++) { - FieldMarshalRow fmRow = fmTable [i]; - - IHasMarshalSpec owner = null; - switch (fmRow.Parent.TokenType) { - case TokenType.Field: - owner = GetFieldDefAt (fmRow.Parent.RID); - break; - case TokenType.Param: - owner = GetParamDefAt (fmRow.Parent.RID); - break; - } - - owner.MarshalSpec = BuildMarshalDesc ( - m_sigReader.GetMarshalSig (fmRow.NativeType), owner); - } - } - - void ReadInitialValues () - { - if (!m_tHeap.HasTable (FieldRVATable.RId)) - return; - - FieldRVATable frTable = m_tableReader.GetFieldRVATable (); - for (int i = 0; i < frTable.Rows.Count; i++) { - FieldRVARow frRow = frTable [i]; - FieldDefinition field = GetFieldDefAt (frRow.Field); - field.RVA = frRow.RVA; - SetInitialValue (field); - } - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ArrayDimensionCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ArrayDimensionCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ArrayDimensionCollection.cs 2008-11-06 19:52:04.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ArrayDimensionCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -// -// ArrayDimensionCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Wed Sep 27 12:46:53 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.Collections; - - using Mono.Cecil.Cil; - - public sealed class ArrayDimensionCollection : CollectionBase { - - ArrayType m_container; - - public ArrayDimension this [int index] { - get { return List [index] as ArrayDimension; } - set { List [index] = value; } - } - - public ArrayType Container { - get { return m_container; } - } - - public ArrayDimensionCollection (ArrayType container) - { - m_container = container; - } - - public void Add (ArrayDimension value) - { - List.Add (value); - } - - public bool Contains (ArrayDimension value) - { - return List.Contains (value); - } - - public int IndexOf (ArrayDimension value) - { - return List.IndexOf (value); - } - - public void Insert (int index, ArrayDimension value) - { - List.Insert (index, value); - } - - public void Remove (ArrayDimension value) - { - List.Remove (value); - } - - protected override void OnValidate (object o) - { - if (! (o is ArrayDimension)) - throw new ArgumentException ("Must be of type " + typeof (ArrayDimension).FullName); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ArrayDimension.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ArrayDimension.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ArrayDimension.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ArrayDimension.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -// -// ArrayDimension.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - public sealed class ArrayDimension { - - int m_lowerBound; - int m_upperBound; - - public int LowerBound { - get { return m_lowerBound; } - set { m_lowerBound = value; } - } - - public int UpperBound { - get { return m_upperBound; } - set { m_upperBound = value; } - } - - public ArrayDimension (int lb, int ub) - { - m_lowerBound = lb; - m_upperBound = ub; - } - - public override string ToString () - { - if (m_upperBound == 0) - return string.Empty; - return string.Concat (m_lowerBound, "...", m_upperBound); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ArrayType.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ArrayType.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ArrayType.cs 2008-11-06 19:52:04.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ArrayType.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,80 +26,134 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System; +using System.Text; +using Mono.Collections.Generic; +using MD = Mono.Cecil.Metadata; + namespace Mono.Cecil { - using System; - using System.Text; + public struct ArrayDimension { + + int? lower_bound; + int? upper_bound; - using Mono.Cecil.Signatures; + public int? LowerBound { + get { return lower_bound; } + set { lower_bound = value; } + } + + public int? UpperBound { + get { return upper_bound; } + set { upper_bound = value; } + } + + public bool IsSized { + get { return lower_bound.HasValue || upper_bound.HasValue; } + } + + public ArrayDimension (int? lowerBound, int? upperBound) + { + this.lower_bound = lowerBound; + this.upper_bound = upperBound; + } + + public override string ToString () + { + return !IsSized + ? string.Empty + : lower_bound + "..." + upper_bound; + } + } public sealed class ArrayType : TypeSpecification { - private ArrayDimensionCollection m_dimensions; + Collection dimensions; + + public Collection Dimensions { + get { + if (dimensions != null) + return dimensions; - public ArrayDimensionCollection Dimensions { - get { return m_dimensions; } + dimensions = new Collection (); + dimensions.Add (new ArrayDimension ()); + return dimensions; + } } public int Rank { - get { return m_dimensions.Count; } + get { return dimensions == null ? 1 : dimensions.Count; } } - public bool IsSizedArray { + public bool IsVector { get { - if (this.Rank != 1) + if (dimensions == null) + return true; + + if (dimensions.Count > 1) return false; - ArrayDimension dim = m_dimensions [0]; - return dim.UpperBound == 0; + + var dimension = dimensions [0]; + + return !dimension.IsSized; } } + public override bool IsValueType { + get { return false; } + set { throw new InvalidOperationException (); } + } + public override string Name { - get { return string.Concat (base.Name, Suffix ()); } + get { return base.Name + Suffix; } } public override string FullName { - get { return string.Concat (base.FullName, Suffix ()); } + get { return base.FullName + Suffix; } } - string Suffix () - { - StringBuilder sb = new StringBuilder (); - sb.Append ("["); - for (int i = 0; i < m_dimensions.Count; i++) { - ArrayDimension dim = m_dimensions [i]; - string rank = dim.ToString (); - if (i < m_dimensions.Count - 1) - sb.Append (","); - if (rank.Length > 0) { - sb.Append (" "); - sb.Append (rank); + string Suffix { + get { + if (IsVector) + return "[]"; + + var suffix = new StringBuilder (); + suffix.Append ("["); + for (int i = 0; i < dimensions.Count; i++) { + if (i > 0) + suffix.Append (","); + + suffix.Append (dimensions [i].ToString ()); } + suffix.Append ("]"); + + return suffix.ToString (); } - sb.Append ("]"); - return sb.ToString (); } - internal ArrayType (TypeReference elementsType, ArrayShape shape) : base (elementsType) - { - m_dimensions = new ArrayDimensionCollection (this); - for (int i = 0; i < shape.Rank; i++) { - int lower = 0, upper = 0; - if (i < shape.NumSizes) - if (i < shape.NumLoBounds) { - lower = shape.LoBounds [i]; - upper = shape.LoBounds [i] + shape.Sizes [i] - 1; - } else - upper = shape.Sizes [i] - 1; + public override bool IsArray { + get { return true; } + } - m_dimensions.Add (new ArrayDimension (lower, upper)); - } + public ArrayType (TypeReference type) + : base (type) + { + Mixin.CheckType (type); + this.etype = MD.ElementType.Array; } - public ArrayType (TypeReference elementsType) : base (elementsType) + public ArrayType (TypeReference type, int rank) + : this (type) { - m_dimensions = new ArrayDimensionCollection (this); - m_dimensions.Add (new ArrayDimension (0, 0)); + Mixin.CheckType (type); + + if (rank == 1) + return; + + dimensions = new Collection (rank); + for (int i = 0; i < rank; i++) + dimensions.Add (new ArrayDimension ()); + this.etype = MD.ElementType.Array; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyDefinition.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyDefinition.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyDefinition.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyDefinition.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,133 +26,164 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { +using System; +using System.IO; + +using Mono.Collections.Generic; - using System; - using System.Collections; +namespace Mono.Cecil { - using Mono.Cecil.Metadata; + public sealed class AssemblyDefinition : ICustomAttributeProvider, ISecurityDeclarationProvider { - public class AssemblyDefinition : ICustomAttributeProvider, - IHasSecurity, IAnnotationProvider, IReflectionStructureVisitable { + AssemblyNameDefinition name; - MetadataToken m_token; - AssemblyNameDefinition m_asmName; - ModuleDefinitionCollection m_modules; - SecurityDeclarationCollection m_secDecls; - CustomAttributeCollection m_customAttrs; - MethodDefinition m_ep; - TargetRuntime m_runtime; - AssemblyKind m_kind; + internal ModuleDefinition main_module; + Collection modules; + Collection custom_attributes; + Collection security_declarations; - ModuleDefinition m_mainModule; - StructureReader m_reader; + public AssemblyNameDefinition Name { + get { return name; } + set { name = value; } + } - IAssemblyResolver m_resolver; - IDictionary m_annotations; + public string FullName { + get { return name != null ? name.FullName : string.Empty; } + } public MetadataToken MetadataToken { - get { return m_token; } - set { m_token = value; } + get { return new MetadataToken (TokenType.Assembly, 1); } + set { } } - public AssemblyNameDefinition Name { - get { return m_asmName; } + public Collection Modules { + get { + if (modules != null) + return modules; + + if (main_module.HasImage) + return modules = main_module.Read (this, (_, reader) => reader.ReadModules ()); + + return modules = new Collection { main_module }; + } } - public ModuleDefinitionCollection Modules { - get { return m_modules; } + public ModuleDefinition MainModule { + get { return main_module; } + } + + public MethodDefinition EntryPoint { + get { return main_module.EntryPoint; } + set { main_module.EntryPoint = value; } } - public SecurityDeclarationCollection SecurityDeclarations { + public bool HasCustomAttributes { get { - if (m_secDecls == null) - m_secDecls = new SecurityDeclarationCollection (this); + if (custom_attributes != null) + return custom_attributes.Count > 0; - return m_secDecls; + return this.GetHasCustomAttributes (main_module); } } - public CustomAttributeCollection CustomAttributes { + public Collection CustomAttributes { + get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (main_module)); } + } + + public bool HasSecurityDeclarations { get { - if (m_customAttrs == null) - m_customAttrs = new CustomAttributeCollection (this); + if (security_declarations != null) + return security_declarations.Count > 0; - return m_customAttrs; + return this.GetHasSecurityDeclarations (main_module); } } - public MethodDefinition EntryPoint { - get { return m_ep; } - set { m_ep = value; } + public Collection SecurityDeclarations { + get { return security_declarations ?? (security_declarations = this.GetSecurityDeclarations (main_module)); } } - public TargetRuntime Runtime { - get { return m_runtime; } - set { m_runtime = value; } + internal AssemblyDefinition () + { } - public AssemblyKind Kind { - get { return m_kind; } - set { m_kind = value; } +#if !READ_ONLY + public static AssemblyDefinition CreateAssembly (AssemblyNameDefinition assemblyName, string moduleName, ModuleKind kind) + { + return CreateAssembly (assemblyName, moduleName, new ModuleParameters { Kind = kind }); } - public ModuleDefinition MainModule { - get { - if (m_mainModule == null) - foreach (ModuleDefinition module in m_modules) - if (module.Main) - m_mainModule = module; + public static AssemblyDefinition CreateAssembly (AssemblyNameDefinition assemblyName, string moduleName, ModuleParameters parameters) + { + if (assemblyName == null) + throw new ArgumentNullException ("assemblyName"); + if (moduleName == null) + throw new ArgumentNullException ("moduleName"); + Mixin.CheckParameters (parameters); + if (parameters.Kind == ModuleKind.NetModule) + throw new ArgumentException ("kind"); - return m_mainModule; - } + var assembly = ModuleDefinition.CreateModule (moduleName, parameters).Assembly; + assembly.Name = assemblyName; + + return assembly; } +#endif - internal StructureReader Reader { - get { return m_reader; } + public static AssemblyDefinition ReadAssembly (string fileName) + { + return ReadAssembly (ModuleDefinition.ReadModule (fileName)); } - public IAssemblyResolver Resolver { - get { return m_resolver; } - set { m_resolver = value; } + public static AssemblyDefinition ReadAssembly (string fileName, ReaderParameters parameters) + { + return ReadAssembly (ModuleDefinition.ReadModule (fileName, parameters)); } - IDictionary IAnnotationProvider.Annotations { - get { - if (m_annotations == null) - m_annotations = new Hashtable (); - return m_annotations; - } + public static AssemblyDefinition ReadAssembly (Stream stream) + { + return ReadAssembly (ModuleDefinition.ReadModule (stream)); + } + + public static AssemblyDefinition ReadAssembly (Stream stream, ReaderParameters parameters) + { + return ReadAssembly (ModuleDefinition.ReadModule (stream, parameters)); } - internal AssemblyDefinition (AssemblyNameDefinition name) + static AssemblyDefinition ReadAssembly (ModuleDefinition module) { - if (name == null) - throw new ArgumentNullException ("name"); + var assembly = module.Assembly; + if (assembly == null) + throw new ArgumentException (); - m_asmName = name; - m_modules = new ModuleDefinitionCollection (this); - m_resolver = new DefaultAssemblyResolver (); + return assembly; } - internal AssemblyDefinition (AssemblyNameDefinition name, StructureReader reader) : this (name) +#if !READ_ONLY + public void Write (string fileName) { - m_reader = reader; + Write (fileName, new WriterParameters ()); } - public void Accept (IReflectionStructureVisitor visitor) + public void Write (Stream stream) { - visitor.VisitAssemblyDefinition (this); + Write (stream, new WriterParameters ()); + } - m_asmName.Accept (visitor); - m_modules.Accept (visitor); + public void Write (string fileName, WriterParameters parameters) + { + main_module.Write (fileName, parameters); + } - visitor.TerminateAssemblyDefinition (this); + public void Write (Stream stream, WriterParameters parameters) + { + main_module.Write (stream, parameters); } +#endif public override string ToString () { - return m_asmName.FullName; + return this.FullName; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyFactory.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyFactory.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyFactory.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyFactory.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,176 +0,0 @@ -// -// AssemblyFactory.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.IO; - using SR = System.Reflection; - - using Mono.Cecil.Binary; - - public sealed class AssemblyFactory { - - AssemblyFactory () - { - } - - static AssemblyDefinition GetAssembly (ImageReader irv, bool manifestOnly) - { - StructureReader srv = new StructureReader (irv, manifestOnly); - AssemblyDefinition asm = new AssemblyDefinition ( - new AssemblyNameDefinition (), srv); - - asm.Accept (srv); - return asm; - } - - static AssemblyDefinition GetAssembly (ImageReader reader) - { - return GetAssembly (reader, false); - } - - static AssemblyDefinition GetAssemblyManifest (ImageReader reader) - { - return GetAssembly (reader, true); - } - - public static AssemblyDefinition GetAssembly (string file) - { - return GetAssembly (ImageReader.Read (file)); - } - - public static AssemblyDefinition GetAssembly (byte [] assembly) - { - return GetAssembly (ImageReader.Read (assembly)); - } - - public static AssemblyDefinition GetAssembly (Stream stream) - { - return GetAssembly (ImageReader.Read (stream)); - } - - public static AssemblyDefinition GetAssemblyManifest (string file) - { - return GetAssemblyManifest (ImageReader.Read (file)); - } - - public static AssemblyDefinition GetAssemblyManifest (byte [] assembly) - { - return GetAssemblyManifest (ImageReader.Read (assembly)); - } - - public static AssemblyDefinition GetAssemblyManifest (Stream stream) - { - return GetAssemblyManifest (ImageReader.Read (stream)); - } - - static TargetRuntime CurrentRuntime () - { - Version corlib = typeof (object).Assembly.GetName ().Version; - if (corlib.Major == 1) - return corlib.Minor == 0 ? TargetRuntime.NET_1_0 : TargetRuntime.NET_1_1; - else // if (corlib.Major == 2) - return TargetRuntime.NET_2_0; - } - - public static AssemblyDefinition DefineAssembly (string name, AssemblyKind kind) - { - return DefineAssembly (name, name, CurrentRuntime (), kind); - } - - public static AssemblyDefinition DefineAssembly (string name, TargetRuntime rt, AssemblyKind kind) - { - return DefineAssembly (name, name, rt, kind); - } - - public static AssemblyDefinition DefineAssembly (string assemblyName, string moduleName, TargetRuntime rt, AssemblyKind kind) - { - AssemblyNameDefinition asmName = new AssemblyNameDefinition (); - asmName.Name = assemblyName; - AssemblyDefinition asm = new AssemblyDefinition (asmName); - asm.Runtime = rt; - asm.Kind = kind; - ModuleDefinition main = new ModuleDefinition (moduleName, asm, true); - asm.Modules.Add (main); - return asm; - } - - static void WriteAssembly (AssemblyDefinition asm, BinaryWriter bw) - { - asm.Accept (new StructureWriter (asm, bw)); - } - - public static void SaveAssembly (AssemblyDefinition asm, string file) - { - using (FileStream fs = new FileStream ( - file, FileMode.Create, FileAccess.Write, FileShare.None)) { - - SaveAssembly (asm, fs); - asm.MainModule.Image.SetFileInfo (new FileInfo (file)); - } - } - - public static void SaveAssembly (AssemblyDefinition asm, out byte [] assembly) - { - MemoryBinaryWriter bw = new MemoryBinaryWriter (); - SaveAssembly (asm, bw.BaseStream); - assembly = bw.ToArray (); - } - - public static void SaveAssembly (AssemblyDefinition asm, Stream stream) - { - BinaryWriter bw = new BinaryWriter (stream); - try { - WriteAssembly (asm, bw); - } finally { - bw.Close (); - } - - foreach (ModuleDefinition module in asm.Modules) - if (module.Controller.Writer.SaveSymbols) - module.Controller.Writer.WriteSymbols (module); - } - -#if !CF_1_0 && !CF_2_0 - public static SR.Assembly CreateReflectionAssembly (AssemblyDefinition asm, AppDomain domain) - { - using (MemoryBinaryWriter writer = new MemoryBinaryWriter ()) { - - WriteAssembly (asm, writer); - return domain.Load (writer.ToArray ()); - } - } - - public static SR.Assembly CreateReflectionAssembly (AssemblyDefinition asm) - { - return CreateReflectionAssembly (asm, AppDomain.CurrentDomain); - } -#endif - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyFlags.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyFlags.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyFlags.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyFlags.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,16 +26,16 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { +using System; - using System; +namespace Mono.Cecil { [Flags] - public enum AssemblyFlags : uint { + public enum AssemblyAttributes : uint { PublicKey = 0x0001, SideBySideCompatible = 0x0000, Retargetable = 0x0100, - EnableJITcompileTracking = 0x8000, - DisableJITcompileOptimizer = 0x4000 + DisableJITCompileOptimizer = 0x4000, + EnableJITCompileTracking = 0x8000, } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyHashAlgorithm.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyHashAlgorithm.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyHashAlgorithm.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyHashAlgorithm.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -34,4 +34,3 @@ SHA1 = 0x8004 } } - diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyKind.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyKind.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyKind.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyKind.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// -// AssemblyKind.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - public enum AssemblyKind { - Dll, - Console, - Windows - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyLinkedResource.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyLinkedResource.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyLinkedResource.cs 2008-11-06 19:52:04.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyLinkedResource.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,26 +26,32 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System; + namespace Mono.Cecil { public sealed class AssemblyLinkedResource : Resource { - private AssemblyNameReference m_asmRef; + AssemblyNameReference reference; public AssemblyNameReference Assembly { - get { return m_asmRef; } - set { m_asmRef = value; } + get { return reference; } + set { reference = value; } + } + + public override ResourceType ResourceType { + get { return ResourceType.AssemblyLinked; } } - public AssemblyLinkedResource (string name, ManifestResourceAttributes flags, - AssemblyNameReference asmRef) : base (name, flags) + public AssemblyLinkedResource (string name, ManifestResourceAttributes flags) + : base (name, flags) { - m_asmRef = asmRef; } - public override void Accept (IReflectionStructureVisitor visitor) + public AssemblyLinkedResource (string name, ManifestResourceAttributes flags, AssemblyNameReference reference) + : base (name, flags) { - visitor.VisitAssemblyLinkedResource (this); + this.reference = reference; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyNameDefinition.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyNameDefinition.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyNameDefinition.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyNameDefinition.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,27 +26,25 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { +using System; - using System; +namespace Mono.Cecil { public sealed class AssemblyNameDefinition : AssemblyNameReference { public override byte [] Hash { - get { return new byte [0]; } - } - - public AssemblyNameDefinition () : base() - { + get { return Empty.Array; } } - public AssemblyNameDefinition (string name, string culture, Version version) : base (name, culture, version) + internal AssemblyNameDefinition () { + this.token = new MetadataToken (TokenType.Assembly, 1); } - public override void Accept (IReflectionStructureVisitor visitor) + public AssemblyNameDefinition (string name, Version version) + : base (name, version) { - visitor.VisitAssemblyNameDefinition (this); + this.token = new MetadataToken (TokenType.Assembly, 1); } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyNameReferenceCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyNameReferenceCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyNameReferenceCollection.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyNameReferenceCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ -// -// AssemblyNameReferenceCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Wed Sep 27 12:46:52 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.Collections; - - using Mono.Cecil.Cil; - - public sealed class AssemblyNameReferenceCollection : CollectionBase, IReflectionStructureVisitable { - - ModuleDefinition m_container; - - public AssemblyNameReference this [int index] { - get { return List [index] as AssemblyNameReference; } - set { List [index] = value; } - } - - public ModuleDefinition Container { - get { return m_container; } - } - - public AssemblyNameReferenceCollection (ModuleDefinition container) - { - m_container = container; - } - - public void Add (AssemblyNameReference value) - { - List.Add (value); - } - - public bool Contains (AssemblyNameReference value) - { - return List.Contains (value); - } - - public int IndexOf (AssemblyNameReference value) - { - return List.IndexOf (value); - } - - public void Insert (int index, AssemblyNameReference value) - { - List.Insert (index, value); - } - - public void Remove (AssemblyNameReference value) - { - List.Remove (value); - } - - protected override void OnValidate (object o) - { - if (! (o is AssemblyNameReference)) - throw new ArgumentException ("Must be of type " + typeof (AssemblyNameReference).FullName); - } - - public void Accept (IReflectionStructureVisitor visitor) - { - visitor.VisitAssemblyNameReferenceCollection (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyNameReference.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyNameReference.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyNameReference.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyNameReference.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,155 +26,158 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System; +using System.Globalization; +using System.Security.Cryptography; +using System.Text; + namespace Mono.Cecil { - using System; - using System.Collections; - using System.Globalization; - using System.Security.Cryptography; - using System.Text; - - using Mono.Cecil.Metadata; - - public class AssemblyNameReference : IMetadataScope, IAnnotationProvider, IReflectionStructureVisitable { - - string m_name; - string m_culture; - Version m_version; - AssemblyFlags m_flags; - byte [] m_publicKey; - byte [] m_publicKeyToken; - AssemblyHashAlgorithm m_hashAlgo; - byte [] m_hash; - MetadataToken m_token; - IDictionary m_annotations; + public class AssemblyNameReference : IMetadataScope { + + string name; + string culture; + Version version; + uint attributes; + byte [] public_key; + byte [] public_key_token; + AssemblyHashAlgorithm hash_algorithm; + byte [] hash; + + internal MetadataToken token; - bool m_fullNameDiscarded = true; - string m_fullName; + string full_name; public string Name { - get { return m_name; } + get { return name; } set { - m_name = value; - m_fullNameDiscarded = true; + name = value; + full_name = null; } } public string Culture { - get { return m_culture; } + get { return culture; } set { - m_culture = value; - m_fullNameDiscarded = true; + culture = value; + full_name = null; } } public Version Version { - get { return m_version; } + get { return version; } set { - m_version = value; - m_fullNameDiscarded = true; + version = value; + full_name = null; } } - public AssemblyFlags Flags { - get { return m_flags; } - set { m_flags = value; } + public AssemblyAttributes Attributes { + get { return (AssemblyAttributes) attributes; } + set { attributes = (uint) value; } } public bool HasPublicKey { - get { return (m_flags & AssemblyFlags.PublicKey) != 0; } - set { - if (value) - m_flags |= AssemblyFlags.PublicKey; - else - m_flags &= ~AssemblyFlags.PublicKey; - } + get { return attributes.GetAttributes ((uint) AssemblyAttributes.PublicKey); } + set { attributes = attributes.SetAttributes ((uint) AssemblyAttributes.PublicKey, value); } } public bool IsSideBySideCompatible { - get { return (m_flags & AssemblyFlags.SideBySideCompatible) != 0; } - set { - if (value) - m_flags |= AssemblyFlags.SideBySideCompatible; - else - m_flags &= ~AssemblyFlags.SideBySideCompatible; - } + get { return attributes.GetAttributes ((uint) AssemblyAttributes.SideBySideCompatible); } + set { attributes = attributes.SetAttributes ((uint) AssemblyAttributes.SideBySideCompatible, value); } } public bool IsRetargetable { - get { return (m_flags & AssemblyFlags.Retargetable) != 0; } - set { - if (value) - m_flags |= AssemblyFlags.Retargetable; - else - m_flags &= ~AssemblyFlags.Retargetable; - } + get { return attributes.GetAttributes ((uint) AssemblyAttributes.Retargetable); } + set { attributes = attributes.SetAttributes ((uint) AssemblyAttributes.Retargetable, value); } } public byte [] PublicKey { - get { return m_publicKey; } + get { return public_key; } set { - m_publicKey = value; - m_publicKeyToken = null; - m_fullNameDiscarded = true; + public_key = value; + HasPublicKey = !public_key.IsNullOrEmpty (); + public_key_token = Empty.Array; + full_name = null; } } public byte [] PublicKeyToken { get { -#if !CF_1_0 - if ((m_publicKeyToken == null || m_publicKeyToken.Length == 0) && (m_publicKey != null && m_publicKey.Length > 0)) { - HashAlgorithm ha; - switch (m_hashAlgo) { - case AssemblyHashAlgorithm.Reserved: - ha = MD5.Create (); break; - default: - // None default to SHA1 - ha = SHA1.Create (); break; - } - byte [] hash = ha.ComputeHash (m_publicKey); + if (public_key_token.IsNullOrEmpty () && !public_key.IsNullOrEmpty ()) { + var hash = HashPublicKey (); // we need the last 8 bytes in reverse order - m_publicKeyToken = new byte [8]; - Array.Copy (hash, (hash.Length - 8), m_publicKeyToken, 0, 8); - Array.Reverse (m_publicKeyToken, 0, 8); + public_key_token = new byte [8]; + Array.Copy (hash, (hash.Length - 8), public_key_token, 0, 8); + Array.Reverse (public_key_token, 0, 8); } -#endif - return m_publicKeyToken; + return public_key_token; } set { - m_publicKeyToken = value; - m_fullNameDiscarded = true; + public_key_token = value; + full_name = null; } } + byte [] HashPublicKey () + { + HashAlgorithm algorithm; + + switch (hash_algorithm) { + case AssemblyHashAlgorithm.Reserved: +#if SILVERLIGHT + throw new NotSupportedException (); +#else + algorithm = MD5.Create (); + break; +#endif + default: + // None default to SHA1 +#if SILVERLIGHT + algorithm = new SHA1Managed (); + break; +#else + algorithm = SHA1.Create (); + break; +#endif + } + + using (algorithm) + return algorithm.ComputeHash (public_key); + } + + public virtual MetadataScopeType MetadataScopeType { + get { return MetadataScopeType.AssemblyNameReference; } + } + public string FullName { get { - if (m_fullName != null && !m_fullNameDiscarded) - return m_fullName; + if (full_name != null) + return full_name; - StringBuilder sb = new StringBuilder (); - string sep = ", "; - sb.Append (m_name); - if (m_version != null) { - sb.Append (sep); - sb.Append ("Version="); - sb.Append (m_version.ToString ()); + const string sep = ", "; + + var builder = new StringBuilder (); + builder.Append (name); + if (version != null) { + builder.Append (sep); + builder.Append ("Version="); + builder.Append (version.ToString ()); } - sb.Append (sep); - sb.Append ("Culture="); - sb.Append (m_culture == null || m_culture == string.Empty ? "neutral" : m_culture); - sb.Append (sep); - sb.Append ("PublicKeyToken="); - if (this.PublicKeyToken != null && m_publicKeyToken.Length > 0) { - for (int i = 0 ; i < m_publicKeyToken.Length ; i++) { - sb.Append (m_publicKeyToken [i].ToString ("x2")); + builder.Append (sep); + builder.Append ("Culture="); + builder.Append (string.IsNullOrEmpty (culture) ? "neutral" : culture); + builder.Append (sep); + builder.Append ("PublicKeyToken="); + + if (this.PublicKeyToken != null && public_key_token.Length > 0) { + for (int i = 0 ; i < public_key_token.Length ; i++) { + builder.Append (public_key_token [i].ToString ("x2")); } - } else { - sb.Append ("null"); - } - m_fullName = sb.ToString (); - m_fullNameDiscarded = false; - return m_fullName; + } else + builder.Append ("null"); + + return full_name = builder.ToString (); } } @@ -185,17 +188,17 @@ if (fullName.Length == 0) throw new ArgumentException ("Name can not be empty"); - AssemblyNameReference name = new AssemblyNameReference (); - string [] tokens = fullName.Split (','); + var name = new AssemblyNameReference (); + var tokens = fullName.Split (','); for (int i = 0; i < tokens.Length; i++) { - string token = tokens [i].Trim (); + var token = tokens [i].Trim (); if (i == 0) { name.Name = token; continue; } - string [] parts = token.Split ('='); + var parts = token.Split ('='); if (parts.Length != 2) throw new ArgumentException ("Malformed name"); @@ -207,13 +210,13 @@ name.Culture = parts [1]; break; case "PublicKeyToken": - string pkToken = parts [1]; - if (pkToken == "null") + string pk_token = parts [1]; + if (pk_token == "null") break; - name.PublicKeyToken = new byte [pkToken.Length / 2]; + name.PublicKeyToken = new byte [pk_token.Length / 2]; for (int j = 0; j < name.PublicKeyToken.Length; j++) { - name.PublicKeyToken [j] = Byte.Parse (pkToken.Substring (j * 2, 2), NumberStyles.HexNumber); + name.PublicKeyToken [j] = Byte.Parse (pk_token.Substring (j * 2, 2), NumberStyles.HexNumber); } break; } @@ -222,54 +225,39 @@ return name; } - public AssemblyHashAlgorithm HashAlgorithm - { - get { return m_hashAlgo; } - set { m_hashAlgo = value; } + public AssemblyHashAlgorithm HashAlgorithm { + get { return hash_algorithm; } + set { hash_algorithm = value; } } public virtual byte [] Hash { - get { return m_hash; } - set { m_hash = value; } + get { return hash; } + set { hash = value; } } public MetadataToken MetadataToken { - get { return m_token; } - set { m_token = value; } + get { return token; } + set { token = value; } } - IDictionary IAnnotationProvider.Annotations { - get { - if (m_annotations == null) - m_annotations = new Hashtable (); - return m_annotations; - } - } - - public AssemblyNameReference () : this (string.Empty, string.Empty, new Version (0, 0, 0, 0)) + internal AssemblyNameReference () { } - public AssemblyNameReference (string name, string culture, Version version) + public AssemblyNameReference (string name, Version version) { if (name == null) throw new ArgumentNullException ("name"); - if (culture == null) - throw new ArgumentNullException ("culture"); - m_name = name; - m_culture = culture; - m_version = version; - m_hashAlgo = AssemblyHashAlgorithm.None; + + this.name = name; + this.version = version; + this.hash_algorithm = AssemblyHashAlgorithm.None; + this.token = new MetadataToken (TokenType.AssemblyRef); } public override string ToString () { return this.FullName; } - - public virtual void Accept (IReflectionStructureVisitor visitor) - { - visitor.VisitAssemblyNameReference (this); - } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyReader.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyReader.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyReader.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyReader.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,3024 @@ +// +// AssemblyReader.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +using Mono.Collections.Generic; +using Mono.Cecil.Cil; +using Mono.Cecil.Metadata; +using Mono.Cecil.PE; + +using RVA = System.UInt32; + +namespace Mono.Cecil { + + abstract class ModuleReader { + + readonly protected Image image; + readonly protected ModuleDefinition module; + + protected ModuleReader (Image image, ReadingMode mode) + { + this.image = image; + this.module = new ModuleDefinition (image); + this.module.ReadingMode = mode; + } + + protected abstract void ReadModule (); + + protected void ReadModuleManifest (MetadataReader reader) + { + reader.Populate (module); + + ReadAssembly (reader); + } + + void ReadAssembly (MetadataReader reader) + { + var name = reader.ReadAssemblyNameDefinition (); + if (name == null) { + module.kind = ModuleKind.NetModule; + return; + } + + var assembly = new AssemblyDefinition (); + assembly.Name = name; + + module.assembly = assembly; + assembly.main_module = module; + } + + public static ModuleDefinition CreateModuleFrom (Image image, ReaderParameters parameters) + { + var module = ReadModule (image, parameters); + + ReadSymbols (module, parameters); + + if (parameters.AssemblyResolver != null) + module.assembly_resolver = parameters.AssemblyResolver; + + return module; + } + + static void ReadSymbols (ModuleDefinition module, ReaderParameters parameters) + { + var symbol_reader_provider = parameters.SymbolReaderProvider; + + if (symbol_reader_provider == null && parameters.ReadSymbols) + symbol_reader_provider = SymbolProvider.GetPlatformReaderProvider (); + + if (symbol_reader_provider != null) { + module.SymbolReaderProvider = symbol_reader_provider; + + var reader = parameters.SymbolStream != null + ? symbol_reader_provider.GetSymbolReader (module, parameters.SymbolStream) + : symbol_reader_provider.GetSymbolReader (module, module.FullyQualifiedName); + + module.ReadSymbols (reader); + } + } + + static ModuleDefinition ReadModule (Image image, ReaderParameters parameters) + { + var reader = CreateModuleReader (image, parameters.ReadingMode); + reader.ReadModule (); + return reader.module; + } + + static ModuleReader CreateModuleReader (Image image, ReadingMode mode) + { + switch (mode) { + case ReadingMode.Immediate: + return new ImmediateModuleReader (image); + case ReadingMode.Deferred: + return new DeferredModuleReader (image); + default: + throw new ArgumentException (); + } + } + } + + sealed class ImmediateModuleReader : ModuleReader { + + public ImmediateModuleReader (Image image) + : base (image, ReadingMode.Immediate) + { + } + + protected override void ReadModule () + { + this.module.Read (this.module, (module, reader) => { + ReadModuleManifest (reader); + ReadModule (module); + return module; + }); + } + + public static void ReadModule (ModuleDefinition module) + { + if (module.HasAssemblyReferences) + Read (module.AssemblyReferences); + if (module.HasResources) + Read (module.Resources); + if (module.HasModuleReferences) + Read (module.ModuleReferences); + if (module.HasTypes) + ReadTypes (module.Types); + if (module.HasExportedTypes) + Read (module.ExportedTypes); + if (module.HasCustomAttributes) + Read (module.CustomAttributes); + + var assembly = module.Assembly; + if (assembly == null) + return; + + if (assembly.HasCustomAttributes) + Read (assembly.CustomAttributes); + if (assembly.HasSecurityDeclarations) + Read (assembly.SecurityDeclarations); + } + + static void ReadTypes (Collection types) + { + for (int i = 0; i < types.Count; i++) + ReadType (types [i]); + } + + static void ReadType (TypeDefinition type) + { + ReadGenericParameters (type); + + if (type.HasInterfaces) + Read (type.Interfaces); + + if (type.HasNestedTypes) + ReadTypes (type.NestedTypes); + + if (type.HasLayoutInfo) + Read (type.ClassSize); + + if (type.HasFields) + ReadFields (type); + + if (type.HasMethods) + ReadMethods (type); + + if (type.HasProperties) + ReadProperties (type); + + if (type.HasEvents) + ReadEvents (type); + + ReadSecurityDeclarations (type); + ReadCustomAttributes (type); + } + + static void ReadGenericParameters (IGenericParameterProvider provider) + { + if (!provider.HasGenericParameters) + return; + + var parameters = provider.GenericParameters; + + for (int i = 0; i < parameters.Count; i++) { + var parameter = parameters [i]; + + if (parameter.HasConstraints) + Read (parameter.Constraints); + + if (parameter.HasCustomAttributes) + Read (parameter.CustomAttributes); + } + } + + static void ReadSecurityDeclarations (ISecurityDeclarationProvider provider) + { + if (provider.HasSecurityDeclarations) + Read (provider.SecurityDeclarations); + } + + static void ReadCustomAttributes (ICustomAttributeProvider provider) + { + if (provider.HasCustomAttributes) + Read (provider.CustomAttributes); + } + + static void ReadFields (TypeDefinition type) + { + var fields = type.Fields; + + for (int i = 0; i < fields.Count; i++) { + var field = fields [i]; + + if (field.HasConstant) + Read (field.Constant); + + if (field.HasLayoutInfo) + Read (field.Offset); + + if (field.RVA > 0) + Read (field.InitialValue); + + if (field.HasMarshalInfo) + Read (field.MarshalInfo); + + ReadCustomAttributes (field); + } + } + + static void ReadMethods (TypeDefinition type) + { + var methods = type.Methods; + + for (int i = 0; i < methods.Count; i++) { + var method = methods [i]; + + ReadGenericParameters (method); + + if (method.HasParameters) + ReadParameters (method); + + if (method.HasOverrides) + Read (method.Overrides); + + if (method.IsPInvokeImpl) + Read (method.PInvokeInfo); + + ReadSecurityDeclarations (method); + ReadCustomAttributes (method); + + var return_type = method.MethodReturnType; + if (return_type.HasConstant) + Read (return_type.Constant); + + if (return_type.HasMarshalInfo) + Read (return_type.MarshalInfo); + + ReadCustomAttributes (return_type); + } + } + + static void ReadParameters (MethodDefinition method) + { + var parameters = method.Parameters; + + for (int i = 0; i < parameters.Count; i++) { + var parameter = parameters [i]; + + if (parameter.HasConstant) + Read (parameter.Constant); + + if (parameter.HasMarshalInfo) + Read (parameter.MarshalInfo); + + ReadCustomAttributes (parameter); + } + } + + static void ReadProperties (TypeDefinition type) + { + var properties = type.Properties; + + for (int i = 0; i < properties.Count; i++) { + var property = properties [i]; + + Read (property.GetMethod); + + if (property.HasConstant) + Read (property.Constant); + + ReadCustomAttributes (property); + } + } + + static void ReadEvents (TypeDefinition type) + { + var events = type.Events; + + for (int i = 0; i < events.Count; i++) { + var @event = events [i]; + + Read (@event.AddMethod); + + ReadCustomAttributes (@event); + } + } + + static void Read (object collection) + { + } + } + + sealed class DeferredModuleReader : ModuleReader { + + public DeferredModuleReader (Image image) + : base (image, ReadingMode.Deferred) + { + } + + protected override void ReadModule () + { + this.module.Read (this.module, (module, reader) => { + ReadModuleManifest (reader); + return module; + }); + } + } + + sealed class MetadataReader : ByteBuffer { + + readonly internal Image image; + readonly internal ModuleDefinition module; + readonly internal MetadataSystem metadata; + + internal IGenericContext context; + internal CodeReader code; + + uint Position { + get { return (uint) base.position; } + set { base.position = (int) value; } + } + + public MetadataReader (ModuleDefinition module) + : base (module.Image.MetadataSection.Data) + { + this.image = module.Image; + this.module = module; + this.metadata = module.MetadataSystem; + this.code = CodeReader.CreateCodeReader (this); + } + + int GetCodedIndexSize (CodedIndex index) + { + return image.GetCodedIndexSize (index); + } + + uint ReadByIndexSize (int size) + { + if (size == 4) + return ReadUInt32 (); + else + return ReadUInt16 (); + } + + byte [] ReadBlob () + { + var blob_heap = image.BlobHeap; + if (blob_heap == null) { + position += 2; + return Empty.Array; + } + + return blob_heap.Read (ReadBlobIndex ()); + } + + byte [] ReadBlob (uint signature) + { + var blob_heap = image.BlobHeap; + if (blob_heap == null) + return Empty.Array; + + return blob_heap.Read (signature); + } + + uint ReadBlobIndex () + { + var blob_heap = image.BlobHeap; + return ReadByIndexSize (blob_heap != null ? blob_heap.IndexSize : 2); + } + + string ReadString () + { + return image.StringHeap.Read (ReadByIndexSize (image.StringHeap.IndexSize)); + } + + uint ReadStringIndex () + { + return ReadByIndexSize (image.StringHeap.IndexSize); + } + + uint ReadTableIndex (Table table) + { + return ReadByIndexSize (image.GetTableIndexSize (table)); + } + + MetadataToken ReadMetadataToken (CodedIndex index) + { + return index.GetMetadataToken (ReadByIndexSize (GetCodedIndexSize (index))); + } + + int MoveTo (Table table) + { + var info = image.TableHeap [table]; + if (info.Length != 0) + Position = info.Offset; + + return (int) info.Length; + } + + bool MoveTo (Table table, uint row) + { + var info = image.TableHeap [table]; + var length = info.Length; + if (length == 0 || row > length) + return false; + + Position = info.Offset + (info.RowSize * (row - 1)); + return true; + } + + public AssemblyNameDefinition ReadAssemblyNameDefinition () + { + if (MoveTo (Table.Assembly) == 0) + return null; + + var name = new AssemblyNameDefinition (); + + name.HashAlgorithm = (AssemblyHashAlgorithm) ReadUInt32 (); + + PopulateVersionAndFlags (name); + + name.PublicKey = ReadBlob (); + + PopulateNameAndCulture (name); + + return name; + } + + public ModuleDefinition Populate (ModuleDefinition module) + { + if (MoveTo (Table.Module) == 0) + return module; + + Advance (2); // Generation + + module.Name = ReadString (); + module.Mvid = image.GuidHeap.Read (ReadByIndexSize (image.GuidHeap.IndexSize)); + + return module; + } + + public Collection ReadAssemblyReferences () + { + int length = MoveTo (Table.AssemblyRef); + var references = new Collection (length); + + for (uint i = 1; i <= length; i++) { + var reference = new AssemblyNameReference (); + reference.token = new MetadataToken (TokenType.AssemblyRef, i); + + PopulateVersionAndFlags (reference); + + reference.PublicKeyToken = ReadBlob (); + + PopulateNameAndCulture (reference); + + reference.Hash = ReadBlob (); + + references.Add (reference); + } + + return references; + } + + public MethodDefinition ReadEntryPoint () + { + if (module.Kind != ModuleKind.Console && module.Kind != ModuleKind.Windows) + return null; + + var token = new MetadataToken (module.Image.EntryPointToken); + + return GetMethodDefinition (token.RID); + } + + public Collection ReadModules () + { + var modules = new Collection (1); + modules.Add (this.module); + + int length = MoveTo (Table.File); + for (uint i = 1; i <= length; i++) { + var attributes = (FileAttributes) ReadUInt32 (); + var name = ReadString (); + ReadBlobIndex (); + + if (attributes != FileAttributes.ContainsMetaData) + continue; + + var parameters = new ReaderParameters { + ReadingMode = module.ReadingMode, + SymbolReaderProvider = module.SymbolReaderProvider, + }; + + modules.Add (ModuleDefinition.ReadModule ( + GetModuleFileName (name), parameters)); + } + + return modules; + } + + string GetModuleFileName (string name) + { + if (module.FullyQualifiedName == null) + throw new NotSupportedException (); + + var path = Path.GetDirectoryName (module.FullyQualifiedName); + return Path.Combine (path, name); + } + + public Collection ReadModuleReferences () + { + int length = MoveTo (Table.ModuleRef); + var references = new Collection (length); + + for (uint i = 1; i <= length; i++) { + var reference = new ModuleReference (ReadString ()); + reference.token = new MetadataToken (TokenType.ModuleRef, i); + + references.Add (reference); + } + + return references; + } + + public bool HasFileResource () + { + int length = MoveTo (Table.File); + if (length == 0) + return false; + + for (uint i = 1; i <= length; i++) + if (ReadFileRecord (i).Col1 == FileAttributes.ContainsNoMetaData) + return true; + + return false; + } + + public Collection ReadResources () + { + int length = MoveTo (Table.ManifestResource); + var resources = new Collection (length); + + for (int i = 1; i <= length; i++) { + var offset = ReadUInt32 (); + var flags = (ManifestResourceAttributes) ReadUInt32 (); + var name = ReadString (); + var implementation = ReadMetadataToken (CodedIndex.Implementation); + + Resource resource; + + if (implementation.RID == 0) { + resource = new EmbeddedResource (name, flags, offset, this); + } else if (implementation.TokenType == TokenType.AssemblyRef) { + resource = new AssemblyLinkedResource (name, flags) { + Assembly = (AssemblyNameReference) GetTypeReferenceScope (implementation), + }; + } else if (implementation.TokenType == TokenType.File) { + var file_record = ReadFileRecord (implementation.RID); + + resource = new LinkedResource (name, flags) { + File = file_record.Col2, + hash = ReadBlob (file_record.Col3) + }; + } else + throw new NotSupportedException (); + + resources.Add (resource); + } + + return resources; + } + + Row ReadFileRecord (uint rid) + { + var position = this.position; + + if (!MoveTo (Table.File, rid)) + throw new ArgumentException (); + + var record = new Row ( + (FileAttributes) ReadUInt32 (), + ReadString (), + ReadBlobIndex ()); + + this.position = position; + + return record; + } + + public MemoryStream GetManagedResourceStream (uint offset) + { + var rva = image.Resources.VirtualAddress; + var section = image.GetSectionAtVirtualAddress (rva); + var position = (rva - section.VirtualAddress) + offset; + var buffer = section.Data; + + var length = buffer [position] + | (buffer [position + 1] << 8) + | (buffer [position + 2] << 16) + | (buffer [position + 3] << 24); + + return new MemoryStream (buffer, (int) position + 4, length); + } + + void PopulateVersionAndFlags (AssemblyNameReference name) + { + name.Version = new Version ( + ReadUInt16 (), + ReadUInt16 (), + ReadUInt16 (), + ReadUInt16 ()); + + name.Attributes = (AssemblyAttributes) ReadUInt32 (); + } + + void PopulateNameAndCulture (AssemblyNameReference name) + { + name.Name = ReadString (); + name.Culture = ReadString (); + } + + public TypeDefinitionCollection ReadTypes () + { + InitializeTypeDefinitions (); + var mtypes = metadata.Types; + var type_count = mtypes.Length - metadata.NestedTypes.Count; + var types = new TypeDefinitionCollection (module, type_count); + + for (int i = 0; i < mtypes.Length; i++) { + var type = mtypes [i]; + if (IsNested (type.Attributes)) + continue; + + types.Add (type); + } + + return types; + } + + void InitializeTypeDefinitions () + { + if (metadata.Types != null) + return; + + InitializeNestedTypes (); + InitializeFields (); + InitializeMethods (); + + int length = MoveTo (Table.TypeDef); + var types = metadata.Types = new TypeDefinition [length]; + + for (uint i = 0; i < length; i++) { + if (types [i] != null) + continue; + + types [i] = ReadType (i + 1); + } + } + + static bool IsNested (TypeAttributes attributes) + { + switch (attributes & TypeAttributes.VisibilityMask) { + case TypeAttributes.NestedAssembly: + case TypeAttributes.NestedFamANDAssem: + case TypeAttributes.NestedFamily: + case TypeAttributes.NestedFamORAssem: + case TypeAttributes.NestedPrivate: + case TypeAttributes.NestedPublic: + return true; + default: + return false; + } + } + + public bool HasNestedTypes (TypeDefinition type) + { + uint [] mapping; + InitializeNestedTypes (); + + if (!metadata.TryGetNestedTypeMapping (type, out mapping)) + return false; + + return mapping.Length > 0; + } + + public Collection ReadNestedTypes (TypeDefinition type) + { + InitializeNestedTypes (); + uint [] mapping; + if (!metadata.TryGetNestedTypeMapping (type, out mapping)) + return new MemberDefinitionCollection (type); + + var nested_types = new MemberDefinitionCollection (type, mapping.Length); + + for (int i = 0; i < mapping.Length; i++) + nested_types.Add (GetTypeDefinition (mapping [i])); + + metadata.RemoveNestedTypeMapping (type); + + return nested_types; + } + + void InitializeNestedTypes () + { + if (metadata.NestedTypes != null) + return; + + var length = MoveTo (Table.NestedClass); + + metadata.NestedTypes = new Dictionary (length); + metadata.ReverseNestedTypes = new Dictionary (length); + + if (length == 0) + return; + + for (int i = 1; i <= length; i++) { + var nested = ReadTableIndex (Table.TypeDef); + var declaring = ReadTableIndex (Table.TypeDef); + + AddNestedMapping (declaring, nested); + } + } + + void AddNestedMapping (uint declaring, uint nested) + { + metadata.SetNestedTypeMapping (declaring, AddMapping (metadata.NestedTypes, declaring, nested)); + metadata.SetReverseNestedTypeMapping (nested, declaring); + } + + static TValue [] AddMapping (Dictionary cache, TKey key, TValue value) + { + TValue [] mapped; + if (!cache.TryGetValue (key, out mapped)) { + mapped = new [] { value }; + return mapped; + } + + var new_mapped = new TValue [mapped.Length + 1]; + Array.Copy (mapped, new_mapped, mapped.Length); + new_mapped [mapped.Length] = value; + return new_mapped; + } + + TypeDefinition ReadType (uint rid) + { + if (!MoveTo (Table.TypeDef, rid)) + return null; + + var attributes = (TypeAttributes) ReadUInt32 (); + var name = ReadString (); + var @namespace = ReadString (); + var type = new TypeDefinition (@namespace, name, attributes); + type.token = new MetadataToken (TokenType.TypeDef, rid); + type.scope = module; + type.module = module; + + metadata.AddTypeDefinition (type); + + this.context = type; + + type.BaseType = GetTypeDefOrRef (ReadMetadataToken (CodedIndex.TypeDefOrRef)); + + type.fields_range = ReadFieldsRange (rid); + type.methods_range = ReadMethodsRange (rid); + + if (IsNested (attributes)) + type.DeclaringType = GetNestedTypeDeclaringType (type); + + return type; + } + + TypeDefinition GetNestedTypeDeclaringType (TypeDefinition type) + { + uint declaring_rid; + if (!metadata.TryGetReverseNestedTypeMapping (type, out declaring_rid)) + return null; + + metadata.RemoveReverseNestedTypeMapping (type); + return GetTypeDefinition (declaring_rid); + } + + Range ReadFieldsRange (uint type_index) + { + return ReadListRange (type_index, Table.TypeDef, Table.Field); + } + + Range ReadMethodsRange (uint type_index) + { + return ReadListRange (type_index, Table.TypeDef, Table.Method); + } + + Range ReadListRange (uint current_index, Table current, Table target) + { + var list = new Range (); + + list.Start = ReadTableIndex (target); + + uint next_index; + var current_table = image.TableHeap [current]; + + if (current_index == current_table.Length) + next_index = image.TableHeap [target].Length + 1; + else { + var position = Position; + Position += (uint) (current_table.RowSize - image.GetTableIndexSize (target)); + next_index = ReadTableIndex (target); + Position = position; + } + + list.Length = next_index - list.Start; + + return list; + } + + public Row ReadTypeLayout (TypeDefinition type) + { + InitializeTypeLayouts (); + Row class_layout; + var rid = type.token.RID; + if (!metadata.ClassLayouts.TryGetValue (rid, out class_layout)) + return new Row (Mixin.NoDataMarker, Mixin.NoDataMarker); + + type.PackingSize = (short) class_layout.Col1; + type.ClassSize = (int) class_layout.Col2; + + metadata.ClassLayouts.Remove (rid); + + return new Row ((short) class_layout.Col1, (int) class_layout.Col2); + } + + void InitializeTypeLayouts () + { + if (metadata.ClassLayouts != null) + return; + + int length = MoveTo (Table.ClassLayout); + + var class_layouts = metadata.ClassLayouts = new Dictionary> (length); + + for (uint i = 0; i < length; i++) { + var packing_size = ReadUInt16 (); + var class_size = ReadUInt32 (); + + var parent = ReadTableIndex (Table.TypeDef); + + class_layouts.Add (parent, new Row (packing_size, class_size)); + } + } + + public TypeReference GetTypeDefOrRef (MetadataToken token) + { + return (TypeReference) LookupToken (token); + } + + public TypeDefinition GetTypeDefinition (uint rid) + { + InitializeTypeDefinitions (); + + var type = metadata.GetTypeDefinition (rid); + if (type != null) + return type; + + return ReadTypeDefinition (rid); + } + + TypeDefinition ReadTypeDefinition (uint rid) + { + if (!MoveTo (Table.TypeDef, rid)) + return null; + + return ReadType (rid); + } + + void InitializeTypeReferences () + { + if (metadata.TypeReferences != null) + return; + + metadata.TypeReferences = new TypeReference [image.GetTableLength (Table.TypeRef)]; + } + + public TypeReference GetTypeReference (string scope, string full_name) + { + InitializeTypeReferences (); + + var length = metadata.TypeReferences.Length; + + for (uint i = 1; i <= length; i++) { + var type = GetTypeReference (i); + + if (type.FullName != full_name) + continue; + + if (string.IsNullOrEmpty (scope)) + return type; + + if (type.Scope.Name == scope) + return type; + } + + return null; + } + + TypeReference GetTypeReference (uint rid) + { + InitializeTypeReferences (); + + var type = metadata.GetTypeReference (rid); + if (type != null) + return type; + + return ReadTypeReference (rid); + } + + TypeReference ReadTypeReference (uint rid) + { + if (!MoveTo (Table.TypeRef, rid)) + return null; + + TypeReference declaring_type = null; + IMetadataScope scope; + + var scope_token = ReadMetadataToken (CodedIndex.ResolutionScope); + + var name = ReadString (); + var @namespace = ReadString (); + + var type = new TypeReference ( + @namespace, + name, + module, + null); + + type.token = new MetadataToken (TokenType.TypeRef, rid); + + metadata.AddTypeReference (type); + + if (scope_token.TokenType == TokenType.TypeRef) { + declaring_type = GetTypeDefOrRef (scope_token); + + scope = declaring_type != null + ? declaring_type.Scope + : module; + } else + scope = GetTypeReferenceScope (scope_token); + + type.scope = scope; + type.DeclaringType = declaring_type; + + MetadataSystem.TryProcessPrimitiveType (type); + + return type; + } + + IMetadataScope GetTypeReferenceScope (MetadataToken scope) + { + switch (scope.TokenType) { + // FIXME: both assembly refs and module refs should be in their + // own arrays, in case of someone modify the collections before + // this code is called + case TokenType.AssemblyRef: + return module.AssemblyReferences [(int) scope.RID - 1]; + case TokenType.ModuleRef: + return module.ModuleReferences [(int) scope.RID - 1]; + case TokenType.Module: + return module; + default: + throw new NotSupportedException (); + } + } + + public IEnumerable GetTypeReferences () + { + InitializeTypeReferences (); + + var length = image.GetTableLength (Table.TypeRef); + + var type_references = new TypeReference [length]; + + for (uint i = 1; i <= length; i++) + type_references [i - 1] = GetTypeReference (i); + + return type_references; + } + + TypeReference GetTypeSpecification (uint rid) + { + if (!MoveTo (Table.TypeSpec, rid)) + return null; + + var reader = ReadSignature (ReadBlobIndex ()); + var type = reader.ReadTypeSignature (); + if (type.token.RID == 0) + type.token = new MetadataToken (TokenType.TypeSpec, rid); + + return type; + } + + SignatureReader ReadSignature (uint signature) + { + return new SignatureReader (signature, this); + } + + public bool HasInterfaces (TypeDefinition type) + { + InitializeInterfaces (); + MetadataToken [] mapping; + + return metadata.TryGetInterfaceMapping (type, out mapping); + } + + public Collection ReadInterfaces (TypeDefinition type) + { + InitializeInterfaces (); + MetadataToken [] mapping; + + if (!metadata.TryGetInterfaceMapping (type, out mapping)) + return new Collection (); + + var interfaces = new Collection (mapping.Length); + + this.context = type; + + for (int i = 0; i < mapping.Length; i++) + interfaces.Add (GetTypeDefOrRef (mapping [i])); + + metadata.RemoveInterfaceMapping (type); + + return interfaces; + } + + void InitializeInterfaces () + { + if (metadata.Interfaces != null) + return; + + int length = MoveTo (Table.InterfaceImpl); + + metadata.Interfaces = new Dictionary (length); + + for (int i = 0; i < length; i++) { + var type = ReadTableIndex (Table.TypeDef); + var @interface = ReadMetadataToken (CodedIndex.TypeDefOrRef); + + AddInterfaceMapping (type, @interface); + } + } + + void AddInterfaceMapping (uint type, MetadataToken @interface) + { + metadata.SetInterfaceMapping (type, AddMapping (metadata.Interfaces, type, @interface)); + } + + public Collection ReadFields (TypeDefinition type) + { + var fields_range = type.fields_range; + if (fields_range.Length == 0) + return new MemberDefinitionCollection (type); + + var fields = new MemberDefinitionCollection (type, (int) fields_range.Length); + this.context = type; + + MoveTo (Table.Field, fields_range.Start); + for (uint i = 0; i < fields_range.Length; i++) + fields.Add (ReadField (fields_range.Start + i)); + + return fields; + } + + FieldDefinition ReadField (uint field_rid) + { + var attributes = (FieldAttributes) ReadUInt16 (); + var name = ReadString (); + var signature = ReadBlobIndex (); + + var field = new FieldDefinition (name, attributes, ReadFieldType (signature)); + field.token = new MetadataToken (TokenType.Field, field_rid); + metadata.AddFieldDefinition (field); + + return field; + } + + void InitializeFields () + { + if (metadata.Fields != null) + return; + + metadata.Fields = new FieldDefinition [image.GetTableLength (Table.Field)]; + } + + TypeReference ReadFieldType (uint signature) + { + var reader = ReadSignature (signature); + + const byte field_sig = 0x6; + + if (reader.ReadByte () != field_sig) + throw new NotSupportedException (); + + return reader.ReadTypeSignature (); + } + + public int ReadFieldRVA (FieldDefinition field) + { + InitializeFieldRVAs (); + var rid = field.token.RID; + + RVA rva; + if (!metadata.FieldRVAs.TryGetValue (rid, out rva)) + return 0; + + var size = GetFieldTypeSize (field.FieldType); + + if (size == 0 || rva == 0) + return 0; + + metadata.FieldRVAs.Remove (rid); + + field.InitialValue = GetFieldInitializeValue (size, rva); + + return (int) rva; + } + + byte [] GetFieldInitializeValue (int size, RVA rva) + { + var section = image.GetSectionAtVirtualAddress (rva); + if (section == null) + return Empty.Array; + + var value = new byte [size]; + Buffer.BlockCopy (section.Data, (int) (rva - section.VirtualAddress), value, 0, size); + return value; + } + + static int GetFieldTypeSize (TypeReference type) + { + int size = 0; + + switch (type.etype) { + case ElementType.Boolean: + case ElementType.U1: + case ElementType.I1: + size = 1; + break; + case ElementType.U2: + case ElementType.I2: + case ElementType.Char: + size = 2; + break; + case ElementType.U4: + case ElementType.I4: + case ElementType.R4: + size = 4; + break; + case ElementType.U8: + case ElementType.I8: + case ElementType.R8: + size = 8; + break; + case ElementType.Ptr: + case ElementType.FnPtr: + size = IntPtr.Size; + break; + case ElementType.CModOpt: + case ElementType.CModReqD: + return GetFieldTypeSize (((IModifierType) type).ElementType); + default: + var field_type = type.CheckedResolve (); + if (field_type.HasLayoutInfo) + size = field_type.ClassSize; + + break; + } + + return size; + } + + void InitializeFieldRVAs () + { + if (metadata.FieldRVAs != null) + return; + + int length = MoveTo (Table.FieldRVA); + + var field_rvas = metadata.FieldRVAs = new Dictionary (length); + + for (int i = 0; i < length; i++) { + var rva = ReadUInt32 (); + var field = ReadTableIndex (Table.Field); + + field_rvas.Add (field, rva); + } + } + + public int ReadFieldLayout (FieldDefinition field) + { + InitializeFieldLayouts (); + var rid = field.token.RID; + uint offset; + if (!metadata.FieldLayouts.TryGetValue (rid, out offset)) + return Mixin.NoDataMarker; + + metadata.FieldLayouts.Remove (rid); + + return (int) offset; + } + + void InitializeFieldLayouts () + { + if (metadata.FieldLayouts != null) + return; + + int length = MoveTo (Table.FieldLayout); + + var field_layouts = metadata.FieldLayouts = new Dictionary (length); + + for (int i = 0; i < length; i++) { + var offset = ReadUInt32 (); + var field = ReadTableIndex (Table.Field); + + field_layouts.Add (field, offset); + } + } + + public bool HasEvents (TypeDefinition type) + { + InitializeEvents (); + + Range range; + if (!metadata.TryGetEventsRange (type, out range)) + return false; + + return range.Length > 0; + } + + public Collection ReadEvents (TypeDefinition type) + { + InitializeEvents (); + Range range; + + if (!metadata.TryGetEventsRange (type, out range)) + return new MemberDefinitionCollection (type); + + var events = new MemberDefinitionCollection (type, (int) range.Length); + + metadata.RemoveEventsRange (type); + + if (range.Length == 0 || !MoveTo (Table.Event, range.Start)) + return events; + + this.context = type; + + for (uint i = 0; i < range.Length; i++) + events.Add (ReadEvent (range.Start + i)); + + return events; + } + + EventDefinition ReadEvent (uint event_rid) + { + var attributes = (EventAttributes) ReadUInt16 (); + var name = ReadString (); + var event_type = GetTypeDefOrRef (ReadMetadataToken (CodedIndex.TypeDefOrRef)); + + var @event = new EventDefinition (name, attributes, event_type); + @event.token = new MetadataToken (TokenType.Event, event_rid); + return @event; + } + + void InitializeEvents () + { + if (metadata.Events != null) + return; + + int length = MoveTo (Table.EventMap); + + metadata.Events = new Dictionary (length); + + for (uint i = 1; i <= length; i++) { + var type_rid = ReadTableIndex (Table.TypeDef); + Range events_range = ReadEventsRange (i); + metadata.AddEventsRange (type_rid, events_range); + } + } + + Range ReadEventsRange (uint rid) + { + return ReadListRange (rid, Table.EventMap, Table.Event); + } + + public bool HasProperties (TypeDefinition type) + { + InitializeProperties (); + + Range range; + if (!metadata.TryGetPropertiesRange (type, out range)) + return false; + + return range.Length > 0; + } + + public Collection ReadProperties (TypeDefinition type) + { + InitializeProperties (); + + Range range; + + if (!metadata.TryGetPropertiesRange (type, out range)) + return new MemberDefinitionCollection (type); + + metadata.RemovePropertiesRange (type); + + var properties = new MemberDefinitionCollection (type, (int) range.Length); + + if (range.Length == 0 || !MoveTo (Table.Property, range.Start)) + return properties; + + this.context = type; + + for (uint i = 0; i < range.Length; i++) + properties.Add (ReadProperty (range.Start + i)); + + return properties; + } + + PropertyDefinition ReadProperty (uint property_rid) + { + var attributes = (PropertyAttributes) ReadUInt16 (); + var name = ReadString (); + var signature = ReadBlobIndex (); + + var reader = ReadSignature (signature); + const byte property_signature = 0x8; + + var calling_convention = reader.ReadByte (); + + if ((calling_convention & property_signature) == 0) + throw new NotSupportedException (); + + var has_this = (calling_convention & 0x20) != 0; + + reader.ReadCompressedUInt32 (); // count + + var property = new PropertyDefinition (name, attributes, reader.ReadTypeSignature ()); + property.HasThis = has_this; + property.token = new MetadataToken (TokenType.Property, property_rid); + + return property; + } + + void InitializeProperties () + { + if (metadata.Properties != null) + return; + + int length = MoveTo (Table.PropertyMap); + + metadata.Properties = new Dictionary (length); + + for (uint i = 1; i <= length; i++) { + var type_rid = ReadTableIndex (Table.TypeDef); + var properties_range = ReadPropertiesRange (i); + metadata.AddPropertiesRange (type_rid, properties_range); + } + } + + Range ReadPropertiesRange (uint rid) + { + return ReadListRange (rid, Table.PropertyMap, Table.Property); + } + + MethodSemanticsAttributes ReadMethodSemantics (MethodDefinition method) + { + InitializeMethodSemantics (); + Row row; + if (!metadata.Semantics.TryGetValue (method.token.RID, out row)) + return MethodSemanticsAttributes.None; + + var type = method.DeclaringType; + + switch (row.Col1) { + case MethodSemanticsAttributes.AddOn: + GetEvent (type, row.Col2).add_method = method; + break; + case MethodSemanticsAttributes.Fire: + GetEvent (type, row.Col2).invoke_method = method; + break; + case MethodSemanticsAttributes.RemoveOn: + GetEvent (type, row.Col2).remove_method = method; + break; + case MethodSemanticsAttributes.Getter: + GetProperty (type, row.Col2).get_method = method; + break; + case MethodSemanticsAttributes.Setter: + GetProperty (type, row.Col2).set_method = method; + break; + case MethodSemanticsAttributes.Other: + switch (row.Col2.TokenType) { + case TokenType.Event: { + var @event = GetEvent (type, row.Col2); + if (@event.other_methods == null) + @event.other_methods = new Collection (); + + @event.other_methods.Add (method); + break; + } + case TokenType.Property: { + var property = GetProperty (type, row.Col2); + if (property.other_methods == null) + property.other_methods = new Collection (); + + property.other_methods.Add (method); + + break; + } + default: + throw new NotSupportedException (); + } + break; + default: + throw new NotSupportedException (); + } + + metadata.Semantics.Remove (method.token.RID); + + return row.Col1; + } + + static EventDefinition GetEvent (TypeDefinition type, MetadataToken token) + { + if (token.TokenType != TokenType.Event) + throw new ArgumentException (); + + return GetMember (type.Events, token); + } + + static PropertyDefinition GetProperty (TypeDefinition type, MetadataToken token) + { + if (token.TokenType != TokenType.Property) + throw new ArgumentException (); + + return GetMember (type.Properties, token); + } + + static TMember GetMember (Collection members, MetadataToken token) where TMember : IMemberDefinition + { + for (int i = 0; i < members.Count; i++) { + var member = members [i]; + if (member.MetadataToken == token) + return member; + } + + throw new ArgumentException (); + } + + void InitializeMethodSemantics () + { + if (metadata.Semantics != null) + return; + + int length = MoveTo (Table.MethodSemantics); + + var semantics = metadata.Semantics = new Dictionary> (0); + + for (uint i = 0; i < length; i++) { + var attributes = (MethodSemanticsAttributes) ReadUInt16 (); + var method_rid = ReadTableIndex (Table.Method); + var association = ReadMetadataToken (CodedIndex.HasSemantics); + + semantics [method_rid] = new Row (attributes, association); + } + } + + public PropertyDefinition ReadMethods (PropertyDefinition property) + { + ReadAllSemantics (property.DeclaringType); + return property; + } + + public EventDefinition ReadMethods (EventDefinition @event) + { + ReadAllSemantics (@event.DeclaringType); + return @event; + } + + public MethodSemanticsAttributes ReadAllSemantics (MethodDefinition method) + { + ReadAllSemantics (method.DeclaringType); + + return method.SemanticsAttributes; + } + + void ReadAllSemantics (TypeDefinition type) + { + var methods = type.Methods; + for (int i = 0; i < methods.Count; i++) { + var method = methods [i]; + if (method.sem_attrs.HasValue) + continue; + + method.sem_attrs = ReadMethodSemantics (method); + } + } + + Range ReadParametersRange (uint method_rid) + { + return ReadListRange (method_rid, Table.Method, Table.Param); + } + + public Collection ReadMethods (TypeDefinition type) + { + var methods_range = type.methods_range; + if (methods_range.Length == 0) + return new MemberDefinitionCollection (type); + + var methods = new MemberDefinitionCollection (type, (int) methods_range.Length); + + MoveTo (Table.Method, methods_range.Start); + for (uint i = 0; i < methods_range.Length; i++) + ReadMethod (methods_range.Start + i, methods); + + return methods; + } + + void InitializeMethods () + { + if (metadata.Methods != null) + return; + + metadata.Methods = new MethodDefinition [image.GetTableLength (Table.Method)]; + } + + void ReadMethod (uint method_rid, Collection methods) + { + var method = new MethodDefinition (); + method.rva = ReadUInt32 (); + method.ImplAttributes = (MethodImplAttributes) ReadUInt16 (); + method.Attributes = (MethodAttributes) ReadUInt16 (); + method.Name = ReadString (); + method.token = new MetadataToken (TokenType.Method, method_rid); + + methods.Add (method); // attach method + + var signature = ReadBlobIndex (); + var param_range = ReadParametersRange (method_rid); + + this.context = method; + + ReadMethodSignature (signature, method); + metadata.AddMethodDefinition (method); + + if (param_range.Length == 0) + return; + + var position = base.position; + ReadParameters (method, param_range); + base.position = position; + } + + void ReadParameters (MethodDefinition method, Range param_range) + { + MoveTo (Table.Param, param_range.Start); + for (uint i = 0; i < param_range.Length; i++) { + var attributes = (ParameterAttributes) ReadUInt16 (); + var sequence = ReadUInt16 (); + var name = ReadString (); + + var parameter = sequence == 0 + ? method.MethodReturnType.Parameter + : method.Parameters [sequence - 1]; + + parameter.token = new MetadataToken (TokenType.Param, param_range.Start + i); + parameter.Name = name; + parameter.Attributes = attributes; + } + } + + void ReadMethodSignature (uint signature, IMethodSignature method) + { + var reader = ReadSignature (signature); + reader.ReadMethodSignature (method); + } + + public PInvokeInfo ReadPInvokeInfo (MethodDefinition method) + { + InitializePInvokes (); + Row row; + + var rid = method.token.RID; + + if (!metadata.PInvokes.TryGetValue (rid, out row)) + return null; + + metadata.PInvokes.Remove (rid); + + return new PInvokeInfo ( + row.Col1, + image.StringHeap.Read (row.Col2), + module.ModuleReferences [(int) row.Col3 - 1]); + } + + void InitializePInvokes () + { + if (metadata.PInvokes != null) + return; + + int length = MoveTo (Table.ImplMap); + + var pinvokes = metadata.PInvokes = new Dictionary> (length); + + for (int i = 1; i <= length; i++) { + var attributes = (PInvokeAttributes) ReadUInt16 (); + var method = ReadMetadataToken (CodedIndex.MemberForwarded); + var name = ReadStringIndex (); + var scope = ReadTableIndex (Table.File); + + if (method.TokenType != TokenType.Method) + continue; + + pinvokes.Add (method.RID, new Row (attributes, name, scope)); + } + } + + public bool HasGenericParameters (IGenericParameterProvider provider) + { + InitializeGenericParameters (); + + Range range; + if (!metadata.TryGetGenericParameterRange (provider, out range)) + return false; + + return range.Length > 0; + } + + public Collection ReadGenericParameters (IGenericParameterProvider provider) + { + InitializeGenericParameters (); + + Range range; + if (!metadata.TryGetGenericParameterRange (provider, out range) + || !MoveTo (Table.GenericParam, range.Start)) + return new Collection (); + + metadata.RemoveGenericParameterRange (provider); + + var generic_parameters = new Collection ((int) range.Length); + + for (uint i = 0; i < range.Length; i++) { + ReadUInt16 (); // index + var flags = (GenericParameterAttributes) ReadUInt16 (); + ReadMetadataToken (CodedIndex.TypeOrMethodDef); + var name = ReadString (); + + var parameter = new GenericParameter (name, provider); + parameter.token = new MetadataToken (TokenType.GenericParam, range.Start + i); + parameter.Attributes = flags; + + generic_parameters.Add (parameter); + } + + return generic_parameters; + } + + void InitializeGenericParameters () + { + if (metadata.GenericParameters != null) + return; + + metadata.GenericParameters = InitializeRanges ( + Table.GenericParam, () => { + Advance (4); + var next = ReadMetadataToken (CodedIndex.TypeOrMethodDef); + ReadStringIndex (); + return next; + }); + } + + Dictionary InitializeRanges (Table table, Func get_next) + { + int length = MoveTo (table); + var ranges = new Dictionary (length); + + if (length == 0) + return ranges; + + MetadataToken owner = MetadataToken.Zero; + Range range = new Range (1, 0); + + for (uint i = 1; i <= length; i++) { + var next = get_next (); + + if (i == 1) { + owner = next; + range.Length++; + } else if (next != owner) { + if (owner.RID != 0) + ranges.Add (owner, range); + range = new Range (i, 1); + owner = next; + } else + range.Length++; + } + + if (owner != MetadataToken.Zero) + ranges.Add (owner, range); + + return ranges; + } + + public bool HasGenericConstraints (GenericParameter generic_parameter) + { + InitializeGenericConstraints (); + + MetadataToken [] mapping; + if (!metadata.TryGetGenericConstraintMapping (generic_parameter, out mapping)) + return false; + + return mapping.Length > 0; + } + + public Collection ReadGenericConstraints (GenericParameter generic_parameter) + { + InitializeGenericConstraints (); + + MetadataToken [] mapping; + if (!metadata.TryGetGenericConstraintMapping (generic_parameter, out mapping)) + return new Collection (); + + var constraints = new Collection (mapping.Length); + + this.context = (IGenericContext) generic_parameter.Owner; + + for (int i = 0; i < mapping.Length; i++) + constraints.Add (GetTypeDefOrRef (mapping [i])); + + metadata.RemoveGenericConstraintMapping (generic_parameter); + + return constraints; + } + + void InitializeGenericConstraints () + { + if (metadata.GenericConstraints != null) + return; + + var length = MoveTo (Table.GenericParamConstraint); + + metadata.GenericConstraints = new Dictionary (length); + + for (int i = 1; i <= length; i++) + AddGenericConstraintMapping ( + ReadTableIndex (Table.GenericParam), + ReadMetadataToken (CodedIndex.TypeDefOrRef)); + } + + void AddGenericConstraintMapping (uint generic_parameter, MetadataToken constraint) + { + metadata.SetGenericConstraintMapping ( + generic_parameter, + AddMapping (metadata.GenericConstraints, generic_parameter, constraint)); + } + + public bool HasOverrides (MethodDefinition method) + { + InitializeOverrides (); + MetadataToken [] mapping; + + if (!metadata.TryGetOverrideMapping (method, out mapping)) + return false; + + return mapping.Length > 0; + } + + public Collection ReadOverrides (MethodDefinition method) + { + InitializeOverrides (); + + MetadataToken [] mapping; + if (!metadata.TryGetOverrideMapping (method, out mapping)) + return new Collection (); + + var overrides = new Collection (mapping.Length); + + this.context = method; + + for (int i = 0; i < mapping.Length; i++) + overrides.Add ((MethodReference) LookupToken (mapping [i])); + + metadata.RemoveOverrideMapping (method); + + return overrides; + } + + void InitializeOverrides () + { + if (metadata.Overrides != null) + return; + + var length = MoveTo (Table.MethodImpl); + + metadata.Overrides = new Dictionary (length); + + for (int i = 1; i <= length; i++) { + ReadTableIndex (Table.TypeDef); + + var method = ReadMetadataToken (CodedIndex.MethodDefOrRef); + if (method.TokenType != TokenType.Method) + throw new NotSupportedException (); + + var @override = ReadMetadataToken (CodedIndex.MethodDefOrRef); + + AddOverrideMapping (method.RID, @override); + } + } + + void AddOverrideMapping (uint method_rid, MetadataToken @override) + { + metadata.SetOverrideMapping ( + method_rid, + AddMapping (metadata.Overrides, method_rid, @override)); + } + + public MethodBody ReadMethodBody (MethodDefinition method) + { + return code.ReadMethodBody (method); + } + + public CallSite ReadCallSite (MetadataToken token) + { + if (!MoveTo (Table.StandAloneSig, token.RID)) + return null; + + var signature = ReadBlobIndex (); + + var call_site = new CallSite (); + + ReadMethodSignature (signature, call_site); + + return call_site; + } + + public VariableDefinitionCollection ReadVariables (MetadataToken local_var_token) + { + if (!MoveTo (Table.StandAloneSig, local_var_token.RID)) + return null; + + var reader = ReadSignature (ReadBlobIndex ()); + const byte local_sig = 0x7; + + if (reader.ReadByte () != local_sig) + throw new NotSupportedException (); + + var count = reader.ReadCompressedUInt32 (); + if (count == 0) + return null; + + var variables = new VariableDefinitionCollection ((int) count); + + for (int i = 0; i < count; i++) + variables.Add (new VariableDefinition (reader.ReadTypeSignature ())); + + return variables; + } + + public IMetadataTokenProvider LookupToken (MetadataToken token) + { + var rid = token.RID; + + if (rid == 0) + return null; + + IMetadataTokenProvider element; + var position = this.position; + var context = this.context; + + switch (token.TokenType) { + case TokenType.TypeDef: + element = GetTypeDefinition (rid); + break; + case TokenType.TypeRef: + element = GetTypeReference (rid); + break; + case TokenType.TypeSpec: + element = GetTypeSpecification (rid); + break; + case TokenType.Field: + element = GetFieldDefinition (rid); + break; + case TokenType.Method: + element = GetMethodDefinition (rid); + break; + case TokenType.MemberRef: + element = GetMemberReference (rid); + break; + case TokenType.MethodSpec: + element = GetMethodSpecification (rid); + break; + default: + return null; + } + + this.position = position; + this.context = context; + + return element; + } + + public FieldDefinition GetFieldDefinition (uint rid) + { + InitializeTypeDefinitions (); + + var field = metadata.GetFieldDefinition (rid); + if (field != null) + return field; + + return LookupField (rid); + } + + FieldDefinition LookupField (uint rid) + { + var type = metadata.GetFieldDeclaringType (rid); + if (type == null) + return null; + + InitializeCollection (type.Fields); + + return metadata.GetFieldDefinition (rid); + } + + public MethodDefinition GetMethodDefinition (uint rid) + { + InitializeTypeDefinitions (); + + var method = metadata.GetMethodDefinition (rid); + if (method != null) + return method; + + return LookupMethod (rid); + } + + MethodDefinition LookupMethod (uint rid) + { + var type = metadata.GetMethodDeclaringType (rid); + if (type == null) + return null; + + InitializeCollection (type.Methods); + + return metadata.GetMethodDefinition (rid); + } + + MethodSpecification GetMethodSpecification (uint rid) + { + if (!MoveTo (Table.MethodSpec, rid)) + return null; + + var element_method = (MethodReference) LookupToken ( + ReadMetadataToken (CodedIndex.MethodDefOrRef)); + var signature = ReadBlobIndex (); + + var method_spec = ReadMethodSpecSignature (signature, element_method); + method_spec.token = new MetadataToken (TokenType.MethodSpec, rid); + return method_spec; + } + + MethodSpecification ReadMethodSpecSignature (uint signature, MethodReference method) + { + var reader = ReadSignature (signature); + const byte methodspec_sig = 0x0a; + + var call_conv = reader.ReadByte (); + + if (call_conv != methodspec_sig) + throw new NotSupportedException (); + + var instance = new GenericInstanceMethod (method); + + reader.ReadGenericInstanceSignature (method, instance); + + return instance; + } + + MemberReference GetMemberReference (uint rid) + { + InitializeMemberReferences (); + + var member = metadata.GetMemberReference (rid); + if (member != null) + return member; + + member = ReadMemberReference (rid); + if (member != null && !member.ContainsGenericParameter) + metadata.AddMemberReference (member); + return member; + } + + MemberReference ReadMemberReference (uint rid) + { + if (!MoveTo (Table.MemberRef, rid)) + return null; + + var token = ReadMetadataToken (CodedIndex.MemberRefParent); + var name = ReadString (); + var signature = ReadBlobIndex (); + + MemberReference member; + + switch (token.TokenType) { + case TokenType.TypeDef: + case TokenType.TypeRef: + case TokenType.TypeSpec: + member = ReadTypeMemberReference (token, name, signature); + break; + case TokenType.Method: + member = ReadMethodMemberReference (token, name, signature); + break; + default: + throw new NotSupportedException (); + } + + member.token = new MetadataToken (TokenType.MemberRef, rid); + + return member; + } + + MemberReference ReadTypeMemberReference (MetadataToken type, string name, uint signature) + { + var declaring_type = GetTypeDefOrRef (type); + + this.context = declaring_type; + + var member = ReadMemberReferenceSignature (signature, declaring_type); + member.Name = name; + + return member; + } + + MemberReference ReadMemberReferenceSignature (uint signature, TypeReference declaring_type) + { + var reader = ReadSignature (signature); + const byte field_sig = 0x6; + + if (reader.buffer [reader.position] == field_sig) { + reader.position++; + var field = new FieldReference (); + field.DeclaringType = declaring_type; + field.FieldType = reader.ReadTypeSignature (); + return field; + } else { + var method = new MethodReference (); + method.DeclaringType = declaring_type; + reader.ReadMethodSignature (method); + return method; + } + } + + MemberReference ReadMethodMemberReference (MetadataToken token, string name, uint signature) + { + var method = GetMethodDefinition (token.RID); + + this.context = method; + + var member = ReadMemberReferenceSignature (signature, method.DeclaringType); + member.Name = name; + + return member; + } + + void InitializeMemberReferences () + { + if (metadata.MemberReferences != null) + return; + + metadata.MemberReferences = new MemberReference [image.GetTableLength (Table.MemberRef)]; + } + + public IEnumerable GetMemberReferences () + { + InitializeMemberReferences (); + + var length = image.GetTableLength (Table.MemberRef); + + var type_system = module.TypeSystem; + + var context = new MethodReference (string.Empty, type_system.Void); + context.DeclaringType = new TypeReference (string.Empty, string.Empty, module, type_system.Corlib); + + var member_references = new MemberReference [length]; + + for (uint i = 1; i <= length; i++) { + this.context = context; + member_references [i - 1] = GetMemberReference (i); + } + + return member_references; + } + + void InitializeConstants () + { + if (metadata.Constants != null) + return; + + var length = MoveTo (Table.Constant); + + var constants = metadata.Constants = new Dictionary> (length); + + for (uint i = 1; i <= length; i++) { + var type = (ElementType) ReadUInt16 (); + var owner = ReadMetadataToken (CodedIndex.HasConstant); + var signature = ReadBlobIndex (); + + constants.Add (owner, new Row (type, signature)); + } + } + + public object ReadConstant (IConstantProvider owner) + { + InitializeConstants (); + + Row row; + if (!metadata.Constants.TryGetValue (owner.MetadataToken, out row)) + return Mixin.NoValue; + + metadata.Constants.Remove (owner.MetadataToken); + + switch (row.Col1) { + case ElementType.Class: + case ElementType.Object: + return null; + case ElementType.String: + return ReadConstantString (ReadBlob (row.Col2)); + default: + return ReadConstantPrimitive (row.Col1, row.Col2); + } + } + + static string ReadConstantString (byte [] blob) + { + var length = blob.Length; + if ((length & 1) == 1) + length--; + + return Encoding.Unicode.GetString (blob, 0, length); + } + + object ReadConstantPrimitive (ElementType type, uint signature) + { + var reader = ReadSignature (signature); + return reader.ReadConstantSignature (type); + } + + void InitializeCustomAttributes () + { + if (metadata.CustomAttributes != null) + return; + + metadata.CustomAttributes = InitializeRanges ( + Table.CustomAttribute, () => { + var next = ReadMetadataToken (CodedIndex.HasCustomAttribute); + ReadMetadataToken (CodedIndex.CustomAttributeType); + ReadBlobIndex (); + return next; + }); + } + + public bool HasCustomAttributes (ICustomAttributeProvider owner) + { + InitializeCustomAttributes (); + + Range range; + if (!metadata.TryGetCustomAttributeRange (owner, out range)) + return false; + + return range.Length > 0; + } + + public Collection ReadCustomAttributes (ICustomAttributeProvider owner) + { + InitializeCustomAttributes (); + + Range range; + if (!metadata.TryGetCustomAttributeRange (owner, out range) + || !MoveTo (Table.CustomAttribute, range.Start)) + return new Collection (); + + var custom_attributes = new Collection ((int) range.Length); + + for (int i = 0; i < range.Length; i++) { + ReadMetadataToken (CodedIndex.HasCustomAttribute); + + var constructor = (MethodReference) LookupToken ( + ReadMetadataToken (CodedIndex.CustomAttributeType)); + + var signature = ReadBlobIndex (); + + custom_attributes.Add (new CustomAttribute (signature, constructor)); + } + + metadata.RemoveCustomAttributeRange (owner); + + return custom_attributes; + } + + public byte [] ReadCustomAttributeBlob (uint signature) + { + return ReadBlob (signature); + } + + public void ReadCustomAttributeSignature (CustomAttribute attribute) + { + var reader = ReadSignature (attribute.signature); + if (reader.ReadUInt16 () != 0x0001) + throw new InvalidOperationException (); + + var constructor = attribute.Constructor; + if (constructor.HasParameters) + reader.ReadCustomAttributeConstructorArguments (attribute, constructor.Parameters); + + if (!reader.CanReadMore ()) + return; + + var named = reader.ReadUInt16 (); + + if (named == 0) + return; + + reader.ReadCustomAttributeNamedArguments (named, ref attribute.fields, ref attribute.properties); + } + + void InitializeMarshalInfos () + { + if (metadata.FieldMarshals != null) + return; + + var length = MoveTo (Table.FieldMarshal); + + var marshals = metadata.FieldMarshals = new Dictionary (length); + + for (int i = 0; i < length; i++) { + var token = ReadMetadataToken (CodedIndex.HasFieldMarshal); + var signature = ReadBlobIndex (); + if (token.RID == 0) + continue; + + marshals.Add (token, signature); + } + } + + public bool HasMarshalInfo (IMarshalInfoProvider owner) + { + InitializeMarshalInfos (); + + return metadata.FieldMarshals.ContainsKey (owner.MetadataToken); + } + + public MarshalInfo ReadMarshalInfo (IMarshalInfoProvider owner) + { + InitializeMarshalInfos (); + + uint signature; + if (!metadata.FieldMarshals.TryGetValue (owner.MetadataToken, out signature)) + return null; + + var reader = ReadSignature (signature); + + metadata.FieldMarshals.Remove (owner.MetadataToken); + + return reader.ReadMarshalInfo (); + } + + void InitializeSecurityDeclarations () + { + if (metadata.SecurityDeclarations != null) + return; + + metadata.SecurityDeclarations = InitializeRanges ( + Table.DeclSecurity, () => { + ReadUInt16 (); + var next = ReadMetadataToken (CodedIndex.HasDeclSecurity); + ReadBlobIndex (); + return next; + }); + } + + public bool HasSecurityDeclarations (ISecurityDeclarationProvider owner) + { + InitializeSecurityDeclarations (); + + Range range; + if (!metadata.TryGetSecurityDeclarationRange (owner, out range)) + return false; + + return range.Length > 0; + } + + public Collection ReadSecurityDeclarations (ISecurityDeclarationProvider owner) + { + InitializeSecurityDeclarations (); + + Range range; + if (!metadata.TryGetSecurityDeclarationRange (owner, out range) + || !MoveTo (Table.DeclSecurity, range.Start)) + return new Collection (); + + var security_declarations = new Collection ((int) range.Length); + + for (int i = 0; i < range.Length; i++) { + var action = (SecurityAction) ReadUInt16 (); + ReadMetadataToken (CodedIndex.HasDeclSecurity); + var signature = ReadBlobIndex (); + + security_declarations.Add (new SecurityDeclaration (action, signature, module)); + } + + metadata.RemoveSecurityDeclarationRange (owner); + + return security_declarations; + } + + public byte [] ReadSecurityDeclarationBlob (uint signature) + { + return ReadBlob (signature); + } + + public void ReadSecurityDeclarationSignature (SecurityDeclaration declaration) + { + var signature = declaration.signature; + var reader = ReadSignature (signature); + + if (reader.buffer [reader.position] != '.') { + ReadXmlSecurityDeclaration (signature, declaration); + return; + } + + reader.ReadByte (); + var count = reader.ReadCompressedUInt32 (); + var attributes = new Collection ((int) count); + + for (int i = 0; i < count; i++) + attributes.Add (reader.ReadSecurityAttribute ()); + + declaration.security_attributes = attributes; + } + + void ReadXmlSecurityDeclaration (uint signature, SecurityDeclaration declaration) + { + var blob = ReadBlob (signature); + var attributes = new Collection (1); + + var attribute = new SecurityAttribute ( + module.TypeSystem.LookupType ("System.Security.Permissions", "PermissionSetAttribute")); + + attribute.properties = new Collection (1); + attribute.properties.Add ( + new CustomAttributeNamedArgument ( + "XML", + new CustomAttributeArgument ( + module.TypeSystem.String, + Encoding.Unicode.GetString (blob, 0, blob.Length)))); + + attributes.Add (attribute); + + declaration.security_attributes = attributes; + } + + public Collection ReadExportedTypes () + { + var length = MoveTo (Table.ExportedType); + if (length == 0) + return new Collection (); + + var exported_types = new Collection (length); + + for (int i = 1; i <= length; i++) { + var attributes = (TypeAttributes) ReadUInt32 (); + var identifier = ReadUInt32 (); + var name = ReadString (); + var @namespace = ReadString (); + var implementation = ReadMetadataToken (CodedIndex.Implementation); + + ExportedType declaring_type = null; + IMetadataScope scope = null; + + switch (implementation.TokenType) { + case TokenType.AssemblyRef: + case TokenType.File: + scope = GetExportedTypeScope (implementation); + break; + case TokenType.ExportedType: + // FIXME: if the table is not properly sorted + declaring_type = exported_types [(int) implementation.RID - 1]; + break; + } + + var exported_type = new ExportedType (@namespace, name, scope) { + Attributes = attributes, + Identifier = (int) identifier, + DeclaringType = declaring_type, + }; + exported_type.token = new MetadataToken (TokenType.ExportedType, i); + + exported_types.Add (exported_type); + } + + return exported_types; + } + + IMetadataScope GetExportedTypeScope (MetadataToken token) + { + switch (token.TokenType) { + case TokenType.AssemblyRef: + return module.AssemblyReferences [(int) token.RID - 1]; + case TokenType.File: + var position = this.position; + var reference = GetModuleReferenceFromFile (token); + this.position = position; + + if (reference == null) + throw new NotSupportedException (); + + return reference; + default: + throw new NotSupportedException (); + } + } + + ModuleReference GetModuleReferenceFromFile (MetadataToken token) + { + if (!MoveTo (Table.File, token.RID)) + return null; + + ReadUInt32 (); + var file_name = ReadString (); + var modules = module.ModuleReferences; + + ModuleReference reference = null; + for (int i = 0; i < modules.Count; i++) { + var module_reference = modules [i]; + if (module_reference.Name != file_name) + continue; + + reference = module_reference; + break; + } + + return reference; + } + + static void InitializeCollection (object o) + { + } + } + + sealed class SignatureReader : ByteBuffer { + + readonly MetadataReader reader; + readonly uint start, sig_length; + + TypeSystem TypeSystem { + get { return reader.module.TypeSystem; } + } + + public SignatureReader (uint blob, MetadataReader reader) + : base (reader.buffer) + { + this.reader = reader; + + MoveToBlob (blob); + + this.sig_length = ReadCompressedUInt32 (); + this.start = (uint) position; + } + + void MoveToBlob (uint blob) + { + position = (int) (reader.image.BlobHeap.Offset + blob); + } + + MetadataToken ReadTypeTokenSignature () + { + return CodedIndex.TypeDefOrRef.GetMetadataToken (ReadCompressedUInt32 ()); + } + + GenericParameter GetGenericParameter (GenericParameterType type, uint var) + { + var context = reader.context; + + if (context == null) + throw new NotSupportedException (); + + IGenericParameterProvider provider; + + switch (type) { + case GenericParameterType.Type: + provider = context.Type; + break; + case GenericParameterType.Method: + provider = context.Method; + break; + default: + throw new NotSupportedException (); + } + + int index = (int) var; + + if (!context.IsDefinition) + CheckGenericContext (provider, index); + + return provider.GenericParameters [index]; + } + + static void CheckGenericContext (IGenericParameterProvider owner, int index) + { + var owner_parameters = owner.GenericParameters; + + for (int i = owner_parameters.Count; i <= index; i++) + owner_parameters.Add (new GenericParameter (owner)); + } + + public void ReadGenericInstanceSignature (IGenericParameterProvider provider, IGenericInstance instance) + { + var arity = ReadCompressedUInt32 (); + + if (!provider.IsDefinition) + CheckGenericContext (provider, (int) arity - 1); + + var instance_arguments = instance.GenericArguments; + + for (int i = 0; i < arity; i++) + instance_arguments.Add (ReadTypeSignature ()); + } + + ArrayType ReadArrayTypeSignature () + { + var array = new ArrayType (ReadTypeSignature ()); + + var rank = ReadCompressedUInt32 (); + + var sizes = new uint [ReadCompressedUInt32 ()]; + for (int i = 0; i < sizes.Length; i++) + sizes [i] = ReadCompressedUInt32 (); + + var low_bounds = new int [ReadCompressedUInt32 ()]; + for (int i = 0; i < low_bounds.Length; i++) + low_bounds [i] = ReadCompressedInt32 (); + + array.Dimensions.Clear (); + + for (int i = 0; i < rank; i++) { + int? lower = null, upper = null; + + if (i < low_bounds.Length) + lower = low_bounds [i]; + + if (i < sizes.Length) + upper = lower + (int) sizes [i] - 1; + + array.Dimensions.Add (new ArrayDimension (lower, upper)); + } + + return array; + } + + TypeReference GetTypeDefOrRef (MetadataToken token) + { + return reader.GetTypeDefOrRef (token); + } + + public TypeReference ReadTypeSignature () + { + return ReadTypeSignature ((ElementType) ReadByte ()); + } + + TypeReference ReadTypeSignature (ElementType etype) + { + switch (etype) { + case ElementType.ValueType: { + var value_type = GetTypeDefOrRef (ReadTypeTokenSignature ()); + value_type.IsValueType = true; + return value_type; + } + case ElementType.Class: + return GetTypeDefOrRef (ReadTypeTokenSignature ()); + case ElementType.Ptr: + return new PointerType (ReadTypeSignature ()); + case ElementType.FnPtr: { + var fptr = new FunctionPointerType (); + ReadMethodSignature (fptr); + return fptr; + } + case ElementType.ByRef: + return new ByReferenceType (ReadTypeSignature ()); + case ElementType.Pinned: + return new PinnedType (ReadTypeSignature ()); + case ElementType.SzArray: + return new ArrayType (ReadTypeSignature ()); + case ElementType.Array: + return ReadArrayTypeSignature (); + case ElementType.CModOpt: + return new OptionalModifierType ( + GetTypeDefOrRef (ReadTypeTokenSignature ()), ReadTypeSignature ()); + case ElementType.CModReqD: + return new RequiredModifierType ( + GetTypeDefOrRef (ReadTypeTokenSignature ()), ReadTypeSignature ()); + case ElementType.Sentinel: + return new SentinelType (ReadTypeSignature ()); + case ElementType.Var: + return GetGenericParameter (GenericParameterType.Type, ReadCompressedUInt32 ()); + case ElementType.MVar: + return GetGenericParameter (GenericParameterType.Method, ReadCompressedUInt32 ()); + case ElementType.GenericInst: { + var is_value_type = ReadByte () == (byte) ElementType.ValueType; + var element_type = GetTypeDefOrRef (ReadTypeTokenSignature ()); + var generic_instance = new GenericInstanceType (element_type); + + ReadGenericInstanceSignature (element_type, generic_instance); + + if (is_value_type) { + generic_instance.IsValueType = true; + element_type.GetElementType ().IsValueType = true; + } + + return generic_instance; + } + case ElementType.Object: return TypeSystem.Object; + case ElementType.Void: return TypeSystem.Void; + case ElementType.TypedByRef: return TypeSystem.TypedReference; + case ElementType.I: return TypeSystem.IntPtr; + case ElementType.U: return TypeSystem.UIntPtr; + default: return GetPrimitiveType (etype); + } + } + + public void ReadMethodSignature (IMethodSignature method) + { + var calling_convention = ReadByte (); + method.CallingConvention = (MethodCallingConvention) calling_convention; + method.HasThis = (calling_convention & 0x20) != 0; + method.ExplicitThis = (calling_convention & 0x40) != 0; + + var generic_context = method as MethodReference; + if (generic_context != null) + reader.context = generic_context; + + if ((calling_convention & 0x10) != 0) { + var arity = ReadCompressedUInt32 (); + + if (generic_context != null && !generic_context.IsDefinition) + CheckGenericContext (generic_context, (int) arity -1 ); + } + + // TODO: more call_conv + + var param_count = ReadCompressedUInt32 (); + + method.MethodReturnType.ReturnType = ReadTypeSignature (); + + if (param_count == 0) + return; + + Collection parameters; + + var method_ref = method as MethodReference; + if (method_ref != null) + parameters = method_ref.parameters = new ParameterDefinitionCollection (method, (int) param_count); + else + parameters = method.Parameters; + + for (int i = 0; i < param_count; i++) + parameters.Add (new ParameterDefinition (ReadTypeSignature ())); + } + + public object ReadConstantSignature (ElementType type) + { + return ReadPrimitiveValue (type); + } + + public void ReadCustomAttributeConstructorArguments (CustomAttribute attribute, Collection parameters) + { + var count = parameters.Count; + if (count == 0) + return; + + attribute.arguments = new Collection (count); + + for (int i = 0; i < count; i++) + attribute.arguments.Add ( + ReadCustomAttributeFixedArgument (parameters [i].ParameterType)); + } + + CustomAttributeArgument ReadCustomAttributeFixedArgument (TypeReference type) + { + if (type.IsArray) + return ReadCustomAttributeFixedArrayArgument ((ArrayType) type); + + return ReadCustomAttributeElement (type); + } + + public void ReadCustomAttributeNamedArguments (ushort count, ref Collection fields, ref Collection properties) + { + for (int i = 0; i < count; i++) + ReadCustomAttributeNamedArgument (ref fields, ref properties); + } + + void ReadCustomAttributeNamedArgument (ref Collection fields, ref Collection properties) + { + var kind = ReadByte (); + var type = ReadCustomAttributeFieldOrPropType (); + var name = ReadUTF8String (); + + Collection container; + switch (kind) { + case 0x53: + container = GetCustomAttributeNamedArgumentCollection (ref fields); + break; + case 0x54: + container = GetCustomAttributeNamedArgumentCollection (ref properties); + break; + default: + throw new NotSupportedException (); + } + + container.Add (new CustomAttributeNamedArgument (name, ReadCustomAttributeFixedArgument (type))); + } + + static Collection GetCustomAttributeNamedArgumentCollection (ref Collection collection) + { + if (collection != null) + return collection; + + return collection = new Collection (); + } + + CustomAttributeArgument ReadCustomAttributeFixedArrayArgument (ArrayType type) + { + var length = ReadUInt32 (); + + if (length == 0xffffffff) + return new CustomAttributeArgument (type, null); + + if (length == 0) + return new CustomAttributeArgument (type, Empty.Array); + + var arguments = new CustomAttributeArgument [length]; + var element_type = type.ElementType; + + for (int i = 0; i < length; i++) + arguments [i] = ReadCustomAttributeElement (element_type); + + return new CustomAttributeArgument (type, arguments); + } + + CustomAttributeArgument ReadCustomAttributeElement (TypeReference type) + { + if (type.IsArray) + return ReadCustomAttributeFixedArrayArgument ((ArrayType) type); + + if (type.etype == ElementType.Object) + return ReadCustomAttributeElement (ReadCustomAttributeFieldOrPropType ()); + + return new CustomAttributeArgument (type, ReadCustomAttributeElementValue (type)); + } + + object ReadCustomAttributeElementValue (TypeReference type) + { + var etype = type.etype; + + switch (etype) { + case ElementType.String: + return ReadUTF8String (); + case ElementType.None: + if (type.IsTypeOf ("System", "Type")) + return ReadTypeReference (); + + return ReadCustomAttributeEnum (type); + default: + return ReadPrimitiveValue (etype); + } + } + + object ReadPrimitiveValue (ElementType type) + { + switch (type) { + case ElementType.Boolean: + return ReadByte () == 1; + case ElementType.I1: + return (sbyte) ReadByte (); + case ElementType.U1: + return ReadByte (); + case ElementType.Char: + return (char) ReadUInt16 (); + case ElementType.I2: + return ReadInt16 (); + case ElementType.U2: + return ReadUInt16 (); + case ElementType.I4: + return ReadInt32 (); + case ElementType.U4: + return ReadUInt32 (); + case ElementType.I8: + return ReadInt64 (); + case ElementType.U8: + return ReadUInt64 (); + case ElementType.R4: + return ReadSingle (); + case ElementType.R8: + return ReadDouble (); + default: + throw new NotImplementedException (type.ToString ()); + } + } + + TypeReference GetPrimitiveType (ElementType etype) + { + switch (etype) { + case ElementType.Boolean: + return TypeSystem.Boolean; + case ElementType.Char: + return TypeSystem.Char; + case ElementType.I1: + return TypeSystem.SByte; + case ElementType.U1: + return TypeSystem.Byte; + case ElementType.I2: + return TypeSystem.Int16; + case ElementType.U2: + return TypeSystem.UInt16; + case ElementType.I4: + return TypeSystem.Int32; + case ElementType.U4: + return TypeSystem.UInt32; + case ElementType.I8: + return TypeSystem.Int64; + case ElementType.U8: + return TypeSystem.UInt64; + case ElementType.R4: + return TypeSystem.Single; + case ElementType.R8: + return TypeSystem.Double; + case ElementType.String: + return TypeSystem.String; + default: + throw new NotImplementedException (etype.ToString ()); + } + } + + TypeReference ReadCustomAttributeFieldOrPropType () + { + var etype = (ElementType) ReadByte (); + + switch (etype) { + case ElementType.Boxed: + return TypeSystem.Object; + case ElementType.SzArray: + return new ArrayType (ReadCustomAttributeFieldOrPropType ()); + case ElementType.Enum: + return ReadTypeReference (); + case ElementType.Type: + return TypeSystem.LookupType ("System", "Type"); + default: + return GetPrimitiveType (etype); + } + } + + public TypeReference ReadTypeReference () + { + return TypeParser.ParseType (reader.module, ReadUTF8String ()); + } + + object ReadCustomAttributeEnum (TypeReference enum_type) + { + var type = enum_type.CheckedResolve (); + if (!type.IsEnum) + throw new ArgumentException (); + + return ReadCustomAttributeElementValue (type.GetEnumUnderlyingType ()); + } + + public SecurityAttribute ReadSecurityAttribute () + { + var attribute = new SecurityAttribute (ReadTypeReference ()); + + ReadCompressedUInt32 (); + + ReadCustomAttributeNamedArguments ( + (ushort) ReadCompressedUInt32 (), + ref attribute.fields, + ref attribute.properties); + + return attribute; + } + + public MarshalInfo ReadMarshalInfo () + { + var native = ReadNativeType (); + switch (native) { + case NativeType.Array: { + var array = new ArrayMarshalInfo (); + if (CanReadMore ()) + array.element_type = ReadNativeType (); + if (CanReadMore ()) + array.size_parameter_index = (int) ReadCompressedUInt32 (); + if (CanReadMore ()) + array.size = (int) ReadCompressedUInt32 (); + if (CanReadMore ()) + array.size_parameter_multiplier = (int) ReadCompressedUInt32 (); + return array; + } + case NativeType.SafeArray: { + var array = new SafeArrayMarshalInfo (); + if (CanReadMore ()) + array.element_type = ReadVariantType (); + return array; + } + case NativeType.FixedArray: { + var array = new FixedArrayMarshalInfo (); + if (CanReadMore ()) + array.size = (int) ReadCompressedUInt32 (); + if (CanReadMore ()) + array.element_type = ReadNativeType (); + return array; + } + case NativeType.FixedSysString: { + var sys_string = new FixedSysStringMarshalInfo (); + if (CanReadMore ()) + sys_string.size = (int) ReadCompressedUInt32 (); + return sys_string; + } + case NativeType.CustomMarshaler: { + var marshaler = new CustomMarshalInfo (); + var guid_value = ReadUTF8String (); + marshaler.guid = !string.IsNullOrEmpty (guid_value) ? new Guid (guid_value) : Guid.Empty; + marshaler.unmanaged_type = ReadUTF8String (); + marshaler.managed_type = ReadTypeReference (); + marshaler.cookie = ReadUTF8String (); + return marshaler; + } + default: + return new MarshalInfo (native); + } + } + + NativeType ReadNativeType () + { + return (NativeType) ReadByte (); + } + + VariantType ReadVariantType () + { + return (VariantType) ReadByte (); + } + + string ReadUTF8String () + { + if (buffer [position] == 0xff) { + position++; + return null; + } + + var length = (int) ReadCompressedUInt32 (); + if (length == 0) + return string.Empty; + + var @string = Encoding.UTF8.GetString (buffer, position, + buffer [position + length - 1] == 0 ? length - 1 : length); + + position += length; + return @string; + } + + public bool CanReadMore () + { + return position - start < sig_length; + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyWriter.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyWriter.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyWriter.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyWriter.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,2533 @@ +// +// AssemblyWriter.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +using Mono.Collections.Generic; +using Mono.Cecil.Cil; +using Mono.Cecil.Metadata; +using Mono.Cecil.PE; + +using RVA = System.UInt32; +using RID = System.UInt32; +using CodedRID = System.UInt32; +using StringIndex = System.UInt32; +using BlobIndex = System.UInt32; + +namespace Mono.Cecil { + +#if !READ_ONLY + + using TypeRefRow = Row; + using TypeDefRow = Row; + using FieldRow = Row; + using MethodRow = Row; + using ParamRow = Row; + using InterfaceImplRow = Row; + using MemberRefRow = Row; + using ConstantRow = Row; + using CustomAttributeRow = Row; + using FieldMarshalRow = Row; + using DeclSecurityRow = Row; + using ClassLayoutRow = Row; + using FieldLayoutRow = Row; + using EventMapRow = Row; + using EventRow = Row; + using PropertyMapRow = Row; + using PropertyRow = Row; + using MethodSemanticsRow = Row; + using MethodImplRow = Row; + using ImplMapRow = Row; + using FieldRVARow = Row; + using AssemblyRow = Row; + using AssemblyRefRow = Row; + using FileRow = Row; + using ExportedTypeRow = Row; + using ManifestResourceRow = Row; + using NestedClassRow = Row; + using GenericParamRow = Row; + using MethodSpecRow = Row; + using GenericParamConstraintRow = Row; + + static class ModuleWriter { + + public static void WriteModuleTo (ModuleDefinition module, Stream stream, WriterParameters parameters) + { + if ((module.Attributes & ModuleAttributes.ILOnly) == 0) + throw new ArgumentException (); + + if (module.HasImage && module.ReadingMode == ReadingMode.Deferred) + ImmediateModuleReader.ReadModule (module); + + module.MetadataSystem.Clear (); + + var name = module.assembly != null ? module.assembly.Name : null; + var fq_name = stream.GetFullyQualifiedName (); + var symbol_writer_provider = parameters.SymbolWriterProvider; + if (symbol_writer_provider == null && parameters.WriteSymbols) + symbol_writer_provider = SymbolProvider.GetPlatformWriterProvider (); + var symbol_writer = GetSymbolWriter (module, fq_name, symbol_writer_provider); + +#if !SILVERLIGHT && !CF + if (parameters.StrongNameKeyPair != null && name != null) + name.PublicKey = parameters.StrongNameKeyPair.PublicKey; +#endif + + if (name != null && name.HasPublicKey) + module.Attributes |= ModuleAttributes.StrongNameSigned; + + var metadata = new MetadataBuilder (module, fq_name, + symbol_writer_provider, symbol_writer); + + BuildMetadata (module, metadata); + + if (module.SymbolReader != null) + module.SymbolReader.Dispose (); + + var writer = ImageWriter.CreateWriter (module, metadata, stream); + + writer.WriteImage (); + +#if !SILVERLIGHT && !CF + if (parameters.StrongNameKeyPair != null) + CryptoService.StrongName (stream, writer, parameters.StrongNameKeyPair); +#endif + if (symbol_writer != null) + symbol_writer.Dispose (); + } + + static void BuildMetadata (ModuleDefinition module, MetadataBuilder metadata) + { + if (!module.HasImage) { + metadata.BuildMetadata (); + return; + } + + module.Read (metadata, (builder, _) => { + builder.BuildMetadata (); + return builder; + }); + } + + static ISymbolWriter GetSymbolWriter (ModuleDefinition module, string fq_name, ISymbolWriterProvider symbol_writer_provider) + { + if (symbol_writer_provider == null) + return null; + + return symbol_writer_provider.GetSymbolWriter (module, fq_name); + } + } + + abstract class MetadataTable { + + public abstract int Length { get; } + + public bool IsLarge { + get { return Length > 65535; } + } + + public abstract void Write (TableHeapBuffer buffer); + public abstract void Sort (); + } + + abstract class OneRowTable : MetadataTable where TRow : struct { + + internal TRow row; + + public sealed override int Length { + get { return 1; } + } + + public sealed override void Sort () + { + } + } + + abstract class MetadataTable : MetadataTable where TRow : struct { + + internal TRow [] rows = new TRow [2]; + internal int length; + + public sealed override int Length { + get { return length; } + } + + public int AddRow (TRow row) + { + if (rows.Length == length) + Grow (); + + rows [length++] = row; + return length; + } + + void Grow () + { + var rows = new TRow [this.rows.Length * 2]; + Array.Copy (this.rows, rows, this.rows.Length); + this.rows = rows; + } + + public override void Sort () + { + } + } + + abstract class SortedTable : MetadataTable, IComparer where TRow : struct { + + public sealed override void Sort () + { + Array.Sort (rows, 0, length, this); + } + + protected int Compare (uint x, uint y) + { + return x == y ? 0 : x > y ? 1 : -1; + } + + public abstract int Compare (TRow x, TRow y); + } + + sealed class ModuleTable : OneRowTable { + + public override void Write (TableHeapBuffer buffer) + { + buffer.WriteUInt16 (0); // Generation + buffer.WriteString (row); // Name + buffer.WriteUInt16 (1); // Mvid + buffer.WriteUInt16 (0); // EncId + buffer.WriteUInt16 (0); // EncBaseId + } + } + + sealed class TypeRefTable : MetadataTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteCodedRID ( + rows [i].Col1, CodedIndex.ResolutionScope); // Scope + buffer.WriteString (rows [i].Col2); // Name + buffer.WriteString (rows [i].Col3); // Namespace + } + } + } + + sealed class TypeDefTable : MetadataTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteUInt32 ((uint) rows [i].Col1); // Attributes + buffer.WriteString (rows [i].Col2); // Name + buffer.WriteString (rows [i].Col3); // Namespace + buffer.WriteCodedRID ( + rows [i].Col4, CodedIndex.TypeDefOrRef); // Extends + buffer.WriteRID (rows [i].Col5, Table.Field); // FieldList + buffer.WriteRID (rows [i].Col6, Table.Method); // MethodList + } + } + } + + sealed class FieldTable : MetadataTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteUInt16 ((ushort) rows [i].Col1); // Attributes + buffer.WriteString (rows [i].Col2); // Name + buffer.WriteBlob (rows [i].Col3); // Signature + } + } + } + + sealed class MethodTable : MetadataTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteUInt32 (rows [i].Col1); // RVA + buffer.WriteUInt16 ((ushort) rows [i].Col2); // ImplFlags + buffer.WriteUInt16 ((ushort) rows [i].Col3); // Flags + buffer.WriteString (rows [i].Col4); // Name + buffer.WriteBlob (rows [i].Col5); // Signature + buffer.WriteRID (rows [i].Col6, Table.Param); // ParamList + } + } + } + + sealed class ParamTable : MetadataTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteUInt16 ((ushort) rows [i].Col1); // Attributes + buffer.WriteUInt16 (rows [i].Col2); // Sequence + buffer.WriteString (rows [i].Col3); // Name + } + } + } + + sealed class InterfaceImplTable : MetadataTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteRID (rows [i].Col1, Table.TypeDef); // Class + buffer.WriteCodedRID (rows [i].Col2, CodedIndex.TypeDefOrRef); // Interface + } + } + + /*public override int Compare (InterfaceImplRow x, InterfaceImplRow y) + { + return (int) (x.Col1 == y.Col1 ? y.Col2 - x.Col2 : x.Col1 - y.Col1); + }*/ + } + + sealed class MemberRefTable : MetadataTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteCodedRID (rows [i].Col1, CodedIndex.MemberRefParent); + buffer.WriteString (rows [i].Col2); + buffer.WriteBlob (rows [i].Col3); + } + } + } + + sealed class ConstantTable : SortedTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteUInt16 ((ushort) rows [i].Col1); + buffer.WriteCodedRID (rows [i].Col2, CodedIndex.HasConstant); + buffer.WriteBlob (rows [i].Col3); + } + } + + public override int Compare (ConstantRow x, ConstantRow y) + { + return Compare (x.Col2, y.Col2); + } + } + + sealed class CustomAttributeTable : SortedTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteCodedRID (rows [i].Col1, CodedIndex.HasCustomAttribute); // Parent + buffer.WriteCodedRID (rows [i].Col2, CodedIndex.CustomAttributeType); // Type + buffer.WriteBlob (rows [i].Col3); + } + } + + public override int Compare (CustomAttributeRow x, CustomAttributeRow y) + { + return Compare (x.Col1, y.Col1); + } + } + + sealed class FieldMarshalTable : SortedTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteCodedRID (rows [i].Col1, CodedIndex.HasFieldMarshal); + buffer.WriteBlob (rows [i].Col2); + } + } + + public override int Compare (FieldMarshalRow x, FieldMarshalRow y) + { + return Compare (x.Col1, y.Col1); + } + } + + sealed class DeclSecurityTable : SortedTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteUInt16 ((ushort) rows [i].Col1); + buffer.WriteCodedRID (rows [i].Col2, CodedIndex.HasDeclSecurity); + buffer.WriteBlob (rows [i].Col3); + } + } + + public override int Compare (DeclSecurityRow x, DeclSecurityRow y) + { + return Compare (x.Col2, y.Col2); + } + } + + sealed class ClassLayoutTable : SortedTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteUInt16 (rows [i].Col1); // PackingSize + buffer.WriteUInt32 (rows [i].Col2); // ClassSize + buffer.WriteRID (rows [i].Col3, Table.TypeDef); // Parent + } + } + + public override int Compare (ClassLayoutRow x, ClassLayoutRow y) + { + return Compare (x.Col3, y.Col3); + } + } + + sealed class FieldLayoutTable : SortedTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteUInt32 (rows [i].Col1); // Offset + buffer.WriteRID (rows [i].Col2, Table.Field); // Parent + } + } + + public override int Compare (FieldLayoutRow x, FieldLayoutRow y) + { + return Compare (x.Col2, y.Col2); + } + } + + sealed class StandAloneSigTable : MetadataTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) + buffer.WriteBlob (rows [i]); + } + } + + sealed class EventMapTable : MetadataTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteRID (rows [i].Col1, Table.TypeDef); // Parent + buffer.WriteRID (rows [i].Col2, Table.Event); // EventList + } + } + } + + sealed class EventTable : MetadataTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteUInt16 ((ushort) rows [i].Col1); // Flags + buffer.WriteString (rows [i].Col2); // Name + buffer.WriteCodedRID (rows [i].Col3, CodedIndex.TypeDefOrRef); // EventType + } + } + } + + sealed class PropertyMapTable : MetadataTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteRID (rows [i].Col1, Table.TypeDef); // Parent + buffer.WriteRID (rows [i].Col2, Table.Property); // PropertyList + } + } + } + + sealed class PropertyTable : MetadataTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteUInt16 ((ushort) rows [i].Col1); // Flags + buffer.WriteString (rows [i].Col2); // Name + buffer.WriteBlob (rows [i].Col3); // Type + } + } + } + + sealed class MethodSemanticsTable : SortedTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteUInt16 ((ushort) rows [i].Col1); // Flags + buffer.WriteRID (rows [i].Col2, Table.Method); // Method + buffer.WriteCodedRID (rows [i].Col3, CodedIndex.HasSemantics); // Association + } + } + + public override int Compare (MethodSemanticsRow x, MethodSemanticsRow y) + { + return Compare (x.Col3, y.Col3); + } + } + + sealed class MethodImplTable : MetadataTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteRID (rows [i].Col1, Table.TypeDef); // Class + buffer.WriteCodedRID (rows [i].Col2, CodedIndex.MethodDefOrRef); // MethodBody + buffer.WriteCodedRID (rows [i].Col3, CodedIndex.MethodDefOrRef); // MethodDeclaration + } + } + } + + sealed class ModuleRefTable : MetadataTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) + buffer.WriteString (rows [i]); // Name + } + } + + sealed class TypeSpecTable : MetadataTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) + buffer.WriteBlob (rows [i]); // Signature + } + } + + sealed class ImplMapTable : SortedTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteUInt16 ((ushort) rows [i].Col1); // Flags + buffer.WriteCodedRID (rows [i].Col2, CodedIndex.MemberForwarded); // MemberForwarded + buffer.WriteString (rows [i].Col3); // ImportName + buffer.WriteRID (rows [i].Col4, Table.ModuleRef); // ImportScope + } + } + + public override int Compare (ImplMapRow x, ImplMapRow y) + { + return Compare (x.Col2, y.Col2); + } + } + + sealed class FieldRVATable : SortedTable { + + internal int position; + + public override void Write (TableHeapBuffer buffer) + { + position = buffer.position; + for (int i = 0; i < length; i++) { + buffer.WriteUInt32 (rows [i].Col1); // RVA + buffer.WriteRID (rows [i].Col2, Table.Field); // Field + } + } + + public override int Compare (FieldRVARow x, FieldRVARow y) + { + return Compare (x.Col2, y.Col2); + } + } + + sealed class AssemblyTable : OneRowTable { + + public override void Write (TableHeapBuffer buffer) + { + buffer.WriteUInt32 ((uint) row.Col1); // AssemblyHashAlgorithm + buffer.WriteUInt16 (row.Col2); // MajorVersion + buffer.WriteUInt16 (row.Col3); // MinorVersion + buffer.WriteUInt16 (row.Col4); // Build + buffer.WriteUInt16 (row.Col5); // Revision + buffer.WriteUInt32 ((uint) row.Col6); // Flags + buffer.WriteBlob (row.Col7); // PublicKey + buffer.WriteString (row.Col8); // Name + buffer.WriteString (row.Col9); // Culture + } + } + + sealed class AssemblyRefTable : MetadataTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteUInt16 (rows [i].Col1); // MajorVersion + buffer.WriteUInt16 (rows [i].Col2); // MinorVersion + buffer.WriteUInt16 (rows [i].Col3); // Build + buffer.WriteUInt16 (rows [i].Col4); // Revision + buffer.WriteUInt32 ((uint) rows [i].Col5); // Flags + buffer.WriteBlob (rows [i].Col6); // PublicKeyOrToken + buffer.WriteString (rows [i].Col7); // Name + buffer.WriteString (rows [i].Col8); // Culture + buffer.WriteBlob (rows [i].Col9); // Hash + } + } + } + + sealed class FileTable : MetadataTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteUInt32 ((uint) rows [i].Col1); + buffer.WriteString (rows [i].Col2); + buffer.WriteBlob (rows [i].Col3); + } + } + } + + sealed class ExportedTypeTable : MetadataTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteUInt32 ((uint) rows [i].Col1); + buffer.WriteUInt32 (rows [i].Col2); + buffer.WriteString (rows [i].Col3); + buffer.WriteString (rows [i].Col4); + buffer.WriteCodedRID (rows [i].Col5, CodedIndex.Implementation); + } + } + } + + sealed class ManifestResourceTable : MetadataTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteUInt32 (rows [i].Col1); + buffer.WriteUInt32 ((uint) rows [i].Col2); + buffer.WriteString (rows [i].Col3); + buffer.WriteCodedRID (rows [i].Col4, CodedIndex.Implementation); + } + } + } + + sealed class NestedClassTable : SortedTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteRID (rows [i].Col1, Table.TypeDef); // NestedClass + buffer.WriteRID (rows [i].Col2, Table.TypeDef); // EnclosingClass + } + } + + public override int Compare (NestedClassRow x, NestedClassRow y) + { + return Compare (x.Col1, y.Col1); + } + } + + sealed class GenericParamTable : MetadataTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteUInt16 (rows [i].Col1); // Number + buffer.WriteUInt16 ((ushort) rows [i].Col2); // Flags + buffer.WriteCodedRID (rows [i].Col3, CodedIndex.TypeOrMethodDef); // Owner + buffer.WriteString (rows [i].Col4); // Name + } + } + } + + sealed class MethodSpecTable : MetadataTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteCodedRID (rows [i].Col1, CodedIndex.MethodDefOrRef); // Method + buffer.WriteBlob (rows [i].Col2); // Instantiation + } + } + } + + sealed class GenericParamConstraintTable : MetadataTable { + + public override void Write (TableHeapBuffer buffer) + { + for (int i = 0; i < length; i++) { + buffer.WriteRID (rows [i].Col1, Table.GenericParam); // Owner + buffer.WriteCodedRID (rows [i].Col2, CodedIndex.TypeDefOrRef); // Constraint + } + } + } + + sealed class MetadataBuilder { + + readonly internal ModuleDefinition module; + readonly internal ISymbolWriterProvider symbol_writer_provider; + readonly internal ISymbolWriter symbol_writer; + readonly internal TextMap text_map; + readonly internal string fq_name; + + readonly Dictionary type_ref_map; + readonly Dictionary type_spec_map; + readonly Dictionary member_ref_map; + readonly Dictionary method_spec_map; + readonly Collection generic_parameters; + readonly Dictionary method_def_map; + + readonly internal CodeWriter code; + readonly internal DataBuffer data; + readonly internal ResourceBuffer resources; + readonly internal StringHeapBuffer string_heap; + readonly internal UserStringHeapBuffer user_string_heap; + readonly internal BlobHeapBuffer blob_heap; + readonly internal TableHeapBuffer table_heap; + + internal MetadataToken entry_point; + + RID type_rid = 1; + RID field_rid = 1; + RID method_rid = 1; + RID param_rid = 1; + RID property_rid = 1; + RID event_rid = 1; + + readonly TypeRefTable type_ref_table; + readonly TypeDefTable type_def_table; + readonly FieldTable field_table; + readonly MethodTable method_table; + readonly ParamTable param_table; + readonly InterfaceImplTable iface_impl_table; + readonly MemberRefTable member_ref_table; + readonly ConstantTable constant_table; + readonly CustomAttributeTable custom_attribute_table; + readonly DeclSecurityTable declsec_table; + readonly StandAloneSigTable standalone_sig_table; + readonly EventMapTable event_map_table; + readonly EventTable event_table; + readonly PropertyMapTable property_map_table; + readonly PropertyTable property_table; + readonly TypeSpecTable typespec_table; + readonly MethodSpecTable method_spec_table; + + readonly internal bool write_symbols; + + public MetadataBuilder (ModuleDefinition module, string fq_name, ISymbolWriterProvider symbol_writer_provider, ISymbolWriter symbol_writer) + { + this.module = module; + this.text_map = CreateTextMap (); + this.fq_name = fq_name; + this.symbol_writer_provider = symbol_writer_provider; + this.symbol_writer = symbol_writer; + this.write_symbols = symbol_writer != null; + this.code = new CodeWriter (this); + this.data = new DataBuffer (); + this.resources = new ResourceBuffer (); + this.string_heap = new StringHeapBuffer (); + this.user_string_heap = new UserStringHeapBuffer (); + this.blob_heap = new BlobHeapBuffer (); + this.table_heap = new TableHeapBuffer (module, this); + + this.type_ref_table = GetTable (Table.TypeRef); + this.type_def_table = GetTable (Table.TypeDef); + this.field_table = GetTable (Table.Field); + this.method_table = GetTable (Table.Method); + this.param_table = GetTable (Table.Param); + this.iface_impl_table = GetTable (Table.InterfaceImpl); + this.member_ref_table = GetTable (Table.MemberRef); + this.constant_table = GetTable (Table.Constant); + this.custom_attribute_table = GetTable (Table.CustomAttribute); + this.declsec_table = GetTable (Table.DeclSecurity); + this.standalone_sig_table = GetTable (Table.StandAloneSig); + this.event_map_table = GetTable (Table.EventMap); + this.event_table = GetTable (Table.Event); + this.property_map_table = GetTable (Table.PropertyMap); + this.property_table = GetTable (Table.Property); + this.typespec_table = GetTable (Table.TypeSpec); + this.method_spec_table = GetTable (Table.MethodSpec); + + var row_equality_comparer = new RowEqualityComparer (); + type_ref_map = new Dictionary (row_equality_comparer); + type_spec_map = new Dictionary (); + member_ref_map = new Dictionary (row_equality_comparer); + method_spec_map = new Dictionary (row_equality_comparer); + generic_parameters = new Collection (); + if (write_symbols) + method_def_map = new Dictionary (); + } + + TextMap CreateTextMap () + { + var map = new TextMap (); + map.AddMap (TextSegment.ImportAddressTable, module.Architecture == TargetArchitecture.I386 ? 8 : 16); + map.AddMap (TextSegment.CLIHeader, 0x48, 8); + return map; + } + + TTable GetTable (Table table) where TTable : MetadataTable, new () + { + return table_heap.GetTable (table); + } + + uint GetStringIndex (string @string) + { + if (string.IsNullOrEmpty (@string)) + return 0; + + return string_heap.GetStringIndex (@string); + } + + uint GetBlobIndex (ByteBuffer blob) + { + if (blob.length == 0) + return 0; + + return blob_heap.GetBlobIndex (blob); + } + + uint GetBlobIndex (byte [] blob) + { + if (blob.IsNullOrEmpty ()) + return 0; + + return GetBlobIndex (new ByteBuffer (blob)); + } + + public void BuildMetadata () + { + BuildModule (); + + table_heap.WriteTableHeap (); + } + + void BuildModule () + { + var table = GetTable (Table.Module); + table.row = GetStringIndex (module.Name); + + var assembly = module.Assembly; + + if (assembly != null) + BuildAssembly (); + + if (module.HasAssemblyReferences) + AddAssemblyReferences (); + + if (module.HasModuleReferences) + AddModuleReferences (); + + if (module.HasResources) + AddResources (); + + if (module.HasExportedTypes) + AddExportedTypes (); + + BuildTypes (); + + if (assembly != null) { + if (assembly.HasCustomAttributes) + AddCustomAttributes (assembly); + + if (assembly.HasSecurityDeclarations) + AddSecurityDeclarations (assembly); + } + + if (module.HasCustomAttributes) + AddCustomAttributes (module); + + if (module.EntryPoint != null) + entry_point = LookupToken (module.EntryPoint); + } + + void BuildAssembly () + { + var assembly = module.Assembly; + var name = assembly.Name; + + var table = GetTable (Table.Assembly); + + table.row = new AssemblyRow ( + name.HashAlgorithm, + (ushort) name.Version.Major, + (ushort) name.Version.Minor, + (ushort) name.Version.Build, + (ushort) name.Version.Revision, + name.Attributes, + GetBlobIndex (name.PublicKey), + GetStringIndex (name.Name), + GetStringIndex (name.Culture)); + + if (assembly.Modules.Count > 1) + BuildModules (); + } + + void BuildModules () + { + var modules = this.module.Assembly.Modules; + var table = GetTable (Table.File); + + for (int i = 0; i < modules.Count; i++) { + var module = modules [i]; + if (module.IsMain) + continue; + + var parameters = new WriterParameters { + SymbolWriterProvider = symbol_writer_provider, + }; + + var file_name = GetModuleFileName (module.Name); + module.Write (file_name, parameters); + + var hash = CryptoService.ComputeHash (file_name); + + table.AddRow (new FileRow ( + FileAttributes.ContainsMetaData, + GetStringIndex (module.Name), + GetBlobIndex (hash))); + } + } + + string GetModuleFileName (string name) + { + if (string.IsNullOrEmpty (name)) + throw new NotSupportedException (); + + var path = Path.GetDirectoryName (fq_name); + return Path.Combine (path, name); + } + + void AddAssemblyReferences () + { + var references = module.AssemblyReferences; + var table = GetTable (Table.AssemblyRef); + + for (int i = 0; i < references.Count; i++) { + var reference = references [i]; + + var key_or_token = reference.PublicKey.IsNullOrEmpty () + ? reference.PublicKeyToken + : reference.PublicKey; + + var rid = table.AddRow (new AssemblyRefRow ( + (ushort) reference.Version.Major, + (ushort) reference.Version.Minor, + (ushort) reference.Version.Build, + (ushort) reference.Version.Revision, + reference.Attributes, + GetBlobIndex (key_or_token), + GetStringIndex (reference.Name), + GetStringIndex (reference.Culture), + GetBlobIndex (reference.Hash))); + + reference.token = new MetadataToken (TokenType.AssemblyRef, rid); + } + } + + void AddModuleReferences () + { + var references = module.ModuleReferences; + var table = GetTable (Table.ModuleRef); + + for (int i = 0; i < references.Count; i++) { + var reference = references [i]; + + reference.token = new MetadataToken ( + TokenType.ModuleRef, + table.AddRow (GetStringIndex (reference.Name))); + } + } + + void AddResources () + { + var resources = module.Resources; + var table = GetTable (Table.ManifestResource); + + for (int i = 0; i < resources.Count; i++) { + var resource = resources [i]; + + var row = new ManifestResourceRow ( + 0, + resource.Attributes, + GetStringIndex (resource.Name), + 0); + + switch (resource.ResourceType) { + case ResourceType.Embedded: + row.Col1 = AddEmbeddedResource ((EmbeddedResource) resource); + break; + case ResourceType.Linked: + row.Col4 = CodedIndex.Implementation.CompressMetadataToken ( + new MetadataToken ( + TokenType.File, + AddLinkedResource ((LinkedResource) resource))); + break; + case ResourceType.AssemblyLinked: + row.Col4 = CodedIndex.Implementation.CompressMetadataToken ( + ((AssemblyLinkedResource) resource).Assembly.MetadataToken); + break; + default: + throw new NotSupportedException (); + } + + table.AddRow (row); + } + } + + uint AddLinkedResource (LinkedResource resource) + { + var table = GetTable (Table.File); + + var hash = resource.Hash.IsNullOrEmpty () + ? CryptoService.ComputeHash (resource.File) + : resource.Hash; + + return (uint) table.AddRow (new FileRow ( + FileAttributes.ContainsNoMetaData, + GetStringIndex (resource.File), + GetBlobIndex (hash))); + } + + uint AddEmbeddedResource (EmbeddedResource resource) + { + return resources.AddResource (resource.GetResourceData ()); + } + + void AddExportedTypes () + { + var exported_types = module.ExportedTypes; + var table = GetTable (Table.ExportedType); + + for (int i = 0; i < exported_types.Count; i++) { + var exported_type = exported_types [i]; + + var rid = table.AddRow (new ExportedTypeRow ( + exported_type.Attributes, + (uint) exported_type.Identifier, + GetStringIndex (exported_type.Name), + GetStringIndex (exported_type.Namespace), + MakeCodedRID (GetExportedTypeScope (exported_type), CodedIndex.Implementation))); + + exported_type.token = new MetadataToken (TokenType.ExportedType, rid); + } + } + + MetadataToken GetExportedTypeScope (ExportedType exported_type) + { + if (exported_type.DeclaringType != null) + return exported_type.DeclaringType.MetadataToken; + + var scope = exported_type.Scope; + switch (scope.MetadataToken.TokenType) { + case TokenType.AssemblyRef: + return scope.MetadataToken; + case TokenType.ModuleRef: + var file_table = GetTable (Table.File); + for (int i = 0; i < file_table.length; i++) + if (file_table.rows [i].Col2 == GetStringIndex (scope.Name)) + return new MetadataToken (TokenType.File, i + 1); + + break; + } + + throw new NotSupportedException (); + } + + void BuildTypes () + { + if (!module.HasTypes) + return; + + AttachTokens (); + AddTypeDefs (); + AddGenericParameters (); + } + + void AttachTokens () + { + var types = module.Types; + + for (int i = 0; i < types.Count; i++) + AttachTypeDefToken (types [i]); + } + + void AttachTypeDefToken (TypeDefinition type) + { + type.token = new MetadataToken (TokenType.TypeDef, type_rid++); + type.fields_range.Start = field_rid; + type.methods_range.Start = method_rid; + + if (type.HasFields) + AttachFieldsDefToken (type); + + if (type.HasMethods) + AttachMethodsDefToken (type); + + if (type.HasNestedTypes) + AttachNestedTypesDefToken (type); + } + + void AttachNestedTypesDefToken (TypeDefinition type) + { + var nested_types = type.NestedTypes; + for (int i = 0; i < nested_types.Count; i++) + AttachTypeDefToken (nested_types [i]); + } + + void AttachFieldsDefToken (TypeDefinition type) + { + var fields = type.Fields; + type.fields_range.Length = (uint) fields.Count; + for (int i = 0; i < fields.Count; i++) + fields [i].token = new MetadataToken (TokenType.Field, field_rid++); + } + + void AttachMethodsDefToken (TypeDefinition type) + { + var methods = type.Methods; + type.methods_range.Length = (uint) methods.Count; + for (int i = 0; i < methods.Count; i++) { + var method = methods [i]; + var new_token = new MetadataToken (TokenType.Method, method_rid++); + + if (write_symbols && method.token != MetadataToken.Zero) + method_def_map.Add (new_token, method.token); + + method.token = new_token; + } + } + + public bool TryGetOriginalMethodToken (MetadataToken new_token, out MetadataToken original) + { + return method_def_map.TryGetValue (new_token, out original); + } + + MetadataToken GetTypeToken (TypeReference type) + { + if (type == null) + return MetadataToken.Zero; + + if (type.IsDefinition) + return type.token; + + if (type.IsTypeSpecification ()) + return GetTypeSpecToken (type); + + return GetTypeRefToken (type); + } + + MetadataToken GetTypeSpecToken (TypeReference type) + { + var row = GetBlobIndex (GetTypeSpecSignature (type)); + + MetadataToken token; + if (type_spec_map.TryGetValue (row, out token)) + return token; + + return AddTypeSpecification (type, row); + } + + MetadataToken AddTypeSpecification (TypeReference type, uint row) + { + type.token = new MetadataToken (TokenType.TypeSpec, typespec_table.AddRow (row)); + + var token = type.token; + type_spec_map.Add (row, token); + return token; + } + + MetadataToken GetTypeRefToken (TypeReference type) + { + var row = CreateTypeRefRow (type); + + MetadataToken token; + if (type_ref_map.TryGetValue (row, out token)) + return token; + + return AddTypeReference (type, row); + } + + TypeRefRow CreateTypeRefRow (TypeReference type) + { + var scope_token = type.IsNested + ? GetTypeRefToken (type.DeclaringType) + : type.Scope.MetadataToken; + + return new TypeRefRow ( + MakeCodedRID (scope_token, CodedIndex.ResolutionScope), + GetStringIndex (type.Name), + GetStringIndex (type.Namespace)); + } + + static CodedRID MakeCodedRID (IMetadataTokenProvider provider, CodedIndex index) + { + return MakeCodedRID (provider.MetadataToken, index); + } + + static CodedRID MakeCodedRID (MetadataToken token, CodedIndex index) + { + return index.CompressMetadataToken (token); + } + + MetadataToken AddTypeReference (TypeReference type, TypeRefRow row) + { + type.token = new MetadataToken (TokenType.TypeRef, type_ref_table.AddRow (row)); + + var token = type.token; + type_ref_map.Add (row, token); + return token; + } + + void AddTypeDefs () + { + var types = module.Types; + + for (int i = 0; i < types.Count; i++) + AddType (types [i]); + } + + void AddType (TypeDefinition type) + { + type_def_table.AddRow (new TypeDefRow ( + type.Attributes, + GetStringIndex (type.Name), + GetStringIndex (type.Namespace), + MakeCodedRID (GetTypeToken (type.BaseType), CodedIndex.TypeDefOrRef), + type.fields_range.Start, + type.methods_range.Start)); + + if (type.HasGenericParameters) + AddGenericParameters (type); + + if (type.HasInterfaces) + AddInterfaces (type); + + if (type.HasLayoutInfo) + AddLayoutInfo (type); + + if (type.HasFields) + AddFields (type); + + if (type.HasMethods) + AddMethods (type); + + if (type.HasProperties) + AddProperties (type); + + if (type.HasEvents) + AddEvents (type); + + if (type.HasCustomAttributes) + AddCustomAttributes (type); + + if (type.HasSecurityDeclarations) + AddSecurityDeclarations (type); + + if (type.HasNestedTypes) + AddNestedTypes (type); + } + + void AddGenericParameters (IGenericParameterProvider owner) + { + var parameters = owner.GenericParameters; + + for (int i = 0; i < parameters.Count; i++) + generic_parameters.Add (parameters [i]); + } + + sealed class GenericParameterComparer : IComparer { + + public int Compare (GenericParameter a, GenericParameter b) + { + var a_owner = MakeCodedRID (a.Owner, CodedIndex.TypeOrMethodDef); + var b_owner = MakeCodedRID (b.Owner, CodedIndex.TypeOrMethodDef); + if (a_owner == b_owner) { + var a_pos = a.Position; + var b_pos = b.Position; + return a_pos == b_pos ? 0 : a_pos > b_pos ? 1 : -1; + } + + return a_owner > b_owner ? 1 : -1; + } + } + + void AddGenericParameters () + { + var items = this.generic_parameters.items; + var size = this.generic_parameters.size; + Array.Sort (items, 0, size, new GenericParameterComparer ()); + + var generic_param_table = GetTable (Table.GenericParam); + var generic_param_constraint_table = GetTable (Table.GenericParamConstraint); + + for (int i = 0; i < size; i++) { + var generic_parameter = items [i]; + + var rid = generic_param_table.AddRow (new GenericParamRow ( + (ushort) generic_parameter.Position, + generic_parameter.Attributes, + MakeCodedRID (generic_parameter.Owner, CodedIndex.TypeOrMethodDef), + GetStringIndex (generic_parameter.Name))); + + generic_parameter.token = new MetadataToken (TokenType.GenericParam, rid); + + if (generic_parameter.HasConstraints) + AddConstraints (generic_parameter, generic_param_constraint_table); + + if (generic_parameter.HasCustomAttributes) + AddCustomAttributes (generic_parameter); + } + } + + void AddConstraints (GenericParameter generic_parameter, GenericParamConstraintTable table) + { + var constraints = generic_parameter.Constraints; + + var rid = generic_parameter.token.RID; + + for (int i = 0; i < constraints.Count; i++) + table.AddRow (new GenericParamConstraintRow ( + rid, + MakeCodedRID (GetTypeToken (constraints [i]), CodedIndex.TypeDefOrRef))); + } + + void AddInterfaces (TypeDefinition type) + { + var interfaces = type.Interfaces; + var type_rid = type.token.RID; + + for (int i = 0; i < interfaces.Count; i++) + iface_impl_table.AddRow (new InterfaceImplRow ( + type_rid, + MakeCodedRID (GetTypeToken (interfaces [i]), CodedIndex.TypeDefOrRef))); + } + + void AddLayoutInfo (TypeDefinition type) + { + var table = GetTable (Table.ClassLayout); + + table.AddRow (new ClassLayoutRow ( + (ushort) type.PackingSize, + (uint) type.ClassSize, + type.token.RID)); + } + + void AddNestedTypes (TypeDefinition type) + { + var nested_types = type.NestedTypes; + var nested_table = GetTable (Table.NestedClass); + + for (int i = 0; i < nested_types.Count; i++) { + var nested = nested_types [i]; + AddType (nested); + nested_table.AddRow (new NestedClassRow (nested.token.RID, type.token.RID)); + } + } + + void AddFields (TypeDefinition type) + { + var fields = type.Fields; + + for (int i = 0; i < fields.Count; i++) + AddField (fields [i]); + } + + void AddField (FieldDefinition field) + { + field_table.AddRow (new FieldRow ( + field.Attributes, + GetStringIndex (field.Name), + GetBlobIndex (GetFieldSignature (field)))); + + if (!field.InitialValue.IsNullOrEmpty ()) + AddFieldRVA (field); + + if (field.HasLayoutInfo) + AddFieldLayout (field); + + if (field.HasCustomAttributes) + AddCustomAttributes (field); + + if (field.HasConstant) + AddConstant (field, field.FieldType); + + if (field.HasMarshalInfo) + AddMarshalInfo (field); + } + + void AddFieldRVA (FieldDefinition field) + { + var table = GetTable (Table.FieldRVA); + table.AddRow (new FieldRVARow ( + data.AddData (field.InitialValue), + field.token.RID)); + } + + void AddFieldLayout (FieldDefinition field) + { + var table = GetTable (Table.FieldLayout); + table.AddRow (new FieldLayoutRow ((uint) field.Offset, field.token.RID)); + } + + void AddMethods (TypeDefinition type) + { + var methods = type.Methods; + + for (int i = 0; i < methods.Count; i++) + AddMethod (methods [i]); + } + + void AddMethod (MethodDefinition method) + { + method_table.AddRow (new MethodRow ( + method.HasBody ? code.WriteMethodBody (method) : 0, + method.ImplAttributes, + method.Attributes, + GetStringIndex (method.Name), + GetBlobIndex (GetMethodSignature (method)), + param_rid)); + + AddParameters (method); + + if (method.HasGenericParameters) + AddGenericParameters (method); + + if (method.IsPInvokeImpl) + AddPInvokeInfo (method); + + if (method.HasCustomAttributes) + AddCustomAttributes (method); + + if (method.HasSecurityDeclarations) + AddSecurityDeclarations (method); + + if (method.HasOverrides) + AddOverrides (method); + } + + void AddParameters (MethodDefinition method) + { + var return_parameter = method.MethodReturnType.parameter; + + if (return_parameter != null && RequiresParameterRow (return_parameter)) + AddParameter (0, return_parameter, param_table); + + if (!method.HasParameters) + return; + + var parameters = method.Parameters; + + for (int i = 0; i < parameters.Count; i++) { + var parameter = parameters [i]; + if (!RequiresParameterRow (parameter)) + continue; + + AddParameter ((ushort) (i + 1), parameter, param_table); + } + } + + void AddPInvokeInfo (MethodDefinition method) + { + var pinvoke = method.PInvokeInfo; + if (pinvoke == null) + throw new ArgumentException (); + + var table = GetTable (Table.ImplMap); + table.AddRow (new ImplMapRow ( + pinvoke.Attributes, + MakeCodedRID (method, CodedIndex.MemberForwarded), + GetStringIndex (pinvoke.EntryPoint), + pinvoke.Module.MetadataToken.RID)); + } + + void AddOverrides (MethodDefinition method) + { + var overrides = method.Overrides; + var table = GetTable (Table.MethodImpl); + + for (int i = 0; i < overrides.Count; i++) { + table.AddRow (new MethodImplRow ( + method.DeclaringType.token.RID, + MakeCodedRID (method, CodedIndex.MethodDefOrRef), + MakeCodedRID (LookupToken (overrides [i]), CodedIndex.MethodDefOrRef))); + } + } + + static bool RequiresParameterRow (ParameterDefinition parameter) + { + return !string.IsNullOrEmpty (parameter.Name) + || parameter.Attributes != ParameterAttributes.None + || parameter.HasMarshalInfo + || parameter.HasConstant + || parameter.HasCustomAttributes; + } + + void AddParameter (ushort sequence, ParameterDefinition parameter, ParamTable table) + { + table.AddRow (new ParamRow ( + parameter.Attributes, + sequence, + GetStringIndex (parameter.Name))); + + parameter.token = new MetadataToken (TokenType.Param, param_rid++); + + if (parameter.HasCustomAttributes) + AddCustomAttributes (parameter); + + if (parameter.HasConstant) + AddConstant (parameter, parameter.ParameterType); + + if (parameter.HasMarshalInfo) + AddMarshalInfo (parameter); + } + + void AddMarshalInfo (IMarshalInfoProvider owner) + { + var table = GetTable (Table.FieldMarshal); + + table.AddRow (new FieldMarshalRow ( + MakeCodedRID (owner, CodedIndex.HasFieldMarshal), + GetBlobIndex (GetMarshalInfoSignature (owner)))); + } + + void AddProperties (TypeDefinition type) + { + var properties = type.Properties; + + property_map_table.AddRow (new PropertyMapRow (type.token.RID, property_rid)); + + for (int i = 0; i < properties.Count; i++) + AddProperty (properties [i]); + } + + void AddProperty (PropertyDefinition property) + { + property_table.AddRow (new PropertyRow ( + property.Attributes, + GetStringIndex (property.Name), + GetBlobIndex (GetPropertySignature (property)))); + property.token = new MetadataToken (TokenType.Property, property_rid++); + + var method = property.GetMethod; + if (method != null) + AddSemantic (MethodSemanticsAttributes.Getter, property, method); + + method = property.SetMethod; + if (method != null) + AddSemantic (MethodSemanticsAttributes.Setter, property, method); + + if (property.HasOtherMethods) + AddOtherSemantic (property, property.OtherMethods); + + if (property.HasCustomAttributes) + AddCustomAttributes (property); + + if (property.HasConstant) + AddConstant (property, property.PropertyType); + } + + void AddOtherSemantic (IMetadataTokenProvider owner, Collection others) + { + for (int i = 0; i < others.Count; i++) + AddSemantic (MethodSemanticsAttributes.Other, owner, others [i]); + } + + void AddEvents (TypeDefinition type) + { + var events = type.Events; + + event_map_table.AddRow (new EventMapRow (type.token.RID, event_rid)); + + for (int i = 0; i < events.Count; i++) + AddEvent (events [i]); + } + + void AddEvent (EventDefinition @event) + { + event_table.AddRow (new EventRow ( + @event.Attributes, + GetStringIndex (@event.Name), + MakeCodedRID (GetTypeToken (@event.EventType), CodedIndex.TypeDefOrRef))); + @event.token = new MetadataToken (TokenType.Event, event_rid++); + + var method = @event.AddMethod; + if (method != null) + AddSemantic (MethodSemanticsAttributes.AddOn, @event, method); + + method = @event.InvokeMethod; + if (method != null) + AddSemantic (MethodSemanticsAttributes.Fire, @event, method); + + method = @event.RemoveMethod; + if (method != null) + AddSemantic (MethodSemanticsAttributes.RemoveOn, @event, method); + + if (@event.HasOtherMethods) + AddOtherSemantic (@event, @event.OtherMethods); + + if (@event.HasCustomAttributes) + AddCustomAttributes (@event); + } + + void AddSemantic (MethodSemanticsAttributes semantics, IMetadataTokenProvider provider, MethodDefinition method) + { + method.SemanticsAttributes = semantics; + var table = GetTable (Table.MethodSemantics); + + table.AddRow (new MethodSemanticsRow ( + semantics, + method.token.RID, + MakeCodedRID (provider, CodedIndex.HasSemantics))); + } + + void AddConstant (IConstantProvider owner, TypeReference type) + { + var constant = owner.Constant; + var etype = GetConstantType (type, constant); + + constant_table.AddRow (new ConstantRow ( + etype, + MakeCodedRID (owner.MetadataToken, CodedIndex.HasConstant), + GetBlobIndex (GetConstantSignature (etype, constant)))); + } + + static ElementType GetConstantType (TypeReference constant_type, object constant) + { + if (constant == null) + return ElementType.Class; + + var etype = constant_type.etype; + switch (etype) { + case ElementType.None: + var type = constant_type.CheckedResolve (); + if (type.IsEnum) + return GetConstantType (type.GetEnumUnderlyingType (), constant); + + return ElementType.Class; + case ElementType.String: + return ElementType.String; + case ElementType.Object: + return GetConstantType (constant.GetType ()); + case ElementType.Array: + case ElementType.SzArray: + case ElementType.MVar: + case ElementType.Var: + return ElementType.Class; + case ElementType.GenericInst: + case ElementType.CModOpt: + case ElementType.CModReqD: + case ElementType.ByRef: + case ElementType.Sentinel: + return GetConstantType (((TypeSpecification) constant_type).ElementType, constant); + case ElementType.Boolean: + case ElementType.Char: + case ElementType.I: + case ElementType.I1: + case ElementType.I2: + case ElementType.I4: + case ElementType.I8: + case ElementType.U: + case ElementType.U1: + case ElementType.U2: + case ElementType.U4: + case ElementType.U8: + case ElementType.R4: + case ElementType.R8: + return GetConstantType (constant.GetType ()); + default: + return etype; + } + } + + static ElementType GetConstantType (Type type) + { + switch (Type.GetTypeCode (type)) { + case TypeCode.Boolean: + return ElementType.Boolean; + case TypeCode.Byte: + return ElementType.U1; + case TypeCode.SByte: + return ElementType.I1; + case TypeCode.Char: + return ElementType.Char; + case TypeCode.Int16: + return ElementType.I2; + case TypeCode.UInt16: + return ElementType.U2; + case TypeCode.Int32: + return ElementType.I4; + case TypeCode.UInt32: + return ElementType.U4; + case TypeCode.Int64: + return ElementType.I8; + case TypeCode.UInt64: + return ElementType.U8; + case TypeCode.Single: + return ElementType.R4; + case TypeCode.Double: + return ElementType.R8; + case TypeCode.String: + return ElementType.String; + default: + throw new NotSupportedException (type.FullName); + } + } + + void AddCustomAttributes (ICustomAttributeProvider owner) + { + var custom_attributes = owner.CustomAttributes; + + for (int i = 0; i < custom_attributes.Count; i++) { + var attribute = custom_attributes [i]; + + custom_attribute_table.AddRow (new CustomAttributeRow ( + MakeCodedRID (owner, CodedIndex.HasCustomAttribute), + MakeCodedRID (LookupToken (attribute.Constructor), CodedIndex.CustomAttributeType), + GetBlobIndex (GetCustomAttributeSignature (attribute)))); + } + } + + void AddSecurityDeclarations (ISecurityDeclarationProvider owner) + { + var declarations = owner.SecurityDeclarations; + + for (int i = 0; i < declarations.Count; i++) { + var declaration = declarations [i]; + + declsec_table.AddRow (new DeclSecurityRow ( + declaration.Action, + MakeCodedRID (owner, CodedIndex.HasDeclSecurity), + GetBlobIndex (GetSecurityDeclarationSignature (declaration)))); + } + } + + MetadataToken GetMemberRefToken (MemberReference member) + { + var row = CreateMemberRefRow (member); + + MetadataToken token; + if (member_ref_map.TryGetValue (row, out token)) + return token; + + AddMemberReference (member, row); + + return member.token; + } + + MemberRefRow CreateMemberRefRow (MemberReference member) + { + return new MemberRefRow ( + MakeCodedRID (GetTypeToken (member.DeclaringType), CodedIndex.MemberRefParent), + GetStringIndex (member.Name), + GetBlobIndex (GetMemberRefSignature (member))); + } + + void AddMemberReference (MemberReference member, MemberRefRow row) + { + member.token = new MetadataToken (TokenType.MemberRef, member_ref_table.AddRow (row)); + member_ref_map.Add (row, member.token); + } + + MetadataToken GetMethodSpecToken (MethodSpecification method_spec) + { + var row = CreateMethodSpecRow (method_spec); + + MetadataToken token; + if (method_spec_map.TryGetValue (row, out token)) + return token; + + AddMethodSpecification (method_spec, row); + + return method_spec.token; + } + + void AddMethodSpecification (MethodSpecification method_spec, MethodSpecRow row) + { + method_spec.token = new MetadataToken (TokenType.MethodSpec, method_spec_table.AddRow (row)); + method_spec_map.Add (row, method_spec.token); + } + + MethodSpecRow CreateMethodSpecRow (MethodSpecification method_spec) + { + return new MethodSpecRow ( + MakeCodedRID (LookupToken (method_spec.ElementMethod), CodedIndex.MethodDefOrRef), + GetBlobIndex (GetMethodSpecSignature (method_spec))); + } + + SignatureWriter CreateSignatureWriter () + { + return new SignatureWriter (this); + } + + SignatureWriter GetMethodSpecSignature (MethodSpecification method_spec) + { + if (!method_spec.IsGenericInstance) + throw new NotSupportedException (); + + var generic_instance = (GenericInstanceMethod) method_spec; + + var signature = CreateSignatureWriter (); + signature.WriteByte (0x0a); + + signature.WriteGenericInstanceSignature (generic_instance); + + return signature; + } + + public uint AddStandAloneSignature (uint signature) + { + return (uint) standalone_sig_table.AddRow (signature); + } + + public uint GetLocalVariableBlobIndex (Collection variables) + { + return GetBlobIndex (GetVariablesSignature (variables)); + } + + public uint GetCallSiteBlobIndex (CallSite call_site) + { + return GetBlobIndex (GetMethodSignature (call_site)); + } + + SignatureWriter GetVariablesSignature (Collection variables) + { + var signature = CreateSignatureWriter (); + signature.WriteByte (0x7); + signature.WriteCompressedUInt32 ((uint) variables.Count); + for (int i = 0; i < variables.Count; i++) + signature.WriteTypeSignature (variables [i].VariableType); + return signature; + } + + SignatureWriter GetFieldSignature (FieldReference field) + { + var signature = CreateSignatureWriter (); + signature.WriteByte (0x6); + signature.WriteTypeSignature (field.FieldType); + return signature; + } + + SignatureWriter GetMethodSignature (IMethodSignature method) + { + var signature = CreateSignatureWriter (); + signature.WriteMethodSignature (method); + return signature; + } + + SignatureWriter GetMemberRefSignature (MemberReference member) + { + var field = member as FieldReference; + if (field != null) + return GetFieldSignature (field); + + var method = member as MethodReference; + if (method != null) + return GetMethodSignature (method); + + throw new NotSupportedException (); + } + + SignatureWriter GetPropertySignature (PropertyDefinition property) + { + var signature = CreateSignatureWriter (); + byte calling_convention = 0x8; + if (property.HasThis) + calling_convention |= 0x20; + + uint param_count = 0; + Collection parameters = null; + + if (property.HasParameters) { + parameters = property.Parameters; + param_count = (uint) parameters.Count; + } + + signature.WriteByte (calling_convention); + signature.WriteCompressedUInt32 (param_count); + signature.WriteTypeSignature (property.PropertyType); + + if (param_count == 0) + return signature; + + for (int i = 0; i < param_count; i++) + signature.WriteTypeSignature (parameters [i].ParameterType); + + return signature; + } + + SignatureWriter GetTypeSpecSignature (TypeReference type) + { + var signature = CreateSignatureWriter (); + signature.WriteTypeSignature (type); + return signature; + } + + SignatureWriter GetConstantSignature (ElementType type, object value) + { + var signature = CreateSignatureWriter (); + + switch (type) { + case ElementType.Array: + case ElementType.SzArray: + case ElementType.Class: + case ElementType.Object: + case ElementType.Var: + case ElementType.MVar: + signature.WriteInt32 (0); + break; + case ElementType.String: + signature.WriteConstantString ((string) value); + break; + default: + signature.WriteConstantPrimitive (value); + break; + } + + return signature; + } + + SignatureWriter GetCustomAttributeSignature (CustomAttribute attribute) + { + var signature = CreateSignatureWriter (); + if (!attribute.resolved) { + signature.WriteBytes (attribute.GetBlob ()); + return signature; + } + + signature.WriteUInt16 (0x0001); + + signature.WriteCustomAttributeConstructorArguments (attribute); + + signature.WriteCustomAttributeNamedArguments (attribute); + + return signature; + } + + SignatureWriter GetSecurityDeclarationSignature (SecurityDeclaration declaration) + { + var signature = CreateSignatureWriter (); + if (!declaration.resolved) { + signature.WriteBytes (declaration.GetBlob ()); + return signature; + } + + signature.WriteByte ((byte) '.'); + + var attributes = declaration.security_attributes; + if (attributes == null) + throw new NotSupportedException (); + + signature.WriteCompressedUInt32 ((uint) attributes.Count); + + for (int i = 0; i < attributes.Count; i++) + signature.WriteSecurityAttribute (attributes [i]); + + return signature; + } + + SignatureWriter GetMarshalInfoSignature (IMarshalInfoProvider owner) + { + var signature = CreateSignatureWriter (); + + signature.WriteMarshalInfo (owner.MarshalInfo); + + return signature; + } + + static Exception CreateForeignMemberException (MemberReference member) + { + return new ArgumentException (string.Format ("Member '{0}' is declared in another module and needs to be imported", member)); + } + + public MetadataToken LookupToken (IMetadataTokenProvider provider) + { + if (provider == null) + throw new ArgumentNullException (); + + var member = provider as MemberReference; + if (member == null || member.Module != module) + throw CreateForeignMemberException (member); + + var token = provider.MetadataToken; + + switch (token.TokenType) { + case TokenType.TypeDef: + case TokenType.Method: + case TokenType.Field: + case TokenType.Event: + case TokenType.Property: + return token; + case TokenType.TypeRef: + case TokenType.TypeSpec: + case TokenType.GenericParam: + return GetTypeToken ((TypeReference) provider); + case TokenType.MethodSpec: + return GetMethodSpecToken ((MethodSpecification) provider); + case TokenType.MemberRef: + return GetMemberRefToken (member); + default: + throw new NotSupportedException (); + } + } + } + + sealed class SignatureWriter : ByteBuffer { + + readonly MetadataBuilder metadata; + + public SignatureWriter (MetadataBuilder metadata) + : base (6) + { + this.metadata = metadata; + } + + public void WriteElementType (ElementType element_type) + { + WriteByte ((byte) element_type); + } + + public void WriteUTF8String (string @string) + { + if (@string == null) { + WriteByte (0xff); + return; + } + + var bytes = Encoding.UTF8.GetBytes (@string); + WriteCompressedUInt32 ((uint) bytes.Length); + WriteBytes (bytes); + } + + public void WriteMethodSignature (IMethodSignature method) + { + byte calling_convention = (byte) method.CallingConvention; + if (method.HasThis) + calling_convention |= 0x20; + if (method.ExplicitThis) + calling_convention |= 0x40; + + var generic_provider = method as IGenericParameterProvider; + var generic_arity = generic_provider != null && generic_provider.HasGenericParameters + ? generic_provider.GenericParameters.Count + : 0; + + if (generic_arity > 0) + calling_convention |= 0x10; + + var param_count = method.HasParameters ? method.Parameters.Count : 0; + + WriteByte (calling_convention); + + if (generic_arity > 0) + WriteCompressedUInt32 ((uint) generic_arity); + + WriteCompressedUInt32 ((uint) param_count); + WriteTypeSignature (method.ReturnType); + + if (param_count == 0) + return; + + var parameters = method.Parameters; + + for (int i = 0; i < param_count; i++) + WriteTypeSignature (parameters [i].ParameterType); + } + + uint MakeTypeDefOrRefCodedRID (TypeReference type) + { + return CodedIndex.TypeDefOrRef.CompressMetadataToken (metadata.LookupToken (type)); + } + + public void WriteTypeSignature (TypeReference type) + { + if (type == null) + throw new ArgumentNullException (); + + var etype = type.etype; + + switch (etype) { + case ElementType.MVar: + case ElementType.Var: { + var generic_parameter = (GenericParameter) type; + + WriteElementType (etype); + var position = generic_parameter.Position; + if (position == -1) + throw new NotSupportedException (); + + WriteCompressedUInt32 ((uint) position); + break; + } + + case ElementType.GenericInst: { + var generic_instance = (GenericInstanceType) type; + WriteElementType (ElementType.GenericInst); + WriteElementType (generic_instance.IsValueType ? ElementType.ValueType : ElementType.Class); + WriteCompressedUInt32 (MakeTypeDefOrRefCodedRID (generic_instance.ElementType)); + + WriteGenericInstanceSignature (generic_instance); + break; + } + + case ElementType.Ptr: + case ElementType.ByRef: + case ElementType.Pinned: + case ElementType.Sentinel: { + var type_spec = (TypeSpecification) type; + WriteElementType (etype); + WriteTypeSignature (type_spec.ElementType); + break; + } + + case ElementType.FnPtr: { + var fptr = (FunctionPointerType) type; + WriteElementType (ElementType.FnPtr); + WriteMethodSignature (fptr); + break; + } + + case ElementType.CModOpt: + case ElementType.CModReqD: { + var modifier = (IModifierType) type; + WriteModifierSignature (etype, modifier); + break; + } + + case ElementType.Array: { + var array = (ArrayType) type; + if (!array.IsVector) { + WriteArrayTypeSignature (array); + break; + } + + WriteElementType (ElementType.SzArray); + WriteTypeSignature (array.ElementType); + break; + } + + case ElementType.None: { + WriteElementType (type.IsValueType ? ElementType.ValueType : ElementType.Class); + WriteCompressedUInt32 (MakeTypeDefOrRefCodedRID (type)); + break; + } + + default: + if (!TryWriteElementType (type)) + throw new NotSupportedException (); + + break; + + } + } + + void WriteArrayTypeSignature (ArrayType array) + { + WriteElementType (ElementType.Array); + WriteTypeSignature (array.ElementType); + + var dimensions = array.Dimensions; + var rank = dimensions.Count; + + WriteCompressedUInt32 ((uint) rank); + + var sized = 0; + var lbounds = 0; + + for (int i = 0; i < rank; i++) { + var dimension = dimensions [i]; + + if (dimension.UpperBound.HasValue) { + sized++; + lbounds++; + } else if (dimension.LowerBound.HasValue) + lbounds++; + } + + var sizes = new int [sized]; + var low_bounds = new int [lbounds]; + + for (int i = 0; i < lbounds; i++) { + var dimension = dimensions [i]; + low_bounds [i] = dimension.LowerBound.GetValueOrDefault (); + if (dimension.UpperBound.HasValue) + sizes [i] = dimension.UpperBound.Value - low_bounds [i] + 1; + } + + WriteCompressedUInt32 ((uint) sized); + for (int i = 0; i < sized; i++) + WriteCompressedUInt32 ((uint) sizes [i]); + + WriteCompressedUInt32 ((uint) lbounds); + for (int i = 0; i < lbounds; i++) + WriteCompressedInt32 (low_bounds [i]); + } + + public void WriteGenericInstanceSignature (IGenericInstance instance) + { + var generic_arguments = instance.GenericArguments; + var arity = generic_arguments.Count; + + WriteCompressedUInt32 ((uint) arity); + for (int i = 0; i < arity; i++) + WriteTypeSignature (generic_arguments [i]); + } + + void WriteModifierSignature (ElementType element_type, IModifierType type) + { + WriteElementType (element_type); + WriteCompressedUInt32 (MakeTypeDefOrRefCodedRID (type.ModifierType)); + WriteTypeSignature (type.ElementType); + } + + bool TryWriteElementType (TypeReference type) + { + var element = type.etype; + + if (element == ElementType.None) + return false; + + WriteElementType (element); + return true; + } + + public void WriteConstantString (string value) + { + WriteBytes (Encoding.Unicode.GetBytes (value)); + } + + public void WriteConstantPrimitive (object value) + { + WritePrimitiveValue (value); + } + + public void WriteCustomAttributeConstructorArguments (CustomAttribute attribute) + { + if (!attribute.HasConstructorArguments) + return; + + var arguments = attribute.ConstructorArguments; + var parameters = attribute.Constructor.Parameters; + + if (parameters.Count != arguments.Count) + throw new InvalidOperationException (); + + for (int i = 0; i < arguments.Count; i++) + WriteCustomAttributeFixedArgument (parameters [i].ParameterType, arguments [i]); + } + + void WriteCustomAttributeFixedArgument (TypeReference type, CustomAttributeArgument argument) + { + if (type.IsArray) { + WriteCustomAttributeFixedArrayArgument ((ArrayType) type, argument); + return; + } + + WriteCustomAttributeElement (type, argument); + } + + void WriteCustomAttributeFixedArrayArgument (ArrayType type, CustomAttributeArgument argument) + { + var values = argument.Value as CustomAttributeArgument []; + + if (values == null) { + WriteUInt32 (0xffffffff); + return; + } + + WriteInt32 (values.Length); + + if (values.Length == 0) + return; + + var element_type = type.ElementType; + + for (int i = 0; i < values.Length; i++) + WriteCustomAttributeElement (element_type, values [i]); + } + + void WriteCustomAttributeElement (TypeReference type, CustomAttributeArgument argument) + { + if (type.IsArray) { + WriteCustomAttributeFixedArrayArgument ((ArrayType) type, argument); + return; + } + + if (type.etype == ElementType.Object) { + WriteCustomAttributeFieldOrPropType (argument.Type); + WriteCustomAttributeElement (argument.Type, argument); + return; + } + + WriteCustomAttributeValue (type, argument.Value); + } + + void WriteCustomAttributeValue (TypeReference type, object value) + { + var etype = type.etype; + + switch (etype) { + case ElementType.String: + var @string = (string) value; + if (@string == null) + WriteByte (0xff); + else + WriteUTF8String (@string); + break; + case ElementType.None: + if (type.IsTypeOf ("System", "Type")) + WriteTypeReference ((TypeReference) value); + else + WriteCustomAttributeEnumValue (type, value); + break; + default: + WritePrimitiveValue (value); + break; + } + } + + void WritePrimitiveValue (object value) + { + if (value == null) + throw new ArgumentNullException (); + + switch (Type.GetTypeCode (value.GetType ())) { + case TypeCode.Boolean: + WriteByte ((byte) (((bool) value) ? 1 : 0)); + break; + case TypeCode.Byte: + WriteByte ((byte) value); + break; + case TypeCode.SByte: + WriteSByte ((sbyte) value); + break; + case TypeCode.Int16: + WriteInt16 ((short) value); + break; + case TypeCode.UInt16: + WriteUInt16 ((ushort) value); + break; + case TypeCode.Char: + WriteInt16 ((short) (char) value); + break; + case TypeCode.Int32: + WriteInt32 ((int) value); + break; + case TypeCode.UInt32: + WriteUInt32 ((uint) value); + break; + case TypeCode.Single: + WriteSingle ((float) value); + break; + case TypeCode.Int64: + WriteInt64 ((long) value); + break; + case TypeCode.UInt64: + WriteUInt64 ((ulong) value); + break; + case TypeCode.Double: + WriteDouble ((double) value); + break; + default: + throw new NotSupportedException (value.GetType ().FullName); + } + } + + void WriteCustomAttributeEnumValue (TypeReference enum_type, object value) + { + var type = enum_type.CheckedResolve (); + if (!type.IsEnum) + throw new ArgumentException (); + + WriteCustomAttributeValue (type.GetEnumUnderlyingType (), value); + } + + void WriteCustomAttributeFieldOrPropType (TypeReference type) + { + if (type.IsArray) { + var array = (ArrayType) type; + WriteElementType (ElementType.SzArray); + WriteCustomAttributeFieldOrPropType (array.ElementType); + return; + } + + var etype = type.etype; + + switch (etype) { + case ElementType.Object: + WriteElementType (ElementType.Boxed); + return; + case ElementType.None: + if (type.IsTypeOf ("System", "Type")) + WriteElementType (ElementType.Type); + else { + WriteElementType (ElementType.Enum); + WriteTypeReference (type); + } + return; + default: + WriteElementType (etype); + return; + } + } + + public void WriteCustomAttributeNamedArguments (CustomAttribute attribute) + { + var count = GetNamedArgumentCount (attribute); + + WriteUInt16 ((ushort) count); + + if (count == 0) + return; + + WriteICustomAttributeNamedArguments (attribute); + } + + static int GetNamedArgumentCount (ICustomAttribute attribute) + { + int count = 0; + + if (attribute.HasFields) + count += attribute.Fields.Count; + + if (attribute.HasProperties) + count += attribute.Properties.Count; + + return count; + } + + void WriteICustomAttributeNamedArguments (ICustomAttribute attribute) + { + if (attribute.HasFields) + WriteCustomAttributeNamedArguments (0x53, attribute.Fields); + + if (attribute.HasProperties) + WriteCustomAttributeNamedArguments (0x54, attribute.Properties); + } + + void WriteCustomAttributeNamedArguments (byte kind, Collection named_arguments) + { + for (int i = 0; i < named_arguments.Count; i++) + WriteCustomAttributeNamedArgument (kind, named_arguments [i]); + } + + void WriteCustomAttributeNamedArgument (byte kind, CustomAttributeNamedArgument named_argument) + { + var argument = named_argument.Argument; + + WriteByte (kind); + WriteCustomAttributeFieldOrPropType (argument.Type); + WriteUTF8String (named_argument.Name); + WriteCustomAttributeFixedArgument (argument.Type, argument); + } + + public void WriteSecurityAttribute (SecurityAttribute attribute) + { + WriteTypeReference (attribute.AttributeType); + + var count = GetNamedArgumentCount (attribute); + + if (count == 0) { + WriteCompressedUInt32 (0); // length + WriteCompressedUInt32 (0); // count + return; + } + + var buffer = new SignatureWriter (metadata); + buffer.WriteCompressedUInt32 ((uint) count); + buffer.WriteICustomAttributeNamedArguments (attribute); + + WriteCompressedUInt32 ((uint) buffer.length); + WriteBytes (buffer); + } + + void WriteTypeReference (TypeReference type) + { + WriteUTF8String (TypeParser.ToParseable (type)); + } + + public void WriteMarshalInfo (MarshalInfo marshal_info) + { + WriteNativeType (marshal_info.native); + + switch (marshal_info.native) { + case NativeType.Array: { + var array = (ArrayMarshalInfo) marshal_info; + if (array.element_type != NativeType.None) + WriteNativeType (array.element_type); + if (array.size_parameter_index > -1) + WriteCompressedUInt32 ((uint) array.size_parameter_index); + if (array.size > -1) + WriteCompressedUInt32 ((uint) array.size); + if (array.size_parameter_multiplier > -1) + WriteCompressedUInt32 ((uint) array.size_parameter_multiplier); + return; + } + case NativeType.SafeArray: { + var array = (SafeArrayMarshalInfo) marshal_info; + if (array.element_type != VariantType.None) + WriteVariantType (array.element_type); + return; + } + case NativeType.FixedArray: { + var array = (FixedArrayMarshalInfo) marshal_info; + if (array.size > -1) + WriteCompressedUInt32 ((uint) array.size); + if (array.element_type != NativeType.None) + WriteNativeType (array.element_type); + return; + } + case NativeType.FixedSysString: + var sys_string = (FixedSysStringMarshalInfo) marshal_info; + if (sys_string.size > -1) + WriteCompressedUInt32 ((uint) sys_string.size); + return; + case NativeType.CustomMarshaler: + var marshaler = (CustomMarshalInfo) marshal_info; + WriteUTF8String (marshaler.guid != Guid.Empty ? marshaler.guid.ToString () : string.Empty); + WriteUTF8String (marshaler.unmanaged_type); + WriteTypeReference (marshaler.managed_type); + WriteUTF8String (marshaler.cookie); + return; + } + } + + void WriteNativeType (NativeType native) + { + WriteByte ((byte) native); + } + + void WriteVariantType (VariantType variant) + { + WriteByte ((byte) variant); + } + } + +#endif + +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseAssemblyResolver.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseAssemblyResolver.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseAssemblyResolver.cs 2008-11-06 19:52:04.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseAssemblyResolver.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,88 +26,143 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +using Mono.Collections.Generic; + namespace Mono.Cecil { - using System; - using System.Collections; - using System.IO; - using SR = System.Reflection; - using System.Text; + public delegate AssemblyDefinition AssemblyResolveEventHandler (object sender, AssemblyNameReference reference); + + public sealed class AssemblyResolveEventArgs : EventArgs { + + readonly AssemblyNameReference reference; + + public AssemblyNameReference AssemblyReference { + get { return reference; } + } + + public AssemblyResolveEventArgs (AssemblyNameReference reference) + { + this.reference = reference; + } + } public abstract class BaseAssemblyResolver : IAssemblyResolver { - ArrayList m_directories; + static readonly bool on_mono = Type.GetType ("Mono.Runtime") != null; + + readonly Collection directories; + +#if !SILVERLIGHT && !CF + Collection gac_paths; +#endif public void AddSearchDirectory (string directory) { - m_directories.Add (directory); + directories.Add (directory); } public void RemoveSearchDirectory (string directory) { - m_directories.Remove (directory); + directories.Remove (directory); } public string [] GetSearchDirectories () { - return (string []) m_directories.ToArray (); + var directories = new string [this.directories.size]; + Array.Copy (this.directories.items, directories, directories.Length); + return directories; } public virtual AssemblyDefinition Resolve (string fullName) { - return Resolve (AssemblyNameReference.Parse (fullName)); + return Resolve (fullName, new ReaderParameters ()); } - public BaseAssemblyResolver () + public virtual AssemblyDefinition Resolve (string fullName, ReaderParameters parameters) + { + if (fullName == null) + throw new ArgumentNullException ("fullName"); + + return Resolve (AssemblyNameReference.Parse (fullName), parameters); + } + + public event AssemblyResolveEventHandler ResolveFailure; + + protected BaseAssemblyResolver () { - m_directories = new ArrayList (); - m_directories.Add ("."); - m_directories.Add ("bin"); + directories = new Collection (2) { ".", "bin" }; + } + + AssemblyDefinition GetAssembly (string file, ReaderParameters parameters) + { + if (parameters.AssemblyResolver == null) + parameters.AssemblyResolver = this; + + return ModuleDefinition.ReadModule (file, parameters).Assembly; } public virtual AssemblyDefinition Resolve (AssemblyNameReference name) { - AssemblyDefinition assembly; - string frameworkdir = Path.GetDirectoryName (typeof (object).Module.FullyQualifiedName); + return Resolve (name, new ReaderParameters ()); + } - assembly = SearchDirectory (name, m_directories); + public virtual AssemblyDefinition Resolve (AssemblyNameReference name, ReaderParameters parameters) + { + if (name == null) + throw new ArgumentNullException ("name"); + if (parameters == null) + parameters = new ReaderParameters (); + + var assembly = SearchDirectory (name, directories, parameters); if (assembly != null) return assembly; +#if !SILVERLIGHT && !CF + var framework_dir = Path.GetDirectoryName (typeof (object).Module.FullyQualifiedName); + if (IsZero (name.Version)) { - assembly = SearchDirectory (name, new string [] {frameworkdir}); + assembly = SearchDirectory (name, new [] { framework_dir }, parameters); if (assembly != null) return assembly; } -#if !CF_1_0 && !CF_2_0 if (name.Name == "mscorlib") { - assembly = GetCorlib (name); + assembly = GetCorlib (name, parameters); if (assembly != null) return assembly; } - assembly = GetAssemblyInGac (name); + assembly = GetAssemblyInGac (name, parameters); if (assembly != null) return assembly; -#endif - assembly = SearchDirectory (name, new string [] {frameworkdir}); + assembly = SearchDirectory (name, new [] { framework_dir }, parameters); if (assembly != null) return assembly; +#endif + + if (ResolveFailure != null) { + assembly = ResolveFailure (this, name); + if (assembly != null) + return assembly; + } throw new FileNotFoundException ("Could not resolve: " + name); } - static readonly string [] _extentions = new string [] { ".dll", ".exe" }; - - static AssemblyDefinition SearchDirectory (AssemblyNameReference name, IEnumerable directories) + AssemblyDefinition SearchDirectory (AssemblyNameReference name, IEnumerable directories, ReaderParameters parameters) { - foreach (string dir in directories) { - foreach (string ext in _extentions) { - string file = Path.Combine (dir, name.Name + ext); + var extensions = new [] { ".exe", ".dll" }; + foreach (var directory in directories) { + foreach (var extension in extensions) { + string file = Path.Combine (directory, name.Name + extension); if (File.Exists (file)) - return AssemblyFactory.GetAssembly (file); + return GetAssembly (file, parameters); } } @@ -116,95 +171,164 @@ static bool IsZero (Version version) { - return version.Major == 0 && version.Minor == 0 && version.Build == 0 && version.Revision == 0; + return version == null || (version.Major == 0 && version.Minor == 0 && version.Build == 0 && version.Revision == 0); } -#if !CF_1_0 && !CF_2_0 - static AssemblyDefinition GetCorlib (AssemblyNameReference reference) +#if !SILVERLIGHT && !CF + AssemblyDefinition GetCorlib (AssemblyNameReference reference, ReaderParameters parameters) { - SR.AssemblyName corlib = typeof (object).Assembly.GetName (); - if (corlib.Version == reference.Version || IsZero (reference.Version)) - return AssemblyFactory.GetAssembly (typeof (object).Module.FullyQualifiedName); + var version = reference.Version; + var corlib = typeof (object).Assembly.GetName (); - string path = Directory.GetParent ( + if (corlib.Version == version || IsZero (version)) + return GetAssembly (typeof (object).Module.FullyQualifiedName, parameters); + + var path = Directory.GetParent ( Directory.GetParent ( typeof (object).Module.FullyQualifiedName).FullName ).FullName; - if (OnMono ()) { - if (reference.Version.Major == 1) + if (on_mono) { + if (version.Major == 1) path = Path.Combine (path, "1.0"); - else if (reference.Version.Major == 2) - path = Path.Combine (path, "2.0"); + else if (version.Major == 2) { + if (version.MajorRevision == 5) + path = Path.Combine (path, "2.1"); + else + path = Path.Combine (path, "2.0"); + } else if (version.Major == 4) + path = Path.Combine (path, "4.0"); else - throw new NotSupportedException ("Version not supported: " + reference.Version); + throw new NotSupportedException ("Version not supported: " + version); } else { - if (reference.Version.ToString () == "1.0.3300.0") - path = Path.Combine (path, "v1.0.3705"); - else if (reference.Version.ToString () == "1.0.5000.0") - path = Path.Combine (path, "v1.1.4322"); - else if (reference.Version.ToString () == "2.0.0.0") + switch (version.Major) { + case 1: + if (version.MajorRevision == 3300) + path = Path.Combine (path, "v1.0.3705"); + else + path = Path.Combine (path, "v1.0.5000.0"); + break; + case 2: path = Path.Combine (path, "v2.0.50727"); - else - throw new NotSupportedException ("Version not supported: " + reference.Version); + break; + case 4: + path = Path.Combine (path, "v4.0.30319"); + break; + default: + throw new NotSupportedException ("Version not supported: " + version); + } } - if (File.Exists (Path.Combine (path, "mscorlib.dll"))) - return AssemblyFactory.GetAssembly (Path.Combine (path, "mscorlib.dll")); + var file = Path.Combine (path, "mscorlib.dll"); + if (File.Exists (file)) + return GetAssembly (file, parameters); return null; } - public static bool OnMono () + static Collection GetGacPaths () { - return typeof (object).Assembly.GetType ("System.MonoType", false) != null; + if (on_mono) + return GetDefaultMonoGacPaths (); + + var paths = new Collection (2); + var windir = Environment.GetEnvironmentVariable ("WINDIR"); + if (windir == null) + return paths; + + paths.Add (Path.Combine (windir, "assembly")); + paths.Add (Path.Combine (windir, Path.Combine ("Microsoft.NET", "assembly"))); + return paths; } - static AssemblyDefinition GetAssemblyInGac (AssemblyNameReference reference) + static Collection GetDefaultMonoGacPaths () + { + var paths = new Collection (1); + var gac = GetCurrentMonoGac (); + if (gac != null) + paths.Add (gac); + + var gac_paths_env = Environment.GetEnvironmentVariable ("MONO_GAC_PREFIX"); + if (string.IsNullOrEmpty (gac_paths_env)) + return paths; + + var prefixes = gac_paths_env.Split (Path.PathSeparator); + foreach (var prefix in prefixes) { + if (string.IsNullOrEmpty (prefix)) + continue; + + var gac_path = Path.Combine (Path.Combine (Path.Combine (prefix, "lib"), "mono"), "gac"); + if (Directory.Exists (gac_path) && !paths.Contains (gac)) + paths.Add (gac_path); + } + + return paths; + } + + static string GetCurrentMonoGac () + { + return Path.Combine ( + Directory.GetParent ( + Path.GetDirectoryName (typeof (object).Module.FullyQualifiedName)).FullName, + "gac"); + } + + AssemblyDefinition GetAssemblyInGac (AssemblyNameReference reference, ReaderParameters parameters) { if (reference.PublicKeyToken == null || reference.PublicKeyToken.Length == 0) return null; - string currentGac = GetCurrentGacPath (); - if (OnMono ()) { - string s = GetAssemblyFile (reference, currentGac); - if (File.Exists (s)) - return AssemblyFactory.GetAssembly (s); - } else { - string [] gacs = new string [] {"GAC_MSIL", "GAC_32", "GAC"}; - for (int i = 0; i < gacs.Length; i++) { - string gac = Path.Combine (Directory.GetParent (currentGac).FullName, gacs [i]); - string asm = GetAssemblyFile (reference, gac); - if (Directory.Exists (gac) && File.Exists (asm)) - return AssemblyFactory.GetAssembly (asm); + if (gac_paths == null) + gac_paths = GetGacPaths (); + + if (on_mono) + return GetAssemblyInMonoGac (reference, parameters); + + return GetAssemblyInNetGac (reference, parameters); + } + + AssemblyDefinition GetAssemblyInMonoGac (AssemblyNameReference reference, ReaderParameters parameters) + { + for (int i = 0; i < gac_paths.Count; i++) { + var gac_path = gac_paths [i]; + var file = GetAssemblyFile (reference, string.Empty, gac_path); + if (File.Exists (file)) + return GetAssembly (file, parameters); + } + + return null; + } + + AssemblyDefinition GetAssemblyInNetGac (AssemblyNameReference reference, ReaderParameters parameters) + { + var gacs = new [] { "GAC_MSIL", "GAC_32", "GAC" }; + var prefixes = new [] { string.Empty, "v4.0_" }; + + for (int i = 0; i < 2; i++) { + for (int j = 0; j < gacs.Length; j++) { + var gac = Path.Combine (gac_paths [i], gacs [j]); + var file = GetAssemblyFile (reference, prefixes [i], gac); + if (Directory.Exists (gac) && File.Exists (file)) + return GetAssembly (file, parameters); } } return null; } - static string GetAssemblyFile (AssemblyNameReference reference, string gac) + static string GetAssemblyFile (AssemblyNameReference reference, string prefix, string gac) { - StringBuilder sb = new StringBuilder (); - sb.Append (reference.Version); - sb.Append ("__"); + var gac_folder = new StringBuilder (); + gac_folder.Append (prefix); + gac_folder.Append (reference.Version); + gac_folder.Append ("__"); for (int i = 0; i < reference.PublicKeyToken.Length; i++) - sb.Append (reference.PublicKeyToken [i].ToString ("x2")); + gac_folder.Append (reference.PublicKeyToken [i].ToString ("x2")); return Path.Combine ( Path.Combine ( - Path.Combine (gac, reference.Name), sb.ToString ()), - string.Concat (reference.Name, ".dll")); - } - - static string GetCurrentGacPath () - { - return Directory.GetParent ( - Directory.GetParent ( - Path.GetDirectoryName ( - typeof (Uri).Module.FullyQualifiedName) - ).FullName - ).FullName; + Path.Combine (gac, reference.Name), gac_folder.ToString ()), + reference.Name + ".dll"); } #endif } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseReflectionReader.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseReflectionReader.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseReflectionReader.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseReflectionReader.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -// -// BaseReflectionReader.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - internal abstract class BaseReflectionReader : BaseReflectionVisitor, IDetailReader { - - public virtual void ReadSemantic (EventDefinition evt) - { - } - - public virtual void ReadSemantic (PropertyDefinition prop) - { - } - - public virtual void ReadMarshalSpec (ParameterDefinition param) - { - } - - public virtual void ReadMarshalSpec (FieldDefinition field) - { - } - - public virtual void ReadLayout (TypeDefinition type) - { - } - - public virtual void ReadLayout (FieldDefinition field) - { - } - - public virtual void ReadConstant (FieldDefinition field) - { - } - - public virtual void ReadConstant (PropertyDefinition prop) - { - } - - public virtual void ReadConstant (ParameterDefinition param) - { - } - - public virtual void ReadInitialValue (FieldDefinition field) - { - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseReflectionVisitor.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseReflectionVisitor.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseReflectionVisitor.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseReflectionVisitor.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,188 +0,0 @@ -// -// BaseReflectionVisitor.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System.Collections; - - public abstract class BaseReflectionVisitor : IReflectionVisitor { - - public virtual void VisitModuleDefinition (ModuleDefinition module) - { - } - - public virtual void VisitTypeDefinitionCollection (TypeDefinitionCollection types) - { - } - - public virtual void VisitTypeDefinition (TypeDefinition type) - { - } - - public virtual void VisitTypeReferenceCollection (TypeReferenceCollection refs) - { - } - - public virtual void VisitTypeReference (TypeReference type) - { - } - - public virtual void VisitMemberReferenceCollection (MemberReferenceCollection members) - { - } - - public virtual void VisitMemberReference (MemberReference member) - { - } - - public virtual void VisitInterfaceCollection (InterfaceCollection interfaces) - { - } - - public virtual void VisitInterface (TypeReference interf) - { - } - - public virtual void VisitExternTypeCollection (ExternTypeCollection externs) - { - } - - public virtual void VisitExternType (TypeReference externType) - { - } - - public virtual void VisitOverrideCollection (OverrideCollection meth) - { - } - - public virtual void VisitOverride (MethodReference ov) - { - } - - public virtual void VisitNestedTypeCollection (NestedTypeCollection nestedTypes) - { - } - - public virtual void VisitNestedType (TypeDefinition nestedType) - { - } - - public virtual void VisitParameterDefinitionCollection (ParameterDefinitionCollection parameters) - { - } - - public virtual void VisitParameterDefinition (ParameterDefinition parameter) - { - } - - public virtual void VisitMethodDefinitionCollection (MethodDefinitionCollection methods) - { - } - - public virtual void VisitMethodDefinition (MethodDefinition method) - { - } - - public virtual void VisitConstructorCollection (ConstructorCollection ctors) - { - } - - public virtual void VisitConstructor (MethodDefinition ctor) - { - } - - public virtual void VisitPInvokeInfo (PInvokeInfo pinvk) - { - } - - public virtual void VisitEventDefinitionCollection (EventDefinitionCollection events) - { - } - - public virtual void VisitEventDefinition (EventDefinition evt) - { - } - - public virtual void VisitFieldDefinitionCollection (FieldDefinitionCollection fields) - { - } - - public virtual void VisitFieldDefinition (FieldDefinition field) - { - } - - public virtual void VisitPropertyDefinitionCollection (PropertyDefinitionCollection properties) - { - } - - public virtual void VisitPropertyDefinition (PropertyDefinition property) - { - } - - public virtual void VisitSecurityDeclarationCollection (SecurityDeclarationCollection secDecls) - { - } - - public virtual void VisitSecurityDeclaration (SecurityDeclaration secDecl) - { - } - - public virtual void VisitCustomAttributeCollection (CustomAttributeCollection customAttrs) - { - } - - public virtual void VisitCustomAttribute (CustomAttribute customAttr) - { - } - - public virtual void VisitGenericParameterCollection (GenericParameterCollection genparams) - { - } - - public virtual void VisitGenericParameter (GenericParameter genparam) - { - } - - public virtual void VisitMarshalSpec (MarshalSpec marshalSpec) - { - } - - public virtual void TerminateModuleDefinition (ModuleDefinition module) - { - } - - protected void VisitCollection (ICollection coll) - { - if (coll.Count == 0) - return; - - foreach (IReflectionVisitable visitable in coll) - visitable.Accept (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseStructureVisitor.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseStructureVisitor.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseStructureVisitor.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseStructureVisitor.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,96 +0,0 @@ -// -// BaseStructureVisitor.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System.Collections; - - public abstract class BaseStructureVisitor : IReflectionStructureVisitor { - - public virtual void VisitAssemblyDefinition (AssemblyDefinition asm) - { - } - - public virtual void VisitAssemblyNameDefinition (AssemblyNameDefinition name) - { - } - - public virtual void VisitAssemblyNameReferenceCollection (AssemblyNameReferenceCollection names) - { - } - - public virtual void VisitAssemblyNameReference (AssemblyNameReference name) - { - } - - public virtual void VisitResourceCollection (ResourceCollection resources) - { - } - - public virtual void VisitEmbeddedResource (EmbeddedResource res) - { - } - - public virtual void VisitLinkedResource (LinkedResource res) - { - } - - public virtual void VisitAssemblyLinkedResource (AssemblyLinkedResource res) - { - } - - public virtual void VisitModuleDefinition (ModuleDefinition module) - { - } - - public virtual void VisitModuleDefinitionCollection (ModuleDefinitionCollection modules) - { - } - - public virtual void VisitModuleReference (ModuleReference module) - { - } - - public virtual void VisitModuleReferenceCollection (ModuleReferenceCollection modules) - { - } - - public virtual void TerminateAssemblyDefinition (AssemblyDefinition asm) - { - } - - protected void VisitCollection (ICollection coll) - { - if (coll.Count == 0) - return; - - foreach (IReflectionStructureVisitable visitable in coll) - visitable.Accept (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CallSite.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CallSite.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CallSite.cs 2008-11-06 19:52:04.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CallSite.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 - 2007 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,78 +26,20 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { - - using System.Collections; - using System.Text; - - using Mono.Cecil.Metadata; - - public sealed class CallSite : IMethodSignature, IAnnotationProvider, IMetadataTokenProvider { - - MethodReference m_function; - - public bool HasThis { - get { return m_function.HasThis; } - set { m_function.HasThis = value; } - } - - public bool ExplicitThis { - get { return m_function.ExplicitThis; } - set { m_function.ExplicitThis = value; } - } - - public MethodCallingConvention CallingConvention { - get { return m_function.CallingConvention; } - set { m_function.CallingConvention = value; } - } - - public ParameterDefinitionCollection Parameters { - get { return m_function.Parameters; } - } - - public MethodReturnType ReturnType { - get { return m_function.ReturnType; } - set { m_function.ReturnType = value; } - } - - public MetadataToken MetadataToken { - get { return m_function.MetadataToken; } - set { m_function.MetadataToken = value; } - } - - IDictionary IAnnotationProvider.Annotations { - get { return ((IAnnotationProvider) m_function).Annotations; } - } - - public CallSite (bool hasThis, bool explicitThis, MethodCallingConvention callConv, MethodReturnType retType) - { - m_function = new MethodReference (string.Empty, hasThis, explicitThis, callConv); - m_function.ReturnType = retType; - } +using System; +using System.Text; - public int GetSentinel () - { - return m_function.GetSentinel (); - } - - public override string ToString () - { - int sentinel = GetSentinel (); - StringBuilder sb = new StringBuilder (); - sb.Append (m_function.ReturnType.ReturnType.FullName); - sb.Append ("("); - for (int i = 0; i < m_function.Parameters.Count; i++) { - if (i > 0) - sb.Append (","); +namespace Mono.Cecil { - if (i == sentinel) - sb.Append ("...,"); + public sealed class CallSite : MethodReference { - sb.Append (m_function.Parameters [i].ParameterType.FullName); + public override string FullName { + get { + var signature = new StringBuilder (); + signature.Append (ReturnType.FullName); + this.MethodSignatureFullName (signature); + return signature.ToString (); } - sb.Append (")"); - return sb.ToString (); } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CompactFrameworkCompatibility.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CompactFrameworkCompatibility.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CompactFrameworkCompatibility.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CompactFrameworkCompatibility.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -// -// FrameworkCompatibility.cs -// -// Author: -// Rodrigo B. de Oliveira (rodrigobamboo@gmail.com) -// -// (C) 2005 Jb Evain -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -#if CF_1_0 -namespace System { - - internal class NotImplementedException : System.Exception { - - public NotImplementedException (string message) : base (message) - { - } - - public NotImplementedException () - { - } - } -} -#endif - -#if CF_1_0 || CF_2_0 -namespace System.Security { - - public class SecurityElement { - - public SecurityElement (string tag) - { - } - - public string Text - { - get { return string.Empty; } - set {} - } - - public void AddChild (SecurityElement child) - { - } - - public void AddAttribute (string name, string value) - { - } - } -} -#endif diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Constants.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Constants.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Constants.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Constants.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -// -// Constants.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - public class Constants { - - Constants () - { - } - - public const string Corlib = "mscorlib"; - - public const string ModuleType = ""; - public const string PrivateImplDetails = ""; - public const string Deleted = "_Deleted"; - - public const string Void = "System.Void"; - public const string Object = "System.Object"; - public const string String = "System.String"; - public const string Boolean = "System.Boolean"; - public const string Char = "System.Char"; - public const string Single = "System.Single"; - public const string Double = "System.Double"; - public const string SByte = "System.SByte"; - public const string Byte = "System.Byte"; - public const string Int16 = "System.Int16"; - public const string UInt16 = "System.UInt16"; - public const string Int32 = "System.Int32"; - public const string UInt32 = "System.UInt32"; - public const string Int64 = "System.Int64"; - public const string UInt64 = "System.UInt64"; - public const string IntPtr = "System.IntPtr"; - public const string UIntPtr = "System.UIntPtr"; - public const string TypedReference = "System.TypedReference"; - public const string Type = "System.Type"; - public const string ValueType = "System.ValueType"; - public const string Enum = "System.Enum"; - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ConstraintCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ConstraintCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ConstraintCollection.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ConstraintCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -// -// ConstraintCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Wed Sep 27 12:46:54 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.Collections; - - using Mono.Cecil.Cil; - - public sealed class ConstraintCollection : CollectionBase { - - GenericParameter m_container; - - public TypeReference this [int index] { - get { return List [index] as TypeReference; } - set { List [index] = value; } - } - - public GenericParameter Container { - get { return m_container; } - } - - public ConstraintCollection (GenericParameter container) - { - m_container = container; - } - - public void Add (TypeReference value) - { - List.Add (value); - } - - public bool Contains (TypeReference value) - { - return List.Contains (value); - } - - public int IndexOf (TypeReference value) - { - return List.IndexOf (value); - } - - public void Insert (int index, TypeReference value) - { - List.Insert (index, value); - } - - public void Remove (TypeReference value) - { - List.Remove (value); - } - - protected override void OnValidate (object o) - { - if (! (o is TypeReference)) - throw new ArgumentException ("Must be of type " + typeof (TypeReference).FullName); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ConstructorCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ConstructorCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ConstructorCollection.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ConstructorCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,175 +0,0 @@ -// -// ConstructorCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Fri Mar 30 18:43:56 +0200 2007 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.Collections; - - using Mono.Cecil.Cil; - - public sealed class ConstructorCollection : CollectionBase, IReflectionVisitable { - - TypeDefinition m_container; - - public MethodDefinition this [int index] { - get { return List [index] as MethodDefinition; } - set { List [index] = value; } - } - - public TypeDefinition Container { - get { return m_container; } - } - - public ConstructorCollection (TypeDefinition container) - { - m_container = container; - } - - public void Add (MethodDefinition value) - { - Attach (value); - - List.Add (value); - } - - - public new void Clear () - { - foreach (MethodDefinition item in this) - Detach (item); - - base.Clear (); - } - - public bool Contains (MethodDefinition value) - { - return List.Contains (value); - } - - public int IndexOf (MethodDefinition value) - { - return List.IndexOf (value); - } - - public void Insert (int index, MethodDefinition value) - { - Attach (value); - - List.Insert (index, value); - } - - public void Remove (MethodDefinition value) - { - List.Remove (value); - - Detach (value); - } - - - public new void RemoveAt (int index) - { - MethodDefinition item = this [index]; - Remove (item); - } - - protected override void OnValidate (object o) - { - if (! (o is MethodDefinition)) - throw new ArgumentException ("Must be of type " + typeof (MethodDefinition).FullName); - } - - internal MethodDefinition GetConstructorInternal (bool isStatic, IList parameters) - { - foreach (MethodDefinition ctor in this) { - if (ctor.IsStatic != isStatic || ctor.Parameters.Count != parameters.Count) - continue; - - bool match = true; - for (int i = 0; i < parameters.Count; i++) { - string pname; - object param = parameters [i]; - if (param is Type) - pname = ReflectionHelper.GetTypeSignature (param as Type); - else if (param is TypeReference) - pname = (param as TypeReference).FullName; - else if (param is ParameterDefinition) - pname = (param as ParameterDefinition).ParameterType.FullName; - else - throw new NotSupportedException (); - - if (ctor.Parameters [i].ParameterType.FullName != pname) { - match = false; - break; - } - } - - if (match) - return ctor; - } - - return null; - } - - public MethodDefinition GetConstructor (bool isStatic, Type [] parameters) - { - return GetConstructorInternal (isStatic, parameters); - } - - public MethodDefinition GetConstructor (bool isStatic, TypeReference [] parameters) - { - return GetConstructorInternal (isStatic, parameters); - } - - public MethodDefinition GetConstructor (bool isStatic, ParameterDefinitionCollection parameters) - { - return GetConstructorInternal (isStatic, parameters); - } - - void Attach (MemberReference member) - { - if (member.DeclaringType != null) - throw new ReflectionException ("Member already attached, clone it instead"); - - member.DeclaringType = m_container; - } - - void Detach (MemberReference member) - { - member.DeclaringType = null; - } - - public void Accept (IReflectionVisitor visitor) - { - visitor.VisitConstructorCollection (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CustomAttributeCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CustomAttributeCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CustomAttributeCollection.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CustomAttributeCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ -// -// CustomAttributeCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Wed Sep 27 12:46:53 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.Collections; - - using Mono.Cecil.Cil; - - public sealed class CustomAttributeCollection : CollectionBase, IReflectionVisitable { - - ICustomAttributeProvider m_container; - - public CustomAttribute this [int index] { - get { return List [index] as CustomAttribute; } - set { List [index] = value; } - } - - public ICustomAttributeProvider Container { - get { return m_container; } - } - - public CustomAttributeCollection (ICustomAttributeProvider container) - { - m_container = container; - } - - public void Add (CustomAttribute value) - { - List.Add (value); - } - - public bool Contains (CustomAttribute value) - { - return List.Contains (value); - } - - public int IndexOf (CustomAttribute value) - { - return List.IndexOf (value); - } - - public void Insert (int index, CustomAttribute value) - { - List.Insert (index, value); - } - - public void Remove (CustomAttribute value) - { - List.Remove (value); - } - - protected override void OnValidate (object o) - { - if (! (o is CustomAttribute)) - throw new ArgumentException ("Must be of type " + typeof (CustomAttribute).FullName); - } - - public void Accept (IReflectionVisitor visitor) - { - visitor.VisitCustomAttributeCollection (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CustomAttribute.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CustomAttribute.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CustomAttribute.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CustomAttribute.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,168 +26,192 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System; + +using Mono.Collections.Generic; + namespace Mono.Cecil { - using System.Collections; + public struct CustomAttributeArgument { + + readonly TypeReference type; + readonly object value; + + public TypeReference Type { + get { return type; } + } + + public object Value { + get { return value; } + } + + public CustomAttributeArgument (TypeReference type, object value) + { + Mixin.CheckType (type); + this.type = type; + this.value = value; + } + } + + public struct CustomAttributeNamedArgument { + + readonly string name; + readonly CustomAttributeArgument argument; - public sealed class CustomAttribute : IRequireResolving, IAnnotationProvider, IReflectionVisitable { + public string Name { + get { return name; } + } - MethodReference m_ctor; - IList m_parameters; - IDictionary m_fields; - IDictionary m_properties; - IDictionary m_fieldTypes; - IDictionary m_propTypes; - IDictionary m_annotations; + public CustomAttributeArgument Argument { + get { return argument; } + } - bool m_resolved; - byte [] m_blob; + public CustomAttributeNamedArgument (string name, CustomAttributeArgument argument) + { + Mixin.CheckName (name); + this.name = name; + this.argument = argument; + } + } + + public interface ICustomAttribute { + + TypeReference AttributeType { get; } + + bool HasFields { get; } + bool HasProperties { get; } + Collection Fields { get; } + Collection Properties { get; } + } + + public sealed class CustomAttribute : ICustomAttribute { + + readonly internal uint signature; + internal bool resolved; + MethodReference constructor; + byte [] blob; + internal Collection arguments; + internal Collection fields; + internal Collection properties; public MethodReference Constructor { - get { return m_ctor; } - set { m_ctor = value; } + get { return constructor; } + set { constructor = value; } } - public IList ConstructorParameters { - get { - if (m_parameters == null) - m_parameters = new ArrayList (); - return m_parameters; - } + public TypeReference AttributeType { + get { return constructor.DeclaringType; } } - public IDictionary Fields { + public bool HasConstructorArguments { get { - if (m_fields == null) - m_fields = new Hashtable (); + Resolve (); - return m_fields; + return !arguments.IsNullOrEmpty (); } } - public IDictionary Properties { + public Collection ConstructorArguments { get { - if (m_properties == null) - m_properties = new Hashtable (); + Resolve (); - return m_properties; + return arguments ?? (arguments = new Collection ()); } } - internal IDictionary FieldTypes { + public bool HasFields { get { - if (m_fieldTypes == null) - m_fieldTypes = new Hashtable (); + Resolve (); - return m_fieldTypes; + return !fields.IsNullOrEmpty (); } } - internal IDictionary PropertyTypes { + public Collection Fields { get { - if (m_propTypes == null) - m_propTypes = new Hashtable (); + Resolve (); - return m_propTypes; + return fields ?? (fields = new Collection ()); } } - public bool Resolved { - get { return m_resolved; } - set { m_resolved = value; } - } + public bool HasProperties { + get { + Resolve (); - public byte [] Blob { - get { return m_blob; } - set { m_blob = value; } + return !properties.IsNullOrEmpty (); + } } - IDictionary IAnnotationProvider.Annotations { + public Collection Properties { get { - if (m_annotations == null) - m_annotations = new Hashtable (); - return m_annotations; + Resolve (); + + return properties ?? (properties = new Collection ()); } } - public CustomAttribute (MethodReference ctor) - { - m_ctor = ctor; - m_resolved = true; + internal bool HasImage { + get { return constructor != null && constructor.HasImage; } } - public TypeReference GetFieldType (string fieldName) - { - return (TypeReference) FieldTypes [fieldName]; + internal ModuleDefinition Module { + get { return constructor.Module; } } - public TypeReference GetPropertyType (string propertyName) + internal CustomAttribute (uint signature, MethodReference constructor) { - return (TypeReference) PropertyTypes [propertyName]; + this.signature = signature; + this.constructor = constructor; + this.resolved = false; } - public void SetFieldType (string fieldName, TypeReference type) + public CustomAttribute (MethodReference constructor) { - FieldTypes [fieldName] = type; + this.constructor = constructor; + this.resolved = true; } - public void SetPropertyType (string propertyName, TypeReference type) + public CustomAttribute (MethodReference constructor, byte [] blob) { - PropertyTypes [propertyName] = type; + this.constructor = constructor; + this.resolved = false; + this.blob = blob; } - public CustomAttribute Clone () + public byte [] GetBlob () { - return Clone (this, new ImportContext (NullReferenceImporter.Instance)); - } + if (blob != null) + return blob; - static void Clone (IDictionary original, IDictionary target) - { - target.Clear (); - foreach (DictionaryEntry entry in original) - target.Add (entry.Key, entry.Value); - } + if (!HasImage || signature == 0) + throw new NotSupportedException (); - internal static CustomAttribute Clone (CustomAttribute custattr, ImportContext context) - { - CustomAttribute ca = new CustomAttribute (context.Import (custattr.Constructor)); - custattr.CopyTo (ca); - return ca; + return blob = Module.Read (this, (attribute, reader) => reader.ReadCustomAttributeBlob (attribute.signature)); } - void CopyTo (CustomAttribute target) + void Resolve () { - target.Resolved = Resolved; - if (!Resolved) { - target.Blob = Blob; + if (resolved || !HasImage) return; - } - - foreach (object o in ConstructorParameters) - target.ConstructorParameters.Add (o); - Clone (Fields, target.Fields); - Clone (FieldTypes, target.FieldTypes); - Clone (Properties, target.Properties); - Clone (PropertyTypes, target.PropertyTypes); - } - - public bool Resolve () - { - if (Resolved) - return true; - ReflectionReader r = m_ctor.DeclaringType.Module.Controller.Reader; - CustomAttribute newCa = r.GetCustomAttribute (m_ctor, Blob, true); - if (!newCa.Resolved) - return false; + Module.Read (this, (attribute, reader) => { + reader.ReadCustomAttributeSignature (attribute); + return this; + }); - newCa.CopyTo (this); - return true; + resolved = true; } + } + + static partial class Mixin { - public void Accept (IReflectionVisitor visitor) + public static void CheckName (string name) { - visitor.VisitCustomAttribute (this); + if (name == null) + throw new ArgumentNullException ("name"); + if (name.Length == 0) + throw new ArgumentException ("Empty name"); } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/DefaultAssemblyResolver.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/DefaultAssemblyResolver.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/DefaultAssemblyResolver.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/DefaultAssemblyResolver.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,37 +26,50 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System; +using System.Collections.Generic; + namespace Mono.Cecil { - using System.Collections; + public static class GlobalAssemblyResolver { + + public static readonly IAssemblyResolver Instance = new DefaultAssemblyResolver (); + } public class DefaultAssemblyResolver : BaseAssemblyResolver { - IDictionary m_cache; + readonly IDictionary cache; public DefaultAssemblyResolver () { - m_cache = new Hashtable (); + cache = new Dictionary (); } public override AssemblyDefinition Resolve (AssemblyNameReference name) { - AssemblyDefinition asm = (AssemblyDefinition) m_cache [name.FullName]; - if (asm == null) { - asm = base.Resolve (name); - m_cache [name.FullName] = asm; - } + if (name == null) + throw new ArgumentNullException ("name"); - return asm; + AssemblyDefinition assembly; + if (cache.TryGetValue (name.FullName, out assembly)) + return assembly; + + assembly = base.Resolve (name); + cache [name.FullName] = assembly; + + return assembly; } protected void RegisterAssembly (AssemblyDefinition assembly) { - string key = assembly.Name.FullName; - if (m_cache.Contains (key)) + if (assembly == null) + throw new ArgumentNullException ("assembly"); + + var name = assembly.Name.FullName; + if (cache.ContainsKey (name)) return; - m_cache [key] = assembly; + cache [name] = assembly; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/DefaultImporter.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/DefaultImporter.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/DefaultImporter.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/DefaultImporter.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,230 +0,0 @@ -// -// DefaultReferenceImporter.cs -// -// Author: -// Jb Evain (jbevain@novell.com) -// -// (C) 2007 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.Collections; - - public class DefaultImporter : IImporter { - - ModuleDefinition m_module; - - public ModuleDefinition Module { - get { return m_module; } - } - - public DefaultImporter (ModuleDefinition module) - { - m_module = module; - } - - public AssemblyNameReference ImportAssembly (AssemblyNameReference asm) - { - AssemblyNameReference asmRef = GetAssemblyNameReference (asm); - if (asmRef != null) - return asmRef; - - asmRef = new AssemblyNameReference ( - asm.Name, asm.Culture, asm.Version); - asmRef.PublicKeyToken = asm.PublicKeyToken; - asmRef.HashAlgorithm = asm.HashAlgorithm; - m_module.AssemblyReferences.Add (asmRef); - return asmRef; - } - - AssemblyNameReference GetAssemblyNameReference (AssemblyNameReference asm) - { - foreach (AssemblyNameReference reference in m_module.AssemblyReferences) - if (reference.FullName == asm.FullName) - return reference; - - return null; - } - - TypeReference GetTypeSpec (TypeReference t, ImportContext context) - { - Stack s = new Stack (); - while (t is TypeSpecification) { - s.Push (t); - t = (t as TypeSpecification).ElementType; - } - - TypeReference elementType = ImportTypeReference (t, context); - while (s.Count > 0) { - t = (TypeReference) s.Pop (); - if (t is PointerType) - elementType = new PointerType (elementType); - else if (t is ArrayType) // deal with complex arrays - elementType = new ArrayType (elementType); - else if (t is ReferenceType) - elementType = new ReferenceType (elementType); - else if (t is GenericInstanceType) { - GenericInstanceType git = t as GenericInstanceType; - GenericInstanceType genElemType = new GenericInstanceType (elementType); - - context.GenericContext.CheckProvider (genElemType.GetOriginalType (), git.GenericArguments.Count); - foreach (TypeReference arg in git.GenericArguments) - genElemType.GenericArguments.Add (ImportTypeReference (arg, context)); - - elementType = genElemType; - } else - throw new ReflectionException ("Unknown element type: {0}", t.GetType ().Name); - } - - return elementType; - } - - static GenericParameter GetGenericParameter (GenericParameter gp, ImportContext context) - { - GenericParameter p; - if (gp.Owner is TypeReference) - p = context.GenericContext.Type.GenericParameters [gp.Position]; - else if (gp.Owner is MethodReference) - p = context.GenericContext.Method.GenericParameters [gp.Position]; - else - throw new NotSupportedException (); - - return p; - } - - public virtual TypeReference ImportTypeReference (TypeReference t, ImportContext context) - { - if (t.Module == m_module) - return t; - - if (t is TypeSpecification) - return GetTypeSpec (t, context); - - if (t is GenericParameter) - return GetGenericParameter (t as GenericParameter, context); - - TypeReference type = m_module.TypeReferences [t.FullName]; - if (type != null) - return type; - - AssemblyNameReference asm; - if (t.Scope is AssemblyNameReference) - asm = ImportAssembly ((AssemblyNameReference) t.Scope); - else if (t.Scope is ModuleDefinition) - asm = ImportAssembly (((ModuleDefinition) t.Scope).Assembly.Name); - else - throw new NotImplementedException (); - - type = new TypeReference (t.Name, t.Namespace, asm, t.IsValueType); - - context.GenericContext.Type = type; - - foreach (GenericParameter gp in t.GenericParameters) - type.GenericParameters.Add (GenericParameter.Clone (gp, context)); - - m_module.TypeReferences.Add (type); - return type; - } - - public virtual FieldReference ImportFieldReference (FieldReference fr, ImportContext context) - { - if (fr.DeclaringType.Module == m_module) - return fr; - - FieldReference field = (FieldReference) GetMemberReference (fr); - if (field != null) - return field; - - field = new FieldReference ( - fr.Name, - ImportTypeReference (fr.DeclaringType, context), - ImportTypeReference (fr.FieldType, context)); - - m_module.MemberReferences.Add (field); - return field; - } - - MethodReference GetMethodSpec (MethodReference meth, ImportContext context) - { - if (!(meth is GenericInstanceMethod)) - return null; - - GenericInstanceMethod gim = meth as GenericInstanceMethod; - GenericInstanceMethod ngim = new GenericInstanceMethod ( - ImportMethodReference (gim.ElementMethod, context)); - - context.GenericContext.CheckProvider (ngim.GetOriginalMethod (), gim.GenericArguments.Count); - foreach (TypeReference arg in gim.GenericArguments) - ngim.GenericArguments.Add (ImportTypeReference (arg, context)); - - return ngim; - } - - public virtual MethodReference ImportMethodReference (MethodReference mr, ImportContext context) - { - if (mr.DeclaringType.Module == m_module) - return mr; - - if (mr is MethodSpecification) - return GetMethodSpec (mr, context); - - MethodReference meth = (MethodReference) GetMemberReference (mr); - if (meth != null) - return meth; - - meth = new MethodReference ( - mr.Name, - mr.HasThis, - mr.ExplicitThis, - mr.CallingConvention); - meth.DeclaringType = ImportTypeReference (mr.DeclaringType, context); - - TypeReference contextType = meth.DeclaringType.GetOriginalType (); - - context.GenericContext.Method = meth; - context.GenericContext.Type = contextType; - - foreach (GenericParameter gp in mr.GenericParameters) - meth.GenericParameters.Add (GenericParameter.Clone (gp, context)); - - meth.ReturnType.ReturnType = ImportTypeReference (mr.ReturnType.ReturnType, context); - - foreach (ParameterDefinition param in mr.Parameters) - meth.Parameters.Add (new ParameterDefinition ( - ImportTypeReference (param.ParameterType, context))); - - m_module.MemberReferences.Add (meth); - return meth; - } - - MemberReference GetMemberReference (MemberReference member) - { - foreach (MemberReference reference in m_module.MemberReferences) - if (reference.ToString () == member.ToString ()) - return reference; - - return null; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EmbeddedResource.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EmbeddedResource.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EmbeddedResource.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EmbeddedResource.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,31 +26,80 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System; +using System.IO; + namespace Mono.Cecil { public sealed class EmbeddedResource : Resource { - byte [] m_data; + readonly MetadataReader reader; + + uint? offset; + byte [] data; + Stream stream; - public byte [] Data { - get { return m_data; } - set { m_data = value; } + public override ResourceType ResourceType { + get { return ResourceType.Embedded; } + } + + public EmbeddedResource (string name, ManifestResourceAttributes attributes, byte [] data) : + base (name, attributes) + { + this.data = data; } - public EmbeddedResource (string name, ManifestResourceAttributes flags) : - base (name, flags) + public EmbeddedResource (string name, ManifestResourceAttributes attributes, Stream stream) : + base (name, attributes) { + this.stream = stream; } - public EmbeddedResource (string name, ManifestResourceAttributes flags, byte [] data) : - base (name, flags) + internal EmbeddedResource (string name, ManifestResourceAttributes attributes, uint offset, MetadataReader reader) + : base (name, attributes) { - m_data = data; + this.offset = offset; + this.reader = reader; } - public override void Accept (IReflectionStructureVisitor visitor) + public Stream GetResourceStream () { - visitor.VisitEmbeddedResource (this); + if (stream != null) + return stream; + + if (data != null) + return new MemoryStream (data); + + if (offset.HasValue) + return reader.GetManagedResourceStream (offset.Value); + + throw new InvalidOperationException (); + } + + public byte [] GetResourceData () + { + if (stream != null) + return ReadStream (stream); + + if (data != null) + return data; + + if (offset.HasValue) + return reader.GetManagedResourceStream (offset.Value).ToArray (); + + throw new InvalidOperationException (); + } + + static byte [] ReadStream (Stream stream) + { + var length = (int) stream.Length; + var data = new byte [length]; + int offset = 0, read; + + while ((read = stream.Read (data, offset, length - offset)) > 0) + offset += read; + + return data; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventAttributes.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventAttributes.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventAttributes.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventAttributes.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,12 +26,13 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { +using System; - using System; +namespace Mono.Cecil { [Flags] public enum EventAttributes : ushort { + None = 0x0000, SpecialName = 0x0200, // Event is special RTSpecialName = 0x0400 // CLI provides 'special' behavior, depending upon the name of the event } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventDefinitionCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventDefinitionCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventDefinitionCollection.cs 2008-11-06 19:52:04.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventDefinitionCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,137 +0,0 @@ -// -// EventDefinitionCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Fri Mar 30 18:43:57 +0200 2007 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.Collections; - - using Mono.Cecil.Cil; - - public sealed class EventDefinitionCollection : CollectionBase, IReflectionVisitable { - - TypeDefinition m_container; - - public EventDefinition this [int index] { - get { return List [index] as EventDefinition; } - set { List [index] = value; } - } - - public TypeDefinition Container { - get { return m_container; } - } - - public EventDefinitionCollection (TypeDefinition container) - { - m_container = container; - } - - public void Add (EventDefinition value) - { - Attach (value); - - List.Add (value); - } - - - public new void Clear () - { - foreach (EventDefinition item in this) - Detach (item); - - base.Clear (); - } - - public bool Contains (EventDefinition value) - { - return List.Contains (value); - } - - public int IndexOf (EventDefinition value) - { - return List.IndexOf (value); - } - - public void Insert (int index, EventDefinition value) - { - Attach (value); - - List.Insert (index, value); - } - - public void Remove (EventDefinition value) - { - List.Remove (value); - - Detach (value); - } - - - public new void RemoveAt (int index) - { - EventDefinition item = this [index]; - Remove (item); - } - - protected override void OnValidate (object o) - { - if (! (o is EventDefinition)) - throw new ArgumentException ("Must be of type " + typeof (EventDefinition).FullName); - } - - public EventDefinition GetEvent (string name) - { - foreach (EventDefinition evt in this) - if (evt.Name == name) - return evt; - - return null; - } - - void Attach (MemberReference member) - { - if (member.DeclaringType != null) - throw new ReflectionException ("Member already attached, clone it instead"); - - member.DeclaringType = m_container; - } - - void Detach (MemberReference member) - { - member.DeclaringType = null; - } - - public void Accept (IReflectionVisitor visitor) - { - visitor.VisitEventDefinitionCollection (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventDefinition.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventDefinition.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventDefinition.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventDefinition.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,134 +26,138 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using Mono.Collections.Generic; + namespace Mono.Cecil { - public sealed class EventDefinition : EventReference, IMemberDefinition, ICustomAttributeProvider { + public sealed class EventDefinition : EventReference, IMemberDefinition { - EventAttributes m_attributes; + ushort attributes; - CustomAttributeCollection m_customAttrs; + Collection custom_attributes; - MethodDefinition m_addMeth; - MethodDefinition m_invMeth; - MethodDefinition m_remMeth; + internal MethodDefinition add_method; + internal MethodDefinition invoke_method; + internal MethodDefinition remove_method; + internal Collection other_methods; public EventAttributes Attributes { - get { return m_attributes; } - set { m_attributes = value; } + get { return (EventAttributes) attributes; } + set { attributes = (ushort) value; } } public MethodDefinition AddMethod { - get { return m_addMeth; } - set { m_addMeth = value; } + get { + if (add_method != null) + return add_method; + + InitializeMethods (); + return add_method; + } + set { add_method = value; } } public MethodDefinition InvokeMethod { - get { return m_invMeth; } - set { m_invMeth = value; } - } + get { + if (invoke_method != null) + return invoke_method; - public MethodDefinition RemoveMethod { - get { return m_remMeth; } - set { m_remMeth = value; } + InitializeMethods (); + return invoke_method; + } + set { invoke_method = value; } } - public CustomAttributeCollection CustomAttributes { + public MethodDefinition RemoveMethod { get { - if (m_customAttrs == null) - m_customAttrs = new CustomAttributeCollection (this); + if (remove_method != null) + return remove_method; - return m_customAttrs; + InitializeMethods (); + return remove_method; } + set { remove_method = value; } } - #region EventAttributes + public bool HasOtherMethods { + get { + if (other_methods != null) + return other_methods.Count > 0; - public bool IsSpecialName { - get { return (m_attributes & EventAttributes.SpecialName) != 0; } - set { - if (value) - m_attributes |= EventAttributes.SpecialName; - else - m_attributes &= ~EventAttributes.SpecialName; + InitializeMethods (); + return !other_methods.IsNullOrEmpty (); } } - public bool IsRuntimeSpecialName { - get { return (m_attributes & EventAttributes.RTSpecialName) != 0; } - set { - if (value) - m_attributes |= EventAttributes.RTSpecialName; - else - m_attributes &= ~EventAttributes.RTSpecialName; + public Collection OtherMethods { + get { + if (other_methods != null) + return other_methods; + + InitializeMethods (); + + if (other_methods != null) + return other_methods; + + return other_methods = new Collection (); } } - #endregion + public bool HasCustomAttributes { + get { + if (custom_attributes != null) + return custom_attributes.Count > 0; - public EventDefinition (string name, TypeReference eventType, - EventAttributes attrs) : base (name, eventType) - { - m_attributes = attrs; + return this.GetHasCustomAttributes (Module); + } } - public static MethodDefinition CreateAddMethod (EventDefinition evt) - { - MethodDefinition add = new MethodDefinition ( - string.Concat ("add_", evt.Name), (MethodAttributes) 0, evt.EventType); - evt.AddMethod = add; - return add; + public Collection CustomAttributes { + get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (Module)); } } - public static MethodDefinition CreateRemoveMethod (EventDefinition evt) - { - MethodDefinition remove = new MethodDefinition ( - string.Concat ("remove_", evt.Name), (MethodAttributes) 0, evt.EventType); - evt.RemoveMethod = remove; - return remove; - } + #region EventAttributes - public static MethodDefinition CreateInvokeMethod (EventDefinition evt) - { - MethodDefinition raise = new MethodDefinition ( - string.Concat ("raise_", evt.Name), (MethodAttributes) 0, evt.EventType); - evt.InvokeMethod = raise; - return raise; + public bool IsSpecialName { + get { return attributes.GetAttributes ((ushort) EventAttributes.SpecialName); } + set { attributes = attributes.SetAttributes ((ushort) EventAttributes.SpecialName, value); } } - public EventDefinition Clone () - { - return Clone (this, new ImportContext (NullReferenceImporter.Instance, this.DeclaringType)); + public bool IsRuntimeSpecialName { + get { return attributes.GetAttributes ((ushort) FieldAttributes.RTSpecialName); } + set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.RTSpecialName, value); } } - internal static EventDefinition Clone (EventDefinition evt, ImportContext context) - { - EventDefinition ne = new EventDefinition ( - evt.Name, - context.Import (evt.EventType), - evt.Attributes); + #endregion - if (context.GenericContext.Type is TypeDefinition) { - TypeDefinition type = context.GenericContext.Type as TypeDefinition; - if (evt.AddMethod != null) - ne.AddMethod = type.Methods.GetMethod (evt.AddMethod.Name) [0]; - if (evt.InvokeMethod != null) - ne.InvokeMethod = type.Methods.GetMethod (evt.InvokeMethod.Name) [0]; - if (evt.RemoveMethod != null) - ne.RemoveMethod = type.Methods.GetMethod (evt.RemoveMethod.Name) [0]; - } + public new TypeDefinition DeclaringType { + get { return (TypeDefinition) base.DeclaringType; } + set { base.DeclaringType = value; } + } - foreach (CustomAttribute ca in evt.CustomAttributes) - ne.CustomAttributes.Add (CustomAttribute.Clone (ca, context)); + public override bool IsDefinition { + get { return true; } + } - return ne; + public EventDefinition (string name, EventAttributes attributes, TypeReference eventType) + : base (name, eventType) + { + this.attributes = (ushort) attributes; + this.token = new MetadataToken (TokenType.Event); } - public override void Accept (IReflectionVisitor visitor) + void InitializeMethods () { - visitor.VisitEventDefinition (this); + if (add_method != null + || invoke_method != null + || remove_method != null) + return; + + var module = this.Module; + if (!module.HasImage ()) + return; - this.CustomAttributes.Accept (visitor); + module.Read (this, (@event, reader) => reader.ReadMethods (@event)); } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventReference.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventReference.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventReference.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventReference.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,25 +26,30 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System; + namespace Mono.Cecil { public abstract class EventReference : MemberReference { - TypeReference m_eventType; + TypeReference event_type; public TypeReference EventType { - get { return m_eventType; } - set { m_eventType = value; } + get { return event_type; } + set { event_type = value; } } - public EventReference (string name, TypeReference eventType) : base (name) - { - m_eventType = eventType; + public override string FullName { + get { return event_type.FullName + " " + MemberFullName (); } } - public override string ToString () + protected EventReference (string name, TypeReference eventType) + : base (name) { - return string.Concat (m_eventType.FullName, " ", base.ToString ()); + if (eventType == null) + throw new ArgumentNullException ("eventType"); + + event_type = eventType; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ExportedType.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ExportedType.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ExportedType.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ExportedType.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,235 @@ +// +// ExportedType.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; + +namespace Mono.Cecil { + + public class ExportedType : IMetadataTokenProvider { + + string @namespace; + string name; + uint attributes; + IMetadataScope scope; + int identifier; + ExportedType declaring_type; + internal MetadataToken token; + + public string Namespace { + get { return @namespace; } + set { @namespace = value; } + } + + public string Name { + get { return name; } + set { name = value; } + } + + public TypeAttributes Attributes { + get { return (TypeAttributes) attributes; } + set { attributes = (uint) value; } + } + + public IMetadataScope Scope { + get { + if (declaring_type != null) + return declaring_type.Scope; + + return scope; + } + } + + public ExportedType DeclaringType { + get { return declaring_type; } + set { declaring_type = value; } + } + + public MetadataToken MetadataToken { + get { return token; } + set { token = value; } + } + + public int Identifier { + get { return identifier; } + set { identifier = value; } + } + + #region TypeAttributes + + public bool IsNotPublic { + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NotPublic); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NotPublic, value); } + } + + public bool IsPublic { + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.Public); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.Public, value); } + } + + public bool IsNestedPublic { + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedPublic); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedPublic, value); } + } + + public bool IsNestedPrivate { + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedPrivate); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedPrivate, value); } + } + + public bool IsNestedFamily { + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamily); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamily, value); } + } + + public bool IsNestedAssembly { + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedAssembly); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedAssembly, value); } + } + + public bool IsNestedFamilyAndAssembly { + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamANDAssem); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamANDAssem, value); } + } + + public bool IsNestedFamilyOrAssembly { + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamORAssem); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamORAssem, value); } + } + + public bool IsAutoLayout { + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.AutoLayout); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.AutoLayout, value); } + } + + public bool IsSequentialLayout { + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.SequentialLayout); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.SequentialLayout, value); } + } + + public bool IsExplicitLayout { + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.ExplicitLayout); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.ExplicitLayout, value); } + } + + public bool IsClass { + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.ClassSemanticMask, (uint) TypeAttributes.Class); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.ClassSemanticMask, (uint) TypeAttributes.Class, value); } + } + + public bool IsInterface { + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.ClassSemanticMask, (uint) TypeAttributes.Interface); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.ClassSemanticMask, (uint) TypeAttributes.Interface, value); } + } + + public bool IsAbstract { + get { return attributes.GetAttributes ((uint) TypeAttributes.Abstract); } + set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Abstract, value); } + } + + public bool IsSealed { + get { return attributes.GetAttributes ((uint) TypeAttributes.Sealed); } + set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Sealed, value); } + } + + public bool IsSpecialName { + get { return attributes.GetAttributes ((uint) TypeAttributes.SpecialName); } + set { attributes = attributes.SetAttributes ((uint) TypeAttributes.SpecialName, value); } + } + + public bool IsImport { + get { return attributes.GetAttributes ((uint) TypeAttributes.Import); } + set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Import, value); } + } + + public bool IsSerializable { + get { return attributes.GetAttributes ((uint) TypeAttributes.Serializable); } + set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Serializable, value); } + } + + public bool IsAnsiClass { + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AnsiClass); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AnsiClass, value); } + } + + public bool IsUnicodeClass { + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.UnicodeClass); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.UnicodeClass, value); } + } + + public bool IsAutoClass { + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AutoClass); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AutoClass, value); } + } + + public bool IsBeforeFieldInit { + get { return attributes.GetAttributes ((uint) TypeAttributes.BeforeFieldInit); } + set { attributes = attributes.SetAttributes ((uint) TypeAttributes.BeforeFieldInit, value); } + } + + public bool IsRuntimeSpecialName { + get { return attributes.GetAttributes ((uint) TypeAttributes.RTSpecialName); } + set { attributes = attributes.SetAttributes ((uint) TypeAttributes.RTSpecialName, value); } + } + + public bool HasSecurity { + get { return attributes.GetAttributes ((uint) TypeAttributes.HasSecurity); } + set { attributes = attributes.SetAttributes ((uint) TypeAttributes.HasSecurity, value); } + } + + #endregion + + public bool IsForwarder { + get { return attributes.GetAttributes ((uint) TypeAttributes.Forwarder); } + set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Forwarder, value); } + } + + public string FullName { + get { + if (declaring_type != null) + return declaring_type.FullName + "/" + name; + + if (string.IsNullOrEmpty (@namespace)) + return name; + + return @namespace + "." + name; + } + } + + public ExportedType (string @namespace, string name, IMetadataScope scope) + { + this.@namespace = @namespace; + this.name = name; + this.scope = scope; + } + + public override string ToString () + { + return FullName; + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ExternTypeCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ExternTypeCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ExternTypeCollection.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ExternTypeCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,214 +0,0 @@ -// -// ExternTypeCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Fri Mar 30 18:43:57 +0200 2007 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.Collections; - using System.Collections.Specialized; - - using Mono.Cecil.Cil; - - using Hcp = Mono.Cecil.HashCodeProvider; - using Cmp = System.Collections.Comparer; - - public sealed class ExternTypeCollection : NameObjectCollectionBase, IList, IReflectionVisitable { - - ModuleDefinition m_container; - - public TypeReference this [int index] { - get { return this.BaseGet (index) as TypeReference; } - set { this.BaseSet (index, value); } - } - - public TypeReference this [string fullName] { - get { return this.BaseGet (fullName) as TypeReference; } - set { this.BaseSet (fullName, value); } - } - - public ModuleDefinition Container { - get { return m_container; } - } - - public bool IsSynchronized { - get { return false; } - } - - public object SyncRoot { - get { return this; } - } - - bool IList.IsReadOnly { - get { return false; } - } - - bool IList.IsFixedSize { - get { return false; } - } - - object IList.this [int index] { - get { return BaseGet (index); } - set { - Check (value); - BaseSet (index, value); - } - } - - public ExternTypeCollection (ModuleDefinition container) : - base (Hcp.Instance, Cmp.Default) - { - m_container = container; - } - - public void Add (TypeReference value) - { - if (value == null) - throw new ArgumentNullException ("value"); - - Attach (value); - - this.BaseAdd (value.FullName, value); - } - - public void Clear () - { - foreach (TypeReference item in this) - Detach (item); - - this.BaseClear (); - } - - public bool Contains (TypeReference value) - { - return Contains (value.FullName); - } - - public bool Contains (string fullName) - { - return this.BaseGet (fullName) != null; - } - - public int IndexOf (TypeReference value) - { - string [] keys = this.BaseGetAllKeys (); - return Array.IndexOf (keys, value.FullName, 0, keys.Length); - } - - public void Remove (TypeReference value) - { - this.BaseRemove (value.FullName); - - Detach (value); - } - - public void RemoveAt (int index) - { - TypeReference item = this [index]; - Remove (item); - - Detach (item); - } - - public void CopyTo (Array ary, int index) - { - this.BaseGetAllValues ().CopyTo (ary, index); - } - - public new IEnumerator GetEnumerator () - { - return this.BaseGetAllValues ().GetEnumerator (); - } - - public void Accept (IReflectionVisitor visitor) - { - visitor.VisitExternTypeCollection (this); - } - -#if CF_1_0 || CF_2_0 - internal object [] BaseGetAllValues () - { - object [] values = new object [this.Count]; - for (int i=0; i < values.Length; ++i) { - values [i] = this.BaseGet (i); - } - return values; - } -#endif - - void Check (object value) - { - if (!(value is TypeReference)) - throw new ArgumentException (); - } - - int IList.Add (object value) - { - Check (value); - Add (value as TypeReference); - return 0; - } - - bool IList.Contains (object value) - { - Check (value); - return Contains (value as TypeReference); - } - - int IList.IndexOf (object value) - { - throw new NotSupportedException (); - } - - void IList.Insert (int index, object value) - { - throw new NotSupportedException (); - } - - void IList.Remove (object value) - { - Check (value); - Remove (value as TypeReference); - } - - void Detach (TypeReference type) - { - type.Module = null; - } - - void Attach (TypeReference type) - { - if (type.Module != null) - throw new ReflectionException ("Type is already attached, clone it instead"); - - type.Module = m_container; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldAttributes.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldAttributes.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldAttributes.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldAttributes.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,14 +26,14 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { +using System; - using System; +namespace Mono.Cecil { [Flags] public enum FieldAttributes : ushort { FieldAccessMask = 0x0007, - Compilercontrolled = 0x0000, // Member not referenceable + CompilerControlled = 0x0000, // Member not referenceable Private = 0x0001, // Accessible only by the parent type FamANDAssem = 0x0002, // Accessible by sub-types only in this assembly Assembly = 0x0003, // Accessible by anyone in the Assembly diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldDefinitionCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldDefinitionCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldDefinitionCollection.cs 2008-11-06 19:52:04.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldDefinitionCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,137 +0,0 @@ -// -// FieldDefinitionCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Fri Mar 30 18:43:57 +0200 2007 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.Collections; - - using Mono.Cecil.Cil; - - public sealed class FieldDefinitionCollection : CollectionBase, IReflectionVisitable { - - TypeDefinition m_container; - - public FieldDefinition this [int index] { - get { return List [index] as FieldDefinition; } - set { List [index] = value; } - } - - public TypeDefinition Container { - get { return m_container; } - } - - public FieldDefinitionCollection (TypeDefinition container) - { - m_container = container; - } - - public void Add (FieldDefinition value) - { - Attach (value); - - List.Add (value); - } - - - public new void Clear () - { - foreach (FieldDefinition item in this) - Detach (item); - - base.Clear (); - } - - public bool Contains (FieldDefinition value) - { - return List.Contains (value); - } - - public int IndexOf (FieldDefinition value) - { - return List.IndexOf (value); - } - - public void Insert (int index, FieldDefinition value) - { - Attach (value); - - List.Insert (index, value); - } - - public void Remove (FieldDefinition value) - { - List.Remove (value); - - Detach (value); - } - - - public new void RemoveAt (int index) - { - FieldDefinition item = this [index]; - Remove (item); - } - - protected override void OnValidate (object o) - { - if (! (o is FieldDefinition)) - throw new ArgumentException ("Must be of type " + typeof (FieldDefinition).FullName); - } - - public FieldDefinition GetField (string name) - { - foreach (FieldDefinition field in this) - if (field.Name == name) - return field; - - return null; - } - - void Attach (MemberReference member) - { - if (member.DeclaringType != null) - throw new ReflectionException ("Member already attached, clone it instead"); - - member.DeclaringType = m_container; - } - - void Detach (MemberReference member) - { - member.DeclaringType = null; - } - - public void Accept (IReflectionVisitor visitor) - { - visitor.VisitFieldDefinitionCollection (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldDefinition.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldDefinition.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldDefinition.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldDefinition.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,292 +26,254 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using Mono.Collections.Generic; + namespace Mono.Cecil { - using Mono.Cecil; - using Mono.Cecil.Binary; + public sealed class FieldDefinition : FieldReference, IMemberDefinition, IConstantProvider, IMarshalInfoProvider { + + ushort attributes; + Collection custom_attributes; - public sealed class FieldDefinition : FieldReference, IMemberDefinition, - ICustomAttributeProvider, IHasMarshalSpec, IHasConstant { + int offset = Mixin.NotResolvedMarker; - FieldAttributes m_attributes; + internal int rva = Mixin.NotResolvedMarker; + byte [] initial_value; - CustomAttributeCollection m_customAttrs; + object constant = Mixin.NotResolved; - bool m_hasInfo; - uint m_offset; + MarshalInfo marshal_info; - RVA m_rva; - byte [] m_initVal; + void ResolveLayout () + { + if (offset != Mixin.NotResolvedMarker) + return; - bool m_hasConstant; - object m_const; + if (!HasImage) { + offset = Mixin.NoDataMarker; + return; + } - MarshalSpec m_marshalDesc; + offset = Module.Read (this, (field, reader) => reader.ReadFieldLayout (field)); + } public bool HasLayoutInfo { - get { return m_hasInfo; } + get { + if (offset >= 0) + return true; + + ResolveLayout (); + + return offset >= 0; + } } - public uint Offset { - get { return m_offset; } - set { - m_hasInfo = true; - m_offset = value; + public int Offset { + get { + if (offset >= 0) + return offset; + + ResolveLayout (); + + return offset >= 0 ? offset : -1; } + set { offset = value; } } - public RVA RVA { - get { return m_rva; } - set { m_rva = value; } + void ResolveRVA () + { + if (rva != Mixin.NotResolvedMarker) + return; + + if (!HasImage) + return; + + rva = Module.Read (this, (field, reader) => reader.ReadFieldRVA (field)); + } + + public int RVA { + get { + if (rva > 0) + return rva; + + ResolveRVA (); + + return rva > 0 ? rva : 0; + } } public byte [] InitialValue { - get { return m_initVal; } - set { m_initVal = value; } + get { + if (initial_value != null) + return initial_value; + + ResolveRVA (); + + if (initial_value == null) + initial_value = Empty.Array; + + return initial_value; + } + set { initial_value = value; } } public FieldAttributes Attributes { - get { return m_attributes; } - set { m_attributes = value; } + get { return (FieldAttributes) attributes; } + set { attributes = (ushort) value; } } public bool HasConstant { - get { return m_hasConstant; } + get { + ResolveConstant (); + + return constant != Mixin.NoValue; + } + set { if (!value) constant = Mixin.NoValue; } } public object Constant { - get { return m_const; } - set { - m_hasConstant = true; - m_const = value; - } + get { return HasConstant ? constant : null; } + set { constant = value; } + } + + void ResolveConstant () + { + if (constant != Mixin.NotResolved) + return; + + this.ResolveConstant (ref constant, Module); } - public CustomAttributeCollection CustomAttributes { + public bool HasCustomAttributes { get { - if (m_customAttrs == null) - m_customAttrs = new CustomAttributeCollection (this); + if (custom_attributes != null) + return custom_attributes.Count > 0; - return m_customAttrs; + return this.GetHasCustomAttributes (Module); } } - public MarshalSpec MarshalSpec { - get { return m_marshalDesc; } - set { - m_marshalDesc = value; - if (value != null) - m_attributes |= FieldAttributes.HasFieldMarshal; - else - m_attributes &= FieldAttributes.HasFieldMarshal; + public Collection CustomAttributes { + get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (Module)); } + } + + public bool HasMarshalInfo { + get { + if (marshal_info != null) + return true; + + return this.GetHasMarshalInfo (Module); } } + public MarshalInfo MarshalInfo { + get { return marshal_info ?? (marshal_info = this.GetMarshalInfo (Module)); } + set { marshal_info = value; } + } + #region FieldAttributes public bool IsCompilerControlled { - get { return (m_attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Compilercontrolled; } - set { - if (value) { - m_attributes &= ~FieldAttributes.FieldAccessMask; - m_attributes |= FieldAttributes.Compilercontrolled; - } else - m_attributes &= ~(FieldAttributes.FieldAccessMask & FieldAttributes.Compilercontrolled); - } + get { return attributes.GetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.CompilerControlled); } + set { attributes = attributes.SetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.CompilerControlled, value); } } public bool IsPrivate { - get { return (m_attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Private; } - set { - if (value) { - m_attributes &= ~FieldAttributes.FieldAccessMask; - m_attributes |= FieldAttributes.Private; - } else - m_attributes &= ~(FieldAttributes.FieldAccessMask & FieldAttributes.Private); - } + get { return attributes.GetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.Private); } + set { attributes = attributes.SetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.Private, value); } } public bool IsFamilyAndAssembly { - get { return (m_attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.FamANDAssem; } - set { - if (value) { - m_attributes &= ~FieldAttributes.FieldAccessMask; - m_attributes |= FieldAttributes.FamANDAssem; - } else - m_attributes &= ~(FieldAttributes.FieldAccessMask & FieldAttributes.FamANDAssem); - } + get { return attributes.GetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.FamANDAssem); } + set { attributes = attributes.SetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.FamANDAssem, value); } } public bool IsAssembly { - get { return (m_attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Assembly; } - set { - if (value) { - m_attributes &= ~FieldAttributes.FieldAccessMask; - m_attributes |= FieldAttributes.Assembly; - } else - m_attributes &= ~(FieldAttributes.FieldAccessMask & FieldAttributes.Assembly); - } + get { return attributes.GetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.Assembly); } + set { attributes = attributes.SetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.Assembly, value); } } public bool IsFamily { - get { return (m_attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Family; } - set { - if (value) { - m_attributes &= ~FieldAttributes.FieldAccessMask; - m_attributes |= FieldAttributes.Family; - } else - m_attributes &= ~(FieldAttributes.FieldAccessMask & FieldAttributes.Family); - } + get { return attributes.GetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.Family); } + set { attributes = attributes.SetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.Family, value); } } public bool IsFamilyOrAssembly { - get { return (m_attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.FamORAssem; } - set { - if (value) { - m_attributes &= ~FieldAttributes.FieldAccessMask; - m_attributes |= FieldAttributes.FamORAssem; - } else - m_attributes &= ~(FieldAttributes.FieldAccessMask & FieldAttributes.FamORAssem); - } + get { return attributes.GetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.FamORAssem); } + set { attributes = attributes.SetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.FamORAssem, value); } } public bool IsPublic { - get { return (m_attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Public; } - set { - if (value) { - m_attributes &= ~FieldAttributes.FieldAccessMask; - m_attributes |= FieldAttributes.Public; - } else - m_attributes &= ~(FieldAttributes.FieldAccessMask & FieldAttributes.Public); - } + get { return attributes.GetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.Public); } + set { attributes = attributes.SetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.Public, value); } } public bool IsStatic { - get { return (m_attributes & FieldAttributes.Static) != 0; } - set { - if (value) - m_attributes |= FieldAttributes.Static; - else - m_attributes &= ~FieldAttributes.Static; - } + get { return attributes.GetAttributes ((ushort) FieldAttributes.Static); } + set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.Static, value); } } public bool IsInitOnly { - get { return (m_attributes & FieldAttributes.InitOnly) != 0; } - set { - if (value) - m_attributes |= FieldAttributes.InitOnly; - else - m_attributes &= ~FieldAttributes.InitOnly; - } + get { return attributes.GetAttributes ((ushort) FieldAttributes.InitOnly); } + set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.InitOnly, value); } } public bool IsLiteral { - get { return (m_attributes & FieldAttributes.Literal) != 0; } - set { - if (value) - m_attributes |= FieldAttributes.Literal; - else - m_attributes &= ~FieldAttributes.Literal; - } + get { return attributes.GetAttributes ((ushort) FieldAttributes.Literal); } + set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.Literal, value); } } public bool IsNotSerialized { - get { return (m_attributes & FieldAttributes.NotSerialized) != 0; } - set { - if (value) - m_attributes |= FieldAttributes.NotSerialized; - else - m_attributes &= ~FieldAttributes.NotSerialized; - } + get { return attributes.GetAttributes ((ushort) FieldAttributes.NotSerialized); } + set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.NotSerialized, value); } } public bool IsSpecialName { - get { return (m_attributes & FieldAttributes.SpecialName) != 0; } - set { - if (value) - m_attributes |= FieldAttributes.SpecialName; - else - m_attributes &= ~FieldAttributes.SpecialName; - } + get { return attributes.GetAttributes ((ushort) FieldAttributes.SpecialName); } + set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.SpecialName, value); } } public bool IsPInvokeImpl { - get { return (m_attributes & FieldAttributes.PInvokeImpl) != 0; } - set { - if (value) - m_attributes |= FieldAttributes.PInvokeImpl; - else - m_attributes &= ~FieldAttributes.PInvokeImpl; - } + get { return attributes.GetAttributes ((ushort) FieldAttributes.PInvokeImpl); } + set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.PInvokeImpl, value); } } public bool IsRuntimeSpecialName { - get { return (m_attributes & FieldAttributes.RTSpecialName) != 0; } - set { - if (value) - m_attributes |= FieldAttributes.RTSpecialName; - else - m_attributes &= ~FieldAttributes.RTSpecialName; - } + get { return attributes.GetAttributes ((ushort) FieldAttributes.RTSpecialName); } + set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.RTSpecialName, value); } } public bool HasDefault { - get { return (m_attributes & FieldAttributes.HasDefault) != 0; } - set { - if (value) - m_attributes |= FieldAttributes.HasDefault; - else - m_attributes &= ~FieldAttributes.HasDefault; - } + get { return attributes.GetAttributes ((ushort) FieldAttributes.HasDefault); } + set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.HasDefault, value); } } #endregion - public FieldDefinition (string name, TypeReference fieldType, - FieldAttributes attrs) : base (name, fieldType) - { - m_attributes = attrs; + public override bool IsDefinition { + get { return true; } } - public FieldDefinition Clone () - { - return Clone (this, new ImportContext (NullReferenceImporter.Instance, this.DeclaringType)); + public new TypeDefinition DeclaringType { + get { return (TypeDefinition) base.DeclaringType; } + set { base.DeclaringType = value; } } - internal static FieldDefinition Clone (FieldDefinition field, ImportContext context) + public FieldDefinition (string name, FieldAttributes attributes, TypeReference fieldType) + : base (name, fieldType) { - FieldDefinition nf = new FieldDefinition ( - field.Name, - context.Import (field.FieldType), - field.Attributes); - - if (field.HasConstant) - nf.Constant = field.Constant; - if (field.MarshalSpec != null) - nf.MarshalSpec = field.MarshalSpec; - if (field.RVA != RVA.Zero) - nf.InitialValue = field.InitialValue; - else - nf.InitialValue = new byte [0]; - if (field.HasLayoutInfo) - nf.Offset = field.Offset; - - foreach (CustomAttribute ca in field.CustomAttributes) - nf.CustomAttributes.Add (CustomAttribute.Clone (ca, context)); - - return nf; + this.attributes = (ushort) attributes; } - public override void Accept (IReflectionVisitor visitor) + public override FieldDefinition Resolve () { - visitor.VisitFieldDefinition (this); + return this; + } + } - if (this.MarshalSpec != null) - this.MarshalSpec.Accept (visitor); + static partial class Mixin { - this.CustomAttributes.Accept (visitor); - } + public const int NotResolvedMarker = -2; + public const int NoDataMarker = -1; } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldReference.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldReference.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldReference.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldReference.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,33 +26,58 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { +using System; - using Mono.Cecil; +namespace Mono.Cecil { public class FieldReference : MemberReference { - TypeReference m_fieldType; + TypeReference field_type; public TypeReference FieldType { - get { return m_fieldType; } - set { m_fieldType = value; } + get { return field_type; } + set { field_type = value; } + } + + public override string FullName { + get { return field_type.FullName + " " + MemberFullName (); } + } + + internal override bool ContainsGenericParameter { + get { return field_type.ContainsGenericParameter || base.ContainsGenericParameter; } } - internal FieldReference (string name, TypeReference fieldType) : base (name) + internal FieldReference () { - m_fieldType = fieldType; + this.token = new MetadataToken (TokenType.MemberRef); } - public FieldReference (string name, TypeReference declaringType, TypeReference fieldType) : - this (name, fieldType) + public FieldReference (string name, TypeReference fieldType) + : base (name) { + if (fieldType == null) + throw new ArgumentNullException ("fieldType"); + + this.field_type = fieldType; + this.token = new MetadataToken (TokenType.MemberRef); + } + + public FieldReference (string name, TypeReference fieldType, TypeReference declaringType) + : this (name, fieldType) + { + if (declaringType == null) + throw new ArgumentNullException("declaringType"); + this.DeclaringType = declaringType; } - public override string ToString () + public virtual FieldDefinition Resolve () { - return string.Concat (m_fieldType.FullName, " ", base.ToString ()); + var module = this.Module; + if (module == null) + throw new NotSupportedException (); + + return module.Resolve (this); } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FileAttributes.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FileAttributes.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FileAttributes.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FileAttributes.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -28,7 +28,7 @@ namespace Mono.Cecil { - public enum FileAttributes : uint { + enum FileAttributes : uint { ContainsMetaData = 0x0000, // This is not a resource file ContainsNoMetaData = 0x0001, // This is a resource file or other non-metadata-containing file } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FunctionPointerType.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FunctionPointerType.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FunctionPointerType.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FunctionPointerType.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 - 2007 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,41 +26,51 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { +using System; +using System.Text; +using Mono.Collections.Generic; +using MD = Mono.Cecil.Metadata; - using System; - using System.Text; +namespace Mono.Cecil { public sealed class FunctionPointerType : TypeSpecification, IMethodSignature { - MethodReference m_function; + readonly MethodReference function; public bool HasThis { - get { return m_function.HasThis; } - set { m_function.HasThis = value; } + get { return function.HasThis; } + set { function.HasThis = value; } } public bool ExplicitThis { - get { return m_function.ExplicitThis; } - set { m_function.ExplicitThis = value; } + get { return function.ExplicitThis; } + set { function.ExplicitThis = value; } } public MethodCallingConvention CallingConvention { - get { return m_function.CallingConvention; } - set { m_function.CallingConvention = value; } + get { return function.CallingConvention; } + set { function.CallingConvention = value; } + } + + public bool HasParameters { + get { return function.HasParameters; } } - public ParameterDefinitionCollection Parameters { - get { return m_function.Parameters; } + public Collection Parameters { + get { return function.Parameters; } } - public MethodReturnType ReturnType { - get { return m_function.ReturnType; } - set { m_function.ReturnType = value; } + public TypeReference ReturnType { + get { return function.MethodReturnType.ReturnType; } + set { function.MethodReturnType.ReturnType = value; } + } + + public MethodReturnType MethodReturnType { + get { return function.MethodReturnType; } } public override string Name { - get { return m_function.Name; } + get { return function.Name; } set { throw new InvalidOperationException (); } } @@ -69,42 +79,50 @@ set { throw new InvalidOperationException (); } } + public override ModuleDefinition Module { + get { return ReturnType.Module; } + } + public override IMetadataScope Scope { - get { return m_function.DeclaringType.Scope; } + get { return function.ReturnType.Scope; } + } + + public override bool IsFunctionPointer { + get { return true; } + } + + internal override bool ContainsGenericParameter { + get { return function.ContainsGenericParameter; } } public override string FullName { get { - int sentinel = GetSentinel (); - StringBuilder sb = new StringBuilder (); - sb.Append (m_function.Name); - sb.Append (" "); - sb.Append (m_function.ReturnType.ReturnType.FullName); - sb.Append (" *("); - for (int i = 0; i < m_function.Parameters.Count; i++) { - if (i > 0) - sb.Append (","); - - if (i == sentinel) - sb.Append ("...,"); - - sb.Append (m_function.Parameters [i].ParameterType.FullName); - } - sb.Append (")"); - return sb.ToString (); + var signature = new StringBuilder (); + signature.Append (function.Name); + signature.Append (" "); + signature.Append (function.ReturnType.FullName); + signature.Append (" *"); + this.MethodSignatureFullName (signature); + return signature.ToString (); } } - public FunctionPointerType (bool hasThis, bool explicitThis, MethodCallingConvention callConv, MethodReturnType retType) : - base (retType.ReturnType) + public FunctionPointerType () + : base (null) + { + this.function = new MethodReference (); + this.function.Name = "method"; + this.etype = MD.ElementType.FnPtr; + } + + public override TypeDefinition Resolve () { - m_function = new MethodReference ("method", hasThis, explicitThis, callConv); - m_function.ReturnType = retType; + return null; } - public int GetSentinel () + public override TypeReference GetElementType () { - return m_function.GetSentinel (); + return this; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericArgumentCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericArgumentCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericArgumentCollection.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericArgumentCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -// -// GenericArgumentCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Wed Sep 27 12:46:54 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.Collections; - - using Mono.Cecil.Cil; - - public sealed class GenericArgumentCollection : CollectionBase { - - IGenericInstance m_container; - - public TypeReference this [int index] { - get { return List [index] as TypeReference; } - set { List [index] = value; } - } - - public IGenericInstance Container { - get { return m_container; } - } - - public GenericArgumentCollection (IGenericInstance container) - { - m_container = container; - } - - public void Add (TypeReference value) - { - List.Add (value); - } - - public bool Contains (TypeReference value) - { - return List.Contains (value); - } - - public int IndexOf (TypeReference value) - { - return List.IndexOf (value); - } - - public void Insert (int index, TypeReference value) - { - List.Insert (index, value); - } - - public void Remove (TypeReference value) - { - List.Remove (value); - } - - protected override void OnValidate (object o) - { - if (! (o is TypeReference)) - throw new ArgumentException ("Must be of type " + typeof (TypeReference).FullName); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericContext.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericContext.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericContext.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericContext.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ -// -// GenericContext.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - public class GenericContext { - - TypeReference m_type; - MethodReference m_method; - - public TypeReference Type { - get { return m_type; } - set { m_type = value; } - } - - public MethodReference Method { - get { return m_method; } - set { m_method = value; } - } - - public bool AllowCreation { - get { return m_type != null && m_type.GetType () == typeof (TypeReference); } - } - - public bool Null { - get { return m_type == null && m_method == null; } - } - - public GenericContext () - { - } - - public GenericContext (TypeReference type, MethodReference meth) - { - m_type = type; - m_method = meth; - } - - public GenericContext (IGenericParameterProvider provider) - { - if (provider is TypeReference) - m_type = provider as TypeReference; - else if (provider is MethodReference) { - MethodReference meth = provider as MethodReference; - m_method = meth; - m_type = meth.DeclaringType; - } - } - - internal void CheckProvider (IGenericParameterProvider provider, int count) - { - if (!AllowCreation) - return; - - for (int i = provider.GenericParameters.Count; i < count; i++) - provider.GenericParameters.Add (new GenericParameter (i, provider)); - } - - public GenericContext Clone () - { - GenericContext ctx = new GenericContext (); - ctx.Type = m_type; - ctx.Method = m_method; - return ctx; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericInstanceMethod.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericInstanceMethod.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericInstanceMethod.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericInstanceMethod.cs 2011-04-13 09:00:29.000000000 +0000 @@ -1,10 +1,10 @@ // -// IGenericInstanceMethod.cs +// GenericInstanceMethod.cs // // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,50 +26,65 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System; +using System.Text; + +using Mono.Collections.Generic; + namespace Mono.Cecil { - using System.Text; + public sealed class GenericInstanceMethod : MethodSpecification, IGenericInstance, IGenericContext { - public sealed class GenericInstanceMethod : MethodSpecification, IGenericInstance { + Collection arguments; - private GenericArgumentCollection m_genArgs; + public bool HasGenericArguments { + get { return !arguments.IsNullOrEmpty (); } + } - public GenericArgumentCollection GenericArguments { + public Collection GenericArguments { get { - if (m_genArgs == null) - m_genArgs = new GenericArgumentCollection (this); - return m_genArgs; + if (arguments == null) + arguments = new Collection (); + + return arguments; } } - public GenericInstanceMethod (MethodReference elemMethod) : base (elemMethod) - { + public override bool IsGenericInstance { + get { return true; } } - public override string ToString () - { - StringBuilder sb = new StringBuilder (); - MethodReference meth = this.ElementMethod; - sb.Append (meth.ReturnType.ReturnType.FullName); - sb.Append (" "); - sb.Append (meth.DeclaringType.FullName); - sb.Append ("::"); - sb.Append (meth.Name); - sb.Append ("<"); - for (int i = 0; i < this.GenericArguments.Count; i++) { - if (i > 0) - sb.Append (","); - sb.Append (this.GenericArguments [i].FullName); - } - sb.Append (">"); - sb.Append ("("); - for (int i = 0; i < meth.Parameters.Count; i++) { - sb.Append (meth.Parameters [i].ParameterType.FullName); - if (i < meth.Parameters.Count - 1) - sb.Append (","); + IGenericParameterProvider IGenericContext.Method { + get { return ElementMethod; } + } + + IGenericParameterProvider IGenericContext.Type { + get { return ElementMethod.DeclaringType; } + } + + internal override bool ContainsGenericParameter { + get { return this.ContainsGenericParameter () || base.ContainsGenericParameter; } + } + + public override string FullName { + get { + var signature = new StringBuilder (); + var method = this.ElementMethod; + signature.Append (method.ReturnType.FullName); + signature.Append (" "); + signature.Append (method.DeclaringType.FullName); + signature.Append ("::"); + signature.Append (method.Name); + this.GenericInstanceFullName (signature); + this.MethodSignatureFullName (signature); + return signature.ToString (); + } - sb.Append (")"); - return sb.ToString (); + } + + public GenericInstanceMethod (MethodReference method) + : base (method) + { } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericInstanceType.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericInstanceType.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericInstanceType.cs 2008-11-06 19:52:04.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericInstanceType.cs 2011-04-13 09:00:29.000000000 +0000 @@ -2,10 +2,9 @@ // GenericInstanceType.cs // // Author: -// Martin Baulig -// Jb Evain +// Jb Evain (jbevain@gmail.com) // -// Copyright (C) 2005 Novell, Inc (http://www.novell.com) +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -27,45 +26,63 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System; +using System.Text; + +using Mono.Collections.Generic; + +using MD = Mono.Cecil.Metadata; + namespace Mono.Cecil { - using System.Text; + public sealed class GenericInstanceType : TypeSpecification, IGenericInstance, IGenericContext { - public sealed class GenericInstanceType : TypeSpecification, IGenericInstance { + Collection arguments; - private GenericArgumentCollection m_genArgs; + public bool HasGenericArguments { + get { return !arguments.IsNullOrEmpty (); } + } - public GenericArgumentCollection GenericArguments { + public Collection GenericArguments { get { - if (m_genArgs == null) - m_genArgs = new GenericArgumentCollection (this); - return m_genArgs; + if (arguments == null) + arguments = new Collection (); + + return arguments; } } - public override bool IsValueType { - get { return m_isValueType; } - set { m_isValueType = value; } + public override TypeReference DeclaringType { + get { return ElementType.DeclaringType; } + set { throw new NotSupportedException (); } } public override string FullName { get { - StringBuilder sb = new StringBuilder (); - sb.Append (base.FullName); - sb.Append ("<"); - for (int i = 0; i < this.GenericArguments.Count; i++) { - if (i > 0) - sb.Append (","); - sb.Append (this.GenericArguments [i].FullName); - } - sb.Append (">"); - return sb.ToString (); + var name = new StringBuilder (); + name.Append (base.FullName); + this.GenericInstanceFullName (name); + return name.ToString (); } } - public GenericInstanceType (TypeReference elementType) : base (elementType) + public override bool IsGenericInstance { + get { return true; } + } + + internal override bool ContainsGenericParameter { + get { return this.ContainsGenericParameter () || base.ContainsGenericParameter; } + } + + IGenericParameterProvider IGenericContext.Type { + get { return ElementType; } + } + + public GenericInstanceType (TypeReference type) + : base (type) { - m_isValueType = elementType.IsValueType; + base.IsValueType = type.IsValueType; + this.etype = MD.ElementType.GenericInst; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericParameterAttributes.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericParameterAttributes.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericParameterAttributes.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericParameterAttributes.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,9 +26,9 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { +using System; - using System; +namespace Mono.Cecil { [Flags] public enum GenericParameterAttributes : ushort { diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericParameterCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericParameterCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericParameterCollection.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericParameterCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ -// -// GenericParameterCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Wed Sep 27 12:46:53 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.Collections; - - using Mono.Cecil.Cil; - - public sealed class GenericParameterCollection : CollectionBase, IReflectionVisitable { - - IGenericParameterProvider m_container; - - public GenericParameter this [int index] { - get { return List [index] as GenericParameter; } - set { List [index] = value; } - } - - public IGenericParameterProvider Container { - get { return m_container; } - } - - public GenericParameterCollection (IGenericParameterProvider container) - { - m_container = container; - } - - public void Add (GenericParameter value) - { - List.Add (value); - } - - public bool Contains (GenericParameter value) - { - return List.Contains (value); - } - - public int IndexOf (GenericParameter value) - { - return List.IndexOf (value); - } - - public void Insert (int index, GenericParameter value) - { - List.Insert (index, value); - } - - public void Remove (GenericParameter value) - { - List.Remove (value); - } - - protected override void OnValidate (object o) - { - if (! (o is GenericParameter)) - throw new ArgumentException ("Must be of type " + typeof (GenericParameter).FullName); - } - - public void Accept (IReflectionVisitor visitor) - { - visitor.VisitGenericParameterCollection (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericParameter.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericParameter.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericParameter.cs 2008-11-06 19:52:04.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericParameter.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,54 +26,101 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System; + +using Mono.Collections.Generic; + +using Mono.Cecil.Metadata; + namespace Mono.Cecil { - using System; + public sealed class GenericParameter : TypeReference, ICustomAttributeProvider { - public sealed class GenericParameter : TypeReference { + readonly IGenericParameterProvider owner; - int m_position; - string m_name; - GenericParameterAttributes m_attributes; - IGenericParameterProvider m_owner; - ConstraintCollection m_constraints; + ushort attributes; + Collection constraints; + Collection custom_attributes; - public int Position { - get { return m_position; } - set { m_position = value; } + public GenericParameterAttributes Attributes { + get { return (GenericParameterAttributes) attributes; } + set { attributes = (ushort) value; } } - public GenericParameterAttributes Attributes { - get { return m_attributes; } - set { m_attributes = value; } + public int Position { + get { + if (owner == null) + return -1; + + return owner.GenericParameters.IndexOf (this); + } } public IGenericParameterProvider Owner { - get { return m_owner; } + get { return owner; } + } + + public bool HasConstraints { + get { + if (constraints != null) + return constraints.Count > 0; + + if (HasImage) + return Module.Read (this, (generic_parameter, reader) => reader.HasGenericConstraints (generic_parameter)); + + return false; + } + } + + public Collection Constraints { + get { + if (constraints != null) + return constraints; + + if (HasImage) + return constraints = Module.Read (this, (generic_parameter, reader) => reader.ReadGenericConstraints (generic_parameter)); + + return constraints = new Collection (); + } } - public ConstraintCollection Constraints { + public bool HasCustomAttributes { get { - if (m_constraints == null) - m_constraints = new ConstraintCollection (this); + if (custom_attributes != null) + return custom_attributes.Count > 0; - return m_constraints; + return this.GetHasCustomAttributes (Module); } } + public Collection CustomAttributes { + get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (Module)); } + } + + internal new bool HasImage { + get { return Module != null && Module.HasImage; } + } + + public override IMetadataScope Scope { + get { + if (owner.GenericParameterType == GenericParameterType.Method) + return ((MethodReference) owner).DeclaringType.Scope; + + return ((TypeReference) owner).Scope; + } + } + + public override ModuleDefinition Module { + get { return ((MemberReference) owner).Module; } + } + public override string Name { get { - if (m_name != null) - return m_name; + if (!string.IsNullOrEmpty (base.Name)) + return base.Name; - if (m_owner is TypeReference) - return string.Concat ("!", m_position.ToString ()); - else if (m_owner is MethodReference) - return string.Concat ("!!", m_position.ToString ()); - else - throw new InvalidOperationException (); + return base.Name = (owner.GenericParameterType == GenericParameterType.Type ? "!" : "!!") + Position; } - set { m_name = value; } } public override string Namespace { @@ -85,109 +132,70 @@ get { return Name; } } + public override bool IsGenericParameter { + get { return true; } + } + + internal override bool ContainsGenericParameter { + get { return true; } + } + + public override MetadataType MetadataType { + get { return (MetadataType) etype; } + } + #region GenericParameterAttributes public bool IsNonVariant { - get { return (m_attributes & GenericParameterAttributes.VarianceMask) == GenericParameterAttributes.NonVariant; } - set { - if (value) { - m_attributes &= ~GenericParameterAttributes.VarianceMask; - m_attributes |= GenericParameterAttributes.NonVariant; - } else - m_attributes &= ~(GenericParameterAttributes.VarianceMask & GenericParameterAttributes.NonVariant); - } + get { return attributes.GetMaskedAttributes ((ushort) GenericParameterAttributes.VarianceMask, (ushort) GenericParameterAttributes.NonVariant); } + set { attributes = attributes.SetMaskedAttributes ((ushort) GenericParameterAttributes.VarianceMask, (ushort) GenericParameterAttributes.NonVariant, value); } } public bool IsCovariant { - get { return (m_attributes & GenericParameterAttributes.VarianceMask) == GenericParameterAttributes.Covariant; } - set { - if (value) { - m_attributes &= ~GenericParameterAttributes.VarianceMask; - m_attributes |= GenericParameterAttributes.Covariant; - } else - m_attributes &= ~(GenericParameterAttributes.VarianceMask & GenericParameterAttributes.Covariant); - } + get { return attributes.GetMaskedAttributes ((ushort) GenericParameterAttributes.VarianceMask, (ushort) GenericParameterAttributes.Covariant); } + set { attributes = attributes.SetMaskedAttributes ((ushort) GenericParameterAttributes.VarianceMask, (ushort) GenericParameterAttributes.Covariant, value); } } public bool IsContravariant { - get { return (m_attributes & GenericParameterAttributes.VarianceMask) == GenericParameterAttributes.Contravariant; } - set { - if (value) { - m_attributes &= ~GenericParameterAttributes.VarianceMask; - m_attributes |= GenericParameterAttributes.Contravariant; - } else - m_attributes &= ~(GenericParameterAttributes.VarianceMask & GenericParameterAttributes.Contravariant); - } + get { return attributes.GetMaskedAttributes ((ushort) GenericParameterAttributes.VarianceMask, (ushort) GenericParameterAttributes.Contravariant); } + set { attributes = attributes.SetMaskedAttributes ((ushort) GenericParameterAttributes.VarianceMask, (ushort) GenericParameterAttributes.Contravariant, value); } } public bool HasReferenceTypeConstraint { - get { return (m_attributes & GenericParameterAttributes.SpecialConstraintMask) == GenericParameterAttributes.ReferenceTypeConstraint; } - set { - if (value) { - m_attributes &= ~GenericParameterAttributes.SpecialConstraintMask; - m_attributes |= GenericParameterAttributes.ReferenceTypeConstraint; - } else - m_attributes &= ~(GenericParameterAttributes.SpecialConstraintMask & GenericParameterAttributes.ReferenceTypeConstraint); - } + get { return attributes.GetAttributes ((ushort) GenericParameterAttributes.ReferenceTypeConstraint); } + set { attributes = attributes.SetAttributes ((ushort) GenericParameterAttributes.ReferenceTypeConstraint, value); } } public bool HasNotNullableValueTypeConstraint { - get { return (m_attributes & GenericParameterAttributes.SpecialConstraintMask) == GenericParameterAttributes.NotNullableValueTypeConstraint; } - set { - if (value) { - m_attributes &= ~GenericParameterAttributes.SpecialConstraintMask; - m_attributes |= GenericParameterAttributes.NotNullableValueTypeConstraint; - } else - m_attributes &= ~(GenericParameterAttributes.SpecialConstraintMask & GenericParameterAttributes.NotNullableValueTypeConstraint); - } + get { return attributes.GetAttributes ((ushort) GenericParameterAttributes.NotNullableValueTypeConstraint); } + set { attributes = attributes.SetAttributes ((ushort) GenericParameterAttributes.NotNullableValueTypeConstraint, value); } } public bool HasDefaultConstructorConstraint { - get { return (m_attributes & GenericParameterAttributes.SpecialConstraintMask) == GenericParameterAttributes.DefaultConstructorConstraint; } - set { - if (value) { - m_attributes &= ~GenericParameterAttributes.SpecialConstraintMask; - m_attributes |= GenericParameterAttributes.DefaultConstructorConstraint; - } else - m_attributes &= ~(GenericParameterAttributes.SpecialConstraintMask & GenericParameterAttributes.DefaultConstructorConstraint); - } + get { return attributes.GetAttributes ((ushort) GenericParameterAttributes.DefaultConstructorConstraint); } + set { attributes = attributes.SetAttributes ((ushort) GenericParameterAttributes.DefaultConstructorConstraint, value); } } #endregion - internal GenericParameter (int pos, IGenericParameterProvider owner) : - base (string.Empty, string.Empty) + public GenericParameter (IGenericParameterProvider owner) + : this (string.Empty, owner) { - m_position = pos; - m_owner = owner; } - public GenericParameter (string name, IGenericParameterProvider owner) : - base (string.Empty, string.Empty) + public GenericParameter (string name, IGenericParameterProvider owner) + : base (string.Empty, name) { - m_name = name; - m_owner = owner; + if (owner == null) + throw new ArgumentNullException (); + + this.owner = owner; + this.etype = owner.GenericParameterType == GenericParameterType.Type ? ElementType.Var : ElementType.MVar; } - internal static GenericParameter Clone (GenericParameter gp, ImportContext context) + public override TypeDefinition Resolve () { - GenericParameter ngp; - if (gp.Owner is TypeReference) - ngp = new GenericParameter (gp.m_name, context.GenericContext.Type); - else if (gp.Owner is MethodReference) - ngp = new GenericParameter (gp.m_name, context.GenericContext.Method); - else - throw new NotSupportedException (); - - ngp.Position = gp.Owner.GenericParameters.IndexOf (gp); - ngp.Attributes = gp.Attributes; - - foreach (TypeReference constraint in gp.Constraints) - ngp.Constraints.Add (context.Import (constraint)); - foreach (CustomAttribute ca in gp.CustomAttributes) - ngp.CustomAttributes.Add (CustomAttribute.Clone (ca, context)); - - return ngp; + return null; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/HashCodeProvider.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/HashCodeProvider.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/HashCodeProvider.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/HashCodeProvider.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -// -// HashCodeProvider.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System.Collections; - - internal sealed class HashCodeProvider : IHashCodeProvider { - - public static readonly HashCodeProvider Instance = new HashCodeProvider (); - - HashCodeProvider () - { - } - - public int GetHashCode (object o) - { - return o.GetHashCode (); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IAnnotationProvider.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IAnnotationProvider.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IAnnotationProvider.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IAnnotationProvider.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// -// AssemblyDefinition.cs -// -// Author: -// Jb Evain (jbevain@novell.com) -// -// (C) 2007 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System.Collections; - - public interface IAnnotationProvider { - - IDictionary Annotations { get; } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IAssemblyResolver.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IAssemblyResolver.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IAssemblyResolver.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IAssemblyResolver.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// -// IAssemblyResolver.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2006 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - public interface IAssemblyResolver { - - AssemblyDefinition Resolve (string fullName); - AssemblyDefinition Resolve (AssemblyNameReference name); - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IConstantProvider.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IConstantProvider.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IConstantProvider.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IConstantProvider.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,52 @@ +// +// IConstantProvider.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// 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. +// + +namespace Mono.Cecil { + + public interface IConstantProvider : IMetadataTokenProvider { + + bool HasConstant { get; set; } + object Constant { get; set; } + } + + static partial class Mixin { + + internal static object NoValue = new object (); + internal static object NotResolved = new object (); + + public static void ResolveConstant ( + this IConstantProvider self, + ref object constant, + ModuleDefinition module) + { + constant = module.HasImage () + ? module.Read (self, (provider, reader) => reader.ReadConstant (provider)) + : Mixin.NoValue; + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ICustomAttributeProvider.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ICustomAttributeProvider.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ICustomAttributeProvider.cs 2008-11-06 19:52:04.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ICustomAttributeProvider.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,12 +26,37 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System; + +using Mono.Collections.Generic; + namespace Mono.Cecil { - using System.Reflection; + public interface ICustomAttributeProvider : IMetadataTokenProvider { + + Collection CustomAttributes { get; } + + bool HasCustomAttributes { get; } + } + + static partial class Mixin { - public interface ICustomAttributeProvider { + public static bool GetHasCustomAttributes ( + this ICustomAttributeProvider self, + ModuleDefinition module) + { + return module.HasImage () + ? module.Read (self, (provider, reader) => reader.HasCustomAttributes (provider)) + : false; + } - CustomAttributeCollection CustomAttributes { get; } + public static Collection GetCustomAttributes ( + this ICustomAttributeProvider self, + ModuleDefinition module) + { + return module.HasImage () + ? module.Read (self, (provider, reader) => reader.ReadCustomAttributes (provider)) + : new Collection (); + } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IDetailReader.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IDetailReader.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IDetailReader.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IDetailReader.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// -// IDetailReader.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - internal interface IDetailReader { - - void ReadSemantic (EventDefinition evt); - void ReadSemantic (PropertyDefinition prop); - - void ReadMarshalSpec (ParameterDefinition param); - void ReadMarshalSpec (FieldDefinition field); - - void ReadLayout (TypeDefinition type); - void ReadLayout (FieldDefinition field); - - void ReadConstant (FieldDefinition field); - void ReadConstant (PropertyDefinition prop); - void ReadConstant (ParameterDefinition param); - - void ReadInitialValue (FieldDefinition field); - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IGenericInstance.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IGenericInstance.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IGenericInstance.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IGenericInstance.cs 2011-04-13 09:00:29.000000000 +0000 @@ -1,10 +1,10 @@ // -// IGenericInstanceMethod.cs +// IGenericInstance.cs // // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,10 +26,41 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System.Text; + +using Mono.Collections.Generic; + namespace Mono.Cecil { public interface IGenericInstance : IMetadataTokenProvider { - GenericArgumentCollection GenericArguments { get; } + bool HasGenericArguments { get; } + Collection GenericArguments { get; } + } + + static partial class Mixin { + + public static bool ContainsGenericParameter (this IGenericInstance self) + { + var arguments = self.GenericArguments; + + for (int i = 0; i < arguments.Count; i++) + if (arguments [i].ContainsGenericParameter) + return true; + + return false; + } + + public static void GenericInstanceFullName (this IGenericInstance self, StringBuilder builder) + { + builder.Append ("<"); + var arguments = self.GenericArguments; + for (int i = 0; i < arguments.Count; i++) { + if (i > 0) + builder.Append (","); + builder.Append (arguments [i].FullName); + } + builder.Append (">"); + } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IGenericParameterProvider.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IGenericParameterProvider.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IGenericParameterProvider.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IGenericParameterProvider.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,10 +26,50 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // + +using Mono.Collections.Generic; + namespace Mono.Cecil { public interface IGenericParameterProvider : IMetadataTokenProvider { - GenericParameterCollection GenericParameters { get; } + bool HasGenericParameters { get; } + bool IsDefinition { get; } + ModuleDefinition Module { get; } + Collection GenericParameters { get; } + GenericParameterType GenericParameterType { get; } + } + + public enum GenericParameterType { + Type, + Method + } + + interface IGenericContext { + + bool IsDefinition { get; } + IGenericParameterProvider Type { get; } + IGenericParameterProvider Method { get; } + } + + static partial class Mixin { + + public static bool GetHasGenericParameters ( + this IGenericParameterProvider self, + ModuleDefinition module) + { + return module.HasImage () + ? module.Read (self, (provider, reader) => reader.HasGenericParameters (provider)) + : false; + } + + public static Collection GetGenericParameters ( + this IGenericParameterProvider self, + ModuleDefinition module) + { + return module.HasImage () + ? module.Read (self, (provider, reader) => reader.ReadGenericParameters (provider)) + : new Collection (); + } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IHasConstant.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IHasConstant.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IHasConstant.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IHasConstant.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// -// IHasConstant.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - public interface IHasConstant : IMetadataTokenProvider { - - bool HasConstant { get; } - object Constant { get; set; } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IHasMarshalSpec.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IHasMarshalSpec.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IHasMarshalSpec.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IHasMarshalSpec.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// -// IHasMarshalSpec.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - public interface IHasMarshalSpec : IMetadataTokenProvider { - - MarshalSpec MarshalSpec { get; set; } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IHasSecurity.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IHasSecurity.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IHasSecurity.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IHasSecurity.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// -// IHasSecurity.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - public interface IHasSecurity : IMetadataTokenProvider { - - SecurityDeclarationCollection SecurityDeclarations { get; } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IImporter.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IImporter.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IImporter.cs 2008-11-06 19:52:04.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IImporter.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// -// IImporter.cs -// -// Author: -// Jb Evain (jbevain@novell.com) -// -// (C) 2007 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - public interface IImporter { - - TypeReference ImportTypeReference (TypeReference type, ImportContext context); - FieldReference ImportFieldReference (FieldReference field, ImportContext context); - MethodReference ImportMethodReference (MethodReference method, ImportContext context); - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMarshalInfoProvider.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMarshalInfoProvider.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMarshalInfoProvider.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMarshalInfoProvider.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,57 @@ +// +// IMarshalInfoProvider.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// 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. +// + +namespace Mono.Cecil { + + public interface IMarshalInfoProvider : IMetadataTokenProvider { + + bool HasMarshalInfo { get; } + MarshalInfo MarshalInfo { get; set; } + } + + static partial class Mixin { + + public static bool GetHasMarshalInfo ( + this IMarshalInfoProvider self, + ModuleDefinition module) + { + return module.HasImage () + ? module.Read (self, (provider, reader) => reader.HasMarshalInfo (provider)) + : false; + } + + public static MarshalInfo GetMarshalInfo ( + this IMarshalInfoProvider self, + ModuleDefinition module) + { + return module.HasImage () + ? module.Read (self, (provider, reader) => reader.ReadMarshalInfo (provider)) + : null; + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMemberDefinition.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMemberDefinition.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMemberDefinition.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMemberDefinition.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -28,9 +28,73 @@ namespace Mono.Cecil { - public interface IMemberDefinition : IMemberReference { + public interface IMemberDefinition : ICustomAttributeProvider { + + string Name { get; set; } + string FullName { get; } bool IsSpecialName { get; set; } bool IsRuntimeSpecialName { get; set; } + + TypeDefinition DeclaringType { get; set; } + } + + static partial class Mixin { + + public static bool GetAttributes (this uint self, uint attributes) + { + return (self & attributes) != 0; + } + + public static uint SetAttributes (this uint self, uint attributes, bool value) + { + if (value) + return self | attributes; + + return self & ~attributes; + } + + public static bool GetMaskedAttributes (this uint self, uint mask, uint attributes) + { + return (self & mask) == attributes; + } + + public static uint SetMaskedAttributes (this uint self, uint mask, uint attributes, bool value) + { + if (value) { + self &= ~mask; + return self | attributes; + } + + return self & ~(mask & attributes); + } + + public static bool GetAttributes (this ushort self, ushort attributes) + { + return (self & attributes) != 0; + } + + public static ushort SetAttributes (this ushort self, ushort attributes, bool value) + { + if (value) + return (ushort) (self | attributes); + + return (ushort) (self & ~attributes); + } + + public static bool GetMaskedAttributes (this ushort self, ushort mask, uint attributes) + { + return (self & mask) == attributes; + } + + public static ushort SetMaskedAttributes (this ushort self, ushort mask, uint attributes, bool value) + { + if (value) { + self = (ushort) (self & ~mask); + return (ushort) (self | attributes); + } + + return (ushort) (self & ~(mask & attributes)); + } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMemberReference.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMemberReference.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMemberReference.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMemberReference.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// -// IMemberReference.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - public interface IMemberReference : IMetadataTokenProvider, IAnnotationProvider, IReflectionVisitable { - - string Name { get; set; } - TypeReference DeclaringType { get; } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMetadataScope.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMetadataScope.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMetadataScope.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMetadataScope.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -28,7 +28,14 @@ namespace Mono.Cecil { + public enum MetadataScopeType { + AssemblyNameReference, + ModuleReference, + ModuleDefinition, + } + public interface IMetadataScope : IMetadataTokenProvider { + MetadataScopeType MetadataScopeType { get; } string Name { get; set; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMetadataTokenProvider.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMetadataTokenProvider.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMetadataTokenProvider.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMetadataTokenProvider.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -28,8 +28,6 @@ namespace Mono.Cecil { - using Mono.Cecil.Metadata; - public interface IMetadataTokenProvider { MetadataToken MetadataToken { get; set; } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMethodSignature.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMethodSignature.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMethodSignature.cs 2008-11-06 19:52:04.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMethodSignature.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 - 2007 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,17 +26,45 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System.Text; + +using Mono.Collections.Generic; + namespace Mono.Cecil { - public interface IMethodSignature { + public interface IMethodSignature : IMetadataTokenProvider { bool HasThis { get; set; } bool ExplicitThis { get; set; } MethodCallingConvention CallingConvention { get; set; } - ParameterDefinitionCollection Parameters { get; } - MethodReturnType ReturnType { get; } + bool HasParameters { get; } + Collection Parameters { get; } + TypeReference ReturnType { get; set; } + MethodReturnType MethodReturnType { get; } + } + + static partial class Mixin { + + public static void MethodSignatureFullName (this IMethodSignature self, StringBuilder builder) + { + builder.Append ("("); + + if (self.HasParameters) { + var parameters = self.Parameters; + for (int i = 0; i < parameters.Count; i++) { + var parameter = parameters [i]; + if (i > 0) + builder.Append (","); + + if (parameter.ParameterType.IsSentinel) + builder.Append ("...,"); + + builder.Append (parameter.ParameterType.FullName); + } + } - int GetSentinel (); + builder.Append (")"); + } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ImportContext.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ImportContext.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ImportContext.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ImportContext.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ -// -// ImportContext.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2006 Evaluant RC S.A. -// -// 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. -// - -namespace Mono.Cecil { - - public class ImportContext { - - GenericContext m_genContext; - IImporter m_importer; - - public GenericContext GenericContext { - get { return m_genContext; } - } - - public ImportContext (IImporter importer) - { - m_genContext = new GenericContext (); - m_importer = importer; - } - - public ImportContext (IImporter importer, IGenericParameterProvider provider) - { - m_importer = importer; - m_genContext = new GenericContext (provider); - } - - public TypeReference Import (TypeReference type) - { - return m_importer.ImportTypeReference (type, this); - } - - public MethodReference Import (MethodReference meth) - { - return m_importer.ImportMethodReference (meth, this); - } - - public FieldReference Import (FieldReference field) - { - return m_importer.ImportFieldReference (field, this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Import.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Import.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Import.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Import.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,566 @@ +// +// Import.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Collections.Generic; +using SR = System.Reflection; + +using Mono.Cecil.Metadata; + +namespace Mono.Cecil { + + enum ImportGenericKind { + Definition, + Open, + } + + class MetadataImporter { + + readonly ModuleDefinition module; + + public MetadataImporter (ModuleDefinition module) + { + this.module = module; + } + +#if !CF + static readonly Dictionary type_etype_mapping = new Dictionary (18) { + { typeof (void), ElementType.Void }, + { typeof (bool), ElementType.Boolean }, + { typeof (char), ElementType.Char }, + { typeof (sbyte), ElementType.I1 }, + { typeof (byte), ElementType.U1 }, + { typeof (short), ElementType.I2 }, + { typeof (ushort), ElementType.U2 }, + { typeof (int), ElementType.I4 }, + { typeof (uint), ElementType.U4 }, + { typeof (long), ElementType.I8 }, + { typeof (ulong), ElementType.U8 }, + { typeof (float), ElementType.R4 }, + { typeof (double), ElementType.R8 }, + { typeof (string), ElementType.String }, + { typeof (TypedReference), ElementType.TypedByRef }, + { typeof (IntPtr), ElementType.I }, + { typeof (UIntPtr), ElementType.U }, + { typeof (object), ElementType.Object }, + }; + + public TypeReference ImportType (Type type, IGenericContext context) + { + return ImportType (type, context, ImportGenericKind.Open); + } + + public TypeReference ImportType (Type type, IGenericContext context, ImportGenericKind import_kind) + { + if (IsTypeSpecification (type) || ImportOpenGenericType (type, import_kind)) + return ImportTypeSpecification (type, context); + + var reference = new TypeReference ( + string.Empty, + type.Name, + module, + ImportScope (type.Assembly), + type.IsValueType); + + reference.etype = ImportElementType (type); + + if (IsNestedType (type)) + reference.DeclaringType = ImportType (type.DeclaringType, context, import_kind); + else + reference.Namespace = type.Namespace; + + if (type.IsGenericType) + ImportGenericParameters (reference, type.GetGenericArguments ()); + + return reference; + } + + static bool ImportOpenGenericType (Type type, ImportGenericKind import_kind) + { + return type.IsGenericType && type.IsGenericTypeDefinition && import_kind == ImportGenericKind.Open; + } + + static bool ImportOpenGenericMethod (SR.MethodBase method, ImportGenericKind import_kind) + { + return method.IsGenericMethod && method.IsGenericMethodDefinition && import_kind == ImportGenericKind.Open; + } + + static bool IsNestedType (Type type) + { +#if !SILVERLIGHT + return type.IsNested; +#else + return type.DeclaringType != null; +#endif + } + + TypeReference ImportTypeSpecification (Type type, IGenericContext context) + { + if (type.IsByRef) + return new ByReferenceType (ImportType (type.GetElementType (), context)); + + if (type.IsPointer) + return new PointerType (ImportType (type.GetElementType (), context)); + + if (type.IsArray) + return new ArrayType (ImportType (type.GetElementType (), context), type.GetArrayRank ()); + + if (type.IsGenericType) + return ImportGenericInstance (type, context); + + if (type.IsGenericParameter) + return ImportGenericParameter (type, context); + + throw new NotSupportedException (type.FullName); + } + + static TypeReference ImportGenericParameter (Type type, IGenericContext context) + { + if (context == null) + throw new InvalidOperationException (); + + var owner = type.DeclaringMethod != null + ? context.Method + : context.Type; + + if (owner == null) + throw new InvalidOperationException (); + + return owner.GenericParameters [type.GenericParameterPosition]; + } + + TypeReference ImportGenericInstance (Type type, IGenericContext context) + { + var element_type = ImportType (type.GetGenericTypeDefinition (), context, ImportGenericKind.Definition); + var instance = new GenericInstanceType (element_type); + var arguments = type.GetGenericArguments (); + var instance_arguments = instance.GenericArguments; + + for (int i = 0; i < arguments.Length; i++) + instance_arguments.Add (ImportType (arguments [i], context ?? element_type)); + + return instance; + } + + static bool IsTypeSpecification (Type type) + { + return type.HasElementType + || IsGenericInstance (type) + || type.IsGenericParameter; + } + + static bool IsGenericInstance (Type type) + { + return type.IsGenericType && !type.IsGenericTypeDefinition; + } + + static ElementType ImportElementType (Type type) + { + ElementType etype; + if (!type_etype_mapping.TryGetValue (type, out etype)) + return ElementType.None; + + return etype; + } + + AssemblyNameReference ImportScope (SR.Assembly assembly) + { + AssemblyNameReference scope; +#if !SILVERLIGHT + var name = assembly.GetName (); + + if (TryGetAssemblyNameReference (name, out scope)) + return scope; + + scope = new AssemblyNameReference (name.Name, name.Version) { + Culture = name.CultureInfo.Name, + PublicKeyToken = name.GetPublicKeyToken (), + HashAlgorithm = (AssemblyHashAlgorithm) name.HashAlgorithm, + }; + + module.AssemblyReferences.Add (scope); + + return scope; +#else + var name = AssemblyNameReference.Parse (assembly.FullName); + + if (TryGetAssemblyNameReference (name, out scope)) + return scope; + + module.AssemblyReferences.Add (name); + + return name; +#endif + } + +#if !SILVERLIGHT + bool TryGetAssemblyNameReference (SR.AssemblyName name, out AssemblyNameReference assembly_reference) + { + var references = module.AssemblyReferences; + + for (int i = 0; i < references.Count; i++) { + var reference = references [i]; + if (name.FullName != reference.FullName) // TODO compare field by field + continue; + + assembly_reference = reference; + return true; + } + + assembly_reference = null; + return false; + } +#endif + + public FieldReference ImportField (SR.FieldInfo field, IGenericContext context) + { + var declaring_type = ImportType (field.DeclaringType, context); + + if (IsGenericInstance (field.DeclaringType)) + field = ResolveFieldDefinition (field); + + return new FieldReference { + Name = field.Name, + DeclaringType = declaring_type, + FieldType = ImportType (field.FieldType, context ?? declaring_type), + }; + } + + static SR.FieldInfo ResolveFieldDefinition (SR.FieldInfo field) + { +#if !SILVERLIGHT + return field.Module.ResolveField (field.MetadataToken); +#else + return field.DeclaringType.GetGenericTypeDefinition ().GetField (field.Name, + SR.BindingFlags.Public + | SR.BindingFlags.NonPublic + | (field.IsStatic ? SR.BindingFlags.Static : SR.BindingFlags.Instance)); +#endif + } + + public MethodReference ImportMethod (SR.MethodBase method, IGenericContext context, ImportGenericKind import_kind) + { + if (IsMethodSpecification (method) || ImportOpenGenericMethod (method, import_kind)) + return ImportMethodSpecification (method, context); + + var declaring_type = ImportType (method.DeclaringType, context); + + if (IsGenericInstance (method.DeclaringType)) + method = method.Module.ResolveMethod (method.MetadataToken); + + var reference = new MethodReference { + Name = method.Name, + HasThis = HasCallingConvention (method, SR.CallingConventions.HasThis), + ExplicitThis = HasCallingConvention (method, SR.CallingConventions.ExplicitThis), + DeclaringType = ImportType (method.DeclaringType, context, ImportGenericKind.Definition), + }; + + if (HasCallingConvention (method, SR.CallingConventions.VarArgs)) + reference.CallingConvention &= MethodCallingConvention.VarArg; + + if (method.IsGenericMethod) + ImportGenericParameters (reference, method.GetGenericArguments ()); + + var method_info = method as SR.MethodInfo; + reference.ReturnType = method_info != null + ? ImportType (method_info.ReturnType, context ?? reference) + : ImportType (typeof (void), null); + + var parameters = method.GetParameters (); + var reference_parameters = reference.Parameters; + + for (int i = 0; i < parameters.Length; i++) + reference_parameters.Add ( + new ParameterDefinition (ImportType (parameters [i].ParameterType, context ?? reference))); + + reference.DeclaringType = declaring_type; + + return reference; + } + + static void ImportGenericParameters (IGenericParameterProvider provider, Type [] arguments) + { + var provider_parameters = provider.GenericParameters; + + for (int i = 0; i < arguments.Length; i++) + provider_parameters.Add (new GenericParameter (arguments [i].Name, provider)); + } + + static bool IsMethodSpecification (SR.MethodBase method) + { + return method.IsGenericMethod && !method.IsGenericMethodDefinition; + } + + MethodReference ImportMethodSpecification (SR.MethodBase method, IGenericContext context) + { + var method_info = method as SR.MethodInfo; + if (method_info == null) + throw new InvalidOperationException (); + + var element_method = ImportMethod (method_info.GetGenericMethodDefinition (), context, ImportGenericKind.Definition); + var instance = new GenericInstanceMethod (element_method); + var arguments = method.GetGenericArguments (); + var instance_arguments = instance.GenericArguments; + + for (int i = 0; i < arguments.Length; i++) + instance_arguments.Add (ImportType (arguments [i], context ?? element_method)); + + return instance; + } + + static bool HasCallingConvention (SR.MethodBase method, SR.CallingConventions conventions) + { + return (method.CallingConvention & conventions) != 0; + } +#endif + + public TypeReference ImportType (TypeReference type, IGenericContext context) + { + if (type.IsTypeSpecification ()) + return ImportTypeSpecification (type, context); + + var reference = new TypeReference ( + type.Namespace, + type.Name, + module, + ImportScope (type.Scope), + type.IsValueType); + + MetadataSystem.TryProcessPrimitiveType (reference); + + if (type.IsNested) + reference.DeclaringType = ImportType (type.DeclaringType, context); + + if (type.HasGenericParameters) + ImportGenericParameters (reference, type); + + return reference; + } + + IMetadataScope ImportScope (IMetadataScope scope) + { + switch (scope.MetadataScopeType) { + case MetadataScopeType.AssemblyNameReference: + return ImportAssemblyName ((AssemblyNameReference) scope); + case MetadataScopeType.ModuleDefinition: + return ImportAssemblyName (((ModuleDefinition) scope).Assembly.Name); + case MetadataScopeType.ModuleReference: + throw new NotImplementedException (); + } + + throw new NotSupportedException (); + } + + AssemblyNameReference ImportAssemblyName (AssemblyNameReference name) + { + AssemblyNameReference reference; + if (TryGetAssemblyNameReference (name, out reference)) + return reference; + + reference = new AssemblyNameReference (name.Name, name.Version) { + Culture = name.Culture, + HashAlgorithm = name.HashAlgorithm, + }; + + var pk_token = !name.PublicKeyToken.IsNullOrEmpty () + ? new byte [name.PublicKeyToken.Length] + : Empty.Array; + + if (pk_token.Length > 0) + Buffer.BlockCopy (name.PublicKeyToken, 0, pk_token, 0, pk_token.Length); + + reference.PublicKeyToken = pk_token; + + module.AssemblyReferences.Add (reference); + + return reference; + } + + bool TryGetAssemblyNameReference (AssemblyNameReference name_reference, out AssemblyNameReference assembly_reference) + { + var references = module.AssemblyReferences; + + for (int i = 0; i < references.Count; i++) { + var reference = references [i]; + if (name_reference.FullName != reference.FullName) // TODO compare field by field + continue; + + assembly_reference = reference; + return true; + } + + assembly_reference = null; + return false; + } + + static void ImportGenericParameters (IGenericParameterProvider imported, IGenericParameterProvider original) + { + var parameters = original.GenericParameters; + var imported_parameters = imported.GenericParameters; + + for (int i = 0; i < parameters.Count; i++) + imported_parameters.Add (new GenericParameter (parameters [i].Name, imported)); + } + + TypeReference ImportTypeSpecification (TypeReference type, IGenericContext context) + { + switch (type.etype) { + case ElementType.SzArray: + var vector = (ArrayType) type; + return new ArrayType (ImportType (vector.ElementType, context)); + case ElementType.Ptr: + var pointer = (PointerType) type; + return new PointerType (ImportType (pointer.ElementType, context)); + case ElementType.ByRef: + var byref = (ByReferenceType) type; + return new ByReferenceType (ImportType (byref.ElementType, context)); + case ElementType.Pinned: + var pinned = (PinnedType) type; + return new PinnedType (ImportType (pinned.ElementType, context)); + case ElementType.Sentinel: + var sentinel = (SentinelType) type; + return new SentinelType (ImportType (sentinel.ElementType, context)); + case ElementType.CModOpt: + var modopt = (OptionalModifierType) type; + return new OptionalModifierType ( + ImportType (modopt.ModifierType, context), + ImportType (modopt.ElementType, context)); + case ElementType.CModReqD: + var modreq = (RequiredModifierType) type; + return new RequiredModifierType ( + ImportType (modreq.ModifierType, context), + ImportType (modreq.ElementType, context)); + case ElementType.Array: + var array = (ArrayType) type; + var imported_array = new ArrayType (ImportType (array.ElementType, context)); + if (array.IsVector) + return imported_array; + + var dimensions = array.Dimensions; + var imported_dimensions = imported_array.Dimensions; + + imported_dimensions.Clear (); + + for (int i = 0; i < dimensions.Count; i++) { + var dimension = dimensions [i]; + + imported_dimensions.Add (new ArrayDimension (dimension.LowerBound, dimension.UpperBound)); + } + + return imported_array; + case ElementType.GenericInst: + var instance = (GenericInstanceType) type; + var element_type = ImportType (instance.ElementType, context); + var imported_instance = new GenericInstanceType (element_type); + + var arguments = instance.GenericArguments; + var imported_arguments = imported_instance.GenericArguments; + + for (int i = 0; i < arguments.Count; i++) + imported_arguments.Add (ImportType (arguments [i], context)); + + return imported_instance; + case ElementType.Var: + if (context == null || context.Type == null) + throw new InvalidOperationException (); + + return ((TypeReference) context.Type).GetElementType ().GenericParameters [((GenericParameter) type).Position]; + case ElementType.MVar: + if (context == null || context.Method == null) + throw new InvalidOperationException (); + + return context.Method.GenericParameters [((GenericParameter) type).Position]; + } + + throw new NotSupportedException (type.etype.ToString ()); + } + + public FieldReference ImportField (FieldReference field, IGenericContext context) + { + var declaring_type = ImportType (field.DeclaringType, context); + + return new FieldReference { + Name = field.Name, + DeclaringType = declaring_type, + FieldType = ImportType (field.FieldType, context ?? declaring_type), + }; + } + + public MethodReference ImportMethod (MethodReference method, IGenericContext context) + { + if (method.IsGenericInstance) + return ImportMethodSpecification (method, context); + + var declaring_type = ImportType (method.DeclaringType, context); + + var reference = new MethodReference { + Name = method.Name, + HasThis = method.HasThis, + ExplicitThis = method.ExplicitThis, + DeclaringType = declaring_type, + }; + + reference.CallingConvention = method.CallingConvention; + + if (method.HasGenericParameters) + ImportGenericParameters (reference, method); + + reference.ReturnType = ImportType (method.ReturnType, context ?? reference); + + if (!method.HasParameters) + return reference; + + var reference_parameters = reference.Parameters; + + var parameters = method.Parameters; + for (int i = 0; i < parameters.Count; i++) + reference_parameters.Add ( + new ParameterDefinition (ImportType (parameters [i].ParameterType, context ?? reference))); + + return reference; + } + + MethodSpecification ImportMethodSpecification (MethodReference method, IGenericContext context) + { + if (!method.IsGenericInstance) + throw new NotSupportedException (); + + var instance = (GenericInstanceMethod) method; + var element_method = ImportMethod (instance.ElementMethod, context); + var imported_instance = new GenericInstanceMethod (element_method); + + var arguments = instance.GenericArguments; + var imported_arguments = imported_instance.GenericArguments; + + for (int i = 0; i < arguments.Count; i++) + imported_arguments.Add (ImportType (arguments [i], context)); + + return imported_instance; + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/InterfaceCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/InterfaceCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/InterfaceCollection.cs 2008-11-06 19:52:04.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/InterfaceCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ -// -// InterfaceCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Wed Sep 27 12:46:52 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.Collections; - - using Mono.Cecil.Cil; - - public sealed class InterfaceCollection : CollectionBase, IReflectionVisitable { - - TypeDefinition m_container; - - public TypeReference this [int index] { - get { return List [index] as TypeReference; } - set { List [index] = value; } - } - - public TypeDefinition Container { - get { return m_container; } - } - - public InterfaceCollection (TypeDefinition container) - { - m_container = container; - } - - public void Add (TypeReference value) - { - List.Add (value); - } - - public bool Contains (TypeReference value) - { - return List.Contains (value); - } - - public int IndexOf (TypeReference value) - { - return List.IndexOf (value); - } - - public void Insert (int index, TypeReference value) - { - List.Insert (index, value); - } - - public void Remove (TypeReference value) - { - List.Remove (value); - } - - protected override void OnValidate (object o) - { - if (! (o is TypeReference)) - throw new ArgumentException ("Must be of type " + typeof (TypeReference).FullName); - } - - public void Accept (IReflectionVisitor visitor) - { - visitor.VisitInterfaceCollection (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionStructureVisitable.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionStructureVisitable.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionStructureVisitable.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionStructureVisitable.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// -// IReflectionStructureVisitable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - public interface IReflectionStructureVisitable { - - void Accept (IReflectionStructureVisitor visitor); - } -} - diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionStructureVisitor.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionStructureVisitor.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionStructureVisitor.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionStructureVisitor.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -// -// IReflectionStructureVisitor.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - public interface IReflectionStructureVisitor { - - void VisitAssemblyDefinition (AssemblyDefinition asm); - void VisitAssemblyNameDefinition (AssemblyNameDefinition name); - void VisitAssemblyNameReferenceCollection (AssemblyNameReferenceCollection names); - void VisitAssemblyNameReference (AssemblyNameReference name); - void VisitResourceCollection (ResourceCollection resources); - void VisitEmbeddedResource (EmbeddedResource res); - void VisitLinkedResource (LinkedResource res); - void VisitAssemblyLinkedResource (AssemblyLinkedResource res); - void VisitModuleDefinition (ModuleDefinition module); - void VisitModuleDefinitionCollection (ModuleDefinitionCollection modules); - void VisitModuleReference (ModuleReference module); - void VisitModuleReferenceCollection (ModuleReferenceCollection modules); - - void TerminateAssemblyDefinition (AssemblyDefinition asm); - } -} - diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionVisitable.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionVisitable.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionVisitable.cs 2008-11-06 19:52:04.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionVisitable.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// -// IReflectionVisitable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - public interface IReflectionVisitable { - - void Accept (IReflectionVisitor visitor); - } -} - diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionVisitor.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionVisitor.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionVisitor.cs 2008-11-06 19:52:04.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionVisitor.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -// -// IReflectionVisitor.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - public interface IReflectionVisitor { - - void VisitModuleDefinition (ModuleDefinition module); - void VisitTypeDefinitionCollection (TypeDefinitionCollection types); - void VisitTypeDefinition (TypeDefinition type); - void VisitTypeReferenceCollection (TypeReferenceCollection refs); - void VisitTypeReference (TypeReference type); - void VisitMemberReferenceCollection (MemberReferenceCollection members); - void VisitMemberReference (MemberReference member); - void VisitInterfaceCollection (InterfaceCollection interfaces); - void VisitInterface (TypeReference interf); - void VisitExternTypeCollection (ExternTypeCollection externs); - void VisitExternType (TypeReference externType); - void VisitOverrideCollection (OverrideCollection meth); - void VisitOverride (MethodReference ov); - void VisitNestedTypeCollection (NestedTypeCollection nestedTypes); - void VisitNestedType (TypeDefinition nestedType); - void VisitParameterDefinitionCollection (ParameterDefinitionCollection parameters); - void VisitParameterDefinition (ParameterDefinition parameter); - void VisitMethodDefinitionCollection (MethodDefinitionCollection methods); - void VisitMethodDefinition (MethodDefinition method); - void VisitConstructorCollection (ConstructorCollection ctors); - void VisitConstructor (MethodDefinition ctor); - void VisitPInvokeInfo (PInvokeInfo pinvk); - void VisitEventDefinitionCollection (EventDefinitionCollection events); - void VisitEventDefinition (EventDefinition evt); - void VisitFieldDefinitionCollection (FieldDefinitionCollection fields); - void VisitFieldDefinition (FieldDefinition field); - void VisitPropertyDefinitionCollection (PropertyDefinitionCollection properties); - void VisitPropertyDefinition (PropertyDefinition property); - void VisitSecurityDeclarationCollection (SecurityDeclarationCollection secDecls); - void VisitSecurityDeclaration (SecurityDeclaration secDecl); - void VisitCustomAttributeCollection (CustomAttributeCollection customAttrs); - void VisitCustomAttribute (CustomAttribute customAttr); - void VisitGenericParameterCollection (GenericParameterCollection genparams); - void VisitGenericParameter (GenericParameter genparam); - void VisitMarshalSpec (MarshalSpec marshalSpec); - - void TerminateModuleDefinition (ModuleDefinition module); - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IRequireResolving.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IRequireResolving.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IRequireResolving.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IRequireResolving.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// -// IRequireResolving.cs -// -// Author: -// Jb Evain -// -// Copyright (C) 2006 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - public interface IRequireResolving { - - byte [] Blob { get; } - bool Resolved { get; } - bool Resolve (); - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/LinkedResource.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/LinkedResource.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/LinkedResource.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/LinkedResource.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 - 2007 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -30,28 +30,31 @@ public sealed class LinkedResource : Resource { - byte [] m_hash; - string m_file; + internal byte [] hash; + string file; public byte [] Hash { - get { return m_hash; } - set { m_hash = value; } + get { return hash; } } public string File { - get { return m_file; } - set { m_file = value; } + get { return file; } + set { file = value; } } - public LinkedResource (string name, ManifestResourceAttributes flags, string file) : - base (name, flags) + public override ResourceType ResourceType { + get { return ResourceType.Linked; } + } + + public LinkedResource (string name, ManifestResourceAttributes flags) + : base (name, flags) { - m_file = file; } - public override void Accept (IReflectionStructureVisitor visitor) + public LinkedResource (string name, ManifestResourceAttributes flags, string file) + : base (name, flags) { - visitor.VisitLinkedResource (this); + this.file = file; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ManifestResourceAttributes.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ManifestResourceAttributes.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ManifestResourceAttributes.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ManifestResourceAttributes.cs 2011-04-13 09:00:29.000000000 +0000 @@ -1,10 +1,10 @@ // -// ManigestResourceAttributes.cs +// ManifestResourceAttributes.cs // // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,12 +26,12 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { +using System; - using System; +namespace Mono.Cecil { [Flags] - public enum ManifestResourceAttributes { + public enum ManifestResourceAttributes : uint { VisibilityMask = 0x0007, Public = 0x0001, // The resource is exported from the Assembly Private = 0x0002 // The resource is private to the Assembly diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MarshalInfo.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MarshalInfo.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MarshalInfo.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MarshalInfo.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,171 @@ +// +// MarshalInfo.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; + +namespace Mono.Cecil { + + public class MarshalInfo { + + internal NativeType native; + + public NativeType NativeType { + get { return native; } + set { native = value; } + } + + public MarshalInfo (NativeType native) + { + this.native = native; + } + } + + public sealed class ArrayMarshalInfo : MarshalInfo { + + internal NativeType element_type; + internal int size_parameter_index; + internal int size; + internal int size_parameter_multiplier; + + public NativeType ElementType { + get { return element_type; } + set { element_type = value; } + } + + public int SizeParameterIndex { + get { return size_parameter_index; } + set { size_parameter_index = value; } + } + + public int Size { + get { return size; } + set { size = value; } + } + + public int SizeParameterMultiplier { + get { return size_parameter_multiplier; } + set { size_parameter_multiplier = value; } + } + + public ArrayMarshalInfo () + : base (NativeType.Array) + { + element_type = NativeType.None; + size_parameter_index = -1; + size = -1; + size_parameter_multiplier = -1; + } + } + + public sealed class CustomMarshalInfo : MarshalInfo { + + internal Guid guid; + internal string unmanaged_type; + internal TypeReference managed_type; + internal string cookie; + + public Guid Guid { + get { return guid; } + set { guid = value; } + } + + public string UnmanagedType { + get { return unmanaged_type; } + set { unmanaged_type = value; } + } + + public TypeReference ManagedType { + get { return managed_type; } + set { managed_type = value; } + } + + public string Cookie { + get { return cookie; } + set { cookie = value; } + } + + public CustomMarshalInfo () + : base (NativeType.CustomMarshaler) + { + } + } + + public sealed class SafeArrayMarshalInfo : MarshalInfo { + + internal VariantType element_type; + + public VariantType ElementType { + get { return element_type; } + set { element_type = value; } + } + + public SafeArrayMarshalInfo () + : base (NativeType.SafeArray) + { + element_type = VariantType.None; + } + } + + public sealed class FixedArrayMarshalInfo : MarshalInfo { + + internal NativeType element_type; + internal int size; + + public NativeType ElementType { + get { return element_type; } + set { element_type = value; } + } + + public int Size { + get { return size; } + set { size = value; } + } + + public FixedArrayMarshalInfo () + : base (NativeType.FixedArray) + { + element_type = NativeType.None; + } + } + + public sealed class FixedSysStringMarshalInfo : MarshalInfo { + + internal int size; + + public int Size { + get { return size; } + set { size = value; } + } + + public FixedSysStringMarshalInfo () + : base (NativeType.FixedSysString) + { + size = -1; + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MarshalSpec.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MarshalSpec.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MarshalSpec.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MarshalSpec.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,171 +0,0 @@ -// -// MarshalDesc.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - - public class MarshalSpec { - - NativeType m_natIntr; - IHasMarshalSpec m_container; - - public NativeType NativeIntrinsic { - get { return m_natIntr; } - set { m_natIntr = value; } - } - - public IHasMarshalSpec Container { - get { return m_container; } - set { m_container = value; } - } - - public MarshalSpec (NativeType natIntr, IHasMarshalSpec container) - { - m_natIntr = natIntr; - m_container = container; - } - - public virtual void Accept (IReflectionVisitor visitor) - { - visitor.VisitMarshalSpec (this); - } - } - - public sealed class ArrayMarshalSpec : MarshalSpec { - - NativeType m_elemType; - int m_paramNum; - int m_elemMult; - int m_numElem; - - public NativeType ElemType { - get { return m_elemType; } - set { m_elemType = value; } - } - - public int ParamNum { - get { return m_paramNum; } - set { m_paramNum = value; } - } - - public int ElemMult { - get { return m_elemMult; } - set { m_elemMult = value; } - } - - public int NumElem { - get { return m_numElem; } - set { m_numElem = value; } - } - - public ArrayMarshalSpec (IHasMarshalSpec container) : base (NativeType.ARRAY, container) - { - } - } - - public sealed class CustomMarshalerSpec : MarshalSpec { - - Guid m_guid; - string m_unmanagedType; - string m_managedType; - string m_cookie; - - public Guid Guid { - get { return m_guid; } - set { m_guid = value; } - } - - public String UnmanagedType { - get { return m_unmanagedType; } - set { m_unmanagedType = value; } - } - - public string ManagedType { - get { return m_managedType; } - set { m_managedType = value; } - } - - public string Cookie { - get { return m_cookie; } - set { m_cookie = value; } - } - - public CustomMarshalerSpec (IHasMarshalSpec container) : base (NativeType.CUSTOMMARSHALER, container) - { - } - } - - public sealed class SafeArraySpec : MarshalSpec { - - private VariantType m_elemType; - - public VariantType ElemType { - get { return m_elemType; } - set { m_elemType = value; } - } - - public SafeArraySpec (IHasMarshalSpec container) : base (NativeType.SAFEARRAY, container) - { - } - } - - public sealed class FixedArraySpec : MarshalSpec { - - private int m_numElem; - private NativeType m_elemType; - - public int NumElem { - get { return m_numElem; } - set { m_numElem = value; } - } - - public NativeType ElemType { - get { return m_elemType; } - set { m_elemType = value; } - } - - public FixedArraySpec (IHasMarshalSpec container) : base (NativeType.FIXEDARRAY, container) - { - } - } - - public sealed class FixedSysStringSpec : MarshalSpec { - - private int m_size; - - public int Size { - get { return m_size; } - set { m_size = value; } - } - - public FixedSysStringSpec (IHasMarshalSpec container) : base (NativeType.FIXEDSYSSTRING, container) - { - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MemberDefinitionCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MemberDefinitionCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MemberDefinitionCollection.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MemberDefinitionCollection.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,92 @@ +// +// MemberDefinitionCollection.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; + +using Mono.Collections.Generic; + +namespace Mono.Cecil { + + class MemberDefinitionCollection : Collection where T : IMemberDefinition { + + TypeDefinition container; + + internal MemberDefinitionCollection (TypeDefinition container) + { + this.container = container; + } + + internal MemberDefinitionCollection (TypeDefinition container, int capacity) + : base (capacity) + { + this.container = container; + } + + protected override void OnAdd (T item, int index) + { + Attach (item); + } + + protected sealed override void OnSet (T item, int index) + { + Attach (item); + } + + protected sealed override void OnInsert (T item, int index) + { + Attach (item); + } + + protected sealed override void OnRemove (T item, int index) + { + Detach (item); + } + + protected sealed override void OnClear () + { + foreach (var definition in this) + Detach (definition); + } + + void Attach (T element) + { + if (element.DeclaringType == container) + return; + + if (element.DeclaringType != null) + throw new ArgumentException ("Member already attached"); + + element.DeclaringType = this.container; + } + + static void Detach (T element) + { + element.DeclaringType = null; + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MemberReferenceCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MemberReferenceCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MemberReferenceCollection.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MemberReferenceCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ -// -// MemberReferenceCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Wed Sep 27 12:46:53 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.Collections; - - using Mono.Cecil.Cil; - - public sealed class MemberReferenceCollection : CollectionBase, IReflectionVisitable { - - ModuleDefinition m_container; - - public MemberReference this [int index] { - get { return List [index] as MemberReference; } - set { List [index] = value; } - } - - public ModuleDefinition Container { - get { return m_container; } - } - - public MemberReferenceCollection (ModuleDefinition container) - { - m_container = container; - } - - public void Add (MemberReference value) - { - List.Add (value); - } - - public bool Contains (MemberReference value) - { - return List.Contains (value); - } - - public int IndexOf (MemberReference value) - { - return List.IndexOf (value); - } - - public void Insert (int index, MemberReference value) - { - List.Insert (index, value); - } - - public void Remove (MemberReference value) - { - List.Remove (value); - } - - protected override void OnValidate (object o) - { - if (! (o is MemberReference)) - throw new ArgumentException ("Must be of type " + typeof (MemberReference).FullName); - } - - public void Accept (IReflectionVisitor visitor) - { - visitor.VisitMemberReferenceCollection (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MemberReference.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MemberReference.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MemberReference.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MemberReference.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -28,55 +28,74 @@ namespace Mono.Cecil { - using System.Collections; + public abstract class MemberReference : IMetadataTokenProvider { - using Mono.Cecil.Metadata; + string name; + TypeReference declaring_type; - public abstract class MemberReference : IMemberReference { - - string m_name; - TypeReference m_decType; - MetadataToken m_token; - IDictionary m_annotations; + internal MetadataToken token; public virtual string Name { - get { return m_name; } - set { m_name = value; } + get { return name; } + set { name = value; } + } + + public abstract string FullName { + get; } public virtual TypeReference DeclaringType { - get { return m_decType; } - set { m_decType = value; } + get { return declaring_type; } + set { declaring_type = value; } } public MetadataToken MetadataToken { - get { return m_token; } - set { m_token = value; } + get { return token; } + set { token = value; } } - IDictionary IAnnotationProvider.Annotations { + internal bool HasImage { get { - if (m_annotations == null) - m_annotations = new Hashtable (); - return m_annotations; + var module = Module; + if (module == null) + return false; + + return module.HasImage; } } - public MemberReference (string name) + public virtual ModuleDefinition Module { + get { return declaring_type != null ? declaring_type.Module : null; } + } + + public virtual bool IsDefinition { + get { return false; } + } + + internal virtual bool ContainsGenericParameter { + get { return declaring_type != null && declaring_type.ContainsGenericParameter; } + } + + internal MemberReference () { - m_name = name; } - public override string ToString () + internal MemberReference (string name) { - if (m_decType == null) - return m_name; + this.name = name ?? string.Empty; + } - return string.Concat (m_decType.FullName, "::", m_name); + internal string MemberFullName () + { + if (declaring_type == null) + return name; + + return declaring_type.FullName + "::" + name; } - public virtual void Accept (IReflectionVisitor visitor) + public override string ToString () { + return FullName; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MetadataResolver.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MetadataResolver.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MetadataResolver.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MetadataResolver.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,273 @@ +// +// MetadataResolver.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Collections.Generic; + +using Mono.Collections.Generic; + +namespace Mono.Cecil { + + public interface IAssemblyResolver { + AssemblyDefinition Resolve (AssemblyNameReference name); + AssemblyDefinition Resolve (AssemblyNameReference name, ReaderParameters parameters); + + AssemblyDefinition Resolve (string fullName); + AssemblyDefinition Resolve (string fullName, ReaderParameters parameters); + } + + static class MetadataResolver { + + public static TypeDefinition Resolve (IAssemblyResolver resolver, TypeReference type) + { + type = type.GetElementType (); + + var scope = type.Scope; + switch (scope.MetadataScopeType) { + case MetadataScopeType.AssemblyNameReference: + var assembly = resolver.Resolve ((AssemblyNameReference) scope); + if (assembly == null) + return null; + + return GetType (assembly.MainModule, type); + case MetadataScopeType.ModuleDefinition: + return GetType ((ModuleDefinition) scope, type); + case MetadataScopeType.ModuleReference: + var modules = type.Module.Assembly.Modules; + var module_ref = (ModuleReference) scope; + for (int i = 0; i < modules.Count; i++) { + var netmodule = modules [i]; + if (netmodule.Name == module_ref.Name) + return GetType (netmodule, type); + } + break; + } + + throw new NotSupportedException (); + } + + static TypeDefinition GetType (ModuleDefinition module, TypeReference type) + { + if (!type.IsNested) + return module.GetType (type.Namespace, type.Name); + + var declaring_type = type.DeclaringType.Resolve (); + if (declaring_type == null) + return null; + + return declaring_type.GetNestedType (type.Name); + } + + public static FieldDefinition Resolve (IAssemblyResolver resolver, FieldReference field) + { + var type = Resolve (resolver, field.DeclaringType); + if (type == null) + return null; + + if (!type.HasFields) + return null; + + return GetField (resolver, type, field); + } + + static FieldDefinition GetField (IAssemblyResolver resolver, TypeDefinition type, FieldReference reference) + { + while (type != null) { + var field = GetField (type.Fields, reference); + if (field != null) + return field; + + if (type.BaseType == null) + return null; + + type = Resolve (resolver, type.BaseType); + } + + return null; + } + + static FieldDefinition GetField (IList fields, FieldReference reference) + { + for (int i = 0; i < fields.Count; i++) { + var field = fields [i]; + + if (field.Name != reference.Name) + continue; + + if (!AreSame (field.FieldType, reference.FieldType)) + continue; + + return field; + } + + return null; + } + + public static MethodDefinition Resolve (IAssemblyResolver resolver, MethodReference method) + { + var type = Resolve (resolver, method.DeclaringType); + if (type == null) + return null; + + method = method.GetElementMethod (); + + if (!type.HasMethods) + return null; + + return GetMethod (resolver, type, method); + } + + static MethodDefinition GetMethod (IAssemblyResolver resolver, TypeDefinition type, MethodReference reference) + { + while (type != null) { + var method = GetMethod (type.Methods, reference); + if (method != null) + return method; + + if (type.BaseType == null) + return null; + + type = Resolve (resolver, type.BaseType); + } + + return null; + } + + public static MethodDefinition GetMethod (IList methods, MethodReference reference) + { + for (int i = 0; i < methods.Count; i++) { + var method = methods [i]; + + if (method.Name != reference.Name) + continue; + + if (!AreSame (method.ReturnType, reference.ReturnType)) + continue; + + if (method.HasParameters != reference.HasParameters) + continue; + + if (!method.HasParameters && !reference.HasParameters) + return method; + + if (!AreSame (method.Parameters, reference.Parameters)) + continue; + + return method; + } + + return null; + } + + static bool AreSame (Collection a, Collection b) + { + var count = a.Count; + + if (count != b.Count) + return false; + + if (count == 0) + return true; + + for (int i = 0; i < count; i++) + if (!AreSame (a [i].ParameterType, b [i].ParameterType)) + return false; + + return true; + } + + static bool AreSame (TypeSpecification a, TypeSpecification b) + { + if (!AreSame (a.ElementType, b.ElementType)) + return false; + + if (a.IsGenericInstance) + return AreSame ((GenericInstanceType) a, (GenericInstanceType) b); + + if (a.IsRequiredModifier || a.IsOptionalModifier) + return AreSame ((IModifierType) a, (IModifierType) b); + + if (a.IsArray) + return AreSame ((ArrayType) a, (ArrayType) b); + + return true; + } + + static bool AreSame (ArrayType a, ArrayType b) + { + if (a.Rank != b.Rank) + return false; + + // TODO: dimensions + + return true; + } + + static bool AreSame (IModifierType a, IModifierType b) + { + return AreSame (a.ModifierType, b.ModifierType); + } + + static bool AreSame (GenericInstanceType a, GenericInstanceType b) + { + if (!a.HasGenericArguments) + return !b.HasGenericArguments; + + if (!b.HasGenericArguments) + return false; + + if (a.GenericArguments.Count != b.GenericArguments.Count) + return false; + + for (int i = 0; i < a.GenericArguments.Count; i++) + if (!AreSame (a.GenericArguments [i], b.GenericArguments [i])) + return false; + + return true; + } + + static bool AreSame (GenericParameter a, GenericParameter b) + { + return a.Position == b.Position; + } + + static bool AreSame (TypeReference a, TypeReference b) + { + if (a.etype != b.etype) + return false; + + if (a.IsGenericParameter) + return AreSame ((GenericParameter) a, (GenericParameter) b); + + if (a.IsTypeSpecification ()) + return AreSame ((TypeSpecification) a, (TypeSpecification) b); + + return a.FullName == b.FullName; + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MetadataSystem.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MetadataSystem.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MetadataSystem.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MetadataSystem.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,377 @@ +// +// MetadataSystem.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Collections.Generic; + +using Mono.Cecil.Metadata; + +namespace Mono.Cecil { + + struct Range { + public uint Start; + public uint Length; + + public Range (uint index, uint length) + { + this.Start = index; + this.Length = length; + } + } + + sealed class MetadataSystem { + + internal TypeDefinition [] Types; + internal TypeReference [] TypeReferences; + + internal FieldDefinition [] Fields; + internal MethodDefinition [] Methods; + internal MemberReference [] MemberReferences; + + internal Dictionary NestedTypes; + internal Dictionary ReverseNestedTypes; + internal Dictionary Interfaces; + internal Dictionary> ClassLayouts; + internal Dictionary FieldLayouts; + internal Dictionary FieldRVAs; + internal Dictionary FieldMarshals; + internal Dictionary> Constants; + internal Dictionary Overrides; + internal Dictionary CustomAttributes; + internal Dictionary SecurityDeclarations; + internal Dictionary Events; + internal Dictionary Properties; + internal Dictionary> Semantics; + internal Dictionary> PInvokes; + internal Dictionary GenericParameters; + internal Dictionary GenericConstraints; + + static Dictionary> primitive_value_types; + + static void InitializePrimitives () + { + primitive_value_types = new Dictionary> (18) { + { "Void", new Row (ElementType.Void, false) }, + { "Boolean", new Row (ElementType.Boolean, true) }, + { "Char", new Row (ElementType.Char, true) }, + { "SByte", new Row (ElementType.I1, true) }, + { "Byte", new Row (ElementType.U1, true) }, + { "Int16", new Row (ElementType.I2, true) }, + { "UInt16", new Row (ElementType.U2, true) }, + { "Int32", new Row (ElementType.I4, true) }, + { "UInt32", new Row (ElementType.U4, true) }, + { "Int64", new Row (ElementType.I8, true) }, + { "UInt64", new Row (ElementType.U8, true) }, + { "Single", new Row (ElementType.R4, true) }, + { "Double", new Row (ElementType.R8, true) }, + { "String", new Row (ElementType.String, false) }, + { "TypedReference", new Row (ElementType.TypedByRef, false) }, + { "IntPtr", new Row (ElementType.I, true) }, + { "UIntPtr", new Row (ElementType.U, true) }, + { "Object", new Row (ElementType.Object, false) }, + }; + } + + public static void TryProcessPrimitiveType (TypeReference type) + { + var scope = type.scope; + if (scope == null) + return; + + if (scope.MetadataScopeType != MetadataScopeType.AssemblyNameReference) + return; + + if (scope.Name != "mscorlib") + return; + + if (type.Namespace != "System") + return; + + if (primitive_value_types == null) + InitializePrimitives (); + + Row primitive_data; + if (!primitive_value_types.TryGetValue (type.Name, out primitive_data)) + return; + + type.etype = primitive_data.Col1; + type.IsValueType = primitive_data.Col2; + } + + public void Clear () + { + if (NestedTypes != null) NestedTypes.Clear (); + if (ReverseNestedTypes != null) ReverseNestedTypes.Clear (); + if (Interfaces != null) Interfaces.Clear (); + if (ClassLayouts != null) ClassLayouts.Clear (); + if (FieldLayouts != null) FieldLayouts.Clear (); + if (FieldRVAs != null) FieldRVAs.Clear (); + if (FieldMarshals != null) FieldMarshals.Clear (); + if (Constants != null) Constants.Clear (); + if (Overrides != null) Overrides.Clear (); + if (CustomAttributes != null) CustomAttributes.Clear (); + if (SecurityDeclarations != null) SecurityDeclarations.Clear (); + if (Events != null) Events.Clear (); + if (Properties != null) Properties.Clear (); + if (Semantics != null) Semantics.Clear (); + if (PInvokes != null) PInvokes.Clear (); + if (GenericParameters != null) GenericParameters.Clear (); + if (GenericConstraints != null) GenericConstraints.Clear (); + } + + public TypeDefinition GetTypeDefinition (uint rid) + { + if (rid < 1 || rid > Types.Length) + return null; + + return Types [rid - 1]; + } + + public void AddTypeDefinition (TypeDefinition type) + { + Types [type.token.RID - 1] = type; + } + + public TypeReference GetTypeReference (uint rid) + { + if (rid < 1 || rid > TypeReferences.Length) + return null; + + return TypeReferences [rid - 1]; + } + + public void AddTypeReference (TypeReference type) + { + TypeReferences [type.token.RID - 1] = type; + } + + public FieldDefinition GetFieldDefinition (uint rid) + { + if (rid < 1 || rid > Fields.Length) + return null; + + return Fields [rid - 1]; + } + + public void AddFieldDefinition (FieldDefinition field) + { + Fields [field.token.RID - 1] = field; + } + + public MethodDefinition GetMethodDefinition (uint rid) + { + if (rid < 1 || rid > Methods.Length) + return null; + + return Methods [rid - 1]; + } + + public void AddMethodDefinition (MethodDefinition method) + { + Methods [method.token.RID - 1] = method; + } + + public MemberReference GetMemberReference (uint rid) + { + if (rid < 1 || rid > MemberReferences.Length) + return null; + + return MemberReferences [rid - 1]; + } + + public void AddMemberReference (MemberReference member) + { + MemberReferences [member.token.RID - 1] = member; + } + + public bool TryGetNestedTypeMapping (TypeDefinition type, out uint [] mapping) + { + return NestedTypes.TryGetValue (type.token.RID, out mapping); + } + + public void SetNestedTypeMapping (uint type_rid, uint [] mapping) + { + NestedTypes [type_rid] = mapping; + } + + public void RemoveNestedTypeMapping (TypeDefinition type) + { + NestedTypes.Remove (type.token.RID); + } + + public bool TryGetReverseNestedTypeMapping (TypeDefinition type, out uint declaring) + { + return ReverseNestedTypes.TryGetValue (type.token.RID, out declaring); + } + + public void SetReverseNestedTypeMapping (uint nested, uint declaring) + { + ReverseNestedTypes.Add (nested, declaring); + } + + public void RemoveReverseNestedTypeMapping (TypeDefinition type) + { + ReverseNestedTypes.Remove (type.token.RID); + } + + public bool TryGetInterfaceMapping (TypeDefinition type, out MetadataToken [] mapping) + { + return Interfaces.TryGetValue (type.token.RID, out mapping); + } + + public void SetInterfaceMapping (uint type_rid, MetadataToken [] mapping) + { + Interfaces [type_rid] = mapping; + } + + public void RemoveInterfaceMapping (TypeDefinition type) + { + Interfaces.Remove (type.token.RID); + } + + public void AddPropertiesRange (uint type_rid, Range range) + { + Properties.Add (type_rid, range); + } + + public bool TryGetPropertiesRange (TypeDefinition type, out Range range) + { + return Properties.TryGetValue (type.token.RID, out range); + } + + public void RemovePropertiesRange (TypeDefinition type) + { + Properties.Remove (type.token.RID); + } + + public void AddEventsRange (uint type_rid, Range range) + { + Events.Add (type_rid, range); + } + + public bool TryGetEventsRange (TypeDefinition type, out Range range) + { + return Events.TryGetValue (type.token.RID, out range); + } + + public void RemoveEventsRange (TypeDefinition type) + { + Events.Remove (type.token.RID); + } + + public bool TryGetGenericParameterRange (IGenericParameterProvider owner, out Range range) + { + return GenericParameters.TryGetValue (owner.MetadataToken, out range); + } + + public void RemoveGenericParameterRange (IGenericParameterProvider owner) + { + GenericParameters.Remove (owner.MetadataToken); + } + + public bool TryGetCustomAttributeRange (ICustomAttributeProvider owner, out Range range) + { + return CustomAttributes.TryGetValue (owner.MetadataToken, out range); + } + + public void RemoveCustomAttributeRange (ICustomAttributeProvider owner) + { + CustomAttributes.Remove (owner.MetadataToken); + } + + public bool TryGetSecurityDeclarationRange (ISecurityDeclarationProvider owner, out Range range) + { + return SecurityDeclarations.TryGetValue (owner.MetadataToken, out range); + } + + public void RemoveSecurityDeclarationRange (ISecurityDeclarationProvider owner) + { + SecurityDeclarations.Remove (owner.MetadataToken); + } + + public bool TryGetGenericConstraintMapping (GenericParameter generic_parameter, out MetadataToken [] mapping) + { + return GenericConstraints.TryGetValue (generic_parameter.token.RID, out mapping); + } + + public void SetGenericConstraintMapping (uint gp_rid, MetadataToken [] mapping) + { + GenericConstraints [gp_rid] = mapping; + } + + public void RemoveGenericConstraintMapping (GenericParameter generic_parameter) + { + GenericConstraints.Remove (generic_parameter.token.RID); + } + + public bool TryGetOverrideMapping (MethodDefinition method, out MetadataToken [] mapping) + { + return Overrides.TryGetValue (method.token.RID, out mapping); + } + + public void SetOverrideMapping (uint rid, MetadataToken [] mapping) + { + Overrides [rid] = mapping; + } + + public void RemoveOverrideMapping (MethodDefinition method) + { + Overrides.Remove (method.token.RID); + } + + public TypeDefinition GetFieldDeclaringType (uint field_rid) + { + return BinaryRangeSearch (Types, field_rid, true); + } + + public TypeDefinition GetMethodDeclaringType (uint method_rid) + { + return BinaryRangeSearch (Types, method_rid, false); + } + + static TypeDefinition BinaryRangeSearch (TypeDefinition [] types, uint rid, bool field) + { + int min = 0; + int max = types.Length - 1; + while (min <= max) { + int mid = min + ((max - min) / 2); + var type = types [mid]; + var range = field ? type.fields_range : type.methods_range; + + if (rid < range.Start) + max = mid - 1; + else if (rid >= range.Start + range.Length) + min = mid + 1; + else + return type; + } + + return null; + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodAttributes.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodAttributes.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodAttributes.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodAttributes.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,17 +26,17 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { +using System; - using System; +namespace Mono.Cecil { [Flags] public enum MethodAttributes : ushort { MemberAccessMask = 0x0007, - Compilercontrolled = 0x0000, // Member not referenceable + CompilerControlled = 0x0000, // Member not referenceable Private = 0x0001, // Accessible only by the parent type FamANDAssem = 0x0002, // Accessible by sub-types only in this Assembly - Assem = 0x0003, // Accessibly by anyone in the Assembly + Assembly = 0x0003, // Accessibly by anyone in the Assembly Family = 0x0004, // Accessible only by type and sub-types FamORAssem = 0x0005, // Accessibly by sub-types anywhere, plus anyone in assembly Public = 0x0006, // Accessibly by anyone who has visibility to this scope @@ -50,6 +50,7 @@ ReuseSlot = 0x0000, // Method reuses existing slot in vtable NewSlot = 0x0100, // Method always gets a new slot in the vtable + CheckAccessOnOverride = 0x0200, // Method can only be overriden if also accessible Abstract = 0x0400, // Method does not provide an implementation SpecialName = 0x0800, // Method is special diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodCallingConvention.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodCallingConvention.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodCallingConvention.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodCallingConvention.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -35,6 +35,6 @@ ThisCall = 0x3, FastCall = 0x4, VarArg = 0x5, - Generic = 0x10 + Generic = 0x10, } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodDefinitionCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodDefinitionCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodDefinitionCollection.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodDefinitionCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,185 +0,0 @@ -// -// MethodDefinitionCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Fri Mar 30 18:43:56 +0200 2007 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.Collections; - - using Mono.Cecil.Cil; - - public sealed class MethodDefinitionCollection : CollectionBase, IReflectionVisitable { - - TypeDefinition m_container; - - public MethodDefinition this [int index] { - get { return List [index] as MethodDefinition; } - set { List [index] = value; } - } - - public TypeDefinition Container { - get { return m_container; } - } - - public MethodDefinitionCollection (TypeDefinition container) - { - m_container = container; - } - - public void Add (MethodDefinition value) - { - Attach (value); - - List.Add (value); - } - - - public new void Clear () - { - foreach (MethodDefinition item in this) - Detach (item); - - base.Clear (); - } - - public bool Contains (MethodDefinition value) - { - return List.Contains (value); - } - - public int IndexOf (MethodDefinition value) - { - return List.IndexOf (value); - } - - public void Insert (int index, MethodDefinition value) - { - Attach (value); - - List.Insert (index, value); - } - - public void Remove (MethodDefinition value) - { - List.Remove (value); - - Detach (value); - } - - - public new void RemoveAt (int index) - { - MethodDefinition item = this [index]; - Remove (item); - } - - protected override void OnValidate (object o) - { - if (! (o is MethodDefinition)) - throw new ArgumentException ("Must be of type " + typeof (MethodDefinition).FullName); - } - - public MethodDefinition [] GetMethod (string name) - { - ArrayList ret = new ArrayList (); - foreach (MethodDefinition meth in this) - if (meth.Name == name) - ret.Add (meth); - - return ret.ToArray (typeof (MethodDefinition)) as MethodDefinition []; - } - - internal MethodDefinition GetMethodInternal (string name, IList parameters) - { - foreach (MethodDefinition meth in this) { - if (meth.Name != name || meth.Parameters.Count != parameters.Count) - continue; - - bool match = true; - for (int i = 0; i < parameters.Count; i++) { - string pname; - object param = parameters [i]; - if (param is Type) - pname = ReflectionHelper.GetTypeSignature (param as Type); - else if (param is TypeReference) - pname = (param as TypeReference).FullName; - else if (param is ParameterDefinition) - pname = (param as ParameterDefinition).ParameterType.FullName; - else - throw new NotSupportedException (); - - if (meth.Parameters [i].ParameterType.FullName != pname) { - match = false; - break; - } - } - - if (match) - return meth; - } - - return null; - } - - public MethodDefinition GetMethod (string name, Type [] parameters) - { - return GetMethodInternal (name, parameters); - } - - public MethodDefinition GetMethod (string name, TypeReference [] parameters) - { - return GetMethodInternal (name, parameters); - } - - public MethodDefinition GetMethod (string name, ParameterDefinitionCollection parameters) - { - return GetMethodInternal (name, parameters); - } - - void Attach (MemberReference member) - { - if (member.DeclaringType != null) - throw new ReflectionException ("Member already attached, clone it instead"); - - member.DeclaringType = m_container; - } - - void Detach (MemberReference member) - { - member.DeclaringType = null; - } - - public void Accept (IReflectionVisitor visitor) - { - visitor.VisitMethodDefinitionCollection (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodDefinition.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodDefinition.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodDefinition.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodDefinition.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,304 +26,287 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { +using Mono.Cecil.Cil; +using Mono.Collections.Generic; + +using RVA = System.UInt32; - using Mono.Cecil.Binary; - using Mono.Cecil.Cil; +namespace Mono.Cecil { - public sealed class MethodDefinition : MethodReference, IMemberDefinition, - IHasSecurity, ICustomAttributeProvider { + public sealed class MethodDefinition : MethodReference, IMemberDefinition, ISecurityDeclarationProvider { - public const string Cctor = ".cctor"; - public const string Ctor = ".ctor"; + ushort attributes; + ushort impl_attributes; + internal MethodSemanticsAttributes? sem_attrs; + Collection custom_attributes; + Collection security_declarations; + + internal RVA rva; + internal PInvokeInfo pinvoke; + Collection overrides; - MethodAttributes m_attributes; - MethodImplAttributes m_implAttrs; - MethodSemanticsAttributes m_semAttrs; - SecurityDeclarationCollection m_secDecls; - CustomAttributeCollection m_customAttrs; - - ModuleDefinition m_module; - - MethodBody m_body; - RVA m_rva; - OverrideCollection m_overrides; - PInvokeInfo m_pinvoke; - readonly ParameterDefinition m_this; + internal MethodBody body; public MethodAttributes Attributes { - get { return m_attributes; } - set { m_attributes = value; } + get { return (MethodAttributes) attributes; } + set { attributes = (ushort) value; } } public MethodImplAttributes ImplAttributes { - get { return m_implAttrs; } - set { m_implAttrs = value; } + get { return (MethodImplAttributes) impl_attributes; } + set { impl_attributes = (ushort) value; } } public MethodSemanticsAttributes SemanticsAttributes { - get { return m_semAttrs; } - set { m_semAttrs = value; } - } + get { + if (sem_attrs.HasValue) + return sem_attrs.Value; - public override TypeReference DeclaringType { - get { return base.DeclaringType; } - set { - base.DeclaringType = value; - TypeDefinition t = value as TypeDefinition; - if (t != null) - m_module = t.Module; + if (HasImage) { + ReadSemantics (); + return sem_attrs.Value; + } + + sem_attrs = MethodSemanticsAttributes.None; + return sem_attrs.Value; } + set { sem_attrs = value; } + } + + internal void ReadSemantics () + { + if (sem_attrs.HasValue) + return; + + var module = this.Module; + if (module == null) + return; + + if (!module.HasImage) + return; + + module.Read (this, (method, reader) => reader.ReadAllSemantics (method)); } - public SecurityDeclarationCollection SecurityDeclarations { + public bool HasSecurityDeclarations { get { - if (m_secDecls == null) - m_secDecls = new SecurityDeclarationCollection (this); + if (security_declarations != null) + return security_declarations.Count > 0; - return m_secDecls; + return this.GetHasSecurityDeclarations (Module); } } - public CustomAttributeCollection CustomAttributes { + public Collection SecurityDeclarations { + get { return security_declarations ?? (security_declarations = this.GetSecurityDeclarations (Module)); } + } + + public bool HasCustomAttributes { get { - if (m_customAttrs == null) - m_customAttrs = new CustomAttributeCollection (this); + if (custom_attributes != null) + return custom_attributes.Count > 0; - return m_customAttrs; + return this.GetHasCustomAttributes (Module); } } - public RVA RVA { - get { return m_rva; } - set { m_rva = value; } + public Collection CustomAttributes { + get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (Module)); } + } + + public int RVA { + get { return (int) rva; } + } + + public bool HasBody { + get { + return (attributes & (ushort) MethodAttributes.Abstract) == 0 && + (attributes & (ushort) MethodAttributes.PInvokeImpl) == 0 && + (impl_attributes & (ushort) MethodImplAttributes.InternalCall) == 0 && + (impl_attributes & (ushort) MethodImplAttributes.Native) == 0 && + (impl_attributes & (ushort) MethodImplAttributes.Unmanaged) == 0 && + (impl_attributes & (ushort) MethodImplAttributes.Runtime) == 0; + } } public MethodBody Body { get { - LoadBody (); - return m_body; + if (body != null) + return body; + + if (!HasBody) + return null; + + if (HasImage && rva != 0) + return body = Module.Read (this, (method, reader) => reader.ReadMethodBody (method)); + + return body = new MethodBody (this); + } + set { body = value; } + } + + public bool HasPInvokeInfo { + get { + if (pinvoke != null) + return true; + + return IsPInvokeImpl; } - set { m_body = value; } } public PInvokeInfo PInvokeInfo { - get { return m_pinvoke; } - set { m_pinvoke = value; } + get { + if (pinvoke != null) + return pinvoke; + + if (HasImage && IsPInvokeImpl) + return pinvoke = Module.Read (this, (method, reader) => reader.ReadPInvokeInfo (method)); + + return null; + } + set { + IsPInvokeImpl = true; + pinvoke = value; + } } - public OverrideCollection Overrides { + public bool HasOverrides { get { - if (m_overrides == null) - m_overrides = new OverrideCollection (this); + if (overrides != null) + return overrides.Count > 0; - return m_overrides; + if (HasImage) + return Module.Read (this, (method, reader) => reader.HasOverrides (method)); + + return false; + } + } + + public Collection Overrides { + get { + if (overrides != null) + return overrides; + + if (HasImage) + return overrides = Module.Read (this, (method, reader) => reader.ReadOverrides (method)); + + return overrides = new Collection (); + } + } + + public override bool HasGenericParameters { + get { + if (generic_parameters != null) + return generic_parameters.Count > 0; + + return this.GetHasGenericParameters (Module); } } - public ParameterDefinition This { - get { return m_this; } + public override Collection GenericParameters { + get { return generic_parameters ?? (generic_parameters = this.GetGenericParameters (Module)); } } #region MethodAttributes public bool IsCompilerControlled { - get { return (m_attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Compilercontrolled; } - set { - if (value) { - m_attributes &= ~MethodAttributes.MemberAccessMask; - m_attributes |= MethodAttributes.Compilercontrolled; - } else - m_attributes &= ~(MethodAttributes.MemberAccessMask & MethodAttributes.Compilercontrolled); - } + get { return attributes.GetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.CompilerControlled); } + set { attributes = attributes.SetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.CompilerControlled, value); } } public bool IsPrivate { - get { return (m_attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Private; } - set { - if (value) { - m_attributes &= ~MethodAttributes.MemberAccessMask; - m_attributes |= MethodAttributes.Private; - } else - m_attributes &= ~(MethodAttributes.MemberAccessMask & MethodAttributes.Private); - } + get { return attributes.GetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.Private); } + set { attributes = attributes.SetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.Private, value); } } public bool IsFamilyAndAssembly { - get { return (m_attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.FamANDAssem; } - set { - if (value) { - m_attributes &= ~MethodAttributes.MemberAccessMask; - m_attributes |= MethodAttributes.FamANDAssem; - } else - m_attributes &= ~(MethodAttributes.MemberAccessMask & MethodAttributes.FamANDAssem); - } + get { return attributes.GetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.FamANDAssem); } + set { attributes = attributes.SetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.FamANDAssem, value); } } public bool IsAssembly { - get { return (m_attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Assem; } - set { - if (value) { - m_attributes &= ~MethodAttributes.MemberAccessMask; - m_attributes |= MethodAttributes.Assem; - } else - m_attributes &= ~(MethodAttributes.MemberAccessMask & MethodAttributes.Assem); - } + get { return attributes.GetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.Assembly); } + set { attributes = attributes.SetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.Assembly, value); } } public bool IsFamily { - get { return (m_attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Family; } - set { - if (value) { - m_attributes &= ~MethodAttributes.MemberAccessMask; - m_attributes |= MethodAttributes.Family; - } else - m_attributes &= ~(MethodAttributes.MemberAccessMask & MethodAttributes.Family); - } + get { return attributes.GetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.Family); } + set { attributes = attributes.SetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.Family, value); } } public bool IsFamilyOrAssembly { - get { return (m_attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.FamORAssem; } - set { - if (value) { - m_attributes &= ~MethodAttributes.MemberAccessMask; - m_attributes |= MethodAttributes.FamORAssem; - } else - m_attributes &= ~(MethodAttributes.MemberAccessMask & MethodAttributes.FamORAssem); - } + get { return attributes.GetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.FamORAssem); } + set { attributes = attributes.SetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.FamORAssem, value); } } public bool IsPublic { - get { return (m_attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Public; } - set { - if (value) { - m_attributes &= ~MethodAttributes.MemberAccessMask; - m_attributes |= MethodAttributes.Public; - } else - m_attributes &= ~(MethodAttributes.MemberAccessMask & MethodAttributes.Public); - } + get { return attributes.GetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.Public); } + set { attributes = attributes.SetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.Public, value); } } public bool IsStatic { - get { return (m_attributes & MethodAttributes.Static) != 0; } - set { - if (value) - m_attributes |= MethodAttributes.Static; - else - m_attributes &= ~MethodAttributes.Static; - } + get { return attributes.GetAttributes ((ushort) MethodAttributes.Static); } + set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.Static, value); } } public bool IsFinal { - get { return (m_attributes & MethodAttributes.Final) != 0; } - set { - if (value) - m_attributes |= MethodAttributes.Final; - else - m_attributes &= ~MethodAttributes.Final; - } + get { return attributes.GetAttributes ((ushort) MethodAttributes.Final); } + set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.Final, value); } } public bool IsVirtual { - get { return (m_attributes & MethodAttributes.Virtual) != 0; } - set { - if (value) - m_attributes |= MethodAttributes.Virtual; - else - m_attributes &= ~MethodAttributes.Virtual; - } + get { return attributes.GetAttributes ((ushort) MethodAttributes.Virtual); } + set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.Virtual, value); } } public bool IsHideBySig { - get { return (m_attributes & MethodAttributes.HideBySig) != 0; } - set { - if (value) - m_attributes |= MethodAttributes.HideBySig; - else - m_attributes &= ~MethodAttributes.HideBySig; - } + get { return attributes.GetAttributes ((ushort) MethodAttributes.HideBySig); } + set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.HideBySig, value); } } public bool IsReuseSlot { - get { return (m_attributes & MethodAttributes.VtableLayoutMask) == MethodAttributes.ReuseSlot; } - set { - if (value) { - m_attributes &= ~MethodAttributes.VtableLayoutMask; - m_attributes |= MethodAttributes.ReuseSlot; - } else - m_attributes &= ~(MethodAttributes.VtableLayoutMask & MethodAttributes.ReuseSlot); - } + get { return attributes.GetMaskedAttributes ((ushort) MethodAttributes.VtableLayoutMask, (ushort) MethodAttributes.ReuseSlot); } + set { attributes = attributes.SetMaskedAttributes ((ushort) MethodAttributes.VtableLayoutMask, (ushort) MethodAttributes.ReuseSlot, value); } } public bool IsNewSlot { - get { return (m_attributes & MethodAttributes.VtableLayoutMask) == MethodAttributes.NewSlot; } - set { - if (value) { - m_attributes &= ~MethodAttributes.VtableLayoutMask; - m_attributes |= MethodAttributes.NewSlot; - } else - m_attributes &= ~(MethodAttributes.VtableLayoutMask & MethodAttributes.NewSlot); - } + get { return attributes.GetMaskedAttributes ((ushort) MethodAttributes.VtableLayoutMask, (ushort) MethodAttributes.NewSlot); } + set { attributes = attributes.SetMaskedAttributes ((ushort) MethodAttributes.VtableLayoutMask, (ushort) MethodAttributes.NewSlot, value); } + } + + public bool IsCheckAccessOnOverride { + get { return attributes.GetAttributes ((ushort) MethodAttributes.CheckAccessOnOverride); } + set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.CheckAccessOnOverride, value); } } public bool IsAbstract { - get { return (m_attributes & MethodAttributes.Abstract) != 0; } - set { - if (value) - m_attributes |= MethodAttributes.Abstract; - else - m_attributes &= ~MethodAttributes.Abstract; - } + get { return attributes.GetAttributes ((ushort) MethodAttributes.Abstract); } + set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.Abstract, value); } } public bool IsSpecialName { - get { return (m_attributes & MethodAttributes.SpecialName) != 0; } - set { - if (value) - m_attributes |= MethodAttributes.SpecialName; - else - m_attributes &= ~MethodAttributes.SpecialName; - } + get { return attributes.GetAttributes ((ushort) MethodAttributes.SpecialName); } + set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.SpecialName, value); } } public bool IsPInvokeImpl { - get { return (m_attributes & MethodAttributes.PInvokeImpl) != 0; } - set { - if (value) - m_attributes |= MethodAttributes.PInvokeImpl; - else - m_attributes &= ~MethodAttributes.PInvokeImpl; - } + get { return attributes.GetAttributes ((ushort) MethodAttributes.PInvokeImpl); } + set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.PInvokeImpl, value); } } public bool IsUnmanagedExport { - get { return (m_attributes & MethodAttributes.UnmanagedExport) != 0; } - set { - if (value) - m_attributes |= MethodAttributes.UnmanagedExport; - else - m_attributes &= ~MethodAttributes.UnmanagedExport; - } + get { return attributes.GetAttributes ((ushort) MethodAttributes.UnmanagedExport); } + set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.UnmanagedExport, value); } } public bool IsRuntimeSpecialName { - get { return (m_attributes & MethodAttributes.RTSpecialName) != 0; } - set { - if (value) - m_attributes |= MethodAttributes.RTSpecialName; - else - m_attributes &= ~MethodAttributes.RTSpecialName; - } + get { return attributes.GetAttributes ((ushort) MethodAttributes.RTSpecialName); } + set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.RTSpecialName, value); } } public bool HasSecurity { - get { return (m_attributes & MethodAttributes.HasSecurity) != 0; } - set { - if (value) - m_attributes |= MethodAttributes.HasSecurity; - else - m_attributes &= ~MethodAttributes.HasSecurity; - } + get { return attributes.GetAttributes ((ushort) MethodAttributes.HasSecurity); } + set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.HasSecurity, value); } } #endregion @@ -331,229 +314,174 @@ #region MethodImplAttributes public bool IsIL { - get { return (m_implAttrs & MethodImplAttributes.CodeTypeMask) == MethodImplAttributes.IL; } - set { - if (value) { - m_implAttrs &= ~MethodImplAttributes.CodeTypeMask; - m_implAttrs |= MethodImplAttributes.IL; - } else - m_implAttrs &= ~(MethodImplAttributes.CodeTypeMask & MethodImplAttributes.IL); - } + get { return impl_attributes.GetMaskedAttributes ((ushort) MethodImplAttributes.CodeTypeMask, (ushort) MethodImplAttributes.IL); } + set { impl_attributes = impl_attributes.SetMaskedAttributes ((ushort) MethodImplAttributes.CodeTypeMask, (ushort) MethodImplAttributes.IL, value); } } public bool IsNative { - get { return (m_implAttrs & MethodImplAttributes.CodeTypeMask) == MethodImplAttributes.Native; } - set { - if (value) { - m_implAttrs &= ~MethodImplAttributes.CodeTypeMask; - m_implAttrs |= MethodImplAttributes.Native; - } else - m_implAttrs &= ~(MethodImplAttributes.CodeTypeMask & MethodImplAttributes.Native); - } + get { return impl_attributes.GetMaskedAttributes ((ushort) MethodImplAttributes.CodeTypeMask, (ushort) MethodImplAttributes.Native); } + set { impl_attributes = impl_attributes.SetMaskedAttributes ((ushort) MethodImplAttributes.CodeTypeMask, (ushort) MethodImplAttributes.Native, value); } } public bool IsRuntime { - get { return (m_implAttrs & MethodImplAttributes.CodeTypeMask) == MethodImplAttributes.Runtime; } - set { - if (value) { - m_implAttrs &= ~MethodImplAttributes.CodeTypeMask; - m_implAttrs |= MethodImplAttributes.Runtime; - } else - m_implAttrs &= ~(MethodImplAttributes.CodeTypeMask & MethodImplAttributes.Runtime); - } + get { return impl_attributes.GetMaskedAttributes ((ushort) MethodImplAttributes.CodeTypeMask, (ushort) MethodImplAttributes.Runtime); } + set { impl_attributes = impl_attributes.SetMaskedAttributes ((ushort) MethodImplAttributes.CodeTypeMask, (ushort) MethodImplAttributes.Runtime, value); } } public bool IsUnmanaged { - get { return (m_implAttrs & MethodImplAttributes.ManagedMask) == MethodImplAttributes.Unmanaged; } - set { - if (value) { - m_implAttrs &= ~MethodImplAttributes.ManagedMask; - m_implAttrs |= MethodImplAttributes.Unmanaged; - } else - m_implAttrs &= ~(MethodImplAttributes.ManagedMask & MethodImplAttributes.Unmanaged); - } + get { return impl_attributes.GetMaskedAttributes ((ushort) MethodImplAttributes.ManagedMask, (ushort) MethodImplAttributes.Unmanaged); } + set { impl_attributes = impl_attributes.SetMaskedAttributes ((ushort) MethodImplAttributes.ManagedMask, (ushort) MethodImplAttributes.Unmanaged, value); } } public bool IsManaged { - get { return (m_implAttrs & MethodImplAttributes.ManagedMask) == MethodImplAttributes.Managed; } - set { - if (value) { - m_implAttrs &= ~MethodImplAttributes.ManagedMask; - m_implAttrs |= MethodImplAttributes.Managed; - } else - m_implAttrs &= ~(MethodImplAttributes.ManagedMask & MethodImplAttributes.Managed); - } + get { return impl_attributes.GetMaskedAttributes ((ushort) MethodImplAttributes.ManagedMask, (ushort) MethodImplAttributes.Managed); } + set { impl_attributes = impl_attributes.SetMaskedAttributes ((ushort) MethodImplAttributes.ManagedMask, (ushort) MethodImplAttributes.Managed, value); } } public bool IsForwardRef { - get { return (m_implAttrs & MethodImplAttributes.ForwardRef) != 0; } - set { - if (value) - m_implAttrs |= MethodImplAttributes.ForwardRef; - else - m_implAttrs &= ~MethodImplAttributes.ForwardRef; - } + get { return impl_attributes.GetAttributes ((ushort) MethodImplAttributes.ForwardRef); } + set { impl_attributes = impl_attributes.SetAttributes ((ushort) MethodImplAttributes.ForwardRef, value); } } public bool IsPreserveSig { - get { return (m_implAttrs & MethodImplAttributes.PreserveSig) != 0; } - set { - if (value) - m_implAttrs |= MethodImplAttributes.PreserveSig; - else - m_implAttrs &= ~MethodImplAttributes.PreserveSig; - } + get { return impl_attributes.GetAttributes ((ushort) MethodImplAttributes.PreserveSig); } + set { impl_attributes = impl_attributes.SetAttributes ((ushort) MethodImplAttributes.PreserveSig, value); } } public bool IsInternalCall { - get { return (m_implAttrs & MethodImplAttributes.InternalCall) != 0; } - set { - if (value) - m_implAttrs |= MethodImplAttributes.InternalCall; - else - m_implAttrs &= ~MethodImplAttributes.InternalCall; - } + get { return impl_attributes.GetAttributes ((ushort) MethodImplAttributes.InternalCall); } + set { impl_attributes = impl_attributes.SetAttributes ((ushort) MethodImplAttributes.InternalCall, value); } } public bool IsSynchronized { - get { return (m_implAttrs & MethodImplAttributes.Synchronized) != 0; } - set { - if (value) - m_implAttrs |= MethodImplAttributes.Synchronized; - else - m_implAttrs &= ~MethodImplAttributes.Synchronized; - } + get { return impl_attributes.GetAttributes ((ushort) MethodImplAttributes.Synchronized); } + set { impl_attributes = impl_attributes.SetAttributes ((ushort) MethodImplAttributes.Synchronized, value); } } public bool NoInlining { - get { return (m_implAttrs & MethodImplAttributes.NoInlining) != 0; } - set { - if (value) - m_implAttrs |= MethodImplAttributes.NoInlining; - else - m_implAttrs &= ~MethodImplAttributes.NoInlining; - } + get { return impl_attributes.GetAttributes ((ushort) MethodImplAttributes.NoInlining); } + set { impl_attributes = impl_attributes.SetAttributes ((ushort) MethodImplAttributes.NoInlining, value); } + } + + public bool NoOptimization { + get { return impl_attributes.GetAttributes ((ushort) MethodImplAttributes.NoOptimization); } + set { impl_attributes = impl_attributes.SetAttributes ((ushort) MethodImplAttributes.NoOptimization, value); } } #endregion - public bool IsConstructor { - get { - return this.IsRuntimeSpecialName && this.IsSpecialName && - (this.Name == Cctor || this.Name == Ctor); - } + #region MethodSemanticsAttributes + + public bool IsSetter { + get { return this.GetSemantics (MethodSemanticsAttributes.Setter); } + set { this.SetSemantics (MethodSemanticsAttributes.Setter, value); } } - public bool HasBody { - get { - return (m_attributes & MethodAttributes.Abstract) == 0 && - (m_attributes & MethodAttributes.PInvokeImpl) == 0 && - (m_implAttrs & MethodImplAttributes.InternalCall) == 0 && - (m_implAttrs & MethodImplAttributes.Native) == 0 && - (m_implAttrs & MethodImplAttributes.Unmanaged) == 0 && - (m_implAttrs & MethodImplAttributes.Runtime) == 0; - } + public bool IsGetter { + get { return this.GetSemantics (MethodSemanticsAttributes.Getter); } + set { this.SetSemantics (MethodSemanticsAttributes.Getter, value); } } - public MethodDefinition (string name, RVA rva, - MethodAttributes attrs, MethodImplAttributes implAttrs, - bool hasThis, bool explicitThis, MethodCallingConvention callConv) : - base (name, hasThis, explicitThis, callConv) - { - m_rva = rva; - m_attributes = attrs; - m_implAttrs = implAttrs; + public bool IsOther { + get { return this.GetSemantics (MethodSemanticsAttributes.Other); } + set { this.SetSemantics (MethodSemanticsAttributes.Other, value); } + } - if (!IsStatic) - m_this = new ParameterDefinition ("this", 0, (ParameterAttributes) 0, null); + public bool IsAddOn { + get { return this.GetSemantics (MethodSemanticsAttributes.AddOn); } + set { this.SetSemantics (MethodSemanticsAttributes.AddOn, value); } } - internal MethodDefinition (string name, MethodAttributes attrs) : base (name) - { - m_attributes = attrs; + public bool IsRemoveOn { + get { return this.GetSemantics (MethodSemanticsAttributes.RemoveOn); } + set { this.SetSemantics (MethodSemanticsAttributes.RemoveOn, value); } + } - this.HasThis = !this.IsStatic; - if (!IsStatic) - m_this = new ParameterDefinition ("this", 0, (ParameterAttributes) 0, null); + public bool IsFire { + get { return this.GetSemantics (MethodSemanticsAttributes.Fire); } + set { this.SetSemantics (MethodSemanticsAttributes.Fire, value); } } - public MethodDefinition (string name, MethodAttributes attrs, TypeReference returnType) : - this (name, attrs) - { - this.ReturnType.ReturnType = returnType; + #endregion + + public new TypeDefinition DeclaringType { + get { return (TypeDefinition) base.DeclaringType; } + set { base.DeclaringType = value; } } - internal void LoadBody () - { - if (m_body == null && this.HasBody) { - m_body = new MethodBody (this); - if (m_module != null && m_rva != RVA.Zero) - m_module.Controller.Reader.Code.VisitMethodBody (m_body); + public bool IsConstructor { + get { + return this.IsRuntimeSpecialName + && this.IsSpecialName + && (this.Name == ".cctor" || this.Name == ".ctor"); } } - public MethodDefinition Clone () - { - return Clone (this, new ImportContext (NullReferenceImporter.Instance, this)); + public override bool IsDefinition { + get { return true; } } - internal static MethodDefinition Clone (MethodDefinition meth, ImportContext context) + internal MethodDefinition () { - MethodDefinition nm = new MethodDefinition ( - meth.Name, - RVA.Zero, - meth.Attributes, - meth.ImplAttributes, - meth.HasThis, - meth.ExplicitThis, - meth.CallingConvention); + this.token = new MetadataToken (TokenType.Method); + } - context.GenericContext.Method = nm; + public MethodDefinition (string name, MethodAttributes attributes, TypeReference returnType) + : base (name, returnType) + { + this.attributes = (ushort) attributes; + this.HasThis = !this.IsStatic; + this.token = new MetadataToken (TokenType.Method); + } - foreach (GenericParameter p in meth.GenericParameters) - nm.GenericParameters.Add (GenericParameter.Clone (p, context)); + public override MethodDefinition Resolve () + { + return this; + } + } - nm.ReturnType.ReturnType = context.Import (meth.ReturnType.ReturnType); + static partial class Mixin { - if (meth.ReturnType.HasConstant) - nm.ReturnType.Constant = meth.ReturnType.Constant; + public static ParameterDefinition GetParameter (this MethodBody self, int index) + { + var method = self.method; - if (meth.ReturnType.MarshalSpec != null) - nm.ReturnType.MarshalSpec = meth.ReturnType.MarshalSpec; + if (method.HasThis) { + if (index == 0) + return self.ThisParameter; - foreach (CustomAttribute ca in meth.ReturnType.CustomAttributes) - nm.ReturnType.CustomAttributes.Add (CustomAttribute.Clone (ca, context)); + index--; + } - if (meth.PInvokeInfo != null) - nm.PInvokeInfo = meth.PInvokeInfo; // TODO: import module ? - foreach (ParameterDefinition param in meth.Parameters) - nm.Parameters.Add (ParameterDefinition.Clone (param, context)); - foreach (MethodReference ov in meth.Overrides) - nm.Overrides.Add (context.Import (ov)); - foreach (CustomAttribute ca in meth.CustomAttributes) - nm.CustomAttributes.Add (CustomAttribute.Clone (ca, context)); - foreach (SecurityDeclaration sec in meth.SecurityDeclarations) - nm.SecurityDeclarations.Add (SecurityDeclaration.Clone (sec)); + var parameters = method.Parameters; - if (meth.Body != null) - nm.Body = MethodBody.Clone (meth.Body, nm, context); + if (index < 0 || index >= parameters.size) + return null; - return nm; + return parameters [index]; } - public override void Accept (IReflectionVisitor visitor) + public static VariableDefinition GetVariable (this MethodBody self, int index) { - visitor.VisitMethodDefinition (this); + var variables = self.Variables; + + if (index < 0 || index >= variables.size) + return null; - this.GenericParameters.Accept (visitor); - this.Parameters.Accept (visitor); + return variables [index]; + } - if (this.PInvokeInfo != null) - this.PInvokeInfo.Accept (visitor); + public static bool GetSemantics (this MethodDefinition self, MethodSemanticsAttributes semantics) + { + return (self.SemanticsAttributes & semantics) != 0; + } - this.SecurityDeclarations.Accept (visitor); - this.Overrides.Accept (visitor); - this.CustomAttributes.Accept (visitor); + public static void SetSemantics (this MethodDefinition self, MethodSemanticsAttributes semantics, bool value) + { + if (value) + self.SemanticsAttributes |= semantics; + else + self.SemanticsAttributes &= ~semantics; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodImplAttributes.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodImplAttributes.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodImplAttributes.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodImplAttributes.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,9 +26,9 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { +using System; - using System; +namespace Mono.Cecil { [Flags] public enum MethodImplAttributes : ushort { @@ -47,6 +47,7 @@ PreserveSig = 0x0080, // Reserved: conforming implementations may ignore InternalCall = 0x1000, // Reserved: shall be zero in conforming implementations Synchronized = 0x0020, // Method is single threaded through the body + NoOptimization = 0x0040, // Method is not optimized by the JIT. NoInlining = 0x0008, // Method may not be inlined MaxMethodImplVal = 0xffff // Range check value } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodReference.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodReference.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodReference.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodReference.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 - 2007 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,113 +26,189 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { +using System; +using System.Text; + +using Mono.Collections.Generic; - using System.Text; +namespace Mono.Cecil { - public class MethodReference : MemberReference, IMethodSignature, IGenericParameterProvider { + public class MethodReference : MemberReference, IMethodSignature, IGenericParameterProvider, IGenericContext { - ParameterDefinitionCollection m_parameters; - MethodReturnType m_returnType; + internal ParameterDefinitionCollection parameters; + MethodReturnType return_type; - bool m_hasThis; - bool m_explicitThis; - MethodCallingConvention m_callConv; - GenericParameterCollection m_genparams; + bool has_this; + bool explicit_this; + MethodCallingConvention calling_convention; + internal Collection generic_parameters; public virtual bool HasThis { - get { return m_hasThis; } - set { m_hasThis = value; } + get { return has_this; } + set { has_this = value; } } public virtual bool ExplicitThis { - get { return m_explicitThis; } - set { m_explicitThis = value; } + get { return explicit_this; } + set { explicit_this = value; } } public virtual MethodCallingConvention CallingConvention { - get { return m_callConv; } - set { m_callConv = value; } + get { return calling_convention; } + set { calling_convention = value; } + } + + public virtual bool HasParameters { + get { return !parameters.IsNullOrEmpty (); } + } + + public virtual Collection Parameters { + get { + if (parameters == null) + parameters = new ParameterDefinitionCollection (this); + + return parameters; + } + } + + IGenericParameterProvider IGenericContext.Type { + get { + var declaring_type = this.DeclaringType; + var instance = declaring_type as GenericInstanceType; + if (instance != null) + return instance.ElementType; + + return declaring_type; + } + } + + IGenericParameterProvider IGenericContext.Method { + get { return this; } + } + + GenericParameterType IGenericParameterProvider.GenericParameterType { + get { return GenericParameterType.Method; } + } + + public virtual bool HasGenericParameters { + get { return !generic_parameters.IsNullOrEmpty (); } } - public virtual ParameterDefinitionCollection Parameters { + public virtual Collection GenericParameters { get { - if (m_parameters == null) - m_parameters = new ParameterDefinitionCollection (this); - return m_parameters; + if (generic_parameters != null) + return generic_parameters; + + return generic_parameters = new Collection (); } } - public GenericParameterCollection GenericParameters { + public TypeReference ReturnType { get { - if (m_genparams == null) - m_genparams = new GenericParameterCollection (this); - return m_genparams; + var return_type = MethodReturnType; + return return_type != null ? return_type.ReturnType : null; + } + set { + var return_type = MethodReturnType; + if (return_type != null) + return_type.ReturnType = value; } } - public virtual MethodReturnType ReturnType { - get { return m_returnType;} - set { m_returnType = value; } + public virtual MethodReturnType MethodReturnType { + get { return return_type; } + set { return_type = value; } } - internal MethodReference (string name, bool hasThis, - bool explicitThis, MethodCallingConvention callConv) : this (name) + public override string FullName { + get { + var builder = new StringBuilder (); + builder.Append (ReturnType.FullName); + builder.Append (" "); + builder.Append (MemberFullName ()); + this.MethodSignatureFullName (builder); + return builder.ToString (); + } + } + + public virtual bool IsGenericInstance { + get { return false; } + } + + internal override bool ContainsGenericParameter { + get { + if (this.ReturnType.ContainsGenericParameter || base.ContainsGenericParameter) + return true; + + var parameters = this.Parameters; + + for (int i = 0; i < parameters.Count; i++) + if (parameters [i].ParameterType.ContainsGenericParameter) + return true; + + return false; + } + } + + internal MethodReference () { - m_parameters = new ParameterDefinitionCollection (this); - m_hasThis = hasThis; - m_explicitThis = explicitThis; - m_callConv = callConv; + this.return_type = new MethodReturnType (this); + this.token = new MetadataToken (TokenType.MemberRef); } - internal MethodReference (string name) : base (name) + public MethodReference (string name, TypeReference returnType) + : base (name) { - m_returnType = new MethodReturnType (null); + if (returnType == null) + throw new ArgumentNullException ("returnType"); + + this.return_type = new MethodReturnType (this); + this.return_type.ReturnType = returnType; + this.token = new MetadataToken (TokenType.MemberRef); } - public MethodReference (string name, - TypeReference declaringType, TypeReference returnType, - bool hasThis, bool explicitThis, MethodCallingConvention callConv) : - this (name, hasThis, explicitThis, callConv) + public MethodReference (string name, TypeReference returnType, TypeReference declaringType) + : this (name, returnType) { + if (declaringType == null) + throw new ArgumentNullException ("declaringType"); + this.DeclaringType = declaringType; - this.ReturnType.ReturnType = returnType; } - public virtual MethodReference GetOriginalMethod () + public virtual MethodReference GetElementMethod () { return this; } - public int GetSentinel () + public virtual MethodDefinition Resolve () { - for (int i = 0; i < Parameters.Count; i++) - if (Parameters [i].ParameterType is SentinelType) - return i; + var module = this.Module; + if (module == null) + throw new NotSupportedException (); - return -1; + return module.Resolve (this); } + } + + static partial class Mixin { - public override string ToString () + public static bool IsVarArg (this IMethodSignature self) { - int sentinel = GetSentinel (); + return (self.CallingConvention & MethodCallingConvention.VarArg) != 0; + } - StringBuilder sb = new StringBuilder (); - sb.Append (m_returnType.ReturnType.FullName); - sb.Append (" "); - sb.Append (base.ToString ()); - sb.Append ("("); - for (int i = 0; i < this.Parameters.Count; i++) { - if (i > 0) - sb.Append (","); + public static int GetSentinelPosition (this IMethodSignature self) + { + if (!self.HasParameters) + return -1; - if (i == sentinel) - sb.Append ("...,"); + var parameters = self.Parameters; + for (int i = 0; i < parameters.Count; i++) + if (parameters [i].ParameterType.IsSentinel) + return i; - sb.Append (this.Parameters [i].ParameterType.FullName); - } - sb.Append (")"); - return sb.ToString (); + return -1; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodReturnType.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodReturnType.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodReturnType.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodReturnType.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,85 +26,75 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { - - using System.Reflection; - - using Mono.Cecil.Metadata; +using Mono.Collections.Generic; - public sealed class MethodReturnType : ICustomAttributeProvider, IHasMarshalSpec, IHasConstant { +namespace Mono.Cecil { - MethodReference m_method; - ParameterDefinition m_param; + public sealed class MethodReturnType : IConstantProvider, ICustomAttributeProvider, IMarshalInfoProvider { - TypeReference m_returnType; + internal IMethodSignature method; + internal ParameterDefinition parameter; + TypeReference return_type; - public MethodReference Method { - get { return m_method; } - set { m_method = value; } + public IMethodSignature Method { + get { return method; } } public TypeReference ReturnType { - get { return m_returnType; } - set { m_returnType = value; } + get { return return_type; } + set { return_type = value; } } internal ParameterDefinition Parameter { - get { return m_param; } - set { m_param = value; } + get { return parameter ?? (parameter = new ParameterDefinition (return_type)); } + set { parameter = value; } } public MetadataToken MetadataToken { - get { return m_param.MetadataToken; } - set { m_param.MetadataToken = value; } + get { return Parameter.MetadataToken; } + set { Parameter.MetadataToken = value; } + } + + public bool HasCustomAttributes { + get { return parameter != null && parameter.HasCustomAttributes; } } - public CustomAttributeCollection CustomAttributes { - get { - if (m_param == null) { - m_param = new ParameterDefinition ( - string.Empty, 0, (ParameterAttributes) 0, m_returnType); - m_param.Method = m_method; - } + public Collection CustomAttributes { + get { return Parameter.CustomAttributes; } + } - return m_param.CustomAttributes; - } + public bool HasDefault { + get { return parameter != null && parameter.HasDefault; } + set { Parameter.HasDefault = value; } } public bool HasConstant { - get { - if (m_param == null) - return false; - - return m_param.HasConstant; - } + get { return parameter != null && parameter.HasConstant; } + set { Parameter.HasConstant = value; } } public object Constant { - get { - if (m_param == null) - return null; + get { return Parameter.Constant; } + set { Parameter.Constant = value; } + } - return m_param.Constant; - } - set { - m_param.Constant = value; - } + public bool HasFieldMarshal { + get { return parameter != null && parameter.HasFieldMarshal; } + set { Parameter.HasFieldMarshal = value; } } - public MarshalSpec MarshalSpec { - get { - if (m_param == null) - return null; + public bool HasMarshalInfo { + get { return parameter != null && parameter.HasMarshalInfo; } + } - return m_param.MarshalSpec; - } - set { m_param.MarshalSpec = value; } + public MarshalInfo MarshalInfo { + get { return Parameter.MarshalInfo; } + set { Parameter.MarshalInfo = value; } } - public MethodReturnType (TypeReference retType) + public MethodReturnType (IMethodSignature method) { - m_returnType = retType; + this.method = method; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodSemanticsAttributes.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodSemanticsAttributes.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodSemanticsAttributes.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodSemanticsAttributes.cs 2011-04-13 09:00:29.000000000 +0000 @@ -1,10 +1,10 @@ // -// MethodSemanticsAttributes.cs +// MethodSemanticsattributes.cs // // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,12 +26,13 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { +using System; - using System; +namespace Mono.Cecil { [Flags] public enum MethodSemanticsAttributes : ushort { + None = 0x0000, Setter = 0x0001, // Setter for property Getter = 0x0002, // Getter for property Other = 0x0004, // Other method for property or event diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodSpecification.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodSpecification.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodSpecification.cs 2008-11-06 19:52:04.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodSpecification.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,61 +26,78 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { +using System; + +using Mono.Collections.Generic; - using System; +namespace Mono.Cecil { public abstract class MethodSpecification : MethodReference { - MethodReference m_elementMethod; + readonly MethodReference method; public MethodReference ElementMethod { - get { return m_elementMethod; } - set { m_elementMethod = value; } + get { return method; } } public override string Name { - get { return m_elementMethod.Name; } + get { return method.Name; } set { throw new InvalidOperationException (); } } public override MethodCallingConvention CallingConvention { - get { return m_elementMethod.CallingConvention; } + get { return method.CallingConvention; } set { throw new InvalidOperationException (); } } public override bool HasThis { - get { return m_elementMethod.HasThis; } + get { return method.HasThis; } set { throw new InvalidOperationException (); } } public override bool ExplicitThis { - get { return m_elementMethod.ExplicitThis; } + get { return method.ExplicitThis; } set { throw new InvalidOperationException (); } } - public override MethodReturnType ReturnType { - get { return m_elementMethod.ReturnType; } + public override MethodReturnType MethodReturnType { + get { return method.MethodReturnType; } set { throw new InvalidOperationException (); } } public override TypeReference DeclaringType { - get { return m_elementMethod.DeclaringType; } + get { return method.DeclaringType; } set { throw new InvalidOperationException (); } } - public override ParameterDefinitionCollection Parameters { - get { return m_elementMethod.Parameters; } + public override ModuleDefinition Module { + get { return method.Module; } + } + + public override bool HasParameters { + get { return method.HasParameters; } } - internal MethodSpecification (MethodReference elemMethod) : base (string.Empty) + public override Collection Parameters { + get { return method.Parameters; } + } + + internal override bool ContainsGenericParameter { + get { return method.ContainsGenericParameter; } + } + + internal MethodSpecification (MethodReference method) { - m_elementMethod = elemMethod; + if (method == null) + throw new ArgumentNullException ("method"); + + this.method = method; + this.token = new MetadataToken (TokenType.MethodSpec); } - public override MethodReference GetOriginalMethod() + public sealed override MethodReference GetElementMethod () { - return m_elementMethod.GetOriginalMethod (); + return method.GetElementMethod (); } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Modifiers.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Modifiers.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Modifiers.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Modifiers.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,62 +26,112 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System; + +using MD = Mono.Cecil.Metadata; + namespace Mono.Cecil { - public abstract class ModType : TypeSpecification { + public interface IModifierType { + TypeReference ModifierType { get; } + TypeReference ElementType { get; } + } + + public sealed class OptionalModifierType : TypeSpecification, IModifierType { - TypeReference m_modifierType; + TypeReference modifier_type; public TypeReference ModifierType { - get { return m_modifierType; } - set { m_modifierType = value; } + get { return modifier_type; } + set { modifier_type = value; } } - public override string Name - { - get { return string.Concat (base.Name, Suffix ()); } + public override string Name { + get { return base.Name + Suffix; } } - public override string FullName - { - get { return string.Concat (base.FullName, Suffix ()); } + public override string FullName { + get { return base.FullName + Suffix; } } - string Suffix () - { - return string.Concat (" ", ModifierName, "(", this.ModifierType.FullName, ")"); + string Suffix { + get { return " modopt(" + modifier_type + ")"; } } - protected abstract string ModifierName { - get; + public override bool IsValueType { + get { return false; } + set { throw new InvalidOperationException (); } } - public ModType (TypeReference elemType, TypeReference modType) : base (elemType) + public override bool IsOptionalModifier { + get { return true; } + } + + internal override bool ContainsGenericParameter { + get { return modifier_type.ContainsGenericParameter || base.ContainsGenericParameter; } + } + + public OptionalModifierType (TypeReference modifierType, TypeReference type) + : base (type) { - m_modifierType = modType; + Mixin.CheckModifier (modifierType, type); + this.modifier_type = modifierType; + this.etype = MD.ElementType.CModOpt; } } - public sealed class ModifierOptional : ModType { + public sealed class RequiredModifierType : TypeSpecification, IModifierType { - protected override string ModifierName { - get { return "modopt"; } + TypeReference modifier_type; + + public TypeReference ModifierType { + get { return modifier_type; } + set { modifier_type = value; } } - public ModifierOptional (TypeReference elemType, TypeReference modType) : base (elemType, modType) - { + public override string Name { + get { return base.Name + Suffix; } } - } + public override string FullName { + get { return base.FullName + Suffix; } + } + + string Suffix { + get { return " modreq(" + modifier_type + ")"; } + } - public sealed class ModifierRequired : ModType { + public override bool IsValueType { + get { return false; } + set { throw new InvalidOperationException (); } + } + + public override bool IsRequiredModifier { + get { return true; } + } - protected override string ModifierName { - get { return "modreq"; } + internal override bool ContainsGenericParameter { + get { return modifier_type.ContainsGenericParameter || base.ContainsGenericParameter; } } - public ModifierRequired (TypeReference elemType, TypeReference modType) : base (elemType, modType) + public RequiredModifierType (TypeReference modifierType, TypeReference type) + : base (type) + { + Mixin.CheckModifier (modifierType, type); + this.modifier_type = modifierType; + this.etype = MD.ElementType.CModReqD; + } + + } + + static partial class Mixin { + + public static void CheckModifier (TypeReference modifierType, TypeReference type) { + if (modifierType == null) + throw new ArgumentNullException ("modifierType"); + if (type == null) + throw new ArgumentNullException ("type"); } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleDefinitionCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleDefinitionCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleDefinitionCollection.cs 2008-11-06 19:52:04.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleDefinitionCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ -// -// ModuleDefinitionCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Wed Sep 27 12:46:54 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.Collections; - - using Mono.Cecil.Cil; - - public sealed class ModuleDefinitionCollection : CollectionBase, IReflectionStructureVisitable { - - AssemblyDefinition m_container; - - public ModuleDefinition this [int index] { - get { return List [index] as ModuleDefinition; } - set { List [index] = value; } - } - - public AssemblyDefinition Container { - get { return m_container; } - } - - public ModuleDefinitionCollection (AssemblyDefinition container) - { - m_container = container; - } - - public void Add (ModuleDefinition value) - { - List.Add (value); - } - - public bool Contains (ModuleDefinition value) - { - return List.Contains (value); - } - - public int IndexOf (ModuleDefinition value) - { - return List.IndexOf (value); - } - - public void Insert (int index, ModuleDefinition value) - { - List.Insert (index, value); - } - - public void Remove (ModuleDefinition value) - { - List.Remove (value); - } - - protected override void OnValidate (object o) - { - if (! (o is ModuleDefinition)) - throw new ArgumentException ("Must be of type " + typeof (ModuleDefinition).FullName); - } - - public void Accept (IReflectionStructureVisitor visitor) - { - visitor.VisitModuleDefinitionCollection (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleDefinition.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleDefinition.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleDefinition.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleDefinition.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,503 +26,940 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System; +using System.Collections.Generic; +using System.IO; +using SR = System.Reflection; + +using Mono.Cecil.Cil; +using Mono.Cecil.Metadata; +using Mono.Cecil.PE; +using Mono.Collections.Generic; + namespace Mono.Cecil { - using System; - using SR = System.Reflection; - using SS = System.Security; - using SSP = System.Security.Permissions; - using System.Text; - - using Mono.Cecil.Cil; - using Mono.Cecil.Binary; - using Mono.Cecil.Metadata; - - public sealed class ModuleDefinition : ModuleReference, ICustomAttributeProvider, IMetadataScope, - IReflectionStructureVisitable, IReflectionVisitable { - - Guid m_mvid; - bool m_main; - bool m_manifestOnly; - - AssemblyNameReferenceCollection m_asmRefs; - ModuleReferenceCollection m_modRefs; - ResourceCollection m_res; - TypeDefinitionCollection m_types; - TypeReferenceCollection m_refs; - ExternTypeCollection m_externs; - MemberReferenceCollection m_members; - CustomAttributeCollection m_customAttrs; - - AssemblyDefinition m_asm; - Image m_image; - - ImageReader m_imgReader; - ReflectionController m_controller; - SecurityDeclarationReader m_secReader; + public enum ReadingMode { + Immediate = 1, + Deferred = 2, + } + + public sealed class ReaderParameters { + + ReadingMode reading_mode; + IAssemblyResolver assembly_resolver; + Stream symbol_stream; + ISymbolReaderProvider symbol_reader_provider; + bool read_symbols; + + public ReadingMode ReadingMode { + get { return reading_mode; } + set { reading_mode = value; } + } + + public IAssemblyResolver AssemblyResolver { + get { return assembly_resolver; } + set { assembly_resolver = value; } + } + + public Stream SymbolStream { + get { return symbol_stream; } + set { symbol_stream = value; } + } + + public ISymbolReaderProvider SymbolReaderProvider { + get { return symbol_reader_provider; } + set { symbol_reader_provider = value; } + } + + public bool ReadSymbols { + get { return read_symbols; } + set { read_symbols = value; } + } + + public ReaderParameters () + : this (ReadingMode.Deferred) + { + } + + public ReaderParameters (ReadingMode readingMode) + { + this.reading_mode = readingMode; + } + } + +#if !READ_ONLY + + public sealed class ModuleParameters { + + ModuleKind kind; + TargetRuntime runtime; + TargetArchitecture architecture; + IAssemblyResolver assembly_resolver; + + public ModuleKind Kind { + get { return kind; } + set { kind = value; } + } + + public TargetRuntime Runtime { + get { return runtime; } + set { runtime = value; } + } + + public TargetArchitecture Architecture { + get { return architecture; } + set { architecture = value; } + } + + public IAssemblyResolver AssemblyResolver { + get { return assembly_resolver; } + set { assembly_resolver = value; } + } + + public ModuleParameters () + { + this.kind = ModuleKind.Dll; + this.runtime = GetCurrentRuntime (); + this.architecture = TargetArchitecture.I386; + } + + static TargetRuntime GetCurrentRuntime () + { +#if !CF + return typeof (object).Assembly.ImageRuntimeVersion.ParseRuntime (); +#else + var corlib_version = typeof (object).Assembly.GetName ().Version; + switch (corlib_version.Major) { + case 1: + return corlib_version.Minor == 0 + ? TargetRuntime.Net_1_0 + : TargetRuntime.Net_1_1; + case 2: + return TargetRuntime.Net_2_0; + case 4: + return TargetRuntime.Net_4_0; + default: + throw new NotSupportedException (); + } +#endif + } + } + + public sealed class WriterParameters { + + Stream symbol_stream; + ISymbolWriterProvider symbol_writer_provider; + bool write_symbols; +#if !SILVERLIGHT && !CF + SR.StrongNameKeyPair key_pair; +#endif + public Stream SymbolStream { + get { return symbol_stream; } + set { symbol_stream = value; } + } + + public ISymbolWriterProvider SymbolWriterProvider { + get { return symbol_writer_provider; } + set { symbol_writer_provider = value; } + } + + public bool WriteSymbols { + get { return write_symbols; } + set { write_symbols = value; } + } +#if !SILVERLIGHT && !CF + public SR.StrongNameKeyPair StrongNameKeyPair { + get { return key_pair; } + set { key_pair = value; } + } +#endif + } + +#endif + + public sealed class ModuleDefinition : ModuleReference, ICustomAttributeProvider { + + internal Image Image; + internal MetadataSystem MetadataSystem; + internal ReadingMode ReadingMode; + internal ISymbolReaderProvider SymbolReaderProvider; + internal ISymbolReader SymbolReader; + + internal IAssemblyResolver assembly_resolver; + internal TypeSystem type_system; + + readonly MetadataReader reader; + readonly string fq_name; + + internal ModuleKind kind; + TargetRuntime runtime; + TargetArchitecture architecture; + ModuleAttributes attributes; + Guid mvid; + + internal AssemblyDefinition assembly; + MethodDefinition entry_point; + +#if !READ_ONLY + MetadataImporter importer; +#endif + Collection custom_attributes; + Collection references; + Collection modules; + Collection resources; + Collection exported_types; + TypeDefinitionCollection types; + + public bool IsMain { + get { return kind != ModuleKind.NetModule; } + } + + public ModuleKind Kind { + get { return kind; } + set { kind = value; } + } + + public TargetRuntime Runtime { + get { return runtime; } + set { runtime = value; } + } + + public TargetArchitecture Architecture { + get { return architecture; } + set { architecture = value; } + } + + public ModuleAttributes Attributes { + get { return attributes; } + set { attributes = value; } + } + + public string FullyQualifiedName { + get { return fq_name; } + } public Guid Mvid { - get { return m_mvid; } - set { m_mvid = value; } + get { return mvid; } + set { mvid = value; } + } + + internal bool HasImage { + get { return Image != null; } } - public bool Main { - get { return m_main; } - set { m_main = value; } + public bool HasSymbols { + get { return SymbolReader != null; } } - public AssemblyNameReferenceCollection AssemblyReferences { - get { return m_asmRefs; } + public override MetadataScopeType MetadataScopeType { + get { return MetadataScopeType.ModuleDefinition; } } - public ModuleReferenceCollection ModuleReferences { - get { return m_modRefs; } + public AssemblyDefinition Assembly { + get { return assembly; } } - public ResourceCollection Resources { - get { return m_res; } +#if !READ_ONLY + internal MetadataImporter MetadataImporter { + get { return importer ?? (importer = new MetadataImporter (this)); } } +#endif - public TypeDefinitionCollection Types { - get { return m_types; } + public IAssemblyResolver AssemblyResolver { + get { return assembly_resolver; } } - public TypeReferenceCollection TypeReferences { - get { return m_refs; } + public TypeSystem TypeSystem { + get { return type_system ?? (type_system = TypeSystem.CreateTypeSystem (this)); } } - public MemberReferenceCollection MemberReferences { - get { return m_members; } + public bool HasAssemblyReferences { + get { + if (references != null) + return references.Count > 0; + + return HasImage && Image.HasTable (Table.AssemblyRef); + } } - public ExternTypeCollection ExternTypes { + public Collection AssemblyReferences { get { - if (m_externs == null) - m_externs = new ExternTypeCollection (this); + if (references != null) + return references; - return m_externs; + if (HasImage) + return references = Read (this, (_, reader) => reader.ReadAssemblyReferences ()); + + return references = new Collection (); } } - public CustomAttributeCollection CustomAttributes { + public bool HasModuleReferences { get { - if (m_customAttrs == null) - m_customAttrs = new CustomAttributeCollection (this); + if (modules != null) + return modules.Count > 0; - return m_customAttrs; + return HasImage && Image.HasTable (Table.ModuleRef); } } - public AssemblyDefinition Assembly { - get { return m_asm; } + public Collection ModuleReferences { + get { + if (modules != null) + return modules; + + if (HasImage) + return modules = Read (this, (_, reader) => reader.ReadModuleReferences ()); + + return modules = new Collection (); + } } - internal ReflectionController Controller { - get { return m_controller; } + public bool HasResources { + get { + if (resources != null) + return resources.Count > 0; + + if (HasImage) + return Image.HasTable (Table.ManifestResource) || Read (this, (_, reader) => reader.HasFileResource ()); + + return false; + } } - internal ImageReader ImageReader { - get { return m_imgReader; } + public Collection Resources { + get { + if (resources != null) + return resources; + + if (HasImage) + return resources = Read (this, (_, reader) => reader.ReadResources ()); + + return resources = new Collection (); + } } - public Image Image { - get { return m_image; } - set { - m_image = value; - m_secReader = null; + public bool HasCustomAttributes { + get { + if (custom_attributes != null) + return custom_attributes.Count > 0; + + return this.GetHasCustomAttributes (this); } } - public ModuleDefinition (string name, AssemblyDefinition asm) : - this (name, asm, null, false) - { + public Collection CustomAttributes { + get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (this)); } + } + + public bool HasTypes { + get { + if (types != null) + return types.Count > 0; + + return HasImage && Image.HasTable (Table.TypeDef); + } + } + + public Collection Types { + get { + if (types != null) + return types; + + if (HasImage) + return types = Read (this, (_, reader) => reader.ReadTypes ()); + + return types = new TypeDefinitionCollection (this); + } + } + + public bool HasExportedTypes { + get { + if (exported_types != null) + return exported_types.Count > 0; + + return HasImage && Image.HasTable (Table.ExportedType); + } + } + + public Collection ExportedTypes { + get { + if (exported_types != null) + return exported_types; + + if (HasImage) + return exported_types = Read (this, (_, reader) => reader.ReadExportedTypes ()); + + return exported_types = new Collection (); + } + } + + public MethodDefinition EntryPoint { + get { + if (entry_point != null) + return entry_point; + + if (HasImage) + return entry_point = Read (this, (_, reader) => reader.ReadEntryPoint ()); + + return entry_point = null; + } + set { entry_point = value; } } - public ModuleDefinition (string name, AssemblyDefinition asm, bool main) : - this (name, asm, null, main) + internal ModuleDefinition () { + this.MetadataSystem = new MetadataSystem (); + this.token = new MetadataToken (TokenType.Module, 1); + this.assembly_resolver = GlobalAssemblyResolver.Instance; } - internal ModuleDefinition (string name, AssemblyDefinition asm, StructureReader reader) : - this (name, asm, reader, false) + internal ModuleDefinition (Image image) + : this () { + this.Image = image; + this.kind = image.Kind; + this.runtime = image.Runtime; + this.architecture = image.Architecture; + this.attributes = image.Attributes; + this.fq_name = image.FileName; + + this.reader = new MetadataReader (this); } - internal ModuleDefinition (string name, AssemblyDefinition asm, StructureReader reader, bool main) : base (name) + public bool HasTypeReference (string fullName) { - if (asm == null) - throw new ArgumentNullException ("asm"); - if (name == null || name.Length == 0) - throw new ArgumentNullException ("name"); + return HasTypeReference (string.Empty, fullName); + } - m_asm = asm; - m_main = main; -#if !CF_1_0 - m_mvid = Guid.NewGuid (); -#endif - if (reader != null) { - m_image = reader.Image; - m_imgReader = reader.ImageReader; - m_manifestOnly = reader.ManifestOnly; - } else - m_image = Image.CreateImage (); + public bool HasTypeReference (string scope, string fullName) + { + CheckFullName (fullName); - m_modRefs = new ModuleReferenceCollection (this); - m_asmRefs = new AssemblyNameReferenceCollection (this); - m_res = new ResourceCollection (this); - m_types = new TypeDefinitionCollection (this); - m_refs = new TypeReferenceCollection (this); - m_members = new MemberReferenceCollection (this); + if (!HasImage) + return false; - m_controller = new ReflectionController (this); + return Read (this, (_, reader) => reader.GetTypeReference (scope, fullName) != null); } - public IMetadataTokenProvider LookupByToken (MetadataToken token) + public bool TryGetTypeReference (string fullName, out TypeReference type) { - return m_controller.Reader.LookupByToken (token); + return TryGetTypeReference (string.Empty, fullName, out type); } - public IMetadataTokenProvider LookupByToken (TokenType table, int rid) + public bool TryGetTypeReference (string scope, string fullName, out TypeReference type) { - return LookupByToken (new MetadataToken (table, (uint) rid)); + CheckFullName (fullName); + + if (!HasImage) { + type = null; + return false; + } + + return (type = Read (this, (_, reader) => reader.GetTypeReference (scope, fullName))) != null; } - void CheckContext (TypeDefinition context) + public IEnumerable GetTypeReferences () { - if (context == null) - throw new ArgumentNullException ("context"); - if (context.Module != this) - throw new ArgumentException ("The context parameter does not belongs to this module"); - if (context.GenericParameters.Count == 0) - throw new ArgumentException ("The context parameter is not a generic type"); + if (!HasImage) + return Empty.Array; + + return Read (this, (_, reader) => reader.GetTypeReferences ()); } - ImportContext GetContext () + public IEnumerable GetMemberReferences () { - return new ImportContext (m_controller.Importer); + if (!HasImage) + return Empty.Array; + + return Read (this, (_, reader) => reader.GetMemberReferences ()); } - static ImportContext GetContext (IImporter importer) + public TypeDefinition GetType (string fullName) { - return new ImportContext (importer); + CheckFullName (fullName); + + var position = fullName.IndexOf ('/'); + if (position > 0) + return GetNestedType (fullName); + + return ((TypeDefinitionCollection) this.Types).GetType (fullName); } - ImportContext GetContext (TypeDefinition context) + public TypeDefinition GetType (string @namespace, string name) { - return new ImportContext (m_controller.Importer, context); + Mixin.CheckName (name); + + return ((TypeDefinitionCollection) this.Types).GetType (@namespace ?? string.Empty, name); } - static ImportContext GetContext (IImporter importer, TypeDefinition context) + static void CheckFullName (string fullName) { - return new ImportContext (importer, context); + if (fullName == null) + throw new ArgumentNullException ("fullName"); + if (fullName.Length == 0) + throw new ArgumentException (); } - public TypeReference Import (Type type) + TypeDefinition GetNestedType (string fullname) { + var names = fullname.Split ('/'); + var type = GetType (names [0]); + if (type == null) - throw new ArgumentNullException ("type"); + return null; + + for (int i = 1; i < names.Length; i++) { + var nested_type = type.GetNestedType (names [i]); + if (nested_type == null) + return null; + + type = nested_type; + } + + return type; + } - return m_controller.Helper.ImportSystemType (type, GetContext ()); + internal FieldDefinition Resolve (FieldReference field) + { + return MetadataResolver.Resolve (AssemblyResolver, field); + } + + internal MethodDefinition Resolve (MethodReference method) + { + return MetadataResolver.Resolve (AssemblyResolver, method); } - public TypeReference Import (Type type, TypeDefinition context) + internal TypeDefinition Resolve (TypeReference type) + { + return MetadataResolver.Resolve (AssemblyResolver, type); + } + +#if !READ_ONLY + + static void CheckType (object type) { if (type == null) throw new ArgumentNullException ("type"); - CheckContext (context); + } + + static void CheckField (object field) + { + if (field == null) + throw new ArgumentNullException ("field"); + } + + static void CheckMethod (object method) + { + if (method == null) + throw new ArgumentNullException ("method"); + } + + static void CheckContext (IGenericParameterProvider context, ModuleDefinition module) + { + if (context == null) + return; + + if (context.Module != module) + throw new ArgumentException (); + } + +#if !CF + public TypeReference Import (Type type) + { + CheckType (type); - return m_controller.Helper.ImportSystemType (type, GetContext (context)); + return MetadataImporter.ImportType (type, null, ImportGenericKind.Definition); } - public MethodReference Import (SR.MethodBase meth) + public TypeReference Import (Type type, TypeReference context) { - if (meth == null) - throw new ArgumentNullException ("meth"); + return Import (type, (IGenericParameterProvider) context); + } - if (meth is SR.ConstructorInfo) - return m_controller.Helper.ImportConstructorInfo ( - meth as SR.ConstructorInfo, GetContext ()); - else - return m_controller.Helper.ImportMethodInfo ( - meth as SR.MethodInfo, GetContext ()); + public TypeReference Import (Type type, MethodReference context) + { + return Import (type, (IGenericParameterProvider) context); } - public MethodReference Import (SR.MethodBase meth, TypeDefinition context) + TypeReference Import (Type type, IGenericParameterProvider context) { - if (meth == null) - throw new ArgumentNullException ("meth"); - CheckContext (context); + CheckType (type); + CheckContext (context, this); - if (meth is SR.ConstructorInfo) - return m_controller.Helper.ImportConstructorInfo ( - meth as SR.ConstructorInfo, GetContext (context)); - else - return m_controller.Helper.ImportMethodInfo ( - meth as SR.MethodInfo, GetContext (context)); + return MetadataImporter.ImportType ( + type, + (IGenericContext) context, + context != null + ? ImportGenericKind.Open + : ImportGenericKind.Definition); } public FieldReference Import (SR.FieldInfo field) { - if (field == null) - throw new ArgumentNullException ("field"); + CheckField (field); - return m_controller.Helper.ImportFieldInfo (field, GetContext ()); + return MetadataImporter.ImportField (field, null); } - public FieldReference Import (SR.FieldInfo field, TypeDefinition context) + public FieldReference Import (SR.FieldInfo field, TypeReference context) { - if (field == null) - throw new ArgumentNullException ("field"); - CheckContext (context); + return Import (field, (IGenericParameterProvider) context); + } - return m_controller.Helper.ImportFieldInfo (field, GetContext (context)); + public FieldReference Import (SR.FieldInfo field, MethodReference context) + { + return Import (field, (IGenericParameterProvider) context); } - public TypeReference Import (TypeReference type) + FieldReference Import (SR.FieldInfo field, IGenericParameterProvider context) { - if (type == null) - throw new ArgumentNullException ("type"); + CheckField (field); + CheckContext (context, this); - return m_controller.Importer.ImportTypeReference (type, GetContext ()); + return MetadataImporter.ImportField (field, (IGenericContext) context); } - public TypeReference Import (TypeReference type, TypeDefinition context) + public MethodReference Import (SR.MethodBase method) { - if (type == null) - throw new ArgumentNullException ("type"); - CheckContext (context); + CheckMethod (method); - return m_controller.Importer.ImportTypeReference (type, GetContext (context)); + return MetadataImporter.ImportMethod (method, null, ImportGenericKind.Definition); } - public MethodReference Import (MethodReference meth) + public MethodReference Import (SR.MethodBase method, TypeReference context) { - if (meth == null) - throw new ArgumentNullException ("meth"); + return Import (method, (IGenericParameterProvider) context); + } - return m_controller.Importer.ImportMethodReference (meth, GetContext ()); + public MethodReference Import (SR.MethodBase method, MethodReference context) + { + return Import (method, (IGenericParameterProvider) context); } - public MethodReference Import (MethodReference meth, TypeDefinition context) + MethodReference Import (SR.MethodBase method, IGenericParameterProvider context) { - if (meth == null) - throw new ArgumentNullException ("meth"); - CheckContext (context); + CheckMethod (method); + CheckContext (context, this); - return m_controller.Importer.ImportMethodReference (meth, GetContext (context)); + return MetadataImporter.ImportMethod (method, + (IGenericContext) context, + context != null + ? ImportGenericKind.Open + : ImportGenericKind.Definition); } +#endif - public FieldReference Import (FieldReference field) + public TypeReference Import (TypeReference type) { - if (field == null) - throw new ArgumentNullException ("field"); + CheckType (type); - return m_controller.Importer.ImportFieldReference (field, GetContext ()); + if (type.Module == this) + return type; + + return MetadataImporter.ImportType (type, null); } - public FieldReference Import (FieldReference field, TypeDefinition context) + public TypeReference Import (TypeReference type, TypeReference context) { - if (field == null) - throw new ArgumentNullException ("field"); - CheckContext (context); + return Import (type, (IGenericParameterProvider) context); + } - return m_controller.Importer.ImportFieldReference (field, GetContext (context)); + public TypeReference Import (TypeReference type, MethodReference context) + { + return Import (type, (IGenericParameterProvider) context); } - static FieldDefinition ImportFieldDefinition (FieldDefinition field, ImportContext context) + TypeReference Import (TypeReference type, IGenericParameterProvider context) { - return FieldDefinition.Clone (field, context); + CheckType (type); + + if (type.Module == this) + return type; + + CheckContext (context, this); + + return MetadataImporter.ImportType (type, (IGenericContext) context); } - static MethodDefinition ImportMethodDefinition (MethodDefinition meth, ImportContext context) + public FieldReference Import (FieldReference field) { - return MethodDefinition.Clone (meth, context); + CheckField (field); + + if (field.Module == this) + return field; + + return MetadataImporter.ImportField (field, null); } - static TypeDefinition ImportTypeDefinition (TypeDefinition type, ImportContext context) + public FieldReference Import (FieldReference field, TypeReference context) { - return TypeDefinition.Clone (type, context); + return Import (field, (IGenericParameterProvider) context); } - public TypeDefinition Inject (TypeDefinition type) + public FieldReference Import (FieldReference field, MethodReference context) { - return Inject (type, m_controller.Importer); + return Import (field, (IGenericParameterProvider) context); } - public TypeDefinition Inject (TypeDefinition type, IImporter importer) + FieldReference Import (FieldReference field, IGenericParameterProvider context) { - if (type == null) - throw new ArgumentNullException ("type"); - if (importer == null) - throw new ArgumentNullException ("importer"); + CheckField (field); + + if (field.Module == this) + return field; + + CheckContext (context, this); + + return MetadataImporter.ImportField (field, (IGenericContext) context); + } + + public MethodReference Import (MethodReference method) + { + CheckMethod (method); + + if (method.Module == this) + return method; + + return MetadataImporter.ImportMethod (method, null); + } - TypeDefinition definition = ImportTypeDefinition (type, GetContext (importer)); - this.Types.Add (definition); - return definition; + public MethodReference Import (MethodReference method, TypeReference context) + { + return Import (method, (IGenericParameterProvider) context); } - public TypeDefinition Inject (TypeDefinition type, TypeDefinition context) + public MethodReference Import (MethodReference method, MethodReference context) { - return Inject (type, context, m_controller.Importer); + return Import (method, (IGenericParameterProvider) context); } - public TypeDefinition Inject (TypeDefinition type, TypeDefinition context, IImporter importer) + MethodReference Import (MethodReference method, IGenericParameterProvider context) { - Check (type, context, importer); + CheckMethod (method); + + if (method.Module == this) + return method; - TypeDefinition definition = ImportTypeDefinition (type, GetContext (importer, context)); - context.NestedTypes.Add (definition); - return definition; + CheckContext (context, this); + + return MetadataImporter.ImportMethod (method, (IGenericContext) context); } - public MethodDefinition Inject (MethodDefinition meth, TypeDefinition context) +#endif + + public IMetadataTokenProvider LookupToken (int token) { - return Inject (meth, context, m_controller.Importer); + return LookupToken (new MetadataToken ((uint) token)); } - void Check (IMemberDefinition definition, TypeDefinition context, IImporter importer) + public IMetadataTokenProvider LookupToken (MetadataToken token) { - if (definition == null) - throw new ArgumentNullException ("definition"); - if (context == null) - throw new ArgumentNullException ("context"); - if (importer == null) - throw new ArgumentNullException ("importer"); - if (context.Module != this) - throw new ArgumentException ("The context parameter does not belongs to this module"); + return Read (this, (_, reader) => reader.LookupToken (token)); } - public MethodDefinition Inject (MethodDefinition meth, TypeDefinition context, IImporter importer) + internal TRet Read (TItem item, Func read) { - Check (meth, context, importer); + var position = reader.position; + var context = reader.context; + + var ret = read (item, reader); + + reader.position = position; + reader.context = context; - MethodDefinition definition = ImportMethodDefinition (meth, GetContext (importer, context)); - context.Methods.Add (definition); - return definition; + return ret; } - public FieldDefinition Inject (FieldDefinition field, TypeDefinition context, IImporter importer) + void ProcessDebugHeader () { - Check (field, context, importer); + if (Image == null || Image.Debug.IsZero) + return; + + byte [] header; + var directory = Image.GetDebugHeader (out header); - FieldDefinition definition = ImportFieldDefinition (field, GetContext (importer, context)); - context.Fields.Add (definition); - return definition; + if (!SymbolReader.ProcessDebugHeader (directory, header)) + throw new InvalidOperationException (); } - public void FullLoad () +#if !READ_ONLY + + public static ModuleDefinition CreateModule (string name, ModuleKind kind) { - if (m_manifestOnly) - m_controller.Reader.VisitModuleDefinition (this); + return CreateModule (name, new ModuleParameters { Kind = kind }); + } - foreach (TypeDefinition type in this.Types) { - foreach (MethodDefinition meth in type.Methods) - meth.LoadBody (); - foreach (MethodDefinition ctor in type.Constructors) - ctor.LoadBody (); + public static ModuleDefinition CreateModule (string name, ModuleParameters parameters) + { + Mixin.CheckName (name); + Mixin.CheckParameters (parameters); + + var module = new ModuleDefinition { + Name = name, + kind = parameters.Kind, + runtime = parameters.Runtime, + architecture = parameters.Architecture, + mvid = Guid.NewGuid (), + Attributes = ModuleAttributes.ILOnly, + }; + + if (parameters.AssemblyResolver != null) + module.assembly_resolver = parameters.AssemblyResolver; + + if (parameters.Kind != ModuleKind.NetModule) { + var assembly = new AssemblyDefinition (); + module.assembly = assembly; + module.assembly.Name = new AssemblyNameDefinition (name, new Version (0, 0)); + assembly.main_module = module; } - if (m_controller.Reader.SymbolReader == null) - return; + module.Types.Add (new TypeDefinition (string.Empty, "", TypeAttributes.NotPublic)); - m_controller.Reader.SymbolReader.Dispose (); - m_controller.Reader.SymbolReader = null; + return module; } - public void LoadSymbols () +#endif + + public void ReadSymbols () { - m_controller.Reader.SymbolReader = SymbolStoreHelper.GetReader (this); + if (string.IsNullOrEmpty (fq_name)) + throw new InvalidOperationException (); + + var provider = SymbolProvider.GetPlatformReaderProvider (); + + SymbolReader = provider.GetSymbolReader (this, fq_name); + + ProcessDebugHeader (); } - public void LoadSymbols (ISymbolReader reader) + public void ReadSymbols (ISymbolReader reader) { - m_controller.Reader.SymbolReader = reader; + if (reader == null) + throw new ArgumentNullException ("reader"); + + SymbolReader = reader; + + ProcessDebugHeader (); } - public void SaveSymbols () + public static ModuleDefinition ReadModule (string fileName) { - m_controller.Writer.SaveSymbols = true; + return ReadModule (fileName, new ReaderParameters (ReadingMode.Deferred)); } - public void SaveSymbols (ISymbolWriter writer) + public static ModuleDefinition ReadModule (Stream stream) { - SaveSymbols (); - m_controller.Writer.SymbolWriter = writer; + return ReadModule (stream, new ReaderParameters (ReadingMode.Deferred)); } - public void SaveSymbols (string outputDirectory) + public static ModuleDefinition ReadModule (string fileName, ReaderParameters parameters) { - SaveSymbols (); - m_controller.Writer.OutputFile = outputDirectory; + using (var stream = GetFileStream (fileName, FileMode.Open, FileAccess.Read, FileShare.Read)) { + return ReadModule (stream, parameters); + } } - public void SaveSymbols (string outputDirectory, ISymbolWriter writer) + static void CheckStream (object stream) { - SaveSymbols (outputDirectory); - m_controller.Writer.SymbolWriter = writer; + if (stream == null) + throw new ArgumentNullException ("stream"); } - public byte [] GetAsByteArray (CustomAttribute ca) + public static ModuleDefinition ReadModule (Stream stream, ReaderParameters parameters) { - CustomAttribute customAttr = ca; - if (!ca.Resolved) - if (customAttr.Blob != null) - return customAttr.Blob; - else - return new byte [0]; + CheckStream (stream); + if (!stream.CanRead || !stream.CanSeek) + throw new ArgumentException (); + Mixin.CheckParameters (parameters); - return m_controller.Writer.SignatureWriter.CompressCustomAttribute ( - ReflectionWriter.GetCustomAttributeSig (ca), ca.Constructor); + return ModuleReader.CreateModuleFrom ( + ImageReader.ReadImageFrom (stream), + parameters); } - public byte [] GetAsByteArray (SecurityDeclaration dec) + static Stream GetFileStream (string fileName, FileMode mode, FileAccess access, FileShare share) { - // TODO - add support for 2.0 format - // note: the 1.x format is still supported in 2.0 so this isn't an immediate problem - if (!dec.Resolved) - return dec.Blob; + if (fileName == null) + throw new ArgumentNullException ("fileName"); + if (fileName.Length == 0) + throw new ArgumentException (); -#if !CF_1_0 && !CF_2_0 - if (dec.PermissionSet != null) - return Encoding.Unicode.GetBytes (dec.PermissionSet.ToXml ().ToString ()); -#endif + return new FileStream (fileName, mode, access, share); + } + +#if !READ_ONLY - return new byte [0]; + public void Write (string fileName) + { + Write (fileName, new WriterParameters ()); } - public CustomAttribute FromByteArray (MethodReference ctor, byte [] data) + public void Write (Stream stream) { - return m_controller.Reader.GetCustomAttribute (ctor, data); + Write (stream, new WriterParameters ()); } - public SecurityDeclaration FromByteArray (SecurityAction action, byte [] declaration) + public void Write (string fileName, WriterParameters parameters) { - if (m_secReader == null) - m_secReader = new SecurityDeclarationReader (Image.MetadataRoot, m_controller.Reader); - return m_secReader.FromByteArray (action, declaration); + using (var stream = GetFileStream (fileName, FileMode.Create, FileAccess.ReadWrite, FileShare.None)) { + Write (stream, parameters); + } } - public override void Accept (IReflectionStructureVisitor visitor) + public void Write (Stream stream, WriterParameters parameters) { - visitor.VisitModuleDefinition (this); + CheckStream (stream); + if (!stream.CanWrite || !stream.CanSeek) + throw new ArgumentException (); + Mixin.CheckParameters (parameters); - this.AssemblyReferences.Accept (visitor); - this.ModuleReferences.Accept (visitor); - this.Resources.Accept (visitor); + ModuleWriter.WriteModuleTo (this, stream, parameters); } - public void Accept (IReflectionVisitor visitor) +#endif + + } + + static partial class Mixin { + + public static void CheckParameters (object parameters) { - visitor.VisitModuleDefinition (this); + if (parameters == null) + throw new ArgumentNullException ("parameters"); + } - this.Types.Accept (visitor); - this.TypeReferences.Accept (visitor); + public static bool HasImage (this ModuleDefinition self) + { + return self != null && self.HasImage; } - public override string ToString () + public static string GetFullyQualifiedName (this Stream self) { - string s = (m_main ? "(main), Mvid=" : "Mvid="); - return s + m_mvid; +#if !SILVERLIGHT + var file_stream = self as FileStream; + if (file_stream == null) + return string.Empty; + + return Path.GetFullPath (file_stream.Name); +#else + return string.Empty; +#endif + } + + public static TargetRuntime ParseRuntime (this string self) + { + switch (self [1]) { + case '1': + return self [3] == '0' + ? TargetRuntime.Net_1_0 + : TargetRuntime.Net_1_1; + case '2': + return TargetRuntime.Net_2_0; + case '4': + default: + return TargetRuntime.Net_4_0; + } } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleKind.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleKind.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleKind.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleKind.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,52 @@ +// +// ModuleKind.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; + +namespace Mono.Cecil { + + public enum ModuleKind { + Dll, + Console, + Windows, + NetModule, + } + + public enum TargetArchitecture { + I386, + AMD64, + IA64, + } + + [Flags] + public enum ModuleAttributes { + ILOnly = 1, + Required32Bit = 2, + StrongNameSigned = 8, + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleReferenceCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleReferenceCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleReferenceCollection.cs 2008-11-06 19:52:04.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleReferenceCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ -// -// ModuleReferenceCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Wed Sep 27 12:46:53 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.Collections; - - using Mono.Cecil.Cil; - - public sealed class ModuleReferenceCollection : CollectionBase, IReflectionStructureVisitable { - - ModuleDefinition m_container; - - public ModuleReference this [int index] { - get { return List [index] as ModuleReference; } - set { List [index] = value; } - } - - public ModuleDefinition Container { - get { return m_container; } - } - - public ModuleReferenceCollection (ModuleDefinition container) - { - m_container = container; - } - - public void Add (ModuleReference value) - { - List.Add (value); - } - - public bool Contains (ModuleReference value) - { - return List.Contains (value); - } - - public int IndexOf (ModuleReference value) - { - return List.IndexOf (value); - } - - public void Insert (int index, ModuleReference value) - { - List.Insert (index, value); - } - - public void Remove (ModuleReference value) - { - List.Remove (value); - } - - protected override void OnValidate (object o) - { - if (! (o is ModuleReference)) - throw new ArgumentException ("Must be of type " + typeof (ModuleReference).FullName); - } - - public void Accept (IReflectionStructureVisitor visitor) - { - visitor.VisitModuleReferenceCollection (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleReference.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleReference.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleReference.cs 2008-11-06 19:52:04.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleReference.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -28,44 +28,40 @@ namespace Mono.Cecil { - using System.Collections; + public class ModuleReference : IMetadataScope { - using Mono.Cecil; - using Mono.Cecil.Metadata; + string name; - public class ModuleReference : IMetadataScope, IAnnotationProvider, IReflectionStructureVisitable { - - string m_name; - MetadataToken m_token; - IDictionary m_annotations; + internal MetadataToken token; public string Name { - get { return m_name; } - set { m_name = value; } + get { return name; } + set { name = value; } + } + + public virtual MetadataScopeType MetadataScopeType { + get { return MetadataScopeType.ModuleReference; } } public MetadataToken MetadataToken { - get { return m_token; } - set { m_token = value; } + get { return token; } + set { token = value; } } - IDictionary IAnnotationProvider.Annotations { - get { - if (m_annotations == null) - m_annotations = new Hashtable (); - return m_annotations; - } + internal ModuleReference () + { + this.token = new MetadataToken (TokenType.ModuleRef); } public ModuleReference (string name) + : this () { - m_name = name; + this.name = name; } - public virtual void Accept (IReflectionStructureVisitor visitor) + public override string ToString () { - visitor.VisitModuleReference (this); + return name; } } } - diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/NativeType.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/NativeType.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/NativeType.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/NativeType.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -29,9 +29,9 @@ namespace Mono.Cecil { public enum NativeType { - NONE = 0x66, + None = 0x66, - BOOLEAN = 0x02, + Boolean = 0x02, I1 = 0x03, U1 = 0x04, I2 = 0x05, @@ -42,32 +42,32 @@ U8 = 0x0a, R4 = 0x0b, R8 = 0x0c, - LPSTR = 0x14, - INT = 0x1f, - UINT = 0x20, - FUNC = 0x26, - ARRAY = 0x2a, + LPStr = 0x14, + Int = 0x1f, + UInt = 0x20, + Func = 0x26, + Array = 0x2a, // Msft specific - CURRENCY = 0x0f, - BSTR = 0x13, - LPWSTR = 0x15, - LPTSTR = 0x16, - FIXEDSYSSTRING = 0x17, - IUNKNOWN = 0x19, - IDISPATCH = 0x1a, - STRUCT = 0x1b, - INTF = 0x1c, - SAFEARRAY = 0x1d, - FIXEDARRAY = 0x1e, - BYVALSTR = 0x22, - ANSIBSTR = 0x23, - TBSTR = 0x24, - VARIANTBOOL = 0x25, - ASANY = 0x28, - LPSTRUCT = 0x2b, - CUSTOMMARSHALER = 0x2c, - ERROR = 0x2d, - MAX = 0x50 + Currency = 0x0f, + BStr = 0x13, + LPWStr = 0x15, + LPTStr = 0x16, + FixedSysString = 0x17, + IUnknown = 0x19, + IDispatch = 0x1a, + Struct = 0x1b, + IntF = 0x1c, + SafeArray = 0x1d, + FixedArray = 0x1e, + ByValStr = 0x22, + ANSIBStr = 0x23, + TBStr = 0x24, + VariantBool = 0x25, + ASAny = 0x28, + LPStruct = 0x2b, + CustomMarshaler = 0x2c, + Error = 0x2d, + Max = 0x50 } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/NestedTypeCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/NestedTypeCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/NestedTypeCollection.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/NestedTypeCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,128 +0,0 @@ -// -// NestedTypeCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Fri Mar 30 18:43:57 +0200 2007 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.Collections; - - using Mono.Cecil.Cil; - - public sealed class NestedTypeCollection : CollectionBase, IReflectionVisitable { - - TypeDefinition m_container; - - public TypeDefinition this [int index] { - get { return List [index] as TypeDefinition; } - set { List [index] = value; } - } - - public TypeDefinition Container { - get { return m_container; } - } - - public NestedTypeCollection (TypeDefinition container) - { - m_container = container; - } - - public void Add (TypeDefinition value) - { - Attach (value); - - List.Add (value); - } - - - public new void Clear () - { - foreach (TypeDefinition item in this) - Detach (item); - - base.Clear (); - } - - public bool Contains (TypeDefinition value) - { - return List.Contains (value); - } - - public int IndexOf (TypeDefinition value) - { - return List.IndexOf (value); - } - - public void Insert (int index, TypeDefinition value) - { - Attach (value); - - List.Insert (index, value); - } - - public void Remove (TypeDefinition value) - { - List.Remove (value); - - Detach (value); - } - - - public new void RemoveAt (int index) - { - TypeDefinition item = this [index]; - Remove (item); - } - - protected override void OnValidate (object o) - { - if (! (o is TypeDefinition)) - throw new ArgumentException ("Must be of type " + typeof (TypeDefinition).FullName); - } - - void Attach (MemberReference member) - { - if (member.DeclaringType != null) - throw new ReflectionException ("Member already attached, clone it instead"); - - member.DeclaringType = m_container; - } - - void Detach (MemberReference member) - { - member.DeclaringType = null; - } - - public void Accept (IReflectionVisitor visitor) - { - visitor.VisitNestedTypeCollection (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/NullReferenceImporter.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/NullReferenceImporter.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/NullReferenceImporter.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/NullReferenceImporter.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -// -// NullReferenceImporter.cs -// -// Author: -// Jb Evain (jbevain@novell.com) -// -// (C) 2007 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - class NullReferenceImporter : IImporter { - - public static readonly NullReferenceImporter Instance = new NullReferenceImporter (); - - public TypeReference ImportTypeReference (TypeReference type, ImportContext context) - { - return type; - } - - public FieldReference ImportFieldReference (FieldReference field, ImportContext context) - { - return field; - } - - public MethodReference ImportMethodReference (MethodReference method, ImportContext context) - { - return method; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/OverrideCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/OverrideCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/OverrideCollection.cs 2008-11-06 19:52:04.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/OverrideCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ -// -// OverrideCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Wed Sep 27 12:46:53 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.Collections; - - using Mono.Cecil.Cil; - - public sealed class OverrideCollection : CollectionBase, IReflectionVisitable { - - MethodDefinition m_container; - - public MethodReference this [int index] { - get { return List [index] as MethodReference; } - set { List [index] = value; } - } - - public MethodDefinition Container { - get { return m_container; } - } - - public OverrideCollection (MethodDefinition container) - { - m_container = container; - } - - public void Add (MethodReference value) - { - List.Add (value); - } - - public bool Contains (MethodReference value) - { - return List.Contains (value); - } - - public int IndexOf (MethodReference value) - { - return List.IndexOf (value); - } - - public void Insert (int index, MethodReference value) - { - List.Insert (index, value); - } - - public void Remove (MethodReference value) - { - List.Remove (value); - } - - protected override void OnValidate (object o) - { - if (! (o is MethodReference)) - throw new ArgumentException ("Must be of type " + typeof (MethodReference).FullName); - } - - public void Accept (IReflectionVisitor visitor) - { - visitor.VisitOverrideCollection (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterAttributes.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterAttributes.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterAttributes.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterAttributes.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,15 +26,17 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { +using System; - using System; +namespace Mono.Cecil { [Flags] public enum ParameterAttributes : ushort { None = 0x0000, In = 0x0001, // Param is [In] Out = 0x0002, // Param is [Out] + Lcid = 0x0004, + Retval = 0x0008, Optional = 0x0010, // Param is optional HasDefault = 0x1000, // Param has default value HasFieldMarshal = 0x2000, // Param has field marshal diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterDefinitionCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterDefinitionCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterDefinitionCollection.cs 2008-11-06 19:52:04.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterDefinitionCollection.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,10 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// Generated by /CodeGen/cecil-gen.rb do not edit -// Wed Sep 27 12:46:52 CEST 2006 -// -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -29,65 +26,55 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { - - using System; - using System.Collections; +using System; - using Mono.Cecil.Cil; +using Mono.Collections.Generic; - public sealed class ParameterDefinitionCollection : CollectionBase, IReflectionVisitable { +namespace Mono.Cecil { - IMemberReference m_container; + sealed class ParameterDefinitionCollection : Collection { - public ParameterDefinition this [int index] { - get { return List [index] as ParameterDefinition; } - set { List [index] = value; } - } + readonly IMethodSignature method; - public IMemberReference Container { - get { return m_container; } - } - - public ParameterDefinitionCollection (IMemberReference container) + internal ParameterDefinitionCollection (IMethodSignature method) { - m_container = container; + this.method = method; } - public void Add (ParameterDefinition value) + internal ParameterDefinitionCollection (IMethodSignature method, int capacity) + : base (capacity) { - List.Add (value); + this.method = method; } - public bool Contains (ParameterDefinition value) + protected override void OnAdd (ParameterDefinition item, int index) { - return List.Contains (value); + item.method = method; + item.index = index; } - public int IndexOf (ParameterDefinition value) + protected override void OnInsert (ParameterDefinition item, int index) { - return List.IndexOf (value); - } + item.method = method; + item.index = index; - public void Insert (int index, ParameterDefinition value) - { - List.Insert (index, value); + for (int i = index; i < size; i++) + items [i].index = i + 1; } - public void Remove (ParameterDefinition value) + protected override void OnSet (ParameterDefinition item, int index) { - List.Remove (value); + item.method = method; + item.index = index; } - protected override void OnValidate (object o) + protected override void OnRemove (ParameterDefinition item, int index) { - if (! (o is ParameterDefinition)) - throw new ArgumentException ("Must be of type " + typeof (ParameterDefinition).FullName); - } + item.method = null; + item.index = -1; - public void Accept (IReflectionVisitor visitor) - { - visitor.VisitParameterDefinitionCollection (this); + for (int i = index + 1; i < size; i++) + items [i].index = i - 1; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterDefinition.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterDefinition.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterDefinition.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterDefinition.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 - 2007 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,150 +26,132 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { +using Mono.Collections.Generic; - public sealed class ParameterDefinition : ParameterReference, IHasMarshalSpec, - IMetadataTokenProvider, ICustomAttributeProvider, IHasConstant { +namespace Mono.Cecil { - ParameterAttributes m_attributes; + public sealed class ParameterDefinition : ParameterReference, ICustomAttributeProvider, IConstantProvider, IMarshalInfoProvider { - bool m_hasConstant; - object m_const; + ushort attributes; - MethodReference m_method; - CustomAttributeCollection m_customAttrs; + internal IMethodSignature method; - MarshalSpec m_marshalDesc; + object constant = Mixin.NotResolved; + Collection custom_attributes; + MarshalInfo marshal_info; public ParameterAttributes Attributes { - get { return m_attributes; } - set { m_attributes = value; } + get { return (ParameterAttributes) attributes; } + set { attributes = (ushort) value; } + } + + public IMethodSignature Method { + get { return method; } } public bool HasConstant { - get { return m_hasConstant; } + get { + ResolveConstant (); + + return constant != Mixin.NoValue; + } + set { if (!value) constant = Mixin.NoValue; } } public object Constant { - get { return m_const; } - set { - m_hasConstant = true; - m_const = value; - } + get { return HasConstant ? constant : null; } + set { constant = value; } } - public MethodReference Method { - get { return m_method; } - set { m_method = value; } + void ResolveConstant () + { + if (constant != Mixin.NotResolved) + return; + + this.ResolveConstant (ref constant, parameter_type.Module); } - public CustomAttributeCollection CustomAttributes { + public bool HasCustomAttributes { get { - if (m_customAttrs == null) - m_customAttrs = new CustomAttributeCollection (this); + if (custom_attributes != null) + return custom_attributes.Count > 0; - return m_customAttrs; + return this.GetHasCustomAttributes (parameter_type.Module); } } - public MarshalSpec MarshalSpec { - get { return m_marshalDesc; } - set { - m_marshalDesc = value; - if (value != null) - m_attributes |= ParameterAttributes.HasFieldMarshal; - else - m_attributes &= ~ParameterAttributes.HasFieldMarshal; + public Collection CustomAttributes { + get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (parameter_type.Module)); } + } + + public bool HasMarshalInfo { + get { + if (marshal_info != null) + return true; + + return this.GetHasMarshalInfo (parameter_type.Module); } } + public MarshalInfo MarshalInfo { + get { return marshal_info ?? (marshal_info = this.GetMarshalInfo (parameter_type.Module)); } + set { marshal_info = value; } + } + #region ParameterAttributes public bool IsIn { - get { return (m_attributes & ParameterAttributes.In) != 0; } - set { - if (value) - m_attributes |= ParameterAttributes.In; - else - m_attributes &= ~ParameterAttributes.In; - } + get { return attributes.GetAttributes ((ushort) ParameterAttributes.In); } + set { attributes = attributes.SetAttributes ((ushort) ParameterAttributes.In, value); } } public bool IsOut { - get { return (m_attributes & ParameterAttributes.Out) != 0; } - set { - if (value) - m_attributes |= ParameterAttributes.Out; - else - m_attributes &= ~ParameterAttributes.Out; - } + get { return attributes.GetAttributes ((ushort) ParameterAttributes.Out); } + set { attributes = attributes.SetAttributes ((ushort) ParameterAttributes.Out, value); } } - public bool IsOptional { - get { return (m_attributes & ParameterAttributes.Optional) != 0; } - set { - if (value) - m_attributes |= ParameterAttributes.Optional; - else - m_attributes &= ~ParameterAttributes.Optional; - } + public bool IsLcid { + get { return attributes.GetAttributes ((ushort) ParameterAttributes.Lcid); } + set { attributes = attributes.SetAttributes ((ushort) ParameterAttributes.Lcid, value); } } - public bool HasDefault { - get { return (m_attributes & ParameterAttributes.HasDefault) != 0; } - set { - if (value) - m_attributes |= ParameterAttributes.HasDefault; - else - m_attributes &= ~ParameterAttributes.HasDefault; - } + public bool IsReturnValue { + get { return attributes.GetAttributes ((ushort) ParameterAttributes.Retval); } + set { attributes = attributes.SetAttributes ((ushort) ParameterAttributes.Retval, value); } } - #endregion + public bool IsOptional { + get { return attributes.GetAttributes ((ushort) ParameterAttributes.Optional); } + set { attributes = attributes.SetAttributes ((ushort) ParameterAttributes.Optional, value); } + } - public ParameterDefinition (TypeReference paramType) : - this (string.Empty, -1, (ParameterAttributes) 0, paramType) - { + public bool HasDefault { + get { return attributes.GetAttributes ((ushort) ParameterAttributes.HasDefault); } + set { attributes = attributes.SetAttributes ((ushort) ParameterAttributes.HasDefault, value); } } - public ParameterDefinition (string name, int seq, ParameterAttributes attrs, TypeReference paramType) : base (name, seq, paramType) - { - m_attributes = attrs; + public bool HasFieldMarshal { + get { return attributes.GetAttributes ((ushort) ParameterAttributes.HasFieldMarshal); } + set { attributes = attributes.SetAttributes ((ushort) ParameterAttributes.HasFieldMarshal, value); } } - public ParameterDefinition Clone () + #endregion + + public ParameterDefinition (TypeReference parameterType) + : this (string.Empty, ParameterAttributes.None, parameterType) { - return Clone (this, new ImportContext (NullReferenceImporter.Instance, m_method)); } - internal static ParameterDefinition Clone (ParameterDefinition param, ImportContext context) + public ParameterDefinition (string name, ParameterAttributes attributes, TypeReference parameterType) + : base (name, parameterType) { - ParameterDefinition np = new ParameterDefinition ( - param.Name, - param.Sequence, - param.Attributes, - context.Import (param.ParameterType)); - - if (param.HasConstant) - np.Constant = param.Constant; - - if (param.MarshalSpec != null) - np.MarshalSpec = param.MarshalSpec; - - foreach (CustomAttribute ca in param.CustomAttributes) - np.CustomAttributes.Add (CustomAttribute.Clone (ca, context)); - - return np; + this.attributes = (ushort) attributes; + this.token = new MetadataToken (TokenType.Param); } - public override void Accept (IReflectionVisitor visitor) + public override ParameterDefinition Resolve () { - visitor.VisitParameterDefinition (this); - - if (this.MarshalSpec != null) - this.MarshalSpec.Accept (visitor); - - this.CustomAttributes.Accept (visitor); + return this; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterReference.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterReference.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterReference.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterReference.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,63 +26,50 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { - - using System.Collections; +using System; - using Mono.Cecil.Metadata; +namespace Mono.Cecil { - public abstract class ParameterReference : IMetadataTokenProvider, IAnnotationProvider, IReflectionVisitable { + public abstract class ParameterReference : IMetadataTokenProvider { - string m_name; - int m_sequence; - TypeReference m_paramType; - MetadataToken m_token; - IDictionary m_annotations; + string name; + internal int index = -1; + protected TypeReference parameter_type; + internal MetadataToken token; public string Name { - get { return m_name; } - set { m_name = value; } + get { return name; } + set { name = value; } } - public int Sequence { - get { return m_sequence; } - set { m_sequence = value; } + public int Index { + get { return index; } } public TypeReference ParameterType { - get { return m_paramType; } - set { m_paramType = value; } + get { return parameter_type; } + set { parameter_type = value; } } public MetadataToken MetadataToken { - get { return m_token; } - set { m_token = value; } + get { return token; } + set { token = value; } } - IDictionary IAnnotationProvider.Annotations { - get { - if (m_annotations == null) - m_annotations = new Hashtable (); - return m_annotations; - } - } - - public ParameterReference (string name, int sequence, TypeReference parameterType) + internal ParameterReference (string name, TypeReference parameterType) { - m_name = name; - m_sequence = sequence; - m_paramType = parameterType; + if (parameterType == null) + throw new ArgumentNullException ("parameterType"); + + this.name = name ?? string.Empty; + this.parameter_type = parameterType; } public override string ToString () { - if (m_name != null && m_name.Length > 0) - return m_name; - - return string.Concat ("A_", m_sequence); + return name; } - public abstract void Accept (IReflectionVisitor visitor); + public abstract ParameterDefinition Resolve (); } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PinnedType.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PinnedType.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PinnedType.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PinnedType.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,12 +26,28 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System; + +using MD = Mono.Cecil.Metadata; + namespace Mono.Cecil { public sealed class PinnedType : TypeSpecification { - public PinnedType (TypeReference pType) : base (pType) + public override bool IsValueType { + get { return false; } + set { throw new InvalidOperationException (); } + } + + public override bool IsPinned { + get { return true; } + } + + public PinnedType (TypeReference type) + : base (type) { + Mixin.CheckType (type); + this.etype = MD.ElementType.Pinned; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PInvokeAttributes.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PInvokeAttributes.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PInvokeAttributes.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PInvokeAttributes.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,9 +26,9 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { +using System; - using System; +namespace Mono.Cecil { [Flags] public enum PInvokeAttributes : ushort { @@ -40,6 +40,7 @@ CharSetAnsi = 0x0002, CharSetUnicode = 0x0004, CharSetAuto = 0x0006, + SupportsLastError = 0x0040, // Information about target function. Not relevant for fields // Calling convetion @@ -48,6 +49,14 @@ CallConvCdecl = 0x0200, CallConvStdCall = 0x0300, CallConvThiscall = 0x0400, - CallConvFastcall = 0x0500 + CallConvFastcall = 0x0500, + + BestFitMask = 0x0030, + BestFitEnabled = 0x0010, + BestFidDisabled = 0x0020, + + ThrowOnUnmappableCharMask = 0x3000, + ThrowOnUnmappableCharEnabled = 0x1000, + ThrowOnUnmappableCharDisabled = 0x2000, } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PInvokeInfo.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PInvokeInfo.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PInvokeInfo.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PInvokeInfo.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -28,173 +28,111 @@ namespace Mono.Cecil { - public sealed class PInvokeInfo : IReflectionVisitable { + public sealed class PInvokeInfo { - MethodDefinition m_meth; - - PInvokeAttributes m_attributes; - string m_entryPoint; - ModuleReference m_module; - - public MethodDefinition Method { - get { return m_meth; } - } + ushort attributes; + string entry_point; + ModuleReference module; public PInvokeAttributes Attributes { - get { return m_attributes; } - set { m_attributes = value; } + get { return (PInvokeAttributes) attributes; } + set { attributes = (ushort) value; } } public string EntryPoint { - get { return m_entryPoint; } - set { m_entryPoint = value; } + get { return entry_point; } + set { entry_point = value; } } public ModuleReference Module { - get { return m_module; } - set { m_module = value; } + get { return module; } + set { module = value; } } #region PInvokeAttributes public bool IsNoMangle { - get { return (m_attributes & PInvokeAttributes.NoMangle) != 0; } - set { - if (value) - m_attributes |= PInvokeAttributes.NoMangle; - else - m_attributes &= ~PInvokeAttributes.NoMangle; - } + get { return attributes.GetAttributes ((ushort) PInvokeAttributes.NoMangle); } + set { attributes = attributes.SetAttributes ((ushort) PInvokeAttributes.NoMangle, value); } } public bool IsCharSetNotSpec { - get { return (m_attributes & PInvokeAttributes.CharSetMask) == PInvokeAttributes.CharSetNotSpec; } - set { - if (value) { - m_attributes &= ~PInvokeAttributes.CharSetMask; - m_attributes |= PInvokeAttributes.CharSetNotSpec; - } else - m_attributes &= ~(PInvokeAttributes.CharSetMask & PInvokeAttributes.CharSetNotSpec); - } + get { return attributes.GetMaskedAttributes((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetNotSpec); } + set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetNotSpec, value); } } public bool IsCharSetAnsi { - get { return (m_attributes & PInvokeAttributes.CharSetMask) == PInvokeAttributes.CharSetAnsi; } - set { - if (value) { - m_attributes &= ~PInvokeAttributes.CharSetMask; - m_attributes |= PInvokeAttributes.CharSetAnsi; - } else - m_attributes &= ~(PInvokeAttributes.CharSetMask & PInvokeAttributes.CharSetAnsi); - } + get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetAnsi); } + set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetAnsi, value); } } public bool IsCharSetUnicode { - get { return (m_attributes & PInvokeAttributes.CharSetMask) == PInvokeAttributes.CharSetUnicode; } - set { - if (value) { - m_attributes &= ~PInvokeAttributes.CharSetMask; - m_attributes |= PInvokeAttributes.CharSetUnicode; - } else - m_attributes &= ~(PInvokeAttributes.CharSetMask & PInvokeAttributes.CharSetUnicode); - } + get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetUnicode); } + set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetUnicode, value); } } public bool IsCharSetAuto { - get { return (m_attributes & PInvokeAttributes.CharSetMask) == PInvokeAttributes.CharSetAuto; } - set { - if (value) { - m_attributes &= ~PInvokeAttributes.CharSetMask; - m_attributes |= PInvokeAttributes.CharSetAuto; - } else - m_attributes &= ~(PInvokeAttributes.CharSetMask & PInvokeAttributes.CharSetAuto); - } + get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetAuto); } + set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetAuto, value); } } public bool SupportsLastError { - get { return (m_attributes & PInvokeAttributes.CharSetMask) == PInvokeAttributes.SupportsLastError; } - set { - if (value) { - m_attributes &= ~PInvokeAttributes.CharSetMask; - m_attributes |= PInvokeAttributes.SupportsLastError; - } else - m_attributes &= ~(PInvokeAttributes.CharSetMask & PInvokeAttributes.SupportsLastError); - } + get { return attributes.GetAttributes ((ushort) PInvokeAttributes.SupportsLastError); } + set { attributes = attributes.SetAttributes ((ushort) PInvokeAttributes.SupportsLastError, value); } } public bool IsCallConvWinapi { - get { return (m_attributes & PInvokeAttributes.CallConvMask) == PInvokeAttributes.CallConvWinapi; } - set { - if (value) { - m_attributes &= ~PInvokeAttributes.CallConvMask; - m_attributes |= PInvokeAttributes.CallConvWinapi; - } else - m_attributes &= ~(PInvokeAttributes.CallConvMask & PInvokeAttributes.CallConvWinapi); - } + get { return attributes.GetMaskedAttributes((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvWinapi); } + set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvWinapi, value); } } public bool IsCallConvCdecl { - get { return (m_attributes & PInvokeAttributes.CallConvMask) == PInvokeAttributes.CallConvCdecl; } - set { - if (value) { - m_attributes &= ~PInvokeAttributes.CallConvMask; - m_attributes |= PInvokeAttributes.CallConvCdecl; - } else - m_attributes &= ~(PInvokeAttributes.CallConvMask & PInvokeAttributes.CallConvCdecl); - } + get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvCdecl); } + set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvCdecl, value); } } public bool IsCallConvStdCall { - get { return (m_attributes & PInvokeAttributes.CallConvMask) == PInvokeAttributes.CallConvStdCall; } - set { - if (value) { - m_attributes &= ~PInvokeAttributes.CallConvMask; - m_attributes |= PInvokeAttributes.CallConvStdCall; - } else - m_attributes &= ~(PInvokeAttributes.CallConvMask & PInvokeAttributes.CallConvStdCall); - } + get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvStdCall); } + set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvStdCall, value); } } public bool IsCallConvThiscall { - get { return (m_attributes & PInvokeAttributes.CallConvMask) == PInvokeAttributes.CallConvThiscall; } - set { - if (value) { - m_attributes &= ~PInvokeAttributes.CallConvMask; - m_attributes |= PInvokeAttributes.CallConvThiscall; - } else - m_attributes &= ~(PInvokeAttributes.CallConvMask & PInvokeAttributes.CallConvThiscall); - } + get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvThiscall); } + set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvThiscall, value); } } public bool IsCallConvFastcall { - get { return (m_attributes & PInvokeAttributes.CallConvMask) == PInvokeAttributes.CallConvFastcall; } - set { - if (value) { - m_attributes &= ~PInvokeAttributes.CallConvMask; - m_attributes |= PInvokeAttributes.CallConvFastcall; - } else - m_attributes &= ~(PInvokeAttributes.CallConvMask & PInvokeAttributes.CallConvFastcall); - } + get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvFastcall); } + set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvFastcall, value); } } - #endregion + public bool IsBestFistEnabled { + get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.BestFitMask, (ushort) PInvokeAttributes.BestFitEnabled); } + set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.BestFitMask, (ushort) PInvokeAttributes.BestFitEnabled, value); } + } - public PInvokeInfo (MethodDefinition meth) - { - m_meth = meth; + public bool IsBestFistDisabled { + get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.BestFitMask, (ushort) PInvokeAttributes.BestFidDisabled); } + set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.BestFitMask, (ushort) PInvokeAttributes.BestFidDisabled, value); } } - public PInvokeInfo (MethodDefinition meth, PInvokeAttributes attrs, - string entryPoint, ModuleReference mod) : this (meth) - { - m_attributes = attrs; - m_entryPoint = entryPoint; - m_module = mod; + public bool IsThrowOnUnmappableCharEnabled { + get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.ThrowOnUnmappableCharMask, (ushort) PInvokeAttributes.ThrowOnUnmappableCharEnabled); } + set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.ThrowOnUnmappableCharMask, (ushort) PInvokeAttributes.ThrowOnUnmappableCharEnabled, value); } + } + + public bool IsThrowOnUnmappableCharDisabled { + get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.ThrowOnUnmappableCharMask, (ushort) PInvokeAttributes.ThrowOnUnmappableCharDisabled); } + set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.ThrowOnUnmappableCharMask, (ushort) PInvokeAttributes.ThrowOnUnmappableCharDisabled, value); } } - public void Accept (IReflectionVisitor visitor) + #endregion + + public PInvokeInfo (PInvokeAttributes attributes, string entryPoint, ModuleReference module) { - visitor.VisitPInvokeInfo (this); + this.attributes = (ushort) attributes; + this.entry_point = entryPoint; + this.module = module; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PointerType.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PointerType.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PointerType.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PointerType.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,20 +26,36 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System; + +using MD = Mono.Cecil.Metadata; + namespace Mono.Cecil { public sealed class PointerType : TypeSpecification { public override string Name { - get { return string.Concat (base.Name, "*"); } + get { return base.Name + "*"; } } public override string FullName { - get { return string.Concat (base.FullName, "*"); } + get { return base.FullName + "*"; } + } + + public override bool IsValueType { + get { return false; } + set { throw new InvalidOperationException (); } + } + + public override bool IsPointer { + get { return true; } } - public PointerType (TypeReference pType) : base (pType) + public PointerType (TypeReference type) + : base (type) { + Mixin.CheckType (type); + this.etype = MD.ElementType.Ptr; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyAttributes.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyAttributes.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyAttributes.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyAttributes.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,12 +26,13 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { +using System; - using System; +namespace Mono.Cecil { [Flags] public enum PropertyAttributes : ushort { + None = 0x0000, SpecialName = 0x0200, // Property is special RTSpecialName = 0x0400, // Runtime(metadata internal APIs) should check name encoding HasDefault = 0x1000, // Property has default diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyDefinitionCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyDefinitionCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyDefinitionCollection.cs 2008-11-06 19:52:04.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyDefinitionCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,138 +0,0 @@ -// -// PropertyDefinitionCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Fri Mar 30 18:43:57 +0200 2007 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.Collections; - - using Mono.Cecil.Cil; - - public sealed class PropertyDefinitionCollection : CollectionBase, IReflectionVisitable { - - TypeDefinition m_container; - - public PropertyDefinition this [int index] { - get { return List [index] as PropertyDefinition; } - set { List [index] = value; } - } - - public TypeDefinition Container { - get { return m_container; } - } - - public PropertyDefinitionCollection (TypeDefinition container) - { - m_container = container; - } - - public void Add (PropertyDefinition value) - { - Attach (value); - - List.Add (value); - } - - - public new void Clear () - { - foreach (PropertyDefinition item in this) - Detach (item); - - base.Clear (); - } - - public bool Contains (PropertyDefinition value) - { - return List.Contains (value); - } - - public int IndexOf (PropertyDefinition value) - { - return List.IndexOf (value); - } - - public void Insert (int index, PropertyDefinition value) - { - Attach (value); - - List.Insert (index, value); - } - - public void Remove (PropertyDefinition value) - { - List.Remove (value); - - Detach (value); - } - - - public new void RemoveAt (int index) - { - PropertyDefinition item = this [index]; - Remove (item); - } - - protected override void OnValidate (object o) - { - if (! (o is PropertyDefinition)) - throw new ArgumentException ("Must be of type " + typeof (PropertyDefinition).FullName); - } - - public PropertyDefinition [] GetProperties (string name) - { - ArrayList ret = new ArrayList (); - foreach (PropertyDefinition prop in this) - if (prop.Name == name) - ret.Add (prop); - - return ret.ToArray (typeof (PropertyDefinition)) as PropertyDefinition []; - } - - void Attach (MemberReference member) - { - if (member.DeclaringType != null) - throw new ReflectionException ("Member already attached, clone it instead"); - - member.DeclaringType = m_container; - } - - void Detach (MemberReference member) - { - member.DeclaringType = null; - } - - public void Accept (IReflectionVisitor visitor) - { - visitor.VisitPropertyDefinitionCollection (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyDefinition.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyDefinition.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyDefinition.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyDefinition.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,200 +26,233 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { +using System.Text; + +using Mono.Collections.Generic; - using System; - using System.Text; +namespace Mono.Cecil { - public sealed class PropertyDefinition : PropertyReference, - IMemberDefinition, ICustomAttributeProvider, IHasConstant { + public sealed class PropertyDefinition : PropertyReference, IMemberDefinition, IConstantProvider { - PropertyAttributes m_attributes; + bool? has_this; + ushort attributes; - CustomAttributeCollection m_customAttrs; + Collection custom_attributes; - MethodDefinition m_getMeth; - MethodDefinition m_setMeth; + internal MethodDefinition get_method; + internal MethodDefinition set_method; + internal Collection other_methods; - bool m_hasConstant; - object m_const; + object constant = Mixin.NotResolved; public PropertyAttributes Attributes { - get { return m_attributes; } - set { m_attributes = value; } + get { return (PropertyAttributes) attributes; } + set { attributes = (ushort) value; } } - public CustomAttributeCollection CustomAttributes { + public bool HasThis { get { - if (m_customAttrs == null) - m_customAttrs = new CustomAttributeCollection (this); + if (has_this.HasValue) + return has_this.Value; + + if (GetMethod != null) + return get_method.HasThis; + + if (SetMethod != null) + return set_method.HasThis; - return m_customAttrs; + return false; } + set { has_this = value; } } - public override ParameterDefinitionCollection Parameters { + public bool HasCustomAttributes { get { - if (this.GetMethod != null) - return CloneParameterCollection (this.GetMethod.Parameters); - else if (this.SetMethod != null) { - ParameterDefinitionCollection parameters = - CloneParameterCollection (this.SetMethod.Parameters); - if (parameters.Count > 0) - parameters.RemoveAt (parameters.Count - 1); - return parameters; - } - - if (m_parameters == null) - m_parameters = new ParameterDefinitionCollection (this); + if (custom_attributes != null) + return custom_attributes.Count > 0; - return m_parameters; + return this.GetHasCustomAttributes (Module); } } + public Collection CustomAttributes { + get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (Module)); } + } + public MethodDefinition GetMethod { - get { return m_getMeth; } - set { m_getMeth = value; } + get { + if (get_method != null) + return get_method; + + InitializeMethods (); + return get_method; + } + set { get_method = value; } } public MethodDefinition SetMethod { - get { return m_setMeth; } - set { m_setMeth = value; } - } + get { + if (set_method != null) + return set_method; - ParameterDefinitionCollection CloneParameterCollection (ParameterDefinitionCollection original) - { - ParameterDefinitionCollection clone = new ParameterDefinitionCollection ( - original.Container); - foreach (ParameterDefinition param in original) - clone.Add (param); - return clone; + InitializeMethods (); + return set_method; + } + set { set_method = value; } } - public bool HasConstant { - get { return m_hasConstant; } - } + public bool HasOtherMethods { + get { + if (other_methods != null) + return other_methods.Count > 0; - public object Constant { - get { return m_const; } - set { - m_hasConstant = true; - m_const = value; + InitializeMethods (); + return !other_methods.IsNullOrEmpty (); } } - #region PropertyAttributes + public Collection OtherMethods { + get { + if (other_methods != null) + return other_methods; - public bool IsSpecialName { - get { return (m_attributes & PropertyAttributes.SpecialName) != 0; } - set { - if (value) - m_attributes |= PropertyAttributes.SpecialName; - else - m_attributes &= ~PropertyAttributes.SpecialName; + InitializeMethods (); + + if (other_methods != null) + return other_methods; + + return other_methods = new Collection (); } } - public bool IsRuntimeSpecialName { - get { return (m_attributes & PropertyAttributes.RTSpecialName) != 0; } - set { - if (value) - m_attributes |= PropertyAttributes.RTSpecialName; - else - m_attributes &= ~PropertyAttributes.RTSpecialName; + public bool HasParameters { + get { + if (get_method != null) + return get_method.HasParameters; + + if (set_method != null) + return set_method.HasParameters && set_method.Parameters.Count > 1; + + return false; } } - public bool HasDefault { - get { return (m_attributes & PropertyAttributes.HasDefault) != 0; } - set { - if (value) - m_attributes |= PropertyAttributes.HasDefault; - else - m_attributes &= ~PropertyAttributes.HasDefault; + public override Collection Parameters { + get { + InitializeMethods (); + + if (get_method != null) + return MirrorParameters (get_method, 0); + + if (set_method != null) + return MirrorParameters (set_method, 1); + + return new Collection (); } } - #endregion - - public PropertyDefinition (string name, TypeReference propertyType, PropertyAttributes attrs) : base (name, propertyType) + static Collection MirrorParameters (MethodDefinition method, int bound) { - m_attributes = attrs; + var parameters = new Collection (); + if (!method.HasParameters) + return parameters; + + var original_parameters = method.Parameters; + var end = original_parameters.Count - bound; + + for (int i = 0; i < end; i++) + parameters.Add (original_parameters [i]); + + return parameters; } - public static MethodDefinition CreateGetMethod (PropertyDefinition prop) - { - MethodDefinition get = new MethodDefinition ( - string.Concat ("get_", prop.Name), (MethodAttributes) 0, prop.PropertyType); - prop.GetMethod = get; - return get; + public bool HasConstant { + get { + ResolveConstant (); + + return constant != Mixin.NoValue; + } + set { if (!value) constant = Mixin.NoValue; } } - public static MethodDefinition CreateSetMethod (PropertyDefinition prop) - { - MethodDefinition set = new MethodDefinition ( - string.Concat ("set_", prop.Name), (MethodAttributes) 0, prop.PropertyType); - prop.SetMethod = set; - return set; + public object Constant { + get { return HasConstant ? constant : null; } + set { constant = value; } } - public PropertyDefinition Clone () + void ResolveConstant () { - return Clone (this, new ImportContext (NullReferenceImporter.Instance, this.DeclaringType)); + if (constant != Mixin.NotResolved) + return; + + this.ResolveConstant (ref constant, Module); } - internal static PropertyDefinition Clone (PropertyDefinition prop, ImportContext context) - { - PropertyDefinition np = new PropertyDefinition ( - prop.Name, - context.Import (prop.PropertyType), - prop.Attributes); + #region PropertyAttributes - if (prop.HasConstant) - np.Constant = prop.Constant; + public bool IsSpecialName { + get { return attributes.GetAttributes ((ushort) PropertyAttributes.SpecialName); } + set { attributes = attributes.SetAttributes ((ushort) PropertyAttributes.SpecialName, value); } + } - if (context.GenericContext.Type is TypeDefinition) { - TypeDefinition type = context.GenericContext.Type as TypeDefinition; - if (prop.SetMethod != null) - np.SetMethod = type.Methods.GetMethod (prop.SetMethod.Name, prop.SetMethod.Parameters); - if (prop.GetMethod != null) - np.GetMethod = type.Methods.GetMethod (prop.GetMethod.Name, prop.GetMethod.Parameters); - } + public bool IsRuntimeSpecialName { + get { return attributes.GetAttributes ((ushort) PropertyAttributes.RTSpecialName); } + set { attributes = attributes.SetAttributes ((ushort) PropertyAttributes.RTSpecialName, value); } + } - foreach (CustomAttribute ca in prop.CustomAttributes) - np.CustomAttributes.Add (CustomAttribute.Clone (ca, context)); + public bool HasDefault { + get { return attributes.GetAttributes ((ushort) PropertyAttributes.HasDefault); } + set { attributes = attributes.SetAttributes ((ushort) PropertyAttributes.HasDefault, value); } + } + + #endregion - return np; + public new TypeDefinition DeclaringType { + get { return (TypeDefinition) base.DeclaringType; } + set { base.DeclaringType = value; } } - public override string ToString () - { - StringBuilder sb = new StringBuilder (); - sb.Append (PropertyType.ToString ()); - sb.Append (' '); + public override bool IsDefinition { + get { return true; } + } - if (this.DeclaringType != null) { - sb.Append (this.DeclaringType.ToString ()); - sb.Append ("::"); + public override string FullName { + get { + var builder = new StringBuilder (); + builder.Append (PropertyType.ToString ()); + builder.Append (' '); + builder.Append (MemberFullName ()); + builder.Append ('('); + if (HasParameters) { + var parameters = Parameters; + for (int i = 0; i < parameters.Count; i++) { + if (i > 0) + builder.Append (','); + builder.Append (parameters [i].ParameterType.FullName); + } + } + builder.Append (')'); + return builder.ToString (); } + } - sb.Append (this.Name); - sb.Append ('('); - ParameterDefinitionCollection parameters = this.Parameters; - for (int i = 0; i < parameters.Count; i++) { - if (i > 0) - sb.Append (','); - sb.Append (parameters [i].ParameterType.ToString ()); - } - sb.Append (')'); - return sb.ToString (); + public PropertyDefinition (string name, PropertyAttributes attributes, TypeReference propertyType) + : base (name, propertyType) + { + this.attributes = (ushort) attributes; + this.token = new MetadataToken (TokenType.Property); } - public override void Accept (IReflectionVisitor visitor) + void InitializeMethods () { - visitor.VisitPropertyDefinition (this); + if (get_method != null || set_method != null) + return; + + var module = this.Module; + if (!module.HasImage ()) + return; - this.CustomAttributes.Accept (visitor); + module.Read (this, (property, reader) => reader.ReadMethods (property)); } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyReference.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyReference.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyReference.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyReference.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,25 +26,32 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System; + +using Mono.Collections.Generic; + namespace Mono.Cecil { public abstract class PropertyReference : MemberReference { - TypeReference m_propertyType; - protected ParameterDefinitionCollection m_parameters; + TypeReference property_type; public TypeReference PropertyType { - get { return m_propertyType; } - set { m_propertyType = value; } + get { return property_type; } + set { property_type = value; } } - public abstract ParameterDefinitionCollection Parameters { + public abstract Collection Parameters { get; } - public PropertyReference (string name, TypeReference propertyType) : base (name) + internal PropertyReference (string name, TypeReference propertyType) + : base (name) { - m_propertyType = propertyType; + if (propertyType == null) + throw new ArgumentNullException ("propertyType"); + + property_type = propertyType; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReferenceType.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReferenceType.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReferenceType.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReferenceType.cs 2011-04-13 09:00:29.000000000 +0000 @@ -1,10 +1,10 @@ // -// ReferenceType.cs +// ByReferenceType.cs // // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,20 +26,36 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System; + +using MD = Mono.Cecil.Metadata; + namespace Mono.Cecil { - public sealed class ReferenceType : TypeSpecification { + public sealed class ByReferenceType : TypeSpecification { public override string Name { - get { return string.Concat (base.Name, "&"); } + get { return base.Name + "&"; } } public override string FullName { - get { return string.Concat (base.FullName, "&"); } + get { return base.FullName + "&"; } + } + + public override bool IsValueType { + get { return false; } + set { throw new InvalidOperationException (); } + } + + public override bool IsByReference { + get { return true; } } - public ReferenceType (TypeReference type) : base (type) + public ByReferenceType (TypeReference type) + : base (type) { + Mixin.CheckType (type); + this.etype = MD.ElementType.ByRef; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionController.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionController.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionController.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionController.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -// -// ReflectionController.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - internal sealed class ReflectionController { - - ReflectionReader m_reader; - ReflectionWriter m_writer; - ReflectionHelper m_helper; - DefaultImporter m_importer; - - public ReflectionReader Reader { - get { return m_reader; } - } - - public ReflectionWriter Writer { - get { return m_writer; } - } - - public ReflectionHelper Helper { - get { return m_helper; } - } - - public IImporter Importer { - get { return m_importer; } - } - - public ReflectionController (ModuleDefinition module) - { - m_reader = new AggressiveReflectionReader (module); - m_writer = new ReflectionWriter (module); - m_helper = new ReflectionHelper (module); - m_importer = new DefaultImporter (module); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionException.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionException.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionException.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionException.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -// -// ReflectionException.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - - using Mono.Cecil.Metadata; - - public sealed class ReflectionException : MetadataFormatException { - - internal ReflectionException () : base () - { - } - - internal ReflectionException (string message) : base (message) - { - } - - internal ReflectionException (string message, params string [] parameters) : - base (string.Format (message, parameters)) - { - } - - internal ReflectionException (string message, Exception inner) : - base (message, inner) - { - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionHelper.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionHelper.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionHelper.cs 2008-11-06 19:52:04.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionHelper.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,395 +0,0 @@ -// -// ReflectionHelper.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// (C) 2006 Evaluant RC S.A. -// (C) 2007 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.Collections; - using SR = System.Reflection; - using System.Text; - - internal sealed class ReflectionHelper { - - ModuleDefinition m_module; - - public ReflectionHelper (ModuleDefinition module) - { - m_module = module; - } - - public AssemblyNameReference ImportAssembly (SR.Assembly asm) - { - AssemblyNameReference asmRef = GetAssemblyNameReference (asm.GetName ()); - if (asmRef != null) - return asmRef; - - SR.AssemblyName asmName = asm.GetName (); - asmRef = new AssemblyNameReference ( - asmName.Name, asmName.CultureInfo.Name, asmName.Version); - asmRef.PublicKeyToken = asmName.GetPublicKeyToken (); - asmRef.HashAlgorithm = (AssemblyHashAlgorithm) asmName.HashAlgorithm; - asmRef.Culture = asmName.CultureInfo.ToString (); - m_module.AssemblyReferences.Add (asmRef); - return asmRef; - } - - AssemblyNameReference GetAssemblyNameReference (SR.AssemblyName name) - { - foreach (AssemblyNameReference reference in m_module.AssemblyReferences) - if (reference.FullName == name.FullName) - return reference; - - return null; - } - - public static string GetTypeSignature (Type t) - { - if (t.HasElementType) { - if (t.IsPointer) - return string.Concat (GetTypeSignature (t.GetElementType ()), "*"); - else if (t.IsArray) // deal with complex arrays - return string.Concat (GetTypeSignature (t.GetElementType ()), "[]"); - else if (t.IsByRef) - return string.Concat (GetTypeSignature (t.GetElementType ()), "&"); - } - - if (IsGenericTypeSpec (t)) { - StringBuilder sb = new StringBuilder (); - sb.Append (GetTypeSignature (GetGenericTypeDefinition (t))); - sb.Append ("<"); - Type [] genArgs = GetGenericArguments (t); - for (int i = 0; i < genArgs.Length; i++) { - if (i > 0) - sb.Append (","); - sb.Append (GetTypeSignature (genArgs [i])); - } - sb.Append (">"); - return sb.ToString (); - } - - if (IsGenericParameter (t)) - return t.Name; - - if (t.DeclaringType != null) - return string.Concat (t.DeclaringType.FullName, "/", t.Name); - - if (t.Namespace == null || t.Namespace.Length == 0) - return t.Name; - - return string.Concat (t.Namespace, ".", t.Name); - } - - static bool GetProperty (object o, string prop) - { - SR.PropertyInfo pi = o.GetType ().GetProperty (prop); - if (pi == null) - return false; - - return (bool) pi.GetValue (o, null); - } - - public static bool IsGenericType (Type t) - { - return GetProperty (t, "IsGenericType"); - } - - static bool IsGenericParameter (Type t) - { - return GetProperty (t, "IsGenericParameter"); - } - - static bool IsGenericTypeDefinition (Type t) - { - return GetProperty (t, "IsGenericTypeDefinition"); - } - - static bool IsGenericTypeSpec (Type t) - { - return IsGenericType (t) && !IsGenericTypeDefinition (t); - } - - static Type GetGenericTypeDefinition (Type t) - { - return (Type) t.GetType ().GetMethod ("GetGenericTypeDefinition").Invoke (t, null); - } - - static Type [] GetGenericArguments (Type t) - { - return (Type []) t.GetType ().GetMethod ("GetGenericArguments").Invoke (t, null); - } - - GenericInstanceType GetGenericType (Type t, TypeReference element, ImportContext context) - { - GenericInstanceType git = new GenericInstanceType (element); - foreach (Type genArg in GetGenericArguments (t)) - git.GenericArguments.Add (ImportSystemType (genArg, context)); - - return git; - } - - static bool GenericParameterOfMethod (Type t) - { - return t.GetType ().GetProperty ("DeclaringMethod").GetValue (t, null) != null; - } - - static GenericParameter GetGenericParameter (Type t, ImportContext context) - { - int pos = (int) t.GetType ().GetProperty ("GenericParameterPosition").GetValue (t, null); - if (GenericParameterOfMethod (t)) - return context.GenericContext.Method.GenericParameters [pos]; - else - return context.GenericContext.Type.GenericParameters [pos]; - } - - TypeReference GetTypeSpec (Type t, ImportContext context) - { - Stack s = new Stack (); - while (t.HasElementType || IsGenericTypeSpec (t)) { - s.Push (t); - if (t.HasElementType) - t = t.GetElementType (); - else if (IsGenericTypeSpec (t)) { - t = (Type) t.GetType ().GetMethod ("GetGenericTypeDefinition").Invoke (t, null); - break; - } - } - - TypeReference elementType = ImportSystemType (t, context); - while (s.Count > 0) { - t = (Type) s.Pop (); - if (t.IsPointer) - elementType = new PointerType (elementType); - else if (t.IsArray) // deal with complex arrays - elementType = new ArrayType (elementType); - else if (t.IsByRef) - elementType = new ReferenceType (elementType); - else if (IsGenericTypeSpec (t)) - elementType = GetGenericType (t, elementType, context); - else - throw new ReflectionException ("Unknown element type"); - } - - return elementType; - } - - public TypeReference ImportSystemType (Type t, ImportContext context) - { - if (t.HasElementType || IsGenericTypeSpec (t)) - return GetTypeSpec (t, context); - - if (IsGenericParameter (t)) - return GetGenericParameter (t, context); - - TypeReference type = m_module.TypeReferences [GetTypeSignature (t)]; - if (type != null) { - if (t.IsValueType && !type.IsValueType) - type.IsValueType = true; - - return type; - } - - AssemblyNameReference asm = ImportAssembly (t.Assembly); - type = new TypeReference (t.Name, t.Namespace, asm, t.IsValueType); - - if (IsGenericTypeDefinition (t)) - foreach (Type genParam in GetGenericArguments (t)) - type.GenericParameters.Add (new GenericParameter (genParam.Name, type)); - - context.GenericContext.Type = type; - - m_module.TypeReferences.Add (type); - return type; - } - - static string GetMethodBaseSignature (SR.MethodBase meth, Type declaringType, Type retType) - { - StringBuilder sb = new StringBuilder (); - sb.Append (GetTypeSignature (retType)); - sb.Append (' '); - sb.Append (GetTypeSignature (declaringType)); - sb.Append ("::"); - sb.Append (meth.Name); - if (IsGenericMethodSpec (meth)) { - sb.Append ("<"); - Type [] genArgs = GetGenericArguments (meth as SR.MethodInfo); - for (int i = 0; i < genArgs.Length; i++) { - if (i > 0) - sb.Append (","); - sb.Append (GetTypeSignature (genArgs [i])); - } - sb.Append (">"); - } - sb.Append ("("); - SR.ParameterInfo [] parameters = meth.GetParameters (); - for (int i = 0; i < parameters.Length; i++) { - if (i > 0) - sb.Append (", "); - sb.Append (GetTypeSignature (parameters [i].ParameterType)); - } - sb.Append (")"); - return sb.ToString (); - } - - static bool IsGenericMethod (SR.MethodBase mb) - { - return GetProperty (mb, "IsGenericMethod"); - } - - static bool IsGenericMethodDefinition (SR.MethodBase mb) - { - return GetProperty (mb, "IsGenericMethodDefinition"); - } - - static bool IsGenericMethodSpec (SR.MethodBase mb) - { - return IsGenericMethod (mb) && !IsGenericMethodDefinition (mb); - } - - static Type [] GetGenericArguments (SR.MethodInfo mi) - { - return (Type []) mi.GetType ().GetMethod ("GetGenericArguments").Invoke (mi, null); - } - - static int GetMetadataToken (SR.MethodInfo mi) - { - return (int) mi.GetType ().GetProperty ("MetadataToken").GetValue (mi, null); - } - - MethodReference ImportGenericInstanceMethod (SR.MethodInfo mi, ImportContext context) - { - SR.MethodInfo gmd = (SR.MethodInfo) mi.GetType ().GetMethod ("GetGenericMethodDefinition").Invoke (mi, null); - GenericInstanceMethod gim = new GenericInstanceMethod ( - ImportMethodBase (gmd, gmd.ReturnType, context)); - - foreach (Type genArg in GetGenericArguments (mi)) - gim.GenericArguments.Add (ImportSystemType (genArg, context)); - - return gim; - } - - MethodReference ImportMethodBase (SR.MethodBase mb, Type retType, ImportContext context) - { - if (IsGenericMethod (mb) && !IsGenericMethodDefinition (mb)) - return ImportGenericInstanceMethod ((SR.MethodInfo) mb, context); - - Type originalDecType = mb.DeclaringType; - Type declaringTypeDef = originalDecType; - while (IsGenericTypeSpec (declaringTypeDef)) - declaringTypeDef = GetGenericTypeDefinition (declaringTypeDef); - - if (mb.DeclaringType != declaringTypeDef && mb is SR.MethodInfo) { - int mt = GetMetadataToken (mb as SR.MethodInfo); - // hack to get the generic method definition from the constructed method - foreach (SR.MethodInfo mi in declaringTypeDef.GetMethods ()) { - if (GetMetadataToken (mi) == mt) { - mb = mi; - retType = mi.ReturnType; - break; - } - } - } - - string sig = GetMethodBaseSignature (mb, originalDecType, retType); - MethodReference meth = (MethodReference) GetMemberReference (sig); - if (meth != null) - return meth; - - meth = new MethodReference ( - mb.Name, - (mb.CallingConvention & SR.CallingConventions.HasThis) > 0, - (mb.CallingConvention & SR.CallingConventions.ExplicitThis) > 0, - MethodCallingConvention.Default); // TODO: get the real callconv - meth.DeclaringType = ImportSystemType (originalDecType, context); - - if (IsGenericMethod (mb)) - foreach (Type genParam in GetGenericArguments (mb as SR.MethodInfo)) - meth.GenericParameters.Add (new GenericParameter (genParam.Name, meth)); - - context.GenericContext.Method = meth; - context.GenericContext.Type = ImportSystemType (declaringTypeDef, context); - - meth.ReturnType.ReturnType = ImportSystemType (retType, context); - - SR.ParameterInfo [] parameters = mb.GetParameters (); - for (int i = 0; i < parameters.Length; i++) - meth.Parameters.Add (new ParameterDefinition ( - ImportSystemType (parameters [i].ParameterType, context))); - - m_module.MemberReferences.Add (meth); - return meth; - } - - public MethodReference ImportConstructorInfo (SR.ConstructorInfo ci, ImportContext context) - { - return ImportMethodBase (ci, typeof (void), context); - } - - public MethodReference ImportMethodInfo (SR.MethodInfo mi, ImportContext context) - { - return ImportMethodBase (mi, mi.ReturnType, context); - } - - static string GetFieldSignature (SR.FieldInfo field) - { - StringBuilder sb = new StringBuilder (); - sb.Append (GetTypeSignature (field.FieldType)); - sb.Append (' '); - sb.Append (GetTypeSignature (field.DeclaringType)); - sb.Append ("::"); - sb.Append (field.Name); - return sb.ToString (); - } - - public FieldReference ImportFieldInfo (SR.FieldInfo fi, ImportContext context) - { - string sig = GetFieldSignature (fi); - FieldReference f = (FieldReference) GetMemberReference (sig); - if (f != null) - return f; - - f = new FieldReference ( - fi.Name, - ImportSystemType (fi.DeclaringType, context), - ImportSystemType (fi.FieldType, context)); - - m_module.MemberReferences.Add (f); - return f; - } - - MemberReference GetMemberReference (string signature) - { - foreach (MemberReference reference in m_module.MemberReferences) - if (reference.ToString () == signature) - return reference; - - return null; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionReader.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionReader.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionReader.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionReader.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,1179 +0,0 @@ -// -// ReflectionReader.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 - 2007 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.IO; - using System.Text; - - using Mono.Cecil.Binary; - using Mono.Cecil.Cil; - using Mono.Cecil.Metadata; - using Mono.Cecil.Signatures; - - internal abstract class ReflectionReader : BaseReflectionReader { - - ModuleDefinition m_module; - ImageReader m_reader; - SecurityDeclarationReader m_secReader; - protected MetadataTableReader m_tableReader; - protected MetadataRoot m_root; - protected TablesHeap m_tHeap; - protected bool m_checkDeleted; - - protected TypeDefinition [] m_typeDefs; - protected TypeReference [] m_typeRefs; - protected TypeReference [] m_typeSpecs; - protected MethodDefinition [] m_meths; - protected FieldDefinition [] m_fields; - protected EventDefinition [] m_events; - protected PropertyDefinition [] m_properties; - protected MemberReference [] m_memberRefs; - protected ParameterDefinition [] m_parameters; - protected GenericParameter [] m_genericParameters; - protected GenericInstanceMethod [] m_methodSpecs; - - bool m_isCorlib; - AssemblyNameReference m_corlib; - - protected SignatureReader m_sigReader; - protected CodeReader m_codeReader; - protected ISymbolReader m_symbolReader; - - internal AssemblyNameReference Corlib { - get { - if (m_corlib != null) - return m_corlib; - - foreach (AssemblyNameReference ar in m_module.AssemblyReferences) { - if (ar.Name == Constants.Corlib) { - m_corlib = ar; - return m_corlib; - } - } - - return null; - } - } - - public ModuleDefinition Module { - get { return m_module; } - } - - public SignatureReader SigReader { - get { return m_sigReader; } - } - - public MetadataTableReader TableReader { - get { return m_tableReader; } - } - - public CodeReader Code { - get { return m_codeReader; } - } - - public ISymbolReader SymbolReader { - get { return m_symbolReader; } - set { m_symbolReader = value; } - } - - public MetadataRoot MetadataRoot { - get { return m_root; } - } - - public ReflectionReader (ModuleDefinition module) - { - m_module = module; - m_reader = m_module.ImageReader; - m_root = m_module.Image.MetadataRoot; - m_tHeap = m_root.Streams.TablesHeap; - m_checkDeleted = (m_tHeap.HeapSizes & 0x80) != 0; - if (m_reader != null) - m_tableReader = m_reader.MetadataReader.TableReader; - m_codeReader = new CodeReader (this); - m_sigReader = new SignatureReader (m_root, this); - m_isCorlib = module.Assembly.Name.Name == Constants.Corlib; - } - - public TypeDefinition GetTypeDefAt (uint rid) - { - return m_typeDefs [rid - 1]; - } - - public TypeReference GetTypeRefAt (uint rid) - { - return m_typeRefs [rid - 1]; - } - - public TypeReference GetTypeSpecAt (uint rid, GenericContext context) - { - int index = (int) rid - 1; - TypeReference tspec = m_typeSpecs [index]; - if (tspec != null) - return tspec; - - TypeSpecTable tsTable = m_tableReader.GetTypeSpecTable (); - TypeSpecRow tsRow = tsTable [index]; - TypeSpec ts = m_sigReader.GetTypeSpec (tsRow.Signature); - tspec = GetTypeRefFromSig (ts.Type, context); - tspec = GetModifierType (ts.CustomMods, tspec); - tspec.MetadataToken = MetadataToken.FromMetadataRow (TokenType.TypeSpec, index); - m_typeSpecs [index] = tspec; - - return tspec; - } - - public FieldDefinition GetFieldDefAt (uint rid) - { - return m_fields [rid - 1]; - } - - public MethodDefinition GetMethodDefAt (uint rid) - { - return m_meths [rid - 1]; - } - - protected bool IsDeleted (IMemberDefinition member) - { - if (!m_checkDeleted) - return false; - - if (!member.IsSpecialName || !member.IsRuntimeSpecialName) - return false; - - return member.Name.StartsWith (Constants.Deleted); - } - - public MemberReference GetMemberRefAt (uint rid, GenericContext context) - { - int index = (int) rid - 1; - MemberReference member = m_memberRefs [rid - 1]; - if (member != null) - return member; - - MemberRefTable mrTable = m_tableReader.GetMemberRefTable (); - MemberRefRow mrefRow = mrTable [index]; - - Signature sig = m_sigReader.GetMemberRefSig (mrefRow.Class.TokenType, mrefRow.Signature); - switch (mrefRow.Class.TokenType) { - case TokenType.TypeDef : - case TokenType.TypeRef : - case TokenType.TypeSpec : - TypeReference declaringType = GetTypeDefOrRef (mrefRow.Class, context); - GenericContext nc = context.Clone (); - - if (declaringType is GenericInstanceType) { - TypeReference ct = declaringType; - while (ct is GenericInstanceType) - ct = (ct as GenericInstanceType).ElementType; - - nc.Type = ct; - } - - if (sig is FieldSig) { - FieldSig fs = sig as FieldSig; - TypeReference fieldType = GetTypeRefFromSig (fs.Type, nc); - fieldType = GetModifierType (fs.CustomMods, fieldType); - - member = new FieldReference ( - m_root.Streams.StringsHeap [mrefRow.Name], - declaringType, - fieldType); - } else { - string name = m_root.Streams.StringsHeap [mrefRow.Name]; - MethodSig ms = (MethodSig) sig; - - member = CreateMethodReferenceFromSig (ms, name, declaringType, nc); - } - break; - case TokenType.Method : - // really not sure about this - MethodDefinition methdef = GetMethodDefAt (mrefRow.Class.RID); - - member = CreateMethodReferenceFromSig ((MethodSig) sig, methdef.Name, methdef.DeclaringType, new GenericContext ()); - break; - case TokenType.ModuleRef : - break; // TODO, implement that, or not - } - - member.MetadataToken = MetadataToken.FromMetadataRow (TokenType.MemberRef, index); - m_module.MemberReferences.Add (member); - m_memberRefs [index] = member; - - return member; - } - - MethodReference CreateMethodReferenceFromSig (MethodSig ms, string name, TypeReference declaringType, GenericContext context) - { - MethodReference methref = new MethodReference ( - name, ms.HasThis, ms.ExplicitThis, ms.MethCallConv); - methref.DeclaringType = declaringType; - - if (ms is MethodDefSig) { - int arity = (ms as MethodDefSig).GenericParameterCount; - for (int i = 0; i < arity; i++) - methref.GenericParameters.Add (new GenericParameter (i, methref)); - } - - if (methref.GenericParameters.Count > 0) - context.Method = methref; - - methref.ReturnType = GetMethodReturnType (ms, context); - - methref.ReturnType.Method = methref; - for (int j = 0; j < ms.ParamCount; j++) { - Param p = ms.Parameters [j]; - ParameterDefinition pdef = BuildParameterDefinition (j, p, context); - pdef.Method = methref; - methref.Parameters.Add (pdef); - } - - CreateSentinelIfNeeded (methref, ms); - - return methref; - } - - public static void CreateSentinelIfNeeded (IMethodSignature meth, MethodSig signature) - { - MethodDefSig sig = signature as MethodDefSig; - if (sig == null) - return; - - int sentinel = sig.Sentinel; - - if (sig.Sentinel < 0 || sig.Sentinel >= meth.Parameters.Count) - return; - - ParameterDefinition param = meth.Parameters [sentinel]; - param.ParameterType = new SentinelType (param.ParameterType); - } - - public PropertyDefinition GetPropertyDefAt (uint rid) - { - return m_properties [rid - 1]; - } - - public EventDefinition GetEventDefAt (uint rid) - { - return m_events [rid - 1]; - } - - public ParameterDefinition GetParamDefAt (uint rid) - { - return m_parameters [rid - 1]; - } - - public GenericParameter GetGenericParameterAt (uint rid) - { - return m_genericParameters [rid - 1]; - } - - public GenericInstanceMethod GetMethodSpecAt (uint rid, GenericContext context) - { - int index = (int) rid - 1; - GenericInstanceMethod gim = m_methodSpecs [index]; - if (gim != null) - return gim; - - MethodSpecTable msTable = m_tableReader.GetMethodSpecTable (); - MethodSpecRow msRow = msTable [index]; - - MethodSpec sig = m_sigReader.GetMethodSpec (msRow.Instantiation); - - MethodReference meth; - if (msRow.Method.TokenType == TokenType.Method) - meth = GetMethodDefAt (msRow.Method.RID); - else if (msRow.Method.TokenType == TokenType.MemberRef) - meth = (MethodReference) GetMemberRefAt (msRow.Method.RID, context); - else - throw new ReflectionException ("Unknown method type for method spec"); - - gim = new GenericInstanceMethod (meth); - context.CheckProvider (meth, sig.Signature.Arity); - foreach (GenericArg arg in sig.Signature.Types) - gim.GenericArguments.Add (GetGenericArg (arg, context)); - - m_methodSpecs [index] = gim; - - return gim; - } - - public TypeReference GetTypeDefOrRef (MetadataToken token, GenericContext context) - { - if (token.RID == 0) - return null; - - switch (token.TokenType) { - case TokenType.TypeDef : - return GetTypeDefAt (token.RID); - case TokenType.TypeRef : - return GetTypeRefAt (token.RID); - case TokenType.TypeSpec : - return GetTypeSpecAt (token.RID, context); - default : - return null; - } - } - - public TypeReference SearchCoreType (string fullName) - { - if (m_isCorlib) - return m_module.Types [fullName]; - - TypeReference coreType = m_module.TypeReferences [fullName]; - if (coreType == null) { - string [] parts = fullName.Split ('.'); - if (parts.Length != 2) - throw new ReflectionException ("Unvalid core type name"); - coreType = new TypeReference (parts [1], parts [0], Corlib); - m_module.TypeReferences.Add (coreType); - } - if (!coreType.IsValueType) { - switch (coreType.FullName) { - case Constants.Boolean : - case Constants.Char : - case Constants.Single : - case Constants.Double : - case Constants.SByte : - case Constants.Byte : - case Constants.Int16 : - case Constants.UInt16 : - case Constants.Int32 : - case Constants.UInt32 : - case Constants.Int64 : - case Constants.UInt64 : - case Constants.IntPtr : - case Constants.UIntPtr : - coreType.IsValueType = true; - break; - } - } - return coreType; - } - - public IMetadataTokenProvider LookupByToken (MetadataToken token) - { - switch (token.TokenType) { - case TokenType.TypeDef : - return GetTypeDefAt (token.RID); - case TokenType.TypeRef : - return GetTypeRefAt (token.RID); - case TokenType.Method : - return GetMethodDefAt (token.RID); - case TokenType.Field : - return GetFieldDefAt (token.RID); - case TokenType.Event : - return GetEventDefAt (token.RID); - case TokenType.Property : - return GetPropertyDefAt (token.RID); - case TokenType.Param : - return GetParamDefAt (token.RID); - default : - throw new NotSupportedException ("Lookup is not allowed on this kind of token"); - } - } - - public CustomAttribute GetCustomAttribute (MethodReference ctor, byte [] data, bool resolve) - { - CustomAttrib sig = m_sigReader.GetCustomAttrib (data, ctor, resolve); - return BuildCustomAttribute (ctor, sig); - } - - public CustomAttribute GetCustomAttribute (MethodReference ctor, byte [] data) - { - return GetCustomAttribute (ctor, data, false); - } - - public override void VisitModuleDefinition (ModuleDefinition mod) - { - VisitTypeDefinitionCollection (mod.Types); - } - - public override void VisitTypeDefinitionCollection (TypeDefinitionCollection types) - { - // type def reading - TypeDefTable typesTable = m_tableReader.GetTypeDefTable (); - m_typeDefs = new TypeDefinition [typesTable.Rows.Count]; - for (int i = 0; i < typesTable.Rows.Count; i++) { - TypeDefRow type = typesTable [i]; - TypeDefinition t = new TypeDefinition ( - m_root.Streams.StringsHeap [type.Name], - m_root.Streams.StringsHeap [type.Namespace], - type.Flags); - t.MetadataToken = MetadataToken.FromMetadataRow (TokenType.TypeDef, i); - - m_typeDefs [i] = t; - } - - // nested types - if (m_tHeap.HasTable (NestedClassTable.RId)) { - NestedClassTable nested = m_tableReader.GetNestedClassTable (); - for (int i = 0; i < nested.Rows.Count; i++) { - NestedClassRow row = nested [i]; - - TypeDefinition parent = GetTypeDefAt (row.EnclosingClass); - TypeDefinition child = GetTypeDefAt (row.NestedClass); - - if (!IsDeleted (child)) - parent.NestedTypes.Add (child); - } - } - - foreach (TypeDefinition type in m_typeDefs) - if (!IsDeleted (type)) - types.Add (type); - - // type ref reading - if (m_tHeap.HasTable (TypeRefTable.RId)) { - TypeRefTable typesRef = m_tableReader.GetTypeRefTable (); - - m_typeRefs = new TypeReference [typesRef.Rows.Count]; - - for (int i = 0; i < typesRef.Rows.Count; i++) - AddTypeRef (typesRef, i); - } else - m_typeRefs = new TypeReference [0]; - - ReadTypeSpecs (); - ReadMethodSpecs (); - - ReadMethods (); - ReadGenericParameters (); - - // set base types - for (int i = 0; i < typesTable.Rows.Count; i++) { - TypeDefRow type = typesTable [i]; - TypeDefinition child = m_typeDefs [i]; - child.BaseType = GetTypeDefOrRef (type.Extends, new GenericContext (child)); - } - - CompleteMethods (); - ReadAllFields (); - ReadMemberReferences (); - } - - void AddTypeRef (TypeRefTable typesRef, int i) - { - // Check if index has been already added. - if (m_typeRefs [i] != null) - return; - - TypeRefRow type = typesRef [i]; - IMetadataScope scope = null; - TypeReference parent = null; - - if (type.ResolutionScope.RID != 0) { - int rid = (int) type.ResolutionScope.RID - 1; - switch (type.ResolutionScope.TokenType) { - case TokenType.AssemblyRef: - scope = m_module.AssemblyReferences [rid]; - break; - case TokenType.ModuleRef: - scope = m_module.ModuleReferences [rid]; - break; - case TokenType.Module: - scope = m_module.Assembly.Modules [rid]; - break; - case TokenType.TypeRef: - AddTypeRef (typesRef, rid); - parent = GetTypeRefAt (type.ResolutionScope.RID); - scope = parent.Scope; - break; - } - } - - TypeReference t = new TypeReference ( - m_root.Streams.StringsHeap [type.Name], - m_root.Streams.StringsHeap [type.Namespace], - scope); - t.MetadataToken = MetadataToken.FromMetadataRow (TokenType.TypeRef, i); - - if (parent != null) - t.DeclaringType = parent; - - m_typeRefs [i] = t; - m_module.TypeReferences.Add (t); - } - - void ReadTypeSpecs () - { - if (!m_tHeap.HasTable (TypeSpecTable.RId)) - return; - - TypeSpecTable tsTable = m_tableReader.GetTypeSpecTable (); - m_typeSpecs = new TypeReference [tsTable.Rows.Count]; - } - - void ReadMethodSpecs () - { - if (!m_tHeap.HasTable (MethodSpecTable.RId)) - return; - - MethodSpecTable msTable = m_tableReader.GetMethodSpecTable (); - m_methodSpecs = new GenericInstanceMethod [msTable.Rows.Count]; - } - - void ReadGenericParameters () - { - if (!m_tHeap.HasTable (GenericParamTable.RId)) - return; - - GenericParamTable gpTable = m_tableReader.GetGenericParamTable (); - m_genericParameters = new GenericParameter [gpTable.Rows.Count]; - for (int i = 0; i < gpTable.Rows.Count; i++) { - GenericParamRow gpRow = gpTable [i]; - IGenericParameterProvider owner; - if (gpRow.Owner.TokenType == TokenType.Method) - owner = GetMethodDefAt (gpRow.Owner.RID); - else if (gpRow.Owner.TokenType == TokenType.TypeDef) - owner = GetTypeDefAt (gpRow.Owner.RID); - else - throw new ReflectionException ("Unknown owner type for generic parameter"); - - GenericParameter gp = new GenericParameter (gpRow.Number, owner); - gp.Attributes = gpRow.Flags; - gp.Name = MetadataRoot.Streams.StringsHeap [gpRow.Name]; - gp.MetadataToken = MetadataToken.FromMetadataRow (TokenType.GenericParam, i); - - owner.GenericParameters.Add (gp); - m_genericParameters [i] = gp; - } - } - - void ReadAllFields () - { - TypeDefTable tdefTable = m_tableReader.GetTypeDefTable (); - - if (!m_tHeap.HasTable (FieldTable.RId)) { - m_fields = new FieldDefinition [0]; - return; - } - - FieldTable fldTable = m_tableReader.GetFieldTable (); - m_fields = new FieldDefinition [fldTable.Rows.Count]; - - for (int i = 0; i < m_typeDefs.Length; i++) { - TypeDefinition dec = m_typeDefs [i]; - GenericContext context = new GenericContext (dec); - - int index = i, next; - - if (index == tdefTable.Rows.Count - 1) - next = fldTable.Rows.Count + 1; - else - next = (int) (tdefTable [index + 1]).FieldList; - - for (int j = (int) tdefTable [index].FieldList; j < next; j++) { - FieldRow frow = fldTable [j - 1]; - FieldSig fsig = m_sigReader.GetFieldSig (frow.Signature); - - FieldDefinition fdef = new FieldDefinition ( - m_root.Streams.StringsHeap [frow.Name], - GetTypeRefFromSig (fsig.Type, context), frow.Flags); - fdef.MetadataToken = MetadataToken.FromMetadataRow (TokenType.Field, j - 1); - - if (fsig.CustomMods.Length > 0) - fdef.FieldType = GetModifierType (fsig.CustomMods, fdef.FieldType); - - if (!IsDeleted (fdef)) - dec.Fields.Add (fdef); - - m_fields [j - 1] = fdef; - } - } - } - - void ReadMethods () - { - if (!m_tHeap.HasTable (MethodTable.RId)) { - m_meths = new MethodDefinition [0]; - return; - } - - MethodTable mTable = m_tableReader.GetMethodTable (); - m_meths = new MethodDefinition [mTable.Rows.Count]; - for (int i = 0; i < mTable.Rows.Count; i++) { - MethodRow mRow = mTable [i]; - MethodDefinition meth = new MethodDefinition ( - m_root.Streams.StringsHeap [mRow.Name], - mRow.Flags); - meth.RVA = mRow.RVA; - meth.ImplAttributes = mRow.ImplFlags; - - meth.MetadataToken = MetadataToken.FromMetadataRow (TokenType.Method, i); - - m_meths [i] = meth; - } - } - - void CompleteMethods () - { - TypeDefTable tdefTable = m_tableReader.GetTypeDefTable (); - - if (!m_tHeap.HasTable (MethodTable.RId)) { - m_meths = new MethodDefinition [0]; - return; - } - - MethodTable methTable = m_tableReader.GetMethodTable (); - ParamTable paramTable = m_tableReader.GetParamTable (); - if (!m_tHeap.HasTable (ParamTable.RId)) - m_parameters = new ParameterDefinition [0]; - else - m_parameters = new ParameterDefinition [paramTable.Rows.Count]; - - for (int i = 0; i < m_typeDefs.Length; i++) { - TypeDefinition dec = m_typeDefs [i]; - - int index = i, next; - - if (index == tdefTable.Rows.Count - 1) - next = methTable.Rows.Count + 1; - else - next = (int) (tdefTable [index + 1]).MethodList; - - for (int j = (int) tdefTable [index].MethodList; j < next; j++) { - MethodRow methRow = methTable [j - 1]; - MethodDefinition mdef = m_meths [j - 1]; - - if (!IsDeleted (mdef)) { - if (mdef.IsConstructor) - dec.Constructors.Add (mdef); - else - dec.Methods.Add (mdef); - } - - GenericContext context = new GenericContext (mdef); - - MethodDefSig msig = m_sigReader.GetMethodDefSig (methRow.Signature); - mdef.HasThis = msig.HasThis; - mdef.ExplicitThis = msig.ExplicitThis; - mdef.CallingConvention = msig.MethCallConv; - - int prms; - if (j == methTable.Rows.Count) - prms = m_parameters.Length + 1; - else - prms = (int) (methTable [j]).ParamList; - - ParameterDefinition retparam = null; - - //TODO: optimize this - int start = (int) methRow.ParamList - 1; - - if (paramTable != null && start < prms - 1) { - - ParamRow pRetRow = paramTable [start]; - - if (pRetRow != null && pRetRow.Sequence == 0) { // ret type - - retparam = new ParameterDefinition ( - m_root.Streams.StringsHeap [pRetRow.Name], - 0, - pRetRow.Flags, - null); - - retparam.Method = mdef; - m_parameters [start] = retparam; - start++; - } - } - - for (int k = 0; k < msig.ParamCount; k++) { - - int pointer = start + k; - - ParamRow pRow = null; - - if (paramTable != null && pointer < prms - 1) - pRow = paramTable [pointer]; - - Param psig = msig.Parameters [k]; - - ParameterDefinition pdef; - if (pRow != null) { - pdef = BuildParameterDefinition ( - m_root.Streams.StringsHeap [pRow.Name], - pRow.Sequence, pRow.Flags, psig, context); - pdef.MetadataToken = MetadataToken.FromMetadataRow (TokenType.Param, pointer); - m_parameters [pointer] = pdef; - } else - pdef = BuildParameterDefinition (k + 1, psig, context); - - pdef.Method = mdef; - mdef.Parameters.Add (pdef); - } - - mdef.ReturnType = GetMethodReturnType (msig, context); - MethodReturnType mrt = mdef.ReturnType; - mrt.Method = mdef; - if (retparam != null) { - mrt.Parameter = retparam; - mrt.Parameter.ParameterType = mrt.ReturnType; - } - } - } - - uint eprid = CodeReader.GetRid ((int) m_reader.Image.CLIHeader.EntryPointToken); - if (eprid > 0 && eprid <= m_meths.Length) - m_module.Assembly.EntryPoint = GetMethodDefAt (eprid); - } - - void ReadMemberReferences () - { - if (!m_tHeap.HasTable (MemberRefTable.RId)) - return; - - MemberRefTable mrefTable = m_tableReader.GetMemberRefTable (); - m_memberRefs = new MemberReference [mrefTable.Rows.Count]; - } - - public override void VisitExternTypeCollection (ExternTypeCollection externs) - { - ExternTypeCollection ext = externs; - - if (!m_tHeap.HasTable (ExportedTypeTable.RId)) - return; - - ExportedTypeTable etTable = m_tableReader.GetExportedTypeTable (); - TypeReference [] buffer = new TypeReference [etTable.Rows.Count]; - - for (int i = 0; i < etTable.Rows.Count; i++) { - ExportedTypeRow etRow = etTable [i]; - if (etRow.Implementation.TokenType != TokenType.File) - continue; - - string name = m_root.Streams.StringsHeap [etRow.TypeName]; - string ns = m_root.Streams.StringsHeap [etRow.TypeNamespace]; - if (ns.Length == 0) - buffer [i] = m_module.TypeReferences [name]; - else - buffer [i] = m_module.TypeReferences [string.Concat (ns, '.', name)]; - } - - for (int i = 0; i < etTable.Rows.Count; i++) { - ExportedTypeRow etRow = etTable [i]; - if (etRow.Implementation.TokenType != TokenType.ExportedType) - continue; - - TypeReference owner = buffer [etRow.Implementation.RID - 1]; - string name = m_root.Streams.StringsHeap [etRow.TypeName]; - buffer [i] = m_module.TypeReferences [string.Concat (owner.FullName, '/', name)]; - } - - for (int i = 0; i < buffer.Length; i++) { - TypeReference curs = buffer [i]; - if (curs != null) - ext.Add (curs); - } - } - - static object GetFixedArgValue (CustomAttrib.FixedArg fa) - { - if (fa.SzArray) { - object [] vals = new object [fa.NumElem]; - for (int j = 0; j < vals.Length; j++) - vals [j] = fa.Elems [j].Value; - return vals; - } else - return fa.Elems [0].Value; - } - - TypeReference GetFixedArgType (CustomAttrib.FixedArg fa) - { - if (fa.SzArray) { - if (fa.NumElem == 0) - return new ArrayType (SearchCoreType (Constants.Object)); - else - return new ArrayType (fa.Elems [0].ElemType); - } else - return fa.Elems [0].ElemType; - } - - TypeReference GetNamedArgType (CustomAttrib.NamedArg na) - { - if (na.FieldOrPropType == ElementType.Boxed) - return SearchCoreType (Constants.Object); - - return GetFixedArgType (na.FixedArg); - } - - protected CustomAttribute BuildCustomAttribute (MethodReference ctor, CustomAttrib sig) - { - CustomAttribute cattr = new CustomAttribute (ctor); - - foreach (CustomAttrib.FixedArg fa in sig.FixedArgs) - cattr.ConstructorParameters.Add (GetFixedArgValue (fa)); - - foreach (CustomAttrib.NamedArg na in sig.NamedArgs) { - object value = GetFixedArgValue (na.FixedArg); - if (na.Field) { - cattr.Fields [na.FieldOrPropName] = value; - cattr.SetFieldType (na.FieldOrPropName, GetNamedArgType (na)); - } else if (na.Property) { - cattr.Properties [na.FieldOrPropName] = value; - cattr.SetPropertyType (na.FieldOrPropName, GetNamedArgType (na)); - } else - throw new ReflectionException ("Non valid named arg"); - } - - return cattr; - } - - void CompleteParameter (ParameterDefinition parameter, Param signature, GenericContext context) - { - TypeReference paramType; - - if (signature.ByRef) - paramType = new ReferenceType (GetTypeRefFromSig (signature.Type, context)); - else if (signature.TypedByRef) - paramType = SearchCoreType (Constants.TypedReference); - else - paramType = GetTypeRefFromSig (signature.Type, context); - - paramType = GetModifierType (signature.CustomMods, paramType); - - parameter.ParameterType = paramType; - } - - public ParameterDefinition BuildParameterDefinition (int sequence, Param psig, GenericContext context) - { - ParameterDefinition parameter = new ParameterDefinition (null); - parameter.Sequence = sequence; - - CompleteParameter (parameter, psig, context); - - return parameter; - } - - public ParameterDefinition BuildParameterDefinition (string name, int sequence, ParameterAttributes attrs, Param psig, GenericContext context) - { - ParameterDefinition parameter = new ParameterDefinition (name, sequence, attrs, null); - - CompleteParameter (parameter, psig, context); - - return parameter; - } - - protected SecurityDeclaration BuildSecurityDeclaration (DeclSecurityRow dsRow) - { - return BuildSecurityDeclaration (dsRow.Action, m_root.Streams.BlobHeap.Read (dsRow.PermissionSet)); - } - - public SecurityDeclaration BuildSecurityDeclaration (SecurityAction action, byte [] permset) - { - if (m_secReader == null) - m_secReader = new SecurityDeclarationReader (m_root, this); - - return m_secReader.FromByteArray (action, permset); - } - - protected MarshalSpec BuildMarshalDesc (MarshalSig ms, IHasMarshalSpec container) - { - if (ms.Spec is MarshalSig.Array) { - ArrayMarshalSpec amd = new ArrayMarshalSpec (container); - MarshalSig.Array ar = (MarshalSig.Array) ms.Spec; - amd.ElemType = ar.ArrayElemType; - amd.NumElem = ar.NumElem; - amd.ParamNum = ar.ParamNum; - amd.ElemMult = ar.ElemMult; - return amd; - } else if (ms.Spec is MarshalSig.CustomMarshaler) { - CustomMarshalerSpec cmd = new CustomMarshalerSpec (container); - MarshalSig.CustomMarshaler cmsig = (MarshalSig.CustomMarshaler) ms.Spec; - cmd.Guid = cmsig.Guid.Length > 0 ? new Guid (cmsig.Guid) : new Guid (); - cmd.UnmanagedType = cmsig.UnmanagedType; - cmd.ManagedType = cmsig.ManagedType; - cmd.Cookie = cmsig.Cookie; - return cmd; - } else if (ms.Spec is MarshalSig.FixedArray) { - FixedArraySpec fad = new FixedArraySpec (container); - MarshalSig.FixedArray fasig = (MarshalSig.FixedArray) ms.Spec; - fad.ElemType = fasig.ArrayElemType; - fad.NumElem = fasig.NumElem; - return fad; - } else if (ms.Spec is MarshalSig.FixedSysString) { - FixedSysStringSpec fssc = new FixedSysStringSpec (container); - fssc.Size = ((MarshalSig.FixedSysString) ms.Spec).Size; - return fssc; - } else if (ms.Spec is MarshalSig.SafeArray) { - SafeArraySpec sad = new SafeArraySpec (container); - sad.ElemType = ((MarshalSig.SafeArray) ms.Spec).ArrayElemType; - return sad; - } else { - return new MarshalSpec (ms.NativeInstrinsic, container); - } - } - - public TypeReference GetModifierType (CustomMod [] cmods, TypeReference type) - { - if (cmods == null || cmods.Length == 0) - return type; - - TypeReference ret = type; - for (int i = cmods.Length - 1; i >= 0; i--) { - CustomMod cmod = cmods [i]; - TypeReference modType; - - if (cmod.TypeDefOrRef.TokenType == TokenType.TypeDef) - modType = GetTypeDefAt (cmod.TypeDefOrRef.RID); - else - modType = GetTypeRefAt (cmod.TypeDefOrRef.RID); - - if (cmod.CMOD == CustomMod.CMODType.OPT) - ret = new ModifierOptional (ret, modType); - else if (cmod.CMOD == CustomMod.CMODType.REQD) - ret = new ModifierRequired (ret, modType); - } - return ret; - } - - public MethodReturnType GetMethodReturnType (MethodSig msig, GenericContext context) - { - TypeReference retType; - if (msig.RetType.Void) - retType = SearchCoreType (Constants.Void); - else if (msig.RetType.ByRef) - retType = new ReferenceType (GetTypeRefFromSig (msig.RetType.Type, context)); - else if (msig.RetType.TypedByRef) - retType = SearchCoreType (Constants.TypedReference); - else - retType = GetTypeRefFromSig (msig.RetType.Type, context); - - retType = GetModifierType (msig.RetType.CustomMods, retType); - - return new MethodReturnType (retType); - } - - public TypeReference GetTypeRefFromSig (SigType t, GenericContext context) - { - switch (t.ElementType) { - case ElementType.Class : - CLASS c = t as CLASS; - return GetTypeDefOrRef (c.Type, context); - case ElementType.ValueType : - VALUETYPE vt = t as VALUETYPE; - TypeReference vtr = GetTypeDefOrRef (vt.Type, context); - vtr.IsValueType = true; - return vtr; - case ElementType.String : - return SearchCoreType (Constants.String); - case ElementType.Object : - return SearchCoreType (Constants.Object); - case ElementType.Void : - return SearchCoreType (Constants.Void); - case ElementType.Boolean : - return SearchCoreType (Constants.Boolean); - case ElementType.Char : - return SearchCoreType (Constants.Char); - case ElementType.I1 : - return SearchCoreType (Constants.SByte); - case ElementType.U1 : - return SearchCoreType (Constants.Byte); - case ElementType.I2 : - return SearchCoreType (Constants.Int16); - case ElementType.U2 : - return SearchCoreType (Constants.UInt16); - case ElementType.I4 : - return SearchCoreType (Constants.Int32); - case ElementType.U4 : - return SearchCoreType (Constants.UInt32); - case ElementType.I8 : - return SearchCoreType (Constants.Int64); - case ElementType.U8 : - return SearchCoreType (Constants.UInt64); - case ElementType.R4 : - return SearchCoreType (Constants.Single); - case ElementType.R8 : - return SearchCoreType (Constants.Double); - case ElementType.I : - return SearchCoreType (Constants.IntPtr); - case ElementType.U : - return SearchCoreType (Constants.UIntPtr); - case ElementType.TypedByRef : - return SearchCoreType (Constants.TypedReference); - case ElementType.Array : - ARRAY ary = t as ARRAY; - return new ArrayType (GetTypeRefFromSig (ary.Type, context), ary.Shape); - case ElementType.SzArray : - SZARRAY szary = t as SZARRAY; - ArrayType at = new ArrayType (GetTypeRefFromSig (szary.Type, context)); - return at; - case ElementType.Ptr : - PTR pointer = t as PTR; - if (pointer.Void) - return new PointerType (SearchCoreType (Constants.Void)); - return new PointerType (GetTypeRefFromSig (pointer.PtrType, context)); - case ElementType.FnPtr : - FNPTR funcptr = t as FNPTR; - FunctionPointerType fnptr = new FunctionPointerType (funcptr.Method.HasThis, funcptr.Method.ExplicitThis, - funcptr.Method.MethCallConv, GetMethodReturnType (funcptr.Method, context)); - - for (int i = 0; i < funcptr.Method.ParamCount; i++) { - Param p = funcptr.Method.Parameters [i]; - fnptr.Parameters.Add (BuildParameterDefinition (i, p, context)); - } - - CreateSentinelIfNeeded (fnptr, funcptr.Method); - - return fnptr; - case ElementType.Var: - VAR var = t as VAR; - context.CheckProvider (context.Type, var.Index + 1); - - if (context.Type is GenericInstanceType) - return (context.Type as GenericInstanceType).GenericArguments [var.Index]; - else - return context.Type.GenericParameters [var.Index]; - case ElementType.MVar: - MVAR mvar = t as MVAR; - context.CheckProvider (context.Method, mvar.Index + 1); - - if (context.Method is GenericInstanceMethod) - return (context.Method as GenericInstanceMethod).GenericArguments [mvar.Index]; - else - return context.Method.GenericParameters [mvar.Index]; - case ElementType.GenericInst: - GENERICINST ginst = t as GENERICINST; - GenericInstanceType instance = new GenericInstanceType (GetTypeDefOrRef (ginst.Type, context)); - instance.IsValueType = ginst.ValueType; - context.CheckProvider (instance.GetOriginalType (), ginst.Signature.Arity); - - for (int i = 0; i < ginst.Signature.Arity; i++) - instance.GenericArguments.Add (GetGenericArg ( - ginst.Signature.Types [i], context)); - - return instance; - default: - break; - } - return null; - } - - TypeReference GetGenericArg (GenericArg arg, GenericContext context) - { - TypeReference type = GetTypeRefFromSig (arg.Type, context); - type = GetModifierType (arg.CustomMods, type); - return type; - } - - static bool IsOdd (int i) - { - return (i & 1) == 1; - } - - protected object GetConstant (uint pos, ElementType elemType) - { - if (elemType == ElementType.Class) - return null; - - byte [] constant = m_root.Streams.BlobHeap.Read (pos); - - if (elemType == ElementType.String) { - int length = constant.Length; - if (IsOdd (length)) - length--; - - return Encoding.Unicode.GetString (constant, 0, length); - } - - BinaryReader br = new BinaryReader (new MemoryStream (constant)); - - switch (elemType) { - case ElementType.Boolean : - return br.ReadByte () == 1; - case ElementType.Char : - return (char) br.ReadUInt16 (); - case ElementType.I1 : - return br.ReadSByte (); - case ElementType.I2 : - return br.ReadInt16 (); - case ElementType.I4 : - return br.ReadInt32 (); - case ElementType.I8 : - return br.ReadInt64 (); - case ElementType.U1 : - return br.ReadByte (); - case ElementType.U2 : - return br.ReadUInt16 (); - case ElementType.U4 : - return br.ReadUInt32 (); - case ElementType.U8 : - return br.ReadUInt64 (); - case ElementType.R4 : - return br.ReadSingle (); - case ElementType.R8 : - return br.ReadDouble (); - default : - throw new ReflectionException ("Non valid element in constant table"); - } - } - - protected void SetInitialValue (FieldDefinition field) - { - int size = 0; - TypeReference fieldType = field.FieldType; - switch (fieldType.FullName) { - case Constants.Byte: - case Constants.SByte: - size = 1; - break; - case Constants.Int16: - case Constants.UInt16: - case Constants.Char: - size = 2; - break; - case Constants.Int32: - case Constants.UInt32: - case Constants.Single: - size = 4; - break; - case Constants.Int64: - case Constants.UInt64: - case Constants.Double: - size = 8; - break; - default: - fieldType = fieldType.GetOriginalType (); - - TypeDefinition fieldTypeDef = fieldType as TypeDefinition; - - if (fieldTypeDef != null) - size = (int) fieldTypeDef.ClassSize; - break; - } - - if (size > 0 && field.RVA != RVA.Zero) { - BinaryReader br = m_reader.MetadataReader.GetDataReader (field.RVA); - field.InitialValue = br == null ? new byte [size] : br.ReadBytes (size); - } else - field.InitialValue = new byte [0]; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionWriter.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionWriter.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionWriter.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionWriter.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,1522 +0,0 @@ -// -// ReflectionWriter.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 - 2007 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.Collections; - using System.Globalization; - using System.Text; - - using Mono.Cecil.Binary; - using Mono.Cecil.Cil; - using Mono.Cecil.Metadata; - using Mono.Cecil.Signatures; - - internal sealed class ReflectionWriter : BaseReflectionVisitor { - - StructureWriter m_structureWriter; - ModuleDefinition m_mod; - SignatureWriter m_sigWriter; - CodeWriter m_codeWriter; - MetadataWriter m_mdWriter; - MetadataTableWriter m_tableWriter; - MetadataRowWriter m_rowWriter; - - bool m_saveSymbols; - string m_asmOutput; - ISymbolWriter m_symbolWriter; - - ArrayList m_typeDefStack; - ArrayList m_methodStack; - ArrayList m_fieldStack; - ArrayList m_genericParamStack; - IDictionary m_typeSpecTokenCache; - IDictionary m_memberRefTokenCache; - - uint m_methodIndex; - uint m_fieldIndex; - uint m_paramIndex; - uint m_eventIndex; - uint m_propertyIndex; - - MemoryBinaryWriter m_constWriter; - - public StructureWriter StructureWriter { - get { return m_structureWriter; } - set { - m_structureWriter = value; - - Initialize (); - } - } - - public CodeWriter CodeWriter { - get { return m_codeWriter; } - } - - public bool SaveSymbols { - get { return m_saveSymbols; } - set { m_saveSymbols = value; } - } - - public string OutputFile - { - get { return m_asmOutput; } - set { m_asmOutput = value; } - } - - public ISymbolWriter SymbolWriter { - get { return m_symbolWriter; } - set { m_symbolWriter = value; } - } - - public SignatureWriter SignatureWriter { - get { return m_sigWriter; } - } - - public MetadataWriter MetadataWriter { - get { return m_mdWriter; } - } - - public MetadataTableWriter MetadataTableWriter { - get { return m_tableWriter; } - } - - public MetadataRowWriter MetadataRowWriter { - get { return m_rowWriter; } - } - - public ReflectionWriter (ModuleDefinition mod) - { - m_mod = mod; - } - - void Initialize () - { - m_mdWriter = new MetadataWriter ( - m_mod.Assembly, - m_mod.Image.MetadataRoot, - m_structureWriter.Assembly.Kind, - m_mod.Assembly.Runtime, - m_structureWriter.GetWriter ()); - m_tableWriter = m_mdWriter.GetTableVisitor (); - m_rowWriter = m_tableWriter.GetRowVisitor () as MetadataRowWriter; - m_sigWriter = new SignatureWriter (m_mdWriter); - m_codeWriter = new CodeWriter (this, m_mdWriter.CilWriter); - - m_typeDefStack = new ArrayList (); - m_methodStack = new ArrayList (); - m_fieldStack = new ArrayList (); - m_genericParamStack = new ArrayList (); - m_typeSpecTokenCache = new Hashtable (); - m_memberRefTokenCache = new Hashtable (); - - m_methodIndex = 1; - m_fieldIndex = 1; - m_paramIndex = 1; - m_eventIndex = 1; - m_propertyIndex = 1; - - m_constWriter = new MemoryBinaryWriter (); - } - - public TypeReference GetCoreType (string name) - { - return m_mod.Controller.Reader.SearchCoreType (name); - } - - public static uint GetRidFor (IMetadataTokenProvider tp) - { - return tp.MetadataToken.RID; - } - - public uint GetRidFor (AssemblyNameReference asmName) - { - return (uint) m_mod.AssemblyReferences.IndexOf (asmName) + 1; - } - - public uint GetRidFor (ModuleDefinition mod) - { - return (uint) m_mod.Assembly.Modules.IndexOf (mod) + 1; - } - - public uint GetRidFor (ModuleReference modRef) - { - return (uint) m_mod.ModuleReferences.IndexOf (modRef) + 1; - } - - static bool IsTypeSpec (TypeReference type) - { - return type is TypeSpecification || type is GenericParameter; - } - - public MetadataToken GetTypeDefOrRefToken (TypeReference type) - { - if (IsTypeSpec (type)) { - uint sig = m_sigWriter.AddTypeSpec (GetTypeSpecSig (type)); - if (m_typeSpecTokenCache.Contains (sig)) - return (MetadataToken) m_typeSpecTokenCache [sig]; - - TypeSpecTable tsTable = m_tableWriter.GetTypeSpecTable (); - TypeSpecRow tsRow = m_rowWriter.CreateTypeSpecRow (sig); - tsTable.Rows.Add (tsRow); - - MetadataToken token = new MetadataToken (TokenType.TypeSpec, (uint) tsTable.Rows.Count); - if (! (type is GenericParameter)) - type.MetadataToken = token; - - m_typeSpecTokenCache [sig] = token; - return token; - } else if (type != null) - return type.MetadataToken; - else // and interfaces - return new MetadataToken (TokenType.TypeRef, 0); - } - - public MetadataToken GetMemberRefToken (MemberReference member) - { - if (member is MethodSpecification) - return GetMemberRefToken (((MethodSpecification) member).ElementMethod); - if (member is IMemberDefinition) - return member.MetadataToken; - if (m_memberRefTokenCache.Contains (member)) - return (MetadataToken) m_memberRefTokenCache [member]; - - MemberRefTable mrTable = m_tableWriter.GetMemberRefTable (); - - uint sig = 0; - if (member is FieldReference) - sig = m_sigWriter.AddFieldSig (GetFieldSig ((FieldReference) member)); - else if (member is MethodReference) - sig = m_sigWriter.AddMethodRefSig (GetMethodRefSig ((MethodReference) member)); - - MetadataToken declaringType = GetTypeDefOrRefToken (member.DeclaringType); - uint name = m_mdWriter.AddString (member.Name); - - for (int i = 0; i < mrTable.Rows.Count; i++) { - MemberRefRow row = mrTable [i]; - if (row.Class == declaringType && row.Name == name && row.Signature == sig) - return MetadataToken.FromMetadataRow (TokenType.MemberRef, i); - } - - MemberRefRow mrRow = m_rowWriter.CreateMemberRefRow ( - declaringType, - name, - sig); - - mrTable.Rows.Add (mrRow); - member.MetadataToken = new MetadataToken ( - TokenType.MemberRef, (uint) mrTable.Rows.Count); - m_memberRefTokenCache [member] = member.MetadataToken; - return member.MetadataToken; - } - - public MetadataToken GetMethodSpecToken (GenericInstanceMethod gim) - { - uint sig = m_sigWriter.AddMethodSpec (GetMethodSpecSig (gim)); - MethodSpecTable msTable = m_tableWriter.GetMethodSpecTable (); - - MetadataToken meth = GetMemberRefToken (gim.ElementMethod); - - for (int i = 0; i < msTable.Rows.Count; i++) { - MethodSpecRow row = msTable [i]; - if (row.Method == meth && row.Instantiation == sig) - return MetadataToken.FromMetadataRow (TokenType.MethodSpec, i); - } - - MethodSpecRow msRow = m_rowWriter.CreateMethodSpecRow ( - meth, - sig); - msTable.Rows.Add (msRow); - gim.MetadataToken = new MetadataToken (TokenType.MethodSpec, (uint) msTable.Rows.Count); - return gim.MetadataToken; - } - - public override void VisitModuleDefinition (ModuleDefinition mod) - { - mod.FullLoad (); - } - - public override void VisitTypeDefinitionCollection (TypeDefinitionCollection types) - { - TypeDefTable tdTable = m_tableWriter.GetTypeDefTable (); - - if (types [Constants.ModuleType] == null) - types.Add (new TypeDefinition ( - Constants.ModuleType, string.Empty, TypeAttributes.NotPublic)); - - foreach (TypeDefinition t in types) - m_typeDefStack.Add (t); - - m_typeDefStack.Sort (TableComparers.TypeDef.Instance); - - for (int i = 0; i < m_typeDefStack.Count; i++) { - TypeDefinition t = (TypeDefinition) m_typeDefStack [i]; - if (t.Module.Assembly != m_mod.Assembly) - throw new ReflectionException ("A type as not been correctly imported"); - - t.MetadataToken = new MetadataToken (TokenType.TypeDef, (uint) (i + 1)); - } - - foreach (TypeDefinition t in m_typeDefStack) { - TypeDefRow tdRow = m_rowWriter.CreateTypeDefRow ( - t.Attributes, - m_mdWriter.AddString (t.Name), - m_mdWriter.AddString (t.Namespace), - GetTypeDefOrRefToken (t.BaseType), - 0, - 0); - - tdTable.Rows.Add (tdRow); - } - } - - public void CompleteTypeDefinitions () - { - TypeDefTable tdTable = m_tableWriter.GetTypeDefTable (); - - for (int i = 0; i < m_typeDefStack.Count; i++) { - TypeDefRow tdRow = tdTable [i]; - TypeDefinition t = (TypeDefinition) m_typeDefStack [i]; - tdRow.FieldList = m_fieldIndex; - tdRow.MethodList = m_methodIndex; - foreach (FieldDefinition field in t.Fields) - VisitFieldDefinition (field); - foreach (MethodDefinition ctor in t.Constructors) - VisitMethodDefinition (ctor); - foreach (MethodDefinition meth in t.Methods) - VisitMethodDefinition (meth); - - if (t.HasLayoutInfo) - WriteLayout (t); - } - - foreach (FieldDefinition field in m_fieldStack) { - VisitCustomAttributeCollection (field.CustomAttributes); - if (field.MarshalSpec != null) - VisitMarshalSpec (field.MarshalSpec); - } - - foreach (MethodDefinition meth in m_methodStack) { - VisitCustomAttributeCollection (meth.ReturnType.CustomAttributes); - foreach (ParameterDefinition param in meth.Parameters) - VisitCustomAttributeCollection (param.CustomAttributes); - VisitGenericParameterCollection (meth.GenericParameters); - VisitOverrideCollection (meth.Overrides); - VisitCustomAttributeCollection (meth.CustomAttributes); - VisitSecurityDeclarationCollection (meth.SecurityDeclarations); - if (meth.PInvokeInfo != null) { - meth.Attributes |= MethodAttributes.PInvokeImpl; - VisitPInvokeInfo (meth.PInvokeInfo); - } - } - - foreach (TypeDefinition t in m_typeDefStack) - t.Accept (this); - } - - public override void VisitTypeReferenceCollection (TypeReferenceCollection refs) - { - ArrayList orderedTypeRefs = new ArrayList (refs.Count); - foreach (TypeReference tr in refs) - orderedTypeRefs.Add (tr); - - orderedTypeRefs.Sort (TableComparers.TypeRef.Instance); - - TypeRefTable trTable = m_tableWriter.GetTypeRefTable (); - foreach (TypeReference t in orderedTypeRefs) { - MetadataToken scope; - - if (t.Module.Assembly != m_mod.Assembly) - throw new ReflectionException ("A type as not been correctly imported"); - - if (t.Scope == null) - continue; - - if (t.DeclaringType != null) - scope = new MetadataToken (TokenType.TypeRef, GetRidFor (t.DeclaringType)); - else if (t.Scope is AssemblyNameReference) - scope = new MetadataToken (TokenType.AssemblyRef, - GetRidFor ((AssemblyNameReference) t.Scope)); - else if (t.Scope is ModuleDefinition) - scope = new MetadataToken (TokenType.Module, - GetRidFor ((ModuleDefinition) t.Scope)); - else if (t.Scope is ModuleReference) - scope = new MetadataToken (TokenType.ModuleRef, - GetRidFor ((ModuleReference) t.Scope)); - else - scope = new MetadataToken (TokenType.ExportedType, 0); - - TypeRefRow trRow = m_rowWriter.CreateTypeRefRow ( - scope, - m_mdWriter.AddString (t.Name), - m_mdWriter.AddString (t.Namespace)); - - trTable.Rows.Add (trRow); - t.MetadataToken = new MetadataToken (TokenType.TypeRef, (uint) trTable.Rows.Count); - } - } - - public override void VisitGenericParameterCollection (GenericParameterCollection parameters) - { - if (parameters.Count == 0) - return; - - foreach (GenericParameter gp in parameters) - m_genericParamStack.Add (gp); - } - - public override void VisitInterfaceCollection (InterfaceCollection interfaces) - { - if (interfaces.Count == 0) - return; - - InterfaceImplTable iiTable = m_tableWriter.GetInterfaceImplTable (); - foreach (TypeReference interf in interfaces) { - InterfaceImplRow iiRow = m_rowWriter.CreateInterfaceImplRow ( - GetRidFor (interfaces.Container), - GetTypeDefOrRefToken (interf)); - - iiTable.Rows.Add (iiRow); - } - } - - public override void VisitExternTypeCollection (ExternTypeCollection externs) - { - VisitCollection (externs); - } - - public override void VisitExternType (TypeReference externType) - { - // TODO - } - - public override void VisitOverrideCollection (OverrideCollection meths) - { - if (meths.Count == 0) - return; - - MethodImplTable miTable = m_tableWriter.GetMethodImplTable (); - foreach (MethodReference ov in meths) { - MethodImplRow miRow = m_rowWriter.CreateMethodImplRow ( - GetRidFor (meths.Container.DeclaringType as TypeDefinition), - new MetadataToken (TokenType.Method, GetRidFor (meths.Container)), - GetMemberRefToken (ov)); - - miTable.Rows.Add (miRow); - } - } - - public override void VisitNestedTypeCollection (NestedTypeCollection nestedTypes) - { - if (nestedTypes.Count == 0) - return; - - NestedClassTable ncTable = m_tableWriter.GetNestedClassTable (); - foreach (TypeDefinition nested in nestedTypes) { - NestedClassRow ncRow = m_rowWriter.CreateNestedClassRow ( - nested.MetadataToken.RID, - GetRidFor (nestedTypes.Container)); - - ncTable.Rows.Add (ncRow); - } - } - - public override void VisitParameterDefinitionCollection (ParameterDefinitionCollection parameters) - { - if (parameters.Count == 0) - return; - - ushort seq = 1; - ParamTable pTable = m_tableWriter.GetParamTable (); - foreach (ParameterDefinition param in parameters) - InsertParameter (pTable, param, seq++); - } - - void InsertParameter (ParamTable pTable, ParameterDefinition param, ushort seq) - { - ParamRow pRow = m_rowWriter.CreateParamRow ( - param.Attributes, - seq, - m_mdWriter.AddString (param.Name)); - - pTable.Rows.Add (pRow); - param.MetadataToken = new MetadataToken (TokenType.Param, (uint) pTable.Rows.Count); - - if (param.MarshalSpec != null) - param.MarshalSpec.Accept (this); - - if (param.HasConstant) - WriteConstant (param, param.ParameterType); - - m_paramIndex++; - } - - static bool RequiresParameterRow (MethodReturnType mrt) - { - return mrt.HasConstant || mrt.MarshalSpec != null || - mrt.CustomAttributes.Count > 0 || mrt.Parameter.Attributes != (ParameterAttributes) 0; - } - - public override void VisitMethodDefinition (MethodDefinition method) - { - MethodTable mTable = m_tableWriter.GetMethodTable (); - MethodRow mRow = m_rowWriter.CreateMethodRow ( - RVA.Zero, - method.ImplAttributes, - method.Attributes, - m_mdWriter.AddString (method.Name), - m_sigWriter.AddMethodDefSig (GetMethodDefSig (method)), - m_paramIndex); - - mTable.Rows.Add (mRow); - m_methodStack.Add (method); - method.MetadataToken = new MetadataToken (TokenType.Method, (uint) mTable.Rows.Count); - m_methodIndex++; - - if (RequiresParameterRow (method.ReturnType)) - InsertParameter (m_tableWriter.GetParamTable (), method.ReturnType.Parameter, 0); - - VisitParameterDefinitionCollection (method.Parameters); - } - - public override void VisitPInvokeInfo (PInvokeInfo pinvk) - { - ImplMapTable imTable = m_tableWriter.GetImplMapTable (); - ImplMapRow imRow = m_rowWriter.CreateImplMapRow ( - pinvk.Attributes, - new MetadataToken (TokenType.Method, GetRidFor (pinvk.Method)), - m_mdWriter.AddString (pinvk.EntryPoint), - GetRidFor (pinvk.Module)); - - imTable.Rows.Add (imRow); - } - - public override void VisitEventDefinitionCollection (EventDefinitionCollection events) - { - if (events.Count == 0) - return; - - EventMapTable emTable = m_tableWriter.GetEventMapTable (); - EventMapRow emRow = m_rowWriter.CreateEventMapRow ( - GetRidFor (events.Container), - m_eventIndex); - - emTable.Rows.Add (emRow); - VisitCollection (events); - } - - public override void VisitEventDefinition (EventDefinition evt) - { - EventTable eTable = m_tableWriter.GetEventTable (); - EventRow eRow = m_rowWriter.CreateEventRow ( - evt.Attributes, - m_mdWriter.AddString (evt.Name), - GetTypeDefOrRefToken (evt.EventType)); - - eTable.Rows.Add (eRow); - evt.MetadataToken = new MetadataToken (TokenType.Event, (uint) eTable.Rows.Count); - - if (evt.AddMethod != null) - WriteSemantic (MethodSemanticsAttributes.AddOn, evt, evt.AddMethod); - - if (evt.InvokeMethod != null) - WriteSemantic (MethodSemanticsAttributes.Fire, evt, evt.InvokeMethod); - - if (evt.RemoveMethod != null) - WriteSemantic (MethodSemanticsAttributes.RemoveOn, evt, evt.RemoveMethod); - - m_eventIndex++; - } - - public override void VisitFieldDefinition (FieldDefinition field) - { - FieldTable fTable = m_tableWriter.GetFieldTable (); - FieldRow fRow = m_rowWriter.CreateFieldRow ( - field.Attributes, - m_mdWriter.AddString (field.Name), - m_sigWriter.AddFieldSig (GetFieldSig (field))); - - fTable.Rows.Add (fRow); - field.MetadataToken = new MetadataToken (TokenType.Field, (uint) fTable.Rows.Count); - m_fieldIndex++; - - if (field.HasConstant) - WriteConstant (field, field.FieldType); - - if (field.HasLayoutInfo) - WriteLayout (field); - - m_fieldStack.Add (field); - } - - public override void VisitPropertyDefinitionCollection (PropertyDefinitionCollection properties) - { - if (properties.Count == 0) - return; - - PropertyMapTable pmTable = m_tableWriter.GetPropertyMapTable (); - PropertyMapRow pmRow = m_rowWriter.CreatePropertyMapRow ( - GetRidFor (properties.Container), - m_propertyIndex); - - pmTable.Rows.Add (pmRow); - VisitCollection (properties); - } - - public override void VisitPropertyDefinition (PropertyDefinition property) - { - PropertyTable pTable = m_tableWriter.GetPropertyTable (); - PropertyRow pRow = m_rowWriter.CreatePropertyRow ( - property.Attributes, - m_mdWriter.AddString (property.Name), - m_sigWriter.AddPropertySig (GetPropertySig (property))); - - pTable.Rows.Add (pRow); - property.MetadataToken = new MetadataToken (TokenType.Property, (uint) pTable.Rows.Count); - - if (property.GetMethod != null) - WriteSemantic (MethodSemanticsAttributes.Getter, property, property.GetMethod); - - if (property.SetMethod != null) - WriteSemantic (MethodSemanticsAttributes.Setter, property, property.SetMethod); - - if (property.HasConstant) - WriteConstant (property, property.PropertyType); - - m_propertyIndex++; - } - - public override void VisitSecurityDeclarationCollection (SecurityDeclarationCollection secDecls) - { - if (secDecls.Count == 0) - return; - - DeclSecurityTable dsTable = m_tableWriter.GetDeclSecurityTable (); - foreach (SecurityDeclaration secDec in secDecls) { - DeclSecurityRow dsRow = m_rowWriter.CreateDeclSecurityRow ( - secDec.Action, - secDecls.Container.MetadataToken, - m_mdWriter.AddBlob (secDec.Resolved ? - m_mod.GetAsByteArray (secDec) : secDec.Blob)); - - dsTable.Rows.Add (dsRow); - } - } - - public override void VisitCustomAttributeCollection (CustomAttributeCollection customAttrs) - { - if (customAttrs.Count == 0) - return; - - CustomAttributeTable caTable = m_tableWriter.GetCustomAttributeTable (); - foreach (CustomAttribute ca in customAttrs) { - MetadataToken parent; - if (customAttrs.Container is AssemblyDefinition) - parent = new MetadataToken (TokenType.Assembly, 1); - else if (customAttrs.Container is ModuleDefinition) - parent = new MetadataToken (TokenType.Module, 1); - else if (customAttrs.Container is IMetadataTokenProvider) - parent = ((IMetadataTokenProvider) customAttrs.Container).MetadataToken; - else - throw new ReflectionException ("Unknown Custom Attribute parent"); - - uint value = ca.Resolved ? - m_sigWriter.AddCustomAttribute (GetCustomAttributeSig (ca), ca.Constructor) : - m_mdWriter.AddBlob (m_mod.GetAsByteArray (ca)); - CustomAttributeRow caRow = m_rowWriter.CreateCustomAttributeRow ( - parent, - GetMemberRefToken (ca.Constructor), - value); - - caTable.Rows.Add (caRow); - } - } - - public override void VisitMarshalSpec (MarshalSpec marshalSpec) - { - FieldMarshalTable fmTable = m_tableWriter.GetFieldMarshalTable (); - FieldMarshalRow fmRow = m_rowWriter.CreateFieldMarshalRow ( - marshalSpec.Container.MetadataToken, - m_sigWriter.AddMarshalSig (GetMarshalSig (marshalSpec))); - - fmTable.Rows.Add (fmRow); - } - - void WriteConstant (IHasConstant hc, TypeReference type) - { - ConstantTable cTable = m_tableWriter.GetConstantTable (); - ElementType et; - if (type is TypeDefinition && (type as TypeDefinition).IsEnum) { - Type t = hc.Constant.GetType (); - if (t.IsEnum) - t = Enum.GetUnderlyingType (t); - - et = GetCorrespondingType (string.Concat (t.Namespace, '.', t.Name)); - } else - et = GetCorrespondingType (type.FullName); - - if (et == ElementType.Object) - et = hc.Constant == null ? - ElementType.Class : - GetCorrespondingType (hc.Constant.GetType ().FullName); - - ConstantRow cRow = m_rowWriter.CreateConstantRow ( - et, - hc.MetadataToken, - m_mdWriter.AddBlob (EncodeConstant (et, hc.Constant))); - - cTable.Rows.Add (cRow); - } - - void WriteLayout (FieldDefinition field) - { - FieldLayoutTable flTable = m_tableWriter.GetFieldLayoutTable (); - FieldLayoutRow flRow = m_rowWriter.CreateFieldLayoutRow ( - field.Offset, - GetRidFor (field)); - - flTable.Rows.Add (flRow); - } - - void WriteLayout (TypeDefinition type) - { - ClassLayoutTable clTable = m_tableWriter.GetClassLayoutTable (); - ClassLayoutRow clRow = m_rowWriter.CreateClassLayoutRow ( - type.PackingSize, - type.ClassSize, - GetRidFor (type)); - - clTable.Rows.Add (clRow); - } - - void WriteSemantic (MethodSemanticsAttributes attrs, - IMetadataTokenProvider member, MethodDefinition meth) - { - MethodSemanticsTable msTable = m_tableWriter.GetMethodSemanticsTable (); - MethodSemanticsRow msRow = m_rowWriter.CreateMethodSemanticsRow ( - attrs, - GetRidFor (meth), - member.MetadataToken); - - msTable.Rows.Add (msRow); - } - - void SortTables () - { - TablesHeap th = m_mdWriter.GetMetadataRoot ().Streams.TablesHeap; - th.Sorted = 0; - - if (th.HasTable (NestedClassTable.RId)) - m_tableWriter.GetNestedClassTable ().Rows.Sort ( - TableComparers.NestedClass.Instance); - th.Sorted |= ((long) 1 << NestedClassTable.RId); - - if (th.HasTable (InterfaceImplTable.RId)) - m_tableWriter.GetInterfaceImplTable ().Rows.Sort ( - TableComparers.InterfaceImpl.Instance); - th.Sorted |= ((long) 1 << InterfaceImplTable.RId); - - if (th.HasTable (ConstantTable.RId)) - m_tableWriter.GetConstantTable ().Rows.Sort ( - TableComparers.Constant.Instance); - th.Sorted |= ((long) 1 << ConstantTable.RId); - - if (th.HasTable (MethodSemanticsTable.RId)) - m_tableWriter.GetMethodSemanticsTable ().Rows.Sort ( - TableComparers.MethodSem.Instance); - th.Sorted |= ((long) 1 << MethodSemanticsTable.RId); - - if (th.HasTable (FieldMarshalTable.RId)) - m_tableWriter.GetFieldMarshalTable ().Rows.Sort ( - TableComparers.FieldMarshal.Instance); - th.Sorted |= ((long) 1 << FieldMarshalTable.RId); - - if (th.HasTable (ClassLayoutTable.RId)) - m_tableWriter.GetClassLayoutTable ().Rows.Sort ( - TableComparers.TypeLayout.Instance); - th.Sorted |= ((long) 1 << ClassLayoutTable.RId); - - if (th.HasTable (FieldLayoutTable.RId)) - m_tableWriter.GetFieldLayoutTable ().Rows.Sort ( - TableComparers.FieldLayout.Instance); - th.Sorted |= ((long) 1 << FieldLayoutTable.RId); - - if (th.HasTable (ImplMapTable.RId)) - m_tableWriter.GetImplMapTable ().Rows.Sort ( - TableComparers.PInvoke.Instance); - th.Sorted |= ((long) 1 << ImplMapTable.RId); - - if (th.HasTable (FieldRVATable.RId)) - m_tableWriter.GetFieldRVATable ().Rows.Sort ( - TableComparers.FieldRVA.Instance); - th.Sorted |= ((long) 1 << FieldRVATable.RId); - - if (th.HasTable (MethodImplTable.RId)) - m_tableWriter.GetMethodImplTable ().Rows.Sort ( - TableComparers.Override.Instance); - th.Sorted |= ((long) 1 << MethodImplTable.RId); - - if (th.HasTable (CustomAttributeTable.RId)) - m_tableWriter.GetCustomAttributeTable ().Rows.Sort ( - TableComparers.CustomAttribute.Instance); - th.Sorted |= ((long) 1 << CustomAttributeTable.RId); - - if (th.HasTable (DeclSecurityTable.RId)) - m_tableWriter.GetDeclSecurityTable ().Rows.Sort ( - TableComparers.SecurityDeclaration.Instance); - th.Sorted |= ((long) 1 << DeclSecurityTable.RId); - } - - void CompleteGenericTables () - { - if (m_genericParamStack.Count == 0) - return; - - TablesHeap th = m_mdWriter.GetMetadataRoot ().Streams.TablesHeap; - GenericParamTable gpTable = m_tableWriter.GetGenericParamTable (); - GenericParamConstraintTable gpcTable = m_tableWriter.GetGenericParamConstraintTable (); - - m_genericParamStack.Sort (TableComparers.GenericParam.Instance); - - foreach (GenericParameter gp in m_genericParamStack) { - GenericParamRow gpRow = m_rowWriter.CreateGenericParamRow ( - (ushort) gp.Owner.GenericParameters.IndexOf (gp), - gp.Attributes, - gp.Owner.MetadataToken, - m_mdWriter.AddString (gp.Name)); - - gpTable.Rows.Add (gpRow); - gp.MetadataToken = new MetadataToken (TokenType.GenericParam, (uint) gpTable.Rows.Count); - - VisitCustomAttributeCollection (gp.CustomAttributes); - - if (gp.Constraints.Count == 0) - continue; - - foreach (TypeReference constraint in gp.Constraints) { - GenericParamConstraintRow gpcRow = m_rowWriter.CreateGenericParamConstraintRow ( - (uint) gpTable.Rows.Count, - GetTypeDefOrRefToken (constraint)); - - gpcTable.Rows.Add (gpcRow); - } - } - - th.Sorted |= ((long) 1 << GenericParamTable.RId); - th.Sorted |= ((long) 1 << GenericParamConstraintTable.RId); - } - - public override void TerminateModuleDefinition (ModuleDefinition module) - { - VisitCustomAttributeCollection (module.Assembly.CustomAttributes); - VisitSecurityDeclarationCollection (module.Assembly.SecurityDeclarations); - VisitCustomAttributeCollection (module.CustomAttributes); - - CompleteGenericTables (); - SortTables (); - - MethodTable mTable = m_tableWriter.GetMethodTable (); - for (int i = 0; i < m_methodStack.Count; i++) { - MethodDefinition meth = (MethodDefinition) m_methodStack [i]; - if (meth.HasBody) - mTable [i].RVA = m_codeWriter.WriteMethodBody (meth); - } - - if (m_fieldStack.Count > 0) { - FieldRVATable frTable = null; - foreach (FieldDefinition field in m_fieldStack) { - if (field.InitialValue != null && field.InitialValue.Length > 0) { - if (frTable == null) - frTable = m_tableWriter.GetFieldRVATable (); - - FieldRVARow frRow = m_rowWriter.CreateFieldRVARow ( - m_mdWriter.GetDataCursor (), - field.MetadataToken.RID); - - m_mdWriter.AddData (field.InitialValue.Length + 3 & (~3)); - m_mdWriter.AddFieldInitData (field.InitialValue); - - frTable.Rows.Add (frRow); - } - } - } - - if (m_symbolWriter != null) - m_symbolWriter.Dispose (); - - if (m_mod.Assembly.EntryPoint != null) - m_mdWriter.EntryPointToken = - ((uint) TokenType.Method) | GetRidFor (m_mod.Assembly.EntryPoint); - - m_mod.Image.MetadataRoot.Accept (m_mdWriter); - } - - public static ElementType GetCorrespondingType (string fullName) - { - switch (fullName) { - case Constants.Boolean : - return ElementType.Boolean; - case Constants.Char : - return ElementType.Char; - case Constants.SByte : - return ElementType.I1; - case Constants.Int16 : - return ElementType.I2; - case Constants.Int32 : - return ElementType.I4; - case Constants.Int64 : - return ElementType.I8; - case Constants.Byte : - return ElementType.U1; - case Constants.UInt16 : - return ElementType.U2; - case Constants.UInt32 : - return ElementType.U4; - case Constants.UInt64 : - return ElementType.U8; - case Constants.Single : - return ElementType.R4; - case Constants.Double : - return ElementType.R8; - case Constants.String : - return ElementType.String; - case Constants.Type : - return ElementType.Type; - case Constants.Object : - return ElementType.Object; - default: - return ElementType.Class; - } - } - - byte [] EncodeConstant (ElementType et, object value) - { - m_constWriter.Empty (); - - if (value == null) - et = ElementType.Class; - - IConvertible ic = value as IConvertible; - IFormatProvider fp = CultureInfo.CurrentCulture.NumberFormat; - - switch (et) { - case ElementType.Boolean : - m_constWriter.Write ((byte) (ic.ToBoolean (fp) ? 1 : 0)); - break; - case ElementType.Char : - m_constWriter.Write ((ushort) ic.ToChar (fp)); - break; - case ElementType.I1 : - m_constWriter.Write (ic.ToSByte (fp)); - break; - case ElementType.I2 : - m_constWriter.Write (ic.ToInt16 (fp)); - break; - case ElementType.I4 : - m_constWriter.Write (ic.ToInt32 (fp)); - break; - case ElementType.I8 : - m_constWriter.Write (ic.ToInt64 (fp)); - break; - case ElementType.U1 : - m_constWriter.Write (ic.ToByte (fp)); - break; - case ElementType.U2 : - m_constWriter.Write (ic.ToUInt16 (fp)); - break; - case ElementType.U4 : - m_constWriter.Write (ic.ToUInt32 (fp)); - break; - case ElementType.U8 : - m_constWriter.Write (ic.ToUInt64 (fp)); - break; - case ElementType.R4 : - m_constWriter.Write (ic.ToSingle (fp)); - break; - case ElementType.R8 : - m_constWriter.Write (ic.ToDouble (fp)); - break; - case ElementType.String : - m_constWriter.Write (Encoding.Unicode.GetBytes ((string) value)); - break; - case ElementType.Class : - m_constWriter.Write (new byte [4]); - break; - default : - throw new ArgumentException ("Non valid element for a constant"); - } - - return m_constWriter.ToArray (); - } - - public SigType GetSigType (TypeReference type) - { - string name = type.FullName; - - switch (name) { - case Constants.Void : - return new SigType (ElementType.Void); - case Constants.Object : - return new SigType (ElementType.Object); - case Constants.Boolean : - return new SigType (ElementType.Boolean); - case Constants.String : - return new SigType (ElementType.String); - case Constants.Char : - return new SigType (ElementType.Char); - case Constants.SByte : - return new SigType (ElementType.I1); - case Constants.Byte : - return new SigType (ElementType.U1); - case Constants.Int16 : - return new SigType (ElementType.I2); - case Constants.UInt16 : - return new SigType (ElementType.U2); - case Constants.Int32 : - return new SigType (ElementType.I4); - case Constants.UInt32 : - return new SigType (ElementType.U4); - case Constants.Int64 : - return new SigType (ElementType.I8); - case Constants.UInt64 : - return new SigType (ElementType.U8); - case Constants.Single : - return new SigType (ElementType.R4); - case Constants.Double : - return new SigType (ElementType.R8); - case Constants.IntPtr : - return new SigType (ElementType.I); - case Constants.UIntPtr : - return new SigType (ElementType.U); - case Constants.TypedReference : - return new SigType (ElementType.TypedByRef); - } - - if (type is GenericParameter) { - GenericParameter gp = type as GenericParameter; - int pos = gp.Owner.GenericParameters.IndexOf (gp); - if (gp.Owner is TypeReference) - return new VAR (pos); - else if (gp.Owner is MethodReference) - return new MVAR (pos); - else - throw new ReflectionException ("Unkown generic parameter type"); - } else if (type is GenericInstanceType) { - GenericInstanceType git = type as GenericInstanceType; - GENERICINST gi = new GENERICINST (); - gi.ValueType = git.IsValueType; - gi.Type = GetTypeDefOrRefToken (git.ElementType); - gi.Signature = new GenericInstSignature (); - gi.Signature.Arity = git.GenericArguments.Count; - gi.Signature.Types = new GenericArg [gi.Signature.Arity]; - for (int i = 0; i < git.GenericArguments.Count; i++) - gi.Signature.Types [i] = GetGenericArgSig (git.GenericArguments [i]); - - return gi; - } else if (type is ArrayType) { - ArrayType aryType = type as ArrayType; - if (aryType.IsSizedArray) { - SZARRAY szary = new SZARRAY (); - szary.CustomMods = GetCustomMods (aryType.ElementType); - szary.Type = GetSigType (aryType.ElementType); - return szary; - } - - // not optimized - ArrayShape shape = new ArrayShape (); - shape.Rank = aryType.Dimensions.Count; - shape.NumSizes = 0; - - for (int i = 0; i < shape.Rank; i++) { - ArrayDimension dim = aryType.Dimensions [i]; - if (dim.UpperBound > 0) - shape.NumSizes++; - } - - shape.Sizes = new int [shape.NumSizes]; - shape.NumLoBounds = shape.Rank; - shape.LoBounds = new int [shape.NumLoBounds]; - - for (int i = 0; i < shape.Rank; i++) { - ArrayDimension dim = aryType.Dimensions [i]; - shape.LoBounds [i] = dim.LowerBound; - if (dim.UpperBound > 0) - shape.Sizes [i] = dim.UpperBound - dim.LowerBound + 1; - } - - ARRAY ary = new ARRAY (); - ary.Shape = shape; - ary.CustomMods = GetCustomMods (aryType.ElementType); - ary.Type = GetSigType (aryType.ElementType); - return ary; - } else if (type is PointerType) { - PTR p = new PTR (); - TypeReference elementType = (type as PointerType).ElementType; - p.Void = elementType.FullName == Constants.Void; - if (!p.Void) { - p.CustomMods = GetCustomMods (elementType); - p.PtrType = GetSigType (elementType); - } - return p; - } else if (type is FunctionPointerType) { - FNPTR fp = new FNPTR (); - FunctionPointerType fptr = type as FunctionPointerType; - - int sentinel = fptr.GetSentinel (); - if (sentinel < 0) - fp.Method = GetMethodDefSig (fptr); - else - fp.Method = GetMethodRefSig (fptr); - - return fp; - } else if (type is TypeSpecification) { - return GetSigType ((type as TypeSpecification).ElementType); - } else if (type.IsValueType) { - VALUETYPE vt = new VALUETYPE (); - vt.Type = GetTypeDefOrRefToken (type); - return vt; - } else { - CLASS c = new CLASS (); - c.Type = GetTypeDefOrRefToken (type); - return c; - } - } - - public GenericArg GetGenericArgSig (TypeReference type) - { - GenericArg arg = new GenericArg (GetSigType (type)); - arg.CustomMods = GetCustomMods (type); - return arg; - } - - public CustomMod [] GetCustomMods (TypeReference type) - { - ModType modifier = type as ModType; - if (modifier == null) - return new CustomMod [0]; - - ArrayList cmods = new ArrayList (); - do { - CustomMod cmod = new CustomMod (); - cmod.TypeDefOrRef = GetTypeDefOrRefToken (modifier.ModifierType); - - if (modifier is ModifierOptional) - cmod.CMOD = CustomMod.CMODType.OPT; - else if (modifier is ModifierRequired) - cmod.CMOD = CustomMod.CMODType.REQD; - - cmods.Add (cmod); - modifier = modifier.ElementType as ModType; - } while (modifier != null); - - return cmods.ToArray (typeof (CustomMod)) as CustomMod []; - } - - public Signature GetMemberRefSig (MemberReference member) - { - if (member is FieldReference) - return GetFieldSig (member as FieldReference); - else - return GetMemberRefSig (member as MethodReference); - } - - public FieldSig GetFieldSig (FieldReference field) - { - FieldSig sig = new FieldSig (); - sig.CallingConvention |= 0x6; - sig.Field = true; - sig.CustomMods = GetCustomMods (field.FieldType); - sig.Type = GetSigType (field.FieldType); - return sig; - } - - Param [] GetParametersSig (ParameterDefinitionCollection parameters) - { - Param [] ret = new Param [parameters.Count]; - for (int i = 0; i < ret.Length; i++) { - ParameterDefinition pDef = parameters [i]; - Param p = new Param (); - p.CustomMods = GetCustomMods (pDef.ParameterType); - if (pDef.ParameterType.FullName == Constants.TypedReference) - p.TypedByRef = true; - else if (IsByReferenceType (pDef.ParameterType)) { - p.ByRef = true; - p.Type = GetSigType (pDef.ParameterType); - } else - p.Type = GetSigType (pDef.ParameterType); - ret [i] = p; - } - return ret; - } - - void CompleteMethodSig (IMethodSignature meth, MethodSig sig) - { - sig.HasThis = meth.HasThis; - sig.ExplicitThis = meth.ExplicitThis; - if (sig.HasThis) - sig.CallingConvention |= 0x20; - if (sig.ExplicitThis) - sig.CallingConvention |= 0x40; - - if ((meth.CallingConvention & MethodCallingConvention.VarArg) != 0) - sig.CallingConvention |= 0x5; - - sig.ParamCount = meth.Parameters.Count; - sig.Parameters = GetParametersSig (meth.Parameters); - - RetType rtSig = new RetType (); - rtSig.CustomMods = GetCustomMods (meth.ReturnType.ReturnType); - - if (meth.ReturnType.ReturnType.FullName == Constants.Void) - rtSig.Void = true; - else if (meth.ReturnType.ReturnType.FullName == Constants.TypedReference) - rtSig.TypedByRef = true; - else if (IsByReferenceType (meth.ReturnType.ReturnType)) { - rtSig.ByRef = true; - rtSig.Type = GetSigType (meth.ReturnType.ReturnType); - } else - rtSig.Type = GetSigType (meth.ReturnType.ReturnType); - - sig.RetType = rtSig; - } - - static bool IsByReferenceType (TypeReference type) - { - TypeSpecification ts = type as TypeSpecification; - while (ts != null) { - if (ts is ReferenceType) - return true; - ts = ts.ElementType as TypeSpecification; - } - return false; - } - - public MethodRefSig GetMethodRefSig (IMethodSignature meth) - { - MethodReference methodRef = meth as MethodReference; - if (methodRef != null && methodRef.GenericParameters.Count > 0) - return GetMethodDefSig (meth); - - MethodRefSig methSig = new MethodRefSig (); - - CompleteMethodSig (meth, methSig); - - int sentinel = meth.GetSentinel (); - if (sentinel >= 0) - methSig.Sentinel = sentinel; - - if ((meth.CallingConvention & MethodCallingConvention.C) != 0) - methSig.CallingConvention |= 0x1; - else if ((meth.CallingConvention & MethodCallingConvention.StdCall) != 0) - methSig.CallingConvention |= 0x2; - else if ((meth.CallingConvention & MethodCallingConvention.ThisCall) != 0) - methSig.CallingConvention |= 0x3; - else if ((meth.CallingConvention & MethodCallingConvention.FastCall) != 0) - methSig.CallingConvention |= 0x4; - - return methSig; - } - - public MethodDefSig GetMethodDefSig (IMethodSignature meth) - { - MethodDefSig sig = new MethodDefSig (); - - CompleteMethodSig (meth, sig); - - MethodReference methodRef = meth as MethodReference; - if (methodRef != null && methodRef.GenericParameters.Count > 0) { - sig.CallingConvention |= 0x10; - sig.GenericParameterCount = methodRef.GenericParameters.Count; - } - - return sig; - } - - public PropertySig GetPropertySig (PropertyDefinition prop) - { - PropertySig ps = new PropertySig (); - ps.CallingConvention |= 0x8; - - bool hasThis; - bool explicitThis; - MethodCallingConvention mcc; - ParameterDefinitionCollection parameters = prop.Parameters; - - MethodDefinition meth; - if (prop.GetMethod != null) - meth = prop.GetMethod; - else if (prop.SetMethod != null) - meth = prop.SetMethod; - else - meth = null; - - if (meth != null) { - hasThis = meth.HasThis; - explicitThis = meth.ExplicitThis; - mcc = meth.CallingConvention; - } else { - hasThis = explicitThis = false; - mcc = MethodCallingConvention.Default; - } - - if (hasThis) - ps.CallingConvention |= 0x20; - if (explicitThis) - ps.CallingConvention |= 0x40; - - if ((mcc & MethodCallingConvention.VarArg) != 0) - ps.CallingConvention |= 0x5; - - int paramCount = parameters != null ? parameters.Count : 0; - - ps.ParamCount = paramCount; - ps.Parameters = GetParametersSig (parameters); - ps.CustomMods = GetCustomMods (prop.PropertyType); - ps.Type = GetSigType (prop.PropertyType); - - return ps; - } - - public TypeSpec GetTypeSpecSig (TypeReference type) - { - TypeSpec ts = new TypeSpec (); - ts.CustomMods = GetCustomMods (type); - ts.Type = GetSigType (type); - return ts; - } - - public MethodSpec GetMethodSpecSig (GenericInstanceMethod gim) - { - GenericInstSignature gis = new GenericInstSignature (); - gis.Arity = gim.GenericArguments.Count; - gis.Types = new GenericArg [gis.Arity]; - for (int i = 0; i < gis.Arity; i++) - gis.Types [i] = GetGenericArgSig (gim.GenericArguments [i]); - - return new MethodSpec (gis); - } - - static string GetObjectTypeName (object o) - { - Type t = o.GetType (); - return string.Concat (t.Namespace, ".", t.Name); - } - - static CustomAttrib.Elem CreateElem (TypeReference type, object value) - { - CustomAttrib.Elem elem = new CustomAttrib.Elem (); - elem.Value = value; - elem.ElemType = type; - elem.FieldOrPropType = GetCorrespondingType (type.FullName); - - switch (elem.FieldOrPropType) { - case ElementType.Boolean : - case ElementType.Char : - case ElementType.R4 : - case ElementType.R8 : - case ElementType.I1 : - case ElementType.I2 : - case ElementType.I4 : - case ElementType.I8 : - case ElementType.U1 : - case ElementType.U2 : - case ElementType.U4 : - case ElementType.U8 : - elem.Simple = true; - break; - case ElementType.String: - elem.String = true; - break; - case ElementType.Type: - elem.Type = true; - break; - case ElementType.Object: - elem.BoxedValueType = true; - if (value == null) - elem.FieldOrPropType = ElementType.String; - else - elem.FieldOrPropType = GetCorrespondingType ( - GetObjectTypeName (value)); - break; - } - - return elem; - } - - static CustomAttrib.FixedArg CreateFixedArg (TypeReference type, object value) - { - CustomAttrib.FixedArg fa = new CustomAttrib.FixedArg (); - if (value is object []) { - fa.SzArray = true; - object [] values = value as object []; - TypeReference obj = ((ArrayType) type).ElementType; - fa.NumElem = (uint) values.Length; - fa.Elems = new CustomAttrib.Elem [values.Length]; - for (int i = 0; i < values.Length; i++) - fa.Elems [i] = CreateElem (obj, values [i]); - } else { - fa.Elems = new CustomAttrib.Elem [1]; - fa.Elems [0] = CreateElem (type, value); - } - - return fa; - } - - static CustomAttrib.NamedArg CreateNamedArg (TypeReference type, string name, - object value, bool field) - { - CustomAttrib.NamedArg na = new CustomAttrib.NamedArg (); - na.Field = field; - na.Property = !field; - - na.FieldOrPropName = name; - na.FieldOrPropType = GetCorrespondingType (type.FullName); - na.FixedArg = CreateFixedArg (type, value); - - return na; - } - - public static CustomAttrib GetCustomAttributeSig (CustomAttribute ca) - { - CustomAttrib cas = new CustomAttrib (ca.Constructor); - cas.Prolog = CustomAttrib.StdProlog; - - cas.FixedArgs = new CustomAttrib.FixedArg [ca.Constructor.Parameters.Count]; - - for (int i = 0; i < cas.FixedArgs.Length; i++) - cas.FixedArgs [i] = CreateFixedArg ( - ca.Constructor.Parameters [i].ParameterType, ca.ConstructorParameters [i]); - - int nn = ca.Fields.Count + ca.Properties.Count; - cas.NumNamed = (ushort) nn; - cas.NamedArgs = new CustomAttrib.NamedArg [nn]; - - if (cas.NamedArgs.Length > 0) { - int curs = 0; - foreach (DictionaryEntry entry in ca.Fields) { - string field = (string) entry.Key; - cas.NamedArgs [curs++] = CreateNamedArg ( - ca.GetFieldType (field), field, entry.Value, true); - } - - foreach (DictionaryEntry entry in ca.Properties) { - string property = (string) entry.Key; - cas.NamedArgs [curs++] = CreateNamedArg ( - ca.GetPropertyType (property), property, entry.Value, false); - } - } - - return cas; - } - - static MarshalSig GetMarshalSig (MarshalSpec mSpec) - { - MarshalSig ms = new MarshalSig (mSpec.NativeIntrinsic); - - if (mSpec is ArrayMarshalSpec) { - ArrayMarshalSpec amd = mSpec as ArrayMarshalSpec; - MarshalSig.Array ar = new MarshalSig.Array (); - ar.ArrayElemType = amd.ElemType; - ar.NumElem = amd.NumElem; - ar.ParamNum = amd.ParamNum; - ar.ElemMult = amd.ElemMult; - ms.Spec = ar; - } else if (mSpec is CustomMarshalerSpec) { - CustomMarshalerSpec cmd = mSpec as CustomMarshalerSpec; - MarshalSig.CustomMarshaler cm = new MarshalSig.CustomMarshaler (); - cm.Guid = cmd.Guid.ToString (); - cm.UnmanagedType = cmd.UnmanagedType; - cm.ManagedType = cmd.ManagedType; - cm.Cookie = cmd.Cookie; - ms.Spec = cm; - } else if (mSpec is FixedArraySpec) { - FixedArraySpec fad = mSpec as FixedArraySpec; - MarshalSig.FixedArray fa = new MarshalSig.FixedArray (); - fa.ArrayElemType = fad.ElemType; - fa.NumElem = fad.NumElem; - ms.Spec = fa; - } else if (mSpec is FixedSysStringSpec) { - MarshalSig.FixedSysString fss = new MarshalSig.FixedSysString (); - fss.Size = (mSpec as FixedSysStringSpec).Size; - ms.Spec = fss; - } else if (mSpec is SafeArraySpec) { - MarshalSig.SafeArray sa = new MarshalSig.SafeArray (); - sa.ArrayElemType = (mSpec as SafeArraySpec).ElemType; - ms.Spec = sa; - } - - return ms; - } - - public void WriteSymbols (ModuleDefinition module) - { - if (!m_saveSymbols) - return; - - if (m_asmOutput == null) - m_asmOutput = module.Assembly.Name.Name + "." + (module.Assembly.Kind == AssemblyKind.Dll ? "dll" : "exe"); - - if (m_symbolWriter == null) - m_symbolWriter = SymbolStoreHelper.GetWriter (module, m_asmOutput); - - foreach (TypeDefinition type in module.Types) { - foreach (MethodDefinition method in type.Methods) - WriteSymbols (method); - foreach (MethodDefinition ctor in type.Constructors) - WriteSymbols (ctor); - } - - m_symbolWriter.Dispose (); - } - - void WriteSymbols (MethodDefinition meth) - { - if (!meth.HasBody) - return; - - m_symbolWriter.Write (meth.Body, GetVariablesSig (meth)); - } - - byte [][] GetVariablesSig (MethodDefinition meth) - { - VariableDefinitionCollection variables = meth.Body.Variables; - byte [][] signatures = new byte [variables.Count][]; - for (int i = 0; i < variables.Count; i++) { - signatures [i] = GetVariableSig (variables [i]); - } - return signatures; - } - - byte [] GetVariableSig (VariableDefinition var) - { - return m_sigWriter.CompressLocalVar (m_codeWriter.GetLocalVariableSig (var)); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ResourceCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ResourceCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ResourceCollection.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ResourceCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ -// -// ResourceCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Wed Sep 27 12:46:54 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.Collections; - - using Mono.Cecil.Cil; - - public sealed class ResourceCollection : CollectionBase, IReflectionStructureVisitable { - - ModuleDefinition m_container; - - public Resource this [int index] { - get { return List [index] as Resource; } - set { List [index] = value; } - } - - public ModuleDefinition Container { - get { return m_container; } - } - - public ResourceCollection (ModuleDefinition container) - { - m_container = container; - } - - public void Add (Resource value) - { - List.Add (value); - } - - public bool Contains (Resource value) - { - return List.Contains (value); - } - - public int IndexOf (Resource value) - { - return List.IndexOf (value); - } - - public void Insert (int index, Resource value) - { - List.Insert (index, value); - } - - public void Remove (Resource value) - { - List.Remove (value); - } - - protected override void OnValidate (object o) - { - if (! (o is Resource)) - throw new ArgumentException ("Must be of type " + typeof (Resource).FullName); - } - - public void Accept (IReflectionStructureVisitor visitor) - { - visitor.VisitResourceCollection (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Resource.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Resource.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Resource.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Resource.cs 2011-04-13 09:00:29.000000000 +0000 @@ -1,10 +1,10 @@ // -// Resource.cs +// ResourceType.cs // // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -28,64 +28,49 @@ namespace Mono.Cecil { - using System.Collections; + public enum ResourceType { + Linked, + Embedded, + AssemblyLinked, + } - public abstract class Resource : IAnnotationProvider, IReflectionStructureVisitable { + public abstract class Resource { - string m_name; - ManifestResourceAttributes m_attributes; - IDictionary m_annotations; + string name; + uint attributes; public string Name { - get { return m_name; } - set { m_name = value; } + get { return name; } + set { name = value; } } - public ManifestResourceAttributes Flags { - get { return m_attributes; } - set { m_attributes = value; } + public ManifestResourceAttributes Attributes { + get { return (ManifestResourceAttributes) attributes; } + set { attributes = (uint) value; } } - IDictionary IAnnotationProvider.Annotations { - get { - if (m_annotations == null) - m_annotations = new Hashtable (); - return m_annotations; - } + public abstract ResourceType ResourceType { + get; } #region ManifestResourceAttributes public bool IsPublic { - get { return (m_attributes & ManifestResourceAttributes.VisibilityMask) == ManifestResourceAttributes.Public; } - set { - if (value) { - m_attributes &= ~ManifestResourceAttributes.VisibilityMask; - m_attributes |= ManifestResourceAttributes.Public; - } else - m_attributes &= ~(ManifestResourceAttributes.VisibilityMask & ManifestResourceAttributes.Public); - } + get { return attributes.GetMaskedAttributes ((uint) ManifestResourceAttributes.VisibilityMask, (uint) ManifestResourceAttributes.Public); } + set { attributes = attributes.SetMaskedAttributes ((uint) ManifestResourceAttributes.VisibilityMask, (uint) ManifestResourceAttributes.Public, value); } } public bool IsPrivate { - get { return (m_attributes & ManifestResourceAttributes.VisibilityMask) == ManifestResourceAttributes.Private; } - set { - if (value) { - m_attributes &= ~ManifestResourceAttributes.VisibilityMask; - m_attributes |= ManifestResourceAttributes.Private; - } else - m_attributes &= ~(ManifestResourceAttributes.VisibilityMask & ManifestResourceAttributes.Private); - } + get { return attributes.GetMaskedAttributes ((uint) ManifestResourceAttributes.VisibilityMask, (uint) ManifestResourceAttributes.Private); } + set { attributes = attributes.SetMaskedAttributes ((uint) ManifestResourceAttributes.VisibilityMask, (uint) ManifestResourceAttributes.Private, value); } } #endregion internal Resource (string name, ManifestResourceAttributes attributes) { - m_name = name; - m_attributes = attributes; + this.name = name; + this.attributes = (uint) attributes; } - - public abstract void Accept (IReflectionStructureVisitor visitor); } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityAction.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityAction.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityAction.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityAction.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// -// SecurityAction.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - public enum SecurityAction : short { - Request = 1, - Demand = 2, - Assert = 3, - Deny = 4, - PermitOnly = 5, - LinkDemand = 6, - InheritDemand = 7, - RequestMinimum = 8, - RequestOptional = 9, - RequestRefuse = 10, - PreJitGrant = 11, - PreJitDeny = 12, - NonCasDemand = 13, - NonCasLinkDemand = 14, - NonCasInheritance = 15 - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityDeclarationCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityDeclarationCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityDeclarationCollection.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityDeclarationCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,157 +0,0 @@ -// -// SecurityDeclarationCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.Collections; - - public sealed class SecurityDeclarationCollection : IReflectionVisitable { - - IDictionary m_items; - IHasSecurity m_container; - - public SecurityDeclaration this [int index] { - get { return m_items [index] as SecurityDeclaration; } - set { m_items [index] = value; } - } - - public SecurityDeclaration this [SecurityAction action] { - get { return m_items [action] as SecurityDeclaration; } - set { m_items [action] = value; } - } - - public IHasSecurity Container { - get { return m_container; } - } - - public int Count { - get { return m_items.Count; } - } - - public bool IsSynchronized { - get { return false; } - } - - public object SyncRoot { - get { return this; } - } - - public SecurityDeclarationCollection (IHasSecurity container) - { - m_container = container; - m_items = new Hashtable (); - } - - public void Add (SecurityDeclaration value) - { - if (value == null) - throw new ArgumentNullException ("value"); - - // Each action can only be added once so... - SecurityDeclaration current = (SecurityDeclaration) m_items[value.Action]; - if (current != null) { - // ... further additions are transformed into unions -#if !CF_1_0 && !CF_2_0 - current.PermissionSet = current.PermissionSet.Union (value.PermissionSet); -#endif - } else { - m_items.Add (value.Action, value); - SetHasSecurity (true); - } - } - - public void Clear () - { - m_items.Clear (); - SetHasSecurity (false); - } - - public bool Contains (SecurityAction action) - { - return (m_items [action] != null); - } - - public bool Contains (SecurityDeclaration value) - { - if (value == null) - return (m_items.Count == 0); - - SecurityDeclaration item = (SecurityDeclaration) m_items[value.Action]; - if (item == null) - return false; - -#if !CF_1_0 && !CF_2_0 - return value.PermissionSet.IsSubsetOf (item.PermissionSet); -#else - // XXX For CF, this concept does not exist--so always be true - return true; -#endif - } - - public void Remove (SecurityAction action) - { - m_items.Remove (action); - SetHasSecurity (this.Count > 0); - } - - public void CopyTo (Array ary, int index) - { - m_items.Values.CopyTo (ary, index); - } - - public IEnumerator GetEnumerator () - { - return m_items.Values.GetEnumerator (); - } - - public void Accept (IReflectionVisitor visitor) - { - visitor.VisitSecurityDeclarationCollection (this); - } - - private void SetHasSecurity (bool value) - { - TypeDefinition td = (m_container as TypeDefinition); - if (td != null) { - if (value) - td.Attributes |= TypeAttributes.HasSecurity; - else - td.Attributes &= ~TypeAttributes.HasSecurity; - return; - } - MethodDefinition md = (m_container as MethodDefinition); - if (md != null) { - if (value) - md.Attributes |= MethodAttributes.HasSecurity; - else - md.Attributes &= ~MethodAttributes.HasSecurity; - } - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityDeclaration.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityDeclaration.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityDeclaration.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityDeclaration.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,89 +26,157 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System; + +using Mono.Collections.Generic; + namespace Mono.Cecil { - using System; - using System.Collections; - using System.Security; + public enum SecurityAction : ushort { + Request = 1, + Demand = 2, + Assert = 3, + Deny = 4, + PermitOnly = 5, + LinkDemand = 6, + InheritDemand = 7, + RequestMinimum = 8, + RequestOptional = 9, + RequestRefuse = 10, + PreJitGrant = 11, + PreJitDeny = 12, + NonCasDemand = 13, + NonCasLinkDemand = 14, + NonCasInheritance = 15 + } - public sealed class SecurityDeclaration : IRequireResolving, IAnnotationProvider, IReflectionVisitable { + public interface ISecurityDeclarationProvider : IMetadataTokenProvider { - SecurityAction m_action; - IDictionary m_annotations; + bool HasSecurityDeclarations { get; } + Collection SecurityDeclarations { get; } + } -#if !CF_1_0 && !CF_2_0 - PermissionSet m_permSet; -#endif + public sealed class SecurityAttribute : ICustomAttribute { - bool m_resolved; - byte [] m_blob; + TypeReference attribute_type; - public SecurityAction Action { - get { return m_action; } - set { m_action = value; } + internal Collection fields; + internal Collection properties; + + public TypeReference AttributeType { + get { return attribute_type; } + set { attribute_type = value; } + } + + public bool HasFields { + get { return !fields.IsNullOrEmpty (); } + } + + public Collection Fields { + get { return fields ?? (fields = new Collection ()); } } -#if !CF_1_0 && !CF_2_0 - public PermissionSet PermissionSet { - get { return m_permSet; } - set { m_permSet = value; } + public bool HasProperties { + get { return !properties.IsNullOrEmpty (); } } -#endif - public bool Resolved { - get { return m_resolved; } - set { m_resolved = value; } + public Collection Properties { + get { return properties ?? (properties = new Collection ()); } } - public byte [] Blob { - get { return m_blob; } - set { m_blob = value; } + public SecurityAttribute (TypeReference attributeType) + { + this.attribute_type = attributeType; + } + } + + public sealed class SecurityDeclaration { + + readonly internal uint signature; + readonly ModuleDefinition module; + + internal bool resolved; + SecurityAction action; + internal Collection security_attributes; + + public SecurityAction Action { + get { return action; } + set { action = value; } } - IDictionary IAnnotationProvider.Annotations { + public bool HasSecurityAttributes { get { - if (m_annotations == null) - m_annotations = new Hashtable (); - return m_annotations; + Resolve (); + + return !security_attributes.IsNullOrEmpty (); } } + public Collection SecurityAttributes { + get { + Resolve (); + + return security_attributes ?? (security_attributes = new Collection ()); + } + } + + internal bool HasImage { + get { return module != null && module.HasImage; } + } + + internal SecurityDeclaration (SecurityAction action, uint signature, ModuleDefinition module) + { + this.action = action; + this.signature = signature; + this.module = module; + } + public SecurityDeclaration (SecurityAction action) { - m_action = action; - m_resolved = true; + this.action = action; + this.resolved = true; } - public SecurityDeclaration Clone () + public byte [] GetBlob () { - return Clone (this); + if (!HasImage || signature == 0) + throw new NotSupportedException (); + + return module.Read (this, (declaration, reader) => reader.ReadSecurityDeclarationBlob (declaration.signature)); ; } - internal static SecurityDeclaration Clone (SecurityDeclaration sec) + void Resolve () { - SecurityDeclaration sd = new SecurityDeclaration (sec.Action); - if (!sec.Resolved) { - sd.Resolved = false; - sd.Blob = sec.Blob; - return sd; - } + if (resolved || !HasImage) + return; -#if !CF_1_0 && !CF_2_0 - sd.PermissionSet = sec.PermissionSet.Copy (); -#endif - return sd; + module.Read (this, (declaration, reader) => { + reader.ReadSecurityDeclarationSignature (declaration); + return this; + }); + + resolved = true; } + } - public bool Resolve () + static partial class Mixin { + + public static bool GetHasSecurityDeclarations ( + this ISecurityDeclarationProvider self, + ModuleDefinition module) { - throw new NotImplementedException (); + return module.HasImage () + ? module.Read (self, (provider, reader) => reader.HasSecurityDeclarations (provider)) + : false; } - public void Accept (IReflectionVisitor visitor) + public static Collection GetSecurityDeclarations ( + this ISecurityDeclarationProvider self, + ModuleDefinition module) { - visitor.VisitSecurityDeclaration (this); + return module.HasImage () + ? module.Read (self, (provider, reader) => reader.ReadSecurityDeclarations (provider)) + : new Collection (); } } } - diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityDeclarationReader.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityDeclarationReader.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityDeclarationReader.cs 2008-11-06 19:52:04.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityDeclarationReader.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,160 +0,0 @@ -// -// SecurityDeclarationReader.cs -// -// Author: -// Sebastien Pouliot -// -// Copyright (C) 2005 Novell, Inc (http://www.novell.com) -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -namespace Mono.Cecil { - - using System; - using System.IO; - using System.Reflection; - using System.Security; - using SSP = System.Security.Permissions; - using System.Text; - - using Mono.Cecil.Metadata; - using Mono.Cecil.Signatures; - using Mono.Xml; - - internal class SecurityDeclarationReader { - - private SecurityParser m_parser; - private SignatureReader sr; - - public SecurityDeclarationReader (MetadataRoot root, ReflectionReader reader) - { - sr = new SignatureReader (root, reader); - } - - public SecurityParser Parser { - get { - if (m_parser == null) - m_parser = new SecurityParser (); - return m_parser; - } - } - - public SecurityDeclaration FromByteArray (SecurityAction action, byte [] declaration) - { - return FromByteArray (action, declaration, false); - } - - static bool IsEmptyDeclaration (byte [] declaration) - { - return declaration == null || declaration.Length == 0 || - (declaration.Length == 1 && declaration [0] == 0); - } - - public SecurityDeclaration FromByteArray (SecurityAction action, byte [] declaration, bool resolve) - { - SecurityDeclaration dec = new SecurityDeclaration (action); -#if !CF_1_0 && !CF_2_0 - dec.PermissionSet = new PermissionSet (SSP.PermissionState.None); - - if (IsEmptyDeclaration (declaration)) - return dec; - - if (declaration[0] == 0x2e) { - // new binary format introduced in 2.0 - int pos = 1; - int start; - int numattr = Utilities.ReadCompressedInteger (declaration, pos, out start); - if (numattr == 0) - return dec; - - BinaryReader br = new BinaryReader (new MemoryStream (declaration)); - for (int i = 0; i < numattr; i++) { - pos = start; - SSP.SecurityAttribute sa = CreateSecurityAttribute (action, br, declaration, pos, out start, resolve); - if (sa == null) { - dec.Resolved = false; - dec.Blob = declaration; - return dec; - } - - IPermission p = sa.CreatePermission (); - dec.PermissionSet.AddPermission (p); - } - } else { - Parser.LoadXml (Encoding.Unicode.GetString (declaration)); - try { - dec.PermissionSet.FromXml (Parser.ToXml ()); - dec.PermissionSet.ToXml (); - } catch { - dec.Resolved = false; - dec.Blob = declaration; - } - } -#endif - return dec; - } - -#if !CF_1_0 && !CF_2_0 - private SSP.SecurityAttribute CreateSecurityAttribute (SecurityAction action, BinaryReader br, byte [] permset, int pos, out int start, bool resolve) - { - string cname = SignatureReader.ReadUTF8String (permset, pos, out start); - Type secattr = null; - - // note: the SecurityAction parameter isn't important to generate the XML - SSP.SecurityAttribute sa = null; - try { - secattr = Type.GetType (cname, false); - if (secattr == null) - return null; - - sa = Activator.CreateInstance (secattr, new object [] {(SSP.SecurityAction) action}) as SSP.SecurityAttribute; - } catch {} - - if (sa == null) - return null; - - // encoded length of all parameters (we don't need the value - except the updated pos) - Utilities.ReadCompressedInteger (permset, start, out pos); - int numparams = Utilities.ReadCompressedInteger (permset, pos, out start); - if (numparams == 0) - return sa; - - br.BaseStream.Position = start; - for (int j = 0; j < numparams; j++) { - bool read = false; - CustomAttrib.NamedArg na = sr.ReadNamedArg (permset, br, ref read, resolve); - if (!read) - return null; - - if (na.Field) { - FieldInfo fi = secattr.GetField (na.FieldOrPropName); - fi.SetValue (sa, na.FixedArg.Elems[0].Value); - } else if (na.Property) { - PropertyInfo pi = secattr.GetProperty (na.FieldOrPropName); - pi.SetValue (sa, na.FixedArg.Elems[0].Value, null); - } - } - - return sa; - } -#endif - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SentinelType.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SentinelType.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SentinelType.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SentinelType.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2007 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,12 +26,28 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System; + +using MD = Mono.Cecil.Metadata; + namespace Mono.Cecil { public sealed class SentinelType : TypeSpecification { - public SentinelType (TypeReference elementType) : base (elementType) + public override bool IsValueType { + get { return false; } + set { throw new InvalidOperationException (); } + } + + public override bool IsSentinel { + get { return true; } + } + + public SentinelType (TypeReference type) + : base (type) { + Mixin.CheckType (type); + this.etype = MD.ElementType.Sentinel; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/StructureReader.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/StructureReader.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/StructureReader.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/StructureReader.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,274 +0,0 @@ -// -// StructureReader.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.IO; - - using Mono.Cecil.Binary; - using Mono.Cecil.Metadata; - - internal sealed class StructureReader : BaseStructureVisitor { - - ImageReader m_ir; - Image m_img; - bool m_manifestOnly; - AssemblyDefinition m_asmDef; - ModuleDefinition m_module; - MetadataStreamCollection m_streams; - TablesHeap m_tHeap; - MetadataTableReader m_tableReader; - - public bool ManifestOnly { - get { return m_manifestOnly; } - } - - public ImageReader ImageReader { - get { return m_ir; } - } - - public Image Image { - get { return m_img; } - } - - public StructureReader (ImageReader ir) - { - if (ir.Image.CLIHeader == null) - throw new ImageFormatException ("The image is not a managed assembly"); - - m_ir = ir; - m_img = ir.Image; - m_streams = m_img.MetadataRoot.Streams; - m_tHeap = m_streams.TablesHeap; - m_tableReader = ir.MetadataReader.TableReader; - } - - public StructureReader (ImageReader ir, bool manifestOnly) : this (ir) - { - m_manifestOnly = manifestOnly; - } - - byte [] ReadBlob (uint pointer) - { - if (pointer == 0) - return new byte [0]; - - return m_streams.BlobHeap.Read (pointer); - } - - string ReadString (uint pointer) - { - return m_streams.StringsHeap [pointer]; - } - - public override void VisitAssemblyDefinition (AssemblyDefinition asm) - { - if (!m_tHeap.HasTable (AssemblyTable.RId)) - throw new ReflectionException ("No assembly manifest"); - - asm.MetadataToken = new MetadataToken (TokenType.Assembly, 1); - m_asmDef = asm; - - switch (m_img.MetadataRoot.Header.Version) { - case "v1.0.3705" : - asm.Runtime = TargetRuntime.NET_1_0; - break; - case "v1.1.4322" : - asm.Runtime = TargetRuntime.NET_1_1; - break; - default : - asm.Runtime = TargetRuntime.NET_2_0; - break; - } - - if ((m_img.PEFileHeader.Characteristics & ImageCharacteristics.Dll) != 0) - asm.Kind = AssemblyKind.Dll; - else if (m_img.PEOptionalHeader.NTSpecificFields.SubSystem == SubSystem.WindowsGui || - m_img.PEOptionalHeader.NTSpecificFields.SubSystem == SubSystem.WindowsCeGui) - asm.Kind = AssemblyKind.Windows; - else - asm.Kind = AssemblyKind.Console; - } - - public override void VisitAssemblyNameDefinition (AssemblyNameDefinition name) - { - AssemblyTable atable = m_tableReader.GetAssemblyTable (); - AssemblyRow arow = atable [0]; - name.Name = ReadString (arow.Name); - name.Flags = arow.Flags; - name.PublicKey = ReadBlob (arow.PublicKey); - - name.Culture = ReadString (arow.Culture); - name.Version = new Version ( - arow.MajorVersion, arow.MinorVersion, - arow.BuildNumber, arow.RevisionNumber); - name.HashAlgorithm = arow.HashAlgId; - name.MetadataToken = new MetadataToken (TokenType.Assembly, 1); - } - - public override void VisitAssemblyNameReferenceCollection (AssemblyNameReferenceCollection names) - { - if (!m_tHeap.HasTable (AssemblyRefTable.RId)) - return; - - AssemblyRefTable arTable = m_tableReader.GetAssemblyRefTable (); - for (int i = 0; i < arTable.Rows.Count; i++) { - AssemblyRefRow arRow = arTable [i]; - AssemblyNameReference aname = new AssemblyNameReference ( - ReadString (arRow.Name), - ReadString (arRow.Culture), - new Version (arRow.MajorVersion, arRow.MinorVersion, - arRow.BuildNumber, arRow.RevisionNumber)); - aname.PublicKeyToken = ReadBlob (arRow.PublicKeyOrToken); - aname.Hash = ReadBlob (arRow.HashValue); - aname.Flags = arRow.Flags; - aname.MetadataToken = new MetadataToken (TokenType.AssemblyRef, (uint) i + 1); - names.Add (aname); - } - } - - public override void VisitResourceCollection (ResourceCollection resources) - { - if (!m_tHeap.HasTable (ManifestResourceTable.RId)) - return; - - ManifestResourceTable mrTable = m_tableReader.GetManifestResourceTable (); - FileTable fTable = m_tableReader.GetFileTable (); - - for (int i = 0; i < mrTable.Rows.Count; i++) { - ManifestResourceRow mrRow = mrTable [i]; - if (mrRow.Implementation.RID == 0) { - EmbeddedResource eres = new EmbeddedResource ( - ReadString (mrRow.Name), mrRow.Flags); - - BinaryReader br = m_ir.MetadataReader.GetDataReader ( - m_img.CLIHeader.Resources.VirtualAddress); - br.BaseStream.Position += mrRow.Offset; - - eres.Data = br.ReadBytes (br.ReadInt32 ()); - - resources.Add (eres); - continue; - } - - switch (mrRow.Implementation.TokenType) { - case TokenType.File : - FileRow fRow = fTable [(int) mrRow.Implementation.RID - 1]; - LinkedResource lres = new LinkedResource ( - ReadString (mrRow.Name), mrRow.Flags, - ReadString (fRow.Name)); - lres.Hash = ReadBlob (fRow.HashValue); - resources.Add (lres); - break; - case TokenType.AssemblyRef : - AssemblyNameReference asm = - m_module.AssemblyReferences [(int) mrRow.Implementation.RID - 1]; - AssemblyLinkedResource alr = new AssemblyLinkedResource ( - ReadString (mrRow.Name), - mrRow.Flags, asm); - resources.Add (alr); - break; - } - } - } - - public override void VisitModuleDefinitionCollection (ModuleDefinitionCollection modules) - { - ModuleTable mt = m_tableReader.GetModuleTable (); - if (mt == null || mt.Rows.Count != 1) - throw new ReflectionException ("Can not read main module"); - - ModuleRow mr = mt [0]; - string name = ReadString (mr.Name); - ModuleDefinition main = new ModuleDefinition (name, m_asmDef, this, true); - main.Mvid = m_streams.GuidHeap [mr.Mvid]; - main.MetadataToken = new MetadataToken (TokenType.Module, 1); - modules.Add (main); - m_module = main; - m_module.Accept (this); - - FileTable ftable = m_tableReader.GetFileTable (); - if (ftable == null || ftable.Rows.Count == 0) - return; - - foreach (FileRow frow in ftable.Rows) { - if (frow.Flags != FileAttributes.ContainsMetaData) - continue; - - name = ReadString (frow.Name); - FileInfo location = new FileInfo ( - m_img.FileInformation != null ? Path.Combine (m_img.FileInformation.DirectoryName, name) : name); - if (!File.Exists (location.FullName)) - throw new FileNotFoundException ("Module not found : " + name); - - try { - ImageReader module = ImageReader.Read (location.FullName); - mt = module.Image.MetadataRoot.Streams.TablesHeap [ModuleTable.RId] as ModuleTable; - if (mt == null || mt.Rows.Count != 1) - throw new ReflectionException ("Can not read module : " + name); - - mr = mt [0]; - ModuleDefinition modext = new ModuleDefinition (name, m_asmDef, - new StructureReader (module, m_manifestOnly), false); - modext.Mvid = module.Image.MetadataRoot.Streams.GuidHeap [mr.Mvid]; - - modules.Add (modext); - modext.Accept (this); - } catch (ReflectionException) { - throw; - } catch (Exception e) { - throw new ReflectionException ("Can not read module : " + name, e); - } - } - } - - public override void VisitModuleReferenceCollection (ModuleReferenceCollection modules) - { - if (!m_tHeap.HasTable (ModuleRefTable.RId)) - return; - - ModuleRefTable mrTable = m_tableReader.GetModuleRefTable (); - for (int i = 0; i < mrTable.Rows.Count; i++) { - ModuleRefRow mrRow = mrTable [i]; - ModuleReference mod = new ModuleReference (ReadString (mrRow.Name)); - mod.MetadataToken = MetadataToken.FromMetadataRow (TokenType.ModuleRef, i); - modules.Add (mod); - } - } - - public override void TerminateAssemblyDefinition (AssemblyDefinition asm) - { - if (m_manifestOnly) - return; - - foreach (ModuleDefinition mod in asm.Modules) - mod.Controller.Reader.VisitModuleDefinition (mod); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/StructureWriter.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/StructureWriter.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/StructureWriter.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/StructureWriter.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,246 +0,0 @@ -// -// StructureWriter.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.IO; - - using Mono.Cecil.Binary; - using Mono.Cecil.Metadata; - - internal sealed class StructureWriter : BaseStructureVisitor { - - MetadataWriter m_mdWriter; - MetadataTableWriter m_tableWriter; - MetadataRowWriter m_rowWriter; - - AssemblyDefinition m_asm; - BinaryWriter m_binaryWriter; - - public AssemblyDefinition Assembly { - get { return m_asm; } - } - - static void ResetImage (ModuleDefinition mod) - { - Image ni = Image.CreateImage (); - ni.Accept (new CopyImageVisitor (mod.Image)); - mod.Image = ni; - } - - public StructureWriter (AssemblyDefinition asm, BinaryWriter writer) - { - m_asm = asm; - m_binaryWriter = writer; - } - - public BinaryWriter GetWriter () - { - return m_binaryWriter; - } - - public override void VisitAssemblyDefinition (AssemblyDefinition asm) - { - if (asm.Kind != AssemblyKind.Dll && asm.EntryPoint == null) - throw new ReflectionException ("Assembly does not have an entry point defined"); - - if ((asm.MainModule.Image.CLIHeader.Flags & RuntimeImage.ILOnly) == 0) - throw new NotSupportedException ("Can not write a mixed mode assembly"); - - foreach (ModuleDefinition module in asm.Modules) - if (module.Image.CLIHeader.Metadata.VirtualAddress != RVA.Zero) - ResetImage (module); - - ReflectionWriter rw = asm.MainModule.Controller.Writer; - rw.StructureWriter = this; - - m_mdWriter = rw.MetadataWriter; - m_tableWriter = rw.MetadataTableWriter; - m_rowWriter = rw.MetadataRowWriter; - - if (!rw.SaveSymbols) - return; - - FileStream fs = m_binaryWriter.BaseStream as FileStream; - if (fs != null) - rw.OutputFile = fs.Name; - } - - public override void VisitAssemblyNameDefinition (AssemblyNameDefinition name) - { - AssemblyTable asmTable = m_tableWriter.GetAssemblyTable (); - - if (name.PublicKey != null && name.PublicKey.Length > 0) - name.Flags |= AssemblyFlags.PublicKey; - - AssemblyRow asmRow = m_rowWriter.CreateAssemblyRow ( - name.HashAlgorithm, - (ushort) name.Version.Major, - (ushort) name.Version.Minor, - (ushort) name.Version.Build, - (ushort) name.Version.Revision, - name.Flags, - m_mdWriter.AddBlob (name.PublicKey), - m_mdWriter.AddString (name.Name), - m_mdWriter.AddString (name.Culture)); - - asmTable.Rows.Add (asmRow); - } - - public override void VisitAssemblyNameReferenceCollection (AssemblyNameReferenceCollection references) - { - foreach (AssemblyNameReference name in references) - VisitAssemblyNameReference (name); - } - - public override void VisitAssemblyNameReference (AssemblyNameReference name) - { - byte [] pkortoken; - if (name.PublicKey != null && name.PublicKey.Length > 0) - pkortoken = name.PublicKey; - else if (name.PublicKeyToken != null && name.PublicKeyToken.Length > 0) - pkortoken = name.PublicKeyToken; - else - pkortoken = new byte [0]; - - AssemblyRefTable arTable = m_tableWriter.GetAssemblyRefTable (); - AssemblyRefRow arRow = m_rowWriter.CreateAssemblyRefRow ( - (ushort) name.Version.Major, - (ushort) name.Version.Minor, - (ushort) name.Version.Build, - (ushort) name.Version.Revision, - name.Flags, - m_mdWriter.AddBlob (pkortoken), - m_mdWriter.AddString (name.Name), - m_mdWriter.AddString (name.Culture), - m_mdWriter.AddBlob (name.Hash)); - - arTable.Rows.Add (arRow); - } - - public override void VisitResourceCollection (ResourceCollection resources) - { - VisitCollection (resources); - } - - public override void VisitEmbeddedResource (EmbeddedResource res) - { - AddManifestResource ( - m_mdWriter.AddResource (res.Data), - res.Name, res.Flags, - new MetadataToken (TokenType.ManifestResource, 0)); - } - - public override void VisitLinkedResource (LinkedResource res) - { - FileTable fTable = m_tableWriter.GetFileTable (); - FileRow fRow = m_rowWriter.CreateFileRow ( - Mono.Cecil.FileAttributes.ContainsNoMetaData, - m_mdWriter.AddString (res.File), - m_mdWriter.AddBlob (res.Hash)); - - fTable.Rows.Add (fRow); - - AddManifestResource ( - 0, res.Name, res.Flags, - new MetadataToken (TokenType.File, (uint) fTable.Rows.IndexOf (fRow) + 1)); - } - - public override void VisitAssemblyLinkedResource (AssemblyLinkedResource res) - { - MetadataToken impl = new MetadataToken (TokenType.AssemblyRef, - (uint) m_asm.MainModule.AssemblyReferences.IndexOf (res.Assembly) + 1); - - AddManifestResource (0, res.Name, res.Flags, impl); - } - - void AddManifestResource (uint offset, string name, ManifestResourceAttributes flags, MetadataToken impl) - { - ManifestResourceTable mrTable = m_tableWriter.GetManifestResourceTable (); - ManifestResourceRow mrRow = m_rowWriter.CreateManifestResourceRow ( - offset, - flags, - m_mdWriter.AddString (name), - impl); - - mrTable.Rows.Add (mrRow); - } - - public override void VisitModuleDefinitionCollection (ModuleDefinitionCollection modules) - { - VisitCollection (modules); - } - - public override void VisitModuleDefinition (ModuleDefinition module) - { - if (module.Main) { - ModuleTable modTable = m_tableWriter.GetModuleTable (); - ModuleRow modRow = m_rowWriter.CreateModuleRow ( - 0, - m_mdWriter.AddString (module.Name), - m_mdWriter.AddGuid (module.Mvid), - 0, - 0); - - modTable.Rows.Add (modRow); - } else { - // multiple module assemblies - throw new NotImplementedException (); - } - } - - public override void VisitModuleReferenceCollection (ModuleReferenceCollection modules) - { - VisitCollection (modules); - } - - public override void VisitModuleReference (ModuleReference module) - { - ModuleRefTable mrTable = m_tableWriter.GetModuleRefTable (); - ModuleRefRow mrRow = m_rowWriter.CreateModuleRefRow ( - m_mdWriter.AddString (module.Name)); - - mrTable.Rows.Add (mrRow); - } - - public override void TerminateAssemblyDefinition (AssemblyDefinition asm) - { - foreach (ModuleDefinition mod in asm.Modules) { - ReflectionWriter writer = mod.Controller.Writer; - writer.VisitModuleDefinition (mod); - writer.VisitTypeReferenceCollection (mod.TypeReferences); - writer.VisitTypeDefinitionCollection (mod.Types); - writer.VisitMemberReferenceCollection (mod.MemberReferences); - writer.CompleteTypeDefinitions (); - - writer.TerminateModuleDefinition (mod); - } - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TableComparers.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TableComparers.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TableComparers.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TableComparers.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,276 +0,0 @@ -// -// TableComparers.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.Collections; - - using Mono.Cecil.Metadata; - - class TableComparers { - - public sealed class TypeDef : IComparer { - - public static readonly TypeDef Instance = new TypeDef (); - - public int Compare (object x, object y) - { - TypeDefinition a = x as TypeDefinition; - TypeDefinition b = y as TypeDefinition; - - if (a == null || b == null) - throw new ReflectionException ("TypeDefComparer can only compare TypeDefinition"); - - if (a.Name == Constants.ModuleType && b.Name == Constants.ModuleType) - return 0; - else if (a.Name == Constants.ModuleType) - return -1; - else if (b.Name == Constants.ModuleType) - return 1; - - return Comparer.Default.Compare (a.FullName, b.FullName); - } - } - - public class TypeRef : IComparer { - - public static readonly TypeRef Instance = new TypeRef (); - - public int Compare (object x, object y) - { - TypeReference a = x as TypeReference; - TypeReference b = y as TypeReference; - - if (a == null || b == null) - throw new ReflectionException ("TypeRefComparer can only compare TypeReference"); - - if (b.DeclaringType == a) - return -1; - else if (a.DeclaringType == b) - return 1; - - return Comparer.Default.Compare (a.FullName, b.FullName); - } - } - - public class NestedClass : IComparer { - - public static readonly NestedClass Instance = new NestedClass (); - - public int Compare (object x, object y) - { - NestedClassRow a = x as NestedClassRow; - NestedClassRow b = y as NestedClassRow; - - return Comparer.Default.Compare (a.NestedClass, b.NestedClass); - } - } - - public class Constant : IComparer { - - public static readonly Constant Instance = new Constant (); - - public int Compare (object x, object y) - { - ConstantRow a = x as ConstantRow; - ConstantRow b = y as ConstantRow; - - return Comparer.Default.Compare ( - Utilities.CompressMetadataToken (CodedIndex.HasConstant, a.Parent), - Utilities.CompressMetadataToken (CodedIndex.HasConstant, b.Parent)); - } - - } - - public class InterfaceImpl : IComparer { - - public static readonly InterfaceImpl Instance = new InterfaceImpl (); - - public int Compare (object x, object y) - { - InterfaceImplRow a = x as InterfaceImplRow; - InterfaceImplRow b = y as InterfaceImplRow; - - int klass = Comparer.Default.Compare (a.Class, b.Class); - - if (klass == 0) - return Comparer.Default.Compare ( - Utilities.CompressMetadataToken (CodedIndex.TypeDefOrRef, a.Interface), - Utilities.CompressMetadataToken (CodedIndex.TypeDefOrRef, b.Interface)); - - return klass; - } - } - - public class MethodSem : IComparer { - - public static readonly MethodSem Instance = new MethodSem (); - - public int Compare (object x, object y) - { - MethodSemanticsRow a = x as MethodSemanticsRow; - MethodSemanticsRow b = y as MethodSemanticsRow; - - return Comparer.Default.Compare ( - Utilities.CompressMetadataToken (CodedIndex.HasSemantics, a.Association), - Utilities.CompressMetadataToken (CodedIndex.HasSemantics, b.Association)); - } - } - - public class CustomAttribute : IComparer { - - public static readonly CustomAttribute Instance = new CustomAttribute (); - - public int Compare (object x, object y) - { - CustomAttributeRow a = x as CustomAttributeRow; - CustomAttributeRow b = y as CustomAttributeRow; - - return Comparer.Default.Compare ( - Utilities.CompressMetadataToken (CodedIndex.HasCustomAttribute, a.Parent), - Utilities.CompressMetadataToken (CodedIndex.HasCustomAttribute, b.Parent)); - } - } - - public class SecurityDeclaration : IComparer { - - public static readonly SecurityDeclaration Instance = new SecurityDeclaration (); - - public int Compare (object x, object y) - { - DeclSecurityRow a = x as DeclSecurityRow; - DeclSecurityRow b = y as DeclSecurityRow; - - return Comparer.Default.Compare ( - Utilities.CompressMetadataToken (CodedIndex.HasDeclSecurity, a.Parent), - Utilities.CompressMetadataToken (CodedIndex.HasDeclSecurity, b.Parent)); - } - } - - public class Override : IComparer { - - public static readonly Override Instance = new Override (); - - public int Compare (object x, object y) - { - MethodImplRow a = x as MethodImplRow; - MethodImplRow b = y as MethodImplRow; - - return Comparer.Default.Compare (a.Class, b.Class); - } - } - - public class PInvoke : IComparer { - - public static readonly PInvoke Instance = new PInvoke (); - - public int Compare (object x, object y) - { - ImplMapRow a = x as ImplMapRow; - ImplMapRow b = y as ImplMapRow; - - return Comparer.Default.Compare (a.MemberForwarded.RID, b.MemberForwarded.RID); - } - } - - public class FieldRVA : IComparer { - - public static readonly FieldRVA Instance = new FieldRVA (); - - public int Compare (object x, object y) - { - FieldRVARow a = x as FieldRVARow; - FieldRVARow b = y as FieldRVARow; - - return Comparer.Default.Compare (a.Field, b.Field); - } - } - - public class FieldLayout : IComparer { - - public static readonly FieldLayout Instance = new FieldLayout (); - - public int Compare (object x, object y) - { - FieldLayoutRow a = x as FieldLayoutRow; - FieldLayoutRow b = y as FieldLayoutRow; - - return Comparer.Default.Compare (a.Field, b.Field); - } - } - - public class FieldMarshal : IComparer { - - public static readonly FieldMarshal Instance = new FieldMarshal (); - - public int Compare (object x, object y) - { - FieldMarshalRow a = x as FieldMarshalRow; - FieldMarshalRow b = y as FieldMarshalRow; - - return Comparer.Default.Compare ( - Utilities.CompressMetadataToken (CodedIndex.HasFieldMarshal, a.Parent), - Utilities.CompressMetadataToken (CodedIndex.HasFieldMarshal, b.Parent)); - } - } - - public class TypeLayout : IComparer { - - public static readonly TypeLayout Instance = new TypeLayout (); - - public int Compare (object x, object y) - { - ClassLayoutRow a = x as ClassLayoutRow; - ClassLayoutRow b = y as ClassLayoutRow; - - return Comparer.Default.Compare (a.Parent, b.Parent); - } - } - - public class GenericParam : IComparer { - - public static readonly GenericParam Instance = new GenericParam (); - - public int Compare (object x, object y) - { - GenericParameter a = x as GenericParameter; - GenericParameter b = y as GenericParameter; - - int token = Comparer.Default.Compare ( - Utilities.CompressMetadataToken (CodedIndex.TypeOrMethodDef, a.Owner.MetadataToken), - Utilities.CompressMetadataToken (CodedIndex.TypeOrMethodDef, b.Owner.MetadataToken)); - - if (token == 0) - return Comparer.Default.Compare (a.Position, b.Position); - - return token; - } - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TargetRuntime.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TargetRuntime.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TargetRuntime.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TargetRuntime.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -29,8 +29,9 @@ namespace Mono.Cecil { public enum TargetRuntime { - NET_1_0, - NET_1_1, - NET_2_0 + Net_1_0, + Net_1_1, + Net_2_0, + Net_4_0, } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeAttributes.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeAttributes.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeAttributes.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeAttributes.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,9 +26,9 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { +using System; - using System; +namespace Mono.Cecil { [Flags] public enum TypeAttributes : uint { @@ -74,6 +74,7 @@ // Additional flags RTSpecialName = 0x00000800, // CLI provides 'special' behavior, depending upon the name of the Type - HasSecurity = 0x00040000 // Type has security associate with it + HasSecurity = 0x00040000, // Type has security associate with it + Forwarder = 0x00200000, // Exported type is a type forwarder } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeDefinitionCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeDefinitionCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeDefinitionCollection.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeDefinitionCollection.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,10 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// Generated by /CodeGen/cecil-gen.rb do not edit -// Fri Mar 30 18:43:56 +0200 2007 -// -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -29,188 +26,93 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { - - using System; - using System.Collections; - using System.Collections.Specialized; - - using Mono.Cecil.Cil; +using System; +using System.Collections.Generic; - using Hcp = Mono.Cecil.HashCodeProvider; - using Cmp = System.Collections.Comparer; +using Mono.Cecil.Metadata; - public sealed class TypeDefinitionCollection : NameObjectCollectionBase, IList, IReflectionVisitable { - - ModuleDefinition m_container; - - public TypeDefinition this [int index] { - get { return this.BaseGet (index) as TypeDefinition; } - set { this.BaseSet (index, value); } - } - - public TypeDefinition this [string fullName] { - get { return this.BaseGet (fullName) as TypeDefinition; } - set { this.BaseSet (fullName, value); } - } - - public ModuleDefinition Container { - get { return m_container; } - } - - public bool IsSynchronized { - get { return false; } - } +using Mono.Collections.Generic; - public object SyncRoot { - get { return this; } - } - - bool IList.IsReadOnly { - get { return false; } - } +namespace Mono.Cecil { - bool IList.IsFixedSize { - get { return false; } - } + using Slot = Row; - object IList.this [int index] { - get { return BaseGet (index); } - set { - Check (value); - BaseSet (index, value); - } - } + sealed class TypeDefinitionCollection : Collection { - public TypeDefinitionCollection (ModuleDefinition container) : - base (Hcp.Instance, Cmp.Default) - { - m_container = container; - } + readonly ModuleDefinition container; + readonly Dictionary name_cache; - public void Add (TypeDefinition value) + internal TypeDefinitionCollection (ModuleDefinition container) { - if (value == null) - throw new ArgumentNullException ("value"); - - Attach (value); - - this.BaseAdd (value.FullName, value); + this.container = container; + this.name_cache = new Dictionary (new RowEqualityComparer ()); } - public void Clear () + internal TypeDefinitionCollection (ModuleDefinition container, int capacity) + : base (capacity) { - foreach (TypeDefinition item in this) - Detach (item); - - this.BaseClear (); + this.container = container; + this.name_cache = new Dictionary (capacity, new RowEqualityComparer ()); } - public bool Contains (TypeDefinition value) + protected override void OnAdd (TypeDefinition item, int index) { - return Contains (value.FullName); + Attach (item); } - public bool Contains (string fullName) + protected override void OnSet (TypeDefinition item, int index) { - return this.BaseGet (fullName) != null; + Attach (item); } - public int IndexOf (TypeDefinition value) + protected override void OnInsert (TypeDefinition item, int index) { - string [] keys = this.BaseGetAllKeys (); - return Array.IndexOf (keys, value.FullName, 0, keys.Length); + Attach (item); } - public void Remove (TypeDefinition value) + protected override void OnRemove (TypeDefinition item, int index) { - this.BaseRemove (value.FullName); - - Detach (value); - } - - public void RemoveAt (int index) - { - TypeDefinition item = this [index]; - Remove (item); - Detach (item); } - public void CopyTo (Array ary, int index) - { - this.BaseGetAllValues ().CopyTo (ary, index); - } - - public new IEnumerator GetEnumerator () - { - return this.BaseGetAllValues ().GetEnumerator (); - } - - public void Accept (IReflectionVisitor visitor) - { - visitor.VisitTypeDefinitionCollection (this); - } - -#if CF_1_0 || CF_2_0 - internal object [] BaseGetAllValues () - { - object [] values = new object [this.Count]; - for (int i=0; i < values.Length; ++i) { - values [i] = this.BaseGet (i); - } - return values; - } -#endif - - void Check (object value) - { - if (!(value is TypeDefinition)) - throw new ArgumentException (); - } - - int IList.Add (object value) + protected override void OnClear () { - Check (value); - Add (value as TypeDefinition); - return 0; + foreach (var type in this) + Detach (type); } - bool IList.Contains (object value) + void Attach (TypeDefinition type) { - Check (value); - return Contains (value as TypeDefinition); - } + if (type.Module != null && type.Module != container) + throw new ArgumentException ("Type already attached"); - int IList.IndexOf (object value) - { - throw new NotSupportedException (); + type.module = container; + type.scope = container; + name_cache [new Slot (type.Namespace, type.Name)] = type; } - void IList.Insert (int index, object value) + void Detach (TypeDefinition type) { - throw new NotSupportedException (); + type.module = null; + type.scope = null; + name_cache.Remove (new Slot (type.Namespace, type.Name)); } - void IList.Remove (object value) + public TypeDefinition GetType (string fullname) { - Check (value); - Remove (value as TypeDefinition); - } + string @namespace, name; + TypeParser.SplitFullName (fullname, out @namespace, out name); - void Detach (TypeReference type) - { - type.Module = null; + return GetType (@namespace, name); } - void Attach (TypeReference type) + public TypeDefinition GetType (string @namespace, string name) { - if (type.Module != null) - throw new ReflectionException ("Type is already attached, clone it instead"); - - type.Module = m_container; - type.AttachToScope (m_container); + TypeDefinition type; + if (name_cache.TryGetValue (new Slot (@namespace, name), out type)) + return type; + return null; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeDefinition.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeDefinition.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeDefinition.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeDefinition.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,474 +26,474 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { +using System; + +using Mono.Collections.Generic; - public sealed class TypeDefinition : TypeReference, IMemberDefinition, IHasSecurity { +namespace Mono.Cecil { - TypeAttributes m_attributes; - TypeReference m_baseType; + public sealed class TypeDefinition : TypeReference, IMemberDefinition, ISecurityDeclarationProvider { - bool m_hasInfo; - ushort m_packingSize; - uint m_classSize; - - InterfaceCollection m_interfaces; - NestedTypeCollection m_nestedTypes; - MethodDefinitionCollection m_methods; - ConstructorCollection m_ctors; - FieldDefinitionCollection m_fields; - EventDefinitionCollection m_events; - PropertyDefinitionCollection m_properties; - SecurityDeclarationCollection m_secDecls; + uint attributes; + TypeReference base_type; + internal Range fields_range; + internal Range methods_range; + + short packing_size = Mixin.NotResolvedMarker; + int class_size = Mixin.NotResolvedMarker; + + Collection interfaces; + Collection nested_types; + Collection methods; + Collection fields; + Collection events; + Collection properties; + Collection custom_attributes; + Collection security_declarations; public TypeAttributes Attributes { - get { return m_attributes; } - set { m_attributes = value; } + get { return (TypeAttributes) attributes; } + set { attributes = (uint) value; } } public TypeReference BaseType { - get { return m_baseType; } - set { m_baseType = value; } + get { return base_type; } + set { base_type = value; } + } + + void ResolveLayout () + { + if (packing_size != Mixin.NotResolvedMarker || class_size != Mixin.NotResolvedMarker) + return; + + if (!HasImage) { + packing_size = Mixin.NoDataMarker; + class_size = Mixin.NoDataMarker; + return; + } + + var row = Module.Read (this, (type, reader) => reader.ReadTypeLayout (type)); + + packing_size = row.Col1; + class_size = row.Col2; } public bool HasLayoutInfo { - get { return m_hasInfo; } + get { + if (packing_size >= 0 || class_size >= 0) + return true; + + ResolveLayout (); + + return packing_size >= 0 || class_size >= 0; + } + } + + public short PackingSize { + get { + if (packing_size >= 0) + return packing_size; + + ResolveLayout (); + + return packing_size >= 0 ? packing_size : (short) -1; + } + set { packing_size = value; } + } + + public int ClassSize { + get { + if (class_size >= 0) + return class_size; + + ResolveLayout (); + + return class_size >= 0 ? class_size : -1; + } + set { class_size = value; } + } + + public bool HasInterfaces { + get { + if (interfaces != null) + return interfaces.Count > 0; + + if (HasImage) + return Module.Read (this, (type, reader) => reader.HasInterfaces (type)); + + return false; + } + } + + public Collection Interfaces { + get { + if (interfaces != null) + return interfaces; + + if (HasImage) + return interfaces = Module.Read (this, (type, reader) => reader.ReadInterfaces (type)); + + return interfaces = new Collection (); + } } - public ushort PackingSize { - get { return m_packingSize; } - set { - m_hasInfo = true; - m_packingSize = value; + public bool HasNestedTypes { + get { + if (nested_types != null) + return nested_types.Count > 0; + + if (HasImage) + return Module.Read (this, (type, reader) => reader.HasNestedTypes (type)); + + return false; } } - public uint ClassSize { - get { return m_classSize; } - set { - m_hasInfo = true; - m_classSize = value; + public Collection NestedTypes { + get { + if (nested_types != null) + return nested_types; + + if (HasImage) + return nested_types = Module.Read (this, (type, reader) => reader.ReadNestedTypes (type)); + + return nested_types = new MemberDefinitionCollection (this); } } - public InterfaceCollection Interfaces { + internal new bool HasImage { + get { return Module != null && Module.HasImage; } + } + + public bool HasMethods { get { - if (m_interfaces == null) - m_interfaces = new InterfaceCollection (this); + if (methods != null) + return methods.Count > 0; - return m_interfaces; + if (HasImage) + return methods_range.Length > 0; + + return false; } } - public NestedTypeCollection NestedTypes { + public Collection Methods { get { - if (m_nestedTypes == null) - m_nestedTypes = new NestedTypeCollection (this); + if (methods != null) + return methods; + + if (HasImage) + return methods = Module.Read (this, (type, reader) => reader.ReadMethods (type)); - return m_nestedTypes; + return methods = new MemberDefinitionCollection (this); } } - public MethodDefinitionCollection Methods { + public bool HasFields { get { - if (m_methods == null) - m_methods = new MethodDefinitionCollection (this); + if (fields != null) + return fields.Count > 0; + + if (HasImage) + return fields_range.Length > 0; - return m_methods; + return false; } } - public ConstructorCollection Constructors { + public Collection Fields { get { - if (m_ctors == null) - m_ctors = new ConstructorCollection (this); + if (fields != null) + return fields; - return m_ctors; + if (HasImage) + return fields = Module.Read (this, (type, reader) => reader.ReadFields (type)); + + return fields = new MemberDefinitionCollection (this); } } - public FieldDefinitionCollection Fields { + public bool HasEvents { get { - if (m_fields == null) - m_fields = new FieldDefinitionCollection (this); + if (events != null) + return events.Count > 0; + + if (HasImage) + return Module.Read (this, (type, reader) => reader.HasEvents (type)); - return m_fields; + return false; } } - public EventDefinitionCollection Events { + public Collection Events { get { - if (m_events == null) - m_events = new EventDefinitionCollection (this); + if (events != null) + return events; - return m_events; + if (HasImage) + return events = Module.Read (this, (type, reader) => reader.ReadEvents (type)); + + return events = new MemberDefinitionCollection (this); } } - public PropertyDefinitionCollection Properties { + public bool HasProperties { get { - if (m_properties == null) - m_properties = new PropertyDefinitionCollection (this); + if (properties != null) + return properties.Count > 0; + + if (HasImage) + return Module.Read (this, (type, reader) => reader.HasProperties (type)); - return m_properties; + return false; } } - public SecurityDeclarationCollection SecurityDeclarations { + public Collection Properties { get { - if (m_secDecls == null) - m_secDecls = new SecurityDeclarationCollection (this); + if (properties != null) + return properties; - return m_secDecls; + if (HasImage) + return properties = Module.Read (this, (type, reader) => reader.ReadProperties (type)); + + return properties = new MemberDefinitionCollection (this); } } + public bool HasSecurityDeclarations { + get { + if (security_declarations != null) + return security_declarations.Count > 0; + + return this.GetHasSecurityDeclarations (Module); + } + } + + public Collection SecurityDeclarations { + get { return security_declarations ?? (security_declarations = this.GetSecurityDeclarations (Module)); } + } + + public bool HasCustomAttributes { + get { + if (custom_attributes != null) + return custom_attributes.Count > 0; + + return this.GetHasCustomAttributes (Module); + } + } + + public Collection CustomAttributes { + get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (Module)); } + } + + public override bool HasGenericParameters { + get { + if (generic_parameters != null) + return generic_parameters.Count > 0; + + return this.GetHasGenericParameters (Module); + } + } + + public override Collection GenericParameters { + get { return generic_parameters ?? (generic_parameters = this.GetGenericParameters (Module)); } + } + #region TypeAttributes public bool IsNotPublic { - get { return (m_attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NotPublic; } - set { - if (value) { - m_attributes &= ~TypeAttributes.VisibilityMask; - m_attributes |= TypeAttributes.NotPublic; - } else - m_attributes &= ~(TypeAttributes.VisibilityMask & TypeAttributes.NotPublic); - } + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NotPublic); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NotPublic, value); } } public bool IsPublic { - get { return (m_attributes & TypeAttributes.VisibilityMask) == TypeAttributes.Public; } - set { - if (value) { - m_attributes &= ~TypeAttributes.VisibilityMask; - m_attributes |= TypeAttributes.Public; - } else - m_attributes &= ~(TypeAttributes.VisibilityMask & TypeAttributes.Public); - } + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.Public); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.Public, value); } } public bool IsNestedPublic { - get { return (m_attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedPublic; } - set { - if (value) { - m_attributes &= ~TypeAttributes.VisibilityMask; - m_attributes |= TypeAttributes.NestedPublic; - } else - m_attributes &= ~(TypeAttributes.VisibilityMask & TypeAttributes.NestedPublic); - } + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedPublic); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedPublic, value); } } public bool IsNestedPrivate { - get { return (m_attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedPrivate; } - set { - if (value) { - m_attributes &= ~TypeAttributes.VisibilityMask; - m_attributes |= TypeAttributes.NestedPrivate; - } else - m_attributes &= ~(TypeAttributes.VisibilityMask & TypeAttributes.NestedPrivate); - } + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedPrivate); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedPrivate, value); } } public bool IsNestedFamily { - get { return (m_attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedFamily; } - set { - if (value) { - m_attributes &= ~TypeAttributes.VisibilityMask; - m_attributes |= TypeAttributes.NestedFamily; - } else - m_attributes &= ~(TypeAttributes.VisibilityMask & TypeAttributes.NestedFamily); - } + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamily); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamily, value); } } public bool IsNestedAssembly { - get { return (m_attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedAssembly; } - set { - if (value) { - m_attributes &= ~TypeAttributes.VisibilityMask; - m_attributes |= TypeAttributes.NestedAssembly; - } else - m_attributes &= ~(TypeAttributes.VisibilityMask & TypeAttributes.NestedAssembly); - } + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedAssembly); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedAssembly, value); } } public bool IsNestedFamilyAndAssembly { - get { return (m_attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedFamANDAssem; } - set { - if (value) { - m_attributes &= ~TypeAttributes.VisibilityMask; - m_attributes |= TypeAttributes.NestedFamANDAssem; - } else - m_attributes &= ~(TypeAttributes.VisibilityMask & TypeAttributes.NestedFamANDAssem); - } + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamANDAssem); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamANDAssem, value); } } public bool IsNestedFamilyOrAssembly { - get { return (m_attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedFamORAssem; } - set { - if (value) { - m_attributes &= ~TypeAttributes.VisibilityMask; - m_attributes |= TypeAttributes.NestedFamORAssem; - } else - m_attributes &= ~(TypeAttributes.VisibilityMask & TypeAttributes.NestedFamORAssem); - } + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamORAssem); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamORAssem, value); } } public bool IsAutoLayout { - get { return (m_attributes & TypeAttributes.LayoutMask) == TypeAttributes.AutoLayout; } - set { - if (value) { - m_attributes &= ~TypeAttributes.LayoutMask; - m_attributes |= TypeAttributes.AutoLayout; - } else - m_attributes &= ~(TypeAttributes.LayoutMask & TypeAttributes.AutoLayout); - } + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.AutoLayout); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.AutoLayout, value); } } public bool IsSequentialLayout { - get { return (m_attributes & TypeAttributes.LayoutMask) == TypeAttributes.SequentialLayout; } - set { - if (value) { - m_attributes &= ~TypeAttributes.LayoutMask; - m_attributes |= TypeAttributes.SequentialLayout; - } else - m_attributes &= ~(TypeAttributes.LayoutMask & TypeAttributes.SequentialLayout); - } + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.SequentialLayout); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.SequentialLayout, value); } } public bool IsExplicitLayout { - get { return (m_attributes & TypeAttributes.LayoutMask) == TypeAttributes.ExplicitLayout; } - set { - if (value) { - m_attributes &= ~TypeAttributes.LayoutMask; - m_attributes |= TypeAttributes.ExplicitLayout; - } else - m_attributes &= ~(TypeAttributes.LayoutMask & TypeAttributes.ExplicitLayout); - } + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.ExplicitLayout); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.ExplicitLayout, value); } } public bool IsClass { - get { return (m_attributes & TypeAttributes.ClassSemanticMask) == TypeAttributes.Class; } - set { - if (value) { - m_attributes &= ~TypeAttributes.ClassSemanticMask; - m_attributes |= TypeAttributes.Class; - } else - m_attributes &= ~(TypeAttributes.ClassSemanticMask & TypeAttributes.Class); - } + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.ClassSemanticMask, (uint) TypeAttributes.Class); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.ClassSemanticMask, (uint) TypeAttributes.Class, value); } } public bool IsInterface { - get { return (m_attributes & TypeAttributes.ClassSemanticMask) == TypeAttributes.Interface; } - set { - if (value) { - m_attributes &= ~TypeAttributes.ClassSemanticMask; - m_attributes |= TypeAttributes.Interface; - } else - m_attributes &= ~(TypeAttributes.ClassSemanticMask & TypeAttributes.Interface); - } + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.ClassSemanticMask, (uint) TypeAttributes.Interface); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.ClassSemanticMask, (uint) TypeAttributes.Interface, value); } } public bool IsAbstract { - get { return (m_attributes & TypeAttributes.Abstract) != 0; } - set { - if (value) - m_attributes |= TypeAttributes.Abstract; - else - m_attributes &= ~TypeAttributes.Abstract; - } + get { return attributes.GetAttributes ((uint) TypeAttributes.Abstract); } + set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Abstract, value); } } public bool IsSealed { - get { return (m_attributes & TypeAttributes.Sealed) != 0; } - set { - if (value) - m_attributes |= TypeAttributes.Sealed; - else - m_attributes &= ~TypeAttributes.Sealed; - } + get { return attributes.GetAttributes ((uint) TypeAttributes.Sealed); } + set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Sealed, value); } } public bool IsSpecialName { - get { return (m_attributes & TypeAttributes.SpecialName) != 0; } - set { - if (value) - m_attributes |= TypeAttributes.SpecialName; - else - m_attributes &= ~TypeAttributes.SpecialName; - } + get { return attributes.GetAttributes ((uint) TypeAttributes.SpecialName); } + set { attributes = attributes.SetAttributes ((uint) TypeAttributes.SpecialName, value); } } public bool IsImport { - get { return (m_attributes & TypeAttributes.Import) != 0; } - set { - if (value) - m_attributes |= TypeAttributes.Import; - else - m_attributes &= ~TypeAttributes.Import; - } + get { return attributes.GetAttributes ((uint) TypeAttributes.Import); } + set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Import, value); } } public bool IsSerializable { - get { return (m_attributes & TypeAttributes.Serializable) != 0; } - set { - if (value) - m_attributes |= TypeAttributes.Serializable; - else - m_attributes &= ~TypeAttributes.Serializable; - } + get { return attributes.GetAttributes ((uint) TypeAttributes.Serializable); } + set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Serializable, value); } } public bool IsAnsiClass { - get { return (m_attributes & TypeAttributes.StringFormatMask) == TypeAttributes.AnsiClass; } - set { - if (value) { - m_attributes &= ~TypeAttributes.StringFormatMask; - m_attributes |= TypeAttributes.AnsiClass; - } else - m_attributes &= ~(TypeAttributes.StringFormatMask & TypeAttributes.AnsiClass); - } + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AnsiClass); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AnsiClass, value); } } public bool IsUnicodeClass { - get { return (m_attributes & TypeAttributes.StringFormatMask) == TypeAttributes.UnicodeClass; } - set { - if (value) { - m_attributes &= ~TypeAttributes.StringFormatMask; - m_attributes |= TypeAttributes.UnicodeClass; - } else - m_attributes &= ~(TypeAttributes.StringFormatMask & TypeAttributes.UnicodeClass); - } + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.UnicodeClass); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.UnicodeClass, value); } } public bool IsAutoClass { - get { return (m_attributes & TypeAttributes.StringFormatMask) == TypeAttributes.AutoClass; } - set { - if (value) { - m_attributes &= ~TypeAttributes.StringFormatMask; - m_attributes |= TypeAttributes.AutoClass; - } else - m_attributes &= ~(TypeAttributes.StringFormatMask & TypeAttributes.AutoClass); - } + get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AutoClass); } + set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AutoClass, value); } } public bool IsBeforeFieldInit { - get { return (m_attributes & TypeAttributes.BeforeFieldInit) != 0; } - set { - if (value) - m_attributes |= TypeAttributes.BeforeFieldInit; - else - m_attributes &= ~TypeAttributes.BeforeFieldInit; - } + get { return attributes.GetAttributes ((uint) TypeAttributes.BeforeFieldInit); } + set { attributes = attributes.SetAttributes ((uint) TypeAttributes.BeforeFieldInit, value); } } public bool IsRuntimeSpecialName { - get { return (m_attributes & TypeAttributes.RTSpecialName) != 0; } - set { - if (value) - m_attributes |= TypeAttributes.RTSpecialName; - else - m_attributes &= ~TypeAttributes.RTSpecialName; - } + get { return attributes.GetAttributes ((uint) TypeAttributes.RTSpecialName); } + set { attributes = attributes.SetAttributes ((uint) TypeAttributes.RTSpecialName, value); } } public bool HasSecurity { - get { return (m_attributes & TypeAttributes.HasSecurity) != 0; } - set { - if (value) - m_attributes |= TypeAttributes.HasSecurity; - else - m_attributes &= ~TypeAttributes.HasSecurity; - } + get { return attributes.GetAttributes ((uint) TypeAttributes.HasSecurity); } + set { attributes = attributes.SetAttributes ((uint) TypeAttributes.HasSecurity, value); } } #endregion public bool IsEnum { - get { return m_baseType != null && m_baseType.FullName == Constants.Enum; } + get { return base_type != null && base_type.IsTypeOf ("System", "Enum"); } } public override bool IsValueType { get { - return m_baseType != null && ( - this.IsEnum || m_baseType.FullName == Constants.ValueType); + if (base_type == null) + return false; + + return base_type.IsTypeOf ("System", "Enum") || (base_type.IsTypeOf ("System", "ValueType") && !this.IsTypeOf ("System", "Enum")); } } - internal TypeDefinition (string name, string ns, TypeAttributes attrs) : - base (name, ns) + public override bool IsDefinition { + get { return true; } + } + + public new TypeDefinition DeclaringType { + get { return (TypeDefinition) base.DeclaringType; } + set { base.DeclaringType = value; } + } + + public TypeDefinition (string @namespace, string name, TypeAttributes attributes) + : base (@namespace, name) { - m_hasInfo = false; - m_attributes = attrs; + this.attributes = (uint) attributes; + this.token = new MetadataToken (TokenType.TypeDef); } - public TypeDefinition (string name, string ns, - TypeAttributes attributes, TypeReference baseType) : - this (name, ns, attributes) + public TypeDefinition (string @namespace, string name, TypeAttributes attributes, TypeReference baseType) : + this (@namespace, name, attributes) { this.BaseType = baseType; } - public TypeDefinition Clone () + public override TypeDefinition Resolve () { - return Clone (this, new ImportContext (NullReferenceImporter.Instance, this)); + return this; } + } - internal static TypeDefinition Clone (TypeDefinition type, ImportContext context) + static partial class Mixin { + + public static TypeReference GetEnumUnderlyingType (this TypeDefinition self) { - TypeDefinition nt = new TypeDefinition ( - type.Name, - type.Namespace, - type.Attributes); - - context.GenericContext.Type = nt; - - foreach (GenericParameter p in type.GenericParameters) - nt.GenericParameters.Add (GenericParameter.Clone (p, context)); - - if (type.BaseType != null) - nt.BaseType = context.Import (type.BaseType); - - if (type.HasLayoutInfo) { - nt.ClassSize = type.ClassSize; - nt.PackingSize = type.PackingSize; - } - - foreach (FieldDefinition field in type.Fields) - nt.Fields.Add (FieldDefinition.Clone (field, context)); - foreach (MethodDefinition ctor in type.Constructors) - nt.Constructors.Add (MethodDefinition.Clone (ctor, context)); - foreach (MethodDefinition meth in type.Methods) - nt.Methods.Add (MethodDefinition.Clone (meth, context)); - foreach (EventDefinition evt in type.Events) - nt.Events.Add (EventDefinition.Clone (evt, context)); - foreach (PropertyDefinition prop in type.Properties) - nt.Properties.Add (PropertyDefinition.Clone (prop, context)); - foreach (TypeReference intf in type.Interfaces) - nt.Interfaces.Add (context.Import (intf)); - foreach (TypeDefinition nested in type.NestedTypes) - nt.NestedTypes.Add (Clone (nested, context)); - foreach (CustomAttribute ca in type.CustomAttributes) - nt.CustomAttributes.Add (CustomAttribute.Clone (ca, context)); - foreach (SecurityDeclaration dec in type.SecurityDeclarations) - nt.SecurityDeclarations.Add (SecurityDeclaration.Clone (dec)); + var fields = self.Fields; + + for (int i = 0; i < fields.Count; i++) { + var field = fields [i]; + if (!field.IsStatic) + return field.FieldType; + } - return nt; + throw new ArgumentException (); } - public override void Accept (IReflectionVisitor visitor) + public static TypeDefinition GetNestedType (this TypeDefinition self, string name) { - visitor.VisitTypeDefinition (this); + if (!self.HasNestedTypes) + return null; + + var nested_types = self.NestedTypes; + + for (int i = 0; i < nested_types.Count; i++) { + var nested_type = nested_types [i]; + if (nested_type.Name == name) + return nested_type; + } - this.GenericParameters.Accept (visitor); - this.Interfaces.Accept (visitor); - this.Constructors.Accept (visitor); - this.Methods.Accept (visitor); - this.Fields.Accept (visitor); - this.Properties.Accept (visitor); - this.Events.Accept (visitor); - this.NestedTypes.Accept (visitor); - this.CustomAttributes.Accept (visitor); - this.SecurityDeclarations.Accept (visitor); + return null; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeParser.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeParser.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeParser.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeParser.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,554 @@ +// +// TypeParser.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Text; + +using Mono.Cecil.Metadata; + +namespace Mono.Cecil { + + class TypeParser { + + class Type { + public const int Ptr = -1; + public const int ByRef = -2; + public const int SzArray = -3; + + public string type_fullname; + public string [] nested_names; + public int arity; + public int [] specs; + public Type [] generic_arguments; + public string assembly; + } + + readonly string fullname; + readonly int length; + + int position; + + TypeParser (string fullname) + { + this.fullname = fullname; + this.length = fullname.Length; + } + + Type ParseType (bool fq_name) + { + var type = new Type (); + type.type_fullname = ParsePart (); + + type.nested_names = ParseNestedNames (); + + if (TryGetArity (type)) + type.generic_arguments = ParseGenericArguments (type.arity); + + type.specs = ParseSpecs (); + + if (fq_name) + type.assembly = ParseAssemblyName (); + + return type; + } + + static bool TryGetArity (Type type) + { + int arity = 0; + + TryAddArity (type.type_fullname, ref arity); + + var nested_names = type.nested_names; + if (!nested_names.IsNullOrEmpty ()) { + for (int i = 0; i < nested_names.Length; i++) + TryAddArity (nested_names [i], ref arity); + } + + type.arity = arity; + return arity > 0; + } + + static bool TryGetArity (string name, out int arity) + { + arity = 0; + var index = name.LastIndexOf ('`'); + if (index == -1) + return false; + + return ParseInt32 (name.Substring (index + 1), out arity); + } + + static bool ParseInt32 (string value, out int result) + { +#if CF + try { + result = int.Parse (value); + return true; + } catch { + result = 0; + return false; + } +#else + return int.TryParse (value, out result); +#endif + } + + static void TryAddArity (string name, ref int arity) + { + int type_arity; + if (!TryGetArity (name, out type_arity)) + return; + + arity += type_arity; + } + + string ParsePart () + { + int start = position; + while (position < length && !IsDelimiter (fullname [position])) + position++; + + return fullname.Substring (start, position - start); + } + + static bool IsDelimiter (char chr) + { + return "+,[]*&".IndexOf (chr) != -1; + } + + void TryParseWhiteSpace () + { + while (position < length && Char.IsWhiteSpace (fullname [position])) + position++; + } + + string [] ParseNestedNames () + { + string [] nested_names = null; + while (TryParse ('+')) + Add (ref nested_names, ParsePart ()); + + return nested_names; + } + + bool TryParse (char chr) + { + if (position < length && fullname [position] == chr) { + position++; + return true; + } + + return false; + } + + static void Add (ref T [] array, T item) + { + if (array == null) { + array = new [] { item }; + return; + } + +#if !CF + Array.Resize (ref array, array.Length + 1); +#else + var copy = new T [array.Length + 1]; + Array.Copy (array, copy, array.Length); + array = copy; +#endif + array [array.Length - 1] = item; + } + + int [] ParseSpecs () + { + int [] specs = null; + + while (position < length) { + switch (fullname [position]) { + case '*': + position++; + Add (ref specs, Type.Ptr); + break; + case '&': + position++; + Add (ref specs, Type.ByRef); + break; + case '[': + position++; + switch (fullname [position]) { + case ']': + position++; + Add (ref specs, Type.SzArray); + break; + case '*': + position++; + Add (ref specs, 1); + break; + default: + var rank = 1; + while (TryParse (',')) + rank++; + + Add (ref specs, rank); + + TryParse (']'); + break; + } + break; + default: + return specs; + } + } + + return specs; + } + + Type [] ParseGenericArguments (int arity) + { + Type [] generic_arguments = null; + + if (position == length || fullname [position] != '[') + return generic_arguments; + + TryParse ('['); + + for (int i = 0; i < arity; i++) { + var fq_argument = TryParse ('['); + Add (ref generic_arguments, ParseType (fq_argument)); + if (fq_argument) + TryParse (']'); + + TryParse (','); + TryParseWhiteSpace (); + } + + TryParse (']'); + + return generic_arguments; + } + + string ParseAssemblyName () + { + if (!TryParse (',')) + return string.Empty; + + TryParseWhiteSpace (); + + var start = position; + while (position < length) { + var chr = fullname [position]; + if (chr == '[' || chr == ']') + break; + + position++; + } + + return fullname.Substring (start, position - start); + } + + public static TypeReference ParseType (ModuleDefinition module, string fullname) + { + if (fullname == null) + return null; + + var parser = new TypeParser (fullname); + return GetTypeReference (module, parser.ParseType (true)); + } + + static TypeReference GetTypeReference (ModuleDefinition module, Type type_info) + { + TypeReference type; + if (!TryGetDefinition (module, type_info, out type)) + type = CreateReference (type_info, module, GetMetadataScope (module, type_info)); + + return CreateSpecs (type, type_info); + } + + static TypeReference CreateSpecs (TypeReference type, Type type_info) + { + type = TryCreateGenericInstanceType (type, type_info); + + var specs = type_info.specs; + if (specs.IsNullOrEmpty ()) + return type; + + for (int i = 0; i < specs.Length; i++) { + switch (specs [i]) { + case Type.Ptr: + type = new PointerType (type); + break; + case Type.ByRef: + type = new ByReferenceType (type); + break; + case Type.SzArray: + type = new ArrayType (type); + break; + default: + var array = new ArrayType (type); + array.Dimensions.Clear (); + + for (int j = 0; j < specs [i]; j++) + array.Dimensions.Add (new ArrayDimension ()); + + type = array; + break; + } + } + + return type; + } + + static TypeReference TryCreateGenericInstanceType (TypeReference type, Type type_info) + { + var generic_arguments = type_info.generic_arguments; + if (generic_arguments.IsNullOrEmpty ()) + return type; + + var instance = new GenericInstanceType (type); + var instance_arguments = instance.GenericArguments; + + for (int i = 0; i < generic_arguments.Length; i++) + instance_arguments.Add (GetTypeReference (type.Module, generic_arguments [i])); + + return instance; + } + + public static void SplitFullName (string fullname, out string @namespace, out string name) + { + var last_dot = fullname.LastIndexOf ('.'); + + if (last_dot == -1) { + @namespace = string.Empty; + name = fullname; + } else { + @namespace = fullname.Substring (0, last_dot); + name = fullname.Substring (last_dot + 1); + } + } + + static TypeReference CreateReference (Type type_info, ModuleDefinition module, IMetadataScope scope) + { + string @namespace, name; + SplitFullName (type_info.type_fullname, out @namespace, out name); + + var type = new TypeReference (@namespace, name, module, scope); + + AdjustGenericParameters (type); + + var nested_names = type_info.nested_names; + if (nested_names.IsNullOrEmpty ()) + return type; + + for (int i = 0; i < nested_names.Length; i++) { + type = new TypeReference (string.Empty, nested_names [i], module, null) { + DeclaringType = type, + }; + + AdjustGenericParameters (type); + } + + return type; + } + + static void AdjustGenericParameters (TypeReference type) + { + int arity; + if (!TryGetArity (type.Name, out arity)) + return; + + for (int i = 0; i < arity; i++) + type.GenericParameters.Add (new GenericParameter (type)); + } + + static IMetadataScope GetMetadataScope (ModuleDefinition module, Type type_info) + { + if (string.IsNullOrEmpty (type_info.assembly)) + return module.TypeSystem.Corlib; + + return MatchReference (module, AssemblyNameReference.Parse (type_info.assembly)); + } + + static AssemblyNameReference MatchReference (ModuleDefinition module, AssemblyNameReference pattern) + { + var references = module.AssemblyReferences; + + for (int i = 0; i < references.Count; i++) { + var reference = references [i]; + if (reference.FullName == pattern.FullName) + return reference; + } + + return pattern; + } + + static bool TryGetDefinition (ModuleDefinition module, Type type_info, out TypeReference type) + { + type = null; + if (!TryCurrentModule (module, type_info)) + return false; + + var typedef = module.GetType (type_info.type_fullname); + if (typedef == null) + return false; + + var nested_names = type_info.nested_names; + if (!nested_names.IsNullOrEmpty ()) { + for (int i = 0; i < nested_names.Length; i++) + typedef = typedef.GetNestedType (nested_names [i]); + } + + type = typedef; + return true; + } + + static bool TryCurrentModule (ModuleDefinition module, Type type_info) + { + if (string.IsNullOrEmpty (type_info.assembly)) + return true; + + if (module.assembly != null && module.assembly.Name.FullName == type_info.assembly) + return true; + + return false; + } + + public static string ToParseable (TypeReference type) + { + if (type == null) + return null; + + var name = new StringBuilder (); + AppendType (type, name, true, true); + return name.ToString (); + } + + static void AppendType (TypeReference type, StringBuilder name, bool fq_name, bool top_level) + { + var declaring_type = type.DeclaringType; + if (declaring_type != null) { + AppendType (declaring_type, name, false, top_level); + name.Append ('+'); + } + + var @namespace = type.Namespace; + if (!string.IsNullOrEmpty (@namespace)) { + name.Append (@namespace); + name.Append ('.'); + } + + name.Append (type.GetElementType ().Name); + + if (!fq_name) + return; + + if (type.IsTypeSpecification ()) + AppendTypeSpecification ((TypeSpecification) type, name); + + if (RequiresFullyQualifiedName (type, top_level)) { + name.Append (", "); + name.Append (GetScopeFullName (type)); + } + } + + static string GetScopeFullName (TypeReference type) + { + var scope = type.Scope; + switch (scope.MetadataScopeType) { + case MetadataScopeType.AssemblyNameReference: + return ((AssemblyNameReference) scope).FullName; + case MetadataScopeType.ModuleDefinition: + return ((ModuleDefinition) scope).Assembly.Name.FullName; + } + + throw new ArgumentException (); + } + + static void AppendTypeSpecification (TypeSpecification type, StringBuilder name) + { + if (type.ElementType.IsTypeSpecification ()) + AppendTypeSpecification ((TypeSpecification) type.ElementType, name); + + switch (type.etype) { + case ElementType.Ptr: + name.Append ('*'); + break; + case ElementType.ByRef: + name.Append ('&'); + break; + case ElementType.SzArray: + case ElementType.Array: + var array = (ArrayType) type; + if (array.IsVector) { + name.Append ("[]"); + } else { + name.Append ('['); + for (int i = 1; i < array.Rank; i++) + name.Append (','); + name.Append (']'); + } + break; + case ElementType.GenericInst: + var instance = (GenericInstanceType) type; + var arguments = instance.GenericArguments; + + name.Append ('['); + + for (int i = 0; i < arguments.Count; i++) { + if (i > 0) + name.Append (','); + + var argument = arguments [i]; + var requires_fqname = argument.Scope != argument.Module; + + if (requires_fqname) + name.Append ('['); + + AppendType (argument, name, true, false); + + if (requires_fqname) + name.Append (']'); + } + + name.Append (']'); + break; + default: + return; + } + } + + static bool RequiresFullyQualifiedName (TypeReference type, bool top_level) + { + if (type.Scope == type.Module) + return false; + + if (type.Scope.Name == "mscorlib" && top_level) + return false; + + return true; + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeReferenceCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeReferenceCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeReferenceCollection.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeReferenceCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,214 +0,0 @@ -// -// TypeReferenceCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Fri Mar 30 18:43:56 +0200 2007 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil { - - using System; - using System.Collections; - using System.Collections.Specialized; - - using Mono.Cecil.Cil; - - using Hcp = Mono.Cecil.HashCodeProvider; - using Cmp = System.Collections.Comparer; - - public sealed class TypeReferenceCollection : NameObjectCollectionBase, IList, IReflectionVisitable { - - ModuleDefinition m_container; - - public TypeReference this [int index] { - get { return this.BaseGet (index) as TypeReference; } - set { this.BaseSet (index, value); } - } - - public TypeReference this [string fullName] { - get { return this.BaseGet (fullName) as TypeReference; } - set { this.BaseSet (fullName, value); } - } - - public ModuleDefinition Container { - get { return m_container; } - } - - public bool IsSynchronized { - get { return false; } - } - - public object SyncRoot { - get { return this; } - } - - bool IList.IsReadOnly { - get { return false; } - } - - bool IList.IsFixedSize { - get { return false; } - } - - object IList.this [int index] { - get { return BaseGet (index); } - set { - Check (value); - BaseSet (index, value); - } - } - - public TypeReferenceCollection (ModuleDefinition container) : - base (Hcp.Instance, Cmp.Default) - { - m_container = container; - } - - public void Add (TypeReference value) - { - if (value == null) - throw new ArgumentNullException ("value"); - - Attach (value); - - this.BaseAdd (value.FullName, value); - } - - public void Clear () - { - foreach (TypeReference item in this) - Detach (item); - - this.BaseClear (); - } - - public bool Contains (TypeReference value) - { - return Contains (value.FullName); - } - - public bool Contains (string fullName) - { - return this.BaseGet (fullName) != null; - } - - public int IndexOf (TypeReference value) - { - string [] keys = this.BaseGetAllKeys (); - return Array.IndexOf (keys, value.FullName, 0, keys.Length); - } - - public void Remove (TypeReference value) - { - this.BaseRemove (value.FullName); - - Detach (value); - } - - public void RemoveAt (int index) - { - TypeReference item = this [index]; - Remove (item); - - Detach (item); - } - - public void CopyTo (Array ary, int index) - { - this.BaseGetAllValues ().CopyTo (ary, index); - } - - public new IEnumerator GetEnumerator () - { - return this.BaseGetAllValues ().GetEnumerator (); - } - - public void Accept (IReflectionVisitor visitor) - { - visitor.VisitTypeReferenceCollection (this); - } - -#if CF_1_0 || CF_2_0 - internal object [] BaseGetAllValues () - { - object [] values = new object [this.Count]; - for (int i=0; i < values.Length; ++i) { - values [i] = this.BaseGet (i); - } - return values; - } -#endif - - void Check (object value) - { - if (!(value is TypeReference)) - throw new ArgumentException (); - } - - int IList.Add (object value) - { - Check (value); - Add (value as TypeReference); - return 0; - } - - bool IList.Contains (object value) - { - Check (value); - return Contains (value as TypeReference); - } - - int IList.IndexOf (object value) - { - throw new NotSupportedException (); - } - - void IList.Insert (int index, object value) - { - throw new NotSupportedException (); - } - - void IList.Remove (object value) - { - Check (value); - Remove (value as TypeReference); - } - - void Detach (TypeReference type) - { - type.Module = null; - } - - void Attach (TypeReference type) - { - if (type.Module != null) - throw new ReflectionException ("Type is already attached, clone it instead"); - - type.Module = m_container; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeReference.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeReference.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeReference.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeReference.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,69 +26,126 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System; + +using Mono.Cecil.Metadata; +using Mono.Collections.Generic; + namespace Mono.Cecil { - public class TypeReference : MemberReference, IGenericParameterProvider, ICustomAttributeProvider { + public enum MetadataType : byte { + Void = ElementType.Void, + Boolean = ElementType.Boolean, + Char = ElementType.Char, + SByte = ElementType.I1, + Byte = ElementType.U1, + Int16 = ElementType.I2, + UInt16 = ElementType.U2, + Int32 = ElementType.I4, + UInt32 = ElementType.U4, + Int64 = ElementType.I8, + UInt64 = ElementType.U8, + Single = ElementType.R4, + Double = ElementType.R8, + String = ElementType.String, + Pointer = ElementType.Ptr, + ByReference = ElementType.ByRef, + ValueType = ElementType.ValueType, + Class = ElementType.Class, + Var = ElementType.Var, + Array = ElementType.Array, + GenericInstance = ElementType.GenericInst, + TypedByReference = ElementType.TypedByRef, + IntPtr = ElementType.I, + UIntPtr = ElementType.U, + FunctionPointer = ElementType.FnPtr, + Object = ElementType.Object, + MVar = ElementType.MVar, + RequiredModifier = ElementType.CModReqD, + OptionalModifier = ElementType.CModOpt, + Sentinel = ElementType.Sentinel, + Pinned = ElementType.Pinned, + } + + public class TypeReference : MemberReference, IGenericParameterProvider, IGenericContext { - string m_namespace; - bool m_fullNameDiscarded; - string m_fullName; - protected bool m_isValueType; - IMetadataScope m_scope; - ModuleDefinition m_module; + string @namespace; + bool value_type; + internal IMetadataScope scope; + internal ModuleDefinition module; - CustomAttributeCollection m_customAttrs; - GenericParameterCollection m_genparams; + internal ElementType etype = ElementType.None; + + string fullname; + + protected Collection generic_parameters; public override string Name { get { return base.Name; } set { base.Name = value; - m_fullNameDiscarded = true; + fullname = null; } } public virtual string Namespace { - get { return m_namespace; } + get { return @namespace; } set { - m_namespace = value; - m_fullNameDiscarded = true; + @namespace = value; + fullname = null; } } public virtual bool IsValueType { - get { return m_isValueType; } - set { m_isValueType = value; } - } - - public virtual ModuleDefinition Module { - get { return m_module; } - set { m_module = value; } + get { return value_type; } + set { value_type = value; } } - public CustomAttributeCollection CustomAttributes { + public override ModuleDefinition Module { get { - if (m_customAttrs == null) - m_customAttrs = new CustomAttributeCollection (this); + if (module != null) + return module; - return m_customAttrs; + var declaring_type = this.DeclaringType; + if (declaring_type != null) + return declaring_type.Module; + + return null; } } - public GenericParameterCollection GenericParameters { + IGenericParameterProvider IGenericContext.Type { + get { return this; } + } + + IGenericParameterProvider IGenericContext.Method { + get { return null; } + } + + GenericParameterType IGenericParameterProvider.GenericParameterType { + get { return GenericParameterType.Type; } + } + + public virtual bool HasGenericParameters { + get { return !generic_parameters.IsNullOrEmpty (); } + } + + public virtual Collection GenericParameters { get { - if (m_genparams == null) - m_genparams = new GenericParameterCollection (this); - return m_genparams; + if (generic_parameters != null) + return generic_parameters; + + return generic_parameters = new Collection (); } } public virtual IMetadataScope Scope { get { - if (this.DeclaringType != null) - return this.DeclaringType.Scope; + var declaring_type = this.DeclaringType; + if (declaring_type != null) + return declaring_type.Scope; - return m_scope; + return scope; } } @@ -96,58 +153,175 @@ get { return this.DeclaringType != null; } } - public virtual string FullName { + public override TypeReference DeclaringType { + get { return base.DeclaringType; } + set { + base.DeclaringType = value; + fullname = null; + } + } + + public override string FullName { get { - if (m_fullName != null && !m_fullNameDiscarded) - return m_fullName; + if (fullname != null) + return fullname; - if (this.IsNested) - return string.Concat (this.DeclaringType.FullName, "/", this.Name); + if (IsNested) + return fullname = DeclaringType.FullName + "/" + Name; - if (m_namespace == null || m_namespace.Length == 0) - return this.Name; + if (string.IsNullOrEmpty (@namespace)) + return fullname = Name; - m_fullName = string.Concat (m_namespace, ".", this.Name); - m_fullNameDiscarded = false; - return m_fullName; + return fullname = @namespace + "." + Name; } } - protected TypeReference (string name, string ns) : base (name) + public virtual bool IsByReference { + get { return false; } + } + + public virtual bool IsPointer { + get { return false; } + } + + public virtual bool IsSentinel { + get { return false; } + } + + public virtual bool IsArray { + get { return false; } + } + + public virtual bool IsGenericParameter { + get { return false; } + } + + public virtual bool IsGenericInstance { + get { return false; } + } + + public virtual bool IsRequiredModifier { + get { return false; } + } + + public virtual bool IsOptionalModifier { + get { return false; } + } + + public virtual bool IsPinned { + get { return false; } + } + + public virtual bool IsFunctionPointer { + get { return false; } + } + + public bool IsPrimitive { + get { + switch (etype) { + case ElementType.Boolean: + case ElementType.Char: + case ElementType.I: + case ElementType.U: + case ElementType.I1: + case ElementType.U1: + case ElementType.I2: + case ElementType.U2: + case ElementType.I4: + case ElementType.U4: + case ElementType.I8: + case ElementType.U8: + case ElementType.R4: + case ElementType.R8: + return true; + default: + return false; + } + } + } + + public virtual MetadataType MetadataType { + get { + switch (etype) { + case ElementType.None: + return IsValueType ? MetadataType.ValueType : MetadataType.Class; + default: + return (MetadataType) etype; + } + } + } + + protected TypeReference (string @namespace, string name) + : base (name) { - m_namespace = ns; - m_fullNameDiscarded = false; + this.@namespace = @namespace ?? string.Empty; + this.token = new MetadataToken (TokenType.TypeRef, 0); } - internal TypeReference (string name, string ns, IMetadataScope scope) : this (name, ns) + public TypeReference (string @namespace, string name, ModuleDefinition module, IMetadataScope scope) + : this (@namespace, name) { - m_scope = scope; + this.module = module; + this.scope = scope; } - public TypeReference (string name, string ns, IMetadataScope scope, bool valueType) : - this (name, ns, scope) + public TypeReference (string @namespace, string name, ModuleDefinition module, IMetadataScope scope, bool valueType) : + this (@namespace, name, module, scope) { - this.IsValueType = valueType; + value_type = valueType; } - public virtual TypeReference GetOriginalType () + public virtual TypeReference GetElementType () { return this; } - internal void AttachToScope (IMetadataScope scope) + public virtual TypeDefinition Resolve () + { + var module = this.Module; + if (module == null) + throw new NotSupportedException (); + + return module.Resolve (this); + } + } + + static partial class Mixin { + + public static bool IsTypeOf (this TypeReference self, string @namespace, string name) { - m_scope = scope; + return self.Name == name + && self.Namespace == @namespace; } - public override void Accept (IReflectionVisitor visitor) + public static bool IsTypeSpecification (this TypeReference type) { - visitor.VisitTypeReference (this); + switch (type.etype) { + case ElementType.Array: + case ElementType.ByRef: + case ElementType.CModOpt: + case ElementType.CModReqD: + case ElementType.FnPtr: + case ElementType.GenericInst: + case ElementType.MVar: + case ElementType.Pinned: + case ElementType.Ptr: + case ElementType.SzArray: + case ElementType.Sentinel: + case ElementType.Var: + return true; + } + + return false; } - public override string ToString () + public static TypeDefinition CheckedResolve (this TypeReference self) { - return this.FullName; + var type = self.Resolve (); + if (type == null) + throw new InvalidOperationException (string.Format ("Failed to resolve type: {0}", self.FullName)); + + return type; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeSpecification.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeSpecification.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeSpecification.cs 2008-11-06 19:52:04.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeSpecification.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,55 +26,69 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil { +using System; + +using Mono.Cecil.Metadata; - using System; +namespace Mono.Cecil { public abstract class TypeSpecification : TypeReference { - private TypeReference m_elementType; + readonly TypeReference element_type; + + public TypeReference ElementType { + get { return element_type; } + } public override string Name { - get { return m_elementType.Name; } + get { return element_type.Name; } set { throw new NotSupportedException (); } } public override string Namespace { - get { return m_elementType.Namespace; } + get { return element_type.Namespace; } set { throw new NotSupportedException (); } } - public override bool IsValueType { - get { return m_elementType.IsValueType; } - set { throw new InvalidOperationException (); } - } - public override IMetadataScope Scope { - get { return m_elementType.Scope; } + get { return element_type.Scope; } } public override ModuleDefinition Module { - get { return m_elementType.Module; } - set { throw new InvalidOperationException (); } + get { return element_type.Module; } } - public TypeReference ElementType { - get { return m_elementType; } - set { m_elementType = value; } + public override string FullName { + get { return element_type.FullName; } } - public override string FullName { - get { return m_elementType.FullName; } + internal override bool ContainsGenericParameter { + get { return element_type.ContainsGenericParameter; } } - internal TypeSpecification (TypeReference elementType) : base (string.Empty, string.Empty) + public override MetadataType MetadataType { + get { return (MetadataType) etype; } + } + + internal TypeSpecification (TypeReference type) + : base (null, null) { - m_elementType = elementType; + this.element_type = type; + this.token = new MetadataToken (TokenType.TypeSpec); } - public override TypeReference GetOriginalType () + public override TypeReference GetElementType () + { + return element_type.GetElementType (); + } + } + + static partial class Mixin { + + public static void CheckType (TypeReference type) { - return m_elementType.GetOriginalType (); + if (type == null) + throw new ArgumentNullException ("type"); } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeSystem.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeSystem.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeSystem.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeSystem.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,273 @@ +// +// TypeSystem.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; + +using Mono.Cecil.Metadata; + +namespace Mono.Cecil { + + public abstract class TypeSystem { + + sealed class CorlibTypeSystem : TypeSystem { + + public CorlibTypeSystem (ModuleDefinition module) + : base (module) + { + } + + internal override TypeReference LookupType (string @namespace, string name) + { + var metadata = module.MetadataSystem; + if (metadata.Types == null) + Initialize (module.Types); + + return module.Read (this, (_, reader) => { + var types = reader.metadata.Types; + + for (int i = 0; i < types.Length; i++) { + if (types [i] == null) + types [i] = reader.GetTypeDefinition ((uint) i + 1); + + var type = types [i]; + + if (type.Name == name && type.Namespace == @namespace) + return type; + } + + return null; + }); + } + + static void Initialize (object obj) + { + } + } + + sealed class CommonTypeSystem : TypeSystem { + + AssemblyNameReference corlib; + + public CommonTypeSystem (ModuleDefinition module) + : base (module) + { + } + + internal override TypeReference LookupType (string @namespace, string name) + { + return CreateTypeReference (@namespace, name); + } + + public AssemblyNameReference GetCorlibReference () + { + if (corlib != null) + return corlib; + + const string mscorlib = "mscorlib"; + + var references = module.AssemblyReferences; + + for (int i = 0; i < references.Count; i++) { + var reference = references [i]; + if (reference.Name == mscorlib) + return corlib = reference; + } + + corlib = new AssemblyNameReference { + Name = mscorlib, + Version = GetCorlibVersion (), + PublicKeyToken = new byte [] { 0xb7, 0x7a, 0x5c, 0x56, 0x19, 0x34, 0xe0, 0x89 }, + }; + + references.Add (corlib); + + return corlib; + } + + Version GetCorlibVersion () + { + switch (module.Runtime) { + case TargetRuntime.Net_1_0: + case TargetRuntime.Net_1_1: + return new Version (1, 0, 0, 0); + case TargetRuntime.Net_2_0: + return new Version (2, 0, 0, 0); + case TargetRuntime.Net_4_0: + return new Version (4, 0, 0, 0); + default: + throw new NotSupportedException (); + } + } + + TypeReference CreateTypeReference (string @namespace, string name) + { + return new TypeReference (@namespace, name, module, GetCorlibReference ()); + } + } + + readonly ModuleDefinition module; + + TypeReference type_object; + TypeReference type_void; + TypeReference type_bool; + TypeReference type_char; + TypeReference type_sbyte; + TypeReference type_byte; + TypeReference type_int16; + TypeReference type_uint16; + TypeReference type_int32; + TypeReference type_uint32; + TypeReference type_int64; + TypeReference type_uint64; + TypeReference type_single; + TypeReference type_double; + TypeReference type_intptr; + TypeReference type_uintptr; + TypeReference type_string; + TypeReference type_typedref; + + TypeSystem (ModuleDefinition module) + { + this.module = module; + } + + internal static TypeSystem CreateTypeSystem (ModuleDefinition module) + { + if (IsCorlib (module)) + return new CorlibTypeSystem (module); + + return new CommonTypeSystem (module); + } + + static bool IsCorlib (ModuleDefinition module) + { + if (module.Assembly == null) + return false; + + return module.Assembly.Name.Name == "mscorlib"; + } + + internal abstract TypeReference LookupType (string @namespace, string name); + + TypeReference LookupSystemType (string name, ElementType element_type) + { + var type = LookupType ("System", name); + type.etype = element_type; + return type; + } + + TypeReference LookupSystemValueType (string name, ElementType element_type) + { + var type = LookupSystemType (name, element_type); + type.IsValueType = true; + return type; + } + + public IMetadataScope Corlib { + get { + var common = this as CommonTypeSystem; + if (common == null) + return module; + + return common.GetCorlibReference (); + } + } + + public TypeReference Object { + get { return type_object ?? (type_object = LookupSystemType ("Object", ElementType.Object)); } + } + + public TypeReference Void { + get { return type_void ?? (type_void = LookupSystemType ("Void", ElementType.Void)); } + } + + public TypeReference Boolean { + get { return type_bool ?? (type_bool = LookupSystemValueType ("Boolean", ElementType.Boolean)); } + } + + public TypeReference Char { + get { return type_char ?? (type_char = LookupSystemValueType ("Char", ElementType.Char)); } + } + + public TypeReference SByte { + get { return type_sbyte ?? (type_sbyte = LookupSystemValueType ("SByte", ElementType.I1)); } + } + + public TypeReference Byte { + get { return type_byte ?? (type_byte = LookupSystemValueType ("Byte", ElementType.U1)); } + } + + public TypeReference Int16 { + get { return type_int16 ?? (type_int16 = LookupSystemValueType ("Int16", ElementType.I2)); } + } + + public TypeReference UInt16 { + get { return type_uint16 ?? (type_uint16 = LookupSystemValueType ("UInt16", ElementType.U2)); } + } + + public TypeReference Int32 { + get { return type_int32 ?? (type_int32 = LookupSystemValueType ("Int32", ElementType.I4)); } + } + + public TypeReference UInt32 { + get { return type_uint32 ?? (type_uint32 = LookupSystemValueType ("UInt32", ElementType.U4)); } + } + + public TypeReference Int64 { + get { return type_int64 ?? (type_int64 = LookupSystemValueType ("Int64", ElementType.I8)); } + } + + public TypeReference UInt64 { + get { return type_uint64 ?? (type_uint64 = LookupSystemValueType ("UInt64", ElementType.U8)); } + } + + public TypeReference Single { + get { return type_single ?? (type_single = LookupSystemValueType ("Single", ElementType.R4)); } + } + + public TypeReference Double { + get { return type_double ?? (type_double = LookupSystemValueType ("Double", ElementType.R8)); } + } + + public TypeReference IntPtr { + get { return type_intptr ?? (type_intptr = LookupSystemValueType ("IntPtr", ElementType.I)); } + } + + public TypeReference UIntPtr { + get { return type_uintptr ?? (type_uintptr = LookupSystemValueType ("UIntPtr", ElementType.U)); } + } + + public TypeReference String { + get { return type_string ?? (type_string = LookupSystemType ("String", ElementType.String)); } + } + + public TypeReference TypedReference { + get { return type_typedref ?? (type_typedref = LookupSystemValueType ("TypedReference", ElementType.TypedByRef)); } + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/VariantType.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/VariantType.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/VariantType.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/VariantType.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -29,24 +29,25 @@ namespace Mono.Cecil { public enum VariantType { + None = 0, I2 = 2, I4 = 3, R4 = 4, R8 = 5, CY = 6, - DATE = 7, - BSTR = 8, - DISPATCH = 9, - ERROR = 10, - BOOL = 11, - VARIANT = 12, - UNKNOWN = 13, - DECIMAL = 14, + Date = 7, + BStr = 8, + Dispatch = 9, + Error = 10, + Bool = 11, + Variant = 12, + Unknown = 13, + Decimal = 14, I1 = 16, UI1 = 17, UI2 = 18, UI4 = 19, - INT = 22, - UINT = 23 + Int = 22, + UInt = 23 } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/BaseImageVisitor.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/BaseImageVisitor.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/BaseImageVisitor.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/BaseImageVisitor.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -// -// BaseImageVisitor.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 - 2007 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - public abstract class BaseImageVisitor : IBinaryVisitor { - - public virtual void VisitImage (Image img) - { - } - - public virtual void VisitDOSHeader (DOSHeader header) - { - } - - public virtual void VisitPEFileHeader (PEFileHeader header) - { - } - - public virtual void VisitPEOptionalHeader (PEOptionalHeader header) - { - } - - public virtual void VisitStandardFieldsHeader (PEOptionalHeader.StandardFieldsHeader header) - { - } - - public virtual void VisitNTSpecificFieldsHeader (PEOptionalHeader.NTSpecificFieldsHeader header) - { - } - - public virtual void VisitDataDirectoriesHeader (PEOptionalHeader.DataDirectoriesHeader header) - { - } - - public virtual void VisitSectionCollection (SectionCollection coll) - { - } - - public virtual void VisitSection (Section section) - { - } - - public virtual void VisitImportAddressTable (ImportAddressTable iat) - { - } - - public virtual void VisitDebugHeader (DebugHeader dh) - { - } - - public virtual void VisitCLIHeader (CLIHeader header) - { - } - - public virtual void VisitImportTable (ImportTable it) - { - } - - public virtual void VisitImportLookupTable (ImportLookupTable ilt) - { - } - - public virtual void VisitHintNameTable (HintNameTable hnt) - { - } - - public virtual void VisitExportTable (ExportTable et) - { - } - - public virtual void TerminateImage (Image img) - { - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/CLIHeader.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/CLIHeader.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/CLIHeader.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/CLIHeader.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -// -// CLIHeader.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - public sealed class CLIHeader : IHeader, IBinaryVisitable { - - public uint Cb; - public ushort MajorRuntimeVersion; - public ushort MinorRuntimeVersion; - public DataDirectory Metadata; - public RuntimeImage Flags; - public uint EntryPointToken; - public DataDirectory Resources; - public DataDirectory StrongNameSignature; - public DataDirectory CodeManagerTable; - public DataDirectory VTableFixups; - public DataDirectory ExportAddressTableJumps; - public DataDirectory ManagedNativeHeader; - - public byte [] ImageHash; - - internal CLIHeader () - { - } - - public void SetDefaultValues () - { - Cb = 0x48; - MajorRuntimeVersion = 2; - MinorRuntimeVersion = 0; - Flags = RuntimeImage.ILOnly; - CodeManagerTable = DataDirectory.Zero; - ExportAddressTableJumps = DataDirectory.Zero; - ManagedNativeHeader = DataDirectory.Zero; - } - - public void Accept (IBinaryVisitor visitor) - { - visitor.VisitCLIHeader (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/CopyImageVisitor.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/CopyImageVisitor.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/CopyImageVisitor.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/CopyImageVisitor.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,119 +0,0 @@ -// -// CopyImageVisitor.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - class CopyImageVisitor : BaseImageVisitor { - - Image m_newImage; - Image m_originalImage; - - public CopyImageVisitor (Image originalImage) - { - m_originalImage = originalImage; - } - - public override void VisitImage (Image img) - { - m_newImage = img; - if (m_originalImage.DebugHeader != null) - m_newImage.AddDebugHeader (); - } - - public override void VisitDebugHeader (DebugHeader dbgHeader) - { - DebugHeader old = m_originalImage.DebugHeader; - dbgHeader.Age = old.Age; - dbgHeader.Characteristics = old.Characteristics; - dbgHeader.FileName = old.FileName; - dbgHeader.Signature = old.Signature; - dbgHeader.TimeDateStamp = ImageInitializer.TimeDateStampFromEpoch(); - dbgHeader.Type = old.Type; - } - - public override void VisitSectionCollection (SectionCollection sections) - { - Section old = null; - foreach (Section s in m_originalImage.Sections) - if (s.Name == Section.Resources) - old = s; - - if (old == null) - return; - - Section rsrc = new Section (); - rsrc.Characteristics = old.Characteristics; - rsrc.Name = old.Name; - - sections.Add (rsrc); - } - - public override void TerminateImage (Image img) - { - if (m_originalImage.ResourceDirectoryRoot == null) - return; - - m_newImage.ResourceDirectoryRoot = CloneResourceDirectoryTable (m_originalImage.ResourceDirectoryRoot); - } - - ResourceDirectoryTable CloneResourceDirectoryTable (ResourceDirectoryTable old) - { - ResourceDirectoryTable rdt = new ResourceDirectoryTable (); - foreach (ResourceDirectoryEntry oldEntry in old.Entries) - rdt.Entries.Add (CloneResourceDirectoryEntry (oldEntry)); - - return rdt; - } - - ResourceDirectoryEntry CloneResourceDirectoryEntry (ResourceDirectoryEntry old) - { - ResourceDirectoryEntry rde; - if (old.IdentifiedByName) - rde = new ResourceDirectoryEntry(old.Name); - else - rde = new ResourceDirectoryEntry (old.ID); - - if (old.Child is ResourceDirectoryTable) - rde.Child = CloneResourceDirectoryTable (old.Child as ResourceDirectoryTable); - else - rde.Child = CloneResourceDataEntry (old.Child as ResourceDataEntry); - - return rde; - } - - ResourceDataEntry CloneResourceDataEntry (ResourceDataEntry old) - { - ResourceDataEntry rde = new ResourceDataEntry (); - rde.Size = old.Size; - rde.Codepage = old.Codepage; - rde.ResourceData = old.ResourceData; - - return rde; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DataDirectory.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DataDirectory.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DataDirectory.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DataDirectory.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ -// -// DataDirectory.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - using Mono.Cecil.Metadata; - - public struct DataDirectory { - - public static readonly DataDirectory Zero = new DataDirectory(RVA.Zero, 0); - - RVA m_virtualAddress; - uint m_size; - - public RVA VirtualAddress { - get { return m_virtualAddress; } - set { m_virtualAddress = value; } - } - - public uint Size { - get { return m_size; } - set { m_size = value; } - } - - public DataDirectory (RVA virtualAddress, uint size) - { - m_virtualAddress = virtualAddress; - m_size = size; - } - - public override int GetHashCode () - { - return (m_virtualAddress.GetHashCode () ^ (int) m_size << 1); - } - - public override bool Equals (object other) - { - if (other is DataDirectory) { - DataDirectory odd = (DataDirectory)other; - return (this.m_virtualAddress == odd.m_virtualAddress && - this.m_size == odd.m_size); - } - return false; - } - - public override string ToString () - { - return string.Format ("{0} [{1}]", - m_virtualAddress.ToString (), m_size.ToString ("X")); - } - - public static bool operator == (DataDirectory one, DataDirectory other) - { - return one.Equals (other); - } - - public static bool operator != (DataDirectory one, DataDirectory other) - { - return !one.Equals (other); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DebugHeader.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DebugHeader.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DebugHeader.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DebugHeader.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -// -// DebugHeader.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - using System; - - public sealed class DebugHeader : IHeader, IBinaryVisitable { - - public uint Characteristics; - public uint TimeDateStamp; - public ushort MajorVersion; - public ushort MinorVersion; - public DebugStoreType Type; - public uint SizeOfData; - public RVA AddressOfRawData; - public uint PointerToRawData; - - public uint Magic; - public Guid Signature; - public uint Age; - public string FileName; - - internal DebugHeader () - { - } - - public void SetDefaultValues () - { - Characteristics = 0; - - this.Magic = 0x53445352; - this.Age = 0; - this.Type = DebugStoreType.CodeView; - this.FileName = string.Empty; - } - - public uint GetSize () - { - return 0x34 + (uint) FileName.Length + 1; - } - - public void Accept (IBinaryVisitor visitor) - { - visitor.VisitDebugHeader (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DebugStoreType.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DebugStoreType.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DebugStoreType.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DebugStoreType.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// -// DebugStoreType.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - public enum DebugStoreType : uint { - Unknown = 0x00000000, - COFF = 0x00000001, - CodeView = 0x00000002, - FPO = 0x00000003, - Misc = 0x00000004, - Exception = 0x00000005, - Fixup = 0x00000006, - OMAPToSrc = 0x00000007, - OMAPFromSrc = 0x00000008, - Borland = 0x00000009, - Reserved10 = 0x0000000a, - CLSID = 0x0000000b - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DOSHeader.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DOSHeader.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DOSHeader.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DOSHeader.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -// -// DOSHeader.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - public sealed class DOSHeader : IHeader, IBinaryVisitable { - - public byte [] Start; - public byte [] End; - - public uint Lfanew; - - internal DOSHeader () - { - } - - public void SetDefaultValues () - { - Start = new byte [60] { - 0x4d, 0x5a, 0x90, 0x00, 0x03, 0x00, 0x00, - 0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0xff, - 0x00, 0x00, 0xb8, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 - }; - Lfanew = 128; - End = new byte [64] { - 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, - 0xcd, 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, - 0x54, 0x68, 0x69, 0x73, 0x20, 0x70, 0x72, - 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x20, 0x63, - 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x20, 0x62, - 0x65, 0x20, 0x72, 0x75, 0x6e, 0x20, 0x69, - 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, 0x6d, - 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, - 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00 - }; - } - - public void Accept (IBinaryVisitor visitor) - { - visitor.VisitDOSHeader (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ExportTable.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ExportTable.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ExportTable.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ExportTable.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -// -// ExportTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2007 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - public sealed class ExportTable : IBinaryVisitable { - - public uint Characteristics; - public uint TimeDateStamp; - public ushort MajorVersion; - public ushort MinorVersion; - public string Name; - public uint Base; - public uint NumberOfFunctions; - public uint NumberOfNames; - public RVA AddressOfFunctions; - public RVA AddressOfNames; - public RVA AddressOfNameOrdinals; - - public RVA [] AddressesOfFunctions; - public RVA [] AddressesOfNames; - public ushort [] NameOrdinals; - public string [] Names; - - internal ExportTable () - { - } - - public void Accept (IBinaryVisitor visitor) - { - visitor.VisitExportTable (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/IBinaryVisitable.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/IBinaryVisitable.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/IBinaryVisitable.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/IBinaryVisitable.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// -// IBinaryVisitable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - public interface IBinaryVisitable { - void Accept (IBinaryVisitor visitor); - } -} - diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/IBinaryVisitor.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/IBinaryVisitor.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/IBinaryVisitor.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/IBinaryVisitor.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -// -// IBinaryVisitor.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 - 2007 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - public interface IBinaryVisitor { - void VisitImage (Image img); - void VisitDOSHeader (DOSHeader header); - void VisitPEFileHeader (PEFileHeader header); - void VisitPEOptionalHeader (PEOptionalHeader header); - void VisitStandardFieldsHeader (PEOptionalHeader.StandardFieldsHeader header); - void VisitNTSpecificFieldsHeader (PEOptionalHeader.NTSpecificFieldsHeader header); - void VisitDataDirectoriesHeader (PEOptionalHeader.DataDirectoriesHeader header); - void VisitSectionCollection (SectionCollection coll); - void VisitSection (Section section); - void VisitImportAddressTable (ImportAddressTable iat); - void VisitDebugHeader (DebugHeader dh); - void VisitCLIHeader (CLIHeader header); - void VisitImportTable (ImportTable it); - void VisitImportLookupTable (ImportLookupTable ilt); - void VisitHintNameTable (HintNameTable hnt); - void VisitExportTable (ExportTable et); - - void TerminateImage (Image img); - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/IHeader.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/IHeader.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/IHeader.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/IHeader.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// -// IHeader.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - internal interface IHeader { - void SetDefaultValues (); - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageCharacteristics.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageCharacteristics.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageCharacteristics.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageCharacteristics.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -// -// ImageCharacteristics.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - using System; - - [Flags] - public enum ImageCharacteristics : ushort { - RelocsStripped = 0x0001, - ExecutableImage = 0x0002, - LineNumsStripped = 0x0004, - LocalSymsStripped = 0x0008, - AggressiveWSTrim = 0x0010, - LargeAddressAware = 0x0020, - ReservedForFutureUse = 0x0040, - BytesReversedLo = 0x0080, - _32BitsMachine = 0x0100, - DebugStripped = 0x0200, - RemovableRunFromSwap = 0x0400, - NetRunFromSwap = 0x0800, - System = 0x1000, - Dll = 0x2000, - UPSystemOnly = 0x4000, - BytesReversedHI = 0x8000, - - __flags = 0x0002 | 0x0004 | 0x0008 | 0x0100, - - CILOnlyDll = 0x2000 | (ushort) __flags, - CILOnlyExe = __flags - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/Image.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/Image.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/Image.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/Image.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,236 +0,0 @@ -// -// Image.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 - 2007 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - using System; - using System.IO; - - using Mono.Cecil.Metadata; - - public sealed class Image : IBinaryVisitable { - - DOSHeader m_dosHeader; - PEFileHeader m_peFileHeader; - PEOptionalHeader m_peOptionalHeader; - - SectionCollection m_sections; - Section m_textSection; - - ImportAddressTable m_importAddressTable; - CLIHeader m_cliHeader; - ImportTable m_importTable; - ImportLookupTable m_importLookupTable; - HintNameTable m_hintNameTable; - ExportTable m_exportTable; - - DebugHeader m_debugHeader; - MetadataRoot m_mdRoot; - - ResourceDirectoryTable m_rsrcRoot; - - FileInfo m_img; - - public DOSHeader DOSHeader { - get { return m_dosHeader; } - } - - public PEFileHeader PEFileHeader { - get { return m_peFileHeader; } - } - - public PEOptionalHeader PEOptionalHeader { - get { return m_peOptionalHeader; } - } - - public SectionCollection Sections { - get { return m_sections; } - } - - public Section TextSection { - get { return m_textSection; } - set { m_textSection = value; } - } - - public ImportAddressTable ImportAddressTable { - get { return m_importAddressTable; } - } - - public CLIHeader CLIHeader { - get { return m_cliHeader; } - set { m_cliHeader = value; } - } - - public DebugHeader DebugHeader { - get { return m_debugHeader; } - set { m_debugHeader = value; } - } - - public MetadataRoot MetadataRoot { - get { return m_mdRoot; } - } - - public ImportTable ImportTable { - get { return m_importTable; } - } - - public ImportLookupTable ImportLookupTable { - get { return m_importLookupTable; } - } - - public HintNameTable HintNameTable { - get { return m_hintNameTable; } - } - - public ExportTable ExportTable { - get { return m_exportTable; } - set { m_exportTable = value; } - } - - internal ResourceDirectoryTable ResourceDirectoryRoot { - get { return m_rsrcRoot; } - set { m_rsrcRoot = value; } - } - - public FileInfo FileInformation { - get { return m_img; } - } - - internal Image () - { - m_dosHeader = new DOSHeader (); - m_peFileHeader = new PEFileHeader (); - m_peOptionalHeader = new PEOptionalHeader (); - m_sections = new SectionCollection (); - m_importAddressTable = new ImportAddressTable (); - m_importTable = new ImportTable (); - m_importLookupTable = new ImportLookupTable (); - m_hintNameTable = new HintNameTable (); - m_mdRoot = new MetadataRoot (this); - } - - internal Image (FileInfo img) : this () - { - m_img = img; - } - - public long ResolveVirtualAddress (RVA rva) - { - foreach (Section sect in this.Sections) { - if (rva >= sect.VirtualAddress && - rva < sect.VirtualAddress + sect.SizeOfRawData) - - return rva + sect.PointerToRawData - sect.VirtualAddress; - } - - throw new ArgumentOutOfRangeException ("Cannot map the rva to any section"); - } - - public BinaryReader GetReaderAtVirtualAddress (RVA rva) - { - foreach (Section sect in this.Sections) { - if (rva >= sect.VirtualAddress && - rva < sect.VirtualAddress + sect.SizeOfRawData) { - - BinaryReader br = new BinaryReader (new MemoryStream (sect.Data)); - br.BaseStream.Position = rva - sect.VirtualAddress; - return br; - } - } - - return null; - } - - public void AddDebugHeader () - { - m_debugHeader = new DebugHeader (); - m_debugHeader.SetDefaultValues (); - } - - internal void SetFileInfo (FileInfo file) - { - m_img = file; - } - - public void Accept (IBinaryVisitor visitor) - { - visitor.VisitImage (this); - - m_dosHeader.Accept (visitor); - m_peFileHeader.Accept (visitor); - m_peOptionalHeader.Accept (visitor); - - m_sections.Accept (visitor); - - m_importAddressTable.Accept (visitor); - - AcceptIfNotNull (m_cliHeader, visitor); - AcceptIfNotNull (m_debugHeader, visitor); - - m_importTable.Accept (visitor); - m_importLookupTable.Accept (visitor); - m_hintNameTable.Accept (visitor); - AcceptIfNotNull (m_exportTable, visitor); - - visitor.TerminateImage (this); - } - - static void AcceptIfNotNull (IBinaryVisitable visitable, IBinaryVisitor visitor) - { - if (visitable == null) - return; - - visitable.Accept (visitor); - } - - public static Image CreateImage () - { - Image img = new Image (); - - ImageInitializer init = new ImageInitializer (img); - img.Accept (init); - - return img; - } - - public static Image GetImage (string file) - { - return ImageReader.Read (file).Image; - } - - public static Image GetImage (byte [] image) - { - return ImageReader.Read (image).Image; - } - - public static Image GetImage (Stream stream) - { - return ImageReader.Read (stream).Image; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageFormatException.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageFormatException.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageFormatException.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageFormatException.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -// -// ImageFormatException.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - using System; - - public class ImageFormatException : Exception { - - internal ImageFormatException () : base() - { - } - - internal ImageFormatException (string message) : base(message) - { - } - - internal ImageFormatException (string message, params string[] parameters) : - base(string.Format(message, parameters)) - { - } - - internal ImageFormatException (string message, Exception inner) : - base(message, inner) - { - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageInitializer.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageInitializer.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageInitializer.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageInitializer.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,139 +0,0 @@ -// -// ImageInitializer.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - using System; - - using Mono.Cecil.Metadata; - - class ImageInitializer : BaseImageVisitor { - - Image m_image; - MetadataInitializer m_mdinit; - - public Image Image { - get { return m_image; } - } - - public MetadataInitializer Metadata { - get { return m_mdinit; } - } - - public ImageInitializer (Image image) - { - m_image = image; - m_image.CLIHeader = new CLIHeader (); - m_mdinit = new MetadataInitializer (this); - } - - public override void VisitDOSHeader (DOSHeader header) - { - header.SetDefaultValues (); - } - - public override void VisitPEOptionalHeader (PEOptionalHeader header) - { - header.SetDefaultValues (); - } - - public override void VisitPEFileHeader (PEFileHeader header) - { - header.SetDefaultValues (); - header.TimeDateStamp = TimeDateStampFromEpoch (); - } - - public override void VisitNTSpecificFieldsHeader (PEOptionalHeader.NTSpecificFieldsHeader header) - { - header.SetDefaultValues (); - } - - public override void VisitStandardFieldsHeader (PEOptionalHeader.StandardFieldsHeader header) - { - header.SetDefaultValues (); - } - - public override void VisitDataDirectoriesHeader (PEOptionalHeader.DataDirectoriesHeader header) - { - header.SetDefaultValues (); - } - - public override void VisitSectionCollection (SectionCollection coll) - { - Section text = new Section (); - text.Name = Section.Text; - text.Characteristics = SectionCharacteristics.ContainsCode | - SectionCharacteristics.MemoryRead | SectionCharacteristics.MemExecute; - m_image.TextSection = text; - - Section reloc = new Section (); - reloc.Name = Section.Relocs; - reloc.Characteristics = SectionCharacteristics.ContainsInitializedData | - SectionCharacteristics.MemDiscardable | SectionCharacteristics.MemoryRead; - - coll.Add (text); - coll.Add (reloc); - } - - public override void VisitSection (Section sect) - { - sect.SetDefaultValues (); - } - - public override void VisitDebugHeader (DebugHeader dh) - { - if (dh != null) - dh.SetDefaultValues (); - } - - public override void VisitCLIHeader (CLIHeader header) - { - header.SetDefaultValues (); - m_image.MetadataRoot.Accept (m_mdinit); - } - - public override void VisitImportTable (ImportTable it) - { - it.ImportAddressTable = new RVA (0x2000); - } - - public override void VisitHintNameTable (HintNameTable hnt) - { - hnt.Hint = 0; - hnt.RuntimeLibrary = HintNameTable.RuntimeCorEE; - hnt.EntryPoint = 0x25ff; - hnt.RVA = new RVA (0x402000); - } - - public static uint TimeDateStampFromEpoch () - { - return (uint) DateTime.UtcNow.Subtract ( - new DateTime (1970, 1, 1)).TotalSeconds; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageReader.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageReader.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageReader.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageReader.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,472 +0,0 @@ -// -// ImageReader.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 - 2007 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - using System; - using System.IO; - using System.Text; - - using Mono.Cecil.Metadata; - - class ImageReader : BaseImageVisitor { - - MetadataReader m_mdReader; - BinaryReader m_binaryReader; - Image m_image; - - public MetadataReader MetadataReader { - get { return m_mdReader; } - } - - public Image Image { - get { return m_image; } - } - - ImageReader (Image img, BinaryReader reader) - { - m_image = img; - m_binaryReader = reader; - } - - static ImageReader Read (Image img, Stream stream) - { - ImageReader reader = new ImageReader (img, new BinaryReader (stream)); - img.Accept (reader); - return reader; - } - - public static ImageReader Read (string file) - { - if (file == null) - throw new ArgumentNullException ("file"); - - FileInfo fi = new FileInfo (file); - if (!File.Exists (fi.FullName)) - #if CF_1_0 || CF_2_0 - throw new FileNotFoundException (fi.FullName); - #else - throw new FileNotFoundException (string.Format ("File '{0}' not found.", fi.FullName), fi.FullName); - #endif - - return Read (new Image (fi), new FileStream ( - fi.FullName, FileMode.Open, - FileAccess.Read, FileShare.Read)); - } - - public static ImageReader Read (byte [] image) - { - if (image == null) - throw new ArgumentNullException ("image"); - - if (image.Length == 0) - throw new ArgumentException ("Empty image array"); - - return Read (new Image (), new MemoryStream (image)); - } - - public static ImageReader Read (Stream stream) - { - if (stream == null) - throw new ArgumentNullException ("stream"); - - if (!stream.CanRead) - throw new ArgumentException ("Can not read from stream"); - - return Read (new Image (), stream); - } - - public BinaryReader GetReader () - { - return m_binaryReader; - } - - public override void VisitImage (Image img) - { - m_mdReader = new MetadataReader (this); - } - - void SetPositionToAddress (RVA address) - { - m_binaryReader.BaseStream.Position = m_image.ResolveVirtualAddress (address); - } - - public override void VisitDOSHeader (DOSHeader header) - { - header.Start = m_binaryReader.ReadBytes (60); - header.Lfanew = m_binaryReader.ReadUInt32 (); - header.End = m_binaryReader.ReadBytes (64); - - m_binaryReader.BaseStream.Position = header.Lfanew; - - if (m_binaryReader.ReadUInt16 () != 0x4550 || - m_binaryReader.ReadUInt16 () != 0) - - throw new ImageFormatException ("Invalid PE File Signature"); - } - - public override void VisitPEFileHeader (PEFileHeader header) - { - header.Machine = m_binaryReader.ReadUInt16 (); - header.NumberOfSections = m_binaryReader.ReadUInt16 (); - header.TimeDateStamp = m_binaryReader.ReadUInt32 (); - header.PointerToSymbolTable = m_binaryReader.ReadUInt32 (); - header.NumberOfSymbols = m_binaryReader.ReadUInt32 (); - header.OptionalHeaderSize = m_binaryReader.ReadUInt16 (); - header.Characteristics = (ImageCharacteristics) m_binaryReader.ReadUInt16 (); - } - - ulong ReadIntOrLong () - { - return m_image.PEOptionalHeader.StandardFields.IsPE64 ? - m_binaryReader.ReadUInt64 () : - m_binaryReader.ReadUInt32 (); - } - - RVA ReadRVA () - { - return m_binaryReader.ReadUInt32 (); - } - - DataDirectory ReadDataDirectory () - { - return new DataDirectory (ReadRVA (), m_binaryReader.ReadUInt32 ()); - } - - public override void VisitNTSpecificFieldsHeader (PEOptionalHeader.NTSpecificFieldsHeader header) - { - header.ImageBase = ReadIntOrLong (); - header.SectionAlignment = m_binaryReader.ReadUInt32 (); - header.FileAlignment = m_binaryReader.ReadUInt32 (); - header.OSMajor = m_binaryReader.ReadUInt16 (); - header.OSMinor = m_binaryReader.ReadUInt16 (); - header.UserMajor = m_binaryReader.ReadUInt16 (); - header.UserMinor = m_binaryReader.ReadUInt16 (); - header.SubSysMajor = m_binaryReader.ReadUInt16 (); - header.SubSysMinor = m_binaryReader.ReadUInt16 (); - header.Reserved = m_binaryReader.ReadUInt32 (); - header.ImageSize = m_binaryReader.ReadUInt32 (); - header.HeaderSize = m_binaryReader.ReadUInt32 (); - header.FileChecksum = m_binaryReader.ReadUInt32 (); - header.SubSystem = (SubSystem) m_binaryReader.ReadUInt16 (); - header.DLLFlags = m_binaryReader.ReadUInt16 (); - header.StackReserveSize = ReadIntOrLong (); - header.StackCommitSize = ReadIntOrLong (); - header.HeapReserveSize = ReadIntOrLong (); - header.HeapCommitSize = ReadIntOrLong (); - header.LoaderFlags = m_binaryReader.ReadUInt32 (); - header.NumberOfDataDir = m_binaryReader.ReadUInt32 (); - } - - public override void VisitStandardFieldsHeader (PEOptionalHeader.StandardFieldsHeader header) - { - header.Magic = m_binaryReader.ReadUInt16 (); - header.LMajor = m_binaryReader.ReadByte (); - header.LMinor = m_binaryReader.ReadByte (); - header.CodeSize = m_binaryReader.ReadUInt32 (); - header.InitializedDataSize = m_binaryReader.ReadUInt32 (); - header.UninitializedDataSize = m_binaryReader.ReadUInt32 (); - header.EntryPointRVA = ReadRVA (); - header.BaseOfCode = ReadRVA (); - if (!header.IsPE64) - header.BaseOfData = ReadRVA (); - } - - public override void VisitDataDirectoriesHeader (PEOptionalHeader.DataDirectoriesHeader header) - { - header.ExportTable = ReadDataDirectory (); - header.ImportTable = ReadDataDirectory (); - header.ResourceTable = ReadDataDirectory (); - header.ExceptionTable = ReadDataDirectory (); - header.CertificateTable = ReadDataDirectory (); - header.BaseRelocationTable = ReadDataDirectory (); - header.Debug = ReadDataDirectory (); - header.Copyright = ReadDataDirectory (); - header.GlobalPtr = ReadDataDirectory (); - header.TLSTable = ReadDataDirectory (); - header.LoadConfigTable = ReadDataDirectory (); - header.BoundImport = ReadDataDirectory (); - header.IAT = ReadDataDirectory (); - header.DelayImportDescriptor = ReadDataDirectory (); - header.CLIHeader = ReadDataDirectory (); - header.Reserved = ReadDataDirectory (); - - if (header.CLIHeader != DataDirectory.Zero) - m_image.CLIHeader = new CLIHeader (); - if (header.ExportTable != DataDirectory.Zero) - m_image.ExportTable = new ExportTable (); - } - - public override void VisitSectionCollection (SectionCollection coll) - { - for (int i = 0; i < m_image.PEFileHeader.NumberOfSections; i++) - coll.Add (new Section ()); - } - - public override void VisitSection (Section sect) - { - char [] buffer = new char [8]; - int read = 0; - while (read < 8) { - char cur = (char) m_binaryReader.ReadSByte (); - if (cur == '\0') { - m_binaryReader.BaseStream.Position += 8 - read - 1; - break; - } - buffer [read++] = cur; - } - sect.Name = read == 0 ? string.Empty : new string (buffer, 0, read); - if (sect.Name == Section.Text) - m_image.TextSection = sect; - - sect.VirtualSize = m_binaryReader.ReadUInt32 (); - sect.VirtualAddress = ReadRVA (); - sect.SizeOfRawData = m_binaryReader.ReadUInt32 (); - sect.PointerToRawData = ReadRVA (); - sect.PointerToRelocations = ReadRVA (); - sect.PointerToLineNumbers = ReadRVA (); - sect.NumberOfRelocations = m_binaryReader.ReadUInt16 (); - sect.NumberOfLineNumbers = m_binaryReader.ReadUInt16 (); - sect.Characteristics = (SectionCharacteristics) m_binaryReader.ReadUInt32 (); - - long pos = m_binaryReader.BaseStream.Position; - m_binaryReader.BaseStream.Position = sect.PointerToRawData; - sect.Data = m_binaryReader.ReadBytes ((int) sect.SizeOfRawData); - m_binaryReader.BaseStream.Position = pos; - } - - public override void VisitImportAddressTable (ImportAddressTable iat) - { - if (m_image.PEOptionalHeader.DataDirectories.IAT.VirtualAddress == RVA.Zero) - return; - - SetPositionToAddress (m_image.PEOptionalHeader.DataDirectories.IAT.VirtualAddress); - - iat.HintNameTableRVA = ReadRVA (); - } - - public override void VisitCLIHeader (CLIHeader header) - { - if (m_image.PEOptionalHeader.DataDirectories.Debug != DataDirectory.Zero) { - m_image.DebugHeader = new DebugHeader (); - VisitDebugHeader (m_image.DebugHeader); - } - - SetPositionToAddress (m_image.PEOptionalHeader.DataDirectories.CLIHeader.VirtualAddress); - header.Cb = m_binaryReader.ReadUInt32 (); - header.MajorRuntimeVersion = m_binaryReader.ReadUInt16 (); - header.MinorRuntimeVersion = m_binaryReader.ReadUInt16 (); - header.Metadata = ReadDataDirectory (); - header.Flags = (RuntimeImage) m_binaryReader.ReadUInt32 (); - header.EntryPointToken = m_binaryReader.ReadUInt32 (); - header.Resources = ReadDataDirectory (); - header.StrongNameSignature = ReadDataDirectory (); - header.CodeManagerTable = ReadDataDirectory (); - header.VTableFixups = ReadDataDirectory (); - header.ExportAddressTableJumps = ReadDataDirectory (); - header.ManagedNativeHeader = ReadDataDirectory (); - - if (header.StrongNameSignature != DataDirectory.Zero) { - SetPositionToAddress (header.StrongNameSignature.VirtualAddress); - header.ImageHash = m_binaryReader.ReadBytes ((int) header.StrongNameSignature.Size); - } else - header.ImageHash = new byte [0]; - - SetPositionToAddress (m_image.CLIHeader.Metadata.VirtualAddress); - m_image.MetadataRoot.Accept (m_mdReader); - } - - public override void VisitDebugHeader (DebugHeader header) - { - if (m_image.PEOptionalHeader.DataDirectories.Debug == DataDirectory.Zero) - return; - - long pos = m_binaryReader.BaseStream.Position; - - SetPositionToAddress (m_image.PEOptionalHeader.DataDirectories.Debug.VirtualAddress); - header.Characteristics = m_binaryReader.ReadUInt32 (); - header.TimeDateStamp = m_binaryReader.ReadUInt32 (); - header.MajorVersion = m_binaryReader.ReadUInt16 (); - header.MinorVersion = m_binaryReader.ReadUInt16 (); - header.Type = (DebugStoreType) m_binaryReader.ReadUInt32 (); - header.SizeOfData = m_binaryReader.ReadUInt32 (); - header.AddressOfRawData = ReadRVA (); - header.PointerToRawData = m_binaryReader.ReadUInt32 (); - - m_binaryReader.BaseStream.Position = header.PointerToRawData; - - header.Magic = m_binaryReader.ReadUInt32 (); - header.Signature = new Guid (m_binaryReader.ReadBytes (16)); - header.Age = m_binaryReader.ReadUInt32 (); - header.FileName = ReadZeroTerminatedString (); - - m_binaryReader.BaseStream.Position = pos; - } - - string ReadZeroTerminatedString () - { - StringBuilder sb = new StringBuilder (); - while (true) { - byte chr = m_binaryReader.ReadByte (); - if (chr == 0) - break; - sb.Append ((char) chr); - } - return sb.ToString (); - } - - public override void VisitImportTable (ImportTable it) - { - if (m_image.PEOptionalHeader.DataDirectories.ImportTable.VirtualAddress == RVA.Zero) - return; - - SetPositionToAddress (m_image.PEOptionalHeader.DataDirectories.ImportTable.VirtualAddress); - - it.ImportLookupTable = ReadRVA (); - it.DateTimeStamp = m_binaryReader.ReadUInt32 (); - it.ForwardChain = m_binaryReader.ReadUInt32 (); - it.Name = ReadRVA (); - it.ImportAddressTable = ReadRVA (); - } - - public override void VisitImportLookupTable (ImportLookupTable ilt) - { - if (m_image.ImportTable.ImportLookupTable == RVA.Zero) - return; - - SetPositionToAddress (m_image.ImportTable.ImportLookupTable); - - ilt.HintNameRVA = ReadRVA (); - } - - public override void VisitHintNameTable (HintNameTable hnt) - { - if (m_image.ImportAddressTable.HintNameTableRVA == RVA.Zero) - return; - - SetPositionToAddress (m_image.ImportAddressTable.HintNameTableRVA); - - hnt.Hint = m_binaryReader.ReadUInt16 (); - - byte [] bytes = m_binaryReader.ReadBytes (11); - hnt.RuntimeMain = Encoding.ASCII.GetString (bytes, 0, bytes.Length); - - SetPositionToAddress (m_image.ImportTable.Name); - - bytes = m_binaryReader.ReadBytes (11); - hnt.RuntimeLibrary = Encoding.ASCII.GetString (bytes, 0, bytes.Length); - - SetPositionToAddress (m_image.PEOptionalHeader.StandardFields.EntryPointRVA); - hnt.EntryPoint = m_binaryReader.ReadUInt16 (); - hnt.RVA = ReadRVA (); - } - - public override void VisitExportTable (ExportTable et) - { - SetPositionToAddress (m_image.PEOptionalHeader.DataDirectories.ExportTable.VirtualAddress); - - et.Characteristics = m_binaryReader.ReadUInt32 (); - et.TimeDateStamp = m_binaryReader.ReadUInt32 (); - et.MajorVersion = m_binaryReader.ReadUInt16 (); - et.MinorVersion = m_binaryReader.ReadUInt16 (); - - //et.Name = - m_binaryReader.ReadUInt32 (); - - et.Base = m_binaryReader.ReadUInt32 (); - et.NumberOfFunctions = m_binaryReader.ReadUInt32 (); - et.NumberOfNames = m_binaryReader.ReadUInt32 (); - et.AddressOfFunctions = m_binaryReader.ReadUInt32 (); - et.AddressOfNames = m_binaryReader.ReadUInt32 (); - et.AddressOfNameOrdinals = m_binaryReader.ReadUInt32 (); - - et.AddressesOfFunctions = ReadArrayOfRVA (et.AddressOfFunctions, et.NumberOfFunctions); - et.AddressesOfNames = ReadArrayOfRVA (et.AddressOfNames, et.NumberOfNames); - et.NameOrdinals = ReadArrayOfUInt16 (et.AddressOfNameOrdinals, et.NumberOfNames); - et.Names = new string [et.NumberOfFunctions]; - - for (int i = 0; i < et.NumberOfFunctions; i++) { - if (et.AddressesOfFunctions [i] == 0) - continue; - - et.Names [i] = ReadFunctionName (et, i); - } - } - - string ReadFunctionName (ExportTable et, int index) - { - for (int i = 0; i < et.NumberOfNames; i++) { - if (et.NameOrdinals [i] != index) - continue; - - SetPositionToAddress (et.AddressesOfNames [i]); - return ReadZeroTerminatedString (); - } - - return string.Empty; - } - - ushort [] ReadArrayOfUInt16 (RVA position, uint length) - { - if (position == RVA.Zero) - return new ushort [0]; - - SetPositionToAddress (position); - ushort [] array = new ushort [length]; - for (int i = 0; i < length; i++) - array [i] = m_binaryReader.ReadUInt16 (); - - return array; - } - - RVA [] ReadArrayOfRVA (RVA position, uint length) - { - if (position == RVA.Zero) - return new RVA [0]; - - SetPositionToAddress (position); - RVA [] addresses = new RVA [length]; - for (int i = 0; i < length; i++) - addresses [i] = m_binaryReader.ReadUInt32 (); - - return addresses; - } - - public override void TerminateImage(Image img) - { - m_binaryReader.Close (); - - try { - ResourceReader resReader = new ResourceReader (img); - img.ResourceDirectoryRoot = resReader.Read (); - } catch { - img.ResourceDirectoryRoot = null; - } - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageWriter.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageWriter.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageWriter.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageWriter.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,427 +0,0 @@ -// -// ImageWriter.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - using System.IO; - using System.Text; - - using Mono.Cecil.Metadata; - - class ImageWriter : BaseImageVisitor { - - Image m_img; - AssemblyKind m_kind; - MetadataWriter m_mdWriter; - BinaryWriter m_binaryWriter; - - Section m_textSect; - MemoryBinaryWriter m_textWriter; - Section m_relocSect; - MemoryBinaryWriter m_relocWriter; - Section m_rsrcSect; - MemoryBinaryWriter m_rsrcWriter; - - public ImageWriter (MetadataWriter writer, AssemblyKind kind, BinaryWriter bw) - { - m_mdWriter= writer; - m_img = writer.GetMetadataRoot ().GetImage (); - m_kind = kind; - m_binaryWriter = bw; - - m_textWriter = new MemoryBinaryWriter (); - m_textWriter.BaseStream.Position = 80; - m_relocWriter = new MemoryBinaryWriter (); - } - - public Image GetImage () - { - return m_img; - } - - public MemoryBinaryWriter GetTextWriter () - { - return m_textWriter; - } - - public uint GetAligned (uint integer, uint alignWith) - { - return (integer + alignWith - 1) & ~(alignWith - 1); - } - - public void Initialize () - { - Image img = m_img; - ResourceWriter resWriter = null; - - uint sectAlign = img.PEOptionalHeader.NTSpecificFields.SectionAlignment; - uint fileAlign = img.PEOptionalHeader.NTSpecificFields.FileAlignment; - - m_textSect = img.TextSection; - foreach (Section s in img.Sections) { - if (s.Name == Section.Relocs) - m_relocSect = s; - else if (s.Name == Section.Resources) { - m_rsrcSect = s; - m_rsrcWriter = new MemoryBinaryWriter (); - - resWriter = new ResourceWriter (img, m_rsrcSect, m_rsrcWriter); - resWriter.Write (); - } - } - - // size computations, fields setting, etc. - uint nbSects = (uint) img.Sections.Count; - img.PEFileHeader.NumberOfSections = (ushort) nbSects; - - // build the reloc section data - uint relocSize = 12; - m_relocWriter.Write ((uint) 0); - m_relocWriter.Write (relocSize); - m_relocWriter.Write ((ushort) 0); - m_relocWriter.Write ((ushort) 0); - - m_textSect.VirtualSize = (uint) m_textWriter.BaseStream.Length; - m_relocSect.VirtualSize = (uint) m_relocWriter.BaseStream.Length; - if (m_rsrcSect != null) - m_rsrcSect.VirtualSize = (uint) m_rsrcWriter.BaseStream.Length; - - // start counting before sections headers - // section start + section header sixe * number of sections - uint headersEnd = 0x178 + 0x28 * nbSects; - uint fileOffset = headersEnd; - uint sectOffset = sectAlign; - uint imageSize = 0; - - foreach (Section sect in img.Sections) { - fileOffset = GetAligned (fileOffset, fileAlign); - sectOffset = GetAligned (sectOffset, sectAlign); - - sect.PointerToRawData = new RVA (fileOffset); - sect.VirtualAddress = new RVA (sectOffset); - sect.SizeOfRawData = GetAligned (sect.VirtualSize, fileAlign); - - fileOffset += sect.SizeOfRawData; - sectOffset += sect.SizeOfRawData; - imageSize += GetAligned (sect.SizeOfRawData, sectAlign); - } - - if (m_textSect.VirtualAddress.Value != 0x2000) - throw new ImageFormatException ("Wrong RVA for .text section"); - - if (resWriter != null) - resWriter.Patch (); - - img.PEOptionalHeader.StandardFields.CodeSize = GetAligned ( - m_textSect.SizeOfRawData, fileAlign); - img.PEOptionalHeader.StandardFields.InitializedDataSize = m_textSect.SizeOfRawData; - if (m_rsrcSect != null) - img.PEOptionalHeader.StandardFields.InitializedDataSize += m_rsrcSect.SizeOfRawData; - img.PEOptionalHeader.StandardFields.BaseOfCode = m_textSect.VirtualAddress; - img.PEOptionalHeader.StandardFields.BaseOfData = m_relocSect.VirtualAddress; - - imageSize += headersEnd; - img.PEOptionalHeader.NTSpecificFields.ImageSize = GetAligned (imageSize, sectAlign); - - img.PEOptionalHeader.DataDirectories.BaseRelocationTable = new DataDirectory ( - m_relocSect.VirtualAddress, m_relocSect.VirtualSize); - if (m_rsrcSect != null) - img.PEOptionalHeader.DataDirectories.ResourceTable = new DataDirectory ( - m_rsrcSect.VirtualAddress, (uint) m_rsrcWriter.BaseStream.Length); - - if (m_kind == AssemblyKind.Dll) { - img.PEFileHeader.Characteristics = ImageCharacteristics.CILOnlyDll; - img.HintNameTable.RuntimeMain = HintNameTable.RuntimeMainDll; - img.PEOptionalHeader.NTSpecificFields.DLLFlags = 0x400; - } else { - img.PEFileHeader.Characteristics = ImageCharacteristics.CILOnlyExe; - img.HintNameTable.RuntimeMain = HintNameTable.RuntimeMainExe; - } - - switch (m_kind) { - case AssemblyKind.Dll : - case AssemblyKind.Console : - img.PEOptionalHeader.NTSpecificFields.SubSystem = SubSystem.WindowsCui; - break; - case AssemblyKind.Windows : - img.PEOptionalHeader.NTSpecificFields.SubSystem = SubSystem.WindowsGui; - break; - } - - RVA importTable = new RVA (img.TextSection.VirtualAddress + m_mdWriter.ImportTablePosition); - - img.PEOptionalHeader.DataDirectories.ImportTable = new DataDirectory (importTable, 0x57); - - img.ImportTable.ImportLookupTable = new RVA ((uint) importTable + 0x28); - - img.ImportLookupTable.HintNameRVA = img.ImportAddressTable.HintNameTableRVA = - new RVA ((uint) img.ImportTable.ImportLookupTable + 0x14); - img.ImportTable.Name = new RVA ((uint) img.ImportLookupTable.HintNameRVA + 0xe); - } - - public override void VisitDOSHeader (DOSHeader header) - { - m_binaryWriter.Write (header.Start); - m_binaryWriter.Write (header.Lfanew); - m_binaryWriter.Write (header.End); - - m_binaryWriter.Write ((ushort) 0x4550); - m_binaryWriter.Write ((ushort) 0); - } - - public override void VisitPEFileHeader (PEFileHeader header) - { - m_binaryWriter.Write (header.Machine); - m_binaryWriter.Write (header.NumberOfSections); - m_binaryWriter.Write (header.TimeDateStamp); - m_binaryWriter.Write (header.PointerToSymbolTable); - m_binaryWriter.Write (header.NumberOfSymbols); - m_binaryWriter.Write (header.OptionalHeaderSize); - m_binaryWriter.Write ((ushort) header.Characteristics); - } - - public override void VisitNTSpecificFieldsHeader (PEOptionalHeader.NTSpecificFieldsHeader header) - { - WriteIntOrLong (header.ImageBase); - m_binaryWriter.Write (header.SectionAlignment); - m_binaryWriter.Write (header.FileAlignment); - m_binaryWriter.Write (header.OSMajor); - m_binaryWriter.Write (header.OSMinor); - m_binaryWriter.Write (header.UserMajor); - m_binaryWriter.Write (header.UserMinor); - m_binaryWriter.Write (header.SubSysMajor); - m_binaryWriter.Write (header.SubSysMinor); - m_binaryWriter.Write (header.Reserved); - m_binaryWriter.Write (header.ImageSize); - m_binaryWriter.Write (header.HeaderSize); - m_binaryWriter.Write (header.FileChecksum); - m_binaryWriter.Write ((ushort) header.SubSystem); - m_binaryWriter.Write (header.DLLFlags); - WriteIntOrLong (header.StackReserveSize); - WriteIntOrLong (header.StackCommitSize); - WriteIntOrLong (header.HeapReserveSize); - WriteIntOrLong (header.HeapCommitSize); - m_binaryWriter.Write (header.LoaderFlags); - m_binaryWriter.Write (header.NumberOfDataDir); - } - - public override void VisitStandardFieldsHeader (PEOptionalHeader.StandardFieldsHeader header) - { - m_binaryWriter.Write (header.Magic); - m_binaryWriter.Write (header.LMajor); - m_binaryWriter.Write (header.LMinor); - m_binaryWriter.Write (header.CodeSize); - m_binaryWriter.Write (header.InitializedDataSize); - m_binaryWriter.Write (header.UninitializedDataSize); - m_binaryWriter.Write (header.EntryPointRVA.Value); - m_binaryWriter.Write (header.BaseOfCode.Value); - if (!header.IsPE64) - m_binaryWriter.Write (header.BaseOfData.Value); - } - - void WriteIntOrLong (ulong value) - { - if (m_img.PEOptionalHeader.StandardFields.IsPE64) - m_binaryWriter.Write (value); - else - m_binaryWriter.Write ((uint) value); - } - - public override void VisitDataDirectoriesHeader (PEOptionalHeader.DataDirectoriesHeader header) - { - m_binaryWriter.Write (header.ExportTable.VirtualAddress); - m_binaryWriter.Write (header.ExportTable.Size); - m_binaryWriter.Write (header.ImportTable.VirtualAddress); - m_binaryWriter.Write (header.ImportTable.Size); - m_binaryWriter.Write (header.ResourceTable.VirtualAddress); - m_binaryWriter.Write (header.ResourceTable.Size); - m_binaryWriter.Write (header.ExceptionTable.VirtualAddress); - m_binaryWriter.Write (header.ExceptionTable.Size); - m_binaryWriter.Write (header.CertificateTable.VirtualAddress); - m_binaryWriter.Write (header.CertificateTable.Size); - m_binaryWriter.Write (header.BaseRelocationTable.VirtualAddress); - m_binaryWriter.Write (header.BaseRelocationTable.Size); - m_binaryWriter.Write (header.Debug.VirtualAddress); - m_binaryWriter.Write (header.Debug.Size); - m_binaryWriter.Write (header.Copyright.VirtualAddress); - m_binaryWriter.Write (header.Copyright.Size); - m_binaryWriter.Write (header.GlobalPtr.VirtualAddress); - m_binaryWriter.Write (header.GlobalPtr.Size); - m_binaryWriter.Write (header.TLSTable.VirtualAddress); - m_binaryWriter.Write (header.TLSTable.Size); - m_binaryWriter.Write (header.LoadConfigTable.VirtualAddress); - m_binaryWriter.Write (header.LoadConfigTable.Size); - m_binaryWriter.Write (header.BoundImport.VirtualAddress); - m_binaryWriter.Write (header.BoundImport.Size); - m_binaryWriter.Write (header.IAT.VirtualAddress); - m_binaryWriter.Write (header.IAT.Size); - m_binaryWriter.Write (header.DelayImportDescriptor.VirtualAddress); - m_binaryWriter.Write (header.DelayImportDescriptor.Size); - m_binaryWriter.Write (header.CLIHeader.VirtualAddress); - m_binaryWriter.Write (header.CLIHeader.Size); - m_binaryWriter.Write (header.Reserved.VirtualAddress); - m_binaryWriter.Write (header.Reserved.Size); - } - - public override void VisitSection (Section sect) - { - m_binaryWriter.Write (Encoding.ASCII.GetBytes (sect.Name)); - int more = 8 - sect.Name.Length; - for (int i = 0; i < more; i++) - m_binaryWriter.Write ((byte) 0); - - m_binaryWriter.Write (sect.VirtualSize); - m_binaryWriter.Write (sect.VirtualAddress.Value); - m_binaryWriter.Write (sect.SizeOfRawData); - m_binaryWriter.Write (sect.PointerToRawData.Value); - m_binaryWriter.Write (sect.PointerToRelocations.Value); - m_binaryWriter.Write (sect.PointerToLineNumbers.Value); - m_binaryWriter.Write (sect.NumberOfRelocations); - m_binaryWriter.Write (sect.NumberOfLineNumbers); - m_binaryWriter.Write ((uint) sect.Characteristics); - } - - public override void VisitImportAddressTable (ImportAddressTable iat) - { - m_textWriter.BaseStream.Position = 0; - m_textWriter.Write (iat.HintNameTableRVA.Value); - m_textWriter.Write (new byte [4]); - } - - public override void VisitCLIHeader (CLIHeader header) - { - m_textWriter.Write (header.Cb); - m_textWriter.Write (header.MajorRuntimeVersion); - m_textWriter.Write (header.MinorRuntimeVersion); - m_textWriter.Write (header.Metadata.VirtualAddress); - m_textWriter.Write (header.Metadata.Size); - m_textWriter.Write ((uint) header.Flags); - m_textWriter.Write (header.EntryPointToken); - m_textWriter.Write (header.Resources.VirtualAddress); - m_textWriter.Write (header.Resources.Size); - m_textWriter.Write (header.StrongNameSignature.VirtualAddress); - m_textWriter.Write (header.StrongNameSignature.Size); - m_textWriter.Write (header.CodeManagerTable.VirtualAddress); - m_textWriter.Write (header.CodeManagerTable.Size); - m_textWriter.Write (header.VTableFixups.VirtualAddress); - m_textWriter.Write (header.VTableFixups.Size); - m_textWriter.Write (header.ExportAddressTableJumps.VirtualAddress); - m_textWriter.Write (header.ExportAddressTableJumps.Size); - m_textWriter.Write (header.ManagedNativeHeader.VirtualAddress); - m_textWriter.Write (header.ManagedNativeHeader.Size); - } - - public override void VisitDebugHeader (DebugHeader header) - { - m_textWriter.BaseStream.Position = m_mdWriter.DebugHeaderPosition; - uint sizeUntilData = 0x1c; - header.AddressOfRawData = m_img.TextSection.VirtualAddress + m_mdWriter.DebugHeaderPosition + sizeUntilData; - header.PointerToRawData = 0x200 + m_mdWriter.DebugHeaderPosition + sizeUntilData; - header.SizeOfData = 0x18 + (uint) header.FileName.Length + 1; - - m_textWriter.Write (header.Characteristics); - m_textWriter.Write (header.TimeDateStamp); - m_textWriter.Write (header.MajorVersion); - m_textWriter.Write (header.MinorVersion); - m_textWriter.Write ((uint) header.Type); - m_textWriter.Write (header.SizeOfData); - m_textWriter.Write (header.AddressOfRawData.Value); - m_textWriter.Write (header.PointerToRawData); - - m_textWriter.Write (header.Magic); - m_textWriter.Write (header.Signature.ToByteArray ()); - m_textWriter.Write (header.Age); - m_textWriter.Write (Encoding.ASCII.GetBytes (header.FileName)); - m_textWriter.Write ((byte) 0); - } - - public override void VisitImportTable (ImportTable it) - { - m_textWriter.BaseStream.Position = m_mdWriter.ImportTablePosition; - m_textWriter.Write (it.ImportLookupTable.Value); - m_textWriter.Write (it.DateTimeStamp); - m_textWriter.Write (it.ForwardChain); - m_textWriter.Write (it.Name.Value); - m_textWriter.Write (it.ImportAddressTable.Value); - m_textWriter.Write (new byte [20]); - } - - public override void VisitImportLookupTable (ImportLookupTable ilt) - { - m_textWriter.Write (ilt.HintNameRVA.Value); - m_textWriter.Write (new byte [16]); - } - - public override void VisitHintNameTable (HintNameTable hnt) - { - m_textWriter.Write (hnt.Hint); - m_textWriter.Write (Encoding.ASCII.GetBytes (hnt.RuntimeMain)); - m_textWriter.Write ('\0'); - m_textWriter.Write (Encoding.ASCII.GetBytes (hnt.RuntimeLibrary)); - m_textWriter.Write ('\0'); - m_textWriter.Write (new byte [4]); - - // patch header with ep rva - RVA ep = m_img.TextSection.VirtualAddress + - (uint) m_textWriter.BaseStream.Position; - long pos = m_binaryWriter.BaseStream.Position; - m_binaryWriter.BaseStream.Position = 0xa8; - m_binaryWriter.Write (ep.Value); - m_binaryWriter.BaseStream.Position = pos; - - // patch reloc Sect with ep - uint reloc = (ep.Value + 2) % 0x1000; - uint rva = (ep.Value + 2) - reloc; - - m_relocWriter.BaseStream.Position = 0; - m_relocWriter.Write (rva); - m_relocWriter.BaseStream.Position = 8; - m_relocWriter.Write ((ushort) ((3 << 12) | reloc)); - - m_textWriter.Write (hnt.EntryPoint); - m_textWriter.Write (hnt.RVA); - } - - public override void TerminateImage (Image img) - { - m_binaryWriter.BaseStream.Position = 0x200; - - WriteSection (m_textSect, m_textWriter); - WriteSection (m_relocSect, m_relocWriter); - if (m_rsrcSect != null) - WriteSection (m_rsrcSect, m_rsrcWriter); - } - - void WriteSection (Section sect, MemoryBinaryWriter sectWriter) - { - sectWriter.MemoryStream.WriteTo (m_binaryWriter.BaseStream); - m_binaryWriter.Write (new byte [ - sect.SizeOfRawData - sectWriter.BaseStream.Length]); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/Imports.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/Imports.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/Imports.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/Imports.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -// -// Imports.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - public sealed class ImportAddressTable : IBinaryVisitable { - - public RVA HintNameTableRVA; - - internal ImportAddressTable () - { - } - - public void Accept (IBinaryVisitor visitor) - { - visitor.VisitImportAddressTable (this); - } - } - - public sealed class ImportTable : IBinaryVisitable { - - public RVA ImportLookupTable; - public uint DateTimeStamp; - public uint ForwardChain; - public RVA Name; - public RVA ImportAddressTable; - - internal ImportTable () - { - } - - public void Accept (IBinaryVisitor visitor) - { - visitor.VisitImportTable (this); - } - } - - public sealed class ImportLookupTable : IBinaryVisitable { - - public RVA HintNameRVA; - - internal ImportLookupTable () - { - } - - public void Accept (IBinaryVisitor visitor) - { - visitor.VisitImportLookupTable (this); - } - } - - public sealed class HintNameTable : IBinaryVisitable { - - public const string RuntimeMainExe = "_CorExeMain"; - public const string RuntimeMainDll = "_CorDllMain"; - public const string RuntimeCorEE = "mscoree.dll"; - - public ushort Hint; - public string RuntimeMain; - public string RuntimeLibrary; - public ushort EntryPoint; - public RVA RVA; - - internal HintNameTable () - { - } - - public void Accept (IBinaryVisitor visitor) - { - visitor.VisitHintNameTable (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/MemoryBinaryWriter.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/MemoryBinaryWriter.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/MemoryBinaryWriter.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/MemoryBinaryWriter.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -// -// MemoryBinaryWriter.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - using System.IO; - using System.Text; - - internal sealed class MemoryBinaryWriter : BinaryWriter { - - public MemoryStream MemoryStream { - get { return (MemoryStream) this.BaseStream; } - } - - public MemoryBinaryWriter () : base (new MemoryStream ()) - { - } - - public MemoryBinaryWriter (Encoding enc) : base (new MemoryStream (), enc) - { - } - - public void Empty () - { - this.BaseStream.Position = 0; - this.BaseStream.SetLength (0); - } - - public void Write (MemoryBinaryWriter writer) - { - writer.MemoryStream.WriteTo (this.BaseStream); - } - - public byte [] ToArray () - { - return this.MemoryStream.ToArray (); - } - - public void QuadAlign () - { - this.BaseStream.Position += 3; - this.BaseStream.Position &= ~3; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/PEFileHeader.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/PEFileHeader.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/PEFileHeader.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/PEFileHeader.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -// -// PEFileHeader.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - public sealed class PEFileHeader : IHeader, IBinaryVisitable { - - public ushort Machine; - public ushort NumberOfSections; - public uint TimeDateStamp; - public uint PointerToSymbolTable; - public uint NumberOfSymbols; - public ushort OptionalHeaderSize; - public ImageCharacteristics Characteristics; - - internal PEFileHeader () - { - } - - public void SetDefaultValues () - { - Machine = 0x14c; - PointerToSymbolTable = 0; - NumberOfSymbols = 0; - OptionalHeaderSize = 0xe0; - } - - public void Accept (IBinaryVisitor visitor) - { - visitor.VisitPEFileHeader (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/PEOptionalHeader.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/PEOptionalHeader.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/PEOptionalHeader.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/PEOptionalHeader.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,200 +0,0 @@ -// -// PEOptionalHeader.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - public sealed class PEOptionalHeader : IHeader, IBinaryVisitable { - - public StandardFieldsHeader StandardFields; - public NTSpecificFieldsHeader NTSpecificFields; - public DataDirectoriesHeader DataDirectories; - - internal PEOptionalHeader () - { - StandardFields = new StandardFieldsHeader (); - NTSpecificFields = new NTSpecificFieldsHeader (); - DataDirectories = new DataDirectoriesHeader (); - } - - public void SetDefaultValues () - { - } - - public void Accept (IBinaryVisitor visitor) - { - visitor.VisitPEOptionalHeader (this); - - StandardFields.Accept (visitor); - NTSpecificFields.Accept (visitor); - DataDirectories.Accept (visitor); - } - - public sealed class StandardFieldsHeader : IHeader, IBinaryVisitable { - - public ushort Magic; - public byte LMajor; - public byte LMinor; - public uint CodeSize; - public uint InitializedDataSize; - public uint UninitializedDataSize; - public RVA EntryPointRVA; - public RVA BaseOfCode; - public RVA BaseOfData; - - public bool IsPE64 { - get { return Magic == 0x20b; } - set { - if (value) - Magic = 0x20b; - else - Magic = 0x10b; - } - } - - internal StandardFieldsHeader () - { - } - - public void SetDefaultValues () - { - Magic = 0x10b; - LMajor = 6; - LMinor = 0; - } - - public void Accept (IBinaryVisitor visitor) - { - visitor.VisitStandardFieldsHeader (this); - } - } - - public sealed class NTSpecificFieldsHeader : IHeader, IBinaryVisitable { - - public ulong ImageBase; - public uint SectionAlignment; - public uint FileAlignment; - public ushort OSMajor; - public ushort OSMinor; - public ushort UserMajor; - public ushort UserMinor; - public ushort SubSysMajor; - public ushort SubSysMinor; - public uint Reserved; - public uint ImageSize; - public uint HeaderSize; - public uint FileChecksum; - public SubSystem SubSystem; - public ushort DLLFlags; - public ulong StackReserveSize; - public ulong StackCommitSize; - public ulong HeapReserveSize; - public ulong HeapCommitSize; - public uint LoaderFlags; - public uint NumberOfDataDir; - - internal NTSpecificFieldsHeader () - { - } - - public void SetDefaultValues () - { - ImageBase = 0x400000; - SectionAlignment = 0x2000; - FileAlignment = 0x200; - OSMajor = 4; - OSMinor = 0; - UserMajor = 0; - UserMinor = 0; - SubSysMajor = 4; - SubSysMinor = 0; - Reserved = 0; - HeaderSize = 0x200; - FileChecksum = 0; - DLLFlags = 0; - StackReserveSize = 0x100000; - StackCommitSize = 0x1000; - HeapReserveSize = 0x100000; - HeapCommitSize = 0x1000; - LoaderFlags = 0; - NumberOfDataDir = 0x10; - } - - public void Accept (IBinaryVisitor visitor) - { - visitor.VisitNTSpecificFieldsHeader (this); - } - } - - public sealed class DataDirectoriesHeader : IHeader, IBinaryVisitable { - - public DataDirectory ExportTable; - public DataDirectory ImportTable; - public DataDirectory ResourceTable; - public DataDirectory ExceptionTable; - public DataDirectory CertificateTable; - public DataDirectory BaseRelocationTable; - public DataDirectory Debug; - public DataDirectory Copyright; - public DataDirectory GlobalPtr; - public DataDirectory TLSTable; - public DataDirectory LoadConfigTable; - public DataDirectory BoundImport; - public DataDirectory IAT; - public DataDirectory DelayImportDescriptor; - public DataDirectory CLIHeader; - public DataDirectory Reserved; - - internal DataDirectoriesHeader () - { - } - - public void SetDefaultValues () - { - ExportTable = DataDirectory.Zero; - ResourceTable = DataDirectory.Zero; - ExceptionTable = DataDirectory.Zero; - CertificateTable = DataDirectory.Zero; - Debug = DataDirectory.Zero; - Copyright = DataDirectory.Zero; - GlobalPtr = DataDirectory.Zero; - TLSTable = DataDirectory.Zero; - LoadConfigTable = DataDirectory.Zero; - BoundImport = DataDirectory.Zero; - IAT = new DataDirectory (new RVA (0x2000), 8); - DelayImportDescriptor = DataDirectory.Zero; - CLIHeader = new DataDirectory (new RVA (0x2008), 0x48); - Reserved = DataDirectory.Zero; - } - - public void Accept (IBinaryVisitor visitor) - { - visitor.VisitDataDirectoriesHeader (this); - } - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDataEntry.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDataEntry.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDataEntry.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDataEntry.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// -// ResourceDataEntry.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2006 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - public class ResourceDataEntry : ResourceNode { - - public RVA Data; - public uint Size; - public uint Codepage; - public uint Reserved = 0; - - public byte [] ResourceData; - - public ResourceDataEntry (int offset) : base (offset) - { - } - - public ResourceDataEntry () - { - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryEntry.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryEntry.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryEntry.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryEntry.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -// -// ResourceDirectoryEntry.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2006 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - public class ResourceDirectoryEntry : ResourceNode { - - private bool m_idByName; - - public int ID; - public ResourceDirectoryString Name; - - public bool IdentifiedByName { - get { return m_idByName; } - } - - public ResourceNode Child; - - public ResourceDirectoryEntry (ResourceDirectoryString name) - { - this.Name = name; - m_idByName = true; - } - - public ResourceDirectoryEntry (ResourceDirectoryString name, int offset) : base (offset) - { - this.Name = name; - m_idByName = true; - } - - public ResourceDirectoryEntry (int id) - { - this.ID = id; - } - - public ResourceDirectoryEntry (int id, int offset) : base (offset) - { - this.ID = id; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryString.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryString.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryString.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryString.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// -// ResourceDirectoryString.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2006 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - public class ResourceDirectoryString : ResourceNode { - - public string String; - - public ResourceDirectoryString (string str) - { - this.String = str; - } - - public ResourceDirectoryString (string str, int offset) : base (offset) - { - this.String = str; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryTable.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryTable.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryTable.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryTable.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -// -// ResourceDirectoryTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2006 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - using System.Collections; - - public class ResourceDirectoryTable : ResourceNode { - - private ArrayList m_entries; - - public uint Characteristics; - public uint TimeDateStamp; - public ushort MajorVersion; - public ushort MinorVersion; - - public IList Entries { - get { return m_entries; } - } - - public ResourceDirectoryTable (int offset) : base (offset) - { - m_entries = new ArrayList (); - } - - public ResourceDirectoryTable () - { - m_entries = new ArrayList (); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceNode.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceNode.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceNode.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceNode.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// -// ResourceNode.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2006 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - public abstract class ResourceNode { - - public int Offset; - - internal ResourceNode (int offset) - { - this.Offset = offset; - } - - internal ResourceNode () - { - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceReader.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceReader.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceReader.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceReader.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,143 +0,0 @@ -// -// ResourceReader.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2006 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - using System.IO; - using System.Text; - - class ResourceReader { - - Image m_img; - Section m_rsrc; - BinaryReader m_reader; - - public ResourceReader (Image img) - { - m_img = img; - } - - public ResourceDirectoryTable Read () - { - m_rsrc = GetResourceSection (); - if (m_rsrc == null) - return null; - - m_reader = new BinaryReader (new MemoryStream (m_rsrc.Data)); - return ReadDirectoryTable (); - } - - Section GetResourceSection () - { - foreach (Section s in m_img.Sections) - if (s.Name == Section.Resources) - return s; - - return null; - } - - int GetOffset () - { - return (int) m_reader.BaseStream.Position; - } - - ResourceDirectoryTable ReadDirectoryTable () - { - ResourceDirectoryTable rdt = new ResourceDirectoryTable (GetOffset ()); - rdt.Characteristics = m_reader.ReadUInt32 (); - rdt.TimeDateStamp = m_reader.ReadUInt32 (); - rdt.MajorVersion = m_reader.ReadUInt16 (); - rdt.MinorVersion = m_reader.ReadUInt16 (); - ushort nameEntries = m_reader.ReadUInt16 (); - ushort idEntries = m_reader.ReadUInt16 (); - - for (int i = 0; i < nameEntries; i++) - rdt.Entries.Add (ReadDirectoryEntry ()); - - for (int i = 0; i < idEntries; i++) - rdt.Entries.Add (ReadDirectoryEntry ()); - - return rdt; - } - - ResourceDirectoryEntry ReadDirectoryEntry () - { - uint name = m_reader.ReadUInt32 (); - uint child = m_reader.ReadUInt32 (); - - ResourceDirectoryEntry rde; - if ((name & 0x80000000) != 0) - rde = new ResourceDirectoryEntry (ReadDirectoryString ((int) name & 0x7fffffff), GetOffset ()); - else - rde = new ResourceDirectoryEntry ((int) name & 0x7fffffff, GetOffset ()); - - long pos = m_reader.BaseStream.Position; - m_reader.BaseStream.Position = child & 0x7fffffff; - - if ((child & 0x80000000) != 0) - rde.Child = ReadDirectoryTable (); - else - rde.Child = ReadDataEntry (); - - m_reader.BaseStream.Position = pos; - - return rde; - } - - ResourceDirectoryString ReadDirectoryString (int offset) - { - long pos = m_reader.BaseStream.Position; - m_reader.BaseStream.Position = offset; - - byte [] str = m_reader.ReadBytes (m_reader.ReadUInt16 ()); - - ResourceDirectoryString rds = new ResourceDirectoryString ( - Encoding.Unicode.GetString (str, 0, str.Length), - GetOffset ()); - - m_reader.BaseStream.Position = pos; - - return rds; - } - - ResourceNode ReadDataEntry () - { - ResourceDataEntry rde = new ResourceDataEntry (GetOffset ()); - rde.Data = m_reader.ReadUInt32 (); - rde.Size = m_reader.ReadUInt32 (); - rde.Codepage = m_reader.ReadUInt32 (); - rde.Reserved = m_reader.ReadUInt32 (); - - BinaryReader dataReader = m_img.GetReaderAtVirtualAddress (rde.Data); - rde.ResourceData = dataReader.ReadBytes ((int) rde.Size); - dataReader.Close (); - - return rde; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceWriter.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceWriter.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceWriter.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceWriter.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,216 +0,0 @@ -// -// ResourceWriter.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2006 Jb Evain -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System.Text; - -namespace Mono.Cecil.Binary { - - using System.Collections; - - class ResourceWriter { - - Image m_img; - Section m_rsrc; - MemoryBinaryWriter m_writer; - - ArrayList m_dataEntries; - ArrayList m_stringEntries; - - long m_pos; - - public ResourceWriter (Image img, Section rsrc, MemoryBinaryWriter writer) - { - m_img = img; - m_rsrc = rsrc; - m_writer = writer; - - m_dataEntries = new ArrayList (); - m_stringEntries = new ArrayList (); - } - - public void Write () - { - if (m_img.ResourceDirectoryRoot == null) - return; - - ComputeOffset (m_img.ResourceDirectoryRoot); - WriteResourceDirectoryTable (m_img.ResourceDirectoryRoot); - } - - public void Patch () - { - foreach (ResourceDataEntry rde in m_dataEntries) { - GotoOffset (rde.Offset); - m_writer.Write ((uint) rde.Data + m_rsrc.VirtualAddress); - RestoreOffset (); - } - } - - void ComputeOffset (ResourceDirectoryTable root) - { - int offset = 0; - - Queue directoryTables = new Queue (); - directoryTables.Enqueue (root); - - while (directoryTables.Count > 0) { - ResourceDirectoryTable rdt = directoryTables.Dequeue () as ResourceDirectoryTable; - rdt.Offset = offset; - offset += 16; - - foreach (ResourceDirectoryEntry rde in rdt.Entries) { - rde.Offset = offset; - offset += 8; - if (rde.IdentifiedByName) - m_stringEntries.Add (rde.Name); - - if (rde.Child is ResourceDirectoryTable) - directoryTables.Enqueue (rde.Child); - else - m_dataEntries.Add (rde.Child); - } - } - - foreach (ResourceDataEntry rde in m_dataEntries) { - rde.Offset = offset; - offset += 16; - } - - foreach (ResourceDirectoryString rds in m_stringEntries) { - rds.Offset = offset; - byte [] str = Encoding.Unicode.GetBytes (rds.String); - offset += 2 + str.Length; - - offset += 3; - offset &= ~3; - } - - foreach (ResourceDataEntry rde in m_dataEntries) { - rde.Data = (uint) offset; - - offset += rde.ResourceData.Length; - offset += 3; - offset &= ~3; - } - - m_writer.Write (new byte [offset]); - } - - void WriteResourceDirectoryTable (ResourceDirectoryTable rdt) - { - GotoOffset (rdt.Offset); - - m_writer.Write (rdt.Characteristics); - m_writer.Write (rdt.TimeDateStamp); - m_writer.Write (rdt.MajorVersion); - m_writer.Write (rdt.MinorVersion); - - ResourceDirectoryEntry [] namedEntries = GetEntries (rdt, true); - ResourceDirectoryEntry [] idEntries = GetEntries (rdt, false); - - m_writer.Write ((ushort) namedEntries.Length); - m_writer.Write ((ushort) idEntries.Length); - - foreach (ResourceDirectoryEntry rde in namedEntries) - WriteResourceDirectoryEntry (rde); - - foreach (ResourceDirectoryEntry rde in idEntries) - WriteResourceDirectoryEntry (rde); - - RestoreOffset (); - } - - ResourceDirectoryEntry [] GetEntries (ResourceDirectoryTable rdt, bool identifiedByName) - { - ArrayList entries = new ArrayList (); - foreach (ResourceDirectoryEntry rde in rdt.Entries) - if (rde.IdentifiedByName == identifiedByName) - entries.Add (rde); - - return entries.ToArray (typeof (ResourceDirectoryEntry)) as ResourceDirectoryEntry []; - } - - void WriteResourceDirectoryEntry (ResourceDirectoryEntry rde) - { - GotoOffset (rde.Offset); - - if (rde.IdentifiedByName) { - m_writer.Write ((uint) rde.Name.Offset | 0x80000000); - WriteResourceDirectoryString (rde.Name); - } else - m_writer.Write ((uint) rde.ID); - - if (rde.Child is ResourceDirectoryTable) { - m_writer.Write((uint) rde.Child.Offset | 0x80000000); - WriteResourceDirectoryTable (rde.Child as ResourceDirectoryTable); - } else { - m_writer.Write (rde.Child.Offset); - WriteResourceDataEntry (rde.Child as ResourceDataEntry); - } - - RestoreOffset (); - } - - void WriteResourceDataEntry (ResourceDataEntry rde) - { - GotoOffset (rde.Offset); - - m_writer.Write (0); - m_writer.Write ((uint) rde.ResourceData.Length); - m_writer.Write (rde.Codepage); - m_writer.Write (rde.Reserved); - - m_writer.BaseStream.Position = rde.Data; - m_writer.Write (rde.ResourceData); - - RestoreOffset (); - } - - void WriteResourceDirectoryString (ResourceDirectoryString name) - { - GotoOffset (name.Offset); - - byte [] str = Encoding.Unicode.GetBytes (name.String); - m_writer.Write ((ushort) str.Length); - m_writer.Write (str); - - RestoreOffset (); - } - - void GotoOffset (int offset) - { - m_pos = m_writer.BaseStream.Position; - m_writer.BaseStream.Position = offset; - } - - void RestoreOffset () - { - m_writer.BaseStream.Position = m_pos; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/RuntimeImage.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/RuntimeImage.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/RuntimeImage.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/RuntimeImage.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// -// RuntimeImage.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - public enum RuntimeImage : uint { - ILOnly = 0x0000001, - F32BitsRequired = 0x0000002, - StrongNameSigned = 0x0000008, - TrackDebugData = 0x00010000 - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/RVA.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/RVA.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/RVA.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/RVA.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,115 +0,0 @@ -// -// RVA.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - public struct RVA { - - public static readonly RVA Zero = new RVA (0); - - uint m_rva; - - public uint Value { - get { return m_rva; } - set { m_rva = value; } - } - - public RVA (uint rva) - { - m_rva = rva; - } - - public override int GetHashCode () - { - return (int) m_rva; - } - - public override bool Equals (object other) - { - if (other is RVA) - return this.m_rva == ((RVA) other).m_rva; - - return false; - } - - public override string ToString () - { - return string.Format ("0x{0}", m_rva.ToString ("X")); - } - - public static bool operator == (RVA one, RVA other) - { - return one.Equals (other); - } - - public static bool operator != (RVA one, RVA other) - { - return !one.Equals (other); - } - - public static bool operator < (RVA one, RVA other) - { - return one.m_rva < other.m_rva; - } - - public static bool operator > (RVA one, RVA other) - { - return one.m_rva > other.m_rva; - } - - public static bool operator <= (RVA one, RVA other) - { - return one.m_rva <= other.m_rva; - } - - public static bool operator >= (RVA one, RVA other) - { - return one.m_rva >= other.m_rva; - } - - public static RVA operator + (RVA rva, uint x) - { - return new RVA (rva.m_rva + x); - } - - public static RVA operator - (RVA rva, uint x) - { - return new RVA (rva.m_rva - x); - } - - public static implicit operator RVA (uint val) - { - return val == 0 ? RVA.Zero : new RVA (val); - } - - public static implicit operator uint (RVA rva) - { - return rva.m_rva; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/SectionCharacteristics.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/SectionCharacteristics.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/SectionCharacteristics.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/SectionCharacteristics.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -// -// SectionCharacteristics.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - using System; - - [Flags] - public enum SectionCharacteristics : uint { - TypeNoPad = 0x0000008, - ContainsCode = 0x00000020, - ContainsInitializedData = 0x00000040, - ContainsUninitializedData = 0x00000080, - LnkOther = 0x0000100, - LnkInfo = 0x000200, - LnkRemove = 0x0000800, - LnkCOMDAT = 0x00001000, - GPRel = 0x00008000, - MemPurgeable = 0x00020000, - MemLocked = 0x00040000, - MemPreload = 0x00080000, - Align1Bytes = 0x00100000, - Align2Bytes = 0x00200000, - Align4Bytes = 0x00300000, - Align8Bytes = 0x00400000, - Align16Bytes = 0x00500000, - Align32Bytes = 0x00600000, - Align64Bytes = 0x00700000, - Align128Bytes = 0x00800000, - Align256Bytes = 0x00900000, - Align512Bytes = 0x00a00000, - Align1024Bytes = 0x00b00000, - Align2048Bytes = 0x00c00000, - Align4096Bytes = 0x00d00000, - Align8192Bytes = 0x00e00000, - LnkNRelocOvfl = 0x01000000, - MemDiscardable = 0x02000000, - MemNotCached = 0x04000000, - MemNotPaged = 0x08000000, - MemShared = 0x10000000, - MemExecute = 0x20000000, - MemoryRead = 0x40000000, - MemoryWrite = 0x80000000 - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/SectionCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/SectionCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/SectionCollection.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/SectionCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,114 +0,0 @@ -// -// SectionCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - using System; - using System.Collections; - - public sealed class SectionCollection : ICollection, IBinaryVisitable { - - IList m_items; - - public Section this [int index] - { - get { return m_items [index] as Section; } - set { m_items [index] = value; } - } - - public int Count { - get { return m_items.Count; } - } - - public bool IsSynchronized { - get { return false; } - } - - public object SyncRoot { - get { return this; } - } - - internal SectionCollection () - { - m_items = new ArrayList (4); - } - - internal void Add (Section value) - { - m_items.Add (value); - } - - internal void Clear () - { - m_items.Clear (); - } - - public bool Contains (Section value) - { - return m_items.Contains (value); - } - - public int IndexOf (Section value) - { - return m_items.IndexOf (value); - } - - internal void Insert (int index, Section value) - { - m_items.Insert (index, value); - } - - internal void Remove (Section value) - { - m_items.Remove (value); - } - - internal void RemoveAt (int index) - { - m_items.Remove (index); - } - - public void CopyTo (Array ary, int index) - { - m_items.CopyTo (ary, index); - } - - public IEnumerator GetEnumerator () - { - return m_items.GetEnumerator (); - } - - public void Accept (IBinaryVisitor visitor) - { - visitor.VisitSectionCollection (this); - - for (int i = 0; i < m_items.Count; i++) - this [i].Accept (visitor); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/Section.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/Section.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/Section.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/Section.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -// -// Section.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - public sealed class Section : IHeader, IBinaryVisitable { - - public const string Text = ".text"; - public const string Resources = ".rsrc"; - public const string Relocs = ".reloc"; - public const string SData = ".sdata"; - - public uint VirtualSize; - public RVA VirtualAddress; - public uint SizeOfRawData; - public RVA PointerToRawData; - public RVA PointerToRelocations; - public RVA PointerToLineNumbers; - public ushort NumberOfRelocations; - public ushort NumberOfLineNumbers; - public SectionCharacteristics Characteristics; - - public string Name; - public byte [] Data; - - internal Section () - { - } - - public void SetDefaultValues () - { - PointerToLineNumbers = RVA.Zero; - NumberOfLineNumbers = 0; - } - - public void Accept (IBinaryVisitor visitor) - { - visitor.VisitSection (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/SubSystem.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/SubSystem.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/SubSystem.cs 2008-11-06 19:52:06.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/SubSystem.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// -// SubSystem.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Binary { - - public enum SubSystem : ushort { - Unknown = 0x0, - Native = 0x1, - WindowsGui = 0x2, - WindowsCui = 0x3, - PosixCui = 0x7, - WindowsCeGui = 0x9, - EfiApplication = 0x10, - EfiBootServiceDriver = 0x11, - EfiRuntimeDriver = 0x12, - EfiRom = 0x13, - Xbox = 0x14, - NexusAgent = 0x15 - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/BaseCodeVisitor.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/BaseCodeVisitor.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/BaseCodeVisitor.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/BaseCodeVisitor.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -// -// BaseCodeVisitor.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - public abstract class BaseCodeVisitor : ICodeVisitor { - - public virtual void VisitMethodBody (MethodBody body) - { - } - - public virtual void VisitInstructionCollection (InstructionCollection instructions) - { - } - - public virtual void VisitInstruction (Instruction instr) - { - } - - public virtual void VisitExceptionHandlerCollection (ExceptionHandlerCollection seh) - { - } - - public virtual void VisitExceptionHandler (ExceptionHandler eh) - { - } - - public virtual void VisitVariableDefinitionCollection (VariableDefinitionCollection variables) - { - } - - public virtual void VisitVariableDefinition (VariableDefinition var) - { - } - - public virtual void VisitScopeCollection (ScopeCollection scopes) - { - } - - public virtual void VisitScope (Scope s) - { - } - - public virtual void TerminateMethodBody (MethodBody body) - { - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/CilWorker.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/CilWorker.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/CilWorker.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/CilWorker.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,357 +0,0 @@ -// -// CilWorker.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - using System; - using SR = System.Reflection; - - public sealed class CilWorker { - - MethodBody m_mbody; - InstructionCollection m_instrs; - - internal CilWorker (MethodBody body) - { - m_mbody = body; - m_instrs = m_mbody.Instructions; - } - - public MethodBody GetBody () - { - return m_mbody; - } - - public Instruction Create (OpCode opcode) - { - if (opcode.OperandType != OperandType.InlineNone) - throw new ArgumentException ("opcode"); - - return FinalCreate (opcode); - } - - public Instruction Create (OpCode opcode, TypeReference type) - { - if (opcode.OperandType != OperandType.InlineType && - opcode.OperandType != OperandType.InlineTok) - throw new ArgumentException ("opcode"); - - return FinalCreate (opcode, type); - } - - public Instruction Create (OpCode opcode, MethodReference meth) - { - if (opcode.OperandType != OperandType.InlineMethod && - opcode.OperandType != OperandType.InlineTok) - throw new ArgumentException ("opcode"); - - return FinalCreate (opcode, meth); - } - - public Instruction Create (OpCode opcode, FieldReference field) - { - if (opcode.OperandType != OperandType.InlineField && - opcode.OperandType != OperandType.InlineTok) - throw new ArgumentException ("opcode"); - - return FinalCreate (opcode, field); - } - - public Instruction Create (OpCode opcode, string str) - { - if (opcode.OperandType != OperandType.InlineString) - throw new ArgumentException ("opcode"); - - return FinalCreate (opcode, str); - } - - public Instruction Create (OpCode opcode, sbyte b) - { - if (opcode.OperandType != OperandType.ShortInlineI && - opcode != OpCodes.Ldc_I4_S) - throw new ArgumentException ("opcode"); - - return FinalCreate (opcode, b); - } - - public Instruction Create (OpCode opcode, byte b) - { - if (opcode.OperandType != OperandType.ShortInlineI || - opcode == OpCodes.Ldc_I4_S) - throw new ArgumentException ("opcode"); - - return FinalCreate (opcode, b); - } - - public Instruction Create (OpCode opcode, int i) - { - if (opcode.OperandType != OperandType.InlineI) - throw new ArgumentException ("opcode"); - - return FinalCreate (opcode, i); - } - - public Instruction Create (OpCode opcode, long l) - { - if (opcode.OperandType != OperandType.InlineI8) - throw new ArgumentException ("opcode"); - - return FinalCreate (opcode, l); - } - - public Instruction Create (OpCode opcode, float f) - { - if (opcode.OperandType != OperandType.ShortInlineR) - throw new ArgumentException ("opcode"); - - return FinalCreate (opcode, f); - } - - public Instruction Create (OpCode opcode, double d) - { - if (opcode.OperandType != OperandType.InlineR) - throw new ArgumentException ("opcode"); - - return FinalCreate (opcode, d); - } - - public Instruction Create (OpCode opcode, Instruction label) - { - if (opcode.OperandType != OperandType.InlineBrTarget && - opcode.OperandType != OperandType.ShortInlineBrTarget) - throw new ArgumentException ("opcode"); - - return FinalCreate (opcode, label); - } - - public Instruction Create (OpCode opcode, Instruction [] labels) - { - if (opcode.OperandType != OperandType.InlineSwitch) - throw new ArgumentException ("opcode"); - - return FinalCreate (opcode, labels); - } - - public Instruction Create (OpCode opcode, VariableDefinition var) - { - if (opcode.OperandType != OperandType.ShortInlineVar && - opcode.OperandType != OperandType.InlineVar) - throw new ArgumentException ("opcode"); - - return FinalCreate (opcode, var); - } - - public Instruction Create (OpCode opcode, ParameterDefinition param) - { - if (opcode.OperandType != OperandType.ShortInlineParam && - opcode.OperandType != OperandType.InlineParam) - throw new ArgumentException ("opcode"); - - return FinalCreate (opcode, param); - } - - Instruction FinalCreate (OpCode opcode) - { - return FinalCreate (opcode, null); - } - - Instruction FinalCreate (OpCode opcode, object operand) - { - return new Instruction (opcode, operand); - } - - public Instruction Emit (OpCode opcode) - { - Instruction instr = Create (opcode); - Append (instr); - return instr; - } - - public Instruction Emit (OpCode opcode, TypeReference type) - { - Instruction instr = Create (opcode, type); - Append (instr); - return instr; - } - - public Instruction Emit (OpCode opcode, MethodReference meth) - { - Instruction instr = Create (opcode, meth); - Append (instr); - return instr; - } - - public Instruction Emit (OpCode opcode, FieldReference field) - { - Instruction instr = Create (opcode, field); - Append (instr); - return instr; - } - - public Instruction Emit (OpCode opcode, string str) - { - Instruction instr = Create (opcode, str); - Append (instr); - return instr; - } - - public Instruction Emit (OpCode opcode, byte b) - { - Instruction instr = Create (opcode, b); - Append (instr); - return instr; - } - - public Instruction Emit (OpCode opcode, sbyte b) - { - Instruction instr = Create (opcode, b); - Append (instr); - return instr; - } - - public Instruction Emit (OpCode opcode, int i) - { - Instruction instr = Create (opcode, i); - Append (instr); - return instr; - } - - public Instruction Emit (OpCode opcode, long l) - { - Instruction instr = Create (opcode, l); - Append (instr); - return instr; - } - - public Instruction Emit (OpCode opcode, float f) - { - Instruction instr = Create (opcode, f); - Append (instr); - return instr; - } - - public Instruction Emit (OpCode opcode, double d) - { - Instruction instr = Create (opcode, d); - Append (instr); - return instr; - } - - public Instruction Emit (OpCode opcode, Instruction target) - { - Instruction instr = Create (opcode, target); - Append (instr); - return instr; - } - - public Instruction Emit (OpCode opcode, Instruction [] targets) - { - Instruction instr = Create (opcode, targets); - Append (instr); - return instr; - } - - public Instruction Emit (OpCode opcode, VariableDefinition var) - { - Instruction instr = Create (opcode, var); - Append (instr); - return instr; - } - - public Instruction Emit (OpCode opcode, ParameterDefinition param) - { - Instruction instr = Create (opcode, param); - Append (instr); - return instr; - } - - public void InsertBefore (Instruction target, Instruction instr) - { - int index = m_instrs.IndexOf (target); - if (index == -1) - throw new ArgumentOutOfRangeException ("Target instruction not in method body"); - - m_instrs.Insert (index, instr); - instr.Previous = target.Previous; - if (target.Previous != null) - target.Previous.Next = instr; - target.Previous = instr; - instr.Next = target; - } - - public void InsertAfter (Instruction target, Instruction instr) - { - int index = m_instrs.IndexOf (target); - if (index == -1) - throw new ArgumentOutOfRangeException ("Target instruction not in method body"); - - m_instrs.Insert (index + 1, instr); - instr.Next = target.Next; - if (target.Next != null) - target.Next.Previous = instr; - target.Next = instr; - instr.Previous = target; - } - - public void Append (Instruction instr) - { - Instruction last = null, current = instr; - if (m_instrs.Count > 0) - last = m_instrs [m_instrs.Count - 1]; - - if (last != null) { - last.Next = instr; - current.Previous = last; - } - - m_instrs.Add (current); - } - - public void Replace (Instruction old, Instruction instr) - { - int index = m_instrs.IndexOf (old); - if (index == -1) - throw new ArgumentOutOfRangeException ("Target instruction not in method body"); - - InsertAfter (old, instr); - Remove (old); - } - - public void Remove (Instruction instr) - { - if (!m_instrs.Contains (instr)) - throw new ArgumentException ("Instruction not in method body"); - - if (instr.Previous != null) - instr.Previous.Next = instr.Next; - if (instr.Next != null) - instr.Next.Previous = instr.Previous; - m_instrs.Remove (instr); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Code.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Code.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Code.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Code.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,10 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// Generated by /CodeGen/cecil-gen.rb do not edit -// Fri Mar 16 15:37:23 +0100 2007 -// -// (C) 2007 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/CodeReader.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/CodeReader.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/CodeReader.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/CodeReader.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 - 2007 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,330 +26,579 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System; + +using Mono.Cecil.PE; +using Mono.Collections.Generic; + +using RVA = System.UInt32; + namespace Mono.Cecil.Cil { - using System; - using System.Collections; - using System.IO; + sealed class CodeReader : ByteBuffer { - using Mono.Cecil; - using Mono.Cecil.Metadata; - using Mono.Cecil.Signatures; + readonly internal MetadataReader reader; - class CodeReader : BaseCodeVisitor { + int start; + Section code_section; - ReflectionReader m_reflectReader; - MetadataRoot m_root; + MethodDefinition method; + MethodBody body; + + int Offset { + get { return base.position - start; } + } - public CodeReader (ReflectionReader reflectReader) + CodeReader (Section section, MetadataReader reader) + : base (section.Data) { - m_reflectReader = reflectReader; - m_root = m_reflectReader.MetadataRoot; + this.code_section = section; + this.reader = reader; } - public override void VisitMethodBody (MethodBody body) + public static CodeReader CreateCodeReader (MetadataReader metadata) { - MethodDefinition meth = body.Method; - MethodBody methBody = body; - BinaryReader br = m_reflectReader.Module.ImageReader.MetadataReader.GetDataReader (meth.RVA); + return new CodeReader (metadata.image.MetadataSection, metadata); + } - // lets read the method - IDictionary instrs; - int flags = br.ReadByte (); - switch (flags & 0x3) { - case (int) MethodHeader.TinyFormat : - methBody.CodeSize = flags >> 2; - methBody.MaxStack = 8; - ReadCilBody (methBody, br, out instrs); - break; - case (int) MethodHeader.FatFormat : - br.BaseStream.Position--; - int fatflags = br.ReadUInt16 (); - //int headersize = (fatflags >> 12) & 0xf; - methBody.MaxStack = br.ReadUInt16 (); - methBody.CodeSize = br.ReadInt32 (); - methBody.LocalVarToken = br.ReadInt32 (); - body.InitLocals = (fatflags & (int) MethodHeader.InitLocals) != 0; - VisitVariableDefinitionCollection (methBody.Variables); - ReadCilBody (methBody, br, out instrs); - if ((fatflags & (int) MethodHeader.MoreSects) != 0) - ReadSection (methBody, br, instrs); - break; + public MethodBody ReadMethodBody (MethodDefinition method) + { + this.method = method; + this.body = new MethodBody (method); + + reader.context = method; + + ReadMethodBody (); + + return this.body; + } + + public void MoveTo (int rva) + { + if (!IsInSection (rva)) { + code_section = reader.image.GetSectionAtVirtualAddress ((uint) rva); + Reset (code_section.Data); } - if (m_reflectReader.SymbolReader != null) - m_reflectReader.SymbolReader.Read (methBody); + base.position = rva - (int) code_section.VirtualAddress; } - public static uint GetRid (int token) + bool IsInSection (int rva) { - return (uint) token & 0x00ffffff; + return code_section.VirtualAddress <= rva && rva < code_section.VirtualAddress + code_section.SizeOfRawData; } - public static ParameterDefinition GetParameter (MethodBody body, int index) + void ReadMethodBody () { - if (body.Method.HasThis) { - if (index == 0) - return body.Method.This; - index--; + MoveTo (method.RVA); + + var flags = ReadByte (); + switch (flags & 0x3) { + case 0x2: // tiny + body.code_size = flags >> 2; + body.MaxStackSize = 8; + ReadCode (); + break; + case 0x3: // fat + base.position--; + ReadFatMethod (); + break; + default: + throw new InvalidOperationException (); } - return body.Method.Parameters [index]; + var symbol_reader = reader.module.SymbolReader; + + if (symbol_reader != null) { + var instructions = body.Instructions; + symbol_reader.Read (body, offset => GetInstruction (instructions, offset)); + } } - public static VariableDefinition GetVariable (MethodBody body, int index) + void ReadFatMethod () { - return body.Variables [index]; + var flags = ReadUInt16 (); + body.max_stack_size = ReadUInt16 (); + body.code_size = (int) ReadUInt32 (); + body.local_var_token = new MetadataToken (ReadUInt32 ()); + body.init_locals = (flags & 0x10) != 0; + + if (body.local_var_token.RID != 0) + body.variables = ReadVariables (body.local_var_token); + + ReadCode (); + + if ((flags & 0x8) != 0) + ReadSection (); } - void ReadCilBody (MethodBody body, BinaryReader br, out IDictionary instructions) + public VariableDefinitionCollection ReadVariables (MetadataToken local_var_token) { - long start = br.BaseStream.Position; - Instruction last = null; - InstructionCollection code = body.Instructions; - instructions = new Hashtable (); - GenericContext context = new GenericContext (body.Method); + var position = reader.position; + var variables = reader.ReadVariables (local_var_token); + reader.position = position; - while (br.BaseStream.Position < start + body.CodeSize) { - OpCode op; - long offset = br.BaseStream.Position - start; - int cursor = br.ReadByte (); - if (cursor == 0xfe) - op = OpCodes.TwoBytesOpCode [br.ReadByte ()]; - else - op = OpCodes.OneByteOpCode [cursor]; + return variables; + } - Instruction instr = new Instruction ((int) offset, op); - switch (op.OperandType) { - case OperandType.InlineNone : - break; - case OperandType.InlineSwitch : - uint length = br.ReadUInt32 (); - int [] branches = new int [length]; - int [] buf = new int [length]; - for (int i = 0; i < length; i++) - buf [i] = br.ReadInt32 (); - for (int i = 0; i < length; i++) - branches [i] = Convert.ToInt32 (br.BaseStream.Position - start + buf [i]); - instr.Operand = branches; - break; - case OperandType.ShortInlineBrTarget : - sbyte sbrtgt = br.ReadSByte (); - instr.Operand = Convert.ToInt32 (br.BaseStream.Position - start + sbrtgt); - break; - case OperandType.InlineBrTarget : - int brtgt = br.ReadInt32 (); - instr.Operand = Convert.ToInt32 (br.BaseStream.Position - start + brtgt); - break; - case OperandType.ShortInlineI : - if (op == OpCodes.Ldc_I4_S) - instr.Operand = br.ReadSByte (); - else - instr.Operand = br.ReadByte (); - break; - case OperandType.ShortInlineVar : - instr.Operand = GetVariable (body, br.ReadByte ()); - break; - case OperandType.ShortInlineParam : - instr.Operand = GetParameter (body, br.ReadByte ()); - break; - case OperandType.InlineSig : - instr.Operand = GetCallSiteAt (br.ReadInt32 (), context); - break; - case OperandType.InlineI : - instr.Operand = br.ReadInt32 (); - break; - case OperandType.InlineVar : - instr.Operand = GetVariable (body, br.ReadInt16 ()); - break; - case OperandType.InlineParam : - instr.Operand = GetParameter (body, br.ReadInt16 ()); - break; - case OperandType.InlineI8 : - instr.Operand = br.ReadInt64 (); - break; - case OperandType.ShortInlineR : - instr.Operand = br.ReadSingle (); - break; - case OperandType.InlineR : - instr.Operand = br.ReadDouble (); - break; - case OperandType.InlineString : - instr.Operand = m_root.Streams.UserStringsHeap [GetRid (br.ReadInt32 ())]; - break; - case OperandType.InlineField : - case OperandType.InlineMethod : - case OperandType.InlineType : - case OperandType.InlineTok : - MetadataToken token = new MetadataToken (br.ReadInt32 ()); - switch (token.TokenType) { - case TokenType.TypeDef: - instr.Operand = m_reflectReader.GetTypeDefAt (token.RID); - break; - case TokenType.TypeRef: - instr.Operand = m_reflectReader.GetTypeRefAt (token.RID); - break; - case TokenType.TypeSpec: - instr.Operand = m_reflectReader.GetTypeSpecAt (token.RID, context); - break; - case TokenType.Field: - instr.Operand = m_reflectReader.GetFieldDefAt (token.RID); - break; - case TokenType.Method: - instr.Operand = m_reflectReader.GetMethodDefAt (token.RID); - break; - case TokenType.MethodSpec: - instr.Operand = m_reflectReader.GetMethodSpecAt (token.RID, context); - break; - case TokenType.MemberRef: - instr.Operand = m_reflectReader.GetMemberRefAt (token.RID, context); - break; - default: - throw new ReflectionException ("Wrong token: " + token); - } - break; - } + void ReadCode () + { + start = position; + var code_size = body.code_size; - instructions.Add (instr.Offset, instr); + if (code_size < 0 || buffer.Length <= (uint) (code_size + position)) + code_size = 0; - if (last != null) { - last.Next = instr; - instr.Previous = last; - } + var end = start + code_size; + var instructions = body.instructions = new InstructionCollection (code_size / 3); - last = instr; + while (position < end) { + var offset = base.position - start; + var opcode = ReadOpCode (); + var current = new Instruction (offset, opcode); - code.Add (instr); + if (opcode.OperandType != OperandType.InlineNone) + current.operand = ReadOperand (current); + + instructions.Add (current); + } + + ResolveBranches (instructions); + } + + OpCode ReadOpCode () + { + var il_opcode = ReadByte (); + return il_opcode != 0xfe + ? OpCodes.OneByteOpCode [il_opcode] + : OpCodes.TwoBytesOpCode [ReadByte ()]; + } + + object ReadOperand (Instruction instruction) + { + switch (instruction.opcode.OperandType) { + case OperandType.InlineSwitch: + var length = ReadInt32 (); + var base_offset = Offset + (4 * length); + var branches = new int [length]; + for (int i = 0; i < length; i++) + branches [i] = base_offset + ReadInt32 (); + return branches; + case OperandType.ShortInlineBrTarget: + return ReadSByte () + Offset; + case OperandType.InlineBrTarget: + return ReadInt32 () + Offset; + case OperandType.ShortInlineI: + if (instruction.opcode == OpCodes.Ldc_I4_S) + return ReadSByte (); + + return ReadByte (); + case OperandType.InlineI: + return ReadInt32 (); + case OperandType.ShortInlineR: + return ReadSingle (); + case OperandType.InlineR: + return ReadDouble (); + case OperandType.InlineI8: + return ReadInt64 (); + case OperandType.ShortInlineVar: + return GetVariable (ReadByte ()); + case OperandType.InlineVar: + return GetVariable (ReadUInt16 ()); + case OperandType.ShortInlineArg: + return GetParameter (ReadByte ()); + case OperandType.InlineArg: + return GetParameter (ReadUInt16 ()); + case OperandType.InlineSig: + return GetCallSite (ReadToken ()); + case OperandType.InlineString: + return GetString (ReadToken ()); + case OperandType.InlineTok: + case OperandType.InlineType: + case OperandType.InlineMethod: + case OperandType.InlineField: + return reader.LookupToken (ReadToken ()); + default: + throw new NotSupportedException (); } + } + + public string GetString (MetadataToken token) + { + return reader.image.UserStringHeap.Read (token.RID); + } + + public ParameterDefinition GetParameter (int index) + { + return body.GetParameter (index); + } + + public VariableDefinition GetVariable (int index) + { + return body.GetVariable (index); + } - // resolve branches - foreach (Instruction i in code) { - switch (i.OpCode.OperandType) { + public CallSite GetCallSite (MetadataToken token) + { + return reader.ReadCallSite (token); + } + + void ResolveBranches (Collection instructions) + { + var items = instructions.items; + var size = instructions.size; + + for (int i = 0; i < size; i++) { + var instruction = items [i]; + switch (instruction.opcode.OperandType) { case OperandType.ShortInlineBrTarget: case OperandType.InlineBrTarget: - i.Operand = GetInstruction (body, instructions, (int) i.Operand); + instruction.operand = GetInstruction ((int) instruction.operand); break; case OperandType.InlineSwitch: - int [] lbls = (int []) i.Operand; - Instruction [] instrs = new Instruction [lbls.Length]; - for (int j = 0; j < lbls.Length; j++) - instrs [j] = GetInstruction (body, instructions, lbls [j]); - i.Operand = instrs; + var offsets = (int []) instruction.operand; + var branches = new Instruction [offsets.Length]; + for (int j = 0; j < offsets.Length; j++) + branches [j] = GetInstruction (offsets [j]); + + instruction.operand = branches; break; } } } - static Instruction GetInstruction (MethodBody body, IDictionary instructions, int offset) + Instruction GetInstruction (int offset) { - Instruction instruction = instructions [offset] as Instruction; - if (instruction != null) - return instruction; - - return body.Instructions.Outside; - } - - void ReadSection (MethodBody body, BinaryReader br, IDictionary instructions) - { - br.BaseStream.Position += 3; - br.BaseStream.Position &= ~3; - - byte flags = br.ReadByte (); - if ((flags & (byte) MethodDataSection.FatFormat) == 0) { - int length = br.ReadByte () / 12; - br.ReadBytes (2); - - for (int i = 0; i < length; i++) { - ExceptionHandler eh = new ExceptionHandler ( - (ExceptionHandlerType) (br.ReadInt16 () & 0x7)); - eh.TryStart = GetInstruction (body, instructions, Convert.ToInt32 (br.ReadInt16 ())); - eh.TryEnd = GetInstruction (body, instructions, eh.TryStart.Offset + Convert.ToInt32 (br.ReadByte ())); - eh.HandlerStart = GetInstruction (body, instructions, Convert.ToInt32 (br.ReadInt16 ())); - eh.HandlerEnd = GetInstruction (body, instructions, eh.HandlerStart.Offset + Convert.ToInt32 (br.ReadByte ())); - ReadExceptionHandlerEnd (eh, br, body, instructions); - body.ExceptionHandlers.Add (eh); - } - } else { - br.BaseStream.Position--; - int length = (br.ReadInt32 () >> 8) / 24; - if ((flags & (int) MethodDataSection.EHTable) == 0) - br.ReadBytes (length * 24); - for (int i = 0; i < length; i++) { - ExceptionHandler eh = new ExceptionHandler ( - (ExceptionHandlerType) (br.ReadInt32 () & 0x7)); - eh.TryStart = GetInstruction (body, instructions, br.ReadInt32 ()); - eh.TryEnd = GetInstruction (body, instructions, eh.TryStart.Offset + br.ReadInt32 ()); - eh.HandlerStart = GetInstruction (body, instructions, br.ReadInt32 ()); - eh.HandlerEnd = GetInstruction (body, instructions, eh.HandlerStart.Offset + br.ReadInt32 ()); - ReadExceptionHandlerEnd(eh, br, body, instructions); - body.ExceptionHandlers.Add (eh); - } + return GetInstruction (body.Instructions, offset); + } + + static Instruction GetInstruction (Collection instructions, int offset) + { + var size = instructions.size; + var items = instructions.items; + if (offset < 0 || offset > items [size - 1].offset) + return null; + + int min = 0; + int max = size - 1; + while (min <= max) { + int mid = min + ((max - min) / 2); + var instruction = items [mid]; + var instruction_offset = instruction.offset; + + if (offset == instruction_offset) + return instruction; + + if (offset < instruction_offset) + max = mid - 1; + else + min = mid + 1; } - if ((flags & (byte) MethodDataSection.MoreSects) != 0) - ReadSection (body, br, instructions); + return null; + } + + void ReadSection () + { + Align (4); + + const byte fat_format = 0x40; + const byte more_sects = 0x80; + + var flags = ReadByte (); + if ((flags & fat_format) == 0) + ReadSmallSection (); + else + ReadFatSection (); + + if ((flags & more_sects) != 0) + ReadSection (); } - void ReadExceptionHandlerEnd (ExceptionHandler eh, BinaryReader br, MethodBody body, IDictionary instructions) + void ReadSmallSection () { - switch (eh.Type) { - case ExceptionHandlerType.Catch : - MetadataToken token = new MetadataToken (br.ReadInt32 ()); - eh.CatchType = m_reflectReader.GetTypeDefOrRef (token, new GenericContext (body.Method)); + var count = ReadByte () / 12; + Advance (2); + + ReadExceptionHandlers ( + count, + () => (int) ReadUInt16 (), + () => (int) ReadByte ()); + } + + void ReadFatSection () + { + position--; + var count = (ReadInt32 () >> 8) / 24; + + ReadExceptionHandlers ( + count, + ReadInt32, + ReadInt32); + } + + // inline ? + void ReadExceptionHandlers (int count, Func read_entry, Func read_length) + { + for (int i = 0; i < count; i++) { + var handler = new ExceptionHandler ( + (ExceptionHandlerType) (read_entry () & 0x7)); + + handler.TryStart = GetInstruction (read_entry ()); + handler.TryEnd = GetInstruction (handler.TryStart.Offset + read_length ()); + + handler.HandlerStart = GetInstruction (read_entry ()); + handler.HandlerEnd = GetInstruction (handler.HandlerStart.Offset + read_length ()); + + ReadExceptionHandlerSpecific (handler); + + this.body.ExceptionHandlers.Add (handler); + } + } + + void ReadExceptionHandlerSpecific (ExceptionHandler handler) + { + switch (handler.HandlerType) { + case ExceptionHandlerType.Catch: + handler.CatchType = (TypeReference) reader.LookupToken (ReadToken ()); break; - case ExceptionHandlerType.Filter : - eh.FilterStart = GetInstruction (body, instructions, br.ReadInt32 ()); - eh.FilterEnd = GetInstruction (body, instructions, eh.HandlerStart.Previous.Offset); + case ExceptionHandlerType.Filter: + handler.FilterStart = GetInstruction (ReadInt32 ()); + handler.FilterEnd = handler.HandlerStart.Previous; break; - default : - br.ReadInt32 (); + default: + Advance (4); break; } } - CallSite GetCallSiteAt (int token, GenericContext context) + void Align (int align) { - StandAloneSigTable sasTable = m_reflectReader.TableReader.GetStandAloneSigTable (); - MethodSig ms = m_reflectReader.SigReader.GetStandAloneMethodSig ( - sasTable [(int) GetRid (token) - 1].Signature); - CallSite cs = new CallSite (ms.HasThis, ms.ExplicitThis, - ms.MethCallConv, m_reflectReader.GetMethodReturnType (ms, context)); - cs.MetadataToken = new MetadataToken (token); + align--; + Advance (((position + align) & ~align) - position); + } + + public MetadataToken ReadToken () + { + return new MetadataToken (ReadUInt32 ()); + } + +#if !READ_ONLY + + public ByteBuffer PatchRawMethodBody (MethodDefinition method, CodeWriter writer, out MethodSymbols symbols) + { + var buffer = new ByteBuffer (); + symbols = new MethodSymbols (method.Name); + + this.method = method; + reader.context = method; + + MoveTo (method.RVA); - for (int i = 0; i < ms.ParamCount; i++) { - Param p = ms.Parameters [i]; - cs.Parameters.Add (m_reflectReader.BuildParameterDefinition (i, p, context)); + var flags = ReadByte (); + + MetadataToken local_var_token; + + switch (flags & 0x3) { + case 0x2: // tiny + buffer.WriteByte (flags); + local_var_token = MetadataToken.Zero; + symbols.code_size = flags >> 2; + PatchRawCode (buffer, symbols.code_size, writer); + break; + case 0x3: // fat + base.position--; + + PatchRawFatMethod (buffer, symbols, writer, out local_var_token); + break; + default: + throw new NotSupportedException (); + } + + var symbol_reader = reader.module.SymbolReader; + if (symbol_reader != null && writer.metadata.write_symbols) { + symbols.method_token = GetOriginalToken (writer.metadata, method); + symbols.local_var_token = local_var_token; + symbol_reader.Read (symbols); } - ReflectionReader.CreateSentinelIfNeeded (cs, ms); + return buffer; + } + + void PatchRawFatMethod (ByteBuffer buffer, MethodSymbols symbols, CodeWriter writer, out MetadataToken local_var_token) + { + var flags = ReadUInt16 (); + buffer.WriteUInt16 (flags); + buffer.WriteUInt16 (ReadUInt16 ()); + symbols.code_size = ReadInt32 (); + buffer.WriteInt32 (symbols.code_size); + local_var_token = ReadToken (); + + if (local_var_token.RID > 0) { + var variables = symbols.variables = ReadVariables (local_var_token); + buffer.WriteUInt32 (variables != null + ? writer.GetStandAloneSignature (symbols.variables).ToUInt32 () + : 0); + } else + buffer.WriteUInt32 (0); - return cs; + PatchRawCode (buffer, symbols.code_size, writer); + + if ((flags & 0x8) != 0) + PatchRawSection (buffer, writer.metadata); } - public override void VisitVariableDefinitionCollection (VariableDefinitionCollection variables) + static MetadataToken GetOriginalToken (MetadataBuilder metadata, MethodDefinition method) { - MethodBody body = variables.Container as MethodBody; - if (body == null || body.LocalVarToken == 0) - return; + MetadataToken original; + if (metadata.TryGetOriginalMethodToken (method.token, out original)) + return original; - StandAloneSigTable sasTable = m_reflectReader.TableReader.GetStandAloneSigTable (); - StandAloneSigRow sasRow = sasTable [(int) GetRid (body.LocalVarToken) - 1]; - LocalVarSig sig = m_reflectReader.SigReader.GetLocalVarSig (sasRow.Signature); - for (int i = 0; i < sig.Count; i++) { - LocalVarSig.LocalVariable lv = sig.LocalVariables [i]; - TypeReference varType = m_reflectReader.GetTypeRefFromSig ( - lv.Type, new GenericContext (body.Method)); + return MetadataToken.Zero; + } - if (lv.ByRef) - varType = new ReferenceType (varType); - if ((lv.Constraint & Constraint.Pinned) != 0) - varType = new PinnedType (varType); + void PatchRawCode (ByteBuffer buffer, int code_size, CodeWriter writer) + { + var metadata = writer.metadata; + buffer.WriteBytes (ReadBytes (code_size)); + var end = buffer.position; + buffer.position -= code_size; - varType = m_reflectReader.GetModifierType (lv.CustomMods, varType); + while (buffer.position < end) { + OpCode opcode; + var il_opcode = buffer.ReadByte (); + if (il_opcode != 0xfe) { + opcode = OpCodes.OneByteOpCode [il_opcode]; + } else { + var il_opcode2 = buffer.ReadByte (); + opcode = OpCodes.TwoBytesOpCode [il_opcode2]; + } - body.Variables.Add (new VariableDefinition ( - string.Concat ("V_", i), i, body.Method, varType)); + switch (opcode.OperandType) { + case OperandType.ShortInlineI: + case OperandType.ShortInlineBrTarget: + case OperandType.ShortInlineVar: + case OperandType.ShortInlineArg: + buffer.position += 1; + break; + case OperandType.InlineVar: + case OperandType.InlineArg: + buffer.position += 2; + break; + case OperandType.InlineBrTarget: + case OperandType.ShortInlineR: + case OperandType.InlineI: + buffer.position += 4; + break; + case OperandType.InlineI8: + case OperandType.InlineR: + buffer.position += 8; + break; + case OperandType.InlineSwitch: + var length = buffer.ReadInt32 (); + buffer.position += length * 4; + break; + case OperandType.InlineString: + var @string = GetString (new MetadataToken (buffer.ReadUInt32 ())); + buffer.position -= 4; + buffer.WriteUInt32 ( + new MetadataToken ( + TokenType.String, + metadata.user_string_heap.GetStringIndex (@string)).ToUInt32 ()); + break; + case OperandType.InlineSig: + var call_site = GetCallSite (new MetadataToken (buffer.ReadUInt32 ())); + buffer.position -= 4; + buffer.WriteUInt32 (writer.GetStandAloneSignature (call_site).ToUInt32 ()); + break; + case OperandType.InlineTok: + case OperandType.InlineType: + case OperandType.InlineMethod: + case OperandType.InlineField: + var provider = reader.LookupToken (new MetadataToken (buffer.ReadUInt32 ())); + buffer.position -= 4; + buffer.WriteUInt32 (metadata.LookupToken (provider).ToUInt32 ()); + break; + } + } + } + + void PatchRawSection (ByteBuffer buffer, MetadataBuilder metadata) + { + var position = base.position; + Align (4); + buffer.WriteBytes (base.position - position); + + const byte fat_format = 0x40; + const byte more_sects = 0x80; + + var flags = ReadByte (); + if ((flags & fat_format) == 0) { + buffer.WriteByte (flags); + PatchRawSmallSection (buffer, metadata); + } else + PatchRawFatSection (buffer, metadata); + + if ((flags & more_sects) != 0) + PatchRawSection (buffer, metadata); + } + + void PatchRawSmallSection (ByteBuffer buffer, MetadataBuilder metadata) + { + var length = ReadByte (); + buffer.WriteByte (length); + Advance (2); + + buffer.WriteUInt16 (0); + + var count = length / 12; + + PatchRawExceptionHandlers (buffer, metadata, count, false); + } + + void PatchRawFatSection (ByteBuffer buffer, MetadataBuilder metadata) + { + position--; + var length = ReadInt32 (); + buffer.WriteInt32 (length); + + var count = (length >> 8) / 24; + + PatchRawExceptionHandlers (buffer, metadata, count, true); + } + + void PatchRawExceptionHandlers (ByteBuffer buffer, MetadataBuilder metadata, int count, bool fat_entry) + { + const int fat_entry_size = 16; + const int small_entry_size = 6; + + for (int i = 0; i < count; i++) { + ExceptionHandlerType handler_type; + if (fat_entry) { + var type = ReadUInt32 (); + handler_type = (ExceptionHandlerType) (type & 0x7); + buffer.WriteUInt32 (type); + } else { + var type = ReadUInt16 (); + handler_type = (ExceptionHandlerType) (type & 0x7); + buffer.WriteUInt16 (type); + } + + buffer.WriteBytes (ReadBytes (fat_entry ? fat_entry_size : small_entry_size)); + + switch (handler_type) { + case ExceptionHandlerType.Catch: + var exception = reader.LookupToken (ReadToken ()); + buffer.WriteUInt32 (metadata.LookupToken (exception).ToUInt32 ()); + break; + default: + buffer.WriteUInt32 (ReadUInt32 ()); + break; + } } } + +#endif + } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/CodeWriter.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/CodeWriter.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/CodeWriter.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/CodeWriter.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 - 2007 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,437 +26,613 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil.Cil { +using System; +using System.Collections.Generic; - using System; - using System.Collections; +using Mono.Collections.Generic; - using Mono.Cecil; - using Mono.Cecil.Binary; - using Mono.Cecil.Metadata; - using Mono.Cecil.Signatures; +using Mono.Cecil.Metadata; +using Mono.Cecil.PE; - class CodeWriter : BaseCodeVisitor { +using RVA = System.UInt32; - ReflectionWriter m_reflectWriter; - MemoryBinaryWriter m_binaryWriter; - MemoryBinaryWriter m_codeWriter; +#if !READ_ONLY - IDictionary m_localSigCache; - IDictionary m_standaloneSigCache; +namespace Mono.Cecil.Cil { - public CodeWriter (ReflectionWriter reflectWriter, MemoryBinaryWriter writer) - { - m_reflectWriter = reflectWriter; - m_binaryWriter = writer; - m_codeWriter = new MemoryBinaryWriter (); + sealed class CodeWriter : ByteBuffer { - m_localSigCache = new Hashtable (); - m_standaloneSigCache = new Hashtable (); + readonly RVA code_base; + internal readonly MetadataBuilder metadata; + readonly Dictionary standalone_signatures; + + RVA current; + MethodBody body; + + public CodeWriter (MetadataBuilder metadata) + : base (0) + { + this.code_base = metadata.text_map.GetNextRVA (TextSegment.CLIHeader); + this.current = code_base; + this.metadata = metadata; + this.standalone_signatures = new Dictionary (); } - public RVA WriteMethodBody (MethodDefinition meth) + public RVA WriteMethodBody (MethodDefinition method) { - if (meth.Body == null) - return RVA.Zero; + var rva = BeginMethod (); + + if (IsUnresolved (method)) { + if (method.rva == 0) + return 0; + + WriteUnresolvedMethodBody (method); + } else { + if (IsEmptyMethodBody (method.Body)) + return 0; + + WriteResolvedMethodBody (method); + } + + Align (4); - RVA ret = m_reflectWriter.MetadataWriter.GetDataCursor (); - meth.Body.Accept (this); - return ret; + EndMethod (); + return rva; } - public override void VisitMethodBody (MethodBody body) + static bool IsEmptyMethodBody (MethodBody body) { - m_codeWriter.Empty (); + return body.instructions.IsNullOrEmpty () + && body.variables.IsNullOrEmpty (); } - void WriteToken (MetadataToken token) + static bool IsUnresolved (MethodDefinition method) { - if (token.RID == 0) - m_codeWriter.Write (0); - else - m_codeWriter.Write (token.ToUInt ()); + return method.HasBody && method.HasImage && method.body == null; } - static int GetParameterIndex (MethodBody body, ParameterDefinition p) + void WriteUnresolvedMethodBody (MethodDefinition method) { - int idx = body.Method.Parameters.IndexOf (p); - if (idx == -1 && p == body.Method.This) - return 0; - if (body.Method.HasThis) - idx++; + var code_reader = metadata.module.Read (method, (_, reader) => reader.code); + + MethodSymbols symbols; + var buffer = code_reader.PatchRawMethodBody (method, this, out symbols); + + WriteBytes (buffer); + + if (symbols.instructions.IsNullOrEmpty ()) + return; - return idx; + symbols.method_token = method.token; + symbols.local_var_token = GetLocalVarToken (buffer, symbols); + + var symbol_writer = metadata.symbol_writer; + if (symbol_writer != null) + symbol_writer.Write (symbols); } - public override void VisitInstructionCollection (InstructionCollection instructions) + static MetadataToken GetLocalVarToken (ByteBuffer buffer, MethodSymbols symbols) { - MethodBody body = instructions.Container; - long start = m_codeWriter.BaseStream.Position; + if (symbols.variables.IsNullOrEmpty ()) + return MetadataToken.Zero; - ComputeMaxStack (instructions); + buffer.position = 8; + return new MetadataToken (buffer.ReadUInt32 ()); + } - foreach (Instruction instr in instructions) { + void WriteResolvedMethodBody (MethodDefinition method) + { + body = method.Body; + ComputeHeader (); + if (RequiresFatHeader ()) + WriteFatHeader (); + else + WriteByte ((byte) (0x2 | (body.CodeSize << 2))); // tiny - instr.Offset = (int) (m_codeWriter.BaseStream.Position - start); + WriteInstructions (); - if (instr.OpCode.Size == 1) - m_codeWriter.Write (instr.OpCode.Op2); - else { - m_codeWriter.Write (instr.OpCode.Op1); - m_codeWriter.Write (instr.OpCode.Op2); - } + if (body.HasExceptionHandlers) + WriteExceptionHandlers (); - if (instr.OpCode.OperandType != OperandType.InlineNone && - instr.Operand == null) - throw new ReflectionException ("OpCode {0} have null operand", instr.OpCode.Name); + var symbol_writer = metadata.symbol_writer; + if (symbol_writer != null) + symbol_writer.Write (body); + } - switch (instr.OpCode.OperandType) { - case OperandType.InlineNone : - break; - case OperandType.InlineSwitch : - Instruction [] targets = (Instruction []) instr.Operand; - for (int i = 0; i < targets.Length + 1; i++) - m_codeWriter.Write ((uint) 0); - break; - case OperandType.ShortInlineBrTarget : - m_codeWriter.Write ((byte) 0); - break; - case OperandType.InlineBrTarget : - m_codeWriter.Write (0); - break; - case OperandType.ShortInlineI : - if (instr.OpCode == OpCodes.Ldc_I4_S) - m_codeWriter.Write ((sbyte) instr.Operand); - else - m_codeWriter.Write ((byte) instr.Operand); - break; - case OperandType.ShortInlineVar : - m_codeWriter.Write ((byte) body.Variables.IndexOf ( - (VariableDefinition) instr.Operand)); - break; - case OperandType.ShortInlineParam : - m_codeWriter.Write ((byte) GetParameterIndex (body, (ParameterDefinition) instr.Operand)); - break; - case OperandType.InlineSig : - WriteToken (GetCallSiteToken ((CallSite) instr.Operand)); - break; - case OperandType.InlineI : - m_codeWriter.Write ((int) instr.Operand); - break; - case OperandType.InlineVar : - m_codeWriter.Write ((short) body.Variables.IndexOf ( - (VariableDefinition) instr.Operand)); - break; - case OperandType.InlineParam : - m_codeWriter.Write ((short) GetParameterIndex ( - body, (ParameterDefinition) instr.Operand)); - break; - case OperandType.InlineI8 : - m_codeWriter.Write ((long) instr.Operand); - break; - case OperandType.ShortInlineR : - m_codeWriter.Write ((float) instr.Operand); - break; - case OperandType.InlineR : - m_codeWriter.Write ((double) instr.Operand); - break; - case OperandType.InlineString : - WriteToken (new MetadataToken (TokenType.String, - m_reflectWriter.MetadataWriter.AddUserString (instr.Operand as string))); - break; - case OperandType.InlineField : - case OperandType.InlineMethod : - case OperandType.InlineType : - case OperandType.InlineTok : - if (instr.Operand is TypeReference) - WriteToken (m_reflectWriter.GetTypeDefOrRefToken ( - instr.Operand as TypeReference)); - else if (instr.Operand is GenericInstanceMethod) - WriteToken (m_reflectWriter.GetMethodSpecToken (instr.Operand as GenericInstanceMethod)); - else if (instr.Operand is MemberReference) - WriteToken (m_reflectWriter.GetMemberRefToken ((MemberReference) instr.Operand)); - else if (instr.Operand is IMetadataTokenProvider) - WriteToken (((IMetadataTokenProvider) instr.Operand).MetadataToken); - else - throw new ReflectionException ( - string.Format ("Wrong operand for {0} OpCode: {1}", - instr.OpCode.OperandType, - instr.Operand.GetType ().FullName)); - break; - } + void WriteFatHeader () + { + var body = this.body; + byte flags = 0x3; // fat + if (body.InitLocals) + flags |= 0x10; // init locals + if (body.HasExceptionHandlers) + flags |= 0x8; // more sections + + WriteByte (flags); + WriteByte (0x30); + WriteInt16 ((short) body.max_stack_size); + WriteInt32 (body.code_size); + body.local_var_token = body.HasVariables + ? GetStandAloneSignature (body.Variables) + : MetadataToken.Zero; + WriteMetadataToken (body.local_var_token); + } + + void WriteInstructions () + { + var instructions = body.Instructions; + var items = instructions.items; + var size = instructions.size; + + for (int i = 0; i < size; i++) { + var instruction = items [i]; + WriteOpCode (instruction.opcode); + WriteOperand (instruction); } + } - // patch branches - long pos = m_codeWriter.BaseStream.Position; + void WriteOpCode (OpCode opcode) + { + if (opcode.Size == 1) { + WriteByte (opcode.Op2); + } else { + WriteByte (opcode.Op1); + WriteByte (opcode.Op2); + } + } - foreach (Instruction instr in instructions) { - switch (instr.OpCode.OperandType) { - case OperandType.InlineSwitch : - m_codeWriter.BaseStream.Position = instr.Offset + instr.OpCode.Size; - Instruction [] targets = (Instruction []) instr.Operand; - m_codeWriter.Write ((uint) targets.Length); - foreach (Instruction tgt in targets) - m_codeWriter.Write ((tgt.Offset - (instr.Offset + - instr.OpCode.Size + (4 * (targets.Length + 1))))); - break; - case OperandType.ShortInlineBrTarget : - m_codeWriter.BaseStream.Position = instr.Offset + instr.OpCode.Size; - m_codeWriter.Write ((byte) (((Instruction) instr.Operand).Offset - - (instr.Offset + instr.OpCode.Size + 1))); - break; - case OperandType.InlineBrTarget : - m_codeWriter.BaseStream.Position = instr.Offset + instr.OpCode.Size; - m_codeWriter.Write(((Instruction) instr.Operand).Offset - - (instr.Offset + instr.OpCode.Size + 4)); - break; - } + void WriteOperand (Instruction instruction) + { + var opcode = instruction.opcode; + var operand_type = opcode.OperandType; + if (operand_type == OperandType.InlineNone) + return; + + var operand = instruction.operand; + if (operand == null) + throw new ArgumentException (); + + switch (operand_type) { + case OperandType.InlineSwitch: { + var targets = (Instruction []) operand; + WriteInt32 (targets.Length); + var diff = instruction.Offset + opcode.Size + (4 * (targets.Length + 1)); + for (int i = 0; i < targets.Length; i++) + WriteInt32 (GetTargetOffset (targets [i]) - diff); + break; + } + case OperandType.ShortInlineBrTarget: { + var target = (Instruction) operand; + WriteSByte ((sbyte) (GetTargetOffset (target) - (instruction.Offset + opcode.Size + 1))); + break; + } + case OperandType.InlineBrTarget: { + var target = (Instruction) operand; + WriteInt32 (GetTargetOffset (target) - (instruction.Offset + opcode.Size + 4)); + break; + } + case OperandType.ShortInlineVar: + WriteByte ((byte) GetVariableIndex ((VariableDefinition) operand)); + break; + case OperandType.ShortInlineArg: + WriteByte ((byte) GetParameterIndex ((ParameterDefinition) operand)); + break; + case OperandType.InlineVar: + WriteInt16 ((short) GetVariableIndex ((VariableDefinition) operand)); + break; + case OperandType.InlineArg: + WriteInt16 ((short) GetParameterIndex ((ParameterDefinition) operand)); + break; + case OperandType.InlineSig: + WriteMetadataToken (GetStandAloneSignature ((CallSite) operand)); + break; + case OperandType.ShortInlineI: + if (opcode == OpCodes.Ldc_I4_S) + WriteSByte ((sbyte) operand); + else + WriteByte ((byte) operand); + break; + case OperandType.InlineI: + WriteInt32 ((int) operand); + break; + case OperandType.InlineI8: + WriteInt64 ((long) operand); + break; + case OperandType.ShortInlineR: + WriteSingle ((float) operand); + break; + case OperandType.InlineR: + WriteDouble ((double) operand); + break; + case OperandType.InlineString: + WriteMetadataToken ( + new MetadataToken ( + TokenType.String, + GetUserStringIndex ((string) operand))); + break; + case OperandType.InlineType: + case OperandType.InlineField: + case OperandType.InlineMethod: + case OperandType.InlineTok: + WriteMetadataToken (metadata.LookupToken ((IMetadataTokenProvider) operand)); + break; + default: + throw new ArgumentException (); + } + } + + int GetTargetOffset (Instruction instruction) + { + if (instruction == null) { + var last = body.instructions [body.instructions.size - 1]; + return last.offset + last.GetSize (); } - m_codeWriter.BaseStream.Position = pos; + return instruction.offset; } - MetadataToken GetCallSiteToken (CallSite cs) + uint GetUserStringIndex (string @string) { - uint sig; - int sentinel = cs.GetSentinel (); - if (sentinel > 0) - sig = m_reflectWriter.SignatureWriter.AddMethodDefSig ( - m_reflectWriter.GetMethodDefSig (cs)); - else - sig = m_reflectWriter.SignatureWriter.AddMethodRefSig ( - m_reflectWriter.GetMethodRefSig (cs)); + if (@string == null) + return 0; - if (m_standaloneSigCache.Contains (sig)) - return (MetadataToken) m_standaloneSigCache [sig]; + return metadata.user_string_heap.GetStringIndex (@string); + } - StandAloneSigTable sasTable = m_reflectWriter.MetadataTableWriter.GetStandAloneSigTable (); - StandAloneSigRow sasRow = m_reflectWriter.MetadataRowWriter.CreateStandAloneSigRow (sig); + static int GetVariableIndex (VariableDefinition variable) + { + return variable.Index; + } - sasTable.Rows.Add(sasRow); + int GetParameterIndex (ParameterDefinition parameter) + { + if (body.method.HasThis) { + if (parameter == body.this_parameter) + return 0; - MetadataToken token = new MetadataToken (TokenType.Signature, (uint) sasTable.Rows.Count); - m_standaloneSigCache [sig] = token; - return token; + return parameter.Index + 1; + } + + return parameter.Index; } - static int GetLength (Instruction start, Instruction end, InstructionCollection instructions) + bool RequiresFatHeader () { - Instruction last = instructions [instructions.Count - 1]; - return (end == instructions.Outside ? last.Offset + last.GetSize () : end.Offset) - start.Offset; + var body = this.body; + return body.CodeSize >= 64 + || body.InitLocals + || body.HasVariables + || body.HasExceptionHandlers + || body.MaxStackSize > 8; } - static bool IsRangeFat (Instruction start, Instruction end, InstructionCollection instructions) + void ComputeHeader () { - return GetLength (start, end, instructions) >= 256 || - start.Offset >= 65536; + int offset = 0; + var instructions = body.instructions; + var items = instructions.items; + var count = instructions.size; + var stack_size = 0; + var max_stack = 0; + Dictionary stack_sizes = null; + + if (body.HasExceptionHandlers) + ComputeExceptionHandlerStackSize (ref stack_sizes); + + for (int i = 0; i < count; i++) { + var instruction = items [i]; + instruction.offset = offset; + offset += instruction.GetSize (); + + ComputeStackSize (instruction, ref stack_sizes, ref stack_size, ref max_stack); + } + + body.code_size = offset; + body.max_stack_size = max_stack; } - static bool IsFat (ExceptionHandlerCollection seh) + void ComputeExceptionHandlerStackSize (ref Dictionary stack_sizes) { - for (int i = 0; i < seh.Count; i++) { - ExceptionHandler eh = seh [i]; - if (IsRangeFat (eh.TryStart, eh.TryEnd, seh.Container.Instructions)) - return true; + var exception_handlers = body.ExceptionHandlers; - if (IsRangeFat (eh.HandlerStart, eh.HandlerEnd, seh.Container.Instructions)) - return true; + for (int i = 0; i < exception_handlers.Count; i++) { + var exception_handler = exception_handlers [i]; - switch (eh.Type) { - case ExceptionHandlerType.Filter : - if (IsRangeFat (eh.FilterStart, eh.FilterEnd, seh.Container.Instructions)) - return true; + switch (exception_handler.HandlerType) { + case ExceptionHandlerType.Catch: + AddExceptionStackSize (exception_handler.HandlerStart, ref stack_sizes); + break; + case ExceptionHandlerType.Filter: + AddExceptionStackSize (exception_handler.FilterStart, ref stack_sizes); + AddExceptionStackSize (exception_handler.HandlerStart, ref stack_sizes); break; } } + } - return false; + static void AddExceptionStackSize (Instruction handler_start, ref Dictionary stack_sizes) + { + if (handler_start == null) + return; + + if (stack_sizes == null) + stack_sizes = new Dictionary (); + + stack_sizes [handler_start] = 1; } - void WriteExceptionHandlerCollection (ExceptionHandlerCollection seh) + static void ComputeStackSize (Instruction instruction, ref Dictionary stack_sizes, ref int stack_size, ref int max_stack) { - m_codeWriter.QuadAlign (); + int computed_size; + if (stack_sizes != null && stack_sizes.TryGetValue (instruction, out computed_size)) + stack_size = computed_size; - if (seh.Count < 0x15 && !IsFat (seh)) { - m_codeWriter.Write ((byte) MethodDataSection.EHTable); - m_codeWriter.Write ((byte) (seh.Count * 12 + 4)); - m_codeWriter.Write (new byte [2]); - foreach (ExceptionHandler eh in seh) { - m_codeWriter.Write ((ushort) eh.Type); - m_codeWriter.Write ((ushort) eh.TryStart.Offset); - m_codeWriter.Write ((byte) (eh.TryEnd.Offset - eh.TryStart.Offset)); - m_codeWriter.Write ((ushort) eh.HandlerStart.Offset); - m_codeWriter.Write ((byte) GetLength (eh.HandlerStart, eh.HandlerEnd, seh.Container.Instructions)); - WriteHandlerSpecific (eh); - } - } else { - m_codeWriter.Write ((byte) (MethodDataSection.FatFormat | MethodDataSection.EHTable)); - WriteFatBlockSize (seh); - foreach (ExceptionHandler eh in seh) { - m_codeWriter.Write ((uint) eh.Type); - m_codeWriter.Write ((uint) eh.TryStart.Offset); - m_codeWriter.Write ((uint) (eh.TryEnd.Offset - eh.TryStart.Offset)); - m_codeWriter.Write ((uint) eh.HandlerStart.Offset); - m_codeWriter.Write ((uint) GetLength (eh.HandlerStart, eh.HandlerEnd, seh.Container.Instructions)); - WriteHandlerSpecific (eh); - } + max_stack = System.Math.Max (max_stack, stack_size); + ComputeStackDelta (instruction, ref stack_size); + max_stack = System.Math.Max (max_stack, stack_size); + + CopyBranchStackSize (instruction, ref stack_sizes, stack_size); + ComputeStackSize (instruction, ref stack_size); + } + + static void CopyBranchStackSize (Instruction instruction, ref Dictionary stack_sizes, int stack_size) + { + if (stack_size == 0) + return; + + switch (instruction.opcode.OperandType) { + case OperandType.ShortInlineBrTarget: + case OperandType.InlineBrTarget: + CopyBranchStackSize (ref stack_sizes, (Instruction) instruction.operand, stack_size); + break; + case OperandType.InlineSwitch: + var targets = (Instruction[]) instruction.operand; + for (int i = 0; i < targets.Length; i++) + CopyBranchStackSize (ref stack_sizes, targets [i], stack_size); + break; } } - void WriteFatBlockSize (ExceptionHandlerCollection seh) + static void CopyBranchStackSize (ref Dictionary stack_sizes, Instruction target, int stack_size) { - int size = seh.Count * 24 + 4; - m_codeWriter.Write ((byte) (size & 0xff)); - m_codeWriter.Write ((byte) ((size >> 8) & 0xff)); - m_codeWriter.Write ((byte) ((size >> 16) & 0xff)); + if (stack_sizes == null) + stack_sizes = new Dictionary (); + + int branch_stack_size = stack_size; + + int computed_size; + if (stack_sizes.TryGetValue (target, out computed_size)) + branch_stack_size = System.Math.Max (branch_stack_size, computed_size); + + stack_sizes [target] = branch_stack_size; } - void WriteHandlerSpecific (ExceptionHandler eh) + static void ComputeStackSize (Instruction instruction, ref int stack_size) { - switch (eh.Type) { - case ExceptionHandlerType.Catch : - WriteToken (eh.CatchType.MetadataToken); + switch (instruction.opcode.FlowControl) { + case FlowControl.Branch: + case FlowControl.Break: + case FlowControl.Throw: + case FlowControl.Return: + stack_size = 0; break; - case ExceptionHandlerType.Filter : - m_codeWriter.Write ((uint) eh.FilterStart.Offset); + } + } + + static void ComputeStackDelta (Instruction instruction, ref int stack_size) + { + switch (instruction.opcode.FlowControl) { + case FlowControl.Call: { + var method = (IMethodSignature) instruction.operand; + stack_size -= (method.HasParameters ? method.Parameters.Count : 0) + + (method.HasThis && instruction.opcode.Code != Code.Newobj ? 1 : 0); + stack_size += (method.ReturnType.etype == ElementType.Void ? 0 : 1) + + (method.HasThis && instruction.opcode.Code == Code.Newobj ? 1 : 0); break; - default : - m_codeWriter.Write (0); + } + default: + ComputePopDelta (instruction.opcode.StackBehaviourPop, ref stack_size); + ComputePushDelta (instruction.opcode.StackBehaviourPush, ref stack_size); break; } } - public override void VisitVariableDefinitionCollection (VariableDefinitionCollection variables) + static void ComputePopDelta (StackBehaviour pop_behavior, ref int stack_size) { - MethodBody body = variables.Container as MethodBody; - if (body == null) - return; + switch (pop_behavior) { + case StackBehaviour.Popi: + case StackBehaviour.Popref: + case StackBehaviour.Pop1: + stack_size--; + break; + case StackBehaviour.Pop1_pop1: + case StackBehaviour.Popi_pop1: + case StackBehaviour.Popi_popi: + case StackBehaviour.Popi_popi8: + case StackBehaviour.Popi_popr4: + case StackBehaviour.Popi_popr8: + case StackBehaviour.Popref_pop1: + case StackBehaviour.Popref_popi: + stack_size -= 2; + break; + case StackBehaviour.Popi_popi_popi: + case StackBehaviour.Popref_popi_popi: + case StackBehaviour.Popref_popi_popi8: + case StackBehaviour.Popref_popi_popr4: + case StackBehaviour.Popref_popi_popr8: + case StackBehaviour.Popref_popi_popref: + stack_size -= 3; + break; + case StackBehaviour.PopAll: + stack_size = 0; + break; + } + } - uint sig = m_reflectWriter.SignatureWriter.AddLocalVarSig ( - GetLocalVarSig (variables)); + static void ComputePushDelta (StackBehaviour push_behaviour, ref int stack_size) + { + switch (push_behaviour) { + case StackBehaviour.Push1: + case StackBehaviour.Pushi: + case StackBehaviour.Pushi8: + case StackBehaviour.Pushr4: + case StackBehaviour.Pushr8: + case StackBehaviour.Pushref: + stack_size++; + break; + case StackBehaviour.Push1_push1: + stack_size += 2; + break; + } + } - if (m_localSigCache.Contains (sig)) { - body.LocalVarToken = (int) m_localSigCache [sig]; - return; + void WriteExceptionHandlers () + { + Align (4); + + var handlers = body.ExceptionHandlers; + + if (handlers.Count < 0x15 && !RequiresFatSection (handlers)) + WriteSmallSection (handlers); + else + WriteFatSection (handlers); + } + + static bool RequiresFatSection (Collection handlers) + { + for (int i = 0; i < handlers.Count; i++) { + var handler = handlers [i]; + + if (IsFatRange (handler.TryStart, handler.TryEnd)) + return true; + + if (IsFatRange (handler.HandlerStart, handler.HandlerEnd)) + return true; + + if (handler.HandlerType == ExceptionHandlerType.Filter + && IsFatRange (handler.FilterStart, handler.FilterEnd)) + return true; } - StandAloneSigTable sasTable = m_reflectWriter.MetadataTableWriter.GetStandAloneSigTable (); - StandAloneSigRow sasRow = m_reflectWriter.MetadataRowWriter.CreateStandAloneSigRow ( - sig); + return false; + } - sasTable.Rows.Add (sasRow); - body.LocalVarToken = sasTable.Rows.Count; - m_localSigCache [sig] = body.LocalVarToken; + static bool IsFatRange (Instruction start, Instruction end) + { + if (end == null) + return true; + + return end.Offset - start.Offset > 255 || start.Offset > 65535; } - public override void TerminateMethodBody (MethodBody body) + void WriteSmallSection (Collection handlers) { - long pos = m_binaryWriter.BaseStream.Position; + const byte eh_table = 0x1; - if (body.Variables.Count > 0 || body.ExceptionHandlers.Count > 0 - || m_codeWriter.BaseStream.Length >= 64 || body.MaxStack > 8) { + WriteByte (eh_table); + WriteByte ((byte) (handlers.Count * 12 + 4)); + WriteBytes (2); - MethodHeader header = MethodHeader.FatFormat; - if (body.InitLocals) - header |= MethodHeader.InitLocals; - if (body.ExceptionHandlers.Count > 0) - header |= MethodHeader.MoreSects; + WriteExceptionHandlers ( + handlers, + i => WriteUInt16 ((ushort) i), + i => WriteByte ((byte) i)); + } - m_binaryWriter.Write ((byte) header); - m_binaryWriter.Write ((byte) 0x30); // (header size / 4) << 4 - m_binaryWriter.Write ((short) body.MaxStack); - m_binaryWriter.Write ((int) m_codeWriter.BaseStream.Length); - m_binaryWriter.Write (((int) TokenType.Signature | body.LocalVarToken)); + void WriteFatSection (Collection handlers) + { + const byte eh_table = 0x1; + const byte fat_format = 0x40; - WriteExceptionHandlerCollection (body.ExceptionHandlers); - } else - m_binaryWriter.Write ((byte) ((byte) MethodHeader.TinyFormat | - m_codeWriter.BaseStream.Length << 2)); + WriteByte (eh_table | fat_format); - m_binaryWriter.Write (m_codeWriter); - m_binaryWriter.QuadAlign (); + int size = handlers.Count * 24 + 4; + WriteByte ((byte) (size & 0xff)); + WriteByte ((byte) ((size >> 8) & 0xff)); + WriteByte ((byte) ((size >> 16) & 0xff)); - m_reflectWriter.MetadataWriter.AddData ( - (int) (m_binaryWriter.BaseStream.Position - pos)); + WriteExceptionHandlers (handlers, WriteInt32, WriteInt32); } - public LocalVarSig.LocalVariable GetLocalVariableSig (VariableDefinition var) + void WriteExceptionHandlers (Collection handlers, Action write_entry, Action write_length) { - LocalVarSig.LocalVariable lv = new LocalVarSig.LocalVariable (); - TypeReference type = var.VariableType; + for (int i = 0; i < handlers.Count; i++) { + var handler = handlers [i]; - lv.CustomMods = m_reflectWriter.GetCustomMods (type); + write_entry ((int) handler.HandlerType); - if (type is PinnedType) { - lv.Constraint |= Constraint.Pinned; - type = (type as PinnedType).ElementType; + write_entry (handler.TryStart.Offset); + write_length (GetTargetOffset (handler.TryEnd) - handler.TryStart.Offset); + + write_entry (handler.HandlerStart.Offset); + write_length (GetTargetOffset (handler.HandlerEnd) - handler.HandlerStart.Offset); + + WriteExceptionHandlerSpecific (handler); } + } - if (type is ReferenceType) { - lv.ByRef = true; - type = (type as ReferenceType).ElementType; + void WriteExceptionHandlerSpecific (ExceptionHandler handler) + { + switch (handler.HandlerType) { + case ExceptionHandlerType.Catch: + WriteMetadataToken (metadata.LookupToken (handler.CatchType)); + break; + case ExceptionHandlerType.Filter: + WriteInt32 (handler.FilterStart.Offset); + break; + default: + WriteInt32 (0); + break; } + } - lv.Type = m_reflectWriter.GetSigType (type); + public MetadataToken GetStandAloneSignature (Collection variables) + { + var signature = metadata.GetLocalVariableBlobIndex (variables); - return lv; + return GetStandAloneSignatureToken (signature); } - public LocalVarSig GetLocalVarSig (VariableDefinitionCollection vars) + public MetadataToken GetStandAloneSignature (CallSite call_site) { - LocalVarSig lvs = new LocalVarSig (); - lvs.CallingConvention |= 0x7; - lvs.Count = vars.Count; - lvs.LocalVariables = new LocalVarSig.LocalVariable [lvs.Count]; - for (int i = 0; i < lvs.Count; i++) { - lvs.LocalVariables [i] = GetLocalVariableSig (vars [i]); - } + var signature = metadata.GetCallSiteBlobIndex (call_site); + var token = GetStandAloneSignatureToken (signature); + call_site.MetadataToken = token; + return token; + } + + MetadataToken GetStandAloneSignatureToken (uint signature) + { + MetadataToken token; + if (standalone_signatures.TryGetValue (signature, out token)) + return token; - return lvs; + token = new MetadataToken (TokenType.Signature, metadata.AddStandAloneSignature (signature)); + standalone_signatures.Add (signature, token); + return token; } - static void ComputeMaxStack (InstructionCollection instructions) + RVA BeginMethod () { - InstructionCollection ehs = new InstructionCollection (null); - foreach (ExceptionHandler eh in instructions.Container.ExceptionHandlers) { - switch (eh.Type) { - case ExceptionHandlerType.Catch : - ehs.Add (eh.HandlerStart); - break; - case ExceptionHandlerType.Filter : - ehs.Add (eh.FilterStart); - break; - } - } + return current; + } - int max = 0; - foreach (Instruction instr in instructions) { - if (ehs.Contains (instr)) - max++; - - switch (instr.OpCode.StackBehaviourPush) { - case StackBehaviour.Push1: - case StackBehaviour.Pushi: - case StackBehaviour.Pushi8: - case StackBehaviour.Pushr4: - case StackBehaviour.Pushr8: - case StackBehaviour.Pushref: - case StackBehaviour.Varpush: - max++; - break; - case StackBehaviour.Push1_push1: - max += 2; - break; - } + void WriteMetadataToken (MetadataToken token) + { + WriteUInt32 (token.ToUInt32 ()); + } - if (instr.OpCode.OperandType == OperandType.InlineMethod) { - IMethodSignature signature = instr.Operand as IMethodSignature; - if (signature != null && signature.ReturnType.ReturnType.FullName != Constants.Void) - max++; - } - } + void Align (int align) + { + align--; + WriteBytes (((position + align) & ~align) - position); + } - instructions.Container.MaxStack = max; + void EndMethod () + { + current = (RVA) (code_base + position); } } } + +#endif diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Document.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Document.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Document.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Document.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2006 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,55 +26,86 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System; + namespace Mono.Cecil.Cil { - using System; + public enum DocumentType { + Other, + Text, + } + + public enum DocumentHashAlgorithm { + None, + MD5, + SHA1, + } + + public enum DocumentLanguage { + Other, + C, + Cpp, + CSharp, + Basic, + Java, + Cobol, + Pascal, + Cil, + JScript, + Smc, + MCpp, + } + + public enum DocumentLanguageVendor { + Other, + Microsoft, + } - public class Document { + public sealed class Document { - string m_url; + string url; - Guid m_type; - DocumentHashAlgorithm m_hashAlgorithm; - Guid m_language; - Guid m_languageVendor; + byte type; + byte hash_algorithm; + byte language; + byte language_vendor; - byte [] m_hash; + byte [] hash; public string Url { - get { return m_url; } - set { m_url = value; } + get { return url; } + set { url = value; } } - public Guid Type { - get { return m_type; } - set { m_type = value; } + public DocumentType Type { + get { return (DocumentType) type; } + set { type = (byte) value; } } public DocumentHashAlgorithm HashAlgorithm { - get { return m_hashAlgorithm; } - set { m_hashAlgorithm = value; } + get { return (DocumentHashAlgorithm) hash_algorithm; } + set { hash_algorithm = (byte) value; } } - public Guid Language { - get { return m_language; } - set { m_language = value; } + public DocumentLanguage Language { + get { return (DocumentLanguage) language; } + set { language = (byte) value; } } - public Guid LanguageVendor { - get { return m_languageVendor; } - set { m_languageVendor = value; } + public DocumentLanguageVendor LanguageVendor { + get { return (DocumentLanguageVendor) language_vendor; } + set { language_vendor = (byte) value; } } public byte [] Hash { - get { return m_hash; } - set { m_hash = value; } + get { return hash; } + set { hash = value; } } public Document (string url) { - m_url = url; - m_hash = new byte [0]; + this.url = url; + this.hash = Empty.Array; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentHashAlgorithm.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentHashAlgorithm.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentHashAlgorithm.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentHashAlgorithm.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// -// DocumentHashAlgorithm.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2006 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - public enum DocumentHashAlgorithm { - [Guid (0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)] None, - [Guid (0x406ea660, 0x64cf, 0x4c82, 0xb6, 0xf0, 0x42, 0xd4, 0x81, 0x72, 0xa7, 0x99)] MD5, - [Guid (0xff1816ec, 0xaa5e, 0x4d10, 0x87, 0xf7, 0x6f, 0x49, 0x63, 0x83, 0x34, 0x60)] SHA1 - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentLanguage.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentLanguage.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentLanguage.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentLanguage.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// -// DocumentLanguage.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2006 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - using System; - - public abstract class DocumentLanguage { - public static readonly Guid None = new Guid (0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x0, 0x00, 0x00, 0x00, 0x00, 0x00); - public static readonly Guid C = new Guid (0x63a08714, 0xfc37, 0x11d2, 0x90, 0x4c, 0x0, 0xc0, 0x4f, 0xa3, 0x02, 0xa1); - public static readonly Guid Cpp = new Guid (0x3a12d0b7, 0xc26c, 0x11d0, 0xb4, 0x42, 0x0, 0xa0, 0x24, 0x4a, 0x1d, 0xd2); - public static readonly Guid CSharp = new Guid (0x3f5162f8, 0x07c6, 0x11d3, 0x90, 0x53, 0x0, 0xc0, 0x4f, 0xa3, 0x02, 0xa1); - public static readonly Guid Basic = new Guid (0x3a12d0b8, 0xc26c, 0x11d0, 0xb4, 0x42, 0x0, 0xa0, 0x24, 0x4a, 0x1d, 0xd2); - public static readonly Guid Java = new Guid (0x3a12d0b4, 0xc26c, 0x11d0, 0xb4, 0x42, 0x0, 0xa0, 0x24, 0x4a, 0x1d, 0xd2); - public static readonly Guid Cobol = new Guid (0xaf046cd1, 0xd0e1, 0x11d2, 0x97, 0x7c, 0x0, 0xa0, 0xc9, 0xb4, 0xd5, 0xc); - public static readonly Guid Pascal = new Guid (0xaf046cd2, 0xd0e1, 0x11d2, 0x97, 0x7c, 0x0, 0xa0, 0xc9, 0xb4, 0xd5, 0xc); - public static readonly Guid CIL = new Guid (0xaf046cd3, 0xd0e1, 0x11d2, 0x97, 0x7c, 0x0, 0xa0, 0xc9, 0xb4, 0xd5, 0xc); - public static readonly Guid JScript = new Guid (0x3a12d0b6, 0xc26c, 0x11d0, 0xb4, 0x42, 0x0, 0xa0, 0x24, 0x4a, 0x1d, 0xd2); - public static readonly Guid SMC = new Guid (0xd9b9f7b, 0x6611, 0x11d3, 0xbd, 0x2a, 0x0, 0x0, 0xf8, 0x8, 0x49, 0xbd); - public static readonly Guid MCpp = new Guid (0x4b35fde8, 0x07c6, 0x11d3, 0x90, 0x53, 0x0, 0xc0, 0x4f, 0xa3, 0x02, 0xa1); - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentLanguageVendor.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentLanguageVendor.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentLanguageVendor.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentLanguageVendor.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// -// DocumentLanguageVendor.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2006 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - using System; - - public abstract class DocumentLanguageVendor { - public static readonly Guid Other = new Guid (0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); - public static readonly Guid Microsoft = new Guid (0x994b45c4, 0xe6e9, 0x11d2, 0x90, 0x3f, 0x00, 0xc0, 0x4f, 0xa3, 0x02, 0xa1); - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentType.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentType.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentType.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentType.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// -// DocumentType.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2006 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - using System; - - public abstract class DocumentType { - - public static readonly Guid Other = new Guid (0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); - public static readonly Guid Text = new Guid (0x5a869d0b, 0x6611, 0x11d3, 0xbd, 0x2a, 0x00, 0x00, 0xf8, 0x08, 0x49, 0xbd); - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ExceptionHandlerCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ExceptionHandlerCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ExceptionHandlerCollection.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ExceptionHandlerCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ -// -// ExceptionHandlerCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Wed Sep 27 12:46:53 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - using System; - using System.Collections; - - using Mono.Cecil.Cil; - - public sealed class ExceptionHandlerCollection : CollectionBase, ICodeVisitable { - - MethodBody m_container; - - public ExceptionHandler this [int index] { - get { return List [index] as ExceptionHandler; } - set { List [index] = value; } - } - - public MethodBody Container { - get { return m_container; } - } - - public ExceptionHandlerCollection (MethodBody container) - { - m_container = container; - } - - public void Add (ExceptionHandler value) - { - List.Add (value); - } - - public bool Contains (ExceptionHandler value) - { - return List.Contains (value); - } - - public int IndexOf (ExceptionHandler value) - { - return List.IndexOf (value); - } - - public void Insert (int index, ExceptionHandler value) - { - List.Insert (index, value); - } - - public void Remove (ExceptionHandler value) - { - List.Remove (value); - } - - protected override void OnValidate (object o) - { - if (! (o is ExceptionHandler)) - throw new ArgumentException ("Must be of type " + typeof (ExceptionHandler).FullName); - } - - public void Accept (ICodeVisitor visitor) - { - visitor.VisitExceptionHandlerCollection (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ExceptionHandler.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ExceptionHandler.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ExceptionHandler.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ExceptionHandler.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -28,68 +28,68 @@ namespace Mono.Cecil.Cil { - using Mono.Cecil; + public enum ExceptionHandlerType { + Catch = 0, + Filter = 1, + Finally = 2, + Fault = 4, + } - public sealed class ExceptionHandler : ICodeVisitable { + public sealed class ExceptionHandler { - Instruction m_tryStart; - Instruction m_tryEnd; - Instruction m_filterStart; - Instruction m_filterEnd; - Instruction m_handlerStart; - Instruction m_handlerEnd; + Instruction try_start; + Instruction try_end; + Instruction filter_start; + Instruction filter_end; + Instruction handler_start; + Instruction handler_end; - TypeReference m_catchType; - ExceptionHandlerType m_type; + TypeReference catch_type; + ExceptionHandlerType handler_type; public Instruction TryStart { - get { return m_tryStart; } - set { m_tryStart = value; } + get { return try_start; } + set { try_start = value; } } public Instruction TryEnd { - get { return m_tryEnd; } - set { m_tryEnd = value; } + get { return try_end; } + set { try_end = value; } } public Instruction FilterStart { - get { return m_filterStart; } - set { m_filterStart = value; } + get { return filter_start; } + set { filter_start = value; } } public Instruction FilterEnd { - get { return m_filterEnd; } - set { m_filterEnd = value; } + get { return filter_end; } + set { filter_end = value; } } public Instruction HandlerStart { - get { return m_handlerStart; } - set { m_handlerStart = value; } + get { return handler_start; } + set { handler_start = value; } } public Instruction HandlerEnd { - get { return m_handlerEnd; } - set { m_handlerEnd = value; } + get { return handler_end; } + set { handler_end = value; } } public TypeReference CatchType { - get { return m_catchType; } - set { m_catchType = value; } - } - - public ExceptionHandlerType Type { - get { return m_type; } - set { m_type = value; } + get { return catch_type; } + set { catch_type = value; } } - public ExceptionHandler (ExceptionHandlerType type) - { - m_type = type; + public ExceptionHandlerType HandlerType { + get { return handler_type; } + set { handler_type = value; } } - public void Accept (ICodeVisitor visitor) + public ExceptionHandler (ExceptionHandlerType handlerType) { - visitor.VisitExceptionHandler (this); + this.handler_type = handlerType; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ExceptionHandlerType.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ExceptionHandlerType.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ExceptionHandlerType.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ExceptionHandlerType.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// -// ExceptionHandlerType.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - public enum ExceptionHandlerType { - Catch = 0x0000, - Filter = 0x0001, - Finally = 0x0002, - Fault = 0x0004 - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/FlowControl.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/FlowControl.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/FlowControl.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/FlowControl.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// -// FlowControl.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - public enum FlowControl { - Branch, - Break, - Call, - Cond_Branch, - Meta, - Next, - Phi, - Return, - Throw - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/GuidAttribute.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/GuidAttribute.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/GuidAttribute.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/GuidAttribute.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +0,0 @@ -// -// GuidAttribute.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2006 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - using System; - using System.Reflection; - - [AttributeUsage (AttributeTargets.Field)] - public class GuidAttribute : Attribute { - - private Guid m_guid; - - public Guid Guid { - get { return m_guid; } - } - - GuidAttribute () - { - m_guid = new Guid (); - } - - public GuidAttribute ( - uint a, - ushort b, - ushort c, - byte d, - byte e, - byte f, - byte g, - byte h, - byte i, - byte j, - byte k) - { - m_guid = new Guid ((int) a, (short) b, (short) c, d, e, f, g, h, i, j, k); - } - - public static int GetValueFromGuid (Guid id, Type enumeration) - { - foreach (FieldInfo fi in enumeration.GetFields (BindingFlags.Static | BindingFlags.Public)) - if (id == GetGuidAttribute (fi).Guid) - return (int) fi.GetValue (null); - - return -1; - } - - public static Guid GetGuidFromValue (int value, Type enumeration) - { - foreach (FieldInfo fi in enumeration.GetFields (BindingFlags.Static | BindingFlags.Public)) - if (value == (int) fi.GetValue (null)) - return GetGuidAttribute (fi).Guid; - - return new Guid (); - } - - static GuidAttribute GetGuidAttribute (FieldInfo fi) - { - GuidAttribute [] attributes = fi.GetCustomAttributes (typeof (GuidAttribute), false) as GuidAttribute []; - if (attributes == null || attributes.Length != 1) - return new GuidAttribute (); - - return attributes [0]; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ICodeVisitable.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ICodeVisitable.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ICodeVisitable.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ICodeVisitable.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// -// ICodeVisitable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - public interface ICodeVisitable { - void Accept (ICodeVisitor visitor); - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ICodeVisitor.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ICodeVisitor.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ICodeVisitor.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ICodeVisitor.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// -// ICodeVisitor.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - public interface ICodeVisitor { - - void VisitMethodBody (MethodBody body); - void VisitInstructionCollection (InstructionCollection instructions); - void VisitInstruction (Instruction instr); - void VisitExceptionHandlerCollection (ExceptionHandlerCollection seh); - void VisitExceptionHandler (ExceptionHandler eh); - void VisitVariableDefinitionCollection (VariableDefinitionCollection variables); - void VisitVariableDefinition (VariableDefinition var); - void VisitScopeCollection (ScopeCollection scopes); - void VisitScope (Scope scope); - - void TerminateMethodBody (MethodBody body); - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ILProcessor.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ILProcessor.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ILProcessor.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ILProcessor.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,278 @@ +// +// ILProcessor.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; + +using Mono.Collections.Generic; + +namespace Mono.Cecil.Cil { + + public sealed class ILProcessor { + + readonly MethodBody body; + readonly Collection instructions; + + public MethodBody Body { + get { return body; } + } + + internal ILProcessor (MethodBody body) + { + this.body = body; + this.instructions = body.Instructions; + } + + public Instruction Create (OpCode opcode) + { + return Instruction.Create (opcode); + } + + public Instruction Create (OpCode opcode, TypeReference type) + { + return Instruction.Create (opcode, type); + } + + public Instruction Create (OpCode opcode, CallSite site) + { + return Instruction.Create (opcode, site); + } + + public Instruction Create (OpCode opcode, MethodReference method) + { + return Instruction.Create (opcode, method); + } + + public Instruction Create (OpCode opcode, FieldReference field) + { + return Instruction.Create (opcode, field); + } + + public Instruction Create (OpCode opcode, string value) + { + return Instruction.Create (opcode, value); + } + + public Instruction Create (OpCode opcode, sbyte value) + { + return Instruction.Create (opcode, value); + } + + public Instruction Create (OpCode opcode, byte value) + { + if (opcode.OperandType == OperandType.ShortInlineVar) + return Instruction.Create (opcode, body.Variables [value]); + + if (opcode.OperandType == OperandType.ShortInlineArg) + return Instruction.Create (opcode, body.GetParameter (value)); + + return Instruction.Create (opcode, value); + } + + public Instruction Create (OpCode opcode, int value) + { + if (opcode.OperandType == OperandType.InlineVar) + return Instruction.Create (opcode, body.Variables [value]); + + if (opcode.OperandType == OperandType.InlineArg) + return Instruction.Create (opcode, body.GetParameter (value)); + + return Instruction.Create (opcode, value); + } + + public Instruction Create (OpCode opcode, long value) + { + return Instruction.Create (opcode, value); + } + + public Instruction Create (OpCode opcode, float value) + { + return Instruction.Create (opcode, value); + } + + public Instruction Create (OpCode opcode, double value) + { + return Instruction.Create (opcode, value); + } + + public Instruction Create (OpCode opcode, Instruction target) + { + return Instruction.Create (opcode, target); + } + + public Instruction Create (OpCode opcode, Instruction [] targets) + { + return Instruction.Create (opcode, targets); + } + + public Instruction Create (OpCode opcode, VariableDefinition variable) + { + return Instruction.Create (opcode, variable); + } + + public Instruction Create (OpCode opcode, ParameterDefinition parameter) + { + return Instruction.Create (opcode, parameter); + } + + public void Emit (OpCode opcode) + { + Append (Create (opcode)); + } + + public void Emit (OpCode opcode, TypeReference type) + { + Append (Create (opcode, type)); + } + + public void Emit (OpCode opcode, MethodReference method) + { + Append (Create (opcode, method)); + } + + public void Emit (OpCode opcode, CallSite site) + { + Append (Create (opcode, site)); + } + + public void Emit (OpCode opcode, FieldReference field) + { + Append (Create (opcode, field)); + } + + public void Emit (OpCode opcode, string value) + { + Append (Create (opcode, value)); + } + + public void Emit (OpCode opcode, byte value) + { + Append (Create (opcode, value)); + } + + public void Emit (OpCode opcode, sbyte value) + { + Append (Create (opcode, value)); + } + + public void Emit (OpCode opcode, int value) + { + Append (Create (opcode, value)); + } + + public void Emit (OpCode opcode, long value) + { + Append (Create (opcode, value)); + } + + public void Emit (OpCode opcode, float value) + { + Append (Create (opcode, value)); + } + + public void Emit (OpCode opcode, double value) + { + Append (Create (opcode, value)); + } + + public void Emit (OpCode opcode, Instruction target) + { + Append (Create (opcode, target)); + } + + public void Emit (OpCode opcode, Instruction [] targets) + { + Append (Create (opcode, targets)); + } + + public void Emit (OpCode opcode, VariableDefinition variable) + { + Append (Create (opcode, variable)); + } + + public void Emit (OpCode opcode, ParameterDefinition parameter) + { + Append (Create (opcode, parameter)); + } + + public void InsertBefore (Instruction target, Instruction instruction) + { + if (target == null) + throw new ArgumentNullException ("target"); + if (instruction == null) + throw new ArgumentNullException ("instruction"); + + var index = instructions.IndexOf (target); + if (index == -1) + throw new ArgumentOutOfRangeException ("target"); + + instructions.Insert (index, instruction); + } + + public void InsertAfter (Instruction target, Instruction instruction) + { + if (target == null) + throw new ArgumentNullException ("target"); + if (instruction == null) + throw new ArgumentNullException ("instruction"); + + var index = instructions.IndexOf (target); + if (index == -1) + throw new ArgumentOutOfRangeException ("target"); + + instructions.Insert (index + 1, instruction); + } + + public void Append (Instruction instruction) + { + if (instruction == null) + throw new ArgumentNullException ("instruction"); + + instructions.Add (instruction); + } + + public void Replace (Instruction target, Instruction instruction) + { + if (target == null) + throw new ArgumentNullException ("target"); + if (instruction == null) + throw new ArgumentNullException ("instruction"); + + InsertAfter (target, instruction); + Remove (target); + } + + public void Remove (Instruction instruction) + { + if (instruction == null) + throw new ArgumentNullException ("instruction"); + + if (!instructions.Remove (instruction)) + throw new ArgumentOutOfRangeException ("instruction"); + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/InstructionCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/InstructionCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/InstructionCollection.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/InstructionCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ -// -// InstructionCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Thu Sep 28 17:54:43 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - using System; - using System.Collections; - - using Mono.Cecil.Cil; - - public sealed class InstructionCollection : CollectionBase, ICodeVisitable { - - MethodBody m_container; - public readonly Instruction Outside = new Instruction (int.MaxValue, OpCodes.Nop); - - public Instruction this [int index] { - get { return List [index] as Instruction; } - set { List [index] = value; } - } - - public MethodBody Container { - get { return m_container; } - } - - public InstructionCollection (MethodBody container) - { - m_container = container; - } - - internal void Add (Instruction value) - { - List.Add (value); - } - - public bool Contains (Instruction value) - { - return List.Contains (value); - } - - public int IndexOf (Instruction value) - { - return List.IndexOf (value); - } - - internal void Insert (int index, Instruction value) - { - List.Insert (index, value); - } - - internal void Remove (Instruction value) - { - List.Remove (value); - } - - protected override void OnValidate (object o) - { - if (! (o is Instruction)) - throw new ArgumentException ("Must be of type " + typeof (Instruction).FullName); - } - - public void Accept (ICodeVisitor visitor) - { - visitor.VisitInstructionCollection (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Instruction.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Instruction.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Instruction.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Instruction.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,80 +26,74 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System; +using System.Text; + namespace Mono.Cecil.Cil { - public sealed class Instruction : ICodeVisitable { + public sealed class Instruction { - int m_offset; - OpCode m_opCode; - object m_operand; + internal int offset; + internal OpCode opcode; + internal object operand; - Instruction m_previous; - Instruction m_next; + internal Instruction previous; + internal Instruction next; - SequencePoint m_sequencePoint; + SequencePoint sequence_point; public int Offset { - get { return m_offset; } - set { m_offset = value; } + get { return offset; } + set { offset = value; } } public OpCode OpCode { - get { return m_opCode; } - set { m_opCode = value; } + get { return opcode; } + set { opcode = value; } } public object Operand { - get { return m_operand; } - set { m_operand = value; } + get { return operand; } + set { operand = value; } } public Instruction Previous { - get { return m_previous; } - set { m_previous = value; } + get { return previous; } + set { previous = value; } } public Instruction Next { - get { return m_next; } - set { m_next = value; } + get { return next; } + set { next = value; } } public SequencePoint SequencePoint { - get { return m_sequencePoint; } - set { m_sequencePoint = value; } - } - - internal Instruction (int offset, OpCode opCode, object operand) : this (offset, opCode) - { - m_operand = operand; + get { return sequence_point; } + set { sequence_point = value; } } internal Instruction (int offset, OpCode opCode) { - m_offset = offset; - m_opCode = opCode; - } - - internal Instruction (OpCode opCode, object operand) : this (0, opCode, operand) - { + this.offset = offset; + this.opcode = opCode; } - internal Instruction (OpCode opCode) : this (0, opCode) + internal Instruction (OpCode opcode, object operand) { + this.opcode = opcode; + this.operand = operand; } public int GetSize () { - int size = m_opCode.Size; + int size = opcode.Size; - switch (m_opCode.OperandType) { + switch (opcode.OperandType) { case OperandType.InlineSwitch: - size += (1 + ((Instruction []) m_operand).Length) * 4; - break; + return size + (1 + ((Instruction []) operand).Length) * 4; case OperandType.InlineI8: case OperandType.InlineR: - size += 8; - break; + return size + 8; case OperandType.InlineBrTarget: case OperandType.InlineField: case OperandType.InlineI: @@ -108,26 +102,220 @@ case OperandType.InlineTok: case OperandType.InlineType: case OperandType.ShortInlineR: - size += 4; - break; - case OperandType.InlineParam: + case OperandType.InlineSig: + return size + 4; + case OperandType.InlineArg: case OperandType.InlineVar: - size += 2; - break; + return size + 2; case OperandType.ShortInlineBrTarget: case OperandType.ShortInlineI: - case OperandType.ShortInlineParam: + case OperandType.ShortInlineArg: case OperandType.ShortInlineVar: - size += 1; + return size + 1; + default: + return size; + } + } + + public override string ToString () + { + var instruction = new StringBuilder (); + + AppendLabel (instruction, this); + instruction.Append (':'); + instruction.Append (' '); + instruction.Append (opcode.Name); + + if (operand == null) + return instruction.ToString (); + + instruction.Append (' '); + + switch (opcode.OperandType) { + case OperandType.ShortInlineBrTarget: + case OperandType.InlineBrTarget: + AppendLabel (instruction, (Instruction) operand); + break; + case OperandType.InlineSwitch: + var labels = (Instruction []) operand; + for (int i = 0; i < labels.Length; i++) { + if (i > 0) + instruction.Append (','); + + AppendLabel (instruction, labels [i]); + } + break; + case OperandType.InlineString: + instruction.Append ('\"'); + instruction.Append (operand); + instruction.Append ('\"'); + break; + default: + instruction.Append (operand); break; } - return size; + return instruction.ToString (); + } + + static void AppendLabel (StringBuilder builder, Instruction instruction) + { + builder.Append ("IL_"); + builder.Append (instruction.offset.ToString ("x4")); + } + + public static Instruction Create (OpCode opcode) + { + if (opcode.OperandType != OperandType.InlineNone) + throw new ArgumentException ("opcode"); + + return new Instruction (opcode, null); + } + + public static Instruction Create (OpCode opcode, TypeReference type) + { + if (type == null) + throw new ArgumentNullException ("type"); + if (opcode.OperandType != OperandType.InlineType && + opcode.OperandType != OperandType.InlineTok) + throw new ArgumentException ("opcode"); + + return new Instruction (opcode, type); + } + + public static Instruction Create (OpCode opcode, CallSite site) + { + if (site == null) + throw new ArgumentNullException ("site"); + if (opcode.Code != Code.Calli) + throw new ArgumentException ("code"); + + return new Instruction (opcode, site); + } + + public static Instruction Create (OpCode opcode, MethodReference method) + { + if (method == null) + throw new ArgumentNullException ("method"); + if (opcode.OperandType != OperandType.InlineMethod && + opcode.OperandType != OperandType.InlineTok) + throw new ArgumentException ("opcode"); + + return new Instruction (opcode, method); } - public void Accept (ICodeVisitor visitor) + public static Instruction Create (OpCode opcode, FieldReference field) { - visitor.VisitInstruction (this); + if (field == null) + throw new ArgumentNullException ("field"); + if (opcode.OperandType != OperandType.InlineField && + opcode.OperandType != OperandType.InlineTok) + throw new ArgumentException ("opcode"); + + return new Instruction (opcode, field); + } + + public static Instruction Create (OpCode opcode, string value) + { + if (value == null) + throw new ArgumentNullException ("value"); + if (opcode.OperandType != OperandType.InlineString) + throw new ArgumentException ("opcode"); + + return new Instruction (opcode, value); + } + + public static Instruction Create (OpCode opcode, sbyte value) + { + if (opcode.OperandType != OperandType.ShortInlineI && + opcode != OpCodes.Ldc_I4_S) + throw new ArgumentException ("opcode"); + + return new Instruction (opcode, value); + } + + public static Instruction Create (OpCode opcode, byte value) + { + if (opcode.OperandType != OperandType.ShortInlineI || + opcode == OpCodes.Ldc_I4_S) + throw new ArgumentException ("opcode"); + + return new Instruction (opcode, value); + } + + public static Instruction Create (OpCode opcode, int value) + { + if (opcode.OperandType != OperandType.InlineI) + throw new ArgumentException ("opcode"); + + return new Instruction (opcode, value); + } + + public static Instruction Create (OpCode opcode, long value) + { + if (opcode.OperandType != OperandType.InlineI8) + throw new ArgumentException ("opcode"); + + return new Instruction (opcode, value); + } + + public static Instruction Create (OpCode opcode, float value) + { + if (opcode.OperandType != OperandType.ShortInlineR) + throw new ArgumentException ("opcode"); + + return new Instruction (opcode, value); + } + + public static Instruction Create (OpCode opcode, double value) + { + if (opcode.OperandType != OperandType.InlineR) + throw new ArgumentException ("opcode"); + + return new Instruction (opcode, value); + } + + public static Instruction Create (OpCode opcode, Instruction target) + { + if (target == null) + throw new ArgumentNullException ("target"); + if (opcode.OperandType != OperandType.InlineBrTarget && + opcode.OperandType != OperandType.ShortInlineBrTarget) + throw new ArgumentException ("opcode"); + + return new Instruction (opcode, target); + } + + public static Instruction Create (OpCode opcode, Instruction [] targets) + { + if (targets == null) + throw new ArgumentNullException ("targets"); + if (opcode.OperandType != OperandType.InlineSwitch) + throw new ArgumentException ("opcode"); + + return new Instruction (opcode, targets); + } + + public static Instruction Create (OpCode opcode, VariableDefinition variable) + { + if (variable == null) + throw new ArgumentNullException ("variable"); + if (opcode.OperandType != OperandType.ShortInlineVar && + opcode.OperandType != OperandType.InlineVar) + throw new ArgumentException ("opcode"); + + return new Instruction (opcode, variable); + } + + public static Instruction Create (OpCode opcode, ParameterDefinition parameter) + { + if (parameter == null) + throw new ArgumentNullException ("parameter"); + if (opcode.OperandType != OperandType.ShortInlineArg && + opcode.OperandType != OperandType.InlineArg) + throw new ArgumentException ("opcode"); + + return new Instruction (opcode, parameter); } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/IScopeProvider.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/IScopeProvider.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/IScopeProvider.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/IScopeProvider.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// -// Document.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2006 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - public interface IScopeProvider { - - ScopeCollection Scopes { get; } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ISymbolReader.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ISymbolReader.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ISymbolReader.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ISymbolReader.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// -// ISymbolReader.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2006 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - using System; - - public interface ISymbolReader : IDisposable { - - void Read (MethodBody body); - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ISymbolStoreFactory.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ISymbolStoreFactory.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ISymbolStoreFactory.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ISymbolStoreFactory.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// -// ISymbolStoreFactory.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2006 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - public interface ISymbolStoreFactory { - - ISymbolReader CreateReader (ModuleDefinition module, string assemblyFileName); - ISymbolWriter CreateWriter (ModuleDefinition module, string assemblyFileName); - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ISymbolWriter.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ISymbolWriter.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ISymbolWriter.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ISymbolWriter.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// -// ISymbolWriter.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2006 - 2007 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - using System; - - public interface ISymbolWriter : IDisposable { - - void Write (MethodBody body, byte [][] variables); - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/IVariableDefinitionProvider.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/IVariableDefinitionProvider.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/IVariableDefinitionProvider.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/IVariableDefinitionProvider.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// -// IVariableDefinitionProvider.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2006 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - public interface IVariableDefinitionProvider { - - VariableDefinitionCollection Variables { get; } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/MethodBody.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/MethodBody.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/MethodBody.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/MethodBody.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,557 +26,205 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil.Cil { +using System; + +using Mono.Collections.Generic; - using Mono.Cecil; +namespace Mono.Cecil.Cil { - public sealed class MethodBody : IVariableDefinitionProvider, IScopeProvider, ICodeVisitable { + public sealed class MethodBody : IVariableDefinitionProvider { - MethodDefinition m_method; - int m_maxStack; - int m_codeSize; - bool m_initLocals; - int m_localVarToken; - - InstructionCollection m_instructions; - ExceptionHandlerCollection m_exceptions; - VariableDefinitionCollection m_variables; - ScopeCollection m_scopes; + readonly internal MethodDefinition method; - private CilWorker m_cilWorker; + internal ParameterDefinition this_parameter; + internal int max_stack_size; + internal int code_size; + internal bool init_locals; + internal MetadataToken local_var_token; + + internal Collection instructions; + internal Collection exceptions; + internal Collection variables; + Scope scope; public MethodDefinition Method { - get { return m_method; } + get { return method; } } - public int MaxStack { - get { return m_maxStack; } - set { m_maxStack = value; } + public int MaxStackSize { + get { return max_stack_size; } + set { max_stack_size = value; } } public int CodeSize { - get { return m_codeSize; } - set { m_codeSize = value; } + get { return code_size; } } public bool InitLocals { - get { return m_initLocals; } - set { m_initLocals = value; } + get { return init_locals; } + set { init_locals = value; } } - internal int LocalVarToken { - get { return m_localVarToken; } - set { m_localVarToken = value; } + public MetadataToken LocalVarToken { + get { return local_var_token; } + set { local_var_token = value; } } - public CilWorker CilWorker { - get { - if (m_cilWorker == null) - m_cilWorker = new CilWorker (this); - return m_cilWorker; - } - set { m_cilWorker = value; } + public Collection Instructions { + get { return instructions ?? (instructions = new InstructionCollection ()); } } - public InstructionCollection Instructions { - get { return m_instructions; } + public bool HasExceptionHandlers { + get { return !exceptions.IsNullOrEmpty (); } } - public ExceptionHandlerCollection ExceptionHandlers { - get { return m_exceptions; } - } - - public VariableDefinitionCollection Variables { - get { return m_variables; } - } - - public ScopeCollection Scopes { - get { return m_scopes; } - } - - public MethodBody (MethodDefinition meth) - { - m_method = meth; - m_instructions = new InstructionCollection (this); - m_exceptions = new ExceptionHandlerCollection (this); - m_variables = new VariableDefinitionCollection (this); - m_scopes = new ScopeCollection (this); - } - - internal static Instruction GetInstruction (MethodBody oldBody, MethodBody newBody, Instruction i) - { - int pos = oldBody.Instructions.IndexOf (i); - if (pos > -1 && pos < newBody.Instructions.Count) - return newBody.Instructions [pos]; - - return newBody.Instructions.Outside; - } - - internal static MethodBody Clone (MethodBody body, MethodDefinition parent, ImportContext context) - { - MethodBody nb = new MethodBody (parent); - nb.MaxStack = body.MaxStack; - nb.InitLocals = body.InitLocals; - nb.CodeSize = body.CodeSize; - - foreach (VariableDefinition var in body.Variables) - nb.Variables.Add (new VariableDefinition ( - context.Import (var.VariableType))); - - foreach (Instruction instr in body.Instructions) { - Instruction ni = new Instruction (instr.OpCode); - - switch (instr.OpCode.OperandType) { - case OperandType.InlineParam : - case OperandType.ShortInlineParam : - if (instr.Operand == body.Method.This) - ni.Operand = nb.Method.This; - else { - int param = body.Method.Parameters.IndexOf ((ParameterDefinition) instr.Operand); - ni.Operand = parent.Parameters [param]; - } - break; - case OperandType.InlineVar : - case OperandType.ShortInlineVar : - int var = body.Variables.IndexOf ((VariableDefinition) instr.Operand); - ni.Operand = nb.Variables [var]; - break; - case OperandType.InlineField : - ni.Operand = context.Import ((FieldReference) instr.Operand); - break; - case OperandType.InlineMethod : - ni.Operand = context.Import ((MethodReference) instr.Operand); - break; - case OperandType.InlineType : - ni.Operand = context.Import ((TypeReference) instr.Operand); - break; - case OperandType.InlineTok : - if (instr.Operand is TypeReference) - ni.Operand = context.Import ((TypeReference) instr.Operand); - else if (instr.Operand is FieldReference) - ni.Operand = context.Import ((FieldReference) instr.Operand); - else if (instr.Operand is MethodReference) - ni.Operand = context.Import ((MethodReference) instr.Operand); - break; - case OperandType.ShortInlineBrTarget : - case OperandType.InlineBrTarget : - break; - default : - ni.Operand = instr.Operand; - break; - } + public Collection ExceptionHandlers { + get { return exceptions ?? (exceptions = new Collection ()); } + } - nb.Instructions.Add (ni); - } + public bool HasVariables { + get { return !variables.IsNullOrEmpty (); } + } - for (int i = 0; i < body.Instructions.Count; i++) { - Instruction instr = nb.Instructions [i]; - if (instr.OpCode.OperandType != OperandType.ShortInlineBrTarget && - instr.OpCode.OperandType != OperandType.InlineBrTarget) - continue; + public Collection Variables { + get { return variables ?? (variables = new VariableDefinitionCollection ()); } + } - instr.Operand = GetInstruction (body, nb, (Instruction) body.Instructions [i].Operand); - } + public Scope Scope { + get { return scope; } + set { scope = value; } + } - foreach (ExceptionHandler eh in body.ExceptionHandlers) { - ExceptionHandler neh = new ExceptionHandler (eh.Type); - neh.TryStart = GetInstruction (body, nb, eh.TryStart); - neh.TryEnd = GetInstruction (body, nb, eh.TryEnd); - neh.HandlerStart = GetInstruction (body, nb, eh.HandlerStart); - neh.HandlerEnd = GetInstruction (body, nb, eh.HandlerEnd); - - switch (eh.Type) { - case ExceptionHandlerType.Catch : - neh.CatchType = context.Import (eh.CatchType); - break; - case ExceptionHandlerType.Filter : - neh.FilterStart = GetInstruction (body, nb, eh.FilterStart); - neh.FilterEnd = GetInstruction (body, nb, eh.FilterEnd); - break; - } + public ParameterDefinition ThisParameter { + get { + if (method == null || method.DeclaringType == null) + throw new NotSupportedException (); - nb.ExceptionHandlers.Add (neh); + return this_parameter ?? (this_parameter = new ParameterDefinition ("0", ParameterAttributes.None, method.DeclaringType)); } + } - return nb; + public MethodBody (MethodDefinition method) + { + this.method = method; } - public void Modify () + public ILProcessor GetILProcessor () { - foreach (Instruction i in this.Instructions) { - if (i.OpCode.OpCodeType != OpCodeType.Macro) - continue; - - switch (i.OpCode.Code) { - case Code.Ldarg_0 : - Modify (i, OpCodes.Ldarg, - CodeReader.GetParameter (this, 0)); - break; - case Code.Ldarg_1 : - Modify (i, OpCodes.Ldarg, - CodeReader.GetParameter (this, 1)); - break; - case Code.Ldarg_2 : - Modify (i, OpCodes.Ldarg, - CodeReader.GetParameter (this, 2)); - break; - case Code.Ldarg_3 : - Modify (i, OpCodes.Ldarg, - CodeReader.GetParameter (this, 3)); - break; - case Code.Ldloc_0 : - Modify (i, OpCodes.Ldloc, - CodeReader.GetVariable (this, 0)); - break; - case Code.Ldloc_1 : - Modify (i, OpCodes.Ldloc, - CodeReader.GetVariable (this, 1)); - break; - case Code.Ldloc_2 : - Modify (i, OpCodes.Ldloc, - CodeReader.GetVariable (this, 2)); - break; - case Code.Ldloc_3 : - Modify (i, OpCodes.Ldloc, - CodeReader.GetVariable (this, 3)); - break; - case Code.Stloc_0 : - Modify (i, OpCodes.Stloc, - CodeReader.GetVariable (this, 0)); - break; - case Code.Stloc_1 : - Modify (i, OpCodes.Stloc, - CodeReader.GetVariable (this, 1)); - break; - case Code.Stloc_2 : - Modify (i, OpCodes.Stloc, - CodeReader.GetVariable (this, 2)); - break; - case Code.Stloc_3 : - Modify (i, OpCodes.Stloc, - CodeReader.GetVariable (this, 3)); - break; - case Code.Ldarg_S : - i.OpCode = OpCodes.Ldarg; - break; - case Code.Ldarga_S : - i.OpCode = OpCodes.Ldarga; - break; - case Code.Starg_S : - i.OpCode = OpCodes.Starg; - break; - case Code.Ldloc_S : - i.OpCode = OpCodes.Ldloc; - break; - case Code.Ldloca_S : - i.OpCode = OpCodes.Ldloca; - break; - case Code.Stloc_S : - i.OpCode = OpCodes.Stloc; - break; - case Code.Ldc_I4_M1 : - Modify (i, OpCodes.Ldc_I4, -1); - break; - case Code.Ldc_I4_0 : - Modify (i, OpCodes.Ldc_I4, 0); - break; - case Code.Ldc_I4_1 : - Modify (i, OpCodes.Ldc_I4, 1); - break; - case Code.Ldc_I4_2 : - Modify (i, OpCodes.Ldc_I4, 2); - break; - case Code.Ldc_I4_3 : - Modify (i, OpCodes.Ldc_I4, 3); - break; - case Code.Ldc_I4_4 : - Modify (i, OpCodes.Ldc_I4, 4); - break; - case Code.Ldc_I4_5 : - Modify (i, OpCodes.Ldc_I4, 5); - break; - case Code.Ldc_I4_6 : - Modify (i, OpCodes.Ldc_I4, 6); - break; - case Code.Ldc_I4_7 : - Modify (i, OpCodes.Ldc_I4, 7); - break; - case Code.Ldc_I4_8 : - Modify (i, OpCodes.Ldc_I4, 8); - break; - case Code.Ldc_I4_S : - i.OpCode = OpCodes.Ldc_I4; - i.Operand = (int) (sbyte) i.Operand; - break; - case Code.Br_S : - i.OpCode = OpCodes.Br; - break; - case Code.Brfalse_S : - i.OpCode = OpCodes.Brfalse; - break; - case Code.Brtrue_S : - i.OpCode = OpCodes.Brtrue; - break; - case Code.Beq_S : - i.OpCode = OpCodes.Beq; - break; - case Code.Bge_S : - i.OpCode = OpCodes.Bge; - break; - case Code.Bgt_S : - i.OpCode = OpCodes.Bgt; - break; - case Code.Ble_S : - i.OpCode = OpCodes.Ble; - break; - case Code.Blt_S : - i.OpCode = OpCodes.Blt; - break; - case Code.Bne_Un_S : - i.OpCode = OpCodes.Bne_Un; - break; - case Code.Bge_Un_S : - i.OpCode = OpCodes.Bge_Un; - break; - case Code.Bgt_Un_S : - i.OpCode = OpCodes.Bgt_Un; - break; - case Code.Ble_Un_S : - i.OpCode = OpCodes.Ble_Un; - break; - case Code.Blt_Un_S : - i.OpCode = OpCodes.Blt_Un; - break; - case Code.Leave_S : - i.OpCode = OpCodes.Leave; - break; - } - } + return new ILProcessor (this); } + } + + public interface IVariableDefinitionProvider { + bool HasVariables { get; } + Collection Variables { get; } + } - public void Optimize () + class VariableDefinitionCollection : Collection { + + internal VariableDefinitionCollection () { - foreach (Instruction instr in m_instructions) { - int index; - switch (instr.OpCode.Code) { - case Code.Ldarg: - index = m_method.Parameters.IndexOf ((ParameterDefinition) instr.Operand); - if (index == -1 && instr.Operand == m_method.This) - index = 0; - else if (m_method.HasThis) - index++; - - switch (index) { - case 0: - Modify (instr, OpCodes.Ldarg_0, null); - break; - case 1: - Modify (instr, OpCodes.Ldarg_1, null); - break; - case 2: - Modify (instr, OpCodes.Ldarg_2, null); - break; - case 3: - Modify (instr, OpCodes.Ldarg_3, null); - break; - default: - if (index < 256) - Modify (instr, OpCodes.Ldarg_S, instr.Operand); - break; - } - break; - case Code.Ldloc: - index = m_variables.IndexOf ((VariableDefinition) instr.Operand); - switch (index) { - case 0: - Modify (instr, OpCodes.Ldloc_0, null); - break; - case 1: - Modify (instr, OpCodes.Ldloc_1, null); - break; - case 2: - Modify (instr, OpCodes.Ldloc_2, null); - break; - case 3: - Modify (instr, OpCodes.Ldloc_3, null); - break; - default: - if (index < 256) - Modify (instr, OpCodes.Ldloc_S, instr.Operand); - break; - } - break; - case Code.Stloc: - index = m_variables.IndexOf ((VariableDefinition) instr.Operand); - switch (index) { - case 0: - Modify (instr, OpCodes.Stloc_0, null); - break; - case 1: - Modify (instr, OpCodes.Stloc_1, null); - break; - case 2: - Modify (instr, OpCodes.Stloc_2, null); - break; - case 3: - Modify (instr, OpCodes.Stloc_3, null); - break; - default: - if (index < 256) - Modify (instr, OpCodes.Stloc_S, instr.Operand); - break; - } - break; - case Code.Ldarga: - index = m_method.Parameters.IndexOf ((ParameterDefinition) instr.Operand); - if (index == -1 && instr.Operand == m_method.This) - index = 0; - else if (m_method.HasThis) - index++; - if (index < 256) - Modify (instr, OpCodes.Ldarga_S, instr.Operand); - break; - case Code.Ldloca: - if (m_variables.IndexOf ((VariableDefinition) instr.Operand) < 256) - Modify (instr, OpCodes.Ldloca_S, instr.Operand); - break; - case Code.Ldc_I4: - int i = (int) instr.Operand; - switch (i) { - case -1: - Modify (instr, OpCodes.Ldc_I4_M1, null); - break; - case 0: - Modify (instr, OpCodes.Ldc_I4_0, null); - break; - case 1: - Modify (instr, OpCodes.Ldc_I4_1, null); - break; - case 2: - Modify (instr, OpCodes.Ldc_I4_2, null); - break; - case 3: - Modify (instr, OpCodes.Ldc_I4_3, null); - break; - case 4: - Modify (instr, OpCodes.Ldc_I4_4, null); - break; - case 5: - Modify (instr, OpCodes.Ldc_I4_5, null); - break; - case 6: - Modify (instr, OpCodes.Ldc_I4_6, null); - break; - case 7: - Modify (instr, OpCodes.Ldc_I4_7, null); - break; - case 8: - Modify (instr, OpCodes.Ldc_I4_8, null); - break; - default: - if (i >= -128 || i < 128) - Modify (instr, OpCodes.Ldc_I4_S, (sbyte) i); - break; - } - break; - } - } + } - OptimizeBranches (); + internal VariableDefinitionCollection (int capacity) + : base (capacity) + { } - void OptimizeBranches () + protected override void OnAdd (VariableDefinition item, int index) { - ComputeOffsets (); + item.index = index; + } - foreach (Instruction instr in m_instructions) { - if (instr.OpCode.OperandType != OperandType.InlineBrTarget) - continue; + protected override void OnInsert (VariableDefinition item, int index) + { + item.index = index; - if (OptimizeBranch (instr)) - ComputeOffsets (); - } + for (int i = index; i < size; i++) + items [i].index = i + 1; } - static bool OptimizeBranch (Instruction instr) + protected override void OnSet (VariableDefinition item, int index) { - int offset = ((Instruction) instr.Operand).Offset - (instr.Offset + instr.OpCode.Size + 4); - if (! (offset >= -128 && offset <= 127)) - return false; - - switch (instr.OpCode.Code) { - case Code.Br: - instr.OpCode = OpCodes.Br_S; - break; - case Code.Brfalse: - instr.OpCode = OpCodes.Brfalse_S; - break; - case Code.Brtrue: - instr.OpCode = OpCodes.Brtrue_S; - break; - case Code.Beq: - instr.OpCode = OpCodes.Beq_S; - break; - case Code.Bge: - instr.OpCode = OpCodes.Bge_S; - break; - case Code.Bgt: - instr.OpCode = OpCodes.Bgt_S; - break; - case Code.Ble: - instr.OpCode = OpCodes.Ble_S; - break; - case Code.Blt: - instr.OpCode = OpCodes.Blt_S; - break; - case Code.Bne_Un: - instr.OpCode = OpCodes.Bne_Un_S; - break; - case Code.Bge_Un: - instr.OpCode = OpCodes.Bge_Un_S; - break; - case Code.Bgt_Un: - instr.OpCode = OpCodes.Bgt_Un_S; - break; - case Code.Ble_Un: - instr.OpCode = OpCodes.Ble_Un_S; - break; - case Code.Blt_Un: - instr.OpCode = OpCodes.Blt_Un_S; - break; - case Code.Leave: - instr.OpCode = OpCodes.Leave_S; - break; - } + item.index = index; + } + + protected override void OnRemove (VariableDefinition item, int index) + { + item.index = -1; + + for (int i = index + 1; i < size; i++) + items [i].index = i - 1; + } + } + + class InstructionCollection : Collection { - return true; + internal InstructionCollection () + { } - void ComputeOffsets () + internal InstructionCollection (int capacity) + : base (capacity) { - int offset = 0; + } - foreach (Instruction instr in m_instructions) { - instr.Offset = offset; - offset += instr.GetSize (); + protected override void OnAdd (Instruction item, int index) + { + if (index == 0) + return; + + var previous = items [index - 1]; + previous.next = item; + item.previous = previous; + } + + protected override void OnInsert (Instruction item, int index) + { + if (size == 0) + return; + + var current = items [index]; + if (current == null) { + var last = items [index - 1]; + last.next = item; + item.previous = last; + return; } + + var previous = current.previous; + if (previous != null) { + previous.next = item; + item.previous = previous; + } + + current.previous = item; + item.next = current; } - static void Modify (Instruction i, OpCode op, object operand) + protected override void OnSet (Instruction item, int index) { - i.OpCode = op; - i.Operand = operand; + var current = items [index]; + + item.previous = current.previous; + item.next = current.next; + + current.previous = null; + current.next = null; } - public void Accept (ICodeVisitor visitor) + protected override void OnRemove (Instruction item, int index) { - visitor.VisitMethodBody (this); - m_variables.Accept (visitor); - m_instructions.Accept (visitor); - m_exceptions.Accept (visitor); - m_scopes.Accept (visitor); + var previous = item.previous; + if (previous != null) + previous.next = item.next; + + var next = item.next; + if (next != null) + next.previous = item.previous; - visitor.TerminateMethodBody (this); + item.previous = null; + item.next = null; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/MethodDataSection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/MethodDataSection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/MethodDataSection.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/MethodDataSection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// -// MethodDataSection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - internal enum MethodDataSection : ushort { - EHTable = 0x1, - OptILTable = 0x2, - FatFormat = 0x40, - MoreSects = 0x80 - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/MethodHeader.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/MethodHeader.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/MethodHeader.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/MethodHeader.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// -// MethodHeader.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - internal enum MethodHeader : ushort { - TinyFormat = 0x2, - FatFormat = 0x3, - MoreSects = 0x8, - InitLocals = 0x10 - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OpCode.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OpCode.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OpCode.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OpCode.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -28,79 +28,148 @@ namespace Mono.Cecil.Cil { + public enum FlowControl { + Branch, + Break, + Call, + Cond_Branch, + Meta, + Next, + Phi, + Return, + Throw, + } + + public enum OpCodeType { + Annotation, + Macro, + Nternal, + Objmodel, + Prefix, + Primitive, + } + + public enum OperandType { + InlineBrTarget, + InlineField, + InlineI, + InlineI8, + InlineMethod, + InlineNone, + InlinePhi, + InlineR, + InlineSig, + InlineString, + InlineSwitch, + InlineTok, + InlineType, + InlineVar, + InlineArg, + ShortInlineBrTarget, + ShortInlineI, + ShortInlineR, + ShortInlineVar, + ShortInlineArg, + } + + public enum StackBehaviour { + Pop0, + Pop1, + Pop1_pop1, + Popi, + Popi_pop1, + Popi_popi, + Popi_popi8, + Popi_popi_popi, + Popi_popr4, + Popi_popr8, + Popref, + Popref_pop1, + Popref_popi, + Popref_popi_popi, + Popref_popi_popi8, + Popref_popi_popr4, + Popref_popi_popr8, + Popref_popi_popref, + PopAll, + Push0, + Push1, + Push1_push1, + Pushi, + Pushi8, + Pushr4, + Pushr8, + Pushref, + Varpop, + Varpush, + } + public struct OpCode { - string m_name; - byte m_op1; - byte m_op2; - int m_size; - - Code m_code; - FlowControl m_flowControl; - OpCodeType m_opCodeType; - OperandType m_operandType; - StackBehaviour m_stackBehaviourPop; - StackBehaviour m_stackBehaviourPush; + readonly byte op1; + readonly byte op2; + readonly byte code; + readonly byte flow_control; + readonly byte opcode_type; + readonly byte operand_type; + readonly byte stack_behavior_pop; + readonly byte stack_behavior_push; public string Name { - get { return m_name; } + get { return OpCodeNames.names [op1 == 0xff ? op2 : op2 + 256]; } } public int Size { - get { return m_size; } + get { return op1 == 0xff ? 1 : 2; } } public byte Op1 { - get { return m_op1; } + get { return op1; } } public byte Op2 { - get { return m_op2; } + get { return op2; } } public short Value { - get { return m_size == 1 ? m_op2 : (short) ((m_op1 << 8) | m_op2); } + get { return (short) ((op1 << 8) | op2); } } public Code Code { - get { return m_code; } + get { return (Code) code; } } public FlowControl FlowControl { - get { return m_flowControl; } + get { return (FlowControl) flow_control; } } public OpCodeType OpCodeType { - get { return m_opCodeType; } + get { return (OpCodeType) opcode_type; } } public OperandType OperandType { - get { return m_operandType; } + get { return (OperandType) operand_type; } } public StackBehaviour StackBehaviourPop { - get { return m_stackBehaviourPop; } + get { return (StackBehaviour) stack_behavior_pop; } } public StackBehaviour StackBehaviourPush { - get { return m_stackBehaviourPush; } + get { return (StackBehaviour) stack_behavior_push; } } - internal OpCode (string name, byte op1, byte op2, int size, - Code code, FlowControl flowControl, - OpCodeType opCodeType, OperandType operandType, - StackBehaviour pop, StackBehaviour push) - { - m_name = name; - m_op1 = op1; - m_op2 = op2; - m_size = size; - m_code = code; - m_flowControl = flowControl; - m_opCodeType = opCodeType; - m_operandType = operandType; - m_stackBehaviourPop = pop; - m_stackBehaviourPush = push; + internal OpCode (int x, int y) + { + this.op1 = (byte) ((x >> 0) & 0xff); + this.op2 = (byte) ((x >> 8) & 0xff); + this.code = (byte) ((x >> 16) & 0xff); + this.flow_control = (byte) ((x >> 24) & 0xff); + + this.opcode_type = (byte) ((y >> 0) & 0xff); + this.operand_type = (byte) ((y >> 8) & 0xff); + this.stack_behavior_pop = (byte) ((y >> 16) & 0xff); + this.stack_behavior_push = (byte) ((y >> 24) & 0xff); if (op1 == 0xff) OpCodes.OneByteOpCode [op2] = this; @@ -110,30 +179,346 @@ public override int GetHashCode () { - return this.Value; + return Value; } public override bool Equals (object obj) { if (!(obj is OpCode)) return false; - OpCode v = (OpCode) obj; - return v.m_op1 == m_op1 && v.m_op2 == m_op2; + + var opcode = (OpCode) obj; + return op1 == opcode.op1 && op2 == opcode.op2; + } + + public bool Equals (OpCode opcode) + { + return op1 == opcode.op1 && op2 == opcode.op2; } public static bool operator == (OpCode one, OpCode other) { - return one.Equals (other); + return one.op1 == other.op1 && one.op2 == other.op2; } public static bool operator != (OpCode one, OpCode other) { - return !one.Equals (other); + return one.op1 != other.op1 || one.op2 != other.op2; } public override string ToString () { - return m_name; + return Name; } } + + static class OpCodeNames { + + internal static readonly string [] names = { + "nop", + "break", + "ldarg.0", + "ldarg.1", + "ldarg.2", + "ldarg.3", + "ldloc.0", + "ldloc.1", + "ldloc.2", + "ldloc.3", + "stloc.0", + "stloc.1", + "stloc.2", + "stloc.3", + "ldarg.s", + "ldarga.s", + "starg.s", + "ldloc.s", + "ldloca.s", + "stloc.s", + "ldnull", + "ldc.i4.m1", + "ldc.i4.0", + "ldc.i4.1", + "ldc.i4.2", + "ldc.i4.3", + "ldc.i4.4", + "ldc.i4.5", + "ldc.i4.6", + "ldc.i4.7", + "ldc.i4.8", + "ldc.i4.s", + "ldc.i4", + "ldc.i8", + "ldc.r4", + "ldc.r8", + null, + "dup", + "pop", + "jmp", + "call", + "calli", + "ret", + "br.s", + "brfalse.s", + "brtrue.s", + "beq.s", + "bge.s", + "bgt.s", + "ble.s", + "blt.s", + "bne.un.s", + "bge.un.s", + "bgt.un.s", + "ble.un.s", + "blt.un.s", + "br", + "brfalse", + "brtrue", + "beq", + "bge", + "bgt", + "ble", + "blt", + "bne.un", + "bge.un", + "bgt.un", + "ble.un", + "blt.un", + "switch", + "ldind.i1", + "ldind.u1", + "ldind.i2", + "ldind.u2", + "ldind.i4", + "ldind.u4", + "ldind.i8", + "ldind.i", + "ldind.r4", + "ldind.r8", + "ldind.ref", + "stind.ref", + "stind.i1", + "stind.i2", + "stind.i4", + "stind.i8", + "stind.r4", + "stind.r8", + "add", + "sub", + "mul", + "div", + "div.un", + "rem", + "rem.un", + "and", + "or", + "xor", + "shl", + "shr", + "shr.un", + "neg", + "not", + "conv.i1", + "conv.i2", + "conv.i4", + "conv.i8", + "conv.r4", + "conv.r8", + "conv.u4", + "conv.u8", + "callvirt", + "cpobj", + "ldobj", + "ldstr", + "newobj", + "castclass", + "isinst", + "conv.r.un", + null, + null, + "unbox", + "throw", + "ldfld", + "ldflda", + "stfld", + "ldsfld", + "ldsflda", + "stsfld", + "stobj", + "conv.ovf.i1.un", + "conv.ovf.i2.un", + "conv.ovf.i4.un", + "conv.ovf.i8.un", + "conv.ovf.u1.un", + "conv.ovf.u2.un", + "conv.ovf.u4.un", + "conv.ovf.u8.un", + "conv.ovf.i.un", + "conv.ovf.u.un", + "box", + "newarr", + "ldlen", + "ldelema", + "ldelem.i1", + "ldelem.u1", + "ldelem.i2", + "ldelem.u2", + "ldelem.i4", + "ldelem.u4", + "ldelem.i8", + "ldelem.i", + "ldelem.r4", + "ldelem.r8", + "ldelem.ref", + "stelem.i", + "stelem.i1", + "stelem.i2", + "stelem.i4", + "stelem.i8", + "stelem.r4", + "stelem.r8", + "stelem.ref", + "ldelem.any", + "stelem.any", + "unbox.any", + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + "conv.ovf.i1", + "conv.ovf.u1", + "conv.ovf.i2", + "conv.ovf.u2", + "conv.ovf.i4", + "conv.ovf.u4", + "conv.ovf.i8", + "conv.ovf.u8", + null, + null, + null, + null, + null, + null, + null, + "refanyval", + "ckfinite", + null, + null, + "mkrefany", + null, + null, + null, + null, + null, + null, + null, + null, + null, + "ldtoken", + "conv.u2", + "conv.u1", + "conv.i", + "conv.ovf.i", + "conv.ovf.u", + "add.ovf", + "add.ovf.un", + "mul.ovf", + "mul.ovf.un", + "sub.ovf", + "sub.ovf.un", + "endfinally", + "leave", + "leave.s", + "stind.i", + "conv.u", + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + "prefix7", + "prefix6", + "prefix5", + "prefix4", + "prefix3", + "prefix2", + "prefix1", + "prefixref", + "arglist", + "ceq", + "cgt", + "cgt.un", + "clt", + "clt.un", + "ldftn", + "ldvirtftn", + null, + "ldarg", + "ldarga", + "starg", + "ldloc", + "ldloca", + "stloc", + "localloc", + null, + "endfilter", + "unaligned.", + "volatile.", + "tail.", + "initobj", + "constrained.", + "cpblk", + "initblk", + "no.", // added by spouliot to match Cecil existing definitions + "rethrow", + null, + "sizeof", + "refanytype", + "readonly.", // added by spouliot to match Cecil existing definitions + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + }; + } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OpCodes.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OpCodes.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OpCodes.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OpCodes.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,10 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// Generated by /CodeGen/cecil-gen.rb do not edit -// Sat Aug 18 08:11:28 +0200 2007 -// -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -31,1553 +28,885 @@ namespace Mono.Cecil.Cil { - public sealed class OpCodes { + public static class OpCodes { internal static readonly OpCode [] OneByteOpCode = new OpCode [0xe0 + 1]; internal static readonly OpCode [] TwoBytesOpCode = new OpCode [0x1e + 1]; public static readonly OpCode Nop = new OpCode ( - "nop", 0xff, 0x00, 1, - Code.Nop, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Push0); + 0xff << 0 | 0x00 << 8 | (byte) Code.Nop << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Break = new OpCode ( - "break", 0xff, 0x01, 1, - Code.Break, FlowControl.Break, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Push0); + 0xff << 0 | 0x01 << 8 | (byte) Code.Break << 16 | (byte) FlowControl.Break << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Ldarg_0 = new OpCode ( - "ldarg.0", 0xff, 0x02, 1, - Code.Ldarg_0, FlowControl.Next, - OpCodeType.Macro, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Push1); + 0xff << 0 | 0x02 << 8 | (byte) Code.Ldarg_0 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Ldarg_1 = new OpCode ( - "ldarg.1", 0xff, 0x03, 1, - Code.Ldarg_1, FlowControl.Next, - OpCodeType.Macro, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Push1); + 0xff << 0 | 0x03 << 8 | (byte) Code.Ldarg_1 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Ldarg_2 = new OpCode ( - "ldarg.2", 0xff, 0x04, 1, - Code.Ldarg_2, FlowControl.Next, - OpCodeType.Macro, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Push1); + 0xff << 0 | 0x04 << 8 | (byte) Code.Ldarg_2 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Ldarg_3 = new OpCode ( - "ldarg.3", 0xff, 0x05, 1, - Code.Ldarg_3, FlowControl.Next, - OpCodeType.Macro, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Push1); + 0xff << 0 | 0x05 << 8 | (byte) Code.Ldarg_3 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Ldloc_0 = new OpCode ( - "ldloc.0", 0xff, 0x06, 1, - Code.Ldloc_0, FlowControl.Next, - OpCodeType.Macro, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Push1); + 0xff << 0 | 0x06 << 8 | (byte) Code.Ldloc_0 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Ldloc_1 = new OpCode ( - "ldloc.1", 0xff, 0x07, 1, - Code.Ldloc_1, FlowControl.Next, - OpCodeType.Macro, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Push1); + 0xff << 0 | 0x07 << 8 | (byte) Code.Ldloc_1 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Ldloc_2 = new OpCode ( - "ldloc.2", 0xff, 0x08, 1, - Code.Ldloc_2, FlowControl.Next, - OpCodeType.Macro, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Push1); + 0xff << 0 | 0x08 << 8 | (byte) Code.Ldloc_2 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Ldloc_3 = new OpCode ( - "ldloc.3", 0xff, 0x09, 1, - Code.Ldloc_3, FlowControl.Next, - OpCodeType.Macro, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Push1); + 0xff << 0 | 0x09 << 8 | (byte) Code.Ldloc_3 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Stloc_0 = new OpCode ( - "stloc.0", 0xff, 0x0a, 1, - Code.Stloc_0, FlowControl.Next, - OpCodeType.Macro, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Push0); + 0xff << 0 | 0x0a << 8 | (byte) Code.Stloc_0 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Stloc_1 = new OpCode ( - "stloc.1", 0xff, 0x0b, 1, - Code.Stloc_1, FlowControl.Next, - OpCodeType.Macro, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Push0); + 0xff << 0 | 0x0b << 8 | (byte) Code.Stloc_1 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Stloc_2 = new OpCode ( - "stloc.2", 0xff, 0x0c, 1, - Code.Stloc_2, FlowControl.Next, - OpCodeType.Macro, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Push0); + 0xff << 0 | 0x0c << 8 | (byte) Code.Stloc_2 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Stloc_3 = new OpCode ( - "stloc.3", 0xff, 0x0d, 1, - Code.Stloc_3, FlowControl.Next, - OpCodeType.Macro, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Push0); + 0xff << 0 | 0x0d << 8 | (byte) Code.Stloc_3 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Ldarg_S = new OpCode ( - "ldarg.s", 0xff, 0x0e, 1, - Code.Ldarg_S, FlowControl.Next, - OpCodeType.Macro, OperandType.ShortInlineParam, - StackBehaviour.Pop0, StackBehaviour.Push1); + 0xff << 0 | 0x0e << 8 | (byte) Code.Ldarg_S << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineArg << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Ldarga_S = new OpCode ( - "ldarga.s", 0xff, 0x0f, 1, - Code.Ldarga_S, FlowControl.Next, - OpCodeType.Macro, OperandType.ShortInlineParam, - StackBehaviour.Pop0, StackBehaviour.Pushi); + 0xff << 0 | 0x0f << 8 | (byte) Code.Ldarga_S << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineArg << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Starg_S = new OpCode ( - "starg.s", 0xff, 0x10, 1, - Code.Starg_S, FlowControl.Next, - OpCodeType.Macro, OperandType.ShortInlineParam, - StackBehaviour.Pop1, StackBehaviour.Push0); + 0xff << 0 | 0x10 << 8 | (byte) Code.Starg_S << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineArg << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Ldloc_S = new OpCode ( - "ldloc.s", 0xff, 0x11, 1, - Code.Ldloc_S, FlowControl.Next, - OpCodeType.Macro, OperandType.ShortInlineVar, - StackBehaviour.Pop0, StackBehaviour.Push1); + 0xff << 0 | 0x11 << 8 | (byte) Code.Ldloc_S << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineVar << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Ldloca_S = new OpCode ( - "ldloca.s", 0xff, 0x12, 1, - Code.Ldloca_S, FlowControl.Next, - OpCodeType.Macro, OperandType.ShortInlineVar, - StackBehaviour.Pop0, StackBehaviour.Pushi); + 0xff << 0 | 0x12 << 8 | (byte) Code.Ldloca_S << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineVar << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Stloc_S = new OpCode ( - "stloc.s", 0xff, 0x13, 1, - Code.Stloc_S, FlowControl.Next, - OpCodeType.Macro, OperandType.ShortInlineVar, - StackBehaviour.Pop1, StackBehaviour.Push0); + 0xff << 0 | 0x13 << 8 | (byte) Code.Stloc_S << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineVar << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Ldnull = new OpCode ( - "ldnull", 0xff, 0x14, 1, - Code.Ldnull, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Pushref); + 0xff << 0 | 0x14 << 8 | (byte) Code.Ldnull << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushref << 24); public static readonly OpCode Ldc_I4_M1 = new OpCode ( - "ldc.i4.m1", 0xff, 0x15, 1, - Code.Ldc_I4_M1, FlowControl.Next, - OpCodeType.Macro, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Pushi); + 0xff << 0 | 0x15 << 8 | (byte) Code.Ldc_I4_M1 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldc_I4_0 = new OpCode ( - "ldc.i4.0", 0xff, 0x16, 1, - Code.Ldc_I4_0, FlowControl.Next, - OpCodeType.Macro, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Pushi); + 0xff << 0 | 0x16 << 8 | (byte) Code.Ldc_I4_0 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldc_I4_1 = new OpCode ( - "ldc.i4.1", 0xff, 0x17, 1, - Code.Ldc_I4_1, FlowControl.Next, - OpCodeType.Macro, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Pushi); + 0xff << 0 | 0x17 << 8 | (byte) Code.Ldc_I4_1 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldc_I4_2 = new OpCode ( - "ldc.i4.2", 0xff, 0x18, 1, - Code.Ldc_I4_2, FlowControl.Next, - OpCodeType.Macro, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Pushi); + 0xff << 0 | 0x18 << 8 | (byte) Code.Ldc_I4_2 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldc_I4_3 = new OpCode ( - "ldc.i4.3", 0xff, 0x19, 1, - Code.Ldc_I4_3, FlowControl.Next, - OpCodeType.Macro, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Pushi); + 0xff << 0 | 0x19 << 8 | (byte) Code.Ldc_I4_3 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldc_I4_4 = new OpCode ( - "ldc.i4.4", 0xff, 0x1a, 1, - Code.Ldc_I4_4, FlowControl.Next, - OpCodeType.Macro, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Pushi); + 0xff << 0 | 0x1a << 8 | (byte) Code.Ldc_I4_4 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldc_I4_5 = new OpCode ( - "ldc.i4.5", 0xff, 0x1b, 1, - Code.Ldc_I4_5, FlowControl.Next, - OpCodeType.Macro, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Pushi); + 0xff << 0 | 0x1b << 8 | (byte) Code.Ldc_I4_5 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldc_I4_6 = new OpCode ( - "ldc.i4.6", 0xff, 0x1c, 1, - Code.Ldc_I4_6, FlowControl.Next, - OpCodeType.Macro, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Pushi); + 0xff << 0 | 0x1c << 8 | (byte) Code.Ldc_I4_6 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldc_I4_7 = new OpCode ( - "ldc.i4.7", 0xff, 0x1d, 1, - Code.Ldc_I4_7, FlowControl.Next, - OpCodeType.Macro, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Pushi); + 0xff << 0 | 0x1d << 8 | (byte) Code.Ldc_I4_7 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldc_I4_8 = new OpCode ( - "ldc.i4.8", 0xff, 0x1e, 1, - Code.Ldc_I4_8, FlowControl.Next, - OpCodeType.Macro, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Pushi); + 0xff << 0 | 0x1e << 8 | (byte) Code.Ldc_I4_8 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldc_I4_S = new OpCode ( - "ldc.i4.s", 0xff, 0x1f, 1, - Code.Ldc_I4_S, FlowControl.Next, - OpCodeType.Macro, OperandType.ShortInlineI, - StackBehaviour.Pop0, StackBehaviour.Pushi); + 0xff << 0 | 0x1f << 8 | (byte) Code.Ldc_I4_S << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineI << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldc_I4 = new OpCode ( - "ldc.i4", 0xff, 0x20, 1, - Code.Ldc_I4, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineI, - StackBehaviour.Pop0, StackBehaviour.Pushi); + 0xff << 0 | 0x20 << 8 | (byte) Code.Ldc_I4 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineI << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldc_I8 = new OpCode ( - "ldc.i8", 0xff, 0x21, 1, - Code.Ldc_I8, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineI8, - StackBehaviour.Pop0, StackBehaviour.Pushi8); + 0xff << 0 | 0x21 << 8 | (byte) Code.Ldc_I8 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineI8 << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi8 << 24); public static readonly OpCode Ldc_R4 = new OpCode ( - "ldc.r4", 0xff, 0x22, 1, - Code.Ldc_R4, FlowControl.Next, - OpCodeType.Primitive, OperandType.ShortInlineR, - StackBehaviour.Pop0, StackBehaviour.Pushr4); + 0xff << 0 | 0x22 << 8 | (byte) Code.Ldc_R4 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.ShortInlineR << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushr4 << 24); public static readonly OpCode Ldc_R8 = new OpCode ( - "ldc.r8", 0xff, 0x23, 1, - Code.Ldc_R8, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineR, - StackBehaviour.Pop0, StackBehaviour.Pushr8); + 0xff << 0 | 0x23 << 8 | (byte) Code.Ldc_R8 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineR << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushr8 << 24); public static readonly OpCode Dup = new OpCode ( - "dup", 0xff, 0x25, 1, - Code.Dup, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Push1_push1); + 0xff << 0 | 0x25 << 8 | (byte) Code.Dup << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Push1_push1 << 24); public static readonly OpCode Pop = new OpCode ( - "pop", 0xff, 0x26, 1, - Code.Pop, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Push0); + 0xff << 0 | 0x26 << 8 | (byte) Code.Pop << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Jmp = new OpCode ( - "jmp", 0xff, 0x27, 1, - Code.Jmp, FlowControl.Call, - OpCodeType.Primitive, OperandType.InlineMethod, - StackBehaviour.Pop0, StackBehaviour.Push0); + 0xff << 0 | 0x27 << 8 | (byte) Code.Jmp << 16 | (byte) FlowControl.Call << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineMethod << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Call = new OpCode ( - "call", 0xff, 0x28, 1, - Code.Call, FlowControl.Call, - OpCodeType.Primitive, OperandType.InlineMethod, - StackBehaviour.Varpop, StackBehaviour.Varpush); + 0xff << 0 | 0x28 << 8 | (byte) Code.Call << 16 | (byte) FlowControl.Call << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineMethod << 8 | (byte) StackBehaviour.Varpop << 16 | (byte) StackBehaviour.Varpush << 24); public static readonly OpCode Calli = new OpCode ( - "calli", 0xff, 0x29, 1, - Code.Calli, FlowControl.Call, - OpCodeType.Primitive, OperandType.InlineSig, - StackBehaviour.Varpop, StackBehaviour.Varpush); + 0xff << 0 | 0x29 << 8 | (byte) Code.Calli << 16 | (byte) FlowControl.Call << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineSig << 8 | (byte) StackBehaviour.Varpop << 16 | (byte) StackBehaviour.Varpush << 24); public static readonly OpCode Ret = new OpCode ( - "ret", 0xff, 0x2a, 1, - Code.Ret, FlowControl.Return, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Varpop, StackBehaviour.Push0); + 0xff << 0 | 0x2a << 8 | (byte) Code.Ret << 16 | (byte) FlowControl.Return << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Varpop << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Br_S = new OpCode ( - "br.s", 0xff, 0x2b, 1, - Code.Br_S, FlowControl.Branch, - OpCodeType.Macro, OperandType.ShortInlineBrTarget, - StackBehaviour.Pop0, StackBehaviour.Push0); + 0xff << 0 | 0x2b << 8 | (byte) Code.Br_S << 16 | (byte) FlowControl.Branch << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Brfalse_S = new OpCode ( - "brfalse.s", 0xff, 0x2c, 1, - Code.Brfalse_S, FlowControl.Cond_Branch, - OpCodeType.Macro, OperandType.ShortInlineBrTarget, - StackBehaviour.Popi, StackBehaviour.Push0); + 0xff << 0 | 0x2c << 8 | (byte) Code.Brfalse_S << 16 | (byte) FlowControl.Cond_Branch << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Brtrue_S = new OpCode ( - "brtrue.s", 0xff, 0x2d, 1, - Code.Brtrue_S, FlowControl.Cond_Branch, - OpCodeType.Macro, OperandType.ShortInlineBrTarget, - StackBehaviour.Popi, StackBehaviour.Push0); + 0xff << 0 | 0x2d << 8 | (byte) Code.Brtrue_S << 16 | (byte) FlowControl.Cond_Branch << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Beq_S = new OpCode ( - "beq.s", 0xff, 0x2e, 1, - Code.Beq_S, FlowControl.Cond_Branch, - OpCodeType.Macro, OperandType.ShortInlineBrTarget, - StackBehaviour.Pop1_pop1, StackBehaviour.Push0); + 0xff << 0 | 0x2e << 8 | (byte) Code.Beq_S << 16 | (byte) FlowControl.Cond_Branch << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Bge_S = new OpCode ( - "bge.s", 0xff, 0x2f, 1, - Code.Bge_S, FlowControl.Cond_Branch, - OpCodeType.Macro, OperandType.ShortInlineBrTarget, - StackBehaviour.Pop1_pop1, StackBehaviour.Push0); + 0xff << 0 | 0x2f << 8 | (byte) Code.Bge_S << 16 | (byte) FlowControl.Cond_Branch << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Bgt_S = new OpCode ( - "bgt.s", 0xff, 0x30, 1, - Code.Bgt_S, FlowControl.Cond_Branch, - OpCodeType.Macro, OperandType.ShortInlineBrTarget, - StackBehaviour.Pop1_pop1, StackBehaviour.Push0); + 0xff << 0 | 0x30 << 8 | (byte) Code.Bgt_S << 16 | (byte) FlowControl.Cond_Branch << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Ble_S = new OpCode ( - "ble.s", 0xff, 0x31, 1, - Code.Ble_S, FlowControl.Cond_Branch, - OpCodeType.Macro, OperandType.ShortInlineBrTarget, - StackBehaviour.Pop1_pop1, StackBehaviour.Push0); + 0xff << 0 | 0x31 << 8 | (byte) Code.Ble_S << 16 | (byte) FlowControl.Cond_Branch << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Blt_S = new OpCode ( - "blt.s", 0xff, 0x32, 1, - Code.Blt_S, FlowControl.Cond_Branch, - OpCodeType.Macro, OperandType.ShortInlineBrTarget, - StackBehaviour.Pop1_pop1, StackBehaviour.Push0); + 0xff << 0 | 0x32 << 8 | (byte) Code.Blt_S << 16 | (byte) FlowControl.Cond_Branch << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Bne_Un_S = new OpCode ( - "bne.un.s", 0xff, 0x33, 1, - Code.Bne_Un_S, FlowControl.Cond_Branch, - OpCodeType.Macro, OperandType.ShortInlineBrTarget, - StackBehaviour.Pop1_pop1, StackBehaviour.Push0); + 0xff << 0 | 0x33 << 8 | (byte) Code.Bne_Un_S << 16 | (byte) FlowControl.Cond_Branch << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Bge_Un_S = new OpCode ( - "bge.un.s", 0xff, 0x34, 1, - Code.Bge_Un_S, FlowControl.Cond_Branch, - OpCodeType.Macro, OperandType.ShortInlineBrTarget, - StackBehaviour.Pop1_pop1, StackBehaviour.Push0); + 0xff << 0 | 0x34 << 8 | (byte) Code.Bge_Un_S << 16 | (byte) FlowControl.Cond_Branch << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Bgt_Un_S = new OpCode ( - "bgt.un.s", 0xff, 0x35, 1, - Code.Bgt_Un_S, FlowControl.Cond_Branch, - OpCodeType.Macro, OperandType.ShortInlineBrTarget, - StackBehaviour.Pop1_pop1, StackBehaviour.Push0); + 0xff << 0 | 0x35 << 8 | (byte) Code.Bgt_Un_S << 16 | (byte) FlowControl.Cond_Branch << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Ble_Un_S = new OpCode ( - "ble.un.s", 0xff, 0x36, 1, - Code.Ble_Un_S, FlowControl.Cond_Branch, - OpCodeType.Macro, OperandType.ShortInlineBrTarget, - StackBehaviour.Pop1_pop1, StackBehaviour.Push0); + 0xff << 0 | 0x36 << 8 | (byte) Code.Ble_Un_S << 16 | (byte) FlowControl.Cond_Branch << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Blt_Un_S = new OpCode ( - "blt.un.s", 0xff, 0x37, 1, - Code.Blt_Un_S, FlowControl.Cond_Branch, - OpCodeType.Macro, OperandType.ShortInlineBrTarget, - StackBehaviour.Pop1_pop1, StackBehaviour.Push0); + 0xff << 0 | 0x37 << 8 | (byte) Code.Blt_Un_S << 16 | (byte) FlowControl.Cond_Branch << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Br = new OpCode ( - "br", 0xff, 0x38, 1, - Code.Br, FlowControl.Branch, - OpCodeType.Primitive, OperandType.InlineBrTarget, - StackBehaviour.Pop0, StackBehaviour.Push0); + 0xff << 0 | 0x38 << 8 | (byte) Code.Br << 16 | (byte) FlowControl.Branch << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Brfalse = new OpCode ( - "brfalse", 0xff, 0x39, 1, - Code.Brfalse, FlowControl.Cond_Branch, - OpCodeType.Primitive, OperandType.InlineBrTarget, - StackBehaviour.Popi, StackBehaviour.Push0); + 0xff << 0 | 0x39 << 8 | (byte) Code.Brfalse << 16 | (byte) FlowControl.Cond_Branch << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Brtrue = new OpCode ( - "brtrue", 0xff, 0x3a, 1, - Code.Brtrue, FlowControl.Cond_Branch, - OpCodeType.Primitive, OperandType.InlineBrTarget, - StackBehaviour.Popi, StackBehaviour.Push0); + 0xff << 0 | 0x3a << 8 | (byte) Code.Brtrue << 16 | (byte) FlowControl.Cond_Branch << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Beq = new OpCode ( - "beq", 0xff, 0x3b, 1, - Code.Beq, FlowControl.Cond_Branch, - OpCodeType.Macro, OperandType.InlineBrTarget, - StackBehaviour.Pop1_pop1, StackBehaviour.Push0); + 0xff << 0 | 0x3b << 8 | (byte) Code.Beq << 16 | (byte) FlowControl.Cond_Branch << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Bge = new OpCode ( - "bge", 0xff, 0x3c, 1, - Code.Bge, FlowControl.Cond_Branch, - OpCodeType.Macro, OperandType.InlineBrTarget, - StackBehaviour.Pop1_pop1, StackBehaviour.Push0); + 0xff << 0 | 0x3c << 8 | (byte) Code.Bge << 16 | (byte) FlowControl.Cond_Branch << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Bgt = new OpCode ( - "bgt", 0xff, 0x3d, 1, - Code.Bgt, FlowControl.Cond_Branch, - OpCodeType.Macro, OperandType.InlineBrTarget, - StackBehaviour.Pop1_pop1, StackBehaviour.Push0); + 0xff << 0 | 0x3d << 8 | (byte) Code.Bgt << 16 | (byte) FlowControl.Cond_Branch << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Ble = new OpCode ( - "ble", 0xff, 0x3e, 1, - Code.Ble, FlowControl.Cond_Branch, - OpCodeType.Macro, OperandType.InlineBrTarget, - StackBehaviour.Pop1_pop1, StackBehaviour.Push0); + 0xff << 0 | 0x3e << 8 | (byte) Code.Ble << 16 | (byte) FlowControl.Cond_Branch << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Blt = new OpCode ( - "blt", 0xff, 0x3f, 1, - Code.Blt, FlowControl.Cond_Branch, - OpCodeType.Macro, OperandType.InlineBrTarget, - StackBehaviour.Pop1_pop1, StackBehaviour.Push0); + 0xff << 0 | 0x3f << 8 | (byte) Code.Blt << 16 | (byte) FlowControl.Cond_Branch << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Bne_Un = new OpCode ( - "bne.un", 0xff, 0x40, 1, - Code.Bne_Un, FlowControl.Cond_Branch, - OpCodeType.Macro, OperandType.InlineBrTarget, - StackBehaviour.Pop1_pop1, StackBehaviour.Push0); + 0xff << 0 | 0x40 << 8 | (byte) Code.Bne_Un << 16 | (byte) FlowControl.Cond_Branch << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Bge_Un = new OpCode ( - "bge.un", 0xff, 0x41, 1, - Code.Bge_Un, FlowControl.Cond_Branch, - OpCodeType.Macro, OperandType.InlineBrTarget, - StackBehaviour.Pop1_pop1, StackBehaviour.Push0); + 0xff << 0 | 0x41 << 8 | (byte) Code.Bge_Un << 16 | (byte) FlowControl.Cond_Branch << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Bgt_Un = new OpCode ( - "bgt.un", 0xff, 0x42, 1, - Code.Bgt_Un, FlowControl.Cond_Branch, - OpCodeType.Macro, OperandType.InlineBrTarget, - StackBehaviour.Pop1_pop1, StackBehaviour.Push0); + 0xff << 0 | 0x42 << 8 | (byte) Code.Bgt_Un << 16 | (byte) FlowControl.Cond_Branch << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Ble_Un = new OpCode ( - "ble.un", 0xff, 0x43, 1, - Code.Ble_Un, FlowControl.Cond_Branch, - OpCodeType.Macro, OperandType.InlineBrTarget, - StackBehaviour.Pop1_pop1, StackBehaviour.Push0); + 0xff << 0 | 0x43 << 8 | (byte) Code.Ble_Un << 16 | (byte) FlowControl.Cond_Branch << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Blt_Un = new OpCode ( - "blt.un", 0xff, 0x44, 1, - Code.Blt_Un, FlowControl.Cond_Branch, - OpCodeType.Macro, OperandType.InlineBrTarget, - StackBehaviour.Pop1_pop1, StackBehaviour.Push0); + 0xff << 0 | 0x44 << 8 | (byte) Code.Blt_Un << 16 | (byte) FlowControl.Cond_Branch << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Switch = new OpCode ( - "switch", 0xff, 0x45, 1, - Code.Switch, FlowControl.Cond_Branch, - OpCodeType.Primitive, OperandType.InlineSwitch, - StackBehaviour.Popi, StackBehaviour.Push0); + 0xff << 0 | 0x45 << 8 | (byte) Code.Switch << 16 | (byte) FlowControl.Cond_Branch << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineSwitch << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Ldind_I1 = new OpCode ( - "ldind.i1", 0xff, 0x46, 1, - Code.Ldind_I1, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Popi, StackBehaviour.Pushi); + 0xff << 0 | 0x46 << 8 | (byte) Code.Ldind_I1 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldind_U1 = new OpCode ( - "ldind.u1", 0xff, 0x47, 1, - Code.Ldind_U1, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Popi, StackBehaviour.Pushi); + 0xff << 0 | 0x47 << 8 | (byte) Code.Ldind_U1 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldind_I2 = new OpCode ( - "ldind.i2", 0xff, 0x48, 1, - Code.Ldind_I2, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Popi, StackBehaviour.Pushi); + 0xff << 0 | 0x48 << 8 | (byte) Code.Ldind_I2 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldind_U2 = new OpCode ( - "ldind.u2", 0xff, 0x49, 1, - Code.Ldind_U2, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Popi, StackBehaviour.Pushi); + 0xff << 0 | 0x49 << 8 | (byte) Code.Ldind_U2 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldind_I4 = new OpCode ( - "ldind.i4", 0xff, 0x4a, 1, - Code.Ldind_I4, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Popi, StackBehaviour.Pushi); + 0xff << 0 | 0x4a << 8 | (byte) Code.Ldind_I4 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldind_U4 = new OpCode ( - "ldind.u4", 0xff, 0x4b, 1, - Code.Ldind_U4, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Popi, StackBehaviour.Pushi); + 0xff << 0 | 0x4b << 8 | (byte) Code.Ldind_U4 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldind_I8 = new OpCode ( - "ldind.i8", 0xff, 0x4c, 1, - Code.Ldind_I8, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Popi, StackBehaviour.Pushi8); + 0xff << 0 | 0x4c << 8 | (byte) Code.Ldind_I8 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Pushi8 << 24); public static readonly OpCode Ldind_I = new OpCode ( - "ldind.i", 0xff, 0x4d, 1, - Code.Ldind_I, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Popi, StackBehaviour.Pushi); + 0xff << 0 | 0x4d << 8 | (byte) Code.Ldind_I << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldind_R4 = new OpCode ( - "ldind.r4", 0xff, 0x4e, 1, - Code.Ldind_R4, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Popi, StackBehaviour.Pushr4); + 0xff << 0 | 0x4e << 8 | (byte) Code.Ldind_R4 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Pushr4 << 24); public static readonly OpCode Ldind_R8 = new OpCode ( - "ldind.r8", 0xff, 0x4f, 1, - Code.Ldind_R8, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Popi, StackBehaviour.Pushr8); + 0xff << 0 | 0x4f << 8 | (byte) Code.Ldind_R8 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Pushr8 << 24); public static readonly OpCode Ldind_Ref = new OpCode ( - "ldind.ref", 0xff, 0x50, 1, - Code.Ldind_Ref, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Popi, StackBehaviour.Pushref); + 0xff << 0 | 0x50 << 8 | (byte) Code.Ldind_Ref << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Pushref << 24); public static readonly OpCode Stind_Ref = new OpCode ( - "stind.ref", 0xff, 0x51, 1, - Code.Stind_Ref, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Popi_popi, StackBehaviour.Push0); + 0xff << 0 | 0x51 << 8 | (byte) Code.Stind_Ref << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi_popi << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Stind_I1 = new OpCode ( - "stind.i1", 0xff, 0x52, 1, - Code.Stind_I1, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Popi_popi, StackBehaviour.Push0); + 0xff << 0 | 0x52 << 8 | (byte) Code.Stind_I1 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi_popi << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Stind_I2 = new OpCode ( - "stind.i2", 0xff, 0x53, 1, - Code.Stind_I2, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Popi_popi, StackBehaviour.Push0); + 0xff << 0 | 0x53 << 8 | (byte) Code.Stind_I2 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi_popi << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Stind_I4 = new OpCode ( - "stind.i4", 0xff, 0x54, 1, - Code.Stind_I4, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Popi_popi, StackBehaviour.Push0); + 0xff << 0 | 0x54 << 8 | (byte) Code.Stind_I4 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi_popi << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Stind_I8 = new OpCode ( - "stind.i8", 0xff, 0x55, 1, - Code.Stind_I8, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Popi_popi8, StackBehaviour.Push0); + 0xff << 0 | 0x55 << 8 | (byte) Code.Stind_I8 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi_popi8 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Stind_R4 = new OpCode ( - "stind.r4", 0xff, 0x56, 1, - Code.Stind_R4, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Popi_popr4, StackBehaviour.Push0); + 0xff << 0 | 0x56 << 8 | (byte) Code.Stind_R4 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi_popr4 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Stind_R8 = new OpCode ( - "stind.r8", 0xff, 0x57, 1, - Code.Stind_R8, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Popi_popr8, StackBehaviour.Push0); + 0xff << 0 | 0x57 << 8 | (byte) Code.Stind_R8 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi_popr8 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Add = new OpCode ( - "add", 0xff, 0x58, 1, - Code.Add, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1_pop1, StackBehaviour.Push1); + 0xff << 0 | 0x58 << 8 | (byte) Code.Add << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Sub = new OpCode ( - "sub", 0xff, 0x59, 1, - Code.Sub, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1_pop1, StackBehaviour.Push1); + 0xff << 0 | 0x59 << 8 | (byte) Code.Sub << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Mul = new OpCode ( - "mul", 0xff, 0x5a, 1, - Code.Mul, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1_pop1, StackBehaviour.Push1); + 0xff << 0 | 0x5a << 8 | (byte) Code.Mul << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Div = new OpCode ( - "div", 0xff, 0x5b, 1, - Code.Div, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1_pop1, StackBehaviour.Push1); + 0xff << 0 | 0x5b << 8 | (byte) Code.Div << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Div_Un = new OpCode ( - "div.un", 0xff, 0x5c, 1, - Code.Div_Un, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1_pop1, StackBehaviour.Push1); + 0xff << 0 | 0x5c << 8 | (byte) Code.Div_Un << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Rem = new OpCode ( - "rem", 0xff, 0x5d, 1, - Code.Rem, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1_pop1, StackBehaviour.Push1); + 0xff << 0 | 0x5d << 8 | (byte) Code.Rem << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Rem_Un = new OpCode ( - "rem.un", 0xff, 0x5e, 1, - Code.Rem_Un, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1_pop1, StackBehaviour.Push1); + 0xff << 0 | 0x5e << 8 | (byte) Code.Rem_Un << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode And = new OpCode ( - "and", 0xff, 0x5f, 1, - Code.And, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1_pop1, StackBehaviour.Push1); + 0xff << 0 | 0x5f << 8 | (byte) Code.And << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Or = new OpCode ( - "or", 0xff, 0x60, 1, - Code.Or, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1_pop1, StackBehaviour.Push1); + 0xff << 0 | 0x60 << 8 | (byte) Code.Or << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Xor = new OpCode ( - "xor", 0xff, 0x61, 1, - Code.Xor, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1_pop1, StackBehaviour.Push1); + 0xff << 0 | 0x61 << 8 | (byte) Code.Xor << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Shl = new OpCode ( - "shl", 0xff, 0x62, 1, - Code.Shl, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1_pop1, StackBehaviour.Push1); + 0xff << 0 | 0x62 << 8 | (byte) Code.Shl << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Shr = new OpCode ( - "shr", 0xff, 0x63, 1, - Code.Shr, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1_pop1, StackBehaviour.Push1); + 0xff << 0 | 0x63 << 8 | (byte) Code.Shr << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Shr_Un = new OpCode ( - "shr.un", 0xff, 0x64, 1, - Code.Shr_Un, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1_pop1, StackBehaviour.Push1); + 0xff << 0 | 0x64 << 8 | (byte) Code.Shr_Un << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Neg = new OpCode ( - "neg", 0xff, 0x65, 1, - Code.Neg, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Push1); + 0xff << 0 | 0x65 << 8 | (byte) Code.Neg << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Not = new OpCode ( - "not", 0xff, 0x66, 1, - Code.Not, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Push1); + 0xff << 0 | 0x66 << 8 | (byte) Code.Not << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Conv_I1 = new OpCode ( - "conv.i1", 0xff, 0x67, 1, - Code.Conv_I1, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi); + 0xff << 0 | 0x67 << 8 | (byte) Code.Conv_I1 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Conv_I2 = new OpCode ( - "conv.i2", 0xff, 0x68, 1, - Code.Conv_I2, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi); + 0xff << 0 | 0x68 << 8 | (byte) Code.Conv_I2 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Conv_I4 = new OpCode ( - "conv.i4", 0xff, 0x69, 1, - Code.Conv_I4, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi); + 0xff << 0 | 0x69 << 8 | (byte) Code.Conv_I4 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Conv_I8 = new OpCode ( - "conv.i8", 0xff, 0x6a, 1, - Code.Conv_I8, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi8); + 0xff << 0 | 0x6a << 8 | (byte) Code.Conv_I8 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi8 << 24); public static readonly OpCode Conv_R4 = new OpCode ( - "conv.r4", 0xff, 0x6b, 1, - Code.Conv_R4, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushr4); + 0xff << 0 | 0x6b << 8 | (byte) Code.Conv_R4 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushr4 << 24); public static readonly OpCode Conv_R8 = new OpCode ( - "conv.r8", 0xff, 0x6c, 1, - Code.Conv_R8, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushr8); + 0xff << 0 | 0x6c << 8 | (byte) Code.Conv_R8 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushr8 << 24); public static readonly OpCode Conv_U4 = new OpCode ( - "conv.u4", 0xff, 0x6d, 1, - Code.Conv_U4, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi); + 0xff << 0 | 0x6d << 8 | (byte) Code.Conv_U4 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Conv_U8 = new OpCode ( - "conv.u8", 0xff, 0x6e, 1, - Code.Conv_U8, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi8); + 0xff << 0 | 0x6e << 8 | (byte) Code.Conv_U8 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi8 << 24); public static readonly OpCode Callvirt = new OpCode ( - "callvirt", 0xff, 0x6f, 1, - Code.Callvirt, FlowControl.Call, - OpCodeType.Objmodel, OperandType.InlineMethod, - StackBehaviour.Varpop, StackBehaviour.Varpush); + 0xff << 0 | 0x6f << 8 | (byte) Code.Callvirt << 16 | (byte) FlowControl.Call << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineMethod << 8 | (byte) StackBehaviour.Varpop << 16 | (byte) StackBehaviour.Varpush << 24); public static readonly OpCode Cpobj = new OpCode ( - "cpobj", 0xff, 0x70, 1, - Code.Cpobj, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineType, - StackBehaviour.Popi_popi, StackBehaviour.Push0); + 0xff << 0 | 0x70 << 8 | (byte) Code.Cpobj << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Popi_popi << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Ldobj = new OpCode ( - "ldobj", 0xff, 0x71, 1, - Code.Ldobj, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineType, - StackBehaviour.Popi, StackBehaviour.Push1); + 0xff << 0 | 0x71 << 8 | (byte) Code.Ldobj << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Ldstr = new OpCode ( - "ldstr", 0xff, 0x72, 1, - Code.Ldstr, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineString, - StackBehaviour.Pop0, StackBehaviour.Pushref); + 0xff << 0 | 0x72 << 8 | (byte) Code.Ldstr << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineString << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushref << 24); public static readonly OpCode Newobj = new OpCode ( - "newobj", 0xff, 0x73, 1, - Code.Newobj, FlowControl.Call, - OpCodeType.Objmodel, OperandType.InlineMethod, - StackBehaviour.Varpop, StackBehaviour.Pushref); + 0xff << 0 | 0x73 << 8 | (byte) Code.Newobj << 16 | (byte) FlowControl.Call << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineMethod << 8 | (byte) StackBehaviour.Varpop << 16 | (byte) StackBehaviour.Pushref << 24); public static readonly OpCode Castclass = new OpCode ( - "castclass", 0xff, 0x74, 1, - Code.Castclass, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineType, - StackBehaviour.Popref, StackBehaviour.Pushref); + 0xff << 0 | 0x74 << 8 | (byte) Code.Castclass << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Popref << 16 | (byte) StackBehaviour.Pushref << 24); public static readonly OpCode Isinst = new OpCode ( - "isinst", 0xff, 0x75, 1, - Code.Isinst, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineType, - StackBehaviour.Popref, StackBehaviour.Pushi); + 0xff << 0 | 0x75 << 8 | (byte) Code.Isinst << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Popref << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Conv_R_Un = new OpCode ( - "conv.r.un", 0xff, 0x76, 1, - Code.Conv_R_Un, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushr8); + 0xff << 0 | 0x76 << 8 | (byte) Code.Conv_R_Un << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushr8 << 24); public static readonly OpCode Unbox = new OpCode ( - "unbox", 0xff, 0x79, 1, - Code.Unbox, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineType, - StackBehaviour.Popref, StackBehaviour.Pushi); + 0xff << 0 | 0x79 << 8 | (byte) Code.Unbox << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Popref << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Throw = new OpCode ( - "throw", 0xff, 0x7a, 1, - Code.Throw, FlowControl.Throw, - OpCodeType.Objmodel, OperandType.InlineNone, - StackBehaviour.Popref, StackBehaviour.Push0); + 0xff << 0 | 0x7a << 8 | (byte) Code.Throw << 16 | (byte) FlowControl.Throw << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Ldfld = new OpCode ( - "ldfld", 0xff, 0x7b, 1, - Code.Ldfld, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineField, - StackBehaviour.Popref, StackBehaviour.Push1); + 0xff << 0 | 0x7b << 8 | (byte) Code.Ldfld << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineField << 8 | (byte) StackBehaviour.Popref << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Ldflda = new OpCode ( - "ldflda", 0xff, 0x7c, 1, - Code.Ldflda, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineField, - StackBehaviour.Popref, StackBehaviour.Pushi); + 0xff << 0 | 0x7c << 8 | (byte) Code.Ldflda << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineField << 8 | (byte) StackBehaviour.Popref << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Stfld = new OpCode ( - "stfld", 0xff, 0x7d, 1, - Code.Stfld, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineField, - StackBehaviour.Popref_pop1, StackBehaviour.Push0); + 0xff << 0 | 0x7d << 8 | (byte) Code.Stfld << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineField << 8 | (byte) StackBehaviour.Popref_pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Ldsfld = new OpCode ( - "ldsfld", 0xff, 0x7e, 1, - Code.Ldsfld, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineField, - StackBehaviour.Pop0, StackBehaviour.Push1); + 0xff << 0 | 0x7e << 8 | (byte) Code.Ldsfld << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineField << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Ldsflda = new OpCode ( - "ldsflda", 0xff, 0x7f, 1, - Code.Ldsflda, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineField, - StackBehaviour.Pop0, StackBehaviour.Pushi); + 0xff << 0 | 0x7f << 8 | (byte) Code.Ldsflda << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineField << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Stsfld = new OpCode ( - "stsfld", 0xff, 0x80, 1, - Code.Stsfld, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineField, - StackBehaviour.Pop1, StackBehaviour.Push0); + 0xff << 0 | 0x80 << 8 | (byte) Code.Stsfld << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineField << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Stobj = new OpCode ( - "stobj", 0xff, 0x81, 1, - Code.Stobj, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineType, - StackBehaviour.Popi_pop1, StackBehaviour.Push0); + 0xff << 0 | 0x81 << 8 | (byte) Code.Stobj << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Popi_pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Conv_Ovf_I1_Un = new OpCode ( - "conv.ovf.i1.un", 0xff, 0x82, 1, - Code.Conv_Ovf_I1_Un, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi); + 0xff << 0 | 0x82 << 8 | (byte) Code.Conv_Ovf_I1_Un << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Conv_Ovf_I2_Un = new OpCode ( - "conv.ovf.i2.un", 0xff, 0x83, 1, - Code.Conv_Ovf_I2_Un, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi); + 0xff << 0 | 0x83 << 8 | (byte) Code.Conv_Ovf_I2_Un << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Conv_Ovf_I4_Un = new OpCode ( - "conv.ovf.i4.un", 0xff, 0x84, 1, - Code.Conv_Ovf_I4_Un, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi); + 0xff << 0 | 0x84 << 8 | (byte) Code.Conv_Ovf_I4_Un << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Conv_Ovf_I8_Un = new OpCode ( - "conv.ovf.i8.un", 0xff, 0x85, 1, - Code.Conv_Ovf_I8_Un, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi8); + 0xff << 0 | 0x85 << 8 | (byte) Code.Conv_Ovf_I8_Un << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi8 << 24); public static readonly OpCode Conv_Ovf_U1_Un = new OpCode ( - "conv.ovf.u1.un", 0xff, 0x86, 1, - Code.Conv_Ovf_U1_Un, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi); + 0xff << 0 | 0x86 << 8 | (byte) Code.Conv_Ovf_U1_Un << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Conv_Ovf_U2_Un = new OpCode ( - "conv.ovf.u2.un", 0xff, 0x87, 1, - Code.Conv_Ovf_U2_Un, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi); + 0xff << 0 | 0x87 << 8 | (byte) Code.Conv_Ovf_U2_Un << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Conv_Ovf_U4_Un = new OpCode ( - "conv.ovf.u4.un", 0xff, 0x88, 1, - Code.Conv_Ovf_U4_Un, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi); + 0xff << 0 | 0x88 << 8 | (byte) Code.Conv_Ovf_U4_Un << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Conv_Ovf_U8_Un = new OpCode ( - "conv.ovf.u8.un", 0xff, 0x89, 1, - Code.Conv_Ovf_U8_Un, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi8); + 0xff << 0 | 0x89 << 8 | (byte) Code.Conv_Ovf_U8_Un << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi8 << 24); public static readonly OpCode Conv_Ovf_I_Un = new OpCode ( - "conv.ovf.i.un", 0xff, 0x8a, 1, - Code.Conv_Ovf_I_Un, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi); + 0xff << 0 | 0x8a << 8 | (byte) Code.Conv_Ovf_I_Un << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Conv_Ovf_U_Un = new OpCode ( - "conv.ovf.u.un", 0xff, 0x8b, 1, - Code.Conv_Ovf_U_Un, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi); + 0xff << 0 | 0x8b << 8 | (byte) Code.Conv_Ovf_U_Un << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Box = new OpCode ( - "box", 0xff, 0x8c, 1, - Code.Box, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineType, - StackBehaviour.Pop1, StackBehaviour.Pushref); + 0xff << 0 | 0x8c << 8 | (byte) Code.Box << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushref << 24); public static readonly OpCode Newarr = new OpCode ( - "newarr", 0xff, 0x8d, 1, - Code.Newarr, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineType, - StackBehaviour.Popi, StackBehaviour.Pushref); + 0xff << 0 | 0x8d << 8 | (byte) Code.Newarr << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Pushref << 24); public static readonly OpCode Ldlen = new OpCode ( - "ldlen", 0xff, 0x8e, 1, - Code.Ldlen, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineNone, - StackBehaviour.Popref, StackBehaviour.Pushi); + 0xff << 0 | 0x8e << 8 | (byte) Code.Ldlen << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldelema = new OpCode ( - "ldelema", 0xff, 0x8f, 1, - Code.Ldelema, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineType, - StackBehaviour.Popref_popi, StackBehaviour.Pushi); + 0xff << 0 | 0x8f << 8 | (byte) Code.Ldelema << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Popref_popi << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldelem_I1 = new OpCode ( - "ldelem.i1", 0xff, 0x90, 1, - Code.Ldelem_I1, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineNone, - StackBehaviour.Popref_popi, StackBehaviour.Pushi); + 0xff << 0 | 0x90 << 8 | (byte) Code.Ldelem_I1 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldelem_U1 = new OpCode ( - "ldelem.u1", 0xff, 0x91, 1, - Code.Ldelem_U1, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineNone, - StackBehaviour.Popref_popi, StackBehaviour.Pushi); + 0xff << 0 | 0x91 << 8 | (byte) Code.Ldelem_U1 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldelem_I2 = new OpCode ( - "ldelem.i2", 0xff, 0x92, 1, - Code.Ldelem_I2, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineNone, - StackBehaviour.Popref_popi, StackBehaviour.Pushi); + 0xff << 0 | 0x92 << 8 | (byte) Code.Ldelem_I2 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldelem_U2 = new OpCode ( - "ldelem.u2", 0xff, 0x93, 1, - Code.Ldelem_U2, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineNone, - StackBehaviour.Popref_popi, StackBehaviour.Pushi); + 0xff << 0 | 0x93 << 8 | (byte) Code.Ldelem_U2 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldelem_I4 = new OpCode ( - "ldelem.i4", 0xff, 0x94, 1, - Code.Ldelem_I4, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineNone, - StackBehaviour.Popref_popi, StackBehaviour.Pushi); + 0xff << 0 | 0x94 << 8 | (byte) Code.Ldelem_I4 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldelem_U4 = new OpCode ( - "ldelem.u4", 0xff, 0x95, 1, - Code.Ldelem_U4, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineNone, - StackBehaviour.Popref_popi, StackBehaviour.Pushi); + 0xff << 0 | 0x95 << 8 | (byte) Code.Ldelem_U4 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldelem_I8 = new OpCode ( - "ldelem.i8", 0xff, 0x96, 1, - Code.Ldelem_I8, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineNone, - StackBehaviour.Popref_popi, StackBehaviour.Pushi8); + 0xff << 0 | 0x96 << 8 | (byte) Code.Ldelem_I8 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi << 16 | (byte) StackBehaviour.Pushi8 << 24); public static readonly OpCode Ldelem_I = new OpCode ( - "ldelem.i", 0xff, 0x97, 1, - Code.Ldelem_I, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineNone, - StackBehaviour.Popref_popi, StackBehaviour.Pushi); + 0xff << 0 | 0x97 << 8 | (byte) Code.Ldelem_I << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldelem_R4 = new OpCode ( - "ldelem.r4", 0xff, 0x98, 1, - Code.Ldelem_R4, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineNone, - StackBehaviour.Popref_popi, StackBehaviour.Pushr4); + 0xff << 0 | 0x98 << 8 | (byte) Code.Ldelem_R4 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi << 16 | (byte) StackBehaviour.Pushr4 << 24); public static readonly OpCode Ldelem_R8 = new OpCode ( - "ldelem.r8", 0xff, 0x99, 1, - Code.Ldelem_R8, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineNone, - StackBehaviour.Popref_popi, StackBehaviour.Pushr8); + 0xff << 0 | 0x99 << 8 | (byte) Code.Ldelem_R8 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi << 16 | (byte) StackBehaviour.Pushr8 << 24); public static readonly OpCode Ldelem_Ref = new OpCode ( - "ldelem.ref", 0xff, 0x9a, 1, - Code.Ldelem_Ref, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineNone, - StackBehaviour.Popref_popi, StackBehaviour.Pushref); + 0xff << 0 | 0x9a << 8 | (byte) Code.Ldelem_Ref << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi << 16 | (byte) StackBehaviour.Pushref << 24); public static readonly OpCode Stelem_I = new OpCode ( - "stelem.i", 0xff, 0x9b, 1, - Code.Stelem_I, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineNone, - StackBehaviour.Popref_popi_popi, StackBehaviour.Push0); + 0xff << 0 | 0x9b << 8 | (byte) Code.Stelem_I << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi_popi << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Stelem_I1 = new OpCode ( - "stelem.i1", 0xff, 0x9c, 1, - Code.Stelem_I1, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineNone, - StackBehaviour.Popref_popi_popi, StackBehaviour.Push0); + 0xff << 0 | 0x9c << 8 | (byte) Code.Stelem_I1 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi_popi << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Stelem_I2 = new OpCode ( - "stelem.i2", 0xff, 0x9d, 1, - Code.Stelem_I2, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineNone, - StackBehaviour.Popref_popi_popi, StackBehaviour.Push0); + 0xff << 0 | 0x9d << 8 | (byte) Code.Stelem_I2 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi_popi << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Stelem_I4 = new OpCode ( - "stelem.i4", 0xff, 0x9e, 1, - Code.Stelem_I4, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineNone, - StackBehaviour.Popref_popi_popi, StackBehaviour.Push0); + 0xff << 0 | 0x9e << 8 | (byte) Code.Stelem_I4 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi_popi << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Stelem_I8 = new OpCode ( - "stelem.i8", 0xff, 0x9f, 1, - Code.Stelem_I8, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineNone, - StackBehaviour.Popref_popi_popi8, StackBehaviour.Push0); + 0xff << 0 | 0x9f << 8 | (byte) Code.Stelem_I8 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi_popi8 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Stelem_R4 = new OpCode ( - "stelem.r4", 0xff, 0xa0, 1, - Code.Stelem_R4, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineNone, - StackBehaviour.Popref_popi_popr4, StackBehaviour.Push0); + 0xff << 0 | 0xa0 << 8 | (byte) Code.Stelem_R4 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi_popr4 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Stelem_R8 = new OpCode ( - "stelem.r8", 0xff, 0xa1, 1, - Code.Stelem_R8, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineNone, - StackBehaviour.Popref_popi_popr8, StackBehaviour.Push0); + 0xff << 0 | 0xa1 << 8 | (byte) Code.Stelem_R8 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi_popr8 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Stelem_Ref = new OpCode ( - "stelem.ref", 0xff, 0xa2, 1, - Code.Stelem_Ref, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineNone, - StackBehaviour.Popref_popi_popref, StackBehaviour.Push0); + 0xff << 0 | 0xa2 << 8 | (byte) Code.Stelem_Ref << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi_popref << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Ldelem_Any = new OpCode ( - "ldelem.any", 0xff, 0xa3, 1, - Code.Ldelem_Any, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineType, - StackBehaviour.Popref_popi, StackBehaviour.Push1); + 0xff << 0 | 0xa3 << 8 | (byte) Code.Ldelem_Any << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Popref_popi << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Stelem_Any = new OpCode ( - "stelem.any", 0xff, 0xa4, 1, - Code.Stelem_Any, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineType, - StackBehaviour.Popref_popi_popref, StackBehaviour.Push0); + 0xff << 0 | 0xa4 << 8 | (byte) Code.Stelem_Any << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Popref_popi_popref << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Unbox_Any = new OpCode ( - "unbox.any", 0xff, 0xa5, 1, - Code.Unbox_Any, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineType, - StackBehaviour.Popref, StackBehaviour.Push1); + 0xff << 0 | 0xa5 << 8 | (byte) Code.Unbox_Any << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Popref << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Conv_Ovf_I1 = new OpCode ( - "conv.ovf.i1", 0xff, 0xb3, 1, - Code.Conv_Ovf_I1, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi); + 0xff << 0 | 0xb3 << 8 | (byte) Code.Conv_Ovf_I1 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Conv_Ovf_U1 = new OpCode ( - "conv.ovf.u1", 0xff, 0xb4, 1, - Code.Conv_Ovf_U1, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi); + 0xff << 0 | 0xb4 << 8 | (byte) Code.Conv_Ovf_U1 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Conv_Ovf_I2 = new OpCode ( - "conv.ovf.i2", 0xff, 0xb5, 1, - Code.Conv_Ovf_I2, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi); + 0xff << 0 | 0xb5 << 8 | (byte) Code.Conv_Ovf_I2 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Conv_Ovf_U2 = new OpCode ( - "conv.ovf.u2", 0xff, 0xb6, 1, - Code.Conv_Ovf_U2, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi); + 0xff << 0 | 0xb6 << 8 | (byte) Code.Conv_Ovf_U2 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Conv_Ovf_I4 = new OpCode ( - "conv.ovf.i4", 0xff, 0xb7, 1, - Code.Conv_Ovf_I4, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi); + 0xff << 0 | 0xb7 << 8 | (byte) Code.Conv_Ovf_I4 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Conv_Ovf_U4 = new OpCode ( - "conv.ovf.u4", 0xff, 0xb8, 1, - Code.Conv_Ovf_U4, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi); + 0xff << 0 | 0xb8 << 8 | (byte) Code.Conv_Ovf_U4 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Conv_Ovf_I8 = new OpCode ( - "conv.ovf.i8", 0xff, 0xb9, 1, - Code.Conv_Ovf_I8, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi8); + 0xff << 0 | 0xb9 << 8 | (byte) Code.Conv_Ovf_I8 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi8 << 24); public static readonly OpCode Conv_Ovf_U8 = new OpCode ( - "conv.ovf.u8", 0xff, 0xba, 1, - Code.Conv_Ovf_U8, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi8); + 0xff << 0 | 0xba << 8 | (byte) Code.Conv_Ovf_U8 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi8 << 24); public static readonly OpCode Refanyval = new OpCode ( - "refanyval", 0xff, 0xc2, 1, - Code.Refanyval, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineType, - StackBehaviour.Pop1, StackBehaviour.Pushi); + 0xff << 0 | 0xc2 << 8 | (byte) Code.Refanyval << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ckfinite = new OpCode ( - "ckfinite", 0xff, 0xc3, 1, - Code.Ckfinite, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushr8); + 0xff << 0 | 0xc3 << 8 | (byte) Code.Ckfinite << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushr8 << 24); public static readonly OpCode Mkrefany = new OpCode ( - "mkrefany", 0xff, 0xc6, 1, - Code.Mkrefany, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineType, - StackBehaviour.Popi, StackBehaviour.Push1); + 0xff << 0 | 0xc6 << 8 | (byte) Code.Mkrefany << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Ldtoken = new OpCode ( - "ldtoken", 0xff, 0xd0, 1, - Code.Ldtoken, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineTok, - StackBehaviour.Pop0, StackBehaviour.Pushi); + 0xff << 0 | 0xd0 << 8 | (byte) Code.Ldtoken << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineTok << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Conv_U2 = new OpCode ( - "conv.u2", 0xff, 0xd1, 1, - Code.Conv_U2, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi); + 0xff << 0 | 0xd1 << 8 | (byte) Code.Conv_U2 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Conv_U1 = new OpCode ( - "conv.u1", 0xff, 0xd2, 1, - Code.Conv_U1, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi); + 0xff << 0 | 0xd2 << 8 | (byte) Code.Conv_U1 << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Conv_I = new OpCode ( - "conv.i", 0xff, 0xd3, 1, - Code.Conv_I, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi); + 0xff << 0 | 0xd3 << 8 | (byte) Code.Conv_I << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Conv_Ovf_I = new OpCode ( - "conv.ovf.i", 0xff, 0xd4, 1, - Code.Conv_Ovf_I, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi); + 0xff << 0 | 0xd4 << 8 | (byte) Code.Conv_Ovf_I << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Conv_Ovf_U = new OpCode ( - "conv.ovf.u", 0xff, 0xd5, 1, - Code.Conv_Ovf_U, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi); + 0xff << 0 | 0xd5 << 8 | (byte) Code.Conv_Ovf_U << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Add_Ovf = new OpCode ( - "add.ovf", 0xff, 0xd6, 1, - Code.Add_Ovf, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1_pop1, StackBehaviour.Push1); + 0xff << 0 | 0xd6 << 8 | (byte) Code.Add_Ovf << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Add_Ovf_Un = new OpCode ( - "add.ovf.un", 0xff, 0xd7, 1, - Code.Add_Ovf_Un, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1_pop1, StackBehaviour.Push1); + 0xff << 0 | 0xd7 << 8 | (byte) Code.Add_Ovf_Un << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Mul_Ovf = new OpCode ( - "mul.ovf", 0xff, 0xd8, 1, - Code.Mul_Ovf, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1_pop1, StackBehaviour.Push1); + 0xff << 0 | 0xd8 << 8 | (byte) Code.Mul_Ovf << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Mul_Ovf_Un = new OpCode ( - "mul.ovf.un", 0xff, 0xd9, 1, - Code.Mul_Ovf_Un, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1_pop1, StackBehaviour.Push1); + 0xff << 0 | 0xd9 << 8 | (byte) Code.Mul_Ovf_Un << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Sub_Ovf = new OpCode ( - "sub.ovf", 0xff, 0xda, 1, - Code.Sub_Ovf, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1_pop1, StackBehaviour.Push1); + 0xff << 0 | 0xda << 8 | (byte) Code.Sub_Ovf << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Sub_Ovf_Un = new OpCode ( - "sub.ovf.un", 0xff, 0xdb, 1, - Code.Sub_Ovf_Un, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1_pop1, StackBehaviour.Push1); + 0xff << 0 | 0xdb << 8 | (byte) Code.Sub_Ovf_Un << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Endfinally = new OpCode ( - "endfinally", 0xff, 0xdc, 1, - Code.Endfinally, FlowControl.Return, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Push0); + 0xff << 0 | 0xdc << 8 | (byte) Code.Endfinally << 16 | (byte) FlowControl.Return << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Leave = new OpCode ( - "leave", 0xff, 0xdd, 1, - Code.Leave, FlowControl.Branch, - OpCodeType.Primitive, OperandType.InlineBrTarget, - StackBehaviour.PopAll, StackBehaviour.Push0); + 0xff << 0 | 0xdd << 8 | (byte) Code.Leave << 16 | (byte) FlowControl.Branch << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.PopAll << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Leave_S = new OpCode ( - "leave.s", 0xff, 0xde, 1, - Code.Leave_S, FlowControl.Branch, - OpCodeType.Macro, OperandType.ShortInlineBrTarget, - StackBehaviour.PopAll, StackBehaviour.Push0); + 0xff << 0 | 0xde << 8 | (byte) Code.Leave_S << 16 | (byte) FlowControl.Branch << 24, + (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.PopAll << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Stind_I = new OpCode ( - "stind.i", 0xff, 0xdf, 1, - Code.Stind_I, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Popi_popi, StackBehaviour.Push0); + 0xff << 0 | 0xdf << 8 | (byte) Code.Stind_I << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi_popi << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Conv_U = new OpCode ( - "conv.u", 0xff, 0xe0, 1, - Code.Conv_U, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi); + 0xff << 0 | 0xe0 << 8 | (byte) Code.Conv_U << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Arglist = new OpCode ( - "arglist", 0xfe, 0x00, 2, - Code.Arglist, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Pushi); + 0xfe << 0 | 0x00 << 8 | (byte) Code.Arglist << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ceq = new OpCode ( - "ceq", 0xfe, 0x01, 2, - Code.Ceq, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1_pop1, StackBehaviour.Pushi); + 0xfe << 0 | 0x01 << 8 | (byte) Code.Ceq << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Cgt = new OpCode ( - "cgt", 0xfe, 0x02, 2, - Code.Cgt, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1_pop1, StackBehaviour.Pushi); + 0xfe << 0 | 0x02 << 8 | (byte) Code.Cgt << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Cgt_Un = new OpCode ( - "cgt.un", 0xfe, 0x03, 2, - Code.Cgt_Un, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1_pop1, StackBehaviour.Pushi); + 0xfe << 0 | 0x03 << 8 | (byte) Code.Cgt_Un << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Clt = new OpCode ( - "clt", 0xfe, 0x04, 2, - Code.Clt, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1_pop1, StackBehaviour.Pushi); + 0xfe << 0 | 0x04 << 8 | (byte) Code.Clt << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Clt_Un = new OpCode ( - "clt.un", 0xfe, 0x05, 2, - Code.Clt_Un, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1_pop1, StackBehaviour.Pushi); + 0xfe << 0 | 0x05 << 8 | (byte) Code.Clt_Un << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldftn = new OpCode ( - "ldftn", 0xfe, 0x06, 2, - Code.Ldftn, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineMethod, - StackBehaviour.Pop0, StackBehaviour.Pushi); + 0xfe << 0 | 0x06 << 8 | (byte) Code.Ldftn << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineMethod << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldvirtftn = new OpCode ( - "ldvirtftn", 0xfe, 0x07, 2, - Code.Ldvirtftn, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineMethod, - StackBehaviour.Popref, StackBehaviour.Pushi); + 0xfe << 0 | 0x07 << 8 | (byte) Code.Ldvirtftn << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineMethod << 8 | (byte) StackBehaviour.Popref << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Ldarg = new OpCode ( - "ldarg", 0xfe, 0x09, 2, - Code.Ldarg, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineParam, - StackBehaviour.Pop0, StackBehaviour.Push1); + 0xfe << 0 | 0x09 << 8 | (byte) Code.Ldarg << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineArg << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Ldarga = new OpCode ( - "ldarga", 0xfe, 0x0a, 2, - Code.Ldarga, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineParam, - StackBehaviour.Pop0, StackBehaviour.Pushi); + 0xfe << 0 | 0x0a << 8 | (byte) Code.Ldarga << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineArg << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Starg = new OpCode ( - "starg", 0xfe, 0x0b, 2, - Code.Starg, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineParam, - StackBehaviour.Pop1, StackBehaviour.Push0); + 0xfe << 0 | 0x0b << 8 | (byte) Code.Starg << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineArg << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Ldloc = new OpCode ( - "ldloc", 0xfe, 0x0c, 2, - Code.Ldloc, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineVar, - StackBehaviour.Pop0, StackBehaviour.Push1); + 0xfe << 0 | 0x0c << 8 | (byte) Code.Ldloc << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineVar << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push1 << 24); public static readonly OpCode Ldloca = new OpCode ( - "ldloca", 0xfe, 0x0d, 2, - Code.Ldloca, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineVar, - StackBehaviour.Pop0, StackBehaviour.Pushi); + 0xfe << 0 | 0x0d << 8 | (byte) Code.Ldloca << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineVar << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Stloc = new OpCode ( - "stloc", 0xfe, 0x0e, 2, - Code.Stloc, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineVar, - StackBehaviour.Pop1, StackBehaviour.Push0); + 0xfe << 0 | 0x0e << 8 | (byte) Code.Stloc << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineVar << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Localloc = new OpCode ( - "localloc", 0xfe, 0x0f, 2, - Code.Localloc, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Popi, StackBehaviour.Pushi); + 0xfe << 0 | 0x0f << 8 | (byte) Code.Localloc << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Endfilter = new OpCode ( - "endfilter", 0xfe, 0x11, 2, - Code.Endfilter, FlowControl.Return, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Popi, StackBehaviour.Push0); + 0xfe << 0 | 0x11 << 8 | (byte) Code.Endfilter << 16 | (byte) FlowControl.Return << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Unaligned = new OpCode ( - "unaligned.", 0xfe, 0x12, 2, - Code.Unaligned, FlowControl.Meta, - OpCodeType.Prefix, OperandType.ShortInlineI, - StackBehaviour.Pop0, StackBehaviour.Push0); + 0xfe << 0 | 0x12 << 8 | (byte) Code.Unaligned << 16 | (byte) FlowControl.Meta << 24, + (byte) OpCodeType.Prefix << 0 | (byte) OperandType.ShortInlineI << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Volatile = new OpCode ( - "volatile.", 0xfe, 0x13, 2, - Code.Volatile, FlowControl.Meta, - OpCodeType.Prefix, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Push0); + 0xfe << 0 | 0x13 << 8 | (byte) Code.Volatile << 16 | (byte) FlowControl.Meta << 24, + (byte) OpCodeType.Prefix << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Tail = new OpCode ( - "tail.", 0xfe, 0x14, 2, - Code.Tail, FlowControl.Meta, - OpCodeType.Prefix, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Push0); + 0xfe << 0 | 0x14 << 8 | (byte) Code.Tail << 16 | (byte) FlowControl.Meta << 24, + (byte) OpCodeType.Prefix << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Initobj = new OpCode ( - "initobj", 0xfe, 0x15, 2, - Code.Initobj, FlowControl.Next, - OpCodeType.Objmodel, OperandType.InlineType, - StackBehaviour.Popi, StackBehaviour.Push0); + 0xfe << 0 | 0x15 << 8 | (byte) Code.Initobj << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Constrained = new OpCode ( - "constrained.", 0xfe, 0x16, 2, - Code.Constrained, FlowControl.Next, - OpCodeType.Prefix, OperandType.InlineTok, - StackBehaviour.Pop0, StackBehaviour.Push0); + 0xfe << 0 | 0x16 << 8 | (byte) Code.Constrained << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Prefix << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Cpblk = new OpCode ( - "cpblk", 0xfe, 0x17, 2, - Code.Cpblk, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Popi_popi_popi, StackBehaviour.Push0); + 0xfe << 0 | 0x17 << 8 | (byte) Code.Cpblk << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi_popi_popi << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Initblk = new OpCode ( - "initblk", 0xfe, 0x18, 2, - Code.Initblk, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Popi_popi_popi, StackBehaviour.Push0); + 0xfe << 0 | 0x18 << 8 | (byte) Code.Initblk << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi_popi_popi << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode No = new OpCode ( - "no.", 0xfe, 0x19, 2, - Code.No, FlowControl.Next, - OpCodeType.Prefix, OperandType.ShortInlineI, - StackBehaviour.Pop0, StackBehaviour.Push0); + 0xfe << 0 | 0x19 << 8 | (byte) Code.No << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Prefix << 0 | (byte) OperandType.ShortInlineI << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Rethrow = new OpCode ( - "rethrow", 0xfe, 0x1a, 2, - Code.Rethrow, FlowControl.Throw, - OpCodeType.Objmodel, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Push0); + 0xfe << 0 | 0x1a << 8 | (byte) Code.Rethrow << 16 | (byte) FlowControl.Throw << 24, + (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push0 << 24); public static readonly OpCode Sizeof = new OpCode ( - "sizeof", 0xfe, 0x1c, 2, - Code.Sizeof, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineType, - StackBehaviour.Pop0, StackBehaviour.Pushi); + 0xfe << 0 | 0x1c << 8 | (byte) Code.Sizeof << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Refanytype = new OpCode ( - "refanytype", 0xfe, 0x1d, 2, - Code.Refanytype, FlowControl.Next, - OpCodeType.Primitive, OperandType.InlineNone, - StackBehaviour.Pop1, StackBehaviour.Pushi); + 0xfe << 0 | 0x1d << 8 | (byte) Code.Refanytype << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24); public static readonly OpCode Readonly = new OpCode ( - "readonly.", 0xfe, 0x1e, 2, - Code.Readonly, FlowControl.Next, - OpCodeType.Prefix, OperandType.InlineNone, - StackBehaviour.Pop0, StackBehaviour.Push0); - - OpCodes() - { - } - - public static OpCode GetOpCode (Code code) - { - switch (code) { - case Code.Nop : return OpCodes.Nop; - case Code.Break : return OpCodes.Break; - case Code.Ldarg_0 : return OpCodes.Ldarg_0; - case Code.Ldarg_1 : return OpCodes.Ldarg_1; - case Code.Ldarg_2 : return OpCodes.Ldarg_2; - case Code.Ldarg_3 : return OpCodes.Ldarg_3; - case Code.Ldloc_0 : return OpCodes.Ldloc_0; - case Code.Ldloc_1 : return OpCodes.Ldloc_1; - case Code.Ldloc_2 : return OpCodes.Ldloc_2; - case Code.Ldloc_3 : return OpCodes.Ldloc_3; - case Code.Stloc_0 : return OpCodes.Stloc_0; - case Code.Stloc_1 : return OpCodes.Stloc_1; - case Code.Stloc_2 : return OpCodes.Stloc_2; - case Code.Stloc_3 : return OpCodes.Stloc_3; - case Code.Ldarg_S : return OpCodes.Ldarg_S; - case Code.Ldarga_S : return OpCodes.Ldarga_S; - case Code.Starg_S : return OpCodes.Starg_S; - case Code.Ldloc_S : return OpCodes.Ldloc_S; - case Code.Ldloca_S : return OpCodes.Ldloca_S; - case Code.Stloc_S : return OpCodes.Stloc_S; - case Code.Ldnull : return OpCodes.Ldnull; - case Code.Ldc_I4_M1 : return OpCodes.Ldc_I4_M1; - case Code.Ldc_I4_0 : return OpCodes.Ldc_I4_0; - case Code.Ldc_I4_1 : return OpCodes.Ldc_I4_1; - case Code.Ldc_I4_2 : return OpCodes.Ldc_I4_2; - case Code.Ldc_I4_3 : return OpCodes.Ldc_I4_3; - case Code.Ldc_I4_4 : return OpCodes.Ldc_I4_4; - case Code.Ldc_I4_5 : return OpCodes.Ldc_I4_5; - case Code.Ldc_I4_6 : return OpCodes.Ldc_I4_6; - case Code.Ldc_I4_7 : return OpCodes.Ldc_I4_7; - case Code.Ldc_I4_8 : return OpCodes.Ldc_I4_8; - case Code.Ldc_I4_S : return OpCodes.Ldc_I4_S; - case Code.Ldc_I4 : return OpCodes.Ldc_I4; - case Code.Ldc_I8 : return OpCodes.Ldc_I8; - case Code.Ldc_R4 : return OpCodes.Ldc_R4; - case Code.Ldc_R8 : return OpCodes.Ldc_R8; - case Code.Dup : return OpCodes.Dup; - case Code.Pop : return OpCodes.Pop; - case Code.Jmp : return OpCodes.Jmp; - case Code.Call : return OpCodes.Call; - case Code.Calli : return OpCodes.Calli; - case Code.Ret : return OpCodes.Ret; - case Code.Br_S : return OpCodes.Br_S; - case Code.Brfalse_S : return OpCodes.Brfalse_S; - case Code.Brtrue_S : return OpCodes.Brtrue_S; - case Code.Beq_S : return OpCodes.Beq_S; - case Code.Bge_S : return OpCodes.Bge_S; - case Code.Bgt_S : return OpCodes.Bgt_S; - case Code.Ble_S : return OpCodes.Ble_S; - case Code.Blt_S : return OpCodes.Blt_S; - case Code.Bne_Un_S : return OpCodes.Bne_Un_S; - case Code.Bge_Un_S : return OpCodes.Bge_Un_S; - case Code.Bgt_Un_S : return OpCodes.Bgt_Un_S; - case Code.Ble_Un_S : return OpCodes.Ble_Un_S; - case Code.Blt_Un_S : return OpCodes.Blt_Un_S; - case Code.Br : return OpCodes.Br; - case Code.Brfalse : return OpCodes.Brfalse; - case Code.Brtrue : return OpCodes.Brtrue; - case Code.Beq : return OpCodes.Beq; - case Code.Bge : return OpCodes.Bge; - case Code.Bgt : return OpCodes.Bgt; - case Code.Ble : return OpCodes.Ble; - case Code.Blt : return OpCodes.Blt; - case Code.Bne_Un : return OpCodes.Bne_Un; - case Code.Bge_Un : return OpCodes.Bge_Un; - case Code.Bgt_Un : return OpCodes.Bgt_Un; - case Code.Ble_Un : return OpCodes.Ble_Un; - case Code.Blt_Un : return OpCodes.Blt_Un; - case Code.Switch : return OpCodes.Switch; - case Code.Ldind_I1 : return OpCodes.Ldind_I1; - case Code.Ldind_U1 : return OpCodes.Ldind_U1; - case Code.Ldind_I2 : return OpCodes.Ldind_I2; - case Code.Ldind_U2 : return OpCodes.Ldind_U2; - case Code.Ldind_I4 : return OpCodes.Ldind_I4; - case Code.Ldind_U4 : return OpCodes.Ldind_U4; - case Code.Ldind_I8 : return OpCodes.Ldind_I8; - case Code.Ldind_I : return OpCodes.Ldind_I; - case Code.Ldind_R4 : return OpCodes.Ldind_R4; - case Code.Ldind_R8 : return OpCodes.Ldind_R8; - case Code.Ldind_Ref : return OpCodes.Ldind_Ref; - case Code.Stind_Ref : return OpCodes.Stind_Ref; - case Code.Stind_I1 : return OpCodes.Stind_I1; - case Code.Stind_I2 : return OpCodes.Stind_I2; - case Code.Stind_I4 : return OpCodes.Stind_I4; - case Code.Stind_I8 : return OpCodes.Stind_I8; - case Code.Stind_R4 : return OpCodes.Stind_R4; - case Code.Stind_R8 : return OpCodes.Stind_R8; - case Code.Add : return OpCodes.Add; - case Code.Sub : return OpCodes.Sub; - case Code.Mul : return OpCodes.Mul; - case Code.Div : return OpCodes.Div; - case Code.Div_Un : return OpCodes.Div_Un; - case Code.Rem : return OpCodes.Rem; - case Code.Rem_Un : return OpCodes.Rem_Un; - case Code.And : return OpCodes.And; - case Code.Or : return OpCodes.Or; - case Code.Xor : return OpCodes.Xor; - case Code.Shl : return OpCodes.Shl; - case Code.Shr : return OpCodes.Shr; - case Code.Shr_Un : return OpCodes.Shr_Un; - case Code.Neg : return OpCodes.Neg; - case Code.Not : return OpCodes.Not; - case Code.Conv_I1 : return OpCodes.Conv_I1; - case Code.Conv_I2 : return OpCodes.Conv_I2; - case Code.Conv_I4 : return OpCodes.Conv_I4; - case Code.Conv_I8 : return OpCodes.Conv_I8; - case Code.Conv_R4 : return OpCodes.Conv_R4; - case Code.Conv_R8 : return OpCodes.Conv_R8; - case Code.Conv_U4 : return OpCodes.Conv_U4; - case Code.Conv_U8 : return OpCodes.Conv_U8; - case Code.Callvirt : return OpCodes.Callvirt; - case Code.Cpobj : return OpCodes.Cpobj; - case Code.Ldobj : return OpCodes.Ldobj; - case Code.Ldstr : return OpCodes.Ldstr; - case Code.Newobj : return OpCodes.Newobj; - case Code.Castclass : return OpCodes.Castclass; - case Code.Isinst : return OpCodes.Isinst; - case Code.Conv_R_Un : return OpCodes.Conv_R_Un; - case Code.Unbox : return OpCodes.Unbox; - case Code.Throw : return OpCodes.Throw; - case Code.Ldfld : return OpCodes.Ldfld; - case Code.Ldflda : return OpCodes.Ldflda; - case Code.Stfld : return OpCodes.Stfld; - case Code.Ldsfld : return OpCodes.Ldsfld; - case Code.Ldsflda : return OpCodes.Ldsflda; - case Code.Stsfld : return OpCodes.Stsfld; - case Code.Stobj : return OpCodes.Stobj; - case Code.Conv_Ovf_I1_Un : return OpCodes.Conv_Ovf_I1_Un; - case Code.Conv_Ovf_I2_Un : return OpCodes.Conv_Ovf_I2_Un; - case Code.Conv_Ovf_I4_Un : return OpCodes.Conv_Ovf_I4_Un; - case Code.Conv_Ovf_I8_Un : return OpCodes.Conv_Ovf_I8_Un; - case Code.Conv_Ovf_U1_Un : return OpCodes.Conv_Ovf_U1_Un; - case Code.Conv_Ovf_U2_Un : return OpCodes.Conv_Ovf_U2_Un; - case Code.Conv_Ovf_U4_Un : return OpCodes.Conv_Ovf_U4_Un; - case Code.Conv_Ovf_U8_Un : return OpCodes.Conv_Ovf_U8_Un; - case Code.Conv_Ovf_I_Un : return OpCodes.Conv_Ovf_I_Un; - case Code.Conv_Ovf_U_Un : return OpCodes.Conv_Ovf_U_Un; - case Code.Box : return OpCodes.Box; - case Code.Newarr : return OpCodes.Newarr; - case Code.Ldlen : return OpCodes.Ldlen; - case Code.Ldelema : return OpCodes.Ldelema; - case Code.Ldelem_I1 : return OpCodes.Ldelem_I1; - case Code.Ldelem_U1 : return OpCodes.Ldelem_U1; - case Code.Ldelem_I2 : return OpCodes.Ldelem_I2; - case Code.Ldelem_U2 : return OpCodes.Ldelem_U2; - case Code.Ldelem_I4 : return OpCodes.Ldelem_I4; - case Code.Ldelem_U4 : return OpCodes.Ldelem_U4; - case Code.Ldelem_I8 : return OpCodes.Ldelem_I8; - case Code.Ldelem_I : return OpCodes.Ldelem_I; - case Code.Ldelem_R4 : return OpCodes.Ldelem_R4; - case Code.Ldelem_R8 : return OpCodes.Ldelem_R8; - case Code.Ldelem_Ref : return OpCodes.Ldelem_Ref; - case Code.Stelem_I : return OpCodes.Stelem_I; - case Code.Stelem_I1 : return OpCodes.Stelem_I1; - case Code.Stelem_I2 : return OpCodes.Stelem_I2; - case Code.Stelem_I4 : return OpCodes.Stelem_I4; - case Code.Stelem_I8 : return OpCodes.Stelem_I8; - case Code.Stelem_R4 : return OpCodes.Stelem_R4; - case Code.Stelem_R8 : return OpCodes.Stelem_R8; - case Code.Stelem_Ref : return OpCodes.Stelem_Ref; - case Code.Ldelem_Any : return OpCodes.Ldelem_Any; - case Code.Stelem_Any : return OpCodes.Stelem_Any; - case Code.Unbox_Any : return OpCodes.Unbox_Any; - case Code.Conv_Ovf_I1 : return OpCodes.Conv_Ovf_I1; - case Code.Conv_Ovf_U1 : return OpCodes.Conv_Ovf_U1; - case Code.Conv_Ovf_I2 : return OpCodes.Conv_Ovf_I2; - case Code.Conv_Ovf_U2 : return OpCodes.Conv_Ovf_U2; - case Code.Conv_Ovf_I4 : return OpCodes.Conv_Ovf_I4; - case Code.Conv_Ovf_U4 : return OpCodes.Conv_Ovf_U4; - case Code.Conv_Ovf_I8 : return OpCodes.Conv_Ovf_I8; - case Code.Conv_Ovf_U8 : return OpCodes.Conv_Ovf_U8; - case Code.Refanyval : return OpCodes.Refanyval; - case Code.Ckfinite : return OpCodes.Ckfinite; - case Code.Mkrefany : return OpCodes.Mkrefany; - case Code.Ldtoken : return OpCodes.Ldtoken; - case Code.Conv_U2 : return OpCodes.Conv_U2; - case Code.Conv_U1 : return OpCodes.Conv_U1; - case Code.Conv_I : return OpCodes.Conv_I; - case Code.Conv_Ovf_I : return OpCodes.Conv_Ovf_I; - case Code.Conv_Ovf_U : return OpCodes.Conv_Ovf_U; - case Code.Add_Ovf : return OpCodes.Add_Ovf; - case Code.Add_Ovf_Un : return OpCodes.Add_Ovf_Un; - case Code.Mul_Ovf : return OpCodes.Mul_Ovf; - case Code.Mul_Ovf_Un : return OpCodes.Mul_Ovf_Un; - case Code.Sub_Ovf : return OpCodes.Sub_Ovf; - case Code.Sub_Ovf_Un : return OpCodes.Sub_Ovf_Un; - case Code.Endfinally : return OpCodes.Endfinally; - case Code.Leave : return OpCodes.Leave; - case Code.Leave_S : return OpCodes.Leave_S; - case Code.Stind_I : return OpCodes.Stind_I; - case Code.Conv_U : return OpCodes.Conv_U; - case Code.Arglist : return OpCodes.Arglist; - case Code.Ceq : return OpCodes.Ceq; - case Code.Cgt : return OpCodes.Cgt; - case Code.Cgt_Un : return OpCodes.Cgt_Un; - case Code.Clt : return OpCodes.Clt; - case Code.Clt_Un : return OpCodes.Clt_Un; - case Code.Ldftn : return OpCodes.Ldftn; - case Code.Ldvirtftn : return OpCodes.Ldvirtftn; - case Code.Ldarg : return OpCodes.Ldarg; - case Code.Ldarga : return OpCodes.Ldarga; - case Code.Starg : return OpCodes.Starg; - case Code.Ldloc : return OpCodes.Ldloc; - case Code.Ldloca : return OpCodes.Ldloca; - case Code.Stloc : return OpCodes.Stloc; - case Code.Localloc : return OpCodes.Localloc; - case Code.Endfilter : return OpCodes.Endfilter; - case Code.Unaligned : return OpCodes.Unaligned; - case Code.Volatile : return OpCodes.Volatile; - case Code.Tail : return OpCodes.Tail; - case Code.Initobj : return OpCodes.Initobj; - case Code.Constrained : return OpCodes.Constrained; - case Code.Cpblk : return OpCodes.Cpblk; - case Code.Initblk : return OpCodes.Initblk; - case Code.No : return OpCodes.No; - case Code.Rethrow : return OpCodes.Rethrow; - case Code.Sizeof : return OpCodes.Sizeof; - case Code.Refanytype : return OpCodes.Refanytype; - case Code.Readonly : return OpCodes.Readonly; - default : return OpCodes.Nop; - } - } + 0xfe << 0 | 0x1e << 8 | (byte) Code.Readonly << 16 | (byte) FlowControl.Next << 24, + (byte) OpCodeType.Prefix << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push0 << 24); } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OpCodeType.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OpCodeType.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OpCodeType.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OpCodeType.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// -// OpCodeType.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - public enum OpCodeType { - Annotation, - Macro, - Nternal, - Objmodel, - Prefix, - Primitive - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OperandType.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OperandType.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OperandType.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OperandType.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -// -// OperandType.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - public enum OperandType { - InlineBrTarget, - InlineField, - InlineI, - InlineI8, - InlineMethod, - InlineNone, - InlinePhi, - InlineR, - InlineSig, - InlineString, - InlineSwitch, - InlineTok, - InlineType, - InlineVar, - InlineParam, - ShortInlineBrTarget, - ShortInlineI, - ShortInlineR, - ShortInlineVar, - ShortInlineParam - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ScopeCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ScopeCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ScopeCollection.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ScopeCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ -// -// ScopeCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Wed Sep 27 12:46:54 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - using System; - using System.Collections; - - using Mono.Cecil.Cil; - - public sealed class ScopeCollection : CollectionBase, ICodeVisitable { - - IScopeProvider m_container; - - public Scope this [int index] { - get { return List [index] as Scope; } - set { List [index] = value; } - } - - public IScopeProvider Container { - get { return m_container; } - } - - public ScopeCollection (IScopeProvider container) - { - m_container = container; - } - - public void Add (Scope value) - { - List.Add (value); - } - - public bool Contains (Scope value) - { - return List.Contains (value); - } - - public int IndexOf (Scope value) - { - return List.IndexOf (value); - } - - public void Insert (int index, Scope value) - { - List.Insert (index, value); - } - - public void Remove (Scope value) - { - List.Remove (value); - } - - protected override void OnValidate (object o) - { - if (! (o is Scope)) - throw new ArgumentException ("Must be of type " + typeof (Scope).FullName); - } - - public void Accept (ICodeVisitor visitor) - { - visitor.VisitScopeCollection (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Scope.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Scope.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Scope.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Scope.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -// -// Scope.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2006 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - public class Scope : IScopeProvider, IVariableDefinitionProvider, ICodeVisitable { - - Instruction m_start; - Instruction m_end; - - Scope m_parent; - ScopeCollection m_scopes; - - VariableDefinitionCollection m_variables; - - public Instruction Start { - get { return m_start; } - set { m_start = value; } - } - - public Instruction End { - get { return m_end; } - set { m_end = value; } - } - - public Scope Parent { - get { return m_parent; } - set { m_parent = value; } - } - - public ScopeCollection Scopes { - get { - if (m_scopes == null) - m_scopes = new ScopeCollection (this); - - return m_scopes; - } - } - - public VariableDefinitionCollection Variables { - get { - if (m_variables == null) - m_variables = new VariableDefinitionCollection (this); - - return m_variables; - } - } - - public void Accept (ICodeVisitor visitor) - { - visitor.VisitScope (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/SequencePoint.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/SequencePoint.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/SequencePoint.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/SequencePoint.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2006 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -28,51 +28,43 @@ namespace Mono.Cecil.Cil { - public class SequencePoint { + public sealed class SequencePoint { - Document m_document; + Document document; - int m_startLine; - int m_startColumn; - int m_endLine; - int m_endColumn; + int start_line; + int start_column; + int end_line; + int end_column; public int StartLine { - get { return m_startLine; } - set { m_startLine = value; } + get { return start_line; } + set { start_line = value; } } public int StartColumn { - get { return m_startColumn; } - set { m_startColumn = value; } + get { return start_column; } + set { start_column = value; } } public int EndLine { - get { return m_endLine; } - set { m_endLine = value; } + get { return end_line; } + set { end_line = value; } } public int EndColumn { - get { return m_endColumn; } - set { m_endColumn = value; } + get { return end_column; } + set { end_column = value; } } public Document Document { - get { return m_document; } - set { m_document = value; } + get { return document; } + set { document = value; } } public SequencePoint (Document document) { - m_document = document; - } - - public SequencePoint (Document doc, int startLine, int startCol, int endLine, int endCol) : this (doc) - { - m_startLine = startLine; - m_startColumn = startCol; - m_endLine = endLine; - m_endColumn = endCol; + this.document = document; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/StackBehaviour.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/StackBehaviour.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/StackBehaviour.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/StackBehaviour.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -// -// StackBehaviour.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - public enum StackBehaviour { - Pop0, - Pop1, - Pop1_pop1, - Popi, - Popi_pop1, - Popi_popi, - Popi_popi8, - Popi_popi_popi, - Popi_popr4, - Popi_popr8, - Popref, - Popref_pop1, - Popref_popi, - Popref_popi_popi, - Popref_popi_popi8, - Popref_popi_popr4, - Popref_popi_popr8, - Popref_popi_popref, - PopAll, - Push0, - Push1, - Push1_push1, - Pushi, - Pushi8, - Pushr4, - Pushr8, - Pushref, - Varpop, - Varpush - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Symbols.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Symbols.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Symbols.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Symbols.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,272 @@ +// +// Symbols.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.IO; +using System.Runtime.InteropServices; +using SR = System.Reflection; + +using Mono.Collections.Generic; + +namespace Mono.Cecil.Cil { + + [StructLayout (LayoutKind.Sequential)] + public struct ImageDebugDirectory { + public int Characteristics; + public int TimeDateStamp; + public short MajorVersion; + public short MinorVersion; + public int Type; + public int SizeOfData; + public int AddressOfRawData; + public int PointerToRawData; + } + + public sealed class Scope : IVariableDefinitionProvider { + + Instruction start; + Instruction end; + + Collection scopes; + Collection variables; + + public Instruction Start { + get { return start; } + set { start = value; } + } + + public Instruction End { + get { return end; } + set { end = value; } + } + + public bool HasScopes { + get { return !scopes.IsNullOrEmpty (); } + } + + public Collection Scopes { + get { + if (scopes == null) + scopes = new Collection (); + + return scopes; + } + } + + public bool HasVariables { + get { return !variables.IsNullOrEmpty (); } + } + + public Collection Variables { + get { + if (variables == null) + variables = new Collection (); + + return variables; + } + } + } + + public struct InstructionSymbol { + + public readonly int Offset; + public readonly SequencePoint SequencePoint; + + public InstructionSymbol (int offset, SequencePoint sequencePoint) + { + this.Offset = offset; + this.SequencePoint = sequencePoint; + } + } + + public sealed class MethodSymbols { + + internal int code_size; + internal string method_name; + internal MetadataToken method_token; + internal MetadataToken local_var_token; + internal Collection variables; + internal Collection instructions; + + public bool HasVariables { + get { return !variables.IsNullOrEmpty (); } + } + + public Collection Variables { + get { + if (variables == null) + variables = new Collection (); + + return variables; + } + } + + public Collection Instructions { + get { + if (instructions == null) + instructions = new Collection (); + + return instructions; + } + } + + public int CodeSize { + get { return code_size; } + } + + public string MethodName { + get { return method_name; } + } + + public MetadataToken MethodToken { + get { return method_token; } + } + + public MetadataToken LocalVarToken { + get { return local_var_token; } + } + + public MethodSymbols (string methodName) + { + this.method_name = methodName; + } + } + + public delegate Instruction InstructionMapper (int offset); + + public interface ISymbolReader : IDisposable { + + bool ProcessDebugHeader (ImageDebugDirectory directory, byte [] header); + void Read (MethodBody body, InstructionMapper mapper); + void Read (MethodSymbols symbols); + } + + public interface ISymbolReaderProvider { + + ISymbolReader GetSymbolReader (ModuleDefinition module, string fileName); + ISymbolReader GetSymbolReader (ModuleDefinition module, Stream symbolStream); + } + + static class SymbolProvider { + + static readonly string symbol_kind = Type.GetType ("Mono.Runtime") != null ? "Mdb" : "Pdb"; + + static SR.AssemblyName GetPlatformSymbolAssemblyName () + { + var cecil_name = typeof (SymbolProvider).Assembly.GetName (); + + var name = new SR.AssemblyName { + Name = "Mono.Cecil." + symbol_kind, + Version = cecil_name.Version, + }; + + name.SetPublicKeyToken (cecil_name.GetPublicKeyToken ()); + + return name; + } + + static Type GetPlatformType (string fullname) + { + var type = Type.GetType (fullname); + if (type != null) + return type; + + var assembly_name = GetPlatformSymbolAssemblyName (); + + type = Type.GetType (fullname + ", " + assembly_name.FullName); + if (type != null) + return type; + + try { + var assembly = SR.Assembly.Load (assembly_name); + if (assembly != null) + return assembly.GetType (fullname); + } catch (FileNotFoundException) { +#if !CF + } catch (FileLoadException) { +#endif + } + + return null; + } + + static ISymbolReaderProvider reader_provider; + + public static ISymbolReaderProvider GetPlatformReaderProvider () + { + if (reader_provider != null) + return reader_provider; + + var type = GetPlatformType (GetProviderTypeName ("ReaderProvider")); + if (type == null) + return null; + + return reader_provider = (ISymbolReaderProvider) Activator.CreateInstance (type); + } + + static string GetProviderTypeName (string name) + { + return "Mono.Cecil." + symbol_kind + "." + symbol_kind + name; + } + +#if !READ_ONLY + + static ISymbolWriterProvider writer_provider; + + public static ISymbolWriterProvider GetPlatformWriterProvider () + { + if (writer_provider != null) + return writer_provider; + + var type = GetPlatformType (GetProviderTypeName ("WriterProvider")); + if (type == null) + return null; + + return writer_provider = (ISymbolWriterProvider) Activator.CreateInstance (type); + } + +#endif + } + +#if !READ_ONLY + + public interface ISymbolWriter : IDisposable { + + bool GetDebugHeader (out ImageDebugDirectory directory, out byte [] header); + void Write (MethodBody body); + void Write (MethodSymbols symbols); + } + + public interface ISymbolWriterProvider { + + ISymbolWriter GetSymbolWriter (ModuleDefinition module, string fileName); + ISymbolWriter GetSymbolWriter (ModuleDefinition module, Stream symbolStream); + } + +#endif +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/SymbolStoreHelper.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/SymbolStoreHelper.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/SymbolStoreHelper.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/SymbolStoreHelper.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -// -// SymbolStoreHelper.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2006 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - using System; - using SR = System.Reflection; - - class SymbolStoreHelper { - - static readonly string MonoSymbolSupport = "Mono.Cecil.Mdb.MdbFactory, Mono.Cecil.Mdb"; - static readonly string DotNetSymbolSupport = "Mono.Cecil.Pdb.PdbFactory, Mono.Cecil.Pdb"; - - static ISymbolStoreFactory s_factory; - - SymbolStoreHelper () - { - } - - public static ISymbolReader GetReader (ModuleDefinition module) - { - InitFactory (); - - return s_factory.CreateReader (module, module.Image.FileInformation.FullName); - } - - public static ISymbolWriter GetWriter (ModuleDefinition module, string assemblyFileName) - { - InitFactory (); - - return s_factory.CreateWriter (module, assemblyFileName); - } - - static void InitFactory () - { - if (s_factory != null) - return; - - Type factoryType = Type.GetType (OnMono () ? - MonoSymbolSupport : - DotNetSymbolSupport, - true); - - s_factory = (ISymbolStoreFactory) Activator.CreateInstance (factoryType); - } - - static bool OnMono () - { - return typeof (object).Assembly.GetType ("System.MonoType", false) != null; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableDefinitionCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableDefinitionCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableDefinitionCollection.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableDefinitionCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ -// -// VariableDefinitionCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Wed Sep 27 12:46:53 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Cil { - - using System; - using System.Collections; - - using Mono.Cecil.Cil; - - public sealed class VariableDefinitionCollection : CollectionBase, ICodeVisitable { - - IVariableDefinitionProvider m_container; - - public VariableDefinition this [int index] { - get { return List [index] as VariableDefinition; } - set { List [index] = value; } - } - - public IVariableDefinitionProvider Container { - get { return m_container; } - } - - public VariableDefinitionCollection (IVariableDefinitionProvider container) - { - m_container = container; - } - - public void Add (VariableDefinition value) - { - List.Add (value); - } - - public bool Contains (VariableDefinition value) - { - return List.Contains (value); - } - - public int IndexOf (VariableDefinition value) - { - return List.IndexOf (value); - } - - public void Insert (int index, VariableDefinition value) - { - List.Insert (index, value); - } - - public void Remove (VariableDefinition value) - { - List.Remove (value); - } - - protected override void OnValidate (object o) - { - if (! (o is VariableDefinition)) - throw new ArgumentException ("Must be of type " + typeof (VariableDefinition).FullName); - } - - public void Accept (ICodeVisitor visitor) - { - visitor.VisitVariableDefinitionCollection (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableDefinition.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableDefinition.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableDefinition.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableDefinition.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -30,26 +30,23 @@ public sealed class VariableDefinition : VariableReference { - MethodDefinition m_method; - - public MethodDefinition Method { - get { return m_method; } - set { m_method = value; } + public bool IsPinned { + get { return variable_type.IsPinned; } } - public VariableDefinition (TypeReference variableType) : base (variableType) + public VariableDefinition (TypeReference variableType) + : base (variableType) { } - public VariableDefinition (string name, int index, MethodDefinition method, TypeReference variableType) : - base (name, index, variableType) + public VariableDefinition (string name, TypeReference variableType) + : base (name, variableType) { - m_method = method; } - public override void Accept (ICodeVisitor visitor) + public override VariableDefinition Resolve () { - visitor.VisitVariableDefinition (this); + return this; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableReference.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableReference.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableReference.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableReference.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -28,46 +28,48 @@ namespace Mono.Cecil.Cil { - public abstract class VariableReference : ICodeVisitable { + public abstract class VariableReference { - string m_name; - int m_index; - TypeReference m_variableType; + string name; + internal int index = -1; + protected TypeReference variable_type; public string Name { - get { return m_name; } - set { m_name = value; } + get { return name; } + set { name = value; } } - public int Index { - get { return m_index; } - set { m_index = value; } + public TypeReference VariableType { + get { return variable_type; } + set { variable_type = value; } } - public TypeReference VariableType { - get { return m_variableType; } - set { m_variableType = value; } + public int Index { + get { return index; } } - public VariableReference (TypeReference variableType) + internal VariableReference (TypeReference variable_type) + : this (string.Empty, variable_type) { - m_variableType = variableType; } - public VariableReference (string name, int index, TypeReference variableType) : this (variableType) + internal VariableReference (string name, TypeReference variable_type) { - m_name = name; - m_index = index; + this.name = name; + this.variable_type = variable_type; } + public abstract VariableDefinition Resolve (); + public override string ToString () { - if (m_name != null && m_name.Length > 0) - return m_name; + if (!string.IsNullOrEmpty (name)) + return name; - return string.Concat ("V_", m_index); - } + if (index >= 0) + return "V_" + index; - public abstract void Accept (ICodeVisitor visitor); + return string.Empty; + } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Assembly.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Assembly.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Assembly.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Assembly.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -// -// AssemblyTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:25 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using Mono.Cecil; - - public sealed class AssemblyTable : IMetadataTable { - - public const int RId = 0x20; - - RowCollection m_rows; - - public AssemblyRow this [int index] { - get { return m_rows [index] as AssemblyRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal AssemblyTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitAssemblyTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class AssemblyRow : IMetadataRow { - - public AssemblyHashAlgorithm HashAlgId; - public ushort MajorVersion; - public ushort MinorVersion; - public ushort BuildNumber; - public ushort RevisionNumber; - public AssemblyFlags Flags; - public uint PublicKey; - public uint Name; - public uint Culture; - - internal AssemblyRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitAssemblyRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyOS.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyOS.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyOS.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyOS.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -// -// AssemblyOSTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:25 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class AssemblyOSTable : IMetadataTable { - - public const int RId = 0x22; - - RowCollection m_rows; - - public AssemblyOSRow this [int index] { - get { return m_rows [index] as AssemblyOSRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal AssemblyOSTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitAssemblyOSTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class AssemblyOSRow : IMetadataRow { - - public uint OSPlatformID; - public uint OSMajorVersion; - public uint OSMinorVersion; - - internal AssemblyOSRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitAssemblyOSRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyProcessor.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyProcessor.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyProcessor.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyProcessor.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -// -// AssemblyProcessorTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:25 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class AssemblyProcessorTable : IMetadataTable { - - public const int RId = 0x21; - - RowCollection m_rows; - - public AssemblyProcessorRow this [int index] { - get { return m_rows [index] as AssemblyProcessorRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal AssemblyProcessorTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitAssemblyProcessorTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class AssemblyProcessorRow : IMetadataRow { - - public uint Processor; - - internal AssemblyProcessorRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitAssemblyProcessorRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyRef.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyRef.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyRef.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyRef.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -// -// AssemblyRefTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:25 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using Mono.Cecil; - - public sealed class AssemblyRefTable : IMetadataTable { - - public const int RId = 0x23; - - RowCollection m_rows; - - public AssemblyRefRow this [int index] { - get { return m_rows [index] as AssemblyRefRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal AssemblyRefTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitAssemblyRefTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class AssemblyRefRow : IMetadataRow { - - public ushort MajorVersion; - public ushort MinorVersion; - public ushort BuildNumber; - public ushort RevisionNumber; - public AssemblyFlags Flags; - public uint PublicKeyOrToken; - public uint Name; - public uint Culture; - public uint HashValue; - - internal AssemblyRefRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitAssemblyRefRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyRefOS.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyRefOS.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyRefOS.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyRefOS.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -// -// AssemblyRefOSTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:25 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class AssemblyRefOSTable : IMetadataTable { - - public const int RId = 0x25; - - RowCollection m_rows; - - public AssemblyRefOSRow this [int index] { - get { return m_rows [index] as AssemblyRefOSRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal AssemblyRefOSTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitAssemblyRefOSTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class AssemblyRefOSRow : IMetadataRow { - - public uint OSPlatformID; - public uint OSMajorVersion; - public uint OSMinorVersion; - public uint AssemblyRef; - - internal AssemblyRefOSRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitAssemblyRefOSRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyRefProcessor.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyRefProcessor.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyRefProcessor.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyRefProcessor.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -// -// AssemblyRefProcessorTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:25 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class AssemblyRefProcessorTable : IMetadataTable { - - public const int RId = 0x24; - - RowCollection m_rows; - - public AssemblyRefProcessorRow this [int index] { - get { return m_rows [index] as AssemblyRefProcessorRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal AssemblyRefProcessorTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitAssemblyRefProcessorTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class AssemblyRefProcessorRow : IMetadataRow { - - public uint Processor; - public uint AssemblyRef; - - internal AssemblyRefProcessorRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitAssemblyRefProcessorRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/BaseMetadataVisitor.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/BaseMetadataVisitor.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/BaseMetadataVisitor.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/BaseMetadataVisitor.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,448 +0,0 @@ -// -// BaseMetadataVisitor.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Thu Feb 22 14:39:38 CET 2007 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public abstract class BaseMetadataVisitor : IMetadataVisitor { - - public virtual void VisitMetadataRoot (MetadataRoot root) - { - } - - public virtual void VisitMetadataRootHeader (MetadataRoot.MetadataRootHeader header) - { - } - - public virtual void VisitMetadataStreamCollection (MetadataStreamCollection streams) - { - } - - public virtual void VisitMetadataStream (MetadataStream stream) - { - } - - public virtual void VisitMetadataStreamHeader (MetadataStream.MetadataStreamHeader header) - { - } - - public virtual void VisitGuidHeap (GuidHeap heap) - { - } - - public virtual void VisitStringsHeap (StringsHeap heap) - { - } - - public virtual void VisitTablesHeap (TablesHeap heap) - { - } - - public virtual void VisitBlobHeap (BlobHeap heap) - { - } - - public virtual void VisitUserStringsHeap (UserStringsHeap heap) - { - } - - public virtual void TerminateMetadataRoot (MetadataRoot root) - { - } - } - - public abstract class BaseMetadataTableVisitor : IMetadataTableVisitor { - - public virtual void VisitTableCollection (TableCollection coll) - { - } - - public virtual void VisitAssemblyTable (AssemblyTable table) - { - } - - public virtual void VisitAssemblyOSTable (AssemblyOSTable table) - { - } - - public virtual void VisitAssemblyProcessorTable (AssemblyProcessorTable table) - { - } - - public virtual void VisitAssemblyRefTable (AssemblyRefTable table) - { - } - - public virtual void VisitAssemblyRefOSTable (AssemblyRefOSTable table) - { - } - - public virtual void VisitAssemblyRefProcessorTable (AssemblyRefProcessorTable table) - { - } - - public virtual void VisitClassLayoutTable (ClassLayoutTable table) - { - } - - public virtual void VisitConstantTable (ConstantTable table) - { - } - - public virtual void VisitCustomAttributeTable (CustomAttributeTable table) - { - } - - public virtual void VisitDeclSecurityTable (DeclSecurityTable table) - { - } - - public virtual void VisitEventTable (EventTable table) - { - } - - public virtual void VisitEventMapTable (EventMapTable table) - { - } - - public virtual void VisitEventPtrTable (EventPtrTable table) - { - } - - public virtual void VisitExportedTypeTable (ExportedTypeTable table) - { - } - - public virtual void VisitFieldTable (FieldTable table) - { - } - - public virtual void VisitFieldLayoutTable (FieldLayoutTable table) - { - } - - public virtual void VisitFieldMarshalTable (FieldMarshalTable table) - { - } - - public virtual void VisitFieldPtrTable (FieldPtrTable table) - { - } - - public virtual void VisitFieldRVATable (FieldRVATable table) - { - } - - public virtual void VisitFileTable (FileTable table) - { - } - - public virtual void VisitGenericParamTable (GenericParamTable table) - { - } - - public virtual void VisitGenericParamConstraintTable (GenericParamConstraintTable table) - { - } - - public virtual void VisitImplMapTable (ImplMapTable table) - { - } - - public virtual void VisitInterfaceImplTable (InterfaceImplTable table) - { - } - - public virtual void VisitManifestResourceTable (ManifestResourceTable table) - { - } - - public virtual void VisitMemberRefTable (MemberRefTable table) - { - } - - public virtual void VisitMethodTable (MethodTable table) - { - } - - public virtual void VisitMethodImplTable (MethodImplTable table) - { - } - - public virtual void VisitMethodPtrTable (MethodPtrTable table) - { - } - - public virtual void VisitMethodSemanticsTable (MethodSemanticsTable table) - { - } - - public virtual void VisitMethodSpecTable (MethodSpecTable table) - { - } - - public virtual void VisitModuleTable (ModuleTable table) - { - } - - public virtual void VisitModuleRefTable (ModuleRefTable table) - { - } - - public virtual void VisitNestedClassTable (NestedClassTable table) - { - } - - public virtual void VisitParamTable (ParamTable table) - { - } - - public virtual void VisitParamPtrTable (ParamPtrTable table) - { - } - - public virtual void VisitPropertyTable (PropertyTable table) - { - } - - public virtual void VisitPropertyMapTable (PropertyMapTable table) - { - } - - public virtual void VisitPropertyPtrTable (PropertyPtrTable table) - { - } - - public virtual void VisitStandAloneSigTable (StandAloneSigTable table) - { - } - - public virtual void VisitTypeDefTable (TypeDefTable table) - { - } - - public virtual void VisitTypeRefTable (TypeRefTable table) - { - } - - public virtual void VisitTypeSpecTable (TypeSpecTable table) - { - } - - public virtual void TerminateTableCollection (TableCollection coll) - { - } - - public abstract IMetadataRowVisitor GetRowVisitor(); - } - - public abstract class BaseMetadataRowVisitor : IMetadataRowVisitor { - - public virtual void VisitRowCollection (RowCollection coll) - { - } - - public virtual void VisitAssemblyRow (AssemblyRow row) - { - } - - public virtual void VisitAssemblyOSRow (AssemblyOSRow row) - { - } - - public virtual void VisitAssemblyProcessorRow (AssemblyProcessorRow row) - { - } - - public virtual void VisitAssemblyRefRow (AssemblyRefRow row) - { - } - - public virtual void VisitAssemblyRefOSRow (AssemblyRefOSRow row) - { - } - - public virtual void VisitAssemblyRefProcessorRow (AssemblyRefProcessorRow row) - { - } - - public virtual void VisitClassLayoutRow (ClassLayoutRow row) - { - } - - public virtual void VisitConstantRow (ConstantRow row) - { - } - - public virtual void VisitCustomAttributeRow (CustomAttributeRow row) - { - } - - public virtual void VisitDeclSecurityRow (DeclSecurityRow row) - { - } - - public virtual void VisitEventRow (EventRow row) - { - } - - public virtual void VisitEventMapRow (EventMapRow row) - { - } - - public virtual void VisitEventPtrRow (EventPtrRow row) - { - } - - public virtual void VisitExportedTypeRow (ExportedTypeRow row) - { - } - - public virtual void VisitFieldRow (FieldRow row) - { - } - - public virtual void VisitFieldLayoutRow (FieldLayoutRow row) - { - } - - public virtual void VisitFieldMarshalRow (FieldMarshalRow row) - { - } - - public virtual void VisitFieldPtrRow (FieldPtrRow row) - { - } - - public virtual void VisitFieldRVARow (FieldRVARow row) - { - } - - public virtual void VisitFileRow (FileRow row) - { - } - - public virtual void VisitGenericParamRow (GenericParamRow row) - { - } - - public virtual void VisitGenericParamConstraintRow (GenericParamConstraintRow row) - { - } - - public virtual void VisitImplMapRow (ImplMapRow row) - { - } - - public virtual void VisitInterfaceImplRow (InterfaceImplRow row) - { - } - - public virtual void VisitManifestResourceRow (ManifestResourceRow row) - { - } - - public virtual void VisitMemberRefRow (MemberRefRow row) - { - } - - public virtual void VisitMethodRow (MethodRow row) - { - } - - public virtual void VisitMethodImplRow (MethodImplRow row) - { - } - - public virtual void VisitMethodPtrRow (MethodPtrRow row) - { - } - - public virtual void VisitMethodSemanticsRow (MethodSemanticsRow row) - { - } - - public virtual void VisitMethodSpecRow (MethodSpecRow row) - { - } - - public virtual void VisitModuleRow (ModuleRow row) - { - } - - public virtual void VisitModuleRefRow (ModuleRefRow row) - { - } - - public virtual void VisitNestedClassRow (NestedClassRow row) - { - } - - public virtual void VisitParamRow (ParamRow row) - { - } - - public virtual void VisitParamPtrRow (ParamPtrRow row) - { - } - - public virtual void VisitPropertyRow (PropertyRow row) - { - } - - public virtual void VisitPropertyMapRow (PropertyMapRow row) - { - } - - public virtual void VisitPropertyPtrRow (PropertyPtrRow row) - { - } - - public virtual void VisitStandAloneSigRow (StandAloneSigRow row) - { - } - - public virtual void VisitTypeDefRow (TypeDefRow row) - { - } - - public virtual void VisitTypeRefRow (TypeRefRow row) - { - } - - public virtual void VisitTypeSpecRow (TypeSpecRow row) - { - } - - public virtual void TerminateRowCollection (RowCollection coll) - { - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/BlobHeap.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/BlobHeap.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/BlobHeap.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/BlobHeap.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,29 +26,34 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil.Metadata { +using System; + +using Mono.Cecil.PE; - using System.IO; +namespace Mono.Cecil.Metadata { - public class BlobHeap : MetadataHeap { + sealed class BlobHeap : Heap { - internal BlobHeap (MetadataStream stream) : base (stream, MetadataStream.Blob) + public BlobHeap (Section section, uint start, uint size) + : base (section, start, size) { } public byte [] Read (uint index) { - return ReadBytesFromStream (index); - } + if (index == 0 || index > Size - 1) + return Empty.Array; - public BinaryReader GetReader (uint index) - { - return new BinaryReader (new MemoryStream (Read (index))); - } + var data = Section.Data; - public override void Accept (IMetadataVisitor visitor) - { - visitor.VisitBlobHeap (this); + int position = (int) (index + Offset); + int length = (int) data.ReadCompressedUInt32 (ref position); + + var buffer = new byte [length]; + + Buffer.BlockCopy (data, position, buffer, 0, length); + + return buffer; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Buffers.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Buffers.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Buffers.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Buffers.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,373 @@ +// +// TableHeapBuffer.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Collections.Generic; +using System.Text; + +using Mono.Cecil.PE; + +using RVA = System.UInt32; + +#if !READ_ONLY + +namespace Mono.Cecil.Metadata { + + sealed class TableHeapBuffer : HeapBuffer { + + readonly ModuleDefinition module; + readonly MetadataBuilder metadata; + + internal MetadataTable [] tables = new MetadataTable [45]; + + bool large_string; + bool large_blob; + readonly int [] coded_index_sizes = new int [13]; + readonly Func counter; + + public override bool IsEmpty { + get { return false; } + } + + public TableHeapBuffer (ModuleDefinition module, MetadataBuilder metadata) + : base (24) + { + this.module = module; + this.metadata = metadata; + this.counter = GetTableLength; + } + + int GetTableLength (Table table) + { + var md_table = tables [(int) table]; + return md_table != null ? md_table.Length : 0; + } + + public TTable GetTable (Table table) where TTable : MetadataTable, new () + { + var md_table = (TTable) tables [(int) table]; + if (md_table != null) + return md_table; + + md_table = new TTable (); + tables [(int) table] = md_table; + return md_table; + } + + public void WriteBySize (uint value, int size) + { + if (size == 4) + WriteUInt32 (value); + else + WriteUInt16 ((ushort) value); + } + + public void WriteBySize (uint value, bool large) + { + if (large) + WriteUInt32 (value); + else + WriteUInt16 ((ushort) value); + } + + public void WriteString (uint @string) + { + WriteBySize (@string, large_string); + } + + public void WriteBlob (uint blob) + { + WriteBySize (blob, large_blob); + } + + public void WriteRID (uint rid, Table table) + { + var md_table = tables [(int) table]; + WriteBySize (rid, md_table == null ? false : md_table.IsLarge); + } + + int GetCodedIndexSize (CodedIndex coded_index) + { + var index = (int) coded_index; + var size = coded_index_sizes [index]; + if (size != 0) + return size; + + return coded_index_sizes [index] = coded_index.GetSize (counter); + } + + public void WriteCodedRID (uint rid, CodedIndex coded_index) + { + WriteBySize (rid, GetCodedIndexSize (coded_index)); + } + + public void WriteTableHeap () + { + WriteUInt32 (0); // Reserved + WriteByte (GetTableHeapVersion ()); // MajorVersion + WriteByte (0); // MinorVersion + WriteByte (GetHeapSizes ()); // HeapSizes + WriteByte (10); // Reserved2 + WriteUInt64 (GetValid ()); // Valid + WriteUInt64 (0x0016003301fa00); // Sorted + + WriteRowCount (); + WriteTables (); + } + + void WriteRowCount () + { + for (int i = 0; i < tables.Length; i++) { + var table = tables [i]; + if (table == null || table.Length == 0) + continue; + + WriteUInt32 ((uint) table.Length); + } + } + + void WriteTables () + { + for (int i = 0; i < tables.Length; i++) { + var table = tables [i]; + if (table == null || table.Length == 0) + continue; + + table.Write (this); + } + } + + ulong GetValid () + { + ulong valid = 0; + + for (int i = 0; i < tables.Length; i++) { + var table = tables [i]; + if (table == null || table.Length == 0) + continue; + + table.Sort (); + valid |= (1UL << i); + } + + return valid; + } + + byte GetHeapSizes () + { + byte heap_sizes = 0; + + if (metadata.string_heap.IsLarge) { + large_string = true; + heap_sizes |= 0x01; + } + + if (metadata.blob_heap.IsLarge) { + large_blob = true; + heap_sizes |= 0x04; + } + + return heap_sizes; + } + + byte GetTableHeapVersion () + { + switch (module.Runtime) { + case TargetRuntime.Net_1_0: + case TargetRuntime.Net_1_1: + return 1; + default: + return 2; + } + } + + public void FixupData (RVA data_rva) + { + var table = GetTable (Table.FieldRVA); + if (table.length == 0) + return; + + var field_idx_size = GetTable (Table.Field).IsLarge ? 4 : 2; + var previous = this.position; + + base.position = table.position; + for (int i = 0; i < table.length; i++) { + var rva = ReadUInt32 (); + base.position -= 4; + WriteUInt32 (rva + data_rva); + base.position += field_idx_size; + } + + base.position = previous; + } + } + + sealed class ResourceBuffer : ByteBuffer { + + public ResourceBuffer () + : base (0) + { + } + + public uint AddResource (byte [] resource) + { + var offset = (uint) this.position; + WriteInt32 (resource.Length); + WriteBytes (resource); + return offset; + } + } + + sealed class DataBuffer : ByteBuffer { + + public DataBuffer () + : base (0) + { + } + + public RVA AddData (byte [] data) + { + var rva = (RVA) position; + WriteBytes (data); + return rva; + } + } + + abstract class HeapBuffer : ByteBuffer { + + public bool IsLarge { + get { return base.length > 65536; } + } + + public abstract bool IsEmpty { get; } + + protected HeapBuffer (int length) + : base (length) + { + } + } + + class StringHeapBuffer : HeapBuffer { + + readonly Dictionary strings = new Dictionary (); + + public sealed override bool IsEmpty { + get { return length <= 1; } + } + + public StringHeapBuffer () + : base (1) + { + WriteByte (0); + } + + public uint GetStringIndex (string @string) + { + uint index; + if (strings.TryGetValue (@string, out index)) + return index; + + index = (uint) base.position; + WriteString (@string); + strings.Add (@string, index); + return index; + } + + protected virtual void WriteString (string @string) + { + WriteBytes (Encoding.UTF8.GetBytes (@string)); + WriteByte (0); + } + } + + sealed class BlobHeapBuffer : HeapBuffer { + + readonly Dictionary blobs = new Dictionary (new ByteBufferEqualityComparer ()); + + public override bool IsEmpty { + get { return length <= 1; } + } + + public BlobHeapBuffer () + : base (1) + { + WriteByte (0); + } + + public uint GetBlobIndex (ByteBuffer blob) + { + uint index; + if (blobs.TryGetValue (blob, out index)) + return index; + + index = (uint) base.position; + WriteBlob (blob); + blobs.Add (blob, index); + return index; + } + + void WriteBlob (ByteBuffer blob) + { + WriteCompressedUInt32 ((uint) blob.length); + WriteBytes (blob); + } + } + + sealed class UserStringHeapBuffer : StringHeapBuffer { + + protected override void WriteString (string @string) + { + WriteCompressedUInt32 ((uint) @string.Length * 2 + 1); + + byte special = 0; + + for (int i = 0; i < @string.Length; i++) { + var @char = @string [i]; + WriteUInt16 (@char); + + if (special == 1) + continue; + + if (@char < 0x20 || @char > 0x7e) { + if (@char > 0x7e + || (@char >= 0x01 && @char <= 0x08) + || (@char >= 0x0e && @char <= 0x1f) + || @char == 0x27 + || @char == 0x2d) { + + special = 1; + } + } + } + + WriteByte (special); + } + } +} + +#endif diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ClassLayout.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ClassLayout.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ClassLayout.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ClassLayout.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -// -// ClassLayoutTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:25 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class ClassLayoutTable : IMetadataTable { - - public const int RId = 0x0f; - - RowCollection m_rows; - - public ClassLayoutRow this [int index] { - get { return m_rows [index] as ClassLayoutRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal ClassLayoutTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitClassLayoutTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class ClassLayoutRow : IMetadataRow { - - public ushort PackingSize; - public uint ClassSize; - public uint Parent; - - internal ClassLayoutRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitClassLayoutRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/CodedIndex.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/CodedIndex.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/CodedIndex.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/CodedIndex.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,10 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Mar 20 16:02:16 +0100 2007 -// -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -31,7 +28,7 @@ namespace Mono.Cecil.Metadata { - public enum CodedIndex { + enum CodedIndex { TypeDefOrRef, HasConstant, HasCustomAttribute, diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Constant.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Constant.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Constant.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Constant.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -// -// ConstantTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:25 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class ConstantTable : IMetadataTable { - - public const int RId = 0x0b; - - RowCollection m_rows; - - public ConstantRow this [int index] { - get { return m_rows [index] as ConstantRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal ConstantTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitConstantTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class ConstantRow : IMetadataRow { - - public ElementType Type; - public MetadataToken Parent; - public uint Value; - - internal ConstantRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitConstantRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/CultureUtils.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/CultureUtils.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/CultureUtils.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/CultureUtils.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -// -// CultureUtils.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using System; - using System.Collections; - using System.Globalization; - - class CultureUtils { - - static IDictionary m_cultures; - - CultureUtils () - { - } - - static void LoadCultures () - { - if (m_cultures != null) - return; - -#if CF_1_0 || CF_2_0 - CultureInfo [] cultures = new CultureInfo [0]; -#else - CultureInfo [] cultures = CultureInfo.GetCultures (CultureTypes.AllCultures); -#endif - m_cultures = new Hashtable (cultures.Length + 2); - - foreach (CultureInfo ci in cultures) - if (!m_cultures.Contains (ci.Name)) - m_cultures.Add (ci.Name, ci); - - if (!m_cultures.Contains (string.Empty)) - m_cultures.Add (string.Empty, CultureInfo.InvariantCulture); - - m_cultures.Add ("neutral", CultureInfo.InvariantCulture); - } - - public static bool IsValid (string culture) - { - if (culture == null) - throw new ArgumentNullException ("culture"); - - LoadCultures (); - - return m_cultures.Contains (culture); - } - - public static CultureInfo GetCultureInfo (string culture) - { - if (IsValid (culture)) - return m_cultures [culture] as CultureInfo; - - return CultureInfo.InvariantCulture; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/CustomAttribute.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/CustomAttribute.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/CustomAttribute.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/CustomAttribute.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -// -// CustomAttributeTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:25 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class CustomAttributeTable : IMetadataTable { - - public const int RId = 0x0c; - - RowCollection m_rows; - - public CustomAttributeRow this [int index] { - get { return m_rows [index] as CustomAttributeRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal CustomAttributeTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitCustomAttributeTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class CustomAttributeRow : IMetadataRow { - - public MetadataToken Parent; - public MetadataToken Type; - public uint Value; - - internal CustomAttributeRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitCustomAttributeRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/DeclSecurity.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/DeclSecurity.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/DeclSecurity.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/DeclSecurity.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -// -// DeclSecurityTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using Mono.Cecil; - - public sealed class DeclSecurityTable : IMetadataTable { - - public const int RId = 0x0e; - - RowCollection m_rows; - - public DeclSecurityRow this [int index] { - get { return m_rows [index] as DeclSecurityRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal DeclSecurityTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitDeclSecurityTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class DeclSecurityRow : IMetadataRow { - - public SecurityAction Action; - public MetadataToken Parent; - public uint PermissionSet; - - internal DeclSecurityRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitDeclSecurityRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ElementType.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ElementType.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ElementType.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ElementType.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -28,46 +28,46 @@ namespace Mono.Cecil.Metadata { - public enum ElementType { - End = 0x00, // Marks end of a list - Void = 0x01, - Boolean = 0x02, - Char = 0x03, - I1 = 0x04, - U1 = 0x05, - I2 = 0x06, - U2 = 0x07, - I4 = 0x08, - U4 = 0x09, - I8 = 0x0a, - U8 = 0x0b, - R4 = 0x0c, - R8 = 0x0d, - String = 0x0e, - Ptr = 0x0f, // Followed by token - ByRef = 0x10, // Followed by token - ValueType = 0x11, // Followed by token - Class = 0x12, // Followed by token - Var = 0x13, // Followed by generic parameter number - Array = 0x14, // + enum ElementType : byte { + None = 0x00, + Void = 0x01, + Boolean = 0x02, + Char = 0x03, + I1 = 0x04, + U1 = 0x05, + I2 = 0x06, + U2 = 0x07, + I4 = 0x08, + U4 = 0x09, + I8 = 0x0a, + U8 = 0x0b, + R4 = 0x0c, + R8 = 0x0d, + String = 0x0e, + Ptr = 0x0f, // Followed by token + ByRef = 0x10, // Followed by token + ValueType = 0x11, // Followed by token + Class = 0x12, // Followed by token + Var = 0x13, // Followed by generic parameter number + Array = 0x14, // GenericInst = 0x15, // ... */ - TypedByRef = 0x16, - I = 0x18, // System.IntPtr - U = 0x19, // System.UIntPtr - FnPtr = 0x1b, // Followed by full method signature - Object = 0x1c, // System.Object - SzArray = 0x1d, // Single-dim array with 0 lower bound - MVar = 0x1e, // Followed by generic parameter number - CModReqD = 0x1f, // Required modifier : followed by a TypeDef or TypeRef token - CModOpt = 0x20, // Optional modifier : followed by a TypeDef or TypeRef token - Internal = 0x21, // Implemented within the CLI - Modifier = 0x40, // Or'd with following element types - Sentinel = 0x41, // Sentinel for varargs method signature - Pinned = 0x45, // Denotes a local variable that points at a pinned object + TypedByRef = 0x16, + I = 0x18, // System.IntPtr + U = 0x19, // System.UIntPtr + FnPtr = 0x1b, // Followed by full method signature + Object = 0x1c, // System.Object + SzArray = 0x1d, // Single-dim array with 0 lower bound + MVar = 0x1e, // Followed by generic parameter number + CModReqD = 0x1f, // Required modifier : followed by a TypeDef or TypeRef token + CModOpt = 0x20, // Optional modifier : followed by a TypeDef or TypeRef token + Internal = 0x21, // Implemented within the CLI + Modifier = 0x40, // Or'd with following element types + Sentinel = 0x41, // Sentinel for varargs method signature + Pinned = 0x45, // Denotes a local variable that points at a pinned object // special undocumented constants - Type = 0x50, - Boxed = 0x51, - Enum = 0x55 + Type = 0x50, + Boxed = 0x51, + Enum = 0x55 } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Event.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Event.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Event.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Event.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -// -// EventTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using Mono.Cecil; - - public sealed class EventTable : IMetadataTable { - - public const int RId = 0x14; - - RowCollection m_rows; - - public EventRow this [int index] { - get { return m_rows [index] as EventRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal EventTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitEventTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class EventRow : IMetadataRow { - - public EventAttributes EventFlags; - public uint Name; - public MetadataToken EventType; - - internal EventRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitEventRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/EventMap.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/EventMap.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/EventMap.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/EventMap.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -// -// EventMapTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class EventMapTable : IMetadataTable { - - public const int RId = 0x12; - - RowCollection m_rows; - - public EventMapRow this [int index] { - get { return m_rows [index] as EventMapRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal EventMapTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitEventMapTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class EventMapRow : IMetadataRow { - - public uint Parent; - public uint EventList; - - internal EventMapRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitEventMapRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/EventPtr.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/EventPtr.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/EventPtr.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/EventPtr.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -// -// EventPtrTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Thu Feb 22 14:39:38 CET 2007 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class EventPtrTable : IMetadataTable { - - public const int RId = 0x13; - - RowCollection m_rows; - - public EventPtrRow this [int index] { - get { return m_rows [index] as EventPtrRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal EventPtrTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitEventPtrTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class EventPtrRow : IMetadataRow { - - public uint Event; - - internal EventPtrRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitEventPtrRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ExportedType.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ExportedType.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ExportedType.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ExportedType.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -// -// ExportedTypeTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using Mono.Cecil; - - public sealed class ExportedTypeTable : IMetadataTable { - - public const int RId = 0x27; - - RowCollection m_rows; - - public ExportedTypeRow this [int index] { - get { return m_rows [index] as ExportedTypeRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal ExportedTypeTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitExportedTypeTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class ExportedTypeRow : IMetadataRow { - - public TypeAttributes Flags; - public uint TypeDefId; - public uint TypeName; - public uint TypeNamespace; - public MetadataToken Implementation; - - internal ExportedTypeRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitExportedTypeRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Field.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Field.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Field.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Field.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -// -// FieldTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using Mono.Cecil; - - public sealed class FieldTable : IMetadataTable { - - public const int RId = 0x04; - - RowCollection m_rows; - - public FieldRow this [int index] { - get { return m_rows [index] as FieldRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal FieldTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitFieldTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class FieldRow : IMetadataRow { - - public FieldAttributes Flags; - public uint Name; - public uint Signature; - - internal FieldRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitFieldRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldLayout.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldLayout.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldLayout.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldLayout.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -// -// FieldLayoutTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class FieldLayoutTable : IMetadataTable { - - public const int RId = 0x10; - - RowCollection m_rows; - - public FieldLayoutRow this [int index] { - get { return m_rows [index] as FieldLayoutRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal FieldLayoutTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitFieldLayoutTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class FieldLayoutRow : IMetadataRow { - - public uint Offset; - public uint Field; - - internal FieldLayoutRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitFieldLayoutRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldMarshal.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldMarshal.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldMarshal.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldMarshal.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -// -// FieldMarshalTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class FieldMarshalTable : IMetadataTable { - - public const int RId = 0x0d; - - RowCollection m_rows; - - public FieldMarshalRow this [int index] { - get { return m_rows [index] as FieldMarshalRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal FieldMarshalTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitFieldMarshalTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class FieldMarshalRow : IMetadataRow { - - public MetadataToken Parent; - public uint NativeType; - - internal FieldMarshalRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitFieldMarshalRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldPtr.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldPtr.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldPtr.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldPtr.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -// -// FieldPtrTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Thu Feb 22 14:39:38 CET 2007 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class FieldPtrTable : IMetadataTable { - - public const int RId = 0x03; - - RowCollection m_rows; - - public FieldPtrRow this [int index] { - get { return m_rows [index] as FieldPtrRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal FieldPtrTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitFieldPtrTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class FieldPtrRow : IMetadataRow { - - public uint Field; - - internal FieldPtrRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitFieldPtrRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldRVA.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldRVA.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldRVA.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldRVA.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -// -// FieldRVATable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using Mono.Cecil.Binary; - - public sealed class FieldRVATable : IMetadataTable { - - public const int RId = 0x1d; - - RowCollection m_rows; - - public FieldRVARow this [int index] { - get { return m_rows [index] as FieldRVARow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal FieldRVATable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitFieldRVATable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class FieldRVARow : IMetadataRow { - - public RVA RVA; - public uint Field; - - internal FieldRVARow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitFieldRVARow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/File.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/File.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/File.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/File.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -// -// FileTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using Mono.Cecil; - - public sealed class FileTable : IMetadataTable { - - public const int RId = 0x26; - - RowCollection m_rows; - - public FileRow this [int index] { - get { return m_rows [index] as FileRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal FileTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitFileTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class FileRow : IMetadataRow { - - public FileAttributes Flags; - public uint Name; - public uint HashValue; - - internal FileRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitFileRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/GenericParamConstraint.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/GenericParamConstraint.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/GenericParamConstraint.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/GenericParamConstraint.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -// -// GenericParamConstraintTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class GenericParamConstraintTable : IMetadataTable { - - public const int RId = 0x2c; - - RowCollection m_rows; - - public GenericParamConstraintRow this [int index] { - get { return m_rows [index] as GenericParamConstraintRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal GenericParamConstraintTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitGenericParamConstraintTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class GenericParamConstraintRow : IMetadataRow { - - public uint Owner; - public MetadataToken Constraint; - - internal GenericParamConstraintRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitGenericParamConstraintRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/GenericParam.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/GenericParam.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/GenericParam.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/GenericParam.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -// -// GenericParamTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using Mono.Cecil; - - public sealed class GenericParamTable : IMetadataTable { - - public const int RId = 0x2a; - - RowCollection m_rows; - - public GenericParamRow this [int index] { - get { return m_rows [index] as GenericParamRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal GenericParamTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitGenericParamTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class GenericParamRow : IMetadataRow { - - public ushort Number; - public GenericParameterAttributes Flags; - public MetadataToken Owner; - public uint Name; - - internal GenericParamRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitGenericParamRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/GuidHeap.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/GuidHeap.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/GuidHeap.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/GuidHeap.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,49 +26,34 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil.Metadata { +using System; - using System; - using System.Collections; +using Mono.Cecil.PE; - public class GuidHeap : MetadataHeap { +namespace Mono.Cecil.Metadata { - readonly IDictionary m_guids; + sealed class GuidHeap : Heap { - public IDictionary Guids { - get { return m_guids; } + public GuidHeap (Section section, uint start, uint size) + : base (section, start, size) + { } - public GuidHeap (MetadataStream stream) : base (stream, MetadataStream.GUID) + public Guid Read (uint index) { - m_guids = new Hashtable (); - } + if (index == 0) + return new Guid (); - public Guid this [uint index] { - get { - if (index == 0) - return new Guid (new byte [16]); - - int idx = (int) index - 1; - - if (m_guids.Contains (idx)) - return (Guid) m_guids [idx]; - - if (idx + 16 > this.Data.Length) - throw new IndexOutOfRangeException (); - - byte[] buffer = new byte [16]; - Buffer.BlockCopy (this.Data, idx, buffer, 0, 16); - Guid res = new Guid (buffer); - m_guids [idx] = res; - return res; - } - set { m_guids [index] = value; } - } + const int guid_size = 16; + + var buffer = new byte [guid_size]; + + index--; + + Buffer.BlockCopy (Section.Data, (int) (Offset + index), buffer, 0, guid_size); + + return new Guid (buffer); - public override void Accept (IMetadataVisitor visitor) - { - visitor.VisitGuidHeap (this); } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Heap.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Heap.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Heap.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Heap.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,48 @@ +// +// Heap.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using Mono.Cecil.PE; + +namespace Mono.Cecil.Metadata { + + abstract class Heap { + + public int IndexSize; + + public readonly Section Section; + public readonly uint Offset; + public readonly uint Size; + + protected Heap (Section section, uint offset, uint size) + { + this.Section = section; + this.Offset = offset; + this.Size = size; + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataRow.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataRow.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataRow.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataRow.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// -// IMetadataRow.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public interface IMetadataRow : IMetadataRowVisitable { - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataTable.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataTable.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataTable.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataTable.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// -// IMetadataTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public interface IMetadataTable : IMetadataTableVisitable { - int Id { get; } - RowCollection Rows { get; set; } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataVisitable.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataVisitable.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataVisitable.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataVisitable.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// -// IMetadataVisitable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public interface IMetadataVisitable { - void Accept (IMetadataVisitor visitor); - } - - public interface IMetadataTableVisitable { - void Accept (IMetadataTableVisitor visitor); - } - - public interface IMetadataRowVisitable { - void Accept (IMetadataRowVisitor visitor); - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataVisitor.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataVisitor.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataVisitor.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataVisitor.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,149 +0,0 @@ -// -// IMetadataVisitor.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Thu Feb 22 14:39:38 CET 2007 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public interface IMetadataVisitor { - void VisitMetadataRoot (MetadataRoot root); - void VisitMetadataRootHeader (MetadataRoot.MetadataRootHeader header); - void VisitMetadataStreamCollection (MetadataStreamCollection streams); - void VisitMetadataStream (MetadataStream stream); - void VisitMetadataStreamHeader (MetadataStream.MetadataStreamHeader header); - void VisitGuidHeap (GuidHeap heap); - void VisitStringsHeap (StringsHeap heap); - void VisitTablesHeap (TablesHeap heap); - void VisitBlobHeap (BlobHeap heap); - void VisitUserStringsHeap (UserStringsHeap heap); - - void TerminateMetadataRoot (MetadataRoot root); - } - - public interface IMetadataTableVisitor { - void VisitTableCollection (TableCollection coll); - - void VisitAssemblyTable (AssemblyTable table); - void VisitAssemblyOSTable (AssemblyOSTable table); - void VisitAssemblyProcessorTable (AssemblyProcessorTable table); - void VisitAssemblyRefTable (AssemblyRefTable table); - void VisitAssemblyRefOSTable (AssemblyRefOSTable table); - void VisitAssemblyRefProcessorTable (AssemblyRefProcessorTable table); - void VisitClassLayoutTable (ClassLayoutTable table); - void VisitConstantTable (ConstantTable table); - void VisitCustomAttributeTable (CustomAttributeTable table); - void VisitDeclSecurityTable (DeclSecurityTable table); - void VisitEventTable (EventTable table); - void VisitEventMapTable (EventMapTable table); - void VisitEventPtrTable (EventPtrTable table); - void VisitExportedTypeTable (ExportedTypeTable table); - void VisitFieldTable (FieldTable table); - void VisitFieldLayoutTable (FieldLayoutTable table); - void VisitFieldMarshalTable (FieldMarshalTable table); - void VisitFieldPtrTable (FieldPtrTable table); - void VisitFieldRVATable (FieldRVATable table); - void VisitFileTable (FileTable table); - void VisitGenericParamTable (GenericParamTable table); - void VisitGenericParamConstraintTable (GenericParamConstraintTable table); - void VisitImplMapTable (ImplMapTable table); - void VisitInterfaceImplTable (InterfaceImplTable table); - void VisitManifestResourceTable (ManifestResourceTable table); - void VisitMemberRefTable (MemberRefTable table); - void VisitMethodTable (MethodTable table); - void VisitMethodImplTable (MethodImplTable table); - void VisitMethodPtrTable (MethodPtrTable table); - void VisitMethodSemanticsTable (MethodSemanticsTable table); - void VisitMethodSpecTable (MethodSpecTable table); - void VisitModuleTable (ModuleTable table); - void VisitModuleRefTable (ModuleRefTable table); - void VisitNestedClassTable (NestedClassTable table); - void VisitParamTable (ParamTable table); - void VisitParamPtrTable (ParamPtrTable table); - void VisitPropertyTable (PropertyTable table); - void VisitPropertyMapTable (PropertyMapTable table); - void VisitPropertyPtrTable (PropertyPtrTable table); - void VisitStandAloneSigTable (StandAloneSigTable table); - void VisitTypeDefTable (TypeDefTable table); - void VisitTypeRefTable (TypeRefTable table); - void VisitTypeSpecTable (TypeSpecTable table); - - void TerminateTableCollection (TableCollection coll); - IMetadataRowVisitor GetRowVisitor(); -} - - public interface IMetadataRowVisitor { - void VisitRowCollection (RowCollection coll); - - void VisitAssemblyRow (AssemblyRow row); - void VisitAssemblyOSRow (AssemblyOSRow row); - void VisitAssemblyProcessorRow (AssemblyProcessorRow row); - void VisitAssemblyRefRow (AssemblyRefRow row); - void VisitAssemblyRefOSRow (AssemblyRefOSRow row); - void VisitAssemblyRefProcessorRow (AssemblyRefProcessorRow row); - void VisitClassLayoutRow (ClassLayoutRow row); - void VisitConstantRow (ConstantRow row); - void VisitCustomAttributeRow (CustomAttributeRow row); - void VisitDeclSecurityRow (DeclSecurityRow row); - void VisitEventRow (EventRow row); - void VisitEventMapRow (EventMapRow row); - void VisitEventPtrRow (EventPtrRow row); - void VisitExportedTypeRow (ExportedTypeRow row); - void VisitFieldRow (FieldRow row); - void VisitFieldLayoutRow (FieldLayoutRow row); - void VisitFieldMarshalRow (FieldMarshalRow row); - void VisitFieldPtrRow (FieldPtrRow row); - void VisitFieldRVARow (FieldRVARow row); - void VisitFileRow (FileRow row); - void VisitGenericParamRow (GenericParamRow row); - void VisitGenericParamConstraintRow (GenericParamConstraintRow row); - void VisitImplMapRow (ImplMapRow row); - void VisitInterfaceImplRow (InterfaceImplRow row); - void VisitManifestResourceRow (ManifestResourceRow row); - void VisitMemberRefRow (MemberRefRow row); - void VisitMethodRow (MethodRow row); - void VisitMethodImplRow (MethodImplRow row); - void VisitMethodPtrRow (MethodPtrRow row); - void VisitMethodSemanticsRow (MethodSemanticsRow row); - void VisitMethodSpecRow (MethodSpecRow row); - void VisitModuleRow (ModuleRow row); - void VisitModuleRefRow (ModuleRefRow row); - void VisitNestedClassRow (NestedClassRow row); - void VisitParamRow (ParamRow row); - void VisitParamPtrRow (ParamPtrRow row); - void VisitPropertyRow (PropertyRow row); - void VisitPropertyMapRow (PropertyMapRow row); - void VisitPropertyPtrRow (PropertyPtrRow row); - void VisitStandAloneSigRow (StandAloneSigRow row); - void VisitTypeDefRow (TypeDefRow row); - void VisitTypeRefRow (TypeRefRow row); - void VisitTypeSpecRow (TypeSpecRow row); - - void TerminateRowCollection (RowCollection coll); - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ImplMap.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ImplMap.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ImplMap.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ImplMap.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -// -// ImplMapTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using Mono.Cecil; - - public sealed class ImplMapTable : IMetadataTable { - - public const int RId = 0x1c; - - RowCollection m_rows; - - public ImplMapRow this [int index] { - get { return m_rows [index] as ImplMapRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal ImplMapTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitImplMapTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class ImplMapRow : IMetadataRow { - - public PInvokeAttributes MappingFlags; - public MetadataToken MemberForwarded; - public uint ImportName; - public uint ImportScope; - - internal ImplMapRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitImplMapRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/InterfaceImpl.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/InterfaceImpl.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/InterfaceImpl.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/InterfaceImpl.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -// -// InterfaceImplTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class InterfaceImplTable : IMetadataTable { - - public const int RId = 0x09; - - RowCollection m_rows; - - public InterfaceImplRow this [int index] { - get { return m_rows [index] as InterfaceImplRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal InterfaceImplTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitInterfaceImplTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class InterfaceImplRow : IMetadataRow { - - public uint Class; - public MetadataToken Interface; - - internal InterfaceImplRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitInterfaceImplRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ManifestResource.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ManifestResource.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ManifestResource.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ManifestResource.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -// -// ManifestResourceTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using Mono.Cecil; - - public sealed class ManifestResourceTable : IMetadataTable { - - public const int RId = 0x28; - - RowCollection m_rows; - - public ManifestResourceRow this [int index] { - get { return m_rows [index] as ManifestResourceRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal ManifestResourceTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitManifestResourceTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class ManifestResourceRow : IMetadataRow { - - public uint Offset; - public ManifestResourceAttributes Flags; - public uint Name; - public MetadataToken Implementation; - - internal ManifestResourceRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitManifestResourceRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MemberRef.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MemberRef.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MemberRef.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MemberRef.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -// -// MemberRefTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class MemberRefTable : IMetadataTable { - - public const int RId = 0x0a; - - RowCollection m_rows; - - public MemberRefRow this [int index] { - get { return m_rows [index] as MemberRefRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal MemberRefTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitMemberRefTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class MemberRefRow : IMetadataRow { - - public MetadataToken Class; - public uint Name; - public uint Signature; - - internal MemberRefRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitMemberRefRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataFormatException.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataFormatException.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataFormatException.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataFormatException.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -// -// MetadataFormatException.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using System; - - using Mono.Cecil.Binary; - - public class MetadataFormatException : ImageFormatException { - - internal MetadataFormatException () : base () - { - } - - internal MetadataFormatException (string message) : base (message) - { - } - - internal MetadataFormatException (string message, params string [] parameters) : - base (string.Format (message, parameters)) - { - } - - internal MetadataFormatException (string message, Exception inner) : - base (message, inner) - { - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataHeap.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataHeap.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataHeap.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataHeap.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ -// -// MetadataHeap.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using System; - - using Mono.Cecil; - - public abstract class MetadataHeap : IMetadataVisitable { - - MetadataStream m_stream; - string m_name; - byte [] m_data; - - public string Name { - get { return m_name; } - } - - public byte [] Data { - get { return m_data; } - set { m_data = value; } - } - - public int IndexSize; - - internal MetadataHeap (MetadataStream stream, string name) - { - m_name = name; - m_stream = stream; - } - - public static MetadataHeap HeapFactory (MetadataStream stream) - { - switch (stream.Header.Name) { - case MetadataStream.Tables : - case MetadataStream.IncrementalTables : - return new TablesHeap (stream); - case MetadataStream.GUID : - return new GuidHeap (stream); - case MetadataStream.Strings : - return new StringsHeap (stream); - case MetadataStream.UserStrings : - return new UserStringsHeap (stream); - case MetadataStream.Blob : - return new BlobHeap (stream); - default : - return null; - } - } - - public MetadataStream GetStream () - { - return m_stream; - } - - protected virtual byte [] ReadBytesFromStream (uint pos) - { - int start, length = Utilities.ReadCompressedInteger (m_data, (int) pos, out start); - byte [] buffer = new byte [length]; - Buffer.BlockCopy (m_data, start, buffer, 0, length); - return buffer; - } - - public abstract void Accept (IMetadataVisitor visitor); - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataInitializer.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataInitializer.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataInitializer.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataInitializer.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -// -// MetadataInitializer.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using System; - using System.IO; - using System.Text; - - using Mono.Cecil; - using Mono.Cecil.Binary; - - class MetadataInitializer : BaseMetadataVisitor { - - MetadataRoot m_root; - - public MetadataInitializer (ImageInitializer init) - { - m_root = init.Image.MetadataRoot; - } - - public override void VisitMetadataRoot (MetadataRoot root) - { - root.Header = new MetadataRoot.MetadataRootHeader (); - root.Streams = new MetadataStreamCollection (); - } - - public override void VisitMetadataRootHeader (MetadataRoot.MetadataRootHeader header) - { - header.SetDefaultValues (); - } - - public override void VisitMetadataStreamCollection (MetadataStreamCollection coll) - { - MetadataStream tables = new MetadataStream (); - tables.Header.Name = MetadataStream.Tables; - tables.Heap = MetadataHeap.HeapFactory (tables); - TablesHeap th = tables.Heap as TablesHeap; - th.Tables = new TableCollection (th); - m_root.Streams.Add (tables); - } - - public override void VisitTablesHeap (TablesHeap th) - { - th.Reserved = 0; - th.MajorVersion = 1; - th.MinorVersion = 0; - th.Reserved2 = 1; - th.Sorted = 0x2003301fa00; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataReader.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataReader.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataReader.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataReader.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,229 +0,0 @@ -// -// MetadataReader.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using System; - using System.IO; - using System.Text; - - using Mono.Cecil.Binary; - - class MetadataReader : BaseMetadataVisitor { - - ImageReader m_ir; - BinaryReader m_binaryReader; - MetadataTableReader m_tableReader; - MetadataRoot m_root; - - public MetadataTableReader TableReader { - get { return m_tableReader; } - } - - public MetadataReader (ImageReader brv) - { - m_ir = brv; - m_binaryReader = brv.GetReader (); - } - - public MetadataRoot GetMetadataRoot () - { - return m_root; - } - - public BinaryReader GetDataReader (RVA rva) - { - return m_ir.Image.GetReaderAtVirtualAddress (rva); - } - - public override void VisitMetadataRoot (MetadataRoot root) - { - m_root = root; - root.Header = new MetadataRoot.MetadataRootHeader (); - root.Streams = new MetadataStreamCollection (); - } - - public override void VisitMetadataRootHeader (MetadataRoot.MetadataRootHeader header) - { - long headpos = m_binaryReader.BaseStream.Position; - - header.Signature = m_binaryReader.ReadUInt32 (); - - if (header.Signature != MetadataRoot.MetadataRootHeader.StandardSignature) - throw new MetadataFormatException ("Wrong magic number"); - - header.MajorVersion = m_binaryReader.ReadUInt16 (); - header.MinorVersion = m_binaryReader.ReadUInt16 (); - header.Reserved = m_binaryReader.ReadUInt32 (); - - // read version - uint length = m_binaryReader.ReadUInt32 (); - if (length != 0) { - long pos = m_binaryReader.BaseStream.Position; - - byte [] version, buffer = new byte [length]; - int read = 0; - while (read < length) { - byte cur = (byte)m_binaryReader.ReadSByte (); - if (cur == 0) - break; - buffer [read++] = cur; - } - version = new byte [read]; - Buffer.BlockCopy (buffer, 0, version, 0, read); - header.Version = Encoding.UTF8.GetString (version, 0, version.Length); - - pos += length - headpos + 3; - pos &= ~3; - pos += headpos; - - m_binaryReader.BaseStream.Position = pos; - } else - header.Version = string.Empty; - - header.Flags = m_binaryReader.ReadUInt16 (); - header.Streams = m_binaryReader.ReadUInt16 (); - } - - public override void VisitMetadataStreamCollection (MetadataStreamCollection coll) - { - for (int i = 0; i < m_root.Header.Streams; i++) - coll.Add (new MetadataStream ()); - } - - public override void VisitMetadataStreamHeader (MetadataStream.MetadataStreamHeader header) - { - header.Offset = m_binaryReader.ReadUInt32 (); - header.Size = m_binaryReader.ReadUInt32 (); - - StringBuilder buffer = new StringBuilder (); - while (true) { - char cur = (char) m_binaryReader.ReadSByte (); - if (cur == '\0') - break; - buffer.Append (cur); - } - header.Name = buffer.ToString (); - if (header.Name.Length == 0) - throw new MetadataFormatException ("Invalid stream name"); - - long rootpos = m_root.GetImage ().ResolveVirtualAddress ( - m_root.GetImage ().CLIHeader.Metadata.VirtualAddress); - - long curpos = m_binaryReader.BaseStream.Position; - - if (header.Size != 0) - curpos -= rootpos; - - curpos += 3; - curpos &= ~3; - - if (header.Size != 0) - curpos += rootpos; - - m_binaryReader.BaseStream.Position = curpos; - - header.Stream.Heap = MetadataHeap.HeapFactory (header.Stream); - } - - public override void VisitGuidHeap (GuidHeap heap) - { - VisitHeap (heap); - } - - public override void VisitStringsHeap (StringsHeap heap) - { - VisitHeap (heap); - - if (heap.Data.Length < 1 && heap.Data [0] != 0) - throw new MetadataFormatException ("Malformed #Strings heap"); - - heap [(uint) 0] = string.Empty; - } - - public override void VisitTablesHeap (TablesHeap heap) - { - VisitHeap (heap); - heap.Tables = new TableCollection (heap); - - BinaryReader br = new BinaryReader (new MemoryStream (heap.Data)); - try { - heap.Reserved = br.ReadUInt32 (); - heap.MajorVersion = br.ReadByte (); - heap.MinorVersion = br.ReadByte (); - heap.HeapSizes = br.ReadByte (); - heap.Reserved2 = br.ReadByte (); - heap.Valid = br.ReadInt64 (); - heap.Sorted = br.ReadInt64 (); - } finally { - // COMPACT FRAMEWORK NOTE: BinaryReader is not IDisposable - br.Close (); - } - } - - public override void VisitBlobHeap (BlobHeap heap) - { - VisitHeap (heap); - } - - public override void VisitUserStringsHeap (UserStringsHeap heap) - { - VisitHeap (heap); - } - - void VisitHeap (MetadataHeap heap) - { - long cursor = m_binaryReader.BaseStream.Position; - - m_binaryReader.BaseStream.Position = m_root.GetImage ().ResolveVirtualAddress ( - m_root.GetImage ().CLIHeader.Metadata.VirtualAddress) - + heap.GetStream ().Header.Offset; - - heap.Data = m_binaryReader.ReadBytes ((int) heap.GetStream ().Header.Size); - - m_binaryReader.BaseStream.Position = cursor; - } - - void SetHeapIndexSize (MetadataHeap heap, byte flag) - { - if (heap == null) - return; - TablesHeap th = m_root.Streams.TablesHeap; - heap.IndexSize = ((th.HeapSizes & flag) > 0) ? 4 : 2; - } - - public override void TerminateMetadataRoot (MetadataRoot root) - { - SetHeapIndexSize (root.Streams.StringsHeap, 0x01); - SetHeapIndexSize (root.Streams.GuidHeap, 0x02); - SetHeapIndexSize (root.Streams.BlobHeap, 0x04); - m_tableReader = new MetadataTableReader (this); - root.Streams.TablesHeap.Tables.Accept (m_tableReader); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataRoot.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataRoot.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataRoot.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataRoot.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -// -// MetadataRoot.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using Mono.Cecil.Binary; - - public sealed class MetadataRoot : IMetadataVisitable { - - MetadataRootHeader m_header; - Image m_image; - - MetadataStreamCollection m_streams; - - public MetadataRootHeader Header { - get { return m_header; } - set { m_header = value; } - } - - public MetadataStreamCollection Streams { - get { return m_streams; } - set { m_streams = value; } - } - - internal MetadataRoot (Image img) - { - m_image = img; - } - - public Image GetImage () - { - return m_image; - } - - public void Accept (IMetadataVisitor visitor) - { - visitor.VisitMetadataRoot (this); - - m_header.Accept (visitor); - m_streams.Accept (visitor); - - visitor.TerminateMetadataRoot (this); - } - - public sealed class MetadataRootHeader : IHeader, IMetadataVisitable { - - public const uint StandardSignature = 0x424a5342; - - public uint Signature; - public ushort MinorVersion; - public ushort MajorVersion; - public uint Reserved; - public string Version; - public ushort Flags; - public ushort Streams; - - internal MetadataRootHeader () - { - } - - public void SetDefaultValues () - { - Signature = StandardSignature; - Reserved = 0; - Flags = 0; - } - - public void Accept (IMetadataVisitor visitor) - { - visitor.VisitMetadataRootHeader (this); - } - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataRowReader.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataRowReader.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataRowReader.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataRowReader.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,367 +0,0 @@ -// -// MetadataRowReader.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Jul 17 00:22:32 +0200 2007 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using System; - using System.Collections; - using System.IO; - - using Mono.Cecil.Binary; - - class MetadataRowReader : BaseMetadataRowVisitor { - - MetadataTableReader m_mtrv; - BinaryReader m_binaryReader; - MetadataRoot m_metadataRoot; - IDictionary m_ciCache; - - int m_blobHeapIdxSz; - int m_stringsHeapIdxSz; - int m_guidHeapIdxSz; - - public MetadataRowReader (MetadataTableReader mtrv) - { - m_mtrv = mtrv; - m_binaryReader = mtrv.GetReader (); - m_metadataRoot = mtrv.GetMetadataRoot (); - m_ciCache = new Hashtable (); - } - - int GetIndexSize (int rid) - { - return m_mtrv.GetNumberOfRows (rid) < (1 << 16) ? 2 : 4; - } - - int GetCodedIndexSize (CodedIndex ci) - { - return Utilities.GetCodedIndexSize (ci, - new Utilities.TableRowCounter (m_mtrv.GetNumberOfRows), m_ciCache); - } - - uint ReadByIndexSize (int size) - { - if (size == 2) { - return (uint) m_binaryReader.ReadUInt16 (); - } else if (size == 4) { - return m_binaryReader.ReadUInt32 (); - } else { - throw new MetadataFormatException ("Non valid size for indexing"); - } - } - - public override void VisitRowCollection (RowCollection coll) - { - m_blobHeapIdxSz = m_metadataRoot.Streams.BlobHeap != null ? - m_metadataRoot.Streams.BlobHeap.IndexSize : 2; - m_stringsHeapIdxSz = m_metadataRoot.Streams.StringsHeap != null ? - m_metadataRoot.Streams.StringsHeap.IndexSize : 2; - m_guidHeapIdxSz = m_metadataRoot.Streams.GuidHeap != null ? - m_metadataRoot.Streams.GuidHeap.IndexSize : 2; - } - - public override void VisitAssemblyRow (AssemblyRow row) - { - row.HashAlgId = (Mono.Cecil.AssemblyHashAlgorithm) m_binaryReader.ReadUInt32 (); - row.MajorVersion = m_binaryReader.ReadUInt16 (); - row.MinorVersion = m_binaryReader.ReadUInt16 (); - row.BuildNumber = m_binaryReader.ReadUInt16 (); - row.RevisionNumber = m_binaryReader.ReadUInt16 (); - row.Flags = (Mono.Cecil.AssemblyFlags) m_binaryReader.ReadUInt32 (); - row.PublicKey = ReadByIndexSize (m_blobHeapIdxSz); - row.Name = ReadByIndexSize (m_stringsHeapIdxSz); - row.Culture = ReadByIndexSize (m_stringsHeapIdxSz); - } - public override void VisitAssemblyOSRow (AssemblyOSRow row) - { - row.OSPlatformID = m_binaryReader.ReadUInt32 (); - row.OSMajorVersion = m_binaryReader.ReadUInt32 (); - row.OSMinorVersion = m_binaryReader.ReadUInt32 (); - } - public override void VisitAssemblyProcessorRow (AssemblyProcessorRow row) - { - row.Processor = m_binaryReader.ReadUInt32 (); - } - public override void VisitAssemblyRefRow (AssemblyRefRow row) - { - row.MajorVersion = m_binaryReader.ReadUInt16 (); - row.MinorVersion = m_binaryReader.ReadUInt16 (); - row.BuildNumber = m_binaryReader.ReadUInt16 (); - row.RevisionNumber = m_binaryReader.ReadUInt16 (); - row.Flags = (Mono.Cecil.AssemblyFlags) m_binaryReader.ReadUInt32 (); - row.PublicKeyOrToken = ReadByIndexSize (m_blobHeapIdxSz); - row.Name = ReadByIndexSize (m_stringsHeapIdxSz); - row.Culture = ReadByIndexSize (m_stringsHeapIdxSz); - row.HashValue = ReadByIndexSize (m_blobHeapIdxSz); - } - public override void VisitAssemblyRefOSRow (AssemblyRefOSRow row) - { - row.OSPlatformID = m_binaryReader.ReadUInt32 (); - row.OSMajorVersion = m_binaryReader.ReadUInt32 (); - row.OSMinorVersion = m_binaryReader.ReadUInt32 (); - row.AssemblyRef = ReadByIndexSize (GetIndexSize (AssemblyRefTable.RId)); - } - public override void VisitAssemblyRefProcessorRow (AssemblyRefProcessorRow row) - { - row.Processor = m_binaryReader.ReadUInt32 (); - row.AssemblyRef = ReadByIndexSize (GetIndexSize (AssemblyRefTable.RId)); - } - public override void VisitClassLayoutRow (ClassLayoutRow row) - { - row.PackingSize = m_binaryReader.ReadUInt16 (); - row.ClassSize = m_binaryReader.ReadUInt32 (); - row.Parent = ReadByIndexSize (GetIndexSize (TypeDefTable.RId)); - } - public override void VisitConstantRow (ConstantRow row) - { - row.Type = (Mono.Cecil.Metadata.ElementType) m_binaryReader.ReadUInt16 (); - row.Parent = Utilities.GetMetadataToken (CodedIndex.HasConstant, - ReadByIndexSize (GetCodedIndexSize (CodedIndex.HasConstant))); - row.Value = ReadByIndexSize (m_blobHeapIdxSz); - } - public override void VisitCustomAttributeRow (CustomAttributeRow row) - { - row.Parent = Utilities.GetMetadataToken (CodedIndex.HasCustomAttribute, - ReadByIndexSize (GetCodedIndexSize (CodedIndex.HasCustomAttribute))); - row.Type = Utilities.GetMetadataToken (CodedIndex.CustomAttributeType, - ReadByIndexSize (GetCodedIndexSize (CodedIndex.CustomAttributeType))); - row.Value = ReadByIndexSize (m_blobHeapIdxSz); - } - public override void VisitDeclSecurityRow (DeclSecurityRow row) - { - row.Action = (Mono.Cecil.SecurityAction) m_binaryReader.ReadInt16 (); - row.Parent = Utilities.GetMetadataToken (CodedIndex.HasDeclSecurity, - ReadByIndexSize (GetCodedIndexSize (CodedIndex.HasDeclSecurity))); - row.PermissionSet = ReadByIndexSize (m_blobHeapIdxSz); - } - public override void VisitEventRow (EventRow row) - { - row.EventFlags = (Mono.Cecil.EventAttributes) m_binaryReader.ReadUInt16 (); - row.Name = ReadByIndexSize (m_stringsHeapIdxSz); - row.EventType = Utilities.GetMetadataToken (CodedIndex.TypeDefOrRef, - ReadByIndexSize (GetCodedIndexSize (CodedIndex.TypeDefOrRef))); - } - public override void VisitEventMapRow (EventMapRow row) - { - row.Parent = ReadByIndexSize (GetIndexSize (TypeDefTable.RId)); - row.EventList = ReadByIndexSize (GetIndexSize (EventTable.RId)); - } - public override void VisitEventPtrRow (EventPtrRow row) - { - row.Event = ReadByIndexSize (GetIndexSize (EventTable.RId)); - } - public override void VisitExportedTypeRow (ExportedTypeRow row) - { - row.Flags = (Mono.Cecil.TypeAttributes) m_binaryReader.ReadUInt32 (); - row.TypeDefId = m_binaryReader.ReadUInt32 (); - row.TypeName = ReadByIndexSize (m_stringsHeapIdxSz); - row.TypeNamespace = ReadByIndexSize (m_stringsHeapIdxSz); - row.Implementation = Utilities.GetMetadataToken (CodedIndex.Implementation, - ReadByIndexSize (GetCodedIndexSize (CodedIndex.Implementation))); - } - public override void VisitFieldRow (FieldRow row) - { - row.Flags = (Mono.Cecil.FieldAttributes) m_binaryReader.ReadUInt16 (); - row.Name = ReadByIndexSize (m_stringsHeapIdxSz); - row.Signature = ReadByIndexSize (m_blobHeapIdxSz); - } - public override void VisitFieldLayoutRow (FieldLayoutRow row) - { - row.Offset = m_binaryReader.ReadUInt32 (); - row.Field = ReadByIndexSize (GetIndexSize (FieldTable.RId)); - } - public override void VisitFieldMarshalRow (FieldMarshalRow row) - { - row.Parent = Utilities.GetMetadataToken (CodedIndex.HasFieldMarshal, - ReadByIndexSize (GetCodedIndexSize (CodedIndex.HasFieldMarshal))); - row.NativeType = ReadByIndexSize (m_blobHeapIdxSz); - } - public override void VisitFieldPtrRow (FieldPtrRow row) - { - row.Field = ReadByIndexSize (GetIndexSize (FieldTable.RId)); - } - public override void VisitFieldRVARow (FieldRVARow row) - { - row.RVA = new RVA (m_binaryReader.ReadUInt32 ()); - row.Field = ReadByIndexSize (GetIndexSize (FieldTable.RId)); - } - public override void VisitFileRow (FileRow row) - { - row.Flags = (Mono.Cecil.FileAttributes) m_binaryReader.ReadUInt32 (); - row.Name = ReadByIndexSize (m_stringsHeapIdxSz); - row.HashValue = ReadByIndexSize (m_blobHeapIdxSz); - } - public override void VisitGenericParamRow (GenericParamRow row) - { - row.Number = m_binaryReader.ReadUInt16 (); - row.Flags = (Mono.Cecil.GenericParameterAttributes) m_binaryReader.ReadUInt16 (); - row.Owner = Utilities.GetMetadataToken (CodedIndex.TypeOrMethodDef, - ReadByIndexSize (GetCodedIndexSize (CodedIndex.TypeOrMethodDef))); - row.Name = ReadByIndexSize (m_stringsHeapIdxSz); - } - public override void VisitGenericParamConstraintRow (GenericParamConstraintRow row) - { - row.Owner = ReadByIndexSize (GetIndexSize (GenericParamTable.RId)); - row.Constraint = Utilities.GetMetadataToken (CodedIndex.TypeDefOrRef, - ReadByIndexSize (GetCodedIndexSize (CodedIndex.TypeDefOrRef))); - } - public override void VisitImplMapRow (ImplMapRow row) - { - row.MappingFlags = (Mono.Cecil.PInvokeAttributes) m_binaryReader.ReadUInt16 (); - row.MemberForwarded = Utilities.GetMetadataToken (CodedIndex.MemberForwarded, - ReadByIndexSize (GetCodedIndexSize (CodedIndex.MemberForwarded))); - row.ImportName = ReadByIndexSize (m_stringsHeapIdxSz); - row.ImportScope = ReadByIndexSize (GetIndexSize (ModuleRefTable.RId)); - } - public override void VisitInterfaceImplRow (InterfaceImplRow row) - { - row.Class = ReadByIndexSize (GetIndexSize (TypeDefTable.RId)); - row.Interface = Utilities.GetMetadataToken (CodedIndex.TypeDefOrRef, - ReadByIndexSize (GetCodedIndexSize (CodedIndex.TypeDefOrRef))); - } - public override void VisitManifestResourceRow (ManifestResourceRow row) - { - row.Offset = m_binaryReader.ReadUInt32 (); - row.Flags = (Mono.Cecil.ManifestResourceAttributes) m_binaryReader.ReadUInt32 (); - row.Name = ReadByIndexSize (m_stringsHeapIdxSz); - row.Implementation = Utilities.GetMetadataToken (CodedIndex.Implementation, - ReadByIndexSize (GetCodedIndexSize (CodedIndex.Implementation))); - } - public override void VisitMemberRefRow (MemberRefRow row) - { - row.Class = Utilities.GetMetadataToken (CodedIndex.MemberRefParent, - ReadByIndexSize (GetCodedIndexSize (CodedIndex.MemberRefParent))); - row.Name = ReadByIndexSize (m_stringsHeapIdxSz); - row.Signature = ReadByIndexSize (m_blobHeapIdxSz); - } - public override void VisitMethodRow (MethodRow row) - { - row.RVA = new RVA (m_binaryReader.ReadUInt32 ()); - row.ImplFlags = (Mono.Cecil.MethodImplAttributes) m_binaryReader.ReadUInt16 (); - row.Flags = (Mono.Cecil.MethodAttributes) m_binaryReader.ReadUInt16 (); - row.Name = ReadByIndexSize (m_stringsHeapIdxSz); - row.Signature = ReadByIndexSize (m_blobHeapIdxSz); - row.ParamList = ReadByIndexSize (GetIndexSize (ParamTable.RId)); - } - public override void VisitMethodImplRow (MethodImplRow row) - { - row.Class = ReadByIndexSize (GetIndexSize (TypeDefTable.RId)); - row.MethodBody = Utilities.GetMetadataToken (CodedIndex.MethodDefOrRef, - ReadByIndexSize (GetCodedIndexSize (CodedIndex.MethodDefOrRef))); - row.MethodDeclaration = Utilities.GetMetadataToken (CodedIndex.MethodDefOrRef, - ReadByIndexSize (GetCodedIndexSize (CodedIndex.MethodDefOrRef))); - } - public override void VisitMethodPtrRow (MethodPtrRow row) - { - row.Method = ReadByIndexSize (GetIndexSize (MethodTable.RId)); - } - public override void VisitMethodSemanticsRow (MethodSemanticsRow row) - { - row.Semantics = (Mono.Cecil.MethodSemanticsAttributes) m_binaryReader.ReadUInt16 (); - row.Method = ReadByIndexSize (GetIndexSize (MethodTable.RId)); - row.Association = Utilities.GetMetadataToken (CodedIndex.HasSemantics, - ReadByIndexSize (GetCodedIndexSize (CodedIndex.HasSemantics))); - } - public override void VisitMethodSpecRow (MethodSpecRow row) - { - row.Method = Utilities.GetMetadataToken (CodedIndex.MethodDefOrRef, - ReadByIndexSize (GetCodedIndexSize (CodedIndex.MethodDefOrRef))); - row.Instantiation = ReadByIndexSize (m_blobHeapIdxSz); - } - public override void VisitModuleRow (ModuleRow row) - { - row.Generation = m_binaryReader.ReadUInt16 (); - row.Name = ReadByIndexSize (m_stringsHeapIdxSz); - row.Mvid = ReadByIndexSize (m_guidHeapIdxSz); - row.EncId = ReadByIndexSize (m_guidHeapIdxSz); - row.EncBaseId = ReadByIndexSize (m_guidHeapIdxSz); - } - public override void VisitModuleRefRow (ModuleRefRow row) - { - row.Name = ReadByIndexSize (m_stringsHeapIdxSz); - } - public override void VisitNestedClassRow (NestedClassRow row) - { - row.NestedClass = ReadByIndexSize (GetIndexSize (TypeDefTable.RId)); - row.EnclosingClass = ReadByIndexSize (GetIndexSize (TypeDefTable.RId)); - } - public override void VisitParamRow (ParamRow row) - { - row.Flags = (Mono.Cecil.ParameterAttributes) m_binaryReader.ReadUInt16 (); - row.Sequence = m_binaryReader.ReadUInt16 (); - row.Name = ReadByIndexSize (m_stringsHeapIdxSz); - } - public override void VisitParamPtrRow (ParamPtrRow row) - { - row.Param = ReadByIndexSize (GetIndexSize (ParamTable.RId)); - } - public override void VisitPropertyRow (PropertyRow row) - { - row.Flags = (Mono.Cecil.PropertyAttributes) m_binaryReader.ReadUInt16 (); - row.Name = ReadByIndexSize (m_stringsHeapIdxSz); - row.Type = ReadByIndexSize (m_blobHeapIdxSz); - } - public override void VisitPropertyMapRow (PropertyMapRow row) - { - row.Parent = ReadByIndexSize (GetIndexSize (TypeDefTable.RId)); - row.PropertyList = ReadByIndexSize (GetIndexSize (PropertyTable.RId)); - } - public override void VisitPropertyPtrRow (PropertyPtrRow row) - { - row.Property = ReadByIndexSize (GetIndexSize (PropertyTable.RId)); - } - public override void VisitStandAloneSigRow (StandAloneSigRow row) - { - row.Signature = ReadByIndexSize (m_blobHeapIdxSz); - } - public override void VisitTypeDefRow (TypeDefRow row) - { - row.Flags = (Mono.Cecil.TypeAttributes) m_binaryReader.ReadUInt32 (); - row.Name = ReadByIndexSize (m_stringsHeapIdxSz); - row.Namespace = ReadByIndexSize (m_stringsHeapIdxSz); - row.Extends = Utilities.GetMetadataToken (CodedIndex.TypeDefOrRef, - ReadByIndexSize (GetCodedIndexSize (CodedIndex.TypeDefOrRef))); - row.FieldList = ReadByIndexSize (GetIndexSize (FieldTable.RId)); - row.MethodList = ReadByIndexSize (GetIndexSize (MethodTable.RId)); - } - public override void VisitTypeRefRow (TypeRefRow row) - { - row.ResolutionScope = Utilities.GetMetadataToken (CodedIndex.ResolutionScope, - ReadByIndexSize (GetCodedIndexSize (CodedIndex.ResolutionScope))); - row.Name = ReadByIndexSize (m_stringsHeapIdxSz); - row.Namespace = ReadByIndexSize (m_stringsHeapIdxSz); - } - public override void VisitTypeSpecRow (TypeSpecRow row) - { - row.Signature = ReadByIndexSize (m_blobHeapIdxSz); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataRowWriter.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataRowWriter.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataRowWriter.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataRowWriter.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,796 +0,0 @@ -// -// MetadataRowWriter.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Thu Feb 22 14:39:38 CET 2007 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using System; - using System.Collections; - - using Mono.Cecil.Binary; - - class MetadataRowWriter : BaseMetadataRowVisitor { - - MetadataRoot m_root; - MemoryBinaryWriter m_binaryWriter; - IDictionary m_ciCache; - - int m_blobHeapIdxSz; - int m_stringsHeapIdxSz; - int m_guidHeapIdxSz; - - public MetadataRowWriter (MetadataTableWriter mtwv) - { - m_binaryWriter = mtwv.GetWriter (); - m_root = mtwv.GetMetadataRoot (); - m_ciCache = new Hashtable (); - } - - void WriteBlobPointer (uint pointer) - { - WriteByIndexSize (pointer, m_blobHeapIdxSz); - } - - void WriteStringPointer (uint pointer) - { - WriteByIndexSize (pointer, m_stringsHeapIdxSz); - } - - void WriteGuidPointer (uint pointer) - { - WriteByIndexSize (pointer, m_guidHeapIdxSz); - } - - void WriteTablePointer (uint pointer, int rid) - { - WriteByIndexSize (pointer, GetNumberOfRows (rid) < (1 << 16) ? 2 : 4); - } - - void WriteMetadataToken (MetadataToken token, CodedIndex ci) - { - WriteByIndexSize (Utilities.CompressMetadataToken (ci, token), - Utilities.GetCodedIndexSize ( - ci, new Utilities.TableRowCounter (GetNumberOfRows), m_ciCache)); - } - - int GetNumberOfRows (int rid) - { - IMetadataTable t = m_root.Streams.TablesHeap [rid]; - if (t == null || t.Rows == null) - return 0; - return t.Rows.Count; - } - - void WriteByIndexSize (uint value, int size) - { - if (size == 4) - m_binaryWriter.Write (value); - else if (size == 2) - m_binaryWriter.Write ((ushort) value); - else - throw new MetadataFormatException ("Non valid size for indexing"); - } - - public AssemblyRow CreateAssemblyRow (AssemblyHashAlgorithm _hashAlgId, ushort _majorVersion, ushort _minorVersion, ushort _buildNumber, ushort _revisionNumber, AssemblyFlags _flags, uint _publicKey, uint _name, uint _culture) - { - AssemblyRow row = new AssemblyRow (); - row.HashAlgId = _hashAlgId; - row.MajorVersion = _majorVersion; - row.MinorVersion = _minorVersion; - row.BuildNumber = _buildNumber; - row.RevisionNumber = _revisionNumber; - row.Flags = _flags; - row.PublicKey = _publicKey; - row.Name = _name; - row.Culture = _culture; - return row; - } - - public AssemblyOSRow CreateAssemblyOSRow (uint _oSPlatformID, uint _oSMajorVersion, uint _oSMinorVersion) - { - AssemblyOSRow row = new AssemblyOSRow (); - row.OSPlatformID = _oSPlatformID; - row.OSMajorVersion = _oSMajorVersion; - row.OSMinorVersion = _oSMinorVersion; - return row; - } - - public AssemblyProcessorRow CreateAssemblyProcessorRow (uint _processor) - { - AssemblyProcessorRow row = new AssemblyProcessorRow (); - row.Processor = _processor; - return row; - } - - public AssemblyRefRow CreateAssemblyRefRow (ushort _majorVersion, ushort _minorVersion, ushort _buildNumber, ushort _revisionNumber, AssemblyFlags _flags, uint _publicKeyOrToken, uint _name, uint _culture, uint _hashValue) - { - AssemblyRefRow row = new AssemblyRefRow (); - row.MajorVersion = _majorVersion; - row.MinorVersion = _minorVersion; - row.BuildNumber = _buildNumber; - row.RevisionNumber = _revisionNumber; - row.Flags = _flags; - row.PublicKeyOrToken = _publicKeyOrToken; - row.Name = _name; - row.Culture = _culture; - row.HashValue = _hashValue; - return row; - } - - public AssemblyRefOSRow CreateAssemblyRefOSRow (uint _oSPlatformID, uint _oSMajorVersion, uint _oSMinorVersion, uint _assemblyRef) - { - AssemblyRefOSRow row = new AssemblyRefOSRow (); - row.OSPlatformID = _oSPlatformID; - row.OSMajorVersion = _oSMajorVersion; - row.OSMinorVersion = _oSMinorVersion; - row.AssemblyRef = _assemblyRef; - return row; - } - - public AssemblyRefProcessorRow CreateAssemblyRefProcessorRow (uint _processor, uint _assemblyRef) - { - AssemblyRefProcessorRow row = new AssemblyRefProcessorRow (); - row.Processor = _processor; - row.AssemblyRef = _assemblyRef; - return row; - } - - public ClassLayoutRow CreateClassLayoutRow (ushort _packingSize, uint _classSize, uint _parent) - { - ClassLayoutRow row = new ClassLayoutRow (); - row.PackingSize = _packingSize; - row.ClassSize = _classSize; - row.Parent = _parent; - return row; - } - - public ConstantRow CreateConstantRow (ElementType _type, MetadataToken _parent, uint _value) - { - ConstantRow row = new ConstantRow (); - row.Type = _type; - row.Parent = _parent; - row.Value = _value; - return row; - } - - public CustomAttributeRow CreateCustomAttributeRow (MetadataToken _parent, MetadataToken _type, uint _value) - { - CustomAttributeRow row = new CustomAttributeRow (); - row.Parent = _parent; - row.Type = _type; - row.Value = _value; - return row; - } - - public DeclSecurityRow CreateDeclSecurityRow (SecurityAction _action, MetadataToken _parent, uint _permissionSet) - { - DeclSecurityRow row = new DeclSecurityRow (); - row.Action = _action; - row.Parent = _parent; - row.PermissionSet = _permissionSet; - return row; - } - - public EventRow CreateEventRow (EventAttributes _eventFlags, uint _name, MetadataToken _eventType) - { - EventRow row = new EventRow (); - row.EventFlags = _eventFlags; - row.Name = _name; - row.EventType = _eventType; - return row; - } - - public EventMapRow CreateEventMapRow (uint _parent, uint _eventList) - { - EventMapRow row = new EventMapRow (); - row.Parent = _parent; - row.EventList = _eventList; - return row; - } - - public EventPtrRow CreateEventPtrRow (uint _event) - { - EventPtrRow row = new EventPtrRow (); - row.Event = _event; - return row; - } - - public ExportedTypeRow CreateExportedTypeRow (TypeAttributes _flags, uint _typeDefId, uint _typeName, uint _typeNamespace, MetadataToken _implementation) - { - ExportedTypeRow row = new ExportedTypeRow (); - row.Flags = _flags; - row.TypeDefId = _typeDefId; - row.TypeName = _typeName; - row.TypeNamespace = _typeNamespace; - row.Implementation = _implementation; - return row; - } - - public FieldRow CreateFieldRow (FieldAttributes _flags, uint _name, uint _signature) - { - FieldRow row = new FieldRow (); - row.Flags = _flags; - row.Name = _name; - row.Signature = _signature; - return row; - } - - public FieldLayoutRow CreateFieldLayoutRow (uint _offset, uint _field) - { - FieldLayoutRow row = new FieldLayoutRow (); - row.Offset = _offset; - row.Field = _field; - return row; - } - - public FieldMarshalRow CreateFieldMarshalRow (MetadataToken _parent, uint _nativeType) - { - FieldMarshalRow row = new FieldMarshalRow (); - row.Parent = _parent; - row.NativeType = _nativeType; - return row; - } - - public FieldPtrRow CreateFieldPtrRow (uint _field) - { - FieldPtrRow row = new FieldPtrRow (); - row.Field = _field; - return row; - } - - public FieldRVARow CreateFieldRVARow (RVA _rVA, uint _field) - { - FieldRVARow row = new FieldRVARow (); - row.RVA = _rVA; - row.Field = _field; - return row; - } - - public FileRow CreateFileRow (FileAttributes _flags, uint _name, uint _hashValue) - { - FileRow row = new FileRow (); - row.Flags = _flags; - row.Name = _name; - row.HashValue = _hashValue; - return row; - } - - public GenericParamRow CreateGenericParamRow (ushort _number, GenericParameterAttributes _flags, MetadataToken _owner, uint _name) - { - GenericParamRow row = new GenericParamRow (); - row.Number = _number; - row.Flags = _flags; - row.Owner = _owner; - row.Name = _name; - return row; - } - - public GenericParamConstraintRow CreateGenericParamConstraintRow (uint _owner, MetadataToken _constraint) - { - GenericParamConstraintRow row = new GenericParamConstraintRow (); - row.Owner = _owner; - row.Constraint = _constraint; - return row; - } - - public ImplMapRow CreateImplMapRow (PInvokeAttributes _mappingFlags, MetadataToken _memberForwarded, uint _importName, uint _importScope) - { - ImplMapRow row = new ImplMapRow (); - row.MappingFlags = _mappingFlags; - row.MemberForwarded = _memberForwarded; - row.ImportName = _importName; - row.ImportScope = _importScope; - return row; - } - - public InterfaceImplRow CreateInterfaceImplRow (uint _class, MetadataToken _interface) - { - InterfaceImplRow row = new InterfaceImplRow (); - row.Class = _class; - row.Interface = _interface; - return row; - } - - public ManifestResourceRow CreateManifestResourceRow (uint _offset, ManifestResourceAttributes _flags, uint _name, MetadataToken _implementation) - { - ManifestResourceRow row = new ManifestResourceRow (); - row.Offset = _offset; - row.Flags = _flags; - row.Name = _name; - row.Implementation = _implementation; - return row; - } - - public MemberRefRow CreateMemberRefRow (MetadataToken _class, uint _name, uint _signature) - { - MemberRefRow row = new MemberRefRow (); - row.Class = _class; - row.Name = _name; - row.Signature = _signature; - return row; - } - - public MethodRow CreateMethodRow (RVA _rVA, MethodImplAttributes _implFlags, MethodAttributes _flags, uint _name, uint _signature, uint _paramList) - { - MethodRow row = new MethodRow (); - row.RVA = _rVA; - row.ImplFlags = _implFlags; - row.Flags = _flags; - row.Name = _name; - row.Signature = _signature; - row.ParamList = _paramList; - return row; - } - - public MethodImplRow CreateMethodImplRow (uint _class, MetadataToken _methodBody, MetadataToken _methodDeclaration) - { - MethodImplRow row = new MethodImplRow (); - row.Class = _class; - row.MethodBody = _methodBody; - row.MethodDeclaration = _methodDeclaration; - return row; - } - - public MethodPtrRow CreateMethodPtrRow (uint _method) - { - MethodPtrRow row = new MethodPtrRow (); - row.Method = _method; - return row; - } - - public MethodSemanticsRow CreateMethodSemanticsRow (MethodSemanticsAttributes _semantics, uint _method, MetadataToken _association) - { - MethodSemanticsRow row = new MethodSemanticsRow (); - row.Semantics = _semantics; - row.Method = _method; - row.Association = _association; - return row; - } - - public MethodSpecRow CreateMethodSpecRow (MetadataToken _method, uint _instantiation) - { - MethodSpecRow row = new MethodSpecRow (); - row.Method = _method; - row.Instantiation = _instantiation; - return row; - } - - public ModuleRow CreateModuleRow (ushort _generation, uint _name, uint _mvid, uint _encId, uint _encBaseId) - { - ModuleRow row = new ModuleRow (); - row.Generation = _generation; - row.Name = _name; - row.Mvid = _mvid; - row.EncId = _encId; - row.EncBaseId = _encBaseId; - return row; - } - - public ModuleRefRow CreateModuleRefRow (uint _name) - { - ModuleRefRow row = new ModuleRefRow (); - row.Name = _name; - return row; - } - - public NestedClassRow CreateNestedClassRow (uint _nestedClass, uint _enclosingClass) - { - NestedClassRow row = new NestedClassRow (); - row.NestedClass = _nestedClass; - row.EnclosingClass = _enclosingClass; - return row; - } - - public ParamRow CreateParamRow (ParameterAttributes _flags, ushort _sequence, uint _name) - { - ParamRow row = new ParamRow (); - row.Flags = _flags; - row.Sequence = _sequence; - row.Name = _name; - return row; - } - - public ParamPtrRow CreateParamPtrRow (uint _param) - { - ParamPtrRow row = new ParamPtrRow (); - row.Param = _param; - return row; - } - - public PropertyRow CreatePropertyRow (PropertyAttributes _flags, uint _name, uint _type) - { - PropertyRow row = new PropertyRow (); - row.Flags = _flags; - row.Name = _name; - row.Type = _type; - return row; - } - - public PropertyMapRow CreatePropertyMapRow (uint _parent, uint _propertyList) - { - PropertyMapRow row = new PropertyMapRow (); - row.Parent = _parent; - row.PropertyList = _propertyList; - return row; - } - - public PropertyPtrRow CreatePropertyPtrRow (uint _property) - { - PropertyPtrRow row = new PropertyPtrRow (); - row.Property = _property; - return row; - } - - public StandAloneSigRow CreateStandAloneSigRow (uint _signature) - { - StandAloneSigRow row = new StandAloneSigRow (); - row.Signature = _signature; - return row; - } - - public TypeDefRow CreateTypeDefRow (TypeAttributes _flags, uint _name, uint _namespace, MetadataToken _extends, uint _fieldList, uint _methodList) - { - TypeDefRow row = new TypeDefRow (); - row.Flags = _flags; - row.Name = _name; - row.Namespace = _namespace; - row.Extends = _extends; - row.FieldList = _fieldList; - row.MethodList = _methodList; - return row; - } - - public TypeRefRow CreateTypeRefRow (MetadataToken _resolutionScope, uint _name, uint _namespace) - { - TypeRefRow row = new TypeRefRow (); - row.ResolutionScope = _resolutionScope; - row.Name = _name; - row.Namespace = _namespace; - return row; - } - - public TypeSpecRow CreateTypeSpecRow (uint _signature) - { - TypeSpecRow row = new TypeSpecRow (); - row.Signature = _signature; - return row; - } - - public override void VisitRowCollection (RowCollection coll) - { - m_blobHeapIdxSz = m_root.Streams.BlobHeap != null ? - m_root.Streams.BlobHeap.IndexSize : 2; - m_stringsHeapIdxSz = m_root.Streams.StringsHeap != null ? - m_root.Streams.StringsHeap.IndexSize : 2; - m_guidHeapIdxSz = m_root.Streams.GuidHeap != null ? - m_root.Streams.GuidHeap.IndexSize : 2; - } - - public override void VisitAssemblyRow (AssemblyRow row) - { - m_binaryWriter.Write ((uint) row.HashAlgId); - m_binaryWriter.Write (row.MajorVersion); - m_binaryWriter.Write (row.MinorVersion); - m_binaryWriter.Write (row.BuildNumber); - m_binaryWriter.Write (row.RevisionNumber); - m_binaryWriter.Write ((uint) row.Flags); - WriteBlobPointer (row.PublicKey); - WriteStringPointer (row.Name); - WriteStringPointer (row.Culture); - } - - public override void VisitAssemblyOSRow (AssemblyOSRow row) - { - m_binaryWriter.Write (row.OSPlatformID); - m_binaryWriter.Write (row.OSMajorVersion); - m_binaryWriter.Write (row.OSMinorVersion); - } - - public override void VisitAssemblyProcessorRow (AssemblyProcessorRow row) - { - m_binaryWriter.Write (row.Processor); - } - - public override void VisitAssemblyRefRow (AssemblyRefRow row) - { - m_binaryWriter.Write (row.MajorVersion); - m_binaryWriter.Write (row.MinorVersion); - m_binaryWriter.Write (row.BuildNumber); - m_binaryWriter.Write (row.RevisionNumber); - m_binaryWriter.Write ((uint) row.Flags); - WriteBlobPointer (row.PublicKeyOrToken); - WriteStringPointer (row.Name); - WriteStringPointer (row.Culture); - WriteBlobPointer (row.HashValue); - } - - public override void VisitAssemblyRefOSRow (AssemblyRefOSRow row) - { - m_binaryWriter.Write (row.OSPlatformID); - m_binaryWriter.Write (row.OSMajorVersion); - m_binaryWriter.Write (row.OSMinorVersion); - WriteTablePointer (row.AssemblyRef, AssemblyRefTable.RId); - } - - public override void VisitAssemblyRefProcessorRow (AssemblyRefProcessorRow row) - { - m_binaryWriter.Write (row.Processor); - WriteTablePointer (row.AssemblyRef, AssemblyRefTable.RId); - } - - public override void VisitClassLayoutRow (ClassLayoutRow row) - { - m_binaryWriter.Write (row.PackingSize); - m_binaryWriter.Write (row.ClassSize); - WriteTablePointer (row.Parent, TypeDefTable.RId); - } - - public override void VisitConstantRow (ConstantRow row) - { - m_binaryWriter.Write ((ushort) row.Type); - WriteMetadataToken (row.Parent, CodedIndex.HasConstant); - WriteBlobPointer (row.Value); - } - - public override void VisitCustomAttributeRow (CustomAttributeRow row) - { - WriteMetadataToken (row.Parent, CodedIndex.HasCustomAttribute); - WriteMetadataToken (row.Type, CodedIndex.CustomAttributeType); - WriteBlobPointer (row.Value); - } - - public override void VisitDeclSecurityRow (DeclSecurityRow row) - { - m_binaryWriter.Write ((short) row.Action); - WriteMetadataToken (row.Parent, CodedIndex.HasDeclSecurity); - WriteBlobPointer (row.PermissionSet); - } - - public override void VisitEventRow (EventRow row) - { - m_binaryWriter.Write ((ushort) row.EventFlags); - WriteStringPointer (row.Name); - WriteMetadataToken (row.EventType, CodedIndex.TypeDefOrRef); - } - - public override void VisitEventMapRow (EventMapRow row) - { - WriteTablePointer (row.Parent, TypeDefTable.RId); - WriteTablePointer (row.EventList, EventTable.RId); - } - - public override void VisitEventPtrRow (EventPtrRow row) - { - WriteTablePointer (row.Event, EventTable.RId); - } - - public override void VisitExportedTypeRow (ExportedTypeRow row) - { - m_binaryWriter.Write ((uint) row.Flags); - m_binaryWriter.Write (row.TypeDefId); - WriteStringPointer (row.TypeName); - WriteStringPointer (row.TypeNamespace); - WriteMetadataToken (row.Implementation, CodedIndex.Implementation); - } - - public override void VisitFieldRow (FieldRow row) - { - m_binaryWriter.Write ((ushort) row.Flags); - WriteStringPointer (row.Name); - WriteBlobPointer (row.Signature); - } - - public override void VisitFieldLayoutRow (FieldLayoutRow row) - { - m_binaryWriter.Write (row.Offset); - WriteTablePointer (row.Field, FieldTable.RId); - } - - public override void VisitFieldMarshalRow (FieldMarshalRow row) - { - WriteMetadataToken (row.Parent, CodedIndex.HasFieldMarshal); - WriteBlobPointer (row.NativeType); - } - - public override void VisitFieldPtrRow (FieldPtrRow row) - { - WriteTablePointer (row.Field, FieldTable.RId); - } - - public override void VisitFieldRVARow (FieldRVARow row) - { - m_binaryWriter.Write (row.RVA.Value); - WriteTablePointer (row.Field, FieldTable.RId); - } - - public override void VisitFileRow (FileRow row) - { - m_binaryWriter.Write ((uint) row.Flags); - WriteStringPointer (row.Name); - WriteBlobPointer (row.HashValue); - } - - public override void VisitGenericParamRow (GenericParamRow row) - { - m_binaryWriter.Write (row.Number); - m_binaryWriter.Write ((ushort) row.Flags); - WriteMetadataToken (row.Owner, CodedIndex.TypeOrMethodDef); - WriteStringPointer (row.Name); - } - - public override void VisitGenericParamConstraintRow (GenericParamConstraintRow row) - { - WriteTablePointer (row.Owner, GenericParamTable.RId); - WriteMetadataToken (row.Constraint, CodedIndex.TypeDefOrRef); - } - - public override void VisitImplMapRow (ImplMapRow row) - { - m_binaryWriter.Write ((ushort) row.MappingFlags); - WriteMetadataToken (row.MemberForwarded, CodedIndex.MemberForwarded); - WriteStringPointer (row.ImportName); - WriteTablePointer (row.ImportScope, ModuleRefTable.RId); - } - - public override void VisitInterfaceImplRow (InterfaceImplRow row) - { - WriteTablePointer (row.Class, TypeDefTable.RId); - WriteMetadataToken (row.Interface, CodedIndex.TypeDefOrRef); - } - - public override void VisitManifestResourceRow (ManifestResourceRow row) - { - m_binaryWriter.Write (row.Offset); - m_binaryWriter.Write ((uint) row.Flags); - WriteStringPointer (row.Name); - WriteMetadataToken (row.Implementation, CodedIndex.Implementation); - } - - public override void VisitMemberRefRow (MemberRefRow row) - { - WriteMetadataToken (row.Class, CodedIndex.MemberRefParent); - WriteStringPointer (row.Name); - WriteBlobPointer (row.Signature); - } - - public override void VisitMethodRow (MethodRow row) - { - m_binaryWriter.Write (row.RVA.Value); - m_binaryWriter.Write ((ushort) row.ImplFlags); - m_binaryWriter.Write ((ushort) row.Flags); - WriteStringPointer (row.Name); - WriteBlobPointer (row.Signature); - WriteTablePointer (row.ParamList, ParamTable.RId); - } - - public override void VisitMethodImplRow (MethodImplRow row) - { - WriteTablePointer (row.Class, TypeDefTable.RId); - WriteMetadataToken (row.MethodBody, CodedIndex.MethodDefOrRef); - WriteMetadataToken (row.MethodDeclaration, CodedIndex.MethodDefOrRef); - } - - public override void VisitMethodPtrRow (MethodPtrRow row) - { - WriteTablePointer (row.Method, MethodTable.RId); - } - - public override void VisitMethodSemanticsRow (MethodSemanticsRow row) - { - m_binaryWriter.Write ((ushort) row.Semantics); - WriteTablePointer (row.Method, MethodTable.RId); - WriteMetadataToken (row.Association, CodedIndex.HasSemantics); - } - - public override void VisitMethodSpecRow (MethodSpecRow row) - { - WriteMetadataToken (row.Method, CodedIndex.MethodDefOrRef); - WriteBlobPointer (row.Instantiation); - } - - public override void VisitModuleRow (ModuleRow row) - { - m_binaryWriter.Write (row.Generation); - WriteStringPointer (row.Name); - WriteGuidPointer (row.Mvid); - WriteGuidPointer (row.EncId); - WriteGuidPointer (row.EncBaseId); - } - - public override void VisitModuleRefRow (ModuleRefRow row) - { - WriteStringPointer (row.Name); - } - - public override void VisitNestedClassRow (NestedClassRow row) - { - WriteTablePointer (row.NestedClass, TypeDefTable.RId); - WriteTablePointer (row.EnclosingClass, TypeDefTable.RId); - } - - public override void VisitParamRow (ParamRow row) - { - m_binaryWriter.Write ((ushort) row.Flags); - m_binaryWriter.Write (row.Sequence); - WriteStringPointer (row.Name); - } - - public override void VisitParamPtrRow (ParamPtrRow row) - { - WriteTablePointer (row.Param, ParamTable.RId); - } - - public override void VisitPropertyRow (PropertyRow row) - { - m_binaryWriter.Write ((ushort) row.Flags); - WriteStringPointer (row.Name); - WriteBlobPointer (row.Type); - } - - public override void VisitPropertyMapRow (PropertyMapRow row) - { - WriteTablePointer (row.Parent, TypeDefTable.RId); - WriteTablePointer (row.PropertyList, PropertyTable.RId); - } - - public override void VisitPropertyPtrRow (PropertyPtrRow row) - { - WriteTablePointer (row.Property, PropertyTable.RId); - } - - public override void VisitStandAloneSigRow (StandAloneSigRow row) - { - WriteBlobPointer (row.Signature); - } - - public override void VisitTypeDefRow (TypeDefRow row) - { - m_binaryWriter.Write ((uint) row.Flags); - WriteStringPointer (row.Name); - WriteStringPointer (row.Namespace); - WriteMetadataToken (row.Extends, CodedIndex.TypeDefOrRef); - WriteTablePointer (row.FieldList, FieldTable.RId); - WriteTablePointer (row.MethodList, MethodTable.RId); - } - - public override void VisitTypeRefRow (TypeRefRow row) - { - WriteMetadataToken (row.ResolutionScope, CodedIndex.ResolutionScope); - WriteStringPointer (row.Name); - WriteStringPointer (row.Namespace); - } - - public override void VisitTypeSpecRow (TypeSpecRow row) - { - WriteBlobPointer (row.Signature); - } - - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataStreamCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataStreamCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataStreamCollection.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataStreamCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,145 +0,0 @@ -// -// MetadataStreamCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using System; - using System.Collections; - - public class MetadataStreamCollection : ICollection, IMetadataVisitable { - - IList m_items; - - BlobHeap m_blobHeap; - GuidHeap m_guidHeap; - StringsHeap m_stringsHeap; - UserStringsHeap m_usHeap; - TablesHeap m_tablesHeap; - - public MetadataStream this [int index] { - get { return m_items [index] as MetadataStream; } - set { m_items [index] = value; } - } - - public int Count { - get { return m_items.Count; } - } - - public bool IsSynchronized { - get { return false; } - } - - public object SyncRoot { - get { return this; } - } - - public BlobHeap BlobHeap { - get { - if (m_blobHeap == null) - m_blobHeap = GetHeap (MetadataStream.Blob) as BlobHeap; - return m_blobHeap; - } - } - - public GuidHeap GuidHeap { - get { - if (m_guidHeap == null) - m_guidHeap = GetHeap (MetadataStream.GUID) as GuidHeap; - return m_guidHeap; - } - } - - public StringsHeap StringsHeap { - get { - if (m_stringsHeap == null) - m_stringsHeap = GetHeap (MetadataStream.Strings) as StringsHeap; - return m_stringsHeap; - } - } - - public TablesHeap TablesHeap { - get { - if (m_tablesHeap == null) - m_tablesHeap = GetHeap (MetadataStream.Tables) as TablesHeap; - return m_tablesHeap; - } - } - - public UserStringsHeap UserStringsHeap { - get { - if (m_usHeap == null) - m_usHeap = GetHeap (MetadataStream.UserStrings) as UserStringsHeap; - return m_usHeap; - } - } - - public MetadataStreamCollection () - { - m_items = new ArrayList (5); - } - - private MetadataHeap GetHeap (string name) - { - for (int i = 0; i < m_items.Count; i++) { - MetadataStream stream = m_items [i] as MetadataStream; - if (stream.Heap.Name == name) - return stream.Heap; - } - - return null; - } - - internal void Add (MetadataStream value) - { - m_items.Add (value); - } - - internal void Remove (MetadataStream value) - { - m_items.Remove (value); - } - - public void CopyTo (Array ary, int index) - { - m_items.CopyTo (ary, index); - } - - public IEnumerator GetEnumerator () - { - return m_items.GetEnumerator (); - } - - public void Accept (IMetadataVisitor visitor) - { - visitor.VisitMetadataStreamCollection (this); - - for (int i = 0; i < m_items.Count; i++) - this [i].Accept (visitor); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataStream.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataStream.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataStream.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataStream.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,90 +0,0 @@ -// -// MetadataStream.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public class MetadataStream : IMetadataVisitable { - - public const string Strings = "#Strings"; - public const string Tables = "#~"; - public const string IncrementalTables = "#-"; - public const string Blob = "#Blob"; - public const string GUID = "#GUID"; - public const string UserStrings = "#US"; - - MetadataStreamHeader m_header; - MetadataHeap m_heap; - - public MetadataStreamHeader Header { - get { return m_header; } - set { m_header = value; } - } - - public MetadataHeap Heap { - get { return m_heap; } - set { m_heap = value; } - } - - internal MetadataStream () - { - m_header = new MetadataStreamHeader (this); - } - - public void Accept (IMetadataVisitor visitor) - { - visitor.VisitMetadataStream (this); - - m_header.Accept (visitor); - if (m_heap != null) - m_heap.Accept (visitor); - } - - public class MetadataStreamHeader : IMetadataVisitable { - - public uint Offset; - public uint Size; - public string Name; - - private MetadataStream m_stream; - - public MetadataStream Stream { - get { return m_stream; } - } - - internal MetadataStreamHeader (MetadataStream stream) - { - m_stream = stream; - } - - public void Accept (IMetadataVisitor visitor) - { - visitor.VisitMetadataStreamHeader (this); - } - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataTableReader.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataTableReader.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataTableReader.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataTableReader.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,769 +0,0 @@ -// -// MetadataTableReader.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Jul 17 00:22:32 +0200 2007 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using System; - using System.Collections; - using System.IO; - - class MetadataTableReader : BaseMetadataTableVisitor { - - MetadataRoot m_metadataRoot; - TablesHeap m_heap; - MetadataRowReader m_mrrv; - BinaryReader m_binaryReader; - - int [] m_rows = new int [TablesHeap.MaxTableCount]; - - public MetadataTableReader (MetadataReader mrv) - { - m_metadataRoot = mrv.GetMetadataRoot (); - m_heap = m_metadataRoot.Streams.TablesHeap; - m_binaryReader = new BinaryReader (new MemoryStream (m_heap.Data)); - m_binaryReader.BaseStream.Position = 24; - m_mrrv = new MetadataRowReader (this); - } - - public MetadataRoot GetMetadataRoot () - { - return m_metadataRoot; - } - - public BinaryReader GetReader () - { - return m_binaryReader; - } - - public override IMetadataRowVisitor GetRowVisitor () - { - return m_mrrv; - } - - public int GetNumberOfRows (int rid) - { - return m_rows [rid]; - } - - public AssemblyTable GetAssemblyTable () - { - return (AssemblyTable) m_heap [AssemblyTable.RId]; - } - - public AssemblyOSTable GetAssemblyOSTable () - { - return (AssemblyOSTable) m_heap [AssemblyOSTable.RId]; - } - - public AssemblyProcessorTable GetAssemblyProcessorTable () - { - return (AssemblyProcessorTable) m_heap [AssemblyProcessorTable.RId]; - } - - public AssemblyRefTable GetAssemblyRefTable () - { - return (AssemblyRefTable) m_heap [AssemblyRefTable.RId]; - } - - public AssemblyRefOSTable GetAssemblyRefOSTable () - { - return (AssemblyRefOSTable) m_heap [AssemblyRefOSTable.RId]; - } - - public AssemblyRefProcessorTable GetAssemblyRefProcessorTable () - { - return (AssemblyRefProcessorTable) m_heap [AssemblyRefProcessorTable.RId]; - } - - public ClassLayoutTable GetClassLayoutTable () - { - return (ClassLayoutTable) m_heap [ClassLayoutTable.RId]; - } - - public ConstantTable GetConstantTable () - { - return (ConstantTable) m_heap [ConstantTable.RId]; - } - - public CustomAttributeTable GetCustomAttributeTable () - { - return (CustomAttributeTable) m_heap [CustomAttributeTable.RId]; - } - - public DeclSecurityTable GetDeclSecurityTable () - { - return (DeclSecurityTable) m_heap [DeclSecurityTable.RId]; - } - - public EventTable GetEventTable () - { - return (EventTable) m_heap [EventTable.RId]; - } - - public EventMapTable GetEventMapTable () - { - return (EventMapTable) m_heap [EventMapTable.RId]; - } - - public EventPtrTable GetEventPtrTable () - { - return (EventPtrTable) m_heap [EventPtrTable.RId]; - } - - public ExportedTypeTable GetExportedTypeTable () - { - return (ExportedTypeTable) m_heap [ExportedTypeTable.RId]; - } - - public FieldTable GetFieldTable () - { - return (FieldTable) m_heap [FieldTable.RId]; - } - - public FieldLayoutTable GetFieldLayoutTable () - { - return (FieldLayoutTable) m_heap [FieldLayoutTable.RId]; - } - - public FieldMarshalTable GetFieldMarshalTable () - { - return (FieldMarshalTable) m_heap [FieldMarshalTable.RId]; - } - - public FieldPtrTable GetFieldPtrTable () - { - return (FieldPtrTable) m_heap [FieldPtrTable.RId]; - } - - public FieldRVATable GetFieldRVATable () - { - return (FieldRVATable) m_heap [FieldRVATable.RId]; - } - - public FileTable GetFileTable () - { - return (FileTable) m_heap [FileTable.RId]; - } - - public GenericParamTable GetGenericParamTable () - { - return (GenericParamTable) m_heap [GenericParamTable.RId]; - } - - public GenericParamConstraintTable GetGenericParamConstraintTable () - { - return (GenericParamConstraintTable) m_heap [GenericParamConstraintTable.RId]; - } - - public ImplMapTable GetImplMapTable () - { - return (ImplMapTable) m_heap [ImplMapTable.RId]; - } - - public InterfaceImplTable GetInterfaceImplTable () - { - return (InterfaceImplTable) m_heap [InterfaceImplTable.RId]; - } - - public ManifestResourceTable GetManifestResourceTable () - { - return (ManifestResourceTable) m_heap [ManifestResourceTable.RId]; - } - - public MemberRefTable GetMemberRefTable () - { - return (MemberRefTable) m_heap [MemberRefTable.RId]; - } - - public MethodTable GetMethodTable () - { - return (MethodTable) m_heap [MethodTable.RId]; - } - - public MethodImplTable GetMethodImplTable () - { - return (MethodImplTable) m_heap [MethodImplTable.RId]; - } - - public MethodPtrTable GetMethodPtrTable () - { - return (MethodPtrTable) m_heap [MethodPtrTable.RId]; - } - - public MethodSemanticsTable GetMethodSemanticsTable () - { - return (MethodSemanticsTable) m_heap [MethodSemanticsTable.RId]; - } - - public MethodSpecTable GetMethodSpecTable () - { - return (MethodSpecTable) m_heap [MethodSpecTable.RId]; - } - - public ModuleTable GetModuleTable () - { - return (ModuleTable) m_heap [ModuleTable.RId]; - } - - public ModuleRefTable GetModuleRefTable () - { - return (ModuleRefTable) m_heap [ModuleRefTable.RId]; - } - - public NestedClassTable GetNestedClassTable () - { - return (NestedClassTable) m_heap [NestedClassTable.RId]; - } - - public ParamTable GetParamTable () - { - return (ParamTable) m_heap [ParamTable.RId]; - } - - public ParamPtrTable GetParamPtrTable () - { - return (ParamPtrTable) m_heap [ParamPtrTable.RId]; - } - - public PropertyTable GetPropertyTable () - { - return (PropertyTable) m_heap [PropertyTable.RId]; - } - - public PropertyMapTable GetPropertyMapTable () - { - return (PropertyMapTable) m_heap [PropertyMapTable.RId]; - } - - public PropertyPtrTable GetPropertyPtrTable () - { - return (PropertyPtrTable) m_heap [PropertyPtrTable.RId]; - } - - public StandAloneSigTable GetStandAloneSigTable () - { - return (StandAloneSigTable) m_heap [StandAloneSigTable.RId]; - } - - public TypeDefTable GetTypeDefTable () - { - return (TypeDefTable) m_heap [TypeDefTable.RId]; - } - - public TypeRefTable GetTypeRefTable () - { - return (TypeRefTable) m_heap [TypeRefTable.RId]; - } - - public TypeSpecTable GetTypeSpecTable () - { - return (TypeSpecTable) m_heap [TypeSpecTable.RId]; - } - - public override void VisitTableCollection (TableCollection coll) - { - if (m_heap.HasTable (ModuleTable.RId)) { - coll.Add (new ModuleTable ()); - m_rows [ModuleTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (TypeRefTable.RId)) { - coll.Add (new TypeRefTable ()); - m_rows [TypeRefTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (TypeDefTable.RId)) { - coll.Add (new TypeDefTable ()); - m_rows [TypeDefTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (FieldPtrTable.RId)) { - coll.Add (new FieldPtrTable ()); - m_rows [FieldPtrTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (FieldTable.RId)) { - coll.Add (new FieldTable ()); - m_rows [FieldTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (MethodPtrTable.RId)) { - coll.Add (new MethodPtrTable ()); - m_rows [MethodPtrTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (MethodTable.RId)) { - coll.Add (new MethodTable ()); - m_rows [MethodTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (ParamPtrTable.RId)) { - coll.Add (new ParamPtrTable ()); - m_rows [ParamPtrTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (ParamTable.RId)) { - coll.Add (new ParamTable ()); - m_rows [ParamTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (InterfaceImplTable.RId)) { - coll.Add (new InterfaceImplTable ()); - m_rows [InterfaceImplTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (MemberRefTable.RId)) { - coll.Add (new MemberRefTable ()); - m_rows [MemberRefTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (ConstantTable.RId)) { - coll.Add (new ConstantTable ()); - m_rows [ConstantTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (CustomAttributeTable.RId)) { - coll.Add (new CustomAttributeTable ()); - m_rows [CustomAttributeTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (FieldMarshalTable.RId)) { - coll.Add (new FieldMarshalTable ()); - m_rows [FieldMarshalTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (DeclSecurityTable.RId)) { - coll.Add (new DeclSecurityTable ()); - m_rows [DeclSecurityTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (ClassLayoutTable.RId)) { - coll.Add (new ClassLayoutTable ()); - m_rows [ClassLayoutTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (FieldLayoutTable.RId)) { - coll.Add (new FieldLayoutTable ()); - m_rows [FieldLayoutTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (StandAloneSigTable.RId)) { - coll.Add (new StandAloneSigTable ()); - m_rows [StandAloneSigTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (EventMapTable.RId)) { - coll.Add (new EventMapTable ()); - m_rows [EventMapTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (EventPtrTable.RId)) { - coll.Add (new EventPtrTable ()); - m_rows [EventPtrTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (EventTable.RId)) { - coll.Add (new EventTable ()); - m_rows [EventTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (PropertyMapTable.RId)) { - coll.Add (new PropertyMapTable ()); - m_rows [PropertyMapTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (PropertyPtrTable.RId)) { - coll.Add (new PropertyPtrTable ()); - m_rows [PropertyPtrTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (PropertyTable.RId)) { - coll.Add (new PropertyTable ()); - m_rows [PropertyTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (MethodSemanticsTable.RId)) { - coll.Add (new MethodSemanticsTable ()); - m_rows [MethodSemanticsTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (MethodImplTable.RId)) { - coll.Add (new MethodImplTable ()); - m_rows [MethodImplTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (ModuleRefTable.RId)) { - coll.Add (new ModuleRefTable ()); - m_rows [ModuleRefTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (TypeSpecTable.RId)) { - coll.Add (new TypeSpecTable ()); - m_rows [TypeSpecTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (ImplMapTable.RId)) { - coll.Add (new ImplMapTable ()); - m_rows [ImplMapTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (FieldRVATable.RId)) { - coll.Add (new FieldRVATable ()); - m_rows [FieldRVATable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (AssemblyTable.RId)) { - coll.Add (new AssemblyTable ()); - m_rows [AssemblyTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (AssemblyProcessorTable.RId)) { - coll.Add (new AssemblyProcessorTable ()); - m_rows [AssemblyProcessorTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (AssemblyOSTable.RId)) { - coll.Add (new AssemblyOSTable ()); - m_rows [AssemblyOSTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (AssemblyRefTable.RId)) { - coll.Add (new AssemblyRefTable ()); - m_rows [AssemblyRefTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (AssemblyRefProcessorTable.RId)) { - coll.Add (new AssemblyRefProcessorTable ()); - m_rows [AssemblyRefProcessorTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (AssemblyRefOSTable.RId)) { - coll.Add (new AssemblyRefOSTable ()); - m_rows [AssemblyRefOSTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (FileTable.RId)) { - coll.Add (new FileTable ()); - m_rows [FileTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (ExportedTypeTable.RId)) { - coll.Add (new ExportedTypeTable ()); - m_rows [ExportedTypeTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (ManifestResourceTable.RId)) { - coll.Add (new ManifestResourceTable ()); - m_rows [ManifestResourceTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (NestedClassTable.RId)) { - coll.Add (new NestedClassTable ()); - m_rows [NestedClassTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (GenericParamTable.RId)) { - coll.Add (new GenericParamTable ()); - m_rows [GenericParamTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (MethodSpecTable.RId)) { - coll.Add (new MethodSpecTable ()); - m_rows [MethodSpecTable.RId] = m_binaryReader.ReadInt32 (); - } - if (m_heap.HasTable (GenericParamConstraintTable.RId)) { - coll.Add (new GenericParamConstraintTable ()); - m_rows [GenericParamConstraintTable.RId] = m_binaryReader.ReadInt32 (); - } - } - - public override void VisitAssemblyTable (AssemblyTable table) - { - int number = m_rows [AssemblyTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new AssemblyRow ()); - } - public override void VisitAssemblyOSTable (AssemblyOSTable table) - { - int number = m_rows [AssemblyOSTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new AssemblyOSRow ()); - } - public override void VisitAssemblyProcessorTable (AssemblyProcessorTable table) - { - int number = m_rows [AssemblyProcessorTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new AssemblyProcessorRow ()); - } - public override void VisitAssemblyRefTable (AssemblyRefTable table) - { - int number = m_rows [AssemblyRefTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new AssemblyRefRow ()); - } - public override void VisitAssemblyRefOSTable (AssemblyRefOSTable table) - { - int number = m_rows [AssemblyRefOSTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new AssemblyRefOSRow ()); - } - public override void VisitAssemblyRefProcessorTable (AssemblyRefProcessorTable table) - { - int number = m_rows [AssemblyRefProcessorTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new AssemblyRefProcessorRow ()); - } - public override void VisitClassLayoutTable (ClassLayoutTable table) - { - int number = m_rows [ClassLayoutTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new ClassLayoutRow ()); - } - public override void VisitConstantTable (ConstantTable table) - { - int number = m_rows [ConstantTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new ConstantRow ()); - } - public override void VisitCustomAttributeTable (CustomAttributeTable table) - { - int number = m_rows [CustomAttributeTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new CustomAttributeRow ()); - } - public override void VisitDeclSecurityTable (DeclSecurityTable table) - { - int number = m_rows [DeclSecurityTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new DeclSecurityRow ()); - } - public override void VisitEventTable (EventTable table) - { - int number = m_rows [EventTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new EventRow ()); - } - public override void VisitEventMapTable (EventMapTable table) - { - int number = m_rows [EventMapTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new EventMapRow ()); - } - public override void VisitEventPtrTable (EventPtrTable table) - { - int number = m_rows [EventPtrTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new EventPtrRow ()); - } - public override void VisitExportedTypeTable (ExportedTypeTable table) - { - int number = m_rows [ExportedTypeTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new ExportedTypeRow ()); - } - public override void VisitFieldTable (FieldTable table) - { - int number = m_rows [FieldTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new FieldRow ()); - } - public override void VisitFieldLayoutTable (FieldLayoutTable table) - { - int number = m_rows [FieldLayoutTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new FieldLayoutRow ()); - } - public override void VisitFieldMarshalTable (FieldMarshalTable table) - { - int number = m_rows [FieldMarshalTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new FieldMarshalRow ()); - } - public override void VisitFieldPtrTable (FieldPtrTable table) - { - int number = m_rows [FieldPtrTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new FieldPtrRow ()); - } - public override void VisitFieldRVATable (FieldRVATable table) - { - int number = m_rows [FieldRVATable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new FieldRVARow ()); - } - public override void VisitFileTable (FileTable table) - { - int number = m_rows [FileTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new FileRow ()); - } - public override void VisitGenericParamTable (GenericParamTable table) - { - int number = m_rows [GenericParamTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new GenericParamRow ()); - } - public override void VisitGenericParamConstraintTable (GenericParamConstraintTable table) - { - int number = m_rows [GenericParamConstraintTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new GenericParamConstraintRow ()); - } - public override void VisitImplMapTable (ImplMapTable table) - { - int number = m_rows [ImplMapTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new ImplMapRow ()); - } - public override void VisitInterfaceImplTable (InterfaceImplTable table) - { - int number = m_rows [InterfaceImplTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new InterfaceImplRow ()); - } - public override void VisitManifestResourceTable (ManifestResourceTable table) - { - int number = m_rows [ManifestResourceTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new ManifestResourceRow ()); - } - public override void VisitMemberRefTable (MemberRefTable table) - { - int number = m_rows [MemberRefTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new MemberRefRow ()); - } - public override void VisitMethodTable (MethodTable table) - { - int number = m_rows [MethodTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new MethodRow ()); - } - public override void VisitMethodImplTable (MethodImplTable table) - { - int number = m_rows [MethodImplTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new MethodImplRow ()); - } - public override void VisitMethodPtrTable (MethodPtrTable table) - { - int number = m_rows [MethodPtrTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new MethodPtrRow ()); - } - public override void VisitMethodSemanticsTable (MethodSemanticsTable table) - { - int number = m_rows [MethodSemanticsTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new MethodSemanticsRow ()); - } - public override void VisitMethodSpecTable (MethodSpecTable table) - { - int number = m_rows [MethodSpecTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new MethodSpecRow ()); - } - public override void VisitModuleTable (ModuleTable table) - { - int number = m_rows [ModuleTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new ModuleRow ()); - } - public override void VisitModuleRefTable (ModuleRefTable table) - { - int number = m_rows [ModuleRefTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new ModuleRefRow ()); - } - public override void VisitNestedClassTable (NestedClassTable table) - { - int number = m_rows [NestedClassTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new NestedClassRow ()); - } - public override void VisitParamTable (ParamTable table) - { - int number = m_rows [ParamTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new ParamRow ()); - } - public override void VisitParamPtrTable (ParamPtrTable table) - { - int number = m_rows [ParamPtrTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new ParamPtrRow ()); - } - public override void VisitPropertyTable (PropertyTable table) - { - int number = m_rows [PropertyTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new PropertyRow ()); - } - public override void VisitPropertyMapTable (PropertyMapTable table) - { - int number = m_rows [PropertyMapTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new PropertyMapRow ()); - } - public override void VisitPropertyPtrTable (PropertyPtrTable table) - { - int number = m_rows [PropertyPtrTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new PropertyPtrRow ()); - } - public override void VisitStandAloneSigTable (StandAloneSigTable table) - { - int number = m_rows [StandAloneSigTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new StandAloneSigRow ()); - } - public override void VisitTypeDefTable (TypeDefTable table) - { - int number = m_rows [TypeDefTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new TypeDefRow ()); - } - public override void VisitTypeRefTable (TypeRefTable table) - { - int number = m_rows [TypeRefTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new TypeRefRow ()); - } - public override void VisitTypeSpecTable (TypeSpecTable table) - { - int number = m_rows [TypeSpecTable.RId]; - table.Rows = new RowCollection (number); - for (int i = 0; i < number; i++) - table.Rows.Add (new TypeSpecRow ()); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataTableWriter.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataTableWriter.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataTableWriter.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataTableWriter.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,602 +0,0 @@ -// -// MetadataTableWriter.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Thu Feb 22 14:39:38 CET 2007 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using System; - using System.Collections; - - using Mono.Cecil.Binary; - - internal sealed class MetadataTableWriter : BaseMetadataTableVisitor { - - MetadataRoot m_root; - TablesHeap m_heap; - MetadataRowWriter m_mrrw; - MemoryBinaryWriter m_binaryWriter; - - public MetadataTableWriter (MetadataWriter mrv, MemoryBinaryWriter writer) - { - m_root = mrv.GetMetadataRoot (); - m_heap = m_root.Streams.TablesHeap; - m_binaryWriter = writer; - m_mrrw = new MetadataRowWriter (this); - } - - public MetadataRoot GetMetadataRoot () - { - return m_root; - } - - public override IMetadataRowVisitor GetRowVisitor () - { - return m_mrrw; - } - - public MemoryBinaryWriter GetWriter () - { - return m_binaryWriter; - } - - void InitializeTable (IMetadataTable table) - { - table.Rows = new RowCollection (); - m_heap.Valid |= 1L << table.Id; - m_heap.Tables.Add (table); - } - - void WriteCount (int rid) - { - if (m_heap.HasTable (rid)) - m_binaryWriter.Write (m_heap [rid].Rows.Count); - } - - public AssemblyTable GetAssemblyTable () - { - AssemblyTable table = m_heap [AssemblyTable.RId] as AssemblyTable; - if (table != null) - return table; - - table = new AssemblyTable (); - InitializeTable (table); - return table; - } - - public AssemblyOSTable GetAssemblyOSTable () - { - AssemblyOSTable table = m_heap [AssemblyOSTable.RId] as AssemblyOSTable; - if (table != null) - return table; - - table = new AssemblyOSTable (); - InitializeTable (table); - return table; - } - - public AssemblyProcessorTable GetAssemblyProcessorTable () - { - AssemblyProcessorTable table = m_heap [AssemblyProcessorTable.RId] as AssemblyProcessorTable; - if (table != null) - return table; - - table = new AssemblyProcessorTable (); - InitializeTable (table); - return table; - } - - public AssemblyRefTable GetAssemblyRefTable () - { - AssemblyRefTable table = m_heap [AssemblyRefTable.RId] as AssemblyRefTable; - if (table != null) - return table; - - table = new AssemblyRefTable (); - InitializeTable (table); - return table; - } - - public AssemblyRefOSTable GetAssemblyRefOSTable () - { - AssemblyRefOSTable table = m_heap [AssemblyRefOSTable.RId] as AssemblyRefOSTable; - if (table != null) - return table; - - table = new AssemblyRefOSTable (); - InitializeTable (table); - return table; - } - - public AssemblyRefProcessorTable GetAssemblyRefProcessorTable () - { - AssemblyRefProcessorTable table = m_heap [AssemblyRefProcessorTable.RId] as AssemblyRefProcessorTable; - if (table != null) - return table; - - table = new AssemblyRefProcessorTable (); - InitializeTable (table); - return table; - } - - public ClassLayoutTable GetClassLayoutTable () - { - ClassLayoutTable table = m_heap [ClassLayoutTable.RId] as ClassLayoutTable; - if (table != null) - return table; - - table = new ClassLayoutTable (); - InitializeTable (table); - return table; - } - - public ConstantTable GetConstantTable () - { - ConstantTable table = m_heap [ConstantTable.RId] as ConstantTable; - if (table != null) - return table; - - table = new ConstantTable (); - InitializeTable (table); - return table; - } - - public CustomAttributeTable GetCustomAttributeTable () - { - CustomAttributeTable table = m_heap [CustomAttributeTable.RId] as CustomAttributeTable; - if (table != null) - return table; - - table = new CustomAttributeTable (); - InitializeTable (table); - return table; - } - - public DeclSecurityTable GetDeclSecurityTable () - { - DeclSecurityTable table = m_heap [DeclSecurityTable.RId] as DeclSecurityTable; - if (table != null) - return table; - - table = new DeclSecurityTable (); - InitializeTable (table); - return table; - } - - public EventTable GetEventTable () - { - EventTable table = m_heap [EventTable.RId] as EventTable; - if (table != null) - return table; - - table = new EventTable (); - InitializeTable (table); - return table; - } - - public EventMapTable GetEventMapTable () - { - EventMapTable table = m_heap [EventMapTable.RId] as EventMapTable; - if (table != null) - return table; - - table = new EventMapTable (); - InitializeTable (table); - return table; - } - - public EventPtrTable GetEventPtrTable () - { - EventPtrTable table = m_heap [EventPtrTable.RId] as EventPtrTable; - if (table != null) - return table; - - table = new EventPtrTable (); - InitializeTable (table); - return table; - } - - public ExportedTypeTable GetExportedTypeTable () - { - ExportedTypeTable table = m_heap [ExportedTypeTable.RId] as ExportedTypeTable; - if (table != null) - return table; - - table = new ExportedTypeTable (); - InitializeTable (table); - return table; - } - - public FieldTable GetFieldTable () - { - FieldTable table = m_heap [FieldTable.RId] as FieldTable; - if (table != null) - return table; - - table = new FieldTable (); - InitializeTable (table); - return table; - } - - public FieldLayoutTable GetFieldLayoutTable () - { - FieldLayoutTable table = m_heap [FieldLayoutTable.RId] as FieldLayoutTable; - if (table != null) - return table; - - table = new FieldLayoutTable (); - InitializeTable (table); - return table; - } - - public FieldMarshalTable GetFieldMarshalTable () - { - FieldMarshalTable table = m_heap [FieldMarshalTable.RId] as FieldMarshalTable; - if (table != null) - return table; - - table = new FieldMarshalTable (); - InitializeTable (table); - return table; - } - - public FieldPtrTable GetFieldPtrTable () - { - FieldPtrTable table = m_heap [FieldPtrTable.RId] as FieldPtrTable; - if (table != null) - return table; - - table = new FieldPtrTable (); - InitializeTable (table); - return table; - } - - public FieldRVATable GetFieldRVATable () - { - FieldRVATable table = m_heap [FieldRVATable.RId] as FieldRVATable; - if (table != null) - return table; - - table = new FieldRVATable (); - InitializeTable (table); - return table; - } - - public FileTable GetFileTable () - { - FileTable table = m_heap [FileTable.RId] as FileTable; - if (table != null) - return table; - - table = new FileTable (); - InitializeTable (table); - return table; - } - - public GenericParamTable GetGenericParamTable () - { - GenericParamTable table = m_heap [GenericParamTable.RId] as GenericParamTable; - if (table != null) - return table; - - table = new GenericParamTable (); - InitializeTable (table); - return table; - } - - public GenericParamConstraintTable GetGenericParamConstraintTable () - { - GenericParamConstraintTable table = m_heap [GenericParamConstraintTable.RId] as GenericParamConstraintTable; - if (table != null) - return table; - - table = new GenericParamConstraintTable (); - InitializeTable (table); - return table; - } - - public ImplMapTable GetImplMapTable () - { - ImplMapTable table = m_heap [ImplMapTable.RId] as ImplMapTable; - if (table != null) - return table; - - table = new ImplMapTable (); - InitializeTable (table); - return table; - } - - public InterfaceImplTable GetInterfaceImplTable () - { - InterfaceImplTable table = m_heap [InterfaceImplTable.RId] as InterfaceImplTable; - if (table != null) - return table; - - table = new InterfaceImplTable (); - InitializeTable (table); - return table; - } - - public ManifestResourceTable GetManifestResourceTable () - { - ManifestResourceTable table = m_heap [ManifestResourceTable.RId] as ManifestResourceTable; - if (table != null) - return table; - - table = new ManifestResourceTable (); - InitializeTable (table); - return table; - } - - public MemberRefTable GetMemberRefTable () - { - MemberRefTable table = m_heap [MemberRefTable.RId] as MemberRefTable; - if (table != null) - return table; - - table = new MemberRefTable (); - InitializeTable (table); - return table; - } - - public MethodTable GetMethodTable () - { - MethodTable table = m_heap [MethodTable.RId] as MethodTable; - if (table != null) - return table; - - table = new MethodTable (); - InitializeTable (table); - return table; - } - - public MethodImplTable GetMethodImplTable () - { - MethodImplTable table = m_heap [MethodImplTable.RId] as MethodImplTable; - if (table != null) - return table; - - table = new MethodImplTable (); - InitializeTable (table); - return table; - } - - public MethodPtrTable GetMethodPtrTable () - { - MethodPtrTable table = m_heap [MethodPtrTable.RId] as MethodPtrTable; - if (table != null) - return table; - - table = new MethodPtrTable (); - InitializeTable (table); - return table; - } - - public MethodSemanticsTable GetMethodSemanticsTable () - { - MethodSemanticsTable table = m_heap [MethodSemanticsTable.RId] as MethodSemanticsTable; - if (table != null) - return table; - - table = new MethodSemanticsTable (); - InitializeTable (table); - return table; - } - - public MethodSpecTable GetMethodSpecTable () - { - MethodSpecTable table = m_heap [MethodSpecTable.RId] as MethodSpecTable; - if (table != null) - return table; - - table = new MethodSpecTable (); - InitializeTable (table); - return table; - } - - public ModuleTable GetModuleTable () - { - ModuleTable table = m_heap [ModuleTable.RId] as ModuleTable; - if (table != null) - return table; - - table = new ModuleTable (); - InitializeTable (table); - return table; - } - - public ModuleRefTable GetModuleRefTable () - { - ModuleRefTable table = m_heap [ModuleRefTable.RId] as ModuleRefTable; - if (table != null) - return table; - - table = new ModuleRefTable (); - InitializeTable (table); - return table; - } - - public NestedClassTable GetNestedClassTable () - { - NestedClassTable table = m_heap [NestedClassTable.RId] as NestedClassTable; - if (table != null) - return table; - - table = new NestedClassTable (); - InitializeTable (table); - return table; - } - - public ParamTable GetParamTable () - { - ParamTable table = m_heap [ParamTable.RId] as ParamTable; - if (table != null) - return table; - - table = new ParamTable (); - InitializeTable (table); - return table; - } - - public ParamPtrTable GetParamPtrTable () - { - ParamPtrTable table = m_heap [ParamPtrTable.RId] as ParamPtrTable; - if (table != null) - return table; - - table = new ParamPtrTable (); - InitializeTable (table); - return table; - } - - public PropertyTable GetPropertyTable () - { - PropertyTable table = m_heap [PropertyTable.RId] as PropertyTable; - if (table != null) - return table; - - table = new PropertyTable (); - InitializeTable (table); - return table; - } - - public PropertyMapTable GetPropertyMapTable () - { - PropertyMapTable table = m_heap [PropertyMapTable.RId] as PropertyMapTable; - if (table != null) - return table; - - table = new PropertyMapTable (); - InitializeTable (table); - return table; - } - - public PropertyPtrTable GetPropertyPtrTable () - { - PropertyPtrTable table = m_heap [PropertyPtrTable.RId] as PropertyPtrTable; - if (table != null) - return table; - - table = new PropertyPtrTable (); - InitializeTable (table); - return table; - } - - public StandAloneSigTable GetStandAloneSigTable () - { - StandAloneSigTable table = m_heap [StandAloneSigTable.RId] as StandAloneSigTable; - if (table != null) - return table; - - table = new StandAloneSigTable (); - InitializeTable (table); - return table; - } - - public TypeDefTable GetTypeDefTable () - { - TypeDefTable table = m_heap [TypeDefTable.RId] as TypeDefTable; - if (table != null) - return table; - - table = new TypeDefTable (); - InitializeTable (table); - return table; - } - - public TypeRefTable GetTypeRefTable () - { - TypeRefTable table = m_heap [TypeRefTable.RId] as TypeRefTable; - if (table != null) - return table; - - table = new TypeRefTable (); - InitializeTable (table); - return table; - } - - public TypeSpecTable GetTypeSpecTable () - { - TypeSpecTable table = m_heap [TypeSpecTable.RId] as TypeSpecTable; - if (table != null) - return table; - - table = new TypeSpecTable (); - InitializeTable (table); - return table; - } - - public override void VisitTableCollection (TableCollection coll) - { - WriteCount (ModuleTable.RId); - WriteCount (TypeRefTable.RId); - WriteCount (TypeDefTable.RId); - WriteCount (FieldPtrTable.RId); - WriteCount (FieldTable.RId); - WriteCount (MethodPtrTable.RId); - WriteCount (MethodTable.RId); - WriteCount (ParamPtrTable.RId); - WriteCount (ParamTable.RId); - WriteCount (InterfaceImplTable.RId); - WriteCount (MemberRefTable.RId); - WriteCount (ConstantTable.RId); - WriteCount (CustomAttributeTable.RId); - WriteCount (FieldMarshalTable.RId); - WriteCount (DeclSecurityTable.RId); - WriteCount (ClassLayoutTable.RId); - WriteCount (FieldLayoutTable.RId); - WriteCount (StandAloneSigTable.RId); - WriteCount (EventMapTable.RId); - WriteCount (EventPtrTable.RId); - WriteCount (EventTable.RId); - WriteCount (PropertyMapTable.RId); - WriteCount (PropertyPtrTable.RId); - WriteCount (PropertyTable.RId); - WriteCount (MethodSemanticsTable.RId); - WriteCount (MethodImplTable.RId); - WriteCount (ModuleRefTable.RId); - WriteCount (TypeSpecTable.RId); - WriteCount (ImplMapTable.RId); - WriteCount (FieldRVATable.RId); - WriteCount (AssemblyTable.RId); - WriteCount (AssemblyProcessorTable.RId); - WriteCount (AssemblyOSTable.RId); - WriteCount (AssemblyRefTable.RId); - WriteCount (AssemblyRefProcessorTable.RId); - WriteCount (AssemblyRefOSTable.RId); - WriteCount (FileTable.RId); - WriteCount (ExportedTypeTable.RId); - WriteCount (ManifestResourceTable.RId); - WriteCount (NestedClassTable.RId); - WriteCount (GenericParamTable.RId); - WriteCount (MethodSpecTable.RId); - WriteCount (GenericParamConstraintTable.RId); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataToken.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataToken.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataToken.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataToken.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,55 +26,62 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil.Metadata { +namespace Mono.Cecil { public struct MetadataToken { - uint m_rid; - TokenType m_type; + readonly uint token; - public uint RID { - get { return m_rid; } + public uint RID { + get { return token & 0x00ffffff; } } public TokenType TokenType { - get { return m_type; } + get { return (TokenType) (token & 0xff000000); } } - public static readonly MetadataToken Zero = new MetadataToken ((TokenType) 0, 0); + public static readonly MetadataToken Zero = new MetadataToken ((uint) 0); - public MetadataToken (int token) + public MetadataToken (uint token) { - m_type = (TokenType) (token & 0xff000000); - m_rid = (uint) token & 0x00ffffff; + this.token = token; } - public MetadataToken (TokenType table, uint rid) + public MetadataToken (TokenType type) + : this (type, 0) { - m_type = table; - m_rid = rid; } - internal static MetadataToken FromMetadataRow (TokenType table, int rowIndex) + public MetadataToken (TokenType type, uint rid) { - return new MetadataToken (table, (uint) rowIndex + 1); + token = (uint) type | rid; } - public uint ToUInt () + public MetadataToken (TokenType type, int rid) { - return (uint) m_type | m_rid; + token = (uint) type | (uint) rid; + } + + public int ToInt32 () + { + return (int) token; + } + + public uint ToUInt32 () + { + return token; } public override int GetHashCode () { - return (int) ToUInt (); + return (int) token; } - public override bool Equals (object other) + public override bool Equals (object obj) { - if (other is MetadataToken) { - MetadataToken o = (MetadataToken) other; - return o.m_rid == m_rid && o.m_type == m_type; + if (obj is MetadataToken) { + var other = (MetadataToken) obj; + return other.token == token; } return false; @@ -82,18 +89,17 @@ public static bool operator == (MetadataToken one, MetadataToken other) { - return one.Equals (other); + return one.token == other.token; } public static bool operator != (MetadataToken one, MetadataToken other) { - return !one.Equals (other); + return one.token != other.token; } public override string ToString () { - return string.Format ("{0} [0x{1}]", - m_type, m_rid.ToString ("x4")); + return string.Format ("[{0}:0x{1}]", TokenType, RID.ToString ("x4")); } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataWriter.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataWriter.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataWriter.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataWriter.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,506 +0,0 @@ -// -// MetadataWriter.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using System; - using System.Collections; - using System.IO; - using System.Text; - - using Mono.Cecil; - using Mono.Cecil.Binary; - - internal sealed class MetadataWriter : BaseMetadataVisitor { - - AssemblyDefinition m_assembly; - MetadataRoot m_root; - TargetRuntime m_runtime; - ImageWriter m_imgWriter; - MetadataTableWriter m_tableWriter; - MemoryBinaryWriter m_binaryWriter; - - IDictionary m_stringCache; - MemoryBinaryWriter m_stringWriter; - - IDictionary m_guidCache; - MemoryBinaryWriter m_guidWriter; - - IDictionary m_usCache; - MemoryBinaryWriter m_usWriter; - - IDictionary m_blobCache; - MemoryBinaryWriter m_blobWriter; - - MemoryBinaryWriter m_tWriter; - - MemoryBinaryWriter m_cilWriter; - - MemoryBinaryWriter m_fieldDataWriter; - MemoryBinaryWriter m_resWriter; - - uint m_mdStart, m_mdSize; - uint m_resStart, m_resSize; - uint m_snsStart, m_snsSize; - uint m_debugHeaderStart; - uint m_imporTableStart; - - uint m_entryPointToken; - - RVA m_cursor = new RVA (0x2050); - - public MemoryBinaryWriter CilWriter { - get { return m_cilWriter; } - } - - public uint DebugHeaderPosition { - get { return m_debugHeaderStart; } - } - - public uint ImportTablePosition { - get { return m_imporTableStart; } - } - - public uint EntryPointToken { - get { return m_entryPointToken; } - set { m_entryPointToken = value; } - } - - public MetadataWriter (AssemblyDefinition asm, MetadataRoot root, - AssemblyKind kind, TargetRuntime rt, BinaryWriter writer) - { - m_assembly = asm; - m_root = root; - m_runtime = rt; - m_imgWriter = new ImageWriter (this, kind, writer); - m_binaryWriter = m_imgWriter.GetTextWriter (); - - m_stringCache = new Hashtable (); - m_stringWriter = new MemoryBinaryWriter (Encoding.UTF8); - m_stringWriter.Write ((byte) 0); - - m_guidCache = new Hashtable (); - m_guidWriter = new MemoryBinaryWriter (); - - m_usCache = new Hashtable (); - m_usWriter = new MemoryBinaryWriter (Encoding.Unicode); - m_usWriter.Write ((byte) 0); - - m_blobCache = new Hashtable (); - m_blobWriter = new MemoryBinaryWriter (); - m_blobWriter.Write ((byte) 0); - - m_tWriter = new MemoryBinaryWriter (); - m_tableWriter = new MetadataTableWriter (this, m_tWriter); - - m_cilWriter = new MemoryBinaryWriter (); - - m_fieldDataWriter = new MemoryBinaryWriter (); - m_resWriter = new MemoryBinaryWriter (); - } - - public MetadataRoot GetMetadataRoot () - { - return m_root; - } - - public ImageWriter GetImageWriter () - { - return m_imgWriter; - } - - public MemoryBinaryWriter GetWriter () - { - return m_binaryWriter; - } - - public MetadataTableWriter GetTableVisitor () - { - return m_tableWriter; - } - - public void AddData (int length) - { - m_cursor += new RVA ((uint) length); - } - - public RVA GetDataCursor () - { - return m_cursor; - } - - public uint AddString (string str) - { - if (str == null || str.Length == 0) - return 0; - - if (m_stringCache.Contains (str)) - return (uint) m_stringCache [str]; - - uint pointer = (uint) m_stringWriter.BaseStream.Position; - m_stringCache [str] = pointer; - m_stringWriter.Write (Encoding.UTF8.GetBytes (str)); - m_stringWriter.Write ('\0'); - return pointer; - } - - public uint AddBlob (byte [] data) - { - if (data == null || data.Length == 0) - return 0; - - // using CompactFramework compatible version of - // Convert.ToBase64String - string key = Convert.ToBase64String (data, 0, data.Length); - if (m_blobCache.Contains (key)) - return (uint) m_blobCache [key]; - - uint pointer = (uint) m_blobWriter.BaseStream.Position; - m_blobCache [key] = pointer; - Utilities.WriteCompressedInteger (m_blobWriter, data.Length); - m_blobWriter.Write (data); - return pointer; - } - - public uint AddGuid (Guid g) - { - if (m_guidCache.Contains (g)) - return (uint) m_guidCache [g]; - - uint pointer = (uint) m_guidWriter.BaseStream.Position; - m_guidCache [g] = pointer; - m_guidWriter.Write (g.ToByteArray ()); - return pointer + 1; - } - - public uint AddUserString (string str) - { - if (str == null) - return 0; - - if (m_usCache.Contains (str)) - return (uint) m_usCache [str]; - - uint pointer = (uint) m_usWriter.BaseStream.Position; - m_usCache [str] = pointer; - byte [] us = Encoding.Unicode.GetBytes (str); - Utilities.WriteCompressedInteger (m_usWriter, us.Length + 1); - m_usWriter.Write (us); - m_usWriter.Write ((byte) (RequiresSpecialHandling (us) ? 1 : 0)); - return pointer; - } - - static bool RequiresSpecialHandling (byte [] chars) - { - for (int i = 0; i < chars.Length; i++) { - byte c = chars [i]; - if ((i % 2) == 1) - if (c != 0) - return true; - - if (InRange (0x01, 0x08, c) || - InRange (0x0e, 0x1f, c) || - c == 0x27 || - c == 0x2d || - c == 0x7f) { - - return true; - } - } - - return false; - } - - static bool InRange (int left, int right, int value) - { - return left <= value && value <= right; - } - - void CreateStream (string name) - { - MetadataStream stream = new MetadataStream (); - stream.Header.Name = name; - stream.Heap = MetadataHeap.HeapFactory (stream); - m_root.Streams.Add (stream); - } - - void SetHeapSize (MetadataHeap heap, MemoryBinaryWriter data, byte flag) - { - if (data.BaseStream.Length > 65536) { - m_root.Streams.TablesHeap.HeapSizes |= flag; - heap.IndexSize = 4; - } else - heap.IndexSize = 2; - } - - public uint AddResource (byte [] data) - { - uint offset = (uint) m_resWriter.BaseStream.Position; - m_resWriter.Write (data.Length); - m_resWriter.Write (data); - m_resWriter.QuadAlign (); - return offset; - } - - public void AddFieldInitData (byte [] data) - { - m_fieldDataWriter.Write (data); - m_fieldDataWriter.QuadAlign (); - } - - uint GetStrongNameSignatureSize () - { - if (m_assembly.Name.PublicKey != null) { - // in fx 2.0 the key may be from 384 to 16384 bits - // so we must calculate the signature size based on - // the size of the public key (minus the 32 byte header) - int size = m_assembly.Name.PublicKey.Length; - if (size > 32) - return (uint) (size - 32); - // note: size == 16 for the ECMA "key" which is replaced - // by the runtime with a 1024 bits key (128 bytes) - } - return 128; // default strongname signature size - } - - public override void VisitMetadataRoot (MetadataRoot root) - { - WriteMemStream (m_cilWriter); - WriteMemStream (m_fieldDataWriter); - m_resStart = (uint) m_binaryWriter.BaseStream.Position; - WriteMemStream (m_resWriter); - m_resSize = (uint) (m_binaryWriter.BaseStream.Position - m_resStart); - - // for now, we only reserve the place for the strong name signature - if ((m_assembly.Name.Flags & AssemblyFlags.PublicKey) > 0) { - m_snsStart = (uint) m_binaryWriter.BaseStream.Position; - m_snsSize = GetStrongNameSignatureSize (); - m_binaryWriter.Write (new byte [m_snsSize]); - m_binaryWriter.QuadAlign (); - } - - // save place for debug header - if (m_imgWriter.GetImage ().DebugHeader != null) { - m_debugHeaderStart = (uint) m_binaryWriter.BaseStream.Position; - m_binaryWriter.Write (new byte [m_imgWriter.GetImage ().DebugHeader.GetSize ()]); - m_binaryWriter.QuadAlign (); - } - - m_mdStart = (uint) m_binaryWriter.BaseStream.Position; - - if (m_stringWriter.BaseStream.Length > 1) { - CreateStream (MetadataStream.Strings); - SetHeapSize (root.Streams.StringsHeap, m_stringWriter, 0x01); - m_stringWriter.QuadAlign (); - } - - if (m_guidWriter.BaseStream.Length > 0) { - CreateStream (MetadataStream.GUID); - SetHeapSize (root.Streams.GuidHeap, m_guidWriter, 0x02); - } - - if (m_blobWriter.BaseStream.Length > 1) { - CreateStream (MetadataStream.Blob); - SetHeapSize (root.Streams.BlobHeap, m_blobWriter, 0x04); - m_blobWriter.QuadAlign (); - } - - if (m_usWriter.BaseStream.Length > 2) { - CreateStream (MetadataStream.UserStrings); - m_usWriter.QuadAlign (); - } - - m_root.Header.MajorVersion = 1; - m_root.Header.MinorVersion = 1; - - switch (m_runtime) { - case TargetRuntime.NET_1_0 : - m_root.Header.Version = "v1.0.3705"; - break; - case TargetRuntime.NET_1_1 : - m_root.Header.Version = "v1.1.4322"; - break; - case TargetRuntime.NET_2_0 : - m_root.Header.Version = "v2.0.50727"; - break; - } - - m_root.Streams.TablesHeap.Tables.Accept (m_tableWriter); - - if (m_tWriter.BaseStream.Length == 0) - m_root.Streams.Remove (m_root.Streams.TablesHeap.GetStream ()); - } - - public override void VisitMetadataRootHeader (MetadataRoot.MetadataRootHeader header) - { - m_binaryWriter.Write (header.Signature); - m_binaryWriter.Write (header.MajorVersion); - m_binaryWriter.Write (header.MinorVersion); - m_binaryWriter.Write (header.Reserved); - m_binaryWriter.Write (header.Version.Length + 3 & (~3)); - m_binaryWriter.Write (Encoding.ASCII.GetBytes (header.Version)); - m_binaryWriter.QuadAlign (); - m_binaryWriter.Write (header.Flags); - m_binaryWriter.Write ((ushort) m_root.Streams.Count); - } - - public override void VisitMetadataStreamCollection (MetadataStreamCollection streams) - { - foreach (MetadataStream stream in streams) { - MetadataStream.MetadataStreamHeader header = stream.Header; - - header.Offset = (uint) (m_binaryWriter.BaseStream.Position); - m_binaryWriter.Write (header.Offset); - MemoryBinaryWriter container; - string name = header.Name; - uint size = 0; - switch (header.Name) { - case MetadataStream.Tables : - container = m_tWriter; - size += 24; // header - break; - case MetadataStream.Strings : - name += "\0\0\0\0"; - container = m_stringWriter; - break; - case MetadataStream.GUID : - container = m_guidWriter; - break; - case MetadataStream.Blob : - container = m_blobWriter; - break; - case MetadataStream.UserStrings : - container = m_usWriter; - break; - default : - throw new MetadataFormatException ("Unknown stream kind"); - } - - size += (uint) (container.BaseStream.Length + 3 & (~3)); - m_binaryWriter.Write (size); - m_binaryWriter.Write (Encoding.ASCII.GetBytes (name)); - m_binaryWriter.QuadAlign (); - } - } - - void WriteMemStream (MemoryBinaryWriter writer) - { - m_binaryWriter.Write (writer); - m_binaryWriter.QuadAlign (); - } - - void PatchStreamHeaderOffset (MetadataHeap heap) - { - long pos = m_binaryWriter.BaseStream.Position; - m_binaryWriter.BaseStream.Position = heap.GetStream ().Header.Offset; - m_binaryWriter.Write ((uint) (pos - m_mdStart)); - m_binaryWriter.BaseStream.Position = pos; - } - - public override void VisitGuidHeap (GuidHeap heap) - { - PatchStreamHeaderOffset (heap); - WriteMemStream (m_guidWriter); - } - - public override void VisitStringsHeap (StringsHeap heap) - { - PatchStreamHeaderOffset (heap); - WriteMemStream (m_stringWriter); - } - - public override void VisitTablesHeap (TablesHeap heap) - { - PatchStreamHeaderOffset (heap); - m_binaryWriter.Write (heap.Reserved); - switch (m_runtime) { - case TargetRuntime.NET_1_0 : - case TargetRuntime.NET_1_1 : - heap.MajorVersion = 1; - heap.MinorVersion = 0; - break; - case TargetRuntime.NET_2_0 : - heap.MajorVersion = 2; - heap.MinorVersion = 0; - break; - } - m_binaryWriter.Write (heap.MajorVersion); - m_binaryWriter.Write (heap.MinorVersion); - m_binaryWriter.Write (heap.HeapSizes); - m_binaryWriter.Write (heap.Reserved2); - m_binaryWriter.Write (heap.Valid); - m_binaryWriter.Write (heap.Sorted); - WriteMemStream (m_tWriter); - } - - public override void VisitBlobHeap (BlobHeap heap) - { - PatchStreamHeaderOffset (heap); - WriteMemStream (m_blobWriter); - } - - public override void VisitUserStringsHeap (UserStringsHeap heap) - { - PatchStreamHeaderOffset (heap); - WriteMemStream (m_usWriter); - } - - void PatchHeader () - { - Image img = m_imgWriter.GetImage (); - - img.CLIHeader.EntryPointToken = m_entryPointToken; - - if (m_mdSize > 0) - img.CLIHeader.Metadata = new DataDirectory ( - img.TextSection.VirtualAddress + m_mdStart, m_imporTableStart - m_mdStart); - - if (m_resSize > 0) - img.CLIHeader.Resources = new DataDirectory ( - img.TextSection.VirtualAddress + m_resStart, m_resSize); - - if (m_snsStart > 0) - img.CLIHeader.StrongNameSignature = new DataDirectory ( - img.TextSection.VirtualAddress + m_snsStart, m_snsSize); - - if (m_debugHeaderStart > 0) - img.PEOptionalHeader.DataDirectories.Debug = new DataDirectory ( - img.TextSection.VirtualAddress + m_debugHeaderStart, 0x1c); - } - - public override void TerminateMetadataRoot (MetadataRoot root) - { - m_mdSize = (uint) (m_binaryWriter.BaseStream.Position - m_mdStart); - m_imporTableStart = (uint) m_binaryWriter.BaseStream.Position; - m_binaryWriter.Write (new byte [0x60]); // imports - m_imgWriter.Initialize (); - PatchHeader (); - root.GetImage ().Accept (m_imgWriter); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Method.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Method.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Method.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Method.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ -// -// MethodTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using Mono.Cecil; - - using Mono.Cecil.Binary; - - public sealed class MethodTable : IMetadataTable { - - public const int RId = 0x06; - - RowCollection m_rows; - - public MethodRow this [int index] { - get { return m_rows [index] as MethodRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal MethodTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitMethodTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class MethodRow : IMetadataRow { - - public RVA RVA; - public MethodImplAttributes ImplFlags; - public MethodAttributes Flags; - public uint Name; - public uint Signature; - public uint ParamList; - - internal MethodRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitMethodRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodImpl.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodImpl.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodImpl.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodImpl.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -// -// MethodImplTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class MethodImplTable : IMetadataTable { - - public const int RId = 0x19; - - RowCollection m_rows; - - public MethodImplRow this [int index] { - get { return m_rows [index] as MethodImplRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal MethodImplTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitMethodImplTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class MethodImplRow : IMetadataRow { - - public uint Class; - public MetadataToken MethodBody; - public MetadataToken MethodDeclaration; - - internal MethodImplRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitMethodImplRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodPtr.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodPtr.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodPtr.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodPtr.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -// -// MethodPtrTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Thu Feb 22 14:39:38 CET 2007 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class MethodPtrTable : IMetadataTable { - - public const int RId = 0x05; - - RowCollection m_rows; - - public MethodPtrRow this [int index] { - get { return m_rows [index] as MethodPtrRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal MethodPtrTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitMethodPtrTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class MethodPtrRow : IMetadataRow { - - public uint Method; - - internal MethodPtrRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitMethodPtrRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodSemantics.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodSemantics.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodSemantics.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodSemantics.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -// -// MethodSemanticsTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using Mono.Cecil; - - public sealed class MethodSemanticsTable : IMetadataTable { - - public const int RId = 0x18; - - RowCollection m_rows; - - public MethodSemanticsRow this [int index] { - get { return m_rows [index] as MethodSemanticsRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal MethodSemanticsTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitMethodSemanticsTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class MethodSemanticsRow : IMetadataRow { - - public MethodSemanticsAttributes Semantics; - public uint Method; - public MetadataToken Association; - - internal MethodSemanticsRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitMethodSemanticsRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodSpec.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodSpec.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodSpec.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodSpec.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -// -// MethodSpecTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class MethodSpecTable : IMetadataTable { - - public const int RId = 0x2b; - - RowCollection m_rows; - - public MethodSpecRow this [int index] { - get { return m_rows [index] as MethodSpecRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal MethodSpecTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitMethodSpecTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class MethodSpecRow : IMetadataRow { - - public MetadataToken Method; - public uint Instantiation; - - internal MethodSpecRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitMethodSpecRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Module.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Module.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Module.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Module.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -// -// ModuleTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class ModuleTable : IMetadataTable { - - public const int RId = 0x00; - - RowCollection m_rows; - - public ModuleRow this [int index] { - get { return m_rows [index] as ModuleRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal ModuleTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitModuleTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class ModuleRow : IMetadataRow { - - public ushort Generation; - public uint Name; - public uint Mvid; - public uint EncId; - public uint EncBaseId; - - internal ModuleRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitModuleRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ModuleRef.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ModuleRef.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ModuleRef.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ModuleRef.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -// -// ModuleRefTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class ModuleRefTable : IMetadataTable { - - public const int RId = 0x1a; - - RowCollection m_rows; - - public ModuleRefRow this [int index] { - get { return m_rows [index] as ModuleRefRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal ModuleRefTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitModuleRefTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class ModuleRefRow : IMetadataRow { - - public uint Name; - - internal ModuleRefRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitModuleRefRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/NestedClass.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/NestedClass.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/NestedClass.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/NestedClass.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -// -// NestedClassTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class NestedClassTable : IMetadataTable { - - public const int RId = 0x29; - - RowCollection m_rows; - - public NestedClassRow this [int index] { - get { return m_rows [index] as NestedClassRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal NestedClassTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitNestedClassTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class NestedClassRow : IMetadataRow { - - public uint NestedClass; - public uint EnclosingClass; - - internal NestedClassRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitNestedClassRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Param.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Param.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Param.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Param.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -// -// ParamTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using Mono.Cecil; - - public sealed class ParamTable : IMetadataTable { - - public const int RId = 0x08; - - RowCollection m_rows; - - public ParamRow this [int index] { - get { return m_rows [index] as ParamRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal ParamTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitParamTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class ParamRow : IMetadataRow { - - public ParameterAttributes Flags; - public ushort Sequence; - public uint Name; - - internal ParamRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitParamRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ParamPtr.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ParamPtr.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ParamPtr.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ParamPtr.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -// -// ParamPtrTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Thu Feb 22 14:39:38 CET 2007 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class ParamPtrTable : IMetadataTable { - - public const int RId = 0x07; - - RowCollection m_rows; - - public ParamPtrRow this [int index] { - get { return m_rows [index] as ParamPtrRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal ParamPtrTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitParamPtrTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class ParamPtrRow : IMetadataRow { - - public uint Param; - - internal ParamPtrRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitParamPtrRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Property.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Property.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Property.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Property.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -// -// PropertyTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using Mono.Cecil; - - public sealed class PropertyTable : IMetadataTable { - - public const int RId = 0x17; - - RowCollection m_rows; - - public PropertyRow this [int index] { - get { return m_rows [index] as PropertyRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal PropertyTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitPropertyTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class PropertyRow : IMetadataRow { - - public PropertyAttributes Flags; - public uint Name; - public uint Type; - - internal PropertyRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitPropertyRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/PropertyMap.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/PropertyMap.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/PropertyMap.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/PropertyMap.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -// -// PropertyMapTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class PropertyMapTable : IMetadataTable { - - public const int RId = 0x15; - - RowCollection m_rows; - - public PropertyMapRow this [int index] { - get { return m_rows [index] as PropertyMapRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal PropertyMapTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitPropertyMapTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class PropertyMapRow : IMetadataRow { - - public uint Parent; - public uint PropertyList; - - internal PropertyMapRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitPropertyMapRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/PropertyPtr.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/PropertyPtr.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/PropertyPtr.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/PropertyPtr.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -// -// PropertyPtrTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Thu Feb 22 14:39:38 CET 2007 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class PropertyPtrTable : IMetadataTable { - - public const int RId = 0x16; - - RowCollection m_rows; - - public PropertyPtrRow this [int index] { - get { return m_rows [index] as PropertyPtrRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal PropertyPtrTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitPropertyPtrTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class PropertyPtrRow : IMetadataRow { - - public uint Property; - - internal PropertyPtrRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitPropertyPtrRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/RowCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/RowCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/RowCollection.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/RowCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,125 +0,0 @@ -// -// RowCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using System; - using System.Collections; - - public class RowCollection : ICollection, IMetadataRowVisitable { - - ArrayList m_items; - - public IMetadataRow this [int index] { - get { return m_items [index] as IMetadataRow; } - set { m_items [index] = value; } - } - - public int Count { - get { return m_items.Count; } - } - - public bool IsSynchronized { - get { return false; } - } - - public object SyncRoot { - get { return this; } - } - - internal RowCollection (int size) - { - m_items = new ArrayList (size); - } - - internal RowCollection () - { - m_items = new ArrayList (); - } - - internal void Add (IMetadataRow value) - { - m_items.Add (value); - } - - public void Clear () - { - m_items.Clear (); - } - - public bool Contains (IMetadataRow value) - { - return m_items.Contains (value); - } - - public int IndexOf (IMetadataRow value) - { - return m_items.IndexOf (value); - } - - public void Insert (int index, IMetadataRow value) - { - m_items.Insert (index, value); - } - - public void Remove (IMetadataRow value) - { - m_items.Remove (value); - } - - public void RemoveAt (int index) - { - m_items.Remove (index); - } - - public void CopyTo (Array ary, int index) - { - m_items.CopyTo (ary, index); - } - - public void Sort (IComparer comp) - { - m_items.Sort (comp); - } - - public IEnumerator GetEnumerator () - { - return m_items.GetEnumerator (); - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitRowCollection (this); - - for (int i = 0; i < m_items.Count; i++) - this [i].Accept (visitor); - - visitor.TerminateRowCollection (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Row.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Row.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Row.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Row.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,170 @@ +// +// Row.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System.Collections.Generic; + +namespace Mono.Cecil.Metadata { + + struct Row { + internal T1 Col1; + internal T2 Col2; + + public Row (T1 col1, T2 col2) + { + Col1 = col1; + Col2 = col2; + } + } + + struct Row { + internal T1 Col1; + internal T2 Col2; + internal T3 Col3; + + public Row (T1 col1, T2 col2, T3 col3) + { + Col1 = col1; + Col2 = col2; + Col3 = col3; + } + } + + struct Row { + internal T1 Col1; + internal T2 Col2; + internal T3 Col3; + internal T4 Col4; + + public Row (T1 col1, T2 col2, T3 col3, T4 col4) + { + Col1 = col1; + Col2 = col2; + Col3 = col3; + Col4 = col4; + } + } + + struct Row { + internal T1 Col1; + internal T2 Col2; + internal T3 Col3; + internal T4 Col4; + internal T5 Col5; + + public Row (T1 col1, T2 col2, T3 col3, T4 col4, T5 col5) + { + Col1 = col1; + Col2 = col2; + Col3 = col3; + Col4 = col4; + Col5 = col5; + } + } + + struct Row { + internal T1 Col1; + internal T2 Col2; + internal T3 Col3; + internal T4 Col4; + internal T5 Col5; + internal T6 Col6; + + public Row (T1 col1, T2 col2, T3 col3, T4 col4, T5 col5, T6 col6) + { + Col1 = col1; + Col2 = col2; + Col3 = col3; + Col4 = col4; + Col5 = col5; + Col6 = col6; + } + } + + struct Row { + internal T1 Col1; + internal T2 Col2; + internal T3 Col3; + internal T4 Col4; + internal T5 Col5; + internal T6 Col6; + internal T7 Col7; + internal T8 Col8; + internal T9 Col9; + + public Row (T1 col1, T2 col2, T3 col3, T4 col4, T5 col5, T6 col6, T7 col7, T8 col8, T9 col9) + { + Col1 = col1; + Col2 = col2; + Col3 = col3; + Col4 = col4; + Col5 = col5; + Col6 = col6; + Col7 = col7; + Col8 = col8; + Col9 = col9; + } + } + + sealed class RowEqualityComparer : IEqualityComparer>, IEqualityComparer>, IEqualityComparer> { + + public bool Equals (Row x, Row y) + { + return x.Col1 == y.Col1 + && x.Col2 == y.Col2; + } + + public int GetHashCode (Row obj) + { + string x = obj.Col1, y = obj.Col2; + return (x != null ? x.GetHashCode () : 0) ^ (y != null ? y.GetHashCode () : 0); + } + + public bool Equals (Row x, Row y) + { + return x.Col1 == y.Col1 + && x.Col2 == y.Col2; + } + + public int GetHashCode (Row obj) + { + return (int) (obj.Col1 ^ obj.Col2); + } + + public bool Equals (Row x, Row y) + { + return x.Col1 == y.Col1 + && x.Col2 == y.Col2 + && x.Col3 == y.Col3; + } + + public int GetHashCode (Row obj) + { + return (int) (obj.Col1 ^ obj.Col2 ^ obj.Col3); + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/StandAloneSig.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/StandAloneSig.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/StandAloneSig.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/StandAloneSig.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -// -// StandAloneSigTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class StandAloneSigTable : IMetadataTable { - - public const int RId = 0x11; - - RowCollection m_rows; - - public StandAloneSigRow this [int index] { - get { return m_rows [index] as StandAloneSigRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal StandAloneSigTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitStandAloneSigTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class StandAloneSigRow : IMetadataRow { - - public uint Signature; - - internal StandAloneSigRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitStandAloneSigRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/StringHeap.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/StringHeap.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/StringHeap.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/StringHeap.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,81 @@ +// +// StringHeap.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Collections.Generic; +using System.Text; + +using Mono.Cecil.PE; + +namespace Mono.Cecil.Metadata { + + class StringHeap : Heap { + + readonly Dictionary strings = new Dictionary (); + + public StringHeap (Section section, uint start, uint size) + : base (section, start, size) + { + } + + public string Read (uint index) + { + if (index == 0) + return string.Empty; + + string @string; + if (strings.TryGetValue (index, out @string)) + return @string; + + if (index > Size - 1) + return string.Empty; + + @string = ReadStringAt (index); + if (@string.Length != 0) + strings.Add (index, @string); + + return @string; + } + + protected virtual string ReadStringAt (uint index) + { + int length = 0; + byte [] data = Section.Data; + int start = (int) (index + Offset); + + for (int i = start; ; i++) { + if (data [i] == 0) + break; + + length++; + } + + return Encoding.UTF8.GetString (data, start, length); + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/StringsHeap.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/StringsHeap.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/StringsHeap.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/StringsHeap.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -// -// StringsHeap.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using System.Collections; - using System.Text; - - public class StringsHeap : MetadataHeap { - - IDictionary m_strings; - - public string this [uint index] { - get { - string str = m_strings [index] as string; - if (str == null) { - str = ReadStringAt (index); - m_strings [index] = str; - } - return str; - } - set { m_strings [index] = value; } - } - - internal StringsHeap (MetadataStream stream) : base (stream, MetadataStream.Strings) - { - m_strings = new Hashtable (); - } - - string ReadStringAt (uint index) - { - if (index > Data.Length - 1) - return string.Empty; - - int length = 0; - for (int i = (int) index; i < Data.Length; i++) { - if (Data [i] == 0) - break; - - length++; - } - - return Encoding.UTF8.GetString (Data, (int) index, length); - } - - public override void Accept (IMetadataVisitor visitor) - { - visitor.VisitStringsHeap (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TableCollection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TableCollection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TableCollection.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TableCollection.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,115 +0,0 @@ -// -// TableCollection.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using System; - using System.Collections; - - public class TableCollection : ICollection, IMetadataTableVisitable { - - IMetadataTable [] m_tables = new IMetadataTable [TablesHeap.MaxTableCount]; - - TablesHeap m_heap; - - public IMetadataTable this [int index] { - get { return m_tables [index]; } - set { m_tables [index] = value; } - } - - public int Count { - get { - return GetList ().Count; - } - } - - public bool IsSynchronized { - get { return false; } - } - - public object SyncRoot { - get { return this; } - } - - public TablesHeap Heap { - get { return m_heap; } - } - - internal TableCollection (TablesHeap heap) - { - m_heap = heap; - } - - internal void Add (IMetadataTable value) - { - m_tables [value.Id] = value; - } - - public bool Contains (IMetadataTable value) - { - return m_tables [value.Id] != null; - } - - internal void Remove (IMetadataTable value) - { - m_tables [value.Id] = null; - } - - public void CopyTo (Array array, int index) - { - GetList ().CopyTo (array, index); - } - - internal IList GetList () - { - IList tables = new ArrayList (); - for (int i = 0; i < m_tables.Length; i++) { - IMetadataTable table = m_tables [i]; - if (table != null) - tables.Add (table); - } - - return tables; - } - - public IEnumerator GetEnumerator () - { - return GetList ().GetEnumerator (); - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitTableCollection (this); - - foreach (IMetadataTable table in GetList ()) - table.Accept (visitor); - - visitor.TerminateTableCollection (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TableHeap.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TableHeap.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TableHeap.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TableHeap.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,153 @@ +// +// TableHeap.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using Mono.Cecil.PE; + +namespace Mono.Cecil.Metadata { + + enum Table : byte { + Module = 0x00, + TypeRef = 0x01, + TypeDef = 0x02, + FieldPtr = 0x03, + Field = 0x04, + MethodPtr = 0x05, + Method = 0x06, + ParamPtr = 0x07, + Param = 0x08, + InterfaceImpl = 0x09, + MemberRef = 0x0a, + Constant = 0x0b, + CustomAttribute = 0x0c, + FieldMarshal = 0x0d, + DeclSecurity = 0x0e, + ClassLayout = 0x0f, + FieldLayout = 0x10, + StandAloneSig = 0x11, + EventMap = 0x12, + EventPtr = 0x13, + Event = 0x14, + PropertyMap = 0x15, + PropertyPtr = 0x16, + Property = 0x17, + MethodSemantics = 0x18, + MethodImpl = 0x19, + ModuleRef = 0x1a, + TypeSpec = 0x1b, + ImplMap = 0x1c, + FieldRVA = 0x1d, + Assembly = 0x20, + AssemblyProcessor = 0x21, + AssemblyOS = 0x22, + AssemblyRef = 0x23, + AssemblyRefProcessor = 0x24, + AssemblyRefOS = 0x25, + File = 0x26, + ExportedType = 0x27, + ManifestResource = 0x28, + NestedClass = 0x29, + GenericParam = 0x2a, + MethodSpec = 0x2b, + GenericParamConstraint = 0x2c, + } + + struct TableInformation { + public uint Offset; + public uint Length; + public uint RowSize; + } + + sealed class TableHeap : Heap { + + public long Valid; + public long Sorted; + + public static readonly Table [] TableIdentifiers = new [] { + Table.Module, + Table.TypeRef, + Table.TypeDef, + Table.FieldPtr, + Table.Field, + Table.MethodPtr, + Table.Method, + Table.ParamPtr, + Table.Param, + Table.InterfaceImpl, + Table.MemberRef, + Table.Constant, + Table.CustomAttribute, + Table.FieldMarshal, + Table.DeclSecurity, + Table.ClassLayout, + Table.FieldLayout, + Table.StandAloneSig, + Table.EventMap, + Table.EventPtr, + Table.Event, + Table.PropertyMap, + Table.PropertyPtr, + Table.Property, + Table.MethodSemantics, + Table.MethodImpl, + Table.ModuleRef, + Table.TypeSpec, + Table.ImplMap, + Table.FieldRVA, + Table.Assembly, + Table.AssemblyProcessor, + Table.AssemblyOS, + Table.AssemblyRef, + Table.AssemblyRefProcessor, + Table.AssemblyRefOS, + Table.File, + Table.ExportedType, + Table.ManifestResource, + Table.NestedClass, + Table.GenericParam, + Table.MethodSpec, + Table.GenericParamConstraint, + }; + + public readonly TableInformation [] Tables = new TableInformation [45]; + + public TableInformation this [Table table] { + get { return Tables [(int) table]; } + } + + public TableHeap (Section section, uint start, uint size) + : base (section, start, size) + { + } + + public bool HasTable (Table table) + { + return (Valid & (1L << (int) table)) != 0; + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TablesHeap.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TablesHeap.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TablesHeap.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TablesHeap.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -// -// TablesHeap.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using System; - using System.Collections; - - public class TablesHeap : MetadataHeap { - - public uint Reserved; - public byte MajorVersion; - public byte MinorVersion; - public byte HeapSizes; - public byte Reserved2; - public long Valid; - public long Sorted; - - TableCollection m_tables; - - public const int MaxTableCount = 45; - - public TableCollection Tables { - get { return m_tables; } - set { m_tables = value; } - } - - public IMetadataTable this [int id] - { - get { return m_tables [id]; } - set { m_tables [id] = value; } - } - - internal TablesHeap (MetadataStream stream) : base(stream, MetadataStream.Tables) - { - } - - public bool HasTable (int id) - { - return (Valid & (1L << id)) != 0; - } - - public override void Accept (IMetadataVisitor visitor) - { - visitor.VisitTablesHeap (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TokenType.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TokenType.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TokenType.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TokenType.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,7 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -26,33 +26,31 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil.Metadata { +namespace Mono.Cecil { public enum TokenType : uint { - Module = 0x00000000, - TypeRef = 0x01000000, - TypeDef = 0x02000000, - Field = 0x04000000, - Method = 0x06000000, - Param = 0x08000000, - InterfaceImpl = 0x09000000, - MemberRef = 0x0a000000, - CustomAttribute = 0x0c000000, - Permission = 0x0e000000, - Signature = 0x11000000, - Event = 0x14000000, - Property = 0x17000000, - ModuleRef = 0x1a000000, - TypeSpec = 0x1b000000, - Assembly = 0x20000000, - AssemblyRef = 0x23000000, - File = 0x26000000, - ExportedType = 0x27000000, - ManifestResource = 0x28000000, - GenericParam = 0x2a000000, - MethodSpec = 0x2b000000, - String = 0x70000000, - Name = 0x71000000, - BaseType = 0x72000000 + Module = 0x00000000, + TypeRef = 0x01000000, + TypeDef = 0x02000000, + Field = 0x04000000, + Method = 0x06000000, + Param = 0x08000000, + InterfaceImpl = 0x09000000, + MemberRef = 0x0a000000, + CustomAttribute = 0x0c000000, + Permission = 0x0e000000, + Signature = 0x11000000, + Event = 0x14000000, + Property = 0x17000000, + ModuleRef = 0x1a000000, + TypeSpec = 0x1b000000, + Assembly = 0x20000000, + AssemblyRef = 0x23000000, + File = 0x26000000, + ExportedType = 0x27000000, + ManifestResource = 0x28000000, + GenericParam = 0x2a000000, + MethodSpec = 0x2b000000, + String = 0x70000000, } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TypeDef.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TypeDef.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TypeDef.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TypeDef.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -// -// TypeDefTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using Mono.Cecil; - - public sealed class TypeDefTable : IMetadataTable { - - public const int RId = 0x02; - - RowCollection m_rows; - - public TypeDefRow this [int index] { - get { return m_rows [index] as TypeDefRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal TypeDefTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitTypeDefTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class TypeDefRow : IMetadataRow { - - public TypeAttributes Flags; - public uint Name; - public uint Namespace; - public MetadataToken Extends; - public uint FieldList; - public uint MethodList; - - internal TypeDefRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitTypeDefRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TypeRef.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TypeRef.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TypeRef.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TypeRef.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -// -// TypeRefTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class TypeRefTable : IMetadataTable { - - public const int RId = 0x01; - - RowCollection m_rows; - - public TypeRefRow this [int index] { - get { return m_rows [index] as TypeRefRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal TypeRefTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitTypeRefTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class TypeRefRow : IMetadataRow { - - public MetadataToken ResolutionScope; - public uint Name; - public uint Namespace; - - internal TypeRefRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitTypeRefRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TypeSpec.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TypeSpec.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TypeSpec.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TypeSpec.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -// -// TypeSpecTable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Oct 10 23:08:26 CEST 2006 -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - public sealed class TypeSpecTable : IMetadataTable { - - public const int RId = 0x1b; - - RowCollection m_rows; - - public TypeSpecRow this [int index] { - get { return m_rows [index] as TypeSpecRow; } - set { m_rows [index] = value; } - } - - public RowCollection Rows { - get { return m_rows; } - set { m_rows = value; } - } - - public int Id { - get { return RId; } - } - - internal TypeSpecTable () - { - } - - public void Accept (IMetadataTableVisitor visitor) - { - visitor.VisitTypeSpecTable (this); - this.Rows.Accept (visitor.GetRowVisitor ()); - } - } - - public sealed class TypeSpecRow : IMetadataRow { - - public uint Signature; - - internal TypeSpecRow () - { - } - - public void Accept (IMetadataRowVisitor visitor) - { - visitor.VisitTypeSpecRow (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/UserStringHeap.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/UserStringHeap.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/UserStringHeap.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/UserStringHeap.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,59 @@ +// +// UserStringHeap.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; + +using Mono.Cecil.PE; + +namespace Mono.Cecil.Metadata { + + sealed class UserStringHeap : StringHeap { + + public UserStringHeap (Section section, uint start, uint size) + : base (section, start, size) + { + } + + protected override string ReadStringAt (uint index) + { + byte [] data = Section.Data; + int start = (int) (index + Offset); + + uint length = (uint) (data.ReadCompressedUInt32 (ref start) & ~1); + if (length < 1) + return string.Empty; + + var chars = new char [length / 2]; + + for (int i = start, j = 0; i < start + length; i += 2) + chars [j++] = (char) (data [i] | (data [i + 1] << 8)); + + return new string (chars); + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/UserStringsHeap.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/UserStringsHeap.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/UserStringsHeap.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/UserStringsHeap.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ -// -// UserStringsHeap.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Metadata { - - using System.Collections; - using System.Text; - - public class UserStringsHeap : MetadataHeap { - - readonly IDictionary m_strings; - - public string this [uint offset] { - get { - string us = m_strings [offset] as string; - if (us != null) - return us; - - us = ReadStringAt ((int) offset); - if (us != null && us.Length != 0) - m_strings [offset] = us; - - return us; - } - set { m_strings [offset] = value; } - } - - internal UserStringsHeap (MetadataStream stream) : base (stream, MetadataStream.UserStrings) - { - m_strings = new Hashtable (); - } - - string ReadStringAt (int offset) - { - int length = Utilities.ReadCompressedInteger (this.Data, offset, out offset) - 1; - if (length < 1) - return string.Empty; - - return Encoding.Unicode.GetString (this.Data, offset, length); - } - - public override void Accept (IMetadataVisitor visitor) - { - visitor.VisitUserStringsHeap (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Utilities.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Utilities.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Utilities.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Utilities.cs 2011-04-13 09:00:29.000000000 +0000 @@ -4,10 +4,7 @@ // Author: // Jb Evain (jbevain@gmail.com) // -// Generated by /CodeGen/cecil-gen.rb do not edit -// Tue Jul 17 00:22:33 +0200 2007 -// -// (C) 2005 Jb Evain +// Copyright (c) 2008 - 2010 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -29,617 +26,504 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -namespace Mono.Cecil.Metadata { +using System; - using System; - using System.Collections; - using System.IO; +using Mono.Cecil.Metadata; - class Utilities { +namespace Mono.Cecil { - Utilities () - { - } + static partial class Mixin { - public static int ReadCompressedInteger (byte [] data, int pos, out int start) + public static uint ReadCompressedUInt32 (this byte [] data, ref int position) { - int integer = 0; - start = pos; - if ((data [pos] & 0x80) == 0) { - integer = data [pos]; - start++; - } else if ((data [pos] & 0x40) == 0) { - integer = (data [start] & ~0x80) << 8; - integer |= data [pos + 1]; - start += 2; + uint integer; + if ((data [position] & 0x80) == 0) { + integer = data [position]; + position++; + } else if ((data [position] & 0x40) == 0) { + integer = (uint) (data [position] & ~0x80) << 8; + integer |= data [position + 1]; + position += 2; } else { - integer = (data [start] & ~0xc0) << 24; - integer |= data [pos + 1] << 16; - integer |= data [pos + 2] << 8; - integer |= data [pos + 3]; - start += 4; + integer = (uint) (data [position] & ~0xc0) << 24; + integer |= (uint) data [position + 1] << 16; + integer |= (uint) data [position + 2] << 8; + integer |= (uint) data [position + 3]; + position += 4; } return integer; } - public static int WriteCompressedInteger (BinaryWriter writer, int value) + public static MetadataToken GetMetadataToken (this CodedIndex self, uint data) { - if (value < 0x80) - writer.Write ((byte) value); - else if (value < 0x4000) { - writer.Write ((byte) (0x80 | (value >> 8))); - writer.Write ((byte) (value & 0xff)); - } else { - writer.Write ((byte) ((value >> 24) | 0xc0)); - writer.Write ((byte) ((value >> 16) & 0xff)); - writer.Write ((byte) ((value >> 8) & 0xff)); - writer.Write ((byte) (value & 0xff)); - } - return (int) writer.BaseStream.Position; - } - - public static MetadataToken GetMetadataToken (CodedIndex cidx, uint data) - { - uint rid = 0; - switch (cidx) { - case CodedIndex.TypeDefOrRef : + uint rid; + TokenType token_type; + switch (self) { + case CodedIndex.TypeDefOrRef: rid = data >> 2; switch (data & 3) { - case 0 : - return new MetadataToken (TokenType.TypeDef, rid); - case 1 : - return new MetadataToken (TokenType.TypeRef, rid); - case 2 : - return new MetadataToken (TokenType.TypeSpec, rid); - default : - return MetadataToken.Zero; + case 0: + token_type = TokenType.TypeDef; goto ret; + case 1: + token_type = TokenType.TypeRef; goto ret; + case 2: + token_type = TokenType.TypeSpec; goto ret; + default: + goto exit; } - case CodedIndex.HasConstant : + case CodedIndex.HasConstant: rid = data >> 2; switch (data & 3) { - case 0 : - return new MetadataToken (TokenType.Field, rid); - case 1 : - return new MetadataToken (TokenType.Param, rid); - case 2 : - return new MetadataToken (TokenType.Property, rid); - default : - return MetadataToken.Zero; + case 0: + token_type = TokenType.Field; goto ret; + case 1: + token_type = TokenType.Param; goto ret; + case 2: + token_type = TokenType.Property; goto ret; + default: + goto exit; } - case CodedIndex.HasCustomAttribute : + case CodedIndex.HasCustomAttribute: rid = data >> 5; switch (data & 31) { - case 0 : - return new MetadataToken (TokenType.Method, rid); - case 1 : - return new MetadataToken (TokenType.Field, rid); - case 2 : - return new MetadataToken (TokenType.TypeRef, rid); - case 3 : - return new MetadataToken (TokenType.TypeDef, rid); - case 4 : - return new MetadataToken (TokenType.Param, rid); - case 5 : - return new MetadataToken (TokenType.InterfaceImpl, rid); - case 6 : - return new MetadataToken (TokenType.MemberRef, rid); - case 7 : - return new MetadataToken (TokenType.Module, rid); - case 8 : - return new MetadataToken (TokenType.Permission, rid); - case 9 : - return new MetadataToken (TokenType.Property, rid); - case 10 : - return new MetadataToken (TokenType.Event, rid); - case 11 : - return new MetadataToken (TokenType.Signature, rid); - case 12 : - return new MetadataToken (TokenType.ModuleRef, rid); - case 13 : - return new MetadataToken (TokenType.TypeSpec, rid); - case 14 : - return new MetadataToken (TokenType.Assembly, rid); - case 15 : - return new MetadataToken (TokenType.AssemblyRef, rid); - case 16 : - return new MetadataToken (TokenType.File, rid); - case 17 : - return new MetadataToken (TokenType.ExportedType, rid); - case 18 : - return new MetadataToken (TokenType.ManifestResource, rid); - case 19 : - return new MetadataToken (TokenType.GenericParam, rid); - default : - return MetadataToken.Zero; + case 0: + token_type = TokenType.Method; goto ret; + case 1: + token_type = TokenType.Field; goto ret; + case 2: + token_type = TokenType.TypeRef; goto ret; + case 3: + token_type = TokenType.TypeDef; goto ret; + case 4: + token_type = TokenType.Param; goto ret; + case 5: + token_type = TokenType.InterfaceImpl; goto ret; + case 6: + token_type = TokenType.MemberRef; goto ret; + case 7: + token_type = TokenType.Module; goto ret; + case 8: + token_type = TokenType.Permission; goto ret; + case 9: + token_type = TokenType.Property; goto ret; + case 10: + token_type = TokenType.Event; goto ret; + case 11: + token_type = TokenType.Signature; goto ret; + case 12: + token_type = TokenType.ModuleRef; goto ret; + case 13: + token_type = TokenType.TypeSpec; goto ret; + case 14: + token_type = TokenType.Assembly; goto ret; + case 15: + token_type = TokenType.AssemblyRef; goto ret; + case 16: + token_type = TokenType.File; goto ret; + case 17: + token_type = TokenType.ExportedType; goto ret; + case 18: + token_type = TokenType.ManifestResource; goto ret; + case 19: + token_type = TokenType.GenericParam; goto ret; + default: + goto exit; } - case CodedIndex.HasFieldMarshal : + case CodedIndex.HasFieldMarshal: rid = data >> 1; switch (data & 1) { - case 0 : - return new MetadataToken (TokenType.Field, rid); - case 1 : - return new MetadataToken (TokenType.Param, rid); - default : - return MetadataToken.Zero; + case 0: + token_type = TokenType.Field; goto ret; + case 1: + token_type = TokenType.Param; goto ret; + default: + goto exit; } - case CodedIndex.HasDeclSecurity : + case CodedIndex.HasDeclSecurity: rid = data >> 2; switch (data & 3) { - case 0 : - return new MetadataToken (TokenType.TypeDef, rid); - case 1 : - return new MetadataToken (TokenType.Method, rid); - case 2 : - return new MetadataToken (TokenType.Assembly, rid); - default : - return MetadataToken.Zero; + case 0: + token_type = TokenType.TypeDef; goto ret; + case 1: + token_type = TokenType.Method; goto ret; + case 2: + token_type = TokenType.Assembly; goto ret; + default: + goto exit; } - case CodedIndex.MemberRefParent : + case CodedIndex.MemberRefParent: rid = data >> 3; switch (data & 7) { - case 0 : - return new MetadataToken (TokenType.TypeDef, rid); - case 1 : - return new MetadataToken (TokenType.TypeRef, rid); - case 2 : - return new MetadataToken (TokenType.ModuleRef, rid); - case 3 : - return new MetadataToken (TokenType.Method, rid); - case 4 : - return new MetadataToken (TokenType.TypeSpec, rid); - default : - return MetadataToken.Zero; + case 0: + token_type = TokenType.TypeDef; goto ret; + case 1: + token_type = TokenType.TypeRef; goto ret; + case 2: + token_type = TokenType.ModuleRef; goto ret; + case 3: + token_type = TokenType.Method; goto ret; + case 4: + token_type = TokenType.TypeSpec; goto ret; + default: + goto exit; } - case CodedIndex.HasSemantics : + case CodedIndex.HasSemantics: rid = data >> 1; switch (data & 1) { - case 0 : - return new MetadataToken (TokenType.Event, rid); - case 1 : - return new MetadataToken (TokenType.Property, rid); - default : - return MetadataToken.Zero; + case 0: + token_type = TokenType.Event; goto ret; + case 1: + token_type = TokenType.Property; goto ret; + default: + goto exit; } - case CodedIndex.MethodDefOrRef : + case CodedIndex.MethodDefOrRef: rid = data >> 1; switch (data & 1) { - case 0 : - return new MetadataToken (TokenType.Method, rid); - case 1 : - return new MetadataToken (TokenType.MemberRef, rid); - default : - return MetadataToken.Zero; + case 0: + token_type = TokenType.Method; goto ret; + case 1: + token_type = TokenType.MemberRef; goto ret; + default: + goto exit; } - case CodedIndex.MemberForwarded : + case CodedIndex.MemberForwarded: rid = data >> 1; switch (data & 1) { - case 0 : - return new MetadataToken (TokenType.Field, rid); - case 1 : - return new MetadataToken (TokenType.Method, rid); - default : - return MetadataToken.Zero; + case 0: + token_type = TokenType.Field; goto ret; + case 1: + token_type = TokenType.Method; goto ret; + default: + goto exit; } - case CodedIndex.Implementation : + case CodedIndex.Implementation: rid = data >> 2; switch (data & 3) { - case 0 : - return new MetadataToken (TokenType.File, rid); - case 1 : - return new MetadataToken (TokenType.AssemblyRef, rid); - case 2 : - return new MetadataToken (TokenType.ExportedType, rid); - default : - return MetadataToken.Zero; + case 0: + token_type = TokenType.File; goto ret; + case 1: + token_type = TokenType.AssemblyRef; goto ret; + case 2: + token_type = TokenType.ExportedType; goto ret; + default: + goto exit; } - case CodedIndex.CustomAttributeType : + case CodedIndex.CustomAttributeType: rid = data >> 3; switch (data & 7) { - case 2 : - return new MetadataToken (TokenType.Method, rid); - case 3 : - return new MetadataToken (TokenType.MemberRef, rid); - default : - return MetadataToken.Zero; + case 2: + token_type = TokenType.Method; goto ret; + case 3: + token_type = TokenType.MemberRef; goto ret; + default: + goto exit; } - case CodedIndex.ResolutionScope : + case CodedIndex.ResolutionScope: rid = data >> 2; switch (data & 3) { - case 0 : - return new MetadataToken (TokenType.Module, rid); - case 1 : - return new MetadataToken (TokenType.ModuleRef, rid); - case 2 : - return new MetadataToken (TokenType.AssemblyRef, rid); - case 3 : - return new MetadataToken (TokenType.TypeRef, rid); - default : - return MetadataToken.Zero; + case 0: + token_type = TokenType.Module; goto ret; + case 1: + token_type = TokenType.ModuleRef; goto ret; + case 2: + token_type = TokenType.AssemblyRef; goto ret; + case 3: + token_type = TokenType.TypeRef; goto ret; + default: + goto exit; } - case CodedIndex.TypeOrMethodDef : + case CodedIndex.TypeOrMethodDef: rid = data >> 1; switch (data & 1) { - case 0 : - return new MetadataToken (TokenType.TypeDef, rid); - case 1 : - return new MetadataToken (TokenType.Method, rid); - default : - return MetadataToken.Zero; + case 0: + token_type = TokenType.TypeDef; goto ret; + case 1: + token_type = TokenType.Method; goto ret; + default: goto exit; } - default : - return MetadataToken.Zero; + default: + goto exit; } + ret: + return new MetadataToken (token_type, rid); + exit: + return MetadataToken.Zero; } - public static uint CompressMetadataToken (CodedIndex cidx, MetadataToken token) +#if !READ_ONLY + public static uint CompressMetadataToken (this CodedIndex self, MetadataToken token) { uint ret = 0; if (token.RID == 0) return ret; - switch (cidx) { - case CodedIndex.TypeDefOrRef : + switch (self) { + case CodedIndex.TypeDefOrRef: ret = token.RID << 2; switch (token.TokenType) { - case TokenType.TypeDef : + case TokenType.TypeDef: return ret | 0; - case TokenType.TypeRef : + case TokenType.TypeRef: return ret | 1; - case TokenType.TypeSpec : + case TokenType.TypeSpec: return ret | 2; - default : - throw new MetadataFormatException("Non valid Token for TypeDefOrRef"); + default: + goto exit; } - case CodedIndex.HasConstant : + case CodedIndex.HasConstant: ret = token.RID << 2; switch (token.TokenType) { - case TokenType.Field : + case TokenType.Field: return ret | 0; - case TokenType.Param : + case TokenType.Param: return ret | 1; - case TokenType.Property : + case TokenType.Property: return ret | 2; - default : - throw new MetadataFormatException("Non valid Token for HasConstant"); + default: + goto exit; } - case CodedIndex.HasCustomAttribute : + case CodedIndex.HasCustomAttribute: ret = token.RID << 5; switch (token.TokenType) { - case TokenType.Method : + case TokenType.Method: return ret | 0; - case TokenType.Field : + case TokenType.Field: return ret | 1; - case TokenType.TypeRef : + case TokenType.TypeRef: return ret | 2; - case TokenType.TypeDef : + case TokenType.TypeDef: return ret | 3; - case TokenType.Param : + case TokenType.Param: return ret | 4; - case TokenType.InterfaceImpl : + case TokenType.InterfaceImpl: return ret | 5; - case TokenType.MemberRef : + case TokenType.MemberRef: return ret | 6; - case TokenType.Module : + case TokenType.Module: return ret | 7; - case TokenType.Permission : + case TokenType.Permission: return ret | 8; - case TokenType.Property : + case TokenType.Property: return ret | 9; - case TokenType.Event : + case TokenType.Event: return ret | 10; - case TokenType.Signature : + case TokenType.Signature: return ret | 11; - case TokenType.ModuleRef : + case TokenType.ModuleRef: return ret | 12; - case TokenType.TypeSpec : + case TokenType.TypeSpec: return ret | 13; - case TokenType.Assembly : + case TokenType.Assembly: return ret | 14; - case TokenType.AssemblyRef : + case TokenType.AssemblyRef: return ret | 15; - case TokenType.File : + case TokenType.File: return ret | 16; - case TokenType.ExportedType : + case TokenType.ExportedType: return ret | 17; - case TokenType.ManifestResource : + case TokenType.ManifestResource: return ret | 18; - case TokenType.GenericParam : + case TokenType.GenericParam: return ret | 19; - default : - throw new MetadataFormatException("Non valid Token for HasCustomAttribute"); + default: + goto exit; } - case CodedIndex.HasFieldMarshal : + case CodedIndex.HasFieldMarshal: ret = token.RID << 1; switch (token.TokenType) { - case TokenType.Field : + case TokenType.Field: return ret | 0; - case TokenType.Param : + case TokenType.Param: return ret | 1; - default : - throw new MetadataFormatException("Non valid Token for HasFieldMarshal"); + default: + goto exit; } - case CodedIndex.HasDeclSecurity : + case CodedIndex.HasDeclSecurity: ret = token.RID << 2; switch (token.TokenType) { - case TokenType.TypeDef : + case TokenType.TypeDef: return ret | 0; - case TokenType.Method : + case TokenType.Method: return ret | 1; - case TokenType.Assembly : + case TokenType.Assembly: return ret | 2; - default : - throw new MetadataFormatException("Non valid Token for HasDeclSecurity"); + default: + goto exit; } - case CodedIndex.MemberRefParent : + case CodedIndex.MemberRefParent: ret = token.RID << 3; switch (token.TokenType) { - case TokenType.TypeDef : + case TokenType.TypeDef: return ret | 0; - case TokenType.TypeRef : + case TokenType.TypeRef: return ret | 1; - case TokenType.ModuleRef : + case TokenType.ModuleRef: return ret | 2; - case TokenType.Method : + case TokenType.Method: return ret | 3; - case TokenType.TypeSpec : + case TokenType.TypeSpec: return ret | 4; - default : - throw new MetadataFormatException("Non valid Token for MemberRefParent"); + default: + goto exit; } - case CodedIndex.HasSemantics : + case CodedIndex.HasSemantics: ret = token.RID << 1; switch (token.TokenType) { - case TokenType.Event : + case TokenType.Event: return ret | 0; - case TokenType.Property : + case TokenType.Property: return ret | 1; - default : - throw new MetadataFormatException("Non valid Token for HasSemantics"); + default: + goto exit; } - case CodedIndex.MethodDefOrRef : + case CodedIndex.MethodDefOrRef: ret = token.RID << 1; switch (token.TokenType) { - case TokenType.Method : + case TokenType.Method: return ret | 0; - case TokenType.MemberRef : + case TokenType.MemberRef: return ret | 1; - default : - throw new MetadataFormatException("Non valid Token for MethodDefOrRef"); + default: + goto exit; } - case CodedIndex.MemberForwarded : + case CodedIndex.MemberForwarded: ret = token.RID << 1; switch (token.TokenType) { - case TokenType.Field : + case TokenType.Field: return ret | 0; - case TokenType.Method : + case TokenType.Method: return ret | 1; - default : - throw new MetadataFormatException("Non valid Token for MemberForwarded"); + default: + goto exit; } - case CodedIndex.Implementation : + case CodedIndex.Implementation: ret = token.RID << 2; switch (token.TokenType) { - case TokenType.File : + case TokenType.File: return ret | 0; - case TokenType.AssemblyRef : + case TokenType.AssemblyRef: return ret | 1; - case TokenType.ExportedType : + case TokenType.ExportedType: return ret | 2; - default : - throw new MetadataFormatException("Non valid Token for Implementation"); + default: + goto exit; } - case CodedIndex.CustomAttributeType : + case CodedIndex.CustomAttributeType: ret = token.RID << 3; switch (token.TokenType) { - case TokenType.Method : + case TokenType.Method: return ret | 2; - case TokenType.MemberRef : + case TokenType.MemberRef: return ret | 3; - default : - throw new MetadataFormatException("Non valid Token for CustomAttributeType"); + default: + goto exit; } - case CodedIndex.ResolutionScope : + case CodedIndex.ResolutionScope: ret = token.RID << 2; switch (token.TokenType) { - case TokenType.Module : + case TokenType.Module: return ret | 0; - case TokenType.ModuleRef : + case TokenType.ModuleRef: return ret | 1; - case TokenType.AssemblyRef : + case TokenType.AssemblyRef: return ret | 2; - case TokenType.TypeRef : + case TokenType.TypeRef: return ret | 3; - default : - throw new MetadataFormatException("Non valid Token for ResolutionScope"); + default: + goto exit; } - case CodedIndex.TypeOrMethodDef : + case CodedIndex.TypeOrMethodDef: ret = token.RID << 1; switch (token.TokenType) { - case TokenType.TypeDef : + case TokenType.TypeDef: return ret | 0; - case TokenType.Method : + case TokenType.Method: return ret | 1; - default : - throw new MetadataFormatException("Non valid Token for TypeOrMethodDef"); + default: + goto exit; } - default : - throw new MetadataFormatException ("Non valid CodedIndex"); + default: + goto exit; } + exit: + throw new ArgumentException (); } +#endif - internal static Type GetCorrespondingTable (TokenType t) + public static int GetSize (this CodedIndex self, Func counter) { - switch (t) { - case TokenType.Assembly : - return typeof (AssemblyTable); - case TokenType.AssemblyRef : - return typeof (AssemblyRefTable); - case TokenType.CustomAttribute : - return typeof (CustomAttributeTable); - case TokenType.Event : - return typeof (EventTable); - case TokenType.ExportedType : - return typeof (ExportedTypeTable); - case TokenType.Field : - return typeof (FieldTable); - case TokenType.File : - return typeof (FileTable); - case TokenType.InterfaceImpl : - return typeof (InterfaceImplTable); - case TokenType.MemberRef : - return typeof (MemberRefTable); - case TokenType.Method : - return typeof (MethodTable); - case TokenType.Module : - return typeof (ModuleTable); - case TokenType.ModuleRef : - return typeof (ModuleRefTable); - case TokenType.Param : - return typeof (ParamTable); - case TokenType.Permission : - return typeof (DeclSecurityTable); - case TokenType.Property : - return typeof (PropertyTable); - case TokenType.Signature : - return typeof (StandAloneSigTable); - case TokenType.TypeDef : - return typeof (TypeDefTable); - case TokenType.TypeRef : - return typeof (TypeRefTable); - case TokenType.TypeSpec : - return typeof (TypeSpecTable); - default : - return null; - } - } + int bits; + Table [] tables; - internal delegate int TableRowCounter (int rid); - - internal static int GetCodedIndexSize (CodedIndex ci, TableRowCounter rowCounter, IDictionary codedIndexCache) - { - int bits = 0, max = 0; - if (codedIndexCache [ci] != null) - return (int) codedIndexCache [ci]; - - int res = 0; - int [] rids; - switch (ci) { - case CodedIndex.TypeDefOrRef : + switch (self) { + case CodedIndex.TypeDefOrRef: bits = 2; - rids = new int [3]; - rids [0] = TypeDefTable.RId; - rids [1] = TypeRefTable.RId; - rids [2] = TypeSpecTable.RId; + tables = new [] { Table.TypeDef, Table.TypeRef, Table.TypeSpec }; break; - case CodedIndex.HasConstant : + case CodedIndex.HasConstant: bits = 2; - rids = new int [3]; - rids [0] = FieldTable.RId; - rids [1] = ParamTable.RId; - rids [2] = PropertyTable.RId; + tables = new [] { Table.Field, Table.Param, Table.Property }; break; - case CodedIndex.HasCustomAttribute : + case CodedIndex.HasCustomAttribute: bits = 5; - rids = new int [20]; - rids [0] = MethodTable.RId; - rids [1] = FieldTable.RId; - rids [2] = TypeRefTable.RId; - rids [3] = TypeDefTable.RId; - rids [4] = ParamTable.RId; - rids [5] = InterfaceImplTable.RId; - rids [6] = MemberRefTable.RId; - rids [7] = ModuleTable.RId; - rids [8] = DeclSecurityTable.RId; - rids [9] = PropertyTable.RId; - rids [10] = EventTable.RId; - rids [11] = StandAloneSigTable.RId; - rids [12] = ModuleRefTable.RId; - rids [13] = TypeSpecTable.RId; - rids [14] = AssemblyTable.RId; - rids [15] = AssemblyRefTable.RId; - rids [16] = FileTable.RId; - rids [17] = ExportedTypeTable.RId; - rids [18] = ManifestResourceTable.RId; - rids [19] = GenericParamTable.RId; + tables = new [] { + Table.Method, Table.Field, Table.TypeRef, Table.TypeDef, Table.Param, Table.InterfaceImpl, Table.MemberRef, + Table.Module, Table.DeclSecurity, Table.Property, Table.Event, Table.StandAloneSig, Table.ModuleRef, + Table.TypeSpec, Table.Assembly, Table.AssemblyRef, Table.File, Table.ExportedType, + Table.ManifestResource, Table.GenericParam + }; break; - case CodedIndex.HasFieldMarshal : + case CodedIndex.HasFieldMarshal: bits = 1; - rids = new int [2]; - rids [0] = FieldTable.RId; - rids [1] = ParamTable.RId; + tables = new [] { Table.Field, Table.Param }; break; - case CodedIndex.HasDeclSecurity : + case CodedIndex.HasDeclSecurity: bits = 2; - rids = new int [3]; - rids [0] = TypeDefTable.RId; - rids [1] = MethodTable.RId; - rids [2] = AssemblyTable.RId; + tables = new [] { Table.TypeDef, Table.Method, Table.Assembly }; break; - case CodedIndex.MemberRefParent : + case CodedIndex.MemberRefParent: bits = 3; - rids = new int [5]; - rids [0] = TypeDefTable.RId; - rids [1] = TypeRefTable.RId; - rids [2] = ModuleRefTable.RId; - rids [3] = MethodTable.RId; - rids [4] = TypeSpecTable.RId; + tables = new [] { Table.TypeDef, Table.TypeRef, Table.ModuleRef, Table.Method, Table.TypeSpec }; break; - case CodedIndex.HasSemantics : + case CodedIndex.HasSemantics: bits = 1; - rids = new int [2]; - rids [0] = EventTable.RId; - rids [1] = PropertyTable.RId; + tables = new [] { Table.Event, Table.Property }; break; - case CodedIndex.MethodDefOrRef : + case CodedIndex.MethodDefOrRef: bits = 1; - rids = new int [2]; - rids [0] = MethodTable.RId; - rids [1] = MemberRefTable.RId; + tables = new [] { Table.Method, Table.MemberRef }; break; - case CodedIndex.MemberForwarded : + case CodedIndex.MemberForwarded: bits = 1; - rids = new int [2]; - rids [0] = FieldTable.RId; - rids [1] = MethodTable.RId; + tables = new [] { Table.Field, Table.Method }; break; - case CodedIndex.Implementation : + case CodedIndex.Implementation: bits = 2; - rids = new int [3]; - rids [0] = FileTable.RId; - rids [1] = AssemblyRefTable.RId; - rids [2] = ExportedTypeTable.RId; + tables = new [] { Table.File, Table.AssemblyRef, Table.ExportedType }; break; - case CodedIndex.CustomAttributeType : + case CodedIndex.CustomAttributeType: bits = 3; - rids = new int [2]; - rids [0] = MethodTable.RId; - rids [1] = MemberRefTable.RId; + tables = new [] { Table.Method, Table.MemberRef }; break; - case CodedIndex.ResolutionScope : + case CodedIndex.ResolutionScope: bits = 2; - rids = new int [4]; - rids [0] = ModuleTable.RId; - rids [1] = ModuleRefTable.RId; - rids [2] = AssemblyRefTable.RId; - rids [3] = TypeRefTable.RId; + tables = new [] { Table.Module, Table.ModuleRef, Table.AssemblyRef, Table.TypeRef }; break; - case CodedIndex.TypeOrMethodDef : + case CodedIndex.TypeOrMethodDef: bits = 1; - rids = new int [2]; - rids [0] = TypeDefTable.RId; - rids [1] = MethodTable.RId; + tables = new [] { Table.TypeDef, Table.Method }; break; - default : - throw new MetadataFormatException ("Non valid CodedIndex"); + default: + throw new ArgumentException (); } - for (int i = 0; i < rids.Length; i++) { - int rows = rowCounter (rids [i]); - if (rows > max) max = rows; + int max = 0; + + for (int i = 0; i < tables.Length; i++) { + max = System.Math.Max (counter (tables [i]), max); } - res = max < (1 << (16 - bits)) ? 2 : 4; - codedIndexCache [ci] = res; - return res; + return max < (1 << (16 - bits)) ? 2 : 4; } } } diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/BinaryStreamReader.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/BinaryStreamReader.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/BinaryStreamReader.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/BinaryStreamReader.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,51 @@ +// +// BinaryStreamReader.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.IO; + +namespace Mono.Cecil.PE { + + class BinaryStreamReader : BinaryReader { + + public BinaryStreamReader (Stream stream) + : base (stream) + { + } + + protected void Advance (int bytes) + { + BaseStream.Seek (bytes, SeekOrigin.Current); + } + + protected DataDirectory ReadDataDirectory () + { + return new DataDirectory (ReadUInt32 (), ReadUInt32 ()); + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/BinaryStreamWriter.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/BinaryStreamWriter.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/BinaryStreamWriter.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/BinaryStreamWriter.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,96 @@ +// +// BinaryStreamWriter.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.IO; + +#if !READ_ONLY + +namespace Mono.Cecil.PE { + + class BinaryStreamWriter : BinaryWriter { + + public BinaryStreamWriter (Stream stream) + : base (stream) + { + } + + public void WriteByte (byte value) + { + Write (value); + } + + public void WriteUInt16 (ushort value) + { + Write (value); + } + + public void WriteInt16 (short value) + { + Write (value); + } + + public void WriteUInt32 (uint value) + { + Write (value); + } + + public void WriteInt32 (int value) + { + Write (value); + } + + public void WriteUInt64 (ulong value) + { + Write (value); + } + + public void WriteBytes (byte [] bytes) + { + Write (bytes); + } + + public void WriteDataDirectory (DataDirectory directory) + { + Write (directory.VirtualAddress); + Write (directory.Size); + } + + public void WriteBuffer (ByteBuffer buffer) + { + Write (buffer.buffer, 0, buffer.length); + } + + protected void Advance (int bytes) + { + BaseStream.Seek (bytes, SeekOrigin.Current); + } + } +} + +#endif diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ByteBuffer.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ByteBuffer.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ByteBuffer.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ByteBuffer.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,342 @@ +// +// ByteBuffer.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; + +namespace Mono.Cecil.PE { + + class ByteBuffer { + + internal byte [] buffer; + internal int length; + internal int position; + + public ByteBuffer () + { + this.buffer = Empty.Array; + } + + public ByteBuffer (int length) + { + this.buffer = new byte [length]; + } + + public ByteBuffer (byte [] buffer) + { + this.buffer = buffer ?? Empty.Array; + this.length = this.buffer.Length; + } + + public void Reset (byte [] buffer) + { + this.buffer = buffer ?? Empty.Array; + this.length = this.buffer.Length; + } + + public void Advance (int length) + { + position += length; + } + + public byte ReadByte () + { + return buffer [position++]; + } + + public sbyte ReadSByte () + { + return (sbyte) ReadByte (); + } + + public byte [] ReadBytes (int length) + { + var bytes = new byte [length]; + Buffer.BlockCopy (buffer, position, bytes, 0, length); + position += length; + return bytes; + } + + public ushort ReadUInt16 () + { + ushort value = (ushort) (buffer [position] + | (buffer [position + 1] << 8)); + position += 2; + return value; + } + + public short ReadInt16 () + { + return (short) ReadUInt16 (); + } + + public uint ReadUInt32 () + { + uint value = (uint) (buffer [position] + | (buffer [position + 1] << 8) + | (buffer [position + 2] << 16) + | (buffer [position + 3] << 24)); + position += 4; + return value; + } + + public int ReadInt32 () + { + return (int) ReadUInt32 (); + } + + public ulong ReadUInt64 () + { + uint low = ReadUInt32 (); + uint high = ReadUInt32 (); + + return (((ulong) high) << 32) | low; + } + + public long ReadInt64 () + { + return (long) ReadUInt64 (); + } + + public uint ReadCompressedUInt32 () + { + byte first = ReadByte (); + if ((first & 0x80) == 0) + return first; + + if ((first & 0x40) == 0) + return ((uint) (first & ~0x80) << 8) + | ReadByte (); + + return ((uint) (first & ~0xc0) << 24) + | (uint) ReadByte () << 16 + | (uint) ReadByte () << 8 + | ReadByte (); + } + + public int ReadCompressedInt32 () + { + var value = (int) ReadCompressedUInt32 (); + + return (value & 1) != 0 + ? -(value >> 1) + : value >> 1; + } + + public float ReadSingle () + { + if (!BitConverter.IsLittleEndian) { + var bytes = ReadBytes (4); + Array.Reverse (bytes); + return BitConverter.ToSingle (bytes, 0); + } + + float value = BitConverter.ToSingle (buffer, position); + position += 4; + return value; + } + + public double ReadDouble () + { + if (!BitConverter.IsLittleEndian) { + var bytes = ReadBytes (8); + Array.Reverse (bytes); + return BitConverter.ToDouble (bytes, 0); + } + + double value = BitConverter.ToDouble (buffer, position); + position += 8; + return value; + } + +#if !READ_ONLY + + public void WriteByte (byte value) + { + if (position == buffer.Length) + Grow (1); + + buffer [position++] = value; + + if (position > length) + length = position; + } + + public void WriteSByte (sbyte value) + { + WriteByte ((byte) value); + } + + public void WriteUInt16 (ushort value) + { + if (position + 2 > buffer.Length) + Grow (2); + + buffer [position++] = (byte) value; + buffer [position++] = (byte) (value >> 8); + + if (position > length) + length = position; + } + + public void WriteInt16 (short value) + { + WriteUInt16 ((ushort) value); + } + + public void WriteUInt32 (uint value) + { + if (position + 4 > buffer.Length) + Grow (4); + + buffer [position++] = (byte) value; + buffer [position++] = (byte) (value >> 8); + buffer [position++] = (byte) (value >> 16); + buffer [position++] = (byte) (value >> 24); + + if (position > length) + length = position; + } + + public void WriteInt32 (int value) + { + WriteUInt32 ((uint) value); + } + + public void WriteUInt64 (ulong value) + { + if (position + 8 > buffer.Length) + Grow (8); + + buffer [position++] = (byte) value; + buffer [position++] = (byte) (value >> 8); + buffer [position++] = (byte) (value >> 16); + buffer [position++] = (byte) (value >> 24); + buffer [position++] = (byte) (value >> 32); + buffer [position++] = (byte) (value >> 40); + buffer [position++] = (byte) (value >> 48); + buffer [position++] = (byte) (value >> 56); + + if (position > length) + length = position; + } + + public void WriteInt64 (long value) + { + WriteUInt64 ((ulong) value); + } + + public void WriteCompressedUInt32 (uint value) + { + if (value < 0x80) + WriteByte ((byte) value); + else if (value < 0x4000) { + WriteByte ((byte) (0x80 | (value >> 8))); + WriteByte ((byte) (value & 0xff)); + } else { + WriteByte ((byte) ((value >> 24) | 0xc0)); + WriteByte ((byte) ((value >> 16) & 0xff)); + WriteByte ((byte) ((value >> 8) & 0xff)); + WriteByte ((byte) (value & 0xff)); + } + } + + public void WriteCompressedInt32 (int value) + { + WriteCompressedUInt32 ((uint) ((value < 0) ? ((-value) << 1) | 1 : value << 1)); + } + + public void WriteBytes (byte [] bytes) + { + var length = bytes.Length; + if (position + length > buffer.Length) + Grow (length); + + Buffer.BlockCopy (bytes, 0, buffer, position, length); + position += length; + + if (position > this.length) + this.length = position; + } + + public void WriteBytes (int length) + { + if (position + length > buffer.Length) + Grow (length); + + position += length; + + if (position > this.length) + this.length = position; + } + + public void WriteBytes (ByteBuffer buffer) + { + if (position + buffer.length > this.buffer.Length) + Grow (buffer.length); + + Buffer.BlockCopy (buffer.buffer, 0, this.buffer, position, buffer.length); + position += buffer.length; + + if (position > this.length) + this.length = position; + } + + public void WriteSingle (float value) + { + var bytes = BitConverter.GetBytes (value); + + if (!BitConverter.IsLittleEndian) + Array.Reverse (bytes); + + WriteBytes (bytes); + } + + public void WriteDouble (double value) + { + var bytes = BitConverter.GetBytes (value); + + if (!BitConverter.IsLittleEndian) + Array.Reverse (bytes); + + WriteBytes (bytes); + } + + void Grow (int desired) + { + var current = this.buffer; + var current_length = current.Length; + + var buffer = new byte [System.Math.Max (current_length + desired, current_length * 2)]; + Buffer.BlockCopy (current, 0, buffer, 0, current_length); + this.buffer = buffer; + } + +#endif + + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ByteBufferEqualityComparer.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ByteBufferEqualityComparer.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ByteBufferEqualityComparer.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ByteBufferEqualityComparer.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,78 @@ +// +// ByteBufferEqualityComparer.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Collections.Generic; + +namespace Mono.Cecil.PE { + + sealed class ByteBufferEqualityComparer : IEqualityComparer { + + public bool Equals (ByteBuffer x, ByteBuffer y) + { + if (x.length != y.length) + return false; + + var x_buffer = x.buffer; + var y_buffer = y.buffer; + + for (int i = 0; i < x.length; i++) + if (x_buffer [i] != y_buffer [i]) + return false; + + return true; + } + + public int GetHashCode (ByteBuffer buffer) + { +#if !BYTE_BUFFER_WELL_DISTRIBUTED_HASH + var hash = 0; + var bytes = buffer.buffer; + for (int i = 0; i < buffer.length; i++) + hash = (hash * 37) ^ bytes [i]; + + return hash; +#else + const uint p = 16777619; + uint hash = 2166136261; + + var bytes = buffer.buffer; + for (int i = 0; i < buffer.length; i++) + hash = (hash ^ bytes [i]) * p; + + hash += hash << 13; + hash ^= hash >> 7; + hash += hash << 3; + hash ^= hash >> 17; + hash += hash << 5; + + return (int) hash; +#endif + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/DataDirectory.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/DataDirectory.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/DataDirectory.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/DataDirectory.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,50 @@ +// +// DataDirectory.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; + +using RVA = System.UInt32; + +namespace Mono.Cecil.PE { + + struct DataDirectory { + + public readonly RVA VirtualAddress; + public readonly uint Size; + + public bool IsZero { + get { return VirtualAddress == 0 && Size == 0; } + } + + public DataDirectory (RVA rva, uint size) + { + this.VirtualAddress = rva; + this.Size = size; + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/Image.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/Image.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/Image.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/Image.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,159 @@ +// +// Image.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; + +using Mono; +using Mono.Cecil.Cil; +using Mono.Cecil.Metadata; + +using RVA = System.UInt32; + +namespace Mono.Cecil.PE { + + sealed class Image { + + public ModuleKind Kind; + public TargetRuntime Runtime; + public TargetArchitecture Architecture; + public string FileName; + + public Section [] Sections; + + public Section MetadataSection; + + public uint EntryPointToken; + public ModuleAttributes Attributes; + + public DataDirectory Debug; + public DataDirectory Resources; + + public StringHeap StringHeap; + public BlobHeap BlobHeap; + public UserStringHeap UserStringHeap; + public GuidHeap GuidHeap; + public TableHeap TableHeap; + + readonly int [] coded_index_sizes = new int [13]; + + readonly Func counter; + + public Image () + { + counter = GetTableLength; + } + + public bool HasTable (Table table) + { + return GetTableLength (table) > 0; + } + + public int GetTableLength (Table table) + { + return (int) TableHeap [table].Length; + } + + public int GetTableIndexSize (Table table) + { + return GetTableLength (table) < 65536 ? 2 : 4; + } + + public int GetCodedIndexSize (CodedIndex coded_index) + { + var index = (int) coded_index; + var size = coded_index_sizes [index]; + if (size != 0) + return size; + + return coded_index_sizes [index] = coded_index.GetSize (counter); + } + + public uint ResolveVirtualAddress (RVA rva) + { + var section = GetSectionAtVirtualAddress (rva); + if (section == null) + throw new ArgumentOutOfRangeException (); + + return ResolveVirtualAddressInSection (rva, section); + } + + public uint ResolveVirtualAddressInSection (RVA rva, Section section) + { + return rva + section.PointerToRawData - section.VirtualAddress; + } + + public Section GetSection (string name) + { + var sections = this.Sections; + for (int i = 0; i < sections.Length; i++) { + var section = sections [i]; + if (section.Name == name) + return section; + } + + return null; + } + + public Section GetSectionAtVirtualAddress (RVA rva) + { + var sections = this.Sections; + for (int i = 0; i < sections.Length; i++) { + var section = sections [i]; + if (rva >= section.VirtualAddress && rva < section.VirtualAddress + section.SizeOfRawData) + return section; + } + + return null; + } + + public ImageDebugDirectory GetDebugHeader (out byte [] header) + { + var section = GetSectionAtVirtualAddress (Debug.VirtualAddress); + var buffer = new ByteBuffer (section.Data); + buffer.position = (int) (Debug.VirtualAddress - section.VirtualAddress); + + var directory = new ImageDebugDirectory { + Characteristics = buffer.ReadInt32 (), + TimeDateStamp = buffer.ReadInt32 (), + MajorVersion = buffer.ReadInt16 (), + MinorVersion = buffer.ReadInt16 (), + Type = buffer.ReadInt32 (), + SizeOfData = buffer.ReadInt32 (), + AddressOfRawData = buffer.ReadInt32 (), + PointerToRawData = buffer.ReadInt32 (), + }; + + buffer.position = (int) (directory.PointerToRawData - section.PointerToRawData); + + header = new byte [directory.SizeOfData]; + Buffer.BlockCopy (buffer.buffer, buffer.position, header, 0, header.Length); + + return directory; + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ImageReader.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ImageReader.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ImageReader.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ImageReader.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,678 @@ +// +// ImageReader.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.IO; + +using Mono.Cecil.Metadata; + +using RVA = System.UInt32; + +namespace Mono.Cecil.PE { + + sealed class ImageReader : BinaryStreamReader { + + readonly Image image; + + DataDirectory cli; + DataDirectory metadata; + + public ImageReader (Stream stream) + : base (stream) + { + image = new Image (); + + image.FileName = stream.GetFullyQualifiedName (); + } + + void MoveTo (DataDirectory directory) + { + BaseStream.Position = image.ResolveVirtualAddress (directory.VirtualAddress); + } + + void MoveTo (uint position) + { + BaseStream.Position = position; + } + + void ReadImage () + { + if (BaseStream.Length < 128) + throw new BadImageFormatException (); + + // - DOSHeader + + // PE 2 + // Start 58 + // Lfanew 4 + // End 64 + + if (ReadUInt16 () != 0x5a4d) + throw new BadImageFormatException (); + + Advance (58); + + MoveTo (ReadUInt32 ()); + + if (ReadUInt32 () != 0x00004550) + throw new BadImageFormatException (); + + // - PEFileHeader + + // Machine 2 + image.Architecture = ReadArchitecture (); + + // NumberOfSections 2 + ushort sections = ReadUInt16 (); + + // TimeDateStamp 4 + // PointerToSymbolTable 4 + // NumberOfSymbols 4 + // OptionalHeaderSize 2 + Advance (14); + + // Characteristics 2 + ushort characteristics = ReadUInt16 (); + + ushort subsystem; + ReadOptionalHeaders (out subsystem); + ReadSections (sections); + ReadCLIHeader (); + ReadMetadata (); + + image.Kind = GetModuleKind (characteristics, subsystem); + } + + TargetArchitecture ReadArchitecture () + { + var machine = ReadUInt16 (); + switch (machine) { + case 0x014c: + return TargetArchitecture.I386; + case 0x8664: + return TargetArchitecture.AMD64; + case 0x0200: + return TargetArchitecture.IA64; + } + + throw new NotSupportedException (); + } + + static ModuleKind GetModuleKind (ushort characteristics, ushort subsystem) + { + if ((characteristics & 0x2000) != 0) // ImageCharacteristics.Dll + return ModuleKind.Dll; + + if (subsystem == 0x2 || subsystem == 0x9) // SubSystem.WindowsGui || SubSystem.WindowsCeGui + return ModuleKind.Windows; + + return ModuleKind.Console; + } + + void ReadOptionalHeaders (out ushort subsystem) + { + // - PEOptionalHeader + // - StandardFieldsHeader + + // Magic 2 + bool pe64 = ReadUInt16 () == 0x20b; + + // pe32 || pe64 + + // LMajor 1 + // LMinor 1 + // CodeSize 4 + // InitializedDataSize 4 + // UninitializedDataSize4 + // EntryPointRVA 4 + // BaseOfCode 4 + // BaseOfData 4 || 0 + + // - NTSpecificFieldsHeader + + // ImageBase 4 || 8 + // SectionAlignment 4 + // FileAlignement 4 + // OSMajor 2 + // OSMinor 2 + // UserMajor 2 + // UserMinor 2 + // SubSysMajor 2 + // SubSysMinor 2 + // Reserved 4 + // ImageSize 4 + // HeaderSize 4 + // FileChecksum 4 + Advance (66); + + // SubSystem 2 + subsystem = ReadUInt16 (); + + // DLLFlags 2 + // StackReserveSize 4 || 8 + // StackCommitSize 4 || 8 + // HeapReserveSize 4 || 8 + // HeapCommitSize 4 || 8 + // LoaderFlags 4 + // NumberOfDataDir 4 + + // - DataDirectoriesHeader + + // ExportTable 8 + // ImportTable 8 + // ResourceTable 8 + // ExceptionTable 8 + // CertificateTable 8 + // BaseRelocationTable 8 + + Advance (pe64 ? 90 : 74); + + // Debug 8 + image.Debug = ReadDataDirectory (); + + // Copyright 8 + // GlobalPtr 8 + // TLSTable 8 + // LoadConfigTable 8 + // BoundImport 8 + // IAT 8 + // DelayImportDescriptor8 + Advance (56); + + // CLIHeader 8 + cli = ReadDataDirectory (); + + if (cli.IsZero) + throw new BadImageFormatException (); + + // Reserved 8 + Advance (8); + } + + string ReadAlignedString (int length) + { + int read = 0; + var buffer = new char [length]; + while (read < length) { + var current = ReadByte (); + if (current == 0) + break; + + buffer [read++] = (char) current; + } + + Advance (-1 + ((read + 4) & ~3) - read); + + return new string (buffer, 0, read); + } + + string ReadZeroTerminatedString (int length) + { + int read = 0; + var buffer = new char [length]; + var bytes = ReadBytes (length); + while (read < length) { + var current = bytes [read]; + if (current == 0) + break; + + buffer [read++] = (char) current; + } + + return new string (buffer, 0, read); + } + + void ReadSections (ushort count) + { + var sections = new Section [count]; + + for (int i = 0; i < count; i++) { + var section = new Section (); + + // Name + section.Name = ReadZeroTerminatedString (8); + + // VirtualSize 4 + Advance (4); + + // VirtualAddress 4 + section.VirtualAddress = ReadUInt32 (); + // SizeOfRawData 4 + section.SizeOfRawData = ReadUInt32 (); + // PointerToRawData 4 + section.PointerToRawData = ReadUInt32 (); + + // PointerToRelocations 4 + // PointerToLineNumbers 4 + // NumberOfRelocations 2 + // NumberOfLineNumbers 2 + // Characteristics 4 + Advance (16); + + sections [i] = section; + + if (section.Name == ".reloc") + continue; + + ReadSectionData (section); + } + + image.Sections = sections; + } + + void ReadSectionData (Section section) + { + var position = BaseStream.Position; + + MoveTo (section.PointerToRawData); + + var length = (int) section.SizeOfRawData; + var data = new byte [length]; + int offset = 0, read; + + while ((read = Read (data, offset, length - offset)) > 0) + offset += read; + + section.Data = data; + + BaseStream.Position = position; + } + + void ReadCLIHeader () + { + MoveTo (cli); + + // - CLIHeader + + // Cb 4 + // MajorRuntimeVersion 2 + // MinorRuntimeVersion 2 + Advance (8); + + // Metadata 8 + metadata = ReadDataDirectory (); + // Flags 4 + image.Attributes = (ModuleAttributes) ReadUInt32 (); + // EntryPointToken 4 + image.EntryPointToken = ReadUInt32 (); + // Resources 8 + image.Resources = ReadDataDirectory (); + // StrongNameSignature 8 + // CodeManagerTable 8 + // VTableFixups 8 + // ExportAddressTableJumps 8 + // ManagedNativeHeader 8 + } + + void ReadMetadata () + { + MoveTo (metadata); + + if (ReadUInt32 () != 0x424a5342) + throw new BadImageFormatException (); + + // MajorVersion 2 + // MinorVersion 2 + // Reserved 4 + Advance (8); + + var version = ReadZeroTerminatedString (ReadInt32 ()); + image.Runtime = version.ParseRuntime (); + + // Flags 2 + Advance (2); + + var streams = ReadUInt16 (); + + var section = image.GetSectionAtVirtualAddress (metadata.VirtualAddress); + if (section == null) + throw new BadImageFormatException (); + + image.MetadataSection = section; + + for (int i = 0; i < streams; i++) + ReadMetadataStream (section); + + if (image.TableHeap != null) + ReadTableHeap (); + } + + void ReadMetadataStream (Section section) + { + // Offset 4 + uint start = metadata.VirtualAddress - section.VirtualAddress + ReadUInt32 (); // relative to the section start + + // Size 4 + uint size = ReadUInt32 (); + + var name = ReadAlignedString (16); + switch (name) { + case "#~": + case "#-": + image.TableHeap = new TableHeap (section, start, size); + break; + case "#Strings": + image.StringHeap = new StringHeap (section, start, size); + break; + case "#Blob": + image.BlobHeap = new BlobHeap (section, start, size); + break; + case "#GUID": + image.GuidHeap = new GuidHeap (section, start, size); + break; + case "#US": + image.UserStringHeap = new UserStringHeap (section, start, size); + break; + } + } + + void ReadTableHeap () + { + var heap = image.TableHeap; + + uint start = heap.Section.PointerToRawData; + + MoveTo (heap.Offset + start); + + // Reserved 4 + // MajorVersion 1 + // MinorVersion 1 + Advance (6); + + // HeapSizes 1 + var sizes = ReadByte (); + + // Reserved2 1 + Advance (1); + + // Valid 8 + heap.Valid = ReadInt64 (); + + // Sorted 8 + heap.Sorted = ReadInt64 (); + + for (int i = 0; i < TableHeap.TableIdentifiers.Length; i++) { + var table = TableHeap.TableIdentifiers [i]; + if (!heap.HasTable (table)) + continue; + + heap.Tables [(int) table].Length = ReadUInt32 (); + } + + SetIndexSize (image.StringHeap, sizes, 0x1); + SetIndexSize (image.GuidHeap, sizes, 0x2); + SetIndexSize (image.BlobHeap, sizes, 0x4); + + ComputeTableInformations (); + } + + static void SetIndexSize (Heap heap, uint sizes, byte flag) + { + if (heap == null) + return; + + heap.IndexSize = (sizes & flag) > 0 ? 4 : 2; + } + + int GetTableIndexSize (Table table) + { + return image.GetTableIndexSize (table); + } + + int GetCodedIndexSize (CodedIndex index) + { + return image.GetCodedIndexSize (index); + } + + void ComputeTableInformations () + { + uint offset = (uint) BaseStream.Position - image.MetadataSection.PointerToRawData; // header + + int stridx_size = image.StringHeap.IndexSize; + int blobidx_size = image.BlobHeap != null ? image.BlobHeap.IndexSize : 2; + + var heap = image.TableHeap; + var tables = heap.Tables; + + for (int i = 0; i < TableHeap.TableIdentifiers.Length; i++) { + var table = TableHeap.TableIdentifiers [i]; + if (!heap.HasTable (table)) + continue; + + int size; + switch (table) { + case Table.Module: + size = 2 // Generation + + stridx_size // Name + + (image.GuidHeap.IndexSize * 3); // Mvid, EncId, EncBaseId + break; + case Table.TypeRef: + size = GetCodedIndexSize (CodedIndex.ResolutionScope) // ResolutionScope + + (stridx_size * 2); // Name, Namespace + break; + case Table.TypeDef: + size = 4 // Flags + + (stridx_size * 2) // Name, Namespace + + GetCodedIndexSize (CodedIndex.TypeDefOrRef) // BaseType + + GetTableIndexSize (Table.Field) // FieldList + + GetTableIndexSize (Table.Method); // MethodList + break; + case Table.FieldPtr: + size = GetTableIndexSize (Table.Field); // Field + break; + case Table.Field: + size = 2 // Flags + + stridx_size // Name + + blobidx_size; // Signature + break; + case Table.MethodPtr: + size = GetTableIndexSize (Table.Method); // Method + break; + case Table.Method: + size = 8 // Rva 4, ImplFlags 2, Flags 2 + + stridx_size // Name + + blobidx_size // Signature + + GetTableIndexSize (Table.Param); // ParamList + break; + case Table.ParamPtr: + size = GetTableIndexSize (Table.Param); // Param + break; + case Table.Param: + size = 4 // Flags 2, Sequence 2 + + stridx_size; // Name + break; + case Table.InterfaceImpl: + size = GetTableIndexSize (Table.TypeDef) // Class + + GetCodedIndexSize (CodedIndex.TypeDefOrRef); // Interface + break; + case Table.MemberRef: + size = GetCodedIndexSize (CodedIndex.MemberRefParent) // Class + + stridx_size // Name + + blobidx_size; // Signature + break; + case Table.Constant: + size = 2 // Type + + GetCodedIndexSize (CodedIndex.HasConstant) // Parent + + blobidx_size; // Value + break; + case Table.CustomAttribute: + size = GetCodedIndexSize (CodedIndex.HasCustomAttribute) // Parent + + GetCodedIndexSize (CodedIndex.CustomAttributeType) // Type + + blobidx_size; // Value + break; + case Table.FieldMarshal: + size = GetCodedIndexSize (CodedIndex.HasFieldMarshal) // Parent + + blobidx_size; // NativeType + break; + case Table.DeclSecurity: + size = 2 // Action + + GetCodedIndexSize (CodedIndex.HasDeclSecurity) // Parent + + blobidx_size; // PermissionSet + break; + case Table.ClassLayout: + size = 6 // PackingSize 2, ClassSize 4 + + GetTableIndexSize (Table.TypeDef); // Parent + break; + case Table.FieldLayout: + size = 4 // Offset + + GetTableIndexSize (Table.Field); // Field + break; + case Table.StandAloneSig: + size = blobidx_size; // Signature + break; + case Table.EventMap: + size = GetTableIndexSize (Table.TypeDef) // Parent + + GetTableIndexSize (Table.Event); // EventList + break; + case Table.EventPtr: + size = GetTableIndexSize (Table.Event); // Event + break; + case Table.Event: + size = 2 // Flags + + stridx_size // Name + + GetCodedIndexSize (CodedIndex.TypeDefOrRef); // EventType + break; + case Table.PropertyMap: + size = GetTableIndexSize (Table.TypeDef) // Parent + + GetTableIndexSize (Table.Property); // PropertyList + break; + case Table.PropertyPtr: + size = GetTableIndexSize (Table.Property); // Property + break; + case Table.Property: + size = 2 // Flags + + stridx_size // Name + + blobidx_size; // Type + break; + case Table.MethodSemantics: + size = 2 // Semantics + + GetTableIndexSize (Table.Method) // Method + + GetCodedIndexSize (CodedIndex.HasSemantics); // Association + break; + case Table.MethodImpl: + size = GetTableIndexSize (Table.TypeDef) // Class + + GetCodedIndexSize (CodedIndex.MethodDefOrRef) // MethodBody + + GetCodedIndexSize (CodedIndex.MethodDefOrRef); // MethodDeclaration + break; + case Table.ModuleRef: + size = stridx_size; // Name + break; + case Table.TypeSpec: + size = blobidx_size; // Signature + break; + case Table.ImplMap: + size = 2 // MappingFlags + + GetCodedIndexSize (CodedIndex.MemberForwarded) // MemberForwarded + + stridx_size // ImportName + + GetTableIndexSize (Table.ModuleRef); // ImportScope + break; + case Table.FieldRVA: + size = 4 // RVA + + GetTableIndexSize (Table.Field); // Field + break; + case Table.Assembly: + size = 16 // HashAlgId 4, Version 4 * 2, Flags 4 + + blobidx_size // PublicKey + + (stridx_size * 2); // Name, Culture + break; + case Table.AssemblyProcessor: + size = 4; // Processor + break; + case Table.AssemblyOS: + size = 12; // Platform 4, Version 2 * 4 + break; + case Table.AssemblyRef: + size = 12 // Version 2 * 4 + Flags 4 + + (blobidx_size * 2) // PublicKeyOrToken, HashValue + + (stridx_size * 2); // Name, Culture + break; + case Table.AssemblyRefProcessor: + size = 4 // Processor + + GetTableIndexSize (Table.AssemblyRef); // AssemblyRef + break; + case Table.AssemblyRefOS: + size = 12 // Platform 4, Version 2 * 4 + + GetTableIndexSize (Table.AssemblyRef); // AssemblyRef + break; + case Table.File: + size = 4 // Flags + + stridx_size // Name + + blobidx_size; // HashValue + break; + case Table.ExportedType: + size = 8 // Flags 4, TypeDefId 4 + + (stridx_size * 2) // Name, Namespace + + GetCodedIndexSize (CodedIndex.Implementation); // Implementation + break; + case Table.ManifestResource: + size = 8 // Offset, Flags + + stridx_size // Name + + GetCodedIndexSize (CodedIndex.Implementation); // Implementation + break; + case Table.NestedClass: + size = GetTableIndexSize (Table.TypeDef) // NestedClass + + GetTableIndexSize (Table.TypeDef); // EnclosingClass + break; + case Table.GenericParam: + size = 4 // Number, Flags + + GetCodedIndexSize (CodedIndex.TypeOrMethodDef) // Owner + + stridx_size; // Name + break; + case Table.MethodSpec: + size = GetCodedIndexSize (CodedIndex.MethodDefOrRef) // Method + + blobidx_size; // Instantiation + break; + case Table.GenericParamConstraint: + size = GetTableIndexSize (Table.GenericParam) // Owner + + GetCodedIndexSize (CodedIndex.TypeDefOrRef); // Constraint + break; + default: + throw new NotSupportedException (); + } + + int index = (int) table; + + tables [index].RowSize = (uint) size; + tables [index].Offset = offset; + + offset += (uint) size * tables [index].Length; + } + } + + public static Image ReadImageFrom (Stream stream) + { + try { + var reader = new ImageReader (stream); + reader.ReadImage (); + return reader.image; + } catch (EndOfStreamException e) { + throw new BadImageFormatException (stream.GetFullyQualifiedName (), e); + } + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ImageWriter.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ImageWriter.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ImageWriter.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ImageWriter.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,820 @@ +// +// ImageWriter.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.IO; + +#if !READ_ONLY + +using Mono.Cecil.Cil; +using Mono.Cecil.Metadata; + +using RVA = System.UInt32; + +namespace Mono.Cecil.PE { + + sealed class ImageWriter : BinaryStreamWriter { + + readonly ModuleDefinition module; + readonly MetadataBuilder metadata; + readonly TextMap text_map; + + ImageDebugDirectory debug_directory; + byte [] debug_data; + + ByteBuffer win32_resources; + + const uint pe_header_size = 0x178u; + const uint section_header_size = 0x28u; + const uint file_alignment = 0x200; + const uint section_alignment = 0x2000; + const ulong image_base = 0x00400000; + + internal const RVA text_rva = 0x2000; + + readonly bool pe64; + readonly uint time_stamp; + + internal Section text; + internal Section rsrc; + internal Section reloc; + + ushort sections; + + ImageWriter (ModuleDefinition module, MetadataBuilder metadata, Stream stream) + : base (stream) + { + this.module = module; + this.metadata = metadata; + this.GetDebugHeader (); + this.GetWin32Resources (); + this.text_map = BuildTextMap (); + this.sections = 2; // text + reloc + this.pe64 = module.Architecture != TargetArchitecture.I386; + this.time_stamp = (uint) DateTime.UtcNow.Subtract (new DateTime (1970, 1, 1)).TotalSeconds; + } + + void GetDebugHeader () + { + var symbol_writer = metadata.symbol_writer; + if (symbol_writer == null) + return; + + if (!symbol_writer.GetDebugHeader (out debug_directory, out debug_data)) + debug_data = Empty.Array; + } + + void GetWin32Resources () + { + var rsrc = GetImageResourceSection (); + if (rsrc == null) + return; + + var raw_resources = new byte [rsrc.Data.Length]; + Buffer.BlockCopy (rsrc.Data, 0, raw_resources, 0, rsrc.Data.Length); + win32_resources = new ByteBuffer (raw_resources); + } + + Section GetImageResourceSection () + { + if (!module.HasImage) + return null; + + const string rsrc_section = ".rsrc"; + + return module.Image.GetSection (rsrc_section); + } + + public static ImageWriter CreateWriter (ModuleDefinition module, MetadataBuilder metadata, Stream stream) + { + var writer = new ImageWriter (module, metadata, stream); + writer.BuildSections (); + return writer; + } + + void BuildSections () + { + var has_win32_resources = win32_resources != null; + if (has_win32_resources) + sections++; + + text = CreateSection (".text", text_map.GetLength (), null); + var previous = text; + + if (has_win32_resources) { + rsrc = CreateSection (".rsrc", (uint) win32_resources.length, previous); + + PatchWin32Resources (win32_resources); + previous = rsrc; + } + + reloc = CreateSection (".reloc", 12u, previous); + } + + Section CreateSection (string name, uint size, Section previous) + { + return new Section { + Name = name, + VirtualAddress = previous != null + ? previous.VirtualAddress + Align (previous.VirtualSize, section_alignment) + : text_rva, + VirtualSize = size, + PointerToRawData = previous != null + ? previous.PointerToRawData + previous.SizeOfRawData + : Align (GetHeaderSize (), file_alignment), + SizeOfRawData = Align (size, file_alignment) + }; + } + + static uint Align (uint value, uint align) + { + align--; + return (value + align) & ~align; + } + + void WriteDOSHeader () + { + Write (new byte [] { + // dos header start + 0x4d, 0x5a, 0x90, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x00, 0x00, 0xb8, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + // lfanew + 0x80, 0x00, 0x00, 0x00, + // dos header end + 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, + 0xcd, 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, + 0x54, 0x68, 0x69, 0x73, 0x20, 0x70, 0x72, + 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x20, 0x63, + 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x20, 0x62, + 0x65, 0x20, 0x72, 0x75, 0x6e, 0x20, 0x69, + 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, 0x6d, + 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, + 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00 + }); + } + + void WritePEFileHeader () + { + WriteUInt32 (0x00004550); // Magic + WriteUInt16 (GetMachine ()); // Machine + WriteUInt16 (sections); // NumberOfSections + WriteUInt32 (time_stamp); + WriteUInt32 (0); // PointerToSymbolTable + WriteUInt32 (0); // NumberOfSymbols + WriteUInt16 ((ushort) (!pe64 ? 0xe0 : 0xf0)); // SizeOfOptionalHeader + + // ExecutableImage | (pe64 ? 32BitsMachine : LargeAddressAware) + var characteristics = (ushort) (0x0002 | (!pe64 ? 0x0100 : 0x0020)); + if (module.Kind == ModuleKind.Dll || module.Kind == ModuleKind.NetModule) + characteristics |= 0x2000; + WriteUInt16 (characteristics); // Characteristics + } + + ushort GetMachine () + { + switch (module.Architecture) { + case TargetArchitecture.I386: + return 0x014c; + case TargetArchitecture.AMD64: + return 0x8664; + case TargetArchitecture.IA64: + return 0x0200; + } + + throw new NotSupportedException (); + } + + void WriteOptionalHeaders () + { + WriteUInt16 ((ushort) (!pe64 ? 0x10b : 0x20b)); // Magic + WriteByte (8); // LMajor + WriteByte (0); // LMinor + WriteUInt32 (text.SizeOfRawData); // CodeSize + WriteUInt32 (reloc.SizeOfRawData + + (rsrc != null ? rsrc.SizeOfRawData : 0)); // InitializedDataSize + WriteUInt32 (0); // UninitializedDataSize + + var entry_point_rva = text_map.GetRVA (TextSegment.StartupStub); + if (module.Architecture == TargetArchitecture.IA64) + entry_point_rva += 0x20; + WriteUInt32 (entry_point_rva); // EntryPointRVA + WriteUInt32 (text_rva); // BaseOfCode + + if (!pe64) { + WriteUInt32 (0); // BaseOfData + WriteUInt32 ((uint) image_base); // ImageBase + } else { + WriteUInt64 (image_base); // ImageBase + } + + WriteUInt32 (section_alignment); // SectionAlignment + WriteUInt32 (file_alignment); // FileAlignment + + WriteUInt16 (4); // OSMajor + WriteUInt16 (0); // OSMinor + WriteUInt16 (0); // UserMajor + WriteUInt16 (0); // UserMinor + WriteUInt16 (4); // SubSysMajor + WriteUInt16 (0); // SubSysMinor + WriteUInt32 (0); // Reserved + + WriteUInt32 (reloc.VirtualAddress + Align (reloc.VirtualSize, section_alignment)); // ImageSize + WriteUInt32 (text.PointerToRawData); // HeaderSize + + WriteUInt32 (0); // Checksum + WriteUInt16 (GetSubSystem ()); // SubSystem + WriteUInt16 (0x8540); // DLLFlags + + const ulong stack_reserve = 0x100000; + const ulong stack_commit = 0x1000; + const ulong heap_reserve = 0x100000; + const ulong heap_commit = 0x1000; + + if (!pe64) { + WriteUInt32 ((uint) stack_reserve); + WriteUInt32 ((uint) stack_commit); + WriteUInt32 ((uint) heap_reserve); + WriteUInt32 ((uint) heap_commit); + } else { + WriteUInt64 (stack_reserve); + WriteUInt64 (stack_commit); + WriteUInt64 (heap_reserve); + WriteUInt64 (heap_commit); + } + + WriteUInt32 (0); // LoaderFlags + WriteUInt32 (16); // NumberOfDataDir + + WriteZeroDataDirectory (); // ExportTable + WriteDataDirectory (text_map.GetDataDirectory (TextSegment.ImportDirectory)); // ImportTable + if (rsrc != null) { // ResourceTable + WriteUInt32 (rsrc.VirtualAddress); + WriteUInt32 (rsrc.VirtualSize); + } else + WriteZeroDataDirectory (); + + WriteZeroDataDirectory (); // ExceptionTable + WriteZeroDataDirectory (); // CertificateTable + WriteUInt32 (reloc.VirtualAddress); // BaseRelocationTable + WriteUInt32 (reloc.VirtualSize); + + if (text_map.GetLength (TextSegment.DebugDirectory) > 0) { + WriteUInt32 (text_map.GetRVA (TextSegment.DebugDirectory)); + WriteUInt32 (28u); + } else + WriteZeroDataDirectory (); + + WriteZeroDataDirectory (); // Copyright + WriteZeroDataDirectory (); // GlobalPtr + WriteZeroDataDirectory (); // TLSTable + WriteZeroDataDirectory (); // LoadConfigTable + WriteZeroDataDirectory (); // BoundImport + WriteDataDirectory (text_map.GetDataDirectory (TextSegment.ImportAddressTable)); // IAT + WriteZeroDataDirectory (); // DelayImportDesc + WriteDataDirectory (text_map.GetDataDirectory (TextSegment.CLIHeader)); // CLIHeader + WriteZeroDataDirectory (); // Reserved + } + + void WriteZeroDataDirectory () + { + WriteUInt32 (0); + WriteUInt32 (0); + } + + ushort GetSubSystem () + { + switch (module.Kind) { + case ModuleKind.Console: + case ModuleKind.Dll: + case ModuleKind.NetModule: + return 0x3; + case ModuleKind.Windows: + return 0x2; + default: + throw new ArgumentOutOfRangeException (); + } + } + + void WriteSectionHeaders () + { + WriteSection (text, 0x60000020); + + if (rsrc != null) + WriteSection (rsrc, 0x40000040); + + WriteSection (reloc, 0x42000040); + } + + void WriteSection (Section section, uint characteristics) + { + var name = new byte [8]; + var sect_name = section.Name; + for (int i = 0; i < sect_name.Length; i++) + name [i] = (byte) sect_name [i]; + + WriteBytes (name); + WriteUInt32 (section.VirtualSize); + WriteUInt32 (section.VirtualAddress); + WriteUInt32 (section.SizeOfRawData); + WriteUInt32 (section.PointerToRawData); + WriteUInt32 (0); // PointerToRelocations + WriteUInt32 (0); // PointerToLineNumbers + WriteUInt16 (0); // NumberOfRelocations + WriteUInt16 (0); // NumberOfLineNumbers + WriteUInt32 (characteristics); + } + + void MoveTo (uint pointer) + { + BaseStream.Seek (pointer, SeekOrigin.Begin); + } + + void MoveToRVA (Section section, RVA rva) + { + BaseStream.Seek (section.PointerToRawData + rva - section.VirtualAddress, SeekOrigin.Begin); + } + + void MoveToRVA (TextSegment segment) + { + MoveToRVA (text, text_map.GetRVA (segment)); + } + + void WriteRVA (RVA rva) + { + if (!pe64) + WriteUInt32 (rva); + else + WriteUInt64 (rva); + } + + void WriteText () + { + MoveTo (text.PointerToRawData); + + // ImportAddressTable + + WriteRVA (text_map.GetRVA (TextSegment.ImportHintNameTable)); + WriteRVA (0); + + // CLIHeader + + WriteUInt32 (0x48); + WriteUInt16 (2); + WriteUInt16 ((ushort) ((module.Runtime <= TargetRuntime.Net_1_1) ? 0 : 5)); + + WriteUInt32 (text_map.GetRVA (TextSegment.MetadataHeader)); + WriteUInt32 (GetMetadataLength ()); + WriteUInt32 ((uint) module.Attributes); + WriteUInt32 (metadata.entry_point.ToUInt32 ()); + WriteDataDirectory (text_map.GetDataDirectory (TextSegment.Resources)); + WriteDataDirectory (text_map.GetDataDirectory (TextSegment.StrongNameSignature)); + WriteZeroDataDirectory (); // CodeManagerTable + WriteZeroDataDirectory (); // VTableFixups + WriteZeroDataDirectory (); // ExportAddressTableJumps + WriteZeroDataDirectory (); // ManagedNativeHeader + + // Code + + MoveToRVA (TextSegment.Code); + WriteBuffer (metadata.code); + + // Resources + + MoveToRVA (TextSegment.Resources); + WriteBuffer (metadata.resources); + + // Data + + if (metadata.data.length > 0) { + MoveToRVA (TextSegment.Data); + WriteBuffer (metadata.data); + } + + // StrongNameSignature + // stays blank + + // MetadataHeader + + MoveToRVA (TextSegment.MetadataHeader); + WriteMetadataHeader (); + + WriteMetadata (); + + // DebugDirectory + if (text_map.GetLength (TextSegment.DebugDirectory) > 0) { + MoveToRVA (TextSegment.DebugDirectory); + WriteDebugDirectory (); + } + + // ImportDirectory + MoveToRVA (TextSegment.ImportDirectory); + WriteImportDirectory (); + + // StartupStub + MoveToRVA (TextSegment.StartupStub); + WriteStartupStub (); + } + + uint GetMetadataLength () + { + return text_map.GetRVA (TextSegment.DebugDirectory) - text_map.GetRVA (TextSegment.MetadataHeader); + } + + void WriteMetadataHeader () + { + WriteUInt32 (0x424a5342); // Signature + WriteUInt16 (1); // MajorVersion + WriteUInt16 (1); // MinorVersion + WriteUInt32 (0); // Reserved + + var version = GetZeroTerminatedString (GetVersion ()); + WriteUInt32 ((uint) version.Length); + WriteBytes (version); + WriteUInt16 (0); // Flags + WriteUInt16 (GetStreamCount ()); + + uint offset = text_map.GetRVA (TextSegment.TableHeap) - text_map.GetRVA (TextSegment.MetadataHeader); + + WriteStreamHeader (ref offset, TextSegment.TableHeap, "#~"); + WriteStreamHeader (ref offset, TextSegment.StringHeap, "#Strings"); + WriteStreamHeader (ref offset, TextSegment.UserStringHeap, "#US"); + WriteStreamHeader (ref offset, TextSegment.GuidHeap, "#GUID"); + WriteStreamHeader (ref offset, TextSegment.BlobHeap, "#Blob"); + } + + string GetVersion () + { + switch (module.Runtime) { + case TargetRuntime.Net_1_0: + return "v1.0.3705"; + case TargetRuntime.Net_1_1: + return "v1.1.4322"; + case TargetRuntime.Net_2_0: + return "v2.0.50727"; + case TargetRuntime.Net_4_0: + default: + return "v4.0.30319"; + } + } + + ushort GetStreamCount () + { + return (ushort) ( + 1 // #~ + + 1 // #Strings + + (metadata.user_string_heap.IsEmpty ? 0 : 1) // #US + + 1 // GUID + + (metadata.blob_heap.IsEmpty ? 0 : 1)); // #Blob + } + + void WriteStreamHeader (ref uint offset, TextSegment heap, string name) + { + var length = (uint) text_map.GetLength (heap); + if (length == 0) + return; + + WriteUInt32 (offset); + WriteUInt32 (length); + WriteBytes (GetZeroTerminatedString (name)); + offset += length; + } + + static byte [] GetZeroTerminatedString (string @string) + { + return GetString (@string, (@string.Length + 1 + 3) & ~3); + } + + static byte [] GetSimpleString (string @string) + { + return GetString (@string, @string.Length); + } + + static byte [] GetString (string @string, int length) + { + var bytes = new byte [length]; + for (int i = 0; i < @string.Length; i++) + bytes [i] = (byte) @string [i]; + + return bytes; + } + + void WriteMetadata () + { + WriteHeap (TextSegment.TableHeap, metadata.table_heap); + WriteHeap (TextSegment.StringHeap, metadata.string_heap); + WriteHeap (TextSegment.UserStringHeap, metadata.user_string_heap); + WriteGuidHeap (); + WriteHeap (TextSegment.BlobHeap, metadata.blob_heap); + } + + void WriteHeap (TextSegment heap, HeapBuffer buffer) + { + if (buffer.IsEmpty) + return; + + MoveToRVA (heap); + WriteBuffer (buffer); + } + + void WriteGuidHeap () + { + MoveToRVA (TextSegment.GuidHeap); + WriteBytes (module.Mvid.ToByteArray ()); + } + + void WriteDebugDirectory () + { + WriteInt32 (debug_directory.Characteristics); + WriteUInt32 (time_stamp); + WriteInt16 (debug_directory.MajorVersion); + WriteInt16 (debug_directory.MinorVersion); + WriteInt32 (debug_directory.Type); + WriteInt32 (debug_directory.SizeOfData); + WriteInt32 (debug_directory.AddressOfRawData); + WriteInt32 ((int) BaseStream.Position + 4); + + WriteBytes (debug_data); + } + + void WriteImportDirectory () + { + WriteUInt32 (text_map.GetRVA (TextSegment.ImportDirectory) + 40); // ImportLookupTable + WriteUInt32 (0); // DateTimeStamp + WriteUInt32 (0); // ForwarderChain + WriteUInt32 (text_map.GetRVA (TextSegment.ImportHintNameTable) + 14); + WriteUInt32 (text_map.GetRVA (TextSegment.ImportAddressTable)); + Advance (20); + + // ImportLookupTable + WriteUInt32 (text_map.GetRVA (TextSegment.ImportHintNameTable)); + + // ImportHintNameTable + MoveToRVA (TextSegment.ImportHintNameTable); + + WriteUInt16 (0); // Hint + WriteBytes (GetRuntimeMain ()); + WriteByte (0); + WriteBytes (GetSimpleString ("mscoree.dll")); + WriteUInt16 (0); + } + + byte [] GetRuntimeMain () + { + return module.Kind == ModuleKind.Dll || module.Kind == ModuleKind.NetModule + ? GetSimpleString ("_CorDllMain") + : GetSimpleString ("_CorExeMain"); + } + + void WriteStartupStub () + { + switch (module.Architecture) { + case TargetArchitecture.I386: + WriteUInt16 (0x25ff); + WriteUInt32 ((uint) image_base + text_map.GetRVA (TextSegment.ImportAddressTable)); + return; + case TargetArchitecture.AMD64: + WriteUInt16 (0xa148); + WriteUInt32 ((uint) image_base + text_map.GetRVA (TextSegment.ImportAddressTable)); + WriteUInt16 (0xe0ff); + return; + case TargetArchitecture.IA64: + WriteBytes (new byte [] { + 0x0b, 0x48, 0x00, 0x02, 0x18, 0x10, 0xa0, 0x40, 0x24, 0x30, 0x28, 0x00, 0x00, 0x00, 0x04, 0x00, + 0x10, 0x08, 0x00, 0x12, 0x18, 0x10, 0x60, 0x50, 0x04, 0x80, 0x03, 0x00, 0x60, 0x00, 0x80, 0x00 + }); + WriteUInt32 ((uint) image_base + text_map.GetRVA (TextSegment.StartupStub)); + WriteUInt32 ((uint) image_base + text_rva); + return; + } + } + + void WriteRsrc () + { + MoveTo (rsrc.PointerToRawData); + WriteBuffer (win32_resources); + } + + void WriteReloc () + { + MoveTo (reloc.PointerToRawData); + + var reloc_rva = text_map.GetRVA (TextSegment.StartupStub); + reloc_rva += module.Architecture == TargetArchitecture.IA64 ? 0x20u : 2; + var page_rva = reloc_rva & ~0xfffu; + + WriteUInt32 (page_rva); // PageRVA + WriteUInt32 (0x000c); // Block Size + + switch (module.Architecture) { + case TargetArchitecture.I386: + WriteUInt32 (0x3000 + reloc_rva - page_rva); + break; + case TargetArchitecture.AMD64: + WriteUInt32 (0xa000 + reloc_rva - page_rva); + break; + case TargetArchitecture.IA64: + WriteUInt16 ((ushort) (0xa000 + reloc_rva - page_rva)); + WriteUInt16 ((ushort) (0xa000 + reloc_rva - page_rva + 8)); + break; + } + + WriteBytes (new byte [file_alignment - reloc.VirtualSize]); + } + + public void WriteImage () + { + WriteDOSHeader (); + WritePEFileHeader (); + WriteOptionalHeaders (); + WriteSectionHeaders (); + WriteText (); + if (rsrc != null) + WriteRsrc (); + WriteReloc (); + } + + TextMap BuildTextMap () + { + var map = metadata.text_map; + + map.AddMap (TextSegment.Code, metadata.code.length, !pe64 ? 4 : 16); + map.AddMap (TextSegment.Resources, metadata.resources.length, 8); + map.AddMap (TextSegment.Data, metadata.data.length, 4); + if (metadata.data.length > 0) + metadata.table_heap.FixupData (map.GetRVA (TextSegment.Data)); + map.AddMap (TextSegment.StrongNameSignature, GetStrongNameLength (), 4); + + map.AddMap (TextSegment.MetadataHeader, GetMetadataHeaderLength ()); + map.AddMap (TextSegment.TableHeap, metadata.table_heap.length, 4); + map.AddMap (TextSegment.StringHeap, metadata.string_heap.length, 4); + map.AddMap (TextSegment.UserStringHeap, metadata.user_string_heap.IsEmpty ? 0 : metadata.user_string_heap.length, 4); + map.AddMap (TextSegment.GuidHeap, 16); + map.AddMap (TextSegment.BlobHeap, metadata.blob_heap.IsEmpty ? 0 : metadata.blob_heap.length, 4); + + int debug_dir_len = 0; + if (!debug_data.IsNullOrEmpty ()) { + const int debug_dir_header_len = 28; + + debug_directory.AddressOfRawData = (int) map.GetNextRVA (TextSegment.BlobHeap) + debug_dir_header_len; + debug_dir_len = debug_data.Length + debug_dir_header_len; + } + + map.AddMap (TextSegment.DebugDirectory, debug_dir_len, 4); + + RVA import_dir_rva = map.GetNextRVA (TextSegment.DebugDirectory); + RVA import_hnt_rva = import_dir_rva + (!pe64 ? 48u : 52u); + import_hnt_rva = (import_hnt_rva + 15u) & ~15u; + uint import_dir_len = (import_hnt_rva - import_dir_rva) + 27u; + + RVA startup_stub_rva = import_dir_rva + import_dir_len; + startup_stub_rva = module.Architecture == TargetArchitecture.IA64 + ? (startup_stub_rva + 15u) & ~15u + : 2 + ((startup_stub_rva + 3u) & ~3u); + + map.AddMap (TextSegment.ImportDirectory, new Range (import_dir_rva, import_dir_len)); + map.AddMap (TextSegment.ImportHintNameTable, new Range (import_hnt_rva, 0)); + map.AddMap (TextSegment.StartupStub, new Range (startup_stub_rva, GetStartupStubLength ())); + + return map; + } + + uint GetStartupStubLength () + { + switch (module.Architecture) { + case TargetArchitecture.I386: + return 6; + case TargetArchitecture.AMD64: + return 12; + case TargetArchitecture.IA64: + return 48; + default: + throw new InvalidOperationException (); + } + } + + int GetMetadataHeaderLength () + { + return + // MetadataHeader + 40 + // #~ header + + 12 + // #Strings header + + 20 + // #US header + + (metadata.user_string_heap.IsEmpty ? 0 : 12) + // #GUID header + + 16 + // #Blob header + + (metadata.blob_heap.IsEmpty ? 0 : 16); + } + + int GetStrongNameLength () + { + if ((module.Attributes & ModuleAttributes.StrongNameSigned) == 0) + return 0; + + if (module.Assembly == null) + throw new InvalidOperationException (); + + var public_key = module.Assembly.Name.PublicKey; + + if (public_key != null) { + // in fx 2.0 the key may be from 384 to 16384 bits + // so we must calculate the signature size based on + // the size of the public key (minus the 32 byte header) + int size = public_key.Length; + if (size > 32) + return size - 32; + // note: size == 16 for the ECMA "key" which is replaced + // by the runtime with a 1024 bits key (128 bytes) + } + + return 128; // default strongname signature size + } + + public DataDirectory GetStrongNameSignatureDirectory () + { + return text_map.GetDataDirectory (TextSegment.StrongNameSignature); + } + + public uint GetHeaderSize () + { + return pe_header_size + (sections * section_header_size); + } + + void PatchWin32Resources (ByteBuffer resources) + { + PatchResourceDirectoryTable (resources); + } + + void PatchResourceDirectoryTable (ByteBuffer resources) + { + resources.Advance (12); + + var entries = resources.ReadUInt16 () + resources.ReadUInt16 (); + + for (int i = 0; i < entries; i++) + PatchResourceDirectoryEntry (resources); + } + + void PatchResourceDirectoryEntry (ByteBuffer resources) + { + resources.Advance (4); + var child = resources.ReadUInt32 (); + + var position = resources.position; + resources.position = (int) child & 0x7fffffff; + + if ((child & 0x80000000) != 0) + PatchResourceDirectoryTable (resources); + else + PatchResourceDataEntry (resources); + + resources.position = position; + } + + void PatchResourceDataEntry (ByteBuffer resources) + { + var old_rsrc = GetImageResourceSection (); + var rva = resources.ReadUInt32 (); + resources.position -= 4; + resources.WriteUInt32 (rva - old_rsrc.VirtualAddress + rsrc.VirtualAddress); + } + } +} + +#endif diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/Section.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/Section.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/Section.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/Section.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,43 @@ +// +// Section.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; + +using RVA = System.UInt32; + +namespace Mono.Cecil.PE { + + sealed class Section { + public string Name; + public RVA VirtualAddress; + public uint VirtualSize; + public uint SizeOfRawData; + public uint PointerToRawData; + public byte [] Data; + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/TextMap.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/TextMap.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/TextMap.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/TextMap.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,129 @@ +// +// TextMap.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; + +#if !READ_ONLY + +using RVA = System.UInt32; + +namespace Mono.Cecil.PE { + + enum TextSegment { + ImportAddressTable, + CLIHeader, + Code, + Resources, + Data, + StrongNameSignature, + + // Metadata + MetadataHeader, + TableHeap, + StringHeap, + UserStringHeap, + GuidHeap, + BlobHeap, + // End Metadata + + DebugDirectory, + ImportDirectory, + ImportHintNameTable, + StartupStub, + } + + sealed class TextMap { + + readonly Range [] map = new Range [16 /*Enum.GetValues (typeof (TextSegment)).Length*/]; + + public void AddMap (TextSegment segment, int length) + { + map [(int) segment] = new Range (GetStart (segment), (uint) length); + } + + public void AddMap (TextSegment segment, int length, int align) + { + align--; + + AddMap (segment, (length + align) & ~align); + } + + public void AddMap (TextSegment segment, Range range) + { + map [(int) segment] = range; + } + + public Range GetRange (TextSegment segment) + { + return map [(int) segment]; + } + + public DataDirectory GetDataDirectory (TextSegment segment) + { + var range = map [(int) segment]; + + return new DataDirectory (range.Length == 0 ? 0 : range.Start, range.Length); + } + + public RVA GetRVA (TextSegment segment) + { + return map [(int) segment].Start; + } + + public RVA GetNextRVA (TextSegment segment) + { + var i = (int) segment; + return map [i].Start + map [i].Length; + } + + public int GetLength (TextSegment segment) + { + return (int) map [(int) segment].Length; + } + + RVA GetStart (TextSegment segment) + { + var index = (int) segment; + return index == 0 ? ImageWriter.text_rva : ComputeStart (index); + } + + RVA ComputeStart (int index) + { + index--; + return map [index].Start + map [index].Length; + } + + public uint GetLength () + { + var range = map [(int) TextSegment.StartupStub]; + return range.Start - ImageWriter.text_rva + range.Length; + } + } +} + +#endif diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Array.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Array.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Array.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Array.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// -// Array.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 - 2007 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - using Mono.Cecil.Metadata; - - internal sealed class ARRAY : SigType { - - public CustomMod [] CustomMods; - public SigType Type; - public ArrayShape Shape; - - public ARRAY () : base (ElementType.Array) - { - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ArrayShape.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ArrayShape.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ArrayShape.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ArrayShape.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// -// ArrayShape.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - internal sealed class ArrayShape { - - public int Rank; - public int NumSizes; - public int [] Sizes; - public int NumLoBounds; - public int [] LoBounds; - - public ArrayShape () - { - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/BaseSignatureVisitor.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/BaseSignatureVisitor.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/BaseSignatureVisitor.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/BaseSignatureVisitor.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -// -// BaseSignatureVisitor.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - internal abstract class BaseSignatureVisitor : ISignatureVisitor { - - public virtual void VisitMethodDefSig (MethodDefSig methodDef) - { - } - - public virtual void VisitMethodRefSig (MethodRefSig methodRef) - { - } - - public virtual void VisitFieldSig (FieldSig field) - { - } - - public virtual void VisitPropertySig (PropertySig property) - { - } - - public virtual void VisitLocalVarSig (LocalVarSig localvar) - { - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Class.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Class.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Class.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Class.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// -// Class.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - using Mono.Cecil.Metadata; - - internal sealed class CLASS : SigType { - - public MetadataToken Type; - - public CLASS () : base (ElementType.Class) - { - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Constraint.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Constraint.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Constraint.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Constraint.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// -// Constraints.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - using Mono.Cecil.Metadata; - - internal enum Constraint : byte { - None = 0x0, - Pinned = (byte) ElementType.Pinned - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/CustomAttrib.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/CustomAttrib.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/CustomAttrib.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/CustomAttrib.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -// -// CustomAttrib.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - using Mono.Cecil.Metadata; - - internal sealed class CustomAttrib { - - public const ushort StdProlog = 0x0001; - - public MethodReference Constructor; - - public ushort Prolog; - public FixedArg [] FixedArgs; - public ushort NumNamed; - public NamedArg [] NamedArgs; - public bool Read; - - public CustomAttrib (MethodReference ctor) - { - Constructor = ctor; - } - - public struct FixedArg { - - public bool SzArray; - public uint NumElem; - public Elem [] Elems; - } - - public struct Elem { - - public bool Simple; - public bool String; - public bool Type; - public bool BoxedValueType; - - public ElementType FieldOrPropType; - public object Value; - - public TypeReference ElemType; - } - - public struct NamedArg { - - public bool Field; - public bool Property; - - public ElementType FieldOrPropType; - public string FieldOrPropName; - public FixedArg FixedArg; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/CustomMod.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/CustomMod.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/CustomMod.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/CustomMod.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// -// CustomMod.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - using Mono.Cecil.Metadata; - - internal sealed class CustomMod { - - public enum CMODType : byte { - None = 0x0, - OPT = (byte) ElementType.CModOpt, - REQD = (byte) ElementType.CModReqD - } - - public CMODType CMOD; - public MetadataToken TypeDefOrRef; - - public CustomMod () - { - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/FieldSig.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/FieldSig.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/FieldSig.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/FieldSig.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -// -// FieldSig.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - internal sealed class FieldSig : Signature { - - public bool Field; - public CustomMod [] CustomMods; - public SigType Type; - - public FieldSig () : base () - { - } - - public FieldSig (uint blobIndex) : base (blobIndex) - { - } - - public override void Accept (ISignatureVisitor visitor) - { - visitor.VisitFieldSig (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/FnPtr.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/FnPtr.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/FnPtr.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/FnPtr.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// -// FnPtr.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - using Mono.Cecil.Metadata; - - internal sealed class FNPTR : SigType { - - public MethodSig Method; - - public FNPTR () : base (ElementType.FnPtr) - { - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/GenericArg.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/GenericArg.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/GenericArg.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/GenericArg.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// -// GenericArg.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2006 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - class GenericArg { - - public CustomMod [] CustomMods; - public SigType Type; - - public GenericArg (SigType type) - { - Type = type; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/GenericInst.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/GenericInst.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/GenericInst.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/GenericInst.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -// -// GenericInst.cs -// -// Author: -// Martin Baulig -// Jb Evain -// -// Copyright (C) 2005 Novell, Inc (http://www.novell.com) -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -namespace Mono.Cecil.Signatures { - - using Mono.Cecil; - using Mono.Cecil.Metadata; - - internal sealed class GENERICINST : SigType { - - public bool ValueType; - public MetadataToken Type; - - public GenericInstSignature Signature; - - public GENERICINST () : base (ElementType.GenericInst) - { - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/GenericInstSignature.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/GenericInstSignature.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/GenericInstSignature.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/GenericInstSignature.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// -// GenericInstSignature.cs -// -// Author: -// Martin Baulig -// -// Copyright (C) 2005 Novell, Inc (http://www.novell.com) -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -namespace Mono.Cecil.Signatures { - - internal sealed class GenericInstSignature { - - public int Arity; - public GenericArg [] Types; - - public GenericInstSignature () - { - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/InputOutputItem.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/InputOutputItem.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/InputOutputItem.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/InputOutputItem.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// -// InputOutputItem.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - internal abstract class InputOutputItem { - - public CustomMod [] CustomMods; - public bool ByRef; - public SigType Type; - public bool TypedByRef; - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ISignatureVisitable.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ISignatureVisitable.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ISignatureVisitable.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ISignatureVisitable.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// -// ISignatureVisitable.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - internal interface ISignatureVisitable { - - void Accept (ISignatureVisitor visitor); - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ISignatureVisitor.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ISignatureVisitor.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ISignatureVisitor.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ISignatureVisitor.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// -// ISignatureVisitor.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - internal interface ISignatureVisitor { - - void VisitMethodDefSig (MethodDefSig methodDef); - void VisitMethodRefSig (MethodRefSig methodRef); - void VisitFieldSig (FieldSig field); - void VisitPropertySig (PropertySig property); - void VisitLocalVarSig (LocalVarSig localvar); - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/LocalVarSig.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/LocalVarSig.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/LocalVarSig.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/LocalVarSig.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -// -// LocalVarSig.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - internal sealed class LocalVarSig : Signature { - - public bool Local; - public int Count; - public LocalVariable [] LocalVariables; - - public LocalVarSig () : base () - { - } - - public LocalVarSig (uint blobIndex) : base (blobIndex) - { - } - - public override void Accept (ISignatureVisitor visitor) - { - visitor.VisitLocalVarSig (this); - } - - public struct LocalVariable { - - public CustomMod [] CustomMods; - public Constraint Constraint; - public bool ByRef; - public SigType Type; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MarshalSig.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MarshalSig.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MarshalSig.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MarshalSig.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ -// -// MarshalSig.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - using System; - - using Mono.Cecil; - - internal sealed class MarshalSig { - - public NativeType NativeInstrinsic; - public IMarshalSigSpec Spec; - - public MarshalSig (NativeType nt) - { - this.NativeInstrinsic = nt; - } - - public interface IMarshalSigSpec { - } - - public sealed class Array : IMarshalSigSpec { - - public NativeType ArrayElemType; - public int ParamNum; - public int ElemMult; - public int NumElem; - - public Array () - { - this.ParamNum = 0; - this.ElemMult = 0; - this.NumElem = 0; - } - } - - public sealed class CustomMarshaler : IMarshalSigSpec { - - public string Guid; - public string UnmanagedType; - public string ManagedType; - public string Cookie; - } - - public sealed class FixedArray : IMarshalSigSpec { - - public int NumElem; - public NativeType ArrayElemType; - - public FixedArray () - { - this.NumElem = 0; - this.ArrayElemType = NativeType.NONE; - } - } - - public sealed class SafeArray : IMarshalSigSpec { - - public VariantType ArrayElemType; - } - - public sealed class FixedSysString : IMarshalSigSpec { - - public int Size; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodDefSig.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodDefSig.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodDefSig.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodDefSig.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// -// MethodDefSig.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - internal sealed class MethodDefSig : MethodRefSig { - - public int GenericParameterCount; - - public MethodDefSig () : this (0) - { - } - - public MethodDefSig (uint blobIndex) : base (blobIndex) - { - } - - public override void Accept (ISignatureVisitor visitor) - { - visitor.VisitMethodDefSig (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodRefSig.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodRefSig.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodRefSig.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodRefSig.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -// -// MethodRefSig.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - internal class MethodRefSig : MethodSig { - - public int Sentinel; - - public MethodRefSig () : this (0) - { - } - - public MethodRefSig (uint blobIndex) : base (blobIndex) - { - Sentinel = -1; - } - - public override void Accept (ISignatureVisitor visitor) - { - visitor.VisitMethodRefSig (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodSig.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodSig.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodSig.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodSig.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -// -// MethodSig.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using Mono.Cecil; - -namespace Mono.Cecil.Signatures { - - internal abstract class MethodSig : Signature { - - public bool HasThis; - public bool ExplicitThis; - public MethodCallingConvention MethCallConv; - public int ParamCount; - public RetType RetType; - public Param [] Parameters; - - public MethodSig () : base () - { - } - - public MethodSig (uint blobIndex) : base (blobIndex) - { - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodSpec.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodSpec.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodSpec.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodSpec.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// -// TypeSpec.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - internal sealed class MethodSpec { - - public GenericInstSignature Signature; - - public MethodSpec (GenericInstSignature sig) - { - this.Signature = sig; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MVar.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MVar.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MVar.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MVar.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// -// MVar.cs -// -// Author: -// Martin Baulig -// -// Copyright (C) 2005 Novell, Inc (http://www.novell.com) -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -namespace Mono.Cecil.Signatures { - - using Mono.Cecil.Metadata; - - internal sealed class MVAR : SigType { - - public int Index; - - public MVAR (int index) : base (ElementType.MVar) - { - this.Index = index; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Param.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Param.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Param.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Param.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// -// Param.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - internal sealed class Param : InputOutputItem { - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/PropertySig.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/PropertySig.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/PropertySig.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/PropertySig.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -// -// PropertySig.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - internal sealed class PropertySig : Signature { - - public bool Property; - public int ParamCount; - public CustomMod [] CustomMods; - public SigType Type; - public Param [] Parameters; - - public PropertySig () : base () - { - } - - public PropertySig (uint blobIndex) : base (blobIndex) - { - } - - public override void Accept (ISignatureVisitor visitor) - { - visitor.VisitPropertySig (this); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Ptr.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Ptr.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Ptr.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Ptr.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// -// Ptr.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - using Mono.Cecil.Metadata; - - internal sealed class PTR : SigType { - - public CustomMod [] CustomMods; - public SigType PtrType; - public bool Void; - - public PTR () : base (ElementType.Ptr) - { - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/RetType.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/RetType.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/RetType.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/RetType.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// -// RetType.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - internal sealed class RetType : InputOutputItem { - - public bool Void; - - public RetType () - { - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Signature.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Signature.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Signature.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Signature.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -// -// Signature.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - using System; - - internal abstract class Signature : ISignatureVisitable { - - public byte CallingConvention; - public uint BlobIndex; - - public Signature (uint blobIndex) - { - BlobIndex = blobIndex; - } - - public Signature () - { - BlobIndex = 0; - } - - public abstract void Accept (ISignatureVisitor visitor); - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SignatureReader.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SignatureReader.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SignatureReader.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SignatureReader.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,961 +0,0 @@ -// -// SignatureReader.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 - 2007 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - using System; - using System.Collections; - using System.IO; - using System.Text; - - using Mono.Cecil; - using Mono.Cecil.Metadata; - - internal sealed class SignatureReader : BaseSignatureVisitor { - - MetadataRoot m_root; - ReflectionReader m_reflectReader; - byte [] m_blobData; - - IDictionary m_signatures; - - IAssemblyResolver AssemblyResolver { - get { return m_reflectReader.Module.Assembly.Resolver; } - } - - public SignatureReader (MetadataRoot root, ReflectionReader reflectReader) - { - m_root = root; - m_reflectReader = reflectReader; - - m_blobData = m_root.Streams.BlobHeap != null ? m_root.Streams.BlobHeap.Data : new byte [0]; - - m_signatures = new Hashtable (); - } - - public FieldSig GetFieldSig (uint index) - { - FieldSig f = m_signatures [index] as FieldSig; - if (f == null) { - f = new FieldSig (index); - f.Accept (this); - m_signatures [index] = f; - } - return f; - } - - public PropertySig GetPropSig (uint index) - { - PropertySig p = m_signatures [index] as PropertySig; - if (p == null) { - p = new PropertySig (index); - p.Accept (this); - m_signatures [index] = p; - } - return p; - } - - public MethodDefSig GetMethodDefSig (uint index) - { - MethodDefSig m = m_signatures [index] as MethodDefSig; - if (m == null) { - m = new MethodDefSig (index); - m.Accept (this); - m_signatures [index] = m; - } - return m; - } - - public MethodRefSig GetMethodRefSig (uint index) - { - MethodRefSig m = m_signatures [index] as MethodRefSig; - if (m == null) { - m = new MethodRefSig (index); - m.Accept (this); - m_signatures [index] = m; - } - return m; - } - - public TypeSpec GetTypeSpec (uint index) - { - TypeSpec ts = m_signatures [index] as TypeSpec; - - if (ts == null) { - ts = ReadTypeSpec (m_blobData, (int) index); - m_signatures [index] = ts; - } - - return ts; - } - - public MethodSpec GetMethodSpec (uint index) - { - MethodSpec ms = m_signatures [index] as MethodSpec; - - if (ms == null) { - ms = ReadMethodSpec (m_blobData, (int) index); - m_signatures [index] = ms; - } - - return ms; - } - - public LocalVarSig GetLocalVarSig (uint index) - { - LocalVarSig lv = m_signatures [index] as LocalVarSig; - if (lv == null) { - lv = new LocalVarSig (index); - lv.Accept (this); - m_signatures [index] = lv; - } - return lv; - } - - public CustomAttrib GetCustomAttrib (uint index, MethodReference ctor) - { - return GetCustomAttrib (index, ctor, false); - } - - public CustomAttrib GetCustomAttrib (uint index, MethodReference ctor, bool resolve) - { - return ReadCustomAttrib ((int) index, ctor, resolve); - } - - public CustomAttrib GetCustomAttrib (byte [] data, MethodReference ctor) - { - return GetCustomAttrib (data, ctor, false); - } - - public CustomAttrib GetCustomAttrib (byte [] data, MethodReference ctor, bool resolve) - { - BinaryReader br = new BinaryReader (new MemoryStream (data)); - return ReadCustomAttrib (br, data, ctor, resolve); - } - - public Signature GetMemberRefSig (TokenType tt, uint index) - { - int start, callconv; - Utilities.ReadCompressedInteger (m_blobData, (int) index, out start); - callconv = m_blobData [start]; - if ((callconv & 0x5) == 0x5 || (callconv & 0x10) == 0x10) // vararg || generic? - return GetMethodDefSig (index); - if ((callconv & 0x6) != 0) // field ? - return GetFieldSig (index); - - switch (tt) { - case TokenType.TypeDef : - case TokenType.TypeRef : - case TokenType.TypeSpec : - return GetMethodRefSig (index); - case TokenType.ModuleRef : - case TokenType.Method : - return GetMethodDefSig (index); - } - return null; - } - - public MarshalSig GetMarshalSig (uint index) - { - MarshalSig ms = m_signatures [index] as MarshalSig; - if (ms == null) { - byte [] data = m_root.Streams.BlobHeap.Read (index); - ms = ReadMarshalSig (data); - m_signatures [index] = ms; - } - return ms; - } - - public MethodSig GetStandAloneMethodSig (uint index) - { - byte [] data = m_root.Streams.BlobHeap.Read (index); - int start; - if ((data [0] & 0x5) > 0) { - MethodRefSig mrs = new MethodRefSig (index); - ReadMethodRefSig (mrs, data, 0, out start); - return mrs; - } else { - MethodDefSig mds = new MethodDefSig (index); - ReadMethodDefSig (mds, data, 0, out start); - return mds; - } - } - - public override void VisitMethodDefSig (MethodDefSig methodDef) - { - int start; - ReadMethodDefSig (methodDef, m_root.Streams.BlobHeap.Read (methodDef.BlobIndex), 0, out start); - } - - public override void VisitMethodRefSig (MethodRefSig methodRef) - { - int start; - ReadMethodRefSig (methodRef, m_root.Streams.BlobHeap.Read (methodRef.BlobIndex), 0, out start); - } - - public override void VisitFieldSig (FieldSig field) - { - int start; - Utilities.ReadCompressedInteger (m_blobData, (int) field.BlobIndex, out start); - field.CallingConvention = m_blobData [start]; - field.Field = (field.CallingConvention & 0x6) != 0; - field.CustomMods = ReadCustomMods (m_blobData, start + 1, out start); - field.Type = ReadType (m_blobData, start, out start); - } - - public override void VisitPropertySig (PropertySig property) - { - int start; - Utilities.ReadCompressedInteger (m_blobData, (int) property.BlobIndex, out start); - property.CallingConvention = m_blobData [start]; - property.Property = (property.CallingConvention & 0x8) != 0; - property.ParamCount = Utilities.ReadCompressedInteger (m_blobData, start + 1, out start); - property.CustomMods = ReadCustomMods (m_blobData, start, out start); - property.Type = ReadType (m_blobData, start, out start); - property.Parameters = ReadParameters (property.ParamCount, m_blobData, start); - } - - public override void VisitLocalVarSig (LocalVarSig localvar) - { - int start; - Utilities.ReadCompressedInteger (m_blobData, (int) localvar.BlobIndex, out start); - localvar.CallingConvention = m_blobData [start]; - localvar.Local = (localvar.CallingConvention & 0x7) != 0; - localvar.Count = Utilities.ReadCompressedInteger (m_blobData, start + 1, out start); - localvar.LocalVariables = ReadLocalVariables (localvar.Count, m_blobData, start); - } - - void ReadMethodDefSig (MethodDefSig methodDef, byte [] data, int pos, out int start) - { - methodDef.CallingConvention = data [pos]; - start = pos + 1; - methodDef.HasThis = (methodDef.CallingConvention & 0x20) != 0; - methodDef.ExplicitThis = (methodDef.CallingConvention & 0x40) != 0; - if ((methodDef.CallingConvention & 0x5) != 0) - methodDef.MethCallConv |= MethodCallingConvention.VarArg; - else if ((methodDef.CallingConvention & 0x10) != 0) { - methodDef.MethCallConv |= MethodCallingConvention.Generic; - methodDef.GenericParameterCount = Utilities.ReadCompressedInteger (data, start, out start); - } else - methodDef.MethCallConv |= MethodCallingConvention.Default; - - methodDef.ParamCount = Utilities.ReadCompressedInteger (data, start, out start); - methodDef.RetType = ReadRetType (data, start, out start); - int sentpos; - methodDef.Parameters = ReadParameters (methodDef.ParamCount, data, start, out sentpos); - methodDef.Sentinel = sentpos; - } - - void ReadMethodRefSig (MethodRefSig methodRef, byte [] data, int pos, out int start) - { - methodRef.CallingConvention = data [pos]; - start = pos + 1; - methodRef.HasThis = (methodRef.CallingConvention & 0x20) != 0; - methodRef.ExplicitThis = (methodRef.CallingConvention & 0x40) != 0; - if ((methodRef.CallingConvention & 0x1) != 0) - methodRef.MethCallConv |= MethodCallingConvention.C; - else if ((methodRef.CallingConvention & 0x2) != 0) - methodRef.MethCallConv |= MethodCallingConvention.StdCall; - else if ((methodRef.CallingConvention & 0x3) != 0) - methodRef.MethCallConv |= MethodCallingConvention.ThisCall; - else if ((methodRef.CallingConvention & 0x4) != 0) - methodRef.MethCallConv |= MethodCallingConvention.FastCall; - else if ((methodRef.CallingConvention & 0x5) != 0) - methodRef.MethCallConv |= MethodCallingConvention.VarArg; - else - methodRef.MethCallConv |= MethodCallingConvention.Default; - methodRef.ParamCount = Utilities.ReadCompressedInteger (data, start, out start); - methodRef.RetType = ReadRetType (data, start, out start); - int sentpos; - methodRef.Parameters = ReadParameters (methodRef.ParamCount, data, start, out sentpos); - methodRef.Sentinel = sentpos; - } - - LocalVarSig.LocalVariable [] ReadLocalVariables (int length, byte [] data, int pos) - { - int start = pos; - LocalVarSig.LocalVariable [] types = new LocalVarSig.LocalVariable [length]; - for (int i = 0; i < length; i++) - types [i] = ReadLocalVariable (data, start, out start); - return types; - } - - LocalVarSig.LocalVariable ReadLocalVariable (byte [] data, int pos, out int start) - { - start = pos; - LocalVarSig.LocalVariable lv = new LocalVarSig.LocalVariable (); - lv.ByRef = false; - int cursor; - while (true) { - lv.CustomMods = ReadCustomMods (data, start, out start); - cursor = start; - int current = Utilities.ReadCompressedInteger (data, start, out start); - if (current == (int) ElementType.Pinned) // the only possible constraint - lv.Constraint |= Constraint.Pinned; - else if (current == (int) ElementType.ByRef) { - lv.ByRef = true; - - if (lv.CustomMods == null || lv.CustomMods.Length == 0) - lv.CustomMods = ReadCustomMods (data, start, out start); - } else { - lv.Type = ReadType (data, cursor, out start); - break; - } - } - return lv; - } - - TypeSpec ReadTypeSpec (byte [] data, int pos) - { - int start = pos; - Utilities.ReadCompressedInteger (data, start, out start); - TypeSpec ts = new TypeSpec (); - ts.CustomMods = ReadCustomMods (data, start, out start); - ts.Type = ReadType (data, start, out start); - return ts; - } - - MethodSpec ReadMethodSpec (byte [] data, int pos) - { - int start = pos; - - Utilities.ReadCompressedInteger (data, start, out start); - if (Utilities.ReadCompressedInteger (data, start, out start) != 0x0a) - throw new ReflectionException ("Invalid MethodSpec signature"); - - return new MethodSpec (ReadGenericInstSignature (data, start, out start)); - } - - RetType ReadRetType (byte [] data, int pos, out int start) - { - RetType rt = new RetType (); - start = pos; - rt.CustomMods = ReadCustomMods (data, start, out start); - int curs = start; - ElementType flag = (ElementType) Utilities.ReadCompressedInteger (data, start, out start); - switch (flag) { - case ElementType.Void : - rt.ByRef = rt.TypedByRef = false; - rt.Void = true; - break; - case ElementType.TypedByRef : - rt.ByRef = rt.Void = false; - rt.TypedByRef = true; - break; - case ElementType.ByRef : - rt.TypedByRef = rt.Void = false; - rt.ByRef = true; - - if (rt.CustomMods == null || rt.CustomMods.Length == 0) - rt.CustomMods = ReadCustomMods (data, start, out start); - - rt.Type = ReadType (data, start, out start); - break; - default : - rt.TypedByRef = rt.Void = rt.ByRef = false; - rt.Type = ReadType (data, curs, out start); - break; - } - return rt; - } - - Param [] ReadParameters (int length, byte [] data, int pos) - { - Param [] ret = new Param [length]; - int start = pos; - for (int i = 0; i < length; i++) - ret [i] = ReadParameter (data, start, out start); - return ret; - } - - Param [] ReadParameters (int length, byte [] data, int pos, out int sentinelpos) - { - Param [] ret = new Param [length]; - int start = pos; - sentinelpos = -1; - - for (int i = 0; i < length; i++) { - int curs = start; - int flag = Utilities.ReadCompressedInteger (data, start, out start); - - if (flag == (int) ElementType.Sentinel) { - sentinelpos = i; - curs = start; - } - - ret [i] = ReadParameter (data, curs, out start); - } - - return ret; - } - - Param ReadParameter (byte [] data, int pos, out int start) - { - Param p = new Param (); - start = pos; - - p.CustomMods = ReadCustomMods (data, start, out start); - int curs = start; - ElementType flag = (ElementType) Utilities.ReadCompressedInteger (data, start, out start); - switch (flag) { - case ElementType.TypedByRef : - p.TypedByRef = true; - p.ByRef = false; - break; - case ElementType.ByRef : - p.TypedByRef = false; - p.ByRef = true; - - if (p.CustomMods == null || p.CustomMods.Length == 0) - p.CustomMods = ReadCustomMods (data, start, out start); - - p.Type = ReadType (data, start, out start); - break; - default : - p.TypedByRef = false; - p.ByRef = false; - p.Type = ReadType (data, curs, out start); - break; - } - return p; - } - - SigType ReadType (byte [] data, int pos, out int start) - { - start = pos; - ElementType element = (ElementType) Utilities.ReadCompressedInteger (data, start, out start); - switch (element) { - case ElementType.ValueType : - VALUETYPE vt = new VALUETYPE (); - vt.Type = Utilities.GetMetadataToken(CodedIndex.TypeDefOrRef, - (uint) Utilities.ReadCompressedInteger (data, start, out start)); - return vt; - case ElementType.Class : - CLASS c = new CLASS (); - c.Type = Utilities.GetMetadataToken (CodedIndex.TypeDefOrRef, - (uint) Utilities.ReadCompressedInteger (data, start, out start)); - return c; - case ElementType.Ptr : - PTR p = new PTR (); - int buf = start; - int flag = Utilities.ReadCompressedInteger (data, start, out start); - p.Void = flag == (int) ElementType.Void; - if (p.Void) - return p; - start = buf; - p.CustomMods = ReadCustomMods (data, start, out start); - p.PtrType = ReadType (data, start, out start); - return p; - case ElementType.FnPtr : - FNPTR fp = new FNPTR (); - if ((data [start] & 0x5) != 0) { - MethodRefSig mr = new MethodRefSig ((uint) start); - ReadMethodRefSig (mr, data, start, out start); - fp.Method = mr; - } else { - MethodDefSig md = new MethodDefSig ((uint) start); - ReadMethodDefSig (md, data, start, out start); - fp.Method = md; - } - return fp; - case ElementType.Array : - ARRAY ary = new ARRAY (); - ary.CustomMods = ReadCustomMods (data, start, out start); - ArrayShape shape = new ArrayShape (); - ary.Type = ReadType (data, start, out start); - shape.Rank = Utilities.ReadCompressedInteger (data, start, out start); - shape.NumSizes = Utilities.ReadCompressedInteger (data, start, out start); - shape.Sizes = new int [shape.NumSizes]; - for (int i = 0; i < shape.NumSizes; i++) - shape.Sizes [i] = Utilities.ReadCompressedInteger (data, start, out start); - shape.NumLoBounds = Utilities.ReadCompressedInteger (data, start, out start); - shape.LoBounds = new int [shape.NumLoBounds]; - for (int i = 0; i < shape.NumLoBounds; i++) - shape.LoBounds [i] = Utilities.ReadCompressedInteger (data, start, out start); - ary.Shape = shape; - return ary; - case ElementType.SzArray : - SZARRAY sa = new SZARRAY (); - sa.CustomMods = ReadCustomMods (data, start, out start); - sa.Type = ReadType (data, start, out start); - return sa; - case ElementType.Var: - return new VAR (Utilities.ReadCompressedInteger (data, start, out start)); - case ElementType.MVar: - return new MVAR (Utilities.ReadCompressedInteger (data, start, out start)); - case ElementType.GenericInst: - GENERICINST ginst = new GENERICINST (); - - ginst.ValueType = ((ElementType) Utilities.ReadCompressedInteger ( - data, start, out start)) == ElementType.ValueType; - - ginst.Type = Utilities.GetMetadataToken (CodedIndex.TypeDefOrRef, - (uint) Utilities.ReadCompressedInteger (data, start, out start)); - - ginst.Signature = ReadGenericInstSignature (data, start, out start); - - return ginst; - default : - return new SigType (element); - } - } - - GenericInstSignature ReadGenericInstSignature (byte [] data, int pos, out int start) - { - start = pos; - GenericInstSignature gis = new GenericInstSignature (); - gis.Arity = Utilities.ReadCompressedInteger (data, start, out start); - gis.Types = new GenericArg [gis.Arity]; - for (int i = 0; i < gis.Arity; i++) - gis.Types [i] = ReadGenericArg (data, start, out start); - - return gis; - } - - GenericArg ReadGenericArg (byte[] data, int pos, out int start) - { - start = pos; - CustomMod [] mods = ReadCustomMods (data, start, out start); - GenericArg arg = new GenericArg (ReadType (data, start, out start)); - arg.CustomMods = mods; - return arg; - } - - CustomMod [] ReadCustomMods (byte [] data, int pos, out int start) - { - ArrayList cmods = new ArrayList (); - start = pos; - while (true) { - int buf = start; - ElementType flag = (ElementType) Utilities.ReadCompressedInteger (data, start, out start); - start = buf; - if (!((flag == ElementType.CModOpt) || (flag == ElementType.CModReqD))) - break; - cmods.Add (ReadCustomMod (data, start, out start)); - } - return cmods.ToArray (typeof (CustomMod)) as CustomMod []; - } - - CustomMod ReadCustomMod (byte [] data, int pos, out int start) - { - CustomMod cm = new CustomMod (); - start = pos; - ElementType cmod = (ElementType) Utilities.ReadCompressedInteger (data, start, out start); - if (cmod == ElementType.CModOpt) - cm.CMOD = CustomMod.CMODType.OPT; - else if (cmod == ElementType.CModReqD) - cm.CMOD = CustomMod.CMODType.REQD; - else - cm.CMOD = CustomMod.CMODType.None; - cm.TypeDefOrRef = Utilities.GetMetadataToken (CodedIndex.TypeDefOrRef, - (uint) Utilities.ReadCompressedInteger (data, start, out start)); - return cm; - } - - CustomAttrib ReadCustomAttrib (int pos, MethodReference ctor, bool resolve) - { - int start, length = Utilities.ReadCompressedInteger (m_blobData, pos, out start); - byte [] data = new byte [length]; - Buffer.BlockCopy (m_blobData, start, data, 0, length); - try { - return ReadCustomAttrib (new BinaryReader ( - new MemoryStream (data)), data, ctor, resolve); - } catch { - CustomAttrib ca = new CustomAttrib (ctor); - ca.Read = false; - return ca; - } - } - - CustomAttrib ReadCustomAttrib (BinaryReader br, byte [] data, MethodReference ctor, bool resolve) - { - CustomAttrib ca = new CustomAttrib (ctor); - if (data.Length == 0) { - ca.FixedArgs = new CustomAttrib.FixedArg [0]; - ca.NamedArgs = new CustomAttrib.NamedArg [0]; - return ca; - } - - bool read = true; - - ca.Prolog = br.ReadUInt16 (); - if (ca.Prolog != CustomAttrib.StdProlog) - throw new MetadataFormatException ("Non standard prolog for custom attribute"); - - ca.FixedArgs = new CustomAttrib.FixedArg [ctor.Parameters.Count]; - for (int i = 0; i < ca.FixedArgs.Length && read; i++) - ca.FixedArgs [i] = ReadFixedArg (data, br, - ctor.Parameters [i].ParameterType, ref read, resolve); - - if (br.BaseStream.Position == br.BaseStream.Length) - read = false; - - if (!read) { - ca.Read = read; - return ca; - } - - ca.NumNamed = br.ReadUInt16 (); - ca.NamedArgs = new CustomAttrib.NamedArg [ca.NumNamed]; - for (int i = 0; i < ca.NumNamed && read; i++) - ca.NamedArgs [i] = ReadNamedArg (data, br, ref read, resolve); - - ca.Read = read; - return ca; - } - - CustomAttrib.FixedArg ReadFixedArg (byte [] data, BinaryReader br, - TypeReference param, ref bool read, bool resolve) - { - CustomAttrib.FixedArg fa = new CustomAttrib.FixedArg (); - if (param is ArrayType) { - param = ((ArrayType) param).ElementType; - fa.SzArray = true; - fa.NumElem = br.ReadUInt32 (); - - if (fa.NumElem == 0 || fa.NumElem == 0xffffffff) { - fa.Elems = new CustomAttrib.Elem [0]; - fa.NumElem = 0; - return fa; - } - - fa.Elems = new CustomAttrib.Elem [fa.NumElem]; - for (int i = 0; i < fa.NumElem; i++) - fa.Elems [i] = ReadElem (data, br, param, ref read, resolve); - } else - fa.Elems = new CustomAttrib.Elem [] { ReadElem (data, br, param, ref read, resolve) }; - - return fa; - } - - TypeReference CreateEnumTypeReference (string enumName) - { - string asmName = null; - int asmStart = enumName.IndexOf (','); - if (asmStart != -1) { - asmName = enumName.Substring (asmStart + 1); - enumName = enumName.Substring (0, asmStart); - } - // Inner class style is reflection style. - enumName = enumName.Replace ('+', '/'); - AssemblyNameReference asm; - if (asmName == null) { - // If no assembly is given then the ECMA standard says the - // assembly is either the current one or mscorlib. - if (m_reflectReader.Module.Types.Contains (enumName)) - return m_reflectReader.Module.Types [enumName]; - - asm = m_reflectReader.Corlib; - } else - asm = AssemblyNameReference.Parse (asmName); - - string [] outers = enumName.Split ('/'); - string outerfullname = outers [0]; - string ns = null; - int nsIndex = outerfullname.LastIndexOf ('.'); - if (nsIndex != -1) - ns = outerfullname.Substring (0, nsIndex); - string name = outerfullname.Substring (nsIndex + 1); - TypeReference decType = new TypeReference (name, ns, asm); - for (int i = 1; i < outers.Length; i++) { - TypeReference t = new TypeReference (outers [i], null, asm); - t.DeclaringType = decType; - decType = t; - } - decType.IsValueType = true; - - return decType; - } - - TypeReference ReadTypeReference (byte [] data, BinaryReader br, out ElementType elemType) - { - bool array = false; - elemType = (ElementType) br.ReadByte (); - if (elemType == ElementType.SzArray) { - elemType = (ElementType) br.ReadByte (); - array = true; - } - - TypeReference res; - if (elemType == ElementType.Enum) - res = CreateEnumTypeReference (ReadUTF8String (data, br)); - else - res = TypeReferenceFromElemType (elemType); - - if (array) - res = new ArrayType (res); - - return res; - } - - TypeReference TypeReferenceFromElemType (ElementType elemType) - { - switch (elemType) { - case ElementType.Boxed : - return m_reflectReader.SearchCoreType (Constants.Object); - case ElementType.String : - return m_reflectReader.SearchCoreType (Constants.String); - case ElementType.Type : - return m_reflectReader.SearchCoreType (Constants.Type); - case ElementType.Boolean : - return m_reflectReader.SearchCoreType (Constants.Boolean); - case ElementType.Char : - return m_reflectReader.SearchCoreType (Constants.Char); - case ElementType.R4 : - return m_reflectReader.SearchCoreType (Constants.Single); - case ElementType.R8 : - return m_reflectReader.SearchCoreType (Constants.Double); - case ElementType.I1 : - return m_reflectReader.SearchCoreType (Constants.SByte); - case ElementType.I2 : - return m_reflectReader.SearchCoreType (Constants.Int16); - case ElementType.I4 : - return m_reflectReader.SearchCoreType (Constants.Int32); - case ElementType.I8 : - return m_reflectReader.SearchCoreType (Constants.Int64); - case ElementType.U1 : - return m_reflectReader.SearchCoreType (Constants.Byte); - case ElementType.U2 : - return m_reflectReader.SearchCoreType (Constants.UInt16); - case ElementType.U4 : - return m_reflectReader.SearchCoreType (Constants.UInt32); - case ElementType.U8 : - return m_reflectReader.SearchCoreType (Constants.UInt64); - default : - throw new MetadataFormatException ("Non valid type in CustomAttrib.Elem: 0x{0}", - ((byte) elemType).ToString("x2")); - } - } - - internal CustomAttrib.NamedArg ReadNamedArg (byte [] data, BinaryReader br, ref bool read, bool resolve) - { - CustomAttrib.NamedArg na = new CustomAttrib.NamedArg (); - byte kind = br.ReadByte (); - if (kind == 0x53) { // field - na.Field = true; - na.Property = false; - } else if (kind == 0x54) { // property - na.Field = false; - na.Property = true; - } else - throw new MetadataFormatException ("Wrong kind of namedarg found: 0x" + kind.ToString("x2")); - - TypeReference elemType = ReadTypeReference (data, br, out na.FieldOrPropType); - na.FieldOrPropName = ReadUTF8String (data, br); - na.FixedArg = ReadFixedArg (data, br, elemType, ref read, resolve); - - return na; - } - - CustomAttrib.Elem ReadElem (byte [] data, BinaryReader br, TypeReference elemType, ref bool read, bool resolve) - { - CustomAttrib.Elem elem = new CustomAttrib.Elem (); - - string elemName = elemType.FullName; - - if (elemName == Constants.Object) { - elemType = ReadTypeReference (data, br, out elem.FieldOrPropType); - if (elemType is ArrayType) { - read = false; // Don't know how to represent arrays as an object value. - return elem; - } else if (elemType.FullName == Constants.Object) - throw new MetadataFormatException ("Non valid type in CustomAttrib.Elem after boxed prefix: 0x{0}", - ((byte) elem.FieldOrPropType).ToString("x2")); - - elem = ReadElem (data, br, elemType, ref read, resolve); - elem.String = elem.Simple = elem.Type = false; - elem.BoxedValueType = true; - return elem; - } - - elem.ElemType = elemType; - - if (elemName == Constants.Type || elemName == Constants.String) { - switch (elemType.FullName) { - case Constants.String: - elem.String = true; - elem.BoxedValueType = elem.Simple = elem.Type = false; - break; - case Constants.Type: - elem.Type = true; - elem.BoxedValueType = elem.Simple = elem.String = false; - break; - } - - if (data [br.BaseStream.Position] == 0xff) { // null - elem.Value = null; - br.BaseStream.Position++; - } else { - elem.Value = ReadUTF8String (data, br); - } - return elem; - } - - elem.String = elem.Type = elem.BoxedValueType = false; - if (!ReadSimpleValue (br, ref elem, elem.ElemType)) { - if (!resolve) { // until enums writing is implemented - read = false; - return elem; - } - TypeReference typeRef = GetEnumUnderlyingType (elem.ElemType, resolve); - if (typeRef == null || !ReadSimpleValue (br, ref elem, typeRef)) - read = false; - } - - return elem; - } - - TypeReference GetEnumUnderlyingType (TypeReference enumType, bool resolve) - { - TypeDefinition type = enumType as TypeDefinition; - if (type == null && resolve && AssemblyResolver != null) { - if (enumType.Scope is ModuleDefinition) - throw new NotSupportedException (); - - AssemblyDefinition asm = AssemblyResolver.Resolve ( - ((AssemblyNameReference) enumType.Scope).FullName); - type = asm.MainModule.Types [enumType.FullName]; - } - - if (type != null && type.IsEnum) - return type.Fields.GetField ("value__").FieldType; - - return null; - } - - bool ReadSimpleValue (BinaryReader br, ref CustomAttrib.Elem elem, TypeReference type) - { - switch (type.FullName) { - case Constants.Boolean : - elem.Value = br.ReadByte () == 1; - break; - case Constants.Char : - elem.Value = (char) br.ReadUInt16 (); - break; - case Constants.Single : - elem.Value = br.ReadSingle (); - break; - case Constants.Double : - elem.Value = br.ReadDouble (); - break; - case Constants.Byte : - elem.Value = br.ReadByte (); - break; - case Constants.Int16 : - elem.Value = br.ReadInt16 (); - break; - case Constants.Int32 : - elem.Value = br.ReadInt32 (); - break; - case Constants.Int64 : - elem.Value = br.ReadInt64 (); - break; - case Constants.SByte : - elem.Value = br.ReadSByte (); - break; - case Constants.UInt16 : - elem.Value = br.ReadUInt16 (); - break; - case Constants.UInt32 : - elem.Value = br.ReadUInt32 (); - break; - case Constants.UInt64 : - elem.Value = br.ReadUInt64 (); - break; - default : // enum - return false; - } - elem.Simple = true; - return true; - } - - MarshalSig ReadMarshalSig (byte [] data) - { - int start; - MarshalSig ms = new MarshalSig ((NativeType) Utilities.ReadCompressedInteger (data, 0, out start)); - switch (ms.NativeInstrinsic) { - case NativeType.ARRAY: - MarshalSig.Array ar = new MarshalSig.Array (); - ar.ArrayElemType = (NativeType) Utilities.ReadCompressedInteger (data, start, out start); - if (start < data.Length) - ar.ParamNum = Utilities.ReadCompressedInteger (data, start, out start); - if (start < data.Length) - ar.NumElem = Utilities.ReadCompressedInteger (data, start, out start); - if (start < data.Length) - ar.ElemMult = Utilities.ReadCompressedInteger (data, start, out start); - ms.Spec = ar; - break; - case NativeType.CUSTOMMARSHALER: - MarshalSig.CustomMarshaler cm = new MarshalSig.CustomMarshaler (); - cm.Guid = ReadUTF8String (data, start, out start); - cm.UnmanagedType = ReadUTF8String (data, start, out start); - cm.ManagedType = ReadUTF8String (data, start, out start); - cm.Cookie = ReadUTF8String (data, start, out start); - ms.Spec = cm; - break; - case NativeType.FIXEDARRAY: - MarshalSig.FixedArray fa = new MarshalSig.FixedArray (); - fa.NumElem = Utilities.ReadCompressedInteger (data, start, out start); - if (start < data.Length) - fa.ArrayElemType = (NativeType) Utilities.ReadCompressedInteger (data, start, out start); - ms.Spec = fa; - break; - case NativeType.SAFEARRAY: - MarshalSig.SafeArray sa = new MarshalSig.SafeArray (); - if (start < data.Length) - sa.ArrayElemType = (VariantType) Utilities.ReadCompressedInteger (data, start, out start); - ms.Spec = sa; - break; - case NativeType.FIXEDSYSSTRING: - MarshalSig.FixedSysString fss = new MarshalSig.FixedSysString (); - if (start < data.Length) - fss.Size = Utilities.ReadCompressedInteger (data, start, out start); - ms.Spec = fss; - break; - } - return ms; - } - - static internal string ReadUTF8String (byte [] data, BinaryReader br) - { - int start = (int)br.BaseStream.Position; - string val = ReadUTF8String (data, start, out start); - br.BaseStream.Position = start; - return val; - } - - static internal string ReadUTF8String (byte [] data, int pos, out int start) - { - int length = Utilities.ReadCompressedInteger (data, pos, out start); - pos = start; - start += length; - // COMPACT FRAMEWORK NOTE: Encoding.GetString (byte[]) is not supported. - return Encoding.UTF8.GetString (data, pos, length); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SignatureWriter.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SignatureWriter.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SignatureWriter.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SignatureWriter.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,564 +0,0 @@ -// -// SignatureWriter.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 - 2007 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - using System; - using System.Text; - - using Mono.Cecil; - using Mono.Cecil.Binary; - using Mono.Cecil.Metadata; - - internal sealed class SignatureWriter : BaseSignatureVisitor { - - MetadataWriter m_mdWriter; - MemoryBinaryWriter m_sigWriter; - - public SignatureWriter (MetadataWriter mdWriter) - { - m_mdWriter = mdWriter; - m_sigWriter = new MemoryBinaryWriter (); - } - - uint GetPointer () - { - return m_mdWriter.AddBlob (m_sigWriter.ToArray ()); - } - - public uint AddMethodDefSig (MethodDefSig methSig) - { - return AddSignature (methSig); - } - - public uint AddMethodRefSig (MethodRefSig methSig) - { - return AddSignature (methSig); - } - - public uint AddPropertySig (PropertySig ps) - { - return AddSignature (ps); - } - - public uint AddFieldSig (FieldSig fSig) - { - return AddSignature (fSig); - } - - public uint AddLocalVarSig (LocalVarSig lvs) - { - return AddSignature (lvs); - } - - uint AddSignature (Signature s) - { - m_sigWriter.Empty (); - s.Accept (this); - return GetPointer (); - } - - public uint AddTypeSpec (TypeSpec ts) - { - m_sigWriter.Empty (); - Write (ts); - return GetPointer (); - } - - public uint AddMethodSpec (MethodSpec ms) - { - m_sigWriter.Empty (); - Write (ms); - return GetPointer (); - } - - public uint AddMarshalSig (MarshalSig ms) - { - m_sigWriter.Empty (); - Write (ms); - return GetPointer (); - } - - public uint AddCustomAttribute (CustomAttrib ca, MethodReference ctor) - { - CompressCustomAttribute (ca, ctor, m_sigWriter); - return GetPointer (); - } - - public byte [] CompressCustomAttribute (CustomAttrib ca, MethodReference ctor) - { - MemoryBinaryWriter writer = new MemoryBinaryWriter (); - CompressCustomAttribute (ca, ctor, writer); - return writer.ToArray (); - } - - public byte [] CompressFieldSig (FieldSig field) - { - m_sigWriter.Empty (); - VisitFieldSig (field); - return m_sigWriter.ToArray (); - } - - public byte [] CompressLocalVar (LocalVarSig.LocalVariable var) - { - m_sigWriter.Empty (); - Write (var); - return m_sigWriter.ToArray (); - } - - void CompressCustomAttribute (CustomAttrib ca, MethodReference ctor, MemoryBinaryWriter writer) - { - m_sigWriter.Empty (); - Write (ca, ctor, writer); - } - - public override void VisitMethodDefSig (MethodDefSig methodDef) - { - m_sigWriter.Write (methodDef.CallingConvention); - if (methodDef.GenericParameterCount > 0) - Write (methodDef.GenericParameterCount); - Write (methodDef.ParamCount); - Write (methodDef.RetType); - Write (methodDef.Parameters, methodDef.Sentinel); - } - - public override void VisitMethodRefSig (MethodRefSig methodRef) - { - m_sigWriter.Write (methodRef.CallingConvention); - Write (methodRef.ParamCount); - Write (methodRef.RetType); - Write (methodRef.Parameters, methodRef.Sentinel); - } - - public override void VisitFieldSig (FieldSig field) - { - m_sigWriter.Write (field.CallingConvention); - Write (field.CustomMods); - Write (field.Type); - } - - public override void VisitPropertySig (PropertySig property) - { - m_sigWriter.Write (property.CallingConvention); - Write (property.ParamCount); - Write (property.CustomMods); - Write (property.Type); - Write (property.Parameters); - } - - public override void VisitLocalVarSig (LocalVarSig localvar) - { - m_sigWriter.Write (localvar.CallingConvention); - Write (localvar.Count); - Write (localvar.LocalVariables); - } - - void Write (LocalVarSig.LocalVariable [] vars) - { - foreach (LocalVarSig.LocalVariable var in vars) - Write (var); - } - - void Write (LocalVarSig.LocalVariable var) - { - Write (var.CustomMods); - if ((var.Constraint & Constraint.Pinned) != 0) - Write (ElementType.Pinned); - if (var.ByRef) - Write (ElementType.ByRef); - Write (var.Type); - } - - void Write (RetType retType) - { - Write (retType.CustomMods); - if (retType.Void) - Write (ElementType.Void); - else if (retType.TypedByRef) - Write (ElementType.TypedByRef); - else if (retType.ByRef) { - Write (ElementType.ByRef); - Write (retType.Type); - } else - Write (retType.Type); - } - - void Write (Param [] parameters, int sentinel) - { - for (int i = 0; i < parameters.Length; i++) { - if (i == sentinel) - Write (ElementType.Sentinel); - - Write (parameters [i]); - } - } - - void Write (Param [] parameters) - { - foreach (Param p in parameters) - Write (p); - } - - void Write (ElementType et) - { - Write ((int) et); - } - - void Write (SigType t) - { - Write ((int) t.ElementType); - - switch (t.ElementType) { - case ElementType.ValueType : - Write ((int) Utilities.CompressMetadataToken ( - CodedIndex.TypeDefOrRef, ((VALUETYPE) t).Type)); - break; - case ElementType.Class : - Write ((int) Utilities.CompressMetadataToken ( - CodedIndex.TypeDefOrRef, ((CLASS) t).Type)); - break; - case ElementType.Ptr : - PTR p = (PTR) t; - if (p.Void) - Write (ElementType.Void); - else { - Write (p.CustomMods); - Write (p.PtrType); - } - break; - case ElementType.FnPtr : - FNPTR fp = (FNPTR) t; - if (fp.Method is MethodRefSig) - (fp.Method as MethodRefSig).Accept (this); - else - (fp.Method as MethodDefSig).Accept (this); - break; - case ElementType.Array : - ARRAY ary = (ARRAY) t; - Write (ary.CustomMods); - ArrayShape shape = ary.Shape; - Write (ary.Type); - Write (shape.Rank); - Write (shape.NumSizes); - foreach (int size in shape.Sizes) - Write (size); - Write (shape.NumLoBounds); - foreach (int loBound in shape.LoBounds) - Write (loBound); - break; - case ElementType.SzArray : - SZARRAY sa = (SZARRAY) t; - Write (sa.CustomMods); - Write (sa.Type); - break; - case ElementType.Var : - Write (((VAR) t).Index); - break; - case ElementType.MVar : - Write (((MVAR) t).Index); - break; - case ElementType.GenericInst : - GENERICINST gi = t as GENERICINST; - Write (gi.ValueType ? ElementType.ValueType : ElementType.Class); - Write ((int) Utilities.CompressMetadataToken ( - CodedIndex.TypeDefOrRef, gi.Type)); - Write (gi.Signature); - break; - } - } - - void Write (TypeSpec ts) - { - Write (ts.CustomMods); - Write (ts.Type); - } - - void Write (MethodSpec ms) - { - Write (0x0a); - Write (ms.Signature); - } - - void Write (GenericInstSignature gis) - { - Write (gis.Arity); - for (int i = 0; i < gis.Arity; i++) - Write (gis.Types [i]); - } - - void Write (GenericArg arg) - { - Write (arg.CustomMods); - Write (arg.Type); - } - - void Write (Param p) - { - Write (p.CustomMods); - if (p.TypedByRef) - Write (ElementType.TypedByRef); - else if (p.ByRef) { - Write (ElementType.ByRef); - Write (p.Type); - } else - Write (p.Type); - } - - void Write (CustomMod [] customMods) - { - foreach (CustomMod cm in customMods) - Write (cm); - } - - void Write (CustomMod cm) - { - switch (cm.CMOD) { - case CustomMod.CMODType.OPT : - Write (ElementType.CModOpt); - break; - case CustomMod.CMODType.REQD : - Write (ElementType.CModReqD); - break; - } - - Write ((int) Utilities.CompressMetadataToken ( - CodedIndex.TypeDefOrRef, cm.TypeDefOrRef)); - } - - void Write (MarshalSig ms) - { - Write ((int) ms.NativeInstrinsic); - switch (ms.NativeInstrinsic) { - case NativeType.ARRAY : - MarshalSig.Array ar = (MarshalSig.Array) ms.Spec; - Write ((int) ar.ArrayElemType); - if (ar.ParamNum != -1) - Write (ar.ParamNum); - if (ar.NumElem != -1) - Write (ar.NumElem); - if (ar.ElemMult != -1) - Write (ar.ElemMult); - break; - case NativeType.CUSTOMMARSHALER : - MarshalSig.CustomMarshaler cm = (MarshalSig.CustomMarshaler) ms.Spec; - Write (cm.Guid); - Write (cm.UnmanagedType); - Write (cm.ManagedType); - Write (cm.Cookie); - break; - case NativeType.FIXEDARRAY : - MarshalSig.FixedArray fa = (MarshalSig.FixedArray) ms.Spec; - Write (fa.NumElem); - if (fa.ArrayElemType != NativeType.NONE) - Write ((int) fa.ArrayElemType); - break; - case NativeType.SAFEARRAY : - Write ((int) ((MarshalSig.SafeArray) ms.Spec).ArrayElemType); - break; - case NativeType.FIXEDSYSSTRING : - Write (((MarshalSig.FixedSysString) ms.Spec).Size); - break; - } - } - - void Write (CustomAttrib ca, MethodReference ctor, MemoryBinaryWriter writer) - { - if (ca == null) - return; - - if (ca.Prolog != CustomAttrib.StdProlog) - return; - - writer.Write (ca.Prolog); - - for (int i = 0; i < ctor.Parameters.Count; i++) - Write (ca.FixedArgs [i], writer); - - writer.Write (ca.NumNamed); - - for (int i = 0; i < ca.NumNamed; i++) - Write (ca.NamedArgs [i], writer); - } - - void Write (CustomAttrib.FixedArg fa, MemoryBinaryWriter writer) - { - if (fa.SzArray) - writer.Write (fa.NumElem); - - foreach (CustomAttrib.Elem elem in fa.Elems) - Write (elem, writer); - } - - static string GetEnumFullName (TypeReference type) - { - string fullname = type.FullName; - - if (type.IsNested) - fullname = fullname.Replace ('/', '+'); - - if (type is TypeDefinition) - return fullname; - - return string.Concat (fullname, ", ", type.Module.Assembly.Name.FullName); - } - - void Write (CustomAttrib.NamedArg na, MemoryBinaryWriter writer) - { - if (na.Field) - writer.Write ((byte) 0x53); - else if (na.Property) - writer.Write ((byte) 0x54); - else - throw new MetadataFormatException ("Unknown kind of namedarg"); - - if (na.FieldOrPropType == ElementType.Class) - na.FieldOrPropType = ElementType.Enum; - - if (na.FixedArg.SzArray) - writer.Write ((byte) ElementType.SzArray); - - if (na.FieldOrPropType == ElementType.Object) - writer.Write ((byte) ElementType.Boxed); - else - writer.Write ((byte) na.FieldOrPropType); - - if (na.FieldOrPropType == ElementType.Enum) - Write (GetEnumFullName (na.FixedArg.Elems [0].ElemType)); - - Write (na.FieldOrPropName); - - Write (na.FixedArg, writer); - } - - static ElementType GetElementTypeFromTypeCode (TypeCode tc) - { - switch (tc) { - case TypeCode.Byte: - return ElementType.U1; - case TypeCode.SByte: - return ElementType.I1; - case TypeCode.Int16: - return ElementType.I2; - case TypeCode.UInt16: - return ElementType.U2; - case TypeCode.Int32: - return ElementType.I4; - case TypeCode.UInt32: - return ElementType.U4; - case TypeCode.Int64: - return ElementType.I8; - case TypeCode.UInt64: - return ElementType.U8; - default: - throw new ArgumentException ("tc"); - } - } - - void Write (CustomAttrib.Elem elem, MemoryBinaryWriter writer) - { - if (elem.String) - elem.FieldOrPropType = ElementType.String; - else if (elem.Type) - elem.FieldOrPropType = ElementType.Type; - - if (elem.FieldOrPropType == ElementType.Class) // an enum in fact - elem.FieldOrPropType = GetElementTypeFromTypeCode (Type.GetTypeCode (elem.Value.GetType ())); - - if (elem.BoxedValueType) - Write (elem.FieldOrPropType); - - switch (elem.FieldOrPropType) { - case ElementType.Boolean : - writer.Write ((byte) ((bool) elem.Value ? 1 : 0)); - break; - case ElementType.Char : - writer.Write ((ushort) (char) elem.Value); - break; - case ElementType.R4 : - writer.Write ((float) elem.Value); - break; - case ElementType.R8 : - writer.Write ((double) elem.Value); - break; - case ElementType.I1 : - writer.Write ((sbyte) elem.Value); - break; - case ElementType.I2 : - writer.Write ((short) elem.Value); - break; - case ElementType.I4 : - writer.Write ((int) elem.Value); - break; - case ElementType.I8 : - writer.Write ((long) elem.Value); - break; - case ElementType.U1 : - writer.Write ((byte) elem.Value); - break; - case ElementType.U2 : - writer.Write ((ushort) elem.Value); - break; - case ElementType.U4 : - writer.Write ((uint) elem.Value); - break; - case ElementType.U8 : - writer.Write ((long) elem.Value); - break; - case ElementType.String : - case ElementType.Type : - string s = elem.Value as string; - if (s == null) - writer.Write ((byte) 0xff); - else if (s.Length == 0) - writer.Write ((byte) 0x00); - else - Write (s); - break; - case ElementType.Object : - if (elem.Value != null) - throw new NotSupportedException ("Unknown state"); - writer.Write ((byte) 0xff); - break; - default : - throw new NotImplementedException ("WriteElem " + elem.FieldOrPropType.ToString ()); - } - } - - void Write (string s) - { - byte [] str = Encoding.UTF8.GetBytes (s); - Write (str.Length); - m_sigWriter.Write (str); - } - - void Write (int i) - { - Utilities.WriteCompressedInteger (m_sigWriter, i); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SigType.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SigType.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SigType.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SigType.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// -// SigType.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - using Mono.Cecil.Metadata; - - internal class SigType { - - public ElementType ElementType; - - public SigType (ElementType elem) - { - ElementType = elem; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SzArray.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SzArray.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SzArray.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SzArray.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// -// SzArray.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 - 2007 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - using Mono.Cecil.Metadata; - - internal sealed class SZARRAY : SigType { - - public CustomMod [] CustomMods; - public SigType Type; - - public SZARRAY () : base (ElementType.SzArray) - { - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/TypeSpec.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/TypeSpec.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/TypeSpec.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/TypeSpec.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// -// TypeSpec.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 - 2007 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - internal sealed class TypeSpec { - - public CustomMod [] CustomMods; - public SigType Type; - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ValueType.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ValueType.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ValueType.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ValueType.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// -// ValueType.cs -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// (C) 2005 Jb Evain -// -// 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. -// - -namespace Mono.Cecil.Signatures { - - using Mono.Cecil.Metadata; - - internal sealed class VALUETYPE : SigType { - - public MetadataToken Type; - - public VALUETYPE () : base (ElementType.ValueType) - { - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Var.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Var.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Var.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Var.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// -// Var.cs -// -// Author: -// Martin Baulig -// -// Copyright (C) 2005 Novell, Inc (http://www.novell.com) -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -namespace Mono.Cecil.Signatures { - - using Mono.Cecil.Metadata; - - internal sealed class VAR : SigType { - - public int Index; - - public VAR (int index) : base (ElementType.Var) - { - this.Index = index; - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Collections.Generic/Collection.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Collections.Generic/Collection.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Collections.Generic/Collection.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Collections.Generic/Collection.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,417 @@ +// +// Collection.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Mono.Collections.Generic { + + public class Collection : IList, IList { + + internal T [] items; + internal int size; + int version; + + public int Count { + get { return size; } + } + + public T this [int index] { + get { + if (index >= size) + throw new ArgumentOutOfRangeException (); + + return items [index]; + } + set { + CheckIndex (index); + if (index == size) + throw new ArgumentOutOfRangeException (); + + OnSet (value, index); + + items [index] = value; + } + } + + bool ICollection.IsReadOnly { + get { return false; } + } + + bool IList.IsFixedSize { + get { return false; } + } + + bool IList.IsReadOnly { + get { return false; } + } + + object IList.this [int index] { + get { return this [index]; } + set { + CheckIndex (index); + + try { + this [index] = (T) value; + return; + } catch (InvalidCastException) { + } catch (NullReferenceException) { + } + + throw new ArgumentException (); + } + } + + int ICollection.Count { + get { return Count; } + } + + bool ICollection.IsSynchronized { + get { return false; } + } + + object ICollection.SyncRoot { + get { return this; } + } + + public Collection () + { + items = Empty.Array; + } + + public Collection (int capacity) + { + if (capacity < 0) + throw new ArgumentOutOfRangeException (); + + items = new T [capacity]; + } + + public Collection (ICollection items) + { + this.items = new T [items.Count]; + items.CopyTo (this.items, 0); + this.size = this.items.Length; + } + + public void Add (T item) + { + if (size == items.Length) + Grow (1); + + OnAdd (item, size); + + items [size++] = item; + version++; + } + + public bool Contains (T item) + { + return IndexOf (item) != -1; + } + + public int IndexOf (T item) + { + return Array.IndexOf (items, item, 0, size); + } + + public void Insert (int index, T item) + { + CheckIndex (index); + if (size == items.Length) + Grow (1); + + OnInsert (item, index); + + Shift (index, 1); + items [index] = item; + version++; + } + + public void RemoveAt (int index) + { + if (index < 0 || index >= size) + throw new ArgumentOutOfRangeException (); + + var item = items [index]; + + OnRemove (item, index); + + Shift (index, -1); + Array.Clear (items, size, 1); + version++; + } + + public bool Remove (T item) + { + var index = IndexOf (item); + if (index == -1) + return false; + + OnRemove (item, index); + + Shift (index, -1); + Array.Clear (items, size, 1); + version++; + + return true; + } + + public void Clear () + { + OnClear (); + + Array.Clear (items, 0, size); + size = 0; + version++; + } + + public void CopyTo (T [] array, int arrayIndex) + { + Array.Copy (items, 0, array, arrayIndex, size); + } + + public T [] ToArray () + { + var array = new T [size]; + Array.Copy (items, 0, array, 0, size); + return array; + } + + void CheckIndex (int index) + { + if (index < 0 || index > size) + throw new ArgumentOutOfRangeException (); + } + + void Shift (int start, int delta) + { + if (delta < 0) + start -= delta; + + if (start < size) + Array.Copy (items, start, items, start + delta, size - start); + + size += delta; + + if (delta < 0) + Array.Clear (items, size, -delta); + } + + protected virtual void OnAdd (T item, int index) + { + } + + protected virtual void OnInsert (T item, int index) + { + } + + protected virtual void OnSet (T item, int index) + { + } + + protected virtual void OnRemove (T item, int index) + { + } + + protected virtual void OnClear () + { + } + + internal virtual void Grow (int desired) + { + int new_size = size + desired; + if (new_size <= items.Length) + return; + + const int default_capacity = 4; + + new_size = System.Math.Max ( + System.Math.Max (items.Length * 2, default_capacity), + new_size); + +#if !CF + Array.Resize (ref items, new_size); +#else + var array = new T [new_size]; + Array.Copy (items, array, size); + items = array; +#endif + } + + int IList.Add (object value) + { + try { + Add ((T) value); + return size - 1; + } catch (InvalidCastException) { + } catch (NullReferenceException) { + } + + throw new ArgumentException (); + } + + void IList.Clear () + { + Clear (); + } + + bool IList.Contains (object value) + { + return ((IList) this).IndexOf (value) > -1; + } + + int IList.IndexOf (object value) + { + try { + return IndexOf ((T) value); + } catch (InvalidCastException) { + } catch (NullReferenceException) { + } + + return -1; + } + + void IList.Insert (int index, object value) + { + CheckIndex (index); + + try { + Insert (index, (T) value); + return; + } catch (InvalidCastException) { + } catch (NullReferenceException) { + } + + throw new ArgumentException (); + } + + void IList.Remove (object value) + { + try { + Remove ((T) value); + } catch (InvalidCastException) { + } catch (NullReferenceException) { + } + } + + void IList.RemoveAt (int index) + { + RemoveAt (index); + } + + void ICollection.CopyTo (Array array, int index) + { + Array.Copy (items, 0, array, index, size); + } + + public Enumerator GetEnumerator () + { + return new Enumerator (this); + } + + IEnumerator IEnumerable.GetEnumerator () + { + return new Enumerator (this); + } + + IEnumerator IEnumerable.GetEnumerator () + { + return new Enumerator (this); + } + + public struct Enumerator : IEnumerator, IDisposable { + + Collection collection; + T current; + + int next; + readonly int version; + + public T Current { + get { return current; } + } + + object IEnumerator.Current { + get { + CheckState (); + + if (next <= 0) + throw new InvalidOperationException (); + + return current; + } + } + + internal Enumerator (Collection collection) + : this () + { + this.collection = collection; + this.version = collection.version; + } + + public bool MoveNext () + { + CheckState (); + + if (next < 0) + return false; + + if (next < collection.size) { + current = collection.items [next++]; + return true; + } + + next = -1; + return false; + } + + public void Reset () + { + CheckState (); + + next = 0; + } + + void CheckState () + { + if (collection == null) + throw new ObjectDisposedException (GetType ().FullName); + + if (version != collection.version) + throw new InvalidOperationException (); + } + + public void Dispose () + { + collection = null; + } + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Security.Cryptography/CryptoConvert.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Security.Cryptography/CryptoConvert.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Security.Cryptography/CryptoConvert.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Security.Cryptography/CryptoConvert.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,243 @@ +// +// CryptoConvert.cs - Crypto Convertion Routines +// +// Author: +// Sebastien Pouliot +// +// (C) 2003 Motus Technologies Inc. (http://www.motus.com) +// Copyright (C) 2004-2006 Novell Inc. (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Security.Cryptography; + +#if !(SILVERLIGHT || READ_ONLY) + +namespace Mono.Security.Cryptography { + + static class CryptoConvert { + + static private int ToInt32LE (byte [] bytes, int offset) + { + return (bytes [offset+3] << 24) | (bytes [offset+2] << 16) | (bytes [offset+1] << 8) | bytes [offset]; + } + + static private uint ToUInt32LE (byte [] bytes, int offset) + { + return (uint)((bytes [offset+3] << 24) | (bytes [offset+2] << 16) | (bytes [offset+1] << 8) | bytes [offset]); + } + + static private byte[] Trim (byte[] array) + { + for (int i=0; i < array.Length; i++) { + if (array [i] != 0x00) { + byte[] result = new byte [array.Length - i]; + Buffer.BlockCopy (array, i, result, 0, result.Length); + return result; + } + } + return null; + } + + static RSA FromCapiPrivateKeyBlob (byte[] blob, int offset) + { + RSAParameters rsap = new RSAParameters (); + try { + if ((blob [offset] != 0x07) || // PRIVATEKEYBLOB (0x07) + (blob [offset+1] != 0x02) || // Version (0x02) + (blob [offset+2] != 0x00) || // Reserved (word) + (blob [offset+3] != 0x00) || + (ToUInt32LE (blob, offset+8) != 0x32415352)) // DWORD magic = RSA2 + throw new CryptographicException ("Invalid blob header"); + + // ALGID (CALG_RSA_SIGN, CALG_RSA_KEYX, ...) + // int algId = ToInt32LE (blob, offset+4); + + // DWORD bitlen + int bitLen = ToInt32LE (blob, offset+12); + + // DWORD public exponent + byte[] exp = new byte [4]; + Buffer.BlockCopy (blob, offset+16, exp, 0, 4); + Array.Reverse (exp); + rsap.Exponent = Trim (exp); + + int pos = offset+20; + // BYTE modulus[rsapubkey.bitlen/8]; + int byteLen = (bitLen >> 3); + rsap.Modulus = new byte [byteLen]; + Buffer.BlockCopy (blob, pos, rsap.Modulus, 0, byteLen); + Array.Reverse (rsap.Modulus); + pos += byteLen; + + // BYTE prime1[rsapubkey.bitlen/16]; + int byteHalfLen = (byteLen >> 1); + rsap.P = new byte [byteHalfLen]; + Buffer.BlockCopy (blob, pos, rsap.P, 0, byteHalfLen); + Array.Reverse (rsap.P); + pos += byteHalfLen; + + // BYTE prime2[rsapubkey.bitlen/16]; + rsap.Q = new byte [byteHalfLen]; + Buffer.BlockCopy (blob, pos, rsap.Q, 0, byteHalfLen); + Array.Reverse (rsap.Q); + pos += byteHalfLen; + + // BYTE exponent1[rsapubkey.bitlen/16]; + rsap.DP = new byte [byteHalfLen]; + Buffer.BlockCopy (blob, pos, rsap.DP, 0, byteHalfLen); + Array.Reverse (rsap.DP); + pos += byteHalfLen; + + // BYTE exponent2[rsapubkey.bitlen/16]; + rsap.DQ = new byte [byteHalfLen]; + Buffer.BlockCopy (blob, pos, rsap.DQ, 0, byteHalfLen); + Array.Reverse (rsap.DQ); + pos += byteHalfLen; + + // BYTE coefficient[rsapubkey.bitlen/16]; + rsap.InverseQ = new byte [byteHalfLen]; + Buffer.BlockCopy (blob, pos, rsap.InverseQ, 0, byteHalfLen); + Array.Reverse (rsap.InverseQ); + pos += byteHalfLen; + + // ok, this is hackish but CryptoAPI support it so... + // note: only works because CRT is used by default + // http://bugzilla.ximian.com/show_bug.cgi?id=57941 + rsap.D = new byte [byteLen]; // must be allocated + if (pos + byteLen + offset <= blob.Length) { + // BYTE privateExponent[rsapubkey.bitlen/8]; + Buffer.BlockCopy (blob, pos, rsap.D, 0, byteLen); + Array.Reverse (rsap.D); + } + } + catch (Exception e) { + throw new CryptographicException ("Invalid blob.", e); + } + + RSA rsa = null; + try { + rsa = RSA.Create (); + rsa.ImportParameters (rsap); + } + catch (CryptographicException ce) { + // this may cause problem when this code is run under + // the SYSTEM identity on Windows (e.g. ASP.NET). See + // http://bugzilla.ximian.com/show_bug.cgi?id=77559 + try { + CspParameters csp = new CspParameters (); + csp.Flags = CspProviderFlags.UseMachineKeyStore; + rsa = new RSACryptoServiceProvider (csp); + rsa.ImportParameters (rsap); + } + catch { + // rethrow original, not the later, exception if this fails + throw ce; + } + } + return rsa; + } + + static RSA FromCapiPublicKeyBlob (byte[] blob, int offset) + { + try { + if ((blob [offset] != 0x06) || // PUBLICKEYBLOB (0x06) + (blob [offset+1] != 0x02) || // Version (0x02) + (blob [offset+2] != 0x00) || // Reserved (word) + (blob [offset+3] != 0x00) || + (ToUInt32LE (blob, offset+8) != 0x31415352)) // DWORD magic = RSA1 + throw new CryptographicException ("Invalid blob header"); + + // ALGID (CALG_RSA_SIGN, CALG_RSA_KEYX, ...) + // int algId = ToInt32LE (blob, offset+4); + + // DWORD bitlen + int bitLen = ToInt32LE (blob, offset+12); + + // DWORD public exponent + RSAParameters rsap = new RSAParameters (); + rsap.Exponent = new byte [3]; + rsap.Exponent [0] = blob [offset+18]; + rsap.Exponent [1] = blob [offset+17]; + rsap.Exponent [2] = blob [offset+16]; + + int pos = offset+20; + // BYTE modulus[rsapubkey.bitlen/8]; + int byteLen = (bitLen >> 3); + rsap.Modulus = new byte [byteLen]; + Buffer.BlockCopy (blob, pos, rsap.Modulus, 0, byteLen); + Array.Reverse (rsap.Modulus); + + RSA rsa = null; + try { + rsa = RSA.Create (); + rsa.ImportParameters (rsap); + } + catch (CryptographicException) { + // this may cause problem when this code is run under + // the SYSTEM identity on Windows (e.g. ASP.NET). See + // http://bugzilla.ximian.com/show_bug.cgi?id=77559 + CspParameters csp = new CspParameters (); + csp.Flags = CspProviderFlags.UseMachineKeyStore; + rsa = new RSACryptoServiceProvider (csp); + rsa.ImportParameters (rsap); + } + return rsa; + } + catch (Exception e) { + throw new CryptographicException ("Invalid blob.", e); + } + } + + // PRIVATEKEYBLOB + // PUBLICKEYBLOB + static public RSA FromCapiKeyBlob (byte[] blob) + { + return FromCapiKeyBlob (blob, 0); + } + + static public RSA FromCapiKeyBlob (byte[] blob, int offset) + { + if (blob == null) + throw new ArgumentNullException ("blob"); + if (offset >= blob.Length) + throw new ArgumentException ("blob is too small."); + + switch (blob [offset]) { + case 0x00: + // this could be a public key inside an header + // like "sn -e" would produce + if (blob [offset + 12] == 0x06) { + return FromCapiPublicKeyBlob (blob, offset + 12); + } + break; + case 0x06: + return FromCapiPublicKeyBlob (blob, offset); + case 0x07: + return FromCapiPrivateKeyBlob (blob, offset); + } + throw new CryptographicException ("Unknown blob format."); + } + } +} + +#endif diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Security.Cryptography/CryptoService.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Security.Cryptography/CryptoService.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Security.Cryptography/CryptoService.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Security.Cryptography/CryptoService.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,177 @@ +// +// CryptoService.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.IO; +using System.Reflection; +using System.Security.Cryptography; + +#if !READ_ONLY + +#if !SILVERLIGHT && !CF +using System.Runtime.Serialization; +using Mono.Security.Cryptography; +#endif + +using Mono.Cecil.PE; + +namespace Mono.Cecil { + + // Most of this code has been adapted + // from Jeroen Frijters' fantastic work + // in IKVM.Reflection.Emit. Thanks! + + static class CryptoService { + +#if !SILVERLIGHT && !CF + public static void StrongName (Stream stream, ImageWriter writer, StrongNameKeyPair key_pair) + { + int strong_name_pointer; + + var strong_name = CreateStrongName (key_pair, HashStream (stream, writer, out strong_name_pointer)); + PatchStrongName (stream, strong_name_pointer, strong_name); + } + + static void PatchStrongName (Stream stream, int strong_name_pointer, byte [] strong_name) + { + stream.Seek (strong_name_pointer, SeekOrigin.Begin); + stream.Write (strong_name, 0, strong_name.Length); + } + + static byte [] CreateStrongName (StrongNameKeyPair key_pair, byte [] hash) + { + const string hash_algo = "SHA1"; + + using (var rsa = key_pair.CreateRSA ()) { + var formatter = new RSAPKCS1SignatureFormatter (rsa); + formatter.SetHashAlgorithm (hash_algo); + + byte [] signature = formatter.CreateSignature (hash); + Array.Reverse (signature); + + return signature; + } + } + + static byte [] HashStream (Stream stream, ImageWriter writer, out int strong_name_pointer) + { + const int buffer_size = 8192; + + var text = writer.text; + var header_size = (int) writer.GetHeaderSize (); + var text_section_pointer = (int) text.PointerToRawData; + var strong_name_directory = writer.GetStrongNameSignatureDirectory (); + + if (strong_name_directory.Size == 0) + throw new InvalidOperationException (); + + strong_name_pointer = (int) (text_section_pointer + + (strong_name_directory.VirtualAddress - text.VirtualAddress)); + var strong_name_length = (int) strong_name_directory.Size; + + var sha1 = new SHA1Managed (); + var buffer = new byte [buffer_size]; + using (var crypto_stream = new CryptoStream (Stream.Null, sha1, CryptoStreamMode.Write)) { + + stream.Seek (0, SeekOrigin.Begin); + CopyStreamChunk (stream, crypto_stream, buffer, header_size); + + stream.Seek (text_section_pointer, SeekOrigin.Begin); + CopyStreamChunk (stream, crypto_stream, buffer, (int) strong_name_pointer - text_section_pointer); + + stream.Seek (strong_name_length, SeekOrigin.Current); + CopyStreamChunk (stream, crypto_stream, buffer, (int) (stream.Length - (strong_name_pointer + strong_name_length))); + } + + return sha1.Hash; + } +#endif + static void CopyStreamChunk (Stream stream, Stream dest_stream, byte [] buffer, int length) + { + while (length > 0) { + int read = stream.Read (buffer, 0, System.Math.Min (buffer.Length, length)); + dest_stream.Write (buffer, 0, read); + length -= read; + } + } + + public static byte [] ComputeHash (string file) + { + if (!File.Exists (file)) + return Empty.Array; + + const int buffer_size = 8192; + + var sha1 = new SHA1Managed (); + + using (var stream = new FileStream (file, FileMode.Open, FileAccess.Read, FileShare.Read)) { + + var buffer = new byte [buffer_size]; + + using (var crypto_stream = new CryptoStream (Stream.Null, sha1, CryptoStreamMode.Write)) + CopyStreamChunk (stream, crypto_stream, buffer, (int) stream.Length); + } + + return sha1.Hash; + } + } + +#if !SILVERLIGHT && !CF + static partial class Mixin { + + public static RSA CreateRSA (this StrongNameKeyPair key_pair) + { + byte [] key; + string key_container; + + if (!TryGetKeyContainer (key_pair, out key, out key_container)) + return CryptoConvert.FromCapiKeyBlob (key); + + var parameters = new CspParameters { + Flags = CspProviderFlags.UseMachineKeyStore, + KeyContainerName = key_container, + KeyNumber = 2, + }; + + return new RSACryptoServiceProvider (parameters); + } + + static bool TryGetKeyContainer (ISerializable key_pair, out byte [] key, out string key_container) + { + var info = new SerializationInfo (typeof (StrongNameKeyPair), new FormatterConverter ()); + key_pair.GetObjectData (info, new StreamingContext ()); + + key = (byte []) info.GetValue ("_keyPairArray", typeof (byte [])); + key_container = info.GetString ("_keyPairContainer"); + return key_container != null; + } + } +#endif +} + +#endif diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/MiniParser.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/MiniParser.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/MiniParser.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/MiniParser.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,621 +0,0 @@ -// -// System.Security.Cryptography.MiniParser: Internal XML parser implementation -// -// Authors: -// Sergey Chaban -// -// Copyright (c) 2001, 2002 Wild West Software -// Copyright (c) 2002 Sergey Chaban -// Copyright (C) 2004 Novell, Inc (http://www.novell.com) -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using System.Text; -using System.Collections; -using System.Globalization; - -namespace Mono.Xml { - - internal class MiniParser { - - public interface IReader { - int Read(); - } - - public interface IAttrList { - int Length {get;} - bool IsEmpty {get;} - string GetName(int i); - string GetValue(int i); - string GetValue(string name); - void ChangeValue(string name, string newValue); - string[] Names {get;} - string[] Values {get;} - } - - public interface IMutableAttrList : IAttrList { - void Clear(); - void Add(string name, string value); - void CopyFrom(IAttrList attrs); - void Remove(int i); - void Remove(string name); - } - - public interface IHandler { - void OnStartParsing(MiniParser parser); - void OnStartElement(string name, IAttrList attrs); - void OnEndElement(string name); - void OnChars(string ch); - void OnEndParsing(MiniParser parser); - } - - public class HandlerAdapter : IHandler { - public HandlerAdapter() {} - public void OnStartParsing(MiniParser parser) {} - public void OnStartElement(string name, IAttrList attrs) {} - public void OnEndElement(string name) {} - public void OnChars(string ch) {} - public void OnEndParsing(MiniParser parser) {} - } - - private enum CharKind : byte { - LEFT_BR = 0, - RIGHT_BR = 1, - SLASH = 2, - PI_MARK = 3, - EQ = 4, - AMP = 5, - SQUOTE = 6, - DQUOTE = 7, - BANG = 8, - LEFT_SQBR = 9, - SPACE = 0xA, - RIGHT_SQBR = 0xB, - TAB = 0xC, - CR = 0xD, - EOL = 0xE, - CHARS = 0xF, - UNKNOWN = 0x1F - } - - private enum ActionCode : byte { - START_ELEM = 0, - END_ELEM = 1, - END_NAME = 2, - SET_ATTR_NAME = 3, - SET_ATTR_VAL = 4, - SEND_CHARS = 5, - START_CDATA = 6, - END_CDATA = 7, - ERROR = 8, - STATE_CHANGE = 9, - FLUSH_CHARS_STATE_CHANGE = 0xA, - ACC_CHARS_STATE_CHANGE = 0xB, - ACC_CDATA = 0xC, - PROC_CHAR_REF = 0xD, - UNKNOWN = 0xF - } - - public class AttrListImpl : IMutableAttrList { - protected ArrayList names; - protected ArrayList values; - - public AttrListImpl() : this(0) {} - - public AttrListImpl(int initialCapacity) { - if (initialCapacity <= 0) { - names = new ArrayList(); - values = new ArrayList(); - } else { - names = new ArrayList(initialCapacity); - values = new ArrayList(initialCapacity); - } - } - - public AttrListImpl(IAttrList attrs) - : this(attrs != null ? attrs.Length : 0) { - if (attrs != null) this.CopyFrom(attrs); - } - - public int Length { - get {return names.Count;} - } - - public bool IsEmpty { - get {return this.Length != 0;} - } - - public string GetName(int i) { - string res = null; - if (i >= 0 && i < this.Length) { - res = names[i] as string; - } - return res; - } - - public string GetValue(int i) { - string res = null; - if (i >= 0 && i < this.Length) { - res = values[i] as string; - } - return res; - } - - public string GetValue(string name) { - return this.GetValue(names.IndexOf(name)); - } - - public void ChangeValue(string name, string newValue) { - int i = names.IndexOf(name); - if (i >= 0 && i < this.Length) { - values[i] = newValue; - } - } - - public string[] Names { - get {return names.ToArray(typeof(string)) as string[];} - } - - public string[] Values { - get {return values.ToArray(typeof(string)) as string[];} - } - - public void Clear() { - names.Clear(); - values.Clear(); - } - - public void Add(string name, string value) { - names.Add(name); - values.Add(value); - } - - public void Remove(int i) { - if (i >= 0) { - names.RemoveAt(i); - values.RemoveAt(i); - } - } - - public void Remove(string name) { - this.Remove(names.IndexOf(name)); - } - - public void CopyFrom(IAttrList attrs) { - if (attrs != null && ((object)this == (object)attrs)) { - this.Clear(); - int n = attrs.Length; - for (int i = 0; i < n; i++) { - this.Add(attrs.GetName(i), attrs.GetValue(i)); - } - } - } - } - - public class XMLError : Exception { - protected string descr; - protected int line, column; - public XMLError() : this("Unknown") {} - public XMLError(string descr) : this(descr, -1, -1) {} - public XMLError(string descr, int line, int column) - : base(descr) { - this.descr = descr; - this.line = line; - this.column = column; - } - public int Line {get {return line;}} - public int Column {get {return column;}} - public override string ToString() { - return (String.Format("{0} @ (line = {1}, col = {2})", descr, line, column)); - } - } - - private static readonly int INPUT_RANGE = 13; - private static readonly ushort[] tbl = { - (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 1), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 0), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 128), - (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 2), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 133), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 16), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.FLUSH_CHARS_STATE_CHANGE << 8) | 4), - (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.END_ELEM << 8) | 0), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 2), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 2), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), - (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 5), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), - (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 4), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.END_NAME << 8) | 6), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.END_NAME << 8) | 7), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.END_NAME << 8) | 8), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), - (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 0), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), - (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 0), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ERROR << 8) | 129), - (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.FLUSH_CHARS_STATE_CHANGE << 8) | 1), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.PROC_CHAR_REF << 8) | 10), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 7), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), - (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 9), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.START_ELEM << 8) | 6), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.START_ELEM << 8) | 7), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 8), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), - (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 9), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.SET_ATTR_NAME << 8) | 11), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 12), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 130), - (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 13), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.PROC_CHAR_REF << 8) | 10), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), - (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 11), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ERROR << 8) | 132), - (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.SET_ATTR_NAME << 8) | 11), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 12), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ERROR << 8) | 130), - (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.SEND_CHARS << 8) | 2), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 16), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ERROR << 8) | 134), - (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.SET_ATTR_VAL << 8) | 17), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.PROC_CHAR_REF << 8) | 14), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), - (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.SET_ATTR_VAL << 8) | 17), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.PROC_CHAR_REF << 8) | 15), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), - (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.START_CDATA << 8) | 18), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 0), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), - (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.START_ELEM << 8) | 6), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.START_ELEM << 8) | 7), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 17), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 9), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), - (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.END_CDATA << 8) | 10), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), - (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), - (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.UNKNOWN << 8) | 255), - 0xFFFF - }; - - protected static string[] errors = { - /* 0 */ "Expected element", - /* 1 */ "Invalid character in tag", - /* 2 */ "No '='", - /* 3 */ "Invalid character entity", - /* 4 */ "Invalid attr value", - /* 5 */ "Empty tag", - /* 6 */ "No end tag", - /* 7 */ "Bad entity ref" - }; - - protected int line; - protected int col; - protected int[] twoCharBuff; - protected bool splitCData; - - public MiniParser() { - twoCharBuff = new int[2]; - splitCData = false; - Reset(); - } - - public void Reset() { - line = 0; - col = 0; - } - - protected static bool StrEquals(string str, StringBuilder sb, int sbStart, int len) { - if (len != str.Length) return false; - for (int i = 0; i < len; i++) { - if (str[i] != sb[sbStart + i]) return false; - } - return true; - } - - protected void FatalErr(string descr) { - throw new XMLError(descr, this.line, this.col); - } - - protected static int Xlat(int charCode, int state) { - int p = state * INPUT_RANGE; - int n = System.Math.Min(tbl.Length - p, INPUT_RANGE); - for (;--n >= 0;) { - ushort code = tbl[p]; - if (charCode == (code >> 12)) return (code & 0xFFF); - p++; - } - return 0xFFF; - } - - public void Parse(IReader reader, IHandler handler) { - if (reader == null) throw new ArgumentNullException("reader"); - if (handler == null) handler = new HandlerAdapter(); - - AttrListImpl attrList = new AttrListImpl(); - string lastAttrName = null; - Stack tagStack = new Stack(); - string elementName = null; - line = 1; - col = 0; - int currCh = 0; - int stateCode = 0; - StringBuilder sbChars = new StringBuilder(); - bool seenCData = false; - bool isComment = false; - bool isDTD = false; - int bracketSwitch = 0; - - handler.OnStartParsing(this); - - while (true) { - ++this.col; - - currCh = reader.Read(); - - if (currCh == -1) { - if (stateCode != 0) { - FatalErr("Unexpected EOF"); - } - break; - } - - int charCode = "<>/?=&'\"![ ]\t\r\n".IndexOf((char)currCh) & 0xF; - if (charCode == (int)CharKind.CR) continue; // ignore - // whitepace ::= (#x20 | #x9 | #xd | #xa)+ - if (charCode == (int)CharKind.TAB) charCode = (int)CharKind.SPACE; // tab == space - if (charCode == (int)CharKind.EOL) { - this.col = 0; - this.line++; - charCode = (int)CharKind.SPACE; - } - - int actionCode = MiniParser.Xlat(charCode, stateCode); - stateCode = actionCode & 0xFF; - // Ignore newline inside attribute value. - if (currCh == '\n' && (stateCode == 0xE || stateCode == 0xF)) continue; - actionCode >>= 8; - - if (stateCode >= 0x80) { - if (stateCode == 0xFF) { - FatalErr("State dispatch error."); - } else { - FatalErr(errors[stateCode ^ 0x80]); - } - } - - switch (actionCode) { - case (int)ActionCode.START_ELEM: - handler.OnStartElement(elementName, attrList); - if (currCh != '/') { - tagStack.Push(elementName); - } else { - handler.OnEndElement(elementName); - } - attrList.Clear(); - break; - - case (int)ActionCode.END_ELEM: - elementName = sbChars.ToString(); - sbChars = new StringBuilder(); - string endName = null; - if (tagStack.Count == 0 || - elementName != (endName = tagStack.Pop() as string)) { - if (endName == null) { - FatalErr("Tag stack underflow"); - } else { - FatalErr(String.Format("Expected end tag '{0}' but found '{1}'", elementName, endName)); - } - } - handler.OnEndElement(elementName); - break; - - case (int)ActionCode.END_NAME: - elementName = sbChars.ToString(); - sbChars = new StringBuilder(); - if (currCh != '/' && currCh != '>') break; - goto case (int)ActionCode.START_ELEM; - - case (int)ActionCode.SET_ATTR_NAME: - lastAttrName = sbChars.ToString(); - sbChars = new StringBuilder(); - break; - - case (int)ActionCode.SET_ATTR_VAL: - if (lastAttrName == null) FatalErr("Internal error."); - attrList.Add(lastAttrName, sbChars.ToString()); - sbChars = new StringBuilder(); - lastAttrName = null; - break; - - case (int)ActionCode.SEND_CHARS: - handler.OnChars(sbChars.ToString()); - sbChars = new StringBuilder(); - break; - - case (int)ActionCode.START_CDATA: - string cdata = "CDATA["; - isComment = false; - isDTD = false; - - if (currCh == '-') { - currCh = reader.Read(); - - if (currCh != '-') FatalErr("Invalid comment"); - - this.col++; - isComment = true; - twoCharBuff[0] = -1; - twoCharBuff[1] = -1; - } else { - if (currCh != '[') { - isDTD = true; - bracketSwitch = 0; - break; - } - - for (int i = 0; i < cdata.Length; i++) { - if (reader.Read() != cdata[i]) { - this.col += i+1; - break; - } - } - this.col += cdata.Length; - seenCData = true; - } - break; - - case (int)ActionCode.END_CDATA: - int n = 0; - currCh = ']'; - - while (currCh == ']') { - currCh = reader.Read(); - n++; - } - - if (currCh != '>') { - for (int i = 0; i < n; i++) sbChars.Append(']'); - sbChars.Append((char)currCh); - stateCode = 0x12; - } else { - for (int i = 0; i < n-2; i++) sbChars.Append(']'); - seenCData = false; - } - - this.col += n; - break; - - case (int)ActionCode.ERROR: - FatalErr(String.Format("Error {0}", stateCode)); - break; - - case (int)ActionCode.STATE_CHANGE: - break; - - case (int)ActionCode.FLUSH_CHARS_STATE_CHANGE: - sbChars = new StringBuilder(); - if (currCh != '<') goto case (int)ActionCode.ACC_CHARS_STATE_CHANGE; - break; - - case (int)ActionCode.ACC_CHARS_STATE_CHANGE: - sbChars.Append((char)currCh); - break; - - case (int)ActionCode.ACC_CDATA: - if (isComment) { - if (currCh == '>' - && twoCharBuff[0] == '-' - && twoCharBuff[1] == '-') { - isComment = false; - stateCode = 0; - } else { - twoCharBuff[0] = twoCharBuff[1]; - twoCharBuff[1] = currCh; - } - } else if (isDTD) { - if (currCh == '<' || currCh == '>') bracketSwitch ^= 1; - if (currCh == '>' && bracketSwitch != 0) { - isDTD = false; - stateCode = 0; - } - } else { - if (this.splitCData - && sbChars.Length > 0 - && seenCData) { - handler.OnChars(sbChars.ToString()); - sbChars = new StringBuilder(); - } - seenCData = false; - sbChars.Append((char)currCh); - } - break; - - case (int)ActionCode.PROC_CHAR_REF: - currCh = reader.Read(); - int cl = this.col + 1; - if (currCh == '#') { // character reference - int r = 10; - int chCode = 0; - int nDigits = 0; - currCh = reader.Read(); - cl++; - - if (currCh == 'x') { - currCh = reader.Read(); - cl++; - r=16; - } - - NumberStyles style = r == 16 ? NumberStyles.HexNumber : NumberStyles.Integer; - - while (true) { - int x = -1; - if (Char.IsNumber((char)currCh) || "abcdef".IndexOf(Char.ToLower((char)currCh)) != -1) { - try { - x = Int32.Parse(new string((char)currCh, 1), style); - } catch (FormatException) {x = -1;} - } - if (x == -1) break; - chCode *= r; - chCode += x; - nDigits++; - currCh = reader.Read(); - cl++; - } - - if (currCh == ';' && nDigits > 0) { - sbChars.Append((char)chCode); - } else { - FatalErr("Bad char ref"); - } - } else { - // entity reference - string entityRefChars = "aglmopqstu"; // amp | apos | quot | gt | lt - string entities = "&'\"><"; - - int pos = 0; - int entIdx = 0xF; - int predShift = 0; - - int sbLen = sbChars.Length; - - while (true) { - if (pos != 0xF) pos = entityRefChars.IndexOf((char)currCh) & 0xF; - if (pos == 0xF) FatalErr(errors[7]); - sbChars.Append((char)currCh); - - int path = "\uFF35\u3F8F\u4F8F\u0F5F\uFF78\uE1F4\u2299\uEEFF\uEEFF\uFF4F"[pos]; - int lBr = (path >> 4) & 0xF; - int rBr = path & 0xF; - int lPred = path >> 12; - int rPred = (path >> 8) & 0xF; - currCh = reader.Read(); - cl++; - pos = 0xF; - if (lBr != 0xF && currCh == entityRefChars[lBr]) { - if (lPred < 0xE) entIdx = lPred; -// pred = lPred; - predShift = 12; // left - } else if (rBr != 0xF && currCh == entityRefChars[rBr]) { - if (rPred < 0xE) entIdx = rPred; -// pred = rPred; - predShift = 8; // right - } else if (currCh == ';') { - if (entIdx != 0xF - && predShift != 0 - && ((path >> predShift) & 0xF) == 0xE) break; - continue; // pos == 0xF - } - - pos=0; - - } - - int l = cl - this.col - 1; - - if ((l > 0 && l < 5) - &&(StrEquals("amp", sbChars, sbLen, l) - || StrEquals("apos", sbChars, sbLen, l) - || StrEquals("quot", sbChars, sbLen, l) - || StrEquals("lt", sbChars, sbLen, l) - || StrEquals("gt", sbChars, sbLen, l)) - ) { - sbChars.Length = sbLen; - sbChars.Append(entities[entIdx]); - } else FatalErr(errors[7]); - } - - this.col = cl; - break; - - default: - FatalErr(String.Format("Unexpected action code - {0}.", actionCode)); - break; - } - } // while (true) - - handler.OnEndParsing(this); - - } // Parse - - } - -} diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/SecurityParser.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/SecurityParser.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/SecurityParser.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/SecurityParser.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +0,0 @@ -// -// Mono.Xml.SecurityParser.cs class implementation -// -// Author: -// Sebastien Pouliot (spouliot@motus.com) -// -// (C) 2003 Motus Technologies Inc. (http://www.motus.com) -// - -// -// Copyright (C) 2004 Novell, Inc (http://www.novell.com) -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using System.Collections; -using System.IO; -using System.Security; - -namespace Mono.Xml { - - // convert an XML document into SecurityElement objects - internal class SecurityParser : SmallXmlParser, SmallXmlParser.IContentHandler { - - private SecurityElement root; - - public SecurityParser () : base () - { - stack = new Stack (); - } - - public void LoadXml (string xml) - { - root = null; -#if CF_1_0 - stack = new Stack (); -#else - stack.Clear (); -#endif - Parse (new StringReader (xml), this); - } - - public SecurityElement ToXml () - { - return root; - } - - // IContentHandler - - private SecurityElement current; - private Stack stack; - - public void OnStartParsing (SmallXmlParser parser) {} - - public void OnProcessingInstruction (string name, string text) {} - - public void OnIgnorableWhitespace (string s) {} - - public void OnStartElement (string name, SmallXmlParser.IAttrList attrs) - { - SecurityElement newel = new SecurityElement (name); - if (root == null) { - root = newel; - current = newel; - } - else { - SecurityElement parent = (SecurityElement) stack.Peek (); - parent.AddChild (newel); - } - stack.Push (newel); - current = newel; - // attributes - int n = attrs.Length; - for (int i=0; i < n; i++) - current.AddAttribute (attrs.GetName (i), attrs.GetValue (i)); - } - - public void OnEndElement (string name) - { - current = (SecurityElement) stack.Pop (); - } - - public void OnChars (string ch) - { - current.Text = ch; - } - - public void OnEndParsing (SmallXmlParser parser) {} - } -} - diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/SmallXmlParser.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/SmallXmlParser.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/SmallXmlParser.cs 2008-11-06 19:52:05.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/SmallXmlParser.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,637 +0,0 @@ -// -// SmallXmlParser.cs -// -// Author: -// Atsushi Enomoto -// -// Copyright (C) 2005 Novell, Inc (http://www.novell.com) -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -// -// small xml parser that is mostly compatible with -// - -using System; -using System.Collections; -using System.Globalization; -using System.IO; -using System.Text; - -namespace Mono.Xml -{ - internal class DefaultHandler : SmallXmlParser.IContentHandler - { - public void OnStartParsing (SmallXmlParser parser) - { - } - - public void OnEndParsing (SmallXmlParser parser) - { - } - - public void OnStartElement (string name, SmallXmlParser.IAttrList attrs) - { - } - - public void OnEndElement (string name) - { - } - - public void OnChars (string s) - { - } - - public void OnIgnorableWhitespace (string s) - { - } - - public void OnProcessingInstruction (string name, string text) - { - } - } - - internal class SmallXmlParser - { - public interface IContentHandler - { - void OnStartParsing (SmallXmlParser parser); - void OnEndParsing (SmallXmlParser parser); - void OnStartElement (string name, IAttrList attrs); - void OnEndElement (string name); - void OnProcessingInstruction (string name, string text); - void OnChars (string text); - void OnIgnorableWhitespace (string text); - } - - public interface IAttrList - { - int Length { get; } - bool IsEmpty { get; } - string GetName (int i); - string GetValue (int i); - string GetValue (string name); - string [] Names { get; } - string [] Values { get; } - } - - class AttrListImpl : IAttrList - { - public int Length { - get { return attrNames.Count; } - } - public bool IsEmpty { - get { return attrNames.Count == 0; } - } - public string GetName (int i) - { - return (string) attrNames [i]; - } - public string GetValue (int i) - { - return (string) attrValues [i]; - } - public string GetValue (string name) - { - for (int i = 0; i < attrNames.Count; i++) - if ((string) attrNames [i] == name) - return (string) attrValues [i]; - return null; - } - public string [] Names { - get { return (string []) attrNames.ToArray (typeof (string)); } - } - public string [] Values { - get { return (string []) attrValues.ToArray (typeof (string)); } - } - - ArrayList attrNames = new ArrayList (); - ArrayList attrValues = new ArrayList (); - - internal void Clear () - { - attrNames.Clear (); - attrValues.Clear (); - } - - internal void Add (string name, string value) - { - attrNames.Add (name); - attrValues.Add (value); - } - } - - IContentHandler handler; - TextReader reader; - Stack elementNames = new Stack (); - Stack xmlSpaces = new Stack (); - string xmlSpace; - StringBuilder buffer = new StringBuilder (200); - char [] nameBuffer = new char [30]; - bool isWhitespace; - - AttrListImpl attributes = new AttrListImpl (); - int line = 1, column; - bool resetColumn; - - public SmallXmlParser () - { - } - - private Exception Error (string msg) - { - return new SmallXmlParserException (msg, line, column); - } - - private Exception UnexpectedEndError () - { - string [] arr = new string [elementNames.Count]; - // COMPACT FRAMEWORK NOTE: CopyTo is not visible through the Stack class - (elementNames as ICollection).CopyTo (arr, 0); - return Error (String.Format ( - "Unexpected end of stream. Element stack content is {0}", String.Join (",", arr))); - } - - - private bool IsNameChar (char c, bool start) - { - switch (c) { - case ':': - case '_': - return true; - case '-': - case '.': - return !start; - } - if (c > 0x100) { // optional condition for optimization - switch (c) { - case '\u0559': - case '\u06E5': - case '\u06E6': - return true; - } - if ('\u02BB' <= c && c <= '\u02C1') - return true; - } - switch (Char.GetUnicodeCategory (c)) { - case UnicodeCategory.LowercaseLetter: - case UnicodeCategory.UppercaseLetter: - case UnicodeCategory.OtherLetter: - case UnicodeCategory.TitlecaseLetter: - case UnicodeCategory.LetterNumber: - return true; - case UnicodeCategory.SpacingCombiningMark: - case UnicodeCategory.EnclosingMark: - case UnicodeCategory.NonSpacingMark: - case UnicodeCategory.ModifierLetter: - case UnicodeCategory.DecimalDigitNumber: - return !start; - default: - return false; - } - } - - private bool IsWhitespace (int c) - { - switch (c) { - case ' ': - case '\r': - case '\t': - case '\n': - return true; - default: - return false; - } - } - - - public void SkipWhitespaces () - { - SkipWhitespaces (false); - } - - private void HandleWhitespaces () - { - while (IsWhitespace (Peek ())) - buffer.Append ((char) Read ()); - if (Peek () != '<' && Peek () >= 0) - isWhitespace = false; - } - - public void SkipWhitespaces (bool expected) - { - while (true) { - switch (Peek ()) { - case ' ': - case '\r': - case '\t': - case '\n': - Read (); - if (expected) - expected = false; - continue; - } - if (expected) - throw Error ("Whitespace is expected."); - return; - } - } - - - private int Peek () - { - return reader.Peek (); - } - - private int Read () - { - int i = reader.Read (); - if (i == '\n') - resetColumn = true; - if (resetColumn) { - line++; - resetColumn = false; - column = 1; - } - else - column++; - return i; - } - - public void Expect (int c) - { - int p = Read (); - if (p < 0) - throw UnexpectedEndError (); - else if (p != c) - throw Error (String.Format ("Expected '{0}' but got {1}", (char) c, (char) p)); - } - - private string ReadUntil (char until, bool handleReferences) - { - while (true) { - if (Peek () < 0) - throw UnexpectedEndError (); - char c = (char) Read (); - if (c == until) - break; - else if (handleReferences && c == '&') - ReadReference (); - else - buffer.Append (c); - } - string ret = buffer.ToString (); - buffer.Length = 0; - return ret; - } - - public string ReadName () - { - int idx = 0; - if (Peek () < 0 || !IsNameChar ((char) Peek (), true)) - throw Error ("XML name start character is expected."); - for (int i = Peek (); i >= 0; i = Peek ()) { - char c = (char) i; - if (!IsNameChar (c, false)) - break; - if (idx == nameBuffer.Length) { - char [] tmp = new char [idx * 2]; - // COMPACT FRAMEWORK NOTE: Array.Copy(sourceArray, destinationArray, count) is not available. - Array.Copy (nameBuffer, 0, tmp, 0, idx); - nameBuffer = tmp; - } - nameBuffer [idx++] = c; - Read (); - } - if (idx == 0) - throw Error ("Valid XML name is expected."); - return new string (nameBuffer, 0, idx); - } - - - public void Parse (TextReader input, IContentHandler handler) - { - this.reader = input; - this.handler = handler; - - handler.OnStartParsing (this); - - while (Peek () >= 0) - ReadContent (); - HandleBufferedContent (); - if (elementNames.Count > 0) - throw Error (String.Format ("Insufficient close tag: {0}", elementNames.Peek ())); - - handler.OnEndParsing (this); - - Cleanup (); - } - - private void Cleanup () - { - line = 1; - column = 0; - handler = null; - reader = null; -#if CF_1_0 - elementNames = new Stack (); - xmlSpaces = new Stack (); -#else - elementNames.Clear (); - xmlSpaces.Clear (); -#endif - attributes.Clear (); - buffer.Length = 0; - xmlSpace = null; - isWhitespace = false; - } - - public void ReadContent () - { - string name; - if (IsWhitespace (Peek ())) { - if (buffer.Length == 0) - isWhitespace = true; - HandleWhitespaces (); - } - if (Peek () == '<') { - Read (); - switch (Peek ()) { - case '!': // declarations - Read (); - if (Peek () == '[') { - Read (); - if (ReadName () != "CDATA") - throw Error ("Invalid declaration markup"); - Expect ('['); - ReadCDATASection (); - return; - } - else if (Peek () == '-') { - ReadComment (); - return; - } - else if (ReadName () != "DOCTYPE") - throw Error ("Invalid declaration markup."); - else - throw Error ("This parser does not support document type."); - case '?': // PIs - HandleBufferedContent (); - Read (); - name = ReadName (); - SkipWhitespaces (); - string text = String.Empty; - if (Peek () != '?') { - while (true) { - text += ReadUntil ('?', false); - if (Peek () == '>') - break; - text += "?"; - } - } - handler.OnProcessingInstruction ( - name, text); - Expect ('>'); - return; - case '/': // end tags - HandleBufferedContent (); - if (elementNames.Count == 0) - throw UnexpectedEndError (); - Read (); - name = ReadName (); - SkipWhitespaces (); - string expected = (string) elementNames.Pop (); - xmlSpaces.Pop (); - if (xmlSpaces.Count > 0) - xmlSpace = (string) xmlSpaces.Peek (); - else - xmlSpace = null; - if (name != expected) - throw Error (String.Format ("End tag mismatch: expected {0} but found {1}", expected, name)); - handler.OnEndElement (name); - Expect ('>'); - return; - default: // start tags (including empty tags) - HandleBufferedContent (); - name = ReadName (); - while (Peek () != '>' && Peek () != '/') - ReadAttribute (attributes); - handler.OnStartElement (name, attributes); - attributes.Clear (); - SkipWhitespaces (); - if (Peek () == '/') { - Read (); - handler.OnEndElement (name); - } - else { - elementNames.Push (name); - xmlSpaces.Push (xmlSpace); - } - Expect ('>'); - return; - } - } - else - ReadCharacters (); - } - - private void HandleBufferedContent () - { - if (buffer.Length == 0) - return; - if (isWhitespace) - handler.OnIgnorableWhitespace (buffer.ToString ()); - else - handler.OnChars (buffer.ToString ()); - buffer.Length = 0; - isWhitespace = false; - } - - private void ReadCharacters () - { - isWhitespace = false; - while (true) { - int i = Peek (); - switch (i) { - case -1: - return; - case '<': - return; - case '&': - Read (); - ReadReference (); - continue; - default: - buffer.Append ((char) Read ()); - continue; - } - } - } - - private void ReadReference () - { - if (Peek () == '#') { - // character reference - Read (); - ReadCharacterReference (); - } else { - string name = ReadName (); - Expect (';'); - switch (name) { - case "amp": - buffer.Append ('&'); - break; - case "quot": - buffer.Append ('"'); - break; - case "apos": - buffer.Append ('\''); - break; - case "lt": - buffer.Append ('<'); - break; - case "gt": - buffer.Append ('>'); - break; - default: - throw Error ("General non-predefined entity reference is not supported in this parser."); - } - } - } - - private int ReadCharacterReference () - { - int n = 0; - if (Peek () == 'x') { // hex - Read (); - for (int i = Peek (); i >= 0; i = Peek ()) { - if ('0' <= i && i <= '9') - n = n << 4 + i - '0'; - else if ('A' <= i && i <='F') - n = n << 4 + i - 'A' + 10; - else if ('a' <= i && i <='f') - n = n << 4 + i - 'a' + 10; - else - break; - Read (); - } - } else { - for (int i = Peek (); i >= 0; i = Peek ()) { - if ('0' <= i && i <= '9') - n = n << 4 + i - '0'; - else - break; - Read (); - } - } - return n; - } - - private void ReadAttribute (AttrListImpl a) - { - SkipWhitespaces (true); - if (Peek () == '/' || Peek () == '>') - // came here just to spend trailing whitespaces - return; - - string name = ReadName (); - string value; - SkipWhitespaces (); - Expect ('='); - SkipWhitespaces (); - switch (Read ()) { - case '\'': - value = ReadUntil ('\'', true); - break; - case '"': - value = ReadUntil ('"', true); - break; - default: - throw Error ("Invalid attribute value markup."); - } - if (name == "xml:space") - xmlSpace = value; - a.Add (name, value); - } - - private void ReadCDATASection () - { - int nBracket = 0; - while (true) { - if (Peek () < 0) - throw UnexpectedEndError (); - char c = (char) Read (); - if (c == ']') - nBracket++; - else if (c == '>' && nBracket > 1) { - for (int i = nBracket; i > 2; i--) - buffer.Append (']'); - break; - } - else { - for (int i = 0; i < nBracket; i++) - buffer.Append (']'); - nBracket = 0; - buffer.Append (c); - } - } - } - - private void ReadComment () - { - Expect ('-'); - Expect ('-'); - while (true) { - if (Read () != '-') - continue; - if (Read () != '-') - continue; - if (Read () != '>') - throw Error ("'--' is not allowed inside comment markup."); - break; - } - } - } - - internal class SmallXmlParserException : SystemException - { - int line; - int column; - - public SmallXmlParserException (string msg, int line, int column) - : base (String.Format ("{0}. At ({1},{2})", msg, line, column)) - { - this.line = line; - this.column = column; - } - - public int Line { - get { return line; } - } - - public int Column { - get { return column; } - } - } -} - - - diff -Nru mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/System.Runtime.CompilerServices/ExtensionAttribute.cs mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/System.Runtime.CompilerServices/ExtensionAttribute.cs --- mono-addins-0.4/Mono.Addins.CecilReflector/Mono.Cecil/System.Runtime.CompilerServices/ExtensionAttribute.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.CecilReflector/Mono.Cecil/System.Runtime.CompilerServices/ExtensionAttribute.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,40 @@ +// +// ExtensionAttribute.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2010 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; + +#if !NET_3_5 && !NET_4_0 + +namespace System.Runtime.CompilerServices { + + [AttributeUsage (AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly)] + sealed class ExtensionAttribute : Attribute { + } +} + +#endif diff -Nru mono-addins-0.4/Mono.Addins.Gui/AssemblyInfo.cs mono-addins-0.6.1/Mono.Addins.Gui/AssemblyInfo.cs --- mono-addins-0.4/Mono.Addins.Gui/AssemblyInfo.cs 2008-11-06 19:51:59.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/AssemblyInfo.cs 2011-04-13 09:00:29.000000000 +0000 @@ -17,4 +17,4 @@ // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly: AssemblyVersion("0.4.0.0")] +[assembly: AssemblyVersion("0.6.0.0")] diff -Nru mono-addins-0.4/Mono.Addins.Gui/ChangeLog mono-addins-0.6.1/Mono.Addins.Gui/ChangeLog --- mono-addins-0.4/Mono.Addins.Gui/ChangeLog 2008-11-06 19:51:59.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/ChangeLog 2011-04-13 09:00:29.000000000 +0000 @@ -1,3 +1,82 @@ +2010-05-25 Lluis Sanchez Gual + + * Mono.Addins.Gui.csproj: Add Debug and Release + configurations. + +2010-03-30 Lluis Sanchez Gual + + * Mono.Addins.Gui.csproj: csc doesn't like iso-2. + +2010-03-29 Lluis Sanchez Gual + + * Mono.Addins.Gui.csproj: Make sure the solution builds on + MS.NET 2.0. + +2010-03-26 Lluis Sanchez Gual + + * gtk-gui/generated.cs: + * Mono.Addins.Gui.csproj: + * gtk-gui/Mono.Addins.Gui.ErrorDialog.cs: + * gtk-gui/Mono.Addins.Gui.NewSiteDialog.cs: + * gtk-gui/Mono.Addins.Gui.ProgressDialog.cs: + * gtk-gui/Mono.Addins.Gui.AddinInfoDialog.cs: + * gtk-gui/Mono.Addins.Gui.ManageSitesDialog.cs: + * gtk-gui/Mono.Addins.Gui.AddinInstallDialog.cs: + * gtk-gui/Mono.Addins.Gui.AddinManagerDialog.cs: + * gtk-gui/Mono.Addins.Gui.AddinInstallerDialog.cs: Flush. + +2009-09-01 Lluis Sanchez Gual + + * AssemblyInfo.cs: Bump Mono.Addins version. + +2009-08-20 Lluis Sanchez Gual + + * Makefile.am: Build using gmcs. + +2009-08-19 Lluis Sanchez Gual + + * gtk-gui/gui.stetic: + * gtk-gui/Mono.Addins.Gui.ProgressDialog.cs: + * gtk-gui/Mono.Addins.Gui.AddinInstallerDialog.cs: Flush. + + * Mono.Addins.Gui.csproj: Update target framework to 2.0. + +2009-05-28 Lluis Sanchez Gual + + * Mono.Addins.Gui.csproj: Properly sign assemblies. + +2009-05-27 Lluis Sanchez Gual + + * Mono.Addins.Gui/ProgressDialog.cs: The error dialog must run + in the gui thread. + +2009-02-06 Lluis Sanchez Gual + + * Mono.Addins.Gui.csproj: Updated. + +2009-02-06 Lluis Sanchez Gual + + * gtk-gui/gui.stetic: + * gtk-gui/generated.cs: + * gtk-gui/Mono.Addins.Gui.ErrorDialog.cs: + * gtk-gui/Mono.Addins.Gui.NewSiteDialog.cs: + * gtk-gui/Mono.Addins.Gui.ProgressDialog.cs: + * gtk-gui/Mono.Addins.Gui.AddinInfoDialog.cs: + * gtk-gui/Mono.Addins.Gui.ManageSitesDialog.cs: + * gtk-gui/Mono.Addins.Gui.AddinManagerDialog.cs: + * gtk-gui/Mono.Addins.Gui.AddinInstallDialog.cs: + * gtk-gui/Mono.Addins.Gui.AddinInstallerDialog.cs: Flush. + +2008-11-10 Lluis Sanchez Gual + + * mono-addins-gui.pc.in: Respect custom libdir during ./configure. Fixes + bug #443205. Patch by Diego Pettenò. + +2008-11-10 Lluis Sanchez Gual + + * Makefile.am: Fix building with parallel make jobs (-j8). Fixes bug + #443206. Patch by Diego Pettenò. + 2008-08-22 Lluis Sanchez Gual * Mono.Addins.Gui.csproj, Mono.Addins.Gui.mdp: Use msbuild file format diff -Nru mono-addins-0.4/Mono.Addins.Gui/gtk-gui/generated.cs mono-addins-0.6.1/Mono.Addins.Gui/gtk-gui/generated.cs --- mono-addins-0.4/Mono.Addins.Gui/gtk-gui/generated.cs 2008-11-06 19:51:59.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/gtk-gui/generated.cs 2011-04-13 09:00:29.000000000 +0000 @@ -1,68 +1,115 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Mono Runtime Version: 2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -namespace Stetic { - - - internal class Gui { - - private static bool initialized; - - internal static void Initialize(Gtk.Widget iconRenderer) { - if ((Stetic.Gui.initialized == false)) { - Stetic.Gui.initialized = true; - } - } - } - - internal class IconLoader { - - public static Gdk.Pixbuf LoadIcon(Gtk.Widget widget, string name, Gtk.IconSize size, int sz) { - Gdk.Pixbuf res = widget.RenderIcon(name, size, null); - if ((res != null)) { - return res; - } - else { - try { - return Gtk.IconTheme.Default.LoadIcon(name, sz, 0); - } - catch (System.Exception ) { - if ((name != "gtk-missing-image")) { - return Stetic.IconLoader.LoadIcon(widget, "gtk-missing-image", size, sz); - } - else { - Gdk.Pixmap pmap = new Gdk.Pixmap(Gdk.Screen.Default.RootWindow, sz, sz); - Gdk.GC gc = new Gdk.GC(pmap); - gc.RgbFgColor = new Gdk.Color(255, 255, 255); - pmap.DrawRectangle(gc, true, 0, 0, sz, sz); - gc.RgbFgColor = new Gdk.Color(0, 0, 0); - pmap.DrawRectangle(gc, false, 0, 0, (sz - 1), (sz - 1)); - gc.SetLineAttributes(3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round); - gc.RgbFgColor = new Gdk.Color(255, 0, 0); - pmap.DrawLine(gc, (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)), ((sz - 1) - (sz / 4))); - pmap.DrawLine(gc, ((sz - 1) - (sz / 4)), (sz / 4), (sz / 4), ((sz - 1) - (sz / 4))); - return Gdk.Pixbuf.FromDrawable(pmap, pmap.Colormap, 0, 0, 0, 0, sz, sz); - } - } - } - } - } - - internal class ActionGroups { - - public static Gtk.ActionGroup GetActionGroup(System.Type type) { - return Stetic.ActionGroups.GetActionGroup(type.FullName); - } - - public static Gtk.ActionGroup GetActionGroup(string name) { - return null; - } - } + +// This file has been generated by the GUI designer. Do not modify. +namespace Stetic +{ + internal class Gui + { + private static bool initialized; + + internal static void Initialize (Gtk.Widget iconRenderer) + { + if ((Stetic.Gui.initialized == false)) { + Stetic.Gui.initialized = true; + } + } + } + + internal class IconLoader + { + public static Gdk.Pixbuf LoadIcon (Gtk.Widget widget, string name, Gtk.IconSize size) + { + Gdk.Pixbuf res = widget.RenderIcon (name, size, null); + if ((res != null)) { + return res; + } else { + int sz; + int sy; + global::Gtk.Icon.SizeLookup (size, out sz, out sy); + try { + return Gtk.IconTheme.Default.LoadIcon (name, sz, 0); + } catch (System.Exception) { + if ((name != "gtk-missing-image")) { + return Stetic.IconLoader.LoadIcon (widget, "gtk-missing-image", size); + } else { + Gdk.Pixmap pmap = new Gdk.Pixmap (Gdk.Screen.Default.RootWindow, sz, sz); + Gdk.GC gc = new Gdk.GC (pmap); + gc.RgbFgColor = new Gdk.Color (255, 255, 255); + pmap.DrawRectangle (gc, true, 0, 0, sz, sz); + gc.RgbFgColor = new Gdk.Color (0, 0, 0); + pmap.DrawRectangle (gc, false, 0, 0, (sz - 1), (sz - 1)); + gc.SetLineAttributes (3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round); + gc.RgbFgColor = new Gdk.Color (255, 0, 0); + pmap.DrawLine (gc, (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)), ((sz - 1) - (sz / 4))); + pmap.DrawLine (gc, ((sz - 1) - (sz / 4)), (sz / 4), (sz / 4), ((sz - 1) - (sz / 4))); + return Gdk.Pixbuf.FromDrawable (pmap, pmap.Colormap, 0, 0, 0, 0, sz, sz); + } + } + } + } + } + + internal class BinContainer + { + private Gtk.Widget child; + private Gtk.UIManager uimanager; + + public static BinContainer Attach (Gtk.Bin bin) + { + BinContainer bc = new BinContainer (); + bin.SizeRequested += new Gtk.SizeRequestedHandler (bc.OnSizeRequested); + bin.SizeAllocated += new Gtk.SizeAllocatedHandler (bc.OnSizeAllocated); + bin.Added += new Gtk.AddedHandler (bc.OnAdded); + return bc; + } + + private void OnSizeRequested (object sender, Gtk.SizeRequestedArgs args) + { + if ((this.child != null)) { + args.Requisition = this.child.SizeRequest (); + } + } + + private void OnSizeAllocated (object sender, Gtk.SizeAllocatedArgs args) + { + if ((this.child != null)) { + this.child.Allocation = args.Allocation; + } + } + + private void OnAdded (object sender, Gtk.AddedArgs args) + { + this.child = args.Widget; + } + + public void SetUiManager (Gtk.UIManager uim) + { + this.uimanager = uim; + this.child.Realized += new System.EventHandler (this.OnRealized); + } + + private void OnRealized (object sender, System.EventArgs args) + { + if ((this.uimanager != null)) { + Gtk.Widget w; + w = this.child.Toplevel; + if (((w != null) && typeof(Gtk.Window).IsInstanceOfType (w))) { + ((Gtk.Window)(w)).AddAccelGroup (this.uimanager.AccelGroup); + this.uimanager = null; + } + } + } + } + + internal class ActionGroups + { + public static Gtk.ActionGroup GetActionGroup (System.Type type) + { + return Stetic.ActionGroups.GetActionGroup (type.FullName); + } + + public static Gtk.ActionGroup GetActionGroup (string name) + { + return null; + } + } } diff -Nru mono-addins-0.4/Mono.Addins.Gui/gtk-gui/gui.stetic mono-addins-0.6.1/Mono.Addins.Gui/gtk-gui/gui.stetic --- mono-addins-0.4/Mono.Addins.Gui/gtk-gui/gui.stetic 2008-11-06 19:51:59.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/gtk-gui/gui.stetic 2011-04-13 09:00:29.000000000 +0000 @@ -2,8 +2,11 @@ .. - 2.8.3 + 2.12 + + + False @@ -135,19 +138,24 @@ -5 gtk-ok + + False + False + - + + False False Add-in Manager Dialog 6 700 550 - 1 + 2 False @@ -160,69 +168,6 @@ 6 6 - - - 12 - - - - 0 - resource:system-software-update.png - - - 0 - False - False - False - - - - - - <big><b>Add-in Manager</b></big> - True - - - 1 - False - False - False - - - - - 0 - False - False - False - - - - - - 12 - - - - 0 - The following add-ins are currently installed: - - - 0 - False - False - False - - - - - 1 - False - False - False - - - 12 @@ -231,146 +176,340 @@ 12 - + True - In + 0 + False - + - True - True - + 9 + 9 + + + + 6 + + + + True + In + + + + True + + + + + 0 + True + + + + + 0 + True + + + + + + + + + ButtonPressMask + False + + + + + + + + + 1 + True + False + False + + - - - 0 - False - - - - - - 5 - + - True - TextAndIcon - stock:gtk-add Button - _Install Add-ins... - True - + Installed - 0 - False - False - False + tab - + - True - TextOnly - _Repositories... - True - + 9 + 9 + + + + + + + + + + 6 + + + + No updates found + + + 0 + False + False + False + + + + + + True + TextAndIcon + stock:gtk-refresh Menu + Refresh + True + None + + + + End + 1 + False + False + False + + + + + + True + TextAndIcon + resource:download.png + Update All + True + None + + + + End + 2 + True + False + False + + + + + + + 0 + True + False + False + + + + + + True + In + + + + True + + + + + 1 + True + + + + + 0 + False + + + + + + + + + ButtonPressMask + False + + + + + + + + + 1 + True + False + False + + 1 - False - False - False - - - - - - - - 2 - False - False - False - - - - - - True - TextAndIcon - stock:gtk-remove Button - _Uninstall... - True - - - - 3 - False - False - False - + - True - TextAndIcon - stock:gtk-yes Button - Enable - True - + Updates - 4 - False - False - False + tab - + - True - TextAndIcon - stock:gtk-no Button - Disable - True - + 9 + 9 + + + + + + + + + + 6 + + + + Repository: + + + 0 + False + False + False + + + + + + False + + + + + 1 + False + + + + + + True + TextAndIcon + stock:gtk-refresh Menu + + True + None + + + + 2 + False + False + False + + + + + + + 0 + True + False + False + + + + + + True + In + + + + True + + + + + 1 + True + + + + + 0 + False + + + + + + + + + ButtonPressMask + False + + + + + + + + + 1 + True + False + False + + - 5 - False - False - False + 2 - + - True - True - StockItem - gtk-dialog-info - - gtk-dialog-info + Gallery - 6 - False - False - False + tab - 1 - False - False - False + 0 + True @@ -381,7 +520,7 @@ - 2 + 0 False @@ -398,8 +537,23 @@ 6 5 - 1 - End + 2 + Edge + + + + True + TextOnly + Install from file... + True + -1 + + + + False + False + + @@ -411,43 +565,66 @@ -7 gtk-close + + 1 + False + False + - + + False False - Add-in Installation + Add-in Repository Management Dialog - True 6 - 725 - 550 - 0 + 600 + 300 + 1 False - + 6 - 2 - + - True - 0 - False + 12 6 - + - 12 + True + In - + - 0 - <b>Select the add-ins to install and click on Next</b> - True + True + False + + + + + 0 + False + + + + + + 6 + + + + True + True + StockItem + gtk-add + + gtk-add 0 @@ -457,624 +634,7 @@ - - - 6 - - - - Install from: - - - 0 - False - False - False - - - - - - False - - - - - 1 - False - - - - - - True - True - StockItem - gtk-refresh - - gtk-refresh - - - 2 - False - False - False - - - - - - True - TextOnly - _Repositories... - True - - - - 3 - False - False - False - - - - - 1 - False - False - False - - - - - - 12 - - - - 6 - - - - True - In - - - - True - True - - - - - - 0 - False - - - - - - 6 - - - - True - Show all packages -Show new versions only -Show updates only - - - - 0 - False - False - False - - - - - - True - True - StockItem - gtk-dialog-info - - gtk-dialog-info - - - End - 1 - False - False - False - - - - - - True - TextOnly - _Unselect All - True - - - - End - 2 - False - False - False - - - - - - True - TextOnly - Select _All - True - - - - End - 3 - False - False - False - - - - - 1 - False - False - False - - - - - 0 - False - - - - - 2 - False - - - - - - - - label108 - - - tab - - - - - - True - - - - - - - 12 - 12 - - - - 0 - 0 - stock:gtk-dialog-warning Dialog - - - 0 - False - False - False - - - - - - 6 - 6 - 0 - 0 - <b>The following add-ins will be installed:</b> - -C# language binding -C# language IDE extension - -<b>The following add-ins are required by the selected add-ins</b> - -NUnit add-in -NAnt add-in - -asd -asd -a -sd -asd -asd -a -sda -sd -as -da -sd -asd - - True - True - - - 1 - False - False - False - - - - - - - - - 1 - - - - - - label124 - - - tab - - - - - - 6 - 61 - - - - - - - 0 - False - - - - - - 0 - Overall Progress: - End - - - 1 - False - False - False - - - - - - 10000000149 - - - 2 - False - False - False - - - - - - - - - 3 - False - - - - - 2 - - - - - - label110 - - - tab - - - - - - True - - - - - - - - - - - - - 0 - False - - - - - - 1 - stock:gtk-dialog-error Dialog - - - 1 - False - False - False - 5 - - - - - - 1 - stock:gtk-dialog-warning Dialog - - - 2 - True - False - False - - - - - - 1 - stock:gtk-dialog-info Dialog - - - 3 - False - False - False - - - - - - - - - 450 - 9 - 0 - Done - True - True - Center - - - End - 0 - False - - - - - 4 - False - False - False - - - - - - - - - 5 - False - - - - - - - - - 3 - - - - - - label111 - - - tab - - - - - 0 - False - - - - - - 9 - 6 - 4 - End - - - - True - True - True - StockItem - gtk-cancel - - gtk-cancel - - - - - - True - True - True - StockItem - gtk-go-back - - gtk-go-back - - - 1 - - - - - - True - True - True - StockItem - gtk-go-forward - - gtk-go-forward - - - 2 - - - - - - False - True - True - True - StockItem - gtk-ok - - gtk-ok - - - 3 - - - - - End - 2 - False - False - False - - - - - - - - False - 6 - 5 - 0 - End - - - - - - False - Add-in Repository Management - Dialog - 6 - 600 - 300 - 1 - False - - - - 6 - - - - 12 - 6 - - - - True - In - - - - True - False - True - - - - - 0 - False - - - - - - 6 - - - - True - True - StockItem - gtk-add - - gtk-add - - - 0 - False - False - False - - - - + True True @@ -1124,12 +684,17 @@ -7 gtk-close + + False + False + + False False Add New Repository Dialog @@ -1187,7 +752,6 @@ 32 - 0 @@ -1241,84 +805,218 @@ - 3 - False + 3 + False + False + False + + + + + + 6 + + + + 32 + + + 0 + False + False + False + + + + + + Path: + + + 1 + False + False + False + + + + + + 6 + + + + True + True + + + + + 0 + True + + + + + + True + TextOnly + Browse... + True + + + + 1 + True + False + False + + + + + 2 + True + + + + + 4 + False + False + False + + + + + 0 + False + + + + + + + + 10 + 5 + 2 + End + + + + True + True + True + StockItem + gtk-cancel + -6 + gtk-cancel + + + False + False + + + + + + True + True + True + StockItem + gtk-ok + -5 + gtk-ok + + + 1 + False + False + + + + + + + + False + Add-in Manager + CenterOnParent + 6 + 2 + False + + + + 6 + 2 + + + + 6 + 6 + + + + 0 + Additional extensions are required to perform this operation. + + + 0 + True + False + False + + + + + + 0 + The following add-ins will be installed: + + + 1 + True False False - + - 6 - - - - 32 - - - - 0 - False - False - False - - - - - - Path: - - - 1 - False - False - False - - + True + In - + - 6 - - - - True - True - - - - - 0 - True - - + None - + - True - TextOnly - Browse... - True - + 6 + 6 + 0 + 0 + label3 - - 1 - True - False - False - - - 2 - True - - 4 - False + 2 + True + + + + + + False + + + + 3 + True False False @@ -1326,20 +1024,20 @@ 0 - False + True - + 10 - 5 + 6 2 End - + True True @@ -1349,164 +1047,202 @@ -6 gtk-cancel + + False + False + - + True True True StockItem gtk-ok - -5 + -1 + gtk-ok 1 + False + False - + + False False - Package - Dialog - 6 - 550 - 400 + Progress + CenterOnParent + True 1 False - + - 6 + 2 - + - 12 - 6 + 6 + 9 - + - - - - - - 0 - False - False - False - - - - - + 0 0 - False + True + False + False + + + + + + + + 1 + True False False - + True - + - None + In - + - 420 - 6 - 6 - 0 - 0 - aa a a a a a a a a aa a a a a aaa a a a a a a a a aa a a a a aaa a a a a a a a a aa a a a a a - True + True + True + + + + + Details + True + + + label_item + + - 1 - False + 2 + True 0 - False + True - + - 10 - 6 + 6 + 5 1 End - + True True True StockItem - gtk-close - -7 - gtk-close + gtk-cancel + -6 + + gtk-cancel + + False + False + - + + False False - Add-in Manager CenterOnParent - 6 2 False - False - 6 2 - + - 6 - 6 + 9 + 9 - + - 0 - Additional extensions are required to perform this operation. + True + Never + Never + + + + None + + + + 6 + + + + 400 + 0 + 0 + label3 + True + + + 0 + True + False + False + + + + + + 0 True - False - False - + - 0 - The following add-ins will be installed: + False 1 @@ -1516,41 +1252,37 @@ - + - True - In + 6 + + + + 0 + End + + + 0 + True + False + False + + - + - None - - - - 6 - 6 - 0 - 0 - label3 - - + + 1 + True + False + False + 2 True - - - - - - False - - - - 3 - True False False @@ -1567,7 +1299,7 @@ 10 - 6 + 5 2 End @@ -1578,7 +1310,8 @@ True StockItem gtk-cancel - -6 + -1 + gtk-cancel @@ -1591,12 +1324,11 @@ True True - True - StockItem - gtk-ok + TextOnly + Install + True -1 - gtk-ok 1 @@ -1607,29 +1339,52 @@ - + + False False - Progress - CenterOnParent - True - 1 - False - False - - + + - 2 - + - 6 - 9 - + - 0 - + + + + 6 + + + + stock:gtk-dialog-warning Menu + + + 0 + True + False + False + + + + + + 250 + 0 + label1 + True + + + 1 + True + False + False + + + + 0 @@ -1639,81 +1394,251 @@ - + + 6 + 12 + + + + 6 + + + + 6 + + + + 3 + + + + 280 + 0 + <b><big>Some Addin</big></b> + True + True + + + 0 + False + False + False + + + + + + 280 + 0 + Version 2.6 + True + + + 1 + False + False + False + + + + + 0 + True + False + False + + + + + + + + 0 + True + + + + + 0 + True + False + False + + + + + + True + Never + + + + None + + + + + + + 6 + + + + 250 + 0 + Long description of the add-in. Long description of the add-in. Long description of the add-in. Long description of the add-in. Long description of the add-in. Long description of the add-in. + True + + + 0 + True + False + False + + + + + + + + + 6 + + + + True + TextAndIcon + resource:web.png + More information + True + None + + + + 0 + True + False + False + + + + + + + + + + + End + 2 + True + False + False + + + + + + + + + + + 1 + False + + 1 True - False - False - + - True - + - In + 6 - + True - True - + TextAndIcon + resource:download.png + Install... + True + + + 0 + True + False + False + + + + + + True + TextAndIcon + resource:download.png + Update + True + + + + 1 + True + False + False + + + + + + True + TextOnly + Disable + True + + + + 2 + True + False + False + + + + + + True + TextOnly + _Uninstall... + True + + + + 3 + True + False + False + - - - - Details - True - - - label_item - - 2 True + False + False - - 0 - True - - - - - - - - 6 - 5 - 1 - End - - - - True - True - True - StockItem - gtk-cancel - -6 - - gtk-cancel - - - False - False - diff -Nru mono-addins-0.4/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.AddinInfoDialog.cs mono-addins-0.6.1/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.AddinInfoDialog.cs --- mono-addins-0.4/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.AddinInfoDialog.cs 2008-11-06 19:51:59.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.AddinInfoDialog.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Mono Runtime Version: 2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -namespace Mono.Addins.Gui { - - - internal partial class AddinInfoDialog { - - private Gtk.HBox hbox81; - - private Gtk.VBox vbox94; - - private Gtk.Image packageImage; - - private Gtk.ScrolledWindow scrolledwindow22; - - private Gtk.Label infoLabel; - - private Gtk.Button closebutton3; - - protected virtual void Build() { - Stetic.Gui.Initialize(this); - // Widget Mono.Addins.Gui.AddinInfoDialog - this.Name = "Mono.Addins.Gui.AddinInfoDialog"; - this.Title = Mono.Unix.Catalog.GetString("Package"); - this.TypeHint = ((Gdk.WindowTypeHint)(1)); - this.BorderWidth = ((uint)(6)); - this.DefaultWidth = 550; - this.DefaultHeight = 400; - // Internal child Mono.Addins.Gui.AddinInfoDialog.VBox - Gtk.VBox w1 = this.VBox; - w1.Name = "dialog-vbox12"; - w1.Spacing = 6; - // Container child dialog-vbox12.Gtk.Box+BoxChild - this.hbox81 = new Gtk.HBox(); - this.hbox81.Name = "hbox81"; - this.hbox81.Spacing = 12; - this.hbox81.BorderWidth = ((uint)(6)); - // Container child hbox81.Gtk.Box+BoxChild - this.vbox94 = new Gtk.VBox(); - this.vbox94.Name = "vbox94"; - // Container child vbox94.Gtk.Box+BoxChild - this.packageImage = new Gtk.Image(); - this.packageImage.Name = "packageImage"; - this.vbox94.Add(this.packageImage); - Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(this.vbox94[this.packageImage])); - w2.Position = 0; - w2.Expand = false; - w2.Fill = false; - this.hbox81.Add(this.vbox94); - Gtk.Box.BoxChild w3 = ((Gtk.Box.BoxChild)(this.hbox81[this.vbox94])); - w3.Position = 0; - w3.Expand = false; - w3.Fill = false; - // Container child hbox81.Gtk.Box+BoxChild - this.scrolledwindow22 = new Gtk.ScrolledWindow(); - this.scrolledwindow22.CanFocus = true; - this.scrolledwindow22.Name = "scrolledwindow22"; - // Container child scrolledwindow22.Gtk.Container+ContainerChild - Gtk.Viewport w4 = new Gtk.Viewport(); - w4.ShadowType = ((Gtk.ShadowType)(0)); - // Container child viewport4.Gtk.Container+ContainerChild - this.infoLabel = new Gtk.Label(); - this.infoLabel.WidthRequest = 420; - this.infoLabel.Name = "infoLabel"; - this.infoLabel.Xpad = 6; - this.infoLabel.Ypad = 6; - this.infoLabel.Xalign = 0F; - this.infoLabel.Yalign = 0F; - this.infoLabel.LabelProp = "aa a a a a a a a a aa a a a a aaa a a a a a a a a aa a a a a aaa a a a a a a a a aa a a a a a"; - this.infoLabel.Wrap = true; - w4.Add(this.infoLabel); - this.scrolledwindow22.Add(w4); - this.hbox81.Add(this.scrolledwindow22); - Gtk.Box.BoxChild w7 = ((Gtk.Box.BoxChild)(this.hbox81[this.scrolledwindow22])); - w7.Position = 1; - w1.Add(this.hbox81); - Gtk.Box.BoxChild w8 = ((Gtk.Box.BoxChild)(w1[this.hbox81])); - w8.Position = 0; - // Internal child Mono.Addins.Gui.AddinInfoDialog.ActionArea - Gtk.HButtonBox w9 = this.ActionArea; - w9.Name = "dialog-action_area12"; - w9.Spacing = 10; - w9.BorderWidth = ((uint)(6)); - w9.LayoutStyle = ((Gtk.ButtonBoxStyle)(4)); - // Container child dialog-action_area12.Gtk.ButtonBox+ButtonBoxChild - this.closebutton3 = new Gtk.Button(); - this.closebutton3.CanDefault = true; - this.closebutton3.CanFocus = true; - this.closebutton3.Name = "closebutton3"; - this.closebutton3.UseStock = true; - this.closebutton3.UseUnderline = true; - this.closebutton3.Label = "gtk-close"; - this.AddActionWidget(this.closebutton3, -7); - if ((this.Child != null)) { - this.Child.ShowAll(); - } - this.Show(); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.AddinInfoView.cs mono-addins-0.6.1/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.AddinInfoView.cs --- mono-addins-0.4/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.AddinInfoView.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.AddinInfoView.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,306 @@ + +// This file has been generated by the GUI designer. Do not modify. +namespace Mono.Addins.Gui +{ + internal partial class AddinInfoView + { + private global::Gtk.EventBox ebox; + private global::Gtk.VBox vbox6; + private global::Gtk.EventBox boxHeader; + private global::Gtk.HBox hbox2; + private global::Gtk.Image imageHeader; + private global::Gtk.Label labelHeader; + private global::Gtk.VBox vbox3; + private global::Gtk.HBox headerBox; + private global::Gtk.HBox boxTitle; + private global::Gtk.VBox vbox4; + private global::Gtk.Label labelName; + private global::Gtk.Label labelVersion; + private global::Gtk.ScrolledWindow scrolledwindow; + private global::Gtk.EventBox ebox2; + private global::Gtk.VBox vboxDesc; + private global::Gtk.Label labelDesc; + private global::Gtk.HBox hbox3; + private global::Gtk.Button urlButton; + private global::Gtk.EventBox eboxButs; + private global::Gtk.HBox hbox1; + private global::Gtk.Button btnInstall; + private global::Gtk.Button btnUpdate; + private global::Gtk.Button btnDisable; + private global::Gtk.Button btnUninstall; + + protected virtual void Build () + { + global::Stetic.Gui.Initialize (this); + // Widget Mono.Addins.Gui.AddinInfoView + global::Stetic.BinContainer.Attach (this); + this.Name = "Mono.Addins.Gui.AddinInfoView"; + // Container child Mono.Addins.Gui.AddinInfoView.Gtk.Container+ContainerChild + this.ebox = new global::Gtk.EventBox (); + this.ebox.Name = "ebox"; + // Container child ebox.Gtk.Container+ContainerChild + this.vbox6 = new global::Gtk.VBox (); + this.vbox6.Name = "vbox6"; + // Container child vbox6.Gtk.Box+BoxChild + this.boxHeader = new global::Gtk.EventBox (); + this.boxHeader.Name = "boxHeader"; + // Container child boxHeader.Gtk.Container+ContainerChild + this.hbox2 = new global::Gtk.HBox (); + this.hbox2.Name = "hbox2"; + this.hbox2.Spacing = 6; + // Container child hbox2.Gtk.Box+BoxChild + this.imageHeader = new global::Gtk.Image (); + this.imageHeader.Name = "imageHeader"; + this.imageHeader.Pixbuf = global::Stetic.IconLoader.LoadIcon (this, "gtk-dialog-warning", global::Gtk.IconSize.Menu); + this.hbox2.Add (this.imageHeader); + global::Gtk.Box.BoxChild w1 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.imageHeader])); + w1.Position = 0; + w1.Expand = false; + w1.Fill = false; + // Container child hbox2.Gtk.Box+BoxChild + this.labelHeader = new global::Gtk.Label (); + this.labelHeader.WidthRequest = 250; + this.labelHeader.Name = "labelHeader"; + this.labelHeader.Xalign = 0F; + this.labelHeader.LabelProp = global::Mono.Unix.Catalog.GetString ("label1"); + this.labelHeader.Wrap = true; + this.hbox2.Add (this.labelHeader); + global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.labelHeader])); + w2.Position = 1; + w2.Expand = false; + w2.Fill = false; + this.boxHeader.Add (this.hbox2); + this.vbox6.Add (this.boxHeader); + global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.vbox6 [this.boxHeader])); + w4.Position = 0; + w4.Expand = false; + w4.Fill = false; + // Container child vbox6.Gtk.Box+BoxChild + this.vbox3 = new global::Gtk.VBox (); + this.vbox3.Name = "vbox3"; + this.vbox3.Spacing = 6; + this.vbox3.BorderWidth = ((uint)(12)); + // Container child vbox3.Gtk.Box+BoxChild + this.headerBox = new global::Gtk.HBox (); + this.headerBox.Name = "headerBox"; + this.headerBox.Spacing = 6; + // Container child headerBox.Gtk.Box+BoxChild + this.boxTitle = new global::Gtk.HBox (); + this.boxTitle.Name = "boxTitle"; + this.boxTitle.Spacing = 6; + // Container child boxTitle.Gtk.Box+BoxChild + this.vbox4 = new global::Gtk.VBox (); + this.vbox4.Name = "vbox4"; + this.vbox4.Spacing = 3; + // Container child vbox4.Gtk.Box+BoxChild + this.labelName = new global::Gtk.Label (); + this.labelName.WidthRequest = 280; + this.labelName.Name = "labelName"; + this.labelName.Xalign = 0F; + this.labelName.LabelProp = global::Mono.Unix.Catalog.GetString ("Some Addin"); + this.labelName.UseMarkup = true; + this.labelName.Wrap = true; + this.vbox4.Add (this.labelName); + global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.vbox4 [this.labelName])); + w5.Position = 0; + w5.Expand = false; + w5.Fill = false; + // Container child vbox4.Gtk.Box+BoxChild + this.labelVersion = new global::Gtk.Label (); + this.labelVersion.WidthRequest = 280; + this.labelVersion.Name = "labelVersion"; + this.labelVersion.Xalign = 0F; + this.labelVersion.LabelProp = global::Mono.Unix.Catalog.GetString ("Version 2.6"); + this.labelVersion.Wrap = true; + this.vbox4.Add (this.labelVersion); + global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.vbox4 [this.labelVersion])); + w6.Position = 1; + w6.Expand = false; + w6.Fill = false; + this.boxTitle.Add (this.vbox4); + global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.boxTitle [this.vbox4])); + w7.Position = 0; + w7.Expand = false; + w7.Fill = false; + this.headerBox.Add (this.boxTitle); + global::Gtk.Box.BoxChild w8 = ((global::Gtk.Box.BoxChild)(this.headerBox [this.boxTitle])); + w8.Position = 0; + this.vbox3.Add (this.headerBox); + global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.headerBox])); + w9.Position = 0; + w9.Expand = false; + w9.Fill = false; + // Container child vbox3.Gtk.Box+BoxChild + this.scrolledwindow = new global::Gtk.ScrolledWindow (); + this.scrolledwindow.CanFocus = true; + this.scrolledwindow.Name = "scrolledwindow"; + this.scrolledwindow.HscrollbarPolicy = ((global::Gtk.PolicyType)(2)); + // Container child scrolledwindow.Gtk.Container+ContainerChild + global::Gtk.Viewport w10 = new global::Gtk.Viewport (); + w10.ShadowType = ((global::Gtk.ShadowType)(0)); + // Container child GtkViewport.Gtk.Container+ContainerChild + this.ebox2 = new global::Gtk.EventBox (); + this.ebox2.Name = "ebox2"; + // Container child ebox2.Gtk.Container+ContainerChild + this.vboxDesc = new global::Gtk.VBox (); + this.vboxDesc.Name = "vboxDesc"; + this.vboxDesc.Spacing = 6; + // Container child vboxDesc.Gtk.Box+BoxChild + this.labelDesc = new global::Gtk.Label (); + this.labelDesc.WidthRequest = 250; + this.labelDesc.Name = "labelDesc"; + this.labelDesc.Xalign = 0F; + this.labelDesc.LabelProp = global::Mono.Unix.Catalog.GetString ("Long description of the add-in. Long description of the add-in. Long description of the add-in. Long description of the add-in. Long description of the add-in. Long description of the add-in. "); + this.labelDesc.Wrap = true; + this.vboxDesc.Add (this.labelDesc); + global::Gtk.Box.BoxChild w11 = ((global::Gtk.Box.BoxChild)(this.vboxDesc [this.labelDesc])); + w11.Position = 0; + w11.Expand = false; + w11.Fill = false; + // Container child vboxDesc.Gtk.Box+BoxChild + this.hbox3 = new global::Gtk.HBox (); + this.hbox3.Name = "hbox3"; + this.hbox3.Spacing = 6; + // Container child hbox3.Gtk.Box+BoxChild + this.urlButton = new global::Gtk.Button (); + this.urlButton.CanFocus = true; + this.urlButton.Name = "urlButton"; + this.urlButton.UseUnderline = true; + this.urlButton.Relief = ((global::Gtk.ReliefStyle)(2)); + // Container child urlButton.Gtk.Container+ContainerChild + global::Gtk.Alignment w12 = new global::Gtk.Alignment (0.5F, 0.5F, 0F, 0F); + // Container child GtkAlignment.Gtk.Container+ContainerChild + global::Gtk.HBox w13 = new global::Gtk.HBox (); + w13.Spacing = 2; + // Container child GtkHBox.Gtk.Container+ContainerChild + global::Gtk.Image w14 = new global::Gtk.Image (); + w14.Pixbuf = global::Gdk.Pixbuf.LoadFromResource ("web.png"); + w13.Add (w14); + // Container child GtkHBox.Gtk.Container+ContainerChild + global::Gtk.Label w16 = new global::Gtk.Label (); + w16.LabelProp = global::Mono.Unix.Catalog.GetString ("More information"); + w16.UseUnderline = true; + w13.Add (w16); + w12.Add (w13); + this.urlButton.Add (w12); + this.hbox3.Add (this.urlButton); + global::Gtk.Box.BoxChild w20 = ((global::Gtk.Box.BoxChild)(this.hbox3 [this.urlButton])); + w20.Position = 0; + w20.Expand = false; + w20.Fill = false; + this.vboxDesc.Add (this.hbox3); + global::Gtk.Box.BoxChild w21 = ((global::Gtk.Box.BoxChild)(this.vboxDesc [this.hbox3])); + w21.PackType = ((global::Gtk.PackType)(1)); + w21.Position = 2; + w21.Expand = false; + w21.Fill = false; + this.ebox2.Add (this.vboxDesc); + w10.Add (this.ebox2); + this.scrolledwindow.Add (w10); + this.vbox3.Add (this.scrolledwindow); + global::Gtk.Box.BoxChild w25 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.scrolledwindow])); + w25.Position = 1; + this.vbox6.Add (this.vbox3); + global::Gtk.Box.BoxChild w26 = ((global::Gtk.Box.BoxChild)(this.vbox6 [this.vbox3])); + w26.Position = 1; + // Container child vbox6.Gtk.Box+BoxChild + this.eboxButs = new global::Gtk.EventBox (); + this.eboxButs.Name = "eboxButs"; + // Container child eboxButs.Gtk.Container+ContainerChild + this.hbox1 = new global::Gtk.HBox (); + this.hbox1.Name = "hbox1"; + this.hbox1.Spacing = 6; + // Container child hbox1.Gtk.Box+BoxChild + this.btnInstall = new global::Gtk.Button (); + this.btnInstall.CanFocus = true; + this.btnInstall.Name = "btnInstall"; + this.btnInstall.UseUnderline = true; + // Container child btnInstall.Gtk.Container+ContainerChild + global::Gtk.Alignment w27 = new global::Gtk.Alignment (0.5F, 0.5F, 0F, 0F); + // Container child GtkAlignment.Gtk.Container+ContainerChild + global::Gtk.HBox w28 = new global::Gtk.HBox (); + w28.Spacing = 2; + // Container child GtkHBox.Gtk.Container+ContainerChild + global::Gtk.Image w29 = new global::Gtk.Image (); + w29.Pixbuf = global::Gdk.Pixbuf.LoadFromResource ("download.png"); + w28.Add (w29); + // Container child GtkHBox.Gtk.Container+ContainerChild + global::Gtk.Label w31 = new global::Gtk.Label (); + w31.LabelProp = global::Mono.Unix.Catalog.GetString ("Install..."); + w31.UseUnderline = true; + w28.Add (w31); + w27.Add (w28); + this.btnInstall.Add (w27); + this.hbox1.Add (this.btnInstall); + global::Gtk.Box.BoxChild w35 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.btnInstall])); + w35.Position = 0; + w35.Expand = false; + w35.Fill = false; + // Container child hbox1.Gtk.Box+BoxChild + this.btnUpdate = new global::Gtk.Button (); + this.btnUpdate.CanFocus = true; + this.btnUpdate.Name = "btnUpdate"; + this.btnUpdate.UseUnderline = true; + // Container child btnUpdate.Gtk.Container+ContainerChild + global::Gtk.Alignment w36 = new global::Gtk.Alignment (0.5F, 0.5F, 0F, 0F); + // Container child GtkAlignment.Gtk.Container+ContainerChild + global::Gtk.HBox w37 = new global::Gtk.HBox (); + w37.Spacing = 2; + // Container child GtkHBox.Gtk.Container+ContainerChild + global::Gtk.Image w38 = new global::Gtk.Image (); + w38.Pixbuf = global::Gdk.Pixbuf.LoadFromResource ("download.png"); + w37.Add (w38); + // Container child GtkHBox.Gtk.Container+ContainerChild + global::Gtk.Label w40 = new global::Gtk.Label (); + w40.LabelProp = global::Mono.Unix.Catalog.GetString ("Update"); + w40.UseUnderline = true; + w37.Add (w40); + w36.Add (w37); + this.btnUpdate.Add (w36); + this.hbox1.Add (this.btnUpdate); + global::Gtk.Box.BoxChild w44 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.btnUpdate])); + w44.Position = 1; + w44.Expand = false; + w44.Fill = false; + // Container child hbox1.Gtk.Box+BoxChild + this.btnDisable = new global::Gtk.Button (); + this.btnDisable.CanFocus = true; + this.btnDisable.Name = "btnDisable"; + this.btnDisable.UseUnderline = true; + this.btnDisable.Label = global::Mono.Unix.Catalog.GetString ("Disable"); + this.hbox1.Add (this.btnDisable); + global::Gtk.Box.BoxChild w45 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.btnDisable])); + w45.Position = 2; + w45.Expand = false; + w45.Fill = false; + // Container child hbox1.Gtk.Box+BoxChild + this.btnUninstall = new global::Gtk.Button (); + this.btnUninstall.CanFocus = true; + this.btnUninstall.Name = "btnUninstall"; + this.btnUninstall.UseUnderline = true; + this.btnUninstall.Label = global::Mono.Unix.Catalog.GetString ("_Uninstall..."); + this.hbox1.Add (this.btnUninstall); + global::Gtk.Box.BoxChild w46 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.btnUninstall])); + w46.Position = 3; + w46.Expand = false; + w46.Fill = false; + this.eboxButs.Add (this.hbox1); + this.vbox6.Add (this.eboxButs); + global::Gtk.Box.BoxChild w48 = ((global::Gtk.Box.BoxChild)(this.vbox6 [this.eboxButs])); + w48.Position = 2; + w48.Expand = false; + w48.Fill = false; + this.ebox.Add (this.vbox6); + this.Add (this.ebox); + if ((this.Child != null)) { + this.Child.ShowAll (); + } + this.Hide (); + this.urlButton.Clicked += new global::System.EventHandler (this.OnUrlButtonClicked); + this.btnInstall.Clicked += new global::System.EventHandler (this.OnBtnInstallClicked); + this.btnUpdate.Clicked += new global::System.EventHandler (this.OnBtnUpdateClicked); + this.btnDisable.Clicked += new global::System.EventHandler (this.OnBtnDisableClicked); + this.btnUninstall.Clicked += new global::System.EventHandler (this.OnBtnUninstallClicked); + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.AddinInstallDialog.cs mono-addins-0.6.1/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.AddinInstallDialog.cs --- mono-addins-0.4/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.AddinInstallDialog.cs 2008-11-06 19:51:59.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.AddinInstallDialog.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,545 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Mono Runtime Version: 2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -namespace Mono.Addins.Gui { - - - internal partial class AddinInstallDialog { - - private Gtk.Notebook wizardNotebook; - - private Gtk.VBox vbox82; - - private Gtk.Label label113; - - private Gtk.HBox hbox66; - - private Gtk.Label label112; - - private Gtk.ComboBox repoCombo; - - private Gtk.Button button1; - - private Gtk.Button btnManageSites; - - private Gtk.HBox hbox70; - - private Gtk.VBox vbox92; - - private Gtk.ScrolledWindow scrolledwindow18; - - private Gtk.TreeView addinTree; - - private Gtk.HBox hbox83; - - private Gtk.ComboBox filterComboBox; - - private Gtk.Button btnInfo; - - private Gtk.Button btnUnselectAll; - - private Gtk.Button btnSelectAll; - - private Gtk.Label label108; - - private Gtk.ScrolledWindow scrolledwindow19; - - private Gtk.HBox hbox82; - - private Gtk.Image imageInstall; - - private Gtk.Label labelSummary; - - private Gtk.Label label124; - - private Gtk.VBox vbox86; - - private Gtk.Label label1; - - private Gtk.Label globalProgressLabel; - - private Gtk.ProgressBar mainProgressBar; - - private Gtk.Label label2; - - private Gtk.Label label110; - - private Gtk.ScrolledWindow scrolledwindow20; - - private Gtk.VBox vbox91; - - private Gtk.Label label130; - - private Gtk.Image imageError; - - private Gtk.Image imageWarn; - - private Gtk.Image imageInfo; - - private Gtk.HBox hbox71; - - private Gtk.Label labelResult; - - private Gtk.Label label131; - - private Gtk.Label label111; - - private Gtk.HButtonBox dialog_action_area9; - - private Gtk.Button btnCancel; - - private Gtk.Button btnPrev; - - private Gtk.Button btnNext; - - private Gtk.Button btnOk; - - protected virtual void Build() { - Stetic.Gui.Initialize(this); - // Widget Mono.Addins.Gui.AddinInstallDialog - this.Name = "Mono.Addins.Gui.AddinInstallDialog"; - this.Title = Mono.Unix.Catalog.GetString("Add-in Installation"); - this.TypeHint = ((Gdk.WindowTypeHint)(1)); - this.Modal = true; - this.BorderWidth = ((uint)(6)); - this.DefaultWidth = 725; - this.DefaultHeight = 550; - // Internal child Mono.Addins.Gui.AddinInstallDialog.VBox - Gtk.VBox w1 = this.VBox; - w1.Name = "dialog-vbox9"; - w1.Spacing = 6; - w1.BorderWidth = ((uint)(2)); - // Container child dialog-vbox9.Gtk.Box+BoxChild - this.wizardNotebook = new Gtk.Notebook(); - this.wizardNotebook.CanFocus = true; - this.wizardNotebook.Name = "wizardNotebook"; - this.wizardNotebook.CurrentPage = 0; - this.wizardNotebook.ShowBorder = false; - this.wizardNotebook.BorderWidth = ((uint)(6)); - // Container child wizardNotebook.Gtk.Notebook+NotebookChild - this.vbox82 = new Gtk.VBox(); - this.vbox82.Name = "vbox82"; - this.vbox82.Spacing = 12; - // Container child vbox82.Gtk.Box+BoxChild - this.label113 = new Gtk.Label(); - this.label113.Name = "label113"; - this.label113.Xalign = 0F; - this.label113.LabelProp = Mono.Unix.Catalog.GetString("Select the add-ins to install and click on Next"); - this.label113.UseMarkup = true; - this.vbox82.Add(this.label113); - Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(this.vbox82[this.label113])); - w2.Position = 0; - w2.Expand = false; - w2.Fill = false; - // Container child vbox82.Gtk.Box+BoxChild - this.hbox66 = new Gtk.HBox(); - this.hbox66.Name = "hbox66"; - this.hbox66.Spacing = 6; - // Container child hbox66.Gtk.Box+BoxChild - this.label112 = new Gtk.Label(); - this.label112.Name = "label112"; - this.label112.LabelProp = Mono.Unix.Catalog.GetString("Install from:"); - this.hbox66.Add(this.label112); - Gtk.Box.BoxChild w3 = ((Gtk.Box.BoxChild)(this.hbox66[this.label112])); - w3.Position = 0; - w3.Expand = false; - w3.Fill = false; - // Container child hbox66.Gtk.Box+BoxChild - this.repoCombo = new Gtk.ComboBox(); - this.repoCombo.Name = "repoCombo"; - this.hbox66.Add(this.repoCombo); - Gtk.Box.BoxChild w4 = ((Gtk.Box.BoxChild)(this.hbox66[this.repoCombo])); - w4.Position = 1; - // Container child hbox66.Gtk.Box+BoxChild - this.button1 = new Gtk.Button(); - this.button1.CanFocus = true; - this.button1.Name = "button1"; - this.button1.UseStock = true; - this.button1.UseUnderline = true; - this.button1.Label = "gtk-refresh"; - this.hbox66.Add(this.button1); - Gtk.Box.BoxChild w5 = ((Gtk.Box.BoxChild)(this.hbox66[this.button1])); - w5.Position = 2; - w5.Expand = false; - w5.Fill = false; - // Container child hbox66.Gtk.Box+BoxChild - this.btnManageSites = new Gtk.Button(); - this.btnManageSites.CanFocus = true; - this.btnManageSites.Name = "btnManageSites"; - this.btnManageSites.UseUnderline = true; - this.btnManageSites.Label = Mono.Unix.Catalog.GetString("_Repositories..."); - this.hbox66.Add(this.btnManageSites); - Gtk.Box.BoxChild w6 = ((Gtk.Box.BoxChild)(this.hbox66[this.btnManageSites])); - w6.Position = 3; - w6.Expand = false; - w6.Fill = false; - this.vbox82.Add(this.hbox66); - Gtk.Box.BoxChild w7 = ((Gtk.Box.BoxChild)(this.vbox82[this.hbox66])); - w7.Position = 1; - w7.Expand = false; - w7.Fill = false; - // Container child vbox82.Gtk.Box+BoxChild - this.hbox70 = new Gtk.HBox(); - this.hbox70.Name = "hbox70"; - this.hbox70.Spacing = 12; - // Container child hbox70.Gtk.Box+BoxChild - this.vbox92 = new Gtk.VBox(); - this.vbox92.Name = "vbox92"; - this.vbox92.Spacing = 6; - // Container child vbox92.Gtk.Box+BoxChild - this.scrolledwindow18 = new Gtk.ScrolledWindow(); - this.scrolledwindow18.CanFocus = true; - this.scrolledwindow18.Name = "scrolledwindow18"; - this.scrolledwindow18.ShadowType = ((Gtk.ShadowType)(1)); - // Container child scrolledwindow18.Gtk.Container+ContainerChild - this.addinTree = new Gtk.TreeView(); - this.addinTree.CanFocus = true; - this.addinTree.Name = "addinTree"; - this.addinTree.HeadersClickable = true; - this.scrolledwindow18.Add(this.addinTree); - this.vbox92.Add(this.scrolledwindow18); - Gtk.Box.BoxChild w9 = ((Gtk.Box.BoxChild)(this.vbox92[this.scrolledwindow18])); - w9.Position = 0; - // Container child vbox92.Gtk.Box+BoxChild - this.hbox83 = new Gtk.HBox(); - this.hbox83.Name = "hbox83"; - this.hbox83.Spacing = 6; - // Container child hbox83.Gtk.Box+BoxChild - this.filterComboBox = Gtk.ComboBox.NewText(); - this.filterComboBox.AppendText(Mono.Unix.Catalog.GetString("Show all packages")); - this.filterComboBox.AppendText(Mono.Unix.Catalog.GetString("Show new versions only")); - this.filterComboBox.AppendText(Mono.Unix.Catalog.GetString("Show updates only")); - this.filterComboBox.Name = "filterComboBox"; - this.hbox83.Add(this.filterComboBox); - Gtk.Box.BoxChild w10 = ((Gtk.Box.BoxChild)(this.hbox83[this.filterComboBox])); - w10.Position = 0; - w10.Expand = false; - w10.Fill = false; - // Container child hbox83.Gtk.Box+BoxChild - this.btnInfo = new Gtk.Button(); - this.btnInfo.CanFocus = true; - this.btnInfo.Name = "btnInfo"; - this.btnInfo.UseStock = true; - this.btnInfo.UseUnderline = true; - this.btnInfo.Label = "gtk-dialog-info"; - this.hbox83.Add(this.btnInfo); - Gtk.Box.BoxChild w11 = ((Gtk.Box.BoxChild)(this.hbox83[this.btnInfo])); - w11.PackType = ((Gtk.PackType)(1)); - w11.Position = 1; - w11.Expand = false; - w11.Fill = false; - // Container child hbox83.Gtk.Box+BoxChild - this.btnUnselectAll = new Gtk.Button(); - this.btnUnselectAll.CanFocus = true; - this.btnUnselectAll.Name = "btnUnselectAll"; - this.btnUnselectAll.UseUnderline = true; - this.btnUnselectAll.Label = Mono.Unix.Catalog.GetString("_Unselect All"); - this.hbox83.Add(this.btnUnselectAll); - Gtk.Box.BoxChild w12 = ((Gtk.Box.BoxChild)(this.hbox83[this.btnUnselectAll])); - w12.PackType = ((Gtk.PackType)(1)); - w12.Position = 2; - w12.Expand = false; - w12.Fill = false; - // Container child hbox83.Gtk.Box+BoxChild - this.btnSelectAll = new Gtk.Button(); - this.btnSelectAll.CanFocus = true; - this.btnSelectAll.Name = "btnSelectAll"; - this.btnSelectAll.UseUnderline = true; - this.btnSelectAll.Label = Mono.Unix.Catalog.GetString("Select _All"); - this.hbox83.Add(this.btnSelectAll); - Gtk.Box.BoxChild w13 = ((Gtk.Box.BoxChild)(this.hbox83[this.btnSelectAll])); - w13.PackType = ((Gtk.PackType)(1)); - w13.Position = 3; - w13.Expand = false; - w13.Fill = false; - this.vbox92.Add(this.hbox83); - Gtk.Box.BoxChild w14 = ((Gtk.Box.BoxChild)(this.vbox92[this.hbox83])); - w14.Position = 1; - w14.Expand = false; - w14.Fill = false; - this.hbox70.Add(this.vbox92); - Gtk.Box.BoxChild w15 = ((Gtk.Box.BoxChild)(this.hbox70[this.vbox92])); - w15.Position = 0; - this.vbox82.Add(this.hbox70); - Gtk.Box.BoxChild w16 = ((Gtk.Box.BoxChild)(this.vbox82[this.hbox70])); - w16.Position = 2; - this.wizardNotebook.Add(this.vbox82); - // Notebook tab - this.label108 = new Gtk.Label(); - this.label108.Name = "label108"; - this.label108.LabelProp = "label108"; - this.wizardNotebook.SetTabLabel(this.vbox82, this.label108); - this.label108.ShowAll(); - // Container child wizardNotebook.Gtk.Notebook+NotebookChild - this.scrolledwindow19 = new Gtk.ScrolledWindow(); - this.scrolledwindow19.CanFocus = true; - this.scrolledwindow19.Name = "scrolledwindow19"; - // Container child scrolledwindow19.Gtk.Container+ContainerChild - Gtk.Viewport w18 = new Gtk.Viewport(); - // Container child viewport1.Gtk.Container+ContainerChild - this.hbox82 = new Gtk.HBox(); - this.hbox82.Name = "hbox82"; - this.hbox82.Spacing = 12; - this.hbox82.BorderWidth = ((uint)(12)); - // Container child hbox82.Gtk.Box+BoxChild - this.imageInstall = new Gtk.Image(); - this.imageInstall.Name = "imageInstall"; - this.imageInstall.Xalign = 0F; - this.imageInstall.Yalign = 0F; - this.imageInstall.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-dialog-warning", Gtk.IconSize.Dialog, 48); - this.hbox82.Add(this.imageInstall); - Gtk.Box.BoxChild w19 = ((Gtk.Box.BoxChild)(this.hbox82[this.imageInstall])); - w19.Position = 0; - w19.Expand = false; - w19.Fill = false; - // Container child hbox82.Gtk.Box+BoxChild - this.labelSummary = new Gtk.Label(); - this.labelSummary.Name = "labelSummary"; - this.labelSummary.Xpad = 6; - this.labelSummary.Ypad = 6; - this.labelSummary.Xalign = 0F; - this.labelSummary.Yalign = 0F; - this.labelSummary.LabelProp = "The following add-ins will be installed:\n\nC# language binding\nC# language IDE extension\n\nThe following add-ins are required by the selected add-ins\n\nNUnit add-in\nNAnt add-in\n\nasd\nasd\na\nsd\nasd\nasd\na\nsda\nsd\nas\nda\nsd\nasd\n"; - this.labelSummary.UseMarkup = true; - this.labelSummary.Wrap = true; - this.hbox82.Add(this.labelSummary); - Gtk.Box.BoxChild w20 = ((Gtk.Box.BoxChild)(this.hbox82[this.labelSummary])); - w20.Position = 1; - w20.Expand = false; - w20.Fill = false; - w18.Add(this.hbox82); - this.scrolledwindow19.Add(w18); - this.wizardNotebook.Add(this.scrolledwindow19); - Gtk.Notebook.NotebookChild w23 = ((Gtk.Notebook.NotebookChild)(this.wizardNotebook[this.scrolledwindow19])); - w23.Position = 1; - // Notebook tab - this.label124 = new Gtk.Label(); - this.label124.Name = "label124"; - this.label124.LabelProp = Mono.Unix.Catalog.GetString("label124"); - this.wizardNotebook.SetTabLabel(this.scrolledwindow19, this.label124); - this.label124.ShowAll(); - // Container child wizardNotebook.Gtk.Notebook+NotebookChild - this.vbox86 = new Gtk.VBox(); - this.vbox86.Name = "vbox86"; - this.vbox86.Spacing = 6; - this.vbox86.BorderWidth = ((uint)(61)); - // Container child vbox86.Gtk.Box+BoxChild - this.label1 = new Gtk.Label(); - this.label1.Name = "label1"; - this.label1.LabelProp = ""; - this.vbox86.Add(this.label1); - Gtk.Box.BoxChild w24 = ((Gtk.Box.BoxChild)(this.vbox86[this.label1])); - w24.Position = 0; - // Container child vbox86.Gtk.Box+BoxChild - this.globalProgressLabel = new Gtk.Label(); - this.globalProgressLabel.Name = "globalProgressLabel"; - this.globalProgressLabel.Xalign = 0F; - this.globalProgressLabel.LabelProp = Mono.Unix.Catalog.GetString("Overall Progress:"); - this.globalProgressLabel.Ellipsize = ((Pango.EllipsizeMode)(3)); - this.vbox86.Add(this.globalProgressLabel); - Gtk.Box.BoxChild w25 = ((Gtk.Box.BoxChild)(this.vbox86[this.globalProgressLabel])); - w25.Position = 1; - w25.Expand = false; - w25.Fill = false; - // Container child vbox86.Gtk.Box+BoxChild - this.mainProgressBar = new Gtk.ProgressBar(); - this.mainProgressBar.Name = "mainProgressBar"; - this.mainProgressBar.PulseStep = 10000000149; - this.vbox86.Add(this.mainProgressBar); - Gtk.Box.BoxChild w26 = ((Gtk.Box.BoxChild)(this.vbox86[this.mainProgressBar])); - w26.Position = 2; - w26.Expand = false; - w26.Fill = false; - // Container child vbox86.Gtk.Box+BoxChild - this.label2 = new Gtk.Label(); - this.label2.Name = "label2"; - this.label2.LabelProp = ""; - this.vbox86.Add(this.label2); - Gtk.Box.BoxChild w27 = ((Gtk.Box.BoxChild)(this.vbox86[this.label2])); - w27.Position = 3; - this.wizardNotebook.Add(this.vbox86); - Gtk.Notebook.NotebookChild w28 = ((Gtk.Notebook.NotebookChild)(this.wizardNotebook[this.vbox86])); - w28.Position = 2; - // Notebook tab - this.label110 = new Gtk.Label(); - this.label110.Name = "label110"; - this.label110.LabelProp = "label110"; - this.wizardNotebook.SetTabLabel(this.vbox86, this.label110); - this.label110.ShowAll(); - // Container child wizardNotebook.Gtk.Notebook+NotebookChild - this.scrolledwindow20 = new Gtk.ScrolledWindow(); - this.scrolledwindow20.CanFocus = true; - this.scrolledwindow20.Name = "scrolledwindow20"; - // Container child scrolledwindow20.Gtk.Container+ContainerChild - Gtk.Viewport w29 = new Gtk.Viewport(); - // Container child viewport3.Gtk.Container+ContainerChild - this.vbox91 = new Gtk.VBox(); - this.vbox91.Name = "vbox91"; - // Container child vbox91.Gtk.Box+BoxChild - this.label130 = new Gtk.Label(); - this.label130.Name = "label130"; - this.label130.LabelProp = ""; - this.vbox91.Add(this.label130); - Gtk.Box.BoxChild w30 = ((Gtk.Box.BoxChild)(this.vbox91[this.label130])); - w30.Position = 0; - // Container child vbox91.Gtk.Box+BoxChild - this.imageError = new Gtk.Image(); - this.imageError.Name = "imageError"; - this.imageError.Yalign = 1F; - this.imageError.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-dialog-error", Gtk.IconSize.Dialog, 48); - this.vbox91.Add(this.imageError); - Gtk.Box.BoxChild w31 = ((Gtk.Box.BoxChild)(this.vbox91[this.imageError])); - w31.Position = 1; - w31.Expand = false; - w31.Fill = false; - w31.Padding = ((uint)(5)); - // Container child vbox91.Gtk.Box+BoxChild - this.imageWarn = new Gtk.Image(); - this.imageWarn.Name = "imageWarn"; - this.imageWarn.Yalign = 1F; - this.imageWarn.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-dialog-warning", Gtk.IconSize.Dialog, 48); - this.vbox91.Add(this.imageWarn); - Gtk.Box.BoxChild w32 = ((Gtk.Box.BoxChild)(this.vbox91[this.imageWarn])); - w32.Position = 2; - w32.Expand = false; - w32.Fill = false; - // Container child vbox91.Gtk.Box+BoxChild - this.imageInfo = new Gtk.Image(); - this.imageInfo.Name = "imageInfo"; - this.imageInfo.Yalign = 1F; - this.imageInfo.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-dialog-info", Gtk.IconSize.Dialog, 48); - this.vbox91.Add(this.imageInfo); - Gtk.Box.BoxChild w33 = ((Gtk.Box.BoxChild)(this.vbox91[this.imageInfo])); - w33.Position = 3; - w33.Expand = false; - w33.Fill = false; - // Container child vbox91.Gtk.Box+BoxChild - this.hbox71 = new Gtk.HBox(); - this.hbox71.Name = "hbox71"; - // Container child hbox71.Gtk.Box+BoxChild - this.labelResult = new Gtk.Label(); - this.labelResult.WidthRequest = 450; - this.labelResult.Name = "labelResult"; - this.labelResult.Ypad = 9; - this.labelResult.Yalign = 0F; - this.labelResult.LabelProp = "Done"; - this.labelResult.UseMarkup = true; - this.labelResult.Wrap = true; - this.labelResult.Justify = ((Gtk.Justification)(2)); - this.hbox71.Add(this.labelResult); - Gtk.Box.BoxChild w34 = ((Gtk.Box.BoxChild)(this.hbox71[this.labelResult])); - w34.PackType = ((Gtk.PackType)(1)); - w34.Position = 0; - this.vbox91.Add(this.hbox71); - Gtk.Box.BoxChild w35 = ((Gtk.Box.BoxChild)(this.vbox91[this.hbox71])); - w35.Position = 4; - w35.Expand = false; - w35.Fill = false; - // Container child vbox91.Gtk.Box+BoxChild - this.label131 = new Gtk.Label(); - this.label131.Name = "label131"; - this.label131.LabelProp = ""; - this.vbox91.Add(this.label131); - Gtk.Box.BoxChild w36 = ((Gtk.Box.BoxChild)(this.vbox91[this.label131])); - w36.Position = 5; - w29.Add(this.vbox91); - this.scrolledwindow20.Add(w29); - this.wizardNotebook.Add(this.scrolledwindow20); - Gtk.Notebook.NotebookChild w39 = ((Gtk.Notebook.NotebookChild)(this.wizardNotebook[this.scrolledwindow20])); - w39.Position = 3; - // Notebook tab - this.label111 = new Gtk.Label(); - this.label111.Name = "label111"; - this.label111.LabelProp = "label111"; - this.wizardNotebook.SetTabLabel(this.scrolledwindow20, this.label111); - this.label111.ShowAll(); - w1.Add(this.wizardNotebook); - Gtk.Box.BoxChild w40 = ((Gtk.Box.BoxChild)(w1[this.wizardNotebook])); - w40.Position = 0; - // Container child dialog-vbox9.Gtk.Box+BoxChild - this.dialog_action_area9 = new Gtk.HButtonBox(); - this.dialog_action_area9.Name = "dialog_action_area9"; - this.dialog_action_area9.Spacing = 9; - this.dialog_action_area9.BorderWidth = ((uint)(6)); - this.dialog_action_area9.LayoutStyle = ((Gtk.ButtonBoxStyle)(4)); - // Container child dialog_action_area9.Gtk.ButtonBox+ButtonBoxChild - this.btnCancel = new Gtk.Button(); - this.btnCancel.CanDefault = true; - this.btnCancel.CanFocus = true; - this.btnCancel.Name = "btnCancel"; - this.btnCancel.UseStock = true; - this.btnCancel.UseUnderline = true; - this.btnCancel.Label = "gtk-cancel"; - this.dialog_action_area9.Add(this.btnCancel); - // Container child dialog_action_area9.Gtk.ButtonBox+ButtonBoxChild - this.btnPrev = new Gtk.Button(); - this.btnPrev.CanDefault = true; - this.btnPrev.CanFocus = true; - this.btnPrev.Name = "btnPrev"; - this.btnPrev.UseStock = true; - this.btnPrev.UseUnderline = true; - this.btnPrev.Label = "gtk-go-back"; - this.dialog_action_area9.Add(this.btnPrev); - Gtk.ButtonBox.ButtonBoxChild w42 = ((Gtk.ButtonBox.ButtonBoxChild)(this.dialog_action_area9[this.btnPrev])); - w42.Position = 1; - // Container child dialog_action_area9.Gtk.ButtonBox+ButtonBoxChild - this.btnNext = new Gtk.Button(); - this.btnNext.CanDefault = true; - this.btnNext.CanFocus = true; - this.btnNext.Name = "btnNext"; - this.btnNext.UseStock = true; - this.btnNext.UseUnderline = true; - this.btnNext.Label = "gtk-go-forward"; - this.dialog_action_area9.Add(this.btnNext); - Gtk.ButtonBox.ButtonBoxChild w43 = ((Gtk.ButtonBox.ButtonBoxChild)(this.dialog_action_area9[this.btnNext])); - w43.Position = 2; - // Container child dialog_action_area9.Gtk.ButtonBox+ButtonBoxChild - this.btnOk = new Gtk.Button(); - this.btnOk.CanDefault = true; - this.btnOk.CanFocus = true; - this.btnOk.Name = "btnOk"; - this.btnOk.UseStock = true; - this.btnOk.UseUnderline = true; - this.btnOk.Label = "gtk-ok"; - this.dialog_action_area9.Add(this.btnOk); - Gtk.ButtonBox.ButtonBoxChild w44 = ((Gtk.ButtonBox.ButtonBoxChild)(this.dialog_action_area9[this.btnOk])); - w44.Position = 3; - w1.Add(this.dialog_action_area9); - Gtk.Box.BoxChild w45 = ((Gtk.Box.BoxChild)(w1[this.dialog_action_area9])); - w45.PackType = ((Gtk.PackType)(1)); - w45.Position = 2; - w45.Expand = false; - w45.Fill = false; - // Internal child Mono.Addins.Gui.AddinInstallDialog.ActionArea - Gtk.HButtonBox w46 = this.ActionArea; - w46.Spacing = 6; - w46.BorderWidth = ((uint)(5)); - w46.LayoutStyle = ((Gtk.ButtonBoxStyle)(4)); - if ((this.Child != null)) { - this.Child.ShowAll(); - } - this.btnOk.Hide(); - w46.Hide(); - this.Show(); - this.repoCombo.Changed += new System.EventHandler(this.OnRepoChanged); - this.button1.Clicked += new System.EventHandler(this.OnUpdateRepo); - this.btnManageSites.Clicked += new System.EventHandler(this.OnManageSites); - this.addinTree.CursorChanged += new System.EventHandler(this.OnActiveAddinChanged); - this.filterComboBox.Changed += new System.EventHandler(this.OnFilterChanged); - this.btnSelectAll.Clicked += new System.EventHandler(this.OnSelectAll); - this.btnUnselectAll.Clicked += new System.EventHandler(this.OnUnselectAll); - this.btnInfo.Clicked += new System.EventHandler(this.OnShowInfo); - this.btnCancel.Clicked += new System.EventHandler(this.OnCancel); - this.btnPrev.Clicked += new System.EventHandler(this.OnPrevPage); - this.btnNext.Clicked += new System.EventHandler(this.OnNextPage); - this.btnOk.Clicked += new System.EventHandler(this.OnOk); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.AddinInstallerDialog.cs mono-addins-0.6.1/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.AddinInstallerDialog.cs --- mono-addins-0.4/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.AddinInstallerDialog.cs 2008-11-06 19:51:59.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.AddinInstallerDialog.cs 2011-04-13 09:00:29.000000000 +0000 @@ -1,144 +1,128 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Mono Runtime Version: 2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ -namespace Mono.Addins.Gui { - - - internal partial class AddinInstallerDialog { - - private Gtk.VBox vbox2; - - private Gtk.Label label1; - - private Gtk.Label label2; - - private Gtk.ScrolledWindow scrolledwindow1; - - private Gtk.Label addinList; - - private Gtk.ProgressBar progressBar; - - private Gtk.Button buttonCancel; - - private Gtk.Button buttonOk; - - protected virtual void Build() { - Stetic.Gui.Initialize(this); - // Widget Mono.Addins.Gui.AddinInstallerDialog - this.Name = "Mono.Addins.Gui.AddinInstallerDialog"; - this.Title = Mono.Unix.Catalog.GetString("Add-in Manager"); - this.WindowPosition = ((Gtk.WindowPosition)(4)); - this.BorderWidth = ((uint)(6)); - this.HasSeparator = false; - // Internal child Mono.Addins.Gui.AddinInstallerDialog.VBox - Gtk.VBox w1 = this.VBox; - w1.Name = "dialog1_VBox"; - w1.Spacing = 6; - w1.BorderWidth = ((uint)(2)); - // Container child dialog1_VBox.Gtk.Box+BoxChild - this.vbox2 = new Gtk.VBox(); - this.vbox2.Name = "vbox2"; - this.vbox2.Spacing = 6; - this.vbox2.BorderWidth = ((uint)(6)); - // Container child vbox2.Gtk.Box+BoxChild - this.label1 = new Gtk.Label(); - this.label1.Name = "label1"; - this.label1.Xalign = 0F; - this.label1.LabelProp = Mono.Unix.Catalog.GetString("Additional extensions are required to perform this operation."); - this.vbox2.Add(this.label1); - Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(this.vbox2[this.label1])); - w2.Position = 0; - w2.Expand = false; - w2.Fill = false; - // Container child vbox2.Gtk.Box+BoxChild - this.label2 = new Gtk.Label(); - this.label2.Name = "label2"; - this.label2.Xalign = 0F; - this.label2.LabelProp = Mono.Unix.Catalog.GetString("The following add-ins will be installed:"); - this.vbox2.Add(this.label2); - Gtk.Box.BoxChild w3 = ((Gtk.Box.BoxChild)(this.vbox2[this.label2])); - w3.Position = 1; - w3.Expand = false; - w3.Fill = false; - // Container child vbox2.Gtk.Box+BoxChild - this.scrolledwindow1 = new Gtk.ScrolledWindow(); - this.scrolledwindow1.CanFocus = true; - this.scrolledwindow1.Name = "scrolledwindow1"; - this.scrolledwindow1.ShadowType = ((Gtk.ShadowType)(1)); - // Container child scrolledwindow1.Gtk.Container+ContainerChild - Gtk.Viewport w4 = new Gtk.Viewport(); - w4.ShadowType = ((Gtk.ShadowType)(0)); - // Container child GtkViewport.Gtk.Container+ContainerChild - this.addinList = new Gtk.Label(); - this.addinList.Name = "addinList"; - this.addinList.Xpad = 6; - this.addinList.Ypad = 6; - this.addinList.Xalign = 0F; - this.addinList.Yalign = 0F; - this.addinList.LabelProp = "label3"; - w4.Add(this.addinList); - this.scrolledwindow1.Add(w4); - this.vbox2.Add(this.scrolledwindow1); - Gtk.Box.BoxChild w7 = ((Gtk.Box.BoxChild)(this.vbox2[this.scrolledwindow1])); - w7.Position = 2; - // Container child vbox2.Gtk.Box+BoxChild - this.progressBar = new Gtk.ProgressBar(); - this.progressBar.Name = "progressBar"; - this.progressBar.Text = ""; - this.vbox2.Add(this.progressBar); - Gtk.Box.BoxChild w8 = ((Gtk.Box.BoxChild)(this.vbox2[this.progressBar])); - w8.Position = 3; - w8.Expand = false; - w8.Fill = false; - w1.Add(this.vbox2); - Gtk.Box.BoxChild w9 = ((Gtk.Box.BoxChild)(w1[this.vbox2])); - w9.Position = 0; - // Internal child Mono.Addins.Gui.AddinInstallerDialog.ActionArea - Gtk.HButtonBox w10 = this.ActionArea; - w10.Name = "dialog1_ActionArea"; - w10.Spacing = 10; - w10.BorderWidth = ((uint)(6)); - w10.LayoutStyle = ((Gtk.ButtonBoxStyle)(4)); - // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild - this.buttonCancel = new Gtk.Button(); - this.buttonCancel.CanDefault = true; - this.buttonCancel.CanFocus = true; - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.UseStock = true; - this.buttonCancel.UseUnderline = true; - this.buttonCancel.Label = "gtk-cancel"; - this.AddActionWidget(this.buttonCancel, -6); - Gtk.ButtonBox.ButtonBoxChild w11 = ((Gtk.ButtonBox.ButtonBoxChild)(w10[this.buttonCancel])); - w11.Expand = false; - w11.Fill = false; - // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild - this.buttonOk = new Gtk.Button(); - this.buttonOk.CanDefault = true; - this.buttonOk.CanFocus = true; - this.buttonOk.Name = "buttonOk"; - this.buttonOk.UseStock = true; - this.buttonOk.UseUnderline = true; - this.buttonOk.Label = "gtk-ok"; - w10.Add(this.buttonOk); - Gtk.ButtonBox.ButtonBoxChild w12 = ((Gtk.ButtonBox.ButtonBoxChild)(w10[this.buttonOk])); - w12.Position = 1; - w12.Expand = false; - w12.Fill = false; - if ((this.Child != null)) { - this.Child.ShowAll(); - } - this.DefaultWidth = 593; - this.DefaultHeight = 433; - this.progressBar.Hide(); - this.Show(); - this.buttonOk.Clicked += new System.EventHandler(this.OnButtonOkClicked); - } - } +// This file has been generated by the GUI designer. Do not modify. +namespace Mono.Addins.Gui +{ + internal partial class AddinInstallerDialog + { + private global::Gtk.VBox vbox2; + private global::Gtk.Label label1; + private global::Gtk.Label label2; + private global::Gtk.ScrolledWindow scrolledwindow1; + private global::Gtk.Label addinList; + private global::Gtk.ProgressBar progressBar; + private global::Gtk.Button buttonCancel; + private global::Gtk.Button buttonOk; + + protected virtual void Build () + { + global::Stetic.Gui.Initialize (this); + // Widget Mono.Addins.Gui.AddinInstallerDialog + this.Name = "Mono.Addins.Gui.AddinInstallerDialog"; + this.Title = global::Mono.Unix.Catalog.GetString ("Add-in Manager"); + this.WindowPosition = ((global::Gtk.WindowPosition)(4)); + this.BorderWidth = ((uint)(6)); + // Internal child Mono.Addins.Gui.AddinInstallerDialog.VBox + global::Gtk.VBox w1 = this.VBox; + w1.Name = "dialog1_VBox"; + w1.Spacing = 6; + w1.BorderWidth = ((uint)(2)); + // Container child dialog1_VBox.Gtk.Box+BoxChild + this.vbox2 = new global::Gtk.VBox (); + this.vbox2.Name = "vbox2"; + this.vbox2.Spacing = 6; + this.vbox2.BorderWidth = ((uint)(6)); + // Container child vbox2.Gtk.Box+BoxChild + this.label1 = new global::Gtk.Label (); + this.label1.Name = "label1"; + this.label1.Xalign = 0F; + this.label1.LabelProp = global::Mono.Unix.Catalog.GetString ("Additional extensions are required to perform this operation."); + this.vbox2.Add (this.label1); + global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.label1])); + w2.Position = 0; + w2.Expand = false; + w2.Fill = false; + // Container child vbox2.Gtk.Box+BoxChild + this.label2 = new global::Gtk.Label (); + this.label2.Name = "label2"; + this.label2.Xalign = 0F; + this.label2.LabelProp = global::Mono.Unix.Catalog.GetString ("The following add-ins will be installed:"); + this.vbox2.Add (this.label2); + global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.label2])); + w3.Position = 1; + w3.Expand = false; + w3.Fill = false; + // Container child vbox2.Gtk.Box+BoxChild + this.scrolledwindow1 = new global::Gtk.ScrolledWindow (); + this.scrolledwindow1.CanFocus = true; + this.scrolledwindow1.Name = "scrolledwindow1"; + this.scrolledwindow1.ShadowType = ((global::Gtk.ShadowType)(1)); + // Container child scrolledwindow1.Gtk.Container+ContainerChild + global::Gtk.Viewport w4 = new global::Gtk.Viewport (); + w4.ShadowType = ((global::Gtk.ShadowType)(0)); + // Container child GtkViewport.Gtk.Container+ContainerChild + this.addinList = new global::Gtk.Label (); + this.addinList.Name = "addinList"; + this.addinList.Xpad = 6; + this.addinList.Ypad = 6; + this.addinList.Xalign = 0F; + this.addinList.Yalign = 0F; + this.addinList.LabelProp = "label3"; + w4.Add (this.addinList); + this.scrolledwindow1.Add (w4); + this.vbox2.Add (this.scrolledwindow1); + global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.scrolledwindow1])); + w7.Position = 2; + // Container child vbox2.Gtk.Box+BoxChild + this.progressBar = new global::Gtk.ProgressBar (); + this.progressBar.Name = "progressBar"; + this.progressBar.Text = ""; + this.vbox2.Add (this.progressBar); + global::Gtk.Box.BoxChild w8 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.progressBar])); + w8.Position = 3; + w8.Expand = false; + w8.Fill = false; + w1.Add (this.vbox2); + global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(w1 [this.vbox2])); + w9.Position = 0; + // Internal child Mono.Addins.Gui.AddinInstallerDialog.ActionArea + global::Gtk.HButtonBox w10 = this.ActionArea; + w10.Name = "dialog1_ActionArea"; + w10.Spacing = 10; + w10.BorderWidth = ((uint)(6)); + w10.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4)); + // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.buttonCancel = new global::Gtk.Button (); + this.buttonCancel.CanDefault = true; + this.buttonCancel.CanFocus = true; + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.UseStock = true; + this.buttonCancel.UseUnderline = true; + this.buttonCancel.Label = "gtk-cancel"; + this.AddActionWidget (this.buttonCancel, -6); + global::Gtk.ButtonBox.ButtonBoxChild w11 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w10 [this.buttonCancel])); + w11.Expand = false; + w11.Fill = false; + // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.buttonOk = new global::Gtk.Button (); + this.buttonOk.CanDefault = true; + this.buttonOk.CanFocus = true; + this.buttonOk.Name = "buttonOk"; + this.buttonOk.UseStock = true; + this.buttonOk.UseUnderline = true; + this.buttonOk.Label = "gtk-ok"; + w10.Add (this.buttonOk); + global::Gtk.ButtonBox.ButtonBoxChild w12 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w10 [this.buttonOk])); + w12.Position = 1; + w12.Expand = false; + w12.Fill = false; + if ((this.Child != null)) { + this.Child.ShowAll (); + } + this.DefaultWidth = 593; + this.DefaultHeight = 433; + this.progressBar.Hide (); + this.Show (); + this.buttonOk.Clicked += new global::System.EventHandler (this.OnButtonOkClicked); + } + } } diff -Nru mono-addins-0.4/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.AddinManagerDialog.cs mono-addins-0.6.1/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.AddinManagerDialog.cs --- mono-addins-0.4/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.AddinManagerDialog.cs 2008-11-06 19:51:59.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.AddinManagerDialog.cs 2011-04-13 09:00:29.000000000 +0000 @@ -1,324 +1,414 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Mono Runtime Version: 2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ -namespace Mono.Addins.Gui { - - - internal partial class AddinManagerDialog { - - private Gtk.VBox vbox93; - - private Gtk.HBox hbox85; - - private Gtk.Image imageInstall; - - private Gtk.Label label144; - - private Gtk.HBox hbox73; - - private Gtk.Label label134; - - private Gtk.HBox hbox65; - - private Gtk.HBox hbox72; - - private Gtk.ScrolledWindow scrolledwindow13; - - private Gtk.TreeView addinTree; - - private Gtk.VBox vbox933; - - private Gtk.Button btnInstall; - - private Gtk.Button btnRepositories; - - private Gtk.HSeparator hseparator4; - - private Gtk.Button btnUninstall; - - private Gtk.Button btnEnable; - - private Gtk.Button btnDisable; - - private Gtk.Button btnInfo; - - private Gtk.Button btnClose; - - protected virtual void Build() { - Stetic.Gui.Initialize(this); - // Widget Mono.Addins.Gui.AddinManagerDialog - this.Name = "Mono.Addins.Gui.AddinManagerDialog"; - this.Title = Mono.Unix.Catalog.GetString("Add-in Manager"); - this.TypeHint = ((Gdk.WindowTypeHint)(1)); - this.BorderWidth = ((uint)(6)); - this.DefaultWidth = 700; - this.DefaultHeight = 550; - // Internal child Mono.Addins.Gui.AddinManagerDialog.VBox - Gtk.VBox w1 = this.VBox; - w1.Name = "dialog-vbox8"; - w1.Spacing = 3; - w1.BorderWidth = ((uint)(2)); - // Container child dialog-vbox8.Gtk.Box+BoxChild - this.vbox93 = new Gtk.VBox(); - this.vbox93.Name = "vbox93"; - this.vbox93.Spacing = 6; - this.vbox93.BorderWidth = ((uint)(6)); - // Container child vbox93.Gtk.Box+BoxChild - this.hbox85 = new Gtk.HBox(); - this.hbox85.Name = "hbox85"; - this.hbox85.Spacing = 12; - // Container child hbox85.Gtk.Box+BoxChild - this.imageInstall = new Gtk.Image(); - this.imageInstall.Name = "imageInstall"; - this.imageInstall.Yalign = 0F; - this.imageInstall.Pixbuf = Gdk.Pixbuf.LoadFromResource("system-software-update.png"); - this.hbox85.Add(this.imageInstall); - Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(this.hbox85[this.imageInstall])); - w2.Position = 0; - w2.Expand = false; - w2.Fill = false; - // Container child hbox85.Gtk.Box+BoxChild - this.label144 = new Gtk.Label(); - this.label144.Name = "label144"; - this.label144.LabelProp = Mono.Unix.Catalog.GetString("Add-in Manager"); - this.label144.UseMarkup = true; - this.hbox85.Add(this.label144); - Gtk.Box.BoxChild w3 = ((Gtk.Box.BoxChild)(this.hbox85[this.label144])); - w3.Position = 1; - w3.Expand = false; - w3.Fill = false; - this.vbox93.Add(this.hbox85); - Gtk.Box.BoxChild w4 = ((Gtk.Box.BoxChild)(this.vbox93[this.hbox85])); - w4.Position = 0; - w4.Expand = false; - w4.Fill = false; - // Container child vbox93.Gtk.Box+BoxChild - this.hbox73 = new Gtk.HBox(); - this.hbox73.Name = "hbox73"; - this.hbox73.Spacing = 12; - // Container child hbox73.Gtk.Box+BoxChild - this.label134 = new Gtk.Label(); - this.label134.Name = "label134"; - this.label134.Xalign = 0F; - this.label134.LabelProp = Mono.Unix.Catalog.GetString("The following add-ins are currently installed:"); - this.hbox73.Add(this.label134); - Gtk.Box.BoxChild w5 = ((Gtk.Box.BoxChild)(this.hbox73[this.label134])); - w5.Position = 0; - w5.Expand = false; - w5.Fill = false; - this.vbox93.Add(this.hbox73); - Gtk.Box.BoxChild w6 = ((Gtk.Box.BoxChild)(this.vbox93[this.hbox73])); - w6.Position = 1; - w6.Expand = false; - w6.Fill = false; - // Container child vbox93.Gtk.Box+BoxChild - this.hbox65 = new Gtk.HBox(); - this.hbox65.Name = "hbox65"; - this.hbox65.Spacing = 12; - // Container child hbox65.Gtk.Box+BoxChild - this.hbox72 = new Gtk.HBox(); - this.hbox72.Name = "hbox72"; - this.hbox72.Spacing = 12; - // Container child hbox72.Gtk.Box+BoxChild - this.scrolledwindow13 = new Gtk.ScrolledWindow(); - this.scrolledwindow13.CanFocus = true; - this.scrolledwindow13.Name = "scrolledwindow13"; - this.scrolledwindow13.ShadowType = ((Gtk.ShadowType)(1)); - // Container child scrolledwindow13.Gtk.Container+ContainerChild - this.addinTree = new Gtk.TreeView(); - this.addinTree.CanFocus = true; - this.addinTree.Name = "addinTree"; - this.addinTree.HeadersClickable = true; - this.scrolledwindow13.Add(this.addinTree); - this.hbox72.Add(this.scrolledwindow13); - Gtk.Box.BoxChild w8 = ((Gtk.Box.BoxChild)(this.hbox72[this.scrolledwindow13])); - w8.Position = 0; - // Container child hbox72.Gtk.Box+BoxChild - this.vbox933 = new Gtk.VBox(); - this.vbox933.Name = "vbox933"; - this.vbox933.Spacing = 5; - // Container child vbox933.Gtk.Box+BoxChild - this.btnInstall = new Gtk.Button(); - this.btnInstall.CanFocus = true; - this.btnInstall.Name = "btnInstall"; - this.btnInstall.UseUnderline = true; - // Container child btnInstall.Gtk.Container+ContainerChild - Gtk.Alignment w9 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F); - // Container child GtkAlignment.Gtk.Container+ContainerChild - Gtk.HBox w10 = new Gtk.HBox(); - w10.Spacing = 2; - // Container child GtkHBox.Gtk.Container+ContainerChild - Gtk.Image w11 = new Gtk.Image(); - w11.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-add", Gtk.IconSize.Button, 20); - w10.Add(w11); - // Container child GtkHBox.Gtk.Container+ContainerChild - Gtk.Label w13 = new Gtk.Label(); - w13.LabelProp = Mono.Unix.Catalog.GetString("_Install Add-ins..."); - w13.UseUnderline = true; - w10.Add(w13); - w9.Add(w10); - this.btnInstall.Add(w9); - this.vbox933.Add(this.btnInstall); - Gtk.Box.BoxChild w17 = ((Gtk.Box.BoxChild)(this.vbox933[this.btnInstall])); - w17.Position = 0; - w17.Expand = false; - w17.Fill = false; - // Container child vbox933.Gtk.Box+BoxChild - this.btnRepositories = new Gtk.Button(); - this.btnRepositories.CanFocus = true; - this.btnRepositories.Name = "btnRepositories"; - this.btnRepositories.UseUnderline = true; - this.btnRepositories.Label = Mono.Unix.Catalog.GetString("_Repositories..."); - this.vbox933.Add(this.btnRepositories); - Gtk.Box.BoxChild w18 = ((Gtk.Box.BoxChild)(this.vbox933[this.btnRepositories])); - w18.Position = 1; - w18.Expand = false; - w18.Fill = false; - // Container child vbox933.Gtk.Box+BoxChild - this.hseparator4 = new Gtk.HSeparator(); - this.hseparator4.Name = "hseparator4"; - this.vbox933.Add(this.hseparator4); - Gtk.Box.BoxChild w19 = ((Gtk.Box.BoxChild)(this.vbox933[this.hseparator4])); - w19.Position = 2; - w19.Expand = false; - w19.Fill = false; - // Container child vbox933.Gtk.Box+BoxChild - this.btnUninstall = new Gtk.Button(); - this.btnUninstall.CanFocus = true; - this.btnUninstall.Name = "btnUninstall"; - this.btnUninstall.UseUnderline = true; - // Container child btnUninstall.Gtk.Container+ContainerChild - Gtk.Alignment w20 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F); - // Container child GtkAlignment1.Gtk.Container+ContainerChild - Gtk.HBox w21 = new Gtk.HBox(); - w21.Spacing = 2; - // Container child GtkHBox1.Gtk.Container+ContainerChild - Gtk.Image w22 = new Gtk.Image(); - w22.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-remove", Gtk.IconSize.Button, 20); - w21.Add(w22); - // Container child GtkHBox1.Gtk.Container+ContainerChild - Gtk.Label w24 = new Gtk.Label(); - w24.LabelProp = Mono.Unix.Catalog.GetString("_Uninstall..."); - w24.UseUnderline = true; - w21.Add(w24); - w20.Add(w21); - this.btnUninstall.Add(w20); - this.vbox933.Add(this.btnUninstall); - Gtk.Box.BoxChild w28 = ((Gtk.Box.BoxChild)(this.vbox933[this.btnUninstall])); - w28.Position = 3; - w28.Expand = false; - w28.Fill = false; - // Container child vbox933.Gtk.Box+BoxChild - this.btnEnable = new Gtk.Button(); - this.btnEnable.CanFocus = true; - this.btnEnable.Name = "btnEnable"; - this.btnEnable.UseUnderline = true; - // Container child btnEnable.Gtk.Container+ContainerChild - Gtk.Alignment w29 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F); - // Container child GtkAlignment2.Gtk.Container+ContainerChild - Gtk.HBox w30 = new Gtk.HBox(); - w30.Spacing = 2; - // Container child GtkHBox2.Gtk.Container+ContainerChild - Gtk.Image w31 = new Gtk.Image(); - w31.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-yes", Gtk.IconSize.Button, 20); - w30.Add(w31); - // Container child GtkHBox2.Gtk.Container+ContainerChild - Gtk.Label w33 = new Gtk.Label(); - w33.LabelProp = Mono.Unix.Catalog.GetString("Enable"); - w33.UseUnderline = true; - w30.Add(w33); - w29.Add(w30); - this.btnEnable.Add(w29); - this.vbox933.Add(this.btnEnable); - Gtk.Box.BoxChild w37 = ((Gtk.Box.BoxChild)(this.vbox933[this.btnEnable])); - w37.Position = 4; - w37.Expand = false; - w37.Fill = false; - // Container child vbox933.Gtk.Box+BoxChild - this.btnDisable = new Gtk.Button(); - this.btnDisable.CanFocus = true; - this.btnDisable.Name = "btnDisable"; - this.btnDisable.UseUnderline = true; - // Container child btnDisable.Gtk.Container+ContainerChild - Gtk.Alignment w38 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F); - // Container child GtkAlignment3.Gtk.Container+ContainerChild - Gtk.HBox w39 = new Gtk.HBox(); - w39.Spacing = 2; - // Container child GtkHBox3.Gtk.Container+ContainerChild - Gtk.Image w40 = new Gtk.Image(); - w40.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-no", Gtk.IconSize.Button, 20); - w39.Add(w40); - // Container child GtkHBox3.Gtk.Container+ContainerChild - Gtk.Label w42 = new Gtk.Label(); - w42.LabelProp = Mono.Unix.Catalog.GetString("Disable"); - w42.UseUnderline = true; - w39.Add(w42); - w38.Add(w39); - this.btnDisable.Add(w38); - this.vbox933.Add(this.btnDisable); - Gtk.Box.BoxChild w46 = ((Gtk.Box.BoxChild)(this.vbox933[this.btnDisable])); - w46.Position = 5; - w46.Expand = false; - w46.Fill = false; - // Container child vbox933.Gtk.Box+BoxChild - this.btnInfo = new Gtk.Button(); - this.btnInfo.CanFocus = true; - this.btnInfo.Name = "btnInfo"; - this.btnInfo.UseStock = true; - this.btnInfo.UseUnderline = true; - this.btnInfo.Label = "gtk-dialog-info"; - this.vbox933.Add(this.btnInfo); - Gtk.Box.BoxChild w47 = ((Gtk.Box.BoxChild)(this.vbox933[this.btnInfo])); - w47.Position = 6; - w47.Expand = false; - w47.Fill = false; - this.hbox72.Add(this.vbox933); - Gtk.Box.BoxChild w48 = ((Gtk.Box.BoxChild)(this.hbox72[this.vbox933])); - w48.Position = 1; - w48.Expand = false; - w48.Fill = false; - this.hbox65.Add(this.hbox72); - Gtk.Box.BoxChild w49 = ((Gtk.Box.BoxChild)(this.hbox65[this.hbox72])); - w49.Position = 0; - this.vbox93.Add(this.hbox65); - Gtk.Box.BoxChild w50 = ((Gtk.Box.BoxChild)(this.vbox93[this.hbox65])); - w50.Position = 2; - w1.Add(this.vbox93); - Gtk.Box.BoxChild w51 = ((Gtk.Box.BoxChild)(w1[this.vbox93])); - w51.Position = 0; - // Internal child Mono.Addins.Gui.AddinManagerDialog.ActionArea - Gtk.HButtonBox w52 = this.ActionArea; - w52.Name = "dialog-action_area8"; - w52.Spacing = 6; - w52.BorderWidth = ((uint)(5)); - w52.LayoutStyle = ((Gtk.ButtonBoxStyle)(4)); - // Container child dialog-action_area8.Gtk.ButtonBox+ButtonBoxChild - this.btnClose = new Gtk.Button(); - this.btnClose.CanDefault = true; - this.btnClose.CanFocus = true; - this.btnClose.Name = "btnClose"; - this.btnClose.UseStock = true; - this.btnClose.UseUnderline = true; - this.btnClose.Label = "gtk-close"; - this.AddActionWidget(this.btnClose, -7); - if ((this.Child != null)) { - this.Child.ShowAll(); - } - this.Show(); - this.addinTree.CursorChanged += new System.EventHandler(this.OnSelectionChanged); - this.btnInstall.Clicked += new System.EventHandler(this.OnInstall); - this.btnRepositories.Clicked += new System.EventHandler(this.OnManageRepos); - this.btnUninstall.Clicked += new System.EventHandler(this.OnUninstall); - this.btnEnable.Clicked += new System.EventHandler(this.OnEnable); - this.btnDisable.Clicked += new System.EventHandler(this.OnDisable); - this.btnInfo.Clicked += new System.EventHandler(this.OnShowInfo); - } - } +// This file has been generated by the GUI designer. Do not modify. +namespace Mono.Addins.Gui +{ + internal partial class AddinManagerDialog + { + private global::Gtk.VBox vbox93; + private global::Gtk.HBox hbox65; + private global::Gtk.HBox hbox72; + private global::Gtk.Notebook notebook; + private global::Gtk.HBox hbox2; + private global::Gtk.VBox vbox6; + private global::Gtk.ScrolledWindow scrolledwindow13; + private global::Gtk.TreeView addinTree; + private global::Gtk.EventBox eventbox2; + private global::Mono.Addins.Gui.AddinInfoView addininfoInstalled; + private global::Gtk.Label label7; + private global::Gtk.HBox boxUpdates; + private global::Gtk.VBox vboxUpdates; + private global::Gtk.EventBox eboxRepoUpdates; + private global::Gtk.HBox hbox67; + private global::Gtk.Label labelUpdates; + private global::Gtk.Button buttonRefreshUpdates; + private global::Gtk.Button buttonUpdateAll; + private global::Gtk.ScrolledWindow scrolledUpdates; + private global::Gtk.TreeView updatesTreeView; + private global::Gtk.EventBox eventbox3; + private global::Mono.Addins.Gui.AddinInfoView addininfoUpdates; + private global::Gtk.Label label4; + private global::Gtk.HBox hbox6; + private global::Gtk.VBox vboxGallery; + private global::Gtk.EventBox eboxRepo; + private global::Gtk.HBox hbox66; + private global::Gtk.Label label112; + private global::Gtk.ComboBox repoCombo; + private global::Gtk.Button buttonRefresh; + private global::Gtk.ScrolledWindow scrolledGallery; + private global::Gtk.TreeView galleryTreeView; + private global::Gtk.EventBox eventbox1; + private global::Mono.Addins.Gui.AddinInfoView addininfoGallery; + private global::Gtk.Label label8; + private global::Gtk.Button buttonInstallFromFile; + private global::Gtk.Button btnClose; + + protected virtual void Build () + { + global::Stetic.Gui.Initialize (this); + // Widget Mono.Addins.Gui.AddinManagerDialog + this.Name = "Mono.Addins.Gui.AddinManagerDialog"; + this.Title = global::Mono.Unix.Catalog.GetString ("Add-in Manager"); + this.TypeHint = ((global::Gdk.WindowTypeHint)(1)); + this.BorderWidth = ((uint)(6)); + this.DefaultWidth = 700; + this.DefaultHeight = 550; + // Internal child Mono.Addins.Gui.AddinManagerDialog.VBox + global::Gtk.VBox w1 = this.VBox; + w1.Name = "dialog-vbox8"; + w1.Spacing = 3; + w1.BorderWidth = ((uint)(2)); + // Container child dialog-vbox8.Gtk.Box+BoxChild + this.vbox93 = new global::Gtk.VBox (); + this.vbox93.Name = "vbox93"; + this.vbox93.Spacing = 6; + this.vbox93.BorderWidth = ((uint)(6)); + // Container child vbox93.Gtk.Box+BoxChild + this.hbox65 = new global::Gtk.HBox (); + this.hbox65.Name = "hbox65"; + this.hbox65.Spacing = 12; + // Container child hbox65.Gtk.Box+BoxChild + this.hbox72 = new global::Gtk.HBox (); + this.hbox72.Name = "hbox72"; + this.hbox72.Spacing = 12; + // Container child hbox72.Gtk.Box+BoxChild + this.notebook = new global::Gtk.Notebook (); + this.notebook.CanFocus = true; + this.notebook.Name = "notebook"; + this.notebook.CurrentPage = 0; + this.notebook.ShowBorder = false; + // Container child notebook.Gtk.Notebook+NotebookChild + this.hbox2 = new global::Gtk.HBox (); + this.hbox2.Name = "hbox2"; + this.hbox2.Spacing = 9; + this.hbox2.BorderWidth = ((uint)(9)); + // Container child hbox2.Gtk.Box+BoxChild + this.vbox6 = new global::Gtk.VBox (); + this.vbox6.Name = "vbox6"; + this.vbox6.Spacing = 6; + // Container child vbox6.Gtk.Box+BoxChild + this.scrolledwindow13 = new global::Gtk.ScrolledWindow (); + this.scrolledwindow13.CanFocus = true; + this.scrolledwindow13.Name = "scrolledwindow13"; + this.scrolledwindow13.ShadowType = ((global::Gtk.ShadowType)(1)); + // Container child scrolledwindow13.Gtk.Container+ContainerChild + this.addinTree = new global::Gtk.TreeView (); + this.addinTree.CanFocus = true; + this.addinTree.Name = "addinTree"; + this.scrolledwindow13.Add (this.addinTree); + this.vbox6.Add (this.scrolledwindow13); + global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.vbox6 [this.scrolledwindow13])); + w3.Position = 0; + this.hbox2.Add (this.vbox6); + global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.vbox6])); + w4.Position = 0; + // Container child hbox2.Gtk.Box+BoxChild + this.eventbox2 = new global::Gtk.EventBox (); + this.eventbox2.Name = "eventbox2"; + // Container child eventbox2.Gtk.Container+ContainerChild + this.addininfoInstalled = new global::Mono.Addins.Gui.AddinInfoView (); + this.addininfoInstalled.Events = ((global::Gdk.EventMask)(256)); + this.addininfoInstalled.Name = "addininfoInstalled"; + this.addininfoInstalled.AllowInstall = false; + this.eventbox2.Add (this.addininfoInstalled); + this.hbox2.Add (this.eventbox2); + global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.eventbox2])); + w6.Position = 1; + w6.Expand = false; + w6.Fill = false; + this.notebook.Add (this.hbox2); + // Notebook tab + this.label7 = new global::Gtk.Label (); + this.label7.Name = "label7"; + this.label7.LabelProp = global::Mono.Unix.Catalog.GetString ("Installed"); + this.notebook.SetTabLabel (this.hbox2, this.label7); + this.label7.ShowAll (); + // Container child notebook.Gtk.Notebook+NotebookChild + this.boxUpdates = new global::Gtk.HBox (); + this.boxUpdates.Name = "boxUpdates"; + this.boxUpdates.Spacing = 9; + this.boxUpdates.BorderWidth = ((uint)(9)); + // Container child boxUpdates.Gtk.Box+BoxChild + this.vboxUpdates = new global::Gtk.VBox (); + this.vboxUpdates.Name = "vboxUpdates"; + // Container child vboxUpdates.Gtk.Box+BoxChild + this.eboxRepoUpdates = new global::Gtk.EventBox (); + this.eboxRepoUpdates.Name = "eboxRepoUpdates"; + // Container child eboxRepoUpdates.Gtk.Container+ContainerChild + this.hbox67 = new global::Gtk.HBox (); + this.hbox67.Name = "hbox67"; + this.hbox67.Spacing = 6; + // Container child hbox67.Gtk.Box+BoxChild + this.labelUpdates = new global::Gtk.Label (); + this.labelUpdates.Name = "labelUpdates"; + this.labelUpdates.LabelProp = global::Mono.Unix.Catalog.GetString ("No updates found"); + this.hbox67.Add (this.labelUpdates); + global::Gtk.Box.BoxChild w8 = ((global::Gtk.Box.BoxChild)(this.hbox67 [this.labelUpdates])); + w8.Position = 0; + w8.Expand = false; + w8.Fill = false; + // Container child hbox67.Gtk.Box+BoxChild + this.buttonRefreshUpdates = new global::Gtk.Button (); + this.buttonRefreshUpdates.CanFocus = true; + this.buttonRefreshUpdates.Name = "buttonRefreshUpdates"; + this.buttonRefreshUpdates.UseUnderline = true; + this.buttonRefreshUpdates.Relief = ((global::Gtk.ReliefStyle)(2)); + // Container child buttonRefreshUpdates.Gtk.Container+ContainerChild + global::Gtk.Alignment w9 = new global::Gtk.Alignment (0.5F, 0.5F, 0F, 0F); + // Container child GtkAlignment.Gtk.Container+ContainerChild + global::Gtk.HBox w10 = new global::Gtk.HBox (); + w10.Spacing = 2; + // Container child GtkHBox.Gtk.Container+ContainerChild + global::Gtk.Image w11 = new global::Gtk.Image (); + w11.Pixbuf = global::Stetic.IconLoader.LoadIcon (this, "gtk-refresh", global::Gtk.IconSize.Menu); + w10.Add (w11); + // Container child GtkHBox.Gtk.Container+ContainerChild + global::Gtk.Label w13 = new global::Gtk.Label (); + w13.LabelProp = global::Mono.Unix.Catalog.GetString ("Refresh"); + w13.UseUnderline = true; + w10.Add (w13); + w9.Add (w10); + this.buttonRefreshUpdates.Add (w9); + this.hbox67.Add (this.buttonRefreshUpdates); + global::Gtk.Box.BoxChild w17 = ((global::Gtk.Box.BoxChild)(this.hbox67 [this.buttonRefreshUpdates])); + w17.PackType = ((global::Gtk.PackType)(1)); + w17.Position = 1; + w17.Expand = false; + w17.Fill = false; + // Container child hbox67.Gtk.Box+BoxChild + this.buttonUpdateAll = new global::Gtk.Button (); + this.buttonUpdateAll.CanFocus = true; + this.buttonUpdateAll.Name = "buttonUpdateAll"; + this.buttonUpdateAll.UseUnderline = true; + this.buttonUpdateAll.Relief = ((global::Gtk.ReliefStyle)(2)); + // Container child buttonUpdateAll.Gtk.Container+ContainerChild + global::Gtk.Alignment w18 = new global::Gtk.Alignment (0.5F, 0.5F, 0F, 0F); + // Container child GtkAlignment.Gtk.Container+ContainerChild + global::Gtk.HBox w19 = new global::Gtk.HBox (); + w19.Spacing = 2; + // Container child GtkHBox.Gtk.Container+ContainerChild + global::Gtk.Image w20 = new global::Gtk.Image (); + w20.Pixbuf = global::Gdk.Pixbuf.LoadFromResource ("download.png"); + w19.Add (w20); + // Container child GtkHBox.Gtk.Container+ContainerChild + global::Gtk.Label w22 = new global::Gtk.Label (); + w22.LabelProp = global::Mono.Unix.Catalog.GetString ("Update All"); + w22.UseUnderline = true; + w19.Add (w22); + w18.Add (w19); + this.buttonUpdateAll.Add (w18); + this.hbox67.Add (this.buttonUpdateAll); + global::Gtk.Box.BoxChild w26 = ((global::Gtk.Box.BoxChild)(this.hbox67 [this.buttonUpdateAll])); + w26.PackType = ((global::Gtk.PackType)(1)); + w26.Position = 2; + w26.Expand = false; + w26.Fill = false; + this.eboxRepoUpdates.Add (this.hbox67); + this.vboxUpdates.Add (this.eboxRepoUpdates); + global::Gtk.Box.BoxChild w28 = ((global::Gtk.Box.BoxChild)(this.vboxUpdates [this.eboxRepoUpdates])); + w28.Position = 0; + w28.Expand = false; + w28.Fill = false; + // Container child vboxUpdates.Gtk.Box+BoxChild + this.scrolledUpdates = new global::Gtk.ScrolledWindow (); + this.scrolledUpdates.CanFocus = true; + this.scrolledUpdates.Name = "scrolledUpdates"; + this.scrolledUpdates.ShadowType = ((global::Gtk.ShadowType)(1)); + // Container child scrolledUpdates.Gtk.Container+ContainerChild + this.updatesTreeView = new global::Gtk.TreeView (); + this.updatesTreeView.CanFocus = true; + this.updatesTreeView.Name = "updatesTreeView"; + this.scrolledUpdates.Add (this.updatesTreeView); + this.vboxUpdates.Add (this.scrolledUpdates); + global::Gtk.Box.BoxChild w30 = ((global::Gtk.Box.BoxChild)(this.vboxUpdates [this.scrolledUpdates])); + w30.Position = 1; + this.boxUpdates.Add (this.vboxUpdates); + global::Gtk.Box.BoxChild w31 = ((global::Gtk.Box.BoxChild)(this.boxUpdates [this.vboxUpdates])); + w31.Position = 0; + // Container child boxUpdates.Gtk.Box+BoxChild + this.eventbox3 = new global::Gtk.EventBox (); + this.eventbox3.Name = "eventbox3"; + // Container child eventbox3.Gtk.Container+ContainerChild + this.addininfoUpdates = new global::Mono.Addins.Gui.AddinInfoView (); + this.addininfoUpdates.Events = ((global::Gdk.EventMask)(256)); + this.addininfoUpdates.Name = "addininfoUpdates"; + this.addininfoUpdates.AllowInstall = false; + this.eventbox3.Add (this.addininfoUpdates); + this.boxUpdates.Add (this.eventbox3); + global::Gtk.Box.BoxChild w33 = ((global::Gtk.Box.BoxChild)(this.boxUpdates [this.eventbox3])); + w33.Position = 1; + w33.Expand = false; + w33.Fill = false; + this.notebook.Add (this.boxUpdates); + global::Gtk.Notebook.NotebookChild w34 = ((global::Gtk.Notebook.NotebookChild)(this.notebook [this.boxUpdates])); + w34.Position = 1; + // Notebook tab + this.label4 = new global::Gtk.Label (); + this.label4.Name = "label4"; + this.label4.LabelProp = global::Mono.Unix.Catalog.GetString ("Updates"); + this.notebook.SetTabLabel (this.boxUpdates, this.label4); + this.label4.ShowAll (); + // Container child notebook.Gtk.Notebook+NotebookChild + this.hbox6 = new global::Gtk.HBox (); + this.hbox6.Name = "hbox6"; + this.hbox6.Spacing = 9; + this.hbox6.BorderWidth = ((uint)(9)); + // Container child hbox6.Gtk.Box+BoxChild + this.vboxGallery = new global::Gtk.VBox (); + this.vboxGallery.Name = "vboxGallery"; + // Container child vboxGallery.Gtk.Box+BoxChild + this.eboxRepo = new global::Gtk.EventBox (); + this.eboxRepo.Name = "eboxRepo"; + // Container child eboxRepo.Gtk.Container+ContainerChild + this.hbox66 = new global::Gtk.HBox (); + this.hbox66.Name = "hbox66"; + this.hbox66.Spacing = 6; + // Container child hbox66.Gtk.Box+BoxChild + this.label112 = new global::Gtk.Label (); + this.label112.Name = "label112"; + this.label112.LabelProp = global::Mono.Unix.Catalog.GetString ("Repository:"); + this.hbox66.Add (this.label112); + global::Gtk.Box.BoxChild w35 = ((global::Gtk.Box.BoxChild)(this.hbox66 [this.label112])); + w35.Position = 0; + w35.Expand = false; + w35.Fill = false; + // Container child hbox66.Gtk.Box+BoxChild + this.repoCombo = new global::Gtk.ComboBox (); + this.repoCombo.Name = "repoCombo"; + this.hbox66.Add (this.repoCombo); + global::Gtk.Box.BoxChild w36 = ((global::Gtk.Box.BoxChild)(this.hbox66 [this.repoCombo])); + w36.Position = 1; + // Container child hbox66.Gtk.Box+BoxChild + this.buttonRefresh = new global::Gtk.Button (); + this.buttonRefresh.CanFocus = true; + this.buttonRefresh.Name = "buttonRefresh"; + this.buttonRefresh.UseUnderline = true; + this.buttonRefresh.Relief = ((global::Gtk.ReliefStyle)(2)); + // Container child buttonRefresh.Gtk.Container+ContainerChild + global::Gtk.Alignment w37 = new global::Gtk.Alignment (0.5F, 0.5F, 0F, 0F); + // Container child GtkAlignment.Gtk.Container+ContainerChild + global::Gtk.HBox w38 = new global::Gtk.HBox (); + w38.Spacing = 2; + // Container child GtkHBox.Gtk.Container+ContainerChild + global::Gtk.Image w39 = new global::Gtk.Image (); + w39.Pixbuf = global::Stetic.IconLoader.LoadIcon (this, "gtk-refresh", global::Gtk.IconSize.Menu); + w38.Add (w39); + // Container child GtkHBox.Gtk.Container+ContainerChild + global::Gtk.Label w41 = new global::Gtk.Label (); + w38.Add (w41); + w37.Add (w38); + this.buttonRefresh.Add (w37); + this.hbox66.Add (this.buttonRefresh); + global::Gtk.Box.BoxChild w45 = ((global::Gtk.Box.BoxChild)(this.hbox66 [this.buttonRefresh])); + w45.Position = 2; + w45.Expand = false; + w45.Fill = false; + this.eboxRepo.Add (this.hbox66); + this.vboxGallery.Add (this.eboxRepo); + global::Gtk.Box.BoxChild w47 = ((global::Gtk.Box.BoxChild)(this.vboxGallery [this.eboxRepo])); + w47.Position = 0; + w47.Expand = false; + w47.Fill = false; + // Container child vboxGallery.Gtk.Box+BoxChild + this.scrolledGallery = new global::Gtk.ScrolledWindow (); + this.scrolledGallery.CanFocus = true; + this.scrolledGallery.Name = "scrolledGallery"; + this.scrolledGallery.ShadowType = ((global::Gtk.ShadowType)(1)); + // Container child scrolledGallery.Gtk.Container+ContainerChild + this.galleryTreeView = new global::Gtk.TreeView (); + this.galleryTreeView.CanFocus = true; + this.galleryTreeView.Name = "galleryTreeView"; + this.scrolledGallery.Add (this.galleryTreeView); + this.vboxGallery.Add (this.scrolledGallery); + global::Gtk.Box.BoxChild w49 = ((global::Gtk.Box.BoxChild)(this.vboxGallery [this.scrolledGallery])); + w49.Position = 1; + this.hbox6.Add (this.vboxGallery); + global::Gtk.Box.BoxChild w50 = ((global::Gtk.Box.BoxChild)(this.hbox6 [this.vboxGallery])); + w50.Position = 0; + // Container child hbox6.Gtk.Box+BoxChild + this.eventbox1 = new global::Gtk.EventBox (); + this.eventbox1.Name = "eventbox1"; + // Container child eventbox1.Gtk.Container+ContainerChild + this.addininfoGallery = new global::Mono.Addins.Gui.AddinInfoView (); + this.addininfoGallery.Events = ((global::Gdk.EventMask)(256)); + this.addininfoGallery.Name = "addininfoGallery"; + this.addininfoGallery.AllowInstall = false; + this.eventbox1.Add (this.addininfoGallery); + this.hbox6.Add (this.eventbox1); + global::Gtk.Box.BoxChild w52 = ((global::Gtk.Box.BoxChild)(this.hbox6 [this.eventbox1])); + w52.Position = 1; + w52.Expand = false; + w52.Fill = false; + this.notebook.Add (this.hbox6); + global::Gtk.Notebook.NotebookChild w53 = ((global::Gtk.Notebook.NotebookChild)(this.notebook [this.hbox6])); + w53.Position = 2; + // Notebook tab + this.label8 = new global::Gtk.Label (); + this.label8.Name = "label8"; + this.label8.LabelProp = global::Mono.Unix.Catalog.GetString ("Gallery"); + this.notebook.SetTabLabel (this.hbox6, this.label8); + this.label8.ShowAll (); + this.hbox72.Add (this.notebook); + global::Gtk.Box.BoxChild w54 = ((global::Gtk.Box.BoxChild)(this.hbox72 [this.notebook])); + w54.Position = 0; + this.hbox65.Add (this.hbox72); + global::Gtk.Box.BoxChild w55 = ((global::Gtk.Box.BoxChild)(this.hbox65 [this.hbox72])); + w55.Position = 0; + this.vbox93.Add (this.hbox65); + global::Gtk.Box.BoxChild w56 = ((global::Gtk.Box.BoxChild)(this.vbox93 [this.hbox65])); + w56.Position = 0; + w1.Add (this.vbox93); + global::Gtk.Box.BoxChild w57 = ((global::Gtk.Box.BoxChild)(w1 [this.vbox93])); + w57.Position = 0; + // Internal child Mono.Addins.Gui.AddinManagerDialog.ActionArea + global::Gtk.HButtonBox w58 = this.ActionArea; + w58.Name = "dialog-action_area8"; + w58.Spacing = 6; + w58.BorderWidth = ((uint)(5)); + w58.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(2)); + // Container child dialog-action_area8.Gtk.ButtonBox+ButtonBoxChild + this.buttonInstallFromFile = new global::Gtk.Button (); + this.buttonInstallFromFile.CanFocus = true; + this.buttonInstallFromFile.Name = "buttonInstallFromFile"; + this.buttonInstallFromFile.UseUnderline = true; + this.buttonInstallFromFile.Label = global::Mono.Unix.Catalog.GetString ("Install from file..."); + w58.Add (this.buttonInstallFromFile); + global::Gtk.ButtonBox.ButtonBoxChild w59 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w58 [this.buttonInstallFromFile])); + w59.Expand = false; + w59.Fill = false; + // Container child dialog-action_area8.Gtk.ButtonBox+ButtonBoxChild + this.btnClose = new global::Gtk.Button (); + this.btnClose.CanDefault = true; + this.btnClose.CanFocus = true; + this.btnClose.Name = "btnClose"; + this.btnClose.UseStock = true; + this.btnClose.UseUnderline = true; + this.btnClose.Label = "gtk-close"; + this.AddActionWidget (this.btnClose, -7); + global::Gtk.ButtonBox.ButtonBoxChild w60 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w58 [this.btnClose])); + w60.Position = 1; + w60.Expand = false; + w60.Fill = false; + if ((this.Child != null)) { + this.Child.ShowAll (); + } + this.Hide (); + this.addininfoInstalled.InstallClicked += new global::System.EventHandler (this.OnInstallClicked); + this.addininfoInstalled.UninstallClicked += new global::System.EventHandler (this.OnUninstallClicked); + this.addininfoInstalled.UpdateClicked += new global::System.EventHandler (this.OnUpdateClicked); + this.addininfoInstalled.EnableDisableClicked += new global::System.EventHandler (this.OnEnableDisableClicked); + this.buttonUpdateAll.Clicked += new global::System.EventHandler (this.OnUpdateAll); + this.buttonRefreshUpdates.Clicked += new global::System.EventHandler (this.OnButtonRefreshClicked); + this.addininfoUpdates.InstallClicked += new global::System.EventHandler (this.OnInstallClicked); + this.addininfoUpdates.UninstallClicked += new global::System.EventHandler (this.OnUninstallClicked); + this.addininfoUpdates.UpdateClicked += new global::System.EventHandler (this.OnUpdateClicked); + this.addininfoUpdates.EnableDisableClicked += new global::System.EventHandler (this.OnEnableDisableClicked); + this.repoCombo.Changed += new global::System.EventHandler (this.OnRepoComboChanged); + this.buttonRefresh.Clicked += new global::System.EventHandler (this.OnButtonRefreshClicked); + this.addininfoGallery.InstallClicked += new global::System.EventHandler (this.OnInstallClicked); + this.addininfoGallery.UninstallClicked += new global::System.EventHandler (this.OnUninstallClicked); + this.addininfoGallery.UpdateClicked += new global::System.EventHandler (this.OnUpdateClicked); + this.addininfoGallery.EnableDisableClicked += new global::System.EventHandler (this.OnEnableDisableClicked); + this.buttonInstallFromFile.Clicked += new global::System.EventHandler (this.OnButtonInstallFromFileClicked); + } + } } diff -Nru mono-addins-0.4/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.ErrorDialog.cs mono-addins-0.6.1/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.ErrorDialog.cs --- mono-addins-0.4/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.ErrorDialog.cs 2008-11-06 19:51:59.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.ErrorDialog.cs 2011-04-13 09:00:29.000000000 +0000 @@ -1,143 +1,129 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Mono Runtime Version: 2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ -namespace Mono.Addins.Gui { - - - internal partial class ErrorDialog { - - private Gtk.HBox hbox59; - - private Gtk.VBox vbox72; - - private Gtk.Image icon; - - private Gtk.VBox vbox73; - - private Gtk.Label descriptionLabel; - - private Gtk.Expander expander; - - private Gtk.ScrolledWindow scrolledwindow10; - - private Gtk.TextView detailsTextView; - - private Gtk.Label label102; - - private Gtk.Button okButton; - - protected virtual void Build() { - Stetic.Gui.Initialize(this); - // Widget Mono.Addins.Gui.ErrorDialog - this.Name = "Mono.Addins.Gui.ErrorDialog"; - this.Title = Mono.Unix.Catalog.GetString("Error"); - this.TypeHint = ((Gdk.WindowTypeHint)(1)); - this.BorderWidth = ((uint)(6)); - // Internal child Mono.Addins.Gui.ErrorDialog.VBox - Gtk.VBox w1 = this.VBox; - w1.Name = "dialog-vbox5"; - w1.Spacing = 6; - // Container child dialog-vbox5.Gtk.Box+BoxChild - this.hbox59 = new Gtk.HBox(); - this.hbox59.Name = "hbox59"; - this.hbox59.Spacing = 6; - this.hbox59.BorderWidth = ((uint)(6)); - // Container child hbox59.Gtk.Box+BoxChild - this.vbox72 = new Gtk.VBox(); - this.vbox72.Name = "vbox72"; - // Container child vbox72.Gtk.Box+BoxChild - this.icon = new Gtk.Image(); - this.icon.Name = "icon"; - this.icon.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-dialog-error", Gtk.IconSize.Dialog, 48); - this.vbox72.Add(this.icon); - Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(this.vbox72[this.icon])); - w2.Position = 0; - w2.Expand = false; - w2.Fill = false; - this.hbox59.Add(this.vbox72); - Gtk.Box.BoxChild w3 = ((Gtk.Box.BoxChild)(this.hbox59[this.vbox72])); - w3.Position = 0; - w3.Expand = false; - w3.Fill = false; - // Container child hbox59.Gtk.Box+BoxChild - this.vbox73 = new Gtk.VBox(); - this.vbox73.Name = "vbox73"; - this.vbox73.Spacing = 12; - // Container child vbox73.Gtk.Box+BoxChild - this.descriptionLabel = new Gtk.Label(); - this.descriptionLabel.WidthRequest = 540; - this.descriptionLabel.CanFocus = true; - this.descriptionLabel.Name = "descriptionLabel"; - this.descriptionLabel.Xalign = 0F; - this.descriptionLabel.LabelProp = "An exception has been thrown 1 2 3 4 5 6 7 8 9 10 11 12 13 14"; - this.descriptionLabel.Wrap = true; - this.descriptionLabel.Selectable = true; - this.vbox73.Add(this.descriptionLabel); - Gtk.Box.BoxChild w4 = ((Gtk.Box.BoxChild)(this.vbox73[this.descriptionLabel])); - w4.Position = 0; - w4.Expand = false; - w4.Fill = false; - // Container child vbox73.Gtk.Box+BoxChild - this.expander = new Gtk.Expander(null); - this.expander.CanFocus = true; - this.expander.Name = "expander"; - // Container child expander.Gtk.Container+ContainerChild - this.scrolledwindow10 = new Gtk.ScrolledWindow(); - this.scrolledwindow10.CanFocus = true; - this.scrolledwindow10.Name = "scrolledwindow10"; - this.scrolledwindow10.ShadowType = ((Gtk.ShadowType)(1)); - // Container child scrolledwindow10.Gtk.Container+ContainerChild - this.detailsTextView = new Gtk.TextView(); - this.detailsTextView.HeightRequest = 250; - this.detailsTextView.CanFocus = true; - this.detailsTextView.Name = "detailsTextView"; - this.detailsTextView.PixelsAboveLines = 2; - this.detailsTextView.PixelsBelowLines = 2; - this.detailsTextView.LeftMargin = 6; - this.detailsTextView.RightMargin = 6; - this.scrolledwindow10.Add(this.detailsTextView); - this.expander.Add(this.scrolledwindow10); - this.label102 = new Gtk.Label(); - this.label102.Name = "label102"; - this.label102.LabelProp = Mono.Unix.Catalog.GetString("Details"); - this.expander.LabelWidget = this.label102; - this.vbox73.Add(this.expander); - Gtk.Box.BoxChild w7 = ((Gtk.Box.BoxChild)(this.vbox73[this.expander])); - w7.Position = 1; - this.hbox59.Add(this.vbox73); - Gtk.Box.BoxChild w8 = ((Gtk.Box.BoxChild)(this.hbox59[this.vbox73])); - w8.Position = 1; - w1.Add(this.hbox59); - Gtk.Box.BoxChild w9 = ((Gtk.Box.BoxChild)(w1[this.hbox59])); - w9.Position = 0; - // Internal child Mono.Addins.Gui.ErrorDialog.ActionArea - Gtk.HButtonBox w10 = this.ActionArea; - w10.Name = "dialog-action_area5"; - w10.Spacing = 10; - w10.BorderWidth = ((uint)(5)); - w10.LayoutStyle = ((Gtk.ButtonBoxStyle)(4)); - // Container child dialog-action_area5.Gtk.ButtonBox+ButtonBoxChild - this.okButton = new Gtk.Button(); - this.okButton.CanDefault = true; - this.okButton.CanFocus = true; - this.okButton.Name = "okButton"; - this.okButton.UseStock = true; - this.okButton.UseUnderline = true; - this.okButton.Label = "gtk-ok"; - this.AddActionWidget(this.okButton, -5); - if ((this.Child != null)) { - this.Child.ShowAll(); - } - this.DefaultWidth = 632; - this.DefaultHeight = 155; - this.Show(); - } - } +// This file has been generated by the GUI designer. Do not modify. +namespace Mono.Addins.Gui +{ + internal partial class ErrorDialog + { + private global::Gtk.HBox hbox59; + private global::Gtk.VBox vbox72; + private global::Gtk.Image icon; + private global::Gtk.VBox vbox73; + private global::Gtk.Label descriptionLabel; + private global::Gtk.Expander expander; + private global::Gtk.ScrolledWindow scrolledwindow10; + private global::Gtk.TextView detailsTextView; + private global::Gtk.Label label102; + private global::Gtk.Button okButton; + + protected virtual void Build () + { + global::Stetic.Gui.Initialize (this); + // Widget Mono.Addins.Gui.ErrorDialog + this.Name = "Mono.Addins.Gui.ErrorDialog"; + this.Title = global::Mono.Unix.Catalog.GetString ("Error"); + this.TypeHint = ((global::Gdk.WindowTypeHint)(1)); + this.BorderWidth = ((uint)(6)); + // Internal child Mono.Addins.Gui.ErrorDialog.VBox + global::Gtk.VBox w1 = this.VBox; + w1.Name = "dialog-vbox5"; + w1.Spacing = 6; + // Container child dialog-vbox5.Gtk.Box+BoxChild + this.hbox59 = new global::Gtk.HBox (); + this.hbox59.Name = "hbox59"; + this.hbox59.Spacing = 6; + this.hbox59.BorderWidth = ((uint)(6)); + // Container child hbox59.Gtk.Box+BoxChild + this.vbox72 = new global::Gtk.VBox (); + this.vbox72.Name = "vbox72"; + // Container child vbox72.Gtk.Box+BoxChild + this.icon = new global::Gtk.Image (); + this.icon.Name = "icon"; + this.icon.Pixbuf = global::Stetic.IconLoader.LoadIcon (this, "gtk-dialog-error", global::Gtk.IconSize.Dialog); + this.vbox72.Add (this.icon); + global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.vbox72 [this.icon])); + w2.Position = 0; + w2.Expand = false; + w2.Fill = false; + this.hbox59.Add (this.vbox72); + global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.hbox59 [this.vbox72])); + w3.Position = 0; + w3.Expand = false; + w3.Fill = false; + // Container child hbox59.Gtk.Box+BoxChild + this.vbox73 = new global::Gtk.VBox (); + this.vbox73.Name = "vbox73"; + this.vbox73.Spacing = 12; + // Container child vbox73.Gtk.Box+BoxChild + this.descriptionLabel = new global::Gtk.Label (); + this.descriptionLabel.WidthRequest = 540; + this.descriptionLabel.CanFocus = true; + this.descriptionLabel.Name = "descriptionLabel"; + this.descriptionLabel.Xalign = 0F; + this.descriptionLabel.LabelProp = "An exception has been thrown 1 2 3 4 5 6 7 8 9 10 11 12 13 14"; + this.descriptionLabel.Wrap = true; + this.descriptionLabel.Selectable = true; + this.vbox73.Add (this.descriptionLabel); + global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.vbox73 [this.descriptionLabel])); + w4.Position = 0; + w4.Expand = false; + w4.Fill = false; + // Container child vbox73.Gtk.Box+BoxChild + this.expander = new global::Gtk.Expander (null); + this.expander.CanFocus = true; + this.expander.Name = "expander"; + // Container child expander.Gtk.Container+ContainerChild + this.scrolledwindow10 = new global::Gtk.ScrolledWindow (); + this.scrolledwindow10.CanFocus = true; + this.scrolledwindow10.Name = "scrolledwindow10"; + this.scrolledwindow10.ShadowType = ((global::Gtk.ShadowType)(1)); + // Container child scrolledwindow10.Gtk.Container+ContainerChild + this.detailsTextView = new global::Gtk.TextView (); + this.detailsTextView.HeightRequest = 250; + this.detailsTextView.CanFocus = true; + this.detailsTextView.Name = "detailsTextView"; + this.detailsTextView.PixelsAboveLines = 2; + this.detailsTextView.PixelsBelowLines = 2; + this.detailsTextView.LeftMargin = 6; + this.detailsTextView.RightMargin = 6; + this.scrolledwindow10.Add (this.detailsTextView); + this.expander.Add (this.scrolledwindow10); + this.label102 = new global::Gtk.Label (); + this.label102.Name = "label102"; + this.label102.LabelProp = global::Mono.Unix.Catalog.GetString ("Details"); + this.expander.LabelWidget = this.label102; + this.vbox73.Add (this.expander); + global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.vbox73 [this.expander])); + w7.Position = 1; + this.hbox59.Add (this.vbox73); + global::Gtk.Box.BoxChild w8 = ((global::Gtk.Box.BoxChild)(this.hbox59 [this.vbox73])); + w8.Position = 1; + w1.Add (this.hbox59); + global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(w1 [this.hbox59])); + w9.Position = 0; + // Internal child Mono.Addins.Gui.ErrorDialog.ActionArea + global::Gtk.HButtonBox w10 = this.ActionArea; + w10.Name = "dialog-action_area5"; + w10.Spacing = 10; + w10.BorderWidth = ((uint)(5)); + w10.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4)); + // Container child dialog-action_area5.Gtk.ButtonBox+ButtonBoxChild + this.okButton = new global::Gtk.Button (); + this.okButton.CanDefault = true; + this.okButton.CanFocus = true; + this.okButton.Name = "okButton"; + this.okButton.UseStock = true; + this.okButton.UseUnderline = true; + this.okButton.Label = "gtk-ok"; + this.AddActionWidget (this.okButton, -5); + global::Gtk.ButtonBox.ButtonBoxChild w11 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w10 [this.okButton])); + w11.Expand = false; + w11.Fill = false; + if ((this.Child != null)) { + this.Child.ShowAll (); + } + this.DefaultWidth = 632; + this.DefaultHeight = 155; + this.Show (); + } + } } diff -Nru mono-addins-0.4/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.InstallDialog.cs mono-addins-0.6.1/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.InstallDialog.cs --- mono-addins-0.4/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.InstallDialog.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.InstallDialog.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,143 @@ + +// This file has been generated by the GUI designer. Do not modify. +namespace Mono.Addins.Gui +{ + internal partial class InstallDialog + { + private global::Gtk.VBox vbox3; + private global::Gtk.ScrolledWindow scrolledwindow1; + private global::Gtk.VBox vbox4; + private global::Gtk.Label labelInfo; + private global::Gtk.HSeparator insSeparator; + private global::Gtk.VBox boxProgress; + private global::Gtk.Label globalProgressLabel; + private global::Gtk.ProgressBar mainProgressBar; + private global::Gtk.Button buttonCancel; + private global::Gtk.Button buttonOk; + + protected virtual void Build () + { + global::Stetic.Gui.Initialize (this); + // Widget Mono.Addins.Gui.InstallDialog + this.Name = "Mono.Addins.Gui.InstallDialog"; + this.WindowPosition = ((global::Gtk.WindowPosition)(4)); + // Internal child Mono.Addins.Gui.InstallDialog.VBox + global::Gtk.VBox w1 = this.VBox; + w1.Name = "dialog1_VBox"; + w1.BorderWidth = ((uint)(2)); + // Container child dialog1_VBox.Gtk.Box+BoxChild + this.vbox3 = new global::Gtk.VBox (); + this.vbox3.Name = "vbox3"; + this.vbox3.Spacing = 9; + this.vbox3.BorderWidth = ((uint)(9)); + // Container child vbox3.Gtk.Box+BoxChild + this.scrolledwindow1 = new global::Gtk.ScrolledWindow (); + this.scrolledwindow1.CanFocus = true; + this.scrolledwindow1.Name = "scrolledwindow1"; + this.scrolledwindow1.VscrollbarPolicy = ((global::Gtk.PolicyType)(2)); + this.scrolledwindow1.HscrollbarPolicy = ((global::Gtk.PolicyType)(2)); + // Container child scrolledwindow1.Gtk.Container+ContainerChild + global::Gtk.Viewport w2 = new global::Gtk.Viewport (); + w2.ShadowType = ((global::Gtk.ShadowType)(0)); + // Container child GtkViewport.Gtk.Container+ContainerChild + this.vbox4 = new global::Gtk.VBox (); + this.vbox4.Name = "vbox4"; + this.vbox4.Spacing = 6; + // Container child vbox4.Gtk.Box+BoxChild + this.labelInfo = new global::Gtk.Label (); + this.labelInfo.WidthRequest = 400; + this.labelInfo.Name = "labelInfo"; + this.labelInfo.Xalign = 0F; + this.labelInfo.Yalign = 0F; + this.labelInfo.LabelProp = global::Mono.Unix.Catalog.GetString ("label3"); + this.labelInfo.Wrap = true; + this.vbox4.Add (this.labelInfo); + global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.vbox4 [this.labelInfo])); + w3.Position = 0; + w3.Expand = false; + w3.Fill = false; + w2.Add (this.vbox4); + this.scrolledwindow1.Add (w2); + this.vbox3.Add (this.scrolledwindow1); + global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.scrolledwindow1])); + w6.Position = 0; + // Container child vbox3.Gtk.Box+BoxChild + this.insSeparator = new global::Gtk.HSeparator (); + this.insSeparator.Name = "insSeparator"; + this.vbox3.Add (this.insSeparator); + global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.insSeparator])); + w7.Position = 1; + w7.Expand = false; + w7.Fill = false; + // Container child vbox3.Gtk.Box+BoxChild + this.boxProgress = new global::Gtk.VBox (); + this.boxProgress.Name = "boxProgress"; + this.boxProgress.Spacing = 6; + // Container child boxProgress.Gtk.Box+BoxChild + this.globalProgressLabel = new global::Gtk.Label (); + this.globalProgressLabel.Name = "globalProgressLabel"; + this.globalProgressLabel.Xalign = 0F; + this.globalProgressLabel.Ellipsize = ((global::Pango.EllipsizeMode)(3)); + this.boxProgress.Add (this.globalProgressLabel); + global::Gtk.Box.BoxChild w8 = ((global::Gtk.Box.BoxChild)(this.boxProgress [this.globalProgressLabel])); + w8.Position = 0; + w8.Expand = false; + w8.Fill = false; + // Container child boxProgress.Gtk.Box+BoxChild + this.mainProgressBar = new global::Gtk.ProgressBar (); + this.mainProgressBar.Name = "mainProgressBar"; + this.boxProgress.Add (this.mainProgressBar); + global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(this.boxProgress [this.mainProgressBar])); + w9.Position = 1; + w9.Expand = false; + w9.Fill = false; + this.vbox3.Add (this.boxProgress); + global::Gtk.Box.BoxChild w10 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.boxProgress])); + w10.Position = 2; + w10.Expand = false; + w10.Fill = false; + w1.Add (this.vbox3); + global::Gtk.Box.BoxChild w11 = ((global::Gtk.Box.BoxChild)(w1 [this.vbox3])); + w11.Position = 0; + // Internal child Mono.Addins.Gui.InstallDialog.ActionArea + global::Gtk.HButtonBox w12 = this.ActionArea; + w12.Name = "dialog1_ActionArea"; + w12.Spacing = 10; + w12.BorderWidth = ((uint)(5)); + w12.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4)); + // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.buttonCancel = new global::Gtk.Button (); + this.buttonCancel.CanDefault = true; + this.buttonCancel.CanFocus = true; + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.UseStock = true; + this.buttonCancel.UseUnderline = true; + this.buttonCancel.Label = "gtk-cancel"; + w12.Add (this.buttonCancel); + global::Gtk.ButtonBox.ButtonBoxChild w13 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w12 [this.buttonCancel])); + w13.Expand = false; + w13.Fill = false; + // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.buttonOk = new global::Gtk.Button (); + this.buttonOk.CanDefault = true; + this.buttonOk.CanFocus = true; + this.buttonOk.Name = "buttonOk"; + this.buttonOk.UseUnderline = true; + this.buttonOk.Label = global::Mono.Unix.Catalog.GetString ("Install"); + w12.Add (this.buttonOk); + global::Gtk.ButtonBox.ButtonBoxChild w14 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w12 [this.buttonOk])); + w14.Position = 1; + w14.Expand = false; + w14.Fill = false; + if ((this.Child != null)) { + this.Child.ShowAll (); + } + this.DefaultWidth = 494; + this.DefaultHeight = 239; + this.insSeparator.Hide (); + this.Hide (); + this.buttonCancel.Clicked += new global::System.EventHandler (this.OnButtonCancelClicked); + this.buttonOk.Clicked += new global::System.EventHandler (this.OnButtonOkClicked); + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.ManageSitesDialog.cs mono-addins-0.6.1/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.ManageSitesDialog.cs --- mono-addins-0.4/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.ManageSitesDialog.cs 2008-11-06 19:51:59.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.ManageSitesDialog.cs 2011-04-13 09:00:29.000000000 +0000 @@ -1,122 +1,110 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Mono Runtime Version: 2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ -namespace Mono.Addins.Gui { - - - internal partial class ManageSitesDialog { - - private Gtk.HBox hbox67; - - private Gtk.ScrolledWindow scrolledwindow17; - - private Gtk.TreeView repoTree; - - private Gtk.VBox vbox88; - - private Gtk.Button btnAdd; - - private Gtk.Button btnRemove; - - private Gtk.Button closebutton2; - - protected virtual void Build() { - Stetic.Gui.Initialize(this); - // Widget Mono.Addins.Gui.ManageSitesDialog - this.Name = "Mono.Addins.Gui.ManageSitesDialog"; - this.Title = Mono.Unix.Catalog.GetString("Add-in Repository Management"); - this.TypeHint = ((Gdk.WindowTypeHint)(1)); - this.BorderWidth = ((uint)(6)); - this.DefaultWidth = 600; - this.DefaultHeight = 300; - // Internal child Mono.Addins.Gui.ManageSitesDialog.VBox - Gtk.VBox w1 = this.VBox; - w1.Name = "dialog-vbox10"; - w1.Spacing = 6; - // Container child dialog-vbox10.Gtk.Box+BoxChild - this.hbox67 = new Gtk.HBox(); - this.hbox67.Name = "hbox67"; - this.hbox67.Spacing = 12; - this.hbox67.BorderWidth = ((uint)(6)); - // Container child hbox67.Gtk.Box+BoxChild - this.scrolledwindow17 = new Gtk.ScrolledWindow(); - this.scrolledwindow17.CanFocus = true; - this.scrolledwindow17.Name = "scrolledwindow17"; - this.scrolledwindow17.ShadowType = ((Gtk.ShadowType)(1)); - // Container child scrolledwindow17.Gtk.Container+ContainerChild - this.repoTree = new Gtk.TreeView(); - this.repoTree.CanFocus = true; - this.repoTree.Name = "repoTree"; - this.repoTree.HeadersVisible = false; - this.repoTree.HeadersClickable = true; - this.scrolledwindow17.Add(this.repoTree); - this.hbox67.Add(this.scrolledwindow17); - Gtk.Box.BoxChild w3 = ((Gtk.Box.BoxChild)(this.hbox67[this.scrolledwindow17])); - w3.Position = 0; - // Container child hbox67.Gtk.Box+BoxChild - this.vbox88 = new Gtk.VBox(); - this.vbox88.Name = "vbox88"; - this.vbox88.Spacing = 6; - // Container child vbox88.Gtk.Box+BoxChild - this.btnAdd = new Gtk.Button(); - this.btnAdd.CanFocus = true; - this.btnAdd.Name = "btnAdd"; - this.btnAdd.UseStock = true; - this.btnAdd.UseUnderline = true; - this.btnAdd.Label = "gtk-add"; - this.vbox88.Add(this.btnAdd); - Gtk.Box.BoxChild w4 = ((Gtk.Box.BoxChild)(this.vbox88[this.btnAdd])); - w4.Position = 0; - w4.Expand = false; - w4.Fill = false; - // Container child vbox88.Gtk.Box+BoxChild - this.btnRemove = new Gtk.Button(); - this.btnRemove.CanFocus = true; - this.btnRemove.Name = "btnRemove"; - this.btnRemove.UseStock = true; - this.btnRemove.UseUnderline = true; - this.btnRemove.Label = "gtk-delete"; - this.vbox88.Add(this.btnRemove); - Gtk.Box.BoxChild w5 = ((Gtk.Box.BoxChild)(this.vbox88[this.btnRemove])); - w5.Position = 1; - w5.Expand = false; - w5.Fill = false; - this.hbox67.Add(this.vbox88); - Gtk.Box.BoxChild w6 = ((Gtk.Box.BoxChild)(this.hbox67[this.vbox88])); - w6.Position = 1; - w6.Expand = false; - w6.Fill = false; - w1.Add(this.hbox67); - Gtk.Box.BoxChild w7 = ((Gtk.Box.BoxChild)(w1[this.hbox67])); - w7.Position = 0; - // Internal child Mono.Addins.Gui.ManageSitesDialog.ActionArea - Gtk.HButtonBox w8 = this.ActionArea; - w8.Name = "dialog-action_area10"; - w8.Spacing = 10; - w8.BorderWidth = ((uint)(6)); - w8.LayoutStyle = ((Gtk.ButtonBoxStyle)(4)); - // Container child dialog-action_area10.Gtk.ButtonBox+ButtonBoxChild - this.closebutton2 = new Gtk.Button(); - this.closebutton2.CanDefault = true; - this.closebutton2.CanFocus = true; - this.closebutton2.Name = "closebutton2"; - this.closebutton2.UseStock = true; - this.closebutton2.UseUnderline = true; - this.closebutton2.Label = "gtk-close"; - this.AddActionWidget(this.closebutton2, -7); - if ((this.Child != null)) { - this.Child.ShowAll(); - } - this.Show(); - this.btnAdd.Clicked += new System.EventHandler(this.OnAdd); - this.btnRemove.Clicked += new System.EventHandler(this.OnRemove); - } - } +// This file has been generated by the GUI designer. Do not modify. +namespace Mono.Addins.Gui +{ + internal partial class ManageSitesDialog + { + private global::Gtk.HBox hbox67; + private global::Gtk.ScrolledWindow scrolledwindow17; + private global::Gtk.TreeView repoTree; + private global::Gtk.VBox vbox88; + private global::Gtk.Button btnAdd; + private global::Gtk.Button btnRemove; + private global::Gtk.Button closebutton2; + + protected virtual void Build () + { + global::Stetic.Gui.Initialize (this); + // Widget Mono.Addins.Gui.ManageSitesDialog + this.Name = "Mono.Addins.Gui.ManageSitesDialog"; + this.Title = global::Mono.Unix.Catalog.GetString ("Add-in Repository Management"); + this.TypeHint = ((global::Gdk.WindowTypeHint)(1)); + this.BorderWidth = ((uint)(6)); + this.DefaultWidth = 600; + this.DefaultHeight = 300; + // Internal child Mono.Addins.Gui.ManageSitesDialog.VBox + global::Gtk.VBox w1 = this.VBox; + w1.Name = "dialog-vbox10"; + w1.Spacing = 6; + // Container child dialog-vbox10.Gtk.Box+BoxChild + this.hbox67 = new global::Gtk.HBox (); + this.hbox67.Name = "hbox67"; + this.hbox67.Spacing = 12; + this.hbox67.BorderWidth = ((uint)(6)); + // Container child hbox67.Gtk.Box+BoxChild + this.scrolledwindow17 = new global::Gtk.ScrolledWindow (); + this.scrolledwindow17.CanFocus = true; + this.scrolledwindow17.Name = "scrolledwindow17"; + this.scrolledwindow17.ShadowType = ((global::Gtk.ShadowType)(1)); + // Container child scrolledwindow17.Gtk.Container+ContainerChild + this.repoTree = new global::Gtk.TreeView (); + this.repoTree.CanFocus = true; + this.repoTree.Name = "repoTree"; + this.repoTree.HeadersVisible = false; + this.scrolledwindow17.Add (this.repoTree); + this.hbox67.Add (this.scrolledwindow17); + global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.hbox67 [this.scrolledwindow17])); + w3.Position = 0; + // Container child hbox67.Gtk.Box+BoxChild + this.vbox88 = new global::Gtk.VBox (); + this.vbox88.Name = "vbox88"; + this.vbox88.Spacing = 6; + // Container child vbox88.Gtk.Box+BoxChild + this.btnAdd = new global::Gtk.Button (); + this.btnAdd.CanFocus = true; + this.btnAdd.Name = "btnAdd"; + this.btnAdd.UseStock = true; + this.btnAdd.UseUnderline = true; + this.btnAdd.Label = "gtk-add"; + this.vbox88.Add (this.btnAdd); + global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.vbox88 [this.btnAdd])); + w4.Position = 0; + w4.Expand = false; + w4.Fill = false; + // Container child vbox88.Gtk.Box+BoxChild + this.btnRemove = new global::Gtk.Button (); + this.btnRemove.CanFocus = true; + this.btnRemove.Name = "btnRemove"; + this.btnRemove.UseStock = true; + this.btnRemove.UseUnderline = true; + this.btnRemove.Label = "gtk-delete"; + this.vbox88.Add (this.btnRemove); + global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.vbox88 [this.btnRemove])); + w5.Position = 1; + w5.Expand = false; + w5.Fill = false; + this.hbox67.Add (this.vbox88); + global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.hbox67 [this.vbox88])); + w6.Position = 1; + w6.Expand = false; + w6.Fill = false; + w1.Add (this.hbox67); + global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(w1 [this.hbox67])); + w7.Position = 0; + // Internal child Mono.Addins.Gui.ManageSitesDialog.ActionArea + global::Gtk.HButtonBox w8 = this.ActionArea; + w8.Name = "dialog-action_area10"; + w8.Spacing = 10; + w8.BorderWidth = ((uint)(6)); + w8.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4)); + // Container child dialog-action_area10.Gtk.ButtonBox+ButtonBoxChild + this.closebutton2 = new global::Gtk.Button (); + this.closebutton2.CanDefault = true; + this.closebutton2.CanFocus = true; + this.closebutton2.Name = "closebutton2"; + this.closebutton2.UseStock = true; + this.closebutton2.UseUnderline = true; + this.closebutton2.Label = "gtk-close"; + this.AddActionWidget (this.closebutton2, -7); + global::Gtk.ButtonBox.ButtonBoxChild w9 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w8 [this.closebutton2])); + w9.Expand = false; + w9.Fill = false; + if ((this.Child != null)) { + this.Child.ShowAll (); + } + this.Hide (); + this.btnAdd.Clicked += new global::System.EventHandler (this.OnAdd); + this.btnRemove.Clicked += new global::System.EventHandler (this.OnRemove); + } + } } diff -Nru mono-addins-0.4/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.NewSiteDialog.cs mono-addins-0.6.1/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.NewSiteDialog.cs --- mono-addins-0.4/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.NewSiteDialog.cs 2008-11-06 19:51:59.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.NewSiteDialog.cs 2011-04-13 09:00:29.000000000 +0000 @@ -1,234 +1,214 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Mono Runtime Version: 2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ -namespace Mono.Addins.Gui { - - - internal partial class NewSiteDialog { - - private Gtk.VBox vbox89; - - private Gtk.Label label121; - - private Gtk.RadioButton btnOnlineRep; - - private Gtk.HBox hbox68; - - private Gtk.Label label122; - - private Gtk.Label label119; - - private Gtk.Entry urlText; - - private Gtk.RadioButton btnLocalRep; - - private Gtk.HBox hbox69; - - private Gtk.Label label123; - - private Gtk.Label label120; - - private Gtk.HBox hbox1; - - private Gtk.Entry pathEntry; - - private Gtk.Button buttonBrowse; - - private Gtk.Button cancelbutton1; - - private Gtk.Button btnOk; - - protected virtual void Build() { - Stetic.Gui.Initialize(this); - // Widget Mono.Addins.Gui.NewSiteDialog - this.Name = "Mono.Addins.Gui.NewSiteDialog"; - this.Title = Mono.Unix.Catalog.GetString("Add New Repository"); - this.TypeHint = ((Gdk.WindowTypeHint)(1)); - this.BorderWidth = ((uint)(6)); - this.DefaultWidth = 550; - // Internal child Mono.Addins.Gui.NewSiteDialog.VBox - Gtk.VBox w1 = this.VBox; - w1.Name = "dialog-vbox11"; - w1.Spacing = 6; - w1.BorderWidth = ((uint)(2)); - // Container child dialog-vbox11.Gtk.Box+BoxChild - this.vbox89 = new Gtk.VBox(); - this.vbox89.Name = "vbox89"; - this.vbox89.Spacing = 6; - this.vbox89.BorderWidth = ((uint)(6)); - // Container child vbox89.Gtk.Box+BoxChild - this.label121 = new Gtk.Label(); - this.label121.Name = "label121"; - this.label121.Xalign = 0F; - this.label121.LabelProp = Mono.Unix.Catalog.GetString("Select the location of the repository you want to register:"); - this.vbox89.Add(this.label121); - Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(this.vbox89[this.label121])); - w2.Position = 0; - w2.Expand = false; - w2.Fill = false; - // Container child vbox89.Gtk.Box+BoxChild - this.btnOnlineRep = new Gtk.RadioButton(Mono.Unix.Catalog.GetString("Register an on-line repository")); - this.btnOnlineRep.CanFocus = true; - this.btnOnlineRep.Name = "btnOnlineRep"; - this.btnOnlineRep.Active = true; - this.btnOnlineRep.DrawIndicator = true; - this.btnOnlineRep.UseUnderline = true; - this.btnOnlineRep.Group = new GLib.SList(System.IntPtr.Zero); - this.vbox89.Add(this.btnOnlineRep); - Gtk.Box.BoxChild w3 = ((Gtk.Box.BoxChild)(this.vbox89[this.btnOnlineRep])); - w3.Position = 1; - w3.Expand = false; - w3.Fill = false; - // Container child vbox89.Gtk.Box+BoxChild - this.hbox68 = new Gtk.HBox(); - this.hbox68.Name = "hbox68"; - this.hbox68.Spacing = 6; - // Container child hbox68.Gtk.Box+BoxChild - this.label122 = new Gtk.Label(); - this.label122.WidthRequest = 32; - this.label122.Name = "label122"; - this.label122.LabelProp = ""; - this.hbox68.Add(this.label122); - Gtk.Box.BoxChild w4 = ((Gtk.Box.BoxChild)(this.hbox68[this.label122])); - w4.Position = 0; - w4.Expand = false; - w4.Fill = false; - // Container child hbox68.Gtk.Box+BoxChild - this.label119 = new Gtk.Label(); - this.label119.Name = "label119"; - this.label119.LabelProp = Mono.Unix.Catalog.GetString("Url:"); - this.hbox68.Add(this.label119); - Gtk.Box.BoxChild w5 = ((Gtk.Box.BoxChild)(this.hbox68[this.label119])); - w5.Position = 1; - w5.Expand = false; - w5.Fill = false; - // Container child hbox68.Gtk.Box+BoxChild - this.urlText = new Gtk.Entry(); - this.urlText.CanFocus = true; - this.urlText.Name = "urlText"; - this.urlText.IsEditable = true; - this.urlText.InvisibleChar = '●'; - this.hbox68.Add(this.urlText); - Gtk.Box.BoxChild w6 = ((Gtk.Box.BoxChild)(this.hbox68[this.urlText])); - w6.Position = 2; - this.vbox89.Add(this.hbox68); - Gtk.Box.BoxChild w7 = ((Gtk.Box.BoxChild)(this.vbox89[this.hbox68])); - w7.Position = 2; - w7.Expand = false; - w7.Fill = false; - // Container child vbox89.Gtk.Box+BoxChild - this.btnLocalRep = new Gtk.RadioButton(Mono.Unix.Catalog.GetString("Register a local repository")); - this.btnLocalRep.CanFocus = true; - this.btnLocalRep.Name = "btnLocalRep"; - this.btnLocalRep.DrawIndicator = true; - this.btnLocalRep.UseUnderline = true; - this.btnLocalRep.Group = this.btnOnlineRep.Group; - this.vbox89.Add(this.btnLocalRep); - Gtk.Box.BoxChild w8 = ((Gtk.Box.BoxChild)(this.vbox89[this.btnLocalRep])); - w8.Position = 3; - w8.Expand = false; - w8.Fill = false; - // Container child vbox89.Gtk.Box+BoxChild - this.hbox69 = new Gtk.HBox(); - this.hbox69.Name = "hbox69"; - this.hbox69.Spacing = 6; - // Container child hbox69.Gtk.Box+BoxChild - this.label123 = new Gtk.Label(); - this.label123.WidthRequest = 32; - this.label123.Name = "label123"; - this.label123.LabelProp = ""; - this.hbox69.Add(this.label123); - Gtk.Box.BoxChild w9 = ((Gtk.Box.BoxChild)(this.hbox69[this.label123])); - w9.Position = 0; - w9.Expand = false; - w9.Fill = false; - // Container child hbox69.Gtk.Box+BoxChild - this.label120 = new Gtk.Label(); - this.label120.Name = "label120"; - this.label120.LabelProp = Mono.Unix.Catalog.GetString("Path:"); - this.hbox69.Add(this.label120); - Gtk.Box.BoxChild w10 = ((Gtk.Box.BoxChild)(this.hbox69[this.label120])); - w10.Position = 1; - w10.Expand = false; - w10.Fill = false; - // Container child hbox69.Gtk.Box+BoxChild - this.hbox1 = new Gtk.HBox(); - this.hbox1.Name = "hbox1"; - this.hbox1.Spacing = 6; - // Container child hbox1.Gtk.Box+BoxChild - this.pathEntry = new Gtk.Entry(); - this.pathEntry.CanFocus = true; - this.pathEntry.Name = "pathEntry"; - this.pathEntry.IsEditable = true; - this.pathEntry.InvisibleChar = '●'; - this.hbox1.Add(this.pathEntry); - Gtk.Box.BoxChild w11 = ((Gtk.Box.BoxChild)(this.hbox1[this.pathEntry])); - w11.Position = 0; - // Container child hbox1.Gtk.Box+BoxChild - this.buttonBrowse = new Gtk.Button(); - this.buttonBrowse.CanFocus = true; - this.buttonBrowse.Name = "buttonBrowse"; - this.buttonBrowse.UseUnderline = true; - this.buttonBrowse.Label = Mono.Unix.Catalog.GetString("Browse..."); - this.hbox1.Add(this.buttonBrowse); - Gtk.Box.BoxChild w12 = ((Gtk.Box.BoxChild)(this.hbox1[this.buttonBrowse])); - w12.Position = 1; - w12.Expand = false; - w12.Fill = false; - this.hbox69.Add(this.hbox1); - Gtk.Box.BoxChild w13 = ((Gtk.Box.BoxChild)(this.hbox69[this.hbox1])); - w13.Position = 2; - this.vbox89.Add(this.hbox69); - Gtk.Box.BoxChild w14 = ((Gtk.Box.BoxChild)(this.vbox89[this.hbox69])); - w14.Position = 4; - w14.Expand = false; - w14.Fill = false; - w1.Add(this.vbox89); - Gtk.Box.BoxChild w15 = ((Gtk.Box.BoxChild)(w1[this.vbox89])); - w15.Position = 0; - // Internal child Mono.Addins.Gui.NewSiteDialog.ActionArea - Gtk.HButtonBox w16 = this.ActionArea; - w16.Name = "dialog-action_area11"; - w16.Spacing = 10; - w16.BorderWidth = ((uint)(5)); - w16.LayoutStyle = ((Gtk.ButtonBoxStyle)(4)); - // Container child dialog-action_area11.Gtk.ButtonBox+ButtonBoxChild - this.cancelbutton1 = new Gtk.Button(); - this.cancelbutton1.CanDefault = true; - this.cancelbutton1.CanFocus = true; - this.cancelbutton1.Name = "cancelbutton1"; - this.cancelbutton1.UseStock = true; - this.cancelbutton1.UseUnderline = true; - this.cancelbutton1.Label = "gtk-cancel"; - this.AddActionWidget(this.cancelbutton1, -6); - // Container child dialog-action_area11.Gtk.ButtonBox+ButtonBoxChild - this.btnOk = new Gtk.Button(); - this.btnOk.CanDefault = true; - this.btnOk.CanFocus = true; - this.btnOk.Name = "btnOk"; - this.btnOk.UseStock = true; - this.btnOk.UseUnderline = true; - this.btnOk.Label = "gtk-ok"; - this.AddActionWidget(this.btnOk, -5); - Gtk.ButtonBox.ButtonBoxChild w18 = ((Gtk.ButtonBox.ButtonBoxChild)(w16[this.btnOk])); - w18.Position = 1; - if ((this.Child != null)) { - this.Child.ShowAll(); - } - this.DefaultHeight = 249; - this.Show(); - this.btnOnlineRep.Clicked += new System.EventHandler(this.OnOptionClicked); - this.urlText.Changed += new System.EventHandler(this.OnUrlTextChanged); - this.btnLocalRep.Clicked += new System.EventHandler(this.OnOptionClicked); - this.pathEntry.Changed += new System.EventHandler(this.OnPathEntryChanged); - this.buttonBrowse.Clicked += new System.EventHandler(this.OnButtonBrowseClicked); - } - } +// This file has been generated by the GUI designer. Do not modify. +namespace Mono.Addins.Gui +{ + internal partial class NewSiteDialog + { + private global::Gtk.VBox vbox89; + private global::Gtk.Label label121; + private global::Gtk.RadioButton btnOnlineRep; + private global::Gtk.HBox hbox68; + private global::Gtk.Label label122; + private global::Gtk.Label label119; + private global::Gtk.Entry urlText; + private global::Gtk.RadioButton btnLocalRep; + private global::Gtk.HBox hbox69; + private global::Gtk.Label label123; + private global::Gtk.Label label120; + private global::Gtk.HBox hbox1; + private global::Gtk.Entry pathEntry; + private global::Gtk.Button buttonBrowse; + private global::Gtk.Button cancelbutton1; + private global::Gtk.Button btnOk; + + protected virtual void Build () + { + global::Stetic.Gui.Initialize (this); + // Widget Mono.Addins.Gui.NewSiteDialog + this.Name = "Mono.Addins.Gui.NewSiteDialog"; + this.Title = global::Mono.Unix.Catalog.GetString ("Add New Repository"); + this.TypeHint = ((global::Gdk.WindowTypeHint)(1)); + this.BorderWidth = ((uint)(6)); + this.DefaultWidth = 550; + // Internal child Mono.Addins.Gui.NewSiteDialog.VBox + global::Gtk.VBox w1 = this.VBox; + w1.Name = "dialog-vbox11"; + w1.Spacing = 6; + w1.BorderWidth = ((uint)(2)); + // Container child dialog-vbox11.Gtk.Box+BoxChild + this.vbox89 = new global::Gtk.VBox (); + this.vbox89.Name = "vbox89"; + this.vbox89.Spacing = 6; + this.vbox89.BorderWidth = ((uint)(6)); + // Container child vbox89.Gtk.Box+BoxChild + this.label121 = new global::Gtk.Label (); + this.label121.Name = "label121"; + this.label121.Xalign = 0F; + this.label121.LabelProp = global::Mono.Unix.Catalog.GetString ("Select the location of the repository you want to register:"); + this.vbox89.Add (this.label121); + global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.vbox89 [this.label121])); + w2.Position = 0; + w2.Expand = false; + w2.Fill = false; + // Container child vbox89.Gtk.Box+BoxChild + this.btnOnlineRep = new global::Gtk.RadioButton (global::Mono.Unix.Catalog.GetString ("Register an on-line repository")); + this.btnOnlineRep.CanFocus = true; + this.btnOnlineRep.Name = "btnOnlineRep"; + this.btnOnlineRep.Active = true; + this.btnOnlineRep.DrawIndicator = true; + this.btnOnlineRep.UseUnderline = true; + this.btnOnlineRep.Group = new global::GLib.SList (global::System.IntPtr.Zero); + this.vbox89.Add (this.btnOnlineRep); + global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.vbox89 [this.btnOnlineRep])); + w3.Position = 1; + w3.Expand = false; + w3.Fill = false; + // Container child vbox89.Gtk.Box+BoxChild + this.hbox68 = new global::Gtk.HBox (); + this.hbox68.Name = "hbox68"; + this.hbox68.Spacing = 6; + // Container child hbox68.Gtk.Box+BoxChild + this.label122 = new global::Gtk.Label (); + this.label122.WidthRequest = 32; + this.label122.Name = "label122"; + this.hbox68.Add (this.label122); + global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.hbox68 [this.label122])); + w4.Position = 0; + w4.Expand = false; + w4.Fill = false; + // Container child hbox68.Gtk.Box+BoxChild + this.label119 = new global::Gtk.Label (); + this.label119.Name = "label119"; + this.label119.LabelProp = global::Mono.Unix.Catalog.GetString ("Url:"); + this.hbox68.Add (this.label119); + global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.hbox68 [this.label119])); + w5.Position = 1; + w5.Expand = false; + w5.Fill = false; + // Container child hbox68.Gtk.Box+BoxChild + this.urlText = new global::Gtk.Entry (); + this.urlText.CanFocus = true; + this.urlText.Name = "urlText"; + this.urlText.IsEditable = true; + this.urlText.InvisibleChar = '●'; + this.hbox68.Add (this.urlText); + global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.hbox68 [this.urlText])); + w6.Position = 2; + this.vbox89.Add (this.hbox68); + global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.vbox89 [this.hbox68])); + w7.Position = 2; + w7.Expand = false; + w7.Fill = false; + // Container child vbox89.Gtk.Box+BoxChild + this.btnLocalRep = new global::Gtk.RadioButton (global::Mono.Unix.Catalog.GetString ("Register a local repository")); + this.btnLocalRep.CanFocus = true; + this.btnLocalRep.Name = "btnLocalRep"; + this.btnLocalRep.DrawIndicator = true; + this.btnLocalRep.UseUnderline = true; + this.btnLocalRep.Group = this.btnOnlineRep.Group; + this.vbox89.Add (this.btnLocalRep); + global::Gtk.Box.BoxChild w8 = ((global::Gtk.Box.BoxChild)(this.vbox89 [this.btnLocalRep])); + w8.Position = 3; + w8.Expand = false; + w8.Fill = false; + // Container child vbox89.Gtk.Box+BoxChild + this.hbox69 = new global::Gtk.HBox (); + this.hbox69.Name = "hbox69"; + this.hbox69.Spacing = 6; + // Container child hbox69.Gtk.Box+BoxChild + this.label123 = new global::Gtk.Label (); + this.label123.WidthRequest = 32; + this.label123.Name = "label123"; + this.hbox69.Add (this.label123); + global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(this.hbox69 [this.label123])); + w9.Position = 0; + w9.Expand = false; + w9.Fill = false; + // Container child hbox69.Gtk.Box+BoxChild + this.label120 = new global::Gtk.Label (); + this.label120.Name = "label120"; + this.label120.LabelProp = global::Mono.Unix.Catalog.GetString ("Path:"); + this.hbox69.Add (this.label120); + global::Gtk.Box.BoxChild w10 = ((global::Gtk.Box.BoxChild)(this.hbox69 [this.label120])); + w10.Position = 1; + w10.Expand = false; + w10.Fill = false; + // Container child hbox69.Gtk.Box+BoxChild + this.hbox1 = new global::Gtk.HBox (); + this.hbox1.Name = "hbox1"; + this.hbox1.Spacing = 6; + // Container child hbox1.Gtk.Box+BoxChild + this.pathEntry = new global::Gtk.Entry (); + this.pathEntry.CanFocus = true; + this.pathEntry.Name = "pathEntry"; + this.pathEntry.IsEditable = true; + this.pathEntry.InvisibleChar = '●'; + this.hbox1.Add (this.pathEntry); + global::Gtk.Box.BoxChild w11 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.pathEntry])); + w11.Position = 0; + // Container child hbox1.Gtk.Box+BoxChild + this.buttonBrowse = new global::Gtk.Button (); + this.buttonBrowse.CanFocus = true; + this.buttonBrowse.Name = "buttonBrowse"; + this.buttonBrowse.UseUnderline = true; + this.buttonBrowse.Label = global::Mono.Unix.Catalog.GetString ("Browse..."); + this.hbox1.Add (this.buttonBrowse); + global::Gtk.Box.BoxChild w12 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.buttonBrowse])); + w12.Position = 1; + w12.Expand = false; + w12.Fill = false; + this.hbox69.Add (this.hbox1); + global::Gtk.Box.BoxChild w13 = ((global::Gtk.Box.BoxChild)(this.hbox69 [this.hbox1])); + w13.Position = 2; + this.vbox89.Add (this.hbox69); + global::Gtk.Box.BoxChild w14 = ((global::Gtk.Box.BoxChild)(this.vbox89 [this.hbox69])); + w14.Position = 4; + w14.Expand = false; + w14.Fill = false; + w1.Add (this.vbox89); + global::Gtk.Box.BoxChild w15 = ((global::Gtk.Box.BoxChild)(w1 [this.vbox89])); + w15.Position = 0; + // Internal child Mono.Addins.Gui.NewSiteDialog.ActionArea + global::Gtk.HButtonBox w16 = this.ActionArea; + w16.Name = "dialog-action_area11"; + w16.Spacing = 10; + w16.BorderWidth = ((uint)(5)); + w16.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4)); + // Container child dialog-action_area11.Gtk.ButtonBox+ButtonBoxChild + this.cancelbutton1 = new global::Gtk.Button (); + this.cancelbutton1.CanDefault = true; + this.cancelbutton1.CanFocus = true; + this.cancelbutton1.Name = "cancelbutton1"; + this.cancelbutton1.UseStock = true; + this.cancelbutton1.UseUnderline = true; + this.cancelbutton1.Label = "gtk-cancel"; + this.AddActionWidget (this.cancelbutton1, -6); + global::Gtk.ButtonBox.ButtonBoxChild w17 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w16 [this.cancelbutton1])); + w17.Expand = false; + w17.Fill = false; + // Container child dialog-action_area11.Gtk.ButtonBox+ButtonBoxChild + this.btnOk = new global::Gtk.Button (); + this.btnOk.CanDefault = true; + this.btnOk.CanFocus = true; + this.btnOk.Name = "btnOk"; + this.btnOk.UseStock = true; + this.btnOk.UseUnderline = true; + this.btnOk.Label = "gtk-ok"; + this.AddActionWidget (this.btnOk, -5); + global::Gtk.ButtonBox.ButtonBoxChild w18 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w16 [this.btnOk])); + w18.Position = 1; + w18.Expand = false; + w18.Fill = false; + if ((this.Child != null)) { + this.Child.ShowAll (); + } + this.DefaultHeight = 249; + this.Hide (); + this.btnOnlineRep.Clicked += new global::System.EventHandler (this.OnOptionClicked); + this.urlText.Changed += new global::System.EventHandler (this.OnUrlTextChanged); + this.btnLocalRep.Clicked += new global::System.EventHandler (this.OnOptionClicked); + this.pathEntry.Changed += new global::System.EventHandler (this.OnPathEntryChanged); + this.buttonBrowse.Clicked += new global::System.EventHandler (this.OnButtonBrowseClicked); + } + } } diff -Nru mono-addins-0.4/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.ProgressDialog.cs mono-addins-0.6.1/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.ProgressDialog.cs --- mono-addins-0.4/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.ProgressDialog.cs 2008-11-06 19:51:59.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.ProgressDialog.cs 2011-04-13 09:00:29.000000000 +0000 @@ -1,119 +1,102 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Mono Runtime Version: 2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ -namespace Mono.Addins.Gui { - - - internal partial class ProgressDialog { - - private Gtk.VBox vbox2; - - private Gtk.Label labelMessage; - - private Gtk.ProgressBar progressbar; - - private Gtk.Expander expander1; - - private Gtk.ScrolledWindow GtkScrolledWindow; - - private Gtk.TextView textview; - - private Gtk.Label GtkLabel1; - - private Gtk.Button buttonCancel; - - protected virtual void Build() { - Stetic.Gui.Initialize(this); - // Widget Mono.Addins.Gui.ProgressDialog - this.Name = "Mono.Addins.Gui.ProgressDialog"; - this.Title = Mono.Unix.Catalog.GetString("Progress"); - this.WindowPosition = ((Gtk.WindowPosition)(4)); - this.Modal = true; - this.HasSeparator = false; - // Internal child Mono.Addins.Gui.ProgressDialog.VBox - Gtk.VBox w1 = this.VBox; - w1.Name = "dialog1_VBox"; - w1.BorderWidth = ((uint)(2)); - // Container child dialog1_VBox.Gtk.Box+BoxChild - this.vbox2 = new Gtk.VBox(); - this.vbox2.Name = "vbox2"; - this.vbox2.Spacing = 6; - this.vbox2.BorderWidth = ((uint)(9)); - // Container child vbox2.Gtk.Box+BoxChild - this.labelMessage = new Gtk.Label(); - this.labelMessage.Name = "labelMessage"; - this.labelMessage.Xalign = 0F; - this.labelMessage.LabelProp = ""; - this.vbox2.Add(this.labelMessage); - Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(this.vbox2[this.labelMessage])); - w2.Position = 0; - w2.Expand = false; - w2.Fill = false; - // Container child vbox2.Gtk.Box+BoxChild - this.progressbar = new Gtk.ProgressBar(); - this.progressbar.Name = "progressbar"; - this.vbox2.Add(this.progressbar); - Gtk.Box.BoxChild w3 = ((Gtk.Box.BoxChild)(this.vbox2[this.progressbar])); - w3.Position = 1; - w3.Expand = false; - w3.Fill = false; - // Container child vbox2.Gtk.Box+BoxChild - this.expander1 = new Gtk.Expander(null); - this.expander1.CanFocus = true; - this.expander1.Name = "expander1"; - // Container child expander1.Gtk.Container+ContainerChild - this.GtkScrolledWindow = new Gtk.ScrolledWindow(); - this.GtkScrolledWindow.Name = "GtkScrolledWindow"; - this.GtkScrolledWindow.ShadowType = ((Gtk.ShadowType)(1)); - // Container child GtkScrolledWindow.Gtk.Container+ContainerChild - this.textview = new Gtk.TextView(); - this.textview.CanFocus = true; - this.textview.Name = "textview"; - this.GtkScrolledWindow.Add(this.textview); - this.expander1.Add(this.GtkScrolledWindow); - this.GtkLabel1 = new Gtk.Label(); - this.GtkLabel1.Name = "GtkLabel1"; - this.GtkLabel1.LabelProp = Mono.Unix.Catalog.GetString("Details"); - this.GtkLabel1.UseUnderline = true; - this.expander1.LabelWidget = this.GtkLabel1; - this.vbox2.Add(this.expander1); - Gtk.Box.BoxChild w6 = ((Gtk.Box.BoxChild)(this.vbox2[this.expander1])); - w6.Position = 2; - w1.Add(this.vbox2); - Gtk.Box.BoxChild w7 = ((Gtk.Box.BoxChild)(w1[this.vbox2])); - w7.Position = 0; - // Internal child Mono.Addins.Gui.ProgressDialog.ActionArea - Gtk.HButtonBox w8 = this.ActionArea; - w8.Name = "dialog1_ActionArea"; - w8.Spacing = 6; - w8.BorderWidth = ((uint)(5)); - w8.LayoutStyle = ((Gtk.ButtonBoxStyle)(4)); - // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild - this.buttonCancel = new Gtk.Button(); - this.buttonCancel.CanDefault = true; - this.buttonCancel.CanFocus = true; - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.UseStock = true; - this.buttonCancel.UseUnderline = true; - this.buttonCancel.Label = "gtk-cancel"; - this.AddActionWidget(this.buttonCancel, -6); - Gtk.ButtonBox.ButtonBoxChild w9 = ((Gtk.ButtonBox.ButtonBoxChild)(w8[this.buttonCancel])); - w9.Expand = false; - w9.Fill = false; - if ((this.Child != null)) { - this.Child.ShowAll(); - } - this.DefaultWidth = 513; - this.DefaultHeight = 165; - this.Show(); - this.buttonCancel.Clicked += new System.EventHandler(this.OnButtonCancelClicked); - } - } +// This file has been generated by the GUI designer. Do not modify. +namespace Mono.Addins.Gui +{ + internal partial class ProgressDialog + { + private global::Gtk.VBox vbox2; + private global::Gtk.Label labelMessage; + private global::Gtk.ProgressBar progressbar; + private global::Gtk.Expander expander1; + private global::Gtk.ScrolledWindow GtkScrolledWindow; + private global::Gtk.TextView textview; + private global::Gtk.Label GtkLabel1; + private global::Gtk.Button buttonCancel; + + protected virtual void Build () + { + global::Stetic.Gui.Initialize (this); + // Widget Mono.Addins.Gui.ProgressDialog + this.Name = "Mono.Addins.Gui.ProgressDialog"; + this.Title = global::Mono.Unix.Catalog.GetString ("Progress"); + this.WindowPosition = ((global::Gtk.WindowPosition)(4)); + this.Modal = true; + // Internal child Mono.Addins.Gui.ProgressDialog.VBox + global::Gtk.VBox w1 = this.VBox; + w1.Name = "dialog1_VBox"; + w1.BorderWidth = ((uint)(2)); + // Container child dialog1_VBox.Gtk.Box+BoxChild + this.vbox2 = new global::Gtk.VBox (); + this.vbox2.Name = "vbox2"; + this.vbox2.Spacing = 6; + this.vbox2.BorderWidth = ((uint)(9)); + // Container child vbox2.Gtk.Box+BoxChild + this.labelMessage = new global::Gtk.Label (); + this.labelMessage.Name = "labelMessage"; + this.labelMessage.Xalign = 0F; + this.vbox2.Add (this.labelMessage); + global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.labelMessage])); + w2.Position = 0; + w2.Expand = false; + w2.Fill = false; + // Container child vbox2.Gtk.Box+BoxChild + this.progressbar = new global::Gtk.ProgressBar (); + this.progressbar.Name = "progressbar"; + this.vbox2.Add (this.progressbar); + global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.progressbar])); + w3.Position = 1; + w3.Expand = false; + w3.Fill = false; + // Container child vbox2.Gtk.Box+BoxChild + this.expander1 = new global::Gtk.Expander (null); + this.expander1.CanFocus = true; + this.expander1.Name = "expander1"; + // Container child expander1.Gtk.Container+ContainerChild + this.GtkScrolledWindow = new global::Gtk.ScrolledWindow (); + this.GtkScrolledWindow.Name = "GtkScrolledWindow"; + this.GtkScrolledWindow.ShadowType = ((global::Gtk.ShadowType)(1)); + // Container child GtkScrolledWindow.Gtk.Container+ContainerChild + this.textview = new global::Gtk.TextView (); + this.textview.CanFocus = true; + this.textview.Name = "textview"; + this.GtkScrolledWindow.Add (this.textview); + this.expander1.Add (this.GtkScrolledWindow); + this.GtkLabel1 = new global::Gtk.Label (); + this.GtkLabel1.Name = "GtkLabel1"; + this.GtkLabel1.LabelProp = global::Mono.Unix.Catalog.GetString ("Details"); + this.GtkLabel1.UseUnderline = true; + this.expander1.LabelWidget = this.GtkLabel1; + this.vbox2.Add (this.expander1); + global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.expander1])); + w6.Position = 2; + w1.Add (this.vbox2); + global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(w1 [this.vbox2])); + w7.Position = 0; + // Internal child Mono.Addins.Gui.ProgressDialog.ActionArea + global::Gtk.HButtonBox w8 = this.ActionArea; + w8.Name = "dialog1_ActionArea"; + w8.Spacing = 6; + w8.BorderWidth = ((uint)(5)); + w8.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4)); + // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.buttonCancel = new global::Gtk.Button (); + this.buttonCancel.CanDefault = true; + this.buttonCancel.CanFocus = true; + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.UseStock = true; + this.buttonCancel.UseUnderline = true; + this.buttonCancel.Label = "gtk-cancel"; + this.AddActionWidget (this.buttonCancel, -6); + global::Gtk.ButtonBox.ButtonBoxChild w9 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w8 [this.buttonCancel])); + w9.Expand = false; + w9.Fill = false; + if ((this.Child != null)) { + this.Child.ShowAll (); + } + this.DefaultWidth = 513; + this.DefaultHeight = 156; + this.Hide (); + this.buttonCancel.Clicked += new global::System.EventHandler (this.OnButtonCancelClicked); + } + } } Binary files /tmp/avP4DWiy33/mono-addins-0.4/Mono.Addins.Gui/icons/download.png and /tmp/LL8oRgT_6B/mono-addins-0.6.1/Mono.Addins.Gui/icons/download.png differ Binary files /tmp/avP4DWiy33/mono-addins-0.4/Mono.Addins.Gui/icons/installed-overlay.png and /tmp/LL8oRgT_6B/mono-addins-0.6.1/Mono.Addins.Gui/icons/installed-overlay.png differ Binary files /tmp/avP4DWiy33/mono-addins-0.4/Mono.Addins.Gui/icons/plugin-16.png and /tmp/LL8oRgT_6B/mono-addins-0.6.1/Mono.Addins.Gui/icons/plugin-16.png differ Binary files /tmp/avP4DWiy33/mono-addins-0.4/Mono.Addins.Gui/icons/plugin-22.png and /tmp/LL8oRgT_6B/mono-addins-0.6.1/Mono.Addins.Gui/icons/plugin-22.png differ Binary files /tmp/avP4DWiy33/mono-addins-0.4/Mono.Addins.Gui/icons/plugin-32.png and /tmp/LL8oRgT_6B/mono-addins-0.6.1/Mono.Addins.Gui/icons/plugin-32.png differ Binary files /tmp/avP4DWiy33/mono-addins-0.4/Mono.Addins.Gui/icons/plugin-avail-16.png and /tmp/LL8oRgT_6B/mono-addins-0.6.1/Mono.Addins.Gui/icons/plugin-avail-16.png differ Binary files /tmp/avP4DWiy33/mono-addins-0.4/Mono.Addins.Gui/icons/plugin-avail-32.png and /tmp/LL8oRgT_6B/mono-addins-0.6.1/Mono.Addins.Gui/icons/plugin-avail-32.png differ Binary files /tmp/avP4DWiy33/mono-addins-0.4/Mono.Addins.Gui/icons/plugin-disabled-32.png and /tmp/LL8oRgT_6B/mono-addins-0.6.1/Mono.Addins.Gui/icons/plugin-disabled-32.png differ Binary files /tmp/avP4DWiy33/mono-addins-0.4/Mono.Addins.Gui/icons/plugin-update-16.png and /tmp/LL8oRgT_6B/mono-addins-0.6.1/Mono.Addins.Gui/icons/plugin-update-16.png differ Binary files /tmp/avP4DWiy33/mono-addins-0.4/Mono.Addins.Gui/icons/plugin-update-22.png and /tmp/LL8oRgT_6B/mono-addins-0.6.1/Mono.Addins.Gui/icons/plugin-update-22.png differ Binary files /tmp/avP4DWiy33/mono-addins-0.4/Mono.Addins.Gui/icons/plugin-update-32.png and /tmp/LL8oRgT_6B/mono-addins-0.6.1/Mono.Addins.Gui/icons/plugin-update-32.png differ Binary files /tmp/avP4DWiy33/mono-addins-0.4/Mono.Addins.Gui/icons/software-update-available-overlay.png and /tmp/LL8oRgT_6B/mono-addins-0.6.1/Mono.Addins.Gui/icons/software-update-available-overlay.png differ Binary files /tmp/avP4DWiy33/mono-addins-0.4/Mono.Addins.Gui/icons/software-update-available.png and /tmp/LL8oRgT_6B/mono-addins-0.6.1/Mono.Addins.Gui/icons/software-update-available.png differ Binary files /tmp/avP4DWiy33/mono-addins-0.4/Mono.Addins.Gui/icons/system-software-update_22.png and /tmp/LL8oRgT_6B/mono-addins-0.6.1/Mono.Addins.Gui/icons/system-software-update_22.png differ Binary files /tmp/avP4DWiy33/mono-addins-0.4/Mono.Addins.Gui/icons/web.png and /tmp/LL8oRgT_6B/mono-addins-0.6.1/Mono.Addins.Gui/icons/web.png differ diff -Nru mono-addins-0.4/Mono.Addins.Gui/Makefile.am mono-addins-0.6.1/Mono.Addins.Gui/Makefile.am --- mono-addins-0.4/Mono.Addins.Gui/Makefile.am 2008-11-06 19:51:59.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/Makefile.am 2011-04-13 09:00:29.000000000 +0000 @@ -1,7 +1,7 @@ KEY_FILE=$(top_srcdir)/mono-addins.snk -ASSEMBLY_COMPILER_COMMAND = mcs -ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG +ASSEMBLY_COMPILER_COMMAND = gmcs +ASSEMBLY_COMPILER_FLAGS = -unsafe -keyfile:$(KEY_FILE) -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG ASSEMBLY = ../bin/Mono.Addins.Gui.dll ASSEMBLY_NAME=Mono.Addins.Gui COMPILE_TARGET = library @@ -21,36 +21,56 @@ FILES = \ AssemblyInfo.cs \ gtk-gui/generated.cs \ - gtk-gui/Mono.Addins.Gui.AddinInfoDialog.cs \ - gtk-gui/Mono.Addins.Gui.AddinInstallDialog.cs \ + gtk-gui/Mono.Addins.Gui.AddinInfoView.cs \ gtk-gui/Mono.Addins.Gui.AddinInstallerDialog.cs \ gtk-gui/Mono.Addins.Gui.AddinManagerDialog.cs \ gtk-gui/Mono.Addins.Gui.ErrorDialog.cs \ + gtk-gui/Mono.Addins.Gui.InstallDialog.cs \ gtk-gui/Mono.Addins.Gui.ManageSitesDialog.cs \ gtk-gui/Mono.Addins.Gui.NewSiteDialog.cs \ gtk-gui/Mono.Addins.Gui.ProgressDialog.cs \ - Mono.Addins.Gui/AddinInfoDialog.cs \ - Mono.Addins.Gui/AddinInstallDialog.cs \ + Mono.Addins.Gui/AddinInfoView.cs \ Mono.Addins.Gui/AddinInstaller.cs \ Mono.Addins.Gui/AddinInstallerDialog.cs \ Mono.Addins.Gui/AddinManagerDialog.cs \ Mono.Addins.Gui/AddinManagerWindow.cs \ Mono.Addins.Gui/AddinTreeWidget.cs \ Mono.Addins.Gui/ErrorDialog.cs \ + Mono.Addins.Gui/HeaderBox.cs \ + Mono.Addins.Gui/HoverImageButton.cs \ + Mono.Addins.Gui/HslColor.cs \ + Mono.Addins.Gui/InstallDialog.cs \ + Mono.Addins.Gui/InstallMonitor.cs \ Mono.Addins.Gui/ManageSitesDialog.cs \ Mono.Addins.Gui/NewSiteDialog.cs \ Mono.Addins.Gui/ProgressDialog.cs \ + Mono.Addins.Gui/SearchEntry.cs \ Mono.Addins.Gui/Services.cs DATA_FILES = RESOURCES = \ gtk-gui/gui.stetic \ + icons/download.png \ + icons/installed-overlay.png \ icons/package-x-generic.png \ icons/package-x-generic_16.png \ icons/package-x-generic_22.png \ + icons/plugin-16.png \ + icons/plugin-22.png \ + icons/plugin-32.png \ + icons/plugin-avail-16.png \ + icons/plugin-avail-32.png \ + icons/plugin-disabled-32.png \ + icons/plugin-update-16.png \ + icons/plugin-update-22.png \ + icons/plugin-update-32.png \ + icons/software-update-available.png \ + icons/software-update-available-overlay.png \ icons/system-software-update.png \ - icons/user-package.png + icons/system-software-update_22.png \ + icons/user-package.png \ + icons/web.png EXTRAS = \ ./Makefile.am @@ -58,12 +78,16 @@ REFERENCES = \ -pkg:glib-sharp-2.0 \ -pkg:gtk-sharp-2.0 \ + -r:Mono.Cairo \ -r:Mono.Posix \ - -r:System + -r:System \ + -r:System.Core DLL_REFERENCES = -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) $(POLICY_ASSEMBLIES) +$(ASSEMBLY).mdb: $(ASSEMBLY) + +$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) $(POLICY_ASSEMBLIES) mkdir -p $(dir $(ASSEMBLY)) $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) diff -Nru mono-addins-0.4/Mono.Addins.Gui/Makefile.in mono-addins-0.6.1/Mono.Addins.Gui/Makefile.in --- mono-addins-0.4/Mono.Addins.Gui/Makefile.in 2008-11-06 19:52:35.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/Makefile.in 2011-04-13 09:45:29.000000000 +0000 @@ -81,11 +81,15 @@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MCS = @MCS@ MKDIR_P = @MKDIR_P@ +MONODOC_CFLAGS = @MONODOC_CFLAGS@ +MONODOC_LIBS = @MONODOC_LIBS@ MONO_ADDINS_DEFAULT_LIB = @MONO_ADDINS_DEFAULT_LIB@ MONO_ADDINS_GUI_DEFAULT_LIB = @MONO_ADDINS_GUI_DEFAULT_LIB@ +MONO_ADDINS_MSBUILD_DEFAULT_LIB = @MONO_ADDINS_MSBUILD_DEFAULT_LIB@ MONO_ADDINS_SETUP_DEFAULT_LIB = @MONO_ADDINS_SETUP_DEFAULT_LIB@ MONO_NUNIT_CFLAGS = @MONO_NUNIT_CFLAGS@ MONO_NUNIT_LIBS = @MONO_NUNIT_LIBS@ @@ -138,11 +142,12 @@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ KEY_FILE = $(top_srcdir)/mono-addins.snk -ASSEMBLY_COMPILER_COMMAND = mcs -ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG +ASSEMBLY_COMPILER_COMMAND = gmcs +ASSEMBLY_COMPILER_FLAGS = -unsafe -keyfile:$(KEY_FILE) -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG ASSEMBLY = ../bin/Mono.Addins.Gui.dll ASSEMBLY_NAME = Mono.Addins.Gui COMPILE_TARGET = library @@ -155,35 +160,55 @@ FILES = \ AssemblyInfo.cs \ gtk-gui/generated.cs \ - gtk-gui/Mono.Addins.Gui.AddinInfoDialog.cs \ - gtk-gui/Mono.Addins.Gui.AddinInstallDialog.cs \ + gtk-gui/Mono.Addins.Gui.AddinInfoView.cs \ gtk-gui/Mono.Addins.Gui.AddinInstallerDialog.cs \ gtk-gui/Mono.Addins.Gui.AddinManagerDialog.cs \ gtk-gui/Mono.Addins.Gui.ErrorDialog.cs \ + gtk-gui/Mono.Addins.Gui.InstallDialog.cs \ gtk-gui/Mono.Addins.Gui.ManageSitesDialog.cs \ gtk-gui/Mono.Addins.Gui.NewSiteDialog.cs \ gtk-gui/Mono.Addins.Gui.ProgressDialog.cs \ - Mono.Addins.Gui/AddinInfoDialog.cs \ - Mono.Addins.Gui/AddinInstallDialog.cs \ + Mono.Addins.Gui/AddinInfoView.cs \ Mono.Addins.Gui/AddinInstaller.cs \ Mono.Addins.Gui/AddinInstallerDialog.cs \ Mono.Addins.Gui/AddinManagerDialog.cs \ Mono.Addins.Gui/AddinManagerWindow.cs \ Mono.Addins.Gui/AddinTreeWidget.cs \ Mono.Addins.Gui/ErrorDialog.cs \ + Mono.Addins.Gui/HeaderBox.cs \ + Mono.Addins.Gui/HoverImageButton.cs \ + Mono.Addins.Gui/HslColor.cs \ + Mono.Addins.Gui/InstallDialog.cs \ + Mono.Addins.Gui/InstallMonitor.cs \ Mono.Addins.Gui/ManageSitesDialog.cs \ Mono.Addins.Gui/NewSiteDialog.cs \ Mono.Addins.Gui/ProgressDialog.cs \ + Mono.Addins.Gui/SearchEntry.cs \ Mono.Addins.Gui/Services.cs DATA_FILES = RESOURCES = \ gtk-gui/gui.stetic \ + icons/download.png \ + icons/installed-overlay.png \ icons/package-x-generic.png \ icons/package-x-generic_16.png \ icons/package-x-generic_22.png \ + icons/plugin-16.png \ + icons/plugin-22.png \ + icons/plugin-32.png \ + icons/plugin-avail-16.png \ + icons/plugin-avail-32.png \ + icons/plugin-disabled-32.png \ + icons/plugin-update-16.png \ + icons/plugin-update-22.png \ + icons/plugin-update-32.png \ + icons/software-update-available.png \ + icons/software-update-available-overlay.png \ icons/system-software-update.png \ - icons/user-package.png + icons/system-software-update_22.png \ + icons/user-package.png \ + icons/web.png EXTRAS = \ ./Makefile.am @@ -191,8 +216,10 @@ REFERENCES = \ -pkg:glib-sharp-2.0 \ -pkg:gtk-sharp-2.0 \ + -r:Mono.Cairo \ -r:Mono.Posix \ - -r:System + -r:System \ + -r:System.Core DLL_REFERENCES = @ENABLE_GUI_TRUE@build_sources = $(addprefix $(srcdir)/, $(FILES) $(GENERATED_FILES)) @@ -216,7 +243,7 @@ all: all-am .SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.include $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/Makefile.include $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -241,9 +268,9 @@ $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(top_srcdir)/configure: $(am__configure_deps) +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh mono-addins-gui.pc: $(top_builddir)/config.status $(srcdir)/mono-addins-gui.pc.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ @@ -424,7 +451,9 @@ @ENABLE_GUI_TRUE@all: $(ASSEMBLY) @ENABLE_GUI_FALSE@all: -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) $(POLICY_ASSEMBLIES) +$(ASSEMBLY).mdb: $(ASSEMBLY) + +$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) $(POLICY_ASSEMBLIES) mkdir -p $(dir $(ASSEMBLY)) $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) @@ -436,12 +465,11 @@ @ENABLE_GUI_TRUE@ mkdir -p $(dir $@) @ENABLE_GUI_TRUE@ cp $< $@ -@ENABLE_GUI_TRUE@$(POLICY_ASSEMBLIES): $(top_builddir)/policy.config $(top_srcdir)/mono-addins.snk -@ENABLE_GUI_TRUE@ @for i in $(POLICY_VERSIONS); do \ -@ENABLE_GUI_TRUE@ echo "Creating policy.$$i.$(ASSEMBLY_NAME)"; \ -@ENABLE_GUI_TRUE@ sed -e "s/@ASSEMBLY_NAME@/$(ASSEMBLY_NAME)/" -e "s/@POLICY@/$$i/" $(top_builddir)/policy.config > policy.$$i.config; \ -@ENABLE_GUI_TRUE@ $(AL) -link:policy.$$i.config -out:policy.$$i.$(ASSEMBLY_NAME).dll -keyfile:$(top_srcdir)/mono-addins.snk; \ -@ENABLE_GUI_TRUE@ done +@ENABLE_GUI_TRUE@policy.%.config: $(top_builddir)/policy.config +@ENABLE_GUI_TRUE@ sed -e "s/@ASSEMBLY_NAME@/$(ASSEMBLY_NAME)/" -e "s/@POLICY@/$*/" $(top_builddir)/policy.config > $@ + +@ENABLE_GUI_TRUE@$(POLICY_ASSEMBLIES) : policy.%.$(ASSEMBLY_NAME).dll: policy.%.config $(top_srcdir)/mono-addins.snk +@ENABLE_GUI_TRUE@ $(AL) -link:policy.$*.config -out:$@ -keyfile:$(top_srcdir)/mono-addins.snk @ENABLE_GUI_TRUE@gac-install: $(POLICY_ASSEMBLIES) @ENABLE_GUI_TRUE@ $(GACUTIL) /i $(ASSEMBLY) /f $(GACUTIL_FLAGS) || exit 1; diff -Nru mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/AddinInfoDialog.cs mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/AddinInfoDialog.cs --- mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/AddinInfoDialog.cs 2008-11-06 19:51:59.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/AddinInfoDialog.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -// -// AddinInfoDialog.cs -// -// Author: -// Lluis Sanchez Gual -// -// Copyright (C) 2007 Novell, Inc (http://www.novell.com) -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using System.Text; -using Gtk; -using Mono.Addins; -using Mono.Addins.Setup; -using Mono.Addins.Description; -using Mono.Unix; - -namespace Mono.Addins.Gui -{ - partial class AddinInfoDialog : Dialog - { - AddinHeader info; - - public AddinInfoDialog (AddinHeader info) - { - Build (); - this.info = info; - packageImage.Stock = "md-package"; - packageImage.IconSize = (int)IconSize.Dialog; - Fill (); - } - - void Fill () - { - StringBuilder sb = new StringBuilder (); - sb.Append ("" + info.Name + "\n\n"); - - if (info.Description != "") - sb.Append (info.Description + "\n\n"); - - sb.Append (""); - - sb.Append ("").Append (Catalog.GetString ("Version:")).Append ("\n").Append (info.Version).Append ("\n\n"); - - if (info.Author != "") - sb.Append ("").Append (Catalog.GetString ("Author:")).Append ("\n").Append (info.Author).Append ("\n\n"); - - if (info.Copyright != "") - sb.Append ("").Append (Catalog.GetString ("Copyright:")).Append ("\n").Append (info.Copyright).Append ("\n\n"); - - if (info.Dependencies.Count > 0) { - sb.Append ("").Append (Catalog.GetString ("Add-in Dependencies:")).Append ("\n"); - foreach (Dependency dep in info.Dependencies) - sb.Append (dep.Name + "\n"); - } - - sb.Append (""); - -// linkLabel.Visible = info.Url != ""; - - infoLabel.Markup = sb.ToString (); - } - - public override void Dispose () - { - base.Dispose (); - Destroy (); - } - } -} diff -Nru mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/AddinInfoView.cs mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/AddinInfoView.cs --- mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/AddinInfoView.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/AddinInfoView.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,449 @@ +// +// AddinInfoView.cs +// +// Author: +// Lluis Sanchez Gual +// +// Copyright (c) 2011 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using System.IO; +using System.Collections.Generic; +using Mono.Addins.Setup; +using System.Text; +using Mono.Unix; +using System.Linq; + +namespace Mono.Addins.Gui +{ + [System.ComponentModel.ToolboxItem(true)] + partial class AddinInfoView : Gtk.Bin + { + List selectedEntry = new List (); + List selectedAddin = new List (); + SetupService service; + HeaderBox topHeaderBox; + List previewImages = new List (); + ImageContainer titleIcon; + int titleWidth; + string infoUrl; + + public event EventHandler InstallClicked; + public event EventHandler UninstallClicked; + public event EventHandler UpdateClicked; + public event EventHandler EnableDisableClicked; + + public AddinInfoView () + { + this.Build (); + AllowInstall = true; + titleWidth = labelName.SizeRequest ().Width; + + HeaderBox hb = new HeaderBox (1,1,1,1); + hb.Show (); + hb.Replace (this); + + hb = new HeaderBox (1,0,0,0); + hb.SetPadding (6,6,6,6); + hb.Show (); + hb.GradientBackround = true; + hb.Replace (eboxButs); + + hb = new HeaderBox (0,1,0,0); + hb.SetPadding (6,6,6,6); + hb.Show (); + hb.GradientBackround = true; + hb.Replace (boxHeader); + topHeaderBox = hb; + } + + public void Init (SetupService service) + { + this.service = service; + } + + public bool AllowInstall { get; set; } + + public List SelectedEntries { + get { + return this.selectedEntry; + } + } + + public List SelectedAddins { + get { + return this.selectedAddin; + } + } + + public void ShowAddins (object[] data) + { + selectedEntry.Clear (); + selectedAddin.Clear (); + eboxButs.Visible = true; + topHeaderBox.Hide (); + urlButton.Hide (); + + if (titleIcon != null) { + boxTitle.Remove (titleIcon); + titleIcon.Destroy (); + titleIcon = null; + } + + foreach (var img in previewImages) { + ((Gtk.Container)img.Parent).Remove (img); + img.Destroy (); + } + previewImages.Clear (); + + if (data.Length == 1) { + headerBox.Show (); + ShowAddin (data[0]); + } + else if (data.Length > 1) { + headerBox.Hide (); + StringBuilder sb = new StringBuilder (); + sb.Append (Catalog.GetString ("Multiple selection:\n\n")); + bool allowUpdate = AllowInstall; + bool allowInstall = true; + bool allowUninstall = AllowInstall; + bool allowEnable = true; + bool allowDisable = true; + + foreach (object o in data) { + Addin installed; + if (o is Addin) { + Addin a = (Addin)o; + installed = a; + selectedAddin.Add (a); + sb.Append (a.Name); + } + else { + AddinRepositoryEntry entry = (AddinRepositoryEntry) o; + selectedEntry.Add (entry); + sb.Append (entry.Addin.Name); + installed = AddinManager.Registry.GetAddin (Addin.GetIdName (entry.Addin.Id)); + } + if (installed != null) { + if (GetUpdate (installed) == null) + allowUpdate = false; + allowInstall = false; + if (installed.Enabled) + allowEnable = false; + else + allowDisable = false; + } else + allowEnable = allowDisable = allowUninstall = allowUpdate = false; + + sb.Append ('\n'); + labelDesc.Text = sb.ToString (); + + if (allowEnable) { + btnDisable.Visible = true; + btnDisable.Label = Catalog.GetString ("Enable"); + } else if (allowDisable) { + btnDisable.Visible = true; + btnDisable.Label = Catalog.GetString ("Disable"); + } else + btnDisable.Visible = false; + btnInstall.Visible = allowInstall; + btnUninstall.Visible = allowUninstall; + btnUpdate.Visible = allowUpdate; + } + } + else { + headerBox.Hide (); + btnDisable.Visible = false; + btnInstall.Visible = false; + btnUninstall.Visible = false; + btnUpdate.Visible = false; + eboxButs.Visible = false; + labelDesc.Text = Catalog.GetString ("No selection"); + } + } + + + void ShowAddin (object data) + { + AddinHeader sinfo = null; + Addin installed = null; + AddinHeader updateInfo = null; + string repo = ""; + string downloadSize = null; + + topHeaderBox.Hide (); + + if (data is Addin) { + installed = (Addin) data; + sinfo = SetupService.GetAddinHeader (installed); + var entry = GetUpdate (installed); + if (entry != null) { + updateInfo = entry.Addin; + selectedEntry.Add (entry); + } + foreach (var prop in sinfo.Properties) { + if (prop.Name.StartsWith ("PreviewImage")) + previewImages.Add (new ImageContainer (installed, prop.Value)); + } + string icon32 = sinfo.Properties.GetPropertyValue ("Icon32"); + if (icon32.Length > 0) + titleIcon = new ImageContainer (installed, icon32); + } + else if (data is AddinRepositoryEntry) { + AddinRepositoryEntry entry = (AddinRepositoryEntry) data; + sinfo = entry.Addin; + installed = AddinManager.Registry.GetAddin (Addin.GetIdName (sinfo.Id)); + if (installed != null && Addin.CompareVersions (installed.Version, sinfo.Version) > 0) + updateInfo = sinfo; + selectedEntry.Add (entry); + string rname = !string.IsNullOrEmpty (entry.RepositoryName) ? entry.RepositoryName : entry.RepositoryUrl; + repo = "" + Catalog.GetString ("Available in repository:") + "\n" + GLib.Markup.EscapeText (rname) + "\n\n"; + foreach (var prop in sinfo.Properties) { + if (prop.Name.StartsWith ("PreviewImage")) + previewImages.Add (new ImageContainer (entry, prop.Value)); + } + string icon32 = sinfo.Properties.GetPropertyValue ("Icon32"); + if (icon32.Length > 0) + titleIcon = new ImageContainer (entry, icon32); + int size; + if (int.TryParse (sinfo.Properties.GetPropertyValue ("DownloadSize"), out size)) { + float fs = ((float)size) / 1048576f; + downloadSize = fs.ToString ("0.00 MB"); + } + } else + selectedEntry.Clear (); + + if (installed != null) + selectedAddin.Add (installed); + + string missingDepsTxt = null; + + if (sinfo == null) { + btnDisable.Visible = false; + btnUninstall.Visible = false; + btnUpdate.Visible = false; + } else { + string version; + string newVersion = null; + if (installed != null) { + btnInstall.Visible = false; + btnUpdate.Visible = updateInfo != null && AllowInstall; + btnDisable.Visible = true; + btnDisable.Label = installed.Enabled ? "Disable" : "Enable"; + btnDisable.Visible = installed.Description.CanDisable; + btnUninstall.Visible = installed.Description.CanUninstall; + version = installed.Version; + var missingDeps = Services.GetMissingDependencies (installed); + if (updateInfo != null) { + newVersion = updateInfo.Version; + labelHeader.Markup = "" + Catalog.GetString ("Update available") + ""; +// topHeaderBox.BackgroundColor = new Gdk.Color (0, 132, 208); + imageHeader.Pixbuf = Gdk.Pixbuf.LoadFromResource ("software-update-available.png"); + topHeaderBox.BackgroundColor = new Gdk.Color (255, 176, 0); + topHeaderBox.Show (); + } + else if (missingDeps.Any ()) { + labelHeader.Markup = "" + Catalog.GetString ("This add-in can't be loaded due to missing dependencies") + ""; + topHeaderBox.BackgroundColor = new Gdk.Color (255, 176, 0); + imageHeader.SetFromStock (Gtk.Stock.DialogWarning, Gtk.IconSize.Menu); + topHeaderBox.Show (); + missingDepsTxt = ""; + foreach (var mdep in missingDeps) { + if (mdep.Found != null) + missingDepsTxt += "\n" + string.Format (Catalog.GetString ("Required: {0} v{1}, found v{2}"), mdep.Addin, mdep.Required, mdep.Found); + else + missingDepsTxt += "\n" + string.Format (Catalog.GetString ("Missing: {0} v{1}"), mdep.Addin, mdep.Required); + } + } + } else { + btnInstall.Visible = AllowInstall; + btnUpdate.Visible = false; + btnDisable.Visible = false; + btnUninstall.Visible = false; + version = sinfo.Version; + } + labelName.Markup = "" + GLib.Markup.EscapeText(sinfo.Name) + ""; + + string ver; + if (newVersion != null) { + ver = "" + Catalog.GetString ("Installed version") + ": " + version + "\n"; + ver += "" + Catalog.GetString ("Repository version") + ": " + newVersion + ""; + } + else + ver = "" + Catalog.GetString ("Version") + " " + version + ""; + + if (downloadSize != null) + ver += "\n" + Catalog.GetString ("Download size") + ": " + downloadSize + ""; + if (missingDepsTxt != null) + ver += "\n\n" + GLib.Markup.EscapeText (Catalog.GetString ("The following depedencies required by this add-in are not available:")) + missingDepsTxt; + labelVersion.Markup = ver; + + string desc = GLib.Markup.EscapeText (sinfo.Description); + labelDesc.Markup = repo + GLib.Markup.EscapeText (desc); + + foreach (var img in previewImages) + vboxDesc.PackStart (img, false, false, 0); + + urlButton.Visible = !string.IsNullOrEmpty (sinfo.Url); + infoUrl = sinfo.Url; + + if (titleIcon != null) { + boxTitle.PackEnd (titleIcon, false, false, 0); + labelName.WidthRequest = titleWidth - 32; + labelVersion.WidthRequest = titleWidth - 32; + } else { + labelName.WidthRequest = titleWidth; + labelVersion.WidthRequest = titleWidth; + } + + if (IsRealized) + SetComponentsBg (); + } + } + + public AddinRepositoryEntry GetUpdate (Addin a) + { + AddinRepositoryEntry[] updates = service.Repositories.GetAvailableAddinUpdates (Addin.GetIdName (a.Id)); + AddinRepositoryEntry best = null; + string bestVersion = a.Version; + foreach (AddinRepositoryEntry e in updates) { + if (Addin.CompareVersions (bestVersion, e.Addin.Version) > 0) { + best = e; + bestVersion = e.Addin.Version; + } + } + return best; + } + + protected virtual void OnBtnInstallClicked (object sender, System.EventArgs e) + { + if (InstallClicked != null) + InstallClicked (this, e); + } + + protected virtual void OnBtnDisableClicked (object sender, System.EventArgs e) + { + if (EnableDisableClicked != null) + EnableDisableClicked (this, e); + } + + protected virtual void OnBtnUpdateClicked (object sender, System.EventArgs e) + { + if (UpdateClicked != null) + UpdateClicked (this, e); + } + + protected virtual void OnBtnUninstallClicked (object sender, System.EventArgs e) + { + if (UninstallClicked != null) + UninstallClicked (this, e); + } + + protected override void OnRealized () + { + base.OnRealized (); + HslColor gcol = ebox.Style.Background (Gtk.StateType.Normal); + gcol.L -= 0.03; + ebox.ModifyBg (Gtk.StateType.Normal, gcol); + ebox2.ModifyBg (Gtk.StateType.Normal, gcol); + scrolledwindow.ModifyBg (Gtk.StateType.Normal, gcol); + SetComponentsBg (); + } + + void SetComponentsBg () + { + HslColor gcol = ebox.Style.Background (Gtk.StateType.Normal); + //gcol.L -= 0.03; + if (titleIcon != null) + titleIcon.ModifyBg (Gtk.StateType.Normal, gcol); + foreach (var i in previewImages) + i.ModifyBg (Gtk.StateType.Normal, gcol); + } + + protected virtual void OnUrlButtonClicked (object sender, System.EventArgs e) + { + System.Diagnostics.Process.Start (infoUrl); + } + } + + class ImageContainer: Gtk.EventBox + { + AddinRepositoryEntry aentry; + IAsyncResult aresult; + Gtk.Image image; + bool destroyed; + + ImageContainer () + { + image = new Gtk.Image (); + Add (image); + image.SetAlignment (0.5f, 0f); + Show (); + } + + public ImageContainer (AddinRepositoryEntry aentry, string fileName): this () + { + this.aentry = aentry; + aresult = aentry.BeginDownloadSupportFile (fileName, ImageDownloaded, null); + } + + public ImageContainer (Addin addin, string fileName): this () + { + string path = System.IO.Path.Combine (addin.Description.BasePath, fileName); + LoadImage (File.OpenRead (path)); + } + + void ImageDownloaded (object state) + { + Gtk.Application.Invoke (delegate { + if (destroyed) + return; + try { + LoadImage (aentry.EndDownloadSupportFile (aresult)); + } catch { + // ignore + } + }); + } + + void LoadImage (Stream s) + { + using (s) { + Gdk.PixbufLoader loader = new Gdk.PixbufLoader (s); + Gdk.Pixbuf pix = image.Pixbuf = loader.Pixbuf; + loader.Dispose (); + if (pix.Width > 250) { + Gdk.Pixbuf spix = pix.ScaleSimple (250, (250 * pix.Height) / pix.Width, Gdk.InterpType.Hyper); + pix.Dispose (); + pix = spix; + } + image.Pixbuf = pix; + image.Show (); + } + } + + protected override void OnDestroyed () + { + destroyed = true; + base.OnDestroyed (); + } + } +} + diff -Nru mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/AddinInstallDialog.cs mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/AddinInstallDialog.cs --- mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/AddinInstallDialog.cs 2008-11-06 19:51:59.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/AddinInstallDialog.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,637 +0,0 @@ -// -// AddinInstallDialog.cs -// -// Author: -// Lluis Sanchez Gual -// -// Copyright (C) 2007 Novell, Inc (http://www.novell.com) -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - - -using System; -using System.Text; -using System.Threading; -using System.Collections; -using System.Collections.Specialized; -using System.Diagnostics; -using Mono.Unix; - -using Gtk; - -using Mono.Addins.Setup; -using Mono.Addins.Description; - -namespace Mono.Addins.Gui -{ - partial class AddinInstallDialog : Dialog - { - ListStore repoStore; - AddinTreeWidget tree; - bool installing; - - PackageCollection packagesToInstall; - string uninstallId; - - InstallMonitor installMonitor; - SetupService service; - - - public AddinInstallDialog (SetupService service) - { - Build (); - this.service = service; - wizardNotebook.ShowTabs = false; - ActionArea.Hide (); - - tree = new InstallAddinTreeWidget (addinTree); - tree.AllowSelection = true; - tree.SelectionChanged += new EventHandler (OnAddinSelectionChanged); - - repoStore = new ListStore (typeof(string), typeof(string)); - repoCombo.Model = repoStore; - CellRendererText crt = new CellRendererText (); - repoCombo.PackStart (crt, true); - repoCombo.AddAttribute (crt, "text", 0); - filterComboBox.Active = 1; - - imageInstall.Stock = "md-software-update"; - imageInstall.IconSize = (int)IconSize.Dialog; - - FillRepos (); - repoCombo.Active = 0; - LoadAddins (); - FillAddinInfo (); - OnPageChanged (); - } - - public override void Dispose () - { - base.Dispose (); - Destroy (); - } - - void FillRepos () - { - int i = repoCombo.Active; - repoStore.Clear (); - - repoStore.AppendValues (Catalog.GetString ("All registered repositories"), ""); - - foreach (AddinRepository rep in service.Repositories.GetRepositories ()) { - repoStore.AppendValues (rep.Title, rep.Url); - } - repoCombo.Active = i; - } - - void LoadAddins () - { - object s = tree.SaveStatus (); - - tree.Clear (); - - Gtk.TreeIter iter; - if (!repoCombo.GetActiveIter (out iter)) - return; - - bool showUpdates = filterComboBox.Active >= 1; - bool showNotInstalled = filterComboBox.Active <= 1; - - string rep = (string) repoStore.GetValue (iter, 1); - - AddinRepositoryEntry[] reps; - if (rep == "") - reps = service.Repositories.GetAvailableAddins (); - else - reps = service.Repositories.GetAvailableAddins (rep); - - foreach (AddinRepositoryEntry arep in reps) - { - if (!Services.InApplicationNamespace (service, arep.Addin.Id)) - continue; - - // Find whatever version is installed - Addin sinfo = AddinManager.Registry.GetAddin (Addin.GetIdName (arep.Addin.Id)); - - if (sinfo == null) { - if (showNotInstalled) - tree.AddAddin (arep.Addin, arep, true); - continue; - } - - if (showUpdates && Addin.CompareVersions (sinfo.Version, arep.Addin.Version) <= 0) - continue; - - tree.AddAddin (arep.Addin, arep, true); - } - FillAddinInfo (); - - // Only show the select all button when "Show updates only" is selected - btnSelectAll.Visible = filterComboBox.Active == 2; - btnUnselectAll.Visible = filterComboBox.Active == 2; - - tree.RestoreStatus (s); - } - - void OnAddinSelectionChanged (object o, EventArgs e) - { - UpdateAddinSelection (); - } - - void UpdateAddinSelection () - { - btnNext.Sensitive = (tree.GetSelectedAddins().Length != 0); - } - - protected void OnActiveAddinChanged (object o, EventArgs e) - { - FillAddinInfo (); - } - - protected void OnNextPage (object sender, EventArgs e) - { - wizardNotebook.NextPage (); - OnPageChanged (); - } - - protected void OnPrevPage (object sender, EventArgs e) - { - wizardNotebook.PrevPage (); - OnPageChanged (); - } - - protected void OnCancel (object sender, EventArgs e) - { - if (installing) { - if (Services.AskQuestion (Catalog.GetString ("Are you sure you want to cancel the installation?"))) - installMonitor.Cancel (); - } else - Respond (ResponseType.Cancel); - } - - protected void OnOk (object sender, EventArgs e) - { - Respond (ResponseType.Ok); - } - - protected void OnManageSites (object sender, EventArgs e) - { - ManageSitesDialog dlg = new ManageSitesDialog (service); - dlg.TransientFor = this; - try { - dlg.Run (); - FillRepos (); - } finally { - dlg.Destroy (); - } - } - - - bool updateDone; - IProgressStatus updateMonitor; - - protected void OnUpdateRepo (object sender, EventArgs e) - { - ProgressDialog pdlg = new ProgressDialog (); - pdlg.Show (); - pdlg.SetMessage (AddinManager.CurrentLocalizer.GetString ("Updating repository")); - updateMonitor = pdlg; - - Thread t = new Thread (new ThreadStart (RunUpdate)); - t.Start (); - updateDone = false; - while (!updateDone) { - while (Gtk.Application.EventsPending ()) - Gtk.Application.RunIteration (); - Thread.Sleep (50); - } - pdlg.Destroy (); - LoadAddins (); - } - - void RunUpdate () - { - try { - service.Repositories.UpdateAllRepositories (updateMonitor); - } finally { - updateDone = true; - } - } - - protected void OnRepoChanged (object sender, EventArgs e) - { - LoadAddins (); - } - - public void OnPageChanged () - { - switch (wizardNotebook.CurrentPage) { - case 0: - btnPrev.Sensitive = false; - btnNext.Sensitive = (tree.GetSelectedAddins().Length != 0); - break; - case 1: - FillSummaryPage (); - break; - case 2: - Install (); - break; - case 3: - btnPrev.Hide (); - btnNext.Hide (); - btnCancel.Hide (); - btnOk.Show (); - break; - } - } - - protected void OnGotoWeb (object sender, EventArgs e) - { - AddinHeader info = tree.ActiveAddin; - if (info == null) - return; - - if (info.Url != "") - Process.Start (info.Url); - } - - protected void OnShowInfo (object sender, EventArgs e) - { - AddinHeader info = tree.ActiveAddin; - if (info == null) - return; - - AddinInfoDialog dlg = new AddinInfoDialog (info); - try { - dlg.Run (); - } finally { - dlg.Destroy (); - } - } - - protected void OnFilterChanged (object sender, EventArgs e) - { - LoadAddins (); - UpdateAddinSelection (); - } - - protected void OnSelectAll (object sender, EventArgs e) - { - tree.SelectAll (); - } - - protected void OnUnselectAll (object sender, EventArgs e) - { - tree.UnselectAll (); - } - - public void SetUninstallMode (AddinHeader info) - { - btnPrev.Hide (); - btnNext.Sensitive = true; - - uninstallId = info.Id; - wizardNotebook.CurrentPage = 1; - - StringBuilder sb = new StringBuilder (); - sb.Append ("").Append (Catalog.GetString ("The following packages will be uninstalled:")).Append ("\n\n"); - sb.Append (info.Name + "\n\n"); - - Addin[] sinfos = service.GetDependentAddins (info.Id, true); - if (sinfos.Length > 0) { - sb.Append ("").Append (Catalog.GetString ("There are other add-ins that depend on the previous ones which will also be uninstalled:")).Append ("\n\n"); - foreach (Addin si in sinfos) - sb.Append (si.Description.Name + "\n"); - } - - labelSummary.Markup = sb.ToString (); - } - - void FillAddinInfo () - { - AddinHeader info = tree.ActiveAddin; - btnInfo.Sensitive = info != null; - -/* if (info == null) { - infoLabel.Markup = ""; - linkLabel.Visible = false; - return; - } - - StringBuilder sb = new StringBuilder (); - sb.Append ("" + info.Name + "\n\n"); - - if (info.Description != "") - sb.Append (info.Description + "\n\n"); - - sb.Append (""); - - sb.Append ("").Append (Catalog.GetString ("Version:")).Append ("\n").Append (info.Version).Append ("\n\n"); - - if (info.Author != "") - sb.Append ("").Append (Catalog.GetString ("Author:")).Append ("\n").Append (info.Author).Append ("\n\n"); - - if (info.Copyright != "") - sb.Append ("").Append (Catalog.GetString ("Copyright:")).Append ("\n").Append (info.Copyright).Append ("\n\n"); - - if (info.Dependencies.Count > 0) { - sb.Append ("").Append (Catalog.GetString ("Add-in Dependencies:")).Append ("\n"); - foreach (PackageDependency dep in info.Dependencies) - sb.Append (dep.Name + "\n"); - } - - sb.Append (""); - - linkLabel.Visible = info.Url != ""; - - infoLabel.Markup = sb.ToString ();*/ - } - - - void FillSummaryPage () - { - btnPrev.Sensitive = true; - - AddinHeader[] infos = tree.GetSelectedAddins (); - PackageCollection packs = new PackageCollection (); - foreach (AddinHeader info in infos) { - AddinRepositoryEntry arep = (AddinRepositoryEntry) tree.GetAddinData (info); - packs.Add (Package.FromRepository (arep)); - } - - packagesToInstall = new PackageCollection (packs); - - PackageCollection toUninstall; - DependencyCollection unresolved; - bool res; - - InstallMonitor m = new InstallMonitor (); - res = service.ResolveDependencies (m, packs, out toUninstall, out unresolved); - - StringBuilder sb = new StringBuilder (); - if (!res) { - sb.Append ("").Append (Catalog.GetString ("The selected add-ins can't be installed because there are dependency conflicts.")).Append ("\n"); - foreach (string s in m.Errors) { - sb.Append ("" + s + "\n"); - } - sb.Append ("\n"); - } - - if (m.Warnings.Count != 0) { - foreach (string w in m.Warnings) { - sb.Append ("" + w + "\n"); - } - sb.Append ("\n"); - } - - sb.Append ("").Append (Catalog.GetString ("The following packages will be installed:")).Append ("\n\n"); - foreach (Package p in packs) { - sb.Append (p.Name); - if (!p.SharedInstall) - sb.Append (Catalog.GetString (" (in user directory)")); - sb.Append ("\n"); - } - sb.Append ("\n"); - - if (toUninstall.Count > 0) { - sb.Append ("").Append (Catalog.GetString ("The following packages need to be uninstalled:")).Append ("\n\n"); - foreach (Package p in toUninstall) { - sb.Append (p.Name + "\n"); - } - sb.Append ("\n"); - } - - if (unresolved.Count > 0) { - sb.Append ("").Append (Catalog.GetString ("The following dependencies could not be resolved:")).Append ("\n\n"); - foreach (Dependency p in unresolved) { - sb.Append (p.Name + "\n"); - } - sb.Append ("\n"); - } - btnNext.Sensitive = res; - labelSummary.Markup = sb.ToString (); - } - - void Install () - { - btnPrev.Sensitive = false; - btnNext.Sensitive = false; - - string txt; - string okmessage; - string errmessage; - string warnmessage; - - ThreadStart oper; - - if (uninstallId == null) { - installMonitor = new InstallMonitor (globalProgressLabel, mainProgressBar, Catalog.GetString ("Installing Add-ins")); - oper = new ThreadStart (RunInstall); - okmessage = Catalog.GetString ("The installation has been successfully completed."); - errmessage = Catalog.GetString ("The installation failed!"); - warnmessage = Catalog.GetString ("The installation has completed with warnings."); - } else { - installMonitor = new InstallMonitor (globalProgressLabel, mainProgressBar, Catalog.GetString ("Uninstalling Add-ins")); - oper = new ThreadStart (RunUninstall); - okmessage = Catalog.GetString ("The uninstallation has been successfully completed."); - errmessage = Catalog.GetString ("The uninstallation failed!"); - warnmessage = Catalog.GetString ("The uninstallation has completed with warnings."); - } - - Thread t = new Thread (oper); - t.Start (); - - installing = true; - installMonitor.WaitForCompleted (); - installing = false; - - wizardNotebook.NextPage (); - - if (installMonitor.Success && installMonitor.Warnings.Count == 0) { - imageWarn.Visible = false; - imageError.Visible = false; - imageInfo.Visible = true; - txt = "" + okmessage + "\n\n"; - } else if (installMonitor.Success) { - imageWarn.Visible = true; - imageInfo.Visible = false; - imageError.Visible = false; - txt = "" + warnmessage + "\n\n"; - foreach (string s in installMonitor.Warnings) - txt += GLib.Markup.EscapeText (s) + "\n"; - } else { - imageWarn.Visible = false; - imageInfo.Visible = false; - imageError.Visible = true; - txt = "" + errmessage + "\n\n"; - foreach (string s in installMonitor.Errors) - txt += GLib.Markup.EscapeText (s) + "\n"; - } - - labelResult.Markup = txt; - OnPageChanged (); - } - - void RunInstall () - { - try { - service.Install (installMonitor, packagesToInstall); - } catch { - // Nothing - } finally { - installMonitor.Dispose (); - } - } - - void RunUninstall () - { - try { - service.Uninstall (installMonitor, uninstallId); - } catch { - // Nothing - } finally { - installMonitor.Dispose (); - } - } - } - - class InstallMonitor: IProgressStatus, IDisposable - { - Label progressLabel; - ProgressBar progressBar; - StringCollection errors = new StringCollection (); - StringCollection warnings = new StringCollection (); - bool canceled; - bool done; - string mainOperation; - - public InstallMonitor (Label progressLabel, ProgressBar progressBar, string mainOperation) - { - this.progressLabel = progressLabel; - this.progressBar = progressBar; - this.mainOperation = mainOperation; - } - - public InstallMonitor () - { - } - - public void SetMessage (string msg) - { - if (progressLabel != null) - progressLabel.Markup = "" + GLib.Markup.EscapeText (mainOperation) + "\n" + GLib.Markup.EscapeText (msg); - } - - public void SetProgress (double progress) - { - if (progressBar != null) - progressBar.Fraction = progress; - } - - public void Log (string msg) - { - Console.WriteLine (msg); - } - - public void ReportWarning (string message) - { - warnings.Add (message); - } - - public void ReportError (string message, Exception exception) - { - errors.Add (message); - } - - public bool IsCanceled { - get { return canceled; } - } - - public StringCollection Errors { - get { return errors; } - } - - public StringCollection Warnings { - get { return warnings; } - } - - public void Cancel () - { - canceled = true; - } - - public int LogLevel { - get { return 1; } - } - - public void Dispose () - { - done = true; - } - - public void WaitForCompleted () - { - while (!done) { - while (Gtk.Application.EventsPending ()) - Gtk.Application.RunIteration (); - Thread.Sleep (50); - } - } - - public bool Success { - get { return errors.Count == 0; } - } - } - - class InstallAddinTreeWidget: AddinTreeWidget - { - int ncol; - public InstallAddinTreeWidget (Gtk.TreeView treeView): base (treeView) - { - } - - protected override void AddStoreTypes (ArrayList list) - { - base.AddStoreTypes (list); - ncol = list.Count; - list.Add (typeof(string)); - } - - protected override void CreateColumns () - { - base.CreateColumns (); - TreeViewColumn col = new TreeViewColumn (); - col.Title = Catalog.GetString ("Repository"); - CellRendererText crt = new CellRendererText (); - col.PackStart (crt, true); - col.AddAttribute (crt, "text", ncol); - treeView.AppendColumn (col); - } - - protected override void UpdateRow (TreeIter iter, AddinHeader info, object dataItem, bool enabled, Gdk.Pixbuf icon) - { - base.UpdateRow (iter, info, dataItem, enabled, icon); - AddinRepositoryEntry arep = (AddinRepositoryEntry) dataItem; - treeStore.SetValue (iter, ncol, arep.RepositoryName); - } - } -} - diff -Nru mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/AddinManagerDialog.cs mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/AddinManagerDialog.cs --- mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/AddinManagerDialog.cs 2008-11-06 19:51:59.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/AddinManagerDialog.cs 2011-04-13 09:00:29.000000000 +0000 @@ -30,21 +30,37 @@ using Gtk; using Mono.Addins.Setup; using Mono.Addins; +using Mono.Unix; +using System.Threading; +using System.Text; +using System.Collections.Generic; +using System.Linq; namespace Mono.Addins.Gui { partial class AddinManagerDialog : Dialog, IDisposable { AddinTreeWidget tree; + AddinTreeWidget galleryTree; + AddinTreeWidget updatesTree; + SetupService service = new SetupService (); + ListStore repoStore; + int lastRepoActive; + SearchEntry filterEntry; + Label installedTabLabel; + Label updatesTabLabel; + Label galleryTabLabel; + + const string AllRepoMarker = "__ALL"; + const string ManageRepoMarker = "__MANAGE"; internal bool AllowInstall { set { - this.btnInstall.Visible = value; - this.btnRepositories.Visible = value; - this.hseparator4.Visible = value; - this.btnUninstall.Visible = value; + addininfoInstalled.AllowInstall = value; + addininfoGallery.AllowInstall = value; + addininfoUpdates.AllowInstall = value; } } @@ -52,10 +68,119 @@ { Build (); TransientFor = parent; - + HasSeparator = false; + Services.PlaceDialog (this, parent); + Show (); + + addininfoInstalled.Init (service); + addininfoGallery.Init (service); + + addinTree.Selection.Mode = SelectionMode.Multiple; tree = new AddinTreeWidget (addinTree); - LoadAddins (); - UpdateButtons (); + addinTree.Selection.Changed += OnSelectionChanged; + tree.VersionVisible = false; + + galleryTreeView.Selection.Mode = SelectionMode.Multiple; + galleryTree = new AddinTreeWidget (galleryTreeView); + galleryTree.VersionVisible = false; + galleryTree.ShowInstalledMarkers = true; + galleryTreeView.Selection.Changed += OnGallerySelectionChanged; + + updatesTreeView.Selection.Mode = SelectionMode.Multiple; + updatesTree = new AddinTreeWidget (updatesTreeView); + updatesTree.VersionVisible = false; + updatesTree.ShowCategories = false; + updatesTree.ShowInstalledMarkers = true; + updatesTreeView.Selection.Changed += OnGallerySelectionChanged; + + repoStore = new ListStore (typeof(string), typeof(string)); + repoCombo.Model = repoStore; + CellRendererText crt = new CellRendererText (); + repoCombo.PackStart (crt, true); + repoCombo.AddAttribute (crt, "text", 0); + repoCombo.RowSeparatorFunc = delegate(TreeModel model, TreeIter iter) { + string val = (string) model.GetValue (iter, 0); + return val == "---"; + }; + + // Make sure the tree has the focus when switching tabs + + vboxUpdates.FocusChain = new Widget [] { scrolledUpdates, eboxRepoUpdates }; + vboxGallery.FocusChain = new Widget [] { scrolledGallery, eboxRepo }; + + // Improve the look of the headers + + HBox tab = new HBox (false, 3); + tab.PackStart (new Image (Gdk.Pixbuf.LoadFromResource ("plugin-22.png")), false, false, 0); + installedTabLabel = new Label (Catalog.GetString ("Installed")); + tab.PackStart (installedTabLabel, true, true, 0); + tab.BorderWidth = 3; + tab.ShowAll (); + notebook.SetTabLabel (notebook.GetNthPage (0), tab); + + tab = new HBox (false, 3); + tab.PackStart (new Image (Gdk.Pixbuf.LoadFromResource ("plugin-update-22.png")), false, false, 0); + updatesTabLabel = new Label (Catalog.GetString ("Updates")); + tab.PackStart (updatesTabLabel, true, true, 0); + tab.BorderWidth = 3; + tab.ShowAll (); + notebook.SetTabLabel (notebook.GetNthPage (1), tab); + + tab = new HBox (false, 3); + tab.PackStart (new Image (Gdk.Pixbuf.LoadFromResource ("system-software-update_22.png")), false, false, 0); + galleryTabLabel = new Label (Catalog.GetString ("Gallery")); + tab.PackStart (galleryTabLabel, true, true, 0); + tab.BorderWidth = 3; + tab.ShowAll (); + notebook.SetTabLabel (notebook.GetNthPage (2), tab); + + // Gradient header for the updates and gallery tabs + + HeaderBox hb = new HeaderBox (1, 0, 1, 1); + hb.SetPadding (6,6,6,6); + hb.GradientBackround = true; + hb.Show (); + hb.Replace (eboxRepo); + + hb = new HeaderBox (1, 0, 1, 1); + hb.SetPadding (6,6,6,6); + hb.GradientBackround = true; + hb.Show (); + hb.Replace (eboxRepoUpdates); + + InsertFilterEntry (); + + FillRepos (); + repoCombo.Active = 0; + + LoadAll (); + } + + void InsertFilterEntry () + { + filterEntry = new SearchEntry (); + filterEntry.Entry.SetSizeRequest (200, filterEntry.Entry.SizeRequest ().Height); + filterEntry.Parent = notebook; + filterEntry.Show (); + notebook.SizeAllocated += delegate { + RepositionFilter (); + }; + filterEntry.TextChanged += delegate { + tree.SetFilter (filterEntry.Text); + galleryTree.SetFilter (filterEntry.Text); + updatesTree.SetFilter (filterEntry.Text); + LoadAll (); + addinTree.ExpandAll (); + galleryTreeView.ExpandAll (); + }; + RepositionFilter (); + } + + void RepositionFilter () + { + int w = filterEntry.SizeRequest ().Width; + int h = filterEntry.SizeRequest ().Height; + filterEntry.Allocation = new Gdk.Rectangle (notebook.Allocation.Right - w - 1, notebook.Allocation.Y, w, h); } public override void Dispose () @@ -66,117 +191,360 @@ internal void OnSelectionChanged (object sender, EventArgs args) { - UpdateButtons (); + UpdateAddinInfo (); } - internal void OnInstall (object sender, EventArgs e) + internal void OnManageRepos (object sender, EventArgs e) { - AddinInstallDialog dlg = new AddinInstallDialog (service); + ManageSitesDialog dlg = new ManageSitesDialog (this, service); try { dlg.Run (); - LoadAddins (); } finally { dlg.Destroy (); } } - internal void OnUpdate (object sender, EventArgs e) + void LoadAll () + { + LoadInstalled (); + LoadGallery (); + LoadUpdates (); + UpdateAddinInfo (); + } + + void UpdateAddinInfo () + { + addininfoInstalled.ShowAddins (tree.ActiveAddinsData); + addininfoGallery.ShowAddins (galleryTree.ActiveAddinsData); + addininfoUpdates.ShowAddins (updatesTree.ActiveAddinsData); + } + + void LoadInstalled () + { + object s = tree.SaveStatus (); + + int count = 0; + tree.Clear (); + foreach (Addin ainfo in AddinManager.Registry.GetModules (AddinSearchFlags.IncludeAddins | AddinSearchFlags.LatestVersionsOnly)) { + if (Services.InApplicationNamespace (service, ainfo.Id) && !ainfo.Description.IsHidden) { + AddinHeader ah = SetupService.GetAddinHeader (ainfo); + if (IsFiltered (ah)) + continue; + AddinStatus st = AddinStatus.Installed; + if (!ainfo.Enabled || Services.GetMissingDependencies (ainfo).Any()) + st |= AddinStatus.Disabled; + if (addininfoInstalled.GetUpdate (ainfo) != null) + st |= AddinStatus.HasUpdate; + tree.AddAddin (ah, ainfo, st); + count++; + } + } + + if (count > 0) + tree.RestoreStatus (s); + else + tree.ShowEmptyMessage (); + + UpdateAddinInfo (); + + installedTabLabel.Text = Catalog.GetString ("Installed"); + + if (filterEntry.Text.Length != 0 && count > 0) + installedTabLabel.Text += " (" + count + ")"; + } + + void FillRepos () + { + int i = repoCombo.Active; + repoStore.Clear (); + + repoStore.AppendValues (Catalog.GetString ("All repositories"), AllRepoMarker); + + foreach (AddinRepository rep in service.Repositories.GetRepositories ()) { + if (rep.Enabled) + repoStore.AppendValues (rep.Title, rep.Url); + } + repoStore.AppendValues ("---", ""); + repoStore.AppendValues (Catalog.GetString ("Manage Repositories..."), ManageRepoMarker); + repoCombo.Active = i; + } + + string GetRepoSelection () + { + Gtk.TreeIter iter; + if (!repoCombo.GetActiveIter (out iter)) + return null; + return (string) repoStore.GetValue (iter, 1); + } + + void LoadGallery () + { + object s = galleryTree.SaveStatus (); + + galleryTree.Clear (); + + string rep = GetRepoSelection (); + + AddinRepositoryEntry[] reps; + if (rep == AllRepoMarker) + reps = service.Repositories.GetAvailableAddins (RepositorySearchFlags.LatestVersionsOnly); + else + reps = service.Repositories.GetAvailableAddins (rep, RepositorySearchFlags.LatestVersionsOnly); + + int count = 0; + + foreach (AddinRepositoryEntry arep in reps) + { + if (!Services.InApplicationNamespace (service, arep.Addin.Id)) + continue; + + if (IsFiltered (arep.Addin)) + continue; + + AddinStatus status = AddinStatus.NotInstalled; + + // Find whatever version is installed + Addin sinfo = AddinManager.Registry.GetAddin (Addin.GetIdName (arep.Addin.Id)); + + if (sinfo != null) { + status |= AddinStatus.Installed; + if (!sinfo.Enabled || Services.GetMissingDependencies (sinfo).Any()) + status |= AddinStatus.Disabled; + if (Addin.CompareVersions (sinfo.Version, arep.Addin.Version) > 0) + status |= AddinStatus.HasUpdate; + } + galleryTree.AddAddin (arep.Addin, arep, status); + count++; + } + + if (count > 0) + galleryTree.RestoreStatus (s); + else + galleryTree.ShowEmptyMessage (); + + galleryTabLabel.Text = Catalog.GetString ("Gallery"); + + if (filterEntry.Text.Length != 0 && count > 0) + galleryTabLabel.Text += " (" + count + ")"; + } + + void LoadUpdates () + { + object s = updatesTree.SaveStatus (); + + updatesTree.Clear (); + + AddinRepositoryEntry[] reps; + reps = service.Repositories.GetAvailableAddins (RepositorySearchFlags.LatestVersionsOnly); + + int count = 0; + + foreach (AddinRepositoryEntry arep in reps) + { + if (!Services.InApplicationNamespace (service, arep.Addin.Id)) + continue; + + // Find whatever version is installed + Addin sinfo = AddinManager.Registry.GetAddin (Addin.GetIdName (arep.Addin.Id)); + if (sinfo == null || !sinfo.Enabled || Addin.CompareVersions (sinfo.Version, arep.Addin.Version) <= 0) + continue; + + if (IsFiltered (arep.Addin)) + continue; + + AddinStatus status = AddinStatus.Installed; + if (!sinfo.Enabled || Services.GetMissingDependencies (sinfo).Any()) + status |= AddinStatus.Disabled; + + updatesTree.AddAddin (arep.Addin, arep, status | AddinStatus.HasUpdate); + count++; + } + + labelUpdates.Text = string.Format (Catalog.GetPluralString ("{0} update available", "{0} updates available", count), count); + updatesTabLabel.Text = Catalog.GetString ("Updates"); + if (count > 0) + updatesTabLabel.Text += " (" + count + ")"; + + buttonUpdateAll.Visible = count > 0; + + if (count > 0) + updatesTree.RestoreStatus (s); + else + updatesTree.ShowEmptyMessage (); + } + + bool IsFiltered (AddinHeader ah) { + if (filterEntry.Text.Length == 0) + return false; + if (ah.Name.IndexOf (filterEntry.Text, StringComparison.CurrentCultureIgnoreCase) != -1) + return false; + if (ah.Description.IndexOf (filterEntry.Text, StringComparison.CurrentCultureIgnoreCase) != -1) + return false; + if (ah.Id.IndexOf (filterEntry.Text, StringComparison.CurrentCultureIgnoreCase) != -1) + return false; + return true; } - internal void OnUninstall (object sender, EventArgs e) + void ManageSites () { - AddinHeader info = (AddinHeader) tree.ActiveAddin; - AddinInstallDialog dlg = new AddinInstallDialog (service); + ManageSitesDialog dlg = new ManageSitesDialog (this, service); try { - dlg.SetUninstallMode (info); dlg.Run (); - LoadAddins (); + repoCombo.Active = lastRepoActive; + FillRepos (); } finally { dlg.Destroy (); } } - internal void OnEnable (object sender, EventArgs e) + protected virtual void OnRepoComboChanged (object sender, System.EventArgs e) { + if (GetRepoSelection () == ManageRepoMarker) + ManageSites (); + else + LoadGallery (); + lastRepoActive = repoCombo.Active; + } + + protected virtual void OnGallerySelectionChanged (object sender, System.EventArgs e) + { + UpdateAddinInfo (); + } + + protected virtual void OnButtonRefreshClicked (object sender, System.EventArgs e) + { + ProgressDialog pdlg = new ProgressDialog (this); + pdlg.Show (); + pdlg.SetMessage (AddinManager.CurrentLocalizer.GetString ("Updating repository")); + bool updateDone = false; + + Thread t = new Thread (delegate () { + try { + service.Repositories.UpdateAllRepositories (pdlg); + } finally { + updateDone = true; + } + }); + t.Start (); + while (!updateDone) { + while (Gtk.Application.EventsPending ()) + Gtk.Application.RunIteration (); + Thread.Sleep (50); + } + pdlg.Destroy (); + LoadGallery (); + LoadUpdates (); + } + + protected virtual void OnInstallClicked (object sender, System.EventArgs e) + { + InstallDialog dlg = new InstallDialog (this, service); try { - Addin sinfo = (Addin) tree.ActiveAddinData; - if (sinfo == null) - return; - sinfo.Enabled = true; - LoadAddins (); + List selectedEntry = ((AddinInfoView)sender).SelectedEntries; + dlg.InitForInstall (selectedEntry.ToArray ()); + if (dlg.Run () == (int) Gtk.ResponseType.Ok) + LoadAll (); + } finally { + dlg.Destroy (); } - catch (Exception ex) { - Services.ShowError (ex, null, this, true); + } + + protected virtual void OnUninstallClicked (object sender, System.EventArgs e) + { + List selectedAddin = ((AddinInfoView)sender).SelectedAddins; + InstallDialog dlg = new InstallDialog (this, service); + try { + dlg.InitForUninstall (selectedAddin.ToArray ()); + if (dlg.Run () == (int) Gtk.ResponseType.Ok) { + LoadAll (); + } + } finally { + dlg.Destroy (); } } - internal void OnDisable (object sender, EventArgs e) + protected virtual void OnUpdateClicked (object sender, System.EventArgs e) { + List selectedEntry = ((AddinInfoView)sender).SelectedEntries; + InstallDialog dlg = new InstallDialog (this, service); try { - Addin sinfo = (Addin) tree.ActiveAddinData; - if (sinfo == null) - return; - sinfo.Enabled = false; - LoadAddins (); + dlg.InitForInstall (selectedEntry.ToArray ()); + if (dlg.Run () == (int) Gtk.ResponseType.Ok) + LoadAll (); + } finally { + dlg.Destroy (); + } + } + + protected virtual void OnEnableDisableClicked (object sender, System.EventArgs e) + { + try { + foreach (Addin a in ((AddinInfoView)sender).SelectedAddins) { + a.Enabled = !a.Enabled; + } + LoadAll (); } catch (Exception ex) { Services.ShowError (ex, null, this, true); } } - internal void OnShowInfo (object sender, EventArgs e) + protected virtual void OnUpdateAll (object sender, System.EventArgs e) { - Addin sinfo = (Addin) tree.ActiveAddinData; - if (sinfo == null) - return; - - AddinInfoDialog dlg = new AddinInfoDialog (SetupService.GetAddinHeader (sinfo)); + object[] data = updatesTree.AddinsData; + AddinRepositoryEntry[] entries = new AddinRepositoryEntry [data.Length]; + Array.Copy (data, entries, data.Length); + InstallDialog dlg = new InstallDialog (this, service); try { - dlg.Run (); + dlg.InitForInstall (entries); + if (dlg.Run () == (int) Gtk.ResponseType.Ok) + LoadAll (); } finally { dlg.Destroy (); } } - internal void OnManageRepos (object sender, EventArgs e) + static string lastFolder; + + protected virtual void OnButtonInstallFromFileClicked (object sender, System.EventArgs e) { - ManageSitesDialog dlg = new ManageSitesDialog (service); - dlg.TransientFor = this; + string[] files; + Gtk.FileChooserDialog dlg = new Gtk.FileChooserDialog (Catalog.GetString ("Install Add-in Package"), this, FileChooserAction.Open); try { - dlg.Run (); + if (lastFolder != null) + dlg.SetCurrentFolder (lastFolder); + else + dlg.SetCurrentFolder (Environment.GetFolderPath (Environment.SpecialFolder.Personal)); + dlg.SelectMultiple = true; + + Gtk.FileFilter f = new Gtk.FileFilter (); + f.AddPattern ("*.mpack"); + f.Name = Catalog.GetString ("Add-in packages"); + dlg.AddFilter (f); + + f = new Gtk.FileFilter (); + f.AddPattern ("*"); + f.Name = Catalog.GetString ("All files"); + dlg.AddFilter (f); + + dlg.AddButton (Gtk.Stock.Cancel, ResponseType.Cancel); + dlg.AddButton (Gtk.Stock.Open, ResponseType.Ok); + if (dlg.Run () != (int) Gtk.ResponseType.Ok) + return; + files = dlg.Filenames; + lastFolder = dlg.CurrentFolder; } finally { dlg.Destroy (); } - } - - void LoadAddins () - { - object s = tree.SaveStatus (); - tree.Clear (); - foreach (Addin ainfo in AddinManager.Registry.GetAddins ()) { - if (Services.InApplicationNamespace (service, ainfo.Id) && !ainfo.Description.IsHidden) - tree.AddAddin (SetupService.GetAddinHeader (ainfo), ainfo, ainfo.Enabled, ainfo.IsUserAddin); - } - - tree.RestoreStatus (s); - UpdateButtons (); - } - - void UpdateButtons () - { - Addin sinfo = (Addin) tree.ActiveAddinData; - if (sinfo == null) { - btnEnable.Sensitive = false; - btnDisable.Sensitive = false; - btnUninstall.Sensitive = false; - btnInfo.Sensitive = false; - } else { - btnEnable.Sensitive = !sinfo.Enabled && sinfo.Description.CanDisable; - btnDisable.Sensitive = sinfo.Enabled && sinfo.Description.CanDisable; - btnUninstall.Sensitive = true && sinfo.Description.CanUninstall; - btnInfo.Sensitive = true; + InstallDialog idlg = new InstallDialog (this, service); + try { + idlg.InitForInstall (files); + if (idlg.Run () == (int) Gtk.ResponseType.Ok) + LoadAll (); + } finally { + idlg.Destroy (); } } } diff -Nru mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/AddinTreeWidget.cs mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/AddinTreeWidget.cs --- mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/AddinTreeWidget.cs 2008-11-06 19:51:59.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/AddinTreeWidget.cs 2011-04-13 09:00:29.000000000 +0000 @@ -34,6 +34,9 @@ using Mono.Addins; using Mono.Addins.Setup; using Mono.Unix; +using System.Collections.Generic; +using System.Text; +using System.IO; namespace Mono.Addins.Gui { @@ -44,9 +47,14 @@ bool allowSelection; ArrayList selected = new ArrayList (); Hashtable addinData = new Hashtable (); - - Gdk.Pixbuf package; - Gdk.Pixbuf userPackage; + TreeViewColumn versionColumn; + string filter; + Dictionary cachedIcons = new Dictionary (); + bool disposed; + + Gdk.Pixbuf iconInstalled; + Gdk.Pixbuf updateOverlay; + Gdk.Pixbuf installedOverlay; public event EventHandler SelectionChanged; @@ -61,8 +69,9 @@ public AddinTreeWidget (Gtk.TreeView treeView) { - package = Gdk.Pixbuf.LoadFromResource ("package-x-generic_22.png"); - userPackage = Gdk.Pixbuf.LoadFromResource ("user-package.png"); + iconInstalled = Gdk.Pixbuf.LoadFromResource ("plugin-32.png"); + updateOverlay = Gdk.Pixbuf.LoadFromResource ("software-update-available-overlay.png"); + installedOverlay = Gdk.Pixbuf.LoadFromResource ("installed-overlay.png"); this.treeView = treeView; ArrayList list = new ArrayList (); @@ -71,6 +80,26 @@ treeStore = new Gtk.TreeStore (types); treeView.Model = treeStore; CreateColumns (); + ShowCategories = true; + + treeView.Destroyed += HandleTreeViewDestroyed; + } + + void HandleTreeViewDestroyed (object sender, EventArgs e) + { + disposed = true; + foreach (var px in cachedIcons.Values) + if (px != null) px.Dispose (); + } + + internal void SetFilter (string text) + { + this.filter = text; + } + + internal void ShowEmptyMessage () + { + treeStore.AppendValues (null, null, Catalog.GetString ("No add-ins found"), "", false, false, null, false); } protected virtual void AddStoreTypes (ArrayList list) @@ -101,17 +130,20 @@ col.AddAttribute (pr, "visible", ColShowImage); CellRendererText crt = new CellRendererText (); + crt.Ellipsize = Pango.EllipsizeMode.End; col.PackStart (crt, true); col.AddAttribute (crt, "markup", ColName); col.AddAttribute (crtog, "visible", ColAllowSelection); col.AddAttribute (crtog, "active", ColSelected); + col.Expand = true; treeView.AppendColumn (col); col = new TreeViewColumn (); col.Title = Catalog.GetString ("Version"); col.PackStart (crt, true); col.AddAttribute (crt, "markup", ColVersion); + versionColumn = col; treeView.AppendColumn (col); } @@ -120,6 +152,18 @@ set { allowSelection = value; } } + public bool VersionVisible { + get { + return versionColumn.Visible; + } + set { + versionColumn.Visible = value; + treeView.HeadersVisible = value; + } + } + + public bool ShowCategories { get; set; } + void OnAddinToggled (object o, ToggledArgs args) { TreeIter it; @@ -151,53 +195,170 @@ public TreeIter AddAddin (AddinHeader info, object dataItem, bool enabled) { - return AddAddin (info, dataItem, enabled, false); + return AddAddin (info, dataItem, enabled, true); } public TreeIter AddAddin (AddinHeader info, object dataItem, bool enabled, bool userDir) { - Gdk.Pixbuf icon; - if (userDir) - icon = userPackage; - else - icon = package; - + return AddAddin (info, dataItem, enabled ? AddinStatus.Installed : AddinStatus.Disabled | AddinStatus.Installed); + } + + public TreeIter AddAddin (AddinHeader info, object dataItem, AddinStatus status) + { addinData [info] = dataItem; - TreeIter piter = TreeIter.Zero; - if (info.Category == "") { - string otherCat = Catalog.GetString ("Other"); - piter = FindCategory (otherCat); + TreeIter iter; + if (ShowCategories) { + TreeIter piter = TreeIter.Zero; + if (info.Category == "") { + string otherCat = Catalog.GetString ("Other"); + piter = FindCategory (otherCat); + } else { + piter = FindCategory (info.Category); + } + iter = treeStore.AppendNode (piter); } else { - piter = FindCategory (info.Category); + iter = treeStore.AppendNode (); } - - TreeIter iter = treeStore.AppendNode (piter); - UpdateRow (iter, info, dataItem, enabled, icon); + UpdateRow (iter, info, dataItem, status); return iter; } - protected virtual void UpdateRow (TreeIter iter, AddinHeader info, object dataItem, bool enabled, Gdk.Pixbuf icon) + protected virtual void UpdateRow (TreeIter iter, AddinHeader info, object dataItem, AddinStatus status) { bool sel = selected.Contains (info); treeStore.SetValue (iter, ColAddin, info); treeStore.SetValue (iter, ColData, dataItem); - if (enabled) { - treeStore.SetValue (iter, ColName, info.Name); + string name = EscapeWithFilterMarker (info.Name); + if (!string.IsNullOrEmpty (info.Description)) { + string desc = info.Description; + int i = desc.IndexOf ('\n'); + if (i != -1) + desc = desc.Substring (0, i); + name += "\n" + EscapeWithFilterMarker (desc) + ""; + } + + if (status != AddinStatus.Disabled) { + treeStore.SetValue (iter, ColName, name); treeStore.SetValue (iter, ColVersion, info.Version); treeStore.SetValue (iter, ColAllowSelection, allowSelection); } else { - treeStore.SetValue (iter, ColName, "" + info.Name + ""); + treeStore.SetValue (iter, ColName, "" + name + ""); treeStore.SetValue (iter, ColVersion, "" + info.Version + ""); treeStore.SetValue (iter, ColAllowSelection, false); } - treeStore.SetValue (iter, ColImage, icon); treeStore.SetValue (iter, ColShowImage, true); - treeStore.SetValue (iter, ColSelected, sel); + SetRowIcon (iter, info, dataItem, status); + } + + void SetRowIcon (TreeIter it, AddinHeader info, object dataItem, AddinStatus status) + { + string customIcom = info.Properties.GetPropertyValue ("Icon32"); + string iconId = info.Id + " " + info.Version + " " + customIcom; + Gdk.Pixbuf customPix; + + if (customIcom.Length == 0) { + customPix = null; + iconId = "__"; + } + else if (!cachedIcons.TryGetValue (iconId, out customPix)) { + + if (dataItem is Addin) { + string file = Path.Combine (((Addin)dataItem).Description.BasePath, customIcom); + if (File.Exists (file)) { + try { + customPix = new Gdk.Pixbuf (file); + } catch (Exception ex) { + Console.WriteLine (ex); + } + } + cachedIcons [iconId] = customPix; + } + else if (dataItem is AddinRepositoryEntry) { + AddinRepositoryEntry arep = (AddinRepositoryEntry) dataItem; + string tmpId = iconId; + arep.BeginDownloadSupportFile (customIcom, delegate (IAsyncResult res) { + Gtk.Application.Invoke (delegate { + LoadRemoteIcon (it, tmpId, arep, res, info, dataItem, status); + }); + }, null); + iconId = "__"; + } + } + + StoreIcon (it, iconId, customPix, status); + } + + Gdk.Pixbuf GetCachedIcon (string id, string effect, Func pixbufGenerator) + { + Gdk.Pixbuf pix; + if (!cachedIcons.TryGetValue (id + "_" + effect, out pix)) + cachedIcons [id + "_" + effect] = pix = pixbufGenerator (); + return pix; + } + + internal bool ShowInstalledMarkers = false; + + void StoreIcon (TreeIter it, string iconId, Gdk.Pixbuf customPix, AddinStatus status) + { + if (customPix == null) + customPix = iconInstalled; + + if ((status & AddinStatus.Installed) == 0) { + treeStore.SetValue (it, ColImage, customPix); + return; + } else if (ShowInstalledMarkers && (status & AddinStatus.HasUpdate) == 0) { + customPix = GetCachedIcon (iconId, "InstalledOverlay", delegate { return Services.AddIconOverlay (customPix, installedOverlay); }); + iconId = iconId + "_Installed"; + } + + if ((status & AddinStatus.Disabled) != 0) { + customPix = GetCachedIcon (iconId, "Desaturate", delegate { return Services.DesaturateIcon (customPix); }); + iconId = iconId + "_Desaturate"; + } + if ((status & AddinStatus.HasUpdate) != 0) + customPix = GetCachedIcon (iconId, "UpdateOverlay", delegate { return Services.AddIconOverlay (customPix, updateOverlay); }); + + treeStore.SetValue (it, ColImage, customPix); + } + + + void LoadRemoteIcon (TreeIter it, string iconId, AddinRepositoryEntry arep, IAsyncResult res, AddinHeader info, object dataItem, AddinStatus status) + { + if (!disposed && treeStore.IterIsValid (it)) { + Gdk.Pixbuf customPix = null; + try { + Gdk.PixbufLoader loader = new Gdk.PixbufLoader (arep.EndDownloadSupportFile (res)); + customPix = loader.Pixbuf; + } catch (Exception ex) { + Console.WriteLine (ex); + } + cachedIcons [iconId] = customPix; + StoreIcon (it, iconId, customPix, status); + } + } + + string EscapeWithFilterMarker (string txt) + { + if (string.IsNullOrEmpty (filter)) + return GLib.Markup.EscapeText (txt); + + StringBuilder sb = new StringBuilder (); + int last = 0; + int i = txt.IndexOf (filter, StringComparison.CurrentCultureIgnoreCase); + while (i != -1) { + sb.Append (GLib.Markup.EscapeText (txt.Substring (last, i - last))); + sb.Append ("").Append (txt.Substring (i, filter.Length)).Append (""); + last = i + filter.Length; + i = txt.IndexOf (filter, last, StringComparison.CurrentCultureIgnoreCase); + } + if (last < txt.Length) + sb.Append (GLib.Markup.EscapeText (txt.Substring (last, txt.Length - last))); + return sb.ToString (); } public object GetAddinData (AddinHeader info) @@ -248,12 +409,25 @@ public AddinHeader ActiveAddin { get { - Gtk.TreeModel foo; - Gtk.TreeIter iter; - if (!treeView.Selection.GetSelected (out foo, out iter)) + AddinHeader[] sel = ActiveAddins; + if (sel.Length > 0) + return sel[0]; + else return null; - - return (AddinHeader) treeStore.GetValue (iter, 0); + } + } + + public AddinHeader[] ActiveAddins { + get { + List list = new List (); + foreach (TreePath p in treeView.Selection.GetSelectedRows ()) { + TreeIter iter; + treeStore.GetIter (out iter, p); + AddinHeader ah = (AddinHeader) treeStore.GetValue (iter, 0); + if (ah != null) + list.Add (ah); + } + return list.ToArray (); } } @@ -264,17 +438,31 @@ } } + public object[] ActiveAddinsData { + get { + List res = new List (); + foreach (AddinHeader ai in ActiveAddins) { + res.Add (GetAddinData (ai)); + } + return res.ToArray (); + } + } + + public object[] AddinsData { + get { + object[] data = new object [addinData.Count]; + addinData.Values.CopyTo (data, 0); + return data; + } + } + public object SaveStatus () { TreeIter iter; ArrayList list = new ArrayList (); // Save the current selection - Gtk.TreeModel foo; - if (treeView.Selection.GetSelected (out foo, out iter)) - list.Add (treeStore.GetPath (iter)); - else - list.Add (null); + list.Add (treeView.Selection.GetSelectedRows ()); if (!treeStore.GetIterFirst (out iter)) return null; @@ -306,14 +494,14 @@ // The first element is the selection ArrayList list = (ArrayList) ob; - TreePath selpath = (TreePath) list [0]; + TreePath[] selpaths = (TreePath[]) list [0]; list.RemoveAt (0); foreach (TreePath path in list) treeView.ExpandRow (path, false); - - if (selpath != null) - treeView.Selection.SelectPath (selpath); + + foreach (TreePath p in selpaths) + treeView.Selection.SelectPath (p); } public void SelectAll () @@ -372,4 +560,13 @@ } } } + + [Flags] + public enum AddinStatus + { + NotInstalled = 0, + Installed = 1, + Disabled = 2, + HasUpdate = 4 + } } diff -Nru mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/HeaderBox.cs mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/HeaderBox.cs --- mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/HeaderBox.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/HeaderBox.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,173 @@ +// +// HeaderBox.cs +// +// Author: +// Lluis Sanchez Gual +// +// Copyright (c) 2011 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using Gtk; + +namespace Mono.Addins.Gui +{ + class HeaderBox: Bin + { + Gtk.Widget child; + int topMargin; + int bottomMargin; + int leftMargin; + int rightMargin; + + int topPadding; + int bottomPadding; + int leftPadding; + int rightPadding; + + bool useCustomColor; + Gdk.Color customColor; + + public HeaderBox () + { + } + + public HeaderBox (int topMargin, int bottomMargin, int leftMargin, int rightMargin) + { + SetMargins (topMargin, bottomMargin, leftMargin, rightMargin); + } + + public void Replace (Gtk.Bin parent) + { + Gtk.Widget c = parent.Child; + parent.Remove (c); + Add (c); + parent.Add (this); + } + + public void SetMargins (int topMargin, int bottomMargin, int leftMargin, int rightMargin) + { + this.topMargin = topMargin; + this.bottomMargin = bottomMargin; + this.leftMargin = leftMargin; + this.rightMargin = rightMargin; + } + + public void SetPadding (int topPadding, int bottomPadding, int leftPadding, int rightPadding) + { + this.topPadding = topPadding; + this.bottomPadding = bottomPadding; + this.leftPadding = leftPadding; + this.rightPadding = rightPadding; + } + + public bool GradientBackround { get; set; } + + public Gdk.Color BackgroundColor { + get { return customColor; } + set { customColor = value; useCustomColor = true; } + } + + public void ResetBackgroundColor () + { + useCustomColor = false; + } + + protected override void OnAdded (Widget widget) + { + base.OnAdded (widget); + child = widget; + } + + protected override void OnSizeRequested (ref Requisition requisition) + { + if (child != null) { + requisition = child.SizeRequest (); + requisition.Width += leftMargin + rightMargin + leftPadding + rightPadding; + requisition.Height += topMargin + bottomMargin + topPadding + bottomPadding; + } else { + requisition.Width = 0; + requisition.Height = 0; + } + } + + protected override void OnSizeAllocated (Gdk.Rectangle allocation) + { + base.OnSizeAllocated (allocation); + if (allocation.Width > leftMargin + rightMargin + leftPadding + rightPadding) { + allocation.X += leftMargin + leftPadding; + allocation.Width -= leftMargin + rightMargin + leftPadding + rightPadding; + } + if (allocation.Height > topMargin + bottomMargin + topPadding + bottomPadding) { + allocation.Y += topMargin + topPadding; + allocation.Height -= topMargin + bottomMargin + topPadding + bottomPadding; + } + if (child != null) + child.SizeAllocate (allocation); + } + + protected override bool OnExposeEvent (Gdk.EventExpose evnt) + { + Gdk.Rectangle rect; + + if (GradientBackround) { + rect = new Gdk.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height); + HslColor gcol = useCustomColor ? customColor : Parent.Style.Background (Gtk.StateType.Normal); + + using (Cairo.Context cr = Gdk.CairoHelper.Create (GdkWindow)) { + cr.NewPath (); + cr.MoveTo (rect.X, rect.Y); + cr.RelLineTo (rect.Width, 0); + cr.RelLineTo (0, rect.Height); + cr.RelLineTo (-rect.Width, 0); + cr.RelLineTo (0, -rect.Height); + cr.ClosePath (); + Cairo.Gradient pat = new Cairo.LinearGradient (rect.X, rect.Y, rect.X, rect.Bottom); + Cairo.Color color1 = gcol; + pat.AddColorStop (0, color1); + gcol.L -= 0.1; + if (gcol.L < 0) gcol.L = 0; + pat.AddColorStop (1, gcol); + cr.Pattern = pat; + cr.FillPreserve (); + } + } + + bool res = base.OnExposeEvent (evnt); + + Gdk.GC borderColor = Parent.Style.DarkGC (Gtk.StateType.Normal); + + rect = Allocation; + for (int n=0; n + ****************************************************************************/ + +/* THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW: + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +using System; +using Gtk; + +namespace Mono.Addins.Gui +{ + class HoverImageButton : EventBox + { + private static Gdk.Cursor hand_cursor = new Gdk.Cursor(Gdk.CursorType.Hand1); + + private IconSize icon_size = IconSize.Menu; + private string [] icon_names = { "image-missing", Stock.MissingImage }; + private Gdk.Pixbuf normal_pixbuf; + private Gdk.Pixbuf active_pixbuf; + private Image image; + private bool is_hovering; + private bool is_pressed; + + private bool draw_focus = true; + + private event EventHandler clicked; + + public event EventHandler Clicked { + add { clicked += value; } + remove { clicked -= value; } + } + + public HoverImageButton() + { + CanFocus = true; + + image = new Image(); + image.Show(); + Add(image); + } + + public HoverImageButton(IconSize size, string icon_name) : this(size, new string [] { icon_name }) + { + } + + public HoverImageButton(IconSize size, string [] icon_names) : this() + { + this.icon_size = size; + this.icon_names = icon_names; + } + + public new void Activate() + { + EventHandler handler = clicked; + if(handler != null) { + handler(this, EventArgs.Empty); + } + } + + private bool changing_style = false; + protected override void OnStyleSet(Style previous_style) + { + if(changing_style) { + return; + } + + changing_style = true; + if (normal_pixbuf == null) + LoadPixbufs(); + changing_style = false; + } + + protected override bool OnEnterNotifyEvent(Gdk.EventCrossing evnt) + { + image.GdkWindow.Cursor = hand_cursor; + is_hovering = true; + UpdateImage(); + return base.OnEnterNotifyEvent(evnt); + } + + protected override bool OnLeaveNotifyEvent(Gdk.EventCrossing evnt) + { + is_hovering = false; + UpdateImage(); + return base.OnLeaveNotifyEvent(evnt); + } + + protected override bool OnFocusInEvent(Gdk.EventFocus evnt) + { + bool ret = base.OnFocusInEvent(evnt); + UpdateImage(); + return ret; + } + + protected override bool OnFocusOutEvent(Gdk.EventFocus evnt) + { + bool ret = base.OnFocusOutEvent(evnt); + UpdateImage(); + return ret; + } + + protected override bool OnButtonPressEvent(Gdk.EventButton evnt) + { + if(evnt.Button != 1) { + return base.OnButtonPressEvent(evnt); + } + + HasFocus = true; + is_pressed = true; + QueueDraw(); + + return base.OnButtonPressEvent(evnt); + } + + protected override bool OnButtonReleaseEvent(Gdk.EventButton evnt) + { + if(evnt.Button != 1) { + return base.OnButtonReleaseEvent(evnt); + } + + is_pressed = false; + QueueDraw(); + Activate(); + + return base.OnButtonReleaseEvent(evnt); + } + + protected override bool OnExposeEvent(Gdk.EventExpose evnt) + { + base.OnExposeEvent(evnt); + + PropagateExpose(Child, evnt); + + if(HasFocus && draw_focus) { + Style.PaintFocus(Style, GdkWindow, StateType.Normal, evnt.Area, this, "button", + 0, 0, Allocation.Width, Allocation.Height); + } + + return true; + } + + private void UpdateImage() + { + image.Pixbuf = is_hovering || is_pressed || HasFocus + ? active_pixbuf : normal_pixbuf; + } + + private void LoadPixbufs() + { + int width, height; + Icon.SizeLookup(icon_size, out width, out height); + IconTheme theme = IconTheme.GetForScreen(Screen); + + if(normal_pixbuf != null) { + normal_pixbuf.Dispose(); + normal_pixbuf = null; + } + + if(active_pixbuf != null) { + active_pixbuf.Dispose(); + active_pixbuf = null; + } + + for(int i = 0; i < icon_names.Length; i++) { + try { + normal_pixbuf = theme.LoadIcon(icon_names[i], width, 0); + active_pixbuf = ColorShiftPixbuf(normal_pixbuf, 30); + break; + } catch { + } + } + + UpdateImage(); + } + + public Gdk.Pixbuf Pixbuf { + get { return this.normal_pixbuf; } + set { + this.normal_pixbuf = value; + active_pixbuf = ColorShiftPixbuf(normal_pixbuf, 30); + UpdateImage(); + } + } + + + private static byte PixelClamp(int val) + { + return (byte)System.Math.Max(0, System.Math.Min(255, val)); + } + + private unsafe Gdk.Pixbuf ColorShiftPixbuf(Gdk.Pixbuf src, byte shift) + { + Gdk.Pixbuf dest = new Gdk.Pixbuf(src.Colorspace, src.HasAlpha, src.BitsPerSample, src.Width, src.Height); + + byte *src_pixels_orig = (byte *)src.Pixels; + byte *dest_pixels_orig = (byte *)dest.Pixels; + + for(int i = 0; i < src.Height; i++) { + byte *src_pixels = src_pixels_orig + i * src.Rowstride; + byte *dest_pixels = dest_pixels_orig + i * dest.Rowstride; + + for(int j = 0; j < src.Width; j++) { + *(dest_pixels++) = PixelClamp(*(src_pixels++) + shift); + *(dest_pixels++) = PixelClamp(*(src_pixels++) + shift); + *(dest_pixels++) = PixelClamp(*(src_pixels++) + shift); + + if(src.HasAlpha) { + *(dest_pixels++) = *(src_pixels++); + } + } + } + + return dest; + } + + public string [] IconNames { + get { return icon_names; } + set { + icon_names = value; + LoadPixbufs(); + } + } + + public IconSize IconSize { + get { return icon_size; } + set { + icon_size = value; + LoadPixbufs(); + } + } + + public Image Image { + get { return image; } + } + + public bool DrawFocus { + get { return draw_focus; } + set { + draw_focus = value; + QueueDraw(); + } + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/HslColor.cs mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/HslColor.cs --- mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/HslColor.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/HslColor.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,164 @@ +// +// HslColor.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using Gdk; + +namespace Mono.Addins.Gui +{ + struct HslColor + { + public double H { + get; + set; + } + + public double S { + get; + set; + } + + public double L { + get; + set; + } + + static Gdk.Color black = new Gdk.Color (0, 0, 0); + public static implicit operator Color (HslColor hsl) + { + if (hsl.L > 1) hsl.L = 1; + if (hsl.L < 0) hsl.L = 0; + if (hsl.H > 1) hsl.H = 1; + if (hsl.H < 0) hsl.H = 0; + if (hsl.S > 1) hsl.S = 1; + if (hsl.S < 0) hsl.S = 0; + + double r = 0, g = 0, b = 0; + + if (hsl.L == 0) + return black; + + if (hsl.S == 0) { + r = g = b = hsl.L; + } else { + double temp2 = hsl.L <= 0.5 ? hsl.L * (1.0 + hsl.S) : hsl.L + hsl.S -(hsl.L * hsl.S); + double temp1 = 2.0 * hsl.L - temp2; + + double[] t3 = new double[] { hsl.H + 1.0 / 3.0, hsl.H, hsl.H - 1.0 / 3.0}; + double[] clr= new double[] { 0, 0, 0}; + for (int i = 0; i < 3; i++) { + if (t3[i] < 0) + t3[i] += 1.0; + if (t3[i] > 1) + t3[i]-=1.0; + if (6.0 * t3[i] < 1.0) + clr[i] = temp1 + (temp2 - temp1) * t3[i] * 6.0; + else if (2.0 * t3[i] < 1.0) + clr[i] = temp2; + else if (3.0 * t3[i] < 2.0) + clr[i] = (temp1 + (temp2 - temp1) * ((2.0 / 3.0) - t3[i]) * 6.0); + else + clr[i] = temp1; + } + + r = clr[0]; + g = clr[1]; + b = clr[2]; + } + return new Color ((byte)(255 * r), + (byte)(255 * g), + (byte)(255 * b)); + } + + public static Cairo.Color ToCairoColor (Gdk.Color color) + { + return new Cairo.Color ((double)color.Red / ushort.MaxValue, + (double)color.Green / ushort.MaxValue, + (double)color.Blue / ushort.MaxValue); + } + + public static implicit operator Cairo.Color (HslColor hsl) + { + return ToCairoColor ((Gdk.Color)hsl); + } + + public static implicit operator HslColor (Color color) + { + return new HslColor (color); + } + + public HslColor (Color color) : this () + { + double r = color.Red / (double)ushort.MaxValue; + double g = color.Green / (double)ushort.MaxValue; + double b = color.Blue / (double)ushort.MaxValue; + + double v = System.Math.Max (r, g); + v = System.Math.Max (v, b); + + double m = System.Math.Min (r, g); + m = System.Math.Min (m, b); + + this.L = (m + v) / 2.0; + if (this.L <= 0.0) + return; + double vm = v - m; + this.S = vm; + + if (this.S > 0.0) { + this.S /= (this.L <= 0.5) ? (v + m) : (2.0 - v - m); + } else { + return; + } + + double r2 = (v - r) / vm; + double g2 = (v - g) / vm; + double b2 = (v - b) / vm; + + if (r == v) { + this.H = (g == m ? 5.0 + b2 : 1.0 - g2); + } else if (g == v) { + this.H = (b == m ? 1.0 + r2 : 3.0 - b2); + } else { + this.H = (r == m ? 3.0 + g2 : 5.0 - r2); + } + this.H /= 6.0; + } + + public static double Brightness (Gdk.Color c) + { + double r = c.Red / (double)ushort.MaxValue; + double g = c.Green / (double)ushort.MaxValue; + double b = c.Blue / (double)ushort.MaxValue; + return System.Math.Sqrt (r * .241 + g * .691 + b * .068); + } + + public override string ToString () + { + return string.Format ("[HslColor: H={0}, S={1}, L={2}]", H, S, L); + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/InstallDialog.cs mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/InstallDialog.cs --- mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/InstallDialog.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/InstallDialog.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,276 @@ +// +// InstallDialog.cs +// +// Author: +// Lluis Sanchez Gual +// +// Copyright (c) 2011 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using Mono.Addins.Setup; +using Mono.Addins.Description; +using System.Text; +using Mono.Unix; +using System.Threading; +using System.Linq; +using System.Collections.Generic; + +namespace Mono.Addins.Gui +{ + internal partial class InstallDialog : Gtk.Dialog + { + string[] filesToInstall; + AddinRepositoryEntry[] addinsToInstall; + PackageCollection packagesToInstall; + SetupService service; + Gtk.ResponseType response = Gtk.ResponseType.None; + IEnumerable uninstallIds; + InstallMonitor installMonitor; + bool installing; + const int MaxHeight = 350; + + public InstallDialog (Gtk.Window parent, SetupService service) + { + this.Build (); + this.service = service; + TransientFor = parent; + WindowPosition = Gtk.WindowPosition.CenterOnParent; + Services.PlaceDialog (this, parent); + boxProgress.Visible = false; + Resizable = false; + } + + public void InitForInstall (AddinRepositoryEntry[] addinsToInstall) + { + this.addinsToInstall = addinsToInstall; + FillSummaryPage (); + Services.PlaceDialog (this, TransientFor); + } + + public void InitForInstall (string[] filesToInstall) + { + this.filesToInstall = filesToInstall; + FillSummaryPage (); + Services.PlaceDialog (this, TransientFor); + } + + public void InitForUninstall (Addin[] info) + { + this.uninstallIds = info.Select (a => a.Id); + buttonOk.Label = Catalog.GetString ("Uninstall"); + + HashSet sinfos = new HashSet (); + + StringBuilder sb = new StringBuilder (); + sb.Append ("").Append (Catalog.GetString ("The following packages will be uninstalled:")).Append ("\n\n"); + foreach (var a in info) { + sb.Append (a.Name + "\n\n"); + sinfos.UnionWith (service.GetDependentAddins (a.Id, true)); + } + + if (sinfos.Count > 0) { + sb.Append ("").Append (Catalog.GetString ("There are other add-ins that depend on the previous ones which will also be uninstalled:")).Append ("\n\n"); + foreach (Addin si in sinfos) + sb.Append (si.Description.Name + "\n"); + } + + ShowMessage (sb.ToString ()); + Services.PlaceDialog (this, TransientFor); + } + + void FillSummaryPage () + { + PackageCollection packs = new PackageCollection (); + + if (filesToInstall != null) { + foreach (string file in filesToInstall) { + packs.Add (Package.FromFile (file)); + } + } + else { + foreach (AddinRepositoryEntry arep in addinsToInstall) { + packs.Add (Package.FromRepository (arep)); + } + } + + packagesToInstall = new PackageCollection (packs); + + PackageCollection toUninstall; + DependencyCollection unresolved; + bool res; + + InstallMonitor m = new InstallMonitor (); + res = service.ResolveDependencies (m, packs, out toUninstall, out unresolved); + + StringBuilder sb = new StringBuilder (); + if (!res) { + sb.Append ("").Append (Catalog.GetString ("The selected add-ins can't be installed because there are dependency conflicts.")).Append ("\n"); + foreach (string s in m.Errors) { + sb.Append ("" + s + "\n"); + } + sb.Append ("\n"); + } + + if (m.Warnings.Count != 0) { + foreach (string w in m.Warnings) { + sb.Append ("" + w + "\n"); + } + sb.Append ("\n"); + } + + sb.Append ("").Append (Catalog.GetString ("The following packages will be installed:")).Append ("\n\n"); + foreach (Package p in packs) { + sb.Append (p.Name); + if (!p.SharedInstall) + sb.Append (Catalog.GetString (" (in user directory)")); + sb.Append ("\n"); + } + sb.Append ("\n"); + + if (toUninstall.Count > 0) { + sb.Append ("").Append (Catalog.GetString ("The following packages need to be uninstalled:")).Append ("\n\n"); + foreach (Package p in toUninstall) { + sb.Append (p.Name + "\n"); + } + sb.Append ("\n"); + } + + if (unresolved.Count > 0) { + sb.Append ("").Append (Catalog.GetString ("The following dependencies could not be resolved:")).Append ("\n\n"); + foreach (Dependency p in unresolved) { + sb.Append (p.Name + "\n"); + } + sb.Append ("\n"); + } + buttonOk.Sensitive = res; + ShowMessage (sb.ToString ()); + } + + void ShowMessage (string txt) + { + labelInfo.Markup = txt.TrimEnd ('\n','\t',' '); + if (labelInfo.SizeRequest ().Height > MaxHeight) { + scrolledwindow1.VscrollbarPolicy = Gtk.PolicyType.Automatic; + scrolledwindow1.HeightRequest = MaxHeight; + } + else { + scrolledwindow1.HeightRequest = labelInfo.SizeRequest ().Height; + } + } + + protected virtual void OnButtonOkClicked (object sender, System.EventArgs e) + { + if (response != Gtk.ResponseType.None) { + Respond (response); + return; + } + Install (); + } + + protected virtual void OnButtonCancelClicked (object sender, System.EventArgs e) + { + if (installing) { + if (Services.AskQuestion (Catalog.GetString ("Are you sure you want to cancel the installation?"))) + installMonitor.Cancel (); + } else + Respond (Gtk.ResponseType.Cancel); + } + + void Install () + { + insSeparator.Visible = true; + boxProgress.Visible = true; + buttonOk.Sensitive = false; + + string txt; + string errmessage; + string warnmessage; + + ThreadStart oper; + + if (uninstallIds == null) { + installMonitor = new InstallMonitor (globalProgressLabel, mainProgressBar, Catalog.GetString ("Installing Add-ins")); + oper = new ThreadStart (RunInstall); + errmessage = Catalog.GetString ("The installation failed!"); + warnmessage = Catalog.GetString ("The installation has completed with warnings."); + } else { + installMonitor = new InstallMonitor (globalProgressLabel, mainProgressBar, Catalog.GetString ("Uninstalling Add-ins")); + oper = new ThreadStart (RunUninstall); + errmessage = Catalog.GetString ("The uninstallation failed!"); + warnmessage = Catalog.GetString ("The uninstallation has completed with warnings."); + } + + installing = true; + oper (); + installing = false; + + buttonCancel.Visible = false; + buttonOk.Label = Gtk.Stock.Close; + buttonOk.UseStock = true; + + if (installMonitor.Success && installMonitor.Warnings.Count == 0) { + Respond (Gtk.ResponseType.Ok); + return; + } else if (installMonitor.Success) { + txt = "" + warnmessage + "\n\n"; + foreach (string s in installMonitor.Warnings) + txt += GLib.Markup.EscapeText (s) + "\n"; + response = Gtk.ResponseType.Ok; + buttonOk.Sensitive = true; + } else { + buttonCancel.Label = Gtk.Stock.Close; + buttonCancel.UseStock = true; + txt = "" + errmessage + "\n\n"; + foreach (string s in installMonitor.Errors) + txt += GLib.Markup.EscapeText (s) + "\n"; + response = Gtk.ResponseType.Cancel; + buttonOk.Sensitive = true; + } + + ShowMessage (txt); + } + + void RunInstall () + { + try { + if (filesToInstall != null) + service.Install (installMonitor, filesToInstall); + else + service.Install (installMonitor, packagesToInstall); + } catch (Exception ex) { + installMonitor.Errors.Add (ex.Message); + } finally { + installMonitor.Dispose (); + } + } + + void RunUninstall () + { + try { + service.Uninstall (installMonitor, uninstallIds); + } catch (Exception ex) { + installMonitor.Errors.Add (ex.Message); + } finally { + installMonitor.Dispose (); + } + } + } +} + diff -Nru mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/InstallMonitor.cs mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/InstallMonitor.cs --- mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/InstallMonitor.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/InstallMonitor.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,133 @@ +// +// AddinInstallDialog.cs +// +// Author: +// Lluis Sanchez Gual +// +// Copyright (c) 2011 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Text; +using System.Threading; +using System.Collections; +using System.Collections.Specialized; +using System.Diagnostics; +using Mono.Unix; +using Gtk; +using Mono.Addins.Setup; +using Mono.Addins.Description; +namespace Mono.Addins.Gui +{ + class InstallMonitor: IProgressStatus, IDisposable + { + Label progressLabel; + ProgressBar progressBar; + StringCollection errors = new StringCollection (); + StringCollection warnings = new StringCollection (); + bool canceled; + bool done; + string mainOperation; + + public InstallMonitor (Label progressLabel, ProgressBar progressBar, string mainOperation) + { + this.progressLabel = progressLabel; + this.progressBar = progressBar; + this.mainOperation = mainOperation; + } + + public InstallMonitor () + { + } + + public void SetMessage (string msg) + { + if (progressLabel != null) + progressLabel.Markup = "" + GLib.Markup.EscapeText (mainOperation) + "\n" + GLib.Markup.EscapeText (msg); + RunPendingEvents (); + } + + public void SetProgress (double progress) + { + if (progressBar != null) + progressBar.Fraction = progress; + RunPendingEvents (); + } + + public void Log (string msg) + { + Console.WriteLine (msg); + } + + public void ReportWarning (string message) + { + warnings.Add (message); + } + + public void ReportError (string message, Exception exception) + { + errors.Add (message); + } + + public bool IsCanceled { + get { return canceled; } + } + + public StringCollection Errors { + get { return errors; } + } + + public StringCollection Warnings { + get { return warnings; } + } + + public void Cancel () + { + canceled = true; + } + + public int LogLevel { + get { return 1; } + } + + public void Dispose () + { + done = true; + } + + public void WaitForCompleted () + { + while (!done) { + RunPendingEvents (); + Thread.Sleep (50); + } + } + + public bool Success { + get { return errors.Count == 0; } + } + + void RunPendingEvents () + { + while (Gtk.Application.EventsPending ()) + Gtk.Application.RunIteration (); + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/ManageSitesDialog.cs mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/ManageSitesDialog.cs --- mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/ManageSitesDialog.cs 2008-11-06 19:51:59.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/ManageSitesDialog.cs 2011-04-13 09:00:29.000000000 +0000 @@ -42,34 +42,43 @@ ListStore treeStore; SetupService service; - public ManageSitesDialog (SetupService service) + public ManageSitesDialog (Gtk.Window parent, SetupService service) { Build (); + TransientFor = parent; + Services.PlaceDialog (this, parent); this.service = service; - treeStore = new Gtk.ListStore (typeof (string), typeof (string)); + treeStore = new Gtk.ListStore (typeof (string), typeof (string), typeof(bool)); repoTree.Model = treeStore; - repoTree.HeadersVisible = true; - repoTree.AppendColumn (Catalog.GetString ("Name"), new Gtk.CellRendererText (), "text", 1); - repoTree.AppendColumn (Catalog.GetString ("Url"), new Gtk.CellRendererText (), "text", 0); + repoTree.HeadersVisible = false; + var crt = new Gtk.CellRendererToggle (); + crt.Toggled += HandleRepoToggled; + repoTree.AppendColumn ("", crt, "active", 2); + repoTree.AppendColumn ("", new Gtk.CellRendererText (), "markup", 1); repoTree.Selection.Changed += new EventHandler(OnSelect); AddinRepository[] reps = service.Repositories.GetRepositories (); - foreach (AddinRepository rep in reps) { - treeStore.AppendValues (rep.Url, rep.Title); - } + foreach (AddinRepository rep in reps) + AppendRepository (rep); btnRemove.Sensitive = false; } - + public override void Dispose () { base.Dispose (); Destroy (); } + void AppendRepository (AddinRepository rep) + { + string txt = GLib.Markup.EscapeText (rep.Title) + "\n" + GLib.Markup.EscapeText (rep.Url) + ""; + treeStore.AppendValues (rep.Url, txt, rep.Enabled); + } + protected void OnAdd (object sender, EventArgs e) { - NewSiteDialog dlg = new NewSiteDialog (); + NewSiteDialog dlg = new NewSiteDialog (this); try { if (dlg.Run ()) { string url = dlg.Url; @@ -84,7 +93,7 @@ } if (!service.Repositories.ContainsRepository (url)) { - ProgressDialog pdlg = new ProgressDialog (); + ProgressDialog pdlg = new ProgressDialog (this); pdlg.Show (); pdlg.SetMessage (AddinManager.CurrentLocalizer.GetString ("Registering repository")); @@ -122,7 +131,7 @@ return; } - treeStore.AppendValues (rr.Url, rr.Title); + AppendRepository (rr); } } } finally { @@ -143,6 +152,19 @@ treeStore.Remove (ref iter); } + void HandleRepoToggled (object o, ToggledArgs args) + { + Gtk.TreeIter iter; + if (!treeStore.GetIterFromString (out iter, args.Path)) + return; + + bool newVal = !(bool) treeStore.GetValue (iter, 2); + string rep = (string) treeStore.GetValue (iter, 0); + service.Repositories.SetRepositoryEnabled (rep, newVal); + + treeStore.SetValue (iter, 2, newVal); + } + protected void OnSelect(object sender, EventArgs e) { btnRemove.Sensitive = repoTree.Selection.CountSelectedRows() > 0; diff -Nru mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/NewSiteDialog.cs mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/NewSiteDialog.cs --- mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/NewSiteDialog.cs 2008-11-06 19:51:59.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/NewSiteDialog.cs 2011-04-13 09:00:29.000000000 +0000 @@ -34,9 +34,11 @@ { partial class NewSiteDialog : Dialog { - public NewSiteDialog () + public NewSiteDialog (Gtk.Window parent) { Build (); + TransientFor = parent; + Services.PlaceDialog (this, parent); pathEntry.Sensitive = false; CheckValues (); } @@ -90,9 +92,9 @@ { FileChooserDialog dlg = new FileChooserDialog ("Select Folder", this, FileChooserAction.SelectFolder); try { - dlg.AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel); + dlg.AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel); dlg.AddButton (Gtk.Stock.Open, Gtk.ResponseType.Ok); - + dlg.SetFilename (Environment.GetFolderPath (Environment.SpecialFolder.Personal)); if (dlg.Run () == (int) ResponseType.Ok) { pathEntry.Text = dlg.Filename; diff -Nru mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/ProgressDialog.cs mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/ProgressDialog.cs --- mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/ProgressDialog.cs 2008-11-06 19:51:59.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/ProgressDialog.cs 2011-04-13 09:00:29.000000000 +0000 @@ -34,9 +34,10 @@ bool cancelled; bool hadError; - public ProgressDialog() + public ProgressDialog (Gtk.Window parent) { this.Build(); + Services.PlaceDialog (this, parent); } public bool IsCanceled { @@ -89,7 +90,9 @@ Log ("Error: " + message); if (exception != null) Log (exception.ToString ()); - Services.ShowError (exception, message, null, true); + Gtk.Application.Invoke (delegate { + Services.ShowError (exception, message, null, true); + }); hadError = true; } diff -Nru mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/SearchEntry.cs mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/SearchEntry.cs --- mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/SearchEntry.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/SearchEntry.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,130 @@ +// +// SearchEntry.cs +// +// Author: +// Aaron Bockover +// Gabriel Burt +// +// Copyright 2007-2010 Novell, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using Gtk; + +namespace Mono.Addins.Gui +{ + [System.ComponentModel.ToolboxItem(true)] + class SearchEntry : EventBox + { + HBox box = new HBox (); + Gtk.Entry entry = new Gtk.Entry (); + HoverImageButton iconFind; + HoverImageButton iconClean; + const int notifyDelay = 50; + bool notifying; + + public SearchEntry () + { + entry.HasFrame = false; + box.PackStart (entry, true, true, 0); + iconFind = new HoverImageButton (IconSize.Menu, Gtk.Stock.Find); + box.PackStart (iconFind, false, false, 0); + iconClean = new HoverImageButton (IconSize.Menu, Gtk.Stock.Clear); + box.PackStart (iconClean, false, false, 0); + box.BorderWidth = 1; + + HeaderBox hbox = new HeaderBox (1,1,1,1); + hbox.Show (); + hbox.Add (box); + Add (hbox); + + ModifyBg (StateType.Normal, entry.Style.Base (StateType.Normal)); + iconClean.ModifyBg (StateType.Normal, entry.Style.Base (StateType.Normal)); + iconFind.ModifyBg (StateType.Normal, entry.Style.Base (StateType.Normal)); + + iconClean.BorderWidth = 1; + iconClean.CanFocus = false; + iconFind.BorderWidth = 1; + iconFind.CanFocus = false; + + iconClean.Clicked += delegate { + entry.Text = string.Empty; + }; + + iconFind.Clicked += delegate { + FireSearch (); + }; + + entry.Activated += delegate { + FireSearch (); + }; + + ShowAll (); + UpdateIcon (); + + entry.Changed += delegate { + UpdateIcon (); + FireSearch (); + }; + } + + public event EventHandler TextChanged; + + public Gtk.Entry Entry { + get { + return this.entry; + } + set { + entry = value; + } + } + + public string Text { + get { return entry.Text; } + } + + void UpdateIcon () + { + if (entry.Text.Length > 0) { + iconFind.Hide (); + iconClean.Show (); + } + else { + iconFind.Show (); + iconClean.Hide (); + } + } + + void FireSearch () + { + if (!notifying) { + notifying = true; + GLib.Timeout.Add (notifyDelay, delegate { + notifying = false; + if (TextChanged != null) + TextChanged (this, EventArgs.Empty); + return false; + }); + } + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/Services.cs mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/Services.cs --- mono-addins-0.4/Mono.Addins.Gui/Mono.Addins.Gui/Services.cs 2008-11-06 19:51:59.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/Mono.Addins.Gui/Services.cs 2011-04-13 09:00:29.000000000 +0000 @@ -31,6 +31,9 @@ using Gtk; using Mono.Unix; using Mono.Addins.Setup; +using Mono.Addins.Description; +using System.Linq; +using System.Collections.Generic; namespace Mono.Addins.Gui { @@ -77,5 +80,73 @@ } else dlg.Show (); } + + public struct MissingDepInfo + { + public string Addin; + public string Required; + public string Found; + } + + public static IEnumerable GetMissingDependencies (Addin addin) + { + IEnumerable allAddins = AddinManager.Registry.GetAddins ().Union (AddinManager.Registry.GetAddinRoots ()); + foreach (var dep in addin.Description.MainModule.Dependencies) { + AddinDependency adep = dep as AddinDependency; + if (adep != null) { + if (!allAddins.Any (a => Addin.GetIdName (a.Id) == Addin.GetIdName (adep.FullAddinId) && a.SupportsVersion (adep.Version))) { + Addin found = allAddins.FirstOrDefault (a => Addin.GetIdName (a.Id) == Addin.GetIdName (adep.FullAddinId)); + yield return new MissingDepInfo () { Addin = Addin.GetIdName (adep.FullAddinId), Required = adep.Version, Found = found != null ? found.Version : null }; + } + } + } + } + + public static Gdk.Pixbuf AddIconOverlay (Gdk.Pixbuf target, Gdk.Pixbuf overlay) + { + Gdk.Pixbuf res = new Gdk.Pixbuf (target.Colorspace, target.HasAlpha, target.BitsPerSample, target.Width, target.Height); + res.Fill (0); + target.CopyArea (0, 0, target.Width, target.Height, res, 0, 0); + overlay.Composite (res, 0, 0, overlay.Width, overlay.Height, 0, 0, 1, 1, Gdk.InterpType.Bilinear, 255); + return res; + } + + public static Gdk.Pixbuf DesaturateIcon (Gdk.Pixbuf source) + { + Gdk.Pixbuf dest = new Gdk.Pixbuf (source.Colorspace, source.HasAlpha, source.BitsPerSample, source.Width, source.Height); + dest.Fill (0); + source.SaturateAndPixelate (dest, 0, false); + return dest; + } + + public static Gdk.Pixbuf FadeIcon (Gdk.Pixbuf source) + { + Gdk.Pixbuf result = source.Copy (); + result.Fill (0); + result = result.AddAlpha (true, 0, 0, 0); + source.Composite (result, 0, 0, source.Width, source.Height, 0, 0, 1, 1, Gdk.InterpType.Bilinear, 128); + return result; + } + + /// + /// Positions a dialog relative to its parent on platforms where default placement is known to be poor. + /// + public static void PlaceDialog (Window child, Window parent) + { + CenterWindow (child, parent); + } + + /// Centers a window relative to its parent. + static void CenterWindow (Window child, Window parent) + { + child.Child.Show (); + int w, h, winw, winh, x, y, winx, winy; + child.GetSize (out w, out h); + parent.GetSize (out winw, out winh); + parent.GetPosition (out winx, out winy); + x = System.Math.Max (0, (winw - w) /2) + winx; + y = System.Math.Max (0, (winh - h) /2) + winy; + child.Move (x, y); + } } } diff -Nru mono-addins-0.4/Mono.Addins.Gui/mono-addins-gui.pc.in mono-addins-0.6.1/Mono.Addins.Gui/mono-addins-gui.pc.in --- mono-addins-0.4/Mono.Addins.Gui/mono-addins-gui.pc.in 2008-11-06 19:51:59.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Gui/mono-addins-gui.pc.in 2011-04-13 09:00:29.000000000 +0000 @@ -1,11 +1,12 @@ -prefix=@prefix@ +prefix=${pcfiledir}/../.. exec_prefix=${prefix} -pkglibdir=@libdir@/mono/@PACKAGE@ -Libraries= ${pkglibdir}/@MONO_ADDINS_GUI_DEFAULT_LIB@ +pkglibdir=${prefix}/lib/mono/@PACKAGE@ + +Libraries=${pkglibdir}/@MONO_ADDINS_GUI_DEFAULT_LIB@ Name: Mono.Addins.Gui Description: Version: @VERSION@ Requires: mono-addins -Libs: -r:${pkglibdir}/@MONO_ADDINS_GUI_DEFAULT_LIB@ \ No newline at end of file +Libs: -r:${pkglibdir}/@MONO_ADDINS_GUI_DEFAULT_LIB@ diff -Nru mono-addins-0.4/Mono.Addins.MSBuild/AssemblyInfo.cs mono-addins-0.6.1/Mono.Addins.MSBuild/AssemblyInfo.cs --- mono-addins-0.4/Mono.Addins.MSBuild/AssemblyInfo.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.MSBuild/AssemblyInfo.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,51 @@ +// +// AssemblyInfo.cs +// +// Author: +// Lluis Sanchez Gual +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle("Mono.Addins")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion("0.6.0.0")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] diff -Nru mono-addins-0.4/Mono.Addins.MSBuild/ChangeLog mono-addins-0.6.1/Mono.Addins.MSBuild/ChangeLog --- mono-addins-0.4/Mono.Addins.MSBuild/ChangeLog 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.MSBuild/ChangeLog 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,57 @@ +2010-05-25 Lluis Sanchez Gual + + * Mono.Addins.MSBuild.csproj: Fix output directory for the + Release configuration. + +2010-05-21 Andrew Jorgensen + + * Makefile.am: Add Mono.Addins.targets to EXTRAS + +2010-03-30 Lluis Sanchez Gual + + * Mono.Addins.MSBuild.csproj: csc doesn't like iso-2. + +2010-03-29 Lluis Sanchez Gual + + * Mono.Addins.MSBuild.csproj: Make sure the solution builds on + MS.NET 2.0. + +2010-03-26 Lluis Sanchez Gual + + * Mono.Addins.MSBuild.csproj: Flush. + +2010-03-01 Lluis Sanchez Gual + + * Mono.Addins.targets: + * ResolveAddinReferences.cs: The target application is now + specified using the ExtensionDomain property. Addin + references now use a colon as version separator. + + * Makefile.am: Install the .targets file to the xbuild dir. + +2009-09-01 Lluis Sanchez Gual + + * AssemblyInfo.cs: Bump Mono.Addins version. + +2009-08-25 Lluis Sanchez Gual + + * Mono.Addins.MSBuild.csproj: Added Default configuration. + +2009-08-24 Lluis Sanchez Gual + + * Mono.Addins.MSBuild.csproj: Fix build. + +2009-08-21 Lluis Sanchez Gual + + * ResolveAddinReferences.cs: Track api changes. + +2009-08-20 Lluis Sanchez Gual + + * Makefile.am: + * AssemblyInfo.cs: + * Mono.Addins.targets: + * mono-addins-msbuild.pc.in: + * ResolveAddinReferences.cs: + * Mono.Addins.MSBuild.csproj: Added a new project which + Implements an msbuild task for resolving add-in references. + diff -Nru mono-addins-0.4/Mono.Addins.MSBuild/Makefile.am mono-addins-0.6.1/Mono.Addins.MSBuild/Makefile.am --- mono-addins-0.4/Mono.Addins.MSBuild/Makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.MSBuild/Makefile.am 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,51 @@ + +KEY_FILE=$(top_srcdir)/mono-addins.snk +ASSEMBLY_COMPILER_COMMAND = gmcs +ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG +ASSEMBLY = ../bin/Mono.Addins.MSBuild.dll +ASSEMBLY_NAME=Mono.Addins.MSBuild +COMPILE_TARGET = library +PC_FILES_IN = mono-addins-msbuild.pc.in +PROJECT_REFERENCES = \ + ../bin/Mono.Addins.dll \ + ../bin/Mono.Addins.Setup.dll +BUILD_DIR = ../bin + + +all: $(ASSEMBLY) + +FILES = \ + AssemblyInfo.cs \ + ResolveAddinReferences.cs + +DATA_FILES = + +RESOURCES = + +EXTRAS = \ + ./Makefile.am \ + ./Mono.Addins.targets + +REFERENCES = \ + -r:Microsoft.Build.Framework \ + -r:Microsoft.Build.Utilities \ + -r:System + +DLL_REFERENCES = + +$(ASSEMBLY).mdb: $(ASSEMBLY) + +$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) $(POLICY_ASSEMBLIES) + mkdir -p $(dir $(ASSEMBLY)) + $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) + +xbuilddir = $(libdir)/mono/xbuild +xbuild_DATA = Mono.Addins.targets + +install-data-local: gac-install + +uninstall-local: gac-uninstall + +include $(top_srcdir)/Makefile.include + +CLEANFILES += $(POLICY_ASSEMBLIES) $(POLICY_CONFIGS) diff -Nru mono-addins-0.4/Mono.Addins.MSBuild/Makefile.in mono-addins-0.6.1/Mono.Addins.MSBuild/Makefile.in --- mono-addins-0.4/Mono.Addins.MSBuild/Makefile.in 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.MSBuild/Makefile.in 2011-04-13 09:45:29.000000000 +0000 @@ -0,0 +1,458 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(srcdir)/mono-addins-msbuild.pc.in \ + $(top_srcdir)/Makefile.include ChangeLog +subdir = ./Mono.Addins.MSBuild +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = mono-addins-msbuild.pc +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkgconfigdir)" \ + "$(DESTDIR)$(xbuilddir)" +binSCRIPT_INSTALL = $(INSTALL_SCRIPT) +SCRIPTS = $(bin_SCRIPTS) +SOURCES = +DIST_SOURCES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +pkgconfigDATA_INSTALL = $(INSTALL_DATA) +xbuildDATA_INSTALL = $(INSTALL_DATA) +DATA = $(pkgconfig_DATA) $(xbuild_DATA) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AL = @AL@ +AMTAR = @AMTAR@ +API_VERSION = @API_VERSION@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +GACUTIL = @GACUTIL@ +GACUTIL_FLAGS = @GACUTIL_FLAGS@ +GACUTIL_POLICY_FLAGS = @GACUTIL_POLICY_FLAGS@ +GTK_SHARP_20_CFLAGS = @GTK_SHARP_20_CFLAGS@ +GTK_SHARP_20_LIBS = @GTK_SHARP_20_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MCS = @MCS@ +MKDIR_P = @MKDIR_P@ +MONODOC_CFLAGS = @MONODOC_CFLAGS@ +MONODOC_LIBS = @MONODOC_LIBS@ +MONO_ADDINS_DEFAULT_LIB = @MONO_ADDINS_DEFAULT_LIB@ +MONO_ADDINS_GUI_DEFAULT_LIB = @MONO_ADDINS_GUI_DEFAULT_LIB@ +MONO_ADDINS_MSBUILD_DEFAULT_LIB = @MONO_ADDINS_MSBUILD_DEFAULT_LIB@ +MONO_ADDINS_SETUP_DEFAULT_LIB = @MONO_ADDINS_SETUP_DEFAULT_LIB@ +MONO_NUNIT_CFLAGS = @MONO_NUNIT_CFLAGS@ +MONO_NUNIT_LIBS = @MONO_NUNIT_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +POLICY_VERSIONS = @POLICY_VERSIONS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +am__leading_dot = @am__leading_dot@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host_alias = @host_alias@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +KEY_FILE = $(top_srcdir)/mono-addins.snk +ASSEMBLY_COMPILER_COMMAND = gmcs +ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG +ASSEMBLY = ../bin/Mono.Addins.MSBuild.dll +ASSEMBLY_NAME = Mono.Addins.MSBuild +COMPILE_TARGET = library +PC_FILES_IN = mono-addins-msbuild.pc.in +PROJECT_REFERENCES = \ + ../bin/Mono.Addins.dll \ + ../bin/Mono.Addins.Setup.dll + +BUILD_DIR = ../bin +FILES = \ + AssemblyInfo.cs \ + ResolveAddinReferences.cs + +DATA_FILES = +RESOURCES = +EXTRAS = \ + ./Makefile.am \ + ./Mono.Addins.targets + +REFERENCES = \ + -r:Microsoft.Build.Framework \ + -r:Microsoft.Build.Utilities \ + -r:System + +DLL_REFERENCES = +xbuilddir = $(libdir)/mono/xbuild +xbuild_DATA = Mono.Addins.targets +build_sources = $(addprefix $(srcdir)/, $(FILES) $(GENERATED_FILES)) +build_resources = $(addprefix $(srcdir)/, $(RESOURCES)) +build_resources_embed = $(foreach res,$(build_resources), $(addprefix -resource:,$(res)),$(RESOURCES_PREFIX)$(notdir $(res))) +build_references_ref = $(REFERENCES) $(foreach ref, $(DLL_REFERENCES), \ + -r:$(ref)) $(foreach ref, $(PROJECT_REFERENCES), -r:$(ref)) +pc_files = $(PC_FILES_IN:.pc.in=.pc) +build_datafiles = $(addprefix $(BUILD_DIR)/, $(DATA_FILES)) +POLICY_ASSEMBLIES = $(addsuffix .$(ASSEMBLY_NAME).dll, $(addprefix policy., $(POLICY_VERSIONS))) +POLICY_CONFIGS = $(addsuffix .config, $(addprefix policy., $(POLICY_VERSIONS))) +EXTRA_DIST = $(FILES) $(GENERATED_FILES) $(RESOURCES) $(ASSEMBLY_WRAPPER_IN) $(EXTRAS) $(DATA_FILES) $(PC_FILES_IN) +CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb $(DLL_REFERENCES) \ + $(POLICY_ASSEMBLIES) $(POLICY_CONFIGS) +DISTCLEANFILES = $(GENERATED_FILES) $(build_datafiles) $(pc_files) +bin_SCRIPTS = $(ASSEMBLY_WRAPPER) +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = $(pc_files) +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/Makefile.include $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign ./Mono.Addins.MSBuild/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign ./Mono.Addins.MSBuild/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +mono-addins-msbuild.pc: $(top_builddir)/config.status $(srcdir)/mono-addins-msbuild.pc.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +install-binSCRIPTS: $(bin_SCRIPTS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_SCRIPTS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f $$d$$p; then \ + f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ + echo " $(binSCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(binSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(bindir)/$$f"; \ + else :; fi; \ + done + +uninstall-binSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(bin_SCRIPTS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done +install-pkgconfigDATA: $(pkgconfig_DATA) + @$(NORMAL_INSTALL) + test -z "$(pkgconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" + @list='$(pkgconfig_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(pkgconfigDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgconfigdir)/$$f'"; \ + $(pkgconfigDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgconfigdir)/$$f"; \ + done + +uninstall-pkgconfigDATA: + @$(NORMAL_UNINSTALL) + @list='$(pkgconfig_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(pkgconfigdir)/$$f'"; \ + rm -f "$(DESTDIR)$(pkgconfigdir)/$$f"; \ + done +install-xbuildDATA: $(xbuild_DATA) + @$(NORMAL_INSTALL) + test -z "$(xbuilddir)" || $(MKDIR_P) "$(DESTDIR)$(xbuilddir)" + @list='$(xbuild_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(xbuildDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(xbuilddir)/$$f'"; \ + $(xbuildDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(xbuilddir)/$$f"; \ + done + +uninstall-xbuildDATA: + @$(NORMAL_UNINSTALL) + @list='$(xbuild_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(xbuilddir)/$$f'"; \ + rm -f "$(DESTDIR)$(xbuilddir)/$$f"; \ + done +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(SCRIPTS) $(DATA) +installdirs: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(xbuilddir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-data-local install-pkgconfigDATA \ + install-xbuildDATA + +install-dvi: install-dvi-am + +install-exec-am: install-binSCRIPTS + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binSCRIPTS uninstall-local \ + uninstall-pkgconfigDATA uninstall-xbuildDATA + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic distclean \ + distclean-generic distdir dvi dvi-am html html-am info info-am \ + install install-am install-binSCRIPTS install-data \ + install-data-am install-data-local install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-pkgconfigDATA install-ps install-ps-am \ + install-strip install-xbuildDATA installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-generic pdf pdf-am ps ps-am uninstall \ + uninstall-am uninstall-binSCRIPTS uninstall-local \ + uninstall-pkgconfigDATA uninstall-xbuildDATA + + +all: $(ASSEMBLY) + +$(ASSEMBLY).mdb: $(ASSEMBLY) + +$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) $(POLICY_ASSEMBLIES) + mkdir -p $(dir $(ASSEMBLY)) + $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) + +install-data-local: gac-install + +uninstall-local: gac-uninstall + +$(build_datafiles): $(BUILD_DIR)/% : $(addprefix $(srcdir)/, %) + mkdir -p $(dir $@) + cp $< $@ + +policy.%.config: $(top_builddir)/policy.config + sed -e "s/@ASSEMBLY_NAME@/$(ASSEMBLY_NAME)/" -e "s/@POLICY@/$*/" $(top_builddir)/policy.config > $@ + +$(POLICY_ASSEMBLIES) : policy.%.$(ASSEMBLY_NAME).dll: policy.%.config $(top_srcdir)/mono-addins.snk + $(AL) -link:policy.$*.config -out:$@ -keyfile:$(top_srcdir)/mono-addins.snk + +gac-install: $(POLICY_ASSEMBLIES) + $(GACUTIL) /i $(ASSEMBLY) /f $(GACUTIL_FLAGS) || exit 1; + @for p in $(POLICY_ASSEMBLIES); do \ + echo $(GACUTIL) /i $$p /f $(GACUTIL_POLICY_FLAGS) || exit 1; \ + $(GACUTIL) /i $$p /f $(GACUTIL_POLICY_FLAGS) || exit 1; \ + done + +gac-uninstall: + $(GACUTIL) /us $(ASSEMBLY) $(GACUTIL_FLAGS) || exit 1; + @for p in $(POLICY_ASSEMBLIES); do \ + echo $(GACUTIL) /us $$p /f $(GACUTIL_POLICY_FLAGS) || exit 1; \ + $(GACUTIL) /us $$p /f $(GACUTIL_POLICY_FLAGS) || exit 1; \ + done +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff -Nru mono-addins-0.4/Mono.Addins.MSBuild/mono-addins-msbuild.pc.in mono-addins-0.6.1/Mono.Addins.MSBuild/mono-addins-msbuild.pc.in --- mono-addins-0.4/Mono.Addins.MSBuild/mono-addins-msbuild.pc.in 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.MSBuild/mono-addins-msbuild.pc.in 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,12 @@ +prefix=${pcfiledir}/../.. +exec_prefix=${prefix} +pkglibdir=${prefix}/lib/mono/@PACKAGE@ + +Libraries=${pkglibdir}/@MONO_ADDINS_MSBUILD_DEFAULT_LIB@ + +Name: Mono.Addins.MSBuild +Description: +Version: @VERSION@ + +Requires: mono-addins +Libs: -r:${pkglibdir}/@MONO_ADDINS_MSBUILD_DEFAULT_LIB@ diff -Nru mono-addins-0.4/Mono.Addins.MSBuild/Mono.Addins.targets mono-addins-0.6.1/Mono.Addins.MSBuild/Mono.Addins.targets --- mono-addins-0.4/Mono.Addins.MSBuild/Mono.Addins.targets 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.MSBuild/Mono.Addins.targets 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,17 @@ + + + + + + ResolveAddinReferences; + $(ResolveReferencesDependsOn) + + + + + + + + + + diff -Nru mono-addins-0.4/Mono.Addins.MSBuild/ResolveAddinReferences.cs mono-addins-0.6.1/Mono.Addins.MSBuild/ResolveAddinReferences.cs --- mono-addins-0.4/Mono.Addins.MSBuild/ResolveAddinReferences.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.MSBuild/ResolveAddinReferences.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,94 @@ +// +// ResolveAddinReferences.cs +// +// Author: +// Lluis Sanchez Gual +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Collections.Generic; +using Microsoft.Build.Utilities; +using Microsoft.Build.Framework; +using Mono.Addins; +using Mono.Addins.Setup; +using System.IO; + +namespace Mono.Addins.MSBuild +{ + public class ResolveAddinReferences: Task + { + List references = new List (); + ITaskItem[] addinReferences; + string extensionDomain; + + public override bool Execute () + { + if (string.IsNullOrEmpty (extensionDomain)) { + Log.LogError ("ExtensionDomain item not found"); + return false; + } + if (addinReferences == null) { + return true; + } + + Application app = SetupService.GetExtensibleApplication (extensionDomain); + if (app == null) { + Log.LogError ("Extension domain '{0}' not found", extensionDomain); + return false; + } + + foreach (ITaskItem item in addinReferences) { + string addinId = item.ItemSpec.Replace (':',','); + Addin addin = app.Registry.GetAddin (addinId); + if (addin == null) { + Log.LogError ("Add-in '{0}' not found", addinId); + return false; + } + if (addin.Description == null) { + Log.LogError ("Add-in '{0}' could not be loaded", addinId); + return false; + } + foreach (string asm in addin.Description.MainModule.Assemblies) { + string file = Path.Combine (addin.Description.BasePath, asm); + TaskItem ti = new TaskItem (file); + references.Add (ti); + } + } + return true; + } + + public ITaskItem[] AddinReferences { + get { return addinReferences; } + set { addinReferences = value; } + } + + public string ExtensionDomain { + get { return extensionDomain; } + set { extensionDomain = value; } + } + + [Output] + public ITaskItem[] References { + get { return references.ToArray (); } + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.Setup/AssemblyInfo.cs mono-addins-0.6.1/Mono.Addins.Setup/AssemblyInfo.cs --- mono-addins-0.4/Mono.Addins.Setup/AssemblyInfo.cs 2008-11-06 19:52:10.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Setup/AssemblyInfo.cs 2011-04-13 09:00:29.000000000 +0000 @@ -17,4 +17,4 @@ // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly: AssemblyVersion("0.4.0.0")] +[assembly: AssemblyVersion("0.6.0.0")] diff -Nru mono-addins-0.4/Mono.Addins.Setup/ChangeLog mono-addins-0.6.1/Mono.Addins.Setup/ChangeLog --- mono-addins-0.4/Mono.Addins.Setup/ChangeLog 2008-11-06 19:52:10.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Setup/ChangeLog 2011-04-13 09:00:29.000000000 +0000 @@ -1,3 +1,135 @@ +2010-10-14 Lluis Sanchez Gual + + * SetupService.cs: Build package now returns a list of the + generated files. + +2010-07-01 Lluis Sanchez Gual + + * Mono.Addins.Setup.csproj: Generate documentation. + +2010-07-01 Lluis Sanchez Gual + + * Mono.Addins.Setup/Package.cs: + * Mono.Addins.Setup/AddinInfo.cs: + * Mono.Addins.Setup/SetupTool.cs: + * Mono.Addins.Setup/SetupService.cs: + * Mono.Addins.Setup/RepositoryRecord.cs: + * Mono.Addins.Setup/InstallException.cs: + * Mono.Addins.Setup/PackageCollection.cs: + * Mono.Addins.Setup/RepositoryRegistry.cs: + * Mono.Addins.Setup/AddinRepositoryEntry.cs: + * Mono.Addins.Setup/ConsoleAddinInstaller.cs: Added some + documentation. + +2010-05-25 Lluis Sanchez Gual + + * Mono.Addins.Setup.csproj: Fix output directory for the + Release configuration. + +2010-04-08 Lluis Sanchez Gual + + * Mono.Addins.Setup/AddinStore.cs: Properly get the url path + (old way didn't work on windows). + +2010-04-08 Lluis Sanchez Gual + + * Mono.Addins.Setup/RepositoryRegistry.cs: GetAvailableUpdates + (id,version) doesn't work. It makes no sense to ask for + updates for a specific add-in version. Added + GetAvaliableAddinUpdates methods which take only an id and + no version. + +2010-03-30 Lluis Sanchez Gual + + * Mono.Addins.Setup.csproj: csc doesn't like iso-2. + +2010-03-29 Lluis Sanchez Gual + + * Mono.Addins.Setup.csproj: Make sure the solution builds on + MS.NET 2.0. + +2010-03-26 Lluis Sanchez Gual + + * Mono.Addins.Setup.csproj: Flush. + +2009-11-13 Lluis Sanchez Gual + + * Mono.Addins.Setup/SetupTool.cs: Allow specifying multiple + levels of verbosity. + +2009-09-01 Lluis Sanchez Gual + + * AssemblyInfo.cs: Bump Mono.Addins version. + +2009-08-25 Lluis Sanchez Gual + + * Mono.Addins.Setup/PcFileCache.cs: Updated from MD. + +2009-08-24 Lluis Sanchez Gual + + * Mono.Addins.Setup/PcFileCache.cs: + * Mono.Addins.Setup/SetupService.cs: Make it buildable in .net + 2.0. + +2009-08-21 Lluis Sanchez Gual + + * Mono.Addins.Setup/SetupService.cs: Applications can now + register a test command to be used for testing add-ins. + Don't use the pkg-config command, use instead the + PcFileCache. + + * Mono.Addins.Setup/PcFileCache.cs: Updated. + +2009-08-20 Lluis Sanchez Gual + + * Makefile.am: + * Mono.Addins.Setup.csproj: + * Mono.Addins.Setup/SetupTool.cs: + * Mono.Addins.Setup/PcFileCache.cs: + * Mono.Addins.Setup/SetupService.cs: Added a new project which + Implements an msbuild task for resolving add-in references. + +2009-08-19 Lluis Sanchez Gual + + * Mono.Addins.Setup.csproj: Update target framework to 2.0. + +2009-06-17 Lluis Sanchez Gual + + * Mono.Addins.Setup/SetupService.cs: Added method for getting + a registry from a package name. + + * Mono.Addins.Setup/SetupTool.cs: Added some more help for the + info command. + +2009-06-04 Lluis Sanchez Gual + + * Makefile.am: + * Mono.Addins.Setup.csproj: Remove unnecessary Mono.Posix + reference. + +2009-05-28 Lluis Sanchez Gual + + * Mono.Addins.Setup.csproj: Properly sign assemblies. + +2009-02-06 Lluis Sanchez Gual + + * Mono.Addins.Setup/SetupTool.cs: Added command for getting + the list of assemblies of an add-in. + +2009/02/06 Lluis Sanchez Gual + + * Mono.Addins.Setup.csproj: Updated. + +2008-11-10 Lluis Sanchez Gual + + * mono-addins-setup.pc.in: Respect custom libdir during ./configure. + Fixes bug #443205. Patch by Diego Pettenò. + +2008-11-10 Lluis Sanchez Gual + + * Makefile.am: Fix building with parallel make jobs (-j8). Fixes bug + #443206. Patch by Diego Pettenò. + 2008-08-22 Lluis Sanchez Gual * Mono.Addins.Setup.csproj, Mono.Addins.Setup.mdp: Use msbuild file diff -Nru mono-addins-0.4/Mono.Addins.Setup/Makefile.am mono-addins-0.6.1/Mono.Addins.Setup/Makefile.am --- mono-addins-0.4/Mono.Addins.Setup/Makefile.am 2008-11-06 19:52:10.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Setup/Makefile.am 2011-04-13 09:00:29.000000000 +0000 @@ -1,7 +1,7 @@ KEY_FILE=$(top_srcdir)/mono-addins.snk -ASSEMBLY_COMPILER_COMMAND = mcs -ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -langversion:ISO-1 -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG +ASSEMBLY_COMPILER_COMMAND = gmcs +ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG ASSEMBLY = ../bin/Mono.Addins.Setup.dll ASSEMBLY_NAME=Mono.Addins.Setup COMPILE_TARGET = library @@ -32,6 +32,7 @@ Mono.Addins.Setup/IProgressMonitor.cs \ Mono.Addins.Setup/Package.cs \ Mono.Addins.Setup/PackageCollection.cs \ + Mono.Addins.Setup/PcFileCache.cs \ Mono.Addins.Setup/ReferenceRepositoryEntry.cs \ Mono.Addins.Setup/Repository.cs \ Mono.Addins.Setup/RepositoryEntry.cs \ @@ -41,7 +42,8 @@ Mono.Addins.Setup/RepositoryRegistry.cs \ Mono.Addins.Setup/RepositorySerializer.cs \ Mono.Addins.Setup/SetupService.cs \ - Mono.Addins.Setup/SetupTool.cs + Mono.Addins.Setup/SetupTool.cs \ + Mono.Addins.Setup/TextFormatter.cs DATA_FILES = @@ -52,13 +54,15 @@ REFERENCES = \ -r:ICSharpCode.SharpZipLib \ - -r:Mono.Posix \ -r:System \ + -r:System.Core \ -r:System.Xml DLL_REFERENCES = -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) $(POLICY_ASSEMBLIES) +$(ASSEMBLY).mdb: $(ASSEMBLY) + +$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) $(POLICY_ASSEMBLIES) mkdir -p $(dir $(ASSEMBLY)) $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) diff -Nru mono-addins-0.4/Mono.Addins.Setup/Makefile.in mono-addins-0.6.1/Mono.Addins.Setup/Makefile.in --- mono-addins-0.4/Mono.Addins.Setup/Makefile.in 2008-11-06 19:52:35.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Setup/Makefile.in 2011-04-13 09:45:29.000000000 +0000 @@ -81,11 +81,15 @@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MCS = @MCS@ MKDIR_P = @MKDIR_P@ +MONODOC_CFLAGS = @MONODOC_CFLAGS@ +MONODOC_LIBS = @MONODOC_LIBS@ MONO_ADDINS_DEFAULT_LIB = @MONO_ADDINS_DEFAULT_LIB@ MONO_ADDINS_GUI_DEFAULT_LIB = @MONO_ADDINS_GUI_DEFAULT_LIB@ +MONO_ADDINS_MSBUILD_DEFAULT_LIB = @MONO_ADDINS_MSBUILD_DEFAULT_LIB@ MONO_ADDINS_SETUP_DEFAULT_LIB = @MONO_ADDINS_SETUP_DEFAULT_LIB@ MONO_NUNIT_CFLAGS = @MONO_NUNIT_CFLAGS@ MONO_NUNIT_LIBS = @MONO_NUNIT_LIBS@ @@ -138,11 +142,12 @@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ KEY_FILE = $(top_srcdir)/mono-addins.snk -ASSEMBLY_COMPILER_COMMAND = mcs -ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -langversion:ISO-1 -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG +ASSEMBLY_COMPILER_COMMAND = gmcs +ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG ASSEMBLY = ../bin/Mono.Addins.Setup.dll ASSEMBLY_NAME = Mono.Addins.Setup COMPILE_TARGET = library @@ -169,6 +174,7 @@ Mono.Addins.Setup/IProgressMonitor.cs \ Mono.Addins.Setup/Package.cs \ Mono.Addins.Setup/PackageCollection.cs \ + Mono.Addins.Setup/PcFileCache.cs \ Mono.Addins.Setup/ReferenceRepositoryEntry.cs \ Mono.Addins.Setup/Repository.cs \ Mono.Addins.Setup/RepositoryEntry.cs \ @@ -178,7 +184,8 @@ Mono.Addins.Setup/RepositoryRegistry.cs \ Mono.Addins.Setup/RepositorySerializer.cs \ Mono.Addins.Setup/SetupService.cs \ - Mono.Addins.Setup/SetupTool.cs + Mono.Addins.Setup/SetupTool.cs \ + Mono.Addins.Setup/TextFormatter.cs DATA_FILES = RESOURCES = @@ -187,8 +194,8 @@ REFERENCES = \ -r:ICSharpCode.SharpZipLib \ - -r:Mono.Posix \ -r:System \ + -r:System.Core \ -r:System.Xml DLL_REFERENCES = @@ -211,7 +218,7 @@ all: all-am .SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.include $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/Makefile.include $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -236,9 +243,9 @@ $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(top_srcdir)/configure: $(am__configure_deps) +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh mono-addins-setup.pc: $(top_builddir)/config.status $(srcdir)/mono-addins-setup.pc.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ @@ -416,7 +423,9 @@ all: $(ASSEMBLY) -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) $(POLICY_ASSEMBLIES) +$(ASSEMBLY).mdb: $(ASSEMBLY) + +$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) $(POLICY_ASSEMBLIES) mkdir -p $(dir $(ASSEMBLY)) $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) @@ -428,12 +437,11 @@ mkdir -p $(dir $@) cp $< $@ -$(POLICY_ASSEMBLIES): $(top_builddir)/policy.config $(top_srcdir)/mono-addins.snk - @for i in $(POLICY_VERSIONS); do \ - echo "Creating policy.$$i.$(ASSEMBLY_NAME)"; \ - sed -e "s/@ASSEMBLY_NAME@/$(ASSEMBLY_NAME)/" -e "s/@POLICY@/$$i/" $(top_builddir)/policy.config > policy.$$i.config; \ - $(AL) -link:policy.$$i.config -out:policy.$$i.$(ASSEMBLY_NAME).dll -keyfile:$(top_srcdir)/mono-addins.snk; \ - done +policy.%.config: $(top_builddir)/policy.config + sed -e "s/@ASSEMBLY_NAME@/$(ASSEMBLY_NAME)/" -e "s/@POLICY@/$*/" $(top_builddir)/policy.config > $@ + +$(POLICY_ASSEMBLIES) : policy.%.$(ASSEMBLY_NAME).dll: policy.%.config $(top_srcdir)/mono-addins.snk + $(AL) -link:policy.$*.config -out:$@ -keyfile:$(top_srcdir)/mono-addins.snk gac-install: $(POLICY_ASSEMBLIES) $(GACUTIL) /i $(ASSEMBLY) /f $(GACUTIL_FLAGS) || exit 1; diff -Nru mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/AddinInfo.cs mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/AddinInfo.cs --- mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/AddinInfo.cs 2008-11-06 19:52:10.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/AddinInfo.cs 2011-04-13 09:00:29.000000000 +0000 @@ -49,11 +49,13 @@ string category = ""; DependencyCollection dependencies; DependencyCollection optionalDependencies; + AddinPropertyCollectionImpl properties; public AddinInfo () { dependencies = new DependencyCollection (); optionalDependencies = new DependencyCollection (); + properties = new AddinPropertyCollectionImpl (); } public string Id { @@ -73,6 +75,9 @@ public string Name { get { + string s = Properties.GetPropertyValue ("Name"); + if (s.Length > 0) + return s; if (name != null && name.Length > 0) return name; string sid = id; @@ -94,27 +99,52 @@ } public string Author { - get { return author; } + get { + string s = Properties.GetPropertyValue ("Author"); + if (s.Length > 0) + return s; + return author; + } set { author = value; } } public string Copyright { - get { return copyright; } + get { + string s = Properties.GetPropertyValue ("Copyright"); + if (s.Length > 0) + return s; + return copyright; + } set { copyright = value; } } public string Url { - get { return url; } + get { + string s = Properties.GetPropertyValue ("Url"); + if (s.Length > 0) + return s; + return url; + } set { url = value; } } public string Description { - get { return description; } + get { + string s = Properties.GetPropertyValue ("Description"); + if (s.Length > 0) + return s; + return description; + } set { description = value; } } public string Category { - get { return category; } + get { + string s = Properties.GetPropertyValue ("Category"); + if (s.Length > 0) + return s; + return category; + } set { category = value; } } @@ -132,6 +162,15 @@ get { return optionalDependencies; } } + [XmlArrayItem ("Property", typeof(AddinProperty))] + public AddinPropertyCollectionImpl Properties { + get { return properties; } + } + + AddinPropertyCollection AddinHeader.Properties { + get { return properties; } + } + public static AddinInfo ReadFromAddinFile (StreamReader r) { XmlDocument doc = new XmlDocument (); @@ -150,9 +189,10 @@ info.description = doc.DocumentElement.GetAttribute ("description"); info.category = doc.DocumentElement.GetAttribute ("category"); info.baseVersion = doc.DocumentElement.GetAttribute ("compatVersion"); - + AddinPropertyCollectionImpl props = new AddinPropertyCollectionImpl (); + info.properties = props; + ReadHeader (info, props, doc.DocumentElement); ReadDependencies (info.Dependencies, info.OptionalDependencies, doc.DocumentElement); - return info; } @@ -178,6 +218,32 @@ ReadDependencies (opDeps, opDeps, mod); } + static void ReadHeader (AddinInfo info, AddinPropertyCollectionImpl properties, XmlElement elem) + { + elem = elem.SelectSingleNode ("Header") as XmlElement; + if (elem == null) + return; + foreach (XmlNode xprop in elem.ChildNodes) { + XmlElement prop = xprop as XmlElement; + if (prop != null) { + switch (prop.LocalName) { + case "Id": info.id = prop.InnerText; break; + case "Namespace": info.namspace = prop.InnerText; break; + case "Version": info.version = prop.InnerText; break; + case "CompatVersion": info.baseVersion = prop.InnerText; break; + default: { + AddinProperty aprop = new AddinProperty (); + aprop.Name = prop.LocalName; + if (prop.HasAttribute ("locale")) + aprop.Locale = prop.GetAttribute ("locale"); + aprop.Value = prop.InnerText; + properties.Add (aprop); + break; + }} + } + } + } + internal static AddinInfo ReadFromDescription (AddinDescription description) { AddinInfo info = new AddinInfo (); @@ -191,6 +257,7 @@ info.description = description.Description; info.category = description.Category; info.baseVersion = description.CompatVersion; + info.properties = new AddinPropertyCollectionImpl (description.Properties); foreach (Dependency dep in description.MainModule.Dependencies) info.Dependencies.Add (dep); @@ -217,56 +284,111 @@ } } + /// + /// Basic add-in information + /// public interface AddinHeader { + /// + /// Full identifier of the add-in + /// string Id { get; } + /// + /// Display name of the add-in + /// string Name { get; } + /// + /// Namespace of the add-in + /// string Namespace { get; } + /// + /// Version of the add-in + /// string Version { get; } + /// + /// Version with which this add-in is compatible + /// string BaseVersion { get; } + /// + /// Add-in author + /// string Author { get; } + /// + /// Add-in copyright + /// string Copyright { get; } + /// + /// Web page URL with more information about the add-in + /// string Url { get; } + /// + /// Description of the add-in + /// string Description { get; } + /// + /// Category of the add-in + /// string Category { get; } + /// + /// Dependencies of the add-in + /// DependencyCollection Dependencies { get; } + /// + /// Optional dependencies of the add-in + /// DependencyCollection OptionalDependencies { get; } + /// + /// Custom properties specified in the add-in header + /// + AddinPropertyCollection Properties { + get; + } + + /// + /// Compares the versions of two add-ins + /// + /// + /// Another add-in + /// + /// + /// Result of comparison + /// int CompareVersionTo (AddinHeader other); } } diff -Nru mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/AddinPackage.cs mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/AddinPackage.cs --- mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/AddinPackage.cs 2008-11-06 19:52:10.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/AddinPackage.cs 2011-04-13 09:00:29.000000000 +0000 @@ -39,6 +39,7 @@ using ICSharpCode.SharpZipLib.Zip; using Mono.Addins; using Mono.Addins.Description; +using System.Collections.Generic; namespace Mono.Addins.Setup { @@ -48,6 +49,8 @@ string packFile; string url; string tempFolder; + bool disablingOnUninstall; + bool uninstallingLoaded; string configFile; bool installed; Addin iaddin; @@ -117,6 +120,8 @@ internal override void PrepareInstall (IProgressMonitor monitor, AddinStore service) { + if (service.Registry.IsRegisteredForUninstall (info.Id)) + throw new InstallException ("The addin " + info.Name + " v" + info.Version + " is scheduled for uninstallation. Please restart the application before trying to install it again."); if (service.Registry.GetAddin (Mono.Addins.Addin.GetFullId (info.Namespace, info.Id, info.Version), true) != null) throw new InstallException ("The addin " + info.Name + " v" + info.Version + " is already installed."); @@ -219,20 +224,28 @@ throw new InstallException (string.Format ("The add-in '{0}' is not installed.", info.Name)); AddinDescription conf = iaddin.Description; - string basePath = Path.GetDirectoryName (conf.AddinFile); if (!File.Exists (iaddin.AddinFile)) { monitor.ReportWarning (string.Format ("The add-in '{0}' is scheduled for uninstalling, but the add-in file could not be found.", info.Name)); return; } + // The add-in is a core application add-in. It can't be uninstalled, so it will be disabled. + if (!service.IsUserAddin (iaddin.AddinFile)) { + disablingOnUninstall = true; + return; + } + + HashSet files = new HashSet (GetInstalledFiles (conf)); + if (AddinManager.CheckAssembliesLoaded (files)) { + uninstallingLoaded = true; + return; + } + if (!service.HasWriteAccess (iaddin.AddinFile)) throw new InstallException (AddinStore.GetUninstallErrorNoRoot (info)); - foreach (string relPath in conf.AllFiles) { - string path = Path.Combine (basePath, relPath); - if (!File.Exists (path)) - continue; + foreach (string path in GetInstalledFiles (conf)) { if (!service.HasWriteAccess (path)) throw new InstallException (AddinStore.GetUninstallErrorNoRoot (info)); } @@ -241,23 +254,57 @@ CopyAddinFiles (monitor, conf, iaddin.AddinFile, tempFolder); } + IEnumerable GetInstalledFiles (AddinDescription conf) + { + string basePath = Path.GetDirectoryName (conf.AddinFile); + foreach (string relPath in conf.AllFiles) { + string afile = Path.Combine (basePath, relPath); + if (File.Exists (afile)) + yield return afile; + } + foreach (var p in conf.Properties) { + string file; + try { + file = Path.Combine (basePath, p.Value); + if (!File.Exists (file)) + file = null; + } catch { + file = null; + } + if (file != null) + yield return file; + } + } + internal override void CommitUninstall (IProgressMonitor monitor, AddinStore service) { - if (tempFolder == null) + if (disablingOnUninstall) { + disablingOnUninstall = false; + service.Registry.DisableAddin (info.Id); return; - - monitor.Log.WriteLine ("Uninstalling " + info.Name + " v" + info.Version); + } AddinDescription conf = iaddin.Description; + string basePath = Path.GetDirectoryName (conf.AddinFile); - foreach (string relPath in conf.AllFiles) { - string path = Path.Combine (basePath, relPath); - if (!File.Exists (path)) - continue; - File.Delete (path); + if (uninstallingLoaded) { + List files = new List (); + files.Add (iaddin.AddinFile); + foreach (string f in GetInstalledFiles (conf)) + files.Add (f); + service.Registry.RegisterForUninstall (info.Id, files); + return; } + if (tempFolder == null) + return; + + monitor.Log.WriteLine ("Uninstalling " + info.Name + " v" + info.Version); + + foreach (string path in GetInstalledFiles (conf)) + File.Delete (path); + File.Delete (iaddin.AddinFile); RecDeleteDir (monitor, basePath); @@ -282,6 +329,7 @@ internal override void RollbackUninstall (IProgressMonitor monitor, AddinStore service) { + disablingOnUninstall = false; if (tempFolder != null) { AddinDescription conf = iaddin.Description; string configFile = Path.Combine (tempFolder, Path.GetFileName (iaddin.AddinFile)); diff -Nru mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/AddinRepositoryEntry.cs mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/AddinRepositoryEntry.cs --- mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/AddinRepositoryEntry.cs 2008-11-06 19:52:10.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/AddinRepositoryEntry.cs 2011-04-13 09:00:29.000000000 +0000 @@ -27,6 +27,10 @@ // using System; +using System.Net; +using System.Collections.Generic; +using System.IO; +using System.Threading; namespace Mono.Addins.Setup { @@ -61,24 +65,82 @@ else return Mono.Addins.Addin.CompareVersions (rep.Addin.Version, Addin.Version); } + + public IAsyncResult BeginDownloadSupportFile (string name, AsyncCallback cb, object state) + { + return Repository.BeginDownloadSupportFile (name, cb, state); + } + + public Stream EndDownloadSupportFile (IAsyncResult ares) + { + return Repository.EndDownloadSupportFile (ares); + } } + /// + /// A reference to an add-in available in an on-line repository + /// public interface AddinRepositoryEntry { + /// + /// Add-in information + /// AddinHeader Addin { get; } + /// + /// Url to the add-in package + /// string Url { get; } + /// + /// The URL of the repository + /// string RepositoryUrl { get; } + /// + /// Name of the repository + /// string RepositoryName { get; } + + /// + /// Begins downloading a support file + /// + /// + /// Result of the asynchronous operation, to be used when calling EndDownloadSupportFile to + /// get the download result. + /// + /// + /// Name of the file. + /// + /// + /// Callback to be called when the download operation ends. + /// + /// + /// Custom state object provided by the caller. + /// + /// + /// This method can be used to get the contents of a support file of an add-in. + /// A support file is a file referenced in the custom properties of an add-in. + /// + IAsyncResult BeginDownloadSupportFile (string name, AsyncCallback cb, object state); + + /// + /// Gets the result of the asynchronous download of a file + /// + /// + /// The downloaded file. + /// + /// + /// The async result object returned by BeginDownloadSupportFile. + /// + Stream EndDownloadSupportFile (IAsyncResult ares); } } diff -Nru mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/AddinStore.cs mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/AddinStore.cs --- mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/AddinStore.cs 2008-11-06 19:52:10.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/AddinStore.cs 2011-04-13 09:00:29.000000000 +0000 @@ -43,6 +43,8 @@ using Mono.Addins.Setup.ProgressMonitoring; using Mono.Addins.Description; using Mono.Addins.Serialization; +using System.Collections.Generic; +using System.Linq; namespace Mono.Addins.Setup { @@ -120,7 +122,7 @@ throw new InstallException ("Installation cancelled."); monitor.Step (1); } catch (Exception ex) { - monitor.ReportError (null, ex); + ReportException (monitor, ex); rollback = true; break; } @@ -136,7 +138,7 @@ prepared.Add (mpack); monitor.Step (1); } catch (Exception ex) { - monitor.ReportError (null, ex); + ReportException (monitor, ex); rollback = true; break; } @@ -156,7 +158,7 @@ throw new InstallException ("Installation cancelled."); monitor.Step (1); } catch (Exception ex) { - monitor.ReportError (null, ex); + ReportException (monitor, ex); rollback = true; break; } @@ -173,7 +175,7 @@ throw new InstallException ("Installation cancelled."); monitor.Step (1); } catch (Exception ex) { - monitor.ReportError (null, ex); + ReportException (monitor, ex); rollback = true; break; } @@ -195,7 +197,7 @@ mpack.RollbackInstall (monitor, this); monitor.Step (1); } catch (Exception ex) { - monitor.ReportError (null, ex); + ReportException (monitor, ex); } } @@ -204,7 +206,7 @@ mpack.RollbackUninstall (monitor, this); monitor.Step (1); } catch (Exception ex) { - monitor.ReportError (null, ex); + ReportException (monitor, ex); } } } else @@ -245,79 +247,98 @@ return !rollback; } + void ReportException (IProgressMonitor statusMonitor, Exception ex) + { + if (ex is InstallException) + statusMonitor.ReportError (ex.Message, null); + else + statusMonitor.ReportError (null, ex); + } + public void Uninstall (IProgressStatus statusMonitor, string id) { - IProgressMonitor monitor = ProgressStatusMonitor.GetProgressMonitor (statusMonitor); + Uninstall (statusMonitor, new string[] { id }); + } - bool rollback = false; - ArrayList toUninstall = new ArrayList (); - ArrayList uninstallPrepared = new ArrayList (); - - Addin ia = service.Registry.GetAddin (id); - if (ia == null) - throw new InstallException ("The add-in '" + id + "' is not installed."); - - toUninstall.Add (AddinPackage.FromInstalledAddin (ia)); - - Addin[] deps = GetDependentAddins (id, true); - foreach (Addin dep in deps) - toUninstall.Add (AddinPackage.FromInstalledAddin (dep)); - - monitor.BeginTask ("Deleting files", toUninstall.Count*2 + uninstallPrepared.Count + 1); - - // Prepare install - - foreach (Package mpack in toUninstall) { - try { - mpack.PrepareUninstall (monitor, this); - monitor.Step (1); - uninstallPrepared.Add (mpack); - } catch (Exception ex) { - monitor.ReportError (null, ex); - rollback = true; - break; - } - } - - // Commit install + public void Uninstall (IProgressStatus statusMonitor, IEnumerable ids) + { + IProgressMonitor monitor = ProgressStatusMonitor.GetProgressMonitor (statusMonitor); + monitor.BeginTask ("Uninstalling add-ins", ids.Count ()); - if (!rollback) { + foreach (string id in ids) { + bool rollback = false; + ArrayList toUninstall = new ArrayList (); + ArrayList uninstallPrepared = new ArrayList (); + + Addin ia = service.Registry.GetAddin (id); + if (ia == null) + throw new InstallException ("The add-in '" + id + "' is not installed."); + + toUninstall.Add (AddinPackage.FromInstalledAddin (ia)); + + Addin[] deps = GetDependentAddins (id, true); + foreach (Addin dep in deps) + toUninstall.Add (AddinPackage.FromInstalledAddin (dep)); + + monitor.BeginTask ("Deleting files", toUninstall.Count*2 + uninstallPrepared.Count + 1); + + // Prepare install + foreach (Package mpack in toUninstall) { try { - mpack.CommitUninstall (monitor, this); + mpack.PrepareUninstall (monitor, this); monitor.Step (1); + uninstallPrepared.Add (mpack); } catch (Exception ex) { - monitor.ReportError (null, ex); + ReportException (monitor, ex); rollback = true; break; } } - } - - // Rollback if failed - - if (rollback) { - monitor.BeginTask ("Rolling back uninstall", uninstallPrepared.Count); + + // Commit install + + if (!rollback) { + foreach (Package mpack in toUninstall) { + try { + mpack.CommitUninstall (monitor, this); + monitor.Step (1); + } catch (Exception ex) { + ReportException (monitor, ex); + rollback = true; + break; + } + } + } + + // Rollback if failed + + if (rollback) { + monitor.BeginTask ("Rolling back uninstall", uninstallPrepared.Count); + foreach (Package mpack in uninstallPrepared) { + try { + mpack.RollbackUninstall (monitor, this); + } catch (Exception ex) { + ReportException (monitor, ex); + } + } + monitor.EndTask (); + } + monitor.Step (1); + + // Cleanup + foreach (Package mpack in uninstallPrepared) { try { - mpack.RollbackUninstall (monitor, this); + mpack.EndUninstall (monitor, this); + monitor.Step (1); } catch (Exception ex) { - monitor.ReportError (null, ex); + monitor.Log.WriteLine (ex); } } + monitor.EndTask (); - } - monitor.Step (1); - - // Cleanup - - foreach (Package mpack in uninstallPrepared) { - try { - mpack.EndUninstall (monitor, this); - monitor.Step (1); - } catch (Exception ex) { - monitor.Log.WriteLine (ex); - } + monitor.Step (1); } // Update the extension maps @@ -411,7 +432,7 @@ AddinPackage ap = p as AddinPackage; if (ap != null) { Addin ia = service.Registry.GetAddin (ap.Addin.Id); - if (File.Exists (ia.AddinFile) && !HasWriteAccess (ia.AddinFile)) { + if (File.Exists (ia.AddinFile) && !HasWriteAccess (ia.AddinFile) && IsUserAddin (ia.AddinFile)) { monitor.ReportError (GetUninstallErrorNoRoot (ap.Addin), null); return false; } @@ -458,6 +479,16 @@ } } + // Don't allow installing add-ins which are scheduled for uninstall + + foreach (Package p in packages) { + AddinPackage ap = p as AddinPackage; + if (ap != null && Registry.IsRegisteredForUninstall (ap.Addin.Id)) { + error = true; + monitor.ReportError ("The addin " + ap.Addin.Name + " v" + ap.Addin.Version + " is scheduled for uninstallation. Please restart the application before trying to re-install it.", null); + } + } + return !error; } @@ -530,7 +561,7 @@ foreach (string file in Directory.GetFiles (src)) { if (Path.GetFileName (file) != "addin.info") - File.Copy (file, Path.Combine (destDir, Path.GetFileName (file))); + File.Copy (file, Path.Combine (destDir, Path.GetFileName (file)), true); } foreach (string dir in Directory.GetDirectories (src)) @@ -597,7 +628,7 @@ { if (url.StartsWith ("file://")) { string tmpfile = Path.GetTempFileName (); - string path = url.Substring (7); + string path = new Uri (url).LocalPath; File.Delete (tmpfile); File.Copy (path, tmpfile); return tmpfile; @@ -667,6 +698,14 @@ return false; } + internal bool IsUserAddin (string addinFile) + { + string installPath = service.InstallDirectory; + if (installPath [installPath.Length - 1] != Path.DirectorySeparatorChar) + installPath += Path.DirectorySeparatorChar; + return Path.GetFullPath (addinFile).StartsWith (installPath); + } + internal static string GetUninstallErrorNoRoot (AddinHeader ainfo) { return string.Format ("The add-in '{0} v{1}' can't be uninstalled with the current user permissions.", ainfo.Name, ainfo.Version); diff -Nru mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/AddinSystemConfigurationReaderWriter.cs mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/AddinSystemConfigurationReaderWriter.cs --- mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/AddinSystemConfigurationReaderWriter.cs 2008-11-06 19:52:10.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/AddinSystemConfigurationReaderWriter.cs 2011-04-13 09:00:29.000000000 +0000 @@ -1,31 +1,4 @@ -// -// AddinSystemConfigurationReader.cs -// -// Author: -// Lluis Sanchez Gual -// -// Copyright (C) 2007 Novell, Inc (http://www.novell.com) -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - +// It is automatically generated using System; using System.Xml; using System.Xml.Schema; @@ -38,6 +11,11 @@ { internal class AddinSystemConfigurationReader : XmlSerializationReader { + static readonly System.Reflection.MethodInfo fromBinHexStringMethod = typeof (XmlConvert).GetMethod ("FromBinHexString", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic, null, new Type [] {typeof (string)}, null); + static byte [] FromBinHexString (string input) + { + return input == null ? null : (byte []) fromBinHexStringMethod.Invoke (null, new object [] {input}); + } public object ReadRoot_AddinSystemConfiguration () { Reader.MoveToContent(); @@ -60,7 +38,7 @@ throw CreateUnknownTypeException(t); } - ob = new Mono.Addins.Setup.AddinSystemConfiguration (); + ob = (Mono.Addins.Setup.AddinSystemConfiguration) Activator.CreateInstance(typeof(Mono.Addins.Setup.AddinSystemConfiguration), true); Reader.MoveToElement(); @@ -73,6 +51,7 @@ } } + Reader.MoveToElement (); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip (); @@ -103,9 +82,10 @@ if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (Reader.LocalName == "Addin" && Reader.NamespaceURI == "") { + string s5 = Reader.ReadElementString (); if (((object)ob.@AddinPaths) == null) throw CreateReadOnlyCollectionException ("System.Collections.Specialized.StringCollection"); - ob.@AddinPaths.Add (Reader.ReadElementString ()); + ob.@AddinPaths.Add (s5); n4++; } else UnknownNode (null); @@ -120,7 +100,8 @@ } else if (Reader.LocalName == "RepositoryIdCount" && Reader.NamespaceURI == "" && !b1) { b1 = true; - ob.@RepositoryIdCount = Int32.Parse (Reader.ReadElementString (), CultureInfo.InvariantCulture); + string s6 = Reader.ReadElementString (); + ob.@RepositoryIdCount = Int32.Parse (s6, CultureInfo.InvariantCulture); } else if (Reader.LocalName == "DisabledAddins" && Reader.NamespaceURI == "" && !b2) { if (((object)ob.@DisabledAddins) == null) @@ -128,7 +109,7 @@ if (Reader.IsEmptyElement) { Reader.Skip(); } else { - int n5 = 0; + int n7 = 0; Reader.ReadStartElement(); Reader.MoveToContent(); @@ -137,10 +118,11 @@ if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (Reader.LocalName == "Addin" && Reader.NamespaceURI == "") { + string s8 = Reader.ReadElementString (); if (((object)ob.@DisabledAddins) == null) throw CreateReadOnlyCollectionException ("System.Collections.Specialized.StringCollection"); - ob.@DisabledAddins.Add (Reader.ReadElementString ()); - n5++; + ob.@DisabledAddins.Add (s8); + n7++; } else UnknownNode (null); } @@ -158,7 +140,7 @@ if (Reader.IsEmptyElement) { Reader.Skip(); } else { - int n6 = 0; + int n9 = 0; Reader.ReadStartElement(); Reader.MoveToContent(); @@ -170,7 +152,7 @@ if (((object)ob.@Repositories) == null) throw CreateReadOnlyCollectionException ("System.Collections.ArrayList"); ob.@Repositories.Add (ReadObject_RepositoryRecord (false, true)); - n6++; + n9++; } else UnknownNode (null); } @@ -211,7 +193,7 @@ throw CreateUnknownTypeException(t); } - ob = new Mono.Addins.Setup.RepositoryRecord (); + ob = (Mono.Addins.Setup.RepositoryRecord) Activator.CreateInstance(typeof(Mono.Addins.Setup.RepositoryRecord), true); Reader.MoveToElement(); @@ -227,6 +209,7 @@ } } + Reader.MoveToElement (); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip (); @@ -236,31 +219,41 @@ Reader.ReadStartElement(); Reader.MoveToContent(); - bool b7=false, b8=false, b9=false, b10=false, b11=false; + bool b10=false, b11=false, b12=false, b13=false, b14=false, b15=false; while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) { if (Reader.NodeType == System.Xml.XmlNodeType.Element) { - if (Reader.LocalName == "File" && Reader.NamespaceURI == "" && !b8) { - b8 = true; - ob.@File = Reader.ReadElementString (); - } - else if (Reader.LocalName == "IsReference" && Reader.NamespaceURI == "" && !b7) { - b7 = true; - ob.@IsReference = XmlConvert.ToBoolean (Reader.ReadElementString ()); + if (Reader.LocalName == "File" && Reader.NamespaceURI == "" && !b11) { + b11 = true; + string s16 = Reader.ReadElementString (); + ob.@File = s16; } - else if (Reader.LocalName == "Name" && Reader.NamespaceURI == "" && !b10) { - b10 = true; - ob.@Name = Reader.ReadElementString (); + else if (Reader.LocalName == "Enabled" && Reader.NamespaceURI == "" && !b15) { + b15 = true; + string s17 = Reader.ReadElementString (); + ob.@Enabled = XmlConvert.ToBoolean (s17); } - else if (Reader.LocalName == "Url" && Reader.NamespaceURI == "" && !b9) { - b9 = true; - ob.@Url = Reader.ReadElementString (); + else if (Reader.LocalName == "IsReference" && Reader.NamespaceURI == "" && !b10) { + b10 = true; + string s18 = Reader.ReadElementString (); + ob.@IsReference = XmlConvert.ToBoolean (s18); } - else if (Reader.LocalName == "LastModified" && Reader.NamespaceURI == "" && !b11) { - b11 = true; - ob.@LastModified = XmlConvert.ToDateTime (Reader.ReadElementString ()); + else if (Reader.LocalName == "Name" && Reader.NamespaceURI == "" && !b13) { + b13 = true; + string s19 = Reader.ReadElementString (); + ob.@Name = s19; + } + else if (Reader.LocalName == "Url" && Reader.NamespaceURI == "" && !b12) { + b12 = true; + string s20 = Reader.ReadElementString (); + ob.@Url = s20; + } + else if (Reader.LocalName == "LastModified" && Reader.NamespaceURI == "" && !b14) { + b14 = true; + string s21 = Reader.ReadElementString (); + ob.@LastModified = XmlConvert.ToDateTime (s21, XmlDateTimeSerializationMode.RoundtripKind); } else { UnknownNode (ob); @@ -290,6 +283,11 @@ internal class AddinSystemConfigurationWriter : XmlSerializationWriter { const string xmlNamespace = "http://www.w3.org/2000/xmlns/"; + static readonly System.Reflection.MethodInfo toBinHexStringMethod = typeof (XmlConvert).GetMethod ("ToBinHexString", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic, null, new Type [] {typeof (byte [])}, null); + static string ToBinHexString (byte [] input) + { + return input == null ? null : (string) toBinHexStringMethod.Invoke (null, new object [] {input}); + } public void WriteRoot_AddinSystemConfiguration (object o) { WriteStartDocument (); @@ -322,23 +320,23 @@ if (ob.@Repositories != null) { WriteStartElement ("Repositories", "", ob.@Repositories); - for (int n12 = 0; n12 < ob.@Repositories.Count; n12++) { - WriteObject_RepositoryRecord (((Mono.Addins.Setup.RepositoryRecord) ob.@Repositories[n12]), "Repository", "", false, false, true); + for (int n22 = 0; n22 < ob.@Repositories.Count; n22++) { + WriteObject_RepositoryRecord (((Mono.Addins.Setup.RepositoryRecord) ob.@Repositories[n22]), "Repository", "", false, false, true); } WriteEndElement (ob.@Repositories); } WriteElementString ("RepositoryIdCount", "", ob.@RepositoryIdCount.ToString(CultureInfo.InvariantCulture)); if (ob.@DisabledAddins != null) { WriteStartElement ("DisabledAddins", "", ob.@DisabledAddins); - for (int n13 = 0; n13 < ob.@DisabledAddins.Count; n13++) { - WriteElementString ("Addin", "", ob.@DisabledAddins[n13]); + for (int n23 = 0; n23 < ob.@DisabledAddins.Count; n23++) { + WriteElementString ("Addin", "", ob.@DisabledAddins[n23]); } WriteEndElement (ob.@DisabledAddins); } if (ob.@AddinPaths != null) { WriteStartElement ("AddinPaths", "", ob.@AddinPaths); - for (int n14 = 0; n14 < ob.@AddinPaths.Count; n14++) { - WriteElementString ("Addin", "", ob.@AddinPaths[n14]); + for (int n24 = 0; n24 < ob.@AddinPaths.Count; n24++) { + WriteElementString ("Addin", "", ob.@AddinPaths[n24]); } WriteEndElement (ob.@AddinPaths); } @@ -373,15 +371,16 @@ WriteElementString ("File", "", ob.@File); WriteElementString ("Url", "", ob.@Url); WriteElementString ("Name", "", ob.@Name); - WriteElementString ("LastModified", "", ob.@LastModified.ToString("yyyy-MM-ddTHH:mm:ss.fffffffzzz", CultureInfo.InvariantCulture)); + WriteElementString ("LastModified", "", XmlConvert.ToString (ob.@LastModified, XmlDateTimeSerializationMode.RoundtripKind)); + if (ob.@Enabled != true) { + WriteElementString ("Enabled", "", (ob.@Enabled?"true":"false")); + } if (writeWrappingElem) WriteEndElement (ob); } protected override void InitCallbacks () { } - } - } diff -Nru mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/ConsoleAddinInstaller.cs mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/ConsoleAddinInstaller.cs --- mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/ConsoleAddinInstaller.cs 2008-11-06 19:52:10.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/ConsoleAddinInstaller.cs 2011-04-13 09:00:29.000000000 +0000 @@ -31,16 +31,25 @@ namespace Mono.Addins.Setup { + /// + /// An IAddinInstaller implementation which interacts with the user through the console + /// public class ConsoleAddinInstaller: IAddinInstaller { bool prompt; bool repoUpdated; int logLevel = 1; + /// + /// Initializes a new instance of the class. + /// public ConsoleAddinInstaller () { } + /// + /// Gets or sets whether the installer can ask questions to the user + /// public bool UserPrompt { get { return prompt; } set { @@ -50,6 +59,9 @@ } } + /// + /// Log level (0:normal, 1+:verbose); + /// public int LogLevel { get { return logLevel; } set { logLevel = value; } diff -Nru mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/InstallException.cs mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/InstallException.cs --- mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/InstallException.cs 2008-11-06 19:52:10.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/InstallException.cs 2011-04-13 09:00:29.000000000 +0000 @@ -30,12 +30,30 @@ namespace Mono.Addins.Setup { + /// + /// An installation exception + /// public class InstallException: Exception { + /// + /// Initializes the exception + /// + /// + /// Error message + /// public InstallException (string msg): base (msg) { } + /// + /// Initializes the exception + /// + /// + /// Error message + /// + /// + /// Inner exception + /// public InstallException (string msg, Exception ex): base (msg, ex) { } diff -Nru mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/PackageCollection.cs mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/PackageCollection.cs --- mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/PackageCollection.cs 2008-11-06 19:52:10.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/PackageCollection.cs 2011-04-13 09:00:29.000000000 +0000 @@ -34,31 +34,70 @@ namespace Mono.Addins.Setup { + /// + /// A collection of packages + /// public class PackageCollection: CollectionBase { + /// + /// Initializes a new instance of the class. + /// public PackageCollection () { } + /// + /// Copy constructor + /// + /// + /// Collection where to copy from + /// public PackageCollection (ICollection col) { AddRange (col); } + /// + /// Gets a package + /// + /// + /// Package index + /// public Package this [int n] { get { return (Package) List [n]; } } + /// + /// Adds a package + /// + /// + /// A package + /// public void Add (Package p) { List.Add (p); } + /// + /// Checks if a package is present in the collection + /// + /// + /// The package + /// + /// + /// True if the package is preent + /// public bool Contains (Package p) { return List.Contains (p); } + /// + /// Adds a list of packages to the collection + /// + /// + /// The list of packages to add + /// public void AddRange (ICollection col) { foreach (Package p in col) diff -Nru mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/Package.cs mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/Package.cs --- mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/Package.cs 2008-11-06 19:52:10.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/Package.cs 2011-04-13 09:00:29.000000000 +0000 @@ -32,25 +32,51 @@ namespace Mono.Addins.Setup { + /// + /// An add-in package + /// public abstract class Package { internal Package () { } + /// + /// Name of the package + /// public abstract string Name { get; } - // Returns true if the package will be installed in the shared directory, - // false if it will be installed in the user directory. + /// + /// Returns true if the package will be installed in the shared directory, + /// false if it will be installed in the user directory. + /// public virtual bool SharedInstall { get { return false; } } - + + /// + /// Creates a package object for an add-in available in an on-line repository + /// + /// + /// An add-in reference + /// + /// + /// The package + /// public static Package FromRepository (AddinRepositoryEntry repAddin) { return AddinPackage.PackageFromRepository (repAddin); } + /// + /// Creates a package object for a local package file + /// + /// + /// Package file path + /// + /// + /// The package + /// public static Package FromFile (string file) { return AddinPackage.PackageFromFile (file); diff -Nru mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/PcFileCache.cs mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/PcFileCache.cs --- mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/PcFileCache.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/PcFileCache.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,642 @@ +// +// PcFileCache.cs +// +// Author: +// Lluis Sanchez Gual +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Text; +using System.Xml; +using System.IO; +using System.Collections.Generic; + +namespace Mono.PkgConfig +{ + internal interface IPcFileCacheContext where TP:PackageInfo, new() + { + // In the implementation of this method, the host application can extract + // information from the pc file and store it in the PackageInfo object + void StoreCustomData (PcFile pcfile, TP pkg); + + // Should return false if the provided package does not have required + // custom data + bool IsCustomDataComplete (string pcfile, TP pkg); + + // Called to report errors + void ReportError (string message, Exception ex); + } + + internal interface IPcFileCacheContext: IPcFileCacheContext + { + } + + internal abstract class PcFileCache: PcFileCache + { + public PcFileCache (IPcFileCacheContext ctx): base (ctx) + { + } + } + + internal abstract class PcFileCache where TP:PackageInfo, new() + { + const string CACHE_VERSION = "2"; + + Dictionary infos = new Dictionary (); + Dictionary> filesByFolder = new Dictionary> (); + + string cacheFile; + bool hasChanges; + IPcFileCacheContext ctx; + IEnumerable defaultPaths; + + public PcFileCache (IPcFileCacheContext ctx) + { + this.ctx = ctx; + try { + string path = CacheDirectory; + if (!Directory.Exists (path)) + Directory.CreateDirectory (path); + cacheFile = Path.Combine (path, "pkgconfig-cache-" + CACHE_VERSION + ".xml"); + + if (File.Exists (cacheFile)) + Load (); + + } catch (Exception ex) { + ctx.ReportError ("pc file cache could not be loaded.", ex); + } + } + + protected abstract string CacheDirectory { get; } + + // Updates the pkg-config index, using the default search directories + public void Update () + { + Update (GetDefaultPaths ()); + } + + // Updates the pkg-config index, looking for .pc files in the provided directories + public void Update (IEnumerable pkgConfigDirs) + { + foreach (string pcdir in pkgConfigDirs) { + foreach (string pcfile in Directory.GetFiles (pcdir, "*.pc")) + GetPackageInfo (pcfile); + } + Save (); + } + + public IEnumerable GetPackages () + { + return GetPackages (null); + } + + public IEnumerable GetPackages (IEnumerable pkgConfigDirs) + { + if (pkgConfigDirs == null) + pkgConfigDirs = GetDefaultPaths (); + + foreach (string sp in pkgConfigDirs) { + List list; + if (filesByFolder.TryGetValue (Path.GetFullPath (sp), out list)) { + foreach (TP p in list) + yield return p; + } + } + } + + public TP GetPackageInfoByName (string name) + { + return GetPackageInfoByName (name, null); + } + + public TP GetPackageInfoByName (string name, IEnumerable pkgConfigDirs) + { + foreach (TP p in GetPackages (pkgConfigDirs)) + if (p.Name == name) + return p; + return null; + } + + // Returns information about a .pc file + public TP GetPackageInfo (string file) + { + TP info, oldInfo = null; + file = Path.GetFullPath (file); + + DateTime wtime = File.GetLastWriteTime (file); + + lock (infos) { + if (infos.TryGetValue (file, out info)) { + if (info.LastWriteTime == wtime) + return info; + oldInfo = info; + } + } + + try { + info = ParsePackageInfo (file); + } catch (Exception ex) { + ctx.ReportError ("Error while parsing .pc file", ex); + info = new TP (); + } + + lock (infos) { + if (!info.IsValidPackage) + info = new TP (); // Create a default empty instance + info.LastWriteTime = wtime; + Add (file, info, oldInfo); + hasChanges = true; + } + + return info; + } + + void Add (string file, TP info, TP replacedInfo) + { + infos [file] = info; + string dir = Path.GetFullPath (Path.GetDirectoryName (file)); + List list; + if (!filesByFolder.TryGetValue (dir, out list)) { + list = new List (); + filesByFolder [dir] = list; + } + if (replacedInfo != null) { + int i = list.IndexOf (replacedInfo); + if (i != -1) { + list [i] = info; + return; + } + } + list.Add (info); + } + + FileStream OpenFile (FileAccess access) + { + int retries = 6; + FileMode mode = access == FileAccess.Read ? FileMode.Open : FileMode.Create; + Exception lastException = null; + + while (retries > 0) { + try { + return new FileStream (cacheFile, mode, access, FileShare.None); + } catch (Exception ex) { + // the file may be locked by another app. Wait a bit and try again + lastException = ex; + System.Threading.Thread.Sleep (200); + retries--; + } + } + ctx.ReportError ("File could not be opened: " + cacheFile, lastException); + return null; + } + + void Load () + { + // The serializer can't be used because this file is reused in xbuild + using (FileStream fs = OpenFile (FileAccess.Read)) { + if (fs == null) + return; + XmlTextReader xr = new XmlTextReader (fs); + xr.MoveToContent (); + xr.ReadStartElement (); + xr.MoveToContent (); + + while (xr.NodeType == XmlNodeType.Element) + ReadPackage (xr); + } + } + + public void Save () + { + // The serializer can't be used because this file is reused in xbuild + lock (infos) { + if (!hasChanges) + return; + + using (FileStream fs = OpenFile (FileAccess.Write)) { + if (fs == null) + return; + XmlTextWriter tw = new XmlTextWriter (new StreamWriter (fs)); + tw.Formatting = Formatting.Indented; + + tw.WriteStartElement ("PcFileCache"); + foreach (KeyValuePair file in infos) { + WritePackage (tw, file.Key, file.Value); + } + tw.WriteEndElement (); // PcFileCache + tw.Flush (); + + hasChanges = false; + } + } + } + + void WritePackage (XmlTextWriter tw, string file, TP pinfo) + { + tw.WriteStartElement ("File"); + tw.WriteAttributeString ("path", file); + tw.WriteAttributeString ("lastWriteTime", XmlConvert.ToString (pinfo.LastWriteTime, XmlDateTimeSerializationMode.Local)); + + if (pinfo.IsValidPackage) { + if (pinfo.Name != null) + tw.WriteAttributeString ("name", pinfo.Name); + if (pinfo.Version != null) + tw.WriteAttributeString ("version", pinfo.Version); + if (!string.IsNullOrEmpty (pinfo.Description)) + tw.WriteAttributeString ("description", pinfo.Description); + if (pinfo.CustomData != null) { + foreach (KeyValuePair cd in pinfo.CustomData) + tw.WriteAttributeString (cd.Key, cd.Value); + } + WritePackageContent (tw, file, pinfo); + } + tw.WriteEndElement (); // File + } + + protected virtual void WritePackageContent (XmlTextWriter tw, string file, TP pinfo) + { + } + + void ReadPackage (XmlReader tr) + { + TP pinfo = new TP (); + string file = null; + + tr.MoveToFirstAttribute (); + do { + switch (tr.LocalName) { + case "path": file = tr.Value; break; + case "lastWriteTime": pinfo.LastWriteTime = XmlConvert.ToDateTime (tr.Value, XmlDateTimeSerializationMode.Local); break; + case "name": pinfo.Name = tr.Value; break; + case "version": pinfo.Version = tr.Value; break; + case "description": pinfo.Description = tr.Value; break; + default: pinfo.SetData (tr.LocalName, tr.Value); break; + } + } while (tr.MoveToNextAttribute ()); + + tr.MoveToElement (); + + if (!tr.IsEmptyElement) { + tr.ReadStartElement (); + tr.MoveToContent (); + ReadPackageContent (tr, pinfo); + tr.MoveToContent (); + tr.ReadEndElement (); + } else + tr.Read (); + tr.MoveToContent (); + + if (!pinfo.IsValidPackage || ctx.IsCustomDataComplete (file, pinfo)) + Add (file, pinfo, null); + } + + protected virtual void ReadPackageContent (XmlReader tr, TP pinfo) + { + } + + public object SyncRoot { + get { return infos; } + } + + + TP ParsePackageInfo (string pcfile) + { + PcFile file = new PcFile (); + file.Load (pcfile); + + TP pinfo = new TP (); + pinfo.Name = Path.GetFileNameWithoutExtension (file.FilePath); + + if (!file.HasErrors) { + pinfo.Version = file.Version; + pinfo.Description = file.Description; + ParsePackageInfo (file, pinfo); + ctx.StoreCustomData (file, pinfo); + } + return pinfo; + } + + protected virtual void ParsePackageInfo (PcFile file, TP pinfo) + { + } + + IEnumerable GetDefaultPaths () + { + if (defaultPaths == null) { + string pkgConfigPath = Environment.GetEnvironmentVariable ("PKG_CONFIG_PATH"); + string pkgConfigDir = Environment.GetEnvironmentVariable ("PKG_CONFIG_LIBDIR"); + defaultPaths = GetPkgconfigPaths (null, pkgConfigPath, pkgConfigDir); + } + return defaultPaths; + } + + public IEnumerable GetPkgconfigPaths (string prefix, string pkgConfigPath, string pkgConfigLibdir) + { + char[] sep = new char[] { Path.PathSeparator }; + + string[] pkgConfigPaths = null; + if (!String.IsNullOrEmpty (pkgConfigPath)) { + pkgConfigPaths = pkgConfigPath.Split (sep, StringSplitOptions.RemoveEmptyEntries); + if (pkgConfigPaths.Length == 0) + pkgConfigPaths = null; + } + + string[] pkgConfigLibdirs = null; + if (!String.IsNullOrEmpty (pkgConfigLibdir)) { + pkgConfigLibdirs = pkgConfigLibdir.Split (sep, StringSplitOptions.RemoveEmptyEntries); + if (pkgConfigLibdirs.Length == 0) + pkgConfigLibdirs = null; + } + + if (prefix == null) + prefix = PathUp (typeof (int).Assembly.Location, 4); + + IEnumerable paths = GetUnfilteredPkgConfigDirs (pkgConfigPaths, pkgConfigLibdirs, new string [] { prefix }); + return NormaliseAndFilterPaths (paths, Environment.CurrentDirectory); + } + + IEnumerable GetUnfilteredPkgConfigDirs (IEnumerable pkgConfigPaths, IEnumerable pkgConfigLibdirs, IEnumerable systemPrefixes) + { + if (pkgConfigPaths != null) { + foreach (string dir in pkgConfigPaths) + yield return dir; + } + + if (pkgConfigLibdirs != null) { + foreach (string dir in pkgConfigLibdirs) + yield return dir; + } else if (systemPrefixes != null) { + string[] suffixes = new string [] { + Path.Combine ("lib", "pkgconfig"), + Path.Combine ("lib64", "pkgconfig"), + Path.Combine ("libdata", "pkgconfig"), + Path.Combine ("share", "pkgconfig"), + }; + foreach (string prefix in systemPrefixes) + foreach (string suffix in suffixes) + yield return Path.Combine (prefix, suffix); + } + } + + IEnumerable NormaliseAndFilterPaths (IEnumerable paths, string workingDirectory) + { + Dictionary filtered = new Dictionary (); + foreach (string p in paths) { + string path = p; + if (!Path.IsPathRooted (path)) + path = Path.Combine (workingDirectory, path); + path = Path.GetFullPath (path); + if (filtered.ContainsKey (path)) + continue; + filtered.Add (path,path); + try { + if (!Directory.Exists (path)) + continue; + } catch (IOException ex) { + ctx.ReportError ("Error checking for directory '" + path + "'.", ex); + } + yield return path; + } + } + + static string PathUp (string path, int up) + { + if (up == 0) + return path; + for (int i = path.Length -1; i >= 0; i--) { + if (path[i] == Path.DirectorySeparatorChar) { + up--; + if (up == 0) + return path.Substring (0, i); + } + } + return null; + } + } + + internal class PcFile + { + Dictionary variables = new Dictionary (); + + string filePath; + string name; + string description; + string version; + string libs; + bool hasErrors; + + public string Description { + get { + return description; + } + set { + description = value; + } + } + + public string FilePath { + get { + return filePath; + } + set { + filePath = value; + } + } + + public bool HasErrors { + get { + return hasErrors; + } + set { + hasErrors = value; + } + } + + public string Libs { + get { + return libs; + } + set { + libs = value; + } + } + + public string Name { + get { + return name; + } + set { + name = value; + } + } + + public string Version { + get { + return version; + } + set { + version = value; + } + } + + public string GetVariable (string varName) + { + string val; + variables.TryGetValue (varName, out val); + return val; + } + + public void Load (string pcfile) + { + FilePath = pcfile; + variables.Add ("pcfiledir", Path.GetDirectoryName (pcfile)); + using (StreamReader reader = new StreamReader (pcfile)) { + string line; + while ((line = reader.ReadLine ()) != null) { + int i = line.IndexOf (':'); + int j = line.IndexOf ('='); + int k = System.Math.Min (i != -1 ? i : int.MaxValue, j != -1 ? j : int.MaxValue); + if (k == int.MaxValue) + continue; + string var = line.Substring (0, k).Trim (); + string value = line.Substring (k + 1).Trim (); + value = Evaluate (value); + + if (k == j) { + // Is variable + variables [var] = value; + } + else { + switch (var) { + case "Name": Name = value; break; + case "Description": Description = value; break; + case "Version": Version = value; break; + case "Libs": Libs = value; break; + } + } + } + } + } + + string Evaluate (string value) + { + int i = value.IndexOf ("${"); + if (i == -1) + return value; + + StringBuilder sb = new StringBuilder (); + int last = 0; + while (i != -1 && i < value.Length) { + sb.Append (value.Substring (last, i - last)); + if (i == 0 || value [i - 1] != '$') { + // Evaluate if var is not escaped + i += 2; + int n = value.IndexOf ('}', i); + if (n == -1 || n == i) { + // Closing bracket not found or empty name + HasErrors = true; + return value; + } + string rname = value.Substring (i, n - i); + string rval; + if (variables.TryGetValue (rname, out rval)) + sb.Append (rval); + else { + HasErrors = true; + return value; + } + i = n + 1; + last = i; + } else + last = i++; + + if (i < value.Length - 1) + i = value.IndexOf ("${", i); + } + sb.Append (value.Substring (last, value.Length - last)); + return sb.ToString (); + } + } + + internal class PackageInfo + { + Dictionary customData; + string name; + string version; + string description; + DateTime lastWriteTime; + + public string Name { + get { return name; } + set { name = value; } + } + + public string Version { + get { return version; } + set { version = value; } + } + + public string Description { + get { return description; } + set { description = value; } + } + + public string GetData (string name) + { + if (customData == null) + return null; + string res; + customData.TryGetValue (name, out res); + return res; + } + + public void SetData (string name, string value) + { + if (customData == null) + customData = new Dictionary (); + customData [name] = value; + } + + public void RemoveData (string name) + { + if (customData != null) + customData.Remove (name); + } + + internal Dictionary CustomData { + get { return customData; } + } + + internal DateTime LastWriteTime { + get { return lastWriteTime; } + set { lastWriteTime = value; } + } + + internal bool HasCustomData { + get { return customData != null && customData.Count > 0; } + } + + internal protected virtual bool IsValidPackage { + get { return HasCustomData; } + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/Repository.cs mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/Repository.cs --- mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/Repository.cs 2008-11-06 19:52:10.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/Repository.cs 2011-04-13 09:00:29.000000000 +0000 @@ -30,6 +30,9 @@ using System.Collections; using System.Xml; using System.Xml.Serialization; +using System.IO; +using System.Net; +using System.Threading; namespace Mono.Addins.Setup { @@ -49,6 +52,8 @@ get { return url; } set { url = value; } } + + internal string CachedFilesDir { get; set; } [XmlElement ("Repository", Type = typeof(ReferenceRepositoryEntry))] public RepositoryEntryCollection Repositories { @@ -98,5 +103,107 @@ else Repositories.Remove (entry); } + + public IAsyncResult BeginDownloadSupportFile (string name, AsyncCallback cb, object state) + { + FileAsyncResult res = new FileAsyncResult (); + res.AsyncState = state; + res.Callback = cb; + + string cachedFile = Path.Combine (CachedFilesDir, Path.GetFileName (name)); + if (File.Exists (cachedFile)) { + res.FilePath = cachedFile; + res.CompletedSynchronously = true; + res.SetDone (); + return res; + } + + Uri u = new Uri (new Uri (Url), name); + if (u.Scheme == "file") { + res.FilePath = u.AbsolutePath; + res.CompletedSynchronously = true; + res.SetDone (); + return res; + } + else { + HttpWebRequest req = (HttpWebRequest) HttpWebRequest.Create (u); + res.FilePath = cachedFile; + res.Request = req; + req.BeginGetResponse (OnGotResponse, res); + } + return res; + } + + void OnGotResponse (IAsyncResult ares) + { + FileAsyncResult res = (FileAsyncResult) ares.AsyncState; + try { + WebResponse resp = res.Request.EndGetResponse (ares); + string dir = Path.GetDirectoryName (res.FilePath); + lock (this) { + if (!Directory.Exists (dir)) + Directory.CreateDirectory (dir); + } + byte[] buffer = new byte [8092]; + using (var s = resp.GetResponseStream ()) { + using (var f = File.OpenWrite (res.FilePath)) { + int nr = 0; + while ((nr = s.Read (buffer, 0, buffer.Length)) > 0) + f.Write (buffer, 0, nr); + } + } + } catch (Exception ex) { + res.Error = ex; + } + res.SetDone (); + } + + public Stream EndDownloadSupportFile (IAsyncResult ares) + { + FileAsyncResult res = ares as FileAsyncResult; + if (res == null) + throw new InvalidOperationException ("Invalid IAsyncResult instance"); + if (res.Error != null) + throw res.Error; + return File.OpenRead (res.FilePath); + } + } + + class FileAsyncResult: IAsyncResult + { + ManualResetEvent done; + + public string FilePath; + public HttpWebRequest Request; + public AsyncCallback Callback; + public Exception Error; + + public void SetDone () + { + lock (this) { + IsCompleted = true; + if (done != null) + done.Set (); + } + if (Callback != null) + Callback (this); + } + + public object AsyncState { get; set; } + + public WaitHandle AsyncWaitHandle { + get { + lock (this) { + if (done == null) + done = new ManualResetEvent (IsCompleted); + } + return done; + } + } + + public bool CompletedSynchronously { get; set; } + + public bool IsCompleted { get; set; } } + } diff -Nru mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/RepositoryReaderWriter.cs mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/RepositoryReaderWriter.cs --- mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/RepositoryReaderWriter.cs 2008-11-06 19:52:10.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/RepositoryReaderWriter.cs 2011-04-13 09:00:29.000000000 +0000 @@ -1,31 +1,4 @@ -// -// RepositoryReader.cs -// -// Author: -// Lluis Sanchez Gual -// -// Copyright (C) 2007 Novell, Inc (http://www.novell.com) -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - +// It is automatically generated using System; using System.Xml; using System.Xml.Schema; @@ -38,6 +11,11 @@ { internal class RepositoryReader : XmlSerializationReader { + static readonly System.Reflection.MethodInfo fromBinHexStringMethod = typeof (XmlConvert).GetMethod ("FromBinHexString", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic, null, new Type [] {typeof (string)}, null); + static byte [] FromBinHexString (string input) + { + return input == null ? null : (byte []) fromBinHexStringMethod.Invoke (null, new object [] {input}); + } public object ReadRoot_Repository () { Reader.MoveToContent(); @@ -60,7 +38,7 @@ throw CreateUnknownTypeException(t); } - ob = new Mono.Addins.Setup.Repository (); + ob = (Mono.Addins.Setup.Repository) Activator.CreateInstance(typeof(Mono.Addins.Setup.Repository), true); Reader.MoveToElement(); @@ -73,6 +51,7 @@ } } + Reader.MoveToElement (); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip (); @@ -97,7 +76,7 @@ if (Reader.LocalName == "Addin" && Reader.NamespaceURI == "" && !b3) { if (((object)o7) == null) throw CreateReadOnlyCollectionException ("Mono.Addins.Setup.RepositoryEntryCollection"); - o7.Add (ReadObject_AddinRepositoryEntry (false, true)); + o7.Add (ReadObject_PackageRepositoryEntry (false, true)); n6++; } else if (Reader.LocalName == "Repository" && Reader.NamespaceURI == "" && !b2) { @@ -108,11 +87,13 @@ } else if (Reader.LocalName == "Name" && Reader.NamespaceURI == "" && !b0) { b0 = true; - ob.@Name = Reader.ReadElementString (); + string s8 = Reader.ReadElementString (); + ob.@Name = s8; } else if (Reader.LocalName == "Url" && Reader.NamespaceURI == "" && !b1) { b1 = true; - ob.@Url = Reader.ReadElementString (); + string s9 = Reader.ReadElementString (); + ob.@Url = s9; } else { UnknownNode (ob); @@ -130,7 +111,7 @@ return ob; } - public Mono.Addins.Setup.PackageRepositoryEntry ReadObject_AddinRepositoryEntry (bool isNullable, bool checkType) + public Mono.Addins.Setup.PackageRepositoryEntry ReadObject_PackageRepositoryEntry (bool isNullable, bool checkType) { Mono.Addins.Setup.PackageRepositoryEntry ob = null; if (isNullable && ReadNull()) return null; @@ -144,7 +125,7 @@ throw CreateUnknownTypeException(t); } - ob = new Mono.Addins.Setup.PackageRepositoryEntry (); + ob = (Mono.Addins.Setup.PackageRepositoryEntry) Activator.CreateInstance(typeof(Mono.Addins.Setup.PackageRepositoryEntry), true); Reader.MoveToElement(); @@ -157,6 +138,7 @@ } } + Reader.MoveToElement (); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip (); @@ -166,19 +148,20 @@ Reader.ReadStartElement(); Reader.MoveToContent(); - bool b8=false, b9=false; + bool b10=false, b11=false; while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) { if (Reader.NodeType == System.Xml.XmlNodeType.Element) { - if (Reader.LocalName == "Addin" && Reader.NamespaceURI == "" && !b9) { - b9 = true; + if (Reader.LocalName == "Addin" && Reader.NamespaceURI == "" && !b11) { + b11 = true; ob.@Addin = ReadObject_AddinInfo (false, true); } - else if (Reader.LocalName == "Url" && Reader.NamespaceURI == "" && !b8) { - b8 = true; - ob.@Url = Reader.ReadElementString (); + else if (Reader.LocalName == "Url" && Reader.NamespaceURI == "" && !b10) { + b10 = true; + string s12 = Reader.ReadElementString (); + ob.@Url = s12; } else { UnknownNode (ob); @@ -209,7 +192,7 @@ throw CreateUnknownTypeException(t); } - ob = new Mono.Addins.Setup.ReferenceRepositoryEntry (); + ob = (Mono.Addins.Setup.ReferenceRepositoryEntry) Activator.CreateInstance(typeof(Mono.Addins.Setup.ReferenceRepositoryEntry), true); Reader.MoveToElement(); @@ -222,6 +205,7 @@ } } + Reader.MoveToElement (); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip (); @@ -231,19 +215,21 @@ Reader.ReadStartElement(); Reader.MoveToContent(); - bool b10=false, b11=false; + bool b13=false, b14=false; while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) { if (Reader.NodeType == System.Xml.XmlNodeType.Element) { - if (Reader.LocalName == "Url" && Reader.NamespaceURI == "" && !b10) { - b10 = true; - ob.@Url = Reader.ReadElementString (); + if (Reader.LocalName == "Url" && Reader.NamespaceURI == "" && !b13) { + b13 = true; + string s15 = Reader.ReadElementString (); + ob.@Url = s15; } - else if (Reader.LocalName == "LastModified" && Reader.NamespaceURI == "" && !b11) { - b11 = true; - ob.@LastModified = XmlConvert.ToDateTime (Reader.ReadElementString ()); + else if (Reader.LocalName == "LastModified" && Reader.NamespaceURI == "" && !b14) { + b14 = true; + string s16 = Reader.ReadElementString (); + ob.@LastModified = XmlConvert.ToDateTime (s16, XmlDateTimeSerializationMode.RoundtripKind); } else { UnknownNode (ob); @@ -274,7 +260,7 @@ throw CreateUnknownTypeException(t); } - ob = new Mono.Addins.Setup.AddinInfo (); + ob = (Mono.Addins.Setup.AddinInfo) Activator.CreateInstance(typeof(Mono.Addins.Setup.AddinInfo), true); Reader.MoveToElement(); @@ -287,6 +273,7 @@ } } + Reader.MoveToElement (); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip (); @@ -296,23 +283,24 @@ Reader.ReadStartElement(); Reader.MoveToContent(); - bool b12=false, b13=false, b14=false, b15=false, b16=false, b17=false, b18=false, b19=false, b20=false, b21=false, b22=false, b23=false; + bool b17=false, b18=false, b19=false, b20=false, b21=false, b22=false, b23=false, b24=false, b25=false, b26=false, b27=false, b28=false, b29=false; while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) { if (Reader.NodeType == System.Xml.XmlNodeType.Element) { - if (Reader.LocalName == "Version" && Reader.NamespaceURI == "" && !b15) { - b15 = true; - ob.@Version = Reader.ReadElementString (); + if (Reader.LocalName == "Version" && Reader.NamespaceURI == "" && !b20) { + b20 = true; + string s30 = Reader.ReadElementString (); + ob.@Version = s30; } - else if (Reader.LocalName == "Dependencies" && Reader.NamespaceURI == "" && !b22) { + else if (Reader.LocalName == "Dependencies" && Reader.NamespaceURI == "" && !b27) { if (((object)ob.@Dependencies) == null) - throw CreateReadOnlyCollectionException ("Mono.Addins.Setup.DependencyCollection"); + throw CreateReadOnlyCollectionException ("Mono.Addins.Description.DependencyCollection"); if (Reader.IsEmptyElement) { Reader.Skip(); } else { - int n24 = 0; + int n31 = 0; Reader.ReadStartElement(); Reader.MoveToContent(); @@ -322,21 +310,21 @@ { if (Reader.LocalName == "AssemblyDependency" && Reader.NamespaceURI == "") { if (((object)ob.@Dependencies) == null) - throw CreateReadOnlyCollectionException ("Mono.Addins.Setup.DependencyCollection"); + throw CreateReadOnlyCollectionException ("Mono.Addins.Description.DependencyCollection"); ob.@Dependencies.Add (ReadObject_AssemblyDependency (false, true)); - n24++; + n31++; } else if (Reader.LocalName == "NativeDependency" && Reader.NamespaceURI == "") { if (((object)ob.@Dependencies) == null) - throw CreateReadOnlyCollectionException ("Mono.Addins.Setup.DependencyCollection"); + throw CreateReadOnlyCollectionException ("Mono.Addins.Description.DependencyCollection"); ob.@Dependencies.Add (ReadObject_NativeReference (false, true)); - n24++; + n31++; } else if (Reader.LocalName == "AddinDependency" && Reader.NamespaceURI == "") { if (((object)ob.@Dependencies) == null) - throw CreateReadOnlyCollectionException ("Mono.Addins.Setup.DependencyCollection"); + throw CreateReadOnlyCollectionException ("Mono.Addins.Description.DependencyCollection"); ob.@Dependencies.Add (ReadObject_AddinReference (false, true)); - n24++; + n31++; } else UnknownNode (null); } @@ -346,43 +334,50 @@ } ReadEndElement(); } - b22 = true; + b27 = true; } - else if (Reader.LocalName == "Name" && Reader.NamespaceURI == "" && !b14) { - b14 = true; - ob.@Name = Reader.ReadElementString (); + else if (Reader.LocalName == "Name" && Reader.NamespaceURI == "" && !b19) { + b19 = true; + string s32 = Reader.ReadElementString (); + ob.@Name = s32; } - else if (Reader.LocalName == "BaseVersion" && Reader.NamespaceURI == "" && !b16) { - b16 = true; - ob.@BaseVersion = Reader.ReadElementString (); + else if (Reader.LocalName == "BaseVersion" && Reader.NamespaceURI == "" && !b21) { + b21 = true; + string s33 = Reader.ReadElementString (); + ob.@BaseVersion = s33; } - else if (Reader.LocalName == "Id" && Reader.NamespaceURI == "" && !b12) { - b12 = true; - ob.@LocalId = Reader.ReadElementString (); + else if (Reader.LocalName == "Id" && Reader.NamespaceURI == "" && !b17) { + b17 = true; + string s34 = Reader.ReadElementString (); + ob.@LocalId = s34; } - else if (Reader.LocalName == "Url" && Reader.NamespaceURI == "" && !b19) { - b19 = true; - ob.@Url = Reader.ReadElementString (); + else if (Reader.LocalName == "Url" && Reader.NamespaceURI == "" && !b24) { + b24 = true; + string s35 = Reader.ReadElementString (); + ob.@Url = s35; } - else if (Reader.LocalName == "Copyright" && Reader.NamespaceURI == "" && !b18) { - b18 = true; - ob.@Copyright = Reader.ReadElementString (); + else if (Reader.LocalName == "Copyright" && Reader.NamespaceURI == "" && !b23) { + b23 = true; + string s36 = Reader.ReadElementString (); + ob.@Copyright = s36; } - else if (Reader.LocalName == "Description" && Reader.NamespaceURI == "" && !b20) { - b20 = true; - ob.@Description = Reader.ReadElementString (); + else if (Reader.LocalName == "Description" && Reader.NamespaceURI == "" && !b25) { + b25 = true; + string s37 = Reader.ReadElementString (); + ob.@Description = s37; } - else if (Reader.LocalName == "Author" && Reader.NamespaceURI == "" && !b17) { - b17 = true; - ob.@Author = Reader.ReadElementString (); + else if (Reader.LocalName == "Author" && Reader.NamespaceURI == "" && !b22) { + b22 = true; + string s38 = Reader.ReadElementString (); + ob.@Author = s38; } - else if (Reader.LocalName == "OptionalDependencies" && Reader.NamespaceURI == "" && !b23) { + else if (Reader.LocalName == "OptionalDependencies" && Reader.NamespaceURI == "" && !b28) { if (((object)ob.@OptionalDependencies) == null) - throw CreateReadOnlyCollectionException ("Mono.Addins.Setup.DependencyCollection"); + throw CreateReadOnlyCollectionException ("Mono.Addins.Description.DependencyCollection"); if (Reader.IsEmptyElement) { Reader.Skip(); } else { - int n25 = 0; + int n39 = 0; Reader.ReadStartElement(); Reader.MoveToContent(); @@ -392,21 +387,21 @@ { if (Reader.LocalName == "AssemblyDependency" && Reader.NamespaceURI == "") { if (((object)ob.@OptionalDependencies) == null) - throw CreateReadOnlyCollectionException ("Mono.Addins.Setup.DependencyCollection"); + throw CreateReadOnlyCollectionException ("Mono.Addins.Description.DependencyCollection"); ob.@OptionalDependencies.Add (ReadObject_AssemblyDependency (false, true)); - n25++; + n39++; } else if (Reader.LocalName == "NativeDependency" && Reader.NamespaceURI == "") { if (((object)ob.@OptionalDependencies) == null) - throw CreateReadOnlyCollectionException ("Mono.Addins.Setup.DependencyCollection"); + throw CreateReadOnlyCollectionException ("Mono.Addins.Description.DependencyCollection"); ob.@OptionalDependencies.Add (ReadObject_NativeReference (false, true)); - n25++; + n39++; } else if (Reader.LocalName == "AddinDependency" && Reader.NamespaceURI == "") { if (((object)ob.@OptionalDependencies) == null) - throw CreateReadOnlyCollectionException ("Mono.Addins.Setup.DependencyCollection"); + throw CreateReadOnlyCollectionException ("Mono.Addins.Description.DependencyCollection"); ob.@OptionalDependencies.Add (ReadObject_AddinReference (false, true)); - n25++; + n39++; } else UnknownNode (null); } @@ -416,15 +411,47 @@ } ReadEndElement(); } - b23 = true; + b28 = true; } - else if (Reader.LocalName == "Namespace" && Reader.NamespaceURI == "" && !b13) { - b13 = true; - ob.@Namespace = Reader.ReadElementString (); + else if (Reader.LocalName == "Properties" && Reader.NamespaceURI == "" && !b29) { + if (((object)ob.@Properties) == null) + throw CreateReadOnlyCollectionException ("Mono.Addins.Setup.AddinPropertyCollectionImpl"); + if (Reader.IsEmptyElement) { + Reader.Skip(); + } else { + int n40 = 0; + Reader.ReadStartElement(); + Reader.MoveToContent(); + + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) + { + if (Reader.NodeType == System.Xml.XmlNodeType.Element) + { + if (Reader.LocalName == "Property" && Reader.NamespaceURI == "") { + if (((object)ob.@Properties) == null) + throw CreateReadOnlyCollectionException ("Mono.Addins.Setup.AddinPropertyCollectionImpl"); + ob.@Properties.Add (ReadObject_AddinProperty (false, true)); + n40++; + } + else UnknownNode (null); + } + else UnknownNode (null); + + Reader.MoveToContent(); + } + ReadEndElement(); + } + b29 = true; } - else if (Reader.LocalName == "Category" && Reader.NamespaceURI == "" && !b21) { - b21 = true; - ob.@Category = Reader.ReadElementString (); + else if (Reader.LocalName == "Namespace" && Reader.NamespaceURI == "" && !b18) { + b18 = true; + string s41 = Reader.ReadElementString (); + ob.@Namespace = s41; + } + else if (Reader.LocalName == "Category" && Reader.NamespaceURI == "" && !b26) { + b26 = true; + string s42 = Reader.ReadElementString (); + ob.@Category = s42; } else { UnknownNode (ob); @@ -455,7 +482,7 @@ throw CreateUnknownTypeException(t); } - ob = new Mono.Addins.Description.AssemblyDependency (); + ob = (Mono.Addins.Description.AssemblyDependency) Activator.CreateInstance(typeof(Mono.Addins.Description.AssemblyDependency), true); Reader.MoveToElement(); @@ -468,6 +495,7 @@ } } + Reader.MoveToElement (); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip (); @@ -477,19 +505,21 @@ Reader.ReadStartElement(); Reader.MoveToContent(); - bool b26=false, b27=false; + bool b43=false, b44=false; while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) { if (Reader.NodeType == System.Xml.XmlNodeType.Element) { - if (Reader.LocalName == "Package" && Reader.NamespaceURI == "" && !b27) { - b27 = true; - ob.@Package = Reader.ReadElementString (); - } - else if (Reader.LocalName == "FullName" && Reader.NamespaceURI == "" && !b26) { - b26 = true; - ob.@FullName = Reader.ReadElementString (); + if (Reader.LocalName == "Package" && Reader.NamespaceURI == "" && !b44) { + b44 = true; + string s45 = Reader.ReadElementString (); + ob.@Package = s45; + } + else if (Reader.LocalName == "FullName" && Reader.NamespaceURI == "" && !b43) { + b43 = true; + string s46 = Reader.ReadElementString (); + ob.@FullName = s46; } else { UnknownNode (ob); @@ -520,7 +550,7 @@ throw CreateUnknownTypeException(t); } - ob = new Mono.Addins.Description.NativeDependency (); + ob = (Mono.Addins.Description.NativeDependency) Activator.CreateInstance(typeof(Mono.Addins.Description.NativeDependency), true); Reader.MoveToElement(); @@ -533,6 +563,7 @@ } } + Reader.MoveToElement (); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip (); @@ -573,7 +604,7 @@ throw CreateUnknownTypeException(t); } - ob = new Mono.Addins.Description.AddinDependency (); + ob = (Mono.Addins.Description.AddinDependency) Activator.CreateInstance(typeof(Mono.Addins.Description.AddinDependency), true); Reader.MoveToElement(); @@ -586,6 +617,7 @@ } } + Reader.MoveToElement (); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip (); @@ -595,19 +627,21 @@ Reader.ReadStartElement(); Reader.MoveToContent(); - bool b28=false, b29=false; + bool b47=false, b48=false; while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) { if (Reader.NodeType == System.Xml.XmlNodeType.Element) { - if (Reader.LocalName == "Version" && Reader.NamespaceURI == "" && !b29) { - b29 = true; - ob.@Version = Reader.ReadElementString (); - } - else if (Reader.LocalName == "AddinId" && Reader.NamespaceURI == "" && !b28) { - b28 = true; - ob.@AddinId = Reader.ReadElementString (); + if (Reader.LocalName == "Version" && Reader.NamespaceURI == "" && !b48) { + b48 = true; + string s49 = Reader.ReadElementString (); + ob.@Version = s49; + } + else if (Reader.LocalName == "AddinId" && Reader.NamespaceURI == "" && !b47) { + b47 = true; + string s50 = Reader.ReadElementString (); + ob.@AddinId = s50; } else { UnknownNode (ob); @@ -624,6 +658,71 @@ return ob; } + public Mono.Addins.Description.AddinProperty ReadObject_AddinProperty (bool isNullable, bool checkType) + { + Mono.Addins.Description.AddinProperty ob = null; + if (isNullable && ReadNull()) return null; + + if (checkType) + { + System.Xml.XmlQualifiedName t = GetXsiType(); + if (t == null) + { } + else if (t.Name != "AddinProperty" || t.Namespace != "") + throw CreateUnknownTypeException(t); + } + + ob = (Mono.Addins.Description.AddinProperty) Activator.CreateInstance(typeof(Mono.Addins.Description.AddinProperty), true); + + Reader.MoveToElement(); + + while (Reader.MoveToNextAttribute()) + { + if (Reader.LocalName == "name" && Reader.NamespaceURI == "") { + ob.@Name = Reader.Value; + } + else if (Reader.LocalName == "locale" && Reader.NamespaceURI == "") { + ob.@Locale = Reader.Value; + } + else if (IsXmlnsAttribute (Reader.Name)) { + } + else { + UnknownNode (ob); + } + } + + Reader.MoveToElement (); + Reader.MoveToElement(); + if (Reader.IsEmptyElement) { + Reader.Skip (); + return ob; + } + + Reader.ReadStartElement(); + Reader.MoveToContent(); + + + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) + { + if (Reader.NodeType == System.Xml.XmlNodeType.Element) + { + UnknownNode (ob); + } + else if (Reader.NodeType == System.Xml.XmlNodeType.Text || Reader.NodeType == System.Xml.XmlNodeType.CDATA) + { + ob.@Value = ReadString (ob.@Value); + } + else + UnknownNode(ob); + + Reader.MoveToContent(); + } + + ReadEndElement(); + + return ob; + } + protected override void InitCallbacks () { } @@ -637,6 +736,11 @@ internal class RepositoryWriter : XmlSerializationWriter { const string xmlNamespace = "http://www.w3.org/2000/xmlns/"; + static readonly System.Reflection.MethodInfo toBinHexStringMethod = typeof (XmlConvert).GetMethod ("ToBinHexString", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic, null, new Type [] {typeof (byte [])}, null); + static string ToBinHexString (byte [] input) + { + return input == null ? null : (string) toBinHexStringMethod.Invoke (null, new object [] {input}); + } public void WriteRoot_Repository (object o) { WriteStartDocument (); @@ -670,13 +774,13 @@ WriteElementString ("Name", "", ob.@Name); WriteElementString ("Url", "", ob.@Url); if (ob.@Repositories != null) { - for (int n30 = 0; n30 < ob.@Repositories.Count; n30++) { - WriteObject_ReferenceRepositoryEntry (((Mono.Addins.Setup.ReferenceRepositoryEntry) ob.@Repositories[n30]), "Repository", "", false, false, true); + for (int n51 = 0; n51 < ob.@Repositories.Count; n51++) { + WriteObject_ReferenceRepositoryEntry (((Mono.Addins.Setup.ReferenceRepositoryEntry) ob.@Repositories[n51]), "Repository", "", false, false, true); } } if (ob.@Addins != null) { - for (int n31 = 0; n31 < ob.@Addins.Count; n31++) { - WriteObject_AddinRepositoryEntry (((Mono.Addins.Setup.PackageRepositoryEntry) ob.@Addins[n31]), "Addin", "", false, false, true); + for (int n52 = 0; n52 < ob.@Addins.Count; n52++) { + WriteObject_PackageRepositoryEntry (((Mono.Addins.Setup.PackageRepositoryEntry) ob.@Addins[n52]), "Addin", "", false, false, true); } } if (writeWrappingElem) WriteEndElement (ob); @@ -705,11 +809,11 @@ if (needType) WriteXsiType("ReferenceRepositoryEntry", ""); WriteElementString ("Url", "", ob.@Url); - WriteElementString ("LastModified", "", ob.@LastModified.ToString("yyyy-MM-ddTHH:mm:ss.fffffffzzz", CultureInfo.InvariantCulture)); + WriteElementString ("LastModified", "", XmlConvert.ToString (ob.@LastModified, XmlDateTimeSerializationMode.RoundtripKind)); if (writeWrappingElem) WriteEndElement (ob); } - void WriteObject_AddinRepositoryEntry (Mono.Addins.Setup.PackageRepositoryEntry ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem) + void WriteObject_PackageRepositoryEntry (Mono.Addins.Setup.PackageRepositoryEntry ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem) { if (((object)ob) == null) { @@ -770,38 +874,45 @@ WriteElementString ("Category", "", ob.@Category); if (ob.@Dependencies != null) { WriteStartElement ("Dependencies", "", ob.@Dependencies); - for (int n32 = 0; n32 < ob.@Dependencies.Count; n32++) { - if (((object)ob.@Dependencies[n32]) == null) { } - else if (ob.@Dependencies[n32].GetType() == typeof(Mono.Addins.Description.AssemblyDependency)) { - WriteObject_AssemblyDependency (((Mono.Addins.Description.AssemblyDependency) ob.@Dependencies[n32]), "AssemblyDependency", "", false, false, true); + for (int n53 = 0; n53 < ob.@Dependencies.Count; n53++) { + if (((object)ob.@Dependencies[n53]) == null) { } + else if (ob.@Dependencies[n53].GetType() == typeof(Mono.Addins.Description.AssemblyDependency)) { + WriteObject_AssemblyDependency (((Mono.Addins.Description.AssemblyDependency) ob.@Dependencies[n53]), "AssemblyDependency", "", false, false, true); } - else if (ob.@Dependencies[n32].GetType() == typeof(Mono.Addins.Description.NativeDependency)) { - WriteObject_NativeReference (((Mono.Addins.Description.NativeDependency) ob.@Dependencies[n32]), "NativeDependency", "", false, false, true); + else if (ob.@Dependencies[n53].GetType() == typeof(Mono.Addins.Description.NativeDependency)) { + WriteObject_NativeReference (((Mono.Addins.Description.NativeDependency) ob.@Dependencies[n53]), "NativeDependency", "", false, false, true); } - else if (ob.@Dependencies[n32].GetType() == typeof(Mono.Addins.Description.AddinDependency)) { - WriteObject_AddinReference (((Mono.Addins.Description.AddinDependency) ob.@Dependencies[n32]), "AddinDependency", "", false, false, true); + else if (ob.@Dependencies[n53].GetType() == typeof(Mono.Addins.Description.AddinDependency)) { + WriteObject_AddinReference (((Mono.Addins.Description.AddinDependency) ob.@Dependencies[n53]), "AddinDependency", "", false, false, true); } - else throw CreateUnknownTypeException (ob.@Dependencies[n32]); + else throw CreateUnknownTypeException (ob.@Dependencies[n53]); } WriteEndElement (ob.@Dependencies); } if (ob.@OptionalDependencies != null) { WriteStartElement ("OptionalDependencies", "", ob.@OptionalDependencies); - for (int n33 = 0; n33 < ob.@OptionalDependencies.Count; n33++) { - if (((object)ob.@OptionalDependencies[n33]) == null) { } - else if (ob.@OptionalDependencies[n33].GetType() == typeof(Mono.Addins.Description.AssemblyDependency)) { - WriteObject_AssemblyDependency (((Mono.Addins.Description.AssemblyDependency) ob.@OptionalDependencies[n33]), "AssemblyDependency", "", false, false, true); + for (int n54 = 0; n54 < ob.@OptionalDependencies.Count; n54++) { + if (((object)ob.@OptionalDependencies[n54]) == null) { } + else if (ob.@OptionalDependencies[n54].GetType() == typeof(Mono.Addins.Description.AssemblyDependency)) { + WriteObject_AssemblyDependency (((Mono.Addins.Description.AssemblyDependency) ob.@OptionalDependencies[n54]), "AssemblyDependency", "", false, false, true); } - else if (ob.@OptionalDependencies[n33].GetType() == typeof(Mono.Addins.Description.NativeDependency)) { - WriteObject_NativeReference (((Mono.Addins.Description.NativeDependency) ob.@OptionalDependencies[n33]), "NativeDependency", "", false, false, true); + else if (ob.@OptionalDependencies[n54].GetType() == typeof(Mono.Addins.Description.NativeDependency)) { + WriteObject_NativeReference (((Mono.Addins.Description.NativeDependency) ob.@OptionalDependencies[n54]), "NativeDependency", "", false, false, true); } - else if (ob.@OptionalDependencies[n33].GetType() == typeof(Mono.Addins.Description.AddinDependency)) { - WriteObject_AddinReference (((Mono.Addins.Description.AddinDependency) ob.@OptionalDependencies[n33]), "AddinDependency", "", false, false, true); + else if (ob.@OptionalDependencies[n54].GetType() == typeof(Mono.Addins.Description.AddinDependency)) { + WriteObject_AddinReference (((Mono.Addins.Description.AddinDependency) ob.@OptionalDependencies[n54]), "AddinDependency", "", false, false, true); } - else throw CreateUnknownTypeException (ob.@OptionalDependencies[n33]); + else throw CreateUnknownTypeException (ob.@OptionalDependencies[n54]); } WriteEndElement (ob.@OptionalDependencies); } + if (ob.@Properties != null) { + WriteStartElement ("Properties", "", ob.@Properties); + for (int n55 = 0; n55 < ob.@Properties.Count; n55++) { + WriteObject_AddinProperty (ob.@Properties[n55], "Property", "", false, false, true); + } + WriteEndElement (ob.@Properties); + } if (writeWrappingElem) WriteEndElement (ob); } @@ -884,11 +995,39 @@ if (writeWrappingElem) WriteEndElement (ob); } + void WriteObject_AddinProperty (Mono.Addins.Description.AddinProperty ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem) + { + if (((object)ob) == null) + { + if (isNullable) + WriteNullTagLiteral(element, namesp); + return; + } + + System.Type type = ob.GetType (); + if (type == typeof(Mono.Addins.Description.AddinProperty)) + { } + else { + throw CreateUnknownTypeException (ob); + } + + if (writeWrappingElem) { + WriteStartElement (element, namesp, ob); + } + + if (needType) WriteXsiType("AddinProperty", ""); + + WriteAttribute ("name", "", ob.@Name); + WriteAttribute ("locale", "", ob.@Locale); + + WriteValue (ob.@Value); + if (writeWrappingElem) WriteEndElement (ob); + } + protected override void InitCallbacks () { } } - } diff -Nru mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/RepositoryRecord.cs mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/RepositoryRecord.cs --- mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/RepositoryRecord.cs 2008-11-06 19:52:10.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/RepositoryRecord.cs 2011-04-13 09:00:29.000000000 +0000 @@ -42,6 +42,7 @@ string file; string url; string name; + bool enabled = true; DateTime lastModified = new DateTime (1900,1,1); [XmlAttribute ("id")] @@ -60,6 +61,12 @@ set { file = value; } } + public string CachedFilesDir { + get { + return Path.Combine (Path.GetDirectoryName (File), Path.GetFileNameWithoutExtension (File) + "_files"); + } + } + public string Url { get { return url; } set { url = value; } @@ -79,15 +86,26 @@ set { lastModified = value; } } + [System.ComponentModel.DefaultValue (true)] + public bool Enabled { + get { return this.enabled; } + set { enabled = value; } + } + public Repository GetCachedRepository () { - return (Repository) AddinStore.ReadObject (File, typeof(Repository)); + Repository repo = (Repository) AddinStore.ReadObject (File, typeof(Repository)); + if (repo != null) + repo.CachedFilesDir = CachedFilesDir; + return repo; } public void ClearCachedRepository () { if (System.IO.File.Exists (File)) System.IO.File.Delete (File); + if (Directory.Exists (CachedFilesDir)) + Directory.Delete (CachedFilesDir, true); } internal void UpdateCachedRepository (Repository newRep) @@ -98,29 +116,59 @@ AddinStore.WriteObject (File, newRep); if (name == null) name = newRep.Name; + newRep.CachedFilesDir = CachedFilesDir; } } + /// + /// An on-line add-in repository + /// public interface AddinRepository { + /// + /// Path to the cached add-in repository file + /// string File { get; } + /// + /// Url of the repository + /// string Url { get; } + /// + /// Do not use. Use Title instead. + /// string Name { get; + set; } + /// + /// Title of the repository + /// string Title { get; } - + + /// + /// Last change timestamp + /// DateTime LastModified { get; } + + /// + /// Gets a value indicating whether this is enabled. + /// + /// + /// true if enabled; otherwise, false. + /// + bool Enabled { + get; + } } } diff -Nru mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/RepositoryRegistry.cs mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/RepositoryRegistry.cs --- mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/RepositoryRegistry.cs 2008-11-06 19:52:10.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/RepositoryRegistry.cs 2011-04-13 09:00:29.000000000 +0000 @@ -28,12 +28,20 @@ using System; +using System.Linq; using System.IO; using System.Collections; using Mono.Addins.Setup.ProgressMonitoring; +using System.Collections.Generic; namespace Mono.Addins.Setup { + /// + /// A registry of on-line repositories + /// + /// + /// This class can be used to manage on-line repository subscriptions. + /// public class RepositoryRegistry { ArrayList repoList; @@ -44,15 +52,52 @@ this.service = service; } + /// + /// Subscribes to an on-line repository + /// + /// + /// Progress monitor where to show progress status and log + /// + /// + /// URL of the repository + /// + /// + /// A repository reference + /// + /// + /// The repository index is not downloaded by default. It can be downloaded + /// by calling UpdateRepository. + /// public AddinRepository RegisterRepository (IProgressStatus monitor, string url) { return RegisterRepository (monitor, url, false); } + /// + /// Subscribes to an on-line repository + /// + /// + /// Progress monitor where to show progress status and log + /// + /// + /// URL of the repository + /// + /// + /// When set to True, the repository index will be downloaded. + /// + /// + /// A repository reference + /// public AddinRepository RegisterRepository (IProgressStatus monitor, string url, bool updateNow) { - if (!url.EndsWith (".mrep")) - url = url + "/main.mrep"; + if (string.IsNullOrEmpty (url)) + throw new ArgumentException ("Emtpy url"); + + if (!url.EndsWith (".mrep")) { + if (url [url.Length - 1] != '/') + url += "/"; + url = url + "main.mrep"; + } RepositoryRecord rr = FindRepositoryRecord (url); if (rr != null) @@ -118,11 +163,17 @@ return null; } + /// + /// Removes an on-line repository subscription. + /// + /// + /// URL of the repository. + /// public void RemoveRepository (string url) { RepositoryRecord rep = FindRepositoryRecord (url); if (rep == null) - throw new InstallException ("The repository at url '" + url + "' is not registered"); + return; // Nothing to do foreach (RepositoryRecord rr in service.Configuration.Repositories) { if (rr == rep) continue; @@ -130,6 +181,8 @@ if (newRep == null) continue; foreach (ReferenceRepositoryEntry re in newRep.Repositories) { if (re.Url == url) { + // The repository can't be removed because there is another + // repository depending on it. Just mark it as a reference. rep.IsReference = true; return; } @@ -151,6 +204,42 @@ repoList = null; } + /// + /// Enables or disables a repository + /// + /// + /// URL of the repository + /// + /// + /// 'true' if the repository has to be enabled. + /// + /// + /// Disabled repositories are ignored when calling UpdateAllRepositories. + /// + public void SetRepositoryEnabled (string url, bool enabled) + { + RepositoryRecord rep = FindRepositoryRecord (url); + if (rep == null) + return; // Nothing to do + rep.Enabled = enabled; + Repository crep = rep.GetCachedRepository (); + if (crep != null) { + foreach (RepositoryEntry re in crep.Repositories) + SetRepositoryEnabled (new Uri (new Uri (url), re.Url).ToString (), enabled); + } + + service.SaveConfiguration (); + } + + /// + /// Checks if a repository is already subscribed. + /// + /// + /// URL of the repository + /// + /// + /// True if the repository is already subscribed. + /// public bool ContainsRepository (string url) { return FindRepositoryRecord (url) != null; @@ -170,17 +259,37 @@ } } + /// + /// Gets a list of subscribed repositories + /// + /// + /// A list of repositories. + /// public AddinRepository[] GetRepositories () { return (AddinRepository[]) RepositoryList.ToArray (typeof(AddinRepository)); } - + /// + /// Updates the add-in index of all subscribed repositories. + /// + /// + /// Progress monitor where to show progress status and log + /// public void UpdateAllRepositories (IProgressStatus monitor) { UpdateRepository (monitor, (string)null); } + /// + /// Updates the add-in index of the provided repository + /// + /// + /// Progress monitor where to show progress status and log + /// + /// + /// URL of the repository + /// public void UpdateRepository (IProgressStatus statusMonitor, string url) { repoList = null; @@ -192,7 +301,7 @@ int num = service.Configuration.Repositories.Count; for (int n=0; n + /// Gets a list of available add-in updates. + /// + /// + /// A list of add-in references. + /// + /// + /// The list is generated by looking at the add-ins currently installed and checking if there is any + /// add-in with a newer version number in any of the subscribed repositories. This method uses cached + /// information from on-line repositories. Make sure you call UpdateRepository or UpdateAllRepositories + /// before using this method to ensure that the latest information is available. + /// public AddinRepositoryEntry[] GetAvailableUpdates () { - return GetAvailableAddin (null, null, null, true); + return GetAvailableAddin (null, null, null, true, RepositorySearchFlags.None); } - + + /// + /// Gets a list of available add-in updates. + /// + /// + /// Search flags + /// + /// + /// A list of add-in references. + /// + /// + /// The list is generated by looking at the add-ins currently installed and checking if there is any + /// add-in with a newer version number in any of the subscribed repositories. This method uses cached + /// information from on-line repositories. Make sure you call UpdateRepository or UpdateAllRepositories + /// before using this method to ensure that the latest information is available. + /// + public AddinRepositoryEntry[] GetAvailableUpdates (RepositorySearchFlags flags) + { + return GetAvailableAddin (null, null, null, true, flags); + } + + /// + /// Gets a list of available add-in updates in a specific repository. + /// + /// + /// The repository URL + /// + /// + /// A list of add-in references. + /// + /// + /// The list is generated by looking at the add-ins currently installed and checking if there is any + /// add-in with a newer version number in the provided repository. This method uses cached + /// information from on-line repositories. Make sure you call UpdateRepository or UpdateAllRepositories + /// before using this method to ensure that the latest information is available. + /// public AddinRepositoryEntry[] GetAvailableUpdates (string repositoryUrl) { - return GetAvailableAddin (repositoryUrl, null, null, true); + return GetAvailableAddin (repositoryUrl, null, null, true, RepositorySearchFlags.None); } +#pragma warning disable 1591 + [Obsolete ("Use GetAvailableAddinUpdates (id) instead")] public AddinRepositoryEntry[] GetAvailableUpdates (string id, string version) { - return GetAvailableAddin (null, id, version, true); + return GetAvailableAddin (null, id, version, true, RepositorySearchFlags.None); } + [Obsolete ("Use GetAvailableAddinUpdates (repositoryUrl, id) instead")] public AddinRepositoryEntry[] GetAvailableUpdates (string repositoryUrl, string id, string version) { - return GetAvailableAddin (repositoryUrl, id, version, true); + return GetAvailableAddin (repositoryUrl, id, version, true, RepositorySearchFlags.None); } +#pragma warning restore 1591 + /// + /// Gets a list of available updates for an add-in. + /// + /// + /// Identifier of the add-in. + /// + /// + /// List of updates for the specified add-in. + /// + /// + /// The list is generated by checking if there is any + /// add-in with a newer version number in any of the subscribed repositories. This method uses cached + /// information from on-line repositories. Make sure you call UpdateRepository or UpdateAllRepositories + /// before using this method to ensure that the latest information is available. + /// + public AddinRepositoryEntry[] GetAvailableAddinUpdates (string id) + { + return GetAvailableAddin (null, id, null, true, RepositorySearchFlags.None); + } + + /// + /// Gets a list of available updates for an add-in. + /// + /// + /// Identifier of the add-in. + /// + /// + /// Search flags. + /// + /// + /// List of updates for the specified add-in. + /// + /// + /// The list is generated by checking if there is any + /// add-in with a newer version number in any of the subscribed repositories. This method uses cached + /// information from on-line repositories. Make sure you call UpdateRepository or UpdateAllRepositories + /// before using this method to ensure that the latest information is available. + /// + public AddinRepositoryEntry[] GetAvailableAddinUpdates (string id, RepositorySearchFlags flags) + { + return GetAvailableAddin (null, id, null, true, flags); + } + + /// + /// Gets a list of available updates for an add-in in a specific repository + /// + /// + /// Identifier of the add-in. + /// + /// + /// Identifier of the add-in. + /// + /// + /// List of updates for the specified add-in. + /// + /// + /// The list is generated by checking if there is any + /// add-in with a newer version number in the provided repository. This method uses cached + /// information from on-line repositories. Make sure you call UpdateRepository or UpdateAllRepositories + /// before using this method to ensure that the latest information is available. + /// + public AddinRepositoryEntry[] GetAvailableAddinUpdates (string repositoryUrl, string id) + { + return GetAvailableAddin (repositoryUrl, id, null, true, RepositorySearchFlags.None); + } + + /// + /// Gets a list of available updates for an add-in in a specific repository + /// + /// + /// Identifier of the add-in. + /// + /// + /// Identifier of the add-in. + /// + /// + /// Search flags. + /// + /// + /// List of updates for the specified add-in. + /// + /// + /// The list is generated by checking if there is any + /// add-in with a newer version number in the provided repository. This method uses cached + /// information from on-line repositories. Make sure you call UpdateRepository or UpdateAllRepositories + /// before using this method to ensure that the latest information is available. + /// + public AddinRepositoryEntry[] GetAvailableAddinUpdates (string repositoryUrl, string id, RepositorySearchFlags flags) + { + return GetAvailableAddin (repositoryUrl, id, null, true, flags); + } + + /// + /// Gets a list of all available add-ins + /// + /// + /// A list of add-ins + /// + /// + /// This method uses cached + /// information from on-line repositories. Make sure you call UpdateRepository or UpdateAllRepositories + /// before using this method to ensure that the latest information is available. + /// public AddinRepositoryEntry[] GetAvailableAddins () { - return GetAvailableAddin (null, null, null, false); + return GetAvailableAddin (null, null, null, false, RepositorySearchFlags.None); } + /// + /// Gets a list of all available add-ins + /// + /// + /// The available addins. + /// + /// + /// Search flags. + /// + /// + /// This method uses cached + /// information from on-line repositories. Make sure you call UpdateRepository or UpdateAllRepositories + /// before using this method to ensure that the latest information is available. + /// + public AddinRepositoryEntry[] GetAvailableAddins (RepositorySearchFlags flags) + { + return GetAvailableAddin (null, null, null, false, flags); + } + + /// + /// Gets a list of all available add-ins in a repository + /// + /// + /// A repository URL + /// + /// + /// A list of add-ins + /// + /// + /// This method uses cached + /// information from on-line repositories. Make sure you call UpdateRepository or UpdateAllRepositories + /// before using this method to ensure that the latest information is available. + /// public AddinRepositoryEntry[] GetAvailableAddins (string repositoryUrl) { return GetAvailableAddin (repositoryUrl, null, null); } + /// + /// Gets a list of all available add-ins in a repository + /// + /// + /// A repository URL + /// + /// + /// Search flags. + /// + /// + /// A list of add-ins + /// + /// + /// This method uses cached + /// information from on-line repositories. Make sure you call UpdateRepository or UpdateAllRepositories + /// before using this method to ensure that the latest information is available. + /// + public AddinRepositoryEntry[] GetAvailableAddins (string repositoryUrl, RepositorySearchFlags flags) + { + return GetAvailableAddin (repositoryUrl, null, null, false, flags); + } + + /// + /// Checks if an add-in is available to be installed + /// + /// + /// Identifier of the add-in + /// + /// + /// Version of the add-in (optional, it can be null) + /// + /// + /// A list of add-ins + /// + /// + /// List of references to add-ins available in on-line repositories. This method uses cached + /// information from on-line repositories. Make sure you call UpdateRepository or UpdateAllRepositories + /// before using this method to ensure that the latest information is available. + /// public AddinRepositoryEntry[] GetAvailableAddin (string id, string version) { return GetAvailableAddin (null, id, version); } + /// + /// Checks if an add-in is available to be installed from a repository + /// + /// + /// A repository URL + /// + /// + /// Identifier of the add-in + /// + /// + /// Version of the add-in (optional, it can be null) + /// + /// + /// A list of add-ins + /// + /// + /// List of references to add-ins available in the repository. This method uses cached + /// information from on-line repositories. Make sure you call UpdateRepository or UpdateAllRepositories + /// before using this method to ensure that the latest information is available. + /// public AddinRepositoryEntry[] GetAvailableAddin (string repositoryUrl, string id, string version) { - return GetAvailableAddin (repositoryUrl, id, version, false); + return GetAvailableAddin (repositoryUrl, id, version, false, RepositorySearchFlags.None); } - PackageRepositoryEntry[] GetAvailableAddin (string repositoryUrl, string id, string version, bool updates) + PackageRepositoryEntry[] GetAvailableAddin (string repositoryUrl, string id, string version, bool updates, RepositorySearchFlags flags) { - ArrayList list = new ArrayList (); + List list = new List (); IEnumerable ee; if (repositoryUrl != null) { @@ -292,12 +650,14 @@ ee = service.Configuration.Repositories; foreach (RepositoryRecord rr in ee) { + if (!rr.Enabled) + continue; Repository rep = rr.GetCachedRepository(); if (rep == null) continue; foreach (PackageRepositoryEntry addin in rep.Addins) { if ((id == null || Addin.GetIdName (addin.Addin.Id) == id) && (version == null || addin.Addin.Version == version)) { if (updates) { - Addin ainfo = service.Registry.GetAddin (addin.Addin.Id); + Addin ainfo = service.Registry.GetAddin (Addin.GetIdName (addin.Addin.Id)); if (ainfo == null || Addin.CompareVersions (ainfo.Version, addin.Addin.Version) <= 0) continue; } @@ -305,9 +665,32 @@ } } } + + if ((flags & RepositorySearchFlags.LatestVersionsOnly) != 0) + FilterOldVersions (list); + // Old versions are returned first list.Sort (); - return (PackageRepositoryEntry[]) list.ToArray (typeof(PackageRepositoryEntry)); + return list.ToArray (); + } + + void FilterOldVersions (List addins) + { + Dictionary versions = new Dictionary (); + foreach (PackageRepositoryEntry a in addins) { + string last; + string id, version; + Addin.GetIdParts (a.Addin.Id, out id, out version); + if (!versions.TryGetValue (id, out last) || Addin.CompareVersions (last, version) > 0) + versions [id] = version; + } + for (int n=0; n + /// No special search options + /// + None, + + /// + /// Only the latest version of every add-in is included in the search + /// + LatestVersionsOnly = 1, + } } diff -Nru mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/SetupService.cs mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/SetupService.cs --- mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/SetupService.cs 2008-11-06 19:52:10.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/SetupService.cs 2011-04-13 09:00:29.000000000 +0000 @@ -31,12 +31,24 @@ using System.Xml; using System.IO; using System.Collections; +using System.Collections.Generic; using ICSharpCode.SharpZipLib.Zip; using Mono.Addins.Description; using Mono.Addins.Setup.ProgressMonitoring; +using Microsoft.Win32; +using System.Diagnostics; +using Mono.PkgConfig; namespace Mono.Addins.Setup { + /// + /// Provides tools for managing add-ins + /// + /// + /// This class can be used to manage the add-ins of an application. It allows installing and uninstalling + /// add-ins, taking into account add-in dependencies. It provides methods for installing add-ins from on-line + /// repositories and tools for generating those repositories. + /// public class SetupService { RepositoryRegistry repositories; @@ -44,9 +56,17 @@ string installDirectory; AddinStore store; AddinSystemConfiguration config; + const string addinFilesDir = "_addin_files"; AddinRegistry registry; + /// + /// Initializes a new instance + /// + /// + /// If the add-in manager is initialized (AddinManager.Initialize has been called), then this instance + /// will manage the add-in registry of the initialized engine. + /// public SetupService () { if (AddinManager.IsInitialized) @@ -58,6 +78,12 @@ store = new AddinStore (this); } + /// + /// Initializes a new instance + /// + /// + /// Add-in registry to manage + /// public SetupService (AddinRegistry registry) { this.registry = registry; @@ -65,6 +91,9 @@ store = new AddinStore (this); } + /// + /// The add-in registry being managed + /// public AddinRegistry Registry { get { return registry; } } @@ -77,11 +106,19 @@ get { return Path.Combine (registry.RegistryPath, "addins-setup.config"); } } + /// + /// Default add-in namespace of the application (optional). If set, only add-ins that belong to that namespace + /// will be shown in add-in lists. + /// public string ApplicationNamespace { get { return applicationNamespace; } set { applicationNamespace = value; } } + /// + /// Directory where to install add-ins. If not specified, the 'addins' subdirectory of the + /// registry location is used. + /// public string InstallDirectory { get { if (installDirectory != null && installDirectory.Length > 0) @@ -92,6 +129,9 @@ set { installDirectory = value; } } + /// + /// Returns a RepositoryRegistry which can be used to manage on-line repository references + /// public RepositoryRegistry Repositories { get { return repositories; } } @@ -100,58 +140,219 @@ get { return store; } } + /// + /// Resolves add-in dependencies. + /// + /// + /// Progress monitor where to show progress status + /// + /// + /// List of add-ins to check + /// + /// + /// Packages that need to be installed. + /// + /// + /// Packages that need to be uninstalled. + /// + /// + /// Add-in dependencies that could not be resolved. + /// + /// + /// True if all dependencies could be resolved. + /// + /// + /// This method can be used to get a list of all packages that have to be installed in order to install + /// an add-in or set of add-ins. The list of packages to install will include the package that provides the + /// add-in, and all packages that provide the add-in dependencies. In some cases, packages may need to + /// be installed (for example, when an installed add-in needs to be upgraded). + /// public bool ResolveDependencies (IProgressStatus statusMonitor, AddinRepositoryEntry[] addins, out PackageCollection resolved, out PackageCollection toUninstall, out DependencyCollection unresolved) { return store.ResolveDependencies (statusMonitor, addins, out resolved, out toUninstall, out unresolved); } + /// + /// Resolves add-in dependencies. + /// + /// + /// Progress monitor where to show progress status + /// + /// + /// Packages that need to be installed. + /// + /// + /// Packages that need to be uninstalled. + /// + /// + /// Add-in dependencies that could not be resolved. + /// + /// + /// True if all dependencies could be resolved. + /// + /// + /// This method can be used to get a list of all packages that have to be installed in order to satisfy + /// the dependencies of a package or set of packages. The 'packages' argument must have the list of packages + /// to be resolved. When resolving dependencies, if there is any additional package that needs to be installed, + /// it will be added to the same 'packages' collection. In some cases, packages may need to + /// be installed (for example, when an installed add-in needs to be upgraded). Those packages will be added + /// to the 'toUninstall' collection. Packages that could not be resolved are added to the 'unresolved' + /// collection. + /// public bool ResolveDependencies (IProgressStatus statusMonitor, PackageCollection packages, out PackageCollection toUninstall, out DependencyCollection unresolved) { return store.ResolveDependencies (statusMonitor, packages, out toUninstall, out unresolved); } + /// + /// Installs add-in packages + /// + /// + /// Progress monitor where to show progress status + /// + /// + /// Paths to the packages to install + /// + /// + /// True if the installation succeeded + /// public bool Install (IProgressStatus statusMonitor, params string[] files) { return store.Install (statusMonitor, files); } + /// + /// Installs add-in packages from on-line repositories + /// + /// + /// Progress monitor where to show progress status + /// + /// + /// References to the add-ins to be installed + /// + /// + /// True if the installation succeeded + /// public bool Install (IProgressStatus statusMonitor, params AddinRepositoryEntry[] addins) { return store.Install (statusMonitor, addins); } + /// + /// Installs add-in packages + /// + /// + /// Progress monitor where to show progress status + /// + /// + /// Packages to install + /// + /// + /// True if the installation succeeded + /// public bool Install (IProgressStatus statusMonitor, PackageCollection packages) { return store.Install (statusMonitor, packages); } + /// + /// Uninstalls an add-in. + /// + /// + /// Progress monitor where to show progress status + /// + /// + /// Full identifier of the add-in to uninstall. + /// public void Uninstall (IProgressStatus statusMonitor, string id) { store.Uninstall (statusMonitor, id); } + /// + /// Uninstalls a set of add-ins + /// + /// + /// Progress monitor where to show progress status + /// + /// + /// Full identifiers of the add-ins to uninstall. + /// + public void Uninstall (IProgressStatus statusMonitor, IEnumerable ids) + { + store.Uninstall (statusMonitor, ids); + } + + /// + /// Gets information about an add-in + /// + /// + /// The add-in + /// + /// + /// Add-in header data + /// public static AddinHeader GetAddinHeader (Addin addin) { return AddinInfo.ReadFromDescription (addin.Description); } + /// + /// Gets a list of add-ins which depend on an add-in + /// + /// + /// Full identifier of an add-in. + /// + /// + /// When set to True, dependencies will be gathered recursivelly + /// + /// + /// List of dependent add-ins. + /// + /// + /// This methods returns a list of add-ins which have the add-in identified by 'id' as a direct + /// (or indirect if recursive=True) dependency. + /// public Addin[] GetDependentAddins (string id, bool recursive) { return store.GetDependentAddins (id, recursive); } - public void BuildPackage (IProgressStatus statusMonitor, string targetDirectory, params string[] filePaths) - { - foreach (string file in filePaths) - BuildPackageInternal (statusMonitor, targetDirectory, file); + /// + /// Packages an add-in + /// + /// + /// Progress monitor where to show progress status + /// + /// + /// Directory where to generate the package + /// + /// + /// Paths to the add-ins to be packaged. Paths can be either the main assembly of an add-in, or an add-in + /// manifest (.addin or .addin.xml). + /// + /// + /// This method can be used to create a package for an add-in, which can then be pushed to an on-line + /// repository. The package will include the main assembly or manifest of the add-in and any external + /// file declared in the add-in metadata. + /// + public string[] BuildPackage (IProgressStatus statusMonitor, string targetDirectory, params string[] filePaths) + { + List outFiles = new List (); + foreach (string file in filePaths) { + string f = BuildPackageInternal (statusMonitor, targetDirectory, file); + if (f != null) + outFiles.Add (f); + } + return outFiles.ToArray (); } - void BuildPackageInternal (IProgressStatus monitor, string targetDirectory, string filePath) + string BuildPackageInternal (IProgressStatus monitor, string targetDirectory, string filePath) { AddinDescription conf = registry.GetAddinDescription (monitor, filePath); if (conf == null) { monitor.ReportError ("Could not read add-in file: " + filePath, null); - return; + return null; } string basePath = Path.GetDirectoryName (filePath); @@ -201,6 +402,15 @@ list.Add (f); } + foreach (var prop in conf.Properties) { + try { + if (File.Exists (Path.Combine (basePath, prop.Value))) + list.Add (prop.Value); + } catch { + // Ignore errors + } + } + monitor.Log ("Creating package " + Path.GetFileName (outFilePath)); foreach (string file in list) { @@ -216,7 +426,8 @@ } s.Finish(); - s.Close(); + s.Close(); + return outFilePath; } void CleanDescription (XmlElement parent) @@ -225,26 +436,40 @@ foreach (XmlNode nod in parent.ChildNodes) { XmlElement elem = nod as XmlElement; - if (elem == null) + if (elem == null) { + todelete.Add (nod); continue; + } if (elem.LocalName == "Module") CleanDescription (elem); - else if (elem.LocalName != "Dependencies" && elem.LocalName != "Runtime") + else if (elem.LocalName != "Dependencies" && elem.LocalName != "Runtime" && elem.LocalName != "Header") todelete.Add (elem); } - foreach (XmlElement e in todelete) + foreach (XmlNode e in todelete) parent.RemoveChild (e); } + /// + /// Generates an on-line repository + /// + /// + /// Progress monitor where to show progress status + /// + /// + /// Path to the directory that contains the add-ins and that is going to be published + /// + /// + /// This method generates the index files required to publish a directory as an online repository + /// of add-ins. + /// public void BuildRepository (IProgressStatus statusMonitor, string path) { string mainPath = Path.Combine (path, "main.mrep"); ArrayList allAddins = new ArrayList (); Repository rootrep = (Repository) AddinStore.ReadObject (mainPath, typeof(Repository)); - if (rootrep == null) { + if (rootrep == null) rootrep = new Repository (); - } IProgressMonitor monitor = ProgressStatusMonitor.GetProgressMonitor (statusMonitor); BuildRepository (monitor, rootrep, path, "root.mrep", allAddins); @@ -259,52 +484,71 @@ string mainFile = Path.Combine (rootPath, relFilePath); string mainPath = Path.GetDirectoryName (mainFile); + string supportFileDir = Path.Combine (mainPath, addinFilesDir); + + if (File.Exists (mainFile)) + lastModified = File.GetLastWriteTime (mainFile); Repository mainrep = (Repository) AddinStore.ReadObject (mainFile, typeof(Repository)); if (mainrep == null) { mainrep = new Repository (); } + ReferenceRepositoryEntry repEntry = (ReferenceRepositoryEntry) rootrep.FindEntry (relFilePath); + DateTime rootLastModified = repEntry != null ? repEntry.LastModified : DateTime.MinValue; + bool modified = false; monitor.Log.WriteLine ("Checking directory: " + mainPath); foreach (string file in Directory.GetFiles (mainPath, "*.mpack")) { + + DateTime date = File.GetLastWriteTime (file); string fname = Path.GetFileName (file); PackageRepositoryEntry entry = (PackageRepositoryEntry) mainrep.FindEntry (fname); + + if (entry != null && date > rootLastModified) { + mainrep.RemoveEntry (entry); + DeleteSupportFiles (supportFileDir, entry.Addin); + entry = null; + } + if (entry == null) { entry = new PackageRepositoryEntry (); AddinPackage p = (AddinPackage) Package.FromFile (file); entry.Addin = (AddinInfo) p.Addin; entry.Url = fname; + entry.Addin.Properties.SetPropertyValue ("DownloadSize", new FileInfo (file).Length.ToString ()); + ExtractSupportFiles (supportFileDir, file, entry.Addin); mainrep.AddEntry (entry); modified = true; monitor.Log.WriteLine ("Added addin: " + fname); } allAddins.Add (entry); - - DateTime date = File.GetLastWriteTime (file); - if (date > lastModified) - lastModified = date; } ArrayList toRemove = new ArrayList (); - foreach (PackageRepositoryEntry entry in mainrep.Addins) - if (!File.Exists (Path.Combine (mainPath, entry.Url))) + foreach (PackageRepositoryEntry entry in mainrep.Addins) { + if (!File.Exists (Path.Combine (mainPath, entry.Url))) { toRemove.Add (entry); + modified = true; + } + } - foreach (PackageRepositoryEntry entry in toRemove) + foreach (PackageRepositoryEntry entry in toRemove) { + DeleteSupportFiles (supportFileDir, entry.Addin); mainrep.RemoveEntry (entry); + } - if (modified || toRemove.Count > 0) { + if (modified) { AddinStore.WriteObject (mainFile, mainrep); monitor.Log.WriteLine ("Updated " + relFilePath); + lastModified = File.GetLastWriteTime (mainFile); } - ReferenceRepositoryEntry repEntry = (ReferenceRepositoryEntry) rootrep.FindEntry (relFilePath); if (repEntry != null) { if (repEntry.LastModified < lastModified) repEntry.LastModified = lastModified; - } else { + } else if (modified) { repEntry = new ReferenceRepositoryEntry (); repEntry.LastModified = lastModified; repEntry.Url = relFilePath; @@ -312,11 +556,54 @@ } foreach (string dir in Directory.GetDirectories (mainPath)) { + if (Path.GetFileName (dir) == addinFilesDir) + continue; string based = dir.Substring (rootPath.Length + 1); BuildRepository (monitor, rootrep, rootPath, Path.Combine (based, "main.mrep"), allAddins); } } + void DeleteSupportFiles (string targetDir, AddinInfo ainfo) + { + foreach (var prop in ainfo.Properties) { + if (prop.Value.StartsWith (addinFilesDir + Path.DirectorySeparatorChar)) { + string file = Path.Combine (targetDir, Path.GetFileName (prop.Value)); + if (File.Exists (file)) + File.Delete (file); + } + } + if (Directory.Exists (targetDir) && Directory.GetFileSystemEntries (targetDir).Length == 0) + Directory.Delete (targetDir, true); + } + + void ExtractSupportFiles (string targetDir, string file, AddinInfo ainfo) + { + Random r = new Random (); + ZipFile zfile = new ZipFile (file); + foreach (var prop in ainfo.Properties) { + ZipEntry ze = zfile.GetEntry (prop.Value); + if (ze != null) { + string fname; + do { + fname = Path.Combine (targetDir, r.Next().ToString ("x") + Path.GetExtension (prop.Value)); + } while (File.Exists (fname)); + + if (!Directory.Exists (targetDir)) + Directory.CreateDirectory (targetDir); + + using (var f = File.OpenWrite (fname)) { + using (Stream s = zfile.GetInputStream (ze)) { + byte[] buffer = new byte [8092]; + int nr = 0; + while ((nr = s.Read (buffer, 0, buffer.Length)) > 0) + f.Write (buffer, 0, nr); + } + } + prop.Value = Path.Combine (addinFilesDir, Path.GetFileName (fname)); + } + } + } + void GenerateIndexPage (Repository rep, ArrayList addins, string basePath) { StreamWriter sw = new StreamWriter (Path.Combine (basePath, "index.html")); @@ -366,5 +653,236 @@ if (Directory.Exists (RepositoryCachePath)) Directory.Delete (RepositoryCachePath, true); } + + /// + /// Gets a reference to an extensible application + /// + /// + /// Name of the application + /// + /// + /// The Application object. Null if not found. + /// + public static Application GetExtensibleApplication (string name) + { + return GetExtensibleApplication (name, null); + } + + /// + /// Gets a reference to an extensible application + /// + /// + /// Name of the application + /// + /// + /// Custom paths where to look for the application. + /// + /// + /// The Application object. Null if not found. + /// + public static Application GetExtensibleApplication (string name, IEnumerable searchPaths) + { + AddinsPcFileCache pcc = GetAddinsPcFileCache (searchPaths); + PackageInfo pi = pcc.GetPackageInfoByName (name, searchPaths); + if (pi != null) + return new Application (pi); + else + return null; + } + + /// + /// Gets a lis of all known extensible applications + /// + /// + /// A list of applications. + /// + public static Application[] GetExtensibleApplications () + { + return GetExtensibleApplications (null); + } + + /// + /// Gets a lis of all known extensible applications + /// + /// + /// Custom paths where to look for applications. + /// + /// + /// A list of applications. + /// + public static Application[] GetExtensibleApplications (IEnumerable searchPaths) + { + List list = new List (); + + AddinsPcFileCache pcc = GetAddinsPcFileCache (searchPaths); + foreach (PackageInfo pinfo in pcc.GetPackages (searchPaths)) { + if (pinfo.IsValidPackage) + list.Add (new Application (pinfo)); + } + return list.ToArray (); + } + + static AddinsPcFileCache pcFileCache; + + static AddinsPcFileCache GetAddinsPcFileCache (IEnumerable searchPaths) + { + if (pcFileCache == null) { + pcFileCache = new AddinsPcFileCache (); + if (searchPaths != null) + pcFileCache.Update (searchPaths); + else + pcFileCache.Update (); + } + return pcFileCache; + } + } + + class AddinsPcFileCacheContext: IPcFileCacheContext + { + public bool IsCustomDataComplete (string pcfile, PackageInfo pkg) + { + return true; + } + + public void StoreCustomData (Mono.PkgConfig.PcFile pcfile, PackageInfo pkg) + { + } + + public void ReportError (string message, System.Exception ex) + { + Console.WriteLine (message); + Console.WriteLine (ex); + } + } + + class AddinsPcFileCache: PcFileCache + { + public AddinsPcFileCache (): base (new AddinsPcFileCacheContext ()) + { + } + + protected override string CacheDirectory { + get { + string path = Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData); + path = Path.Combine (path, "mono.addins"); + return path; + } + } + + protected override void ParsePackageInfo (PcFile file, PackageInfo pinfo) + { + string rootPath = file.GetVariable ("MonoAddinsRoot"); + string regPath = file.GetVariable ("MonoAddinsRegistry"); + string addinsPath = file.GetVariable ("MonoAddinsInstallPath"); + string databasePath = file.GetVariable ("MonoAddinsCachePath"); + string testCmd = file.GetVariable ("MonoAddinsTestCommand"); + if (string.IsNullOrEmpty (rootPath) || string.IsNullOrEmpty (regPath)) + return; + pinfo.SetData ("MonoAddinsRoot", rootPath); + pinfo.SetData ("MonoAddinsRegistry", regPath); + pinfo.SetData ("MonoAddinsInstallPath", addinsPath); + pinfo.SetData ("MonoAddinsCachePath", databasePath); + pinfo.SetData ("MonoAddinsTestCommand", testCmd); + } + } + + /// + /// A registered extensible application + /// + public class Application + { + AddinRegistry registry; + string description; + string name; + string testCommand; + string startupPath; + string registryPath; + string addinsPath; + string databasePath; + + internal Application (PackageInfo pinfo) + { + name = pinfo.Name; + description = pinfo.Description; + startupPath = pinfo.GetData ("MonoAddinsRoot"); + registryPath = pinfo.GetData ("MonoAddinsRegistry"); + addinsPath = pinfo.GetData ("MonoAddinsInstallPath"); + databasePath = pinfo.GetData ("MonoAddinsCachePath"); + testCommand = pinfo.GetData ("MonoAddinsTestCommand"); + } + + /// + /// Add-in registry of the application + /// + public AddinRegistry Registry { + get { + if (registry == null) + registry = new AddinRegistry (RegistryPath, StartupPath, AddinsPath, AddinCachePath); + return registry; + } + } + + /// + /// Description of the application + /// + public string Description { + get { + return description; + } + } + + /// + /// Name of the application + /// + public string Name { + get { + return name; + } + } + + /// + /// Path to the add-in registry + /// + public string RegistryPath { + get { + return registryPath; + } + } + + /// + /// Path to the directory that contains the main executable assembly of the application + /// + public string StartupPath { + get { + return startupPath; + } + } + + /// + /// Command to be used to execute the application in add-in development mode. + /// + public string TestCommand { + get { + return testCommand; + } + } + + /// + /// Path to the default add-ins directory for the aplpication + /// + public string AddinsPath { + get { + return addinsPath; + } + } + + /// + /// Path to the add-in cache for the application + /// + public string AddinCachePath { + get { + return databasePath; + } + } } } diff -Nru mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/SetupTool.cs mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/SetupTool.cs --- mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/SetupTool.cs 2008-11-06 19:52:10.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/SetupTool.cs 2011-04-13 09:00:29.000000000 +0000 @@ -38,6 +38,12 @@ namespace Mono.Addins.Setup { + /// + /// A command line add-in manager. + /// + /// + /// This class can be used to provide an add-in management command line tool to applications. + /// public class SetupTool { Hashtable options = new Hashtable (); @@ -49,8 +55,14 @@ string setupAppName = ""; int uniqueId = 0; - bool verbose; + int verbose = 1; + /// + /// Creates a new instance + /// + /// + /// Add-in registry to manage. + /// public SetupTool (AddinRegistry registry) { this.registry = registry; @@ -58,21 +70,51 @@ CreateCommands (); } + /// + /// Display name of the host application + /// public string ApplicationName { get { return applicationName; } set { applicationName = value; } } + /// + /// Default add-in namespace of the application (optional). If set, only add-ins that belong to that namespace + /// will be shown in add-in lists. + /// public string ApplicationNamespace { get { return service.ApplicationNamespace; } set { service.ApplicationNamespace = value; } } + /// + /// Enables or disables verbose output + /// public bool VerboseOutput { + get { return verbose > 1; } + set { verbose = value ? 2 : 1; } + } + + /// + /// Sets or gets the verbose output level (0: normal output, 1:verbose, 2+:extra verbose) + /// + public int VerboseOutputLevel { get { return verbose; } set { verbose = value; } } + /// + /// Runs the command line tool. + /// + /// + /// Array that contains the command line arguments + /// + /// + /// Index of the arguments array that has the first argument for the management tool + /// + /// + /// 0 if it succeeds. != 0 otherwise + /// public int Run (string[] args, int firstArgumentIndex) { string[] aa = new string [args.Length - firstArgumentIndex]; @@ -80,6 +122,15 @@ return Run (aa); } + /// + /// Runs the command line tool. + /// + /// + /// Command line arguments + /// + /// + /// 0 if it succeeds. != 0 otherwise + /// public int Run (string[] args) { if (args.Length == 0) { @@ -92,7 +143,8 @@ try { ReadOptions (parms); - verbose = verbose || HasOption ("v"); + if (HasOption ("v")) + verbose++; return RunCommand (args [0], parms); } catch (InstallException ex) { Console.WriteLine (ex.Message); @@ -333,22 +385,65 @@ service.Repositories.RegisterRepository (new ConsoleProgressStatus (verbose), rep); } + string GetRepositoryUrl (string url) + { + AddinRepository[] reps = GetRepositoryList (); + int nr; + if (int.TryParse (url, out nr)) { + if (nr < 0 || nr >= reps.Length) + throw new InstallException ("Invalid repository number."); + return reps[nr].Url; + } else { + if (!service.Repositories.ContainsRepository (url)) + throw new InstallException ("Repository not registered."); + return url; + } + } + void RemoveRepository (string[] args) { + foreach (string rep in args) { + service.Repositories.RemoveRepository (GetRepositoryUrl (rep)); + } + } + + void EnableRepository (string[] args) + { foreach (string rep in args) - service.Repositories.RemoveRepository (rep); + service.Repositories.SetRepositoryEnabled (GetRepositoryUrl(rep), true); } - void ListRepositories (string[] args) + void DisableRepository (string[] args) + { + foreach (string rep in args) + service.Repositories.SetRepositoryEnabled (GetRepositoryUrl(rep), false); + } + + AddinRepository[] GetRepositoryList () { AddinRepository[] reps = service.Repositories.GetRepositories (); + Array.Sort (reps, (r1,r2) => r1.Title.CompareTo(r2.Title)); + return reps; + } + + void ListRepositories (string[] args) + { + AddinRepository[] reps = GetRepositoryList (); if (reps.Length == 0) { Console.WriteLine ("No repositories have been registered."); return; } + int n = 0; Console.WriteLine ("Registered repositories:"); foreach (RepositoryRecord rep in reps) { - Console.WriteLine (" - " + rep.Title); + string num = n.ToString (); + Console.Write (num + ") "); + if (!rep.Enabled) + Console.Write ("(Disabled) "); + Console.WriteLine (rep.Title); + if (rep.Title != rep.Url) + Console.WriteLine (new string (' ', num.Length + 2) + rep.Url); + n++; } } @@ -367,6 +462,40 @@ service.BuildPackage (new ConsoleProgressStatus (verbose), GetOption ("d", "."), GetArguments ()); } + void PrintLibraries (string[] args) + { + if (GetArguments ().Length < 1) + throw new InstallException ("An add-in id is required."); + + bool refFormat = HasOption ("r"); + + System.Text.StringBuilder sb = new System.Text.StringBuilder (); + foreach (string id in GetArguments ()) { + Addin addin = service.Registry.GetAddin (id); + if (addin != null) { + foreach (string asm in addin.Description.MainModule.Assemblies) { + string file = Path.Combine (addin.Description.BasePath, asm); + if (sb.Length > 0) + sb.Append (' '); + if (refFormat) + sb.Append ("-r:"); + sb.Append (file); + } + } + } + Console.WriteLine (sb); + } + + void PrintApplications (string[] args) + { + foreach (Application app in SetupService.GetExtensibleApplications ()) { + string line = app.Name; + if (!string.IsNullOrEmpty (app.Description)) + line += " - " + app.Description; + Console.WriteLine (line); + } + } + void UpdateRegistry (string[] args) { registry.Update (new ConsoleProgressStatus (verbose)); @@ -728,6 +857,30 @@ arguments = (string[]) list.ToArray (typeof(string)); } + /// + /// Adds a custom command to the add-in manager + /// + /// + /// Category under which the command has to be shown in the help text + /// + /// + /// Name of the command + /// + /// + /// Short name of the command (it's an alias of the normal name) + /// + /// + /// Formal description of the arguments that the command accepts. For example: "[addin-id|addin-file] [--xml] [--all] [--full] [--namespace ]" + /// + /// + /// Short description of the command + /// + /// + /// Long description of the command + /// + /// + /// Delegate to be invoked to run the command + /// public void AddCommand (string category, string command, string shortName, string arguments, string description, string longDescription, SetupCommandHandler handler) { SetupCommand cmd = new SetupCommand (category, command, shortName, handler); @@ -755,11 +908,19 @@ return null; } + /// + /// Prints help about the add-in management tool, or about a specific command + /// + /// + /// Optional command name and arguments + /// public void PrintHelp (params string[] parms) { if (parms.Length == 0) { string lastCat = null; foreach (SetupCommand cmd in commands) { + if (cmd.Command == "help") + continue; if (lastCat != cmd.Category) { Console.WriteLine (); Console.WriteLine (cmd.Category + ":"); @@ -783,7 +944,11 @@ Console.WriteLine (); Console.WriteLine ("Usage: {0}{1}", setupAppName, cmd.Usage); Console.WriteLine (); - Console.WriteLine (cmd.LongDescription); + + TextFormatter fm = new TextFormatter (); + fm.Wrap = WrappingType.Word; + fm.Append (cmd.LongDescription); + Console.WriteLine (fm.ToString ()); } else Console.WriteLine ("Unknown command: " + parms [0]); @@ -801,7 +966,7 @@ cmd.Usage = "[package-name|package-file] ..."; cmd.AppendDesc ("Installs an add-in or set of addins. The command argument is a list"); cmd.AppendDesc ("of files and/or package names. If a package name is provided"); - cmd.AppendDesc ("the package will be looked out in the registered repositories."); + cmd.AppendDesc ("the package will be looked up in the registered repositories."); cmd.AppendDesc ("A specific add-in version can be specified by appending it to."); cmd.AppendDesc ("the package name using '/' as a separator, like in this example:"); cmd.AppendDesc ("MonoDevelop.SourceEditor/0.9.1"); @@ -855,8 +1020,28 @@ cmd = new SetupCommand (cat, "rep-remove", "rr", new SetupCommandHandler (RemoveRepository)); cmd.Description = "Unregisters repositories."; - cmd.Usage = " ..."; + cmd.Usage = " ..."; cmd.AppendDesc ("Unregisters an add-in repository. Several URLs can be provided."); + cmd.AppendDesc ("Instead of an url, a repository number can be used (repository numbers are"); + cmd.AppendDesc ("shown by the rep-list command."); + commands.Add (cmd); + + cmd = new SetupCommand (cat, "rep-enable", "re", new SetupCommandHandler (EnableRepository)); + cmd.Description = "Enables repositories."; + cmd.Usage = " ..."; + cmd.AppendDesc ("Enables an add-in repository which has been disabled. Several URLs can be"); + cmd.AppendDesc ("provided. Instead of an url, a repository number can be used (repository"); + cmd.AppendDesc ("numbers are shown by the rep-list command."); + commands.Add (cmd); + + cmd = new SetupCommand (cat, "rep-disable", "rd", new SetupCommandHandler (DisableRepository)); + cmd.Description = "Disables repositories."; + cmd.Usage = " ..."; + cmd.AppendDesc ("Disables an add-in repository. Several URLs can be provided"); + cmd.AppendDesc ("When a repository is disabled, it will be ignored when using the update and"); + cmd.AppendDesc ("install commands."); + cmd.AppendDesc ("Instead of an url, a repository number can be used (repository numbers are"); + cmd.AppendDesc ("shown by the rep-list command."); commands.Add (cmd); cmd = new SetupCommand (cat, "rep-update", "ru", new SetupCommandHandler (UpdateAvailableAddins)); @@ -883,8 +1068,13 @@ commands.Add (cmd); cmd = new SetupCommand (cat, "info", null, new SetupCommandHandler (PrintAddinInfo)); - cmd.Description = "Prints information about an add-in."; - cmd.AppendDesc ("Prints information about an add-in."); + cmd.Usage = "[addin-id|addin-file] [--xml] [--all] [--full] [--namespace ]"; + cmd.Description = "Prints information about add-ins."; + cmd.AppendDesc ("Prints information about add-ins. Options:\n"); + cmd.AppendDesc (" --xml: Dump the information using an XML format.\n"); + cmd.AppendDesc (" --all: Dump information from all add-ins.\n"); + cmd.AppendDesc (" --full: Include add-ins which don't define extension points.\n"); + cmd.AppendDesc (" --namespace ns: Include only add-ins from the specified 'ns' namespace."); commands.Add (cmd); cat = "Packaging Commands"; @@ -911,6 +1101,22 @@ cmd.Usage = ""; commands.Add (cmd); + cat = "Build Commands"; + + cmd = new SetupCommand (cat, "libraries", "libs", new SetupCommandHandler (PrintLibraries)); + cmd.Description = "Lists add-in assemblies."; + cmd.Usage = "[-r] ..."; + cmd.AppendDesc ("Prints a list of assemblies exported by the add-in or add-ins provided"); + cmd.AppendDesc ("as arguments. This list of assemblies can be used as references for"); + cmd.AppendDesc ("building add-ins that depend on them. If the -r option is specified,"); + cmd.AppendDesc ("each assembly is prefixed with '-r:'."); + commands.Add (cmd); + + cmd = new SetupCommand (cat, "applications", "apps", new SetupCommandHandler (PrintApplications)); + cmd.Description = "Lists extensible applications."; + cmd.AppendDesc ("Prints a list of registered extensible applications."); + commands.Add (cmd); + cat = "Debug Commands"; cmd = new SetupCommand (cat, "dump-file", null, new SetupCommandHandler (DumpRegistryFile)); @@ -935,7 +1141,7 @@ public void AppendDesc (string s) { - LongDescription += s + "\n"; + LongDescription += s + " "; } public string Category; @@ -961,6 +1167,9 @@ public string LongDescription = ""; } + /// + /// A command handler + /// public delegate void SetupCommandHandler (string[] args); } diff -Nru mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/TextFormatter.cs mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/TextFormatter.cs --- mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup/TextFormatter.cs 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup/TextFormatter.cs 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,378 @@ +// +// TextFormatter.cs +// +// Author: +// Lluis Sanchez Gual +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Text; + +namespace Mono.Addins.Setup +{ + enum WrappingType + { + None, + Char, + Word, + WordChar + } + + class TextFormatter + { + string indentString = ""; + string formattedIndentString; + int indentColumnWidth; + string paragFormattedIndentString; + int paragIndentColumnWidth; + int leftMargin; + int paragraphStartMargin; + WrappingType wrap; + int tabWidth; + bool tabsAsSpaces; + + public int MaxColumns { get; set; } + + StringBuilder builder = new StringBuilder (); + StringBuilder currentWord = new StringBuilder (); + int curCol; + bool lineStart = true; + bool lastWasSeparator; + bool paragraphStart = true; + int wordLevel; + + public TextFormatter () + { + MaxColumns = 80; + TabWidth = 4; + } + + public int TabWidth { + get { return tabWidth; } + set { + tabWidth = value; + formattedIndentString = null; + } + } + + public string IndentString { + get { return indentString; } + set { + if (value == null) + throw new ArgumentNullException ("value"); + indentString = value; + formattedIndentString = null; + } + } + + public int LeftMargin { + get { + return leftMargin; + } + set { + leftMargin = value; + formattedIndentString = null; + } + } + + public int ParagraphStartMargin { + get { return paragraphStartMargin; } + set { + paragraphStartMargin = value; + formattedIndentString = null; + } + } + + public WrappingType Wrap { + get { + return wrap; + } + set { + if (wrap != value) { + AppendCurrentWord ('x'); + wrap = value; + } + } + } + + public bool TabsAsSpaces { + get { return tabsAsSpaces; } + set { + tabsAsSpaces = value; + formattedIndentString = null; + } + } + + string FormattedIndentString { + get { + if (formattedIndentString == null) + CreateIndentString (); + return formattedIndentString; + } + } + + int IndentColumnWidth { + get { + if (formattedIndentString == null) + CreateIndentString (); + return indentColumnWidth; + } + } + + string ParagFormattedIndentString { + get { + if (formattedIndentString == null) + CreateIndentString (); + return paragFormattedIndentString; + } + } + + int ParagIndentColumnWidth { + get { + if (formattedIndentString == null) + CreateIndentString (); + return paragIndentColumnWidth; + } + } + + public void Clear () + { + builder = new StringBuilder (); + currentWord = new StringBuilder (); + curCol = 0; + lineStart = true; + paragraphStart = true; + lastWasSeparator = false; + } + + public void AppendWord (string text) + { + BeginWord (); + Append (text); + EndWord (); + } + + public void Append (string text) + { + if (string.IsNullOrEmpty (text)) + return; + + if (builder.Length == 0) { + curCol = IndentColumnWidth; + lineStart = true; + paragraphStart = true; + } + + if (Wrap == WrappingType.None || Wrap == WrappingType.Char) { + AppendChars (text, Wrap == WrappingType.Char); + return; + } + + int n = 0; + + while (n < text.Length) + { + int sn = n; + bool foundSpace = false; + while (n < text.Length && !foundSpace) { + if ((char.IsWhiteSpace (text [n]) && wordLevel == 0) || text [n] == '\n') + foundSpace = true; + else + n++; + } + + if (n != sn) + currentWord.Append (text.Substring (sn, n - sn)); + if (foundSpace) { + AppendCurrentWord (text[n]); + n++; + } + } + } + + public void AppendLine () + { + AppendCurrentWord ('x'); + AppendChar ('\n', false); + } + + public void BeginWord () + { + wordLevel++; + } + + public void EndWord () + { + if (wordLevel == 0) + throw new InvalidOperationException ("Missing BeginWord call"); + wordLevel--; + + char lastChar = 'x'; + if (currentWord.Length > 0) { + lastChar = currentWord [currentWord.Length - 1]; + if (char.IsWhiteSpace (lastChar)) + currentWord.Remove (currentWord.Length - 1, 1); + } + AppendCurrentWord (lastChar); + } + + public void FlushWord () + { + AppendCurrentWord ('x'); + if (curCol > MaxColumns) + AppendSoftBreak (); + } + + public override string ToString () + { + if (currentWord.Length > 0) + AppendCurrentWord ('x'); + return builder.ToString (); + } + + void AppendChars (string s, bool wrapChars) + { + foreach (char c in s) + AppendChar (c, wrapChars); + } + + void AppendSoftBreak () + { + AppendChar ('\n', true); + paragraphStart = false; + curCol = IndentColumnWidth; + } + + void AppendChar (char c, bool wrapChars) + { + if (c == '\n') { + lineStart = true; + paragraphStart = true; + builder.Append (c); + curCol = ParagIndentColumnWidth; + lastWasSeparator = false; + return; + } + else if (lineStart) { + if (paragraphStart) + builder.Append (ParagFormattedIndentString); + else + builder.Append (FormattedIndentString); + lineStart = false; + paragraphStart = false; + lastWasSeparator = false; + } + if (wrapChars && curCol >= MaxColumns) { + AppendSoftBreak (); + if (!char.IsWhiteSpace (c)) + AppendChar (c, false); + return; + } + + if (c == '\t') { + int tw = GetTabWidth (curCol); + if (TabsAsSpaces) + builder.Append (' ', tw); + else + builder.Append (c); + curCol += tw; + } + else { + builder.Append (c); + curCol++; + } + } + + void AppendCurrentWord (char separatorChar) + { + if (currentWord.Length == 0) + return; + if (Wrap == WrappingType.Word || Wrap == WrappingType.WordChar) { + if (curCol + currentWord.Length > MaxColumns) { + // If the last char was a word separator, remove it + if (lastWasSeparator) + builder.Remove (builder.Length - 1, 1); + if (!lineStart) + AppendSoftBreak (); + } + } + AppendChars (currentWord.ToString (), Wrap == WrappingType.WordChar); + if (char.IsWhiteSpace (separatorChar) || (separatorChar == '\n' && !lineStart)) { + lastWasSeparator = true; + AppendChar (separatorChar, true); + } else + lastWasSeparator = false; + currentWord = new StringBuilder (); + } + + int GetTabWidth (int startCol) + { + int res = startCol % TabWidth; + if (res == 0) + return TabWidth; + else + return TabWidth - res; + } + + void CreateIndentString () + { + StringBuilder sb = new StringBuilder (); + indentColumnWidth = AddIndentString (sb, indentString); + + paragFormattedIndentString = sb.ToString () + new string (' ', paragraphStartMargin); + paragIndentColumnWidth = indentColumnWidth + paragraphStartMargin; + + if (LeftMargin > 0) { + sb.Append (' ', LeftMargin); + indentColumnWidth += LeftMargin; + } + formattedIndentString = sb.ToString (); + + if (paragraphStart) + curCol = paragIndentColumnWidth; + else if (lineStart) + curCol = indentColumnWidth; + } + + int AddIndentString (StringBuilder sb, string txt) + { + if (string.IsNullOrEmpty (txt)) + return 0; + int count = 0; + foreach (char c in txt) { + if (c == '\t') { + int tw = GetTabWidth (count); + count += tw; + if (TabsAsSpaces) + sb.Append (' ', tw); + else + sb.Append (c); + } + else { + sb.Append (c); + count++; + } + } + return count; + } + } +} diff -Nru mono-addins-0.4/Mono.Addins.Setup/mono-addins-setup.pc.in mono-addins-0.6.1/Mono.Addins.Setup/mono-addins-setup.pc.in --- mono-addins-0.4/Mono.Addins.Setup/mono-addins-setup.pc.in 2008-11-06 19:52:10.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Setup/mono-addins-setup.pc.in 2011-04-13 09:00:29.000000000 +0000 @@ -1,7 +1,8 @@ -prefix=@prefix@ +prefix=${pcfiledir}/../.. exec_prefix=${prefix} -pkglibdir=@libdir@/mono/@PACKAGE@ -Libraries= ${pkglibdir}/@MONO_ADDINS_SETUP_DEFAULT_LIB@ +pkglibdir=${prefix}/lib/mono/@PACKAGE@ + +Libraries=${pkglibdir}/@MONO_ADDINS_SETUP_DEFAULT_LIB@ Name: Mono.Addins.Setup Description: diff -Nru mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup.ProgressMonitoring/ConsoleProgressMonitor.cs mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup.ProgressMonitoring/ConsoleProgressMonitor.cs --- mono-addins-0.4/Mono.Addins.Setup/Mono.Addins.Setup.ProgressMonitoring/ConsoleProgressMonitor.cs 2008-11-06 19:52:08.000000000 +0000 +++ mono-addins-0.6.1/Mono.Addins.Setup/Mono.Addins.Setup.ProgressMonitoring/ConsoleProgressMonitor.cs 2011-04-13 09:00:29.000000000 +0000 @@ -135,26 +135,26 @@ else WriteText (text, 0); } - - void WriteText (string text, int leftMargin) - { + + void WriteText (string text, int leftMargin) + { if (text == null || text.Length == 0) return; - int n = 0; - int maxCols = wrap ? columns : int.MaxValue; + int n = 0; + int maxCols = wrap ? columns : int.MaxValue; - while (n < text.Length) - { + while (n < text.Length) + { if (col == -1) { Console.Write (new String (' ', leftMargin)); col = leftMargin; } - int lastWhite = -1; + int lastWhite = -1; int sn = n; bool eol = false; - + while (col < maxCols && n < text.Length) { char c = text [n]; if (c == '\r') { @@ -164,26 +164,26 @@ if (c == '\n') { eol = true; break; - } - if (char.IsWhiteSpace (c)) - lastWhite = n; - col++; - n++; - } - - if (lastWhite == -1 || col < maxCols) - lastWhite = n; - else if (col >= maxCols) - n = lastWhite + 1; - + } + if (char.IsWhiteSpace (c)) + lastWhite = n; + col++; + n++; + } + + if (lastWhite == -1 || col < maxCols) + lastWhite = n; + else if (col >= maxCols) + n = lastWhite + 1; + Console.Write (text.Substring (sn, lastWhite - sn)); if (eol || col >= maxCols) { col = -1; Console.WriteLine (); if (eol) n++; - } - } + } + } } void Indent () diff -Nru mono-addins-0.4/mono-addins.spec.in mono-addins-0.6.1/mono-addins.spec.in --- mono-addins-0.4/mono-addins.spec.in 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/mono-addins.spec.in 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,46 @@ +%define _libdir %{_prefix}/lib + +Name: mono-addins +Version: @VERSION@ +Release: 0 +License: X11/MIT +BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildArch: noarch +Url: http://www.mono-project.com +Source0: http://ftp.novell.com/pub/mono/sources/%{name}/%{name}-%{version}.tar.bz2 +BuildRequires: gtk-sharp2 +BuildRequires: mono-devel +BuildRequires: pkg-config +Summary: Mono Addins Framework +Group: Development/Languages/Mono + +%description +Mono.Addins is a generic framework for creating extensible +applications, and for creating libraries which extend those +applications. + +%files +%defattr(-, root, root) +%{_bindir}/mautil +%{_datadir}/pkgconfig/*.pc +%{_libdir}/mono/gac/*Mono.Addins* +%{_libdir}/mono/mono-addins +%{_libdir}/mono/xbuild/Mono.Addins.targets +%{_mandir}/man1/mautil.1%ext_man + +%prep +%setup -q + +%build +%configure +make + +%install +make install DESTDIR=%{buildroot} +mkdir -p %{buildroot}%{_datadir}/pkgconfig +mv %{buildroot}%{_libdir}/pkgconfig/*.pc %{buildroot}%{_datadir}/pkgconfig + +%clean +rm -rf %{buildroot} + +%changelog diff -Nru mono-addins-0.4/Samples/ChangeLog mono-addins-0.6.1/Samples/ChangeLog --- mono-addins-0.4/Samples/ChangeLog 2008-11-06 19:52:08.000000000 +0000 +++ mono-addins-0.6.1/Samples/ChangeLog 1970-01-01 00:00:00.000000000 +0000 @@ -1,118 +0,0 @@ -2008-08-22 Lluis Sanchez Gual - - * Samples.mds: More project file fixes. - -2008-08-22 Lluis Sanchez Gual - - * TextEditor.CompilerService.CSharp/TextEditor.CompilerService.CSharp.csproj, - TextEditor.CompilerService/TextEditor.CompilerService.csproj, - TextEditor.Xml/TextEditor.Xml.csproj, TextEditor/TextEditor.csproj, - TextEditorLib/TextEditorLib.csproj, - WriterService.SampleExtender/WriterService.SampleExtender.csproj, - WriterService/WriterService.csproj, - WriterServiceHost/WriterServiceHost.csproj, - WriterServiceHost/WriterServiceHost.mdp, - WriterService/WriterService.mdp, - TextEditor.CompilerService.CSharp/TextEditor.CompilerService.CSharp.mdp, - TextEditor.CompilerService/TextEditor.CompilerService.mdp, - WriterService.SampleExtender/WriterService.SampleExtender.mdp, - TextEditorLib/TextEditorLib.mdp, TextEditor/TextEditor.mdp, - TextEditor.Xml/TextEditor.Xml.mdp: Use msbuild file format for - projects. Removed the old MD1 projects. - -2008-02-15 Lluis Sanchez Gual - - * TextEditorLib/TextEditorLib.mdp, - TextEditor.CompilerService/TextEditor.CompilerService.mdp, - TextEditor.Xml/TextEditor.Xml.mdp, TextEditor/TextEditor.mdp: Flush. - -2008-01-07 Lluis Sanchez Gual - - * TextEditor.CompilerService/MyClass.cs, - TextEditor.CompilerService/TextEditor.CompilerService.mdp, - TextEditor.CompilerService/Makefile.am, TextEditor.Xml/MyClass.cs: - Removed unused MyClass file. - * TextEditor.CompilerService/TextEditor.CompilerService.csproj, - TextEditor.CompilerService.CSharp/TextEditor.CompilerService.CSharp.csproj, - TextEditor.Xml/TextEditor.Xml.csproj, TextEditor/TextEditor.csproj, - TextEditorLib/TextEditorLib.csproj, - WriterService.SampleExtender/WriterService.SampleExtender.csproj, - WriterService/WriterService.csproj, - WriterServiceHost/WriterServiceHost.csproj: Updated VS solution files. - Patch by Andrés G. Aragoneses. - -2008-01-07 Lluis Sanchez Gual - - * TextEditorLib/TextEditorLib.mdp: Update. - * TextEditorLib/gtk-gui/MainWindow.cs, TextEditorLib/gtk-gui/generated.cs: - Regenerated. - * TextEditorLib/Makefile.am: Remove undeeded reference. Patch by Ben - Motmans. - -2007-12-05 Lluis Sanchez Gual - - * TextEditorLib/gtk-gui/gui.stetic, - TextEditor.CompilerService/TextEditor.CompilerService.mdp, - TextEditor.Xml/TextEditor.Xml.mdp, - WriterServiceHost/WriterServiceHost.mdp, - WriterService.SampleExtender/WriterService.SampleExtender.mdp, - WriterService/WriterService.mdp: Flush. - -2007-10-29 Lluis Sanchez Gual - - * Samples.mds, - TextEditor.CompilerService.CSharp/TextEditor.CompilerService.CSharp.mdp, - TextEditor.CompilerService/TextEditor.CompilerService.mdp, - TextEditor.Xml/TextEditor.Xml.mdp, TextEditor/TextEditor.mdp, - TextEditorLib/TextEditorLib.mdp, - WriterService.SampleExtender/WriterService.SampleExtender.mdp, - WriterService/WriterService.mdp, - WriterServiceHost/WriterServiceHost.mdp: Update paths. - -2007-10-18 Lluis Sanchez Gual - - * TextEditor/Main.cs: Get ready for 0.3 release. - -2007-07-05 Lluis Sanchez Gual - - * TextEditorLib/TextEditorLib.mdp, - TextEditor.CompilerService/TextEditor.CompilerService.mdp, - TextEditor.CompilerService/Makefile.am, - TextEditor.Xml/TextEditor.Xml.mdp, TextEditor.Xml/Makefile.am, - TextEditor/Makefile.am, TextEditor/TextEditor.mdp, - WriterServiceHost/Makefile.am, - WriterServiceHost/WriterServiceHost.mdp, - WriterService.SampleExtender/WriterService.SampleExtender.mdp, - WriterService/WriterService.mdp: Makefile and project file fixes. - * TextEditorLib/gtk-gui/MainWindow.cs: Updated. - -2007-04-23 Lluis Sanchez Gual - - * TextEditorLib/MainWindow.cs, TextEditorLib/gtk-gui/MainWindow.cs, - TextEditorLib/gtk-gui/gui.stetic: Updated. - * TextEditorLib/TextEditorLib.mdp, TextEditorLib/Makefile.am, - TextEditor.CompilerService.CSharp/TextEditor.CompilerService.CSharp.mdp, - TextEditor.CompilerService.CSharp/Makefile.am, - TextEditor.CompilerService/TextEditor.CompilerService.mdp, - TextEditor.CompilerService/Makefile.am, - TextEditor.Xml/TextEditor.Xml.mdp, TextEditor.Xml/Makefile.am, - TextEditor/Makefile.am, TextEditor/TextEditor.mdp, - WriterServiceHost/WriterServiceHost.mdp, - WriterService.SampleExtender/Makefile.am, - WriterService.SampleExtender/WriterService.SampleExtender.mdp, - WriterService/Makefile.am, WriterService/WriterService.mdp: Enabled - makefile synchronization. - -2007-03-30 Lluis Sanchez Gual - - * TextEditorLib/MainWindow.cs: Track changes in the templates extension - point. - -2007-03-28 Lluis Sanchez Gual - - * TextEditor/Main.cs: Improved error reporting. - -2007-03-23 Lluis Sanchez Gual - - Added build files. - diff -Nru mono-addins-0.4/Samples/Makefile.am mono-addins-0.6.1/Samples/Makefile.am --- mono-addins-0.4/Samples/Makefile.am 2008-11-06 19:52:08.000000000 +0000 +++ mono-addins-0.6.1/Samples/Makefile.am 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -SUBDIRS = WriterService WriterServiceHost WriterService.SampleExtender TextEditorLib TextEditor.Xml TextEditor.CompilerService TextEditor.CompilerService.CSharp TextEditor - diff -Nru mono-addins-0.4/Samples/Makefile.in mono-addins-0.6.1/Samples/Makefile.in --- mono-addins-0.4/Samples/Makefile.in 2008-11-06 19:52:35.000000000 +0000 +++ mono-addins-0.6.1/Samples/Makefile.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,448 +0,0 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -subdir = ./Samples -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = -SOURCES = -DIST_SOURCES = -RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ - html-recursive info-recursive install-data-recursive \ - install-dvi-recursive install-exec-recursive \ - install-html-recursive install-info-recursive \ - install-pdf-recursive install-ps-recursive install-recursive \ - installcheck-recursive installdirs-recursive pdf-recursive \ - ps-recursive uninstall-recursive -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = $(SUBDIRS) -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AL = @AL@ -AMTAR = @AMTAR@ -API_VERSION = @API_VERSION@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -GACUTIL = @GACUTIL@ -GACUTIL_FLAGS = @GACUTIL_FLAGS@ -GACUTIL_POLICY_FLAGS = @GACUTIL_POLICY_FLAGS@ -GTK_SHARP_20_CFLAGS = @GTK_SHARP_20_CFLAGS@ -GTK_SHARP_20_LIBS = @GTK_SHARP_20_LIBS@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MCS = @MCS@ -MKDIR_P = @MKDIR_P@ -MONO_ADDINS_DEFAULT_LIB = @MONO_ADDINS_DEFAULT_LIB@ -MONO_ADDINS_GUI_DEFAULT_LIB = @MONO_ADDINS_GUI_DEFAULT_LIB@ -MONO_ADDINS_SETUP_DEFAULT_LIB = @MONO_ADDINS_SETUP_DEFAULT_LIB@ -MONO_NUNIT_CFLAGS = @MONO_NUNIT_CFLAGS@ -MONO_NUNIT_LIBS = @MONO_NUNIT_LIBS@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PKG_CONFIG = @PKG_CONFIG@ -POLICY_VERSIONS = @POLICY_VERSIONS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -am__leading_dot = @am__leading_dot@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build_alias = @build_alias@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host_alias = @host_alias@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -SUBDIRS = WriterService WriterServiceHost WriterService.SampleExtender TextEditorLib TextEditor.Xml TextEditor.CompilerService TextEditor.CompilerService.CSharp TextEditor -all: all-recursive - -.SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign ./Samples/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign ./Samples/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -# This directory's subdirectories are mostly independent; you can cd -# into them and run `make' without going through this Makefile. -# To change the values of `make' variables: instead of editing Makefiles, -# (1) if the variable is set in `config.status', edit `config.status' -# (which will cause the Makefiles to be regenerated when you run `make'); -# (2) otherwise, pass the desired values on the `make' command line. -$(RECURSIVE_TARGETS): - @failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -$(RECURSIVE_CLEAN_TARGETS): - @failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - rev=''; for subdir in $$list; do \ - if test "$$subdir" = "."; then :; else \ - rev="$$subdir $$rev"; \ - fi; \ - done; \ - rev="$$rev ."; \ - target=`echo $@ | sed s/-recursive//`; \ - for subdir in $$rev; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done && test -z "$$fail" -tags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ - done -ctags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ - done - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique; \ - fi -ctags: CTAGS -CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$tags$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$tags $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done - list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - distdir=`$(am__cd) $(distdir) && pwd`; \ - top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ - (cd $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$top_distdir" \ - distdir="$$distdir/$$subdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - distdir) \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-recursive -all-am: Makefile -installdirs: installdirs-recursive -installdirs-am: -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic mostlyclean-am - -distclean: distclean-recursive - -rm -f Makefile -distclean-am: clean-am distclean-generic distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -info: info-recursive - -info-am: - -install-data-am: - -install-dvi: install-dvi-recursive - -install-exec-am: - -install-html: install-html-recursive - -install-info: install-info-recursive - -install-man: - -install-pdf: install-pdf-recursive - -install-ps: install-ps-recursive - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-generic - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: - -.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \ - install-strip - -.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ - all all-am check check-am clean clean-generic ctags \ - ctags-recursive distclean distclean-generic distclean-tags \ - distdir dvi dvi-am html html-am info info-am install \ - install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - installdirs-am maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-generic pdf pdf-am ps ps-am tags \ - tags-recursive uninstall uninstall-am - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff -Nru mono-addins-0.4/Samples/TextEditor/AssemblyInfo.cs mono-addins-0.6.1/Samples/TextEditor/AssemblyInfo.cs --- mono-addins-0.4/Samples/TextEditor/AssemblyInfo.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditor/AssemblyInfo.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using Mono.Addins; - -// Information about this assembly is defined by the following -// attributes. -// -// change them to the information which is associated with the assembly -// you compile. - -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has following format : -// -// Major.Minor.Build.Revision -// -// You can specify all values by your own or you can build default build and revision -// numbers with the '*' character (the default): - -[assembly: AssemblyVersion("1.0.0.0")] - -// The following attributes specify the key for the sign of your assembly. See the -// .NET Framework documentation for more information about signing. -// This is not required, if you don't want signing let these attributes like they're. -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] diff -Nru mono-addins-0.4/Samples/TextEditor/Main.cs mono-addins-0.6.1/Samples/TextEditor/Main.cs --- mono-addins-0.4/Samples/TextEditor/Main.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditor/Main.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -using System; -using Gtk; -using Mono.Addins; - -namespace TextEditor -{ - class MainClass - { - public static void Main (string[] args) - { - Application.Init (); - - AddinManager.AddinLoadError += OnLoadError; - AddinManager.AddinLoaded += OnLoad; - AddinManager.AddinUnloaded += OnUnload; - - AddinManager.Initialize (); - AddinManager.Registry.Update (null); - AddinManager.ExtensionChanged += OnExtensionChange; - - - MainWindow win = new MainWindow (); - - foreach (ICommand cmd in AddinManager.GetExtensionObjects ("/TextEditor/StartupCommands")) - cmd.Run (); - - win.Show (); - Application.Run (); - } - - static void OnLoadError (object s, AddinErrorEventArgs args) - { - Console.WriteLine ("Add-in error: " + args.Message); - Console.WriteLine (args.AddinId); - Console.WriteLine (args.Exception); - } - - static void OnLoad (object s, AddinEventArgs args) - { - Console.WriteLine ("Add-in loaded: " + args.AddinId); - } - - static void OnUnload (object s, AddinEventArgs args) - { - Console.WriteLine ("Add-in unloaded: " + args.AddinId); - } - - static void OnExtensionChange (object s, ExtensionEventArgs args) - { - Console.WriteLine ("Extension changed: " + args.Path); - } - } -} \ No newline at end of file diff -Nru mono-addins-0.4/Samples/TextEditor/Makefile.am mono-addins-0.6.1/Samples/TextEditor/Makefile.am --- mono-addins-0.4/Samples/TextEditor/Makefile.am 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditor/Makefile.am 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ - -ASSEMBLY_COMPILER_COMMAND = mcs -ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG -ASSEMBLY = ../bin/TextEditor.exe -COMPILE_TARGET = exe -PROJECT_REFERENCES = \ - ../../bin/Mono.Addins.dll \ - ../bin/TextEditorLib.dll -BUILD_DIR = ../bin - - -if ENABLE_GUI -all: $(ASSEMBLY) -endif - -FILES = \ - AssemblyInfo.cs \ - Main.cs - -DATA_FILES = - -RESOURCES = - -EXTRAS = - -REFERENCES = \ - -pkg:gtk-sharp-2.0 \ - -r:Mono.Posix \ - -r:System - -DLL_REFERENCES = - -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) - mkdir -p $(dir $(ASSEMBLY)) - - $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) - -if ENABLE_GUI -include $(top_srcdir)/makefile-sample.include -endif diff -Nru mono-addins-0.4/Samples/TextEditor/Makefile.in mono-addins-0.6.1/Samples/TextEditor/Makefile.in --- mono-addins-0.4/Samples/TextEditor/Makefile.in 2008-11-06 19:52:35.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditor/Makefile.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,336 +0,0 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(top_srcdir)/makefile-sample.include -subdir = ./Samples/TextEditor -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = -SOURCES = -DIST_SOURCES = -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AL = @AL@ -AMTAR = @AMTAR@ -API_VERSION = @API_VERSION@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -GACUTIL = @GACUTIL@ -GACUTIL_FLAGS = @GACUTIL_FLAGS@ -GACUTIL_POLICY_FLAGS = @GACUTIL_POLICY_FLAGS@ -GTK_SHARP_20_CFLAGS = @GTK_SHARP_20_CFLAGS@ -GTK_SHARP_20_LIBS = @GTK_SHARP_20_LIBS@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MCS = @MCS@ -MKDIR_P = @MKDIR_P@ -MONO_ADDINS_DEFAULT_LIB = @MONO_ADDINS_DEFAULT_LIB@ -MONO_ADDINS_GUI_DEFAULT_LIB = @MONO_ADDINS_GUI_DEFAULT_LIB@ -MONO_ADDINS_SETUP_DEFAULT_LIB = @MONO_ADDINS_SETUP_DEFAULT_LIB@ -MONO_NUNIT_CFLAGS = @MONO_NUNIT_CFLAGS@ -MONO_NUNIT_LIBS = @MONO_NUNIT_LIBS@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PKG_CONFIG = @PKG_CONFIG@ -POLICY_VERSIONS = @POLICY_VERSIONS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -am__leading_dot = @am__leading_dot@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build_alias = @build_alias@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host_alias = @host_alias@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -ASSEMBLY_COMPILER_COMMAND = mcs -ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG -ASSEMBLY = ../bin/TextEditor.exe -COMPILE_TARGET = exe -PROJECT_REFERENCES = \ - ../../bin/Mono.Addins.dll \ - ../bin/TextEditorLib.dll - -BUILD_DIR = ../bin -FILES = \ - AssemblyInfo.cs \ - Main.cs - -DATA_FILES = -RESOURCES = -EXTRAS = -REFERENCES = \ - -pkg:gtk-sharp-2.0 \ - -r:Mono.Posix \ - -r:System - -DLL_REFERENCES = -@ENABLE_GUI_TRUE@build_sources = $(addprefix $(srcdir)/, $(FILES) $(GENERATED_FILES)) -@ENABLE_GUI_TRUE@build_resources = $(addprefix $(srcdir)/, $(RESOURCES)) -@ENABLE_GUI_TRUE@build_resources_embed = $(foreach res,$(build_resources), $(addprefix -resource:,$(res)),$(RESOURCES_PREFIX)$(notdir $(res))) -@ENABLE_GUI_TRUE@build_references_ref = $(REFERENCES) $(foreach ref, \ -@ENABLE_GUI_TRUE@ $(DLL_REFERENCES), -r:$(ref)) $(foreach ref, \ -@ENABLE_GUI_TRUE@ $(PROJECT_REFERENCES), -r:$(ref)) -@ENABLE_GUI_TRUE@pc_files = $(PC_FILES_IN:.pc.in=.pc) -@ENABLE_GUI_TRUE@build_datafiles = $(addprefix $(BUILD_DIR)/, $(DATA_FILES)) -@ENABLE_GUI_TRUE@EXTRA_DIST = $(FILES) $(GENERATED_FILES) $(RESOURCES) $(ASSEMBLY_WRAPPER_IN) $(EXTRAS) $(DATA_FILES) $(PC_FILES_IN) -@ENABLE_GUI_TRUE@CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb $(DLL_REFERENCES) -@ENABLE_GUI_TRUE@DISTCLEANFILES = $(GENERATED_FILES) $(build_datafiles) $(pc_files) -all: all-am - -.SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/makefile-sample.include $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign ./Samples/TextEditor/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign ./Samples/TextEditor/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -tags: TAGS -TAGS: - -ctags: CTAGS -CTAGS: - - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic mostlyclean-am - -distclean: distclean-am - -rm -f Makefile -distclean-am: clean-am distclean-generic - -dvi: dvi-am - -dvi-am: - -html: html-am - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-exec-am: - -install-html: install-html-am - -install-info: install-info-am - -install-man: - -install-pdf: install-pdf-am - -install-ps: install-ps-am - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-generic - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: install-am install-strip - -.PHONY: all all-am check check-am clean clean-generic distclean \ - distclean-generic distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am - - -@ENABLE_GUI_TRUE@all: $(ASSEMBLY) - -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) - mkdir -p $(dir $(ASSEMBLY)) - - $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) - -@ENABLE_GUI_TRUE@$(build_datafiles): $(BUILD_DIR)/% : $(addprefix $(srcdir)/, %) -@ENABLE_GUI_TRUE@ mkdir -p $(dir $@) -@ENABLE_GUI_TRUE@ cp $< $@ -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff -Nru mono-addins-0.4/Samples/TextEditor.CompilerService/AssemblyInfo.cs mono-addins-0.6.1/Samples/TextEditor.CompilerService/AssemblyInfo.cs --- mono-addins-0.4/Samples/TextEditor.CompilerService/AssemblyInfo.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditor.CompilerService/AssemblyInfo.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following -// attributes. -// -// change them to the information which is associated with the assembly -// you compile. - -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has following format : -// -// Major.Minor.Build.Revision -// -// You can specify all values by your own or you can build default build and revision -// numbers with the '*' character (the default): - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes specify the key for the sign of your assembly. See the -// .NET Framework documentation for more information about signing. -// This is not required, if you don't want signing let these attributes like they're. -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] diff -Nru mono-addins-0.4/Samples/TextEditor.CompilerService/CompilerManager.cs mono-addins-0.6.1/Samples/TextEditor.CompilerService/CompilerManager.cs --- mono-addins-0.4/Samples/TextEditor.CompilerService/CompilerManager.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditor.CompilerService/CompilerManager.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ - -using System; -using Mono.Addins; - -namespace TextEditor.CompilerService -{ - public class CompilerManager - { - public static void Run (string file) - { - ICompiler[] compilers = (ICompiler[]) AddinManager.GetExtensionObjects (typeof(ICompiler)); - - ICompiler compiler = null; - foreach (ICompiler comp in compilers) { - if (comp.CanCompile (file)) { - compiler = comp; - break; - } - } - if (compiler == null) { - string msg = "No compiler available for this kind of file."; - Gtk.MessageDialog dlg = new Gtk.MessageDialog (TextEditorApp.MainWindow, Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.Close, msg); - dlg.Run (); - dlg.Destroy (); - return; - } - - string messages = compiler.Compile (file, file + ".exe"); - - TextEditorApp.MainWindow.ConsoleWrite ("Compilation finished.\n"); - TextEditorApp.MainWindow.ConsoleWrite (messages); - } - } -} diff -Nru mono-addins-0.4/Samples/TextEditor.CompilerService/ICompiler.cs mono-addins-0.6.1/Samples/TextEditor.CompilerService/ICompiler.cs --- mono-addins-0.4/Samples/TextEditor.CompilerService/ICompiler.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditor.CompilerService/ICompiler.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ - -using System; -using Mono.Addins; - -namespace TextEditor.CompilerService -{ - [TypeExtensionPoint] - public interface ICompiler - { - bool CanCompile (string file); - string Compile (string file, string outFile); - } -} diff -Nru mono-addins-0.4/Samples/TextEditor.CompilerService/Makefile.am mono-addins-0.6.1/Samples/TextEditor.CompilerService/Makefile.am --- mono-addins-0.4/Samples/TextEditor.CompilerService/Makefile.am 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditor.CompilerService/Makefile.am 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ - -ASSEMBLY_COMPILER_COMMAND = mcs -ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG -ASSEMBLY = ../bin/TextEditor.CompilerService.dll -COMPILE_TARGET = library -PROJECT_REFERENCES = \ - ../../bin/Mono.Addins.dll \ - ../bin/TextEditorLib.dll -BUILD_DIR = ../bin - - -if ENABLE_GUI -all: $(ASSEMBLY) -endif - -FILES = \ - AssemblyInfo.cs \ - CompilerManager.cs \ - ICompiler.cs \ - RunCommand.cs - -DATA_FILES = - -RESOURCES = TextEditor.CompilerService.addin.xml - -EXTRAS = - -REFERENCES = \ - -pkg:gtk-sharp-2.0 \ - -r:System - -DLL_REFERENCES = - -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) - mkdir -p $(dir $(ASSEMBLY)) - - $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) - -if ENABLE_GUI -include $(top_srcdir)/makefile-sample.include -endif diff -Nru mono-addins-0.4/Samples/TextEditor.CompilerService/Makefile.in mono-addins-0.6.1/Samples/TextEditor.CompilerService/Makefile.in --- mono-addins-0.4/Samples/TextEditor.CompilerService/Makefile.in 2008-11-06 19:52:35.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditor.CompilerService/Makefile.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,337 +0,0 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(top_srcdir)/makefile-sample.include -subdir = ./Samples/TextEditor.CompilerService -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = -SOURCES = -DIST_SOURCES = -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AL = @AL@ -AMTAR = @AMTAR@ -API_VERSION = @API_VERSION@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -GACUTIL = @GACUTIL@ -GACUTIL_FLAGS = @GACUTIL_FLAGS@ -GACUTIL_POLICY_FLAGS = @GACUTIL_POLICY_FLAGS@ -GTK_SHARP_20_CFLAGS = @GTK_SHARP_20_CFLAGS@ -GTK_SHARP_20_LIBS = @GTK_SHARP_20_LIBS@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MCS = @MCS@ -MKDIR_P = @MKDIR_P@ -MONO_ADDINS_DEFAULT_LIB = @MONO_ADDINS_DEFAULT_LIB@ -MONO_ADDINS_GUI_DEFAULT_LIB = @MONO_ADDINS_GUI_DEFAULT_LIB@ -MONO_ADDINS_SETUP_DEFAULT_LIB = @MONO_ADDINS_SETUP_DEFAULT_LIB@ -MONO_NUNIT_CFLAGS = @MONO_NUNIT_CFLAGS@ -MONO_NUNIT_LIBS = @MONO_NUNIT_LIBS@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PKG_CONFIG = @PKG_CONFIG@ -POLICY_VERSIONS = @POLICY_VERSIONS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -am__leading_dot = @am__leading_dot@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build_alias = @build_alias@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host_alias = @host_alias@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -ASSEMBLY_COMPILER_COMMAND = mcs -ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG -ASSEMBLY = ../bin/TextEditor.CompilerService.dll -COMPILE_TARGET = library -PROJECT_REFERENCES = \ - ../../bin/Mono.Addins.dll \ - ../bin/TextEditorLib.dll - -BUILD_DIR = ../bin -FILES = \ - AssemblyInfo.cs \ - CompilerManager.cs \ - ICompiler.cs \ - RunCommand.cs - -DATA_FILES = -RESOURCES = TextEditor.CompilerService.addin.xml -EXTRAS = -REFERENCES = \ - -pkg:gtk-sharp-2.0 \ - -r:System - -DLL_REFERENCES = -@ENABLE_GUI_TRUE@build_sources = $(addprefix $(srcdir)/, $(FILES) $(GENERATED_FILES)) -@ENABLE_GUI_TRUE@build_resources = $(addprefix $(srcdir)/, $(RESOURCES)) -@ENABLE_GUI_TRUE@build_resources_embed = $(foreach res,$(build_resources), $(addprefix -resource:,$(res)),$(RESOURCES_PREFIX)$(notdir $(res))) -@ENABLE_GUI_TRUE@build_references_ref = $(REFERENCES) $(foreach ref, \ -@ENABLE_GUI_TRUE@ $(DLL_REFERENCES), -r:$(ref)) $(foreach ref, \ -@ENABLE_GUI_TRUE@ $(PROJECT_REFERENCES), -r:$(ref)) -@ENABLE_GUI_TRUE@pc_files = $(PC_FILES_IN:.pc.in=.pc) -@ENABLE_GUI_TRUE@build_datafiles = $(addprefix $(BUILD_DIR)/, $(DATA_FILES)) -@ENABLE_GUI_TRUE@EXTRA_DIST = $(FILES) $(GENERATED_FILES) $(RESOURCES) $(ASSEMBLY_WRAPPER_IN) $(EXTRAS) $(DATA_FILES) $(PC_FILES_IN) -@ENABLE_GUI_TRUE@CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb $(DLL_REFERENCES) -@ENABLE_GUI_TRUE@DISTCLEANFILES = $(GENERATED_FILES) $(build_datafiles) $(pc_files) -all: all-am - -.SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/makefile-sample.include $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign ./Samples/TextEditor.CompilerService/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign ./Samples/TextEditor.CompilerService/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -tags: TAGS -TAGS: - -ctags: CTAGS -CTAGS: - - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic mostlyclean-am - -distclean: distclean-am - -rm -f Makefile -distclean-am: clean-am distclean-generic - -dvi: dvi-am - -dvi-am: - -html: html-am - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-exec-am: - -install-html: install-html-am - -install-info: install-info-am - -install-man: - -install-pdf: install-pdf-am - -install-ps: install-ps-am - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-generic - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: install-am install-strip - -.PHONY: all all-am check check-am clean clean-generic distclean \ - distclean-generic distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am - - -@ENABLE_GUI_TRUE@all: $(ASSEMBLY) - -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) - mkdir -p $(dir $(ASSEMBLY)) - - $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) - -@ENABLE_GUI_TRUE@$(build_datafiles): $(BUILD_DIR)/% : $(addprefix $(srcdir)/, %) -@ENABLE_GUI_TRUE@ mkdir -p $(dir $@) -@ENABLE_GUI_TRUE@ cp $< $@ -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff -Nru mono-addins-0.4/Samples/TextEditor.CompilerService/RunCommand.cs mono-addins-0.6.1/Samples/TextEditor.CompilerService/RunCommand.cs --- mono-addins-0.4/Samples/TextEditor.CompilerService/RunCommand.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditor.CompilerService/RunCommand.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ - -using System; -using TextEditor; -using Mono.Addins; - -namespace TextEditor.CompilerService -{ - public class RunCommand: ICommand - { - public void Run () - { - CompilerManager.Run (TextEditorApp.OpenFileName); - } - } -} diff -Nru mono-addins-0.4/Samples/TextEditor.CompilerService/TextEditor.CompilerService.addin.xml mono-addins-0.6.1/Samples/TextEditor.CompilerService/TextEditor.CompilerService.addin.xml --- mono-addins-0.4/Samples/TextEditor.CompilerService/TextEditor.CompilerService.addin.xml 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditor.CompilerService/TextEditor.CompilerService.addin.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ - - - - - - - - diff -Nru mono-addins-0.4/Samples/TextEditor.CompilerService.CSharp/AssemblyInfo.cs mono-addins-0.6.1/Samples/TextEditor.CompilerService.CSharp/AssemblyInfo.cs --- mono-addins-0.4/Samples/TextEditor.CompilerService.CSharp/AssemblyInfo.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditor.CompilerService.CSharp/AssemblyInfo.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following -// attributes. -// -// change them to the information which is associated with the assembly -// you compile. - -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has following format : -// -// Major.Minor.Build.Revision -// -// You can specify all values by your own or you can build default build and revision -// numbers with the '*' character (the default): - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes specify the key for the sign of your assembly. See the -// .NET Framework documentation for more information about signing. -// This is not required, if you don't want signing let these attributes like they're. -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] diff -Nru mono-addins-0.4/Samples/TextEditor.CompilerService.CSharp/CSharpCompiler.cs mono-addins-0.6.1/Samples/TextEditor.CompilerService.CSharp/CSharpCompiler.cs --- mono-addins-0.4/Samples/TextEditor.CompilerService.CSharp/CSharpCompiler.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditor.CompilerService.CSharp/CSharpCompiler.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -using System; -using System.IO; -using System.Diagnostics; -using Mono.Addins; -using TextEditor.CompilerService; - -[assembly:Addin] -[assembly:AddinDependency ("TextEditor.CompilerService", "1.0")] - -namespace TextEditor.CompilerService.CSharp -{ - [Extension] - public class CSharpCompiler: ICompiler - { - public bool CanCompile (string file) - { - return Path.GetExtension (file) == ".cs"; - } - - public string Compile (string file, string outFile) - { - string messages = ""; - - ProcessStartInfo ps = new ProcessStartInfo (); - ps.FileName = "mcs"; - ps.Arguments = "file"; - ps.UseShellExecute = false; - ps.RedirectStandardOutput = true; - Process p = Process.Start (ps); - - string line = null; - while ((line = p.StandardOutput.ReadLine ()) != null) { - messages += line + "\n"; - } - return messages; - } - } -} \ No newline at end of file diff -Nru mono-addins-0.4/Samples/TextEditor.CompilerService.CSharp/Makefile.am mono-addins-0.6.1/Samples/TextEditor.CompilerService.CSharp/Makefile.am --- mono-addins-0.4/Samples/TextEditor.CompilerService.CSharp/Makefile.am 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditor.CompilerService.CSharp/Makefile.am 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ - -ASSEMBLY_COMPILER_COMMAND = mcs -ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG -ASSEMBLY = ../bin/TextEditor.CompilerService.CSharp.dll -COMPILE_TARGET = library -PROJECT_REFERENCES = \ - ../../bin/Mono.Addins.dll \ - ../bin/TextEditor.CompilerService.dll -BUILD_DIR = ../bin - - -if ENABLE_GUI -all: $(ASSEMBLY) -endif - -FILES = \ - AssemblyInfo.cs \ - CSharpCompiler.cs - -DATA_FILES = - -RESOURCES = - -EXTRAS = - -REFERENCES = -r:System - -DLL_REFERENCES = - -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) - mkdir -p $(dir $(ASSEMBLY)) - - $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) - -if ENABLE_GUI -include $(top_srcdir)/makefile-sample.include -endif diff -Nru mono-addins-0.4/Samples/TextEditor.CompilerService.CSharp/Makefile.in mono-addins-0.6.1/Samples/TextEditor.CompilerService.CSharp/Makefile.in --- mono-addins-0.4/Samples/TextEditor.CompilerService.CSharp/Makefile.in 2008-11-06 19:52:35.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditor.CompilerService.CSharp/Makefile.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,332 +0,0 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(top_srcdir)/makefile-sample.include -subdir = ./Samples/TextEditor.CompilerService.CSharp -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = -SOURCES = -DIST_SOURCES = -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AL = @AL@ -AMTAR = @AMTAR@ -API_VERSION = @API_VERSION@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -GACUTIL = @GACUTIL@ -GACUTIL_FLAGS = @GACUTIL_FLAGS@ -GACUTIL_POLICY_FLAGS = @GACUTIL_POLICY_FLAGS@ -GTK_SHARP_20_CFLAGS = @GTK_SHARP_20_CFLAGS@ -GTK_SHARP_20_LIBS = @GTK_SHARP_20_LIBS@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MCS = @MCS@ -MKDIR_P = @MKDIR_P@ -MONO_ADDINS_DEFAULT_LIB = @MONO_ADDINS_DEFAULT_LIB@ -MONO_ADDINS_GUI_DEFAULT_LIB = @MONO_ADDINS_GUI_DEFAULT_LIB@ -MONO_ADDINS_SETUP_DEFAULT_LIB = @MONO_ADDINS_SETUP_DEFAULT_LIB@ -MONO_NUNIT_CFLAGS = @MONO_NUNIT_CFLAGS@ -MONO_NUNIT_LIBS = @MONO_NUNIT_LIBS@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PKG_CONFIG = @PKG_CONFIG@ -POLICY_VERSIONS = @POLICY_VERSIONS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -am__leading_dot = @am__leading_dot@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build_alias = @build_alias@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host_alias = @host_alias@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -ASSEMBLY_COMPILER_COMMAND = mcs -ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG -ASSEMBLY = ../bin/TextEditor.CompilerService.CSharp.dll -COMPILE_TARGET = library -PROJECT_REFERENCES = \ - ../../bin/Mono.Addins.dll \ - ../bin/TextEditor.CompilerService.dll - -BUILD_DIR = ../bin -FILES = \ - AssemblyInfo.cs \ - CSharpCompiler.cs - -DATA_FILES = -RESOURCES = -EXTRAS = -REFERENCES = -r:System -DLL_REFERENCES = -@ENABLE_GUI_TRUE@build_sources = $(addprefix $(srcdir)/, $(FILES) $(GENERATED_FILES)) -@ENABLE_GUI_TRUE@build_resources = $(addprefix $(srcdir)/, $(RESOURCES)) -@ENABLE_GUI_TRUE@build_resources_embed = $(foreach res,$(build_resources), $(addprefix -resource:,$(res)),$(RESOURCES_PREFIX)$(notdir $(res))) -@ENABLE_GUI_TRUE@build_references_ref = $(REFERENCES) $(foreach ref, \ -@ENABLE_GUI_TRUE@ $(DLL_REFERENCES), -r:$(ref)) $(foreach ref, \ -@ENABLE_GUI_TRUE@ $(PROJECT_REFERENCES), -r:$(ref)) -@ENABLE_GUI_TRUE@pc_files = $(PC_FILES_IN:.pc.in=.pc) -@ENABLE_GUI_TRUE@build_datafiles = $(addprefix $(BUILD_DIR)/, $(DATA_FILES)) -@ENABLE_GUI_TRUE@EXTRA_DIST = $(FILES) $(GENERATED_FILES) $(RESOURCES) $(ASSEMBLY_WRAPPER_IN) $(EXTRAS) $(DATA_FILES) $(PC_FILES_IN) -@ENABLE_GUI_TRUE@CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb $(DLL_REFERENCES) -@ENABLE_GUI_TRUE@DISTCLEANFILES = $(GENERATED_FILES) $(build_datafiles) $(pc_files) -all: all-am - -.SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/makefile-sample.include $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign ./Samples/TextEditor.CompilerService.CSharp/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign ./Samples/TextEditor.CompilerService.CSharp/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -tags: TAGS -TAGS: - -ctags: CTAGS -CTAGS: - - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic mostlyclean-am - -distclean: distclean-am - -rm -f Makefile -distclean-am: clean-am distclean-generic - -dvi: dvi-am - -dvi-am: - -html: html-am - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-exec-am: - -install-html: install-html-am - -install-info: install-info-am - -install-man: - -install-pdf: install-pdf-am - -install-ps: install-ps-am - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-generic - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: install-am install-strip - -.PHONY: all all-am check check-am clean clean-generic distclean \ - distclean-generic distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am - - -@ENABLE_GUI_TRUE@all: $(ASSEMBLY) - -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) - mkdir -p $(dir $(ASSEMBLY)) - - $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) - -@ENABLE_GUI_TRUE@$(build_datafiles): $(BUILD_DIR)/% : $(addprefix $(srcdir)/, %) -@ENABLE_GUI_TRUE@ mkdir -p $(dir $@) -@ENABLE_GUI_TRUE@ cp $< $@ -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff -Nru mono-addins-0.4/Samples/TextEditorLib/AssemblyInfo.cs mono-addins-0.6.1/Samples/TextEditorLib/AssemblyInfo.cs --- mono-addins-0.4/Samples/TextEditorLib/AssemblyInfo.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/AssemblyInfo.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using Mono.Addins; - -// Information about this assembly is defined by the following -// attributes. -// -// change them to the information which is associated with the assembly -// you compile. - -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has following format : -// -// Major.Minor.Build.Revision -// -// You can specify all values by your own or you can build default build and revision -// numbers with the '*' character (the default): - -[assembly: AssemblyVersion("1.0.0.0")] - -// The following attributes specify the key for the sign of your assembly. See the -// .NET Framework documentation for more information about signing. -// This is not required, if you don't want signing let these attributes like they're. -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] - - - - diff -Nru mono-addins-0.4/Samples/TextEditorLib/Commands/CopyCommand.cs mono-addins-0.6.1/Samples/TextEditorLib/Commands/CopyCommand.cs --- mono-addins-0.4/Samples/TextEditorLib/Commands/CopyCommand.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/Commands/CopyCommand.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ - -using System; - -namespace TextEditor -{ - public class CopyCommand: ICommand - { - public void Run () - { - Gtk.Clipboard clipboard = Gtk.Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false)); - TextEditorApp.MainWindow.View.Buffer.CopyClipboard (clipboard); - } - } -} diff -Nru mono-addins-0.4/Samples/TextEditorLib/Commands/CutCommand.cs mono-addins-0.6.1/Samples/TextEditorLib/Commands/CutCommand.cs --- mono-addins-0.4/Samples/TextEditorLib/Commands/CutCommand.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/Commands/CutCommand.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ - -using System; - -namespace TextEditor -{ - - - public class CutCommand: ICommand - { - public void Run () - { - Gtk.Clipboard clipboard = Gtk.Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false)); - TextEditorApp.MainWindow.View.Buffer.CutClipboard (clipboard, true); - } - } -} diff -Nru mono-addins-0.4/Samples/TextEditorLib/Commands/ExitCommand.cs mono-addins-0.6.1/Samples/TextEditorLib/Commands/ExitCommand.cs --- mono-addins-0.4/Samples/TextEditorLib/Commands/ExitCommand.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/Commands/ExitCommand.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ - -using System; - -namespace TextEditor -{ - public class ExitCommand: ICommand - { - public void Run () - { - Gtk.Application.Quit (); - } - } -} diff -Nru mono-addins-0.4/Samples/TextEditorLib/Commands/NewCommand.cs mono-addins-0.6.1/Samples/TextEditorLib/Commands/NewCommand.cs --- mono-addins-0.4/Samples/TextEditorLib/Commands/NewCommand.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/Commands/NewCommand.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ - -using System; - -namespace TextEditor -{ - public class NewCommand: ICommand - { - public void Run () - { - TextEditorApp.NewFile (""); - } - } -} diff -Nru mono-addins-0.4/Samples/TextEditorLib/Commands/OpenCommand.cs mono-addins-0.6.1/Samples/TextEditorLib/Commands/OpenCommand.cs --- mono-addins-0.4/Samples/TextEditorLib/Commands/OpenCommand.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/Commands/OpenCommand.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ - -using System; -using System.IO; - -namespace TextEditor -{ - public class OpenCommand: ICommand - { - public void Run () - { - Gtk.FileChooserDialog fcd = new Gtk.FileChooserDialog ("Open File", null, Gtk.FileChooserAction.Open); - fcd.AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel); - fcd.AddButton (Gtk.Stock.Open, Gtk.ResponseType.Ok); - fcd.DefaultResponse = Gtk.ResponseType.Ok; - fcd.SelectMultiple = false; - - Gtk.ResponseType response = (Gtk.ResponseType) fcd.Run (); - if (response == Gtk.ResponseType.Ok) - TextEditorApp.OpenFile (fcd.Filename); - fcd.Destroy (); - } - } -} diff -Nru mono-addins-0.4/Samples/TextEditorLib/Commands/PasteCommand.cs mono-addins-0.6.1/Samples/TextEditorLib/Commands/PasteCommand.cs --- mono-addins-0.4/Samples/TextEditorLib/Commands/PasteCommand.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/Commands/PasteCommand.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ - -using System; - -namespace TextEditor -{ - public class PasteCommand: ICommand - { - public void Run () - { - Gtk.Clipboard clipboard = Gtk.Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false)); - TextEditorApp.MainWindow.View.Buffer.PasteClipboard (clipboard); - } - } -} diff -Nru mono-addins-0.4/Samples/TextEditorLib/Commands/SaveCommand.cs mono-addins-0.6.1/Samples/TextEditorLib/Commands/SaveCommand.cs --- mono-addins-0.4/Samples/TextEditorLib/Commands/SaveCommand.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/Commands/SaveCommand.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ - -using System; - -namespace TextEditor -{ - public class SaveCommand: ICommand - { - public void Run () - { - TextEditorApp.SaveFile (); - } - } -} diff -Nru mono-addins-0.4/Samples/TextEditorLib/Commands/SetupCommand.cs mono-addins-0.6.1/Samples/TextEditorLib/Commands/SetupCommand.cs --- mono-addins-0.4/Samples/TextEditorLib/Commands/SetupCommand.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/Commands/SetupCommand.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ - -using System; -using Mono.Addins.Gui; - -namespace TextEditor -{ - public class SetupCommand: ICommand - { - public void Run () - { - AddinManagerWindow.Run (TextEditorApp.MainWindow); - } - } -} diff -Nru mono-addins-0.4/Samples/TextEditorLib/ExtensionNodes/FileTemplateNode.cs mono-addins-0.6.1/Samples/TextEditorLib/ExtensionNodes/FileTemplateNode.cs --- mono-addins-0.4/Samples/TextEditorLib/ExtensionNodes/FileTemplateNode.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/ExtensionNodes/FileTemplateNode.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ - -using System; -using System.IO; -using Mono.Addins; - -namespace TextEditor -{ - public class FileTemplateNode: ExtensionNode - { - [NodeAttribute] - string resource; - - [NodeAttribute] - string name; - - public string Name { - get { return name != null ? name : Id; } - } - - public virtual string GetContent () - { - using (StreamReader sr = new StreamReader(Addin.GetResource (resource))) { - return sr.ReadToEnd (); - } - } - } -} diff -Nru mono-addins-0.4/Samples/TextEditorLib/ExtensionNodes/MenuItemNode.cs mono-addins-0.6.1/Samples/TextEditorLib/ExtensionNodes/MenuItemNode.cs --- mono-addins-0.4/Samples/TextEditorLib/ExtensionNodes/MenuItemNode.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/ExtensionNodes/MenuItemNode.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ - -using System; -using Mono.Addins; - -namespace TextEditor -{ - [ExtensionNode ("MenuItem")] - public class MenuItemNode: MenuNode - { - [NodeAttribute] - string label; - - [NodeAttribute] - string icon; - - [NodeAttribute] - string commandType; - - static Gtk.AccelGroup accelGroup = new Gtk.AccelGroup (); - - public override Gtk.MenuItem GetMenuItem () - { - Gtk.MenuItem item; - if (icon != null) - item = new Gtk.ImageMenuItem (icon, accelGroup); - else - item = new Gtk.MenuItem (label); - item.Activated += OnClicked; - return item; - } - - void OnClicked (object s, EventArgs a) - { - ICommand command = (ICommand) Addin.CreateInstance (commandType); - command.Run (); - } - } -} diff -Nru mono-addins-0.4/Samples/TextEditorLib/ExtensionNodes/MenuNode.cs mono-addins-0.6.1/Samples/TextEditorLib/ExtensionNodes/MenuNode.cs --- mono-addins-0.4/Samples/TextEditorLib/ExtensionNodes/MenuNode.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/ExtensionNodes/MenuNode.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ - -using System; -using Mono.Addins; - -namespace TextEditor -{ - public abstract class MenuNode: ExtensionNode - { - // Abstract method to be implemented by subclasses, and which - // should return a menu item. - public abstract Gtk.MenuItem GetMenuItem (); - } -} diff -Nru mono-addins-0.4/Samples/TextEditorLib/ExtensionNodes/MenuSeparatorNode.cs mono-addins-0.6.1/Samples/TextEditorLib/ExtensionNodes/MenuSeparatorNode.cs --- mono-addins-0.4/Samples/TextEditorLib/ExtensionNodes/MenuSeparatorNode.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/ExtensionNodes/MenuSeparatorNode.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ - -using System; -using Mono.Addins; - -namespace TextEditor -{ - [ExtensionNode ("MenuSeparator")] - public class MenuSeparatorNode: MenuNode - { - public override Gtk.MenuItem GetMenuItem () - { - return new Gtk.SeparatorMenuItem (); - } - } -} diff -Nru mono-addins-0.4/Samples/TextEditorLib/ExtensionNodes/SubmenuNode.cs mono-addins-0.6.1/Samples/TextEditorLib/ExtensionNodes/SubmenuNode.cs --- mono-addins-0.4/Samples/TextEditorLib/ExtensionNodes/SubmenuNode.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/ExtensionNodes/SubmenuNode.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ - -using System; -using Mono.Addins; - -namespace TextEditor -{ - [ExtensionNode ("Menu")] - [ExtensionNodeChild (typeof(MenuItemNode))] - [ExtensionNodeChild (typeof(MenuSeparatorNode))] - [ExtensionNodeChild (typeof(SubmenuNode))] - public class SubmenuNode: MenuNode - { - [NodeAttribute] - string label; - - public override Gtk.MenuItem GetMenuItem () - { - Gtk.MenuItem it = new Gtk.MenuItem (label); - Gtk.Menu submenu = new Gtk.Menu (); - foreach (MenuNode node in ChildNodes) - submenu.Insert (node.GetMenuItem (), -1); - it.Submenu = submenu; - return it; - } - } -} diff -Nru mono-addins-0.4/Samples/TextEditorLib/ExtensionNodes/TemplateCategoryNode.cs mono-addins-0.6.1/Samples/TextEditorLib/ExtensionNodes/TemplateCategoryNode.cs --- mono-addins-0.4/Samples/TextEditorLib/ExtensionNodes/TemplateCategoryNode.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/ExtensionNodes/TemplateCategoryNode.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ - -using System; -using Mono.Addins; - -namespace TextEditor -{ - public class TemplateCategoryNode: ExtensionNode - { - [NodeAttribute] - string name; - - public string Name { - get { - if (name != null && name.Length > 0) - return name; - else - return Id; - } - } - } -} diff -Nru mono-addins-0.4/Samples/TextEditorLib/ExtensionNodes/ToolbarNode.cs mono-addins-0.6.1/Samples/TextEditorLib/ExtensionNodes/ToolbarNode.cs --- mono-addins-0.4/Samples/TextEditorLib/ExtensionNodes/ToolbarNode.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/ExtensionNodes/ToolbarNode.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ - -using System; -using Mono.Addins; - -namespace TextEditor -{ - public abstract class ToolbarNode: ExtensionNode - { - public abstract Gtk.ToolItem GetToolItem (); - } -} diff -Nru mono-addins-0.4/Samples/TextEditorLib/ExtensionNodes/ToolButtonNode.cs mono-addins-0.6.1/Samples/TextEditorLib/ExtensionNodes/ToolButtonNode.cs --- mono-addins-0.4/Samples/TextEditorLib/ExtensionNodes/ToolButtonNode.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/ExtensionNodes/ToolButtonNode.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ - -using System; -using Mono.Addins; - -namespace TextEditor -{ - public class ToolButtonNode: ToolbarNode - { - [NodeAttribute] - string icon; - - [NodeAttribute] - string commandType; - - public override Gtk.ToolItem GetToolItem () - { - Gtk.ToolButton but = new Gtk.ToolButton (icon); - but.Clicked += OnClicked; - return but; - } - - void OnClicked (object s, EventArgs a) - { - ICommand command = (ICommand) Addin.CreateInstance (commandType); - command.Run (); - } - } -} diff -Nru mono-addins-0.4/Samples/TextEditorLib/ExtensionNodes/ToolSeparatorNode.cs mono-addins-0.6.1/Samples/TextEditorLib/ExtensionNodes/ToolSeparatorNode.cs --- mono-addins-0.4/Samples/TextEditorLib/ExtensionNodes/ToolSeparatorNode.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/ExtensionNodes/ToolSeparatorNode.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ - -using System; - -namespace TextEditor -{ - public class ToolSeparatorNode: ToolbarNode - { - public override Gtk.ToolItem GetToolItem () - { - return new Gtk.SeparatorToolItem (); - } - } -} diff -Nru mono-addins-0.4/Samples/TextEditorLib/gtk-gui/generated.cs mono-addins-0.6.1/Samples/TextEditorLib/gtk-gui/generated.cs --- mono-addins-0.4/Samples/TextEditorLib/gtk-gui/generated.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/gtk-gui/generated.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Mono Runtime Version: 2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -namespace Stetic { - - - internal class Gui { - - private static bool initialized; - - internal static void Initialize(Gtk.Widget iconRenderer) { - if ((Stetic.Gui.initialized == false)) { - Stetic.Gui.initialized = true; - } - } - } - - internal class IconLoader { - - public static Gdk.Pixbuf LoadIcon(Gtk.Widget widget, string name, Gtk.IconSize size, int sz) { - Gdk.Pixbuf res = widget.RenderIcon(name, size, null); - if ((res != null)) { - return res; - } - else { - try { - return Gtk.IconTheme.Default.LoadIcon(name, sz, 0); - } - catch (System.Exception ) { - if ((name != "gtk-missing-image")) { - return Stetic.IconLoader.LoadIcon(widget, "gtk-missing-image", size, sz); - } - else { - Gdk.Pixmap pmap = new Gdk.Pixmap(Gdk.Screen.Default.RootWindow, sz, sz); - Gdk.GC gc = new Gdk.GC(pmap); - gc.RgbFgColor = new Gdk.Color(255, 255, 255); - pmap.DrawRectangle(gc, true, 0, 0, sz, sz); - gc.RgbFgColor = new Gdk.Color(0, 0, 0); - pmap.DrawRectangle(gc, false, 0, 0, (sz - 1), (sz - 1)); - gc.SetLineAttributes(3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round); - gc.RgbFgColor = new Gdk.Color(255, 0, 0); - pmap.DrawLine(gc, (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)), ((sz - 1) - (sz / 4))); - pmap.DrawLine(gc, ((sz - 1) - (sz / 4)), (sz / 4), (sz / 4), ((sz - 1) - (sz / 4))); - return Gdk.Pixbuf.FromDrawable(pmap, pmap.Colormap, 0, 0, 0, 0, sz, sz); - } - } - } - } - } - - internal class ActionGroups { - - public static Gtk.ActionGroup GetActionGroup(System.Type type) { - return Stetic.ActionGroups.GetActionGroup(type.FullName); - } - - public static Gtk.ActionGroup GetActionGroup(string name) { - return null; - } - } -} diff -Nru mono-addins-0.4/Samples/TextEditorLib/gtk-gui/gui.stetic mono-addins-0.6.1/Samples/TextEditorLib/gtk-gui/gui.stetic --- mono-addins-0.4/Samples/TextEditorLib/gtk-gui/gui.stetic 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/gtk-gui/gui.stetic 1970-01-01 00:00:00.000000000 +0000 @@ -1,161 +0,0 @@ - - - - .. - 2.8.3 - - - - - Text Editor - - - - - - - - - - - 0 - True - False - False - - - - - - False - Icons - LargeToolbar - - - - 1 - True - False - False - - - - - - True - Automatic - Automatic - In - - - - True - - - - - - 2 - True - - - - - - 6 - 6 - - - - - - - 0 - Console - - - 0 - True - False - False - - - - - - 27 - 20 - TextAndIcon - stock:gtk-close Menu - - True - False - None - - - - End - 1 - True - False - False - - - - - 0 - True - False - False - - - - - - True - Automatic - Automatic - In - - - - True - - - - - - 1 - True - - - - - 3 - False - False - False - - - - - - 2 - - - - - - - - - 4 - True - False - False - - - - - - \ No newline at end of file diff -Nru mono-addins-0.4/Samples/TextEditorLib/gtk-gui/MainWindow.cs mono-addins-0.6.1/Samples/TextEditorLib/gtk-gui/MainWindow.cs --- mono-addins-0.4/Samples/TextEditorLib/gtk-gui/MainWindow.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/gtk-gui/MainWindow.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,173 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Mono Runtime Version: 2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - - - -public partial class MainWindow { - - private Gtk.VBox vbox2; - - private Gtk.MenuBar menubar; - - private Gtk.Toolbar toolbar; - - private Gtk.ScrolledWindow scrolledwindow1; - - private Gtk.TextView textview; - - private Gtk.VBox console; - - private Gtk.HBox hbox1; - - private Gtk.Label label1; - - private Gtk.Button button1; - - private Gtk.ScrolledWindow scrolledwindow2; - - private Gtk.TextView consoleView; - - private Gtk.Statusbar statusbar1; - - protected virtual void Build() { - Stetic.Gui.Initialize(this); - // Widget MainWindow - Gtk.UIManager w1 = new Gtk.UIManager(); - Gtk.ActionGroup w2 = new Gtk.ActionGroup("Default"); - w1.InsertActionGroup(w2, 0); - this.AddAccelGroup(w1.AccelGroup); - this.Name = "MainWindow"; - this.Title = Mono.Unix.Catalog.GetString("Text Editor"); - // Container child MainWindow.Gtk.Container+ContainerChild - this.vbox2 = new Gtk.VBox(); - this.vbox2.Name = "vbox2"; - // Container child vbox2.Gtk.Box+BoxChild - w1.AddUiFromString(""); - this.menubar = ((Gtk.MenuBar)(w1.GetWidget("/menubar"))); - this.menubar.Name = "menubar"; - this.vbox2.Add(this.menubar); - Gtk.Box.BoxChild w3 = ((Gtk.Box.BoxChild)(this.vbox2[this.menubar])); - w3.Position = 0; - w3.Expand = false; - w3.Fill = false; - // Container child vbox2.Gtk.Box+BoxChild - w1.AddUiFromString(""); - this.toolbar = ((Gtk.Toolbar)(w1.GetWidget("/toolbar"))); - this.toolbar.Name = "toolbar"; - this.toolbar.ShowArrow = false; - this.toolbar.ToolbarStyle = ((Gtk.ToolbarStyle)(0)); - this.toolbar.IconSize = ((Gtk.IconSize)(3)); - this.vbox2.Add(this.toolbar); - Gtk.Box.BoxChild w4 = ((Gtk.Box.BoxChild)(this.vbox2[this.toolbar])); - w4.Position = 1; - w4.Expand = false; - w4.Fill = false; - // Container child vbox2.Gtk.Box+BoxChild - this.scrolledwindow1 = new Gtk.ScrolledWindow(); - this.scrolledwindow1.CanFocus = true; - this.scrolledwindow1.Name = "scrolledwindow1"; - this.scrolledwindow1.ShadowType = ((Gtk.ShadowType)(1)); - // Container child scrolledwindow1.Gtk.Container+ContainerChild - this.textview = new Gtk.TextView(); - this.textview.CanFocus = true; - this.textview.Name = "textview"; - this.scrolledwindow1.Add(this.textview); - this.vbox2.Add(this.scrolledwindow1); - Gtk.Box.BoxChild w6 = ((Gtk.Box.BoxChild)(this.vbox2[this.scrolledwindow1])); - w6.Position = 2; - // Container child vbox2.Gtk.Box+BoxChild - this.console = new Gtk.VBox(); - this.console.Name = "console"; - this.console.Spacing = 6; - this.console.BorderWidth = ((uint)(6)); - // Container child console.Gtk.Box+BoxChild - this.hbox1 = new Gtk.HBox(); - this.hbox1.Name = "hbox1"; - // Container child hbox1.Gtk.Box+BoxChild - this.label1 = new Gtk.Label(); - this.label1.Name = "label1"; - this.label1.Xalign = 0F; - this.label1.LabelProp = Mono.Unix.Catalog.GetString("Console"); - this.hbox1.Add(this.label1); - Gtk.Box.BoxChild w7 = ((Gtk.Box.BoxChild)(this.hbox1[this.label1])); - w7.Position = 0; - w7.Expand = false; - w7.Fill = false; - // Container child hbox1.Gtk.Box+BoxChild - this.button1 = new Gtk.Button(); - this.button1.WidthRequest = 27; - this.button1.HeightRequest = 20; - this.button1.Name = "button1"; - this.button1.UseUnderline = true; - this.button1.Relief = ((Gtk.ReliefStyle)(2)); - // Container child button1.Gtk.Container+ContainerChild - Gtk.Alignment w8 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F); - // Container child GtkAlignment.Gtk.Container+ContainerChild - Gtk.HBox w9 = new Gtk.HBox(); - w9.Spacing = 2; - // Container child GtkHBox.Gtk.Container+ContainerChild - Gtk.Image w10 = new Gtk.Image(); - w10.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-close", Gtk.IconSize.Menu, 16); - w9.Add(w10); - // Container child GtkHBox.Gtk.Container+ContainerChild - Gtk.Label w12 = new Gtk.Label(); - w12.LabelProp = ""; - w9.Add(w12); - w8.Add(w9); - this.button1.Add(w8); - this.hbox1.Add(this.button1); - Gtk.Box.BoxChild w16 = ((Gtk.Box.BoxChild)(this.hbox1[this.button1])); - w16.PackType = ((Gtk.PackType)(1)); - w16.Position = 1; - w16.Expand = false; - w16.Fill = false; - this.console.Add(this.hbox1); - Gtk.Box.BoxChild w17 = ((Gtk.Box.BoxChild)(this.console[this.hbox1])); - w17.Position = 0; - w17.Expand = false; - w17.Fill = false; - // Container child console.Gtk.Box+BoxChild - this.scrolledwindow2 = new Gtk.ScrolledWindow(); - this.scrolledwindow2.CanFocus = true; - this.scrolledwindow2.Name = "scrolledwindow2"; - this.scrolledwindow2.ShadowType = ((Gtk.ShadowType)(1)); - // Container child scrolledwindow2.Gtk.Container+ContainerChild - this.consoleView = new Gtk.TextView(); - this.consoleView.CanFocus = true; - this.consoleView.Name = "consoleView"; - this.scrolledwindow2.Add(this.consoleView); - this.console.Add(this.scrolledwindow2); - Gtk.Box.BoxChild w19 = ((Gtk.Box.BoxChild)(this.console[this.scrolledwindow2])); - w19.Position = 1; - this.vbox2.Add(this.console); - Gtk.Box.BoxChild w20 = ((Gtk.Box.BoxChild)(this.vbox2[this.console])); - w20.Position = 3; - w20.Expand = false; - w20.Fill = false; - // Container child vbox2.Gtk.Box+BoxChild - this.statusbar1 = new Gtk.Statusbar(); - this.statusbar1.Name = "statusbar1"; - this.statusbar1.Spacing = 2; - this.vbox2.Add(this.statusbar1); - Gtk.Box.BoxChild w21 = ((Gtk.Box.BoxChild)(this.vbox2[this.statusbar1])); - w21.Position = 4; - w21.Expand = false; - w21.Fill = false; - this.Add(this.vbox2); - if ((this.Child != null)) { - this.Child.ShowAll(); - } - this.DefaultWidth = 586; - this.DefaultHeight = 356; - this.Show(); - this.DeleteEvent += new Gtk.DeleteEventHandler(this.OnDeleteEvent); - this.button1.Clicked += new System.EventHandler(this.OnButton1Clicked); - } -} diff -Nru mono-addins-0.4/Samples/TextEditorLib/ICommand.cs mono-addins-0.6.1/Samples/TextEditorLib/ICommand.cs --- mono-addins-0.4/Samples/TextEditorLib/ICommand.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/ICommand.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ - -using System; -using Mono.Addins; - -namespace TextEditor -{ - [TypeExtensionPoint ("/TextEditor/StartupCommands")] - public interface ICommand - { - void Run (); - } -} diff -Nru mono-addins-0.4/Samples/TextEditorLib/MainWindow.cs mono-addins-0.6.1/Samples/TextEditorLib/MainWindow.cs --- mono-addins-0.4/Samples/TextEditorLib/MainWindow.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/MainWindow.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ -using System; -using Gtk; -using Mono.Addins; -using TextEditor; - -public partial class MainWindow: Gtk.Window -{ - internal static MainWindow Instance; - - public MainWindow (): base (Gtk.WindowType.Toplevel) - { - Instance = this; - Build (); - - AddinManager.ExtensionChanged += OnExtensionChanged; - BuildToolbar (); - BuildMenu (); - } - - public void ConsoleWrite (string txt) - { - console.Show (); - consoleView.Buffer.Text += txt; - consoleView.ScrollToMark (consoleView.Buffer.InsertMark, 0d, false, 0d, 0d); - } - - void BuildToolbar () - { - // Clean the toolbar - foreach (Gtk.Widget w in toolbar.Children) - toolbar.Remove (w); - - // Add the new buttons - foreach (ToolbarNode node in AddinManager.GetExtensionNodes ("/TextEditor/ToolbarButtons")) - toolbar.Insert (node.GetToolItem (), -1); - - toolbar.ShowAll (); - } - - void BuildMenu () - { - // Clean the toolbar - foreach (Gtk.Widget w in menubar.Children) - menubar.Remove (w); - - // Add the new buttons - foreach (MenuNode node in AddinManager.GetExtensionNodes ("/TextEditor/MainMenu")) - menubar.Insert (node.GetMenuItem (), -1); - - // Create the menu for creating documents from templates - - Gtk.Menu menu = BuildTemplateItems (AddinManager.GetExtensionNodes ("/TextEditor/Templates")); - Gtk.MenuItem it = new MenuItem ("New From Template"); - it.Submenu = menu; - - Gtk.MenuItem men = (Gtk.MenuItem) menubar.Children [0]; - ((Gtk.Menu)men.Submenu).Insert (it, 1); - - menubar.ShowAll (); - } - - Gtk.Menu BuildTemplateItems (ExtensionNodeList nodes) - { - Gtk.Menu menu = new Gtk.Menu (); - foreach (ExtensionNode tn in nodes) { - Gtk.MenuItem item; - if (tn is TemplateCategoryNode) { - TemplateCategoryNode cat = (TemplateCategoryNode) tn; - item = new Gtk.MenuItem (cat.Name); - item.Submenu = BuildTemplateItems (cat.ChildNodes); - } - else { - FileTemplateNode t = (FileTemplateNode) tn; - item = new Gtk.MenuItem (t.Name); - item.Activated += delegate { - TextEditor.TextEditorApp.NewFile (t.GetContent ()); - }; - } - menu.Insert (item, -1); - } - return menu; - } - - - void OnExtensionChanged (object o, ExtensionEventArgs args) - { - if (args.PathChanged ("/TextEditor/ToolbarButtons")) - BuildToolbar (); - else if (args.PathChanged ("/TextEditor/MainMenu") || args.PathChanged ("/TextEditor/Templates")) - BuildMenu (); - } - - protected void OnDeleteEvent (object sender, DeleteEventArgs a) - { - Application.Quit (); - a.RetVal = true; - } - - protected virtual void OnButton1Clicked(object sender, System.EventArgs e) - { - console.Hide (); - } - - public Gtk.TextView View { - get { return textview; } - } -} diff -Nru mono-addins-0.4/Samples/TextEditorLib/Makefile.am mono-addins-0.6.1/Samples/TextEditorLib/Makefile.am --- mono-addins-0.4/Samples/TextEditorLib/Makefile.am 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/Makefile.am 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -ASSEMBLY_COMPILER_COMMAND = mcs -ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG -ASSEMBLY = ../bin/TextEditorLib.dll -COMPILE_TARGET = library -PROJECT_REFERENCES = \ - ../../bin/Mono.Addins.dll \ - ../../bin/Mono.Addins.Gui.dll -BUILD_DIR = ../bin - - -if ENABLE_GUI -all: $(ASSEMBLY) -endif - -FILES = \ - AssemblyInfo.cs \ - Commands/CopyCommand.cs \ - Commands/CutCommand.cs \ - Commands/ExitCommand.cs \ - Commands/NewCommand.cs \ - Commands/OpenCommand.cs \ - Commands/PasteCommand.cs \ - Commands/SaveCommand.cs \ - Commands/SetupCommand.cs \ - ExtensionNodes/FileTemplateNode.cs \ - ExtensionNodes/MenuItemNode.cs \ - ExtensionNodes/MenuNode.cs \ - ExtensionNodes/MenuSeparatorNode.cs \ - ExtensionNodes/SubmenuNode.cs \ - ExtensionNodes/TemplateCategoryNode.cs \ - ExtensionNodes/ToolbarNode.cs \ - ExtensionNodes/ToolButtonNode.cs \ - ExtensionNodes/ToolSeparatorNode.cs \ - gtk-gui/generated.cs \ - gtk-gui/MainWindow.cs \ - ICommand.cs \ - MainWindow.cs \ - OpenFileCondition.cs \ - TextEditorApp.cs - -DATA_FILES = - -RESOURCES = \ - gtk-gui/gui.stetic \ - Templates/ChangeLogTemplate.txt \ - Templates/DotConfigTemplate.txt \ - Templates/TextEditor.addin.xml \ - Templates/WorkReport.txt - -EXTRAS = - -REFERENCES = \ - -pkg:gtk-sharp-2.0 \ - -r:Mono.Posix \ - -r:System - -DLL_REFERENCES = - -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) - mkdir -p $(dir $(ASSEMBLY)) - - $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) - -if ENABLE_GUI -include $(top_srcdir)/makefile-sample.include -endif diff -Nru mono-addins-0.4/Samples/TextEditorLib/Makefile.in mono-addins-0.6.1/Samples/TextEditorLib/Makefile.in --- mono-addins-0.4/Samples/TextEditorLib/Makefile.in 2008-11-06 19:52:35.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/Makefile.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,364 +0,0 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(top_srcdir)/makefile-sample.include -subdir = ./Samples/TextEditorLib -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = -SOURCES = -DIST_SOURCES = -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AL = @AL@ -AMTAR = @AMTAR@ -API_VERSION = @API_VERSION@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -GACUTIL = @GACUTIL@ -GACUTIL_FLAGS = @GACUTIL_FLAGS@ -GACUTIL_POLICY_FLAGS = @GACUTIL_POLICY_FLAGS@ -GTK_SHARP_20_CFLAGS = @GTK_SHARP_20_CFLAGS@ -GTK_SHARP_20_LIBS = @GTK_SHARP_20_LIBS@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MCS = @MCS@ -MKDIR_P = @MKDIR_P@ -MONO_ADDINS_DEFAULT_LIB = @MONO_ADDINS_DEFAULT_LIB@ -MONO_ADDINS_GUI_DEFAULT_LIB = @MONO_ADDINS_GUI_DEFAULT_LIB@ -MONO_ADDINS_SETUP_DEFAULT_LIB = @MONO_ADDINS_SETUP_DEFAULT_LIB@ -MONO_NUNIT_CFLAGS = @MONO_NUNIT_CFLAGS@ -MONO_NUNIT_LIBS = @MONO_NUNIT_LIBS@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PKG_CONFIG = @PKG_CONFIG@ -POLICY_VERSIONS = @POLICY_VERSIONS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -am__leading_dot = @am__leading_dot@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build_alias = @build_alias@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host_alias = @host_alias@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -ASSEMBLY_COMPILER_COMMAND = mcs -ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG -ASSEMBLY = ../bin/TextEditorLib.dll -COMPILE_TARGET = library -PROJECT_REFERENCES = \ - ../../bin/Mono.Addins.dll \ - ../../bin/Mono.Addins.Gui.dll - -BUILD_DIR = ../bin -FILES = \ - AssemblyInfo.cs \ - Commands/CopyCommand.cs \ - Commands/CutCommand.cs \ - Commands/ExitCommand.cs \ - Commands/NewCommand.cs \ - Commands/OpenCommand.cs \ - Commands/PasteCommand.cs \ - Commands/SaveCommand.cs \ - Commands/SetupCommand.cs \ - ExtensionNodes/FileTemplateNode.cs \ - ExtensionNodes/MenuItemNode.cs \ - ExtensionNodes/MenuNode.cs \ - ExtensionNodes/MenuSeparatorNode.cs \ - ExtensionNodes/SubmenuNode.cs \ - ExtensionNodes/TemplateCategoryNode.cs \ - ExtensionNodes/ToolbarNode.cs \ - ExtensionNodes/ToolButtonNode.cs \ - ExtensionNodes/ToolSeparatorNode.cs \ - gtk-gui/generated.cs \ - gtk-gui/MainWindow.cs \ - ICommand.cs \ - MainWindow.cs \ - OpenFileCondition.cs \ - TextEditorApp.cs - -DATA_FILES = -RESOURCES = \ - gtk-gui/gui.stetic \ - Templates/ChangeLogTemplate.txt \ - Templates/DotConfigTemplate.txt \ - Templates/TextEditor.addin.xml \ - Templates/WorkReport.txt - -EXTRAS = -REFERENCES = \ - -pkg:gtk-sharp-2.0 \ - -r:Mono.Posix \ - -r:System - -DLL_REFERENCES = -@ENABLE_GUI_TRUE@build_sources = $(addprefix $(srcdir)/, $(FILES) $(GENERATED_FILES)) -@ENABLE_GUI_TRUE@build_resources = $(addprefix $(srcdir)/, $(RESOURCES)) -@ENABLE_GUI_TRUE@build_resources_embed = $(foreach res,$(build_resources), $(addprefix -resource:,$(res)),$(RESOURCES_PREFIX)$(notdir $(res))) -@ENABLE_GUI_TRUE@build_references_ref = $(REFERENCES) $(foreach ref, \ -@ENABLE_GUI_TRUE@ $(DLL_REFERENCES), -r:$(ref)) $(foreach ref, \ -@ENABLE_GUI_TRUE@ $(PROJECT_REFERENCES), -r:$(ref)) -@ENABLE_GUI_TRUE@pc_files = $(PC_FILES_IN:.pc.in=.pc) -@ENABLE_GUI_TRUE@build_datafiles = $(addprefix $(BUILD_DIR)/, $(DATA_FILES)) -@ENABLE_GUI_TRUE@EXTRA_DIST = $(FILES) $(GENERATED_FILES) $(RESOURCES) $(ASSEMBLY_WRAPPER_IN) $(EXTRAS) $(DATA_FILES) $(PC_FILES_IN) -@ENABLE_GUI_TRUE@CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb $(DLL_REFERENCES) -@ENABLE_GUI_TRUE@DISTCLEANFILES = $(GENERATED_FILES) $(build_datafiles) $(pc_files) -all: all-am - -.SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/makefile-sample.include $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign ./Samples/TextEditorLib/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign ./Samples/TextEditorLib/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -tags: TAGS -TAGS: - -ctags: CTAGS -CTAGS: - - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic mostlyclean-am - -distclean: distclean-am - -rm -f Makefile -distclean-am: clean-am distclean-generic - -dvi: dvi-am - -dvi-am: - -html: html-am - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-exec-am: - -install-html: install-html-am - -install-info: install-info-am - -install-man: - -install-pdf: install-pdf-am - -install-ps: install-ps-am - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-generic - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: install-am install-strip - -.PHONY: all all-am check check-am clean clean-generic distclean \ - distclean-generic distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am - - -@ENABLE_GUI_TRUE@all: $(ASSEMBLY) - -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) - mkdir -p $(dir $(ASSEMBLY)) - - $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) - -@ENABLE_GUI_TRUE@$(build_datafiles): $(BUILD_DIR)/% : $(addprefix $(srcdir)/, %) -@ENABLE_GUI_TRUE@ mkdir -p $(dir $@) -@ENABLE_GUI_TRUE@ cp $< $@ -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff -Nru mono-addins-0.4/Samples/TextEditorLib/OpenFileCondition.cs mono-addins-0.6.1/Samples/TextEditorLib/OpenFileCondition.cs --- mono-addins-0.4/Samples/TextEditorLib/OpenFileCondition.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/OpenFileCondition.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ - -using System; -using System.IO; -using Mono.Addins; - -namespace TextEditor -{ - public class OpenFileCondition: ConditionType - { - public OpenFileCondition () - { - // It's important to notify changes in the status of a condition, - // to make sure the extension points are properly updated. - TextEditorApp.OpenFileChanged += delegate { - NotifyChanged (); - }; - } - - public override bool Evaluate (NodeElement conditionNode) - { - // Get the required extension value from an attribute, - // and check againts the extension of the currently open document - string val = conditionNode.GetAttribute ("extension"); - if (val.Length > 0) { - string ext = Path.GetExtension (TextEditorApp.OpenFileName); - foreach (string requiredExtension in val.Split (',')) - if (ext == "." + requiredExtension) - return true; - } - return false; - } - } -} diff -Nru mono-addins-0.4/Samples/TextEditorLib/Templates/ChangeLogTemplate.txt mono-addins-0.6.1/Samples/TextEditorLib/Templates/ChangeLogTemplate.txt --- mono-addins-0.4/Samples/TextEditorLib/Templates/ChangeLogTemplate.txt 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/Templates/ChangeLogTemplate.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,4 +0,0 @@ -yyyy-mm-dd Developer name - - * File name: change done - diff -Nru mono-addins-0.4/Samples/TextEditorLib/Templates/DotConfigTemplate.txt mono-addins-0.6.1/Samples/TextEditorLib/Templates/DotConfigTemplate.txt --- mono-addins-0.4/Samples/TextEditorLib/Templates/DotConfigTemplate.txt 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/Templates/DotConfigTemplate.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,4 +0,0 @@ - - - - diff -Nru mono-addins-0.4/Samples/TextEditorLib/Templates/TextEditor.addin.xml mono-addins-0.6.1/Samples/TextEditorLib/Templates/TextEditor.addin.xml --- mono-addins-0.4/Samples/TextEditorLib/Templates/TextEditor.addin.xml 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/Templates/TextEditor.addin.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -Nru mono-addins-0.4/Samples/TextEditorLib/Templates/WorkReport.txt mono-addins-0.6.1/Samples/TextEditorLib/Templates/WorkReport.txt --- mono-addins-0.4/Samples/TextEditorLib/Templates/WorkReport.txt 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/Templates/WorkReport.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ - -Work done last week: -* ... -* ... - -Work to do next week: -* ... -* ... \ No newline at end of file diff -Nru mono-addins-0.4/Samples/TextEditorLib/TextEditorApp.cs mono-addins-0.6.1/Samples/TextEditorLib/TextEditorApp.cs --- mono-addins-0.4/Samples/TextEditorLib/TextEditorApp.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditorLib/TextEditorApp.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ - -using System; -using System.IO; - -namespace TextEditor -{ - public class TextEditorApp - { - static string openFile = ""; - - private TextEditorApp() - { - } - - public static string OpenFileName { - get { return openFile; } - } - - public static MainWindow MainWindow { - get { return MainWindow.Instance; } - } - - public static void OpenFile (string file) - { - using (StreamReader sr = new StreamReader (file)) { - MainWindow.View.Buffer.Text = sr.ReadToEnd (); - } - SetOpenFile (file); - } - - public static void SaveFile () - { - if (openFile == "") { - Gtk.FileChooserDialog fcd = new Gtk.FileChooserDialog ("Save File", null, Gtk.FileChooserAction.Save); - fcd.AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel); - fcd.AddButton (Gtk.Stock.Open, Gtk.ResponseType.Ok); - fcd.DefaultResponse = Gtk.ResponseType.Ok; - fcd.SelectMultiple = false; - - Gtk.ResponseType response = (Gtk.ResponseType) fcd.Run (); - if (response != Gtk.ResponseType.Ok) { - fcd.Destroy (); - return; - } - - SetOpenFile (fcd.Filename); - fcd.Destroy (); - } - using (StreamWriter sr = new StreamWriter (openFile)) { - sr.Write (TextEditorApp.MainWindow.View.Buffer.Text); - } - } - - public static void NewFile (string content) - { - SetOpenFile (""); - MainWindow.View.Buffer.Text = content; - } - - static void SetOpenFile (string file) - { - openFile = file; - if (file.Length > 0) - MainWindow.Title = Path.GetFileName (file); - else - MainWindow.Title = "New File"; - - if (OpenFileChanged != null) - OpenFileChanged (null, EventArgs.Empty); - } - - public static event EventHandler OpenFileChanged; - } -} diff -Nru mono-addins-0.4/Samples/TextEditor.Xml/AssemblyInfo.cs mono-addins-0.6.1/Samples/TextEditor.Xml/AssemblyInfo.cs --- mono-addins-0.4/Samples/TextEditor.Xml/AssemblyInfo.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditor.Xml/AssemblyInfo.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following -// attributes. -// -// change them to the information which is associated with the assembly -// you compile. - -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has following format : -// -// Major.Minor.Build.Revision -// -// You can specify all values by your own or you can build default build and revision -// numbers with the '*' character (the default): - -[assembly: AssemblyVersion("1.0.0.0")] - -// The following attributes specify the key for the sign of your assembly. See the -// .NET Framework documentation for more information about signing. -// This is not required, if you don't want signing let these attributes like they're. -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] diff -Nru mono-addins-0.4/Samples/TextEditor.Xml/EmptyFile.xml mono-addins-0.6.1/Samples/TextEditor.Xml/EmptyFile.xml --- mono-addins-0.4/Samples/TextEditor.Xml/EmptyFile.xml 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditor.Xml/EmptyFile.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ - - \ No newline at end of file diff -Nru mono-addins-0.4/Samples/TextEditor.Xml/FormatXmlCommand.cs mono-addins-0.6.1/Samples/TextEditor.Xml/FormatXmlCommand.cs --- mono-addins-0.4/Samples/TextEditor.Xml/FormatXmlCommand.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditor.Xml/FormatXmlCommand.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ - -using System; -using System.IO; -using System.Xml; -using TextEditor; -using Mono.Addins; - -[assembly: Addin (Namespace="TextEditor")] -[assembly: AddinDependency ("Core", "1.0")] - - -namespace TextEditor.Xml -{ - public class FormatXmlCommand: ICommand - { - public void Run () - { - string text = TextEditorApp.MainWindow.View.Buffer.Text; - XmlDocument doc = new XmlDocument (); - try { - doc.LoadXml (text); - StringWriter sw = new StringWriter (); - XmlTextWriter tw = new XmlTextWriter (sw); - tw.Formatting = Formatting.Indented; - doc.Save (tw); - TextEditorApp.MainWindow.View.Buffer.Text = sw.ToString (); - } - catch { - Gtk.MessageDialog dlg = new Gtk.MessageDialog (TextEditorApp.MainWindow, Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.Close, "Error parsing XML."); - dlg.Run (); - dlg.Destroy (); - } - } - } - - class Subno: TextEditor.CopyCommand - { - } -} diff -Nru mono-addins-0.4/Samples/TextEditor.Xml/Makefile.am mono-addins-0.6.1/Samples/TextEditor.Xml/Makefile.am --- mono-addins-0.4/Samples/TextEditor.Xml/Makefile.am 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditor.Xml/Makefile.am 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -ASSEMBLY_COMPILER_COMMAND = mcs -ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG -ASSEMBLY = ../bin/XmlAddin.dll -COMPILE_TARGET = library -PROJECT_REFERENCES = \ - ../../bin/Mono.Addins.dll \ - ../bin/TextEditorLib.dll -BUILD_DIR = ../bin - -if ENABLE_GUI -all: $(ASSEMBLY) -endif - -FILES = \ - AssemblyInfo.cs \ - FormatXmlCommand.cs - -DATA_FILES = - -RESOURCES = \ - EmptyFile.xml \ - TextEditor.Xml.addin.xml - -EXTRAS = - -REFERENCES = \ - -pkg:gtk-sharp-2.0 \ - -r:System \ - -r:System.Xml - -DLL_REFERENCES = - -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) - mkdir -p $(dir $(ASSEMBLY)) - - $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) - -if ENABLE_GUI -include $(top_srcdir)/makefile-sample.include -endif diff -Nru mono-addins-0.4/Samples/TextEditor.Xml/Makefile.in mono-addins-0.6.1/Samples/TextEditor.Xml/Makefile.in --- mono-addins-0.4/Samples/TextEditor.Xml/Makefile.in 2008-11-06 19:52:35.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditor.Xml/Makefile.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,339 +0,0 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(top_srcdir)/makefile-sample.include -subdir = ./Samples/TextEditor.Xml -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = -SOURCES = -DIST_SOURCES = -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AL = @AL@ -AMTAR = @AMTAR@ -API_VERSION = @API_VERSION@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -GACUTIL = @GACUTIL@ -GACUTIL_FLAGS = @GACUTIL_FLAGS@ -GACUTIL_POLICY_FLAGS = @GACUTIL_POLICY_FLAGS@ -GTK_SHARP_20_CFLAGS = @GTK_SHARP_20_CFLAGS@ -GTK_SHARP_20_LIBS = @GTK_SHARP_20_LIBS@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MCS = @MCS@ -MKDIR_P = @MKDIR_P@ -MONO_ADDINS_DEFAULT_LIB = @MONO_ADDINS_DEFAULT_LIB@ -MONO_ADDINS_GUI_DEFAULT_LIB = @MONO_ADDINS_GUI_DEFAULT_LIB@ -MONO_ADDINS_SETUP_DEFAULT_LIB = @MONO_ADDINS_SETUP_DEFAULT_LIB@ -MONO_NUNIT_CFLAGS = @MONO_NUNIT_CFLAGS@ -MONO_NUNIT_LIBS = @MONO_NUNIT_LIBS@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PKG_CONFIG = @PKG_CONFIG@ -POLICY_VERSIONS = @POLICY_VERSIONS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -am__leading_dot = @am__leading_dot@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build_alias = @build_alias@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host_alias = @host_alias@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -ASSEMBLY_COMPILER_COMMAND = mcs -ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG -ASSEMBLY = ../bin/XmlAddin.dll -COMPILE_TARGET = library -PROJECT_REFERENCES = \ - ../../bin/Mono.Addins.dll \ - ../bin/TextEditorLib.dll - -BUILD_DIR = ../bin -FILES = \ - AssemblyInfo.cs \ - FormatXmlCommand.cs - -DATA_FILES = -RESOURCES = \ - EmptyFile.xml \ - TextEditor.Xml.addin.xml - -EXTRAS = -REFERENCES = \ - -pkg:gtk-sharp-2.0 \ - -r:System \ - -r:System.Xml - -DLL_REFERENCES = -@ENABLE_GUI_TRUE@build_sources = $(addprefix $(srcdir)/, $(FILES) $(GENERATED_FILES)) -@ENABLE_GUI_TRUE@build_resources = $(addprefix $(srcdir)/, $(RESOURCES)) -@ENABLE_GUI_TRUE@build_resources_embed = $(foreach res,$(build_resources), $(addprefix -resource:,$(res)),$(RESOURCES_PREFIX)$(notdir $(res))) -@ENABLE_GUI_TRUE@build_references_ref = $(REFERENCES) $(foreach ref, \ -@ENABLE_GUI_TRUE@ $(DLL_REFERENCES), -r:$(ref)) $(foreach ref, \ -@ENABLE_GUI_TRUE@ $(PROJECT_REFERENCES), -r:$(ref)) -@ENABLE_GUI_TRUE@pc_files = $(PC_FILES_IN:.pc.in=.pc) -@ENABLE_GUI_TRUE@build_datafiles = $(addprefix $(BUILD_DIR)/, $(DATA_FILES)) -@ENABLE_GUI_TRUE@EXTRA_DIST = $(FILES) $(GENERATED_FILES) $(RESOURCES) $(ASSEMBLY_WRAPPER_IN) $(EXTRAS) $(DATA_FILES) $(PC_FILES_IN) -@ENABLE_GUI_TRUE@CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb $(DLL_REFERENCES) -@ENABLE_GUI_TRUE@DISTCLEANFILES = $(GENERATED_FILES) $(build_datafiles) $(pc_files) -all: all-am - -.SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/makefile-sample.include $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign ./Samples/TextEditor.Xml/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign ./Samples/TextEditor.Xml/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -tags: TAGS -TAGS: - -ctags: CTAGS -CTAGS: - - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic mostlyclean-am - -distclean: distclean-am - -rm -f Makefile -distclean-am: clean-am distclean-generic - -dvi: dvi-am - -dvi-am: - -html: html-am - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-exec-am: - -install-html: install-html-am - -install-info: install-info-am - -install-man: - -install-pdf: install-pdf-am - -install-ps: install-ps-am - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-generic - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: install-am install-strip - -.PHONY: all all-am check check-am clean clean-generic distclean \ - distclean-generic distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am - - -@ENABLE_GUI_TRUE@all: $(ASSEMBLY) - -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) - mkdir -p $(dir $(ASSEMBLY)) - - $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) - -@ENABLE_GUI_TRUE@$(build_datafiles): $(BUILD_DIR)/% : $(addprefix $(srcdir)/, %) -@ENABLE_GUI_TRUE@ mkdir -p $(dir $@) -@ENABLE_GUI_TRUE@ cp $< $@ -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff -Nru mono-addins-0.4/Samples/TextEditor.Xml/TextEditor.Xml.addin.xml mono-addins-0.6.1/Samples/TextEditor.Xml/TextEditor.Xml.addin.xml --- mono-addins-0.4/Samples/TextEditor.Xml/TextEditor.Xml.addin.xml 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/TextEditor.Xml/TextEditor.Xml.addin.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff -Nru mono-addins-0.4/Samples/WriterService/AssemblyInfo.cs mono-addins-0.6.1/Samples/WriterService/AssemblyInfo.cs --- mono-addins-0.4/Samples/WriterService/AssemblyInfo.cs 2008-11-06 19:52:08.000000000 +0000 +++ mono-addins-0.6.1/Samples/WriterService/AssemblyInfo.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following -// attributes. -// -// change them to the information which is associated with the assembly -// you compile. - -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has following format : -// -// Major.Minor.Build.Revision -// -// You can specify all values by your own or you can build default build and revision -// numbers with the '*' character (the default): - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes specify the key for the sign of your assembly. See the -// .NET Framework documentation for more information about signing. -// This is not required, if you don't want signing let these attributes like they're. -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] diff -Nru mono-addins-0.4/Samples/WriterService/FlagsCondition.cs mono-addins-0.6.1/Samples/WriterService/FlagsCondition.cs --- mono-addins-0.4/Samples/WriterService/FlagsCondition.cs 2008-11-06 19:52:08.000000000 +0000 +++ mono-addins-0.6.1/Samples/WriterService/FlagsCondition.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ - -using System; -using Mono.Addins; - -namespace WriterService -{ - public class FlagsCondition: ConditionType - { - string[] flags; - - public FlagsCondition (string[] flags) - { - this.flags = flags; - } - - public override bool Evaluate (NodeElement attributes) - { - string flag = attributes.GetAttribute ("value"); - return Array.IndexOf (flags, flag) != -1; - } - } -} diff -Nru mono-addins-0.4/Samples/WriterService/IWriter.cs mono-addins-0.6.1/Samples/WriterService/IWriter.cs --- mono-addins-0.4/Samples/WriterService/IWriter.cs 2008-11-06 19:52:08.000000000 +0000 +++ mono-addins-0.6.1/Samples/WriterService/IWriter.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ - -using System; - -namespace WriterService -{ - public interface IWriter - { - string Write (); - } -} diff -Nru mono-addins-0.4/Samples/WriterService/Makefile.am mono-addins-0.6.1/Samples/WriterService/Makefile.am --- mono-addins-0.4/Samples/WriterService/Makefile.am 2008-11-06 19:52:08.000000000 +0000 +++ mono-addins-0.6.1/Samples/WriterService/Makefile.am 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -ASSEMBLY_COMPILER_COMMAND = mcs -ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG -ASSEMBLY = ../bin/WriterService.dll -COMPILE_TARGET = library -PROJECT_REFERENCES = ../../bin/Mono.Addins.dll -BUILD_DIR = ../bin - - -all: $(ASSEMBLY) - -FILES = \ - AssemblyInfo.cs \ - FlagsCondition.cs \ - IWriter.cs \ - WriterManager.cs - -DATA_FILES = - -RESOURCES = WriterService.addin.xml - -EXTRAS = - -REFERENCES = -r:System - -DLL_REFERENCES = - -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) - mkdir -p $(dir $(ASSEMBLY)) - - $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) - -include $(top_srcdir)/makefile-sample.include diff -Nru mono-addins-0.4/Samples/WriterService/Makefile.in mono-addins-0.6.1/Samples/WriterService/Makefile.in --- mono-addins-0.4/Samples/WriterService/Makefile.in 2008-11-06 19:52:35.000000000 +0000 +++ mono-addins-0.6.1/Samples/WriterService/Makefile.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,330 +0,0 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(top_srcdir)/makefile-sample.include -subdir = ./Samples/WriterService -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = -SOURCES = -DIST_SOURCES = -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AL = @AL@ -AMTAR = @AMTAR@ -API_VERSION = @API_VERSION@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -GACUTIL = @GACUTIL@ -GACUTIL_FLAGS = @GACUTIL_FLAGS@ -GACUTIL_POLICY_FLAGS = @GACUTIL_POLICY_FLAGS@ -GTK_SHARP_20_CFLAGS = @GTK_SHARP_20_CFLAGS@ -GTK_SHARP_20_LIBS = @GTK_SHARP_20_LIBS@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MCS = @MCS@ -MKDIR_P = @MKDIR_P@ -MONO_ADDINS_DEFAULT_LIB = @MONO_ADDINS_DEFAULT_LIB@ -MONO_ADDINS_GUI_DEFAULT_LIB = @MONO_ADDINS_GUI_DEFAULT_LIB@ -MONO_ADDINS_SETUP_DEFAULT_LIB = @MONO_ADDINS_SETUP_DEFAULT_LIB@ -MONO_NUNIT_CFLAGS = @MONO_NUNIT_CFLAGS@ -MONO_NUNIT_LIBS = @MONO_NUNIT_LIBS@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PKG_CONFIG = @PKG_CONFIG@ -POLICY_VERSIONS = @POLICY_VERSIONS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -am__leading_dot = @am__leading_dot@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build_alias = @build_alias@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host_alias = @host_alias@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -ASSEMBLY_COMPILER_COMMAND = mcs -ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG -ASSEMBLY = ../bin/WriterService.dll -COMPILE_TARGET = library -PROJECT_REFERENCES = ../../bin/Mono.Addins.dll -BUILD_DIR = ../bin -FILES = \ - AssemblyInfo.cs \ - FlagsCondition.cs \ - IWriter.cs \ - WriterManager.cs - -DATA_FILES = -RESOURCES = WriterService.addin.xml -EXTRAS = -REFERENCES = -r:System -DLL_REFERENCES = -build_sources = $(addprefix $(srcdir)/, $(FILES) $(GENERATED_FILES)) -build_resources = $(addprefix $(srcdir)/, $(RESOURCES)) -build_resources_embed = $(foreach res,$(build_resources), $(addprefix -resource:,$(res)),$(RESOURCES_PREFIX)$(notdir $(res))) -build_references_ref = $(REFERENCES) $(foreach ref, $(DLL_REFERENCES), \ - -r:$(ref)) $(foreach ref, $(PROJECT_REFERENCES), -r:$(ref)) -pc_files = $(PC_FILES_IN:.pc.in=.pc) -build_datafiles = $(addprefix $(BUILD_DIR)/, $(DATA_FILES)) -EXTRA_DIST = $(FILES) $(GENERATED_FILES) $(RESOURCES) $(ASSEMBLY_WRAPPER_IN) $(EXTRAS) $(DATA_FILES) $(PC_FILES_IN) -CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb $(DLL_REFERENCES) -DISTCLEANFILES = $(GENERATED_FILES) $(build_datafiles) $(pc_files) -all: all-am - -.SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/makefile-sample.include $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign ./Samples/WriterService/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign ./Samples/WriterService/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -tags: TAGS -TAGS: - -ctags: CTAGS -CTAGS: - - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic mostlyclean-am - -distclean: distclean-am - -rm -f Makefile -distclean-am: clean-am distclean-generic - -dvi: dvi-am - -dvi-am: - -html: html-am - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-exec-am: - -install-html: install-html-am - -install-info: install-info-am - -install-man: - -install-pdf: install-pdf-am - -install-ps: install-ps-am - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-generic - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: install-am install-strip - -.PHONY: all all-am check check-am clean clean-generic distclean \ - distclean-generic distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am - - -all: $(ASSEMBLY) - -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) - mkdir -p $(dir $(ASSEMBLY)) - - $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) - -$(build_datafiles): $(BUILD_DIR)/% : $(addprefix $(srcdir)/, %) - mkdir -p $(dir $@) - cp $< $@ -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff -Nru mono-addins-0.4/Samples/WriterService/WriterManager.cs mono-addins-0.6.1/Samples/WriterService/WriterManager.cs --- mono-addins-0.4/Samples/WriterService/WriterManager.cs 2008-11-06 19:52:08.000000000 +0000 +++ mono-addins-0.6.1/Samples/WriterService/WriterManager.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ - -using System; -using Mono.Addins; - -namespace WriterService -{ - public class WriterManager - { - ExtensionContext ctx; - public event EventHandler Changed; - - public WriterManager (string[] flags) - { - // Create a new extension context - ctx = AddinManager.CreateExtensionContext (); - - // Register the flags condition in the new context - FlagsCondition condition = new FlagsCondition (flags); - ctx.RegisterCondition ("HasFlag", condition); - - ctx.AddExtensionNodeHandler ("/WriterService/Writers", delegate { - if (Changed != null) - Changed (this, EventArgs.Empty); - }); - } - - public IWriter[] GetWriters () - { - // Returns the IWriter objects registered in the Writers path - return (IWriter[]) ctx.GetExtensionObjects ("/WriterService/Writers", typeof(IWriter)); - } - } -} - diff -Nru mono-addins-0.4/Samples/WriterService/WriterService.addin.xml mono-addins-0.6.1/Samples/WriterService/WriterService.addin.xml --- mono-addins-0.4/Samples/WriterService/WriterService.addin.xml 2008-11-06 19:52:08.000000000 +0000 +++ mono-addins-0.6.1/Samples/WriterService/WriterService.addin.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff -Nru mono-addins-0.4/Samples/WriterServiceHost/AssemblyInfo.cs mono-addins-0.6.1/Samples/WriterServiceHost/AssemblyInfo.cs --- mono-addins-0.4/Samples/WriterServiceHost/AssemblyInfo.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/WriterServiceHost/AssemblyInfo.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following -// attributes. -// -// change them to the information which is associated with the assembly -// you compile. - -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has following format : -// -// Major.Minor.Build.Revision -// -// You can specify all values by your own or you can build default build and revision -// numbers with the '*' character (the default): - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes specify the key for the sign of your assembly. See the -// .NET Framework documentation for more information about signing. -// This is not required, if you don't want signing let these attributes like they're. -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] diff -Nru mono-addins-0.4/Samples/WriterServiceHost/Main.cs mono-addins-0.6.1/Samples/WriterServiceHost/Main.cs --- mono-addins-0.4/Samples/WriterServiceHost/Main.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/WriterServiceHost/Main.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -using System; -using WriterService; -using Mono.Addins; - -namespace SampleAddinHost -{ - class MainClass - { - public static void Main(string[] args) - { - AddinManager.Initialize ("."); - AddinManager.Registry.Update (null); - - Console.WriteLine ("Normal writers:"); - WriterManager manager = new WriterManager (new string[0]); - foreach (IWriter w in manager.GetWriters ()) - Console.WriteLine (w.Write ()); - - Console.WriteLine ("Including debug writers:"); - WriterManager debugManager = new WriterManager (new string[] { "debug" }); - foreach (IWriter w in debugManager.GetWriters ()) - Console.WriteLine (w.Write ()); - } - } -} \ No newline at end of file diff -Nru mono-addins-0.4/Samples/WriterServiceHost/Makefile.am mono-addins-0.6.1/Samples/WriterServiceHost/Makefile.am --- mono-addins-0.4/Samples/WriterServiceHost/Makefile.am 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/WriterServiceHost/Makefile.am 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -ASSEMBLY_COMPILER_COMMAND = mcs -ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG -ASSEMBLY = ../bin/SampleAddinHost.exe -COMPILE_TARGET = exe -PROJECT_REFERENCES = \ - ../../bin/Mono.Addins.dll \ - ../bin/WriterService.dll -BUILD_DIR = ../bin - - -all: $(ASSEMBLY) - -FILES = \ - AssemblyInfo.cs \ - Main.cs - -DATA_FILES = - -RESOURCES = - -EXTRAS = - -REFERENCES = -r:System - -DLL_REFERENCES = - -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) - mkdir -p $(dir $(ASSEMBLY)) - - $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) - -include $(top_srcdir)/makefile-sample.include diff -Nru mono-addins-0.4/Samples/WriterServiceHost/Makefile.in mono-addins-0.6.1/Samples/WriterServiceHost/Makefile.in --- mono-addins-0.4/Samples/WriterServiceHost/Makefile.in 2008-11-06 19:52:35.000000000 +0000 +++ mono-addins-0.6.1/Samples/WriterServiceHost/Makefile.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,331 +0,0 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(top_srcdir)/makefile-sample.include -subdir = ./Samples/WriterServiceHost -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = -SOURCES = -DIST_SOURCES = -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AL = @AL@ -AMTAR = @AMTAR@ -API_VERSION = @API_VERSION@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -GACUTIL = @GACUTIL@ -GACUTIL_FLAGS = @GACUTIL_FLAGS@ -GACUTIL_POLICY_FLAGS = @GACUTIL_POLICY_FLAGS@ -GTK_SHARP_20_CFLAGS = @GTK_SHARP_20_CFLAGS@ -GTK_SHARP_20_LIBS = @GTK_SHARP_20_LIBS@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MCS = @MCS@ -MKDIR_P = @MKDIR_P@ -MONO_ADDINS_DEFAULT_LIB = @MONO_ADDINS_DEFAULT_LIB@ -MONO_ADDINS_GUI_DEFAULT_LIB = @MONO_ADDINS_GUI_DEFAULT_LIB@ -MONO_ADDINS_SETUP_DEFAULT_LIB = @MONO_ADDINS_SETUP_DEFAULT_LIB@ -MONO_NUNIT_CFLAGS = @MONO_NUNIT_CFLAGS@ -MONO_NUNIT_LIBS = @MONO_NUNIT_LIBS@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PKG_CONFIG = @PKG_CONFIG@ -POLICY_VERSIONS = @POLICY_VERSIONS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -am__leading_dot = @am__leading_dot@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build_alias = @build_alias@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host_alias = @host_alias@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -ASSEMBLY_COMPILER_COMMAND = mcs -ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG -ASSEMBLY = ../bin/SampleAddinHost.exe -COMPILE_TARGET = exe -PROJECT_REFERENCES = \ - ../../bin/Mono.Addins.dll \ - ../bin/WriterService.dll - -BUILD_DIR = ../bin -FILES = \ - AssemblyInfo.cs \ - Main.cs - -DATA_FILES = -RESOURCES = -EXTRAS = -REFERENCES = -r:System -DLL_REFERENCES = -build_sources = $(addprefix $(srcdir)/, $(FILES) $(GENERATED_FILES)) -build_resources = $(addprefix $(srcdir)/, $(RESOURCES)) -build_resources_embed = $(foreach res,$(build_resources), $(addprefix -resource:,$(res)),$(RESOURCES_PREFIX)$(notdir $(res))) -build_references_ref = $(REFERENCES) $(foreach ref, $(DLL_REFERENCES), \ - -r:$(ref)) $(foreach ref, $(PROJECT_REFERENCES), -r:$(ref)) -pc_files = $(PC_FILES_IN:.pc.in=.pc) -build_datafiles = $(addprefix $(BUILD_DIR)/, $(DATA_FILES)) -EXTRA_DIST = $(FILES) $(GENERATED_FILES) $(RESOURCES) $(ASSEMBLY_WRAPPER_IN) $(EXTRAS) $(DATA_FILES) $(PC_FILES_IN) -CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb $(DLL_REFERENCES) -DISTCLEANFILES = $(GENERATED_FILES) $(build_datafiles) $(pc_files) -all: all-am - -.SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/makefile-sample.include $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign ./Samples/WriterServiceHost/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign ./Samples/WriterServiceHost/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -tags: TAGS -TAGS: - -ctags: CTAGS -CTAGS: - - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic mostlyclean-am - -distclean: distclean-am - -rm -f Makefile -distclean-am: clean-am distclean-generic - -dvi: dvi-am - -dvi-am: - -html: html-am - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-exec-am: - -install-html: install-html-am - -install-info: install-info-am - -install-man: - -install-pdf: install-pdf-am - -install-ps: install-ps-am - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-generic - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: install-am install-strip - -.PHONY: all all-am check check-am clean clean-generic distclean \ - distclean-generic distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am - - -all: $(ASSEMBLY) - -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) - mkdir -p $(dir $(ASSEMBLY)) - - $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) - -$(build_datafiles): $(BUILD_DIR)/% : $(addprefix $(srcdir)/, %) - mkdir -p $(dir $@) - cp $< $@ -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff -Nru mono-addins-0.4/Samples/WriterService.SampleExtender/AssemblyInfo.cs mono-addins-0.6.1/Samples/WriterService.SampleExtender/AssemblyInfo.cs --- mono-addins-0.4/Samples/WriterService.SampleExtender/AssemblyInfo.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/WriterService.SampleExtender/AssemblyInfo.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following -// attributes. -// -// change them to the information which is associated with the assembly -// you compile. - -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has following format : -// -// Major.Minor.Build.Revision -// -// You can specify all values by your own or you can build default build and revision -// numbers with the '*' character (the default): - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes specify the key for the sign of your assembly. See the -// .NET Framework documentation for more information about signing. -// This is not required, if you don't want signing let these attributes like they're. -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] diff -Nru mono-addins-0.4/Samples/WriterService.SampleExtender/Makefile.am mono-addins-0.6.1/Samples/WriterService.SampleExtender/Makefile.am --- mono-addins-0.4/Samples/WriterService.SampleExtender/Makefile.am 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/WriterService.SampleExtender/Makefile.am 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -ASSEMBLY_COMPILER_COMMAND = mcs -ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG -ASSEMBLY = ../bin/SampleExtender.dll -COMPILE_TARGET = library -PROJECT_REFERENCES = ../bin/WriterService.dll -BUILD_DIR = ../bin - - -all: $(ASSEMBLY) - -FILES = \ - AssemblyInfo.cs \ - MyWriter.cs - -DATA_FILES = - -RESOURCES = SampleExtender.addin.xml - -EXTRAS = - -REFERENCES = -r:System - -DLL_REFERENCES = - -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) - mkdir -p $(dir $(ASSEMBLY)) - - $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) - -include $(top_srcdir)/makefile-sample.include diff -Nru mono-addins-0.4/Samples/WriterService.SampleExtender/Makefile.in mono-addins-0.6.1/Samples/WriterService.SampleExtender/Makefile.in --- mono-addins-0.4/Samples/WriterService.SampleExtender/Makefile.in 2008-11-06 19:52:35.000000000 +0000 +++ mono-addins-0.6.1/Samples/WriterService.SampleExtender/Makefile.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,328 +0,0 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(top_srcdir)/makefile-sample.include -subdir = ./Samples/WriterService.SampleExtender -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = -SOURCES = -DIST_SOURCES = -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AL = @AL@ -AMTAR = @AMTAR@ -API_VERSION = @API_VERSION@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -GACUTIL = @GACUTIL@ -GACUTIL_FLAGS = @GACUTIL_FLAGS@ -GACUTIL_POLICY_FLAGS = @GACUTIL_POLICY_FLAGS@ -GTK_SHARP_20_CFLAGS = @GTK_SHARP_20_CFLAGS@ -GTK_SHARP_20_LIBS = @GTK_SHARP_20_LIBS@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MCS = @MCS@ -MKDIR_P = @MKDIR_P@ -MONO_ADDINS_DEFAULT_LIB = @MONO_ADDINS_DEFAULT_LIB@ -MONO_ADDINS_GUI_DEFAULT_LIB = @MONO_ADDINS_GUI_DEFAULT_LIB@ -MONO_ADDINS_SETUP_DEFAULT_LIB = @MONO_ADDINS_SETUP_DEFAULT_LIB@ -MONO_NUNIT_CFLAGS = @MONO_NUNIT_CFLAGS@ -MONO_NUNIT_LIBS = @MONO_NUNIT_LIBS@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PKG_CONFIG = @PKG_CONFIG@ -POLICY_VERSIONS = @POLICY_VERSIONS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -am__leading_dot = @am__leading_dot@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build_alias = @build_alias@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host_alias = @host_alias@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -ASSEMBLY_COMPILER_COMMAND = mcs -ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG -ASSEMBLY = ../bin/SampleExtender.dll -COMPILE_TARGET = library -PROJECT_REFERENCES = ../bin/WriterService.dll -BUILD_DIR = ../bin -FILES = \ - AssemblyInfo.cs \ - MyWriter.cs - -DATA_FILES = -RESOURCES = SampleExtender.addin.xml -EXTRAS = -REFERENCES = -r:System -DLL_REFERENCES = -build_sources = $(addprefix $(srcdir)/, $(FILES) $(GENERATED_FILES)) -build_resources = $(addprefix $(srcdir)/, $(RESOURCES)) -build_resources_embed = $(foreach res,$(build_resources), $(addprefix -resource:,$(res)),$(RESOURCES_PREFIX)$(notdir $(res))) -build_references_ref = $(REFERENCES) $(foreach ref, $(DLL_REFERENCES), \ - -r:$(ref)) $(foreach ref, $(PROJECT_REFERENCES), -r:$(ref)) -pc_files = $(PC_FILES_IN:.pc.in=.pc) -build_datafiles = $(addprefix $(BUILD_DIR)/, $(DATA_FILES)) -EXTRA_DIST = $(FILES) $(GENERATED_FILES) $(RESOURCES) $(ASSEMBLY_WRAPPER_IN) $(EXTRAS) $(DATA_FILES) $(PC_FILES_IN) -CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb $(DLL_REFERENCES) -DISTCLEANFILES = $(GENERATED_FILES) $(build_datafiles) $(pc_files) -all: all-am - -.SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/makefile-sample.include $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign ./Samples/WriterService.SampleExtender/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign ./Samples/WriterService.SampleExtender/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -tags: TAGS -TAGS: - -ctags: CTAGS -CTAGS: - - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic mostlyclean-am - -distclean: distclean-am - -rm -f Makefile -distclean-am: clean-am distclean-generic - -dvi: dvi-am - -dvi-am: - -html: html-am - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-exec-am: - -install-html: install-html-am - -install-info: install-info-am - -install-man: - -install-pdf: install-pdf-am - -install-ps: install-ps-am - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-generic - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: install-am install-strip - -.PHONY: all all-am check check-am clean clean-generic distclean \ - distclean-generic distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am - - -all: $(ASSEMBLY) - -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) - mkdir -p $(dir $(ASSEMBLY)) - - $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) - -$(build_datafiles): $(BUILD_DIR)/% : $(addprefix $(srcdir)/, %) - mkdir -p $(dir $@) - cp $< $@ -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff -Nru mono-addins-0.4/Samples/WriterService.SampleExtender/MyWriter.cs mono-addins-0.6.1/Samples/WriterService.SampleExtender/MyWriter.cs --- mono-addins-0.4/Samples/WriterService.SampleExtender/MyWriter.cs 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/WriterService.SampleExtender/MyWriter.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -using System; -using WriterService; - -namespace SampleExtender -{ - public class MyWriter: IWriter - { - public string Write () - { - return "Some writer"; - } - } - - public class DebugWriter: IWriter - { - public string Write () - { - return "Some debug output"; - } - } -} diff -Nru mono-addins-0.4/Samples/WriterService.SampleExtender/SampleExtender.addin.xml mono-addins-0.6.1/Samples/WriterService.SampleExtender/SampleExtender.addin.xml --- mono-addins-0.4/Samples/WriterService.SampleExtender/SampleExtender.addin.xml 2008-11-06 19:52:07.000000000 +0000 +++ mono-addins-0.6.1/Samples/WriterService.SampleExtender/SampleExtender.addin.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff -Nru mono-addins-0.4/Test/ChangeLog mono-addins-0.6.1/Test/ChangeLog --- mono-addins-0.4/Test/ChangeLog 2008-11-06 19:51:57.000000000 +0000 +++ mono-addins-0.6.1/Test/ChangeLog 2011-04-13 09:00:29.000000000 +0000 @@ -1,3 +1,17 @@ +2010-05-21 Lluis Sanchez Gual + + * MultiAssemblyAddin: Added new tests. + +2008-11-10 Lluis Sanchez Gual + + * UnitTests/Makefile.am: + * FileExtender/Makefile.am: + * CommandExtension/Makefile.am: + * SystemInfoExtension/Makefile.am: + * HelloWorldExtension/Makefile.am: + * FileContentExtension/Makefile.am: Fix building with parallel make jobs + (-j8). Fixes bug #443206. Patch by Diego Pettenò. + 2008-08-22 Lluis Sanchez Gual * Test.mds: More project file fixes. diff -Nru mono-addins-0.4/Test/CommandExtension/ChangeLog mono-addins-0.6.1/Test/CommandExtension/ChangeLog --- mono-addins-0.4/Test/CommandExtension/ChangeLog 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Test/CommandExtension/ChangeLog 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,13 @@ +2010-03-26 Lluis Sanchez Gual + + * CommandExtension.csproj: Disable makefile integration since + we are not using makefiles anymore. + +2009-08-19 Lluis Sanchez Gual + + * CommandExtension.csproj: Update target framework to 2.0. + +2009/02/06 Lluis Sanchez Gual + + * CommandExtension.csproj: Updated. + diff -Nru mono-addins-0.4/Test/CommandExtension/Makefile.am mono-addins-0.6.1/Test/CommandExtension/Makefile.am --- mono-addins-0.4/Test/CommandExtension/Makefile.am 2008-11-06 19:51:57.000000000 +0000 +++ mono-addins-0.6.1/Test/CommandExtension/Makefile.am 2011-04-13 09:00:29.000000000 +0000 @@ -1,4 +1,4 @@ -ASSEMBLY_COMPILER_COMMAND = mcs +ASSEMBLY_COMPILER_COMMAND = @MCS@ ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG ASSEMBLY = ../lib/CommandExtension.dll COMPILE_TARGET = library @@ -24,7 +24,9 @@ DLL_REFERENCES = -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) +$(ASSEMBLY).mdb: $(ASSEMBLY) + +$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) mkdir -p $(dir $(ASSEMBLY)) $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) diff -Nru mono-addins-0.4/Test/CommandExtension/Makefile.in mono-addins-0.6.1/Test/CommandExtension/Makefile.in --- mono-addins-0.4/Test/CommandExtension/Makefile.in 2008-11-06 19:52:35.000000000 +0000 +++ mono-addins-0.6.1/Test/CommandExtension/Makefile.in 2011-04-13 09:45:29.000000000 +0000 @@ -30,7 +30,7 @@ PRE_UNINSTALL = : POST_UNINSTALL = : DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(top_srcdir)/makefile-sample.include + $(top_srcdir)/makefile-sample.include ChangeLog subdir = ./Test/CommandExtension ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac @@ -67,11 +67,15 @@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MCS = @MCS@ MKDIR_P = @MKDIR_P@ +MONODOC_CFLAGS = @MONODOC_CFLAGS@ +MONODOC_LIBS = @MONODOC_LIBS@ MONO_ADDINS_DEFAULT_LIB = @MONO_ADDINS_DEFAULT_LIB@ MONO_ADDINS_GUI_DEFAULT_LIB = @MONO_ADDINS_GUI_DEFAULT_LIB@ +MONO_ADDINS_MSBUILD_DEFAULT_LIB = @MONO_ADDINS_MSBUILD_DEFAULT_LIB@ MONO_ADDINS_SETUP_DEFAULT_LIB = @MONO_ADDINS_SETUP_DEFAULT_LIB@ MONO_NUNIT_CFLAGS = @MONO_NUNIT_CFLAGS@ MONO_NUNIT_LIBS = @MONO_NUNIT_LIBS@ @@ -124,9 +128,10 @@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -ASSEMBLY_COMPILER_COMMAND = mcs +ASSEMBLY_COMPILER_COMMAND = @MCS@ ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG ASSEMBLY = ../lib/CommandExtension.dll COMPILE_TARGET = library @@ -155,7 +160,7 @@ all: all-am .SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/makefile-sample.include $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/makefile-sample.include $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -180,9 +185,9 @@ $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(top_srcdir)/configure: $(am__configure_deps) +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh tags: TAGS TAGS: @@ -316,7 +321,9 @@ @ENABLE_TESTS_TRUE@all: $(ASSEMBLY) -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) +$(ASSEMBLY).mdb: $(ASSEMBLY) + +$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) mkdir -p $(dir $(ASSEMBLY)) $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) diff -Nru mono-addins-0.4/Test/FileContentExtension/ChangeLog mono-addins-0.6.1/Test/FileContentExtension/ChangeLog --- mono-addins-0.4/Test/FileContentExtension/ChangeLog 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Test/FileContentExtension/ChangeLog 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,13 @@ +2010-03-26 Lluis Sanchez Gual + + * FileContentExtension.csproj: Disable makefile integration + since we are not using makefiles anymore. + +2009-08-19 Lluis Sanchez Gual + + * FileContentExtension.csproj: Update target framework to 2.0. + +2009/02/06 Lluis Sanchez Gual + + * FileContentExtension.csproj: Updated. + diff -Nru mono-addins-0.4/Test/FileContentExtension/Makefile.am mono-addins-0.6.1/Test/FileContentExtension/Makefile.am --- mono-addins-0.4/Test/FileContentExtension/Makefile.am 2008-11-06 19:51:57.000000000 +0000 +++ mono-addins-0.6.1/Test/FileContentExtension/Makefile.am 2011-04-13 09:00:29.000000000 +0000 @@ -1,4 +1,4 @@ -ASSEMBLY_COMPILER_COMMAND = mcs +ASSEMBLY_COMPILER_COMMAND = @MCS@ ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG ASSEMBLY = ../lib/FileContentExtension.dll COMPILE_TARGET = library @@ -27,7 +27,9 @@ DLL_REFERENCES = -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) +$(ASSEMBLY).mdb: $(ASSEMBLY) + +$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) mkdir -p $(dir $(ASSEMBLY)) $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) diff -Nru mono-addins-0.4/Test/FileContentExtension/Makefile.in mono-addins-0.6.1/Test/FileContentExtension/Makefile.in --- mono-addins-0.4/Test/FileContentExtension/Makefile.in 2008-11-06 19:52:35.000000000 +0000 +++ mono-addins-0.6.1/Test/FileContentExtension/Makefile.in 2011-04-13 09:45:29.000000000 +0000 @@ -30,7 +30,7 @@ PRE_UNINSTALL = : POST_UNINSTALL = : DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(top_srcdir)/makefile-sample.include + $(top_srcdir)/makefile-sample.include ChangeLog subdir = ./Test/FileContentExtension ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac @@ -67,11 +67,15 @@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MCS = @MCS@ MKDIR_P = @MKDIR_P@ +MONODOC_CFLAGS = @MONODOC_CFLAGS@ +MONODOC_LIBS = @MONODOC_LIBS@ MONO_ADDINS_DEFAULT_LIB = @MONO_ADDINS_DEFAULT_LIB@ MONO_ADDINS_GUI_DEFAULT_LIB = @MONO_ADDINS_GUI_DEFAULT_LIB@ +MONO_ADDINS_MSBUILD_DEFAULT_LIB = @MONO_ADDINS_MSBUILD_DEFAULT_LIB@ MONO_ADDINS_SETUP_DEFAULT_LIB = @MONO_ADDINS_SETUP_DEFAULT_LIB@ MONO_NUNIT_CFLAGS = @MONO_NUNIT_CFLAGS@ MONO_NUNIT_LIBS = @MONO_NUNIT_LIBS@ @@ -124,9 +128,10 @@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -ASSEMBLY_COMPILER_COMMAND = mcs +ASSEMBLY_COMPILER_COMMAND = @MCS@ ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG ASSEMBLY = ../lib/FileContentExtension.dll COMPILE_TARGET = library @@ -159,7 +164,7 @@ all: all-am .SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/makefile-sample.include $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/makefile-sample.include $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -184,9 +189,9 @@ $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(top_srcdir)/configure: $(am__configure_deps) +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh tags: TAGS TAGS: @@ -320,7 +325,9 @@ @ENABLE_TESTS_TRUE@all: $(ASSEMBLY) -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) +$(ASSEMBLY).mdb: $(ASSEMBLY) + +$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) mkdir -p $(dir $(ASSEMBLY)) $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) diff -Nru mono-addins-0.4/Test/FileExtender/ChangeLog mono-addins-0.6.1/Test/FileExtender/ChangeLog --- mono-addins-0.4/Test/FileExtender/ChangeLog 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Test/FileExtender/ChangeLog 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,24 @@ +2010-05-21 Lluis Sanchez Gual + + * FileExtender.Bis.addin.xml: Added new tests. + +2010-03-29 Lluis Sanchez Gual + + * FileExtender.csproj: Remove import. + +2010-03-26 Lluis Sanchez Gual + + * Makefile.am: + * FileExtender.csproj: + * FileExtender.addin.xml: + * FileExtender.Bis.addin.xml: Updated and created new tests + for testing extension definition using the new features. + +2009-08-19 Lluis Sanchez Gual + + * FileExtender.csproj: Update target framework to 2.0. + +2009/02/06 Lluis Sanchez Gual + + * FileExtender.csproj: Updated. + diff -Nru mono-addins-0.4/Test/FileExtender/Makefile.am mono-addins-0.6.1/Test/FileExtender/Makefile.am --- mono-addins-0.4/Test/FileExtender/Makefile.am 2008-11-06 19:51:57.000000000 +0000 +++ mono-addins-0.6.1/Test/FileExtender/Makefile.am 2011-04-13 09:00:29.000000000 +0000 @@ -1,10 +1,11 @@ -ASSEMBLY_COMPILER_COMMAND = mcs +ASSEMBLY_COMPILER_COMMAND = @MCS@ ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG ASSEMBLY = ../lib/extras/FileExtender.dll COMPILE_TARGET = library PROJECT_REFERENCES = \ ../../bin/Mono.Addins.dll \ - ../lib/FileContentExtension.dll + ../lib/FileContentExtension.dll \ + ../UnitTests/bin/Debug/UnitTests.dll BUILD_DIR = ../lib/extras @@ -16,7 +17,9 @@ DATA_FILES = ExtraExtender.addin.xml -RESOURCES = FileExtender.addin.xml +RESOURCES = \ + FileExtender.addin.xml \ + FileExtender.Bis.addin.xml EXTRAS = @@ -24,7 +27,9 @@ DLL_REFERENCES = -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) +$(ASSEMBLY).mdb: $(ASSEMBLY) + +$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) mkdir -p $(dir $(ASSEMBLY)) $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) diff -Nru mono-addins-0.4/Test/FileExtender/Makefile.in mono-addins-0.6.1/Test/FileExtender/Makefile.in --- mono-addins-0.4/Test/FileExtender/Makefile.in 2008-11-06 19:52:35.000000000 +0000 +++ mono-addins-0.6.1/Test/FileExtender/Makefile.in 2011-04-13 09:45:29.000000000 +0000 @@ -30,7 +30,7 @@ PRE_UNINSTALL = : POST_UNINSTALL = : DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(top_srcdir)/makefile-sample.include + $(top_srcdir)/makefile-sample.include ChangeLog subdir = ./Test/FileExtender ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac @@ -67,11 +67,15 @@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MCS = @MCS@ MKDIR_P = @MKDIR_P@ +MONODOC_CFLAGS = @MONODOC_CFLAGS@ +MONODOC_LIBS = @MONODOC_LIBS@ MONO_ADDINS_DEFAULT_LIB = @MONO_ADDINS_DEFAULT_LIB@ MONO_ADDINS_GUI_DEFAULT_LIB = @MONO_ADDINS_GUI_DEFAULT_LIB@ +MONO_ADDINS_MSBUILD_DEFAULT_LIB = @MONO_ADDINS_MSBUILD_DEFAULT_LIB@ MONO_ADDINS_SETUP_DEFAULT_LIB = @MONO_ADDINS_SETUP_DEFAULT_LIB@ MONO_NUNIT_CFLAGS = @MONO_NUNIT_CFLAGS@ MONO_NUNIT_LIBS = @MONO_NUNIT_LIBS@ @@ -124,20 +128,25 @@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -ASSEMBLY_COMPILER_COMMAND = mcs +ASSEMBLY_COMPILER_COMMAND = @MCS@ ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG ASSEMBLY = ../lib/extras/FileExtender.dll COMPILE_TARGET = library PROJECT_REFERENCES = \ ../../bin/Mono.Addins.dll \ - ../lib/FileContentExtension.dll + ../lib/FileContentExtension.dll \ + ../UnitTests/bin/Debug/UnitTests.dll BUILD_DIR = ../lib/extras FILES = FileExtender.cs DATA_FILES = ExtraExtender.addin.xml -RESOURCES = FileExtender.addin.xml +RESOURCES = \ + FileExtender.addin.xml \ + FileExtender.Bis.addin.xml + EXTRAS = REFERENCES = -r:System DLL_REFERENCES = @@ -155,7 +164,7 @@ all: all-am .SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/makefile-sample.include $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/makefile-sample.include $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -180,9 +189,9 @@ $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(top_srcdir)/configure: $(am__configure_deps) +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh tags: TAGS TAGS: @@ -316,7 +325,9 @@ @ENABLE_TESTS_TRUE@all: $(ASSEMBLY) -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) +$(ASSEMBLY).mdb: $(ASSEMBLY) + +$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) mkdir -p $(dir $(ASSEMBLY)) $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) diff -Nru mono-addins-0.4/Test/HelloWorldExtension/ChangeLog mono-addins-0.6.1/Test/HelloWorldExtension/ChangeLog --- mono-addins-0.4/Test/HelloWorldExtension/ChangeLog 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Test/HelloWorldExtension/ChangeLog 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,21 @@ +2010-05-21 Lluis Sanchez Gual + + * AttributeExtensions.cs: Reorganized tests. + +2010-03-26 Lluis Sanchez Gual + + * Makefile.am: + * HelloWorldWriter.cs: + * AttributeExtensions.cs: + * HelloWriterWithMetadata.cs: + * HelloWorldExtension.csproj: Updated and created new tests + for testing extension definition using the new features. + +2009-08-19 Lluis Sanchez Gual + + * HelloWorldExtension.csproj: Update target framework to 2.0. + +2009/02/06 Lluis Sanchez Gual + + * HelloWorldExtension.csproj: Updated. + diff -Nru mono-addins-0.4/Test/HelloWorldExtension/Makefile.am mono-addins-0.6.1/Test/HelloWorldExtension/Makefile.am --- mono-addins-0.4/Test/HelloWorldExtension/Makefile.am 2008-11-06 19:51:57.000000000 +0000 +++ mono-addins-0.6.1/Test/HelloWorldExtension/Makefile.am 2011-04-13 09:00:29.000000000 +0000 @@ -1,4 +1,4 @@ -ASSEMBLY_COMPILER_COMMAND = mcs +ASSEMBLY_COMPILER_COMMAND = @MCS@ ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG ASSEMBLY = ../lib/HelloWorldExtension.dll COMPILE_TARGET = library @@ -13,8 +13,10 @@ endif FILES = \ + AttributeExtensions.cs \ HelloSampleExtender.cs \ - HelloWorldWriter.cs + HelloWorldWriter.cs \ + HelloWriterWithMetadata.cs DATA_FILES = @@ -26,7 +28,9 @@ DLL_REFERENCES = -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) +$(ASSEMBLY).mdb: $(ASSEMBLY) + +$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) mkdir -p $(dir $(ASSEMBLY)) $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) diff -Nru mono-addins-0.4/Test/HelloWorldExtension/Makefile.in mono-addins-0.6.1/Test/HelloWorldExtension/Makefile.in --- mono-addins-0.4/Test/HelloWorldExtension/Makefile.in 2008-11-06 19:52:35.000000000 +0000 +++ mono-addins-0.6.1/Test/HelloWorldExtension/Makefile.in 2011-04-13 09:45:29.000000000 +0000 @@ -30,7 +30,7 @@ PRE_UNINSTALL = : POST_UNINSTALL = : DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(top_srcdir)/makefile-sample.include + $(top_srcdir)/makefile-sample.include ChangeLog subdir = ./Test/HelloWorldExtension ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac @@ -67,11 +67,15 @@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MCS = @MCS@ MKDIR_P = @MKDIR_P@ +MONODOC_CFLAGS = @MONODOC_CFLAGS@ +MONODOC_LIBS = @MONODOC_LIBS@ MONO_ADDINS_DEFAULT_LIB = @MONO_ADDINS_DEFAULT_LIB@ MONO_ADDINS_GUI_DEFAULT_LIB = @MONO_ADDINS_GUI_DEFAULT_LIB@ +MONO_ADDINS_MSBUILD_DEFAULT_LIB = @MONO_ADDINS_MSBUILD_DEFAULT_LIB@ MONO_ADDINS_SETUP_DEFAULT_LIB = @MONO_ADDINS_SETUP_DEFAULT_LIB@ MONO_NUNIT_CFLAGS = @MONO_NUNIT_CFLAGS@ MONO_NUNIT_LIBS = @MONO_NUNIT_LIBS@ @@ -124,9 +128,10 @@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -ASSEMBLY_COMPILER_COMMAND = mcs +ASSEMBLY_COMPILER_COMMAND = @MCS@ ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG ASSEMBLY = ../lib/HelloWorldExtension.dll COMPILE_TARGET = library @@ -136,8 +141,10 @@ BUILD_DIR = ../lib FILES = \ + AttributeExtensions.cs \ HelloSampleExtender.cs \ - HelloWorldWriter.cs + HelloWorldWriter.cs \ + HelloWriterWithMetadata.cs DATA_FILES = RESOURCES = @@ -158,7 +165,7 @@ all: all-am .SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/makefile-sample.include $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/makefile-sample.include $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -183,9 +190,9 @@ $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(top_srcdir)/configure: $(am__configure_deps) +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh tags: TAGS TAGS: @@ -319,7 +326,9 @@ @ENABLE_TESTS_TRUE@all: $(ASSEMBLY) -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) +$(ASSEMBLY).mdb: $(ASSEMBLY) + +$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) mkdir -p $(dir $(ASSEMBLY)) $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) diff -Nru mono-addins-0.4/Test/Makefile.in mono-addins-0.6.1/Test/Makefile.in --- mono-addins-0.4/Test/Makefile.in 2008-11-06 19:52:35.000000000 +0000 +++ mono-addins-0.6.1/Test/Makefile.in 2011-04-13 09:45:29.000000000 +0000 @@ -78,11 +78,15 @@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MCS = @MCS@ MKDIR_P = @MKDIR_P@ +MONODOC_CFLAGS = @MONODOC_CFLAGS@ +MONODOC_LIBS = @MONODOC_LIBS@ MONO_ADDINS_DEFAULT_LIB = @MONO_ADDINS_DEFAULT_LIB@ MONO_ADDINS_GUI_DEFAULT_LIB = @MONO_ADDINS_GUI_DEFAULT_LIB@ +MONO_ADDINS_MSBUILD_DEFAULT_LIB = @MONO_ADDINS_MSBUILD_DEFAULT_LIB@ MONO_ADDINS_SETUP_DEFAULT_LIB = @MONO_ADDINS_SETUP_DEFAULT_LIB@ MONO_NUNIT_CFLAGS = @MONO_NUNIT_CFLAGS@ MONO_NUNIT_LIBS = @MONO_NUNIT_LIBS@ @@ -135,6 +139,7 @@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = UnitTests CommandExtension FileContentExtension HelloWorldExtension SystemInfoExtension FileExtender @@ -142,7 +147,7 @@ all: all-recursive .SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -167,9 +172,9 @@ $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(top_srcdir)/configure: $(am__configure_deps) +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh # This directory's subdirectories are mostly independent; you can cd diff -Nru mono-addins-0.4/Test/SystemInfoExtension/ChangeLog mono-addins-0.6.1/Test/SystemInfoExtension/ChangeLog --- mono-addins-0.4/Test/SystemInfoExtension/ChangeLog 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Test/SystemInfoExtension/ChangeLog 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,15 @@ +2010-03-26 Lluis Sanchez Gual + + * Makefile.am: + * SystemInfoWriter.cs: + * SystemInfoExtension.csproj: Updated and created new tests + for testing extension definition using the new features. + +2009-08-19 Lluis Sanchez Gual + + * SystemInfoExtension.csproj: Update target framework to 2.0. + +2009/02/06 Lluis Sanchez Gual + + * SystemInfoExtension.csproj: Updated. + diff -Nru mono-addins-0.4/Test/SystemInfoExtension/Makefile.am mono-addins-0.6.1/Test/SystemInfoExtension/Makefile.am --- mono-addins-0.4/Test/SystemInfoExtension/Makefile.am 2008-11-06 19:51:57.000000000 +0000 +++ mono-addins-0.6.1/Test/SystemInfoExtension/Makefile.am 2011-04-13 09:00:29.000000000 +0000 @@ -1,9 +1,10 @@ -ASSEMBLY_COMPILER_COMMAND = mcs +ASSEMBLY_COMPILER_COMMAND = gmcs ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG ASSEMBLY = ../lib/SystemInfoExtension.dll COMPILE_TARGET = library PROJECT_REFERENCES = \ ../../bin/Mono.Addins.dll \ + ../lib/CommandExtension.dll \ ../UnitTests/bin/Debug/UnitTests.dll BUILD_DIR = ../lib @@ -29,7 +30,9 @@ DLL_REFERENCES = -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) $(MAIN_RESOURCE) +$(ASSEMBLY).mdb: $(ASSEMBLY) + +$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) $(MAIN_RESOURCE) mkdir -p $(dir $(ASSEMBLY)) $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) /res:$(MAIN_RESOURCE) $(build_sources) $(build_resources_embed) $(build_references_ref) diff -Nru mono-addins-0.4/Test/SystemInfoExtension/Makefile.in mono-addins-0.6.1/Test/SystemInfoExtension/Makefile.in --- mono-addins-0.4/Test/SystemInfoExtension/Makefile.in 2008-11-06 19:52:35.000000000 +0000 +++ mono-addins-0.6.1/Test/SystemInfoExtension/Makefile.in 2011-04-13 09:45:29.000000000 +0000 @@ -30,7 +30,7 @@ PRE_UNINSTALL = : POST_UNINSTALL = : DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(top_srcdir)/makefile-sample.include + $(top_srcdir)/makefile-sample.include ChangeLog subdir = ./Test/SystemInfoExtension ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac @@ -67,11 +67,15 @@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MCS = @MCS@ MKDIR_P = @MKDIR_P@ +MONODOC_CFLAGS = @MONODOC_CFLAGS@ +MONODOC_LIBS = @MONODOC_LIBS@ MONO_ADDINS_DEFAULT_LIB = @MONO_ADDINS_DEFAULT_LIB@ MONO_ADDINS_GUI_DEFAULT_LIB = @MONO_ADDINS_GUI_DEFAULT_LIB@ +MONO_ADDINS_MSBUILD_DEFAULT_LIB = @MONO_ADDINS_MSBUILD_DEFAULT_LIB@ MONO_ADDINS_SETUP_DEFAULT_LIB = @MONO_ADDINS_SETUP_DEFAULT_LIB@ MONO_NUNIT_CFLAGS = @MONO_NUNIT_CFLAGS@ MONO_NUNIT_LIBS = @MONO_NUNIT_LIBS@ @@ -124,14 +128,16 @@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -ASSEMBLY_COMPILER_COMMAND = mcs +ASSEMBLY_COMPILER_COMMAND = gmcs ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG ASSEMBLY = ../lib/SystemInfoExtension.dll COMPILE_TARGET = library PROJECT_REFERENCES = \ ../../bin/Mono.Addins.dll \ + ../lib/CommandExtension.dll \ ../UnitTests/bin/Debug/UnitTests.dll BUILD_DIR = ../lib @@ -163,7 +169,7 @@ all: all-am .SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/makefile-sample.include $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/makefile-sample.include $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -188,9 +194,9 @@ $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(top_srcdir)/configure: $(am__configure_deps) +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh tags: TAGS TAGS: @@ -324,7 +330,9 @@ @ENABLE_TESTS_TRUE@all: $(ASSEMBLY) $(SATELLITE_ASSEMBLY) -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) $(MAIN_RESOURCE) +$(ASSEMBLY).mdb: $(ASSEMBLY) + +$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) $(MAIN_RESOURCE) mkdir -p $(dir $(ASSEMBLY)) $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) /res:$(MAIN_RESOURCE) $(build_sources) $(build_resources_embed) $(build_references_ref) diff -Nru mono-addins-0.4/Test/UnitTests/ChangeLog mono-addins-0.6.1/Test/UnitTests/ChangeLog --- mono-addins-0.4/Test/UnitTests/ChangeLog 1970-01-01 00:00:00.000000000 +0000 +++ mono-addins-0.6.1/Test/UnitTests/ChangeLog 2011-04-13 09:00:29.000000000 +0000 @@ -0,0 +1,57 @@ +2010-05-21 Lluis Sanchez Gual + + * Makefile.am: + * UnitTests.csproj: + * TestExtensions.cs: + * ExtensionModel/AttrExtensionWithManyNodes.cs: + * ExtensionModel/MultiAssemblyTestExtensionPoint.cs: Added new + tests. + +2010-05-21 Lluis Sanchez Gual + + * IWriter.cs: + * Makefile.am: + * TestEvents.cs: + * ExtensionModel: + * ComplexNode.cs: + * UnitTests.csproj: + * TestExtensions.cs: + * ISampleExtender.cs: + * NodeWithAttribute.cs: + * GlobalInfoCondition.cs: + * IWriterWithMetadata.cs: + * ParameterInfoCondition.cs: + * ExtensionModel/IWriter.cs: + * ExtensionModel/ComplexNode.cs: + * ExtensionModel/ISampleExtender.cs: + * ExtensionModel/NodeWithAttribute.cs: + * ExtensionModel/IWriterWithMetadata.cs: + * ExtensionModel/GlobalInfoCondition.cs: + * ExtensionModel/ParameterInfoCondition.cs: + * ExtensionModel/SimpleExtensionAttribute.cs: Reorganized + tests. + +2010-03-26 Lluis Sanchez Gual + + * IWriter.cs: + * Makefile.am: + * TestBase.cs: + * TestSetup.cs: + * TestEvents.cs: + * UnitTests.csproj: + * TestLoadUnload.cs: + * TestConditions.cs: + * TestExtensions.cs: + * SimpleApp.addin.xml: + * NodeWithAttribute.cs: + * IWriterWithMetadata.cs: Updated and created new tests for + testing extension definition using the new features. + +2009-08-19 Lluis Sanchez Gual + + * UnitTests.csproj: Update target framework to 2.0. + +2009/02/06 Lluis Sanchez Gual + + * UnitTests.csproj: Updated. + diff -Nru mono-addins-0.4/Test/UnitTests/Makefile.am mono-addins-0.6.1/Test/UnitTests/Makefile.am --- mono-addins-0.4/Test/UnitTests/Makefile.am 2008-11-06 19:51:57.000000000 +0000 +++ mono-addins-0.6.1/Test/UnitTests/Makefile.am 2011-04-13 09:00:29.000000000 +0000 @@ -1,8 +1,11 @@ -ASSEMBLY_COMPILER_COMMAND = mcs +ASSEMBLY_COMPILER_COMMAND = @MCS@ ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG ASSEMBLY = ./bin/Debug/UnitTests.dll COMPILE_TARGET = library -PROJECT_REFERENCES = ../../bin/Mono.Addins.dll +PROJECT_REFERENCES = \ + ../../bin/Mono.Addins.CecilReflector.dll \ + ../../bin/Mono.Addins.dll \ + ../../bin/Mono.Addins.Setup.dll BUILD_DIR = ./bin/Debug NOINSTALL=yes @@ -14,35 +17,53 @@ FILES = \ AddinInformationTests.cs \ - ComplexNode.cs \ - GlobalInfoCondition.cs \ - ISampleExtender.cs \ - IWriter.cs \ - ParameterInfoCondition.cs \ + ExtensionModel/AttrExtensionWithManyNodes.cs \ + ExtensionModel/ComplexNode.cs \ + ExtensionModel/GlobalInfoCondition.cs \ + ExtensionModel/ISampleExtender.cs \ + ExtensionModel/IWriter.cs \ + ExtensionModel/IWriterWithMetadata.cs \ + ExtensionModel/MultiAssemblyTestExtensionPoint.cs \ + ExtensionModel/NodeWithAttribute.cs \ + ExtensionModel/ParameterInfoCondition.cs \ + ExtensionModel/Properties.cs \ + ExtensionModel/SimpleExtensionAttribute.cs \ + TestAddinDescription.cs \ TestBase.cs \ TestConditions.cs \ TestEvents.cs \ TestExtensions.cs \ TestLoadUnload.cs \ + TestLoadXmlAddinDescription.cs \ TestLocalization.cs \ - TestSetup.cs + TestSetup.cs \ + TestSetupService.cs \ + TestVerifyAddinDescription.cs \ + Util.cs DATA_FILES = \ SimpleApp.addin.xml \ test.addins -RESOURCES = +RESOURCES = \ + TestManifest2.xml \ + TestManifest2-bis.xml \ + TestManifest3.xml EXTRAS = REFERENCES = \ -pkg:mono-nunit \ + -pkg:nunit \ -r:System \ + -r:System.Core \ -r:System.Xml DLL_REFERENCES = -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) +$(ASSEMBLY).mdb: $(ASSEMBLY) + +$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) mkdir -p $(dir $(ASSEMBLY)) $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref) diff -Nru mono-addins-0.4/Test/UnitTests/Makefile.in mono-addins-0.6.1/Test/UnitTests/Makefile.in --- mono-addins-0.4/Test/UnitTests/Makefile.in 2008-11-06 19:52:35.000000000 +0000 +++ mono-addins-0.6.1/Test/UnitTests/Makefile.in 2011-04-13 09:45:29.000000000 +0000 @@ -30,7 +30,7 @@ PRE_UNINSTALL = : POST_UNINSTALL = : DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(top_srcdir)/makefile-sample.include + $(top_srcdir)/makefile-sample.include ChangeLog subdir = ./Test/UnitTests ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac @@ -67,11 +67,15 @@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MCS = @MCS@ MKDIR_P = @MKDIR_P@ +MONODOC_CFLAGS = @MONODOC_CFLAGS@ +MONODOC_LIBS = @MONODOC_LIBS@ MONO_ADDINS_DEFAULT_LIB = @MONO_ADDINS_DEFAULT_LIB@ MONO_ADDINS_GUI_DEFAULT_LIB = @MONO_ADDINS_GUI_DEFAULT_LIB@ +MONO_ADDINS_MSBUILD_DEFAULT_LIB = @MONO_ADDINS_MSBUILD_DEFAULT_LIB@ MONO_ADDINS_SETUP_DEFAULT_LIB = @MONO_ADDINS_SETUP_DEFAULT_LIB@ MONO_NUNIT_CFLAGS = @MONO_NUNIT_CFLAGS@ MONO_NUNIT_LIBS = @MONO_NUNIT_LIBS@ @@ -124,39 +128,61 @@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -ASSEMBLY_COMPILER_COMMAND = mcs +ASSEMBLY_COMPILER_COMMAND = @MCS@ ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG ASSEMBLY = ./bin/Debug/UnitTests.dll COMPILE_TARGET = library -PROJECT_REFERENCES = ../../bin/Mono.Addins.dll +PROJECT_REFERENCES = \ + ../../bin/Mono.Addins.CecilReflector.dll \ + ../../bin/Mono.Addins.dll \ + ../../bin/Mono.Addins.Setup.dll + BUILD_DIR = ./bin/Debug NOINSTALL = yes FILES = \ AddinInformationTests.cs \ - ComplexNode.cs \ - GlobalInfoCondition.cs \ - ISampleExtender.cs \ - IWriter.cs \ - ParameterInfoCondition.cs \ + ExtensionModel/AttrExtensionWithManyNodes.cs \ + ExtensionModel/ComplexNode.cs \ + ExtensionModel/GlobalInfoCondition.cs \ + ExtensionModel/ISampleExtender.cs \ + ExtensionModel/IWriter.cs \ + ExtensionModel/IWriterWithMetadata.cs \ + ExtensionModel/MultiAssemblyTestExtensionPoint.cs \ + ExtensionModel/NodeWithAttribute.cs \ + ExtensionModel/ParameterInfoCondition.cs \ + ExtensionModel/Properties.cs \ + ExtensionModel/SimpleExtensionAttribute.cs \ + TestAddinDescription.cs \ TestBase.cs \ TestConditions.cs \ TestEvents.cs \ TestExtensions.cs \ TestLoadUnload.cs \ + TestLoadXmlAddinDescription.cs \ TestLocalization.cs \ - TestSetup.cs + TestSetup.cs \ + TestSetupService.cs \ + TestVerifyAddinDescription.cs \ + Util.cs DATA_FILES = \ SimpleApp.addin.xml \ test.addins -RESOURCES = +RESOURCES = \ + TestManifest2.xml \ + TestManifest2-bis.xml \ + TestManifest3.xml + EXTRAS = REFERENCES = \ -pkg:mono-nunit \ + -pkg:nunit \ -r:System \ + -r:System.Core \ -r:System.Xml DLL_REFERENCES = @@ -174,7 +200,7 @@ all: all-am .SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/makefile-sample.include $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/makefile-sample.include $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -199,9 +225,9 @@ $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(top_srcdir)/configure: $(am__configure_deps) +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh tags: TAGS TAGS: @@ -336,7 +362,9 @@ @ENABLE_TESTS_TRUE@all: $(ASSEMBLY) @ENABLE_TESTS_FALSE@all: -$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) $(build_datafiles) +$(ASSEMBLY).mdb: $(ASSEMBLY) + +$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) mkdir -p $(dir $(ASSEMBLY)) $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ -target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) $(build_references_ref)