Skip to content

Commit f829dd3

Browse files
committed
Only emit the ChatClientExtensions if package is referenced
Otherwise, InternalsVisibleTo from a core package to another can cause ambiguous matches.
1 parent d7c5021 commit f829dd3

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/AI.CodeAnalysis/ChatClientExtensionsGenerator.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,16 @@ public class ChatClientExtensionsGenerator : IIncrementalGenerator
1616
{
1717
public void Initialize(IncrementalGeneratorInitializationContext context)
1818
{
19-
context.RegisterSourceOutput(context.CompilationProvider,
20-
(spc, _) =>
19+
var provider = context.AnalyzerConfigOptionsProvider
20+
.Select((options, _) => options.GlobalOptions.TryGetValue("build_property.HasDevloopedExtensionsAI", out var hasExtensions) ? !string.IsNullOrEmpty(hasExtensions) : false)
21+
.Combine(context.CompilationProvider);
22+
23+
context.RegisterSourceOutput(provider,
24+
(spc, source) =>
2125
{
26+
if (!source.Left)
27+
return;
28+
2229
spc.AddSource(
2330
$"Devlooped.{nameof(ThisAssembly.Resources.ChatClientExtensions)}.g.cs",
2431
SourceText.From(ThisAssembly.Resources.ChatClientExtensions.Text, Encoding.UTF8));

src/AI/Devlooped.Extensions.AI.props

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
<Project>
22

3+
<PropertyGroup>
4+
<HasDevloopedExtensionsAI>true</HasDevloopedExtensionsAI>
5+
</PropertyGroup>
6+
37
<ItemGroup>
48
<Compile Update="@(Compile -> WithMetadataValue('NuGetPackageId', 'Devlooped.Extensions.AI'))" Visible="false" />
9+
<CompilerVisibleProperty Include="HasDevloopedExtensionsAI" />
510
</ItemGroup>
611

712
<ItemGroup>

0 commit comments

Comments
 (0)