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
[.NET] Better .editorconfig
setup in modules/mono/
#88570
[.NET] Better .editorconfig
setup in modules/mono/
#88570
Conversation
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.
Looks great, thanks for working on this.
# Diagnostics to prevent defensive copies of `in` struct parameters | ||
resharper_possibly_impure_method_call_on_readonly_variable_highlighting = error | ||
|
||
# Severity levels for dotnet_naming_rule only affect IDE environments. |
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.
Do the naming rules affect dotnet format
? If so, our CI check should enforce them.
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.
It does, and doesn't. It's dependent on the severity level we set for IDE1006. We can set it on suggestion if we don't want to block PRs, or on warning if we want to. One thing to note is IDE1006 won't apply changes automatically, so it would be listed as dotnet format
issues, but no corrections would be visible in the diff. If that make sense?
(I personally think we should set it as suggestion, and go from there)
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.
it would be listed as
dotnet format
issues, but no corrections would be visible in the diff
But would it show up in the Files changed tab? (like the analyzer tracking diagnostic) If so, I think that may be good enough. But I guess suggestion won't show, so we'd have to go with warning.
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.
I'm not entirely against setting that as warning, but it means we'd need to scrap the current codebase of formatting issues. Also, am I right in the rules I defined? Because it's not entirely consistent at the moment.
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.
At a first glance it looks correct, although they're probably not exhaustive enough (for example it doesn't cover parameters, local variables, properties, etc). For reference, here's the .editorconfig
used by roslyn: https://github.com/dotnet/roslyn/blob/6eb91fbee2f416285dcc7603e8c8769f78ed0aa8/.editorconfig#L65-L143
As for the current codebase, it's likely that we're not consistent because we didn't start closely following the code-style until somewhat recently. We'll have to do that at some point but I think it's fine to set the severity to suggestion for now.
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.
Yes, I only added rules for things where I saw naming issues for now. I'll add more exhaustive ones before un-drafting 👍
Basically:
- Everything is
PascalCase
- Non-public fields are
_camelCase
- Unless they are
const
/static readonly
, in which case they arePascalCase
- Unless they are
- Local variables are
camelCase
1bdaa45
to
8b9c594
Compare
I'm un-drafting this one. There is an additional commit that I left separate. It fixes the indentation in the generated I wrote additional naming rules in the |
From what I can see, most of the violations are from As for the generated files, it looks like most violations are due to virtual methods having a I'm not sure what the rule should be for static readonly, it seems we use It would be great to also add a rule to require tuples to use explicit naming and use PascalCase, there's |
Yeah, we kind of use both currently. With the |
Sadly, I don't think that's a thing. |
Looks like there's an issue for this: dotnet/roslyn#46205. Until then, since we should only be using the |
|
.editorconfig
setup in modules/mono/
@@ -771,10 +771,10 @@ public static godot_variant ConvertToVariant(object? obj) | |||
[typeof(Variant)] = (in godot_variant variant) => VariantUtils.ConvertTo<Variant>(variant), | |||
}; | |||
|
|||
[SuppressMessage("ReSharper", "RedundantNameQualifier")] | |||
// ReSharper disable RedundantNameQualifier |
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.
Shouldn't this be disable once
like the others? Then we don't need to restore it later.
// ReSharper disable RedundantNameQualifier | |
// ReSharper disable once RedundantNameQualifier |
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.
disable once
would only affect the next line, here we affect the entire method.
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.
Ah I see. What is this suppressing anyway? Is it because of the Godot.Collections
fully-qualified names? If so we may want to suppress this diagnostic everywhere, since we prefer to fully qualify Godot's collections.
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.
Yes, it's because we're inside the Godot
namespace, and we specify Godot.Whatever
.
modules/mono/glue/GodotSharp/GodotSharp/Core/GodotObject.base.cs
Outdated
Show resolved
Hide resolved
modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs
Outdated
Show resolved
Hide resolved
30d6054
to
621ff8c
Compare
modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs
Outdated
Show resolved
Hide resolved
621ff8c
to
0fa7abf
Compare
0fa7abf
to
801cea0
Compare
I'll squash once we know there's nothing more we wanna add to this specific PR. |
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.
I think this looks good enough already, we can always add more rules to .editorconfig
later. Thanks for the great cleanup!
New rules: - Do not silence CA1805 any more - Limit where we silence CA1707, CA1711, CA1720 - Enforce severity=warning for IDE0040 - Enforce Allman style braces - Enforce naming conventions (IDE1006 is still severity=suggestion) Fixes: - Fix REFL045, CS1572, CS1573 - Suppress CS0618 when generating `InvokeGodotClassMethod` - Fix indent when generating GD_constants.cs - Temporarily silence CS1734 in generated code - Fix a lot of naming rule violations Misc.: - Remove ReSharper comments for RedundantNameQualifier - Remove suppression attributes for RedundantNameQualifier - Remove severity=warnings for CA1716, CA1304 (already included in the level of analysis we run)
801cea0
to
139a5df
Compare
Here's to hoping I didn't break everything 🥂 |
Thanks! |
When did the naming convention for private members change to PascalCase? |
The changes in this PR are only meant to add the conventions that we've already been following to the I guess you're referring to the few constant names that were changed from |
InvokeGodotClassMethod