rspec/rules/S2553/csharp/rule.adoc

49 lines
1.3 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
The ``++ISerializable++`` interface gives you control over _how_ your class is serialized, but does not itself make the class serializable. Such classes must also have the ``++[Serializable]++`` attribute.
=== Noncompliant code example
2022-02-04 17:28:24 +01:00
[source,csharp]
----
public class Person : ISerializable { // Noncompliant; [Serializable] attribute missing
// ...
}
----
=== Compliant solution
2022-02-04 17:28:24 +01:00
[source,csharp]
----
[Serializable]
public class Person : ISerializable {
// ...
}
----
ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)
=== on 4 Feb 2015, 14:17:17 Ann Campbell wrote:
Gendarme MissingSerializableAttributeOnISerializableTypeRule
=== on 13 Apr 2015, 10:47:40 Freddy Mallet wrote:
@Tamas, does this rule makes sense to you ? Thanks
=== on 22 May 2015, 09:23:53 Tamas Vajk wrote:
\[~freddy.mallet] Yes, it makes sense. BUT it is already implemented by the Roslyn team:
https://msdn.microsoft.com/en-us/library/ms182350.aspx
https://github.com/dotnet/roslyn/blob/master/src/Diagnostics/FxCop/Core/Usage/SerializationRulesDiagnosticAnalyzer.cs
=== on 28 May 2015, 12:44:55 Tamas Vajk wrote:
This rule duplicates CA2237 (\https://msdn.microsoft.com/en-us/library/ms182350.aspx), which is already implemented by the Roslyn team.
endif::env-github,rspecator-view[]