-
Don't open the repo in vscode with the c/c++ extension enabled, it will hoard enormous amounts of resources.
-
Be sure to build
clr+libs
in Debug the first time; then you can build just the clr (as long as you don't touch the libs, duh). -
To try the changes out, use
artifacts/bin/coreclr/linux.x64.Debug/corerun
, though you'll probably first have to copy the contents oflinux.x64.Debug/libs
intolinux.x64.Debug/
. You should probably also setCORE_LIBRARIES
toartifacts/bin/runtime/net-9.0-linux-Debug-x64
.
- CFF Explorer
- mdv, the metadata visualizer
ilasm
andildasm
from dotnet/runtime
- ECMA-335 Partition II: Metadata
- Anatomy of a .NET Assembly – Custom attribute encoding
- Anatomy of a .NET Assembly – CLR metadata 1 (and the series as a whole)
- The .NET File Format
inc/caparser.h
-- helper to turn the raw data from blobs into the target type (int, string, type, etc...)- methods like
GetData
also useinc/strgpooli.h(29): CPackedLen
to decode some compressed data
- methods like
inc/corhdr.h(932): CorSerializationType
-- list of types that can be serialized for attributesvm/customattribute.cpp(222): ParseCaValue
-- used in loader to parse attr argumentsmd/
-- heart of the metadata loading/readingmd/compiler/custattr.h
md/compiler/custattr_import.cpp
md/inc/cahlprinternal.h(56): CaValue
-- structure holding the actual value
- what should we actually encode (answer: probably just MD tokens)
- how do we construct the actual delegate from what we encoded
- if MD token, probably use
ResolveMethodHandle
to getRuntimeMethodHandleInternal
->RuntimeMethodInfo.ctor
to get MethodInfo ->.CreateDelegate
- if MD token, probably use
- delegate could end-up in
object[]
, how do we handle boxing in that case? - encoding generic methods and/or methods on generic types
- what restrictions have to be in place for this to work out? (e.g. cannot be instance lambda/method group, obviously)
- what restrictions should be in place to make our lives easier?
- we'll also have to change a bunch of other things/tools: compiler back-end + mid-end (for ex. GetAttributeData could now return
IMethodInfo
), mdv, ilasm+ildasm, System.Reflection.Metadata/Emit - do we even want to give a delegate??? Like a
MethodInfo
would allow getting instance delegates for example, it'd then be up to the user to actually instantiate them - how do we reference methods from another assembly?
- types are encoded as strings -- probably not a great sign that they chose the "stringly-typed" road instead of using MD tokens ;-;
- attribute ctors are called lazily when introspecting (e.g.
typeof(C).GetCustomAttributes()
will run the ctors of all attributes on classC
) - getting RVA from MethodBase