diff options
author | Raul Santos <raulsntos@gmail.com> | 2022-08-24 14:15:33 +0200 |
---|---|---|
committer | Raul Santos <raulsntos@gmail.com> | 2022-08-24 14:15:33 +0200 |
commit | a0da258401c665d773b5247945c17472fca42b43 (patch) | |
tree | ea20c7a0689945c280b059870d45d526bbfa1e46 /modules/mono/editor/GodotTools | |
parent | 70ceba291017e32fb34545aa2caedddaa12e1512 (diff) |
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`
Diffstat (limited to 'modules/mono/editor/GodotTools')
-rw-r--r-- | modules/mono/editor/GodotTools/GodotTools.IdeMessaging/GodotIdeMetadata.cs | 5 | ||||
-rw-r--r-- | modules/mono/editor/GodotTools/GodotTools/Build/BuildInfo.cs | 16 |
2 files changed, 8 insertions, 13 deletions
diff --git a/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/GodotIdeMetadata.cs b/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/GodotIdeMetadata.cs index 686202e81e..2448a2953b 100644 --- a/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/GodotIdeMetadata.cs +++ b/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/GodotIdeMetadata.cs @@ -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) diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/BuildInfo.cs b/modules/mono/editor/GodotTools/GodotTools/Build/BuildInfo.cs index 3c5b897719..edbf53a389 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/BuildInfo.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/BuildInfo.cs @@ -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() |