我正在尝试使用 Reg Gate 的反射器从程序集中恢复源。原始源代码利用了几个 C# 3.0 特性,这使得恢复起来有点困难。例如,这里是匿名类型的恢复源。弹出的第一件事是类标识符上的 <> 。运行时类型命名规则显然比设计时规则更自由。很公平。一个简单的搜索和替换将解决这个问题。我必须注意哪些其他编译器修改以及如何处理它们?
[DebuggerDisplay(@"\{ OverrideType = {OverrideType}, EntityType = {EntityType} }", Type="<Anonymous Type>"), CompilerGenerated]
internal sealed class <>f__AnonymousType1<<OverrideType>j__TPar, <EntityType>j__TPar>
{
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private readonly <EntityType>j__TPar <EntityType>i__Field;
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private readonly <OverrideType>j__TPar <OverrideType>i__Field;
[DebuggerHidden]
public <>f__AnonymousType1(<OverrideType>j__TPar OverrideType, <EntityType>j__TPar EntityType)
{
this.<OverrideType>i__Field = OverrideType;
this.<EntityType>i__Field = EntityType;
}
[DebuggerHidden]
public override bool Equals(object value)
{
var type = value as <>f__AnonymousType1<<OverrideType>j__TPar, <EntityType>j__TPar>;
return (((type != null) && EqualityComparer<> <<OverrideType>j__TPar>.Default.Equals(this.<OverrideType>i__Field, type.<OverrideType>i__Field)) && EqualityComparer<<EntityType>j__TPar>.Default.Equals(this.<EntityType>i__Field, type.<EntityType>i__Field));
}
[DebuggerHidden]
public override int GetHashCode()
{
int num = -338316509;
num = (-1521134295 * num) + EqualityComparer<<OverrideType>j__TPar>.Default.GetHashCode(this.<OverrideType>i__Field);
return ((-1521134295 * num) + EqualityComparer<<EntityType>j__TPar>.Default.GetHashCode(this.<EntityType>i__Field));
}
[DebuggerHidden]
public override string ToString()
{
StringBuilder builder = new StringBuilder();
builder.Append("{ OverrideType = ");
builder.Append(this.<OverrideType>i__Field);
builder.Append(", EntityType = ");
builder.Append(this.<EntityType>i__Field);
builder.Append(" }");
return builder.ToString();
}
public <EntityType>j__TPar EntityType
{
get
{
return this.<EntityType>i__Field;
}
}
public <OverrideType>j__TPar OverrideType
{
get
{
return this.<OverrideType>i__Field;
}
}
}