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

Update to C# 10 and upgrade code style #10105

Merged
merged 2 commits into from
Jun 23, 2022

Conversation

erikmav
Copy link
Contributor

@erikmav erikmav commented Jun 3, 2022

Plus update C# README with Visual Studio 2022 info.

@erikmav
Copy link
Contributor Author

erikmav commented Jun 3, 2022

@jskeet Related to #9801

@jskeet
Copy link
Contributor

jskeet commented Jun 3, 2022

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.)

Copy link
Contributor

@jskeet jskeet left a 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.

@erikmav
Copy link
Contributor Author

erikmav commented Jun 10, 2022

Reverts committed per comment above, ready for next round.

@jskeet
Copy link
Contributor

jskeet commented Jun 10, 2022

Great, thanks - I'll hopefully get to it on Monday.

@erikmav erikmav force-pushed the dev/erikma/csharp10 branch 2 times, most recently from 009c063 to 57c0109 Compare June 15, 2022 07:12
Copy link
Contributor

@jskeet jskeet left a 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

csharp/src/Google.Protobuf.Test/UnknownFieldSetTest.cs Outdated Show resolved Hide resolved
csharp/src/Google.Protobuf/Collections/MapField.cs Outdated Show resolved Hide resolved
csharp/src/Google.Protobuf/Collections/MapField.cs Outdated Show resolved Hide resolved
csharp/src/Google.Protobuf/Collections/RepeatedField.cs Outdated Show resolved Hide resolved
csharp/src/Google.Protobuf/FieldCodec.cs Outdated Show resolved Hide resolved
csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs Outdated Show resolved Hide resolved
csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs Outdated Show resolved Hide resolved
csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs Outdated Show resolved Hide resolved
csharp/src/Google.Protobuf/UnknownField.cs Show resolved Hide resolved
@erikmav erikmav force-pushed the dev/erikma/csharp10 branch from 57c0109 to 0153482 Compare June 22, 2022 07:24
@jskeet
Copy link
Contributor

jskeet commented Jun 22, 2022

@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?

@erikmav erikmav force-pushed the dev/erikma/csharp10 branch from 610b3da to d7d1477 Compare June 23, 2022 00:39
@erikmav
Copy link
Contributor Author

erikmav commented Jun 23, 2022

Not sure how that happened. Reset to current main commit then cherry-picked my 2 commits on top.

@jskeet
Copy link
Contributor

jskeet commented Jun 23, 2022

@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?

Copy link
Contributor

@jskeet jskeet left a 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.

@jskeet
Copy link
Contributor

jskeet commented Jun 23, 2022

Test failures aren't specific to this PR. Merging.

@erikmav
Copy link
Contributor Author

erikmav commented Jun 23, 2022

@jskeet no release note works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants