I need a way to check out all namespaces used by a type via reflection.
namespace My.Program.BaseTypes { using System; using System.Text; using My.Program.Extenders; using My.Program.Helpers; using My.Program.Interfaces; public class MyTypeBase { public MyTypeBase() { } public My.Program.Helpers.HelperTypeX X { get; set; } public My.Program.Extenders.ExtenderTypeY Y { get; set; } public My.Program.Interfaces.InterfaceZ IZ { get; set; } } } I have only the Type of MyTypeBase in my code and need to find out with reflection all referenced namespaces of all Properties in MyTypeBase.
Sure I could loop through all Properties, get the types from them and check their namespaces, but is there a cleaner way of achiving this goal?
To prevent the question, it is for writing a generator which shall create new classes based on some legacy code.