From d62435fb2385a4bf67bb76e8f80c7bc6072c7288 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Mon, 25 Jul 2005 17:14:20 +0000 Subject: [PATCH] Ported some fixes for unit test mode from Fidalgo rev. 2014. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@256 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../AbstractCompletionDataProvider.cs | 1 - .../Core/Project/Src/AddInTree/AddInTree.cs | 8 +--- .../Src/Services/FileUtility/FileUtility.cs | 18 +++------ .../Src/Services/MessageService/InputBox.cs | 1 - .../PropertyService/PropertyService.cs | 2 +- .../ResourceService/ResourceService.cs | 37 +++++++------------ 6 files changed, 21 insertions(+), 46 deletions(-) diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/AbstractCompletionDataProvider.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/AbstractCompletionDataProvider.cs index b58e29d115..53ff3abede 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/AbstractCompletionDataProvider.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/AbstractCompletionDataProvider.cs @@ -87,7 +87,6 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor if (list == null) { return; } - System.Diagnostics.Debugger.Break(); completionData.Capacity += list.Count; CodeCompletionData suggestedData = null; foreach (object o in list) { diff --git a/src/Main/Core/Project/Src/AddInTree/AddInTree.cs b/src/Main/Core/Project/Src/AddInTree/AddInTree.cs index 2801e4e148..3406157749 100644 --- a/src/Main/Core/Project/Src/AddInTree/AddInTree.cs +++ b/src/Main/Core/Project/Src/AddInTree/AddInTree.cs @@ -28,13 +28,7 @@ namespace ICSharpCode.Core static AddInTree() { - try { - // might fail in unit test mode - Assembly entryAssembly = Assembly.GetEntryAssembly(); - defaultCoreDirectory = FileUtility.Combine(Path.GetDirectoryName(entryAssembly.Location), "..", "AddIns"); - } catch (Exception) { - defaultCoreDirectory = ""; - } + defaultCoreDirectory = FileUtility.Combine(FileUtility.SharpDevelopRootPath, "AddIns"); erbauer.Add("Class", new ClassErbauer()); erbauer.Add("FileFilter", new FileFilterErbauer()); diff --git a/src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs b/src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs index 2fc12e26af..975e5fa7b9 100644 --- a/src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs +++ b/src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs @@ -74,7 +74,7 @@ namespace ICSharpCode.Core } } - public static string[] GetAvaiableRuntimeVersions() + public static string[] GetAvailableRuntimeVersions() { string installRoot = NETFrameworkInstallRoot; string[] files = Directory.GetDirectories(installRoot); @@ -95,19 +95,11 @@ namespace ICSharpCode.Core return String.Empty; } - if (paths.Length == 1) { - return paths[0]; + string result = paths[0]; + for (int i = 1; i < paths.Length; i++) { + result = Path.Combine(result, paths[i]); } - - string[] newPaths = new string[paths.Length - 1]; - - newPaths[0] = Path.Combine(paths[0], paths[1]); - - Array.Copy(paths, 2, - newPaths, 1, - paths.Length - 2); - - return Combine(newPaths); + return result; } diff --git a/src/Main/Core/Project/Src/Services/MessageService/InputBox.cs b/src/Main/Core/Project/Src/Services/MessageService/InputBox.cs index 40c8407c0c..f21de9479a 100644 --- a/src/Main/Core/Project/Src/Services/MessageService/InputBox.cs +++ b/src/Main/Core/Project/Src/Services/MessageService/InputBox.cs @@ -109,7 +109,6 @@ namespace ICSharpCode.Core // InputBox // this.AcceptButton = this.acceptButton; - this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.CancelButton = this.cancelButton; this.ClientSize = new System.Drawing.Size(338, 144); this.Controls.Add(this.textBox); diff --git a/src/Main/Core/Project/Src/Services/PropertyService/PropertyService.cs b/src/Main/Core/Project/Src/Services/PropertyService/PropertyService.cs index 63a3c91438..161191a476 100644 --- a/src/Main/Core/Project/Src/Services/PropertyService/PropertyService.cs +++ b/src/Main/Core/Project/Src/Services/PropertyService/PropertyService.cs @@ -19,7 +19,7 @@ namespace ICSharpCode.Core const string propertyXmlRootNodeName = "SharpDevelopProperties"; static string configDirectory = FileUtility.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ".ICSharpCode", "Corsavy") + Path.DirectorySeparatorChar; - static string dataDirectory = FileUtility.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "..", "data"); + static string dataDirectory = FileUtility.Combine(FileUtility.SharpDevelopRootPath, "data"); static Properties properties = new Properties(); diff --git a/src/Main/Core/Project/Src/Services/ResourceService/ResourceService.cs b/src/Main/Core/Project/Src/Services/ResourceService/ResourceService.cs index fead296fdf..50f8c8ca48 100644 --- a/src/Main/Core/Project/Src/Services/ResourceService/ResourceService.cs +++ b/src/Main/Core/Project/Src/Services/ResourceService/ResourceService.cs @@ -24,18 +24,18 @@ namespace ICSharpCode.Core /// This Class contains two ResourceManagers, which handle string and image resources /// for the application. It do handle localization strings on this level. /// - public sealed class ResourceService + public static class ResourceService { readonly static string uiLanguageProperty = "CoreProperties.UILanguage"; readonly static string stringResources = "StringResources"; readonly static string imageResources = "BitmapResources"; - static string resourceDirctory; + static string resourceDirectory; static ResourceService() { - resourceDirctory = FileUtility.Combine(PropertyService.DataDirectory, "resources"); + resourceDirectory = FileUtility.Combine(PropertyService.DataDirectory, "resources"); LoadLanguageResources(); } @@ -58,8 +58,8 @@ namespace ICSharpCode.Core static void ChangeProperty(object sender, PropertyChangedEventArgs e) { if (e.Key == uiLanguageProperty && e.OldValue != e.NewValue) { - LoadLanguageResources(); - } + LoadLanguageResources(); + } } static void LoadLanguageResources() @@ -73,7 +73,7 @@ namespace ICSharpCode.Core Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(language.Split('-')[0]); } catch (Exception) {} } -// TODO: AppSettings is obsolete + // TODO: AppSettings is obsolete // if (System.Configuration.ConfigurationSettings.AppSettings["UserStrings"] != null) { // string resourceName = System.Configuration.ConfigurationSettings.AppSettings["UserStrings"]; // resourceName = resourceName.Insert(resourceName.LastIndexOf(".resources"), "." + language); @@ -103,7 +103,7 @@ namespace ICSharpCode.Core localStringsResMgrs.Add(new ResourceManager("Resources." + stringResources, assembly)); } - if (assembly.GetManifestResourceInfo("Resources." + imageResources + ".resources") != null) { + if (assembly.GetManifestResourceInfo("Resources." + imageResources + ".resources") != null) { localIconsResMgrs.Add(new ResourceManager("Resources." + imageResources, assembly)); } } @@ -111,25 +111,16 @@ namespace ICSharpCode.Core static void InitializeService() { - RegisterAssembly(Assembly.GetEntryAssembly()); + Assembly assembly = Assembly.GetEntryAssembly(); + if (assembly != null) { + RegisterAssembly(assembly); + } PropertyService.PropertyChanged += new PropertyChangedEventHandler(ChangeProperty); LoadLanguageResources(); } - // core service : Can't use Initialize, because all other stuff needs this service before initialize is called. - ResourceService() - { -// if (System.Configuration.ConfigurationSettings.AppSettings["UserStrings"] != null) { -// userStrings = Load(resourceDirctory + Path.DirectorySeparatorChar + System.Configuration.ConfigurationSettings.AppSettings["UserStrings"]); -// } -// if (System.Configuration.ConfigurationSettings.AppSettings["UserIcons"] != null) { -// userIcons = Load(resourceDirctory + Path.DirectorySeparatorChar + System.Configuration.ConfigurationSettings.AppSettings["UserIcons"]); -// } - InitializeService(); - } - /// /// The LoadFont routines provide a safe way to load fonts. /// @@ -210,7 +201,7 @@ namespace ICSharpCode.Core static Hashtable Load(string name, string language) { - return Load(resourceDirctory + Path.DirectorySeparatorChar + name + "." + language + ".resources"); + return Load(resourceDirectory + Path.DirectorySeparatorChar + name + "." + language + ".resources"); } @@ -238,7 +229,7 @@ namespace ICSharpCode.Core if (localStrings != null && localStrings[name] != null) { return localStrings[name].ToString(); } - + string s = null; foreach (ResourceManager resourceManger in localStringsResMgrs) { s = resourceManger.GetString(name); @@ -337,7 +328,7 @@ namespace ICSharpCode.Core /// /// Returns a bitmap from the resource database, it handles localization - /// transparent for the user. + /// transparent for the user. /// /// /// The bitmap in the (localized) resource database.