Fix binder gen nullability issue wrt binding ref type members (#89900)
authorLayomi Akinrinade <laakinri@microsoft.com>
Thu, 3 Aug 2023 13:03:49 +0000 (06:03 -0700)
committerGitHub <noreply@github.com>
Thu, 3 Aug 2023 13:03:49 +0000 (06:03 -0700)
18 files changed:
src/libraries/Microsoft.Extensions.Configuration.Binder/gen/ConfigurationBindingGenerator.Emitter.cs
src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Helpers/Emitter/CoreBindingHelper.cs
src/libraries/Microsoft.Extensions.Configuration.Binder/tests/Common/ConfigurationBinderTests.TestClasses.cs
src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/Collections.generated.txt
src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/ConfigurationBinder/Bind.generated.txt
src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/ConfigurationBinder/Bind_Instance.generated.txt
src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/ConfigurationBinder/Bind_Instance_BinderOptions.generated.txt
src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/ConfigurationBinder/Bind_Key_Instance.generated.txt
src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/ConfigurationBinder/Get.generated.txt
src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/ConfigurationBinder/Get_T.generated.txt
src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/ConfigurationBinder/Get_T_BinderOptions.generated.txt
src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/OptionsBuilder/BindConfiguration.generated.txt
src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/OptionsBuilder/Bind_T.generated.txt
src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/OptionsBuilder/Bind_T_BinderOptions.generated.txt
src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/ServiceCollection/Configure_T.generated.txt
src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/ServiceCollection/Configure_T_BinderOptions.generated.txt
src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/ServiceCollection/Configure_T_name.generated.txt
src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/ServiceCollection/Configure_T_name_BinderOptions.generated.txt

index 6363149..a40cf29 100644 (file)
@@ -73,7 +73,8 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
                 string tempIdentifier = GetIncrementalIdentifier(Identifier.temp);
                 if (initKind is InitializationKind.AssignmentWithNullCheck)
                 {
-                    _writer.WriteLine($"{type.MinimalDisplayString} {tempIdentifier} = {memberAccessExpr};");
+                    Debug.Assert(!type.IsValueType);
+                    _writer.WriteLine($"{type.MinimalDisplayString}? {tempIdentifier} = {memberAccessExpr};");
                     EmitBindCoreCall(tempIdentifier, InitializationKind.AssignmentWithNullCheck);
                 }
                 else if (initKind is InitializationKind.None && type.IsValueType)
index 3d38f83..a7b42b1 100644 (file)
@@ -837,14 +837,14 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
                 EmitStartBlock($"if ({sectionValidationCall} is {Identifier.IConfigurationSection} {sectionIdentifier})");
 
-                bool success = !EmitInitException(effectiveMemberType);
-                if (success)
+                bool canInit = !EmitInitException(effectiveMemberType);
+                if (canInit)
                 {
                     EmitBindCoreCallForMember(member, memberAccessExpr, sectionIdentifier, canSet);
                 }
 
                 EmitEndBlock();
-                return success;
+                return canInit;
             }
 
             private void EmitBindCoreCallForMember(
@@ -856,8 +856,6 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
                 TypeSpec memberType = member.Type;
                 TypeSpec effectiveMemberType = memberType.EffectiveType;
-                string effectiveMemberTypeDisplayString = effectiveMemberType.MinimalDisplayString;
-                bool canGet = member.CanGet;
 
                 string tempIdentifier = GetIncrementalIdentifier(Identifier.temp);
                 InitializationKind initKind;
@@ -871,6 +869,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
                     }
 
                     Debug.Assert(canSet);
+                    string effectiveMemberTypeDisplayString = effectiveMemberType.MinimalDisplayString;
                     initKind = InitializationKind.None;
 
                     if (memberType.SpecKind is TypeSpecKind.Nullable)
@@ -889,7 +888,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
                     targetObjAccessExpr = tempIdentifier;
                 }
-                else if (canGet)
+                else if (member.CanGet)
                 {
                     targetObjAccessExpr = memberAccessExpr;
                     initKind = InitializationKind.AssignmentWithNullCheck;
index 6258ed3..1e537b4 100644 (file)
@@ -605,7 +605,7 @@ namespace Microsoft.Extensions
         {
             public string Namespace { get; set; }
 
-            public Dictionary<string, QueueProperties> Queues { get; set; } = new();
+            public Dictionary<string, QueueProperties>? Queues { get; set; } = new();
         }
 
         public class QueueProperties
index 1e593a4..2149dca 100644 (file)
@@ -198,7 +198,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("CustomDictionary")) is IConfigurationSection section1)
             {
-                Program.CustomDictionary<string, int> temp3 = obj.CustomDictionary;
+                Program.CustomDictionary<string, int>? temp3 = obj.CustomDictionary;
                 temp3 ??= new Program.CustomDictionary<string, int>();
                 BindCore(section1, ref temp3, binderOptions);
                 obj.CustomDictionary = temp3;
@@ -206,7 +206,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("CustomList")) is IConfigurationSection section4)
             {
-                Program.CustomList temp6 = obj.CustomList;
+                Program.CustomList? temp6 = obj.CustomList;
                 temp6 ??= new Program.CustomList();
                 BindCore(section4, ref temp6, binderOptions);
                 obj.CustomList = temp6;
@@ -214,7 +214,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("IReadOnlyList")) is IConfigurationSection section7)
             {
-                IReadOnlyList<int> temp9 = obj.IReadOnlyList;
+                IReadOnlyList<int>? temp9 = obj.IReadOnlyList;
                 temp9 = temp9 is null ? new List<int>() : new List<int>(temp9);
                 BindCore(section7, ref temp9, binderOptions);
                 obj.IReadOnlyList = temp9;
@@ -222,7 +222,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("IReadOnlyDictionary")) is IConfigurationSection section10)
             {
-                IReadOnlyDictionary<string, int> temp12 = obj.IReadOnlyDictionary;
+                IReadOnlyDictionary<string, int>? temp12 = obj.IReadOnlyDictionary;
                 temp12 = temp12 is null ? new Dictionary<string, int>() : temp12.ToDictionary(pair => pair.Key, pair => pair.Value);
                 BindCore(section10, ref temp12, binderOptions);
                 obj.IReadOnlyDictionary = temp12;
index e5d1e51..406e8db 100644 (file)
@@ -97,7 +97,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section2)
             {
-                List<int> temp4 = obj.MyList;
+                List<int>? temp4 = obj.MyList;
                 temp4 ??= new List<int>();
                 BindCore(section2, ref temp4, binderOptions);
                 obj.MyList = temp4;
@@ -105,7 +105,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section5)
             {
-                Dictionary<string, string> temp7 = obj.MyDictionary;
+                Dictionary<string, string>? temp7 = obj.MyDictionary;
                 temp7 ??= new Dictionary<string, string>();
                 BindCore(section5, ref temp7, binderOptions);
                 obj.MyDictionary = temp7;
@@ -113,7 +113,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyComplexDictionary")) is IConfigurationSection section8)
             {
-                Dictionary<string, Program.MyClass2> temp10 = obj.MyComplexDictionary;
+                Dictionary<string, Program.MyClass2>? temp10 = obj.MyComplexDictionary;
                 temp10 ??= new Dictionary<string, Program.MyClass2>();
                 BindCore(section8, ref temp10, binderOptions);
                 obj.MyComplexDictionary = temp10;
index 31354af..106e017 100644 (file)
@@ -91,7 +91,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section2)
             {
-                List<int> temp4 = obj.MyList;
+                List<int>? temp4 = obj.MyList;
                 temp4 ??= new List<int>();
                 BindCore(section2, ref temp4, binderOptions);
                 obj.MyList = temp4;
@@ -99,7 +99,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section5)
             {
-                Dictionary<string, string> temp7 = obj.MyDictionary;
+                Dictionary<string, string>? temp7 = obj.MyDictionary;
                 temp7 ??= new Dictionary<string, string>();
                 BindCore(section5, ref temp7, binderOptions);
                 obj.MyDictionary = temp7;
@@ -107,7 +107,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyComplexDictionary")) is IConfigurationSection section8)
             {
-                Dictionary<string, Program.MyClass2> temp10 = obj.MyComplexDictionary;
+                Dictionary<string, Program.MyClass2>? temp10 = obj.MyComplexDictionary;
                 temp10 ??= new Dictionary<string, Program.MyClass2>();
                 BindCore(section8, ref temp10, binderOptions);
                 obj.MyComplexDictionary = temp10;
index 653ac97..a1cb7d6 100644 (file)
@@ -91,7 +91,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section2)
             {
-                List<int> temp4 = obj.MyList;
+                List<int>? temp4 = obj.MyList;
                 temp4 ??= new List<int>();
                 BindCore(section2, ref temp4, binderOptions);
                 obj.MyList = temp4;
@@ -99,7 +99,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section5)
             {
-                Dictionary<string, string> temp7 = obj.MyDictionary;
+                Dictionary<string, string>? temp7 = obj.MyDictionary;
                 temp7 ??= new Dictionary<string, string>();
                 BindCore(section5, ref temp7, binderOptions);
                 obj.MyDictionary = temp7;
@@ -107,7 +107,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyComplexDictionary")) is IConfigurationSection section8)
             {
-                Dictionary<string, Program.MyClass2> temp10 = obj.MyComplexDictionary;
+                Dictionary<string, Program.MyClass2>? temp10 = obj.MyComplexDictionary;
                 temp10 ??= new Dictionary<string, Program.MyClass2>();
                 BindCore(section8, ref temp10, binderOptions);
                 obj.MyComplexDictionary = temp10;
index 575822f..f3ee8a9 100644 (file)
@@ -91,7 +91,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section2)
             {
-                List<int> temp4 = obj.MyList;
+                List<int>? temp4 = obj.MyList;
                 temp4 ??= new List<int>();
                 BindCore(section2, ref temp4, binderOptions);
                 obj.MyList = temp4;
@@ -99,7 +99,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section5)
             {
-                Dictionary<string, string> temp7 = obj.MyDictionary;
+                Dictionary<string, string>? temp7 = obj.MyDictionary;
                 temp7 ??= new Dictionary<string, string>();
                 BindCore(section5, ref temp7, binderOptions);
                 obj.MyDictionary = temp7;
@@ -107,7 +107,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyComplexDictionary")) is IConfigurationSection section8)
             {
-                Dictionary<string, Program.MyClass2> temp10 = obj.MyComplexDictionary;
+                Dictionary<string, Program.MyClass2>? temp10 = obj.MyComplexDictionary;
                 temp10 ??= new Dictionary<string, Program.MyClass2>();
                 BindCore(section8, ref temp10, binderOptions);
                 obj.MyComplexDictionary = temp10;
index 9be69f1..fb71c70 100644 (file)
@@ -129,7 +129,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section6)
             {
-                List<int> temp8 = obj.MyList;
+                List<int>? temp8 = obj.MyList;
                 temp8 ??= new List<int>();
                 BindCore(section6, ref temp8, binderOptions);
                 obj.MyList = temp8;
@@ -137,7 +137,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyArray")) is IConfigurationSection section9)
             {
-                int[] temp11 = obj.MyArray;
+                int[]? temp11 = obj.MyArray;
                 temp11 ??= new int[0];
                 BindCore(section9, ref temp11, binderOptions);
                 obj.MyArray = temp11;
@@ -145,7 +145,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section12)
             {
-                Dictionary<string, string> temp14 = obj.MyDictionary;
+                Dictionary<string, string>? temp14 = obj.MyDictionary;
                 temp14 ??= new Dictionary<string, string>();
                 BindCore(section12, ref temp14, binderOptions);
                 obj.MyDictionary = temp14;
index 8840001..de8201f 100644 (file)
@@ -112,7 +112,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section5)
             {
-                List<int> temp7 = obj.MyList;
+                List<int>? temp7 = obj.MyList;
                 temp7 ??= new List<int>();
                 BindCore(section5, ref temp7, binderOptions);
                 obj.MyList = temp7;
@@ -120,7 +120,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyArray")) is IConfigurationSection section8)
             {
-                int[] temp10 = obj.MyArray;
+                int[]? temp10 = obj.MyArray;
                 temp10 ??= new int[0];
                 BindCore(section8, ref temp10, binderOptions);
                 obj.MyArray = temp10;
@@ -128,7 +128,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section11)
             {
-                Dictionary<string, string> temp13 = obj.MyDictionary;
+                Dictionary<string, string>? temp13 = obj.MyDictionary;
                 temp13 ??= new Dictionary<string, string>();
                 BindCore(section11, ref temp13, binderOptions);
                 obj.MyDictionary = temp13;
index aea24cb..34fadac 100644 (file)
@@ -112,7 +112,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section5)
             {
-                List<int> temp7 = obj.MyList;
+                List<int>? temp7 = obj.MyList;
                 temp7 ??= new List<int>();
                 BindCore(section5, ref temp7, binderOptions);
                 obj.MyList = temp7;
@@ -120,7 +120,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyArray")) is IConfigurationSection section8)
             {
-                int[] temp10 = obj.MyArray;
+                int[]? temp10 = obj.MyArray;
                 temp10 ??= new int[0];
                 BindCore(section8, ref temp10, binderOptions);
                 obj.MyArray = temp10;
@@ -128,7 +128,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section11)
             {
-                Dictionary<string, string> temp13 = obj.MyDictionary;
+                Dictionary<string, string>? temp13 = obj.MyDictionary;
                 temp13 ??= new Dictionary<string, string>();
                 BindCore(section11, ref temp13, binderOptions);
                 obj.MyDictionary = temp13;
index 6500dc0..a74dbfd 100644 (file)
@@ -103,7 +103,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section3)
             {
-                List<int> temp5 = obj.MyList;
+                List<int>? temp5 = obj.MyList;
                 temp5 ??= new List<int>();
                 BindCore(section3, ref temp5, binderOptions);
                 obj.MyList = temp5;
index 7d5271b..ac53b58 100644 (file)
@@ -121,7 +121,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section3)
             {
-                List<int> temp5 = obj.MyList;
+                List<int>? temp5 = obj.MyList;
                 temp5 ??= new List<int>();
                 BindCore(section3, ref temp5, binderOptions);
                 obj.MyList = temp5;
index 315c9e3..fd3ec70 100644 (file)
@@ -115,7 +115,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section3)
             {
-                List<int> temp5 = obj.MyList;
+                List<int>? temp5 = obj.MyList;
                 temp5 ??= new List<int>();
                 BindCore(section3, ref temp5, binderOptions);
                 obj.MyList = temp5;
index 13e9646..461f605 100644 (file)
@@ -150,7 +150,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section5)
             {
-                List<int> temp7 = obj.MyList;
+                List<int>? temp7 = obj.MyList;
                 temp7 ??= new List<int>();
                 BindCore(section5, ref temp7, binderOptions);
                 obj.MyList = temp7;
@@ -158,7 +158,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyList2")) is IConfigurationSection section8)
             {
-                List<Program.MyClass2> temp10 = obj.MyList2;
+                List<Program.MyClass2>? temp10 = obj.MyList2;
                 temp10 ??= new List<Program.MyClass2>();
                 BindCore(section8, ref temp10, binderOptions);
                 obj.MyList2 = temp10;
@@ -166,7 +166,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section11)
             {
-                Dictionary<string, string> temp13 = obj.MyDictionary;
+                Dictionary<string, string>? temp13 = obj.MyDictionary;
                 temp13 ??= new Dictionary<string, string>();
                 BindCore(section11, ref temp13, binderOptions);
                 obj.MyDictionary = temp13;
index e2c8faa..a57f652 100644 (file)
@@ -150,7 +150,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section5)
             {
-                List<int> temp7 = obj.MyList;
+                List<int>? temp7 = obj.MyList;
                 temp7 ??= new List<int>();
                 BindCore(section5, ref temp7, binderOptions);
                 obj.MyList = temp7;
@@ -158,7 +158,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyList2")) is IConfigurationSection section8)
             {
-                List<Program.MyClass2> temp10 = obj.MyList2;
+                List<Program.MyClass2>? temp10 = obj.MyList2;
                 temp10 ??= new List<Program.MyClass2>();
                 BindCore(section8, ref temp10, binderOptions);
                 obj.MyList2 = temp10;
@@ -166,7 +166,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section11)
             {
-                Dictionary<string, string> temp13 = obj.MyDictionary;
+                Dictionary<string, string>? temp13 = obj.MyDictionary;
                 temp13 ??= new Dictionary<string, string>();
                 BindCore(section11, ref temp13, binderOptions);
                 obj.MyDictionary = temp13;
index 17d5050..66975c3 100644 (file)
@@ -150,7 +150,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section5)
             {
-                List<int> temp7 = obj.MyList;
+                List<int>? temp7 = obj.MyList;
                 temp7 ??= new List<int>();
                 BindCore(section5, ref temp7, binderOptions);
                 obj.MyList = temp7;
@@ -158,7 +158,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyList2")) is IConfigurationSection section8)
             {
-                List<Program.MyClass2> temp10 = obj.MyList2;
+                List<Program.MyClass2>? temp10 = obj.MyList2;
                 temp10 ??= new List<Program.MyClass2>();
                 BindCore(section8, ref temp10, binderOptions);
                 obj.MyList2 = temp10;
@@ -166,7 +166,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section11)
             {
-                Dictionary<string, string> temp13 = obj.MyDictionary;
+                Dictionary<string, string>? temp13 = obj.MyDictionary;
                 temp13 ??= new Dictionary<string, string>();
                 BindCore(section11, ref temp13, binderOptions);
                 obj.MyDictionary = temp13;
index a23f9b2..0263ef1 100644 (file)
@@ -144,7 +144,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section5)
             {
-                List<int> temp7 = obj.MyList;
+                List<int>? temp7 = obj.MyList;
                 temp7 ??= new List<int>();
                 BindCore(section5, ref temp7, binderOptions);
                 obj.MyList = temp7;
@@ -152,7 +152,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyList2")) is IConfigurationSection section8)
             {
-                List<Program.MyClass2> temp10 = obj.MyList2;
+                List<Program.MyClass2>? temp10 = obj.MyList2;
                 temp10 ??= new List<Program.MyClass2>();
                 BindCore(section8, ref temp10, binderOptions);
                 obj.MyList2 = temp10;
@@ -160,7 +160,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
 
             if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section11)
             {
-                Dictionary<string, string> temp13 = obj.MyDictionary;
+                Dictionary<string, string>? temp13 = obj.MyDictionary;
                 temp13 ??= new Dictionary<string, string>();
                 BindCore(section11, ref temp13, binderOptions);
                 obj.MyDictionary = temp13;