Browse Source

Merge branch 'master' of https://github.com/icsharpcode/ILSpy into cs73-stackalloc-initializers

pull/1246/head
Siegfried Pammer 7 years ago
parent
commit
5f699c4236
  1. 2
      DecompilerNuGetDemos.workbook
  2. 5
      Frontends.sln
  3. 6
      ICSharpCode.Decompiler.Console/ICSharpCode.Decompiler.Console.csproj
  4. 35
      ICSharpCode.Decompiler.Console/Program.cs
  5. 1
      ICSharpCode.Decompiler.Console/README.md
  6. 4
      ICSharpCode.Decompiler.PdbProvider.Cecil/ICSharpCode.Decompiler.PdbProvider.Cecil.csproj
  7. 92
      ICSharpCode.Decompiler.PdbProvider.Cecil/MonoCecilDebugInfoProvider.cs
  8. 10
      ICSharpCode.Decompiler.PowerShell/ErrorIds.cs
  9. 59
      ICSharpCode.Decompiler.PowerShell/GetDecompiledProjectCmdlet.cs
  10. 3
      ICSharpCode.Decompiler.PowerShell/GetDecompiledSourceCmdlet.cs
  11. 50
      ICSharpCode.Decompiler.PowerShell/GetDecompiledTypesCmdlet.cs
  12. 42
      ICSharpCode.Decompiler.PowerShell/GetDecompilerCmdlet.cs
  13. 4
      ICSharpCode.Decompiler.PowerShell/ICSharpCode.Decompiler.PowerShell.csproj
  14. 6
      ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs
  15. 4
      ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
  16. 6
      ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs
  17. 383
      ICSharpCode.Decompiler.Tests/Output/CSharpAmbienceTests.cs
  18. 76
      ICSharpCode.Decompiler.Tests/TestCases/Correctness/LocalFunctions.cs
  19. 17
      ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue1256.cs
  20. 58
      ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue1256.il
  21. 358
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.cs
  22. 5553
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.il
  23. 5043
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.opt.il
  24. 5204
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.opt.roslyn.il
  25. 5339
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.roslyn.il
  26. 151
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs
  27. 724
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.il
  28. 620
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.il
  29. 709
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.roslyn.il
  30. 777
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.roslyn.il
  31. 70
      ICSharpCode.Decompiler.Tests/TypeSystem/TypeSystemLoaderTests.cs
  32. 13
      ICSharpCode.Decompiler.Tests/TypeSystem/TypeSystemTestCase.cs
  33. 97
      ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs
  34. 24
      ICSharpCode.Decompiler/CSharp/CallBuilder.cs
  35. 109
      ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
  36. 62
      ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpAmbience.cs
  37. 2
      ICSharpCode.Decompiler/CSharp/StatementBuilder.cs
  38. 12
      ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs
  39. 41
      ICSharpCode.Decompiler/CSharp/Transforms/PatternStatementTransform.cs
  40. 9
      ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs
  41. 9
      ICSharpCode.Decompiler/DebugInfo/IDebugInfoProvider.cs
  42. 20
      ICSharpCode.Decompiler/DecompilerSettings.cs
  43. 3
      ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj
  44. 2
      ICSharpCode.Decompiler/IL/ControlFlow/YieldReturnDecompiler.cs
  45. 14
      ICSharpCode.Decompiler/IL/ILAstWritingOptions.cs
  46. 5
      ICSharpCode.Decompiler/IL/Instructions/Block.cs
  47. 113
      ICSharpCode.Decompiler/IL/Transforms/LocalFunctionDecompiler.cs
  48. 51
      ICSharpCode.Decompiler/IL/Transforms/SplitVariables.cs
  49. 26
      ICSharpCode.Decompiler/IL/Transforms/SwitchOnStringTransform.cs
  50. 2
      ICSharpCode.Decompiler/IL/Transforms/TransformCollectionAndObjectInitializers.cs
  51. 29
      ICSharpCode.Decompiler/IL/Transforms/TransformExpressionTrees.cs
  52. 31
      ICSharpCode.Decompiler/Output/IAmbience.cs
  53. 11
      ICSharpCode.Decompiler/SRMExtensions.cs
  54. 6
      ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataMethod.cs
  55. 11
      ICSharpCode.Decompiler/TypeSystem/KnownTypeReference.cs
  56. 9
      ILSpy.Tests/ILSpy.Tests.csproj
  57. 129
      ILSpy.Tests/Languages/CSharpLanguageTests.cs
  58. 2
      ILSpy.Tests/Stub.cs
  59. 5
      ILSpy.sln
  60. 14
      ILSpy/Analyzers/AnalyzerScope.cs
  61. 27
      ILSpy/Analyzers/Builtin/MethodUsedByAnalyzer.cs
  62. 2
      ILSpy/DebugInfo/PortableDebugInfoProvider.cs
  63. 1
      ILSpy/DebugSteps.xaml
  64. 7
      ILSpy/ILSpy.csproj
  65. 7
      ILSpy/Languages/CSharpHighlightingTokenWriter.cs
  66. 179
      ILSpy/Languages/CSharpLanguage.cs
  67. 18
      ILSpy/Languages/Language.cs
  68. 3
      ILSpy/LoadedAssembly.cs
  69. 18
      ILSpy/LoadedAssemblyExtensions.cs
  70. 14
      ILSpy/MainWindow.xaml.cs
  71. 2
      ILSpy/Properties/AssemblyInfo.template.cs
  72. 3
      ILSpy/Search/AbstractSearchStrategy.cs
  73. 1
      ILSpy/Search/SearchPane.cs
  74. 2
      ILSpy/Search/SearchPane.xaml
  75. 89
      ILSpy/TreeNodes/AssemblyTreeNode.cs

2
DecompilerNuGetDemos.workbook

@ -6,7 +6,7 @@ platforms: @@ -6,7 +6,7 @@ platforms:
- DotNetCore
packages:
- id: ICSharpCode.Decompiler
version: 4.0.0.4285-beta1
version: 4.0.0.4319-beta2
---
Setup: load the references required to work with the decompiler

5
Frontends.sln

@ -10,11 +10,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "doc", "doc", "{F45DB999-7E7 @@ -10,11 +10,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "doc", "doc", "{F45DB999-7E7
doc\IntPtr.txt = doc\IntPtr.txt
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0A344E19-D1FC-4F4C-8883-0844AC669113}"
ProjectSection(SolutionItems) = preProject
Rebracer.xml = Rebracer.xml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ICSharpCode.Decompiler.Console", "ICSharpCode.Decompiler.Console\ICSharpCode.Decompiler.Console.csproj", "{8FDA011E-FAF8-4C1F-A695-21E2C6B5375F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ICSharpCode.Decompiler.PowerShell", "ICSharpCode.Decompiler.PowerShell\ICSharpCode.Decompiler.PowerShell.csproj", "{FF7D6041-3C52-47D1-A32A-0BFE8EE4EEEB}"

6
ICSharpCode.Decompiler.Console/ICSharpCode.Decompiler.Console.csproj

@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
<PackAsTool>true</PackAsTool>
<AssemblyName>ilspycmd</AssemblyName>
<ToolCommandName>ilspycmd</ToolCommandName>
<Version>2.0.0</Version>
<Version>3.0.0</Version>
<Description>Command-line decompiler using the ILSpy decompilation engine</Description>
<Copyright>Copyright 2011-2018 AlphaSierraPapa</Copyright>
<PackageProjectUrl>https://github.com/icsharpcode/ILSpy/</PackageProjectUrl>
@ -23,8 +23,8 @@ @@ -23,8 +23,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.2.0" />
<PackageReference Include="ICSharpCode.Decompiler" Version="4.0.0.4285-beta1" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.2.5" />
<PackageReference Include="ICSharpCode.Decompiler" Version="4.0.0.4319-beta2" />
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
<PackageReference Include="System.Runtime.Handles" Version="4.3.0" />

35
ICSharpCode.Decompiler.Console/Program.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@ -6,6 +6,9 @@ using McMaster.Extensions.CommandLineUtils; @@ -6,6 +6,9 @@ using McMaster.Extensions.CommandLineUtils;
using ICSharpCode.Decompiler.CSharp;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.Disassembler;
using System.Threading;
using System.Reflection.Metadata;
namespace ICSharpCode.Decompiler.Console
{
@ -24,6 +27,7 @@ namespace ICSharpCode.Decompiler.Console @@ -24,6 +27,7 @@ namespace ICSharpCode.Decompiler.Console
var outputOption = app.Option("-o|--outputdir <directory>", "The output directory, if omitted decompiler output is written to standard out.", CommandOptionType.SingleValue);
var typeOption = app.Option("-t|--type <type-name>", "The fully qualified name of the type to decompile.", CommandOptionType.SingleValue);
var listOption = app.Option("-l|--list <entity-type(s)>", "Lists all entities of the specified type(s). Valid types: c(lass), i(interface), s(truct), d(elegate), e(num)", CommandOptionType.MultipleValue);
var ilViewerOption = app.Option("-il|--ilcode", "Show IL code.", CommandOptionType.NoValue);
app.ExtendedHelpText = Environment.NewLine + "-o is valid with every option and required when using -p.";
app.ThrowOnUnexpectedArgument = false; // Ignore invalid arguments / options
@ -60,6 +64,14 @@ namespace ICSharpCode.Decompiler.Console @@ -60,6 +64,14 @@ namespace ICSharpCode.Decompiler.Console
output = File.CreateText(Path.Combine(directory, outputName) + ".list.txt");
}
ListContent(inputAssemblyFileName.Value, output, kinds);
} else if (ilViewerOption.HasValue()) {
TextWriter output = System.Console.Out;
if (outputOption.HasValue()) {
string directory = outputOption.Value();
string outputName = Path.GetFileNameWithoutExtension(inputAssemblyFileName.Value);
output = File.CreateText(Path.Combine(directory, outputName) + ".il");
}
ShowIL(inputAssemblyFileName.Value, output);
} else {
TextWriter output = System.Console.Out;
if (outputOption.HasValue()) {
@ -77,7 +89,7 @@ namespace ICSharpCode.Decompiler.Console @@ -77,7 +89,7 @@ namespace ICSharpCode.Decompiler.Console
static CSharpDecompiler GetDecompiler(string assemblyFileName)
{
return new CSharpDecompiler(assemblyFileName, new DecompilerSettings() { ThrowOnAssemblyResolveErrors = false });
return new CSharpDecompiler(assemblyFileName, new DecompilerSettings() { ThrowOnAssemblyResolveErrors = false });
}
static void ListContent(string assemblyFileName, TextWriter output, ISet<TypeKind> kinds)
@ -91,10 +103,27 @@ namespace ICSharpCode.Decompiler.Console @@ -91,10 +103,27 @@ namespace ICSharpCode.Decompiler.Console
}
}
static void ShowIL(string assemblyFileName, TextWriter output)
{
CSharpDecompiler decompiler = GetDecompiler(assemblyFileName);
ITextOutput textOutput = new PlainTextOutput();
ReflectionDisassembler disassembler = new ReflectionDisassembler(textOutput, CancellationToken.None);
disassembler.DisassembleNamespace(decompiler.TypeSystem.MainModule.RootNamespace.Name,
decompiler.TypeSystem.MainModule.PEFile,
decompiler.TypeSystem.MainModule.TypeDefinitions.Select(x => (TypeDefinitionHandle)x.MetadataToken));
output.WriteLine($"// IL code: {decompiler.TypeSystem.MainModule.AssemblyName}");
output.WriteLine(textOutput.ToString());
output.Flush();
}
static void DecompileAsProject(string assemblyFileName, string outputDirectory)
{
WholeProjectDecompiler decompiler = new WholeProjectDecompiler();
decompiler.DecompileProject(new PEFile(assemblyFileName), outputDirectory);
var module = new PEFile(assemblyFileName);
decompiler.AssemblyResolver = new UniversalAssemblyResolver(assemblyFileName, false, module.Reader.DetectTargetFrameworkId());
decompiler.DecompileProject(module, outputDirectory);
}
static void Decompile(string assemblyFileName, TextWriter output, string typeName = null)

1
ICSharpCode.Decompiler.Console/README.md

@ -21,6 +21,7 @@ Options: @@ -21,6 +21,7 @@ Options:
-t|--type <type-name> The fully qualified name of the type to decompile.
-l|--list <entity-type(s)> Lists all entities of the specified type(s). Valid types: c(lass), i(interface), s(truct),
d(elegate), e(num)
-il|--ilcode Show IL code.
-o is valid with every option and required when using -p.
```

4
ICSharpCode.Decompiler.PdbProvider.Cecil/ICSharpCode.Decompiler.PdbProvider.Cecil.csproj

@ -1,7 +1,9 @@ @@ -1,7 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>7.2</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>

92
ICSharpCode.Decompiler.PdbProvider.Cecil/MonoCecilDebugInfoProvider.cs

@ -16,66 +16,106 @@ @@ -16,66 +16,106 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
using ICSharpCode.Decompiler.DebugInfo;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.Util;
using Mono.Cecil;
using Mono.Cecil.Pdb;
using SRM = System.Reflection.Metadata;
namespace ICSharpCode.Decompiler.PdbProvider.Cecil
{
public class MonoCecilDebugInfoProvider : IDebugInfoProvider
{
readonly ModuleDefinition module;
readonly Dictionary<SRM.MethodDefinitionHandle, (IList<SequencePoint> SequencePoints, IList<Variable> Variables)> debugInfo;
public MonoCecilDebugInfoProvider(ModuleDefinition module, string description = null)
public unsafe MonoCecilDebugInfoProvider(PEFile module, string pdbFileName, string description = null)
{
this.module = module;
this.Description = description ?? "none";
if (module == null) {
throw new ArgumentNullException(nameof(module));
}
if (!module.Reader.IsEntireImageAvailable) {
throw new ArgumentException("This provider needs access to the full image!");
}
this.Description = description ?? $"Loaded from PDB file: {pdbFileName}";
var image = module.Reader.GetEntireImage();
this.debugInfo = new Dictionary<SRM.MethodDefinitionHandle, (IList<SequencePoint> SequencePoints, IList<Variable> Variables)>();
using (UnmanagedMemoryStream stream = new UnmanagedMemoryStream(image.Pointer, image.Length))
using (var moduleDef = ModuleDefinition.ReadModule(stream)) {
moduleDef.ReadSymbols(new PdbReaderProvider().GetSymbolReader(moduleDef, pdbFileName));
foreach (var method in module.Metadata.MethodDefinitions) {
var cecilMethod = moduleDef.LookupToken(MetadataTokens.GetToken(method)) as MethodDefinition;
var debugInfo = cecilMethod?.DebugInformation;
if (debugInfo == null)
continue;
IList<SequencePoint> sequencePoints = EmptyList<SequencePoint>.Instance;
if (debugInfo.HasSequencePoints) {
sequencePoints = new List<SequencePoint>(debugInfo.SequencePoints.Count);
foreach (var point in debugInfo.SequencePoints) {
sequencePoints.Add(new SequencePoint {
Offset = point.Offset,
StartLine = point.StartLine,
StartColumn = point.StartColumn,
EndLine = point.EndLine,
EndColumn = point.EndColumn,
DocumentUrl = point.Document.Url
});
}
}
var variables = new List<Variable>();
foreach (var scope in debugInfo.GetScopes()) {
if (!scope.HasVariables)
continue;
foreach (var v in scope.Variables) {
variables.Add(new Variable(v.Index, v.Name));
}
}
this.debugInfo.Add(method, (sequencePoints, variables));
}
}
}
public string Description { get; }
public IList<SequencePoint> GetSequencePoints(SRM.MethodDefinitionHandle handle)
{
var method = this.module.LookupToken(MetadataTokens.GetToken(handle)) as MethodDefinition;
if (method?.DebugInformation == null || !method.DebugInformation.HasSequencePoints)
if (!debugInfo.TryGetValue(handle, out var info)) {
return EmptyList<SequencePoint>.Instance;
return method.DebugInformation.SequencePoints.Select(point => new SequencePoint {
Offset = point.Offset,
StartLine = point.StartLine,
StartColumn = point.StartColumn,
EndLine = point.EndLine,
EndColumn = point.EndColumn,
DocumentUrl = point.Document.Url
}).ToList();
}
return info.SequencePoints;
}
public IList<Variable> GetVariables(SRM.MethodDefinitionHandle handle)
{
var method = this.module.LookupToken(MetadataTokens.GetToken(handle)) as MethodDefinition;
if (method?.DebugInformation == null)
if (!debugInfo.TryGetValue(handle, out var info)) {
return EmptyList<Variable>.Instance;
return method.DebugInformation.GetScopes()
.SelectMany(s => s.Variables)
.Select(v => new Variable { Name = v.Name }).ToList();
}
return info.Variables;
}
public bool TryGetName(SRM.MethodDefinitionHandle handle, int index, out string name)
{
var method = this.module.LookupToken(MetadataTokens.GetToken(handle)) as MethodDefinition;
name = null;
if (method?.DebugInformation == null || !method.HasBody)
if (!debugInfo.TryGetValue(handle, out var info)) {
return false;
var variable = method.Body.Variables.FirstOrDefault(v => v.Index == index);
if (variable == null)
return false;
return method.DebugInformation.TryGetName(variable, out name);
}
var variable = info.Variables.FirstOrDefault(v => v.Index == index);
name = variable.Name;
return name != null;
}
}
}

10
ICSharpCode.Decompiler.PowerShell/ErrorIds.cs

@ -4,9 +4,9 @@ using System.Text; @@ -4,9 +4,9 @@ using System.Text;
namespace ICSharpCode.Decompiler.PowerShell
{
public static class ErrorIds
{
public static readonly string AssemblyLoadFailed = "1";
public static readonly string DecompilationFailed = "2";
}
public static class ErrorIds
{
public static readonly string AssemblyLoadFailed = "1";
public static readonly string DecompilationFailed = "2";
}
}

59
ICSharpCode.Decompiler.PowerShell/GetDecompiledProjectCmdlet.cs

@ -4,40 +4,41 @@ using System.IO; @@ -4,40 +4,41 @@ using System.IO;
using System.Management.Automation;
using System.Text;
using ICSharpCode.Decompiler.CSharp;
using ICSharpCode.Decompiler.Metadata;
namespace ICSharpCode.Decompiler.PowerShell
{
[Cmdlet(VerbsCommon.Get, "DecompiledProject")]
[OutputType(typeof(string))]
public class GetDecompiledProjectCmdlet : PSCmdlet
{
[Parameter(Position = 0, Mandatory = true)]
public CSharpDecompiler Decompiler { get; set; }
[Cmdlet(VerbsCommon.Get, "DecompiledProject")]
[OutputType(typeof(string))]
public class GetDecompiledProjectCmdlet : PSCmdlet
{
[Parameter(Position = 0, Mandatory = true)]
public CSharpDecompiler Decompiler { get; set; }
[Parameter(Position = 1, Mandatory = true)]
[Alias("PSPath", "OutputPath")]
[ValidateNotNullOrEmpty]
public string LiteralPath { get; set; }
[Parameter(Position = 1, Mandatory = true)]
[Alias("PSPath", "OutputPath")]
[ValidateNotNullOrEmpty]
public string LiteralPath { get; set; }
protected override void ProcessRecord()
{
string path = GetUnresolvedProviderPathFromPSPath(LiteralPath);
if (!Directory.Exists(path))
{
WriteObject("Destination directory must exist prior to decompilation");
return;
}
protected override void ProcessRecord()
{
string path = GetUnresolvedProviderPathFromPSPath(LiteralPath);
if (!Directory.Exists(path)) {
WriteObject("Destination directory must exist prior to decompilation");
return;
}
try
{
WholeProjectDecompiler decompiler = new WholeProjectDecompiler();
decompiler.DecompileProject(Decompiler.TypeSystem.MainModule.PEFile, path);
try {
WholeProjectDecompiler decompiler = new WholeProjectDecompiler();
PEFile module = Decompiler.TypeSystem.MainModule.PEFile;
decompiler.AssemblyResolver = new UniversalAssemblyResolver(module.FileName, false, module.Reader.DetectTargetFrameworkId());
decompiler.DecompileProject(module, path);
WriteObject("Decompilation finished");
} catch (Exception e) {
WriteVerbose(e.ToString());
WriteError(new ErrorRecord(e, ErrorIds.DecompilationFailed, ErrorCategory.OperationStopped, null));
}
}
}
WriteObject("Decompilation finished");
} catch (Exception e) {
WriteVerbose(e.ToString());
WriteError(new ErrorRecord(e, ErrorIds.DecompilationFailed, ErrorCategory.OperationStopped, null));
}
}
}
}

3
ICSharpCode.Decompiler.PowerShell/GetDecompiledSourceCmdlet.cs

@ -20,8 +20,7 @@ namespace ICSharpCode.Decompiler.PowerShell @@ -20,8 +20,7 @@ namespace ICSharpCode.Decompiler.PowerShell
protected override void ProcessRecord()
{
try
{
try {
StringWriter output = new StringWriter();
if (TypeName == null) {
output.Write(Decompiler.DecompileWholeModuleAsString());

50
ICSharpCode.Decompiler.PowerShell/GetDecompiledTypesCmdlet.cs

@ -9,33 +9,33 @@ using ICSharpCode.Decompiler.TypeSystem; @@ -9,33 +9,33 @@ using ICSharpCode.Decompiler.TypeSystem;
namespace ICSharpCode.Decompiler.PowerShell
{
[Cmdlet(VerbsCommon.Get, "DecompiledTypes")]
[OutputType(typeof(ITypeDefinition[]))]
public class GetDecompiledTypesCmdlet : PSCmdlet
{
[Parameter(Position = 0, Mandatory = true)]
public CSharpDecompiler Decompiler { get; set; }
[Cmdlet(VerbsCommon.Get, "DecompiledTypes")]
[OutputType(typeof(ITypeDefinition[]))]
public class GetDecompiledTypesCmdlet : PSCmdlet
{
[Parameter(Position = 0, Mandatory = true)]
public CSharpDecompiler Decompiler { get; set; }
[Parameter(Mandatory = true)]
public string[] Types { get; set; }
[Parameter(Mandatory = true)]
public string[] Types { get; set; }
protected override void ProcessRecord()
{
HashSet<TypeKind> kinds = TypesParser.ParseSelection(Types);
protected override void ProcessRecord()
{
HashSet<TypeKind> kinds = TypesParser.ParseSelection(Types);
try {
List<ITypeDefinition> output = new List<ITypeDefinition>();
foreach (var type in Decompiler.TypeSystem.MainModule.TypeDefinitions) {
if (!kinds.Contains(type.Kind))
continue;
output.Add(type);
}
try {
List<ITypeDefinition> output = new List<ITypeDefinition>();
foreach (var type in Decompiler.TypeSystem.MainModule.TypeDefinitions) {
if (!kinds.Contains(type.Kind))
continue;
output.Add(type);
}
WriteObject(output.ToArray());
} catch (Exception e) {
WriteVerbose(e.ToString());
WriteError(new ErrorRecord(e, ErrorIds.DecompilationFailed, ErrorCategory.OperationStopped, null));
}
}
}
WriteObject(output.ToArray());
} catch (Exception e) {
WriteVerbose(e.ToString());
WriteError(new ErrorRecord(e, ErrorIds.DecompilationFailed, ErrorCategory.OperationStopped, null));
}
}
}
}

42
ICSharpCode.Decompiler.PowerShell/GetDecompilerCmdlet.cs

@ -6,29 +6,29 @@ using ICSharpCode.Decompiler.CSharp; @@ -6,29 +6,29 @@ using ICSharpCode.Decompiler.CSharp;
namespace ICSharpCode.Decompiler.PowerShell
{
[Cmdlet(VerbsCommon.Get, "Decompiler")]
[OutputType(typeof(CSharpDecompiler))]
public class GetDecompilerCmdlet : PSCmdlet
{
[Parameter(Position = 0, Mandatory = true, HelpMessage = "Path to the assembly you want to decompile")]
[Alias("PSPath")]
[ValidateNotNullOrEmpty]
public string LiteralPath { get; set; }
[Cmdlet(VerbsCommon.Get, "Decompiler")]
[OutputType(typeof(CSharpDecompiler))]
public class GetDecompilerCmdlet : PSCmdlet
{
[Parameter(Position = 0, Mandatory = true, HelpMessage = "Path to the assembly you want to decompile")]
[Alias("PSPath")]
[ValidateNotNullOrEmpty]
public string LiteralPath { get; set; }
protected override void ProcessRecord()
{
string path = GetUnresolvedProviderPathFromPSPath(LiteralPath);
protected override void ProcessRecord()
{
string path = GetUnresolvedProviderPathFromPSPath(LiteralPath);
try {
var decompiler = new CSharpDecompiler(path, new DecompilerSettings() {
try {
var decompiler = new CSharpDecompiler(path, new DecompilerSettings() {
ThrowOnAssemblyResolveErrors = false
});
WriteObject(decompiler);
});
WriteObject(decompiler);
} catch (Exception e) {
WriteVerbose(e.ToString());
WriteError(new ErrorRecord(e, ErrorIds.AssemblyLoadFailed, ErrorCategory.OperationStopped, null));
}
}
}
} catch (Exception e) {
WriteVerbose(e.ToString());
WriteError(new ErrorRecord(e, ErrorIds.AssemblyLoadFailed, ErrorCategory.OperationStopped, null));
}
}
}
}

4
ICSharpCode.Decompiler.PowerShell/ICSharpCode.Decompiler.PowerShell.csproj

@ -7,8 +7,8 @@ @@ -7,8 +7,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="PowerShellStandard.Library" Version="5.1.0-preview-03" />
<PackageReference Include="ICSharpCode.Decompiler" Version="4.0.0.4285-beta1" />
<PackageReference Include="PowerShellStandard.Library" Version="5.1.0-preview-06" />
<PackageReference Include="ICSharpCode.Decompiler" Version="4.0.0.4319-beta2" />
</ItemGroup>
</Project>

6
ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs

@ -283,6 +283,12 @@ namespace ICSharpCode.Decompiler.Tests @@ -283,6 +283,12 @@ namespace ICSharpCode.Decompiler.Tests
RunCS(options: options);
}
[Test]
public void LocalFunctions([ValueSource(nameof(roslynOnlyOptions))] CSharpCompilerOptions options)
{
RunCS(options: options);
}
void RunCS([CallerMemberName] string testName = null, CSharpCompilerOptions options = CSharpCompilerOptions.UseDebug)
{
string testFileName = testName + ".cs";

4
ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj

@ -63,15 +63,19 @@ @@ -63,15 +63,19 @@
<ItemGroup>
<Compile Include="DisassemblerPrettyTestRunner.cs" />
<Compile Include="Output\CSharpAmbienceTests.cs" />
<Compile Include="Semantics\ConversionTests.cs" />
<Compile Include="Semantics\ExplicitConversionTest.cs" />
<Compile Include="Semantics\OverloadResolutionTests.cs" />
<Compile Include="DataFlowTest.cs" />
<Compile Include="TestCases\Correctness\LocalFunctions.cs" />
<Compile Include="TestCases\Correctness\RefLocalsAndReturns.cs" />
<Compile Include="TestCases\ILPretty\Issue1256.cs" />
<Compile Include="TestCases\Pretty\CS73_StackAllocInitializers.cs" />
<Compile Include="TestCases\Pretty\OptionalArguments.cs" />
<Compile Include="TestCases\Pretty\CustomShortCircuitOperators.cs" />
<Compile Include="TestCases\Pretty\TypeTests.cs" />
<None Include="TestCases\ILPretty\Issue1256.il" />
<None Include="TestCases\Ugly\NoDecimalConstants.Expected.cs" />
<Compile Include="TestCases\Ugly\NoDecimalConstants.cs" />
<None Include="TestCases\Disassembler\Pretty\SecurityDeclarations.il" />

6
ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs

@ -118,6 +118,12 @@ namespace ICSharpCode.Decompiler.Tests @@ -118,6 +118,12 @@ namespace ICSharpCode.Decompiler.Tests
Run();
}
[Test]
public void Issue1256()
{
Run();
}
[Test]
public void FSharpLoops_Debug()
{

383
ICSharpCode.Decompiler.Tests/Output/CSharpAmbienceTests.cs

@ -0,0 +1,383 @@ @@ -0,0 +1,383 @@
// 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
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using ICSharpCode.Decompiler.CSharp.OutputVisitor;
using ICSharpCode.Decompiler.Output;
using ICSharpCode.Decompiler.Tests.TypeSystem;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.Decompiler.TypeSystem.Implementation;
using NUnit.Framework;
using static ICSharpCode.Decompiler.Output.ConversionFlags;
namespace ICSharpCode.Decompiler.Tests.Output
{
[TestFixture]
public class CSharpAmbienceTests
{
ICompilation compilation;
CSharpAmbience ambience;
[OneTimeSetUp]
public void FixtureSetUp()
{
ambience = new CSharpAmbience();
compilation = new SimpleCompilation(TypeSystemLoaderTests.TestAssembly,
TypeSystemLoaderTests.Mscorlib.WithOptions(TypeSystemOptions.Default));
}
ITypeDefinition GetDefinition(Type type)
{
if (type == null) {
throw new ArgumentNullException(nameof(type));
}
var foundType = compilation.FindType(type).GetDefinition();
Assert.IsNotNull(foundType);
return foundType;
}
const ConversionFlags ILSpyMainTreeViewTypeFlags = ShowTypeParameterList | PlaceReturnTypeAfterParameterList;
const ConversionFlags ILSpyMainTreeViewMemberFlags = ILSpyMainTreeViewTypeFlags | ShowParameterList | ShowReturnType | ShowParameterModifiers;
#region ITypeDefinition tests
[TestCase(None, "Dictionary")]
[TestCase(ShowDefinitionKeyword, "class Dictionary")]
[TestCase(ShowAccessibility, "public Dictionary")]
[TestCase(ShowDefinitionKeyword | ShowAccessibility, "public class Dictionary")]
[TestCase(ShowTypeParameterList, "Dictionary<TKey,TValue>")]
[TestCase(ShowTypeParameterList | ShowDefinitionKeyword | ShowAccessibility, "public class Dictionary<TKey,TValue>")]
[TestCase(UseFullyQualifiedEntityNames | ShowTypeParameterList, "System.Collections.Generic.Dictionary<TKey,TValue>")]
[TestCase(UseFullyQualifiedEntityNames | ShowTypeParameterList | ShowDefinitionKeyword | ShowAccessibility, "public class System.Collections.Generic.Dictionary<TKey,TValue>")]
[TestCase(ILSpyMainTreeViewTypeFlags, "Dictionary<TKey,TValue>")]
public void GenericType(ConversionFlags flags, string expectedOutput)
{
var typeDef = GetDefinition(typeof(Dictionary<,>));
ambience.ConversionFlags = flags;
Assert.AreEqual(expectedOutput, ambience.ConvertSymbol(typeDef));
}
[TestCase(None, "Object")]
[TestCase(ShowDefinitionKeyword, "class Object")]
[TestCase(ShowAccessibility, "public Object")]
[TestCase(ShowDefinitionKeyword | ShowAccessibility, "public class Object")]
[TestCase(ShowTypeParameterList, "Object")]
[TestCase(ShowTypeParameterList | ShowDefinitionKeyword | ShowAccessibility, "public class Object")]
[TestCase(UseFullyQualifiedEntityNames | ShowTypeParameterList, "System.Object")]
[TestCase(All, "public class System.Object")]
[TestCase(ILSpyMainTreeViewTypeFlags, "Object")]
public void SimpleType(ConversionFlags flags, string expectedOutput)
{
var typeDef = GetDefinition(typeof(object));
ambience.ConversionFlags = flags;
Assert.AreEqual(expectedOutput, ambience.ConvertSymbol(typeDef));
}
[TestCase(None, "IEnumerable")]
[TestCase(ShowTypeParameterList, "IEnumerable<T>")]
[TestCase(ShowTypeParameterList | ShowTypeParameterVarianceModifier, "IEnumerable<out T>")]
[TestCase(All, "public interface System.Collections.Generic.IEnumerable<out T>")]
[TestCase(ILSpyMainTreeViewTypeFlags, "IEnumerable<T>")]
public void GenericInterface(ConversionFlags flags, string expectedOutput)
{
var typeDef = GetDefinition(typeof(IEnumerable<>));
ambience.ConversionFlags = flags;
Assert.AreEqual(expectedOutput, ambience.ConvertSymbol(typeDef));
}
[TestCase(None, "Enumerator")]
[TestCase(ShowDefinitionKeyword, "struct Enumerator")]
[TestCase(ShowAccessibility, "public Enumerator")]
[TestCase(ShowDefinitionKeyword | ShowAccessibility, "public struct Enumerator")]
[TestCase(ShowTypeParameterList, "Enumerator")]
[TestCase(ShowTypeParameterList | ShowDefinitionKeyword | ShowAccessibility, "public struct Enumerator")]
[TestCase(UseFullyQualifiedEntityNames | ShowTypeParameterList, "System.Collections.Generic.List<T>.Enumerator")]
[TestCase(ShowDeclaringType | ShowTypeParameterList, "List<T>.Enumerator")]
[TestCase(All, "public struct System.Collections.Generic.List<T>.Enumerator")]
[TestCase(ILSpyMainTreeViewTypeFlags, "Enumerator")]
public void GenericTypeWithNested(ConversionFlags flags, string expectedOutput)
{
var typeDef = GetDefinition(typeof(List<>.Enumerator));
ambience.ConversionFlags = flags;
Assert.AreEqual(expectedOutput, ambience.ConvertSymbol(typeDef));
}
[TestCase(None, "StaticClass")]
[TestCase(ShowDefinitionKeyword, "class StaticClass")]
[TestCase(ShowModifiers | ShowDefinitionKeyword, "static class StaticClass")]
[TestCase(ShowModifiers | ShowAccessibility, "private static StaticClass")]
[TestCase(ShowModifiers | ShowDefinitionKeyword | ShowAccessibility, "private static class StaticClass")]
[TestCase(ShowModifiers | ShowTypeParameterList, "static StaticClass")]
[TestCase(ShowModifiers | ShowTypeParameterList | ShowDefinitionKeyword | ShowAccessibility, "private static class StaticClass")]
[TestCase(All, "private static class ICSharpCode.Decompiler.Tests.Output.CSharpAmbienceTests.StaticClass")]
[TestCase(ILSpyMainTreeViewTypeFlags, "StaticClass")]
public void StaticClassTest(ConversionFlags flags, string expectedOutput)
{
var typeDef = GetDefinition(typeof(StaticClass));
ambience.ConversionFlags = flags;
Assert.AreEqual(expectedOutput, ambience.ConvertSymbol(typeDef));
}
[TestCase(None, "SealedClass")]
[TestCase(ShowDefinitionKeyword, "class SealedClass")]
[TestCase(ShowModifiers | ShowDefinitionKeyword, "sealed class SealedClass")]
[TestCase(ShowModifiers | ShowAccessibility, "private sealed SealedClass")]
[TestCase(ShowModifiers | ShowDefinitionKeyword | ShowAccessibility, "private sealed class SealedClass")]
[TestCase(ShowModifiers | ShowTypeParameterList, "sealed SealedClass")]
[TestCase(ShowModifiers | ShowTypeParameterList | ShowDefinitionKeyword | ShowAccessibility, "private sealed class SealedClass")]
[TestCase(All, "private sealed class ICSharpCode.Decompiler.Tests.Output.CSharpAmbienceTests.SealedClass")]
[TestCase(ILSpyMainTreeViewTypeFlags, "SealedClass")]
public void SealedClassTest(ConversionFlags flags, string expectedOutput)
{
var typeDef = GetDefinition(typeof(SealedClass));
ambience.ConversionFlags = flags;
Assert.AreEqual(expectedOutput, ambience.ConvertSymbol(typeDef));
}
[TestCase(None, "RefStruct")]
[TestCase(ShowDefinitionKeyword, "struct RefStruct")]
[TestCase(ShowModifiers | ShowDefinitionKeyword, "ref struct RefStruct")]
[TestCase(ShowModifiers | ShowAccessibility, "private ref RefStruct")]
[TestCase(ShowModifiers | ShowDefinitionKeyword | ShowAccessibility, "private ref struct RefStruct")]
[TestCase(ShowModifiers | ShowTypeParameterList, "ref RefStruct")]
[TestCase(ShowModifiers | ShowTypeParameterList | ShowDefinitionKeyword | ShowAccessibility, "private ref struct RefStruct")]
[TestCase(All, "private ref struct ICSharpCode.Decompiler.Tests.Output.CSharpAmbienceTests.RefStruct")]
[TestCase(ILSpyMainTreeViewTypeFlags, "RefStruct")]
public void RefStructTest(ConversionFlags flags, string expectedOutput)
{
var typeDef = GetDefinition(typeof(RefStruct));
ambience.ConversionFlags = flags;
Assert.AreEqual(expectedOutput, ambience.ConvertSymbol(typeDef));
}
[TestCase(None, "ReadonlyStruct")]
[TestCase(ShowDefinitionKeyword, "struct ReadonlyStruct")]
[TestCase(ShowModifiers | ShowDefinitionKeyword, "readonly struct ReadonlyStruct")]
[TestCase(ShowModifiers | ShowAccessibility, "private readonly ReadonlyStruct")]
[TestCase(ShowModifiers | ShowDefinitionKeyword | ShowAccessibility, "private readonly struct ReadonlyStruct")]
[TestCase(ShowModifiers | ShowTypeParameterList, "readonly ReadonlyStruct")]
[TestCase(ShowModifiers | ShowTypeParameterList | ShowDefinitionKeyword | ShowAccessibility, "private readonly struct ReadonlyStruct")]
[TestCase(All, "private readonly struct ICSharpCode.Decompiler.Tests.Output.CSharpAmbienceTests.ReadonlyStruct")]
[TestCase(ILSpyMainTreeViewTypeFlags, "ReadonlyStruct")]
public void ReadonlyStructTest(ConversionFlags flags, string expectedOutput)
{
var typeDef = GetDefinition(typeof(ReadonlyStruct));
ambience.ConversionFlags = flags;
Assert.AreEqual(expectedOutput, ambience.ConvertSymbol(typeDef));
}
[TestCase(None, "ReadonlyRefStruct")]
[TestCase(ShowDefinitionKeyword, "struct ReadonlyRefStruct")]
[TestCase(ShowModifiers | ShowDefinitionKeyword, "readonly ref struct ReadonlyRefStruct")]
[TestCase(ShowModifiers | ShowAccessibility, "private readonly ref ReadonlyRefStruct")]
[TestCase(ShowModifiers | ShowDefinitionKeyword | ShowAccessibility, "private readonly ref struct ReadonlyRefStruct")]
[TestCase(ShowModifiers | ShowTypeParameterList, "readonly ref ReadonlyRefStruct")]
[TestCase(ShowModifiers | ShowTypeParameterList | ShowDefinitionKeyword | ShowAccessibility, "private readonly ref struct ReadonlyRefStruct")]
[TestCase(All, "private readonly ref struct ICSharpCode.Decompiler.Tests.Output.CSharpAmbienceTests.ReadonlyRefStruct")]
[TestCase(ILSpyMainTreeViewTypeFlags, "ReadonlyRefStruct")]
public void ReadonlyRefStructTest(ConversionFlags flags, string expectedOutput)
{
var typeDef = GetDefinition(typeof(ReadonlyRefStruct));
ambience.ConversionFlags = flags;
Assert.AreEqual(expectedOutput, ambience.ConvertSymbol(typeDef));
}
#endregion
#region Delegate tests
[TestCase(None, "Func")]
[TestCase(ShowTypeParameterList, "Func<T,TResult>")]
[TestCase(ShowTypeParameterList | ShowTypeParameterVarianceModifier, "Func<in T,out TResult>")]
[TestCase(ShowTypeParameterList | ShowReturnType | ShowTypeParameterVarianceModifier, "TResult Func<in T,out TResult>")]
[TestCase(ShowTypeParameterList | ShowParameterList | ShowTypeParameterVarianceModifier, "Func<in T,out TResult>(T)")]
[TestCase(ShowTypeParameterList | ShowParameterList | ShowReturnType | ShowTypeParameterVarianceModifier, "TResult Func<in T,out TResult>(T)")]
[TestCase(All & ~PlaceReturnTypeAfterParameterList, "public delegate TResult System.Func<in T,out TResult>(T arg);")]
[TestCase(All, "public delegate System.Func<in T,out TResult>(T arg) : TResult;")]
[TestCase(ILSpyMainTreeViewTypeFlags, "Func<T,TResult>")]
public void FuncDelegate(ConversionFlags flags, string expectedOutput)
{
var func = GetDefinition(typeof(Func<,>));
ambience.ConversionFlags = flags;
Assert.AreEqual(expectedOutput, ambience.ConvertSymbol(func));
}
#endregion
#region IField tests
[TestCase(All & ~PlaceReturnTypeAfterParameterList, "private int ICSharpCode.Decompiler.Tests.Output.CSharpAmbienceTests.Program.test;")]
[TestCase(ILSpyMainTreeViewMemberFlags, "test : int")]
[TestCase(ConversionFlags.All & ~(ConversionFlags.ShowDeclaringType | ConversionFlags.ShowModifiers | ConversionFlags.ShowAccessibility | ConversionFlags.PlaceReturnTypeAfterParameterList), "int test;")]
public void SimpleField(ConversionFlags flags, string expectedOutput)
{
var field = GetDefinition(typeof(CSharpAmbienceTests.Program)).GetFields(f => f.Name == "test").Single();
ambience.ConversionFlags = flags;
Assert.AreEqual(expectedOutput, ambience.ConvertSymbol(field));
}
[TestCase(All & ~PlaceReturnTypeAfterParameterList, "private const int ICSharpCode.Decompiler.Tests.Output.CSharpAmbienceTests.Program.TEST2;")]
[TestCase(ILSpyMainTreeViewMemberFlags, "TEST2 : int")]
public void SimpleConstField(ConversionFlags flags, string expectedOutput)
{
var field = compilation.FindType(typeof(CSharpAmbienceTests.Program)).GetFields(f => f.Name == "TEST2").Single();
ambience.ConversionFlags = flags;
Assert.AreEqual(expectedOutput, ambience.ConvertSymbol(field));
}
#endregion
#region IEvent tests
[Test]
public void EventWithDeclaringType()
{
var ev = compilation.FindType(typeof(CSharpAmbienceTests.Program)).GetEvents(f => f.Name == "ProgramChanged").Single();
ambience.ConversionFlags = ConversionFlags.StandardConversionFlags | ConversionFlags.ShowDeclaringType;
string result = ambience.ConvertSymbol(ev);
Assert.AreEqual("public event EventHandler Program.ProgramChanged;", result);
}
[Test]
public void CustomEvent()
{
var ev = compilation.FindType(typeof(CSharpAmbienceTests.Program)).GetEvents(f => f.Name == "SomeEvent").Single();
ambience.ConversionFlags = ConversionFlags.StandardConversionFlags;
string result = ambience.ConvertSymbol(ev);
Assert.AreEqual("public event EventHandler SomeEvent;", result);
}
#endregion
#region Property tests
[TestCase(StandardConversionFlags, "public int Test { get; set; }")]
[TestCase(ILSpyMainTreeViewMemberFlags, "Test : int")]
public void AutomaticProperty(ConversionFlags flags, string expectedOutput)
{
var prop = compilation.FindType(typeof(CSharpAmbienceTests.Program)).GetProperties(p => p.Name == "Test").Single();
ambience.ConversionFlags = flags;
Assert.AreEqual(expectedOutput, ambience.ConvertSymbol(prop));
}
[TestCase(StandardConversionFlags, "public int this[int index] { get; }")]
[TestCase(ILSpyMainTreeViewMemberFlags, "this[int] : int")]
public void Indexer(ConversionFlags flags, string expectedOutput)
{
var prop = compilation.FindType(typeof(CSharpAmbienceTests.Program)).GetProperties(p => p.IsIndexer).Single();
ambience.ConversionFlags = flags;
Assert.AreEqual(expectedOutput, ambience.ConvertSymbol(prop));
}
#endregion
#region IMethod tests
[TestCase(StandardConversionFlags, "public Program(int x);")]
[TestCase(ILSpyMainTreeViewMemberFlags, "Program(int)")]
public void ConstructorTests(ConversionFlags flags, string expectedOutput)
{
var prop = compilation.FindType(typeof(CSharpAmbienceTests.Program)).GetConstructors().Single();
ambience.ConversionFlags = flags;
Assert.AreEqual(expectedOutput, ambience.ConvertSymbol(prop));
}
[TestCase(StandardConversionFlags, "~Program();")]
[TestCase(ILSpyMainTreeViewMemberFlags, "~Program()")]
public void DestructorTests(ConversionFlags flags, string expectedOutput)
{
var dtor = compilation.FindType(typeof(CSharpAmbienceTests.Program))
.GetMembers(m => m.SymbolKind == SymbolKind.Destructor, GetMemberOptions.IgnoreInheritedMembers).Single();
ambience.ConversionFlags = flags;
Assert.AreEqual(expectedOutput, ambience.ConvertSymbol(dtor));
}
#endregion
#region Test types
#pragma warning disable 169, 67
class Test { }
static class StaticClass { }
sealed class SealedClass { }
ref struct RefStruct { }
readonly struct ReadonlyStruct { }
readonly ref struct ReadonlyRefStruct { }
class Program
{
int test;
const int TEST2 = 2;
public int Test { get; set; }
public int this[int index] {
get {
return index;
}
}
public event EventHandler ProgramChanged;
public event EventHandler SomeEvent {
add { }
remove { }
}
public static bool operator +(Program lhs, Program rhs)
{
throw new NotImplementedException();
}
public static implicit operator Test(Program lhs)
{
throw new NotImplementedException();
}
public static explicit operator int(Program lhs)
{
throw new NotImplementedException();
}
public Program(int x)
{
}
~Program()
{
}
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
public static void InParameter(in int a)
{
}
}
#endregion
}
}

76
ICSharpCode.Decompiler.Tests/TestCases/Correctness/LocalFunctions.cs

@ -0,0 +1,76 @@ @@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LocalFunctions
{
class LocalFunctions
{
int field;
public static void Main(string[] args)
{
StaticContextNoCapture(10);
StaticContextSimpleCapture(10);
StaticContextCaptureInForLoop(10);
var inst = new LocalFunctions() { field = 10 };
inst.ContextNoCapture();
inst.ContextSimpleCapture();
inst.ContextCaptureInForLoop();
}
public static void StaticContextNoCapture(int length)
{
for (int i = 0; i < length; i++) {
LocalWrite("Hello " + i);
}
void LocalWrite(string s) => Console.WriteLine(s);
}
public static void StaticContextSimpleCapture(int length)
{
for (int i = 0; i < length; i++) {
LocalWrite();
}
void LocalWrite() => Console.WriteLine("Hello " + length);
}
public static void StaticContextCaptureInForLoop(int length)
{
for (int i = 0; i < length; i++) {
void LocalWrite() => Console.WriteLine("Hello " + i + "/" + length);
LocalWrite();
}
}
public void ContextNoCapture()
{
for (int i = 0; i < field; i++) {
LocalWrite("Hello " + i);
}
void LocalWrite(string s) => Console.WriteLine(s);
}
public void ContextSimpleCapture()
{
for (int i = 0; i < field; i++) {
LocalWrite();
}
void LocalWrite() => Console.WriteLine("Hello " + field);
}
public void ContextCaptureInForLoop()
{
for (int i = 0; i < field; i++) {
void LocalWrite() => Console.WriteLine("Hello " + i + "/" + field);
LocalWrite();
}
}
}
}

17
ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue1256.cs

@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
using System;
namespace ICSharpCode.Decompiler.Tests.TestCases.ILPretty
{
internal class Issue1256
{
public void Method(Enum e, object o, string s)
{
int num = (int)(object)e;
object obj = new object();
int num2 = (int)obj;
long num3 = (long)o;
int num4 = (int)(object)s;
int num5 = (int)num3;
}
}
}

58
ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue1256.il

@ -0,0 +1,58 @@ @@ -0,0 +1,58 @@
.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.Issue1256
extends [mscorlib]System.Object
{
// Methods
.method public hidebysig
instance void Method (
class [mscorlib]System.Enum e,
object o,
string s
) cil managed
{
// Method begins at RVA 0x2050
// Code size 41 (0x29)
.maxstack 1
.locals init (
[0] int32,
[1] object,
[2] int32,
[3] int64,
[4] int32,
[5] int32
)
IL_0000: nop
IL_0001: ldarg.1
IL_0002: unbox.any [mscorlib]System.Int32
IL_0007: stloc.0
IL_0008: newobj instance void [mscorlib]System.Object::.ctor()
IL_000d: stloc.1
IL_000e: ldloc.1
IL_000f: unbox.any [mscorlib]System.Int32
IL_0014: stloc.2
IL_0015: ldarg.2
IL_0016: unbox.any [mscorlib]System.Int64
IL_001b: stloc.3
IL_001c: ldarg.3
IL_001d: unbox.any [mscorlib]System.Int32
IL_0022: stloc.s 4
IL_0024: ldloc.3
IL_0025: conv.i4
IL_0026: stloc.s 5
IL_0028: ret
} // end of method Issue1256::Method
.method public hidebysig specialname rtspecialname
instance void .ctor () cil managed
{
// Method begins at RVA 0x2085
// 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 Issue1256::.ctor
} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.Issue1256

358
ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.cs

@ -48,6 +48,21 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -48,6 +48,21 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
}
}
internal class GenericClassWithCtor<T>
{
}
internal class GenericClassWithMultipleCtors<T>
{
public GenericClassWithMultipleCtors()
{
}
public GenericClassWithMultipleCtors(int x)
{
}
}
private class AssertTest
{
private struct DataStruct
@ -78,7 +93,218 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -78,7 +93,218 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
}
}
public class Administrator
{
public int ID {
get;
set;
}
public string TrueName {
get;
set;
}
public string Phone {
get;
set;
}
}
public class Contract
{
public int ID {
get;
set;
}
public string ContractNo {
get;
set;
}
public string HouseAddress {
get;
set;
}
public DateTime SigningTime {
get;
set;
}
public string BuyerName {
get;
set;
}
public string BuyerTelephone {
get;
set;
}
public string Customer {
get;
set;
}
public string CustTelephone {
get;
set;
}
public int AdminID {
get;
set;
}
public int StoreID {
get;
set;
}
}
public class Database
{
public IQueryable<Contract> Contracts {
get;
set;
}
public IQueryable<Loan> Loan {
get;
set;
}
public IQueryable<Administrator> Administrator {
get;
set;
}
public IQueryable<Store> Store {
get;
set;
}
}
public class Loan
{
public string ContractNo {
get;
set;
}
public DateTime? ShenDate {
get;
set;
}
public DateTime? LoanDate {
get;
set;
}
public string Credit {
get;
set;
}
public string LoanBank {
get;
set;
}
public string Remarks {
get;
set;
}
}
public class Store
{
public int ID {
get;
set;
}
public string Name {
get;
set;
}
}
internal class MyClass
{
public static MyClass operator +(MyClass a, MyClass b)
{
return new MyClass();
}
}
internal class SimpleType
{
public const int ConstField = 1;
public static readonly int StaticReadonlyField = 2;
public static int StaticField = 3;
public readonly int ReadonlyField = 2;
public int Field = 3;
#if CS60
public static int StaticReadonlyProperty => 0;
#else
public static int StaticReadonlyProperty {
get {
return 0;
}
}
#endif
public static int StaticProperty {
get;
set;
}
#if CS60
public int ReadonlyProperty => 0;
#else
public int ReadonlyProperty {
get {
return 0;
}
}
#endif
public int Property {
get;
set;
}
}
internal class SimpleTypeWithCtor
{
public SimpleTypeWithCtor(int i)
{
}
}
internal class SimpleTypeWithMultipleCtors
{
public SimpleTypeWithMultipleCtors()
{
}
public SimpleTypeWithMultipleCtors(int i)
{
}
}
private int field;
private Database db;
private dynamic ViewBag;
public static readonly object[] SupportedMethods = new object[2] {
ToCode(null, () => ((IQueryable<object>)null).Aggregate((object o1, object o2) => null)),
@ -92,6 +318,53 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -92,6 +318,53 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
ToCode(null, () => ((IEnumerable<object>)null).Aggregate((object)null, (Func<object, object, object>)((object o1, object o2) => null), (Func<object, object>)((object o) => null)))
};
private void Issue1249(int ID)
{
if (ID == 0) {
ViewBag.data = "''";
} else {
var model = (from a in db.Contracts
where a.ID == ID
select new {
ID = a.ID,
ContractNo = a.ContractNo,
HouseAddress = a.HouseAddress,
AdminID = (from b in db.Administrator
where b.ID == a.AdminID
select b.TrueName).FirstOrDefault(),
StoreID = (from b in db.Store
where b.ID == a.StoreID
select b.Name).FirstOrDefault(),
SigningTime = a.SigningTime,
YeWuPhone = (from b in db.Administrator
where b.ID == a.AdminID
select b.Phone).FirstOrDefault(),
BuyerName = a.BuyerName,
BuyerTelephone = a.BuyerTelephone,
Customer = a.Customer,
CustTelephone = a.CustTelephone,
Credit = (from b in db.Loan
where b.ContractNo == a.ContractNo
select b.Credit).FirstOrDefault(),
LoanBank = (from b in db.Loan
where b.ContractNo == a.ContractNo
select b.LoanBank).FirstOrDefault(),
Remarks = (from b in db.Loan
where b.ContractNo == a.ContractNo
select b.Remarks).FirstOrDefault()
}).FirstOrDefault();
ViewBag.data = model.ToJson();
DateTime? dateTime = (from b in db.Loan
where b.ContractNo == model.ContractNo
select b.ShenDate).FirstOrDefault();
DateTime? dateTime2 = (from b in db.Loan
where b.ContractNo == model.ContractNo
select b.LoanDate).FirstOrDefault();
ViewBag.ShenDate = ((!dateTime.HasValue) ? "" : dateTime.ParseDateTime().ToString("yyyy-MM-dd"));
ViewBag.LoanDate = ((!dateTime2.HasValue) ? "" : dateTime2.ParseDateTime().ToString("yyyy-MM-dd"));
}
}
private static object ToCode<R>(object x, Expression<Action<R>> expr)
{
return expr;
@ -721,91 +994,16 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -721,91 +994,16 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
}
}
internal class MyClass
internal static class Extensions
{
public static MyClass operator +(MyClass a, MyClass b)
{
return new MyClass();
}
}
internal class SimpleType
{
public const int ConstField = 1;
public static readonly int StaticReadonlyField = 2;
public static int StaticField = 3;
public readonly int ReadonlyField = 2;
public int Field = 3;
#if CS60
public static int StaticReadonlyProperty => 0;
#else
public static int StaticReadonlyProperty {
get {
return 0;
}
}
#endif
public static int StaticProperty {
get;
set;
}
#if CS60
public int ReadonlyProperty => 0;
#else
public int ReadonlyProperty {
get {
return 0;
}
}
#endif
public int Property {
get;
set;
}
}
internal class SimpleTypeWithCtor
{
public SimpleTypeWithCtor(int i)
{
}
}
internal class SimpleTypeWithMultipleCtors
{
public SimpleTypeWithMultipleCtors()
{
}
public SimpleTypeWithMultipleCtors(int i)
{
}
}
internal class GenericClassWithCtor<T>
{
}
internal class GenericClassWithMultipleCtors<T>
{
public GenericClassWithMultipleCtors()
public static dynamic ToJson(this object o)
{
return null;
}
public GenericClassWithMultipleCtors(int x)
public static DateTime ParseDateTime(this object str)
{
return default(DateTime);
}
}
internal class GenericClass<T>
{
}
}

5553
ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.il

File diff suppressed because it is too large Load Diff

5043
ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.opt.il

File diff suppressed because it is too large Load Diff

5204
ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.opt.roslyn.il

File diff suppressed because it is too large Load Diff

5339
ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.roslyn.il

File diff suppressed because it is too large Load Diff

151
ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs

@ -62,6 +62,22 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests @@ -62,6 +62,22 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests
public int Z;
public S Y;
public List<S> L;
public S this[int index] {
get {
return default(S);
}
set {
}
}
public S this[object key] {
get {
return default(S);
}
set {
}
}
}
public struct S
@ -154,6 +170,77 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests @@ -154,6 +170,77 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests
}
}
public class Item
{
public string Text {
get;
set;
}
public decimal Value {
get;
set;
}
public decimal Value2 {
get;
set;
}
public string Value3 {
get;
set;
}
public string Value4 {
get;
set;
}
public string Value5 {
get;
set;
}
public string Value6 {
get;
set;
}
}
public class OtherItem
{
public decimal Value {
get;
set;
}
public decimal Value2 {
get;
set;
}
public decimal? Nullable {
get;
set;
}
public decimal? Nullable2 {
get;
set;
}
public decimal? Nullable3 {
get;
set;
}
public decimal? Nullable4 {
get;
set;
}
}
// Helper methods used to ensure initializers used within expressions work correctly
private static void X(object a, object b)
{
@ -471,7 +558,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests @@ -471,7 +558,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests
});
}
public void NestedListWithIndexInitializer()
private void NestedListWithIndexInitializer(MyEnum myEnum)
{
#if !OPT
List<List<int>> list = new List<List<int>> {
@ -482,6 +569,9 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests @@ -482,6 +569,9 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests
1,
2,
3
},
[1] = {
(int)myEnum
}
};
}
@ -612,5 +702,64 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests @@ -612,5 +702,64 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests
}
});
}
private void Issue1250_Test1(MyEnum value)
{
X(Y(), new C {
Z = (int)value
});
}
#if CS60
private void Issue1250_Test2(MyEnum value)
{
X(Y(), new C {
[(int)value] = new S((int)value)
});
}
private void Issue1250_Test3(int value)
{
X(Y(), new C {
[value] = new S(value)
});
}
private void Issue1250_Test4(int value)
{
X(Y(), new C {
[(object)value] = new S(value)
});
}
#endif
private void Issue1251_Test(List<Item> list, OtherItem otherItem)
{
list.Add(new Item {
Text = "Text",
Value = otherItem.Value,
Value2 = otherItem.Value2,
Value3 = otherItem.Nullable.ToString(),
Value4 = otherItem.Nullable2.ToString(),
Value5 = otherItem.Nullable3.ToString(),
Value6 = otherItem.Nullable4.ToString()
});
}
private Data Issue1279(int p)
{
if (p == 1) {
Data data = new Data();
data.a = MyEnum.a;
data.TestEvent += Data_TestEvent;
return data;
}
return null;
}
private void Data_TestEvent(object sender, EventArgs e)
{
throw new NotImplementedException();
}
}
}

724
ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.il

@ -15,8 +15,8 @@ @@ -15,8 +15,8 @@
}
.assembly InitializerTests
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
.permissionset reqmin
@ -125,9 +125,68 @@ @@ -125,9 +125,68 @@
.class auto ansi nested public beforefieldinit C
extends [mscorlib]System.Object
{
.custom instance void [mscorlib]System.Reflection.DefaultMemberAttribute::.ctor(string) = ( 01 00 04 49 74 65 6D 00 00 ) // ...Item..
.field public int32 Z
.field public valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S Y
.field public class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S> L
.method public hidebysig specialname
instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S
get_Item(int32 index) cil managed
{
// Code size 15 (0xf)
.maxstack 1
.locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S V_0,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S V_1)
IL_0000: nop
IL_0001: ldloca.s V_1
IL_0003: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S
IL_0009: ldloc.1
IL_000a: stloc.0
IL_000b: br.s IL_000d
IL_000d: ldloc.0
IL_000e: ret
} // end of method C::get_Item
.method public hidebysig specialname
instance void set_Item(int32 index,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S 'value') cil managed
{
// Code size 2 (0x2)
.maxstack 8
IL_0000: nop
IL_0001: ret
} // end of method C::set_Item
.method public hidebysig specialname
instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S
get_Item(object key) cil managed
{
// Code size 15 (0xf)
.maxstack 1
.locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S V_0,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S V_1)
IL_0000: nop
IL_0001: ldloca.s V_1
IL_0003: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S
IL_0009: ldloc.1
IL_000a: stloc.0
IL_000b: br.s IL_000d
IL_000d: ldloc.0
IL_000e: ret
} // end of method C::get_Item
.method public hidebysig specialname
instance void set_Item(object key,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S 'value') cil managed
{
// Code size 2 (0x2)
.maxstack 8
IL_0000: nop
IL_0001: ret
} // end of method C::set_Item
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
@ -138,6 +197,20 @@ @@ -138,6 +197,20 @@
IL_0006: ret
} // end of method C::.ctor
.property instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S
Item(int32)
{
.get instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::get_Item(int32)
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::set_Item(int32,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S)
} // end of property C::Item
.property instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S
Item(object)
{
.get instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::get_Item(object)
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::set_Item(object,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S)
} // end of property C::Item
} // end of class C
.class sequential ansi sealed nested public beforefieldinit S
@ -495,8 +568,8 @@ @@ -495,8 +568,8 @@
.property instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum
a()
{
.get instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::get_a()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum)
.get instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::get_a()
} // end of property Data::a
.property instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum
b()
@ -507,8 +580,8 @@ @@ -507,8 +580,8 @@
.property instance class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum2>
PropertyList()
{
.get instance class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum2> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::get_PropertyList()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::set_PropertyList(class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum2>)
.get instance class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum2> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::get_PropertyList()
} // end of property Data::PropertyList
.property instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data
MoreData()
@ -637,6 +710,507 @@ @@ -637,6 +710,507 @@
} // end of property StructData::MoreData
} // end of class StructData
.class auto ansi nested public beforefieldinit Item
extends [mscorlib]System.Object
{
.field private string '<Text>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private valuetype [mscorlib]System.Decimal '<Value>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private valuetype [mscorlib]System.Decimal '<Value2>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private string '<Value3>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private string '<Value4>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private string '<Value5>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private string '<Value6>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.method public hidebysig specialname
instance string get_Text() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 11 (0xb)
.maxstack 1
.locals init (string V_0)
IL_0000: ldarg.0
IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Text>k__BackingField'
IL_0006: stloc.0
IL_0007: br.s IL_0009
IL_0009: ldloc.0
IL_000a: ret
} // end of method Item::get_Text
.method public hidebysig specialname
instance void set_Text(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Text>k__BackingField'
IL_0007: ret
} // end of method Item::set_Text
.method public hidebysig specialname
instance valuetype [mscorlib]System.Decimal
get_Value() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 11 (0xb)
.maxstack 1
.locals init (valuetype [mscorlib]System.Decimal V_0)
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value>k__BackingField'
IL_0006: stloc.0
IL_0007: br.s IL_0009
IL_0009: ldloc.0
IL_000a: ret
} // end of method Item::get_Value
.method public hidebysig specialname
instance void set_Value(valuetype [mscorlib]System.Decimal 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value>k__BackingField'
IL_0007: ret
} // end of method Item::set_Value
.method public hidebysig specialname
instance valuetype [mscorlib]System.Decimal
get_Value2() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 11 (0xb)
.maxstack 1
.locals init (valuetype [mscorlib]System.Decimal V_0)
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value2>k__BackingField'
IL_0006: stloc.0
IL_0007: br.s IL_0009
IL_0009: ldloc.0
IL_000a: ret
} // end of method Item::get_Value2
.method public hidebysig specialname
instance void set_Value2(valuetype [mscorlib]System.Decimal 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value2>k__BackingField'
IL_0007: ret
} // end of method Item::set_Value2
.method public hidebysig specialname
instance string get_Value3() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 11 (0xb)
.maxstack 1
.locals init (string V_0)
IL_0000: ldarg.0
IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value3>k__BackingField'
IL_0006: stloc.0
IL_0007: br.s IL_0009
IL_0009: ldloc.0
IL_000a: ret
} // end of method Item::get_Value3
.method public hidebysig specialname
instance void set_Value3(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value3>k__BackingField'
IL_0007: ret
} // end of method Item::set_Value3
.method public hidebysig specialname
instance string get_Value4() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 11 (0xb)
.maxstack 1
.locals init (string V_0)
IL_0000: ldarg.0
IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value4>k__BackingField'
IL_0006: stloc.0
IL_0007: br.s IL_0009
IL_0009: ldloc.0
IL_000a: ret
} // end of method Item::get_Value4
.method public hidebysig specialname
instance void set_Value4(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value4>k__BackingField'
IL_0007: ret
} // end of method Item::set_Value4
.method public hidebysig specialname
instance string get_Value5() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 11 (0xb)
.maxstack 1
.locals init (string V_0)
IL_0000: ldarg.0
IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value5>k__BackingField'
IL_0006: stloc.0
IL_0007: br.s IL_0009
IL_0009: ldloc.0
IL_000a: ret
} // end of method Item::get_Value5
.method public hidebysig specialname
instance void set_Value5(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value5>k__BackingField'
IL_0007: ret
} // end of method Item::set_Value5
.method public hidebysig specialname
instance string get_Value6() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 11 (0xb)
.maxstack 1
.locals init (string V_0)
IL_0000: ldarg.0
IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value6>k__BackingField'
IL_0006: stloc.0
IL_0007: br.s IL_0009
IL_0009: ldloc.0
IL_000a: ret
} // end of method Item::get_Value6
.method public hidebysig specialname
instance void set_Value6(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value6>k__BackingField'
IL_0007: ret
} // end of method Item::set_Value6
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// 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 Item::.ctor
.property instance string Text()
{
.get instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Text()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Text(string)
} // end of property Item::Text
.property instance valuetype [mscorlib]System.Decimal
Value()
{
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value(valuetype [mscorlib]System.Decimal)
.get instance valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Value()
} // end of property Item::Value
.property instance valuetype [mscorlib]System.Decimal
Value2()
{
.get instance valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Value2()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value2(valuetype [mscorlib]System.Decimal)
} // end of property Item::Value2
.property instance string Value3()
{
.get instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Value3()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value3(string)
} // end of property Item::Value3
.property instance string Value4()
{
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value4(string)
.get instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Value4()
} // end of property Item::Value4
.property instance string Value5()
{
.get instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Value5()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value5(string)
} // end of property Item::Value5
.property instance string Value6()
{
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value6(string)
.get instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Value6()
} // end of property Item::Value6
} // end of class Item
.class auto ansi nested public beforefieldinit OtherItem
extends [mscorlib]System.Object
{
.field private valuetype [mscorlib]System.Decimal '<Value>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private valuetype [mscorlib]System.Decimal '<Value2>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> '<Nullable>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> '<Nullable2>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> '<Nullable3>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> '<Nullable4>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.method public hidebysig specialname
instance valuetype [mscorlib]System.Decimal
get_Value() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 11 (0xb)
.maxstack 1
.locals init (valuetype [mscorlib]System.Decimal V_0)
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Value>k__BackingField'
IL_0006: stloc.0
IL_0007: br.s IL_0009
IL_0009: ldloc.0
IL_000a: ret
} // end of method OtherItem::get_Value
.method public hidebysig specialname
instance void set_Value(valuetype [mscorlib]System.Decimal 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Value>k__BackingField'
IL_0007: ret
} // end of method OtherItem::set_Value
.method public hidebysig specialname
instance valuetype [mscorlib]System.Decimal
get_Value2() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 11 (0xb)
.maxstack 1
.locals init (valuetype [mscorlib]System.Decimal V_0)
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Value2>k__BackingField'
IL_0006: stloc.0
IL_0007: br.s IL_0009
IL_0009: ldloc.0
IL_000a: ret
} // end of method OtherItem::get_Value2
.method public hidebysig specialname
instance void set_Value2(valuetype [mscorlib]System.Decimal 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Value2>k__BackingField'
IL_0007: ret
} // end of method OtherItem::set_Value2
.method public hidebysig specialname
instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
get_Nullable() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 11 (0xb)
.maxstack 1
.locals init (valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> V_0)
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable>k__BackingField'
IL_0006: stloc.0
IL_0007: br.s IL_0009
IL_0009: ldloc.0
IL_000a: ret
} // end of method OtherItem::get_Nullable
.method public hidebysig specialname
instance void set_Nullable(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable>k__BackingField'
IL_0007: ret
} // end of method OtherItem::set_Nullable
.method public hidebysig specialname
instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
get_Nullable2() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 11 (0xb)
.maxstack 1
.locals init (valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> V_0)
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable2>k__BackingField'
IL_0006: stloc.0
IL_0007: br.s IL_0009
IL_0009: ldloc.0
IL_000a: ret
} // end of method OtherItem::get_Nullable2
.method public hidebysig specialname
instance void set_Nullable2(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable2>k__BackingField'
IL_0007: ret
} // end of method OtherItem::set_Nullable2
.method public hidebysig specialname
instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
get_Nullable3() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 11 (0xb)
.maxstack 1
.locals init (valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> V_0)
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable3>k__BackingField'
IL_0006: stloc.0
IL_0007: br.s IL_0009
IL_0009: ldloc.0
IL_000a: ret
} // end of method OtherItem::get_Nullable3
.method public hidebysig specialname
instance void set_Nullable3(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable3>k__BackingField'
IL_0007: ret
} // end of method OtherItem::set_Nullable3
.method public hidebysig specialname
instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
get_Nullable4() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 11 (0xb)
.maxstack 1
.locals init (valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> V_0)
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable4>k__BackingField'
IL_0006: stloc.0
IL_0007: br.s IL_0009
IL_0009: ldloc.0
IL_000a: ret
} // end of method OtherItem::get_Nullable4
.method public hidebysig specialname
instance void set_Nullable4(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable4>k__BackingField'
IL_0007: ret
} // end of method OtherItem::set_Nullable4
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// 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 OtherItem::.ctor
.property instance valuetype [mscorlib]System.Decimal
Value()
{
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::set_Value(valuetype [mscorlib]System.Decimal)
.get instance valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Value()
} // end of property OtherItem::Value
.property instance valuetype [mscorlib]System.Decimal
Value2()
{
.get instance valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Value2()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::set_Value2(valuetype [mscorlib]System.Decimal)
} // end of property OtherItem::Value2
.property instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
Nullable()
{
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::set_Nullable(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>)
.get instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable()
} // end of property OtherItem::Nullable
.property instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
Nullable2()
{
.get instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable2()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::set_Nullable2(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>)
} // end of property OtherItem::Nullable2
.property instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
Nullable3()
{
.get instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable3()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::set_Nullable3(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>)
} // end of property OtherItem::Nullable3
.property instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
Nullable4()
{
.get instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable4()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::set_Nullable4(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>)
} // end of property OtherItem::Nullable4
} // end of class OtherItem
.field private static class [mscorlib]System.EventHandler 'CS$<>9__CachedAnonymousMethodDelegate9'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private static class [mscorlib]System.Func`2<class [mscorlib]System.Globalization.NumberFormatInfo,bool> 'CS$<>9__CachedAnonymousMethodDelegate1d'
@ -1789,6 +2363,150 @@ @@ -1789,6 +2363,150 @@
IL_0020: ret
} // end of method TestCases::Issue907_Test3
.method private hidebysig instance void
Issue1250_Test1(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum 'value') cil managed
{
// Code size 27 (0x1b)
.maxstack 3
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C V_0)
IL_0000: nop
IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Y()
IL_0006: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::.ctor()
IL_000b: stloc.0
IL_000c: ldloc.0
IL_000d: ldarg.1
IL_000e: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::Z
IL_0013: ldloc.0
IL_0014: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object,
object)
IL_0019: nop
IL_001a: ret
} // end of method TestCases::Issue1250_Test1
.method private hidebysig instance void
Issue1251_Test(class [mscorlib]System.Collections.Generic.List`1<class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item> list,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem otherItem) cil managed
{
// Code size 162 (0xa2)
.maxstack 3
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item V_0,
valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> V_1)
IL_0000: nop
IL_0001: ldarg.1
IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::.ctor()
IL_0007: stloc.0
IL_0008: ldloc.0
IL_0009: ldstr "Text"
IL_000e: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Text(string)
IL_0013: nop
IL_0014: ldloc.0
IL_0015: ldarg.2
IL_0016: callvirt instance valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Value()
IL_001b: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value(valuetype [mscorlib]System.Decimal)
IL_0020: nop
IL_0021: ldloc.0
IL_0022: ldarg.2
IL_0023: callvirt instance valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Value2()
IL_0028: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value2(valuetype [mscorlib]System.Decimal)
IL_002d: nop
IL_002e: ldloc.0
IL_002f: ldarg.2
IL_0030: callvirt instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable()
IL_0035: stloc.1
IL_0036: ldloca.s V_1
IL_0038: constrained. valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
IL_003e: callvirt instance string [mscorlib]System.Object::ToString()
IL_0043: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value3(string)
IL_0048: nop
IL_0049: ldloc.0
IL_004a: ldarg.2
IL_004b: callvirt instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable2()
IL_0050: stloc.1
IL_0051: ldloca.s V_1
IL_0053: constrained. valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
IL_0059: callvirt instance string [mscorlib]System.Object::ToString()
IL_005e: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value4(string)
IL_0063: nop
IL_0064: ldloc.0
IL_0065: ldarg.2
IL_0066: callvirt instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable3()
IL_006b: stloc.1
IL_006c: ldloca.s V_1
IL_006e: constrained. valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
IL_0074: callvirt instance string [mscorlib]System.Object::ToString()
IL_0079: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value5(string)
IL_007e: nop
IL_007f: ldloc.0
IL_0080: ldarg.2
IL_0081: callvirt instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable4()
IL_0086: stloc.1
IL_0087: ldloca.s V_1
IL_0089: constrained. valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
IL_008f: callvirt instance string [mscorlib]System.Object::ToString()
IL_0094: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value6(string)
IL_0099: nop
IL_009a: ldloc.0
IL_009b: callvirt instance void class [mscorlib]System.Collections.Generic.List`1<class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item>::Add(!0)
IL_00a0: nop
IL_00a1: ret
} // end of method TestCases::Issue1251_Test
.method private hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data
Issue1279(int32 p) cil managed
{
// Code size 56 (0x38)
.maxstack 3
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data V_0,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data V_1,
bool V_2)
IL_0000: nop
IL_0001: ldarg.1
IL_0002: ldc.i4.1
IL_0003: ceq
IL_0005: ldc.i4.0
IL_0006: ceq
IL_0008: stloc.2
IL_0009: ldloc.2
IL_000a: brtrue.s IL_0032
IL_000c: nop
IL_000d: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::.ctor()
IL_0012: stloc.0
IL_0013: ldloc.0
IL_0014: ldc.i4.0
IL_0015: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum)
IL_001a: nop
IL_001b: ldloc.0
IL_001c: ldarg.0
IL_001d: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Data_TestEvent(object,
class [mscorlib]System.EventArgs)
IL_0023: newobj instance void [mscorlib]System.EventHandler::.ctor(object,
native int)
IL_0028: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::add_TestEvent(class [mscorlib]System.EventHandler)
IL_002d: nop
IL_002e: ldloc.0
IL_002f: stloc.1
IL_0030: br.s IL_0036
IL_0032: ldnull
IL_0033: stloc.1
IL_0034: br.s IL_0036
IL_0036: ldloc.1
IL_0037: ret
} // end of method TestCases::Issue1279
.method private hidebysig instance void
Data_TestEvent(object sender,
class [mscorlib]System.EventArgs e) cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: nop
IL_0001: newobj instance void [mscorlib]System.NotImplementedException::.ctor()
IL_0006: throw
} // end of method TestCases::Data_TestEvent
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{

620
ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.il

@ -15,8 +15,8 @@ @@ -15,8 +15,8 @@
}
.assembly InitializerTests.opt
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
.permissionset reqmin
@ -119,9 +119,54 @@ @@ -119,9 +119,54 @@
.class auto ansi nested public beforefieldinit C
extends [mscorlib]System.Object
{
.custom instance void [mscorlib]System.Reflection.DefaultMemberAttribute::.ctor(string) = ( 01 00 04 49 74 65 6D 00 00 ) // ...Item..
.field public int32 Z
.field public valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S Y
.field public class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S> L
.method public hidebysig specialname
instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S
get_Item(int32 index) cil managed
{
// Code size 10 (0xa)
.maxstack 1
.locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S V_0)
IL_0000: ldloca.s V_0
IL_0002: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S
IL_0008: ldloc.0
IL_0009: ret
} // end of method C::get_Item
.method public hidebysig specialname
instance void set_Item(int32 index,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S 'value') cil managed
{
// Code size 1 (0x1)
.maxstack 8
IL_0000: ret
} // end of method C::set_Item
.method public hidebysig specialname
instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S
get_Item(object key) cil managed
{
// Code size 10 (0xa)
.maxstack 1
.locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S V_0)
IL_0000: ldloca.s V_0
IL_0002: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S
IL_0008: ldloc.0
IL_0009: ret
} // end of method C::get_Item
.method public hidebysig specialname
instance void set_Item(object key,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S 'value') cil managed
{
// Code size 1 (0x1)
.maxstack 8
IL_0000: ret
} // end of method C::set_Item
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
@ -132,6 +177,20 @@ @@ -132,6 +177,20 @@
IL_0006: ret
} // end of method C::.ctor
.property instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S
Item(int32)
{
.get instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::get_Item(int32)
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::set_Item(int32,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S)
} // end of property C::Item
.property instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S
Item(object)
{
.get instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::get_Item(object)
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::set_Item(object,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S)
} // end of property C::Item
} // end of class C
.class sequential ansi sealed nested public beforefieldinit S
@ -436,8 +495,8 @@ @@ -436,8 +495,8 @@
.property instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum
a()
{
.get instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::get_a()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum)
.get instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::get_a()
} // end of property Data::a
.property instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum
b()
@ -448,8 +507,8 @@ @@ -448,8 +507,8 @@
.property instance class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum2>
PropertyList()
{
.get instance class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum2> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::get_PropertyList()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::set_PropertyList(class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum2>)
.get instance class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum2> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::get_PropertyList()
} // end of property Data::PropertyList
.property instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data
MoreData()
@ -566,6 +625,442 @@ @@ -566,6 +625,442 @@
} // end of property StructData::MoreData
} // end of class StructData
.class auto ansi nested public beforefieldinit Item
extends [mscorlib]System.Object
{
.field private string '<Text>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private valuetype [mscorlib]System.Decimal '<Value>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private valuetype [mscorlib]System.Decimal '<Value2>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private string '<Value3>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private string '<Value4>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private string '<Value5>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private string '<Value6>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.method public hidebysig specialname
instance string get_Text() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Text>k__BackingField'
IL_0006: ret
} // end of method Item::get_Text
.method public hidebysig specialname
instance void set_Text(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Text>k__BackingField'
IL_0007: ret
} // end of method Item::set_Text
.method public hidebysig specialname
instance valuetype [mscorlib]System.Decimal
get_Value() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value>k__BackingField'
IL_0006: ret
} // end of method Item::get_Value
.method public hidebysig specialname
instance void set_Value(valuetype [mscorlib]System.Decimal 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value>k__BackingField'
IL_0007: ret
} // end of method Item::set_Value
.method public hidebysig specialname
instance valuetype [mscorlib]System.Decimal
get_Value2() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value2>k__BackingField'
IL_0006: ret
} // end of method Item::get_Value2
.method public hidebysig specialname
instance void set_Value2(valuetype [mscorlib]System.Decimal 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value2>k__BackingField'
IL_0007: ret
} // end of method Item::set_Value2
.method public hidebysig specialname
instance string get_Value3() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value3>k__BackingField'
IL_0006: ret
} // end of method Item::get_Value3
.method public hidebysig specialname
instance void set_Value3(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value3>k__BackingField'
IL_0007: ret
} // end of method Item::set_Value3
.method public hidebysig specialname
instance string get_Value4() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value4>k__BackingField'
IL_0006: ret
} // end of method Item::get_Value4
.method public hidebysig specialname
instance void set_Value4(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value4>k__BackingField'
IL_0007: ret
} // end of method Item::set_Value4
.method public hidebysig specialname
instance string get_Value5() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value5>k__BackingField'
IL_0006: ret
} // end of method Item::get_Value5
.method public hidebysig specialname
instance void set_Value5(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value5>k__BackingField'
IL_0007: ret
} // end of method Item::set_Value5
.method public hidebysig specialname
instance string get_Value6() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value6>k__BackingField'
IL_0006: ret
} // end of method Item::get_Value6
.method public hidebysig specialname
instance void set_Value6(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value6>k__BackingField'
IL_0007: ret
} // end of method Item::set_Value6
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// 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 Item::.ctor
.property instance string Text()
{
.get instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Text()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Text(string)
} // end of property Item::Text
.property instance valuetype [mscorlib]System.Decimal
Value()
{
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value(valuetype [mscorlib]System.Decimal)
.get instance valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Value()
} // end of property Item::Value
.property instance valuetype [mscorlib]System.Decimal
Value2()
{
.get instance valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Value2()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value2(valuetype [mscorlib]System.Decimal)
} // end of property Item::Value2
.property instance string Value3()
{
.get instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Value3()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value3(string)
} // end of property Item::Value3
.property instance string Value4()
{
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value4(string)
.get instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Value4()
} // end of property Item::Value4
.property instance string Value5()
{
.get instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Value5()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value5(string)
} // end of property Item::Value5
.property instance string Value6()
{
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value6(string)
.get instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Value6()
} // end of property Item::Value6
} // end of class Item
.class auto ansi nested public beforefieldinit OtherItem
extends [mscorlib]System.Object
{
.field private valuetype [mscorlib]System.Decimal '<Value>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private valuetype [mscorlib]System.Decimal '<Value2>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> '<Nullable>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> '<Nullable2>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> '<Nullable3>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> '<Nullable4>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.method public hidebysig specialname
instance valuetype [mscorlib]System.Decimal
get_Value() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Value>k__BackingField'
IL_0006: ret
} // end of method OtherItem::get_Value
.method public hidebysig specialname
instance void set_Value(valuetype [mscorlib]System.Decimal 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Value>k__BackingField'
IL_0007: ret
} // end of method OtherItem::set_Value
.method public hidebysig specialname
instance valuetype [mscorlib]System.Decimal
get_Value2() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Value2>k__BackingField'
IL_0006: ret
} // end of method OtherItem::get_Value2
.method public hidebysig specialname
instance void set_Value2(valuetype [mscorlib]System.Decimal 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Value2>k__BackingField'
IL_0007: ret
} // end of method OtherItem::set_Value2
.method public hidebysig specialname
instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
get_Nullable() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable>k__BackingField'
IL_0006: ret
} // end of method OtherItem::get_Nullable
.method public hidebysig specialname
instance void set_Nullable(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable>k__BackingField'
IL_0007: ret
} // end of method OtherItem::set_Nullable
.method public hidebysig specialname
instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
get_Nullable2() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable2>k__BackingField'
IL_0006: ret
} // end of method OtherItem::get_Nullable2
.method public hidebysig specialname
instance void set_Nullable2(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable2>k__BackingField'
IL_0007: ret
} // end of method OtherItem::set_Nullable2
.method public hidebysig specialname
instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
get_Nullable3() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable3>k__BackingField'
IL_0006: ret
} // end of method OtherItem::get_Nullable3
.method public hidebysig specialname
instance void set_Nullable3(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable3>k__BackingField'
IL_0007: ret
} // end of method OtherItem::set_Nullable3
.method public hidebysig specialname
instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
get_Nullable4() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable4>k__BackingField'
IL_0006: ret
} // end of method OtherItem::get_Nullable4
.method public hidebysig specialname
instance void set_Nullable4(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable4>k__BackingField'
IL_0007: ret
} // end of method OtherItem::set_Nullable4
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// 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 OtherItem::.ctor
.property instance valuetype [mscorlib]System.Decimal
Value()
{
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::set_Value(valuetype [mscorlib]System.Decimal)
.get instance valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Value()
} // end of property OtherItem::Value
.property instance valuetype [mscorlib]System.Decimal
Value2()
{
.get instance valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Value2()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::set_Value2(valuetype [mscorlib]System.Decimal)
} // end of property OtherItem::Value2
.property instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
Nullable()
{
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::set_Nullable(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>)
.get instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable()
} // end of property OtherItem::Nullable
.property instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
Nullable2()
{
.get instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable2()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::set_Nullable2(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>)
} // end of property OtherItem::Nullable2
.property instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
Nullable3()
{
.get instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable3()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::set_Nullable3(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>)
} // end of property OtherItem::Nullable3
.property instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
Nullable4()
{
.get instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable4()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::set_Nullable4(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>)
} // end of property OtherItem::Nullable4
} // end of class OtherItem
.field private static class [mscorlib]System.EventHandler 'CS$<>9__CachedAnonymousMethodDelegate9'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private static class [mscorlib]System.Func`2<class [mscorlib]System.Globalization.NumberFormatInfo,bool> 'CS$<>9__CachedAnonymousMethodDelegate1d'
@ -1527,6 +2022,125 @@ @@ -1527,6 +2022,125 @@
IL_001d: ret
} // end of method TestCases::Issue907_Test3
.method private hidebysig instance void
Issue1250_Test1(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum 'value') cil managed
{
// Code size 25 (0x19)
.maxstack 3
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C V_0)
IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Y()
IL_0005: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::.ctor()
IL_000a: stloc.0
IL_000b: ldloc.0
IL_000c: ldarg.1
IL_000d: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::Z
IL_0012: ldloc.0
IL_0013: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object,
object)
IL_0018: ret
} // end of method TestCases::Issue1250_Test1
.method private hidebysig instance void
Issue1251_Test(class [mscorlib]System.Collections.Generic.List`1<class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item> list,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem otherItem) cil managed
{
// Code size 154 (0x9a)
.maxstack 3
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item V_0,
valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> V_1,
valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> V_2,
valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> V_3,
valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> V_4)
IL_0000: ldarg.1
IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::.ctor()
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: ldstr "Text"
IL_000d: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Text(string)
IL_0012: ldloc.0
IL_0013: ldarg.2
IL_0014: callvirt instance valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Value()
IL_0019: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value(valuetype [mscorlib]System.Decimal)
IL_001e: ldloc.0
IL_001f: ldarg.2
IL_0020: callvirt instance valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Value2()
IL_0025: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value2(valuetype [mscorlib]System.Decimal)
IL_002a: ldloc.0
IL_002b: ldarg.2
IL_002c: callvirt instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable()
IL_0031: stloc.1
IL_0032: ldloca.s V_1
IL_0034: constrained. valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
IL_003a: callvirt instance string [mscorlib]System.Object::ToString()
IL_003f: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value3(string)
IL_0044: ldloc.0
IL_0045: ldarg.2
IL_0046: callvirt instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable2()
IL_004b: stloc.2
IL_004c: ldloca.s V_2
IL_004e: constrained. valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
IL_0054: callvirt instance string [mscorlib]System.Object::ToString()
IL_0059: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value4(string)
IL_005e: ldloc.0
IL_005f: ldarg.2
IL_0060: callvirt instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable3()
IL_0065: stloc.3
IL_0066: ldloca.s V_3
IL_0068: constrained. valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
IL_006e: callvirt instance string [mscorlib]System.Object::ToString()
IL_0073: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value5(string)
IL_0078: ldloc.0
IL_0079: ldarg.2
IL_007a: callvirt instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable4()
IL_007f: stloc.s V_4
IL_0081: ldloca.s V_4
IL_0083: constrained. valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
IL_0089: callvirt instance string [mscorlib]System.Object::ToString()
IL_008e: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value6(string)
IL_0093: ldloc.0
IL_0094: callvirt instance void class [mscorlib]System.Collections.Generic.List`1<class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item>::Add(!0)
IL_0099: ret
} // end of method TestCases::Issue1251_Test
.method private hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data
Issue1279(int32 p) cil managed
{
// Code size 39 (0x27)
.maxstack 3
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data V_0)
IL_0000: ldarg.1
IL_0001: ldc.i4.1
IL_0002: bne.un.s IL_0025
IL_0004: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::.ctor()
IL_0009: stloc.0
IL_000a: ldloc.0
IL_000b: ldc.i4.0
IL_000c: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum)
IL_0011: ldloc.0
IL_0012: ldarg.0
IL_0013: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Data_TestEvent(object,
class [mscorlib]System.EventArgs)
IL_0019: newobj instance void [mscorlib]System.EventHandler::.ctor(object,
native int)
IL_001e: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::add_TestEvent(class [mscorlib]System.EventHandler)
IL_0023: ldloc.0
IL_0024: ret
IL_0025: ldnull
IL_0026: ret
} // end of method TestCases::Issue1279
.method private hidebysig instance void
Data_TestEvent(object sender,
class [mscorlib]System.EventArgs e) cil managed
{
// Code size 6 (0x6)
.maxstack 8
IL_0000: newobj instance void [mscorlib]System.NotImplementedException::.ctor()
IL_0005: throw
} // end of method TestCases::Data_TestEvent
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{

709
ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.roslyn.il

@ -123,9 +123,54 @@ @@ -123,9 +123,54 @@
.class auto ansi nested public beforefieldinit C
extends [mscorlib]System.Object
{
.custom instance void [mscorlib]System.Reflection.DefaultMemberAttribute::.ctor(string) = ( 01 00 04 49 74 65 6D 00 00 ) // ...Item..
.field public int32 Z
.field public valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S Y
.field public class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S> L
.method public hidebysig specialname
instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S
get_Item(int32 index) cil managed
{
// Code size 10 (0xa)
.maxstack 1
.locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S V_0)
IL_0000: ldloca.s V_0
IL_0002: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S
IL_0008: ldloc.0
IL_0009: ret
} // end of method C::get_Item
.method public hidebysig specialname
instance void set_Item(int32 index,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S 'value') cil managed
{
// Code size 1 (0x1)
.maxstack 8
IL_0000: ret
} // end of method C::set_Item
.method public hidebysig specialname
instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S
get_Item(object key) cil managed
{
// Code size 10 (0xa)
.maxstack 1
.locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S V_0)
IL_0000: ldloca.s V_0
IL_0002: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S
IL_0008: ldloc.0
IL_0009: ret
} // end of method C::get_Item
.method public hidebysig specialname
instance void set_Item(object key,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S 'value') cil managed
{
// Code size 1 (0x1)
.maxstack 8
IL_0000: ret
} // end of method C::set_Item
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
@ -136,6 +181,20 @@ @@ -136,6 +181,20 @@
IL_0006: ret
} // end of method C::.ctor
.property instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S
Item(int32)
{
.get instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::get_Item(int32)
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::set_Item(int32,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S)
} // end of property C::Item
.property instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S
Item(object)
{
.get instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::get_Item(object)
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::set_Item(object,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S)
} // end of property C::Item
} // end of class C
.class sequential ansi sealed nested public beforefieldinit S
@ -573,13 +632,449 @@ @@ -573,13 +632,449 @@
} // end of property StructData::MoreData
} // end of class StructData
.class auto ansi nested public beforefieldinit Item
extends [mscorlib]System.Object
{
.field private string '<Text>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private valuetype [mscorlib]System.Decimal '<Value>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private valuetype [mscorlib]System.Decimal '<Value2>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private string '<Value3>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private string '<Value4>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private string '<Value5>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private string '<Value6>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.method public hidebysig specialname
instance string get_Text() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Text>k__BackingField'
IL_0006: ret
} // end of method Item::get_Text
.method public hidebysig specialname
instance void set_Text(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Text>k__BackingField'
IL_0007: ret
} // end of method Item::set_Text
.method public hidebysig specialname
instance valuetype [mscorlib]System.Decimal
get_Value() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value>k__BackingField'
IL_0006: ret
} // end of method Item::get_Value
.method public hidebysig specialname
instance void set_Value(valuetype [mscorlib]System.Decimal 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value>k__BackingField'
IL_0007: ret
} // end of method Item::set_Value
.method public hidebysig specialname
instance valuetype [mscorlib]System.Decimal
get_Value2() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value2>k__BackingField'
IL_0006: ret
} // end of method Item::get_Value2
.method public hidebysig specialname
instance void set_Value2(valuetype [mscorlib]System.Decimal 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value2>k__BackingField'
IL_0007: ret
} // end of method Item::set_Value2
.method public hidebysig specialname
instance string get_Value3() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value3>k__BackingField'
IL_0006: ret
} // end of method Item::get_Value3
.method public hidebysig specialname
instance void set_Value3(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value3>k__BackingField'
IL_0007: ret
} // end of method Item::set_Value3
.method public hidebysig specialname
instance string get_Value4() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value4>k__BackingField'
IL_0006: ret
} // end of method Item::get_Value4
.method public hidebysig specialname
instance void set_Value4(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value4>k__BackingField'
IL_0007: ret
} // end of method Item::set_Value4
.method public hidebysig specialname
instance string get_Value5() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value5>k__BackingField'
IL_0006: ret
} // end of method Item::get_Value5
.method public hidebysig specialname
instance void set_Value5(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value5>k__BackingField'
IL_0007: ret
} // end of method Item::set_Value5
.method public hidebysig specialname
instance string get_Value6() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value6>k__BackingField'
IL_0006: ret
} // end of method Item::get_Value6
.method public hidebysig specialname
instance void set_Value6(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value6>k__BackingField'
IL_0007: ret
} // end of method Item::set_Value6
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// 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 Item::.ctor
.property instance string Text()
{
.get instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Text()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Text(string)
} // end of property Item::Text
.property instance valuetype [mscorlib]System.Decimal
Value()
{
.get instance valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Value()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value(valuetype [mscorlib]System.Decimal)
} // end of property Item::Value
.property instance valuetype [mscorlib]System.Decimal
Value2()
{
.get instance valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Value2()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value2(valuetype [mscorlib]System.Decimal)
} // end of property Item::Value2
.property instance string Value3()
{
.get instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Value3()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value3(string)
} // end of property Item::Value3
.property instance string Value4()
{
.get instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Value4()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value4(string)
} // end of property Item::Value4
.property instance string Value5()
{
.get instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Value5()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value5(string)
} // end of property Item::Value5
.property instance string Value6()
{
.get instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Value6()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value6(string)
} // end of property Item::Value6
} // end of class Item
.class auto ansi nested public beforefieldinit OtherItem
extends [mscorlib]System.Object
{
.field private valuetype [mscorlib]System.Decimal '<Value>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private valuetype [mscorlib]System.Decimal '<Value2>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> '<Nullable>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> '<Nullable2>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> '<Nullable3>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> '<Nullable4>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.method public hidebysig specialname
instance valuetype [mscorlib]System.Decimal
get_Value() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Value>k__BackingField'
IL_0006: ret
} // end of method OtherItem::get_Value
.method public hidebysig specialname
instance void set_Value(valuetype [mscorlib]System.Decimal 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Value>k__BackingField'
IL_0007: ret
} // end of method OtherItem::set_Value
.method public hidebysig specialname
instance valuetype [mscorlib]System.Decimal
get_Value2() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Value2>k__BackingField'
IL_0006: ret
} // end of method OtherItem::get_Value2
.method public hidebysig specialname
instance void set_Value2(valuetype [mscorlib]System.Decimal 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Value2>k__BackingField'
IL_0007: ret
} // end of method OtherItem::set_Value2
.method public hidebysig specialname
instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
get_Nullable() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable>k__BackingField'
IL_0006: ret
} // end of method OtherItem::get_Nullable
.method public hidebysig specialname
instance void set_Nullable(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable>k__BackingField'
IL_0007: ret
} // end of method OtherItem::set_Nullable
.method public hidebysig specialname
instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
get_Nullable2() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable2>k__BackingField'
IL_0006: ret
} // end of method OtherItem::get_Nullable2
.method public hidebysig specialname
instance void set_Nullable2(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable2>k__BackingField'
IL_0007: ret
} // end of method OtherItem::set_Nullable2
.method public hidebysig specialname
instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
get_Nullable3() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable3>k__BackingField'
IL_0006: ret
} // end of method OtherItem::get_Nullable3
.method public hidebysig specialname
instance void set_Nullable3(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable3>k__BackingField'
IL_0007: ret
} // end of method OtherItem::set_Nullable3
.method public hidebysig specialname
instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
get_Nullable4() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable4>k__BackingField'
IL_0006: ret
} // end of method OtherItem::get_Nullable4
.method public hidebysig specialname
instance void set_Nullable4(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable4>k__BackingField'
IL_0007: ret
} // end of method OtherItem::set_Nullable4
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// 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 OtherItem::.ctor
.property instance valuetype [mscorlib]System.Decimal
Value()
{
.get instance valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Value()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::set_Value(valuetype [mscorlib]System.Decimal)
} // end of property OtherItem::Value
.property instance valuetype [mscorlib]System.Decimal
Value2()
{
.get instance valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Value2()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::set_Value2(valuetype [mscorlib]System.Decimal)
} // end of property OtherItem::Value2
.property instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
Nullable()
{
.get instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::set_Nullable(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>)
} // end of property OtherItem::Nullable
.property instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
Nullable2()
{
.get instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable2()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::set_Nullable2(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>)
} // end of property OtherItem::Nullable2
.property instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
Nullable3()
{
.get instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable3()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::set_Nullable3(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>)
} // end of property OtherItem::Nullable3
.property instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
Nullable4()
{
.get instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable4()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::set_Nullable4(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>)
} // end of property OtherItem::Nullable4
} // end of class OtherItem
.class auto ansi serializable sealed nested private beforefieldinit '<>c'
extends [mscorlib]System.Object
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field public static initonly class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c' '<>9'
.field public static class [mscorlib]System.EventHandler '<>9__30_0'
.field public static class [mscorlib]System.Func`2<class [mscorlib]System.Globalization.NumberFormatInfo,bool> '<>9__50_0'
.field public static class [mscorlib]System.EventHandler '<>9__32_0'
.field public static class [mscorlib]System.Func`2<class [mscorlib]System.Globalization.NumberFormatInfo,bool> '<>9__52_0'
.method private hidebysig specialname rtspecialname static
void .cctor() cil managed
{
@ -601,17 +1096,17 @@ @@ -601,17 +1096,17 @@
} // end of method '<>c'::.ctor
.method assembly hidebysig instance void
'<NotAnObjectInitializerWithEvent>b__30_0'(object '<p0>',
'<NotAnObjectInitializerWithEvent>b__32_0'(object '<p0>',
class [mscorlib]System.EventArgs '<p1>') cil managed
{
// Code size 6 (0x6)
.maxstack 8
IL_0000: call void [mscorlib]System.Console::WriteLine()
IL_0005: ret
} // end of method '<>c'::'<NotAnObjectInitializerWithEvent>b__30_0'
} // end of method '<>c'::'<NotAnObjectInitializerWithEvent>b__32_0'
.method assembly hidebysig instance bool
'<Bug270_NestedInitialisers>b__50_0'(class [mscorlib]System.Globalization.NumberFormatInfo format) cil managed
'<Bug270_NestedInitialisers>b__52_0'(class [mscorlib]System.Globalization.NumberFormatInfo format) cil managed
{
// Code size 17 (0x11)
.maxstack 8
@ -621,7 +1116,7 @@ @@ -621,7 +1116,7 @@
IL_000b: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0010: ret
} // end of method '<>c'::'<Bug270_NestedInitialisers>b__50_0'
} // end of method '<>c'::'<Bug270_NestedInitialisers>b__52_0'
} // end of class '<>c'
@ -1030,18 +1525,18 @@ @@ -1030,18 +1525,18 @@
IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::.ctor()
IL_0005: stloc.0
IL_0006: ldloc.0
IL_0007: ldsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__30_0'
IL_0007: ldsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__32_0'
IL_000c: dup
IL_000d: brtrue.s IL_0026
IL_000f: pop
IL_0010: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9'
IL_0015: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<NotAnObjectInitializerWithEvent>b__30_0'(object,
IL_0015: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<NotAnObjectInitializerWithEvent>b__32_0'(object,
class [mscorlib]System.EventArgs)
IL_001b: newobj instance void [mscorlib]System.EventHandler::.ctor(object,
native int)
IL_0020: dup
IL_0021: stsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__30_0'
IL_0021: stsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__32_0'
IL_0026: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::add_TestEvent(class [mscorlib]System.EventHandler)
IL_002b: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Y()
IL_0030: ldloc.0
@ -1261,10 +1756,10 @@ @@ -1261,10 +1756,10 @@
IL_0081: ret
} // end of method TestCases::MixedObjectAndDictInitializer
.method public hidebysig instance void
NestedListWithIndexInitializer() cil managed
.method private hidebysig instance void
NestedListWithIndexInitializer(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum myEnum) cil managed
{
// Code size 46 (0x2e)
// Code size 59 (0x3b)
.maxstack 8
IL_0000: newobj instance void class [mscorlib]System.Collections.Generic.List`1<class [mscorlib]System.Collections.Generic.List`1<int32>>::.ctor()
IL_0005: dup
@ -1282,8 +1777,13 @@ @@ -1282,8 +1777,13 @@
IL_0021: callvirt instance !0 class [mscorlib]System.Collections.Generic.List`1<class [mscorlib]System.Collections.Generic.List`1<int32>>::get_Item(int32)
IL_0026: ldc.i4.3
IL_0027: callvirt instance void class [mscorlib]System.Collections.Generic.List`1<int32>::Add(!0)
IL_002c: pop
IL_002d: ret
IL_002c: dup
IL_002d: ldc.i4.1
IL_002e: callvirt instance !0 class [mscorlib]System.Collections.Generic.List`1<class [mscorlib]System.Collections.Generic.List`1<int32>>::get_Item(int32)
IL_0033: ldarg.1
IL_0034: callvirt instance void class [mscorlib]System.Collections.Generic.List`1<int32>::Add(!0)
IL_0039: pop
IL_003a: ret
} // end of method TestCases::NestedListWithIndexInitializer
.method public hidebysig static void ObjectInitializerWithInitializationOfDeeplyNestedObjects() cil managed
@ -1504,17 +2004,17 @@ @@ -1504,17 +2004,17 @@
IL_0033: callvirt instance void [mscorlib]System.Globalization.CultureInfo::set_DateTimeFormat(class [mscorlib]System.Globalization.DateTimeFormatInfo)
IL_0038: dup
IL_0039: ldloc.0
IL_003a: ldsfld class [mscorlib]System.Func`2<class [mscorlib]System.Globalization.NumberFormatInfo,bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__50_0'
IL_003a: ldsfld class [mscorlib]System.Func`2<class [mscorlib]System.Globalization.NumberFormatInfo,bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__52_0'
IL_003f: dup
IL_0040: brtrue.s IL_0059
IL_0042: pop
IL_0043: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9'
IL_0048: ldftn instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<Bug270_NestedInitialisers>b__50_0'(class [mscorlib]System.Globalization.NumberFormatInfo)
IL_0048: ldftn instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<Bug270_NestedInitialisers>b__52_0'(class [mscorlib]System.Globalization.NumberFormatInfo)
IL_004e: newobj instance void class [mscorlib]System.Func`2<class [mscorlib]System.Globalization.NumberFormatInfo,bool>::.ctor(object,
native int)
IL_0053: dup
IL_0054: stsfld class [mscorlib]System.Func`2<class [mscorlib]System.Globalization.NumberFormatInfo,bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__50_0'
IL_0054: stsfld class [mscorlib]System.Func`2<class [mscorlib]System.Globalization.NumberFormatInfo,bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__52_0'
IL_0059: call class [mscorlib]System.Collections.Generic.IEnumerable`1<!!0> [System.Core]System.Linq.Enumerable::Where<class [mscorlib]System.Globalization.NumberFormatInfo>(class [mscorlib]System.Collections.Generic.IEnumerable`1<!!0>,
class [mscorlib]System.Func`2<!!0,bool>)
IL_005e: call !!0 [System.Core]System.Linq.Enumerable::First<class [mscorlib]System.Globalization.NumberFormatInfo>(class [mscorlib]System.Collections.Generic.IEnumerable`1<!!0>)
@ -1557,6 +2057,177 @@ @@ -1557,6 +2057,177 @@
IL_001b: ret
} // end of method TestCases::Issue907_Test3
.method private hidebysig instance void
Issue1250_Test1(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum 'value') cil managed
{
// Code size 23 (0x17)
.maxstack 8
IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Y()
IL_0005: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::.ctor()
IL_000a: dup
IL_000b: ldarg.1
IL_000c: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::Z
IL_0011: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object,
object)
IL_0016: ret
} // end of method TestCases::Issue1250_Test1
.method private hidebysig instance void
Issue1250_Test2(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum 'value') cil managed
{
// Code size 31 (0x1f)
.maxstack 5
.locals init (int32 V_0)
IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Y()
IL_0005: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::.ctor()
IL_000a: ldarg.1
IL_000b: stloc.0
IL_000c: dup
IL_000d: ldloc.0
IL_000e: ldarg.1
IL_000f: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S::.ctor(int32)
IL_0014: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::set_Item(int32,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S)
IL_0019: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object,
object)
IL_001e: ret
} // end of method TestCases::Issue1250_Test2
.method private hidebysig instance void
Issue1250_Test3(int32 'value') cil managed
{
// Code size 31 (0x1f)
.maxstack 5
.locals init (int32 V_0)
IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Y()
IL_0005: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::.ctor()
IL_000a: ldarg.1
IL_000b: stloc.0
IL_000c: dup
IL_000d: ldloc.0
IL_000e: ldarg.1
IL_000f: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S::.ctor(int32)
IL_0014: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::set_Item(int32,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S)
IL_0019: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object,
object)
IL_001e: ret
} // end of method TestCases::Issue1250_Test3
.method private hidebysig instance void
Issue1250_Test4(int32 'value') cil managed
{
// Code size 36 (0x24)
.maxstack 5
.locals init (object V_0)
IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Y()
IL_0005: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::.ctor()
IL_000a: ldarg.1
IL_000b: box [mscorlib]System.Int32
IL_0010: stloc.0
IL_0011: dup
IL_0012: ldloc.0
IL_0013: ldarg.1
IL_0014: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S::.ctor(int32)
IL_0019: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::set_Item(object,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S)
IL_001e: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object,
object)
IL_0023: ret
} // end of method TestCases::Issue1250_Test4
.method private hidebysig instance void
Issue1251_Test(class [mscorlib]System.Collections.Generic.List`1<class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item> list,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem otherItem) cil managed
{
// Code size 151 (0x97)
.maxstack 4
.locals init (valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> V_0)
IL_0000: ldarg.1
IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::.ctor()
IL_0006: dup
IL_0007: ldstr "Text"
IL_000c: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Text(string)
IL_0011: dup
IL_0012: ldarg.2
IL_0013: callvirt instance valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Value()
IL_0018: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value(valuetype [mscorlib]System.Decimal)
IL_001d: dup
IL_001e: ldarg.2
IL_001f: callvirt instance valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Value2()
IL_0024: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value2(valuetype [mscorlib]System.Decimal)
IL_0029: dup
IL_002a: ldarg.2
IL_002b: callvirt instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable()
IL_0030: stloc.0
IL_0031: ldloca.s V_0
IL_0033: constrained. valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
IL_0039: callvirt instance string [mscorlib]System.Object::ToString()
IL_003e: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value3(string)
IL_0043: dup
IL_0044: ldarg.2
IL_0045: callvirt instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable2()
IL_004a: stloc.0
IL_004b: ldloca.s V_0
IL_004d: constrained. valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
IL_0053: callvirt instance string [mscorlib]System.Object::ToString()
IL_0058: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value4(string)
IL_005d: dup
IL_005e: ldarg.2
IL_005f: callvirt instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable3()
IL_0064: stloc.0
IL_0065: ldloca.s V_0
IL_0067: constrained. valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
IL_006d: callvirt instance string [mscorlib]System.Object::ToString()
IL_0072: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value5(string)
IL_0077: dup
IL_0078: ldarg.2
IL_0079: callvirt instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable4()
IL_007e: stloc.0
IL_007f: ldloca.s V_0
IL_0081: constrained. valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
IL_0087: callvirt instance string [mscorlib]System.Object::ToString()
IL_008c: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value6(string)
IL_0091: callvirt instance void class [mscorlib]System.Collections.Generic.List`1<class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item>::Add(!0)
IL_0096: ret
} // end of method TestCases::Issue1251_Test
.method private hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data
Issue1279(int32 p) cil managed
{
// Code size 37 (0x25)
.maxstack 8
IL_0000: ldarg.1
IL_0001: ldc.i4.1
IL_0002: bne.un.s IL_0023
IL_0004: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::.ctor()
IL_0009: dup
IL_000a: ldc.i4.0
IL_000b: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum)
IL_0010: dup
IL_0011: ldarg.0
IL_0012: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Data_TestEvent(object,
class [mscorlib]System.EventArgs)
IL_0018: newobj instance void [mscorlib]System.EventHandler::.ctor(object,
native int)
IL_001d: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::add_TestEvent(class [mscorlib]System.EventHandler)
IL_0022: ret
IL_0023: ldnull
IL_0024: ret
} // end of method TestCases::Issue1279
.method private hidebysig instance void
Data_TestEvent(object sender,
class [mscorlib]System.EventArgs e) cil managed
{
// Code size 6 (0x6)
.maxstack 8
IL_0000: newobj instance void [mscorlib]System.NotImplementedException::.ctor()
IL_0005: throw
} // end of method TestCases::Data_TestEvent
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
@ -1580,13 +2251,13 @@ @@ -1580,13 +2251,13 @@
.size 40
} // end of class '__StaticArrayInitTypeSize=40'
.field static assembly initonly valuetype '<PrivateImplementationDetails>'/'__StaticArrayInitTypeSize=40' E0D2592373A0C161E56E266306CD8405CD719D19 at I_00004630
.field static assembly initonly valuetype '<PrivateImplementationDetails>'/'__StaticArrayInitTypeSize=40' E0D2592373A0C161E56E266306CD8405CD719D19 at I_00005180
} // end of class '<PrivateImplementationDetails>'
// =============================================================
.data cil I_00004630 = bytearray (
.data cil I_00005180 = bytearray (
01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00
05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00
09 00 00 00 0A 00 00 00)

777
ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.roslyn.il

@ -130,9 +130,68 @@ @@ -130,9 +130,68 @@
.class auto ansi nested public beforefieldinit C
extends [mscorlib]System.Object
{
.custom instance void [mscorlib]System.Reflection.DefaultMemberAttribute::.ctor(string) = ( 01 00 04 49 74 65 6D 00 00 ) // ...Item..
.field public int32 Z
.field public valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S Y
.field public class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S> L
.method public hidebysig specialname
instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S
get_Item(int32 index) cil managed
{
// Code size 15 (0xf)
.maxstack 1
.locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S V_0,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S V_1)
IL_0000: nop
IL_0001: ldloca.s V_0
IL_0003: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S
IL_0009: ldloc.0
IL_000a: stloc.1
IL_000b: br.s IL_000d
IL_000d: ldloc.1
IL_000e: ret
} // end of method C::get_Item
.method public hidebysig specialname
instance void set_Item(int32 index,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S 'value') cil managed
{
// Code size 2 (0x2)
.maxstack 8
IL_0000: nop
IL_0001: ret
} // end of method C::set_Item
.method public hidebysig specialname
instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S
get_Item(object key) cil managed
{
// Code size 15 (0xf)
.maxstack 1
.locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S V_0,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S V_1)
IL_0000: nop
IL_0001: ldloca.s V_0
IL_0003: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S
IL_0009: ldloc.0
IL_000a: stloc.1
IL_000b: br.s IL_000d
IL_000d: ldloc.1
IL_000e: ret
} // end of method C::get_Item
.method public hidebysig specialname
instance void set_Item(object key,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S 'value') cil managed
{
// Code size 2 (0x2)
.maxstack 8
IL_0000: nop
IL_0001: ret
} // end of method C::set_Item
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
@ -144,6 +203,20 @@ @@ -144,6 +203,20 @@
IL_0007: ret
} // end of method C::.ctor
.property instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S
Item(int32)
{
.get instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::get_Item(int32)
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::set_Item(int32,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S)
} // end of property C::Item
.property instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S
Item(object)
{
.get instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::get_Item(object)
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::set_Item(object,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S)
} // end of property C::Item
} // end of class C
.class sequential ansi sealed nested public beforefieldinit S
@ -607,13 +680,464 @@ @@ -607,13 +680,464 @@
} // end of property StructData::MoreData
} // end of class StructData
.class auto ansi nested public beforefieldinit Item
extends [mscorlib]System.Object
{
.field private string '<Text>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
.field private valuetype [mscorlib]System.Decimal '<Value>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
.field private valuetype [mscorlib]System.Decimal '<Value2>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
.field private string '<Value3>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
.field private string '<Value4>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
.field private string '<Value5>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
.field private string '<Value6>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
.method public hidebysig specialname
instance string get_Text() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Text>k__BackingField'
IL_0006: ret
} // end of method Item::get_Text
.method public hidebysig specialname
instance void set_Text(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Text>k__BackingField'
IL_0007: ret
} // end of method Item::set_Text
.method public hidebysig specialname
instance valuetype [mscorlib]System.Decimal
get_Value() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value>k__BackingField'
IL_0006: ret
} // end of method Item::get_Value
.method public hidebysig specialname
instance void set_Value(valuetype [mscorlib]System.Decimal 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value>k__BackingField'
IL_0007: ret
} // end of method Item::set_Value
.method public hidebysig specialname
instance valuetype [mscorlib]System.Decimal
get_Value2() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value2>k__BackingField'
IL_0006: ret
} // end of method Item::get_Value2
.method public hidebysig specialname
instance void set_Value2(valuetype [mscorlib]System.Decimal 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value2>k__BackingField'
IL_0007: ret
} // end of method Item::set_Value2
.method public hidebysig specialname
instance string get_Value3() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value3>k__BackingField'
IL_0006: ret
} // end of method Item::get_Value3
.method public hidebysig specialname
instance void set_Value3(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value3>k__BackingField'
IL_0007: ret
} // end of method Item::set_Value3
.method public hidebysig specialname
instance string get_Value4() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value4>k__BackingField'
IL_0006: ret
} // end of method Item::get_Value4
.method public hidebysig specialname
instance void set_Value4(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value4>k__BackingField'
IL_0007: ret
} // end of method Item::set_Value4
.method public hidebysig specialname
instance string get_Value5() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value5>k__BackingField'
IL_0006: ret
} // end of method Item::get_Value5
.method public hidebysig specialname
instance void set_Value5(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value5>k__BackingField'
IL_0007: ret
} // end of method Item::set_Value5
.method public hidebysig specialname
instance string get_Value6() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value6>k__BackingField'
IL_0006: ret
} // end of method Item::get_Value6
.method public hidebysig specialname
instance void set_Value6(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::'<Value6>k__BackingField'
IL_0007: ret
} // end of method Item::set_Value6
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// 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 Item::.ctor
.property instance string Text()
{
.get instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Text()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Text(string)
} // end of property Item::Text
.property instance valuetype [mscorlib]System.Decimal
Value()
{
.get instance valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Value()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value(valuetype [mscorlib]System.Decimal)
} // end of property Item::Value
.property instance valuetype [mscorlib]System.Decimal
Value2()
{
.get instance valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Value2()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value2(valuetype [mscorlib]System.Decimal)
} // end of property Item::Value2
.property instance string Value3()
{
.get instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Value3()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value3(string)
} // end of property Item::Value3
.property instance string Value4()
{
.get instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Value4()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value4(string)
} // end of property Item::Value4
.property instance string Value5()
{
.get instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Value5()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value5(string)
} // end of property Item::Value5
.property instance string Value6()
{
.get instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::get_Value6()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value6(string)
} // end of property Item::Value6
} // end of class Item
.class auto ansi nested public beforefieldinit OtherItem
extends [mscorlib]System.Object
{
.field private valuetype [mscorlib]System.Decimal '<Value>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
.field private valuetype [mscorlib]System.Decimal '<Value2>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
.field private valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> '<Nullable>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
.field private valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> '<Nullable2>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
.field private valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> '<Nullable3>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
.field private valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> '<Nullable4>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
.method public hidebysig specialname
instance valuetype [mscorlib]System.Decimal
get_Value() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Value>k__BackingField'
IL_0006: ret
} // end of method OtherItem::get_Value
.method public hidebysig specialname
instance void set_Value(valuetype [mscorlib]System.Decimal 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Value>k__BackingField'
IL_0007: ret
} // end of method OtherItem::set_Value
.method public hidebysig specialname
instance valuetype [mscorlib]System.Decimal
get_Value2() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Value2>k__BackingField'
IL_0006: ret
} // end of method OtherItem::get_Value2
.method public hidebysig specialname
instance void set_Value2(valuetype [mscorlib]System.Decimal 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Value2>k__BackingField'
IL_0007: ret
} // end of method OtherItem::set_Value2
.method public hidebysig specialname
instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
get_Nullable() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable>k__BackingField'
IL_0006: ret
} // end of method OtherItem::get_Nullable
.method public hidebysig specialname
instance void set_Nullable(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable>k__BackingField'
IL_0007: ret
} // end of method OtherItem::set_Nullable
.method public hidebysig specialname
instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
get_Nullable2() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable2>k__BackingField'
IL_0006: ret
} // end of method OtherItem::get_Nullable2
.method public hidebysig specialname
instance void set_Nullable2(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable2>k__BackingField'
IL_0007: ret
} // end of method OtherItem::set_Nullable2
.method public hidebysig specialname
instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
get_Nullable3() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable3>k__BackingField'
IL_0006: ret
} // end of method OtherItem::get_Nullable3
.method public hidebysig specialname
instance void set_Nullable3(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable3>k__BackingField'
IL_0007: ret
} // end of method OtherItem::set_Nullable3
.method public hidebysig specialname
instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
get_Nullable4() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable4>k__BackingField'
IL_0006: ret
} // end of method OtherItem::get_Nullable4
.method public hidebysig specialname
instance void set_Nullable4(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::'<Nullable4>k__BackingField'
IL_0007: ret
} // end of method OtherItem::set_Nullable4
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// 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 OtherItem::.ctor
.property instance valuetype [mscorlib]System.Decimal
Value()
{
.get instance valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Value()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::set_Value(valuetype [mscorlib]System.Decimal)
} // end of property OtherItem::Value
.property instance valuetype [mscorlib]System.Decimal
Value2()
{
.get instance valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Value2()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::set_Value2(valuetype [mscorlib]System.Decimal)
} // end of property OtherItem::Value2
.property instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
Nullable()
{
.get instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::set_Nullable(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>)
} // end of property OtherItem::Nullable
.property instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
Nullable2()
{
.get instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable2()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::set_Nullable2(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>)
} // end of property OtherItem::Nullable2
.property instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
Nullable3()
{
.get instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable3()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::set_Nullable3(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>)
} // end of property OtherItem::Nullable3
.property instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
Nullable4()
{
.get instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable4()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::set_Nullable4(valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>)
} // end of property OtherItem::Nullable4
} // end of class OtherItem
.class auto ansi serializable sealed nested private beforefieldinit '<>c'
extends [mscorlib]System.Object
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field public static initonly class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c' '<>9'
.field public static class [mscorlib]System.EventHandler '<>9__30_0'
.field public static class [mscorlib]System.Func`2<class [mscorlib]System.Globalization.NumberFormatInfo,bool> '<>9__50_0'
.field public static class [mscorlib]System.EventHandler '<>9__32_0'
.field public static class [mscorlib]System.Func`2<class [mscorlib]System.Globalization.NumberFormatInfo,bool> '<>9__52_0'
.method private hidebysig specialname rtspecialname static
void .cctor() cil managed
{
@ -636,7 +1160,7 @@ @@ -636,7 +1160,7 @@
} // end of method '<>c'::.ctor
.method assembly hidebysig instance void
'<NotAnObjectInitializerWithEvent>b__30_0'(object '<p0>',
'<NotAnObjectInitializerWithEvent>b__32_0'(object '<p0>',
class [mscorlib]System.EventArgs '<p1>') cil managed
{
// Code size 8 (0x8)
@ -645,10 +1169,10 @@ @@ -645,10 +1169,10 @@
IL_0001: call void [mscorlib]System.Console::WriteLine()
IL_0006: nop
IL_0007: ret
} // end of method '<>c'::'<NotAnObjectInitializerWithEvent>b__30_0'
} // end of method '<>c'::'<NotAnObjectInitializerWithEvent>b__32_0'
.method assembly hidebysig instance bool
'<Bug270_NestedInitialisers>b__50_0'(class [mscorlib]System.Globalization.NumberFormatInfo format) cil managed
'<Bug270_NestedInitialisers>b__52_0'(class [mscorlib]System.Globalization.NumberFormatInfo format) cil managed
{
// Code size 17 (0x11)
.maxstack 8
@ -658,7 +1182,7 @@ @@ -658,7 +1182,7 @@
IL_000b: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0010: ret
} // end of method '<>c'::'<Bug270_NestedInitialisers>b__50_0'
} // end of method '<>c'::'<Bug270_NestedInitialisers>b__52_0'
} // end of class '<>c'
@ -1185,18 +1709,18 @@ @@ -1185,18 +1709,18 @@
IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::.ctor()
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: ldsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__30_0'
IL_0008: ldsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__32_0'
IL_000d: dup
IL_000e: brtrue.s IL_0027
IL_0010: pop
IL_0011: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9'
IL_0016: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<NotAnObjectInitializerWithEvent>b__30_0'(object,
IL_0016: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<NotAnObjectInitializerWithEvent>b__32_0'(object,
class [mscorlib]System.EventArgs)
IL_001c: newobj instance void [mscorlib]System.EventHandler::.ctor(object,
native int)
IL_0021: dup
IL_0022: stsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__30_0'
IL_0022: stsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__32_0'
IL_0027: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::add_TestEvent(class [mscorlib]System.EventHandler)
IL_002c: nop
IL_002d: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Y()
@ -1467,10 +1991,10 @@ @@ -1467,10 +1991,10 @@
IL_0088: ret
} // end of method TestCases::MixedObjectAndDictInitializer
.method public hidebysig instance void
NestedListWithIndexInitializer() cil managed
.method private hidebysig instance void
NestedListWithIndexInitializer(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum myEnum) cil managed
{
// Code size 50 (0x32)
// Code size 64 (0x40)
.maxstack 3
.locals init (class [mscorlib]System.Collections.Generic.List`1<class [mscorlib]System.Collections.Generic.List`1<int32>> V_0)
IL_0000: nop
@ -1493,8 +2017,14 @@ @@ -1493,8 +2017,14 @@
IL_0029: ldc.i4.3
IL_002a: callvirt instance void class [mscorlib]System.Collections.Generic.List`1<int32>::Add(!0)
IL_002f: nop
IL_0030: stloc.0
IL_0031: ret
IL_0030: dup
IL_0031: ldc.i4.1
IL_0032: callvirt instance !0 class [mscorlib]System.Collections.Generic.List`1<class [mscorlib]System.Collections.Generic.List`1<int32>>::get_Item(int32)
IL_0037: ldarg.1
IL_0038: callvirt instance void class [mscorlib]System.Collections.Generic.List`1<int32>::Add(!0)
IL_003d: nop
IL_003e: stloc.0
IL_003f: ret
} // end of method TestCases::NestedListWithIndexInitializer
.method public hidebysig static void ObjectInitializerWithInitializationOfDeeplyNestedObjects() cil managed
@ -1751,17 +2281,17 @@ @@ -1751,17 +2281,17 @@
IL_003b: nop
IL_003c: dup
IL_003d: ldloc.0
IL_003e: ldsfld class [mscorlib]System.Func`2<class [mscorlib]System.Globalization.NumberFormatInfo,bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__50_0'
IL_003e: ldsfld class [mscorlib]System.Func`2<class [mscorlib]System.Globalization.NumberFormatInfo,bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__52_0'
IL_0043: dup
IL_0044: brtrue.s IL_005d
IL_0046: pop
IL_0047: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9'
IL_004c: ldftn instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<Bug270_NestedInitialisers>b__50_0'(class [mscorlib]System.Globalization.NumberFormatInfo)
IL_004c: ldftn instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<Bug270_NestedInitialisers>b__52_0'(class [mscorlib]System.Globalization.NumberFormatInfo)
IL_0052: newobj instance void class [mscorlib]System.Func`2<class [mscorlib]System.Globalization.NumberFormatInfo,bool>::.ctor(object,
native int)
IL_0057: dup
IL_0058: stsfld class [mscorlib]System.Func`2<class [mscorlib]System.Globalization.NumberFormatInfo,bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__50_0'
IL_0058: stsfld class [mscorlib]System.Func`2<class [mscorlib]System.Globalization.NumberFormatInfo,bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__52_0'
IL_005d: call class [mscorlib]System.Collections.Generic.IEnumerable`1<!!0> [System.Core]System.Linq.Enumerable::Where<class [mscorlib]System.Globalization.NumberFormatInfo>(class [mscorlib]System.Collections.Generic.IEnumerable`1<!!0>,
class [mscorlib]System.Func`2<!!0,bool>)
IL_0062: call !!0 [System.Core]System.Linq.Enumerable::First<class [mscorlib]System.Globalization.NumberFormatInfo>(class [mscorlib]System.Collections.Generic.IEnumerable`1<!!0>)
@ -1812,6 +2342,215 @@ @@ -1812,6 +2342,215 @@
IL_001e: ret
} // end of method TestCases::Issue907_Test3
.method private hidebysig instance void
Issue1250_Test1(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum 'value') cil managed
{
// Code size 25 (0x19)
.maxstack 8
IL_0000: nop
IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Y()
IL_0006: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::.ctor()
IL_000b: dup
IL_000c: ldarg.1
IL_000d: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::Z
IL_0012: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object,
object)
IL_0017: nop
IL_0018: ret
} // end of method TestCases::Issue1250_Test1
.method private hidebysig instance void
Issue1250_Test2(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum 'value') cil managed
{
// Code size 34 (0x22)
.maxstack 5
.locals init (int32 V_0)
IL_0000: nop
IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Y()
IL_0006: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::.ctor()
IL_000b: ldarg.1
IL_000c: stloc.0
IL_000d: dup
IL_000e: ldloc.0
IL_000f: ldarg.1
IL_0010: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S::.ctor(int32)
IL_0015: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::set_Item(int32,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S)
IL_001a: nop
IL_001b: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object,
object)
IL_0020: nop
IL_0021: ret
} // end of method TestCases::Issue1250_Test2
.method private hidebysig instance void
Issue1250_Test3(int32 'value') cil managed
{
// Code size 34 (0x22)
.maxstack 5
.locals init (int32 V_0)
IL_0000: nop
IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Y()
IL_0006: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::.ctor()
IL_000b: ldarg.1
IL_000c: stloc.0
IL_000d: dup
IL_000e: ldloc.0
IL_000f: ldarg.1
IL_0010: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S::.ctor(int32)
IL_0015: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::set_Item(int32,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S)
IL_001a: nop
IL_001b: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object,
object)
IL_0020: nop
IL_0021: ret
} // end of method TestCases::Issue1250_Test3
.method private hidebysig instance void
Issue1250_Test4(int32 'value') cil managed
{
// Code size 39 (0x27)
.maxstack 5
.locals init (object V_0)
IL_0000: nop
IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Y()
IL_0006: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::.ctor()
IL_000b: ldarg.1
IL_000c: box [mscorlib]System.Int32
IL_0011: stloc.0
IL_0012: dup
IL_0013: ldloc.0
IL_0014: ldarg.1
IL_0015: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S::.ctor(int32)
IL_001a: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C::set_Item(object,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/S)
IL_001f: nop
IL_0020: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object,
object)
IL_0025: nop
IL_0026: ret
} // end of method TestCases::Issue1250_Test4
.method private hidebysig instance void
Issue1251_Test(class [mscorlib]System.Collections.Generic.List`1<class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item> list,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem otherItem) cil managed
{
// Code size 160 (0xa0)
.maxstack 4
.locals init (valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> V_0)
IL_0000: nop
IL_0001: ldarg.1
IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::.ctor()
IL_0007: dup
IL_0008: ldstr "Text"
IL_000d: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Text(string)
IL_0012: nop
IL_0013: dup
IL_0014: ldarg.2
IL_0015: callvirt instance valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Value()
IL_001a: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value(valuetype [mscorlib]System.Decimal)
IL_001f: nop
IL_0020: dup
IL_0021: ldarg.2
IL_0022: callvirt instance valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Value2()
IL_0027: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value2(valuetype [mscorlib]System.Decimal)
IL_002c: nop
IL_002d: dup
IL_002e: ldarg.2
IL_002f: callvirt instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable()
IL_0034: stloc.0
IL_0035: ldloca.s V_0
IL_0037: constrained. valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
IL_003d: callvirt instance string [mscorlib]System.Object::ToString()
IL_0042: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value3(string)
IL_0047: nop
IL_0048: dup
IL_0049: ldarg.2
IL_004a: callvirt instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable2()
IL_004f: stloc.0
IL_0050: ldloca.s V_0
IL_0052: constrained. valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
IL_0058: callvirt instance string [mscorlib]System.Object::ToString()
IL_005d: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value4(string)
IL_0062: nop
IL_0063: dup
IL_0064: ldarg.2
IL_0065: callvirt instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable3()
IL_006a: stloc.0
IL_006b: ldloca.s V_0
IL_006d: constrained. valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
IL_0073: callvirt instance string [mscorlib]System.Object::ToString()
IL_0078: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value5(string)
IL_007d: nop
IL_007e: dup
IL_007f: ldarg.2
IL_0080: callvirt instance valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/OtherItem::get_Nullable4()
IL_0085: stloc.0
IL_0086: ldloca.s V_0
IL_0088: constrained. valuetype [mscorlib]System.Nullable`1<valuetype [mscorlib]System.Decimal>
IL_008e: callvirt instance string [mscorlib]System.Object::ToString()
IL_0093: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item::set_Value6(string)
IL_0098: nop
IL_0099: callvirt instance void class [mscorlib]System.Collections.Generic.List`1<class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Item>::Add(!0)
IL_009e: nop
IL_009f: ret
} // end of method TestCases::Issue1251_Test
.method private hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data
Issue1279(int32 p) cil managed
{
// Code size 53 (0x35)
.maxstack 3
.locals init (bool V_0,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data V_1,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data V_2)
IL_0000: nop
IL_0001: ldarg.1
IL_0002: ldc.i4.1
IL_0003: ceq
IL_0005: stloc.0
IL_0006: ldloc.0
IL_0007: brfalse.s IL_002f
IL_0009: nop
IL_000a: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::.ctor()
IL_000f: stloc.1
IL_0010: ldloc.1
IL_0011: ldc.i4.0
IL_0012: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/MyEnum)
IL_0017: nop
IL_0018: ldloc.1
IL_0019: ldarg.0
IL_001a: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Data_TestEvent(object,
class [mscorlib]System.EventArgs)
IL_0020: newobj instance void [mscorlib]System.EventHandler::.ctor(object,
native int)
IL_0025: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::add_TestEvent(class [mscorlib]System.EventHandler)
IL_002a: nop
IL_002b: ldloc.1
IL_002c: stloc.2
IL_002d: br.s IL_0033
IL_002f: ldnull
IL_0030: stloc.2
IL_0031: br.s IL_0033
IL_0033: ldloc.2
IL_0034: ret
} // end of method TestCases::Issue1279
.method private hidebysig instance void
Data_TestEvent(object sender,
class [mscorlib]System.EventArgs e) cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: nop
IL_0001: newobj instance void [mscorlib]System.NotImplementedException::.ctor()
IL_0006: throw
} // end of method TestCases::Data_TestEvent
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
@ -1836,13 +2575,13 @@ @@ -1836,13 +2575,13 @@
.size 40
} // end of class '__StaticArrayInitTypeSize=40'
.field static assembly initonly valuetype '<PrivateImplementationDetails>'/'__StaticArrayInitTypeSize=40' E0D2592373A0C161E56E266306CD8405CD719D19 at I_00004884
.field static assembly initonly valuetype '<PrivateImplementationDetails>'/'__StaticArrayInitTypeSize=40' E0D2592373A0C161E56E266306CD8405CD719D19 at I_0000545C
} // end of class '<PrivateImplementationDetails>'
// =============================================================
.data cil I_00004884 = bytearray (
.data cil I_0000545C = bytearray (
01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00
05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00
09 00 00 00 0A 00 00 00)

70
ICSharpCode.Decompiler.Tests/TypeSystem/TypeSystemLoaderTests.cs

@ -111,6 +111,42 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem @@ -111,6 +111,42 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
Assert.IsNull(method.AccessorOwner);
}
[Test]
public void SimplePublicClassCtorTest()
{
ITypeDefinition c = GetTypeDefinition(typeof(SimplePublicClass));
IMethod method = c.Methods.Single(m => m.IsConstructor);
Assert.AreEqual(typeof(SimplePublicClass).FullName + "..ctor", method.FullName);
Assert.AreSame(c, method.DeclaringType);
Assert.AreEqual(Accessibility.Public, method.Accessibility);
Assert.AreEqual(SymbolKind.Constructor, method.SymbolKind);
Assert.IsFalse(method.IsVirtual);
Assert.IsFalse(method.IsStatic);
Assert.AreEqual(0, method.Parameters.Count);
Assert.AreEqual(0, method.GetAttributes().Count());
Assert.IsTrue(method.HasBody);
Assert.IsNull(method.AccessorOwner);
}
[Test]
public void SimplePublicClassDtorTest()
{
ITypeDefinition c = GetTypeDefinition(typeof(SimplePublicClass));
IMethod method = c.Methods.Single(m => m.IsDestructor);
Assert.AreEqual(typeof(SimplePublicClass).FullName + ".Finalize", method.FullName);
Assert.AreSame(c, method.DeclaringType);
Assert.AreEqual(Accessibility.Protected, method.Accessibility);
Assert.AreEqual(SymbolKind.Destructor, method.SymbolKind);
Assert.IsFalse(method.IsVirtual);
Assert.IsFalse(method.IsStatic);
Assert.AreEqual(0, method.Parameters.Count);
Assert.AreEqual(0, method.GetAttributes().Count());
Assert.IsTrue(method.HasBody);
Assert.IsNull(method.AccessorOwner);
}
[Test]
public void DynamicType()
{
@ -521,6 +557,40 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem @@ -521,6 +557,40 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
tp.DirectBaseTypes.Select(t => t.ReflectionName).ToArray());
}
[Test]
public void DtorInDerivedClass()
{
ITypeDefinition c = GetTypeDefinition(typeof(Derived<,>));
IMethod method = c.Methods.Single(m => m.IsDestructor);
Assert.AreEqual(c.FullName + ".Finalize", method.FullName);
Assert.AreSame(c, method.DeclaringType);
Assert.AreEqual(Accessibility.Protected, method.Accessibility);
Assert.AreEqual(SymbolKind.Destructor, method.SymbolKind);
Assert.IsFalse(method.IsVirtual);
Assert.IsFalse(method.IsStatic);
Assert.AreEqual(0, method.Parameters.Count);
Assert.AreEqual(0, method.GetAttributes().Count());
Assert.IsTrue(method.HasBody);
Assert.IsNull(method.AccessorOwner);
}
[Test]
public void PrivateFinalizeMethodIsNotADtor()
{
ITypeDefinition c = GetTypeDefinition(typeof(TypeTestAttribute));
IMethod method = c.Methods.Single(m => m.Name == "Finalize");
Assert.AreEqual(c.FullName + ".Finalize", method.FullName);
Assert.AreSame(c, method.DeclaringType);
Assert.AreEqual(Accessibility.Private, method.Accessibility);
Assert.AreEqual(SymbolKind.Method, method.SymbolKind);
Assert.IsFalse(method.IsVirtual);
Assert.IsFalse(method.IsStatic);
Assert.AreEqual(0, method.Parameters.Count);
Assert.AreEqual(0, method.GetAttributes().Count());
Assert.IsTrue(method.HasBody);
Assert.IsNull(method.AccessorOwner);
}
[Test]
public void DefaultConstructorAddedToStruct()
{

13
ICSharpCode.Decompiler.Tests/TypeSystem/TypeSystemTestCase.cs

@ -33,11 +33,21 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem @@ -33,11 +33,21 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
public class SimplePublicClass
{
public void Method() { }
public SimplePublicClass() { }
~SimplePublicClass() { }
}
public class TypeTestAttribute : Attribute
{
public TypeTestAttribute(int a1, Type a2, Type a3) { }
#pragma warning disable CS0465
private void Finalize()
{
}
#pragma warning restore CS0465
}
[Params(1, StringComparison.CurrentCulture, null, 4.0, "Test")]
@ -114,10 +124,13 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem @@ -114,10 +124,13 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
{
public class Nested<X> { }
~Base() { }
public virtual void GenericMethodWithConstraints<X>(T a) where X : IComparer<T>, new() { }
}
public class Derived<A, B> : Base<B>
{
~Derived() { }
public override void GenericMethodWithConstraints<Y>(B a) { }
}

97
ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs

@ -249,9 +249,11 @@ namespace ICSharpCode.Decompiler.CSharp @@ -249,9 +249,11 @@ namespace ICSharpCode.Decompiler.CSharp
var methodSemantics = module.MethodSemanticsLookup.GetSemantics(methodHandle).Item2;
if (methodSemantics != 0 && methodSemantics != System.Reflection.MethodSemanticsAttributes.Other)
return true;
if (LocalFunctionDecompiler.IsLocalFunctionMethod(module, methodHandle))
return settings.LocalFunctions;
if (settings.AnonymousMethods && methodHandle.HasGeneratedName(metadata) && methodHandle.IsCompilerGenerated(metadata))
return true;
if (settings.AsyncAwait && AsyncAwaitDecompiler.IsCompilerGeneratedMainMethod(module, (MethodDefinitionHandle)member))
if (settings.AsyncAwait && AsyncAwaitDecompiler.IsCompilerGeneratedMainMethod(module, methodHandle))
return true;
return false;
case HandleKind.TypeDefinition:
@ -259,6 +261,8 @@ namespace ICSharpCode.Decompiler.CSharp @@ -259,6 +261,8 @@ namespace ICSharpCode.Decompiler.CSharp
var type = metadata.GetTypeDefinition(typeHandle);
name = metadata.GetString(type.Name);
if (!type.GetDeclaringType().IsNil) {
if (LocalFunctionDecompiler.IsLocalFunctionDisplayClass(module, typeHandle))
return settings.LocalFunctions;
if (settings.AnonymousMethods && IsClosureType(type, metadata))
return true;
if (settings.YieldReturn && YieldReturnDecompiler.IsCompilerGeneratorEnumerator(typeHandle, metadata))
@ -536,25 +540,70 @@ namespace ICSharpCode.Decompiler.CSharp @@ -536,25 +540,70 @@ namespace ICSharpCode.Decompiler.CSharp
case ILOpCode.Stfld:
// async and yield fsms:
var token = MetadataTokenHelpers.EntityHandleOrNil(blob.ReadInt32());
if (!token.IsNil && token.Kind == HandleKind.FieldDefinition) {
var fsmField = module.Metadata.GetFieldDefinition((FieldDefinitionHandle)token);
var fsmTypeDef = fsmField.GetDeclaringType();
if (!fsmTypeDef.IsNil) {
var fsmType = module.Metadata.GetTypeDefinition(fsmTypeDef);
// Must be a nested type of the containing type.
if (fsmType.GetDeclaringType() != declaringType)
break;
if (!processedNestedTypes.Add(fsmTypeDef))
break;
if (YieldReturnDecompiler.IsCompilerGeneratorEnumerator(fsmTypeDef, module.Metadata)
|| AsyncAwaitDecompiler.IsCompilerGeneratedStateMachine(fsmTypeDef, module.Metadata)) {
foreach (var h in fsmType.GetMethods()) {
if (module.MethodSemanticsLookup.GetSemantics(h).Item2 != 0)
if (token.IsNil)
continue;
TypeDefinitionHandle fsmTypeDef;
switch (token.Kind) {
case HandleKind.FieldDefinition:
var fsmField = module.Metadata.GetFieldDefinition((FieldDefinitionHandle)token);
fsmTypeDef = fsmField.GetDeclaringType();
break;
case HandleKind.MemberReference:
var memberRef = module.Metadata.GetMemberReference((MemberReferenceHandle)token);
if (memberRef.GetKind() != MemberReferenceKind.Field)
continue;
switch (memberRef.Parent.Kind) {
case HandleKind.TypeReference:
// This should never happen in normal code, because we are looking at nested types
// If it's not a nested type, it can't be a reference to the statem machine anyway, and
// those should be either TypeDef or TypeSpec.
continue;
case HandleKind.TypeDefinition:
fsmTypeDef = (TypeDefinitionHandle)memberRef.Parent;
break;
case HandleKind.TypeSpecification:
var ts = module.Metadata.GetTypeSpecification((TypeSpecificationHandle)memberRef.Parent);
if (ts.Signature.IsNil)
continue;
var otherMethod = module.Metadata.GetMethodDefinition(h);
if (!otherMethod.GetCustomAttributes().HasKnownAttribute(module.Metadata, KnownAttribute.DebuggerHidden)) {
connectedMethods.Enqueue(h);
}
// Do a quick scan using BlobReader
var signature = module.Metadata.GetBlobReader(ts.Signature);
// When dealing with FSM implementations, we can safely assume that if it's a type spec,
// it must be a generic type instance.
if (signature.ReadByte() != (byte)SignatureTypeCode.GenericTypeInstance)
continue;
// Skip over the rawTypeKind: value type or class
var rawTypeKind = signature.ReadCompressedInteger();
if (rawTypeKind < 17 || rawTypeKind > 18)
continue;
// Only read the generic type, ignore the type arguments
var genericType = signature.ReadTypeHandle();
// Again, we assume this is a type def, because we are only looking at nested types
if (genericType.Kind != HandleKind.TypeDefinition)
continue;
fsmTypeDef = (TypeDefinitionHandle)genericType;
break;
default:
continue;
}
break;
default:
continue;
}
if (!fsmTypeDef.IsNil) {
var fsmType = module.Metadata.GetTypeDefinition(fsmTypeDef);
// Must be a nested type of the containing type.
if (fsmType.GetDeclaringType() != declaringType)
break;
if (!processedNestedTypes.Add(fsmTypeDef))
break;
if (YieldReturnDecompiler.IsCompilerGeneratorEnumerator(fsmTypeDef, module.Metadata)
|| AsyncAwaitDecompiler.IsCompilerGeneratedStateMachine(fsmTypeDef, module.Metadata)) {
foreach (var h in fsmType.GetMethods()) {
if (module.MethodSemanticsLookup.GetSemantics(h).Item2 != 0)
continue;
var otherMethod = module.Metadata.GetMethodDefinition(h);
if (!otherMethod.GetCustomAttributes().HasKnownAttribute(module.Metadata, KnownAttribute.DebuggerHidden)) {
connectedMethods.Enqueue(h);
}
}
}
@ -564,7 +613,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -564,7 +613,7 @@ namespace ICSharpCode.Decompiler.CSharp
// deal with ldftn instructions, i.e., lambdas
token = MetadataTokenHelpers.EntityHandleOrNil(blob.ReadInt32());
if (!token.IsNil && token.Kind == HandleKind.MethodDefinition) {
if (((MethodDefinitionHandle)token).IsCompilerGenerated(module.Metadata))
if (((MethodDefinitionHandle)token).IsCompilerGeneratedOrIsInCompilerGeneratedClass(module.Metadata))
connectedMethods.Enqueue((MethodDefinitionHandle)token);
}
break;
@ -1025,6 +1074,14 @@ namespace ICSharpCode.Decompiler.CSharp @@ -1025,6 +1074,14 @@ namespace ICSharpCode.Decompiler.CSharp
}
FixParameterNames(methodDecl);
var methodDefinition = metadata.GetMethodDefinition((MethodDefinitionHandle)method.MetadataToken);
if (!settings.LocalFunctions && LocalFunctionDecompiler.IsLocalFunctionMethod(method.ParentModule.PEFile, (MethodDefinitionHandle)method.MetadataToken)) {
// if local functions are not active and we're dealing with a local function,
// reduce the visibility of the method to private,
// otherwise this leads to compile errors because the display classes have lesser accessibility.
// Note: removing and then adding the static modifier again is necessary to set the private modifier before all other modifiers.
methodDecl.Modifiers &= ~(Modifiers.Internal | Modifiers.Static);
methodDecl.Modifiers |= Modifiers.Private | (method.IsStatic ? Modifiers.Static : 0);
}
if (methodDefinition.HasBody()) {
DecompileBody(method, methodDecl, decompileRun, decompilationContext);
} else if (!method.IsAbstract && method.DeclaringType.Kind != TypeKind.Interface) {

24
ICSharpCode.Decompiler/CSharp/CallBuilder.cs

@ -383,6 +383,28 @@ namespace ICSharpCode.Decompiler.CSharp @@ -383,6 +383,28 @@ namespace ICSharpCode.Decompiler.CSharp
isExtensionMethodInvocation: method.IsExtensionMethod, isExpandedForm: argumentList.IsExpandedForm));
}
public ExpressionWithResolveResult BuildDictionaryInitializerExpression(OpCode callOpCode, IMethod method,
InitializedObjectResolveResult target, IReadOnlyList<ILInstruction> indices, ILInstruction value = null)
{
ExpectedTargetDetails expectedTargetDetails = new ExpectedTargetDetails { CallOpCode = callOpCode };
var callArguments = new List<ILInstruction>();
callArguments.Add(new LdNull());
callArguments.AddRange(indices);
callArguments.Add(value ?? new Nop());
var argumentList = BuildArgumentList(expectedTargetDetails, target, method, 1, callArguments, null);
var unused = new IdentifierExpression("initializedObject").WithRR(target).WithoutILInstruction();
var assignment = HandleAccessorCall(expectedTargetDetails, method, unused,
argumentList.Arguments.ToList(), argumentList.ArgumentNames);
if (value != null)
return assignment;
return new ExpressionWithResolveResult(((AssignmentExpression)assignment).Left.Detach());
}
private bool IsInterpolatedStringCreation(IMethod method)
{
return method.IsStatic && (
@ -1035,7 +1057,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -1035,7 +1057,7 @@ namespace ICSharpCode.Decompiler.CSharp
TranslatedExpression expr;
if (arguments.Count != 0) {
expr = new IndexerExpression(target.Expression, arguments.Select(a => a.Expression))
expr = new IndexerExpression(target.ResolveResult is InitializedObjectResolveResult ? null : target.Expression, arguments.Select(a => a.Expression))
.WithoutILInstruction().WithRR(rr);
} else if (requireTarget) {
expr = new MemberReferenceExpression(target.Expression, method.AccessorOwner.Name)

109
ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

@ -646,9 +646,9 @@ namespace ICSharpCode.Decompiler.CSharp @@ -646,9 +646,9 @@ namespace ICSharpCode.Decompiler.CSharp
} else {
targetType = compilation.FindType(inst.InputType.ToKnownTypeCode(leftUType.GetSign()));
}
}
if (inst.IsLifted) {
targetType = NullableType.Create(compilation, targetType);
if (inst.IsLifted) {
targetType = NullableType.Create(compilation, targetType);
}
}
if (targetType.Equals(left.Type)) {
right = right.ConvertTo(targetType, this);
@ -1883,10 +1883,6 @@ namespace ICSharpCode.Decompiler.CSharp @@ -1883,10 +1883,6 @@ namespace ICSharpCode.Decompiler.CSharp
// isinst followed by unbox.any of the same type is used for as-casts to generic types
return arg.WithILInstruction(inst);
}
if (arg.Type.IsReferenceType != true) {
// ensure we treat the input as a reference type
arg = arg.ConvertTo(compilation.FindType(KnownTypeCode.Object), this);
}
IType targetType = inst.Type;
if (targetType.Kind == TypeKind.TypeParameter) {
@ -1898,6 +1894,11 @@ namespace ICSharpCode.Decompiler.CSharp @@ -1898,6 +1894,11 @@ namespace ICSharpCode.Decompiler.CSharp
arg = arg.ConvertTo(((ITypeParameter)targetType).EffectiveBaseClass, this);
}
}
else {
// Before unboxing arg must be a object
arg = arg.ConvertTo(compilation.FindType(KnownTypeCode.Object), this);
}
return new CastExpression(ConvertType(targetType), arg.Expression)
.WithILInstruction(inst)
.WithRR(new ConversionResolveResult(targetType, arg.ResolveResult, Conversion.UnboxingConversion));
@ -2018,10 +2019,13 @@ namespace ICSharpCode.Decompiler.CSharp @@ -2018,10 +2019,13 @@ namespace ICSharpCode.Decompiler.CSharp
{
var stloc = block.Instructions.FirstOrDefault() as StLoc;
var final = block.FinalInstruction as LdLoc;
if (stloc == null || final == null || stloc.Variable != final.Variable || stloc.Variable.Kind != VariableKind.InitializerTarget)
// Check basic structure of block
if (stloc == null || final == null || stloc.Variable != final.Variable
|| stloc.Variable.Kind != VariableKind.InitializerTarget)
throw new ArgumentException("given Block is invalid!");
InitializedObjectResolveResult initObjRR;
TranslatedExpression expr;
// Detect type of initializer
switch (stloc.Value) {
case NewObj newObjInst:
initObjRR = new InitializedObjectResolveResult(newObjInst.Method.DeclaringType);
@ -2040,18 +2044,24 @@ namespace ICSharpCode.Decompiler.CSharp @@ -2040,18 +2044,24 @@ namespace ICSharpCode.Decompiler.CSharp
default:
throw new ArgumentException("given Block is invalid!");
}
var elementsStack = new Stack<List<Expression>>();
var elements = new List<Expression>(block.Instructions.Count);
// Build initializer expression
var elementsStack = new Stack<List<TranslatedExpression>>();
var elements = new List<TranslatedExpression>(block.Instructions.Count);
elementsStack.Push(elements);
List<IL.Transforms.AccessPathElement> currentPath = null;
var indexVariables = new Dictionary<ILVariable, ILInstruction>();
foreach (var inst in block.Instructions.Skip(1)) {
// Collect indexer variables (for C# 6 dictionary initializers)
if (inst is StLoc indexStore) {
indexVariables.Add(indexStore.Variable, indexStore.Value);
continue;
}
// Get current path
var info = IL.Transforms.AccessPathElement.GetAccessPath(inst, initObjRR.Type, settings: settings);
// This should not happen, because the IL transform should not create invalid access paths,
// but we leave it here as sanity check.
if (info.Kind == IL.Transforms.AccessPathKind.Invalid) continue;
// Calculate "difference" to previous path
if (currentPath == null) {
currentPath = info.Path;
} else {
@ -2063,25 +2073,38 @@ namespace ICSharpCode.Decompiler.CSharp @@ -2063,25 +2073,38 @@ namespace ICSharpCode.Decompiler.CSharp
var methodElement = currentPath[elementsStack.Count - 1];
var pathElement = currentPath[elementsStack.Count - 2];
var values = elementsStack.Pop();
elementsStack.Peek().Add(MakeInitializerAssignment(methodElement.Member, pathElement, values, indexVariables));
elementsStack.Peek().Add(MakeInitializerAssignment(initObjRR, methodElement, pathElement, values, indexVariables));
}
currentPath = info.Path;
}
// Fill the stack with empty expression lists
while (elementsStack.Count < currentPath.Count)
elementsStack.Push(new List<Expression>());
elementsStack.Push(new List<TranslatedExpression>());
var lastElement = currentPath.Last();
var memberRR = new MemberResolveResult(initObjRR, lastElement.Member);
switch (info.Kind) {
case IL.Transforms.AccessPathKind.Adder:
elementsStack.Peek().Add(new CallBuilder(this, typeSystem, settings).BuildCollectionInitializerExpression(lastElement.OpCode, (IMethod)lastElement.Member, initObjRR, info.Values));
Debug.Assert(lastElement.Member is IMethod);
elementsStack.Peek().Add(
new CallBuilder(this, typeSystem, settings)
.BuildCollectionInitializerExpression(lastElement.OpCode, (IMethod)lastElement.Member, initObjRR, info.Values)
.WithILInstruction(inst)
);
break;
case IL.Transforms.AccessPathKind.Setter:
Debug.Assert(lastElement.Member is IProperty || lastElement.Member is IField);
if (lastElement.Indices?.Length > 0) {
var indexer = new IndexerExpression(null, lastElement.Indices.SelectArray(i => TranslateInitializerIndexerValue(i, indexVariables)))
.WithILInstruction(inst).WithRR(memberRR);
elementsStack.Peek().Add(Assignment(indexer, Translate(info.Values.Single(), typeHint: indexer.Type)));
var property = (IProperty)lastElement.Member;
Debug.Assert(property.IsIndexer);
elementsStack.Peek().Add(
new CallBuilder(this, typeSystem, settings)
.BuildDictionaryInitializerExpression(lastElement.OpCode, property.Setter, initObjRR, GetIndices(lastElement.Indices, indexVariables).ToList(), info.Values.Single())
.WithILInstruction(inst)
);
} else {
var assignment = new NamedExpression(lastElement.Member.Name, Translate(info.Values.Single(), typeHint: memberRR.Type))
var value = Translate(info.Values.Single(), typeHint: memberRR.Type)
.ConvertTo(memberRR.Type, this, allowImplicitConversion: true);
var assignment = new NamedExpression(lastElement.Member.Name, value)
.WithILInstruction(inst).WithRR(memberRR);
elementsStack.Peek().Add(assignment);
}
@ -2092,34 +2115,56 @@ namespace ICSharpCode.Decompiler.CSharp @@ -2092,34 +2115,56 @@ namespace ICSharpCode.Decompiler.CSharp
var methodElement = currentPath[elementsStack.Count - 1];
var pathElement = currentPath[elementsStack.Count - 2];
var values = elementsStack.Pop();
elementsStack.Peek().Add(MakeInitializerAssignment(methodElement.Member, pathElement, values, indexVariables));
elementsStack.Peek().Add(
MakeInitializerAssignment(initObjRR, methodElement, pathElement, values, indexVariables)
);
}
var oce = (ObjectCreateExpression)expr.Expression;
oce.Initializer = new ArrayInitializerExpression(elements);
oce.Initializer = new ArrayInitializerExpression(elements.SelectArray(e => e.Expression));
return expr.WithILInstruction(block);
}
Expression TranslateInitializerIndexerValue(ILInstruction inst, Dictionary<ILVariable, ILInstruction> indexVariables)
IEnumerable<ILInstruction> GetIndices(IEnumerable<ILInstruction> indices, Dictionary<ILVariable, ILInstruction> indexVariables)
{
if (inst is LdLoc ld && indexVariables.TryGetValue(ld.Variable, out var newInst)) {
inst = newInst;
foreach (var inst in indices) {
if (inst is LdLoc ld && indexVariables.TryGetValue(ld.Variable, out var newInst))
yield return newInst;
else
yield return inst;
}
return Translate(inst).Expression;
}
Expression MakeInitializerAssignment(IMember method, IL.Transforms.AccessPathElement member, List<Expression> values, Dictionary<ILVariable, ILInstruction> indexVariables)
TranslatedExpression MakeInitializerAssignment(InitializedObjectResolveResult rr, IL.Transforms.AccessPathElement memberPath,
IL.Transforms.AccessPathElement valuePath, List<TranslatedExpression> values,
Dictionary<ILVariable, ILInstruction> indexVariables)
{
Expression value;
if (values.Count == 1 && !(values[0] is AssignmentExpression || values[0] is NamedExpression) && !(method.SymbolKind == SymbolKind.Method && method.Name == "Add")) {
TranslatedExpression value;
if (memberPath.Member is IMethod method && method.Name == "Add") {
value = new ArrayInitializerExpression(values.Select(v => v.Expression))
.WithRR(new ResolveResult(SpecialType.UnknownType))
.WithoutILInstruction();
} else if (values.Count == 1 && !(values[0].Expression is AssignmentExpression || values[0].Expression is NamedExpression)) {
value = values[0];
} else {
value = new ArrayInitializerExpression(values);
}
if (member.Indices?.Length > 0) {
var index = new IndexerExpression(null, member.Indices.SelectArray(i => Translate(i is LdLoc ld ? indexVariables[ld.Variable] : i).Expression));
return new AssignmentExpression(index, value);
value = new ArrayInitializerExpression(values.Select(v => v.Expression))
.WithRR(new ResolveResult(SpecialType.UnknownType))
.WithoutILInstruction();
}
if (valuePath.Indices?.Length > 0) {
Expression index;
if (memberPath.Member is IProperty property) {
index = new CallBuilder(this, typeSystem, settings)
.BuildDictionaryInitializerExpression(valuePath.OpCode, property.Setter, rr, GetIndices(valuePath.Indices, indexVariables).ToList());
} else {
index = new IndexerExpression(null, GetIndices(valuePath.Indices, indexVariables).Select(i => Translate(i).Expression));
}
return new AssignmentExpression(index, value)
.WithRR(new MemberResolveResult(rr, memberPath.Member))
.WithoutILInstruction();
} else {
return new NamedExpression(member.Member.Name, value);
return new NamedExpression(valuePath.Member.Name, value)
.WithRR(new MemberResolveResult(rr, memberPath.Member))
.WithoutILInstruction();
}
}

62
ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpAmbience.cs

@ -17,8 +17,12 @@ @@ -17,8 +17,12 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using ICSharpCode.Decompiler.CSharp.Syntax;
using ICSharpCode.Decompiler.Output;
using ICSharpCode.Decompiler.TypeSystem;
namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
@ -37,7 +41,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -37,7 +41,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
throw new ArgumentNullException("symbol");
StringWriter writer = new StringWriter();
ConvertSymbol(symbol, new TextWriterTokenWriter(writer), FormattingOptionsFactory.CreateMono ());
ConvertSymbol(symbol, new TextWriterTokenWriter(writer), FormattingOptionsFactory.CreateEmpty());
return writer.ToString();
}
@ -87,7 +91,9 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -87,7 +91,9 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
}
}
if ((ConversionFlags & ConversionFlags.ShowReturnType) == ConversionFlags.ShowReturnType) {
if ((ConversionFlags & ConversionFlags.PlaceReturnTypeAfterParameterList) != ConversionFlags.PlaceReturnTypeAfterParameterList
&& (ConversionFlags & ConversionFlags.ShowReturnType) == ConversionFlags.ShowReturnType)
{
var rt = node.GetChildByRole(Roles.Type);
if (!rt.IsNull) {
rt.AcceptVisitor(new CSharpOutputVisitor(writer, formattingPolicy));
@ -106,6 +112,12 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -106,6 +112,12 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
writer.WriteToken(symbol.SymbolKind == SymbolKind.Indexer ? Roles.LBracket : Roles.LPar, symbol.SymbolKind == SymbolKind.Indexer ? "[" : "(");
bool first = true;
foreach (var param in node.GetChildrenByRole(Roles.Parameter)) {
if ((ConversionFlags & ConversionFlags.ShowParameterModifiers) == 0) {
param.ParameterModifier = ParameterModifier.None;
}
if ((ConversionFlags & ConversionFlags.ShowParameterDefaultValues) == 0) {
param.DefaultExpression.Detach();
}
if (first) {
first = false;
} else {
@ -116,7 +128,19 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -116,7 +128,19 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
}
writer.WriteToken(symbol.SymbolKind == SymbolKind.Indexer ? Roles.RBracket : Roles.RPar, symbol.SymbolKind == SymbolKind.Indexer ? "]" : ")");
}
if ((ConversionFlags & ConversionFlags.PlaceReturnTypeAfterParameterList) == ConversionFlags.PlaceReturnTypeAfterParameterList
&& (ConversionFlags & ConversionFlags.ShowReturnType) == ConversionFlags.ShowReturnType)
{
var rt = node.GetChildByRole(Roles.Type);
if (!rt.IsNull) {
writer.Space();
writer.WriteToken(Roles.Colon, ":");
writer.Space();
rt.AcceptVisitor(new CSharpOutputVisitor(writer, formattingPolicy));
}
}
if ((ConversionFlags & ConversionFlags.ShowBody) == ConversionFlags.ShowBody && !(node is TypeDeclaration)) {
IProperty property = symbol as IProperty;
if (property != null) {
@ -171,7 +195,9 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -171,7 +195,9 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
{
TypeSystemAstBuilder astBuilder = CreateAstBuilder();
EntityDeclaration node = astBuilder.ConvertEntity(typeDef);
if (typeDef.DeclaringTypeDefinition != null) {
if (typeDef.DeclaringTypeDefinition != null &&
((ConversionFlags & ConversionFlags.ShowDeclaringType) == ConversionFlags.ShowDeclaringType ||
(ConversionFlags & ConversionFlags.UseFullyQualifiedEntityNames) == ConversionFlags.UseFullyQualifiedEntityNames)) {
WriteTypeDeclarationName(typeDef.DeclaringTypeDefinition, writer, formattingPolicy);
writer.WriteToken(Roles.Dot, ".");
} else if ((ConversionFlags & ConversionFlags.UseFullyQualifiedEntityNames) == ConversionFlags.UseFullyQualifiedEntityNames) {
@ -181,12 +207,9 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -181,12 +207,9 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
}
}
writer.WriteIdentifier(node.NameToken);
if ((ConversionFlags & ConversionFlags.ShowTypeParameterList) == ConversionFlags.ShowTypeParameterList) {
var outputVisitor = new CSharpOutputVisitor(writer, formattingPolicy);
outputVisitor.WriteTypeParameters(node.GetChildrenByRole(Roles.TypeParameter));
}
WriteTypeParameters(node, writer, formattingPolicy);
}
void WriteMemberDeclarationName(IMember member, TokenWriter writer, CSharpFormattingOptions formattingPolicy)
{
TypeSystemAstBuilder astBuilder = CreateAstBuilder();
@ -237,12 +260,27 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -237,12 +260,27 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
writer.WriteIdentifier(Identifier.Create(member.Name));
break;
}
if ((ConversionFlags & ConversionFlags.ShowTypeParameterList) == ConversionFlags.ShowTypeParameterList && member.SymbolKind == SymbolKind.Method) {
WriteTypeParameters(node, writer, formattingPolicy);
}
void WriteTypeParameters(EntityDeclaration node, TokenWriter writer, CSharpFormattingOptions formattingPolicy)
{
if ((ConversionFlags & ConversionFlags.ShowTypeParameterList) == ConversionFlags.ShowTypeParameterList) {
var outputVisitor = new CSharpOutputVisitor(writer, formattingPolicy);
outputVisitor.WriteTypeParameters(node.GetChildrenByRole(Roles.TypeParameter));
IEnumerable<TypeParameterDeclaration> typeParameters = node.GetChildrenByRole(Roles.TypeParameter);
if ((ConversionFlags & ConversionFlags.ShowTypeParameterVarianceModifier) == 0) {
typeParameters = typeParameters.Select(RemoveVarianceModifier);
}
outputVisitor.WriteTypeParameters(typeParameters);
}
TypeParameterDeclaration RemoveVarianceModifier(TypeParameterDeclaration decl)
{
decl.Variance = VarianceModifier.Invariant;
return decl;
}
}
void PrintModifiers(Modifiers modifiers, TokenWriter writer)
{
foreach (var m in CSharpModifierToken.AllModifiers) {

2
ICSharpCode.Decompiler/CSharp/StatementBuilder.cs

@ -928,7 +928,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -928,7 +928,7 @@ namespace ICSharpCode.Decompiler.CSharp
}
string label;
if (endContainerLabels.TryGetValue(container, out label)) {
if (isLoop) {
if (isLoop && !(blockStatement.LastOrDefault() is ContinueStatement)) {
blockStatement.Add(new ContinueStatement());
}
blockStatement.Add(new LabelStatement { Label = label });

12
ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs

@ -1016,11 +1016,13 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -1016,11 +1016,13 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
case TypeKind.Struct:
classType = ClassType.Struct;
modifiers &= ~Modifiers.Sealed;
if (typeDefinition.IsReadOnly) {
modifiers |= Modifiers.Readonly;
}
if (typeDefinition.IsByRefLike) {
modifiers |= Modifiers.Ref;
if (ShowModifiers) {
if (typeDefinition.IsReadOnly) {
modifiers |= Modifiers.Readonly;
}
if (typeDefinition.IsByRefLike) {
modifiers |= Modifiers.Ref;
}
}
break;
case TypeKind.Enum:

41
ICSharpCode.Decompiler/CSharp/Transforms/PatternStatementTransform.cs

@ -121,7 +121,12 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -121,7 +121,12 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
{
return TransformDestructor(methodDeclaration) ?? base.VisitMethodDeclaration(methodDeclaration);
}
public override AstNode VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration)
{
return TransformDestructorBody(destructorDeclaration) ?? base.VisitDestructorDeclaration(destructorDeclaration);
}
public override AstNode VisitTryCatchStatement(TryCatchStatement tryCatchStatement)
{
return TransformTryCatchFinally(tryCatchStatement) ?? base.VisitTryCatchStatement(tryCatchStatement);
@ -805,23 +810,25 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -805,23 +810,25 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
return ed;
}
#endregion
#region Destructor
static readonly BlockStatement destructorBodyPattern = new BlockStatement {
new TryCatchStatement {
TryBlock = new AnyNode("body"),
FinallyBlock = new BlockStatement {
new InvocationExpression(new MemberReferenceExpression(new BaseReferenceExpression(), "Finalize"))
}
}
};
static readonly MethodDeclaration destructorPattern = new MethodDeclaration {
Attributes = { new Repeat(new AnyNode()) },
Modifiers = Modifiers.Any,
ReturnType = new PrimitiveType("void"),
Name = "Finalize",
Body = new BlockStatement {
new TryCatchStatement {
TryBlock = new AnyNode("body"),
FinallyBlock = new BlockStatement {
new InvocationExpression(new MemberReferenceExpression(new BaseReferenceExpression(), "Finalize"))
}
}
}
Body = destructorBodyPattern
};
DestructorDeclaration TransformDestructor(MethodDeclaration methodDef)
{
Match m = destructorPattern.Match(methodDef);
@ -837,8 +844,18 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -837,8 +844,18 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
}
return null;
}
DestructorDeclaration TransformDestructorBody(DestructorDeclaration dtorDef)
{
Match m = destructorBodyPattern.Match(dtorDef.Body);
if (m.Success) {
dtorDef.Body = m.Get<BlockStatement>("body").Single().Detach();
return dtorDef;
}
return null;
}
#endregion
#region Try-Catch-Finally
static readonly TryCatchStatement tryCatchFinallyPattern = new TryCatchStatement {
TryBlock = new BlockStatement {

9
ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs

@ -69,7 +69,14 @@ namespace ICSharpCode.Decompiler.CSharp @@ -69,7 +69,14 @@ namespace ICSharpCode.Decompiler.CSharp
public IType Type {
get { return ResolveResult.Type; }
}
internal ExpressionWithResolveResult(Expression expression)
{
Debug.Assert(expression != null);
this.Expression = expression;
this.ResolveResult = expression.Annotation<ResolveResult>() ?? ErrorResolveResult.UnknownError;
}
internal ExpressionWithResolveResult(Expression expression, ResolveResult resolveResult)
{
Debug.Assert(expression != null && resolveResult != null);

9
ICSharpCode.Decompiler/DebugInfo/IDebugInfoProvider.cs

@ -7,7 +7,14 @@ namespace ICSharpCode.Decompiler.DebugInfo @@ -7,7 +7,14 @@ namespace ICSharpCode.Decompiler.DebugInfo
{
public struct Variable
{
public string Name { get; set; }
public Variable(int index, string name)
{
Index = index;
Name = name;
}
public int Index { get; }
public string Name { get; }
}
public interface IDebugInfoProvider

20
ICSharpCode.Decompiler/DecompilerSettings.cs

@ -81,6 +81,7 @@ namespace ICSharpCode.Decompiler @@ -81,6 +81,7 @@ namespace ICSharpCode.Decompiler
tupleTypes = false;
tupleConversions = false;
discards = false;
localFunctions = false;
}
if (languageVersion < CSharp.LanguageVersion.CSharp7_2) {
introduceReadonlyAndInModifiers = false;
@ -101,7 +102,7 @@ namespace ICSharpCode.Decompiler @@ -101,7 +102,7 @@ namespace ICSharpCode.Decompiler
if (introduceRefModifiersOnStructs || introduceReadonlyAndInModifiers || nonTrailingNamedArguments)
return CSharp.LanguageVersion.CSharp7_2;
// C# 7.1 missing
if (outVariables || tupleTypes || tupleConversions || discards)
if (outVariables || tupleTypes || tupleConversions || discards || localFunctions)
return CSharp.LanguageVersion.CSharp7;
if (awaitInCatchFinally || useExpressionBodyForCalculatedGetterOnlyProperties || nullPropagation
|| stringInterpolation || dictionaryInitializers || extensionMethodsInCollectionInitializers)
@ -790,6 +791,23 @@ namespace ICSharpCode.Decompiler @@ -790,6 +791,23 @@ namespace ICSharpCode.Decompiler
}
}
bool localFunctions = false;
/// <summary>
/// Gets/Sets whether C# 7.0 local functions should be used.
/// Note: this language feature is currenly not implemented and this setting is always false.
/// </summary>
public bool LocalFunctions {
get { return localFunctions; }
set {
if (localFunctions != value) {
throw new NotImplementedException("C# 7.0 local functions are not implemented!");
//localFunctions = value;
//OnPropertyChanged();
}
}
}
#region Options to aid VB decompilation
bool assumeArrayLengthFitsIntoInt32 = true;

3
ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj

@ -265,6 +265,7 @@ @@ -265,6 +265,7 @@
<Compile Include="CSharp\Transforms\AddXmlDocumentationTransform.cs" />
<Compile Include="DecompileRun.cs" />
<Compile Include="Disassembler\ILParser.cs" />
<Compile Include="IL\Transforms\LocalFunctionDecompiler.cs" />
<Compile Include="IL\Transforms\UserDefinedLogicTransform.cs" />
<Compile Include="Metadata\AssemblyReferences.cs" />
<Compile Include="Metadata\CodeMappingInfo.cs" />
@ -485,7 +486,7 @@ @@ -485,7 +486,7 @@
<Compile Include="TypeSystem\ComHelper.cs" />
<Compile Include="TypeSystem\DecompilerTypeSystem.cs" />
<Compile Include="TypeSystem\FullTypeName.cs" />
<Compile Include="TypeSystem\IAmbience.cs" />
<Compile Include="Output\IAmbience.cs" />
<Compile Include="TypeSystem\IAssembly.cs" />
<Compile Include="TypeSystem\IAttribute.cs" />
<Compile Include="TypeSystem\ICodeContext.cs" />

2
ICSharpCode.Decompiler/IL/ControlFlow/YieldReturnDecompiler.cs

@ -133,7 +133,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -133,7 +133,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
context.Step("Replacing body with MoveNext() body", function);
function.IsIterator = true;
function.StateMachineCompiledWithMono = true;
function.StateMachineCompiledWithMono = isCompiledWithMono;
function.Body = newBody;
// register any locals used in newBody
function.Variables.AddRange(newBody.Descendants.OfType<IInstructionWithVariableOperand>().Select(inst => inst.Variable).Distinct());

14
ICSharpCode.Decompiler/IL/ILAstWritingOptions.cs

@ -26,6 +26,7 @@ namespace ICSharpCode.Decompiler.IL @@ -26,6 +26,7 @@ namespace ICSharpCode.Decompiler.IL
private bool useLogicOperationSugar;
private bool useFieldSugar;
private bool showILRanges;
private bool showChildIndexInBlock;
/// <summary>
/// Sugar for logic.not/and/or.
@ -66,6 +67,19 @@ namespace ICSharpCode.Decompiler.IL @@ -66,6 +67,19 @@ namespace ICSharpCode.Decompiler.IL
}
}
/// <summary>
/// Show the child index of the instruction in ILAst output.
/// </summary>
public bool ShowChildIndexInBlock {
get { return showChildIndexInBlock; }
set {
if (showChildIndexInBlock != value) {
showChildIndexInBlock = value;
OnPropertyChanged();
}
}
}
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
OnPropertyChanged(new PropertyChangedEventArgs(propertyName));

5
ICSharpCode.Decompiler/IL/Instructions/Block.cs

@ -161,7 +161,12 @@ namespace ICSharpCode.Decompiler.IL @@ -161,7 +161,12 @@ namespace ICSharpCode.Decompiler.IL
output.MarkFoldStart("{...}");
output.WriteLine("{");
output.Indent();
int index = 0;
foreach (var inst in Instructions) {
if (options.ShowChildIndexInBlock) {
output.Write("[" + index + "] ");
index++;
}
inst.WriteTo(output, options);
output.WriteLine();
}

113
ICSharpCode.Decompiler/IL/Transforms/LocalFunctionDecompiler.cs

@ -0,0 +1,113 @@ @@ -0,0 +1,113 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Reflection;
using System.Reflection.Metadata;
using System.Text;
using System.Text.RegularExpressions;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.Util;
namespace ICSharpCode.Decompiler.IL.Transforms
{
class LocalFunctionDecompiler : IILTransform
{
public void Run(ILFunction function, ILTransformContext context)
{
throw new NotImplementedException();
}
public static bool IsLocalFunctionMethod(PEFile module, MethodDefinitionHandle methodHandle)
{
var metadata = module.Metadata;
var method = metadata.GetMethodDefinition(methodHandle);
if ((method.Attributes & MethodAttributes.Assembly) == 0 || !method.IsCompilerGenerated(metadata))
return false;
if (!ParseLocalFunctionName(metadata.GetString(method.Name), out _, out _))
return false;
return true;
}
public static bool IsLocalFunctionDisplayClass(PEFile module, TypeDefinitionHandle typeHandle)
{
var metadata = module.Metadata;
var type = metadata.GetTypeDefinition(typeHandle);
if ((type.Attributes & TypeAttributes.NestedPrivate) == 0)
return false;
if (!type.HasGeneratedName(metadata))
return false;
var declaringTypeHandle = type.GetDeclaringType();
var declaringType = metadata.GetTypeDefinition(declaringTypeHandle);
foreach (var method in declaringType.GetMethods()) {
if (!IsLocalFunctionMethod(module, method))
continue;
var md = metadata.GetMethodDefinition(method);
if (md.DecodeSignature(new FindTypeDecoder(typeHandle), default).ParameterTypes.Any())
return true;
}
return false;
}
/// <summary>
/// Newer Roslyn versions use the format "&ltcallerName&gtg__functionName|x_y"
/// Older versions use "&ltcallerName&gtg__functionNamex_y"
/// </summary>
static readonly Regex functionNameRegex = new Regex(@"^<(.*)>g__(.*)\|{0,1}\d+_\d+$", RegexOptions.Compiled);
static bool ParseLocalFunctionName(string name, out string callerName, out string functionName)
{
callerName = null;
functionName = null;
if (string.IsNullOrWhiteSpace(name))
return false;
var match = functionNameRegex.Match(name);
callerName = match.Groups[1].Value;
functionName = match.Groups[2].Value;
return match.Success;
}
struct FindTypeDecoder : ISignatureTypeProvider<bool, Unit>
{
TypeDefinitionHandle handle;
public FindTypeDecoder(TypeDefinitionHandle handle)
{
this.handle = handle;
}
public bool GetArrayType(bool elementType, ArrayShape shape) => elementType;
public bool GetByReferenceType(bool elementType) => elementType;
public bool GetFunctionPointerType(MethodSignature<bool> signature) => false;
public bool GetGenericInstantiation(bool genericType, ImmutableArray<bool> typeArguments) => genericType;
public bool GetGenericMethodParameter(Unit genericContext, int index) => false;
public bool GetGenericTypeParameter(Unit genericContext, int index) => false;
public bool GetModifiedType(bool modifier, bool unmodifiedType, bool isRequired) => unmodifiedType;
public bool GetPinnedType(bool elementType) => elementType;
public bool GetPointerType(bool elementType) => elementType;
public bool GetPrimitiveType(PrimitiveTypeCode typeCode) => false;
public bool GetSZArrayType(bool elementType) => false;
public bool GetTypeFromDefinition(MetadataReader reader, TypeDefinitionHandle handle, byte rawTypeKind)
{
return this.handle == handle;
}
public bool GetTypeFromReference(MetadataReader reader, TypeReferenceHandle handle, byte rawTypeKind)
{
return false;
}
public bool GetTypeFromSpecification(MetadataReader reader, Unit genericContext, TypeSpecificationHandle handle, byte rawTypeKind)
{
return reader.GetTypeSpecification(handle).DecodeSignature(this, genericContext);
}
}
}
}

51
ICSharpCode.Decompiler/IL/Transforms/SplitVariables.cs

@ -104,26 +104,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -104,26 +104,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
case Await await:
// GetAwaiter() may write to the struct, but shouldn't store the address for later use
return AddressUse.Immediate;
case Call call:
// Address is passed to method.
// We'll assume the method only uses the address locally,
// unless we can see an address being returned from the method:
if (call.Method.ReturnType.IsByRefLike) {
return AddressUse.Unknown;
}
foreach (var p in call.Method.Parameters) {
// catch "out Span<int>" and similar
if (p.Type.SkipModifiers() is ByReferenceType brt && brt.ElementType.IsByRefLike)
return AddressUse.Unknown;
}
// ensure there's no 'stloc target' in between the ldloca and the call consuming the address
for (int i = addressLoadingInstruction.ChildIndex + 1; i < call.Arguments.Count; i++) {
foreach (var inst in call.Arguments[i].Descendants) {
if (inst is StLoc store && store.Variable == targetVar)
return AddressUse.Unknown;
}
}
return AddressUse.Immediate;
case CallInstruction call:
return HandleCall(addressLoadingInstruction, targetVar, call);
case StLoc stloc when stloc.Variable.IsSingleDefinition:
// Address stored in local variable: also check all uses of that variable.
if (!(stloc.Variable.Kind == VariableKind.StackSlot || stloc.Variable.Kind == VariableKind.Local))
@ -142,6 +124,35 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -142,6 +124,35 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
}
static AddressUse HandleCall(ILInstruction addressLoadingInstruction, ILVariable targetVar, CallInstruction call)
{
// Address is passed to method.
// We'll assume the method only uses the address locally,
// unless we can see an address being returned from the method:
if (call is NewObj) {
if (call.Method.DeclaringType.IsByRefLike) {
return AddressUse.Unknown;
}
} else {
if (call.Method.ReturnType.IsByRefLike) {
return AddressUse.Unknown;
}
}
foreach (var p in call.Method.Parameters) {
// catch "out Span<int>" and similar
if (p.Type.SkipModifiers() is ByReferenceType brt && brt.ElementType.IsByRefLike)
return AddressUse.Unknown;
}
// ensure there's no 'stloc target' in between the ldloca and the call consuming the address
for (int i = addressLoadingInstruction.ChildIndex + 1; i < call.Arguments.Count; i++) {
foreach (var inst in call.Arguments[i].Descendants) {
if (inst is StLoc store && store.Variable == targetVar)
return AddressUse.Unknown;
}
}
return AddressUse.Immediate;
}
/// <summary>
/// Given 'ldloc ref_local' and 'ldloca target; stloc ref_local', returns the ldloca.
/// This function must return a non-null LdLoca for every use of a SupportedRefLocal.

26
ICSharpCode.Decompiler/IL/Transforms/SwitchOnStringTransform.cs

@ -373,22 +373,30 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -373,22 +373,30 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// </summary>
bool MatchLegacySwitchOnStringWithDict(InstructionCollection<ILInstruction> instructions, ref int i)
{
if (i < 1) return false;
// match first block: checking switch-value for null
// match first block: checking switch-value for null:
// (In some cases, i.e., if switchValueVar is a parameter, the initial store is optional.)
// stloc switchValueVar(switchValue)
// if (comp(ldloc switchValueVar == ldnull)) br nullCase
// br nextBlock
if (!(instructions[i].MatchIfInstruction(out var condition, out var exitBlockJump) &&
instructions[i - 1].MatchStLoc(out var switchValueVar, out var switchValue) && switchValueVar.Type.IsKnownType(KnownTypeCode.String)))
if (!instructions[i].MatchIfInstruction(out var condition, out var exitBlockJump))
return false;
if (!switchValueVar.IsSingleDefinition)
if (!(condition.MatchCompEquals(out var left, out var right) && right.MatchLdNull()))
return false;
// The initial store can be omitted in some cases. If there is no initial store or the switch value variable is reused later,
// we do not inline the "switch value", but create an extra load later on.
if (i > 0 && instructions[i - 1].MatchStLoc(out var switchValueVar, out var switchValue)) {
if (!(switchValueVar.IsSingleDefinition && ((SemanticHelper.IsPure(switchValue.Flags) && left.Match(switchValue).Success) || left.MatchLdLoc(switchValueVar))))
return false;
} else {
if (!left.MatchLdLoc(out switchValueVar))
return false;
switchValue = null;
}
if (!switchValueVar.Type.IsKnownType(KnownTypeCode.String))
return false;
// either br nullCase or leave container
if (!exitBlockJump.MatchBranch(out var nullValueCaseBlock) && !exitBlockJump.MatchLeave((BlockContainer)instructions[i].Parent.Parent))
return false;
if (!(condition.MatchCompEquals(out var left, out var right) && right.MatchLdNull()
&& ((SemanticHelper.IsPure(switchValue.Flags) && left.Match(switchValue).Success) || left.MatchLdLoc(switchValueVar))))
return false;
var nextBlockJump = instructions.ElementAtOrDefault(i + 1) as Branch;
if (nextBlockJump == null || nextBlockJump.TargetBlock.IncomingEdgeCount != 1)
return false;
@ -475,7 +483,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -475,7 +483,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
}
bool keepAssignmentBefore = false;
if (switchValueVar.LoadCount > 2) {
if (switchValueVar.LoadCount > 2 || switchValue == null) {
switchValue = new LdLoc(switchValueVar);
keepAssignmentBefore = true;
}

2
ICSharpCode.Decompiler/IL/Transforms/TransformCollectionAndObjectInitializers.cs

@ -338,7 +338,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -338,7 +338,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
{
if (method.IsStatic && !method.IsExtensionMethod)
return false;
if (method.IsAccessor)
if (method.AccessorOwner is IProperty)
return true;
if (!"Add".Equals(method.Name, StringComparison.Ordinal) || arguments.Count == 0)
return false;

29
ICSharpCode.Decompiler/IL/Transforms/TransformExpressionTrees.cs

@ -164,6 +164,14 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -164,6 +164,14 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return (null, SpecialType.UnknownType);
container.ExpectedResultType = bodyInstruction.ResultType;
container.Blocks.Add(new Block() { Instructions = { new Leave(container, bodyInstruction) } });
// Replace all other usages of the parameter variable
foreach (var mapping in parameterMapping) {
foreach (var load in mapping.Key.LoadInstructions.ToArray()) {
if (load.IsDescendantOf(instruction))
continue;
load.ReplaceWith(new LdLoc(mapping.Value));
}
}
return (function, function.DelegateType);
}
@ -333,9 +341,20 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -333,9 +341,20 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return (function, function.DelegateType);
case LdLoc ldloc:
if (IsExpressionTreeParameter(ldloc.Variable)) {
if (!parameterMapping.TryGetValue(ldloc.Variable, out var v))
return (null, SpecialType.UnknownType);
return (new LdLoc(v), v.Type);
// Replace an already mapped parameter with the actual ILVariable,
// we generated earlier.
if (parameterMapping.TryGetValue(ldloc.Variable, out var v))
return (new LdLoc(v), v.Type);
// This is a parameter variable from an outer scope.
// We can't replace these variables just yet, because the transform works backwards.
// We simply return the same instruction again, but return the actual expected type,
// so our transform can continue normally.
// Later, we will replace all references to unmapped variables,
// with references to mapped parameters.
if (ldloc.Variable.IsSingleDefinition && ldloc.Variable.StoreInstructions[0] is ILInstruction inst) {
if (MatchParameterVariableAssignment(inst, out _, out var type, out _))
return (ldloc, type);
}
}
return (null, SpecialType.UnknownType);
default:
@ -1017,7 +1036,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -1017,7 +1036,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
case LdLoc ldloc:
if (IsExpressionTreeParameter(ldloc.Variable)) {
if (!parameterMapping.TryGetValue(ldloc.Variable, out var v))
return null;
return ldloc;
if (context is CallInstruction parentCall
&& parentCall.Method.FullName == "System.Linq.Expressions.Expression.Call"
&& v.StackType.IsIntegerType())
@ -1025,7 +1044,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -1025,7 +1044,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return null;
} else {
if (ldloc.Variable.Kind != VariableKind.StackSlot)
return new LdLoc(ldloc.Variable);
return ldloc;
return null;
}
default:

31
ICSharpCode.Decompiler/TypeSystem/IAmbience.cs → ICSharpCode.Decompiler/Output/IAmbience.cs

@ -17,8 +17,9 @@ @@ -17,8 +17,9 @@
// DEALINGS IN THE SOFTWARE.
using System;
using ICSharpCode.Decompiler.TypeSystem;
namespace ICSharpCode.Decompiler.TypeSystem
namespace ICSharpCode.Decompiler.Output
{
[Flags]
public enum ConversionFlags
@ -44,7 +45,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -44,7 +45,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// </summary>
ShowDefinitionKeyword = 8,
/// <summary>
/// Show the declaring type for the member
/// Show the declaring type for the type or member
/// </summary>
ShowDeclaringType = 0x10,
/// <summary>
@ -69,22 +70,42 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -69,22 +70,42 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// For properties: shows "{ get; }" or similar.
/// </summary>
ShowBody = 0x200,
/// <summary>
/// Use fully qualified names for members.
/// </summary>
UseFullyQualifiedEntityNames = 0x400,
/// <summary>
/// Instead of placing the return type before the entity name,
/// append it after the parameter list, preceeded by a colon.
/// </summary>
PlaceReturnTypeAfterParameterList = 0x800,
/// <summary>
/// Show the variance modifier of the type parameter.
/// If active, shows 'Func&lt;in T, out TResult&gt;' instead of 'Func&lt;T, TResult&gt;'.
/// </summary>
ShowTypeParameterVarianceModifier = 0x1000,
/// <summary>
/// Show modifiers of parameters, e.g. 'this', 'params', 'ref', 'out' and 'in'.
/// </summary>
ShowParameterModifiers = 0x2000,
/// <summary>
/// Show default values of parameters.
/// </summary>
ShowParameterDefaultValues = 0x4000,
StandardConversionFlags = ShowParameterNames |
ShowAccessibility |
ShowParameterList |
ShowParameterModifiers |
ShowParameterDefaultValues |
ShowReturnType |
ShowModifiers |
ShowTypeParameterList |
ShowTypeParameterVarianceModifier |
ShowDefinitionKeyword |
ShowBody,
All = 0x7ff,
All = 0x7ffff,
}
/// <summary>

11
ICSharpCode.Decompiler/SRMExtensions.cs

@ -291,6 +291,17 @@ namespace ICSharpCode.Decompiler @@ -291,6 +291,17 @@ namespace ICSharpCode.Decompiler
return metadata.GetMethodDefinition(handle).IsCompilerGenerated(metadata);
}
public static bool IsCompilerGeneratedOrIsInCompilerGeneratedClass(this MethodDefinitionHandle handle, MetadataReader metadata)
{
MethodDefinition method = metadata.GetMethodDefinition(handle);
if (method.IsCompilerGenerated(metadata))
return true;
TypeDefinitionHandle declaringTypeHandle = method.GetDeclaringType();
if (!declaringTypeHandle.IsNil && declaringTypeHandle.IsCompilerGenerated(metadata))
return true;
return false;
}
public static bool IsCompilerGenerated(this MethodDefinition method, MetadataReader metadata)
{
return method.GetCustomAttributes().HasKnownAttribute(metadata, KnownAttribute.CompilerGenerated);

6
ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataMethod.cs

@ -60,6 +60,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -60,6 +60,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
this.symbolKind = SymbolKind.Method;
var (accessorOwner, semanticsAttribute) = module.PEFile.MethodSemanticsLookup.GetSemantics(handle);
const MethodAttributes finalizerAttributes = (MethodAttributes.Virtual | MethodAttributes.Family | MethodAttributes.HideBySig);
if (semanticsAttribute != 0) {
this.symbolKind = SymbolKind.Accessor;
this.accessorOwner = accessorOwner;
@ -69,6 +70,11 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -69,6 +70,11 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
this.symbolKind = SymbolKind.Constructor;
else if (name.StartsWith("op_", StringComparison.Ordinal))
this.symbolKind = SymbolKind.Operator;
} else if ((attributes & finalizerAttributes) == finalizerAttributes) {
string name = this.Name;
if (name == "Finalize" && Parameters.Count == 0) {
this.symbolKind = SymbolKind.Destructor;
}
}
this.typeParameters = MetadataTypeParameter.Create(module, this, def.GetGenericParameters());
this.IsExtensionMethod = (attributes & MethodAttributes.Static) == MethodAttributes.Static

11
ICSharpCode.Decompiler/TypeSystem/KnownTypeReference.cs

@ -129,6 +129,12 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -129,6 +129,12 @@ namespace ICSharpCode.Decompiler.TypeSystem
IFormattable,
/// <summary><c>System.FormattableString</c></summary>
FormattableString,
/// <summary><c>System.Span{T}</c></summary>
SpanOfT,
/// <summary><c>System.ReadOnlySpan{T}</c></summary>
ReadOnlySpanOfT,
/// <summary><c>System.Memory{T}</c></summary>
MemoryOfT,
}
/// <summary>
@ -137,7 +143,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -137,7 +143,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
[Serializable]
public sealed class KnownTypeReference : ITypeReference
{
internal const int KnownTypeCodeCount = (int)KnownTypeCode.FormattableString + 1;
internal const int KnownTypeCodeCount = (int)KnownTypeCode.MemoryOfT + 1;
static readonly KnownTypeReference[] knownTypeReferences = new KnownTypeReference[KnownTypeCodeCount] {
null, // None
@ -191,6 +197,9 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -191,6 +197,9 @@ namespace ICSharpCode.Decompiler.TypeSystem
new KnownTypeReference(KnownTypeCode.TypedReference, TypeKind.Struct, "System", "TypedReference"),
new KnownTypeReference(KnownTypeCode.IFormattable, TypeKind.Interface, "System", "IFormattable"),
new KnownTypeReference(KnownTypeCode.FormattableString, TypeKind.Class, "System", "FormattableString", baseType: KnownTypeCode.IFormattable),
new KnownTypeReference(KnownTypeCode.SpanOfT, TypeKind.Struct, "System", "Span", 1),
new KnownTypeReference(KnownTypeCode.ReadOnlySpanOfT, TypeKind.Struct, "System", "ReadOnlySpan", 1),
new KnownTypeReference(KnownTypeCode.MemoryOfT, TypeKind.Struct, "System", "Memory", 1),
};
/// <summary>

9
ILSpy.Tests/ILSpy.Tests.csproj

@ -14,11 +14,12 @@ @@ -14,11 +14,12 @@
<EnableDefaultItems>false</EnableDefaultItems>
<OutputType>Exe</OutputType>
<StartupObject>ILSpy.Tests.Stub</StartupObject>
<StartupObject>ICSharpCode.ILSpy.Tests.Stub</StartupObject>
<AutoGenerateBindingRedirects>True</AutoGenerateBindingRedirects>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>..\ICSharpCode.Decompiler\ICSharpCode.Decompiler.snk</AssemblyOriginatorKeyFile>
<RootNamespace>ICSharpCode.ILSpy.Tests</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
@ -36,8 +37,6 @@ @@ -36,8 +37,6 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="..\ICSharpCode.Decompiler.Tests\TypeSystem\TypeSystemTestCase.cs" Link="TestCases\TypeSystemTestCase.cs" />
<Compile Include="Languages\CSharpLanguageTests.cs" />
<Compile Include="Stub.cs" />
</ItemGroup>
@ -63,8 +62,4 @@ @@ -63,8 +62,4 @@
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<ItemGroup>
<Folder Include="TestCases\" />
</ItemGroup>
</Project>

129
ILSpy.Tests/Languages/CSharpLanguageTests.cs

@ -1,129 +0,0 @@ @@ -1,129 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.Tests.TypeSystem;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.Decompiler.TypeSystem.Implementation;
using ICSharpCode.ILSpy;
using NUnit.Framework;
namespace ILSpy.Tests.Languages
{
[TestFixture, Parallelizable(ParallelScope.All)]
public class CSharpLanguageTests
{
const string ns = "ICSharpCode.Decompiler.Tests.TypeSystem";
static PEFile LoadAssembly(string filename)
{
return new PEFile(filename, new FileStream(filename, FileMode.Open, FileAccess.Read));
}
static readonly Lazy<PEFile> mscorlib = new Lazy<PEFile>(
delegate {
return LoadAssembly(typeof(object).Assembly.Location);
});
static readonly Lazy<PEFile> systemCore = new Lazy<PEFile>(
delegate {
return LoadAssembly(typeof(System.Linq.Enumerable).Assembly.Location);
});
static readonly Lazy<PEFile> testAssembly = new Lazy<PEFile>(
delegate {
return LoadAssembly(typeof(CSharpLanguageTests).Assembly.Location);
});
public static PEFile Mscorlib { get { return mscorlib.Value; } }
public static PEFile SystemCore { get { return systemCore.Value; } }
public static PEFile TestAssembly { get { return testAssembly.Value; } }
[OneTimeSetUp]
public void FixtureSetUp()
{
compilation = new SimpleCompilation(TestAssembly,
Mscorlib.WithOptions(TypeSystemOptions.Default));
language = new CSharpLanguage();
}
ICompilation compilation;
CSharpLanguage language;
ITypeDefinition GetTypeDefinition(Type type)
{
return compilation.FindType(type).GetDefinition();
}
void TestType(Type t, string ns, string name)
{
var type = GetTypeDefinition(t);
Assert.AreEqual(name, language.TypeToString(type, includeNamespace: false));
Assert.AreEqual(ns + "." + name, language.TypeToString(type, includeNamespace: true));
}
void TestMethod(Type t, Predicate<IMember> filter, string ns, string typeName, string name, string paramListReturnType, string longParamListReturnType = null)
{
var type = GetTypeDefinition(t);
var method = type.GetMembers(filter, GetMemberOptions.IgnoreInheritedMembers).Single() as IMethod;
if (method == null)
throw new ArgumentNullException();
if (longParamListReturnType == null)
longParamListReturnType = paramListReturnType;
Assert.AreEqual(name + paramListReturnType, language.MethodToString(method, includeDeclaringTypeName: false, includeNamespace: false, includeNamespaceOfDeclaringTypeName: false));
Assert.AreEqual(typeName + "." + name + paramListReturnType, language.MethodToString(method, includeDeclaringTypeName: true, includeNamespace: false, includeNamespaceOfDeclaringTypeName: false));
Assert.AreEqual(name + longParamListReturnType, language.MethodToString(method, includeDeclaringTypeName: false, includeNamespace: true, includeNamespaceOfDeclaringTypeName: false));
Assert.AreEqual(typeName + "." + name + longParamListReturnType, language.MethodToString(method, includeDeclaringTypeName: true, includeNamespace: true, includeNamespaceOfDeclaringTypeName: false));
Assert.AreEqual(name + paramListReturnType, language.MethodToString(method, includeDeclaringTypeName: false, includeNamespace: false, includeNamespaceOfDeclaringTypeName: true));
Assert.AreEqual(ns + "." + typeName + "." + name + paramListReturnType, language.MethodToString(method, includeDeclaringTypeName: true, includeNamespace: false, includeNamespaceOfDeclaringTypeName: true));
Assert.AreEqual(name + longParamListReturnType, language.MethodToString(method, includeDeclaringTypeName: false, includeNamespace: true, includeNamespaceOfDeclaringTypeName: true));
Assert.AreEqual(ns + "." + typeName + "." + name + longParamListReturnType, language.MethodToString(method, includeDeclaringTypeName: true, includeNamespace: true, includeNamespaceOfDeclaringTypeName: true));
}
[Test]
public void PrimitiveTypes()
{
TestType(typeof(object), "System", "Object");
TestType(typeof(string), "System", "String");
TestType(typeof(int), "System", "Int32");
}
[Test]
public void ClassTests()
{
TestType(typeof(SimplePublicClass), ns, "SimplePublicClass");
TestType(typeof(GenericClass<,>), ns, "GenericClass<A,B>");
TestType(typeof(OuterGeneric<>), ns, "OuterGeneric<X>");
TestType(typeof(OuterGeneric<>.Inner), ns + ".OuterGeneric<X>", "Inner");
}
[Test]
public void InterfaceTests()
{
TestType(typeof(IBase1), ns, "IBase1");
TestType(typeof(IGenericInterface<>), ns, "IGenericInterface<T>");
}
[Test]
public void EnumTests()
{
TestType(typeof(MyEnum), ns, "MyEnum");
TestType(typeof(GenericClass<,>.NestedEnum), ns + ".GenericClass<A,B>", "NestedEnum");
}
[Test]
public void DelegateTests()
{
TestType(typeof(GenericDelegate<,>), ns, "GenericDelegate<T,S>");
}
[Test]
public void MethodTests()
{
TestMethod(typeof(IMarshalAsTests), x => x.Name == "QueryApplicationFile", ns, "IMarshalAsTests", "QueryApplicationFile", "(string, out string, out string, out bool, out bool, out object[]) : void");
TestMethod(typeof(MyClassWithCtor), x => x is IMethod m && m.IsConstructor, ns, "MyClassWithCtor", "MyClassWithCtor", "(int)");
TestMethod(typeof(OuterGeneric<>), x => x is IMethod m && m.IsConstructor, ns, "OuterGeneric<X>", "OuterGeneric<X>", "()");
}
}
}

2
ILSpy.Tests/Stub.cs

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
using System;
namespace ILSpy.Tests
namespace ICSharpCode.ILSpy.Tests
{
class Stub
{

5
ILSpy.sln

@ -26,11 +26,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ILSpy.BamlDecompiler.Tests" @@ -26,11 +26,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ILSpy.BamlDecompiler.Tests"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ILSpy.AddIn", "ILSpy.AddIn\ILSpy.AddIn.csproj", "{9D7BE6C0-B7B3-4A50-A54E-18A2D84A3384}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0A344E19-D1FC-4F4C-8883-0844AC669113}"
ProjectSection(SolutionItems) = preProject
Rebracer.xml = Rebracer.xml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ICSharpCode.Decompiler.PdbProvider.Cecil", "ICSharpCode.Decompiler.PdbProvider.Cecil\ICSharpCode.Decompiler.PdbProvider.Cecil.csproj", "{B85A155A-9DD6-43BC-A624-2D8EC773D71F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILSpy.Tests", "ILSpy.Tests\ILSpy.Tests.csproj", "{B51C6636-B8D1-4200-9869-08F2689DE6C2}"

14
ILSpy/Analyzers/AnalyzerScope.cs

@ -89,14 +89,12 @@ namespace ICSharpCode.ILSpy.Analyzers @@ -89,14 +89,12 @@ namespace ICSharpCode.ILSpy.Analyzers
{
if (IsLocal) {
var typeSystem = new DecompilerTypeSystem(TypeScope.ParentModule.PEFile, TypeScope.ParentModule.PEFile.GetAssemblyResolver());
if (memberAccessibility == Accessibility.Private) {
foreach (var type in TreeTraversal.PreOrder(typeScope, t => t.NestedTypes)) {
yield return type;
}
} else {
foreach (var type in TreeTraversal.PreOrder(typeScope.DeclaringTypeDefinition, t => t.NestedTypes)) {
yield return type;
}
ITypeDefinition scope = typeScope;
if (memberAccessibility != Accessibility.Private && typeScope.DeclaringTypeDefinition != null) {
scope = typeScope.DeclaringTypeDefinition;
}
foreach (var type in TreeTraversal.PreOrder(scope, t => t.NestedTypes)) {
yield return type;
}
} else {
foreach (var module in GetModulesInScope(ct)) {

27
ILSpy/Analyzers/Builtin/MethodUsedByAnalyzer.cs

@ -99,7 +99,7 @@ namespace ICSharpCode.ILSpy.Analyzers.Builtin @@ -99,7 +99,7 @@ namespace ICSharpCode.ILSpy.Analyzers.Builtin
ILOpCode opCode;
try {
opCode = blob.DecodeOpCode();
if (opCode != ILOpCode.Call && opCode != ILOpCode.Callvirt) {
if (!IsSupportedOpCode(opCode)) {
ILParser.SkipOperand(ref blob, opCode);
continue;
}
@ -118,22 +118,35 @@ namespace ICSharpCode.ILSpy.Analyzers.Builtin @@ -118,22 +118,35 @@ namespace ICSharpCode.ILSpy.Analyzers.Builtin
if (m == null)
continue;
if (opCode == ILOpCode.Call) {
if (IsSameMember(analyzedMethod, m)) {
return true;
}
}
if (opCode == ILOpCode.Callvirt && baseMethod != null) {
if (IsSameMember(baseMethod, m)) {
return true;
}
} else {
if (IsSameMember(analyzedMethod, m)) {
return true;
}
}
}
return false;
}
static bool IsSupportedOpCode(ILOpCode opCode)
{
switch (opCode) {
case ILOpCode.Call:
case ILOpCode.Callvirt:
case ILOpCode.Ldtoken:
case ILOpCode.Ldftn:
case ILOpCode.Ldvirtftn:
case ILOpCode.Newobj:
return true;
default:
return false;
}
}
static bool IsSameMember(IMember analyzedMethod, IMember m)
{
return m.MetadataToken == analyzedMethod.MetadataToken

2
ILSpy/DebugInfo/PortableDebugInfoProvider.cs

@ -75,7 +75,7 @@ namespace ICSharpCode.ILSpy.DebugInfo @@ -75,7 +75,7 @@ namespace ICSharpCode.ILSpy.DebugInfo
var scope = metadata.GetLocalScope(h);
foreach (var v in scope.GetLocalVariables()) {
var var = metadata.GetLocalVariable(v);
variables.Add(new Variable { Name = metadata.GetString(var.Name) });
variables.Add(new Variable(var.Index, metadata.GetString(var.Name)));
}
}

1
ILSpy/DebugSteps.xaml

@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
<CheckBox Margin="3" Content="UseFieldSugar" IsChecked="{Binding UseFieldSugar, Source={x:Static local:DebugSteps.Options}}" />
<CheckBox Margin="3" Content="UseLogicOperationSugar" IsChecked="{Binding UseLogicOperationSugar, Source={x:Static local:DebugSteps.Options}}" />
<CheckBox Margin="3" Content="ShowILRanges" IsChecked="{Binding ShowILRanges, Source={x:Static local:DebugSteps.Options}}" />
<CheckBox Margin="3" Content="ShowChildIndexInBlock" IsChecked="{Binding ShowChildIndexInBlock, Source={x:Static local:DebugSteps.Options}}" />
</StackPanel>
<TreeView Name="tree" MouseDoubleClick="ShowStateAfter_Click" KeyDown="tree_KeyDown">
<TreeView.ItemTemplate>

7
ILSpy/ILSpy.csproj

@ -50,9 +50,8 @@ @@ -50,9 +50,8 @@
<ItemGroup>
<PackageReference Include="AvalonEdit" Version="5.0.4" />
<PackageReference Include="Microsoft.DiaSymReader.Native" Version="1.7.0" />
<PackageReference Include="Microsoft.VisualStudio.Composition" Version="15.5.23" />
<PackageReference Include="Microsoft.DiaSymReader" Version="1.2.0" />
<PackageReference Include="Mono.Cecil" Version="0.10.0" />
</ItemGroup>
<ItemGroup>
@ -65,6 +64,7 @@ @@ -65,6 +64,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="..\ICSharpCode.Decompiler.PdbProvider.Cecil\MonoCecilDebugInfoProvider.cs" Link="DebugInfo\MonoCecilDebugInfoProvider.cs" />
<Compile Include="AboutPage.cs" />
<Compile Include="Analyzers\AnalyzerScope.cs" />
<Compile Include="Analyzers\Builtin\AttributeAppliedToAnalyzer.cs" />
@ -128,7 +128,6 @@ @@ -128,7 +128,6 @@
<Compile Include="CreateListDialog.xaml.cs">
<DependentUpon>CreateListDialog.xaml</DependentUpon>
</Compile>
<Compile Include="DebugInfo\DiaSymNativeDebugInfoProvider.cs" />
<Compile Include="DebugInfo\PortableDebugInfoProvider.cs" />
<Compile Include="DebugSteps.xaml.cs">
<DependentUpon>DebugSteps.xaml</DependentUpon>
@ -422,6 +421,8 @@ @@ -422,6 +421,8 @@
<NuGetPackagesToCopy Include="$(TargetDir)System.Reflection.Metadata.dll" />
<NuGetPackagesToCopy Include="$(TargetDir)Microsoft.VisualStudio.Composition.dll" />
<NuGetPackagesToCopy Include="$(TargetDir)Microsoft.VisualStudio.Validation.dll" />
<NuGetPackagesToCopy Include="$(TargetDir)Mono.Cecil.dll" />
<NuGetPackagesToCopy Include="$(TargetDir)Mono.Cecil.Pdb.dll" />
</ItemGroup>
<Copy SourceFiles="@(NuGetPackagesToCopy)" DestinationFolder="..\ILSpy.AddIn\packages" />
</Target>

7
ILSpy/Languages/CSharpHighlightingTokenWriter.cs

@ -207,8 +207,6 @@ namespace ICSharpCode.ILSpy @@ -207,8 +207,6 @@ namespace ICSharpCode.ILSpy
case "by":
case "into":
case "from":
case "ascending":
case "descending":
case "orderby":
case "let":
case "join":
@ -217,6 +215,11 @@ namespace ICSharpCode.ILSpy @@ -217,6 +215,11 @@ namespace ICSharpCode.ILSpy
if (nodeStack.PeekOrDefault() is QueryClause)
color = queryKeywordsColor;
break;
case "ascending":
case "descending":
if (nodeStack.PeekOrDefault() is QueryOrdering)
color = queryKeywordsColor;
break;
case "explicit":
case "implicit":
case "operator":

179
ILSpy/Languages/CSharpLanguage.cs

@ -21,19 +21,21 @@ using System.Collections.Generic; @@ -21,19 +21,21 @@ using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.CSharp;
using ICSharpCode.Decompiler.CSharp.OutputVisitor;
using ICSharpCode.Decompiler.CSharp.Syntax;
using ICSharpCode.Decompiler.CSharp.Transforms;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.Decompiler.Metadata;
using System.Reflection.Metadata;
using ICSharpCode.Decompiler.Output;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.Decompiler.Util;
using System.Text;
using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy
{
@ -113,7 +115,7 @@ namespace ICSharpCode.ILSpy @@ -113,7 +115,7 @@ namespace ICSharpCode.ILSpy
return decompiler;
}
void WriteCode(ITextOutput output, Decompiler.DecompilerSettings settings, SyntaxTree syntaxTree, IDecompilerTypeSystem typeSystem)
void WriteCode(ITextOutput output, DecompilerSettings settings, SyntaxTree syntaxTree, IDecompilerTypeSystem typeSystem)
{
syntaxTree.AcceptVisitor(new InsertParenthesesVisitor { InsertParenthesesForReadability = true });
TokenWriter tokenWriter = new TextTokenWriter(output, settings, typeSystem) { FoldBraces = settings.FoldBraces, ExpandMemberDefinitions = settings.ExpandMemberDefinitions };
@ -424,170 +426,69 @@ namespace ICSharpCode.ILSpy @@ -424,170 +426,69 @@ namespace ICSharpCode.ILSpy
}
}
static readonly CSharpFormattingOptions TypeToStringFormattingOptions = FormattingOptionsFactory.CreateEmpty();
public override string TypeToString(IType type, bool includeNamespace)
static CSharpAmbience CreateAmbience()
{
if (type == null)
throw new ArgumentNullException(nameof(type));
if (type is ITypeDefinition definition && definition.TypeParameterCount > 0) {
return TypeToStringInternal(new ParameterizedType(definition, definition.TypeParameters), includeNamespace, false);
}
return TypeToStringInternal(type, includeNamespace, false);
CSharpAmbience ambience = new CSharpAmbience();
// Do not forget to update CSharpAmbienceTests.ILSpyMainTreeViewTypeFlags, if this ever changes.
ambience.ConversionFlags = ConversionFlags.ShowTypeParameterList | ConversionFlags.PlaceReturnTypeAfterParameterList;
return ambience;
}
string TypeToStringInternal(IType t, bool includeNamespace, bool useBuiltinTypeNames = true, ParameterModifier parameterModifier = ParameterModifier.None)
static string EntityToString(IEntity entity, bool includeDeclaringTypeName, bool includeNamespace, bool includeNamespaceOfDeclaringTypeName)
{
TypeSystemAstBuilder builder = new TypeSystemAstBuilder();
builder.AlwaysUseShortTypeNames = !includeNamespace;
builder.AlwaysUseBuiltinTypeNames = useBuiltinTypeNames;
const ParameterModifier refInOutModifier = ParameterModifier.Ref | ParameterModifier.Out | ParameterModifier.In;
AstType astType = builder.ConvertType(t);
if ((parameterModifier & refInOutModifier) != 0 && astType is ComposedType ct && ct.HasRefSpecifier) {
ct.HasRefSpecifier = false;
}
StringWriter w = new StringWriter();
astType.AcceptVisitor(new CSharpOutputVisitor(w, TypeToStringFormattingOptions));
string output = w.ToString();
switch (parameterModifier) {
case ParameterModifier.Ref:
output = "ref " + output;
break;
case ParameterModifier.Out:
output = "out " + output;
break;
case ParameterModifier.In:
output = "in " + output;
break;
}
return output;
// Do not forget to update CSharpAmbienceTests, if this ever changes.
var ambience = CreateAmbience();
ambience.ConversionFlags |= ConversionFlags.ShowReturnType | ConversionFlags.ShowParameterList | ConversionFlags.ShowParameterModifiers;
if (includeDeclaringTypeName)
ambience.ConversionFlags |= ConversionFlags.ShowDeclaringType;
if (includeNamespace)
ambience.ConversionFlags |= ConversionFlags.UseFullyQualifiedTypeNames;
if (includeNamespaceOfDeclaringTypeName)
ambience.ConversionFlags |= ConversionFlags.UseFullyQualifiedEntityNames;
return ambience.ConvertSymbol(entity);
}
static ParameterModifier GetModifier(IParameter p)
public override string TypeToString(IType type, bool includeNamespace)
{
if (p.IsRef)
return ParameterModifier.Ref;
if (p.IsOut)
return ParameterModifier.Out;
if (p.IsIn)
return ParameterModifier.In;
return ParameterModifier.None;
if (type == null)
throw new ArgumentNullException(nameof(type));
var ambience = CreateAmbience();
// Do not forget to update CSharpAmbienceTests.ILSpyMainTreeViewFlags, if this ever changes.
if (includeNamespace)
ambience.ConversionFlags |= ConversionFlags.UseFullyQualifiedTypeNames;
if (type is ITypeDefinition definition) {
return ambience.ConvertSymbol(definition);
} else {
return ambience.ConvertType(type);
}
}
public override string FieldToString(IField field, bool includeDeclaringTypeName, bool includeNamespace, bool includeNamespaceOfDeclaringTypeName)
{
if (field == null)
throw new ArgumentNullException(nameof(field));
string simple = field.Name + " : " + TypeToString(field.Type, includeNamespace);
if (!includeDeclaringTypeName)
return simple;
return TypeToStringInternal(field.DeclaringType, includeNamespaceOfDeclaringTypeName) + "." + simple;
return EntityToString(field, includeDeclaringTypeName, includeNamespace, includeNamespaceOfDeclaringTypeName);
}
public override string PropertyToString(IProperty property, bool includeDeclaringTypeName, bool includeNamespace, bool includeNamespaceOfDeclaringTypeName)
{
if (property == null)
throw new ArgumentNullException(nameof(property));
var buffer = new System.Text.StringBuilder();
if (includeDeclaringTypeName) {
buffer.Append(TypeToString(property.DeclaringType, includeNamespaceOfDeclaringTypeName));
buffer.Append('.');
}
if (property.IsIndexer) {
if (property.IsExplicitInterfaceImplementation) {
string name = property.Name;
int index = name.LastIndexOf('.');
if (index > 0) {
buffer.Append(name.Substring(0, index));
buffer.Append('.');
}
}
buffer.Append(@"this[");
int i = 0;
var parameters = property.Parameters;
foreach (var param in parameters) {
if (i > 0)
buffer.Append(", ");
buffer.Append(TypeToStringInternal(param.Type, includeNamespace, parameterModifier: GetModifier(param)));
i++;
}
buffer.Append(@"]");
} else {
buffer.Append(property.Name);
}
buffer.Append(" : ");
buffer.Append(TypeToStringInternal(property.ReturnType, includeNamespace));
return buffer.ToString();
return EntityToString(property, includeDeclaringTypeName, includeNamespace, includeNamespaceOfDeclaringTypeName);
}
public override string MethodToString(IMethod method, bool includeDeclaringTypeName, bool includeNamespace, bool includeNamespaceOfDeclaringTypeName)
{
if (method == null)
throw new ArgumentNullException(nameof(method));
string name;
if (includeDeclaringTypeName) {
name = TypeToString(method.DeclaringType, includeNamespace: includeNamespaceOfDeclaringTypeName) + ".";
} else {
name = "";
}
if (method.IsConstructor) {
name += TypeToString(method.DeclaringType, false);
} else {
name += method.Name;
}
int i = 0;
var buffer = new StringBuilder(name);
if (method.TypeParameters.Count > 0) {
buffer.Append('<');
foreach (var tp in method.TypeParameters) {
if (i > 0)
buffer.Append(", ");
buffer.Append(tp.Name);
i++;
}
buffer.Append('>');
}
buffer.Append('(');
i = 0;
var parameters = method.Parameters;
foreach (var param in parameters) {
if (i > 0)
buffer.Append(", ");
buffer.Append(TypeToStringInternal(param.Type, includeNamespace, parameterModifier: GetModifier(param)));
i++;
}
buffer.Append(')');
if (!method.IsConstructor) {
buffer.Append(" : ");
buffer.Append(TypeToStringInternal(method.ReturnType, includeNamespace));
}
return buffer.ToString();
return EntityToString(method, includeDeclaringTypeName, includeNamespace, includeNamespaceOfDeclaringTypeName);
}
public override string EventToString(IEvent @event, bool includeDeclaringTypeName, bool includeNamespace, bool includeNamespaceOfDeclaringTypeName)
{
if (@event == null)
throw new ArgumentNullException(nameof(@event));
var buffer = new System.Text.StringBuilder();
if (includeDeclaringTypeName) {
buffer.Append(TypeToString(@event.DeclaringType, includeNamespaceOfDeclaringTypeName) + ".");
}
buffer.Append(@event.Name);
buffer.Append(" : ");
buffer.Append(TypeToStringInternal(@event.ReturnType, includeNamespace));
return buffer.ToString();
return EntityToString(@event, includeDeclaringTypeName, includeNamespace, includeNamespaceOfDeclaringTypeName);
}
string ToCSharpString(MetadataReader metadata, TypeDefinitionHandle handle, bool fullName)
@ -684,7 +585,7 @@ namespace ICSharpCode.ILSpy @@ -684,7 +585,7 @@ namespace ICSharpCode.ILSpy
public override string GetTooltip(IEntity entity)
{
var flags = ConversionFlags.All & ~ConversionFlags.ShowBody;
var flags = ConversionFlags.All & ~(ConversionFlags.ShowBody | ConversionFlags.PlaceReturnTypeAfterParameterList);
return new CSharpAmbience() { ConversionFlags = flags }.ConvertSymbol(entity);
}

18
ILSpy/Languages/Language.cs

@ -249,12 +249,21 @@ namespace ICSharpCode.ILSpy @@ -249,12 +249,21 @@ namespace ICSharpCode.ILSpy
}
public override IType VisitOtherType(IType type)
{
WriteType(type);
return type;
}
private void WriteType(IType type)
{
if (includeNamespace)
builder.Append(type.FullName);
else
builder.Append(type.Name);
return type;
if (type.TypeParameterCount > 0) {
builder.Append('`');
builder.Append(type.TypeParameterCount);
}
}
public override IType VisitTypeDefinition(ITypeDefinition type)
@ -315,10 +324,7 @@ namespace ICSharpCode.ILSpy @@ -315,10 +324,7 @@ namespace ICSharpCode.ILSpy
builder.Append("typedref");
break;
default:
if (includeNamespace)
builder.Append(type.FullName);
else
builder.Append(type.Name);
WriteType(type);
break;
}
return type;
@ -359,6 +365,8 @@ namespace ICSharpCode.ILSpy @@ -359,6 +365,8 @@ namespace ICSharpCode.ILSpy
buffer.Append(GetDisplayName(method, includeDeclaringTypeName, includeNamespace, includeNamespaceOfDeclaringTypeName));
var typeParameters = method.TypeParameters;
if (typeParameters.Count > 0) {
buffer.Append("``");
buffer.Append(typeParameters.Count);
buffer.Append('<');
foreach (var tp in typeParameters) {
if (i > 0)

3
ILSpy/LoadedAssembly.cs

@ -28,6 +28,7 @@ using System.Threading.Tasks; @@ -28,6 +28,7 @@ using System.Threading.Tasks;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.DebugInfo;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.PdbProvider.Cecil;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.Decompiler.TypeSystem.Implementation;
using ICSharpCode.ILSpy.DebugInfo;
@ -187,7 +188,7 @@ namespace ICSharpCode.ILSpy @@ -187,7 +188,7 @@ namespace ICSharpCode.ILSpy
string pdbDirectory = Path.GetDirectoryName(fileName);
pdbFileName = Path.Combine(pdbDirectory, Path.GetFileNameWithoutExtension(fileName) + ".pdb");
if (File.Exists(pdbFileName)) {
debugInfoProvider = new DiaSymNativeDebugInfoProvider(module, pdbFileName, OpenStream(pdbFileName));
debugInfoProvider = new MonoCecilDebugInfoProvider(module, pdbFileName);
return;
}

18
ILSpy/LoadedAssemblyExtensions.cs

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
@ -12,6 +13,23 @@ namespace ICSharpCode.ILSpy @@ -12,6 +13,23 @@ namespace ICSharpCode.ILSpy
{
public static class LoadedAssemblyExtensions
{
/// <summary>
/// This method creates a Cecil object model from a PEFile. It is intended as helper method for plugins.
/// Note that this method is expensive and creates high memory pressure!
/// Note that accessing the Cecil objects created by this method after an assembly has been unloaded by ILSpy
/// might lead to <see cref="AccessViolationException"/> or similar.
/// </summary>
/// <remarks>Use only as last resort if there is something missing in the official ILSpy API.
/// Consider creating an issue at https://github.com/icsharpcode/ILSpy/issues/new
/// and discussing the problem with us.</remarks>
public unsafe static Mono.Cecil.ModuleDefinition CreateCecilObjectModel(this PEFile file)
{
if (!file.Reader.IsEntireImageAvailable)
throw new InvalidOperationException("Need full image to create Cecil object model!");
var image = file.Reader.GetEntireImage();
return Mono.Cecil.ModuleDefinition.ReadModule(new UnmanagedMemoryStream(image.Pointer, image.Length));
}
public static IAssemblyResolver GetAssemblyResolver(this PEFile file)
{
return GetLoadedAssembly(file).GetAssemblyResolver();

14
ILSpy/MainWindow.xaml.cs

@ -661,8 +661,20 @@ namespace ICSharpCode.ILSpy @@ -661,8 +661,20 @@ namespace ICSharpCode.ILSpy
// just ignore all of them.
}
}
public static void ExecuteCommand(string fileName, string arguments)
{
try {
Process.Start(fileName, arguments);
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
} catch (Exception) {
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
// Process.Start can throw several errors (not all of them documented),
// just ignore all of them.
}
}
#endregion
#region Open/Refresh
void OpenCommandExecuted(object sender, ExecutedRoutedEventArgs e)
{

2
ILSpy/Properties/AssemblyInfo.template.cs

@ -42,7 +42,7 @@ internal static class RevisionClass @@ -42,7 +42,7 @@ internal static class RevisionClass
public const string Minor = "0";
public const string Build = "0";
public const string Revision = "$INSERTREVISION$";
public const string VersionName = "beta1";
public const string VersionName = "beta2";
public const string FullVersion = Major + "." + Minor + "." + Build + ".$INSERTREVISION$$INSERTBRANCHPOSTFIX$$INSERTVERSIONNAMEPOSTFIX$";
}

3
ILSpy/Search/AbstractSearchStrategy.cs

@ -188,7 +188,8 @@ namespace ICSharpCode.ILSpy.Search @@ -188,7 +188,8 @@ namespace ICSharpCode.ILSpy.Search
Image = GetIcon(item),
Name = GetLanguageSpecificName(item),
LocationImage = declaringType != null ? TypeTreeNode.GetIcon(declaringType) : Images.Namespace,
Location = declaringType != null ? language.TypeToString(declaringType, includeNamespace: true) : item.Namespace
Location = declaringType != null ? language.TypeToString(declaringType, includeNamespace: true) : item.Namespace,
ToolTip = item.ParentModule.PEFile?.FileName
};
}
}

1
ILSpy/Search/SearchPane.cs

@ -336,6 +336,7 @@ namespace ICSharpCode.ILSpy @@ -336,6 +336,7 @@ namespace ICSharpCode.ILSpy
public string Location { get; set; }
public string Name { get; set; }
public object ToolTip { get; set; }
public ImageSource Image { get; set; }
public ImageSource LocationImage { get; set; }

2
ILSpy/Search/SearchPane.xaml

@ -45,7 +45,7 @@ @@ -45,7 +45,7 @@
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Height="16" Margin="0,0,4,0" Width="16" Source="{Binding Image}" />
<TextBlock Text="{Binding Name}" TextTrimming="CharacterEllipsis" />
<TextBlock Text="{Binding Name}" ToolTip="{Binding ToolTip}" TextTrimming="CharacterEllipsis" />
</StackPanel>
</DataTemplate>
</controls:SortableGridViewColumn.CellTemplate>

89
ILSpy/TreeNodes/AssemblyTreeNode.cs

@ -434,4 +434,93 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -434,4 +434,93 @@ namespace ICSharpCode.ILSpy.TreeNodes
MainWindow.Instance.CurrentAssemblyList.RefreshSave();
}
}
[ExportContextMenuEntry(Header = "_Open Containing Folder", Category = "Shell")]
sealed class OpenContainingFolder : IContextMenuEntry
{
public bool IsVisible(TextViewContext context)
{
if (context.SelectedTreeNodes == null)
return false;
return context.SelectedTreeNodes
.All(n => {
var a = GetAssemblyTreeNode(n);
return a != null && File.Exists(a.LoadedAssembly.FileName);
});
}
internal static AssemblyTreeNode GetAssemblyTreeNode(SharpTreeNode node)
{
while (node != null) {
if (node is AssemblyTreeNode a)
return a;
node = node.Parent;
}
return null;
}
public bool IsEnabled(TextViewContext context)
{
if (context.SelectedTreeNodes == null)
return false;
return context.SelectedTreeNodes
.All(n => {
var a = GetAssemblyTreeNode(n);
return a != null && File.Exists(a.LoadedAssembly.FileName);
});
}
public void Execute(TextViewContext context)
{
if (context.SelectedTreeNodes == null)
return;
foreach (var n in context.SelectedTreeNodes) {
var node = GetAssemblyTreeNode(n);
var path = node.LoadedAssembly.FileName;
if (File.Exists(path)) {
MainWindow.ExecuteCommand("explorer.exe", $"/select,\"{path}\"");
}
}
}
}
[ExportContextMenuEntry(Header = "_Open Command Line Here", Category = "Shell")]
sealed class OpenCmdHere : IContextMenuEntry
{
public bool IsVisible(TextViewContext context)
{
if (context.SelectedTreeNodes == null)
return false;
return context.SelectedTreeNodes
.All(n => {
var a = OpenContainingFolder.GetAssemblyTreeNode(n);
return a != null && File.Exists(a.LoadedAssembly.FileName);
});
}
public bool IsEnabled(TextViewContext context)
{
if (context.SelectedTreeNodes == null)
return false;
return context.SelectedTreeNodes
.All(n => {
var a = OpenContainingFolder.GetAssemblyTreeNode(n);
return a != null && File.Exists(a.LoadedAssembly.FileName);
});
}
public void Execute(TextViewContext context)
{
if (context.SelectedTreeNodes == null)
return;
foreach (var n in context.SelectedTreeNodes) {
var node = OpenContainingFolder.GetAssemblyTreeNode(n);
var path = Path.GetDirectoryName(node.LoadedAssembly.FileName);
if (Directory.Exists(path)) {
MainWindow.ExecuteCommand("cmd.exe", $"/k \"cd {path}\"");
}
}
}
}
}

Loading…
Cancel
Save