Closed GoogleCodeExporter closed 8 years ago
Can you clarify? perhaps giving an example of where it is impossible /
undesirable to add a using directive?
Original comment by marc.gravell
on 9 Jun 2011 at 10:36
You can just store the result of a .Step() call in a variable:
var disposeMeLater = MiniProfiler.Current.Step("This spans lots of stuff!");
...
if (disposeMeLater != null)
disposeMeLater.Dispose(); // stop this step's timer
The extension method .Step() protects you from having to check
MiniProfiler.Current != null
every time you want to call .Step()
Original comment by jarrod.m.dixon
on 9 Jun 2011 at 10:39
@marc,
I was planning on wrapping the code for starting and stopping in an `#if
PROFILING` directive, and I wanted to have it all together; forcing a using
makes it such that I can't do "remove and sort usings", because one of them
would be wrapped in the `#if` directives. I also wanted to use it in my
_Layout.cshtml, without adding it to my web.config.
@jarrod,
Did that comment belong on issue #4, perhaps?
Original comment by Spoonful...@gmail.com
on 10 Jun 2011 at 12:36
I was just giving an example of how to use .Step() outside of a using block
(yes, it's not the prettiest code).
I don't know how we could make this cleaner, other than exposing
MiniProfiler.StepImpl() to return a Timing object, which you could then call
.Stop() on.
Original comment by jarrod.m.dixon
on 13 Jun 2011 at 6:54
[deleted comment]
Right, however, this request is to drop the need for:
using MvcMiniProfiler;
namespace Foo
{
...
}
issue #4 discusses a non-IDisposable version of `Step`.
Original comment by Spoonful...@gmail.com
on 13 Jun 2011 at 7:34
Could we add some static methods on `MvcProfiler` that make use of the existing
extension methods?
Something like:
public class MvcProfiler
{
...
public static IDisposable Step(string name, ProfileLevel level = ...)
{
return MvcProfiler.Current.Step(name, level);
}
}
That would allow us to call `MvcProfiler.Step` statically, eliminating the need
for extension methods in the simple case.
Original comment by Spoonful...@gmail.com
on 13 Jun 2011 at 7:39
http://code.google.com/p/mvc-mini-profiler/source/detail?r=b867900956199fe09873c
d73460910a122f5eb5a
If you can think of a better name, I'm happy to change it!
Original comment by jarrod.m.dixon
on 14 Jun 2011 at 10:29
Original comment by jarrod.m.dixon
on 14 Jun 2011 at 10:38
Original issue reported on code.google.com by
Spoonful...@gmail.com
on 9 Jun 2011 at 5:55