@@ -18,6 +18,7 @@ public class DocFileBuilder
1818 { typeof ( bool ) . FullName , "Boolean" } ,
1919 { typeof ( char ) . FullName , "Char" } ,
2020 { typeof ( byte ) . FullName , "Byte" } ,
21+ { typeof ( short ) . FullName , "Integer" } ,
2122 { typeof ( CultureInfo ) . FullName , "Culture" } ,
2223 { typeof ( Encoding ) . FullName , "Encoding" } ,
2324 { "NLog.Layouts.Layout" , "Layout" } ,
@@ -118,7 +119,6 @@ private string FixWhitespace(string p)
118119 private static string GetTypeName ( Type type )
119120 {
120121 string simpleName ;
121-
122122 type = GetUnderlyingType ( type ) ;
123123
124124 if ( simpleTypeNames . TryGetValue ( type . FullName , out simpleName ) )
@@ -131,6 +131,11 @@ private static string GetTypeName(Type type)
131131
132132 private static Type GetUnderlyingType ( Type type )
133133 {
134+ if ( type . IsGenericType && type . Name . StartsWith ( "Layout" ) )
135+ {
136+ type = type . GetGenericArguments ( ) [ 0 ] ;
137+ }
138+
134139 if ( type . IsGenericType && type . GetGenericTypeDefinition ( ) == typeof ( Nullable < > ) )
135140 {
136141 type = type . GetGenericArguments ( ) [ 0 ] ;
@@ -479,6 +484,34 @@ private static bool TryGetPropertyDefaultValue(object configInstance, PropertyIn
479484 return true ;
480485 }
481486
487+ var underlyingType = GetUnderlyingType ( propInfo . PropertyType ) ;
488+ if ( propertyValue != null && underlyingType != null && ! ReferenceEquals ( underlyingType , propInfo . PropertyType ) && ! underlyingType . Equals ( propertyValue ? . GetType ( ) ) )
489+ {
490+ try
491+ {
492+ if ( underlyingType . IsEnum )
493+ {
494+ var enumStringValue = propertyValue ? . ToString ( ) ;
495+ defaultValue = Enum . Parse ( underlyingType , enumStringValue , true ) . ToString ( ) ;
496+ return true ;
497+ }
498+
499+ if ( typeof ( IConvertible ) . IsAssignableFrom ( underlyingType ) )
500+ {
501+ var convStringValue = propertyValue ? . ToString ( ) ;
502+ defaultValue = Convert . ChangeType ( convStringValue , underlyingType ) . ToString ( ) ;
503+ return true ;
504+ }
505+ }
506+ catch
507+ {
508+ // Nothing to do
509+ }
510+
511+ defaultValue = null ;
512+ return false ;
513+ }
514+
482515 IConvertible convertibleValue = propertyValue as IConvertible ;
483516 if ( convertibleValue == null && propertyValue != null )
484517 {
0 commit comments