Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Remove some dead code in System.ComponentModel.Annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
hughbe committed Jun 19, 2017
1 parent 4467f39 commit 4721339
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,7 @@ protected override ValidationResult IsValid(object value, ValidationContext vali
}
catch (TargetInvocationException tie)
{
if (tie.InnerException != null)
{
throw tie.InnerException;
}

throw;
throw tie.InnerException;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ private class PropertyStoreItem : StoreItem
internal PropertyStoreItem(Type propertyType, IEnumerable<Attribute> attributes)
: base(attributes)
{
Debug.Assert(propertyType != null);
_propertyType = propertyType;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -352,12 +353,9 @@ public static void ValidateValue(object value, ValidationContext validationConte
/// </param>
/// <returns>A new <see cref="ValidationContext" /> for the <paramref name="instance" /> provided.</returns>
/// <exception cref="ArgumentNullException">When <paramref name="validationContext" /> is null.</exception>
internal static ValidationContext CreateValidationContext(object instance, ValidationContext validationContext)
private static ValidationContext CreateValidationContext(object instance, ValidationContext validationContext)
{
if (validationContext == null)
{
throw new ArgumentNullException(nameof(validationContext));
}
Debug.Assert(validationContext != null);

// Create a new context using the existing ValidationContext that acts as an IServiceProvider and contains our existing items.
var context = new ValidationContext(instance, validationContext, validationContext.Items);
Expand All @@ -376,11 +374,6 @@ internal static ValidationContext CreateValidationContext(object instance, Valid
/// <exception cref="ArgumentNullException">When <paramref name="destinationType" /> is null.</exception>
private static bool CanBeAssigned(Type destinationType, object value)
{
if (destinationType == null)
{
throw new ArgumentNullException(nameof(destinationType));
}

if (value == null)
{
// Null can be assigned only to reference types or Nullable or Nullable<>
Expand Down Expand Up @@ -431,10 +424,7 @@ private static void EnsureValidPropertyType(string propertyName, Type propertyTy
private static IEnumerable<ValidationError> GetObjectValidationErrors(object instance,
ValidationContext validationContext, bool validateAllProperties, bool breakOnFirstError)
{
if (instance == null)
{
throw new ArgumentNullException(nameof(instance));
}
Debug.Assert(instance != null);

if (validationContext == null)
{
Expand Down Expand Up @@ -633,10 +623,7 @@ private static IEnumerable<ValidationError> GetValidationErrors(object value,
private static bool TryValidate(object value, ValidationContext validationContext, ValidationAttribute attribute,
out ValidationError validationError)
{
if (validationContext == null)
{
throw new ArgumentNullException(nameof(validationContext));
}
Debug.Assert(validationContext != null);

var validationResult = attribute.GetValidationResult(value, validationContext);
if (validationResult != ValidationResult.Success)
Expand Down Expand Up @@ -669,10 +656,7 @@ internal ValidationError(ValidationAttribute validationAttribute, object value,

internal ValidationResult ValidationResult { get; set; }

internal void ThrowValidationException()
{
throw new ValidationException(ValidationResult, ValidationAttribute, Value);
}
internal Exception ThrowValidationException() => throw new ValidationException(ValidationResult, ValidationAttribute, Value);
}
}
}

0 comments on commit 4721339

Please sign in to comment.