public override bool IsAvailable(IUserDataHolder cache) { myMethodDeclaration = myProvider.GetSelectedElement<IMethodDeclaration>(true, true); if (myMethodDeclaration == null) return false; // only on non-generic methods var method = myMethodDeclaration.DeclaredElement; if (method == null || method.TypeParameters.Any()) return false; if (!method.IsStatic) { // only on non-generic types myClassDeclaration = method.GetContainingType() as IClass; if (myClassDeclaration == null || myClassDeclaration.HasTypeParameters()) return false; // with default constructor if (!myClassDeclaration.IsStatic || (!myClassDeclaration.Constructors.IsEmpty() && !myClassDeclaration.Constructors.Any(c => c.Parameters.IsEmpty()))) return false; } return !method.Parameters.Any(); }