public static DiagnosticSourceStub CreateNewSource(string diagnosticSourceName)
        {
            Validate.NotNull(diagnosticSourceName, nameof(diagnosticSourceName));

            DynamicInvoker_DiagnosticListener invoker = null;

            try
            {
                invoker = DynamicInvoker.Current.DiagnosticListener;
                object diagnosticListenerInstance = invoker.Call.Ctor(diagnosticSourceName);
                return(DiagnosticSourceStub.Wrap(diagnosticListenerInstance));
            }
            catch (Exception ex)
            {
                throw LogAndRethrowStubInvocationError(ex, invoker?.GetType(), nameof(DynamicInvoker_DiagnosticListener.StubbedApis.Ctor), invoker?.TargetType);
            }
        }
        internal static bool TryWrap(object diagnosticSourceInstance, out DiagnosticSourceStub diagnosticSourceStub)
        {
            if (diagnosticSourceInstance == null)
            {
                diagnosticSourceStub = NoOpSingeltons.DiagnosticSourceStub;
                return(true);
            }

            DynamicInvoker_DiagnosticSource invoker = DynamicInvoker.Current.DiagnosticSource;

            if (invoker != null && invoker.TryGetInvokerHandleForInstance(diagnosticSourceInstance, out DynamicInvokerHandle <DynamicInvoker_DiagnosticSource> handle))
            {
                diagnosticSourceStub = new DiagnosticSourceStub(diagnosticSourceInstance, handle);
                return(true);
            }
            else
            {
                diagnosticSourceStub = NoOpSingeltons.DiagnosticSourceStub;
                return(false);
            }
        }