反编译代码的修改

kernelj 2013-07-05 04:06:35
下面是一段反编译后的 vb 代码,应该是 lamda 或者匿名方法之类的,求翻译为正确的代码

Dim dictionary As New Dictionary(Of QueryMethod, Func(Of Expression, Expression, Expression))
If (QueryableSearcher(Of T).CS$<>9__CachedAnonymousMethodDelegate18 Is Nothing) Then
QueryableSearcher(Of T).CS$<>9__CachedAnonymousMethodDelegate18 = New Func(Of Expression, Expression, Expression)(Nothing, DirectCast(QueryableSearcher(Of T).<.cctor>b__d, IntPtr))
End If
dictionary.Add(QueryMethod.GreaterThanOrEqual, QueryableSearcher(Of T).CS$<>9__CachedAnonymousMethodDelegate18)

......

Private Shared Function <.cctor>b__d(ByVal left As Expression, ByVal right As Expression) As Expression
Return Expression.GreaterThanOrEqual(left, right)
End Function


...全文
283 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
呵呵,“反编译”。
threenewbee 2013-07-06
  • 打赏
  • 举报
回复
引用 5 楼 kernelj 的回复:
谢谢版主提醒,下面是反编译的C#代码
 Dictionary<QueryMethod, Func<Expression, Expression, Expression>> dictionary = new Dictionary<QueryMethod, Func<Expression, Expression, Expression>>();
        if (QueryableSearcher<T>.CS$<>9__CachedAnonymousMethodDelegate16 == null)
        {
            QueryableSearcher<T>.CS$<>9__CachedAnonymousMethodDelegate16 = new Func<Expression, Expression, Expression>(null, (IntPtr) QueryableSearcher<T>.<.cctor>b__b);
        }
        dictionary.Add(QueryMethod.Equal, QueryableSearcher<T>.CS$<>9__CachedAnonymousMethodDelegate16);

private static Expression <.cctor>b__b(Expression left, Expression right)
{
    return Expression.Equal(left, right);
}

有没有更多的代码,没有上下文,没办法分析。 个人的猜测,这是一个用来优化Linq表达式的代码。 QueryMethod.Equal枚举对应了这样一个表达式工厂。 传入两个表达式,将他们组合成一个相等比较的表达式。 比如dict[QueryMethod.Equal](Expression.Constant(a), Expression.Constant(b)) 返回 a == b
liuyilin777 2013-07-06
  • 打赏
  • 举报
回复
似乎是被加密了
kernelj 2013-07-06
  • 打赏
  • 举报
回复
其实代码的意思我能够理解,QueryableSearcher<T>.CS$<>9__CachedAnonymousMethodDelegate16 是一个匿名代理,他指向的是 <.cctor>b__b 方法,然后放在 dictionary 中,我就是不是很懂,这个正常情况下是怎么写的
kernelj 2013-07-05
  • 打赏
  • 举报
回复
谢谢版主提醒,下面是反编译的C#代码
 Dictionary<QueryMethod, Func<Expression, Expression, Expression>> dictionary = new Dictionary<QueryMethod, Func<Expression, Expression, Expression>>();
        if (QueryableSearcher<T>.CS$<>9__CachedAnonymousMethodDelegate16 == null)
        {
            QueryableSearcher<T>.CS$<>9__CachedAnonymousMethodDelegate16 = new Func<Expression, Expression, Expression>(null, (IntPtr) QueryableSearcher<T>.<.cctor>b__b);
        }
        dictionary.Add(QueryMethod.Equal, QueryableSearcher<T>.CS$<>9__CachedAnonymousMethodDelegate16);

private static Expression <.cctor>b__b(Expression left, Expression right)
{
    return Expression.Equal(left, right);
}

kernelj 2013-07-05
  • 打赏
  • 举报
回复
之前的代码是什么写的反编译出来就是什么吧,选不了反编译成什么语言
threenewbee 2013-07-05
  • 打赏
  • 举报
回复
你还不如反编译成C#形式,再帮你写成VB.NET代码。
kernelj 2013-07-05
  • 打赏
  • 举报
回复
这个代码是编译不过的
rtdb 2013-07-05
  • 打赏
  • 举报
回复
翻译为正确的代码? 什么意思?原代码怎么了?

16,549

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧