Adding coding style in Engineering guidelines wiki
- Dominant language
- C#
- Stars
- 818
- Forks
- 260
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 10
Description
I noticed in many parts of https://github.com/dotnet/Scaffolding code still using hardcoded string instead of nameof operator like this line here which is for scaffolding controller:
https://github.com/dotnet/Scaffolding/blob/263009df57869c78bbb6e94cda397f4d0c4484a6/src/VS.Web.CG.Mvc/Templates/ControllerGenerator/ApiControllerWithContext.cshtml#L120
and this one here :
https://github.com/dotnet/Scaffolding/blob/263009df57869c78bbb6e94cda397f4d0c4484a6/src/VS.Web.CG.Mvc/Templates/Identity/Bootstrap4/Pages/Account/Account.ResetPassword.cs.cshtml#L60
and this is the code from the second example and how it should be:
```diff
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm password")]
-[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
+[Compare(nameof(Password), ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
```
So I think it would be nice if there is a coding style in engineering guidelines for this.
Contributor guide
Assessment
This issue has not been assessed yet.