public class NullableTestParent
public string? StringNullable { get; set; }
public string StringNotNullable { get; set; } = "";
public NullableTestChild Child { get; set; } = new();
public class NullableTestChild
public string? StringNullableChild { get; set; }
public string StringNotNullableChild { get; set; } = "";
public string? Prop {get;set;}
public string Prop2 {get;set;}
private static NullabilityInfoContext _nullabilityContext = new NullabilityInfoContext();
public static void Main()
var p1 = typeof(NullableTestParent.NullableTestChild).GetProperty(nameof(NullableTestParent.NullableTestChild.StringNullableChild));
var p2 = typeof(NullableTestParent.NullableTestChild).GetProperty(nameof(NullableTestParent.NullableTestChild.StringNotNullableChild));
var nullabilityInfo1 = _nullabilityContext.Create(p1);
var nullabilityInfo2 = _nullabilityContext.Create(p2);
Console.WriteLine($"{nameof(NullableTestParent.NullableTestChild.StringNullableChild)} is: " + nullabilityInfo1.WriteState);
Console.WriteLine($"{nameof(NullableTestParent.NullableTestChild.StringNotNullableChild)} is: " + nullabilityInfo2.WriteState);