Cobol.Net 到 C# 转换器
我们在 Micro Focus Cobol.Net 中有一些系统,我们正在考虑将其转换为 C#。
我们尝试在反射器中打开 dll,但随后我们只得到 C 代码。
有人建议如何执行此操作吗?
当我在反射器中选择 C# 时,我得到的代码如下所示:
meminit(&(this._MF_OSBLOCK[0]), 0x20, 4);
this._MF_OSBLOCK[4] = 0x30;
this._MF_OSBLOCK[5] = 0x30;
this._MF_OSBLOCK[6] = 0x30;
this._MF_OSBLOCK[7] = 0x30;
meminit(&(this._MF_OSBLOCK[8]), 0x20, 30);
memcpy(&(this._MF_OSBLOCK[0x26]), &(_MF_LITBLOCK[0]), 2);
int num2 = 0;
do
{
memcpy(&(this._MF_OSBLOCK[40 + num2]), &(_MF_LITBLOCK[0]), 2);
}
while ((num2 += 2) < 0xc6);
memcpy(&(this._MF_OSBLOCK[240]), &(_MF_LITBLOCK[2]), 4);
We have some systems in Micro Focus Cobol.Net which we are considering converting to C#.
We have tried opening up the dll's in reflector, but then we just get C code.
Anyone have a recommendation of how to do this?
When I select C# in reflector I get code that looks like this:
meminit(&(this._MF_OSBLOCK[0]), 0x20, 4);
this._MF_OSBLOCK[4] = 0x30;
this._MF_OSBLOCK[5] = 0x30;
this._MF_OSBLOCK[6] = 0x30;
this._MF_OSBLOCK[7] = 0x30;
meminit(&(this._MF_OSBLOCK[8]), 0x20, 30);
memcpy(&(this._MF_OSBLOCK[0x26]), &(_MF_LITBLOCK[0]), 2);
int num2 = 0;
do
{
memcpy(&(this._MF_OSBLOCK[40 + num2]), &(_MF_LITBLOCK[0]), 2);
}
while ((num2 += 2) < 0xc6);
memcpy(&(this._MF_OSBLOCK[240]), &(_MF_LITBLOCK[2]), 4);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以放心地假设您正在查看 C# 代码,Reflector 没有 C 代码转换器。您不能假设 Cobol 编译器正在生成正常的 C# 代码。它没有义务这样做。它可以自由地使用在特定于编译器的运行时程序集中定义的辅助函数。与 Microsoft.CSharp.dll 不同。
获得使用类似 C 名称的帮助程序的代码并不意外,C 长期以来一直是随处运行的语言。编译器常常是语言翻译器,在本例中从 Cobol 翻译为 C,然后使用 C 编译器生成特定于平台的机器代码。编写一次,随处运行。将 C 视为过去的 IL。
您当然可以编译并运行生成的 C# 代码,请务必使用 Cobol 特定的程序集引用。您可能必须从 GAC 中挖掘它。就获得像样的 C# 代码而言,几乎没有。语言之间的差异太大了。
You can safely assume you are looking at C# code, Reflector doesn't have a code converter for C. What you can't assume is that the Cobol compiler is generating sane C# code. It has no obligation in doing so. It can freely use helper functions that are defined in a runtime assembly that's specific to the compiler. Not unlike Microsoft.CSharp.dll.
Getting code that uses helpers with C-like names is not unexpected, C has been the run-anywhere language for a very long time. Compilers not infrequently were language translators, going from Cobol to C in this case and then using a C compiler to generate the platform specific machine code. Write once, run anywhere. Think of C as the IL of the olden days.
You can surely compile and run the generated C# code, be sure to use that Cobol specific assembly reference. You may have to dig it out of the GAC. As far as a running start to get decent C# code, hardly. The differences between the languages are too great.
在 Reflector 中打开 .NET dll 肯定不会显示 C 代码。它可能会显示托管 C++ 代码,但只需在工具栏的语言组合框中选择 C# 即可更改。
考虑使用FileDisassembler 插件,它允许从程序集创建完整的项目。
Opening a .NET dll in Reflector surely doesn't show C code. It might show Managed C++ code, but that can be changed simply by choosing C# in the language combobox in the toolbar.
Consider using the FileDisassembler add in, which allows to create a complete project from the assembly.