Skip to content

[csharp][netcore] Update type "String" to "string" for consistent type #9713

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

Merged
merged 2 commits into from
Jun 19, 2021

Conversation

prajon84
Copy link
Contributor

@prajon84 prajon84 commented Jun 7, 2021

This PR is for removing inconsistent use of type "String" and "string" by updating "String" to "string"

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master, 5.1.x, 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@Blackclaws @lucamazzanti @wing328 @shibayan @jfeltesse-mdsol

@wing328
Copy link
Member

wing328 commented Jun 10, 2021

@prajon84 thanks for the PR. What about following the advise in this SO: https://stackoverflow.com/a/7077/677735 ?

As far as guidelines, it's generally recommended to use string any time you're referring to an object.

Likewise, I think it's generally recommended to use String if you need to refer specifically to the class.

@lucamazzanti
Copy link

lucamazzanti commented Jun 10, 2021

Good PR, I also wanted to start removing coding style warnings and hints.
Personally I would have done the same thing. William's proposal is a further improvement.

Visual Studio changes everything like in your PR.

Resharper has two different hints:

The default setup is the VS one, so it shows the hints also on the static cases like String.Format().

But if you setup on Resharper the second hint as CLR preference, then the fix applied on the entire project will exclude the static cases. But we need to apply that code syntax on the project itself. We can add an .editorconfig file in the solution to commit this code syntax preference . This is also useful for the furhter emprovements.
We can do that directly on that PR or on another one in the future, if you find that useful.

The .editorconfig content for that change will be this hint:

[*]

# Microsoft .NET properties
dotnet_style_predefined_type_for_member_access = false:suggestion

Without the shared project setting, I will choose the vanilla version moving everything to string, otherwhise the green hints on the IDEs will still remain.

@prajon84
Copy link
Contributor Author

@prajon84 thanks for the PR. What about following the advise in this SO: stackoverflow.com/a/7077/677735 ?

Seems like that was old guidance.

It appears that the guidance in this area may have changed, as StyleCop now enforces the use of the C# specific aliases.

@prajon84
Copy link
Contributor Author

prajon84 commented Jun 10, 2021

We can add an .editorconfig file in the solution to commit this code syntax preference . This is also useful for the furter emprovements.

Seems like it requires other file updates too to add .editorconfig way and which needs another PR (i guess).

@devhl-labs
Copy link
Contributor

string is the way it is normally written. It's very odd to see String. I don't think we should set .editorconfig. We should just satisfy all the code hints in vanilla Visual Studio.

@wing328
Copy link
Member

wing328 commented Jun 13, 2021

Can you please follow the instructions in the PR checklist item 3 to update the samples?

@prajon84
Copy link
Contributor Author

@wing328: I have updated the samples for bin/configs/csharp-netcore* and pushed the commit. But, the ci/circleci:build and continuous-integration/appveyor/pr build are still failing. Any ideas?

@wing328
Copy link
Member

wing328 commented Jun 19, 2021

Appveyor tests passed via https://ci.appveyor.com/project/WilliamCheng/openapi-generator/builds/39666876

@wing328 wing328 merged commit 015886f into OpenAPITools:master Jun 19, 2021
@wing328 wing328 added this to the 5.2.0 milestone Jul 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants