Fix a race and inefficiency in Microsoft-Diagnostics-DiagnosticSource (dotnet/corefx#35764)
* Fix a race and inefficiency in Microsoft-Diagnostics-DiagnosticSource
There is a bridge from DiagnosticSource to EventSoruce called Microsoft-Diagnostics-DiagnosticSource.
This bridge take the data object payload and derializes it int EventSource events.
There was a cache that kept the type and it cooresponding serialization transform of the last object, which were not atomic and thus could be confused if code was executed concurrently.
In this cache is per EXPLICITLY filtered events, and works well for that case. If however the transform is implicit, many events can share the same cache slot, and the cache becomes very ineffective.
To fix this we keep the existing one element cache, but we only set it once (which keeps things simple but avoids races and covers the explicitly filtered case), and add a lazily created ConcurrentDictionary for the 'many envent' case.
Also fixes some unrelate test issues (avoided using the same DiagnosticListner names so that tests don't interact when run concurrently), Fixed issue were a test fails under the debugger (because the debugger turns on Microsoft-Diagnostics-DiagnosticSource which interfers with the test).
I did walk new code to insure that we at least had code coverage for the new code over our set of tests.
* Review feedback.
Basically rather than tolerate races, change to code to remove them.
This makes the code less error prone.
* Fix more nits.
* fix whitespace
* comment and use lambda so c# caches it.
* fix typo
* add in deleted line
Commit migrated from https://github.com/dotnet/corefx/commit/
a8cef502cd74aabb209cb9ad7a1e2a5bc1612459