2023-06-08 16:46:44 +02:00
include::../why-dotnet.adoc[]
2023-05-25 14:18:12 +02:00
2023-06-08 16:46:44 +02:00
== How to fix it
2023-05-25 14:18:12 +02:00
2023-06-08 16:46:44 +02:00
=== Code examples
2023-05-25 14:18:12 +02:00
2023-06-08 16:46:44 +02:00
==== Noncompliant code example
2023-05-25 14:18:12 +02:00
2023-06-08 16:46:44 +02:00
[source,vbnet,diff-id=1,diff-type=noncompliant]
2023-05-25 14:18:12 +02:00
----
2023-06-08 16:46:44 +02:00
Dim foo = {"a", "b", "c" }
Property Foo() As String() ' Noncompliant
Get
Dim copy = foo.Clone ' Expensive call
Return copy
End Get
End Property
2023-05-25 14:18:12 +02:00
----
2023-06-08 16:46:44 +02:00
==== Compliant solution
2023-05-25 14:18:12 +02:00
2023-06-08 16:46:44 +02:00
[source,vbnet,diff-id=1,diff-type=compliant]
2023-05-25 14:18:12 +02:00
----
2023-06-08 16:46:44 +02:00
Dim foo = {"a", "b", "c" }
Function GetFoo() As String()
Dim copy = foo.Clone
Return copy
End Function
2023-05-25 14:18:12 +02:00
----
2023-06-08 16:46:44 +02:00
== Resources
2021-06-02 20:44:38 +02:00
2023-06-08 16:46:44 +02:00
=== Documentation
2021-09-20 15:38:42 +02:00
2023-06-08 16:46:44 +02:00
* https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/properties[Properties (Visual Basic)]
* https://learn.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/objects-and-classes/#fields-and-properties[Fields and properties]
* https://learn.microsoft.com/en-us/dotnet/visual-basic/programming-guide/concepts/collections[Collections (Visual Basic)]
2021-06-02 20:44:38 +02:00
2023-06-08 16:46:44 +02:00
include::../rspecator.adoc[]