agoda-com / agoda-com/AgodaAnalyzers

AG0034: Check if method parameters are being mutated by reference

Offen
#107 0 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
Needs discussion Proposal
Vorherrschende Sprache
C#
Sterne
25
Forks
15
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

I would like to prevent people from misusing the parameters as a way to return some value from a method.
For example, for following code:
```cs
public static void Method(A a){
a.B = new B();
a.B.C = new C();
}
```
both assignments are mutating the input parameter and treating it like a return value. The rule would not be applied for `ref` and `out` type params, as they imply explicitly that the parameter is / might be mutated.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.