Skip to content

Commit a0d60d2

Browse files
Added user rating prompt
[release]
1 parent b850f57 commit a0d60d2

File tree

9 files changed

+57
-11
lines changed

9 files changed

+57
-11
lines changed

.github/workflows/build.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,19 @@ jobs:
3939
vsix-token-source-file: ${{ env.VsixManifestSourcePath }}
4040

4141
- name: Build
42-
run: msbuild /v:m -restore /p:OutDir=../_built
42+
run: msbuild /v:m -restore /p:OutDir=\_built
4343

4444
- name: Setup test
4545
uses: darenm/Setup-VSTest@v1
4646

4747
- name: Test
48-
run: vstest.console.exe _built\*test.dll
48+
run: vstest.console.exe \_built\*test.dll
4949

5050
- name: Upload artifact
5151
uses: actions/upload-artifact@v2
5252
with:
5353
name: ${{ github.event.repository.name }}.vsix
54-
path: _built/**/*.vsix
54+
path: /_built/**/*.vsix
5555

5656
publish:
5757
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}

src/Constants.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ public class Constants
66
public static string[] CommentChars = new[] { ";", "//" };
77
public const string PkgDefExt = ".pkgdef";
88
public const string PkgUndefExt = ".pkgundef";
9+
10+
public const string MarketplaceId = "MadsKristensen.PkgdefLanguage";
911
}
1012
}

src/Editor/EditorFeatures.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using System.ComponentModel.Composition;
34
using Microsoft.VisualStudio.Language.Intellisense;
45
using Microsoft.VisualStudio.Language.Intellisense.AsyncCompletion;
56
using Microsoft.VisualStudio.Language.StandardClassification;
67
using Microsoft.VisualStudio.Text.BraceCompletion;
8+
using Microsoft.VisualStudio.Text.Editor;
79
using Microsoft.VisualStudio.Text.Tagging;
810
using Microsoft.VisualStudio.Utilities;
911

@@ -75,4 +77,27 @@ internal sealed class BraceMatchingTaggerProvider : BraceMatchingBase
7577
[TagType(typeof(TextMarkerTag))]
7678
public class SameWordHighlighter : SameWordHighlighterBase
7779
{ }
80+
81+
[Export(typeof(IWpfTextViewCreationListener))]
82+
[ContentType(Constants.LanguageName)]
83+
[TextViewRole(PredefinedTextViewRoles.PrimaryDocument)]
84+
public class UserRatings : WpfTextViewCreationListener
85+
{
86+
private DateTime _openedDate;
87+
private RatingPrompt _rating;
88+
89+
protected override void Created(DocumentView docView)
90+
{
91+
_openedDate = DateTime.Now;
92+
_rating = new RatingPrompt(Constants.MarketplaceId, Vsix.Name, AdvancedOptions.Instance, 5);
93+
}
94+
95+
protected override void Closed(IWpfTextView textView)
96+
{
97+
if (_openedDate.AddMinutes(2) < DateTime.Now)
98+
{
99+
_rating.RegisterSuccessfulUsage();
100+
}
101+
}
102+
}
78103
}

src/Editor/TokenTagger.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,19 @@ public override Task TokenizeAsync()
5151
return Task.CompletedTask;
5252
}
5353

54-
AddTagToList(list, item);
54+
ConvertItemToTag(list, item);
5555

5656
foreach (ParseItem variable in item.References)
5757
{
58-
AddTagToList(list, variable);
58+
ConvertItemToTag(list, variable);
5959
}
6060
}
6161

6262
OnTagsUpdated(list);
6363
return Task.CompletedTask;
6464
}
6565

66-
private void AddTagToList(List<ITagSpan<TokenTag>> list, ParseItem item)
66+
private void ConvertItemToTag(List<ITagSpan<TokenTag>> list, ParseItem item)
6767
{
6868
var hasTooltip = !item.IsValid;
6969
var supportsOutlining = item is Entry entry && entry.Properties.Any();

src/Options/AdvancedOptions.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System.ComponentModel;
2+
using System.Runtime.InteropServices;
3+
4+
namespace PkgdefLanguage
5+
{
6+
internal partial class OptionsProvider
7+
{
8+
[ComVisible(true)]
9+
public class AdvancedOptionsPage : BaseOptionPage<AdvancedOptions> { }
10+
}
11+
12+
public class AdvancedOptions : BaseOptionModel<AdvancedOptions>, IRatingConfig
13+
{
14+
[Browsable(false)]
15+
public int RatingRequests { get; set; }
16+
}
17+
}

src/Parser/Document.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,11 @@ public Document(ITextBuffer buffer)
2727
_buffer.Changed += BufferChanged;
2828
FileName = buffer.GetFileName();
2929

30-
#pragma warning disable VSTHRD104 // Offer async methods
3130
ThreadHelper.JoinableTaskFactory.Run(async () =>
3231
{
3332
Project project = await VS.Solutions.GetActiveProjectAsync();
3433
ProjectName = project?.Name;
3534
});
36-
#pragma warning restore VSTHRD104 // Offer async methods
3735
}
3836

3937
public bool IsProcessing { get; private set; }

src/PkgdefLanguage.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
<UseCodebase>true</UseCodebase>
99
<AppDesignerFolder>Properties</AppDesignerFolder>
1010
<NoWarn>MSB3277</NoWarn>
11+
<NoWarn>VSTHRD104</NoWarn>
1112
<DisableWarning>MSB3277</DisableWarning>
13+
<DisableWarning>VSTHRD104</DisableWarning>
1214
</PropertyGroup>
1315
<PropertyGroup>
1416
</PropertyGroup>
@@ -70,7 +72,7 @@
7072
</None>
7173
</ItemGroup>
7274
<ItemGroup>
73-
<PackageReference Include="Community.VisualStudio.Toolkit.16" version="16.0.394" ExcludeAssets="runtime">
75+
<PackageReference Include="Community.VisualStudio.Toolkit.16" version="16.0.408" ExcludeAssets="runtime">
7476
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
7577
</PackageReference>
7678
<PackageReference Include="Microsoft.VSSDK.BuildTools">
@@ -82,6 +84,7 @@
8284
<ItemGroup>
8385
<Compile Include="Commands\Formatting.cs" />
8486
<Compile Include="Editor\DropdownBars.cs" />
87+
<Compile Include="Options\AdvancedOptions.cs" />
8588
<Compile Include="Properties\AssemblyInfo.cs" />
8689
<Compile Include="Commands\Commenting.cs" />
8790
<Compile Include="Constants.cs" />

src/PkgdefPackage.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ namespace PkgdefLanguage
1414
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
1515
[Guid(PackageGuids.PkgdefLanguageString)]
1616
[ProvideMenuResource("Menus.ctmenu", 1)]
17+
[ProvideOptionPage(typeof(OptionsProvider.AdvancedOptionsPage), "PkgdefLanguage", "Advanced", 0, 0, true, SupportsProfiles = true, NoShowAllView = true)]
1718

1819
[ProvideLanguageService(typeof(LanguageFactory), Constants.LanguageName, 0, EnableLineNumbers = true, EnableAsyncCompletion = true, ShowCompletion = true, EnableFormatSelection = false, ShowDropDownOptions = true)]
1920
[ProvideLanguageExtension(typeof(LanguageFactory), Constants.PkgDefExt)]

test/PkgdefLanguage.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<Compile Remove="C:\Users\madsk\.nuget\packages\community.visualstudio.toolkit.16\16.0.357\build\AssemblyInfo.cs" />
88
</ItemGroup>
99
<ItemGroup>
10-
<PackageReference Include="Community.VisualStudio.Toolkit.16" Version="16.0.394" />
10+
<PackageReference Include="Community.VisualStudio.Toolkit.16" Version="16.0.408" />
1111
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
1212
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
1313
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />

0 commit comments

Comments
 (0)