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)
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(
TypeSpec memberType = member.Type;
TypeSpec effectiveMemberType = memberType.EffectiveType;
- string effectiveMemberTypeDisplayString = effectiveMemberType.MinimalDisplayString;
- bool canGet = member.CanGet;
string tempIdentifier = GetIncrementalIdentifier(Identifier.temp);
InitializationKind initKind;
}
Debug.Assert(canSet);
+ string effectiveMemberTypeDisplayString = effectiveMemberType.MinimalDisplayString;
initKind = InitializationKind.None;
if (memberType.SpecKind is TypeSpecKind.Nullable)
targetObjAccessExpr = tempIdentifier;
}
- else if (canGet)
+ else if (member.CanGet)
{
targetObjAccessExpr = memberAccessExpr;
initKind = InitializationKind.AssignmentWithNullCheck;
{
public string Namespace { get; set; }
- public Dictionary<string, QueueProperties> Queues { get; set; } = new();
+ public Dictionary<string, QueueProperties>? Queues { get; set; } = new();
}
public class QueueProperties
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;