From c99f67105fb7e4ffb44d3a3b5857f30acd1e4ba7 Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Thu, 1 Jun 2023 19:38:20 +0200 Subject: [PATCH] C#: Fix dictionary key lookup documentation The method to check if a key exists in the dictionary is called `ContainsKey`. (cherry picked from commit 6723b4e8c37966924784036e89507f3e64db248e) --- doc/classes/Control.xml | 4 ++-- doc/classes/Dictionary.xml | 6 +++--- doc/classes/EditorImportPlugin.xml | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml index cefdd13bca8..95a766c5376 100644 --- a/doc/classes/Control.xml +++ b/doc/classes/Control.xml @@ -41,7 +41,7 @@ { // Check position if it is relevant to you // Otherwise, just check data - return data.VariantType == Variant.Type.Dictionary && data.AsGodotDictionary().Contains("expected"); + return data.VariantType == Variant.Type.Dictionary && data.AsGodotDictionary().ContainsKey("expected"); } [/csharp] [/codeblocks] @@ -64,7 +64,7 @@ [csharp] public override bool _CanDropData(Vector2 atPosition, Variant data) { - return data.VariantType == Variant.Type.Dictionary && dict.AsGodotDictionary().Contains("color"); + return data.VariantType == Variant.Type.Dictionary && dict.AsGodotDictionary().ContainsKey("color"); } public override void _DropData(Vector2 atPosition, Variant data) diff --git a/doc/classes/Dictionary.xml b/doc/classes/Dictionary.xml index d41e3653c61..e0bb85b892d 100644 --- a/doc/classes/Dictionary.xml +++ b/doc/classes/Dictionary.xml @@ -217,9 +217,9 @@ { 210, default }, }; - GD.Print(myDict.Contains("Godot")); // Prints true - GD.Print(myDict.Contains(210)); // Prints true - GD.Print(myDict.Contains(4)); // Prints false + GD.Print(myDict.ContainsKey("Godot")); // Prints true + GD.Print(myDict.ContainsKey(210)); // Prints true + GD.Print(myDict.ContainsKey(4)); // Prints false [/csharp] [/codeblocks] In GDScript, this is equivalent to the [code]in[/code] operator: diff --git a/doc/classes/EditorImportPlugin.xml b/doc/classes/EditorImportPlugin.xml index 66b61f187e2..15cb18a5995 100644 --- a/doc/classes/EditorImportPlugin.xml +++ b/doc/classes/EditorImportPlugin.xml @@ -93,7 +93,7 @@ new Godot.Collections.Dictionary { { "name", "myOption" }, - { "defaultValue", false }, + { "default_value", false }, } }; } @@ -157,12 +157,12 @@ return true [/gdscript] [csharp] - public void GetOptionVisibility(string option, Godot.Collections.Dictionary options) + public void _GetOptionVisibility(string option, Godot.Collections.Dictionary options) { // Only show the lossy quality setting if the compression mode is set to "Lossy". - if (option == "compress/lossyQuality" && options.Contains("compress/mode")) + if (option == "compress/lossy_quality" && options.ContainsKey("compress/mode")) { - return (int)options["compress/mode"] == COMPRESS_LOSSY; // This is a constant you set + return (int)options["compress/mode"] == CompressLossy; // This is a constant you set } return true;