Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在寻找一种方法来确定 Mono.Cecil 中值类型(TypeReference)的字节大小。
我需要它来优化 Nullable 相等比较代码生成。
但要这样做,我需要以某种方式获取 sizeof(T)。
它不是 100% 完美的(因为它将根据 32/64 位拱形而有所不同),但宪兵有代码来完成这项任务。看里面的SizeOf方法:
https://raw.github.com/mono/mono-tools/master/gendarme/rules/Gendarme.Rules.Performance/AvoidLargeStructureRule.cs