<commit_before>using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace Harmony
{
	// A test for https://github.com/dotnet/coreclr/blob/master/Documentation/botr/clr-abi.md
	//
	internal class NativeThisPointer
	{
		internal static bool NeedsNativeThisPointerFix(MethodBase method)
		{
			if (method.IsStatic) return false;
			var returnType = AccessTools.GetReturnedType(method);
			if (AccessTools.IsStruct(returnType) == false) return false;
			var size = Marshal.SizeOf(returnType);
			if (size != 3 && size != 5 && size != 6 && size != 7 && size < 9) return false;
			return HasNativeThis();
		}

		static IntPtr magicValue = (IntPtr)0xabadbabe;
		static bool hasTestResult, hasNativeThis;
		static bool HasNativeThis()
		{
			if (hasTestResult == false)
			{
				hasNativeThis = false;
				var self = new NativeThisPointer();
				var original = AccessTools.DeclaredMethod(typeof(NativeThisPointer), "GetStruct");
				var replacement = AccessTools.DeclaredMethod(typeof(NativeThisPointer), "GetStructReplacement");
				Memory.DetourMethod(original, replacement);
				new NativeThisPointer().GetStruct(magicValue, magicValue);
				hasTestResult = true;
			}
			return hasNativeThis;
		}

		struct SomeStruct
		{
#pragma warning disable CS0169
			readonly byte b1;
			readonly byte b2;<commit_msg>Duh, must use value below 0x1FFFFFFF<commit_after>using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace Harmony
{
	// A test for https://github.com/dotnet/coreclr/blob/master/Documentation/botr/clr-abi.md
	//
	internal class NativeThisPointer
	{
		internal static bool NeedsNativeThisPointerFix(MethodBase method)
		{
			if (method.IsStatic) return false;
			var returnType = AccessTools.GetReturnedType(method);
			if (AccessTools.IsStruct(returnType) == false) return false;
			var size = Marshal.SizeOf(returnType);
			if (size != 3 && size != 5 && size != 6 && size != 7 && size < 9) return false;
			return HasNativeThis();
		}

		static IntPtr magicValue = (IntPtr)0x12345678;
		static bool hasTestResult, hasNativeThis;
		static bool HasNativeThis()
		{
			if (hasTestResult == false)
			{
				hasNativeThis = false;
				var self = new NativeThisPointer();
				var original = AccessTools.DeclaredMethod(typeof(NativeThisPointer), "GetStruct");
				var replacement = AccessTools.DeclaredMethod(typeof(NativeThisPointer), "GetStructReplacement");
				Memory.DetourMethod(original, replacement);
				new NativeThisPointer().GetStruct(magicValue, magicValue);
				hasTestResult = true;
			}
			return hasNativeThis;
		}

		struct SomeStruct
		{
#pragma warning disable CS0169
			readonly byte b1;
			readonly byte b2;
{'fraction_non_alphanumeric': 0.10242490047050308, 'fraction_numerical': 0.012305465074194716, 'mean_word_length': 4.462450592885376, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, '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': '7047237', 'n_tokens_mistral': 961, 'n_tokens_neox': 817, 'n_words': 206}