* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / System / Test / System.ComponentModel / Int16ConverterTests.cs
1 //
2 // System.ComponentModel.Int16Converter test cases
3 //
4 // Authors:
5 //      Gert Driesen (drieseng@users.sourceforge.net)
6 //
7 // (c) 2005 Novell, Inc. (http://www.ximian.com)
8 //
9
10 using System;
11 using System.ComponentModel;
12 using System.ComponentModel.Design.Serialization;
13 using System.Globalization;
14
15 using NUnit.Framework;
16
17 namespace MonoTests.System.ComponentModel
18 {
19         [TestFixture]
20         public class Int16ConverterTests
21         {
22                 private Int16Converter converter;
23                 
24                 [SetUp]
25                 public void SetUp ()
26                 {
27                         converter = new Int16Converter ();
28                 }
29
30                 [Test]
31                 public void CanConvertFrom ()
32                 {
33                         Assert.IsTrue (converter.CanConvertFrom (typeof (string)), "#1");
34                         Assert.IsFalse (converter.CanConvertFrom (typeof (short)), "#2");
35                         Assert.IsFalse (converter.CanConvertFrom (typeof (object)), "#3");
36                         Assert.IsTrue (converter.CanConvertFrom (typeof (InstanceDescriptor)), "#4");
37                 }
38
39                 [Test]
40                 public void CanConvertTo ()
41                 {
42                         Assert.IsTrue (converter.CanConvertTo (typeof (string)), "#1");
43                         Assert.IsFalse (converter.CanConvertTo (typeof (object)), "#2");
44                 }
45
46                 [Test]
47                 public void ConvertFrom_MinValue ()
48                 {
49                         Assert.AreEqual (short.MinValue, converter.ConvertFrom (null, CultureInfo.InvariantCulture, "#8000"), "#1");
50                         Assert.AreEqual (short.MinValue, converter.ConvertFrom (null, CultureInfo.InvariantCulture, "#0x8000"), "#2");
51                         Assert.AreEqual (short.MinValue, converter.ConvertFrom (null, CultureInfo.InvariantCulture, "#0X8000"), "#3");
52                         Assert.AreEqual (short.MinValue, converter.ConvertFrom (null, CultureInfo.InvariantCulture, "0x8000"), "#4");
53                         Assert.AreEqual (short.MinValue, converter.ConvertFrom (null, CultureInfo.InvariantCulture, "0X8000"), "#5");
54                 }
55
56                 [Test]
57                 public void ConvertFrom_MaxValue ()
58                 {
59                         Assert.AreEqual (short.MaxValue, converter.ConvertFrom (null, CultureInfo.InvariantCulture, "#7fff"), "#1");
60                         Assert.AreEqual (short.MaxValue, converter.ConvertFrom (null, CultureInfo.InvariantCulture, "#7FFF"), "#2");
61                         Assert.AreEqual (short.MaxValue, converter.ConvertFrom (null, CultureInfo.InvariantCulture, "#0x7fff"), "#3");
62                         Assert.AreEqual (short.MaxValue, converter.ConvertFrom (null, CultureInfo.InvariantCulture, "#0X7FFF"), "#4");
63                         Assert.AreEqual (short.MaxValue, converter.ConvertFrom (null, CultureInfo.InvariantCulture, "0x7fff"), "#5");
64                         Assert.AreEqual (short.MaxValue, converter.ConvertFrom (null, CultureInfo.InvariantCulture, "0X7FFF"), "#6");
65                 }
66
67                 [Test]
68                 public void ConvertToString ()
69                 {
70                         CultureInfo culture = new MyCultureInfo ();
71                         NumberFormatInfo numberFormatInfo = (NumberFormatInfo) culture.GetFormat (typeof (NumberFormatInfo));
72
73                         Assert.AreEqual (numberFormatInfo.NegativeSign + "5", converter.ConvertToString (null, culture, (short) -5), "#1");
74                         Assert.AreEqual (culture.NumberFormat.NegativeSign + "5", converter.ConvertToString (null, culture, (int) -5), "#2");
75                 }
76
77                 [Test]
78                 public void ConvertFromString ()
79                 {
80                         CultureInfo culture = new MyCultureInfo ();
81                         NumberFormatInfo numberFormatInfo = (NumberFormatInfo) culture.GetFormat (typeof (NumberFormatInfo));
82
83                         Assert.AreEqual (-5, converter.ConvertFrom (null, culture, numberFormatInfo.NegativeSign + "5"));
84                 }
85
86                 [Test]
87                 [ExpectedException (typeof (NotSupportedException))]
88                 public void ConvertFrom_Object ()
89                 {
90                         converter.ConvertFrom (new object ());
91                 }
92
93                 [Test]
94                 [ExpectedException (typeof (NotSupportedException))]
95                 public void ConvertFrom_Int16 ()
96                 {
97                         converter.ConvertFrom ((short) 10);
98                 }
99
100                 [Test]
101                 [ExpectedException (typeof (NotSupportedException))]
102                 public void ConvertFrom_Int32 ()
103                 {
104                         converter.ConvertFrom (10);
105                 }
106
107                 [Test]
108                 public void ConvertTo_MinValue ()
109                 {
110                         Assert.AreEqual (short.MinValue.ToString (CultureInfo.InvariantCulture),
111                                 converter.ConvertTo (null, CultureInfo.InvariantCulture, short.MinValue,
112                                 typeof (string)), "#1");
113                         Assert.AreEqual (short.MinValue.ToString (CultureInfo.CurrentCulture),
114                                 converter.ConvertTo (null, CultureInfo.CurrentCulture, short.MinValue,
115                                 typeof (string)), "#2");
116                         Assert.AreEqual (short.MinValue.ToString (CultureInfo.CurrentCulture),
117                                 converter.ConvertTo (short.MinValue, typeof (string)), "#3");
118                 }
119
120                 [Test]
121                 public void ConvertTo_MaxValue ()
122                 {
123                         Assert.AreEqual (short.MaxValue.ToString (CultureInfo.InvariantCulture),
124                                 converter.ConvertTo (null, CultureInfo.InvariantCulture, short.MaxValue,
125                                 typeof (string)), "#1");
126                         Assert.AreEqual (short.MaxValue.ToString (CultureInfo.CurrentCulture),
127                                 converter.ConvertTo (null, CultureInfo.CurrentCulture, short.MaxValue,
128                                 typeof (string)), "#2");
129                         Assert.AreEqual (short.MaxValue.ToString (CultureInfo.CurrentCulture),
130                                 converter.ConvertTo (short.MaxValue, typeof (string)), "#3");
131                 }
132
133                 [Test]
134                 public void ConvertToString_MinValue ()
135                 {
136                         Assert.AreEqual (short.MinValue.ToString (CultureInfo.InvariantCulture),
137                                 converter.ConvertToString (null, CultureInfo.InvariantCulture,
138                                 short.MinValue), "#1");
139
140                         Assert.AreEqual (short.MinValue.ToString (CultureInfo.CurrentCulture),
141                                 converter.ConvertToString (null, short.MinValue), "#2");
142                         Assert.AreEqual (short.MinValue.ToString (CultureInfo.CurrentCulture),
143                                 converter.ConvertToString (null, CultureInfo.CurrentCulture,
144                                 short.MinValue), "#3");
145                         Assert.AreEqual (short.MinValue.ToString (CultureInfo.CurrentCulture),
146                                 converter.ConvertToString (short.MinValue), "#4");
147                 }
148
149                 [Test]
150                 public void ConvertToString_MaxValue ()
151                 {
152                         Assert.AreEqual (short.MaxValue.ToString (CultureInfo.InvariantCulture),
153                                 converter.ConvertToString (null, CultureInfo.InvariantCulture,
154                                 short.MaxValue), "#1");
155
156                         Assert.AreEqual (short.MaxValue.ToString (CultureInfo.CurrentCulture),
157                                 converter.ConvertToString (null, short.MaxValue), "#2");
158                         Assert.AreEqual (short.MaxValue.ToString (CultureInfo.CurrentCulture),
159                                 converter.ConvertToString (null, CultureInfo.CurrentCulture,
160                                 short.MaxValue), "#3");
161                         Assert.AreEqual (short.MaxValue.ToString (CultureInfo.CurrentCulture),
162                                 converter.ConvertToString (short.MaxValue), "#4");
163                 }
164
165                 [Test]
166                 public void ConvertFrom_InvalidValue ()
167                 {
168                         try {
169                                 converter.ConvertFrom ("*1");
170                                 Assert.Fail ("#1");
171                         } catch (AssertionException) {
172                                 throw;
173                         } catch (Exception ex) {
174                                 Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
175                                 Assert.IsNotNull (ex.InnerException, "#3");
176                                 Assert.AreEqual (typeof (FormatException), ex.InnerException.GetType (), "#3");
177                         }
178                 }
179
180                 [Test]
181                 public void ConvertFrom_InvalidValue_Invariant ()
182                 {
183                         try {
184                                 converter.ConvertFrom (null, CultureInfo.InvariantCulture, "*1");
185                                 Assert.Fail ("#1");
186                         } catch (AssertionException) {
187                                 throw;
188                         } catch (Exception ex) {
189                                 Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
190                                 Assert.IsNotNull (ex.InnerException, "#3");
191                                 Assert.AreEqual (typeof (FormatException), ex.InnerException.GetType (), "#3");
192                         }
193                 }
194
195                 [Test]
196                 public void ConvertFrom_Base10_MinOverflow ()
197                 {
198                         string minOverflow = ((int) (short.MinValue - 1)).ToString (
199                                 CultureInfo.CurrentCulture);
200
201                         try {
202                                 converter.ConvertFrom (minOverflow);
203                                 Assert.Fail ("#1");
204                         } catch (AssertionException) {
205                                 throw;
206                         } catch (Exception ex) {
207                                 Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
208                                 Assert.IsNotNull (ex.InnerException, "#3");
209                                 Assert.AreEqual (typeof (OverflowException), ex.InnerException.GetType (), "#3");
210                         }
211                 }
212
213                 [Test]
214                 public void ConvertFrom_Base10_MinOverflow_Invariant ()
215                 {
216                         string minOverflow = ((int) (short.MinValue - 1)).ToString (
217                                 CultureInfo.InvariantCulture);
218
219                         try {
220                                 converter.ConvertFrom (null, CultureInfo.InvariantCulture,
221                                         minOverflow);
222                                 Assert.Fail ("#1");
223                         } catch (AssertionException) {
224                                 throw;
225                         } catch (Exception ex) {
226                                 Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
227                                 Assert.IsNotNull (ex.InnerException, "#3");
228                                 Assert.AreEqual (typeof (OverflowException), ex.InnerException.GetType (), "#3");
229                         }
230                 }
231
232                 [Test]
233                 public void ConvertFrom_Base10_MaxOverflow ()
234                 {
235                         string maxOverflow = ((int) (short.MaxValue + 1)).ToString (
236                                 CultureInfo.CurrentCulture);
237
238                         try {
239                                 converter.ConvertFrom (maxOverflow);
240                                 Assert.Fail ("#1");
241                         } catch (AssertionException) {
242                                 throw;
243                         } catch (Exception ex) {
244                                 Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
245                                 Assert.IsNotNull (ex.InnerException, "#3");
246                                 Assert.AreEqual (typeof (OverflowException), ex.InnerException.GetType (), "#3");
247                         }
248                 }
249
250                 [Test]
251                 public void ConvertFrom_Base10_MaxOverflow_Invariant ()
252                 {
253                         string maxOverflow = ((int) (short.MaxValue + 1)).ToString (
254                                 CultureInfo.InvariantCulture);
255
256                         try {
257                                 converter.ConvertFrom (null, CultureInfo.InvariantCulture,
258                                         maxOverflow);
259                                 Assert.Fail ("#1");
260                         } catch (AssertionException) {
261                                 throw;
262                         } catch (Exception ex) {
263                                 Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
264                                 Assert.IsNotNull (ex.InnerException, "#3");
265                                 Assert.AreEqual (typeof (OverflowException), ex.InnerException.GetType (), "#3");
266                         }
267                 }
268
269                 [Test]
270                 public void ConvertFrom_Base16_MinOverflow ()
271                 {
272                         string minOverflow = ((int) (short.MinValue - 1)).ToString ("x",
273                                 CultureInfo.CurrentCulture);
274
275                         try {
276                                 converter.ConvertFrom ("#" + minOverflow);
277                                 Assert.Fail ("#1");
278                         } catch (AssertionException) {
279                                 throw;
280                         } catch (Exception ex) {
281                                 Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
282                                 Assert.IsNotNull (ex.InnerException, "#3");
283                                 Assert.AreEqual (typeof (OverflowException), ex.InnerException.GetType (), "#3");
284                         }
285                 }
286
287                 [Test]
288                 public void ConvertFrom_Base16_MinOverflow_Invariant ()
289                 {
290                         string minOverflow = ((int) (short.MinValue - 1)).ToString ("x",
291                                 CultureInfo.InvariantCulture);
292
293                         try {
294                                 converter.ConvertFrom (null, CultureInfo.InvariantCulture,
295                                         "#" + minOverflow);
296                                 Assert.Fail ("#1");
297                         } catch (AssertionException) {
298                                 throw;
299                         } catch (Exception ex) {
300                                 Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
301                                 Assert.IsNotNull (ex.InnerException, "#3");
302                                 Assert.AreEqual (typeof (OverflowException), ex.InnerException.GetType (), "#4");
303                         }
304                 }
305
306                 [Test]
307                 public void ConvertFrom_Base16_MaxOverflow ()
308                 {
309                         string maxOverflow = ((int) (short.MaxValue + 1)).ToString ("x",
310                                 CultureInfo.CurrentCulture);
311                         Assert.AreEqual (-32768, converter.ConvertFrom (null, CultureInfo.CurrentCulture,
312                                 "#" + maxOverflow), "#1");
313
314                         maxOverflow = ((int) (ushort.MaxValue)).ToString ("x",
315                                 CultureInfo.CurrentCulture);
316                         Assert.AreEqual (-1, converter.ConvertFrom (null, CultureInfo.CurrentCulture,
317                                 "#" + maxOverflow), "#2");
318
319                         maxOverflow = (ushort.MaxValue + 1).ToString ("x",
320                                 CultureInfo.CurrentCulture);
321
322                         try {
323                                 converter.ConvertFrom (null, CultureInfo.CurrentCulture,
324                                         "#" + maxOverflow);
325                                 Assert.Fail ("#3");
326                         } catch (AssertionException) {
327                                 throw;
328                         } catch (Exception ex) {
329                                 Assert.AreEqual (typeof (Exception), ex.GetType (), "#4");
330                                 Assert.IsNotNull (ex.InnerException, "#5");
331                                 Assert.AreEqual (typeof (OverflowException), ex.InnerException.GetType (), "#6");
332                         }
333                 }
334
335                 [Test]
336                 public void ConvertFrom_Base16_MaxOverflow_Invariant ()
337                 {
338                         string maxOverflow = ((int) (short.MaxValue + 1)).ToString ("x",
339                                 CultureInfo.InvariantCulture);
340                         Assert.AreEqual (-32768, converter.ConvertFrom (null, CultureInfo.InvariantCulture,
341                                 "#" + maxOverflow), "#1");
342
343                         maxOverflow = ((int) (ushort.MaxValue)).ToString ("x",
344                                 CultureInfo.InvariantCulture);
345                         Assert.AreEqual (-1, converter.ConvertFrom (null, CultureInfo.InvariantCulture,
346                                 "#" + maxOverflow), "#2");
347
348                         maxOverflow = (ushort.MaxValue + 1).ToString ("x",
349                                 CultureInfo.InvariantCulture);
350
351                         try {
352                                 converter.ConvertFrom (null, CultureInfo.InvariantCulture,
353                                         "#" + maxOverflow);
354                                 Assert.Fail ("#3");
355                         } catch (AssertionException) {
356                                 throw;
357                         } catch (Exception ex) {
358                                 Assert.AreEqual (typeof (Exception), ex.GetType (), "#4");
359                                 Assert.IsNotNull (ex.InnerException, "#5");
360                                 Assert.AreEqual (typeof (OverflowException), ex.InnerException.GetType (), "#6");
361                         }
362                 }
363
364                 [Test]
365                 public void ConvertFromString_InvalidValue ()
366                 {
367                         try {
368                                 converter.ConvertFromString ("*1");
369                                 Assert.Fail ("#1");
370                         } catch (AssertionException) {
371                                 throw;
372                         } catch (Exception ex) {
373                                 Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
374                                 Assert.IsNotNull (ex.InnerException, "#3");
375                                 Assert.AreEqual (typeof (FormatException), ex.InnerException.GetType (), "#3");
376                         }
377                 }
378
379                 [Test]
380                 public void ConvertFromString_InvalidValue_Invariant ()
381                 {
382                         try {
383                                 converter.ConvertFromString (null, CultureInfo.InvariantCulture, "*1");
384                                 Assert.Fail ("#1");
385                         } catch (AssertionException) {
386                                 throw;
387                         } catch (Exception ex) {
388                                 Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
389                                 Assert.IsNotNull (ex.InnerException, "#3");
390                                 Assert.AreEqual (typeof (FormatException), ex.InnerException.GetType (), "#3");
391                         }
392                 }
393
394                 [Test]
395                 public void ConvertFromString_Base10_MinOverflow ()
396                 {
397                         string minOverflow = ((int) (short.MinValue - 1)).ToString (
398                                 CultureInfo.CurrentCulture);
399
400                         try {
401                                 converter.ConvertFromString (minOverflow);
402                                 Assert.Fail ("#1");
403                         } catch (AssertionException) {
404                                 throw;
405                         } catch (Exception ex) {
406                                 Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
407                                 Assert.IsNotNull (ex.InnerException, "#3");
408                                 Assert.AreEqual (typeof (OverflowException), ex.InnerException.GetType (), "#3");
409                         }
410                 }
411
412                 [Test]
413                 public void ConvertFromString_Base10_MinOverflow_Invariant ()
414                 {
415                         string minOverflow = ((int) (short.MinValue - 1)).ToString (
416                                 CultureInfo.InvariantCulture);
417
418                         try {
419                                 converter.ConvertFromString (null, CultureInfo.InvariantCulture,
420                                         minOverflow);
421                                 Assert.Fail ("#1");
422                         } catch (AssertionException) {
423                                 throw;
424                         } catch (Exception ex) {
425                                 Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
426                                 Assert.IsNotNull (ex.InnerException, "#3");
427                                 Assert.AreEqual (typeof (OverflowException), ex.InnerException.GetType (), "#3");
428                         }
429                 }
430
431                 [Test]
432                 public void ConvertFromString_Base10_MaxOverflow ()
433                 {
434                         string maxOverflow = ((int) (short.MaxValue + 1)).ToString (
435                                 CultureInfo.CurrentCulture);
436
437                         try {
438                                 converter.ConvertFromString (maxOverflow);
439                                 Assert.Fail ("#1");
440                         } catch (AssertionException) {
441                                 throw;
442                         } catch (Exception ex) {
443                                 Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
444                                 Assert.IsNotNull (ex.InnerException, "#3");
445                                 Assert.AreEqual (typeof (OverflowException), ex.InnerException.GetType (), "#3");
446                         }
447                 }
448
449                 [Test]
450                 public void ConvertFromString_Base10_MaxOverflow_Invariant ()
451                 {
452                         string maxOverflow = ((int) (short.MaxValue + 1)).ToString (
453                                 CultureInfo.InvariantCulture);
454
455                         try {
456                                 converter.ConvertFromString (null, CultureInfo.InvariantCulture,
457                                         maxOverflow);
458                                 Assert.Fail ("#1");
459                         } catch (AssertionException) {
460                                 throw;
461                         } catch (Exception ex) {
462                                 Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
463                                 Assert.IsNotNull (ex.InnerException, "#3");
464                                 Assert.AreEqual (typeof (OverflowException), ex.InnerException.GetType (), "#3");
465                         }
466                 }
467
468                 [Test]
469                 public void ConvertFromString_Base16_MinOverflow ()
470                 {
471                         string minOverflow = ((int) (short.MinValue - 1)).ToString ("x",
472                                 CultureInfo.CurrentCulture);
473
474                         try {
475                                 converter.ConvertFromString ("#" + minOverflow);
476                                 Assert.Fail ("#1");
477                         } catch (AssertionException) {
478                                 throw;
479                         } catch (Exception ex) {
480                                 Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
481                                 Assert.IsNotNull (ex.InnerException, "#3");
482                                 Assert.AreEqual (typeof (OverflowException), ex.InnerException.GetType (), "#3");
483                         }
484                 }
485
486                 [Test]
487                 public void ConvertFromString_Base16_MinOverflow_Invariant ()
488                 {
489                         string minOverflow = ((int) (short.MinValue - 1)).ToString ("x",
490                                 CultureInfo.InvariantCulture);
491
492                         try {
493                                 converter.ConvertFromString (null, CultureInfo.InvariantCulture,
494                                         "#" + minOverflow);
495                                 Assert.Fail ("#1");
496                         } catch (AssertionException) {
497                                 throw;
498                         } catch (Exception ex) {
499                                 Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
500                                 Assert.IsNotNull (ex.InnerException, "#3");
501                                 Assert.AreEqual (typeof (OverflowException), ex.InnerException.GetType (), "#3");
502                         }
503                 }
504
505                 [Test]
506                 public void ConvertFromString_Base16_MaxOverflow ()
507                 {
508                         string maxOverflow = ((int) (short.MaxValue + 1)).ToString ("x",
509                                 CultureInfo.CurrentCulture);
510                         Assert.AreEqual (-32768, converter.ConvertFromString ("#" + maxOverflow), "#1");
511
512                         maxOverflow = (ushort.MaxValue).ToString ("x",
513                                 CultureInfo.CurrentCulture);
514                         Assert.AreEqual (-1, converter.ConvertFromString ("#" + maxOverflow), "#2");
515
516                         maxOverflow = (ushort.MaxValue + 1).ToString ("x",
517                                 CultureInfo.CurrentCulture);
518
519                         try {
520                                 converter.ConvertFromString ("#" + maxOverflow);
521                                 Assert.Fail ("#3");
522                         } catch (AssertionException) {
523                                 throw;
524                         } catch (Exception ex) {
525                                 Assert.AreEqual (typeof (Exception), ex.GetType (), "#4");
526                                 Assert.IsNotNull (ex.InnerException, "#5");
527                                 Assert.AreEqual (typeof (OverflowException), ex.InnerException.GetType (), "#6");
528                         }
529                 }
530
531                 [Test]
532                 public void ConvertFromString_Base16_MaxOverflow_Invariant ()
533                 {
534                         string maxOverflow = ((int) (short.MaxValue + 1)).ToString ("x",
535                                 CultureInfo.CurrentCulture);
536                         Assert.AreEqual (-32768, converter.ConvertFromString ("#" + maxOverflow), "#1");
537
538                         maxOverflow = (ushort.MaxValue + 1).ToString ("x",
539                                 CultureInfo.CurrentCulture);
540
541                         try {
542                                 converter.ConvertFromString (null, CultureInfo.InvariantCulture,
543                                         "#" + maxOverflow);
544                                 Assert.Fail ("#2");
545                         } catch (AssertionException) {
546                                 throw;
547                         } catch (Exception ex) {
548                                 Assert.AreEqual (typeof (Exception), ex.GetType (), "#3");
549                                 Assert.IsNotNull (ex.InnerException, "#4");
550                                 Assert.AreEqual (typeof (OverflowException), ex.InnerException.GetType (), "#5");
551                         }
552                 }
553
554                 [Serializable]
555                 private sealed class MyCultureInfo : CultureInfo
556                 {
557                         internal MyCultureInfo ()
558                                 : base ("en-US")
559                         {
560                         }
561
562                         public override object GetFormat (Type formatType)
563                         {
564                                 if (formatType == typeof (NumberFormatInfo)) {
565                                         NumberFormatInfo nfi = (NumberFormatInfo) ((NumberFormatInfo) base.GetFormat (formatType)).Clone ();
566
567                                         nfi.NegativeSign = "myNegativeSign";
568                                         return NumberFormatInfo.ReadOnly (nfi);
569                                 } else {
570                                         return base.GetFormat (formatType);
571                                 }
572                         }
573
574 #if NET_2_0
575 // adding this override in 1.x shows different result in .NET (it is ignored).
576 // Some compatibility kids might want to fix this issue.
577                         public override NumberFormatInfo NumberFormat {
578                                 get {
579                                         NumberFormatInfo nfi = (NumberFormatInfo) base.NumberFormat.Clone ();
580                                         nfi.NegativeSign = "myNegativeSign";
581                                         return nfi;
582                                 }
583                                 set { throw new NotSupportedException (); }
584                         }
585 #endif
586                 }
587         }
588 }