0

So I currently write code analyzer with roslyn for c#, but now I'm stuck.

I want to analyze extension methods. It is demanded that the namespace the extension is declared in, equals the namespace of the class passed with the 'this' argument.

Example:

   namespace Project.Test
{
    public static class Test
    {
        public static SomeCustomClass MethodName( this SomeCustomClass object )
        {
            //...
        }
    }
}

So I want to get the original namespace of "SomeCustomClass". It is defined somewhere in the solution.

I'm really struggling with this one. Thanks for the help and have a nice day!

TL;DR How do I get the original namespace of a class, when it is referenced in another file and/or another namespace?

Tom
  • 1
  • Look here: https://msdn.microsoft.com/en-us/library/system.type.namespace(v=vs.110).aspx – Sasha Jul 20 '18 at 09:31
  • Thanks! I was almost right. I just was confused because the namespace I got - when the Type wasn't declared anywhere - was global namespace. Thanks for the help :) – Tom Jul 20 '18 at 15:12
  • No problem, glad it's sorted. – Sasha Jul 20 '18 at 15:14

0 Answers0