diff --git a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/DesignerGenerator/CodeDOMGenerator.cs b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/DesignerGenerator/CodeDOMGenerator.cs index 7ae1556973..889eee2b72 100644 --- a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/DesignerGenerator/CodeDOMGenerator.cs +++ b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/DesignerGenerator/CodeDOMGenerator.cs @@ -47,6 +47,7 @@ namespace ICSharpCode.FormDesigner public void ConvertContentDefinition(TextWriter writer) { + LoggingService.Info("Start CodeCOMGenerator.ConvertContentDefinition"); DesignerSerializationManager serializationManager = (DesignerSerializationManager)host.GetService(typeof(IDesignerSerializationManager)); IDisposable session = serializationManager.CreateSession(); DesignerResourceService designerResourceService = (DesignerResourceService)host.GetService(typeof(System.ComponentModel.Design.IResourceService)); @@ -67,7 +68,6 @@ namespace ICSharpCode.FormDesigner options.IndentString = "\t\t\t"; // ICSharpCode.NRefactory.Parser.CodeDOMVerboseOutputGenerator outputGenerator = new ICSharpCode.NRefactory.Parser.CodeDOMVerboseOutputGenerator(); -// Console.WriteLine("<<<<START."); foreach (CodeStatement statement in statements) { if (!(statement is CodeVariableDeclarationStatement)) { @@ -86,7 +86,7 @@ namespace ICSharpCode.FormDesigner } designerResourceService.SerializationEnded(true); session.Dispose(); -// Console.WriteLine("<<<<END."); + LoggingService.Info("End CodeCOMGenerator.ConvertContentDefinition"); } } } diff --git a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/DesignerGenerator/XmlDesignerGenerator.cs b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/DesignerGenerator/XmlDesignerGenerator.cs index 713dd831e2..514ed70df7 100644 --- a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/DesignerGenerator/XmlDesignerGenerator.cs +++ b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/DesignerGenerator/XmlDesignerGenerator.cs @@ -126,7 +126,7 @@ namespace ICSharpCode.FormDesigner try { propertyValue = pd.GetValue(o); } catch (Exception e) { - Console.WriteLine(e); + ICSharpCode.Core.LoggingService.Warn(e); continue; } diff --git a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/DesignerLoader/NRefactoryDesignerLoader.cs b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/DesignerLoader/NRefactoryDesignerLoader.cs index a5700eb4cf..8246c5d7b7 100644 --- a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/DesignerLoader/NRefactoryDesignerLoader.cs +++ b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/DesignerLoader/NRefactoryDesignerLoader.cs @@ -78,7 +78,6 @@ namespace ICSharpCode.FormDesigner protected override ITypeResolutionService TypeResolutionService { get { - Console.WriteLine("type resolution service"); return typeResolutionService; } } @@ -109,7 +108,7 @@ namespace ICSharpCode.FormDesigner protected override CodeCompileUnit Parse() { - Console.Write("ParseCompileUnit"); + LoggingService.Debug("NRefactoryDesignerLoader.Parse()"); isReloadNeeded = false; ICSharpCode.NRefactory.Parser.IParser p = ICSharpCode.NRefactory.Parser.ParserFactory.CreateParser(language, new StringReader(TextContent)); p.Parse(); diff --git a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/DesignerLoader/XmlDesignerLoader.cs b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/DesignerLoader/XmlDesignerLoader.cs index 0a44abc24d..967fd4e97c 100644 --- a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/DesignerLoader/XmlDesignerLoader.cs +++ b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/DesignerLoader/XmlDesignerLoader.cs @@ -79,7 +79,6 @@ namespace ICSharpCode.FormDesigner object IObjectCreator.CreateObject(string name, XmlElement el) { - Console.WriteLine("Name:" + name); string componentName = null; if (el != null) { diff --git a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/FormDesignerViewContent.cs b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/FormDesignerViewContent.cs index 6870c78ffd..ae2ae4ab5e 100644 --- a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/FormDesignerViewContent.cs +++ b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/FormDesignerViewContent.cs @@ -133,6 +133,8 @@ namespace ICSharpCode.FormDesigner { if (isInitialized) return; isInitialized = true; + LoggingService.Info("Form Designer: BEGIN INITIALIZE"); + DefaultServiceContainer serviceContainer = new DefaultServiceContainer(); serviceContainer.AddService(typeof(System.Windows.Forms.Design.IUIService), new UIService()); serviceContainer.AddService(typeof(System.Drawing.Design.IToolboxService), ToolboxProvider.ToolboxService); @@ -166,7 +168,7 @@ namespace ICSharpCode.FormDesigner designSurface.Flush(); generator.Attach(this); - Console.WriteLine("!!!!!! END LOAD"); + LoggingService.Info("Form Designer: END INITIALIZE"); } PropertyContainer propertyContainer = new PropertyContainer(); diff --git a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/FormKeyHandler.cs b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/FormKeyHandler.cs index 8a88683324..6eec4badce 100644 --- a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/FormKeyHandler.cs +++ b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/FormKeyHandler.cs @@ -118,7 +118,7 @@ namespace ICSharpCode.FormDesigner // formDesigner.SetNextTabIndex(c.PointToScreen(p)); // } // } catch (Exception e) { -// Console.WriteLine(e); +// MessageService.ShowError(e); // } // } // return false; diff --git a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Gui/ComponentLibraryLoader.cs b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Gui/ComponentLibraryLoader.cs index 3f1b1114fe..db3068c44b 100644 --- a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Gui/ComponentLibraryLoader.cs +++ b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Gui/ComponentLibraryLoader.cs @@ -274,7 +274,7 @@ namespace ICSharpCode.FormDesigner.Gui } } } catch (Exception e) { - Console.WriteLine(e); + ICSharpCode.Core.LoggingService.Warn("ComponentLibraryLoader.LoadToolComponentLibrary: " + e.Message); return false; } return true; @@ -304,7 +304,7 @@ namespace ICSharpCode.FormDesigner.Gui b.MakeTransparent(); } } catch (Exception e) { - Console.WriteLine(e); + ICSharpCode.Core.LoggingService.Warn("ComponentLibraryLoader.GetIcon: " + e.Message); } } diff --git a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Gui/CustomComponentsSideTab.cs b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Gui/CustomComponentsSideTab.cs index 5dd7316a9e..6716001e1a 100644 --- a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Gui/CustomComponentsSideTab.cs +++ b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Gui/CustomComponentsSideTab.cs @@ -67,6 +67,7 @@ namespace ICSharpCode.FormDesigner.Gui Assembly MyResolveEventHandler(object sender, ResolveEventArgs args) { + LoggingService.Debug("Form Designer: MyResolve: " + args.Name); string file = args.Name; int idx = file.IndexOf(','); if (idx >= 0) { @@ -74,13 +75,16 @@ namespace ICSharpCode.FormDesigner.Gui } try { if (File.Exists(loadingPath + file + ".exe")) { + LoggingService.Debug("Form Designer: MyResolve: Load bytes from exe"); return Assembly.Load(GetBytes(loadingPath + file + ".exe")); } if (File.Exists(loadingPath + file + ".dll")) { + LoggingService.Debug("Form Designer: MyResolve: Load bytes from dll"); return Assembly.Load(GetBytes(loadingPath + file + ".dll")); } + LoggingService.Info("Form Designer: MyResolve: did not find " + args.Name); } catch (Exception ex) { - Console.WriteLine("Can't load assembly : " + ex.ToString()); + LoggingService.Warn("Form Designer: MyResolve: Can't load assembly", ex); } return null; } @@ -173,7 +177,7 @@ namespace ICSharpCode.FormDesigner.Gui } } } catch (Exception e) { - Console.WriteLine("Exception : " + e); + LoggingService.Warn("Form Designer: ScanProjectAssemblies", e); } finally { AppDomain.CurrentDomain.AssemblyResolve -= new ResolveEventHandler(MyResolveEventHandler); } diff --git a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Gui/SideTabDesigner.cs b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Gui/SideTabDesigner.cs index 6d60c31bb2..6f7831a604 100644 --- a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Gui/SideTabDesigner.cs +++ b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Gui/SideTabDesigner.cs @@ -136,7 +136,7 @@ namespace ICSharpCode.FormDesigner.Gui stream.Close(); } } catch (Exception e) { - Console.WriteLine(e); + LoggingService.Warn("Form Designer: GetToolboxItemsFromAssembly", e); } } Module[] ms = assembly.GetModules(false); @@ -176,7 +176,7 @@ namespace ICSharpCode.FormDesigner.Gui try { item.Bitmap = (Bitmap)images[imageName]; } catch (Exception ex) { - Console.WriteLine("Exception converting bitmap : " + images[imageName] + " : " + ex.ToString()); + MessageService.ShowError(ex, "Exception converting bitmap : " + images[imageName] + " : "); } } toolBoxItems.Add(item); diff --git a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Services/DefaultServiceContainer.cs b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Services/DefaultServiceContainer.cs index cec7e4ef97..048208d7c1 100644 --- a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Services/DefaultServiceContainer.cs +++ b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Services/DefaultServiceContainer.cs @@ -13,6 +13,7 @@ using System.Drawing; using System.ComponentModel; using System.ComponentModel.Design; using System.Windows.Forms.Design; +using ICSharpCode.Core; namespace ICSharpCode.FormDesigner.Services { @@ -99,10 +100,9 @@ namespace ICSharpCode.FormDesigner.Services public object GetService(System.Type serviceType) { if (IsServiceMissing(serviceType)) { - Console.WriteLine("request missing service : {0} from Assembly {1} is not aviable.", serviceType, serviceType.Assembly.FullName); -// Console.ReadLine(); + LoggingService.InfoFormatted("request missing service : {0} from Assembly {1} is not aviable.", serviceType, serviceType.Assembly.FullName); } else { -// Console.WriteLine("get service : {0} from Assembly {1}.", serviceType, serviceType.Assembly.FullName); + LoggingService.DebugFormatted("get service : {0} from Assembly {1}.", serviceType, serviceType.Assembly.FullName); } return serviceContainer.GetService(serviceType); } diff --git a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Services/ToolboxService.cs b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Services/ToolboxService.cs index 81a472bad1..577f76e5bc 100644 --- a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Services/ToolboxService.cs +++ b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Services/ToolboxService.cs @@ -11,6 +11,7 @@ using System.Collections; using System.Collections.Specialized; using System.Drawing.Design; using System.ComponentModel.Design; +using ICSharpCode.Core; namespace ICSharpCode.FormDesigner.Services { @@ -183,8 +184,7 @@ namespace ICSharpCode.FormDesigner.Services /// </remarks> public void AddCreator(ToolboxItemCreatorCallback creator, string format, IDesignerHost host) { - //System.Console.WriteLine("\tDefaultToolboxService:AddCreator({0}, {1}, {2})", - // creator, format, host); + LoggingService.DebugFormatted("\tDefaultToolboxService:AddCreator({0}, {1}, {2})", creator, format, host); if (host == null) { creators.Add(format, creator); } else { @@ -250,7 +250,7 @@ namespace ICSharpCode.FormDesigner.Services public ToolboxItem DeserializeToolboxItem(object serializedObject) { -// Console.WriteLine("DeserializeToolboxItem {0}", serializedObject); + LoggingService.DebugFormatted("DeserializeToolboxItem {0}", serializedObject); if (serializedObject is System.Windows.Forms.IDataObject) { if (((System.Windows.Forms.IDataObject)serializedObject).GetDataPresent(typeof(ToolboxItem))) { return (ToolboxItem) ((System.Windows.Forms.IDataObject)serializedObject).GetData(typeof(ToolboxItem)); @@ -261,7 +261,7 @@ namespace ICSharpCode.FormDesigner.Services public ToolboxItem DeserializeToolboxItem(object serializedObject, IDesignerHost host) { - Console.WriteLine("DeserializeToolboxItem {0} host {1}", serializedObject, host); + LoggingService.DebugFormatted("DeserializeToolboxItem {0} host {1}", serializedObject, host); if (serializedObject is System.Windows.Forms.IDataObject) { if (((System.Windows.Forms.IDataObject)serializedObject).GetDataPresent(typeof(ToolboxItem))) { ToolboxItem item = (ToolboxItem) ((System.Windows.Forms.IDataObject)serializedObject).GetData(typeof(ToolboxItem)); @@ -269,30 +269,26 @@ namespace ICSharpCode.FormDesigner.Services if (host != null) { ArrayList list = (ArrayList)toolboxByHost[host]; if (list != null && list.Contains(item)) { - Console.WriteLine("Item1>" + item); return item; } list = (ArrayList)toolboxByHost[ALL_HOSTS]; if (list != null && list.Contains(item)) { - Console.WriteLine("Item2>" + item + " type " + item.GetType()); return item; } } } } - Console.WriteLine("return null"); + LoggingService.InfoFormatted("DeserializeToolboxItem {0} host {1} return null", serializedObject, host); return null; } public ToolboxItem GetSelectedToolboxItem() { -// Console.WriteLine("GetSelectedToolboxItem"); return selectedItem; } public ToolboxItem GetSelectedToolboxItem(IDesignerHost host) { -// Console.WriteLine("GetSelectedToolboxItem host {0}", host); IList list = (IList)toolboxByHost[host]; if (list != null && list.Contains(selectedItem)) { return selectedItem; @@ -307,7 +303,7 @@ namespace ICSharpCode.FormDesigner.Services public ToolboxItemCollection GetToolboxItems() { -// Console.WriteLine("GetToolboxItems"); + LoggingService.Debug("ToolboxService: GetToolboxItems"); ToolboxItem[] items = new ToolboxItem[toolboxItems.Count]; toolboxItems.CopyTo(items); return new ToolboxItemCollection(items); @@ -315,7 +311,7 @@ namespace ICSharpCode.FormDesigner.Services public ToolboxItemCollection GetToolboxItems(string category) { -// Console.WriteLine("GetToolboxItems category {0}", category); + LoggingService.Debug("ToolboxService: GetToolboxItems category " + category); if (category == null) { category = ALL_CATEGORIES; } @@ -329,7 +325,7 @@ namespace ICSharpCode.FormDesigner.Services public ToolboxItemCollection GetToolboxItems(string category, IDesignerHost host) { -// Console.WriteLine("GetToolboxItems category {0} host {1}", category, host); + LoggingService.DebugFormatted("ToolboxService: GetToolboxItems category {0} host {1}", category, host); if (category == null) { category = ALL_CATEGORIES; } @@ -374,19 +370,16 @@ namespace ICSharpCode.FormDesigner.Services public bool IsSupported(object serializedObject, ICollection filterAttributes) { -// Console.WriteLine("IsSupported serializedObiect {0} filterAttributes {1}", serializedObject, filterAttributes); return true; } public bool IsSupported(object serializedObject, IDesignerHost host) { -// Console.WriteLine("IsSupported serializedObiect {0} host {1}", serializedObject, host); return true; } public bool IsToolboxItem(object serializedObject) { -// Console.WriteLine("IsToolboxItem serializedObiect {0}", serializedObject); if (serializedObject is System.Windows.Forms.IDataObject) { if (((System.Windows.Forms.IDataObject)serializedObject).GetDataPresent(typeof(ToolboxItem))) { return true; @@ -397,7 +390,6 @@ namespace ICSharpCode.FormDesigner.Services public bool IsToolboxItem(object serializedObject, IDesignerHost host) { -// Console.WriteLine("IsToolboxItem serializedObiect {0} host {1}", serializedObject, host); // needed for Toolbox drag & drop if (serializedObject is System.Windows.Forms.IDataObject) { if (((System.Windows.Forms.IDataObject)serializedObject).GetDataPresent(typeof(ToolboxItem))) { @@ -450,13 +442,11 @@ namespace ICSharpCode.FormDesigner.Services public void SelectedToolboxItemUsed() { -// Console.WriteLine("SelectedToolboxItemUsed"); FireSelectedItemUsed(); } public object SerializeToolboxItem(ToolboxItem toolboxItem) { -// Console.WriteLine("SerializeToolboxItem"); return null; } @@ -473,7 +463,6 @@ namespace ICSharpCode.FormDesigner.Services public void SetSelectedToolboxItem(ToolboxItem toolboxItem) { -// Console.WriteLine("SetSelectedToolboxItem toolboxItem {0}", toolboxItem); if (toolboxItem != selectedItem) { FireSelectedItemChanging(); selectedItem = toolboxItem; diff --git a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Services/TypeResolutionService.cs b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Services/TypeResolutionService.cs index a5fd73ec3f..669b840ef0 100644 --- a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Services/TypeResolutionService.cs +++ b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/Services/TypeResolutionService.cs @@ -95,7 +95,7 @@ namespace ICSharpCode.FormDesigner.Services public void ReferenceAssembly(AssemblyName name) { - Console.WriteLine("TODO!!! : Add Assembly reference : " + name); + ICSharpCode.Core.LoggingService.Warn("TODO: Add Assembly reference : " + name); } } } diff --git a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/ToolboxProvider.cs b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/ToolboxProvider.cs index 6fed40d0b0..95c7e1e270 100644 --- a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/ToolboxProvider.cs +++ b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/ToolboxProvider.cs @@ -122,7 +122,7 @@ namespace ICSharpCode.FormDesigner SideTabDesigner newTab = new SideTabDesigner(SharpDevelopSideBar.SideBar, category, toolboxService); SideTabs.Add(newTab); } catch (Exception e) { - Console.WriteLine("Can't add tab : " + e); + ICSharpCode.Core.LoggingService.Warn("Can't add tab : " + e); } } } diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/CodeCompletionWindow.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/CodeCompletionWindow.cs index 0d48bc72b0..73b453ed2d 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/CodeCompletionWindow.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/CodeCompletionWindow.cs @@ -114,7 +114,6 @@ namespace ICSharpCode.XmlEditor void SetDeclarationViewLocation() { - Console.WriteLine("SET DECLARATION VIEW LOCATION."); // This method uses the side with more free space int leftSpace = Bounds.Left - workingScreen.Left; int rightSpace = workingScreen.Right - Bounds.Right; @@ -162,7 +161,6 @@ namespace ICSharpCode.XmlEditor protected override void CaretOffsetChanged(object sender, EventArgs e) { int offset = control.ActiveTextAreaControl.Caret.Offset; - //Console.WriteLine("StartOffset {0} endOffset {1} - Offset {2}", startOffset, endOffset, offset); if (offset < startOffset || offset > endOffset) { Close(); } else { @@ -253,7 +251,6 @@ namespace ICSharpCode.XmlEditor control.BeginUpdate(); if (endOffset - startOffset > 0) { - //Console.WriteLine("start {0} length {1}", startOffset, endOffset - startOffset); control.Document.Remove(startOffset, endOffset - startOffset); control.ActiveTextAreaControl.Caret.Position = control.Document.OffsetToPosition(startOffset); } diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlSchemaManager.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlSchemaManager.cs index 93a2a82d9d..04bbd80934 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlSchemaManager.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlSchemaManager.cs @@ -112,7 +112,7 @@ namespace ICSharpCode.XmlEditor SchemaCompletionDataItems.Add(schemaData); OnUserSchemaAdded(); } else { - Console.WriteLine(String.Concat("Trying to add a schema that already exists. Namespace=", schemaData.NamespaceUri)); + LoggingService.Warn("Trying to add a schema that already exists. Namespace=" + schemaData.NamespaceUri); } } @@ -155,14 +155,14 @@ namespace ICSharpCode.XmlEditor schemas.Add(data); } else { // Namespace already exists. - Console.WriteLine(String.Concat("Ignoring duplicate schema namespace ", data.NamespaceUri)); + LoggingService.Warn("Ignoring duplicate schema namespace " + data.NamespaceUri); } } else { // Namespace is null. - Console.WriteLine(String.Concat("Ignoring schema with no namespace ", data.FileName)); + LoggingService.Warn("Ignoring schema with no namespace " + data.FileName); } } catch (Exception ex) { - Console.WriteLine(String.Concat("Unable to read schema '", fileName, "'. ", ex.Message)); + LoggingService.Warn("Unable to read schema '" + fileName + "'. ", ex); } } diff --git a/src/AddIns/Misc/NUnitPad/Project/Src/Gui/NUnitPadContent.cs b/src/AddIns/Misc/NUnitPad/Project/Src/Gui/NUnitPadContent.cs index 276fe1aae6..b4168de98e 100644 --- a/src/AddIns/Misc/NUnitPad/Project/Src/Gui/NUnitPadContent.cs +++ b/src/AddIns/Misc/NUnitPad/Project/Src/Gui/NUnitPadContent.cs @@ -213,16 +213,14 @@ namespace ICSharpCode.NUnitPad } if (referenceFound) { string outputAssembly = project.OutputAssemblyFullPath; + LoggingService.Debug("NUnitPad: Load " + outputAssembly); try { TestDomain testDomain = new TestDomain(); -// NUnitProject prj = NUnitProject.LoadProject(outputAssembly); Test test = testDomain.Load(outputAssembly); -// TestSuiteBuilder builder = new TestSuiteBuilder(); -// Console.WriteLine("Try to load '" + outputAssembly +"'"); -// Test testDomain = builder.Build(outputAssembly); testTreeView.PrintTests(outputAssembly, test, project); } catch (Exception e) { + LoggingService.Warn("NUnitPad load error", e); testTreeView.PrintTestErrors(outputAssembly, e); } } diff --git a/src/AddIns/Misc/NUnitPad/Project/Src/Gui/TestTreeView.cs b/src/AddIns/Misc/NUnitPad/Project/Src/Gui/TestTreeView.cs index f155ceb7dd..f5b8713851 100644 --- a/src/AddIns/Misc/NUnitPad/Project/Src/Gui/TestTreeView.cs +++ b/src/AddIns/Misc/NUnitPad/Project/Src/Gui/TestTreeView.cs @@ -163,7 +163,6 @@ namespace ICSharpCode.NUnitPad public void PrintTests(string assembly, Test test, IProject project) { - Console.WriteLine(assembly); TreeNode assemblyNode = new TreeNode(Path.GetFileName(assembly)); assemblyNode.Tag = new TestItemTag(test, project); treeView.Nodes.Add(assemblyNode); @@ -341,16 +340,9 @@ namespace ICSharpCode.NUnitPad testRunnerCategory.AppendText(outputMessage + Environment.NewLine); testRunnerCategory.AppendText(result.Description + Environment.NewLine); testRunnerCategory.AppendText(result.StackTrace + Environment.NewLine); -// if (result.StackTrace != null ) { -// Console.WriteLine("result.StackTrace=" + result.StackTrace); -// } -// else { -// Console.WriteLine("result.StackTrace=null"); -// } FileLineReference LineRef = OutputTextLineParser.GetNUnitOutputFileLineReference(result.StackTrace, true); if (LineRef != null) { -// Console.WriteLine("Adding NUnit error task."); Task Task = new Task(Path.GetFullPath(LineRef.FileName), outputMessage, LineRef.Column, @@ -370,17 +362,10 @@ namespace ICSharpCode.NUnitPad testRunnerCategory.AppendText(result.Message + Environment.NewLine); testRunnerCategory.AppendText(result.Description + Environment.NewLine); testRunnerCategory.AppendText(result.StackTrace + Environment.NewLine); -// if (result.StackTrace != null ) { -// Console.WriteLine("result.StackTrace=" + result.StackTrace); -// } -// else { -// Console.WriteLine("result.StackTrace=null"); -// } FileLineReference LineRef = OutputTextLineParser.GetNUnitOutputFileLineReference(result.StackTrace, true); if (LineRef != null) { -// Console.WriteLine("Adding NUnit warning task."); Task Task = new Task(Path.GetFullPath(LineRef.FileName), outputMessage, LineRef.Column, diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/AutostartCommands.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/AutostartCommands.cs index a9ae36e03f..b916b04c6b 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/AutostartCommands.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/AutostartCommands.cs @@ -51,11 +51,19 @@ namespace ICSharpCode.Svn.Commands node.AcceptVisitor(visitor, null); } + bool CanBeVersionControlled(string fileName) + { + string svnDir = Path.Combine(Path.GetDirectoryName(fileName), ".svn"); + return Directory.Exists(svnDir); + } + void FileSaved(object sender, FileNameEventArgs e) { ProjectBrowserPad pad = ProjectBrowserPad.Instance; if (pad == null) return; - FileNode node = pad.ProjectBrowserControl.FindFileNode(e.FileName); + string fileName = e.FileName; + if (!CanBeVersionControlled(fileName)) return; + FileNode node = pad.ProjectBrowserControl.FindFileNode(fileName); if (node == null) return; OverlayIconManager.Enqueue(node); } @@ -64,6 +72,7 @@ namespace ICSharpCode.Svn.Commands { try { if (AddInOptions.AutomaticallyAddFiles) { + if (!CanBeVersionControlled(e.FileName)) return; SvnClient.Instance.Client.Add(Path.GetFullPath(e.FileName), false); } } catch (Exception ex) { @@ -77,6 +86,7 @@ namespace ICSharpCode.Svn.Commands if (e.IsDirectory) return; if (!AddInOptions.AutomaticallyDeleteFiles) return; string fullName = Path.GetFullPath(e.FileName); + if (!CanBeVersionControlled(fullName)) return; try { Status status = SvnClient.Instance.Client.SingleStatus(fullName); switch (status.TextStatus) { @@ -114,6 +124,7 @@ namespace ICSharpCode.Svn.Commands void FileRenaming(object sender, FileRenamingEventArgs e) { string fullSource = Path.GetFullPath(e.SourceFile); + if (!CanBeVersionControlled(fullSource)) return; try { Status status = SvnClient.Instance.Client.SingleStatus(fullSource); switch (status.TextStatus) { diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewDisplayBinding.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewDisplayBinding.cs index 22540a261a..6316b87ae4 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewDisplayBinding.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewDisplayBinding.cs @@ -46,12 +46,20 @@ namespace ICSharpCode.Svn return new ICSharpCode.SharpDevelop.Gui.ISecondaryViewContent[] { new HistoryView(viewContent) }; } + static Client client; + public bool CanAttachTo(ICSharpCode.SharpDevelop.Gui.IViewContent content) { if (content.IsUntitled || content.FileName == null || !File.Exists(content.FileName)) { return false; } - Client client = new Client(); + string svnDir = Path.Combine(Path.GetDirectoryName(content.FileName), ".svn"); + if (!Directory.Exists(svnDir)) + return false; + if (client == null) { + LoggingService.Info("SVN: HistoryViewDisplayBinding initializes client"); + client = new Client(); + } Status status = client.SingleStatus(Path.GetFullPath(content.FileName)); return status != null && status.Entry != null; } 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 8e6b8d454c..283c8dd8fc 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewPanel.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewPanel.cs @@ -9,6 +9,7 @@ using System; using System.IO; using System.Threading; using System.Windows.Forms; +using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Gui; using NSvn.Common; using NSvn.Core; @@ -74,7 +75,7 @@ namespace ICSharpCode.Svn void GetLogMessages() { string fileName = Path.GetFullPath(viewContent.FileName); - Console.WriteLine("Get log of " + fileName); + LoggingService.Info("SVN: Get log of " + fileName); if (File.Exists(fileName)) { Client client = SvnClient.Instance.Client; client.Log(new string[] { fileName}, diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/ProjectBrowserVisitor/OverlayIconManager.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/ProjectBrowserVisitor/OverlayIconManager.cs index 1560496730..950116cf9b 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/ProjectBrowserVisitor/OverlayIconManager.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/ProjectBrowserVisitor/OverlayIconManager.cs @@ -126,10 +126,14 @@ namespace ICSharpCode.Svn static void Run() { + LoggingService.Debug("SVN: OverlayIconManager Thread started"); while (true) { AbstractProjectBrowserTreeNode node; lock (queue) { - if (queue.Count == 0) return; + if (queue.Count == 0) { + LoggingService.Debug("SVN: OverlayIconManager Thread finished"); + return; + } node = queue.Dequeue(); } try { diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/SvnClient.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/SvnClient.cs index 87a02af151..c80783037d 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/SvnClient.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/SvnClient.cs @@ -221,6 +221,7 @@ namespace ICSharpCode.Svn SvnClient() { + LoggingService.Info("SVN: SvnClient initialized"); client = new Client(); client.LogMessage += new LogMessageDelegate(SetLogMessage); client.Notification += new NotificationDelegate(ReceiveNotification); diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/ICSharpCode.TextEditor.csproj b/src/Libraries/ICSharpCode.TextEditor/Project/ICSharpCode.TextEditor.csproj index 72124dbbfc..86e208ce1f 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/ICSharpCode.TextEditor.csproj +++ b/src/Libraries/ICSharpCode.TextEditor/Project/ICSharpCode.TextEditor.csproj @@ -181,4 +181,4 @@ <Compile Include="Src\Document\TextBufferStrategy\PieceTableTextBufferStrategy.cs" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> -</Project> +</Project> \ No newline at end of file diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/LineManager/DefaultLineManager.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/LineManager/DefaultLineManager.cs index d85f383388..7e85e38b1d 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/LineManager/DefaultLineManager.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/LineManager/DefaultLineManager.cs @@ -170,7 +170,6 @@ namespace ICSharpCode.TextEditor.Document LineSegment line = (LineSegment)lineCollection[lineNumber]; if ((lineNumber == lineCollection.Count - 1) && removedLineEnds > 0) { line.TotalLength -= length; -// Console.WriteLine("3:Line length of line {0} set to {1}", lineNumber, line.TotalLength - line.DelimiterLength); line.DelimiterLength = 0; } else { ++lineNumber; diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/Caret.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/Caret.cs index c08ecc9efd..2ad577612b 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/Caret.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/Caret.cs @@ -36,7 +36,7 @@ namespace ICSharpCode.TextEditor InsertMode, /// <summary> - /// If the caret is in overwirte mode typed characters will + /// If the caret is in overwirte mode typed characters will /// overwrite the character at the caret position /// </summary> OverwriteMode @@ -212,7 +212,7 @@ namespace ICSharpCode.TextEditor get { int xpos = textArea.TextView.GetDrawingXPos(this.line, this.column); return new Point(textArea.TextView.DrawingPosition.X + xpos, - textArea.TextView.DrawingPosition.Y + (textArea.Document.GetVisibleLine(this.line)) * textArea.TextView.FontHeight - textArea.TextView.TextArea.VirtualTop.Y); + textArea.TextView.DrawingPosition.Y + (textArea.Document.GetVisibleLine(this.line)) * textArea.TextView.FontHeight - textArea.TextView.TextArea.VirtualTop.Y); } } int oldLine = -1; @@ -228,39 +228,34 @@ namespace ICSharpCode.TextEditor if (hidden || textArea.MotherTextEditorControl.IsUpdating) { return; } - try { - if (!caretCreated) { - CreateCaret(); - } - if (caretCreated) { - ValidateCaretPos(); - int lineNr = this.line; - int xpos = textArea.TextView.GetDrawingXPos(lineNr, this.column); - //LineSegment lineSegment = textArea.Document.GetLineSegment(lineNr); - Point pos = ScreenPosition; - if (xpos >= 0) { - bool success = SetCaretPos(pos.X, pos.Y); - if (!success) { - DestroyCaret(); - caretCreated = false; - UpdateCaretPosition(); - } - } - // set the input method editor location - if (ime == null) { - ime = new Ime(textArea.Handle, textArea.Document.TextEditorProperties.Font); - } else { - ime.Font = textArea.Document.TextEditorProperties.Font; + if (!caretCreated) { + CreateCaret(); + } + if (caretCreated) { + ValidateCaretPos(); + int lineNr = this.line; + int xpos = textArea.TextView.GetDrawingXPos(lineNr, this.column); + //LineSegment lineSegment = textArea.Document.GetLineSegment(lineNr); + Point pos = ScreenPosition; + if (xpos >= 0) { + bool success = SetCaretPos(pos.X, pos.Y); + if (!success) { + DestroyCaret(); + caretCreated = false; + UpdateCaretPosition(); } - ime.SetIMEWindowLocation(pos.X + 2, - pos.Y); - - currentPos = pos; } - } catch (Exception e) { - Console.WriteLine("Got exception while update caret position : " + e); + // set the input method editor location + if (ime == null) { + ime = new Ime(textArea.Handle, textArea.Document.TextEditorProperties.Font); + } else { + ime.Font = textArea.Document.TextEditorProperties.Font; + } + ime.SetIMEWindowLocation(pos.X + 2, + pos.Y); + + currentPos = pos; } - } public void Dispose() @@ -291,7 +286,6 @@ namespace ICSharpCode.TextEditor List<FoldMarker> foldings = textArea.Document.FoldingManager.GetFoldingsFromPosition(line, column); bool shouldUpdate = false; foreach (FoldMarker foldMarker in foldings) { - //Console.WriteLine(foldMarker); shouldUpdate |= foldMarker.IsFolded; foldMarker.IsFolded = false; } diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/CompletionWindow/CodeCompletionWindow.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/CompletionWindow/CodeCompletionWindow.cs index 204c885dda..2697125713 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/CompletionWindow/CodeCompletionWindow.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/CompletionWindow/CodeCompletionWindow.cs @@ -159,7 +159,6 @@ namespace ICSharpCode.TextEditor.Gui.CompletionWindow protected override void CaretOffsetChanged(object sender, EventArgs e) { int offset = control.ActiveTextAreaControl.Caret.Offset; - //Console.WriteLine("StartOffset {0} endOffset {1} - Offset {2}", startOffset, endOffset, offset); if (offset < startOffset || offset > endOffset) { Close(); } else { @@ -251,7 +250,6 @@ namespace ICSharpCode.TextEditor.Gui.CompletionWindow control.BeginUpdate(); if (endOffset - startOffset > 0) { - //Console.WriteLine("start {0} length {1}", startOffset, endOffset - startOffset); control.Document.Remove(startOffset, endOffset - startOffset); control.ActiveTextAreaControl.Caret.Position = control.Document.OffsetToPosition(startOffset); } diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs index 06e70ceedb..bc6c2fc713 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs @@ -375,11 +375,7 @@ namespace ICSharpCode.TextEditor if (updateMargin != null) { - try { - updateMargin.Paint(g, updateMargin.DrawingPosition); - } catch (Exception ex) { - Console.WriteLine("Got exception : " + ex); - } + updateMargin.Paint(g, updateMargin.DrawingPosition); // clipRectangle.Intersect(updateMargin.DrawingPosition); } @@ -404,11 +400,7 @@ namespace ICSharpCode.TextEditor if (clipRectangle.IntersectsWith(marginRectangle)) { marginRectangle.Intersect(clipRectangle); if (!marginRectangle.IsEmpty) { - try { - margin.Paint(g, marginRectangle); - } catch (Exception ex) { - Console.WriteLine("Got exception : " + ex); - } + margin.Paint(g, marginRectangle); } } } @@ -422,23 +414,15 @@ namespace ICSharpCode.TextEditor if (clipRectangle.IntersectsWith(textViewArea)) { textViewArea.Intersect(clipRectangle); if (!textViewArea.IsEmpty) { - try { - textView.Paint(g, textViewArea); - } catch (Exception ex) { - Console.WriteLine("Got exception : " + ex); - } + textView.Paint(g, textViewArea); } } if (adjustScrollBars) { - try { - this.motherTextAreaControl.AdjustScrollBars(null, null); - } catch (Exception) {} + this.motherTextAreaControl.AdjustScrollBars(null, null); } - try { - Caret.UpdateCaretPosition(); - } catch (Exception) {} + Caret.UpdateCaretPosition(); base.OnPaint(e); } @@ -537,8 +521,6 @@ namespace ICSharpCode.TextEditor } } } - } catch (Exception e) { - Console.WriteLine("Got Exception while executing action " + action + " : " + e.ToString()); } finally { motherTextEditorControl.EndUpdate(); Caret.UpdateCaretPosition(); diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaClipboardHandler.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaClipboardHandler.cs index 51bad0bbed..32cc8107ad 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaClipboardHandler.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaClipboardHandler.cs @@ -44,14 +44,7 @@ namespace ICSharpCode.TextEditor public bool EnablePaste { get { - // Clipboard.GetDataObject may throw an exception... - try { - IDataObject data = Clipboard.GetDataObject(); - return data != null && data.GetDataPresent(DataFormats.Text); - } catch (Exception e) { - Console.WriteLine("Got exception while enablepaste : " + e); - return false; - } + return Clipboard.ContainsText(); } } @@ -96,8 +89,8 @@ namespace ICSharpCode.TextEditor OnCopyText(new CopyTextEventArgs(str)); Clipboard.SetDataObject(dataObject, true); return true; - } catch (Exception e) { - Console.WriteLine("Got exception while Copy text to clipboard : " + e); + } catch (ExternalException) { + } Thread.Sleep(100); } @@ -139,8 +132,7 @@ namespace ICSharpCode.TextEditor textArea.Document.UndoStack.UndoLast(redocounter + 1); // redo the whole operation } } } - } catch (Exception ex) { - Console.WriteLine("Got exception while Paste : " + ex); + } catch (ExternalException) { } } diff --git a/src/Libraries/NRefactory/Project/Src/Output/SpecialNodesInserter.cs b/src/Libraries/NRefactory/Project/Src/Output/SpecialNodesInserter.cs index 23d006981a..cd9457cb8a 100644 --- a/src/Libraries/NRefactory/Project/Src/Output/SpecialNodesInserter.cs +++ b/src/Libraries/NRefactory/Project/Src/Output/SpecialNodesInserter.cs @@ -76,7 +76,6 @@ namespace ICSharpCode.NRefactory.PrettyPrinter /// </summary> public void AcceptNodeStart(INode node) { - Console.Write("Start node " + node.GetType().Name + ": "); AcceptPoint(node.StartLocation); } @@ -85,7 +84,6 @@ namespace ICSharpCode.NRefactory.PrettyPrinter /// </summary> public void AcceptNodeEnd(INode node) { - Console.Write("End node " + node.GetType().Name + ": "); AcceptPoint(node.EndLocation); } @@ -94,7 +92,6 @@ namespace ICSharpCode.NRefactory.PrettyPrinter /// </summary> public void AcceptPoint(Point a) { - Console.WriteLine(a.Y + ", " + a.X); while (available) { Point b = enumerator.Current.StartPosition; if (b.Y < a.Y || (b.Y == a.Y && b.X <= a.X)) { diff --git a/src/Main/Base/Project/Src/Dom/ExpressionContext.cs b/src/Main/Base/Project/Src/Dom/ExpressionContext.cs index 1920717f4d..81edbe84c4 100644 --- a/src/Main/Base/Project/Src/Dom/ExpressionContext.cs +++ b/src/Main/Base/Project/Src/Dom/ExpressionContext.cs @@ -79,7 +79,7 @@ namespace ICSharpCode.SharpDevelop.Dom /// <remarks>When using this context, a resolver should try resolving typenames with an /// appended "Attribute" suffix and treat "invocations" of the attribute type as /// object creation.</remarks> - public static ExpressionContext Attribute = new TypeExpressionContext(ProjectContentRegistry.Mscorlib.GetClass("System.Attribute"), true, true); + public static ExpressionContext Attribute = new TypeExpressionContext(ProjectContentRegistry.Mscorlib.GetClass("System.Attribute"), false, true); /// <summary>Context expects a type name which has special base type</summary> /// <param name="baseClass">The class the expression must derive from.</param> diff --git a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs index 8d22e43ae4..7960bbfd7b 100644 --- a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs +++ b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs @@ -528,7 +528,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver if (e != null) { e.Documentation = GetDocumentation(region.BeginLine); } else { - Console.WriteLine("Warning: " + eventDeclaration + " has no events!"); + LoggingService.Warn("NRefactoryASTConvertVisitor: " + eventDeclaration + " has no events!"); } return null; } diff --git a/src/Main/Base/Project/Src/Dom/ResolveResult.cs b/src/Main/Base/Project/Src/Dom/ResolveResult.cs index f3493ec992..e030d8c330 100644 --- a/src/Main/Base/Project/Src/Dom/ResolveResult.cs +++ b/src/Main/Base/Project/Src/Dom/ResolveResult.cs @@ -202,18 +202,16 @@ namespace ICSharpCode.SharpDevelop.Dom { ICompilationUnit cu = this.CallingClass.CompilationUnit; if (cu == null) { - Console.WriteLine("callingClass.CompilationUnit is null"); return null; } if (cu.FileName == null || cu.FileName.Length == 0) { - Console.WriteLine("callingClass.CompilationUnit.FileName is empty"); return null; } IRegion reg = field.Region; if (reg != null) { return new FilePosition(cu.FileName, new Point(reg.BeginLine, reg.BeginColumn)); } else { - Console.WriteLine("Fieldregion not set!"); + LoggingService.Warn("GetDefinitionPosition: field.Region is null"); return new FilePosition(cu.FileName, Point.Empty); } } @@ -376,16 +374,13 @@ namespace ICSharpCode.SharpDevelop.Dom { IClass declaringType = resolvedMember.DeclaringType; if (declaringType == null) { - Console.WriteLine("declaringType is null"); return null; } ICompilationUnit cu = declaringType.CompilationUnit; if (cu == null) { - Console.WriteLine("declaringType.CompilationUnit is null"); return null; } if (cu.FileName == null || cu.FileName.Length == 0) { - Console.WriteLine("declaringType.CompilationUnit.FileName is empty"); return null; } IRegion reg = resolvedMember.Region; diff --git a/src/Main/Base/Project/Src/Dom/XmlDoc.cs b/src/Main/Base/Project/Src/Dom/XmlDoc.cs index 86751ad501..982941f6b0 100644 --- a/src/Main/Base/Project/Src/Dom/XmlDoc.cs +++ b/src/Main/Base/Project/Src/Dom/XmlDoc.cs @@ -9,11 +9,13 @@ using System; using System.IO; using System.Collections.Generic; using System.Xml; +using ICSharpCode.Core; namespace ICSharpCode.SharpDevelop.Dom { /// <summary> - /// Description of XmlDoc. + /// Class capable of loading xml documentation files. XmlDoc automatically creates a + /// binary cache for big xml files to reduce memory usage. /// </summary> public class XmlDoc : IDisposable { @@ -116,15 +118,15 @@ namespace ICSharpCode.SharpDevelop.Dom int len = (int)fs.Length; loader = new BinaryReader(fs); if (loader.ReadInt64() != magic) { - Console.WriteLine("Wrong magic"); + LoggingService.Warn("Cannot load XmlDoc: wrong magic"); return false; } if (loader.ReadInt16() != version) { - Console.WriteLine("Wrong version"); + LoggingService.Warn("Cannot load XmlDoc: wrong version"); return false; } if (loader.ReadInt64() != fileDate.Ticks) { - Console.WriteLine("Wrong date"); + LoggingService.Info("Not loading XmlDoc: file changed since cache was created"); return false; } fs.Position = loader.ReadInt32(); // go to start of index @@ -151,6 +153,7 @@ namespace ICSharpCode.SharpDevelop.Dom public void Dispose() { + LoggingService.Debug("Disposing XmlDoc object"); if (loader != null) { loader.Close(); fs.Close(); @@ -190,12 +193,14 @@ namespace ICSharpCode.SharpDevelop.Dom public static XmlDoc Load(string fileName) { + LoggingService.Debug("Loading XmlDoc for " + fileName); string cacheName = MakeTempPath() + "/" + Path.GetFileNameWithoutExtension(fileName) + "." + fileName.GetHashCode().ToString("x") + ".dat"; XmlDoc doc; if (File.Exists(cacheName)) { doc = new XmlDoc(); if (doc.LoadFromBinary(cacheName, File.GetLastWriteTimeUtc(fileName))) { + LoggingService.Debug("XmlDoc: Load from cache successful"); return doc; } else { doc.Dispose(); @@ -210,6 +215,7 @@ namespace ICSharpCode.SharpDevelop.Dom } if (doc.xmlDescription.Count > cacheLength * 2) { + LoggingService.Debug("XmlDoc: Creating cache"); DateTime date = File.GetLastWriteTimeUtc(fileName); doc.Save(cacheName, date); doc.Dispose(); diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs b/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs index 707caead3e..0dd7e8386d 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs @@ -86,7 +86,7 @@ namespace ICSharpCode.SharpDevelop.Gui imglist.Images.Add(bitmap); tmp[entry.Key] = ++i; } else { - Console.WriteLine("can't load bitmap " + entry.Key.ToString() + " using default"); + LoggingService.Warn("NewFileDialog: can't load bitmap " + entry.Key.ToString() + " using default"); } } diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs b/src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs index 396195b1ee..999a374368 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs @@ -77,7 +77,7 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs imglist.Images.Add(bitmap); tmp[entry.Key] = ++i; } else { - Console.WriteLine("can't load bitmap " + entry.Key.ToString() + " using default"); + LoggingService.Warn("NewProjectDialog: can't load bitmap " + entry.Key.ToString() + " using default"); } } diff --git a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionFolderNode.cs b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionFolderNode.cs index 770d8afe8c..39512b763e 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionFolderNode.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionFolderNode.cs @@ -103,7 +103,7 @@ namespace ICSharpCode.SharpDevelop.Project SolutionFolderNode folderNode = new SolutionFolderNode(solution, (SolutionFolder)treeObject); folderNode.AddTo(this); } else { - Console.WriteLine("unknown tree object : " + treeObject); + LoggingService.Warn("SolutionFolderNode.Initialize(): unknown tree object : " + treeObject); } } diff --git a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/Util/ProjectBrowserTreeNodeVisitor.cs b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/Util/ProjectBrowserTreeNodeVisitor.cs index 6ad58f96e7..d987a14827 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/Util/ProjectBrowserTreeNodeVisitor.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/Util/ProjectBrowserTreeNodeVisitor.cs @@ -6,6 +6,7 @@ // </file> using System; +using ICSharpCode.Core; namespace ICSharpCode.SharpDevelop.Project { @@ -13,7 +14,7 @@ namespace ICSharpCode.SharpDevelop.Project { public object Visit(AbstractProjectBrowserTreeNode abstractProjectBrowserTreeNode, object data) { - Console.WriteLine("Warning visited default Visit() for : " + abstractProjectBrowserTreeNode); + LoggingService.Warn("Warning visited default Visit() for : " + abstractProjectBrowserTreeNode); abstractProjectBrowserTreeNode.AcceptChildren(this, data); return data; } diff --git a/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs b/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs index cd67d4ebd0..3988605975 100644 --- a/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs +++ b/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs @@ -159,9 +159,7 @@ namespace ICSharpCode.SharpDevelop.Gui } MessageService.ShowError(ex, "Exception got."); #if DEBUG - Console.WriteLine("Stacktrace of source thread:"); - Console.WriteLine(callerStack); - Console.WriteLine(); + LoggingService.Info("Stacktrace of source thread:\n" + callerStack); #endif } } diff --git a/src/Main/Base/Project/Src/Internal/Templates/CodeTemplateLoader.cs b/src/Main/Base/Project/Src/Internal/Templates/CodeTemplateLoader.cs index f7fa2553dc..7b10f8c683 100644 --- a/src/Main/Base/Project/Src/Internal/Templates/CodeTemplateLoader.cs +++ b/src/Main/Base/Project/Src/Internal/Templates/CodeTemplateLoader.cs @@ -96,7 +96,7 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates static CodeTemplateLoader() { if (!LoadTemplatesFromStream(Path.Combine(PropertyService.ConfigDirectory, TemplateFileName))) { - Console.WriteLine("Templates: can't load user defaults, reading system defaults"); + LoggingService.Info("Templates: can't load user defaults, reading system defaults"); if (!LoadTemplatesFromStream(FileUtility.Combine(PropertyService.DataDirectory, "options", TemplateFileName))) { MessageService.ShowWarning("${res:Internal.Templates.CodeTemplateLoader.CantLoadTemplatesWarning}"); } diff --git a/src/Main/Base/Project/Src/Project/MSBuildEngine.cs b/src/Main/Base/Project/Src/Project/MSBuildEngine.cs index f7866cb428..d8cbd5a4b4 100644 --- a/src/Main/Base/Project/Src/Project/MSBuildEngine.cs +++ b/src/Main/Base/Project/Src/Project/MSBuildEngine.cs @@ -52,6 +52,8 @@ namespace ICSharpCode.SharpDevelop.Project public CompilerResults Run(string buildFile, string[] targets) { + LoggingService.Debug("Run MSBuild on " + buildFile); + // HACK: Workaround for MSBuild bug: // "unknown" MSBuild projects (projects with unknown type id, e.g. IL-projects) // are looked up by MSBuild if the project files are MSBuild-compatible. @@ -69,6 +71,8 @@ namespace ICSharpCode.SharpDevelop.Project engine.RegisterLogger(logger); engine.BuildProjectFile(buildFile, targets, properties, null); logger.FlushText(); + + LoggingService.Debug("MSBuild finished"); return results; } diff --git a/src/Main/Base/Project/Src/Project/MSBuildProject.cs b/src/Main/Base/Project/Src/Project/MSBuildProject.cs index 191d39ca3d..a1bab263d1 100644 --- a/src/Main/Base/Project/Src/Project/MSBuildProject.cs +++ b/src/Main/Base/Project/Src/Project/MSBuildProject.cs @@ -295,7 +295,6 @@ namespace ICSharpCode.SharpDevelop.Project public static CompilerResults RunMSBuild(string fileName, string target) { - Console.WriteLine("Run : " + fileName); WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView)).BringPadToFront(); // BeforeBuild(); MSBuildEngine engine = new MSBuildEngine(); diff --git a/src/Main/Base/Project/Src/Project/Solution/Solution.cs b/src/Main/Base/Project/Src/Project/Solution/Solution.cs index 284b2b00a5..8f2512a5c6 100644 --- a/src/Main/Base/Project/Src/Project/Solution/Solution.cs +++ b/src/Main/Base/Project/Src/Project/Solution/Solution.cs @@ -309,7 +309,7 @@ namespace ICSharpCode.SharpDevelop.Project nestedProjectsSection.Append(Environment.NewLine); } } else { - Console.WriteLine("unknown folder : "+ currentFolder); + LoggingService.Warn("Solution.Load(): unknown folder : " + currentFolder); } projectSection.Append("EndProject"); projectSection.Append(Environment.NewLine); diff --git a/src/Main/Base/Project/Src/Services/ParserService/DefaultProjectContent.cs b/src/Main/Base/Project/Src/Services/ParserService/DefaultProjectContent.cs index 0d587e7338..4acfc8dcce 100644 --- a/src/Main/Base/Project/Src/Services/ParserService/DefaultProjectContent.cs +++ b/src/Main/Base/Project/Src/Services/ParserService/DefaultProjectContent.cs @@ -198,7 +198,7 @@ namespace ICSharpCode.Core protected void AddClassToNamespaceListInternal(IClass addClass) { if (addClass.IsPartial) { - Console.WriteLine("Adding partial class " + addClass.Name + " from " + Path.GetFileName(addClass.CompilationUnit.FileName)); + LoggingService.Debug("Adding partial class " + addClass.Name + " from " + Path.GetFileName(addClass.CompilationUnit.FileName)); Dictionary<string, IClass> classes = GetClasses(language); CompoundClass compound = null; if (classes.ContainsKey(addClass.FullyQualifiedName)) @@ -209,17 +209,17 @@ namespace ICSharpCode.Core if (compound.Parts[i].CompilationUnit.FileName == addClass.CompilationUnit.FileName) { compound.Parts[i] = addClass; compound.UpdateInformationFromParts(); - Console.WriteLine("\tReplaced old part!"); + LoggingService.Debug("Replaced old part!"); return; } } compound.Parts.Add(addClass); compound.UpdateInformationFromParts(); - Console.WriteLine("\tAdded new part!"); + LoggingService.Debug("Added new part!"); return; } else { addClass = new CompoundClass(addClass); - Console.WriteLine("\tCompound created!"); + LoggingService.Debug("Compound created!"); } } diff --git a/src/Main/Base/Project/Src/Services/ParserService/ProjectContentRegistry.cs b/src/Main/Base/Project/Src/Services/ParserService/ProjectContentRegistry.cs index 42a91df4bf..8543ada423 100644 --- a/src/Main/Base/Project/Src/Services/ParserService/ProjectContentRegistry.cs +++ b/src/Main/Base/Project/Src/Services/ParserService/ProjectContentRegistry.cs @@ -35,17 +35,10 @@ namespace ICSharpCode.Core mscorlibContent = contents["mscorlib"]; return contents["mscorlib"]; } - #if DEBUG - Console.WriteLine("Loading mscorlib..."); - int time = Environment.TickCount; - #endif - + LoggingService.Debug("Loading PC for mscorlib..."); mscorlibContent = new ReflectionProjectContent(typeof(object).Assembly); contents["mscorlib"] = mscorlibContent; - - #if DEBUG - Console.WriteLine("mscorlib loaded in {0} ms", Environment.TickCount - time); - #endif + LoggingService.Debug("Finished loading mscorlib"); return mscorlibContent; } } @@ -95,10 +88,12 @@ namespace ICSharpCode.Core } string shortName = item.Include; + LoggingService.Debug("Loading PC for " + shortName); + int pos = shortName.IndexOf(','); if (pos > 0) shortName = shortName.Substring(0, pos); - + StatusBarService.ProgressMonitor.BeginTask("Loading " + shortName + "...", 100); #if DEBUG int time = Environment.TickCount; @@ -139,13 +134,13 @@ namespace ICSharpCode.Core return contents[item.Include]; } } catch (Exception e) { - Console.WriteLine("Can't load assembly '{0}' : " + e.Message, item.Include); + LoggingService.Debug("Can't load assembly '" + item.Include + "' : " + e.Message); } } catch (BadImageFormatException) { - Console.WriteLine("BadImageFormat: " + shortName); + LoggingService.Warn("BadImageFormat: " + shortName); } finally { #if DEBUG - Console.WriteLine("Loaded {0} with {2} in {1}ms", item.Include, Environment.TickCount - time, how); + LoggingService.DebugFormatted("Loaded {0} with {2} in {1}ms", item.Include, Environment.TickCount - time, how); #endif StatusBarService.ProgressMonitor.Done(); } @@ -188,28 +183,28 @@ namespace ICSharpCode.Core static Assembly AssemblyResolve(object sender, ResolveEventArgs e) { string shortName = e.Name; - Console.Write("AssemblyResolve: " + e.Name); + LoggingService.Debug("ProjectContentRegistry.AssemblyResolve" + e.Name); int pos = shortName.IndexOf(','); if (pos > 0) shortName = shortName.Substring(0, pos); string path = Path.Combine(lookupDirectory, shortName); if (File.Exists(path + ".dll")) { - Console.WriteLine(" - found .dll file"); + LoggingService.Debug("AssemblyResolve ReflectionOnlyLoadFrom .dll file"); return Assembly.ReflectionOnlyLoadFrom(path + ".dll"); } if (File.Exists(path + ".exe")) { - Console.WriteLine(" - found .exe file"); + LoggingService.Debug("AssemblyResolve ReflectionOnlyLoadFrom .exe file"); return Assembly.ReflectionOnlyLoadFrom(path + ".exe"); } if (File.Exists(path)) { - Console.WriteLine(" - found file"); + LoggingService.Debug("AssemblyResolve ReflectionOnlyLoadFrom file"); return Assembly.ReflectionOnlyLoadFrom(path); } try { - Console.WriteLine(" - try ReflectionOnlyLoad"); + LoggingService.Debug("AssemblyResolve trying ReflectionOnlyLoad"); return Assembly.ReflectionOnlyLoad(e.Name); } catch (FileNotFoundException ex) { - Console.WriteLine("AssemblyResolve: " + ex.Message); + LoggingService.Warn("AssemblyResolve failed: " + ex.Message); return null; } } diff --git a/src/Main/Base/Project/Src/Services/ProjectService/ParseableFileContentEnumerator.cs b/src/Main/Base/Project/Src/Services/ProjectService/ParseableFileContentEnumerator.cs index c365d595cc..68f49a540a 100644 --- a/src/Main/Base/Project/Src/Services/ProjectService/ParseableFileContentEnumerator.cs +++ b/src/Main/Base/Project/Src/Services/ProjectService/ParseableFileContentEnumerator.cs @@ -130,11 +130,11 @@ namespace ICSharpCode.SharpDevelop.Project } } catch (FileNotFoundException ex) { res = null; - Console.WriteLine("ParseableFileContentEnumerator: " + ex.Message); + LoggingService.Warn("ParseableFileContentEnumerator: " + ex.Message); return MoveNext(); // skip files that were not found } catch (IOException ex) { res = null; - Console.WriteLine("ParseableFileContentEnumerator: " + ex.Message); + LoggingService.Warn("ParseableFileContentEnumerator: " + ex.Message); return MoveNext(); // skip invalid files } if (nextItem != null && nextItem.ItemType == ItemType.Compile && CanReadAsync(nextItem)) diff --git a/src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/CodeGenerator.cs b/src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/CodeGenerator.cs index 8fe5648f9a..75857566ea 100644 --- a/src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/CodeGenerator.cs +++ b/src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/CodeGenerator.cs @@ -35,14 +35,14 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands csa = (IAmbience)AddInTree.GetTreeNode("/SharpDevelop/Workbench/Ambiences").BuildChildItem("C#", this); csa.ConversionFlags = ConversionFlags.ShowAccessibility | ConversionFlags.ShowModifiers | ConversionFlags.QualifiedNamesOnlyForReturnTypes | ConversionFlags.ShowReturnType | ConversionFlags.ShowParameterNames; } catch (Exception) { - Console.WriteLine("CSharpAmbience not found -- is the C# backend binding loaded???"); + LoggingService.Warn("CSharpAmbience not found -- is the C# backend binding loaded???"); } try { vba = (IAmbience)AddInTree.GetTreeNode("/SharpDevelop/Workbench/Ambiences").BuildChildItem("VBNET", this); vba.ConversionFlags = ConversionFlags.ShowAccessibility | ConversionFlags.ShowModifiers | ConversionFlags.QualifiedNamesOnlyForReturnTypes | ConversionFlags.ShowReturnType | ConversionFlags.ShowParameterNames; } catch (Exception) { - Console.WriteLine("VBNet ambience not found -- is the VB.NET backend binding loaded???"); + LoggingService.Warn("VBNet ambience not found -- is the VB.NET backend binding loaded???"); } } diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionData.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionData.cs index 1064e8a551..4c5c72d4f7 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionData.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionData.cs @@ -121,7 +121,6 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor ambience.ConversionFlags = ConversionFlags.None; text = ambience.Convert(c); ambience.ConversionFlags = ConversionFlags.UseFullyQualifiedNames | ConversionFlags.ShowReturnType | ConversionFlags.ShowModifiers; -// Console.WriteLine("Convert : " + c); description = ambience.Convert(c); documentation = c.Documentation; GetPriority(c.DotNetName); @@ -277,7 +276,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor } } while(xml.Read()); } catch (Exception ex) { - Console.WriteLine("Invalid XML documentation: " + ex.Message); + LoggingService.Debug("Invalid XML documentation: " + ex.Message); return doc; } return ret.ToString(); diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionDataProvider.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionDataProvider.cs index e7bc8c4ebc..5df4b39a96 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionDataProvider.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionDataProvider.cs @@ -36,6 +36,12 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor if (expressionResult.Expression == null || expressionResult.Expression.Length == 0) { return; } + if (LoggingService.IsDebugEnabled) { + if (expressionResult.Context == ExpressionContext.Default) + LoggingService.DebugFormatted("GenerateCompletionData for >>{0}<<", expressionResult.Expression); + else + LoggingService.DebugFormatted("GenerateCompletionData for >>{0}<<, context={1}", expressionResult.Expression, expressionResult.Context); + } #if DEBUG if (DebugMode) { Debugger.Break(); diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionDataUsageCache.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionDataUsageCache.cs index b4e351081e..15edfc53b4 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionDataUsageCache.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionDataUsageCache.cs @@ -64,11 +64,11 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor using (FileStream fs = new FileStream(CacheFilename, FileMode.Open, FileAccess.Read)) { using (BinaryReader reader = new BinaryReader(fs)) { if (reader.ReadInt64() != magic) { - Console.WriteLine("CodeCompletionDataUsageCache: wrong file magic"); + LoggingService.Warn("CodeCompletionDataUsageCache: wrong file magic"); return; } if (reader.ReadInt16() != version) { - Console.WriteLine("CodeCompletionDataUsageCache: unknown file version"); + LoggingService.Warn("CodeCompletionDataUsageCache: unknown file version"); return; } int itemCount = reader.ReadInt32(); @@ -86,7 +86,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor } } } - Console.WriteLine("Loaded CodeCompletionDataUsageCache (" + dict.Count + " items)"); + LoggingService.Info("Loaded CodeCompletionDataUsageCache (" + dict.Count + " items)"); } public static void SaveCache() @@ -100,7 +100,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor count = SaveCache(writer); } } - Console.WriteLine("Saved CodeCompletionDataUsageCache (" + count + " of " + dict.Count + " items)"); + LoggingService.Info("Saved CodeCompletionDataUsageCache (" + count + " of " + dict.Count + " items)"); } static int SaveCache(BinaryWriter writer) @@ -155,7 +155,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor File.Delete(CacheFilename); } } catch (Exception ex) { - Console.WriteLine("CodeCompletionDataUsageCache.ResetCache(): " + ex.Message); + LoggingService.Warn("CodeCompletionDataUsageCache.ResetCache(): " + ex.Message); } } diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/InsightWindow/MethodInsightDataProvider.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/InsightWindow/MethodInsightDataProvider.cs index 1b97e36a79..a93a5e9418 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/InsightWindow/MethodInsightDataProvider.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/InsightWindow/MethodInsightDataProvider.cs @@ -110,6 +110,13 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor return; expressionResult.Expression = expressionResult.Expression.Trim(); + if (LoggingService.IsDebugEnabled) { + if (expressionResult.Context == ExpressionContext.Default) + LoggingService.DebugFormatted("ShowInsight for >>{0}<<", expressionResult.Expression); + else + LoggingService.DebugFormatted("ShowInsight for >>{0}<<, context={1}", expressionResult.Expression, expressionResult.Context); + } + // the parser works with 1 based coordinates int caretLineNumber = document.GetLineNumberForOffset(useOffset) + 1; int caretColumn = useOffset - document.GetLineSegment(caretLineNumber).Offset + 1; @@ -119,11 +126,11 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor protected virtual void SetupDataProvider(string fileName, IDocument document, ExpressionResult expressionResult, int caretLineNumber, int caretColumn) { bool constructorInsight = false; - if (expressionResult.Context.IsObjectCreation) { + if (expressionResult.Context == ExpressionContext.Attribute) { constructorInsight = true; - expressionResult.Context = ExpressionContext.Type; - } else if (expressionResult.Context == ExpressionContext.Attribute) { + } else if (expressionResult.Context.IsObjectCreation) { constructorInsight = true; + expressionResult.Context = ExpressionContext.Type; } ResolveResult results = ParserService.Resolve(expressionResult, caretLineNumber, caretColumn, fileName, document.TextContent); if (constructorInsight) { diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/QuickClassBrowserPanel.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/QuickClassBrowserPanel.cs index 42799649c3..15eeb29481 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/QuickClassBrowserPanel.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/QuickClassBrowserPanel.cs @@ -500,11 +500,9 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor // font - has to be static - don't create on each draw static Font font = font = new Font("Arial", 8.25f); static StringFormat drawStringFormat = new StringFormat(StringFormatFlags.NoWrap); -// static int drawingCount = 0; void ComboBoxDrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { -// Console.WriteLine("Draw " + (drawingCount++)); ComboBox comboBox = (ComboBox)sender; e.DrawBackground(); diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextAreaControl.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextAreaControl.cs index 892d5ea468..0a32aca853 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextAreaControl.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextAreaControl.cs @@ -163,7 +163,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor } } } catch (TreePathNotFoundException) { - Console.WriteLine(editActionsPath + " doesn't exists in the AddInTree"); + LoggingService.Warn("EditAction " + editActionsPath + " doesn't exists in the AddInTree"); } } diff --git a/src/Main/Core/Project/ICSharpCode.Core.csproj b/src/Main/Core/Project/ICSharpCode.Core.csproj index d154ea39ac..415e986987 100644 --- a/src/Main/Core/Project/ICSharpCode.Core.csproj +++ b/src/Main/Core/Project/ICSharpCode.Core.csproj @@ -35,6 +35,10 @@ <Reference Include="System.Drawing" /> <Reference Include="System.Windows.Forms" /> <Reference Include="System.XML" /> + <Reference Include="log4net"> + <HintPath>..\..\..\Libraries\log4net\bin\net\1.1\release\log4net.dll</HintPath> + <SpecificVersion>False</SpecificVersion> + </Reference> </ItemGroup> <ItemGroup> <None Include="Resources\ICSharpCode.Core.doc" /> @@ -128,6 +132,10 @@ </Compile> <Compile Include="Src\AddInTree\AddIn\IBuildItemsModifier.cs" /> <Compile Include="Src\AddInTree\AddIn\DefaultDoozers\IncludeDoozer.cs" /> + <Compile Include="Src\Services\LoggingService\LoggingService.cs" /> + </ItemGroup> + <ItemGroup> + <Folder Include="Src\Services\LoggingService" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> </Project> \ No newline at end of file diff --git a/src/Main/Core/Project/Src/AddInTree/AddIn/AddIn.cs b/src/Main/Core/Project/Src/AddInTree/AddIn/AddIn.cs index d878faa854..712c419785 100644 --- a/src/Main/Core/Project/Src/AddInTree/AddIn/AddIn.cs +++ b/src/Main/Core/Project/Src/AddInTree/AddIn/AddIn.cs @@ -32,7 +32,7 @@ namespace ICSharpCode.Core return o; } } - Console.WriteLine("Cannot create object: " + className); + LoggingService.Error("Cannot create object: " + className); if (!hasShownErrorMessage) { hasShownErrorMessage = true; MessageService.ShowError("Cannot create object: " + className + "\nFuture missing objects will not cause an error message."); diff --git a/src/Main/Core/Project/Src/AddInTree/AddIn/Codon.cs b/src/Main/Core/Project/Src/AddInTree/AddIn/Codon.cs index 8f64740798..4bc18693ef 100644 --- a/src/Main/Core/Project/Src/AddInTree/AddIn/Codon.cs +++ b/src/Main/Core/Project/Src/AddInTree/AddIn/Codon.cs @@ -102,8 +102,8 @@ namespace ICSharpCode.Core return action = ConditionFailedAction.Exclude; } } - } catch (Exception) { - Console.WriteLine("Exception in AddIn : " + addIn.FileName); + } catch { + LoggingService.Error("Exception while getting failed action from " + addIn.FileName); throw; } } diff --git a/src/Main/Core/Project/Src/AddInTree/AddIn/Runtime.cs b/src/Main/Core/Project/Src/AddInTree/AddIn/Runtime.cs index 4011f991eb..d31c7d120e 100644 --- a/src/Main/Core/Project/Src/AddInTree/AddIn/Runtime.cs +++ b/src/Main/Core/Project/Src/AddInTree/AddIn/Runtime.cs @@ -38,9 +38,7 @@ namespace ICSharpCode.Core public Assembly LoadedAssembly { get { if (!isAssemblyLoaded) { - #if DEBUG - Console.WriteLine("Loading addin " + assembly + "..."); - #endif + LoggingService.Info("Loading addin " + assembly); isAssemblyLoaded = true; diff --git a/src/Main/Core/Project/Src/AddInTree/AddInTreeNode.cs b/src/Main/Core/Project/Src/AddInTree/AddInTreeNode.cs index 565aa7792e..c9955ef251 100644 --- a/src/Main/Core/Project/Src/AddInTree/AddInTreeNode.cs +++ b/src/Main/Core/Project/Src/AddInTree/AddInTreeNode.cs @@ -89,7 +89,7 @@ namespace ICSharpCode.Core codons[indexOfName[before]].InsertAfter = after + ',' + codons[i].Id; } } else { - Console.WriteLine("Codon ({0}) specified in the insertbefore of the {1} codon does not exist!", before, codons[i]); + LoggingService.WarnFormatted("Codon ({0}) specified in the insertbefore of the {1} codon does not exist!", before, codons[i]); } } } @@ -119,7 +119,7 @@ namespace ICSharpCode.Core if (indexOfName.ContainsKey(s)) { Visit(indexOfName[s]); } else { - Console.WriteLine("Codon ({0}) specified in the insertafter of the {1} codon does not exist!", codons[codonIndex].InsertAfter, codons[codonIndex]); + LoggingService.WarnFormatted("Codon ({0}) specified in the insertafter of the {1} codon does not exist!", codons[codonIndex].InsertAfter, codons[codonIndex]); } } sortedCodons.Add(codons[codonIndex]); diff --git a/src/Main/Core/Project/Src/Services/LoggingService/LoggingService.cs b/src/Main/Core/Project/Src/Services/LoggingService/LoggingService.cs new file mode 100644 index 0000000000..9370bea46f --- /dev/null +++ b/src/Main/Core/Project/Src/Services/LoggingService/LoggingService.cs @@ -0,0 +1,120 @@ +// <file> +// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright> +// <license see="prj:///doc/license.txt">GNU General Public License</license> +// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/> +// <version>$Revision$</version> +// </file> + +using System; +using System.IO; +using log4net; +using log4net.Core; +using log4net.Config; + +namespace ICSharpCode.Core +{ + public static class LoggingService + { + static readonly ILog log = LogManager.GetLogger(typeof(LoggingService)); + + static LoggingService() + { + XmlConfigurator.ConfigureAndWatch(new FileInfo(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile)); + } + + public static void Debug(object message) + { + log.Debug(message); + } + + public static void DebugFormatted(string format, params object[] args) + { + log.DebugFormat(format, args); + } + + public static void Info(object message) + { + log.Info(message); + } + + public static void InfoFormatted(string format, params object[] args) + { + log.InfoFormat(format, args); + } + + public static void Warn(object message) + { + log.Warn(message); + } + + public static void Warn(object message, Exception exception) + { + log.Warn(message, exception); + } + + public static void WarnFormatted(string format, params object[] args) + { + log.WarnFormat(format, args); + } + + public static void Error(object message) + { + log.Error(message); + } + + public static void Error(object message, Exception exception) + { + log.Error(message, exception); + } + + public static void ErrorFormatted(string format, params object[] args) + { + log.ErrorFormat(format, args); + } + + public static void Fatal(object message) + { + log.Fatal(message); + } + + public static void Fatal(object message, Exception exception) + { + log.Fatal(message, exception); + } + + public static void FatalFormatted(string format, params object[] args) + { + log.FatalFormat(format, args); + } + + public static bool IsDebugEnabled { + get { + return log.IsDebugEnabled; + } + } + + public static bool IsInfoEnabled { + get { + return log.IsInfoEnabled; + } + } + + public static bool IsWarnEnabled { + get { + return log.IsWarnEnabled; + } + } + + public static bool IsErrorEnabled { + get { + return log.IsErrorEnabled; + } + } + + public static bool IsFatalEnabled { + get { + return log.IsFatalEnabled; + } + } + } +} diff --git a/src/Main/Core/Project/Src/Services/MessageService/MessageService.cs b/src/Main/Core/Project/Src/Services/MessageService/MessageService.cs index 7959fba937..a1b366e2dd 100644 --- a/src/Main/Core/Project/Src/Services/MessageService/MessageService.cs +++ b/src/Main/Core/Project/Src/Services/MessageService/MessageService.cs @@ -62,17 +62,18 @@ namespace ICSharpCode.Core public static void ShowError(Exception ex, string message) { - if (customErrorReporter != null && ex != null) { - customErrorReporter(ex, message); - return; + if (ex != null) { + LoggingService.Error(message, ex); + if (customErrorReporter != null) { + customErrorReporter(ex, message); + return; + } + } else { + LoggingService.Error(message); } #if DEBUG - Console.WriteLine(); - if (message != null) - Console.WriteLine(message); if (ex != null) { - Console.WriteLine(ex); Console.Beep(); return; } @@ -96,7 +97,9 @@ namespace ICSharpCode.Core public static void ShowWarning(string message) { - MessageBox.Show(MessageService.MainForm, StringParser.Parse(message), StringParser.Parse("${res:Global.WarningText}"), MessageBoxButtons.OK, MessageBoxIcon.Warning); + message = StringParser.Parse(message); + LoggingService.Warn(message); + MessageBox.Show(MessageService.MainForm, message, StringParser.Parse("${res:Global.WarningText}"), MessageBoxButtons.OK, MessageBoxIcon.Warning); } public static void ShowWarningFormatted(string formatstring, params string[] formatitems) @@ -162,7 +165,9 @@ namespace ICSharpCode.Core public static void ShowMessage(string message, string caption) { - MessageBox.Show(mainForm, StringParser.Parse(message), StringParser.Parse(caption), MessageBoxButtons.OK, MessageBoxIcon.Information); + message = StringParser.Parse(message); + LoggingService.Info(message); + MessageBox.Show(mainForm, message, StringParser.Parse(caption), MessageBoxButtons.OK, MessageBoxIcon.Information); } static string Format(string formatstring, string[] formatitems) diff --git a/src/Main/StartUp/Project/SharpDevelop.exe.config b/src/Main/StartUp/Project/SharpDevelop.exe.config index 8496319c51..67038f51ae 100644 --- a/src/Main/StartUp/Project/SharpDevelop.exe.config +++ b/src/Main/StartUp/Project/SharpDevelop.exe.config @@ -1,4 +1,7 @@ <configuration> + <configSections> + <section name="log4net" type="System.Configuration.IgnoreSectionHandler" /> + </configSections> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> @@ -19,4 +22,36 @@ </dependentAssembly> </assemblyBinding> </runtime> + <log4net> + <appender name="ColoredConsoleAppender" type="log4net.Appender.ColoredConsoleAppender"> + <mapping> + <level value="FATAL" /> + <foreColor value="Red, HighIntensity" /> + </mapping> + <mapping> + <level value="ERROR" /> + <foreColor value="Red" /> + </mapping> + <mapping> + <level value="WARN" /> + <foreColor value="Yellow" /> + </mapping> + <mapping> + <level value="INFO" /> + <foreColor value="White" /> + </mapping> + <mapping> + <level value="DEBUG" /> + <foreColor value="Green" /> + </mapping> + <layout type="log4net.Layout.PatternLayout"> + <conversionPattern value="%date [%thread] %-5level- %message%newline" /> + </layout> + </appender> + + <root> + <level value="DEBUG" /> + <appender-ref ref="ColoredConsoleAppender" /> + </root> + </log4net> </configuration> diff --git a/src/Main/StartUp/Project/SharpDevelopMain.cs b/src/Main/StartUp/Project/SharpDevelopMain.cs index c45bfadf3b..5ef8c92407 100644 --- a/src/Main/StartUp/Project/SharpDevelopMain.cs +++ b/src/Main/StartUp/Project/SharpDevelopMain.cs @@ -41,6 +41,7 @@ namespace ICSharpCode.SharpDevelop static void ShowErrorBox(object sender, ThreadExceptionEventArgs eargs) { + LoggingService.Error("ThreadException caught", eargs.Exception); ShowErrorBox(eargs.Exception, null); } @@ -55,54 +56,45 @@ namespace ICSharpCode.SharpDevelop } } - readonly static string[] assemblyList = { - "Microsoft.VisualBasic.dll", - "Microsoft.JScript.dll", - "mscorlib.dll", - "System.Data.dll", - "System.Design.dll", - "System.DirectoryServices.dll", - "System.Drawing.Design.dll", - "System.Drawing.dll", - "System.EnterpriseServices.dll", - "System.Management.dll", - "System.Messaging.dll", - "System.Runtime.Remoting.dll", - "System.Runtime.Serialization.Formatters.Soap.dll", - - "System.Security.dll", - "System.ServiceProcess.dll", - "System.Web.Services.dll", - "System.Web.dll", - "System.Windows.Forms.dll", - "System.dll", - "System.XML.dll" - }; - /// <summary> /// Starts the core of SharpDevelop. /// </summary> [STAThread()] public static void Main(string[] args) { + #if DEBUG if (Debugger.IsAttached) { Run(args); - } else { - try { - Run(args); - } catch (Exception ex) { - Console.WriteLine(ex); - try { - Application.Run(new ExceptionBox(ex, "Unhandled exception terminated SharpDevelop")); - } catch { - MessageBox.Show(ex.ToString(), "Critical error (cannot use ExceptionBox)"); - } - } + return; + } + #endif + // Do not use LoggingService here (see comment in Run(string[])) + try { + Run(args); + } catch (Exception ex) { + HandleMainException(ex); + } + } + + static void HandleMainException(Exception ex) + { + LoggingService.Fatal(ex); + try { + Application.Run(new ExceptionBox(ex, "Unhandled exception terminated SharpDevelop")); + } catch { + MessageBox.Show(ex.ToString(), "Critical error (cannot use ExceptionBox)"); } } static void Run(string[] args) { + // DO NOT USE LoggingService HERE! + // LoggingService requires ICSharpCode.Core.dll and log4net.dll + // When a method containing a call to LoggingService is JITted, the + // libraries are loaded. + // We want to show the SplashScreen while those libraries are loaded, so + // don't call LoggingService. + #if DEBUG Control.CheckForIllegalCrossThreadCalls = true; #endif @@ -133,18 +125,36 @@ namespace ICSharpCode.SharpDevelop static void RunApplication() { - if (!Debugger.IsAttached) { - Application.ThreadException += ShowErrorBox; + LoggingService.Info("Starting SharpDevelop..."); + try { + if (!Debugger.IsAttached) { + Application.ThreadException += ShowErrorBox; + } + #if !DEBUG + MessageService.CustomErrorReporter = ShowErrorBox; + #endif + + RegisterDoozers(); + + InitializeCore(); + + // finally start the workbench. + try { + LoggingService.Info("Starting workbench..."); + new StartWorkbenchCommand().Run(SplashScreenForm.GetRequestedFileList()); + } finally { + LoggingService.Info("Unloading services..."); + ProjectService.CloseSolution(); + FileService.Unload(); + PropertyService.Save(); + } + } finally { + LoggingService.Info("Leaving RunApplication()"); } - #if !DEBUG - MessageService.CustomErrorReporter = ShowErrorBox; - #endif - -// TODO: -// bool ignoreDefaultPath = false; -// string [] addInDirs = ICSharpCode.SharpDevelop.AddInSettingsHandler.GetAddInDirectories(out ignoreDefaultPath); -// SetAddInDirectories(addInDirs, ignoreDefaultPath); - + } + + static void RegisterDoozers() + { AddInTree.ConditionEvaluators.Add("ActiveContentExtension", new ActiveContentExtensionConditionEvaluator()); AddInTree.ConditionEvaluators.Add("ActiveViewContentUntitled", new ActiveViewContentUntitledConditionEvaluator()); AddInTree.ConditionEvaluators.Add("ActiveWindowState", new ActiveWindowStateConditionEvaluator()); @@ -171,43 +181,38 @@ namespace ICSharpCode.SharpDevelop AddInTree.Doozers.Add("Debugger", new DebuggerDoozer()); MenuCommand.LinkCommandCreator = delegate(string link) { return new LinkCommand(link); }; - + } + + static void InitializeCore() + { + LoggingService.Info("Loading properties..."); PropertyService.Load(); StringParser.RegisterStringTagProvider(new SharpDevelopStringTagProvider()); + LoggingService.Info("Loading AddInTree..."); AddInTree.Load(); + LoggingService.Info("Initializing workbench..."); // .NET base autostarts // taken out of the add-in tree for performance reasons (every tick in startup counts) new InitializeWorkbenchCommand().Run(); // run workspace autostart commands try { + LoggingService.Info("Running autostart commands..."); foreach (ICommand command in AddInTree.BuildItems("/Workspace/Autostart", null, false)) { command.Run(); } } catch (XmlException e) { + LoggingService.Error("Could not load XML", e); MessageBox.Show("Could not load XML :" + Environment.NewLine + e.Message); return; - } catch (Exception e) { - MessageBox.Show("Loading error, please reinstall :" + Environment.NewLine + e.ToString()); - return; } finally { if (SplashScreenForm.SplashScreen != null) { SplashScreenForm.SplashScreen.Dispose(); } } - - // finally start the workbench. - try { - new StartWorkbenchCommand().Run(SplashScreenForm.GetRequestedFileList()); - } finally { - // unloading - ProjectService.CloseSolution(); - FileService.Unload(); - PropertyService.Save(); - } } } }