Пример #1
0
        public ScriptProjectSystem(OmniSharpWorkspace workspace, IOmniSharpEnvironment env, ILoggerFactory loggerFactory,
                                   MetadataFileReferenceCache metadataFileReferenceCache, IFileSystemWatcher fileSystemWatcher)
        {
            _metadataFileReferenceCache = metadataFileReferenceCache;
            _workspace         = workspace;
            _env               = env;
            _fileSystemWatcher = fileSystemWatcher;
            _logger            = loggerFactory.CreateLogger <ScriptProjectSystem>();
            _projects          = new ConcurrentDictionary <string, ProjectInfo>();

            _compilationDependencyResolver = new CompilationDependencyResolver(type =>
            {
                // Prefix with "OmniSharp" so that we make it through the log filter.
                var categoryName             = $"OmniSharp.Script.{type.FullName}";
                var dependencyResolverLogger = loggerFactory.CreateLogger(categoryName);
                return((level, message) =>
                {
                    if (level == LogLevel.Debug)
                    {
                        dependencyResolverLogger.LogDebug(message);
                    }
                    if (level == LogLevel.Info)
                    {
                        dependencyResolverLogger.LogInformation(message);
                    }
                });
            });
        }
Пример #2
0
        private CompilationDependencyResolver CreateResolverCompilationDependencyResolver()
        {
            var resolver = new CompilationDependencyResolver(type => ((level, message) =>
            {
            }));

            return(resolver);
        }
        private CompilationDependencyResolver CreateResolver()
        {
            var resolver = new CompilationDependencyResolver(type => ((level, message) =>
            {
                _testOutputHelper.WriteLine($"{level}:{message ?? ""}");
            }));

            return(resolver);
        }
Пример #4
0
 public ScriptContextProvider(ILoggerFactory loggerFactory, IOmniSharpEnvironment env, MetadataFileReferenceCache metadataFileReferenceCache, FileSystemHelper fileSystemHelper)
 {
     _loggerFactory = loggerFactory;
     _env           = env;
     _metadataFileReferenceCache = metadataFileReferenceCache;
     _fileSystemHelper           = fileSystemHelper;
     _logger = loggerFactory.CreateLogger <ScriptContextProvider>();
     _compilationDependencyResolver = new CompilationDependencyResolver(type =>
     {
         // Prefix with "OmniSharp" so that we make it through the log filter.
         var categoryName             = $"OmniSharp.Script.{type.FullName}";
         var dependencyResolverLogger = loggerFactory.CreateLogger(categoryName);
         return((level, message, exception) =>
         {
             if (level == LogLevel.Trace)
             {
                 dependencyResolverLogger.LogTrace(message);
             }
             if (level == LogLevel.Debug)
             {
                 dependencyResolverLogger.LogDebug(message);
             }
             if (level == LogLevel.Info)
             {
                 dependencyResolverLogger.LogInformation(message);
             }
             if (level == LogLevel.Warning)
             {
                 dependencyResolverLogger.LogWarning(message);
             }
             if (level == LogLevel.Error)
             {
                 dependencyResolverLogger.LogError(exception, message);
             }
             if (level == LogLevel.Critical)
             {
                 dependencyResolverLogger.LogCritical(exception, message);
             }
         });
     });
 }
Пример #5
0
        void AddCompilationDependencies(ScriptSource source)
        {
            var loaded = AppDomain.CurrentDomain.GetAssemblies()
                         .Where(a => !a.IsDynamic)
                         .Select(a => a.Location)
                         .Distinct()
                         .ToDictionary(Path.GetFileName);

            var dependencyResolver = new CompilationDependencyResolver(t => (l, m, e) => Log.Out(m));
            var dependencies       = dependencyResolver.GetDependencies(
                source.File.DirectoryName,
                source.AllFiles().Select(x => x.File.ToString()),
                true, "netcoreapp3.1");

            var assemblyReferences = dependencies
                                     .SelectMany(d => d.AssemblyPaths)
                                     .Select(l => loaded.TryGetValue(Path.GetFileName(l), out var e) ? e : l)
                                     .ToArray();

            foreach (var each in assemblyReferences)
            {
                AddReference(each);
            }
        }
        private CompilationDependencyResolver CreateCompilationDependencyResolver()
        {
            var resolver = new CompilationDependencyResolver(TestOutputHelper.CreateTestLogFactory());

            return(resolver);
        }