From 3ab6c9973f0abfc53304ad76eef1e66b972b6388 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Fri, 28 Jul 2006 20:54:02 +0000 Subject: [PATCH] Add ICSharpCode.SharpDevelop.Sda and SdaUser example application. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1624 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- AddIns/ICSharpCode.SharpDevelop.addin | 31 +- samples/SdaUser/AssemblyInfo.cs | 31 ++ samples/SdaUser/MainForm.Designer.cs | 136 +++++++ samples/SdaUser/MainForm.cs | 125 ++++++ samples/SdaUser/MainForm.resx | 120 ++++++ samples/SdaUser/SdaAddIns/SdaBase.addin | 238 +++++++++++ samples/SdaUser/SdaUser.csproj | 67 ++++ samples/SdaUser/SdaUser.sln | 16 + .../FormsDesignerLoadException.cs | 2 +- .../Project/Src/CodeCoverageException.cs | 14 +- .../Project/Src/NAntAddInException.cs | 12 +- .../Exceptions/ConnectionStringException.cs | 11 +- .../Exceptions/ExecuteProcedureException.cs | 10 + .../Src/Exceptions/ExecuteSQLException.cs | 9 + .../Src/Exceptions/OpenConnectionException.cs | 10 +- .../Exceptions/SharpQueryAbstractException.cs | 16 + .../HistoryViewPanel.cs | 1 + .../SubversionAddIn/Project/Src/SvnClient.cs | 1 + .../WinFormsUI/WinFormsUI.csproj | 3 +- .../HighlightingColorNotFoundException.cs | 16 +- .../Project/ICSharpCode.SharpDevelop.csproj | 4 +- .../Project/Src/Commands/AutostartCommands.cs | 25 +- .../ProjectOptions/AbstractBuildOptions.cs | 3 +- .../Gui/Dialogs/SharpDevelopAboutPanels.cs | 28 +- .../Workbench/Layouts/LayoutConfiguration.cs | 27 +- .../Project/Src/Gui/WorkbenchSingleton.cs | 2 + .../Base/Project/Src/Project/MSBuildEngine.cs | 1 + .../Base/Project/Src/Services/IconService.cs | 1 + .../Services/ParserService/ParserService.cs | 13 +- .../Services/ProjectService/ProjectService.cs | 14 +- .../Gui/Dialogs/ExportProjectToHtmlDialog.cs | 1 + .../Base/Project/Src/Util/OutputReader.cs | 1 + .../Src/Util/ProcessRunnerException.cs | 19 +- src/Main/Core/Project/ICSharpCode.Core.csproj | 5 +- .../Project/Resources/ICSharpCode.Core.snk | Bin 596 -> 0 bytes .../Src/AddInTree/AddIn/AddInLoadException.cs | 18 +- .../Core/Project/Src/AddInTree/CoreStartup.cs | 15 + .../AddInTree/TreePathNotFoundException.cs | 17 +- src/Main/Core/Project/Src/CoreException.cs | 7 +- .../Src/Services/FileUtility/FileUtility.cs | 4 +- .../Services/LoggingService/LoggingService.cs | 2 +- .../Src/Services/MenuService/MenuService.cs | 5 +- .../Services/MessageService/MessageService.cs | 3 +- .../ResourceNotFoundException.cs | 14 + .../Configuration/AssemblyInfo.cs | 22 + .../ICSharpCode.SharpDevelop.Sda.csproj | 85 ++++ .../ICSharpCode.SharpDevelop.Sda.dll.config | 72 ++++ .../ICSharpCode.SharpDevelop.Sda.sln | 6 + .../Src/CallHelper.cs | 260 ++++++++++++ .../Src/Document.cs | 78 ++++ .../Src/EventArgs.cs | 38 ++ .../Src}/ExceptionBox.cs | 81 +++- .../Src/RunWorkbenchException.cs | 47 +++ .../Src/SharpDevelopHost.cs | 378 ++++++++++++++++++ .../Src/StartupSettings.cs | 159 ++++++++ .../Src/WorkbenchSettings.cs | 59 +++ .../ICSharpCode.SharpDevelop.snk | Bin .../StartUp/Project/Resources/StartUp.snk | Bin 596 -> 0 bytes src/Main/StartUp/Project/SharpDevelopMain.cs | 155 +------ src/Main/StartUp/Project/StartUp.csproj | 13 +- src/SharpDevelop.sln | 7 + 61 files changed, 2325 insertions(+), 233 deletions(-) create mode 100644 samples/SdaUser/AssemblyInfo.cs create mode 100644 samples/SdaUser/MainForm.Designer.cs create mode 100644 samples/SdaUser/MainForm.cs create mode 100644 samples/SdaUser/MainForm.resx create mode 100644 samples/SdaUser/SdaAddIns/SdaBase.addin create mode 100644 samples/SdaUser/SdaUser.csproj create mode 100644 samples/SdaUser/SdaUser.sln delete mode 100644 src/Main/Core/Project/Resources/ICSharpCode.Core.snk create mode 100644 src/Main/ICSharpCode.SharpDevelop.Sda/Configuration/AssemblyInfo.cs create mode 100644 src/Main/ICSharpCode.SharpDevelop.Sda/ICSharpCode.SharpDevelop.Sda.csproj create mode 100644 src/Main/ICSharpCode.SharpDevelop.Sda/ICSharpCode.SharpDevelop.Sda.dll.config create mode 100644 src/Main/ICSharpCode.SharpDevelop.Sda/ICSharpCode.SharpDevelop.Sda.sln create mode 100644 src/Main/ICSharpCode.SharpDevelop.Sda/Src/CallHelper.cs create mode 100644 src/Main/ICSharpCode.SharpDevelop.Sda/Src/Document.cs create mode 100644 src/Main/ICSharpCode.SharpDevelop.Sda/Src/EventArgs.cs rename src/Main/{StartUp/Project/Dialogs => ICSharpCode.SharpDevelop.Sda/Src}/ExceptionBox.cs (78%) create mode 100644 src/Main/ICSharpCode.SharpDevelop.Sda/Src/RunWorkbenchException.cs create mode 100644 src/Main/ICSharpCode.SharpDevelop.Sda/Src/SharpDevelopHost.cs create mode 100644 src/Main/ICSharpCode.SharpDevelop.Sda/Src/StartupSettings.cs create mode 100644 src/Main/ICSharpCode.SharpDevelop.Sda/Src/WorkbenchSettings.cs rename src/Main/{Base/Project/Resources => }/ICSharpCode.SharpDevelop.snk (100%) delete mode 100644 src/Main/StartUp/Project/Resources/StartUp.snk diff --git a/AddIns/ICSharpCode.SharpDevelop.addin b/AddIns/ICSharpCode.SharpDevelop.addin index 691bbc72fc..4cfd751a35 100644 --- a/AddIns/ICSharpCode.SharpDevelop.addin +++ b/AddIns/ICSharpCode.SharpDevelop.addin @@ -10,7 +10,36 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/SdaUser/AssemblyInfo.cs b/samples/SdaUser/AssemblyInfo.cs new file mode 100644 index 0000000000..157431a9fd --- /dev/null +++ b/samples/SdaUser/AssemblyInfo.cs @@ -0,0 +1,31 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("SdaUser")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SdaUser")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.*")] diff --git a/samples/SdaUser/MainForm.Designer.cs b/samples/SdaUser/MainForm.Designer.cs new file mode 100644 index 0000000000..b37dec8fc7 --- /dev/null +++ b/samples/SdaUser/MainForm.Designer.cs @@ -0,0 +1,136 @@ +/* + * Created by SharpDevelop. + * User: Daniel Grunwald + * Date: 26.07.2006 + * Time: 19:49 + */ +namespace SdaUser +{ + partial class MainForm : System.Windows.Forms.Form + { + /// + /// Designer variable used to keep track of non-visual components. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Disposes resources used by the form. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing) { + if (components != null) { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + /// + /// This method is required for Windows Forms designer support. + /// Do not change the method contents inside the source code editor. The Forms designer might + /// not be able to load this method if it was changed manually. + /// + private void InitializeComponent() + { + this.runButton = new System.Windows.Forms.Button(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.closeButton = new System.Windows.Forms.Button(); + this.visibleCheckBox = new System.Windows.Forms.CheckBox(); + this.unloadHostDomainButton = new System.Windows.Forms.Button(); + this.openFileButton = new System.Windows.Forms.Button(); + this.groupBox1.SuspendLayout(); + this.SuspendLayout(); + // + // runButton + // + this.runButton.Location = new System.Drawing.Point(28, 57); + this.runButton.Name = "runButton"; + this.runButton.Size = new System.Drawing.Size(221, 31); + this.runButton.TabIndex = 0; + this.runButton.Text = "Run Integrated SharpDevelop"; + this.runButton.UseVisualStyleBackColor = true; + this.runButton.Click += new System.EventHandler(this.RunButtonClick); + // + // groupBox1 + // + this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBox1.Controls.Add(this.closeButton); + this.groupBox1.Controls.Add(this.visibleCheckBox); + this.groupBox1.Enabled = false; + this.groupBox1.Location = new System.Drawing.Point(12, 130); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(268, 92); + this.groupBox1.TabIndex = 1; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "groupBox1"; + // + // closeButton + // + this.closeButton.Location = new System.Drawing.Point(6, 50); + this.closeButton.Name = "closeButton"; + this.closeButton.Size = new System.Drawing.Size(123, 23); + this.closeButton.TabIndex = 1; + this.closeButton.Text = "Close Workbench"; + this.closeButton.UseVisualStyleBackColor = true; + this.closeButton.Click += new System.EventHandler(this.CloseButtonClick); + // + // visibleCheckBox + // + this.visibleCheckBox.Checked = true; + this.visibleCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; + this.visibleCheckBox.Location = new System.Drawing.Point(6, 20); + this.visibleCheckBox.Name = "visibleCheckBox"; + this.visibleCheckBox.Size = new System.Drawing.Size(256, 24); + this.visibleCheckBox.TabIndex = 0; + this.visibleCheckBox.Text = "WorkbenchVisible"; + this.visibleCheckBox.UseVisualStyleBackColor = true; + this.visibleCheckBox.CheckedChanged += new System.EventHandler(this.VisibleCheckBoxCheckedChanged); + // + // unloadHostDomainButton + // + this.unloadHostDomainButton.Enabled = false; + this.unloadHostDomainButton.Location = new System.Drawing.Point(28, 94); + this.unloadHostDomainButton.Name = "unloadHostDomainButton"; + this.unloadHostDomainButton.Size = new System.Drawing.Size(221, 23); + this.unloadHostDomainButton.TabIndex = 2; + this.unloadHostDomainButton.Text = "Unload SharpDevelop AppDomain"; + this.unloadHostDomainButton.UseVisualStyleBackColor = true; + this.unloadHostDomainButton.Click += new System.EventHandler(this.UnloadHostDomainButtonClick); + // + // openFileButton + // + this.openFileButton.Location = new System.Drawing.Point(18, 243); + this.openFileButton.Name = "openFileButton"; + this.openFileButton.Size = new System.Drawing.Size(75, 23); + this.openFileButton.TabIndex = 3; + this.openFileButton.Text = "Open File"; + this.openFileButton.UseVisualStyleBackColor = true; + this.openFileButton.Click += new System.EventHandler(this.OpenFileButtonClick); + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(292, 334); + this.Controls.Add(this.openFileButton); + this.Controls.Add(this.unloadHostDomainButton); + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.runButton); + this.Name = "MainForm"; + this.Text = "SdaUser"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainFormFormClosing); + this.groupBox1.ResumeLayout(false); + this.ResumeLayout(false); + } + private System.Windows.Forms.Button openFileButton; + private System.Windows.Forms.Button unloadHostDomainButton; + private System.Windows.Forms.Button closeButton; + private System.Windows.Forms.CheckBox visibleCheckBox; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.Button runButton; + } +} diff --git a/samples/SdaUser/MainForm.cs b/samples/SdaUser/MainForm.cs new file mode 100644 index 0000000000..0be2e8b061 --- /dev/null +++ b/samples/SdaUser/MainForm.cs @@ -0,0 +1,125 @@ +/* + * Created by SharpDevelop. + * User: Daniel Grunwald + * Date: 26.07.2006 + * Time: 19:49 + */ + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.IO; +using System.Reflection; +using System.Windows.Forms; +using ICSharpCode.SharpDevelop.Sda; + +namespace SdaUser +{ + public partial class MainForm + { + [STAThread] + public static void Main(string[] args) + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new MainForm()); + } + + public MainForm() + { + // + // The InitializeComponent() call is required for Windows Forms designer support. + // + InitializeComponent(); + + // + // TODO: Add constructor code after the InitializeComponent() call. + // + } + + void RunButtonClick(object sender, EventArgs e) + { + Run(); + } + + SharpDevelopHost host; + + void Run() + { + runButton.Enabled = false; + unloadHostDomainButton.Enabled = true; + System.Threading.ThreadPool.QueueUserWorkItem(ThreadedRun); + } + + void ThreadedRun(object state) + { + RunWorkbench(new WorkbenchSettings()); + } + + void RunWorkbench(WorkbenchSettings wbSettings) + { + if (host == null) { + StartupSettings startup = new StartupSettings(); + startup.ApplicationName = "HostedSharpDevelop"; + startup.DataDirectory = Path.Combine(Path.GetDirectoryName(typeof(SharpDevelopHost).Assembly.Location), "../data"); + string sdaDir = Path.Combine(Path.GetDirectoryName(typeof(MainForm).Assembly.Location), "SdaAddIns"); + startup.AddAddInFile(Path.Combine(sdaDir, "SdaBase.addin")); + + host = new SharpDevelopHost(startup); + host.InvokeTarget = this; + host.BeforeRunWorkbench += delegate { groupBox1.Enabled = true; }; + host.WorkbenchClosed += delegate { groupBox1.Enabled = false; runButton.Enabled = true; }; + } + + host.RunWorkbench(wbSettings); + } + + void VisibleCheckBoxCheckedChanged(object sender, System.EventArgs e) + { + host.WorkbenchVisible = visibleCheckBox.Checked; + } + + void CloseButtonClick(object sender, System.EventArgs e) + { + if (!host.CloseWorkbench(false)) { + if (DialogResult.Yes == MessageBox.Show("Force close?", "Force", MessageBoxButtons.YesNo)) { + host.CloseWorkbench(true); + } + } + } + + void MainFormFormClosing(object sender, FormClosingEventArgs e) + { + if (host != null && host.WorkbenchVisible == false) { + if (!host.CloseWorkbench(false)) { + host.WorkbenchVisible = true; + } + } + } + + void UnloadHostDomainButtonClick(object sender, System.EventArgs e) + { + unloadHostDomainButton.Enabled = false; + host.UnloadDomain(); + host = null; + } + + void OpenFileButtonClick(object sender, System.EventArgs e) + { + using (OpenFileDialog dlg = new OpenFileDialog()) { + if (dlg.ShowDialog() == DialogResult.OK) { + if (runButton.Enabled) { + runButton.Enabled = false; + unloadHostDomainButton.Enabled = true; + + WorkbenchSettings wbSettings = new WorkbenchSettings(); + wbSettings.InitialFileList.Add(dlg.FileName); + RunWorkbench(wbSettings); + } else if (host != null) { + host.OpenDocument(dlg.FileName); + } + } + } + } + } +} diff --git a/samples/SdaUser/MainForm.resx b/samples/SdaUser/MainForm.resx new file mode 100644 index 0000000000..7080a7d118 --- /dev/null +++ b/samples/SdaUser/MainForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/samples/SdaUser/SdaAddIns/SdaBase.addin b/samples/SdaUser/SdaAddIns/SdaBase.addin new file mode 100644 index 0000000000..66291b2c40 --- /dev/null +++ b/samples/SdaUser/SdaAddIns/SdaBase.addin @@ -0,0 +1,238 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/SdaUser/SdaUser.csproj b/samples/SdaUser/SdaUser.csproj new file mode 100644 index 0000000000..579a56ea93 --- /dev/null +++ b/samples/SdaUser/SdaUser.csproj @@ -0,0 +1,67 @@ + + + WinExe + SdaUser + SdaUser + Debug + AnyCPU + {3FF48818-69D2-4884-8F4F-62EC72F0D5F0} + False + False + False + Auto + 4194304 + AnyCPU + 4096 + 4 + false + + + obj\ + obj\Debug\ + ..\..\bin\ + False + DEBUG;TRACE + true + Full + True + + + obj\ + obj\Release\ + bin\Release\ + True + TRACE + False + None + False + + + + + + + + + ..\..\bin\ICSharpCode.SharpDevelop.Sda.dll + False + + + + + + MainForm.cs + + + + MainForm.cs + + + + + + Always + + + + \ No newline at end of file diff --git a/samples/SdaUser/SdaUser.sln b/samples/SdaUser/SdaUser.sln new file mode 100644 index 0000000000..f62f0f2516 --- /dev/null +++ b/samples/SdaUser/SdaUser.sln @@ -0,0 +1,16 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# SharpDevelop 2.1.0.1602 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SdaUser", "SdaUser.csproj", "{3FF48818-69D2-4884-8F4F-62EC72F0D5F0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3FF48818-69D2-4884-8F4F-62EC72F0D5F0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3FF48818-69D2-4884-8F4F-62EC72F0D5F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3FF48818-69D2-4884-8F4F-62EC72F0D5F0}.Release|Any CPU.Build.0 = Release|Any CPU + {3FF48818-69D2-4884-8F4F-62EC72F0D5F0}.Release|Any CPU.ActiveCfg = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerLoader/FormsDesignerLoadException.cs b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerLoader/FormsDesignerLoadException.cs index a8eb12a4db..9b768bb894 100644 --- a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerLoader/FormsDesignerLoadException.cs +++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerLoader/FormsDesignerLoadException.cs @@ -11,7 +11,7 @@ using System.Runtime.Serialization; namespace ICSharpCode.FormsDesigner { [Serializable()] - public class FormsDesignerLoadException : ApplicationException + public class FormsDesignerLoadException : Exception { public FormsDesignerLoadException() : base() { diff --git a/src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageException.cs b/src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageException.cs index 76a20ad11b..bbb154d6a8 100644 --- a/src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageException.cs +++ b/src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageException.cs @@ -6,14 +6,16 @@ // using System; +using System.Runtime.Serialization; namespace ICSharpCode.CodeCoverage { /// - /// The exception that is thrown when a non-fatal + /// The exception that is thrown when a non-fatal /// error occurs in the code coverage add-in. /// - public class CodeCoverageException : ApplicationException + [Serializable()] + public class CodeCoverageException : Exception { public CodeCoverageException() { @@ -23,5 +25,13 @@ namespace ICSharpCode.CodeCoverage : base(message) { } + + public CodeCoverageException(string message, Exception innerException) : base(message, innerException) + { + } + + protected CodeCoverageException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } } } diff --git a/src/AddIns/Misc/NAntAddIn/Project/Src/NAntAddInException.cs b/src/AddIns/Misc/NAntAddIn/Project/Src/NAntAddInException.cs index e2ef0155af..6ecb53568a 100644 --- a/src/AddIns/Misc/NAntAddIn/Project/Src/NAntAddInException.cs +++ b/src/AddIns/Misc/NAntAddIn/Project/Src/NAntAddInException.cs @@ -6,13 +6,15 @@ // using System; +using System.Runtime.Serialization; namespace ICSharpCode.NAntAddIn { /// - /// The exception that is thrown when a non-fatal + /// The exception that is thrown when a non-fatal /// error occurs in the NAnt add-in. /// + [Serializable()] public class NAntAddInException : ApplicationException { public NAntAddInException() @@ -23,5 +25,13 @@ namespace ICSharpCode.NAntAddIn : base(message) { } + + public NAntAddInException(string message, Exception innerException) : base(message, innerException) + { + } + + protected NAntAddInException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } } } diff --git a/src/AddIns/Misc/SharpQuery/Src/Exceptions/ConnectionStringException.cs b/src/AddIns/Misc/SharpQuery/Src/Exceptions/ConnectionStringException.cs index 4e71c62c5e..61aa49c3dc 100644 --- a/src/AddIns/Misc/SharpQuery/Src/Exceptions/ConnectionStringException.cs +++ b/src/AddIns/Misc/SharpQuery/Src/Exceptions/ConnectionStringException.cs @@ -8,9 +8,11 @@ using System; using ICSharpCode.Core; using SharpQuery.SchemaClass; +using System.Runtime.Serialization; namespace SharpQuery.Exceptions { + [Serializable()] public class ConnectionStringException : Exception { public ConnectionStringException() @@ -38,6 +40,13 @@ namespace SharpQuery.Exceptions + message) { } + + public ConnectionStringException(string message, Exception innerException) : base(message, innerException) + { + } + + protected ConnectionStringException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } } - } diff --git a/src/AddIns/Misc/SharpQuery/Src/Exceptions/ExecuteProcedureException.cs b/src/AddIns/Misc/SharpQuery/Src/Exceptions/ExecuteProcedureException.cs index 3f6f6a1cfb..6a2b96d74f 100644 --- a/src/AddIns/Misc/SharpQuery/Src/Exceptions/ExecuteProcedureException.cs +++ b/src/AddIns/Misc/SharpQuery/Src/Exceptions/ExecuteProcedureException.cs @@ -8,9 +8,11 @@ using System; using ICSharpCode.Core; using SharpQuery.SchemaClass; +using System.Runtime.Serialization; namespace SharpQuery.Exceptions { + [Serializable()] public class ExecuteProcedureException : Exception { public ExecuteProcedureException() @@ -38,6 +40,14 @@ namespace SharpQuery.Exceptions + message) { } + + public ExecuteProcedureException(string message, Exception innerException) : base(message, innerException) + { + } + + protected ExecuteProcedureException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } } } diff --git a/src/AddIns/Misc/SharpQuery/Src/Exceptions/ExecuteSQLException.cs b/src/AddIns/Misc/SharpQuery/Src/Exceptions/ExecuteSQLException.cs index a082956fc4..9d3119fff3 100644 --- a/src/AddIns/Misc/SharpQuery/Src/Exceptions/ExecuteSQLException.cs +++ b/src/AddIns/Misc/SharpQuery/Src/Exceptions/ExecuteSQLException.cs @@ -8,9 +8,11 @@ using System; using ICSharpCode.Core; using SharpQuery.SchemaClass; +using System.Runtime.Serialization; namespace SharpQuery.Exceptions { + [Serializable()] public class ExecuteSQLException : Exception { public ExecuteSQLException() @@ -39,6 +41,13 @@ namespace SharpQuery.Exceptions { } + public ExecuteSQLException(string message, Exception innerException) : base(message, innerException) + { + } + + protected ExecuteSQLException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } } } diff --git a/src/AddIns/Misc/SharpQuery/Src/Exceptions/OpenConnectionException.cs b/src/AddIns/Misc/SharpQuery/Src/Exceptions/OpenConnectionException.cs index 21b67fac0c..c9586c72a9 100644 --- a/src/AddIns/Misc/SharpQuery/Src/Exceptions/OpenConnectionException.cs +++ b/src/AddIns/Misc/SharpQuery/Src/Exceptions/OpenConnectionException.cs @@ -8,9 +8,11 @@ using System; using ICSharpCode.Core; using SharpQuery.SchemaClass; +using System.Runtime.Serialization; namespace SharpQuery.Exceptions { + [Serializable()] public class OpenConnectionException : Exception { public OpenConnectionException() @@ -39,7 +41,13 @@ namespace SharpQuery.Exceptions { } - + public OpenConnectionException(string message, Exception innerException) : base(message, innerException) + { + } + + protected OpenConnectionException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } } } diff --git a/src/AddIns/Misc/SharpQuery/Src/Exceptions/SharpQueryAbstractException.cs b/src/AddIns/Misc/SharpQuery/Src/Exceptions/SharpQueryAbstractException.cs index 917a9995c9..84f7331a20 100644 --- a/src/AddIns/Misc/SharpQuery/Src/Exceptions/SharpQueryAbstractException.cs +++ b/src/AddIns/Misc/SharpQuery/Src/Exceptions/SharpQueryAbstractException.cs @@ -6,11 +6,27 @@ // using System; +using System.Runtime.Serialization; namespace SharpQuery.Exceptions { + [Serializable()] public abstract class SharpQueryAbstractException : Exception { + public SharpQueryAbstractException() : base() + { + } + public SharpQueryAbstractException(string message) : base(message) + { + } + + public SharpQueryAbstractException(string message, Exception innerException) : base(message, innerException) + { + } + + protected SharpQueryAbstractException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } } } diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewPanel.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewPanel.cs index 190146b3e0..c46c043b23 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewPanel.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewPanel.cs @@ -68,6 +68,7 @@ namespace ICSharpCode.Svn Controls.Add(mainTab); Thread logMessageThread = new Thread(new ThreadStart(GetLogMessages)); + logMessageThread.Name = "svnLogMessage"; logMessageThread.IsBackground = true; logMessageThread.Start(); } diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/SvnClient.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/SvnClient.cs index 102dd3e569..decc71a3ab 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/SvnClient.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/SvnClient.cs @@ -186,6 +186,7 @@ namespace ICSharpCode.Svn WriteMid(operationName); Thread thread = new Thread(new ThreadStart(new ThreadStartWrapper(threadStart).Start)); + thread.Name = "SvnOperation"; thread.IsBackground = true; inOperationForm = new InOperationDialog(operationName, thread); inOperationForm.Owner = (Form)WorkbenchSingleton.Workbench; diff --git a/src/Libraries/DockPanel_Src/WinFormsUI/WinFormsUI.csproj b/src/Libraries/DockPanel_Src/WinFormsUI/WinFormsUI.csproj index b5155e8efb..e47e696e9c 100644 --- a/src/Libraries/DockPanel_Src/WinFormsUI/WinFormsUI.csproj +++ b/src/Libraries/DockPanel_Src/WinFormsUI/WinFormsUI.csproj @@ -7,7 +7,7 @@ Debug AnyCPU WeifenLuo.WinFormsUI.Docking - ..\..\..\Main\Core\Project\Resources\ICSharpCode.Core.snk + ..\..\..\Main\ICSharpCode.SharpDevelop.snk JScript Grid IE50 @@ -18,6 +18,7 @@ true Auto AnyCPU + File bin\Debug\ diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/HighlightingColorNotFoundException.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/HighlightingColorNotFoundException.cs index 737f9b4f17..330b267fe3 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/HighlightingColorNotFoundException.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/HighlightingColorNotFoundException.cs @@ -6,12 +6,26 @@ // using System; +using System.Runtime.Serialization; namespace ICSharpCode.TextEditor.Document { + [Serializable()] public class HighlightingColorNotFoundException : Exception { - public HighlightingColorNotFoundException(string name) : base(name) + public HighlightingColorNotFoundException() : base() + { + } + + public HighlightingColorNotFoundException(string message) : base(message) + { + } + + public HighlightingColorNotFoundException(string message, Exception innerException) : base(message, innerException) + { + } + + protected HighlightingColorNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { } } diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj index 77d14c90f7..6fb3f4247c 100644 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj @@ -11,7 +11,7 @@ False Library True - Resources\ICSharpCode.SharpDevelop.snk + ..\..\ICSharpCode.SharpDevelop.snk File False False @@ -20,6 +20,7 @@ AnyCPU 4096 false + False False @@ -482,7 +483,6 @@ - diff --git a/src/Main/Base/Project/Src/Commands/AutostartCommands.cs b/src/Main/Base/Project/Src/Commands/AutostartCommands.cs index 5f92d7a619..e1ab1f1f83 100644 --- a/src/Main/Base/Project/Src/Commands/AutostartCommands.cs +++ b/src/Main/Base/Project/Src/Commands/AutostartCommands.cs @@ -1,32 +1,27 @@ // // // -// +// // $Revision$ // using System; -using System.IO; -using System.Collections; -using System.CodeDom.Compiler; +using System.Collections.Generic; using System.Windows.Forms; -using System.Reflection; -using System.Threading; -using System.Runtime.Remoting; -using System.Security.Policy; using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Project; -using ICSharpCode.SharpDevelop.Dom; - namespace ICSharpCode.SharpDevelop.Commands { - public class StartWorkbenchCommand // : AbstractCommand + public class StartWorkbenchCommand { const string workbenchMemento = "WorkbenchMemento"; + public bool AllowTipOfTheDay = true; + public bool TipOfTheDayDefault = true; + /// /// The worst workaround in the whole project /// @@ -35,7 +30,7 @@ namespace ICSharpCode.SharpDevelop.Commands Application.Idle -= ShowTipOfTheDay; // show tip of the day - if (PropertyService.Get("ShowTipsAtStartup", true)) { + if (PropertyService.Get("ShowTipsAtStartup", TipOfTheDayDefault)) { ViewTipOfTheDay dview = new ViewTipOfTheDay(); dview.Run(); } @@ -97,12 +92,14 @@ namespace ICSharpCode.SharpDevelop.Commands } } - public void Run(string[] fileList) + public void Run(IList fileList) { Form f = (Form)WorkbenchSingleton.Workbench; f.Show(); - Application.Idle += ShowTipOfTheDay; + if (AllowTipOfTheDay) { + Application.Idle += ShowTipOfTheDay; + } bool didLoadCombineOrFile = false; diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AbstractBuildOptions.cs b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AbstractBuildOptions.cs index 7864cc1e09..ea16f03eb0 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AbstractBuildOptions.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AbstractBuildOptions.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using System.IO; using System.Windows.Forms; using ICSharpCode.SharpDevelop.Project; @@ -61,7 +62,7 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels Get("xmlDocumentation").Enabled = Get("xmlDocumentation").Checked; if (Get("xmlDocumentation").Checked) { if (Get("xmlDocumentation").Text.Length == 0) { - Get("xmlDocumentation").Text = FileUtility.GetRelativePath(baseDirectory, project.OutputAssemblyFullPath) + ".xml"; + Get("xmlDocumentation").Text = Path.ChangeExtension(FileUtility.GetRelativePath(baseDirectory, project.OutputAssemblyFullPath), ".xml"); } } else { Get("xmlDocumentation").Text = ""; diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/SharpDevelopAboutPanels.cs b/src/Main/Base/Project/Src/Gui/Dialogs/SharpDevelopAboutPanels.cs index c791ba9416..17f12db198 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/SharpDevelopAboutPanels.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/SharpDevelopAboutPanels.cs @@ -6,17 +6,11 @@ // using System; -using System.Drawing; -using System.ComponentModel; -using System.Windows.Forms; -using System.Resources; -using System.IO; -using System.Text; using System.Reflection; -using System.Runtime.CompilerServices; +using System.Runtime.Serialization; +using System.Text; +using System.Windows.Forms; -using ICSharpCode.SharpDevelop.Gui; -using ICSharpCode.SharpDevelop.Project; using ICSharpCode.Core; namespace ICSharpCode.SharpDevelop.Gui @@ -84,8 +78,24 @@ namespace ICSharpCode.SharpDevelop.Gui } } + [Serializable()] class ClownFishException : System.Exception { + public ClownFishException() : base() + { + } + + public ClownFishException(string message) : base(message) + { + } + + public ClownFishException(string message, Exception innerException) : base(message, innerException) + { + } + + protected ClownFishException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } } void ThrowExceptionButtonClick(object sender, EventArgs e) diff --git a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/LayoutConfiguration.cs b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/LayoutConfiguration.cs index 97dfdf55bb..33f93f53c6 100644 --- a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/LayoutConfiguration.cs +++ b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/LayoutConfiguration.cs @@ -96,11 +96,6 @@ namespace ICSharpCode.SharpDevelop.Gui PropertyService.Set("Workbench.CurrentLayout", value); WorkbenchSingleton.Workbench.WorkbenchLayout.LoadConfiguration(); OnLayoutChanged(EventArgs.Empty); - #if DEBUG - GC.Collect(); - GC.WaitForPendingFinalizers(); - GC.Collect(); - #endif } } } @@ -148,20 +143,18 @@ namespace ICSharpCode.SharpDevelop.Gui return null; } - static LayoutConfiguration() + internal static void LoadLayoutConfiguration() { - LoadLayoutConfiguration(); - } - - static void LoadLayoutConfiguration() - { - - string configPath = Path.Combine(PropertyService.ConfigDirectory, "layouts"); - if (File.Exists(Path.Combine(configPath, configFile))) { - LoadLayoutConfiguration(Path.Combine(configPath, configFile)); + if (Layouts.Count == 0) { + string configPath = Path.Combine(PropertyService.ConfigDirectory, "layouts"); + if (File.Exists(Path.Combine(configPath, configFile))) { + LoadLayoutConfiguration(Path.Combine(configPath, configFile)); + } + string dataPath = Path.Combine(PropertyService.DataDirectory, "resources" + Path.DirectorySeparatorChar + "layouts"); + if (File.Exists(Path.Combine(dataPath, configFile))) { + LoadLayoutConfiguration(Path.Combine(dataPath, configFile)); + } } - string dataPath = Path.Combine(PropertyService.DataDirectory, "resources" + Path.DirectorySeparatorChar + "layouts"); - LoadLayoutConfiguration(Path.Combine(dataPath, configFile)); } static void LoadLayoutConfiguration(string layoutConfig) diff --git a/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs b/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs index 3a2b3a29b5..0a0dc5a863 100644 --- a/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs +++ b/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs @@ -73,6 +73,8 @@ namespace ICSharpCode.SharpDevelop.Gui public static void InitializeWorkbench() { + LayoutConfiguration.LoadLayoutConfiguration(); + workbench = new DefaultWorkbench(); MessageService.MainForm = workbench; diff --git a/src/Main/Base/Project/Src/Project/MSBuildEngine.cs b/src/Main/Base/Project/Src/Project/MSBuildEngine.cs index ea4d79d1df..066dbc05e6 100644 --- a/src/Main/Base/Project/Src/Project/MSBuildEngine.cs +++ b/src/Main/Base/Project/Src/Project/MSBuildEngine.cs @@ -207,6 +207,7 @@ namespace ICSharpCode.SharpDevelop.Project } else { isRunning = true; Thread thread = new Thread(new ThreadStarter(buildFile, targets, this, callback).Run); + thread.Name = "MSBuildEngine"; thread.SetApartmentState(ApartmentState.STA); thread.Start(); } diff --git a/src/Main/Base/Project/Src/Services/IconService.cs b/src/Main/Base/Project/Src/Services/IconService.cs index 0673b7934f..7e01636922 100644 --- a/src/Main/Base/Project/Src/Services/IconService.cs +++ b/src/Main/Base/Project/Src/Services/IconService.cs @@ -32,6 +32,7 @@ namespace ICSharpCode.Core static IconService() { Thread myThread = new Thread(new ThreadStart(LoadThread)); + myThread.Name = "IconLoader"; myThread.IsBackground = true; myThread.Priority = ThreadPriority.Normal; myThread.Start(); diff --git a/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs b/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs index 7d2157cea8..b9ea704609 100644 --- a/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs +++ b/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs @@ -107,6 +107,7 @@ namespace ICSharpCode.Core } } loadSolutionProjectsThread = new Thread(new ThreadStart(LoadSolutionProjects)); + loadSolutionProjectsThread.Name = "loadSolutionProjects"; loadSolutionProjectsThread.Priority = ThreadPriority.BelowNormal; loadSolutionProjectsThread.IsBackground = true; loadSolutionProjectsThread.Start(); @@ -244,6 +245,7 @@ namespace ICSharpCode.Core { abortParserUpdateThread = false; Thread parserThread = new Thread(new ThreadStart(ParserUpdateThread)); + parserThread.Name = "parser"; parserThread.Priority = ThreadPriority.BelowNormal; parserThread.IsBackground = true; parserThread.Start(); @@ -301,13 +303,12 @@ namespace ICSharpCode.Core object[] workbench; try { workbench = (object[])WorkbenchSingleton.SafeThreadCall(typeof(ParserService), "GetWorkbench"); - } catch (ObjectDisposedException) { + } catch (InvalidOperationException) { // includes ObjectDisposedException // maybe workbench has been disposed while waiting for the SafeThreadCall - LoggingService.Warn("ObjectDisposedException while trying to invoke GetWorkbench()"); - if (abortParserUpdateThread) - return; // abort this thread - else - throw; // some other error -> re-raise + // can occur after workbench unload or after aborting SharpDevelop with + // Application.Exit() + LoggingService.Warn("InvalidOperationException while trying to invoke GetWorkbench()"); + return; // abort this thread } if (workbench != null) { IEditable editable = workbench[0] as IEditable; diff --git a/src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs b/src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs index 002e67a661..a0a73078ba 100644 --- a/src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs +++ b/src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs @@ -57,12 +57,12 @@ namespace ICSharpCode.SharpDevelop.Project public static void InitializeService() { - if (initialized) - throw new InvalidOperationException("ProjectService already is initialized"); - initialized = true; - WorkbenchSingleton.Workbench.ActiveWorkbenchWindowChanged += ActiveWindowChanged; - FileService.FileRenamed += FileServiceFileRenamed; - FileService.FileRemoved += FileServiceFileRemoved; + if (!initialized) { + initialized = true; + WorkbenchSingleton.Workbench.ActiveWorkbenchWindowChanged += ActiveWindowChanged; + FileService.FileRenamed += FileServiceFileRenamed; + FileService.FileRemoved += FileServiceFileRemoved; + } } /// @@ -93,7 +93,7 @@ namespace ICSharpCode.SharpDevelop.Project } return null; } - + public static void LoadSolutionOrProject(string fileName) { IProjectLoader loader = GetProjectLoader(fileName); diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/ExportProjectToHtmlDialog.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/ExportProjectToHtmlDialog.cs index 245e30d246..291bab08ac 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/ExportProjectToHtmlDialog.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/ExportProjectToHtmlDialog.cs @@ -485,6 +485,7 @@ namespace ICSharpCode.SharpDevelop.Gui StartExporting(); exportFilesThread = new Thread(new ThreadStart(ExportFilesThread)); + exportFilesThread.Name = "exportFiles"; exportFilesThread.IsBackground = true; exportFilesThread.Start(); } diff --git a/src/Main/Base/Project/Src/Util/OutputReader.cs b/src/Main/Base/Project/Src/Util/OutputReader.cs index 7b97ddf9ae..e874fb15df 100644 --- a/src/Main/Base/Project/Src/Util/OutputReader.cs +++ b/src/Main/Base/Project/Src/Util/OutputReader.cs @@ -36,6 +36,7 @@ namespace ICSharpCode.SharpDevelop.Util public void Start() { thread = new Thread(new ThreadStart(ReadOutput)); + thread.Name = "OutputReader"; thread.Start(); } diff --git a/src/Main/Base/Project/Src/Util/ProcessRunnerException.cs b/src/Main/Base/Project/Src/Util/ProcessRunnerException.cs index 5a5115b82c..bb592b0a51 100644 --- a/src/Main/Base/Project/Src/Util/ProcessRunnerException.cs +++ b/src/Main/Base/Project/Src/Util/ProcessRunnerException.cs @@ -1,11 +1,12 @@ // // // -// +// // $Revision$ // using System; +using System.Runtime.Serialization; namespace ICSharpCode.SharpDevelop.Util { @@ -13,10 +14,22 @@ namespace ICSharpCode.SharpDevelop.Util /// An exception thrown by a /// instance. /// + [Serializable()] public class ProcessRunnerException : ApplicationException { - public ProcessRunnerException(string message) - : base(message) + public ProcessRunnerException() : base() + { + } + + public ProcessRunnerException(string message) : base(message) + { + } + + public ProcessRunnerException(string message, Exception innerException) : base(message, innerException) + { + } + + protected ProcessRunnerException(SerializationInfo info, StreamingContext context) : base(info, context) { } } diff --git a/src/Main/Core/Project/ICSharpCode.Core.csproj b/src/Main/Core/Project/ICSharpCode.Core.csproj index b193b47681..48ee8ec31a 100644 --- a/src/Main/Core/Project/ICSharpCode.Core.csproj +++ b/src/Main/Core/Project/ICSharpCode.Core.csproj @@ -12,10 +12,12 @@ False Library true - Resources\ICSharpCode.Core.snk + ..\..\ICSharpCode.SharpDevelop.snk 83886080 ..\src\Tools\UpdateAssemblyInfo\bin\Debug\UpdateAssemblyInfo.exe Always + False + File true @@ -48,7 +50,6 @@ - diff --git a/src/Main/Core/Project/Resources/ICSharpCode.Core.snk b/src/Main/Core/Project/Resources/ICSharpCode.Core.snk deleted file mode 100644 index 9936f8bf842b9d7c8ebd06ab4355a591a1ecf4e0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50097F)!SKDB@aQCoO$Ssy@&=DT&LM>Mv9$a z@fQTBuxW;bwXDH!$S!Q{}EN`phE0P!LST&6bvk+LY_aKVO># zZylprv7|HGMhpJz=}aF*RJ<~8fKX0|BeMidzvF**u#$kAlXhBV%NURpV}=*LmO=RE z6kA8H0Tt${_pZoC&&i>!&^kWFga@Y_o;AenuHO1>HO0nIeUg((_sx(d?vUvlG|3?? zcs`tDa7w24f|=Hb>OVTn%WOGV?J~xtaFij9B`#TQU_fAkLkR$AIqpC#p7Fi3w$aRN z;!`WBNPMqs7N_B9fz~!Y6;lKG;S|kIRLPP>)VWL+#>p)otFmOK%*VN1{Ez>c?hQKR zb%A-fSZUuZ!VTsLxXr7O*&@+;9tY$;jw#}m?swX(dA345MRigW10zr2N`SO19VDNd z@MFWl$*zbQIh_aGx-X3kk*V0xP{-#}uT // // -// +// // $Revision$ // using System; +using System.Runtime.Serialization; namespace ICSharpCode.Core { /// - /// Description of AddInLoadException. + /// Exception used when loading an AddIn fails. /// + [Serializable] public class AddInLoadException : CoreException { + public AddInLoadException() : base() + { + } + public AddInLoadException(string message) : base(message) { } + + public AddInLoadException(string message, Exception innerException) : base(message, innerException) + { + } + + protected AddInLoadException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } } } diff --git a/src/Main/Core/Project/Src/AddInTree/CoreStartup.cs b/src/Main/Core/Project/Src/AddInTree/CoreStartup.cs index bcffbb0ee8..1db2ced3da 100644 --- a/src/Main/Core/Project/Src/AddInTree/CoreStartup.cs +++ b/src/Main/Core/Project/Src/AddInTree/CoreStartup.cs @@ -76,11 +76,26 @@ namespace ICSharpCode.Core MessageService.ProductName = applicationName; } + /// + /// Find AddIns by searching all .addin files recursively in . + /// public void AddAddInsFromDirectory(string addInDir) { + if (addInDir == null) + throw new ArgumentNullException("addInDir"); addInFiles.AddRange(FileUtility.SearchDirectory(addInDir, "*.addin")); } + /// + /// Add the specified .addin file. + /// + public void AddAddInFile(string addInFile) + { + if (addInFile == null) + throw new ArgumentNullException("addInFile"); + addInFiles.Add(addInFile); + } + public void ConfigureExternalAddIns(string addInConfigurationFile) { AddInManager.ConfigurationFileName = addInConfigurationFile; diff --git a/src/Main/Core/Project/Src/AddInTree/TreePathNotFoundException.cs b/src/Main/Core/Project/Src/AddInTree/TreePathNotFoundException.cs index 19a9933231..0b2c46d3f9 100644 --- a/src/Main/Core/Project/Src/AddInTree/TreePathNotFoundException.cs +++ b/src/Main/Core/Project/Src/AddInTree/TreePathNotFoundException.cs @@ -1,17 +1,19 @@ // // // -// +// // $Revision$ // using System; +using System.Runtime.Serialization; namespace ICSharpCode.Core { /// /// Is thrown when the AddInTree could not find the requested path. /// + [Serializable()] public class TreePathNotFoundException : CoreException { /// @@ -20,5 +22,18 @@ namespace ICSharpCode.Core public TreePathNotFoundException(string path) : base("Treepath not found: " + path) { } + + // Required for Serialization + public TreePathNotFoundException() : base() + { + } + + public TreePathNotFoundException(string message, Exception innerException) : base(message, innerException) + { + } + + protected TreePathNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } } } diff --git a/src/Main/Core/Project/Src/CoreException.cs b/src/Main/Core/Project/Src/CoreException.cs index 3c84bb183f..76658ffd53 100644 --- a/src/Main/Core/Project/Src/CoreException.cs +++ b/src/Main/Core/Project/Src/CoreException.cs @@ -1,7 +1,7 @@ // // // -// +// // $Revision$ // @@ -10,8 +10,11 @@ using System.Runtime.Serialization; namespace ICSharpCode.Core { + /// + /// Base class for exceptions thrown by the SharpDevelop core. + /// [Serializable()] - public class CoreException : ApplicationException + public class CoreException : Exception { public CoreException() : base() { diff --git a/src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs b/src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs index d9611350db..cc1426612a 100644 --- a/src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs +++ b/src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs @@ -45,7 +45,7 @@ namespace ICSharpCode.Core // Call it only when necessary. (see IsEqualFile) readonly static char[] separators = { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar, Path.VolumeSeparatorChar }; - static string applicationRootPath = Environment.CurrentDirectory; + static string applicationRootPath = AppDomain.CurrentDomain.BaseDirectory; const string fileNameRegEx = @"^([a-zA-Z]:)?[^:]+$"; public static string ApplicationRootPath { @@ -165,7 +165,7 @@ namespace ICSharpCode.Core // Optimized for performance: //return Path.GetFullPath(fileName1.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)).ToLower() == Path.GetFullPath(fileName2.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)).ToLower(); - if (fileName1.Length == 0 || fileName2.Length == 0) return false; + if (string.IsNullOrEmpty(fileName1) || string.IsNullOrEmpty(fileName2)) return false; char lastChar; lastChar = fileName1[fileName1.Length - 1]; diff --git a/src/Main/Core/Project/Src/Services/LoggingService/LoggingService.cs b/src/Main/Core/Project/Src/Services/LoggingService/LoggingService.cs index 42bff341e1..b1886a9be0 100644 --- a/src/Main/Core/Project/Src/Services/LoggingService/LoggingService.cs +++ b/src/Main/Core/Project/Src/Services/LoggingService/LoggingService.cs @@ -15,7 +15,7 @@ namespace ICSharpCode.Core { public static class LoggingService { - static readonly ILog log = LogManager.GetLogger(typeof(LoggingService)); + static ILog log = LogManager.GetLogger(typeof(LoggingService)); static LoggingService() { diff --git a/src/Main/Core/Project/Src/Services/MenuService/MenuService.cs b/src/Main/Core/Project/Src/Services/MenuService/MenuService.cs index 4101275a83..09481fbe8f 100644 --- a/src/Main/Core/Project/Src/Services/MenuService/MenuService.cs +++ b/src/Main/Core/Project/Src/Services/MenuService/MenuService.cs @@ -90,7 +90,10 @@ namespace ICSharpCode.Core public static void ShowContextMenu(object owner, string addInTreePath, Control parent, int x, int y) { - CreateContextMenu(owner, addInTreePath).Show(parent, new Point(x, y)); + ContextMenuStrip menu = CreateContextMenu(owner, addInTreePath); + if (menu != null) { + menu.Show(parent, new Point(x, y)); + } } class QuickInsertMenuHandler diff --git a/src/Main/Core/Project/Src/Services/MessageService/MessageService.cs b/src/Main/Core/Project/Src/Services/MessageService/MessageService.cs index d04069406a..1ce9bd62e4 100644 --- a/src/Main/Core/Project/Src/Services/MessageService/MessageService.cs +++ b/src/Main/Core/Project/Src/Services/MessageService/MessageService.cs @@ -49,8 +49,7 @@ namespace ICSharpCode.Core /// /// Gets/Sets the custom error reporter. If this property is null, the default - /// messagebox is used (except for debug builds of ICSharpCode.Core, where the - /// message is only logged to the LoggingService). + /// messagebox is used. /// public static ShowErrorDelegate CustomErrorReporter { get { diff --git a/src/Main/Core/Project/Src/Services/ResourceService/ResourceNotFoundException.cs b/src/Main/Core/Project/Src/Services/ResourceService/ResourceNotFoundException.cs index ee4e7a9e0f..84d86d7d6f 100644 --- a/src/Main/Core/Project/Src/Services/ResourceService/ResourceNotFoundException.cs +++ b/src/Main/Core/Project/Src/Services/ResourceService/ResourceNotFoundException.cs @@ -6,6 +6,7 @@ // using System; +using System.Runtime.Serialization; namespace ICSharpCode.Core { @@ -13,10 +14,23 @@ namespace ICSharpCode.Core /// Is thrown when the GlobalResource manager can't find a requested /// resource. /// + [Serializable()] public class ResourceNotFoundException : CoreException { public ResourceNotFoundException(string resource) : base("Resource not found : " + resource) { } + + public ResourceNotFoundException() : base() + { + } + + public ResourceNotFoundException(string message, Exception innerException) : base(message, innerException) + { + } + + protected ResourceNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } } } diff --git a/src/Main/ICSharpCode.SharpDevelop.Sda/Configuration/AssemblyInfo.cs b/src/Main/ICSharpCode.SharpDevelop.Sda/Configuration/AssemblyInfo.cs new file mode 100644 index 0000000000..76b1a7ebc7 --- /dev/null +++ b/src/Main/ICSharpCode.SharpDevelop.Sda/Configuration/AssemblyInfo.cs @@ -0,0 +1,22 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security.Permissions; +using System.Diagnostics.CodeAnalysis; + +[assembly: CLSCompliant(true)] +[assembly: StringFreezing()] + +[assembly: AssemblyTitle("ICSharpCode.SharpDevelop.Sda")] +[assembly: AssemblyDescription("SharpDevelop for Applications")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: SecurityPermission(SecurityAction.RequestMinimum, Unrestricted=true)] diff --git a/src/Main/ICSharpCode.SharpDevelop.Sda/ICSharpCode.SharpDevelop.Sda.csproj b/src/Main/ICSharpCode.SharpDevelop.Sda/ICSharpCode.SharpDevelop.Sda.csproj new file mode 100644 index 0000000000..a4b7549933 --- /dev/null +++ b/src/Main/ICSharpCode.SharpDevelop.Sda/ICSharpCode.SharpDevelop.Sda.csproj @@ -0,0 +1,85 @@ + + + Library + ICSharpCode.SharpDevelop.Sda + ICSharpCode.SharpDevelop.Sda + Debug + AnyCPU + {80318B5F-A25D-45AB-8A95-EF31D2370A4C} + ..\..\..\bin\ + False + False + False + Auto + 4194304 + AnyCPU + 4096 + 4 + false + ..\..\..\bin\ICSharpCode.SharpDevelop.Sda.xml + True + True + ..\ICSharpCode.SharpDevelop.snk + False + File + -Microsoft.Naming#CA1704;-Microsoft.Performance#CA1822 + + + obj\ + obj\Debug\ + False + DEBUG;TRACE + true + Full + True + + + obj\ + obj\Release\ + True + TRACE + False + None + False + + + + + + + + + + Configuration\GlobalAssemblyInfo.cs + + + + + + Form + + + + + + + + + + {2748AD25-9C63-4E12-877B-4DCE96FBED54} + ICSharpCode.SharpDevelop + False + + + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} + ICSharpCode.Core + False + + + + Always + + + + + \ No newline at end of file diff --git a/src/Main/ICSharpCode.SharpDevelop.Sda/ICSharpCode.SharpDevelop.Sda.dll.config b/src/Main/ICSharpCode.SharpDevelop.Sda/ICSharpCode.SharpDevelop.Sda.dll.config new file mode 100644 index 0000000000..95560552cb --- /dev/null +++ b/src/Main/ICSharpCode.SharpDevelop.Sda/ICSharpCode.SharpDevelop.Sda.dll.config @@ -0,0 +1,72 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Main/ICSharpCode.SharpDevelop.Sda/ICSharpCode.SharpDevelop.Sda.sln b/src/Main/ICSharpCode.SharpDevelop.Sda/ICSharpCode.SharpDevelop.Sda.sln new file mode 100644 index 0000000000..c69efa2f22 --- /dev/null +++ b/src/Main/ICSharpCode.SharpDevelop.Sda/ICSharpCode.SharpDevelop.Sda.sln @@ -0,0 +1,6 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# SharpDevelop 2.1.0.1602 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Sda", "ICSharpCode.SharpDevelop.Sda.csproj", "{80318B5F-A25D-45AB-8A95-EF31D2370A4C}" +EndProject +Global +EndGlobal diff --git a/src/Main/ICSharpCode.SharpDevelop.Sda/Src/CallHelper.cs b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/CallHelper.cs new file mode 100644 index 0000000000..f133e9d002 --- /dev/null +++ b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/CallHelper.cs @@ -0,0 +1,260 @@ +/* + * Created by SharpDevelop. + * User: Daniel Grunwald + * Date: 27.07.2006 + * Time: 20:28 + */ + +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.IO; +using System.Reflection; +using System.Resources; +using System.Threading; + +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Commands; +using ICSharpCode.SharpDevelop.Gui; + +namespace ICSharpCode.SharpDevelop.Sda +{ + internal sealed class CallHelper : MarshalByRefObject + { + private static readonly object[] emptyObjectArray = new object[0]; + + SharpDevelopHost.CallbackHelper callback; + bool useSharpDevelopErrorHandler; + + #region Initialize Core + public void InitSharpDevelopCore(SharpDevelopHost.CallbackHelper callback, StartupSettings properties) + { + LoggingService.Info("InitSharpDevelop..."); + this.callback = callback; + CoreStartup startup = new CoreStartup(properties.ApplicationName); + if (properties.UseSharpDevelopErrorHandler) { + this.useSharpDevelopErrorHandler = true; + ExceptionBox.RegisterExceptionBoxForUnhandledExceptions(); + } + startup.ConfigDirectory = properties.ConfigDirectory; + startup.DataDirectory = properties.DataDirectory; + if (properties.PropertiesName != null) { + startup.PropertiesName = properties.PropertiesName; + } + + // disable RTL: translations for the RTL languages are inactive + RightToLeftConverter.RightToLeftLanguages = new string[0]; + + if (properties.ApplicationRootPath != null) { + FileUtility.ApplicationRootPath = properties.ApplicationRootPath; + } + + startup.StartCoreServices(); + Assembly exe = Assembly.Load("SharpDevelop"); + ResourceService.RegisterNeutralStrings(new ResourceManager("Resources.StringResources", exe)); + ResourceService.RegisterNeutralImages(new ResourceManager("Resources.BitmapResources", exe)); + + MenuCommand.LinkCommandCreator = delegate(string link) { return new LinkCommand(link); }; + StringParser.RegisterStringTagProvider(new SharpDevelopStringTagProvider()); + + LoggingService.Info("Looking for AddIns..."); + foreach (string file in properties.addInFiles) { + startup.AddAddInFile(file); + } + foreach (string dir in properties.addInDirectories) { + startup.AddAddInsFromDirectory(dir); + } + + if (properties.AllowAddInConfigurationAndExternalAddIns) { + startup.ConfigureExternalAddIns(Path.Combine(PropertyService.ConfigDirectory, "AddIns.xml")); + } + if (properties.AllowUserAddIns) { + startup.ConfigureUserAddIns(Path.Combine(PropertyService.ConfigDirectory, "AddInInstallTemp"), + Path.Combine(PropertyService.ConfigDirectory, "AddIns")); + } + + LoggingService.Info("Loading AddInTree..."); + startup.RunInitialization(); + + // Register events to marshal back + Project.ProjectService.StartBuild += delegate { this.callback.StartBuild(); }; + Project.ProjectService.EndBuild += delegate { this.callback.EndBuild(); }; + Project.ProjectService.SolutionLoaded += delegate { this.callback.SolutionLoaded(); }; + Project.ProjectService.SolutionClosed += delegate { this.callback.SolutionClosed(); }; + Project.ProjectService.SolutionConfigurationChanged += delegate { this.callback.SolutionConfigurationChanged(); }; + FileUtility.FileLoaded += delegate(object sender, FileNameEventArgs e) { this.callback.FileLoaded(e.FileName); }; + FileUtility.FileSaved += delegate(object sender, FileNameEventArgs e) { this.callback.FileSaved(e.FileName); }; + + LoggingService.Info("InitSharpDevelop finished"); + } + #endregion + + #region Initialize and run Workbench + public void RunWorkbench(WorkbenchSettings settings) + { + if (settings.RunOnNewThread) { + Thread t = new Thread(RunWorkbenchInternal); + t.SetApartmentState(ApartmentState.STA); + t.Name = "SDmain"; + t.Start(settings); + } else { + RunWorkbenchInternal(settings); + } + } + + [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] + void RunWorkbenchInternal(object settings) + { + WorkbenchSettings wbSettings = (WorkbenchSettings)settings; + + LoggingService.Info("Initializing workbench..."); + WorkbenchSingleton.InitializeWorkbench(); + + // initialize workbench-dependent services: + Project.ProjectService.InitializeService(); + + LoggingService.Info("Starting workbench..."); + Exception exception = null; + // finally start the workbench. + try { + StartWorkbenchCommand wbc = new StartWorkbenchCommand(); + wbc.AllowTipOfTheDay = wbSettings.UseTipOfTheDay; + callback.BeforeRunWorkbench(); + wbc.Run(wbSettings.InitialFileList); + } catch (Exception ex) { + exception = ex; + } finally { + LoggingService.Info("Unloading services..."); + try { + Project.ProjectService.CloseSolution(); + FileService.Unload(); + PropertyService.Save(); + } catch (Exception ex) { + LoggingService.Warn("Exception during unloading", ex); + if (exception != null) { + exception = ex; + } + } + } + LoggingService.Info("Finished running workbench."); + callback.WorkbenchClosed(); + if (exception != null) { + const string errorText = "Unhandled exception terminated the workbench"; + LoggingService.Fatal(exception); + if (useSharpDevelopErrorHandler) { + System.Windows.Forms.Application.Run(new ExceptionBox(exception, errorText, true)); + } else { + throw new RunWorkbenchException(errorText, exception); + } + } + } + #endregion + + delegate T Func(); + delegate T Func(S arg); + + public List OpenDocuments { + get { + List l = new List(); + if (WorkbenchSingleton.InvokeRequired) { + WorkbenchSingleton.SafeThreadCall(new Action>(GetOpenDocuments), l); + } else { + GetOpenDocuments(l); + } + return l; + } + } + void GetOpenDocuments(List l) + { + foreach (IViewContent vc in WorkbenchSingleton.Workbench.ViewContentCollection) { + Document d = Document.FromWindow(vc.WorkbenchWindow); + if (d != null) { + l.Add(d); + } + } + } + + /// + /// Opens the document with the specified file name. + /// + public Document OpenDocument(string fileName) + { + if (WorkbenchSingleton.InvokeRequired) { + return (Document)WorkbenchSingleton.SafeThreadCall(new Func(OpenDocumentInternal), new object[] { fileName }); + } else { + return OpenDocumentInternal(fileName); + } + } + Document OpenDocumentInternal(string fileName) + { + return Document.FromWindow(FileService.OpenFile(fileName)); + } + + public void OpenProject(string fileName) + { + if (WorkbenchSingleton.InvokeRequired) { + WorkbenchSingleton.SafeThreadCall(new Action(OpenProjectInternal), new object[] { fileName }); + } else { + OpenProjectInternal(fileName); + } + } + void OpenProjectInternal(string fileName) + { + Project.ProjectService.LoadSolutionOrProject(fileName); + } + + public bool IsSolutionOrProject(string fileName) + { + return Project.ProjectService.HasProjectLoader(fileName); + } + + public bool CloseWorkbench(bool force) + { + if (WorkbenchSingleton.InvokeRequired) { + return (bool)WorkbenchSingleton.SafeThreadCall(new Func(CloseWorkbenchInternal), new object[] { force }); + } else { + return CloseWorkbenchInternal(force); + } + } + bool CloseWorkbenchInternal(bool force) + { + if (force) { + foreach (IViewContent vc in WorkbenchSingleton.Workbench.ViewContentCollection.ToArray()) { + vc.WorkbenchWindow.CloseWindow(true); + } + } + WorkbenchSingleton.MainForm.Close(); + return WorkbenchSingleton.MainForm.IsDisposed; + } + + public void KillWorkbench() + { + System.Windows.Forms.Application.Exit(); + } + + public bool WorkbenchVisible { + get { + if (WorkbenchSingleton.InvokeRequired) { + return (bool)WorkbenchSingleton.SafeThreadCall(new Func(GetWorkbenchVisibleInternal), emptyObjectArray); + } else { + return GetWorkbenchVisibleInternal(); + } + } + set { + if (WorkbenchSingleton.InvokeRequired) { + WorkbenchSingleton.SafeThreadCall(new Action(SetWorkbenchVisibleInternal), new object[] { value }); + } else { + SetWorkbenchVisibleInternal(value); + } + } + } + bool GetWorkbenchVisibleInternal() + { + return WorkbenchSingleton.MainForm.Visible; + } + void SetWorkbenchVisibleInternal(bool value) + { + WorkbenchSingleton.MainForm.Visible = value; + } + } +} diff --git a/src/Main/ICSharpCode.SharpDevelop.Sda/Src/Document.cs b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/Document.cs new file mode 100644 index 0000000000..99e9fd6907 --- /dev/null +++ b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/Document.cs @@ -0,0 +1,78 @@ +/* + * Created by SharpDevelop. + * User: Daniel Grunwald + * Date: 27.07.2006 + * Time: 21:54 + */ + +using System; +using ICSharpCode.SharpDevelop.Gui; + +namespace ICSharpCode.SharpDevelop.Sda +{ + /// + /// Wraps a file opened in SharpDevelop. + /// + public sealed class Document : MarshalByRefObject + { + internal static Document FromWindow(IWorkbenchWindow window) + { + if (window != null && window.ViewContent is IEditable) { + return new Document(window, ((IEditable)window.ViewContent)); + } else { + return null; + } + } + + IWorkbenchWindow window; + IEditable editable; + + private Document(IWorkbenchWindow window, IEditable editable) + { + this.window = window; + this.editable = editable; + } + + /// + /// Gets the file name assigned to this document. Can be null. + /// + public string FileName { + get { + return window.ViewContent.FileName; + } + } + + /// + /// Gets/Sets the text displayed in the document. + /// + public string Text { + // IEditable implementor is responsible for thread-safety + get { + return editable.Text; + } + set { + editable.Text = value; + } + } + + /// + /// Gets if the document tab has been disposed because the document has been closed. + /// + public bool IsDisposed { + get { + return window.IsDisposed; + } + } + + /// + /// Closes the document. + /// + /// If true, the window is closed without giving the user + /// a change to save changes if there were modifications. + /// true, if the window has been closed + public bool Close(bool force) + { + return window.CloseWindow(force); + } + } +} diff --git a/src/Main/ICSharpCode.SharpDevelop.Sda/Src/EventArgs.cs b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/EventArgs.cs new file mode 100644 index 0000000000..39180f4ee7 --- /dev/null +++ b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/EventArgs.cs @@ -0,0 +1,38 @@ +/* + * Created by SharpDevelop. + * User: Daniel Grunwald + * Date: 27.07.2006 + * Time: 21:05 + */ + +using System; + +namespace ICSharpCode.SharpDevelop.Sda +{ + /// + /// EventArgs for the SharpDevelopHost.FileLoaded + /// and SharpDevelopHost.FileSaved events. + /// + [Serializable] + public class FileEventArgs : EventArgs + { + string fileName; + + /// + /// Gets the file name. + /// + public string FileName { + get { + return fileName; + } + } + + /// + /// Creates a new instance of the FileEventArgs class. + /// + public FileEventArgs(string fileName) + { + this.fileName = fileName; + } + } +} diff --git a/src/Main/StartUp/Project/Dialogs/ExceptionBox.cs b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/ExceptionBox.cs similarity index 78% rename from src/Main/StartUp/Project/Dialogs/ExceptionBox.cs rename to src/Main/ICSharpCode.SharpDevelop.Sda/Src/ExceptionBox.cs index 04dc772cce..1b108f0a5b 100644 --- a/src/Main/StartUp/Project/Dialogs/ExceptionBox.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/ExceptionBox.cs @@ -7,18 +7,22 @@ // project created on 2/6/2003 at 11:10 AM using System; -using System.Windows.Forms; using System.Diagnostics; -using System.Resources; -using System.Reflection; +using System.Diagnostics.CodeAnalysis; using System.Drawing; -using System.Threading; using System.Globalization; +using System.Resources; +using System.Threading; +using System.Windows.Forms; + using ICSharpCode.Core; -namespace ICSharpCode.SharpDevelop +namespace ICSharpCode.SharpDevelop.Sda { - public class ExceptionBox : System.Windows.Forms.Form + /// + /// Form used to display display unhandled errors in SharpDevelop. + /// + public class ExceptionBox : Form { private System.Windows.Forms.TextBox exceptionTextBox; private System.Windows.Forms.CheckBox copyErrorCheckBox; @@ -32,6 +36,60 @@ namespace ICSharpCode.SharpDevelop Exception exceptionThrown; string message; + internal static void RegisterExceptionBoxForUnhandledExceptions() + { + Application.ThreadException += ShowErrorBox; + AppDomain.CurrentDomain.UnhandledException += ShowErrorBox; + MessageService.CustomErrorReporter = ShowErrorBox; + } + + static void ShowErrorBox(object sender, ThreadExceptionEventArgs e) + { + LoggingService.Error("ThreadException caught", e.Exception); + ShowErrorBox(e.Exception, null); + } + + [SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters")] + static void ShowErrorBox(object sender, UnhandledExceptionEventArgs e) + { + Exception ex = e.ExceptionObject as Exception; + LoggingService.Fatal("UnhandledException caught", ex); + if (e.IsTerminating) + LoggingService.Fatal("Runtime is terminating because of unhandled exception."); + ShowErrorBox(ex, "Unhandled exception", e.IsTerminating); + } + + static void ShowErrorBox(Exception exception, string message) + { + ShowErrorBox(exception, message, false); + } + + [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] + static void ShowErrorBox(Exception exception, string message, bool mustTerminate) + { + try { + using (ExceptionBox box = new ExceptionBox(exception, message, mustTerminate)) { + try { + box.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm); + } catch (InvalidOperationException) { + box.ShowDialog(); + } + } + } catch (Exception ex) { + LoggingService.Warn("Error showing ExceptionBox", ex); + MessageBox.Show(exception.ToString(), message, MessageBoxButtons.OK, + MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); + } + } + + /// + /// Creates a new ExceptionBox instance. + /// + /// The exception to display + /// An additional message to display + /// If is true, the + /// continue button is not available. + [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] public ExceptionBox(Exception e, string message, bool mustTerminate) { this.exceptionThrown = e; @@ -51,8 +109,7 @@ namespace ICSharpCode.SharpDevelop exceptionTextBox.Text = getClipboardString(); try { - ResourceManager resources = new ResourceManager("Resources.BitmapResources", typeof(ExceptionBox).Assembly); - this.pictureBox.Image = (Bitmap)resources.GetObject("ErrorReport"); + this.pictureBox.Image = ResourceService.GetBitmap("ErrorReport"); } catch {} } @@ -64,6 +121,7 @@ namespace ICSharpCode.SharpDevelop } } + [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] string getClipboardString() { string str = ""; @@ -114,6 +172,7 @@ namespace ICSharpCode.SharpDevelop Thread th = new Thread((ThreadStart)delegate { ClipboardWrapper.SetText(getClipboardString()); }); + th.Name = "CopyInfoToClipboard"; th.SetApartmentState(ApartmentState.STA); th.Start(); } @@ -155,6 +214,7 @@ namespace ICSharpCode.SharpDevelop */ } + [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] static void StartUrl(string url) { try { @@ -172,11 +232,14 @@ namespace ICSharpCode.SharpDevelop void CloseButtonClick(object sender, EventArgs e) { - if (MessageBox.Show(StringParser.Parse("${res:ICSharpCode.SharpDevelop.ExceptionBox.QuitWarning}"), "SharpDevelop", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { + if (MessageBox.Show(StringParser.Parse("${res:ICSharpCode.SharpDevelop.ExceptionBox.QuitWarning}"), MessageService.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, MessageBoxOptions.DefaultDesktopOnly) + == DialogResult.Yes) + { Application.Exit(); } } + [SuppressMessage("Microsoft.Globalization", "CA1303")] void InitializeComponent() { this.closeButton = new System.Windows.Forms.Button(); diff --git a/src/Main/ICSharpCode.SharpDevelop.Sda/Src/RunWorkbenchException.cs b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/RunWorkbenchException.cs new file mode 100644 index 0000000000..1eaff8ce68 --- /dev/null +++ b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/RunWorkbenchException.cs @@ -0,0 +1,47 @@ +/* + * Created by SharpDevelop. + * User: Daniel Grunwald + * Date: 27.07.2006 + * Time: 22:37 + */ + +using System; +using System.Runtime.Serialization; + +namespace ICSharpCode.SharpDevelop.Sda +{ + /// + /// Exception used when there's an unhandled exception running the workbench. + /// + [Serializable()] + public class RunWorkbenchException : Exception + { + /// + /// Create a new RunWorkbenchException instance. + /// + public RunWorkbenchException() : base() + { + } + + /// + /// Create a new RunWorkbenchException instance. + /// + public RunWorkbenchException(string message) : base(message) + { + } + + /// + /// Create a new RunWorkbenchException instance. + /// + public RunWorkbenchException(string message, Exception innerException) : base(message, innerException) + { + } + + /// + /// Create a new RunWorkbenchException instance. + /// + protected RunWorkbenchException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } + } +} diff --git a/src/Main/ICSharpCode.SharpDevelop.Sda/Src/SharpDevelopHost.cs b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/SharpDevelopHost.cs new file mode 100644 index 0000000000..4fdd4e03ec --- /dev/null +++ b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/SharpDevelopHost.cs @@ -0,0 +1,378 @@ +/* + * Created by SharpDevelop. + * User: Daniel Grunwald + * Date: 26.07.2006 + * Time: 19:20 + */ + +using System; +using System.Collections.ObjectModel; +using System.IO; +using System.Diagnostics.CodeAnalysis; +using System.Reflection; + +namespace ICSharpCode.SharpDevelop.Sda +{ + /// + /// This class can host an instance of SharpDevelop inside another + /// AppDomain. + /// + public sealed class SharpDevelopHost + { + #region CreateDomain + /// + /// Create an AppDomain capable of hosting SharpDevelop. + /// + public static AppDomain CreateDomain() + { + return AppDomain.CreateDomain("SharpDevelop.Sda", null, CreateDomainSetup()); + } + + /// + /// Creates an AppDomainSetup specifying properties for an AppDomain capable of + /// hosting SharpDevelop. + /// + public static AppDomainSetup CreateDomainSetup() + { + AppDomainSetup s = new AppDomainSetup(); + s.ApplicationBase = Path.GetDirectoryName(SdaAssembly.Location); + s.ConfigurationFile = SdaAssembly.Location + ".config"; + s.ApplicationName = "SharpDevelop.Sda"; + return s; + } + #endregion + + #region Static helpers + internal static Assembly SdaAssembly { + get { + return typeof(SharpDevelopHost).Assembly; + } + } + #endregion + + #region SDInitStatus enum + enum SDInitStatus + { + None, + CoreInitialized, + WorkbenchInitialized, + Busy, + AppDomainUnloaded + } + #endregion + + AppDomain appDomain; + CallHelper helper; + SDInitStatus initStatus; + + #region Constructors + /// + /// Create a new AppDomain to host SharpDevelop. + /// + public SharpDevelopHost(StartupSettings startup) + { + if (startup == null) { + throw new ArgumentNullException("startup"); + } + this.appDomain = CreateDomain(); + helper = (CallHelper)appDomain.CreateInstanceAndUnwrap(SdaAssembly.FullName, typeof(CallHelper).FullName); + helper.InitSharpDevelopCore(new CallbackHelper(this), startup); + initStatus = SDInitStatus.CoreInitialized; + } + + /// + /// Host SharpDevelop in the existing AppDomain. + /// + public SharpDevelopHost(AppDomain appDomain, StartupSettings startup) + { + if (appDomain == null) { + throw new ArgumentNullException("appDomain"); + } + if (startup == null) { + throw new ArgumentNullException("startup"); + } + this.appDomain = appDomain; + helper = (CallHelper)appDomain.CreateInstanceAndUnwrap(SdaAssembly.FullName, typeof(CallHelper).FullName); + helper.InitSharpDevelopCore(new CallbackHelper(this), startup); + initStatus = SDInitStatus.CoreInitialized; + } + #endregion + + #region Workbench Initialization and startup + /// + /// Initializes the workbench (create the MainForm instance, construct menu from AddInTree etc.) + /// and runs it using the supplied settings. + /// This starts a new message loop for the workbench. By default the message loop + /// is created on a new thread, but you can change the settings so that + /// it is created on the thread calling RunWorkbench. + /// In that case, RunWorkbench will block until SharpDevelop is shut down! + /// + public void RunWorkbench(WorkbenchSettings settings) + { + if (settings == null) { + throw new ArgumentNullException("settings"); + } + if (initStatus == SDInitStatus.CoreInitialized) { + initStatus = SDInitStatus.Busy; + helper.RunWorkbench(settings); + if (settings.RunOnNewThread) { + initStatus = SDInitStatus.WorkbenchInitialized; + } + } else { + throw new InvalidOperationException(); + } + } + #endregion + + #region Application control + /// + /// Gets the list of currently opened documents. + /// + public ReadOnlyCollection OpenDocuments { + get { + if (initStatus != SDInitStatus.WorkbenchInitialized) { + return new ReadOnlyCollection(new Document[0]); + } + return new ReadOnlyCollection(helper.OpenDocuments); + } + } + + /// + /// Opens the document with the specified file name. + /// Requires that the workbench is running. + /// + public Document OpenDocument(string fileName) + { + if (initStatus != SDInitStatus.WorkbenchInitialized) { + throw new InvalidOperationException(); + } + return helper.OpenDocument(fileName); + } + + /// + /// Opens the project or solution with the specified file name. + /// Requires that the workbench is running. + /// + public void OpenProject(string fileName) + { + if (initStatus != SDInitStatus.WorkbenchInitialized) { + throw new InvalidOperationException(); + } + helper.OpenProject(fileName); + } + + /// + /// Gets if the specified file is a project or solution file. + /// + public bool IsSolutionOrProject(string fileName) + { + return helper.IsSolutionOrProject(fileName); + } + + /// + /// Gets/Sets whether the workbench is visible. + /// Requires that the workbench is running. + /// + public bool WorkbenchVisible { + get { + if (initStatus != SDInitStatus.WorkbenchInitialized) { + return false; + } else { + return helper.WorkbenchVisible; + } + } + set { + if (initStatus != SDInitStatus.WorkbenchInitialized) { + throw new InvalidOperationException(); + } + helper.WorkbenchVisible = value; + } + } + + /// + /// Closes and unloads the workbench. The user is asked to save his work + /// and can abort closing. + /// Requires that the workbench is running. + /// + /// When force is used (=true), unsaved changes to documents + /// are lost, but SharpDevelop still terminates correctly and saves changed + /// settings. + /// True when the workbench was closed. + public bool CloseWorkbench(bool force) + { + if (initStatus == SDInitStatus.CoreInitialized) { + // Workbench not loaded/already closed: do nothing + return true; + } + if (initStatus != SDInitStatus.WorkbenchInitialized) { + throw new InvalidOperationException(); + } + return helper.CloseWorkbench(force); + } + + /// + /// Unload the SharpDevelop AppDomain. This will force SharpDevelop to close + /// without saving open files or changed settings. + /// Call CloseWorkbench before UnloadDomain to prompt the user to save documents and settings. + /// + public void UnloadDomain() + { + if (initStatus != SDInitStatus.AppDomainUnloaded) { + if (initStatus == SDInitStatus.WorkbenchInitialized) { + helper.KillWorkbench(); + } + AppDomain.Unload(appDomain); + initStatus = SDInitStatus.AppDomainUnloaded; + } + } + #endregion + + #region Callback Events + System.ComponentModel.ISynchronizeInvoke invokeTarget; + + /// + /// Gets/Sets an object to use to synchronize all events with a thread. + /// Use null (default) to handle all events on the thread they were + /// raised on. + /// + public System.ComponentModel.ISynchronizeInvoke InvokeTarget { + get { + return invokeTarget; + } + set { + invokeTarget = value; + } + } + + /// + /// Event before the workbench has been unloaded. + /// + [SuppressMessage("Microsoft.Naming", "CA1713:EventsShouldNotHaveBeforeOrAfterPrefix")] + public event EventHandler BeforeRunWorkbench; + + /// + /// Event after the workbench has been unloaded. Occurs on the thread + /// + public event EventHandler WorkbenchClosed; + + /// + /// Event when SharpDevelop starts to compile a project or solution. + /// + public event EventHandler StartBuild; + + /// + /// Event when SharpDevelop finishes to compile a project or solution. + /// + public event EventHandler EndBuild; + + /// + /// Event when a solution was loaded inside SharpDevelop. + /// + public event EventHandler SolutionLoaded; + + /// + /// Event when the current solution was closed. + /// + public event EventHandler SolutionClosed; + + /// + /// Event when the active solution configuration was changed. + /// + public event EventHandler SolutionConfigurationChanged; + + /// + /// Event when a file was loaded inside SharpDevelop. + /// + public event EventHandler FileLoaded; + + /// + /// Event when a file was saved inside SharpDevelop. + /// + public event EventHandler FileSaved; + + internal sealed class CallbackHelper : MarshalByRefObject + { + private static readonly object[] emptyObjectArray = new object[0]; + + readonly SharpDevelopHost host; + + public CallbackHelper(SharpDevelopHost host) + { + this.host = host; + } + + private bool InvokeRequired { + get { + return host.invokeTarget != null && host.invokeTarget.InvokeRequired; + } + } + + private void Invoke(System.Windows.Forms.MethodInvoker method) + { + host.invokeTarget.BeginInvoke(method, emptyObjectArray); + } + + private void Invoke(Action method, string argument) + { + host.invokeTarget.BeginInvoke(method, new object[] { argument }); + } + + internal void BeforeRunWorkbench() + { + if (InvokeRequired) { Invoke(BeforeRunWorkbench); return; } + host.initStatus = SDInitStatus.WorkbenchInitialized; + if (host.BeforeRunWorkbench != null) host.BeforeRunWorkbench(host, EventArgs.Empty); + } + + internal void WorkbenchClosed() + { + if (InvokeRequired) { Invoke(WorkbenchClosed); return; } + host.initStatus = SDInitStatus.CoreInitialized; + if (host.WorkbenchClosed != null) host.WorkbenchClosed(host, EventArgs.Empty); + } + + internal void StartBuild() + { + if (InvokeRequired) { Invoke(StartBuild); return; } + if (host.StartBuild != null) host.StartBuild(host, EventArgs.Empty); + } + + internal void EndBuild() + { + if (InvokeRequired) { Invoke(EndBuild); return; } + if (host.EndBuild != null) host.EndBuild(host, EventArgs.Empty); + } + + internal void SolutionLoaded() + { + if (InvokeRequired) { Invoke(SolutionLoaded); return; } + if (host.SolutionLoaded != null) host.SolutionLoaded(host, EventArgs.Empty); + } + + internal void SolutionClosed() + { + if (InvokeRequired) { Invoke(SolutionClosed); return; } + if (host.SolutionClosed != null) host.SolutionClosed(host, EventArgs.Empty); + } + + internal void SolutionConfigurationChanged() + { + if (InvokeRequired) { Invoke(SolutionConfigurationChanged); return; } + if (host.SolutionConfigurationChanged != null) host.SolutionConfigurationChanged(host, EventArgs.Empty); + } + + internal void FileLoaded(string fileName) + { + if (InvokeRequired) { Invoke(FileLoaded, fileName); return; } + if (host.FileLoaded != null) host.FileLoaded(host, new FileEventArgs(fileName)); + } + + internal void FileSaved(string fileName) + { + if (InvokeRequired) { Invoke(FileSaved, fileName); return; } + if (host.FileSaved != null) host.FileSaved(host, new FileEventArgs(fileName)); + } + } + #endregion + } +} diff --git a/src/Main/ICSharpCode.SharpDevelop.Sda/Src/StartupSettings.cs b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/StartupSettings.cs new file mode 100644 index 0000000000..b2974c32e7 --- /dev/null +++ b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/StartupSettings.cs @@ -0,0 +1,159 @@ +/* + * Created by SharpDevelop. + * User: Daniel Grunwald + * Date: 26.07.2006 + * Time: 19:45 + */ + +using System; +using System.Collections.Generic; + +namespace ICSharpCode.SharpDevelop.Sda +{ + /// + /// This class contains properties you can use to control how SharpDevelop is launched. + /// + [Serializable] + public sealed class StartupSettings + { + bool useSharpDevelopErrorHandler = true; + string applicationName = "SharpDevelop"; + string applicationRootPath; + bool allowAddInConfigurationAndExternalAddIns = true; + bool allowUserAddIns; + string propertiesName; + string configDirectory; + string dataDirectory; + internal List addInDirectories = new List(); + internal List addInFiles = new List(); + + /// + /// Gets/Sets whether the SharpDevelop exception box should be used for + /// unhandled exceptions. The default is true. + /// + public bool UseSharpDevelopErrorHandler { + get { + return useSharpDevelopErrorHandler; + } + set { + useSharpDevelopErrorHandler = value; + } + } + + /// + /// Use the file \AddIns.xml to maintain + /// a list of deactivated AddIns and list of AddIns to load from + /// external locations. + /// The default value is true. + /// + public bool AllowAddInConfigurationAndExternalAddIns { + get { + return allowAddInConfigurationAndExternalAddIns; + } + set { + allowAddInConfigurationAndExternalAddIns = value; + } + } + + /// + /// Allow user AddIns stored in the "application data" directory. + /// The default is false. + /// + public bool AllowUserAddIns { + get { + return allowUserAddIns; + } + set { + allowUserAddIns = value; + } + } + + /// + /// Gets/Sets the application name used by the MessageService and some + /// SharpDevelop windows. The default is "SharpDevelop". + /// + public string ApplicationName { + get { + return applicationName; + } + set { + if (value == null) + throw new ArgumentNullException("value"); + applicationName = value; + } + } + + /// + /// Gets/Sets the application root path to use. + /// Use null (default) to use the base directory of the SharpDevelop AppDomain. + /// + public string ApplicationRootPath { + get { + return applicationRootPath; + } + set { + applicationRootPath = value; + } + } + + /// + /// Gets/Sets the directory used to store SharpDevelop properties, + /// settings and user AddIns. + /// Use null (default) to use "ApplicationData\ApplicationName" + /// + public string ConfigDirectory { + get { + return configDirectory; + } + set { + configDirectory = value; + } + } + + /// + /// Sets the data directory used to load resources. + /// Use null (default) to use the default path "ApplicationRootPath\data". + /// + public string DataDirectory { + get { + return dataDirectory; + } + set { + dataDirectory = value; + } + } + + /// + /// Sets the name used for the properties file (without path or extension). + /// Use null (default) to use the default name. + /// + public string PropertiesName { + get { + return propertiesName; + } + set { + propertiesName = value; + } + } + + /// + /// Find AddIns by searching all .addin files recursively in . + /// + public void AddAddInsFromDirectory(string addInDir) + { + if (addInDir == null) + throw new ArgumentNullException("addInDir"); + addInDirectories.Add(addInDir); + } + + /// + /// Add the specified .addin file. + /// + public void AddAddInFile(string addInFile) + { + if (addInFile == null) + throw new ArgumentNullException("addInFile"); + addInFiles.Add(addInFile); + } + } +} diff --git a/src/Main/ICSharpCode.SharpDevelop.Sda/Src/WorkbenchSettings.cs b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/WorkbenchSettings.cs new file mode 100644 index 0000000000..243adee5d6 --- /dev/null +++ b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/WorkbenchSettings.cs @@ -0,0 +1,59 @@ +/* + * Created by SharpDevelop. + * User: Daniel Grunwald + * Date: 27.07.2006 + * Time: 21:17 + */ + +using System; +using System.Collections.ObjectModel; + +namespace ICSharpCode.SharpDevelop.Sda +{ + /// + /// This class contains properties to control how the SharpDevelop + /// workbench is being run. + /// + [Serializable] + public sealed class WorkbenchSettings + { + bool runOnNewThread = true; + bool useTipOfTheDay; + Collection fileList = new Collection(); + + /// + /// Gets/Sets whether to create a new thread to run the workbench on. + /// The default value is true. + /// + public bool RunOnNewThread { + get { + return runOnNewThread; + } + set { + runOnNewThread = value; + } + } + + /// + /// Gets/Sets whether the tip of the day is supported. + /// The default is false. + /// + public bool UseTipOfTheDay { + get { + return useTipOfTheDay; + } + set { + useTipOfTheDay = value; + } + } + + /// + /// Put files to open at workbench startup into this collection. + /// + public Collection InitialFileList { + get { + return fileList; + } + } + } +} diff --git a/src/Main/Base/Project/Resources/ICSharpCode.SharpDevelop.snk b/src/Main/ICSharpCode.SharpDevelop.snk similarity index 100% rename from src/Main/Base/Project/Resources/ICSharpCode.SharpDevelop.snk rename to src/Main/ICSharpCode.SharpDevelop.snk diff --git a/src/Main/StartUp/Project/Resources/StartUp.snk b/src/Main/StartUp/Project/Resources/StartUp.snk deleted file mode 100644 index 9936f8bf842b9d7c8ebd06ab4355a591a1ecf4e0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50097F)!SKDB@aQCoO$Ssy@&=DT&LM>Mv9$a z@fQTBuxW;bwXDH!$S!Q{}EN`phE0P!LST&6bvk+LY_aKVO># zZylprv7|HGMhpJz=}aF*RJ<~8fKX0|BeMidzvF**u#$kAlXhBV%NURpV}=*LmO=RE z6kA8H0Tt${_pZoC&&i>!&^kWFga@Y_o;AenuHO1>HO0nIeUg((_sx(d?vUvlG|3?? zcs`tDa7w24f|=Hb>OVTn%WOGV?J~xtaFij9B`#TQU_fAkLkR$AIqpC#p7Fi3w$aRN z;!`WBNPMqs7N_B9fz~!Y6;lKG;S|kIRLPP>)VWL+#>p)otFmOK%*VN1{Ez>c?hQKR zb%A-fSZUuZ!VTsLxXr7O*&@+;9tY$;jw#}m?swX(dA345MRigW10zr2N`SO19VDNd z@MFWl$*zbQIh_aGx-X3kk*V0xP{-#}uT /// Starts the core of SharpDevelop. /// @@ -143,46 +106,20 @@ namespace ICSharpCode.SharpDevelop { LoggingService.Info("Starting SharpDevelop..."); try { + StartupSettings startup = new StartupSettings(); #if DEBUG - if (!Debugger.IsAttached) { - Application.ThreadException += ShowErrorBox; - AppDomain.CurrentDomain.UnhandledException += ShowErrorBox; - } - #else - Application.ThreadException += ShowErrorBox; - AppDomain.CurrentDomain.UnhandledException += ShowErrorBox; - MessageService.CustomErrorReporter = ShowErrorBox; + startup.UseSharpDevelopErrorHandler = !Debugger.IsAttached; #endif - // disable RTL: translations for the RTL languages are inactive - RightToLeftConverter.RightToLeftLanguages = new string[0]; - Assembly exe = typeof(SharpDevelopMain).Assembly; + startup.ApplicationRootPath = Path.Combine(Path.GetDirectoryName(exe.Location), ".."); + startup.AllowUserAddIns = true; + startup.ConfigDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), + ".ICSharpCode/SharpDevelop2.1"); - FileUtility.ApplicationRootPath = Path.Combine(Path.GetDirectoryName(exe.Location), ".."); - - CoreStartup c = new CoreStartup("SharpDevelop"); - c.ConfigDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), - ".ICSharpCode/SharpDevelop2.1"); - LoggingService.Info("Starting core services..."); - c.StartCoreServices(); + startup.AddAddInsFromDirectory(Path.Combine(startup.ApplicationRootPath, "AddIns")); - ResourceService.RegisterNeutralStrings(new ResourceManager("Resources.StringResources", exe)); - ResourceService.RegisterNeutralImages(new ResourceManager("Resources.BitmapResources", exe)); - - RegisterDoozers(); - - StringParser.RegisterStringTagProvider(new SharpDevelopStringTagProvider()); - - LoggingService.Info("Looking for AddIns..."); - c.AddAddInsFromDirectory(Path.Combine(FileUtility.ApplicationRootPath, "AddIns")); - - c.ConfigureExternalAddIns(Path.Combine(PropertyService.ConfigDirectory, "AddIns.xml")); - c.ConfigureUserAddIns(Path.Combine(PropertyService.ConfigDirectory, "AddInInstallTemp"), - Path.Combine(PropertyService.ConfigDirectory, "AddIns")); - - LoggingService.Info("Loading AddInTree..."); - c.RunInitialization(); + SharpDevelopHost host = new SharpDevelopHost(AppDomain.CurrentDomain, startup); string[] fileList = SplashScreenForm.GetRequestedFileList(); if (fileList.Length > 0) { @@ -192,37 +129,16 @@ namespace ICSharpCode.SharpDevelop } } - LoggingService.Info("Initializing workbench..."); - // .NET base autostarts - // taken out of the add-in tree for performance reasons (every tick in startup counts) - WorkbenchSingleton.InitializeWorkbench(); - - // initialize workbench-dependent services: - ProjectService.InitializeService(); - - if (SplashScreenForm.SplashScreen != null) { - SplashScreenForm.SplashScreen.Dispose(); - } - - bool exception = true; - // finally start the workbench. - try { - LoggingService.Info("Starting workbench..."); - new StartWorkbenchCommand().Run(fileList); - exception = false; - } finally { - LoggingService.Info("Unloading services..."); - try { - ProjectService.CloseSolution(); - FileService.Unload(); - PropertyService.Save(); - } catch (Exception ex) { - if (exception) - LoggingService.Warn("Exception during unloading after exception", ex); - else - MessageService.ShowError(ex); + host.BeforeRunWorkbench += delegate { + if (SplashScreenForm.SplashScreen != null) { + SplashScreenForm.SplashScreen.BeginInvoke(new MethodInvoker(SplashScreenForm.SplashScreen.Dispose)); } - } + }; + + WorkbenchSettings workbenchSettings = new WorkbenchSettings(); + workbenchSettings.RunOnNewThread = false; + workbenchSettings.UseTipOfTheDay = true; + host.RunWorkbench(workbenchSettings); } finally { LoggingService.Info("Leaving RunApplication()"); } @@ -242,40 +158,5 @@ namespace ICSharpCode.SharpDevelop return false; } } - - static void RegisterDoozers() - { - AddInTree.ConditionEvaluators.Add("ActiveContentExtension", new ActiveContentExtensionConditionEvaluator()); - AddInTree.ConditionEvaluators.Add("ActiveViewContentUntitled", new ActiveViewContentUntitledConditionEvaluator()); - AddInTree.ConditionEvaluators.Add("ActiveWindowState", new ActiveWindowStateConditionEvaluator()); - AddInTree.ConditionEvaluators.Add("SolutionOpen", new SolutionOpenConditionEvaluator()); - AddInTree.ConditionEvaluators.Add("DebuggerSupports", new DebuggerSupportsConditionEvaluator()); - AddInTree.ConditionEvaluators.Add("IsProcessRunning", new IsProcessRunningConditionEvaluator()); - AddInTree.ConditionEvaluators.Add("OpenWindowState", new OpenWindowStateConditionEvaluator()); - AddInTree.ConditionEvaluators.Add("WindowActive", new WindowActiveConditionEvaluator()); - AddInTree.ConditionEvaluators.Add("WindowOpen", new WindowOpenConditionEvaluator()); - AddInTree.ConditionEvaluators.Add("ProjectActive", new ProjectActiveConditionEvaluator()); - AddInTree.ConditionEvaluators.Add("TextContent", new ICSharpCode.SharpDevelop.DefaultEditor.Conditions.TextContentConditionEvaluator()); - AddInTree.ConditionEvaluators.Add("BrowserLocation", new ICSharpCode.SharpDevelop.BrowserDisplayBinding.BrowserLocationConditionEvaluator()); - AddInTree.ConditionEvaluators.Add("RefactoringProviderSupports", new Refactoring.RefactoringProviderSupportsConditionEvaluator()); - // TODO: is there a way to automate ConditionEvaluator registration via reflection? or to specify it in the .addin files? - AddInTree.ConditionEvaluators.Add("CanNavigateBack", new CanNavigateBackConditionEvaluator()); - AddInTree.ConditionEvaluators.Add("CanNavigateForward", new CanNavigateForwardConditionEvaluator()); - - AddInTree.Doozers.Add("DialogPanel", new DialogPanelDoozer()); - AddInTree.Doozers.Add("DisplayBinding", new DisplayBindingDoozer()); - AddInTree.Doozers.Add("Pad", new PadDoozer()); - AddInTree.Doozers.Add("LanguageBinding", new LanguageBindingDoozer()); - AddInTree.Doozers.Add("Parser", new ParserDoozer()); - AddInTree.Doozers.Add("EditAction", new ICSharpCode.SharpDevelop.DefaultEditor.Codons.EditActionDoozer()); - AddInTree.Doozers.Add("SyntaxMode", new ICSharpCode.SharpDevelop.DefaultEditor.Codons.SyntaxModeDoozer()); - AddInTree.Doozers.Add("BrowserSchemeExtension", new ICSharpCode.SharpDevelop.BrowserDisplayBinding.SchemeExtensionDoozer()); - AddInTree.Doozers.Add("CodeCompletionBinding", new ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor.CodeCompletionBindingDoozer()); - AddInTree.Doozers.Add("Debugger", new DebuggerDoozer()); - AddInTree.Doozers.Add("Directory", new DirectoryDoozer()); - AddInTree.Doozers.Add("TaskBoundAdditionalLogger", new TaskBoundAdditionalLoggerDoozer()); - - MenuCommand.LinkCommandCreator = delegate(string link) { return new LinkCommand(link); }; - } } } diff --git a/src/Main/StartUp/Project/StartUp.csproj b/src/Main/StartUp/Project/StartUp.csproj index fa2a68b51e..b948b55601 100644 --- a/src/Main/StartUp/Project/StartUp.csproj +++ b/src/Main/StartUp/Project/StartUp.csproj @@ -10,7 +10,7 @@ False False true - Resources\StartUp.snk + ..\..\ICSharpCode.SharpDevelop.snk .\Resources\SharpDevelop.ico Always 4194304 @@ -20,6 +20,8 @@ AnyCPU 4096 false + False + File Full @@ -42,18 +44,13 @@ - Form - - Form - - Always @@ -81,6 +78,10 @@ Configuration\GlobalAssemblyInfo.template + + {80318B5F-A25D-45AB-8A95-EF31D2370A4C} + ICSharpCode.SharpDevelop.Sda + \ No newline at end of file diff --git a/src/SharpDevelop.sln b/src/SharpDevelop.sln index 44a6774d5c..a291d4778d 100644 --- a/src/SharpDevelop.sln +++ b/src/SharpDevelop.sln @@ -120,6 +120,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Main", "Main", "{5A3EBEBA-0 ProjectSection(SolutionItems) = postProject EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Sda", "Main\ICSharpCode.SharpDevelop.Sda\ICSharpCode.SharpDevelop.Sda.csproj", "{80318B5F-A25D-45AB-8A95-EF31D2370A4C}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop", "Main\Base\Project\ICSharpCode.SharpDevelop.csproj", "{2748AD25-9C63-4E12-877B-4DCE96FBED54}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core", "Main\Core\Project\ICSharpCode.Core.csproj", "{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}" @@ -326,6 +328,10 @@ Global {413A467D-7EA1-4C40-B10B-D6832B94DD6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {413A467D-7EA1-4C40-B10B-D6832B94DD6E}.Release|Any CPU.Build.0 = Release|Any CPU {413A467D-7EA1-4C40-B10B-D6832B94DD6E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {80318B5F-A25D-45AB-8A95-EF31D2370A4C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {80318B5F-A25D-45AB-8A95-EF31D2370A4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {80318B5F-A25D-45AB-8A95-EF31D2370A4C}.Release|Any CPU.Build.0 = Release|Any CPU + {80318B5F-A25D-45AB-8A95-EF31D2370A4C}.Release|Any CPU.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {CE5B42B7-6E8C-4385-9E97-F4023FC16BF2} = {14A277EE-7DF1-4529-B639-7D1EF334C1C5} @@ -379,5 +385,6 @@ Global {1152B71B-3C05-4598-B20D-823B5D40559E} = {5A3EBEBA-0560-41C1-966B-23F7D03A5486} {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {5A3EBEBA-0560-41C1-966B-23F7D03A5486} {2748AD25-9C63-4E12-877B-4DCE96FBED54} = {5A3EBEBA-0560-41C1-966B-23F7D03A5486} + {80318B5F-A25D-45AB-8A95-EF31D2370A4C} = {5A3EBEBA-0560-41C1-966B-23F7D03A5486} EndGlobalSection EndGlobal