How to get number of parameters of FuncOp?

I have a function like this:

func.func @test(%arg0: i32) -> i32 attributes {llvm.linkage = #llvm.linkage<external>} {
  %c1_i32 = arith.constant 1 : i32
  return c1_i32 : i32
}

I want to get the number of parameter %arg0: i32 , but:

func::FuncOp func = getOperation();
Block* block=func.getOperation()->getBlock();
std::cout<<block->getNumArguments()<<std::endl;

return 0. How can I get it?

Oh, I know the funop argument is related to a region

This gives you the parent block of the operation, e.g., the block that contains it. What you need is the entry block of the function body region, which is you can get as func.front() provided the function is non-empty.