From bd9aabeae28efe1ec5cc1a8daed48b1f206355b8 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Fri, 7 May 2021 22:23:09 +0200 Subject: [PATCH] Update to dotnet-format 5.1.225507. This makes the formatting expected by our CI consistent with that generated by VS2019.9. --- .github/workflows/build-ilspy.yml | 2 +- .../Helpers/Tester.VB.cs | 3 +- .../Helpers/Tester.cs | 6 ++-- .../TestCases/Pretty/SwitchExpressions.cs | 18 ++++------- .../CSharp/ExpressionBuilder.cs | 3 +- .../ProjectFileWriterSdkStyle.cs | 3 +- .../CSharp/RecordDecompiler.cs | 32 +++++++++---------- .../CSharp/Syntax/TypeSystemAstBuilder.cs | 9 ++---- .../IL/Instructions/MatchInstruction.cs | 3 +- .../IL/Transforms/AssignVariableNames.cs | 3 +- .../IntroduceNativeIntTypeOnLocals.cs | 3 +- .../IL/Transforms/TransformAssignment.cs | 3 +- ICSharpCode.Decompiler/SRMExtensions.cs | 3 +- .../TypeSystem/ApplyAttributeTypeVisitor.cs | 3 +- .../Implementation/AttributeListBuilder.cs | 3 +- .../TypeSystem/TypeSystemExtensions.cs | 3 +- ILSpy/TreeNodes/AssemblyTreeNode.cs | 3 +- 17 files changed, 40 insertions(+), 63 deletions(-) diff --git a/.github/workflows/build-ilspy.yml b/.github/workflows/build-ilspy.yml index 15466ebb4..51a6629a5 100644 --- a/.github/workflows/build-ilspy.yml +++ b/.github/workflows/build-ilspy.yml @@ -48,7 +48,7 @@ jobs: uses: microsoft/setup-msbuild@v1.0.2 - name: Install dotnet-format - run: dotnet tool install dotnet-format --global --version 4.1.131201 + run: dotnet tool install dotnet-format --global --version 5.1.225507 - name: Get Version id: version diff --git a/ICSharpCode.Decompiler.Tests/Helpers/Tester.VB.cs b/ICSharpCode.Decompiler.Tests/Helpers/Tester.VB.cs index 2f0792a1b..9dde0d530 100644 --- a/ICSharpCode.Decompiler.Tests/Helpers/Tester.VB.cs +++ b/ICSharpCode.Decompiler.Tests/Helpers/Tester.VB.cs @@ -45,8 +45,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers CompilerResults results = new CompilerResults(new TempFileCollection()); results.PathToAssembly = outputFileName ?? Path.GetTempFileName(); - var (roslynVersion, languageVersion) = (flags & CompilerOptions.UseRoslynMask) switch - { + var (roslynVersion, languageVersion) = (flags & CompilerOptions.UseRoslynMask) switch { 0 => ("legacy", "11"), CompilerOptions.UseRoslyn1_3_2 => ("1.3.2", "14"), CompilerOptions.UseRoslyn2_10_0 => ("2.10.0", "latest"), diff --git a/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs b/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs index 89c0a8f9f..c31b75171 100644 --- a/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs +++ b/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs @@ -355,8 +355,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers CompilerResults results = new CompilerResults(new TempFileCollection()); results.PathToAssembly = outputFileName ?? Path.GetTempFileName(); - var (roslynVersion, languageVersion) = (flags & CompilerOptions.UseRoslynMask) switch - { + var (roslynVersion, languageVersion) = (flags & CompilerOptions.UseRoslynMask) switch { 0 => ("legacy", "5"), CompilerOptions.UseRoslyn1_3_2 => ("1.3.2", "6"), CompilerOptions.UseRoslyn2_10_0 => ("2.10.0", "latest"), @@ -522,8 +521,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers { if ((cscOptions & CompilerOptions.UseRoslynMask) != 0) { - var langVersion = (cscOptions & CompilerOptions.UseRoslynMask) switch - { + var langVersion = (cscOptions & CompilerOptions.UseRoslynMask) switch { CompilerOptions.UseRoslyn1_3_2 => CSharp.LanguageVersion.CSharp6, CompilerOptions.UseRoslyn2_10_0 => CSharp.LanguageVersion.CSharp7_3, _ => cscOptions.HasFlag(CompilerOptions.Preview) ? CSharp.LanguageVersion.Latest : CSharp.LanguageVersion.CSharp8_0, diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/SwitchExpressions.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/SwitchExpressions.cs index 23b3a4663..f7b381cd4 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/SwitchExpressions.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/SwitchExpressions.cs @@ -39,8 +39,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty public static bool? SwitchOverNullableEnum(State? state) { - return state switch - { + return state switch { State.False => false, State.True => true, State.Null => null, @@ -51,8 +50,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty public static string SparseIntegerSwitch(int i) { Console.WriteLine("SparseIntegerSwitch: " + i); - return i switch - { + return i switch { -10000000 => "-10 mln", -100 => "-hundred", -1 => "-1", @@ -88,8 +86,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty public static string SwitchOverNullableInt(int? i, int? j) { - return (i + j) switch - { + return (i + j) switch { null => "null", 0 => "zero", 5 => "five", @@ -100,8 +97,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty public static void SwitchOverInt(int i) { - Console.WriteLine(i switch - { + Console.WriteLine(i switch { 0 => "zero", 5 => "five", 10 => "ten", @@ -116,8 +112,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty public static string SwitchOverString1(string text) { Console.WriteLine("SwitchOverString1: " + text); - return text switch - { + return text switch { "First case" => "Text1", "Second case" => "Text2", "Third case" => "Text3", @@ -157,8 +152,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty public static string Issue2222() { - return (string)new ImplicitlyCastToString() switch - { + return (string)new ImplicitlyCastToString() switch { "foo" => "foo", "bar" => "bar", "quux" => "quux", diff --git a/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs b/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs index 5b126f112..37e9eb9b5 100644 --- a/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs @@ -797,8 +797,7 @@ namespace ICSharpCode.Decompiler.CSharp { // Reference comparison using Unsafe intrinsics Debug.Assert(!inst.IsLifted); - (string methodName, bool negate) = inst.Kind switch - { + (string methodName, bool negate) = inst.Kind switch { ComparisonKind.Equality => ("AreSame", false), ComparisonKind.Inequality => ("AreSame", true), ComparisonKind.LessThan => ("IsAddressLessThan", false), diff --git a/ICSharpCode.Decompiler/CSharp/ProjectDecompiler/ProjectFileWriterSdkStyle.cs b/ICSharpCode.Decompiler/CSharp/ProjectDecompiler/ProjectFileWriterSdkStyle.cs index f6045514c..61bb6d21f 100644 --- a/ICSharpCode.Decompiler/CSharp/ProjectDecompiler/ProjectFileWriterSdkStyle.cs +++ b/ICSharpCode.Decompiler/CSharp/ProjectDecompiler/ProjectFileWriterSdkStyle.cs @@ -208,8 +208,7 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler // remove phase foreach (var (itemType, fileName) in files.Where(t => t.itemType == "EmbeddedResource")) { - string buildAction = Path.GetExtension(fileName).ToUpperInvariant() switch - { + string buildAction = Path.GetExtension(fileName).ToUpperInvariant() switch { ".CS" => "Compile", ".RESX" => "EmbeddedResource", _ => "None" diff --git a/ICSharpCode.Decompiler/CSharp/RecordDecompiler.cs b/ICSharpCode.Decompiler/CSharp/RecordDecompiler.cs index 11356fc53..037de43a3 100644 --- a/ICSharpCode.Decompiler/CSharp/RecordDecompiler.cs +++ b/ICSharpCode.Decompiler/CSharp/RecordDecompiler.cs @@ -859,18 +859,18 @@ namespace ICSharpCode.Decompiler.CSharp bool Visit(ILInstruction inst) { if (inst is BinaryNumericInstruction - { - Operator: BinaryNumericOperator.Add, - CheckForOverflow: false, - Left: BinaryNumericInstruction { - Operator: BinaryNumericOperator.Mul, + Operator: BinaryNumericOperator.Add, CheckForOverflow: false, - Left: var left, - Right: LdcI4 { Value: -1521134295 } - }, - Right: var right - }) + Left: BinaryNumericInstruction + { + Operator: BinaryNumericOperator.Mul, + CheckForOverflow: false, + Left: var left, + Right: LdcI4 { Value: -1521134295 } + }, + Right: var right + }) { if (!Visit(left)) return false; @@ -971,13 +971,13 @@ namespace ICSharpCode.Decompiler.CSharp target = null; member = null; if (inst is CallVirt - { - Method: { - AccessorKind: System.Reflection.MethodSemanticsAttributes.Getter, - AccessorOwner: IProperty property - } - } call) + Method: + { + AccessorKind: System.Reflection.MethodSemanticsAttributes.Getter, + AccessorOwner: IProperty property + } + } call) { if (call.Arguments.Count != 1) return false; diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs index 5fdec7514..fde5a7647 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs @@ -320,8 +320,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax } else if (fpt.CallingConvention != System.Reflection.Metadata.SignatureCallingConvention.Default) { - string callconvName = fpt.CallingConvention switch - { + string callconvName = fpt.CallingConvention switch { System.Reflection.Metadata.SignatureCallingConvention.CDecl => "Cdecl", System.Reflection.Metadata.SignatureCallingConvention.StdCall => "Stdcall", System.Reflection.Metadata.SignatureCallingConvention.ThisCall => "Thiscall", @@ -352,8 +351,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax for (int i = 0; i < fpt.ParameterTypes.Length; i++) { var paramDecl = new ParameterDeclaration(); - paramDecl.ParameterModifier = fpt.ParameterReferenceKinds[i] switch - { + paramDecl.ParameterModifier = fpt.ParameterReferenceKinds[i] switch { ReferenceKind.In => ParameterModifier.In, ReferenceKind.Ref => ParameterModifier.Ref, ReferenceKind.Out => ParameterModifier.Out, @@ -1976,8 +1974,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax decl.Modifiers = ModifierFromAccessibility(accessor.Accessibility); if (accessor.HasReadonlyModifier()) decl.Modifiers |= Modifiers.Readonly; - TokenRole keywordRole = kind switch - { + TokenRole keywordRole = kind switch { MethodSemanticsAttributes.Getter => PropertyDeclaration.GetKeywordRole, MethodSemanticsAttributes.Setter => PropertyDeclaration.SetKeywordRole, MethodSemanticsAttributes.Adder => CustomEventDeclaration.AddKeywordRole, diff --git a/ICSharpCode.Decompiler/IL/Instructions/MatchInstruction.cs b/ICSharpCode.Decompiler/IL/Instructions/MatchInstruction.cs index 955ece6e8..091ebb72f 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/MatchInstruction.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/MatchInstruction.cs @@ -138,8 +138,7 @@ namespace ICSharpCode.Decompiler.IL private static bool IsConstant(ILInstruction inst) { - return inst.OpCode switch - { + return inst.OpCode switch { OpCode.LdcDecimal => true, OpCode.LdcF4 => true, OpCode.LdcF8 => true, diff --git a/ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs b/ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs index 7a78c7385..da8730287 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs @@ -582,8 +582,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms type = NullableType.GetUnderlyingType(((TypeWithElementType)type).ElementType); } - string name = type.Kind switch - { + string name = type.Kind switch { TypeKind.Array => "array", TypeKind.Pointer => "ptr", TypeKind.TypeParameter => "val", diff --git a/ICSharpCode.Decompiler/IL/Transforms/IntroduceNativeIntTypeOnLocals.cs b/ICSharpCode.Decompiler/IL/Transforms/IntroduceNativeIntTypeOnLocals.cs index 94f531a2e..aa78ecedd 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/IntroduceNativeIntTypeOnLocals.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/IntroduceNativeIntTypeOnLocals.cs @@ -54,8 +54,7 @@ namespace ICSharpCode.Decompiler.IL static bool IsUsedAsNativeInt(LdLoc load) { - return load.Parent switch - { + return load.Parent switch { BinaryNumericInstruction { UnderlyingResultType: StackType.I } => true, BitNot { UnderlyingResultType: StackType.I } => true, CallInstruction call => call.GetParameter(load.ChildIndex)?.Type.IsCSharpNativeIntegerType() ?? false, diff --git a/ICSharpCode.Decompiler/IL/Transforms/TransformAssignment.cs b/ICSharpCode.Decompiler/IL/Transforms/TransformAssignment.cs index 603bb984b..0fca1e954 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/TransformAssignment.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/TransformAssignment.cs @@ -388,8 +388,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms static ExpressionType ToCompound(ExpressionType from) { - return from switch - { + return from switch { ExpressionType.Add => ExpressionType.AddAssign, ExpressionType.AddChecked => ExpressionType.AddAssignChecked, ExpressionType.And => ExpressionType.AndAssign, diff --git a/ICSharpCode.Decompiler/SRMExtensions.cs b/ICSharpCode.Decompiler/SRMExtensions.cs index bd957c4cd..7c53797e2 100644 --- a/ICSharpCode.Decompiler/SRMExtensions.cs +++ b/ICSharpCode.Decompiler/SRMExtensions.cs @@ -580,8 +580,7 @@ namespace ICSharpCode.Decompiler public static string ToILSyntax(this SignatureCallingConvention callConv) { - return callConv switch - { + return callConv switch { SignatureCallingConvention.Default => "default", SignatureCallingConvention.CDecl => "unmanaged cdecl", SignatureCallingConvention.StdCall => "unmanaged stdcall", diff --git a/ICSharpCode.Decompiler/TypeSystem/ApplyAttributeTypeVisitor.cs b/ICSharpCode.Decompiler/TypeSystem/ApplyAttributeTypeVisitor.cs index fee4a6d2d..459ce0fdc 100644 --- a/ICSharpCode.Decompiler/TypeSystem/ApplyAttributeTypeVisitor.cs +++ b/ICSharpCode.Decompiler/TypeSystem/ApplyAttributeTypeVisitor.cs @@ -330,8 +330,7 @@ namespace ICSharpCode.Decompiler.TypeSystem var parameters = new IType[type.ParameterTypes.Length]; for (int i = 0; i < parameters.Length; i++) { - dynamicTypeIndex += type.ParameterReferenceKinds[i] switch - { + dynamicTypeIndex += type.ParameterReferenceKinds[i] switch { ReferenceKind.None => 1, ReferenceKind.Ref => 1, ReferenceKind.Out => 2, // in/out also count the modreq diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/AttributeListBuilder.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/AttributeListBuilder.cs index ca25a93c1..d60aa4bac 100644 --- a/ICSharpCode.Decompiler/TypeSystem/Implementation/AttributeListBuilder.cs +++ b/ICSharpCode.Decompiler/TypeSystem/Implementation/AttributeListBuilder.cs @@ -258,8 +258,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation static bool IsMethodLike(SymbolKind kind) { - return kind switch - { + return kind switch { SymbolKind.Method => true, SymbolKind.Operator => true, SymbolKind.Constructor => true, diff --git a/ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs b/ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs index 993804d95..486c7cdd8 100644 --- a/ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs +++ b/ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs @@ -295,8 +295,7 @@ namespace ICSharpCode.Decompiler.TypeSystem public static bool IsAnyPointer(this TypeKind typeKind) { - return typeKind switch - { + return typeKind switch { TypeKind.Pointer => true, TypeKind.FunctionPointer => true, _ => false diff --git a/ILSpy/TreeNodes/AssemblyTreeNode.cs b/ILSpy/TreeNodes/AssemblyTreeNode.cs index 3bd95559d..100eec589 100644 --- a/ILSpy/TreeNodes/AssemblyTreeNode.cs +++ b/ILSpy/TreeNodes/AssemblyTreeNode.cs @@ -90,8 +90,7 @@ namespace ICSharpCode.ILSpy.TreeNodes var loadResult = LoadedAssembly.GetLoadResultAsync().GetAwaiter().GetResult(); if (loadResult.Package != null) { - return loadResult.Package.Kind switch - { + return loadResult.Package.Kind switch { LoadedPackage.PackageKind.Zip => Images.NuGet, _ => Images.Library, };