using System; namespace Ariadne.Generator { /// /// Describes what an arc class gets written as plain data, which an incremental generator step can compare between /// runs. /// public sealed class ArcOutput : IEquatable { /// /// Holds the path of the script file the class's code-behind is written beside, or null if nothing is written /// for the class. /// public readonly string FilePath; public readonly string TypeName; /// /// Holds where the class is declared, which orders the classes of a file and places errors about the file. /// public readonly SourcePlace TypePlace; /// /// Holds the using directives the script file needs the code-behind to repeat. /// public readonly EquatableArray FileUsings; /// /// Holds the class as the code-behind writes it, or null if nothing is written for it. /// public readonly string ClassText; /// /// Holds what is wrong with the class itself, which is reported whether or not its file is written. /// public readonly EquatableArray ClassProblems; /// /// Holds what is wrong with the script's code, which is only reported if its file is written. /// public readonly EquatableArray ScriptProblems; public ArcOutput(string filePath, string typeName, SourcePlace typePlace, EquatableArray fileUsings, string classText, EquatableArray classProblems, EquatableArray scriptProblems) { FilePath = filePath; TypeName = typeName; TypePlace = typePlace; FileUsings = fileUsings; ClassText = classText; ClassProblems = classProblems; ScriptProblems = scriptProblems; } public bool Equals(ArcOutput other) { return other != null && FilePath == other.FilePath && TypeName == other.TypeName && TypePlace.Equals(other.TypePlace) && FileUsings.Equals(other.FileUsings) && ClassText == other.ClassText && ClassProblems.Equals(other.ClassProblems) && ScriptProblems.Equals(other.ScriptProblems); } public override bool Equals(object obj) { return Equals(obj as ArcOutput); } public override int GetHashCode() { int returnMe = TypeName.GetHashCode(); if (ClassText != null) { returnMe = returnMe * 31 + ClassText.GetHashCode(); } return returnMe; } } }