Can I somehow run a single method in C# using Visual Studio 2017 / ReSharper in order to debug it? I am aware that I can:
All of these are time consuming and I am wondering if there is some alternative.
EDIT: In SQL Management Studio, I can highlight an individual query and run it. I want some way to debug C# methods like this (obviously I would need to provide params for this). I haven't heard of anything like that, but it doesn't hurt to ask.
You can use the C# interactive window (it doesn't support debugging, but lets you quickly iterate on functions).
You can highlight chunks of code and then click on the Execute in Interactive menu item.
To use this effectively, you probably need to add some references and some using blocks to the interactive window.
To add a reference, you can use the #r command:
#r "System.Windows.Forms"
#r "C:\Full\Path\To\Your\Reference\Assembly.dll"
You can use using blocks from there using the normal syntax
using System.Windows.Forms
You can also declare and use objects within the scope of the interactive window:
var f = new Form();
f.ShowDialog();
If you ever need to cleanup your interactive window, you can use the reset command:
#reset
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With