# False positive for S4275 Getters and setters should access the expected fields False postive

**URL:** <https://community.sonarsource.com/t/false-positive-for-s4275-getters-and-setters-should-access-the-expected-fields-false-postive/56913>\
**Category:** Report False-positive / False-negative...\
**Tags:** vbnet\
**Created:** [January 24, 2022, 4:09pm UTC](https://community.sonarsource.com/t/false-positive-for-s4275-getters-and-setters-should-access-the-expected-fields-false-postive/56913 "2022-01-24T16:09:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RowlandShaw](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/rowlandshaw/32/1162_2.png) [@RowlandShaw](https://community.sonarsource.com/u/RowlandShaw)\
**Post date:** [January 24, 2022, 4:09pm UTC](https://community.sonarsource.com/t/false-positive-for-s4275-getters-and-setters-should-access-the-expected-fields-false-postive/56913/1 "2022-01-24T16:09:17Z")

</div>

Seems something has changed in the processing for S4275 “recently” (between January 18th and this morning).

We have code that is loosely like:

```auto
Public Class A
    Private _chargeId as Integer
    Public Overrideable Property ChargeId As Integer
        Get
            Return _chargeId
        End Get
        Set(value As Integer)
            If (value <> _chargeId)
                _chargeId = value ' strictly speaking, we're doing other validation, but a scenario where auto properties aren't a solution
            End If
        End Set
    End Propery
End Class

Public Class B
    Inherits A

    Public Overrides Property ChargeId As Integer
        Get ' Refactor this getter so that it actually refers to the field '_chargeID'.
            Return If(SomeCondition, MyBase.ChargeId, 1234)
        End Get
        Set(value As Integer) ' Refactor this setter so that it actually refers to the field '_chargeID'
            MyBase.ChargeId = value
        End Set
    End Property
End Class

```

So we’re overriding a virtual method that doesn’t have access to \_chargeId, yet the derived class class is told it should reference it.

As an aside, this also doesn’t show up in Visual Studio; but only when doing analysis on a build with Azure DevOps…

---

<div class="post-metadata">

**Author:** ![costin.zaharia](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/costin.zaharia/32/62600_2.png) [@costin.zaharia](https://community.sonarsource.com/u/costin.zaharia)\
**Post date:** [January 28, 2022, 1:39pm UTC](https://community.sonarsource.com/t/false-positive-for-s4275-getters-and-setters-should-access-the-expected-fields-false-postive/56913/3 "2022-01-28T13:39:07Z")

</div>

Hi @RowlandShaw,

thanks a lot for your feedback. I can confirm the false positive, I’ve added an issue and you can follow the progress here: [Rule S4275: false positive on Visual Basic when using property overload · Issue #5336 · SonarSource/sonar-dotnet · GitHub](https://github.com/SonarSource/sonar-dotnet/issues/5336)

---

<div class="post-metadata">

**Author:** ![costin.zaharia](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/costin.zaharia/32/62600_2.png) [@costin.zaharia](https://community.sonarsource.com/u/costin.zaharia)\
**Post date:** [January 31, 2022, 8:04am UTC](https://community.sonarsource.com/t/false-positive-for-s4275-getters-and-setters-should-access-the-expected-fields-false-postive/56913/4 "2022-01-31T08:04:26Z")

</div>


