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
35 changed files with 295 additions and 278 deletions

View File

@@ -27,27 +27,25 @@
[/gdscript]
[csharp]
using Godot;
using System;
[Tool]
public class CustomParser : EditorTranslationParserPlugin
public partial class CustomParser : EditorTranslationParserPlugin
{
public override void ParseFile(string path, Godot.Collections.Array msgids, Godot.Collections.Array msgidsContextPlural)
public override void _ParseFile(string path, Godot.Collections.Array<string> msgids, Godot.Collections.Array<Godot.Collections.Array> msgidsContextPlural)
{
var file = new File();
file.Open(path, File.ModeFlags.Read);
using var file = FileAccess.Open(path, FileAccess.ModeFlags.Read);
string text = file.GetAsText();
string[] splitStrs = text.Split(",", false);
foreach (var s in splitStrs)
string[] splitStrs = text.Split(",", allowEmpty: false);
foreach (string s in splitStrs)
{
msgids.Add(s);
//GD.Print("Extracted string: " + s)
//GD.Print($"Extracted string: {s}");
}
}
public override Godot.Collections.Array GetRecognizedExtensions()
public override string[] _GetRecognizedExtensions()
{
return new Godot.Collections.Array{"csv"};
return new string[] { "csv" };
}
}
[/csharp]
@@ -84,16 +82,16 @@
return ["gd"]
[/gdscript]
[csharp]
public override void ParseFile(string path, Godot.Collections.Array msgids, Godot.Collections.Array msgidsContextPlural)
public override void _ParseFile(string path, Godot.Collections.Array<string> msgids, Godot.Collections.Array<Godot.Collections.Array> msgidsContextPlural)
{
var res = ResourceLoader.Load<Script>(path, "Script");
string text = res.SourceCode;
// Parsing logic.
}
public override Godot.Collections.Array GetRecognizedExtensions()
public override string[] _GetRecognizedExtensions()
{
return new Godot.Collections.Array{"gd"};
return new string[] { "gd" };
}
[/csharp]
[/codeblocks]