75 lines
1.7 KiB
Plaintext
75 lines
1.7 KiB
Plaintext
include::../description.adoc[]
|
|
|
|
== How to fix it
|
|
|
|
=== Code examples
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,csharp,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
[Serializable]
|
|
public class Foo
|
|
{
|
|
[OnSerializing]
|
|
public void OnSerializing(StreamingContext context) {} // Noncompliant: should be private
|
|
|
|
[OnSerialized]
|
|
int OnSerialized(StreamingContext context) {} // Noncompliant: should return void
|
|
|
|
[OnDeserializing]
|
|
void OnDeserializing() {} // Noncompliant: should have a single parameter of type StreamingContext
|
|
|
|
[OnSerializing]
|
|
public void OnSerializing2<T>(StreamingContext context) {} // Noncompliant: should have no type parameters
|
|
|
|
[OnDeserialized]
|
|
void OnDeserialized(StreamingContext context, string str) {} // Noncompliant: should have a single parameter of type StreamingContext
|
|
}
|
|
----
|
|
|
|
|
|
==== Compliant solution
|
|
|
|
[source,csharp,diff-id=1,diff-type=compliant]
|
|
----
|
|
[Serializable]
|
|
public class Foo
|
|
{
|
|
[OnSerializing]
|
|
private void OnSerializing(StreamingContext context) {}
|
|
|
|
[OnSerialized]
|
|
private void OnSerialized(StreamingContext context) {}
|
|
|
|
[OnDeserializing]
|
|
private void OnDeserializing(StreamingContext context) {}
|
|
|
|
[OnDeserialized]
|
|
private void OnDeserialized(StreamingContext context) {}
|
|
}
|
|
----
|
|
|
|
include::../resources.adoc[]
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Make this method [non-public | non-static | return 'void' | have no type parameters | have a single parameter of type 'StreamingContext'].
|
|
|
|
|
|
include::../highlighting.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|