diff --git a/ICSharpCode.Editor/ITextEditor.cs b/ICSharpCode.Editor/ITextEditor.cs index 6d15eb7699..8a9003cb65 100644 --- a/ICSharpCode.Editor/ITextEditor.cs +++ b/ICSharpCode.Editor/ITextEditor.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; namespace ICSharpCode.Editor { + /* /// /// Interface for text editors. /// @@ -64,6 +65,7 @@ namespace ICSharpCode.Editor /// // Task ShowLinkedElements(IEnumerable linkedElements); } + */ /// /// Represents the caret in a text editor. diff --git a/ICSharpCode.NRefactory/Documentation/XmlDocumentationProvider.cs b/ICSharpCode.NRefactory/Documentation/XmlDocumentationProvider.cs index 70d88aa164..620139fef4 100644 --- a/ICSharpCode.NRefactory/Documentation/XmlDocumentationProvider.cs +++ b/ICSharpCode.NRefactory/Documentation/XmlDocumentationProvider.cs @@ -90,22 +90,26 @@ namespace ICSharpCode.NRefactory.Documentation if (fileName == null) throw new ArgumentNullException("fileName"); - using (XmlTextReader xmlReader = new XmlTextReader(fileName)) { - xmlReader.XmlResolver = null; // no DTD resolving - xmlReader.MoveToContent(); - if (string.IsNullOrEmpty(xmlReader.GetAttribute("redirect"))) { - this.fileName = fileName; - ReadXmlDoc(xmlReader); - } else { - string redirectionTarget = GetRedirectionTarget(xmlReader.GetAttribute("redirect")); - if (redirectionTarget != null) { - Debug.WriteLine("XmlDoc " + fileName + " is redirecting to " + redirectionTarget); - using (XmlTextReader redirectedXmlReader = new XmlTextReader(redirectionTarget)) { - this.fileName = redirectionTarget; - ReadXmlDoc(redirectedXmlReader); - } + using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete)) { + using (XmlTextReader xmlReader = new XmlTextReader(fs)) { + xmlReader.XmlResolver = null; // no DTD resolving + xmlReader.MoveToContent(); + if (string.IsNullOrEmpty(xmlReader.GetAttribute("redirect"))) { + this.fileName = fileName; + ReadXmlDoc(xmlReader); } else { - throw new XmlException("XmlDoc " + fileName + " is redirecting to " + xmlReader.GetAttribute("redirect") + ", but that file was not found."); + string redirectionTarget = GetRedirectionTarget(xmlReader.GetAttribute("redirect")); + if (redirectionTarget != null) { + Debug.WriteLine("XmlDoc " + fileName + " is redirecting to " + redirectionTarget); + using (FileStream redirectedFs = new FileStream(redirectionTarget, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete)) { + using (XmlTextReader redirectedXmlReader = new XmlTextReader(redirectedFs)) { + this.fileName = redirectionTarget; + ReadXmlDoc(redirectedXmlReader); + } + } + } else { + throw new XmlException("XmlDoc " + fileName + " is redirecting to " + xmlReader.GetAttribute("redirect") + ", but that file was not found."); + } } } } @@ -138,7 +142,11 @@ namespace ICSharpCode.NRefactory.Documentation return dir + Path.DirectorySeparatorChar; } - internal static string LookupLocalizedXmlDoc(string fileName) + /// + /// Given the assembly file name, looks up the XML documentation file name. + /// Returns null if no XML documentation file is found. + /// + public static string LookupLocalizedXmlDoc(string fileName) { string xmlFileName = Path.ChangeExtension(fileName, ".xml"); string currentCulture = System.Threading.Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName; diff --git a/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs b/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs index d7765d938d..ce111f1fba 100644 --- a/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs +++ b/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs @@ -8,6 +8,7 @@ using System.Diagnostics; using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using System.Threading; using ICSharpCode.NRefactory.TypeSystem.Implementation; using Mono.Cecil; @@ -44,6 +45,11 @@ namespace ICSharpCode.NRefactory.TypeSystem /// public IInterningProvider InterningProvider { get; set; } + /// + /// Gets/Sets the cancellation token used by the cecil loader. + /// + public CancellationToken CancellationToken { get; set; } + /// /// Gets a value indicating whether this instance stores references to the cecil objects. /// @@ -91,6 +97,7 @@ namespace ICSharpCode.NRefactory.TypeSystem List types = new List(); foreach (ModuleDefinition module in assemblyDefinition.Modules) { foreach (TypeDefinition td in module.Types) { + this.CancellationToken.ThrowIfCancellationRequested(); if (this.IncludeInternalMembers || (td.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.Public) { string name = td.FullName; if (name.Length == 0 || name[0] == '<') @@ -719,6 +726,7 @@ namespace ICSharpCode.NRefactory.TypeSystem public void Init(CecilLoader loader) { + loader.CancellationToken.ThrowIfCancellationRequested(); InitModifiers(); if (typeDefinition.HasGenericParameters) { diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultTypeDefinition.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultTypeDefinition.cs index f9ee9a45ea..a162b1a14e 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultTypeDefinition.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultTypeDefinition.cs @@ -265,7 +265,15 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation } public virtual string Documentation { - get { return null; } + get { + // To save memory, we don't store the documentation provider within the type, + // but use our the project content as a documentation provider: + IDocumentationProvider provider = projectContent as IDocumentationProvider; + if (provider != null) + return provider.GetDocumentation(this); + else + return null; + } } public Accessibility Accessibility { diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedEvent.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedEvent.cs index b344d94914..7aad82a16f 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedEvent.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedEvent.cs @@ -33,6 +33,10 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation get { return memberDefinition; } } + public override string Documentation { + get { return memberDefinition.Documentation; } + } + public override int GetHashCode() { int hashCode = 0; diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedField.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedField.cs index d8fc104b1e..b58851a40b 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedField.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedField.cs @@ -33,6 +33,10 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation get { return memberDefinition; } } + public override string Documentation { + get { return memberDefinition.Documentation; } + } + public override int GetHashCode() { int hashCode = 0; diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedMethod.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedMethod.cs index 9d76f93e26..697437bba6 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedMethod.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedMethod.cs @@ -33,6 +33,10 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation get { return memberDefinition; } } + public override string Documentation { + get { return memberDefinition.Documentation; } + } + public override int GetHashCode() { int hashCode = 0; diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedProperty.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedProperty.cs index 921ffc0299..e5db1acdb8 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedProperty.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedProperty.cs @@ -33,6 +33,10 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation get { return memberDefinition; } } + public override string Documentation { + get { return memberDefinition.Documentation; } + } + public override int GetHashCode() { int hashCode = 0;