CA1823 false positive
-
Thursday, December 15, 2011 1:08 PM
Hi,
Getting a false positive on structure marked as DataContract which is serialized to JSON using the DataContractJsonSerializer.
[DataContract]
internal class TheData
{
[DataMember]
internal string TheId ;Any workarounds as we use this DataContract approach in a few places.
Thanks
Donal
All Replies
-
Thursday, December 15, 2011 3:52 PM
From the docs:
It is safe to suppress a warning from this rule.
These types of rules are known to cause false positives on objects used for serialization only.
You might be able to trick the rule by using:
[DataMember]
internal string TheId{get; set; }And I'm wondering whether the TheId field is ever set from your code.
My blog: blog.jessehouwing.nl -
Thursday, December 15, 2011 4:37 PM
>>And I'm wondering whether the TheId field is ever set from your code
Yes TheId is set but there is no get ever called on it.
-
Monday, April 09, 2012 6:03 AM
For your reference
http://social.msdn.microsoft.com/Forums/en-US/vstscode/thread/aa026bf1-95e8-4979-b20f-0ace63f96f68/
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Regards, Jun Zh - MSFT Microsoft Online Community Support

