<commit_before>﻿using System;
using Microsoft.AspNet.DependencyInjection;
using Microsoft.AspNet.DependencyInjection.NestedProviders;
using Microsoft.AspNet.FileSystems;
using Microsoft.AspNet.Mvc.ModelBinding;
using Microsoft.AspNet.Mvc.Razor;
using Microsoft.AspNet.Mvc.Razor.Compilation;

namespace Microsoft.AspNet.Mvc
{
    public class MvcServices
    {
        public ServiceProvider Services { get; private set; }

        public MvcServices(string appRoot)
            : this(appRoot, null)
        {
        }

        public MvcServices(string appRoot, IServiceProvider hostServiceProvider)
        {
            Services = new ServiceProvider();

            Add<IControllerFactory, DefaultControllerFactory>();
            Add<IControllerDescriptorFactory, DefaultControllerDescriptorFactory>();
            Add<IActionSelector, DefaultActionSelector>();
            Add<IActionInvokerFactory, ActionInvokerFactory>();
            Add<IActionResultHelper, ActionResultHelper>();
            Add<IActionResultFactory, ActionResultFactory>();
            Add<IParameterDescriptorFactory, DefaultParameterDescriptorFactory>();
            Add<IValueProviderFactory, RouteValueValueProviderFactory>();
            Add<IValueProviderFactory, QueryStringValueProviderFactory>();
            Add<IControllerAssemblyProvider, AppDomainControllerAssemblyProvider>();
            Add<IActionDiscoveryConventions, DefaultActionDiscoveryConventions>();
            AddInstance<IFileSystem>(new PhysicalFileSystem(appRoot));
            AddInstance<IMvcRazorHost>(new MvcRazorHost(typeof(RazorView).FullName));

#if NET45
            // TODO: Container chaining to flow services from the host to this container
            if (hostServiceProvider == null)
            {
                Add<ICompilationService, CscBasedCompilationService>();
            }
            else
            {
                // TODO: Make this work like normal when we get container chaining
                AddInstance<ICompilationService>(new RoslynCompilationService(hostServiceProvider));
            }
#endif
            Add<IRazorCompilationService, RazorCompilationService>();
            Add<IVirtualPathViewFactory, VirtualPathViewFactory>();
            Add<IViewEngine, RazorViewEngine>();
<commit_msg>Use csc compilation to avoid temporary churn in host services<commit_after>﻿using System;
using Microsoft.AspNet.DependencyInjection;
using Microsoft.AspNet.DependencyInjection.NestedProviders;
using Microsoft.AspNet.FileSystems;
using Microsoft.AspNet.Mvc.ModelBinding;
using Microsoft.AspNet.Mvc.Razor;
using Microsoft.AspNet.Mvc.Razor.Compilation;

namespace Microsoft.AspNet.Mvc
{
    public class MvcServices
    {
        public ServiceProvider Services { get; private set; }

        public MvcServices(string appRoot)
            : this(appRoot, null)
        {
        }

        public MvcServices(string appRoot, IServiceProvider hostServiceProvider)
        {
            Services = new ServiceProvider();

            Add<IControllerFactory, DefaultControllerFactory>();
            Add<IControllerDescriptorFactory, DefaultControllerDescriptorFactory>();
            Add<IActionSelector, DefaultActionSelector>();
            Add<IActionInvokerFactory, ActionInvokerFactory>();
            Add<IActionResultHelper, ActionResultHelper>();
            Add<IActionResultFactory, ActionResultFactory>();
            Add<IParameterDescriptorFactory, DefaultParameterDescriptorFactory>();
            Add<IValueProviderFactory, RouteValueValueProviderFactory>();
            Add<IValueProviderFactory, QueryStringValueProviderFactory>();
            Add<IControllerAssemblyProvider, AppDomainControllerAssemblyProvider>();
            Add<IActionDiscoveryConventions, DefaultActionDiscoveryConventions>();
            AddInstance<IFileSystem>(new PhysicalFileSystem(appRoot));
            AddInstance<IMvcRazorHost>(new MvcRazorHost(typeof(RazorView).FullName));

#if NET45
            // TODO: Container chaining to flow services from the host to this container

            Add<ICompilationService, CscBasedCompilationService>();

            // TODO: Make this work like normal when we get container chaining
            // TODO: Update this when we have the new host services
            // AddInstance<ICompilationService>(new RoslynCompilationService(hostServiceProvider));
#endif
            Add<IRazorCompilationService, RazorCompilationService>();
            Add<IVirtualPathViewFactory, VirtualPathViewFactory>();
            Add<IViewEngine, RazorViewEngine>();

{'fraction_non_alphanumeric': 0.07894161382024929, 'fraction_numerical': 0.0008746993221080254, 'mean_word_length': 3.3437796771130106, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, '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': '1675418', 'n_tokens_mistral': 1047, 'n_tokens_neox': 1084, 'n_words': 223}