Skip to content

Commit

Permalink
Allow conditional inclusion of the AddServices extension methods
Browse files Browse the repository at this point in the history
  • Loading branch information
kzu committed Nov 20, 2024
1 parent 265bf07 commit 9cf6472
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/DependencyInjection/AddServicesNoReflectionExtension.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
// <auto-generated />
#if DDI_ADDSERVICES
using System;
using System.ComponentModel;
using Microsoft.Extensions.DependencyInjection;

Expand Down Expand Up @@ -122,4 +124,5 @@ public static IServiceCollection AddServices(this IServiceCollection services)
[AttributeUsage(AttributeTargets.Method)]
class DDIAddServicesAttribute : Attribute { }
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<DevloopedExtensionsDependencyInjectionVersion>42.42.42</DevloopedExtensionsDependencyInjectionVersion>
<AddServiceAttribute Condition="'$(AddServiceAttribute)' == ''">true</AddServiceAttribute>
<AddServicesExtension Condition="'$(AddServicesExtension)' == ''">true</AddServicesExtension>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
<!-- Backwards compatiblity -->
<AddServiceAttribute Condition="'$(IncludeServiceAttribute)' != ''">$(IncludeServiceAttribute)</AddServiceAttribute>
<DefineConstants Condition="'$(Language)' == 'C#' and '$(AddServiceAttribute)' == 'true'">$(DefineConstants);DDI_ADDSERVICE</DefineConstants>
<DefineConstants Condition="'$(Language)' == 'C#' and '$(AddServicesExtension)' == 'true'">$(DefineConstants);DDI_ADDSERVICES</DefineConstants>
</PropertyGroup>

<Target Name="_AddDDI_Constant" BeforeTargets="CoreCompile">
<PropertyGroup>
<DefineConstants Condition="'$(Language)' == 'C#' and '$(AddServiceAttribute)' == 'true' and !$(DefineConstants.Contains('DDI_ADDSERVICE'))">$(DefineConstants);DDI_ADDSERVICE</DefineConstants>
<DefineConstants Condition="'$(Language)' == 'C#' and '$(AddServicesExtension)' == 'true' and !$(DefineConstants.Contains('DDI_ADDSERVICES'))">$(DefineConstants);DDI_ADDSERVICES</DefineConstants>
</PropertyGroup>
</Target>

Expand Down

0 comments on commit 9cf6472

Please sign in to comment.