<commit_before>﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;

namespace Outliner
{
public static class Throw
{
   /// <summary>
   /// Tests if an object is null, and throws an ArgumentNullException if it is.
   /// </summary>
   /// <param name="argument">The argument object to test.</param>
   /// <param name="name">The name of the argument in the called function.</param>
   /// <exception cref="ArgumentNullException"></exception>
   public static void IfArgumentIsNull([ValidatedNotNull] Object argument, String name)
   {
      if (argument == null)
      {
         throw new ArgumentNullException(name);
      }
   }

   /// <summary>
   /// Tests if an object is null, and throws a NullReferenceException if it is.
   /// </summary>
   /// <param name="argument">The object to test.</param>
   /// <param name="message">The message for the exception if it is thrown.</param>
   /// <exception cref="NullReferenceException"></exception>
   public static void IfNull(Object obj, String message)
   {
      if (obj == null)
         throw new NullReferenceException(message);
   }

   /// <summary>
   /// Tests if an enumerable is empty, and throws an InvalidOperationException if it is.
   /// </summary>
   /// <param name="source">The IEnumerable to test.</param>
   /// <param name="message">The message for the exception if it is thrown.</param>
   /// <exception cref="InvalidOperationException"></exception>
   public static void IfEmpty<T>(IEnumerable<T> source, String message)<commit_msg>Added functions to Throw<commit_after>﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;

namespace Outliner
{
public static class Throw
{
   /// <summary>
   /// Tests if an object argument is null.
   /// </summary>
   /// <param name="argument">The argument object to test.</param>
   /// <param name="name">The name of the argument in the called function.</param>
   /// <exception cref="ArgumentNullException"></exception>
   public static void IfArgumentIsNull([ValidatedNotNull] Object argument, String name)
   {
      if (argument == null)
      {
         throw new ArgumentNullException(name);
      }
   }

   /// <summary>
   /// Tests if a string argument is null or empty.
   /// </summary>
   /// <param name="str">The string argument to test.</param>
   /// <param name="name">The name of the argument</param>
   /// <exception cref="ArgumentNullException"></exception>
   public static void IfArgumentIsNullOrEmpty(String str, String name)
   {
      if (String.IsNullOrEmpty(str))
         throw new ArgumentNullException(name);
   }

   /// <summary>
   /// Tests if an object is null.
   /// </summary>
   /// <param name="argument">The object to test.</param>
   /// <param name="message">The message for the exception if it is thrown.</param>
   /// <exception cref="InvalidOperationException"></exception>
   public static void IfNull(Object obj, String message)
   {
      if (obj == null)
         throw new InvalidOperationException(message);
   }

   /// <summary>
   /// Tests if a string is null or empty.
   /// </summary>
   /// <param name="str">The string to test.</param>
   /// <param name="varName">The name of the string variable.</param>
   /// <exception cref="InvalidOperationException"/>
   public static void IfNullOrEmpty(String str, String varName)
   {
      if (String.IsNullOrEmpty(str))
         throw new InvalidOperationException(varName + " cannot be null or empty");
   }

   /// <summary>
   /// Tests if an enumerable is empty, and throws an InvalidOperationException if it is.
   /// </summary>
   /// <param name="source">The IEnumerable to test.</param>
   /// <param name="message">The message for the exception if it is thrown.</param>
   /// <exception cref="InvalidOperationException"></exception>
   public static void IfEmpty<T>(IEnumerable<T> source, String message)
{'fraction_non_alphanumeric': 0.1328757048296151, 'fraction_numerical': 0.0, 'mean_word_length': 3.1379310344827585, 'pattern_counts': {'":': 0, '<': 70, '<?xml version=': 0, '>': 70, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5364433', 'n_tokens_mistral': 1079, 'n_tokens_neox': 1080, 'n_words': 370}