Ejemplo n.º 1
0
        public InteractiveHostTests()
        {
            _host = new InteractiveHost(typeof(CSharpReplServiceProvider), GetInteractiveHostPath(), ".", millisecondsTimeout: -1);

            RedirectOutput();

            _host.ResetAsync(new InteractiveHostOptions(initializationFile: null, culture: CultureInfo.InvariantCulture)).Wait();

            var remoteService = _host.TryGetService();
            Assert.NotNull(remoteService);

            _host.SetPathsAsync(new[] { s_fxDir }, new[] { s_homeDir }, s_homeDir).Wait();

            // assert and remove logo:
            var output = SplitLines(ReadOutputToEnd());
            var errorOutput = ReadErrorOutputToEnd();

            Assert.Equal("", errorOutput);
            Assert.Equal(2, output.Length);
            Assert.Equal("Microsoft (R) Roslyn C# Compiler version " + FileVersionInfo.GetVersionInfo(_host.GetType().Assembly.Location).FileVersion, output[0]);
            // "Type "#help" for more information."
            Assert.Equal(FeaturesResources.TypeHelpForMoreInformation, output[1]);

            // remove logo:
            ClearOutput();
        }
Ejemplo n.º 2
0
        public InteractiveHostTests()
        {
            Host = new InteractiveHost(typeof(CSharpReplServiceProvider), GetInteractiveHostPath(), ".", millisecondsTimeout: -1);

            RedirectOutput();

            Host.ResetAsync(new InteractiveHostOptions(initializationFile: null, culture: CultureInfo.InvariantCulture)).Wait();

            var remoteService = Host.TryGetService();

            Assert.NotNull(remoteService);

            remoteService.SetTestObjectFormattingOptions();

            Host.SetPathsAsync(new[] { s_fxDir }, new[] { s_homeDir }, s_homeDir).Wait();

            // assert and remove logo:
            var output      = SplitLines(ReadOutputToEnd());
            var errorOutput = ReadErrorOutputToEnd();

            Assert.Equal("", errorOutput);
            Assert.Equal(2, output.Length);
            Assert.Equal("Microsoft (R) Roslyn C# Compiler version " + FileVersionInfo.GetVersionInfo(Host.GetType().Assembly.Location).FileVersion, output[0]);
            // "Type "#help" for more information."
            Assert.Equal(FeaturesResources.TypeHelpForMoreInformation, output[1]);

            // remove logo:
            ClearOutput();
        }
Ejemplo n.º 3
0
        public InteractiveHostTests()
        {
            _host = new InteractiveHost(typeof(CSharpReplServiceProvider), ".", millisecondsTimeout: -1);

            RedirectOutput();

            _host.ResetAsync(new InteractiveHostOptions(GetInteractiveHostDirectory(), initializationFile: null, culture: CultureInfo.InvariantCulture)).Wait();

            var remoteService = _host.TryGetService();

            Assert.NotNull(remoteService);

            _host.SetPathsAsync(new[] { s_fxDir }, new[] { s_homeDir }, s_homeDir).Wait();

            // assert and remove logo:
            var output      = SplitLines(ReadOutputToEnd());
            var errorOutput = ReadErrorOutputToEnd();

            Assert.Equal("", errorOutput);
            Assert.Equal(2, output.Length);
            Assert.Equal(string.Format(CSharpScriptingResources.LogoLine1, typeof(CSharpReplServiceProvider).GetTypeInfo().Assembly.GetCustomAttribute <AssemblyFileVersionAttribute>().Version), output[0]);
            // "Type "#help" for more information."
            Assert.Equal(InteractiveHostResources.Type_Sharphelp_for_more_information, output[1]);

            // remove logo:
            ClearOutput();
        }
Ejemplo n.º 4
0
        public InteractiveHostTests()
        {
            _host = new InteractiveHost(typeof(CSharpReplServiceProvider), ".", millisecondsTimeout: -1);

            RedirectOutput();

            _host.ResetAsync(new InteractiveHostOptions(initializationFile: null, culture: CultureInfo.InvariantCulture)).Wait();

            var remoteService = _host.TryGetService();

            Assert.NotNull(remoteService);

            _host.SetPathsAsync(new[] { s_fxDir }, new[] { s_homeDir }, s_homeDir).Wait();

            // assert and remove logo:
            var output      = SplitLines(ReadOutputToEnd());
            var errorOutput = ReadErrorOutputToEnd();

            Assert.Equal("", errorOutput);
            Assert.Equal(2, output.Length);
            Assert.Equal(string.Format(CSharpInteractiveEditorResources.Microsoft_R_Roslyn_CSharp_Compiler_version_0, FileVersionInfo.GetVersionInfo(_host.GetType().Assembly.Location).FileVersion), output[0]);
            // "Type "#help" for more information."
            Assert.Equal(FeaturesResources.Type_Sharphelp_for_more_information, output[1]);

            // remove logo:
            ClearOutput();
        }
Ejemplo n.º 5
0
        public async Task SetPathsAsync(ImmutableArray <string> referenceSearchPaths, ImmutableArray <string> sourceSearchPaths, string workingDirectory)
        {
            try
            {
                var result = await _interactiveHost.SetPathsAsync(referenceSearchPaths.ToArray(), sourceSearchPaths.ToArray(), workingDirectory).ConfigureAwait(false);

                UpdateResolvers(result);
            }
            catch (Exception e) when(FatalError.Report(e))
            {
                throw ExceptionUtilities.Unreachable;
            }
        }
Ejemplo n.º 6
0
        public async Task InitializeAsync()
        {
            await _host.ResetAsync(new InteractiveHostOptions(GetInteractiveHostDirectory(), initializationFile : null, culture : CultureInfo.InvariantCulture));

            await _host.SetPathsAsync(new[] { s_fxDir }, new[] { s_homeDir }, s_homeDir);

            // assert and remove logo:
            var output      = SplitLines(await ReadOutputToEnd());
            var errorOutput = await ReadErrorOutputToEnd();

            Assert.Equal("", errorOutput);
            Assert.Equal(2, output.Length);
            var version = CommonCompiler.GetProductVersion(typeof(CSharpReplServiceProvider));

            Assert.Equal(string.Format(CSharpScriptingResources.LogoLine1, version), output[0]);
            // "Type "#help" for more information."
            Assert.Equal(InteractiveHostResources.Type_Sharphelp_for_more_information, output[1]);

            // remove logo:
            ClearOutput();
        }
Ejemplo n.º 7
0
 public void SetInitialPaths(string[] referenceSearchPaths, string[] sourceSearchPaths, string baseDirectory)
 {
     _initialWorkingDirectory = baseDirectory;
     UpdateLocalPaths(referenceSearchPaths, sourceSearchPaths, baseDirectory);
     _interactiveHost.SetPathsAsync(referenceSearchPaths, sourceSearchPaths, baseDirectory);
 }