-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Improve code style of Send-MailMessage cmdlet #7723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve code style of Send-MailMessage cmdlet #7723
Conversation
Change properties to auto properties Fix comment styling Insert lines after statement with curly braces
|
Can those suppress message attributes be removed too? e.g. [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Cc")]
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]Haven't seen them in newer cmdlets. I guess some artefacts from the original code base. |
iSazonov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one minor comment.
| } | ||
| } | ||
| private SwitchParameter _bodyashtml; | ||
| public SwitchParameter BodyAsHtml { get; set; } = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the init really needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really needed. It would be false anyway. Just make it more explicit. Same for the other inits.
I've seen it in other cmdlets and adopted this style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, C# coding guidelines discourage initializing properties and fields to the default value. Thus, you don't initialize int to zero, references to null, and fields/properties to false. A SwitchParameter is a good example of this.
dantraMSFT
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of minor comments/nits; otherwise, looks good.
| } | ||
| } | ||
| private SwitchParameter _bodyashtml; | ||
| public SwitchParameter BodyAsHtml { get; set; } = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, C# coding guidelines discourage initializing properties and fields to the default value. Thus, you don't initialize int to zero, references to null, and fields/properties to false. A SwitchParameter is a good example of this.
|
|
||
| /// <summary> | ||
| /// Specifies a value indicating whether the mail message body is in Html. | ||
| /// Gets or sets a value indicating whether the mail message body is in Html. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nit... To be consistent with the other property summaries, use
'Gets or sets the value...'
versus
'Gets or set a value...'
Fix summary comment for BodyAsHtml
|
@dantraMSFT and @iSazonov Thank you for the review and the help.
|
PR Summary
This PR should improve the code readability for the cmdlet, before any other work is started. Changes:
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.or can only be tested interactively[feature]if the change is significant or affects feature tests