Skip to content

Conversation

@kartheekp-ms
Copy link
Contributor

Bug

Fixes: https://github.com/NuGet/Client.Engineering/issues/643

Regression: No

Fix

Details: Fixed CA2000 analyzer warnings in the product code. 36 out of 90 violations were fixed and added justification in GlobalSuppressions.cs for the remaining violations.

Testing/Validation

Tests Added: No
Reason for not adding tests:
Validation: All checks passed in CI

@kartheekp-ms kartheekp-ms requested a review from a team as a code owner January 4, 2021 05:14
Copy link
Member

@nkolev92 nkolev92 left a comment

Choose a reason for hiding this comment

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

I think we should try to make use of some modern using declaration pattern to reduce the footprint.

wyt?

@kartheekp-ms kartheekp-ms force-pushed the dev-kartheep-ms-ca2000-warnings branch from 6da4b65 to 9fa2ab1 Compare January 7, 2021 02:02
@kartheekp-ms kartheekp-ms requested a review from nkolev92 January 7, 2021 18:12
Copy link
Member

@nkolev92 nkolev92 left a comment

Choose a reason for hiding this comment

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

Just a question or two about what the analyzer fix is in that scenario.

I also left a few style nits.


using (var package = new PackageArchiveReader(outputPath))
{
using var package = new PackageArchiveReader(outputPath);
Copy link
Member

Choose a reason for hiding this comment

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

This seems like it's only changing from old usage to new usage. Is there an analyer fix here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I followed the example in this doc.

IDE0063 is the analyzer to simplify using statements in C# language version >= 8. This analyzer has a fixer whose light bulb suggestions can be observed in the image below.

image

Copy link
Member

Choose a reason for hiding this comment

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

Given that it's a stylistic fix, rather than a functional one, I'd normally say, avoid doing that to not introduce unnecessary changes. Especially when readability is not necessarily changing too much.

Given all that, I won't block on that, you can make a judgment call/discuss this feedback with others from the team.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Given that it's a stylistic fix, rather than a functional one, I'd normally say, avoid doing that to not introduce unnecessary changes. Especially when readability is not necessarily changing too much.

Sure, I agree. I also feel setting Language Version to 8 to core libraries a bit restrictive because net5.0 already defaults to Language Version 9. Since all of our projects targets multiple TFMs including net472, I think we will be struck to C# 7.3 which is the default language version for all .NET framework projects.

I prefer reverting my last commit to this branch where we added '8` for few projects unless other team members has additional feedback.

Copy link
Member

@nkolev92 nkolev92 Jan 8, 2021

Choose a reason for hiding this comment

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

I'm not suggesting going back to 7.3 actually.
I'm merely suggesting address only CA2000 warnings in this PR.

We should move to 8 or even 9 wherever we can.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it. Thanks, Nikolche for clarification. AFAIK, I modified using statement while fixing CA2000 warnings in this PR but not in other places. I will fix the nit pics suggested in other comments in the next commit.

Copy link
Member

@nkolev92 nkolev92 left a comment

Choose a reason for hiding this comment

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

Nice job ;)

Make sure you read my comment in the previous thread :)

@kartheekp-ms kartheekp-ms force-pushed the dev-kartheep-ms-ca2000-warnings branch from 9fa2ab1 to 2299298 Compare January 8, 2021 01:57
@kartheekp-ms
Copy link
Contributor Author

🔔 @NuGet/nuget-client

@kartheekp-ms
Copy link
Contributor Author

Planning to merge this PR by end of day today. Happy to address additional feedback.

@kartheekp-ms kartheekp-ms merged commit e7c4754 into dev Jan 14, 2021
@kartheekp-ms kartheekp-ms deleted the dev-kartheep-ms-ca2000-warnings branch January 14, 2021 01:33
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.

3 participants