<commit_before>using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Text;
using ServiceStack.Text.Common;
using ServiceStack.Text.Jsv;
using ServiceStack.Text.Reflection;

namespace ServiceStack.Text
{
	public class CsvSerializer
	{
		private static readonly UTF8Encoding UTF8EncodingWithoutBom = new UTF8Encoding(false);

		private static readonly Dictionary<Type, WriteObjectDelegate> WriteFnCache =
			new Dictionary<Type, WriteObjectDelegate>();

		internal static WriteObjectDelegate GetWriteFn(Type type)
		{
			try
			{
				WriteObjectDelegate writeFn;
				lock (WriteFnCache)
				{
					if (!WriteFnCache.TryGetValue(type, out writeFn))
					{
						var genericType = typeof(CsvSerializer<>).MakeGenericType(type);
						var mi = genericType.GetMethod("WriteFn",
							BindingFlags.Public | BindingFlags.Static);

						var writeFactoryFn = (Func<WriteObjectDelegate>)Delegate.CreateDelegate(
							typeof(Func<WriteObjectDelegate>), mi);
						writeFn = writeFactoryFn();
						WriteFnCache.Add(type, writeFn);
					}
				}
				return writeFn;
			}
			catch (Exception ex)
			{
				Tracer.Instance.WriteError(ex);
				throw;
			}
		}

		public static string SerializeToCsv<T>(IEnumerable<T> records)
		{
			var sb = new StringBuilder();
			using (var writer = new StringWriter(sb, CultureInfo.InvariantCulture))
			{
				writer.WriteCsv(records);
				return sb.ToString();
			}
		}

		public static string SerializeToString<T>(T value)
		{
			if (value == null) return null;
			if (typeof(T) == typeof(string)) return value as string;

			var sb = new StringBuilder(4096);
			using (var writer = new StringWriter(sb, CultureInfo.InvariantCulture))
			{
				CsvSerializer<T>.WriteObject(writer, value);
			}
			return sb.ToString();
		}

		public static void SerializeToWriter<T>(T value, TextWriter writer)
		{
			if (value == null) return;
			if (typeof(T) == typeof(string))
			{
				writer.Write(value);
				return;
			}
			CsvSerializer<T>.WriteObject(writer, value);
		}

		public static void SerializeToStream<T>(T value, Stream stream)
		{
			if (value == null) return;
			using (var writer = new StreamWriter(stream, UTF8EncodingWithoutBom))
			{
				CsvSerializer<T>.WriteObject(writer, value);
			}
		}

		public static void SerializeToStream(object obj, Stream stream)
		{
			if (obj == null) return;
			using (var writer = new StreamWriter(stream, UTF8EncodingWithoutBom))
			{
				var writeFn = GetWriteFn(obj.GetType());
				writeFn(writer, obj);
			}
		}

		public static T DeserializeFromStream<T>(Stream stream)
		{
			return default(T);
		}

		public static object DeserializeFromStream(Type type, Stream stream)
		{
			return null;
		}

		public static void WriteLateBoundObject(TextWriter writer, object value)
		{
			if (value == null) return;
			var writeFn = GetWriteFn(value.GetType());
			writeFn(writer, value);
		}
	}<commit_msg>throw not implemented exception for CSV serializer.<commit_after>using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Text;
using ServiceStack.Text.Common;
using ServiceStack.Text.Jsv;
using ServiceStack.Text.Reflection;

namespace ServiceStack.Text
{
	public class CsvSerializer
	{
		private static readonly UTF8Encoding UTF8EncodingWithoutBom = new UTF8Encoding(false);

		private static readonly Dictionary<Type, WriteObjectDelegate> WriteFnCache =
			new Dictionary<Type, WriteObjectDelegate>();

		internal static WriteObjectDelegate GetWriteFn(Type type)
		{
			try
			{
				WriteObjectDelegate writeFn;
				lock (WriteFnCache)
				{
					if (!WriteFnCache.TryGetValue(type, out writeFn))
					{
						var genericType = typeof(CsvSerializer<>).MakeGenericType(type);
						var mi = genericType.GetMethod("WriteFn",
							BindingFlags.Public | BindingFlags.Static);

						var writeFactoryFn = (Func<WriteObjectDelegate>)Delegate.CreateDelegate(
							typeof(Func<WriteObjectDelegate>), mi);
						writeFn = writeFactoryFn();
						WriteFnCache.Add(type, writeFn);
					}
				}
				return writeFn;
			}
			catch (Exception ex)
			{
				Tracer.Instance.WriteError(ex);
				throw;
			}
		}

		public static string SerializeToCsv<T>(IEnumerable<T> records)
		{
			var sb = new StringBuilder();
			using (var writer = new StringWriter(sb, CultureInfo.InvariantCulture))
			{
				writer.WriteCsv(records);
				return sb.ToString();
			}
		}

		public static string SerializeToString<T>(T value)
		{
			if (value == null) return null;
			if (typeof(T) == typeof(string)) return value as string;

			var sb = new StringBuilder(4096);
			using (var writer = new StringWriter(sb, CultureInfo.InvariantCulture))
			{
				CsvSerializer<T>.WriteObject(writer, value);
			}
			return sb.ToString();
		}

		public static void SerializeToWriter<T>(T value, TextWriter writer)
		{
			if (value == null) return;
			if (typeof(T) == typeof(string))
			{
				writer.Write(value);
				return;
			}
			CsvSerializer<T>.WriteObject(writer, value);
		}

		public static void SerializeToStream<T>(T value, Stream stream)
		{
			if (value == null) return;
			using (var writer = new StreamWriter(stream, UTF8EncodingWithoutBom))
			{
				CsvSerializer<T>.WriteObject(writer, value);
			}
		}

		public static void SerializeToStream(object obj, Stream stream)
		{
			if (obj == null) return;
			using (var writer = new StreamWriter(stream, UTF8EncodingWithoutBom))
			{
				var writeFn = GetWriteFn(obj.GetType());
				writeFn(writer, obj);
			}
		}

		public static T DeserializeFromStream<T>(Stream stream)
		{
            throw new NotImplementedException();
		}

		public static object DeserializeFromStream(Type type, Stream stream)
		{
            throw new NotImplementedException();
		}

		public static void WriteLateBoundObject(TextWriter writer, object value)
		{
			if (value == null) return;
			var writeFn = GetWriteFn(value.GetType());
			writeFn(writer, value);
		}
	}
{'fraction_non_alphanumeric': 0.10571142284569138, 'fraction_numerical': 0.003006012024048096, 'mean_word_length': 3.7912, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, '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': '6330269', 'n_tokens_mistral': 2219, 'n_tokens_neox': 1790, 'n_words': 442}