IDISP0004 false positive for DiagnosticSource.StartActivity
Bouke opened this issue · comments
Bouke Haarsma commented
DiagnosticSource.StartActivity returns the activity
instance that was passed as an argument. The analyzer suggests to also dispose the returned activity, however it is already being disposed with the using on the first line:
using var activity = new Activity("Do work");
activity.SetParentId(parentId);
↓diagnosticSource.StartActivity(activity, new { work });
However with a pattern like the following, we should still raise IDISP0004 as expected:
diagnosticSource.StartActivity(↓new Activity("Do work"), new { work });