Skip to content

Commit

Permalink
[NRBF] List all exceptions that can be thrown by the decoder (#106138)
Browse files Browse the repository at this point in the history
* TypeName.DeclaringType is not nullable, it throws an exception when the type is not nested (src already does that, ref needs to reflect it)

* fix a typo (we don't take into account member (field) types, not just generic types)

* add NotSupportedException to the list of exceptions the decoder can throw

* add EndOfStreamException to the list of exceptions the decoder can throw
  • Loading branch information
adamsitnik authored Aug 8, 2024
1 parent 3f09c37 commit aac3b2c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,15 @@ public static bool StartsWithPayloadHeader(Stream stream)
/// <exception cref="ArgumentNullException"><paramref name="payload"/> is <see langword="null" />.</exception>
/// <exception cref="ArgumentException"><paramref name="payload"/> does not support reading or is already closed.</exception>
/// <exception cref="SerializationException">Reading from <paramref name="payload"/> encounters invalid NRBF data.</exception>
/// <exception cref="NotSupportedException">
/// Reading from <paramref name="payload"/> encounters not supported records.
/// For example, arrays with non-zero offset or not supported record types
/// (<see cref="SerializationRecordType.ClassWithMembers"/>, <see cref="SerializationRecordType.SystemClassWithMembers"/>,
/// <see cref="SerializationRecordType.MethodCall"/> or <see cref="SerializationRecordType.MethodReturn"/>).
/// </exception>
/// <exception cref="DecoderFallbackException">Reading from <paramref name="payload"/>
/// encounters an invalid UTF8 sequence.</exception>
/// <exception cref="EndOfStreamException">The end of the stream is reached before reading <see cref="SerializationRecordType.MessageEnd"/> record.</exception>
public static SerializationRecord Decode(Stream payload, PayloadOptions? options = default, bool leaveOpen = false)
=> Decode(payload, out _, options, leaveOpen);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ internal SerializationRecord() // others can't derive from this type
/// </summary>
/// <remarks>
/// <para>This method ignores assembly names.</para>
/// <para>This method does NOT take into account member names or their generic types.</para>
/// <para>This method does NOT take into account member names or their types.</para>
/// </remarks>
/// <param name="type">The type to compare against.</param>
/// <returns><see langword="true" /> if the serialized type name match provided type; otherwise, <see langword="false" />.</returns>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2427,7 +2427,7 @@ public sealed partial class TypeName
internal TypeName() { }
public string AssemblyQualifiedName { get { throw null; } }
public AssemblyNameInfo? AssemblyName { get { throw null; } }
public System.Reflection.Metadata.TypeName? DeclaringType { get { throw null; } }
public System.Reflection.Metadata.TypeName DeclaringType { get { throw null; } }
public string FullName { get { throw null; } }
public bool IsArray { get { throw null; } }
public bool IsByRef { get { throw null; } }
Expand Down

0 comments on commit aac3b2c

Please sign in to comment.