For a cross platform library in C#, I wish to have a certain set of methods marked protected for extensibility purposes. These methods are later accessed by reflection, using meta-programming with attributes
However, on Windows Phone 7 accessing protected methods by reflection isn’t allowed, and instead I wish for them to be marked internal.
So what I’m wondering, is if I could do something like this, in C#, or if there’s a better workaround for it?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
#if WINDOWS_PHONE
#define ACCESSOR internal
#else
#define ACCESSOR protected
#endif
namespace Example
{
public class MyTestClass
{
[MyAttribute]
ACCESSOR void MyMethod()
{
}
}
}
You can do this:
But you’re better off making them
internalorprotected internal.