Skip to content

Commit e5d641f

Browse files
committed
Fix ReflectionCacheGenerator choking on dummy projects
1 parent fda159a commit e5d641f

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

Common.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<AnalysisModeReliability>Recommended</AnalysisModeReliability>
77
<AnalysisModePerformance>Recommended</AnalysisModePerformance>
88
<AnalysisModeUsage>Recommended</AnalysisModeUsage>
9-
<EmitCompilerGeneratedFiles>false</EmitCompilerGeneratedFiles> <!-- enable to copy Roslyn Source Gemerators' outputs to $(ProjectDir)/obj/.../generated -->
9+
<EmitCompilerGeneratedFiles>false</EmitCompilerGeneratedFiles> <!-- enable to copy Roslyn Source Generators' outputs to $(ProjectDir)/obj/.../generated -->
1010
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
1111
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
1212
<ContinuousIntegrationBuild Condition=" '$(GITLAB_CI)' != '' Or '$(APPVEYOR)' != '' ">true</ContinuousIntegrationBuild>

ExternalProjects/BizHawk.SrcGen.ReflectionCache/ReflectionCacheGenerator.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ private sealed class NamespaceInferrer
2727

2828
private string CalcNamespace()
2929
{
30+
if (_namespaces.Count is 0) return string.Empty; // this can happen if the Analyzer is applied to a project with no source files
3031
// black magic wizardry to find common prefix https://stackoverflow.com/a/35081977
3132
var ns = new string(_namespaces[0]
3233
.Substring(0, _namespaces.Min(s => s.Length))
@@ -63,6 +64,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
6364

6465
public void Execute(SourceProductionContext context, string nSpace)
6566
{
67+
if (string.IsNullOrWhiteSpace(nSpace)) return; // see note in `CalcNamespace`
6668
var src = $@"#nullable enable
6769
6870
using System;
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)