Skip to content

Commit 4378ead

Browse files
committed
refactor out LegacyOutProcReqnrollConnector from base class
1 parent 538cf00 commit 4378ead

File tree

5 files changed

+56
-43
lines changed

5 files changed

+56
-43
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
22
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ID/@EntryIndexedValue">ID</s:String>
3+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=53eecf85_002Dd821_002D40e8_002Dac97_002Dfdb734542b84/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Instance" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Instance fields (not private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="AaBb"&gt;&lt;ExtraRule Prefix="_" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;&lt;/Policy&gt;</s:String>
34
<s:Boolean x:Key="/Default/UserDictionary/Words/=Deveroom/@EntryIndexedValue">True</s:Boolean>
45
<s:Boolean x:Key="/Default/UserDictionary/Words/=Reqnroll/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
namespace Reqnroll.VisualStudio.Connectors;
2+
3+
public class LegacyOutProcReqnrollConnector : OutProcReqnrollConnector
4+
{
5+
private const string ConnectorV1AnyCpu = @"Reqnroll-V1\reqnroll-vs.exe";
6+
private const string ConnectorV1X86 = @"Reqnroll-V1\reqnroll-vs-x86.exe";
7+
private const string SpecFlowConnectorV1AnyCpu = @"SpecFlow-V1\specflow-vs.exe";
8+
private const string SpecFlowConnectorV1X86 = @"SpecFlow-V1\specflow-vs-x86.exe";
9+
private const string SpecFlowConnectorV2Net60 = @"SpecFlow-V2-net6.0\specflow-vs.dll";
10+
private const string SpecFlowConnectorV3Net60 = @"SpecFlow-V3-net6.0\specflow-vs.dll";
11+
12+
public LegacyOutProcReqnrollConnector(DeveroomConfiguration configuration, IDeveroomLogger logger, TargetFrameworkMoniker targetFrameworkMoniker, string extensionFolder, ProcessorArchitectureSetting processorArchitecture, ProjectSettings projectSettings, IMonitoringService monitoringService) : base(configuration, logger, targetFrameworkMoniker, extensionFolder, processorArchitecture, projectSettings, monitoringService)
13+
{
14+
}
15+
16+
protected override string GetConnectorPath(List<string> arguments)
17+
{
18+
var connectorsFolder = GetConnectorsFolder();
19+
20+
if (_targetFrameworkMoniker.IsNetCore && _projectSettings.IsSpecFlowProject)
21+
{
22+
if (ReqnrollVersion != null && ReqnrollVersion.Version >= new Version(3, 9, 22))
23+
return GetDotNetExecCommand(arguments, connectorsFolder, SpecFlowConnectorV3Net60);
24+
return GetDotNetExecCommand(arguments, connectorsFolder, SpecFlowConnectorV2Net60);
25+
}
26+
27+
//V1
28+
string connectorName = _projectSettings.IsSpecFlowProject ?
29+
SpecFlowConnectorV1AnyCpu : ConnectorV1AnyCpu;
30+
if (_processorArchitecture == ProcessorArchitectureSetting.X86)
31+
connectorName = _projectSettings.IsSpecFlowProject ?
32+
SpecFlowConnectorV1X86 : ConnectorV1X86;
33+
34+
#if DEBUG
35+
_logger.LogInfo($"Invoking '{connectorName}'...");
36+
#endif
37+
38+
return Path.Combine(connectorsFolder, connectorName);
39+
}
40+
41+
}

Reqnroll.VisualStudio/Connectors/OutProcReqnrollConnector.cs

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,20 @@
11
#nullable disable
22
namespace Reqnroll.VisualStudio.Connectors;
33

4-
public class OutProcReqnrollConnector
4+
public abstract class OutProcReqnrollConnector
55
{
6-
private const string ConnectorV1AnyCpu = @"Reqnroll-V1\reqnroll-vs.exe";
7-
private const string ConnectorV1X86 = @"Reqnroll-V1\reqnroll-vs-x86.exe";
8-
private const string SpecFlowConnectorV1AnyCpu = @"SpecFlow-V1\specflow-vs.exe";
9-
private const string SpecFlowConnectorV1X86 = @"SpecFlow-V1\specflow-vs-x86.exe";
10-
private const string SpecFlowConnectorV2Net60 = @"SpecFlow-V2-net6.0\specflow-vs.dll";
11-
private const string SpecFlowConnectorV3Net60 = @"SpecFlow-V3-net6.0\specflow-vs.dll";
126
private const string BindingDiscoveryCommandName = "binding discovery";
137

14-
private readonly DeveroomConfiguration _configuration;
15-
private readonly string _extensionFolder;
16-
private readonly IDeveroomLogger _logger;
17-
private readonly IMonitoringService _monitoringService;
18-
private readonly ProcessorArchitectureSetting _processorArchitecture;
8+
protected readonly DeveroomConfiguration _configuration;
9+
protected readonly string _extensionFolder;
10+
protected readonly IDeveroomLogger _logger;
11+
protected readonly IMonitoringService _monitoringService;
12+
protected readonly ProcessorArchitectureSetting _processorArchitecture;
1913
protected readonly ProjectSettings _projectSettings;
2014
protected readonly TargetFrameworkMoniker _targetFrameworkMoniker;
2115
protected NuGetVersion ReqnrollVersion => _projectSettings.ReqnrollVersion;
2216

23-
public OutProcReqnrollConnector(DeveroomConfiguration configuration, IDeveroomLogger logger,
17+
protected OutProcReqnrollConnector(DeveroomConfiguration configuration, IDeveroomLogger logger,
2418
TargetFrameworkMoniker targetFrameworkMoniker, string extensionFolder,
2519
ProcessorArchitectureSetting processorArchitecture, ProjectSettings projectSettings,
2620
IMonitoringService monitoringService)
@@ -127,30 +121,7 @@ private string GetDetailedErrorMessage(ProcessHelper.RunProcessResult result, st
127121
$"Error during {command}. {Environment.NewLine}Command executed:{Environment.NewLine} {result.CommandLine}{Environment.NewLine}Exit code: {exitCode}{Environment.NewLine}Message: {Environment.NewLine}{errorMessage}";
128122
}
129123

130-
protected virtual string GetConnectorPath(List<string> arguments)
131-
{
132-
var connectorsFolder = GetConnectorsFolder();
133-
134-
if (_targetFrameworkMoniker.IsNetCore && _projectSettings.IsSpecFlowProject)
135-
{
136-
if (ReqnrollVersion != null && ReqnrollVersion.Version >= new Version(3, 9, 22))
137-
return GetDotNetExecCommand(arguments, connectorsFolder, SpecFlowConnectorV3Net60);
138-
return GetDotNetExecCommand(arguments, connectorsFolder, SpecFlowConnectorV2Net60);
139-
}
140-
141-
//V1
142-
string connectorName = _projectSettings.IsSpecFlowProject ?
143-
SpecFlowConnectorV1AnyCpu : ConnectorV1AnyCpu;
144-
if (_processorArchitecture == ProcessorArchitectureSetting.X86)
145-
connectorName = _projectSettings.IsSpecFlowProject ?
146-
SpecFlowConnectorV1X86 : ConnectorV1X86;
147-
148-
#if DEBUG
149-
_logger.LogInfo($"Invoking '{connectorName}'...");
150-
#endif
151-
152-
return Path.Combine(connectorsFolder, connectorName);
153-
}
124+
protected abstract string GetConnectorPath(List<string> arguments);
154125

155126
private string GetDotNetInstallLocation()
156127
{

Reqnroll.VisualStudio/Connectors/OutProcReqnrollConnectorFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ public static OutProcReqnrollConnector CreateGeneric(IProjectScope projectScope)
1818
ideScope.MonitoringService);
1919
}
2020

21-
public static OutProcReqnrollConnector Create(IProjectScope projectScope)
21+
public static OutProcReqnrollConnector CreateLegacy(IProjectScope projectScope)
2222
{
2323
var ideScope = projectScope.IdeScope;
2424
var projectSettings = projectScope.GetProjectSettings();
2525
var deveroomConfiguration = projectScope.GetDeveroomConfiguration();
2626
var processorArchitecture = GetProcessorArchitecture(deveroomConfiguration, projectSettings);
27-
return new OutProcReqnrollConnector(
27+
return new LegacyOutProcReqnrollConnector(
2828
deveroomConfiguration,
2929
ideScope.Logger,
3030
projectSettings.TargetFrameworkMoniker,

Reqnroll.VisualStudio/Discovery/IDiscoveryResultProvider.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public DiscoveryResult RunDiscovery(string testAssemblyPath, string configFilePa
2020
{
2121
if (projectSettings.IsSpecFlowProject && projectSettings.ReqnrollVersion.Version <= new Version(3, 0, 225))
2222
{
23-
return RunDiscovery(testAssemblyPath, configFilePath, projectSettings, GetConnector(projectSettings));
23+
return RunDiscovery(testAssemblyPath, configFilePath, projectSettings, GetLegacyConnector(projectSettings));
2424
}
2525

2626
DiscoveryResult genericConnectorResult = RunDiscovery(testAssemblyPath, configFilePath, projectSettings,
@@ -30,7 +30,7 @@ public DiscoveryResult RunDiscovery(string testAssemblyPath, string configFilePa
3030
return genericConnectorResult;
3131

3232
var retryResult =
33-
RunDiscovery(testAssemblyPath, configFilePath, projectSettings, GetConnector(projectSettings));
33+
RunDiscovery(testAssemblyPath, configFilePath, projectSettings, GetLegacyConnector(projectSettings));
3434

3535
if (retryResult.IsFailed)
3636
{
@@ -47,6 +47,6 @@ public DiscoveryResult RunDiscovery(string testAssemblyPath, string configFilePa
4747
OutProcReqnrollConnector connector) => connector.RunDiscovery(projectSettings.OutputAssemblyPath,
4848
projectSettings.ReqnrollConfigFilePath);
4949

50-
private OutProcReqnrollConnector GetConnector(ProjectSettings projectSettings) =>
51-
OutProcReqnrollConnectorFactory.Create(_projectScope);
50+
private OutProcReqnrollConnector GetLegacyConnector(ProjectSettings projectSettings) =>
51+
OutProcReqnrollConnectorFactory.CreateLegacy(_projectScope);
5252
}

0 commit comments

Comments
 (0)