RoslynClrHeapAllocationAnalyzer
RoslynClrHeapAllocationAnalyzer copied to clipboard
Disabling for Unit Tests and knobs/dials for reducing simple allocations
Unit tests and dialing down are somewhat related. I need to tap into the configuration APIs to get some info about what context I'm running in.
Furthermore it seems like the barrage of warnings is dissuading its usage. So need to figure out a way to make the dial down configurable or a good default.
For me, I think the ability to set user-defined levels for different analyzers is key for the usefulness of this addin. As have been noted elsewhere, some analyzers cause a lot of noise and it would be useful to be able to turn them off.
I have pushed a branch on my fork, VsOptions branch, adding settings for the analyzers to the Visual Studio Options dialog:

The General tab does not contain much right now, but I think that we should make the #25 configurable as to which pattern to ignore, which would fit there.
The settings can also be used within unit tests if deemed wanted, otherwise they are set to the old default values.
One question regarding settings is how to persist them.
In my current implementation I do it via the WritableSettingsStore. An alternative, however, would be to create and/or use a .ruleset file. That way it would be easier to share settings and also to reuse settings between the VS analyzer and the build analyzer.
@edespong I think the ruleset option is better, but the store one is also useful. I'm not familiar enough with VS APIs. Can we have both?
I think we can, and should, have both. I see an issue in where this .ruleset would be located, though. The settings would be global settings, but you want to have a ruleset for each solution/project. I do not want to be working with/changing the ruleset of solution A when having opened solution B.
I cannot think of a really good solution off the top of my head.
I will start by creating a PR for adding the VS API one and then we can discuss a way forward regarding the ruleset option.