[Mono-devel-list] [patch] c# CodeGenerator enum output
Jackson Harper
jackson at ximian.com
Mon Jul 12 21:53:28 EDT 2004
This looks good to me. Please commit.
Bonus points and a warp whistle if you add a test case to the unit
tests.
Thanks!
Jackson
On Sun, 2004-07-11 at 19:09, Fawad Halim wrote:
> Hi,
> Attached patch fixes a small bug with the output of the enum
> expression in the C# Generator. For example,
>
> CodeTypeDeclaration colorEnum=new CodeTypeDeclaration("Colors");
> colorEnum.IsEnum=true;
> colorEnum.Members.Add(new CodeMemberField(typeof(int),"Green"));
>
> was generating
>
> public enum Colors{int Green,}
>
> which doesn't compile.
>
> Ok to commit?
>
> ______________________________________________________________________
> ? patch_codedom_enum.diff
> ? class/Commons.Xml.Relaxng/y.output
> ? class/Microsoft.VisualBasic/Microsoft.VisualBasic/VBUtils.resources
> Index: class/System/Microsoft.CSharp/CSharpCodeGenerator.cs
> ===================================================================
> RCS file: /cvs/public/mcs/class/System/Microsoft.CSharp/CSharpCodeGenerator.cs,v
> retrieving revision 1.23
> diff -u -r1.23 CSharpCodeGenerator.cs
> --- class/System/Microsoft.CSharp/CSharpCodeGenerator.cs 23 Jun 2004 16:25:02 -0000 1.23
> +++ class/System/Microsoft.CSharp/CSharpCodeGenerator.cs 12 Jul 2004 01:08:01 -0000
> @@ -503,7 +503,10 @@
> OutputMemberAccessModifier( attributes );
> OutputFieldScopeModifier( attributes );
>
> - OutputTypeNamePair( field.Type, GetSafeName (field.Name) );
> + if (IsCurrentEnum)
> + Output.Write(field.Name);
> + else
> + OutputTypeNamePair( field.Type, GetSafeName (field.Name) );
>
> CodeExpression initExpression = field.InitExpression;
> if ( initExpression != null ) {
More information about the Mono-devel-list
mailing list