Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Housekeeping clean up Android X project #694

Merged
merged 1 commit into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Directory.build.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<LangVersion>preview</LangVersion>
<EnableNETAnalyzers>True</EnableNETAnalyzers>
<AnalysisLevel>latest</AnalysisLevel>
<NoWarn>$(NoWarn);IDE1006</NoWarn>
<NoWarn>$(NoWarn);IDE1006;IDE0130</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand All @@ -48,4 +48,4 @@
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" />
</ItemGroup>

</Project>
</Project>
87 changes: 6 additions & 81 deletions src/ReactiveUI.Validation.AndroidX/Extensions/ViewForExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using ReactiveUI.Validation.ValidationBindings;
using Splat;

// ReSharper disable once CheckNamespace
namespace ReactiveUI.Validation.Extensions;

/// <summary>
Expand All @@ -40,7 +39,6 @@ public static class ViewForExtensions
/// IValidationTextFormatter&lt;string&gt; into Splat.Locator.
/// </param>
/// <returns>Returns a <see cref="IDisposable"/> object.</returns>
[SuppressMessage("Design", "CA1801: Parameter unused", Justification = "Used for generic resolution.")]
public static IDisposable BindValidation<TView, TViewModel, TViewModelProperty>(
this TView view,
TViewModel? viewModel,
Expand All @@ -50,74 +48,11 @@ public static IDisposable BindValidation<TView, TViewModel, TViewModelProperty>(
where TView : IViewFor<TViewModel>
where TViewModel : class, IReactiveObject, IValidatableViewModel
{
if (view is null)
{
throw new ArgumentNullException(nameof(view));
}
ArgumentNullException.ThrowIfNull(view);

if (viewModelProperty is null)
{
throw new ArgumentNullException(nameof(viewModelProperty));
}
ArgumentNullException.ThrowIfNull(viewModelProperty);

if (viewProperty is null)
{
throw new ArgumentNullException(nameof(viewProperty));
}

formatter ??= Locator.Current.GetService<IValidationTextFormatter<string>>() ??
SingleLineFormatter.Default;

return ValidationBinding.ForProperty(
view,
viewModelProperty,
(_, errors) => viewProperty.Error = errors.FirstOrDefault(msg => !string.IsNullOrEmpty(msg)),
formatter);
}

/// <summary>
/// Platform binding to the TextInputLayout.
/// </summary>
/// <remarks>Supports multiple validations for the same property.</remarks>
/// <typeparam name="TView">IViewFor of TViewModel.</typeparam>
/// <typeparam name="TViewModel">ViewModel type.</typeparam>
/// <typeparam name="TViewModelProperty">ViewModel property type.</typeparam>
/// <param name="view">IViewFor instance.</param>
/// <param name="viewModel">ViewModel instance. Can be null, used for generic type resolution.</param>
/// <param name="viewModelProperty">ViewModel property.</param>
/// <param name="viewProperty">View property to bind the validation message.</param>
/// <param name="formatter">
/// Validation formatter. Defaults to <see cref="SingleLineFormatter"/>. In order to override the global
/// default value, implement <see cref="IValidationTextFormatter{TOut}"/> and register an instance of
/// IValidationTextFormatter&lt;string&gt; into Splat.Locator.
/// </param>
/// <returns>Returns a <see cref="IDisposable"/> object.</returns>
[ExcludeFromCodeCoverage]
[Obsolete("This method is no longer required, BindValidation now supports multiple validations.")]
[SuppressMessage("Design", "CA1801: Parameter unused", Justification = "Used for generic resolution.")]
public static IDisposable BindValidationEx<TView, TViewModel, TViewModelProperty>(
this TView view,
TViewModel? viewModel,
Expression<Func<TViewModel, TViewModelProperty?>> viewModelProperty,
TextInputLayout viewProperty,
IValidationTextFormatter<string>? formatter = null)
where TView : IViewFor<TViewModel>
where TViewModel : class, IReactiveObject, IValidatableViewModel
{
if (view is null)
{
throw new ArgumentNullException(nameof(view));
}

if (viewModelProperty is null)
{
throw new ArgumentNullException(nameof(viewModelProperty));
}

if (viewProperty is null)
{
throw new ArgumentNullException(nameof(viewProperty));
}
ArgumentNullException.ThrowIfNull(viewProperty);

formatter ??= Locator.Current.GetService<IValidationTextFormatter<string>>() ??
SingleLineFormatter.Default;
Expand All @@ -144,7 +79,6 @@ public static IDisposable BindValidationEx<TView, TViewModel, TViewModelProperty
/// IValidationTextFormatter&lt;string&gt; into Splat.Locator.
/// </param>
/// <returns>Returns a <see cref="IDisposable"/> object.</returns>
[SuppressMessage("Design", "CA1801: Parameter unused", Justification = "Used for generic resolution.")]
public static IDisposable BindValidation<TView, TViewModel>(
this TView view,
TViewModel? viewModel,
Expand All @@ -154,20 +88,11 @@ public static IDisposable BindValidation<TView, TViewModel>(
where TView : IViewFor<TViewModel>
where TViewModel : class, IReactiveObject, IValidatableViewModel
{
if (view is null)
{
throw new ArgumentNullException(nameof(view));
}
ArgumentNullException.ThrowIfNull(view);

if (viewModelHelperProperty is null)
{
throw new ArgumentNullException(nameof(viewModelHelperProperty));
}
ArgumentNullException.ThrowIfNull(viewModelHelperProperty);

if (viewProperty is null)
{
throw new ArgumentNullException(nameof(viewProperty));
}
ArgumentNullException.ThrowIfNull(viewProperty);

formatter ??= Locator.Current.GetService<IValidationTextFormatter<string>>() ??
SingleLineFormatter.Default;
Expand Down
Loading