Browse Source

Add IAddInTree to ICSharpCode.Core to allow mocking BuildItems() calls.

newNRvisualizers
Daniel Grunwald 13 years ago
parent
commit
23cad81544
  1. 18
      SharpDevelop.Tests.sln
  2. 17
      src/AddIns/Analysis/UnitTesting/Implementation/UnitTestAddInTree.cs
  3. 13
      src/AddIns/Analysis/UnitTesting/Interfaces/IAddInTree.cs
  4. 4
      src/AddIns/Analysis/UnitTesting/Service/RegisteredTestFrameworks.cs
  5. 3
      src/AddIns/Analysis/UnitTesting/Service/TestService.cs
  6. 2
      src/AddIns/Analysis/UnitTesting/UnitTesting.csproj
  7. 38
      src/AddIns/BackendBindings/CSharpBinding/Tests/OverrideCompletionTests.cs
  8. 6
      src/AddIns/Misc/HelpViewer/Source/Commands.cs
  9. 1
      src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs
  10. 4
      src/Main/Base/Project/Src/Services/SD.cs
  11. 2
      src/Main/Base/Test/CheckAssemblyFlags.cs
  12. 4
      src/Main/Core/Project/ICSharpCode.Core.csproj
  13. 15
      src/Main/Core/Project/Src/AddInTree/AddIn/Codon.cs
  14. 4
      src/Main/Core/Project/Src/AddInTree/AddIn/Runtime.cs
  15. 16
      src/Main/Core/Project/Src/AddInTree/AddInTree.cs
  16. 30
      src/Main/Core/Project/Src/AddInTree/AddInTreeImpl.cs
  17. 10
      src/Main/Core/Project/Src/AddInTree/AddInTreeNode.cs
  18. 47
      src/Main/Core/Project/Src/AddInTree/IAddInTree.cs
  19. 58
      src/Main/Core/Project/Src/Services/RegistryService/RegistryService.cs
  20. 2
      src/Main/Core/Test/Utils/DerivedRuntime.cs

18
SharpDevelop.Tests.sln

@ -1,7 +1,7 @@ @@ -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 @@ -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 @@ -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 @@ -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 @@ -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

17
src/AddIns/Analysis/UnitTesting/Implementation/UnitTestAddInTree.cs

@ -1,17 +0,0 @@ @@ -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<T> BuildItems<T>(string path, object caller)
{
return AddInTree.BuildItems<T>(path, caller);
}
}
}

13
src/AddIns/Analysis/UnitTesting/Interfaces/IAddInTree.cs

@ -1,13 +0,0 @@ @@ -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<T> BuildItems<T>(string path, object caller);
}
}

4
src/AddIns/Analysis/UnitTesting/Service/RegisteredTestFrameworks.cs

@ -4,6 +4,8 @@ @@ -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 @@ -11,7 +13,7 @@ namespace ICSharpCode.UnitTesting
{
public class RegisteredTestFrameworks : IRegisteredTestFrameworks
{
List<TestFrameworkDescriptor> testFrameworkDescriptors;
IReadOnlyList<TestFrameworkDescriptor> testFrameworkDescriptors;
public const string AddInPath = "/SharpDevelop/UnitTesting/TestFrameworks";
public RegisteredTestFrameworks(IAddInTree addInTree)

3
src/AddIns/Analysis/UnitTesting/Service/TestService.cs

@ -28,8 +28,7 @@ namespace ICSharpCode.UnitTesting @@ -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);
}
}

2
src/AddIns/Analysis/UnitTesting/UnitTesting.csproj

@ -78,7 +78,6 @@ @@ -78,7 +78,6 @@
<DependentUpon>UnitTestingOptionsPanel.xaml</DependentUpon>
</Compile>
<Compile Include="Gui\UnitTestsPad.cs" />
<Compile Include="Implementation\UnitTestAddInTree.cs" />
<Compile Include="Implementation\UnitTestBuildOptions.cs" />
<Compile Include="Implementation\UnitTestBuildProjectFactory.cs" />
<Compile Include="Implementation\UnitTestDebuggerService.cs" />
@ -86,7 +85,6 @@ @@ -86,7 +85,6 @@
<Compile Include="Implementation\UnitTestSaveAllFilesCommand.cs" />
<Compile Include="Implementation\UnitTestTaskService.cs" />
<Compile Include="Implementation\UnitTestWorkbench.cs" />
<Compile Include="Interfaces\IAddInTree.cs" />
<Compile Include="Interfaces\IBuildOptions.cs" />
<Compile Include="Interfaces\IBuildProjectFactory.cs" />
<Compile Include="Interfaces\IFileSystem.cs" />

38
src/AddIns/BackendBindings/CSharpBinding/Tests/OverrideCompletionTests.cs

@ -3,10 +3,15 @@ @@ -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 @@ -16,7 +21,6 @@ namespace CSharpBinding.Tests
/// Tests code completion after the 'override' keyword
/// </summary>
[TestFixture]
[Ignore("Override completion is not yet implemented")]
public class OverrideCompletionTests
{
string programStart = @"using System;
@ -40,13 +44,22 @@ class DerivedClass : BaseClass { @@ -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<IParserService>());
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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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)
);
}
}
}

6
src/AddIns/Misc/HelpViewer/Source/Commands.cs

@ -69,8 +69,10 @@ namespace MSHelpSystem.Commands @@ -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;
}

1
src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs

@ -301,7 +301,6 @@ namespace ICSharpCode.SharpDevelop.Project @@ -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);

4
src/Main/Base/Project/Src/Services/SD.cs

@ -104,5 +104,9 @@ namespace ICSharpCode.SharpDevelop @@ -104,5 +104,9 @@ namespace ICSharpCode.SharpDevelop
public static IGlobalAssemblyCacheService GlobalAssemblyCache {
get { return GetRequiredService<IGlobalAssemblyCacheService>(); }
}
public static IAddInTree AddInTree {
get { return GetRequiredService<IAddInTree>(); }
}
}
}

2
src/Main/Base/Test/CheckAssemblyFlags.cs

@ -10,7 +10,7 @@ using System.Text.RegularExpressions; @@ -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, "..");

4
src/Main/Core/Project/ICSharpCode.Core.csproj

@ -69,6 +69,7 @@ @@ -69,6 +69,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Src\AddInTree\AddInTreeImpl.cs" />
<Compile Include="Src\AddInTree\AddIn\AddIn.cs" />
<Compile Include="Src\AddInTree\AddIn\AddInLoadException.cs" />
<Compile Include="Src\AddInTree\AddIn\AssemblyLocator.cs" />
@ -100,6 +101,7 @@ @@ -100,6 +101,7 @@
<Compile Include="Src\AddInTree\AddIn\DefaultDoozers\ToolBarItem\ToolBarItemDoozer.cs" />
<Compile Include="Src\AddInTree\AddInTree.cs" />
<Compile Include="Src\AddInTree\AddInTreeNode.cs" />
<Compile Include="Src\AddInTree\IAddInTree.cs" />
<Compile Include="Src\AddInTree\TopologicalSort.cs" />
<Compile Include="Src\AddInTree\TreePathNotFoundException.cs" />
<Compile Include="Src\CoreException.cs" />
@ -118,7 +120,6 @@ @@ -118,7 +120,6 @@
<Compile Include="Src\Services\MessageService\MessageService.cs" />
<Compile Include="Src\Services\PropertyService\Properties.cs" />
<Compile Include="Src\Services\PropertyService\PropertyService.cs" />
<Compile Include="Src\Services\RegistryService\RegistryService.cs" />
<Compile Include="Src\Services\ResourceService\ResourceNotFoundException.cs" />
<Compile Include="Src\Services\ResourceService\ResourceService.cs" />
<Compile Include="Src\Services\ServiceSingleton.cs" />
@ -146,7 +147,6 @@ @@ -146,7 +147,6 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Src\Services\LoggingService" />
<Folder Include="Src\Services\RegistryService" />
<Folder Include="Src\Services\ResourceService" />
<Content Include="..\..\..\..\data\schemas\AddIn.xsd">
<Link>Src\AddInTree\AddIn\AddIn.xsd</Link>

15
src/Main/Core/Project/Src/AddInTree/AddIn/Codon.cs

@ -74,21 +74,6 @@ namespace ICSharpCode.Core @@ -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;

4
src/Main/Core/Project/Src/AddInTree/AddIn/Runtime.cs

@ -19,7 +19,7 @@ namespace ICSharpCode.Core @@ -19,7 +19,7 @@ namespace ICSharpCode.Core
IList<LazyLoadDoozer> definedDoozers = new List<LazyLoadDoozer>();
IList<LazyConditionEvaluator> definedConditionEvaluators = new List<LazyConditionEvaluator>();
ICondition[] conditions;
IList<AddIn> addIns;
IReadOnlyList<AddIn> 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 @@ -41,7 +41,7 @@ namespace ICSharpCode.Core
{
}
public Runtime(string assembly, string hintPath, IList<AddIn> addIns)
public Runtime(string assembly, string hintPath, IReadOnlyList<AddIn> addIns)
{
this.assembly = assembly;
this.hintPath = hintPath;

16
src/Main/Core/Project/Src/AddInTree/AddInTree.cs

@ -69,7 +69,7 @@ namespace ICSharpCode.Core @@ -69,7 +69,7 @@ namespace ICSharpCode.Core
/// <summary>
/// Gets the list of loaded AddIns.
/// </summary>
public static IList<AddIn> AddIns {
public static IReadOnlyList<AddIn> AddIns {
get {
return addIns.AsReadOnly();
}
@ -101,16 +101,6 @@ namespace ICSharpCode.Core @@ -101,16 +101,6 @@ namespace ICSharpCode.Core
return GetTreeNode(path, false) != null;
}
/// <summary>
/// Gets the <see cref="AddInTreeNode"/> representing the specified path.
/// This method throws a <see cref="TreePathNotFoundException"/> when the
/// path does not exist.
/// </summary>
public static AddInTreeNode GetTreeNode(string path)
{
return GetTreeNode(path, true);
}
/// <summary>
/// Gets the <see cref="AddInTreeNode"/> representing the specified path.
/// </summary>
@ -120,7 +110,7 @@ namespace ICSharpCode.Core @@ -120,7 +110,7 @@ namespace ICSharpCode.Core
/// <see cref="TreePathNotFoundException"/> when the path does not exist.
/// If set to <c>false</c>, <c>null</c> is returned for non-existing paths.
/// </param>
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 @@ -178,7 +168,7 @@ namespace ICSharpCode.Core
/// <param name="throwOnNotFound">If true, throws a <see cref="TreePathNotFoundException"/>
/// if the path is not found. If false, an empty ArrayList is returned when the
/// path is not found.</param>
public static List<T> BuildItems<T>(string path, object caller, bool throwOnNotFound)
public static List<T> BuildItems<T>(string path, object caller, bool throwOnNotFound = true)
{
AddInTreeNode node = GetTreeNode(path, throwOnNotFound);
if (node == null)

30
src/Main/Core/Project/Src/AddInTree/AddInTreeImpl.cs

@ -0,0 +1,30 @@ @@ -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<AddIn> IAddInTree.AddIns {
get { return AddInTree.AddIns; }
}
IReadOnlyList<T> IAddInTree.BuildItems<T>(string path, object caller, bool throwOnNotFound)
{
return AddInTree.BuildItems<T>(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);
}
}
}

10
src/Main/Core/Project/Src/AddInTree/AddInTreeNode.cs

@ -107,16 +107,6 @@ namespace ICSharpCode.Core @@ -107,16 +107,6 @@ namespace ICSharpCode.Core
return codon.BuildItem(new BuildItemArgs(caller, codon, conditions, subItemNode));
}
/// <summary>
/// Builds the child items in this path.
/// </summary>
/// <param name="caller">The owner used to create the objects.</param>
[Obsolete("Use the generic BuildChildItems version instead")]
public ArrayList BuildChildItems(object caller)
{
return new ArrayList(this.BuildChildItems<object>(caller));
}
/// <summary>
/// Builds a specific child items in this path.
/// </summary>

47
src/Main/Core/Project/Src/AddInTree/IAddInTree.cs

@ -0,0 +1,47 @@ @@ -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
{
/// <summary>
/// Gets the AddIns that are registered for this AddIn tree.
/// </summary>
IReadOnlyList<AddIn> AddIns { get; }
/// <summary>
/// Builds the items in the path. Ensures that all items have the type T.
/// </summary>
/// <param name="path">A path in the addin tree.</param>
/// <param name="caller">The owner used to create the objects.</param>
/// <param name="throwOnNotFound">If true, throws a <see cref="TreePathNotFoundException"/>
/// if the path is not found. If false, an empty ArrayList is returned when the
/// path is not found.</param>
IReadOnlyList<T> BuildItems<T>(string path, object caller, bool throwOnNotFound = true);
/// <summary>
/// Builds a single item in the addin tree.
/// </summary>
/// <param name="path">A path to the item in the addin tree.</param>
/// <param name="caller">The owner used to create the objects.</param>
/// <exception cref="TreePathNotFoundException">The path does not
/// exist or does not point to an item.</exception>
object BuildItem(string path, object caller);
/// <summary>
/// Gets the <see cref="AddInTreeNode"/> representing the specified path.
/// </summary>
/// <param name="path">The path of the AddIn tree node</param>
/// <param name="throwOnNotFound">
/// If set to <c>true</c>, this method throws a
/// <see cref="TreePathNotFoundException"/> when the path does not exist.
/// If set to <c>false</c>, <c>null</c> is returned for non-existing paths.
/// </param>
AddInTreeNode GetTreeNode(string path, bool throwOnNotFound = true);
}
}

58
src/Main/Core/Project/Src/Services/RegistryService/RegistryService.cs

@ -1,58 +0,0 @@ @@ -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
{
/// <summary>
/// RegistryService.
/// </summary>
public static class RegistryService
{
/// <summary>
/// Gets the registry value.
/// </summary>
/// <param name="hive">Registry hive.</param>
/// <param name="key">Registry key.</param>
/// <param name="value">Registry value.</param>
/// <param name="kind">Registry kind.</param>
/// <param name="data">Data.</param>
/// <returns>True, if the data was found, False otherwise.</returns>
public static bool GetRegistryValue<T>(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;
}
}
}
}

2
src/Main/Core/Test/Utils/DerivedRuntime.cs

@ -21,7 +21,7 @@ namespace ICSharpCode.Core.Tests.Utils @@ -21,7 +21,7 @@ namespace ICSharpCode.Core.Tests.Utils
: this(assembly, hintPath, new List<AddIn>())
{
}
public DerivedRuntime(string assembly, string hintPath, IList<AddIn> addIns)
public DerivedRuntime(string assembly, string hintPath, IReadOnlyList<AddIn> addIns)
: base(assembly, hintPath, addIns)
{
}

Loading…
Cancel
Save