Say I have a property implementing INotifyPropertyChanged:
public WhichHandle LastHandleFC
{
get => _lastHandleFc;
set => SetField(ref _lastHandleFc, value);
}
I can replace with regex: \r\n^\s+ to (space), select the property 5 lines, select replace all in selection (alt+a), then confirm with OK.
Result:
public WhichHandle LastHandleFC { get => _lastHandleFc; set => SetField(ref _lastHandleFc, value); }
But now I would like to have my cursor somewhere on the property (not selection) and make it happen with a defined shortcut (like a resharper or VS operation, with alt+enter or ctrl+.).
Is there a way to achieve this ? Is there a way to achieve this after selection a block with several properties and have each of them transformed like this, while respecting the distance between properties ?
To be complete, INotifyPropertyChanged is implemented with:
public event PropertyChangedEventHandler? PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
protected bool SetField<T>(ref T field, T value, [CallerMemberName] string? propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
field = value;
OnPropertyChanged(propertyName);
return true;
}