public string Foo { get; set; } = "FooMang";
public string Bar1 { get; set; } = "Bar1Mang";
public string Bar2 { get; set; } = "Bar2Mang";
public HttpStatusCode StatusCode { get; set; } = HttpStatusCode.OK;
public class Sub2Dash1 : Sub2
public Type Ugh1Type { get; set; } = typeof(int);
public string Ugh1 { get; set; } = "Ugh1Mang";
public class Sub2Dash2 : Sub2
public Type Ugh2Type { get; set; } = typeof(double);
public string Ugh2 { get; set; } = "Ugh2Mang";
public static void Main()
Console.WriteLine("Hello World");
private static void Print(Base b)
Console.WriteLine(ToLogString(b));
private static string ToLogString(Base b)
var builder = new StringBuilder();
builder.Append(b.GetType().Name);
.GetProperties(BindingFlags.Instance | BindingFlags.Public)
.OrderBy(GetInheritanceHierarchyDepth);
foreach (var prop in props)
builder.Append(prop.Name);
var val = prop.GetValue(b);
builder.AppendFormat("\"{0}\"", val);
builder.Append(type.Name);
case HttpStatusCode code:
builder.AppendFormat("{0} ({1})", (int)code, code);
builder.Remove(builder.Length - 1, 1);
return builder.ToString();
static int GetInheritanceHierarchyDepth(PropertyInfo prop)
for (var t = prop.DeclaringType; t?.BaseType != null; t = t.BaseType)