Android Studio does this by default, and it works quite well. It's called Sticky Lines.
For JetBrains Rider it only seems to be working for class names but not methods. I was able to get something similiar using this answer. Go to settings > appearance and tick "Show breadcrumbs". And pin it to the top instead of the bottom if that's where you want to see it: