What do you mean? It works fine for me.... If I have code written in C# I can
decompile it in managed C++ but in order for that to work I need to reference
the McppLanguage DLL.
A little test:
The Iterator design pattern written in C#:
namespace Iterator
{
internal abstract class AbstractCollect ion
{
// Methods
protected AbstractCollect ion();
public abstract Iterator.Iterat or CreateIterator( );
}
internal abstract class AbstractIterato r
{
// Methods
protected AbstractIterato r();
public abstract Item CurrentItem();
public abstract Item First();
public abstract bool IsDone();
public abstract Item Next();
}
internal class Collection : AbstractCollect ion
{
// Methods
public Collection();
public override Iterator.Iterat or CreateIterator( );
// Properties
public int Count { get; }
public object this[int index] { get; set; }
// Fields
private ArrayList items;
}
public class Form1 : Form
{
// Methods
public Form1();
protected override void Dispose(bool disposing);
private void Form1_Load(obje ct sender, EventArgs e);
private void InitializeCompo nent();
[STAThread]
private static void Main();
// Fields
private Container components;
private TextBox txtIteratorText ;
}
internal class Item
{
// Methods
public Item(string name);
// Properties
public string Name { get; }
// Fields
private string name;
}
internal class Iterator : AbstractIterato r
{
// Methods
public Iterator(Collec tion collection);
public override Item CurrentItem();
public override Item First();
public override bool IsDone();
public override Item Next();
// Properties
public int Step { get; set; }
// Fields
private Collection collection;
private int current;
private int step;
}
}
Compiled then decompiled to C++ using Reflector:
namespace Iterator
{
private __gc abstract class AbstractCollect ion
{
// Methods
protected: AbstractCollect ion();
public: abstract Iterator::Itera tor __gc * CreateIterator( );
};
private __gc abstract class AbstractIterato r
{
// Methods
protected: AbstractIterato r();
public: abstract Iterator::Item __gc * CurrentItem();
public: abstract Iterator::Item __gc * First();
public: abstract System::Boolean IsDone();
public: abstract Iterator::Item __gc * Next();
};
[System::Reflect ion::DefaultMem ber(S"Item")]
private __gc class Collection : public Iterator::Abstr actCollection
{
// Methods
public: Collection();
public: override Iterator::Itera tor __gc * CreateIterator( );
// Properties
public: __property System::Int32 get_Count();
public: __property System::Object __gc * get_Item(System ::Int32
index);public: __property void set_Item(System ::Int32 index, System::Object
__gc * value);
// Fields
private: System::Collect ions::ArrayList __gc * items;
};
public __gc class Form1 : public System::Windows ::Forms::Form
{
// Methods
public: Form1();
protected: override void Dispose(System: :Boolean disposing);
private: void Form1_Load(Syst em::Object __gc * sender,
System::EventAr gs __gc * e);
private: void InitializeCompo nent();
[System::STAThre ad]
private: static void Main();
// Fields
private: System::Compone ntModel::Contai ner __gc * components;
private: System::Windows ::Forms::TextBo x __gc * txtIteratorText ;
};
private __gc class Item
{
// Methods
public: Item(System::St ring __gc * name);
// Properties
public: __property System::String __gc * get_Name();
// Fields
private: System::String __gc * name;
};
private __gc class Iterator : public Iterator::Abstr actIterator
{
// Methods
public: Iterator(Iterat or::Collection __gc * collection);
public: override Iterator::Item __gc * CurrentItem();
public: override Iterator::Item __gc * First();
public: override System::Boolean IsDone();
public: override Iterator::Item __gc * Next();
// Properties
public: __property System::Int32 get_Step();publ ic: __property
void set_Step(System ::Int32 value);
// Fields
private: Iterator::Colle ction __gc * collection;
private: System::Int32 current;
private: System::Int32 step;
};
}
Any questions?
Yama
"James" wrote:
thanks, but unfortunately Reflector doesn't cover Managed C++.
Thinking about it though, I'm not sure that we really want to write code in
the Managed c++ syntax.
We will probably just write our C# code outside our managed C++ project and
include the assemblies.
(We are using managed C++ in order to write all new dialogs as win forms. We
can't throw all the c++ code away although I wish we could.)
"Yama" wrote:
You can compile then decompile your code from C# to C++.NET using Reflector:
http://www.aisto.com/roeder/dotnet/D...File=Reflector
C++ AddIn
http://www.testdriven.net/downloads/...ppLanguage.dll
Steps:
Once downloaded open Reflector
Click the View menu and select the Add-Ins... item.
Click on Add and select the McppLanguage.dl l you downloaded.
1. Compile your program either a DLL or EXE
2. Open it with Reflector
3. Select the language you want your source code decompiled in.
4. Right click on the class your want to decompile.
Hope this helps,
Yama Kamyar
"James" wrote:
Has anyone written a utility to convert a C# form to C++.net?
i.e. to convert "using System.Data" to "using namespace System::Data" etc