-
Notifications
You must be signed in to change notification settings - Fork 15.6k
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
Update to C# 10 and upgrade code style #10105
Conversation
I'll have a look at this on Monday. I'm always slightly wary of mass changes like this as I tend to find that it makes the history harder to read ("git blame" basically shows the big change for everything, for example) but we'll see. (I usually update any code I'm already touching, and maybe code in the same file in a separate commit. That does have the disadvantage of an inconsistent style through the codebase, of course.) |
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 summary of my thoughts at the moment, definitely up for discussion:
- I should probably have another look at the readme at some point, as I'm not sure the bit about it only using C# 3 is still valid. But I can do that later.
using
directives without blocks: yes- switch statement to switch expression: yes
- adding "private readonly" where feasible: definitely!
- Target-typed new: I'm on the fence about this in general; I think I'd prefer not to explicitly change existing code
- Converting to use var everywhere: while I think it's okay when changing existing code for other reasons, I'd rather not create "false diffs" that pollute history/blame just for this change
- Collection initializers: yes
- Object initializers: yes
- Tidying using directives: yes
- Removing code that's no longer used (e.g. CodedInputStream.RefillBuffer): yes
- Renaming parameters: no - that's a breaking change
- Adding appropriate copyright: yes
- Using pattern matching to avoid a subsequent cast: yes
I think that probably covers most of the changes. I'm open to suggestions of how we proceed here.
csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
Show resolved
Hide resolved
Reverts committed per comment above, ready for next round. |
Great, thanks - I'll hopefully get to it on Monday. |
009c063
to
57c0109
Compare
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.
Sorry that it's taken so long to get to the next round of this. This is looking really great! I haven't checked yet where we're at in terms of rebasing... I'd suggest the next steps could be:
- I'll get Kokoro to run
- You rebase to HEAD and force push (without addressing any comments)
- Address comments in a new commit so I know I only have to review that commit
- When we're there, we can squash and merge so it's still just a single commit
57c0109
to
0153482
Compare
@Erikma: I think the rebase has gone a bit wrong - there's lots of non-C# stuff in here, and lots of unexpected commits. Do you want me to see if I can sort it out, or are you happy to have a look? |
610b3da
to
d7d1477
Compare
Not sure how that happened. Reset to current main commit then cherry-picked my 2 commits on top. |
@Erikma: I've changed the labels to indicate that I don't think we need this change in the release notes. Are you happy with that? |
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.
This is all looking so much nicer - thanks very much! I've got the Kokoro tests running, and I'll merge when they're green.
Test failures aren't specific to this PR. Merging. |
@jskeet no release note works. |
Plus update C# README with Visual Studio 2022 info.