diff --git a/dotnet/private/dotnet_format.bzl b/dotnet/private/dotnet_format.bzl index 919c9a2d2b962..315c72603e6a8 100644 --- a/dotnet/private/dotnet_format.bzl +++ b/dotnet/private/dotnet_format.bzl @@ -52,10 +52,10 @@ DOTNET_DIR="$WORKSPACE_ROOT/dotnet" cd "$DOTNET_DIR" -echo "Running dotnet format on all projects..." +echo "Running dotnet format $@ on all projects..." find "$DOTNET_DIR/src" "$DOTNET_DIR/test" -name "*.csproj" 2>/dev/null | while read -r proj; do echo " Formatting $proj..." - "$DOTNET" format "$proj" || exit 1 + "$DOTNET" format "$@" "$proj" || exit 1 done || exit 1 echo "Done." @@ -90,14 +90,14 @@ set DOTNET_DIR=%WORKSPACE_ROOT%\\dotnet cd /d "%DOTNET_DIR%" -echo Running dotnet format on all projects... +echo Running dotnet format %* on all projects... for /r "%DOTNET_DIR%\\src" %%%%p in (*.csproj) do ( echo Formatting %%%%p... - "%DOTNET%" format "%%%%p" || exit /b 1 + "%DOTNET%" format %* "%%%%p" || exit /b 1 ) for /r "%DOTNET_DIR%\\test" %%%%p in (*.csproj) do ( echo Formatting %%%%p... - "%DOTNET%" format "%%%%p" || exit /b 1 + "%DOTNET%" format %* "%%%%p" || exit /b 1 ) echo Done. diff --git a/dotnet/test/common/WebElementWrapper.cs b/dotnet/test/common/WebElementWrapper.cs index bc131fa17eb83..3dc70ac5ea3ab 100644 --- a/dotnet/test/common/WebElementWrapper.cs +++ b/dotnet/test/common/WebElementWrapper.cs @@ -20,79 +20,78 @@ using System.Collections.ObjectModel; using System.Drawing; -namespace OpenQA.Selenium +namespace OpenQA.Selenium; + +public class WebElementWrapper(IWebElement element) : IWebElement, IWrapsElement { - public class WebElementWrapper(IWebElement element) : IWebElement, IWrapsElement - { - public IWebElement WrappedElement { get; } = element; + public IWebElement WrappedElement { get; } = element; - public string TagName => WrappedElement.TagName; + public string TagName => WrappedElement.TagName; - public string Text => WrappedElement.Text; + public string Text => WrappedElement.Text; - public bool Enabled => WrappedElement.Enabled; + public bool Enabled => WrappedElement.Enabled; - public bool Selected => WrappedElement.Selected; + public bool Selected => WrappedElement.Selected; - public Point Location => WrappedElement.Location; + public Point Location => WrappedElement.Location; - public Size Size => WrappedElement.Size; + public Size Size => WrappedElement.Size; - public bool Displayed => WrappedElement.Displayed; + public bool Displayed => WrappedElement.Displayed; - public void Clear() - { - WrappedElement.Clear(); - } + public void Clear() + { + WrappedElement.Clear(); + } - public void Click() - { - WrappedElement.Click(); - } + public void Click() + { + WrappedElement.Click(); + } - public IWebElement FindElement(By by) - { - return WrappedElement.FindElement(by); - } + public IWebElement FindElement(By by) + { + return WrappedElement.FindElement(by); + } - public ReadOnlyCollection FindElements(By by) - { - return WrappedElement.FindElements(by); - } + public ReadOnlyCollection FindElements(By by) + { + return WrappedElement.FindElements(by); + } - public string GetAttribute(string attributeName) - { - return WrappedElement.GetAttribute(attributeName); - } + public string GetAttribute(string attributeName) + { + return WrappedElement.GetAttribute(attributeName); + } - public string GetCssValue(string propertyName) - { - return WrappedElement.GetCssValue(propertyName); - } + public string GetCssValue(string propertyName) + { + return WrappedElement.GetCssValue(propertyName); + } - public string GetDomAttribute(string attributeName) - { - return WrappedElement.GetDomAttribute(attributeName); - } + public string GetDomAttribute(string attributeName) + { + return WrappedElement.GetDomAttribute(attributeName); + } - public string GetDomProperty(string propertyName) - { - return WrappedElement.GetDomProperty(propertyName); - } + public string GetDomProperty(string propertyName) + { + return WrappedElement.GetDomProperty(propertyName); + } - public ISearchContext GetShadowRoot() - { - return WrappedElement.GetShadowRoot(); - } + public ISearchContext GetShadowRoot() + { + return WrappedElement.GetShadowRoot(); + } - public void SendKeys(string text) - { - WrappedElement.SendKeys(text); - } + public void SendKeys(string text) + { + WrappedElement.SendKeys(text); + } - public void Submit() - { - WrappedElement.Submit(); - } + public void Submit() + { + WrappedElement.Submit(); } } diff --git a/rake_tasks/dotnet.rake b/rake_tasks/dotnet.rake index c9a49e084168c..ad6ab12835d13 100644 --- a/rake_tasks/dotnet.rake +++ b/rake_tasks/dotnet.rake @@ -112,3 +112,17 @@ task :pin do '--output-folder', "#{Dir.pwd}/dotnet"], '@rules_dotnet//tools/paket2bazel:paket2bazel') end + +desc 'Run .NET formatter (whitespace only)' +task :format do |_task, arguments| + raise ArgumentError, 'arguments not supported for this task' unless arguments.to_a.empty? + + puts ' Running dotnet format whitespace...' + Bazel.execute('run', ['--', 'whitespace'], '//dotnet:format') +end + +desc 'Run .NET linter (format + style + analyzers)' +task :lint do |_task, arguments| + puts ' Running dotnet format...' + Bazel.execute('run', ['--'] + arguments.to_a, '//dotnet:format') +end diff --git a/scripts/format.sh b/scripts/format.sh index e88e49bcde093..d6497e729111a 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -15,8 +15,8 @@ echo " buildifier" >&2 bazel run //:buildifier section "Dotnet" -echo " dotnet format" >&2 -bazel run //dotnet:format +echo " dotnet format whitespace" >&2 +bazel run //dotnet:format -- whitespace section "Java" echo " google-java-format" >&2