Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit df471af

Browse files
authored
Fix wrong target type in UInt16Converter (#28253)
1 parent 7b137a3 commit df471af

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/System.ComponentModel.TypeConverter/src/System/ComponentModel/UInt16Converter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class UInt16Converter : BaseNumberConverter
1515
/// <summary>
1616
/// The Type this converter is targeting (e.g. Int16, UInt32, etc.)
1717
/// </summary>
18-
internal override Type TargetType => typeof(short);
18+
internal override Type TargetType => typeof(ushort);
1919

2020
/// <summary>
2121
/// Convert the given value to a string using the given radix

src/System.ComponentModel.TypeConverter/tests/UInt16ConverterTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,12 @@ public static void ConvertTo_WithContext()
4141
},
4242
UInt16ConverterTests.s_converter);
4343
}
44+
45+
[Fact]
46+
public static void ConvertFrom_InvalidValue_ExceptionMessageContainsTypeName()
47+
{
48+
Exception e = Assert.ThrowsAny<Exception>(() => s_converter.ConvertFrom("badvalue"));
49+
Assert.Contains(typeof(ushort).Name, e.Message);
50+
}
4451
}
4552
}

0 commit comments

Comments
 (0)