/// <summary>
        /// Creates a build request.
        /// </summary>
        private BuildRequest CreateBuildRequest(int nodeRequestId, int configId, string[] targets, NodeAffinity nodeAffinity, BuildRequest parentRequest)
        {
            HostServices hostServices = null;

            if (nodeAffinity != NodeAffinity.Any)
            {
                hostServices = new HostServices();
                hostServices.SetNodeAffinity(String.Empty, nodeAffinity);
            }

            BuildRequest request = new BuildRequest(1 /* submissionId */, nodeRequestId, configId, targets, hostServices, BuildEventContext.Invalid, parentRequest);

            return(request);
        }
        public void TestClearingAffinities()
        {
            HostServices hostServices = new HostServices();

            hostServices.SetNodeAffinity("project", NodeAffinity.OutOfProc);
            Assert.Equal(NodeAffinity.OutOfProc, hostServices.GetNodeAffinity("project"));
            hostServices.SetNodeAffinity(null, NodeAffinity.OutOfProc);
            Assert.Equal(NodeAffinity.Any, hostServices.GetNodeAffinity("project"));

            hostServices.SetNodeAffinity(String.Empty, NodeAffinity.OutOfProc);
            Assert.Equal(NodeAffinity.OutOfProc, hostServices.GetNodeAffinity("project"));
            hostServices.SetNodeAffinity(null, NodeAffinity.OutOfProc);
            Assert.Equal(NodeAffinity.Any, hostServices.GetNodeAffinity("project"));
        }
        public void UnloadedProjectDiscardsHostServicesAllProjects()
        {
            HostServices   hostServices = new HostServices();
            TestHostObject th           = new TestHostObject();

            ProjectCollection.GlobalProjectCollection.HostServices = hostServices;
            Project project = LoadDummyProject("foo.proj");

            hostServices.RegisterHostObject(project.FullPath, "test", "Message", th);

            ProjectCollection.GlobalProjectCollection.UnloadAllProjects();

            Assert.False(hostServices.HasHostObject(project.FullPath));
        }
    public override async Task InitializeAsync()
    {
        // Let's re-create the database first
        await using var dbContext = HostServices.GetRequiredService <IDbContextFactory <AppDbContext> >().CreateDbContext();
        await dbContext.Database.EnsureDeletedAsync();

        await dbContext.Database.EnsureCreatedAsync();

        await base.InitializeAsync();

        await Host.StartAsync();

        await Task.Delay(100);
    }
Exemple #5
0
        /// <summary>
        /// Create a new instance of a workspace that can be populated by opening solution and project files.
        /// </summary>
        /// <param name="properties">The MSBuild properties used when interpreting project files.
        /// These are the same properties that are passed to msbuild via the /property:&lt;n&gt;=&lt;v&gt; command line argument.</param>
        /// <param name="hostServices">The <see cref="HostServices"/> used to configure this workspace.</param>
        public static ErgonWorkspace Create(IDictionary <string, string> properties, HostServices hostServices)
        {
            if (properties == null)
            {
                throw new ArgumentNullException(nameof(properties));
            }

            if (hostServices == null)
            {
                throw new ArgumentNullException(nameof(hostServices));
            }

            return(new ErgonWorkspace(hostServices, properties.ToImmutableDictionary()));
        }
Exemple #6
0
        public void TestValidHostObjectRegistration()
        {
            HostServices   hostServices = new HostServices();
            TestHostObject hostObject   = new TestHostObject();
            TestHostObject hostObject2  = new TestHostObject();
            TestHostObject hostObject3  = new TestHostObject();

            hostServices.RegisterHostObject("foo.proj", "target", "task", hostObject);
            hostServices.RegisterHostObject("foo.proj", "target2", "task", hostObject2);
            hostServices.RegisterHostObject("foo.proj", "target", "task2", hostObject3);

            Assert.Same(hostObject, hostServices.GetHostObject("foo.proj", "target", "task"));
            Assert.Same(hostObject2, hostServices.GetHostObject("foo.proj", "target2", "task"));
            Assert.Same(hostObject3, hostServices.GetHostObject("foo.proj", "target", "task2"));
        }
        internal VisualStudioWorkspace(HostServices hostServices)
            : base(hostServices, WorkspaceKind.Host)
        {
            _backgroundCompiler = new BackgroundCompiler(this);

            var cacheService = Services.GetService <IWorkspaceCacheService>();

            if (cacheService != null)
            {
                cacheService.CacheFlushRequested += OnCacheFlushRequested;
            }

            _backgroundParser = new BackgroundParser(this);
            _backgroundParser.Start();
        }
Exemple #8
0
        public void TestTranslationHostObjectsWhenEmpty()
        {
            var          hostServices = new HostServices();
            BuildRequest request      = new BuildRequest(
                submissionId: 1,
                _nodeRequestId++,
                1,
                new string[] { "alpha", "omega" },
                hostServices: hostServices,
                BuildEventContext.Invalid,
                parentRequest: null);

            ((ITranslatable)request).Translate(TranslationHelpers.GetWriteTranslator());
            BuildRequest.FactoryForDeserialization(TranslationHelpers.GetReadTranslator());
        }
Exemple #9
0
        /// <summary>
        /// Constructs a new workspace instance.
        /// </summary>
        /// <param name="host">The <see cref="HostServices"/> this workspace uses</param>
        /// <param name="workspaceKind">A string that can be used to identify the kind of workspace. Usually this matches the name of the class.</param>
        protected Workspace(HostServices host, string workspaceKind)
        {
            this.primaryBranchId = BranchId.GetNextId();
            this.workspaceKind   = workspaceKind;

            this.services = host.CreateWorkspaceServices(this);

            // queue used for sending events
            var workspaceTaskSchedulerFactory = this.services.GetService <IWorkspaceTaskSchedulerFactory>();

            this.taskQueue = workspaceTaskSchedulerFactory.CreateTaskQueue();

            // initialize with empty solution
            this.latestSolution = CreateSolution(SolutionId.CreateNewId());
        }
Exemple #10
0
        async Task InitializeInstanceAsync()
        {
            var timings  = new Dictionary <string, long> ();
            var metadata = new CompositionLoadMetadata(timings);

            using (var timer = Counters.CompositionLoad.BeginTiming(metadata)) {
                var fullTimer = System.Diagnostics.Stopwatch.StartNew();
                var stepTimer = System.Diagnostics.Stopwatch.StartNew();

                var mefAssemblies = ReadAssembliesFromAddins(timer);
                timings ["ReadFromAddins"] = stepTimer.ElapsedMilliseconds;
                stepTimer.Restart();

                var caching = new Caching(mefAssemblies, new IdeRuntimeCompositionExceptionHandler());

                // Try to use cached MEF data

                var canUse = metadata.ValidCache = caching.CanUse();
                if (canUse)
                {
                    LoggingService.LogInfo("Creating MEF composition from cache");
                    RuntimeComposition = await TryCreateRuntimeCompositionFromCache(caching);
                }
                timings ["LoadFromCache"] = stepTimer.ElapsedMilliseconds;
                stepTimer.Restart();

                // Otherwise fallback to runtime discovery.
                if (RuntimeComposition == null)
                {
                    LoggingService.LogInfo("Creating MEF composition from runtime");
                    var(runtimeComposition, catalog) = await CreateRuntimeCompositionFromDiscovery(caching, timer);

                    RuntimeComposition = runtimeComposition;

                    CachedComposition cacheManager = new CachedComposition();
                    caching.Write(RuntimeComposition, catalog, cacheManager).Ignore();
                }
                timings ["LoadRuntimeComposition"] = stepTimer.ElapsedMilliseconds;
                stepTimer.Restart();

                ExportProviderFactory = RuntimeComposition.CreateExportProviderFactory();
                ExportProvider        = ExportProviderFactory.CreateExportProvider();
                HostServices          = Microsoft.VisualStudio.LanguageServices.VisualStudioMefHostServices.Create(ExportProvider);

                timings ["CreateServices"] = stepTimer.ElapsedMilliseconds;
                metadata.Duration          = fullTimer.ElapsedMilliseconds;
            }
        }
Exemple #11
0
        public bool Stop()
        {
            Log.LogInfo("Stopping service");

            _listener.Stop();

            _cacheServer.Stop();

            Log.LogInfo("Service stopped successfully");

            // stop this after last log
            HostServices.Stop();


            return(true);
        }
Exemple #12
0
        internal RoslynWorkspace(HostServices host, NuGetConfiguration nuGetConfiguration, CompositionHost compositionContext, string dotnetPath, string sdkPath)
            : base(host, WorkspaceKind.Host)
        {
            this.dotnetPath     = dotnetPath;
            this.sdkPath        = sdkPath;
            _nuGetConfiguration = nuGetConfiguration;

            _openDocumentTextLoaders     = new Dictionary <DocumentId, AvalonEditTextContainer>();
            _diagnosticsUpdatedNotifiers = new ConcurrentDictionary <DocumentId, Action <DiagnosticsUpdatedArgs> >();

            _compositionContext = compositionContext;

            this.EnableDiagnostics(DiagnosticOptions.Semantic | DiagnosticOptions.Syntax);

            GetService <IDiagnosticService>().DiagnosticsUpdated += OnDiagnosticsUpdated;
        }
Exemple #13
0
        public void TestGeneralAffinityRegistration()
        {
            HostServices hostServices = new HostServices();

            hostServices.SetNodeAffinity(String.Empty, NodeAffinity.InProc);
            Assert.Equal(NodeAffinity.InProc, hostServices.GetNodeAffinity("project"));
            Assert.Equal(NodeAffinity.InProc, hostServices.GetNodeAffinity("project2"));

            hostServices.SetNodeAffinity(String.Empty, NodeAffinity.OutOfProc);
            Assert.Equal(NodeAffinity.OutOfProc, hostServices.GetNodeAffinity("project"));
            Assert.Equal(NodeAffinity.OutOfProc, hostServices.GetNodeAffinity("project2"));

            hostServices.SetNodeAffinity(String.Empty, NodeAffinity.Any);
            Assert.Equal(NodeAffinity.Any, hostServices.GetNodeAffinity("project"));
            Assert.Equal(NodeAffinity.Any, hostServices.GetNodeAffinity("project2"));
        }
Exemple #14
0
        public void TestUnregisteringNonConflictingHostObjectRestoresOriginalAffinity()
        {
            HostServices   hostServices = new HostServices();
            TestHostObject hostObject   = new TestHostObject();

            hostServices.SetNodeAffinity(String.Empty, NodeAffinity.OutOfProc);
            hostServices.SetNodeAffinity("project", NodeAffinity.Any);
            Assert.Equal(NodeAffinity.OutOfProc, hostServices.GetNodeAffinity("project2"));
            Assert.Equal(NodeAffinity.Any, hostServices.GetNodeAffinity("project"));

            hostServices.RegisterHostObject("project", "target", "task", hostObject);
            Assert.Equal(NodeAffinity.InProc, hostServices.GetNodeAffinity("project"));
            hostServices.RegisterHostObject("project", "target", "task", hostObject: null);
            Assert.Equal(NodeAffinity.Any, hostServices.GetNodeAffinity("project"));
            Assert.Equal(NodeAffinity.OutOfProc, hostServices.GetNodeAffinity("project2"));
        }
Exemple #15
0
        public void CloneTargets()
        {
            var hostServices = new HostServices();

            ProjectInstance first  = GetSampleProjectInstance(hostServices);
            ProjectInstance second = first.DeepCopy();

            // Targets, tasks are immutable so we can expect the same objects
            Assert.True(Object.ReferenceEquals(first.Targets, second.Targets));
            Assert.True(Object.ReferenceEquals(first.Targets["t"], second.Targets["t"]));

            var firstTasks  = first.Targets["t"];
            var secondTasks = second.Targets["t"];

            Assert.True(Object.ReferenceEquals(firstTasks.Children[0], secondTasks.Children[0]));
        }
        public HttpResponseMessage CreateCustomer(CreateCustomerRequest request)
        {
            CreateCustomerResponse responseData = null;

            try
            {
                //Authenticate API key
                long?hostId = HostServices.GetCallerHostId();
                if (!hostId.HasValue)
                {
                    Log.Warn(ResponseMessages.InvalidAPIKey);
                    return(Request.CreateResponse(new GenericResponse(null, ResponseCodes.InvalidAPIKey, ResponseMessages.InvalidAPIKey)));
                }

                //Validate input
                if (request == null ||
                    string.IsNullOrEmpty(request.ReferenceId))
                {
                    return(Request.CreateResponse(new GenericResponse(null, ResponseCodes.InvalidParam, ResponseMessages.InvalidParam)));
                }

                //Validate input length
                if (request.ReferenceId.Length > 30)
                {
                    return(Request.CreateResponse(new GenericResponse(null, ResponseCodes.InvalidParam, "Reference ID (max 30 length) is too long.")));
                }

                //Validate customer reference ID
                IdentityServices identityService = new IdentityServices();
                if (identityService.IsRefIdExists(IdentityServices.RefIdTypes.Customer, hostId.Value, request.ReferenceId))
                {
                    return(Request.CreateResponse(new GenericResponse(null, ResponseCodes.DuplicateRefId, ResponseMessages.DuplicateRefId + " (Customer " + request.ReferenceId + ")")));
                }

                //Perform transaction
                CustomerServices customerServices = new CustomerServices();
                responseData = customerServices.CreateCustomer(hostId.Value, request);

                //Send response
                return(Request.CreateResponse(new GenericResponse(responseData, ResponseCodes.Success, ResponseMessages.Success)));
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
                return(Request.CreateResponse(new GenericResponse(null, ResponseCodes.Error, ResponseMessages.Error)));
            }
        }
        static WorkspaceHacks()
        {
            var assemblyNames = new[]
            {
                "Microsoft.CodeAnalysis.Workspaces",
                "Microsoft.CodeAnalysis.Workspaces.Desktop",
                "Microsoft.CodeAnalysis.CSharp.Workspaces",
                "Microsoft.CodeAnalysis.VisualBasic.Workspaces",
                "Microsoft.CodeAnalysis.Features",
                "Microsoft.CodeAnalysis.CSharp.Features",
                "Microsoft.CodeAnalysis.VisualBasic.Features"
            };
            var assemblies = assemblyNames
                             .Select(n => Assembly.Load(n));

            Pack = MefHostServices.Create(assemblies);
        }
Exemple #18
0
        /// <summary>
        /// Create a ProjectInstance from provided project content and host services object
        /// </summary>
        private static ProjectInstance GetProjectInstance(string content, HostServices hostServices, IDictionary <string, string> globalProperties, ProjectCollection projectCollection, string toolsVersion = null)
        {
            XmlReader reader = XmlReader.Create(new StringReader(content));

            if (globalProperties == null)
            {
                // choose some interesting defaults if we weren't explicitly asked to use a set.
                globalProperties = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
                globalProperties.Add("g1", "v1");
                globalProperties.Add("g2", "v2");
            }

            Project project = new Project(reader, globalProperties, toolsVersion ?? ObjectModelHelpers.MSBuildDefaultToolsVersion, projectCollection ?? ProjectCollection.GlobalProjectCollection);

            ProjectInstance instance = project.CreateProjectInstance();

            return(instance);
        }
Exemple #19
0
        public BuildRequest(
            int submissionId,
            int nodeRequestId,
            int configurationId,
            ProxyTargets proxyTargets,
            HostServices hostServices,
            BuildRequestDataFlags buildRequestDataFlags = BuildRequestDataFlags.None,
            RequestedProjectState requestedProjectState = null,
            int projectContextId = BuildEventContext.InvalidProjectContextId)
            : this(submissionId, nodeRequestId, configurationId, hostServices, buildRequestDataFlags, requestedProjectState, projectContextId)
        {
            _proxyTargets = proxyTargets;
            _targets      = proxyTargets.ProxyTargetToRealTargetMap.Keys.ToList();

            // Only root requests can have proxy targets.
            _parentGlobalRequestId   = InvalidGlobalRequestId;
            _parentBuildEventContext = BuildEventContext.Invalid;
        }
Exemple #20
0
        public TemporaryWorkspace(
            HostServices hostServices,
            string?workspaceKind,
            SolutionInfo solutionInfo,
            SerializableOptionSet options
            ) : base(hostServices, workspaceKind)
        {
            SetOptions(Options.WithChangedOption(CacheOptions.RecoverableTreeLengthThreshold, 0));

            var documentOptionsProviderFactories = (
                (IMefHostExportProvider)Services.HostServices
                ).GetExports <IDocumentOptionsProviderFactory, OrderableMetadata>();

            RegisterDocumentOptionProviders(documentOptionsProviderFactories);

            OnSolutionAdded(solutionInfo);
            SetCurrentSolution(CurrentSolution.WithOptions(options));
        }
Exemple #21
0
        private async Task <string> GetXmlDocumentAsync(HostServices services)
        {
            using (var tempRoot = new TempRoot())
            {
                // get original assembly location
                var mscorlibLocation = typeof(object).Assembly.Location;

                // set up dll and xml doc content
                var tempDir       = tempRoot.CreateDirectory();
                var tempCorlib    = tempDir.CopyFile(mscorlibLocation);
                var tempCorlibXml = tempDir.CreateFile(Path.ChangeExtension(tempCorlib.Path, "xml"));
                tempCorlibXml.WriteAllText(@"<?xml version=""1.0"" encoding=""utf-8""?>
<doc>
  <assembly>
    <name>mscorlib</name>
  </assembly>
  <members>
    <member name=""T:System.Object"">
      <summary>Supports all classes in the .NET Framework class hierarchy and provides low-level services to derived classes. This is the ultimate base class of all classes in the .NET Framework; it is the root of the type hierarchy.To browse the .NET Framework source code for this type, see the Reference Source.</summary>
    </member>
  </members>
</doc>");

                // currently portable layer doesn't support xml documment
                var solution = new AdhocWorkspace(services).CurrentSolution
                               .AddProject("Project", "Project.dll", LanguageNames.CSharp)
                               .AddMetadataReference(MetadataReference.CreateFromFile(tempCorlib.Path))
                               .Solution;

                var snapshotService = (new RemotableDataServiceFactory()).CreateService(solution.Workspace.Services) as IRemotableDataService;
                using (var scope = await snapshotService.CreatePinnedRemotableDataScopeAsync(solution, CancellationToken.None))
                {
                    // recover solution from given snapshot
                    var recovered = await GetSolutionAsync(snapshotService, scope);

                    var compilation = await recovered.Projects.First().GetCompilationAsync(CancellationToken.None);

                    var objectType    = compilation.GetTypeByMetadataName("System.Object");
                    var xmlDocComment = objectType.GetDocumentationCommentXml();

                    return(xmlDocComment);
                }
            }
        }
        internal static Solution CreateFullSolution(HostServices hostServices = null)
        {
            var solution  = new AdhocWorkspace(hostServices ?? Host.Mef.MefHostServices.DefaultHost).CurrentSolution;
            var csCode    = "class A { }";
            var project1  = solution.AddProject("Project", "Project.dll", LanguageNames.CSharp);
            var document1 = project1.AddDocument("Document1", SourceText.From(csCode));

            var vbCode    = "Class B\r\nEnd Class";
            var project2  = document1.Project.Solution.AddProject("Project2", "Project2.dll", LanguageNames.VisualBasic);
            var document2 = project2.AddDocument("Document2", SourceText.From(vbCode));

            project1 = document2.Project.Solution.GetProject(project1.Id).AddProjectReference(new ProjectReference(project2.Id, ImmutableArray.Create("test")));
            project1 = project1.AddMetadataReference(MetadataReference.CreateFromFile(typeof(object).Assembly.Location));
            project1 = project1.AddAnalyzerReference(new AnalyzerFileReference(typeof(object).Assembly.Location, new TestAnalyzerAssemblyLoader()));

            var textDocument1 = project1.AddAdditionalDocument("Additional", SourceText.From("hello"), ImmutableArray.Create("test"), @".\Add");

            return(textDocument1.Project.Solution);
        }
Exemple #23
0
        private BuildRequest(
            int submissionId,
            int nodeRequestId,
            int configurationId,
            HostServices hostServices,
            BuildRequestDataFlags buildRequestDataFlags = BuildRequestDataFlags.None,
            RequestedProjectState requestedProjectState = null)
        {
            _submissionId    = submissionId;
            _configurationId = configurationId;

            HostServices       = hostServices;
            _buildEventContext = BuildEventContext.Invalid;
            _globalRequestId   = InvalidGlobalRequestId;

            _nodeRequestId         = nodeRequestId;
            _buildRequestDataFlags = buildRequestDataFlags;
            _requestedProjectState = requestedProjectState;
        }
 public CSharpInteractiveEvaluator(
     HostServices hostServices,
     IViewClassifierAggregatorService classifierAggregator,
     IInteractiveWindowCommandsFactory commandsFactory,
     ImmutableArray <IInteractiveWindowCommand> commands,
     IContentTypeRegistryService contentTypeRegistry,
     string responseFileDirectory,
     string initialWorkingDirectory)
     : base(
         contentTypeRegistry.GetContentType(ContentTypeNames.CSharpContentType),
         hostServices,
         classifierAggregator,
         commandsFactory,
         commands,
         (responseFileDirectory != null) ? Path.Combine(responseFileDirectory, InteractiveResponseFile) : null,
         initialWorkingDirectory,
         typeof(CSharpReplServiceProvider))
 {
 }
 public CSharpInteractiveEvaluator(
     IThreadingContext threadingContext,
     HostServices hostServices,
     IViewClassifierAggregatorService classifierAggregator,
     IInteractiveWindowCommandsFactory commandsFactory,
     ImmutableArray <IInteractiveWindowCommand> commands,
     IContentTypeRegistryService contentTypeRegistry,
     string initialWorkingDirectory)
     : base(
         threadingContext,
         contentTypeRegistry.GetContentType(ContentTypeNames.CSharpContentType),
         hostServices,
         classifierAggregator,
         commandsFactory,
         commands,
         InteractiveResponseFile,
         initialWorkingDirectory,
         typeof(CSharpReplServiceProvider))
 {
 }
        public ActionResult <IEnumerable <string> > Get(string relativeUrl)
        {
            var hs       = new HostServices(_settings.Tenant, _settings.Tenant, _serviceUrl, _settings.ApiKey);
            var filePath = _settings.Url + relativeUrl;

            try
            {
                var content = hs.GetContent(filePath);
                //TODO: consider caching content locally for speed
                return(File(content.Blob, GetContentType(content.Filename)));
            }
            catch (System.Exception ex)
            {
                if (ex.Message.Contains("authenticated"))
                {
                    return(Unauthorized());
                }
                return(NotFound());
            }
        }
Exemple #27
0
        internal RoslynWorkspace(HostServices host, NuGetConfiguration nuGetConfiguration, CompositionHost compositionContext, string dotnetPath, string sdkPath)
            : base(host, WorkspaceKind.Host)
        {
            this.dotnetPath     = dotnetPath;
            this.sdkPath        = sdkPath;
            _nuGetConfiguration = nuGetConfiguration;

            _openDocumentTextLoaders     = new Dictionary <DocumentId, AvalonEditTextContainer>();
            _diagnosticsUpdatedNotifiers = new ConcurrentDictionary <DocumentId, Action <DiagnosticsUpdatedArgs> >();

            _compositionContext = compositionContext;

            _buildNodes = new BlockingCollection <MSBuildHost>(Environment.ProcessorCount);

            DiagnosticProvider.Enable(this, DiagnosticProvider.Options.Semantic | DiagnosticProvider.Options.Syntax);

            //this.EnableDiagnostics(DiagnosticOptions.Semantic | DiagnosticOptions.Syntax);

            GetService <IDiagnosticService>().DiagnosticsUpdated += OnDiagnosticsUpdated;
        }
Exemple #28
0
        static MonoDevelopWorkspace()
        {
            List <Assembly> assemblies = new List <Assembly> ();

            foreach (var asmName in mefHostServices)
            {
                try {
                    var asm = Assembly.Load(asmName);
                    if (asm == null)
                    {
                        continue;
                    }
                    assemblies.Add(asm);
                } catch (Exception) {
                    LoggingService.LogError("Error - can't load host service assembly: " + asmName);
                }
            }
            assemblies.Add(typeof(MonoDevelopWorkspace).Assembly);
            services = Microsoft.CodeAnalysis.Host.Mef.MefHostServices.Create(assemblies);
        }
 public CSharpInteractiveEvaluator(
     HostServices hostServices,
     IViewClassifierAggregatorService classifierAggregator,
     IInteractiveWindowCommandsFactory commandsFactory,
     IInteractiveWindowCommand[] commands,
     IContentTypeRegistryService contentTypeRegistry,
     string responseFileDirectory,
     string initialWorkingDirectory)
     : base(
         contentTypeRegistry.GetContentType(ContentTypeNames.CSharpContentType),
         hostServices,
         classifierAggregator,
         commandsFactory,
         commands,
         (responseFileDirectory != null) ? Path.Combine(responseFileDirectory, InteractiveResponseFile) : null,
         initialWorkingDirectory,
         typeof(InteractiveHostEntryPoint).Assembly.Location,
         typeof(CSharpRepl))
 {
 }
Exemple #30
0
        public void TestTranslationRemoteHostObjects()
        {
            var stateInHostObject = 3;

            var hostServices = new HostServices();
            var rot          = new MockRunningObjectTable();

            hostServices.SetTestRunningObjectTable(rot);
            var moniker    = nameof(TestTranslationRemoteHostObjects) + Guid.NewGuid();
            var remoteHost = new MockRemoteHostObject(stateInHostObject);

            using (var result = rot.Register(moniker, remoteHost))
            {
                hostServices.RegisterHostObject(
                    "WithOutOfProc.targets",
                    "DisplayMessages",
                    "ATask",
                    moniker);

                BuildRequest request = new BuildRequest(
                    submissionId: 1,
                    _nodeRequestId++,
                    1,
                    new string[] { "alpha", "omega" },
                    hostServices: hostServices,
                    BuildEventContext.Invalid,
                    parentRequest: null);

                ((ITranslatable)request).Translate(TranslationHelpers.GetWriteTranslator());
                INodePacket packet = BuildRequest.FactoryForDeserialization(TranslationHelpers.GetReadTranslator());

                BuildRequest deserializedRequest = packet as BuildRequest;
                deserializedRequest.HostServices.SetTestRunningObjectTable(rot);
                var hostObject = deserializedRequest.HostServices.GetHostObject(
                    "WithOutOfProc.targets",
                    "DisplayMessages",
                    "ATask") as ITestRemoteHostObject;

                hostObject.GetState().ShouldBe(stateInHostObject);
            }
        }