As I understand, it’s good practice on public APIs to have the CancellationToken parameter as the last one and for it to be optional with a default value of None.
However, if I have internal methods, I don’t want to make the CancellationToken optional because I want to ensure it’s propagated through properly. However, if that method has other optional parameters then what is the better thing to do?
- Make the CancellationToken optional as the last parameter with a default value of None (even though I don’t actually want to do it) or
- Keep the CancellationToken non-optional and have it as the last non-optional parameter while the optional parameter(s) then come after it?