Skip to content

Commit

Permalink
remove some defensive ArgumentNullExceptions that nullable reference …
Browse files Browse the repository at this point in the history
…types sufficiently warn about
  • Loading branch information
adelikat committed Mar 23, 2024
1 parent 78afdf8 commit 5f2c0da
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 25 deletions.
5 changes: 0 additions & 5 deletions TASVideos.Common/Extensions/EnumerableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ public static IEnumerable<T> SecondHalf<T>(this IEnumerable<T> source)
/// </summary>
public static T AtRandom<T>(this ICollection<T> collection)
{
if (collection is null)
{
throw new ArgumentNullException($"{nameof(collection)} can not be null");
}

var randomIndex = new Random(DateTime.UtcNow.Millisecond).Next(0, collection.Count);
return collection.ElementAt(randomIndex);
}
Expand Down
10 changes: 0 additions & 10 deletions TASVideos/Extensions/HtmlHelperExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@ public static class HtmlHelperExtensions
{
public static IHtmlContent DescriptionFor<TModel, TValue>(this IHtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression)
{
if (html is null)
{
throw new ArgumentNullException(nameof(html));
}

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

var expressionProvider = html.ViewContext.HttpContext.RequestServices.GetRequiredService<ModelExpressionProvider>();
var modelExpression = expressionProvider.CreateModelExpression(html.ViewData, expression);

Expand Down
5 changes: 0 additions & 5 deletions TASVideos/Extensions/HttpRequestExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ public static class HttpRequestExtensions

public static bool IsAjaxRequest(this HttpRequest request)
{
if (request is null)
{
throw new ArgumentNullException(nameof(request));
}

return request.Headers[RequestedWithHeader] == XmlHttpRequest;
}

Expand Down
5 changes: 0 additions & 5 deletions TASVideos/Models/CommaSeparatedModelBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ public class DelimitedQueryStringValueProvider(

public override ValueProviderResult GetValue(string key)
{
if (key is null)
{
throw new ArgumentNullException(nameof(key));
}

var values = _queryCollection[key];
if (values.Count == 0)
{
Expand Down

0 comments on commit 5f2c0da

Please sign in to comment.