Skip to content

Commit

Permalink
Provoke the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveGilham committed Oct 14, 2020
1 parent e9a4815 commit 1a2275b
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Mono.Cecil.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mono.Cecil.Rocks", "rocks\M
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mono.Cecil.Rocks.Tests", "rocks\Test\Mono.Cecil.Rocks.Tests.csproj", "{EF768F7A-3C08-45EE-8A7E-BB5A81BADB7B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cecil.11.3.issue", "repro\Cecil.11.3.issue.csproj", "{BC2C29E7-BE9E-4087-9F7E-D9BCAFCA635E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -57,6 +59,10 @@ Global
{EF768F7A-3C08-45EE-8A7E-BB5A81BADB7B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EF768F7A-3C08-45EE-8A7E-BB5A81BADB7B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EF768F7A-3C08-45EE-8A7E-BB5A81BADB7B}.Release|Any CPU.Build.0 = Release|Any CPU
{BC2C29E7-BE9E-4087-9F7E-D9BCAFCA635E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BC2C29E7-BE9E-4087-9F7E-D9BCAFCA635E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BC2C29E7-BE9E-4087-9F7E-D9BCAFCA635E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BC2C29E7-BE9E-4087-9F7E-D9BCAFCA635E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
31 changes: 31 additions & 0 deletions repro/Cecil.11.3.issue.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RootNamespace>Issue</RootNamespace>
</PropertyGroup>

<ItemGroup>
<Compile Include="Program.cs" />
</ItemGroup>

<ItemGroup>
<None Include="Sample3.dll" />
<None Include="Sample3.dll.mdb" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Mono.Cecil.csproj" />
<ProjectReference Include="..\symbols\mdb\Mono.Cecil.Mdb.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="Sample3.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Sample3.dll.mdb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
36 changes: 36 additions & 0 deletions repro/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.IO;
using System.Linq;
using System.Reflection;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Cecil.Mdb;

public class Issue
{
private static void Main(string[] args)
{
var here = Assembly.GetExecutingAssembly().Location;
var target = Path.Combine(
Path.GetDirectoryName(here),
"Sample3.dll"
);

var definition = AssemblyDefinition.ReadAssembly(target);

var provider = new MdbReaderProvider();
var reader = provider.GetSymbolReader(definition.MainModule, target);
definition.MainModule.ReadSymbols(reader);

var pathGetterDef =
definition.MainModule.GetTypes().
SelectMany(t => t.Methods).
First(m => m.Name.Equals("get_Defer"));

var body = pathGetterDef.Body;
var worker = body.GetILProcessor();
var initialBody = body.Instructions.ToList();
var head = initialBody.First();
var opcode = worker.Create(OpCodes.Ldc_I4_1);
worker.InsertBefore(head, opcode);
}
}
Binary file added repro/Sample3.dll
Binary file not shown.
Binary file added repro/Sample3.dll.mdb
Binary file not shown.

0 comments on commit 1a2275b

Please sign in to comment.