@@ -35,7 +35,7 @@ public static void ArgumentNotNullOrEmptyEnumerable<T>(IEnumerable<T> argumentVa
35
35
{
36
36
ArgumentNotNull ( argumentValue , argumentName ) ;
37
37
38
- if ( argumentValue . Count ( ) == 0 )
38
+ if ( ! argumentValue . Any ( ) )
39
39
{
40
40
throw new ArgumentException ( "Enumerable cannot be empty" , argumentName ) ;
41
41
}
@@ -50,7 +50,7 @@ public static void ArgumentNotNullOrEmptyString(string argumentValue, string arg
50
50
{
51
51
ArgumentNotNull ( argumentValue , argumentName ) ;
52
52
53
- if ( argumentValue . Trim ( ) . Length == 0 )
53
+ if ( String . IsNullOrWhiteSpace ( argumentValue ) )
54
54
{
55
55
throw new ArgumentException ( "String cannot be empty" , argumentName ) ;
56
56
}
@@ -145,17 +145,15 @@ public static void ZeroResult(int result)
145
145
}
146
146
147
147
/// <summary>
148
- /// Check that the result of a C call that returns a boolean value
149
- /// was successful
148
+ /// Check that the result of a C call returns a boolean value.
150
149
/// <para>
151
- /// The native function is expected to return strictly 0 for
152
- /// success or a negative value in the case of failure.
150
+ /// The native function is expected to return strictly 0 or 1.
153
151
/// </para>
154
152
/// </summary>
155
153
/// <param name="result">The result to examine.</param>
156
154
public static void BooleanResult ( int result )
157
155
{
158
- if ( result == ( int ) GitErrorCode . Ok || result == 1 )
156
+ if ( result == 0 || result == 1 )
159
157
{
160
158
return ;
161
159
}
@@ -164,11 +162,11 @@ public static void BooleanResult(int result)
164
162
}
165
163
166
164
/// <summary>
167
- /// Check that the result of a C call that returns an integer value
168
- /// was successful
165
+ /// Check that the result of a C call that returns an integer
166
+ /// value was successful.
169
167
/// <para>
170
- /// The native function is expected to return strictly 0 for
171
- /// success or a negative value in the case of failure.
168
+ /// The native function is expected to return 0 or a positive
169
+ /// value for success or a negative value in the case of failure.
172
170
/// </para>
173
171
/// </summary>
174
172
/// <param name="result">The result to examine.</param>
@@ -182,16 +180,6 @@ public static void Int32Result(int result)
182
180
HandleError ( result ) ;
183
181
}
184
182
185
- public static void NotNullResult ( Object result )
186
- {
187
- if ( result != null )
188
- {
189
- return ;
190
- }
191
-
192
- HandleError ( ( int ) GitErrorCode . Error ) ;
193
- }
194
-
195
183
/// <summary>
196
184
/// Checks an argument by applying provided checker.
197
185
/// </summary>
@@ -208,6 +196,15 @@ public static void ArgumentConformsTo<T>(T argumentValue, Func<T, bool> checker,
208
196
throw new ArgumentException ( argumentName ) ;
209
197
}
210
198
199
+ /// <summary>
200
+ /// Check that the result of a C call that returns a non-null GitObject
201
+ /// using the default exception builder.
202
+ /// <para>
203
+ /// The native function is expected to return a valid object value.
204
+ /// </para>
205
+ /// </summary>
206
+ /// <param name="gitObject">The <see cref="GitObject"/> to examine.</param>
207
+ /// <param name="identifier">The <see cref="GitObject"/> identifier to examine.</param>
211
208
public static void GitObjectIsNotNull ( GitObject gitObject , string identifier )
212
209
{
213
210
Func < string , LibGit2SharpException > exceptionBuilder ;
@@ -224,6 +221,17 @@ public static void GitObjectIsNotNull(GitObject gitObject, string identifier)
224
221
GitObjectIsNotNull ( gitObject , identifier , exceptionBuilder ) ;
225
222
}
226
223
224
+
225
+ /// <summary>
226
+ /// Check that the result of a C call that returns a non-null GitObject
227
+ /// using the default exception builder.
228
+ /// <para>
229
+ /// The native function is expected to return a valid object value.
230
+ /// </para>
231
+ /// </summary>
232
+ /// <param name="gitObject">The <see cref="GitObject"/> to examine.</param>
233
+ /// <param name="identifier">The <see cref="GitObject"/> identifier to examine.</param>
234
+ /// <param name="exceptionBuilder">The builder which constructs an <see cref="LibGit2SharpException"/> from a message.</param>
227
235
public static void GitObjectIsNotNull (
228
236
GitObject gitObject ,
229
237
string identifier ,
0 commit comments