From 85271865a947003c603179d881358108f705c9dd Mon Sep 17 00:00:00 2001 From: Daniel Cazzulino Date: Tue, 6 Aug 2024 15:27:45 -0300 Subject: [PATCH] Ignore design-time build value when debugging generator This allows running F5 on the generator project and troubleshoot issues. By checking for an already attached debugger, we can debug also scenarios of code generation where the roslyn component starts it with DTB=true. --- src/Orleans.CodeGenerator/Orleans.CodeGenerator.csproj | 1 + src/Orleans.CodeGenerator/OrleansSourceGenerator.cs | 3 ++- src/Orleans.CodeGenerator/Properties/launchSettings.json | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 src/Orleans.CodeGenerator/Properties/launchSettings.json diff --git a/src/Orleans.CodeGenerator/Orleans.CodeGenerator.csproj b/src/Orleans.CodeGenerator/Orleans.CodeGenerator.csproj index af653ca935e..c05d097cd98 100644 --- a/src/Orleans.CodeGenerator/Orleans.CodeGenerator.csproj +++ b/src/Orleans.CodeGenerator/Orleans.CodeGenerator.csproj @@ -10,6 +10,7 @@ true false true + true diff --git a/src/Orleans.CodeGenerator/OrleansSourceGenerator.cs b/src/Orleans.CodeGenerator/OrleansSourceGenerator.cs index b23ba45ba4d..992e75573df 100644 --- a/src/Orleans.CodeGenerator/OrleansSourceGenerator.cs +++ b/src/Orleans.CodeGenerator/OrleansSourceGenerator.cs @@ -23,7 +23,8 @@ public void Execute(GeneratorExecutionContext context) return; } - if (context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.orleans_designtimebuild", out var isDesignTimeBuild) + if (!Debugger.IsAttached && + context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.orleans_designtimebuild", out var isDesignTimeBuild) && string.Equals("true", isDesignTimeBuild, StringComparison.OrdinalIgnoreCase)) { return; diff --git a/src/Orleans.CodeGenerator/Properties/launchSettings.json b/src/Orleans.CodeGenerator/Properties/launchSettings.json new file mode 100644 index 00000000000..3b0cf0fa237 --- /dev/null +++ b/src/Orleans.CodeGenerator/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Roslyn": { + "commandName": "DebugRoslynComponent", + "targetProject": "..\\..\\test\\Orleans.Serialization.UnitTests\\Orleans.Serialization.UnitTests.csproj" + } + } +} \ No newline at end of file