Closed WeihanLi closed 1 week ago
@WeihanLi hey! thanks for the PR! But can you explain why exactly did you decide to make those changes?
@gritsenko using the nameof
expression, the compiler would help us check whether the param name is valid and it would be helpful when doing some refactoring especially when renaming
For example, when we change the param name from val
to val1
, the nameof
would report an error while the hard-coded param name would not, though it references a param not exist
And it's also used in the dotnet runtime code, for example:
source code link: https://github.com/dotnet/runtime/blob/e4fe27d8be89ac6805d9f2d4e92295a3322364a9/src/libraries/System.Private.CoreLib/src/System/ArgumentNullException.cs#L55
Hope it explains, thanks
use
nameof
forCallerArgumentExpression