@@ -139,6 +139,9 @@ private static string ToString(IList<DoubleUtf16Char> source, int start, int cou
139139 /// <returns>An <see cref="IEnumerable{TextPart}"/> whose elements are parts of <paramref name="text"/>.</returns>
140140 public static IEnumerable < TextPart > EnumerateTextParts ( string text , Entities entities )
141141 {
142+ if ( text == null )
143+ throw new ArgumentNullException ( nameof ( text ) ) ;
144+
142145 var chars = GetCodePoints ( text ) ;
143146 return EnumerateTextParts ( chars , entities , 0 , chars . Count ) ;
144147 }
@@ -153,6 +156,9 @@ public static IEnumerable<TextPart> EnumerateTextParts(string text, Entities ent
153156 /// <returns>An <see cref="IEnumerable{TextPart}"/> whose elements are parts of <paramref name="text"/>.</returns>
154157 public static IEnumerable < TextPart > EnumerateTextParts ( string text , Entities entities , int startIndex , int endIndex )
155158 {
159+ if ( text == null )
160+ throw new ArgumentNullException ( nameof ( text ) ) ;
161+
156162 var chars = GetCodePoints ( text ) ;
157163
158164 if ( startIndex < 0 || startIndex >= chars . Count )
@@ -166,6 +172,8 @@ public static IEnumerable<TextPart> EnumerateTextParts(string text, Entities ent
166172
167173 private static IEnumerable < TextPart > EnumerateTextParts ( IList < DoubleUtf16Char > chars , Entities entities , int startIndex , int endIndex )
168174 {
175+ if ( startIndex == endIndex ) yield break ;
176+
169177 if ( entities == null )
170178 {
171179 var text = ToString ( chars , startIndex , endIndex - startIndex ) ;
@@ -185,7 +193,7 @@ private static IEnumerable<TextPart> EnumerateTextParts(IList<DoubleUtf16Char> c
185193 }
186194
187195 var list = new LinkedList < TextPart > (
188- ( entities . HashTags ?? Enumerable . Empty < SymbolEntity > ( ) )
196+ ( entities . HashTags ?? Enumerable . Empty < HashtagEntity > ( ) )
189197 . Select ( e => new TextPart ( )
190198 {
191199 Type = TextPartType . Hashtag ,
@@ -196,7 +204,7 @@ private static IEnumerable<TextPart> EnumerateTextParts(IList<DoubleUtf16Char> c
196204 Entity = e
197205 } )
198206 . Concat (
199- ( entities . Symbols ?? Enumerable . Empty < SymbolEntity > ( ) )
207+ ( entities . Symbols ?? Enumerable . Empty < CashtagEntity > ( ) )
200208 . Select ( e => new TextPart ( )
201209 {
202210 Type = TextPartType . Cashtag ,
0 commit comments