<commit_before>using Uno;
using Uno.Compiler.ExportTargetInterop;
using Uno.Platform;
using Uno.Collections;

namespace Experimental.TextureLoader
{
	public class InvalidContentTypeException : Exception
	{
		public InvalidContentTypeException(string reason) : base(reason) { }
	}

	public static class TextureLoader
	{
		[Obsolete("Use the byte[] overload instead")]
		public static void JpegByteArrayToTexture2D(Buffer arr, Uno.Action<texture2D> callback)
		{
			JpegByteArrayToTexture2D(arr.GetBytes(), callback);
		}

		public static void JpegByteArrayToTexture2D(byte[] arr, Uno.Action<texture2D> callback)
		{
			try
			{
				callback(TextureLoaderImpl.JpegByteArrayToTexture2D(arr));
			}
			catch (Exception jpegException)
			{
				try
				{
					callback(TextureLoaderImpl.PngByteArrayToTexture2D(arr));
				}
				catch (Exception pngException)
				{
					// both threw, but since the user asked for JPEG, answer with the JPEG-error
					throw jpegException;
				}
			}
		}

		[Obsolete("Use the byte[] overload instead")]
		public static void PngByteArrayToTexture2D(Buffer arr, Uno.Action<texture2D> callback)
		{
			PngByteArrayToTexture2D(arr.GetBytes(), callback);
		}

		public static void PngByteArrayToTexture2D(byte[] arr, Uno.Action<texture2D> callback)
		{
			try
			{
				callback(TextureLoaderImpl.PngByteArrayToTexture2D(arr));
			}
			catch (Exception pngException)
			{
				try
				{
					callback(TextureLoaderImpl.JpegByteArrayToTexture2D(arr));
				}
				catch (Exception jpegException)
				{
					// both threw, but since the user asked for PNG, answer with the PNG-error
					throw pngException;
				}
			}
		}

		[Obsolete("Use the byte[] overload instead")]
		public static void ByteArrayToTexture2DFilename(Buffer arr, string filename, Uno.Action<texture2D> callback)
		{
			ByteArrayToTexture2DFilename(arr.GetBytes(), filename, callback);
		}

		public static void ByteArrayToTexture2DFilename(byte[] arr, string filename, Uno.Action<texture2D> callback)
		{
			filename = filename.ToLower();
			if (filename.EndsWith(".png"))
				PngByteArrayToTexture2D(arr, callback);
			else if (filename.EndsWith(".jpg") || filename.EndsWith(".jpeg"))
				JpegByteArrayToTexture2D(arr, callback);
			else
				throw new InvalidContentTypeException(filename);
		}

		[Obsolete("Use the byte[] overload instead")]
		public static void ByteArrayToTexture2DContentType(Buffer arr, string filename, Uno.Action<texture2D> callback)
		{
			ByteArrayToTexture2DFilename(arr.GetBytes(), filename, callback);
		}

		public static void ByteArrayToTexture2DContentType(byte[] arr, string contentType, Uno.Action<texture2D> callback)
		{
			if (contentType.IndexOf("image/jpeg") != -1 || contentType.IndexOf("image/jpg") != -1)
				JpegByteArrayToTexture2D(arr, callback);
			else if (contentType.IndexOf("image/png") != -1)
				PngByteArrayToTexture2D(arr, callback);
			else if (contentType.IndexOf("application/octet-stream") != -1)
				JpegByteArrayToTexture2D(arr, callback);
			else if (contentType.IndexOf("binary/octet-stream") != -1)
				JpegByteArrayToTexture2D(arr, callback);
			else
				throw new InvalidContentTypeException(contentType);
		}
	}
}<commit_msg>Experimental.TextureLoader: add returning overloads in TextureLoader<commit_after>using Uno;
using Uno.Compiler.ExportTargetInterop;
using Uno.Platform;
using Uno.Collections;

namespace Experimental.TextureLoader
{
	public class InvalidContentTypeException : Exception
	{
		public InvalidContentTypeException(string reason) : base(reason) { }
	}

	public static class TextureLoader
	{
		[Obsolete("Use the byte[] overload instead")]
		public static void JpegByteArrayToTexture2D(Buffer arr, Uno.Action<texture2D> callback)
		{
			JpegByteArrayToTexture2D(arr.GetBytes(), callback);
		}

		[Obsolete("Use the returning overload instead")]
		public static void JpegByteArrayToTexture2D(byte[] arr, Uno.Action<texture2D> callback)
		{
			callback(JpegByteArrayToTexture2D(arr));
		}

		public static texture2D JpegByteArrayToTexture2D(byte[] arr)
		{
			try
			{
				return TextureLoaderImpl.JpegByteArrayToTexture2D(arr);
			}
			catch (Exception jpegException)
			{
				try
				{
					return TextureLoaderImpl.PngByteArrayToTexture2D(arr);
				}
				catch (Exception pngException)
				{
					// both threw, but since the user asked for JPEG, answer with the JPEG-error
					throw jpegException;
				}
			}
		}

		[Obsolete("Use the byte[] overload instead")]
		public static void PngByteArrayToTexture2D(Buffer arr, Uno.Action<texture2D> callback)
		{
			PngByteArrayToTexture2D(arr.GetBytes(), callback);
		}

		[Obsolete("Use the returning overload instead")]
		public static void PngByteArrayToTexture2D(byte[] arr, Uno.Action<texture2D> callback)
		{
			callback(PngByteArrayToTexture2D(arr));
		}

		public static texture2D PngByteArrayToTexture2D(byte[] arr)
		{
			try
			{
				return TextureLoaderImpl.PngByteArrayToTexture2D(arr);
			}
			catch (Exception pngException)
			{
				try
				{
					return TextureLoaderImpl.JpegByteArrayToTexture2D(arr);
				}
				catch (Exception jpegException)
				{
					// both threw, but since the user asked for PNG, answer with the PNG-error
					throw pngException;
				}
			}
		}

		[Obsolete("Use the byte[] overload instead")]
		public static void ByteArrayToTexture2DFilename(Buffer arr, string filename, Uno.Action<texture2D> callback)
		{
			ByteArrayToTexture2DFilename(arr.GetBytes(), filename, callback);
		}

		[Obsolete("Use the returning overload instead")]
		public static void ByteArrayToTexture2DFilename(byte[] arr, string filename, Uno.Action<texture2D> callback)
		{
			callback(ByteArrayToTexture2DFilename(arr, filename));
		}

		public static texture2D ByteArrayToTexture2DFilename(byte[] arr, string filename)
		{
			filename = filename.ToLower();
			if (filename.EndsWith(".png"))
				return PngByteArrayToTexture2D(arr);
			else if (filename.EndsWith(".jpg") || filename.EndsWith(".jpeg"))
				return JpegByteArrayToTexture2D(arr);
			else
				throw new InvalidContentTypeException(filename);
		}

		[Obsolete("Use the byte[] overload instead")]
		public static void ByteArrayToTexture2DContentType(Buffer arr, string filename, Uno.Action<texture2D> callback)
		{
			ByteArrayToTexture2DFilename(arr.GetBytes(), filename, callback);
		}

		[Obsolete("Use the returning overload instead")]
		public static void ByteArrayToTexture2DContentType(byte[] arr, string contentType, Uno.Action<texture2D> callback)
		{
			callback(ByteArrayToTexture2DContentType(arr, contentType));
		}

		public static texture2D ByteArrayToTexture2DContentType(byte[] arr, string contentType)
		{
			if (contentType.IndexOf("image/jpeg") != -1 || contentType.IndexOf("image/jpg") != -1)
				return JpegByteArrayToTexture2D(arr);
			else if (contentType.IndexOf("image/png") != -1)
				return PngByteArrayToTexture2D(arr);
			else if (contentType.IndexOf("application/octet-stream") != -1)
				return JpegByteArrayToTexture2D(arr);
			else if (contentType.IndexOf("binary/octet-stream") != -1)
				return JpegByteArrayToTexture2D(arr);
			else
				throw new InvalidContentTypeException(contentType);
		}
	}
}
{'fraction_non_alphanumeric': 0.10374316556848451, 'fraction_numerical': 0.01149586429272396, 'mean_word_length': 4.595294117647059, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '4549487', 'n_tokens_mistral': 2618, 'n_tokens_neox': 2211, 'n_words': 481}