我对 PostSharp 有疑问。像这样的代码:
class Program
{
static void Main(string[] args)
{
}
}
interface IA
{
int a { get; set; }
}
[Serializable]
[IntroduceInterface(typeof(IA))]
public class Aaaa : InstanceLevelAspect, IA
{
public int a { get; set; }
}
[Serializable]
[Aaaa]
class B
{
}
使用 PostSharp 2.0 构建提供了类 B,该类可通过接口 IA 中的字段进行序列化。使用 PostSharp 2.1 IA 文件构建后不会序列化。反编译后,我得到该代码:
[Serializable]
private class B : IA
{
[NonSerialized]
private Aaaa <>__aspect1;
public B()
{
base.\u002Ector();
this.\u003C\u003Ez__InitializeAspects();
}
{...}
}
在 2.0 版中,代码几乎相同,但有一处不同。没有 [NonSerialized] 属性。有什么办法让它在 2.1 上像在 2.0 上一样工作吗?