Here's what I want the resulting class declaration to look like:
public sealed partial class Refund : DataObjectBase<Refund>
{
}
}
This code (snipped):
targetClass = new CodeTypeDeclaration(className);
targetClass.IsClass = true;
targetClass.TypeAttributes =
TypeAttributes.Public | TypeAttributes.Sealed;
targetClass.IsPartial = true; //partial so that genn'ed code can be safely modified
targetClass.TypeParameters.Add(new CodeTypeParameter{ Name=className});
targetClass.BaseTypes.Add(new CodeTypeReference { BaseType = "DataObjectBase", Options = CodeTypeReferenceOptions.GenericTypeParameter });
Produces this class declaration:
public sealed partial class Refund<Refund> : DataObjectBase
{
}
What am I doing wrong?
If you use Expressions to CodeDOM it could be
I think that the following string for the BaseType should do the trick (untested):
It may be possible that you need to provide a fully-qualified name for
Refund
, at least including the assembly name:And you should then remove the line
targetClass.TypeParameters.Add(...)
.