Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DependencyInjection.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
<Project Path="src/CodeAnalysis.Tests/CodeAnalysis.Tests.csproj" />
<Project Path="src/DependencyInjection.Tests/DependencyInjection.Tests.csproj" />
<Project Path="src/DependencyInjection/DependencyInjection.csproj" />
<Project Path="src/NoAddServices/NoAddServices.csproj" />
</Solution>
6 changes: 1 addition & 5 deletions src/CodeAnalysis.Tests/AddServicesAnalyzerTests.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Collections.Immutable;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Devlooped.Extensions.DependencyInjection;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Testing;
using Microsoft.CodeAnalysis.Testing;
using Xunit;
Expand Down
3 changes: 3 additions & 0 deletions src/DependencyInjection/IncrementalGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@ void ReportInconsistencies(SourceProductionContext context, ImmutableArray<Servi

void AddPartial(string methodName, SourceProductionContext ctx, (ImmutableArray<KeyedService> Types, Compilation Compilation) data)
{
if (data.Types.IsEmpty)
return;

var builder = new StringBuilder()
.AppendLine("// <auto-generated />");

Expand Down
22 changes: 22 additions & 0 deletions src/NoAddServices/NoAddServices.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="..\DependencyInjection\Devlooped.Extensions.DependencyInjection.props" />

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<!-- This property causes no AddXXX partial methods to be emitted -->
<AddServicesExtension>false</AddServicesExtension>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\DependencyInjection\DependencyInjection.csproj" ReferenceOutputAssembly="false" OutputItemType="Analyzer" />
</ItemGroup>

<Import Project="..\DependencyInjection\Devlooped.Extensions.DependencyInjection.targets" />

</Project>