Skip to content

Conversation

WilliamAntonRohm
Copy link
Contributor

@WilliamAntonRohm WilliamAntonRohm commented Oct 18, 2019

@BillWagner
Copy link
Member

@WilliamAntonRohm I reviewed all these changes. I generally agree with @Youssef1313 's comments. You can apply those suggestions, and then this is ready to :shipit:

@WilliamAntonRohm
Copy link
Contributor Author

@Youssef1313 -- Youssef, thank you for your helpful suggestions. I have applied them and I'll look for future such strings.

@BillWagner -- Bill, please merge.

Copy link
Contributor

@mairaw mairaw left a comment

Choose a reason for hiding this comment

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

Thanks @WilliamAntonRohm. The changes look great. Since we've started making changes to use var and string interpolation, I thought we should be consistent.

@mairaw mairaw added this to the October 2019 milestone Oct 22, 2019
WilliamAntonRohm and others added 13 commits October 22, 2019 09:42
@mairaw
Copy link
Contributor

mairaw commented Oct 22, 2019

You can apply all suggestions in bulk using the Files changed tab (https://github.com/dotnet/samples/pull/1654/files).

@mairaw
Copy link
Contributor

mairaw commented Oct 22, 2019

Only the manual suggestions left and then we can merge

Copy link
Contributor

@mairaw mairaw left a comment

Choose a reason for hiding this comment

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

Thank you @WilliamAntonRohm!

@WilliamAntonRohm
Copy link
Contributor Author

@mairaw -- Maira, thanks for that tip! I believe these samples are all ready to go now.

@mairaw mairaw merged commit 7b12611 into dotnet:master Oct 22, 2019
@WilliamAntonRohm WilliamAntonRohm deleted the guid branch October 22, 2019 17:46
foreach (var stringGuid in stringGuids) {
if (Guid.TryParse(stringGuid, out newGuid))
Console.WriteLine("Converted {0} to a Guid", stringGuid);
if (Guid.TryParse(stringGuid, out var newGuid))
Copy link
Member

Choose a reason for hiding this comment

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

I think this change is incorrect. var is used when declaring variables. However, I still didn't test this in an IDE.

Copy link
Contributor

Choose a reason for hiding this comment

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

I did test this on https://try.dot.net/. Check this: https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-7#out-variables

I'd use discards since that variable is not used but try.net didn't like that.

Copy link
Member

Choose a reason for hiding this comment

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

I'm also seeing some occurrences of var which would compile and be correct C# code, but doesn't follow the guidelines, which says to use var when the type is clear from the right hand side.

Copy link
Member

Choose a reason for hiding this comment

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

@mairaw, Thanks, didn't know this feature of C# 7.

I'll open another PR for the other occurrences of var that doesn't follow the guidelines like:

var g = Guid.NewGuid();

Copy link
Member

Choose a reason for hiding this comment

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

@Youssef1313

var g = Guid.NewGuid();

To me, that example is clear. I would be be very surprised if a method Guid.NewGuid() returned anything other than a Guid. When I reviewed the changes in this PR, I didn't find uses of var that were unclear. I don't think another PR is needed here.

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