Skip to content

Commit

Permalink
Ignore design-time build value when debugging generator
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kzu authored and ReubenBond committed Aug 20, 2024
1 parent 5c70668 commit 60aedf2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Orleans.CodeGenerator/Orleans.CodeGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<DevelopmentDependency>true</DevelopmentDependency>
<IsOrleansFrameworkPart>false</IsOrleansFrameworkPart>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<IsRoslynComponent>true</IsRoslynComponent>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/Orleans.CodeGenerator/OrleansSourceGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions src/Orleans.CodeGenerator/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"profiles": {
"Roslyn": {
"commandName": "DebugRoslynComponent",
"targetProject": "..\\..\\test\\Orleans.Serialization.UnitTests\\Orleans.Serialization.UnitTests.csproj"
}
}
}

0 comments on commit 60aedf2

Please sign in to comment.