1- using System ;
2- using System . Collections . Generic ;
3- using System . Linq ;
4- using System . Text ;
5- using System . Threading . Tasks ;
1+ using System . Diagnostics . CodeAnalysis ;
62using MwParserFromScratch . Nodes ;
73
84namespace MwParserFromScratch ;
@@ -15,7 +11,8 @@ public static class MwParserUtility
1511
1612 /// <inheritdoc cref="NormalizeTemplateArgumentName(string)"/>
1713 /// <param name="argumentName">The argument name to be normalized. The node will be converted into its string representation.</param>
18- public static string NormalizeTemplateArgumentName ( Node argumentName )
14+ [ return : NotNullIfNotNull ( nameof ( argumentName ) ) ]
15+ public static string ? NormalizeTemplateArgumentName ( Node ? argumentName )
1916 {
2017 if ( argumentName == null ) return null ;
2118 return NormalizeTemplateArgumentName ( argumentName . ToString ( ) ) ;
@@ -27,18 +24,20 @@ public static string NormalizeTemplateArgumentName(Node argumentName)
2724 /// <param name="argumentName">The argument name to be normalized.</param>
2825 /// <returns>The normalized argument name, with leading and trailing whitespace removed,
2926 /// or <c>null</c> if <paramref name="argumentName"/> is <c>null</c>.</returns>
30- public static string NormalizeTemplateArgumentName ( string argumentName )
27+ [ return : NotNullIfNotNull ( nameof ( argumentName ) ) ]
28+ public static string ? NormalizeTemplateArgumentName ( string ? argumentName )
3129 {
3230 if ( string . IsNullOrEmpty ( argumentName ) ) return argumentName ;
3331 return argumentName . Trim ( ) ;
3432 }
3533
3634 /// <inheritdoc cref="NormalizeImageLinkArgumentName(string)"/>
3735 /// <param name="argumentName">The argument name to be normalized. The node will be converted into its string representation.</param>
38- public static string NormalizeImageLinkArgumentName ( Node argumentName )
36+ [ return : NotNullIfNotNull ( nameof ( argumentName ) ) ]
37+ public static string ? NormalizeImageLinkArgumentName ( Node ? argumentName )
3938 {
4039 if ( argumentName == null ) return null ;
41- return NormalizeImageLinkArgumentName ( argumentName . ToString ( ) ) ;
40+ return NormalizeImageLinkArgumentName ( argumentName . ToString ( ) ! ) ;
4241 }
4342
4443 /// <summary>
@@ -47,7 +46,8 @@ public static string NormalizeImageLinkArgumentName(Node argumentName)
4746 /// <param name="argumentName">The argument name to be normalized.</param>
4847 /// <returns>The normalized argument name, with leading and trailing whitespace removed, and first letter converted into lowercase
4948 /// or <c>null</c> if <paramref name="argumentName"/> is <c>null</c>.</returns>
50- public static string NormalizeImageLinkArgumentName ( string argumentName )
49+ [ return : NotNullIfNotNull ( nameof ( argumentName ) ) ]
50+ public static string ? NormalizeImageLinkArgumentName ( string ? argumentName )
5151 {
5252 if ( string . IsNullOrEmpty ( argumentName ) ) return argumentName ;
5353 argumentName = argumentName . Trim ( ) ;
@@ -61,7 +61,7 @@ public static string NormalizeImageLinkArgumentName(string argumentName)
6161
6262 /// <inheritdoc cref="NormalizeTitle(string)"/>
6363 /// <param name="title">The title to be normalized. The node will be converted into its string representation.</param>
64- public static string NormalizeTitle ( Node title )
64+ public static string ? NormalizeTitle ( Node ? title )
6565 {
6666 if ( title == null ) return null ;
6767 return NormalizeTitle ( title . ToString ( ) ) ;
@@ -77,12 +77,13 @@ public static string NormalizeTitle(Node title)
7777 /// <returns>The normalized argument name, with leading and trailing whitespace removed,
7878 /// underscore replaced with space, starting with an upper-case letter.
7979 /// Or <c>null</c> if <paramref name="title"/> is <c>null</c>.</returns>
80- public static string NormalizeTitle ( string title )
80+ public static string ? NormalizeTitle ( string ? title )
8181 {
8282 if ( string . IsNullOrEmpty ( title ) ) return title ;
83- var parts = title . Split ( new [ ] { ':' } , 2 ) ;
83+ var parts = title . Split ( [ ':' ] , 2 ) ;
8484 for ( int i = 0 ; i < parts . Length ; i ++ )
8585 parts [ i ] = Utility . NormalizeTitlePart ( parts [ i ] , false ) ;
8686 return string . Join ( ":" , parts ) ;
8787 }
88+
8889}
0 commit comments