From e2c38c531ece4ee601b09b9cfc338677f3800d87 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Wed, 12 Sep 2012 12:52:10 +0200 Subject: [PATCH] Move some types to the new folder structure. --- TODOnewNR.txt | 109 +++++++++++- .../CSharpFormattingStrategy.cs | 4 +- .../Editor/DocumentServiceAttribute.cs | 0 .../HighlighterKnownSpanNames.cs} | 2 +- .../{Src => }/Editor/IEditorControlService.cs | 0 .../{Src => }/Editor/IEditorUIService.cs | 0 .../{Src => }/Editor/IFileDocumentProvider.cs | 0 .../Project/{Src => }/Editor/ITextEditor.cs | 0 .../Project/{Src => }/Editor/ITextMarker.cs | 0 .../Project/ICSharpCode.SharpDevelop.csproj | 15 +- .../Src/Editor/AddInHighlightingResource.cs | 58 ------- .../Base/Project/Src/Util/ExtensionMethods.cs | 39 +---- .../Project/Src/Util/ReactiveExtensions.cs | 68 +++++--- .../AddInHighlightingResourceTests.cs | 163 ------------------ .../ICSharpCode.SharpDevelop.Tests.csproj | 1 - 15 files changed, 164 insertions(+), 295 deletions(-) rename src/Main/Base/Project/{Src => }/Editor/DocumentServiceAttribute.cs (100%) rename src/Main/Base/Project/{Src/Editor/SyntaxHighlighterKnownSpanNames.cs => Editor/HighlighterKnownSpanNames.cs} (94%) rename src/Main/Base/Project/{Src => }/Editor/IEditorControlService.cs (100%) rename src/Main/Base/Project/{Src => }/Editor/IEditorUIService.cs (100%) rename src/Main/Base/Project/{Src => }/Editor/IFileDocumentProvider.cs (100%) rename src/Main/Base/Project/{Src => }/Editor/ITextEditor.cs (100%) rename src/Main/Base/Project/{Src => }/Editor/ITextMarker.cs (100%) delete mode 100644 src/Main/Base/Project/Src/Editor/AddInHighlightingResource.cs delete mode 100644 src/Main/Base/Test/Highlighting/AddInHighlightingResourceTests.cs diff --git a/TODOnewNR.txt b/TODOnewNR.txt index da19855e65..97bde5595e 100644 --- a/TODOnewNR.txt +++ b/TODOnewNR.txt @@ -25,13 +25,27 @@ Stuff that was renamed/moved: ICSharpCode.SharpDevelop.Dom -> the type system and resolvers now are part of ICSharpCode.NRefactory IDocument -> moved to ICSharpCode.NRefactory.Editor IClass -> ITypeDefinition - ISyntaxTree -> IUnresolvedFile + ICompilationUnit -> IUnresolvedFile ITextBuffer -> ITextSource (in ICSharpCode.NRefactory.Editor) IReturnType -> ITypeReference (unresolved) or IType (resolved) Location -> TextLocation in ICSharpCode.NRefactory TextLocation -> moved to ICSharpCode.NRefactory Functionality changes: + + SharpDevelop.Dom was replaced by NRefactory 5: + Apart from plenty of API changes, there are also a couple of architectural changes + to look out for. + Most importantly, the type system has been split up into an unresolved and a resolved + version. When porting code using SD.Dom, be careful which one of the two you choose. + + If possible, try to avoid using the unresolved type system. The planned observable code model + (will be implemented for the 5.0 class browser) might be a better alternative in some cases. + Features related to the type system / refactorings should probably wait for this code model + before they are ported to 5.0. + + NRefactory 5 introduction: http://www.codeproject.com/Articles/408663/Using-NRefactory-for-analyzing-Csharp-code + Static services replaced with interfaces: To make writing unit tests easier, the static services in SharpDevelop are getting @@ -39,7 +53,7 @@ Functionality changes: to the services, so the call "ResourceService.GetString()" becomes "SD.ResourceService.GetString()". In unit tests, Rhino.Mocks can be used to easily create mocks of the services: - SD.InitializeForUnitTests(); // removes services from previous test cases + SD.InitializeForUnitTests(); // initialize container and remove services from previous test cases SD.Services.AddService(typeof(IParserService), MockRepository.GenerateStrictMock()); SD.ParserService.Stub(p => p.GetCachedParseInformation(textEditor.FileName)).Return(parseInfo); SD.ParserService.Stub(p => p.GetCompilationForFile(textEditor.FileName)).Return(compilation); @@ -52,6 +66,30 @@ Functionality changes: and have the implementation details in SharpDevelop.exe (which AddIns aren't supposed to reference). + ICSharpCode.Core.WinForms hidden behind service interfaces: + This is an extension of the previous point. + The whole assembly ICSharpCode.Core.WinForms still exists and has the old static services, + which makes porting old AddIns a bit easier. + However, it should no longer be used in new code and AddIns should get rid of the reference + to ICSharpCode.Core.WinForms if possible. + The services in SD.WinForms provide the same functionality. + + + Namespaces in ICSharpCode.SharpDevelop reorganized: + I'm currently moving types around in ICSharpCode.SharpDevelop, so you'll have to update + plenty of usings. + The idea behind the new namespaces is that grouping the code into 'Gui' and 'Services' + isn't very useful; so I'm getting rid of those namespaces and the old folder structure, + and re-group the types into feature areas. + + Within the ICSharpCode.SharpDevelop project, the 'Src' folder contains the old code + that hasn't been cleaned up yet and may still be in an old namespace. + + When I'm done cleaning up a code file, I'm moving to out of the 'Src' folder into one of + the new folders corresponding to the new namespace. + As part of this cleanup, I'm also replacing static services with service interfaces (see above). + + SD.MainThread: The new best way to invoke a call on the main thread is: SD.MainThread.InvokeAsync(delegate { ... }).FireAndForget(); @@ -60,6 +98,17 @@ Functionality changes: executing the delegate, they will get stored in the task object. This can cause the exception to get silently ignored if the task object isn't used later. The "FireAndForget()" extension method solves this problem by reporting any (future) errors to the message service. + + It is also often possible to avoid explicit thread switches alltogether by using the C# 5 async/await feature. + + + ICSharpCode.Core.ICommand replaced with WPF ICommand + New menu commands should derive from 'SimpleCommand' instead of 'AbstractMenuCommand'. + If 'IsEnabled'-handling is required, new commands should just implement ICommand directly without using any base class. + + The old class AbstractMenuCommand still exist and simulates the old API, which makes porting AddIns a bit easier. + I'm thinking about writing a tool that automatically ports AbstractMenuCommand-derived classes to SimpleCommand, + so you don't need to bother updating your commands manually. SD.PropertyService: @@ -71,6 +120,10 @@ Functionality changes: However, a nested properties container still is connected with its parent, and any changes done to the nested container will get saves without having to call the SetNestedProperties() method. + + The property service now uses XAML serialization instead of XML serialization. This might require + some changes to your classes to ensure they get serialized correctly, for example + you need to use public properties instead of public fields. SD.ParserService: @@ -81,6 +134,58 @@ Functionality changes: The IUnresolvedFile is stored permanently (both in ParserService and in the IProjectContents). + Text editor and document services: + In SharpDevelop 4.x it was possible to use IDocument.GetService(typeof(ITextEditor)) to find the + editor that presents the document. + This is no longer possible in SharpDevelop 5, as the same IDocument may be used by + multiple editors (e.g. split view). + + ITextEditor and IDocument now use separate service containers. + ITextEditor.GetService() will also return document services, but not the other way around. + + The attributes [DocumentService] and [TextEditorService] are used to mark the service interfaces + that are available in the document and in the editor respectively. + The attributes exist purely for documentation, and some services may not use them + (for example the service interfaces defined in AvalonEdit, where the attributes aren't referenced). + + + View content services: + Instead of casting a view content to an interface "var x = viewContent as IEditable;", + code should use the viewContent.GetService() method. + This allows the view content implementation to be flexible where the interface is implemented, + it no longer is necessary to implement everything in the same class. + + Interfaces that are supposed to be used as view content services are marked with the + [ViewContentService] attribute. + + In the case of the AvalonEditViewContent, all text editor and document services are + also available via IViewContent.GetService(). + If split view is in use, the view content will return the services from the editor that has the focus. + + + XML Forms: + Classic .xfrm still exists and can be used in SD 5.0. + However XML forms support should be considered a temporary feature for making AddIns easier to port, + we still plan to get rid of all .xfrms and the associated infrastructure by the time SD 5.0 ships. + + Simply porting an .xfrm to a regular WinForms control with InitializeComponents() is acceptable, + but porting it to WPF is preferred. + + + +What wasn't changed: + + SD-1234 still makes implementing view contents difficult by preventing them from loading/saving + files when they want to. I'd like to fix this, but this likely won't fit into 5.0 and will have to wait for 5.1. + + + The IProject/ProjectItem model is mostly unchanged and still does not provide proper change notifications + (apart from those in the static ProjectService). + Lacking a good project model, we also haven't started moving the project browser to WPF. + This is a major refactoring on top of the already existing major changes in 5.0, so it doesn't fit. + But it's definitely a goal for 5.1. + + Context Actions vs. Member Context Menu: Members context menu should include refactoring options that can be applied from the outside, for example in the classes pad when the code file isn't open. diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingStrategy.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingStrategy.cs index 17efc4e48a..206e5ef62e 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingStrategy.cs +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingStrategy.cs @@ -347,8 +347,8 @@ namespace CSharpBinding.FormattingStrategy bool isInMultilineString = false; if (highlighter != null && lineAbove != null) { var spanStack = highlighter.GetColorStack(lineNr).Select(c => c.Name).ToArray(); - isInMultilineComment = spanStack.Contains(SyntaxHighlighterKnownSpanNames.Comment); - isInMultilineString = spanStack.Contains(SyntaxHighlighterKnownSpanNames.String); + isInMultilineComment = spanStack.Contains(HighlighterKnownSpanNames.Comment); + isInMultilineString = spanStack.Contains(HighlighterKnownSpanNames.String); } bool isInNormalCode = !(isInMultilineComment || isInMultilineString); diff --git a/src/Main/Base/Project/Src/Editor/DocumentServiceAttribute.cs b/src/Main/Base/Project/Editor/DocumentServiceAttribute.cs similarity index 100% rename from src/Main/Base/Project/Src/Editor/DocumentServiceAttribute.cs rename to src/Main/Base/Project/Editor/DocumentServiceAttribute.cs diff --git a/src/Main/Base/Project/Src/Editor/SyntaxHighlighterKnownSpanNames.cs b/src/Main/Base/Project/Editor/HighlighterKnownSpanNames.cs similarity index 94% rename from src/Main/Base/Project/Src/Editor/SyntaxHighlighterKnownSpanNames.cs rename to src/Main/Base/Project/Editor/HighlighterKnownSpanNames.cs index 45a9a046b9..771bcc7aae 100644 --- a/src/Main/Base/Project/Src/Editor/SyntaxHighlighterKnownSpanNames.cs +++ b/src/Main/Base/Project/Editor/HighlighterKnownSpanNames.cs @@ -9,7 +9,7 @@ using ICSharpCode.NRefactory.Editor; namespace ICSharpCode.SharpDevelop.Editor { - public static class SyntaxHighlighterKnownSpanNames + public static class HighlighterKnownSpanNames { public const string Comment = "Comment"; public const string String = "String"; diff --git a/src/Main/Base/Project/Src/Editor/IEditorControlService.cs b/src/Main/Base/Project/Editor/IEditorControlService.cs similarity index 100% rename from src/Main/Base/Project/Src/Editor/IEditorControlService.cs rename to src/Main/Base/Project/Editor/IEditorControlService.cs diff --git a/src/Main/Base/Project/Src/Editor/IEditorUIService.cs b/src/Main/Base/Project/Editor/IEditorUIService.cs similarity index 100% rename from src/Main/Base/Project/Src/Editor/IEditorUIService.cs rename to src/Main/Base/Project/Editor/IEditorUIService.cs diff --git a/src/Main/Base/Project/Src/Editor/IFileDocumentProvider.cs b/src/Main/Base/Project/Editor/IFileDocumentProvider.cs similarity index 100% rename from src/Main/Base/Project/Src/Editor/IFileDocumentProvider.cs rename to src/Main/Base/Project/Editor/IFileDocumentProvider.cs diff --git a/src/Main/Base/Project/Src/Editor/ITextEditor.cs b/src/Main/Base/Project/Editor/ITextEditor.cs similarity index 100% rename from src/Main/Base/Project/Src/Editor/ITextEditor.cs rename to src/Main/Base/Project/Editor/ITextEditor.cs diff --git a/src/Main/Base/Project/Src/Editor/ITextMarker.cs b/src/Main/Base/Project/Editor/ITextMarker.cs similarity index 100% rename from src/Main/Base/Project/Src/Editor/ITextMarker.cs rename to src/Main/Base/Project/Editor/ITextMarker.cs diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj index 6cc2301ed9..0aaa4ac99e 100644 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj @@ -97,11 +97,17 @@ + + + + + + + - @@ -117,10 +123,7 @@ - - - @@ -152,15 +155,11 @@ - - ToolTipService.cs - - ToolTipService.cs diff --git a/src/Main/Base/Project/Src/Editor/AddInHighlightingResource.cs b/src/Main/Base/Project/Src/Editor/AddInHighlightingResource.cs deleted file mode 100644 index 331ad2031a..0000000000 --- a/src/Main/Base/Project/Src/Editor/AddInHighlightingResource.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.IO; -using System.Reflection; -using System.Xml; - -using ICSharpCode.AvalonEdit.Highlighting; -using ICSharpCode.AvalonEdit.Highlighting.Xshd; -using ICSharpCode.Core; - -namespace ICSharpCode.SharpDevelop.Editor -{ - public class AddInHighlightingResource - { - Runtime[] runtimes; - - public AddInHighlightingResource(Runtime[] runtimes) - { - this.runtimes = runtimes; - } - - public Stream OpenStream(string name) - { - foreach (Runtime runtime in runtimes) { - Assembly assembly = runtime.LoadedAssembly; - if (assembly != null) { - Stream stream = assembly.GetManifestResourceStream(name); - if (stream != null) { - return stream; - } - } - } - ThrowFileNotFoundException(name); - return null; - } - - void ThrowFileNotFoundException(string name) - { - string message = String.Format("The resource file '{0}' was not found.", name); - throw new FileNotFoundException(message); - } - - public IHighlightingDefinition LoadHighlighting(string name, IHighlightingDefinitionReferenceResolver resolver) - { - if (resolver == null) { - throw new ArgumentNullException("resolver"); - } - - using (Stream stream = OpenStream(name)) { - using (XmlTextReader reader = new XmlTextReader(stream)) { - return HighlightingLoader.Load(reader, resolver); - } - } - } - } -} diff --git a/src/Main/Base/Project/Src/Util/ExtensionMethods.cs b/src/Main/Base/Project/Src/Util/ExtensionMethods.cs index dfc3ffda66..7232d2b1b5 100644 --- a/src/Main/Base/Project/Src/Util/ExtensionMethods.cs +++ b/src/Main/Base/Project/Src/Util/ExtensionMethods.cs @@ -2,7 +2,6 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; @@ -11,10 +10,10 @@ using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Forms; using System.Windows.Media; using System.Xml; using System.Xml.Linq; + using ICSharpCode.Core; using ICSharpCode.Core.Presentation; using ICSharpCode.NRefactory; @@ -22,7 +21,6 @@ using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.Utils; using ICSharpCode.SharpDevelop.Editor; -using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Parser; using ICSharpCode.SharpDevelop.Project; @@ -369,40 +367,7 @@ namespace ICSharpCode.SharpDevelop return AmbienceService.GetCurrentAmbience(); } #endregion - - #region WPF SetContent - /* - /// - /// Sets the Content property of the specified ControlControl to the specified content. - /// If the content is a Windows-Forms control, it is wrapped in a WindowsFormsHost. - /// If the content control already contains a WindowsFormsHost with that content, - /// the old WindowsFormsHost is kept. - /// When a WindowsFormsHost is replaced with another content, the host is disposed (but the control - /// inside the host isn't) - /// - public static void SetContent(this ContentControl contentControl, object content) - { - SetContent(contentControl, content, null); - } - - public static void SetContent(this ContentPresenter contentControl, object content) - { - SetContent(contentControl, content, null); - } - - public static void SetContent(this ContentControl contentControl, object content, object serviceObject) - { - - } - - - public static void SetContent(this ContentPresenter contentControl, object content, object serviceObject) - { - - } - */ - #endregion - + #region DPI independence public static Rect TransformToDevice(this Rect rect, Visual visual) { diff --git a/src/Main/Base/Project/Src/Util/ReactiveExtensions.cs b/src/Main/Base/Project/Src/Util/ReactiveExtensions.cs index 64a636b6e2..ffcfaaaa34 100644 --- a/src/Main/Base/Project/Src/Util/ReactiveExtensions.cs +++ b/src/Main/Base/Project/Src/Util/ReactiveExtensions.cs @@ -16,19 +16,33 @@ namespace ICSharpCode.SharpDevelop /// public static class ReactiveExtensions { + #region ObserveOnUIThread public static IObservable ObserveOnUIThread(this IObservable source) { - return new AnonymousObservable( - observer => source.Subscribe( - new AnonymousObserver( - value => WorkbenchSingleton.SafeThreadAsyncCall(delegate { observer.OnNext(value); }), - exception => WorkbenchSingleton.SafeThreadAsyncCall(delegate { observer.OnError(exception); }), - () => WorkbenchSingleton.SafeThreadAsyncCall(delegate { observer.OnCompleted(); }) - ) - ) - ); + return new UIThreadObservable(source, SD.MainThread.SynchronizationContext); } + class UIThreadObservable : IObservable + { + readonly IObservable source; + readonly SynchronizationContext synchronizationContext; + + public UIThreadObservable(IObservable source, SynchronizationContext synchronizationContext) + { + this.source = source; + this.synchronizationContext = synchronizationContext; + } + + public IDisposable Subscribe(IObserver observer) + { + return source.Subscribe(value => synchronizationContext.Post(state => observer.OnNext((T)state), value), + ex => synchronizationContext.Post(state => observer.OnError((Exception)state), ex), + () => synchronizationContext.Post(state => observer.OnCompleted(), null)); + } + } + #endregion + + #region Create Observable from Task + Callback Delegate public static IObservable CreateObservable(Func, Task> func) { return new AnonymousObservable(observer => new TaskToObserverSubscription(func, observer)); @@ -85,29 +99,36 @@ namespace ICSharpCode.SharpDevelop cts.Cancel(); } } + #endregion - public static IDisposable Subscribe(this IObservable source, Action onNext, Action onError, Action onCompleted) + #region ToListAsync + /// + /// Converts the observable into a List. + /// + public static async Task> ToListAsync(this IObservable source, CancellationToken cancellationToken) { - return source.Subscribe(new AnonymousObserver(onNext, onError, onCompleted)); + var tcs = new TaskCompletionSource>(); + List results = new List(); + using (source.Subscribe(item => results.Add(item), + exception => tcs.TrySetException(exception), + () => tcs.TrySetResult(results))) + { + using (cancellationToken.Register(() => tcs.SetCanceled())) { + return await tcs.Task.ConfigureAwait(false); + } + } } + #endregion - public static List ToList(this IObservable source, CancellationToken cancellationToken) + #region AnonymousObserver + public static IDisposable Subscribe(this IObservable source, Action onNext, Action onError, Action onCompleted) { - List results = new List(); - ManualResetEventSlim ev = new ManualResetEventSlim(); - ExceptionDispatchInfo error = null; - using (source.Subscribe(item => results.Add(item), - exception => { error = ExceptionDispatchInfo.Capture(exception); ev.Set(); }, - () => ev.Set())) - ev.Wait(cancellationToken); - if (error != null) - error.Throw(); - return results; + return source.Subscribe(new AnonymousObserver(onNext, onError, onCompleted)); } class AnonymousObservable : IObservable { - Func, IDisposable> subscribe; + readonly Func, IDisposable> subscribe; public AnonymousObservable(Func, IDisposable> subscribe) { @@ -154,5 +175,6 @@ namespace ICSharpCode.SharpDevelop onCompleted(); } } + #endregion } } diff --git a/src/Main/Base/Test/Highlighting/AddInHighlightingResourceTests.cs b/src/Main/Base/Test/Highlighting/AddInHighlightingResourceTests.cs deleted file mode 100644 index 1fba10b551..0000000000 --- a/src/Main/Base/Test/Highlighting/AddInHighlightingResourceTests.cs +++ /dev/null @@ -1,163 +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 System.IO; -using System.Text; -using System.Xml; -using ICSharpCode.AvalonEdit.Highlighting; -using ICSharpCode.AvalonEdit.Highlighting.Xshd; -using ICSharpCode.Core; -using ICSharpCode.Core.Tests.Utils; -using ICSharpCode.SharpDevelop.Editor; -using ICSharpCode.SharpDevelop.Tests.Utils; -using NUnit.Framework; -using Rhino.Mocks; - -namespace ICSharpCode.SharpDevelop.Tests.Highlighting -{ - [TestFixture] - public class AddInHighlightingResourceTests - { - AddInHighlightingResource highlightingResource; - Stream predefinedManifestResourceStream; - MockAssembly assembly; - DerivedRuntime testRuntime; - DerivedRuntime unloadedRuntime; - - [SetUp] - public void Init() - { - // Create assembly. - byte[] bytes = UnicodeEncoding.UTF8.GetBytesWithPreamble(GetHighlightingDefinitionXml()); - predefinedManifestResourceStream = new MemoryStream(bytes); - assembly = new MockAssembly(); - assembly.AddManifestResourceStream("ICSharpCode.Xml.xshd", predefinedManifestResourceStream); - - // Create addins. - IAddInTree addInTree = MockRepository.GenerateStrictMock(); - AddIn addIn = AddIn.Load(addInTree, new StringReader(GetAddInXml())); - addIn.FileName = @"D:\SharpDevelop\AddIns\MyAddIn.addin"; - addIn.Enabled = true; - - // Create runtimes. - testRuntime = new DerivedRuntime(addInTree, "MyAddIn.dll", String.Empty); - testRuntime.AssemblyFileNames.Add("MyAddIn.dll", assembly); - - unloadedRuntime = new DerivedRuntime(addInTree, "UnLoadedAssembly.dll", String.Empty); - unloadedRuntime.AssemblyFileNames.Add("UnLoadedAssembly.dll", null); - unloadedRuntime.LoadAssemblyFromExceptionToThrow = new FileNotFoundException("UnloadedAssembly.dll not found."); - - List runtimes = new List(); - runtimes.Add(testRuntime); - runtimes.Add(unloadedRuntime); - - // Create addin highlighting resource. - highlightingResource = new AddInHighlightingResource(runtimes.ToArray()); - } - - string GetHighlightingDefinitionXml() - { - return - "\r\n" + - " \r\n" + - " \r\n" + - " \r\n" + - " \r\n" + - " \r\n" + - " \r\n" + - " \r\n" + - "\r\n" + - " \r\n" + - "\r\n" + - " \r\n" + - " \r\n" + - " \r\n" + - " \r\n" + - " \r\n" + - ""; - } - - string GetAddInXml() - { - return - "\r\n" + - "\r\n" + - " \r\n" + - " \r\n" + - " \r\n" + - "\r\n" + - " \r\n" + - " \r\n" + - " \r\n" + - " \r\n" + - " \r\n" + - ""; - } - - [TearDown] - public void TearDown() - { - predefinedManifestResourceStream.Dispose(); - } - - [Test] - public void OpenStreamThrowsFileNotFoundExceptionForUnknownManifestResourceName() - { - string expectedMessage = "The resource file 'Unknown' was not found."; - FileNotFoundException ex = - Assert.Throws(delegate { highlightingResource.OpenStream("Unknown"); }); - Assert.AreEqual(expectedMessage, ex.Message); - } - - [Test] - public void OpenStreamReturnsAssemblyManifestResourceStreamForKnownManifestResourceName() - { - Stream stream = highlightingResource.OpenStream("ICSharpCode.Xml.xshd"); - Assert.AreSame(predefinedManifestResourceStream, stream); - } - - [Test] - public void MockAssemblyReturnedFromMyAddInRuntime() - { - Assert.IsInstanceOf(typeof(MockAssembly), testRuntime.LoadedAssembly); - } - - [Test] - public void UnloadedRunTimeReturnsNullFromLoadedAssembly() - { - Assert.IsNull(unloadedRuntime.LoadedAssembly); - } - - [Test] - public void HighlightingDefinitionCanBeLoadedFromXmlViaMemoryStream() - { - using (XmlTextReader reader = new XmlTextReader(predefinedManifestResourceStream)) { - XshdSyntaxDefinition xshd = HighlightingLoader.LoadXshd(reader); - Assert.AreEqual("BAT", xshd.Name); - } - } - - [Test] - public void HighlightingDefinitionReturnedFromLoadHighlightingMethod() - { - HighlightingManager manager = new HighlightingManager(); - IHighlightingDefinition highlighting = highlightingResource.LoadHighlighting("ICSharpCode.Xml.xshd", manager); - Assert.AreEqual("BAT", highlighting.Name); - } - - [Test] - public void LoadHighlightingThrowsArgumentNullExceptionIfResolverParameterIsNull() - { - ArgumentNullException ex = - Assert.Throws( - delegate { highlightingResource.LoadHighlighting("ICSharpCode.Xml.xshd", null); }); - Assert.AreEqual("resolver", ex.ParamName); - } - } -} diff --git a/src/Main/Base/Test/ICSharpCode.SharpDevelop.Tests.csproj b/src/Main/Base/Test/ICSharpCode.SharpDevelop.Tests.csproj index 17a3656850..778865f006 100644 --- a/src/Main/Base/Test/ICSharpCode.SharpDevelop.Tests.csproj +++ b/src/Main/Base/Test/ICSharpCode.SharpDevelop.Tests.csproj @@ -82,7 +82,6 @@ -