Skip to content

Commit e72b1f9

Browse files
Merge branch 'master' into feature/ReferenceAssemblyOverly
2 parents 65f546d + a9eccdb commit e72b1f9

File tree

144 files changed

+4107
-1194
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+4107
-1194
lines changed

.github/workflows/build-frontends.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
1515
with:
1616
fetch-depth: 0
1717
- name: Setup .NET

.github/workflows/build-ilspy.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- run: mkdir -p $env:StagingDirectory
2222

2323

24-
- uses: actions/checkout@v3
24+
- uses: actions/checkout@v4
2525
with:
2626
submodules: true
2727
fetch-depth: 0
@@ -95,7 +95,7 @@ jobs:
9595
run: |
9696
msbuild ILSpy.Installer.sln /t:Restore /p:Configuration="Release" /p:Platform="Any CPU"
9797
msbuild ILSpy.Installer.sln /p:Configuration="Release" /p:Platform="Any CPU"
98-
msbuild ILSpy.Installer.sln /p:Configuration="Release" /p:Platform="Any CPU" /p:DefineConstants="ARM64"
98+
msbuild ILSpy.Installer.sln /p:Configuration="Release" /p:Platform="Any CPU" /p:PlatformForInstaller="ARM64"
9999
100100
- name: Build VS Extensions (for 2017-2019 and 2022)
101101
if: matrix.configuration == 'release'

.github/workflows/codeql-analysis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
steps:
2020
- name: Checkout repository
21-
uses: actions/checkout@v3
21+
uses: actions/checkout@v4
2222
with:
2323
fetch-depth: 0
2424

.github/workflows/generate-bom.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
steps:
1212
- name: Checkout
1313
run: git config --global core.autocrlf true
14-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
1515
with:
1616
submodules: true
1717

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
</ItemGroup>
2727

2828
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
29-
<Exec Command="pwsh -Command &quot;Copy-Item $(ProjectDir)manifest.psd1 $(TargetDir)$(TargetName).psd1&quot;" />
29+
<Exec Condition=" '$(OS)' == 'Windows_NT' " Command="powershell -Command &quot;Copy-Item $(ProjectDir)manifest.psd1 $(TargetDir)$(TargetName).psd1&quot;" />
30+
<Exec Condition=" '$(OS)' != 'Windows_NT' " Command="pwsh -Command &quot;Copy-Item $(ProjectDir)manifest.psd1 $(TargetDir)$(TargetName).psd1&quot;" />
3031
</Target>
3132
</Project>

ICSharpCode.Decompiler.Tests/Helpers/Tester.VB.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,16 @@ public static async Task<CompilerResults> CompileVB(string sourceFileName, Compi
6060
var vbcPath = roslynToolset.GetVBCompiler(roslynVersion);
6161

6262
IEnumerable<string> references;
63+
string libPath;
6364
if ((flags & CompilerOptions.UseRoslynMask) != 0 && (flags & CompilerOptions.TargetNet40) == 0)
6465
{
6566
references = coreDefaultReferences.Select(r => "-r:\"" + r + "\"");
67+
libPath = coreRefAsmPath;
6668
}
6769
else
6870
{
6971
references = defaultReferences.Select(r => "-r:\"" + r + "\"");
72+
libPath = RefAsmPath;
7073
}
7174
if (flags.HasFlag(CompilerOptions.ReferenceVisualBasic))
7275
{
@@ -116,7 +119,7 @@ public static async Task<CompilerResults> CompileVB(string sourceFileName, Compi
116119
}
117120

118121
var command = Cli.Wrap(vbcPath)
119-
.WithArguments($"{otherOptions}{string.Join(" ", references)} -out:\"{Path.GetFullPath(results.PathToAssembly)}\" {string.Join(" ", sourceFileNames.Select(fn => '"' + Path.GetFullPath(fn) + '"'))}")
122+
.WithArguments($"{otherOptions}-libpath:\"{libPath}\" {string.Join(" ", references)} -out:\"{Path.GetFullPath(results.PathToAssembly)}\" {string.Join(" ", sourceFileNames.Select(fn => '"' + Path.GetFullPath(fn) + '"'))}")
120123
.WithValidation(CommandResultValidation.None);
121124
Console.WriteLine($"\"{command.TargetFilePath}\" {command.Arguments}");
122125

ICSharpCode.Decompiler.Tests/Helpers/Tester.cs

+1
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ private static string ReplacePrivImplDetails(string il)
295295
"System.Linq.Expressions.dll",
296296
"System.Linq.Queryable.dll",
297297
"System.IO.FileSystem.Watcher.dll",
298+
"System.Memory.dll",
298299
"System.Threading.dll",
299300
"System.Threading.Thread.dll",
300301
"System.Runtime.dll",

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

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<EnableDefaultItems>false</EnableDefaultItems>
1818

1919
<AutoGenerateBindingRedirects>True</AutoGenerateBindingRedirects>
20+
<EnableUnsafeBinaryFormatterSerialization>True</EnableUnsafeBinaryFormatterSerialization>
2021

2122
<SignAssembly>True</SignAssembly>
2223
<AssemblyOriginatorKeyFile>..\ICSharpCode.Decompiler\ICSharpCode.Decompiler.snk</AssemblyOriginatorKeyFile>
@@ -61,6 +62,7 @@
6162
<PackageReference Include="Mono.Cecil" Version="$(MonoCecilVersion)" />
6263
<PackageReference Include="Microsoft.NETCore.ILAsm" Version="$(ILAsmVersion)" />
6364
<PackageReference Include="Microsoft.NETCore.ILDAsm" Version="$(ILDAsmVersion)" />
65+
<PackageReference Include="System.Resources.Extensions" Version="6.0.0" />
6466
</ItemGroup>
6567

6668
<ItemGroup>
@@ -113,6 +115,7 @@
113115
<Compile Include="Output\InsertParenthesesVisitorTests.cs" />
114116
<Compile Include="ProjectDecompiler\TargetFrameworkTests.cs" />
115117
<Compile Include="TestAssemblyResolver.cs" />
118+
<Compile Include="Util\ResourceReaderWriterTests.cs" />
116119
<None Include="TestCases\VBPretty\VBAutomaticEvents.vb" />
117120
<Compile Include="TestCases\VBPretty\VBAutomaticEvents.cs" />
118121
<Compile Include="TestCases\VBPretty\VBNonGenericForEach.cs" />
@@ -322,6 +325,7 @@
322325
</ItemGroup>
323326

324327
<ItemGroup>
328+
<Content Include="TestCases\PdbGen\Members.xml" />
325329
<Content Include="TestCases\PdbGen\ProgressReporting.xml" />
326330
<Content Include="TestCases\PdbGen\ForLoopTests.xml" />
327331
<Content Include="TestCases\PdbGen\CustomPdbId.xml" />
@@ -337,6 +341,7 @@
337341
<None Include="TestCases\VBPretty\VBCompoundAssign.vb" />
338342
<None Include="TestCases\VBPretty\Async.vb" />
339343
<None Include="TestCases\VBPretty\VBPropertiesTest.vb" />
344+
<EmbeddedResource Include="Util\Test.resources" />
340345
</ItemGroup>
341346

342347
</Project>

ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
2-
//
2+
//
33
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
44
// software and associated documentation files (the "Software"), to deal in the Software
55
// without restriction, including without limitation the rights to use, copy, modify, merge,
66
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
77
// to whom the Software is furnished to do so, subject to the following conditions:
8-
//
8+
//
99
// The above copyright notice and this permission notice shall be included in all copies or
1010
// substantial portions of the Software.
11-
//
11+
//
1212
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
1313
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
1414
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
@@ -269,6 +269,12 @@ public async Task EmptyBodies()
269269
await Run();
270270
}
271271

272+
[Test]
273+
public async Task MonoFixed()
274+
{
275+
await Run();
276+
}
277+
272278
async Task Run([CallerMemberName] string testName = null, DecompilerSettings settings = null,
273279
AssemblerOptions assemblerOptions = AssemblerOptions.Library)
274280
{

ICSharpCode.Decompiler.Tests/PdbGenerationTestRunner.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ public void LambdaCapturing()
4343
TestGeneratePdb();
4444
}
4545

46+
[Test]
47+
[Ignore("Duplicate sequence points for local function")]
48+
public void Members()
49+
{
50+
TestGeneratePdb();
51+
}
52+
4653
[Test]
4754
public void CustomPdbId()
4855
{
@@ -155,7 +162,7 @@ private void TestGeneratePdb([CallerMemberName] string testName = null)
155162
ProcessXmlFile(expectedFileName);
156163
string generatedFileName = Path.ChangeExtension(xmlFile, ".generated.xml");
157164
ProcessXmlFile(generatedFileName);
158-
Assert.AreEqual(Normalize(expectedFileName), Normalize(generatedFileName));
165+
CodeAssert.AreEqual(Normalize(expectedFileName), Normalize(generatedFileName));
159166
}
160167

161168
private (string peFileName, string pdbFileName) CompileTestCase(string testName)

ICSharpCode.Decompiler.Tests/TestCases/Correctness/ValueTypeCall.cs

+37
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public void Increment()
1616
public void Dispose()
1717
{
1818
Console.WriteLine("MutValueType disposed on {0}", val);
19+
val = val + 1;
1920
}
2021

2122
public override string ToString()
@@ -67,6 +68,10 @@ public static void Main()
6768
gvt.Call(ref gvt);
6869
new ValueTypeCall().InstanceFieldTests();
6970
ForEach();
71+
#if CS73
72+
DisposeMultipleTimes(ref m, in m);
73+
ToStringGeneric(ref m, in m);
74+
#endif
7075
}
7176

7277
static void RefParameter(ref MutValueType m)
@@ -213,5 +218,37 @@ static void ForEachArray1(MutValueType[] list)
213218
}
214219
Console.WriteLine("after: " + list[0].val);
215220
}
221+
222+
#if CS73
223+
static void DisposeMultipleTimes<T>(ref T mutRef, in T immutableRef) where T : struct, IDisposable
224+
{
225+
Console.WriteLine("DisposeMultipleTimes:");
226+
mutRef.Dispose();
227+
mutRef.Dispose();
228+
T copyFromMut = mutRef;
229+
copyFromMut.Dispose();
230+
immutableRef.Dispose();
231+
immutableRef.Dispose();
232+
T copyFromImmutable = immutableRef;
233+
copyFromImmutable.Dispose();
234+
mutRef.Dispose();
235+
immutableRef.Dispose();
236+
}
237+
238+
static void ToStringGeneric<T>(ref T mutRef, in T immutableRef) where T : struct
239+
{
240+
Console.WriteLine("ToStringGeneric:");
241+
Console.WriteLine(mutRef.ToString());
242+
Console.WriteLine(mutRef.ToString());
243+
T copyFromMut = mutRef;
244+
Console.WriteLine(copyFromMut.ToString());
245+
Console.WriteLine(immutableRef.ToString());
246+
Console.WriteLine(immutableRef.ToString());
247+
T copyFromImmutable = immutableRef;
248+
Console.WriteLine(copyFromImmutable.ToString());
249+
Console.WriteLine(mutRef.ToString());
250+
Console.WriteLine(immutableRef.ToString());
251+
}
252+
#endif
216253
}
217254
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
3+
public class MonoFixed
4+
{
5+
public unsafe void FixMultipleStrings(string text)
6+
{
7+
fixed (char* ptr = text)
8+
{
9+
fixed (char* ptr2 = Environment.UserName)
10+
{
11+
fixed (char* ptr3 = text)
12+
{
13+
*ptr = 'c';
14+
*ptr2 = 'd';
15+
*ptr3 = 'e';
16+
}
17+
}
18+
}
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
.assembly extern mscorlib
2+
{
3+
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 )
4+
.ver 4:0:0:0
5+
}
6+
.assembly MonoFixed
7+
{
8+
.ver 1:0:0:0
9+
}
10+
11+
.module MonoFixed.exe
12+
.imagebase 0x00400000
13+
.file alignment 0x00000200
14+
.stackreserve 0x00100000
15+
.subsystem 0x0003 // WindowsCui
16+
.corflags 0x00000001 // ILOnly
17+
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = (
18+
01 00 00 00
19+
)
20+
21+
.class public auto ansi beforefieldinit MonoFixed
22+
extends [mscorlib]System.Object
23+
{
24+
.method public hidebysig instance void FixMultipleStrings (string text) cil managed
25+
{
26+
.maxstack 7
27+
.locals init (
28+
[0] char* pinned,
29+
[1] char* pinned,
30+
[2] char* pinned,
31+
[3] string pinned,
32+
[4] string pinned,
33+
[5] string pinned
34+
)
35+
36+
IL_0000: ldarg.1
37+
IL_0001: stloc.3
38+
IL_0002: ldloc.3
39+
IL_0003: conv.i
40+
IL_0004: call int32 [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::get_OffsetToStringData()
41+
IL_0009: add
42+
IL_000a: stloc.0
43+
IL_000b: call string [mscorlib]System.Environment::get_UserName()
44+
IL_0010: stloc.s 4
45+
IL_0012: ldloc.s 4
46+
IL_0014: conv.i
47+
IL_0015: call int32 [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::get_OffsetToStringData()
48+
IL_001a: add
49+
IL_001b: stloc.1
50+
IL_001c: ldarg.1
51+
IL_001d: stloc.s 5
52+
IL_001f: ldloc.s 5
53+
IL_0021: conv.i
54+
IL_0022: call int32 [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::get_OffsetToStringData()
55+
IL_0027: add
56+
IL_0028: stloc.2
57+
IL_0029: ldloc.0
58+
IL_002a: ldc.i4.s 99
59+
IL_002c: stind.i2
60+
IL_002d: ldloc.1
61+
IL_002e: ldc.i4.s 100
62+
IL_0030: stind.i2
63+
IL_0031: ldloc.2
64+
IL_0032: ldc.i4.s 101
65+
IL_0034: stind.i2
66+
IL_0035: ldnull
67+
IL_0036: stloc.3
68+
IL_0037: ldnull
69+
IL_0038: stloc.s 4
70+
IL_003a: ldnull
71+
IL_003b: stloc.s 5
72+
IL_003d: ret
73+
}
74+
}

ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Unsafe.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public static class Unsafe
150150
[MethodImpl(MethodImplOptions.AggressiveInlining)]
151151
public unsafe static T Read<T>(void* source)
152152
{
153-
return *(T*)source;
153+
return Unsafe.Read<T>(source);
154154
}
155155

156156
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -168,7 +168,7 @@ public static T ReadUnaligned<T>(ref byte source)
168168
[MethodImpl(MethodImplOptions.AggressiveInlining)]
169169
public unsafe static void Write<T>(void* destination, T value)
170170
{
171-
*(T*)destination = value;
171+
Unsafe.Write(destination, value);
172172
}
173173

174174
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -186,13 +186,13 @@ public static void WriteUnaligned<T>(ref byte destination, T value)
186186
[MethodImpl(MethodImplOptions.AggressiveInlining)]
187187
public unsafe static void Copy<T>(void* destination, ref T source)
188188
{
189-
*(T*)destination = source;
189+
Unsafe.Write(destination, source);
190190
}
191191

192192
[MethodImpl(MethodImplOptions.AggressiveInlining)]
193193
public unsafe static void Copy<T>(ref T destination, void* source)
194194
{
195-
destination = *(T*)source;
195+
destination = Unsafe.Read<T>(source);
196196
}
197197

198198
[MethodImpl(MethodImplOptions.AggressiveInlining)]

0 commit comments

Comments
 (0)