@@ -28,7 +28,7 @@ public sealed class NbtFile {
2828 public NbtCompound RootTag {
2929 get { return rootTag ; }
3030 set {
31- if ( value == null ) throw new ArgumentNullException ( " value" ) ;
31+ if ( value == null ) throw new ArgumentNullException ( nameof ( value ) ) ;
3232 if ( value . Name == null ) throw new ArgumentException ( "Root tag must be named." ) ;
3333 rootTag = value ;
3434 }
@@ -50,7 +50,7 @@ public static int DefaultBufferSize {
5050 get { return defaultBufferSize ; }
5151 set {
5252 if ( value < 0 ) {
53- throw new ArgumentOutOfRangeException ( " value" , value , "DefaultBufferSize cannot be negative." ) ;
53+ throw new ArgumentOutOfRangeException ( nameof ( value ) , value , "DefaultBufferSize cannot be negative." ) ;
5454 }
5555 defaultBufferSize = value ;
5656 }
@@ -65,7 +65,7 @@ public int BufferSize {
6565 get { return bufferSize ; }
6666 set {
6767 if ( value < 0 ) {
68- throw new ArgumentOutOfRangeException ( " value" , value , "BufferSize cannot be negative." ) ;
68+ throw new ArgumentOutOfRangeException ( nameof ( value ) , value , "BufferSize cannot be negative." ) ;
6969 }
7070 bufferSize = value ;
7171 }
@@ -96,7 +96,7 @@ public NbtFile() {
9696 /// <exception cref="ArgumentException"> If given <paramref name="rootTag"/> is unnamed. </exception>
9797 public NbtFile ( [ NotNull ] NbtCompound rootTag )
9898 : this ( ) {
99- if ( rootTag == null ) throw new ArgumentNullException ( " rootTag" ) ;
99+ if ( rootTag == null ) throw new ArgumentNullException ( nameof ( rootTag ) ) ;
100100 RootTag = rootTag ;
101101 }
102102
@@ -112,7 +112,7 @@ public NbtFile([NotNull] NbtCompound rootTag)
112112 /// <exception cref="IOException"> If an I/O error occurred while reading the file. </exception>
113113 public NbtFile ( [ NotNull ] string fileName )
114114 : this ( ) {
115- if ( fileName == null ) throw new ArgumentNullException ( " fileName" ) ;
115+ if ( fileName == null ) throw new ArgumentNullException ( nameof ( fileName ) ) ;
116116 LoadFromFile ( fileName , NbtCompression . AutoDetect , null ) ;
117117 }
118118
@@ -149,7 +149,7 @@ public long LoadFromFile([NotNull] string fileName) {
149149 /// <exception cref="NbtFormatException"> If an error occurred while parsing data in NBT format. </exception>
150150 /// <exception cref="IOException"> If an I/O error occurred while reading the file. </exception>
151151 public long LoadFromFile ( [ NotNull ] string fileName , NbtCompression compression , [ CanBeNull ] TagSelector selector ) {
152- if ( fileName == null ) throw new ArgumentNullException ( " fileName" ) ;
152+ if ( fileName == null ) throw new ArgumentNullException ( nameof ( fileName ) ) ;
153153
154154 using (
155155 var readFileStream = new FileStream ( fileName ,
@@ -183,7 +183,7 @@ public long LoadFromFile([NotNull] string fileName, NbtCompression compression,
183183 /// <exception cref="NbtFormatException"> If an error occurred while parsing data in NBT format. </exception>
184184 public long LoadFromBuffer ( [ NotNull ] byte [ ] buffer , int index , int length , NbtCompression compression ,
185185 [ CanBeNull ] TagSelector selector ) {
186- if ( buffer == null ) throw new ArgumentNullException ( " buffer" ) ;
186+ if ( buffer == null ) throw new ArgumentNullException ( nameof ( buffer ) ) ;
187187
188188 using ( var ms = new MemoryStream ( buffer , index , length ) ) {
189189 LoadFromStream ( ms , compression , selector ) ;
@@ -208,7 +208,7 @@ public long LoadFromBuffer([NotNull] byte[] buffer, int index, int length, NbtCo
208208 /// <exception cref="InvalidDataException"> If file compression could not be detected or decompressing failed. </exception>
209209 /// <exception cref="NbtFormatException"> If an error occurred while parsing data in NBT format. </exception>
210210 public long LoadFromBuffer ( [ NotNull ] byte [ ] buffer , int index , int length , NbtCompression compression ) {
211- if ( buffer == null ) throw new ArgumentNullException ( " buffer" ) ;
211+ if ( buffer == null ) throw new ArgumentNullException ( nameof ( buffer ) ) ;
212212
213213 using ( var ms = new MemoryStream ( buffer , index , length ) ) {
214214 LoadFromStream ( ms , compression , null ) ;
@@ -231,7 +231,7 @@ public long LoadFromBuffer([NotNull] byte[] buffer, int index, int length, NbtCo
231231 /// <exception cref="InvalidDataException"> If file compression could not be detected, decompressing failed, or given stream does not support reading. </exception>
232232 /// <exception cref="NbtFormatException"> If an error occurred while parsing data in NBT format. </exception>
233233 public long LoadFromStream ( [ NotNull ] Stream stream , NbtCompression compression , [ CanBeNull ] TagSelector selector ) {
234- if ( stream == null ) throw new ArgumentNullException ( " stream" ) ;
234+ if ( stream == null ) throw new ArgumentNullException ( nameof ( stream ) ) ;
235235
236236 FileName = null ;
237237
@@ -280,7 +280,7 @@ public long LoadFromStream([NotNull] Stream stream, NbtCompression compression,
280280 break ;
281281
282282 default :
283- throw new ArgumentOutOfRangeException ( " compression" ) ;
283+ throw new ArgumentOutOfRangeException ( nameof ( compression ) ) ;
284284 }
285285
286286 // report bytes read
@@ -375,7 +375,7 @@ void LoadFromStreamInternal([NotNull] Stream stream, [CanBeNull] TagSelector tag
375375 /// <exception cref="NbtFormatException"> If one of the NbtCompound tags contained unnamed tags;
376376 /// or if an NbtList tag had Unknown list type and no elements. </exception>
377377 public long SaveToFile ( [ NotNull ] string fileName , NbtCompression compression ) {
378- if ( fileName == null ) throw new ArgumentNullException ( " fileName" ) ;
378+ if ( fileName == null ) throw new ArgumentNullException ( nameof ( fileName ) ) ;
379379
380380 using (
381381 var saveFile = new FileStream ( fileName ,
@@ -403,7 +403,7 @@ public long SaveToFile([NotNull] string fileName, NbtCompression compression) {
403403 /// <exception cref="NbtFormatException"> If one of the NbtCompound tags contained unnamed tags;
404404 /// or if an NbtList tag had Unknown list type and no elements. </exception>
405405 public long SaveToBuffer ( [ NotNull ] byte [ ] buffer , int index , NbtCompression compression ) {
406- if ( buffer == null ) throw new ArgumentNullException ( " buffer" ) ;
406+ if ( buffer == null ) throw new ArgumentNullException ( nameof ( buffer ) ) ;
407407
408408 using ( var ms = new MemoryStream ( buffer , index , buffer . Length - index ) ) {
409409 return SaveToStream ( ms , compression ) ;
@@ -442,7 +442,7 @@ public byte[] SaveToBuffer(NbtCompression compression) {
442442 /// or if one of the NbtCompound tags contained unnamed tags;
443443 /// or if an NbtList tag had Unknown list type and no elements. </exception>
444444 public long SaveToStream ( [ NotNull ] Stream stream , NbtCompression compression ) {
445- if ( stream == null ) throw new ArgumentNullException ( " stream" ) ;
445+ if ( stream == null ) throw new ArgumentNullException ( nameof ( stream ) ) ;
446446
447447 switch ( compression ) {
448448 case NbtCompression . AutoDetect :
@@ -452,7 +452,7 @@ public long SaveToStream([NotNull] Stream stream, NbtCompression compression) {
452452 case NbtCompression . None :
453453 break ;
454454 default :
455- throw new ArgumentOutOfRangeException ( " compression" ) ;
455+ throw new ArgumentOutOfRangeException ( nameof ( compression ) ) ;
456456 }
457457
458458 if ( rootTag . Name == null ) {
@@ -546,13 +546,13 @@ public static string ReadRootTagName([NotNull] string fileName) {
546546 public static string ReadRootTagName ( [ NotNull ] string fileName , NbtCompression compression , bool bigEndian ,
547547 int bufferSize ) {
548548 if ( fileName == null ) {
549- throw new ArgumentNullException ( " fileName" ) ;
549+ throw new ArgumentNullException ( nameof ( fileName ) ) ;
550550 }
551551 if ( ! File . Exists ( fileName ) ) {
552552 throw new FileNotFoundException ( "Could not find the given NBT file." , fileName ) ;
553553 }
554554 if ( bufferSize < 0 ) {
555- throw new ArgumentOutOfRangeException ( " bufferSize" , bufferSize , "DefaultBufferSize cannot be negative." ) ;
555+ throw new ArgumentOutOfRangeException ( nameof ( bufferSize ) , bufferSize , "DefaultBufferSize cannot be negative." ) ;
556556 }
557557 using ( FileStream readFileStream = File . OpenRead ( fileName ) ) {
558558 return ReadRootTagName ( readFileStream , compression , bigEndian , bufferSize ) ;
@@ -575,9 +575,9 @@ public static string ReadRootTagName([NotNull] string fileName, NbtCompression c
575575 [ NotNull ]
576576 public static string ReadRootTagName ( [ NotNull ] Stream stream , NbtCompression compression , bool bigEndian ,
577577 int bufferSize ) {
578- if ( stream == null ) throw new ArgumentNullException ( " stream" ) ;
578+ if ( stream == null ) throw new ArgumentNullException ( nameof ( stream ) ) ;
579579 if ( bufferSize < 0 ) {
580- throw new ArgumentOutOfRangeException ( " bufferSize" , bufferSize , "DefaultBufferSize cannot be negative." ) ;
580+ throw new ArgumentOutOfRangeException ( nameof ( bufferSize ) , bufferSize , "DefaultBufferSize cannot be negative." ) ;
581581 }
582582 // detect compression, based on the first byte
583583 if ( compression == NbtCompression . AutoDetect ) {
@@ -611,7 +611,7 @@ public static string ReadRootTagName([NotNull] Stream stream, NbtCompression com
611611 }
612612
613613 default :
614- throw new ArgumentOutOfRangeException ( " compression" ) ;
614+ throw new ArgumentOutOfRangeException ( nameof ( compression ) ) ;
615615 }
616616 }
617617
0 commit comments