Page MenuHomePhabricator

C#: CA1044: Properties should not be write only
Closed, ResolvedPublic

Description

Either add a getter accessor or turn this into a method.

lauromoura triaged this task as Normal priority.

Occurrences of this issue:

  • efl_access_editable_text.eo.cs: TextContent
  • efl_core_command_line.eo.cs: CommandArray
  • efl_core_command_line.eo.cs: CommandString
  • efl_canvas_filter_internal.eo.cs: FilterChanged
  • efl_canvas_filter_internal.eo.cs: FilterInvalid
  • efl_canvas_image_internal.eo.cs: FilterInvalid
  • efl_canvas_image_internal.eo.cs: FilterChanged
  • efl_canvas_text.eo.cs: FilterChanged
  • efl_canvas_text.eo.cs: FilterInvalid
  • efl_canvas_vg_image.eo.cs: Data
  • efl_canvas_vg_node.eo.cs: CompMethod
  • efl_ui_alert_popup.eo.cs: Button
  • efl_ui_position_manager_data_access_v1.eo.cs: DataAccess
  • efl_ui_position_manager_entity.eo.cs: Viewport
  • efl_ui_position_manager_entity.eo.cs: ScrollPosition
  • efl_ui_scrollable.eo.cs: MatchContent
  • efl_ui_scroll_manager.eo.cs: Pan
  • efl_ui_spotlight_manager.eo.cs: Size
  • efl_ui_text.eo.cs: InputPanelReturnKeyAutoenabled
  • efl_ui_text.eo.cs: TextContent
  • efl_ui_widget.eo.cs: ResizeObject
  • efl_ui_win.eo.cs: PropFocusSkip

I think we could fix this by generating only the setter method for these properties (i.e. reject property wrappers for setter-only properties) .

If any is really needed (like for MVVM binding?), we could suppress the message for these cases.

What do you think @segfaultxavi, @woohyun ?

From the rule: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1044?view=vs-2019

Get accessors provide read access to a property and set accessors provide write access. Although it is acceptable and often necessary to have a read-only property, the design guidelines prohibit the use of write-only properties. This is because letting a user set a value and then preventing the user from viewing the value does not provide any security. Also, without read access, the state of shared objects cannot be viewed, which limits their usefulness.

I totally agree with Microsoft here. Write-only properties are extremely weird.

For now, we can use only setter methods for these properties, sure. But I think we should make the extra effort and add the missing getters for these properties (maybe create a task for that).

YOhoho closed this task as Resolved.Jan 21 2020, 4:45 PM
YOhoho claimed this task.