mirror of https://github.com/icsharpcode/ILSpy.git
352 changed files with 10352 additions and 5272 deletions
@ -0,0 +1,129 @@
@@ -0,0 +1,129 @@
|
||||
@{ |
||||
# Script module or binary module file associated with this manifest. |
||||
RootModule = 'ICSharpCode.Decompiler.PowerShell.dll' |
||||
|
||||
# Version number of this module. |
||||
ModuleVersion = '8.0.0.0' |
||||
|
||||
# Supported PSEditions |
||||
# CompatiblePSEditions = @() |
||||
|
||||
# ID used to uniquely identify this module |
||||
GUID = '198b4312-cbe7-417e-81a7-1aaff467ef06' |
||||
|
||||
# Author of this module |
||||
Author = 'ILSpy Contributors' |
||||
|
||||
# Company or vendor of this module |
||||
CompanyName = 'ic#code' |
||||
|
||||
# Copyright statement for this module |
||||
Copyright = 'Copyright 2011-2023 AlphaSierraPapa' |
||||
|
||||
# Description of the functionality provided by this module |
||||
Description = 'PowerShell front-end for ILSpy' |
||||
|
||||
# Minimum version of the PowerShell engine required by this module |
||||
# PowerShellVersion = '' |
||||
|
||||
# Name of the PowerShell host required by this module |
||||
# PowerShellHostName = '' |
||||
|
||||
# Minimum version of the PowerShell host required by this module |
||||
# PowerShellHostVersion = '' |
||||
|
||||
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. |
||||
# DotNetFrameworkVersion = '' |
||||
|
||||
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. |
||||
# ClrVersion = '' |
||||
|
||||
# Processor architecture (None, X86, Amd64) required by this module |
||||
# ProcessorArchitecture = '' |
||||
|
||||
# Modules that must be imported into the global environment prior to importing this module |
||||
# RequiredModules = @() |
||||
|
||||
# Assemblies that must be loaded prior to importing this module |
||||
# RequiredAssemblies = @() |
||||
|
||||
# Script files (.ps1) that are run in the caller's environment prior to importing this module. |
||||
# ScriptsToProcess = @() |
||||
|
||||
# Type files (.ps1xml) to be loaded when importing this module |
||||
# TypesToProcess = @() |
||||
|
||||
# Format files (.ps1xml) to be loaded when importing this module |
||||
# FormatsToProcess = @() |
||||
|
||||
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess |
||||
# NestedModules = @() |
||||
|
||||
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. |
||||
FunctionsToExport = @() |
||||
|
||||
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. |
||||
CmdletsToExport = @( |
||||
'Get-DecompiledProject', |
||||
'Get-DecompiledSource', |
||||
'Get-DecompiledTypes', |
||||
'Get-Decompiler', |
||||
'Get-DecompilerVersion' |
||||
) |
||||
|
||||
# Variables to export from this module |
||||
VariablesToExport = '*' |
||||
|
||||
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. |
||||
AliasesToExport = @() |
||||
|
||||
# DSC resources to export from this module |
||||
# DscResourcesToExport = @() |
||||
|
||||
# List of all modules packaged with this module |
||||
# ModuleList = @() |
||||
|
||||
# List of all files packaged with this module |
||||
# FileList = @() |
||||
|
||||
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. |
||||
PrivateData = @{ |
||||
|
||||
PSData = @{ |
||||
|
||||
# Tags applied to this module. These help with module discovery in online galleries. |
||||
# Tags = @() |
||||
|
||||
# A URL to the license for this module. |
||||
# LicenseUri = '' |
||||
|
||||
# A URL to the main website for this project. |
||||
ProjectUri = 'https://github.com/icsharpcode/ILSpy' |
||||
|
||||
# A URL to an icon representing this module. |
||||
# IconUri = '' |
||||
|
||||
# ReleaseNotes of this module |
||||
# ReleaseNotes = '' |
||||
|
||||
# Prerelease string of this module |
||||
# Prerelease = '' |
||||
|
||||
# Flag to indicate whether the module requires explicit user acceptance for install/update/save |
||||
# RequireLicenseAcceptance = $false |
||||
|
||||
# External dependent modules of this module |
||||
# ExternalModuleDependencies = @() |
||||
|
||||
} # End of PSData hashtable |
||||
|
||||
} # End of PrivateData hashtable |
||||
|
||||
# HelpInfo URI of this module |
||||
# HelpInfoURI = '' |
||||
|
||||
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. |
||||
# DefaultCommandPrefix = '' |
||||
|
||||
} |
||||
|
@ -0,0 +1,2 @@
@@ -0,0 +1,2 @@
|
||||
*.result.il |
||||
*.dll |
@ -0,0 +1,75 @@
@@ -0,0 +1,75 @@
|
||||
.assembly extern mscorlib |
||||
{ |
||||
.publickeytoken = ( |
||||
b7 7a 5c 56 19 34 e0 89 |
||||
) |
||||
.ver 4:0:0:0 |
||||
} |
||||
.assembly InterfaceImplAttributes |
||||
{ |
||||
.custom instance void [mscorlib]System.Reflection.AssemblyFileVersionAttribute::.ctor(string) = ( |
||||
01 00 07 31 2e 30 2e 30 2e 30 00 00 |
||||
) |
||||
.hash algorithm 0x00008004 // SHA1 |
||||
.ver 1:0:0:0 |
||||
} |
||||
|
||||
.module InterfaceImplAttributes.dll |
||||
.imagebase 0x10000000 |
||||
.file alignment 0x00000200 |
||||
.stackreserve 0x00100000 |
||||
.subsystem 0x0003 // WindowsCui |
||||
.corflags 0x00000001 // ILOnly |
||||
|
||||
.class private auto ansi '<Module>' |
||||
{ |
||||
} // end of class <Module> |
||||
|
||||
.class public auto ansi beforefieldinit TestType |
||||
extends [mscorlib]System.Object |
||||
implements ITestInterfaceA |
||||
{ |
||||
.interfaceimpl type ITestInterfaceA |
||||
.custom instance void TestAttributeA::.ctor() = ( |
||||
01 00 00 00 |
||||
) |
||||
|
||||
// Methods |
||||
.method public hidebysig specialname rtspecialname |
||||
instance void .ctor () cil managed |
||||
{ |
||||
// Method begins at RVA 0x2050 |
||||
// Header size: 1 |
||||
// Code size: 7 (0x7) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: call instance void [mscorlib]System.Object::.ctor() |
||||
IL_0006: ret |
||||
} // end of method TestType::.ctor |
||||
|
||||
} // end of class TestType |
||||
|
||||
.class interface public auto ansi abstract ITestInterfaceA |
||||
{ |
||||
} // end of class ITestInterfaceA |
||||
|
||||
.class public auto ansi beforefieldinit TestAttributeA |
||||
extends [mscorlib]System.Attribute |
||||
{ |
||||
// Methods |
||||
.method public hidebysig specialname rtspecialname |
||||
instance void .ctor () cil managed |
||||
{ |
||||
// Method begins at RVA 0x2058 |
||||
// Header size: 1 |
||||
// Code size: 7 (0x7) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: call instance void [mscorlib]System.Attribute::.ctor() |
||||
IL_0006: ret |
||||
} // end of method TestAttributeA::.ctor |
||||
|
||||
} // end of class TestAttributeA |
||||
|
@ -0,0 +1,395 @@
@@ -0,0 +1,395 @@
|
||||
.assembly extern mscorlib |
||||
{ |
||||
.publickeytoken = ( |
||||
b7 7a 5c 56 19 34 e0 89 |
||||
) |
||||
.ver 4:0:0:0 |
||||
} |
||||
.assembly SecurityDeclarations |
||||
{ |
||||
.custom instance void [mscorlib]System.Reflection.AssemblyFileVersionAttribute::.ctor(string) = ( |
||||
01 00 07 31 2e 30 2e 30 2e 30 00 00 |
||||
) |
||||
.hash algorithm 0x00008004 // SHA1 |
||||
.ver 1:0:0:0 |
||||
} |
||||
|
||||
.module SecurityDeclarations.dll |
||||
.imagebase 0x10000000 |
||||
.file alignment 0x00000200 |
||||
.stackreserve 0x00100000 |
||||
.subsystem 0x0003 // WindowsCui |
||||
.corflags 0x00000001 // ILOnly |
||||
|
||||
.class private auto ansi '<Module>' |
||||
{ |
||||
} // end of class <Module> |
||||
|
||||
.class private auto ansi beforefieldinit SecurityDeclarations.NestedArrays |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
.permissionset assert = { |
||||
class 'SecurityDeclarations.SecurityAttrTest, SecurityDeclarations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' = { |
||||
field object TestBoxed2 = object(object[4](int32(1) int32(2) int32(3) object[3](int32(4) int32(5) int32(6)))) |
||||
} |
||||
} |
||||
// Methods |
||||
.method public hidebysig specialname rtspecialname |
||||
instance void .ctor () cil managed |
||||
{ |
||||
// Method begins at RVA 0x20d4 |
||||
// Header size: 1 |
||||
// Code size: 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: call instance void [mscorlib]System.Object::.ctor() |
||||
IL_0006: nop |
||||
IL_0007: ret |
||||
} // end of method NestedArrays::.ctor |
||||
|
||||
} // end of class SecurityDeclarations.NestedArrays |
||||
|
||||
.class private auto ansi beforefieldinit SecurityDeclarations.SecurityAttrTest |
||||
extends [mscorlib]System.Security.Permissions.SecurityAttribute |
||||
{ |
||||
// Fields |
||||
.field private valuetype SecurityDeclarations.TestEnum[] _testEnumArray |
||||
.field private int32[] _testInt32Array |
||||
.field private string[] _testStringArray |
||||
.field private class [mscorlib]System.Type[] _testTypeArray |
||||
.field public object TestBoxed |
||||
.field public object TestBoxed2 |
||||
.field public object TestBoxedArray |
||||
.field public object TestBoxedString |
||||
.field public object TestBoxedType |
||||
.field public valuetype SecurityDeclarations.TestEnum TestEnumType |
||||
.field public int32 TestInt32 |
||||
.field public string TestString |
||||
.field public class [mscorlib]System.Type TestType |
||||
|
||||
// Methods |
||||
.method public hidebysig specialname rtspecialname |
||||
instance void .ctor ( |
||||
valuetype [mscorlib]System.Security.Permissions.SecurityAction action |
||||
) cil managed |
||||
{ |
||||
// Method begins at RVA 0x2059 |
||||
// Header size: 1 |
||||
// Code size: 10 (0xa) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldarg.1 |
||||
IL_0002: call instance void [mscorlib]System.Security.Permissions.SecurityAttribute::.ctor(valuetype [mscorlib]System.Security.Permissions.SecurityAction) |
||||
IL_0007: nop |
||||
IL_0008: nop |
||||
IL_0009: ret |
||||
} // end of method SecurityAttrTest::.ctor |
||||
|
||||
.method public hidebysig virtual |
||||
instance class [mscorlib]System.Security.IPermission CreatePermission () cil managed |
||||
{ |
||||
// Method begins at RVA 0x2064 |
||||
// Header size: 1 |
||||
// Code size: 7 (0x7) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: nop |
||||
IL_0001: newobj instance void [mscorlib]System.NotImplementedException::.ctor() |
||||
IL_0006: throw |
||||
} // end of method SecurityAttrTest::CreatePermission |
||||
|
||||
.method public hidebysig specialname |
||||
instance valuetype SecurityDeclarations.TestEnum[] get_TestEnumArray () cil managed |
||||
{ |
||||
// Method begins at RVA 0x208e |
||||
// Header size: 1 |
||||
// Code size: 7 (0x7) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldfld valuetype SecurityDeclarations.TestEnum[] SecurityDeclarations.SecurityAttrTest::_testEnumArray |
||||
IL_0006: ret |
||||
} // end of method SecurityAttrTest::get_TestEnumArray |
||||
|
||||
.method public hidebysig specialname |
||||
instance int32[] get_TestInt32Array () cil managed |
||||
{ |
||||
// Method begins at RVA 0x207d |
||||
// Header size: 1 |
||||
// Code size: 7 (0x7) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldfld int32[] SecurityDeclarations.SecurityAttrTest::_testInt32Array |
||||
IL_0006: ret |
||||
} // end of method SecurityAttrTest::get_TestInt32Array |
||||
|
||||
.method public hidebysig specialname |
||||
instance string[] get_TestStringArray () cil managed |
||||
{ |
||||
// Method begins at RVA 0x206c |
||||
// Header size: 1 |
||||
// Code size: 7 (0x7) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldfld string[] SecurityDeclarations.SecurityAttrTest::_testStringArray |
||||
IL_0006: ret |
||||
} // end of method SecurityAttrTest::get_TestStringArray |
||||
|
||||
.method public hidebysig specialname |
||||
instance class [mscorlib]System.Type[] get_TestTypeArray () cil managed |
||||
{ |
||||
// Method begins at RVA 0x209f |
||||
// Header size: 1 |
||||
// Code size: 7 (0x7) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldfld class [mscorlib]System.Type[] SecurityDeclarations.SecurityAttrTest::_testTypeArray |
||||
IL_0006: ret |
||||
} // end of method SecurityAttrTest::get_TestTypeArray |
||||
|
||||
.method public hidebysig specialname |
||||
instance void set_TestEnumArray ( |
||||
valuetype SecurityDeclarations.TestEnum[] 'value' |
||||
) cil managed |
||||
{ |
||||
// Method begins at RVA 0x2096 |
||||
// Header size: 1 |
||||
// Code size: 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldarg.1 |
||||
IL_0002: stfld valuetype SecurityDeclarations.TestEnum[] SecurityDeclarations.SecurityAttrTest::_testEnumArray |
||||
IL_0007: ret |
||||
} // end of method SecurityAttrTest::set_TestEnumArray |
||||
|
||||
.method public hidebysig specialname |
||||
instance void set_TestInt32Array ( |
||||
int32[] 'value' |
||||
) cil managed |
||||
{ |
||||
// Method begins at RVA 0x2085 |
||||
// Header size: 1 |
||||
// Code size: 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldarg.1 |
||||
IL_0002: stfld int32[] SecurityDeclarations.SecurityAttrTest::_testInt32Array |
||||
IL_0007: ret |
||||
} // end of method SecurityAttrTest::set_TestInt32Array |
||||
|
||||
.method public hidebysig specialname |
||||
instance void set_TestStringArray ( |
||||
string[] 'value' |
||||
) cil managed |
||||
{ |
||||
// Method begins at RVA 0x2074 |
||||
// Header size: 1 |
||||
// Code size: 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldarg.1 |
||||
IL_0002: stfld string[] SecurityDeclarations.SecurityAttrTest::_testStringArray |
||||
IL_0007: ret |
||||
} // end of method SecurityAttrTest::set_TestStringArray |
||||
|
||||
.method public hidebysig specialname |
||||
instance void set_TestTypeArray ( |
||||
class [mscorlib]System.Type[] 'value' |
||||
) cil managed |
||||
{ |
||||
// Method begins at RVA 0x20a7 |
||||
// Header size: 1 |
||||
// Code size: 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldarg.1 |
||||
IL_0002: stfld class [mscorlib]System.Type[] SecurityDeclarations.SecurityAttrTest::_testTypeArray |
||||
IL_0007: ret |
||||
} // end of method SecurityAttrTest::set_TestTypeArray |
||||
|
||||
// Properties |
||||
.property instance valuetype SecurityDeclarations.TestEnum[] TestEnumArray() |
||||
{ |
||||
.get instance valuetype SecurityDeclarations.TestEnum[] SecurityDeclarations.SecurityAttrTest::get_TestEnumArray() |
||||
.set instance void SecurityDeclarations.SecurityAttrTest::set_TestEnumArray(valuetype SecurityDeclarations.TestEnum[]) |
||||
} |
||||
.property instance int32[] TestInt32Array() |
||||
{ |
||||
.get instance int32[] SecurityDeclarations.SecurityAttrTest::get_TestInt32Array() |
||||
.set instance void SecurityDeclarations.SecurityAttrTest::set_TestInt32Array(int32[]) |
||||
} |
||||
.property instance string[] TestStringArray() |
||||
{ |
||||
.get instance string[] SecurityDeclarations.SecurityAttrTest::get_TestStringArray() |
||||
.set instance void SecurityDeclarations.SecurityAttrTest::set_TestStringArray(string[]) |
||||
} |
||||
.property instance class [mscorlib]System.Type[] TestTypeArray() |
||||
{ |
||||
.get instance class [mscorlib]System.Type[] SecurityDeclarations.SecurityAttrTest::get_TestTypeArray() |
||||
.set instance void SecurityDeclarations.SecurityAttrTest::set_TestTypeArray(class [mscorlib]System.Type[]) |
||||
} |
||||
|
||||
} // end of class SecurityDeclarations.SecurityAttrTest |
||||
|
||||
.class private auto ansi beforefieldinit SecurityDeclarations.SimpleType |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
// Methods |
||||
.method public hidebysig specialname rtspecialname |
||||
instance void .ctor () cil managed |
||||
{ |
||||
// Method begins at RVA 0x2050 |
||||
// Header size: 1 |
||||
// Code size: 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: call instance void [mscorlib]System.Object::.ctor() |
||||
IL_0006: nop |
||||
IL_0007: ret |
||||
} // end of method SimpleType::.ctor |
||||
|
||||
} // end of class SecurityDeclarations.SimpleType |
||||
|
||||
.class private auto ansi sealed SecurityDeclarations.TestEnum |
||||
extends [mscorlib]System.Enum |
||||
{ |
||||
// Fields |
||||
.field public static literal valuetype SecurityDeclarations.TestEnum A = int32(0) |
||||
.field public static literal valuetype SecurityDeclarations.TestEnum B = int32(1) |
||||
.field public static literal valuetype SecurityDeclarations.TestEnum C = int32(2) |
||||
.field public specialname rtspecialname int32 value__ |
||||
|
||||
} // end of class SecurityDeclarations.TestEnum |
||||
|
||||
.class private auto ansi beforefieldinit SecurityDeclarations.TestEnumTypes |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
.permissionset inheritcheck = { |
||||
class 'SecurityDeclarations.SecurityAttrTest, SecurityDeclarations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' = { |
||||
field enum SecurityDeclarations.TestEnum TestEnumType = int32(0) |
||||
field object TestBoxed = object(int32(1)) |
||||
property enum SecurityDeclarations.TestEnum[] TestEnumArray = int32[3](0 1 2) |
||||
field object TestBoxed2 = object(object[4](int32(0) int32(1) int32(2) object[1](int32(3)))) |
||||
field object TestBoxedArray = object(int32[3](0 1 2)) |
||||
} |
||||
} |
||||
// Methods |
||||
.method public hidebysig specialname rtspecialname |
||||
instance void .ctor () cil managed |
||||
{ |
||||
// Method begins at RVA 0x20c2 |
||||
// Header size: 1 |
||||
// Code size: 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: call instance void [mscorlib]System.Object::.ctor() |
||||
IL_0006: nop |
||||
IL_0007: ret |
||||
} // end of method TestEnumTypes::.ctor |
||||
|
||||
} // end of class SecurityDeclarations.TestEnumTypes |
||||
|
||||
.class private auto ansi beforefieldinit SecurityDeclarations.TestInt32Types |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
.permissionset permitonly = { |
||||
class 'SecurityDeclarations.SecurityAttrTest, SecurityDeclarations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' = { |
||||
field int32 TestInt32 = int32(5) |
||||
field object TestBoxed = object(int32(10)) |
||||
property int32[] TestInt32Array = int32[3](1 2 3) |
||||
field object TestBoxedArray = object(int32[3](4 5 6)) |
||||
field object TestBoxed2 = object(object[3](int32(7) int32(8) int32(9))) |
||||
} |
||||
} |
||||
// Methods |
||||
.method public hidebysig specialname rtspecialname |
||||
instance void .ctor () cil managed |
||||
{ |
||||
// Method begins at RVA 0x20cb |
||||
// Header size: 1 |
||||
// Code size: 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: call instance void [mscorlib]System.Object::.ctor() |
||||
IL_0006: nop |
||||
IL_0007: ret |
||||
} // end of method TestInt32Types::.ctor |
||||
|
||||
} // end of class SecurityDeclarations.TestInt32Types |
||||
|
||||
.class private auto ansi beforefieldinit SecurityDeclarations.TestStringTypes |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
.permissionset assert = { |
||||
class 'SecurityDeclarations.SecurityAttrTest, SecurityDeclarations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' = { |
||||
field string TestString = string('Hello World!') |
||||
field object TestBoxedString = object(string('Boxed String')) |
||||
property string[] TestStringArray = string[2]('a' 'b') |
||||
field object TestBoxedArray = object(string[2]('c' 'd')) |
||||
} |
||||
} |
||||
// Methods |
||||
.method public hidebysig specialname rtspecialname |
||||
instance void .ctor () cil managed |
||||
{ |
||||
// Method begins at RVA 0x20b0 |
||||
// Header size: 1 |
||||
// Code size: 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: call instance void [mscorlib]System.Object::.ctor() |
||||
IL_0006: nop |
||||
IL_0007: ret |
||||
} // end of method TestStringTypes::.ctor |
||||
|
||||
} // end of class SecurityDeclarations.TestStringTypes |
||||
|
||||
.class private sequential ansi sealed beforefieldinit SecurityDeclarations.TestStruct |
||||
extends [mscorlib]System.ValueType |
||||
{ |
||||
.pack 0 |
||||
.size 1 |
||||
|
||||
} // end of class SecurityDeclarations.TestStruct |
||||
|
||||
.class private auto ansi beforefieldinit SecurityDeclarations.TestTypeTypes |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
.permissionset demand = { |
||||
class 'SecurityDeclarations.SecurityAttrTest, SecurityDeclarations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' = { |
||||
field type TestType = type(SecurityDeclarations.SimpleType) |
||||
field object TestBoxed = object(type(SecurityDeclarations.TestEnum)) |
||||
property type[] TestTypeArray = type[2](SecurityDeclarations.TestStruct SecurityDeclarations.SimpleType) |
||||
field object TestBoxedArray = object(type[2](SecurityDeclarations.TestStringTypes SecurityDeclarations.TestTypeTypes)) |
||||
} |
||||
} |
||||
// Methods |
||||
.method public hidebysig specialname rtspecialname |
||||
instance void .ctor () cil managed |
||||
{ |
||||
// Method begins at RVA 0x20b9 |
||||
// Header size: 1 |
||||
// Code size: 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: call instance void [mscorlib]System.Object::.ctor() |
||||
IL_0006: nop |
||||
IL_0007: ret |
||||
} // end of method TestTypeTypes::.ctor |
||||
|
||||
} // end of class SecurityDeclarations.TestTypeTypes |
||||
|
@ -0,0 +1,381 @@
@@ -0,0 +1,381 @@
|
||||
.assembly extern mscorlib |
||||
{ |
||||
.publickeytoken = ( |
||||
b7 7a 5c 56 19 34 e0 89 |
||||
) |
||||
.ver 4:0:0:0 |
||||
} |
||||
.assembly SecurityDeclarations |
||||
{ |
||||
.custom instance void [mscorlib]System.Reflection.AssemblyFileVersionAttribute::.ctor(string) = ( |
||||
01 00 07 31 2e 30 2e 30 2e 30 00 00 |
||||
) |
||||
.hash algorithm 0x00008004 // SHA1 |
||||
.ver 1:0:0:0 |
||||
} |
||||
|
||||
.module SecurityDeclarations.dll |
||||
// MVID: {761F919A-2373-48EB-9282-9DAB26913D43} |
||||
.imagebase 0x10000000 |
||||
.file alignment 0x00000200 |
||||
.stackreserve 0x00100000 |
||||
.subsystem 0x0003 // WindowsCui |
||||
.corflags 0x00000001 // ILOnly |
||||
|
||||
|
||||
.class private auto ansi '<Module>' |
||||
{ |
||||
} // end of class <Module> |
||||
|
||||
.class private sequential ansi sealed beforefieldinit SecurityDeclarations.TestStruct |
||||
extends [mscorlib]System.ValueType |
||||
{ |
||||
.pack 0 |
||||
.size 1 |
||||
|
||||
} // end of class SecurityDeclarations.TestStruct |
||||
|
||||
.class private auto ansi beforefieldinit SecurityDeclarations.SimpleType |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
// Methods |
||||
.method public hidebysig specialname rtspecialname |
||||
instance void .ctor () cil managed |
||||
{ |
||||
// Method begins at RVA 0x2050 |
||||
// Code size 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: call instance void [mscorlib]System.Object::.ctor() |
||||
IL_0006: nop |
||||
IL_0007: ret |
||||
} // end of method SimpleType::.ctor |
||||
|
||||
} // end of class SecurityDeclarations.SimpleType |
||||
|
||||
.class private auto ansi sealed SecurityDeclarations.TestEnum |
||||
extends [mscorlib]System.Enum |
||||
{ |
||||
// Fields |
||||
.field public specialname rtspecialname int32 value__ |
||||
.field public static literal valuetype SecurityDeclarations.TestEnum A = int32(0) |
||||
.field public static literal valuetype SecurityDeclarations.TestEnum B = int32(1) |
||||
.field public static literal valuetype SecurityDeclarations.TestEnum C = int32(2) |
||||
|
||||
} // end of class SecurityDeclarations.TestEnum |
||||
|
||||
.class private auto ansi beforefieldinit SecurityDeclarations.SecurityAttrTest |
||||
extends [mscorlib]System.Security.Permissions.SecurityAttribute |
||||
{ |
||||
// Fields |
||||
.field private string[] _testStringArray |
||||
.field private int32[] _testInt32Array |
||||
.field private valuetype SecurityDeclarations.TestEnum[] _testEnumArray |
||||
.field private class [mscorlib]System.Type[] _testTypeArray |
||||
.field public int32 TestInt32 |
||||
.field public class [mscorlib]System.Type TestType |
||||
.field public valuetype SecurityDeclarations.TestEnum TestEnumType |
||||
.field public object TestBoxed |
||||
.field public object TestBoxed2 |
||||
.field public string TestString |
||||
.field public object TestBoxedString |
||||
.field public object TestBoxedArray |
||||
.field public object TestBoxedType |
||||
|
||||
// Methods |
||||
.method public hidebysig specialname rtspecialname |
||||
instance void .ctor ( |
||||
valuetype [mscorlib]System.Security.Permissions.SecurityAction action |
||||
) cil managed |
||||
{ |
||||
// Method begins at RVA 0x2059 |
||||
// Code size 10 (0xa) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldarg.1 |
||||
IL_0002: call instance void [mscorlib]System.Security.Permissions.SecurityAttribute::.ctor(valuetype [mscorlib]System.Security.Permissions.SecurityAction) |
||||
IL_0007: nop |
||||
IL_0008: nop |
||||
IL_0009: ret |
||||
} // end of method SecurityAttrTest::.ctor |
||||
|
||||
.method public hidebysig virtual |
||||
instance class [mscorlib]System.Security.IPermission CreatePermission () cil managed |
||||
{ |
||||
// Method begins at RVA 0x2064 |
||||
// Code size 7 (0x7) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: nop |
||||
IL_0001: newobj instance void [mscorlib]System.NotImplementedException::.ctor() |
||||
IL_0006: throw |
||||
} // end of method SecurityAttrTest::CreatePermission |
||||
|
||||
.method public hidebysig specialname |
||||
instance string[] get_TestStringArray () cil managed |
||||
{ |
||||
// Method begins at RVA 0x206c |
||||
// Code size 7 (0x7) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldfld string[] SecurityDeclarations.SecurityAttrTest::_testStringArray |
||||
IL_0006: ret |
||||
} // end of method SecurityAttrTest::get_TestStringArray |
||||
|
||||
.method public hidebysig specialname |
||||
instance void set_TestStringArray ( |
||||
string[] 'value' |
||||
) cil managed |
||||
{ |
||||
// Method begins at RVA 0x2074 |
||||
// Code size 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldarg.1 |
||||
IL_0002: stfld string[] SecurityDeclarations.SecurityAttrTest::_testStringArray |
||||
IL_0007: ret |
||||
} // end of method SecurityAttrTest::set_TestStringArray |
||||
|
||||
.method public hidebysig specialname |
||||
instance int32[] get_TestInt32Array () cil managed |
||||
{ |
||||
// Method begins at RVA 0x207d |
||||
// Code size 7 (0x7) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldfld int32[] SecurityDeclarations.SecurityAttrTest::_testInt32Array |
||||
IL_0006: ret |
||||
} // end of method SecurityAttrTest::get_TestInt32Array |
||||
|
||||
.method public hidebysig specialname |
||||
instance void set_TestInt32Array ( |
||||
int32[] 'value' |
||||
) cil managed |
||||
{ |
||||
// Method begins at RVA 0x2085 |
||||
// Code size 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldarg.1 |
||||
IL_0002: stfld int32[] SecurityDeclarations.SecurityAttrTest::_testInt32Array |
||||
IL_0007: ret |
||||
} // end of method SecurityAttrTest::set_TestInt32Array |
||||
|
||||
.method public hidebysig specialname |
||||
instance valuetype SecurityDeclarations.TestEnum[] get_TestEnumArray () cil managed |
||||
{ |
||||
// Method begins at RVA 0x208e |
||||
// Code size 7 (0x7) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldfld valuetype SecurityDeclarations.TestEnum[] SecurityDeclarations.SecurityAttrTest::_testEnumArray |
||||
IL_0006: ret |
||||
} // end of method SecurityAttrTest::get_TestEnumArray |
||||
|
||||
.method public hidebysig specialname |
||||
instance void set_TestEnumArray ( |
||||
valuetype SecurityDeclarations.TestEnum[] 'value' |
||||
) cil managed |
||||
{ |
||||
// Method begins at RVA 0x2096 |
||||
// Code size 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldarg.1 |
||||
IL_0002: stfld valuetype SecurityDeclarations.TestEnum[] SecurityDeclarations.SecurityAttrTest::_testEnumArray |
||||
IL_0007: ret |
||||
} // end of method SecurityAttrTest::set_TestEnumArray |
||||
|
||||
.method public hidebysig specialname |
||||
instance class [mscorlib]System.Type[] get_TestTypeArray () cil managed |
||||
{ |
||||
// Method begins at RVA 0x209f |
||||
// Code size 7 (0x7) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldfld class [mscorlib]System.Type[] SecurityDeclarations.SecurityAttrTest::_testTypeArray |
||||
IL_0006: ret |
||||
} // end of method SecurityAttrTest::get_TestTypeArray |
||||
|
||||
.method public hidebysig specialname |
||||
instance void set_TestTypeArray ( |
||||
class [mscorlib]System.Type[] 'value' |
||||
) cil managed |
||||
{ |
||||
// Method begins at RVA 0x20a7 |
||||
// Code size 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldarg.1 |
||||
IL_0002: stfld class [mscorlib]System.Type[] SecurityDeclarations.SecurityAttrTest::_testTypeArray |
||||
IL_0007: ret |
||||
} // end of method SecurityAttrTest::set_TestTypeArray |
||||
|
||||
// Properties |
||||
.property instance string[] TestStringArray() |
||||
{ |
||||
.get instance string[] SecurityDeclarations.SecurityAttrTest::get_TestStringArray() |
||||
.set instance void SecurityDeclarations.SecurityAttrTest::set_TestStringArray(string[]) |
||||
} |
||||
.property instance int32[] TestInt32Array() |
||||
{ |
||||
.get instance int32[] SecurityDeclarations.SecurityAttrTest::get_TestInt32Array() |
||||
.set instance void SecurityDeclarations.SecurityAttrTest::set_TestInt32Array(int32[]) |
||||
} |
||||
.property instance valuetype SecurityDeclarations.TestEnum[] TestEnumArray() |
||||
{ |
||||
.get instance valuetype SecurityDeclarations.TestEnum[] SecurityDeclarations.SecurityAttrTest::get_TestEnumArray() |
||||
.set instance void SecurityDeclarations.SecurityAttrTest::set_TestEnumArray(valuetype SecurityDeclarations.TestEnum[]) |
||||
} |
||||
.property instance class [mscorlib]System.Type[] TestTypeArray() |
||||
{ |
||||
.get instance class [mscorlib]System.Type[] SecurityDeclarations.SecurityAttrTest::get_TestTypeArray() |
||||
.set instance void SecurityDeclarations.SecurityAttrTest::set_TestTypeArray(class [mscorlib]System.Type[]) |
||||
} |
||||
|
||||
} // end of class SecurityDeclarations.SecurityAttrTest |
||||
|
||||
.class private auto ansi beforefieldinit SecurityDeclarations.TestStringTypes |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
.permissionset assert = { |
||||
class 'SecurityDeclarations.SecurityAttrTest, SecurityDeclarations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' = { |
||||
field string TestString = string('Hello World!') |
||||
field object TestBoxedString = object(string('Boxed String')) |
||||
property string[] TestStringArray = string[2]('a' 'b') |
||||
field object TestBoxedArray = object(string[2]('c' 'd')) |
||||
} |
||||
} |
||||
// Methods |
||||
.method public hidebysig specialname rtspecialname |
||||
instance void .ctor () cil managed |
||||
{ |
||||
// Method begins at RVA 0x2050 |
||||
// Code size 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: call instance void [mscorlib]System.Object::.ctor() |
||||
IL_0006: nop |
||||
IL_0007: ret |
||||
} // end of method TestStringTypes::.ctor |
||||
|
||||
} // end of class SecurityDeclarations.TestStringTypes |
||||
|
||||
.class private auto ansi beforefieldinit SecurityDeclarations.TestTypeTypes |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
.permissionset demand = { |
||||
class 'SecurityDeclarations.SecurityAttrTest, SecurityDeclarations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' = { |
||||
field type TestType = type(SecurityDeclarations.SimpleType) |
||||
field object TestBoxed = object(type(SecurityDeclarations.TestEnum)) |
||||
property type[] TestTypeArray = type[2](SecurityDeclarations.TestStruct SecurityDeclarations.SimpleType) |
||||
field object TestBoxedArray = object(type[2](SecurityDeclarations.TestStringTypes SecurityDeclarations.TestTypeTypes)) |
||||
} |
||||
} |
||||
// Methods |
||||
.method public hidebysig specialname rtspecialname |
||||
instance void .ctor () cil managed |
||||
{ |
||||
// Method begins at RVA 0x2050 |
||||
// Code size 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: call instance void [mscorlib]System.Object::.ctor() |
||||
IL_0006: nop |
||||
IL_0007: ret |
||||
} // end of method TestTypeTypes::.ctor |
||||
|
||||
} // end of class SecurityDeclarations.TestTypeTypes |
||||
|
||||
.class private auto ansi beforefieldinit SecurityDeclarations.TestEnumTypes |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
.permissionset inheritcheck = { |
||||
class 'SecurityDeclarations.SecurityAttrTest, SecurityDeclarations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' = { |
||||
field enum SecurityDeclarations.TestEnum TestEnumType = int32(0) |
||||
field object TestBoxed = object(int32(1)) |
||||
property enum SecurityDeclarations.TestEnum[] TestEnumArray = int32[3](0 1 2) |
||||
field object TestBoxed2 = object(object[4](int32(0) int32(1) int32(2) object[1](int32(3)))) |
||||
field object TestBoxedArray = object(int32[3](0 1 2)) |
||||
} |
||||
} |
||||
// Methods |
||||
.method public hidebysig specialname rtspecialname |
||||
instance void .ctor () cil managed |
||||
{ |
||||
// Method begins at RVA 0x2050 |
||||
// Code size 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: call instance void [mscorlib]System.Object::.ctor() |
||||
IL_0006: nop |
||||
IL_0007: ret |
||||
} // end of method TestEnumTypes::.ctor |
||||
|
||||
} // end of class SecurityDeclarations.TestEnumTypes |
||||
|
||||
.class private auto ansi beforefieldinit SecurityDeclarations.TestInt32Types |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
.permissionset permitonly = { |
||||
class 'SecurityDeclarations.SecurityAttrTest, SecurityDeclarations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' = { |
||||
field int32 TestInt32 = int32(5) |
||||
field object TestBoxed = object(int32(10)) |
||||
property int32[] TestInt32Array = int32[3](1 2 3) |
||||
field object TestBoxedArray = object(int32[3](4 5 6)) |
||||
field object TestBoxed2 = object(object[3](int32(7) int32(8) int32(9))) |
||||
} |
||||
} |
||||
// Methods |
||||
.method public hidebysig specialname rtspecialname |
||||
instance void .ctor () cil managed |
||||
{ |
||||
// Method begins at RVA 0x2050 |
||||
// Code size 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: call instance void [mscorlib]System.Object::.ctor() |
||||
IL_0006: nop |
||||
IL_0007: ret |
||||
} // end of method TestInt32Types::.ctor |
||||
|
||||
} // end of class SecurityDeclarations.TestInt32Types |
||||
|
||||
.class private auto ansi beforefieldinit SecurityDeclarations.NestedArrays |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
.permissionset assert = { |
||||
class 'SecurityDeclarations.SecurityAttrTest, SecurityDeclarations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' = { |
||||
field object TestBoxed2 = object(object[4](int32(1) int32(2) int32(3) object[3](int32(4) int32(5) int32(6)))) |
||||
} |
||||
} |
||||
// Methods |
||||
.method public hidebysig specialname rtspecialname |
||||
instance void .ctor () cil managed |
||||
{ |
||||
// Method begins at RVA 0x2050 |
||||
// Code size 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: call instance void [mscorlib]System.Object::.ctor() |
||||
IL_0006: nop |
||||
IL_0007: ret |
||||
} // end of method NestedArrays::.ctor |
||||
|
||||
} // end of class SecurityDeclarations.NestedArrays |
||||
|
@ -0,0 +1,14 @@
@@ -0,0 +1,14 @@
|
||||
internal class EmptyBodies |
||||
{ |
||||
public static void RetVoid() |
||||
{ |
||||
} |
||||
public static int RetInt() |
||||
{ |
||||
/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/; |
||||
} |
||||
public static void Nop() |
||||
{ |
||||
/*Error: End of method reached without returning.*/; |
||||
} |
||||
} |
@ -0,0 +1,45 @@
@@ -0,0 +1,45 @@
|
||||
#define CORE_ASSEMBLY "System.Runtime" |
||||
|
||||
.assembly extern CORE_ASSEMBLY |
||||
{ |
||||
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....: |
||||
.ver 4:0:0:0 |
||||
} |
||||
|
||||
.class private auto ansi beforefieldinit EmptyBodies |
||||
extends [CORE_ASSEMBLY]System.Object |
||||
{ |
||||
// I cannot test a truly empty body because the assembler will automatically add a ret instruction. |
||||
|
||||
.method public hidebysig static void RetVoid () cil managed |
||||
{ |
||||
.maxstack 8 |
||||
ret |
||||
} |
||||
|
||||
.method public hidebysig static int32 RetInt () cil managed |
||||
{ |
||||
.maxstack 8 |
||||
ret |
||||
} |
||||
|
||||
.method public hidebysig static void Nop () cil managed |
||||
{ |
||||
.maxstack 8 |
||||
nop |
||||
} |
||||
|
||||
.method public hidebysig specialname rtspecialname |
||||
instance void .ctor () cil managed |
||||
{ |
||||
// Method begins at RVA 0x206e |
||||
// Code size 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: call instance void [System.Private.CoreLib]System.Object::.ctor() |
||||
IL_0006: nop |
||||
IL_0007: ret |
||||
} // end of method Example::.ctor |
||||
|
||||
} // end of class EmptyBodies |
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<symbols> |
||||
<files> |
||||
<file id="1" name="ICSharpCode.Decompiler.Tests.TestCases.PdbGen\ProgressReporting.cs" language="C#" checksumAlgorithm="SHA256"> |
||||
<![CDATA[using System; |
||||
|
||||
namespace ICSharpCode.Decompiler.Tests.TestCases.PdbGen; |
||||
|
||||
public class ProgressReporting |
||||
{ |
||||
public static void Main(string[] args) |
||||
{ |
||||
Console.ReadKey(); |
||||
Console.WriteLine("Hello World!"); |
||||
Console.ReadKey(); |
||||
} |
||||
} |
||||
|
||||
public class Class1 |
||||
{ |
||||
public static void Test() |
||||
{ |
||||
Console.WriteLine("Class1"); |
||||
} |
||||
} |
||||
|
||||
public class Class2 |
||||
{ |
||||
public static void Test() |
||||
{ |
||||
Console.WriteLine("Class2"); |
||||
} |
||||
} |
||||
|
||||
public class Class3 |
||||
{ |
||||
public static void Test() |
||||
{ |
||||
Console.WriteLine("Class3"); |
||||
} |
||||
} |
||||
]]></file> |
||||
</files> |
||||
</symbols> |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,225 @@
@@ -0,0 +1,225 @@
|
||||
// Copyright (c) Daniel Grunwald
|
||||
//
|
||||
// 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; |
||||
|
||||
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty |
||||
{ |
||||
public class AllOperators |
||||
{ |
||||
public static AllOperators operator +(AllOperators a, AllOperators b) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public static AllOperators operator -(AllOperators a, AllOperators b) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public static AllOperators operator *(AllOperators a, AllOperators b) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public static AllOperators operator /(AllOperators a, AllOperators b) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public static AllOperators operator %(AllOperators a, AllOperators b) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public static AllOperators operator &(AllOperators a, AllOperators b) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public static AllOperators operator |(AllOperators a, AllOperators b) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public static AllOperators operator ^(AllOperators a, AllOperators b) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public static AllOperators operator <<(AllOperators a, int b) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public static AllOperators operator >>(AllOperators a, int b) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
#if CS110
|
||||
public static AllOperators operator >>>(AllOperators a, int b) |
||||
{ |
||||
return null; |
||||
} |
||||
#endif
|
||||
|
||||
public static AllOperators operator ~(AllOperators a) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public static AllOperators operator !(AllOperators a) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public static AllOperators operator -(AllOperators a) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public static AllOperators operator +(AllOperators a) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public static AllOperators operator ++(AllOperators a) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public static AllOperators operator --(AllOperators a) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public static bool operator true(AllOperators a) |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
public static bool operator false(AllOperators a) |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
public static bool operator ==(AllOperators a, AllOperators b) |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
public static bool operator !=(AllOperators a, AllOperators b) |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
public static bool operator <(AllOperators a, AllOperators b) |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
public static bool operator >(AllOperators a, AllOperators b) |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
public static bool operator <=(AllOperators a, AllOperators b) |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
public static bool operator >=(AllOperators a, AllOperators b) |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
public static implicit operator AllOperators(int a) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public static explicit operator int(AllOperators a) |
||||
{ |
||||
return 0; |
||||
} |
||||
} |
||||
|
||||
public class UseAllOperators |
||||
{ |
||||
private AllOperators a = new AllOperators(); |
||||
private AllOperators b = new AllOperators(); |
||||
private AllOperators c; |
||||
public void Test() |
||||
{ |
||||
c = a + b; |
||||
c = a - b; |
||||
c = a * b; |
||||
c = a / b; |
||||
c = a % b; |
||||
c = a & b; |
||||
c = a | b; |
||||
c = a ^ b; |
||||
c = a << 5; |
||||
c = a >> 5; |
||||
#if CS110
|
||||
c = a >>> 5; |
||||
#endif
|
||||
c = ~a; |
||||
c = !a; |
||||
c = -a; |
||||
c = +a; |
||||
c = ++a; |
||||
c = --a; |
||||
if (a) |
||||
{ |
||||
Console.WriteLine("a"); |
||||
} |
||||
if (!a) |
||||
{ |
||||
Console.WriteLine("!a"); |
||||
} |
||||
if (a == b) |
||||
{ |
||||
Console.WriteLine("a == b"); |
||||
} |
||||
if (a != b) |
||||
{ |
||||
Console.WriteLine("a != b"); |
||||
} |
||||
if (a < b) |
||||
{ |
||||
Console.WriteLine("a < b"); |
||||
} |
||||
if (a > b) |
||||
{ |
||||
Console.WriteLine("a > b"); |
||||
} |
||||
if (a <= b) |
||||
{ |
||||
Console.WriteLine("a <= b"); |
||||
} |
||||
if (a >= b) |
||||
{ |
||||
Console.WriteLine("a >= b"); |
||||
} |
||||
int num = (int)a; |
||||
a = num; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,87 @@
@@ -0,0 +1,87 @@
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty |
||||
{ |
||||
internal class LifetimeTests |
||||
{ |
||||
private static int staticField; |
||||
|
||||
public Span<int> CreateWithoutCapture(scoped ref int value) |
||||
{ |
||||
// Okay: value is not captured
|
||||
return new Span<int>(ref staticField); |
||||
} |
||||
|
||||
public Span<int> CreateAndCapture(ref int value) |
||||
{ |
||||
// Okay: value Rule 3 specifies that the safe-to-escape be limited to the ref-safe-to-escape
|
||||
// of the ref argument. That is the *calling method* for value hence this is not allowed.
|
||||
return new Span<int>(ref value); |
||||
} |
||||
|
||||
public Span<int> ScopedRefSpan(scoped ref Span<int> span) |
||||
{ |
||||
return span; |
||||
} |
||||
|
||||
public Span<int> ScopedSpan(scoped Span<int> span) |
||||
{ |
||||
return default(Span<int>); |
||||
} |
||||
|
||||
public void OutSpan(out Span<int> span) |
||||
{ |
||||
span = default(Span<int>); |
||||
} |
||||
|
||||
public void Calls() |
||||
{ |
||||
int value = 0; |
||||
Span<int> span = CreateWithoutCapture(ref value); |
||||
//span = CreateAndCapture(ref value); -- would need scoped local, not yet implemented
|
||||
span = ScopedRefSpan(ref span); |
||||
span = ScopedSpan(span); |
||||
OutSpan(out span); |
||||
} |
||||
} |
||||
|
||||
internal ref struct RefFields |
||||
{ |
||||
public ref int Field0; |
||||
public ref readonly int Field1; |
||||
public readonly ref int Field2; |
||||
public readonly ref readonly int Field3; |
||||
|
||||
public int PropertyAccessingRefFieldByValue { |
||||
get { |
||||
return Field0; |
||||
} |
||||
set { |
||||
Field0 = value; |
||||
} |
||||
} |
||||
|
||||
public ref int PropertyReturningRefFieldByReference => ref Field0; |
||||
|
||||
public void Uses(int[] array) |
||||
{ |
||||
Field1 = ref array[0]; |
||||
Field2 = array[0]; |
||||
} |
||||
|
||||
public void ReadonlyLocal() |
||||
{ |
||||
ref readonly int field = ref Field1; |
||||
Console.WriteLine("No inlining"); |
||||
field.ToString(); |
||||
} |
||||
|
||||
public RefFields(ref int v) |
||||
{ |
||||
Field0 = ref v; |
||||
Field1 = ref v; |
||||
Field2 = ref v; |
||||
Field3 = ref v; |
||||
} |
||||
} |
||||
} |
@ -1 +1,3 @@
@@ -1 +1,3 @@
|
||||
*.dll |
||||
/*.dll |
||||
/*.exe |
||||
/*.pdb |
@ -1,45 +1,255 @@
@@ -1,45 +1,255 @@
|
||||
using System; |
||||
using System.IO; |
||||
using System.Collections.Generic; |
||||
using System.Runtime.CompilerServices; |
||||
using System.Threading.Tasks; |
||||
|
||||
namespace EquivalentCSharpConsoleApp |
||||
using Microsoft.VisualBasic.CompilerServices; |
||||
|
||||
namespace ICSharpCode.Decompiler.Tests.TestCases.VBPretty |
||||
{ |
||||
static class Program |
||||
public class Async |
||||
{ |
||||
public static void Main(string[] args) |
||||
private int memberField; |
||||
|
||||
private static bool True() |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
public async void SimpleVoidMethod() |
||||
{ |
||||
Console.WriteLine("Before"); |
||||
await Task.Delay(TimeSpan.FromSeconds(1.0)); |
||||
Console.WriteLine("After"); |
||||
} |
||||
|
||||
public async void VoidMethodWithoutAwait() |
||||
{ |
||||
Console.WriteLine("No Await"); |
||||
} |
||||
|
||||
public async void EmptyVoidMethod() |
||||
{ |
||||
} |
||||
|
||||
public async void AwaitYield() |
||||
{ |
||||
await Task.Yield(); |
||||
} |
||||
|
||||
public async void AwaitDefaultYieldAwaitable() |
||||
{ |
||||
#if LEGACY_VBC || (OPTIMIZE && !ROSLYN4)
|
||||
YieldAwaitable yieldAwaitable = default(YieldAwaitable); |
||||
YieldAwaitable yieldAwaitable2 = yieldAwaitable; |
||||
await yieldAwaitable2; |
||||
#else
|
||||
await default(YieldAwaitable); |
||||
#endif
|
||||
} |
||||
|
||||
public async void AwaitDefaultHopToThreadPool() |
||||
{ |
||||
#if LEGACY_VBC || (OPTIMIZE && !ROSLYN4)
|
||||
HopToThreadPoolAwaitable hopToThreadPoolAwaitable = default(HopToThreadPoolAwaitable); |
||||
HopToThreadPoolAwaitable hopToThreadPoolAwaitable2 = hopToThreadPoolAwaitable; |
||||
await hopToThreadPoolAwaitable2; |
||||
#else
|
||||
await default(HopToThreadPoolAwaitable); |
||||
#endif
|
||||
} |
||||
|
||||
public async Task SimpleVoidTaskMethod() |
||||
{ |
||||
Console.WriteLine("Before"); |
||||
await Task.Delay(TimeSpan.FromSeconds(1.0)); |
||||
Console.WriteLine("After"); |
||||
} |
||||
|
||||
public async Task TaskMethodWithoutAwait() |
||||
{ |
||||
Console.WriteLine("No Await"); |
||||
} |
||||
|
||||
public async Task CapturingThis() |
||||
{ |
||||
await Task.Delay(memberField); |
||||
} |
||||
|
||||
public async Task CapturingThisWithoutAwait() |
||||
{ |
||||
Console.WriteLine(memberField); |
||||
} |
||||
|
||||
public async Task<bool> SimpleBoolTaskMethod() |
||||
{ |
||||
var task = new Task(ProcessDataAsync); |
||||
task.Start(); |
||||
task.Wait(); |
||||
Console.ReadLine(); |
||||
Console.WriteLine("Before"); |
||||
await Task.Delay(TimeSpan.FromSeconds(1.0)); |
||||
Console.WriteLine("After"); |
||||
return true; |
||||
} |
||||
|
||||
public async static void ProcessDataAsync() |
||||
public async void TwoAwaitsWithDifferentAwaiterTypes() |
||||
{ |
||||
Task<int> task = HandleFileAsync("C:\\enable1.txt"); |
||||
Console.WriteLine("Please wait, processing"); |
||||
int result = await task; |
||||
Console.WriteLine("Count: " + result.ToString()); |
||||
Console.WriteLine("Before"); |
||||
if (await SimpleBoolTaskMethod()) |
||||
{ |
||||
await Task.Delay(TimeSpan.FromSeconds(1.0)); |
||||
} |
||||
Console.WriteLine("After"); |
||||
} |
||||
|
||||
public async void AwaitInLoopCondition() |
||||
{ |
||||
while (await SimpleBoolTaskMethod()) |
||||
{ |
||||
Console.WriteLine("Body"); |
||||
} |
||||
} |
||||
|
||||
public async static Task<int> HandleFileAsync(string file) |
||||
public async Task Issue2366a() |
||||
{ |
||||
Console.WriteLine("HandleFile enter"); |
||||
int count = 0; |
||||
using (StreamReader reader = new StreamReader(file)) |
||||
while (true) |
||||
{ |
||||
string value = await reader.ReadToEndAsync(); |
||||
count += value.Length; |
||||
for (var i = 0; i <= 10000; i += 1) |
||||
try |
||||
{ |
||||
var x = value.GetHashCode(); |
||||
if (x == 0) |
||||
count -= 1; |
||||
await Task.CompletedTask; |
||||
} |
||||
catch (Exception projectError) |
||||
{ |
||||
ProjectData.SetProjectError(projectError); |
||||
ProjectData.ClearProjectError(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static async Task<int> GetIntegerSumAsync(IEnumerable<int> items) |
||||
{ |
||||
await Task.Delay(100); |
||||
int num = 0; |
||||
foreach (int item in items) |
||||
{ |
||||
num = checked(num + item); |
||||
} |
||||
return num; |
||||
} |
||||
|
||||
Console.WriteLine("HandleFile exit"); |
||||
return count; |
||||
public async Task AsyncCatch(bool b, Task<int> task1, Task<int> task2) |
||||
{ |
||||
try |
||||
{ |
||||
Console.WriteLine("Start try"); |
||||
await task1; |
||||
Console.WriteLine("End try"); |
||||
} |
||||
catch (Exception projectError) |
||||
{ |
||||
ProjectData.SetProjectError(projectError); |
||||
Console.WriteLine("No await"); |
||||
ProjectData.ClearProjectError(); |
||||
} |
||||
} |
||||
|
||||
public async Task AsyncCatchThrow(bool b, Task<int> task1, Task<int> task2) |
||||
{ |
||||
try |
||||
{ |
||||
Console.WriteLine("Start try"); |
||||
await task1; |
||||
Console.WriteLine("End try"); |
||||
} |
||||
catch (Exception projectError) |
||||
{ |
||||
ProjectData.SetProjectError(projectError); |
||||
Console.WriteLine("No await"); |
||||
throw; |
||||
} |
||||
} |
||||
|
||||
public async Task AsyncFinally(bool b, Task<int> task1, Task<int> task2) |
||||
{ |
||||
try |
||||
{ |
||||
Console.WriteLine("Start try"); |
||||
await task1; |
||||
Console.WriteLine("End try"); |
||||
} |
||||
finally |
||||
{ |
||||
Console.WriteLine("No await"); |
||||
} |
||||
} |
||||
|
||||
public static async Task AlwaysThrow() |
||||
{ |
||||
throw new Exception(); |
||||
} |
||||
|
||||
public static async Task InfiniteLoop() |
||||
{ |
||||
while (true) |
||||
{ |
||||
} |
||||
} |
||||
|
||||
public static async Task InfiniteLoopWithAwait() |
||||
{ |
||||
while (true) |
||||
{ |
||||
await Task.Delay(10); |
||||
} |
||||
} |
||||
|
||||
public async Task AsyncWithLocalVar() |
||||
{ |
||||
object objectValue = RuntimeHelpers.GetObjectValue(new object()); |
||||
await UseObj(RuntimeHelpers.GetObjectValue(objectValue)); |
||||
await UseObj(RuntimeHelpers.GetObjectValue(objectValue)); |
||||
} |
||||
|
||||
public static async Task UseObj(object a) |
||||
{ |
||||
} |
||||
} |
||||
|
||||
public struct AsyncInStruct |
||||
{ |
||||
private int i; |
||||
|
||||
public async Task<int> Test(AsyncInStruct xx) |
||||
{ |
||||
checked |
||||
{ |
||||
xx.i++; |
||||
i++; |
||||
await Task.Yield(); |
||||
return i + xx.i; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public struct HopToThreadPoolAwaitable : INotifyCompletion |
||||
{ |
||||
public bool IsCompleted { get; set; } |
||||
|
||||
public HopToThreadPoolAwaitable GetAwaiter() |
||||
{ |
||||
return this; |
||||
} |
||||
|
||||
public void OnCompleted(Action continuation) |
||||
{ |
||||
Task.Run(continuation); |
||||
} |
||||
|
||||
void INotifyCompletion.OnCompleted(Action continuation) |
||||
{ |
||||
//ILSpy generated this explicit interface implementation from .override directive in OnCompleted
|
||||
this.OnCompleted(continuation); |
||||
} |
||||
|
||||
public void GetResult() |
||||
{ |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,47 +1,181 @@
@@ -1,47 +1,181 @@
|
||||
Imports System |
||||
Imports System.IO |
||||
|
||||
Module Program |
||||
' Sample taken verbatim from https://www.dotnetperls.com/async-vbnet |
||||
Sub Main(args As String()) |
||||
Dim task = New Task(AddressOf ProcessDataAsync) |
||||
' Start and wait for task to end. |
||||
task.Start() |
||||
task.Wait() |
||||
Console.ReadLine() |
||||
End Sub |
||||
|
||||
Async Sub ProcessDataAsync() |
||||
' Create a task Of Integer. |
||||
' ... Use HandleFileAsync method with a large file. |
||||
Dim task As Task(Of Integer) = HandleFileAsync("C:\enable1.txt") |
||||
' This statement runs while HandleFileAsync executes. |
||||
Console.WriteLine("Please wait, processing") |
||||
' Use await to wait for task to complete. |
||||
Dim result As Integer = Await task |
||||
Console.WriteLine("Count: " + result.ToString()) |
||||
End Sub |
||||
|
||||
Async Function HandleFileAsync(ByVal file As String) As Task(Of Integer) |
||||
Console.WriteLine("HandleFile enter") |
||||
|
||||
' Open the file. |
||||
Dim count As Integer = 0 |
||||
Using reader As StreamReader = New StreamReader(file) |
||||
Dim value As String = Await reader.ReadToEndAsync() |
||||
count += value.Length |
||||
|
||||
' Do a slow computation on the file. |
||||
For i = 0 To 10000 Step 1 |
||||
Dim x = value.GetHashCode() |
||||
If x = 0 Then |
||||
count -= 1 |
||||
End If |
||||
|
||||
Next |
||||
End Using |
||||
|
||||
Console.WriteLine("HandleFile exit") |
||||
Return count |
||||
End Function |
||||
End Module |
||||
Imports System.Collections.Generic |
||||
Imports System.Threading.Tasks |
||||
Imports System.Runtime.CompilerServices |
||||
|
||||
Namespace ICSharpCode.Decompiler.Tests.TestCases.VBPretty |
||||
Public Class Async |
||||
Private memberField As Integer |
||||
|
||||
Private Shared Function [True]() As Boolean |
||||
Return True |
||||
End Function |
||||
|
||||
Public Async Sub SimpleVoidMethod() |
||||
Console.WriteLine("Before") |
||||
Await Task.Delay(TimeSpan.FromSeconds(1.0)) |
||||
Console.WriteLine("After") |
||||
End Sub |
||||
|
||||
Public Async Sub VoidMethodWithoutAwait() |
||||
Console.WriteLine("No Await") |
||||
End Sub |
||||
|
||||
Public Async Sub EmptyVoidMethod() |
||||
End Sub |
||||
|
||||
Public Async Sub AwaitYield() |
||||
Await Task.Yield() |
||||
End Sub |
||||
|
||||
Public Async Sub AwaitDefaultYieldAwaitable() |
||||
Await CType(Nothing, YieldAwaitable) |
||||
End Sub |
||||
|
||||
Public Async Sub AwaitDefaultHopToThreadPool() |
||||
' unlike YieldAwaitable which implements ICriticalNotifyCompletion, |
||||
' the HopToThreadPoolAwaitable struct only implements |
||||
' INotifyCompletion, so this results in different codegen |
||||
Await CType(Nothing, HopToThreadPoolAwaitable) |
||||
End Sub |
||||
|
||||
Public Async Function SimpleVoidTaskMethod() As Task |
||||
Console.WriteLine("Before") |
||||
Await Task.Delay(TimeSpan.FromSeconds(1.0)) |
||||
Console.WriteLine("After") |
||||
End Function |
||||
|
||||
Public Async Function TaskMethodWithoutAwait() As Task |
||||
Console.WriteLine("No Await") |
||||
End Function |
||||
|
||||
Public Async Function CapturingThis() As Task |
||||
Await Task.Delay(memberField) |
||||
End Function |
||||
|
||||
Public Async Function CapturingThisWithoutAwait() As Task |
||||
Console.WriteLine(memberField) |
||||
End Function |
||||
|
||||
Public Async Function SimpleBoolTaskMethod() As Task(Of Boolean) |
||||
Console.WriteLine("Before") |
||||
Await Task.Delay(TimeSpan.FromSeconds(1.0)) |
||||
Console.WriteLine("After") |
||||
Return True |
||||
End Function |
||||
|
||||
Public Async Sub TwoAwaitsWithDifferentAwaiterTypes() |
||||
Console.WriteLine("Before") |
||||
If Await SimpleBoolTaskMethod() Then |
||||
Await Task.Delay(TimeSpan.FromSeconds(1.0)) |
||||
End If |
||||
Console.WriteLine("After") |
||||
End Sub |
||||
|
||||
Public Async Sub AwaitInLoopCondition() |
||||
While Await SimpleBoolTaskMethod() |
||||
Console.WriteLine("Body") |
||||
End While |
||||
End Sub |
||||
|
||||
Public Async Function Issue2366a() As Task |
||||
While True |
||||
Try |
||||
Await Task.CompletedTask |
||||
Catch |
||||
End Try |
||||
End While |
||||
End Function |
||||
|
||||
Public Shared Async Function GetIntegerSumAsync(ByVal items As IEnumerable(Of Integer)) As Task(Of Integer) |
||||
Await Task.Delay(100) |
||||
Dim num = 0 |
||||
For Each item In items |
||||
num += item |
||||
Next |
||||
Return num |
||||
End Function |
||||
|
||||
Public Async Function AsyncCatch(ByVal b As Boolean, ByVal task1 As Task(Of Integer), ByVal task2 As Task(Of Integer)) As Task |
||||
Try |
||||
Console.WriteLine("Start try") |
||||
Await task1 |
||||
Console.WriteLine("End try") |
||||
Catch ex As Exception |
||||
Console.WriteLine("No await") |
||||
End Try |
||||
End Function |
||||
|
||||
Public Async Function AsyncCatchThrow(ByVal b As Boolean, ByVal task1 As Task(Of Integer), ByVal task2 As Task(Of Integer)) As Task |
||||
Try |
||||
Console.WriteLine("Start try") |
||||
Await task1 |
||||
Console.WriteLine("End try") |
||||
Catch ex As Exception |
||||
Console.WriteLine("No await") |
||||
Throw |
||||
End Try |
||||
End Function |
||||
|
||||
Public Async Function AsyncFinally(ByVal b As Boolean, ByVal task1 As Task(Of Integer), ByVal task2 As Task(Of Integer)) As Task |
||||
Try |
||||
Console.WriteLine("Start try") |
||||
Await task1 |
||||
Console.WriteLine("End try") |
||||
Finally |
||||
Console.WriteLine("No await") |
||||
End Try |
||||
End Function |
||||
|
||||
Public Shared Async Function AlwaysThrow() As Task |
||||
Throw New Exception |
||||
End Function |
||||
|
||||
Public Shared Async Function InfiniteLoop() As Task |
||||
While True |
||||
End While |
||||
End Function |
||||
|
||||
Public Shared Async Function InfiniteLoopWithAwait() As Task |
||||
While True |
||||
Await Task.Delay(10) |
||||
End While |
||||
End Function |
||||
|
||||
Public Async Function AsyncWithLocalVar() As Task |
||||
Dim a As Object = New Object() |
||||
Await UseObj(a) |
||||
Await UseObj(a) |
||||
End Function |
||||
|
||||
Public Shared Async Function UseObj(ByVal a As Object) As Task |
||||
End Function |
||||
End Class |
||||
|
||||
Public Structure AsyncInStruct |
||||
Private i As Integer |
||||
|
||||
Public Async Function Test(ByVal xx As AsyncInStruct) As Task(Of Integer) |
||||
xx.i += 1 |
||||
i += 1 |
||||
Await Task.Yield() |
||||
Return i + xx.i |
||||
End Function |
||||
End Structure |
||||
|
||||
Public Structure HopToThreadPoolAwaitable |
||||
Implements INotifyCompletion |
||||
Public Property IsCompleted As Boolean |
||||
|
||||
Public Function GetAwaiter() As HopToThreadPoolAwaitable |
||||
Return Me |
||||
End Function |
||||
|
||||
Public Sub OnCompleted(ByVal continuation As Action) Implements INotifyCompletion.OnCompleted |
||||
Task.Run(continuation) |
||||
End Sub |
||||
|
||||
Public Sub GetResult() |
||||
End Sub |
||||
End Structure |
||||
End Namespace |
||||
|
@ -0,0 +1,14 @@
@@ -0,0 +1,14 @@
|
||||
public class VBAutomaticEvents |
||||
{ |
||||
public delegate void EventWithParameterEventHandler(int EventNumber); |
||||
public delegate void EventWithoutParameterEventHandler(); |
||||
|
||||
public event EventWithParameterEventHandler EventWithParameter; |
||||
public event EventWithoutParameterEventHandler EventWithoutParameter; |
||||
|
||||
public void RaiseEvents() |
||||
{ |
||||
EventWithParameter?.Invoke(1); |
||||
EventWithoutParameter?.Invoke(); |
||||
} |
||||
} |
@ -0,0 +1,9 @@
@@ -0,0 +1,9 @@
|
||||
Public Class VBAutomaticEvents |
||||
Event EventWithParameter(ByVal EventNumber As Integer) |
||||
Event EventWithoutParameter() |
||||
|
||||
Sub RaiseEvents() |
||||
RaiseEvent EventWithParameter(1) |
||||
RaiseEvent EventWithoutParameter() |
||||
End Sub |
||||
End Class |
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Runtime.CompilerServices; |
||||
|
||||
public class VBNonGenericForEach |
||||
{ |
||||
public static void M() |
||||
{ |
||||
ArrayList arrayList = new ArrayList(); |
||||
foreach (object item in arrayList) |
||||
{ |
||||
#if ROSLYN && OPT
|
||||
Console.WriteLine(RuntimeHelpers.GetObjectValue(RuntimeHelpers.GetObjectValue(item))); |
||||
#else
|
||||
object objectValue = RuntimeHelpers.GetObjectValue(item); |
||||
Console.WriteLine(RuntimeHelpers.GetObjectValue(objectValue)); |
||||
#endif
|
||||
} |
||||
} |
||||
} |
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
Imports System |
||||
Imports System.Collections |
||||
|
||||
Public Class VBNonGenericForEach |
||||
Public Shared Sub M() |
||||
Dim collection = New ArrayList |
||||
For Each element In collection |
||||
Console.WriteLine(element) |
||||
Next |
||||
End Sub |
||||
End Class |
@ -0,0 +1,419 @@
@@ -0,0 +1,419 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
using Microsoft.VisualBasic.CompilerServices; |
||||
|
||||
namespace ICSharpCode.Decompiler.Tests.TestCases.VBPretty |
||||
{ |
||||
internal struct StructWithYieldReturn |
||||
{ |
||||
private int val; |
||||
|
||||
public IEnumerable<int> Count() |
||||
{ |
||||
yield return val; |
||||
yield return val; |
||||
} |
||||
} |
||||
|
||||
public class YieldReturnPrettyTest |
||||
{ |
||||
private int fieldOnThis; |
||||
|
||||
public static IEnumerable<char> YieldChars { |
||||
get { |
||||
yield return 'a'; |
||||
yield return 'b'; |
||||
yield return 'c'; |
||||
} |
||||
} |
||||
|
||||
internal static void Print<T>(string name, IEnumerator<T> enumerator) |
||||
{ |
||||
Console.WriteLine(name + ": Test start"); |
||||
while (enumerator.MoveNext()) |
||||
{ |
||||
Console.WriteLine(name + ": " + enumerator.Current.ToString()); |
||||
} |
||||
} |
||||
|
||||
public static IEnumerable<string> SimpleYieldReturn() |
||||
{ |
||||
yield return "A"; |
||||
yield return "B"; |
||||
yield return "C"; |
||||
} |
||||
|
||||
public static IEnumerator<string> SimpleYieldReturnEnumerator() |
||||
{ |
||||
yield return "A"; |
||||
yield return "B"; |
||||
yield return "C"; |
||||
} |
||||
|
||||
public IEnumerable<int> YieldReturnParameters(int p) |
||||
{ |
||||
yield return p; |
||||
yield return fieldOnThis; |
||||
} |
||||
|
||||
public IEnumerator<int> YieldReturnParametersEnumerator(int p) |
||||
{ |
||||
yield return p; |
||||
yield return fieldOnThis; |
||||
} |
||||
|
||||
public static IEnumerable<int> YieldReturnInLoop() |
||||
{ |
||||
int num = 0; |
||||
do |
||||
{ |
||||
yield return num; |
||||
num = checked(num + 1); |
||||
} while (num <= 99); |
||||
} |
||||
|
||||
public static IEnumerable<int> YieldReturnWithTryFinally() |
||||
{ |
||||
yield return 0; |
||||
try |
||||
{ |
||||
yield return 1; |
||||
} |
||||
finally |
||||
{ |
||||
Console.WriteLine("Finally!"); |
||||
} |
||||
yield return 2; |
||||
} |
||||
|
||||
public static IEnumerable<string> YieldReturnWithNestedTryFinally(bool breakInMiddle) |
||||
{ |
||||
Console.WriteLine("Start of method - 1"); |
||||
yield return "Start of method"; |
||||
Console.WriteLine("Start of method - 2"); |
||||
try |
||||
{ |
||||
Console.WriteLine("Within outer try - 1"); |
||||
yield return "Within outer try"; |
||||
Console.WriteLine("Within outer try - 2"); |
||||
try |
||||
{ |
||||
Console.WriteLine("Within inner try - 1"); |
||||
yield return "Within inner try"; |
||||
Console.WriteLine("Within inner try - 2"); |
||||
if (breakInMiddle) |
||||
{ |
||||
Console.WriteLine("Breaking..."); |
||||
yield break; |
||||
} |
||||
Console.WriteLine("End of inner try - 1"); |
||||
yield return "End of inner try"; |
||||
Console.WriteLine("End of inner try - 2"); |
||||
} |
||||
finally |
||||
{ |
||||
Console.WriteLine("Inner Finally"); |
||||
} |
||||
Console.WriteLine("End of outer try - 1"); |
||||
yield return "End of outer try"; |
||||
Console.WriteLine("End of outer try - 2"); |
||||
} |
||||
finally |
||||
{ |
||||
Console.WriteLine("Outer Finally"); |
||||
} |
||||
Console.WriteLine("End of method - 1"); |
||||
yield return "End of method"; |
||||
Console.WriteLine("End of method - 2"); |
||||
} |
||||
|
||||
public static IEnumerable<string> YieldReturnWithTwoNonNestedFinallyBlocks(IEnumerable<string> input) |
||||
{ |
||||
// outer try-finally block
|
||||
foreach (string item in input) |
||||
{ |
||||
// nested try-finally block
|
||||
try |
||||
{ |
||||
yield return item; |
||||
} |
||||
finally |
||||
{ |
||||
Console.WriteLine("Processed " + item); |
||||
} |
||||
} |
||||
yield return "A"; |
||||
yield return "B"; |
||||
yield return "C"; |
||||
yield return "D"; |
||||
yield return "E"; |
||||
yield return "F"; |
||||
// outer try-finally block
|
||||
foreach (string item2 in input) |
||||
{ |
||||
yield return item2.ToUpper(); |
||||
} |
||||
} |
||||
|
||||
public static IEnumerable<int> GetEvenNumbers(int n) |
||||
{ |
||||
int num = checked(n - 1); |
||||
for (int i = 0; i <= num; i = checked(i + 1)) |
||||
{ |
||||
if (i % 2 == 0) |
||||
{ |
||||
yield return i; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static IEnumerable<char> ExceptionHandling() |
||||
{ |
||||
yield return 'a'; |
||||
try |
||||
{ |
||||
Console.WriteLine("1 - try"); |
||||
} |
||||
catch (Exception projectError) |
||||
{ |
||||
ProjectData.SetProjectError(projectError); |
||||
Console.WriteLine("1 - catch"); |
||||
ProjectData.ClearProjectError(); |
||||
} |
||||
yield return 'b'; |
||||
try |
||||
{ |
||||
try |
||||
{ |
||||
Console.WriteLine("2 - try"); |
||||
} |
||||
finally |
||||
{ |
||||
Console.WriteLine("2 - finally"); |
||||
} |
||||
yield return 'c'; |
||||
} |
||||
finally |
||||
{ |
||||
Console.WriteLine("outer finally"); |
||||
} |
||||
} |
||||
|
||||
public static IEnumerable<int> YieldBreakInCatch() |
||||
{ |
||||
yield return 0; |
||||
try |
||||
{ |
||||
Console.WriteLine("In Try"); |
||||
} |
||||
catch (Exception projectError) |
||||
{ |
||||
ProjectData.SetProjectError(projectError); |
||||
ProjectData.ClearProjectError(); |
||||
// yield return is not allowed in catch, but yield break is
|
||||
yield break; |
||||
} |
||||
yield return 1; |
||||
} |
||||
|
||||
public static IEnumerable<int> YieldBreakInCatchInTryFinally() |
||||
{ |
||||
try |
||||
{ |
||||
yield return 0; |
||||
try |
||||
{ |
||||
Console.WriteLine("In Try"); |
||||
} |
||||
catch (Exception projectError) |
||||
{ |
||||
ProjectData.SetProjectError(projectError); |
||||
ProjectData.ClearProjectError(); |
||||
// yield return is not allowed in catch, but yield break is
|
||||
// Note that pre-roslyn, this code triggers a compiler bug:
|
||||
// If the finally block throws an exception, it ends up getting
|
||||
// called a second time.
|
||||
yield break; |
||||
} |
||||
yield return 1; |
||||
} |
||||
finally |
||||
{ |
||||
Console.WriteLine("Finally"); |
||||
} |
||||
} |
||||
|
||||
public static IEnumerable<int> YieldBreakInTryCatchInTryFinally() |
||||
{ |
||||
try |
||||
{ |
||||
yield return 0; |
||||
try |
||||
{ |
||||
Console.WriteLine("In Try"); |
||||
// same compiler bug as in YieldBreakInCatchInTryFinally
|
||||
yield break; |
||||
} |
||||
catch (Exception projectError) |
||||
{ |
||||
ProjectData.SetProjectError(projectError); |
||||
Console.WriteLine("Catch"); |
||||
ProjectData.ClearProjectError(); |
||||
} |
||||
yield return 1; |
||||
} |
||||
finally |
||||
{ |
||||
Console.WriteLine("Finally"); |
||||
} |
||||
} |
||||
|
||||
public static IEnumerable<int> YieldBreakInTryFinallyInTryFinally(bool b) |
||||
{ |
||||
try |
||||
{ |
||||
yield return 0; |
||||
try |
||||
{ |
||||
Console.WriteLine("In Try"); |
||||
if (b) |
||||
{ |
||||
// same compiler bug as in YieldBreakInCatchInTryFinally
|
||||
yield break; |
||||
} |
||||
} |
||||
finally |
||||
{ |
||||
Console.WriteLine("Inner Finally"); |
||||
} |
||||
yield return 1; |
||||
} |
||||
finally |
||||
{ |
||||
Console.WriteLine("Finally"); |
||||
} |
||||
} |
||||
|
||||
public static IEnumerable<int> YieldBreakOnly() |
||||
{ |
||||
yield break; |
||||
} |
||||
|
||||
public static IEnumerable<int> UnconditionalThrowInTryFinally() |
||||
{ |
||||
// Here, MoveNext() doesn't call the finally methods at all
|
||||
// (only indirectly via Dispose())
|
||||
try |
||||
{ |
||||
yield return 0; |
||||
throw new NotImplementedException(); |
||||
} |
||||
finally |
||||
{ |
||||
Console.WriteLine("Finally"); |
||||
} |
||||
} |
||||
|
||||
public static IEnumerable<int> NestedTryFinallyStartingOnSamePosition() |
||||
{ |
||||
// The first user IL instruction is already in 2 nested try blocks.
|
||||
#if ((ROSLYN2 && !ROSLYN4) && OPT)
|
||||
int num = -1; |
||||
#endif
|
||||
try |
||||
{ |
||||
#if ((ROSLYN2 && !ROSLYN4) && OPT)
|
||||
_ = num - 1; |
||||
#endif
|
||||
try |
||||
{ |
||||
yield return 0; |
||||
} |
||||
finally |
||||
{ |
||||
Console.WriteLine("Inner Finally"); |
||||
} |
||||
} |
||||
finally |
||||
{ |
||||
Console.WriteLine("Outer Finally"); |
||||
} |
||||
} |
||||
|
||||
#if ROSLYN
|
||||
public static IEnumerable<int> LocalInFinally<T>(T a) where T : IDisposable |
||||
{ |
||||
yield return 1; |
||||
try |
||||
{ |
||||
yield return 2; |
||||
} |
||||
finally |
||||
{ |
||||
T val = a; |
||||
val.Dispose(); |
||||
val.Dispose(); |
||||
} |
||||
yield return 3; |
||||
} |
||||
#endif
|
||||
|
||||
public static IEnumerable<T> GenericYield<T>() where T : new() |
||||
{ |
||||
T val = new T(); |
||||
int num = 0; |
||||
do |
||||
{ |
||||
yield return val; |
||||
num = checked(num + 1); |
||||
} while (num <= 2); |
||||
} |
||||
|
||||
public static IEnumerable<int> MultipleYieldBreakInTryFinally(int i) |
||||
{ |
||||
try |
||||
{ |
||||
if (i == 2) |
||||
{ |
||||
yield break; |
||||
} |
||||
|
||||
while (i < 40) |
||||
{ |
||||
if (i % 2 == 0) |
||||
{ |
||||
yield break; |
||||
} |
||||
i = checked(i + 1); |
||||
|
||||
yield return i; |
||||
} |
||||
} |
||||
finally |
||||
{ |
||||
Console.WriteLine("finally"); |
||||
} |
||||
Console.WriteLine("normal exit"); |
||||
} |
||||
|
||||
internal IEnumerable<int> ForLoopWithYieldReturn(int end, int evil) |
||||
{ |
||||
// This loop needs to pick the implicit "yield break;" as exit point
|
||||
// in order to produce pretty code; not the "throw" which would
|
||||
// be a less-pretty option.
|
||||
checked |
||||
{ |
||||
int num = end - 1; |
||||
for (int i = 0; i <= num; i++) |
||||
{ |
||||
if (i == evil) |
||||
{ |
||||
throw new InvalidOperationException("Found evil number"); |
||||
} |
||||
yield return i; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,300 @@
@@ -0,0 +1,300 @@
|
||||
Imports System |
||||
Imports System.Collections.Generic |
||||
|
||||
Namespace ICSharpCode.Decompiler.Tests.TestCases.VBPretty |
||||
Friend Structure StructWithYieldReturn |
||||
Private val As Integer |
||||
|
||||
Public Iterator Function Count() As IEnumerable(Of Integer) |
||||
Yield val |
||||
Yield val |
||||
End Function |
||||
End Structure |
||||
|
||||
Public Class YieldReturnPrettyTest |
||||
Private fieldOnThis As Integer |
||||
|
||||
Public Shared ReadOnly Iterator Property YieldChars As IEnumerable(Of Char) |
||||
Get |
||||
Yield "a"c |
||||
Yield "b"c |
||||
Yield "c"c |
||||
End Get |
||||
End Property |
||||
|
||||
Friend Shared Sub Print(Of T)(ByVal name As String, ByVal enumerator As IEnumerator(Of T)) |
||||
Console.WriteLine(name + ": Test start") |
||||
While enumerator.MoveNext() |
||||
Console.WriteLine(name + ": " + enumerator.Current.ToString()) |
||||
End While |
||||
End Sub |
||||
|
||||
Public Shared Iterator Function SimpleYieldReturn() As IEnumerable(Of String) |
||||
Yield "A" |
||||
Yield "B" |
||||
Yield "C" |
||||
End Function |
||||
|
||||
Public Shared Iterator Function SimpleYieldReturnEnumerator() As IEnumerator(Of String) |
||||
Yield "A" |
||||
Yield "B" |
||||
Yield "C" |
||||
End Function |
||||
|
||||
Public Iterator Function YieldReturnParameters(ByVal p As Integer) As IEnumerable(Of Integer) |
||||
Yield p |
||||
Yield fieldOnThis |
||||
End Function |
||||
|
||||
Public Iterator Function YieldReturnParametersEnumerator(ByVal p As Integer) As IEnumerator(Of Integer) |
||||
Yield p |
||||
Yield fieldOnThis |
||||
End Function |
||||
|
||||
Public Shared Iterator Function YieldReturnInLoop() As IEnumerable(Of Integer) |
||||
For i = 0 To 99 |
||||
Yield i |
||||
Next |
||||
End Function |
||||
|
||||
Public Shared Iterator Function YieldReturnWithTryFinally() As IEnumerable(Of Integer) |
||||
Yield 0 |
||||
Try |
||||
Yield 1 |
||||
Finally |
||||
Console.WriteLine("Finally!") |
||||
End Try |
||||
Yield 2 |
||||
End Function |
||||
|
||||
Public Shared Iterator Function YieldReturnWithNestedTryFinally(ByVal breakInMiddle As Boolean) As IEnumerable(Of String) |
||||
Console.WriteLine("Start of method - 1") |
||||
Yield "Start of method" |
||||
Console.WriteLine("Start of method - 2") |
||||
Try |
||||
Console.WriteLine("Within outer try - 1") |
||||
Yield "Within outer try" |
||||
Console.WriteLine("Within outer try - 2") |
||||
Try |
||||
Console.WriteLine("Within inner try - 1") |
||||
Yield "Within inner try" |
||||
Console.WriteLine("Within inner try - 2") |
||||
If breakInMiddle Then |
||||
Console.WriteLine("Breaking...") |
||||
Return |
||||
End If |
||||
Console.WriteLine("End of inner try - 1") |
||||
Yield "End of inner try" |
||||
Console.WriteLine("End of inner try - 2") |
||||
Finally |
||||
Console.WriteLine("Inner Finally") |
||||
End Try |
||||
Console.WriteLine("End of outer try - 1") |
||||
Yield "End of outer try" |
||||
Console.WriteLine("End of outer try - 2") |
||||
Finally |
||||
Console.WriteLine("Outer Finally") |
||||
End Try |
||||
Console.WriteLine("End of method - 1") |
||||
Yield "End of method" |
||||
Console.WriteLine("End of method - 2") |
||||
End Function |
||||
|
||||
Public Shared Iterator Function YieldReturnWithTwoNonNestedFinallyBlocks(ByVal input As IEnumerable(Of String)) As IEnumerable(Of String) |
||||
' outer try-finally block |
||||
For Each line In input |
||||
' nested try-finally block |
||||
Try |
||||
Yield line |
||||
Finally |
||||
Console.WriteLine("Processed " & line) |
||||
End Try |
||||
Next |
||||
Yield "A" |
||||
Yield "B" |
||||
Yield "C" |
||||
Yield "D" |
||||
Yield "E" |
||||
Yield "F" |
||||
' outer try-finally block |
||||
For Each item In input |
||||
Yield item.ToUpper() |
||||
Next |
||||
End Function |
||||
|
||||
Public Shared Iterator Function GetEvenNumbers(ByVal n As Integer) As IEnumerable(Of Integer) |
||||
For i = 0 To n - 1 |
||||
If i Mod 2 = 0 Then |
||||
Yield i |
||||
End If |
||||
Next |
||||
End Function |
||||
|
||||
Public Shared Iterator Function ExceptionHandling() As IEnumerable(Of Char) |
||||
Yield "a"c |
||||
Try |
||||
Console.WriteLine("1 - try") |
||||
Catch __unusedException1__ As Exception |
||||
Console.WriteLine("1 - catch") |
||||
End Try |
||||
Yield "b"c |
||||
Try |
||||
Try |
||||
Console.WriteLine("2 - try") |
||||
Finally |
||||
Console.WriteLine("2 - finally") |
||||
End Try |
||||
Yield "c"c |
||||
Finally |
||||
Console.WriteLine("outer finally") |
||||
End Try |
||||
End Function |
||||
|
||||
Public Shared Iterator Function YieldBreakInCatch() As IEnumerable(Of Integer) |
||||
Yield 0 |
||||
Try |
||||
Console.WriteLine("In Try") |
||||
Catch |
||||
' yield return is not allowed in catch, but yield break is |
||||
Return |
||||
End Try |
||||
Yield 1 |
||||
End Function |
||||
|
||||
Public Shared Iterator Function YieldBreakInCatchInTryFinally() As IEnumerable(Of Integer) |
||||
Try |
||||
Yield 0 |
||||
Try |
||||
Console.WriteLine("In Try") |
||||
Catch |
||||
' yield return is not allowed in catch, but yield break is |
||||
' Note that pre-roslyn, this code triggers a compiler bug: |
||||
' If the finally block throws an exception, it ends up getting |
||||
' called a second time. |
||||
Return |
||||
End Try |
||||
Yield 1 |
||||
Finally |
||||
Console.WriteLine("Finally") |
||||
End Try |
||||
End Function |
||||
|
||||
Public Shared Iterator Function YieldBreakInTryCatchInTryFinally() As IEnumerable(Of Integer) |
||||
Try |
||||
Yield 0 |
||||
Try |
||||
Console.WriteLine("In Try") |
||||
' same compiler bug as in YieldBreakInCatchInTryFinally |
||||
Return |
||||
Catch |
||||
Console.WriteLine("Catch") |
||||
End Try |
||||
Yield 1 |
||||
Finally |
||||
Console.WriteLine("Finally") |
||||
End Try |
||||
End Function |
||||
|
||||
Public Shared Iterator Function YieldBreakInTryFinallyInTryFinally(ByVal b As Boolean) As IEnumerable(Of Integer) |
||||
Try |
||||
Yield 0 |
||||
Try |
||||
Console.WriteLine("In Try") |
||||
If b Then |
||||
' same compiler bug as in YieldBreakInCatchInTryFinally |
||||
Return |
||||
End If |
||||
|
||||
Finally |
||||
Console.WriteLine("Inner Finally") |
||||
End Try |
||||
Yield 1 |
||||
Finally |
||||
Console.WriteLine("Finally") |
||||
End Try |
||||
End Function |
||||
|
||||
Public Shared Iterator Function YieldBreakOnly() As IEnumerable(Of Integer) |
||||
Return |
||||
End Function |
||||
|
||||
Public Shared Iterator Function UnconditionalThrowInTryFinally() As IEnumerable(Of Integer) |
||||
' Here, MoveNext() doesn't call the finally methods at all |
||||
' (only indirectly via Dispose()) |
||||
Try |
||||
Yield 0 |
||||
Throw New NotImplementedException() |
||||
Finally |
||||
Console.WriteLine("Finally") |
||||
End Try |
||||
End Function |
||||
|
||||
Public Shared Iterator Function NestedTryFinallyStartingOnSamePosition() As IEnumerable(Of Integer) |
||||
' The first user IL instruction is already in 2 nested try blocks. |
||||
Try |
||||
Try |
||||
Yield 0 |
||||
Finally |
||||
Console.WriteLine("Inner Finally") |
||||
End Try |
||||
|
||||
Finally |
||||
Console.WriteLine("Outer Finally") |
||||
End Try |
||||
End Function |
||||
|
||||
#If ROSLYN Then |
||||
Public Shared Iterator Function LocalInFinally(Of T As IDisposable)(ByVal a As T) As IEnumerable(Of Integer) |
||||
Yield 1 |
||||
Try |
||||
Yield 2 |
||||
Finally |
||||
Dim val = a |
||||
val.Dispose() |
||||
val.Dispose() |
||||
End Try |
||||
Yield 3 |
||||
End Function |
||||
#End If |
||||
|
||||
Public Shared Iterator Function GenericYield(Of T As New)() As IEnumerable(Of T) |
||||
Dim val As T = New T() |
||||
For i = 0 To 2 |
||||
Yield val |
||||
Next |
||||
End Function |
||||
|
||||
Public Shared Iterator Function MultipleYieldBreakInTryFinally(ByVal i As Integer) As IEnumerable(Of Integer) |
||||
Try |
||||
If i = 2 Then |
||||
Return |
||||
End If |
||||
|
||||
While i < 40 |
||||
If i Mod 2 = 0 Then |
||||
Return |
||||
End If |
||||
i += 1 |
||||
|
||||
Yield i |
||||
End While |
||||
|
||||
Finally |
||||
Console.WriteLine("finally") |
||||
End Try |
||||
Console.WriteLine("normal exit") |
||||
End Function |
||||
|
||||
Friend Iterator Function ForLoopWithYieldReturn(ByVal [end] As Integer, ByVal evil As Integer) As IEnumerable(Of Integer) |
||||
' This loop needs to pick the implicit "yield break;" as exit point |
||||
' in order to produce pretty code; not the "throw" which would |
||||
' be a less-pretty option. |
||||
For i = 0 To [end] - 1 |
||||
If i = evil Then |
||||
Throw New InvalidOperationException("Found evil number") |
||||
End If |
||||
Yield i |
||||
Next |
||||
End Function |
||||
End Class |
||||
End Namespace |
@ -0,0 +1,189 @@
@@ -0,0 +1,189 @@
|
||||
// Copyright (c) 2023 Siegfried Pammer
|
||||
//
|
||||
// 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.Globalization; |
||||
using System.IO; |
||||
using System.Linq; |
||||
using System.Resources; |
||||
using System.Runtime.CompilerServices; |
||||
using System.Xml.Linq; |
||||
using System.Xml.XPath; |
||||
|
||||
using ICSharpCode.Decompiler.Util; |
||||
|
||||
using NUnit.Framework; |
||||
using NUnit.Framework.Internal; |
||||
|
||||
namespace ICSharpCode.Decompiler.Tests.Util |
||||
{ |
||||
[TestFixture] |
||||
public class ResourceReaderWriterTests |
||||
{ |
||||
const string WinFormsAssemblyName = ", System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; |
||||
const string MSCorLibAssemblyName = ", mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; |
||||
|
||||
[Serializable] |
||||
public class SerializableClass |
||||
{ |
||||
public string Name { get; set; } |
||||
public int Age { get; set; } |
||||
} |
||||
|
||||
static readonly object[][] TestWriteCases = { |
||||
new object[] { "Decimal", 1.0m, "1.0", "System.Decimal" + MSCorLibAssemblyName }, |
||||
new object[] { "TimeSpan", TimeSpan.FromSeconds(42), "00:00:42", "System.TimeSpan" + MSCorLibAssemblyName }, |
||||
new object[] { "DateTime", DateTime.Parse("06/18/2023 21:36:30", CultureInfo.InvariantCulture), "06/18/2023 21:36:30", "System.DateTime" + MSCorLibAssemblyName }, |
||||
}; |
||||
|
||||
static readonly object[][] TestReadCases = { |
||||
new object[] { "Decimal", 1.0m }, |
||||
new object[] { "TimeSpan", TimeSpan.FromSeconds(42) }, |
||||
new object[] { "DateTime", DateTime.Parse("06/18/2023 21:36:30", CultureInfo.InvariantCulture) }, |
||||
}; |
||||
|
||||
static MemoryStream ProduceResourcesTestFile<T>(string name, T value) |
||||
{ |
||||
var ms = new MemoryStream(); |
||||
var writer = new ResourceWriter(ms); |
||||
writer.AddResource(name, value); |
||||
writer.Generate(); |
||||
ms.Position = 0; |
||||
return ms; |
||||
} |
||||
|
||||
static XElement ProduceResXTest<T>(string name, T value) |
||||
{ |
||||
using var ms = new MemoryStream(); |
||||
var writer = new ResXResourceWriter(ms); |
||||
writer.AddResource(name, value); |
||||
writer.Generate(); |
||||
ms.Position = 0; |
||||
var doc = XDocument.Load(ms); |
||||
return doc.XPathSelectElement(".//data"); |
||||
} |
||||
|
||||
[TestCase("Null", null)] |
||||
[TestCase("String", "Hello World!")] |
||||
[TestCase("Char", 'A')] |
||||
[TestCase("Bool", true)] |
||||
[TestCase("Bool", false)] |
||||
[TestCase("Byte", (byte)1)] |
||||
[TestCase("SByte", (sbyte)-1)] |
||||
[TestCase("Int16", (short)1)] |
||||
[TestCase("UInt16", (ushort)1)] |
||||
[TestCase("Int32", 1)] |
||||
[TestCase("UInt32", (uint)1)] |
||||
[TestCase("Int64", (long)1)] |
||||
[TestCase("UInt64", (ulong)1)] |
||||
[TestCase("Single", 1.0f)] |
||||
[TestCase("Double", 1.0d)] |
||||
[TestCase("Bytes", new byte[] { 42, 43, 44 })] |
||||
[TestCaseSource(nameof(TestReadCases))] |
||||
public void Read(string name, object value) |
||||
{ |
||||
using var testFile = ProduceResourcesTestFile(name, value); |
||||
using var reader = new ResourcesFile(testFile); |
||||
var items = reader.ToArray(); |
||||
Assert.AreEqual(1, items.Length); |
||||
Assert.AreEqual(name, items[0].Key); |
||||
Assert.AreEqual(value, items[0].Value); |
||||
} |
||||
|
||||
[TestCase("Null", null, null, "System.Resources.ResXNullRef" + WinFormsAssemblyName)] |
||||
[TestCase("String", "Hello World!", "Hello World!", null)] |
||||
[TestCase("Bool", true, "True", "System.Boolean" + MSCorLibAssemblyName)] |
||||
[TestCase("Bool", false, "False", "System.Boolean" + MSCorLibAssemblyName)] |
||||
[TestCase("Char", 'A', "A", "System.Char" + MSCorLibAssemblyName)] |
||||
[TestCase("Byte", (byte)1, "1", "System.Byte" + MSCorLibAssemblyName)] |
||||
[TestCase("SByte", (sbyte)-1, "-1", "System.SByte" + MSCorLibAssemblyName)] |
||||
[TestCase("Int16", (short)1, "1", "System.Int16" + MSCorLibAssemblyName)] |
||||
[TestCase("UInt16", (ushort)1, "1", "System.UInt16" + MSCorLibAssemblyName)] |
||||
[TestCase("Int32", 1, "1", "System.Int32" + MSCorLibAssemblyName)] |
||||
[TestCase("UInt32", (uint)1, "1", "System.UInt32" + MSCorLibAssemblyName)] |
||||
[TestCase("Int64", (long)1, "1", "System.Int64" + MSCorLibAssemblyName)] |
||||
[TestCase("UInt64", (ulong)1, "1", "System.UInt64" + MSCorLibAssemblyName)] |
||||
[TestCase("Single", 1.0f, "1", "System.Single" + MSCorLibAssemblyName)] |
||||
[TestCase("Double", 1.0d, "1", "System.Double" + MSCorLibAssemblyName)] |
||||
[TestCaseSource(nameof(TestWriteCases))] |
||||
public void Write(string name, object value, string serializedValue, string typeName) |
||||
{ |
||||
var element = ProduceResXTest(name, value); |
||||
Assert.AreEqual(name, element.Attribute("name")?.Value); |
||||
if (typeName != null) |
||||
{ |
||||
Assert.AreEqual(typeName, element.Attribute("type")?.Value); |
||||
} |
||||
var v = element.Element("value"); |
||||
Assert.IsNotNull(v); |
||||
Assert.IsTrue(v.IsEmpty ? serializedValue == null : v.Value == serializedValue); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResXSerializableClassIsRejected() |
||||
{ |
||||
Assert.Throws<NotSupportedException>( |
||||
() => ProduceResXTest("Serial", new SerializableClass { Name = "Hugo", Age = 42 }) |
||||
); |
||||
} |
||||
|
||||
[Test] |
||||
public void BitmapIsResourceSerializedObject() |
||||
{ |
||||
Stream stream = typeof(ResourceReaderWriterTests).Assembly |
||||
.GetManifestResourceStream(typeof(ResourceReaderWriterTests).Namespace + ".Test.resources"); |
||||
using var reader = new ResourcesFile(stream); |
||||
var items = reader.ToArray(); |
||||
Assert.AreEqual(3, items.Length); |
||||
var item = items.FirstOrDefault(i => i.Key == "Bitmap"); |
||||
Assert.IsNotNull(item.Key); |
||||
Assert.IsInstanceOf<ResourceSerializedObject>(item.Value); |
||||
} |
||||
|
||||
[Test] |
||||
public void ByteArrayIsSupported() |
||||
{ |
||||
Stream stream = typeof(ResourceReaderWriterTests).Assembly |
||||
.GetManifestResourceStream(typeof(ResourceReaderWriterTests).Namespace + ".Test.resources"); |
||||
using var reader = new ResourcesFile(stream); |
||||
var items = reader.ToArray(); |
||||
Assert.AreEqual(3, items.Length); |
||||
var item = items.FirstOrDefault(i => i.Key == "Byte[]"); |
||||
Assert.IsNotNull(item.Key); |
||||
Assert.IsInstanceOf<byte[]>(item.Value); |
||||
byte[] array = (byte[])item.Value; |
||||
Assert.AreEqual(3, array.Length); |
||||
Assert.AreEqual(42, array[0]); |
||||
Assert.AreEqual(43, array[1]); |
||||
Assert.AreEqual(44, array[2]); |
||||
} |
||||
|
||||
[Test] |
||||
public void MemoryStreamIsSupported() |
||||
{ |
||||
Stream stream = typeof(ResourceReaderWriterTests).Assembly |
||||
.GetManifestResourceStream(typeof(ResourceReaderWriterTests).Namespace + ".Test.resources"); |
||||
using var reader = new ResourcesFile(stream); |
||||
var items = reader.ToArray(); |
||||
Assert.AreEqual(3, items.Length); |
||||
var item = items.FirstOrDefault(i => i.Key == "MemoryStream"); |
||||
Assert.IsNotNull(item.Key); |
||||
Assert.IsInstanceOf<MemoryStream>(item.Value); |
||||
} |
||||
} |
||||
} |
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue