43 lines
810 B
Plaintext
43 lines
810 B
Plaintext
include::../why-dotnet.adoc[]
|
|
|
|
== How to fix it
|
|
|
|
=== Code examples
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,vbnet,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
<Export(GetType(IFooBar))>
|
|
<PartCreationPolicy(CreationPolicy.[Shared])>
|
|
Public Class FooBar
|
|
Inherits IFooBar
|
|
End Class
|
|
|
|
Public Class Program
|
|
Public Shared Sub Main()
|
|
Dim fooBar = New FooBar() ' Noncompliant
|
|
End Sub
|
|
End Class
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,vbnet,diff-id=1,diff-type=compliant]
|
|
----
|
|
<Export(GetType(IFooBar))>
|
|
<PartCreationPolicy(CreationPolicy.[Shared])>
|
|
Public Class FooBar
|
|
Inherits IFooBar
|
|
End Class
|
|
|
|
Public Class Program
|
|
Public Shared Sub Main()
|
|
Dim fooBar = serviceProvider.GetService(Of IFooBar)()
|
|
End Sub
|
|
End Class
|
|
----
|
|
|
|
include::../resources-dotnet.adoc[]
|
|
|
|
include::../rspecator.adoc[] |