Skip to content

Commit 831787d

Browse files
author
Maxim Korsukov
committed
Code cleanup - introducing the 'nameof' operator instead of string values
1 parent 515cbde commit 831787d

29 files changed

+270
-270
lines changed

DocumentFormat.OpenXml/src/Framework/DataPartReferenceRelationship.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ internal static DataPartReferenceRelationship CreateDataPartReferenceRelationshi
107107
break;
108108

109109
default:
110-
throw new ArgumentOutOfRangeException("relationshipType");
110+
throw new ArgumentOutOfRangeException(nameof(relationshipType));
111111
}
112112
dataPartReferenceRelationship.Container = containter;
113113
return dataPartReferenceRelationship;

DocumentFormat.OpenXml/src/Framework/MediaDataPart.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public void FeedData(Stream sourceStream)
152152

153153
if (sourceStream == null)
154154
{
155-
throw new ArgumentNullException("sourceStream");
155+
throw new ArgumentNullException(nameof(sourceStream));
156156
}
157157

158158
using (Stream targetStream = this.GetStream(FileMode.Create))
@@ -554,7 +554,7 @@ internal static string GetContentType(this MediaDataPartType mediaDataPartType)
554554
return "video/vc1";
555555

556556
default:
557-
throw new ArgumentOutOfRangeException("mediaDataPartType");
557+
throw new ArgumentOutOfRangeException(nameof(mediaDataPartType));
558558
}
559559
}
560560

DocumentFormat.OpenXml/src/Framework/NamespaceIdMap.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ public static bool TryGetTransitionalNamespace(string strictNamespace, out strin
414414
{
415415
if (strictNamespace == null)
416416
{
417-
throw new ArgumentNullException("strictNamespace");
417+
throw new ArgumentNullException(nameof(strictNamespace));
418418
}
419419

420420
return _namespaceTranslationDic.TryGetValue(strictNamespace, out transitionalNamespace);
@@ -430,7 +430,7 @@ public static bool TryGetTransitionalRelationship(string strictRelationship, out
430430
{
431431
if (strictRelationship == null)
432432
{
433-
throw new ArgumentNullException("strictRelationship");
433+
throw new ArgumentNullException(nameof(strictRelationship));
434434
}
435435

436436
return _relationshipTranslationDic.TryGetValue(strictRelationship, out transitionalRelationship);
@@ -478,7 +478,7 @@ public static byte GetNamespaceId(string namespaceUri)
478478
{
479479
if (namespaceUri == null)
480480
{
481-
throw new ArgumentNullException("namespaceUri");
481+
throw new ArgumentNullException(nameof(namespaceUri));
482482
}
483483

484484
int index = Array.IndexOf(_namespaceList, namespaceUri);
@@ -507,7 +507,7 @@ public static bool TryGetNamespaceId(string namespaceUri, out byte id)
507507
{
508508
if (namespaceUri == null)
509509
{
510-
throw new ArgumentNullException("namespaceUri");
510+
throw new ArgumentNullException(nameof(namespaceUri));
511511
}
512512

513513
int index = Array.IndexOf(_namespaceList, namespaceUri);
@@ -552,7 +552,7 @@ public static string GetNamespaceUri(string prefix)
552552
{
553553
if (prefix == null)
554554
{
555-
throw new ArgumentNullException("prefix");
555+
throw new ArgumentNullException(nameof(prefix));
556556
}
557557

558558
int index = Array.IndexOf(_namespacePrefixList, prefix);

DocumentFormat.OpenXml/src/Framework/OpenXmlAttribute.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public OpenXmlAttribute(string qualifiedName, string namespaceUri, string value)
3333
{
3434
if (String.IsNullOrEmpty(qualifiedName))
3535
{
36-
throw new ArgumentNullException("qualifiedName");
36+
throw new ArgumentNullException(nameof(qualifiedName));
3737
}
3838

3939
this._namespaceUri = namespaceUri;
@@ -53,7 +53,7 @@ public OpenXmlAttribute(string prefix, string localName, string namespaceUri, st
5353
{
5454
if (String.IsNullOrEmpty(localName))
5555
{
56-
throw new ArgumentNullException("localName");
56+
throw new ArgumentNullException(nameof(localName));
5757
}
5858

5959
this._namespaceUri = namespaceUri;

DocumentFormat.OpenXml/src/Framework/OpenXmlBasePart.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ internal void Load(OpenXmlPackage openXmlPackage, OpenXmlPart parent, Uri uriTar
5151
{
5252
if (uriTarget == null)
5353
{
54-
throw new ArgumentNullException("uriTarget");
54+
throw new ArgumentNullException(nameof(uriTarget));
5555
}
5656

5757
if (id == null)
5858
{
59-
throw new ArgumentNullException("id");
59+
throw new ArgumentNullException(nameof(id));
6060
}
6161

6262
if (openXmlPackage == null && parent == null)
@@ -66,7 +66,7 @@ internal void Load(OpenXmlPackage openXmlPackage, OpenXmlPart parent, Uri uriTar
6666
else if (parent != null && openXmlPackage != null &&
6767
parent.OpenXmlPackage != openXmlPackage)
6868
{
69-
throw new ArgumentOutOfRangeException("parent");
69+
throw new ArgumentOutOfRangeException(nameof(parent));
7070
}
7171
else if (parent != null && openXmlPackage == null)
7272
{
@@ -121,7 +121,7 @@ internal sealed override OpenXmlPart NewPart(string relationshipType, string con
121121

122122
if (contentType == null)
123123
{
124-
throw new ArgumentNullException("contentType");
124+
throw new ArgumentNullException(nameof(contentType));
125125
}
126126

127127
PartConstraintRule partConstraintRule;
@@ -148,7 +148,7 @@ internal sealed override OpenXmlPart NewPart(string relationshipType, string con
148148

149149
return child;
150150
}
151-
throw new ArgumentOutOfRangeException("relationshipType");
151+
throw new ArgumentOutOfRangeException(nameof(relationshipType));
152152
}
153153

154154
// get app specific TargetPath if exists
@@ -193,7 +193,7 @@ internal void CreateInternal(OpenXmlPackage openXmlPackage, OpenXmlPart parent,
193193
else if (parent != null && openXmlPackage != null &&
194194
parent.OpenXmlPackage != openXmlPackage)
195195
{
196-
throw new ArgumentOutOfRangeException("parent");
196+
throw new ArgumentOutOfRangeException(nameof(parent));
197197
}
198198
else if (parent != null && openXmlPackage == null)
199199
{
@@ -262,7 +262,7 @@ internal void CreateInternal2(OpenXmlPackage openXmlPackage, OpenXmlPart parent,
262262
else if (parent != null && openXmlPackage != null &&
263263
parent.OpenXmlPackage != openXmlPackage)
264264
{
265-
throw new ArgumentOutOfRangeException("parent");
265+
throw new ArgumentOutOfRangeException(nameof(parent));
266266
}
267267
else if (parent != null && openXmlPackage == null)
268268
{
@@ -407,7 +407,7 @@ public void FeedData(Stream sourceStream)
407407

408408
if (sourceStream == null)
409409
{
410-
throw new ArgumentNullException("sourceStream");
410+
throw new ArgumentNullException(nameof(sourceStream));
411411
}
412412

413413
using (Stream targetStream = this.GetStream(FileMode.Create))
@@ -449,7 +449,7 @@ public void ValidateXml(XmlSchemaSet schemas, ValidationEventHandler validationE
449449

450450
if (schemas == null)
451451
{
452-
throw new ArgumentNullException("schemas");
452+
throw new ArgumentNullException(nameof(schemas));
453453
}
454454

455455
XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();
@@ -491,7 +491,7 @@ public void ValidateXml(string schemaFile, ValidationEventHandler validationEven
491491

492492
if (schemaFile == null)
493493
{
494-
throw new ArgumentNullException("schemaFile");
494+
throw new ArgumentNullException(nameof(schemaFile));
495495
}
496496

497497
XmlSchemaSet schemas = new XmlSchemaSet();
@@ -580,7 +580,7 @@ internal sealed override void FindAllReachableParts(IDictionary<OpenXmlPart, boo
580580

581581
if (reachableParts == null)
582582
{
583-
throw new ArgumentNullException("reachableParts");
583+
throw new ArgumentNullException(nameof(reachableParts));
584584
}
585585

586586
reachableParts.Add(this, false);
@@ -860,7 +860,7 @@ internal static void CopyStream(Stream sourceStream, Stream targetStream)
860860
{
861861
if (sourceStream == null)
862862
{
863-
throw new ArgumentNullException("sourceStream");
863+
throw new ArgumentNullException(nameof(sourceStream));
864864
}
865865

866866
using (BinaryReader sourceReader = new BinaryReader(sourceStream))

DocumentFormat.OpenXml/src/Framework/OpenXmlCompositeElement.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ protected OpenXmlCompositeElement(IEnumerable childrenElements)
6969
{
7070
if (childrenElements == null)
7171
{
72-
throw new ArgumentNullException("childrenElements");
72+
throw new ArgumentNullException(nameof(childrenElements));
7373
}
7474

7575
foreach (OpenXmlElement child in childrenElements)
@@ -88,7 +88,7 @@ protected OpenXmlCompositeElement(IEnumerable<OpenXmlElement> childrenElements)
8888
{
8989
if (childrenElements == null)
9090
{
91-
throw new ArgumentNullException("childrenElements");
91+
throw new ArgumentNullException(nameof(childrenElements));
9292
}
9393

9494
foreach (OpenXmlElement child in childrenElements)
@@ -106,7 +106,7 @@ protected OpenXmlCompositeElement(params OpenXmlElement[] childrenElements)
106106
{
107107
if (childrenElements == null)
108108
{
109-
throw new ArgumentNullException("childrenElements");
109+
throw new ArgumentNullException(nameof(childrenElements));
110110
}
111111

112112
foreach (OpenXmlElement child in childrenElements)
@@ -251,7 +251,7 @@ public override T AppendChild<T>(T newChild)
251251
{
252252
if (newChild == null)
253253
{
254-
// throw new ArgumentNullException("newChild");
254+
// throw new ArgumentNullException(nameof(newChild));
255255
return null;
256256
}
257257

@@ -297,7 +297,7 @@ public override T InsertAfter<T>(T newChild, OpenXmlElement refChild)
297297
{
298298
if (newChild == null)
299299
{
300-
// throw new ArgumentNullException("newChild");
300+
// throw new ArgumentNullException(nameof(newChild));
301301
return null;
302302
}
303303

@@ -356,7 +356,7 @@ public override T InsertBefore<T>(T newChild, OpenXmlElement refChild)
356356
{
357357
if (newChild == null)
358358
{
359-
// throw new ArgumentNullException("newChild");
359+
// throw new ArgumentNullException(nameof(newChild));
360360
return null;
361361
}
362362

@@ -415,7 +415,7 @@ public override T InsertAt<T>(T newChild, int index)
415415
{
416416
if (newChild == null)
417417
{
418-
// throw new ArgumentNullException("newChild");
418+
// throw new ArgumentNullException(nameof(newChild));
419419
return null;
420420
}
421421

@@ -426,7 +426,7 @@ public override T InsertAt<T>(T newChild, int index)
426426

427427
if (index < 0 || index > this.ChildElements.Count)
428428
{
429-
throw new ArgumentOutOfRangeException("index");
429+
throw new ArgumentOutOfRangeException(nameof(index));
430430
}
431431
else if ( index == 0 )
432432
{
@@ -453,7 +453,7 @@ public override T PrependChild<T>(T newChild)
453453
{
454454
if (newChild == null)
455455
{
456-
//throw new ArgumentNullException("newChild");
456+
//throw new ArgumentNullException(nameof(newChild));
457457
return null;
458458
}
459459

@@ -475,7 +475,7 @@ public override T RemoveChild<T>(T oldChild)
475475
{
476476
if (oldChild == null)
477477
{
478-
// throw new ArgumentNullException("oldChild");
478+
// throw new ArgumentNullException(nameof(oldChild));
479479
return null;
480480
}
481481

@@ -559,13 +559,13 @@ public override T ReplaceChild<T>(OpenXmlElement newChild, T oldChild)
559559
{
560560
if (oldChild == null)
561561
{
562-
//throw new ArgumentNullException("oldChild");
562+
//throw new ArgumentNullException(nameof(oldChild));
563563
return null;
564564
}
565565

566566
if (newChild == null)
567567
{
568-
throw new ArgumentNullException("newChild");
568+
throw new ArgumentNullException(nameof(newChild));
569569
}
570570

571571
if (oldChild.Parent != this)

0 commit comments

Comments
 (0)