'Under what conditions can Assembly.GetName().Name be null?

This is defined as nullable (string?):

typeof(Foo).GetTypeInfo().Assembly.GetName().Name

The docs say:

Gets or sets the simple name of the assembly. This is usually, but not necessarily, the file name of the manifest file of the assembly, minus its extension.

Under what conditions can the value be null?



Solution 1:[1]

An assembly cannot have a null name. This is clearly specified in ECMA-335, which defines .NET and the CLI:

Section II.22.2
...
Name shall index a non-empty string in the String heap [ERROR]

It's probably just that no-one has gotten round to changing it to non-nullable. You can create your own pull-request on Github to change it to not-null, or raise a bug report if you like.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1