z_e*_*_eb 8 c# decompiling visual-studio
我有
但是当我然后查看例如 .NET 框架中任何引用类的反编译源代码时,例如System.Console或 for Microsoft.AspNetCore.Builder(或几乎任何其他类型),我能看到的每个方法的主体都是 throw null(我在下面展示了一个摘录)
我已经阅读了这个问题(更新:和问题的答案是重复的),但是只有一个班级有这个问题(因为它是在增量更新中添加的)。对我来说,这个问题适用于 .NET 框架中的每个类。我究竟做错了什么?这是预期的行为,我应该使用 dotPeek 之类的东西吗?我可以使用符号服务器而不是反编译源吗?(原谅我的无知,我真的是 C# 的新手......和 .NET 世界)
region Assembly System.Console, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\3.0.0\ref\netcoreapp3.0\System.Console.dll
// Decompiled with ICSharpCode.Decompiler 4.0.0.4521
#endregion
using System.IO;
using System.Text;
namespace System
{
// Summary:
// ....
public static ConsoleColor BackgroundColor
{
get
{
throw null;
}
set
{
}
}
//
// Summary:
//...
public static int BufferHeight
{
get
{
throw null;
}
set
{
}
}
...
Run Code Online (Sandbox Code Playgroud)
你用ILSpy试过吗?
您可以独立使用它(这里的免费版本:https://github.com/icsharpcode/ILSpy),但是如果您有 LinqPad,则包含 ILSpy(我认为在付费版本中)。
请尝试以下方法:
创建一个示例程序,其中包含您想要检查的 1 行:
void Main()
{
System.Console.Clear();
}
Run Code Online (Sandbox Code Playgroud)
将鼠标指针置于“Clear()”上,然后按 F12。
ILSpy 打开,显示您将光标设置在其上的方法:
// System.Console
public static void Clear()
{
ConsolePal.Clear();
}
Run Code Online (Sandbox Code Playgroud)
在左侧,您可以进一步深入了解反编译的类,例如
internal static class ConsolePal
{
[Flags]
internal enum ControlKeyState
{
RightAltPressed = 0x1,
LeftAltPressed = 0x2,
RightCtrlPressed = 0x4,
LeftCtrlPressed = 0x8,
ShiftPressed = 0x10,
NumLockOn = 0x20,
ScrollLockOn = 0x40,
CapsLockOn = 0x80,
EnhancedKey = 0x100
}
private sealed class WindowsConsoleStream : ConsoleStream
{
private readonly bool _isPipe;
private IntPtr _handle;
// ...
Run Code Online (Sandbox Code Playgroud)
注意:作为 LinqPad 的替代方案,Visual Studio 2022 还默认启用对 F12 的反编译支持。
| 归档时间: |
|
| 查看次数: |
566 次 |
| 最近记录: |