public ScriptCsProjectSystem(OmnisharpWorkspace workspace, IOmnisharpEnvironment env, ILoggerFactory loggerFactory, ScriptCsContext scriptCsContext)
 {
     _workspace       = workspace;
     _env             = env;
     _scriptCsContext = scriptCsContext;
     _logger          = loggerFactory.CreateLogger <ScriptCsProjectSystem>();
 }
예제 #2
0
        private static bool LogFilter(string category, LogLevel level, IOmnisharpEnvironment environment)
        {
            if (environment.TraceType > level)
            {
                return(false);
            }

            if (string.Equals(category,
                              typeof(ExceptionHandlerMiddleware).FullName,
                              StringComparison.OrdinalIgnoreCase))
            {
                return(true);
            }

            if (!category.StartsWith("OmniSharp", StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }

            if (string.Equals(category,
                              typeof(WorkspaceInformationService).FullName,
                              StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }

            if (string.Equals(category,
                              typeof(ProjectEventForwarder).FullName,
                              StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }

            return(true);
        }
        public DnxProjectSystem(OmnisharpWorkspace workspace,
                                    IOmnisharpEnvironment env,
                                    IOptions<OmniSharpOptions> optionsAccessor,
                                    ILoggerFactory loggerFactory,
                                    IMetadataFileReferenceCache metadataFileReferenceCache,
                                    IApplicationLifetime lifetime,
                                    IFileSystemWatcher watcher,
                                    IEventEmitter emitter,
                                    DnxContext context)
        {
            _workspace = workspace;
            _env = env;
            _logger = loggerFactory.CreateLogger<DnxProjectSystem>();
            _metadataFileReferenceCache = metadataFileReferenceCache;
            _options = optionsAccessor.Options;
            _dnxPaths = new DnxPaths(env, _options, loggerFactory);
            _designTimeHostManager = new DesignTimeHostManager(loggerFactory, _dnxPaths);
            _packagesRestoreTool = new PackagesRestoreTool(_options, loggerFactory, emitter, context, _dnxPaths);
            _context = context;
            _watcher = watcher;
            _emitter = emitter;
            _directoryEnumerator = new DirectoryEnumerator(loggerFactory);

            lifetime.ApplicationStopping.Register(OnShutdown);
        }
예제 #4
0
        public DnxProjectSystem(OmnisharpWorkspace workspace,
                                IOmnisharpEnvironment env,
                                IOptions <OmniSharpOptions> optionsAccessor,
                                ILoggerFactory loggerFactory,
                                IMetadataFileReferenceCache metadataFileReferenceCache,
                                IApplicationLifetime lifetime,
                                IFileSystemWatcher watcher,
                                IEventEmitter emitter,
                                DnxContext context)
        {
            _workspace = workspace;
            _env       = env;
            _logger    = loggerFactory.CreateLogger <DnxProjectSystem>();
            _metadataFileReferenceCache = metadataFileReferenceCache;
            _options  = optionsAccessor.Options;
            _dnxPaths = new DnxPaths(env, _options, loggerFactory);
            _designTimeHostManager = new DesignTimeHostManager(loggerFactory, _dnxPaths);
            _packagesRestoreTool   = new PackagesRestoreTool(_options, loggerFactory, emitter, context, _dnxPaths);
            _context             = context;
            _watcher             = watcher;
            _emitter             = emitter;
            _directoryEnumerator = new DirectoryEnumerator(loggerFactory);

            lifetime.ApplicationStopping.Register(OnShutdown);
        }
예제 #5
0
        public void Configure(IApplicationBuilder app,
                              ILoggerFactory loggerFactory,
                              IOmnisharpEnvironment env,
                              ISharedTextWriter writer)
        {
            Func <string, LogLevel, bool> logFilter = (category, type) =>
                                                      (category.StartsWith("OmniSharp", StringComparison.OrdinalIgnoreCase) || string.Equals(category, typeof(ErrorHandlerMiddleware).FullName, StringComparison.OrdinalIgnoreCase)) &&
                                                      env.TraceType <= type;

            if (env.TransportType == TransportType.Stdio)
            {
                loggerFactory.AddStdio(writer, logFilter);
            }
            else
            {
                loggerFactory.AddConsole(logFilter);
            }

            var logger = loggerFactory.CreateLogger <Startup>();

            app.UseRequestLogging();

            app.UseErrorHandler("/error");

            app.UseMvc();

            if (env.TransportType == TransportType.Stdio)
            {
                logger.LogInformation($"Omnisharp server running using stdio at location '{env.Path}' on host {env.HostPID}.");
            }
            else
            {
                logger.LogInformation($"Omnisharp server running on port '{env.Port}' at location '{env.Path}' on host {env.HostPID}.");
            }

            // Forward workspace events
            app.ApplicationServices.GetRequiredService <ProjectEventForwarder>();

            // Initialize everything!
            var projectSystems = app.ApplicationServices.GetRequiredServices <IProjectSystem>();

            foreach (var projectSystem in projectSystems)
            {
                try
                {
                    projectSystem.Initalize();
                }
                catch (Exception e)
                {
                    //if a project system throws an unhandled exception
                    //it should not crash the entire server
                    logger.LogError($"The project system '{projectSystem.GetType().Name}' threw an exception.", e);
                }
            }

            // Mark the workspace as initialized
            Workspace.Initialized = true;

            logger.LogInformation("Solution has finished loading");
        }
예제 #6
0
        public void Configure(IApplicationBuilder app,
                              ILoggerFactory loggerFactory,
                              IOmnisharpEnvironment env)
        {
            loggerFactory.AddConsole((category, type) =>
                                     (category.StartsWith("OmniSharp", StringComparison.OrdinalIgnoreCase) ||
                                      string.Equals(category, typeof(ErrorHandlerMiddleware).FullName, StringComparison.OrdinalIgnoreCase)) &&
                                     env.TraceType <= type);

            var logger = loggerFactory.Create <Startup>();

            app.UseRequestLogging();

            app.UseErrorHandler("/error");

            app.UseMvc();

            logger.WriteInformation(string.Format("Omnisharp server running on port '{0}' at location '{1}'.", env.Port, env.Path));

            // Initialize everything!
            var initializers = app.ApplicationServices.GetRequiredService <IEnumerable <IWorkspaceInitializer> >();

            foreach (var initializer in initializers)
            {
                initializer.Initalize();
            }

            // This is temporary so that plugins work
            Console.WriteLine("Solution has finished loading");
        }
 public ScriptCsProjectSystem(OmnisharpWorkspace workspace, IOmnisharpEnvironment env, ILoggerFactory loggerFactory, ScriptCsContext scriptCsContext)
 {
     _workspace = workspace;
     _env = env;
     _scriptCsContext = scriptCsContext;
     _logger = loggerFactory.CreateLogger<ScriptCsProjectSystem>();
 }
 public DnxTestCommandProvider(DnxContext context,
                                   IOmnisharpEnvironment env,
                                   ILoggerFactory loggerFactory,
                                   IEventEmitter emitter)
 {
     _context = context;
     var dnxPaths = new DnxPaths(env, context.Options, loggerFactory);
     _dnx = dnxPaths.Dnx != null ? dnxPaths.Dnx + " ." : dnxPaths.K;
 }
        public DnxTestCommandProvider(DnxContext context,
                                      IOmnisharpEnvironment env,
                                      ILoggerFactory loggerFactory,
                                      IEventEmitter emitter)
        {
            _context = context;
            var dnxPaths = new DnxPaths(env, context.Options, loggerFactory);

            _dnx = dnxPaths.Dnx + " .";
        }
 public MSBuildInitializer(OmnisharpWorkspace workspace,
                           IOmnisharpEnvironment env,
                           ILoggerFactory loggerFactory,
                           IMetadataFileReferenceCache metadataReferenceCache)
 {
     _workspace = workspace;
     _metadataReferenceCache = metadataReferenceCache;
     _env    = env;
     _logger = loggerFactory.Create <MSBuildInitializer>();
 }
예제 #11
0
        public AspNet5TestCommandProvider(AspNet5Context context,
                                          IOmnisharpEnvironment env,
                                          ILoggerFactory loggerFactory,
                                          IEventEmitter emitter,
                                          IOptions <OmniSharpOptions> options)
        {
            _context = context;
            var aspNet5Paths = new AspNet5Paths(env, options.Options, loggerFactory);

            _dnx = aspNet5Paths.Dnx != null ? aspNet5Paths.Dnx + " ." : aspNet5Paths.K;
        }
예제 #12
0
        public DnxTestCommandProvider(DnxContext context,
                                      IOmnisharpEnvironment env,
                                      ILoggerFactory loggerFactory,
                                      IEventEmitter emitter,
                                      IOptions <OmniSharpOptions> options)
        {
            _context = context;
            var dnxPaths = new DnxPaths(env, options.Options, loggerFactory);

            _dnx = dnxPaths.Dnx != null ? dnxPaths.Dnx + " ." : dnxPaths.K;
        }
예제 #13
0
        public DnxPaths(IOmnisharpEnvironment env,
                        DnxOptions options,
                        ILoggerFactory loggerFactory)
        {
            _env     = env;
            _options = options;
            _logger  = loggerFactory.CreateLogger <DnxPaths>();

            RuntimePath = GetRuntimePath();
            Dnx         = FirstPath(RuntimePath.Value, "dnx", "dnx.exe");
            Dnu         = FirstPath(RuntimePath.Value, "dnu", "dnu.cmd");
        }
예제 #14
0
        public DnxPaths(IOmnisharpEnvironment env,
                        DnxOptions options,
                        ILoggerFactory loggerFactory)
        {
            _env = env;
            _options = options;
            _logger = loggerFactory.CreateLogger<DnxPaths>();

            RuntimePath = GetRuntimePath();
            Dnx = FirstPath(RuntimePath.Value, "dnx", "dnx.exe");
            Dnu = FirstPath(RuntimePath.Value, "dnu", "dnu.cmd");
        }
 public AspNet5Initializer(OmnisharpWorkspace workspace,
                           IOmnisharpEnvironment env,
                           IOptions <OmniSharpOptions> optionsAccessor,
                           ILoggerFactory loggerFactory,
                           IMetadataFileReferenceCache metadataFileReferenceCache)
 {
     _workspace = workspace;
     _env       = env;
     _options   = optionsAccessor.Options;
     _logger    = loggerFactory.Create <AspNet5Initializer>();
     _metadataFileReferenceCache = metadataFileReferenceCache;
     _designTimeHostManager      = new DesignTimeHostManager(loggerFactory);
 }
예제 #16
0
 public MSBuildProjectSystem(OmnisharpWorkspace workspace,
                             IOmnisharpEnvironment env,
                             ILoggerFactory loggerFactory,
                             IMetadataFileReferenceCache metadataReferenceCache,
                             IFileSystemWatcher watcher,
                             MSBuildContext context)
 {
     _workspace = workspace;
     _metadataReferenceCache = metadataReferenceCache;
     _watcher = watcher;
     _env     = env;
     _logger  = loggerFactory.Create <MSBuildProjectSystem>();
     _context = context;
 }
 public FileSystemWatcherWrapper(IOmnisharpEnvironment env)
 {
     _watcher = new FileSystemWatcher(env.Path);
     _watcher.IncludeSubdirectories = true;
     _watcher.EnableRaisingEvents   = true;
     _watcher.Changed += OnChanged;
     _watcher.Created += OnChanged;
     _watcher.Deleted += OnChanged;
     _watcher.Renamed += (sender, e) =>
     {
         TriggerChange(e.OldFullPath);
         TriggerChange(e.FullPath);
     };
 }
예제 #18
0
 public MSBuildProjectSystem(OmnisharpWorkspace workspace,
                             IOmnisharpEnvironment env,
                             ILoggerFactory loggerFactory,
                             IMetadataFileReferenceCache metadataReferenceCache,
                             IFileSystemWatcher watcher,
                             MSBuildContext context)
 {
     _workspace = workspace;
     _metadataReferenceCache = metadataReferenceCache;
     _watcher = watcher;
     _env = env;
     _logger = loggerFactory.Create<MSBuildProjectSystem>();
     _context = context;
 }
예제 #19
0
        public AspNet5Paths(IOmnisharpEnvironment env,
                            OmniSharpOptions options,
                            ILoggerFactory loggerFactory)
        {
            _env     = env;
            _options = options;
            _logger  = loggerFactory.Create <AspNet5Paths>();

            RuntimePath = GetRuntimePath();
            Dnx         = FirstPath(RuntimePath, "dnx", "dnx.exe");
            Dnu         = FirstPath(RuntimePath, "dnu", "dnu.cmd");
            Klr         = FirstPath(RuntimePath, "klr", "klr.exe");
            Kpm         = FirstPath(RuntimePath, "kpm", "kpm.cmd");
        }
 public FileSystemWatcherWrapper(IOmnisharpEnvironment env)
 {
     // Environment.SetEnvironmentVariable ("MONO_MANAGED_WATCHER", "1");
     _watcher = new FileSystemWatcher(env.Path);
     _watcher.IncludeSubdirectories = true;
     _watcher.EnableRaisingEvents = true;
     _watcher.Changed += OnChanged;
     _watcher.Created += OnChanged;
     _watcher.Deleted += OnChanged;
     _watcher.Renamed += (sender, e) =>
     {
         TriggerChange(e.OldFullPath);
         TriggerChange(e.FullPath);
     };
 }
        public AspNet5Paths(IOmnisharpEnvironment env,
                            OmniSharpOptions options,
                            ILoggerFactory loggerFactory)
        {
            _env = env;
            _options = options;
            _logger = loggerFactory.CreateLogger<AspNet5Paths>();

            RuntimePath = GetRuntimePath();
            Dnx = FirstPath(RuntimePath.Value, "dnx", "dnx.exe");
            Dnu = FirstPath(RuntimePath.Value, "dnu", "dnu.cmd");
            Klr = FirstPath(RuntimePath.Value, "klr", "klr.exe");
            Kpm = FirstPath(RuntimePath.Value, "kpm", "kpm.cmd");
            K   = FirstPath(RuntimePath.Value, "k", "k.cmd");
        }
        public DotNetProjectSystem(IOmnisharpEnvironment environment,
                                   OmnisharpWorkspace omnisharpWorkspace,
                                   IMetadataFileReferenceCache metadataFileReferenceCache,
                                   ILoggerFactory loggerFactory,
                                   IFileSystemWatcher watcher,
                                   IEventEmitter emitter)
        {
            _environment = environment;
            _omnisharpWorkspace = omnisharpWorkspace;
            _logger = loggerFactory.CreateLogger<DotNetProjectSystem>();
            _emitter = emitter;
            _metadataFileReferenceCache = metadataFileReferenceCache;
            _watcher = watcher;

            _packageRestore = new PackagesRestoreTool(loggerFactory, _emitter);
            _projectStates = new ProjectStatesCache(loggerFactory);
        }
예제 #23
0
        public DotNetProjectSystem(IOmnisharpEnvironment environment,
                                   OmnisharpWorkspace omnisharpWorkspace,
                                   IMetadataFileReferenceCache metadataFileReferenceCache,
                                   ILoggerFactory loggerFactory,
                                   IFileSystemWatcher watcher,
                                   IEventEmitter emitter)
        {
            _environment                = environment;
            _omnisharpWorkspace         = omnisharpWorkspace;
            _logger                     = loggerFactory.CreateLogger <DotNetProjectSystem>();
            _emitter                    = emitter;
            _metadataFileReferenceCache = metadataFileReferenceCache;
            _watcher                    = watcher;

            _packageRestore = new PackagesRestoreTool(loggerFactory, _emitter);
            _projectStates  = new ProjectStatesCache(loggerFactory, _emitter);
        }
예제 #24
0
        public void Configure(IApplicationBuilder app,
                              ILoggerFactory loggerFactory,
                              IOmnisharpEnvironment env,
                              ISharedTextWriter writer)
        {
            Func <string, LogLevel, bool> logFilter = (category, type) =>
                                                      (category.StartsWith("OmniSharp", StringComparison.OrdinalIgnoreCase) || string.Equals(category, typeof(ErrorHandlerMiddleware).FullName, StringComparison.OrdinalIgnoreCase)) &&
                                                      env.TraceType <= type;

            if (env.TransportType == TransportType.Stdio)
            {
                loggerFactory.AddStdio(writer, logFilter);
            }
            else
            {
                loggerFactory.AddConsole(logFilter);
            }

            var logger = loggerFactory.Create <Startup>();

            app.UseRequestLogging();

            app.UseErrorHandler("/error");

            app.UseMvc();

            logger.WriteInformation($"Omnisharp server running on port '{env.Port}' at location '{env.Path}' on host {env.HostPID}.");

            // Forward workspace events
            app.ApplicationServices.GetRequiredService <ProjectEventForwarder>();

            // Initialize everything!
            var projectSystems = app.ApplicationServices.GetRequiredService <IEnumerable <IProjectSystem> >();

            foreach (var projectSystem in projectSystems)
            {
                projectSystem.Initalize();
            }

            // Mark the workspace as initialized
            Workspace.Initialized = true;

            // This is temporary so that plugins work
            Console.WriteLine("Solution has finished loading");
        }
 public MSBuildProjectSystem(OmnisharpWorkspace workspace,
                             IOmnisharpEnvironment env,
                             IOptions <OmniSharpOptions> optionsAccessor,
                             ILoggerFactory loggerFactory,
                             IEventEmitter emitter,
                             IMetadataFileReferenceCache metadataReferenceCache,
                             IFileSystemWatcher watcher,
                             MSBuildContext context)
 {
     _workspace = workspace;
     _metadataReferenceCache = metadataReferenceCache;
     _watcher = watcher;
     _env     = env;
     _options = optionsAccessor.Options.MsBuild;
     _logger  = loggerFactory.CreateLogger <MSBuildProjectSystem>();
     _emitter = emitter;
     _context = context;
 }
 public MSBuildProjectSystem(OmnisharpWorkspace workspace,
                             IOmnisharpEnvironment env,
                             IOptions<OmniSharpOptions> optionsAccessor,
                             ILoggerFactory loggerFactory,
                             IEventEmitter emitter,
                             IMetadataFileReferenceCache metadataReferenceCache,
                             IFileSystemWatcher watcher,
                             MSBuildContext context)
 {
     _workspace = workspace;
     _metadataReferenceCache = metadataReferenceCache;
     _watcher = watcher;
     _env = env;
     _options = optionsAccessor.Options.MsBuild;
     _logger = loggerFactory.CreateLogger<MSBuildProjectSystem>();
     _emitter = emitter;
     _context = context;
 }
예제 #27
0
        public AspNet5ProjectSystem(OmnisharpWorkspace workspace,
                                    IOmnisharpEnvironment env,
                                    IOptions<OmniSharpOptions> optionsAccessor,
                                    ILoggerFactory loggerFactory,
                                    IMetadataFileReferenceCache metadataFileReferenceCache,
                                    IApplicationLifetime lifetime,
                                    IFileSystemWatcher watcher,
                                    AspNet5Context context)
        {
            _workspace = workspace;
            _env = env;
            _options = optionsAccessor.Options;
            _logger = loggerFactory.Create<AspNet5ProjectSystem>();
            _metadataFileReferenceCache = metadataFileReferenceCache;
            _designTimeHostManager = new DesignTimeHostManager(loggerFactory);
            _context = context;
            _watcher = watcher;

            lifetime.ApplicationStopping.Register(OnShutdown);
        }
예제 #28
0
        public AspNet5ProjectSystem(OmnisharpWorkspace workspace,
                                    IOmnisharpEnvironment env,
                                    IOptions <OmniSharpOptions> optionsAccessor,
                                    ILoggerFactory loggerFactory,
                                    IMetadataFileReferenceCache metadataFileReferenceCache,
                                    IApplicationShutdown shutdown,
                                    IFileSystemWatcher watcher,
                                    AspNet5Context context)
        {
            _workspace = workspace;
            _env       = env;
            _options   = optionsAccessor.Options;
            _logger    = loggerFactory.Create <AspNet5ProjectSystem>();
            _metadataFileReferenceCache = metadataFileReferenceCache;
            _designTimeHostManager      = new DesignTimeHostManager(loggerFactory);
            _context = context;
            _watcher = watcher;

            shutdown.ShutdownRequested.Register(OnShutdown);
        }
        public DnxProjectSystem(OmnisharpWorkspace workspace,
                                IOmnisharpEnvironment env,
                                ILoggerFactory loggerFactory,
                                IMetadataFileReferenceCache metadataFileReferenceCache,
                                IApplicationLifetime lifetime,
                                IFileSystemWatcher watcher,
                                IEventEmitter emitter,
                                DnxContext context)
        {
            _workspace     = workspace;
            _env           = env;
            _loggerFactory = loggerFactory;
            _logger        = loggerFactory.CreateLogger <DnxProjectSystem>();
            _metadataFileReferenceCache = metadataFileReferenceCache;
            _context             = context;
            _watcher             = watcher;
            _emitter             = emitter;
            _directoryEnumerator = new DirectoryEnumerator(loggerFactory);

            lifetime?.ApplicationStopping.Register(OnShutdown);
        }
예제 #30
0
 public ProtobuildProjectSystem(
     OmnisharpWorkspace workspace,
     IOmnisharpEnvironment env,
     ILoggerFactory loggerFactory,
     IEventEmitter emitter,
     IMetadataFileReferenceCache metadataReferenceCache,
     IFileSystemWatcher watcher,
     MSBuildContext context) : base(
         workspace,
         env,
         loggerFactory,
         emitter,
         metadataReferenceCache,
         watcher,
         context)
 {
     _env     = env;
     _logger  = loggerFactory.CreateLogger <ProtobuildProjectSystem>();
     _context = context;
     _watcher = watcher;
 }
예제 #31
0
        public DnxProjectSystem(OmnisharpWorkspace workspace,
                                IOmnisharpEnvironment env,
                                ILoggerFactory loggerFactory,
                                IMetadataFileReferenceCache metadataFileReferenceCache,
                                IApplicationLifetime lifetime,
                                IFileSystemWatcher watcher,
                                IEventEmitter emitter,
                                DnxContext context)
        {
            _workspace = workspace;
            _env = env;
            _loggerFactory = loggerFactory;
            _logger = loggerFactory.CreateLogger<DnxProjectSystem>();
            _metadataFileReferenceCache = metadataFileReferenceCache;
            _context = context;
            _watcher = watcher;
            _emitter = emitter;
            _directoryEnumerator = new DirectoryEnumerator(loggerFactory);

            lifetime?.ApplicationStopping.Register(OnShutdown);
        }
예제 #32
0
        public void Configure(IApplicationBuilder app,
                              ILoggerFactory loggerFactory,
                              IOmnisharpEnvironment env,
                              ISharedTextWriter writer)
        {
            Func<string, LogLevel, bool> logFilter = (category, type) =>
                (category.StartsWith("OmniSharp", StringComparison.OrdinalIgnoreCase) || string.Equals(category, typeof(ErrorHandlerMiddleware).FullName, StringComparison.OrdinalIgnoreCase))
                && env.TraceType <= type;

            if (env.TransportType == TransportType.Stdio)
            {
                loggerFactory.AddStdio(writer, logFilter);
            }
            else
            {
                loggerFactory.AddConsole(logFilter);
            }

            var logger = loggerFactory.CreateLogger<Startup>();

            app.UseRequestLogging();

            app.UseErrorHandler("/error");

            app.UseMvc();

            if (env.TransportType == TransportType.Stdio)
            {
                logger.LogInformation($"Omnisharp server running using stdio at location '{env.Path}' on host {env.HostPID}.");
            }
            else
            {
                logger.LogInformation($"Omnisharp server running on port '{env.Port}' at location '{env.Path}' on host {env.HostPID}.");
            }

            // Forward workspace events
            app.ApplicationServices.GetRequiredService<ProjectEventForwarder>();

            // Initialize everything!
            var projectSystems = app.ApplicationServices.GetRequiredServices<IProjectSystem>();

            foreach (var projectSystem in projectSystems)
            {
                try
                {
                    projectSystem.Initalize();
                }
                catch (Exception e)
                {
                    //if a project system throws an unhandled exception
                    //it should not crash the entire server
                    logger.LogError($"The project system '{projectSystem.GetType().Name}' threw an exception.", e);
                }
            }

            // Mark the workspace as initialized
            Workspace.Initialized = true;

            logger.LogInformation("Solution has finished loading");
        }
예제 #33
0
        public void Configure(IApplicationBuilder app,
                              IServiceProvider serviceProvider,
                              IOmnisharpEnvironment env,
                              ILoggerFactory loggerFactory,
                              ISharedTextWriter writer,
                              IOptions <OmniSharpOptions> optionsAccessor)
        {
            var assemblies = DnxPlatformServices.Default.LibraryManager.GetReferencingLibraries("OmniSharp.Abstractions")
                             .SelectMany(libraryInformation => libraryInformation.Assemblies)
                             .Concat(
                DnxPlatformServices.Default.LibraryManager.GetReferencingLibraries("OmniSharp.Roslyn")
                .SelectMany(libraryInformation => libraryInformation.Assemblies)
                )
                             .Select(assemblyName => Assembly.Load(assemblyName));

            PluginHost = ConfigureMef(serviceProvider, optionsAccessor.Value, assemblies);

            Workspace = PluginHost.GetExport <OmnisharpWorkspace>();

            if (env.TransportType == TransportType.Stdio)
            {
                loggerFactory.AddStdio(writer, (category, level) => LogFilter(category, level, env));
            }
            else
            {
                loggerFactory.AddConsole((category, level) => LogFilter(category, level, env));
            }

            var logger = loggerFactory.CreateLogger <Startup>();

            app.UseRequestLogging();
            app.UseExceptionHandler("/error");
            app.UseMiddleware <EndpointMiddleware>();
            app.UseMiddleware <StatusMiddleware>();
            app.UseMiddleware <StopServerMiddleware>();

            if (env.TransportType == TransportType.Stdio)
            {
                logger.LogInformation($"Omnisharp server running using stdio at location '{env.Path}' on host {env.HostPID}.");
            }
            else
            {
                logger.LogInformation($"Omnisharp server running on port '{env.Port}' at location '{env.Path}' on host {env.HostPID}.");
            }

            // Forward workspace events
            PluginHost.GetExport <ProjectEventForwarder>();
            foreach (var projectSystem in PluginHost.GetExports <IProjectSystem>())
            {
                try
                {
                    projectSystem.Initalize(Configuration.GetSection(projectSystem.Key));
                }
                catch (Exception e)
                {
                    //if a project system throws an unhandled exception
                    //it should not crash the entire server
                    logger.LogError($"The project system '{projectSystem.GetType().Name}' threw an exception.", e);
                }
            }

            // Mark the workspace as initialized
            Workspace.Initialized = true;

            logger.LogInformation("Solution has finished loading");
        }
예제 #34
0
        private static bool LogFilter(string category, LogLevel level, IOmnisharpEnvironment environment)
        {
            if (environment.TraceType > level)
            {
                return false;
            }

            if (string.Equals(category,
                              typeof(ExceptionHandlerMiddleware).FullName,
                              StringComparison.OrdinalIgnoreCase))
            {
                return true;
            }

            if (!category.StartsWith("OmniSharp", StringComparison.OrdinalIgnoreCase))
            {
                return false;
            }

            if (string.Equals(category,
                              typeof(WorkspaceInformationService).FullName,
                              StringComparison.OrdinalIgnoreCase))
            {
                return false;
            }

            if (string.Equals(category,
                              typeof(ProjectEventForwarder).FullName,
                              StringComparison.OrdinalIgnoreCase))
            {
                return false;
            }

            return true;
        }
예제 #35
0
        public void Configure(IApplicationBuilder app,
                              IServiceProvider serviceProvider,
                              IOmnisharpEnvironment env,
                              ILoggerFactory loggerFactory,
                              ISharedTextWriter writer,
                              IOmnisharpAssemblyLoader loader,
                              IOptions<OmniSharpOptions> optionsAccessor)
        {
            Func<RuntimeLibrary, bool> shouldLoad = lib => lib.Dependencies.Any(dep => dep.Name == "OmniSharp.Abstractions" ||
                                                                                       dep.Name == "OmniSharp.Roslyn");
                       
            var assemblies = DependencyContext.Default
                                              .RuntimeLibraries
                                              .Where(shouldLoad)
                                              .SelectMany(lib => lib.Assemblies)
                                              .Select(each => loader.Load(each.Name))
                                              .ToList();

            PluginHost = ConfigureMef(serviceProvider, optionsAccessor.Value, assemblies);

            Workspace = PluginHost.GetExport<OmnisharpWorkspace>();

            if (env.TransportType == TransportType.Stdio)
            {
                loggerFactory.AddStdio(writer, (category, level) => LogFilter(category, level, env));
            }
            else
            {
                loggerFactory.AddConsole((category, level) => LogFilter(category, level, env));
            }

            var logger = loggerFactory.CreateLogger<Startup>();
            foreach (var assembly in assemblies)
            {
                logger.LogDebug($"Loaded {assembly.FullName}");
            }

            app.UseRequestLogging();
            app.UseExceptionHandler("/error");
            app.UseMiddleware<EndpointMiddleware>();
            app.UseMiddleware<StatusMiddleware>();
            app.UseMiddleware<StopServerMiddleware>();

            if (env.TransportType == TransportType.Stdio)
            {
                logger.LogInformation($"Omnisharp server running using {nameof(TransportType.Stdio)} at location '{env.Path}' on host {env.HostPID}.");
            }
            else
            {
                logger.LogInformation($"Omnisharp server running on port '{env.Port}' at location '{env.Path}' on host {env.HostPID}.");
            }

            // ProjectEventForwarder register event to OmnisharpWorkspace during instantiation
            PluginHost.GetExport<ProjectEventForwarder>();
            
            // Initialize all the project systems
            foreach (var projectSystem in PluginHost.GetExports<IProjectSystem>())
            {
                try
                {
                    projectSystem.Initalize(Configuration.GetSection(projectSystem.Key));
                }
                catch (Exception e)
                {
                    var message = $"The project system '{projectSystem.GetType().Name}' threw exception during initialization.\n{e.Message}\n{e.StackTrace}";
                    // if a project system throws an unhandled exception it should not crash the entire server
                    logger.LogError(message);
                }
            }

            // Mark the workspace as initialized
            Workspace.Initialized = true;

            logger.LogInformation("Configuration finished.");
        }
예제 #36
0
        public void Configure(IApplicationBuilder app,
                              IServiceProvider serviceProvider,
                              IOmnisharpEnvironment env,
                              ILoggerFactory loggerFactory,
                              ISharedTextWriter writer,
                              IOmnisharpAssemblyLoader loader,
                              IOptions <OmniSharpOptions> optionsAccessor)
        {
            Func <RuntimeLibrary, bool> shouldLoad = lib => lib.Dependencies.Any(dep => dep.Name == "OmniSharp.Abstractions" ||
                                                                                 dep.Name == "OmniSharp.Roslyn");

            var dependencyContext = DependencyContext.Default;
            var assemblies        = dependencyContext.RuntimeLibraries
                                    .Where(shouldLoad)
                                    .SelectMany(lib => lib.GetDefaultAssemblyNames(dependencyContext))
                                    .Select(each => loader.Load(each.Name))
                                    .ToList();

            PluginHost = ConfigureMef(serviceProvider, optionsAccessor.Value, assemblies);

            Workspace = PluginHost.GetExport <OmnisharpWorkspace>();

            if (env.TransportType == TransportType.Stdio)
            {
                loggerFactory.AddStdio(writer, (category, level) => LogFilter(category, level, env));
            }
            else
            {
                loggerFactory.AddConsole((category, level) => LogFilter(category, level, env));
            }

            var logger = loggerFactory.CreateLogger <Startup>();

            foreach (var assembly in assemblies)
            {
                logger.LogDebug($"Loaded {assembly.FullName}");
            }

            app.UseRequestLogging();
            app.UseExceptionHandler("/error");
            app.UseMiddleware <EndpointMiddleware>();
            app.UseMiddleware <StatusMiddleware>();
            app.UseMiddleware <StopServerMiddleware>();

            if (env.TransportType == TransportType.Stdio)
            {
                logger.LogInformation($"Omnisharp server running using {nameof(TransportType.Stdio)} at location '{env.Path}' on host {env.HostPID}.");
            }
            else
            {
                logger.LogInformation($"Omnisharp server running on port '{env.Port}' at location '{env.Path}' on host {env.HostPID}.");
            }

            // ProjectEventForwarder register event to OmnisharpWorkspace during instantiation
            PluginHost.GetExport <ProjectEventForwarder>();

            // Initialize all the project systems
            foreach (var projectSystem in PluginHost.GetExports <IProjectSystem>())
            {
                try
                {
                    projectSystem.Initalize(Configuration.GetSection(projectSystem.Key));
                }
                catch (Exception e)
                {
                    var message = $"The project system '{projectSystem.GetType().Name}' threw exception during initialization.\n{e.Message}\n{e.StackTrace}";
                    // if a project system throws an unhandled exception it should not crash the entire server
                    logger.LogError(message);
                }
            }

            // Mark the workspace as initialized
            Workspace.Initialized = true;

            logger.LogInformation("Configuration finished.");
        }
예제 #37
0
파일: Startup.cs 프로젝트: Jenkin0603/myvim
        public void Configure(IApplicationBuilder app,
                              ILoggerFactory loggerFactory,
                              IOmnisharpEnvironment env,
                              ISharedTextWriter writer)
        {
            Func<string, LogLevel, bool> logFilter = (category, type) =>
                (category.StartsWith("OmniSharp", StringComparison.OrdinalIgnoreCase) || string.Equals(category, typeof(ErrorHandlerMiddleware).FullName, StringComparison.OrdinalIgnoreCase))
                && env.TraceType <= type;
                    
            if (env.TransportType == TransportType.Stdio)
            {
                loggerFactory.AddStdio(writer, logFilter);
            }
            else
            {
                loggerFactory.AddConsole(logFilter);
            }

            var logger = loggerFactory.Create<Startup>();

            app.UseRequestLogging();

            app.UseErrorHandler("/error");

            app.UseMvc();

            logger.WriteInformation($"Omnisharp server running on port '{env.Port}' at location '{env.Path}' on host {env.HostPID}.");

            // Initialize everything!
            var projectSystems = app.ApplicationServices.GetRequiredService<IEnumerable<IProjectSystem>>();

            foreach (var projectSystem in projectSystems)
            {
                projectSystem.Initalize();
            }

            // Mark the workspace as initialized
            Workspace.Initialized = true;

            // This is temporary so that plugins work
            Console.WriteLine("Solution has finished loading");
        }
예제 #38
0
        public void Configure(IApplicationBuilder app, IServiceProvider serviceProvider, ILibraryManager manager,
            IOmnisharpEnvironment env, ILoggerFactory loggerFactory, ISharedTextWriter writer, IOptions<OmniSharpOptions> optionsAccessor)
        {
            var assemblies = manager.GetReferencingLibraries("OmniSharp.Abstractions")
                .SelectMany(libraryInformation => libraryInformation.LoadableAssemblies)
                .Concat(
                    manager.GetReferencingLibraries("OmniSharp.Roslyn")
                        .SelectMany(libraryInformation => libraryInformation.LoadableAssemblies)
                )
                .Select(assemblyName => Assembly.Load(assemblyName));

            PluginHost = ConfigureMef(serviceProvider, optionsAccessor.Options, assemblies);

            Workspace = PluginHost.GetExport<OmnisharpWorkspace>();

            Func<string, LogLevel, bool> logFilter = (category, type) =>
                (category.StartsWith("OmniSharp", StringComparison.OrdinalIgnoreCase) || string.Equals(category, typeof(ErrorHandlerMiddleware).FullName, StringComparison.OrdinalIgnoreCase))
                && env.TraceType <= type;

            if (env.TransportType == TransportType.Stdio)
            {
                loggerFactory.AddStdio(writer, logFilter);
            }
            else
            {
                loggerFactory.AddConsole(logFilter);
            }

            var logger = loggerFactory.CreateLogger<Startup>();

            app.UseRequestLogging();

            app.UseErrorHandler("/error");

            app.UseMiddleware<EndpointMiddleware>();
            app.UseMiddleware<StatusMiddleware>();
            app.UseMiddleware<StopServerMiddleware>();

            if (env.TransportType == TransportType.Stdio)
            {
                logger.LogInformation($"Omnisharp server running using stdio at location '{env.Path}' on host {env.HostPID}.");
            }
            else
            {
                logger.LogInformation($"Omnisharp server running on port '{env.Port}' at location '{env.Path}' on host {env.HostPID}.");
            }

            // Forward workspace events
            PluginHost.GetExport<ProjectEventForwarder>();
            foreach (var projectSystem in PluginHost.GetExports<IProjectSystem>())
            {
                try
                {
                    projectSystem.Initalize(Configuration.GetSubKey(projectSystem.Key));
                }
                catch (Exception e)
                {
                    //if a project system throws an unhandled exception
                    //it should not crash the entire server
                    logger.LogError($"The project system '{projectSystem.GetType().Name}' threw an exception.", e);
                }
            }

            // Mark the workspace as initialized
            Workspace.Initialized = true;

            logger.LogInformation("Solution has finished loading");
        }