diff --git a/.github/workflows/build-ilspy.yml b/.github/workflows/build-ilspy.yml
index 444d22b3c..10e5d8e9d 100644
--- a/.github/workflows/build-ilspy.yml
+++ b/.github/workflows/build-ilspy.yml
@@ -35,7 +35,7 @@ jobs:
uses: microsoft/setup-msbuild@v2
- name: Install dotnet-format
- run: dotnet tool install -g dotnet-format --version "6.2.315104" --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json
+ run: dotnet tool install -g dotnet-format --version "8.0.453106" --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json
- name: Get Version
id: version
diff --git a/BuildTools/format.bat b/BuildTools/format.bat
new file mode 100644
index 000000000..be49dc68c
--- /dev/null
+++ b/BuildTools/format.bat
@@ -0,0 +1,3 @@
+@rem This file can be used to trigger the commit hook's formatting,
+@rem modifying the local formatting even if not committing all changes.
+"%ProgramFiles%\Git\usr\bin\bash.exe" BuildTools\pre-commit --format
\ No newline at end of file
diff --git a/BuildTools/pre-commit b/BuildTools/pre-commit
index a55e3bdc4..eee675c87 100644
--- a/BuildTools/pre-commit
+++ b/BuildTools/pre-commit
@@ -5,16 +5,21 @@
set -eu
-DOTNET_FORMAT_VERSION=6.2.315104
+DOTNET_FORMAT_VERSION=8.0.453106
DOTNET_PATH="$LOCALAPPDATA/ICSharpCode/ILSpy/dotnet-format-$DOTNET_FORMAT_VERSION"
if [ ! -d "$DOTNET_PATH" ]; then
- dotnet tool install --tool-path "$DOTNET_PATH" dotnet-format --version "$DOTNET_FORMAT_VERSION" --add-source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json"
+ echo "Downloading dotnet-format $DOTNET_FORMAT_VERSION..."
+ dotnet tool install --tool-path "$DOTNET_PATH" dotnet-format --version "$DOTNET_FORMAT_VERSION" --add-source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json"
fi
"$DOTNET_PATH/dotnet-format.exe" --version
-if git diff --quiet --ignore-submodules; then
+if [ "${1:-}" = "--format" ]; then
+ # called via format.bat
+ "$DOTNET_PATH/dotnet-format.exe" whitespace --no-restore --verbosity detailed ILSpy.sln
+elif git diff --quiet --ignore-submodules; then
"$DOTNET_PATH/dotnet-format.exe" whitespace --no-restore --verbosity detailed ILSpy.sln
git add -u -- \*\*.cs
else
+ echo Partial commit: only verifying formatting
exec "$DOTNET_PATH/dotnet-format.exe" whitespace --verify-no-changes --no-restore --verbosity detailed ILSpy.sln
fi
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 7647ddba4..c8f3dd3f5 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -17,8 +17,8 @@
-
-
+
+
@@ -37,7 +37,7 @@
-
+
@@ -47,7 +47,7 @@
-
+
\ No newline at end of file
diff --git a/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs b/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs
index 92eb339f6..bdea4570f 100644
--- a/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs
+++ b/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs
@@ -528,7 +528,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
{
CompilerResults results = new CompilerResults();
results.PathToAssembly = outputFileName;
- string testBasePath = RoundtripAssembly.TestDir;
+ string testBasePath = Roundtrip.RoundtripAssembly.TestDir;
if (!Directory.Exists(testBasePath))
{
Assert.Ignore($"Compilation with mcs ignored: test directory '{testBasePath}' needs to be checked out separately." + Environment.NewLine +
@@ -596,7 +596,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
CompilerOptions.UseRoslyn1_3_2 => CSharp.LanguageVersion.CSharp6,
CompilerOptions.UseRoslyn2_10_0 => CSharp.LanguageVersion.CSharp7_3,
CompilerOptions.UseRoslyn3_11_0 => CSharp.LanguageVersion.CSharp9_0,
- _ => cscOptions.HasFlag(CompilerOptions.Preview) ? CSharp.LanguageVersion.Latest : CSharp.LanguageVersion.CSharp11_0,
+ _ => cscOptions.HasFlag(CompilerOptions.Preview) ? CSharp.LanguageVersion.Latest : CSharp.LanguageVersion.CSharp12_0,
};
DecompilerSettings settings = new(langVersion) {
// Never use file-scoped namespaces
diff --git a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
index 7970f6265..697ca18d9 100644
--- a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
+++ b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
@@ -17,6 +17,7 @@
True
1701;1702;1705,67,169,1058,728,1720,649,168,251,660,661,675;1998;162;8632;626;8618;8714;8602;8981
+ ROSLYN;NET60;CS60;CS70;CS71;CS72;CS73;CS80;CS90;CS100;CS110;CS120
False
False
@@ -40,11 +41,11 @@
- TRACE;DEBUG;ROSLYN;NET60;CS60;CS70;CS71;CS72;CS73;CS80;CS90;CS100
+ TRACE;DEBUG;$(DefineConstants)
- TRACE;ROSLYN;NET60;CS60;CS70;CS71;CS72;CS73;CS80;CS90;CS100
+ TRACE;$(DefineConstants)
@@ -152,7 +153,7 @@
-
+
diff --git a/ICSharpCode.Decompiler.Tests/RoundtripAssembly.cs b/ICSharpCode.Decompiler.Tests/RoundtripAssembly.cs
index 3043c9246..de1639cf0 100644
--- a/ICSharpCode.Decompiler.Tests/RoundtripAssembly.cs
+++ b/ICSharpCode.Decompiler.Tests/RoundtripAssembly.cs
@@ -29,11 +29,12 @@ using CliWrap;
using ICSharpCode.Decompiler.CSharp;
using ICSharpCode.Decompiler.CSharp.ProjectDecompiler;
using ICSharpCode.Decompiler.Metadata;
+using ICSharpCode.Decompiler.Tests;
using ICSharpCode.Decompiler.Tests.Helpers;
using NUnit.Framework;
-namespace ICSharpCode.Decompiler.Tests
+namespace ICSharpCode.Decompiler.Roundtrip
{
[TestFixture, Parallelizable(ParallelScope.All)]
public class RoundtripAssembly
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/OverloadResolution.cs b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/OverloadResolution.cs
index e206872a5..50925bddd 100644
--- a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/OverloadResolution.cs
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/OverloadResolution.cs
@@ -36,6 +36,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
Issue1747();
CallAmbiguousOutParam();
CallWithInParam();
+ CallWithRefReadOnlyParam();
#if CS90
NativeIntTests(new IntPtr(1), 2);
#endif
@@ -277,6 +278,73 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
}
#endregion
+ #region Ref readonly Parameter
+
+ static void CallWithRefReadOnlyParam()
+ {
+#if CS120
+#pragma warning disable CS9193
+ Console.WriteLine("OverloadSetWithRefReadOnlyParam:");
+ OverloadSetWithRefReadOnlyParam(1);
+ OverloadSetWithRefReadOnlyParam(2L);
+ int i = 3;
+ OverloadSetWithRefReadOnlyParam(in i);
+ OverloadSetWithRefReadOnlyParam((long)4);
+
+ Console.WriteLine("OverloadSetWithRefReadOnlyParam2:");
+ OverloadSetWithRefReadOnlyParam2(1);
+ OverloadSetWithRefReadOnlyParam2((object)1);
+
+ Console.WriteLine("OverloadSetWithRefReadOnlyParam3:");
+ OverloadSetWithRefReadOnlyParam3(1);
+ OverloadSetWithRefReadOnlyParam3(2);
+ OverloadSetWithRefReadOnlyParam3((object)3);
+
+ Console.WriteLine("RefReadOnlyVsRegularParam:");
+ RefReadOnlyVsRegularParam(1);
+ i = 2;
+ RefReadOnlyVsRegularParam(in i);
+#endif
+ }
+
+#if CS120
+ static void OverloadSetWithRefReadOnlyParam(ref readonly int i)
+ {
+ Console.WriteLine("ref readonly int " + i);
+ }
+ static void OverloadSetWithRefReadOnlyParam(long l)
+ {
+ Console.WriteLine("long " + l);
+ }
+ static void OverloadSetWithRefReadOnlyParam2(ref readonly long i)
+ {
+ Console.WriteLine("ref readonly long " + i);
+ }
+ static void OverloadSetWithRefReadOnlyParam2(object o)
+ {
+ Console.WriteLine("object " + o);
+ }
+ static void OverloadSetWithRefReadOnlyParam3(ref readonly int i)
+ {
+ Console.WriteLine("ref readonly int " + i);
+ }
+ static void OverloadSetWithRefReadOnlyParam3(T a)
+ {
+ Console.WriteLine("T " + a);
+ }
+ static void RefReadOnlyVsRegularParam(ref readonly int i)
+ {
+ Console.WriteLine("ref readonly int " + i);
+ }
+ static void RefReadOnlyVsRegularParam(int i)
+ {
+ Console.WriteLine("int " + i);
+ }
+
+#endif
+
+ #endregion
+
#region In Parameter
static void CallWithInParam()
{
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.cs
index 1cc74865c..34275f252 100644
--- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.cs
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.cs
@@ -4719,12 +4719,14 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
}
#endif
- private static void StringPropertyCompoundAssign()
+ private static void StringPropertyCompoundAssign(char c)
{
StaticStringProperty += "a";
StaticStringProperty += 1;
+ StaticStringProperty += c;
new CustomClass().StringProp += "a";
new CustomClass().StringProp += 1;
+ new CustomClass().StringProp += c;
}
public uint PreIncrementIndexer(string name)
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DynamicTests.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DynamicTests.cs
index 01edd50d2..7b90338f1 100644
--- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DynamicTests.cs
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DynamicTests.cs
@@ -1,4 +1,7 @@
using System;
+#if CS120
+using System.Collections.Generic;
+#endif
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{
@@ -74,6 +77,12 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
}
#endif
+#if CS120
+ private static void CallWithRefReadonly(ref readonly Dictionary