Skip to content

Instantly share code, notes, and snippets.

@olejorgensen
Last active March 22, 2019 17:18
Show Gist options
  • Save olejorgensen/0138f0b50471d54b5f17f694b730ea99 to your computer and use it in GitHub Desktop.
Save olejorgensen/0138f0b50471d54b5f17f694b730ea99 to your computer and use it in GitHub Desktop.
CTRl+SHIFT+F
tick "Look In" to current document
tick regular expression
tick match whole word
Filetype *.cs
find:
(NotifyPropertyChanged|RaisePropertyChanged|ArgumentNullException|ArgumentOutOfRangeException)\(([\s\t\r\n]?)\"\b(_\w+|[\w-[0-9_]]\w*)\b\"
replace:
$1($2nameof($3))
find:
ArgumentNullException\(\"\b(_\w+|[\w-[0-9_]]\w*)\b\"\)
replace:
ArgumentNullException\(nameof($1))
find:
(NotifyPropertyChanged|RaisePropertyChanged|ArgumentNullException|ArgumentOutOfRangeException)\(\"\b(_\w+|[\w-[0-9_]]\w*)\b\"\)
replace:
$1(nameof($2))
Traces
remember to set "Look In" to current document - it changes without warning p.o.s
tick regular expression
untick match whole word
Filetype *.cs
find:
Trace.WriteLine\(\$" \{Name\}\.([a-z_]+)(\"|:)
replace:
Trace.WriteLine($" {Name}.{nameof($1)}$2
find:
Trace.WriteLine\(\$?"([\s\t\r\n]?)([a-z_]+)\.([a-z_]+)(\"|:)?
replace:
Trace.WriteLine($"$1{Name}.{nameof($3)}$4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment