Your class code doesn't care because of this line of code.

Dim methods As MethodInfo() = Me.GetType.GetMethods

The GetMethods can occur from anywhere, so you could do it against any other class.

Dim methods As MethodInfo() = SomeOtherClass.GetType().GetMethods()

See what I mean? All you need is [CustomAttribute()] on methods inside SomeOtherClass.

As for the developer knowing whether the attribute exists or not, that's a matter of referencing whatever assembly the CustomAttribute class is in.




Take your webmethod as an example. WebMethodAttribute just happens to be in System.Web.Services but importantly, it inherits from Attribute. Web service codebehind classes inherit from System.Web.Services.WebService. Attributes are a completely different area of the .NET framework as you can see.