I am trying to generate a class hierarchy like this:
public class A {
public class A.Helper {
}
}
public class B: A {
public new class B.Helper: A.Helper {
}
}
CodeDOM apparently ignores the Attribute property on the CodeTypeDeclaration
object for nested types and uses the TypeAttributes property to decorate the
type declaration. However, TypeAttributes does not permit you to express an
equivalent to MemberAttributes.New, and the B.Helper class above comes out
without the new modifier.
The generated code compiles and works fine, but with the warning level set
at 1 or above, I have to filter through lots of warnings about missing "new"
modifiers, which makes it hard to find other, more significant, warnings.
I've tried this in framework versions 1.0, 1.1, and PDC bits of 1.2 with the
same result.
This problem has been discussed in various dotnet newsgroups, but never with
any response from Microsoft. Can anyone in the CLR (or appropriate) group
suggest a workaround?
Thanks,
Eric Schoen
Gang Peng[MSFT] - 03 Dec 2003 21:36 GMT
You are right. You don't have a way to specify "new" for type declaration
in CodeDom.
CodeDom is not designed to generate any code you can possible write. It is
meant to be a subset of all languages.
You need to generate different code.
I don't see why you would need to generate the code you mentioned above.
If you can illustrate the scenario, we can see if it is important enough
for us to support in future.
Gang Peng
[MS]