You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I like this rule very much, because it's forcing good encapsulation. But when using [DataContract]s for DTOs, it's hard to fulfill this rule.
Repro steps
[DataContract]
public class Message
{
[DataMember]
[Required]
public string Id { get; set; }
[DataMember]
[Required]
public string MessageBody { get; set; }
[DataMember]
[Required]
public Dictionary<string, string> Properties { get; set; }
}
Expected behavior
The rule should not raise, when [DataContract] attribute is attached to the class or maybe more explicitly [DataMember] is on the property.
Actual behavior
The rule raises a violation.
Known workarounds
Implement custom serialization/deserialization for the class.
Use custom backing fields and attach to attribute to datamember
Related information
SonarC# 6.5.0.27846
Visual Studio 2017.3
MSBuild 15.3.409.57025
The text was updated successfully, but these errors were encountered:
cmenzi
changed the title
S4004 should raise when [DataContract] is applied
S4004 should not raise a violation when [DataContract] or [DataMember] is applied
Sep 24, 2017
Evangelink
changed the title
S4004 should not raise a violation when [DataContract] or [DataMember] is applied
Fix S4004: Rule should not raise a violation when [DataContract] or [DataMember] is applied
Oct 4, 2017
Evangelink
changed the title
Fix S4004: Rule should not raise a violation when [DataContract] or [DataMember] is applied
Fix S4004: Rule should not raise a violation when[DataMember] is applied
Oct 16, 2017
Evangelink
changed the title
Fix S4004: Rule should not raise a violation when[DataMember] is applied
Fix S4004: Rule should not raise a violation when [DataMember] is applied
Oct 16, 2017
Description
I like this rule very much, because it's forcing good encapsulation. But when using
[DataContract]
s for DTOs, it's hard to fulfill this rule.Repro steps
Expected behavior
The rule should not raise, when
[DataContract]
attribute is attached to the class or maybe more explicitly[DataMember]
is on the property.Actual behavior
The rule raises a violation.
Known workarounds
Related information
The text was updated successfully, but these errors were encountered: