include::../description.adoc[]

== How to fix it

=== Code examples

==== Noncompliant code example

[source,vbnet,diff-id=1,diff-type=noncompliant]
----
<Serializable>
Public Class Foo
    <OnSerializing>
    Public Sub OnSerializing(ByVal context As StreamingContext) ' Noncompliant: should be private
    End Sub

    <OnSerialized>
    Private Function OnSerialized(ByVal context As StreamingContext) As Integer '  Noncompliant: should return void
    End Function

    <OnDeserializing>
    Private Sub OnDeserializing() ' Noncompliant: should have a single parameter of type StreamingContext
    End Sub

    <OnSerializing>
    Public Sub OnSerializing2(Of T)(ByVal context As StreamingContext) ' Noncompliant: should have no type parameters
    End Sub

    <OnDeserialized>
    Private Sub OnDeserialized(ByVal context As StreamingContext, ByVal str As String) ' Noncompliant: should have a single parameter of type StreamingContext
    End Sub
End Class
----

==== Compliant solution

[source,vbnet,diff-id=1,diff-type=compliant]
----
<Serializable>
Public Class Foo
    <OnSerializing>
    Private Sub OnSerializing(ByVal context As StreamingContext)
    End Sub

    <OnSerialized>
    Private Sub OnSerialized(ByVal context As StreamingContext)
    End Sub

    <OnDeserializing>
    Private Sub OnDeserializing(ByVal context As StreamingContext)
    End Sub

    <OnDeserialized>
    Private Sub OnDeserialized(ByVal context As StreamingContext)
    End Sub
End Class
----

include::../resources.adoc[]

ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Make this method [non-public | non-shared | a 'Sub' not a 'Function' | 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[]
