diff --git a/data/resources/StringResources.de.resx b/data/resources/StringResources.de.resx index aa4ea7305c..bc5f5117f2 100644 --- a/data/resources/StringResources.de.resx +++ b/data/resources/StringResources.de.resx @@ -4033,6 +4033,12 @@ Grund: Der Wert zu dem zurückgesetzt werden soll ist ungültig weil sich eine a Das öffentliche Schlüsseltoken der Assembly + + Assembly referenzieren + + + Wenn auf false gesetzt, gibt diese Referenz nur eine Build-Reihenfolgenabhängigkeit an und fügt keine Assembly-Referenz zum Projekt hinzu. + Festgelegte Version @@ -4979,6 +4985,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension< Kopiere Wert in Zwischenablage + + Name + Nicht-öffentliche Mitglieder @@ -5000,6 +5009,12 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension< Statische Mitglieder + + Typ + + + Wert + Speicher @@ -5375,6 +5390,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension< Öffne beinhaltenden Ordner im Explorer + + Kommandozeile hier öffnen + Alle Knoten einklappen @@ -5510,6 +5528,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension< Projekt sta&rten + + Projekt ohne Debugger starten + Als St&artprojekt festlegen diff --git a/data/resources/StringResources.fr.resx b/data/resources/StringResources.fr.resx index 2f0e2f9e55..e8e68aa95f 100644 --- a/data/resources/StringResources.fr.resx +++ b/data/resources/StringResources.fr.resx @@ -1862,6 +1862,9 @@ Voulez-vous ajouter le nouveau fichier au projet ${CurrentProjectName}? Pas-à-pas en cours + + Décompiler le code sans symboles + Utiliser 'Seulement mon code' pour le pas-à-pas @@ -3379,6 +3382,9 @@ Configurez le chemin vers NAnt dans les options de SharpDevelop. L'élément sélectionné n'est ni une classe ni un membre surchargeable: aucun symbole dérivé n'est disponible. + + Impossible de trouver la définition du type sous le curseur. + Envoyer cette ligne vers la console Ruby @@ -3774,6 +3780,9 @@ Toutes les modifications seront perdues. Impossible de charger le concepteur. Vérifier les erreurs de syntaxe du code source et si toutes les références sont disponibles. + + Une ou plusieurs erreurs sont survenues en essayant de vider le contenu du concepteur. C'est peut-être une exception non gérée dans un composant tiers sur le formulaire ou le contrôle. + Ne peut charger la librairie contenant la barre de composants. Les composants Windows Form ne seront pas accessibles, veuillez configurer manuellement la barre de composants (clic droit sur une catégorie de la barre de menu -> Paramétrer la barre de menu). @@ -3988,6 +3997,12 @@ Utilisez seulement des lettres, chiffres, espace, '.' ou '_'. La culture supportée par la référence + + Embarquer les types interop + + + Précise si les type d'interop COM définis dans l'assembly référencé sont embarqués dans l'assembly cible. + Copie locale @@ -4006,6 +4021,12 @@ Utilisez seulement des lettres, chiffres, espace, '.' ou '_'. Le jeton de clé publique + + Référencer l'assembly + + + Si positionné à Faux, cette référence spécifie uniquement une dépendance dans l'ordre de la construction sans référencer l'assembly. + Version Spécifique @@ -4051,6 +4072,9 @@ Utilisez seulement des lettres, chiffres, espace, '.' ou '_'. Chargement de ${Filename}... + + Fermer la solution + Laisser la solution précédente ouverte @@ -4084,6 +4108,14 @@ Utilisez seulement des lettres, chiffres, espace, '.' ou '_'. Mettre à jour le projet + + Le projet '${ProjectName}' cible MSBuild ${OldToolsVersion}, mais cette version n'est pas installée. +Voulez vous mettre à jour le projet vers MSBuild ${NewToolsVersion}? +Le projet ne sera pas ouvert sans cette mise à jour. + + + Mettre à jour vers MSBuild ${NewToolsVersion} + Cette solution a été créée par une précédente version de SharpDevelop. La mettre à jour vous permet d'utiliser de nouveaux languages, ou les évolutions du framework. @@ -4165,7 +4197,7 @@ Allez dans 'Outils/Options->Style Visuel pour changer l'ambiance actuelle.Processus de travail {0} ASP.NET/IIS(Express) introuvable. - Pas d'URL du projet spécifiée ou de programme externe. Vérifier le serveur web dans Propriétés du projet - Onglet debug. + Aucun programme externe ni URL spécifié. Vérifier le serveur web dans Propriétés du projet - onglet Web. Port: @@ -4783,7 +4815,7 @@ Soit ils n'existent pas, soit le document Wix n'est pas pour WiX 3.0 et l'espace Vous ne pouvez pas changer pour une fonction sans symboles. - Les options de décompilation du code doivent être activés pour aller vers une fonction sans symboles. + Impossible de basculer vers une méthode sans symboles de déboguage.Recompilez avec les symboles ou activer l'option de décompilation du code sans symboles. [Méthodes externes] @@ -5001,12 +5033,18 @@ Soit ils n'existent pas, soit le document Wix n'est pas pour WiX 3.0 et l'espace Adresse + + (dynamique) + Aucun symbole n'est chargé. Symboles chargés. + + (en mémoire) + Ordre diff --git a/data/resources/StringResources.nl.resx b/data/resources/StringResources.nl.resx index 4ccfb33a77..7cd2bbc355 100644 --- a/data/resources/StringResources.nl.resx +++ b/data/resources/StringResources.nl.resx @@ -4023,6 +4023,12 @@ Alleen letters, getallen, spatie, '.' of '_' zijn toegestaan. De openbare sleutel token + + Referentie assembly + + + Indien false, specificeert deze referentie enkel een bouw-volgorde afhankelijkheid en heeft niet tot gevolg dat de assembly gerefereerd wordt. + Specifieke versie @@ -4969,6 +4975,9 @@ Microsoft.Tools.WindowsInstallerXml.Extenties.NetFxCompiler, WixNetFxExtentie Kopieer waarde naar klembord + + Naam + Niet openbare leden @@ -4990,6 +4999,12 @@ Microsoft.Tools.WindowsInstallerXml.Extenties.NetFxCompiler, WixNetFxExtentie Statische leden + + Type + + + Waarde + Geheugen diff --git a/data/resources/StringResources.resx b/data/resources/StringResources.resx index 363b3b0163..f0096690f8 100644 --- a/data/resources/StringResources.resx +++ b/data/resources/StringResources.resx @@ -5270,6 +5270,9 @@ Stop/terminate the debuggee. Copy value to clipboard Item in variable's context menu + + Name + Non-Public members @@ -5297,6 +5300,12 @@ Shows the full callstack of the error. Static members + + Type + + + Value + Memory @@ -5686,6 +5695,9 @@ Removed the end part of the original message ", reason '${Message}'" since this Open containing folder in Explorer String for the editor tab context menu that will open the directory in which a documents file is contained in Windows Explorer. + + Open command prompt here + Collapse all nodes @@ -5830,6 +5842,9 @@ Removed the end part of the original message ", reason '${Message}'" since this &Run Project + + Run Project without Debugger + Set as St&artUp Project diff --git a/src/AddIns/Analysis/CodeCoverage/Test/Testing/CodeCoverageTestRunnerTests.cs b/src/AddIns/Analysis/CodeCoverage/Test/Testing/CodeCoverageTestRunnerTests.cs index 416c25431c..a0f2da9c78 100644 --- a/src/AddIns/Analysis/CodeCoverage/Test/Testing/CodeCoverageTestRunnerTests.cs +++ b/src/AddIns/Analysis/CodeCoverage/Test/Testing/CodeCoverageTestRunnerTests.cs @@ -118,7 +118,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Testing string expectedCommandLine = "--target \"d:\\sharpdevelop\\bin\\Tools\\NUnit\\nunit-console-x86.exe\" " + "--target-work-dir \"c:\\projects\\MyTests\\bin\\Debug\" " + - "--target-args \"\\\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\\\" /results=\\\"d:\\temp\\results.txt\\\"\" " + + "--target-args \"\\\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\\\" /noxml /results=\\\"d:\\temp\\results.txt\\\"\" " + "--output \"c:\\projects\\MyTests\\PartCover\\coverage.xml\" " + "--include [MyTests]*"; @@ -218,7 +218,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Testing "\"d:\\sharpdevelop\\bin\\Tools\\PartCover\\PartCover.exe\" " + "--target \"d:\\sharpdevelop\\bin\\Tools\\NUnit\\nunit-console-x86.exe\" " + "--target-work-dir \"c:\\projects\\MyTests\\bin\\Debug\" " + - "--target-args \"\\\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\\\"\" " + + "--target-args \"\\\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\\\" /noxml\" " + "--output \"c:\\projects\\MyTests\\PartCover\\coverage.xml\" " + "--include [*]*"; } diff --git a/src/AddIns/Analysis/CodeCoverage/Test/Testing/PartCoverApplicationTests.cs b/src/AddIns/Analysis/CodeCoverage/Test/Testing/PartCoverApplicationTests.cs index b4e2ecdc85..1f4c628ef4 100644 --- a/src/AddIns/Analysis/CodeCoverage/Test/Testing/PartCoverApplicationTests.cs +++ b/src/AddIns/Analysis/CodeCoverage/Test/Testing/PartCoverApplicationTests.cs @@ -133,7 +133,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Testing string expectedCommandLine = "--target \"d:\\sharpdevelop\\bin\\Tools\\NUnit\\nunit-console-x86.exe\" " + "--target-work-dir \"c:\\projects\\MyTests\\bin\\Debug\" " + - "--target-args \"\\\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\\\"\" " + + "--target-args \"\\\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\\\" /noxml\" " + "--output \"c:\\projects\\MyTests\\PartCover\\coverage.xml\" " + "--include [*]*"; @@ -157,7 +157,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Testing string expectedCommandLine = "--target \"d:\\sharpdevelop\\bin\\Tools\\NUnit\\nunit-console-x86.exe\" " + "--target-work-dir \"c:\\projects\\MyTests\\bin\\Debug\" " + - "--target-args \"\\\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\\\"\" " + + "--target-args \"\\\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\\\" /noxml\" " + "--output \"c:\\projects\\MyTests\\PartCover\\coverage.xml\" " + "--include [MyTests]* " + "--include [MoreTests]* " + diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleCommandLineTests.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleCommandLineTests.cs index cfebc1c133..93f237a0bd 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleCommandLineTests.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleCommandLineTests.cs @@ -32,6 +32,7 @@ namespace UnitTesting.Tests.Frameworks NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); app.NoLogo = false; app.ShadowCopy = true; + app.NoXmlOutputFile = false; app.Results = @"C:\results.txt"; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /results=\"C:\\results.txt\""; @@ -45,6 +46,7 @@ namespace UnitTesting.Tests.Frameworks NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); app.NoLogo = true; app.ShadowCopy = true; + app.NoXmlOutputFile = false; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /nologo"; Assert.AreEqual(expectedCommandLine, app.GetArguments()); @@ -57,6 +59,7 @@ namespace UnitTesting.Tests.Frameworks NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); app.NoLogo = false; app.ShadowCopy = false; + app.NoXmlOutputFile = false; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /noshadow"; Assert.AreEqual(expectedCommandLine, app.GetArguments()); @@ -70,6 +73,7 @@ namespace UnitTesting.Tests.Frameworks app.NoLogo = false; app.ShadowCopy = true; app.NoThread = true; + app.NoXmlOutputFile = false; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /nothread"; Assert.AreEqual(expectedCommandLine, app.GetArguments()); @@ -83,6 +87,7 @@ namespace UnitTesting.Tests.Frameworks app.NoLogo = false; app.ShadowCopy = true; app.NoDots = true; + app.NoXmlOutputFile = false; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /nodots"; Assert.AreEqual(expectedCommandLine, app.GetArguments()); @@ -96,6 +101,7 @@ namespace UnitTesting.Tests.Frameworks app.NoLogo = false; app.ShadowCopy = true; app.Labels = true; + app.NoXmlOutputFile = false; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /labels"; Assert.AreEqual(expectedCommandLine, app.GetArguments()); @@ -109,6 +115,7 @@ namespace UnitTesting.Tests.Frameworks app.NoLogo = false; app.ShadowCopy = true; app.Fixture = "TestFixture"; + app.NoXmlOutputFile = false; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"TestFixture\""; Assert.AreEqual(expectedCommandLine, app.GetArguments()); @@ -122,6 +129,7 @@ namespace UnitTesting.Tests.Frameworks app.NoLogo = false; app.ShadowCopy = true; app.NamespaceFilter = "TestFixture"; + app.NoXmlOutputFile = false; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"TestFixture\""; Assert.AreEqual(expectedCommandLine, app.GetArguments()); @@ -135,11 +143,26 @@ namespace UnitTesting.Tests.Frameworks app.NoLogo = false; app.ShadowCopy = true; app.XmlOutputFile = @"C:\NUnit.xml"; + app.NoXmlOutputFile = false; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /xml=\"C:\\NUnit.xml\""; Assert.AreEqual(expectedCommandLine, app.GetArguments()); } + [Test] + public void NoXmlWhenXmlOutputFileSpecified() + { + SelectedTests selectedTests = new SelectedTests(project); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); + app.NoLogo = false; + app.ShadowCopy = true; + app.XmlOutputFile = @"C:\NUnit.xml"; + app.NoXmlOutputFile = true; + + string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /noxml"; + Assert.AreEqual(expectedCommandLine, app.GetArguments()); + } + [Test] public void TestMethod() { @@ -149,6 +172,7 @@ namespace UnitTesting.Tests.Frameworks app.ShadowCopy = true; app.Fixture = "TestFixture"; app.Test = "Test"; + app.NoXmlOutputFile = false; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"TestFixture.Test\""; Assert.AreEqual(expectedCommandLine, app.GetArguments()); @@ -163,6 +187,7 @@ namespace UnitTesting.Tests.Frameworks NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); app.NoLogo = false; app.ShadowCopy = true; + app.NoXmlOutputFile = false; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"TestFixture.Test\""; Assert.AreEqual(expectedCommandLine, app.GetArguments()); @@ -175,6 +200,7 @@ namespace UnitTesting.Tests.Frameworks NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); app.NoLogo = false; app.ShadowCopy = true; + app.NoXmlOutputFile = false; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"Project.MyTests\""; Assert.AreEqual(expectedCommandLine, app.GetArguments()); @@ -187,6 +213,7 @@ namespace UnitTesting.Tests.Frameworks NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); app.NoLogo = true; app.ShadowCopy = true; + app.NoXmlOutputFile = false; FileUtility.ApplicationRootPath = @"C:\SharpDevelop"; @@ -211,6 +238,7 @@ namespace UnitTesting.Tests.Frameworks app.NoLogo = false; app.ShadowCopy = true; app.Results = @"C:\results.txt"; + app.NoXmlOutputFile = false; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" " + @@ -235,6 +263,7 @@ namespace UnitTesting.Tests.Frameworks NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); app.NoLogo = false; app.ShadowCopy = true; + app.NoXmlOutputFile = false; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" " + "/run=\"MyTests.TestFixture+InnerTest\""; diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleProcessStartInfoTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleProcessStartInfoTestFixture.cs index a63fad5c3a..8902702f73 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleProcessStartInfoTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleProcessStartInfoTestFixture.cs @@ -50,7 +50,7 @@ namespace UnitTesting.Tests.Frameworks public void CommandLineArgumentsAreNUnitConsoleExeCommandLineArguments() { string expectedCommandLine = - "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\""; + "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\" /noxml"; Assert.AreEqual(expectedCommandLine, info.Arguments); } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunNUnitTestsForMethodTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunNUnitTestsForMethodTestFixture.cs index a8edcd6ccf..d604124e99 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunNUnitTestsForMethodTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunNUnitTestsForMethodTestFixture.cs @@ -173,7 +173,7 @@ namespace UnitTesting.Tests.Tree StartNUnitTestRunner(); string expectedArgs = - "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\" " + + "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\" /noxml " + "/results=\"c:\\temp\\tmp66.tmp\" " + "/run=\"MyTests.MyTestClass.MyTestMethod\""; Assert.AreEqual(expectedArgs, context.MockProcessRunner.CommandArgumentsPassedToStartMethod); diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunNUnitTestsWithDebuggerTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunNUnitTestsWithDebuggerTestFixture.cs index 19ccf38875..2bea660cd7 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunNUnitTestsWithDebuggerTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunNUnitTestsWithDebuggerTestFixture.cs @@ -57,7 +57,7 @@ namespace UnitTesting.Tests.Tree StartTestDebugger(); string expectedArguments = "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\" " + - "/noshadow " + + "/noshadow /noxml " + "/results=\"c:\\temp\\tmp66.tmp\" " + "/run=\"MyTests.MyTestClass.MyTestMethod\""; @@ -167,7 +167,7 @@ namespace UnitTesting.Tests.Tree string commandLine = "\"C:\\SharpDevelop\\bin\\Tools\\NUnit\\nunit-console-x86.exe\" " + "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\" " + - "/noshadow " + + "/noshadow /noxml " + "/results=\"c:\\temp\\tmp66.tmp\" " + "/run=\"MyTests.MyTestClass.MyTestMethod\""; Assert.AreEqual(commandLine, message); diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestInPadCommandTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestInPadCommandTestFixture.cs index dbb49a143e..e008a885e4 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestInPadCommandTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestInPadCommandTestFixture.cs @@ -79,7 +79,7 @@ namespace UnitTesting.Tests.Tree { runCommand.Run(); buildProject.FireBuildCompleteEvent(); - string expectedArgs = "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\""; + string expectedArgs = "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\" /noxml"; Assert.AreEqual(expectedArgs, processRunner.CommandArgumentsPassedToStartMethod); } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestWithDebuggerCommandTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestWithDebuggerCommandTestFixture.cs index 6babf3d975..6aa2a63386 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestWithDebuggerCommandTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestWithDebuggerCommandTestFixture.cs @@ -34,7 +34,7 @@ namespace UnitTesting.Tests.Tree public void DebuggerStartsUnitTestApplicationWithCorrectCommandLineArguments() { string expectedArguments = - "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\""; + "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\" /noxml"; string actualArguments = debuggerService.MockDebugger.ProcessStartInfo.Arguments; Assert.AreEqual(expectedArguments, actualArguments); @@ -54,7 +54,7 @@ namespace UnitTesting.Tests.Tree { string expectedText = "\"D:\\SharpDevelop\\bin\\Tools\\NUnit\\nunit-console-x86.exe\" " + - "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\"\r\n"; + "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\" /noxml\r\n"; string actualText = context.UnitTestCategory.Text; Assert.AreEqual(expectedText, actualText); diff --git a/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/CppProject.cs b/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/CppProject.cs index 1bea083584..971a1640e5 100644 --- a/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/CppProject.cs +++ b/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/CppProject.cs @@ -67,7 +67,7 @@ namespace ICSharpCode.CppBinding.Project else { // this will be valid if there is an explicit OutDir property in vcxproj file. - if (GetUnevalatedProperty("OutDir").StartsWith("$(SolutionDir)")) + if ((GetUnevalatedProperty("OutDir") ?? "").StartsWith("$(SolutionDir)")) { // in #D every project is compiled by msbuild separately, this mean that SolutionDir will // be equal to ProjectDir, so it has to be replaced with actual solution directory diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonComponentWalker.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonComponentWalker.cs index 74395e322a..56fea8db0d 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonComponentWalker.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonComponentWalker.cs @@ -165,7 +165,7 @@ namespace ICSharpCode.PythonBinding MemberExpression eventExpression = node.Left as MemberExpression; string eventName = eventExpression.Name.ToString(); - PythonControlFieldExpression field = PythonControlFieldExpression.Create(eventExpression); + fieldExpression = PythonControlFieldExpression.Create(eventExpression); MemberExpression eventHandlerExpression = node.Right as MemberExpression; string eventHandlerName = eventHandlerExpression.Name.ToString(); diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/LoadFormWithButtonFollowedByTimerTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/LoadFormWithButtonFollowedByTimerTestFixture.cs new file mode 100644 index 0000000000..6ba6b96b49 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/LoadFormWithButtonFollowedByTimerTestFixture.cs @@ -0,0 +1,108 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.IO; +using System.Windows.Forms; + +using ICSharpCode.PythonBinding; +using ICSharpCode.Scripting.Tests.Utils; +using NUnit.Framework; +using PythonBinding.Tests.Utils; + +namespace PythonBinding.Tests.Designer +{ + /// + /// Fix ArgumentNullException when form has a button followed by a timer and the + /// first timer statement is the setting of the event handler. + /// + [TestFixture] + public class LoadFormWithButtonFollowedByTimerTestFixture : LoadFormTestFixtureBase + { + MockPropertyDescriptor mockTickPropertyDescriptor; + + public override string PythonCode { + get { + return + "import System.Drawing\r\n" + + "import System.Windows.Forms\r\n" + + "\r\n" + + "from System.Drawing import *\r\n" + + "from System.Windows.Forms import *\r\n" + + "\r\n" + + "class MainForm(Form):\r\n" + + " def __init__(self):\r\n" + + " self.InitializeComponent()\r\n" + + "\r\n" + + " def InitializeComponent(self):\r\n" + + " self._components = System.ComponentModel.Container()\r\n" + + " self._button1 = System.Windows.Forms.Button()\r\n" + + " self._timer1 = System.Windows.Forms.Timer(self._components)\r\n" + + " self.SuspendLayout()\r\n" + + " # \r\n" + + " # button1\r\n" + + " # \r\n" + + " self._button1.Location = System.Drawing.Point(37, 29)\r\n" + + " self._button1.Name = \"button1\"\r\n" + + " self._button1.Size = System.Drawing.Size(75, 23)\r\n" + + " self._button1.TabIndex = 0\r\n" + + " self._button1.Text = \"button1\"\r\n" + + " self._button1.UseVisualStyleBackColor = True\r\n" + + " # \r\n" + + " # timer1\r\n" + + " # \r\n" + + " self._timer1.Tick += self.Timer1Tick\r\n" + + " # \r\n" + + " # MainForm\r\n" + + " # \r\n" + + " self.ClientSize = System.Drawing.Size(284, 264)\r\n" + + " self.Controls.Add(self._button1)\r\n" + + " self.Name = \"MainForm\"\r\n" + + " self.Text = \"PyWinTest\"\r\n" + + " self.ResumeLayout(False)\r\n" + + "\r\n" + + "\r\n" + + " def Timer1Tick(self, sender, e):\r\n" + + " pass"; + } + } + + public override void BeforeSetUpFixture() + { + mockTickPropertyDescriptor = new MockPropertyDescriptor("Tick", null, false); + ComponentCreator.SetEventPropertyDescriptor(mockTickPropertyDescriptor); + } + + [Test] + public void EventDescriptorUsedToGetEventProperty() + { + Assert.IsNotNull(ComponentCreator.EventDescriptorPassedToGetEventProperty); + } + + [Test] + public void EventDescriptorNameUsedToGetEventPropertyIsTick() + { + Assert.AreEqual("Tick", ComponentCreator.EventDescriptorPassedToGetEventProperty.Name); + } + + [Test] + public void GetPropertyValueSetForTimer() + { + string value = mockTickPropertyDescriptor.GetValue(null) as String; + Assert.AreEqual("Timer1Tick", value); + } + + [Test] + public void GetComponentUsedWhenSettingTickHandler() + { + IComponent expectedComponent = ComponentCreator.GetComponent("timer1"); + + object component = mockTickPropertyDescriptor.GetSetValueComponent(); + + Assert.AreEqual(expectedComponent, component); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj index 3ab64c6e51..1d3876c6fe 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj @@ -265,6 +265,7 @@ + diff --git a/src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBNetFormattingStrategy.cs b/src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBNetFormattingStrategy.cs index 4a751e7d6e..5fa9e46fec 100644 --- a/src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBNetFormattingStrategy.cs +++ b/src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBNetFormattingStrategy.cs @@ -143,7 +143,7 @@ namespace ICSharpCode.VBNetBinding InsertDocumentationComments(editor, lineNr, cursorOffset); } - if (ch == '\n' && lineAboveText != null) { + if (ch == '\n' && lineAbove != null) { if (LanguageUtils.IsInsideDocumentationComment(editor, lineAbove, lineAbove.EndOffset)) { editor.Document.Insert(cursorOffset, "''' "); return; @@ -410,7 +410,7 @@ namespace ICSharpCode.VBNetBinding while ((currentToken = lexer.NextToken()).Kind != Tokens.EOF) { if (prevToken == null) prevToken = currentToken; - if (IsBlockStart(lexer, currentToken, prevToken)) { + if (IsBlockStart(lexer, currentToken, prevToken) && !IsAutomaticPropertyWithDefaultValue(lexer, currentToken, prevToken)) { if ((tokens.Count > 0 && tokens.Peek().Kind != Tokens.Interface) || IsDeclaration(currentToken.Kind)) tokens.Push(currentToken); } @@ -438,6 +438,30 @@ namespace ICSharpCode.VBNetBinding return false; } + static bool IsAutomaticPropertyWithDefaultValue(ILexer lexer, Token currentToken, Token prevToken) + { + if (currentToken.Kind != Tokens.Property) + return false; + lexer.StartPeek(); + + int parenthesesNesting = 0; + + // look for parameter list, = or EOL + Token t; + while ((t = lexer.Peek()).Kind != Tokens.EOF) { + if (t.Kind == Tokens.OpenParenthesis) + parenthesesNesting++; + if (t.Kind == Tokens.CloseParenthesis) + parenthesesNesting--; + if (parenthesesNesting == 0 && t.Kind == Tokens.Assign) + return true; + if (t.Kind == Tokens.EOL) + return false; + } + + return false; + } + static Token GetClosestMissing(List missingEnds, VBStatement statement, ITextEditor editor, int lineNr) { Token closest = null; @@ -612,7 +636,7 @@ namespace ICSharpCode.VBNetBinding Indent(editor, indentation, new string(' ', endColumn - startColumn - 1)); } - if (!inInterface && !isMustOverride && !isDeclare && !isDelegate) { + if (!inInterface && !isMustOverride && !isDeclare && !isDelegate && !IsAutomaticPropertyWithDefaultValue(lexer, currentToken, prevToken)) { Indent(editor, indentation); if (currentToken.Kind == Tokens.Select) diff --git a/src/AddIns/BackendBindings/VBNetBinding/Test/FormattingStrategy/EndSubTests.cs b/src/AddIns/BackendBindings/VBNetBinding/Test/FormattingStrategy/EndSubTests.cs index 01d104c1b8..fd3624b556 100644 --- a/src/AddIns/BackendBindings/VBNetBinding/Test/FormattingStrategy/EndSubTests.cs +++ b/src/AddIns/BackendBindings/VBNetBinding/Test/FormattingStrategy/EndSubTests.cs @@ -173,5 +173,52 @@ namespace ICSharpCode.VBNetBinding.Tests RunTest(code, cursorOffset, expectedCode, expectedOffset, '\n'); } + + [Test] + public void AutomaticPropertyWithInitializer() + { + string code = "Public Class Foo\r\n" + + "\tPublic Property Bar As Boolean = True\r\n" + + "\r\n" + // This extra new line is required. This is the new line just entered by the user. + "End Class"; + + string bar = "= True\r\n"; + int cursorOffset = code.IndexOf(bar) + bar.Length; + + string expectedCode = "Public Class Foo\r\n" + + "\tPublic Property Bar As Boolean = True\r\n" + + "\t\r\n" + + "End Class"; + + int expectedOffset = ("Public Class Foo\r\n" + + "\tPublic Property Bar As Boolean = True\r\n" + + "\t").Length; + + RunTest(code, cursorOffset, expectedCode, expectedOffset, '\n'); + } + + [Test] + public void StandardProperty() + { + string code = "Public Class Foo\r\n" + + "\tPublic Property Bar As Boolean\r\n" + + "\r\n" + // This extra new line is required. This is the new line just entered by the user. + "End Class"; + + string bar = "As Boolean\r\n"; + int cursorOffset = code.IndexOf(bar) + bar.Length; + + string expectedCode = "Public Class Foo\r\n" + + "\tPublic Property Bar As Boolean\r\n" + + "\t\t\r\n" + + "\tEnd Property\r\n" + + "End Class"; + + int expectedOffset = ("Public Class Foo\r\n" + + "\tPublic Property Bar As Boolean\r\n" + + "\t\t").Length; + + RunTest(code, cursorOffset, expectedCode, expectedOffset, '\n'); + } } } diff --git a/src/AddIns/Debugger/Debugger.AddIn/Options/DebuggingOptions.cs b/src/AddIns/Debugger/Debugger.AddIn/Options/DebuggingOptions.cs index 216aab5df9..9632eb7b95 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Options/DebuggingOptions.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Options/DebuggingOptions.cs @@ -41,5 +41,26 @@ namespace ICSharpCode.SharpDevelop.Services // Properties for the DebuggeeExceptionForm public FormWindowState DebuggeeExceptionWindowState { get; set; } + + /// + /// Used to update status of some debugger properties while debugger is running. + /// + internal static void ResetStatus(Action resetStatus) + { + Process proc = WindowsDebugger.CurrentProcess; + // debug session is running + if (proc != null) { + bool wasPausedNow = false; + // if it is not paused, break execution + if (!proc.IsPaused) { + proc.Break(); + wasPausedNow = true; + } + resetStatus(proc); + // continue if it was not paused before + if (wasPausedNow) + proc.AsyncContinue(); + } + } } } diff --git a/src/AddIns/Debugger/Debugger.AddIn/Options/DebuggingOptionsPanel.xaml.cs b/src/AddIns/Debugger/Debugger.AddIn/Options/DebuggingOptionsPanel.xaml.cs index f467805274..dd878773cf 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Options/DebuggingOptionsPanel.xaml.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Options/DebuggingOptionsPanel.xaml.cs @@ -50,19 +50,7 @@ namespace Debugger.AddIn.Options public override bool SaveOptions() { bool result = base.SaveOptions(); - Process proc = WindowsDebugger.CurrentProcess; - // debug session is running - if (proc != null) { - bool wasPausedNow = false; - // if it is not paused, break execution - if (!proc.IsPaused) { - proc.Break(); - wasPausedNow = true; - } - proc.Debugger.ResetJustMyCodeStatus(); - // continue if it was not paused before - if (wasPausedNow) proc.AsyncContinue(); - } + DebuggingOptions.ResetStatus(proc => proc.Debugger.ResetJustMyCodeStatus()); return result; } } diff --git a/src/AddIns/Debugger/Debugger.AddIn/Options/DebuggingSymbolsPanel.cs b/src/AddIns/Debugger/Debugger.AddIn/Options/DebuggingSymbolsPanel.cs index 8abeb8e487..2e0329b2a6 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Options/DebuggingSymbolsPanel.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Options/DebuggingSymbolsPanel.cs @@ -30,11 +30,11 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels public override bool StorePanelContents() { DebuggingOptions.Instance.SymbolsSearchPaths = pathList.GetList(); - Process proc = WindowsDebugger.CurrentProcess; - if (proc != null) { - proc.Debugger.ReloadModuleSymbols(); - proc.Debugger.ResetJustMyCodeStatus(); - } + DebuggingOptions.ResetStatus( + proc => { + proc.Debugger.ReloadModuleSymbols(); + proc.Debugger.ResetJustMyCodeStatus(); + }); return true; } } diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/CallStackPad.xaml.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/CallStackPad.xaml.cs index 0edd6f1f3d..960339446d 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Pads/CallStackPad.xaml.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/CallStackPad.xaml.cs @@ -12,6 +12,7 @@ using System.Windows.Media; using Debugger; using Debugger.AddIn.TreeModel; using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Gui.Pads; using ICSharpCode.SharpDevelop.Services; namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -21,10 +22,12 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads /// public partial class CallStackPadContent : UserControl { + CallStackPad callStackPad; Process debuggedProcess; - public CallStackPadContent() + public CallStackPadContent(CallStackPad pad) { + this.callStackPad = pad; InitializeComponent(); view.ContextMenu = CreateMenu(); @@ -40,7 +43,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads extMethodsItem.IsChecked = DebuggingOptions.Instance.ShowExternalMethods; extMethodsItem.Click += delegate { extMethodsItem.IsChecked = DebuggingOptions.Instance.ShowExternalMethods = !DebuggingOptions.Instance.ShowExternalMethods; - CallStackPad.InvalidateCallstackPad(); + callStackPad.InvalidatePad(); }; MenuItem moduleItem = new MenuItem(); @@ -49,7 +52,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads moduleItem.Click += delegate { moduleItem.IsChecked = DebuggingOptions.Instance.ShowModuleNames = !DebuggingOptions.Instance.ShowModuleNames; ((GridView)view.View).Columns[0].Width = DebuggingOptions.Instance.ShowModuleNames ? 100d : 0d; - CallStackPad.InvalidateCallstackPad(); + callStackPad.InvalidatePad(); }; MenuItem argNamesItem = new MenuItem(); @@ -57,7 +60,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads argNamesItem.IsChecked = DebuggingOptions.Instance.ShowArgumentNames; argNamesItem.Click += delegate { argNamesItem.IsChecked = DebuggingOptions.Instance.ShowArgumentNames = !DebuggingOptions.Instance.ShowArgumentNames; - CallStackPad.InvalidateCallstackPad(); + callStackPad.InvalidatePad(); }; MenuItem argValuesItem = new MenuItem(); @@ -65,7 +68,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads argValuesItem.IsChecked = DebuggingOptions.Instance.ShowArgumentValues; argValuesItem.Click += delegate { argValuesItem.IsChecked = DebuggingOptions.Instance.ShowArgumentValues = !DebuggingOptions.Instance.ShowArgumentValues; - CallStackPad.InvalidateCallstackPad(); + callStackPad.InvalidatePad(); }; MenuItem lineItem = new MenuItem(); @@ -74,7 +77,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads lineItem.Click += delegate { lineItem.IsChecked = DebuggingOptions.Instance.ShowLineNumbers = !DebuggingOptions.Instance.ShowLineNumbers; ((GridView)view.View).Columns[2].Width = DebuggingOptions.Instance.ShowLineNumbers ? 50d : 0d; - CallStackPad.InvalidateCallstackPad(); + callStackPad.InvalidatePad(); }; return new ContextMenu() { @@ -98,12 +101,12 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads if (debuggedProcess != null) { debuggedProcess.Paused += debuggedProcess_Paused; } - CallStackPad.InvalidateCallstackPad(); + callStackPad.InvalidatePad(); } void debuggedProcess_Paused(object sender, ProcessEventArgs e) { - CallStackPad.InvalidateCallstackPad(); + callStackPad.InvalidatePad(); } void View_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) @@ -150,13 +153,13 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads var items = new ObservableCollection(); using(new PrintTimes("Callstack refresh")) { bool showExternalMethods = DebuggingOptions.Instance.ShowExternalMethods; - bool previousItemIsExternalMethod = false; + bool previousItemIsExternalMethod = false; - debuggedProcess.EnqueueForEach( - Dispatcher, - debuggedProcess.SelectedThread.GetCallstack(100), - f => items.AddIfNotNull(CreateItem(f, showExternalMethods, ref previousItemIsExternalMethod)) - ); + debuggedProcess.EnqueueForEach( + Dispatcher, + debuggedProcess.SelectedThread.GetCallstack(100), + f => items.AddIfNotNull(CreateItem(f, showExternalMethods, ref previousItemIsExternalMethod)) + ); } view.ItemsSource = items; } @@ -287,7 +290,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads protected override void InitializeComponents() { - callStackList = new CallStackPadContent(); + callStackList = new CallStackPadContent(this); } protected override void SelectProcess(Process process) @@ -299,11 +302,5 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads { callStackList.RefreshPad(); } - - public static void InvalidateCallstackPad() - { - if (instance != null) - instance.InvalidatePad(); - } } } diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/Commands/WatchPadCommands.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/Commands/WatchPadCommands.cs index 8faa9a6054..051113efa6 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Pads/Commands/WatchPadCommands.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/Commands/WatchPadCommands.cs @@ -29,20 +29,13 @@ namespace Debugger.AddIn var inputWindow = new WatchInputBox(StringParser.Parse("${res:MainWindow.Windows.Debug.Watch.AddWatch}"), StringParser.Parse("${res:MainWindow.Windows.Debug.Watch.EnterExpression}")); inputWindow.Owner = ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainWindow; - var result = inputWindow.ShowDialog(); - if (!result.HasValue || !result.Value) + if (inputWindow.ShowDialog() != true) return; string input = inputWindow.CommandText; if (!string.IsNullOrEmpty(input)) { - // get language - if (ProjectService.CurrentProject == null) return; - - string language = ProjectService.CurrentProject.Language; - - var text = new TextNode(null, input, - language == "VB" || language == "VBNet" ? SupportedLanguage.VBNet : SupportedLanguage.CSharp).ToSharpTreeNode(); + var text = new TextNode(null, input, inputWindow.ScriptLanguage).ToSharpTreeNode(); var list = pad.WatchList; if(!list.WatchItems.Any(n => text.Node.FullName == ((TreeNodeWrapper)n).Node.FullName)) diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchList.xaml.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchList.xaml.cs index 07ad0ec678..2809cb6adf 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchList.xaml.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchList.xaml.cs @@ -69,17 +69,18 @@ namespace Debugger.AddIn.Pads.Controls void WatchListAutoCompleteCellCommandEntered(object sender, EventArgs e) { - if (SelectedNode == null) return; + var selectedNode = SelectedNode; + if (selectedNode == null) return; if (WatchType != WatchListType.Watch) return; var cell = ((WatchListAutoCompleteCell)sender); - SelectedNode.Node.Name = cell.CommandText; + selectedNode.Node.Name = cell.CommandText; myList.UnselectAll(); if (WatchType == WatchListType.Watch && WatchPad.Instance != null) { WatchPad.Instance.InvalidatePad(); } - SelectedNode.IsEditing = false; + selectedNode.IsEditing = false; } void MyListPreviewMouseDoubleClick(object sender, MouseButtonEventArgs e) diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchListAutoCompleteCell.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchListAutoCompleteCell.cs index 60e8147132..4b26e798e4 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchListAutoCompleteCell.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchListAutoCompleteCell.cs @@ -121,9 +121,9 @@ namespace Debugger.AddIn.Pads.Controls // FIXME workaround the NRefactory issue that needs a ; at the end if (language == "C#" || language == "CSharp") { - if(!command.EndsWith(";")) + if (!command.EndsWith(";")) command += ";"; - // FIXME only one string should be available; highlighting expects C#, supproted language, CSharp + // FIXME only one string should be available; highlighting expects C#, supported language, CSharp language = "CSharp"; } diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchInputBox.xaml.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchInputBox.xaml.cs index e2cb564716..5e0ea97792 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchInputBox.xaml.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchInputBox.xaml.cs @@ -13,7 +13,9 @@ using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Debugging; using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver; +using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor.CodeCompletion; +using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui.Pads; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Services; @@ -25,8 +27,12 @@ namespace Debugger.AddIn.Pads /// public partial class WatchInputBox : BaseWatchBox { - private NRefactoryResolver resolver; - private string language; + NRefactoryResolver resolver; + SupportedLanguage language; + + public SupportedLanguage ScriptLanguage { + get { return language; } + } public WatchInputBox(string text, string caption) : base() { @@ -37,18 +43,20 @@ namespace Debugger.AddIn.Pads this.Title = StringParser.Parse(caption); this.ConsolePanel.Content = console; - if (ProjectService.CurrentProject == null) return; - - // get language - language = ProjectService.CurrentProject.Language; - resolver = new NRefactoryResolver(LanguageProperties.GetLanguage(language)); - - // FIXME set language - if (language == "VB" || language == "VBNet") { - console.SetHighlighting("VBNET"); - } else { - language = "C#"; - console.SetHighlighting("C#"); + if (ProjectService.CurrentProject == null) + language = GetLanguageFromActiveViewContent(); + else + language = GetLanguage(ProjectService.CurrentProject.Language); + + resolver = new NRefactoryResolver(LanguageProperties.GetLanguage(language.ToString())); + + switch (language) { + case SupportedLanguage.CSharp: + console.SetHighlighting("C#"); + break; + case SupportedLanguage.VBNet: + console.SetHighlighting("VBNET"); + break; } // get process @@ -72,7 +80,7 @@ namespace Debugger.AddIn.Pads } } - private void ShowDotCompletion(string currentText) + void ShowDotCompletion(string currentText) { var seg = Process.SelectedStackFrame.NextStatement; @@ -94,20 +102,15 @@ namespace Debugger.AddIn.Pads } } - private bool CheckSyntax() + bool CheckSyntax() { string command = console.CommandText.Trim(); // FIXME workaround the NRefactory issue that needs a ; at the end - if (language == "C#") { - if(!command.EndsWith(";")) - command += ";"; - // FIXME only one string should be available; highlighting expects C#, supproted language, CSharp - language = "CSharp"; - } + if (language == SupportedLanguage.CSharp && !command.EndsWith(";")) + command += ";"; - SupportedLanguage supportedLanguage = (SupportedLanguage)Enum.Parse(typeof(SupportedLanguage), language, true); - using (var parser = ParserFactory.CreateParser(supportedLanguage, new StringReader(command))) { + using (var parser = ParserFactory.CreateParser(language, new StringReader(command))) { parser.ParseExpression(); if (parser.Errors.Count > 0) { MessageService.ShowError(parser.Errors.ErrorOutput); @@ -118,7 +121,38 @@ namespace Debugger.AddIn.Pads return true; } - private void AcceptButton_Click(object sender, RoutedEventArgs e) + SupportedLanguage GetLanguage(string language) + { + if ("VBNet".Equals(language, StringComparison.OrdinalIgnoreCase) + || "VB".Equals(language, StringComparison.OrdinalIgnoreCase) + || "VB.NET".Equals(language, StringComparison.OrdinalIgnoreCase)) + return SupportedLanguage.VBNet; + + return SupportedLanguage.CSharp; + } + + /// + /// Gets the language used in the currently active view content. This is useful, when there is no project + /// opened and we still want to add watches (i.e. the debugger is attached to an existing process without a solution). + /// + SupportedLanguage GetLanguageFromActiveViewContent() + { + ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorProvider; + + if (provider != null && provider.TextEditor != null) { + string extension = Path.GetExtension(provider.TextEditor.FileName).ToLowerInvariant(); + switch (extension) { + case ".cs": + return SupportedLanguage.CSharp; + case ".vb": + return SupportedLanguage.VBNet; + } + } + + return SupportedLanguage.CSharp; + } + + void AcceptButton_Click(object sender, RoutedEventArgs e) { if (!this.CheckSyntax()) return; @@ -127,7 +161,7 @@ namespace Debugger.AddIn.Pads this.Close(); } - private void CancelButton_Click(object sender, RoutedEventArgs e) + void CancelButton_Click(object sender, RoutedEventArgs e) { DialogResult = false; this.Close(); diff --git a/src/AddIns/Debugger/Debugger.Core/ManagedCallback.cs b/src/AddIns/Debugger/Debugger.Core/ManagedCallback.cs index 1ac7c330b5..7842aa06fa 100644 --- a/src/AddIns/Debugger/Debugger.Core/ManagedCallback.cs +++ b/src/AddIns/Debugger/Debugger.Core/ManagedCallback.cs @@ -74,7 +74,7 @@ namespace Debugger void EnterCallback(PausedReason pausedReason, string name, ICorDebugThread pThread) { EnterCallback(pausedReason, name, pThread.GetProcess()); - process.SelectedThread = process.Threads[pThread]; + process.SelectedThread = process.GetThread(pThread); } void ExitCallback() @@ -128,7 +128,7 @@ namespace Debugger { EnterCallback(PausedReason.StepComplete, "StepComplete (" + reason.ToString() + ")", pThread); - Thread thread = process.Threads[pThread]; + Thread thread = process.GetThread(pThread); Stepper stepper = process.GetStepper(pStepper); StackFrame currentStackFrame = process.SelectedThread.MostRecentStackFrame; @@ -378,7 +378,7 @@ namespace Debugger EnterCallback(PausedReason.Other, "NameChange: pThread", pThread); - Thread thread = process.Threads[pThread]; + Thread thread = process.GetThread(pThread); thread.NotifyNameChanged(); ExitCallback(); @@ -445,7 +445,7 @@ namespace Debugger if (process.Threads.Contains(pThread)) { EnterCallback(PausedReason.Other, "ExitThread " + pThread.GetID(), pThread); - process.Threads[pThread].NotifyExited(); + process.GetThread(pThread).NotifyExited(); } else { EnterCallback(PausedReason.Other, "ExitThread " + pThread.GetID(), process.CorProcess); diff --git a/src/AddIns/Debugger/Debugger.Core/MetaData/DebugMethodInfo.cs b/src/AddIns/Debugger/Debugger.Core/MetaData/DebugMethodInfo.cs index 2882714214..37a0fed063 100644 --- a/src/AddIns/Debugger/Debugger.Core/MetaData/DebugMethodInfo.cs +++ b/src/AddIns/Debugger/Debugger.Core/MetaData/DebugMethodInfo.cs @@ -187,12 +187,12 @@ namespace Debugger.MetaData /// public override bool IsGenericMethod { - get { return methodDefSig.GenericParameterCount > 0; } + get { return this.MethodDefSig.GenericParameterCount > 0; } } /// public override bool IsGenericMethodDefinition { - get { return methodDefSig.GenericParameterCount > 0; } + get { return this.MethodDefSig.GenericParameterCount > 0; } } /// diff --git a/src/AddIns/Debugger/Debugger.Core/Process.cs b/src/AddIns/Debugger/Debugger.Core/Process.cs index 3ca68f7a06..268bd63f3f 100644 --- a/src/AddIns/Debugger/Debugger.Core/Process.cs +++ b/src/AddIns/Debugger/Debugger.Core/Process.cs @@ -233,6 +233,18 @@ namespace Debugger return written; } + internal Thread GetThread(ICorDebugThread corThread) + { + foreach(Thread thread in this.Threads) { + if (thread.CorThread == corThread) { + return thread; + } + } + Thread t = new Thread(this, corThread); + this.Threads.Add(t); + return t; + } + #region Exceptions public event EventHandler ExceptionThrown; diff --git a/src/AddIns/Debugger/Debugger.Core/ThreadCollection.cs b/src/AddIns/Debugger/Debugger.Core/ThreadCollection.cs index 500b52aa46..b8bd30ef1c 100644 --- a/src/AddIns/Debugger/Debugger.Core/ThreadCollection.cs +++ b/src/AddIns/Debugger/Debugger.Core/ThreadCollection.cs @@ -38,16 +38,5 @@ namespace Debugger } return false; } - - internal Thread this[ICorDebugThread corThread] { - get { - foreach(Thread thread in this) { - if (thread.CorThread == corThread) { - return thread; - } - } - throw new DebuggerException("Thread is not in collection"); - } - } } } diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj index 37b25488ec..826e8cdab4 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj @@ -102,6 +102,7 @@ + diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs index 7ed3925a5c..09de907e73 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs @@ -276,7 +276,8 @@ namespace ICSharpCode.AvalonEdit.AddIn { if (trackedFeature != null) trackedFeature.EndTracking(); - this.PrimaryFile.IsDirtyChanged -= PrimaryFile_IsDirtyChanged; + if (PrimaryFile != null) + this.PrimaryFile.IsDirtyChanged -= PrimaryFile_IsDirtyChanged; base.Dispose(); BookmarksDetach(); codeEditor.Dispose(); diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ChangeMarkerMargin.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ChangeMarkerMargin.cs index 89f1cc3417..2634a84377 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ChangeMarkerMargin.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ChangeMarkerMargin.cs @@ -39,7 +39,6 @@ namespace ICSharpCode.AvalonEdit.AddIn { if (!disposed) { changeWatcher.ChangeOccurred -= ChangeOccurred; - changeWatcher.Dispose(); disposed = true; } } diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs index 6189d7d093..f393ea9bef 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs @@ -609,6 +609,8 @@ namespace ICSharpCode.AvalonEdit.AddIn if (errorPainter != null) errorPainter.Dispose(); + if (changeWatcher != null) + changeWatcher.Dispose(); this.Document = null; DisposeTextEditor(primaryTextEditor); if (secondaryTextEditor != null) diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/DefaultChangeWatcher.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/DefaultChangeWatcher.cs index f98d5556b1..f760c4e48d 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/DefaultChangeWatcher.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/DefaultChangeWatcher.cs @@ -198,8 +198,10 @@ namespace ICSharpCode.AvalonEdit.AddIn if (!disposed) { if (watcher != null) watcher.Dispose(); - this.textDocument.LineTrackers.Remove(this); - this.textDocument.UndoStack.PropertyChanged -= UndoStackPropertyChanged; + if (this.textDocument != null) { + this.textDocument.LineTrackers.Remove(this); + this.textDocument.UndoStack.PropertyChanged -= UndoStackPropertyChanged; + } disposed = true; } } diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopCompletionWindow.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopCompletionWindow.cs index 955d8bbece..18420e587d 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopCompletionWindow.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopCompletionWindow.cs @@ -125,6 +125,9 @@ namespace ICSharpCode.AvalonEdit.AddIn case CompletionItemListKeyResult.InsertionKey: this.CompletionList.RequestInsertion(e); return; + case CompletionItemListKeyResult.Cancel: + Close(); + return; } } } diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Snippets/CodeSnippet.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Snippets/CodeSnippet.cs index 5cfbe14f7c..7b22bd779f 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Snippets/CodeSnippet.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Snippets/CodeSnippet.cs @@ -6,20 +6,21 @@ using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text.RegularExpressions; + using ICSharpCode.AvalonEdit.Snippets; using ICSharpCode.NRefactory.TypeSystem; +using ICSharpCode.NRefactory.TypeSystem.Implementation; using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor.AvalonEdit; using ICSharpCode.SharpDevelop.Editor.CodeCompletion; -using ICSharpCode.SharpDevelop.Parser; namespace ICSharpCode.AvalonEdit.AddIn.Snippets { /// /// A code snippet. /// - public class CodeSnippet : INotifyPropertyChanged, IEquatable + public class CodeSnippet : AbstractFreezable, INotifyPropertyChanged { string name = string.Empty, description = string.Empty, text = string.Empty, keyword = string.Empty; @@ -38,6 +39,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Snippets public string Name { get { return name; } set { + FreezableHelper.ThrowIfFrozen(this); if (name != value) { name = value ?? string.Empty; OnPropertyChanged("Name"); @@ -48,6 +50,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Snippets public string Text { get { return text; } set { + FreezableHelper.ThrowIfFrozen(this); if (text != value) { text = value ?? string.Empty; OnPropertyChanged("Text"); @@ -58,6 +61,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Snippets public string Description { get { return description; } set { + FreezableHelper.ThrowIfFrozen(this); if (description != value) { description = value ?? string.Empty; OnPropertyChanged("Description"); @@ -76,6 +80,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Snippets public string Keyword { get { return keyword; } set { + FreezableHelper.ThrowIfFrozen(this); if (keyword != value) { keyword = value ?? string.Empty; OnPropertyChanged("Keyword"); @@ -229,41 +234,12 @@ namespace ICSharpCode.AvalonEdit.AddIn.Snippets } } - public override int GetHashCode() - { - int hashCode = 0; - unchecked { - if (name != null) - hashCode += 1000000007 * name.GetHashCode(); - if (description != null) - hashCode += 1000000009 * description.GetHashCode(); - if (text != null) - hashCode += 1000000021 * text.GetHashCode(); - if (keyword != null) - hashCode += 1000000033 * keyword.GetHashCode(); - } - return hashCode; - } - - public override bool Equals(object obj) - { - CodeSnippet other = obj as CodeSnippet; - return Equals(other); - } - - public bool Equals(CodeSnippet other) - { - if (other == null) - return false; - return this.name == other.name && this.description == other.description && this.text == other.text && this.keyword == other.keyword; - } - /// /// Reports the snippet usage to UDC /// internal void TrackUsage(string activationMethod) { - bool isUserModified = !SnippetManager.defaultSnippets.Any(g => g.Snippets.Contains(this)); + bool isUserModified = !SnippetManager.Instance.defaultSnippets.Any(g => g.Snippets.Contains(this, CodeSnippetComparer.Instance)); SD.AnalyticsMonitor.TrackFeature(typeof(CodeSnippet), isUserModified ? "usersnippet" : Name, activationMethod); } } diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Snippets/CodeSnippetComparer.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Snippets/CodeSnippetComparer.cs new file mode 100644 index 0000000000..0eed621795 --- /dev/null +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Snippets/CodeSnippetComparer.cs @@ -0,0 +1,30 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; + +namespace ICSharpCode.AvalonEdit.AddIn.Snippets +{ + /// + /// Compares code snippets. + /// + public class CodeSnippetComparer : IEqualityComparer + { + public static readonly CodeSnippetComparer Instance = new CodeSnippetComparer(); + + public bool Equals(CodeSnippet x, CodeSnippet y) + { + if (x == y) + return true; + if (x == null || y == null) + return false; + return x.Name == y.Name && x.Description == y.Description && x.Text == y.Text && x.Keyword == y.Keyword; + } + + public int GetHashCode(CodeSnippet obj) + { + return obj != null ? obj.Name.GetHashCode() : 0; + } + } +} diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Snippets/CodeSnippetGroup.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Snippets/CodeSnippetGroup.cs index 816f5e622c..91747c9971 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Snippets/CodeSnippetGroup.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Snippets/CodeSnippetGroup.cs @@ -4,14 +4,28 @@ using System; using System.Collections.ObjectModel; using System.ComponentModel; +using System.Linq; + +using ICSharpCode.NRefactory.TypeSystem.Implementation; +using ICSharpCode.SharpDevelop; namespace ICSharpCode.AvalonEdit.AddIn.Snippets { /// /// A group of snippets (for a specific file extension). /// - public class CodeSnippetGroup : INotifyPropertyChanged + public class CodeSnippetGroup : AbstractFreezable, INotifyPropertyChanged { + public CodeSnippetGroup() + { + } + + public CodeSnippetGroup(CodeSnippetGroup g) + { + this.Extensions = g.Extensions; + this.Snippets.AddRange(g.Snippets.Select(s => new CodeSnippet(s))); + } + string extensions = ""; ObservableCollection snippets = new ObservableCollection(); @@ -19,11 +33,20 @@ namespace ICSharpCode.AvalonEdit.AddIn.Snippets get { return snippets; } } + protected override void FreezeInternal() + { + base.FreezeInternal(); + foreach (var snippet in this.snippets) + snippet.Freeze(); + this.snippets.CollectionChanged += delegate { throw new NotSupportedException(); }; + } + public string Extensions { get { return extensions; } set { if (value == null) throw new ArgumentNullException(); + FreezableHelper.ThrowIfFrozen(this); if (extensions != value) { extensions = value; OnPropertyChanged("Extensions"); diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Snippets/SnippetManager.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Snippets/SnippetManager.cs index d149c250fa..dd1f890265 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Snippets/SnippetManager.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Snippets/SnippetManager.cs @@ -18,7 +18,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Snippets public sealed class SnippetManager { readonly object lockObj = new object(); - internal static readonly List defaultSnippets = new List { + internal readonly List defaultSnippets = new List { new CodeSnippetGroup { Extensions = ".cs", Snippets = { @@ -304,6 +304,8 @@ End Property${Caret}", private SnippetManager() { + foreach (var g in defaultSnippets) + g.Freeze(); snippetElementProviders = AddInTree.BuildItems("/SharpDevelop/ViewContent/AvalonEdit/SnippetElementProviders", null, false); } @@ -314,6 +316,10 @@ End Property${Caret}", { var savedSnippets = new List(PropertyService.GetList("CodeSnippets")); + // HACK: clone all groups to ensure we use instances independent from the PropertyService + // this can be removed in SD5 where PropertyService.Get deserializes a new instance on every call. + savedSnippets = savedSnippets.Select(g => new CodeSnippetGroup(g)).ToList(); + foreach (var group in savedSnippets) { var defaultGroup = defaultSnippets.FirstOrDefault(i => i.Extensions == group.Extensions); if (defaultGroup != null) { @@ -329,7 +335,7 @@ End Property${Caret}", } foreach (var group in defaultSnippets.Except(savedSnippets, new ByMemberComparer(g => g.Extensions))) { - savedSnippets.Add(group); + savedSnippets.Add(new CodeSnippetGroup(group)); } return savedSnippets; @@ -371,7 +377,7 @@ End Property${Caret}", IEnumerable saveSnippets = group.Snippets; if (defaultGroup != null) { - saveSnippets = group.Snippets.Except(defaultGroup.Snippets); + saveSnippets = group.Snippets.Except(defaultGroup.Snippets, CodeSnippetComparer.Instance); } // save all groups, even if they're empty @@ -391,8 +397,11 @@ End Property${Caret}", public ReadOnlyCollection ActiveGroups { get { lock (lockObj) { - if (activeGroups == null) + if (activeGroups == null) { activeGroups = LoadGroups().AsReadOnly(); + foreach (var g in activeGroups) + g.Freeze(); + } return activeGroups; } } diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/AbstractDesignerGenerator.cs b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/AbstractDesignerGenerator.cs index c656b83996..cda90f1c2e 100644 --- a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/AbstractDesignerGenerator.cs +++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/AbstractDesignerGenerator.cs @@ -337,10 +337,10 @@ namespace ICSharpCode.FormsDesigner foreach (var stmt in initializeComponent.Statements.OfType().Where(ces => ces.Expression is CodeMethodInvokeExpression)) { CodeMethodInvokeExpression invocation = (CodeMethodInvokeExpression)stmt.Expression; - if (invocation.Method.TargetObject is CodeCastExpression) { - CodeCastExpression expr = (CodeCastExpression)invocation.Method.TargetObject; - CodeFieldReferenceExpression fieldRef = (CodeFieldReferenceExpression)expr.Expression; - if (!(fieldRef.TargetObject is CodeThisReferenceExpression)) + CodeCastExpression expr = invocation.Method.TargetObject as CodeCastExpression; + if (expr != null) { + CodeFieldReferenceExpression fieldRef = expr.Expression as CodeFieldReferenceExpression; + if (fieldRef == null || !(fieldRef.TargetObject is CodeThisReferenceExpression)) continue; if (expr.TargetType.BaseType != "System.ComponentModel.ISupportInitialize") continue; diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/ResourceStore.cs b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/ResourceStore.cs index 4e34fd61b8..30de41c535 100644 --- a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/ResourceStore.cs +++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/ResourceStore.cs @@ -37,7 +37,7 @@ namespace ICSharpCode.FormsDesigner.Services { ResourceStorage storage; if (!resources.TryGetValue(culture.Name, out storage)) { - storage = resources[culture.Name] = new ResourceStorage(culture.Name); + storage = resources[culture.Name] = new ResourceStorage(culture.Name, viewContent.PrimaryFileName); string fileName = CalcResourceFileName(viewContent.PrimaryFileName, culture.Name); CreateOpenedFileForStorage(storage, fileName, File.Exists(fileName)); } @@ -108,12 +108,14 @@ namespace ICSharpCode.FormsDesigner.Services IResourceWriter writer; byte[] buffer; readonly string cultureName; + string parentDesignerSourceFileName; internal OpenedFile OpenedFile; internal bool IsNewFile; - public ResourceStorage(string cultureName) + public ResourceStorage(string cultureName, string parentDesignerSourceFileName) { this.cultureName = cultureName; + this.parentDesignerSourceFileName = parentDesignerSourceFileName; } public void Dispose() @@ -204,7 +206,7 @@ namespace ICSharpCode.FormsDesigner.Services public IResourceWriter GetWriter() { this.stream = new MemoryStream(); - this.writer = CreateResourceWriter(this.stream, GetResourceType(OpenedFile.FileName)); + this.writer = CreateResourceWriter(this.stream, GetResourceType(OpenedFile.FileName), parentDesignerSourceFileName); return this.writer; } @@ -335,12 +337,12 @@ namespace ICSharpCode.FormsDesigner.Services return new ResXResourceReader(stream); } - internal static IResourceWriter CreateResourceWriter(Stream stream, ResourceType type) + internal static IResourceWriter CreateResourceWriter(Stream stream, ResourceType type, string parentDesignerSourceFileName) { if (type == ResourceType.Resources) { return new ResourceWriter(stream); } - return new ResXResourceWriter(stream); + return new ResXResourceWriter(stream, t => ResXConverter.ConvertTypeName(t, parentDesignerSourceFileName)); } internal static ResourceType GetResourceType(string fileName) diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeResolutionService.cs b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeResolutionService.cs index 7862e938c0..943c8c39aa 100644 --- a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeResolutionService.cs +++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeResolutionService.cs @@ -122,6 +122,10 @@ namespace ICSharpCode.FormsDesigner.Services if (!projectContentsCurrentlyLoadingAssembly.Add(pc)) return null; + Assembly sdAssembly; + if (IsSharpDevelopAssembly(pc, out sdAssembly)) + return sdAssembly; + try { // load dependencies of current assembly foreach (IProjectContent rpc in pc.ReferencedContents) { @@ -151,6 +155,20 @@ namespace ICSharpCode.FormsDesigner.Services } } + readonly string sharpDevelopRoot = Directory.GetParent(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)).FullName; + + bool IsSharpDevelopAssembly(IProjectContent pc, out Assembly assembly) + { + assembly = null; + foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) { + if (!asm.IsDynamic && asm.Location.StartsWith(sharpDevelopRoot, StringComparison.OrdinalIgnoreCase) && pc.AssemblyName == asm.GetName().Name) { + assembly = asm; + return true; + } + } + return false; + } + static string GetHash(string fileName) { return Path.GetFileName(fileName).ToLowerInvariant() + File.GetLastWriteTimeUtc(fileName).Ticks.ToString(); diff --git a/src/AddIns/DisplayBindings/ResourceEditor/Project/Src/ResourceEdit/ResourceList.cs b/src/AddIns/DisplayBindings/ResourceEditor/Project/Src/ResourceEdit/ResourceList.cs index 738a5ebc85..7c6d199542 100644 --- a/src/AddIns/DisplayBindings/ResourceEditor/Project/Src/ResourceEdit/ResourceList.cs +++ b/src/AddIns/DisplayBindings/ResourceEditor/Project/Src/ResourceEdit/ResourceList.cs @@ -8,9 +8,9 @@ using System.Drawing.Printing; using System.IO; using System.Resources; using System.Windows.Forms; - using ICSharpCode.Core; using ICSharpCode.Core.WinForms; +using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Widgets.ListViewSorting; namespace ResourceEditor @@ -174,7 +174,7 @@ namespace ResourceEditor // write XML resource case ".resx": - ResXResourceWriter rxw = new ResXResourceWriter(stream); + ResXResourceWriter rxw = new ResXResourceWriter(stream, t => ResXConverter.ConvertTypeName(t, filename)); foreach (KeyValuePair entry in resources) { if (entry.Value != null) { ResourceItem item = entry.Value; diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCodeCompletionBinding.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCodeCompletionBinding.cs index fa1de75b7f..75ec3943c4 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCodeCompletionBinding.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCodeCompletionBinding.cs @@ -2,10 +2,8 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using System.Collections.Generic; -using System.IO; using System.Linq; -using ICSharpCode.Core; +using ICSharpCode.NRefactory.Editor; using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor.CodeCompletion; @@ -27,7 +25,7 @@ namespace ICSharpCode.XmlEditor this.schemas = schemaFileAssociations.Schemas; } - char[] ignoredChars = new[] { '\\', '/', '"', '\'', '=', '>' }; + char[] ignoredChars = new[] { '\\', '/', '"', '\'', '=', '>', '!', '?' }; public CodeCompletionKeyPressResult HandleKeyPress(ITextEditor editor, char ch) { @@ -62,6 +60,14 @@ namespace ICSharpCode.XmlEditor public bool CtrlSpace(ITextEditor editor) { + int elementStartIndex = XmlParser.GetActiveElementStartIndex(editor.Document.Text, editor.Caret.Offset); + if (elementStartIndex <= -1) + return false; + if (ElementStartsWith(" 0) diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCompletionItemCollection.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCompletionItemCollection.cs index f11a995ee5..cd2204551e 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCompletionItemCollection.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCompletionItemCollection.cs @@ -15,7 +15,7 @@ namespace ICSharpCode.XmlEditor public XmlCompletionItemCollection() { - normalKeys.AddRange(new char[] { ' ', ':', '.', '_' }); + normalKeys.AddRange(new char[] { ':', '.', '_' }); } public XmlCompletionItemCollection(XmlCompletionItemCollection items) @@ -120,11 +120,12 @@ namespace ICSharpCode.XmlEditor public CompletionItemListKeyResult ProcessInput(char key) { - if (char.IsLetterOrDigit(key)) { + if (key == '!' || key == '?') + return CompletionItemListKeyResult.Cancel; + if (char.IsLetterOrDigit(key)) return CompletionItemListKeyResult.NormalKey; - } else if (normalKeys.Contains(key)) { + if (normalKeys.Contains(key)) return CompletionItemListKeyResult.NormalKey; - } return CompletionItemListKeyResult.InsertionKey; } diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlFormattingStrategy.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlFormattingStrategy.cs index b99a439e5a..155d9e16cb 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlFormattingStrategy.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlFormattingStrategy.cs @@ -151,12 +151,7 @@ namespace ICSharpCode.XmlEditor else newText = currentIndentation + lineText.Trim(); - if (newText != lineText) { - int extraCharsToBeAddedAtStartedOfLine = newText.Length - lineText.Length; - document.Replace(line.Offset, line.Length, newText); - TextLocation caretLocation = document.GetLocation(line.Offset + extraCharsToBeAddedAtStartedOfLine); - editor.Caret.Location = caretLocation; - } + document.SmartReplaceLine(line, newText); nextLine++; } if (r.LineNumber > end) diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Completion/ProcessKeyTests.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Completion/ProcessKeyTests.cs index 2a241f4835..6449030319 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Completion/ProcessKeyTests.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Completion/ProcessKeyTests.cs @@ -24,7 +24,7 @@ namespace XmlEditor.Tests.Completion [Test] public void ProcessInputWithSpaceCharReturnsNormalKey() { - Assert.AreEqual(CompletionItemListKeyResult.NormalKey, completionItems.ProcessInput(' ')); + Assert.AreEqual(CompletionItemListKeyResult.InsertionKey, completionItems.ProcessInput(' ')); } [Test] diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Editor/IndentChildElementEndTagAfterNewLineTypedTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Editor/IndentChildElementEndTagAfterNewLineTypedTestFixture.cs index 56ef571728..0778d898f0 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Editor/IndentChildElementEndTagAfterNewLineTypedTestFixture.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Editor/IndentChildElementEndTagAfterNewLineTypedTestFixture.cs @@ -72,14 +72,5 @@ namespace XmlEditor.Tests.Editor Assert.AreEqual(expectedText, textDocument.Text); } - - [Test] - public void CursorIsJustBeforeChildEndElementEndTagAfterIndent() - { - int line = 3; - int column = 2; - var expectedLocation = new TextLocation(line, column); - Assert.AreEqual(expectedLocation, textEditor.Caret.Location); - } } } diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockDocument.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockDocument.cs index 5a9ffb06c6..e81708fd8e 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockDocument.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockDocument.cs @@ -20,10 +20,12 @@ namespace XmlEditor.Tests.Utils public List PositionToOffsetReturnValues = new List(); - public MockDocument() + MockTextEditor editor; + + public MockDocument(MockTextEditor editor = null) { + this.editor = editor; } - public string Text { get { return text; } set { text = value; } @@ -75,6 +77,8 @@ namespace XmlEditor.Tests.Utils public void Insert(int offset, string text) { this.text = this.text.Insert(offset, text); + if (editor != null && editor.Caret.Offset == offset) + editor.Caret.Offset += text.Length; } public void Insert(int offset, string text, AnchorMovementType defaultAnchorMovementType) diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockTextEditor.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockTextEditor.cs index d650e982dc..00efb19087 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockTextEditor.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockTextEditor.cs @@ -18,7 +18,7 @@ namespace XmlEditor.Tests.Utils MockCompletionListWindow completionWindowDisplayed; ICompletionItemList completionItemsDisplayed; ITextEditorCaret caret = MockRepository.GenerateStub(); - IDocument document = new MockDocument(); + IDocument document; ITextEditorOptions options = new MockTextEditorOptions(); FileName fileName; bool showCompletionWindowReturnsNull; @@ -28,6 +28,7 @@ namespace XmlEditor.Tests.Utils public MockTextEditor() { + document = new MockDocument(this); } public event EventHandler SelectionChanged; diff --git a/src/AddIns/Misc/PackageManagement/Project/PackageManagement.csproj b/src/AddIns/Misc/PackageManagement/Project/PackageManagement.csproj index ab37b7482a..467ef85879 100644 --- a/src/AddIns/Misc/PackageManagement/Project/PackageManagement.csproj +++ b/src/AddIns/Misc/PackageManagement/Project/PackageManagement.csproj @@ -70,6 +70,7 @@ + diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/AvailablePackagesViewModel.cs b/src/AddIns/Misc/PackageManagement/Project/Src/AvailablePackagesViewModel.cs index d5be42c56c..86876e3a68 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/AvailablePackagesViewModel.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/AvailablePackagesViewModel.cs @@ -43,13 +43,9 @@ namespace ICSharpCode.PackageManagement protected override IEnumerable GetFilteredPackagesBeforePagingResults(IQueryable allPackages) { - IEnumerable filteredPackages = base.GetFilteredPackagesBeforePagingResults(allPackages); - return GetDistinctPackagesById(filteredPackages); - } - - IEnumerable GetDistinctPackagesById(IEnumerable allPackages) - { - return allPackages.DistinctLast(PackageEqualityComparer.Id); + return base.GetFilteredPackagesBeforePagingResults(allPackages) + .Where(package => package.IsReleaseVersion()) + .DistinctLast(PackageEqualityComparer.Id); } } } diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/ConfigSettingsFileSystem.cs b/src/AddIns/Misc/PackageManagement/Project/Src/ConfigSettingsFileSystem.cs new file mode 100644 index 0000000000..daccf7b809 --- /dev/null +++ b/src/AddIns/Misc/PackageManagement/Project/Src/ConfigSettingsFileSystem.cs @@ -0,0 +1,24 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.IO; +using ICSharpCode.SharpDevelop.Project; +using NuGet; + +namespace ICSharpCode.PackageManagement +{ + public class ConfigSettingsFileSystem : PhysicalFileSystem + { + ConfigSettingsFileSystem(string root) + : base(root) + { + } + + public static ConfigSettingsFileSystem CreateConfigSettingsFileSystem(Solution solution) + { + string configSettingsFolder = Path.Combine(solution.Directory, ".nuget"); + return new ConfigSettingsFileSystem(configSettingsFolder); + } + } +} diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeProjectSystem.cs b/src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeProjectSystem.cs index 72cd36e734..761a699bf9 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeProjectSystem.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeProjectSystem.cs @@ -54,5 +54,7 @@ namespace ICSharpCode.PackageManagement.Design { throw new NotImplementedException(); } + + public bool IsBindingRedirectSupported { get; set; } } } diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeSettings.cs b/src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeSettings.cs index a480329bff..84afc7bf54 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeSettings.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeSettings.cs @@ -118,5 +118,15 @@ namespace ICSharpCode.PackageManagement.Design AddFakePackageSource(packageSource); } } + + public IList> GetNestedValues(string section, string key) + { + throw new NotImplementedException(); + } + + public void SetNestedValues(string section, string key, IList> values) + { + throw new NotImplementedException(); + } } } diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/ISharpDevelopPackageRepositoryFactory.cs b/src/AddIns/Misc/PackageManagement/Project/Src/ISharpDevelopPackageRepositoryFactory.cs index 58d6c938aa..19029c8030 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/ISharpDevelopPackageRepositoryFactory.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/ISharpDevelopPackageRepositoryFactory.cs @@ -11,7 +11,8 @@ namespace ICSharpCode.PackageManagement { ISharedPackageRepository CreateSharedRepository( IPackagePathResolver pathResolver, - IFileSystem fileSystem); + IFileSystem fileSystem, + IFileSystem configSettingsFileSystem); IRecentPackageRepository CreateRecentPackageRepository( IList recentPackages, diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementOptions.cs b/src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementOptions.cs index bd587c46f1..25772f88ab 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementOptions.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementOptions.cs @@ -26,7 +26,7 @@ namespace ICSharpCode.PackageManagement } public PackageManagementOptions(Properties properties) - : this(properties, Settings.DefaultSettings) + : this(properties, Settings.LoadDefaultSettings()) { } diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/PackageReferenceFileNameForProject.cs b/src/AddIns/Misc/PackageManagement/Project/Src/PackageReferenceFileNameForProject.cs index de26abddc7..84d7c3fe7b 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/PackageReferenceFileNameForProject.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/PackageReferenceFileNameForProject.cs @@ -17,7 +17,7 @@ namespace ICSharpCode.PackageManagement void GetFileNameForProject(IProject project) { - FileName = Path.Combine(project.Directory, PackageReferenceRepository.PackageReferenceFile); + FileName = Path.Combine(project.Directory, Constants.PackageReferenceFile); } public string FileName { get; private set; } diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/PackageRepositoryCache.cs b/src/AddIns/Misc/PackageManagement/Project/Src/PackageRepositoryCache.cs index ed44642528..be95abfacb 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/PackageRepositoryCache.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/PackageRepositoryCache.cs @@ -62,9 +62,9 @@ namespace ICSharpCode.PackageManagement return repository; } - public ISharedPackageRepository CreateSharedRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem) + public ISharedPackageRepository CreateSharedRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, IFileSystem configSettingsFileSystem) { - return factory.CreateSharedRepository(pathResolver, fileSystem); + return factory.CreateSharedRepository(pathResolver, fileSystem, configSettingsFileSystem); } public IPackageRepository CreateAggregateRepository() diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/ProjectTemplatePackageRepositoryCache.cs b/src/AddIns/Misc/PackageManagement/Project/Src/ProjectTemplatePackageRepositoryCache.cs index 72c3aed9c1..cb827da187 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/ProjectTemplatePackageRepositoryCache.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/ProjectTemplatePackageRepositoryCache.cs @@ -46,7 +46,7 @@ namespace ICSharpCode.PackageManagement } } - public ISharedPackageRepository CreateSharedRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem) + public ISharedPackageRepository CreateSharedRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, IFileSystem configSettingsFileSystem) { throw new NotImplementedException(); } diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/SharpDevelopPackageManagerFactory.cs b/src/AddIns/Misc/PackageManagement/Project/Src/SharpDevelopPackageManagerFactory.cs index 736783326b..97b65f0366 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/SharpDevelopPackageManagerFactory.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/SharpDevelopPackageManagerFactory.cs @@ -55,10 +55,5 @@ namespace ICSharpCode.PackageManagement { return projectSystemFactory.CreateProjectSystem(project); } - - ISharedPackageRepository CreateSharedRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem) - { - return packageRepositoryFactory.CreateSharedRepository(pathResolver, fileSystem); - } } } diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/SharpDevelopPackageRepositoryFactory.cs b/src/AddIns/Misc/PackageManagement/Project/Src/SharpDevelopPackageRepositoryFactory.cs index 7f41647dda..043e85e8c4 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/SharpDevelopPackageRepositoryFactory.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/SharpDevelopPackageRepositoryFactory.cs @@ -23,9 +23,10 @@ namespace ICSharpCode.PackageManagement public ISharedPackageRepository CreateSharedRepository( IPackagePathResolver pathResolver, - IFileSystem fileSystem) + IFileSystem fileSystem, + IFileSystem configSettingsFileSystem) { - return new SharedPackageRepository(pathResolver, fileSystem); + return new SharedPackageRepository(pathResolver, fileSystem, configSettingsFileSystem); } public IRecentPackageRepository CreateRecentPackageRepository( diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/SharpDevelopProjectSystem.cs b/src/AddIns/Misc/PackageManagement/Project/Src/SharpDevelopProjectSystem.cs index b7e0047d20..e6a387c059 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/SharpDevelopProjectSystem.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/SharpDevelopProjectSystem.cs @@ -40,6 +40,8 @@ namespace ICSharpCode.PackageManagement return directory + @"\"; } + public bool IsBindingRedirectSupported { get; set; } + public FrameworkName TargetFramework { get { return GetTargetFramework(); } } diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/SolutionPackageRepository.cs b/src/AddIns/Misc/PackageManagement/Project/Src/SolutionPackageRepository.cs index 9773d016a2..482f3d7887 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/SolutionPackageRepository.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/SolutionPackageRepository.cs @@ -35,7 +35,7 @@ namespace ICSharpCode.PackageManagement repositoryPath = new SolutionPackageRepositoryPath(solution, options); CreatePackagePathResolver(); CreateFileSystem(); - CreateRepository(); + CreateRepository(ConfigSettingsFileSystem.CreateConfigSettingsFileSystem(solution)); } void CreatePackagePathResolver() @@ -48,9 +48,9 @@ namespace ICSharpCode.PackageManagement fileSystem = new PhysicalFileSystem(repositoryPath.PackageRepositoryPath); } - void CreateRepository() + void CreateRepository(ConfigSettingsFileSystem configSettingsFileSystem) { - repository = repositoryFactory.CreateSharedRepository(packagePathResolver, fileSystem); + repository = repositoryFactory.CreateSharedRepository(packagePathResolver, fileSystem, configSettingsFileSystem); } public ISharedPackageRepository Repository { diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/UpdatedPackages.cs b/src/AddIns/Misc/PackageManagement/Project/Src/UpdatedPackages.cs index 3f9c367266..c958019c84 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/UpdatedPackages.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/UpdatedPackages.cs @@ -53,7 +53,7 @@ namespace ICSharpCode.PackageManagement IEnumerable GetUpdatedPackages(IPackageRepository sourceRepository, IQueryable localPackages) { - return sourceRepository.GetUpdates(localPackages, false); + return sourceRepository.GetUpdates(localPackages, false, false); } } } diff --git a/src/AddIns/Misc/PackageManagement/RequiredLibraries/NuGet.Cmdlets.dll-Help.xml b/src/AddIns/Misc/PackageManagement/RequiredLibraries/NuGet.Cmdlets.dll-Help.xml index 9468c01b73..43b81a1a78 100644 --- a/src/AddIns/Misc/PackageManagement/RequiredLibraries/NuGet.Cmdlets.dll-Help.xml +++ b/src/AddIns/Misc/PackageManagement/RequiredLibraries/NuGet.Cmdlets.dll-Help.xml @@ -420,6 +420,10 @@ Returns a list of recently installed packages. RemoveDependencies + + ProjectName + string + Force @@ -457,6 +461,12 @@ Returns a list of recently installed packages. string + + Force + + Forces an uninstall of the package even if another package depends on it. + + Version @@ -707,124 +717,6 @@ available in the feed, the -Safe flag updates the package to 1.0.2. - - - - - - New-Package - - - Creates a package. - - New - Package - - - - - Creates a new package when supplied with a Nuspec package specification file. - - - - - - New-Package - - ProjectName - string - - - SpecFileName - string - - - TargetFile - string - - - NoClobber - - - - - - - - ProjectName - - Specifies the project containing the NuSpec file to use when creating the package. If omitted, the current project selected in the console is used. - - string - - - SpecFileName - - Specifies the NuSpec file used to create the package. If omitted, the NuSpec file within the current project is used if there is only one such file. - - string - - - TargetFile - - Specifes the full name of the output NuPkg file. - - string - - - NoClobber - - If specified, the target file is not overwritten. - - - - - - - ---------- EXAMPLE 1 ---------- - PM> New-Package - - -Description ------------------------------------------------------------------- -Creates a new package based on the current project using a Nuspec file within the project if only one such file is found. - - - - - - - - ---------- EXAMPLE 2 ---------- - PM> New-Package -Project MyProjectName -SpecFileName MyPackage.nuspec - - -Description ------------------------------------------------------------------- -Creates a new package from the specified project, MyProjectName using the specified Nuspec file, MyPackage.nuspec. - - - - - - - - - - - Online version: - http://docs.nuget.org/ - - - New-Package - - - - - (() => CompleteReadPackagesTask()); Assert.AreEqual("Test", ex.Message); } + + [Test] + public void ReadPackages_RepositoryHasPrereleaseAndReleasePackage_HasReleasePackageOnly() + { + CreateViewModel(); + + var releasePackage = new FakePackage("Test", "1.0.0.0"); + var prereleasePackage = new FakePackage("Test", "1.1.0-alpha"); + + var packages = new FakePackage[] { + releasePackage, prereleasePackage + }; + + registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange(packages); + + viewModel.ReadPackages(); + CompleteReadPackagesTask(); + + var expectedPackages = new FakePackage[] { + releasePackage + }; + + PackageCollectionAssert.AreEqual(expectedPackages, viewModel.PackageViewModels); + } } } diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakePackageRepositoryFactory.cs b/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakePackageRepositoryFactory.cs index f8b44f9a5e..150c963d83 100644 --- a/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakePackageRepositoryFactory.cs +++ b/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakePackageRepositoryFactory.cs @@ -37,12 +37,14 @@ namespace PackageManagement.Tests.Helpers public IPackagePathResolver PathResolverPassedToCreateSharedRepository; public IFileSystem FileSystemPassedToCreateSharedRepository; + public IFileSystem ConfigSettingsFileSystemPassedToCreateSharedRepository; public FakeSharedPackageRepository FakeSharedRepository = new FakeSharedPackageRepository(); - public ISharedPackageRepository CreateSharedRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem) + public ISharedPackageRepository CreateSharedRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, IFileSystem configSettingsFileSystem) { PathResolverPassedToCreateSharedRepository = pathResolver; FileSystemPassedToCreateSharedRepository = fileSystem; + ConfigSettingsFileSystemPassedToCreateSharedRepository = configSettingsFileSystem; return FakeSharedRepository; } diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/PackageRepositoryCacheTests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/PackageRepositoryCacheTests.cs index 0614083b6a..f9044d8a61 100644 --- a/src/AddIns/Misc/PackageManagement/Test/Src/PackageRepositoryCacheTests.cs +++ b/src/AddIns/Misc/PackageManagement/Test/Src/PackageRepositoryCacheTests.cs @@ -112,7 +112,7 @@ namespace PackageManagement.Tests public void CreateSharedRepository_MethodCalled_ReturnsSharedPackageRepository() { CreateCache(); - ISharedPackageRepository repository = cache.CreateSharedRepository(null, null); + ISharedPackageRepository repository = cache.CreateSharedRepository(null, null, null); Assert.IsNotNull(repository); } @@ -121,7 +121,7 @@ namespace PackageManagement.Tests { CreateCache(); FakePackagePathResolver resolver = new FakePackagePathResolver(); - cache.CreateSharedRepository(resolver, null); + cache.CreateSharedRepository(resolver, null, null); Assert.AreEqual(resolver, fakePackageRepositoryFactory.PathResolverPassedToCreateSharedRepository); } @@ -131,11 +131,21 @@ namespace PackageManagement.Tests { CreateCache(); FakeFileSystem fileSystem = new FakeFileSystem(); - cache.CreateSharedRepository(null, fileSystem); + cache.CreateSharedRepository(null, fileSystem, null); Assert.AreEqual(fileSystem, fakePackageRepositoryFactory.FileSystemPassedToCreateSharedRepository); } + [Test] + public void CreatedSharedRepository_ConfigSettingsFileSystemPassed_FileSystemUsedToCreatedSharedRepository() + { + CreateCache(); + FakeFileSystem fileSystem = new FakeFileSystem(); + cache.CreateSharedRepository(null, null, fileSystem); + + Assert.AreEqual(fileSystem, fakePackageRepositoryFactory.ConfigSettingsFileSystemPassedToCreateSharedRepository); + } + [Test] public void CreateAggregatePackageRepository_TwoRegisteredPackageRepositories_ReturnsAggregateRepositoryFromFactory() { diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/Scripting/RunPackageScriptsActionTests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/Scripting/RunPackageScriptsActionTests.cs index b43a4da6e5..aa487146b3 100644 --- a/src/AddIns/Misc/PackageManagement/Test/Src/Scripting/RunPackageScriptsActionTests.cs +++ b/src/AddIns/Misc/PackageManagement/Test/Src/Scripting/RunPackageScriptsActionTests.cs @@ -46,8 +46,7 @@ namespace PackageManagement.Tests.Scripting PackageOperationEventArgs CreatePackageOperationEventArgs(FakePackage package, string installPath) { - string targetPath = @"d:\projects\myproject\packages\target"; - return new PackageOperationEventArgs(package, null, targetPath, installPath); + return new PackageOperationEventArgs(package, null, installPath); } [Test] diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/SolutionPackageRepositoryTests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/SolutionPackageRepositoryTests.cs index e2b95f89d4..9f36efa3af 100644 --- a/src/AddIns/Misc/PackageManagement/Test/Src/SolutionPackageRepositoryTests.cs +++ b/src/AddIns/Misc/PackageManagement/Test/Src/SolutionPackageRepositoryTests.cs @@ -120,13 +120,10 @@ namespace PackageManagement.Tests } [Test] - public void GetPackagesByDependencyOrder_OnePackageInSharedRepository_SharedRepositoryCreatedWithFileSystemForSolutionPackagesFolder() + public void Constructor_CreateInstance_SharedRepositoryCreatedWithFileSystemForSolutionPackagesFolder() { CreateSolution(@"d:\projects\myproject\myproject.sln"); CreateRepository(solution); - FakePackage package = AddPackageToSharedRepository("Test"); - - List actualPackages = repository.GetPackagesByDependencyOrder().ToList(); IFileSystem fileSystem = fakeRepositoryFactory.FileSystemPassedToCreateSharedRepository; string rootPath = fileSystem.Root; @@ -136,6 +133,20 @@ namespace PackageManagement.Tests Assert.AreEqual(expectedRootPath, rootPath); } + [Test] + public void Constructor_CreateInstance_SharedRepositoryCreatedWithConfigSettingsFileSystemForSolutionNuGetFolder() + { + CreateSolution(@"d:\projects\myproject\myproject.sln"); + CreateRepository(solution); + + IFileSystem fileSystem = fakeRepositoryFactory.ConfigSettingsFileSystemPassedToCreateSharedRepository; + string rootPath = fileSystem.Root; + + string expectedRootPath = @"d:\projects\myproject\.nuget"; + + Assert.AreEqual(expectedRootPath, rootPath); + } + [Test] public void GetPackagesByDependencyOrder_TwoPackagesInSharedRepositoryFirstPackageDependsOnSecond_ReturnsSecondPackageFirst() { diff --git a/src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchManager.cs b/src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchManager.cs index ae87027c0f..ed78bf6ebf 100644 --- a/src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchManager.cs +++ b/src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchManager.cs @@ -5,9 +5,9 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text; using System.Threading; using System.Threading.Tasks; - using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.AvalonEdit.Highlighting; @@ -32,21 +32,64 @@ namespace SearchAndReplace public static IObservable FindAllParallel(ISearchStrategy strategy, SearchLocation location, IProgressMonitor progressMonitor) { currentSearchRegion = null; - ParseableFileContentFinder fileFinder = new ParseableFileContentFinder(); + SearchableFileContentFinder fileFinder = new SearchableFileContentFinder(); return new SearchRun(strategy, fileFinder, location.GenerateFileList(), progressMonitor) { Target = location.Target, Selection = location.Selection }; } public static IEnumerable FindAll(ISearchStrategy strategy, SearchLocation location, IProgressMonitor progressMonitor) { currentSearchRegion = null; - ParseableFileContentFinder fileFinder = new ParseableFileContentFinder(); + SearchableFileContentFinder fileFinder = new SearchableFileContentFinder(); return new SearchRun(strategy, fileFinder, location.GenerateFileList(), progressMonitor) { Target = location.Target, Selection = location.Selection }.GetResults(); } + class SearchableFileContentFinder + { + FileName[] viewContentFileNamesCollection = WorkbenchSingleton.SafeThreadFunction(() => SD.FileService.OpenedFiles.Select(f => f.FileName).ToArray()); + + static ITextSource ReadFile(FileName fileName) + { + OpenedFile openedFile = SD.FileService.GetOpenedFile(fileName); + if (openedFile == null) + return null; + IFileDocumentProvider provider = FileService.GetOpenFile(fileName) as IFileDocumentProvider; + if (provider == null) + return null; + IDocument doc = provider.GetDocumentForFile(openedFile); + if (doc == null) + return null; + return doc.CreateSnapshot(); + } + + public ITextSource Create(FileName fileName) + { + try { + foreach (FileName name in viewContentFileNamesCollection) { + if (FileUtility.IsEqualFileName(name, fileName)) { + ITextSource buffer = WorkbenchSingleton.SafeThreadFunction(ReadFile, fileName); + if (buffer != null) + return buffer; + } + } + using (Stream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { + if (MimeTypeDetection.FindMimeType(stream).StartsWith("text/")) { + stream.Position = 0; + return new StringTextSource(ICSharpCode.AvalonEdit.Utils.FileReader.ReadFileContent(stream, Encoding.Default)); + } + } + return null; + } catch (IOException) { + return null; + } catch (UnauthorizedAccessException) { + return null; + } + } + } + class SearchRun : IObservable, IDisposable { ISearchStrategy strategy; - ParseableFileContentFinder fileFinder; + SearchableFileContentFinder fileFinder; IEnumerable fileList; IProgressMonitor monitor; CancellationTokenSource cts; @@ -55,7 +98,7 @@ namespace SearchAndReplace public ISegment Selection { get; set; } - public SearchRun(ISearchStrategy strategy, ParseableFileContentFinder fileFinder, IEnumerable fileList, IProgressMonitor monitor) + public SearchRun(ISearchStrategy strategy, SearchableFileContentFinder fileFinder, IEnumerable fileList, IProgressMonitor monitor) { this.strategy = strategy; this.fileFinder = fileFinder; @@ -151,8 +194,6 @@ namespace SearchAndReplace ThrowIfCancellationRequested(); - if (!MimeTypeDetection.FindMimeType(source).StartsWith("text/", StringComparison.Ordinal)) - return null; TextDocument document = null; DocumentHighlighter highlighter = null; @@ -213,7 +254,7 @@ namespace SearchAndReplace public SearchResultMatch FindNext() { // Setup search inside current or first file. - ParseableFileContentFinder finder = new ParseableFileContentFinder(); + SearchableFileContentFinder finder = new SearchableFileContentFinder(); int index = GetCurrentFileIndex(); int i = 0; int searchOffset = 0; diff --git a/src/AddIns/Misc/UsageDataCollector/UsageDataCollector.AddIn/AnalyticsMonitor.cs b/src/AddIns/Misc/UsageDataCollector/UsageDataCollector.AddIn/AnalyticsMonitor.cs index facedde123..ea446bcd3c 100644 --- a/src/AddIns/Misc/UsageDataCollector/UsageDataCollector.AddIn/AnalyticsMonitor.cs +++ b/src/AddIns/Misc/UsageDataCollector/UsageDataCollector.AddIn/AnalyticsMonitor.cs @@ -49,6 +49,8 @@ namespace ICSharpCode.UsageDataCollector static void AsyncEnableDisable() { + if (System.Diagnostics.Debugger.IsAttached) + return; if (Enabled) { Instance.OpenSession(); } else { @@ -253,6 +255,8 @@ namespace ICSharpCode.UsageDataCollector { public override void Run() { + if (System.Diagnostics.Debugger.IsAttached) + return; if (AnalyticsMonitor.Enabled) AnalyticsMonitor.Instance.OpenSession(); } diff --git a/src/Libraries/AvalonDock/AvalonDock/DockingManager.cs b/src/Libraries/AvalonDock/AvalonDock/DockingManager.cs index 45a393e3fa..b65cdc147d 100644 --- a/src/Libraries/AvalonDock/AvalonDock/DockingManager.cs +++ b/src/Libraries/AvalonDock/AvalonDock/DockingManager.cs @@ -2636,6 +2636,15 @@ namespace AvalonDock //_flyoutWindow.KeepWindowOpen(); return; } + + // David: This sometimes seems to be null when hovering over auto-hide pad. + // It only seems to occur in specific circumstances - whether the pad is the + // "selected" one in the set seems important. Having no open document might have effect? + // I have only managed to reliablely reproduce it in stand-alone application. + if (content.ContainerPane == null) + { + return; + } //hide previous window HideFlyoutWindow(); diff --git a/src/Libraries/AvalonDock/AvalonDock/DocumentTabPanel.cs b/src/Libraries/AvalonDock/AvalonDock/DocumentTabPanel.cs index b4ed1cf282..86c963cc92 100644 --- a/src/Libraries/AvalonDock/AvalonDock/DocumentTabPanel.cs +++ b/src/Libraries/AvalonDock/AvalonDock/DocumentTabPanel.cs @@ -65,6 +65,10 @@ namespace AvalonDock foreach (ManagedContent child in Children) { + // David: Sometimes happened when closing document tab by middle clicking. Really difficult to reproduce. + if (child == null) + continue; + Panel.SetZIndex(child, Selector.GetIsSelected(child) ? 1 : -i); i++; child.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); @@ -81,6 +85,10 @@ namespace AvalonDock bool skipAllOthers = false; foreach (ManagedContent doc in Children) { + // David: Sometimes happened when closing document tab by middle clicking. Really difficult to reproduce. + if (doc == null) + continue; + if (skipAllOthers || offset + doc.DesiredSize.Width > finalSize.Width) { SetIsHeaderVisible(doc, false); diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/ICSharpCode.AvalonEdit.Tests.csproj b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/ICSharpCode.AvalonEdit.Tests.csproj index 61a27f0c36..3e9a5c7875 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/ICSharpCode.AvalonEdit.Tests.csproj +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/ICSharpCode.AvalonEdit.Tests.csproj @@ -86,6 +86,7 @@ + @@ -104,4 +105,7 @@ ICSharpCode.AvalonEdit + + + \ No newline at end of file diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Search/FindTests.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Search/FindTests.cs new file mode 100644 index 0000000000..63de9fed35 --- /dev/null +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Search/FindTests.cs @@ -0,0 +1,115 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Linq; +using ICSharpCode.AvalonEdit.Document; +using ICSharpCode.NRefactory.Editor; +using NUnit.Framework; + +namespace ICSharpCode.AvalonEdit.Search +{ + [TestFixture] + public class FindTests + { + [Test] + public void SkipWordBorderSimple() + { + var strategy = SearchStrategyFactory.Create("All", false, true, SearchMode.Normal); + var text = new StringTextSource(" FindAllTests "); + var results = strategy.FindAll(text, 0, text.TextLength).ToArray(); + + Assert.IsEmpty(results, "No results should be found!"); + } + + [Test] + public void SkipWordBorder() + { + var strategy = SearchStrategyFactory.Create("AllTests", false, true, SearchMode.Normal); + var text = new StringTextSource("name=\"{FindAllTests}\""); + var results = strategy.FindAll(text, 0, text.TextLength).ToArray(); + + Assert.IsEmpty(results, "No results should be found!"); + } + + [Test] + public void SkipWordBorder2() + { + var strategy = SearchStrategyFactory.Create("AllTests", false, true, SearchMode.Normal); + var text = new StringTextSource("name=\"FindAllTests "); + var results = strategy.FindAll(text, 0, text.TextLength).ToArray(); + + Assert.IsEmpty(results, "No results should be found!"); + } + + [Test] + public void SkipWordBorder3() + { + var strategy = SearchStrategyFactory.Create("// find", false, true, SearchMode.Normal); + var text = new StringTextSource(" // findtest"); + var results = strategy.FindAll(text, 0, text.TextLength).ToArray(); + + Assert.IsEmpty(results, "No results should be found!"); + } + + [Test] + public void WordBorderTest() + { + var strategy = SearchStrategyFactory.Create("// find", false, true, SearchMode.Normal); + var text = new StringTextSource(" // find me"); + var results = strategy.FindAll(text, 0, text.TextLength).ToArray(); + + Assert.AreEqual(1, results.Length, "One result should be found!"); + Assert.AreEqual(" ".Length, results[0].Offset); + Assert.AreEqual("// find".Length, results[0].Length); + } + + [Test] + public void ResultAtStart() + { + var strategy = SearchStrategyFactory.Create("result", false, true, SearchMode.Normal); + var text = new StringTextSource("result // find me"); + var results = strategy.FindAll(text, 0, text.TextLength).ToArray(); + + Assert.AreEqual(1, results.Length, "One result should be found!"); + Assert.AreEqual(0, results[0].Offset); + Assert.AreEqual("result".Length, results[0].Length); + } + + [Test] + public void ResultAtEnd() + { + var strategy = SearchStrategyFactory.Create("me", false, true, SearchMode.Normal); + var text = new StringTextSource("result // find me"); + var results = strategy.FindAll(text, 0, text.TextLength).ToArray(); + + Assert.AreEqual(1, results.Length, "One result should be found!"); + Assert.AreEqual("result // find ".Length, results[0].Offset); + Assert.AreEqual("me".Length, results[0].Length); + } + + [Test] + public void TextWithDots() + { + var strategy = SearchStrategyFactory.Create("Text", false, true, SearchMode.Normal); + var text = new StringTextSource(".Text."); + var results = strategy.FindAll(text, 0, text.TextLength).ToArray(); + + Assert.AreEqual(1, results.Length, "One result should be found!"); + Assert.AreEqual(".".Length, results[0].Offset); + Assert.AreEqual("Text".Length, results[0].Length); + } + + [Test] + public void SimpleTest() + { + var strategy = SearchStrategyFactory.Create("AllTests", false, false, SearchMode.Normal); + var text = new StringTextSource("name=\"FindAllTests "); + var results = strategy.FindAll(text, 0, text.TextLength).ToArray(); + + Assert.AreEqual(1, results.Length, "One result should be found!"); + Assert.AreEqual("name=\"Find".Length, results[0].Offset); + Assert.AreEqual("AllTests".Length, results[0].Length); + } + } +} diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/TextArea.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/TextArea.cs index 7ee52f2a4c..1f8575b76a 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/TextArea.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/TextArea.cs @@ -805,11 +805,13 @@ namespace ICSharpCode.AvalonEdit.Editing //Debug.WriteLine("TextInput: Text='" + e.Text + "' SystemText='" + e.SystemText + "' ControlText='" + e.ControlText + "'"); base.OnTextInput(e); if (!e.Handled && this.Document != null) { - if (string.IsNullOrEmpty(e.Text) || e.Text == "\x1b") { + if (string.IsNullOrEmpty(e.Text) || e.Text == "\x1b" || e.Text == "\b") { // ASCII 0x1b = ESC. // WPF produces a TextInput event with that old ASCII control char // when Escape is pressed. We'll just ignore it. + // A deadkey followed by backspace causes a textinput event for the BS character. + // Similarly, some shortcuts like Alt+Space produce an empty TextInput event. // We have to ignore those (not handle them) to keep the shortcut working. return; @@ -845,7 +847,7 @@ namespace ICSharpCode.AvalonEdit.Editing throw ThrowUtil.NoDocumentAssigned(); OnTextEntering(e); if (!e.Handled) { - if (e.Text == "\n" || e.Text == "\r\n") + if (e.Text == "\n" || e.Text == "\r" || e.Text == "\r\n") ReplaceSelectionWithNewLine(); else ReplaceSelectionWithText(e.Text); diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/RegexSearchStrategy.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/RegexSearchStrategy.cs index 0df65a8ae5..6b49a1cb0c 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/RegexSearchStrategy.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/RegexSearchStrategy.cs @@ -33,7 +33,7 @@ namespace ICSharpCode.AvalonEdit.Search int resultEndOffset = result.Length + result.Index; if (offset > result.Index || endOffset < resultEndOffset) continue; - if (matchWholeWords && (!IsWordBorder(document, offset) || !IsWordBorder(document, resultEndOffset))) + if (matchWholeWords && (!IsWordBorder(document, result.Index) || !IsWordBorder(document, resultEndOffset))) continue; yield return new SearchResult { StartOffset = result.Index, Length = result.Length, Data = result }; } diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/SearchPanel.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/SearchPanel.cs index cb4c9970e4..586c8c9b18 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/SearchPanel.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/SearchPanel.cs @@ -198,8 +198,10 @@ namespace ICSharpCode.AvalonEdit.Search if (currentDocument != null) currentDocument.TextChanged -= textArea_Document_TextChanged; currentDocument = textArea.Document; - if (currentDocument != null) + if (currentDocument != null) { currentDocument.TextChanged += textArea_Document_TextChanged; + DoSearch(false); + } } void textArea_Document_TextChanged(object sender, EventArgs e) diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory.VB/Lexer/PushParser.frame b/src/Libraries/NRefactory/ICSharpCode.NRefactory.VB/Lexer/PushParser.frame index 2e7fcca080..1bf369d5ea 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory.VB/Lexer/PushParser.frame +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory.VB/Lexer/PushParser.frame @@ -42,6 +42,7 @@ partial class ExpressionFinder { bool isMissingModifier = false; bool isAlreadyInExpr = false; bool wasNormalAttribute = false; + int lambdaNestingDepth = 0; int activeArgument = 0; List errors = new List(); diff --git a/src/Libraries/SharpTreeView/ICSharpCode.TreeView/DropEffect.cs b/src/Libraries/SharpTreeView/ICSharpCode.TreeView/DropEffect.cs deleted file mode 100644 index 24a16504fe..0000000000 --- a/src/Libraries/SharpTreeView/ICSharpCode.TreeView/DropEffect.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace ICSharpCode.TreeView -{ - public enum DropEffect - { - None, Move, Copy, Link - } -} diff --git a/src/Libraries/SharpTreeView/ICSharpCode.TreeView/FlatListTreeNode.cs b/src/Libraries/SharpTreeView/ICSharpCode.TreeView/FlatListTreeNode.cs index cf30a85e35..4f5a4d5448 100644 --- a/src/Libraries/SharpTreeView/ICSharpCode.TreeView/FlatListTreeNode.cs +++ b/src/Libraries/SharpTreeView/ICSharpCode.TreeView/FlatListTreeNode.cs @@ -364,6 +364,8 @@ namespace ICSharpCode.TreeView Debug.Assert(node.listParent == null); Debug.Assert(node.left == null); Debug.Assert(node.right == null); + node.height = 1; + node.totalListLength = -1; if (balancingNode != null) RebalanceUntilRoot(balancingNode); } diff --git a/src/Libraries/SharpTreeView/ICSharpCode.TreeView/ICSharpCode.TreeView.csproj b/src/Libraries/SharpTreeView/ICSharpCode.TreeView/ICSharpCode.TreeView.csproj index 7709e9c517..a21ed199a5 100644 --- a/src/Libraries/SharpTreeView/ICSharpCode.TreeView/ICSharpCode.TreeView.csproj +++ b/src/Libraries/SharpTreeView/ICSharpCode.TreeView/ICSharpCode.TreeView.csproj @@ -6,7 +6,7 @@ 9.0.30729 2.0 {DDE2A481-8271-4EAC-A330-8FA6A38D13D1} - library + Library Properties ICSharpCode.TreeView ICSharpCode.TreeView @@ -14,15 +14,16 @@ 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4 + Client ..\..\..\..\bin\ - - + False + False + false true - full + Full false - ..\..\..\..\bin\ DEBUG;TRACE prompt 4 @@ -30,11 +31,19 @@ pdbonly true - ..\..\..\..\bin\ TRACE prompt 4 + + False + + + False + Auto + 4194304 + AnyCPU + @@ -64,16 +73,15 @@ Properties\GlobalAssemblyInfo.cs - - Code + diff --git a/src/Libraries/SharpTreeView/ICSharpCode.TreeView/SharpTreeNode.cs b/src/Libraries/SharpTreeView/ICSharpCode.TreeView/SharpTreeNode.cs index ae0a0e6468..65561ea930 100644 --- a/src/Libraries/SharpTreeView/ICSharpCode.TreeView/SharpTreeNode.cs +++ b/src/Libraries/SharpTreeView/ICSharpCode.TreeView/SharpTreeNode.cs @@ -12,6 +12,7 @@ using System.Collections.ObjectModel; using System.Windows.Controls; using System.Collections.Specialized; using System.Windows.Input; +using System.Windows.Media; namespace ICSharpCode.TreeView { @@ -101,6 +102,10 @@ namespace ICSharpCode.TreeView get { return null; } } + public virtual Brush Foreground { + get { return SystemColors.WindowTextBrush; } + } + public virtual object Icon { get { return null; } diff --git a/src/Libraries/SharpTreeView/ICSharpCode.TreeView/SharpTreeView.cs b/src/Libraries/SharpTreeView/ICSharpCode.TreeView/SharpTreeView.cs index 7d44e0744b..3addc9e03b 100644 --- a/src/Libraries/SharpTreeView/ICSharpCode.TreeView/SharpTreeView.cs +++ b/src/Libraries/SharpTreeView/ICSharpCode.TreeView/SharpTreeView.cs @@ -135,11 +135,11 @@ namespace ICSharpCode.TreeView this.ItemsSource = flattener; } } - + void flattener_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { - // Deselect nodes that are being hidden - if (e.Action == NotifyCollectionChangedAction.Remove) { + // Deselect nodes that are being hidden, if any remain in the tree + if (e.Action == NotifyCollectionChangedAction.Remove && Items.Count > 0) { List selectedOldItems = null; foreach (SharpTreeNode node in e.OldItems) { if (node.IsSelected) { @@ -151,11 +151,13 @@ namespace ICSharpCode.TreeView if (selectedOldItems != null) { var list = SelectedItems.Cast().Except(selectedOldItems).ToList(); SetSelectedItems(list); + if (SelectedItem == null) { + // if we removed all selected nodes, then move the focus to the node + // preceding the first of the old selected nodes + SelectedIndex = Math.Max(0, e.OldStartingIndex - 1); + FocusNode((SharpTreeNode)SelectedItem); + } } - // reset the focus to the previous node - SelectedIndex = Math.Max(0, e.OldStartingIndex - 1); - if (SelectedItem != null) - FocusNode((SharpTreeNode)SelectedItem); } } @@ -174,6 +176,10 @@ namespace ICSharpCode.TreeView base.PrepareContainerForItemOverride(element, item); SharpTreeViewItem container = element as SharpTreeViewItem; container.ParentTreeView = this; + // Make sure that the line renderer takes into account the new bound data + if (container.NodeView != null) { + container.NodeView.LinesRenderer.InvalidateVisual(); + } } bool doNotScrollOnExpanding; diff --git a/src/Libraries/SharpTreeView/ICSharpCode.TreeView/Themes/Generic.xaml b/src/Libraries/SharpTreeView/ICSharpCode.TreeView/Themes/Generic.xaml index a10e19c75c..00b807af01 100644 --- a/src/Libraries/SharpTreeView/ICSharpCode.TreeView/Themes/Generic.xaml +++ b/src/Libraries/SharpTreeView/ICSharpCode.TreeView/Themes/Generic.xaml @@ -181,6 +181,7 @@ @@ -210,7 +211,8 @@ --> - diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin b/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin index 6b6b6f02ac..4e757c0446 100755 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin @@ -252,6 +252,13 @@ + + + @@ -291,7 +298,9 @@ - + @@ -368,13 +377,19 @@ - + + @@ -417,6 +432,9 @@ + - + @@ -1175,6 +1195,9 @@ + @@ -1228,6 +1251,9 @@ + diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj index 63db9a9579..202d65d0d0 100644 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj @@ -242,28 +242,36 @@ - - - - + + + + + + ServiceReferenceOptionsPanel..xaml + Code + - + + + + + ToolNotFoundDialog.cs @@ -308,6 +316,7 @@ + @@ -799,6 +808,7 @@ + {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1} diff --git a/src/Main/Base/Project/Src/Commands/FileTabStripCommands.cs b/src/Main/Base/Project/Src/Commands/FileTabStripCommands.cs index 550a392dee..8085a6e362 100644 --- a/src/Main/Base/Project/Src/Commands/FileTabStripCommands.cs +++ b/src/Main/Base/Project/Src/Commands/FileTabStripCommands.cs @@ -117,4 +117,17 @@ namespace ICSharpCode.SharpDevelop.Commands.TabStrip window.ActiveViewContent.PrimaryFileName); } } + + /// + /// Opens a command prompt at the file's location. + /// + public class OpenCommandPromptHere : AbstractMenuCommand + { + public override void Run() + { + IWorkbenchWindow window = Owner as IWorkbenchWindow; + ICSharpCode.SharpDevelop.Project.Commands.OpenCommandPromptHere.OpenCommandPrompt( + window.ActiveViewContent.PrimaryFileName); + } + } } diff --git a/src/Main/Base/Project/Src/Editor/CodeCompletion/ICompletionItemList.cs b/src/Main/Base/Project/Src/Editor/CodeCompletion/ICompletionItemList.cs index 9481b68273..a5736d4e92 100644 --- a/src/Main/Base/Project/Src/Editor/CodeCompletion/ICompletionItemList.cs +++ b/src/Main/Base/Project/Src/Editor/CodeCompletion/ICompletionItemList.cs @@ -64,7 +64,11 @@ namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion /// key. Can be used to insert whitespace (or other characters) in front of the expression /// while the completion window is open. /// - BeforeStartKey + BeforeStartKey, + /// + /// This key triggers cancellation of completion. The completion window will be closed. + /// + Cancel } public class DefaultCompletionItemList : ICompletionItemList diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/AddServiceReferenceDialog.xaml b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/AddServiceReferenceDialog.xaml index fbb2a7c10c..eefd2344ef 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/AddServiceReferenceDialog.xaml +++ b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/AddServiceReferenceDialog.xaml @@ -53,8 +53,8 @@ - + - - - - - (); - AssembliesToReference.Add(new CheckableImageAndDescription(image, "Microsoft.CSharp")); - AssembliesToReference.Add(new CheckableImageAndDescription(image, "mscorlib")); - AssembliesToReference.Add(new CheckableImageAndDescription(image, "System.Core")); - AssembliesToReference.Add(new CheckableImageAndDescription(image, "System.Data")); - AssembliesToReference.Add(new CheckableImageAndDescription(image, "System.Data.DataSetExtensions")); - AssembliesToReference.Add(new CheckableImageAndDescription(image, "System.Runtime.Serialization")); - AssembliesToReference.Add(new CheckableImageAndDescription(image, "System.ServiceModel")); - AssembliesToReference.Add(new CheckableImageAndDescription(image, "System.Xml")); - AssembliesToReference.Add(new CheckableImageAndDescription(image, "System.Xml.Linq")); + this.options = options; + UpdateSettingsFromOptions(); + Title = "Service Reference Settings"; + AssembliesToReference = new ObservableCollection(); + } + + public ServiceReferenceGeneratorOptions Options { + get { return options; } + } + + void UpdateSettingsFromOptions() + { + UpdateSelectedModifier(); + UpdateReferencedTypes(); + } + + void UpdateReferencedTypes() + { + if (options.UseTypesInProjectReferences) { + this.ReuseTypes = true; + this.UseReferencedAssemblies = true; + } else if (options.UseTypesInSpecifiedAssemblies) { + this.ReuseReferencedTypes = true; + this.UseReferencedAssemblies = true; + } else { + this.ReuseReferencedTypes = false; + this.ReuseTypes = false; + this.UseReferencedAssemblies = false; + } + } + + void UpdateSelectedModifier() + { + if (options.GenerateInternalClasses) { + SelectedModifier = Modifiers.Internal; + } else { + SelectedModifier = Modifiers.Public; + } } public string Title { get; set; } @@ -85,46 +118,44 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference get { return selectedModifier; } set { selectedModifier = value; + UpdateClassGenerationModifier(); OnPropertyChanged(); } } - bool generateAsyncOperations; + void UpdateClassGenerationModifier() + { + options.GenerateInternalClasses = (selectedModifier == Modifiers.Internal); + } public bool GenerateAsyncOperations { - get { return generateAsyncOperations; } + get { return options.GenerateAsyncOperations; } set { - generateAsyncOperations = value; + options.GenerateAsyncOperations = value; OnPropertyChanged(); } } - bool generateMessageContract; - public bool GenerateMessageContract { - get { return generateMessageContract; } + get { return options.GenerateMessageContract; } set { - generateMessageContract = value; + options.GenerateMessageContract = value; OnPropertyChanged(); } } - CollectionTypes collectionType; - public CollectionTypes CollectionType { - get { return collectionType; } + get { return options.ArrayCollectionType; } set { - collectionType = value; + options.ArrayCollectionType = value; OnPropertyChanged(); } } - DictionaryCollectionTypes dictionaryCollectionType; - public DictionaryCollectionTypes DictionaryCollectionType { - get { return dictionaryCollectionType; } + get { return options.DictionaryCollectionType; } set { - dictionaryCollectionType = value; + options.DictionaryCollectionType = value; OnPropertyChanged(); } } @@ -136,26 +167,24 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference set { useReferencedAssemblies = value; ReuseTypes = useReferencedAssemblies; + if (!useReferencedAssemblies) + ReuseReferencedTypes = false; OnPropertyChanged(); } } - bool reuseTypes; - public bool ReuseTypes { - get { return reuseTypes; } + get { return options.UseTypesInProjectReferences; } set { - reuseTypes = value; + options.UseTypesInProjectReferences = value; OnPropertyChanged(); } } - bool reuseReferencedTypes; - public bool ReuseReferencedTypes { - get { return reuseReferencedTypes; } + get { return options.UseTypesInSpecifiedAssemblies; } set { - reuseReferencedTypes = value; + options.UseTypesInSpecifiedAssemblies = value; ListViewEnable = value; OnPropertyChanged(); } @@ -171,11 +200,6 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference } } - public ObservableCollection AssembliesToReference { get; private set; } - - public string CompatibilityText - { - get { return compatibilityText + c_2; } - } + public ObservableCollection AssembliesToReference { get; private set; } } } diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ICodeDomProvider.cs b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ICodeDomProvider.cs deleted file mode 100644 index 4400ed3f46..0000000000 --- a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ICodeDomProvider.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -using System; -using System.CodeDom; - -namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference -{ - public interface ICodeDomProvider - { - string FileExtension { get; } - - void GenerateCodeFromCompileUnit(CodeCompileUnit compileUnit, string fileName); - } -} diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/IProjectWithServiceReferences.cs b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/IProjectWithServiceReferences.cs index 26f041abb6..adfdaff955 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/IProjectWithServiceReferences.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/IProjectWithServiceReferences.cs @@ -2,13 +2,16 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; +using System.Collections.Generic; +using ICSharpCode.SharpDevelop.Project; namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference { public interface IProjectWithServiceReferences { string ServiceReferencesFolder { get; } - ICodeDomProvider CodeDomProvider { get; } + string Language { get; } + string RootNamespace { get; } ServiceReferenceFileName GetServiceReferenceFileName(string serviceReferenceName); ServiceReferenceMapFileName GetServiceReferenceMapFileName(string serviceReferenceName); @@ -16,5 +19,9 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference void AddServiceReferenceMapFile(ServiceReferenceMapFileName fileName); void Save(); void AddAssemblyReference(string referenceName); + bool HasAppConfigFile(); + string GetAppConfigFileName(); + void AddAppConfigFile(); + IEnumerable GetReferences(); } } diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/IServiceReferenceCodeDomBuilder.cs b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/IServiceReferenceCodeDomBuilder.cs deleted file mode 100644 index 11d853cc4c..0000000000 --- a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/IServiceReferenceCodeDomBuilder.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -using System; -using System.CodeDom; -using System.ServiceModel.Description; - -namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference -{ - public interface IServiceReferenceCodeDomBuilder - { - string Namespace { get; set; } - CodeCompileUnit GenerateCompileUnit(MetadataSet metadata); - } -} diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/IServiceReferenceProxyGenerator.cs b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/IServiceReferenceProxyGenerator.cs index 9b117b442e..e5eab2f37b 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/IServiceReferenceProxyGenerator.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/IServiceReferenceProxyGenerator.cs @@ -8,8 +8,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference { public interface IServiceReferenceProxyGenerator { - string ServiceReferenceNamespace { get; set; } - - void GenerateProxyFile(MetadataSet metadata, string proxyFileName); + ServiceReferenceGeneratorOptions Options { get; set; } + void GenerateProxyFile(); } } diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ProjectWithServiceReferences.cs b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ProjectWithServiceReferences.cs index 16a155f91f..78dec9ce42 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ProjectWithServiceReferences.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ProjectWithServiceReferences.cs @@ -3,6 +3,7 @@ using System; using System.CodeDom.Compiler; +using System.Collections.Generic; using System.IO; using System.Linq; @@ -18,14 +19,8 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference public static readonly string DefaultServiceReferencesFolderName = "Service References"; public ProjectWithServiceReferences(IProject project) - : this(project, new ServiceReferenceCodeDomProvider(project)) - { - } - - public ProjectWithServiceReferences(IProject project, ICodeDomProvider codeDomProvider) { this.project = project; - this.CodeDomProvider = codeDomProvider; } public string ServiceReferencesFolder { @@ -42,7 +37,18 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference serviceReferencesFolder = Path.Combine(project.Directory, DefaultServiceReferencesFolderName); } - public ICodeDomProvider CodeDomProvider { get; private set; } + public string Language { + get { return project.Language; } + } + + public string RootNamespace { + get { + if (project.RootNamespace != null) { + return project.RootNamespace; + } + return String.Empty; + } + } public ServiceReferenceFileName GetServiceReferenceFileName(string serviceReferenceName) { @@ -123,5 +129,49 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference { return String.Equals(a, b, StringComparison.OrdinalIgnoreCase); } + + public bool HasAppConfigFile() + { + return GetAppConfigFile() != null; + } + + ProjectItem GetAppConfigFile() + { + return project.Items.SingleOrDefault(item => IsAppConfigFile(item)); + } + + bool IsAppConfigFile(ProjectItem item) + { + string fileNameWithoutPath = Path.GetFileName(item.FileName); + return String.Equals(fileNameWithoutPath, "app.config", StringComparison.OrdinalIgnoreCase); + } + + public string GetAppConfigFileName() + { + ProjectItem item = GetAppConfigFile(); + if (item != null) { + return item.FileName; + } + return GetDefaultAppConfigFileName(); + } + + public void AddAppConfigFile() + { + var item = new FileProjectItem(project, ItemType.None); + item.FileName = GetDefaultAppConfigFileName(); + AddProjectItemToProject(item); + } + + string GetDefaultAppConfigFileName() + { + return Path.Combine(project.Directory, "app.config"); + } + + public IEnumerable GetReferences() + { + foreach (ReferenceProjectItem item in project.GetItemsOfType(ItemType.Reference)) { + yield return item; + } + } } } diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceCodeDomBuilder.cs b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceCodeDomBuilder.cs deleted file mode 100644 index c7b2bf89af..0000000000 --- a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceCodeDomBuilder.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -using System; -using System.CodeDom; -using System.Runtime.Serialization; -using System.ServiceModel.Channels; -using System.ServiceModel.Description; - -namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference -{ - public class ServiceReferenceCodeDomBuilder : IServiceReferenceCodeDomBuilder - { - public ServiceReferenceCodeDomBuilder() - { - this.Namespace = String.Empty; - } - - public string Namespace { get; set; } - - public CodeCompileUnit GenerateCompileUnit(MetadataSet metadata) - { - ServiceContractGenerator contractGenerator = CreateServiceContractGenerator(); - WsdlImporter importer = CreateWsdlImporter(metadata); - - foreach (ContractDescription contract in importer.ImportAllContracts()) { - contractGenerator.GenerateServiceContractType(contract); - } - - return contractGenerator.TargetCompileUnit; - } - - WsdlImporter CreateWsdlImporter(MetadataSet metadata) - { - var importer = new WsdlImporter(metadata); - var contractImporter = new XsdDataContractImporter(); - contractImporter.Options = new ImportOptions(); - contractImporter.Options.Namespaces.Add("*", Namespace); - importer.State.Add(typeof(XsdDataContractImporter), contractImporter); - return importer; - } - - ServiceContractGenerator CreateServiceContractGenerator() - { - var contractGenerator = new ServiceContractGenerator(); - contractGenerator.Options = - ServiceContractGenerationOptions.ClientClass | - ServiceContractGenerationOptions.ChannelInterface; - contractGenerator.NamespaceMappings.Add("*", Namespace); - return contractGenerator; - } - } -} diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceCodeDomProvider.cs b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceCodeDomProvider.cs deleted file mode 100644 index 4028db80c7..0000000000 --- a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceCodeDomProvider.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -using System; -using System.CodeDom; -using System.CodeDom.Compiler; -using System.IO; -using ICSharpCode.SharpDevelop.Project; - -namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference -{ - public class ServiceReferenceCodeDomProvider : ICodeDomProvider - { - IProject project; - CodeDomProvider codeDomProvider; - - public ServiceReferenceCodeDomProvider(IProject project) - { - this.project = project; - } - - public string FileExtension { - get { return CodeDomProvider.FileExtension; } - } - - CodeDomProvider CodeDomProvider { - get { - if (codeDomProvider == null) { - codeDomProvider = project.CreateCodeDomProvider(); - } - return codeDomProvider; - } - } - - public void GenerateCodeFromCompileUnit(CodeCompileUnit compileUnit, string fileName) - { - using (var writer = new StreamWriter(fileName)) { - CodeDomProvider.GenerateCodeFromCompileUnit(compileUnit, writer, null); - } - } - } -} diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceDiscoveryClient.cs b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceDiscoveryClient.cs new file mode 100644 index 0000000000..3c80442058 --- /dev/null +++ b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceDiscoveryClient.cs @@ -0,0 +1,115 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Net; +using System.ServiceModel.Description; +using System.Web.Services.Discovery; + +namespace ICSharpCode.SharpDevelop.Gui +{ + public class ServiceReferenceDiscoveryClient + { + const int DiscoveryClientsUsed = 3; + + Uri discoveryUrl; + BackgroundWorker webServiceDiscoveryBackgroundWorker = new BackgroundWorker(); + BackgroundWorker mexDiscoveryBackgroundWorker = new BackgroundWorker(); + BackgroundWorker mexRelativePathDiscoveryBackgroundWorker = new BackgroundWorker(); + List errors = new List(); + + public event EventHandler DiscoveryComplete; + + protected virtual void OnDiscoveryComplete(ServiceReferenceDiscoveryEventArgs e) + { + if (DiscoveryComplete != null) { + DiscoveryComplete(this, e); + } + } + + public void Discover(Uri url) + { + this.discoveryUrl = url; + DiscoverWebService(); + DiscoverMexMetadata(); + } + + void DiscoverWebService() + { + webServiceDiscoveryBackgroundWorker.DoWork += DiscoverWebServiceMetadata; + webServiceDiscoveryBackgroundWorker.RunWorkerCompleted += DiscoveryCompleted; + webServiceDiscoveryBackgroundWorker.RunWorkerAsync(discoveryUrl); + } + + void DiscoverWebServiceMetadata(object sender, DoWorkEventArgs e) + { + Uri url = (Uri)e.Argument; + var client = new DiscoveryClientProtocol(); + client.Credentials = GetCredentials(); + DiscoveryDocument document = client.DiscoverAny(url.AbsoluteUri); + client.ResolveOneLevel(); + + e.Result = new ServiceReferenceDiscoveryEventArgs(client.References); + } + + DiscoveryNetworkCredential GetCredentials() + { + return new DiscoveryNetworkCredential( + CredentialCache.DefaultNetworkCredentials, + DiscoveryNetworkCredential.DefaultAuthenticationType); + } + + void DiscoverMexMetadata() + { + DiscoverMexMetadata(mexDiscoveryBackgroundWorker, discoveryUrl); + DiscoverMexMetadata(mexRelativePathDiscoveryBackgroundWorker, GetRelativeUrl("mex")); + } + + Uri GetRelativeUrl(string relativeUrl) + { + return new Uri(GetDiscoveryUrlWithTrailingSlash(), relativeUrl); + } + + Uri GetDiscoveryUrlWithTrailingSlash() + { + if (discoveryUrl.AbsoluteUri.EndsWith("/")) { + return discoveryUrl; + } + return new Uri(discoveryUrl.AbsoluteUri + "/"); + } + + void DiscoverMexMetadata(BackgroundWorker worker, Uri url) + { + worker.DoWork += DiscoverMexMetadata; + worker.RunWorkerCompleted += DiscoveryCompleted; + worker.RunWorkerAsync(url); + } + + void DiscoverMexMetadata(object sender, DoWorkEventArgs e) + { + Uri url = (Uri)e.Argument; + var client = new MetadataExchangeClient(url, MetadataExchangeClientMode.MetadataExchange); + MetadataSet metadata = client.GetMetadata(); + e.Result = new ServiceReferenceDiscoveryEventArgs(metadata); + } + + void DiscoveryCompleted(object sender, RunWorkerCompletedEventArgs e) + { + if (e.Error != null) { + OnDiscoveryError(e.Error); + } else { + OnDiscoveryComplete((ServiceReferenceDiscoveryEventArgs)e.Result); + } + } + + void OnDiscoveryError(Exception ex) + { + errors.Add(ex); + if (errors.Count == DiscoveryClientsUsed) { + OnDiscoveryComplete(new ServiceReferenceDiscoveryEventArgs(errors)); + } + } + } +} diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceDiscoveryEventArgs.cs b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceDiscoveryEventArgs.cs new file mode 100644 index 0000000000..d3249b45e9 --- /dev/null +++ b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceDiscoveryEventArgs.cs @@ -0,0 +1,74 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections; +using System.Collections.Generic; +using System.ServiceModel.Description; +using System.Text; +using System.Web.Services.Description; +using System.Web.Services.Discovery; + +using WebServices = System.Web.Services.Description; + +namespace ICSharpCode.SharpDevelop.Gui +{ + public class ServiceReferenceDiscoveryEventArgs : EventArgs + { + ServiceDescriptionCollection services = new ServiceDescriptionCollection(); + + public ServiceReferenceDiscoveryEventArgs(IEnumerable errors) + { + GenerateAggregateError(errors); + } + + void GenerateAggregateError(IEnumerable errors) + { + var message = new StringBuilder(); + foreach (Exception ex in errors) { + message.AppendLine(ex.Message); + } + Error = new AggregateException(message.ToString(), errors); + } + + public ServiceReferenceDiscoveryEventArgs(DiscoveryClientReferenceCollection references) + { + GetServices(references); + } + + void GetServices(DiscoveryClientReferenceCollection references) + { + foreach (DictionaryEntry entry in references) { + var contractRef = entry.Value as ContractReference; + if (contractRef != null) { + services.Add(contractRef.Contract); + } + } + } + + public ServiceReferenceDiscoveryEventArgs(MetadataSet metadata) + { + GetServices(metadata); + } + + void GetServices(MetadataSet metadata) + { + foreach (MetadataSection section in metadata.MetadataSections) { + var service = section.Metadata as WebServices.ServiceDescription; + if (service != null) { + Services.Add(service); + } + } + } + + public ServiceDescriptionCollection Services { + get { return services; } + } + + public Exception Error { get; private set; } + + public bool HasError { + get { return Error != null; } + } + } +} diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceFileGenerator.cs b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceFileGenerator.cs index 93654abfdf..ba54756fca 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceFileGenerator.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceFileGenerator.cs @@ -11,9 +11,9 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference IServiceReferenceProxyGenerator proxyGenerator; IServiceReferenceMapGenerator mapGenerator; - public ServiceReferenceFileGenerator(ICodeDomProvider codeDomProvider) + public ServiceReferenceFileGenerator() : this( - new ServiceReferenceProxyGenerator(codeDomProvider), + new ServiceReferenceProxyGenerator(), new ServiceReferenceMapGenerator()) { } @@ -26,14 +26,14 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference this.mapGenerator = mapGenerator; } - public string ServiceReferenceNamespace { - get { return proxyGenerator.ServiceReferenceNamespace; } - set { proxyGenerator.ServiceReferenceNamespace = value; } + public ServiceReferenceGeneratorOptions Options { + get { return proxyGenerator.Options; } + set { proxyGenerator.Options = value; } } - public void GenerateProxyFile(MetadataSet metadata, string proxyFileName) + public void GenerateProxyFile() { - proxyGenerator.GenerateProxyFile(metadata, proxyFileName); + proxyGenerator.GenerateProxyFile(); } public void GenerateServiceReferenceMapFile(ServiceReferenceMapFile mapFile) diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceGenerator.cs b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceGenerator.cs index 16cbad416a..2ac5a1942e 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceGenerator.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceGenerator.cs @@ -2,7 +2,9 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; +using System.Collections.Generic; using System.IO; +using System.Linq; using System.ServiceModel.Description; using ICSharpCode.SharpDevelop.Project; @@ -23,7 +25,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference public ServiceReferenceGenerator(IProjectWithServiceReferences project) : this( project, - new ServiceReferenceFileGenerator(project.CodeDomProvider), + new ServiceReferenceFileGenerator(), new ServiceReferenceFileSystem()) { } @@ -38,29 +40,52 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference this.fileSystem = fileSystem; } - public string Namespace { get; set; } + public ServiceReferenceGeneratorOptions Options { + get { return fileGenerator.Options; } + set { fileGenerator.Options = value; } + } - public void AddServiceReference(MetadataSet metadata) + public void AddServiceReference() { - GenerateServiceReferenceProxy(metadata); + GenerateServiceReferenceProxy(); project.AddAssemblyReference("System.ServiceModel"); project.Save(); } - void GenerateServiceReferenceProxy(MetadataSet metadata) + void GenerateServiceReferenceProxy() + { + ServiceReferenceFileName referenceFileName = GenerateProxyFile(); + ServiceReferenceMapFileName mapFileName = CreateServiceReferenceMapFile(); + project.AddServiceReferenceProxyFile(referenceFileName); + project.AddServiceReferenceMapFile(mapFileName); + if (!project.HasAppConfigFile()) { + project.AddAppConfigFile(); + } + } + + ServiceReferenceFileName GenerateProxyFile() { - ServiceReferenceFileName referenceFileName = project.GetServiceReferenceFileName(Namespace); + ServiceReferenceFileName referenceFileName = project.GetServiceReferenceFileName(fileGenerator.Options.ServiceName); CreateFolderForFileIfFolderMissing(referenceFileName.Path); - fileGenerator.ServiceReferenceNamespace = Namespace; - fileGenerator.GenerateProxyFile(metadata, referenceFileName.Path); + Options.OutputFileName = referenceFileName.Path; + Options.AppConfigFileName = project.GetAppConfigFileName(); + Options.NoAppConfig = false; + Options.MergeAppConfig = project.HasAppConfigFile(); + Options.MapProjectLanguage(project.Language); + Options.GenerateNamespace(project.RootNamespace); + Options.AddProjectReferencesIfUsingTypesFromProjectReferences(project.GetReferences()); + fileGenerator.GenerateProxyFile(); - ServiceReferenceMapFileName mapFileName = project.GetServiceReferenceMapFileName(Namespace); + return referenceFileName; + } + + ServiceReferenceMapFileName CreateServiceReferenceMapFile() + { + ServiceReferenceMapFileName mapFileName = project.GetServiceReferenceMapFileName(fileGenerator.Options.ServiceName); var mapFile = new ServiceReferenceMapFile(mapFileName); fileGenerator.GenerateServiceReferenceMapFile(mapFile); - - project.AddServiceReferenceProxyFile(referenceFileName); - project.AddServiceReferenceMapFile(mapFileName); + return mapFileName; } void CreateFolderForFileIfFolderMissing(string fileName) @@ -68,5 +93,29 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference string folder = Path.GetDirectoryName(fileName); fileSystem.CreateDirectoryIfMissing(folder); } + + public IEnumerable GetCheckableAssemblyReferences() + { + return GetUnsortedCheckableAssemblyReferences() + .OrderBy(reference => reference.Description) + .ToArray(); + } + + IEnumerable GetUnsortedCheckableAssemblyReferences() + { + foreach (ReferenceProjectItem item in project.GetReferences()) { + yield return new CheckableAssemblyReference(item); + } + } + + public void UpdateAssemblyReferences(IEnumerable references) + { + Options.Assemblies.Clear(); + foreach (CheckableAssemblyReference reference in references) { + if (reference.ItemChecked) { + Options.Assemblies.Add(reference.GetFileName()); + } + } + } } } diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceGeneratorOptions.cs b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceGeneratorOptions.cs new file mode 100644 index 0000000000..77ab44cef1 --- /dev/null +++ b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceGeneratorOptions.cs @@ -0,0 +1,168 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Reflection; + +using ICSharpCode.SharpDevelop.Project; + +namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference +{ + public class ServiceReferenceGeneratorOptions + { + List assemblies = new List(); + + public ServiceReferenceGeneratorOptions() + : this(new string[0]) + { + } + + public ServiceReferenceGeneratorOptions(IEnumerable assemblies) + { + this.assemblies.AddRange(assemblies); + this.AppConfigFileName = String.Empty; + this.MergeAppConfig = false; + this.OutputFileName = String.Empty; + this.ServiceName = String.Empty; + this.Language = "CS"; + this.NoAppConfig = true; + this.UseTypesInProjectReferences = true; + this.ArrayCollectionType = CollectionTypes.Array; + this.DictionaryCollectionType = DictionaryCollectionTypes.Dictionary; + } + + public string ServiceName { get; set; } + public string Namespace { get; set; } + public string OutputFileName { get; set; } + public string Url { get; set; } + public string Language { get; set; } + public string AppConfigFileName { get; set; } + public bool NoAppConfig { get; set; } + public bool MergeAppConfig { get; set; } + public bool GenerateInternalClasses { get; set; } + public bool GenerateAsyncOperations { get; set; } + public bool GenerateMessageContract { get; set; } + public bool UseTypesInProjectReferences { get; set; } + public bool UseTypesInSpecifiedAssemblies { get; set; } + public CollectionTypes ArrayCollectionType { get; set; } + public DictionaryCollectionTypes DictionaryCollectionType { get; set; } + + public void MapProjectLanguage(string language) + { + if (language == "VBNet") { + Language = "VB"; + } else { + Language = "CS"; + } + } + + public IList Assemblies { + get { return assemblies; } + } + + public ServiceReferenceGeneratorOptions Clone() + { + return new ServiceReferenceGeneratorOptions(this.assemblies) { + ServiceName = this.ServiceName, + OutputFileName = this.OutputFileName, + Url = this.Url, + Language = this.Language, + AppConfigFileName = this.AppConfigFileName, + NoAppConfig = this.NoAppConfig, + MergeAppConfig = this.MergeAppConfig, + UseTypesInSpecifiedAssemblies = this.UseTypesInSpecifiedAssemblies, + UseTypesInProjectReferences = this.UseTypesInProjectReferences, + ArrayCollectionType = this.ArrayCollectionType, + DictionaryCollectionType = this.DictionaryCollectionType, + GenerateInternalClasses = this.GenerateInternalClasses, + GenerateAsyncOperations = this.GenerateAsyncOperations, + GenerateMessageContract = this.GenerateMessageContract + }; + } + + public string GetNamespaceMapping() + { + if (Namespace != null) { + return "*," + Namespace; + } + return null; + } + + public string GetArrayCollectionTypeDescription() + { + string description = GetEnumTypeDescription(ArrayCollectionType.GetType(), ArrayCollectionType.ToString()); + return description + GetGenericTypeSuffix(ArrayCollectionType); + } + + string GetEnumTypeDescription(Type type, string name) + { + foreach (FieldInfo field in type.GetFields()) { + if (field.IsStatic) { + if (field.Name == name) { + return GetDescription(field); + } + } + } + return null; + } + + string GetDescription(FieldInfo field) + { + foreach (DescriptionAttribute attribute in field.GetCustomAttributes(typeof(DescriptionAttribute), false)) + return attribute.Description; + return field.Name; + } + + string GetGenericTypeSuffix(CollectionTypes type) + { + switch (type) { + case CollectionTypes.List: + case CollectionTypes.LinkedList: + case CollectionTypes.ObservableCollection: + case CollectionTypes.Collection: + case CollectionTypes.BindingList: + return "`1"; + } + return String.Empty; + } + + public string GetDictionaryCollectionTypeDescription() + { + string description = GetEnumTypeDescription(DictionaryCollectionType.GetType(), DictionaryCollectionType.ToString()); + return description + GetGenericTypeSuffix(DictionaryCollectionType); + } + + string GetGenericTypeSuffix(DictionaryCollectionTypes type) + { + switch (type) { + case DictionaryCollectionTypes.SortedList_2: + case DictionaryCollectionTypes.HashTable: + case DictionaryCollectionTypes.HybridDictionary: + case DictionaryCollectionTypes.ListDictionary: + case DictionaryCollectionTypes.OrderedDictionary: + return String.Empty; + } + return "`2"; + } + + public void AddProjectReferencesIfUsingTypesFromProjectReferences(IEnumerable assemblies) + { + if (UseTypesInProjectReferences) { + foreach (ReferenceProjectItem item in assemblies) { + Assemblies.Add(item.FileName); + } + } + } + + public void GenerateNamespace(string rootNamespace) + { + if (String.IsNullOrEmpty(rootNamespace)) { + Namespace = ServiceName; + } else { + Namespace = rootNamespace + "." + ServiceName; + } + } + } +} diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceOptions.cs b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceOptions.cs new file mode 100644 index 0000000000..88a65b4190 --- /dev/null +++ b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceOptions.cs @@ -0,0 +1,22 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using ICSharpCode.Core; + +namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference +{ + public static class ServiceReferenceOptions + { + static Properties properties = PropertyService.NestedProperties("ServiceReferenceOptions"); + + public static bool HasSvcUtilPath { + get { return !String.IsNullOrEmpty(SvcUtilPath); } + } + + public static string SvcUtilPath { + get { return properties.Get("SvcUtilPath", String.Empty); } + set { properties.Set("SvcUtilPath", value); } + } + } +} diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceOptionsPanel..xaml b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceOptionsPanel..xaml new file mode 100644 index 0000000000..4c5b0ee833 --- /dev/null +++ b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceOptionsPanel..xaml @@ -0,0 +1,32 @@ + + + + + + + + + + +