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