File tree 2 files changed +24
-1
lines changed
src/libraries/System.Formats.Nrbf
2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,20 @@ internal SerializationRecord() // others can't derive from this type
50
50
/// </remarks>
51
51
/// <param name="type">The type to compare against.</param>
52
52
/// <returns><see langword="true" /> if the serialized type name matches the provided type; otherwise, <see langword="false" />.</returns>
53
- public bool TypeNameMatches ( Type type ) => Matches ( type , TypeName ) ;
53
+ /// <exception cref="ArgumentNullException"><paramref name="type" /> is <see langword="null" />.</exception>
54
+ public bool TypeNameMatches ( Type type )
55
+ {
56
+ #if NET
57
+ ArgumentNullException . ThrowIfNull ( type ) ;
58
+ #else
59
+ if ( type is null )
60
+ {
61
+ throw new ArgumentNullException ( nameof ( type ) ) ;
62
+ }
63
+ #endif
64
+
65
+ return Matches ( type , TypeName ) ;
66
+ }
54
67
55
68
private static bool Matches ( Type type , TypeName typeName )
56
69
{
Original file line number Diff line number Diff line change @@ -73,6 +73,16 @@ public void CanRecognizeGenericSystemTypes()
73
73
Verify ( new Dictionary < string , List < ValueTuple < int , short > > > ( ) ) ;
74
74
}
75
75
76
+ [ Fact ]
77
+ public void ThrowsForNullType ( )
78
+ {
79
+ List < int > input = new List < int > ( ) ;
80
+
81
+ SerializationRecord record = NrbfDecoder . Decode ( Serialize ( input ) ) ;
82
+
83
+ Assert . Throws < ArgumentNullException > ( ( ) => record . TypeNameMatches ( type : null ) ) ;
84
+ }
85
+
76
86
[ Fact ]
77
87
public void TakesGenericTypeDefinitionIntoAccount ( )
78
88
{
You can’t perform that action at this time.
0 commit comments