Skip to content

Commit c4d7c58

Browse files
committed
Fixed a recursion problem in the encryption mutator when system.datetime
was used as a property. Related to #469
1 parent e5d391b commit c4d7c58

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/encryption/NServiceBus.Encryption/EncryptionMessageMutator.cs

+9-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void EncryptObject(object target)
3535
continue;
3636
}
3737

38-
if (property.PropertyType.IsPrimitive)
38+
if (property.PropertyType.IsPrimitive || IsSystemType(property.PropertyType))
3939
continue;
4040

4141
//recurse
@@ -94,14 +94,21 @@ void DecryptObject(object target)
9494
continue;
9595
}
9696

97-
if (property.PropertyType.IsPrimitive)
97+
if (property.PropertyType.IsPrimitive || IsSystemType(property.PropertyType))
9898
continue;
9999

100100
//recurse
101101
DecryptObject(property.GetValue(target, null));
102102
}
103103
}
104104

105+
bool IsSystemType(Type propertyType)
106+
{
107+
var nameOfContainingAssembly = propertyType.Assembly.FullName.ToLower();
108+
109+
return nameOfContainingAssembly.StartsWith("mscorlib") || nameOfContainingAssembly.StartsWith("system.core");
110+
}
111+
105112
void DecryptProperty(object target, PropertyInfo property)
106113
{
107114

tests/encryption/NServiceBus.Encryption.Tests/WireEncryptedStringSpecs.cs

+2
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ public class SecureMessage:IMessage
153153
public MySecretSubProperty SubProperty { get; set; }
154154

155155
public WireEncryptedString SecretThatIsNull { get; set; }
156+
157+
public DateTime DateTime { get; set; }
156158
}
157159

158160

0 commit comments

Comments
 (0)