Home > Mobile >  Under what conditions can Assembly.GetName().Name be null?
Under what conditions can Assembly.GetName().Name be null?

Time:01-04

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?

CodePudding user response:

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

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.

  •  Tags:  
  • Related