44using System . Collections . Generic ;
55using System . Diagnostics ;
66using JetBrains . Annotations ;
7- using System . Reflection ;
7+ // using System.Reflection;
88
99// Copied from https://github.com/aspnet/EntityFramework/blob/dev/src/Shared/Check.cs
1010namespace System . Linq . Dynamic . Core . Validation
1111{
1212 [ DebuggerStepThrough ]
1313 internal static class Check
1414 {
15- public static T Condition < T > ( [ NoEnumeration ] T value , [ NotNull ] Predicate < T > condition , [ InvokerParameterName ] [ NotNull ] string parameterName )
15+ public static T Condition < T > ( [ ValidatedNotNull , NoEnumeration ] T value , [ ValidatedNotNull , NotNull ] Predicate < T > condition , [ InvokerParameterName , ValidatedNotNull , NotNull ] string parameterName )
1616 {
1717 NotNull ( condition , nameof ( condition ) ) ;
1818
@@ -27,7 +27,7 @@ public static T Condition<T>([NoEnumeration] T value, [NotNull] Predicate<T> con
2727 }
2828
2929 [ ContractAnnotation ( "value:null => halt" ) ]
30- public static T NotNull < T > ( [ NoEnumeration ] T value , [ InvokerParameterName ] [ NotNull ] string parameterName )
30+ public static T NotNull < T > ( [ ValidatedNotNull , NoEnumeration ] T value , [ InvokerParameterName , ValidatedNotNull , NotNull ] string parameterName )
3131 {
3232 if ( ReferenceEquals ( value , null ) )
3333 {
@@ -42,8 +42,8 @@ public static T NotNull<T>([NoEnumeration] T value, [InvokerParameterName] [NotN
4242 [ ContractAnnotation ( "value:null => halt" ) ]
4343 public static T NotNull < T > (
4444 [ NoEnumeration ] T value ,
45- [ InvokerParameterName ] [ NotNull ] string parameterName ,
46- [ NotNull ] string propertyName )
45+ [ InvokerParameterName , ValidatedNotNull , NotNull ] string parameterName ,
46+ [ ValidatedNotNull , NotNull ] string propertyName )
4747 {
4848 if ( ReferenceEquals ( value , null ) )
4949 {
@@ -56,23 +56,23 @@ public static T NotNull<T>(
5656 return value ;
5757 }
5858
59- [ ContractAnnotation ( "value:null => halt" ) ]
60- public static IList < T > NotEmpty < T > ( IList < T > value , [ InvokerParameterName ] [ NotNull ] string parameterName )
61- {
62- NotNull ( value , parameterName ) ;
59+ // [ContractAnnotation("value:null => halt")]
60+ // public static IList<T> NotEmpty<T>(IList<T> value, [InvokerParameterName, ValidatedNotNull, NotNull] string parameterName)
61+ // {
62+ // NotNull(value, parameterName);
6363
64- if ( value . Count == 0 )
65- {
66- NotEmpty ( parameterName , nameof ( parameterName ) ) ;
64+ // if (value.Count == 0)
65+ // {
66+ // NotEmpty(parameterName, nameof(parameterName));
6767
68- throw new ArgumentException ( CoreStrings . CollectionArgumentIsEmpty ( parameterName ) ) ;
69- }
68+ // throw new ArgumentException(CoreStrings.CollectionArgumentIsEmpty(parameterName));
69+ // }
7070
71- return value ;
72- }
71+ // return value;
72+ // }
7373
7474 [ ContractAnnotation ( "value:null => halt" ) ]
75- public static string NotEmpty ( string value , [ InvokerParameterName ] [ NotNull ] string parameterName )
75+ public static string NotEmpty ( string value , [ InvokerParameterName , ValidatedNotNull , NotNull ] string parameterName )
7676 {
7777 Exception e = null ;
7878 if ( ReferenceEquals ( value , null ) )
@@ -94,20 +94,19 @@ public static string NotEmpty(string value, [InvokerParameterName] [NotNull] str
9494 return value ;
9595 }
9696
97- public static string NullButNotEmpty ( string value , [ InvokerParameterName ] [ NotNull ] string parameterName )
98- {
99- if ( ! ReferenceEquals ( value , null )
100- && ( value . Length == 0 ) )
101- {
102- NotEmpty ( parameterName , nameof ( parameterName ) ) ;
97+ //public static string NullButNotEmpty(string value, [InvokerParameterName, ValidatedNotNull, NotNull] string parameterName)
98+ //{
99+ // if (!ReferenceEquals(value, null) && value.Length == 0)
100+ // {
101+ // NotEmpty(parameterName, nameof(parameterName));
103102
104- throw new ArgumentException ( CoreStrings . ArgumentIsEmpty ( parameterName ) ) ;
105- }
103+ // throw new ArgumentException(CoreStrings.ArgumentIsEmpty(parameterName));
104+ // }
106105
107- return value ;
108- }
106+ // return value;
107+ // }
109108
110- public static IList < T > HasNoNulls < T > ( IList < T > value , [ InvokerParameterName ] [ NotNull ] string parameterName )
109+ public static IList < T > HasNoNulls < T > ( IList < T > value , [ InvokerParameterName , ValidatedNotNull , NotNull ] string parameterName )
111110 where T : class
112111 {
113112 NotNull ( value , parameterName ) ;
@@ -122,16 +121,16 @@ public static IList<T> HasNoNulls<T>(IList<T> value, [InvokerParameterName] [Not
122121 return value ;
123122 }
124123
125- public static Type ValidEntityType ( Type value , [ InvokerParameterName ] [ NotNull ] string parameterName )
126- {
127- if ( ! value . GetTypeInfo ( ) . IsClass )
128- {
129- NotEmpty ( parameterName , nameof ( parameterName ) ) ;
124+ // public static Type ValidEntityType(Type value, [InvokerParameterName, ValidatedNotNull, NotNull] string parameterName)
125+ // {
126+ // if (!value.GetTypeInfo().IsClass)
127+ // {
128+ // NotEmpty(parameterName, nameof(parameterName));
130129
131- throw new ArgumentException ( CoreStrings . InvalidEntityType ( value , parameterName ) ) ;
132- }
130+ // throw new ArgumentException(CoreStrings.InvalidEntityType(value, parameterName));
131+ // }
133132
134- return value ;
135- }
133+ // return value;
134+ // }
136135 }
137136}
0 commit comments