Dotnet-api-docs: ReflectionTypeLoadException - Types is not marked as nullable

Created on 23 Aug 2020  路  2Comments  路  Source: dotnet/dotnet-api-docs

Hey,

Following Nullable update, I'm not clear about the following declaration inside ReflectionTypeLoadException:

public Type[]? Types { get; }

The documentation clearly states:
An array of type Type containing the classes that were defined in the module and loaded. This array can contain some null values.

As such, writing such a code:

catch (ReflectionTypeLoadException e)
{
return e.Types?.Where(t => t != null).Select(t => t.GetTypeInfo()) ?? Array.Empty<TypeInfo>();
}

Provides a warning on the where, as t is not marked as nullable.

Shouldn't the declaration be:
public Type?[]? Types { get; }

Pri3 area-Infrastructure bug external

All 2 comments

Was this page helpful?
0 / 5 - 0 ratings