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

Code Style - apply PascalCase #3828

Merged
merged 8 commits into from
Apr 23, 2020
Merged

Code Style - apply PascalCase #3828

merged 8 commits into from
Apr 23, 2020

Conversation

chriselion
Copy link
Contributor

Proposed change(s)

Unity's C# style guide says

In the Unity namespace, public fields are PascalCase with no prefix
In the Unity namespace, public properties are PascalCase with no prefix

(as opposed to UnityEngine and UnityEditor namespaces, which have different conventions).

This PR updates all the public fields and properties that I could find (via API scraper) that were camelCase instead of PascalCase

Useful links (Github issues, JIRA tickets, ML-Agents forum threads etc.)

https://ono.unity3d.com/unity-extra/unity-meta/files/@/ReferenceSource/CSharp/Assets/CSharpReference.cs

Types of change(s)

  • Bug fix
  • New feature
  • Code refactor
  • Breaking change
  • Documentation update
  • Other (please describe)

Checklist

  • Added tests that prove my fix is effective or that my feature works
  • Updated the changelog (if applicable)
  • Updated the documentation (if applicable)
  • Updated the migration guide (if applicable)

Other comments

@@ -81,7 +81,7 @@ public bool grayscale
/// <summary>
/// The compression type to use for the sensor.
/// </summary>
public SensorCompressionType compression
public SensorCompressionType CompressionType
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 renamed a few of these to be more consistent too.

@vincentpierre
Copy link
Contributor

vincentpierre commented Apr 22, 2020

There should be some changes to the documentation I think.
https://github.com/Unity-Technologies/ml-agents/blame/api-PascalCase/docs/Learning-Environment-Examples.md#L364

Otherwise looks good

@chriselion
Copy link
Contributor Author

😭 Yeah, I'll do a pass on those too.

@chriselion
Copy link
Contributor Author

I skimmed through code blocks, and did a few spot checks with git grep foo -- docs/. and didn't find any others:

$ git grep maxStep -- docs/.
docs/Migrating.md:  instead of "camelCase"; for example, `Agent.maxStep` was renamed to
docs/Migrating.md:    `maxStep` information)
docs/Migrating.md:  - `maxStep` is now a public field on the Agent. (Was moved from

Copy link

@mmattar mmattar left a comment

Choose a reason for hiding this comment

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

❤️

@mmattar
Copy link

mmattar commented Apr 23, 2020

@chriselion - is there any error-ing/warning/pre-commit checks we can do to defend against this in the future?

@chriselion
Copy link
Contributor Author

@mmattar Nothing that I'm aware of. It sounds like something the [Coding Support Tools package] (https://docs.unity3d.com/Packages/com.unity.coding@0.1/manual/index.html) could potentially handle but not sure if it does (and we don't currently have a way to enforce anything else it does like code formatting anyway).

More extreme, we could use that package to generate a dump of the API scraping and parse that.

@chriselion chriselion merged commit da45b1c into master Apr 23, 2020
@delete-merged-branch delete-merged-branch bot deleted the api-PascalCase branch April 23, 2020 16:58
@chriselion
Copy link
Contributor Author

Followup for enforcing this automatically: https://jira.unity3d.com/browse/MLA-947

@JPhilipp
Copy link

JPhilipp commented Apr 30, 2020

Unity's C# style guide

@chriselion Is this document publicly available by any chance? I'd be interested to have a look (I understand it's also Microsoft C# convention to go for .PascalCase for public fields, whereas I'm always used to Unity fields being .camelCase; which means Unity developers need to choose either-or, resulting in mixes). Thanks!

@chriselion
Copy link
Contributor Author

@JPhilipp I'll find out - AFAIK the only version is in Unity's internal repo, but there might be a public copy somewhere.

@chriselion
Copy link
Contributor Author

@JPhilipp You can install the com.unity.coding package (it's in the public registry, but not visible by default), and once you do that, there's a copy of the file in
{your project}/Library/PackageCache/com.unity.coding@0.1.0-preview.13/Coding~/Conventions/CSharpReference.cs

Not exactly obvious :/ but hopefully that's enough to go on. Here's the line to add it to your list of dependencies:

"com.unity.coding": "0.1.0-preview.13",

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants