<commit_before>using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Terraria.ModLoader.IO;

namespace Terraria.ModLoader
{
	internal class BuildProperties
	{
		internal struct ModReference
		{
			public string mod;
			public Version target;

			public ModReference(string mod, Version target)
			{
				this.mod = mod;
				this.target = target;
			}

			public override string ToString() => target == null ? mod : mod + '@' + target;

			public static ModReference Parse(string spec)
			{
				var split = spec.Split('@');
				if (split.Length == 1)
					return new ModReference(split[0], null);

				if (split.Length > 2)
					throw new Exception("Invalid mod reference: " + spec);

				try
				{
					return new ModReference(split[0], new Version(split[1]));
				}
				catch
				{
					throw new Exception("Invalid mod reference: " + spec);
				}
			}
		}

		internal string[] dllReferences = new string[0];
		internal ModReference[] modReferences = new ModReference[0];
		internal ModReference[] weakReferences = new ModReference[0];
		//this mod will load after any mods in this list
		//sortAfter includes (mod|weak)References that are not in sortBefore
		internal string[] sortAfter = new string[0];
		//this mod will load before any mods in this list
		internal string[] sortBefore = new string[0];
		internal string[] buildIgnores = new string[0];
		internal string author = "";
		internal Version version = new Version(1, 0);
		internal string displayName = "";
		internal bool noCompile = false;
		internal bool hideCode = true;
		internal bool hideResources = true;
		internal bool includeSource = false;
		internal bool includePDB = false;
		internal bool editAndContinue = false;
		internal int languageVersion = 4;
		internal string homepage = "";
		internal string description = "";
		internal ModSide side;

		public IEnumerable<ModReference> Refs(bool build) =>
			build ? modReferences.Concat(weakReferences) : modReferences;

		public IEnumerable<string> RefNames(bool build) => Refs(build).Select(dep => dep.mod);

		private static IEnumerable<string> ReadList(string value)
			=> value.Split(',').Select(s => s.Trim()).Where(s => s.Length > 0);

		private static IEnumerable<string> ReadList(BinaryReader reader)
		{
			var list = new List<string>();
			for (string item = reader.ReadString(); item.Length > 0; item = reader.ReadString())
				list.Add(item);

			return list;
		}

		private static void WriteList<T>(IEnumerable<T> list, BinaryWriter writer)
		{
			foreach (var item in list)
				writer.Write(item.ToString());

			writer.Write("");
		}

		internal static BuildProperties ReadBuildFile(string modDir)
		{
			string propertiesFile = modDir + Path.DirectorySeparatorChar + "build.txt";
			string descriptionfile = modDir + Path.DirectorySeparatorChar + "description.txt";
			BuildProperties properties = new BuildProperties();
			if (!File.Exists(propertiesFile))
			{
				return properties;
			}
			if (File.Exists(descriptionfile))
			{
				properties.description = File.ReadAllText(descriptionfile);
			}
			string[] lines = File.ReadAllLines(propertiesFile);
			foreach (string line in lines)
			{
				if (line.Length == 0)
				{
					continue;
				}
				int split = line.IndexOf('=');
				string property = line.Substring(0, split).Trim();
				string value = line.Substring(split + 1).Trim();
				if (value.Length == 0)
				{
					continue;
				}
				switch (property)
				{
					case "dllReferences":
						properties.dllReferences = ReadList(value).ToArray();
						break;
					case "modReferences":
						properties.modReferences = ReadList(value).Select(ModReference.Parse).ToArray();
						break;
					case "weakReferences":
						properties.weakReferences = ReadList(value).Select(ModReference.Parse).ToArray();
						break;
					case "sortBefore":
						properties.sortAfter = ReadList(value).ToArray();
						break;
					case "sortAfter":
						properties.sortBefore = ReadList(value).ToArray();
						break;
					case "author":
						properties.author = value;
						break;
					case "version":
						properties.version = new Version(value);
						break;
					case "displayName":
						properties.displayName = value;
						break;
					case "homepage":
						properties.homepage = value;
						break;
					case "noCompile":
						properties.noCompile = value.ToLower() == "true";
						break;
					case "hideCode":
						properties.hideCode = value.ToLower() != "false";
						break;
					case "hideResources":
						properties.hideResources = value.ToLower() != "false";
						break;
					case "includeSource":
						properties.includeSource = value.ToLower() == "true";
						break;
					case "includePDB":<commit_msg>Default hideCode and hideResources to false.<commit_after>using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Terraria.ModLoader.IO;

namespace Terraria.ModLoader
{
	internal class BuildProperties
	{
		internal struct ModReference
		{
			public string mod;
			public Version target;

			public ModReference(string mod, Version target)
			{
				this.mod = mod;
				this.target = target;
			}

			public override string ToString() => target == null ? mod : mod + '@' + target;

			public static ModReference Parse(string spec)
			{
				var split = spec.Split('@');
				if (split.Length == 1)
					return new ModReference(split[0], null);

				if (split.Length > 2)
					throw new Exception("Invalid mod reference: " + spec);

				try
				{
					return new ModReference(split[0], new Version(split[1]));
				}
				catch
				{
					throw new Exception("Invalid mod reference: " + spec);
				}
			}
		}

		internal string[] dllReferences = new string[0];
		internal ModReference[] modReferences = new ModReference[0];
		internal ModReference[] weakReferences = new ModReference[0];
		//this mod will load after any mods in this list
		//sortAfter includes (mod|weak)References that are not in sortBefore
		internal string[] sortAfter = new string[0];
		//this mod will load before any mods in this list
		internal string[] sortBefore = new string[0];
		internal string[] buildIgnores = new string[0];
		internal string author = "";
		internal Version version = new Version(1, 0);
		internal string displayName = "";
		internal bool noCompile = false;
		internal bool hideCode = false;
		internal bool hideResources = false;
		internal bool includeSource = false;
		internal bool includePDB = false;
		internal bool editAndContinue = false;
		internal int languageVersion = 4;
		internal string homepage = "";
		internal string description = "";
		internal ModSide side;

		public IEnumerable<ModReference> Refs(bool build) =>
			build ? modReferences.Concat(weakReferences) : modReferences;

		public IEnumerable<string> RefNames(bool build) => Refs(build).Select(dep => dep.mod);

		private static IEnumerable<string> ReadList(string value)
			=> value.Split(',').Select(s => s.Trim()).Where(s => s.Length > 0);

		private static IEnumerable<string> ReadList(BinaryReader reader)
		{
			var list = new List<string>();
			for (string item = reader.ReadString(); item.Length > 0; item = reader.ReadString())
				list.Add(item);

			return list;
		}

		private static void WriteList<T>(IEnumerable<T> list, BinaryWriter writer)
		{
			foreach (var item in list)
				writer.Write(item.ToString());

			writer.Write("");
		}

		internal static BuildProperties ReadBuildFile(string modDir)
		{
			string propertiesFile = modDir + Path.DirectorySeparatorChar + "build.txt";
			string descriptionfile = modDir + Path.DirectorySeparatorChar + "description.txt";
			BuildProperties properties = new BuildProperties();
			if (!File.Exists(propertiesFile))
			{
				return properties;
			}
			if (File.Exists(descriptionfile))
			{
				properties.description = File.ReadAllText(descriptionfile);
			}
			string[] lines = File.ReadAllLines(propertiesFile);
			foreach (string line in lines)
			{
				if (line.Length == 0)
				{
					continue;
				}
				int split = line.IndexOf('=');
				string property = line.Substring(0, split).Trim();
				string value = line.Substring(split + 1).Trim();
				if (value.Length == 0)
				{
					continue;
				}
				switch (property)
				{
					case "dllReferences":
						properties.dllReferences = ReadList(value).ToArray();
						break;
					case "modReferences":
						properties.modReferences = ReadList(value).Select(ModReference.Parse).ToArray();
						break;
					case "weakReferences":
						properties.weakReferences = ReadList(value).Select(ModReference.Parse).ToArray();
						break;
					case "sortBefore":
						properties.sortAfter = ReadList(value).ToArray();
						break;
					case "sortAfter":
						properties.sortBefore = ReadList(value).ToArray();
						break;
					case "author":
						properties.author = value;
						break;
					case "version":
						properties.version = new Version(value);
						break;
					case "displayName":
						properties.displayName = value;
						break;
					case "homepage":
						properties.homepage = value;
						break;
					case "noCompile":
						properties.noCompile = value.ToLower() == "true";
						break;
					case "hideCode":
						properties.hideCode = value.ToLower() == "true";
						break;
					case "hideResources":
						properties.hideResources = value.ToLower() == "true";
						break;
					case "includeSource":
						properties.includeSource = value.ToLower() == "true";
						break;
					case "includePDB":
{'fraction_non_alphanumeric': 0.116132422490804, 'fraction_numerical': 0.004203888596952181, 'mean_word_length': 3.3471904979442666, 'pattern_counts': {'":': 28, '<': 17, '<?xml version=': 0, '>': 37, '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': '3311715', 'n_tokens_mistral': 3516, 'n_tokens_neox': 2659, 'n_words': 748}