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:
parent
70ceba2910
commit
a0da258401
19 changed files with 26 additions and 104 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue