From 23cad81544d09171731b888c3b9612c82a644269 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Fri, 27 Jul 2012 21:55:22 +0200 Subject: [PATCH] Add IAddInTree to ICSharpCode.Core to allow mocking BuildItems() calls. --- SharpDevelop.Tests.sln | 18 +++++- .../Implementation/UnitTestAddInTree.cs | 17 ------ .../UnitTesting/Interfaces/IAddInTree.cs | 13 ----- .../Service/RegisteredTestFrameworks.cs | 4 +- .../UnitTesting/Service/TestService.cs | 3 +- .../Analysis/UnitTesting/UnitTesting.csproj | 2 - .../Tests/OverrideCompletionTests.cs | 38 ++++++++---- src/AddIns/Misc/HelpViewer/Source/Commands.cs | 6 +- .../Services/ProjectService/ProjectService.cs | 1 - src/Main/Base/Project/Src/Services/SD.cs | 4 ++ src/Main/Base/Test/CheckAssemblyFlags.cs | 2 +- src/Main/Core/Project/ICSharpCode.Core.csproj | 4 +- .../Core/Project/Src/AddInTree/AddIn/Codon.cs | 15 ----- .../Project/Src/AddInTree/AddIn/Runtime.cs | 4 +- .../Core/Project/Src/AddInTree/AddInTree.cs | 16 +---- .../Project/Src/AddInTree/AddInTreeImpl.cs | 30 ++++++++++ .../Project/Src/AddInTree/AddInTreeNode.cs | 10 ---- .../Core/Project/Src/AddInTree/IAddInTree.cs | 47 +++++++++++++++ .../RegistryService/RegistryService.cs | 58 ------------------- src/Main/Core/Test/Utils/DerivedRuntime.cs | 2 +- 20 files changed, 142 insertions(+), 152 deletions(-) delete mode 100644 src/AddIns/Analysis/UnitTesting/Implementation/UnitTestAddInTree.cs delete mode 100644 src/AddIns/Analysis/UnitTesting/Interfaces/IAddInTree.cs create mode 100644 src/Main/Core/Project/Src/AddInTree/AddInTreeImpl.cs create mode 100644 src/Main/Core/Project/Src/AddInTree/IAddInTree.cs delete mode 100644 src/Main/Core/Project/Src/Services/RegistryService/RegistryService.cs diff --git a/SharpDevelop.Tests.sln b/SharpDevelop.Tests.sln index 7668a63364..852da15eef 100644 --- a/SharpDevelop.Tests.sln +++ b/SharpDevelop.Tests.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -# SharpDevelop 4.2.0.8783 +# SharpDevelop 4.3 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Main", "Main", "{256F5C28-532C-44C0-8AB8-D8EC5E492E01}" ProjectSection(SolutionItems) = postProject EndProjectSection @@ -131,6 +131,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.AddIn", "src\AddIn EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.Tests", "src\AddIns\Debugger\Debugger.Tests\Debugger.Tests.csproj", "{A4C858C8-51B6-4265-A695-A20FCEBA1D19}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Analysis", "Analysis", "{B3352C08-3CB4-4DD9-996F-B9DCE4356BB9}" + ProjectSection(SolutionItems) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting", "src\AddIns\Analysis\UnitTesting\UnitTesting.csproj", "{1F261725-6318-4434-A1B1-6C70CE4CD324}" +EndProject Project("{00000000-0000-0000-0000-000000000000}") = "Tools", "src\Tools\Tools.build", "{3DF4060F-5EE0-41CF-8096-F27355FD5511}" EndProject Global @@ -501,6 +507,14 @@ Global {A4C858C8-51B6-4265-A695-A20FCEBA1D19}.Release|Any CPU.ActiveCfg = Release|Any CPU {A4C858C8-51B6-4265-A695-A20FCEBA1D19}.Release|x86.Build.0 = Release|Any CPU {A4C858C8-51B6-4265-A695-A20FCEBA1D19}.Release|x86.ActiveCfg = Release|Any CPU + {1F261725-6318-4434-A1B1-6C70CE4CD324}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F261725-6318-4434-A1B1-6C70CE4CD324}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F261725-6318-4434-A1B1-6C70CE4CD324}.Debug|x86.Build.0 = Debug|Any CPU + {1F261725-6318-4434-A1B1-6C70CE4CD324}.Debug|x86.ActiveCfg = Debug|Any CPU + {1F261725-6318-4434-A1B1-6C70CE4CD324}.Release|Any CPU.Build.0 = Release|Any CPU + {1F261725-6318-4434-A1B1-6C70CE4CD324}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F261725-6318-4434-A1B1-6C70CE4CD324}.Release|x86.Build.0 = Release|Any CPU + {1F261725-6318-4434-A1B1-6C70CE4CD324}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -532,6 +546,7 @@ Global {F3662720-9EA2-4591-BBC6-97361DCE50A9} = {39327899-ED91-4F7F-988C-4FE4E17C014D} {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} = {39327899-ED91-4F7F-988C-4FE4E17C014D} {AF5E0DC1-1FA0-4346-A436-0C817C68F7C1} = {39327899-ED91-4F7F-988C-4FE4E17C014D} + {B3352C08-3CB4-4DD9-996F-B9DCE4356BB9} = {39327899-ED91-4F7F-988C-4FE4E17C014D} {83F15BA7-8478-4664-81BB-A82F146D88B3} = {F208FF4F-E5D8-41D5-A7C7-B463976F156E} {17F4D7E0-6933-4C2E-8714-FD7E98D625D5} = {F208FF4F-E5D8-41D5-A7C7-B463976F156E} {1F1AC7CD-D154-45BB-8EAF-804CA8055F5A} = {E0646C25-36F2-4524-969F-FA621353AB94} @@ -557,5 +572,6 @@ Global {1D18D788-F7EE-4585-A23B-34DC8EC63CB8} = {AF5E0DC1-1FA0-4346-A436-0C817C68F7C1} {EC06F96A-AEEC-49D6-B03D-AB87C6EB674C} = {AF5E0DC1-1FA0-4346-A436-0C817C68F7C1} {A4C858C8-51B6-4265-A695-A20FCEBA1D19} = {AF5E0DC1-1FA0-4346-A436-0C817C68F7C1} + {1F261725-6318-4434-A1B1-6C70CE4CD324} = {B3352C08-3CB4-4DD9-996F-B9DCE4356BB9} EndGlobalSection EndGlobal diff --git a/src/AddIns/Analysis/UnitTesting/Implementation/UnitTestAddInTree.cs b/src/AddIns/Analysis/UnitTesting/Implementation/UnitTestAddInTree.cs deleted file mode 100644 index a280718375..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Implementation/UnitTestAddInTree.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; -using ICSharpCode.Core; - -namespace ICSharpCode.UnitTesting -{ - public class UnitTestAddInTree : IAddInTree - { - public List BuildItems(string path, object caller) - { - return AddInTree.BuildItems(path, caller); - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Interfaces/IAddInTree.cs b/src/AddIns/Analysis/UnitTesting/Interfaces/IAddInTree.cs deleted file mode 100644 index 11b6baa3e6..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Interfaces/IAddInTree.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; - -namespace ICSharpCode.UnitTesting -{ - public interface IAddInTree - { - List BuildItems(string path, object caller); - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Service/RegisteredTestFrameworks.cs b/src/AddIns/Analysis/UnitTesting/Service/RegisteredTestFrameworks.cs index 27739e45e7..7815abd37e 100644 --- a/src/AddIns/Analysis/UnitTesting/Service/RegisteredTestFrameworks.cs +++ b/src/AddIns/Analysis/UnitTesting/Service/RegisteredTestFrameworks.cs @@ -4,6 +4,8 @@ using System; using System.Collections.Generic; using System.Linq; + +using ICSharpCode.Core; using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.SharpDevelop.Project; @@ -11,7 +13,7 @@ namespace ICSharpCode.UnitTesting { public class RegisteredTestFrameworks : IRegisteredTestFrameworks { - List testFrameworkDescriptors; + IReadOnlyList testFrameworkDescriptors; public const string AddInPath = "/SharpDevelop/UnitTesting/TestFrameworks"; public RegisteredTestFrameworks(IAddInTree addInTree) diff --git a/src/AddIns/Analysis/UnitTesting/Service/TestService.cs b/src/AddIns/Analysis/UnitTesting/Service/TestService.cs index 463027346a..683ce7bce2 100644 --- a/src/AddIns/Analysis/UnitTesting/Service/TestService.cs +++ b/src/AddIns/Analysis/UnitTesting/Service/TestService.cs @@ -28,8 +28,7 @@ namespace ICSharpCode.UnitTesting static void CreateRegisteredTestFrameworks() { if (testFrameworks == null) { - UnitTestAddInTree addInTree = new UnitTestAddInTree(); - testFrameworks = new RegisteredTestFrameworks(addInTree); + testFrameworks = new RegisteredTestFrameworks(SD.AddInTree); } } diff --git a/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj b/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj index 7d948086d0..24a0416b98 100644 --- a/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj +++ b/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj @@ -78,7 +78,6 @@ UnitTestingOptionsPanel.xaml - @@ -86,7 +85,6 @@ - diff --git a/src/AddIns/BackendBindings/CSharpBinding/Tests/OverrideCompletionTests.cs b/src/AddIns/BackendBindings/CSharpBinding/Tests/OverrideCompletionTests.cs index 28745d01a4..ebe66f88a2 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Tests/OverrideCompletionTests.cs +++ b/src/AddIns/BackendBindings/CSharpBinding/Tests/OverrideCompletionTests.cs @@ -3,10 +3,15 @@ using CSharpBinding.Completion; using ICSharpCode.AvalonEdit.Document; +using ICSharpCode.NRefactory.CSharp; +using ICSharpCode.NRefactory.TypeSystem; +using ICSharpCode.NRefactory.TypeSystem.Implementation; +using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Editor.CodeCompletion; using System; using System.Linq; using ICSharpCode.SharpDevelop.Editor; +using ICSharpCode.SharpDevelop.Parser; using NUnit.Framework; using Rhino.Mocks; @@ -16,7 +21,6 @@ namespace CSharpBinding.Tests /// Tests code completion after the 'override' keyword /// [TestFixture] - [Ignore("Override completion is not yet implemented")] public class OverrideCompletionTests { string programStart = @"using System; @@ -40,13 +44,22 @@ class DerivedClass : BaseClass { MockTextEditor textEditor; bool keyPressResult; + static readonly IUnresolvedAssembly Corlib = new CecilLoader().LoadAssemblyFile(typeof(object).Assembly.Location); + [SetUp] public void SetUp() { + SD.InitializeForUnitTests(); textEditor = new MockTextEditor(); textEditor.Document.Text = programStart + "override " + programEnd; textEditor.Caret.Offset = programStart.Length + "override ".Length; - textEditor.CreateParseInformation(); + var parseInfo = textEditor.CreateParseInformation(); + var pc = new CSharpProjectContent().UpdateProjectContent(null, parseInfo.ParsedFile); + pc = pc.AddAssemblyReferences(new[] { Corlib }); + var compilation = pc.CreateCompilation(); + SD.Services.AddService(typeof(IParserService), MockRepository.GenerateStub()); + SD.ParserService.Stub(p => p.GetCachedParseInformation(textEditor.FileName)).Return(parseInfo); + SD.ParserService.Stub(p => p.GetCompilationForFile(textEditor.FileName)).Return(compilation); CSharpCompletionBinding completion = new CSharpCompletionBinding(); keyPressResult = completion.HandleKeyPressed(textEditor, ' '); } @@ -72,7 +85,7 @@ class DerivedClass : BaseClass { Assert.AreEqual( new string[] { "AbstractEvent", "AbstractMethod()", "AbstractProperty", - "Equals(obj : Object)", "GetHashCode()", "ToString()", + "Equals(object obj)", "GetHashCode()", "ToString()", "VirtualEvent", "VirtualMethod()", "VirtualProperty" }, itemNames); } @@ -83,6 +96,7 @@ class DerivedClass : BaseClass { } [Test] + [Ignore("Implement formatter")] public void OverrideAbstractMethod() { CompletionContext context = new CompletionContext(); @@ -96,11 +110,12 @@ class DerivedClass : BaseClass { " {\n" + " throw new NotImplementedException();\n" + " }" + programEnd), - Normalize(textEditor.Document.Text) - ); + Normalize(textEditor.Document.Text) + ); } [Test] + [Ignore("Implement formatter")] public void OverrideVirtualMethod() { CompletionContext context = new CompletionContext(); @@ -114,11 +129,12 @@ class DerivedClass : BaseClass { " {\n" + " base.VirtualMethod();\n" + " }" + programEnd), - Normalize(textEditor.Document.Text) - ); + Normalize(textEditor.Document.Text) + ); } [Test] + [Ignore("Implement formatter")] public void OverrideVirtualProperty() { CompletionContext context = new CompletionContext(); @@ -132,8 +148,8 @@ class DerivedClass : BaseClass { " get { return base.VirtualProperty; }\n" + " set { base.VirtualProperty = value; }\n" + " }" + programEnd), - Normalize(textEditor.Document.Text) - ); + Normalize(textEditor.Document.Text) + ); } [Test] @@ -147,8 +163,8 @@ class DerivedClass : BaseClass { textEditor.LastCompletionItemList.Complete(context, item); Assert.AreEqual(Normalize( programStart + "public override event EventHandler VirtualEvent;" + programEnd), - Normalize(textEditor.Document.Text) - ); + Normalize(textEditor.Document.Text) + ); } } } diff --git a/src/AddIns/Misc/HelpViewer/Source/Commands.cs b/src/AddIns/Misc/HelpViewer/Source/Commands.cs index 93ada01b11..a0ade3ed43 100644 --- a/src/AddIns/Misc/HelpViewer/Source/Commands.cs +++ b/src/AddIns/Misc/HelpViewer/Source/Commands.cs @@ -69,8 +69,10 @@ namespace MSHelpSystem.Commands public override void Run() { string path; - if (!RegistryService.GetRegistryValue(RegistryHive.LocalMachine, @"SOFTWARE\Microsoft\Help\v1.0", - "AppRoot", RegistryValueKind.String, out path)) { + using (var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Help\v1.0")) { + path = key != null ? key.GetValue("AppRoot") as string : null; + } + if (string.IsNullOrEmpty(path)) { MessageService.ShowError("${res:AddIns.HelpViewer.HLMNotFound}"); return; } diff --git a/src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs b/src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs index 4cc05aed09..b20b067548 100644 --- a/src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs +++ b/src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs @@ -301,7 +301,6 @@ namespace ICSharpCode.SharpDevelop.Project { try { string file = GetPreferenceFileName(solutionFileName); - Properties properties = null; if (FileUtility.IsValidPath(file) && File.Exists(file)) { try { return Properties.Load(file); diff --git a/src/Main/Base/Project/Src/Services/SD.cs b/src/Main/Base/Project/Src/Services/SD.cs index d3d2ccef06..bc6236c442 100644 --- a/src/Main/Base/Project/Src/Services/SD.cs +++ b/src/Main/Base/Project/Src/Services/SD.cs @@ -104,5 +104,9 @@ namespace ICSharpCode.SharpDevelop public static IGlobalAssemblyCacheService GlobalAssemblyCache { get { return GetRequiredService(); } } + + public static IAddInTree AddInTree { + get { return GetRequiredService(); } + } } } diff --git a/src/Main/Base/Test/CheckAssemblyFlags.cs b/src/Main/Base/Test/CheckAssemblyFlags.cs index 17c662ce65..625b4321d6 100644 --- a/src/Main/Base/Test/CheckAssemblyFlags.cs +++ b/src/Main/Base/Test/CheckAssemblyFlags.cs @@ -10,7 +10,7 @@ using System.Text.RegularExpressions; namespace ICSharpCode.SharpDevelop.Tests { - [TestFixture, Ignore] + [TestFixture] public class CheckAssemblyFlags { string binPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ".."); diff --git a/src/Main/Core/Project/ICSharpCode.Core.csproj b/src/Main/Core/Project/ICSharpCode.Core.csproj index c28c1fc64e..9d32ab4013 100644 --- a/src/Main/Core/Project/ICSharpCode.Core.csproj +++ b/src/Main/Core/Project/ICSharpCode.Core.csproj @@ -69,6 +69,7 @@ + @@ -100,6 +101,7 @@ + @@ -118,7 +120,6 @@ - @@ -146,7 +147,6 @@ - Src\AddInTree\AddIn\AddIn.xsd diff --git a/src/Main/Core/Project/Src/AddInTree/AddIn/Codon.cs b/src/Main/Core/Project/Src/AddInTree/AddIn/Codon.cs index dfc1ea7cbd..a251829cf6 100644 --- a/src/Main/Core/Project/Src/AddInTree/AddIn/Codon.cs +++ b/src/Main/Core/Project/Src/AddInTree/AddIn/Codon.cs @@ -74,21 +74,6 @@ namespace ICSharpCode.Core this.conditions = conditions; } - [Obsolete("Use BuildItemArgs.Conditions instead")] - public ConditionFailedAction GetFailedAction(object caller) - { - return Condition.GetFailedAction(conditions, caller); - } - -// -// public void BinarySerialize(BinaryWriter writer) -// { -// writer.Write(AddInTree.GetNameOffset(name)); -// writer.Write(AddInTree.GetAddInOffset(addIn)); -// properties.BinarySerialize(writer); -// } -// - internal object BuildItem(BuildItemArgs args) { IDoozer doozer; diff --git a/src/Main/Core/Project/Src/AddInTree/AddIn/Runtime.cs b/src/Main/Core/Project/Src/AddInTree/AddIn/Runtime.cs index f527d28223..06db406955 100644 --- a/src/Main/Core/Project/Src/AddInTree/AddIn/Runtime.cs +++ b/src/Main/Core/Project/Src/AddInTree/AddIn/Runtime.cs @@ -19,7 +19,7 @@ namespace ICSharpCode.Core IList definedDoozers = new List(); IList definedConditionEvaluators = new List(); ICondition[] conditions; - IList addIns; + IReadOnlyList addIns; bool isActive = true; bool isAssemblyLoaded; readonly object lockObj = new object(); // used to protect mutable parts of runtime @@ -41,7 +41,7 @@ namespace ICSharpCode.Core { } - public Runtime(string assembly, string hintPath, IList addIns) + public Runtime(string assembly, string hintPath, IReadOnlyList addIns) { this.assembly = assembly; this.hintPath = hintPath; diff --git a/src/Main/Core/Project/Src/AddInTree/AddInTree.cs b/src/Main/Core/Project/Src/AddInTree/AddInTree.cs index f65bb5dcf2..9e8aece74f 100644 --- a/src/Main/Core/Project/Src/AddInTree/AddInTree.cs +++ b/src/Main/Core/Project/Src/AddInTree/AddInTree.cs @@ -69,7 +69,7 @@ namespace ICSharpCode.Core /// /// Gets the list of loaded AddIns. /// - public static IList AddIns { + public static IReadOnlyList AddIns { get { return addIns.AsReadOnly(); } @@ -101,16 +101,6 @@ namespace ICSharpCode.Core return GetTreeNode(path, false) != null; } - /// - /// Gets the representing the specified path. - /// This method throws a when the - /// path does not exist. - /// - public static AddInTreeNode GetTreeNode(string path) - { - return GetTreeNode(path, true); - } - /// /// Gets the representing the specified path. /// @@ -120,7 +110,7 @@ namespace ICSharpCode.Core /// when the path does not exist. /// If set to false, null is returned for non-existing paths. /// - public static AddInTreeNode GetTreeNode(string path, bool throwOnNotFound) + public static AddInTreeNode GetTreeNode(string path, bool throwOnNotFound = true) { if (path == null || path.Length == 0) { return rootNode; @@ -178,7 +168,7 @@ namespace ICSharpCode.Core /// If true, throws a /// if the path is not found. If false, an empty ArrayList is returned when the /// path is not found. - public static List BuildItems(string path, object caller, bool throwOnNotFound) + public static List BuildItems(string path, object caller, bool throwOnNotFound = true) { AddInTreeNode node = GetTreeNode(path, throwOnNotFound); if (node == null) diff --git a/src/Main/Core/Project/Src/AddInTree/AddInTreeImpl.cs b/src/Main/Core/Project/Src/AddInTree/AddInTreeImpl.cs new file mode 100644 index 0000000000..f04e0ef09e --- /dev/null +++ b/src/Main/Core/Project/Src/AddInTree/AddInTreeImpl.cs @@ -0,0 +1,30 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; + +namespace ICSharpCode.Core +{ + sealed class AddInTreeImpl : IAddInTree + { + IReadOnlyList IAddInTree.AddIns { + get { return AddInTree.AddIns; } + } + + IReadOnlyList IAddInTree.BuildItems(string path, object caller, bool throwOnNotFound) + { + return AddInTree.BuildItems(path, caller, throwOnNotFound); + } + + object IAddInTree.BuildItem(string path, object caller) + { + return AddInTree.BuildItem(path, caller); + } + + AddInTreeNode IAddInTree.GetTreeNode(string path, bool throwOnNotFound) + { + return AddInTree.GetTreeNode(path, throwOnNotFound); + } + } +} diff --git a/src/Main/Core/Project/Src/AddInTree/AddInTreeNode.cs b/src/Main/Core/Project/Src/AddInTree/AddInTreeNode.cs index c65159bd49..4213d85cbc 100644 --- a/src/Main/Core/Project/Src/AddInTree/AddInTreeNode.cs +++ b/src/Main/Core/Project/Src/AddInTree/AddInTreeNode.cs @@ -107,16 +107,6 @@ namespace ICSharpCode.Core return codon.BuildItem(new BuildItemArgs(caller, codon, conditions, subItemNode)); } - /// - /// Builds the child items in this path. - /// - /// The owner used to create the objects. - [Obsolete("Use the generic BuildChildItems version instead")] - public ArrayList BuildChildItems(object caller) - { - return new ArrayList(this.BuildChildItems(caller)); - } - /// /// Builds a specific child items in this path. /// diff --git a/src/Main/Core/Project/Src/AddInTree/IAddInTree.cs b/src/Main/Core/Project/Src/AddInTree/IAddInTree.cs new file mode 100644 index 0000000000..51e077fde4 --- /dev/null +++ b/src/Main/Core/Project/Src/AddInTree/IAddInTree.cs @@ -0,0 +1,47 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; + +namespace ICSharpCode.Core +{ + [FallbackService(typeof(AddInTreeImpl))] + public interface IAddInTree + { + /// + /// Gets the AddIns that are registered for this AddIn tree. + /// + IReadOnlyList AddIns { get; } + + /// + /// Builds the items in the path. Ensures that all items have the type T. + /// + /// A path in the addin tree. + /// The owner used to create the objects. + /// If true, throws a + /// if the path is not found. If false, an empty ArrayList is returned when the + /// path is not found. + IReadOnlyList BuildItems(string path, object caller, bool throwOnNotFound = true); + + /// + /// Builds a single item in the addin tree. + /// + /// A path to the item in the addin tree. + /// The owner used to create the objects. + /// The path does not + /// exist or does not point to an item. + object BuildItem(string path, object caller); + + /// + /// Gets the representing the specified path. + /// + /// The path of the AddIn tree node + /// + /// If set to true, this method throws a + /// when the path does not exist. + /// If set to false, null is returned for non-existing paths. + /// + AddInTreeNode GetTreeNode(string path, bool throwOnNotFound = true); + } +} diff --git a/src/Main/Core/Project/Src/Services/RegistryService/RegistryService.cs b/src/Main/Core/Project/Src/Services/RegistryService/RegistryService.cs deleted file mode 100644 index b3dd3c04c1..0000000000 --- a/src/Main/Core/Project/Src/Services/RegistryService/RegistryService.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -using System; -using System.Globalization; -using Microsoft.Win32; - -namespace ICSharpCode.Core -{ - /// - /// RegistryService. - /// - public static class RegistryService - { - /// - /// Gets the registry value. - /// - /// Registry hive. - /// Registry key. - /// Registry value. - /// Registry kind. - /// Data. - /// True, if the data was found, False otherwise. - public static bool GetRegistryValue(RegistryHive hive, string key, string value, RegistryValueKind kind, out T data) - { - data = default(T); - - try { - using (RegistryKey baseKey = RegistryKey.OpenRemoteBaseKey(hive, String.Empty)) - { - if (baseKey != null) - { - using (RegistryKey registryKey = baseKey.OpenSubKey(key, RegistryKeyPermissionCheck.ReadSubTree)) - { - if (registryKey != null) - { - RegistryValueKind kindFound = registryKey.GetValueKind(value); - if (kindFound == kind) - { - object regValue = registryKey.GetValue(value, null); - if (regValue != null) - { - data = (T)Convert.ChangeType(regValue, typeof(T), CultureInfo.InvariantCulture); - return true; - } - } - } - } - } - } - - return false; - } catch { - return false; - } - } - } -} diff --git a/src/Main/Core/Test/Utils/DerivedRuntime.cs b/src/Main/Core/Test/Utils/DerivedRuntime.cs index 27db6e1f82..eea8cf35fc 100644 --- a/src/Main/Core/Test/Utils/DerivedRuntime.cs +++ b/src/Main/Core/Test/Utils/DerivedRuntime.cs @@ -21,7 +21,7 @@ namespace ICSharpCode.Core.Tests.Utils : this(assembly, hintPath, new List()) { } - public DerivedRuntime(string assembly, string hintPath, IList addIns) + public DerivedRuntime(string assembly, string hintPath, IReadOnlyList addIns) : base(assembly, hintPath, addIns) { }