Skip to content
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

Closing #141 - var guidance #162

Merged
merged 8 commits into from
Apr 23, 2021
Merged

Closing #141 - var guidance #162

merged 8 commits into from
Apr 23, 2021

Conversation

joeriddles
Copy link
Collaborator

@joeriddles joeriddles commented Mar 19, 2021

Fixes #141

@joeriddles joeriddles requested a review from Keboo March 19, 2021 05:12
global.json Outdated Show resolved Hide resolved
@@ -246,6 +246,8 @@
<guideline key="Ch14_6baa967" severity="DO" section="Coding" subsection="Types">DO use System.EventArgs or a type that derives from System.EventArgs for a TEventArgs type.</guideline>
<guideline key="Ch03_f566c99" severity="AVOID" section="Coding" subsection="Types">AVOID using implicitly typed local variables unless the data type of the assigned value is obvious.</guideline>
<guideline key="Ch14_3e1089d" severity="CONSIDER" section="Coding" subsection="Types">CONSIDER using System.EventHandler&lt;T&gt; instead of manually creating new delegate types for event handlers unless the parameter names of a custom type offer significant clarification.</guideline>
<guideline severity="CONSIDER" section="CODING" subsection="Variables">CONSIDER using var any time that the initialization of the variable clearly shows what the variable will contain.</guideline>
Copy link
Collaborator Author

@joeriddles joeriddles Mar 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without a key, XMLtoMD.GuidelineXmlToMD.Guidelines.GetHashCode throws an error because it expects its Key property to be non-null. @Keboo what do you think is a better solution: refactor GetHashCode on Guideline.cs or add keys to these new XML lines?

See:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O that is not good. I missed that previously. I would expect the Guidline to use all of its members to determine equality/hashcodes.
An even better solution would be to just make it a record type.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will investigate switching to a record type. I haven't been working with C# lately, so I have some reading up to do on how record types work. Fortunately, I know some people that did a meetup on the topic. 😉

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public record Guideline(string Text, string Severity, string Section, string Subsection, string? Key IList<string>? Comments); should probably do it

@joeriddles joeriddles linked an issue Mar 19, 2021 that may be closed by this pull request
@joeriddles
Copy link
Collaborator Author

@Keboo @adamskt @ascott18 This PR is ready for final review.

@Keboo Keboo merged commit 777a37f into main Apr 23, 2021
@Keboo Keboo deleted the add-var-guidance branch April 23, 2021 21:49
@adamskt
Copy link
Member

adamskt commented Apr 23, 2021

giphy (23)

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.

var guidance
3 participants