__ObservableValidatorHelper.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // See the LICENSE file in the project root for more information.
  4. using System;
  5. using System.ComponentModel;
  6. using System.Diagnostics.CodeAnalysis;
  7. namespace CommunityToolkit.Mvvm.ComponentModel.__Internals;
  8. /// <summary>
  9. /// An internal helper to support the source generator APIs related to <see cref="ObservableValidator"/>.
  10. /// This type is not intended to be used directly by user code.
  11. /// </summary>
  12. [EditorBrowsable(EditorBrowsableState.Never)]
  13. [Obsolete("This type is not intended to be used directly by user code")]
  14. public static class __ObservableValidatorHelper
  15. {
  16. /// <summary>
  17. /// Invokes <see cref="ObservableValidator.ValidateProperty(object?, string?)"/> externally on a target instance.
  18. /// </summary>
  19. /// <param name="instance">The target <see cref="ObservableValidator"/> instance.</param>
  20. /// <param name="value">The value to test for the specified property.</param>
  21. /// <param name="propertyName">The name of the property to validate.</param>
  22. [EditorBrowsable(EditorBrowsableState.Never)]
  23. [Obsolete("This method is not intended to be called directly by user code")]
  24. [UnconditionalSuppressMessage(
  25. "ReflectionAnalysis",
  26. "IL2026:RequiresUnreferencedCode",
  27. Justification = "This helper is called by generated code from public APIs that have the proper annotations already (and we don't want generated code to produce warnings that developers cannot fix).")]
  28. public static void ValidateProperty(ObservableValidator instance, object? value, string propertyName)
  29. {
  30. instance.ValidateProperty(value, propertyName);
  31. }
  32. }