Skip to content

Conversation

nvborisenko
Copy link
Member

@nvborisenko nvborisenko commented Oct 13, 2025

User description

Code style is opiniated. We want to introduce some rules. But which rules - it is opiniated again.

💥 What does this PR do?

I took rules from dotnet itself: https://github.com/dotnet/runtime/blob/main/.editorconfig

🔧 Implementation Notes

And executed dotnet format

🔄 Types of changes

  • Cleanup (formatting, renaming)

PR Type

Other


Description

  • Introduce global .editorconfig with comprehensive C# formatting rules

  • Reorder using directives to place System namespaces first

  • Adjust code formatting: braces, spacing, and indentation per new rules

  • Apply consistent code style across entire .NET codebase


Diagram Walkthrough

flowchart LR
  A["Add .editorconfig"] --> B["Define C# style rules"]
  B --> C["Run dotnet format"]
  C --> D["Reorder using statements"]
  C --> E["Adjust brace placement"]
  C --> F["Fix spacing/indentation"]
Loading

File Walkthrough

Relevant files
Configuration changes
1 files
.editorconfig
Add comprehensive editorconfig with C# formatting rules   
+200/-1 
Formatting
18 files
ResponseValueJsonConverter.cs
Adjust brace placement in switch cases                                     
+32/-32 
Base64UrlEncoder.cs
Reformat switch case braces                                                           
+18/-18 
Broker.cs
Reorder using directives                                                                 
+2/-2     
DownloadEndEventArgsConverter.cs
Reorder using directives                                                                 
+2/-2     
InputSourceActionsConverter.cs
Reorder using directives                                                                 
+2/-2     
EvaluateResultConverter.cs
Reorder using directives                                                                 
+2/-2     
LogEntryConverter.cs
Reorder using directives                                                                 
+2/-2     
RealmInfoConverter.cs
Reorder using directives                                                                 
+2/-2     
RemoteValueConverter.cs
Reorder using directives                                                                 
+2/-2     
SetForcedColorsModeThemeOverrideCommand.cs
Reorder using directives                                                                 
+2/-2     
SetScreenOrientationOverrideCommand.cs
Reorder using directives                                                                 
+2/-2     
PrintCommand.cs
Reorder using directives                                                                 
+2/-2     
CaptureScreenshotCommand.cs
Reorder using directives                                                                 
+2/-2     
InputOriginConverter.cs
Reorder using directives                                                                 
+1/-1     
UserPromptOpenedEventArgs.cs
Reorder using directives                                                                 
+1/-1     
ClientWindowInfo.cs
Reorder using directives                                                                 
+1/-1     
DownloadEndEventArgs.cs
Reorder using directives                                                                 
+1/-1     
PrintPageRangeConverter.cs
Reorder using directives                                                                 
+1/-1     
Additional files
101 files
BrowserModule.cs +1/-1     
ClientWindow.cs +1/-1     
GetClientWindowsCommand.cs +1/-1     
GetUserContextsCommand.cs +1/-1     
SetDownloadBehaviorCommand.cs +1/-1     
BrowsingContext.cs +1/-1     
BrowsingContextInputModule.cs +1/-1     
BrowsingContextLogModule.cs +2/-2     
BrowsingContextNetworkModule.cs +1/-1     
CreateCommand.cs +1/-1     
GetTreeCommand.cs +1/-1     
LocateNodesCommand.cs +1/-1     
Locator.cs +1/-1     
NavigateCommand.cs +1/-1     
Navigation.cs +1/-1     
BrowserClientWindowConverter.cs +1/-1     
BrowserUserContextConverter.cs +1/-1     
ChannelConverter.cs +1/-1     
CollectorConverter.cs +1/-1     
HandleConverter.cs +1/-1     
InterceptConverter.cs +1/-1     
InternalIdConverter.cs +1/-1     
NavigationConverter.cs +1/-1     
PreloadScriptConverter.cs +1/-1     
RealmConverter.cs +1/-1     
RequestConverter.cs +1/-1     
WebExtensionConverter.cs +1/-1     
ITransport.cs +2/-2     
WebSocketTransport.cs +2/-2     
SetTimezoneOverrideCommand.cs +1/-1     
SetUserAgentOverrideCommand.cs +1/-1     
InputModule.cs +1/-1     
Origin.cs +1/-1     
PerformActionsCommand.cs +1/-1     
SetFilesCommand.cs +1/-1     
SourceActions.cs +2/-2     
LogEntry.cs +2/-2     
LogModule.cs +1/-1     
Module.cs +1/-1     
AddDataCollectorCommand.cs +2/-2     
AddInterceptCommand.cs +2/-2     
BaseParametersEventArgs.cs +1/-1     
BeforeRequestSentEventArgs.cs +1/-1     
ContinueRequestCommand.cs +1/-1     
ContinueResponseCommand.cs +1/-1     
ContinueWithAuthCommand.cs +1/-1     
Cookie.cs +1/-1     
FetchErrorEventArgs.cs +1/-1     
Initiator.cs +1/-1     
ProvideResponseCommand.cs +1/-1     
Request.cs +1/-1     
ResponseCompletedEventArgs.cs +1/-1     
ResponseStartedEventArgs.cs +1/-1     
SetCacheBehaviorCommand.cs +2/-2     
AddPreloadScriptCommand.cs +1/-1     
CallFunctionCommand.cs +1/-1     
Channel.cs +1/-1     
DisownCommand.cs +1/-1     
EvaluateCommand.cs +2/-2     
GetRealmsCommand.cs +1/-1     
LocalValue.cs +9/-9     
RealmInfo.cs +1/-1     
RealmType.cs +1/-1     
RemoteValue.cs +2/-2     
ResultOwnership.cs +1/-1     
ScriptModule.cs +1/-1     
SerializationOptions.cs +1/-1     
SessionModule.cs +1/-1     
SubscribeCommand.cs +1/-1     
Subscription.cs +1/-1     
UnsubscribeCommand.cs +1/-1     
UserPromptHandler.cs +1/-1     
GetCookiesCommand.cs +1/-1     
SetCookieCommand.cs +2/-2     
StorageModule.cs +1/-1     
Subscription.cs +1/-1     
InstallCommand.cs +1/-1     
WebExtensionModule.cs +1/-1     
By.cs +1/-1     
ChromeDriver.cs +2/-2     
ChromeDriverService.cs +1/-1     
ChromeOptions.cs +1/-1     
ChromiumDriver.cs +2/-2     
ChromiumDriverLogLevel.cs +1/-1     
Command.cs +1/-1     
Cookie.cs +1/-1     
DevToolsSession.cs +1/-1     
V138JavaScript.cs +2/-2     
V138Log.cs +1/-1     
V138Network.cs +2/-2     
V138Target.cs +1/-1     
V139JavaScript.cs +2/-2     
V139Log.cs +1/-1     
V139Network.cs +2/-2     
V139Target.cs +1/-1     
V140JavaScript.cs +2/-2     
V140Log.cs +1/-1     
V140Network.cs +2/-2     
V140Target.cs +1/-1     
DriverOptions.cs +2/-2     
Additional files not shown

@selenium-ci selenium-ci added C-dotnet .NET Bindings B-support Issue or PR related to support classes labels Oct 13, 2025
@nvborisenko nvborisenko changed the title [dotnet] Introduce global editroconfig [dotnet] Introduce global editorconfig Oct 13, 2025
@selenium-ci
Copy link
Member

Thank you, @nvborisenko for this code suggestion.

The support packages contain example code that many users find helpful, but they do not necessarily represent
the best practices for using Selenium, and the Selenium team is not currently merging changes to them.

After reviewing the change, unless it is a critical fix or a feature that is needed for Selenium
to work, we will likely close the PR.

We actively encourage people to add the wrapper and helper code that makes sense for them to their own frameworks.
If you have any questions, please contact us

@qodo-merge-pro qodo-merge-pro bot changed the title [dotnet] Introduce global editorconfig [dotnet] Introduce global editroconfig Oct 13, 2025
Copy link
Contributor

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
No custom compliance provided

Follow the guide to enable custom compliance check.

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

Copy link
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
High-level
Incorrect license in editorconfig template

The new .editorconfig file contains a file_header_template with an incorrect
license (MIT License for .NET Foundation) instead of the project's Apache 2.0
license. This template should be removed or corrected to avoid legal issues.

Examples:

dotnet/.editorconfig [160]
file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license.

Solution Walkthrough:

Before:

# In dotnet/.editorconfig

# ... other rules

# License header
file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license.

# ... other rules

After:

# In dotnet/.editorconfig

# ... other rules

# License header
# The incorrect template is removed to prevent applying the wrong license.
# Alternatively, it could be updated to the correct Apache 2.0 license header.

# ... other rules
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies a critical legal issue where the file_header_template in the new .editorconfig specifies an incorrect license (MIT) and copyright holder, which contradicts the project's actual Apache 2.0 license.

High
General
Refine static field naming rule

Refine the .editorconfig naming rule for static fields to exclude const and
readonly fields, preventing conflicts with other naming conventions.

dotnet/.editorconfig [66-74]

 # static fields should have s_ prefix
 dotnet_naming_rule.static_fields_should_have_prefix.severity = suggestion
 dotnet_naming_rule.static_fields_should_have_prefix.symbols  = static_fields
 dotnet_naming_rule.static_fields_should_have_prefix.style    = static_prefix_style
 dotnet_naming_symbols.static_fields.applicable_kinds   = field
 dotnet_naming_symbols.static_fields.required_modifiers = static
+dotnet_naming_symbols.static_fields.prohibited_modifiers = const, readonly
 dotnet_naming_symbols.static_fields.applicable_accessibilities = private, internal, private_protected
 dotnet_naming_style.static_prefix_style.required_prefix = s_
 dotnet_naming_style.static_prefix_style.capitalization = camel_case
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies a conflict between naming rules in the new .editorconfig file and provides a valid fix to ensure consistent styling for different types of static fields.

Low
Refine private field naming rule

Refine the .editorconfig naming rule for private/internal fields to exclude
static, const, and readonly fields, preventing conflicts with more specific
rules.

dotnet/.editorconfig [76-83]

 # internal and private fields should be _camelCase
 dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion
 dotnet_naming_rule.camel_case_for_private_internal_fields.symbols  = private_internal_fields
 dotnet_naming_rule.camel_case_for_private_internal_fields.style    = camel_case_underscore_style
 dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
+dotnet_naming_symbols.private_internal_fields.prohibited_modifiers = static, const, readonly
 dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
 dotnet_naming_style.camel_case_underscore_style.required_prefix = _
 dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies a conflict between naming rules in the new .editorconfig file and provides a valid fix to properly scope the rule for private instance fields.

Low
  • More

@cgoldberg
Copy link
Member

isn't there a linter/formatter to fix and enforce that stuff instead of doing it through your editor?

@nvborisenko
Copy link
Member Author

It is possible to do it via cli: dotnet format, but I don't want to know how it may be supported by format.sh/bazel.

csharp_space_between_square_brackets = false

# License header
file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license.
Copy link
Member Author

Choose a reason for hiding this comment

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

AI is good:

The new .editorconfig file contains a file_header_template with an incorrect
license (MIT License for .NET Foundation) instead of the project's Apache 2.0
license. This template should be removed or corrected to avoid legal issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B-support Issue or PR related to support classes C-dotnet .NET Bindings Review effort 2/5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants