From d77704b837dcea71daf3ce7ae74f9fdc6f3b012f Mon Sep 17 00:00:00 2001 From: Mads Kristensen Date: Wed, 11 May 2022 11:15:09 -0700 Subject: [PATCH] Updated NuGet packages and added rating prompt [release] --- src/RestClient/Constants.cs | 1 + src/RestClientVS/Editor/EditorFeatures.cs | 25 +++++++++++++++++++++++ src/RestClientVS/Options/General.cs | 5 ++++- src/RestClientVS/RestClientVS.csproj | 8 ++++---- 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/RestClient/Constants.cs b/src/RestClient/Constants.cs index ea872d0..d387250 100644 --- a/src/RestClient/Constants.cs +++ b/src/RestClient/Constants.cs @@ -3,5 +3,6 @@ public class Constants { public const char CommentChar = '#'; + public const string MarketplaceId = "MadsKristensen.RestClient"; } } diff --git a/src/RestClientVS/Editor/EditorFeatures.cs b/src/RestClientVS/Editor/EditorFeatures.cs index 3cef51a..a07cf96 100644 --- a/src/RestClientVS/Editor/EditorFeatures.cs +++ b/src/RestClientVS/Editor/EditorFeatures.cs @@ -1,9 +1,15 @@ using System.Collections.Generic; using System.ComponentModel.Composition; +using Microsoft.VisualStudio.Imaging; +using System.Linq; +using System.Text.RegularExpressions; +using System.Threading.Tasks; using Microsoft.VisualStudio.Language.Intellisense; using Microsoft.VisualStudio.Language.Intellisense.AsyncCompletion; using Microsoft.VisualStudio.Language.StandardClassification; +using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.BraceCompletion; +using Microsoft.VisualStudio.Text.Editor; using Microsoft.VisualStudio.Text.Tagging; using Microsoft.VisualStudio.Utilities; using RestClient; @@ -79,4 +85,23 @@ internal sealed class BraceMatchingTaggerProvider : BraceMatchingBase [TagType(typeof(TextMarkerTag))] public class SameWordHighlighter : SameWordHighlighterBase { } + + [Export(typeof(IWpfTextViewCreationListener))] + [ContentType(LanguageFactory.LanguageName)] + [TextViewRole(PredefinedTextViewRoles.PrimaryDocument)] + public class UserRating : WpfTextViewCreationListener + { + private readonly RatingPrompt _rating = new(Constants.MarketplaceId, Vsix.Name, General.Instance); + private readonly DateTime _openedDate = DateTime.Now; + + protected override void Closed(IWpfTextView textView) + { + if (_openedDate.AddMinutes(2) < DateTime.Now) + { + // Only register use after the document was open for more than 2 minutes. + _rating.RegisterSuccessfulUsage(); + + } + } + } } diff --git a/src/RestClientVS/Options/General.cs b/src/RestClientVS/Options/General.cs index b813aeb..e7ef13e 100644 --- a/src/RestClientVS/Options/General.cs +++ b/src/RestClientVS/Options/General.cs @@ -9,7 +9,7 @@ internal partial class OptionsProvider public class GeneralOptions : BaseOptionPage { } } - public class General : BaseOptionModel + public class General : BaseOptionModel, IRatingConfig { [Category("General")] [DisplayName("Request timeout")] @@ -29,5 +29,8 @@ public class General : BaseOptionModel [Browsable(false)] [DefaultValue(500)] public int ResponseWindowWidth { get; set; } = 500; + + [Browsable(false)] + public int RatingRequests { get; set; } } } diff --git a/src/RestClientVS/RestClientVS.csproj b/src/RestClientVS/RestClientVS.csproj index 1fb1fe3..7d3f3a9 100644 --- a/src/RestClientVS/RestClientVS.csproj +++ b/src/RestClientVS/RestClientVS.csproj @@ -113,13 +113,13 @@ - + compile; build; native; contentfiles; analyzers; buildtransitive - - 17.0.64 + + runtime; build; native; contentfiles; analyzers; buildtransitive + all -