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

Feat/code formatting #1912

Merged
merged 9 commits into from
Feb 23, 2025
Merged

Feat/code formatting #1912

merged 9 commits into from
Feb 23, 2025

Conversation

duckdoom5
Copy link
Contributor

@duckdoom5 duckdoom5 commented Feb 12, 2025

  • Added formatting settings for c++/c# files

  • Added a workflow to check formatting of c++ files

  • Generated files are ignored

  • C++/CLI isn't properly supported by clang-format so those are ignored as well

@tritao
Copy link
Collaborator

tritao commented Feb 12, 2025

https://gist.github.com/kateinoigakukun/b0bc920e587851bfffa98b9e279175f2

I think it needs to be added after this goes in as a separate PR (maybe add the previous cleanup commit too).

@duckdoom5 duckdoom5 force-pushed the feat/code-formatting branch from ad7da91 to b1b7e84 Compare February 12, 2025 16:26
@duckdoom5 duckdoom5 marked this pull request as draft February 12, 2025 16:26
@duckdoom5
Copy link
Contributor Author

duckdoom5 commented Feb 12, 2025

What do you think of these formatting settings for c++ files?
(Would still need to run 'format all' on c# files)
(Also note that clang-format still doesn't support c++/cli formatting. They result in weird formatting 'bugs')

@duckdoom5 duckdoom5 force-pushed the feat/code-formatting branch from b1b7e84 to 845d7e7 Compare February 12, 2025 16:35
const char* get##name (unsigned i); \
void add##name (const char* s); \
unsigned get##name##Count (); \
#define DEF_VECTOR(klass, type, name) \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not really sure these are an improvement tbh, but willing to live with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what you mean? Do you think the formatting should not add line breaks to these macro's?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm just saying I find the old style more readable in this case, but not a big deal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yeah, I see. I can try to change it

@duckdoom5 duckdoom5 force-pushed the feat/code-formatting branch 3 times, most recently from 8057f58 to a6fc5f1 Compare February 13, 2025 14:18
@duckdoom5 duckdoom5 force-pushed the feat/code-formatting branch from a6fc5f1 to 891bd95 Compare February 20, 2025 14:48
- Added `RunClangFormat` shell script
- Added workflow to check if formatting was applied to PR's
@duckdoom5 duckdoom5 force-pushed the feat/code-formatting branch 2 times, most recently from 3aa766c to 61f9c1b Compare February 20, 2025 15:15
@duckdoom5 duckdoom5 marked this pull request as ready for review February 20, 2025 15:16
@duckdoom5 duckdoom5 force-pushed the feat/code-formatting branch from 61f9c1b to a5ff7c6 Compare February 20, 2025 15:17
duckdoom5 added a commit to duckdoom5/CppSharp that referenced this pull request Feb 20, 2025
duckdoom5 added a commit to duckdoom5/CppSharp that referenced this pull request Feb 20, 2025
@duckdoom5
Copy link
Contributor Author

duckdoom5 commented Feb 21, 2025

@tritao This is ready for review. I was unable to resolve the macro thing specifically, there's no option for that.

There is however an option to force small functions onto one line so it does look as before, but that means ALL small functions will ALWAYS be forced on one line. There's no option to leave it unfortunately. I can enable that one if that's your preference.

Lastly, I haven't formatted/added C# files to the workflow checks yet. Clang-format does support C# now, so I can add that as well. Let me know if you think it should be part of this PR

@tritao
Copy link
Collaborator

tritao commented Feb 21, 2025

Thanks, bit busy today, I will try to look at this ASAP and merge/provide some feedback.

@tritao
Copy link
Collaborator

tritao commented Feb 23, 2025

Was hoping that would have removed the extra indentation in namespaces, for example https://github.com/duckdoom5/CppSharp/blob/feat/code-formatting/src/CppParser/AST.cpp#L65.

I think I would also prefer to have IndentCaseLabels as false.

Anyway in the name progress lets get this in, we can re-format easily if needed in the future.

Thanks for your work on this.

@tritao tritao merged commit 9d1c484 into mono:main Feb 23, 2025
10 checks passed
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.

2 participants