Skip to content

Commit fb5ccd4

Browse files
committed
[AssemblyProcessor] Temporary workaround for dotnet/android#1177
# Original commit: '6d7f270371006c8abcb93dff3fd1111de71acf58'
1 parent 14f5209 commit fb5ccd4

9 files changed

+84
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:dc4162c56792cb419d28cc79df1a790ba4c78bfbc2c8e098b4ba8a0b4398dfe7
3-
size 8202752
2+
oid sha256:b081e9f8cb6eb4e642ad175430fca21aebdf2c2c2f3fd38dc50e973c39816a87
3+
size 8203264

deps/AssemblyProcessor/SiliconStudio.AssemblyProcessor.Packed.exe.config

+4-1
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,11 @@
7676
</dependentAssembly>
7777
<dependentAssembly>
7878
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
79-
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1" />
79+
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
8080
</dependentAssembly>
8181
</assemblyBinding>
8282
</runtime>
83+
<startup>
84+
<supportedRuntime version="v4.0" />
85+
</startup>
8386
</configuration>
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:55a6c656bf7b1c313913fe43419a72068c7fb817d8037eee13ae08e520846c94
2+
oid sha256:2df395004c508ff48e46383cfac60b2b0938395f861c0f19b16e17993989a1db
33
size 335360
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:d1618a93e5649efd6b763e495e09fc93d69a2c44849e7c59e21457b8c39272e9
3-
size 166400
2+
oid sha256:515fd74339ecf72f694a26a7926f8e2b1316f35a842a39b99cbe3b54754261dc
3+
size 166912

deps/AssemblyProcessor/SiliconStudio.AssemblyProcessor.exe.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
</dependentAssembly>
7777
<dependentAssembly>
7878
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
79-
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1" />
79+
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
8080
</dependentAssembly>
8181
</assemblyBinding>
8282
</runtime>
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:1c331bc21029461d465375b416acdeba3d2bf50b1a02ec0b7f79ef749f2a47da
3-
size 357888
2+
oid sha256:53ee8e82b9381cb4cb643f8b9993246c1b08729196299f84f46793dda120b564
3+
size 341504

sources/common/core/SiliconStudio.AssemblyProcessor/AssemblyProcessorApp.cs

+1
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ public bool Run(ref AssemblyDefinition assemblyDefinition, ref bool readWriteSym
205205

206206
// Always applies the interop processor
207207
processors.Add(new InteropProcessor());
208+
processors.Add(new MonoFixedProcessor());
208209

209210
processors.Add(new AssemblyVersionProcessor());
210211

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright (c) 2014-2017 Silicon Studio Corp. All rights reserved. (https://www.siliconstudio.co.jp)
2+
// See LICENSE.md for full license information.
3+
4+
using System;
5+
using System.Linq;
6+
using Mono.Cecil.Cil;
7+
using Mono.Cecil.Rocks;
8+
9+
namespace SiliconStudio.AssemblyProcessor
10+
{
11+
/// <summary>
12+
/// Temporary workaround for https://github.com/xamarin/xamarin-android/issues/1177.
13+
/// </summary>
14+
internal class MonoFixedProcessor : IAssemblyDefinitionProcessor
15+
{
16+
public bool Process(AssemblyProcessorContext context)
17+
{
18+
if (context.Platform != Core.PlatformType.Android && context.Platform != Core.PlatformType.iOS)
19+
return false;
20+
21+
bool changed = false;
22+
foreach (var type in context.Assembly.MainModule.GetAllTypes())
23+
{
24+
foreach (var method in type.Methods)
25+
{
26+
if (method.Body == null)
27+
continue;
28+
29+
for (var index = 0; index < method.Body.Instructions.Count; index++)
30+
{
31+
var instruction = method.Body.Instructions[index];
32+
if (instruction.OpCode == OpCodes.Conv_U)
33+
{
34+
VariableDefinition variable = null;
35+
36+
// Check if next store is in a pointer variable
37+
switch (instruction.Next.OpCode.Code)
38+
{
39+
case Code.Stloc_0:
40+
variable = method.Body.Variables[0];
41+
break;
42+
case Code.Stloc_1:
43+
variable = method.Body.Variables[1];
44+
break;
45+
case Code.Stloc_2:
46+
variable = method.Body.Variables[2];
47+
break;
48+
case Code.Stloc_3:
49+
variable = method.Body.Variables[3];
50+
break;
51+
case Code.Stloc:
52+
variable = (VariableDefinition)instruction.Operand;
53+
break;
54+
}
55+
56+
if (variable != null && variable.VariableType.IsPointer)
57+
{
58+
// We are in a fixed instruction, let's fix it
59+
instruction.OpCode = OpCodes.Conv_I;
60+
changed = true;
61+
}
62+
}
63+
}
64+
}
65+
}
66+
67+
return changed;
68+
}
69+
}
70+
}

sources/common/core/SiliconStudio.AssemblyProcessor/SiliconStudio.AssemblyProcessor.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@
216216
<Compile Include="DispatcherProcessor.cs" />
217217
<Compile Include="FixupValueTypeVisitor.cs" />
218218
<Compile Include="GenerateUserDocumentationProcessor.cs" />
219+
<Compile Include="MonoFixedProcessor.cs" />
219220
<Compile Include="InitLocalsProcessor.cs" />
220221
<Compile Include="OpenSourceSignProcessor.cs" />
221222
<Compile Include="PclFixupTypeVisitor.cs" />

0 commit comments

Comments
 (0)