public async Task <MethodDescriptor> FindMethodImplementationAsync(MethodDescriptor methodDescriptor, TypeDescriptor typeDescriptor) { //var roslynMethod = RoslynSymbolFactory.FindMethodInCompilation(methodDescriptor, this.Compilation); var methodParserInfo = await this.FindMethodInProjectAsync(methodDescriptor); //if (roslynMethod != null) if (methodParserInfo != null) { var roslynMethod = methodParserInfo.MethodSymbol; var roslynType = RoslynSymbolFactory.GetTypeByName(typeDescriptor, this.Compilation); var implementedMethod = Utils.FindMethodImplementation(roslynMethod, roslynType); //Contract.Assert(implementedMethod != null); if (implementedMethod != null) { methodDescriptor = Utils.CreateMethodDescriptor(implementedMethod); } } else { // If it is interface/abstract or code that we did not parse (library) var roslynMethod = RoslynSymbolFactory.FindMethodInCompilation(methodDescriptor, this.Compilation); if (roslynMethod != null) { var roslynType = RoslynSymbolFactory.GetTypeByName(typeDescriptor, this.Compilation); var implementedMethod = Utils.FindMethodImplementation(roslynMethod, roslynType); if (implementedMethod != null) { methodDescriptor = Utils.CreateMethodDescriptor(implementedMethod); } } } // TODO: If we cannot resolve the method, we return the same method. // Maybe we should consider to return null instead? return(methodDescriptor); }
public Task <MethodDescriptor> FindMethodImplementationUsingRoslynAsync(MethodDescriptor methodDescriptor, TypeDescriptor typeDescriptor) { var roslynMethod = RoslynSymbolFactory.FindMethodInCompilation(methodDescriptor, this.Compilation); if (roslynMethod != null) { var roslynType = RoslynSymbolFactory.GetTypeByName(typeDescriptor, this.Compilation); var implementedMethod = Utils.FindMethodImplementation(roslynMethod, roslynType); //Contract.Assert(implementedMethod != null); if (implementedMethod != null) { methodDescriptor = Utils.CreateMethodDescriptor(implementedMethod); } else { Logger.LogS("BaseProjectCodeProvider", "FindMethodImplementationAsync", "Cannot find implementation for method {0}", methodDescriptor); } } // If we cannot resolve the method, we return the same method. return(Task.FromResult(methodDescriptor)); }