clrinterop/clrinterop-issues-sandbox

Remove the word Attribute from Attributes in generated code and optionally remove namespaces

Opened this issue · 0 comments

Issue from Fri, 07 Sep 2012 13:09:23 GMT
Originally opened at https://clrinterop.codeplex.com/workitem/10470


The code generated by this tool is very verbose. Since the general use case is to hand edit the generated code, it should be made more terser for readability.
 
First of all all attribute decorations should not include the word Attribute. e.g DllImportAttribute should become DllImport. Secondly, there should be an option to not qualify attributes with namespaces. Here is a real life example:
 
Currently:
[System.Runtime.InteropServices.DllImportAttribute("", EntryPoint="TraceOpenLogFile")]
public static extern short TraceOpenLogFile(
[System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPWStr)] System.Text.StringBuilder s,
[System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPWStr)] System.Text.StringBuilder t,
uint w) ;
 
After
[DllImport("", EntryPoint="TraceOpenLogFile")]
public static extern short public static short TraceOpenLogFile(
[MarshalAs(UnmanagedType.LPWStr)] StringBuilder s,
[MarshalAs(UnmanagedType.LPWStr)] StringBuilder t,
uint w);
 
 
In both cases i formatted the code slightly.