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 f0c9043fd5c..7f627f0dc43 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs @@ -26,6 +26,12 @@ namespace Godot.SourceGenerators toggle != null && toggle.Equals("true", StringComparison.OrdinalIgnoreCase); + public static bool IsGodotSourceGeneratorDisabled(this GeneratorExecutionContext context, string generatorName) => + AreGodotSourceGeneratorsDisabled(context) || + (context.TryGetGlobalAnalyzerProperty("GodotDisabledSourceGenerators", out string? disabledGenerators) && + disabledGenerators != null && + disabledGenerators.Split(';').Contains(generatorName)); + public static bool InheritsFrom(this INamedTypeSymbol? symbol, string assemblyName, string typeFullName) { while (symbol != null) diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Godot.SourceGenerators.props b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Godot.SourceGenerators.props index 2a8ae7f9583..56c51159d08 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Godot.SourceGenerators.props +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Godot.SourceGenerators.props @@ -1,6 +1,7 @@ + diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotPluginsInitializerGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotPluginsInitializerGenerator.cs index 47a45169488..467313dc28d 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotPluginsInitializerGenerator.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotPluginsInitializerGenerator.cs @@ -13,7 +13,7 @@ namespace Godot.SourceGenerators public void Execute(GeneratorExecutionContext context) { - if (context.IsGodotToolsProject()) + if (context.IsGodotToolsProject() || context.IsGodotSourceGeneratorDisabled("GodotPluginsInitializer")) return; string source = diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptMethodsGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptMethodsGenerator.cs index f79909589ef..8b75530380c 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptMethodsGenerator.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptMethodsGenerator.cs @@ -16,7 +16,7 @@ namespace Godot.SourceGenerators public void Execute(GeneratorExecutionContext context) { - if (context.AreGodotSourceGeneratorsDisabled()) + if (context.IsGodotSourceGeneratorDisabled("ScriptMethods")) return; INamedTypeSymbol[] godotClasses = context diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPathAttributeGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPathAttributeGenerator.cs index d14e3c3781c..01aafe9c740 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPathAttributeGenerator.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPathAttributeGenerator.cs @@ -14,7 +14,7 @@ namespace Godot.SourceGenerators { public void Execute(GeneratorExecutionContext context) { - if (context.AreGodotSourceGeneratorsDisabled()) + if (context.IsGodotSourceGeneratorDisabled("ScriptPathAttribute")) return; if (context.IsGodotToolsProject()) diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs index d333c244512..ef8e6f8fff4 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs @@ -16,7 +16,7 @@ namespace Godot.SourceGenerators public void Execute(GeneratorExecutionContext context) { - if (context.AreGodotSourceGeneratorsDisabled()) + if (context.IsGodotSourceGeneratorDisabled("ScriptProperties")) return; INamedTypeSymbol[] godotClasses = context diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertyDefValGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertyDefValGenerator.cs index 089ee3f196c..ac908a6de3b 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertyDefValGenerator.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertyDefValGenerator.cs @@ -17,7 +17,7 @@ namespace Godot.SourceGenerators public void Execute(GeneratorExecutionContext context) { - if (context.AreGodotSourceGeneratorsDisabled()) + if (context.IsGodotSourceGeneratorDisabled("ScriptPropertyDefVal")) return; INamedTypeSymbol[] godotClasses = context diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSerializationGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSerializationGenerator.cs index d8c6f3a1964..97771b721da 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSerializationGenerator.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSerializationGenerator.cs @@ -16,7 +16,7 @@ namespace Godot.SourceGenerators public void Execute(GeneratorExecutionContext context) { - if (context.AreGodotSourceGeneratorsDisabled()) + if (context.IsGodotSourceGeneratorDisabled("ScriptSerialization")) return; INamedTypeSymbol[] godotClasses = context 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 d67cb5349de..f40322bd899 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSignalsGenerator.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSignalsGenerator.cs @@ -23,7 +23,7 @@ namespace Godot.SourceGenerators public void Execute(GeneratorExecutionContext context) { - if (context.AreGodotSourceGeneratorsDisabled()) + if (context.IsGodotSourceGeneratorDisabled("ScriptSignals")) return; INamedTypeSymbol[] godotClasses = context