<commit_before>﻿// dnlib: See LICENSE.txt for more info

using System;
using System.Diagnostics;
using System.Reflection;

namespace dnlib.PE {
	static class ProcessorArchUtils {
		static Machine cachedMachine = 0;

		public static Machine GetProcessCpuArchitecture() {
			if (cachedMachine == 0)
				cachedMachine = GetProcessCpuArchitectureCore();
			return cachedMachine;
		}

		static class RuntimeInformationUtils {
#if NETSTANDARD2_0
			public static bool TryGet_RuntimeInformation_Architecture(out Machine machine) =>
				TryGetArchitecture((int)System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture, out machine);
#else
			// .NET Framework 4.7.1: mscorlib
			// .NET Core: System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=<KEY>
			static Assembly RuntimeInformationAssembly =>
				Assembly.Load("System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=<KEY>") ??
				typeof(object).Assembly;
			static Type System_Runtime_InteropServices_RuntimeInformation => RuntimeInformationAssembly.GetType("System.Runtime.InteropServices.RuntimeInformation", throwOnError: false);

			public static bool TryGet_RuntimeInformation_Architecture(out Machine machine) {
				machine = 0;
				var processArchitectureMethod = System_Runtime_InteropServices_RuntimeInformation?.GetMethod("get_ProcessArchitecture", Array2.Empty<Type>());
				if ((object)processArchitectureMethod == null)
					return false;

				var result = processArchitectureMethod.Invoke(null, Array2.Empty<object>());
				return TryGetArchitecture((int)result, out machine);<commit_msg>Don't use assembly load, fixes #188<commit_after>﻿// dnlib: See LICENSE.txt for more info

using System;
using System.Diagnostics;
using System.Reflection;

namespace dnlib.PE {
	static class ProcessorArchUtils {
		static Machine cachedMachine = 0;

		public static Machine GetProcessCpuArchitecture() {
			if (cachedMachine == 0)
				cachedMachine = GetProcessCpuArchitectureCore();
			return cachedMachine;
		}

		static class RuntimeInformationUtils {
#if NETSTANDARD2_0
			public static bool TryGet_RuntimeInformation_Architecture(out Machine machine) =>
				TryGetArchitecture((int)System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture, out machine);
#else
			// .NET Framework 4.7.1: mscorlib
			static Assembly RuntimeInformationAssembly => typeof(object).Assembly;
			static Type System_Runtime_InteropServices_RuntimeInformation => RuntimeInformationAssembly.GetType("System.Runtime.InteropServices.RuntimeInformation", throwOnError: false);

			public static bool TryGet_RuntimeInformation_Architecture(out Machine machine) {
				machine = 0;
				var processArchitectureMethod = System_Runtime_InteropServices_RuntimeInformation?.GetMethod("get_ProcessArchitecture", Array2.Empty<Type>());
				if ((object)processArchitectureMethod == null)
					return false;

				var result = processArchitectureMethod.Invoke(null, Array2.Empty<object>());
				return TryGetArchitecture((int)result, out machine);
{'fraction_non_alphanumeric': 0.08887447291599092, 'fraction_numerical': 0.010055141096334739, 'mean_word_length': 6.05720823798627, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '7363948', 'n_tokens_mistral': 951, 'n_tokens_neox': 811, 'n_words': 188}