Skip to content

Commit cc315a8

Browse files
committed
Enable interceptors feature when ConfigurationBindingGenerator is enabled
1 parent 15459e2 commit cc315a8

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToUseAnalyzers.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,28 @@ public void It_resolves_requestdelegategenerator_correctly(string testAssetName,
3131
VerifyInterceptorsFeatureEnabled(asset, isEnabled);
3232
}
3333

34+
[Theory]
35+
[InlineData("WebApp", false)]
36+
[InlineData("WebApp", true)]
37+
[InlineData("WebApp", null)]
38+
public void It_resolves_configbindinggenerator_correctly(string testAssetName, bool? isEnabled)
39+
{
40+
var asset = _testAssetsManager
41+
.CopyTestAsset(testAssetName, identifier: isEnabled.ToString())
42+
.WithSource()
43+
.WithProjectChanges(project =>
44+
{
45+
if (isEnabled != null)
46+
{
47+
var ns = project.Root.Name.Namespace;
48+
project.Root.Add(new XElement(ns + "PropertyGroup", new XElement("EnableConfigurationBindingGenerator", isEnabled)));
49+
}
50+
});
51+
52+
VerifyConfigBindingGeneratorIsUsed(asset, isEnabled);
53+
VerifyInterceptorsFeatureEnabled(asset, isEnabled);
54+
}
55+
3456
[Fact]
3557
public void It_enables_requestdelegategenerator_and_configbindinggenerator_for_PublishAot()
3658
{

src/WebSdk/ProjectSystem/Targets/Microsoft.NET.Sdk.Web.ProjectSystem.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ Copyright (c) .NET Foundation. All rights reserved.
5959
<EnableConfigurationBindingGenerator Condition="'$(EnableConfigurationBindingGenerator)' == ''">true</EnableConfigurationBindingGenerator>
6060
</PropertyGroup>
6161

62-
<!-- Enable the interceptors compiler feature by default for projects that use the RequestDelegateGenerator. -->
63-
<PropertyGroup Condition="'$(EnableRequestDelegateGenerator)' == 'true'">
62+
<!-- Enable the interceptors compiler feature by default for projects that use the RequestDelegateGenerator or the ConfigurationBindingGenerator. -->
63+
<PropertyGroup Condition="'$(EnableRequestDelegateGenerator)' == 'true' Or '$(EnableConfigurationBindingGenerator)' == 'true'">
6464
<Features>$(Features);InterceptorsPreview</Features>
6565
</PropertyGroup>
6666

0 commit comments

Comments
 (0)