Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 10f7397

Browse files
committed
Merge pull request #403 from takenet/master
Fix EmitDefaultValue support for Enums with custom SerializeFn.
2 parents 6d399c5 + 66e537f commit 10f7397

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ServiceStack.Text/Common/WriteType.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ private static bool Init()
134134
int propertyOrder = -1;
135135
var propertyType = propertyInfo.PropertyType;
136136
var defaultValue = propertyType.GetDefaultValue();
137-
bool propertySuppressDefaultConfig = defaultValue != null && propertyType.IsValueType() && JsConfig.HasSerializeFn.Contains(propertyType);
137+
bool propertySuppressDefaultConfig = defaultValue != null && propertyType.IsValueType() && !propertyType.IsEnum() && JsConfig.HasSerializeFn.Contains(propertyType);
138138
bool propertySuppressDefaultAttribute = false;
139139

140140
var shouldSerialize = GetShouldSerializeMethod(propertyInfo);
@@ -183,7 +183,7 @@ private static bool Init()
183183
int propertyOrder = -1;
184184
var propertyType = fieldInfo.FieldType;
185185
var defaultValue = propertyType.GetDefaultValue();
186-
bool propertySuppressDefaultConfig = defaultValue != null && propertyType.IsValueType() && JsConfig.HasSerializeFn.Contains(propertyType);
186+
bool propertySuppressDefaultConfig = defaultValue != null && propertyType.IsValueType() && !propertyType.IsEnum() && JsConfig.HasSerializeFn.Contains(propertyType);
187187
bool propertySuppressDefaultAttribute = false;
188188
#if (NETFX_CORE)
189189
var shouldSerialize = (Func<T, bool>)null;

0 commit comments

Comments
 (0)