From dcd4f35323a2b244590a518a422fb8e21f3ee249 Mon Sep 17 00:00:00 2001 From: Jaroslaw Waliszko Date: Sat, 8 Nov 2014 15:33:51 +0100 Subject: [PATCH] The only remaining warnings (all related to lack of XML comments) completely eradicated. Version up. --- .../Properties/AssemblyInfo.cs | 4 +-- .../Validators/ExpressiveValidator.cs | 36 +++++++++++++------ .../Attributes/AssertThatAttribute.cs | 9 +++++ .../Attributes/ExpressiveAttribute.cs | 27 +++++++++++--- .../Attributes/RequiredIfAttribute.cs | 9 +++++ .../Properties/AssemblyInfo.cs | 4 +-- 6 files changed, 71 insertions(+), 18 deletions(-) diff --git a/src/ExpressiveAnnotations.MvcUnobtrusiveValidatorProvider/Properties/AssemblyInfo.cs b/src/ExpressiveAnnotations.MvcUnobtrusiveValidatorProvider/Properties/AssemblyInfo.cs index 79407d8..899c05a 100644 --- a/src/ExpressiveAnnotations.MvcUnobtrusiveValidatorProvider/Properties/AssemblyInfo.cs +++ b/src/ExpressiveAnnotations.MvcUnobtrusiveValidatorProvider/Properties/AssemblyInfo.cs @@ -30,5 +30,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.2.2.0")] -[assembly: AssemblyFileVersion("2.2.2.0")] +[assembly: AssemblyVersion("2.2.3.0")] +[assembly: AssemblyFileVersion("2.2.3.0")] diff --git a/src/ExpressiveAnnotations.MvcUnobtrusiveValidatorProvider/Validators/ExpressiveValidator.cs b/src/ExpressiveAnnotations.MvcUnobtrusiveValidatorProvider/Validators/ExpressiveValidator.cs index db107fd..d5f3f26 100644 --- a/src/ExpressiveAnnotations.MvcUnobtrusiveValidatorProvider/Validators/ExpressiveValidator.cs +++ b/src/ExpressiveAnnotations.MvcUnobtrusiveValidatorProvider/Validators/ExpressiveValidator.cs @@ -74,36 +74,52 @@ protected ExpressiveValidator(ModelMetadata metadata, ControllerContext context, } } + /// + /// Gets the expression. + /// protected string Expression { get; private set; } + + /// + /// Gets the formatted error message. + /// protected string FormattedErrorMessage { get; private set; } + + /// + /// Gets names and coarse types of properties extracted from specified expression within given context. + /// protected IDictionary FieldsMap { get; private set; } + + /// + /// Gets names and values of constants extracted from specified expression within given context. + /// protected IDictionary ConstsMap { get; private set; } - protected string FieldAttributeType { get; private set; } - protected bool Cached + private string FieldAttributeType { get; set; } + + private bool Cached { get { return FieldsMap != null || ConstsMap != null; } } + /// + /// Provides unique validation type within current annotated field range, when multiple annotations are used (required for client side). + /// + /// Base name. + /// + /// Unique validation type within current request. + /// protected string ProvideUniqueValidationType(string baseName) { return string.Format("{0}{1}", baseName, AllocateSuffix()); } - /// - /// Provides unique suffix related to each attribute instance within current annotated field range - /// (required for multiple annotations to be distingueshed at client side). - /// - /// - /// Single lowercase letter from latin alphabet or an empty string. - /// private string AllocateSuffix() { var count = RequestStorage.Get(FieldAttributeType) + 1; Assert.AttribsQuantityAllowed(count); RequestStorage.Set(FieldAttributeType, count); - return count == 1 ? string.Empty : char.ConvertFromUtf32(95 + count); + return count == 1 ? string.Empty : char.ConvertFromUtf32(95 + count); // single lowercase letter from latin alphabet or an empty string } } } diff --git a/src/ExpressiveAnnotations/Attributes/AssertThatAttribute.cs b/src/ExpressiveAnnotations/Attributes/AssertThatAttribute.cs index 333df9e..9bed162 100644 --- a/src/ExpressiveAnnotations/Attributes/AssertThatAttribute.cs +++ b/src/ExpressiveAnnotations/Attributes/AssertThatAttribute.cs @@ -23,6 +23,15 @@ public AssertThatAttribute(string expression) { } + /// + /// Validates a specified value with respect to the associated validation attribute. + /// Internally used by the method. + /// + /// The value to validate. + /// The validation context. + /// + /// An instance of the class. + /// protected override ValidationResult IsValidInternal(object value, ValidationContext validationContext) { if (value != null) diff --git a/src/ExpressiveAnnotations/Attributes/ExpressiveAttribute.cs b/src/ExpressiveAnnotations/Attributes/ExpressiveAttribute.cs index d180ebd..3e24b55 100644 --- a/src/ExpressiveAnnotations/Attributes/ExpressiveAttribute.cs +++ b/src/ExpressiveAnnotations/Attributes/ExpressiveAttribute.cs @@ -31,14 +31,24 @@ protected ExpressiveAttribute(string expression, string errorMessage) CachedValidationFuncs = new Dictionary>(); } - protected Dictionary> CachedValidationFuncs { get; set; } - protected Parser Parser { get; set; } + /// + /// Gets the cached validation funcs. + /// + protected Dictionary> CachedValidationFuncs { get; private set; } + + /// + /// Gets the parser. + /// + protected Parser Parser { get; private set; } /// /// Gets or sets the logical expression based on which specified condition is computed. /// public string Expression { get; set; } + /// + /// When implemented in a derived class, gets a unique identifier for this . + /// public override object TypeId { /* From MSDN (msdn.microsoft.com/en-us/library/system.attribute.typeid.aspx, msdn.microsoft.com/en-us/library/6w3a7b50.aspx): @@ -91,13 +101,22 @@ public string FormatErrorMessage(string displayName, string expression) return string.Format(ErrorMessageString, displayName, expression); } + /// + /// Validates a specified value with respect to the associated validation attribute. + /// Internally used by the method. + /// + /// The value to validate. + /// The validation context. + /// + /// An instance of the class. + /// protected abstract ValidationResult IsValidInternal(object value, ValidationContext validationContext); /// - /// Validates a specified value with respect to the current validation attribute. + /// Validates a specified value with respect to the associated validation attribute. /// /// The value to validate. - /// The context information about the validation operation. + /// The validation context. /// /// An instance of the class. /// diff --git a/src/ExpressiveAnnotations/Attributes/RequiredIfAttribute.cs b/src/ExpressiveAnnotations/Attributes/RequiredIfAttribute.cs index 2a1ffef..e841ff3 100644 --- a/src/ExpressiveAnnotations/Attributes/RequiredIfAttribute.cs +++ b/src/ExpressiveAnnotations/Attributes/RequiredIfAttribute.cs @@ -28,6 +28,15 @@ public RequiredIfAttribute(string expression) /// public bool AllowEmptyStrings { get; set; } + /// + /// Validates a specified value with respect to the associated validation attribute. + /// Internally used by the method. + /// + /// The value to validate. + /// The validation context. + /// + /// An instance of the class. + /// protected override ValidationResult IsValidInternal(object value, ValidationContext validationContext) { var isEmpty = value is string && string.IsNullOrWhiteSpace((string) value); diff --git a/src/ExpressiveAnnotations/Properties/AssemblyInfo.cs b/src/ExpressiveAnnotations/Properties/AssemblyInfo.cs index 8b8faaf..a65be38 100644 --- a/src/ExpressiveAnnotations/Properties/AssemblyInfo.cs +++ b/src/ExpressiveAnnotations/Properties/AssemblyInfo.cs @@ -48,5 +48,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.2.6.0")] -[assembly: AssemblyFileVersion("2.2.6.0")] +[assembly: AssemblyVersion("2.2.7.0")] +[assembly: AssemblyFileVersion("2.2.7.0")]