Skip to content

Commit a290a9c

Browse files
authored
Housekeeping clean up Android X project (#694)
1 parent 8884b6f commit a290a9c

File tree

2 files changed

+8
-83
lines changed

2 files changed

+8
-83
lines changed

src/Directory.build.props

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<LangVersion>preview</LangVersion>
2828
<EnableNETAnalyzers>True</EnableNETAnalyzers>
2929
<AnalysisLevel>latest</AnalysisLevel>
30-
<NoWarn>$(NoWarn);IDE1006</NoWarn>
30+
<NoWarn>$(NoWarn);IDE1006;IDE0130</NoWarn>
3131
</PropertyGroup>
3232

3333
<ItemGroup>
@@ -48,4 +48,4 @@
4848
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" />
4949
</ItemGroup>
5050

51-
</Project>
51+
</Project>

src/ReactiveUI.Validation.AndroidX/Extensions/ViewForExtensions.cs

+6-81
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
using ReactiveUI.Validation.ValidationBindings;
1616
using Splat;
1717

18-
// ReSharper disable once CheckNamespace
1918
namespace ReactiveUI.Validation.Extensions;
2019

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

58-
if (viewModelProperty is null)
59-
{
60-
throw new ArgumentNullException(nameof(viewModelProperty));
61-
}
53+
ArgumentNullException.ThrowIfNull(viewModelProperty);
6254

63-
if (viewProperty is null)
64-
{
65-
throw new ArgumentNullException(nameof(viewProperty));
66-
}
67-
68-
formatter ??= Locator.Current.GetService<IValidationTextFormatter<string>>() ??
69-
SingleLineFormatter.Default;
70-
71-
return ValidationBinding.ForProperty(
72-
view,
73-
viewModelProperty,
74-
(_, errors) => viewProperty.Error = errors.FirstOrDefault(msg => !string.IsNullOrEmpty(msg)),
75-
formatter);
76-
}
77-
78-
/// <summary>
79-
/// Platform binding to the TextInputLayout.
80-
/// </summary>
81-
/// <remarks>Supports multiple validations for the same property.</remarks>
82-
/// <typeparam name="TView">IViewFor of TViewModel.</typeparam>
83-
/// <typeparam name="TViewModel">ViewModel type.</typeparam>
84-
/// <typeparam name="TViewModelProperty">ViewModel property type.</typeparam>
85-
/// <param name="view">IViewFor instance.</param>
86-
/// <param name="viewModel">ViewModel instance. Can be null, used for generic type resolution.</param>
87-
/// <param name="viewModelProperty">ViewModel property.</param>
88-
/// <param name="viewProperty">View property to bind the validation message.</param>
89-
/// <param name="formatter">
90-
/// Validation formatter. Defaults to <see cref="SingleLineFormatter"/>. In order to override the global
91-
/// default value, implement <see cref="IValidationTextFormatter{TOut}"/> and register an instance of
92-
/// IValidationTextFormatter&lt;string&gt; into Splat.Locator.
93-
/// </param>
94-
/// <returns>Returns a <see cref="IDisposable"/> object.</returns>
95-
[ExcludeFromCodeCoverage]
96-
[Obsolete("This method is no longer required, BindValidation now supports multiple validations.")]
97-
[SuppressMessage("Design", "CA1801: Parameter unused", Justification = "Used for generic resolution.")]
98-
public static IDisposable BindValidationEx<TView, TViewModel, TViewModelProperty>(
99-
this TView view,
100-
TViewModel? viewModel,
101-
Expression<Func<TViewModel, TViewModelProperty?>> viewModelProperty,
102-
TextInputLayout viewProperty,
103-
IValidationTextFormatter<string>? formatter = null)
104-
where TView : IViewFor<TViewModel>
105-
where TViewModel : class, IReactiveObject, IValidatableViewModel
106-
{
107-
if (view is null)
108-
{
109-
throw new ArgumentNullException(nameof(view));
110-
}
111-
112-
if (viewModelProperty is null)
113-
{
114-
throw new ArgumentNullException(nameof(viewModelProperty));
115-
}
116-
117-
if (viewProperty is null)
118-
{
119-
throw new ArgumentNullException(nameof(viewProperty));
120-
}
55+
ArgumentNullException.ThrowIfNull(viewProperty);
12156

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

162-
if (viewModelHelperProperty is null)
163-
{
164-
throw new ArgumentNullException(nameof(viewModelHelperProperty));
165-
}
93+
ArgumentNullException.ThrowIfNull(viewModelHelperProperty);
16694

167-
if (viewProperty is null)
168-
{
169-
throw new ArgumentNullException(nameof(viewProperty));
170-
}
95+
ArgumentNullException.ThrowIfNull(viewProperty);
17196

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

0 commit comments

Comments
 (0)