Skip to content

Commit

Permalink
docs: fix all <seealso> tags in XML docs and reformat code (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
natemcmaster authored Dec 24, 2019
1 parent 308de01 commit 64fdff7
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 41 deletions.
11 changes: 7 additions & 4 deletions src/CommandLineUtils/Attributes/ArgumentAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ namespace McMaster.Extensions.CommandLineUtils
/// <summary>
/// Represents one or many positional command line arguments.
/// Arguments are parsed based the <see cref="Order"/> given.
/// Compare to <seealso cref="OptionAttribute"/>.
/// </summary>
/// <seealso cref="OptionAttribute"/>
[AttributeUsage(AttributeTargets.Property)]
public sealed class ArgumentAttribute : Attribute
{
Expand Down Expand Up @@ -50,18 +50,21 @@ public ArgumentAttribute(int order, string? name, string? description)
public int Order { get; set; }

/// <summary>
/// The name of the argument. <seealso cref="CommandArgument.Name"/>.
/// The name of the argument.
/// </summary>
/// <seealso cref="CommandArgument.Name"/>
public string? Name { get; set; }

/// <summary>
/// Determines if the argument appears in the generated help-text. <seealso cref="CommandArgument.ShowInHelpText"/>.
/// Determines if the argument appears in the generated help-text.
/// </summary>
/// <seealso cref="CommandArgument.ShowInHelpText"/>
public bool ShowInHelpText { get; set; } = true;

/// <summary>
/// A description of the argument. <seealso cref="CommandArgument.Description"/>.
/// A description of the argument.
/// </summary>
/// <seealso cref="CommandArgument.Description"/>
public string? Description { get; set; }

internal CommandArgument Configure(PropertyInfo prop)
Expand Down
23 changes: 15 additions & 8 deletions src/CommandLineUtils/Attributes/CommandAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public CommandAttribute(params string[] names)

/// <summary>
/// The name of the command line application. When this is a subcommand, it is the name of the word used to invoke the subcommand.
/// <seealso cref="CommandLineApplication.Name" />
/// </summary>
/// <seealso cref="CommandLineApplication.Name" />
public string? Name
{
get => _names.Length > 0 ? _names[0] : null;
Expand All @@ -66,38 +66,45 @@ public string? Name
public IEnumerable<string> Names => _names;

/// <summary>
/// The full name of the command line application to show in help text. <seealso cref="CommandLineApplication.FullName" />
/// The full name of the command line application to show in help text.
/// </summary>
/// <seealso cref="CommandLineApplication.FullName" />
public string? FullName { get; set; }

/// <summary>
/// A description of the command. <seealso cref="CommandLineApplication.Description"/>
/// A description of the command.
/// </summary>
/// <seealso cref="CommandLineApplication.Description"/>
public string? Description { get; set; }

/// <summary>
/// Determines if this command appears in generated help text. <seealso cref="CommandLineApplication.ShowInHelpText"/>
/// Determines if this command appears in generated help text.
/// </summary>
/// <seealso cref="CommandLineApplication.ShowInHelpText"/>
public bool ShowInHelpText { get; set; } = true;

/// <summary>
/// Additional text that appears at the bottom of generated help text. <seealso cref="CommandLineApplication.ExtendedHelpText"/>
/// Additional text that appears at the bottom of generated help text.
/// </summary>
/// <seealso cref="CommandLineApplication.ExtendedHelpText"/>
public string? ExtendedHelpText { get; set; }

/// <summary>
/// Throw when unexpected arguments are encountered. <seealso cref="CommandLineApplication.ThrowOnUnexpectedArgument"/>
/// Throw when unexpected arguments are encountered.
/// </summary>
/// <seealso cref="CommandLineApplication.ThrowOnUnexpectedArgument"/>
public bool ThrowOnUnexpectedArgument { get; set; } = true;

/// <summary>
/// Allow '--' to be used to stop parsing arguments. <seealso cref="CommandLineApplication.AllowArgumentSeparator"/>
/// Allow '--' to be used to stop parsing arguments.
/// </summary>
/// <seealso cref="CommandLineApplication.AllowArgumentSeparator"/>
public bool AllowArgumentSeparator { get; set; }

/// <summary>
/// Treat arguments beginning as '@' as a response file. <seealso cref="CommandLineApplication.ResponseFileHandling"/>
/// Treat arguments beginning as '@' as a response file.
/// </summary>
/// <seealso cref="CommandLineApplication.ResponseFileHandling"/>
public ResponseFileHandling ResponseFileHandling { get; set; } = ResponseFileHandling.Disabled;

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion src/CommandLineUtils/Attributes/OptionAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ public OptionAttribute(string? template, string? description, CommandOptionType
}

/// <summary>
/// Defines the type of the option. When not set, this will be inferred from the CLR type of the property. <seealso cref="CommandOption.OptionType"/>
/// Defines the type of the option. When not set, this will be inferred from the CLR type of the property.
/// </summary>
/// <seealso cref="CommandOption.OptionType"/>
public CommandOptionType? OptionType { get; set; }

internal CommandOption Configure(CommandLineApplication app, PropertyInfo prop)
Expand Down
9 changes: 6 additions & 3 deletions src/CommandLineUtils/Attributes/OptionAttributeBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,22 @@ public abstract class OptionAttributeBase : Attribute
public string? ValueName { get; set; }

/// <summary>
/// A description of this option to show in generated help text. <seealso cref="CommandOption.Description"/>.
/// A description of this option to show in generated help text.
/// </summary>
/// <seealso cref="CommandOption.Description"/>
public string? Description { get; set; }

/// <summary>
/// Determines if this option should be shown in generated help text. <seealso cref="CommandOption.ShowInHelpText"/>.
/// Determines if this option should be shown in generated help text.
/// </summary>
/// <seealso cref="CommandOption.ShowInHelpText"/>
public bool ShowInHelpText { get; set; } = true;

/// <summary>
/// Determines if subcommands added to <see cref="CommandLineApplication.Commands"/>
/// should also have access to this option. <seealso cref="CommandOption.Inherited"/>.
/// should also have access to this option.
/// </summary>
/// <seealso cref="CommandOption.Inherited"/>
public bool Inherited { get; set; }

internal void Configure(CommandOption option)
Expand Down
2 changes: 1 addition & 1 deletion src/CommandLineUtils/Attributes/VersionOptionAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public VersionOptionAttribute(string version)
/// <summary>
/// Initializes a new <see cref="VersionOptionAttribute"/>.
/// </summary>
/// <param name="template">The string template. <seealso cref="CommandOption.Template"/>.</param>
/// <param name="template">The string template that will be used for <see cref="CommandOption.Template"/>.</param>
/// <param name="version">The version</param>
public VersionOptionAttribute(string template, string version)
{
Expand Down
2 changes: 1 addition & 1 deletion src/CommandLineUtils/CommandArgument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace McMaster.Extensions.CommandLineUtils
/// <summary>
/// Represents one or many positional command line arguments.
/// Arguments are parsed in the order in which <see cref="CommandLineApplication.Arguments"/> lists them.
/// Compare to <seealso cref="CommandOption"/>.
/// </summary>
/// <seealso cref="CommandOption"/>
public class CommandArgument
{
/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/CommandLineUtils/CommandArgument{T}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ namespace McMaster.Extensions.CommandLineUtils
/// <summary>
/// Represents one or many positional command line arguments.
/// Arguments are parsed in the order in which <see cref="CommandLineApplication.Arguments"/> lists them.
/// Compare to <seealso cref="CommandOption"/>. The raw value must be
/// parsable into type <typeparamref name="T" />
/// The raw value must be parsable into type <typeparamref name="T" />.
/// </summary>
/// <seealso cref="CommandOption"/>
public class CommandArgument<T> : CommandArgument, IInternalCommandParamOfT
{
private readonly List<T> _parsedValues = new List<T>();
Expand Down
42 changes: 28 additions & 14 deletions src/CommandLineUtils/CommandLineApplication.Execute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ partial class CommandLineApplication
/// <summary>
/// Creates an instance of <typeparamref name="TApp"/>, matching <see cref="CommandLineContext.Arguments"/>
/// to all attributes on the type, and then invoking a method named "OnExecute" or "OnExecuteAsync" if it exists.
/// See <seealso cref="OptionAttribute" />, <seealso cref="ArgumentAttribute" />,
/// <seealso cref="HelpOptionAttribute"/>, and <seealso cref="VersionOptionAttribute"/>.
/// </summary>
/// <seealso cref="OptionAttribute" />
/// <seealso cref="ArgumentAttribute" />
/// <seealso cref="HelpOptionAttribute"/>
/// <seealso cref="VersionOptionAttribute"/>
/// <param name="context">The execution context.</param>
/// <typeparam name="TApp">A type that should be bound to the arguments.</typeparam>
/// <exception cref="InvalidOperationException">Thrown when attributes are incorrectly configured.</exception>
Expand All @@ -35,9 +37,11 @@ public static int Execute<TApp>(CommandLineContext context)
/// <summary>
/// Creates an instance of <typeparamref name="TApp"/>, matching <see cref="CommandLineContext.Arguments"/>
/// to all attributes on the type, and then invoking a method named "OnExecute" or "OnExecuteAsync" if it exists.
/// See <seealso cref="OptionAttribute" />, <seealso cref="ArgumentAttribute" />,
/// <seealso cref="HelpOptionAttribute"/>, and <seealso cref="VersionOptionAttribute"/>.
/// </summary>
/// <seealso cref="OptionAttribute" />
/// <seealso cref="ArgumentAttribute" />
/// <seealso cref="HelpOptionAttribute"/>
/// <seealso cref="VersionOptionAttribute"/>
/// <param name="context">The execution context.</param>
/// <param name="cancellationToken"></param>
/// <typeparam name="TApp">A type that should be bound to the arguments.</typeparam>
Expand Down Expand Up @@ -92,9 +96,11 @@ public static async Task<int> ExecuteAsync<TApp>(CommandLineContext context, Can
/// <summary>
/// Creates an instance of <typeparamref name="TApp"/>, matching <paramref name="args"/>
/// to all attributes on the type, and then invoking a method named "OnExecute" or "OnExecuteAsync" if it exists.
/// See <seealso cref="OptionAttribute" />, <seealso cref="ArgumentAttribute" />,
/// <seealso cref="HelpOptionAttribute"/>, and <seealso cref="VersionOptionAttribute"/>.
/// </summary>
/// <seealso cref="OptionAttribute" />
/// <seealso cref="ArgumentAttribute" />
/// <seealso cref="HelpOptionAttribute"/>
/// <seealso cref="VersionOptionAttribute"/>
/// <param name="args">The arguments</param>
/// <typeparam name="TApp">A type that should be bound to the arguments.</typeparam>
/// <exception cref="InvalidOperationException">Thrown when attributes are incorrectly configured.</exception>
Expand All @@ -106,9 +112,11 @@ public static int Execute<TApp>(params string[] args)
/// <summary>
/// Creates an instance of <typeparamref name="TApp"/>, matching <paramref name="args"/>
/// to all attributes on the type, and then invoking a method named "OnExecute" or "OnExecuteAsync" if it exists.
/// See <seealso cref="OptionAttribute" />, <seealso cref="ArgumentAttribute" />,
/// <seealso cref="HelpOptionAttribute"/>, and <seealso cref="VersionOptionAttribute"/>.
/// </summary>
/// <seealso cref="OptionAttribute" />
/// <seealso cref="ArgumentAttribute" />
/// <seealso cref="HelpOptionAttribute"/>
/// <seealso cref="VersionOptionAttribute"/>
/// <param name="console">The console to use</param>
/// <param name="args">The arguments</param>
/// <typeparam name="TApp">A type that should be bound to the arguments.</typeparam>
Expand All @@ -125,9 +133,11 @@ public static int Execute<TApp>(IConsole console, params string[] args)
/// <summary>
/// Creates an instance of <typeparamref name="TApp"/>, matching <paramref name="args"/>
/// to all attributes on the type, and then invoking a method named "OnExecute" or "OnExecuteAsync" if it exists.
/// See <seealso cref="OptionAttribute" />, <seealso cref="ArgumentAttribute" />,
/// <seealso cref="HelpOptionAttribute"/>, and <seealso cref="VersionOptionAttribute"/>.
/// </summary>
/// <seealso cref="OptionAttribute" />
/// <seealso cref="ArgumentAttribute" />
/// <seealso cref="HelpOptionAttribute"/>
/// <seealso cref="VersionOptionAttribute"/>
/// <param name="args">The arguments</param>
/// <typeparam name="TApp">A type that should be bound to the arguments.</typeparam>
/// <exception cref="InvalidOperationException">Thrown when attributes are incorrectly configured.</exception>
Expand All @@ -140,9 +150,11 @@ public static Task<int> ExecuteAsync<TApp>(params string[] args)
/// <summary>
/// Creates an instance of <typeparamref name="TApp"/>, matching <paramref name="args"/>
/// to all attributes on the type, and then invoking a method named "OnExecute" or "OnExecuteAsync" if it exists.
/// See <seealso cref="OptionAttribute" />, <seealso cref="ArgumentAttribute" />,
/// <seealso cref="HelpOptionAttribute"/>, and <seealso cref="VersionOptionAttribute"/>.
/// </summary>
/// <seealso cref="OptionAttribute" />
/// <seealso cref="ArgumentAttribute" />
/// <seealso cref="HelpOptionAttribute"/>
/// <seealso cref="VersionOptionAttribute"/>
/// <param name="args">The arguments</param>
/// <param name="cancellationToken"></param>
/// <typeparam name="TApp">A type that should be bound to the arguments.</typeparam>
Expand All @@ -160,9 +172,11 @@ public static Task<int> ExecuteAsync<TApp>(string[] args, CancellationToken canc
/// <summary>
/// Creates an instance of <typeparamref name="TApp"/>, matching <paramref name="args"/>
/// to all attributes on the type, and then invoking a method named "OnExecute" or "OnExecuteAsync" if it exists.
/// See <seealso cref="OptionAttribute" />, <seealso cref="ArgumentAttribute" />,
/// <seealso cref="HelpOptionAttribute"/>, and <seealso cref="VersionOptionAttribute"/>.
/// </summary>
/// <seealso cref="OptionAttribute" />
/// <seealso cref="ArgumentAttribute" />
/// <seealso cref="HelpOptionAttribute"/>
/// <seealso cref="VersionOptionAttribute"/>
/// <param name="console">The console to use</param>
/// <param name="args">The arguments</param>
/// <typeparam name="TApp">A type that should be bound to the arguments.</typeparam>
Expand Down
8 changes: 4 additions & 4 deletions src/CommandLineUtils/Validation/ValidationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static class ValidationExtensions
/// </summary>
/// <param name="option">The option.</param>
/// <param name="allowEmptyStrings">Indicates whether an empty string is allowed.</param>
/// <param name="errorMessage">The custom error message to display. See also <seealso cref="ValidationAttribute.ErrorMessage"/>.</param>
/// <param name="errorMessage">The custom error message to display. See also: <see cref="ValidationAttribute.ErrorMessage"/>.</param>
/// <returns>The option.</returns>
public static CommandOption IsRequired(this CommandOption option, bool allowEmptyStrings = false, string? errorMessage = null)
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
Expand All @@ -36,7 +36,7 @@ public static CommandOption IsRequired(this CommandOption option, bool allowEmpt
/// </summary>
/// <param name="option">The option.</param>
/// <param name="allowEmptyStrings">Indicates whether an empty string is allowed.</param>
/// <param name="errorMessage">The custom error message to display. See also <seealso cref="ValidationAttribute.ErrorMessage"/>.</param>
/// <param name="errorMessage">The custom error message to display. See also: <see cref="ValidationAttribute.ErrorMessage"/>.</param>
/// <returns>The option.</returns>
public static CommandOption<T> IsRequired<T>(this CommandOption<T> option, bool allowEmptyStrings = false,
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
Expand All @@ -53,7 +53,7 @@ public static CommandOption<T> IsRequired<T>(this CommandOption<T> option, bool
/// </summary>
/// <param name="argument">The argument.</param>
/// <param name="allowEmptyStrings">Indicates whether an empty string is allowed.</param>
/// <param name="errorMessage">The custom error message to display. See also <seealso cref="ValidationAttribute.ErrorMessage"/>.</param>
/// <param name="errorMessage">The custom error message to display. See also: <see cref="ValidationAttribute.ErrorMessage"/>.</param>
/// <returns>The argument.</returns>
public static CommandArgument IsRequired(this CommandArgument argument, bool allowEmptyStrings = false, string? errorMessage = null)
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
Expand All @@ -70,7 +70,7 @@ public static CommandArgument IsRequired(this CommandArgument argument, bool all
/// </summary>
/// <param name="argument">The argument.</param>
/// <param name="allowEmptyStrings">Indicates whether an empty string is allowed.</param>
/// <param name="errorMessage">The custom error message to display. See also <seealso cref="ValidationAttribute.ErrorMessage"/>.</param>
/// <param name="errorMessage">The custom error message to display. See also: <see cref="ValidationAttribute.ErrorMessage"/>.</param>
/// <returns>The argument.</returns>
public static CommandArgument<T> IsRequired<T>(this CommandArgument<T> argument, bool allowEmptyStrings = false, string? errorMessage = null)
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
Expand Down
6 changes: 3 additions & 3 deletions test/CommandLineUtils.Tests/DefaultHelpTextGeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void DoesNotOrderCommandsByName()
app.Conventions.UseDefaultConventions();
app.Command("b", _ => { });
app.Command("a", _ => { });
var generator = new DefaultHelpTextGenerator() {SortCommandsByName = false};
var generator = new DefaultHelpTextGenerator() { SortCommandsByName = false };
var helpText = GetHelpText(app, generator);

var indexOfA = helpText.IndexOf(" a", StringComparison.InvariantCulture);
Expand Down Expand Up @@ -135,7 +135,7 @@ SomeEnumArgument enum arg desc
[Fact]
public void ShowHelpFromAttributes()
{
var app = new CommandLineApplication<MyApp>(){Name = "test"};
var app = new CommandLineApplication<MyApp>() { Name = "test" };
app.Conventions.UseDefaultConventions();
var helpText = GetHelpText(app);

Expand All @@ -161,7 +161,7 @@ SomeEnumArgument enum arg desc
public class MyApp
{
[Option(ShortName = "strOpt", Description = "str option desc")]
public string strOpt{ get; set; }
public string strOpt { get; set; }

[Option(ShortName = "intOpt", Description = "int option desc")]
public int intOpt { get; set; }
Expand Down

0 comments on commit 64fdff7

Please sign in to comment.