diff options
author | Matt Ward <ward.matt@gmail.com> | 2014-02-12 21:14:55 +0400 |
---|---|---|
committer | Matt Ward <ward.matt@gmail.com> | 2014-02-12 21:14:55 +0400 |
commit | 0f04715e2a8081456253def9687fd59193231230 (patch) | |
tree | 84b7b63385f900c870f6befcb4e0e09dc2210102 | |
parent | d9eba24eafd74dfe772568ae51c6578dd576b139 (diff) | |
parent | 38a5f2cbdb88f3ef83b500c5ec319d5de90d3f4e (diff) |
Merge branch 'master' into nuget-integration
174 files changed, 3806 insertions, 1775 deletions
diff --git a/.gitignore b/.gitignore index 9879dd21ee..90f166ff55 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ obj/ /main/tests/Ide.Tests/bin /main/src/addins/MonoDevelop.Debugger.Win32/CorApi/bin /main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/bin +/main/src/core/MonoDevelop.Core/BuildVariables.cs #VS writes these sometimes even when it doesn't change anything /main/_UpgradeReport_Files @@ -55,10 +55,10 @@ Bear in mind that if you are installing under a custom prefix, you may need to m *(It's possible that you need to install for your locale to be correctly set.)* -Packaging for OSX +Packaging for OS X ----------------- -To package MonoDevelop for OSX in a convenient MonoDevelop.app +To package MonoDevelop for OS X in a convenient MonoDevelop.app file, just do this after MonoDevelop has finished building (with `make`): `cd main/build/MacOSX ; make MonoDevelop.app` @@ -180,11 +180,9 @@ configure_packages () create_local_config () { - # Get the version from configure.in, if it exists - if test -a $path/configure.in; then - ver=`grep AC_INIT $path/configure.in | cut -d "," -f 2 | sed "s/ //"` - elif test -a $path/configure; then - ver=`grep ^VERSION= $path/configure | cut -d "=" -f 2 | sed "s/ //"` + # Get the version from the version.config file, if it exists + if test -a version.config; then + ver=`grep ^Version version.config|cut -d '=' -f 2|tr -d '\n'` else ver=VERSION fi diff --git a/extras/MonoDevelop.Database/configure.in b/extras/MonoDevelop.Database/configure.in index c06c0fc278..094f1247cc 100644 --- a/extras/MonoDevelop.Database/configure.in +++ b/extras/MonoDevelop.Database/configure.in @@ -1,4 +1,4 @@ -AC_INIT([monodevelop-database], 4.2.3, [monodevelop-list@lists.ximian.com]) +AC_INIT([monodevelop-database], m4_esyscmd_s([grep ^Version ../../version.config|cut -d '=' -f 2|tr -d '\n']), [monodevelop-list@lists.ximian.com]) AC_PREREQ(2.53) AM_INIT_AUTOMAKE([1.9 tar-ustar]) AM_MAINTAINER_MODE diff --git a/main/Makefile.am b/main/Makefile.am index 8c039cc542..25f753a494 100644 --- a/main/Makefile.am +++ b/main/Makefile.am @@ -2,6 +2,8 @@ include $(top_srcdir)/xbuild.include SUBDIRS = external . contrib src po man theme-icons build tests +MD_CONFIGURE=$(top_srcdir)/../scripts/configure.sh + #capture aclocal flags for autoreconf ACLOCAL_AMFLAGS=$(ACLOCAL_FLAGS) @@ -11,29 +13,18 @@ buildinfo = $(top_builddir)/build/bin/buildinfo all: vcrevision -all-local: sln_build +all-local: vcrevision sln_build clean: clean-local clean-local: sln_clean vcrevision: - @if test -d ../.git; then \ - version=$$(cd ..; \ - LANG=C; export LANG; \ - git rev-parse HEAD; \ - ); \ - echo "$$version" > "vcrevision"; \ - else \ - if test ! -f ./vcrevision; then \ - echo "unknown" > "vcrevision"; \ - fi; \ - fi - -$(buildinfo): vcrevision + touch vcrevision + +$(buildinfo): @mkdir -p "$(top_builddir)/build/bin" - @echo "Git revision: $$(cat $(top_srcdir)/vcrevision)" > "$@" - @echo "Build date: $$(date -u +'%Y-%m-%d %H:%M:%S%z')" >> "$@" + @$(MD_CONFIGURE) gen-buildinfo "$(top_builddir)/build/bin" @echo "Updated build information" @cat $(buildinfo) @@ -169,7 +160,7 @@ app-dir: all # we can't use the variables that are conditionally defined EXTRA_DIST = $(bin_SCRIPTS) $(desktop_DATA) $(pixmap_DATA) \ - monodevelop.xml $(pkgconfig_in_files) vcrevision external/Makefile.in \ + monodevelop.xml $(pkgconfig_in_files) external/Makefile.in \ Main.sln \ md.targets diff --git a/main/build/MacOSX/Makefile.am b/main/build/MacOSX/Makefile.am index 25012cfb0f..af39321da2 100644 --- a/main/build/MacOSX/Makefile.am +++ b/main/build/MacOSX/Makefile.am @@ -5,20 +5,10 @@ MAC_APP_LIB_DIR=$(MACOS)/lib/monodevelop ADDINS=$(MACOS)/lib/monodevelop/AddIns EXTRAS=$(top_srcdir)/../extras ARTIFACTS=$(top_srcdir)/../../artifacts +MD_CONFIGURE=$(top_srcdir)/../scripts/configure.sh -# In which commit did the MonoDevelop version change? 00000000 if uncommitted -commit_of_last_version_change := $(shell LANG=C git blame $(top_srcdir)/configure.in | grep AC_INIT | sed 's/ .*//') - -# How many commits have passed since $(-commit-of-last-version-change)? -# "0" when commit hash is invalid (e.g. 00000000) -num_commits_since_version_change := $(shell LANG=C git rev-list --count $(commit_of_last_version_change)..HEAD) - -PACKAGE_VERSION_MAJOR=0$(word 1, $(subst ., ,$(VERSION))) -PACKAGE_VERSION_MINOR=$(word 2, $(subst ., ,$(VERSION))) -PACKAGE_VERSION_REV=0$(word 3, $(subst ., ,$(VERSION))) -PACKAGE_VERSION_BUILD=$(num_commits_since_version_change) -PACKAGE_UPDATE_ID=$(shell echo $(PACKAGE_VERSION_MAJOR) $(PACKAGE_VERSION_MINOR) $(PACKAGE_VERSION_REV) $(PACKAGE_VERSION_BUILD) | awk '{printf "%d%02d%02d%04d",$$1,$$2,$$3,$$4}') -BUNDLE_VERSION=$(shell echo $(PACKAGE_VERSION_MAJOR) $(PACKAGE_VERSION_MINOR) $(PACKAGE_VERSION_REV) $(PACKAGE_VERSION_BUILD) | awk '{printf "%d.%d.%d.%d",$$1,$$2,$$3,$$4}') +PACKAGE_UPDATE_ID=$(shell $(MD_CONFIGURE) get-releaseid) +BUNDLE_VERSION=$(shell $(MD_CONFIGURE) get-version) CLEANFILES = render.exe #DISTCLEANFILES = @@ -137,19 +127,13 @@ app: monostub @echo "Updating build information" @echo "" - pushd ../..; make buildinfo; popd - - echo "a3140c14-ef90-4019-ae6c-9d93804d6611 $(PACKAGE_UPDATE_ID)" > "$(MACOS)/updateinfo" - - echo "Release ID: $(PACKAGE_UPDATE_ID)" > "$(MACOS)/lib/monodevelop/bin/buildinfo" - @cat ../bin/buildinfo >> "$(MACOS)/lib/monodevelop/bin/buildinfo" + $(MD_CONFIGURE) gen-buildinfo "$(MACOS)/lib/monodevelop/bin" # touch the directory so that update dependencies work touch MonoDevelop.app @echo "" - @echo "MONODEVELOP RELEASE: $(PACKAGE_UPDATE_ID)" - @echo "$$(cat ../../vcrevision)" + @cat "$(MACOS)/lib/monodevelop/bin/buildinfo" @if test -f missing-stuff; then echo ""; echo "Missing stuff:"; cat missing-stuff; fi @echo "" @rm -f missing-stuff diff --git a/main/configure.in b/main/configure.in index 4f2692e0c1..4d4d722bfb 100644 --- a/main/configure.in +++ b/main/configure.in @@ -1,4 +1,4 @@ -AC_INIT([monodevelop], 4.2.3, [monodevelop-list@lists.ximian.com]) +AC_INIT([monodevelop], m4_esyscmd_s([grep ^Version ../version.config|cut -d '=' -f 2|tr -d '\n']), [monodevelop-list@lists.ximian.com]) AC_PREREQ(2.53) AM_INIT_AUTOMAKE([1.10 tar-ustar]) AM_MAINTAINER_MODE @@ -12,9 +12,9 @@ ASSEMBLY_VERSION=4.0.0.0 # the C# side of things. It should be one of the following two formats: # 1) "VERSION_NUMBER" "2.0" # 2) "VERSION_NUMBER BUILD_TYPE BUILD_NUMBER" "2.0 Alpha 1" -PACKAGE_VERSION_LABEL="4.2.3" +PACKAGE_VERSION_LABEL="m4_esyscmd_s([grep ^Label ../version.config|cut -d "=" -f 2|tr -d '\n'])" -COMPAT_ADDIN_VERSION=4.0 +COMPAT_ADDIN_VERSION=m4_esyscmd_s([grep ^CompatVersion ../version.config|cut -d "=" -f 2|tr -d '\n']) AC_PATH_PROG(MONO, mono) AC_PATH_PROG(MCS, gmcs) @@ -276,7 +276,6 @@ src/Makefile src/core/Makefile src/core/Mono.Texteditor/Makefile src/core/MonoDevelop.Core/Makefile -src/core/MonoDevelop.Core/BuildVariables.cs src/core/MonoDevelop.Projects.Formats.MSBuild/Makefile src/core/MonoDevelop.Ide/Makefile src/core/MonoDevelop.Startup/Makefile @@ -358,6 +357,9 @@ echo "" echo "Configuration summary" echo "" echo " * Installation prefix = $prefix" +echo " * Version = $VERSION" +echo " * Version Label = $PACKAGE_VERSION_LABEL" +echo " * Compat Version = $COMPAT_ADDIN_VERSION" echo " * C# compiler = $CSC" echo " * Mono class library development extensions: $enable_monoextensions" echo " * Version control providers:" diff --git a/main/contrib/ICSharpCode.Decompiler/Ast/TextTokenWriter.cs b/main/contrib/ICSharpCode.Decompiler/Ast/TextTokenWriter.cs index 45ed21bd69..b77284cb24 100644 --- a/main/contrib/ICSharpCode.Decompiler/Ast/TextTokenWriter.cs +++ b/main/contrib/ICSharpCode.Decompiler/Ast/TextTokenWriter.cs @@ -269,7 +269,7 @@ namespace ICSharpCode.Decompiler.Ast public override void WritePrimitiveValue(object value, string literalValue = null) { - + output.WritePrimitiveValue(value, literalValue); } public override void WritePrimitiveType(string type) diff --git a/main/contrib/ICSharpCode.Decompiler/ITextOutput.cs b/main/contrib/ICSharpCode.Decompiler/ITextOutput.cs index f13a55d61b..e459e36e70 100644 --- a/main/contrib/ICSharpCode.Decompiler/ITextOutput.cs +++ b/main/contrib/ICSharpCode.Decompiler/ITextOutput.cs @@ -34,6 +34,7 @@ namespace ICSharpCode.Decompiler void WriteLine(); void WriteDefinition(string text, object definition, bool isLocal = true); void WriteReference(string text, object reference, bool isLocal = false); + void WritePrimitiveValue (object value, string literalValue = null); void AddDebugSymbols(MethodDebugSymbols methodDebugSymbols); diff --git a/main/contrib/ICSharpCode.Decompiler/PlainTextOutput.cs b/main/contrib/ICSharpCode.Decompiler/PlainTextOutput.cs index 6319226d16..6ed760ad39 100644 --- a/main/contrib/ICSharpCode.Decompiler/PlainTextOutput.cs +++ b/main/contrib/ICSharpCode.Decompiler/PlainTextOutput.cs @@ -106,7 +106,12 @@ namespace ICSharpCode.Decompiler { Write(text); } - + + public void WritePrimitiveValue (object value, string literalValue) + { + Write (value.ToString ()); + } + void ITextOutput.MarkFoldStart(string collapsedText, bool defaultCollapsed) { } diff --git a/main/external/debugger-libs b/main/external/debugger-libs -Subproject 75d09e3e2697bf2c9d604fbacbedd639b8da622 +Subproject d62a7388b972490fc72c5c4905333789864d172 diff --git a/main/external/mono-addins b/main/external/mono-addins -Subproject d2665f78225fdb50370a2c9c1e64dbb1ccc7a7e +Subproject cf78748bfce43727b2dd80a26359243e4a782f4 diff --git a/main/external/nrefactory b/main/external/nrefactory -Subproject c1b8ab5268d5f86034079c0d69f9d8d54a49ac4 +Subproject 1403af7038e52d4a5ab6a3156d9b5fed363e8f8 diff --git a/main/external/xwt b/main/external/xwt -Subproject bef4c628b06639f67734d6de50b0b14c957395f +Subproject 5a2a4c1f35ab45b0f880e54139a142d3a862334 diff --git a/main/src/addins/CBinding/AddinInfo.cs b/main/src/addins/CBinding/AddinInfo.cs new file mode 100644 index 0000000000..2d04910221 --- /dev/null +++ b/main/src/addins/CBinding/AddinInfo.cs @@ -0,0 +1,20 @@ + +using System; +using Mono.Addins; +using Mono.Addins.Description; + +[assembly:Addin ("CBinding", + Namespace = "MonoDevelop", + Version = MonoDevelop.BuildInfo.Version, + Category = "Language bindings")] + +[assembly:AddinName ("C/C++ Language Binding")] +[assembly:AddinDescription ("C/C++ Language binding")] + +[assembly:AddinDependency ("Core", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("Ide", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("DesignerSupport", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("Deployment", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("Deployment.Linux", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("Refactoring", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("SourceEditor2", MonoDevelop.BuildInfo.Version)] diff --git a/main/src/addins/CBinding/CBinding.addin.xml b/main/src/addins/CBinding/CBinding.addin.xml index dd95393524..2240d391e1 100644 --- a/main/src/addins/CBinding/CBinding.addin.xml +++ b/main/src/addins/CBinding/CBinding.addin.xml @@ -1,23 +1,5 @@ -<Addin id = "CBinding" - namespace = "MonoDevelop" - name = "C/C++ Language Binding" - author = "Marcos David Marín Amador" - copyright = "MIT X11" - url = "http://www.monodevelop.com" - description = "C/C++ Language binding" - category = "Language bindings" - version = "4.2.3"> +<ExtensionModel> - <Dependencies> - <Addin id = "Core" version = "4.2.3"/> - <Addin id = "Ide" version = "4.2.3"/> - <Addin id = "Deployment" version = "4.2.3"/> - <Addin id = "Deployment.Linux" version = "4.2.3"/> - <Addin id = "SourceEditor2" version = "4.2.3" /> - <Addin id = "DesignerSupport" version = "4.2.3" /> - <Addin id = "Refactoring" version = "4.2.3" /> - </Dependencies> - <Extension path = "/MonoDevelop/Core/StockIcons"> <StockIcon stockid = "md-union" resource = "Icons.16x16.Union" size="Menu"/> <StockIcon stockid = "md-protected-union" resource = "Icons.16x16.ProtectedUnion" size="Menu"/> @@ -259,4 +241,4 @@ <Extension path = "/MonoDevelop/Ide/CompletionCharacters"> <Complete id="C/C++" insertbefore="Other" insertafter="Html" language="C/C++" commitOnSpace="True" commitChars="{}[]().,:;+-*/%&|^!~=<>?@#'"\"/> </Extension> -</Addin> +</ExtensionModel> diff --git a/main/src/addins/CBinding/CBinding.csproj b/main/src/addins/CBinding/CBinding.csproj index fd0286c6ef..1b224c3cf1 100644 --- a/main/src/addins/CBinding/CBinding.csproj +++ b/main/src/addins/CBinding/CBinding.csproj @@ -326,6 +326,7 @@ <Compile Include="Parser\CTagsManager.cs" /> <Compile Include="Parser\ExuberantCTagsManager.cs" /> <Compile Include="Parser\BsdCTagsManager.cs" /> + <Compile Include="AddinInfo.cs" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> diff --git a/main/src/addins/CSharpBinding/AddinInfo.cs b/main/src/addins/CSharpBinding/AddinInfo.cs index 150c294c84..2b9deee4f4 100644 --- a/main/src/addins/CSharpBinding/AddinInfo.cs +++ b/main/src/addins/CSharpBinding/AddinInfo.cs @@ -15,3 +15,7 @@ using Mono.Addins.Description; [assembly:AddinDependency ("Ide", MonoDevelop.BuildInfo.Version)] [assembly:AddinDependency ("Refactoring", MonoDevelop.BuildInfo.Version)] [assembly:AddinDependency ("SourceEditor2", MonoDevelop.BuildInfo.Version)] + +// Submodules +[assembly:AddinModule ("MonoDevelop.CSharpBinding.Autotools.dll")] +[assembly:AddinModule ("MonoDevelop.CSharpBinding.AspNet.dll")] diff --git a/main/src/addins/CSharpBinding/AspNet/AddinInfo.cs b/main/src/addins/CSharpBinding/AspNet/AddinInfo.cs new file mode 100644 index 0000000000..dbd9d75be0 --- /dev/null +++ b/main/src/addins/CSharpBinding/AspNet/AddinInfo.cs @@ -0,0 +1,6 @@ + +using System; +using Mono.Addins; +using Mono.Addins.Description; + +[assembly:AddinDependency ("AspNet", MonoDevelop.BuildInfo.Version)] diff --git a/main/src/addins/CSharpBinding/AspNet/CSharpBinding.AspNet.csproj b/main/src/addins/CSharpBinding/AspNet/CSharpBinding.AspNet.csproj index 77c74f509f..1a9efe1a2a 100644 --- a/main/src/addins/CSharpBinding/AspNet/CSharpBinding.AspNet.csproj +++ b/main/src/addins/CSharpBinding/AspNet/CSharpBinding.AspNet.csproj @@ -45,6 +45,7 @@ <ItemGroup> <Compile Include="AspLanguageBuilder.cs" /> <Compile Include="ASPNetReferenceFinder.cs" /> + <Compile Include="AddinInfo.cs" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\..\AspNet\MonoDevelop.AspNet\MonoDevelop.AspNet.csproj"> @@ -117,6 +118,16 @@ <Name>Mono.Debugging</Name> <Private>False</Private> </ProjectReference> + <ProjectReference Include="..\..\..\..\external\mono-addins\Mono.Addins\Mono.Addins.csproj"> + <Project>{91DD5A2D-9FE3-4C3C-9253-876141874DAD}</Project> + <Name>Mono.Addins</Name> + <Private>False</Private> + </ProjectReference> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> + <ItemGroup> + <EmbeddedResource Include="ExtensionModel.addin.xml"> + <LogicalName>ExtensionModel.addin.xml</LogicalName> + </EmbeddedResource> + </ItemGroup> </Project>
\ No newline at end of file diff --git a/main/src/addins/CSharpBinding/AspNet/ExtensionModel.addin.xml b/main/src/addins/CSharpBinding/AspNet/ExtensionModel.addin.xml new file mode 100644 index 0000000000..047552a725 --- /dev/null +++ b/main/src/addins/CSharpBinding/AspNet/ExtensionModel.addin.xml @@ -0,0 +1,9 @@ +<ExtensionModel> + <Extension path = "/MonoDevelop/Asp/CompletionBuilders"> + <Class class = "MonoDevelop.CSharp.Completion.AspLanguageBuilder" /> + </Extension> + <Extension path = "/MonoDevelop/Ide/ReferenceFinder"> + <ReferenceFinder supportedmimetypes = "application/x-aspx,application/x-ascx,application/x-asax,application/x-ashx,application/x-asmx,application/x-asix" + class = "MonoDevelop.CSharp.Refactoring.ASPNetReferenceFinder" /> + </Extension> +</ExtensionModel> diff --git a/main/src/addins/CSharpBinding/Autotools/AddinInfo.cs b/main/src/addins/CSharpBinding/Autotools/AddinInfo.cs new file mode 100644 index 0000000000..06fb5e9711 --- /dev/null +++ b/main/src/addins/CSharpBinding/Autotools/AddinInfo.cs @@ -0,0 +1,6 @@ + +using System; +using Mono.Addins; +using Mono.Addins.Description; + +[assembly:AddinDependency ("Autotools", MonoDevelop.BuildInfo.Version)] diff --git a/main/src/addins/CSharpBinding/Autotools/Autotools.csproj b/main/src/addins/CSharpBinding/Autotools/Autotools.csproj index ee32210300..e3db35b5e0 100644 --- a/main/src/addins/CSharpBinding/Autotools/Autotools.csproj +++ b/main/src/addins/CSharpBinding/Autotools/Autotools.csproj @@ -80,13 +80,24 @@ <Name>MonoDevelop.DesignerSupport</Name> <Private>False</Private> </ProjectReference> + <ProjectReference Include="..\..\..\..\external\mono-addins\Mono.Addins\Mono.Addins.csproj"> + <Project>{91DD5A2D-9FE3-4C3C-9253-876141874DAD}</Project> + <Name>Mono.Addins</Name> + <Private>False</Private> + </ProjectReference> </ItemGroup> <ItemGroup> <Reference Include="System" /> </ItemGroup> <ItemGroup> <Compile Include="CSharpAutotoolsSetup.cs" /> + <Compile Include="AddinInfo.cs" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="..\..\..\..\md.targets" /> + <ItemGroup> + <EmbeddedResource Include="ExtensionModel.addin.xml"> + <LogicalName>ExtensionModel.addin.xml</LogicalName> + </EmbeddedResource> + </ItemGroup> </Project> diff --git a/main/src/addins/CSharpBinding/Autotools/ExtensionModel.addin.xml b/main/src/addins/CSharpBinding/Autotools/ExtensionModel.addin.xml new file mode 100644 index 0000000000..801d6cbff2 --- /dev/null +++ b/main/src/addins/CSharpBinding/Autotools/ExtensionModel.addin.xml @@ -0,0 +1,5 @@ +<ExtensionModel> + <Extension path = "/MonoDevelop/Autotools/SimpleSetups"> + <Class class="CSharpBinding.Autotools.CSharpAutotoolsSetup" /> + </Extension> +</ExtensionModel> diff --git a/main/src/addins/CSharpBinding/CSharpBinding.addin.xml b/main/src/addins/CSharpBinding/CSharpBinding.addin.xml index 819abef3bb..7f4545ceb7 100644 --- a/main/src/addins/CSharpBinding/CSharpBinding.addin.xml +++ b/main/src/addins/CSharpBinding/CSharpBinding.addin.xml @@ -263,32 +263,4 @@ <Complete id="C#" insertbefore="Html" language="C#" commitOnSpace="True" commitChars="{}[]().,:;+-*/%&|^!~=<>?@#'"\"/> </Extension> - - <Module> - <Runtime> - <Import assembly="MonoDevelop.CSharpBinding.Autotools.dll"/> - </Runtime> - <Dependencies> - <Addin id="Autotools" version="4.2.3"/> - </Dependencies> - <Extension path = "/MonoDevelop/Autotools/SimpleSetups"> - <Class class="CSharpBinding.Autotools.CSharpAutotoolsSetup" /> - </Extension> - </Module> - - <Module> - <Runtime> - <Import assembly="MonoDevelop.CSharpBinding.AspNet.dll"/> - </Runtime> - <Dependencies> - <Addin id="AspNet" version="4.2.3"/> - </Dependencies> - <Extension path = "/MonoDevelop/Asp/CompletionBuilders"> - <Class class = "MonoDevelop.CSharp.Completion.AspLanguageBuilder" /> - </Extension> - <Extension path = "/MonoDevelop/Ide/ReferenceFinder"> - <ReferenceFinder supportedmimetypes = "application/x-aspx,application/x-ascx,application/x-asax,application/x-ashx,application/x-asmx,application/x-asix" - class = "MonoDevelop.CSharp.Refactoring.ASPNetReferenceFinder" /> - </Extension> - </Module> </ExtensionModel> diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/HighlightUsagesExtension.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/HighlightUsagesExtension.cs index 29c20d084e..310feca17a 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/HighlightUsagesExtension.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/HighlightUsagesExtension.cs @@ -205,7 +205,7 @@ namespace MonoDevelop.CSharp.Highlighting continue; var marker = GetMarker (r.Region.BeginLine); - usages.Add (r.Region.Begin); + usages.Add (new Usage (r.Region.Begin, r.ReferenceUsageType)); int offset = r.Offset; int endOffset = offset + r.Length; @@ -365,8 +365,8 @@ namespace MonoDevelop.CSharp.Highlighting handler (this, e); } - List<DocumentLocation> usages = new List<DocumentLocation> (); - IEnumerable<DocumentLocation> IUsageProvider.Usages { + readonly List<Usage> usages = new List<Usage> (); + IEnumerable<Usage> IUsageProvider.Usages { get { return usages; } diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring.CodeIssues/NamingInspection/NameConventionEditRuleDialog.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring.CodeIssues/NamingInspection/NameConventionEditRuleDialog.cs index b534967d1b..6fd7df8189 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring.CodeIssues/NamingInspection/NameConventionEditRuleDialog.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring.CodeIssues/NamingInspection/NameConventionEditRuleDialog.cs @@ -82,8 +82,8 @@ namespace MonoDevelop.CSharp.Refactoring.CodeIssues NameConventionRule rule; - TreeStore entityStore = new TreeStore (typeof(string), typeof(AffectedEntity), typeof(bool)); - TreeStore accessibiltyStore = new TreeStore (typeof(string), typeof(Modifiers), typeof(bool)); + ListStore entityStore = new ListStore (typeof(string), typeof(AffectedEntity), typeof(bool)); + ListStore accessibiltyStore = new ListStore (typeof(string), typeof(Modifiers), typeof(bool)); public NameConventionEditRuleDialog (NameConventionRule rule) { @@ -92,7 +92,6 @@ namespace MonoDevelop.CSharp.Refactoring.CodeIssues this.rule = rule; this.Build (); - treeviewEntities.AppendColumn ("Entity", new CellRendererText (), "text", 0); var ct1 = new CellRendererToggle (); ct1.Toggled += delegate(object o, Gtk.ToggledArgs args) { TreeIter iter; @@ -101,9 +100,9 @@ namespace MonoDevelop.CSharp.Refactoring.CodeIssues entityStore.SetValue (iter, 2, !(bool)entityStore.GetValue (iter, 2)); }; treeviewEntities.AppendColumn ("IsChecked", ct1, "active", 2); + treeviewEntities.AppendColumn ("Entity", new CellRendererText (), "text", 0); treeviewEntities.Model = entityStore; - treeviewAccessibility.AppendColumn ("Entity", new CellRendererText (), "text", 0); var ct2 = new CellRendererToggle (); ct2.Toggled += delegate(object o, Gtk.ToggledArgs args) { TreeIter iter; @@ -112,6 +111,7 @@ namespace MonoDevelop.CSharp.Refactoring.CodeIssues accessibiltyStore.SetValue (iter, 2, !(bool)accessibiltyStore.GetValue (iter, 2)); }; treeviewAccessibility.AppendColumn ("IsChecked", ct2, "active", 2); + treeviewAccessibility.AppendColumn ("Entity", new CellRendererText (), "text", 0); treeviewAccessibility.Model = accessibiltyStore; buttonOk.Clicked += (sender, e) => Apply (); diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CSharpCodeGenerator.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CSharpCodeGenerator.cs index 93bde86a7a..a079e33406 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CSharpCodeGenerator.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CSharpCodeGenerator.cs @@ -500,7 +500,15 @@ namespace MonoDevelop.CSharp.Refactoring if (options.ImplementingType.Properties.Any ()) result.Append (": "); int i = 0; + var properties = new List<IProperty> (); + foreach (IProperty property in options.ImplementingType.Properties) { + if (properties.Any (p => p.Name == property.Name)) + continue; + properties.Add (property); + } + + foreach (IProperty property in properties) { if (property.IsStatic || !property.IsPublic) continue; if (i > 0) @@ -511,7 +519,7 @@ namespace MonoDevelop.CSharp.Refactoring result.Append ("}"); } result.Append ("]\""); - foreach (IProperty property in options.ImplementingType.Properties) { + foreach (IProperty property in properties) { if (property.IsStatic || !property.IsPublic) continue; result.Append (", "); @@ -648,6 +656,8 @@ namespace MonoDevelop.CSharp.Refactoring result.Append ("'" + p.ConstantValue + "'"); } else if (p.ConstantValue is string) { result.Append ("\"" + CSharpTextEditorIndentation.ConvertToStringLiteral ((string)p.ConstantValue) + "\""); + } else if (p.ConstantValue is bool) { + result.Append ((bool)p.ConstantValue ? "true" : "false"); } else { result.Append (p.ConstantValue); } @@ -1033,7 +1043,7 @@ namespace MonoDevelop.CSharp.Refactoring public override void CompleteStatement (MonoDevelop.Ide.Gui.Document doc) { - var fixer = new ConstructFixer (doc.GetFormattingOptions ()); + var fixer = new ConstructFixer (doc.GetFormattingOptions (), doc.Editor.CreateNRefactoryTextEditorOptions ()); int newOffset; if (fixer.TryFix (doc.Editor.Document, doc.Editor.Caret.Offset, out newOffset)) { doc.Editor.Caret.Offset = newOffset; diff --git a/main/src/addins/CSharpBinding/gtk-gui/MonoDevelop.CSharp.Refactoring.CodeIssues.NameConventionEditRuleDialog.cs b/main/src/addins/CSharpBinding/gtk-gui/MonoDevelop.CSharp.Refactoring.CodeIssues.NameConventionEditRuleDialog.cs index 138f3deb21..e1b750e4a6 100644 --- a/main/src/addins/CSharpBinding/gtk-gui/MonoDevelop.CSharp.Refactoring.CodeIssues.NameConventionEditRuleDialog.cs +++ b/main/src/addins/CSharpBinding/gtk-gui/MonoDevelop.CSharp.Refactoring.CodeIssues.NameConventionEditRuleDialog.cs @@ -50,11 +50,13 @@ namespace MonoDevelop.CSharp.Refactoring.CodeIssues // Internal child MonoDevelop.CSharp.Refactoring.CodeIssues.NameConventionEditRuleDialog.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.vbox3 = new global::Gtk.VBox (); this.vbox3.Name = "vbox3"; this.vbox3.Spacing = 6; + this.vbox3.BorderWidth = ((uint)(6)); // Container child vbox3.Gtk.Box+BoxChild this.hbox3 = new global::Gtk.HBox (); this.hbox3.Name = "hbox3"; @@ -70,6 +72,7 @@ namespace MonoDevelop.CSharp.Refactoring.CodeIssues w2.Position = 0; w2.Expand = false; w2.Fill = false; + w2.Padding = ((uint)(6)); // Container child hbox3.Gtk.Box+BoxChild this.entryRuleName = new global::Gtk.Entry (); this.entryRuleName.CanFocus = true; @@ -90,7 +93,6 @@ namespace MonoDevelop.CSharp.Refactoring.CodeIssues this.hbox1.Spacing = 6; // Container child hbox1.Gtk.Box+BoxChild this.table1 = new global::Gtk.Table (((uint)(4)), ((uint)(2)), false); - this.table1.Name = "table1"; this.table1.RowSpacing = ((uint)(6)); this.table1.ColumnSpacing = ((uint)(6)); this.table1.BorderWidth = ((uint)(6)); @@ -110,6 +112,7 @@ namespace MonoDevelop.CSharp.Refactoring.CodeIssues w6.TopAttach = ((uint)(1)); w6.BottomAttach = ((uint)(2)); w6.RightAttach = ((uint)(2)); + w6.YPadding = ((uint)(6)); w6.XOptions = ((global::Gtk.AttachOptions)(4)); // Container child table1.Gtk.Table+TableChild this.GtkScrolledWindow1 = new global::Gtk.ScrolledWindow (); @@ -125,6 +128,8 @@ namespace MonoDevelop.CSharp.Refactoring.CodeIssues global::Gtk.Table.TableChild w8 = ((global::Gtk.Table.TableChild)(this.table1 [this.GtkScrolledWindow1])); w8.TopAttach = ((uint)(3)); w8.BottomAttach = ((uint)(4)); + w8.XPadding = ((uint)(6)); + w8.YPadding = ((uint)(6)); // Container child table1.Gtk.Table+TableChild this.label5 = new global::Gtk.Label (); this.label5.Name = "label5"; diff --git a/main/src/addins/CSharpBinding/gtk-gui/gui.stetic b/main/src/addins/CSharpBinding/gtk-gui/gui.stetic index 92bde23b85..eee4352196 100644 --- a/main/src/addins/CSharpBinding/gtk-gui/gui.stetic +++ b/main/src/addins/CSharpBinding/gtk-gui/gui.stetic @@ -2064,11 +2064,13 @@ None</property> <child internal-child="VBox"> <widget class="Gtk.VBox" id="dialog1_VBox"> <property name="MemberName" /> + <property name="Spacing">6</property> <property name="BorderWidth">2</property> <child> <widget class="Gtk.VBox" id="vbox3"> <property name="MemberName" /> <property name="Spacing">6</property> + <property name="BorderWidth">6</property> <child> <widget class="Gtk.HBox" id="hbox3"> <property name="MemberName" /> @@ -2086,6 +2088,7 @@ None</property> <property name="AutoSize">True</property> <property name="Expand">False</property> <property name="Fill">False</property> + <property name="Padding">6</property> </packing> </child> <child> @@ -2141,6 +2144,7 @@ None</property> <property name="TopAttach">1</property> <property name="BottomAttach">2</property> <property name="RightAttach">2</property> + <property name="YPadding">6</property> <property name="AutoSize">True</property> <property name="XOptions">Fill</property> <property name="XExpand">False</property> @@ -2167,6 +2171,8 @@ None</property> <packing> <property name="TopAttach">3</property> <property name="BottomAttach">4</property> + <property name="XPadding">6</property> + <property name="YPadding">6</property> <property name="AutoSize">False</property> <property name="XExpand">True</property> <property name="XFill">True</property> diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment.Linux/AddinInfo.cs b/main/src/addins/Deployment/MonoDevelop.Deployment.Linux/AddinInfo.cs new file mode 100644 index 0000000000..b3d738acc3 --- /dev/null +++ b/main/src/addins/Deployment/MonoDevelop.Deployment.Linux/AddinInfo.cs @@ -0,0 +1,16 @@ + +using System; +using Mono.Addins; +using Mono.Addins.Description; + +[assembly:Addin ("Deployment.Linux", + Namespace = "MonoDevelop", + Version = MonoDevelop.BuildInfo.Version, + Category = "Deployment")] + +[assembly:AddinName ("Deployment Services for Linux")] +[assembly:AddinDescription ("Provides basic deployment services for Linux")] + +[assembly:AddinDependency ("Core", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("Ide", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("Deployment", MonoDevelop.BuildInfo.Version)] diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment.Linux/MonoDevelop.Deployment.Linux.addin.xml b/main/src/addins/Deployment/MonoDevelop.Deployment.Linux/MonoDevelop.Deployment.Linux.addin.xml index 46ae87f060..39d5404b66 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment.Linux/MonoDevelop.Deployment.Linux.addin.xml +++ b/main/src/addins/Deployment/MonoDevelop.Deployment.Linux/MonoDevelop.Deployment.Linux.addin.xml @@ -1,24 +1,4 @@ -<Addin id = "Deployment.Linux" - namespace = "MonoDevelop" - name = "Deployment Services for Linux" - author = "Lluis Sanchez, Michael Hutchinson" - copyright = "MIT X11" - url = "http://www.monodevelop.com" - description = "Provides basic deployment services for Linux" - category = "Deployment" - version = "4.2.3" - flags = "Hidden" - compatVersion = "4.0"> - - <Runtime> - <Import assembly="MonoDevelop.Deployment.Linux.dll"/> - </Runtime> - - <Dependencies> - <Addin id="Core" version="4.2.3"/> - <Addin id="Ide" version="4.2.3"/> - <Addin id="Deployment" version="4.2.3"/> - </Dependencies> +<ExtensionModel> <Extension path = "/MonoDevelop/Ide/Commands"> </Extension> @@ -98,4 +78,4 @@ <Class class="MonoDevelop.Deployment.Linux.LinuxDeploymentSetup" /> </Condition> </Extension> -</Addin> +</ExtensionModel> diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment.Linux/MonoDevelop.Deployment.Linux.csproj b/main/src/addins/Deployment/MonoDevelop.Deployment.Linux/MonoDevelop.Deployment.Linux.csproj index b1f599cbea..319908f676 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment.Linux/MonoDevelop.Deployment.Linux.csproj +++ b/main/src/addins/Deployment/MonoDevelop.Deployment.Linux/MonoDevelop.Deployment.Linux.csproj @@ -120,6 +120,7 @@ <Compile Include="gtk-gui\MonoDevelop.Deployment.Linux.MenuCategorySelectorDialog.cs" /> <Compile Include="AssemblyInfo.cs" /> <Compile Include="MonoDevelop.Deployment.Linux\LinuxDeploymentSetup.cs" /> + <Compile Include="AddinInfo.cs" /> </ItemGroup> <ItemGroup> <None Include="Makefile.am" /> diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/AddinInfo.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/AddinInfo.cs new file mode 100644 index 0000000000..db9f908173 --- /dev/null +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/AddinInfo.cs @@ -0,0 +1,17 @@ + +using System; +using Mono.Addins; +using Mono.Addins.Description; + +[assembly:Addin ("Deployment", + Namespace = "MonoDevelop", + Version = MonoDevelop.BuildInfo.Version, + Category = "Deployment")] + +[assembly:AddinName ("Deployment Services Core")] +[assembly:AddinDescription ("Provides basic deployment services")] +[assembly:AddinFlags (AddinFlags.Hidden)] + +[assembly:AddinDependency ("Core", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("Ide", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("DesignerSupport", MonoDevelop.BuildInfo.Version)] diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.addin.xml b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.addin.xml index 36c0824235..aebe21cd94 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.addin.xml +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.addin.xml @@ -1,20 +1,4 @@ -<Addin id = "Deployment" - namespace = "MonoDevelop" - name = "Deployment Services Core" - author = "Lluis Sanchez, Michael Hutchinson" - copyright = "MIT X11" - url = "http://www.monodevelop.com" - description = "Provides basic deployment services" - category = "Deployment" - version = "4.2.3" - flags = "Hidden" - compatVersion = "4.0"> - - <Dependencies> - <Addin id="Core" version="4.2.3"/> - <Addin id="Ide" version="4.2.3"/> - <Addin id="DesignerSupport" version="4.2.3"/> - </Dependencies> +<ExtensionModel> <Extension path = "/MonoDevelop/Ide/Commands"> <Category _name = "Deployment" id = "Deployment"> @@ -196,4 +180,4 @@ <Extension path = "/MonoDevelop/Ide/ProjectFeatures"> <!-- <Class class = "MonoDevelop.Deployment.Gui.PackagingFeature" /> --> </Extension> -</Addin> +</ExtensionModel> diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.csproj b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.csproj index 658b2b47fc..9826312fea 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.csproj +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.csproj @@ -158,6 +158,7 @@ <Compile Include="MonoDevelop.Deployment.Gui\SshFuseFileCopyConfigurationEditorWidget.cs" /> <Compile Include="gtk-gui\MonoDevelop.Deployment.Gui.SshFuseFileCopyConfigurationEditorWidget.cs" /> <Compile Include="MonoDevelop.Deployment.Gui\SshFuseFileCopyConfigurationEditor.cs" /> + <Compile Include="AddinInfo.cs" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="gtk-gui\gui.stetic"> diff --git a/main/src/addins/MacPlatform/ExtendedTitleBarWindowBackend.cs b/main/src/addins/MacPlatform/ExtendedTitleBarWindowBackend.cs new file mode 100644 index 0000000000..085e0cad85 --- /dev/null +++ b/main/src/addins/MacPlatform/ExtendedTitleBarWindowBackend.cs @@ -0,0 +1,137 @@ +// +// ExtendedTitleBarWindowBackend.cs +// +// Author: +// Lluis Sanchez Gual <lluis@xamarin.com> +// +// Copyright (c) 2014 Xamarin, Inc (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using MonoDevelop.MacInterop; +using MonoMac.AppKit; +using MonoDevelop.Components; +using Mono.TextEditor; +using MonoDevelop.Components.Extensions; +using Xwt.GtkBackend; + +namespace MonoDevelop.MacIntegration +{ + class ExtendedTitleBarWindowBackend: Xwt.GtkBackend.WindowBackend, IExtendedTitleBarWindowBackend + { + CustomToolbar toolbar; + + class CustomToolbar: Gtk.EventBox + { + public CustomToolbar () + { + WidgetFlags |= Gtk.WidgetFlags.AppPaintable; + } + + public Cairo.ImageSurface Background { + get; + set; + } + + public int TitleBarHeight { + get; + set; + } + + protected override bool OnExposeEvent (Gdk.EventExpose evnt) + { + using (var context = Gdk.CairoHelper.Create (evnt.Window)) { + context.Rectangle ( + evnt.Area.X, + evnt.Area.Y, + evnt.Area.Width, + evnt.Area.Height + ); + context.Clip (); + context.LineWidth = 1; + if (Background != null && Background.Width > 0) { + for (int x=0; x < Allocation.Width; x += Background.Width) { + Background.Show (context, x, -TitleBarHeight); + } + } else { + context.Rectangle (0, 0, Allocation.Width, Allocation.Height); + using (var lg = new Cairo.LinearGradient (0, 0, 0, Allocation.Height)) { + lg.AddColorStop (0, Style.Light (Gtk.StateType.Normal).ToCairoColor ()); + lg.AddColorStop (1, Style.Mid (Gtk.StateType.Normal).ToCairoColor ()); + context.SetSource (lg); + } + context.Fill (); + + } + context.MoveTo (0, Allocation.Height - 0.5); + context.RelLineTo (Allocation.Width, 0); + context.SetSourceColor (MonoDevelop.Ide.Gui.Styles.ToolbarBottomBorderColor); + context.Stroke (); + + context.MoveTo (0, Allocation.Height - 1.5); + context.RelLineTo (Allocation.Width, 0); + context.SetSourceColor (MonoDevelop.Ide.Gui.Styles.ToolbarBottomGlowColor); + context.Stroke (); + + } + return base.OnExposeEvent (evnt); + } + } + + public ExtendedTitleBarWindowBackend () + { + } + + public override void Initialize () + { + base.Initialize (); + + var resource = "maintoolbarbg.png"; + + Window.Realized += delegate { + NSWindow w = GtkQuartz.GetWindow (Window); + w.IsOpaque = false; + NSImage img = MacPlatformService.LoadImage (resource); + w.BackgroundColor = NSColor.FromPatternImage (img); + w.StyleMask |= NSWindowStyle.TexturedBackground; + }; + + toolbar = new CustomToolbar (); + toolbar.Background = MonoDevelop.Components.CairoExtensions.LoadImage (typeof(MacPlatformService).Assembly, resource); + toolbar.TitleBarHeight = MacPlatformService.GetTitleBarHeight (); + MainBox.PackStart (toolbar, false, false, 0); + ((Gtk.Box.BoxChild)MainBox [toolbar]).Position = 0; + } + + public void SetHeaderContent (Xwt.Backends.IWidgetBackend backend) + { + if (toolbar.Child != null) { + WidgetBackend.RemoveChildPlacement (toolbar.Child); + toolbar.Remove (toolbar.Child); + } + if (backend != null) { + toolbar.Child = WidgetBackend.GetWidgetWithPlacement (backend); + toolbar.Show (); + } else { + toolbar.Hide (); + } + } + } +} + diff --git a/main/src/addins/MacPlatform/MacPlatform.cs b/main/src/addins/MacPlatform/MacPlatform.cs index 29775452c1..6c7390868b 100644 --- a/main/src/addins/MacPlatform/MacPlatform.cs +++ b/main/src/addins/MacPlatform/MacPlatform.cs @@ -49,6 +49,7 @@ using MonoDevelop.Ide.Desktop; using MonoDevelop.MacInterop; using MonoDevelop.Components.MainToolbar; using MonoDevelop.MacIntegration.MacMenu; +using MonoDevelop.Components.Extensions; namespace MonoDevelop.MacIntegration { @@ -88,6 +89,7 @@ namespace MonoDevelop.MacIntegration CheckGtkVersion (2, 24, 14); + Xwt.Toolkit.CurrentEngine.RegisterBackend<IExtendedTitleBarWindowBackend,ExtendedTitleBarWindowBackend> (); } static void CheckGtkVersion (uint major, uint minor, uint micro) @@ -643,7 +645,7 @@ namespace MonoDevelop.MacIntegration return new Cairo.Color (r, g, b, a); } - static int GetTitleBarHeight () + internal static int GetTitleBarHeight () { var frame = new RectangleF (0, 0, 100, 100); var rect = NSWindow.ContentRectFor (frame, NSWindowStyle.Titled); @@ -651,20 +653,12 @@ namespace MonoDevelop.MacIntegration } - static NSImage LoadImage (string resource) + internal static NSImage LoadImage (string resource) { - byte[] buffer; - using (var stream = typeof (MacPlatformService).Assembly.GetManifestResourceStream (resource)) { - buffer = new byte [stream.Length]; - stream.Read (buffer, 0, (int)stream.Length); + using (var stream = typeof (MacPlatformService).Assembly.GetManifestResourceStream (resource)) + using (NSData data = NSData.FromStream (stream)) { + return new NSImage (data); } - - // Workaround: loading from file name. - var tmp = Path.GetTempFileName (); - File.WriteAllBytes (tmp, buffer); - var img = new NSImage (tmp); - File.Delete (tmp); - return img; } internal override void SetMainWindowDecorations (Gtk.Window window) diff --git a/main/src/addins/MacPlatform/MacPlatform.csproj b/main/src/addins/MacPlatform/MacPlatform.csproj index 9c2e5e14fa..65921f58a0 100644 --- a/main/src/addins/MacPlatform/MacPlatform.csproj +++ b/main/src/addins/MacPlatform/MacPlatform.csproj @@ -82,6 +82,15 @@ <Project>{E95833C9-90AA-4366-9262-0A1BED148249}</Project> <Name>Xwt.Gtk.Mac</Name> </ProjectReference> + <ProjectReference Include="..\..\..\external\xwt\Xwt.Gtk\Xwt.Gtk.csproj"> + <Project>{C3887A93-B2BD-4097-8E2F-3A063EFF32FD}</Project> + <Name>Xwt.Gtk</Name> + <Private>False</Private> + </ProjectReference> + <ProjectReference Include="..\..\core\Mono.Texteditor\Mono.TextEditor.csproj"> + <Project>{A2329308-3751-4DBD-9A75-5F7B8B024625}</Project> + <Name>Mono.TextEditor</Name> + </ProjectReference> </ItemGroup> <ItemGroup /> <ItemGroup> @@ -117,6 +126,7 @@ <Compile Include="MacMenu\MDSubMenuItem.cs" /> <Compile Include="AddinInfo.cs" /> <Compile Include="MacProxyCredentialProvider.cs" /> + <Compile Include="ExtendedTitleBarWindowBackend.cs" /> </ItemGroup> <ItemGroup> <None Include="Makefile.am" /> diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyBrowserWidget.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyBrowserWidget.cs index f33dedf3b9..d090c458ff 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyBrowserWidget.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyBrowserWidget.cs @@ -1396,12 +1396,12 @@ namespace MonoDevelop.AssemblyBrowser List<AssemblyLoader> definitions = new List<AssemblyLoader> (); List<Project> projects = new List<Project> (); - public AssemblyLoader AddReferenceByAssemblyName (AssemblyNameReference reference, bool selectReference = false) + public AssemblyLoader AddReferenceByAssemblyName (AssemblyNameReference reference, bool selectReference = true) { return AddReferenceByAssemblyName (reference.Name, selectReference); } - public AssemblyLoader AddReferenceByAssemblyName (string assemblyFullName, bool selectReference = false) + public AssemblyLoader AddReferenceByAssemblyName (string assemblyFullName, bool selectReference = true) { string assemblyFile = Runtime.SystemAssemblyService.DefaultAssemblyContext.GetAssemblyLocation (assemblyFullName, null); if (assemblyFile == null || !System.IO.File.Exists (assemblyFile)) { @@ -1417,11 +1417,18 @@ namespace MonoDevelop.AssemblyBrowser return AddReferenceByFileName (assemblyFile, selectReference); } - public AssemblyLoader AddReferenceByFileName (string fileName, bool selectReference = false) + public AssemblyLoader AddReferenceByFileName (string fileName, bool selectReference = true) { var result = definitions.FirstOrDefault (d => d.FileName == fileName); - if (result != null) + if (result != null) { + // Select the result. + if (selectReference) { + ITreeNavigator navigator = TreeView.GetNodeAtObject (result); + navigator.Selected = true; + } + return result; + } result = new AssemblyLoader (this, fileName); definitions.Add (result); @@ -1442,12 +1449,20 @@ namespace MonoDevelop.AssemblyBrowser return result; } - public void AddProject (Project project, bool selectReference = false) + public void AddProject (Project project, bool selectReference = true) { if (project == null) throw new ArgumentNullException ("project"); - if (projects.Contains (project)) + + if (projects.Contains (project)) { + // Select the project. + if (selectReference) { + ITreeNavigator navigator = TreeView.GetNodeAtObject (project); + navigator.Selected = true; + } + return; + } projects.Add (project); ITreeBuilder builder; if (definitions.Count + projects.Count == 1) { diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyLoader.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyLoader.cs index f8053cffd4..c23bc5fc3f 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyLoader.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyLoader.cs @@ -131,6 +131,12 @@ namespace MonoDevelop.AssemblyBrowser var exe = Path.Combine (path, name.Name + ".exe"); if (File.Exists (exe)) return exe; + + foreach (var asm in Runtime.SystemAssemblyService.DefaultAssemblyContext.GetAssemblies ()) { + if (asm.Name.ToLowerInvariant () == fullAssemblyName.ToLowerInvariant ()) + return asm.Location; + } + return null; } diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ColoredCSharpFormatter.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ColoredCSharpFormatter.cs index 5f5aff6c34..05d9a3fbfc 100755 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ColoredCSharpFormatter.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ColoredCSharpFormatter.cs @@ -132,7 +132,24 @@ namespace MonoDevelop.AssemblyBrowser WriteIndent (); sb.Append (text); } - + + void ITextOutput.WritePrimitiveValue (object value, string literalValue) + { + WriteIndent (); + if (value == null) { + sb.Append ("null"); + } else if (value is string) { + sb.Append ("\"" + value + "\""); + } else if (value is char) { + sb.Append ("'" + value + "'"); + } else if (value is bool) { + sb.Append ((bool)value ? "true" : "false"); + } else { + sb.Append (value.ToString()); + } + + } + void WriteIndent () { if (!write_indent) @@ -172,7 +189,7 @@ namespace MonoDevelop.AssemblyBrowser { foldSegmentStarts.Push (Tuple.Create (sb.Length, collapsedText, defaultCollapsed)); } - + public void MarkFoldEnd () { var curFold = foldSegmentStarts.Pop (); diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/TreeNodes/AssemblyNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/TreeNodes/AssemblyNodeBuilder.cs index cc3b805981..02d5fba0e4 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/TreeNodes/AssemblyNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/TreeNodes/AssemblyNodeBuilder.cs @@ -159,16 +159,22 @@ namespace MonoDevelop.AssemblyBrowser LoggingService.LogError ("Can't get cecil object for assembly:" + assembly); return new List<ReferenceSegment> (); } - return DomMethodNodeBuilder.Decompile (data, DomMethodNodeBuilder.GetModule (navigator), null, b => { - if (b != null) - b.AddAssembly (compilationUnit, true); - }); + return DomMethodNodeBuilder.Disassemble (data, rd => rd.WriteAssemblyHeader (compilationUnit)); } public List<ReferenceSegment> Decompile (TextEditorData data, ITreeNavigator navigator, bool publicOnly) { - return Disassemble (data, navigator); + var assembly = ((AssemblyLoader)navigator.DataItem).UnresolvedAssembly; + var compilationUnit = Widget.CecilLoader.GetCecilObject (assembly); + if (compilationUnit == null) { + LoggingService.LogError ("Can't get cecil object for assembly:" + assembly); + return new List<ReferenceSegment> (); + } + return DomMethodNodeBuilder.Decompile (data, DomMethodNodeBuilder.GetModule (navigator), null, b => { + if (b != null) + b.AddAssembly (compilationUnit, true); + }); } public string GetDocumentationMarkup (ITreeNavigator navigator) diff --git a/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.AspNet/AddinInfo.cs b/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.AspNet/AddinInfo.cs new file mode 100644 index 0000000000..2a14f37358 --- /dev/null +++ b/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.AspNet/AddinInfo.cs @@ -0,0 +1,17 @@ + +using System; +using Mono.Addins; +using Mono.Addins.Description; + +[assembly:Addin ("Debugger.Soft.AspNet", + Namespace = "MonoDevelop", + Version = MonoDevelop.BuildInfo.Version, + Category = "Debugging")] + +[assembly:AddinName ("Mono Soft Debugger Support for ASP.NET")] +[assembly:AddinDescription ("Mono Soft Debugger Support for ASP.NET")] + +[assembly:AddinDependency ("Core", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("Debugger", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("AspNet", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("Debugger.Soft", MonoDevelop.BuildInfo.Version)] diff --git a/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.AspNet/Manifest.addin.xml b/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.AspNet/Manifest.addin.xml index a677466210..4cb81df805 100644 --- a/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.AspNet/Manifest.addin.xml +++ b/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.AspNet/Manifest.addin.xml @@ -1,19 +1,5 @@ -<Addin id = "MonoDevelop.Debugger.Soft.AspNet" - name = "Mono Soft Debugger Support for ASP.NET" - author = "Michael Hutchinson" - url = "http://www.mono-project.com" - description = "Mono Soft Debugger Support for ASP.NET" - copyright = "MIT X11" - category = "Debugging" - version = "4.2.3"> +<ExtensionModel> - <Dependencies> - <Addin id="MonoDevelop.Core" version="4.2.3"/> - <Addin id="MonoDevelop.Debugger" version="4.2.3"/> - <Addin id="MonoDevelop.AspNet" version="4.2.3"/> - <Addin id="MonoDevelop.Debugger.Soft" version="4.2.3"/> - </Dependencies> - <Extension path="/MonoDevelop/Debugging/DebuggerEngines"> <DebuggerEngine id="Mono.Debugger.Soft.AspNet" @@ -21,4 +7,5 @@ features="Breakpoints, Pause, Stepping, DebugFile, ConditionalBreakpoints, Tracepoints, Catchpoints, Disassembly" type="MonoDevelop.Debugger.Soft.AspNet.AspNetSoftDebuggerEngine" /> </Extension> -</Addin> + +</ExtensionModel> diff --git a/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.AspNet/MonoDevelop.Debugger.Soft.AspNet.csproj b/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.AspNet/MonoDevelop.Debugger.Soft.AspNet.csproj index 583c144897..870e7c1d32 100644 --- a/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.AspNet/MonoDevelop.Debugger.Soft.AspNet.csproj +++ b/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.AspNet/MonoDevelop.Debugger.Soft.AspNet.csproj @@ -112,9 +112,15 @@ <Name>Mono.Debugger.Soft</Name> <Private>False</Private> </ProjectReference> + <ProjectReference Include="..\..\..\..\external\mono-addins\Mono.Addins\Mono.Addins.csproj"> + <Project>{91DD5A2D-9FE3-4C3C-9253-876141874DAD}</Project> + <Name>Mono.Addins</Name> + <Private>False</Private> + </ProjectReference> </ItemGroup> <ItemGroup> <Compile Include="AspNetSoftDebuggerEngine.cs" /> + <Compile Include="AddinInfo.cs" /> </ItemGroup> <ItemGroup> <None Include="Makefile.am" /> diff --git a/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft/AddinInfo.cs b/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft/AddinInfo.cs new file mode 100644 index 0000000000..c4f2535ce7 --- /dev/null +++ b/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft/AddinInfo.cs @@ -0,0 +1,15 @@ + +using System; +using Mono.Addins; +using Mono.Addins.Description; + +[assembly:Addin ("Debugger.Soft", + Namespace = "MonoDevelop", + Version = MonoDevelop.BuildInfo.Version, + Category = "Debugging")] + +[assembly:AddinName ("Mono Soft Debugger Support")] +[assembly:AddinDescription ("Mono Soft Debugger Support")] + +[assembly:AddinDependency ("Core", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("Debugger", MonoDevelop.BuildInfo.Version)] diff --git a/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft/Manifest.addin.xml b/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft/Manifest.addin.xml index cd59d01fba..319ed08a2b 100644 --- a/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft/Manifest.addin.xml +++ b/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft/Manifest.addin.xml @@ -1,17 +1,5 @@ -<Addin id = "MonoDevelop.Debugger.Soft" - name = "Mono Soft Debugger Support" - author = "Lluis Sanchez" - url = "http://www.mono-project.com/Soft_Debugger" - description = "Mono Soft Debugger Support" - copyright = "MIT X11" - category = "Debugging" - version = "4.2.3"> +<ExtensionModel> - <Dependencies> - <Addin id="MonoDevelop.Core" version="4.2.3"/> - <Addin id="MonoDevelop.Debugger" version="4.2.3"/> - </Dependencies> - <Runtime> <Import assembly="Mono.Debugging.Soft.dll" /> <Import assembly="Mono.Debugger.Soft.dll" /> @@ -32,4 +20,5 @@ features="Breakpoints, Pause, Stepping, DebugFile, ConditionalBreakpoints, Tracepoints, Catchpoints, Disassembly" type="MonoDevelop.Debugger.Soft.CustomSoftDebuggerEngine" /> </Extension> -</Addin> + +</ExtensionModel> diff --git a/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.csproj b/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.csproj index 7ab1ed775f..53f13d019f 100644 --- a/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.csproj +++ b/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.csproj @@ -46,6 +46,7 @@ <Compile Include="AssemblyInfo.cs" /> <Compile Include="SoftDebuggerEngine.cs" /> <Compile Include="CustomSoftDebuggerEngine.cs" /> + <Compile Include="AddinInfo.cs" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="Manifest.addin.xml"> @@ -92,6 +93,11 @@ <Project>{372E8E3E-29D5-4B4D-88A2-4711CD628C4E}</Project> <Name>Mono.Debugger.Soft</Name> </ProjectReference> + <ProjectReference Include="..\..\..\..\external\mono-addins\Mono.Addins\Mono.Addins.csproj"> + <Project>{91DD5A2D-9FE3-4C3C-9253-876141874DAD}</Project> + <Name>Mono.Addins</Name> + <Private>False</Private> + </ProjectReference> </ItemGroup> <ItemGroup> <None Include="Makefile.am" /> diff --git a/main/src/addins/MonoDevelop.Debugger.Win32/CorApi/IMetadataImport.cs b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi/IMetadataImport.cs index 2e41ce78c9..8673fa30e6 100644 --- a/main/src/addins/MonoDevelop.Debugger.Win32/CorApi/IMetadataImport.cs +++ b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi/IMetadataImport.cs @@ -42,10 +42,15 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi [ComAliasName("mdTypeDef*")] out int rTypeDefs,
uint cMax /*must be 1*/,
[ComAliasName("ULONG*")] out uint pcTypeDefs);
-#if !MDBG_FAKE_COM
+
//STDMETHOD(EnumInterfaceImpls)(HCORENUM *phEnum, mdTypeDef td, mdInterfaceImpl rImpls[], ULONG cMax, ULONG* pcImpls) PURE;
- void EnumInterfaceImpls_(IntPtr phEnum, int td);
-
+ void EnumInterfaceImpls(
+ ref IntPtr phEnum,
+ int td,
+ [ComAliasName("mdInterfaceImpl*")] out int rImpls,
+ uint cMax /*must be 1*/,
+ [ComAliasName("ULONG*")] out uint pcImpls);
+#if !MDBG_FAKE_COM
//STDMETHOD(EnumTypeRefs)(HCORENUM *phEnum, mdTypeRef rTypeRefs[], ULONG cMax, ULONG* pcTypeRefs) PURE;
void EnumTypeRefs_();
#endif
@@ -640,10 +645,16 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi [ComAliasName("mdTypeDef*")] out int rTypeDefs,
uint cMax /*must be 1*/,
[ComAliasName("ULONG*")] out uint pcTypeDefs);
-#if !MDBG_FAKE_COM
+
//STDMETHOD(EnumInterfaceImpls)(HCORENUM *phEnum, mdTypeDef td, mdInterfaceImpl rImpls[], ULONG cMax, ULONG* pcImpls) PURE;
- new void EnumInterfaceImpls_(IntPtr phEnum, int td);
+ new void EnumInterfaceImpls(
+ ref IntPtr phEnum,
+ int td,
+ [ComAliasName("mdInterfaceImpl*")] out int rImpls,
+ uint cMax /*must be 1*/,
+ [ComAliasName("ULONG*")] out uint pcImpls);
+#if !MDBG_FAKE_COM
//STDMETHOD(EnumTypeRefs)(HCORENUM *phEnum, mdTypeRef rTypeRefs[], ULONG cMax, ULONG* pcTypeRefs) PURE;
new void EnumTypeRefs_();
#endif
diff --git a/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/CorApi2.csproj b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/CorApi2.csproj index d8998cf04d..0246f09c30 100644 --- a/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/CorApi2.csproj +++ b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/CorApi2.csproj @@ -23,7 +23,6 @@ <OldToolsVersion>3.5</OldToolsVersion> <UpgradeBackupLocation> </UpgradeBackupLocation> - <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> @@ -119,6 +118,9 @@ <Compile Include="SymStore\SymSearchPolicyAttributes.cs" /> <Compile Include="SymStore\symvariable.cs" /> <Compile Include="SymStore\SymWriter.cs" /> + <Compile Include="Extensions\MetadataExtensions.cs" /> + <Compile Include="Extensions\ProcessExtensions.cs" /> + <Compile Include="Extensions\DebuggerExtensions.cs" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. diff --git a/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Extensions/DebuggerExtensions.cs b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Extensions/DebuggerExtensions.cs new file mode 100644 index 0000000000..c0a1192d65 --- /dev/null +++ b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Extensions/DebuggerExtensions.cs @@ -0,0 +1,175 @@ +//
+// DebuggerExtensions.cs
+//
+// Author:
+// Therzok <teromario@yahoo.com>
+//
+// Copyright (c) 2013 Xamarin Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using Microsoft.Samples.Debugging.CorDebug;
+using Microsoft.Samples.Debugging.CorDebug.NativeApi;
+using Microsoft.Win32.SafeHandles;
+
+namespace Microsoft.Samples.Debugging.Extensions
+{
+ [CLSCompliant (false)]
+ public static class DebuggerExtensions
+ {
+ // [Xamarin] Output redirection.
+ public const int CREATE_REDIRECT_STD = 0x40000000;
+ const string Kernel32LibraryName = "kernel32.dll";
+
+ [
+ DllImport (Kernel32LibraryName, CharSet = CharSet.Auto, SetLastError = true)
+ ]
+ public static extern bool CreatePipe (out SafeFileHandle hReadPipe, out SafeFileHandle hWritePipe, SECURITY_ATTRIBUTES lpPipeAttributes, int nSize);
+
+ [
+ DllImport (Kernel32LibraryName)
+ ]
+ public static extern bool DuplicateHandle (
+ IntPtr hSourceProcessHandle,
+ SafeFileHandle hSourceHandle,
+ IntPtr hTargetProcessHandle,
+ out SafeFileHandle lpTargetHandle,
+ uint dwDesiredAccess,
+ bool bInheritHandle,
+ uint dwOptions
+ );
+
+ const uint DUPLICATE_CLOSE_SOURCE = 0x00000001;
+ const uint DUPLICATE_SAME_ACCESS = 0x00000002;
+
+ [
+ DllImport (Kernel32LibraryName)
+ ]
+ public static extern SafeFileHandle GetStdHandle (uint nStdHandle);
+
+ const uint STD_INPUT_HANDLE = unchecked ((uint)-10);
+ const uint STD_OUTPUT_HANDLE = unchecked ((uint)-11);
+ const uint STD_ERROR_HANDLE = unchecked ((uint)-12);
+
+ [
+ DllImport (Kernel32LibraryName)
+ ]
+ public static extern bool ReadFile (
+ SafeFileHandle hFile,
+ byte[] lpBuffer,
+ int nNumberOfBytesToRead,
+ out int lpNumberOfBytesRead,
+ IntPtr lpOverlapped
+ );
+
+ [
+ DllImport (Kernel32LibraryName, CharSet = CharSet.Auto, SetLastError = true)
+ ]
+ public static extern IntPtr GetCurrentProcess ();
+
+ static void CreateHandles (STARTUPINFO si, out SafeFileHandle outReadPipe, out SafeFileHandle errorReadPipe)
+ {
+ si.dwFlags |= 0x00000100; /* STARTF_USESTDHANDLES*/
+ var sa = new SECURITY_ATTRIBUTES ();
+ sa.bInheritHandle = true;
+ IntPtr curProc = GetCurrentProcess ();
+
+ SafeFileHandle outWritePipe, outReadPipeTmp;
+ if (!CreatePipe (out outReadPipeTmp, out outWritePipe, sa, 0))
+ throw new Exception ("Pipe creation failed");
+
+ // Create the child error pipe.
+ SafeFileHandle errorWritePipe, errorReadPipeTmp;
+ if (!CreatePipe (out errorReadPipeTmp, out errorWritePipe, sa, 0))
+ throw new Exception ("Pipe creation failed");
+
+ // Create new output read and error read handles. Set
+ // the Properties to FALSE. Otherwise, the child inherits the
+ // properties and, as a result, non-closeable handles to the pipes
+ // are created.
+ if (!DuplicateHandle (curProc, outReadPipeTmp, curProc, out outReadPipe, 0, false, DUPLICATE_SAME_ACCESS))
+ throw new Exception ("Pipe creation failed");
+ if (!DuplicateHandle (curProc, errorReadPipeTmp, curProc, out errorReadPipe, 0, false, DUPLICATE_SAME_ACCESS))
+ throw new Exception ("Pipe creation failed");
+
+ NativeMethods.CloseHandle (curProc);
+
+ // Close inheritable copies of the handles you do not want to be
+ // inherited.
+ outReadPipeTmp.Close ();
+ errorReadPipeTmp.Close ();
+
+ si.hStdInput = GetStdHandle (STD_INPUT_HANDLE);
+ si.hStdOutput = outWritePipe;
+ si.hStdError = errorWritePipe;
+ }
+
+ internal static void SetupOutputRedirection (STARTUPINFO si, ref int flags, SafeFileHandle outReadPipe, SafeFileHandle errorReadPipe)
+ {
+ if ((flags & CREATE_REDIRECT_STD) != 0) {
+ CreateHandles (si, out outReadPipe, out errorReadPipe);
+ flags &= ~CREATE_REDIRECT_STD;
+ }
+ else {
+ si.hStdInput = new SafeFileHandle (IntPtr.Zero, false);
+ si.hStdOutput = new SafeFileHandle (IntPtr.Zero, false);
+ si.hStdError = new SafeFileHandle (IntPtr.Zero, false);
+ }
+ }
+
+ internal static void TearDownOutputRedirection (SafeFileHandle outReadPipe, SafeFileHandle errorReadPipe, STARTUPINFO si, CorProcess ret)
+ {
+ if (outReadPipe != null) {
+ // Close pipe handles (do not continue to modify the parent).
+ // You need to make sure that no handles to the write end of the
+ // output pipe are maintained in this process or else the pipe will
+ // not close when the child process exits and the ReadFile will hang.
+
+ si.hStdInput.Close ();
+ si.hStdOutput.Close ();
+ si.hStdError.Close ();
+
+ ret.TrackStdOutput (outReadPipe, errorReadPipe);
+ }
+ }
+
+ internal static IntPtr SetupEnvironment (IDictionary<string, string> environment)
+ {
+ IntPtr env = IntPtr.Zero;
+ if (environment != null) {
+ string senv = null;
+ foreach (KeyValuePair<string, string> var in environment) {
+ senv += var.Key + "=" + var.Value + "\0";
+ }
+ senv += "\0";
+ env = Marshal.StringToHGlobalAnsi (senv);
+ }
+ return env;
+ }
+
+ internal static void TearDownEnvironment (IntPtr env)
+ {
+ if (env != IntPtr.Zero)
+ Marshal.FreeHGlobal (env);
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Extensions/MetadataExtensions.cs b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Extensions/MetadataExtensions.cs new file mode 100644 index 0000000000..e8b6375678 --- /dev/null +++ b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Extensions/MetadataExtensions.cs @@ -0,0 +1,345 @@ +//
+// MetadataExtensions.cs
+//
+// Author:
+// Lluis Sanchez <lluis@xamarin.com>
+// Therzok <teromario@yahoo.com>
+//
+// Copyright (c) 2013 Xamarin Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using Microsoft.Samples.Debugging.CorDebug.NativeApi;
+using Microsoft.Samples.Debugging.CorMetadata;
+using Microsoft.Samples.Debugging.CorMetadata.NativeApi;
+
+namespace Microsoft.Samples.Debugging.Extensions
+{
+ // [Xamarin] Expression evaluator.
+ public static class MetadataExtensions
+ {
+ internal static bool TypeFlagsMatch (bool isPublic, bool isStatic, BindingFlags flags)
+ {
+ if (isPublic && (flags & BindingFlags.Public) == 0)
+ return false;
+ if (!isPublic && (flags & BindingFlags.NonPublic) == 0)
+ return false;
+ if (isStatic && (flags & BindingFlags.Static) == 0)
+ return false;
+ if (!isStatic && (flags & BindingFlags.Instance) == 0)
+ return false;
+ return true;
+ }
+
+ internal static Type MakeDelegate (Type retType, List<Type> argTypes)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public static Type MakeArray (Type t, List<int> sizes, List<int> loBounds)
+ {
+ var mt = t as MetadataType;
+ if (mt != null) {
+ if (sizes == null) {
+ sizes = new List<int> ();
+ sizes.Add (1);
+ }
+ mt.m_arraySizes = sizes;
+ mt.m_arrayLoBounds = loBounds;
+ return mt;
+ }
+ if (sizes == null || sizes.Count == 1)
+ return t.MakeArrayType ();
+ return t.MakeArrayType (sizes.Capacity);
+ }
+
+ public static Type MakeByRef (Type t)
+ {
+ var mt = t as MetadataType;
+ if (mt != null) {
+ mt.m_isByRef = true;
+ return mt;
+ }
+ return t.MakeByRefType ();
+ }
+
+ public static Type MakePointer (Type t)
+ {
+ var mt = t as MetadataType;
+ if (mt != null) {
+ mt.m_isPtr = true;
+ return mt;
+ }
+ return t.MakeByRefType ();
+ }
+
+ public static Type MakeGeneric (Type t, List<Type> typeArgs)
+ {
+ var mt = (MetadataType)t;
+ mt.m_typeArgs = typeArgs;
+ return mt;
+ }
+ }
+
+ // [Xamarin] Expression evaluator.
+ [CLSCompliant (false)]
+ public static class MetadataHelperFunctionsExtensions
+ {
+ public static Dictionary<CorElementType, Type> CoreTypes = new Dictionary<CorElementType, Type> ();
+ static MetadataHelperFunctionsExtensions ()
+ {
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_BOOLEAN, typeof (bool));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_CHAR, typeof (char));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_I1, typeof (sbyte));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_U1, typeof (byte));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_I2, typeof (short));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_U2, typeof (ushort));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_I4, typeof (int));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_U4, typeof (uint));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_I8, typeof (long));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_U8, typeof (ulong));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_R4, typeof (float));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_R8, typeof (double));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_STRING, typeof (string));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_I, typeof (IntPtr));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_U, typeof (UIntPtr));
+ }
+
+ internal static void ReadMethodSignature (IMetadataImport importer, ref IntPtr pData, out CorCallingConvention cconv, out Type retType, out List<Type> argTypes)
+ {
+ cconv = MetadataHelperFunctions.CorSigUncompressCallingConv (ref pData);
+ uint numArgs = 0;
+ // FIXME: Use number of <T>s.
+ uint types = 0;
+ if ((cconv & CorCallingConvention.Generic) == CorCallingConvention.Generic)
+ types = MetadataHelperFunctions.CorSigUncompressData (ref pData);
+
+ if (cconv != CorCallingConvention.Field)
+ numArgs = MetadataHelperFunctions.CorSigUncompressData (ref pData);
+
+ retType = ReadType (importer, ref pData);
+ argTypes = new List<Type> ();
+ for (int n = 0; n < numArgs; n++)
+ argTypes.Add (ReadType (importer, ref pData));
+ }
+
+ class GenericType
+ {
+ // Used as marker for generic method args
+ }
+
+ static Type ReadType (IMetadataImport importer, ref IntPtr pData)
+ {
+ CorElementType et;
+ unsafe {
+ var pBytes = (byte*)pData;
+ et = (CorElementType) (*pBytes);
+ pData = (IntPtr) (pBytes + 1);
+ }
+
+ switch (et)
+ {
+ case CorElementType.ELEMENT_TYPE_VOID: return typeof (void);
+ case CorElementType.ELEMENT_TYPE_BOOLEAN: return typeof (bool);
+ case CorElementType.ELEMENT_TYPE_CHAR: return typeof (char);
+ case CorElementType.ELEMENT_TYPE_I1: return typeof (sbyte);
+ case CorElementType.ELEMENT_TYPE_U1: return typeof (byte);
+ case CorElementType.ELEMENT_TYPE_I2: return typeof (short);
+ case CorElementType.ELEMENT_TYPE_U2: return typeof (ushort);
+ case CorElementType.ELEMENT_TYPE_I4: return typeof (int);
+ case CorElementType.ELEMENT_TYPE_U4: return typeof (uint);
+ case CorElementType.ELEMENT_TYPE_I8: return typeof (long);
+ case CorElementType.ELEMENT_TYPE_U8: return typeof (ulong);
+ case CorElementType.ELEMENT_TYPE_R4: return typeof (float);
+ case CorElementType.ELEMENT_TYPE_R8: return typeof (double);
+ case CorElementType.ELEMENT_TYPE_STRING: return typeof (string);
+ case CorElementType.ELEMENT_TYPE_I: return typeof (IntPtr);
+ case CorElementType.ELEMENT_TYPE_U: return typeof (UIntPtr);
+ case CorElementType.ELEMENT_TYPE_OBJECT: return typeof (object);
+
+ case CorElementType.ELEMENT_TYPE_VAR:
+ case CorElementType.ELEMENT_TYPE_MVAR:
+ // Generic args in methods not supported. Return a dummy type.
+ MetadataHelperFunctions.CorSigUncompressData (ref pData);
+ return typeof(GenericType);
+
+ case CorElementType.ELEMENT_TYPE_GENERICINST: {
+ Type t = ReadType (importer, ref pData);
+ var typeArgs = new List<Type> ();
+ uint num = MetadataHelperFunctions.CorSigUncompressData (ref pData);
+ for (int n=0; n<num; n++) {
+ typeArgs.Add (ReadType (importer, ref pData));
+ }
+ return MetadataExtensions.MakeGeneric (t, typeArgs);
+ }
+
+ case CorElementType.ELEMENT_TYPE_PTR: {
+ Type t = ReadType (importer, ref pData);
+ return MetadataExtensions.MakePointer (t);
+ }
+
+ case CorElementType.ELEMENT_TYPE_BYREF: {
+ Type t = ReadType (importer, ref pData);
+ return MetadataExtensions.MakeByRef(t);
+ }
+
+ case CorElementType.ELEMENT_TYPE_END:
+ case CorElementType.ELEMENT_TYPE_VALUETYPE:
+ case CorElementType.ELEMENT_TYPE_CLASS: {
+ uint token = MetadataHelperFunctions.CorSigUncompressToken (ref pData);
+ return new MetadataType (importer, (int) token);
+ }
+
+ case CorElementType.ELEMENT_TYPE_ARRAY: {
+ Type t = ReadType (importer, ref pData);
+ int rank = (int)MetadataHelperFunctions.CorSigUncompressData (ref pData);
+ if (rank == 0)
+ return MetadataExtensions.MakeArray (t, null, null);
+
+ uint numSizes = MetadataHelperFunctions.CorSigUncompressData (ref pData);
+ var sizes = new List<int> (rank);
+ for (int n = 0; n < numSizes && n < rank; n++)
+ sizes.Add ((int)MetadataHelperFunctions.CorSigUncompressData (ref pData));
+
+ uint numLoBounds = MetadataHelperFunctions.CorSigUncompressData (ref pData);
+ var loBounds = new List<int> (rank);
+ for (int n = 0; n < numLoBounds && n < rank; n++)
+ loBounds.Add ((int)MetadataHelperFunctions.CorSigUncompressData (ref pData));
+
+ return MetadataExtensions.MakeArray (t, sizes, loBounds);
+ }
+
+ case CorElementType.ELEMENT_TYPE_SZARRAY: {
+ Type t = ReadType (importer, ref pData);
+ return MetadataExtensions.MakeArray (t, null, null);
+ }
+
+ case CorElementType.ELEMENT_TYPE_FNPTR: {
+ CorCallingConvention cconv;
+ Type retType;
+ List<Type> argTypes;
+ ReadMethodSignature (importer, ref pData, out cconv, out retType, out argTypes);
+ return MetadataExtensions.MakeDelegate (retType, argTypes);
+ }
+
+ case CorElementType.ELEMENT_TYPE_CMOD_REQD:
+ case CorElementType.ELEMENT_TYPE_CMOD_OPT:
+ return ReadType (importer, ref pData);
+ }
+ throw new NotSupportedException ("Unknown sig element type: " + et);
+ }
+
+ static readonly object[] emptyAttributes = new object[0];
+
+ static internal object[] GetDebugAttributes (IMetadataImport importer, int token)
+ {
+ var attributes = new ArrayList ();
+ object attr = GetCustomAttribute (importer, token, typeof (System.Diagnostics.DebuggerTypeProxyAttribute));
+ if (attr != null)
+ attributes.Add (attr);
+ attr = GetCustomAttribute (importer, token, typeof (System.Diagnostics.DebuggerDisplayAttribute));
+ if (attr != null)
+ attributes.Add (attr);
+ attr = GetCustomAttribute (importer, token, typeof (System.Diagnostics.DebuggerBrowsableAttribute));
+ if (attr != null)
+ attributes.Add (attr);
+ attr = GetCustomAttribute (importer, token, typeof (System.Runtime.CompilerServices.CompilerGeneratedAttribute));
+ if (attr != null)
+ attributes.Add (attr);
+ attr = GetCustomAttribute (importer, token, typeof (System.Diagnostics.DebuggerHiddenAttribute));
+ if (attr != null)
+ attributes.Add (attr);
+
+ return attributes.Count == 0 ? emptyAttributes : attributes.ToArray ();
+ }
+
+ // [Xamarin] Expression evaluator.
+ static internal object GetCustomAttribute (IMetadataImport importer, int token, Type type)
+ {
+ uint sigSize;
+ IntPtr ppvSig;
+ int hr = importer.GetCustomAttributeByName (token, type.FullName, out ppvSig, out sigSize);
+ if (hr != 0)
+ return null;
+
+ var data = new byte[sigSize];
+ Marshal.Copy (ppvSig, data, 0, (int)sigSize);
+ var br = new BinaryReader (new MemoryStream (data));
+
+ // Prolog
+ if (br.ReadUInt16 () != 1)
+ throw new InvalidOperationException ("Incorrect attribute prolog");
+
+ ConstructorInfo ctor = type.GetConstructors ()[0];
+ ParameterInfo[] pars = ctor.GetParameters ();
+
+ var args = new object[pars.Length];
+
+ // Fixed args
+ for (int n=0; n<pars.Length; n++)
+ args [n] = ReadValue (br, pars[n].ParameterType);
+
+ object ob = Activator.CreateInstance (type, args);
+
+ // Named args
+ uint nargs = br.ReadUInt16 ();
+ for (; nargs > 0; nargs--) {
+ byte fieldOrProp = br.ReadByte ();
+ byte atype = br.ReadByte ();
+
+ // Boxed primitive
+ if (atype == 0x51)
+ atype = br.ReadByte ();
+ var et = (CorElementType) atype;
+ string pname = br.ReadString ();
+ object val = ReadValue (br, CoreTypes [et]);
+
+ if (fieldOrProp == 0x53) {
+ FieldInfo fi = type.GetField (pname);
+ fi.SetValue (ob, val);
+ }
+ else {
+ PropertyInfo pi = type.GetProperty (pname);
+ pi.SetValue (ob, val, null);
+ }
+ }
+ return ob;
+ }
+
+ // [Xamarin] Expression evaluator.
+ static object ReadValue (BinaryReader br, Type type)
+ {
+ if (type.IsEnum) {
+ object ob = ReadValue (br, Enum.GetUnderlyingType (type));
+ return Enum.ToObject (type, Convert.ToInt64 (ob));
+ }
+ if (type == typeof (string) || type == typeof(Type))
+ return br.ReadString ();
+ if (type == typeof (int))
+ return br.ReadInt32 ();
+ throw new InvalidOperationException ("Can't parse value of type: " + type);
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Extensions/ProcessExtensions.cs b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Extensions/ProcessExtensions.cs new file mode 100644 index 0000000000..de197db461 --- /dev/null +++ b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Extensions/ProcessExtensions.cs @@ -0,0 +1,117 @@ +//
+// ProcessExtensions.cs
+//
+// Author:
+// Lluis Sanchez <lluis@xamarin.com>
+// Therzok <teromario@yahoo.com>
+//
+// Copyright (c) 2013 Xamarin Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using Microsoft.Samples.Debugging.CorDebug;
+using Microsoft.Win32.SafeHandles;
+
+namespace Microsoft.Samples.Debugging.Extensions
+{
+ // [Xamarin] Output redirection.
+ public class CorTargetOutputEventArgs: EventArgs
+ {
+ public CorTargetOutputEventArgs (string text, bool isStdError)
+ {
+ Text = text;
+ IsStdError = isStdError;
+ }
+
+ public string Text { get; set; }
+
+ public bool IsStdError { get; set; }
+ }
+
+ public delegate void CorTargetOutputEventHandler (Object sender, CorTargetOutputEventArgs e);
+
+ public static class CorProcessExtensions
+ {
+ internal static void TrackStdOutput (this CorProcess proc, SafeFileHandle outputPipe, SafeFileHandle errorPipe)
+ {
+ var outputReader = new Thread (delegate () {
+ proc.ReadOutput (outputPipe, false);
+ });
+ outputReader.Name = "Debugger output reader";
+ outputReader.IsBackground = true;
+ outputReader.Start ();
+
+ var errorReader = new Thread (delegate () {
+ proc.ReadOutput (errorPipe, true);
+ });
+ errorReader.Name = "Debugger error reader";
+ errorReader.IsBackground = true;
+ errorReader.Start ();
+ }
+
+ // [Xamarin] Output redirection.
+ static void ReadOutput (this CorProcess proc, SafeFileHandle pipe, bool isStdError)
+ {
+ var buffer = new byte[256];
+ int nBytesRead;
+
+ try {
+ while (true) {
+ if (!DebuggerExtensions.ReadFile (pipe, buffer, buffer.Length, out nBytesRead, IntPtr.Zero) || nBytesRead == 0)
+ break; // pipe done - normal exit path.
+
+ string s = System.Text.Encoding.Default.GetString (buffer, 0, nBytesRead);
+ if (OnStdOutput != null)
+ OnStdOutput (proc, new CorTargetOutputEventArgs (s, isStdError));
+ }
+ } catch {
+ }
+ }
+
+ public static void RegisterStdOutput (this CorProcess proc, CorTargetOutputEventHandler handler)
+ {
+ proc.OnProcessExit += delegate {
+ RemoveEventsFor (proc);
+ };
+
+ List<CorTargetOutputEventHandler> list;
+ if (!events.TryGetValue (proc, out list))
+ list = new List<CorTargetOutputEventHandler> ();
+ list.Add (handler);
+
+ events [proc] = list;
+ OnStdOutput += handler;
+ }
+
+ static void RemoveEventsFor (CorProcess proc)
+ {
+ foreach (CorTargetOutputEventHandler handler in events [proc])
+ OnStdOutput -= handler;
+
+ events.Remove (proc);
+ }
+
+ // [Xamarin] Output redirection.
+ static event CorTargetOutputEventHandler OnStdOutput;
+ static readonly Dictionary<CorProcess, List<CorTargetOutputEventHandler>> events = new Dictionary<CorProcess, List<CorTargetOutputEventHandler>> ();
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Metadata/CorMetadata.cs b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Metadata/CorMetadata.cs index cc0fc283bd..3060c0c593 100644 --- a/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Metadata/CorMetadata.cs +++ b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Metadata/CorMetadata.cs @@ -4,46 +4,23 @@ // Copyright (C) Microsoft Corporation. All rights reserved.
//---------------------------------------------------------------------
using System;
-using System.IO;
using System.Reflection;
using System.Text;
using System.Runtime.InteropServices;
using System.Globalization;
using System.Collections;
-using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.Samples.Debugging.CorDebug;
using Microsoft.Samples.Debugging.CorMetadata.NativeApi;
using Microsoft.Samples.Debugging.CorDebug.NativeApi;
+using Microsoft.Samples.Debugging.Extensions;
+using System.Collections.Generic;
namespace Microsoft.Samples.Debugging.CorMetadata
{
public sealed class CorMetadataImport
{
- // [Xamarin] Expression evaluator.
- public static Dictionary<CorElementType, Type> CoreTypes = new Dictionary<CorElementType, Type> ();
-
- // [Xamarin] Expression evaluator.
- static CorMetadataImport ()
- {
- CoreTypes.Add (CorElementType.ELEMENT_TYPE_BOOLEAN, typeof (bool));
- CoreTypes.Add (CorElementType.ELEMENT_TYPE_CHAR, typeof (char));
- CoreTypes.Add (CorElementType.ELEMENT_TYPE_I1, typeof (sbyte));
- CoreTypes.Add (CorElementType.ELEMENT_TYPE_U1, typeof (byte));
- CoreTypes.Add (CorElementType.ELEMENT_TYPE_I2, typeof (short));
- CoreTypes.Add (CorElementType.ELEMENT_TYPE_U2, typeof (ushort));
- CoreTypes.Add (CorElementType.ELEMENT_TYPE_I4, typeof (int));
- CoreTypes.Add (CorElementType.ELEMENT_TYPE_U4, typeof (uint));
- CoreTypes.Add (CorElementType.ELEMENT_TYPE_I8, typeof (long));
- CoreTypes.Add (CorElementType.ELEMENT_TYPE_U8, typeof (ulong));
- CoreTypes.Add (CorElementType.ELEMENT_TYPE_R4, typeof (float));
- CoreTypes.Add (CorElementType.ELEMENT_TYPE_R8, typeof (double));
- CoreTypes.Add (CorElementType.ELEMENT_TYPE_STRING, typeof (string));
- CoreTypes.Add (CorElementType.ELEMENT_TYPE_I, typeof (IntPtr));
- CoreTypes.Add (CorElementType.ELEMENT_TYPE_U, typeof (UIntPtr));
- }
-
public CorMetadataImport(CorModule managedModule)
{
m_importer = managedModule.GetMetaDataInterface <IMetadataImport>();
@@ -326,8 +303,8 @@ namespace Microsoft.Samples.Debugging.CorMetadata // [Xamarin] Expression evaluator.
CorCallingConvention callingConv;
- MetadataHelperFunctions.ReadMethodSignature (importer, ref ppvSigBlob, out callingConv, out m_retType, out m_argTypes);
- m_name = szMethodName.ToString ();
+ MetadataHelperFunctionsExtensions.ReadMethodSignature (importer, ref ppvSigBlob, out callingConv, out m_retType, out m_argTypes);
+ m_name = szMethodName.ToString();
m_methodAttributes = (MethodAttributes)pdwAttr;
}
@@ -396,20 +373,30 @@ namespace Microsoft.Samples.Debugging.CorMetadata throw new NotImplementedException();
}
- public override bool IsDefined (Type attributeType, bool inherit)
- {
- throw new NotImplementedException();
- }
+ // [Xamarin] Expression evaluator.
+ public override bool IsDefined (Type attributeType, bool inherit)
+ {
+ return GetCustomAttributes (attributeType, inherit).Length > 0;
+ }
- public override object[] GetCustomAttributes(Type attributeType, bool inherit)
- {
- throw new NotImplementedException();
- }
+ // [Xamarin] Expression evaluator.
+ public override object[] GetCustomAttributes (Type attributeType, bool inherit)
+ {
+ ArrayList list = new ArrayList ();
+ foreach (object ob in GetCustomAttributes (inherit)) {
+ if (attributeType.IsInstanceOfType (ob))
+ list.Add (ob);
+ }
+ return list.ToArray ();
+ }
- public override object[] GetCustomAttributes(bool inherit)
- {
- throw new NotImplementedException();
- }
+ // [Xamarin] Expression evaluator.
+ public override object[] GetCustomAttributes(bool inherit)
+ {
+ if (m_customAttributes == null)
+ m_customAttributes = MetadataHelperFunctionsExtensions.GetDebugAttributes (m_importer, m_methodToken);
+ return m_customAttributes;
+ }
public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
{
@@ -437,10 +424,11 @@ namespace Microsoft.Samples.Debugging.CorMetadata m_methodToken, out paramToken,1,out count);
if(count!=1)
break;
- MetadataParameterInfo mp = new MetadataParameterInfo (m_importer, paramToken,
- this, DeclaringType, m_argTypes [nArg++]);
- if (mp.Name != string.Empty)
- al.Add(mp);
+ var mp = new MetadataParameterInfo (m_importer, paramToken, this, m_argTypes [nArg++]);
+ if (mp.Name != String.Empty)
+ al.Add (mp);
+ //al.Add(new MetadataParameterInfo(m_importer,paramToken,
+ // this,DeclaringType));
}
}
finally
@@ -471,7 +459,8 @@ namespace Microsoft.Samples.Debugging.CorMetadata // [Xamarin] Expression evaluator.
private List<Type> m_argTypes;
private Type m_retType;
- }
+ private object[] m_customAttributes;
+ }
public enum MetadataTokenType
{
@@ -594,133 +583,6 @@ namespace Microsoft.Samples.Debugging.CorMetadata {
private static uint TokenFromRid(uint rid, uint tktype) {return (rid) | (tktype);}
- // [Xamarin] Expression evaluator.
- public static void ReadMethodSignature (IMetadataImport importer, ref IntPtr pData, out CorCallingConvention cconv, out Type retType, out List<Type> argTypes)
- {
- cconv = MetadataHelperFunctions.CorSigUncompressCallingConv (ref pData);
- uint numArgs = 0;
- // FIXME: Use number of <T>s.
- uint types = 0;
- if ((cconv & CorCallingConvention.Generic) == CorCallingConvention.Generic)
- types = MetadataHelperFunctions.CorSigUncompressData (ref pData);
-
- if (cconv != CorCallingConvention.Field)
- numArgs = MetadataHelperFunctions.CorSigUncompressData (ref pData);
-
- retType = MetadataHelperFunctions.ReadType (importer, ref pData);
- argTypes = new List<Type> ();
- for (int n = 0; n < numArgs; n++)
- argTypes.Add (MetadataHelperFunctions.ReadType (importer, ref pData));
- }
-
- // [Xamarin] Expression evaluator.
- class GenericType
- {
- // Used as marker for generic method args
- }
-
- // [Xamarin] Expression evaluator.
- static Type ReadType (IMetadataImport importer, ref IntPtr pData)
- {
- CorElementType et;
- unsafe {
- byte* pBytes = (byte*)pData;
- et = (CorElementType) (*pBytes);
- pData = (IntPtr) (pBytes + 1);
- }
-
- switch (et)
- {
- case CorElementType.ELEMENT_TYPE_VOID: return typeof (void);
- case CorElementType.ELEMENT_TYPE_BOOLEAN: return typeof (bool);
- case CorElementType.ELEMENT_TYPE_CHAR: return typeof (char);
- case CorElementType.ELEMENT_TYPE_I1: return typeof (sbyte);
- case CorElementType.ELEMENT_TYPE_U1: return typeof (byte);
- case CorElementType.ELEMENT_TYPE_I2: return typeof (short);
- case CorElementType.ELEMENT_TYPE_U2: return typeof (ushort);
- case CorElementType.ELEMENT_TYPE_I4: return typeof (int);
- case CorElementType.ELEMENT_TYPE_U4: return typeof (uint);
- case CorElementType.ELEMENT_TYPE_I8: return typeof (long);
- case CorElementType.ELEMENT_TYPE_U8: return typeof (ulong);
- case CorElementType.ELEMENT_TYPE_R4: return typeof (float);
- case CorElementType.ELEMENT_TYPE_R8: return typeof (double);
- case CorElementType.ELEMENT_TYPE_STRING: return typeof (string);
- case CorElementType.ELEMENT_TYPE_I: return typeof (IntPtr);
- case CorElementType.ELEMENT_TYPE_U: return typeof (UIntPtr);
- case CorElementType.ELEMENT_TYPE_OBJECT: return typeof (object);
-
- case CorElementType.ELEMENT_TYPE_VAR:
- case CorElementType.ELEMENT_TYPE_MVAR:
- // Generic args in methods not supported. Return a dummy type.
- CorSigUncompressData (ref pData);
- return typeof(GenericType);
-
- case CorElementType.ELEMENT_TYPE_GENERICINST: {
- Type t = ReadType (importer, ref pData);
- List<Type> typeArgs = new List<Type> ();
- uint num = CorSigUncompressData (ref pData);
- for (int n=0; n<num; n++) {
- typeArgs.Add (ReadType (importer, ref pData));
- }
- return MetadataType.MakeGeneric (t, typeArgs);
- }
-
- case CorElementType.ELEMENT_TYPE_PTR: {
- Type t = ReadType (importer, ref pData);
- return MetadataType.MakePointer (t);
- }
-
- case CorElementType.ELEMENT_TYPE_BYREF: {
- Type t = ReadType (importer, ref pData);
- return MetadataType.MakeByRef(t);
- }
-
- case CorElementType.ELEMENT_TYPE_END:
- case CorElementType.ELEMENT_TYPE_VALUETYPE:
- case CorElementType.ELEMENT_TYPE_CLASS: {
- uint token = CorSigUncompressToken (ref pData);
- return new MetadataType (importer, (int) token);
- }
-
- case CorElementType.ELEMENT_TYPE_ARRAY: {
- Type t = ReadType (importer, ref pData);
- int rank = (int)CorSigUncompressData (ref pData);
- if (rank == 0)
- return MetadataType.MakeArray (t, null, null);
-
- uint numSizes = CorSigUncompressData (ref pData);
- var sizes = new List<int> (rank);
- for (int n = 0; n < numSizes && n < rank; n++)
- sizes.Add ((int)CorSigUncompressData (ref pData));
-
- uint numLoBounds = CorSigUncompressData (ref pData);
- var loBounds = new List<int> (rank);
- for (int n = 0; n < numLoBounds && n < rank; n++)
- loBounds.Add ((int)CorSigUncompressData (ref pData));
-
- return MetadataType.MakeArray (t, sizes, loBounds);
- }
-
- case CorElementType.ELEMENT_TYPE_SZARRAY: {
- Type t = ReadType (importer, ref pData);
- return MetadataType.MakeArray (t, null, null);
- }
-
- case CorElementType.ELEMENT_TYPE_FNPTR: {
- CorCallingConvention cconv;
- Type retType;
- List<Type> argTypes;
- ReadMethodSignature (importer, ref pData, out cconv, out retType, out argTypes);
- return MetadataType.MakeDelegate (retType, argTypes);
- }
-
- case CorElementType.ELEMENT_TYPE_CMOD_REQD:
- case CorElementType.ELEMENT_TYPE_CMOD_OPT:
- return ReadType (importer, ref pData);
- }
- throw new NotSupportedException ("Unknown sig element type: " + et);
- }
-
// The below have been translated manually from the inline C++ helpers in cor.h
internal static uint CorSigUncompressBigData(
@@ -980,97 +842,6 @@ namespace Microsoft.Samples.Debugging.CorMetadata }
return genargs;
}
+ }
- // [Xamarin] Expression evaluator.
- static object[] emptyAttributes = new object[0];
-
- static internal object[] GetDebugAttributes (IMetadataImport importer, int token)
- {
- ArrayList attributes = new ArrayList ();
- object attr = MetadataHelperFunctions.GetCustomAttribute (importer, token, typeof (System.Diagnostics.DebuggerTypeProxyAttribute));
- if (attr != null)
- attributes.Add (attr);
- attr = MetadataHelperFunctions.GetCustomAttribute (importer, token, typeof (System.Diagnostics.DebuggerDisplayAttribute));
- if (attr != null)
- attributes.Add (attr);
- attr = MetadataHelperFunctions.GetCustomAttribute (importer, token, typeof (System.Diagnostics.DebuggerBrowsableAttribute));
- if (attr != null)
- attributes.Add (attr);
- attr = MetadataHelperFunctions.GetCustomAttribute (importer, token, typeof (System.Runtime.CompilerServices.CompilerGeneratedAttribute));
- if (attr != null)
- attributes.Add (attr);
-
- if (attributes.Count == 0)
- return emptyAttributes;
- else
- return attributes.ToArray ();
- }
-
- // [Xamarin] Expression evaluator.
- static internal object GetCustomAttribute (IMetadataImport importer, int token, Type type)
- {
- uint sigSize = 0;
- IntPtr ppvSig = IntPtr.Zero;
- int hr = importer.GetCustomAttributeByName (token, type.FullName, out ppvSig, out sigSize);
- if (hr != 0)
- return null;
-
- byte[] data = new byte[sigSize];
- Marshal.Copy (ppvSig, data, 0, (int)sigSize);
- BinaryReader br = new BinaryReader (new MemoryStream (data));
-
- // Prolog
- if (br.ReadUInt16 () != 1)
- throw new InvalidOperationException ("Incorrect attribute prolog");
-
- ConstructorInfo ctor = type.GetConstructors ()[0];
- ParameterInfo[] pars = ctor.GetParameters ();
-
- object[] args = new object[pars.Length];
-
- // Fixed args
- for (int n=0; n<pars.Length; n++)
- args [n] = ReadValue (br, pars[n].ParameterType);
-
- object ob = Activator.CreateInstance (type, args);
-
- // Named args
- uint nargs = br.ReadUInt16 ();
- for (; nargs > 0; nargs--) {
- byte fieldOrProp = br.ReadByte ();
- byte atype = br.ReadByte ();
-
- // Boxed primitive
- if (atype == 0x51)
- atype = br.ReadByte ();
- CorElementType et = (CorElementType) atype;
- string pname = br.ReadString ();
- object val = ReadValue (br, CorMetadataImport.CoreTypes[et]);
-
- if (fieldOrProp == 0x53) {
- FieldInfo fi = type.GetField (pname);
- fi.SetValue (ob, val);
- }
- else {
- PropertyInfo pi = type.GetProperty (pname);
- pi.SetValue (ob, val, null);
- }
- }
- return ob;
- }
-
- // [Xamarin] Expression evaluator.
- static object ReadValue (BinaryReader br, Type type)
- {
- if (type.IsEnum) {
- object ob = ReadValue (br, Enum.GetUnderlyingType (type));
- return Enum.ToObject (type, Convert.ToInt64 (ob));
- }
- if (type == typeof (string) || type == typeof(Type))
- return br.ReadString ();
- if (type == typeof (int))
- return br.ReadInt32 ();
- throw new InvalidOperationException ("Can't parse value of type: " + type);
- }
- }
} // namspace Microsoft.Debugger.MetadataWrapper
diff --git a/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataFieldInfo.cs b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataFieldInfo.cs index 360d83acd4..64c7f01b0b 100644 --- a/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataFieldInfo.cs +++ b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataFieldInfo.cs @@ -14,6 +14,7 @@ using System.Diagnostics; using Microsoft.Samples.Debugging.CorDebug;
using Microsoft.Samples.Debugging.CorMetadata.NativeApi;
using Microsoft.Samples.Debugging.CorDebug.NativeApi;
+using Microsoft.Samples.Debugging.Extensions;
namespace Microsoft.Samples.Debugging.CorMetadata
{
@@ -66,8 +67,8 @@ namespace Microsoft.Samples.Debugging.CorMetadata m_value = ParseDefaultValue(declaringType,ppvSigBlob,ppvRawValue);
}
// [Xamarin] Expression evaluator.
- MetadataHelperFunctions.GetCustomAttribute (importer, m_fieldToken, typeof (System.Diagnostics.DebuggerBrowsableAttribute));
- }
+ MetadataHelperFunctionsExtensions.GetCustomAttribute (m_importer, m_fieldToken, typeof (DebuggerBrowsableAttribute));
+ }
private static object ParseDefaultValue(MetadataType declaringType, IntPtr ppvSigBlob, IntPtr ppvRawValue)
{
@@ -76,7 +77,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata Debug.Assert(callingConv == CorCallingConvention.Field);
CorElementType elementType = MetadataHelperFunctions.CorSigUncompressElementType(ref ppvSigTemp);
- if (elementType == CorElementType.ELEMENT_TYPE_END || elementType == CorElementType.ELEMENT_TYPE_VALUETYPE)
+ if (elementType == CorElementType.ELEMENT_TYPE_VALUETYPE)
{
uint token = MetadataHelperFunctions.CorSigUncompressToken(ref ppvSigTemp);
@@ -148,9 +149,11 @@ namespace Microsoft.Samples.Debugging.CorMetadata }
// [Xamarin] Expression evaluator.
- public override bool IsDefined (Type attributeType, bool inherit)
+ public override object[] GetCustomAttributes (bool inherit)
{
- return GetCustomAttributes (attributeType, inherit).Length > 0;
+ if (m_customAttributes == null)
+ m_customAttributes = MetadataHelperFunctionsExtensions.GetDebugAttributes (m_importer, m_fieldToken);
+ return m_customAttributes;
}
// [Xamarin] Expression evaluator.
@@ -165,11 +168,9 @@ namespace Microsoft.Samples.Debugging.CorMetadata }
// [Xamarin] Expression evaluator.
- public override object[] GetCustomAttributes (bool inherit)
+ public override bool IsDefined (Type attributeType, bool inherit)
{
- if (m_customAttributes == null)
- m_customAttributes = MetadataHelperFunctions.GetDebugAttributes (m_importer, m_fieldToken);
- return m_customAttributes;
+ return GetCustomAttributes (attributeType, inherit).Length > 0;
}
@@ -246,5 +247,5 @@ namespace Microsoft.Samples.Debugging.CorMetadata private Object m_value;
// [Xamarin] Expression evaluator.
private object[] m_customAttributes;
- }
+ }
}
diff --git a/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataParameterInfo.cs b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataParameterInfo.cs index 0793fab1fc..4eda1940af 100644 --- a/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataParameterInfo.cs +++ b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataParameterInfo.cs @@ -19,9 +19,8 @@ namespace Microsoft.Samples.Debugging.CorMetadata {
public sealed class MetadataParameterInfo : ParameterInfo
{
- // [Xamarin] Expression evaluator.
internal MetadataParameterInfo(IMetadataImport importer,int paramToken,
- MemberInfo memberImpl,Type typeImpl, Type argType)
+ MemberInfo memberImpl,Type typeImpl)
{
int parentToken;
uint pulSequence,pdwAttr,pdwCPlusTypeFlag,pcchValue,size;
@@ -51,8 +50,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata out pcchValue
);
NameImpl = szName.ToString();
- // [Xamarin] Expression evaluator.
- ClassImpl = argType;
+ ClassImpl = typeImpl;
PositionImpl = (int)pulSequence;
AttrsImpl = (ParameterAttributes)pdwAttr;
diff --git a/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataPropertyInfo.cs b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataPropertyInfo.cs index 5a41d0d7df..b2caeea90b 100644 --- a/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataPropertyInfo.cs +++ b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataPropertyInfo.cs @@ -7,6 +7,7 @@ using System.Reflection; using Microsoft.Samples.Debugging.CorDebug;
using Microsoft.Samples.Debugging.CorMetadata.NativeApi;
using Microsoft.Samples.Debugging.CorDebug.NativeApi;
+using Microsoft.Samples.Debugging.Extensions;
namespace Microsoft.Samples.Debugging.CorMetadata
{
@@ -82,7 +83,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata m_propAttributes = (PropertyAttributes) pdwPropFlags;
m_name = szProperty.ToString ();
- MetadataHelperFunctions.GetCustomAttribute (importer, propertyToken, typeof (System.Diagnostics.DebuggerBrowsableAttribute));
+ MetadataHelperFunctionsExtensions.GetCustomAttribute (importer, propertyToken, typeof (System.Diagnostics.DebuggerBrowsableAttribute));
if (!m_importer.IsValidToken ((uint)m_pmdGetter))
m_pmdGetter = 0;
@@ -183,7 +184,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata public override object[] GetCustomAttributes (bool inherit)
{
if (m_customAttributes == null)
- m_customAttributes = MetadataHelperFunctions.GetDebugAttributes (m_importer, m_propertyToken);
+ m_customAttributes = MetadataHelperFunctionsExtensions.GetDebugAttributes (m_importer, m_propertyToken);
return m_customAttributes;
}
diff --git a/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataType.cs b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataType.cs index a476aa77fd..90aa89e00e 100644 --- a/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataType.cs +++ b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataType.cs @@ -15,12 +15,12 @@ using System.Diagnostics; using Microsoft.Samples.Debugging.CorDebug;
using Microsoft.Samples.Debugging.CorMetadata.NativeApi;
using Microsoft.Samples.Debugging.CorDebug.NativeApi;
+using Microsoft.Samples.Debugging.Extensions;
namespace Microsoft.Samples.Debugging.CorMetadata
{
public sealed class MetadataType : Type
{
- // [Xamarin] Expression evaluator.
internal MetadataType(IMetadataImport importer,int classToken)
{
Debug.Assert(importer!=null);
@@ -61,19 +61,21 @@ namespace Microsoft.Samples.Debugging.CorMetadata string baseTypeName = GetTypeName(importer, ptkExtends);
IntPtr ppvSig;
- if (baseTypeName == "System.Enum") {
- m_isEnum = true;
- m_enumUnderlyingType = GetEnumUnderlyingType (importer, classToken);
-
- // Check for flags enum by looking for FlagsAttribute
- uint sigSize = 0;
- ppvSig = IntPtr.Zero;
- int hr = importer.GetCustomAttributeByName (classToken, "System.FlagsAttribute", out ppvSig, out sigSize);
- if (hr < 0) {
- throw new COMException ("Exception looking for flags attribute", hr);
- }
- m_isFlagsEnum = (hr == 0); // S_OK means the attribute is present.
- }
+ if (baseTypeName == "System.Enum")
+ {
+ m_isEnum = true;
+ m_enumUnderlyingType = GetEnumUnderlyingType(importer,classToken);
+
+ // Check for flags enum by looking for FlagsAttribute
+ uint sigSize = 0;
+ ppvSig = IntPtr.Zero;
+ int hr = importer.GetCustomAttributeByName(classToken,"System.FlagsAttribute",out ppvSig,out sigSize);
+ if (hr < 0)
+ {
+ throw new COMException("Exception looking for flags attribute",hr);
+ }
+ m_isFlagsEnum = (hr == 0); // S_OK means the attribute is present.
+ }
}
}
@@ -223,7 +225,26 @@ namespace Microsoft.Samples.Debugging.CorMetadata // token, depending on the nature and location of the base type.
//
// See ECMA Partition II for more details.
- throw new NotImplementedException();
+ if (m_typeToken == 0)
+ throw new NotImplementedException ();
+
+ var token = new MetadataToken(m_typeToken);
+ int size;
+ TypeAttributes pdwTypeDefFlags;
+ int ptkExtends;
+
+ m_importer.GetTypeDefProps (token,
+ null,
+ 0,
+ out size,
+ out pdwTypeDefFlags,
+ out ptkExtends
+ );
+
+ if (ptkExtends == 0)
+ return null;
+
+ return new MetadataType (m_importer, ptkExtends);
}
}
@@ -337,7 +358,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata public override object[] GetCustomAttributes(bool inherit)
{
if (m_customAttributes == null)
- m_customAttributes = MetadataHelperFunctions.GetDebugAttributes (m_importer, m_typeToken);
+ m_customAttributes = MetadataHelperFunctionsExtensions.GetDebugAttributes (m_importer, m_typeToken);
return m_customAttributes;
}
@@ -411,22 +432,22 @@ namespace Microsoft.Samples.Debugging.CorMetadata // [Xamarin] Expression evaluator.
public override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
{
- ArrayList al = new ArrayList ();
- IntPtr hEnum = new IntPtr ();
+ var al = new ArrayList ();
+ var hEnum = new IntPtr ();
int methodToken;
try {
while (true) {
uint size;
- ((IMetadataImport2)m_importer).EnumProperties (ref hEnum, (int) m_typeToken, out methodToken, 1, out size);
+ m_importer.EnumProperties (ref hEnum, (int) m_typeToken, out methodToken, 1, out size);
if (size == 0)
break;
- MetadataPropertyInfo prop = new MetadataPropertyInfo (m_importer, methodToken, this);
+ var prop = new MetadataPropertyInfo (m_importer, methodToken, this);
try {
MethodInfo mi = prop.GetGetMethod () ?? prop.GetSetMethod ();
if (mi == null)
continue;
- if (FlagsMatch (mi.IsPublic, mi.IsStatic, bindingAttr))
+ if (MetadataExtensions.TypeFlagsMatch (mi.IsPublic, mi.IsStatic, bindingAttr))
al.Add (prop);
}
catch {
@@ -462,35 +483,44 @@ namespace Microsoft.Samples.Debugging.CorMetadata throw new NotImplementedException();
}
+ // TODO: Implement
public override Type[] GetInterfaces()
{
- throw new NotImplementedException();
+ var al = new ArrayList();
+ var hEnum = new IntPtr();
+
+ int impl;
+ try
+ {
+ while(true)
+ {
+ uint size;
+ m_importer.EnumInterfaceImpls (ref hEnum,(int)m_typeToken,out impl,1,out size);
+ if(size==0)
+ break;
+ al.Add (new MetadataType (m_importer, impl));
+ }
+ }
+ finally
+ {
+ m_importer.CloseEnum(hEnum);
+ }
+ return (Type[]) al.ToArray(typeof(Type));
}
public override FieldInfo GetField(String name, BindingFlags bindingAttr)
{
- throw new NotImplementedException();
+ foreach (var field in GetFields (bindingAttr)) {
+ if (field.Name == name)
+ return field;
+ }
+ return null;
}
- // [Xamarin] Expression evaluator.
- bool FlagsMatch (bool ispublic, bool isstatic, BindingFlags flags)
- {
- if (ispublic && (flags & BindingFlags.Public) == 0)
- return false;
- if (!ispublic && (flags & BindingFlags.NonPublic) == 0)
- return false;
- if (isstatic && (flags & BindingFlags.Static) == 0)
- return false;
- if (!isstatic && (flags & BindingFlags.Instance) == 0)
- return false;
- return true;
- }
-
- // [Xamarin] Expression evaluator.
public override FieldInfo[] GetFields(BindingFlags bindingAttr)
{
- ArrayList al = new ArrayList();
- IntPtr hEnum = new IntPtr();
+ var al = new ArrayList();
+ var hEnum = new IntPtr();
int fieldToken;
try
@@ -498,12 +528,12 @@ namespace Microsoft.Samples.Debugging.CorMetadata while(true)
{
uint size;
- // TODO: Check this. Was just m_importer.EnumFields.
- ((IMetadataImport2) m_importer).EnumFields(ref hEnum,(int)m_typeToken,out fieldToken,1,out size);
+ m_importer.EnumFields(ref hEnum,(int)m_typeToken,out fieldToken,1,out size);
if(size==0)
break;
- MetadataFieldInfo field = new MetadataFieldInfo (m_importer, fieldToken, this);
- if (FlagsMatch (field.IsPublic, field.IsStatic, bindingAttr))
+ // [Xamarin] Expression evaluator.
+ var field = new MetadataFieldInfo (m_importer, fieldToken, this);
+ if (MetadataExtensions.TypeFlagsMatch (field.IsPublic, field.IsStatic, bindingAttr))
al.Add (field);
}
}
@@ -514,7 +544,6 @@ namespace Microsoft.Samples.Debugging.CorMetadata return (FieldInfo[]) al.ToArray(typeof(FieldInfo));
}
- // [Xamarin] Expression evaluator.
public override MethodInfo[] GetMethods(BindingFlags bindingAttr)
{
ArrayList al = new ArrayList();
@@ -529,8 +558,9 @@ namespace Microsoft.Samples.Debugging.CorMetadata m_importer.EnumMethods(ref hEnum,(int)m_typeToken,out methodToken,1,out size);
if(size==0)
break;
- MetadataMethodInfo met = new MetadataMethodInfo (m_importer, methodToken);
- if (FlagsMatch (met.IsPublic, met.IsStatic, bindingAttr))
+ // [Xamarin] Expression evaluator.
+ var met = new MetadataMethodInfo (m_importer, methodToken);
+ if (MetadataExtensions.TypeFlagsMatch (met.IsPublic, met.IsStatic, bindingAttr))
al.Add (met);
}
}
@@ -632,7 +662,6 @@ namespace Microsoft.Samples.Debugging.CorMetadata }
}
- // [Xamarin] Expression evaluator.
// returns "" for normal classes, returns prefix for nested classes
private string GetNestedClassPrefix(IMetadataImport importer, int classToken, TypeAttributes attribs)
{
@@ -641,86 +670,32 @@ namespace Microsoft.Samples.Debugging.CorMetadata // it is a nested class
int enclosingClass;
importer.GetNestedClassProps(classToken, out enclosingClass);
+ // [Xamarin] Expression evaluator.
m_declaringType = new MetadataType (importer, enclosingClass);
return m_declaringType.FullName + "+";
+ //MetadataType mt = new MetadataType(importer,enclosingClass);
+ //return mt.Name+".";
}
else
return String.Empty;
}
+ // member variables
+ private string m_name;
+ private IMetadataImport m_importer;
+ private int m_typeToken;
+ private bool m_isEnum;
+ private bool m_isFlagsEnum;
+ private CorElementType m_enumUnderlyingType;
+ private List<KeyValuePair<string,ulong>> m_enumValues;
// [Xamarin] Expression evaluator.
- internal static Type MakeDelegate (Type retType, List<Type> argTypes)
- {
-
- throw new NotImplementedException ();
- }
-
- // [Xamarin] Expression evaluator.
- public static Type MakeArray (Type t, List<int> sizes, List<int> loBounds)
- {
- MetadataType mt = t as MetadataType;
- if (mt != null) {
- if (sizes == null) {
- sizes = new List<int> ();
- sizes.Add (1);
- }
- mt.m_arraySizes = sizes;
- mt.m_arrayLoBounds = loBounds;
- return mt;
- }
- if (sizes == null || sizes.Count == 1)
- return t.MakeArrayType ();
- else
- return t.MakeArrayType (sizes.Capacity);
- }
-
- // [Xamarin] Expression evaluator.
- public static Type MakeByRef (Type t)
- {
- MetadataType mt = t as MetadataType;
- if (mt != null) {
- mt.m_isByRef = true;
- return mt;
- }
- return t.MakeByRefType ();
- }
-
- // [Xamarin] Expression evaluator.
- public static Type MakePointer (Type t)
- {
- MetadataType mt = t as MetadataType;
- if (mt != null) {
- mt.m_isPtr = true;
- return mt;
- }
- return t.MakeByRefType ();
- }
-
- // [Xamarin] Expression evaluator.
- public static Type MakeGeneric (Type t, List<Type> typeArgs)
- {
- MetadataType mt = (MetadataType)t;
- mt.m_typeArgs = typeArgs;
- return mt;
- }
-
- // member variables
- private string m_name;
- private IMetadataImport m_importer;
- private int m_typeToken;
- private bool m_isEnum;
- private bool m_isFlagsEnum;
- private CorElementType m_enumUnderlyingType;
- // [Xamarin] Expression evaluator.
- private List<KeyValuePair<string, ulong>> m_enumValues;
private object[] m_customAttributes;
private Type m_declaringType;
- private List<int> m_arraySizes;
- private List<int> m_arrayLoBounds;
- private bool m_isByRef, m_isPtr;
- private List<Type> m_typeArgs;
-
- }
+ internal List<int> m_arraySizes;
+ internal List<int> m_arrayLoBounds;
+ internal bool m_isByRef, m_isPtr;
+ internal List<Type> m_typeArgs;
+ }
// Sorts KeyValuePair<string,ulong>'s in increasing order by the value
class AscendingValueComparer<K, V> : IComparer<KeyValuePair<K,V>> where V:IComparable
diff --git a/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/debug/Debugger.cs b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/debug/Debugger.cs index ddbc5f186d..7f31cd1306 100644 --- a/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/debug/Debugger.cs +++ b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/debug/Debugger.cs @@ -5,11 +5,8 @@ //---------------------------------------------------------------------
using System;
using System.Collections;
-using System.Collections.Generic;
using System.Diagnostics;
-#if !MDBG_FAKE_COM
using System.Runtime.InteropServices;
-#endif
using System.Runtime.InteropServices.ComTypes;
using System.Threading;
using System.Text;
@@ -18,6 +15,8 @@ using System.Globalization; using Microsoft.Samples.Debugging.CorDebug.NativeApi;
+using Microsoft.Samples.Debugging.Extensions;
+using System.Collections.Generic;
using Microsoft.Win32.SafeHandles;
@@ -31,8 +30,6 @@ namespace Microsoft.Samples.Debugging.CorDebug public sealed class CorDebugger : MarshalByRefObject
{
private const int MaxVersionStringLength = 256; // == MAX_PATH
- // [Xamarin] Output redirection.
- public const int CREATE_REDIRECT_STD = 0x40000000;
public static string GetDebuggerVersionFromFile(string pathToExe)
{
@@ -153,7 +150,6 @@ namespace Microsoft.Samples.Debugging.CorDebug return CreateProcess (applicationName, commandLine, ".");
}
- // [Xamarin] ASP.NET Debugging.
/**
* Launch a process under the control of the debugger.
*
@@ -164,16 +160,17 @@ namespace Microsoft.Samples.Debugging.CorDebug String commandLine,
String currentDirectory
)
- {
+ {
+ // [Xamarin] ASP.NET Debugging.
return CreateProcess (applicationName, commandLine, currentDirectory, null, 0);
}
- // [Xamarin] ASP.NET Debugging.
/**
* Launch a process under the control of the debugger.
*
* Parameters are the same as the Win32 CreateProcess call.
*/
+ // [Xamarin] ASP.NET Debugging.
public CorProcess CreateProcess (
String applicationName,
String commandLine,
@@ -184,7 +181,6 @@ namespace Microsoft.Samples.Debugging.CorDebug return CreateProcess (applicationName, commandLine, currentDirectory, environment, 0);
}
- // [Xamarin] ASP.NET Debugging and output redirection.
/**
* Launch a process under the control of the debugger.
*
@@ -204,26 +200,10 @@ namespace Microsoft.Samples.Debugging.CorDebug si.cb = Marshal.SizeOf(si);
// initialize safe handles
+ // [Xamarin] ASP.NET Debugging and output redirection.
SafeFileHandle outReadPipe = null, errorReadPipe = null;
- if ((flags & CREATE_REDIRECT_STD) != 0) {
- CreateHandles (si, out outReadPipe, out errorReadPipe);
- flags &= ~CREATE_REDIRECT_STD;
- }
- else {
- si.hStdInput = new SafeFileHandle (IntPtr.Zero, false);
- si.hStdOutput = new SafeFileHandle (IntPtr.Zero, false);
- si.hStdError = new SafeFileHandle (IntPtr.Zero, false);
- }
-
- IntPtr env = IntPtr.Zero;
- if (environment != null) {
- string senv = null;
- foreach (KeyValuePair<string, string> var in environment) {
- senv += var.Key + "=" + var.Value + "\0";
- }
- senv += "\0";
- env = Marshal.StringToHGlobalAnsi (senv);
- }
+ DebuggerExtensions.SetupOutputRedirection (si, ref flags, outReadPipe, errorReadPipe);
+ IntPtr env = DebuggerExtensions.SetupEnvironment (environment);
CorProcess ret;
@@ -250,64 +230,12 @@ namespace Microsoft.Samples.Debugging.CorDebug NativeMethods.CloseHandle (pi.hThread);
}
- if (env != IntPtr.Zero)
- Marshal.FreeHGlobal (env);
-
- if (outReadPipe != null) {
-
- // Close pipe handles (do not continue to modify the parent).
- // You need to make sure that no handles to the write end of the
- // output pipe are maintained in this process or else the pipe will
- // not close when the child process exits and the ReadFile will hang.
-
- si.hStdInput.Close ();
- si.hStdOutput.Close ();
- si.hStdError.Close ();
-
- ret.TrackStdOutput (outReadPipe, errorReadPipe);
- }
+ DebuggerExtensions.TearDownEnvironment (env);
+ DebuggerExtensions.TearDownOutputRedirection (outReadPipe, errorReadPipe, si, ret);
- return ret;
+ return ret;
}
- // [Xamarin] Output redirection.
- void CreateHandles (STARTUPINFO si, out SafeFileHandle outReadPipe, out SafeFileHandle errorReadPipe)
- {
- si.dwFlags |= 0x00000100; /*STARTF_USESTDHANDLES*/
- SECURITY_ATTRIBUTES sa = new SECURITY_ATTRIBUTES ();
- sa.bInheritHandle = true;
- IntPtr curProc = NativeMethods.GetCurrentProcess ();
-
- SafeFileHandle outWritePipe, outReadPipeTmp;
- if (!NativeMethods.CreatePipe (out outReadPipeTmp, out outWritePipe, sa, 0))
- throw new Exception ("Pipe creation failed");
-
- // Create the child error pipe.
- SafeFileHandle errorWritePipe, errorReadPipeTmp;
- if (!NativeMethods.CreatePipe (out errorReadPipeTmp, out errorWritePipe, sa, 0))
- throw new Exception ("Pipe creation failed");
-
- // Create new output read and error read handles. Set
- // the Properties to FALSE. Otherwise, the child inherits the
- // properties and, as a result, non-closeable handles to the pipes
- // are created.
- if (!NativeMethods.DuplicateHandle (curProc, outReadPipeTmp, curProc, out outReadPipe, 0, false, NativeMethods.DUPLICATE_SAME_ACCESS))
- throw new Exception ("Pipe creation failed");
- if (!NativeMethods.DuplicateHandle (curProc, errorReadPipeTmp, curProc, out errorReadPipe, 0, false, NativeMethods.DUPLICATE_SAME_ACCESS))
- throw new Exception ("Pipe creation failed");
-
- NativeMethods.CloseHandle (curProc);
-
- // Close inheritable copies of the handles you do not want to be
- // inherited.
- outReadPipeTmp.Close ();
- errorReadPipeTmp.Close ();
-
- si.hStdInput = NativeMethods.GetStdHandle (NativeMethods.STD_INPUT_HANDLE);
- si.hStdOutput = outWritePipe;
- si.hStdError = errorWritePipe;
- }
-
/**
* Launch a process under the control of the debugger.
*
@@ -416,7 +344,6 @@ namespace Microsoft.Samples.Debugging.CorDebug //
////////////////////////////////////////////////////////////////////////////////
- // [Xamarin] .NET 4 API Version.
// called by constructors during initialization
private void InitFromVersion(string debuggerVersion)
{
@@ -427,6 +354,7 @@ namespace Microsoft.Samples.Debugging.CorDebug }
ICorDebug rawDebuggingAPI;
+ // [Xamarin] .NET 4 API Version.
#if MDBG_FAKE_COM
// TODO: Ideally, there wouldn't be any difference in the corapi code for MDBG_FAKE_COM.
// This would require puting this initialization logic into the wrapper and interop assembly, which doesn't seem right.
@@ -610,60 +538,7 @@ namespace Microsoft.Samples.Debugging.CorDebug ref Guid riid, // must be "ref NativeMethods.IIDICorDebug"
[MarshalAs(UnmanagedType.Interface)]out ICorDebug debuggingInterface
);
-
- // [Xamarin] Output redirection.
- [
- DllImport (Kernel32LibraryName, CharSet = CharSet.Auto, SetLastError = true)
- ]
- public static extern bool CreatePipe (out SafeFileHandle hReadPipe, out SafeFileHandle hWritePipe, SECURITY_ATTRIBUTES lpPipeAttributes, int nSize);
-
- // [Xamarin] Output redirection.
- [
- DllImport (Kernel32LibraryName)
- ]
- public static extern bool DuplicateHandle (
- IntPtr hSourceProcessHandle,
- SafeFileHandle hSourceHandle,
- IntPtr hTargetProcessHandle,
- out SafeFileHandle lpTargetHandle,
- uint dwDesiredAccess,
- bool bInheritHandle,
- uint dwOptions
- );
-
- // [Xamarin] Output redirection.
- public static uint DUPLICATE_CLOSE_SOURCE = 0x00000001;
- public static uint DUPLICATE_SAME_ACCESS = 0x00000002;
-
- // [Xamarin] Output redirection.
- [
- DllImport (Kernel32LibraryName)
- ]
- public static extern SafeFileHandle GetStdHandle (uint nStdHandle);
-
- // [Xamarin] Output redirection.
- public const uint STD_INPUT_HANDLE = unchecked ((uint)-10);
- public const uint STD_OUTPUT_HANDLE = unchecked ((uint)-11);
- public const uint STD_ERROR_HANDLE = unchecked ((uint)-12);
-
- // [Xamarin] Output redirection.
- [
- DllImport (Kernel32LibraryName)
- ]
- public static extern bool ReadFile (
- SafeFileHandle hFile,
- byte[] lpBuffer,
- int nNumberOfBytesToRead,
- out int lpNumberOfBytesRead,
- IntPtr lpOverlapped
- );
-
- // [Xamarin] Output redirection.
- [
- DllImport (Kernel32LibraryName, CharSet = CharSet.Auto, SetLastError = true)
- ]
- public static extern IntPtr GetCurrentProcess ();
- }
+ }
////////////////////////////////////////////////////////////////////////////////
//
@@ -1969,22 +1844,6 @@ namespace Microsoft.Samples.Debugging.CorDebug Last = ManagedCallbackType.OnExceptionInCallback,
}
- // [Xamarin] Output redirection.
- public class CorTargetOutputEventArgs: EventArgs
- {
- public CorTargetOutputEventArgs (string text, bool isStdError)
- {
- Text = text;
- }
-
- public string Text { get; set; }
-
- public bool IsStdError { get; set; }
- }
-
- // [Xamarin] Output redirection.
- public delegate void CorTargetOutputEventHandler (Object sender, CorTargetOutputEventArgs e);
-
// Helper class to convert from COM-classic callback interface into managed args.
// Derived classes can overide the HandleEvent method to define the handling.
abstract public class ManagedCallbackBase : ICorDebugManagedCallback, ICorDebugManagedCallback2
@@ -2077,7 +1936,7 @@ namespace Microsoft.Samples.Debugging.CorDebug {
HandleEvent(ManagedCallbackType.OnProcessExit,
new CorProcessEventArgs(process == null ? null : CorProcess.GetCorProcess(process),
- ManagedCallbackType.OnProcessExit));
+ ManagedCallbackType.OnProcessExit) { Continue = false });
}
void ICorDebugManagedCallback.CreateThread(
diff --git a/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/debug/Process.cs b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/debug/Process.cs index c59dcac254..4076b9de20 100644 --- a/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/debug/Process.cs +++ b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/debug/Process.cs @@ -276,45 +276,6 @@ namespace Microsoft.Samples.Debugging.CorDebug else
base.Continue(outOfBand);
}
-
- // [Xamarin] Output redirection.
- internal void TrackStdOutput (Microsoft.Win32.SafeHandles.SafeFileHandle outputPipe, Microsoft.Win32.SafeHandles.SafeFileHandle errorPipe)
- {
- Thread outputReader = new Thread (delegate ()
- {
- ReadOutput (outputPipe, false);
- });
- outputReader.Name = "Debugger output reader";
- outputReader.IsBackground = true;
- outputReader.Start ();
-
- Thread errorReader = new Thread (delegate ()
- {
- ReadOutput (errorPipe, true);
- });
- errorReader.Name = "Debugger error reader";
- errorReader.IsBackground = true;
- errorReader.Start ();
- }
-
- // [Xamarin] Output redirection.
- void ReadOutput (Microsoft.Win32.SafeHandles.SafeFileHandle pipe, bool isStdError)
- {
- byte[] buffer = new byte[256];
- int nBytesRead;
-
- try {
- while (true) {
- if (!NativeMethods.ReadFile (pipe, buffer, buffer.Length, out nBytesRead, IntPtr.Zero) || nBytesRead == 0)
- break; // pipe done - normal exit path.
- string s = System.Text.Encoding.Default.GetString (buffer, 0, nBytesRead);
- if (OnStdOutput != null)
- OnStdOutput (this, new CorTargetOutputEventArgs (s, isStdError));
- }
- }
- catch {
- }
- }
// when process is first created wait till callbacks are enabled.
private ManualResetEvent m_callbackAttachedEvent = new ManualResetEvent(false);
@@ -789,8 +750,5 @@ namespace Microsoft.Samples.Debugging.CorDebug }
}
- // [Xamarin] Output redirection.
- public event CorTargetOutputEventHandler OnStdOutput;
-
} /* class Process */
} /* namespace */
diff --git a/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/debug/Type.cs b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/debug/Type.cs index cf49fb0212..d15b35b190 100644 --- a/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/debug/Type.cs +++ b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/debug/Type.cs @@ -91,7 +91,7 @@ namespace Microsoft.Samples.Debugging.CorDebug // [Xamarin] Expression evaluator.
// Expose IEnumerable, which can be used with for-each constructs.
// This will provide an collection of CorType parameters.
- public CorType[] TypeParameters
+ public CorType[] TypeParameters
{
get
{
@@ -102,6 +102,7 @@ namespace Microsoft.Samples.Debugging.CorDebug foreach (CorType t in new CorTypeEnumerator (etp))
list.Add (t);
return list.ToArray ();
+ //return new CorTypeEnumerator (etp);
}
}
} /* class Type */
diff --git a/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/debug/Value.cs b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/debug/Value.cs index a3722f36b6..184c6b6f32 100644 --- a/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/debug/Value.cs +++ b/main/src/addins/MonoDevelop.Debugger.Win32/CorApi2/debug/Value.cs @@ -739,9 +739,9 @@ namespace Microsoft.Samples.Debugging.CorDebug {
Debug.Assert(Rank!=0);
uint[] dims = new uint[Rank];
- m_arrayVal.GetDimensions((uint)dims.Length, dims);
+ m_arrayVal.GetDimensions((uint)dims.Length,dims);
- int[] sdims = Array.ConvertAll<uint,int>(dims, delegate(uint u) { return (int)u; });
+ int[] sdims = Array.ConvertAll<uint,int>( dims, delegate(uint u) { return (int)u; } );
return sdims;
}
diff --git a/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/AddinInfo.cs b/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/AddinInfo.cs new file mode 100644 index 0000000000..be6398819e --- /dev/null +++ b/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/AddinInfo.cs @@ -0,0 +1,17 @@ + +using System; +using Mono.Addins; +using Mono.Addins.Description; + +[assembly:Addin ("Debugger.Win32", + Namespace = "MonoDevelop", + Version = MonoDevelop.BuildInfo.Version, + Category = "Debugging")] + +[assembly:AddinName ("Microsoft .NET support for Mono.Debugging")] +[assembly:AddinDescription ("Managed Debugging Engine support for MS.NET")] + +[assembly:AddinDependency ("Core", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("Ide", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("Debugger", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("AspNet", MonoDevelop.BuildInfo.Version)] diff --git a/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/CorDebuggerBacktrace.cs b/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/CorDebuggerBacktrace.cs index 9807a3738f..373bad3e69 100644 --- a/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/CorDebuggerBacktrace.cs +++ b/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/CorDebuggerBacktrace.cs @@ -78,13 +78,21 @@ namespace MonoDevelop.Debugger.Win32 internal static StackFrame CreateFrame (CorDebuggerSession session, CorFrame frame)
{
+ // TODO: Fix remaining.
uint address = 0;
+ //string typeFQN;
+ //string typeFullName;
+ string addressSpace = "";
string file = "";
int line = 0;
+ int column = 0;
string method = "";
string lang = "";
string module = "";
string type = "";
+ bool hasDebugInfo = false;
+ bool hidden = false;
+ bool external = true;
if (frame.FrameType == CorFrameType.ILFrame) {
if (frame.Function != null) {
@@ -93,27 +101,32 @@ namespace MonoDevelop.Debugger.Win32 MethodInfo mi = importer.GetMethodInfo (frame.Function.Token);
method = mi.DeclaringType.FullName + "." + mi.Name;
type = mi.DeclaringType.FullName;
+ addressSpace = mi.Name;
ISymbolReader reader = session.GetReaderForModule (frame.Function.Module.Name);
if (reader != null) {
ISymbolMethod met = reader.GetMethod (new SymbolToken (frame.Function.Token));
if (met != null) {
- uint offset;
CorDebugMappingResult mappingResult;
- frame.GetIP (out offset, out mappingResult);
+ frame.GetIP (out address, out mappingResult);
SequencePoint prevSp = null;
foreach (SequencePoint sp in met.GetSequencePoints ()) {
- if (sp.Offset > offset)
+ if (sp.Offset > address)
break;
prevSp = sp;
}
if (prevSp != null) {
line = prevSp.Line;
+ column = prevSp.Offset;
file = prevSp.Document.URL;
+ address = (uint)prevSp.Offset;
}
}
}
+ // FIXME: Still steps into.
+ //hidden = mi.GetCustomAttributes (true).Any (v => v is System.Diagnostics.DebuggerHiddenAttribute);
}
lang = "Managed";
+ hasDebugInfo = true;
}
else if (frame.FrameType == CorFrameType.NativeFrame) {
frame.GetNativeIP (out address);
@@ -129,10 +142,12 @@ namespace MonoDevelop.Debugger.Win32 case CorDebugInternalFrameType.STUBFRAME_FUNC_EVAL: method = "[Function Evaluation]"; break;
}
}
+
if (method == null)
method = "<Unknown>";
- var loc = new SourceLocation (method, file, line);
- return new StackFrame ((long) address, loc, lang);
+
+ var loc = new SourceLocation (method, file, line, column);
+ return new StackFrame ((long) address, addressSpace, loc, lang, external, hasDebugInfo, hidden, null, null);
}
#endregion
diff --git a/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/CorDebuggerSession.cs b/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/CorDebuggerSession.cs index 07220319bc..ec54e33a16 100644 --- a/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/CorDebuggerSession.cs +++ b/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/CorDebuggerSession.cs @@ -10,6 +10,7 @@ using Microsoft.Samples.Debugging.CorDebug; using Microsoft.Samples.Debugging.CorDebug.NativeApi;
using Microsoft.Samples.Debugging.CorMetadata;
using Microsoft.Samples.Debugging.CorSymbolStore;
+using Microsoft.Samples.Debugging.Extensions;
using Mono.Debugging.Backend;
using Mono.Debugging.Client;
using Mono.Debugging.Evaluation;
@@ -143,7 +144,7 @@ namespace MonoDevelop.Debugger.Win32 int flags = 0;
if (!startInfo.UseExternalConsole) {
flags = (int)CreationFlags.CREATE_NO_WINDOW;
- flags |= CorDebugger.CREATE_REDIRECT_STD;
+ flags |= DebuggerExtensions.CREATE_REDIRECT_STD;
}
process = dbg.CreateProcess (startInfo.Command, cmdLine, startInfo.WorkingDirectory, env, flags);
@@ -167,9 +168,10 @@ namespace MonoDevelop.Debugger.Win32 process.OnEvalComplete += new EvalEventHandler (OnEvalComplete);
process.OnEvalException += new EvalEventHandler (OnEvalException);
process.OnLogMessage += new LogMessageEventHandler (OnLogMessage);
- process.OnStdOutput += new CorTargetOutputEventHandler (OnStdOutput);
process.OnException2 += new CorException2EventHandler (OnException2);
+ process.RegisterStdOutput (OnStdOutput);
+
process.Continue (false);
});
OnStarted ();
@@ -932,7 +934,7 @@ namespace MonoDevelop.Debugger.Win32 mc.OnGetDescription = delegate {
MethodInfo met = function.GetMethodInfo (ctx.Session);
if (met != null)
- return met.Name;
+ return met.DeclaringType.FullName + "." + met.Name;
else
return "<Unknown>";
};
@@ -1263,7 +1265,7 @@ namespace MonoDevelop.Debugger.Win32 public static Type GetTypeInfo (this CorType type, CorDebuggerSession session)
{
Type t;
- if (CorMetadataImport.CoreTypes.TryGetValue (type.Type, out t))
+ if (MetadataHelperFunctionsExtensions.CoreTypes.TryGetValue (type.Type, out t))
return t;
if (type.Type == CorElementType.ELEMENT_TYPE_ARRAY || type.Type == CorElementType.ELEMENT_TYPE_SZARRAY) {
@@ -1273,14 +1275,14 @@ namespace MonoDevelop.Debugger.Win32 sizes.Add (1);
loBounds.Add (0);
}
- return MetadataType.MakeArray (type.FirstTypeParameter.GetTypeInfo (session), sizes, loBounds);
+ return MetadataExtensions.MakeArray (type.FirstTypeParameter.GetTypeInfo (session), sizes, loBounds);
}
if (type.Type == CorElementType.ELEMENT_TYPE_BYREF)
- return MetadataType.MakeByRef (type.FirstTypeParameter.GetTypeInfo (session));
+ return MetadataExtensions.MakeByRef (type.FirstTypeParameter.GetTypeInfo (session));
if (type.Type == CorElementType.ELEMENT_TYPE_PTR)
- return MetadataType.MakePointer (type.FirstTypeParameter.GetTypeInfo (session));
+ return MetadataExtensions.MakePointer (type.FirstTypeParameter.GetTypeInfo (session));
CorMetadataImport mi = session.GetMetadataForModule (type.Class.Module.Name);
if (mi != null) {
@@ -1290,7 +1292,7 @@ namespace MonoDevelop.Debugger.Win32 List<Type> types = new List<Type> ();
foreach (CorType ct in targs)
types.Add (ct.GetTypeInfo (session));
- return MetadataType.MakeGeneric (t, types);
+ return MetadataExtensions.MakeGeneric (t, types);
}
else
return t;
diff --git a/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/CorObjectAdaptor.cs b/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/CorObjectAdaptor.cs index 9e9410415e..6c6e1203bd 100644 --- a/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/CorObjectAdaptor.cs +++ b/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/CorObjectAdaptor.cs @@ -42,6 +42,9 @@ using SR = System.Reflection; using CorDebugHandleType = Microsoft.Samples.Debugging.CorDebug.NativeApi.CorDebugHandleType;
using CorDebugMappingResult = Microsoft.Samples.Debugging.CorDebug.NativeApi.CorDebugMappingResult;
using CorElementType = Microsoft.Samples.Debugging.CorDebug.NativeApi.CorElementType;
+using Microsoft.Samples.Debugging.Extensions;
+using System.Linq;
+using System.Runtime.CompilerServices;
namespace MonoDevelop.Debugger.Win32
{
@@ -93,7 +96,22 @@ namespace MonoDevelop.Debugger.Win32 public override bool IsClass (EvaluationContext ctx, object type)
{
- return ((CorType)type).Type == CorElementType.ELEMENT_TYPE_CLASS && ((CorType)type).Class != null;
+ var t = (CorType) type;
+ var cctx = (CorEvaluationContext)ctx;
+ Type tt;
+ // Primitive check
+ if (MetadataHelperFunctionsExtensions.CoreTypes.TryGetValue (t.Type, out tt))
+ return false;
+
+ if (IsIEnumerable (t, cctx.Session))
+ return false;
+
+ return (t.Type == CorElementType.ELEMENT_TYPE_CLASS && t.Class != null) || IsValueType (t);
+ }
+
+ public override bool IsGenericType (EvaluationContext ctx, object type)
+ {
+ return (((CorType)type).Type == CorElementType.ELEMENT_TYPE_GENERICINST) || base.IsGenericType (ctx, type);
}
public override string GetTypeName (EvaluationContext ctx, object gtype)
@@ -101,7 +119,7 @@ namespace MonoDevelop.Debugger.Win32 CorType type = (CorType) gtype;
CorEvaluationContext cctx = (CorEvaluationContext) ctx;
Type t;
- if (CorMetadataImport.CoreTypes.TryGetValue (type.Type, out t))
+ if (MetadataHelperFunctionsExtensions.CoreTypes.TryGetValue (type.Type, out t))
return t.FullName;
try {
if (type.Type == CorElementType.ELEMENT_TYPE_ARRAY || type.Type == CorElementType.ELEMENT_TYPE_SZARRAY)
@@ -116,8 +134,8 @@ namespace MonoDevelop.Debugger.Win32 return type.GetTypeInfo (cctx.Session).FullName;
}
catch (Exception ex) {
- Console.WriteLine (ex);
- throw;
+ ctx.WriteDebuggerError (ex);
+ return t.FullName;
}
}
@@ -137,7 +155,7 @@ namespace MonoDevelop.Debugger.Win32 return CastArray<object> (types);
}
- IEnumerable<Type> GetAllTypes (EvaluationContext gctx)
+ static IEnumerable<Type> GetAllTypes (EvaluationContext gctx)
{
CorEvaluationContext ctx = (CorEvaluationContext) gctx;
foreach (CorModule mod in ctx.Session.GetModules ()) {
@@ -149,19 +167,27 @@ namespace MonoDevelop.Debugger.Win32 }
}
+ Dictionary<string, CorType> typeCache = new Dictionary<string, CorType> ();
public override object GetType (EvaluationContext gctx, string name, object[] gtypeArgs)
{
+ CorType fastRet;
+ if (typeCache.TryGetValue (name, out fastRet))
+ return fastRet;
+
CorType[] typeArgs = CastArray<CorType> (gtypeArgs);
CorEvaluationContext ctx = (CorEvaluationContext) gctx;
foreach (CorModule mod in ctx.Session.GetModules ()) {
CorMetadataImport mi = ctx.Session.GetMetadataForModule (mod.Name);
if (mi != null) {
- foreach (Type t in mi.DefinedTypes)
+ foreach (Type t in mi.DefinedTypes) {
if (t.FullName == name) {
CorClass cls = mod.GetClassFromToken (t.MetadataToken);
- return cls.GetParameterizedType (CorElementType.ELEMENT_TYPE_CLASS, typeArgs);
+ fastRet = cls.GetParameterizedType (CorElementType.ELEMENT_TYPE_CLASS, typeArgs);
+ typeCache [name] = fastRet;
+ return fastRet;
}
+ }
}
}
return null;
@@ -183,14 +209,18 @@ namespace MonoDevelop.Debugger.Win32 if ((obj is CorReferenceValue) && ((CorReferenceValue)obj).IsNull)
return string.Empty;
- CorStringValue stringVal = obj as CorStringValue;
+ var stringVal = obj as CorStringValue;
if (stringVal != null)
return stringVal.String;
- CorArrayValue arr = obj as CorArrayValue;
+ var genericVal = obj as CorGenericValue;
+ if (genericVal != null)
+ return genericVal.GetValue ().ToString ();
+
+ var arr = obj as CorArrayValue;
if (arr != null)
{
- StringBuilder tn = new StringBuilder (GetDisplayTypeName (ctx, arr.ExactType.FirstTypeParameter));
+ var tn = new StringBuilder (GetDisplayTypeName (ctx, arr.ExactType.FirstTypeParameter));
tn.Append("[");
int[] dims = arr.GetDimensions();
for (int n = 0; n < dims.Length; n++)
@@ -203,8 +233,8 @@ namespace MonoDevelop.Debugger.Win32 return tn.ToString();
}
- CorEvaluationContext cctx = (CorEvaluationContext)ctx;
- CorObjectValue co = obj as CorObjectValue;
+ var cctx = (CorEvaluationContext)ctx;
+ var co = obj as CorObjectValue;
if (co != null)
{
if (IsEnum (ctx, co.ExactType))
@@ -242,13 +272,13 @@ namespace MonoDevelop.Debugger.Win32 return nval.ToString ();
}
- CorType targetType = (CorType)GetValueType (ctx, objr);
+ var targetType = (CorType)GetValueType (ctx, objr);
MethodInfo met = OverloadResolve (cctx, "ToString", targetType, new CorType[0], BindingFlags.Public | BindingFlags.Instance, false);
if (met != null && met.DeclaringType.FullName != "System.Object") {
- object[] args = new object[0];
+ var args = new object[0];
object ores = RuntimeInvoke (ctx, targetType, objr, "ToString", args, args);
- CorStringValue res = GetRealObject (ctx, ores) as CorStringValue;
+ var res = GetRealObject (ctx, ores) as CorStringValue;
if (res != null)
return res.String;
}
@@ -256,22 +286,16 @@ namespace MonoDevelop.Debugger.Win32 return GetDisplayTypeName (ctx, targetType);
}
- CorGenericValue genVal = obj as CorGenericValue;
- if (genVal != null)
- {
- return genVal.GetValue().ToString ();
- }
-
return base.CallToString(ctx, obj);
}
public override object CreateTypeObject (EvaluationContext ctx, object type)
{
- CorType t = (CorType)type;
+ var t = (CorType)type;
string tname = GetTypeName (ctx, t) + ", " + System.IO.Path.GetFileNameWithoutExtension (t.Class.Module.Assembly.Name);
- CorType stype = (CorType) GetType (ctx, "System.Type");
- object[] argTypes = new object[] { GetType (ctx, "System.String") };
- object[] argVals = new object[] { CreateValue (ctx, tname) };
+ var stype = (CorType) GetType (ctx, "System.Type");
+ object[] argTypes = { GetType (ctx, "System.String") };
+ object[] argVals = { CreateValue (ctx, tname) };
return RuntimeInvoke (ctx, stype, null, "GetType", argTypes, argVals);
}
@@ -300,10 +324,10 @@ namespace MonoDevelop.Debugger.Win32 CorArrayValue array = CorObjectAdaptor.GetRealObject (ctx, arr) as CorArrayValue;
ArrayAdaptor realArr = new ArrayAdaptor (ctx, arr, array);
- realArr.SetElement (new int[] { 0 }, val);
+ realArr.SetElement (new [] { 0 }, val);
CorType at = (CorType) GetType (ctx, "System.Array");
- object[] argTypes = new object[] { GetType (ctx, "System.Int32") };
+ object[] argTypes = { GetType (ctx, "System.Int32") };
return (CorValRef)RuntimeInvoke (ctx, at, arr, "GetValue", argTypes, new object[] { CreateValue (ctx, 0) });
}
@@ -335,6 +359,7 @@ namespace MonoDevelop.Debugger.Win32 CorEvaluationContext ctx = (CorEvaluationContext)gctx;
MethodInfo method = OverloadResolve (ctx, methodName, targetType, argTypes, flags, true);
ParameterInfo[] parameters = method.GetParameters ();
+ // TODO: Check this.
for (int n = 0; n < parameters.Length; n++) {
if (parameters[n].ParameterType == typeof(object) && (IsValueType (ctx, argValues[n])))
argValues[n] = Box (ctx, argValues[n]);
@@ -374,9 +399,16 @@ namespace MonoDevelop.Debugger.Win32 candidates.Add (met);
}
}
+
+ if (argtypes == null && candidates.Count > 0)
+ break; // when argtypes is null, we are just looking for *any* match (not a specific match)
+
if (methodName == ".ctor")
break; // Can't create objects using constructor from base classes
- currentType = currentType.Base;
+ if (rtype.BaseType == null && rtype.FullName != "System.Object")
+ currentType = ctx.Adapter.GetType (ctx, "System.Object") as CorType;
+ else
+ currentType = currentType.Base;
}
return OverloadResolve (ctx, GetTypeName (ctx, type), methodName, argtypes, candidates, throwIfNotFound);
@@ -481,30 +513,32 @@ namespace MonoDevelop.Debugger.Win32 public override string[] GetImportedNamespaces (EvaluationContext ctx)
{
- Set<string> list = new Set<string> ();
+ var list = new HashSet<string> ();
foreach (Type t in GetAllTypes (ctx)) {
list.Add (t.Namespace);
}
- string[] arr = new string[list.Count];
- list.CopyTo (arr, 0);
+ var arr = new string[list.Count];
+ list.CopyTo (arr);
return arr;
}
public override void GetNamespaceContents (EvaluationContext ctx, string namspace, out string[] childNamespaces, out string[] childTypes)
{
- Set<string> nss = new Set<string> ();
- List<string> types = new List<string> ();
+ var nss = new HashSet<string> ();
+ var types = new HashSet<string> ();
+ string namspacePrefix = namspace.Length > 0 ? namspace + "." : "";
foreach (Type t in GetAllTypes (ctx)) {
- if (t.Namespace == namspace)
+ if (t.Namespace == namspace || t.Namespace.StartsWith (namspacePrefix, StringComparison.InvariantCulture)) {
+ nss.Add (t.Namespace);
types.Add (t.FullName);
- else if (t.Namespace.StartsWith (namspace + ".", StringComparison.Ordinal)) {
- if (t.Namespace.IndexOf ('.', namspace.Length + 1) == -1)
- nss.Add (t.Namespace);
}
}
+
childNamespaces = new string[nss.Count];
- nss.CopyTo (childNamespaces, 0);
- childTypes = types.ToArray ();
+ nss.CopyTo (childNamespaces);
+
+ childTypes = new string [types.Count];
+ types.CopyTo (childTypes);
}
bool IsAssignableFrom (CorEvaluationContext ctx, Type baseType, CorType ctype)
@@ -517,7 +551,7 @@ namespace MonoDevelop.Debugger.Win32 if (tname == ctypeName)
return true;
- if (CorMetadataImport.CoreTypes.ContainsKey (ctype.Type))
+ if (MetadataHelperFunctionsExtensions.CoreTypes.ContainsKey (ctype.Type))
return false;
switch (ctype.Type) {
@@ -538,7 +572,7 @@ namespace MonoDevelop.Debugger.Win32 public override object TryCast (EvaluationContext ctx, object val, object type)
{
- CorType ctype = (CorType) GetValueType (ctx, val);
+ var ctype = (CorType) GetValueType (ctx, val);
CorValue obj = GetRealObject(ctx, val);
string tname = GetTypeName(ctx, type);
string ctypeName = GetValueTypeName (ctx, val);
@@ -554,26 +588,9 @@ namespace MonoDevelop.Debugger.Win32 if (obj is CorArrayValue)
return (ctypeName == tname || ctypeName == "System.Array") ? val : null;
- if (obj is CorObjectValue)
- {
- CorObjectValue co = (CorObjectValue)obj;
- if (IsEnum (ctx, co.ExactType)) {
- ValueReference rval = GetMember (ctx, null, val, "value__");
- return TryCast (ctx, rval.Value, type);
- }
-
- while (ctype != null)
- {
- if (GetTypeName(ctx, ctype) == tname)
- return val;
- ctype = ctype.Base;
- }
- return null;
- }
-
- CorGenericValue genVal = obj as CorGenericValue;
- if (genVal != null) {
- Type t = Type.GetType(tname);
+ var genVal = obj as CorGenericValue;
+ if (genVal != null) {
+ Type t = Type.GetType(tname);
try {
if (t != null && t.IsPrimitive && t != typeof (string)) {
object pval = genVal.GetValue ();
@@ -591,6 +608,23 @@ namespace MonoDevelop.Debugger.Win32 }
} catch {
}
+ }
+
+ if (obj is CorObjectValue)
+ {
+ var co = (CorObjectValue)obj;
+ if (IsEnum (ctx, co.ExactType)) {
+ ValueReference rval = GetMember (ctx, null, val, "value__");
+ return TryCast (ctx, rval.Value, type);
+ }
+
+ while (ctype != null)
+ {
+ if (GetTypeName(ctx, ctype) == tname)
+ return val;
+ ctype = ctype.Base;
+ }
+ return null;
}
return null;
}
@@ -604,8 +638,8 @@ namespace MonoDevelop.Debugger.Win32 {
object systemEnumType = GetType (ctx, "System.Enum");
object enumType = CreateTypeObject (ctx, type);
- object[] argTypes = new object[] { GetValueType (ctx, enumType), GetValueType (ctx, val) };
- object[] args = new object[] { enumType, val };
+ object[] argTypes = { GetValueType (ctx, enumType), GetValueType (ctx, val) };
+ object[] args = { enumType, val };
return RuntimeInvoke (ctx, systemEnumType, null, "ToObject", argTypes, args);
}
@@ -623,7 +657,7 @@ namespace MonoDevelop.Debugger.Win32 });
}
- foreach (KeyValuePair<CorElementType, Type> tt in CorMetadataImport.CoreTypes) {
+ foreach (KeyValuePair<CorElementType, Type> tt in MetadataHelperFunctionsExtensions.CoreTypes) {
if (tt.Value == value.GetType ()) {
CorValue val = ctx.Eval.CreateValue (tt.Key, null);
CorGenericValue gv = val.CastToGenericValue ();
@@ -631,7 +665,8 @@ namespace MonoDevelop.Debugger.Win32 return new CorValRef (val);
}
}
- throw new NotSupportedException ();
+ ctx.WriteDebuggerError (new NotSupportedException (String.Format ("Unable to create value for type: {0}", value.GetType ())));
+ return null;
}
public override object CreateValue (EvaluationContext ctx, object type, params object[] gargs)
@@ -678,9 +713,8 @@ namespace MonoDevelop.Debugger.Win32 CorValue val = CorObjectAdaptor.GetRealObject (ctx, arr);
if (val is CorArrayValue)
- return new ArrayAdaptor (ctx, (CorValRef) arr, (CorArrayValue) val);
- else
- return null;
+ return new ArrayAdaptor (ctx, (CorValRef)arr, (CorArrayValue)val);
+ return null;
}
public override IStringAdaptor CreateStringAdaptor (EvaluationContext ctx, object str)
@@ -688,9 +722,8 @@ namespace MonoDevelop.Debugger.Win32 CorValue val = CorObjectAdaptor.GetRealObject (ctx, str);
if (val is CorStringValue)
- return new StringAdaptor (ctx, (CorValRef) str, (CorStringValue) val);
- else
- return null;
+ return new StringAdaptor (ctx, (CorValRef)str, (CorStringValue)val);
+ return null;
}
public static CorValue GetRealObject (EvaluationContext cctx, object objr)
@@ -736,7 +769,7 @@ namespace MonoDevelop.Debugger.Win32 if (obj.ExactType.Type == CorElementType.ELEMENT_TYPE_STRING)
return obj.CastToStringValue ();
- if (CorMetadataImport.CoreTypes.ContainsKey (obj.Type)) {
+ if (MetadataHelperFunctionsExtensions.CoreTypes.ContainsKey (obj.Type)) {
CorGenericValue genVal = obj.CastToGenericValue ();
if (genVal != null)
return genVal;
@@ -830,7 +863,7 @@ namespace MonoDevelop.Debugger.Win32 catch {
// Ignore
}
- if (mi != null && mi.GetParameters ().Length > 0) {
+ if (mi != null && !mi.IsStatic && mi.GetParameters ().Length > 0) {
candidates.Add (mi);
props.Add (prop);
propTypes.Add (t);
@@ -841,6 +874,10 @@ namespace MonoDevelop.Debugger.Win32 MethodInfo idx = OverloadResolve (cctx, GetTypeName (ctx, targetType), null, types, candidates, true);
int i = candidates.IndexOf (idx);
+
+ if (props [i].GetGetMethod (true) == null)
+ return null;
+
return new PropertyReference (ctx, props[i], (CorValRef)target, propTypes[i], values);
}
@@ -874,19 +911,48 @@ namespace MonoDevelop.Debugger.Win32 protected override IEnumerable<ValueReference> GetMembers (EvaluationContext ctx, object tt, object gval, BindingFlags bindingFlags)
{
- CorType t = (CorType) tt;
- CorValRef val = (CorValRef) gval;
-
- if (t.Class == null)
+ var subProps = new Dictionary<string, PropertyInfo> ();
+ var t = (CorType) tt;
+ var val = (CorValRef) gval;
+ CorType realType = null;
+ if (gval != null && (bindingFlags & BindingFlags.Instance) != 0)
+ realType = GetValueType (ctx, gval) as CorType;
+
+ if (t.Type == CorElementType.ELEMENT_TYPE_CLASS && t.Class == null)
yield break;
CorEvaluationContext cctx = (CorEvaluationContext) ctx;
+ // First of all, get a list of properties overriden in sub-types
+ while (realType != null && realType != t) {
+ Type type = realType.GetTypeInfo (cctx.Session);
+ foreach (PropertyInfo prop in type.GetProperties (bindingFlags | BindingFlags.DeclaredOnly)) {
+ MethodInfo mi = prop.GetGetMethod (true);
+ if (mi == null || mi.GetParameters ().Length != 0 || mi.IsAbstract || !mi.IsVirtual || mi.IsStatic)
+ continue;
+ if (mi.IsPublic && ((bindingFlags & BindingFlags.Public) == 0))
+ continue;
+ if (!mi.IsPublic && ((bindingFlags & BindingFlags.NonPublic) == 0))
+ continue;
+ subProps [prop.Name] = prop;
+ }
+ realType = realType.Base;
+ }
+
while (t != null) {
Type type = t.GetTypeInfo (cctx.Session);
- foreach (FieldInfo field in type.GetFields (bindingFlags))
+ foreach (FieldInfo field in type.GetFields (bindingFlags)) {
+ if (field.IsStatic && ((bindingFlags & BindingFlags.Static) == 0))
+ continue;
+ if (!field.IsStatic && ((bindingFlags & BindingFlags.Instance) == 0))
+ continue;
+ if (field.IsPublic && ((bindingFlags & BindingFlags.Public) == 0))
+ continue;
+ if (!field.IsPublic && ((bindingFlags & BindingFlags.NonPublic) == 0))
+ continue;
yield return new FieldReference (ctx, val, t, field);
+ }
foreach (PropertyInfo prop in type.GetProperties (bindingFlags)) {
MethodInfo mi = null;
@@ -895,42 +961,190 @@ namespace MonoDevelop.Debugger.Win32 } catch {
// Ignore
}
- if (mi != null && mi.GetParameters ().Length == 0)
+ if (mi == null || mi.GetParameters ().Length != 0 || mi.IsAbstract)
+ continue;
+
+ if (mi.IsStatic && ((bindingFlags & BindingFlags.Static) == 0))
+ continue;
+ if (!mi.IsStatic && ((bindingFlags & BindingFlags.Instance) == 0))
+ continue;
+ if (mi.IsPublic && ((bindingFlags & BindingFlags.Public) == 0))
+ continue;
+ if (!mi.IsPublic && ((bindingFlags & BindingFlags.NonPublic) == 0))
+ continue;
+
+ // If a property is overriden, return the override instead of the base property
+ PropertyInfo overridden;
+ if (mi.IsVirtual && subProps.TryGetValue (prop.Name, out overridden)) {
+ mi = overridden.GetGetMethod (true);
+ if (mi == null)
+ continue;
+
+ var declaringType = GetType (ctx, overridden.DeclaringType.FullName) as CorType;
+ yield return new PropertyReference (ctx, overridden, val, declaringType);
+ } else {
yield return new PropertyReference (ctx, prop, val, t);
+ }
}
if ((bindingFlags & BindingFlags.DeclaredOnly) != 0)
break;
t = t.Base;
}
}
-
- public static string UnscapeString (string text)
+
+ static T FindByName<T> (IEnumerable<T> elems, Func<T,string> getName, string name, bool caseSensitive)
{
- StringBuilder sb = new StringBuilder ();
- for (int i = 0; i < text.Length; i++) {
- char c = text[i];
- if (c != '\\') {
- sb.Append (c);
- continue;
+ T best = default(T);
+ foreach (T t in elems) {
+ string n = getName (t);
+ if (n == name)
+ return t;
+ if (!caseSensitive && n.Equals (name, StringComparison.CurrentCultureIgnoreCase))
+ best = t;
+ }
+ return best;
+ }
+
+ static bool IsStatic (PropertyInfo prop)
+ {
+ MethodInfo met = prop.GetGetMethod (true) ?? prop.GetSetMethod (true);
+ return met.IsStatic;
+ }
+
+ static bool IsAnonymousType (Type type)
+ {
+ return type.Name.StartsWith ("<>__AnonType", StringComparison.Ordinal);
+ }
+
+ static bool IsCompilerGenerated (FieldInfo field)
+ {
+ return field.GetCustomAttributes (true).Any (v => v is System.Diagnostics.DebuggerHiddenAttribute);
+ }
+
+ protected override ValueReference GetMember (EvaluationContext ctx, object t, object co, string name)
+ {
+ var cctx = ctx as CorEvaluationContext;
+ var type = t as CorType;
+
+ while (type != null) {
+ var tt = type.GetTypeInfo (cctx.Session);
+ FieldInfo field = FindByName (tt.GetFields (), f => f.Name, name, ctx.CaseSensitive);
+ if (field != null && (field.IsStatic || co != null))
+ return new FieldReference (ctx, co as CorValRef, type, field);
+
+ PropertyInfo prop = FindByName (tt.GetProperties (), p => p.Name, name, ctx.CaseSensitive);
+ if (prop != null && (IsStatic (prop) || co != null)) {
+ // Optimization: if the property has a CompilerGenerated backing field, use that instead.
+ // This way we avoid overhead of invoking methods on the debugee when the value is requested.
+ string cgFieldName = string.Format ("<{0}>{1}", prop.Name, IsAnonymousType (tt) ? "" : "k__BackingField");
+ if ((field = FindByName (tt.GetFields (), f => f.Name, cgFieldName, true)) != null && IsCompilerGenerated (field))
+ return new FieldReference (ctx, co as CorValRef, type, field, prop.Name, ObjectValueFlags.Property);
+
+ // Backing field not available, so do things the old fashioned way.
+ MethodInfo getter = prop.GetGetMethod (true);
+ if (getter == null)
+ return null;
+
+ return new PropertyReference (ctx, prop, co as CorValRef, type);
}
- i++;
- if (i >= text.Length)
- return null;
-
- switch (text[i]) {
- case '\\': c = '\\'; break;
- case 'a': c = '\a'; break;
- case 'b': c = '\b'; break;
- case 'f': c = '\f'; break;
- case 'v': c = '\v'; break;
- case 'n': c = '\n'; break;
- case 'r': c = '\r'; break;
- case 't': c = '\t'; break;
- default: return null;
+
+ type = type.Base;
+ }
+
+ return null;
+ }
+
+ static bool IsIEnumerable (Type type)
+ {
+ if (type.Namespace == "System.Collections" && type.Name == "IEnumerable")
+ return true;
+
+ if (type.Namespace == "System.Collections.Generic" && type.Name == "IEnumerable`1")
+ return true;
+
+ return false;
+ }
+
+ static bool IsIEnumerable (CorType type, CorDebuggerSession session)
+ {
+ return IsIEnumerable (type.GetTypeInfo (session));
+ }
+
+ protected override CompletionData GetMemberCompletionData (EvaluationContext ctx, ValueReference vr)
+ {
+ var properties = new HashSet<string> ();
+ var methods = new HashSet<string> ();
+ var fields = new HashSet<string> ();
+ var data = new CompletionData ();
+ var type = vr.Type as CorType;
+ bool isEnumerable = false;
+ Type t;
+
+ var cctx = (CorEvaluationContext)ctx;
+ while (type != null) {
+ t = type.GetTypeInfo (cctx.Session);
+ if (!isEnumerable && IsIEnumerable (t))
+ isEnumerable = true;
+
+ foreach (var field in t.GetFields ()) {
+ if (field.IsStatic || field.IsSpecialName || !field.IsPublic)
+ continue;
+
+ if (fields.Add (field.Name))
+ data.Items.Add (new CompletionItem (field.Name, FieldReference.GetFlags (field)));
+ }
+
+ foreach (var property in t.GetProperties ()) {
+ var getter = property.GetGetMethod (true);
+
+ if (getter == null || getter.IsStatic || !getter.IsPublic)
+ continue;
+
+ if (properties.Add (property.Name))
+ data.Items.Add (new CompletionItem (property.Name, PropertyReference.GetFlags (property)));
+ }
+
+ foreach (var method in t.GetMethods ()) {
+ if (method.IsStatic || method.IsConstructor || method.IsSpecialName || !method.IsPublic)
+ continue;
+
+ if (methods.Add (method.Name))
+ data.Items.Add (new CompletionItem (method.Name, ObjectValueFlags.Method | ObjectValueFlags.Public));
+ }
+
+ if (t.BaseType == null && t.FullName != "System.Object")
+ type = ctx.Adapter.GetType (ctx, "System.Object") as CorType;
+ else
+ type = type.Base;
+ }
+
+ type = vr.Type as CorType;
+ t = type.GetTypeInfo (cctx.Session);
+ foreach (var iface in t.GetInterfaces ()) {
+ if (!isEnumerable && IsIEnumerable (iface)) {
+ isEnumerable = true;
+ break;
+ }
+ }
+
+ if (isEnumerable) {
+ // Look for LINQ extension methods...
+ var linq = ctx.Adapter.GetType (ctx, "System.Linq.Enumerable") as CorType;
+ if (linq != null) {
+ var linqt = linq.GetTypeInfo (cctx.Session);
+ foreach (var method in linqt.GetMethods ()) {
+ if (!method.IsStatic || method.IsConstructor || method.IsSpecialName || !method.IsPublic)
+ continue;
+
+ if (methods.Add (method.Name))
+ data.Items.Add (new CompletionItem (method.Name, ObjectValueFlags.Method | ObjectValueFlags.Public));
+ }
}
- sb.Append (c);
}
- return sb.ToString ();
+
+ data.ExpressionLength = 0;
+
+ return data;
}
public override object TargetObjectToObject (EvaluationContext ctx, object objr)
@@ -941,8 +1155,18 @@ namespace MonoDevelop.Debugger.Win32 return new EvaluationResult ("(null)");
CorStringValue stringVal = obj as CorStringValue;
- if (stringVal != null)
- return stringVal.String;
+ if (stringVal != null) {
+ string str;
+ if (ctx.Options.EllipsizeStrings) {
+ str = stringVal.String;
+ if (str.Length > ctx.Options.EllipsizedLength)
+ str = str.Substring (0, ctx.Options.EllipsizedLength) + EvaluationOptions.Ellipsis;
+ } else {
+ str = stringVal.String;
+ }
+ return str;
+
+ }
CorArrayValue arr = obj as CorArrayValue;
if (arr != null)
@@ -959,12 +1183,122 @@ namespace MonoDevelop.Debugger.Win32 return base.TargetObjectToObject (ctx, objr);
}
- protected override ValueReference OnGetThisReference (EvaluationContext gctx)
+ static bool InGeneratedClosureOrIteratorType (CorEvaluationContext ctx)
{
- CorEvaluationContext ctx = (CorEvaluationContext) gctx;
- if (ctx.Frame.FrameType != CorFrameType.ILFrame || ctx.Frame.Function == null)
+ MethodInfo mi = ctx.Frame.Function.GetMethodInfo (ctx.Session);
+ if (mi == null || mi.IsStatic)
+ return false;
+
+ Type tm = mi.DeclaringType;
+ return IsGeneratedType (tm);
+ }
+
+ internal static bool IsGeneratedType (string name)
+ {
+ //
+ // This should cover all C# generated special containers
+ // - anonymous methods
+ // - lambdas
+ // - iterators
+ // - async methods
+ //
+ // which allow stepping into
+ //
+
+ return name[0] == '<' &&
+ // mcs is of the form <${NAME}>.c__{KIND}${NUMBER}
+ (name.IndexOf (">c__", StringComparison.Ordinal) > 0 ||
+ // csc is of form <${NAME}>d__${NUMBER}
+ name.IndexOf (">d__", StringComparison.Ordinal) > 0);
+ }
+
+ internal static bool IsGeneratedType (Type tm)
+ {
+ return IsGeneratedType (tm.Name);
+ }
+
+ ValueReference GetHoistedThisReference (CorEvaluationContext cx)
+ {
+ try {
+ CorValRef vref = new CorValRef (delegate {
+ return cx.Frame.GetArgument (0);
+ });
+ var type = (CorType) GetValueType (cx, vref);
+ return GetHoistedThisReference (cx, type, vref);
+ } catch (Exception) {
+ }
+ return null;
+ }
+
+ ValueReference GetHoistedThisReference (CorEvaluationContext cx, CorType type, object val)
+ {
+ Type t = type.GetTypeInfo (cx.Session);
+ var vref = (CorValRef)val;
+ foreach (FieldInfo field in t.GetFields ()) {
+ if (IsHoistedThisReference (field))
+ return new FieldReference (cx, vref, type, field, "this", ObjectValueFlags.Literal);
+
+ if (IsClosureReferenceField (field)) {
+ var fieldRef = new FieldReference (cx, vref, type, field);
+ var fieldType = (CorType)GetValueType (cx, fieldRef.Value);
+ var thisRef = GetHoistedThisReference (cx, fieldType, fieldRef.Value);
+ if (thisRef != null)
+ return thisRef;
+ }
+ }
+
+ return null;
+ }
+
+ static bool IsHoistedThisReference (FieldInfo field)
+ {
+ // mcs is "<>f__this" or "$this" (if in an async compiler generated type)
+ // csc is "<>4__this"
+ return field.Name == "$this" ||
+ (field.Name.StartsWith ("<>", StringComparison.Ordinal) &&
+ field.Name.EndsWith ("__this", StringComparison.Ordinal));
+ }
+
+ static bool IsClosureReferenceField (FieldInfo field)
+ {
+ // mcs is "<>f__ref"
+ // csc is "CS$<>"
+ return field.Name.StartsWith ("CS$<>", StringComparison.Ordinal) ||
+ field.Name.StartsWith ("<>f__ref", StringComparison.Ordinal);
+ }
+
+ static bool IsClosureReferenceLocal (ISymbolVariable local)
+ {
+ if (local.Name == null)
+ return false;
+
+ // mcs is "$locvar" or starts with '<'
+ // csc is "CS$<>"
+ return local.Name.Length == 0 || local.Name[0] == '<' || local.Name.StartsWith ("$locvar", StringComparison.Ordinal) ||
+ local.Name.StartsWith ("CS$<>", StringComparison.Ordinal);
+ }
+
+ static bool IsGeneratedTemporaryLocal (ISymbolVariable local)
+ {
+ // csc uses CS$ prefix for temporary variables and <>t__ prefix for async task-related state variables
+ return local.Name != null && (local.Name.StartsWith ("CS$", StringComparison.Ordinal) || local.Name.StartsWith ("<>t__", StringComparison.Ordinal));
+ }
+
+ protected override ValueReference OnGetThisReference (EvaluationContext ctx)
+ {
+ CorEvaluationContext cctx = (CorEvaluationContext) ctx;
+ if (cctx.Frame.FrameType != CorFrameType.ILFrame || cctx.Frame.Function == null)
return null;
+ if (InGeneratedClosureOrIteratorType (cctx))
+ return GetHoistedThisReference (cctx);
+
+ return GetThisReference (cctx);
+
+ }
+
+ ValueReference GetThisReference (CorEvaluationContext ctx)
+ {
MethodInfo mi = ctx.Frame.Function.GetMethodInfo (ctx.Session);
if (mi == null || mi.IsStatic)
return null;
@@ -976,7 +1310,7 @@ namespace MonoDevelop.Debugger.Win32 return new VariableReference (ctx, vref, "this", ObjectValueFlags.Variable | ObjectValueFlags.ReadOnly);
} catch (Exception e) {
- gctx.WriteDebuggerError (e);
+ ctx.WriteDebuggerError (e);
return null;
}
}
@@ -1009,7 +1343,7 @@ namespace MonoDevelop.Debugger.Win32 int count = ctx.Frame.GetArgumentCount ();
for (int n = 0; n < count; n++) {
int locn = n;
- CorValRef vref = new CorValRef (delegate {
+ var vref = new CorValRef (delegate {
return ctx.Frame.GetArgument (locn);
});
yield return new VariableReference (ctx, vref, "arg_" + (n + 1), ObjectValueFlags.Parameter);
@@ -1018,14 +1352,76 @@ namespace MonoDevelop.Debugger.Win32 protected override IEnumerable<ValueReference> OnGetLocalVariables (EvaluationContext ctx)
{
- CorEvaluationContext wctx = (CorEvaluationContext) ctx;
+ CorEvaluationContext cctx = (CorEvaluationContext)ctx;
+ if (InGeneratedClosureOrIteratorType (cctx)) {
+ ValueReference vthis = GetThisReference (cctx);
+ return GetHoistedLocalVariables (cctx, vthis).Union (GetLocalVariables (cctx));
+ }
+
+ return GetLocalVariables (cctx);
+ }
+
+ IEnumerable<ValueReference> GetHoistedLocalVariables (CorEvaluationContext cx, ValueReference vthis)
+ {
+ if (vthis == null)
+ return new ValueReference [0];
+
+ object val = vthis.Value;
+ if (IsNull (cx, val))
+ return new ValueReference [0];
+
+ CorType tm = (CorType) vthis.Type;
+ Type t = tm.GetTypeInfo (cx.Session);
+ bool isIterator = IsGeneratedType (t);
+
+ var list = new List<ValueReference> ();
+ foreach (FieldInfo field in t.GetFields ()) {
+ if (IsHoistedThisReference (field))
+ continue;
+ if (IsClosureReferenceField (field)) {
+ list.AddRange (GetHoistedLocalVariables (cx, new FieldReference (cx, (CorValRef)val, tm, field)));
+ continue;
+ }
+ if (field.Name[0] == '<') {
+ if (isIterator) {
+ var name = GetHoistedIteratorLocalName (field);
+ if (!string.IsNullOrEmpty (name)) {
+ list.Add (new FieldReference (cx, (CorValRef)val, tm, field, name, ObjectValueFlags.Variable));
+ }
+ }
+ } else if (!field.Name.Contains ("$")) {
+ list.Add (new FieldReference (cx, (CorValRef)val, tm, field, field.Name, ObjectValueFlags.Variable));
+ }
+ }
+ return list;
+ }
+
+ static string GetHoistedIteratorLocalName (FieldInfo field)
+ {
+ //mcs captured args, of form <$>name
+ if (field.Name.StartsWith ("<$>", StringComparison.Ordinal)) {
+ return field.Name.Substring (3);
+ }
+
+ // csc, mcs locals of form <name>__0
+ if (field.Name[0] == '<') {
+ int i = field.Name.IndexOf ('>');
+ if (i > 1) {
+ return field.Name.Substring (1, i - 1);
+ }
+ }
+ return null;
+ }
+
+ IEnumerable<ValueReference> GetLocalVariables (CorEvaluationContext cx)
+ {
uint offset;
CorDebugMappingResult mr;
try {
- wctx.Frame.GetIP (out offset, out mr);
- return GetLocals (wctx, null, (int) offset, false);
+ cx.Frame.GetIP (out offset, out mr);
+ return GetLocals (cx, null, (int) offset, false);
} catch (Exception e) {
- ctx.WriteDebuggerError (e);
+ cx.WriteDebuggerError (e);
return null;
}
}
@@ -1078,9 +1474,18 @@ namespace MonoDevelop.Debugger.Win32 foreach (ISymbolVariable var in scope.GetLocals ()) {
if (var.Name == "$site")
continue;
- if (var.Name.IndexOfAny(new char[] {'$','<','>'}) == -1 || showHidden) {
+ if (IsClosureReferenceLocal (var) && IsGeneratedType (var.Name)) {
int addr = var.AddressField1;
- CorValRef vref = new CorValRef (delegate {
+ var vref = new CorValRef (delegate {
+ return ctx.Frame.GetLocalVariable (addr);
+ });
+
+ foreach (var gv in GetHoistedLocalVariables (ctx, new VariableReference (ctx, vref, var.Name, ObjectValueFlags.Variable))) {
+ yield return gv;
+ }
+ } else if (!IsGeneratedTemporaryLocal (var) || showHidden) {
+ int addr = var.AddressField1;
+ var vref = new CorValRef (delegate {
return ctx.Frame.GetLocalVariable (addr);
});
yield return new VariableReference (ctx, vref, var.Name, ObjectValueFlags.Variable);
@@ -1097,21 +1502,20 @@ namespace MonoDevelop.Debugger.Win32 protected override TypeDisplayData OnGetTypeDisplayData (EvaluationContext ctx, object gtype)
{
- CorType type = (CorType) gtype;
+ var type = (CorType) gtype;
- CorEvaluationContext wctx = (CorEvaluationContext) ctx;
+ var wctx = (CorEvaluationContext) ctx;
Type t = type.GetTypeInfo (wctx.Session);
if (t == null)
return null;
- // FIXME: find out how to implement CompilerGenerated.
- //bool isCompilerGenerated = false;
string proxyType = null;
string nameDisplayString = null;
string typeDisplayString = null;
string valueDisplayString = null;
Dictionary<string, DebuggerBrowsableState> memberData = null;
bool hasTypeData = false;
+ bool isCompilerGenerated = false;
try {
foreach (object att in t.GetCustomAttributes (false)) {
@@ -1129,6 +1533,11 @@ namespace MonoDevelop.Debugger.Win32 valueDisplayString = datt.Value;
continue;
}
+ CompilerGeneratedAttribute cgatt = att as CompilerGeneratedAttribute;
+ if (cgatt != null) {
+ isCompilerGenerated = true;
+ continue;
+ }
}
ArrayList mems = new ArrayList ();
@@ -1138,13 +1547,14 @@ namespace MonoDevelop.Debugger.Win32 foreach (MemberInfo m in mems) {
object[] atts = m.GetCustomAttributes (typeof (DebuggerBrowsableAttribute), false);
if (atts.Length == 0) {
- atts = m.GetCustomAttributes (typeof (System.Runtime.CompilerServices.CompilerGeneratedAttribute), false);
+ atts = m.GetCustomAttributes (typeof (CompilerGeneratedAttribute), false);
if (atts.Length > 0)
atts[0] = new DebuggerBrowsableAttribute (DebuggerBrowsableState.Never);
}
if (atts.Length > 0) {
hasTypeData = true;
- if (memberData == null) memberData = new Dictionary<string, DebuggerBrowsableState> ();
+ if (memberData == null)
+ memberData = new Dictionary<string, DebuggerBrowsableState> ();
memberData[m.Name] = ((DebuggerBrowsableAttribute)atts[0]).State;
}
}
@@ -1152,9 +1562,33 @@ namespace MonoDevelop.Debugger.Win32 ctx.WriteDebuggerError (ex);
}
if (hasTypeData)
- return new TypeDisplayData (proxyType, valueDisplayString, typeDisplayString, nameDisplayString, false, memberData);
+ return new TypeDisplayData (proxyType, valueDisplayString, typeDisplayString, nameDisplayString, isCompilerGenerated, memberData);
else
return null;
}
+
+ // TODO: implement in metadatatype
+ public override IEnumerable<object> GetNestedTypes (EvaluationContext ctx, object type)
+ {
+ return base.GetNestedTypes (ctx, type);
+ }
+
+ // TODO: implement for session
+ public override bool IsExternalType (EvaluationContext ctx, object type)
+ {
+ return base.IsExternalType (ctx, type);
+ }
+
+ public override bool IsTypeLoaded (EvaluationContext ctx, string typeName)
+ {
+ return ctx.Adapter.GetType (ctx, typeName) != null;
+ }
+
+ public override bool IsTypeLoaded (EvaluationContext ctx, object type)
+ {
+ var t = type as Type;
+ return IsTypeLoaded (ctx, t.FullName);
+ }
+ // TODO: Implement GetHoistedLocalVariables
}
}
diff --git a/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/FieldReference.cs b/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/FieldReference.cs index 28018951da..b9db438de8 100644 --- a/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/FieldReference.cs +++ b/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/FieldReference.cs @@ -38,20 +38,29 @@ namespace MonoDevelop.Debugger.Win32 readonly FieldInfo field; readonly CorValRef thisobj; readonly CorValRef.ValueLoader loader; + readonly ObjectValueFlags flags; + readonly string vname; - public FieldReference (EvaluationContext ctx, CorValRef thisobj, CorType type, FieldInfo field) - : base (ctx) + public FieldReference (EvaluationContext ctx, CorValRef thisobj, CorType type, FieldInfo field, string vname, ObjectValueFlags vflags) : base (ctx) { this.thisobj = thisobj; this.type = type; this.field = field; + this.vname = vname; if (field.IsStatic) this.thisobj = null; + flags = vflags | GetFlags (field); + loader = delegate { return ((CorValRef)Value).Val; }; } + + public FieldReference (EvaluationContext ctx, CorValRef thisobj, CorType type, FieldInfo field) + : this (ctx, thisobj, type, field, null, ObjectValueFlags.Field) + { + } public override object Type { get { @@ -75,25 +84,33 @@ namespace MonoDevelop.Debugger.Win32 public override object Value { get { - CorEvaluationContext ctx = (CorEvaluationContext) Context; - if (thisobj != null && !field.IsStatic) { - CorObjectValue cval = (CorObjectValue) CorObjectAdaptor.GetRealObject (ctx, thisobj); - CorValue val = cval.GetFieldValue (type.Class, field.MetadataToken); - return new CorValRef (val, loader); - } - else { - if (field.IsLiteral && field.IsStatic) { - object oval = field.GetValue (null); - CorObjectAdaptor ad = ctx.Adapter; - // When getting enum members, convert the integer value to an enum value - if (ad.IsEnum (ctx, type)) - return ad.CreateEnum (ctx, type, Context.Adapter.CreateValue (ctx, oval)); - - return Context.Adapter.CreateValue (ctx, oval); + var ctx = (CorEvaluationContext) Context; + CorValue val; + if (thisobj != null && !field.IsStatic) {
+ CorObjectValue cval; + val = CorObjectAdaptor.GetRealObject (ctx, thisobj); + if (val is CorObjectValue) { + cval = (CorObjectValue)val; + val = cval.GetFieldValue (type.Class, field.MetadataToken); + return new CorValRef (val, loader); + } + if (val is CorReferenceValue) { + CorReferenceValue rval = (CorReferenceValue)val; + return new CorValRef (rval, loader); } - CorValue val = type.GetStaticFieldValue (field.MetadataToken, ctx.Frame); - return new CorValRef (val, loader); } + + if (field.IsLiteral && field.IsStatic) { + object oval = field.GetValue (null); + CorObjectAdaptor ad = ctx.Adapter; + // When getting enum members, convert the integer value to an enum value + if (ad.IsEnum (ctx, type)) + return ad.CreateEnum (ctx, type, Context.Adapter.CreateValue (ctx, oval)); + + return Context.Adapter.CreateValue (ctx, oval); + } + val = type.GetStaticFieldValue (field.MetadataToken, ctx.Frame); + return new CorValRef (val, loader); } set { ((CorValRef)Value).SetValue (Context, (CorValRef) value); @@ -108,33 +125,38 @@ namespace MonoDevelop.Debugger.Win32 public override string Name { get { - return field.Name; + return vname ?? field.Name; } } public override ObjectValueFlags Flags { get { - ObjectValueFlags flags = ObjectValueFlags.Field; + return flags; + } + } - if (field.IsStatic) - flags |= ObjectValueFlags.Global; + internal static ObjectValueFlags GetFlags (FieldInfo field) + { + ObjectValueFlags flags = ObjectValueFlags.Field; - if (field.IsFamilyOrAssembly) - flags |= ObjectValueFlags.InternalProtected; - else if (field.IsFamilyAndAssembly) - flags |= ObjectValueFlags.Internal; - else if (field.IsFamily) - flags |= ObjectValueFlags.Protected; - else if (field.IsPublic) - flags |= ObjectValueFlags.Public; - else - flags |= ObjectValueFlags.Private; + if (field.IsStatic) + flags |= ObjectValueFlags.Global; - if (field.IsLiteral) - flags |= ObjectValueFlags.ReadOnly; + if (field.IsFamilyOrAssembly) + flags |= ObjectValueFlags.InternalProtected; + else if (field.IsFamilyAndAssembly) + flags |= ObjectValueFlags.Internal; + else if (field.IsFamily) + flags |= ObjectValueFlags.Protected; + else if (field.IsPublic) + flags |= ObjectValueFlags.Public; + else + flags |= ObjectValueFlags.Private; - return flags; - } + if (field.IsLiteral) + flags |= ObjectValueFlags.ReadOnly; + + return flags; } } } diff --git a/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32.addin.xml b/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32.addin.xml index d4ebadd769..5b88b4b560 100644 --- a/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32.addin.xml +++ b/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32.addin.xml @@ -1,18 +1,4 @@ -<Addin id = "MonoDevelop.Debugger.Win32" - name = "Microsoft .NET support for Mono.Debugging" - author = "Lluis Sanchez" - url = "http://www.mono-project.com" - description = "Managed Debugging Engine support for MS.NET" - copyright = "MIT X11" - category = "Debugging" - version = "4.2.3"> - - <Dependencies> - <Addin id="MonoDevelop.Core" version="4.2.3"/> - <Addin id="MonoDevelop.Ide" version="4.2.3"/> - <Addin id="MonoDevelop.Debugger" version="4.2.3"/> - <Addin id="MonoDevelop.AspNet" version="4.2.3"/> - </Dependencies> +<ExtensionModel> <Extension path="/MonoDevelop/Debugging/DebuggerEngines"> <DebuggerEngine @@ -22,4 +8,4 @@ type="MonoDevelop.Debugger.Win32.CorDebuggerEngine" /> </Extension> -</Addin> +</ExtensionModel> diff --git a/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32.csproj b/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32.csproj index d3d5a011c0..933c6f829b 100644 --- a/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32.csproj +++ b/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32.csproj @@ -88,6 +88,7 @@ <Compile Include="CorDebuggerSession.cs" /> <Compile Include="CorEvaluationContext.cs" /> <Compile Include="CorDebuggerBacktrace.cs" /> + <Compile Include="AddinInfo.cs" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="MonoDevelop.Debugger.Win32.addin.xml" /> @@ -126,6 +127,11 @@ <Name>MonoDevelop.Ide</Name> <Private>False</Private> </ProjectReference> + <ProjectReference Include="..\..\..\..\external\mono-addins\Mono.Addins\Mono.Addins.csproj"> + <Project>{91DD5A2D-9FE3-4C3C-9253-876141874DAD}</Project> + <Name>Mono.Addins</Name> + <Private>False</Private> + </ProjectReference> </ItemGroup> <ItemGroup> <BootstrapperPackage Include="Microsoft.Net.Client.3.5"> diff --git a/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/PropertyReference.cs b/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/PropertyReference.cs index e9ea4682ff..93fd50c4f5 100644 --- a/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/PropertyReference.cs +++ b/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/PropertyReference.cs @@ -40,6 +40,7 @@ namespace MonoDevelop.Debugger.Win32 readonly CorModule module; readonly CorType declaringType; readonly CorValRef.ValueLoader loader; + readonly ObjectValueFlags flags; CorValRef cachedValue; public PropertyReference (EvaluationContext ctx, PropertyInfo prop, CorValRef thisobj, CorType declaringType) @@ -57,6 +58,8 @@ namespace MonoDevelop.Debugger.Win32 if (!prop.GetGetMethod (true).IsStatic) this.thisobj = thisobj; + flags = GetFlags (prop); + loader = delegate { return ((CorValRef)Value).Val; }; @@ -134,31 +137,36 @@ namespace MonoDevelop.Debugger.Win32 } } - public override ObjectValueFlags Flags { - get { - ObjectValueFlags flags = ObjectValueFlags.Property; - MethodInfo mi = prop.GetGetMethod () ?? prop.GetSetMethod (); + internal static ObjectValueFlags GetFlags (PropertyInfo prop) + { + ObjectValueFlags flags = ObjectValueFlags.Property; + MethodInfo mi = prop.GetGetMethod () ?? prop.GetSetMethod (); - if (prop.GetSetMethod (true) == null) - flags |= ObjectValueFlags.ReadOnly; + if (prop.GetSetMethod (true) == null) + flags |= ObjectValueFlags.ReadOnly; - if (mi.IsStatic) - flags |= ObjectValueFlags.Global; + if (mi.IsStatic) + flags |= ObjectValueFlags.Global; - if (mi.IsFamilyAndAssembly) - flags |= ObjectValueFlags.Internal; - else if (mi.IsFamilyOrAssembly) - flags |= ObjectValueFlags.InternalProtected; - else if (mi.IsFamily) - flags |= ObjectValueFlags.Protected; - else if (mi.IsPublic) - flags |= ObjectValueFlags.Public; - else - flags |= ObjectValueFlags.Private; + if (mi.IsFamilyAndAssembly) + flags |= ObjectValueFlags.Internal; + else if (mi.IsFamilyOrAssembly) + flags |= ObjectValueFlags.InternalProtected; + else if (mi.IsFamily) + flags |= ObjectValueFlags.Protected; + else if (mi.IsPublic) + flags |= ObjectValueFlags.Public; + else + flags |= ObjectValueFlags.Private; - if (!prop.CanWrite) - flags |= ObjectValueFlags.ReadOnly; + if (!prop.CanWrite) + flags |= ObjectValueFlags.ReadOnly; + return flags; + } + + public override ObjectValueFlags Flags { + get { return flags; } } diff --git a/main/src/addins/MonoDevelop.Debugger.Win32/README.txt b/main/src/addins/MonoDevelop.Debugger.Win32/README.txt index a72ceb44c9..db84fb29a5 100644 --- a/main/src/addins/MonoDevelop.Debugger.Win32/README.txt +++ b/main/src/addins/MonoDevelop.Debugger.Win32/README.txt @@ -1,9 +1,6 @@ CorApi and CorApi2 are samples taken from http://www.microsoft.com/en-us/download/details.aspx?id=19621 with our own API changes added to it. -API changes are to be marked with [Xamarin] tags. +Most sample changes are to be marked with [Xamarin] tags. *For additions of properties or changes to existing properties, apply the tag to the property explaining the fix applied. -API changes are to be done with tabs as it's easier to differentiate between their code and our code. - -Post-update API changes can be applied with this commit: -5056a6ade8e0d0e8398c13dcbba734ea25419b87 +Most changes in samples are implementations of NotImplementedException or use of Extension code. diff --git a/main/src/addins/MonoDevelop.Debugger/AddinInfo.cs b/main/src/addins/MonoDevelop.Debugger/AddinInfo.cs new file mode 100644 index 0000000000..d1fa007c22 --- /dev/null +++ b/main/src/addins/MonoDevelop.Debugger/AddinInfo.cs @@ -0,0 +1,16 @@ + +using System; +using Mono.Addins; +using Mono.Addins.Description; + +[assembly:Addin ("Debugger", + Namespace = "MonoDevelop", + Version = MonoDevelop.BuildInfo.Version, + Category = "Debugging")] + +[assembly:AddinName ("Debugger support for MonoDevelop")] +[assembly:AddinDescription ("Support for Debugging projects")] +[assembly:AddinFlags (AddinFlags.Hidden)] + +[assembly:AddinDependency ("Core", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("Ide", MonoDevelop.BuildInfo.Version)] diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.addin.xml b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.addin.xml index 29c2e02d70..dfeef727c0 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.addin.xml +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.addin.xml @@ -1,17 +1,4 @@ -<Addin id = "Debugger" - namespace = "MonoDevelop" - name = "Debugger support for MonoDevelop" - author = "Ankit Jain, Lluis Sanchez" - url = "http://www.monodevelop.com" - description = "Support for Debugging projects" - copyright = "MIT X11" - flags = "Hidden" - version = "4.2.3"> - - <Dependencies> - <Addin id="Core" version="4.2.3"/> - <Addin id="Ide" version="4.2.3"/> - </Dependencies> +<ExtensionModel> <ExtensionPoint path="/MonoDevelop/Debugging/DebuggerEngines"> <Description>Debug session factories. Specified classes must implement MonoDevelop.Debugger.IDebuggerEngine</Description> @@ -249,4 +236,5 @@ <Extension path = "/MonoDevelop/Ide/TextEditorExtensions"> <Class class="MonoDevelop.Debugger.ExceptionCaughtTextEditorExtension" /> </Extension> -</Addin> +</ExtensionModel> + diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.csproj b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.csproj index 484057ea6a..31a71ef1a9 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.csproj +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.csproj @@ -149,6 +149,7 @@ <Compile Include="MonoDevelop.Debugger.Visualizer\CStringVisualizer.cs" /> <Compile Include="MonoDevelop.Debugger.Visualizer\ValueVisualizer.cs" /> <Compile Include="MonoDevelop.Debugger\InfoFrame.cs" /> + <Compile Include="AddinInfo.cs" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="MonoDevelop.Debugger.addin.xml"> diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValueTreeView.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValueTreeView.cs index 4272b287cd..e90e9d049b 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValueTreeView.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValueTreeView.cs @@ -1406,21 +1406,25 @@ namespace MonoDevelop.Debugger } } } - + [CommandHandler (DebugCommands.AddWatch)] protected void OnAddWatch () { - List<string> exps = new List<string> (); + var expressions = new List<string> (); + foreach (TreePath tp in Selection.GetSelectedRows ()) { TreeIter it; + if (store.GetIter (out it, tp)) { - string exp = GetFullExpression (it); - exps.Add (exp); + var expression = GetFullExpression (it); + + if (!string.IsNullOrEmpty (expression)) + expressions.Add (expression); } } - foreach (string s in exps) { - DebuggingService.AddWatch (s); - } + + foreach (string expr in expressions) + DebuggingService.AddWatch (expr); } [CommandUpdateHandler (DebugCommands.AddWatch)] @@ -1484,41 +1488,50 @@ namespace MonoDevelop.Debugger string GetFullExpression (TreeIter it) { TreePath path = store.GetPath (it); - string exp = ""; + string name, expression = ""; while (path.Depth != 1) { - ObjectValue val = (ObjectValue)store.GetValue (it, ObjectColumn); - exp = val.ChildSelector + exp; + var val = (ObjectValue) store.GetValue (it, ObjectColumn); + if (val == null) + return null; + + expression = val.ChildSelector + expression; if (!store.IterParent (out it, it)) break; + path = store.GetPath (it); } - string name = (string) store.GetValue (it, NameColumn); + name = (string) store.GetValue (it, NameColumn); - return name + exp; + return name + expression; } public void CreatePinnedWatch (TreeIter it) { - string exp = GetFullExpression (it); - - PinnedWatch watch = new PinnedWatch (); + var expression = GetFullExpression (it); + + if (string.IsNullOrEmpty (expression)) + return; + + var watch = new PinnedWatch (); + if (PinnedWatch != null) { CollapseAll (); watch.File = PinnedWatch.File; watch.Line = PinnedWatch.Line; watch.OffsetX = PinnedWatch.OffsetX; watch.OffsetY = PinnedWatch.OffsetY + SizeRequest ().Height + 5; - } - else { + } else { watch.File = PinnedWatchFile; watch.Line = PinnedWatchLine; watch.OffsetX = -1; // means that the watch should be placed at the line coordinates defined by watch.Line watch.OffsetY = -1; } - watch.Expression = exp; + + watch.Expression = expression; DebuggingService.PinnedWatches.Add (watch); + if (PinStatusChanged != null) PinStatusChanged (this, EventArgs.Empty); } diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/PinnedWatch.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/PinnedWatch.cs index e288e6b46b..679d5f4d0f 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/PinnedWatch.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/PinnedWatch.cs @@ -23,6 +23,7 @@ // LIABILITY, WHETHER IN AN ACTION 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.Debugging.Client; using MonoDevelop.Core; @@ -53,7 +54,6 @@ namespace MonoDevelop.Debugger bool liveUpdate; ObjectValue value; - PinnedWatchStore store; bool evaluated; internal Breakpoint BoundTracer; @@ -63,8 +63,7 @@ namespace MonoDevelop.Debugger } internal PinnedWatchStore Store { - get { return this.store; } - set { this.store = value; } + get; set; } internal void Evaluate (bool notify) @@ -100,33 +99,33 @@ namespace MonoDevelop.Debugger } public FilePath File { - get { return this.file; } - set { this.file = value; NotifyChanged (); } + get { return file; } + set { file = value; NotifyChanged (); } } public bool LiveUpdate { - get { return this.liveUpdate; } - internal set { this.liveUpdate = value; } + get { return liveUpdate; } + internal set { liveUpdate = value; } } public int Line { - get { return this.line; } - set { this.line = value; NotifyChanged (); } + get { return line; } + set { line = value; NotifyChanged (); } } public int OffsetX { - get { return this.offsetX; } - set { this.offsetX = value; NotifyChanged (); } + get { return offsetX; } + set { offsetX = value; NotifyChanged (); } } public int OffsetY { - get { return this.offsetY; } - set { this.offsetY = value; NotifyChanged (); } + get { return offsetY; } + set { offsetY = value; NotifyChanged (); } } internal void LoadValue (ObjectValue val) { - this.value = val; + value = val; value.Name = expression; evaluated = true; } @@ -146,7 +145,7 @@ namespace MonoDevelop.Debugger } public string Expression { - get { return this.expression; } + get { return expression; } set { if (expression != value) { evaluated = false; @@ -158,8 +157,8 @@ namespace MonoDevelop.Debugger void NotifyChanged () { - if (store != null) - store.NotifyWatchChanged (this); + if (Store != null) + Store.NotifyWatchChanged (this); } } } diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/PinnedWatchStore.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/PinnedWatchStore.cs index 2cf8a54849..b040e0ffa9 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/PinnedWatchStore.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/PinnedWatchStore.cs @@ -306,7 +306,7 @@ namespace MonoDevelop.Debugger } public PinnedWatch Watch { - get { return this.watch; } + get { return watch; } } } } diff --git a/main/src/addins/MonoDevelop.GtkCore/AddinInfo.cs b/main/src/addins/MonoDevelop.GtkCore/AddinInfo.cs new file mode 100644 index 0000000000..904938eb23 --- /dev/null +++ b/main/src/addins/MonoDevelop.GtkCore/AddinInfo.cs @@ -0,0 +1,16 @@ + +using System; +using Mono.Addins; +using Mono.Addins.Description; + +[assembly:Addin ("GtkCore", + Namespace = "MonoDevelop", + Version = MonoDevelop.BuildInfo.Version, + Category = "IDE extensions")] + +[assembly:AddinName ("GTK# Visual Designer")] +[assembly:AddinDescription ("Provides support for visual design of GTK# windows, dialogs and widgets")] + +[assembly:AddinDependency ("Core", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("Ide", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("DesignerSupport", MonoDevelop.BuildInfo.Version)] diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.addin.xml b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.addin.xml index 3508bc8d18..8cf80f0493 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.addin.xml +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.addin.xml @@ -1,12 +1,4 @@ -<Addin id = "GtkCore" - namespace = "MonoDevelop" - name = "GTK# Visual Designer" - author = "Lluis Sanchez Gual" - copyright = "X11" - url = "" - description = "Provides support for visual design of GTK# windows, dialogs and widgets." - category = "IDE extensions" - version = "4.2.3"> +<ExtensionModel> <Runtime> <Import assembly="libstetic.dll"/> @@ -16,12 +8,6 @@ <Import assembly="MonoDevelop.GtkCore.dll"/> </Runtime> - <Dependencies> - <Addin id="Core" version="4.2.3"/> - <Addin id="Ide" version="4.2.3"/> - <Addin id="DesignerSupport" version="4.2.3"/> - </Dependencies> - <ExtensionPoint path = "/MonoDevelop/GtkCore/ContextMenu/ProjectPad.ActionGroup"> <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> </ExtensionPoint> @@ -183,4 +169,5 @@ <Extension path = "/MonoDevelop/Ide/GlobalOptionsDialog/Projects"> <Panel _label = "GTK# Designer" class = "MonoDevelop.GtkCore.Dialogs.GtkDesignerOptionPanel" /> </Extension> -</Addin> + +</ExtensionModel> diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.csproj b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.csproj index c1c298c822..cc0b54010e 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.csproj +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.csproj @@ -211,6 +211,7 @@ <Compile Include="MonoDevelop.GtkCore.Dialogs\GtkDesignerOptionsPanelWidget.cs" /> <Compile Include="gtk-gui\MonoDevelop.GtkCore.Dialogs.GtkDesignerOptionsPanelWidget.cs" /> <Compile Include="MonoDevelop.GtkCore\Counters.cs" /> + <Compile Include="AddinInfo.cs" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> </Project> diff --git a/main/src/addins/MonoDevelop.GtkCore/libsteticui/Application.cs b/main/src/addins/MonoDevelop.GtkCore/libsteticui/Application.cs index 94d009f8fe..b8ee8d274a 100644 --- a/main/src/addins/MonoDevelop.GtkCore/libsteticui/Application.cs +++ b/main/src/addins/MonoDevelop.GtkCore/libsteticui/Application.cs @@ -388,9 +388,15 @@ namespace Stetic foreach (SteticCompilationUnit unit in res.Units) { string fname; - if (unit.Name.Length == 0) + if (unit.Name.Length == 0) { + if (provider is Microsoft.CSharp.CSharpCodeProvider && unit.Namespaces.Count > 0) { + var types = unit.Namespaces [0].Types; + if (types.Count > 0) { + types [0].Members.Insert (0, new CodeSnippetTypeMember ("#pragma warning disable 436")); + } + } fname = file; - else + } else fname = Path.Combine (basePath, unit.Name) + ext; files.Add (fname); unit.Name = fname; diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/FindDerivedSymbolsHandler.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/FindDerivedSymbolsHandler.cs index c39056be1c..39c62af565 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/FindDerivedSymbolsHandler.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/FindDerivedSymbolsHandler.cs @@ -41,27 +41,34 @@ namespace MonoDevelop.Refactoring { class FindDerivedSymbolsHandler { - //Ide.Gui.Document doc; + Ide.Gui.Document doc; readonly IMember entity; public FindDerivedSymbolsHandler (Ide.Gui.Document doc, IMember entity) { - //this.doc = doc; + this.doc = doc; this.entity = entity; } - Task<HashSet<IAssembly>> GetAllAssemblies () + static bool IsReferenced (Project project, Project referencedProject) + { + return project == referencedProject || + project.GetReferencedItems (IdeApp.Workspace.ActiveConfiguration).Contains (referencedProject); + } + + Task<HashSet<IAssembly>> GetAllAssemblies (Project referencedProject) { var solution = IdeApp.ProjectOperations.CurrentSelectedSolution; return Task.Factory.StartNew (delegate { var assemblies = new HashSet<IAssembly> (); foreach (var project in solution.GetAllProjects ()) { + if (!IsReferenced (project, referencedProject)) + continue; var comp = TypeSystemService.GetCompilation (project); if (comp == null) continue; - foreach (var asm in comp.Assemblies) - assemblies.Add (asm); + assemblies.Add (comp.MainAssembly); } return assemblies; }); @@ -75,7 +82,7 @@ namespace MonoDevelop.Refactoring public void Run () { - var assemblies = GetAllAssemblies (); + var assemblies = GetAllAssemblies (doc.Project); assemblies.ContinueWith (delegate(Task<HashSet<IAssembly>> arg) { using (var monitor = IdeApp.Workbench.ProgressMonitors.GetSearchProgressMonitor (true, true)) { monitor.BeginTask (GettextCatalog.GetString ("Building type graph in solution ..."), 1); diff --git a/main/src/addins/MonoDevelop.SourceEditor2/AssemblyInfo.cs b/main/src/addins/MonoDevelop.SourceEditor2/AssemblyInfo.cs index f5414c4362..f9f893a74a 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/AssemblyInfo.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/AssemblyInfo.cs @@ -1,8 +1,10 @@ // Autogenerated from MonoDevelop.SourceEditor.addin.xml using System.Reflection; +using System.Runtime.CompilerServices; [assembly: AssemblyProduct ("MonoDevelop")] [assembly: AssemblyTitle ("MonoDevelop Source Editor")] [assembly: AssemblyDescription ("Provides a text editor for the MonoDevelop based on Mono.TextEditor")] [assembly: AssemblyVersion ("2.6")] +[assembly: InternalsVisibleTo("UnitTests")] diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.JSon/JSonIndentEngine.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.JSon/JSonIndentEngine.cs new file mode 100644 index 0000000000..18be36da2b --- /dev/null +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.JSon/JSonIndentEngine.cs @@ -0,0 +1,295 @@ +// +// JSonTextEditorExtension.cs +// +// Author: +// Mike Krüger <mkrueger@xamarin.com> +// +// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION 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 ICSharpCode.NRefactory.CSharp; +using Mono.TextEditor; +using System.Text; +using ICSharpCode.NRefactory; + +namespace MonoDevelop.SourceEditor.JSon +{ + class JSonIndentEngine : IStateMachineIndentEngine + { + TextEditorData data; + int offset, line, column; + internal Indent thisLineIndent, nextLineIndent; + StringBuilder currentIndent; + char previousNewline = '\0'; + char previousChar = '\0'; + bool isLineStart; + bool isInString; + + public JSonIndentEngine (TextEditorData data) + { + this.data = data; + Reset (); + } + + #region IStateMachineIndentEngine implementation + + public IStateMachineIndentEngine Clone () + { + return (IStateMachineIndentEngine)MemberwiseClone (); + } + + public bool IsInsidePreprocessorDirective { + get { + return false; + } + } + + public bool IsInsidePreprocessorComment { + get { + return false; + } + } + + public bool IsInsideStringLiteral { + get { + return false; + } + } + + public bool IsInsideVerbatimString { + get { + return false; + } + } + + public bool IsInsideCharacter { + get { + return false; + } + } + + public bool IsInsideString { + get { + return isInString; + } + } + + public bool IsInsideLineComment { + get { + return false; + } + } + + public bool IsInsideMultiLineComment { + get { + return false; + } + } + + public bool IsInsideDocLineComment { + get { + return false; + } + } + + public bool IsInsideComment { + get { + return false; + } + } + + public bool IsInsideOrdinaryComment { + get { + return false; + } + } + + public bool IsInsideOrdinaryCommentOrString { + get { + return false; + } + } + + public bool LineBeganInsideVerbatimString { + get { + return false; + } + } + + public bool LineBeganInsideMultiLineComment { + get { + return false; + } + } + + #endregion + + public static ICSharpCode.NRefactory.CSharp.TextEditorOptions CreateNRefactoryTextEditorOptions (TextEditorData doc) + { + return new ICSharpCode.NRefactory.CSharp.TextEditorOptions { + TabsToSpaces = doc.TabsToSpaces, + TabSize = doc.Options.TabSize, + IndentSize = doc.Options.IndentationSize, + ContinuationIndent = doc.Options.IndentationSize, + LabelIndent = -doc.Options.IndentationSize, + EolMarker = doc.EolMarker, + IndentBlankLines = doc.Options.IndentStyle != IndentStyle.Virtual, + WrapLineLength = doc.Options.RulerColumn + }; + } + + #region IDocumentIndentEngine implementation + + public void Push (char ch) + { + var isNewLine = NewLine.IsNewLine (ch); + if (!isNewLine) { + if (ch == '"') + isInString = !IsInsideString; + if (ch == '{' || ch == '[') { + nextLineIndent.Push (IndentType.Block); + } else if (ch == '}' || ch == ']') { + if (thisLineIndent.Count > 0) + thisLineIndent.Pop (); + if (nextLineIndent.Count > 0) + nextLineIndent.Pop (); + } + } else { + if (ch == NewLine.LF && previousChar == NewLine.CR) { + offset++; + previousChar = ch; + return; + } + } + + offset++; + if (!isNewLine) { + previousNewline = '\0'; + + isLineStart &= char.IsWhiteSpace (ch); + + if (isLineStart) + currentIndent.Append (ch); + + if (ch == '\t') { + var nextTabStop = (column - 1 + data.Options.IndentationSize) / data.Options.IndentationSize; + column = 1 + nextTabStop * data.Options.IndentationSize; + } else { + column++; + } + } else { + previousNewline = ch; + currentIndent.Length = 0; + isLineStart = true; + column = 1; + line++; + thisLineIndent = nextLineIndent.Clone (); + } + previousChar = ch; + } + + public void Reset () + { + offset = 0; + line = column = 1; + thisLineIndent = new Indent (CreateNRefactoryTextEditorOptions (data)); + nextLineIndent = new Indent (CreateNRefactoryTextEditorOptions (data)); + currentIndent = new StringBuilder (); + previousNewline = '\0'; + previousChar = '\0'; + isLineStart = true; + isInString = false; + } + + public void Update (int offset) + { + if (Offset > offset) + Reset (); + + while (Offset < offset) { + Push (Document.GetCharAt (Offset)); + } + } + + IDocumentIndentEngine IDocumentIndentEngine.Clone () + { + return Clone (); + } + + public ICSharpCode.NRefactory.Editor.IDocument Document { + get { + return data.Document; + } + } + + public string ThisLineIndent { + get { + return thisLineIndent.IndentString; + } + } + + public string NextLineIndent { + get { + return nextLineIndent.IndentString; + } + } + + public string CurrentIndent { + get { + return currentIndent.ToString (); + } + } + + public bool NeedsReindent { + get { + return ThisLineIndent != CurrentIndent; + } + } + + public int Offset { + get { + return offset; + } + } + + public TextLocation Location { + get { + return new TextLocation (line, column); + } + } + + public bool EnableCustomIndentLevels { + get; + set; + } + + #endregion + + #region ICloneable implementation + + object ICloneable.Clone () + { + return Clone (); + } + + #endregion + } +} + diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.JSon/JSonIndentationTracker.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.JSon/JSonIndentationTracker.cs new file mode 100644 index 0000000000..7ebfbe34fb --- /dev/null +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.JSon/JSonIndentationTracker.cs @@ -0,0 +1,86 @@ +// +// JSonTextEditorExtension.cs +// +// Author: +// Mike Krüger <mkrueger@xamarin.com> +// +// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION 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.TextEditor; +using ICSharpCode.NRefactory.CSharp; +using System; +using MonoDevelop.Core; + +namespace MonoDevelop.SourceEditor.JSon +{ + class JSonIndentationTracker : IIndentationTracker + { + readonly TextEditorData data; + readonly CacheIndentEngine stateTracker; + + public JSonIndentationTracker(TextEditorData data, CacheIndentEngine stateTracker) + { + this.data = data; + this.stateTracker = stateTracker; + } + + string GetIndentationString (DocumentLocation loc) + { + var line = data.Document.GetLine (loc.Line); + if (line == null) + return ""; + // Get context to the end of the line w/o changing the main engine's state + var offset = line.Offset; + string curIndent = line.GetIndentation (data.Document); + try { + stateTracker.Update (Math.Min (data.Length, offset + Math.Min (line.Length, loc.Column - 1))); + int nlwsp = curIndent.Length; + if (!stateTracker.LineBeganInsideMultiLineComment || (nlwsp < line.LengthIncludingDelimiter && data.Document.GetCharAt (offset + nlwsp) == '*')) + return stateTracker.ThisLineIndent; + } catch (Exception e) { + LoggingService.LogError ("Error while indenting at "+ loc, e); + } + return curIndent; + } + + #region IIndentationTracker implementation + public string GetIndentationString (int offset) + { + return GetIndentationString (data.OffsetToLocation (offset)); + } + + public string GetIndentationString (int lineNumber, int column) + { + return GetIndentationString (new DocumentLocation (lineNumber, column)); + } + + public int GetVirtualIndentationColumn (int offset) + { + return 1 + GetIndentationString (offset).Length; + } + + public int GetVirtualIndentationColumn (int lineNumber, int column) + { + return 1 + GetIndentationString (lineNumber, column).Length; + } + #endregion + } +} + diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.JSon/JSonTextEditorExtension.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.JSon/JSonTextEditorExtension.cs new file mode 100644 index 0000000000..5ae84fa44a --- /dev/null +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.JSon/JSonTextEditorExtension.cs @@ -0,0 +1,131 @@ +// +// JSonTextEditorExtension.cs +// +// Author: +// Mike Krüger <mkrueger@xamarin.com> +// +// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION 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 MonoDevelop.Ide.Gui.Content; +using ICSharpCode.NRefactory.CSharp; +using Gdk; +using Mono.TextEditor; +using System; +using MonoDevelop.Core; +using MonoDevelop.Ide.CodeCompletion; + +namespace MonoDevelop.SourceEditor.JSon +{ + class JSonTextEditorExtension : TextEditorExtension + { + CacheIndentEngine stateTracker; + + TextEditorData textEditorData { + get { + return document.Editor; + } + } + + public override void Initialize () + { + base.Initialize (); + IStateMachineIndentEngine indentEngine; + indentEngine = new JSonIndentEngine (document.Editor); + stateTracker = new CacheIndentEngine (indentEngine); + document.Editor.IndentationTracker = new JSonIndentationTracker (document.Editor, stateTracker); + } + + + public override bool KeyPress (Key key, char keyChar, ModifierType modifier) + { + var result = base.KeyPress (key, keyChar, modifier); + + if (key == Key.Return) { + if (textEditorData.Options.IndentStyle == IndentStyle.Virtual) { + if (textEditorData.GetLine (textEditorData.Caret.Line).Length == 0) + textEditorData.Caret.Column = textEditorData.IndentationTracker.GetVirtualIndentationColumn (textEditorData.Caret.Location); + } else { + DoReSmartIndent (); + } + } + + return result; + } + + void DoReSmartIndent () + { + DoReSmartIndent (textEditorData.Caret.Offset); + } + + void DoReSmartIndent (int cursor) + { + SafeUpdateIndentEngine (cursor); + if (stateTracker.LineBeganInsideVerbatimString || stateTracker.LineBeganInsideMultiLineComment) + return; + var line = textEditorData.Document.GetLineByOffset (cursor); + + // Get context to the end of the line w/o changing the main engine's state + var curTracker = stateTracker.Clone (); + try { + for (int max = cursor; max < line.EndOffset; max++) { + curTracker.Push (textEditorData.Document.GetCharAt (max)); + } + } catch (Exception e) { + LoggingService.LogError ("Exception during indentation", e); + } + + int pos = line.Offset; + string curIndent = line.GetIndentation (textEditorData.Document); + int nlwsp = curIndent.Length; + int offset = cursor > pos + nlwsp ? cursor - (pos + nlwsp) : 0; + if (!stateTracker.LineBeganInsideMultiLineComment || (nlwsp < line.LengthIncludingDelimiter && textEditorData.Document.GetCharAt (line.Offset + nlwsp) == '*')) { + // Possibly replace the indent + string newIndent = curTracker.ThisLineIndent; + int newIndentLength = newIndent.Length; + if (newIndent != curIndent) { + if (CompletionWindowManager.IsVisible) { + if (pos < CompletionWindowManager.CodeCompletionContext.TriggerOffset) + CompletionWindowManager.CodeCompletionContext.TriggerOffset -= nlwsp; + } + + newIndentLength = textEditorData.Replace (pos, nlwsp, newIndent); + textEditorData.Document.CommitLineUpdate (textEditorData.Caret.Line); + CompletionWindowManager.HideWindow (); + } + pos += newIndentLength; + } else { + pos += curIndent.Length; + } + + pos += offset; + + textEditorData.FixVirtualIndentation (); + } + internal void SafeUpdateIndentEngine (int offset) + { + try { + stateTracker.Update (offset); + } catch (Exception e) { + LoggingService.LogError ("Error while updating the indentation engine", e); + } + } + + } +}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.QuickTasks/IUsageProvider.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.QuickTasks/IUsageProvider.cs index 44290288ff..df309f5806 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.QuickTasks/IUsageProvider.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.QuickTasks/IUsageProvider.cs @@ -27,12 +27,26 @@ using System; using System.Collections.Generic; using Mono.TextEditor; +using MonoDevelop.Ide.FindInFiles; namespace MonoDevelop.SourceEditor.QuickTasks { + + public struct Usage + { + public DocumentLocation Location; + public ReferenceUsageType UsageType; + + public Usage (DocumentLocation location, ReferenceUsageType usageType) + { + this.Location = location; + this.UsageType = usageType; + } + } + public interface IUsageProvider { - IEnumerable<DocumentLocation> Usages { + IEnumerable<Usage> Usages { get; } diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.QuickTasks/QuickTaskOverviewMode.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.QuickTasks/QuickTaskOverviewMode.cs index db531c1a79..e0b807f181 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.QuickTasks/QuickTaskOverviewMode.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.QuickTasks/QuickTaskOverviewMode.cs @@ -59,7 +59,7 @@ namespace MonoDevelop.SourceEditor.QuickTasks } } - public IEnumerable<TextLocation> AllUsages { + public IEnumerable<Usage> AllUsages { get { return parentStrip.AllUsages; } @@ -475,19 +475,29 @@ namespace MonoDevelop.SourceEditor.QuickTasks protected Severity DrawQuickTasks (Cairo.Context cr) { Severity severity = Severity.None; - /* + foreach (var usage in AllUsages) { - double y = GetYPosition (usage.Line); + double y = GetYPosition (usage.Location.Line); var usageColor = TextEditor.ColorStyle.PlainText.Foreground; usageColor.A = 0.4; - cr.Color = usageColor; + HslColor color; + if ((usage.UsageType & MonoDevelop.Ide.FindInFiles.ReferenceUsageType.Write) != 0) { + color = TextEditor.ColorStyle.ChangingUsagesRectangle.Color; + } else if ((usage.UsageType & MonoDevelop.Ide.FindInFiles.ReferenceUsageType.Read) != 0) { + color = TextEditor.ColorStyle.UsagesRectangle.Color; + } else { + color = usageColor; + } + color.L = 0.5; + cr.Color = color; cr.MoveTo (0, y - 3); cr.LineTo (5, y); cr.LineTo (0, y + 3); + cr.LineTo (0, y - 3); cr.ClosePath (); cr.Fill (); } -*/ + foreach (var task in AllTasks) { double y = GetYPosition (task.Location.Line); diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.QuickTasks/QuickTaskStrip.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.QuickTasks/QuickTaskStrip.cs index 69c0716efb..0eb2fa5f5a 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.QuickTasks/QuickTaskStrip.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.QuickTasks/QuickTaskStrip.cs @@ -85,7 +85,7 @@ namespace MonoDevelop.SourceEditor.QuickTasks } Dictionary<IQuickTaskProvider, List<QuickTask>> providerTasks = new Dictionary<IQuickTaskProvider, List<QuickTask>> (); - Dictionary<IUsageProvider, List<DocumentLocation>> providerUsages = new Dictionary<IUsageProvider, List<DocumentLocation>> (); + Dictionary<IUsageProvider, List<Usage>> providerUsages = new Dictionary<IUsageProvider, List<Usage>> (); public IEnumerable<QuickTask> AllTasks { get { @@ -98,7 +98,7 @@ namespace MonoDevelop.SourceEditor.QuickTasks } } } - public IEnumerable<TextLocation> AllUsages { + public IEnumerable<Usage> AllUsages { get { if (providerUsages == null) yield break; @@ -176,10 +176,10 @@ namespace MonoDevelop.SourceEditor.QuickTasks public void Update (IUsageProvider provider) { -/* if (providerTasks == null) + if (providerTasks == null) return; - providerUsages [provider] = new List<DocumentLocation> (provider.Usages); - OnTaskProviderUpdated (EventArgs.Empty);*/ + providerUsages [provider] = new List<Usage> (provider.Usages); + OnTaskProviderUpdated (EventArgs.Empty); } protected virtual void OnTaskProviderUpdated (EventArgs e) diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.addin.xml b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.addin.xml index abaa4f234b..9246d14ada 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.addin.xml +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.addin.xml @@ -224,6 +224,10 @@ <Font name ="LanguageTooltips" _displayName="Editor tooltips" default ="_DEFAULT_SANS"/> </Extension> + <Extension path = "/MonoDevelop/Ide/TextEditorExtensions"> + <Class fileExtensions = ".json" class = "MonoDevelop.SourceEditor.JSon.JSonTextEditorExtension" /> + </Extension> + <Extension path = "/MonoDevelop/Core/UserDataMigration"> <!-- 2.4 --> <Migration sourceVersion="2.4" kind="UserData" path="syntaxmodes" targetPath="HighlightingSchemes" isDirectory="true" /> diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.csproj b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.csproj index 4baa51f11a..fec2bba616 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.csproj +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.csproj @@ -3,7 +3,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>9.0.21022</ProductVersion> + <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{F8F92AA4-A376-4679-A9D4-60E7B7FBF477}</ProjectGuid> <OutputType>Library</OutputType> @@ -187,6 +187,9 @@ <Compile Include="MonoDevelop.SourceEditor.OptionPanels\CompletionCharactersPanel.cs" /> <Compile Include="MonoDevelop.SourceEditor\OverlayMessageWindow.cs" /> <Compile Include="MonoDevelop.SourceEditor\HoverCloseButton.cs" /> + <Compile Include="MonoDevelop.SourceEditor.JSon\JSonIndentationTracker.cs" /> + <Compile Include="MonoDevelop.SourceEditor.JSon\JSonIndentEngine.cs" /> + <Compile Include="MonoDevelop.SourceEditor.JSon\JSonTextEditorExtension.cs" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="gtk-gui\gui.stetic"> diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/PinnedWatchWidget.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/PinnedWatchWidget.cs index c90d4259f3..c53fa61362 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/PinnedWatchWidget.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/PinnedWatchWidget.cs @@ -39,7 +39,7 @@ namespace MonoDevelop.SourceEditor { public class PinnedWatchWidget : Gtk.EventBox { - ObjectValueTreeView valueTree; + readonly ObjectValueTreeView valueTree; ObjectValue objectValue; TextEditor Editor { @@ -55,6 +55,9 @@ namespace MonoDevelop.SourceEditor return objectValue; } set { + if (objectValue == value) + return; + if (objectValue != null && value != null) { valueTree.ReplaceValue (objectValue, value); } else { diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SearchAndReplaceWidget.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SearchAndReplaceWidget.cs index 5223820291..794d9c2c2f 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SearchAndReplaceWidget.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SearchAndReplaceWidget.cs @@ -289,6 +289,7 @@ namespace MonoDevelop.SourceEditor } else { IsInSelectionSearchMode = true; SelectionSegment = textEditor.SelectionRange; + SetSearchOptions (); } } SetSearchPattern (SearchAndReplaceOptions.SearchPattern); diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs index 6e96ae2508..6d6f29fa5c 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs @@ -871,14 +871,15 @@ namespace MonoDevelop.SourceEditor internal void UpdateEolMarkerMessage (bool multiple) { + if (UseIncorrectMarkers || DefaultSourceEditorOptions.Instance.LineEndingConversion == LineEndingConversion.LeaveAsIs) + return; ShowIncorretEolMarkers (Document.FileName, multiple); } internal bool EnsureCorrectEolMarker (string fileName) { - if (UseIncorrectMarkers) + if (UseIncorrectMarkers || DefaultSourceEditorOptions.Instance.LineEndingConversion == LineEndingConversion.LeaveAsIs) return true; - if (HasIncorrectEolMarker) { switch (DefaultSourceEditorOptions.Instance.LineEndingConversion) { case LineEndingConversion.Ask: diff --git a/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.NodeBuilders/WebReferenceNodeBuilder.cs b/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.NodeBuilders/WebReferenceNodeBuilder.cs index 9166628fe8..e15e029333 100644 --- a/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.NodeBuilders/WebReferenceNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.NodeBuilders/WebReferenceNodeBuilder.cs @@ -57,7 +57,7 @@ namespace MonoDevelop.WebReferences.NodeBuilders /// <param name="dataObject">An object containing the current activated node.</param> public override bool HasChildNodes (ITreeBuilder builder, object dataObject) { - return false; + return true; } /// <summary>Add entries for all the web references in the project to the tree builder.</summary> @@ -65,11 +65,8 @@ namespace MonoDevelop.WebReferences.NodeBuilders /// <param name="dataObject">An object containing the data for the current node in the tree.</param> public override void BuildChildNodes (ITreeBuilder treeBuilder, object dataObject) { - /* - WebReferenceItem item = (WebReferenceItem) dataObject; - builder.AddChild(item.ProxyFile); - builder.AddChild(item.MapFile); - */ + var item = (WebReferenceItem) dataObject; + treeBuilder.AddChild(item.MapFile); } } }
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.XmlEditor/AddinInfo.cs b/main/src/addins/MonoDevelop.XmlEditor/AddinInfo.cs new file mode 100644 index 0000000000..eb38989c4c --- /dev/null +++ b/main/src/addins/MonoDevelop.XmlEditor/AddinInfo.cs @@ -0,0 +1,17 @@ + +using System; +using Mono.Addins; +using Mono.Addins.Description; + +[assembly:Addin ("XmlEditor", + Namespace = "MonoDevelop", + Version = MonoDevelop.BuildInfo.Version, + Category = "IDE extensions")] + +[assembly:AddinName ("XML Editor")] +[assembly:AddinDescription ("XML Editor")] + +[assembly:AddinDependency ("Core", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("Ide", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("DesignerSupport", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("SourceEditor2", MonoDevelop.BuildInfo.Version)] diff --git a/main/src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor.addin.xml b/main/src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor.addin.xml index fc5264ff51..822f3daf40 100644 --- a/main/src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor.addin.xml +++ b/main/src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor.addin.xml @@ -1,12 +1,4 @@ -<Addin name = "XML Editor"
- id = "XmlEditor"
- namespace = "MonoDevelop"
- author = "Matt Ward, Michael Hutchinson"
- copyright = "MIT X11"
- url = "http://md-xed.sourceforge.net"
- description = "XML Editor"
- category = "IDE extensions"
- version = "4.2.3">
+<ExtensionModel>
<Runtime>
<Import assembly="MonoDevelop.XmlEditor.dll" />
@@ -20,13 +12,6 @@ <Import file="schemas/nant.xsd" />
</Runtime>
- <Dependencies>
- <Addin id="Core" version="4.2.3"/>
- <Addin id="Ide" version="4.2.3"/>
- <Addin id="DesignerSupport" version="4.2.3"/>
- <Addin id="SourceEditor2" version="4.2.3"/>
- </Dependencies>
-
<ExtensionPoint path = "/MonoDevelop/XmlEditor/XmlFileAssociations">
<ExtensionNode name = "Association" type = "MonoDevelop.XmlEditor.XmlFileAssociationNode"/>
</ExtensionPoint>
@@ -154,4 +139,5 @@ <!-- 2.6+ -->
<Migration sourceVersion="2.6+" kind="UserData" path="XmlSchemas" isDirectory="true" />
</Extension>
-</Addin>
+
+</ExtensionModel>
diff --git a/main/src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor.csproj b/main/src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor.csproj index 795f6508de..bebfbe2fa6 100644 --- a/main/src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor.csproj +++ b/main/src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor.csproj @@ -177,6 +177,7 @@ <Compile Include="MonoDevelop.XmlEditor.Completion\XmlCompletionDataList.cs" /> <Compile Include="MonoDevelop.XmlEditor.Completion\EmptyXmlCompletionProvider.cs" /> <Compile Include="MonoDevelop.XmlEditor.Completion\XmlNamespacePrefixMap.cs" /> + <Compile Include="AddinInfo.cs" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="MonoDevelop.XmlEditor.addin.xml"> diff --git a/main/src/addins/MonoDeveloperExtensions/AddinInfo.cs b/main/src/addins/MonoDeveloperExtensions/AddinInfo.cs new file mode 100644 index 0000000000..99eb91a274 --- /dev/null +++ b/main/src/addins/MonoDeveloperExtensions/AddinInfo.cs @@ -0,0 +1,17 @@ + +using System; +using Mono.Addins; +using Mono.Addins.Description; + +[assembly:Addin ("MonoDeveloperExtensions", + Namespace = "MonoDevelop", + Version = MonoDevelop.BuildInfo.Version, + Category = "Project Import and Export")] + +[assembly:AddinName ("IDE Extensions for developers of the Mono framework")] +[assembly:AddinDescription ("Provides some IDE extensions useful for developing and building the Mono class libraries")] + +[assembly:AddinDependency ("Core", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("Ide", MonoDevelop.BuildInfo.Version)] + +[assembly:AddinModule ("MonoDeveloperExtensions_nunit.dll")]
\ No newline at end of file diff --git a/main/src/addins/MonoDeveloperExtensions/MonoDeveloperExtensions.addin.xml b/main/src/addins/MonoDeveloperExtensions/MonoDeveloperExtensions.addin.xml index 66b44f2f3d..f8288a171a 100644 --- a/main/src/addins/MonoDeveloperExtensions/MonoDeveloperExtensions.addin.xml +++ b/main/src/addins/MonoDeveloperExtensions/MonoDeveloperExtensions.addin.xml @@ -1,22 +1,5 @@ -<Addin id = "MonoDeveloperExtensions" - namespace = "MonoDevelop" - name = "IDE Extensions for developers of the Mono framework" - author = "Lluis Sanchez Gual" - copyright = "(c) 2005 Novell, Inc." - url = "http://www.monodevelop.com" - description = "Provides some IDE extensions useful for developing and building the Mono class libraries." - category = "Project Import and Export" - version = "4.2.3"> +<ExtensionModel> - <Runtime> - <Import assembly="MonoDeveloperExtensions.dll"/> - </Runtime> - - <Dependencies> - <Addin id="Core" version="4.2.3"/> - <Addin id="Ide" version="4.2.3"/> - </Dependencies> - <Extension path = "/MonoDevelop/ProjectModel/FileFormats"> <FileFormat id = "MonoMakefile" name="Mono Makefile" class = "MonoDeveloper.MonoMakefileFormat" /> @@ -46,15 +29,4 @@ </Condition> </Extension> - <Module> - <Runtime> - <Import assembly="MonoDeveloperExtensions_nunit.dll"/> - </Runtime> - <Dependencies> - <Addin id="NUnit" version="4.2.3"/> - </Dependencies> - <Extension path = "/MonoDevelop/NUnit/TestProviders"> - <Class id = "MonoTestProvider" class = "MonoDeveloper.MonoTestProvider"/> - </Extension> - </Module> -</Addin> +</ExtensionModel> diff --git a/main/src/addins/MonoDeveloperExtensions/MonoDeveloperExtensions.csproj b/main/src/addins/MonoDeveloperExtensions/MonoDeveloperExtensions.csproj index d7727e1f9a..c3f470074e 100644 --- a/main/src/addins/MonoDeveloperExtensions/MonoDeveloperExtensions.csproj +++ b/main/src/addins/MonoDeveloperExtensions/MonoDeveloperExtensions.csproj @@ -77,6 +77,7 @@ <Compile Include="MonoMakefileFormat.cs" /> <Compile Include="Commands.cs" /> <Compile Include="MonoSolutionItemHandler.cs" /> + <Compile Include="AddinInfo.cs" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="MonoDeveloperExtensions.addin.xml"> diff --git a/main/src/addins/MonoDeveloperExtensions/NUnit/AddinInfo.cs b/main/src/addins/MonoDeveloperExtensions/NUnit/AddinInfo.cs new file mode 100644 index 0000000000..14d9f61a8c --- /dev/null +++ b/main/src/addins/MonoDeveloperExtensions/NUnit/AddinInfo.cs @@ -0,0 +1,6 @@ + +using System; +using Mono.Addins; +using Mono.Addins.Description; + +[assembly:AddinDependency ("NUnit", MonoDevelop.BuildInfo.Version)] diff --git a/main/src/addins/MonoDeveloperExtensions/NUnit/ExtensionModel.addin.xml b/main/src/addins/MonoDeveloperExtensions/NUnit/ExtensionModel.addin.xml new file mode 100644 index 0000000000..1bef6a70fc --- /dev/null +++ b/main/src/addins/MonoDeveloperExtensions/NUnit/ExtensionModel.addin.xml @@ -0,0 +1,7 @@ +<ExtensionModel> + + <Extension path = "/MonoDevelop/NUnit/TestProviders"> + <Class id = "MonoTestProvider" class = "MonoDeveloper.MonoTestProvider"/> + </Extension> + +</ExtensionModel> diff --git a/main/src/addins/MonoDeveloperExtensions/NUnit/NUnit.csproj b/main/src/addins/MonoDeveloperExtensions/NUnit/NUnit.csproj index bf976b8870..f01db34192 100644 --- a/main/src/addins/MonoDeveloperExtensions/NUnit/NUnit.csproj +++ b/main/src/addins/MonoDeveloperExtensions/NUnit/NUnit.csproj @@ -56,16 +56,27 @@ <Name>MonoDevelop.NUnit</Name> <Private>False</Private> </ProjectReference> + <ProjectReference Include="..\..\..\..\external\mono-addins\Mono.Addins\Mono.Addins.csproj"> + <Project>{91DD5A2D-9FE3-4C3C-9253-876141874DAD}</Project> + <Name>Mono.Addins</Name> + <Private>False</Private> + </ProjectReference> </ItemGroup> <ItemGroup> <Reference Include="System" /> </ItemGroup> <ItemGroup> <Compile Include="MonoTestProvider.cs" /> + <Compile Include="AddinInfo.cs" /> </ItemGroup> <ItemGroup> <None Include="Makefile.am" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="..\..\..\..\md.targets" /> + <ItemGroup> + <EmbeddedResource Include="ExtensionModel.addin.xml"> + <LogicalName>ExtensionModel.addin.xml</LogicalName> + </EmbeddedResource> + </ItemGroup> </Project> diff --git a/main/src/addins/NUnit/AddinInfo.cs b/main/src/addins/NUnit/AddinInfo.cs new file mode 100644 index 0000000000..b7a7b115b1 --- /dev/null +++ b/main/src/addins/NUnit/AddinInfo.cs @@ -0,0 +1,15 @@ + +using System; +using Mono.Addins; +using Mono.Addins.Description; + +[assembly:Addin ("NUnit", + Namespace = "MonoDevelop", + Version = MonoDevelop.BuildInfo.Version, + Category = "Testing")] + +[assembly:AddinName ("NUnit support")] +[assembly:AddinDescription ("Integrates NUnit into the MonoDevelop IDE")] + +[assembly:AddinDependency ("Core", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("Ide", MonoDevelop.BuildInfo.Version)] diff --git a/main/src/addins/NUnit/MonoDevelop.NUnit.csproj b/main/src/addins/NUnit/MonoDevelop.NUnit.csproj index b589a05445..9d84bc00f5 100644 --- a/main/src/addins/NUnit/MonoDevelop.NUnit.csproj +++ b/main/src/addins/NUnit/MonoDevelop.NUnit.csproj @@ -202,6 +202,7 @@ <Compile Include="Gui\NUnitOptionsPanel.cs" /> <Compile Include="gtk-gui\MonoDevelop.NUnit.NUnitOptionsWidget.cs" /> <Compile Include="Services\TcpTestListener.cs" /> + <Compile Include="AddinInfo.cs" /> </ItemGroup> <ItemGroup> <None Include="Makefile.am" /> diff --git a/main/src/addins/NUnit/MonoDevelopNUnit.addin.xml b/main/src/addins/NUnit/MonoDevelopNUnit.addin.xml index f2d3557317..9e5d07506f 100644 --- a/main/src/addins/NUnit/MonoDevelopNUnit.addin.xml +++ b/main/src/addins/NUnit/MonoDevelopNUnit.addin.xml @@ -1,12 +1,4 @@ -<Addin id = "NUnit" - namespace = "MonoDevelop" - name = "NUnit support" - author = "Lluis Sanchez, John Luke" - copyright = "MIT X11" - url = "http://monodevelop.com" - description = "Integrates NUnit into the MonoDevelop IDE." - category = "Testing" - version = "4.2.3"> +<ExtensionModel> <Runtime> <Import assembly="MonoDevelop.NUnit.dll" /> @@ -16,11 +8,6 @@ <Import assembly="nunit.util.dll" /> </Runtime> - <Dependencies> - <Addin id="Core" version="4.2.3"/> - <Addin id="Ide" version="4.2.3"/> - </Dependencies> - <!-- Extension Points --> <ExtensionPoint path = "/MonoDevelop/NUnit/TestProviders" name = "Test providers"> @@ -222,4 +209,4 @@ name = "TestRunnerArgs" type = "System.String" external="false" /> </Extension> -</Addin> +</ExtensionModel> diff --git a/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/AddinInfo.cs b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/AddinInfo.cs new file mode 100644 index 0000000000..1ca73e49a5 --- /dev/null +++ b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/AddinInfo.cs @@ -0,0 +1,16 @@ + +using System; +using Mono.Addins; +using Mono.Addins.Description; + +[assembly:Addin ("TextTemplating", + Namespace = "MonoDevelop", + Version = MonoDevelop.BuildInfo.Version, + Category = "IDE extensions")] + +[assembly:AddinName ("Text Templating")] +[assembly:AddinDescription ("Support for editing and running T4 text templates")] + +[assembly:AddinDependency ("Core", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("Ide", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("SourceEditor2", MonoDevelop.BuildInfo.Version)] diff --git a/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelop.TextTemplating.addin.xml b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelop.TextTemplating.addin.xml index c2fe7390e4..013995a0dd 100644 --- a/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelop.TextTemplating.addin.xml +++ b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelop.TextTemplating.addin.xml @@ -1,23 +1,9 @@ -<Addin id = "TextTemplating" - namespace = "MonoDevelop" - name = "Text Templating" - author = "Michael Hutchinson" - copyright = "MIT X11" - url = "http://monodevelop.com" - description = "Support for editing and running T4 text templates." - category = "IDE extensions" - version = "4.2.3"> +<ExtensionModel> <Runtime> <Import assembly="Mono.TextTemplating.dll" /> </Runtime> - <Dependencies> - <Addin id="Core" version="4.2.3"/> - <Addin id="Ide" version="4.2.3"/> - <Addin id="SourceEditor2" version="4.2.3"/> - </Dependencies> - <Extension path = "/MonoDevelop/SourceEditor2/SyntaxModes"> <Templates resource="T4SyntaxMode.xml" /> </Extension> @@ -53,4 +39,5 @@ <Tool name="TextTemplatingFileGenerator" type="MonoDevelop.TextTemplating.TextTemplatingFileGenerator"/> <Tool name="TextTemplatingFilePreprocessor" type="MonoDevelop.TextTemplating.TextTemplatingFilePreprocessor"/> </Extension> -</Addin> + +</ExtensionModel> diff --git a/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelop.TextTemplating.csproj b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelop.TextTemplating.csproj index 61e452d98b..4e07f8cd1a 100644 --- a/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelop.TextTemplating.csproj +++ b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelop.TextTemplating.csproj @@ -51,6 +51,7 @@ <Compile Include="TextTemplatingFileGenerator.cs" /> <Compile Include="MonoDevelopTemplatingHost.cs" /> <Compile Include="ProjectFileTemplatingHost.cs" /> + <Compile Include="AddinInfo.cs" /> </ItemGroup> <ItemGroup> <Reference Include="System" /> @@ -112,6 +113,11 @@ <Name>ICSharpCode.NRefactory</Name> <Private>False</Private> </ProjectReference> + <ProjectReference Include="..\..\..\..\external\mono-addins\Mono.Addins\Mono.Addins.csproj"> + <Project>{91DD5A2D-9FE3-4C3C-9253-876141874DAD}</Project> + <Name>Mono.Addins</Name> + <Private>False</Private> + </ProjectReference> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="..\..\..\..\md.targets" /> diff --git a/main/src/addins/VBNetBinding/AddinInfo.cs b/main/src/addins/VBNetBinding/AddinInfo.cs new file mode 100644 index 0000000000..996927e3d3 --- /dev/null +++ b/main/src/addins/VBNetBinding/AddinInfo.cs @@ -0,0 +1,15 @@ + +using System; +using Mono.Addins; +using Mono.Addins.Description; + +[assembly:Addin ("VBBinding", + Namespace = "MonoDevelop", + Version = MonoDevelop.BuildInfo.Version, + Category = "Language bindings")] + +[assembly:AddinName ("VB.NET Language Binding")] +[assembly:AddinDescription ("VB.NET Language Binding")] + +[assembly:AddinDependency ("Core", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("Ide", MonoDevelop.BuildInfo.Version)] diff --git a/main/src/addins/VBNetBinding/VBNetBinding.addin.xml b/main/src/addins/VBNetBinding/VBNetBinding.addin.xml index 45d7814864..d6531db682 100644 --- a/main/src/addins/VBNetBinding/VBNetBinding.addin.xml +++ b/main/src/addins/VBNetBinding/VBNetBinding.addin.xml @@ -1,18 +1,5 @@ -<Addin id = "VBBinding" - namespace = "MonoDevelop" - name = "VB.NET Language Binding" - author = "Levi Bard" - copyright = "LGPL" - url = "http://bard.sytes.net/vbnetbinding" - description = "VB.NET Language Binding" - category = "Language bindings" - version = "4.2.3"> +<ExtensionModel> - <Dependencies> - <Addin id="Core" version="4.2.3"/> - <Addin id="Ide" version="4.2.3"/> - </Dependencies> - <Extension path = "/MonoDevelop/ProjectModel/MSBuildItemTypes"> <DotNetProject language="VBNet" @@ -84,4 +71,4 @@ <Parser class = "MonoDevelop.VBNetBinding.DomParser" fileExtensions=".vb" /> </Extension>--> -</Addin> +</ExtensionModel> diff --git a/main/src/addins/VBNetBinding/VBNetBinding.csproj b/main/src/addins/VBNetBinding/VBNetBinding.csproj index b39ea2d8ff..2fcb016816 100644 --- a/main/src/addins/VBNetBinding/VBNetBinding.csproj +++ b/main/src/addins/VBNetBinding/VBNetBinding.csproj @@ -95,6 +95,7 @@ <Compile Include="Gui\ImportsOptionsPanel.cs" /> <Compile Include="gtk-gui\MonoDevelop.VBNetBinding.ImportsOptionsPanelWidget.cs" /> <Compile Include="Project\VBProjectParameters.cs" /> + <Compile Include="AddinInfo.cs" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="templates\EmptyVBFile.xft.xml"> diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/BaseGitRepositoryTests.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/BaseGitRepositoryTests.cs index 452a997337..ea243201d4 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/BaseGitRepositoryTests.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/BaseGitRepositoryTests.cs @@ -203,6 +203,8 @@ namespace MonoDevelop.VersionControl.Git.Tests repo2.RenameBranch ("branch2", "branch3");
Assert.IsTrue (repo2.GetBranches ().Any (b => b.Name == "branch3") && repo2.GetBranches ().All (b => b.Name != "branch2"), "Failed to rename branch");
+
+ // TODO: Add CreateBranchFromCommit tests.
}
[Test]
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/AddinInfo.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/AddinInfo.cs new file mode 100644 index 0000000000..276881da23 --- /dev/null +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/AddinInfo.cs @@ -0,0 +1,16 @@ + +using System; +using Mono.Addins; +using Mono.Addins.Description; + +[assembly:Addin ("VersionControl.Git", + Namespace = "MonoDevelop", + Version = MonoDevelop.BuildInfo.Version, + Category = "Version Control")] + +[assembly:AddinName ("Git support")] +[assembly:AddinDescription ("Git support for the Version Control Add-in")] + +[assembly:AddinDependency ("Core", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("Ide", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("VersionControl", MonoDevelop.BuildInfo.Version)] diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.addin.xml b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.addin.xml index 5708c8a7c4..cdaa9dc6a8 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.addin.xml +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.addin.xml @@ -1,24 +1,9 @@ -<Addin id = "VersionControl.Git" - namespace = "MonoDevelop" - name = "Git support" - author = "Dale Ragan, Lluis Sanchez" - copyright = "LGPL" - url = "http://www.monodevelop.com/" - description = "Git support for the Version Control Add-in" - category = "Version Control" - version = "4.2.3"> +<ExtensionModel> <Runtime> - <Import assembly="MonoDevelop.VersionControl.Git.dll"/> <Import assembly="NGit.dll"/> </Runtime> - <Dependencies> - <Addin id="Core" version="4.2.3"/> - <Addin id="Ide" version="4.2.3"/> - <Addin id="VersionControl" version="4.2.3"/> - </Dependencies> - <Extension path="/MonoDevelop/VersionControl/VersionControlSystems"> <Class class="MonoDevelop.VersionControl.Git.GitClient"/> </Extension> @@ -106,4 +91,4 @@ <Class class = "MonoDevelop.VersionControl.Git.GitSupportFeature" /> </Extension> --> -</Addin> +</ExtensionModel> diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.csproj b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.csproj index e3b3b4f363..47badaf362 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.csproj +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.csproj @@ -86,6 +86,7 @@ <Compile Include="gtk-gui\MonoDevelop.VersionControl.Git.UserGitConfigDialog.cs" /> <Compile Include="MonoDevelop.VersionControl.Git\MyersDiff.cs" /> <Compile Include="MonoDevelop.VersionControl.Git\GitSelectRevisionDialog.cs" /> + <Compile Include="AddinInfo.cs" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\..\..\core\Mono.Texteditor\Mono.TextEditor.csproj"> @@ -129,6 +130,11 @@ <Name>Xwt</Name> <Private>False</Private> </ProjectReference> + <ProjectReference Include="..\..\..\..\external\mono-addins\Mono.Addins\Mono.Addins.csproj"> + <Project>{91DD5A2D-9FE3-4C3C-9253-876141874DAD}</Project> + <Name>Mono.Addins</Name> + <Private>False</Private> + </ProjectReference> </ItemGroup> <ItemGroup> <EmbeddedResource Include="MonoDevelop.VersionControl.Git.addin.xml"> diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs index ae20d23e9b..384fd24dfa 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs @@ -1301,19 +1301,22 @@ namespace MonoDevelop.VersionControl.Git } } - public void CreateBranch (string name, string trackSource) + public void CreateBranchFromCommit (string name, RevCommit id) { - // If the user did not specify a branch to base the new local - // branch off, assume they want to create the new branch based - // on the current HEAD. - if (string.IsNullOrEmpty (trackSource)) - trackSource = Constants.HEAD; + var create = new NGit.Api.Git (RootRepository).BranchCreate (); + if (id != null) + create.SetStartPoint (id); + create.SetName (name); + create.Call (); + } - ObjectId headId = RootRepository.Resolve (trackSource); - RefUpdate updateRef = RootRepository.UpdateRef (Constants.R_HEADS + name); - updateRef.SetNewObjectId(headId); - updateRef.Update(); - GitUtil.SetUpstreamSource (RootRepository, name, trackSource); + public void CreateBranch (string name, string trackSource) + { + var create = new NGit.Api.Git (RootRepository).BranchCreate (); + if (!String.IsNullOrEmpty (trackSource)) + create.SetStartPoint (trackSource); + create.SetName (name); + create.Call (); } public void SetBranchTrackSource (string name, string trackSource) diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/StashManagerDialog.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/StashManagerDialog.cs index 7e6f25153a..b546e803fc 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/StashManagerDialog.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/StashManagerDialog.cs @@ -27,17 +27,22 @@ using Gtk; using MonoDevelop.Core; using MonoDevelop.Components; using MonoDevelop.Ide; +using NGit.Revwalk; +using NGit; namespace MonoDevelop.VersionControl.Git { partial class StashManagerDialog : Dialog { + readonly GitRepository repository; readonly ListStore store; readonly StashCollection stashes; public StashManagerDialog (GitRepository repo) { this.Build (); + repository = repo; + stashes = repo.GetStashes (); store = new ListStore (typeof(Stash), typeof(string), typeof(string)); @@ -88,6 +93,16 @@ namespace MonoDevelop.VersionControl.Git return (Stash) store.GetValue (it, 0); } + void ApplyStashAndRemove(Stash s) + { + using (IdeApp.Workspace.GetFileStatusTracker ()) { + GitService.ApplyStash (s).Completed += delegate(IAsyncOperation op) { + if (op.Success) + stashes.Remove (s); + }; + } + } + protected void OnButtonApplyClicked (object sender, System.EventArgs e) { Stash s = GetSelected (); @@ -99,6 +114,25 @@ namespace MonoDevelop.VersionControl.Git protected void OnButtonBranchClicked (object sender, System.EventArgs e) { + Stash s = GetSelected (); + if (s != null) { + var dlg = new EditBranchDialog (repository, null, true); + try { + if (MessageService.RunCustomDialog (dlg) == (int) ResponseType.Ok) { + ObjectId commit = repository.RootRepository.Resolve (s.CommitId); + var rw = new RevWalk (repository.RootRepository); + RevCommit c = rw.ParseCommit (commit); + RevCommit old = c.GetParent (0); + rw.ParseHeaders (old); + repository.CreateBranchFromCommit (dlg.BranchName, old); + GitService.SwitchToBranch (repository, dlg.BranchName); + ApplyStashAndRemove (s); + } + } finally { + dlg.Destroy (); + } + Respond (ResponseType.Ok); + } } protected void OnButtonDeleteClicked (object sender, System.EventArgs e) @@ -115,12 +149,7 @@ namespace MonoDevelop.VersionControl.Git { Stash s = GetSelected (); if (s != null) { - using (IdeApp.Workspace.GetFileStatusTracker ()) { - GitService.ApplyStash (s).Completed += delegate(IAsyncOperation op) { - if (op.Success) - stashes.Remove (s); - }; - } + ApplyStashAndRemove (s); Respond (ResponseType.Ok); } } diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/gtk-gui/MonoDevelop.VersionControl.Git.StashManagerDialog.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/gtk-gui/MonoDevelop.VersionControl.Git.StashManagerDialog.cs index 9e24913933..36bd326a0d 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/gtk-gui/MonoDevelop.VersionControl.Git.StashManagerDialog.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/gtk-gui/MonoDevelop.VersionControl.Git.StashManagerDialog.cs @@ -14,7 +14,7 @@ namespace MonoDevelop.VersionControl.Git private global::Gtk.HSeparator hseparator1; private global::Gtk.Button buttonDelete; private global::Gtk.Button buttonOk; - + protected virtual void Build () { global::Stetic.Gui.Initialize (this); @@ -134,6 +134,7 @@ namespace MonoDevelop.VersionControl.Git this.Show (); this.buttonApplyRemove.Clicked += new global::System.EventHandler (this.OnButtonApplyRemoveClicked); this.buttonApply.Clicked += new global::System.EventHandler (this.OnButtonApplyClicked); + this.buttonBranch.Clicked += new global::System.EventHandler (this.OnButtonBranchClicked); this.buttonDelete.Clicked += new global::System.EventHandler (this.OnButtonDeleteClicked); } } diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/gtk-gui/gui.stetic b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/gtk-gui/gui.stetic index dd7c961f0c..6a100b622c 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/gtk-gui/gui.stetic +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/gtk-gui/gui.stetic @@ -1678,6 +1678,7 @@ <property name="Type">TextOnly</property> <property name="Label" translatable="yes">Convert to Branch</property> <property name="UseUnderline">True</property> + <signal name="Clicked" handler="OnButtonBranchClicked" /> </widget> <packing> <property name="Position">2</property> diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/AddinInfo.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/AddinInfo.cs new file mode 100644 index 0000000000..29d0738d94 --- /dev/null +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/AddinInfo.cs @@ -0,0 +1,17 @@ + +using System; +using Mono.Addins; +using Mono.Addins.Description; + +[assembly:Addin ("VersionControl.Subversion.Unix", + Namespace = "MonoDevelop", + Version = MonoDevelop.BuildInfo.Version, + Category = "Version Control")] + +[assembly:AddinName ("Subversion support")] +[assembly:AddinDescription ("Subversion support for Linux and MacOSX")] + +[assembly:AddinDependency ("Core", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("Ide", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("VersionControl", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("VersionControl.Subversion", MonoDevelop.BuildInfo.Version)] diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix.addin.xml b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix.addin.xml index 8b87152077..98fc884cb6 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix.addin.xml +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix.addin.xml @@ -1,23 +1,9 @@ -<Addin id = "VersionControl.Subversion.Unix"
- namespace = "MonoDevelop"
- name = "Subversion support"
- author = "Joshua Tauberer, Lluis Sanchez"
- copyright = "LGPL"
- url = "http://taubz.for.net/code/diff"
- description = "Subversion support for Linux and MacOSX"
- category = "Version Control"
- version = "4.2.3">
-
- <Dependencies>
- <Addin id="Core" version="4.2.3"/>
- <Addin id="Ide" version="4.2.3"/>
- <Addin id="VersionControl" version="4.2.3"/>
- <Addin id="VersionControl.Subversion" version="4.2.3"/>
- </Dependencies>
+<ExtensionModel>
<Extension path = "/MonoDevelop/VersionControl/VersionControlSystems">
<Condition id="Platform" value="!windows">
<Class class = "MonoDevelop.VersionControl.Subversion.Unix.SvnClient" />
</Condition>
</Extension>
-</Addin>
+
+</ExtensionModel>
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix.csproj b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix.csproj index 50097c2fc9..8d478b0f44 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix.csproj +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix.csproj @@ -45,6 +45,7 @@ <Compile Include="MonoDevelop.VersionControl.Subversion.Unix\SvnClient.cs" /> <Compile Include="MonoDevelop.VersionControl.Subversion.Unix\LibSvnClient0.cs" /> <Compile Include="MonoDevelop.VersionControl.Subversion.Unix\LibSvnClient1.cs" /> + <Compile Include="AddinInfo.cs" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <ItemGroup> @@ -66,6 +67,11 @@ <Name>MonoDevelop.VersionControl</Name> <Private>False</Private> </ProjectReference> + <ProjectReference Include="..\..\..\..\external\mono-addins\Mono.Addins\Mono.Addins.csproj"> + <Project>{91DD5A2D-9FE3-4C3C-9253-876141874DAD}</Project> + <Name>Mono.Addins</Name> + <Private>False</Private> + </ProjectReference> </ItemGroup> <ItemGroup> <EmbeddedResource Include="MonoDevelop.VersionControl.Subversion.Unix.addin.xml"> diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix/SvnClient.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix/SvnClient.cs index 9a037ae202..a5d18760f6 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix/SvnClient.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix/SvnClient.cs @@ -1279,7 +1279,7 @@ namespace MonoDevelop.VersionControl.Subversion.Unix long totalProgress = total; if (totalProgress != -1 && currentProgress >= totalProgress) { - progressData.LogTimer.Close (); + progressData.LogTimer.Dispose (); return; } diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/AddinInfo.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/AddinInfo.cs new file mode 100644 index 0000000000..bfa933e395 --- /dev/null +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/AddinInfo.cs @@ -0,0 +1,17 @@ + +using System; +using Mono.Addins; +using Mono.Addins.Description; + +[assembly:Addin ("VersionControl.Subversion", + Namespace = "MonoDevelop", + Version = MonoDevelop.BuildInfo.Version, + Category = "Version Control")] + +[assembly:AddinName ("Subversion core engine")] +[assembly:AddinDescription ("Subversion core engine")] +[assembly:AddinFlags (AddinFlags.Hidden)] + +[assembly:AddinDependency ("Core", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("Ide", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("VersionControl", MonoDevelop.BuildInfo.Version)] diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.addin.xml b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.addin.xml deleted file mode 100644 index 139b7d3533..0000000000 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.addin.xml +++ /dev/null @@ -1,17 +0,0 @@ -<Addin id = "VersionControl.Subversion"
- namespace = "MonoDevelop"
- name = "Subversion core engine"
- author = "Joshua Tauberer"
- copyright = "LGPL"
- url = "http://taubz.for.net/code/diff"
- description = "Subversion core engine"
- category = "Version Control"
- flags = "Hidden"
- version = "4.2.3">
-
- <Dependencies>
- <Addin id="Core" version="4.2.3"/>
- <Addin id="Ide" version="4.2.3"/>
- <Addin id="VersionControl" version="4.2.3"/>
- </Dependencies>
-</Addin>
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.csproj b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.csproj index 27094361c1..2b3ead87ff 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.csproj +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.csproj @@ -65,6 +65,11 @@ <Name>ICSharpCode.NRefactory</Name> <Private>False</Private> </ProjectReference> + <ProjectReference Include="..\..\..\..\external\mono-addins\Mono.Addins\Mono.Addins.csproj"> + <Project>{91DD5A2D-9FE3-4C3C-9253-876141874DAD}</Project> + <Name>Mono.Addins</Name> + <Private>False</Private> + </ProjectReference> </ItemGroup> <ItemGroup> <Reference Include="Mono.Posix" /> @@ -100,6 +105,7 @@ <Compile Include="gtk-gui\MonoDevelop.VersionControl.Subversion.Gui.UserPasswordDialog.cs" /> <Compile Include="AssemblyInfo.cs" /> <Compile Include="MonoDevelop.VersionControl.Subversion\SvnRevision.cs" /> + <Compile Include="AddinInfo.cs" /> </ItemGroup> <ItemGroup> <None Include="Makefile.am" /> @@ -111,9 +117,6 @@ <EmbeddedResource Include="gtk-gui\gui.stetic"> <LogicalName>gui.stetic</LogicalName> </EmbeddedResource> - <EmbeddedResource Include="MonoDevelop.VersionControl.Subversion.addin.xml"> - <LogicalName>MonoDevelop.VersionControl.Subversion.addin.xml</LogicalName> - </EmbeddedResource> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <ItemGroup> diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/AddinInfo.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/AddinInfo.cs new file mode 100644 index 0000000000..64026895ad --- /dev/null +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/AddinInfo.cs @@ -0,0 +1,17 @@ + +using System; +using Mono.Addins; +using Mono.Addins.Description; + +[assembly:Addin ("VersionControl", + Namespace = "MonoDevelop", + Version = MonoDevelop.BuildInfo.Version, + Category = "Version Control")] + +[assembly:AddinName ("Version Control Support")] +[assembly:AddinDescription ("A MonoDevelop addin for using version control systems like Subversion")] +[assembly:AddinFlags (AddinFlags.Hidden)] + +[assembly:AddinDependency ("Core", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("Ide", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("SourceEditor2", MonoDevelop.BuildInfo.Version)] diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/ChangeSetView.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/ChangeSetView.cs index 4b97aed600..2e76febb93 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/ChangeSetView.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/ChangeSetView.cs @@ -292,9 +292,12 @@ namespace MonoDevelop.VersionControl.Views return; else if (files.Length == 1) { TreePath[] rows = filelist.Selection.GetSelectedRows (); - int line = -1; - if (rows.Length == 1 && rows [0].Depth == 2) - line = diffRenderer.GetSelectedLine (rows[0]); + int line = 1; + if (rows.Length == 1 && rows [0].Depth == 2) { + line = diffRenderer.GetSelectedLine (rows [0]); + if (line == -1) + line = 1; + } IdeApp.Workbench.OpenDocument (files [0], line, 0); } else { diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/LogWidget.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/LogWidget.cs index 0ba1857191..8bbdcdddaa 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/LogWidget.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/LogWidget.cs @@ -319,6 +319,8 @@ namespace MonoDevelop.VersionControl.Views string fileName = (string)changedpathstore.GetValue (iter, colPath); int line = diffRenderer.GetSelectedLine (paths[0]); + if (line == -1) + line = 1; var doc = IdeApp.Workbench.OpenDocument (fileName, line, 0, OpenDocumentOptions.Default | OpenDocumentOptions.OnlyInternalViewer); int i = 1; foreach (var content in doc.Window.SubViewContents) { diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/StatusView.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/StatusView.cs index 8e97b47f42..4054804f17 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/StatusView.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/StatusView.cs @@ -889,9 +889,12 @@ namespace MonoDevelop.VersionControl.Views return; else if (files.Length == 1) { TreePath[] rows = filelist.Selection.GetSelectedRows (); - int line = -1; - if (rows.Length == 1 && rows [0].Depth == 2) - line = diffRenderer.GetSelectedLine (rows[0]); + int line = 1; + if (rows.Length == 1 && rows [0].Depth == 2) { + line = diffRenderer.GetSelectedLine (rows [0]); + if (line == -1) + line = 1; + } IdeApp.Workbench.OpenDocument (files [0], line, 0); } else { diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.csproj b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.csproj index d50401bd13..cf3891b785 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.csproj +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.csproj @@ -276,6 +276,7 @@ <Compile Include="MonoDevelop.VersionControl\ResolveConflictsCommand.cs" /> <Compile Include="MonoDevelop.VersionControl.Dialogs\VersionControlGeneralOptionsPanel.cs" /> <Compile Include="MonoDevelop.VersionControl.Dialogs\VersionControlSolutionOptionsPanel.cs" /> + <Compile Include="AddinInfo.cs" /> </ItemGroup> <ItemGroup> <None Include="Makefile.am" /> diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlNodeExtension.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlNodeExtension.cs index 6c8fbd77c5..ca41fbf61a 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlNodeExtension.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlNodeExtension.cs @@ -24,20 +24,17 @@ namespace MonoDevelop.VersionControl || typeof(SystemFile).IsAssignableFrom (dataType)
|| typeof(ProjectFolder).IsAssignableFrom (dataType)
|| typeof(IWorkspaceObject).IsAssignableFrom (dataType);
- } - - public VersionControlNodeExtension () - { - VersionControlService.FileStatusChanged += Monitor; }
protected override void Initialize ()
{
base.Initialize ();
+ VersionControlService.FileStatusChanged += Monitor;
}
public override void Dispose ()
{
+ VersionControlService.FileStatusChanged -= Monitor;
base.Dispose ();
}
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml b/main/src/addins/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml index 0985ccc52b..781c21279d 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml @@ -1,19 +1,4 @@ -<Addin id = "VersionControl" - namespace = "MonoDevelop" - name = "Version Control Support" - author = "Joshua Tauberer" - copyright = "LGPL" - url = "http://taubz.for.net/code/diff" - description = "A MonoDevelop addin for using version control systems like Subversion" - category = "Version Control" - flags = "Hidden" - version = "4.2.3"> - - <Dependencies> - <Addin id="Core" version="4.2.3"/> - <Addin id="Ide" version="4.2.3"/> - <Addin id="SourceEditor2" version="4.2.3"/> - </Dependencies> +<ExtensionModel> <ExtensionPoint path = "/MonoDevelop/VersionControl/VersionControlSystems" name = "Version control systems"> <Description>Version control systems</Description> @@ -339,4 +324,4 @@ <Migration sourceVersion="2.6+" kind="Cache" path="version-control-commit-msg" /> <Migration sourceVersion="2.6+" kind="Config" path="VersionControl.config" /> </Extension> -</Addin> +</ExtensionModel> diff --git a/main/src/addins/VersionControl/Subversion.Win32/AddinInfo.cs b/main/src/addins/VersionControl/Subversion.Win32/AddinInfo.cs new file mode 100644 index 0000000000..94dc9bba55 --- /dev/null +++ b/main/src/addins/VersionControl/Subversion.Win32/AddinInfo.cs @@ -0,0 +1,17 @@ + +using System; +using Mono.Addins; +using Mono.Addins.Description; + +[assembly:Addin ("VersionControl.Subversion.Windows", + Namespace = "MonoDevelop", + Version = MonoDevelop.BuildInfo.Version, + Category = "Version Control")] + +[assembly:AddinName ("Subversion support")] +[assembly:AddinDescription ("Subversion support for Windows")] + +[assembly:AddinDependency ("Core", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("Ide", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("VersionControl", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("VersionControl.Subversion", MonoDevelop.BuildInfo.Version)] diff --git a/main/src/addins/VersionControl/Subversion.Win32/Manifest.addin.xml b/main/src/addins/VersionControl/Subversion.Win32/Manifest.addin.xml index f4ef78d8f8..5c366d9262 100644 --- a/main/src/addins/VersionControl/Subversion.Win32/Manifest.addin.xml +++ b/main/src/addins/VersionControl/Subversion.Win32/Manifest.addin.xml @@ -1,22 +1,4 @@ -<Addin id = "SubversionAddinWindows"
- namespace = "MonoDevelop"
- version = "4.2.3">
- <Header>
- <Name>Subversion Add-in</Name>
- <Description>Subversion support for the Version Control Add-in</Description>
- <Description locale="ca">Suport per a Subversion</Description>
- <Icon32>subversion-logo.png</Icon32>
- <Author>Lluis Sanchez</Author>
- <Copyright>GPL</Copyright>
- <Category>Version Control</Category>
- </Header>
-
- <Dependencies>
- <Addin id="Core" version="4.2.3"/>
- <Addin id="Ide" version="4.2.3"/>
- <Addin id="VersionControl" version="4.2.3"/>
- <Addin id="VersionControl.Subversion" version="4.2.3"/>
- </Dependencies>
+<ExtensionModel>
<!-- Some files are excluded twice. This is on purpose to work around some case sensivity issues. If you change this you break addin installation on windows -->
<Runtime>
@@ -31,4 +13,5 @@ <Extension path = "/MonoDevelop/VersionControl/VersionControlSystems">
<Class class = "SubversionAddinWindows.SvnSharpClient" />
</Extension>
-</Addin>
+
+</ExtensionModel>
diff --git a/main/src/addins/VersionControl/Subversion.Win32/SvnSharpClient.cs b/main/src/addins/VersionControl/Subversion.Win32/SvnSharpClient.cs index 4eed6651bf..6690d055ba 100644 --- a/main/src/addins/VersionControl/Subversion.Win32/SvnSharpClient.cs +++ b/main/src/addins/VersionControl/Subversion.Win32/SvnSharpClient.cs @@ -657,7 +657,7 @@ namespace SubversionAddinWindows long totalProgress = e.TotalProgress;
if (totalProgress != -1 && currentProgress >= totalProgress) {
- data.LogTimer.Close ();
+ data.LogTimer.Dispose ();
return;
}
diff --git a/main/src/addins/VersionControl/Subversion.Win32/VersionControl.Subversion.Win32.csproj b/main/src/addins/VersionControl/Subversion.Win32/VersionControl.Subversion.Win32.csproj index e138e4825d..40172b23a7 100644 --- a/main/src/addins/VersionControl/Subversion.Win32/VersionControl.Subversion.Win32.csproj +++ b/main/src/addins/VersionControl/Subversion.Win32/VersionControl.Subversion.Win32.csproj @@ -66,6 +66,7 @@ <ItemGroup> <Compile Include="SvnSharpClient.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="AddinInfo.cs" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="Manifest.addin.xml" /> @@ -119,6 +120,11 @@ <Name>MonoDevelop.VersionControl.Subversion</Name> <Private>False</Private> </ProjectReference> + <ProjectReference Include="..\..\..\..\external\mono-addins\Mono.Addins\Mono.Addins.csproj"> + <Project>{91DD5A2D-9FE3-4C3C-9253-876141874DAD}</Project> + <Name>Mono.Addins</Name> + <Private>False</Private> + </ProjectReference> </ItemGroup> <ItemGroup> <None Include="..\..\..\..\external\sharpsvn-binary\SharpPlink-Win32.svnExe"> diff --git a/main/src/addins/WindowsPlatform/AddinInfo.cs b/main/src/addins/WindowsPlatform/AddinInfo.cs new file mode 100644 index 0000000000..5e380e8435 --- /dev/null +++ b/main/src/addins/WindowsPlatform/AddinInfo.cs @@ -0,0 +1,13 @@ + +using Mono.Addins; + +[assembly:Addin ("WindowsPlatform", + Namespace = "MonoDevelop", + Version = MonoDevelop.BuildInfo.Version, + Category = "Platform Support")] + +[assembly:AddinName ("MonoDevelop Windows Platform Support")] +[assembly:AddinDescription ("Windows Platform Support for MonoDevelop")] + +[assembly:AddinDependency ("Core", MonoDevelop.BuildInfo.Version)] +[assembly:AddinDependency ("Ide", MonoDevelop.BuildInfo.Version)] diff --git a/main/src/addins/WindowsPlatform/WindowsPlatform.addin.xml b/main/src/addins/WindowsPlatform/WindowsPlatform.addin.xml index d04df8a99e..9339f30ebd 100644 --- a/main/src/addins/WindowsPlatform/WindowsPlatform.addin.xml +++ b/main/src/addins/WindowsPlatform/WindowsPlatform.addin.xml @@ -1,22 +1,4 @@ -<Addin id = "WindowsPlatform"
- namespace = "MonoDevelop"
- name = "MonoDevelop Windows Platform Support"
- author = "Jonathan Pobst"
- copyright = "MIT X11"
- url = "http://monodevelop.com/"
- description = "Windows Platform Support for MonoDevelop"
- category = "Platform Support"
- version = "4.2.3">
-
- <Runtime>
- <Import assembly="WindowsPlatform.dll"/>
- </Runtime>
-
- <Dependencies>
- <Addin id="Core" version="4.2.3"/>
- <Addin id="Ide" version="4.2.3"/>
- </Dependencies>
-
+<ExtensionModel>
<Extension path = "/MonoDevelop/Core/PlatformService">
<Class class = "MonoDevelop.Platform.WindowsPlatform"/>
@@ -41,4 +23,4 @@ </Extension>
-->
-</Addin>
+</ExtensionModel>
diff --git a/main/src/addins/WindowsPlatform/WindowsPlatform.csproj b/main/src/addins/WindowsPlatform/WindowsPlatform.csproj index e3bc7c4c06..60e9b30d85 100644 --- a/main/src/addins/WindowsPlatform/WindowsPlatform.csproj +++ b/main/src/addins/WindowsPlatform/WindowsPlatform.csproj @@ -65,6 +65,11 @@ <Name>MonoDevelop.Ide</Name> <Private>False</Private> </ProjectReference> + <ProjectReference Include="..\..\..\external\mono-addins\Mono.Addins\Mono.Addins.csproj"> + <Project>{91DD5A2D-9FE3-4C3C-9253-876141874DAD}</Project> + <Name>Mono.Addins</Name> + <Private>False</Private> + </ProjectReference> </ItemGroup> <ItemGroup> <Compile Include="Dialogs\CustomAddFilesDialog.cs"> @@ -109,6 +114,7 @@ <SubType>Form</SubType> </Compile> <Compile Include="WindowsSecureStoragePasswordProvider.cs" /> + <Compile Include="AddinInfo.cs" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="Dialogs\CustomAddFilesDialog.resx"> diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/TextEditorData.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/TextEditorData.cs index e6291178b9..c61b532a33 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor/TextEditorData.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/TextEditorData.cs @@ -1242,6 +1242,10 @@ namespace Mono.TextEditor } } var insertedChars = Insert (offset, text); + if (options.GenerateFormattingUndoStep) { + undoGroup.Dispose (); + undoGroup = OpenUndoGroup (); + } if (Paste != null) Paste (offset, text, insertedChars); return insertedChars; diff --git a/main/src/core/MonoDevelop.Core/BuildVariables.cs b/main/src/core/MonoDevelop.Core/BuildVariables.cs deleted file mode 100644 index 0bdb6b1e3e..0000000000 --- a/main/src/core/MonoDevelop.Core/BuildVariables.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace MonoDevelop -{ - public static class BuildInfo - { - public const string Version = "4.2.3"; - public const string VersionLabel = "4.2.3"; - public const string CompatVersion = "4.0"; - } -} - diff --git a/main/src/core/MonoDevelop.Core/BuildVariables.gen.cs b/main/src/core/MonoDevelop.Core/BuildVariables.gen.cs new file mode 100644 index 0000000000..4dc0f82825 --- /dev/null +++ b/main/src/core/MonoDevelop.Core/BuildVariables.gen.cs @@ -0,0 +1,27 @@ +using System; +using System.IO; +using System.Linq; + +namespace Application +{ + public class GenVersion + { + public static void Main (string[] args) + { + var dir = args [0]; + var lines = File.ReadAllLines (Path.Combine (dir, "..", "..", "..", "..", "version.config")); + var txt = File.ReadAllText (Path.Combine (dir, "BuildVariables.cs.in")); + txt = txt.Replace ("@PACKAGE_VERSION@", GetValue (lines, "Version")); + txt = txt.Replace ("@PACKAGE_VERSION_LABEL@", GetValue (lines, "Label")); + txt = txt.Replace ("@COMPAT_ADDIN_VERSION@", GetValue (lines, "CompatVersion")); + File.WriteAllText (Path.Combine (dir, "BuildVariables.cs"), txt); + } + + static string GetValue (string[] lines, string key) + { + var val = lines.First (li => li.StartsWith (key + "=")); + return val.Substring (key.Length + 1); + } + } +} + diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj index cb6fdd99ea..2e2c68d050 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj @@ -3,7 +3,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>9.0.21022</ProductVersion> + <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{7525BB88-6142-4A26-93B9-A30C6983390A}</ProjectGuid> <OutputType>Library</OutputType> @@ -11,6 +11,7 @@ <RootNamespace>MonoDevelop.Core</RootNamespace> <BuildInfo>..\..\..\build\bin\buildinfo</BuildInfo> <VcRevision>..\..\..\vcrevision</VcRevision> + <MonoLauncher Condition=" '$(VisualStudioVersion)' == '' ">mono </MonoLauncher> </PropertyGroup> <Choose> <When Condition=" Exists('c:\Program Files\Git\bin\git.exe') "> @@ -559,4 +560,9 @@ <ItemGroup> <Folder Include="MonoDevelop.Core.Web\" /> </ItemGroup> + <Target Name="BeforeBuild" Inputs="BuildVariables.cs.in; $(MSBuildProjectDirectory)\..\..\..\..\version.txt" Outputs="BuildVariables.cs"> + <Csc Sources="BuildVariables.gen.cs" OutputAssembly="BuildVariables.gen.exe" /> + <Exec Command="$(MonoLauncher)$(MSBuildProjectDirectory)\BuildVariables.gen.exe ." WorkingDirectory="$(MSBuildProjectDirectory)"/> + <Delete Files="BuildVariables.gen.exe" /> + </Target> </Project> diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/MSBuildProjectHandler.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/MSBuildProjectHandler.cs index a1a80ed621..0055641f4e 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/MSBuildProjectHandler.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/MSBuildProjectHandler.cs @@ -1230,7 +1230,7 @@ namespace MonoDevelop.Projects.Formats.MSBuild // Remove old items Dictionary<string,ItemInfo> oldItems = new Dictionary<string, ItemInfo> (); foreach (MSBuildItem item in msproject.GetAllItems ()) - oldItems [item.Name + "<" + item.Include] = new ItemInfo () { Item=item }; + oldItems [item.Name + "<" + item.Include + "<" + item.Condition] = new ItemInfo () { Item=item }; // Add the new items foreach (object ob in ((SolutionEntityItem)Item).Items.Concat (((SolutionEntityItem)Item).WildcardItems)) @@ -1394,7 +1394,7 @@ namespace MonoDevelop.Projects.Formats.MSBuild if ((file.Subtype == Subtype.Directory) && path[path.Length-1] != '\\') path = path + "\\"; - MSBuildItem buildItem = AddOrGetBuildItem (msproject, oldItems, itemName, path); + MSBuildItem buildItem = AddOrGetBuildItem (msproject, oldItems, itemName, path, file.Condition); WriteBuildItemMetadata (ser, buildItem, file, oldItems); if (!string.IsNullOrEmpty (file.DependsOn)) @@ -1476,7 +1476,7 @@ namespace MonoDevelop.Projects.Formats.MSBuild if (asm == null) asm = Path.GetFileNameWithoutExtension (pref.Reference); - buildItem = AddOrGetBuildItem (msproject, oldItems, "Reference", asm); + buildItem = AddOrGetBuildItem (msproject, oldItems, "Reference", asm, pref.Condition); if (!pref.SpecificVersion && ReferenceStringHasVersion (asm)) { buildItem.SetMetadata ("SpecificVersion", "False"); @@ -1494,7 +1494,7 @@ namespace MonoDevelop.Projects.Formats.MSBuild if (i != -1) include = include.Substring (0, i).Trim (); } - buildItem = AddOrGetBuildItem (msproject, oldItems, "Reference", include); + buildItem = AddOrGetBuildItem (msproject, oldItems, "Reference", include, pref.Condition); if (!pref.SpecificVersion && ReferenceStringHasVersion (include)) buildItem.SetMetadata ("SpecificVersion", "False"); else @@ -1523,7 +1523,7 @@ namespace MonoDevelop.Projects.Formats.MSBuild else if (pref.ReferenceType == ReferenceType.Project) { Project refProj = Item.ParentSolution.FindProjectByName (pref.Reference); if (refProj != null) { - buildItem = AddOrGetBuildItem (msproject, oldItems, "ProjectReference", MSBuildProjectService.ToMSBuildPath (Item.ItemDirectory, refProj.FileName)); + buildItem = AddOrGetBuildItem (msproject, oldItems, "ProjectReference", MSBuildProjectService.ToMSBuildPath (Item.ItemDirectory, refProj.FileName), pref.Condition); MSBuildProjectHandler handler = refProj.ItemHandler as MSBuildProjectHandler; if (handler != null) buildItem.SetMetadata ("Project", handler.Item.ItemId); @@ -1538,7 +1538,7 @@ namespace MonoDevelop.Projects.Formats.MSBuild else { // Custom DataType dt = ser.DataContext.GetConfigurationDataType (pref.GetType ()); - buildItem = AddOrGetBuildItem (msproject, oldItems, dt.Name, pref.Reference); + buildItem = AddOrGetBuildItem (msproject, oldItems, dt.Name, pref.Reference, pref.Condition); } if (pref.LocalCopy != pref.DefaultLocalCopy) @@ -1600,10 +1600,10 @@ namespace MonoDevelop.Projects.Formats.MSBuild buildItem.UnsetMetadata (prop); } - MSBuildItem AddOrGetBuildItem (MSBuildProject msproject, Dictionary<string,ItemInfo> oldItems, string name, string include) + MSBuildItem AddOrGetBuildItem (MSBuildProject msproject, Dictionary<string,ItemInfo> oldItems, string name, string include, string condition) { ItemInfo itemInfo; - string key = name + "<" + include; + string key = name + "<" + include + "<" + condition; if (oldItems.TryGetValue (key, out itemInfo)) { if (!itemInfo.Added) { itemInfo.Added = true; diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/SlnFileFormat.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/SlnFileFormat.cs index e9c4e3f87e..711320c68e 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/SlnFileFormat.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/SlnFileFormat.cs @@ -53,7 +53,7 @@ namespace MonoDevelop.Projects.Formats.MSBuild public bool CanReadFile (string file, MSBuildFileFormat format) { - if (String.Compare (Path.GetExtension (file), ".sln", true) == 0) { + if (String.Compare (Path.GetExtension (file), ".sln", StringComparison.OrdinalIgnoreCase) == 0) { string tmp; string version = GetSlnFileVersion (file, out tmp); return format.SupportsSlnVersion (version); @@ -122,13 +122,14 @@ namespace MonoDevelop.Projects.Formats.MSBuild slnData.UpdateVersion (format); sw.WriteLine (); + //Write Header sw.WriteLine ("Microsoft Visual Studio Solution File, Format Version " + slnData.VersionString); sw.WriteLine (slnData.HeaderComment); if (slnData.VisualStudioVersion != null) - sw.WriteLine ("VisualStudioVersion = {0}"); + sw.WriteLine ("VisualStudioVersion = {0}", slnData.VisualStudioVersion); if (slnData.MinimumVisualStudioVersion != null) - sw.WriteLine ("MinimumVisualStudioVersion = {0}"); + sw.WriteLine ("MinimumVisualStudioVersion = {0}", slnData.MinimumVisualStudioVersion); //Write the projects monitor.BeginTask (GettextCatalog.GetString ("Saving projects"), 1); @@ -704,13 +705,19 @@ namespace MonoDevelop.Projects.Formats.MSBuild } if (s.StartsWith ("VisualStudioVersion = ", StringComparison.Ordinal)) { - var v = Version.Parse (s.Substring ("VisualStudioVersion = ".Length)); - data.VisualStudioVersion = v; + Version v; + if (Version.TryParse (s.Substring ("VisualStudioVersion = ".Length), out v)) + data.VisualStudioVersion = v; + else + monitor.Log.WriteLine ("Ignoring unparseable VisualStudioVersion value in sln file"); } if (s.StartsWith ("MinimumVisualStudioVersion = ", StringComparison.Ordinal)) { - var v = Version.Parse (s.Substring ("MinimumVisualStudioVersion = ".Length)); - data.MinimumVisualStudioVersion = v; + Version v; + if (Version.TryParse (s.Substring ("MinimumVisualStudioVersion = ".Length), out v)) + data.MinimumVisualStudioVersion = v; + else + monitor.Log.WriteLine ("Ignoring unparseable MinimumVisualStudioVersion value in sln file"); } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Extensions/IExtendedTitleBarWindowBackend.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Extensions/IExtendedTitleBarWindowBackend.cs new file mode 100644 index 0000000000..4d10b5a24c --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Extensions/IExtendedTitleBarWindowBackend.cs @@ -0,0 +1,66 @@ +// +// IExtendedTitleBarWindowBackend.cs +// +// Author: +// Lluis Sanchez Gual <lluis@xamarin.com> +// +// Copyright (c) 2014 Xamarin, Inc (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using Xwt.Backends; +using Xwt.GtkBackend; + +namespace MonoDevelop.Components.Extensions +{ + public interface IExtendedTitleBarWindowBackend: IWindowBackend + { + void SetHeaderContent (IWidgetBackend backend); + } + + class GtkExtendedTitleBarWindowBackend: WindowBackend, IExtendedTitleBarWindowBackend + { + HeaderBox toolbar; + + public override void Initialize () + { + base.Initialize (); + toolbar = new HeaderBox (); + toolbar.GradientBackround = true; + toolbar.SetMargins (0, 1, 0, 0); + MainBox.PackStart (toolbar, false, false, 0); + ((Gtk.Box.BoxChild)MainBox [toolbar]).Position = 0; + } + + public void SetHeaderContent (IWidgetBackend backend) + { + if (toolbar.Child != null) { + WidgetBackend.RemoveChildPlacement (toolbar.Child); + toolbar.Remove (toolbar.Child); + } + if (backend != null) { + toolbar.Child = WidgetBackend.GetWidgetWithPlacement (backend); + toolbar.Show (); + } else { + toolbar.Hide (); + } + } + } +} + diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbar.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbar.cs index 5116cbade3..8264aebd58 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbar.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbar.cs @@ -299,10 +299,7 @@ namespace MonoDevelop.Components.MainToolbar BuildToolbar (); IdeApp.CommandService.RegisterCommandBar (buttonBar); - AddinManager.ExtensionChanged += delegate(object sender, ExtensionEventArgs args) { - if (args.PathChanged (ToolbarExtensionPath)) - BuildToolbar (); - }; + AddinManager.ExtensionChanged += OnExtensionChanged; contentBox.PackStart (matchEntry, false, false, 0); @@ -328,6 +325,12 @@ namespace MonoDevelop.Components.MainToolbar this.ShowAll (); this.statusArea.statusIconBox.HideAll (); } + + void OnExtensionChanged (object sender, ExtensionEventArgs args) + { + if (args.PathChanged (ToolbarExtensionPath)) + BuildToolbar (); + } protected override bool OnButtonPressEvent (Gdk.EventButton evnt) { @@ -896,6 +899,7 @@ namespace MonoDevelop.Components.MainToolbar { base.OnDestroyed (); + AddinManager.ExtensionChanged -= OnExtensionChanged; if (Background != null) { ((IDisposable)Background).Dispose (); Background = null; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ExtendedTitleBarWindow.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ExtendedTitleBarWindow.cs new file mode 100644 index 0000000000..f17c129618 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ExtendedTitleBarWindow.cs @@ -0,0 +1,54 @@ +// +// ExtendedTitleBarWindow.cs +// +// Author: +// Lluis Sanchez Gual <lluis@xamarin.com> +// +// Copyright (c) 2014 Xamarin, Inc (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using Xwt; +using Xwt.Backends; +using MonoDevelop.Components.Extensions; + +namespace MonoDevelop.Components +{ + [BackendType (typeof(IExtendedTitleBarWindowBackend))] + public class ExtendedTitleBarWindow: Xwt.Window + { + Widget content; + + public ExtendedTitleBarWindow () + { + } + + IExtendedTitleBarWindowBackend Backend { + get { return (IExtendedTitleBarWindowBackend) BackendHost.Backend; } + } + + public Widget HeaderContent { + get { return content; } + set { + content = value; + Backend.SetHeaderContent (content.GetBackend ()); + } + } + } +} diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TypeSystemService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TypeSystemService.cs index 4761bbea8d..002ea082c4 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TypeSystemService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TypeSystemService.cs @@ -1572,7 +1572,7 @@ namespace MonoDevelop.Ide.TypeSystem var contexts = new List<IAssemblyReference> (); var nonCyclicCache = new HashSet<Project> (); foreach (var referencedWrapper in referencedWrappers) { - referencedWrapper.Loaded += HandleReferencedProjectInLoadChange; + referencedWrapper.Loaded -= HandleReferencedProjectInLoadChange; } var newReferencedWrappers = new List<ProjectContentWrapper>(); foreach (var referencedProject in ReferencedProjects) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj index 2ae10dcb3e..f3c2b893ce 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj @@ -3,7 +3,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>9.0.21022</ProductVersion> + <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{27096E7F-C91C-4AC6-B289-6897A701DF21}</ProjectGuid> <OutputType>Library</OutputType> @@ -1905,6 +1905,8 @@ <Compile Include="MonoDevelop.Ide.Projects.OptionPanels\CombineMSBuildOptions.cs" /> <Compile Include="MonoDevelop.Ide.Gui\PadCollection.cs" /> <Compile Include="MonoDevelop.Ide.Extensions\IdeCustomizer.cs" /> + <Compile Include="MonoDevelop.Components\ExtendedTitleBarWindow.cs" /> + <Compile Include="MonoDevelop.Components.Extensions\IExtendedTitleBarWindowBackend.cs" /> </ItemGroup> <ItemGroup> <None Include="Makefile.am" /> diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs index 2678b04900..c16c7c230a 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs @@ -50,6 +50,7 @@ using MonoDevelop.Core.Instrumentation; using System.Diagnostics; using System.Collections.Generic; using MonoDevelop.Ide.Extensions; +using MonoDevelop.Components.Extensions; namespace MonoDevelop.Ide { @@ -103,9 +104,11 @@ namespace MonoDevelop.Ide LoggingService.LogInfo ("Using GTK+ {0}", IdeVersionInfo.GetGtkVersion ()); + // XWT initialization FilePath p = typeof(IdeStartup).Assembly.Location; Assembly.LoadFrom (p.ParentDirectory.Combine ("Xwt.Gtk.dll")); Xwt.Application.InitializeAsGuest (Xwt.ToolkitType.Gtk); + Xwt.Toolkit.CurrentEngine.RegisterBackend<IExtendedTitleBarWindowBackend,GtkExtendedTitleBarWindowBackend> (); //default to Windows IME on Windows if (Platform.IsWindows && Mono.TextEditor.GtkWorkarounds.GtkMinorVersion >= 16) { @@ -223,7 +226,7 @@ namespace MonoDevelop.Ide Exception error = null; int reportedFailures = 0; - + try { Counters.Initialization.Trace ("Loading Icons"); //force initialisation before the workbench so that it can register stock icons for GTK before they get requested @@ -292,19 +295,49 @@ namespace MonoDevelop.Ide Counters.Initialization.EndTiming (); AddinManager.AddExtensionNodeHandler("/MonoDevelop/Ide/InitCompleteHandlers", OnExtensionChanged); - + StartLockupTracker (); IdeApp.Run (); // unloading services if (null != socket_filename) File.Delete (socket_filename); - + lockupCheckRunning = false; Runtime.Shutdown (); InstrumentationService.Stop (); + AddinManager.AddinLoadError -= OnAddinError; return 0; } + static DateTime lastIdle; + static bool lockupCheckRunning = true; + + static void StartLockupTracker () + { + if (Platform.IsWindows) + return; + GLib.Idle.Add (() => { + lastIdle = DateTime.Now; + return true; + }); + lastIdle = DateTime.Now; + var lockupCheckThread = new Thread (delegate () { + while (lockupCheckRunning) { + const int waitTimeout = 2000; + const int maxResponseTime = 5000; + Thread.Sleep (waitTimeout); + if ((DateTime.Now - lastIdle).TotalMilliseconds > maxResponseTime) { + var pid = Process.GetCurrentProcess ().Id; + Mono.Unix.Native.Syscall.kill (pid, Mono.Unix.Native.Signum.SIGQUIT); + return; + } + } + }); + lockupCheckThread.Name = "Lockup check"; + lockupCheckThread.IsBackground = true; + lockupCheckThread.Start (); + } + void SetupTheme () { // Use the bundled gtkrc only if the Xamarin theme is installed @@ -520,7 +553,7 @@ namespace MonoDevelop.Ide } } - void SetupExceptionManager () + static void SetupExceptionManager () { System.Threading.Tasks.TaskScheduler.UnobservedTaskException += (sender, e) => { HandleException (e.Exception.Flatten (), false); @@ -537,7 +570,7 @@ namespace MonoDevelop.Ide }; } - void HandleException (Exception ex, bool willShutdown) + static void HandleException (Exception ex, bool willShutdown) { var msg = String.Format ("An unhandled exception has occured. Terminating MonoDevelop? {0}", willShutdown); diff --git a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/BuildEngine.v4.0.cs b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/BuildEngine.v4.0.cs index ce6786a00c..6e2db2895f 100644 --- a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/BuildEngine.v4.0.cs +++ b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/BuildEngine.v4.0.cs @@ -49,7 +49,6 @@ namespace MonoDevelop.Projects.Formats.MSBuild static Exception workError;
ManualResetEvent doneEvent = new ManualResetEvent (false);
- Dictionary<string,ProjectCollection> engines = new Dictionary<string, ProjectCollection> ();
Dictionary<string, string> unsavedProjects = new Dictionary<string, string> ();
ProjectCollection engine; @@ -124,25 +123,6 @@ namespace MonoDevelop.Projects.Formats.MSBuild return engine;
}
- ProjectCollection GetEngine (string binDir)
- {
- ProjectCollection engine = null;
- RunSTA (delegate {
- if (!engines.TryGetValue (binDir, out engine)) {
- engine = new ProjectCollection ();
- engine.DefaultToolsVersion = MSBuildConsts.Version;
- engine.SetGlobalProperty ("BuildingInsideVisualStudio", "true");
-
- //we don't have host compilers in MD, and this is set to true by some of the MS targets
- //which causes it to always run the CoreCompile task if BuildingInsideVisualStudio is also
- //true, because the VS in-process compiler would take care of the deps tracking
- engine.SetGlobalProperty ("UseHostCompilerIfAvailable", "false");
- engines [binDir] = engine;
- }
- });
- return engine;
- }
-
internal void UnloadProject (string file)
{
lock (unsavedProjects)
@@ -150,27 +130,25 @@ namespace MonoDevelop.Projects.Formats.MSBuild RunSTA (delegate
{
- foreach (var engine in engines.Values) {
- //unloading projects modifies the collection, so copy it
- var projects = engine.GetLoadedProjects (file).ToArray ();
+ //unloading projects modifies the collection, so copy it
+ var projects = engine.GetLoadedProjects (file).ToArray ();
- if (projects.Length == 0) {
- return;
- }
+ if (projects.Length == 0) {
+ return;
+ }
- var rootElement = projects[0].Xml;
+ var rootElement = projects[0].Xml;
- foreach (var p in projects) {
- engine.UnloadProject (p);
- }
+ foreach (var p in projects) {
+ engine.UnloadProject (p);
+ }
- //try to unload the projects' XML from the cache
- try {
- engine.UnloadProject (rootElement);
- } catch (InvalidOperationException) {
- // This could fail if something else is referencing the xml somehow.
- // But not a big deal, it's just a cache.
- }
+ //try to unload the projects' XML from the cache
+ try {
+ engine.UnloadProject (rootElement);
+ } catch (InvalidOperationException) {
+ // This could fail if something else is referencing the xml somehow.
+ // But not a big deal, it's just a cache.
}
});
}
diff --git a/main/tests/TestRunner/AddinInfo.cs b/main/tests/TestRunner/AddinInfo.cs new file mode 100644 index 0000000000..3f432f5738 --- /dev/null +++ b/main/tests/TestRunner/AddinInfo.cs @@ -0,0 +1,14 @@ + +using System; +using Mono.Addins; +using Mono.Addins.Description; + +[assembly:Addin ("TestRunner", + Namespace = "MonoDevelop", + Version = MonoDevelop.BuildInfo.Version, + Category = "MonoDevelop Core")] + +[assembly:AddinName ("Test Runner")] +[assembly:AddinDescription ("Test runner for the MonoDevelop unit tests")] + +[assembly:AddinDependency ("Core", MonoDevelop.BuildInfo.Version)] diff --git a/main/tests/TestRunner/MonoDevelop.TestRunner.addin.xml b/main/tests/TestRunner/MonoDevelop.TestRunner.addin.xml index 7c7c9cd9e0..f2b1a0acd2 100644 --- a/main/tests/TestRunner/MonoDevelop.TestRunner.addin.xml +++ b/main/tests/TestRunner/MonoDevelop.TestRunner.addin.xml @@ -1,19 +1,7 @@ -<Addin id = "TestRunner" - namespace = "MonoDevelop" - name = "Test Runner" - copyright = "MIT/X11" - url = "http://www.monodevelop.com" - description = "Test runner for the MonoDevelop unit tests" - category = "MonoDevelop Core" - isroot = "false" - version = "4.2.3" - compatVersion = "4.0"> +<ExtensionModel> - <Dependencies> - <Addin id="Core" version="4.2.3"/> - </Dependencies> - <Extension path = "/MonoDevelop/Core/Applications"> <Application id = "run-md-tests" class = "MonoDevelop.Tests.TestRunner.Runer" description = "Runs the MonoDevelop unit test suite"/> </Extension> -</Addin> + +</ExtensionModel> diff --git a/main/tests/TestRunner/TestRunner.csproj b/main/tests/TestRunner/TestRunner.csproj index 4aa0546920..2101e9a64a 100644 --- a/main/tests/TestRunner/TestRunner.csproj +++ b/main/tests/TestRunner/TestRunner.csproj @@ -48,6 +48,7 @@ <ItemGroup> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Runner.cs" /> + <Compile Include="AddinInfo.cs" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <ItemGroup> diff --git a/main/tests/UnitTests/MonoDevelop.Projects/MSBuildTests.cs b/main/tests/UnitTests/MonoDevelop.Projects/MSBuildTests.cs index 804d6563b6..a87347d514 100644 --- a/main/tests/UnitTests/MonoDevelop.Projects/MSBuildTests.cs +++ b/main/tests/UnitTests/MonoDevelop.Projects/MSBuildTests.cs @@ -430,5 +430,20 @@ namespace MonoDevelop.Projects { LoadBuildVSConsoleProject ("2013", "12.0"); } + + [Test] + public void SaveReferenceWithCondition () + { + string solFile = Util.GetSampleProject ("console-project-conditional-reference", "ConsoleProject.sln"); + Solution sol = Services.ProjectService.ReadWorkspaceItem (Util.GetMonitor (), solFile) as Solution; + + string proj = sol.GetAllProjects ().First ().FileName; + + string projectXml1 = Util.GetXmlFileInfoset (proj); + sol.Save (new NullProgressMonitor ()); + + string projectXml2 = Util.GetXmlFileInfoset (proj); + Assert.AreEqual (projectXml1, projectXml2); + } } } diff --git a/main/tests/UnitTests/MonoDevelop.SourceEditor/JSonIndentEngineTests.cs b/main/tests/UnitTests/MonoDevelop.SourceEditor/JSonIndentEngineTests.cs new file mode 100644 index 0000000000..ac7b5d0d40 --- /dev/null +++ b/main/tests/UnitTests/MonoDevelop.SourceEditor/JSonIndentEngineTests.cs @@ -0,0 +1,108 @@ +// +// JSonIndentEngineTests.cs +// +// Author: +// Mike Krüger <mkrueger@xamarin.com> +// +// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION 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 NUnit.Framework; +using MonoDevelop.Ide.CodeCompletion; +using ICSharpCode.NRefactory.CSharp; +using System.Text; +using ICSharpCode.NRefactory.Editor; +using MonoDevelop.SourceEditor.JSon; +using Mono.TextEditor; + +namespace MonoDevelop.SourceEditor +{ + [TestFixture] + public class JSonIndentEngineTests + { + public static IDocumentIndentEngine CreateEngine (string text) + { + var sb = new StringBuilder (); + int offset = 0; + for (int i = 0; i < text.Length; i++) { + var ch = text [i]; + if (ch == '$') { + offset = i; + continue; + } + sb.Append (ch); + } + + var data = new TextEditorData (); + data.Text = sb.ToString (); + var csi = new JSonIndentEngine (data); + var result = new CacheIndentEngine (csi); + result.Update (offset); + return result; + } + + [Test] + public void TestBracketIndentation () + { + var engine = CreateEngine ( + @" +{ +$ +"); + Assert.AreEqual ("\t", engine.ThisLineIndent); + Assert.AreEqual ("\t", engine.NextLineIndent); + } + + [Test] + public void TestBodyIndentation () + { + var engine = CreateEngine ( + @" +{ + ""foo"":""bar"", +$ +"); + Assert.AreEqual ("\t", engine.ThisLineIndent); + Assert.AreEqual ("\t", engine.NextLineIndent); + } + + [Test] + public void TestArrayIndentation () + { + var engine = CreateEngine ( + @" +{ + ""test"":[ +$ +"); + Assert.AreEqual ("\t\t", engine.ThisLineIndent); + Assert.AreEqual ("\t\t", engine.NextLineIndent); + } + + [Test] + public void TestWindowsEOL () + { + var engine = CreateEngine ("\r\n{\r\n$\r\n"); + Assert.AreEqual ("\t", engine.ThisLineIndent); + Assert.AreEqual ("\t", engine.NextLineIndent); + } + } +} + diff --git a/main/tests/UnitTests/UnitTests.csproj b/main/tests/UnitTests/UnitTests.csproj index 693cfae5a2..1de46c8677 100644 --- a/main/tests/UnitTests/UnitTests.csproj +++ b/main/tests/UnitTests/UnitTests.csproj @@ -3,7 +3,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>9.0.21022</ProductVersion> + <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{1497D0A8-AFF1-4938-BC22-BE79B358BA5B}</ProjectGuid> <OutputType>Library</OutputType> @@ -287,6 +287,7 @@ <Compile Include="MonoDevelop.Refactoring\ProjectGroupingProviderTests.cs" /> <Compile Include="MonoDevelop.Refactoring\FileGroupingProviderTests.cs" /> <Compile Include="MonoDevelop.Ide.Gui\LogViewTests.cs" /> + <Compile Include="MonoDevelop.SourceEditor\JSonIndentEngineTests.cs" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="..\..\md.targets" /> diff --git a/main/tests/test-projects/console-project-conditional-reference/ConsoleProject.sln b/main/tests/test-projects/console-project-conditional-reference/ConsoleProject.sln new file mode 100755 index 0000000000..199aa24543 --- /dev/null +++ b/main/tests/test-projects/console-project-conditional-reference/ConsoleProject.sln @@ -0,0 +1,23 @@ +
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleProject", "ConsoleProject\ConsoleProject.csproj", "{4A9E3523-48F0-4BDF-A0F4-49DAD4431FAB}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {4A9E3523-48F0-4BDF-A0F4-49DAD4431FAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4A9E3523-48F0-4BDF-A0F4-49DAD4431FAB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4A9E3523-48F0-4BDF-A0F4-49DAD4431FAB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4A9E3523-48F0-4BDF-A0F4-49DAD4431FAB}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(MonoDevelopProperties) = preSolution
+ StartupItem = ConsoleProject\ConsoleProject.csproj
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/main/tests/test-projects/console-project-conditional-reference/ConsoleProject/ConsoleProject.csproj b/main/tests/test-projects/console-project-conditional-reference/ConsoleProject/ConsoleProject.csproj new file mode 100755 index 0000000000..1b82a09794 --- /dev/null +++ b/main/tests/test-projects/console-project-conditional-reference/ConsoleProject/ConsoleProject.csproj @@ -0,0 +1,51 @@ +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>8.0.50727</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{4A9E3523-48F0-4BDF-A0F4-49DAD4431FAB}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>ConsoleProject</RootNamespace> + <AssemblyName>ConsoleProject</AssemblyName> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>True</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>False</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>True</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Data" /> + <Reference Include="protobuf-net" Condition=" '$(Configuration)' == 'Debug' "> + <HintPath>..\Lib\Debug\protobuf-net.dll</HintPath> + </Reference> + <Reference Include="protobuf-net" Condition=" '$(Configuration)' != 'Debug' "> + <HintPath>..\Lib\Release\protobuf-net.dll</HintPath> + </Reference> </ItemGroup> + <ItemGroup> + <Compile Include="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> diff --git a/main/tests/test-projects/console-project-conditional-reference/ConsoleProject/Program.cs b/main/tests/test-projects/console-project-conditional-reference/ConsoleProject/Program.cs new file mode 100755 index 0000000000..cd4be63967 --- /dev/null +++ b/main/tests/test-projects/console-project-conditional-reference/ConsoleProject/Program.cs @@ -0,0 +1,14 @@ +using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace ConsoleProject
+{
+ class Program
+ {
+ static void Main (string[] args)
+ {
+ Console.WriteLine ("Hello world");
+ }
+ }
+}
diff --git a/main/tests/test-projects/console-project-conditional-reference/ConsoleProject/Properties/AssemblyInfo.cs b/main/tests/test-projects/console-project-conditional-reference/ConsoleProject/Properties/AssemblyInfo.cs new file mode 100755 index 0000000000..be1e50670d --- /dev/null +++ b/main/tests/test-projects/console-project-conditional-reference/ConsoleProject/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle ("ConsoleProject")]
+[assembly: AssemblyDescription ("")]
+[assembly: AssemblyConfiguration ("")]
+[assembly: AssemblyCompany ("")]
+[assembly: AssemblyProduct ("ConsoleProject")]
+[assembly: AssemblyCopyright ("Copyright © 2008")]
+[assembly: AssemblyTrademark ("")]
+[assembly: AssemblyCulture ("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible (false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid ("a1b85c5f-e506-462a-911c-cbe67c035c93")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+[assembly: AssemblyVersion ("1.0.0.0")]
+[assembly: AssemblyFileVersion ("1.0.0.0")]
diff --git a/scripts/configure.bat b/scripts/configure.bat new file mode 100644 index 0000000000..e1fc3ff8d6 --- /dev/null +++ b/scripts/configure.bat @@ -0,0 +1,6 @@ +@echo off
+set DIR=%~dp0\
+if not exist %DIR%\configure.exe (
+ csc /nologo /out:%DIR%\configure.exe %DIR%\configure.cs
+)
+%DIR%\configure.exe %*
\ No newline at end of file diff --git a/scripts/configure.cs b/scripts/configure.cs new file mode 100644 index 0000000000..4c407efc44 --- /dev/null +++ b/scripts/configure.cs @@ -0,0 +1,307 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; +using System.Diagnostics; +using System.Text.RegularExpressions; +using System.Xml.Serialization; +using System.Xml; +using System.Net; +using System.Reflection; + +namespace MonoDevelop.Configuration +{ + public class PlatformInfo + { + public string AppId; + public string UpdaterId; + public string UpdaterVersion; + } + + public enum Platform + { + Mac, + Windows, + Linux + } + + class Program + { + static IdeConfigurationTool config; + + static int Main (string[] args) + { + try { + config = new IdeConfigurationTool (new FileInfo(Assembly.GetEntryAssembly().Location).Directory.Parent.FullName); + + if (args.Length == 0) + { + PrintHelp(); + return 0; + } + + var cmd = args[0]; + args = args.Skip(1).ToArray(); + + switch (cmd) + { + case "get-version": + GetVersion(args); + break; + case "get-releaseid": + GetReleaseId(args); + break; + case "gen-updateinfo": + GenerateUpdateInfo(args); + break; + case "gen-buildinfo": + GenerateBuildInfo(args); + break; + default: + Console.WriteLine("Unknown command: " + cmd); + return 1; + } + return 0; + } + catch (UserException ex) { + Console.WriteLine (ex.Message); + return 1; + } + catch (Exception ex) { + Console.WriteLine (ex.ToString()); + return 1; + } + } + + static void GetVersion (string[] args) + { + Console.WriteLine (config.ProductVersion); + } + + static void GetReleaseId (string[] args) + { + Console.WriteLine (config.ReleaseId); + } + + static void GenerateUpdateInfo(string[] args) + { + if (args.Length == 0) + throw new UserException("Platform config file not provided"); + if (args.Length == 1) + throw new UserException("Target directory not provided"); + + config.GenerateUpdateInfo(args[0], args[1]); + } + + static void GenerateBuildInfo(string[] args) + { + if (args.Length == 0) + throw new UserException("Target directory not provided"); + + config.GenerateBuildInfo(args[0]); + } + + static void PrintHelp() + { + Console.WriteLine("MonoDevelop Configuration Script"); + Console.WriteLine(); + Console.WriteLine("Commands:"); + Console.WriteLine("\tget-version: Prints the version of this release"); + Console.WriteLine("\tget-releaseid: Prints the release id"); + Console.WriteLine("\tgen-updateinfo <config-file> <path>: Generates the updateinfo file"); + Console.WriteLine("\t\tin the provided path"); + Console.WriteLine("\tgen-buildinfo <path>: Generates the buildinfo file in the provided path"); + Console.WriteLine(); + } + } + + public class IdeConfigurationTool + { + public readonly string MonoDevelopPath; + public readonly string Version; + public readonly string ProductVersion; + public readonly string ProductVersionText; + public readonly string CompatVersion; + public readonly string AssemblyVersion = "4.0.0.0"; + public readonly string ReleaseId; + public readonly PlatformInfo PlatformInfo; + + public IdeConfigurationTool(string monoDevelopPath) + { + MonoDevelopPath = monoDevelopPath; + + string versionTxt = Path.Combine(MonoDevelopPath, "version.config"); + Version = SystemUtil.Grep(versionTxt, @"Version=(.*)"); + ProductVersionText = SystemUtil.Grep(versionTxt, "Label=(.*)"); + CompatVersion = SystemUtil.Grep(versionTxt, "CompatVersion=(.*)"); + + Version ver = new Version(Version); + int vbuild = ver.Build != -1 ? ver.Build : 0; + var cd = GetVersionCommitDistance(MonoDevelopPath); + int vbrev = ver.Revision != -1 ? ver.Revision : cd; + ReleaseId = "" + ver.Major + ver.Minor.ToString("00") + vbuild.ToString("00") + vbrev.ToString("0000"); + ProductVersion = ver.Major + "." + ver.Minor + "." + vbuild + "." + vbrev; + } + + public void GenerateUpdateInfo (string platformConfigFile, string targetDir) + { + PlatformInfo pinfo; + using (var sr = new StreamReader(platformConfigFile)) + { + XmlSerializer ser = new XmlSerializer (typeof(PlatformInfo)); + pinfo = (PlatformInfo)ser.Deserialize (sr); + } + + if (pinfo.AppId != null) + File.WriteAllText (Path.Combine (targetDir, "updateinfo"), pinfo.AppId + " " + ReleaseId); + + if (pinfo.UpdaterId != null) + File.WriteAllText (Path.Combine (targetDir, "updateinfo.updater"), pinfo.UpdaterId + " " + pinfo.UpdaterVersion); + } + + public void GenerateBuildInfo(string targetDir) + { + string head = SystemUtil.RunProcess(SystemUtil.GitExe, "rev-parse HEAD", MonoDevelopPath).Trim(); + + var txt = "Release ID: " + ReleaseId + "\n"; + txt += "Git revision: " + head + "\n"; + txt += "Build date: " + DateTime.Now.ToString ("yyyy-MM-dd HH:mm:sszz") + "\n"; + + File.WriteAllText(Path.Combine(targetDir, "buildinfo"), txt); + } + + static int GetVersionCommitDistance (string path) + { + var blame = new StringReader(SystemUtil.RunProcess(SystemUtil.GitExe, "blame version.config", path)); + string line; + while ((line = blame.ReadLine ()) != null && line.IndexOf ("Version=") == -1) + ; + if (line != null) { + string hash = line.Substring (0, line.IndexOf (' ')); + string dist = SystemUtil.RunProcess(SystemUtil.GitExe, "rev-list --count " + hash + "..HEAD", path); + return int.Parse (dist.Trim ()); + } + return 0; + } + } + + class UserException: Exception + { + public UserException (string msg) + : base (msg) + { + } + } + + public static class Logging + { + static string logFile; + static object localLock = new object (); + + public static void Initialize(string logFileName) + { + logFile = logFileName; + } + + public static void ReportError(string msg) + { + if (logFile != null) { + lock (localLock) + File.AppendAllText(logFile, "[ERROR] " + msg + Environment.NewLine); + } + Console.WriteLine("[ERROR] " + msg); + } + + public static void ReportInfo(string msg) + { + if (logFile != null) { + lock (localLock) + File.AppendAllText(logFile, "[INFO] " + msg + Environment.NewLine); + } + Console.WriteLine(msg); + } + + public static void ReportDebug(string msg) + { + if (logFile != null) + { + lock (localLock) + File.AppendAllText(logFile, "[INFO] " + msg + Environment.NewLine); + } + } + } + + public static class SystemUtil + { + static SystemUtil () + { + if (Path.DirectorySeparatorChar == '\\') + Platform = Platform.Windows; + else if (Directory.Exists ("/Library/Application Support")) + Platform = Platform.Mac; + else + Platform = Platform.Linux; + + if (Platform == Platform.Windows) { + if (File.Exists (@"c:\Program Files\Git\bin\git.exe")) + GitExe = @"c:\Program Files\Git\bin\git.exe"; + else if (File.Exists (@"c:\Program Files (x86)\Git\bin\git.exe")) + GitExe = @"c:\Program Files (x86)\Git\bin\git.exe"; + else if (File.Exists (@"c:\msysgit\bin\git.exe")) + GitExe = @"c:\msysgit\bin\git.exe"; + else + GitExe = "git.exe"; + } else { + GitExe = "git"; + } + } + + public static string GitExe { get; private set; } + + public static Platform Platform { get; private set; } + + public static string Grep(string file, string regex) + { + string txt = File.ReadAllText(file); + var m = Regex.Match(txt, regex); + if (m == null) + throw new UserException("Match not found for regex: " + regex); + if (m.Groups.Count != 2) + throw new UserException("Invalid regex: expression must have a single capture group: " + regex); + Group cap = m.Groups[1]; + return cap.Value; + } + + public static string RunProcess(string file, string args, string workingDir) + { + Logging.ReportDebug(file + " " + args); + + Process p = new Process(); + p.StartInfo.CreateNoWindow = true; + p.StartInfo.UseShellExecute = false; + p.StartInfo.RedirectStandardOutput = true; + p.StartInfo.RedirectStandardError = true; + p.StartInfo.WorkingDirectory = workingDir; + p.StartInfo.FileName = file; + p.StartInfo.Arguments = args; + StringBuilder sb = new StringBuilder(); + p.OutputDataReceived += delegate(object s, DataReceivedEventArgs e) + { + Logging.ReportDebug(e.Data); + sb.AppendLine(e.Data); + }; + p.ErrorDataReceived += delegate(object s, DataReceivedEventArgs e) + { + Logging.ReportDebug(e.Data); + }; + p.Start(); + p.BeginOutputReadLine(); + p.BeginErrorReadLine(); + p.WaitForExit(); + if (p.ExitCode != 0) + throw new UserException(file + " failed"); + return sb.ToString(); + } + } +} diff --git a/scripts/configure.sh b/scripts/configure.sh new file mode 100755 index 0000000000..e4a361759e --- /dev/null +++ b/scripts/configure.sh @@ -0,0 +1,7 @@ +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +if [ ! -f $DIR/configure.exe ]; then + mcs $DIR/configure.cs -out:$DIR/configure.exe +fi + +LANG=C mono $DIR/configure.exe "$@" diff --git a/scripts/mdbranch b/scripts/mdbranch deleted file mode 100755 index d32f7f4497..0000000000 --- a/scripts/mdbranch +++ /dev/null @@ -1,153 +0,0 @@ -#!/usr/bin/env bash -version=1.9 -prefix=/usr/local -profile=dist -trunkRoot=svn+ssh://$USER@mono-cvs.ximian.com/source/trunk/monodevelop -branchesRoot=svn+ssh://$USER@mono-cvs.ximian.com/source/branches/monodevelop -tagsRoot=svn+ssh://$USER@mono-cvs.ximian.com/source/tags/monodevelop -srcVersion= - -sourceRoot=$trunkRoot -destRoot=$branchesRoot - -MSG=`mktemp` - -usage () -{ - echo "Usage : mdbrach [--profile=PROFILE] versionNumber" - echo "" - echo "Creates a new branch of MonoDevelop and the extras add-ins included" - echo "in the specified profile (which is 'stable' by default)." -} - -validate_profile () -{ - test -z "$1" && return 0 - for c in `ls ../profiles`; do - if [ "$c" = "$1" ]; then - return 1 - fi - done - return 0 -} - -read_packages () -{ - for p in `sed -e /#/d -e 's/ /,/g' < ../profiles/$profile` ; do - path=`echo $p | cut -d ',' -f 1` - packages="$packages $path" - done - return 0 -} - -while test x$1 != x; do - case $1 in - --profile=*) - prof=`echo $1 | sed 's/--profile=//'` - validate_profile "$prof" - if [ $? -eq 1 ]; then - profile=$prof - else - echo "Invalid profile name - $conf" - usage - exit 1 - fi - ;; - --profile) - shift - prof=$1 - validate_profile "$prof" - if [ $? -eq 1 ]; then - profile=$prof - else - echo "Invalid profile name - $conf" - usage - exit 1 - fi - ;; - --tag) - shift - sourceRoot=$branchesRoot - destRoot=$tagsRoot - srcVersion="/$1" - ;; - --help) - usage - exit - ;; - *) - version=$1 - ;; - esac - shift -done - -read_packages - - -echo "" -if [ $destRoot = $tagsRoot ]; then - echo "The following tags will be created:" -else - echo "The following branches will be created:" -fi - -echo "" -for p in $packages; do - echo "$destRoot/$p/$version" -done -echo "" -echo "From sources:" -echo "" -for p in $packages; do - echo "$sourceRoot/$p$srcVersion" -done - -if [ $destRoot = $tagsRoot ]; then - echo "Created $version tag." > $MSG -else - echo "Created $version branch." > $MSG -fi - -echo "" -echo "Commit message:" -cat $MSG -echo "" - -while [[ 1 ]] -do - - read -a RESPONSE -p"Would you like to continue (Y)es/(N)o/(E)dit Message: " - if [[ $? != 0 ]] - then - RESPONSE="N" - fi - - case $RESPONSE in - "Y" | "y" | "yes" | "Yes") - - echo "Comitting..." - for p in $packages; do - echo "svn cp -F $MSG $sourceRoot/$p$srcVersion $destRoot/$p/$version" - svn cp -F $MSG $sourceRoot/$p$srcVersion $destRoot/$p/$version - done - rm $MSG - exit 0 - ;; - - "N" | "n" | "no" | "No") - echo "Aborting..." - rm $MSG - exit 1 - ;; - - "E" | "e" | "ed" | "Ed" | "Edit" | "edit") - vi $MSG - # try again - ;; - *) - # try again - ;; - esac -done - diff --git a/scripts/mdget b/scripts/mdget deleted file mode 100755 index ff4f3b59bc..0000000000 --- a/scripts/mdget +++ /dev/null @@ -1,154 +0,0 @@ -#!/usr/bin/env bash -version= -prefix=/usr/local -profile=stable -trunkRoot=svn+ssh://$USER@mono-cvs.ximian.com/source/trunk/monodevelop -branchesRoot=svn+ssh://$USER@mono-cvs.ximian.com/source/branches/monodevelop -tagsRoot=svn+ssh://$USER@mono-cvs.ximian.com/source/tags/monodevelop -destDirRoot=../.. - -sourceRoot=$branchesRoot - -MSG=`mktemp` - -usage () -{ - echo "" - echo "Usage : mdget [--profile=PROFILE] [--dir=DIRECTORY] [--tag] versionNumber" - echo "" - echo "Check outs a MonoDevelop branch or tag and the extras add-ins included" - echo "in the specified profile (which is 'stable' by default)." - echo "" - echo "PROFILE is the profile that contains the list of packages to check out." - echo "" - echo "DIRECTORY is the root directory where MonoDevelop will be checked out." - echo "Example: mdget --dir=/home/user/test 2.1" - echo "This command will checkout the 2.1 branch to the directory:" - echo "/home/user/test/monodevelop-2.1" - echo "The output directory is ../.. by default." - echo "" - echo "When the --tag option is specified, a tag will be checked out," - echo "instead of a branch." - echo "" -} - -validate_profile () -{ - test -z "$1" && return 0 - for c in `ls ../profiles`; do - if [ "$c" = "$1" ]; then - return 1 - fi - done - return 0 -} - -read_packages () -{ - for p in `sed -e /#/d -e 's/ /,/g' < ../profiles/$profile` ; do - path=`echo $p | cut -d ',' -f 1` - packages="$packages $path" - done - return 0 -} - -while test x$1 != x; do - case $1 in - --profile=*) - prof=`echo $1 | sed 's/--profile=//'` - validate_profile "$prof" - if [ $? -eq 1 ]; then - profile=$prof - else - echo "Invalid profile name - $conf" - usage - exit 1 - fi - ;; - --profile) - shift - prof=$1 - validate_profile "$prof" - if [ $? -eq 1 ]; then - profile=$prof - else - echo "Invalid profile name - $conf" - usage - exit 1 - fi - ;; - --tag) - shift - sourceRoot=$tagsRoot - ;; - --help) - usage - exit - ;; - *) - version=$1 - ;; - esac - shift -done - -if [ "$version" = "" ]; then - usage - exit -fi - - -read_packages - -destDir=$destDirRoot/monodevelop-$version - -echo "" -echo "MonoDevelop $version will be checked out from:" -echo "$sourceRoot/*/$version" -echo "" -echo "The following directories will be created:" - -echo "" -for p in $packages; do - echo "$destDir/$p" -done - -while [[ 1 ]] -do - - read -a RESPONSE -p"Would you like to continue (Y)es/(N)o: " - if [[ $? != 0 ]] - then - RESPONSE="N" - fi - - case $RESPONSE in - "Y" | "y" | "yes" | "Yes") - - echo "Getting MonoDevelop $version ..." - mkdir $destDir - for p in $packages; do - echo "svn co $sourceRoot/$p/$version $destDir/$p" - svn co $sourceRoot/$p/$version $destDir/$p - done - cp ../configure $destDir/configure - cp ../MonoDevelop.mdw $destDir/MonoDevelop.mdw - cp ../Makefile $destDir/Makefile - cp ../extras/extras.mdw $destDir/extras/extras.mdw - mkdir $destDir/profiles - cp ../profiles/$profile $destDir/profiles/all - cp ../profiles/$profile $destDir/profiles/stable - cp ../profiles/$profile $destDir/profiles/default - exit 0 - ;; - - "N" | "n" | "no" | "No") - echo "Aborting..." - exit 1 - ;; - *) - # try again - ;; - esac -done - diff --git a/scripts/mdtag b/scripts/mdtag deleted file mode 100755 index a574f46ec4..0000000000 --- a/scripts/mdtag +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash - -usage () -{ - echo "" - echo "Usage : mdtag branchVersionNumber tagVersionNumber" - echo "" - echo "Creates a new tag of MonoDevelop using the provided branch number as source." - echo "" -} - -if [ x$1 = x ]; then - usage - exit 1 -fi - -if [ x$2 = x ]; then - echo "Branch version number not provided" - exit 1 -fi - -./mdbranch --tag $1 $2 - diff --git a/version-checks b/version-checks index b2fe51e66a..70c45b4077 100755 --- a/version-checks +++ b/version-checks @@ -17,7 +17,7 @@ DEP[0]=md-addins DEP_NAME[0]=MDADDINS DEP_PATH[0]=${top_srcdir}/../md-addins DEP_MODULE[0]=git@github.com:xamarin/md-addins.git -DEP_NEEDED_VERSION[0]=effd965b2b1dbb5d5eb31ecf4b0650e093a099cd +DEP_NEEDED_VERSION[0]=6ca9662fd90124c714991266bc4531787ad5f578 DEP_BRANCH_AND_REMOTE[0]="master origin/master" # heap-shot diff --git a/version.config b/version.config new file mode 100644 index 0000000000..363af4d2b9 --- /dev/null +++ b/version.config @@ -0,0 +1,3 @@ +Version=4.2.4 +Label=4.2.4 +CompatVersion=4.0 |