/// <summary>
 /// Gets the test case discover instance for the given discoverer type. The instances are cached
 /// and reused, since they should not be stateful.
 /// </summary>
 /// <param name="discovererType">The discoverer type.</param>
 /// <returns>Returns the test case discoverer instance.</returns>
 protected IXunitTestCaseDiscoverer GetDiscoverer(Type discovererType)
 {
     try
     {
         return(ExtensibilityPointFactory.GetXunitTestCaseDiscoverer(DiagnosticMessageSink, discovererType));
     }
     catch (Exception ex)
     {
         DiagnosticMessageSink.OnMessage(new DiagnosticMessage($"Discoverer type '{discovererType.FullName}' could not be created or does not implement IXunitTestCaseDiscoverer: {ex.Unwrap()}"));
         return(null);
     }
 }
        /// <summary>
        /// Gets the test case discover instance for the given discoverer type. The instances are cached
        /// and reused, since they should not be stateful.
        /// </summary>
        /// <param name="discovererType">The discoverer type.</param>
        /// <returns>Returns the test case discoverer instance.</returns>
        protected IXunitTestCaseDiscoverer GetDiscoverer(Type discovererType)
        {
            if (!discovererCache.TryGetValue(discovererType, out IXunitTestCaseDiscoverer result))
            {
                try
                {
                    result = ExtensibilityPointFactory.GetXunitTestCaseDiscoverer(DiagnosticMessageSink, discovererType);
                }
                catch (Exception ex)
                {
                    result = null;
                    DiagnosticMessageSink.OnMessage(new DiagnosticMessage($"Discoverer type '{discovererType.FullName}' could not be created or does not implement IXunitTestCaseDiscoverer: {ex.Unwrap()}"));
                }

                discovererCache[discovererType] = result;
            }

            return(result);
        }
        /// <summary>
        /// Gets the test case discover instance for the given discoverer type. The instances are cached
        /// and reused, since they should not be stateful.
        /// </summary>
        /// <param name="discovererType">The discoverer type.</param>
        /// <returns>Returns the test case discoverer instance.</returns>
        protected IXunitTestCaseDiscoverer GetDiscoverer(Type discovererType)
        {
            IXunitTestCaseDiscoverer result;

            if (!discovererCache.TryGetValue(discovererType, out result))
            {
                try
                {
                    result = ExtensibilityPointFactory.GetXunitTestCaseDiscoverer(discovererType);
                }
                catch (Exception ex)
                {
                    result = null;
                    Aggregator.Add(new EnvironmentalWarning {
                        Message = String.Format("Discoverer type '{0}' could not be created or does not implement IXunitTestCaseDiscoverer: {1}", discovererType.FullName, ex)
                    });
                }

                discovererCache[discovererType] = result;
            }

            return(result);
        }