Skip to content

Commit 86c46c8

Browse files
authored
Add processing to update native methods CRC32 (#67)
***NO_CI***
1 parent 1148160 commit 86c46c8

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

source/MetadataProcessor.Core/nanoAssemblyDefinition.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
//
66

77
using System.IO;
8+
using System.Linq;
89

910
namespace nanoFramework.Tools.MetadataProcessor
1011
{
@@ -89,8 +90,20 @@ public void Write(
8990
// keeping this here for now, just for compatibility
9091
writer.WriteUInt32(0);
9192

93+
var nativeMethdodsCount = _context.MethodDefinitionTable.Items.Count(method => method.RVA == 0 && !method.IsAbstract);
94+
9295
// native methods CRC32
93-
writer.WriteUInt32(_context.NativeMethodsCrc.Current);
96+
// this is used by other tools to check if the assembly has native implementation
97+
// (like the deployment provider in the VS extension)
98+
if (nativeMethdodsCount > 0)
99+
{
100+
writer.WriteUInt32(_context.NativeMethodsCrc.Current);
101+
}
102+
else
103+
{
104+
// this assembly doesn't have any native methods implemented
105+
writer.WriteUInt32(0);
106+
}
94107

95108
// Native methods offset
96109
writer.WriteUInt32(0xFFFFFFFF);

0 commit comments

Comments
 (0)