Trace implementation for static methods.
-
Hi, My C# code calls to bunch of external methods exported from gdi32.dll That’s example of the code we use to export the methods from the dll:
[DllImport("gdi32.dll")] internal static extern int ExtEscape(HDC hDC, int nEscape, int inputSize, ref CWDDECMD InputData, int outputSize, ref CIWSINFO OutputData); … [DllImport("gdi32.dll")] internal static extern int ExtEscape(HDC hDC, int nEscape, int inputSize, ref CWDDECMD InputData, int outputSize, ref CIOVLTHEATERMODE OutputData);
There are over two hundred of method declarations and they are different only by type of parameters (ie CIWSINFO versus CIOVLTHEATERMODE in this examle). The methods are called from all around the code. Now I have to come with design that allows tracing calls to the methods While printing the name of the method and type and values of passed parameters (this part is simple as each passed type implements ToString method). I just hate idea of duplicating each declaration with the method that performs tracing before calling to real method:[DllImport("gdi32.dll")] internal static extern int ExtEscape(…); static int ExtEscapeTrace (…) { DoTrace (); ExtEscape (…) ; //Perform real call }
To bad the methods are static; otherwise I would be able to use proxies. Any ideas?