mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
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:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user