46 {
48 {
49 throw new ArgumentNullException("format");
50 }
51 int num = 0;
53 char c = '\0';
54 ICustomFormatter customFormatter = (ICustomFormatter)(provider?.GetFormat(typeof(ICustomFormatter)));
55 while (true)
56 {
58 {
60 num++;
61 if (c == '}')
62 {
64 {
65 num++;
66 }
67 else
68 {
70 }
71 }
72 else if (c == '{')
73 {
75 {
76 num--;
77 goto IL_008f;
78 }
79 num++;
80 }
82 continue;
83 }
84 goto IL_008f;
85 IL_008f:
87 {
88 break;
89 }
90 num++;
92 {
94 }
95 int num2 = 0;
96 do
97 {
98 num2 = num2 * 10 + c - 48;
99 num++;
101 {
103 }
105 }
106 while (c >= '0' && c <= '9' && num2 < 1000000);
107 if (num2 >= args.Length)
108 {
109 throw new FormatException(SR.Format_IndexOutOfRange);
110 }
111 for (; num <
length; num++)
112 {
113 if ((c =
format[num]) !=
' ')
114 {
115 break;
116 }
117 }
118 bool flag = false;
119 int num3 = 0;
120 if (c == ',')
121 {
123 {
124 }
126 {
128 }
130 if (c == '-')
131 {
132 flag = true;
133 num++;
135 {
137 }
139 }
140 if (c < '0' || c > '9')
141 {
143 }
144 do
145 {
146 num3 = num3 * 10 + c - 48;
147 num++;
149 {
151 }
153 }
154 while (c >= '0' && c <= '9' && num3 < 1000000);
155 }
156 for (; num <
length; num++)
157 {
158 if ((c =
format[num]) !=
' ')
159 {
160 break;
161 }
162 }
163 object obj = args[num2];
164 ReadOnlySpan<char> readOnlySpan = default(ReadOnlySpan<char>);
165 switch (c)
166 {
167 case ':':
168 {
169 num++;
170 int num4 = num;
171 while (true)
172 {
174 {
176 }
178 switch (c)
179 {
180 case '{':
182 goto IL_0205;
183 default:
184 goto IL_0205;
185 case '}':
186 break;
187 }
188 break;
189 IL_0205:
190 num++;
191 }
192 if (num > num4)
193 {
194 readOnlySpan =
format.AsSpan(num4, num - num4);
195 }
196 break;
197 }
198 default:
200 break;
201 case '}':
202 break;
203 }
204 num++;
206 string text2 = null;
207 if (customFormatter != null)
208 {
209 if (readOnlySpan.Length != 0)
210 {
211 text2 =
new string(readOnlySpan);
212 }
213 text = customFormatter.Format(text2,
obj, provider);
214 }
216 {
217 if (
obj is ISpanFormattable spanFormattable && (flag || num3 == 0) && spanFormattable.TryFormat(
_chars.
Slice(
_pos), out var charsWritten, readOnlySpan, provider))
218 {
219 _pos += charsWritten;
220 int num5 = num3 - charsWritten;
221 if (flag && num5 > 0)
222 {
224 }
225 continue;
226 }
227 if (
obj is IFormattable formattable)
228 {
229 if (readOnlySpan.Length != 0 && text2 == null)
230 {
231 text2 =
new string(readOnlySpan);
232 }
233 text = formattable.ToString(text2, provider);
234 }
235 else if (
obj !=
null)
236 {
238 }
239 }
241 {
243 }
244 int num6 = num3 -
text.Length;
245 if (!flag && num6 > 0)
246 {
248 }
250 if (flag && num6 > 0)
251 {
253 }
254 }
255 }
Span< T > Slice(int start)
static void ThrowFormatError()