diff --git a/.github/workflows/build-frontends.yml b/.github/workflows/build-frontends.yml
index c35da7dab2..c216fdaae8 100644
--- a/.github/workflows/build-frontends.yml
+++ b/.github/workflows/build-frontends.yml
@@ -15,7 +15,7 @@ jobs:
with:
fetch-depth: 0
- name: Setup .NET
- uses: actions/setup-dotnet@v2
+ uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
diff --git a/.github/workflows/build-ilspy.yml b/.github/workflows/build-ilspy.yml
index e6a91feee0..2b6b3ed2cc 100644
--- a/.github/workflows/build-ilspy.yml
+++ b/.github/workflows/build-ilspy.yml
@@ -27,7 +27,7 @@ jobs:
fetch-depth: 0
- name: Add msbuild to PATH
- uses: microsoft/setup-msbuild@v1.1
+ uses: microsoft/setup-msbuild@v1.3
- 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
@@ -37,7 +37,7 @@ jobs:
shell: pwsh
run: |
.\BuildTools\ghactions-install.ps1
- Get-ChildItem Env: | Where-Object {$_.Name -Match "^ILSPY_"} | %{ echo "::set-output name=$($_.Name)::$($_.Value)" }
+ Get-ChildItem Env: | Where-Object {$_.Name -Match "^ILSPY_"} | %{ echo "$($_.Name)=$($_.Value)" } | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append
- name: Restore the application
run: msbuild ILSpy.sln /t:Restore /p:Configuration=${{ matrix.configuration }} /p:Platform=$env:BuildPlatform
@@ -60,7 +60,7 @@ jobs:
path: 'test-results/${{ matrix.configuration }}.xml'
- name: Create Test Report
- uses: test-summary/action@v1
+ uses: test-summary/action@v2
if: always()
with:
paths: "test-results/${{ matrix.configuration }}.xml"
@@ -78,14 +78,30 @@ jobs:
- name: Zip ILSpy (framework-dependent)
run: 7z a -tzip $env:StagingDirectory\ILSpy_binaries.zip .\ILSpy\bin\${{ matrix.configuration }}\net6.0-windows\*.dll .\ILSpy\bin\${{ matrix.configuration }}\net6.0-windows\*.exe .\ILSpy\bin\${{ matrix.configuration }}\net6.0-windows\*.config .\ILSpy\bin\${{ matrix.configuration }}\net6.0-windows\*.json .\ILSpy\bin\${{ matrix.configuration }}\net6.0-windows\*\ILSpy.resources.dll .\ILSpy\bin\${{ matrix.configuration }}\net6.0-windows\*\ILSpy.ReadyToRun.Plugin.resources.dll
- - name: Zip ILSpy Release (self-contained win-x64)
- if: matrix.configuration == 'release'
+ - name: Publish x64/arm64 framework-dependent/self-contained
shell: pwsh
+ run: .\publish.ps1
+
+ - name: Zip ILSpy Release (x64 self-contained)
+ if: matrix.configuration == 'release'
+ run: 7z a -tzip $env:StagingDirectory\ILSpy_selfcontained_x64.zip .\ILSpy\bin\Release\net6.0-windows\win-x64\publish\selfcontained\*
+
+ - name: Zip ILSpy Release (arm64 framework-dependent)
+ if: matrix.configuration == 'release'
+ run: 7z a -tzip $env:StagingDirectory\ILSpy_binaries_arm64.zip .\ILSpy\bin\Release\net6.0-windows\win-arm64\publish\fwdependent\*
+
+ - name: Build Installer (x64 and arm64, framework-dependent)
+ if: matrix.configuration == 'release'
+ run: |
+ msbuild ILSpy.Installer.sln /t:Restore /p:Configuration="Release" /p:Platform="Any CPU"
+ msbuild ILSpy.Installer.sln /p:Configuration="Release" /p:Platform="Any CPU"
+ msbuild ILSpy.Installer.sln /p:Configuration="Release" /p:Platform="Any CPU" /p:DefineConstants="ARM64"
+
+ - name: Build VS Extensions (for 2017-2019 and 2022)
+ if: matrix.configuration == 'release'
run: |
- dotnet publish ./ILSpy/ILSpy.csproj -c Release --no-restore --self-contained -r win-x64
- dotnet publish ./ILSpy.ReadyToRun/ILSpy.ReadyToRun.csproj -c Release --no-restore --self-contained -r win-x64
- dotnet publish ./ILSpy.BamlDecompiler/ILSpy.BamlDecompiler.csproj -c Release --no-restore --self-contained -r win-x64
- 7z a -tzip $env:StagingDirectory\ILSpy_selfcontained_x64.zip .\ILSpy\bin\Release\net6.0-windows\win-x64\publish\*
+ msbuild ILSpy.VSExtensions.sln /t:Restore /p:Configuration="Release" /p:Platform="Any CPU"
+ msbuild ILSpy.VSExtensions.sln /p:Configuration="Release" /p:Platform="Any CPU"
# https://github.com/actions/upload-artifact
- name: Upload VSIX (VS 2019) release build artifacts
@@ -137,7 +153,7 @@ jobs:
path: ${{ env.StagingDirectory }}\ILSpy_binaries.zip
if-no-files-found: error
- - name: Upload self-contained zip build artifacts (Release-only)
+ - name: Upload x64 self-contained zip (Release-only)
if: matrix.configuration == 'release'
uses: actions/upload-artifact@v3
with:
@@ -145,12 +161,28 @@ jobs:
path: ${{ env.StagingDirectory }}\ILSpy_selfcontained_x64.zip
if-no-files-found: error
- - name: Upload installer artifact
+ - name: Upload arm64 framework-dependent zip (Release-only)
+ if: matrix.configuration == 'release'
+ uses: actions/upload-artifact@v3
+ with:
+ name: ILSpy arm64 ${{ steps.version.outputs.ILSPY_VERSION_NUMBER }} (${{ matrix.configuration }})
+ path: ${{ env.StagingDirectory }}\ILSpy_binaries_arm64.zip
+ if-no-files-found: error
+
+ - name: Upload x64 installer artifact
+ if: matrix.configuration == 'release'
+ uses: actions/upload-artifact@v3
+ with:
+ name: ILSpy Installer x64 ${{ steps.version.outputs.ILSPY_VERSION_NUMBER }} (${{ matrix.configuration }})
+ path: ILSpy.Installer\wix\*-x64.msi
+ if-no-files-found: error
+
+ - name: Upload arm64 installer artifact
if: matrix.configuration == 'release'
uses: actions/upload-artifact@v3
with:
- name: ILSpy Installer ${{ steps.version.outputs.ILSPY_VERSION_NUMBER }} (${{ matrix.configuration }})
- path: ILSpy.Installer\wix\*.msi
+ name: ILSpy Installer arm64 ${{ steps.version.outputs.ILSPY_VERSION_NUMBER }} (${{ matrix.configuration }})
+ path: ILSpy.Installer\wix\*-arm64.msi
if-no-files-found: error
- name: Upload ilspycmd release build artifacts
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index 4cc0d34d7d..9d33c4b969 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -28,7 +28,7 @@ jobs:
languages: ${{ matrix.language }}
- name: Setup .NET
- uses: actions/setup-dotnet@v2
+ uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml
index 3a3dafb137..86c6960a3c 100644
--- a/.github/workflows/lock.yml
+++ b/.github/workflows/lock.yml
@@ -8,7 +8,8 @@ jobs:
lock:
runs-on: ubuntu-latest
steps:
- - uses: dessant/lock-threads@v3.0.0
+
+ - uses: dessant/lock-threads@v4.0.1
with:
github-token: ${{ github.token }}
issue-inactive-days: '90'
diff --git a/.gitignore b/.gitignore
index 9e00f3b055..be16796fde 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,7 @@ _ReSharper*/
*.ReSharper
*.patch
.vs/
+.idea/
/ILSpy.AddIn*/Packages/*
/ILSpy.AddIn*/source.extension.vsixmanifest
/ICSharpCode.Decompiler.Tests/TestCases/Disassembler/Pretty/*.dll
@@ -18,3 +19,4 @@ multitargeting.props
ILSpy.Installer/wix/
/VERSION
/ICSharpCode.Decompiler/Properties/DecompilerVersionInfo.cs
+*/.vscode/
diff --git a/BuildTools/pre-commit b/BuildTools/pre-commit
index 9a77bea3c1..a55e3bdc49 100644
--- a/BuildTools/pre-commit
+++ b/BuildTools/pre-commit
@@ -12,9 +12,9 @@ if [ ! -d "$DOTNET_PATH" ]; then
fi
"$DOTNET_PATH/dotnet-format.exe" --version
-#if git diff --quiet --ignore-submodules; then
-# "$DOTNET_PATH/dotnet-format.exe" whitespace --no-restore --verbosity detailed ILSpy.sln
-# git add -u -- \*\*.cs
-#else
+if git diff --quiet --ignore-submodules; then
+ "$DOTNET_PATH/dotnet-format.exe" whitespace --no-restore --verbosity detailed ILSpy.sln
+ git add -u -- \*\*.cs
+else
exec "$DOTNET_PATH/dotnet-format.exe" whitespace --verify-no-changes --no-restore --verbosity detailed ILSpy.sln
-#fi
+fi
diff --git a/ICSharpCode.Decompiler.PowerShell/GetDecompiledProjectCmdlet.cs b/ICSharpCode.Decompiler.PowerShell/GetDecompiledProjectCmdlet.cs
index 4db4ad4554..9b87d99bee 100644
--- a/ICSharpCode.Decompiler.PowerShell/GetDecompiledProjectCmdlet.cs
+++ b/ICSharpCode.Decompiler.PowerShell/GetDecompiledProjectCmdlet.cs
@@ -33,8 +33,8 @@ public void Report(DecompilationProgress value)
lock (syncObject)
{
completed++;
- progress = new ProgressRecord(1, "Decompiling " + fileName, $"Completed {completed} of {value.TotalNumberOfFiles}: {value.Status}") {
- PercentComplete = (int)(completed * 100.0 / value.TotalNumberOfFiles)
+ progress = new ProgressRecord(1, "Decompiling " + fileName, $"Completed {completed} of {value.TotalUnits}: {value.Status}") {
+ PercentComplete = (int)(completed * 100.0 / value.TotalUnits)
};
}
}
diff --git a/ICSharpCode.Decompiler.PowerShell/ICSharpCode.Decompiler.PowerShell.csproj b/ICSharpCode.Decompiler.PowerShell/ICSharpCode.Decompiler.PowerShell.csproj
index 8e73fc14ae..c50801c161 100644
--- a/ICSharpCode.Decompiler.PowerShell/ICSharpCode.Decompiler.PowerShell.csproj
+++ b/ICSharpCode.Decompiler.PowerShell/ICSharpCode.Decompiler.PowerShell.csproj
@@ -25,4 +25,8 @@
+
+
+
+
diff --git a/ICSharpCode.Decompiler.PowerShell/README.md b/ICSharpCode.Decompiler.PowerShell/README.md
index 2bac472f43..acb6e671d0 100644
--- a/ICSharpCode.Decompiler.PowerShell/README.md
+++ b/ICSharpCode.Decompiler.PowerShell/README.md
@@ -4,20 +4,21 @@ Built using https://github.com/PowerShell/PowerShell/blob/master/docs/cmdlet-exa
Sample usage: Demo.ps1
-Tested with: PowerShell 5.1 on Windows, PowerShell Core on Windows and Mac (Beta9)
+Tested with: PowerShell 5.1 on Windows, PowerShell 7+ on Windows and Mac
## Missing
-.psd1 for deploying to https://www.powershellgallery.com/
+Publishing to https://www.powershellgallery.com/
+* https://learn.microsoft.com/en-us/powershell/gallery/how-to/publishing-packages/publishing-a-package
+* https://learn.microsoft.com/en-us/powershell/gallery/concepts/publishing-guidelines
## Links for developing PS cmdlets
-* https://docs.microsoft.com/en-us/powershell/gallery/psgallery/creating-and-publishing-an-item
+* https://learn.microsoft.com/en-us/powershell/scripting/developer/cmdlet/how-to-write-a-simple-cmdlet
+* https://learn.microsoft.com/en-us/powershell/scripting/developer/cmdlet/approved-verbs-for-windows-powershell-commands
* https://github.com/mmaitre314/PowerShellGet-Test-Binary-Module
* https://www.red-gate.com/simple-talk/dotnet/net-development/using-c-to-create-powershell-cmdlets-beyond-the-basics/
-* https://msdn.microsoft.com/en-us/library/dd878294(v=VS.85).aspx Writing a Windows PowerShell Cmdlet
-* https://msdn.microsoft.com/en-us/library/ms714428(v=vs.85).aspx Approved verbs
* https://www.google.com/search?q=write+a+module+for+powershell+core
\ No newline at end of file
diff --git a/ICSharpCode.Decompiler.PowerShell/manifest.psd1 b/ICSharpCode.Decompiler.PowerShell/manifest.psd1
new file mode 100644
index 0000000000..575226e49b
--- /dev/null
+++ b/ICSharpCode.Decompiler.PowerShell/manifest.psd1
@@ -0,0 +1,129 @@
+@{
+ # Script module or binary module file associated with this manifest.
+ RootModule = 'ICSharpCode.Decompiler.PowerShell.dll'
+
+ # Version number of this module.
+ ModuleVersion = '8.0.0.0'
+
+ # Supported PSEditions
+ # CompatiblePSEditions = @()
+
+ # ID used to uniquely identify this module
+ GUID = '198b4312-cbe7-417e-81a7-1aaff467ef06'
+
+ # Author of this module
+ Author = 'ILSpy Contributors'
+
+ # Company or vendor of this module
+ CompanyName = 'ic#code'
+
+ # Copyright statement for this module
+ Copyright = 'Copyright 2011-2023 AlphaSierraPapa'
+
+ # Description of the functionality provided by this module
+ Description = 'PowerShell front-end for ILSpy'
+
+ # Minimum version of the PowerShell engine required by this module
+ # PowerShellVersion = ''
+
+ # Name of the PowerShell host required by this module
+ # PowerShellHostName = ''
+
+ # Minimum version of the PowerShell host required by this module
+ # PowerShellHostVersion = ''
+
+ # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
+ # DotNetFrameworkVersion = ''
+
+ # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
+ # ClrVersion = ''
+
+ # Processor architecture (None, X86, Amd64) required by this module
+ # ProcessorArchitecture = ''
+
+ # Modules that must be imported into the global environment prior to importing this module
+ # RequiredModules = @()
+
+ # Assemblies that must be loaded prior to importing this module
+ # RequiredAssemblies = @()
+
+ # Script files (.ps1) that are run in the caller's environment prior to importing this module.
+ # ScriptsToProcess = @()
+
+ # Type files (.ps1xml) to be loaded when importing this module
+ # TypesToProcess = @()
+
+ # Format files (.ps1xml) to be loaded when importing this module
+ # FormatsToProcess = @()
+
+ # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
+ # NestedModules = @()
+
+ # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
+ FunctionsToExport = @()
+
+ # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
+ CmdletsToExport = @(
+ 'Get-DecompiledProject',
+ 'Get-DecompiledSource',
+ 'Get-DecompiledTypes',
+ 'Get-Decompiler',
+ 'Get-DecompilerVersion'
+ )
+
+ # Variables to export from this module
+ VariablesToExport = '*'
+
+ # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
+ AliasesToExport = @()
+
+ # DSC resources to export from this module
+ # DscResourcesToExport = @()
+
+ # List of all modules packaged with this module
+ # ModuleList = @()
+
+ # List of all files packaged with this module
+ # FileList = @()
+
+ # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
+ PrivateData = @{
+
+ PSData = @{
+
+ # Tags applied to this module. These help with module discovery in online galleries.
+ # Tags = @()
+
+ # A URL to the license for this module.
+ # LicenseUri = ''
+
+ # A URL to the main website for this project.
+ ProjectUri = 'https://github.com/icsharpcode/ILSpy'
+
+ # A URL to an icon representing this module.
+ # IconUri = ''
+
+ # ReleaseNotes of this module
+ # ReleaseNotes = ''
+
+ # Prerelease string of this module
+ # Prerelease = ''
+
+ # Flag to indicate whether the module requires explicit user acceptance for install/update/save
+ # RequireLicenseAcceptance = $false
+
+ # External dependent modules of this module
+ # ExternalModuleDependencies = @()
+
+ } # End of PSData hashtable
+
+ } # End of PrivateData hashtable
+
+ # HelpInfo URI of this module
+ # HelpInfoURI = ''
+
+ # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
+ # DefaultCommandPrefix = ''
+
+}
+
diff --git a/ICSharpCode.Decompiler.TestRunner/ICSharpCode.Decompiler.TestRunner.csproj b/ICSharpCode.Decompiler.TestRunner/ICSharpCode.Decompiler.TestRunner.csproj
index c60a25481a..8c8d40ddc3 100644
--- a/ICSharpCode.Decompiler.TestRunner/ICSharpCode.Decompiler.TestRunner.csproj
+++ b/ICSharpCode.Decompiler.TestRunner/ICSharpCode.Decompiler.TestRunner.csproj
@@ -2,7 +2,7 @@
Exe
- net6.0-windows
+ net7.0
enable
diff --git a/ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs b/ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs
index 443485a815..ed4a3f2bb2 100644
--- a/ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs
+++ b/ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs
@@ -1,4 +1,4 @@
-// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
@@ -317,7 +317,7 @@ public async Task Jmp()
public async Task StackTests()
{
// IL contains .corflags = 32BITREQUIRED
- await RunIL("StackTests.il", asmOptions: AssemblerOptions.Force32Bit);
+ await RunIL("StackTests.il", CompilerOptions.Force32Bit, AssemblerOptions.Force32Bit);
}
[Test]
@@ -398,10 +398,6 @@ public async Task DynamicTests([ValueSource(nameof(noMonoOptions))] CompilerOpti
[Test]
public async Task MiniJSON([ValueSource(nameof(defaultOptions))] CompilerOptions options)
{
- if (options.HasFlag(CompilerOptions.UseMcs2_6_4))
- {
- Assert.Ignore("Decompiler bug with mono!");
- }
await RunCS(options: options);
}
@@ -487,6 +483,11 @@ async Task RunIL(string testFileName, CompilerOptions options = CompilerOptions.
string outputFile = null;
CompilerResults decompiledOutputFile = null;
+ bool optionsForce32Bit = options.HasFlag(CompilerOptions.Force32Bit);
+ bool asmOptionsForce32Bit = asmOptions.HasFlag(AssemblerOptions.Force32Bit);
+
+ Assert.AreEqual(optionsForce32Bit, asmOptionsForce32Bit, "Inconsistent architecture.");
+
try
{
options |= CompilerOptions.UseTestRunner;
diff --git a/ICSharpCode.Decompiler.Tests/DisassemblerPrettyTestRunner.cs b/ICSharpCode.Decompiler.Tests/DisassemblerPrettyTestRunner.cs
index 8cec9947be..9636facc1c 100644
--- a/ICSharpCode.Decompiler.Tests/DisassemblerPrettyTestRunner.cs
+++ b/ICSharpCode.Decompiler.Tests/DisassemblerPrettyTestRunner.cs
@@ -58,15 +58,28 @@ public async Task SecurityDeclarations()
await Run();
}
- async Task Run([CallerMemberName] string testName = null)
+ [Test]
+ public async Task SortMembers()
+ {
+ await Run(ilExpectedFile: Path.Combine(TestCasePath, "SortMembers.expected.il"), asmOptions: AssemblerOptions.SortedOutput);
+ }
+
+ [Test]
+ public async Task InterfaceImplAttributes()
+ {
+ await Run();
+ }
+
+ async Task Run([CallerMemberName] string testName = null, string ilExpectedFile = null, AssemblerOptions asmOptions = AssemblerOptions.None)
{
- var ilExpectedFile = Path.Combine(TestCasePath, testName + ".il");
+ var ilInputFile = Path.Combine(TestCasePath, testName + ".il");
+ ilExpectedFile ??= ilInputFile;
var ilResultFile = Path.Combine(TestCasePath, testName + ".result.il");
- var executable = await Tester.AssembleIL(ilExpectedFile, AssemblerOptions.Library).ConfigureAwait(false);
- var disassembled = await Tester.Disassemble(executable, ilResultFile, AssemblerOptions.UseOwnDisassembler).ConfigureAwait(false);
+ var executable = await Tester.AssembleIL(ilInputFile, AssemblerOptions.Library).ConfigureAwait(false);
+ var disassembled = await Tester.Disassemble(executable, ilResultFile, AssemblerOptions.UseOwnDisassembler | asmOptions).ConfigureAwait(false);
- CodeAssert.FilesAreEqual(ilExpectedFile, ilResultFile);
+ CodeAssert.FilesAreEqual(ilExpectedFile, disassembled);
}
}
}
diff --git a/ICSharpCode.Decompiler.Tests/Helpers/RemoveCompilerAttribute.cs b/ICSharpCode.Decompiler.Tests/Helpers/RemoveCompilerAttribute.cs
index efdd021d30..2ce551e791 100644
--- a/ICSharpCode.Decompiler.Tests/Helpers/RemoveCompilerAttribute.cs
+++ b/ICSharpCode.Decompiler.Tests/Helpers/RemoveCompilerAttribute.cs
@@ -20,7 +20,7 @@ public override void VisitAttribute(CSharp.Syntax.Attribute attribute)
if (section.Attributes.Count == 0)
section.Remove();
}
- if (section.AttributeTarget == "module" && type.Identifier == "UnverifiableCode")
+ if (section.AttributeTarget == "module" && type.Identifier is "UnverifiableCode" or "RefSafetyRules")
{
attribute.Remove();
if (section.Attributes.Count == 0)
@@ -34,35 +34,6 @@ public void Run(AstNode rootNode, TransformContext context)
}
}
- public class RemoveEmbeddedAttributes : DepthFirstAstVisitor, IAstTransform
- {
- HashSet attributeNames = new HashSet() {
- "System.Runtime.CompilerServices.IsReadOnlyAttribute",
- "System.Runtime.CompilerServices.IsByRefLikeAttribute",
- "System.Runtime.CompilerServices.IsUnmanagedAttribute",
- "System.Runtime.CompilerServices.NullableAttribute",
- "System.Runtime.CompilerServices.NullableContextAttribute",
- "System.Runtime.CompilerServices.NativeIntegerAttribute",
- "Microsoft.CodeAnalysis.EmbeddedAttribute",
- };
-
- public override void VisitTypeDeclaration(TypeDeclaration typeDeclaration)
- {
- var typeDefinition = typeDeclaration.GetSymbol() as ITypeDefinition;
- if (typeDefinition == null || !attributeNames.Contains(typeDefinition.FullName))
- return;
- if (typeDeclaration.Parent is NamespaceDeclaration ns && ns.Members.Count == 1)
- ns.Remove();
- else
- typeDeclaration.Remove();
- }
-
- public void Run(AstNode rootNode, TransformContext context)
- {
- rootNode.AcceptVisitor(this);
- }
- }
-
public class RemoveNamespaceMy : DepthFirstAstVisitor, IAstTransform
{
public override void VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration)
diff --git a/ICSharpCode.Decompiler.Tests/Helpers/Tester.VB.cs b/ICSharpCode.Decompiler.Tests/Helpers/Tester.VB.cs
index d871bed941..967f564e6b 100644
--- a/ICSharpCode.Decompiler.Tests/Helpers/Tester.VB.cs
+++ b/ICSharpCode.Decompiler.Tests/Helpers/Tester.VB.cs
@@ -72,7 +72,7 @@ public static async Task CompileVB(string sourceFileName, Compi
{
references = references.Concat(new[] { "-r:\"Microsoft.VisualBasic.dll\"" });
}
- string otherOptions = $"-noconfig " +
+ string otherOptions = $"-nologo -noconfig " +
"-optioninfer+ -optionexplicit+ " +
$"-langversion:{languageVersion} " +
$"/optimize{(flags.HasFlag(CompilerOptions.Optimize) ? "+ " : "- ")}";
@@ -122,8 +122,14 @@ public static async Task CompileVB(string sourceFileName, Compi
var result = await command.ExecuteBufferedAsync().ConfigureAwait(false);
- Console.WriteLine("output: " + result.StandardOutput);
- Console.WriteLine("errors: " + result.StandardError);
+ if (!string.IsNullOrWhiteSpace(result.StandardOutput))
+ {
+ Console.WriteLine("output:" + Environment.NewLine + result.StandardOutput);
+ }
+ if (!string.IsNullOrWhiteSpace(result.StandardError))
+ {
+ Console.WriteLine("errors:" + Environment.NewLine + result.StandardError);
+ }
Assert.AreEqual(0, result.ExitCode, "vbc failed");
return results;
diff --git a/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs b/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs
index 5a55e10c29..6219c2a1af 100644
--- a/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs
+++ b/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs
@@ -69,6 +69,7 @@ public enum CompilerOptions
UseMcs5_23 = 0x2000,
UseTestRunner = 0x4000,
NullableEnable = 0x8000,
+ ReferenceUnsafe = 0x10000,
UseMcsMask = UseMcs2_6_4 | UseMcs5_23,
UseRoslynMask = UseRoslyn1_3_2 | UseRoslyn2_10_0 | UseRoslyn3_11_0 | UseRoslynLatest
}
@@ -84,6 +85,8 @@ public enum AssemblerOptions
UseOwnDisassembler = 0x8,
/// Work around bug in .NET 5 ilasm (https://github.com/dotnet/runtime/issues/32400)
UseLegacyAssembler = 0x10,
+ /// UseSortByNameFilter, implies UseOwnDisassembler
+ SortedOutput = 0x20,
}
public static partial class Tester
@@ -102,9 +105,9 @@ static Tester()
TesterPath = Path.GetDirectoryName(typeof(Tester).Assembly.Location);
TestCasePath = Path.Combine(TesterPath, "../../../../TestCases");
#if DEBUG
- testRunnerBasePath = Path.Combine(TesterPath, "../../../../../ICSharpCode.Decompiler.TestRunner/bin/Debug/net6.0-windows");
+ testRunnerBasePath = Path.Combine(TesterPath, "../../../../../ICSharpCode.Decompiler.TestRunner/bin/Debug/net7.0");
#else
- testRunnerBasePath = Path.Combine(TesterPath, "../../../../../ICSharpCode.Decompiler.TestRunner/bin/Release/net6.0-windows");
+ testRunnerBasePath = Path.Combine(TesterPath, "../../../../../ICSharpCode.Decompiler.TestRunner/bin/Release/net7.0");
#endif
packagesPropsFile = Path.Combine(TesterPath, "../../../../../packages.props");
roslynLatestVersion = XDocument.Load(packagesPropsFile).XPathSelectElement("//RoslynVersion").Value;
@@ -175,13 +178,19 @@ public static async Task AssembleIL(string sourceFileName, AssemblerOpti
}
var command = Cli.Wrap(ilasmPath)
- .WithArguments($"/nologo {otherOptions}/output=\"{outputFile}\" \"{sourceFileName}\"")
+ .WithArguments($"/quiet {otherOptions}/output=\"{outputFile}\" \"{sourceFileName}\"")
.WithValidation(CommandResultValidation.None);
var result = await command.ExecuteBufferedAsync().ConfigureAwait(false);
- Console.WriteLine("output: " + result.StandardOutput);
- Console.WriteLine("errors: " + result.StandardError);
+ if (!string.IsNullOrWhiteSpace(result.StandardOutput))
+ {
+ Console.WriteLine("output:" + Environment.NewLine + result.StandardOutput);
+ }
+ if (!string.IsNullOrWhiteSpace(result.StandardError))
+ {
+ Console.WriteLine("errors:" + Environment.NewLine + result.StandardError);
+ }
Assert.AreEqual(0, result.ExitCode, "ilasm failed");
return outputFile;
@@ -189,7 +198,7 @@ public static async Task AssembleIL(string sourceFileName, AssemblerOpti
public static async Task Disassemble(string sourceFileName, string outputFile, AssemblerOptions asmOptions)
{
- if (asmOptions.HasFlag(AssemblerOptions.UseOwnDisassembler))
+ if (asmOptions.HasFlag(AssemblerOptions.UseOwnDisassembler) || asmOptions.HasFlag(AssemblerOptions.SortedOutput))
{
using (var peFileStream = new FileStream(sourceFileName, FileMode.Open, FileAccess.Read))
using (var peFile = new PEFile(sourceFileName, peFileStream))
@@ -198,7 +207,11 @@ public static async Task Disassemble(string sourceFileName, string outpu
var metadata = peFile.Metadata;
var output = new PlainTextOutput(writer);
ReflectionDisassembler rd = new ReflectionDisassembler(output, CancellationToken.None);
- rd.AssemblyResolver = new UniversalAssemblyResolver(sourceFileName, true, null);
+ if (asmOptions.HasFlag(AssemblerOptions.SortedOutput))
+ {
+ rd.EntityProcessor = new SortByNameProcessor();
+ }
+ rd.AssemblyResolver = new UniversalAssemblyResolver(sourceFileName, throwOnError: true, null);
rd.DetectControlStructure = false;
rd.WriteAssemblyReferences(metadata);
if (metadata.IsAssembly)
@@ -223,8 +236,14 @@ public static async Task Disassemble(string sourceFileName, string outpu
var result = await command.ExecuteBufferedAsync().ConfigureAwait(false);
- Console.WriteLine("output: " + result.StandardOutput);
- Console.WriteLine("errors: " + result.StandardError);
+ if (!string.IsNullOrWhiteSpace(result.StandardOutput))
+ {
+ Console.WriteLine("output:" + Environment.NewLine + result.StandardOutput);
+ }
+ if (!string.IsNullOrWhiteSpace(result.StandardError))
+ {
+ Console.WriteLine("errors:" + Environment.NewLine + result.StandardError);
+ }
Assert.AreEqual(0, result.ExitCode, "ildasm failed");
// Unlike the .imagebase directive (which is a fixed value when compiling with /deterministic),
@@ -251,8 +270,8 @@ private static string ReplacePrivImplDetails(string il)
}
static readonly string coreRefAsmPath = new DotNetCorePathFinder(TargetFrameworkIdentifier.NET,
- new Version(6, 0), "Microsoft.NETCore.App")
- .GetReferenceAssemblyPath(".NETCoreApp,Version=v6.0");
+ new Version(7, 0), "Microsoft.NETCore.App")
+ .GetReferenceAssemblyPath(".NETCoreApp,Version=v7.0");
public static readonly string RefAsmPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86),
@"Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2");
@@ -289,7 +308,7 @@ private static string ReplacePrivImplDetails(string il)
const string targetFrameworkAttributeSnippet = @"
-[assembly: System.Runtime.Versioning.TargetFramework("".NETCoreApp,Version=v6.0"", FrameworkDisplayName = """")]
+[assembly: System.Runtime.Versioning.TargetFramework("".NETCoreApp,Version=v7.0"", FrameworkDisplayName = """")]
";
@@ -324,6 +343,7 @@ public static List GetPreprocessorSymbols(CompilerOptions flags)
{
preprocessorSymbols.Add("NETCORE");
preprocessorSymbols.Add("NET60");
+ preprocessorSymbols.Add("NET70");
}
preprocessorSymbols.Add("ROSLYN");
preprocessorSymbols.Add("CS60");
@@ -352,10 +372,7 @@ public static List GetPreprocessorSymbols(CompilerOptions flags)
{
preprocessorSymbols.Add("ROSLYN4");
preprocessorSymbols.Add("CS100");
- if (flags.HasFlag(CompilerOptions.Preview))
- {
- preprocessorSymbols.Add("CS110");
- }
+ preprocessorSymbols.Add("CS110");
}
}
else if ((flags & CompilerOptions.UseMcsMask) != 0)
@@ -425,7 +442,11 @@ public static async Task CompileCSharp(string sourceFileName, C
{
references = references.Concat(new[] { "-r:\"Microsoft.VisualBasic.dll\"" });
}
- string otherOptions = $"-noconfig " +
+ if (useRoslyn && !targetNet40 && flags.HasFlag(CompilerOptions.ReferenceUnsafe))
+ {
+ references = references.Concat(new[] { "-r:\"System.Runtime.CompilerServices.Unsafe.dll\"" });
+ }
+ string otherOptions = $"-nologo -noconfig " +
$"-langversion:{languageVersion} " +
$"-unsafe -o{(flags.HasFlag(CompilerOptions.Optimize) ? "+ " : "- ")}";
@@ -477,12 +498,18 @@ public static async Task CompileCSharp(string sourceFileName, C
var command = Cli.Wrap(cscPath)
.WithArguments($"{otherOptions} -lib:{libPath} {string.Join(" ", references)} -out:\"{Path.GetFullPath(results.PathToAssembly)}\" {string.Join(" ", sourceFileNames.Select(fn => '"' + Path.GetFullPath(fn) + '"'))}")
.WithValidation(CommandResultValidation.None);
- Console.WriteLine($"\"{command.TargetFilePath}\" {command.Arguments}");
+ //Console.WriteLine($"\"{command.TargetFilePath}\" {command.Arguments}");
var result = await command.ExecuteBufferedAsync().ConfigureAwait(false);
+ if (!string.IsNullOrWhiteSpace(result.StandardOutput))
+ {
+ Console.WriteLine("output:" + Environment.NewLine + result.StandardOutput);
+ }
+ if (!string.IsNullOrWhiteSpace(result.StandardError))
+ {
+ Console.WriteLine("errors:" + Environment.NewLine + result.StandardError);
+ }
- Console.WriteLine("output: " + result.StandardOutput);
- Console.WriteLine("errors: " + result.StandardError);
Assert.AreEqual(0, result.ExitCode, "csc failed");
return results;
@@ -533,12 +560,18 @@ public static async Task CompileCSharp(string sourceFileName, C
var command = Cli.Wrap(mcsPath)
.WithArguments($"{otherOptions}-out:\"{Path.GetFullPath(results.PathToAssembly)}\" {string.Join(" ", sourceFileNames.Select(fn => '"' + Path.GetFullPath(fn) + '"'))}")
.WithValidation(CommandResultValidation.None);
- Console.WriteLine($"\"{command.TargetFilePath}\" {command.Arguments}");
+ //Console.WriteLine($"\"{command.TargetFilePath}\" {command.Arguments}");
var result = await command.ExecuteBufferedAsync().ConfigureAwait(false);
- Console.WriteLine("output: " + result.StandardOutput);
- Console.WriteLine("errors: " + result.StandardError);
+ if (!string.IsNullOrWhiteSpace(result.StandardOutput))
+ {
+ Console.WriteLine("output:" + Environment.NewLine + result.StandardOutput);
+ }
+ if (!string.IsNullOrWhiteSpace(result.StandardError))
+ {
+ Console.WriteLine("errors:" + Environment.NewLine + result.StandardError);
+ }
Assert.AreEqual(0, result.ExitCode, "mcs failed");
return results;
@@ -553,7 +586,7 @@ internal static DecompilerSettings GetSettings(CompilerOptions cscOptions)
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.CSharp10_0,
+ _ => cscOptions.HasFlag(CompilerOptions.Preview) ? CSharp.LanguageVersion.Latest : CSharp.LanguageVersion.CSharp11_0,
};
DecompilerSettings settings = new(langVersion) {
// Never use file-scoped namespaces
@@ -810,8 +843,14 @@ public static async Task SignAssembly(string assemblyPath, string keyFilePath)
var result = await command.ExecuteBufferedAsync().ConfigureAwait(false);
Assert.AreEqual(0, result.ExitCode, "sn failed");
- Console.WriteLine("output: " + result.StandardOutput);
- Console.WriteLine("errors: " + result.StandardError);
+ if (!string.IsNullOrWhiteSpace(result.StandardOutput))
+ {
+ Console.WriteLine("output:" + Environment.NewLine + result.StandardOutput);
+ }
+ if (!string.IsNullOrWhiteSpace(result.StandardError))
+ {
+ Console.WriteLine("errors:" + Environment.NewLine + result.StandardError);
+ }
}
public static async Task FindMSBuild()
diff --git a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
index 90c8558727..5af3b8fabc 100644
--- a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
+++ b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
@@ -1,4 +1,4 @@
-
+
@@ -9,7 +9,7 @@
True
- 1701;1702;1705,67,169,1058,728,1720,649,168,251,660,661,675;1998;162
+ 1701;1702;1705,67,169,1058,728,1720,649,168,251,660,661,675;1998;162;8632;626;8618;8714;8602
False
False
@@ -17,6 +17,7 @@
false
True
+ True
True
..\ICSharpCode.Decompiler\ICSharpCode.Decompiler.snk
@@ -33,11 +34,11 @@
- TRACE;DEBUG;ROSLYN;CS60;CS70;CS71;CS72;CS73;CS80;CS90;CS100
+ TRACE;DEBUG;ROSLYN;NET60;CS60;CS70;CS71;CS72;CS73;CS80;CS90;CS100
- TRACE;ROSLYN;CS60;CS70;CS71;CS72;CS73;CS80;CS90;CS100
+ TRACE;ROSLYN;NET60;CS60;CS70;CS71;CS72;CS73;CS80;CS90;CS100
@@ -45,7 +46,7 @@
-
+
@@ -57,10 +58,11 @@
-
+
+
@@ -73,6 +75,9 @@
+
+
+
@@ -110,6 +115,13 @@
+
+
+
+
+
+
+
@@ -211,6 +223,7 @@
+
@@ -312,6 +325,7 @@
+
@@ -326,6 +340,7 @@
+
diff --git a/ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs b/ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs
index 237bdd4029..5338bb7c99 100644
--- a/ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs
+++ b/ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs
@@ -263,6 +263,12 @@ public async Task GuessAccessors()
await Run();
}
+ [Test]
+ public async Task EmptyBodies()
+ {
+ await Run();
+ }
+
async Task Run([CallerMemberName] string testName = null, DecompilerSettings settings = null,
AssemblerOptions assemblerOptions = AssemblerOptions.Library)
{
diff --git a/ICSharpCode.Decompiler.Tests/PdbGenerationTestRunner.cs b/ICSharpCode.Decompiler.Tests/PdbGenerationTestRunner.cs
index 174711c8b5..991c59caef 100644
--- a/ICSharpCode.Decompiler.Tests/PdbGenerationTestRunner.cs
+++ b/ICSharpCode.Decompiler.Tests/PdbGenerationTestRunner.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection.Metadata;
@@ -9,13 +8,10 @@
using System.Xml.Linq;
using ICSharpCode.Decompiler.CSharp;
-using ICSharpCode.Decompiler.CSharp.OutputVisitor;
using ICSharpCode.Decompiler.DebugInfo;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.Tests.Helpers;
-using ICSharpCode.Decompiler.TypeSystem;
-using Microsoft.CodeAnalysis.CSharp;
using Microsoft.DiaSymReader.Tools;
using NUnit.Framework;
@@ -72,6 +68,60 @@ public void CustomPdbId()
}
}
+ [Test]
+ public void ProgressReporting()
+ {
+ // Generate a PDB for an assembly and validate that the progress reporter is called with reasonable values
+ (string peFileName, string pdbFileName) = CompileTestCase(nameof(ProgressReporting));
+
+ var moduleDefinition = new PEFile(peFileName);
+ var resolver = new UniversalAssemblyResolver(peFileName, false, moduleDefinition.Metadata.DetectTargetFrameworkId(), null, PEStreamOptions.PrefetchEntireImage);
+ var decompiler = new CSharpDecompiler(moduleDefinition, resolver, new DecompilerSettings());
+
+ var lastFilesWritten = 0;
+ var totalFiles = -1;
+
+ Action reportFunc = progress => {
+ if (totalFiles == -1)
+ {
+ // Initialize value on first call
+ totalFiles = progress.TotalUnits;
+ }
+
+ Assert.AreEqual(progress.TotalUnits, totalFiles);
+ Assert.AreEqual(progress.UnitsCompleted, lastFilesWritten + 1);
+
+ lastFilesWritten = progress.UnitsCompleted;
+ };
+
+ using (FileStream pdbStream = File.Open(Path.Combine(TestCasePath, nameof(ProgressReporting) + ".pdb"), FileMode.OpenOrCreate, FileAccess.ReadWrite))
+ {
+ pdbStream.SetLength(0);
+ PortablePdbWriter.WritePdb(moduleDefinition, decompiler, new DecompilerSettings(), pdbStream, noLogo: true, progress: new TestProgressReporter(reportFunc));
+
+ pdbStream.Position = 0;
+ var metadataReader = MetadataReaderProvider.FromPortablePdbStream(pdbStream).GetMetadataReader();
+ var generatedPdbId = new BlobContentId(metadataReader.DebugMetadataHeader.Id);
+ }
+
+ Assert.AreEqual(totalFiles, lastFilesWritten);
+ }
+
+ private class TestProgressReporter : IProgress
+ {
+ private Action reportFunc;
+
+ public TestProgressReporter(Action reportFunc)
+ {
+ this.reportFunc = reportFunc;
+ }
+
+ public void Report(DecompilationProgress value)
+ {
+ reportFunc(value);
+ }
+ }
+
private void TestGeneratePdb([CallerMemberName] string testName = null)
{
const PdbToXmlOptions options = PdbToXmlOptions.IncludeEmbeddedSources | PdbToXmlOptions.ThrowOnError | PdbToXmlOptions.IncludeTokens | PdbToXmlOptions.ResolveTokens | PdbToXmlOptions.IncludeMethodSpans;
diff --git a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
index b2542be8d1..c341835e0e 100644
--- a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
+++ b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
@@ -1,4 +1,4 @@
-// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
@@ -135,15 +135,7 @@ public void AllFilesHaveTests()
CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest,
};
- static readonly CompilerOptions[] roslynLatestOnlyWithNet40Options =
- {
- CompilerOptions.UseRoslynLatest | CompilerOptions.TargetNet40,
- CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest | CompilerOptions.TargetNet40,
- CompilerOptions.UseRoslynLatest,
- CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest,
- };
-
- static readonly CompilerOptions[] roslynLatestOnlyOptions =
+ static readonly CompilerOptions[] roslyn4OrNewerOptions =
{
CompilerOptions.UseRoslynLatest,
CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest,
@@ -261,7 +253,7 @@ public async Task Switch([ValueSource(nameof(defaultOptions))] CompilerOptions c
}
[Test]
- public async Task SwitchExpressions([ValueSource(nameof(roslynLatestOnlyOptions))] CompilerOptions cscOptions)
+ public async Task SwitchExpressions([ValueSource(nameof(roslyn3OrNewerOptions))] CompilerOptions cscOptions)
{
await RunForLibrary(cscOptions: cscOptions);
}
@@ -275,7 +267,7 @@ public async Task ReduceNesting([ValueSource(nameof(defaultOptions))] CompilerOp
[Test]
public async Task DelegateConstruction([ValueSource(nameof(defaultOptionsWithMcs))] CompilerOptions cscOptions)
{
- await RunForLibrary(cscOptions: cscOptions | CompilerOptions.Preview);
+ await RunForLibrary(cscOptions: cscOptions);
}
[Test]
@@ -320,6 +312,12 @@ public async Task LiftedOperators([ValueSource(nameof(defaultOptions))] Compiler
await RunForLibrary(cscOptions: cscOptions);
}
+ [Test]
+ public async Task Operators([ValueSource(nameof(defaultOptions))] CompilerOptions cscOptions)
+ {
+ await RunForLibrary(cscOptions: cscOptions);
+ }
+
[Test]
public async Task Generics([ValueSource(nameof(defaultOptions))] CompilerOptions cscOptions)
{
@@ -329,18 +327,17 @@ public async Task Generics([ValueSource(nameof(defaultOptions))] CompilerOptions
[Test]
public async Task Loops([ValueSource(nameof(defaultOptionsWithMcs))] CompilerOptions cscOptions)
{
- await RunForLibrary(cscOptions: cscOptions, decompilerSettings: new DecompilerSettings {
- // legacy csc generates a dead store in debug builds
- RemoveDeadStores = (cscOptions == CompilerOptions.None),
- UseExpressionBodyForCalculatedGetterOnlyProperties = false,
- FileScopedNamespaces = false,
- });
+ DecompilerSettings settings = Tester.GetSettings(cscOptions);
+ // legacy csc generates a dead store in debug builds
+ settings.RemoveDeadStores = (cscOptions == CompilerOptions.None);
+ settings.UseExpressionBodyForCalculatedGetterOnlyProperties = false;
+ await RunForLibrary(cscOptions: cscOptions, decompilerSettings: settings);
}
[Test]
public async Task LocalFunctions([ValueSource(nameof(roslyn2OrNewerOptions))] CompilerOptions cscOptions)
{
- await RunForLibrary(cscOptions: cscOptions | CompilerOptions.Preview);
+ await RunForLibrary(cscOptions: cscOptions);
}
[Test]
@@ -376,7 +373,7 @@ public async Task CheckedUnchecked([ValueSource(nameof(defaultOptions))] Compile
[Test]
public async Task UnsafeCode([ValueSource(nameof(defaultOptions))] CompilerOptions cscOptions)
{
- await RunForLibrary(cscOptions: cscOptions);
+ await RunForLibrary(cscOptions: cscOptions | CompilerOptions.ReferenceUnsafe);
}
[Test]
@@ -494,13 +491,13 @@ public async Task NullableRefTypes([ValueSource(nameof(roslyn3OrNewerOptions))]
}
[Test]
- public async Task NativeInts([ValueSource(nameof(roslynLatestOnlyOptions))] CompilerOptions cscOptions)
+ public async Task NativeInts([ValueSource(nameof(roslyn3OrNewerWithNet40Options))] CompilerOptions cscOptions)
{
- await RunForLibrary(cscOptions: cscOptions | CompilerOptions.Preview);
+ await RunForLibrary(cscOptions: cscOptions);
}
[Test]
- public async Task FileScopedNamespaces([ValueSource(nameof(roslynLatestOnlyOptions))] CompilerOptions cscOptions)
+ public async Task FileScopedNamespaces([ValueSource(nameof(roslyn4OrNewerOptions))] CompilerOptions cscOptions)
{
await RunForLibrary(cscOptions: cscOptions, decompilerSettings: new DecompilerSettings());
}
@@ -512,13 +509,13 @@ public async Task Structs([ValueSource(nameof(defaultOptionsWithMcs))] CompilerO
}
[Test]
- public async Task FunctionPointers([ValueSource(nameof(roslynLatestOnlyOptions))] CompilerOptions cscOptions)
+ public async Task FunctionPointers([ValueSource(nameof(roslyn3OrNewerOptions))] CompilerOptions cscOptions)
{
- await RunForLibrary(cscOptions: cscOptions | CompilerOptions.Preview);
+ await RunForLibrary(cscOptions: cscOptions);
}
[Test]
- public async Task Records([ValueSource(nameof(roslynLatestOnlyOptions))] CompilerOptions cscOptions)
+ public async Task Records([ValueSource(nameof(roslyn3OrNewerOptions))] CompilerOptions cscOptions)
{
await RunForLibrary(cscOptions: cscOptions | CompilerOptions.NullableEnable);
}
@@ -547,6 +544,12 @@ public async Task RefLocalsAndReturns([ValueSource(nameof(roslyn2OrNewerOptions)
await RunForLibrary(cscOptions: cscOptions);
}
+ [Test]
+ public async Task RefFields([ValueSource(nameof(roslyn4OrNewerOptions))] CompilerOptions cscOptions)
+ {
+ await RunForLibrary(cscOptions: cscOptions);
+ }
+
[Test]
public async Task ThrowExpressions([ValueSource(nameof(roslyn2OrNewerOptions))] CompilerOptions cscOptions)
{
@@ -568,12 +571,6 @@ public async Task QualifierTests([ValueSource(nameof(defaultOptions))] CompilerO
[Test]
public async Task TupleTests([ValueSource(nameof(roslyn2OrNewerOptions))] CompilerOptions cscOptions)
{
- if (cscOptions.HasFlag(CompilerOptions.UseRoslynLatest))
- {
- Assert.Ignore("DefaultInterpolatedStringHandler is not yet supported!");
- return;
- }
-
await RunForLibrary(cscOptions: cscOptions);
}
@@ -586,7 +583,7 @@ public async Task NamedArguments([ValueSource(nameof(defaultOptions))] CompilerO
[Test]
public async Task OptionalArguments([ValueSource(nameof(defaultOptions))] CompilerOptions cscOptions)
{
- await RunForLibrary(cscOptions: cscOptions | CompilerOptions.Preview);
+ await RunForLibrary(cscOptions: cscOptions);
}
[Test]
@@ -610,11 +607,6 @@ public async Task AssemblyCustomAttributes([ValueSource(nameof(defaultOptions))]
[Test]
public async Task CustomAttributes([ValueSource(nameof(defaultOptions))] CompilerOptions cscOptions)
{
- if (cscOptions.HasFlag(CompilerOptions.UseRoslynLatest))
- {
- // Test C# 11 generic attributes
- cscOptions |= CompilerOptions.Preview;
- }
await RunForLibrary(cscOptions: cscOptions);
}
@@ -669,7 +661,7 @@ public async Task TypeMemberTests([ValueSource(nameof(defaultOptions))] Compiler
[Test]
public async Task YieldReturn([ValueSource(nameof(defaultOptionsWithMcs))] CompilerOptions cscOptions)
{
- await RunForLibrary(cscOptions: cscOptions | CompilerOptions.Preview);
+ await RunForLibrary(cscOptions: cscOptions);
}
[Test]
@@ -703,9 +695,9 @@ public async Task CovariantReturns([ValueSource(nameof(roslyn3OrNewerOptions))]
}
[Test]
- public async Task StaticAbstractInterfaceMembers([ValueSource(nameof(roslynLatestOnlyOptions))] CompilerOptions cscOptions)
+ public async Task StaticAbstractInterfaceMembers([ValueSource(nameof(roslyn4OrNewerOptions))] CompilerOptions cscOptions)
{
- await RunForLibrary(cscOptions: cscOptions | CompilerOptions.Preview);
+ await RunForLibrary(cscOptions: cscOptions);
}
[Test]
diff --git a/ICSharpCode.Decompiler.Tests/Semantics/OverloadResolutionTests.cs b/ICSharpCode.Decompiler.Tests/Semantics/OverloadResolutionTests.cs
index 46b297807a..5a72ad5b2c 100644
--- a/ICSharpCode.Decompiler.Tests/Semantics/OverloadResolutionTests.cs
+++ b/ICSharpCode.Decompiler.Tests/Semantics/OverloadResolutionTests.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
+// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
@@ -104,7 +104,7 @@ public void PreferUIntOverLong_FromIntLiteral()
Assert.AreSame(c1, r.BestCandidate);
}
- [Test, Ignore("Broken after migration to ICS.Decompiler")]
+ [Test]
public void NullableIntAndNullableUIntIsAmbiguous()
{
OverloadResolution r = new OverloadResolution(compilation, MakeArgumentList(typeof(ushort?)));
@@ -300,7 +300,7 @@ public void BetterConversionByLambdaReturnValue_ExpressionTree()
Assert.AreEqual(OverloadResolutionErrors.None, r.BestCandidateErrors);
}
- [Test, Ignore("Broken on SRM branch???")]
+ [Test]
public void Lambda_DelegateAndExpressionTreeOverloadsAreAmbiguous()
{
var m1 = MakeMethod(typeof(Func));
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/DecimalFields.cs b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/DecimalFields.cs
index f3873bc387..c843b422a0 100644
--- a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/DecimalFields.cs
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/DecimalFields.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
+// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
@@ -36,7 +36,31 @@ public static int Main()
Console.WriteLine(field2);
Console.WriteLine(field3);
Console.WriteLine(field4);
+ Console.WriteLine(IntToDecimal());
+ Console.WriteLine(UIntToDecimal());
+ Console.WriteLine(LongToDecimal());
+ Console.WriteLine(ULongToDecimal());
return 0;
}
+
+ public static decimal IntToDecimal()
+ {
+ return (decimal)int.MaxValue;
+ }
+
+ public static decimal UIntToDecimal()
+ {
+ return (decimal)uint.MaxValue;
+ }
+
+ public static decimal LongToDecimal()
+ {
+ return (decimal)long.MaxValue;
+ }
+
+ public static decimal ULongToDecimal()
+ {
+ return (decimal)ulong.MaxValue;
+ }
}
}
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/OverloadResolution.cs b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/OverloadResolution.cs
index 6d829ce95b..e206872a5f 100644
--- a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/OverloadResolution.cs
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/OverloadResolution.cs
@@ -36,6 +36,9 @@ static void Main()
Issue1747();
CallAmbiguousOutParam();
CallWithInParam();
+#if CS90
+ NativeIntTests(new IntPtr(1), 2);
+#endif
Issue2444.M2();
Issue2741.B.Test(new Issue2741.C());
}
@@ -337,6 +340,34 @@ static void InVsRegularParam(int i)
#endif
#endregion
+#if CS90
+ static void NativeIntTests(IntPtr i1, nint i2)
+ {
+ Console.WriteLine("NativeIntTests(i1):");
+ ObjectOrLong((object)i1);
+ ObjectOrLong((long)i1);
+ Console.WriteLine("NativeIntTests(i2):");
+ ObjectOrLong((object)i2);
+ ObjectOrLong((long)i2);
+ Console.WriteLine("NativeIntTests(new IntPtr):");
+ ObjectOrLong((object)new IntPtr(3));
+ ObjectOrLong((long)new IntPtr(3));
+ Console.WriteLine("NativeIntTests(IntPtr.Zero):");
+ ObjectOrLong((object)IntPtr.Zero);
+ ObjectOrLong((long)IntPtr.Zero);
+ }
+
+ static void ObjectOrLong(object o)
+ {
+ Console.WriteLine("object " + o);
+ }
+
+ static void ObjectOrLong(long l)
+ {
+ Console.WriteLine("long " + l);
+ }
+#endif
+
#region #2444
public struct Issue2444
{
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/StackTypes.il b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/StackTypes.il
index 9c178a2ce7..47ebea33a1 100644
--- a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/StackTypes.il
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/StackTypes.il
@@ -79,7 +79,34 @@ pointless:
box native int
call void [mscorlib]System.Console::WriteLine(string, object)
- /*
+ ldstr "Int32OrNativeReordered(0x7fffffff, false) = {0}"
+ ldc.i4 0x7fffffff
+ ldc.i4 0
+ call native int Program::Int32OrNativeReordered(int32, bool)
+ box native int
+ call void [mscorlib]System.Console::WriteLine(string, object)
+
+ ldstr "Int32OrNativeReordered(0x7fffffff, true) = {0}"
+ ldc.i4 0x7fffffff
+ ldc.i4 1
+ call native int Program::Int32OrNativeReordered(int32, bool)
+ box native int
+ call void [mscorlib]System.Console::WriteLine(string, object)
+
+ ldstr "Int32OrNativeReordered(-1, false) = {0}"
+ ldc.i4.m1
+ ldc.i4 0
+ call native int Program::Int32OrNativeReordered(int32, bool)
+ box native int
+ call void [mscorlib]System.Console::WriteLine(string, object)
+
+ ldstr "Int32OrNativeReordered(-1, true) = {0}"
+ ldc.i4.m1
+ ldc.i4 1
+ call native int Program::Int32OrNativeReordered(int32, bool)
+ box native int
+ call void [mscorlib]System.Console::WriteLine(string, object)
+
ldstr "Int32OrNativeLoopStyle(0x7fffffff):"
call void [mscorlib]System.Console::WriteLine(string)
ldc.i4 0x7fffffff
@@ -101,7 +128,6 @@ pointless:
call native int Program::Int32OrNativeDeadCode(int32)
box native int
call void [mscorlib]System.Console::WriteLine(string, object)
- */
ldc.i4 0x7fffffff
call void Program::RunInt32OrNativeMultiUse(int32)
@@ -127,7 +153,6 @@ pointless:
ret
}
- /*
.method public static native int Int32OrNativeReordered(int32 val, bool use_native)
{
// The spec is ambiguous whether the addition will be in 32-bits or native size.
@@ -187,7 +212,6 @@ pointless:
conv.u
br after_if
}
- */
.method public static void RunInt32OrNativeMultiUse(int32 val)
{
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Disassembler/Pretty/.gitignore b/ICSharpCode.Decompiler.Tests/TestCases/Disassembler/Pretty/.gitignore
new file mode 100644
index 0000000000..5bb64d7b20
--- /dev/null
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Disassembler/Pretty/.gitignore
@@ -0,0 +1,2 @@
+*.result.il
+*.dll
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Disassembler/Pretty/InterfaceImplAttributes.il b/ICSharpCode.Decompiler.Tests/TestCases/Disassembler/Pretty/InterfaceImplAttributes.il
new file mode 100644
index 0000000000..8ae75838c0
--- /dev/null
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Disassembler/Pretty/InterfaceImplAttributes.il
@@ -0,0 +1,75 @@
+.assembly extern mscorlib
+{
+ .publickeytoken = (
+ b7 7a 5c 56 19 34 e0 89
+ )
+ .ver 4:0:0:0
+}
+.assembly InterfaceImplAttributes
+{
+ .custom instance void [mscorlib]System.Reflection.AssemblyFileVersionAttribute::.ctor(string) = (
+ 01 00 07 31 2e 30 2e 30 2e 30 00 00
+ )
+ .hash algorithm 0x00008004 // SHA1
+ .ver 1:0:0:0
+}
+
+.module InterfaceImplAttributes.dll
+.imagebase 0x10000000
+.file alignment 0x00000200
+.stackreserve 0x00100000
+.subsystem 0x0003 // WindowsCui
+.corflags 0x00000001 // ILOnly
+
+.class private auto ansi ''
+{
+} // end of class
+
+.class public auto ansi beforefieldinit TestType
+ extends [mscorlib]System.Object
+ implements ITestInterfaceA
+{
+ .interfaceimpl type ITestInterfaceA
+ .custom instance void TestAttributeA::.ctor() = (
+ 01 00 00 00
+ )
+
+ // Methods
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor () cil managed
+ {
+ // Method begins at RVA 0x2050
+ // Header size: 1
+ // Code size: 7 (0x7)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: ret
+ } // end of method TestType::.ctor
+
+} // end of class TestType
+
+.class interface public auto ansi abstract ITestInterfaceA
+{
+} // end of class ITestInterfaceA
+
+.class public auto ansi beforefieldinit TestAttributeA
+ extends [mscorlib]System.Attribute
+{
+ // Methods
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor () cil managed
+ {
+ // Method begins at RVA 0x2058
+ // Header size: 1
+ // Code size: 7 (0x7)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Attribute::.ctor()
+ IL_0006: ret
+ } // end of method TestAttributeA::.ctor
+
+} // end of class TestAttributeA
+
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Disassembler/Pretty/SortMembers.expected.il b/ICSharpCode.Decompiler.Tests/TestCases/Disassembler/Pretty/SortMembers.expected.il
new file mode 100644
index 0000000000..2d5208085d
--- /dev/null
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Disassembler/Pretty/SortMembers.expected.il
@@ -0,0 +1,395 @@
+.assembly extern mscorlib
+{
+ .publickeytoken = (
+ b7 7a 5c 56 19 34 e0 89
+ )
+ .ver 4:0:0:0
+}
+.assembly SecurityDeclarations
+{
+ .custom instance void [mscorlib]System.Reflection.AssemblyFileVersionAttribute::.ctor(string) = (
+ 01 00 07 31 2e 30 2e 30 2e 30 00 00
+ )
+ .hash algorithm 0x00008004 // SHA1
+ .ver 1:0:0:0
+}
+
+.module SecurityDeclarations.dll
+.imagebase 0x10000000
+.file alignment 0x00000200
+.stackreserve 0x00100000
+.subsystem 0x0003 // WindowsCui
+.corflags 0x00000001 // ILOnly
+
+.class private auto ansi ''
+{
+} // end of class
+
+.class private auto ansi beforefieldinit SecurityDeclarations.NestedArrays
+ extends [mscorlib]System.Object
+{
+ .permissionset assert = {
+ class 'SecurityDeclarations.SecurityAttrTest, SecurityDeclarations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' = {
+ field object TestBoxed2 = object(object[4](int32(1) int32(2) int32(3) object[3](int32(4) int32(5) int32(6))))
+ }
+ }
+ // Methods
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor () cil managed
+ {
+ // Method begins at RVA 0x20d4
+ // Header size: 1
+ // Code size: 8 (0x8)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: nop
+ IL_0007: ret
+ } // end of method NestedArrays::.ctor
+
+} // end of class SecurityDeclarations.NestedArrays
+
+.class private auto ansi beforefieldinit SecurityDeclarations.SecurityAttrTest
+ extends [mscorlib]System.Security.Permissions.SecurityAttribute
+{
+ // Fields
+ .field private valuetype SecurityDeclarations.TestEnum[] _testEnumArray
+ .field private int32[] _testInt32Array
+ .field private string[] _testStringArray
+ .field private class [mscorlib]System.Type[] _testTypeArray
+ .field public object TestBoxed
+ .field public object TestBoxed2
+ .field public object TestBoxedArray
+ .field public object TestBoxedString
+ .field public object TestBoxedType
+ .field public valuetype SecurityDeclarations.TestEnum TestEnumType
+ .field public int32 TestInt32
+ .field public string TestString
+ .field public class [mscorlib]System.Type TestType
+
+ // Methods
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor (
+ valuetype [mscorlib]System.Security.Permissions.SecurityAction action
+ ) cil managed
+ {
+ // Method begins at RVA 0x2059
+ // Header size: 1
+ // Code size: 10 (0xa)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: ldarg.1
+ IL_0002: call instance void [mscorlib]System.Security.Permissions.SecurityAttribute::.ctor(valuetype [mscorlib]System.Security.Permissions.SecurityAction)
+ IL_0007: nop
+ IL_0008: nop
+ IL_0009: ret
+ } // end of method SecurityAttrTest::.ctor
+
+ .method public hidebysig virtual
+ instance class [mscorlib]System.Security.IPermission CreatePermission () cil managed
+ {
+ // Method begins at RVA 0x2064
+ // Header size: 1
+ // Code size: 7 (0x7)
+ .maxstack 8
+
+ IL_0000: nop
+ IL_0001: newobj instance void [mscorlib]System.NotImplementedException::.ctor()
+ IL_0006: throw
+ } // end of method SecurityAttrTest::CreatePermission
+
+ .method public hidebysig specialname
+ instance valuetype SecurityDeclarations.TestEnum[] get_TestEnumArray () cil managed
+ {
+ // Method begins at RVA 0x208e
+ // Header size: 1
+ // Code size: 7 (0x7)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: ldfld valuetype SecurityDeclarations.TestEnum[] SecurityDeclarations.SecurityAttrTest::_testEnumArray
+ IL_0006: ret
+ } // end of method SecurityAttrTest::get_TestEnumArray
+
+ .method public hidebysig specialname
+ instance int32[] get_TestInt32Array () cil managed
+ {
+ // Method begins at RVA 0x207d
+ // Header size: 1
+ // Code size: 7 (0x7)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: ldfld int32[] SecurityDeclarations.SecurityAttrTest::_testInt32Array
+ IL_0006: ret
+ } // end of method SecurityAttrTest::get_TestInt32Array
+
+ .method public hidebysig specialname
+ instance string[] get_TestStringArray () cil managed
+ {
+ // Method begins at RVA 0x206c
+ // Header size: 1
+ // Code size: 7 (0x7)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: ldfld string[] SecurityDeclarations.SecurityAttrTest::_testStringArray
+ IL_0006: ret
+ } // end of method SecurityAttrTest::get_TestStringArray
+
+ .method public hidebysig specialname
+ instance class [mscorlib]System.Type[] get_TestTypeArray () cil managed
+ {
+ // Method begins at RVA 0x209f
+ // Header size: 1
+ // Code size: 7 (0x7)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: ldfld class [mscorlib]System.Type[] SecurityDeclarations.SecurityAttrTest::_testTypeArray
+ IL_0006: ret
+ } // end of method SecurityAttrTest::get_TestTypeArray
+
+ .method public hidebysig specialname
+ instance void set_TestEnumArray (
+ valuetype SecurityDeclarations.TestEnum[] 'value'
+ ) cil managed
+ {
+ // Method begins at RVA 0x2096
+ // Header size: 1
+ // Code size: 8 (0x8)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: ldarg.1
+ IL_0002: stfld valuetype SecurityDeclarations.TestEnum[] SecurityDeclarations.SecurityAttrTest::_testEnumArray
+ IL_0007: ret
+ } // end of method SecurityAttrTest::set_TestEnumArray
+
+ .method public hidebysig specialname
+ instance void set_TestInt32Array (
+ int32[] 'value'
+ ) cil managed
+ {
+ // Method begins at RVA 0x2085
+ // Header size: 1
+ // Code size: 8 (0x8)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: ldarg.1
+ IL_0002: stfld int32[] SecurityDeclarations.SecurityAttrTest::_testInt32Array
+ IL_0007: ret
+ } // end of method SecurityAttrTest::set_TestInt32Array
+
+ .method public hidebysig specialname
+ instance void set_TestStringArray (
+ string[] 'value'
+ ) cil managed
+ {
+ // Method begins at RVA 0x2074
+ // Header size: 1
+ // Code size: 8 (0x8)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: ldarg.1
+ IL_0002: stfld string[] SecurityDeclarations.SecurityAttrTest::_testStringArray
+ IL_0007: ret
+ } // end of method SecurityAttrTest::set_TestStringArray
+
+ .method public hidebysig specialname
+ instance void set_TestTypeArray (
+ class [mscorlib]System.Type[] 'value'
+ ) cil managed
+ {
+ // Method begins at RVA 0x20a7
+ // Header size: 1
+ // Code size: 8 (0x8)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: ldarg.1
+ IL_0002: stfld class [mscorlib]System.Type[] SecurityDeclarations.SecurityAttrTest::_testTypeArray
+ IL_0007: ret
+ } // end of method SecurityAttrTest::set_TestTypeArray
+
+ // Properties
+ .property instance valuetype SecurityDeclarations.TestEnum[] TestEnumArray()
+ {
+ .get instance valuetype SecurityDeclarations.TestEnum[] SecurityDeclarations.SecurityAttrTest::get_TestEnumArray()
+ .set instance void SecurityDeclarations.SecurityAttrTest::set_TestEnumArray(valuetype SecurityDeclarations.TestEnum[])
+ }
+ .property instance int32[] TestInt32Array()
+ {
+ .get instance int32[] SecurityDeclarations.SecurityAttrTest::get_TestInt32Array()
+ .set instance void SecurityDeclarations.SecurityAttrTest::set_TestInt32Array(int32[])
+ }
+ .property instance string[] TestStringArray()
+ {
+ .get instance string[] SecurityDeclarations.SecurityAttrTest::get_TestStringArray()
+ .set instance void SecurityDeclarations.SecurityAttrTest::set_TestStringArray(string[])
+ }
+ .property instance class [mscorlib]System.Type[] TestTypeArray()
+ {
+ .get instance class [mscorlib]System.Type[] SecurityDeclarations.SecurityAttrTest::get_TestTypeArray()
+ .set instance void SecurityDeclarations.SecurityAttrTest::set_TestTypeArray(class [mscorlib]System.Type[])
+ }
+
+} // end of class SecurityDeclarations.SecurityAttrTest
+
+.class private auto ansi beforefieldinit SecurityDeclarations.SimpleType
+ extends [mscorlib]System.Object
+{
+ // Methods
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor () cil managed
+ {
+ // Method begins at RVA 0x2050
+ // Header size: 1
+ // Code size: 8 (0x8)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: nop
+ IL_0007: ret
+ } // end of method SimpleType::.ctor
+
+} // end of class SecurityDeclarations.SimpleType
+
+.class private auto ansi sealed SecurityDeclarations.TestEnum
+ extends [mscorlib]System.Enum
+{
+ // Fields
+ .field public static literal valuetype SecurityDeclarations.TestEnum A = int32(0)
+ .field public static literal valuetype SecurityDeclarations.TestEnum B = int32(1)
+ .field public static literal valuetype SecurityDeclarations.TestEnum C = int32(2)
+ .field public specialname rtspecialname int32 value__
+
+} // end of class SecurityDeclarations.TestEnum
+
+.class private auto ansi beforefieldinit SecurityDeclarations.TestEnumTypes
+ extends [mscorlib]System.Object
+{
+ .permissionset inheritcheck = {
+ class 'SecurityDeclarations.SecurityAttrTest, SecurityDeclarations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' = {
+ field enum SecurityDeclarations.TestEnum TestEnumType = int32(0)
+ field object TestBoxed = object(int32(1))
+ property enum SecurityDeclarations.TestEnum[] TestEnumArray = int32[3](0 1 2)
+ field object TestBoxed2 = object(object[4](int32(0) int32(1) int32(2) object[1](int32(3))))
+ field object TestBoxedArray = object(int32[3](0 1 2))
+ }
+ }
+ // Methods
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor () cil managed
+ {
+ // Method begins at RVA 0x20c2
+ // Header size: 1
+ // Code size: 8 (0x8)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: nop
+ IL_0007: ret
+ } // end of method TestEnumTypes::.ctor
+
+} // end of class SecurityDeclarations.TestEnumTypes
+
+.class private auto ansi beforefieldinit SecurityDeclarations.TestInt32Types
+ extends [mscorlib]System.Object
+{
+ .permissionset permitonly = {
+ class 'SecurityDeclarations.SecurityAttrTest, SecurityDeclarations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' = {
+ field int32 TestInt32 = int32(5)
+ field object TestBoxed = object(int32(10))
+ property int32[] TestInt32Array = int32[3](1 2 3)
+ field object TestBoxedArray = object(int32[3](4 5 6))
+ field object TestBoxed2 = object(object[3](int32(7) int32(8) int32(9)))
+ }
+ }
+ // Methods
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor () cil managed
+ {
+ // Method begins at RVA 0x20cb
+ // Header size: 1
+ // Code size: 8 (0x8)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: nop
+ IL_0007: ret
+ } // end of method TestInt32Types::.ctor
+
+} // end of class SecurityDeclarations.TestInt32Types
+
+.class private auto ansi beforefieldinit SecurityDeclarations.TestStringTypes
+ extends [mscorlib]System.Object
+{
+ .permissionset assert = {
+ class 'SecurityDeclarations.SecurityAttrTest, SecurityDeclarations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' = {
+ field string TestString = string('Hello World!')
+ field object TestBoxedString = object(string('Boxed String'))
+ property string[] TestStringArray = string[2]('a' 'b')
+ field object TestBoxedArray = object(string[2]('c' 'd'))
+ }
+ }
+ // Methods
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor () cil managed
+ {
+ // Method begins at RVA 0x20b0
+ // Header size: 1
+ // Code size: 8 (0x8)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: nop
+ IL_0007: ret
+ } // end of method TestStringTypes::.ctor
+
+} // end of class SecurityDeclarations.TestStringTypes
+
+.class private sequential ansi sealed beforefieldinit SecurityDeclarations.TestStruct
+ extends [mscorlib]System.ValueType
+{
+ .pack 0
+ .size 1
+
+} // end of class SecurityDeclarations.TestStruct
+
+.class private auto ansi beforefieldinit SecurityDeclarations.TestTypeTypes
+ extends [mscorlib]System.Object
+{
+ .permissionset demand = {
+ class 'SecurityDeclarations.SecurityAttrTest, SecurityDeclarations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' = {
+ field type TestType = type(SecurityDeclarations.SimpleType)
+ field object TestBoxed = object(type(SecurityDeclarations.TestEnum))
+ property type[] TestTypeArray = type[2](SecurityDeclarations.TestStruct SecurityDeclarations.SimpleType)
+ field object TestBoxedArray = object(type[2](SecurityDeclarations.TestStringTypes SecurityDeclarations.TestTypeTypes))
+ }
+ }
+ // Methods
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor () cil managed
+ {
+ // Method begins at RVA 0x20b9
+ // Header size: 1
+ // Code size: 8 (0x8)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: nop
+ IL_0007: ret
+ } // end of method TestTypeTypes::.ctor
+
+} // end of class SecurityDeclarations.TestTypeTypes
+
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Disassembler/Pretty/SortMembers.il b/ICSharpCode.Decompiler.Tests/TestCases/Disassembler/Pretty/SortMembers.il
new file mode 100644
index 0000000000..056544a9db
--- /dev/null
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Disassembler/Pretty/SortMembers.il
@@ -0,0 +1,381 @@
+.assembly extern mscorlib
+{
+ .publickeytoken = (
+ b7 7a 5c 56 19 34 e0 89
+ )
+ .ver 4:0:0:0
+}
+.assembly SecurityDeclarations
+{
+ .custom instance void [mscorlib]System.Reflection.AssemblyFileVersionAttribute::.ctor(string) = (
+ 01 00 07 31 2e 30 2e 30 2e 30 00 00
+ )
+ .hash algorithm 0x00008004 // SHA1
+ .ver 1:0:0:0
+}
+
+.module SecurityDeclarations.dll
+// MVID: {761F919A-2373-48EB-9282-9DAB26913D43}
+.imagebase 0x10000000
+.file alignment 0x00000200
+.stackreserve 0x00100000
+.subsystem 0x0003 // WindowsCui
+.corflags 0x00000001 // ILOnly
+
+
+.class private auto ansi ''
+{
+} // end of class
+
+.class private sequential ansi sealed beforefieldinit SecurityDeclarations.TestStruct
+ extends [mscorlib]System.ValueType
+{
+ .pack 0
+ .size 1
+
+} // end of class SecurityDeclarations.TestStruct
+
+.class private auto ansi beforefieldinit SecurityDeclarations.SimpleType
+ extends [mscorlib]System.Object
+{
+ // Methods
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor () cil managed
+ {
+ // Method begins at RVA 0x2050
+ // Code size 8 (0x8)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: nop
+ IL_0007: ret
+ } // end of method SimpleType::.ctor
+
+} // end of class SecurityDeclarations.SimpleType
+
+.class private auto ansi sealed SecurityDeclarations.TestEnum
+ extends [mscorlib]System.Enum
+{
+ // Fields
+ .field public specialname rtspecialname int32 value__
+ .field public static literal valuetype SecurityDeclarations.TestEnum A = int32(0)
+ .field public static literal valuetype SecurityDeclarations.TestEnum B = int32(1)
+ .field public static literal valuetype SecurityDeclarations.TestEnum C = int32(2)
+
+} // end of class SecurityDeclarations.TestEnum
+
+.class private auto ansi beforefieldinit SecurityDeclarations.SecurityAttrTest
+ extends [mscorlib]System.Security.Permissions.SecurityAttribute
+{
+ // Fields
+ .field private string[] _testStringArray
+ .field private int32[] _testInt32Array
+ .field private valuetype SecurityDeclarations.TestEnum[] _testEnumArray
+ .field private class [mscorlib]System.Type[] _testTypeArray
+ .field public int32 TestInt32
+ .field public class [mscorlib]System.Type TestType
+ .field public valuetype SecurityDeclarations.TestEnum TestEnumType
+ .field public object TestBoxed
+ .field public object TestBoxed2
+ .field public string TestString
+ .field public object TestBoxedString
+ .field public object TestBoxedArray
+ .field public object TestBoxedType
+
+ // Methods
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor (
+ valuetype [mscorlib]System.Security.Permissions.SecurityAction action
+ ) cil managed
+ {
+ // Method begins at RVA 0x2059
+ // Code size 10 (0xa)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: ldarg.1
+ IL_0002: call instance void [mscorlib]System.Security.Permissions.SecurityAttribute::.ctor(valuetype [mscorlib]System.Security.Permissions.SecurityAction)
+ IL_0007: nop
+ IL_0008: nop
+ IL_0009: ret
+ } // end of method SecurityAttrTest::.ctor
+
+ .method public hidebysig virtual
+ instance class [mscorlib]System.Security.IPermission CreatePermission () cil managed
+ {
+ // Method begins at RVA 0x2064
+ // Code size 7 (0x7)
+ .maxstack 8
+
+ IL_0000: nop
+ IL_0001: newobj instance void [mscorlib]System.NotImplementedException::.ctor()
+ IL_0006: throw
+ } // end of method SecurityAttrTest::CreatePermission
+
+ .method public hidebysig specialname
+ instance string[] get_TestStringArray () cil managed
+ {
+ // Method begins at RVA 0x206c
+ // Code size 7 (0x7)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: ldfld string[] SecurityDeclarations.SecurityAttrTest::_testStringArray
+ IL_0006: ret
+ } // end of method SecurityAttrTest::get_TestStringArray
+
+ .method public hidebysig specialname
+ instance void set_TestStringArray (
+ string[] 'value'
+ ) cil managed
+ {
+ // Method begins at RVA 0x2074
+ // Code size 8 (0x8)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: ldarg.1
+ IL_0002: stfld string[] SecurityDeclarations.SecurityAttrTest::_testStringArray
+ IL_0007: ret
+ } // end of method SecurityAttrTest::set_TestStringArray
+
+ .method public hidebysig specialname
+ instance int32[] get_TestInt32Array () cil managed
+ {
+ // Method begins at RVA 0x207d
+ // Code size 7 (0x7)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: ldfld int32[] SecurityDeclarations.SecurityAttrTest::_testInt32Array
+ IL_0006: ret
+ } // end of method SecurityAttrTest::get_TestInt32Array
+
+ .method public hidebysig specialname
+ instance void set_TestInt32Array (
+ int32[] 'value'
+ ) cil managed
+ {
+ // Method begins at RVA 0x2085
+ // Code size 8 (0x8)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: ldarg.1
+ IL_0002: stfld int32[] SecurityDeclarations.SecurityAttrTest::_testInt32Array
+ IL_0007: ret
+ } // end of method SecurityAttrTest::set_TestInt32Array
+
+ .method public hidebysig specialname
+ instance valuetype SecurityDeclarations.TestEnum[] get_TestEnumArray () cil managed
+ {
+ // Method begins at RVA 0x208e
+ // Code size 7 (0x7)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: ldfld valuetype SecurityDeclarations.TestEnum[] SecurityDeclarations.SecurityAttrTest::_testEnumArray
+ IL_0006: ret
+ } // end of method SecurityAttrTest::get_TestEnumArray
+
+ .method public hidebysig specialname
+ instance void set_TestEnumArray (
+ valuetype SecurityDeclarations.TestEnum[] 'value'
+ ) cil managed
+ {
+ // Method begins at RVA 0x2096
+ // Code size 8 (0x8)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: ldarg.1
+ IL_0002: stfld valuetype SecurityDeclarations.TestEnum[] SecurityDeclarations.SecurityAttrTest::_testEnumArray
+ IL_0007: ret
+ } // end of method SecurityAttrTest::set_TestEnumArray
+
+ .method public hidebysig specialname
+ instance class [mscorlib]System.Type[] get_TestTypeArray () cil managed
+ {
+ // Method begins at RVA 0x209f
+ // Code size 7 (0x7)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: ldfld class [mscorlib]System.Type[] SecurityDeclarations.SecurityAttrTest::_testTypeArray
+ IL_0006: ret
+ } // end of method SecurityAttrTest::get_TestTypeArray
+
+ .method public hidebysig specialname
+ instance void set_TestTypeArray (
+ class [mscorlib]System.Type[] 'value'
+ ) cil managed
+ {
+ // Method begins at RVA 0x20a7
+ // Code size 8 (0x8)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: ldarg.1
+ IL_0002: stfld class [mscorlib]System.Type[] SecurityDeclarations.SecurityAttrTest::_testTypeArray
+ IL_0007: ret
+ } // end of method SecurityAttrTest::set_TestTypeArray
+
+ // Properties
+ .property instance string[] TestStringArray()
+ {
+ .get instance string[] SecurityDeclarations.SecurityAttrTest::get_TestStringArray()
+ .set instance void SecurityDeclarations.SecurityAttrTest::set_TestStringArray(string[])
+ }
+ .property instance int32[] TestInt32Array()
+ {
+ .get instance int32[] SecurityDeclarations.SecurityAttrTest::get_TestInt32Array()
+ .set instance void SecurityDeclarations.SecurityAttrTest::set_TestInt32Array(int32[])
+ }
+ .property instance valuetype SecurityDeclarations.TestEnum[] TestEnumArray()
+ {
+ .get instance valuetype SecurityDeclarations.TestEnum[] SecurityDeclarations.SecurityAttrTest::get_TestEnumArray()
+ .set instance void SecurityDeclarations.SecurityAttrTest::set_TestEnumArray(valuetype SecurityDeclarations.TestEnum[])
+ }
+ .property instance class [mscorlib]System.Type[] TestTypeArray()
+ {
+ .get instance class [mscorlib]System.Type[] SecurityDeclarations.SecurityAttrTest::get_TestTypeArray()
+ .set instance void SecurityDeclarations.SecurityAttrTest::set_TestTypeArray(class [mscorlib]System.Type[])
+ }
+
+} // end of class SecurityDeclarations.SecurityAttrTest
+
+.class private auto ansi beforefieldinit SecurityDeclarations.TestStringTypes
+ extends [mscorlib]System.Object
+{
+ .permissionset assert = {
+ class 'SecurityDeclarations.SecurityAttrTest, SecurityDeclarations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' = {
+ field string TestString = string('Hello World!')
+ field object TestBoxedString = object(string('Boxed String'))
+ property string[] TestStringArray = string[2]('a' 'b')
+ field object TestBoxedArray = object(string[2]('c' 'd'))
+ }
+ }
+ // Methods
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor () cil managed
+ {
+ // Method begins at RVA 0x2050
+ // Code size 8 (0x8)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: nop
+ IL_0007: ret
+ } // end of method TestStringTypes::.ctor
+
+} // end of class SecurityDeclarations.TestStringTypes
+
+.class private auto ansi beforefieldinit SecurityDeclarations.TestTypeTypes
+ extends [mscorlib]System.Object
+{
+ .permissionset demand = {
+ class 'SecurityDeclarations.SecurityAttrTest, SecurityDeclarations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' = {
+ field type TestType = type(SecurityDeclarations.SimpleType)
+ field object TestBoxed = object(type(SecurityDeclarations.TestEnum))
+ property type[] TestTypeArray = type[2](SecurityDeclarations.TestStruct SecurityDeclarations.SimpleType)
+ field object TestBoxedArray = object(type[2](SecurityDeclarations.TestStringTypes SecurityDeclarations.TestTypeTypes))
+ }
+ }
+ // Methods
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor () cil managed
+ {
+ // Method begins at RVA 0x2050
+ // Code size 8 (0x8)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: nop
+ IL_0007: ret
+ } // end of method TestTypeTypes::.ctor
+
+} // end of class SecurityDeclarations.TestTypeTypes
+
+.class private auto ansi beforefieldinit SecurityDeclarations.TestEnumTypes
+ extends [mscorlib]System.Object
+{
+ .permissionset inheritcheck = {
+ class 'SecurityDeclarations.SecurityAttrTest, SecurityDeclarations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' = {
+ field enum SecurityDeclarations.TestEnum TestEnumType = int32(0)
+ field object TestBoxed = object(int32(1))
+ property enum SecurityDeclarations.TestEnum[] TestEnumArray = int32[3](0 1 2)
+ field object TestBoxed2 = object(object[4](int32(0) int32(1) int32(2) object[1](int32(3))))
+ field object TestBoxedArray = object(int32[3](0 1 2))
+ }
+ }
+ // Methods
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor () cil managed
+ {
+ // Method begins at RVA 0x2050
+ // Code size 8 (0x8)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: nop
+ IL_0007: ret
+ } // end of method TestEnumTypes::.ctor
+
+} // end of class SecurityDeclarations.TestEnumTypes
+
+.class private auto ansi beforefieldinit SecurityDeclarations.TestInt32Types
+ extends [mscorlib]System.Object
+{
+ .permissionset permitonly = {
+ class 'SecurityDeclarations.SecurityAttrTest, SecurityDeclarations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' = {
+ field int32 TestInt32 = int32(5)
+ field object TestBoxed = object(int32(10))
+ property int32[] TestInt32Array = int32[3](1 2 3)
+ field object TestBoxedArray = object(int32[3](4 5 6))
+ field object TestBoxed2 = object(object[3](int32(7) int32(8) int32(9)))
+ }
+ }
+ // Methods
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor () cil managed
+ {
+ // Method begins at RVA 0x2050
+ // Code size 8 (0x8)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: nop
+ IL_0007: ret
+ } // end of method TestInt32Types::.ctor
+
+} // end of class SecurityDeclarations.TestInt32Types
+
+.class private auto ansi beforefieldinit SecurityDeclarations.NestedArrays
+ extends [mscorlib]System.Object
+{
+ .permissionset assert = {
+ class 'SecurityDeclarations.SecurityAttrTest, SecurityDeclarations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' = {
+ field object TestBoxed2 = object(object[4](int32(1) int32(2) int32(3) object[3](int32(4) int32(5) int32(6))))
+ }
+ }
+ // Methods
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor () cil managed
+ {
+ // Method begins at RVA 0x2050
+ // Code size 8 (0x8)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: nop
+ IL_0007: ret
+ } // end of method NestedArrays::.ctor
+
+} // end of class SecurityDeclarations.NestedArrays
+
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/EmptyBodies.cs b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/EmptyBodies.cs
new file mode 100644
index 0000000000..73998e2bd4
--- /dev/null
+++ b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/EmptyBodies.cs
@@ -0,0 +1,14 @@
+internal class EmptyBodies
+{
+ public static void RetVoid()
+ {
+ }
+ public static int RetInt()
+ {
+ /*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
+ }
+ public static void Nop()
+ {
+ /*Error: End of method reached without returning.*/;
+ }
+}
\ No newline at end of file
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/EmptyBodies.il b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/EmptyBodies.il
new file mode 100644
index 0000000000..bd14a188ca
--- /dev/null
+++ b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/EmptyBodies.il
@@ -0,0 +1,45 @@
+#define CORE_ASSEMBLY "System.Runtime"
+
+.assembly extern CORE_ASSEMBLY
+{
+ .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....:
+ .ver 4:0:0:0
+}
+
+.class private auto ansi beforefieldinit EmptyBodies
+ extends [CORE_ASSEMBLY]System.Object
+{
+ // I cannot test a truly empty body because the assembler will automatically add a ret instruction.
+
+ .method public hidebysig static void RetVoid () cil managed
+ {
+ .maxstack 8
+ ret
+ }
+
+ .method public hidebysig static int32 RetInt () cil managed
+ {
+ .maxstack 8
+ ret
+ }
+
+ .method public hidebysig static void Nop () cil managed
+ {
+ .maxstack 8
+ nop
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor () cil managed
+ {
+ // Method begins at RVA 0x206e
+ // Code size 8 (0x8)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: call instance void [System.Private.CoreLib]System.Object::.ctor()
+ IL_0006: nop
+ IL_0007: ret
+ } // end of method Example::.ctor
+
+} // end of class EmptyBodies
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/GuessAccessors.cs b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/GuessAccessors.cs
index 37d64c6e5b..c9e0f56e07 100644
--- a/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/GuessAccessors.cs
+++ b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/GuessAccessors.cs
@@ -15,9 +15,8 @@ public void MethodUnknownClass()
//IL_0007: Expected O, but got Unknown
UnknownClass val = new UnknownClass();
int? unknownProperty = val.UnknownProperty;
- int? num = unknownProperty.GetValueOrDefault();
- val.UnknownProperty = num;
- int? num2 = num;
+ int? num2 = (val.UnknownProperty = unknownProperty.GetValueOrDefault());
+ int? num3 = num2;
List