-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH16: Detect Existence of SpecFlow for Visual Studio Extension and sh…
…ow a dialog box warning about conflicting instances. (#26)
- Loading branch information
1 parent
9774c95
commit 6d80e62
Showing
11 changed files
with
91 additions
and
8 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
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
26 changes: 26 additions & 0 deletions
26
Reqnroll.VisualStudio/SpecFlowExtensionDetection/SpecFlowExtensionDetectionClassifier.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,26 @@ | ||
using Microsoft.VisualStudio.Text.Classification; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Reqnroll.VisualStudio.SpecFlowExtensionDetection | ||
{ | ||
[Export(typeof(IClassifierProvider))] | ||
[ContentType("gherkin")] | ||
public class SpecFlowExtensionDetectionClassifierProvider : IClassifierProvider | ||
{ | ||
private readonly SpecFlowExtensionDetectionService _detectionService; | ||
|
||
public SpecFlowExtensionDetectionClassifierProvider(SpecFlowExtensionDetectionService detectionService) | ||
{ | ||
_detectionService = detectionService; | ||
} | ||
public IClassifier GetClassifier(ITextBuffer textBuffer) | ||
{ | ||
_detectionService.CheckForSpecFlowExtension(); | ||
return null; | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
Reqnroll.VisualStudio/SpecFlowExtensionDetection/SpecFlowExtensionDetectionService.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,48 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Reqnroll.VisualStudio.SpecFlowExtensionDetection | ||
{ | ||
[Export] | ||
public class SpecFlowExtensionDetectionService | ||
{ | ||
private readonly IIdeScope _ideScope; | ||
private bool _extensionExistenceChecked = false; | ||
private bool _compatibilityAlertShown = false; | ||
|
||
[ImportingConstructor] | ||
public SpecFlowExtensionDetectionService(IIdeScope ideScope) | ||
{ | ||
_ideScope = ideScope; | ||
} | ||
|
||
public void CheckForSpecFlowExtensionOnce() | ||
{ | ||
if (_extensionExistenceChecked) | ||
return; | ||
|
||
CheckForSpecFlowExtension(); | ||
} | ||
|
||
public void CheckForSpecFlowExtension() | ||
{ | ||
if (_compatibilityAlertShown) | ||
return; | ||
|
||
_extensionExistenceChecked = true; | ||
var specFlowExtensionDetected = AppDomain.CurrentDomain.GetAssemblies().Any(a => | ||
a.FullName.StartsWith("SpecFlow.VisualStudio")); | ||
|
||
if (specFlowExtensionDetected && !_compatibilityAlertShown) | ||
{ | ||
_compatibilityAlertShown = true; | ||
_ideScope.Actions.ShowProblem( | ||
$"We detected that both the 'Reqnroll for Visual Studio 2022' and the 'SpecFlow for Visual Studio 2022' extension have been installed in this Visual Studio instance.{Environment.NewLine}For the proper behavior you need to uninstall or disable one of these extensions in the 'Extensions / Manage Extensions' dialog."); | ||
|
||
} | ||
} | ||
} | ||
} |
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
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