add generic support for fragment types.
Merge pull request #3789 from hieupham007/fragments

Add generic support for fragment types.