Is it possible with Roslyn to find out if the class method implements any interface method that was marked with the attribute?
In particular, in wcf we describe service contracts using an interface. Each of its methods should be marked OperationContractAttributeas in the following example.
[ServiceContract]
public interface ISimleService
{
[OperationContract]
string GetData(int value);
}
public class SimleService : ISimleService
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
}
In the Roslyn interface, ISymbolwe get the GetAttributes () method, but call the method SimleService.GetData()that returns 0. The called << 24> declaration returns OperationContractAttributeas expected.
So, in general, I need to check the class hierarchy to find all implemented interfaces, and then go through the hierarchy to find suitable methods. This is the hard way, and I think it should be easier.