From 45ccf885a149f13d7386647f3b260312c8d70aba Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 22 Sep 2022 13:07:01 +0200 Subject: [PATCH] [actions] Autoformat xibuild.csproj (#16059) Also fix a merge conflict that made autoformatting not work, and make sure to not add any temporary files to the diff. Co-authored-by: GitHub Actions Autoformatter --- .github/workflows/autoformat.yml | 2 +- tools/common/StringUtils.cs | 23 +++++++++++------------ tools/xibuild/Main.cs | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/workflows/autoformat.yml b/.github/workflows/autoformat.yml index d39caf7f5e..1052ac45cd 100644 --- a/.github/workflows/autoformat.yml +++ b/.github/workflows/autoformat.yml @@ -54,6 +54,7 @@ jobs: echo "No code formatting occurred" else git add -- . + git reset -- autoformat/PR # Don't add this file to the diff git config --global user.email "github-actions-autoformatter@xamarin.com" git config --global user.name "GitHub Actions Autoformatter" git checkout "$GITHUB_HEAD_REF" @@ -64,7 +65,6 @@ jobs: - name: 'Upload patch' uses: actions/upload-artifact@v3 - if: steps.autoformat.outputs.autoformatted == 'true' with: name: autoformat path: autoformat/ diff --git a/tools/common/StringUtils.cs b/tools/common/StringUtils.cs index df6fd1961f..54a3a84988 100644 --- a/tools/common/StringUtils.cs +++ b/tools/common/StringUtils.cs @@ -3,24 +3,24 @@ using System.Collections.Generic; using System.Linq; using System.Text; -#nullable enable +#nullable enable namespace Xamarin.Utils { internal class StringUtils { static StringUtils () { PlatformID pid = Environment.OSVersion.Platform; - if (((int)pid != 128 && pid != PlatformID.Unix && pid != PlatformID.MacOSX)) + if (((int) pid != 128 && pid != PlatformID.Unix && pid != PlatformID.MacOSX)) shellQuoteChar = '"'; // Windows else shellQuoteChar = '\''; // !Windows } static char shellQuoteChar; - static char[] mustQuoteCharacters = new char [] { ' ', '\'', ',', '$', '\\' }; + static char [] mustQuoteCharacters = new char [] { ' ', '\'', ',', '$', '\\' }; static char [] mustQuoteCharactersProcess = { ' ', '\\', '"', '\'' }; - public static string[]? Quote (params string[] array) + public static string []? Quote (params string [] array) { if (array is null || array.Length == 0) return array; @@ -53,14 +53,14 @@ namespace Xamarin.Utils { return s.ToString (); } - public static string[]? QuoteForProcess (IList arguments) + public static string []? QuoteForProcess (IList arguments) { if (arguments is null) return Array.Empty (); return QuoteForProcess (arguments.ToArray ()); } - public static string[]? QuoteForProcess (params string [] array) + public static string []? QuoteForProcess (params string [] array) { if (array is null || array.Length == 0) return array; @@ -184,7 +184,7 @@ namespace Xamarin.Utils { } else if (qchar == '\0' && (c == '\'' || c == '"')) { string sofar = builder.ToString (); - if (GetArgument (builder, buf, i, out endIndex, out ex) is string embedded ) { + if (GetArgument (builder, buf, i, out endIndex, out ex) is string embedded) { i = endIndex; builder.Clear (); builder.Append (sofar); @@ -212,7 +212,7 @@ namespace Xamarin.Utils { return builder.ToString (); } - + // Version.Parse requires, minimally, both major and minor parts. // However we want to accept `11` as `11.0` public static Version ParseVersion (string v) @@ -224,20 +224,19 @@ namespace Xamarin.Utils { } } - static class StringExtensions - { + static class StringExtensions { internal static string [] SplitLines (this string s) => s.Split (new [] { Environment.NewLine }, StringSplitOptions.None); // Adds an element to an array and returns a new array with the added element. // The original array is not modified. // If the original array is null, a new array is also created, with just the new value. - internal static T [] CopyAndAdd(this T[] array, T value) + internal static T [] CopyAndAdd (this T [] array, T value) { if (array is null || array.Length == 0) return new T [] { value }; var tmpArray = array; Array.Resize (ref array, array.Length + 1); - tmpArray[tmpArray.Length - 1] = value; + tmpArray [tmpArray.Length - 1] = value; return tmpArray; } } diff --git a/tools/xibuild/Main.cs b/tools/xibuild/Main.cs index 0e100e1199..f83c519729 100644 --- a/tools/xibuild/Main.cs +++ b/tools/xibuild/Main.cs @@ -236,7 +236,7 @@ namespace xibuild { return; // MSBuild property names are case insensitive - var valueAttribute = toolsets.SelectSingleNode ($"property[translate(@name, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')='{name.ToLowerInvariant()}']/@value"); + var valueAttribute = toolsets.SelectSingleNode ($"property[translate(@name, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')='{name.ToLowerInvariant ()}']/@value"); if (valueAttribute != null) { valueAttribute.Value = value; } else {