Skip to content

Commit 9c422ed

Browse files
[release/8.0] Fix nullable annotation for Validator.TryValidateValue and ValidateValue (#91293)
* Fix nullable annotation for Validator.TryValidateValue and ValidateValue * Revert Options source generator nullable annotation changes for Validator.TryValidateValue (#91305) * Fix nullable annotation for Validator.ValidateValue ref source (#91351) --------- Co-authored-by: Jeff Handley <jeffhandley@users.noreply.github.com>
1 parent 35f043f commit 9c422ed

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/libraries/System.ComponentModel.Annotations/ref/System.ComponentModel.Annotations.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,14 +387,14 @@ public static partial class Validator
387387
public static bool TryValidateObject(object instance, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult>? validationResults, bool validateAllProperties) { throw null; }
388388
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The Type of validationContext.ObjectType cannot be statically discovered.")]
389389
public static bool TryValidateProperty(object? value, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult>? validationResults) { throw null; }
390-
public static bool TryValidateValue(object value, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult>? validationResults, System.Collections.Generic.IEnumerable<System.ComponentModel.DataAnnotations.ValidationAttribute> validationAttributes) { throw null; }
390+
public static bool TryValidateValue(object? value, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult>? validationResults, System.Collections.Generic.IEnumerable<System.ComponentModel.DataAnnotations.ValidationAttribute> validationAttributes) { throw null; }
391391
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The Type of instance cannot be statically discovered and the Type's properties can be trimmed.")]
392392
public static void ValidateObject(object instance, System.ComponentModel.DataAnnotations.ValidationContext validationContext) { }
393393
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The Type of instance cannot be statically discovered and the Type's properties can be trimmed.")]
394394
public static void ValidateObject(object instance, System.ComponentModel.DataAnnotations.ValidationContext validationContext, bool validateAllProperties) { }
395395
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The Type of validationContext.ObjectType cannot be statically discovered.")]
396396
public static void ValidateProperty(object? value, System.ComponentModel.DataAnnotations.ValidationContext validationContext) { }
397-
public static void ValidateValue(object value, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.IEnumerable<System.ComponentModel.DataAnnotations.ValidationAttribute> validationAttributes) { }
397+
public static void ValidateValue(object? value, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.IEnumerable<System.ComponentModel.DataAnnotations.ValidationAttribute> validationAttributes) { }
398398
}
399399
}
400400
namespace System.ComponentModel.DataAnnotations.Schema

src/libraries/System.ComponentModel.Annotations/src/System/ComponentModel/DataAnnotations/Validator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public static bool TryValidateObject(object instance, ValidationContext validati
171171
/// then all validators will be evaluated.
172172
/// </para>
173173
/// </remarks>
174-
/// <param name="value">The value to test. It cannot be null.</param>
174+
/// <param name="value">The value to test.</param>
175175
/// <param name="validationContext">
176176
/// Describes the object being validated and provides services and context for the
177177
/// validators.
@@ -182,7 +182,7 @@ public static bool TryValidateObject(object instance, ValidationContext validati
182182
/// <paramref name="value" /> against.
183183
/// </param>
184184
/// <returns><c>true</c> if the object is valid, <c>false</c> if any validation errors are encountered.</returns>
185-
public static bool TryValidateValue(object value, ValidationContext validationContext,
185+
public static bool TryValidateValue(object? value, ValidationContext validationContext,
186186
ICollection<ValidationResult>? validationResults, IEnumerable<ValidationAttribute> validationAttributes)
187187
{
188188
ArgumentNullException.ThrowIfNull(validationAttributes);
@@ -303,12 +303,12 @@ public static void ValidateObject(object instance, ValidationContext validationC
303303
/// first.
304304
/// </para>
305305
/// </remarks>
306-
/// <param name="value">The value to test. It cannot be null.</param>
306+
/// <param name="value">The value to test.</param>
307307
/// <param name="validationContext">Describes the object being tested.</param>
308308
/// <param name="validationAttributes">The list of <see cref="ValidationAttribute" />s to validate against this instance.</param>
309309
/// <exception cref="ArgumentNullException">When <paramref name="validationContext" /> is null.</exception>
310310
/// <exception cref="ValidationException">When <paramref name="value" /> is found to be invalid.</exception>
311-
public static void ValidateValue(object value, ValidationContext validationContext,
311+
public static void ValidateValue(object? value, ValidationContext validationContext,
312312
IEnumerable<ValidationAttribute> validationAttributes)
313313
{
314314
ArgumentNullException.ThrowIfNull(validationContext);

0 commit comments

Comments
 (0)