CodeDom generic type constraint
问题 Is there a way to generate a class constraint with CodeDom. Because when I use something like var method = new CodeMemberMethod(); var genericParam = new CodeTypeParameter("InterfaceType"); genericParam.Constraints.Add("class"); method.TypeParameters.Add(genericParam); the generated code is like private InterfaceType GetImpl<InterfaceType>() where InterfaceType : @class { } The best workaround i found is to use a leading whitespace before the class genericParam.Constraints.Add(" class"); But