Skip to content

Use consistent field names - #4387

Merged
stevenaw merged 5 commits into
nunit:masterfrom
manfred-brands:UseConsistentFieldNames
May 29, 2023
Merged

stevenaw merged 5 commits into
nunit:masterfrom
manfred-brands:UseConsistentFieldNames

Conversation

@manfred-brands

Copy link
Copy Markdown
Member

Fixes #4380

I also added a separate commit to enforce braces on multiline if/for statements but leave them optional on single line.

@manfred-brands
manfred-brands force-pushed the UseConsistentFieldNames branch from c95d159 to 47626fd Compare May 19, 2023 02:46
@manfred-brands

Copy link
Copy Markdown
Member Author

@nunit/framework-team any chance for a review. It is mainly text substitution.

@stevenaw stevenaw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @manfred-brands
I've been keeping an eye on this one but hadn't explicitly reviewed since I'd already weighed in on the original issue and wanted to let others have a chance.
Time got away from me, I hadn't realized it had already been a few weeks since you'd made this. Thanks again for putting this up, LGTM.

Comment thread .editorconfig

# Required
dotnet_naming_symbols.namespaces_types_and_non_field_members.applicable_kinds = namespace, class, struct, enum, interface, delegate, type_parameter, method, property, event
dotnet_naming_rule.namespaces_types_and_non_field_members.severity = error

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@manfred-brands What are your thoughts on relaxing these formatting rules to warnings in the IDE? That way contributors can experiment with different approaches without worrying about formatting, but we could still have CI promote these to errors to prevent things from merging.

It looks like this was something we tried in the past here: https://github.com/nunit/nunit/blob/master/src/NUnitFramework/Directory.Build.props#L16-L19

@manfred-brands manfred-brands May 27, 2023 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@stevenaw They are warnings:
image

Building with that error inside VS results in a successful build:

1>Done building project "nunit.framework.csproj".
1>D:\Development\3rd\NUnit\nunit\src\NUnitFramework\framework\Api\NUnitTestAssemblyRunner.cs(38,28,38,32): warning IDE1006: Naming rule violation: Missing prefix: '_'
1>nunit.framework -> D:\Development\3rd\NUnit\nunit\src\NUnitFramework\framework\bin\Debug\netstandard2.0\nunit.framework.dll
1>Done building project "nunit.framework.csproj".
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

The severity field in these don't seem to make any difference, only the setting of the 1006 severity does:

# IDE1006: Naming Styles
dotnet_diagnostic.IDE1006.severity = warning

I set the severity in the naming rules to error simply to match the existing enforced items.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Now to how I feel about treating these as warnings inside VS.
Yes it might help a little, but when I see a warning when typing, I tend to fix it on the fly, even before building.
However, assume now we have a contributor that develops and tests in VS and ignores warnings.
As soon as the PR is pushed, it fails compilation. Same if they had run the build on the command line.
I think that is more frustrating than having to fix it "on the go".
But as I seem to be in the minority, I'm ok with leaving the BuildingInsideVisualStudio exception in place.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @manfred-brands ! Perhaps it's something specific to my setup then, but I recently noticed IDE1005 (unused using) was actually failing my build within VS. I'd thought it related to these but perhaps not.

FWIW regarding addressing warnings, my personal flow and preference is also to remove warnings instead of ignore them. I usually just tend to do it at the end, between finishing a feature and pushing.

@stevenaw

Copy link
Copy Markdown
Member

I'm going to go ahead and merge this since there don't seem to be any objections to the styles. Thanks once again @manfred-brands

@stevenaw
stevenaw merged commit dbe0d74 into nunit:master May 29, 2023
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.

Consistently use _ prefix for field names

2 participants