<commit_before>﻿using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using FreecraftCore.Serializer;

namespace FreecraftCore
{
	public static class ITypeSerializerStrategyExtensions
	{
		/// <summary>
		/// Reads a copy of <typeparamref name="T"/> from the buffer <paramref name="buffer"/>
		/// starting from <paramref name="offset"/>
		/// Specialized extension that won't move the offset forward.
		/// </summary>
		/// <param name="serializer"></param>
		/// <param name="buffer">The source buffer to read from.</param>
		/// <param name="offset">The starting offset into the buffer to read from.</param>
		/// <returns></returns>
		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static T Read<T>(this ITypeSerializerStrategy<T> serializer, Span<byte> buffer, int offset)
		{
			return serializer.Read(buffer, ref offset);
		}

		/// <summary>
		/// Writes a copy of <typeparamref name="T"/> <paramref name="value"/> starting at <paramref name="offset"/>
		/// into the buffer <paramref name="buffer"/>.
		/// Specialized extension that won't move the offset forward.
		/// </summary>
		/// <param name="serializer"></param>
		/// <param name="value">The value to write.</param>
		/// <param name="buffer">The destination buffer to write the value into.</param>
		/// <param name="offset">The offset to start writing the value into.</param>
		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static void Write<T>(this ITypeSerializerStrategy<T> serializer, T value, Span<byte> buffer, int offset)
		{
			serializer.Write(value, buffer, ref offset);<commit_msg>Fixed Read/Write serializer extensions<commit_after>﻿using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using FreecraftCore.Serializer;

namespace FreecraftCore
{
	public static class ITypeSerializerStrategyExtensions
	{
		/// <summary>
		/// Reads a copy of <typeparamref name="T"/> from the buffer <paramref name="buffer"/>
		/// starting from <paramref name="offset"/>
		/// Specialized extension that won't move the offset forward.
		/// </summary>
		/// <param name="serializer"></param>
		/// <param name="buffer">The source buffer to read from.</param>
		/// <param name="offset">The starting offset into the buffer to read from.</param>
		/// <returns></returns>
		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static T Read<T>(this ITypeSerializerReadingStrategy<T> serializer, Span<byte> buffer, int offset)
		{
			return serializer.Read(buffer, ref offset);
		}

		/// <summary>
		/// Writes a copy of <typeparamref name="T"/> <paramref name="value"/> starting at <paramref name="offset"/>
		/// into the buffer <paramref name="buffer"/>.
		/// Specialized extension that won't move the offset forward.
		/// </summary>
		/// <param name="serializer"></param>
		/// <param name="value">The value to write.</param>
		/// <param name="buffer">The destination buffer to write the value into.</param>
		/// <param name="offset">The offset to start writing the value into.</param>
		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static void Write<T>(this ITypeSerializerWritingStrategy<T> serializer, T value, Span<byte> buffer, int offset)
		{
			serializer.Write(value, buffer, ref offset);
{'fraction_non_alphanumeric': 0.14414685525127896, 'fraction_numerical': 0.0, 'mean_word_length': 4.218210361067504, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 69, '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': '7153219', 'n_tokens_mistral': 995, 'n_tokens_neox': 920, 'n_words': 292}