Skip to content

Conversation

@ThreeFive-O
Copy link
Contributor

PR Summary

This PR should improve the code readability for the cmdlet, before any other work is started. Changes:

  • Change properties to auto properties
  • Improve code style as suggested by CodeFactor, mainly
    • Fix comment styling
    • Insert lines after statement with curly braces

PR Checklist

Change properties to auto properties
Fix comment  styling
Insert lines after statement with curly braces
@ThreeFive-O
Copy link
Contributor Author

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.

Copy link
Collaborator

@iSazonov iSazonov left a 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;
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@iSazonov iSazonov requested a review from rjmholt September 7, 2018 09:07
@iSazonov iSazonov self-assigned this Sep 7, 2018
Copy link
Contributor

@dantraMSFT dantraMSFT left a 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;
Copy link
Contributor

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.
Copy link
Contributor

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
@ThreeFive-O
Copy link
Contributor Author

@dantraMSFT and @iSazonov Thank you for the review and the help.

  • Removed the initializers from the properties. For -Encoding paramater the initializer has to stay, because it will be null otherwise. Already present in the original code.
  • Fixed the summary to be in line with the other comments.

@iSazonov iSazonov merged commit dfe415e into PowerShell:master Sep 8, 2018
@ThreeFive-O ThreeFive-O deleted the Improve-SendMailMessage-CodeStyle branch September 8, 2018 19:40
@TravisEz13 TravisEz13 added this to the v6.1.0 milestone Sep 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants