Skip to content
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 @@ -112,7 +112,7 @@ async Task DisplayOptionsAsync(IOutputDevice outputDevice, IEnumerable<CommandLi
string optionInfoIndent = new(' ', (indentLevel + 1) * 2);
foreach (CommandLineOption option in options.OrderBy(x => x.Name))
{
string optionName = option.ObsolescenceMessage is not null ? $"{optionNameIndent}--{option.Name} [obsolete]" : $"{optionNameIndent}--{option.Name}";
string optionName = $"{optionNameIndent}--{option.Name}";
await outputDevice.DisplayAsync(this, new TextOutputDeviceData(optionName), cancellationToken).ConfigureAwait(false);
if (option.Arity.Min == option.Arity.Max)
{
Expand All @@ -126,10 +126,6 @@ async Task DisplayOptionsAsync(IOutputDevice outputDevice, IEnumerable<CommandLi

await outputDevice.DisplayAsync(this, new TextOutputDeviceData($"{optionInfoIndent}Hidden: {option.IsHidden}"), cancellationToken).ConfigureAwait(false);
await outputDevice.DisplayAsync(this, new FormattedTextOutputDeviceData($"Description: {option.Description}") { Padding = optionInfoIndent.Length }, cancellationToken).ConfigureAwait(false);
if (option.ObsolescenceMessage is not null)
{
await outputDevice.DisplayAsync(this, new FormattedTextOutputDeviceData($"Obsolete: {option.ObsolescenceMessage}") { Padding = optionInfoIndent.Length }, cancellationToken).ConfigureAwait(false);
}
}
}

Expand Down Expand Up @@ -262,14 +258,9 @@ [.. optionProviders

foreach (CommandLineOption? option in options)
{
string optionName = option.ObsolescenceMessage is not null ? $"--{option.Name} [obsolete]" : $"--{option.Name}";
string optionName = $"--{option.Name}";
await outputDevice.DisplayAsync(this, new FormattedTextOutputDeviceData(optionName) { Padding = 4 }, cancellationToken).ConfigureAwait(false);
await outputDevice.DisplayAsync(this, new FormattedTextOutputDeviceData(option.Description) { Padding = 8 }, cancellationToken).ConfigureAwait(false);
if (option.ObsolescenceMessage is not null)
{
await outputDevice.DisplayAsync(this, new FormattedTextOutputDeviceData($"Obsolete: {option.ObsolescenceMessage}") { Padding = 8 }, cancellationToken).ConfigureAwait(false);
}

await outputDevice.DisplayAsync(this, new TextOutputDeviceData(string.Empty), cancellationToken).ConfigureAwait(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ public sealed class CommandLineOption : IEquatable<CommandLineOption>
/// <param name="arity">The arity of the command line option.</param>
/// <param name="isHidden">Indicates whether the command line option is hidden.</param>
/// <param name="isBuiltIn">Indicates whether the command line option is built-in.</param>
/// <param name="obsolescenceMessage">The obsolescence message for the command line option.</param>
internal CommandLineOption(string name, string description, ArgumentArity arity, bool isHidden, bool isBuiltIn, string? obsolescenceMessage = null)
internal CommandLineOption(string name, string description, ArgumentArity arity, bool isHidden, bool isBuiltIn)
{
Ensure.NotNullOrWhiteSpace(name);
Ensure.NotNullOrWhiteSpace(description);
Expand All @@ -38,37 +37,6 @@ internal CommandLineOption(string name, string description, ArgumentArity arity,
Arity = arity;
IsHidden = isHidden;
IsBuiltIn = isBuiltIn;
ObsolescenceMessage = obsolescenceMessage;
}

/// <summary>
/// Initializes a new instance of the <see cref="CommandLineOption"/> class.
/// </summary>
/// <param name="name">The name of the command line option.</param>
/// <param name="description">The description of the command line option.</param>
/// <param name="arity">The arity of the command line option.</param>
/// <param name="isHidden">Indicates whether the command line option is hidden.</param>
/// <param name="isBuiltIn">Indicates whether the command line option is built-in.</param>
internal CommandLineOption(string name, string description, ArgumentArity arity, bool isHidden, bool isBuiltIn)
: this(name, description, arity, isHidden, isBuiltIn, null)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="CommandLineOption"/> class.
/// </summary>
/// <param name="name">The name of the command line option.</param>
/// <param name="description">The description of the command line option.</param>
/// <param name="arity">The arity of the command line option.</param>
/// <param name="isHidden">Indicates whether the command line option is hidden.</param>
/// <param name="obsolescenceMessage">The obsolescence message for the command line option.</param>
/// <remarks>
/// This ctor is public and used by non built-in extension, we need to know if the extension is built-in or not
/// to correctly handle the --internal- prefix.
/// </remarks>
public CommandLineOption(string name, string description, ArgumentArity arity, bool isHidden, string? obsolescenceMessage = null)
: this(name, description, arity, isHidden, isBuiltIn: false, obsolescenceMessage)
{
}

/// <summary>
Expand All @@ -83,7 +51,7 @@ public CommandLineOption(string name, string description, ArgumentArity arity, b
/// to correctly handle the --internal- prefix.
/// </remarks>
public CommandLineOption(string name, string description, ArgumentArity arity, bool isHidden)
: this(name, description, arity, isHidden, isBuiltIn: false, null)
: this(name, description, arity, isHidden, isBuiltIn: false)
{
}

Expand All @@ -109,11 +77,6 @@ public CommandLineOption(string name, string description, ArgumentArity arity, b

internal bool IsBuiltIn { get; }

/// <summary>
/// Gets the obsolescence message for the command line option.
/// </summary>
public string? ObsolescenceMessage { get; }

/// <inheritdoc />
public override bool Equals(object? obj) => Equals(obj as CommandLineOption);

Expand All @@ -123,8 +86,7 @@ public bool Equals(CommandLineOption? other)
Name == other.Name &&
Description == other.Description &&
Arity == other.Arity &&
IsHidden == other.IsHidden &&
ObsolescenceMessage == other.ObsolescenceMessage;
IsHidden == other.IsHidden;

/// <inheritdoc />
public override int GetHashCode()
Expand All @@ -134,7 +96,6 @@ public override int GetHashCode()
hc.Add(Description);
hc.Add(Arity.GetHashCode());
hc.Add(IsHidden);
hc.Add(ObsolescenceMessage);
return hc.ToHashCode();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

using Microsoft.Testing.Platform.Extensions;
using Microsoft.Testing.Platform.Extensions.CommandLine;
using Microsoft.Testing.Platform.Extensions.OutputDevice;
using Microsoft.Testing.Platform.Helpers;
using Microsoft.Testing.Platform.OutputDevice;
using Microsoft.Testing.Platform.Resources;

namespace Microsoft.Testing.Platform.CommandLine;
Expand Down Expand Up @@ -70,30 +68,6 @@ public static async Task<ValidationResult> ValidateAsync(
return await ValidateConfigurationAsync(extensionOptionsByProvider.Keys, systemOptionsByProvider.Keys, commandLineOptions).ConfigureAwait(false);
Comment thread
Youssef1313 marked this conversation as resolved.
Resolved
}

public static async Task CheckForObsoleteOptionsAsync(
CommandLineParseResult commandLineParseResult,
IEnumerable<ICommandLineOptionsProvider> systemCommandLineOptionsProviders,
IEnumerable<ICommandLineOptionsProvider> extensionCommandLineOptionsProviders,
IOutputDevice outputDevice,
IOutputDeviceDataProducer outputDeviceDataProducer,
CancellationToken cancellationToken)
{
var allOptions = systemCommandLineOptionsProviders
.Union(extensionCommandLineOptionsProviders)
.SelectMany(provider => provider.GetCommandLineOptions())
.Where(option => option.ObsolescenceMessage is not null)
.ToDictionary(option => option.Name);

foreach (CommandLineParseOption optionRecord in commandLineParseResult.Options)
{
if (allOptions.TryGetValue(optionRecord.Name, out CommandLineOption? option))
{
string warningMessage = string.Format(CultureInfo.InvariantCulture, PlatformResources.CommandLineOptionObsoleteWarning, optionRecord.Name, option.ObsolescenceMessage);
await outputDevice.DisplayAsync(outputDeviceDataProducer, new WarningMessageOutputDeviceData(warningMessage), cancellationToken).ConfigureAwait(false);
}
}
}

private static ValidationResult ValidateExtensionOptionsDoNotContainReservedPrefix(
Dictionary<ICommandLineOptionsProvider, IReadOnlyCollection<CommandLineOption>> extensionOptionsByProvider)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,6 @@ public async Task<IHost> BuildAsync(
// to file disc also the banner, so at this point we need to have all services and configuration(result directory) built.
await DisplayBannerIfEnabledAsync(loggingState, proxyOutputDevice, testFrameworkCapabilities, testApplicationCancellationTokenSource.CancellationToken).ConfigureAwait(false);

// Check for obsolete options and display warnings
await CommandLineOptionsValidator.CheckForObsoleteOptionsAsync(
loggingState.CommandLineParseResult,
commandLineHandler.SystemCommandLineOptionsProviders,
commandLineHandler.ExtensionsCommandLineOptionsProviders,
proxyOutputDevice,
commandLineHandler,
testApplicationCancellationTokenSource.CancellationToken).ConfigureAwait(false);

// Add global telemetry service.
// Add at this point or the telemetry banner appearance order will be wrong, we want the testing app banner before the telemetry banner.
ITelemetryCollector telemetryService = await ((TelemetryManager)Telemetry).BuildTelemetryAsync(serviceProvider, loggerFactory, testApplicationOptions).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,11 @@ Microsoft.Testing.Platform.Extensions.CommandLine.ArgumentArity.Max.get -> int
Microsoft.Testing.Platform.Extensions.CommandLine.ArgumentArity.Min.get -> int
Microsoft.Testing.Platform.Extensions.CommandLine.CommandLineOption
Microsoft.Testing.Platform.Extensions.CommandLine.CommandLineOption.Arity.get -> Microsoft.Testing.Platform.Extensions.CommandLine.ArgumentArity
Microsoft.Testing.Platform.Extensions.CommandLine.CommandLineOption.CommandLineOption(string! name, string! description, Microsoft.Testing.Platform.Extensions.CommandLine.ArgumentArity arity, bool isHidden, string? obsolescenceMessage = null) -> void
Microsoft.Testing.Platform.Extensions.CommandLine.CommandLineOption.CommandLineOption(string! name, string! description, Microsoft.Testing.Platform.Extensions.CommandLine.ArgumentArity arity, bool isHidden) -> void
Microsoft.Testing.Platform.Extensions.CommandLine.CommandLineOption.Description.get -> string!
Microsoft.Testing.Platform.Extensions.CommandLine.CommandLineOption.Equals(Microsoft.Testing.Platform.Extensions.CommandLine.CommandLineOption? other) -> bool
Microsoft.Testing.Platform.Extensions.CommandLine.CommandLineOption.IsHidden.get -> bool
Microsoft.Testing.Platform.Extensions.CommandLine.CommandLineOption.Name.get -> string!
Microsoft.Testing.Platform.Extensions.CommandLine.CommandLineOption.ObsolescenceMessage.get -> string?
Microsoft.Testing.Platform.Extensions.CommandLine.ICommandLineOptionsProvider
Microsoft.Testing.Platform.Extensions.CommandLine.ICommandLineOptionsProvider.GetCommandLineOptions() -> System.Collections.Generic.IReadOnlyCollection<Microsoft.Testing.Platform.Extensions.CommandLine.CommandLineOption!>!
Microsoft.Testing.Platform.Extensions.CommandLine.ICommandLineOptionsProvider.ValidateCommandLineOptionsAsync(Microsoft.Testing.Platform.CommandLine.ICommandLineOptions! commandLineOptions) -> System.Threading.Tasks.Task<Microsoft.Testing.Platform.Extensions.ValidationResult>!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,6 @@
<data name="CommandLineOptionIsReserved" xml:space="preserve">
<value>Option '--{0}' is reserved and cannot be used by providers: '{0}'</value>
</data>
<data name="CommandLineOptionObsoleteWarning" xml:space="preserve">
<value>Warning: Option '--{0}' is obsolete. {1}</value>
</data>
<data name="CommandLineParserUnexpectedArgument" xml:space="preserve">
<value>Unexpected argument {0}</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@
<target state="translated">Možnost --{0} je vyhrazená a nelze ji použít zprostředkovateli: {0}</target>
<note />
</trans-unit>
<trans-unit id="CommandLineOptionObsoleteWarning">
<source>Warning: Option '--{0}' is obsolete. {1}</source>
<target state="translated">Upozornění: Možnost --{0} je zastaralá. {1}</target>
<note />
</trans-unit>
<trans-unit id="CommandLineOptionIsUsingReservedPrefix">
<source>Option `--{0}` from provider '{1}' (UID: {2}) is using the reserved prefix '--internal'</source>
<target state="translated">Možnost --{0} od zprostředkovatele {1} (UID: {2}) používá vyhrazenou předponu --internal.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@
<target state="translated">Die Option "--{0}" ist reserviert und kann nicht von Anbietern verwendet werden: "{0}"</target>
<note />
</trans-unit>
<trans-unit id="CommandLineOptionObsoleteWarning">
<source>Warning: Option '--{0}' is obsolete. {1}</source>
<target state="translated">Warnung: Die Option „--{0}“ ist veraltet. {1}</target>
<note />
</trans-unit>
<trans-unit id="CommandLineOptionIsUsingReservedPrefix">
<source>Option `--{0}` from provider '{1}' (UID: {2}) is using the reserved prefix '--internal'</source>
<target state="translated">Die Option "--{0}" vom Anbieter "{1}" (UID: {2}) verwendet das reservierte Präfix "--internal".</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@
<target state="translated">La opción “--{0}” está reservada y los proveedores no la pueden usar: “{0}”</target>
<note />
</trans-unit>
<trans-unit id="CommandLineOptionObsoleteWarning">
<source>Warning: Option '--{0}' is obsolete. {1}</source>
<target state="translated">Advertencia: La opción "--{0}" está obsoleta. {1}</target>
<note />
</trans-unit>
<trans-unit id="CommandLineOptionIsUsingReservedPrefix">
<source>Option `--{0}` from provider '{1}' (UID: {2}) is using the reserved prefix '--internal'</source>
<target state="translated">La opción “--{0}” del proveedor “{1}” (UID: {2}) usa el prefijo reservado “--internal”</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@
<target state="translated">L’option « --{0} » est réservée et ne peut pas être utilisée par les fournisseurs : « {0} »</target>
<note />
</trans-unit>
<trans-unit id="CommandLineOptionObsoleteWarning">
<source>Warning: Option '--{0}' is obsolete. {1}</source>
<target state="translated">Avertissement : l’option « --{0} » est obsolète. {1}</target>
<note />
</trans-unit>
<trans-unit id="CommandLineOptionIsUsingReservedPrefix">
<source>Option `--{0}` from provider '{1}' (UID: {2}) is using the reserved prefix '--internal'</source>
<target state="translated">L’option « --{0} » du fournisseur « {1} » (UID : {2}) utilise le préfixe réservé « --internal »</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@
<target state="translated">L'opzione '--{0}' è riservata e non può essere usata dai provider: '{0}'</target>
<note />
</trans-unit>
<trans-unit id="CommandLineOptionObsoleteWarning">
<source>Warning: Option '--{0}' is obsolete. {1}</source>
<target state="translated">Avviso: l'opzione '--{0}' è obsoleta. {1}</target>
<note />
</trans-unit>
<trans-unit id="CommandLineOptionIsUsingReservedPrefix">
<source>Option `--{0}` from provider '{1}' (UID: {2}) is using the reserved prefix '--internal'</source>
<target state="translated">L'opzione '--{0}' del provider '{1}' (UID: {2}) usa il prefisso riservato '--internal'</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@
<target state="translated">オプション '--{0}' は予約されており、プロバイダーでは使用できません: '{0}'</target>
<note />
</trans-unit>
<trans-unit id="CommandLineOptionObsoleteWarning">
<source>Warning: Option '--{0}' is obsolete. {1}</source>
<target state="translated">警告: オプション '--{0}' は廃止されています。{1}</target>
<note />
</trans-unit>
<trans-unit id="CommandLineOptionIsUsingReservedPrefix">
<source>Option `--{0}` from provider '{1}' (UID: {2}) is using the reserved prefix '--internal'</source>
<target state="translated">プロバイダー '{1}' のオプション '--{0}' (UID:{2}) は予約済みプレフィックス '--internal' を 使用しています</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@
<target state="translated">'--{0}' 옵션은 예약되어 있으므로 공급자 '{0}'이(가) 사용할 수 없습니다.</target>
<note />
</trans-unit>
<trans-unit id="CommandLineOptionObsoleteWarning">
<source>Warning: Option '--{0}' is obsolete. {1}</source>
<target state="translated">경고: 옵션 '--{0}'이(가) 사용되지 않습니다. {1}</target>
<note />
</trans-unit>
<trans-unit id="CommandLineOptionIsUsingReservedPrefix">
<source>Option `--{0}` from provider '{1}' (UID: {2}) is using the reserved prefix '--internal'</source>
<target state="translated">공급자 '{1}'(UID: {2})의 옵션 '-- {0}'이 예약된 접두사 '--internal'을 사용하고 있습니다.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@
<target state="translated">Opcja „--{0}” jest zastrzeżona i nie może być używana przez dostawców: „{0}”</target>
<note />
</trans-unit>
<trans-unit id="CommandLineOptionObsoleteWarning">
<source>Warning: Option '--{0}' is obsolete. {1}</source>
<target state="translated">Ostrzeżenie: opcja „--{0}” jest przestarzała. {1}</target>
<note />
</trans-unit>
<trans-unit id="CommandLineOptionIsUsingReservedPrefix">
<source>Option `--{0}` from provider '{1}' (UID: {2}) is using the reserved prefix '--internal'</source>
<target state="translated">Opcja „--{0}” od dostawcy „{1}” (UID: {2}) używa zastrzeżonego prefiksu „--internal”</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@
<target state="translated">A opção '--{0}' está reservada e não pode ser usada pelos provedores: '{0}'</target>
<note />
</trans-unit>
<trans-unit id="CommandLineOptionObsoleteWarning">
<source>Warning: Option '--{0}' is obsolete. {1}</source>
<target state="translated">Aviso: a opção '--{0}' está obsoleta. {1}</target>
<note />
</trans-unit>
<trans-unit id="CommandLineOptionIsUsingReservedPrefix">
<source>Option `--{0}` from provider '{1}' (UID: {2}) is using the reserved prefix '--internal'</source>
<target state="translated">A opção '--{0}' do provedor '{1}' (UID: {2}) está usando o prefixo reservado '--internal'</target>
Expand Down
Loading