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
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,15 @@ private bool EmitBindImplForMember(
}
case ComplexTypeSpec complexType:
{
// Early detection of types we cannot bind to and skip it.
if (!_typeIndex.HasBindableMembers(complexType) &&
!_typeIndex.GetEffectiveTypeSpec(complexType).IsValueType &&
complexType is not CollectionSpec &&
((ObjectSpec)complexType).InstantiationStrategy == ObjectInstantiationStrategy.ParameterizedConstructor)
{
return false;
}

string sectionValidationCall = $"{MethodsToGen_CoreBindingHelper.AsConfigWithChildren}({sectionParseExpr})";
string sectionIdentifier = GetIncrementalIdentifier(Identifier.section);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,39 @@ async Task Test(bool expectOutput)
}
}

/// <summary>
/// We binding the type "SslClientAuthenticationOptions" which has a property "CipherSuitesPolicy" of type "CipherSuitesPolicy". We can't bind this type.
/// This test is to ensure not including the property "CipherSuitesPolicy" in the generated code caused a build break.
/// </summary>
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNetCore))]
public async Task IgnoredUnBindablePropertiesTest()
{
string source = """
using System;
using System.Net.Security;
using Microsoft.Extensions.Configuration;
using System.Collections.Immutable;
using System.Text;
using System.Text.Json;

public class Program
{
public static void Main()
{
ConfigurationBuilder configurationBuilder = new();
IConfiguration config = configurationBuilder.Build();

var obj = config.Get<SslClientAuthenticationOptions>();
}
}
""";

ConfigBindingGenRunResult result = await RunGeneratorAndUpdateCompilation(source, assemblyReferences: GetAssemblyRefsWithAdditional(typeof(ImmutableArray<>), typeof(Encoding), typeof(JsonSerializer), typeof(System.Net.Security.AuthenticatedStream)));
Assert.NotNull(result.GeneratedSource);

Assert.DoesNotContain("CipherSuitesPolicy = ", result.GeneratedSource.Value.SourceText.ToString());
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNetCore))]
[ActiveIssue("Work out why we aren't getting all the expected diagnostics.")]
public async Task IssueDiagnosticsForAllOffendingCallsites()
Expand Down