| 1 | using System.Diagnostics.CodeAnalysis; |
| 2 | |
| 3 | namespace GodotTools.IdeMessaging |
| 4 | { |
| 5 | public readonly struct GodotIdeMetadata |
| 6 | { |
| 7 | public int Port { get; } |
| 8 | public string EditorExecutablePath { get; } |
| 9 | |
| 10 | public const string DefaultFileName = "ide_messaging_meta.txt"; |
| 11 | |
| 12 | public GodotIdeMetadata(int port, string editorExecutablePath) |
| 13 | { |
| 14 | Port = port; |
| 15 | EditorExecutablePath = editorExecutablePath; |
| 16 | } |
| 17 | |
| 18 | public static bool operator ==(GodotIdeMetadata a, GodotIdeMetadata b) |
| 19 | { |
| 20 | return a.Port == b.Port && a.EditorExecutablePath == b.EditorExecutablePath; |
| 21 | } |
| 22 | |
| 23 | public static bool operator !=(GodotIdeMetadata a, GodotIdeMetadata b) |
| 24 | { |
| 25 | return !(a == b); |
| 26 | } |
| 27 | |
| 28 | public override bool Equals([NotNullWhen(true)] object? obj) |
| 29 | { |
| 30 | return obj is GodotIdeMetadata metadata && metadata == this; |
| 31 | } |
| 32 | |
| 33 | public bool Equals(GodotIdeMetadata other) |
| 34 | { |
| 35 | return Port == other.Port && EditorExecutablePath == other.EditorExecutablePath; |
| 36 | } |
| 37 | |
| 38 | public override int GetHashCode() |
| 39 | { |
| 40 | unchecked |
| 41 | { |
| 42 | return (Port * 397) ^ (EditorExecutablePath != null ? EditorExecutablePath.GetHashCode() : 0); |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | } |