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.
This commit is contained in:
Raul Santos 2023-01-31 18:21:09 +01:00
parent 8612c12be6
commit 7eb8325180
No known key found for this signature in database
GPG key ID: B532473AE3A803E4
35 changed files with 295 additions and 278 deletions

View file

@ -26,25 +26,24 @@
[/gdscript]
[csharp]
using Godot;
using System;
using System.Diagnostics;
public class CryptoNode : Node
public partial class MyNode : Node
{
private HMACContext ctx = new HMACContext();
private HmacContext _ctx = new HmacContext();
public override void _Ready()
{
byte[] key = "supersecret".ToUTF8();
Error err = ctx.Start(HashingContext.HashType.Sha256, key);
byte[] key = "supersecret".ToUtf8();
Error err = _ctx.Start(HashingContext.HashType.Sha256, key);
Debug.Assert(err == Error.Ok);
byte[] msg1 = "this is ".ToUTF8();
byte[] msg2 = "super duper secret".ToUTF8();
err = ctx.Update(msg1);
byte[] msg1 = "this is ".ToUtf8();
byte[] msg2 = "super duper secret".ToUtf8();
err = _ctx.Update(msg1);
Debug.Assert(err == Error.Ok);
err = ctx.Update(msg2);
err = _ctx.Update(msg2);
Debug.Assert(err == Error.Ok);
byte[] hmac = ctx.Finish();
byte[] hmac = _ctx.Finish();
GD.Print(hmac.HexEncode());
}
}