Use pattern matching to simplify Equals

- Simplify and unify `Equals` implementation of C# struct types
- Also add pattern matching to replace a cast in `DebuggingUtils`
This commit is contained in:
Raul Santos 2022-08-24 14:15:33 +02:00
parent 70ceba2910
commit a0da258401
No known key found for this signature in database
GPG key ID: B532473AE3A803E4
19 changed files with 26 additions and 104 deletions

View file

@ -25,10 +25,7 @@ namespace GodotTools.IdeMessaging
public override bool Equals(object obj)
{
if (obj is GodotIdeMetadata metadata)
return metadata == this;
return false;
return obj is GodotIdeMetadata metadata && metadata == this;
}
public bool Equals(GodotIdeMetadata other)

View file

@ -27,15 +27,13 @@ namespace GodotTools.Build
public override bool Equals(object? obj)
{
if (obj is BuildInfo other)
return other.Solution == Solution &&
other.Configuration == Configuration && other.RuntimeIdentifier == RuntimeIdentifier &&
other.PublishOutputDir == PublishOutputDir && other.Restore == Restore &&
other.Rebuild == Rebuild && other.OnlyClean == OnlyClean &&
other.CustomProperties == CustomProperties &&
other.LogsDirPath == LogsDirPath;
return false;
return obj is BuildInfo other &&
other.Solution == Solution &&
other.Configuration == Configuration && other.RuntimeIdentifier == RuntimeIdentifier &&
other.PublishOutputDir == PublishOutputDir && other.Restore == Restore &&
other.Rebuild == Rebuild && other.OnlyClean == OnlyClean &&
other.CustomProperties == CustomProperties &&
other.LogsDirPath == LogsDirPath;
}
public override int GetHashCode()