Skip to content

Commit c4dbc08

Browse files
committed
VS 2.0.2, fix install csharpier warning that shows up in every new instance
1 parent 9e9df25 commit c4dbc08

4 files changed

Lines changed: 37 additions & 6 deletions

File tree

Src/CSharpier.VisualStudio/CSharpier.VisualStudio/source.extension.vsixmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
33
<Metadata>
4-
<Identity Id="83d6b6a0-9e25-4034-80f3-38445d8a8837" Version="2.0.1" Language="en-US" Publisher="CSharpier" />
4+
<Identity Id="83d6b6a0-9e25-4034-80f3-38445d8a8837" Version="2.0.2" Language="en-US" Publisher="CSharpier" />
55
<DisplayName>CSharpier</DisplayName>
66
<Description xml:space="preserve">CSharpier is an opinionated code formatter for c#. It uses Roslyn to parse your code and re-prints it using its own rules.</Description>
77
<MoreInfo>https://github.com/belav/csharpier</MoreInfo>

Src/CSharpier.VisualStudio/CSharpier.VisualStudio2019/source.extension.vsixmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
33
<Metadata>
4-
<Identity Id="edd8b38c-baa1-46c6-b82e-1da7a0ba597b" Version="2.0.1" Language="en-US" Publisher="CSharpier" />
4+
<Identity Id="edd8b38c-baa1-46c6-b82e-1da7a0ba597b" Version="2.0.2" Language="en-US" Publisher="CSharpier" />
55
<DisplayName>CSharpier 2019</DisplayName>
66
<Description xml:space="preserve">CSharpier is an opinionated code formatter for c#. It uses Roslyn to parse your code and re-prints it using its own rules.</Description>
77
<MoreInfo>https://github.com/belav/csharpier</MoreInfo>

Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/InstallerService.cs

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
using System.IO;
33
using System.Threading.Tasks;
44
using EnvDTE;
5+
using Microsoft.VisualStudio.Settings;
6+
using Microsoft.VisualStudio.Shell.Interop;
7+
using Microsoft.VisualStudio.Shell.Settings;
58

69
namespace CSharpier.VisualStudio
710
{
@@ -11,19 +14,42 @@ public class InstallerService
1114
private readonly DTE dte;
1215

1316
private bool warnedAlready;
17+
private const string InstallerWarningShownKey = "CSharpier.InstallerWarningShown";
18+
private const string CollectionName = "CSharpier";
19+
private readonly WritableSettingsStore settingsStore;
1420

15-
public static InstallerService Instance { get; private set; } = default!;
21+
public static InstallerService Instance { get; private set; } = null!;
1622

1723
public static async Task InitializeAsync(CSharpierPackage package)
1824
{
1925
var dte = await package.GetServiceAsync(typeof(DTE)) as DTE;
20-
Instance = new InstallerService(dte!);
26+
var settingsManager =
27+
await package.GetServiceAsync(typeof(SVsSettingsManager)) as IVsSettingsManager;
28+
29+
var writableSettingsStore = new ShellSettingsManager(
30+
settingsManager
31+
).GetWritableSettingsStore(SettingsScope.UserSettings);
32+
Instance = new InstallerService(dte!, writableSettingsStore);
2133
}
2234

23-
private InstallerService(DTE dte)
35+
private InstallerService(DTE dte, WritableSettingsStore settingsStore)
2436
{
2537
this.logger = Logger.Instance;
2638
this.dte = dte;
39+
40+
this.settingsStore = settingsStore;
41+
42+
if (!this.settingsStore.CollectionExists(CollectionName))
43+
{
44+
this.settingsStore.CreateCollection(CollectionName);
45+
}
46+
47+
this.warnedAlready = this.settingsStore.GetBoolean(
48+
CollectionName,
49+
InstallerWarningShownKey,
50+
false
51+
);
52+
this.logger.Debug(InstallerWarningShownKey + " was " + this.warnedAlready);
2753
}
2854

2955
public void DisplayInstallNeededMessage(
@@ -37,6 +63,7 @@ IProcessKiller processKiller
3763
}
3864

3965
this.warnedAlready = true;
66+
this.settingsStore.SetBoolean(CollectionName, InstallerWarningShownKey, true);
4067
this.logger.Warn("CSharpier was not found so files may not be formatted.");
4168

4269
var solutionFullName = this.dte.Solution?.FullName;
@@ -114,6 +141,7 @@ private bool IgnoreDirectory(string directoryThatContainsFile)
114141
var normalizedPath = directoryThatContainsFile.Replace("\\", "/");
115142
return normalizedPath.ContainsIgnoreCase("Temp/TFSTemp")
116143
|| normalizedPath.ContainsIgnoreCase("Temp/MetadataAsSource")
144+
|| normalizedPath.ContainsIgnoreCase("Temp/.vsdbgsrc")
117145
|| normalizedPath.ContainsIgnoreCase("MSBuild/Current/Bin");
118146
}
119147
}

Src/CSharpier.VisualStudio/ChangeLog.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
## [2.0.1]
1+
## [2.0.2]
2+
- Remember if a user has closed the "CSharpier must be installed" warning so that it doesn't reappear in each new instance of VS
3+
4+
## [2.0.1]
25
- Set working directory for CSharpier Server to the directory that contains CSharpier. Fixes an issue with a recursive file watch being run on the project root.
36

47
## [2.0.0]

0 commit comments

Comments
 (0)