<commit_before>using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

namespace Express
{
	public class EntityDeclarationInfo
	{

		/// <summary>
		/// The name of the entity.
		/// </summary>
		/// <returns></returns>
		public string Name {get;set;}
		
		/// <summary>
		/// A list of entities which derive from this.
		/// </summary>
		/// <returns></returns>
		public List<string> SupertypeOf {get;set;}

		/// <summary>
		/// A list of entities from which this derives.
		/// </summary>
		/// <returns></returns>
		public List<string> SubtypeOf {get;set;}
		
		/// <summary>
		/// The entity from which this entity is derived.
		/// EXPRESS supports multiple inheritance. In C#, we
		/// support only one parent.
		/// </summary>
		/// <returns></returns>
		public EntityDeclarationInfo ParentEntity{get;set;}

		/// <summary>
		/// A list of entities which derive from this entity.
		/// </summary>
		/// <returns></returns>
		public List<EntityDeclarationInfo> ChildEntities{get;set;}

		/// <summary>
		/// A list of attributes which define this entity.
		/// </summary>
		/// <returns></returns>
		public List<AttributeDeclaration> Attributes{get;set;}

		/// <summary>
		/// A flag indicating whether this entity can be constructed.
		/// </summary>
		/// <returns></returns>
		public bool IsAbstract{get;set;}

		public EntityDeclarationInfo(string name)
		{
			Name = name;
			Attributes = new List<AttributeDeclaration>();
			SupertypeOf = new List<string>();
			SubtypeOf = new List<string>();
			ChildEntities = new List<EntityDeclarationInfo>();
		}

		public override string ToString()
		{
			var propStringBuilder = new StringBuilder();
			foreach(var a in AttributesForProperties())
			{
				propStringBuilder.AppendLine(a.ToString());
			}

			var supertype = string.Empty;
			var baseConstructor = string.Empty;
			if(SubtypeOf.Any())
			{
				supertype = $" : {string.Join(",",SubtypeOf)}";
				baseConstructor = $" : base({(BaseConstructorParameters())})"; 
			}

			var assignBuilder = new StringBuilder();

			if(Name == "IfcRoot")
			{
				assignBuilder.AppendLine($"\t\t\tGlobalId = new IfcGloballyUniqueId(\"{Guid.NewGuid().ToString()}\");");
			}
			else
			{
				foreach(var a in AttributesForUseInConstructors())
				{
					assignBuilder.AppendLine($"\t\t\t{a.TypeInfo.Name} = {a.TypeInfo.ParameterName};");
				}
				var collAttrs = Attributes.Where(a=>a.TypeInfo is CollectionInfo && a.IsOptional);
				if(collAttrs.Any())
				{
					foreach(var c in collAttrs)
					{
						assignBuilder.AppendLine($"\t\t\t{c.TypeInfo.ToInitializationString()}");
					}
				}
			}
			

			var classStr =
$@"
	/// <summary>
	/// <see href=""http://www.buildingsmart-tech.org/ifc/IFC4/final/html/link/{Name.ToLower()}.htm""/>
	/// </summary>
	public {Modifier()} partial class {Name}{supertype}
	{{
{propStringBuilder.ToString()}
		public {Name}({ConstructorParameters()}){baseConstructor}
		{{
{assignBuilder.ToString()}
		}}
	}}
";
			return classStr;
		}

		private string Modifier()
		{
			return IsAbstract? "abstract" : string.Empty;
		}

		/// <summary><commit_msg>Correctly generated Id. Add ToString override.<commit_after>using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

namespace Express
{
	public class EntityDeclarationInfo
	{

		/// <summary>
		/// The name of the entity.
		/// </summary>
		/// <returns></returns>
		public string Name {get;set;}
		
		/// <summary>
		/// A list of entities which derive from this.
		/// </summary>
		/// <returns></returns>
		public List<string> SupertypeOf {get;set;}

		/// <summary>
		/// A list of entities from which this derives.
		/// </summary>
		/// <returns></returns>
		public List<string> SubtypeOf {get;set;}
		
		/// <summary>
		/// The entity from which this entity is derived.
		/// EXPRESS supports multiple inheritance. In C#, we
		/// support only one parent.
		/// </summary>
		/// <returns></returns>
		public EntityDeclarationInfo ParentEntity{get;set;}

		/// <summary>
		/// A list of entities which derive from this entity.
		/// </summary>
		/// <returns></returns>
		public List<EntityDeclarationInfo> ChildEntities{get;set;}

		/// <summary>
		/// A list of attributes which define this entity.
		/// </summary>
		/// <returns></returns>
		public List<AttributeDeclaration> Attributes{get;set;}

		/// <summary>
		/// A flag indicating whether this entity can be constructed.
		/// </summary>
		/// <returns></returns>
		public bool IsAbstract{get;set;}

		public EntityDeclarationInfo(string name)
		{
			Name = name;
			Attributes = new List<AttributeDeclaration>();
			SupertypeOf = new List<string>();
			SubtypeOf = new List<string>();
			ChildEntities = new List<EntityDeclarationInfo>();
		}

		public override string ToString()
		{
			var propStringBuilder = new StringBuilder();
			foreach(var a in AttributesForProperties())
			{
				propStringBuilder.AppendLine(a.ToString());
			}

			var supertype = string.Empty;
			var baseConstructor = string.Empty;
			if(SubtypeOf.Any())
			{
				supertype = $" : {string.Join(",",SubtypeOf)}";
				baseConstructor = $" : base({(BaseConstructorParameters())})"; 
			}

			var assignBuilder = new StringBuilder();

			if(Name == "IfcRoot")
			{
				assignBuilder.AppendLine($"\t\t\tGlobalId = new IfcGloballyUniqueId(Guid.NewGuid().ToString());");
			}
			else
			{
				foreach(var a in AttributesForUseInConstructors())
				{
					assignBuilder.AppendLine($"\t\t\t{a.TypeInfo.Name} = {a.TypeInfo.ParameterName};");
				}
				var collAttrs = Attributes.Where(a=>a.TypeInfo is CollectionInfo && a.IsOptional);
				if(collAttrs.Any())
				{
					foreach(var c in collAttrs)
					{
						assignBuilder.AppendLine($"\t\t\t{c.TypeInfo.ToInitializationString()}");
					}
				}
			}
			

			var classStr =
$@"
	/// <summary>
	/// <see href=""http://www.buildingsmart-tech.org/ifc/IFC4/final/html/link/{Name.ToLower()}.htm""/>
	/// </summary>
	public {Modifier()} partial class {Name}{supertype}
	{{
{propStringBuilder.ToString()}
		public {Name}({ConstructorParameters()}){baseConstructor}
		{{
{assignBuilder.ToString()}
		}}

		public override string ToString()
		{{
			var settings = new JsonSerializationSettings()
			{{
				Formatting = Formatting.Indented,
				TypeNameHandling = TypeNameHandling.Objects
			}}
			return JsonConvert.SerializeObject(this);
		}}
	}}
";
			return classStr;
		}

		private string Modifier()
		{
			return IsAbstract? "abstract" : string.Empty;
		}

		/// <summary>
{'fraction_non_alphanumeric': 0.16105732288304903, 'fraction_numerical': 0.0003073613032119256, 'mean_word_length': 3.1531589023612, 'pattern_counts': {'":': 0, '<': 83, '<?xml version=': 0, '>': 85, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6260970', 'n_tokens_mistral': 2342, 'n_tokens_neox': 1990, 'n_words': 454}