<commit_before>﻿using System;
using System.Linq;
using Microsoft.AspNet.Abstractions;
using Microsoft.AspNet.DependencyInjection;

namespace Microsoft.AspNet.Mvc
{
    public class DefaultControllerFactory : IControllerFactory
    {
        private readonly IServiceProvider _serviceProvider;

        public DefaultControllerFactory(IServiceProvider serviceProvider)
        {
            _serviceProvider = serviceProvider;
        }

        public object CreateController(HttpContext context, string controllerName)
        {
            if (!controllerName.EndsWith("Controller", StringComparison.OrdinalIgnoreCase))
            {
                controllerName += "Controller";
            }

            foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
            {
                var type = a.GetType(controllerName) ??
                           a.GetType(a.GetName().Name + "." + controllerName);
#if NET45
                type = type ?? a.GetTypes().FirstOrDefault(t => t.Name.Equals(controllerName, StringComparison.OrdinalIgnoreCase));
#endif

                if (type != null)
                {
                    return ActivatorUtilities.CreateInstance(_serviceProvider, type);
                }
            }

            return null;
        }

        public void ReleaseController(object controller)
        {

        }
    }
}<commit_msg>Swallow errors while trying to load types.<commit_after>﻿using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using Microsoft.AspNet.Abstractions;
using Microsoft.AspNet.DependencyInjection;

namespace Microsoft.AspNet.Mvc
{
    public class DefaultControllerFactory : IControllerFactory
    {
        private readonly IServiceProvider _serviceProvider;

        public DefaultControllerFactory(IServiceProvider serviceProvider)
        {
            _serviceProvider = serviceProvider;
        }

        public object CreateController(HttpContext context, string controllerName)
        {
            if (!controllerName.EndsWith("Controller", StringComparison.OrdinalIgnoreCase))
            {
                controllerName += "Controller";
            }

            foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
            {
                try
                {
                    var type = a.GetType(controllerName) ??
                               a.GetType(a.GetName().Name + "." + controllerName);
#if NET45
                    type = type ?? a.GetTypes().FirstOrDefault(t => t.Name.Equals(controllerName, StringComparison.OrdinalIgnoreCase));
#endif

                    if (type != null)
                    {
                        return ActivatorUtilities.CreateInstance(_serviceProvider, type);
                    }
                }
                catch (ReflectionTypeLoadException)
                {
                    // TODO: Trace here 
                }
                catch (Exception)
                {
                    // TODO: Trace here
                }
            }

            return null;
        }

        public void ReleaseController(object controller)
        {

        }
    }
}
{'fraction_non_alphanumeric': 0.07780247697681804, 'fraction_numerical': 0.0012702445220704986, 'mean_word_length': 1.7296360485268631, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4550338', 'n_tokens_mistral': 736, 'n_tokens_neox': 705, 'n_words': 149}