Updated with a solution that works for me. See the bottom of this question.
Context:
I needed a way to evaluate the size of a generic type for the p
Ok, this is the result of my research (based on https://github.com/dotnet/corefx/tree/master/src/System.Runtime.CompilerServices.Unsafe and https://github.com/jvbsl/ILProj):
global.json
:
{
"msbuild-sdks": {
"Microsoft.NET.Sdk.IL": "3.0.0-preview-27318-01"
}
}
ILProj\ILProj.ilproj
:
netstandard2.0
3.0.0-preview-27318-01
include\netstandard
include\netstandard
include\netcoreapp
include\netcoreapp
$(IlasmFlags) -INCLUDE=$(IncludePath)
ILProj\include\netstandard\coreassembly.h
:
#define CORE_ASSEMBLY "System.Runtime"
// Metadata version: v4.0.30319
.assembly extern CORE_ASSEMBLY
{
.publickeytoken = ( B0 3F 5F 7F 11 D5 0A 3A )
.ver 4:0:0:0
}
ILProj\Class.il
#include "coreassembly.h"
.assembly ILProj
{
.ver 1:0:0:0
}
.module ILProj.dll
.class public abstract auto ansi sealed beforefieldinit ILProj.Class
extends [CORE_ASSEMBLY]System.Object
{
.method public hidebysig static int32 Square(int32 a) cil managed
{
.maxstack 2
ldarg.0
dup
mul
ret
}
}
If you have difficulties to put it all together, then look at the example here: https://github.com/Konard/ILProj