Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use null-coalesce assignment #3405

Merged
merged 1 commit into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public static TestDiscoveryExtensionManager Create()
{
if (s_testDiscoveryExtensionManager == null)
{

TestPluginManager.GetSpecificTestExtensions<TestDiscovererPluginInformation, ITestDiscoverer, ITestDiscovererCapabilities, TestDiscovererMetadata>(
TestPlatformConstants.TestAdapterEndsWithPattern,
out var unfilteredTestExtensions,
Expand Down
14 changes: 2 additions & 12 deletions src/vstest.console/CommandLine/CommandLineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,7 @@ internal class CommandLineOptions
/// Gets the instance.
/// </summary>
internal static CommandLineOptions Instance
{
get
{
if (s_instance == null)
{
s_instance = new CommandLineOptions();
}

return s_instance;
}
}
=> s_instance ??= new CommandLineOptions();

/// <summary>
/// Default constructor.
Expand All @@ -78,7 +68,7 @@ internal CommandLineOptions()
FileHelper = new FileHelper();
FilePatternParser = new FilePatternParser();
#if TODO
UseVsixExtensions = Utilities.GetAppSettingValue(UseVsixExtensionsKey, false);
UseVsixExtensions = Utilities.GetAppSettingValue(UseVsixExtensionsKey, false);
#endif
}

Expand Down
12 changes: 1 addition & 11 deletions src/vstest.console/CommandLine/TestRunResultAggregator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,7 @@ protected internal TestRunResultAggregator()
/// </summary>
/// <returns>Instance of the test run result aggregator.</returns>
public static TestRunResultAggregator Instance
{
get
{
if (s_instance == null)
{
s_instance = new TestRunResultAggregator();
}

return s_instance;
}
}
=> s_instance ??= new TestRunResultAggregator();

/// <summary>
/// The current test run outcome.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,18 @@ internal class ArtifactProcessingCollectModeProcessor : IArgumentProcessor
/// Gets the metadata.
/// </summary>
public Lazy<IArgumentProcessorCapabilities> Metadata
{
get
{
if (_metadata == null)
{
_metadata = new Lazy<IArgumentProcessorCapabilities>(() => new ArtifactProcessingCollectModeProcessorCapabilities());
}

return _metadata;
}
}
=> _metadata ??= new Lazy<IArgumentProcessorCapabilities>(() =>
new ArtifactProcessingCollectModeProcessorCapabilities());

/// <summary>
/// Gets or sets the executor.
/// </summary>
public Lazy<IArgumentExecutor> Executor
{
get
{
if (_executor == null)
{
_executor = new Lazy<IArgumentExecutor>(() => new ArtifactProcessingCollectModeProcessorExecutor(CommandLineOptions.Instance));
}

return _executor;
}

set
{
_executor = value;
}
get => _executor ??= new Lazy<IArgumentExecutor>(() =>
new ArtifactProcessingCollectModeProcessorExecutor(CommandLineOptions.Instance));

set => _executor = value;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,38 +29,19 @@ internal class ArtifactProcessingPostProcessModeProcessor : IArgumentProcessor
/// Gets the metadata.
/// </summary>
public Lazy<IArgumentProcessorCapabilities> Metadata
{
get
{
if (_metadata == null)
{
_metadata = new Lazy<IArgumentProcessorCapabilities>(() => new ArtifactProcessingPostProcessModeProcessorCapabilities());
}

return _metadata;
}
}
=> _metadata ??= new Lazy<IArgumentProcessorCapabilities>(() =>
new ArtifactProcessingPostProcessModeProcessorCapabilities());

/// <summary>
/// Gets or sets the executor.
/// </summary>
public Lazy<IArgumentExecutor> Executor
{
get
{
if (_executor == null)
{
_executor = new Lazy<IArgumentExecutor>(() => new ArtifactProcessingPostProcessModeProcessorExecutor(CommandLineOptions.Instance,
new ArtifactProcessingManager(CommandLineOptions.Instance.TestSessionCorrelationId)));
}

return _executor;
}
get => _executor ??= new Lazy<IArgumentExecutor>(() =>
new ArtifactProcessingPostProcessModeProcessorExecutor(CommandLineOptions.Instance,
new ArtifactProcessingManager(CommandLineOptions.Instance.TestSessionCorrelationId)));

set
{
_executor = value;
}
set => _executor = value;
}

public static bool ContainsPostProcessCommand(string[]? args, IFeatureFlag? featureFlag = null)
Expand Down
33 changes: 7 additions & 26 deletions src/vstest.console/Processors/CLIRunSettingsArgumentProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,37 +36,18 @@ internal class CliRunSettingsArgumentProcessor : IArgumentProcessor
/// Gets the metadata.
/// </summary>
public Lazy<IArgumentProcessorCapabilities> Metadata
{
get
{
if (_metadata == null)
{
_metadata = new Lazy<IArgumentProcessorCapabilities>(() => new CliRunSettingsArgumentProcessorCapabilities());
}

return _metadata;
}
}
=> _metadata ??= new Lazy<IArgumentProcessorCapabilities>(() =>
new CliRunSettingsArgumentProcessorCapabilities());

/// <summary>
/// Gets or sets the executor.
/// </summary>
public Lazy<IArgumentExecutor> Executor
{
get
{
if (_executor == null)
{
_executor = new Lazy<IArgumentExecutor>(() => new CliRunSettingsArgumentExecutor(RunSettingsManager.Instance, CommandLineOptions.Instance));
}
get => _executor ??= new Lazy<IArgumentExecutor>(() =>
new CliRunSettingsArgumentExecutor(RunSettingsManager.Instance, CommandLineOptions.Instance));

return _executor;
}

set
{
_executor = value;
}
set => _executor = value;
}
}

Expand Down Expand Up @@ -141,7 +122,7 @@ private void CreateOrOverwriteRunSettings(IRunSettingsProvider runSettingsProvid

foreach (var arg in args)
{
// when we see that the parameter begins with TestRunParameters
// when we see that the parameter begins with TestRunParameters
// but does not end with ") we start merging the params
if (arg.StartsWith("TestRunParameters", StringComparison.OrdinalIgnoreCase))
{
Expand Down Expand Up @@ -180,7 +161,7 @@ private void CreateOrOverwriteRunSettings(IRunSettingsProvider runSettingsProvid

if (merge)
{
// we tried to merge but never found the end of that
// we tried to merge but never found the end of that
// test paramter, add what we merged up until now
mergedArgs.Add(mergedArg);
}
Expand Down
29 changes: 5 additions & 24 deletions src/vstest.console/Processors/CollectArgumentProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,37 +42,18 @@ internal class CollectArgumentProcessor : IArgumentProcessor
/// Gets the metadata.
/// </summary>
public Lazy<IArgumentProcessorCapabilities> Metadata
{
get
{
if (_metadata == null)
{
_metadata = new Lazy<IArgumentProcessorCapabilities>(() => new CollectArgumentProcessorCapabilities());
}

return _metadata;
}
}
=> _metadata ??= new Lazy<IArgumentProcessorCapabilities>(() =>
new CollectArgumentProcessorCapabilities());

/// <summary>
/// Gets or sets the executor.
/// </summary>
public Lazy<IArgumentExecutor> Executor
{
get
{
if (_executor == null)
{
_executor = new Lazy<IArgumentExecutor>(() => new CollectArgumentExecutor(RunSettingsManager.Instance, new FileHelper()));
}
get => _executor ??= new Lazy<IArgumentExecutor>(() =>
new CollectArgumentExecutor(RunSettingsManager.Instance, new FileHelper()));

return _executor;
}

set
{
_executor = value;
}
set => _executor = value;
}
}

Expand Down
17 changes: 4 additions & 13 deletions src/vstest.console/Processors/DisableAutoFakesArgumentProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,15 @@ internal class DisableAutoFakesArgumentProcessor : IArgumentProcessor

public Lazy<IArgumentExecutor> Executor
{
get
{
return _executor ??= new Lazy<IArgumentExecutor>(
() => new DisableAutoFakesArgumentExecutor(
CommandLineOptions.Instance));
}
get => _executor ??= new Lazy<IArgumentExecutor>(() =>
new DisableAutoFakesArgumentExecutor(CommandLineOptions.Instance));

set => _executor = value;
}

public Lazy<IArgumentProcessorCapabilities> Metadata
{
get
{
return _metadata ??= new Lazy<IArgumentProcessorCapabilities>(
() => new DisableAutoFakesArgumentProcessorCapabilities());
}
}
=> _metadata ??= new Lazy<IArgumentProcessorCapabilities>(() =>
new DisableAutoFakesArgumentProcessorCapabilities());
}

internal class DisableAutoFakesArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities
Expand Down
28 changes: 5 additions & 23 deletions src/vstest.console/Processors/EnableBlameArgumentProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,36 +44,18 @@ public EnableBlameArgumentProcessor()
}

public Lazy<IArgumentProcessorCapabilities> Metadata
{
get
{
if (_metadata == null)
{
_metadata = new Lazy<IArgumentProcessorCapabilities>(() => new EnableBlameArgumentProcessorCapabilities());
}

return _metadata;
}
}
=> _metadata ??= new Lazy<IArgumentProcessorCapabilities>(() =>
new EnableBlameArgumentProcessorCapabilities());

/// <summary>
/// Gets or sets the executor.
/// </summary>
public Lazy<IArgumentExecutor> Executor
{
get
{
if (_executor == null)
{
_executor = new Lazy<IArgumentExecutor>(() => new EnableBlameArgumentExecutor(RunSettingsManager.Instance, new PlatformEnvironment(), new FileHelper()));
}
get => _executor ??= new Lazy<IArgumentExecutor>(() =>
new EnableBlameArgumentExecutor(RunSettingsManager.Instance, new PlatformEnvironment(), new FileHelper()));

return _executor;
}
set
{
_executor = value;
}
set => _executor = value;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,37 +37,18 @@ internal class EnableCodeCoverageArgumentProcessor : IArgumentProcessor
/// Gets the metadata.
/// </summary>
public Lazy<IArgumentProcessorCapabilities> Metadata
{
get
{
if (_metadata == null)
{
_metadata = new Lazy<IArgumentProcessorCapabilities>(() => new EnableCodeCoverageArgumentProcessorCapabilities());
}

return _metadata;
}
}
=> _metadata ??= new Lazy<IArgumentProcessorCapabilities>(() =>
new EnableCodeCoverageArgumentProcessorCapabilities());

/// <summary>
/// Gets or sets the executor.
/// </summary>
public Lazy<IArgumentExecutor> Executor
{
get
{
if (_executor == null)
{
_executor = new Lazy<IArgumentExecutor>(() => new EnableCodeCoverageArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance, new FileHelper()));
}
get => _executor ??= new Lazy<IArgumentExecutor>(() =>
new EnableCodeCoverageArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance, new FileHelper()));

return _executor;
}

set
{
_executor = value;
}
set => _executor = value;
}
}

Expand Down
Loading