Skip to content

Commit ed0bd14

Browse files
Use nameof() instead of hardcoded strings for INPC
1 parent 5df497d commit ed0bd14

File tree

1 file changed

+29
-28
lines changed

1 file changed

+29
-28
lines changed

ICSharpCode.AvalonEdit/TextEditorOptions.cs

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ public TextEditorOptions(TextEditorOptions options)
4747

4848
// copy each value over to 'this'
4949
foreach (FieldInfo fi in fields) {
50-
if (fi.GetCustomAttribute<NonSerializedAttribute>() == null)
50+
if (fi.GetCustomAttribute<NonSerializedAttribute>() == null) {
5151
fi.SetValue(this, fi.GetValue(options));
52+
}
5253
}
5354
}
5455
#endregion
@@ -91,7 +92,7 @@ public virtual bool ShowSpaces {
9192
set {
9293
if (showSpaces != value) {
9394
showSpaces = value;
94-
OnPropertyChanged("ShowSpaces");
95+
OnPropertyChanged(nameof(ShowSpaces));
9596
}
9697
}
9798
}
@@ -108,7 +109,7 @@ public virtual bool ShowTabs {
108109
set {
109110
if (showTabs != value) {
110111
showTabs = value;
111-
OnPropertyChanged("ShowTabs");
112+
OnPropertyChanged(nameof(ShowTabs));
112113
}
113114
}
114115
}
@@ -125,7 +126,7 @@ public virtual bool ShowEndOfLine {
125126
set {
126127
if (showEndOfLine != value) {
127128
showEndOfLine = value;
128-
OnPropertyChanged("ShowEndOfLine");
129+
OnPropertyChanged(nameof(ShowEndOfLine));
129130
}
130131
}
131132
}
@@ -142,7 +143,7 @@ public virtual bool ShowBoxForControlCharacters {
142143
set {
143144
if (showBoxForControlCharacters != value) {
144145
showBoxForControlCharacters = value;
145-
OnPropertyChanged("ShowBoxForControlCharacters");
146+
OnPropertyChanged(nameof(ShowBoxForControlCharacters));
146147
}
147148
}
148149
}
@@ -161,7 +162,7 @@ public virtual bool EnableHyperlinks {
161162
set {
162163
if (enableHyperlinks != value) {
163164
enableHyperlinks = value;
164-
OnPropertyChanged("EnableHyperlinks");
165+
OnPropertyChanged(nameof(EnableHyperlinks));
165166
}
166167
}
167168
}
@@ -196,7 +197,7 @@ public virtual bool RequireControlModifierForHyperlinkClick {
196197
set {
197198
if (requireControlModifierForHyperlinkClick != value) {
198199
requireControlModifierForHyperlinkClick = value;
199-
OnPropertyChanged("RequireControlModifierForHyperlinkClick");
200+
OnPropertyChanged(nameof(RequireControlModifierForHyperlinkClick));
200201
}
201202
}
202203
}
@@ -219,15 +220,15 @@ public virtual int IndentationSize {
219220
get { return indentationSize; }
220221
set {
221222
if (value < 1)
222-
throw new ArgumentOutOfRangeException("value", value, "value must be positive");
223+
throw new ArgumentOutOfRangeException(nameof(value), value, "value must be positive");
223224
// sanity check; a too large value might cause WPF to crash internally much later
224225
// (it only crashed in the hundred thousands for me; but might crash earlier with larger fonts)
225226
if (value > 1000)
226-
throw new ArgumentOutOfRangeException("value", value, "indentation size is too large");
227+
throw new ArgumentOutOfRangeException(nameof(value), value, "indentation size is too large");
227228
if (indentationSize != value) {
228229
indentationSize = value;
229-
OnPropertyChanged("IndentationSize");
230-
OnPropertyChanged("IndentationString");
230+
OnPropertyChanged(nameof(IndentationSize));
231+
OnPropertyChanged(nameof(IndentationString));
231232
}
232233
}
233234
}
@@ -244,8 +245,8 @@ public virtual bool ConvertTabsToSpaces {
244245
set {
245246
if (convertTabsToSpaces != value) {
246247
convertTabsToSpaces = value;
247-
OnPropertyChanged("ConvertTabsToSpaces");
248-
OnPropertyChanged("IndentationString");
248+
OnPropertyChanged(nameof(ConvertTabsToSpaces));
249+
OnPropertyChanged(nameof(IndentationString));
249250
}
250251
}
251252
}
@@ -265,7 +266,7 @@ public string IndentationString {
265266
public virtual string GetIndentationString(int column)
266267
{
267268
if (column < 1)
268-
throw new ArgumentOutOfRangeException("column", column, "Value must be at least 1.");
269+
throw new ArgumentOutOfRangeException(nameof(column), column, "Value must be at least 1.");
269270
int indentationSize = this.IndentationSize;
270271
if (ConvertTabsToSpaces) {
271272
return new string(' ', indentationSize - ((column - 1) % indentationSize));
@@ -286,7 +287,7 @@ public virtual bool CutCopyWholeLine {
286287
set {
287288
if (cutCopyWholeLine != value) {
288289
cutCopyWholeLine = value;
289-
OnPropertyChanged("CutCopyWholeLine");
290+
OnPropertyChanged(nameof(CutCopyWholeLine));
290291
}
291292
}
292293
}
@@ -303,7 +304,7 @@ public virtual bool AllowScrollBelowDocument {
303304
set {
304305
if (allowScrollBelowDocument != value) {
305306
allowScrollBelowDocument = value;
306-
OnPropertyChanged("AllowScrollBelowDocument");
307+
OnPropertyChanged(nameof(AllowScrollBelowDocument));
307308
}
308309
}
309310
}
@@ -319,10 +320,10 @@ public virtual double WordWrapIndentation {
319320
get { return wordWrapIndentation; }
320321
set {
321322
if (double.IsNaN(value) || double.IsInfinity(value))
322-
throw new ArgumentOutOfRangeException("value", value, "value must not be NaN/infinity");
323+
throw new ArgumentOutOfRangeException(nameof(value), value, "value must not be NaN/infinity");
323324
if (value != wordWrapIndentation) {
324325
wordWrapIndentation = value;
325-
OnPropertyChanged("WordWrapIndentation");
326+
OnPropertyChanged(nameof(WordWrapIndentation));
326327
}
327328
}
328329
}
@@ -340,7 +341,7 @@ public virtual bool InheritWordWrapIndentation {
340341
set {
341342
if (value != inheritWordWrapIndentation) {
342343
inheritWordWrapIndentation = value;
343-
OnPropertyChanged("InheritWordWrapIndentation");
344+
OnPropertyChanged(nameof(InheritWordWrapIndentation));
344345
}
345346
}
346347
}
@@ -356,7 +357,7 @@ public bool EnableRectangularSelection {
356357
set {
357358
if (enableRectangularSelection != value) {
358359
enableRectangularSelection = value;
359-
OnPropertyChanged("EnableRectangularSelection");
360+
OnPropertyChanged(nameof(EnableRectangularSelection));
360361
}
361362
}
362363
}
@@ -372,7 +373,7 @@ public bool EnableTextDragDrop {
372373
set {
373374
if (enableTextDragDrop != value) {
374375
enableTextDragDrop = value;
375-
OnPropertyChanged("EnableTextDragDrop");
376+
OnPropertyChanged(nameof(EnableTextDragDrop));
376377
}
377378
}
378379
}
@@ -391,7 +392,7 @@ public virtual bool EnableVirtualSpace {
391392
set {
392393
if (enableVirtualSpace != value) {
393394
enableVirtualSpace = value;
394-
OnPropertyChanged("EnableVirtualSpace");
395+
OnPropertyChanged(nameof(EnableVirtualSpace));
395396
}
396397
}
397398
}
@@ -408,7 +409,7 @@ public virtual bool EnableImeSupport {
408409
set {
409410
if (enableImeSupport != value) {
410411
enableImeSupport = value;
411-
OnPropertyChanged("EnableImeSupport");
412+
OnPropertyChanged(nameof(EnableImeSupport));
412413
}
413414
}
414415
}
@@ -424,7 +425,7 @@ public virtual bool ShowColumnRuler {
424425
set {
425426
if (showColumnRuler != value) {
426427
showColumnRuler = value;
427-
OnPropertyChanged("ShowColumnRuler");
428+
OnPropertyChanged(nameof(ShowColumnRuler));
428429
}
429430
}
430431
}
@@ -440,7 +441,7 @@ public virtual int ColumnRulerPosition {
440441
set {
441442
if (columnRulerPosition != value) {
442443
columnRulerPosition = value;
443-
OnPropertyChanged("ColumnRulerPosition");
444+
OnPropertyChanged(nameof(ColumnRulerPosition));
444445
}
445446
}
446447
}
@@ -456,7 +457,7 @@ public virtual bool HighlightCurrentLine {
456457
set {
457458
if (highlightCurrentLine != value) {
458459
highlightCurrentLine = value;
459-
OnPropertyChanged("HighlightCurrentLine");
460+
OnPropertyChanged(nameof(HighlightCurrentLine));
460461
}
461462
}
462463
}
@@ -472,7 +473,7 @@ public bool HideCursorWhileTyping {
472473
set {
473474
if (hideCursorWhileTyping != value) {
474475
hideCursorWhileTyping = value;
475-
OnPropertyChanged("HideCursorWhileTyping");
476+
OnPropertyChanged(nameof(HideCursorWhileTyping));
476477
}
477478
}
478479
}
@@ -488,7 +489,7 @@ public bool AllowToggleOverstrikeMode {
488489
set {
489490
if (allowToggleOverstrikeMode != value) {
490491
allowToggleOverstrikeMode = value;
491-
OnPropertyChanged("AllowToggleOverstrikeMode");
492+
OnPropertyChanged(nameof(AllowToggleOverstrikeMode));
492493
}
493494
}
494495
}

0 commit comments

Comments
 (0)