44// See the LICENSE file in the project root for full license information.
55
66using System ;
7+ using System . Diagnostics . CodeAnalysis ;
78using System . Linq ;
89using System . Linq . Expressions ;
910using System . Reactive . Disposables ;
1011using System . Reactive . Linq ;
12+
1113using ReactiveUI . Validation . Abstractions ;
1214using ReactiveUI . Validation . Components ;
1315using ReactiveUI . Validation . Components . Abstractions ;
@@ -32,6 +34,10 @@ public static class ValidatableViewModelExtensions
3234 /// <param name="isPropertyValid">Func to define if the viewModelProperty is valid or not.</param>
3335 /// <param name="message">Validation error message.</param>
3436 /// <returns>Returns a <see cref="ValidationHelper"/> object.</returns>
37+ #if NET6_0_OR_GREATER
38+ [ RequiresDynamicCode ( "WhenAnyValue uses expression trees which require dynamic code generation in AOT scenarios." ) ]
39+ [ RequiresUnreferencedCode ( "WhenAnyValue may reference members that could be trimmed in AOT scenarios." ) ]
40+ #endif
3541 public static ValidationHelper ValidationRule < TViewModel , TViewModelProp > (
3642 this TViewModel viewModel ,
3743 Expression < Func < TViewModel , TViewModelProp ? > > viewModelProperty ,
@@ -76,6 +82,10 @@ public static ValidationHelper ValidationRule<TViewModel, TViewModelProp>(
7682 /// <param name="isPropertyValid">Func to define if the viewModelProperty is valid or not.</param>
7783 /// <param name="message">Func to define the validation error message based on the viewModelProperty value.</param>
7884 /// <returns>Returns a <see cref="ValidationHelper"/> object.</returns>
85+ #if NET6_0_OR_GREATER
86+ [ RequiresDynamicCode ( "WhenAnyValue uses expression trees which require dynamic code generation in AOT scenarios." ) ]
87+ [ RequiresUnreferencedCode ( "WhenAnyValue may reference members that could be trimmed in AOT scenarios." ) ]
88+ #endif
7989 public static ValidationHelper ValidationRule < TViewModel , TViewModelProp > (
8090 this TViewModel viewModel ,
8191 Expression < Func < TViewModel , TViewModelProp ? > > viewModelProperty ,
@@ -120,6 +130,10 @@ public static ValidationHelper ValidationRule<TViewModel, TViewModelProp>(
120130 /// It should be noted that the observable should provide an initial value, otherwise that can result
121131 /// in an inconsistent performance.
122132 /// </remarks>
133+ #if NET6_0_OR_GREATER
134+ [ RequiresDynamicCode ( "WhenAnyValue uses expression trees which require dynamic code generation in AOT scenarios." ) ]
135+ [ RequiresUnreferencedCode ( "WhenAnyValue may reference members that could be trimmed in AOT scenarios." ) ]
136+ #endif
123137 public static ValidationHelper ValidationRule < TViewModel > (
124138 this TViewModel viewModel ,
125139 IObservable < bool > validationObservable ,
@@ -164,6 +178,10 @@ public static ValidationHelper ValidationRule<TViewModel>(
164178 /// It should be noted that the observable should provide an initial value, otherwise that can result
165179 /// in an inconsistent performance.
166180 /// </remarks>
181+ #if NET6_0_OR_GREATER
182+ [ RequiresDynamicCode ( "WhenAnyValue uses expression trees which require dynamic code generation in AOT scenarios." ) ]
183+ [ RequiresUnreferencedCode ( "WhenAnyValue may reference members that could be trimmed in AOT scenarios." ) ]
184+ #endif
167185 public static ValidationHelper ValidationRule < TViewModel , TValue > (
168186 this TViewModel viewModel ,
169187 IObservable < TValue > validationObservable ,
@@ -207,6 +225,10 @@ public static ValidationHelper ValidationRule<TViewModel, TValue>(
207225 /// It should be noted that the observable should provide an initial value, otherwise that can result
208226 /// in an inconsistent performance.
209227 /// </remarks>
228+ #if NET6_0_OR_GREATER
229+ [ RequiresDynamicCode ( "WhenAnyValue uses expression trees which require dynamic code generation in AOT scenarios." ) ]
230+ [ RequiresUnreferencedCode ( "WhenAnyValue may reference members that could be trimmed in AOT scenarios." ) ]
231+ #endif
210232 public static ValidationHelper ValidationRule < TViewModel > (
211233 this TViewModel viewModel ,
212234 IObservable < IValidationState > validationObservable )
@@ -239,6 +261,10 @@ public static ValidationHelper ValidationRule<TViewModel>(
239261 /// It should be noted that the observable should provide an initial value, otherwise that can result
240262 /// in an inconsistent performance.
241263 /// </remarks>
264+ #if NET6_0_OR_GREATER
265+ [ RequiresDynamicCode ( "WhenAnyValue uses expression trees which require dynamic code generation in AOT scenarios." ) ]
266+ [ RequiresUnreferencedCode ( "WhenAnyValue may reference members that could be trimmed in AOT scenarios." ) ]
267+ #endif
242268 public static ValidationHelper ValidationRule < TViewModel , TValue > (
243269 this TViewModel viewModel ,
244270 IObservable < TValue > validationObservable )
@@ -275,6 +301,10 @@ public static ValidationHelper ValidationRule<TViewModel, TValue>(
275301 /// It should be noted that the observable should provide an initial value, otherwise that can result
276302 /// in an inconsistent performance.
277303 /// </remarks>
304+ #if NET6_0_OR_GREATER
305+ [ RequiresDynamicCode ( "WhenAnyValue uses expression trees which require dynamic code generation in AOT scenarios." ) ]
306+ [ RequiresUnreferencedCode ( "WhenAnyValue may reference members that could be trimmed in AOT scenarios." ) ]
307+ #endif
278308 public static ValidationHelper ValidationRule < TViewModel , TViewModelProp > (
279309 this TViewModel viewModel ,
280310 Expression < Func < TViewModel , TViewModelProp > > viewModelProperty ,
@@ -328,6 +358,10 @@ public static ValidationHelper ValidationRule<TViewModel, TViewModelProp>(
328358 /// It should be noted that the observable should provide an initial value, otherwise that can result
329359 /// in an inconsistent performance.
330360 /// </remarks>
361+ #if NET6_0_OR_GREATER
362+ [ RequiresDynamicCode ( "WhenAnyValue uses expression trees which require dynamic code generation in AOT scenarios." ) ]
363+ [ RequiresUnreferencedCode ( "WhenAnyValue may reference members that could be trimmed in AOT scenarios." ) ]
364+ #endif
331365 public static ValidationHelper ValidationRule < TViewModel , TViewModelProp , TValue > (
332366 this TViewModel viewModel ,
333367 Expression < Func < TViewModel , TViewModelProp > > viewModelProperty ,
@@ -379,6 +413,10 @@ public static ValidationHelper ValidationRule<TViewModel, TViewModelProp, TValue
379413 /// It should be noted that the observable should provide an initial value, otherwise that can result
380414 /// in an inconsistent performance.
381415 /// </remarks>
416+ #if NET6_0_OR_GREATER
417+ [ RequiresDynamicCode ( "WhenAnyValue uses expression trees which require dynamic code generation in AOT scenarios." ) ]
418+ [ RequiresUnreferencedCode ( "WhenAnyValue may reference members that could be trimmed in AOT scenarios." ) ]
419+ #endif
382420 public static ValidationHelper ValidationRule < TViewModel , TViewModelProp > (
383421 this TViewModel viewModel ,
384422 Expression < Func < TViewModel , TViewModelProp > > viewModelProperty ,
@@ -419,6 +457,10 @@ public static ValidationHelper ValidationRule<TViewModel, TViewModelProp>(
419457 /// It should be noted that the observable should provide an initial value, otherwise that can result
420458 /// in an inconsistent performance.
421459 /// </remarks>
460+ #if NET6_0_OR_GREATER
461+ [ RequiresDynamicCode ( "WhenAnyValue uses expression trees which require dynamic code generation in AOT scenarios." ) ]
462+ [ RequiresUnreferencedCode ( "WhenAnyValue may reference members that could be trimmed in AOT scenarios." ) ]
463+ #endif
422464 public static ValidationHelper ValidationRule < TViewModel , TViewModelProp , TValue > (
423465 this TViewModel viewModel ,
424466 Expression < Func < TViewModel , TViewModelProp > > viewModelProperty ,
@@ -525,6 +567,10 @@ public static IObservable<bool> IsValid<TViewModel>(this TViewModel viewModel)
525567 /// <param name="validation">The disposable validation component to register into the context.</param>
526568 /// <typeparam name="TValidationComponent">The disposable validation component type.</typeparam>
527569 /// <returns>The bindable validation helper holding the disposable.</returns>
570+ #if NET6_0_OR_GREATER
571+ [ RequiresDynamicCode ( "WhenAnyValue uses expression trees which require dynamic code generation in AOT scenarios." ) ]
572+ [ RequiresUnreferencedCode ( "WhenAnyValue may reference members that could be trimmed in AOT scenarios." ) ]
573+ #endif
528574 private static ValidationHelper RegisterValidation < TValidationComponent > (
529575 this IValidatableViewModel viewModel ,
530576 TValidationComponent validation )
0 commit comments