summaryrefslogtreecommitdiffstats
path: root/modules/mono/editor
diff options
context:
space:
mode:
Diffstat (limited to 'modules/mono/editor')
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs26
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSignalsGenerator.cs2
2 files changed, 27 insertions, 1 deletions
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs
index 957d5789df..62fa7b0a36 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs
@@ -155,6 +155,32 @@ namespace Godot.SourceGenerators
};
}
+ public static string GetAccessibilityKeyword(this INamedTypeSymbol namedTypeSymbol)
+ {
+ if (namedTypeSymbol.DeclaredAccessibility == Accessibility.NotApplicable)
+ {
+ // Accessibility not specified. Get the default accessibility.
+ return namedTypeSymbol.ContainingSymbol switch
+ {
+ null or INamespaceSymbol => "internal",
+ ITypeSymbol { TypeKind: TypeKind.Class or TypeKind.Struct } => "private",
+ ITypeSymbol { TypeKind: TypeKind.Interface } => "public",
+ _ => "",
+ };
+ }
+
+ return namedTypeSymbol.DeclaredAccessibility switch
+ {
+ Accessibility.Private => "private",
+ Accessibility.Protected => "protected",
+ Accessibility.Internal => "internal",
+ Accessibility.ProtectedAndInternal => "private",
+ Accessibility.ProtectedOrInternal => "private",
+ Accessibility.Public => "public",
+ _ => "",
+ };
+ }
+
public static string NameWithTypeParameters(this INamedTypeSymbol symbol)
{
return symbol.IsGenericType ?
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSignalsGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSignalsGenerator.cs
index 54f2212339..23253524ab 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSignalsGenerator.cs
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSignalsGenerator.cs
@@ -276,7 +276,7 @@ namespace Godot.SourceGenerators
source.Append(
$" /// <inheritdoc cref=\"{signalDelegate.DelegateSymbol.FullQualifiedNameIncludeGlobal()}\"/>\n");
- source.Append(" public event ")
+ source.Append($" {signalDelegate.DelegateSymbol.GetAccessibilityKeyword()} event ")
.Append(signalDelegate.DelegateSymbol.FullQualifiedNameIncludeGlobal())
.Append(" @")
.Append(signalName)