Exemplo n.º 1
0
        public static TestManager Create(Project project, DotNetCliService dotNetCli, IEventEmitter eventEmitter, ILoggerFactory loggerFactory)
        {
            var workingDirectory = Path.GetDirectoryName(project.FilePath);

            var version = dotNetCli.GetVersion(workingDirectory);

            return(dotNetCli.IsLegacy(version)
                ? new LegacyTestManager(project, workingDirectory, dotNetCli, version, eventEmitter, loggerFactory)
                : (TestManager) new VSTestManager(project, workingDirectory, dotNetCli, version, eventEmitter, loggerFactory));
        }
Exemplo n.º 2
0
        public async Task Given_a_restored_project_the_references_are_emitted()
        {
            var emitter = new ProjectLoadTestEventEmitter();

            using var testProject = await TestAssets.Instance.GetTestProjectAsync("HelloWorld");

            var dotnetCliService = new DotNetCliService(LoggerFactory, emitter);
            await dotnetCliService.RestoreAsync(testProject.Directory);

            using var host = CreateMSBuildTestHost(testProject.Directory, emitter.AsExportDescriptionProvider(LoggerFactory));
            Assert.Single(emitter.ReceivedMessages);
            Assert.NotEmpty(emitter.ReceivedMessages[0].References.Where(reference => reference == GetHashedReference("system.core")));
        }
        private static string SetMSBuildSdksPath(DotNetCliService dotNetCli)
        {
            var oldMSBuildSDKsPath = Environment.GetEnvironmentVariable(MSBuildSDKsPath);

            var info            = dotNetCli.GetInfo();
            var msbuildSdksPath = Path.Combine(info.BasePath, "Sdks");

            if (Directory.Exists(msbuildSdksPath))
            {
                Environment.SetEnvironmentVariable(MSBuildSDKsPath, msbuildSdksPath);
            }

            return(oldMSBuildSDKsPath);
        }
Exemplo n.º 4
0
        public DotNetProjectSystem(
            IOmniSharpEnvironment environment,
            OmniSharpWorkspace workspace,
            DotNetCliService dotNetCliService,
            MetadataFileReferenceCache metadataFileReferenceCache,
            IEventEmitter eventEmitter,
            IFileSystemWatcher fileSystemWatcher,
            ILoggerFactory loggerFactory)
        {
            _environment                = environment;
            _workspace                  = workspace;
            _dotNetCliService           = dotNetCliService;
            _metadataFileReferenceCache = metadataFileReferenceCache;
            _eventEmitter               = eventEmitter;
            _fileSystemWatcher          = fileSystemWatcher;
            _logger = loggerFactory.CreateLogger <DotNetProjectSystem>();

            _projectStates = new ProjectStatesCache(loggerFactory, _eventEmitter);
        }
Exemplo n.º 5
0
        public MSBuildProjectSystem(
            IOmniSharpEnvironment environment,
            OmniSharpWorkspace workspace,
            DotNetCliService dotNetCliService,
            MetadataFileReferenceCache metadataFileReferenceCache,
            IEventEmitter eventEmitter,
            IFileSystemWatcher fileSystemWatcher,
            ILoggerFactory loggerFactory)
        {
            _environment = environment;
            _workspace   = workspace;
            _dotNetCli   = dotNetCliService;
            _metadataFileReferenceCache = metadataFileReferenceCache;
            _eventEmitter      = eventEmitter;
            _fileSystemWatcher = fileSystemWatcher;
            _loggerFactory     = loggerFactory;

            _projects                 = new ProjectFileInfoCollection();
            _projectsToProcess        = new Queue <ProjectFileInfo>();
            _logger                   = loggerFactory.CreateLogger <MSBuildProjectSystem>();
            _packageDepedencyResolver = new PackageDependencyResolver(loggerFactory);
        }
        public async Task Given_a_restored_project_the_references_are_emitted()
        {
            var messages = new List <ProjectConfigurationMessage>();
            var emitter  = new ProjectLoadTestEventEmitter(messages);

            var listener = new ProjectLoadListener(LoggerFactory, emitter);
            var exports  = new ExportDescriptorProvider[]
            {
                MefValueProvider.From <IMSBuildEventSink>(listener)
            };

            using (var testProject = await TestAssets.Instance.GetTestProjectAsync("HelloWorld"))
            {
                var dotnetCliService = new DotNetCliService(LoggerFactory, emitter);
                await dotnetCliService.RestoreAsync(testProject.Directory);

                using (var host = CreateMSBuildTestHost(testProject.Directory, exports))
                {
                    Assert.Single(messages);
                    Assert.NotEmpty(messages[0].References.Where(reference => reference == GetHashedReference("system.core")));
                }
            }
        }
        public ProjectSystem(
            IOmniSharpEnvironment environment,
            OmniSharpWorkspace workspace,
            IMSBuildLocator msbuildLocator,
            DotNetCliService dotNetCliService,
            SdksPathResolver sdksPathResolver,
            MetadataFileReferenceCache metadataFileReferenceCache,
            IEventEmitter eventEmitter,
            IFileSystemWatcher fileSystemWatcher,
            ILoggerFactory loggerFactory)
        {
            _environment                = environment;
            _workspace                  = workspace;
            _propertyOverrides          = msbuildLocator.RegisteredInstance.PropertyOverrides;
            _dotNetCli                  = dotNetCliService;
            _sdksPathResolver           = sdksPathResolver;
            _metadataFileReferenceCache = metadataFileReferenceCache;
            _eventEmitter               = eventEmitter;
            _fileSystemWatcher          = fileSystemWatcher;
            _loggerFactory              = loggerFactory;

            _projectsToProcess = new Queue <ProjectFileInfo>();
            _logger            = loggerFactory.CreateLogger <ProjectSystem>();
        }
Exemplo n.º 8
0
 public VSTestManager(Project project, string workingDirectory, DotNetCliService dotNetCli, SemanticVersion dotNetCliVersion, IEventEmitter eventEmitter, ILoggerFactory loggerFactory)
     : base(project, workingDirectory, dotNetCli, dotNetCliVersion, eventEmitter, loggerFactory.CreateLogger <VSTestManager>())
 {
 }
Exemplo n.º 9
0
 public LegacyTestManager(Project project, string workingDirectory, DotNetCliService dotNetCli, IEventEmitter eventEmitter, ILoggerFactory loggerFactory)
     : base(project, workingDirectory, dotNetCli, eventEmitter, loggerFactory.CreateLogger <LegacyTestManager>())
 {
 }
Exemplo n.º 10
0
 public RunTestService(OmniSharpWorkspace workspace, DotNetCliService dotNetCli, IEventEmitter eventEmitter, ILoggerFactory loggerFactory)
     : base(workspace, dotNetCli, eventEmitter, loggerFactory)
 {
 }
Exemplo n.º 11
0
 public DebugTestClassService(DebugSessionManager debugSessionManager, OmniSharpWorkspace workspace, DotNetCliService dotNetCli, IEventEmitter eventEmitter, ILoggerFactory loggerFactory)
     : base(workspace, dotNetCli, eventEmitter, loggerFactory)
 {
     _debugSessionManager = debugSessionManager;
 }
 public PackageDependencyChecker(ILoggerFactory loggerFactory, IEventEmitter eventEmitter, DotNetCliService dotNetCli, MSBuildOptions options)
 {
     _logger       = loggerFactory.CreateLogger <PackageDependencyChecker>();
     _eventEmitter = eventEmitter;
     _dotNetCli    = dotNetCli;
     _options      = options;
 }
Exemplo n.º 13
0
 public SdksPathResolver(DotNetCliService dotNetCli)
 {
     _dotNetCli = dotNetCli;
 }