Skip to content

Commit

Permalink
more nullability for PropertySupport api
Browse files Browse the repository at this point in the history
  • Loading branch information
RLittlesII committed May 16, 2024
1 parent a12ff18 commit 1ce4c73
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/Prism.Core/Mvvm/ErrorsContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public bool HasErrors
/// </summary>
/// <param name="propertyName">The name of the property.</param>
/// <returns>The validation errors of type <typeparamref name="T"/> for the property.</returns>
public IEnumerable<T> GetErrors(string propertyName)
public IEnumerable<T> GetErrors(string? propertyName)
{
var localPropertyName = propertyName;
var localPropertyName = propertyName ?? string.Empty;
if (this.validationResults.TryGetValue(localPropertyName, out var currentValidationResults))
{
return currentValidationResults;
Expand Down Expand Up @@ -104,7 +104,7 @@ public void ClearErrors<TProperty>(Expression<Func<TProperty>> propertyExpressio
/// <example>
/// container.ClearErrors("SomeProperty");
/// </example>
public void ClearErrors(string propertyName) => this.SetErrors(propertyName, new List<T>());
public void ClearErrors(string? propertyName) => this.SetErrors(propertyName, new List<T>());

/// <summary>
/// Sets the validation errors for the specified property.
Expand All @@ -113,7 +113,7 @@ public void ClearErrors<TProperty>(Expression<Func<TProperty>> propertyExpressio
/// <param name="propertyExpression">The <see cref="Expression"/> indicating the property.</param>
/// <param name="propertyErrors">The list of errors to set for the property.</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
public void SetErrors<TProperty>(Expression<Func<TProperty>> propertyExpression, IEnumerable<T> propertyErrors)
public void SetErrors<TProperty>(Expression<Func<TProperty>> propertyExpression, IEnumerable<T>? propertyErrors)
{
var propertyName = PropertySupport.ExtractPropertyName(propertyExpression);
this.SetErrors(propertyName, propertyErrors);
Expand All @@ -127,11 +127,11 @@ public void SetErrors<TProperty>(Expression<Func<TProperty>> propertyExpression,
/// </remarks>
/// <param name="propertyName">The name of the property.</param>
/// <param name="newValidationResults">The new validation errors.</param>
public void SetErrors(string propertyName, IEnumerable<T> newValidationResults)
public void SetErrors(string? propertyName, IEnumerable<T>? newValidationResults)
{
var localPropertyName = propertyName ?? string.Empty;
var hasCurrentValidationResults = this.validationResults.ContainsKey(localPropertyName);
var hasNewValidationResults = newValidationResults.Count() > 0;
var hasNewValidationResults = newValidationResults != null && newValidationResults.Count() > 0;

if (hasCurrentValidationResults || hasNewValidationResults)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Prism.Core/Mvvm/PropertySupport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static class PropertySupport
/// The <see cref="MemberExpression"/> does not represent a property.<br/>
/// Or, the property is static.
/// </exception>
public static string ExtractPropertyName<T>(Expression<Func<T>> propertyExpression)
public static string? ExtractPropertyName<T>(Expression<Func<T>> propertyExpression)
{
if (propertyExpression == null)
throw new ArgumentNullException(nameof(propertyExpression));
Expand All @@ -40,7 +40,7 @@ public static string ExtractPropertyName<T>(Expression<Func<T>> propertyExpressi
/// The <see cref="MemberExpression"/> does not represent a property.<br/>
/// Or, the property is static.
/// </exception>
internal static string ExtractPropertyNameFromLambda(LambdaExpression expression)
internal static string? ExtractPropertyNameFromLambda(LambdaExpression expression)
{
if (expression == null)
throw new ArgumentNullException(nameof(expression));
Expand Down

0 comments on commit 1ce4c73

Please sign in to comment.