diff options
author | Raul Santos <raulsntos@gmail.com> | 2023-01-31 18:21:09 +0100 |
---|---|---|
committer | Raul Santos <raulsntos@gmail.com> | 2023-01-31 19:04:07 +0100 |
commit | 7eb832518081f15477150c561d6767fe35d17221 (patch) | |
tree | e13d1d0502d6290571daf441d41e1449e0c5f232 /doc/classes/HashingContext.xml | |
parent | 8612c12be61c0bc50d9039402fe19cabadfe0b16 (diff) |
Fix C# examples in documentation
- Fix documentation after C# renames.
- Add missing `partial` in C# class declarations.
- Change `delta` parameter type to `double` in C#.
- Ensure parameters match base declaration.
- Use `$` string interpolation in C#.
- Fix invalid or outdated C# code.
- Changed some examples to follow our style guide more closely.
Diffstat (limited to 'doc/classes/HashingContext.xml')
-rw-r--r-- | doc/classes/HashingContext.xml | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/doc/classes/HashingContext.xml b/doc/classes/HashingContext.xml index 7c2be6f817..5223cbf52f 100644 --- a/doc/classes/HashingContext.xml +++ b/doc/classes/HashingContext.xml @@ -8,7 +8,7 @@ The [enum HashType] enum shows the supported hashing algorithms. [codeblocks] [gdscript] - const CHUNK_SIZE = 102 + const CHUNK_SIZE = 1024 func hash_file(path): # Check that file exists. @@ -32,17 +32,16 @@ public void HashFile(string path) { - var ctx = new HashingContext(); - var file = new File(); - // Start a SHA-256 context. - ctx.Start(HashingContext.HashType.Sha256); // Check that file exists. - if (!file.FileExists(path)) + if (!FileAccess.FileExists(path)) { return; } + // Start a SHA-256 context. + var ctx = new HashingContext(); + ctx.Start(HashingContext.HashType.Sha256); // Open the file to hash. - file.Open(path, File.ModeFlags.Read); + using var file = FileAccess.Open(path, FileAccess.ModeFlags.Read); // Update the context after reading each chunk. while (!file.EofReached()) { @@ -51,8 +50,7 @@ // Get the computed hash. byte[] res = ctx.Finish(); // Print the result as hex string and array. - - GD.PrintT(res.HexEncode(), res); + GD.PrintT(res.HexEncode(), (Variant)res); } [/csharp] [/codeblocks] |