Add fine-grained disabling of SourceGenerators
This allows manual testing and/or alternate source generators to provide functionality without conflict.
This commit is contained in:
parent
0291fcd7b6
commit
8ab3295e57
9 changed files with 14 additions and 7 deletions
|
@ -26,6 +26,12 @@ namespace Godot.SourceGenerators
|
||||||
toggle != null &&
|
toggle != null &&
|
||||||
toggle.Equals("true", StringComparison.OrdinalIgnoreCase);
|
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)
|
public static bool InheritsFrom(this INamedTypeSymbol? symbol, string assemblyName, string typeFullName)
|
||||||
{
|
{
|
||||||
while (symbol != null)
|
while (symbol != null)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<Project>
|
<Project>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- $(GodotProjectDir) is defined by Godot.NET.Sdk -->
|
<!-- $(GodotProjectDir) is defined by Godot.NET.Sdk -->
|
||||||
|
<CompilerVisibleProperty Include="GodotDisabledSourceGenerators" />
|
||||||
<CompilerVisibleProperty Include="GodotProjectDir" />
|
<CompilerVisibleProperty Include="GodotProjectDir" />
|
||||||
<CompilerVisibleProperty Include="GodotProjectDirBase64" />
|
<CompilerVisibleProperty Include="GodotProjectDirBase64" />
|
||||||
<CompilerVisibleProperty Include="GodotSourceGenerators" />
|
<CompilerVisibleProperty Include="GodotSourceGenerators" />
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace Godot.SourceGenerators
|
||||||
|
|
||||||
public void Execute(GeneratorExecutionContext context)
|
public void Execute(GeneratorExecutionContext context)
|
||||||
{
|
{
|
||||||
if (context.IsGodotToolsProject())
|
if (context.IsGodotToolsProject() || context.IsGodotSourceGeneratorDisabled("GodotPluginsInitializer"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string source =
|
string source =
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace Godot.SourceGenerators
|
||||||
|
|
||||||
public void Execute(GeneratorExecutionContext context)
|
public void Execute(GeneratorExecutionContext context)
|
||||||
{
|
{
|
||||||
if (context.AreGodotSourceGeneratorsDisabled())
|
if (context.IsGodotSourceGeneratorDisabled("ScriptMethods"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
INamedTypeSymbol[] godotClasses = context
|
INamedTypeSymbol[] godotClasses = context
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Godot.SourceGenerators
|
||||||
{
|
{
|
||||||
public void Execute(GeneratorExecutionContext context)
|
public void Execute(GeneratorExecutionContext context)
|
||||||
{
|
{
|
||||||
if (context.AreGodotSourceGeneratorsDisabled())
|
if (context.IsGodotSourceGeneratorDisabled("ScriptPathAttribute"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (context.IsGodotToolsProject())
|
if (context.IsGodotToolsProject())
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace Godot.SourceGenerators
|
||||||
|
|
||||||
public void Execute(GeneratorExecutionContext context)
|
public void Execute(GeneratorExecutionContext context)
|
||||||
{
|
{
|
||||||
if (context.AreGodotSourceGeneratorsDisabled())
|
if (context.IsGodotSourceGeneratorDisabled("ScriptProperties"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
INamedTypeSymbol[] godotClasses = context
|
INamedTypeSymbol[] godotClasses = context
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace Godot.SourceGenerators
|
||||||
|
|
||||||
public void Execute(GeneratorExecutionContext context)
|
public void Execute(GeneratorExecutionContext context)
|
||||||
{
|
{
|
||||||
if (context.AreGodotSourceGeneratorsDisabled())
|
if (context.IsGodotSourceGeneratorDisabled("ScriptPropertyDefVal"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
INamedTypeSymbol[] godotClasses = context
|
INamedTypeSymbol[] godotClasses = context
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace Godot.SourceGenerators
|
||||||
|
|
||||||
public void Execute(GeneratorExecutionContext context)
|
public void Execute(GeneratorExecutionContext context)
|
||||||
{
|
{
|
||||||
if (context.AreGodotSourceGeneratorsDisabled())
|
if (context.IsGodotSourceGeneratorDisabled("ScriptSerialization"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
INamedTypeSymbol[] godotClasses = context
|
INamedTypeSymbol[] godotClasses = context
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace Godot.SourceGenerators
|
||||||
|
|
||||||
public void Execute(GeneratorExecutionContext context)
|
public void Execute(GeneratorExecutionContext context)
|
||||||
{
|
{
|
||||||
if (context.AreGodotSourceGeneratorsDisabled())
|
if (context.IsGodotSourceGeneratorDisabled("ScriptSignals"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
INamedTypeSymbol[] godotClasses = context
|
INamedTypeSymbol[] godotClasses = context
|
||||||
|
|
Loading…
Reference in a new issue