From 8f1ec7445341a8fd46633770ab03f2d3827fe5f3 Mon Sep 17 00:00:00 2001 From: Peter Malik Date: Thu, 4 Apr 2019 08:27:34 +0200 Subject: [PATCH 01/10] Migrate to support VS 2019 --- T4Toolbox.Common.props | 2 +- .../T4Toolbox.DirectiveProcessors.csproj | 2 + .../T4Toolbox.TemplateAnalysis.csproj | 2 + .../T4Toolbox.VisualStudio.Editor.csproj | 6 ++ .../TemplateQuickInfoSource.cs | 24 ++++---- .../TemplateQuickInfoSourceProvider.cs | 18 +++--- ...4Toolbox.VisualStudio.ItemTemplates.csproj | 4 +- .../Resources.Designer.cs | 2 +- .../T4Toolbox.VisualStudio.csproj | 2 + src/T4Toolbox.vsix/T4Toolbox.vsix.csproj | 2 + .../source.extension.vsixmanifest | 56 +++++++++---------- src/T4Toolbox/T4Toolbox.csproj | 2 + ...T4Toolbox.VisualStudio.Editor.Tests.csproj | 4 ++ 13 files changed, 72 insertions(+), 54 deletions(-) diff --git a/T4Toolbox.Common.props b/T4Toolbox.Common.props index 17567f1..2197892 100644 --- a/T4Toolbox.Common.props +++ b/T4Toolbox.Common.props @@ -7,7 +7,7 @@ $(MSBuildProjectName) $(MSBuildProjectName) Properties - v4.6 + v4.7.2 15.0 15.0 diff --git a/src/T4Toolbox.DirectiveProcessors/T4Toolbox.DirectiveProcessors.csproj b/src/T4Toolbox.DirectiveProcessors/T4Toolbox.DirectiveProcessors.csproj index f925e84..715f5e4 100644 --- a/src/T4Toolbox.DirectiveProcessors/T4Toolbox.DirectiveProcessors.csproj +++ b/src/T4Toolbox.DirectiveProcessors/T4Toolbox.DirectiveProcessors.csproj @@ -3,6 +3,8 @@ {E0282961-2D83-48CC-B4D4-8257449CF8F7} Library + v4.7.2 + diff --git a/src/T4Toolbox.TemplateAnalysis/T4Toolbox.TemplateAnalysis.csproj b/src/T4Toolbox.TemplateAnalysis/T4Toolbox.TemplateAnalysis.csproj index c146ee5..bd5d848 100644 --- a/src/T4Toolbox.TemplateAnalysis/T4Toolbox.TemplateAnalysis.csproj +++ b/src/T4Toolbox.TemplateAnalysis/T4Toolbox.TemplateAnalysis.csproj @@ -8,6 +8,8 @@ ..\..\packages\YaccLexTools.0.2.2\tools\ "$(YaccLexTools)gplex.exe" "$(YaccLexTools)gppg.exe" + v4.7.2 + diff --git a/src/T4Toolbox.VisualStudio.Editor/T4Toolbox.VisualStudio.Editor.csproj b/src/T4Toolbox.VisualStudio.Editor/T4Toolbox.VisualStudio.Editor.csproj index 575bf15..b9d4c6c 100644 --- a/src/T4Toolbox.VisualStudio.Editor/T4Toolbox.VisualStudio.Editor.csproj +++ b/src/T4Toolbox.VisualStudio.Editor/T4Toolbox.VisualStudio.Editor.csproj @@ -5,12 +5,18 @@ {FDE953D3-AD27-4398-8EF4-293C0CEBDC3E} Library + v4.7.2 + + + False + ..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VSSDK\VisualStudioIntegration\Common\Assemblies\v4.0\Microsoft.VisualStudio.Language.dll + diff --git a/src/T4Toolbox.VisualStudio.Editor/TemplateQuickInfoSource.cs b/src/T4Toolbox.VisualStudio.Editor/TemplateQuickInfoSource.cs index 22f61d4..b07b701 100644 --- a/src/T4Toolbox.VisualStudio.Editor/TemplateQuickInfoSource.cs +++ b/src/T4Toolbox.VisualStudio.Editor/TemplateQuickInfoSource.cs @@ -5,34 +5,31 @@ namespace T4Toolbox.VisualStudio.Editor { using System; - using System.Collections.Generic; using System.Diagnostics; + using System.Threading; + using System.Threading.Tasks; using Microsoft.VisualStudio.Language.Intellisense; using Microsoft.VisualStudio.Text; - internal sealed class TemplateQuickInfoSource : IQuickInfoSource + internal sealed class TemplateQuickInfoSource : IAsyncQuickInfoSource { private readonly TemplateAnalyzer analyzer; public TemplateQuickInfoSource(ITextBuffer buffer) { Debug.Assert(buffer != null, "buffer"); - this.analyzer = TemplateAnalyzer.GetOrCreate(buffer); + analyzer = TemplateAnalyzer.GetOrCreate(buffer); } - public void AugmentQuickInfoSession(IQuickInfoSession session, IList quickInfoContent, out ITrackingSpan applicableToSpan) + public Task GetQuickInfoItemAsync(IAsyncQuickInfoSession session, CancellationToken cancellationToken) { + QuickInfoItem quickInfoItem = null; if (session == null) { throw new ArgumentNullException("session"); } - if (quickInfoContent == null) - { - throw new ArgumentNullException("quickInfoContent"); - } - - TemplateAnalysis analysis = this.analyzer.CurrentAnalysis; + TemplateAnalysis analysis = analyzer.CurrentAnalysis; SnapshotPoint? triggerPoint = session.GetTriggerPoint(analysis.TextSnapshot); if (triggerPoint != null && analysis.Template != null) { @@ -40,13 +37,12 @@ public void AugmentQuickInfoSession(IQuickInfoSession session, IList qui Span applicableTo; if (analysis.Template.TryGetDescription(triggerPoint.Value.Position, out description, out applicableTo)) { - quickInfoContent.Add(description); - applicableToSpan = analysis.TextSnapshot.CreateTrackingSpan(applicableTo, SpanTrackingMode.EdgeExclusive); - return; + ITrackingSpan applicableToSpan = analysis.TextSnapshot.CreateTrackingSpan(applicableTo, SpanTrackingMode.EdgeExclusive); + quickInfoItem = new QuickInfoItem(applicableToSpan, description); } } - applicableToSpan = null; + return Task.FromResult(quickInfoItem); } public void Dispose() diff --git a/src/T4Toolbox.VisualStudio.Editor/TemplateQuickInfoSourceProvider.cs b/src/T4Toolbox.VisualStudio.Editor/TemplateQuickInfoSourceProvider.cs index cf27c87..d2f75da 100644 --- a/src/T4Toolbox.VisualStudio.Editor/TemplateQuickInfoSourceProvider.cs +++ b/src/T4Toolbox.VisualStudio.Editor/TemplateQuickInfoSourceProvider.cs @@ -10,11 +10,11 @@ namespace T4Toolbox.VisualStudio.Editor using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Utilities; - [Export(typeof(IQuickInfoSourceProvider)), ContentType(TemplateContentType.Name)] + [Export(typeof(IAsyncQuickInfoSourceProvider)), ContentType(TemplateContentType.Name)] [Name("Template Quick Info Source"), Order(Before = "Default Quick Info Presenter")] - internal sealed class TemplateQuickInfoSourceProvider : IQuickInfoSourceProvider + internal sealed class TemplateQuickInfoSourceProvider : IAsyncQuickInfoSourceProvider { - private readonly ITemplateEditorOptions options; + private readonly ITemplateEditorOptions _options; [ImportingConstructor] public TemplateQuickInfoSourceProvider(ITemplateEditorOptions options) @@ -24,19 +24,19 @@ public TemplateQuickInfoSourceProvider(ITemplateEditorOptions options) throw new ArgumentNullException(nameof(options)); } - this.options = options; + _options = options; } - public IQuickInfoSource TryCreateQuickInfoSource(ITextBuffer buffer) + public IAsyncQuickInfoSource TryCreateQuickInfoSource(ITextBuffer textBuffer) { - if (buffer == null) + if (textBuffer == null) { - throw new ArgumentNullException(nameof(buffer)); + throw new ArgumentNullException(nameof(textBuffer)); } - if (this.options.QuickInfoTooltipsEnabled) + if (_options.QuickInfoTooltipsEnabled) { - return buffer.Properties.GetOrCreateSingletonProperty(() => new TemplateQuickInfoSource(buffer)); + return textBuffer.Properties.GetOrCreateSingletonProperty(() => new TemplateQuickInfoSource(textBuffer)); } return null; diff --git a/src/T4Toolbox.VisualStudio.ItemTemplates/T4Toolbox.VisualStudio.ItemTemplates.csproj b/src/T4Toolbox.VisualStudio.ItemTemplates/T4Toolbox.VisualStudio.ItemTemplates.csproj index d300072..e3a08b6 100644 --- a/src/T4Toolbox.VisualStudio.ItemTemplates/T4Toolbox.VisualStudio.ItemTemplates.csproj +++ b/src/T4Toolbox.VisualStudio.ItemTemplates/T4Toolbox.VisualStudio.ItemTemplates.csproj @@ -21,6 +21,8 @@ false false false + v4.7.2 + @@ -58,4 +60,4 @@ - + \ No newline at end of file diff --git a/src/T4Toolbox.VisualStudio/Resources.Designer.cs b/src/T4Toolbox.VisualStudio/Resources.Designer.cs index c81db75..6987f9b 100644 --- a/src/T4Toolbox.VisualStudio/Resources.Designer.cs +++ b/src/T4Toolbox.VisualStudio/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace T4Toolbox.VisualStudio { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { diff --git a/src/T4Toolbox.VisualStudio/T4Toolbox.VisualStudio.csproj b/src/T4Toolbox.VisualStudio/T4Toolbox.VisualStudio.csproj index b1c22a7..05861d2 100644 --- a/src/T4Toolbox.VisualStudio/T4Toolbox.VisualStudio.csproj +++ b/src/T4Toolbox.VisualStudio/T4Toolbox.VisualStudio.csproj @@ -10,6 +10,8 @@ false false true + v4.7.2 + diff --git a/src/T4Toolbox.vsix/T4Toolbox.vsix.csproj b/src/T4Toolbox.vsix/T4Toolbox.vsix.csproj index 6f31ecc..d2e8536 100644 --- a/src/T4Toolbox.vsix/T4Toolbox.vsix.csproj +++ b/src/T4Toolbox.vsix/T4Toolbox.vsix.csproj @@ -23,6 +23,8 @@ false false + v4.7.2 + diff --git a/src/T4Toolbox.vsix/source.extension.vsixmanifest b/src/T4Toolbox.vsix/source.extension.vsixmanifest index 1141602..80c98a8 100644 --- a/src/T4Toolbox.vsix/source.extension.vsixmanifest +++ b/src/T4Toolbox.vsix/source.extension.vsixmanifest @@ -1,31 +1,31 @@  - - - T4 Toolbox for Visual Studio 2017 - Extends Text Templates with syntax colorization, error reporting, outlining, QuickInfo tooltips, statement completion, generation of multiple output files with source control integration, support for template parameters in Solution Explorer properties and more. - https://github.com/olegsych/T4Toolbox - License.txt - http://olegsych.github.io/T4Toolbox/getting-started.html - https://github.com/olegsych/T4Toolbox/releases - - - - - - - - - - - - - - - - - - - - + + + T4 Toolbox for Visual Studio 2019 + Extends Text Templates with syntax colorization, error reporting, outlining, QuickInfo tooltips, statement completion, generation of multiple output files with source control integration, support for template parameters in Solution Explorer properties and more. + https://github.com/olegsych/T4Toolbox + License.txt + http://olegsych.github.io/T4Toolbox/getting-started.html + https://github.com/olegsych/T4Toolbox/releases + + + + + + + + + + + + + + + + + + + + diff --git a/src/T4Toolbox/T4Toolbox.csproj b/src/T4Toolbox/T4Toolbox.csproj index 1f4013f..949d8f0 100644 --- a/src/T4Toolbox/T4Toolbox.csproj +++ b/src/T4Toolbox/T4Toolbox.csproj @@ -3,6 +3,8 @@ {682E771A-76F7-4972-BBDC-1250B67F399B} Library + v4.7.2 + diff --git a/test/T4Toolbox.VisualStudio.Editor.Tests/T4Toolbox.VisualStudio.Editor.Tests.csproj b/test/T4Toolbox.VisualStudio.Editor.Tests/T4Toolbox.VisualStudio.Editor.Tests.csproj index 04650d0..56f838e 100644 --- a/test/T4Toolbox.VisualStudio.Editor.Tests/T4Toolbox.VisualStudio.Editor.Tests.csproj +++ b/test/T4Toolbox.VisualStudio.Editor.Tests/T4Toolbox.VisualStudio.Editor.Tests.csproj @@ -12,6 +12,10 @@ + + False + ..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VSSDK\VisualStudioIntegration\Common\Assemblies\v4.0\Microsoft.VisualStudio.Language.dll + From 6a6f228dbefd9d8d5a44d933aa7fab7bbcd63a99 Mon Sep 17 00:00:00 2001 From: Peter Malik Date: Thu, 4 Apr 2019 08:33:36 +0200 Subject: [PATCH 02/10] Put back 'this' --- .../TemplateQuickInfoSourceProvider.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/T4Toolbox.VisualStudio.Editor/TemplateQuickInfoSourceProvider.cs b/src/T4Toolbox.VisualStudio.Editor/TemplateQuickInfoSourceProvider.cs index d2f75da..b143782 100644 --- a/src/T4Toolbox.VisualStudio.Editor/TemplateQuickInfoSourceProvider.cs +++ b/src/T4Toolbox.VisualStudio.Editor/TemplateQuickInfoSourceProvider.cs @@ -14,7 +14,7 @@ namespace T4Toolbox.VisualStudio.Editor [Name("Template Quick Info Source"), Order(Before = "Default Quick Info Presenter")] internal sealed class TemplateQuickInfoSourceProvider : IAsyncQuickInfoSourceProvider { - private readonly ITemplateEditorOptions _options; + private readonly ITemplateEditorOptions options; [ImportingConstructor] public TemplateQuickInfoSourceProvider(ITemplateEditorOptions options) @@ -24,7 +24,7 @@ public TemplateQuickInfoSourceProvider(ITemplateEditorOptions options) throw new ArgumentNullException(nameof(options)); } - _options = options; + this.options = options; } public IAsyncQuickInfoSource TryCreateQuickInfoSource(ITextBuffer textBuffer) @@ -34,7 +34,7 @@ public IAsyncQuickInfoSource TryCreateQuickInfoSource(ITextBuffer textBuffer) throw new ArgumentNullException(nameof(textBuffer)); } - if (_options.QuickInfoTooltipsEnabled) + if (options.QuickInfoTooltipsEnabled) { return textBuffer.Properties.GetOrCreateSingletonProperty(() => new TemplateQuickInfoSource(textBuffer)); } From 23ef1a363ed60f87538291ee9e4aa5c147e38273 Mon Sep 17 00:00:00 2001 From: Peter Malik Date: Thu, 4 Apr 2019 08:34:36 +0200 Subject: [PATCH 03/10] Put back 'this' --- src/T4Toolbox.VisualStudio.Editor/TemplateQuickInfoSource.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/T4Toolbox.VisualStudio.Editor/TemplateQuickInfoSource.cs b/src/T4Toolbox.VisualStudio.Editor/TemplateQuickInfoSource.cs index b07b701..96f5028 100644 --- a/src/T4Toolbox.VisualStudio.Editor/TemplateQuickInfoSource.cs +++ b/src/T4Toolbox.VisualStudio.Editor/TemplateQuickInfoSource.cs @@ -18,7 +18,7 @@ internal sealed class TemplateQuickInfoSource : IAsyncQuickInfoSource public TemplateQuickInfoSource(ITextBuffer buffer) { Debug.Assert(buffer != null, "buffer"); - analyzer = TemplateAnalyzer.GetOrCreate(buffer); + this.analyzer = TemplateAnalyzer.GetOrCreate(buffer); } public Task GetQuickInfoItemAsync(IAsyncQuickInfoSession session, CancellationToken cancellationToken) @@ -29,7 +29,7 @@ public Task GetQuickInfoItemAsync(IAsyncQuickInfoSession session, throw new ArgumentNullException("session"); } - TemplateAnalysis analysis = analyzer.CurrentAnalysis; + TemplateAnalysis analysis = this.analyzer.CurrentAnalysis; SnapshotPoint? triggerPoint = session.GetTriggerPoint(analysis.TextSnapshot); if (triggerPoint != null && analysis.Template != null) { From cdb5e1132220637ec16944d86bd7922d1fcaac24 Mon Sep 17 00:00:00 2001 From: Peter Malik Date: Thu, 4 Apr 2019 08:36:53 +0200 Subject: [PATCH 04/10] Put back 'this' --- .../TemplateQuickInfoSourceProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/T4Toolbox.VisualStudio.Editor/TemplateQuickInfoSourceProvider.cs b/src/T4Toolbox.VisualStudio.Editor/TemplateQuickInfoSourceProvider.cs index b143782..6053195 100644 --- a/src/T4Toolbox.VisualStudio.Editor/TemplateQuickInfoSourceProvider.cs +++ b/src/T4Toolbox.VisualStudio.Editor/TemplateQuickInfoSourceProvider.cs @@ -34,7 +34,7 @@ public IAsyncQuickInfoSource TryCreateQuickInfoSource(ITextBuffer textBuffer) throw new ArgumentNullException(nameof(textBuffer)); } - if (options.QuickInfoTooltipsEnabled) + if (this.options.QuickInfoTooltipsEnabled) { return textBuffer.Properties.GetOrCreateSingletonProperty(() => new TemplateQuickInfoSource(textBuffer)); } From d9aff85b734f94fc3a8d9e91fd42ed0ef73fa3ef Mon Sep 17 00:00:00 2001 From: Peter Malik Date: Thu, 4 Apr 2019 08:57:38 +0200 Subject: [PATCH 05/10] Try fix tests --- .../FakeQuickInfoSession.cs | 72 +++++-------------- .../TemplateQuickInfoSourceProviderTest.cs | 12 ++-- .../TemplateQuickInfoSourceTest.cs | 38 +++++----- 3 files changed, 41 insertions(+), 81 deletions(-) diff --git a/test/T4Toolbox.VisualStudio.Editor.Tests/FakeQuickInfoSession.cs b/test/T4Toolbox.VisualStudio.Editor.Tests/FakeQuickInfoSession.cs index 138701b..1957edf 100644 --- a/test/T4Toolbox.VisualStudio.Editor.Tests/FakeQuickInfoSession.cs +++ b/test/T4Toolbox.VisualStudio.Editor.Tests/FakeQuickInfoSession.cs @@ -5,109 +5,73 @@ namespace T4Toolbox.VisualStudio.Editor { using System; + using System.Collections.Generic; + using System.Threading.Tasks; using Microsoft.VisualStudio.Language.Intellisense; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Editor; using Microsoft.VisualStudio.Utilities; - internal class FakeQuickInfoSession : IQuickInfoSession + internal class FakeQuickInfoSession : IAsyncQuickInfoSession { public SnapshotPoint? SnapshotTriggerPoint { get; set; } - #region IQuickInfoSession + #region IAsyncQuickInfoSession - ITrackingSpan IQuickInfoSession.ApplicableToSpan + public ITrackingSpan ApplicableToSpan { get { throw new NotImplementedException(); } } - event EventHandler IQuickInfoSession.ApplicableToSpanChanged - { - add { throw new NotImplementedException(); } - remove { throw new NotImplementedException(); } - } - - BulkObservableCollection IQuickInfoSession.QuickInfoContent + public IEnumerable Content { get { throw new NotImplementedException(); } } - bool IQuickInfoSession.TrackMouse + public bool HasInteractiveContent { get { throw new NotImplementedException(); } } - void IIntellisenseSession.Collapse() + public QuickInfoSessionOptions Options { - throw new NotImplementedException(); - } - - void IIntellisenseSession.Dismiss() - { - throw new NotImplementedException(); - } - - event EventHandler IIntellisenseSession.Dismissed - { - add { throw new NotImplementedException(); } - remove { throw new NotImplementedException(); } - } - - SnapshotPoint? IIntellisenseSession.GetTriggerPoint(ITextSnapshot textSnapshot) - { - return this.SnapshotTriggerPoint; - } - - ITrackingPoint IIntellisenseSession.GetTriggerPoint(ITextBuffer textBuffer) - { - throw new NotImplementedException(); + get { throw new NotImplementedException(); } } - bool IIntellisenseSession.IsDismissed + public QuickInfoSessionState State { get { throw new NotImplementedException(); } } - bool IIntellisenseSession.Match() + public ITextView TextView { - throw new NotImplementedException(); + get { throw new NotImplementedException(); } } - IIntellisensePresenter IIntellisenseSession.Presenter + public PropertyCollection Properties { get { throw new NotImplementedException(); } } - event EventHandler IIntellisenseSession.PresenterChanged + public event EventHandler StateChanged { add { throw new NotImplementedException(); } remove { throw new NotImplementedException(); } } - void IIntellisenseSession.Recalculate() + public Task DismissAsync() { throw new NotImplementedException(); } - event EventHandler IIntellisenseSession.Recalculated - { - add { throw new NotImplementedException(); } - remove { throw new NotImplementedException(); } - } - - void IIntellisenseSession.Start() + public ITrackingPoint GetTriggerPoint(ITextBuffer textBuffer) { throw new NotImplementedException(); } - ITextView IIntellisenseSession.TextView + public SnapshotPoint? GetTriggerPoint(ITextSnapshot snapshot) { - get { throw new NotImplementedException(); } - } - - PropertyCollection IPropertyOwner.Properties - { - get { throw new NotImplementedException(); } + return this.SnapshotTriggerPoint; } #endregion diff --git a/test/T4Toolbox.VisualStudio.Editor.Tests/TemplateQuickInfoSourceProviderTest.cs b/test/T4Toolbox.VisualStudio.Editor.Tests/TemplateQuickInfoSourceProviderTest.cs index 37d7888..3e77ab7 100644 --- a/test/T4Toolbox.VisualStudio.Editor.Tests/TemplateQuickInfoSourceProviderTest.cs +++ b/test/T4Toolbox.VisualStudio.Editor.Tests/TemplateQuickInfoSourceProviderTest.cs @@ -30,14 +30,14 @@ public static void TemplateQuickInfoSourceProviderIsSealedAndNotMeantToHaveChild [Fact] public static void TemplateQuickInfoSourceProviderImplementsIQuickSourceProviderInterface() { - Assert.Equal(typeof(IQuickInfoSourceProvider), typeof(TemplateQuickInfoSourceProvider).GetInterfaces()[0]); + Assert.Equal(typeof(IAsyncQuickInfoSourceProvider), typeof(TemplateQuickInfoSourceProvider).GetInterfaces()[0]); } [Fact] public static void TemplateQuickInfoSourceProviderExportsIQuickSourceProviderInterface() { ExportAttribute attribute = typeof(TemplateQuickInfoSourceProvider).GetCustomAttributes(false).OfType().Single(); - Assert.Equal(typeof(IQuickInfoSourceProvider), attribute.ContractType); + Assert.Equal(typeof(IAsyncQuickInfoSourceProvider), attribute.ContractType); } [Fact] @@ -67,7 +67,7 @@ public static void TemplateQuickInfoSourceProviderCanBeConstructedByVisualStudio typeof(SubstituteExporter))) using (var container = new CompositionContainer(catalog)) { - Lazy export = container.GetExport(); + Lazy export = container.GetExport(); Assert.IsType(export.Value); } } @@ -93,7 +93,7 @@ public static void TryCreateQuickInfoSourceReturnsTemplateQuickInfoSource() ITemplateEditorOptions options = OptionsWithQuickInfoTooltipsEnabled(true); var provider = new TemplateQuickInfoSourceProvider(options); var textBuffer = new FakeTextBuffer(string.Empty); - IQuickInfoSource quickInfoSource = provider.TryCreateQuickInfoSource(textBuffer); + IAsyncQuickInfoSource quickInfoSource = provider.TryCreateQuickInfoSource(textBuffer); Assert.Equal(typeof(TemplateQuickInfoSource), quickInfoSource.GetType()); } @@ -103,8 +103,8 @@ public static void TryCreateQuickInfoSourceReturnsSameObjectWhenCalledMultipleTi ITemplateEditorOptions options = OptionsWithQuickInfoTooltipsEnabled(true); var provider = new TemplateQuickInfoSourceProvider(options); var textBuffer = new FakeTextBuffer(string.Empty); - IQuickInfoSource source1 = provider.TryCreateQuickInfoSource(textBuffer); - IQuickInfoSource source2 = provider.TryCreateQuickInfoSource(textBuffer); + IAsyncQuickInfoSource source1 = provider.TryCreateQuickInfoSource(textBuffer); + IAsyncQuickInfoSource source2 = provider.TryCreateQuickInfoSource(textBuffer); Assert.Same(source1, source2); } diff --git a/test/T4Toolbox.VisualStudio.Editor.Tests/TemplateQuickInfoSourceTest.cs b/test/T4Toolbox.VisualStudio.Editor.Tests/TemplateQuickInfoSourceTest.cs index e94ae99..8298b39 100644 --- a/test/T4Toolbox.VisualStudio.Editor.Tests/TemplateQuickInfoSourceTest.cs +++ b/test/T4Toolbox.VisualStudio.Editor.Tests/TemplateQuickInfoSourceTest.cs @@ -6,6 +6,8 @@ namespace T4Toolbox.VisualStudio.Editor { using System; using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; using Microsoft.VisualStudio.Text; using Xunit; @@ -24,80 +26,74 @@ public static void TemplateQuickInfoSourceIsSealedAndNotMeantToBeExtended() } [Fact] - public static void AugmentQuickInfoSessionReturnsNoContentOrApplicableSpanWhenBufferIsEmpty() + public static async Task AugmentQuickInfoSessionReturnsNoContentOrApplicableSpanWhenBufferIsEmpty() { var buffer = new FakeTextBuffer(string.Empty); var session = new FakeQuickInfoSession(); using (var source = new TemplateQuickInfoSource(buffer)) { var quickInfoContent = new List(); - ITrackingSpan applicableToSpan; - source.AugmentQuickInfoSession(session, quickInfoContent, out applicableToSpan); + var result = await source.GetQuickInfoItemAsync(session, CancellationToken.None); Assert.Equal(0, quickInfoContent.Count); - Assert.Null(applicableToSpan); + Assert.Null(result.ApplicableToSpan); } } [Fact] - public static void AugmentQuickInfoSessionReturnsNoContentOrApplicableSpanSyntaxNodeAtTriggerPointHasNoDescription() + public static async Task AugmentQuickInfoSessionReturnsNoContentOrApplicableSpanSyntaxNodeAtTriggerPointHasNoDescription() { var buffer = new FakeTextBuffer("<# code #>"); var session = new FakeQuickInfoSession { SnapshotTriggerPoint = new SnapshotPoint(buffer.CurrentSnapshot, 3) }; using (var source = new TemplateQuickInfoSource(buffer)) { var quickInfoContent = new List(); - ITrackingSpan applicableToSpan; - source.AugmentQuickInfoSession(session, quickInfoContent, out applicableToSpan); + var result = await source.GetQuickInfoItemAsync(session, CancellationToken.None); Assert.Equal(0, quickInfoContent.Count); - Assert.Null(applicableToSpan); + Assert.Null(result.ApplicableToSpan); } } [Fact] - public static void AugmentQuickInfoSessionReturnsNoContentOrApplicableSpanWhenBufferContainsTemplateThatCouldNotBeParsed() + public static async Task AugmentQuickInfoSessionReturnsNoContentOrApplicableSpanWhenBufferContainsTemplateThatCouldNotBeParsed() { var buffer = new FakeTextBuffer("<#"); var session = new FakeQuickInfoSession { SnapshotTriggerPoint = new SnapshotPoint(buffer.CurrentSnapshot, 1) }; using (var source = new TemplateQuickInfoSource(buffer)) { var quickInfoContent = new List(); - ITrackingSpan applicableToSpan; - source.AugmentQuickInfoSession(session, quickInfoContent, out applicableToSpan); + var result = await source.GetQuickInfoItemAsync(session, CancellationToken.None); Assert.Equal(0, quickInfoContent.Count); - Assert.Null(applicableToSpan); + Assert.Null(result.ApplicableToSpan); } } [Fact] - public static void AugmentQuickInfoSessionReturnsDescriptionOfSyntaxNodeAtTriggerPoint() + public static async Task AugmentQuickInfoSessionReturnsDescriptionOfSyntaxNodeAtTriggerPoint() { var buffer = new FakeTextBuffer("<#@ assembly name=\"System\" #>"); var session = new FakeQuickInfoSession { SnapshotTriggerPoint = new SnapshotPoint(buffer.CurrentSnapshot, 5) }; using (var source = new TemplateQuickInfoSource(buffer)) { - var quickInfoContent = new List(); - ITrackingSpan applicableToSpan; - source.AugmentQuickInfoSession(session, quickInfoContent, out applicableToSpan); + var result = await source.GetQuickInfoItemAsync(session, CancellationToken.None); - Assert.Contains("assembly", (string)quickInfoContent[0], StringComparison.Ordinal); + Assert.Contains("assembly", (string)result.Item, StringComparison.Ordinal); } } [Fact] - public static void AugmentQuickInfoSessionReturnsSpanOfSyntaxNodeProvidingDescription() + public static async Task AugmentQuickInfoSessionReturnsSpanOfSyntaxNodeProvidingDescription() { var buffer = new FakeTextBuffer("<#@ assembly name=\"System\" #>"); var session = new FakeQuickInfoSession { SnapshotTriggerPoint = new SnapshotPoint(buffer.CurrentSnapshot, 15) }; using (var source = new TemplateQuickInfoSource(buffer)) { var quickInfoContent = new List(); - ITrackingSpan applicableToSpan; - source.AugmentQuickInfoSession(session, quickInfoContent, out applicableToSpan); + var result = await source.GetQuickInfoItemAsync(session, CancellationToken.None); - Assert.Equal(new Span(13, 13), applicableToSpan.GetSpan(buffer.CurrentSnapshot).Span); + Assert.Equal(new Span(13, 13), result.ApplicableToSpan.GetSpan(buffer.CurrentSnapshot).Span); } } } From 786f1fb86013dc782382a05b1e30fe42ae862f37 Mon Sep 17 00:00:00 2001 From: Peter Malik Date: Thu, 4 Apr 2019 09:58:19 +0200 Subject: [PATCH 06/10] Fix 'CreateTaggerThrowsArgumentNullExceptionWhenBufferIsNullToFailFast' test --- .../TemplateQuickInfoSourceProviderTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/T4Toolbox.VisualStudio.Editor.Tests/TemplateQuickInfoSourceProviderTest.cs b/test/T4Toolbox.VisualStudio.Editor.Tests/TemplateQuickInfoSourceProviderTest.cs index 3e77ab7..37005d7 100644 --- a/test/T4Toolbox.VisualStudio.Editor.Tests/TemplateQuickInfoSourceProviderTest.cs +++ b/test/T4Toolbox.VisualStudio.Editor.Tests/TemplateQuickInfoSourceProviderTest.cs @@ -84,7 +84,7 @@ public static void CreateTaggerThrowsArgumentNullExceptionWhenBufferIsNullToFail { var provider = new TemplateQuickInfoSourceProvider(Substitute.For()); var e = Assert.Throws(() => provider.TryCreateQuickInfoSource(null)); - Assert.Equal("buffer", e.ParamName); + Assert.Equal("textBuffer", e.ParamName); } [Fact] From 90a00c36fe9bc3b7ec0d07d413001c74b114a7da Mon Sep 17 00:00:00 2001 From: Peter Malik Date: Thu, 4 Apr 2019 10:00:19 +0200 Subject: [PATCH 07/10] Remove unused fields in test --- .../TemplateQuickInfoSourceTest.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/test/T4Toolbox.VisualStudio.Editor.Tests/TemplateQuickInfoSourceTest.cs b/test/T4Toolbox.VisualStudio.Editor.Tests/TemplateQuickInfoSourceTest.cs index 8298b39..7bc89c9 100644 --- a/test/T4Toolbox.VisualStudio.Editor.Tests/TemplateQuickInfoSourceTest.cs +++ b/test/T4Toolbox.VisualStudio.Editor.Tests/TemplateQuickInfoSourceTest.cs @@ -32,10 +32,8 @@ public static async Task AugmentQuickInfoSessionReturnsNoContentOrApplicableSpan var session = new FakeQuickInfoSession(); using (var source = new TemplateQuickInfoSource(buffer)) { - var quickInfoContent = new List(); var result = await source.GetQuickInfoItemAsync(session, CancellationToken.None); - Assert.Equal(0, quickInfoContent.Count); Assert.Null(result.ApplicableToSpan); } } @@ -47,10 +45,8 @@ public static async Task AugmentQuickInfoSessionReturnsNoContentOrApplicableSpan var session = new FakeQuickInfoSession { SnapshotTriggerPoint = new SnapshotPoint(buffer.CurrentSnapshot, 3) }; using (var source = new TemplateQuickInfoSource(buffer)) { - var quickInfoContent = new List(); var result = await source.GetQuickInfoItemAsync(session, CancellationToken.None); - Assert.Equal(0, quickInfoContent.Count); Assert.Null(result.ApplicableToSpan); } } @@ -62,10 +58,8 @@ public static async Task AugmentQuickInfoSessionReturnsNoContentOrApplicableSpan var session = new FakeQuickInfoSession { SnapshotTriggerPoint = new SnapshotPoint(buffer.CurrentSnapshot, 1) }; using (var source = new TemplateQuickInfoSource(buffer)) { - var quickInfoContent = new List(); var result = await source.GetQuickInfoItemAsync(session, CancellationToken.None); - Assert.Equal(0, quickInfoContent.Count); Assert.Null(result.ApplicableToSpan); } } @@ -90,7 +84,6 @@ public static async Task AugmentQuickInfoSessionReturnsSpanOfSyntaxNodeProviding var session = new FakeQuickInfoSession { SnapshotTriggerPoint = new SnapshotPoint(buffer.CurrentSnapshot, 15) }; using (var source = new TemplateQuickInfoSource(buffer)) { - var quickInfoContent = new List(); var result = await source.GetQuickInfoItemAsync(session, CancellationToken.None); Assert.Equal(new Span(13, 13), result.ApplicableToSpan.GetSpan(buffer.CurrentSnapshot).Span); From f7f2ec92aceee1ae01ae1a856482b46b5fb3006e Mon Sep 17 00:00:00 2001 From: Peter Malik Date: Thu, 4 Apr 2019 10:02:31 +0200 Subject: [PATCH 08/10] Try Fix 'TemplateQuickInfoSourceTest' test --- .../TemplateQuickInfoSourceTest.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/T4Toolbox.VisualStudio.Editor.Tests/TemplateQuickInfoSourceTest.cs b/test/T4Toolbox.VisualStudio.Editor.Tests/TemplateQuickInfoSourceTest.cs index 7bc89c9..acf76fd 100644 --- a/test/T4Toolbox.VisualStudio.Editor.Tests/TemplateQuickInfoSourceTest.cs +++ b/test/T4Toolbox.VisualStudio.Editor.Tests/TemplateQuickInfoSourceTest.cs @@ -34,7 +34,7 @@ public static async Task AugmentQuickInfoSessionReturnsNoContentOrApplicableSpan { var result = await source.GetQuickInfoItemAsync(session, CancellationToken.None); - Assert.Null(result.ApplicableToSpan); + Assert.Null(result?.ApplicableToSpan); } } @@ -47,7 +47,7 @@ public static async Task AugmentQuickInfoSessionReturnsNoContentOrApplicableSpan { var result = await source.GetQuickInfoItemAsync(session, CancellationToken.None); - Assert.Null(result.ApplicableToSpan); + Assert.Null(result?.ApplicableToSpan); } } @@ -60,7 +60,7 @@ public static async Task AugmentQuickInfoSessionReturnsNoContentOrApplicableSpan { var result = await source.GetQuickInfoItemAsync(session, CancellationToken.None); - Assert.Null(result.ApplicableToSpan); + Assert.Null(result?.ApplicableToSpan); } } From a828efb12d2aa43295d0b8caf02f608ca5334c11 Mon Sep 17 00:00:00 2001 From: Peter Malik Date: Thu, 4 Apr 2019 10:04:33 +0200 Subject: [PATCH 09/10] Remove unused using --- .../TemplateQuickInfoSourceTest.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/T4Toolbox.VisualStudio.Editor.Tests/TemplateQuickInfoSourceTest.cs b/test/T4Toolbox.VisualStudio.Editor.Tests/TemplateQuickInfoSourceTest.cs index acf76fd..60b5b30 100644 --- a/test/T4Toolbox.VisualStudio.Editor.Tests/TemplateQuickInfoSourceTest.cs +++ b/test/T4Toolbox.VisualStudio.Editor.Tests/TemplateQuickInfoSourceTest.cs @@ -5,10 +5,11 @@ namespace T4Toolbox.VisualStudio.Editor { using System; - using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; + using Microsoft.VisualStudio.Text; + using Xunit; public static class TemplateQuickInfoSourceTest From 0d1e8978939c0b5b9e77bbcf4ffca6d57486ca35 Mon Sep 17 00:00:00 2001 From: Peter Malik Date: Thu, 4 Apr 2019 10:19:31 +0200 Subject: [PATCH 10/10] Remove hint path from reference --- .../T4Toolbox.VisualStudio.Editor.csproj | 5 +---- .../T4Toolbox.VisualStudio.Editor.Tests.csproj | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/T4Toolbox.VisualStudio.Editor/T4Toolbox.VisualStudio.Editor.csproj b/src/T4Toolbox.VisualStudio.Editor/T4Toolbox.VisualStudio.Editor.csproj index b9d4c6c..146cf53 100644 --- a/src/T4Toolbox.VisualStudio.Editor/T4Toolbox.VisualStudio.Editor.csproj +++ b/src/T4Toolbox.VisualStudio.Editor/T4Toolbox.VisualStudio.Editor.csproj @@ -13,10 +13,7 @@ - - False - ..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VSSDK\VisualStudioIntegration\Common\Assemblies\v4.0\Microsoft.VisualStudio.Language.dll - + diff --git a/test/T4Toolbox.VisualStudio.Editor.Tests/T4Toolbox.VisualStudio.Editor.Tests.csproj b/test/T4Toolbox.VisualStudio.Editor.Tests/T4Toolbox.VisualStudio.Editor.Tests.csproj index 56f838e..fc43aef 100644 --- a/test/T4Toolbox.VisualStudio.Editor.Tests/T4Toolbox.VisualStudio.Editor.Tests.csproj +++ b/test/T4Toolbox.VisualStudio.Editor.Tests/T4Toolbox.VisualStudio.Editor.Tests.csproj @@ -12,10 +12,7 @@ - - False - ..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VSSDK\VisualStudioIntegration\Common\Assemblies\v4.0\Microsoft.VisualStudio.Language.dll - +