Is it a breaking change that modifying the access modifier of a public property?

前端 未结 5 829
太阳男子
太阳男子 2021-02-01 05:22

If I change the access modifier of the setter of a public property from private to public, is that causes any breaking change in the other assemblies that refer it?

5条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-01 06:11

    It might be, if those other assemblies use reflection to test for the presence of the setter.

    But early-bound code will not break.

    Another thing to consider is whether this is a change in semantics. If the property was formerly set only during construction, and now can be modified at any time, that definitely could break consumers who cached the value, used it as a Dictionary key, etc.

提交回复
热议问题