<commit_before>﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.IO;

namespace WebAssembly
{
	static class ModuleExtensions
	{
		private sealed class ForwardReadOnlyStream : Stream
		{
			private readonly byte[] data;
			private int position;

			public ForwardReadOnlyStream(byte[] data)
			{
				this.data = data;
			}

			public override bool CanRead => true;

			public override bool CanSeek => false;

			public override bool CanWrite => false;

			public override long Length => throw new NotSupportedException();

			public override long Position { get => throw new NotSupportedException(); set => throw new NotSupportedException(); }

			public override void Flush() => throw new NotSupportedException();

			public override int Read(byte[] buffer, int offset, int count)
			{
				count = Math.Min(count, this.data.Length - this.position);
				if (count == 0)
					return 0;

				Array.Copy(this.data, this.position, buffer, offset, count);<commit_msg>Added new extension method required by data mutability test added in the last commit (missed during staging).<commit_after>﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.IO;

namespace WebAssembly
{
	static class ModuleExtensions
	{
		public static Module BinaryRoundTrip(this Module module)
		{
			Assert.IsNotNull(module);

			using (var memory = new MemoryStream())
			{
				module.WriteToBinary(memory);
				Assert.AreNotEqual(0, memory.Position);

				memory.Position = 0;
				var result = Module.ReadFromBinary(memory);
				Assert.IsNotNull(result);
				return result;
			}
		}

		private sealed class ForwardReadOnlyStream : Stream
		{
			private readonly byte[] data;
			private int position;

			public ForwardReadOnlyStream(byte[] data)
			{
				this.data = data;
			}

			public override bool CanRead => true;

			public override bool CanSeek => false;

			public override bool CanWrite => false;

			public override long Length => throw new NotSupportedException();

			public override long Position { get => throw new NotSupportedException(); set => throw new NotSupportedException(); }

			public override void Flush() => throw new NotSupportedException();

			public override int Read(byte[] buffer, int offset, int count)
			{
				count = Math.Min(count, this.data.Length - this.position);
				if (count == 0)
					return 0;

				Array.Copy(this.data, this.position, buffer, offset, count);
{'fraction_non_alphanumeric': 0.09327461969575661, 'fraction_numerical': 0.0024019215372297837, 'mean_word_length': 3.9192913385826773, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '6422405', 'n_tokens_mistral': 803, 'n_tokens_neox': 655, 'n_words': 226}