-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add new consistent ignores setting [IDE-723] (#322)
* fix: add new consistent ignores setting [IDE-723] --------- Co-authored-by: Abdelrahman Shawki Hassan <[email protected]> Co-authored-by: Darius-Beniamin Zdroba <[email protected]>
- Loading branch information
1 parent
154647c
commit 96ccf5d
Showing
33 changed files
with
642 additions
and
482 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
Snyk.VisualStudio.Extension.2022/Language/FeatureFlagResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Snyk.VisualStudio.Extension.Language; | ||
|
||
public class FeatureFlagResponse | ||
{ | ||
public bool Ok { get; set; } | ||
public string UserMessage { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
Snyk.VisualStudio.Extension.2022/Service/FeatureFlagService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System.Threading.Tasks; | ||
using Serilog; | ||
using Snyk.Common; | ||
using Snyk.Common.Settings; | ||
using Snyk.VisualStudio.Extension.Language; | ||
|
||
namespace Snyk.VisualStudio.Extension.Service; | ||
|
||
public class FeatureFlagService | ||
{ | ||
private readonly ILanguageClientManager languageClient; | ||
private readonly ISnykOptions settings; | ||
private static readonly ILogger Logger = LogManager.ForContext<FeatureFlagService>(); | ||
private static FeatureFlagService instance; | ||
|
||
public FeatureFlagService(ILanguageClientManager languageClient, ISnykOptions settings) | ||
{ | ||
this.languageClient = languageClient; | ||
this.settings = settings; | ||
} | ||
|
||
public static FeatureFlagService Instance => instance; | ||
|
||
/// <summary> | ||
/// Initialize service. | ||
/// </summary> | ||
/// <param name="languageClient"></param> | ||
/// <param name="settings"></param> | ||
/// <returns>Task.</returns> | ||
public static FeatureFlagService Initialize(ILanguageClientManager languageClient, ISnykOptions settings) | ||
{ | ||
if (instance != null) | ||
return instance; | ||
|
||
instance = new FeatureFlagService(languageClient, settings); | ||
|
||
Logger.Information("FeatureFlagService initialized"); | ||
return instance; | ||
} | ||
|
||
public async Task RefreshAsync() | ||
{ | ||
var result = await languageClient.InvokeGetFeatureFlagStatusAsync(LsConstants.SnykConsistentIgnoresEnabled, SnykVSPackage.Instance.DisposalToken); | ||
if (result == null) | ||
{ | ||
settings.ConsistentIgnoresEnabled = false; | ||
return; | ||
} | ||
settings.ConsistentIgnoresEnabled = result.Ok; | ||
if (!result.Ok) | ||
{ | ||
if (!result.UserMessage.IsNullOrEmpty()) Logger.Error("feature flag not enabled: {UserMessage}", result.UserMessage); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.