Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

more xmldoc

  • Loading branch information...
commit 6bf317b320fe63a120f2debfb1fe122bac135d44 1 parent c9253f4
@adrianaisemberg adrianaisemberg authored
View
4 CLAP/CLAP.csproj
@@ -38,6 +38,8 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ <DocumentationFile>bin\Debug\CLAP.XML</DocumentationFile>
+ <NoWarn>1591</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -47,6 +49,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ <DocumentationFile>bin\Release\CLAP.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseFW2|AnyCPU'">
<OutputPath>bin\ReleaseFW2\</OutputPath>
@@ -64,6 +67,7 @@
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
+ <DocumentationFile>bin\ReleaseFW2\CLAP.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
View
7 CLAP/CollectionValidationAttribute.cs
@@ -7,7 +7,14 @@ namespace CLAP
/// </summary>
public abstract class CollectionValidationAttribute : Attribute, ICollectionValidation
{
+ /// <summary>
+ /// Gets a validator instance
+ /// </summary>
public abstract ICollectionValidator GetValidator();
+
+ /// <summary>
+ /// The validation description
+ /// </summary>
public abstract string Description { get; }
}
}
View
75 CLAP/Exceptions.cs
@@ -4,32 +4,35 @@
namespace CLAP
{
+ /// <summary>
+ /// Base exception class for all parser exceptions
+ /// </summary>
[Serializable]
- public abstract class CommandLineException : Exception
+ public abstract class CommandLineParserException : Exception
{
- public CommandLineException() { }
- public CommandLineException(string message) : base(message) { }
- public CommandLineException(string message, Exception inner) : base(message, inner) { }
- protected CommandLineException(
- System.Runtime.Serialization.SerializationInfo info,
- System.Runtime.Serialization.StreamingContext context)
- : base(info, context) { }
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ public CommandLineParserException() { }
- [Serializable]
- public abstract class ParserException : Exception
- {
- public ParserException() { }
- public ParserException(string message) : base(message) { }
- public ParserException(string message, Exception inner) : base(message, inner) { }
- protected ParserException(
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ public CommandLineParserException(string message) : base(message) { }
+
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ public CommandLineParserException(string message, Exception inner) : base(message, inner) { }
+
+ protected CommandLineParserException(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context)
: base(info, context) { }
}
[Serializable]
- public class MissingDefaultVerbException : CommandLineException
+ public class MissingDefaultVerbException : CommandLineParserException
{
public MissingDefaultVerbException()
: this("No default verb was found")
@@ -44,7 +47,7 @@ public MissingDefaultVerbException()
}
[Serializable]
- public class VerbNotFoundException : CommandLineException
+ public class VerbNotFoundException : CommandLineParserException
{
/// <summary>
/// The verb string that wasn't found
@@ -65,7 +68,7 @@ public VerbNotFoundException(string verb)
}
[Serializable]
- public class MissingVerbException : CommandLineException
+ public class MissingVerbException : CommandLineParserException
{
public MissingVerbException()
: this("Arguments contain no verb", null)
@@ -80,7 +83,7 @@ public MissingVerbException()
}
[Serializable]
- public class MultiParserMissingClassNameException : CommandLineException
+ public class MultiParserMissingClassNameException : CommandLineParserException
{
public MultiParserMissingClassNameException()
: this("Arguments contain no class name", null)
@@ -95,7 +98,7 @@ public MultiParserMissingClassNameException()
}
[Serializable]
- public class InvalidVerbException : CommandLineException
+ public class InvalidVerbException : CommandLineParserException
{
public InvalidVerbException()
: this("Invalid verb: Contains more than two parts.", null)
@@ -110,7 +113,7 @@ public InvalidVerbException()
}
[Serializable]
- public class UnknownParserTypeException : CommandLineException
+ public class UnknownParserTypeException : CommandLineParserException
{
public UnknownParserTypeException(string typeName)
: this("Parser type '{0}' not found".FormatWith(typeName), null)
@@ -125,7 +128,7 @@ public UnknownParserTypeException(string typeName)
}
[Serializable]
- public class MissingRequiredArgumentException : CommandLineException
+ public class MissingRequiredArgumentException : CommandLineParserException
{
/// <summary>
/// The name of the required parameter
@@ -152,7 +155,7 @@ public MissingRequiredArgumentException(string verb, string parameter)
}
[Serializable]
- public class MissingArgumentValueException : CommandLineException
+ public class MissingArgumentValueException : CommandLineParserException
{
/// <summary>
/// The name of the parameter
@@ -173,7 +176,7 @@ public MissingArgumentValueException(string parameter)
}
[Serializable]
- public class MissingArgumentPrefixException : CommandLineException
+ public class MissingArgumentPrefixException : CommandLineParserException
{
/// <summary>
/// The name of the parameter
@@ -194,7 +197,7 @@ public MissingArgumentPrefixException(string parameter, string prefixes)
}
[Serializable]
- public class ValidationException : CommandLineException
+ public class ValidationException : CommandLineParserException
{
public ValidationException(string message) : base(message) { }
public ValidationException(string message, Exception inner) : base(message, inner) { }
@@ -205,7 +208,7 @@ public class ValidationException : CommandLineException
}
[Serializable]
- public class TypeConvertionException : CommandLineException
+ public class TypeConvertionException : CommandLineParserException
{
/// <summary>
/// The string value that failed to be converted
@@ -231,7 +234,7 @@ public TypeConvertionException(string value, Type type, Exception inner)
}
[Serializable]
- public class MoreThanOneEmptyHandlerException : CommandLineException
+ public class MoreThanOneEmptyHandlerException : CommandLineParserException
{
public MoreThanOneEmptyHandlerException()
: base("More than one empty handler was defined. Only a single method can be marked with [Empty] in a type and only a single action can be registered as an empty handler.")
@@ -245,7 +248,7 @@ public MoreThanOneEmptyHandlerException()
}
[Serializable]
- public class MoreThanOneErrorHandlerException : CommandLineException
+ public class MoreThanOneErrorHandlerException : CommandLineParserException
{
public MoreThanOneErrorHandlerException()
: base("More than one error handler was defined. Only a single method can be marked with [Error] in a type and only a single action can be registered as an error handler.")
@@ -259,7 +262,7 @@ public MoreThanOneErrorHandlerException()
}
[Serializable]
- public class MoreThanOnePreVerbInterceptorException : CommandLineException
+ public class MoreThanOnePreVerbInterceptorException : CommandLineParserException
{
public MoreThanOnePreVerbInterceptorException()
: base("More than one pre-verb interceptor was defined. Only a single method can be marked with [PreVerbExecutionAttribute] in a type and only a single action can be registered as a pre-interceptor.")
@@ -273,7 +276,7 @@ public MoreThanOnePreVerbInterceptorException()
}
[Serializable]
- public class MoreThanOnePostVerbInterceptorException : CommandLineException
+ public class MoreThanOnePostVerbInterceptorException : CommandLineParserException
{
public MoreThanOnePostVerbInterceptorException()
: base("More than one post-verb interceptor was defined. Only a single method can be marked with [PostVerbExecutionAttribute] in a type and only a single action can be registered as a post-interceptor.")
@@ -287,7 +290,7 @@ public MoreThanOnePostVerbInterceptorException()
}
[Serializable]
- public class ArgumentMismatchException : CommandLineException
+ public class ArgumentMismatchException : CommandLineParserException
{
public ArgumentMismatchException() { }
public ArgumentMismatchException(string message) : base(message) { }
@@ -299,7 +302,7 @@ public class ArgumentMismatchException : CommandLineException
}
[Serializable]
- public class ParserExecutionTargetException : ParserException
+ public class ParserExecutionTargetException : CommandLineParserException
{
public ParserExecutionTargetException() { }
public ParserExecutionTargetException(string message) : base(message) { }
@@ -311,7 +314,7 @@ public class ParserExecutionTargetException : ParserException
}
[Serializable]
- public class UnhandledParametersException : CommandLineException
+ public class UnhandledParametersException : CommandLineParserException
{
/// <summary>
/// The collection of unhandled arguments
@@ -331,7 +334,7 @@ public UnhandledParametersException(Dictionary<string, string> unhandledParamete
}
[Serializable]
- public class MoreThanOneDefaultVerbException : CommandLineException
+ public class MoreThanOneDefaultVerbException : CommandLineParserException
{
/// <summary>
/// The collection of the verbs that are defined as default
@@ -351,7 +354,7 @@ public MoreThanOneDefaultVerbException(IEnumerable<string> verbs)
}
[Serializable]
- public class InvalidHelpHandlerException : CommandLineException
+ public class InvalidHelpHandlerException : CommandLineParserException
{
/// <summary>
/// The method that is defined as help
View
52 CLAP/Parser.cs
@@ -60,7 +60,8 @@ public static void Run<T>(string[] args, T t)
/// <summary>
/// Executes a generic parser of some specified types
/// </summary>
- /// <typeparam name="T">The type of the parser</typeparam>
+ /// <typeparam name="T1">The type of the parser</typeparam>
+ /// <typeparam name="T2">The type of the parser</typeparam>
/// <param name="args">The user arguments</param>
/// <param name="t1">An instance of the verb class</param>
/// <param name="t2">An instance of the verb class</param>
@@ -77,7 +78,9 @@ public static void Run<T>(string[] args, T t)
/// <summary>
/// Executes a generic parser of some specified types
/// </summary>
- /// <typeparam name="T">The type of the parser</typeparam>
+ /// <typeparam name="T1">The type of the parser</typeparam>
+ /// <typeparam name="T2">The type of the parser</typeparam>
+ /// <typeparam name="T3">The type of the parser</typeparam>
/// <param name="args">The user arguments</param>
/// <param name="t1">An instance of the verb class</param>
/// <param name="t2">An instance of the verb class</param>
@@ -95,7 +98,10 @@ public static void Run<T>(string[] args, T t)
/// <summary>
/// Executes a generic parser of some specified types
/// </summary>
- /// <typeparam name="T">The type of the parser</typeparam>
+ /// <typeparam name="T1">The type of the parser</typeparam>
+ /// <typeparam name="T2">The type of the parser</typeparam>
+ /// <typeparam name="T3">The type of the parser</typeparam>
+ /// <typeparam name="T4">The type of the parser</typeparam>
/// <param name="args">The user arguments</param>
/// <param name="t1">An instance of the verb class</param>
/// <param name="t2">An instance of the verb class</param>
@@ -114,7 +120,11 @@ public static void Run<T>(string[] args, T t)
/// <summary>
/// Executes a generic parser of some specified types
/// </summary>
- /// <typeparam name="T">The type of the parser</typeparam>
+ /// <typeparam name="T1">The type of the parser</typeparam>
+ /// <typeparam name="T2">The type of the parser</typeparam>
+ /// <typeparam name="T3">The type of the parser</typeparam>
+ /// <typeparam name="T4">The type of the parser</typeparam>
+ /// <typeparam name="T5">The type of the parser</typeparam>
/// <param name="args">The user arguments</param>
/// <param name="t1">An instance of the verb class</param>
/// <param name="t2">An instance of the verb class</param>
@@ -134,7 +144,12 @@ public static void Run<T>(string[] args, T t)
/// <summary>
/// Executes a generic parser of some specified types
/// </summary>
- /// <typeparam name="T">The type of the parser</typeparam>
+ /// <typeparam name="T1">The type of the parser</typeparam>
+ /// <typeparam name="T2">The type of the parser</typeparam>
+ /// <typeparam name="T3">The type of the parser</typeparam>
+ /// <typeparam name="T4">The type of the parser</typeparam>
+ /// <typeparam name="T5">The type of the parser</typeparam>
+ /// <typeparam name="T6">The type of the parser</typeparam>
/// <param name="args">The user arguments</param>
/// <param name="t1">An instance of the verb class</param>
/// <param name="t2">An instance of the verb class</param>
@@ -155,7 +170,13 @@ public static void Run<T>(string[] args, T t)
/// <summary>
/// Executes a generic parser of some specified types
/// </summary>
- /// <typeparam name="T">The type of the parser</typeparam>
+ /// <typeparam name="T1">The type of the parser</typeparam>
+ /// <typeparam name="T2">The type of the parser</typeparam>
+ /// <typeparam name="T3">The type of the parser</typeparam>
+ /// <typeparam name="T4">The type of the parser</typeparam>
+ /// <typeparam name="T5">The type of the parser</typeparam>
+ /// <typeparam name="T6">The type of the parser</typeparam>
+ /// <typeparam name="T7">The type of the parser</typeparam>
/// <param name="args">The user arguments</param>
/// <param name="t1">An instance of the verb class</param>
/// <param name="t2">An instance of the verb class</param>
@@ -177,7 +198,14 @@ public static void Run<T>(string[] args, T t)
/// <summary>
/// Executes a generic parser of some specified types
/// </summary>
- /// <typeparam name="T">The type of the parser</typeparam>
+ /// <typeparam name="T1">The type of the parser</typeparam>
+ /// <typeparam name="T2">The type of the parser</typeparam>
+ /// <typeparam name="T3">The type of the parser</typeparam>
+ /// <typeparam name="T4">The type of the parser</typeparam>
+ /// <typeparam name="T5">The type of the parser</typeparam>
+ /// <typeparam name="T6">The type of the parser</typeparam>
+ /// <typeparam name="T7">The type of the parser</typeparam>
+ /// <typeparam name="T8">The type of the parser</typeparam>
/// <param name="args">The user arguments</param>
/// <param name="t1">An instance of the verb class</param>
/// <param name="t2">An instance of the verb class</param>
@@ -200,7 +228,15 @@ public static void Run<T>(string[] args, T t)
/// <summary>
/// Executes a generic parser of some specified types
/// </summary>
- /// <typeparam name="T">The type of the parser</typeparam>
+ /// <typeparam name="T1">The type of the parser</typeparam>
+ /// <typeparam name="T2">The type of the parser</typeparam>
+ /// <typeparam name="T3">The type of the parser</typeparam>
+ /// <typeparam name="T4">The type of the parser</typeparam>
+ /// <typeparam name="T5">The type of the parser</typeparam>
+ /// <typeparam name="T6">The type of the parser</typeparam>
+ /// <typeparam name="T7">The type of the parser</typeparam>
+ /// <typeparam name="T8">The type of the parser</typeparam>
+ /// <typeparam name="T9">The type of the parser</typeparam>
/// <param name="args">The user arguments</param>
/// <param name="t1">An instance of the verb class</param>
/// <param name="t2">An instance of the verb class</param>
View
58 CLAP/ParserRegistration.cs
@@ -4,6 +4,9 @@
namespace CLAP
{
+ /// <summary>
+ /// Provides registration features for parser instances
+ /// </summary>
public sealed class ParserRegistration
{
#region Properties
@@ -22,7 +25,7 @@ public sealed class ParserRegistration
#region Constructors
- public ParserRegistration(Func<string> helpGetter, Func<Type, string, string, object> parameterValueGetter)
+ internal ParserRegistration(Func<string> helpGetter, Func<Type, string, string, object> parameterValueGetter)
{
RegisteredGlobalHandlers = new Dictionary<string, GlobalParameterHandler>();
RegisteredHelpHandlers = new Dictionary<string, Action<string>>();
@@ -35,11 +38,20 @@ public ParserRegistration(Func<string> helpGetter, Func<Type, string, string, ob
#region Public Methods
+ /// <summary>
+ /// Registers a help handler that is executed when the user requests for help
+ /// </summary>
+ /// <param name="names">The names (CSV) to be registered as help parameters. For example: "?,h,help"</param>
+ /// <param name="helpHandler">The action to be executed</param>
public void HelpHandler(string names, Action<string> helpHandler)
{
RegisterHelpHandlerInternal(names, helpHandler);
}
+ /// <summary>
+ /// Registers an empty help handler that is executed when there is no input
+ /// </summary>
+ /// <param name="handler">The action to be executed</param>
public void EmptyHelpHandler(Action<string> handler)
{
if (RegisteredEmptyHandler != null)
@@ -55,6 +67,10 @@ public void EmptyHelpHandler(Action<string> handler)
};
}
+ /// <summary>
+ /// Registers an empty handler that is executed when there is no input
+ /// </summary>
+ /// <param name="handler">The action to be executed</param>
public void EmptyHandler(Action handler)
{
if (RegisteredEmptyHandler != null)
@@ -65,6 +81,10 @@ public void EmptyHandler(Action handler)
RegisteredEmptyHandler = handler;
}
+ /// <summary>
+ /// Registers an error handler that is executed when an exception is thrown
+ /// </summary>
+ /// <param name="handler">The action to be executed</param>
public void ErrorHandler(Action<Exception> handler)
{
ErrorHandler(new Func<Exception, bool>(ex =>
@@ -75,6 +95,10 @@ public void ErrorHandler(Action<Exception> handler)
}));
}
+ /// <summary>
+ /// Registers an error handler that is executed when an exception is thrown
+ /// </summary>
+ /// <param name="handler">The action to be executed. Returning "true" will cause the parser to re-throw the original exception</param>
public void ErrorHandler(Func<Exception, bool> handler)
{
if (RegisteredErrorHandler != null)
@@ -85,6 +109,10 @@ public void ErrorHandler(Func<Exception, bool> handler)
RegisteredErrorHandler = handler;
}
+ /// <summary>
+ /// Registers a pre-verb execution interceptor
+ /// </summary>
+ /// <param name="interceptor">The action to be executed before each verb is executed</param>
public void PreVerbInterceptor(Action<PreVerbExecutionContext> interceptor)
{
if (RegisteredPreVerbInterceptor != null)
@@ -95,6 +123,10 @@ public void PreVerbInterceptor(Action<PreVerbExecutionContext> interceptor)
RegisteredPreVerbInterceptor = interceptor;
}
+ /// <summary>
+ /// Registers a post-verb execution interceptor
+ /// </summary>
+ /// <param name="interceptor">The action to be executed after each verb is executed</param>
public void PostVerbInterceptor(Action<PostVerbExecutionContext> interceptor)
{
if (RegisteredPostVerbInterceptor != null)
@@ -105,6 +137,11 @@ public void PostVerbInterceptor(Action<PostVerbExecutionContext> interceptor)
RegisteredPostVerbInterceptor = interceptor;
}
+ /// <summary>
+ /// Registers a global parameter handler
+ /// </summary>
+ /// <param name="names">The names (CSV) to be registered as boolean parameters (switches)</param>
+ /// <param name="action">The action to execute</param>
public void ParameterHandler(string names, Action action)
{
ParameterHandler(
@@ -113,6 +150,12 @@ public void ParameterHandler(string names, Action action)
null);
}
+ /// <summary>
+ /// Registers a global parameter handler
+ /// </summary>
+ /// <param name="names">The names (CSV) to be registered as boolean parameters (switches)</param>
+ /// <param name="action">The action to execute</param>
+ /// <param name="description">The parameter description (for help generation)</param>
public void ParameterHandler(string names, Action action, string description)
{
ParameterHandler(
@@ -121,6 +164,12 @@ public void ParameterHandler(string names, Action action, string description)
description);
}
+ /// <summary>
+ /// Registers a global parameter handler
+ /// </summary>
+ /// <typeparam name="TParameter">The type of the parameter</typeparam>
+ /// <param name="names">The names (CSV) to be registered as parameters</param>
+ /// <param name="action">The action to execute</param>
public void ParameterHandler<TParameter>(string names, Action<TParameter> action)
{
ParameterHandler(
@@ -129,6 +178,13 @@ public void ParameterHandler<TParameter>(string names, Action<TParameter> action
null);
}
+ /// <summary>
+ /// Registers a global parameter handler
+ /// </summary>
+ /// <typeparam name="TParameter">The type of the parameter</typeparam>
+ /// <param name="names">The names (CSV) to be registered as parameters</param>
+ /// <param name="action">The action to execute</param>
+ /// <param name="description">The parameter description (for help generation)</param>
public void ParameterHandler<TParameter>(string names, Action<TParameter> action, string description)
{
RegisterParameterHandlerInternal(
View
2  CLAP/ParserRunner.cs
@@ -11,7 +11,7 @@
namespace CLAP
{
- public class ParserRunner
+ internal class ParserRunner
{
#region Fields
View
9 CLAP/Validation/FileExistsAttribute.cs
@@ -11,16 +11,25 @@ namespace CLAP.Validation
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)]
public sealed class FileExistsAttribute : ValidationAttribute
{
+ /// <summary>
+ /// Constructor
+ /// </summary>
public FileExistsAttribute()
{
}
+ /// <summary>
+ /// Gets a validator instance
+ /// </summary>
public override IValueValidator GetValidator()
{
return new FileExistsValidator();
}
+ /// <summary>
+ /// The validation description
+ /// </summary>
public override string Description
{
get
View
3  CLAP/Validation/NumberValidator.cs
@@ -10,6 +10,9 @@ public abstract class NumberValidationAttribute : ValidationAttribute
{
protected double Number { get; private set; }
+ /// <summary>
+ /// Constructor
+ /// </summary>
protected NumberValidationAttribute(double number)
{
Number = number;
View
16 CLAP/ValueInfo.cs
@@ -3,18 +3,32 @@
namespace CLAP
{
+ /// <summary>
+ /// Information about a vluae
+ /// </summary>
[DebuggerDisplay("{Name}:{Value} [{Type}]")]
public class ValueInfo
{
- public ValueInfo(string name, Type type, object value)
+ internal ValueInfo(string name, Type type, object value)
{
Name = name;
Type = type;
Value = value;
}
+ /// <summary>
+ /// The name of the value. Either the parameter or property name
+ /// </summary>
public string Name { get; private set; }
+
+ /// <summary>
+ /// The type of the value
+ /// </summary>
public Type Type { get; private set; }
+
+ /// <summary>
+ /// The value
+ /// </summary>
public object Value { get; private set; }
}
}
View
2  CLAP/VerbAttribute.cs
@@ -3,7 +3,7 @@
namespace CLAP
{
/// <summary>
- /// A verb
+ /// Marks a method as a verb
/// </summary>
[Serializable]
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
View
2  Tests/Tests.cs
@@ -314,7 +314,7 @@ public void Required_Exception()
Assert.Fail();
}
- catch (CommandLineException)
+ catch (CommandLineParserException)
{
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.