JetBrains / ExternalAnnotations

JetBrains ReSharper External Annotations
https://www.jetbrains.com/help/resharper/Code_Analysis__External_Annotations.html
MIT License
81 stars 44 forks source link

CanBeNull for assemblyName for System.Activator.CreateInstance #209

Closed GitHubPang closed 3 years ago

GitHubPang commented 3 years ago

According to the official doc: https://docs.microsoft.com/en-us/dotnet/api/system.activator.createinstance For all overloads of the Activator.CreateInstance() method, the string assemblyName parameter can be null.

If assemblyName is null, the executing assembly is searched.

This is true for all versions (.NET 5, .NET Core, .NET Framework).


Source code also says so: https://github.com/dotnet/runtime/blob/11cd2721a9bb3fe0c21e20979a3e670f61e3507d/src/libraries/System.Private.CoreLib/src/System/Activator.RuntimeType.cs#L120-L123