Esempio n. 1
0
        /// <summary>
        ///     Create a new <see cref="LspConnection"/>.
        /// </summary>
        /// <param name="loggerFactory">
        ///     The factory for loggers used by the connection and its components.
        /// </param>
        /// <param name="input">
        ///     The input stream.
        /// </param>
        /// <param name="output">
        ///     The output stream.
        /// </param>
        public LspConnection(ILoggerFactory loggerFactory, Stream input, Stream output)
        {
            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

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

            if (!input.CanRead)
            {
                throw new ArgumentException("Input stream does not support reading.", nameof(input));
            }

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

            if (!output.CanWrite)
            {
                throw new ArgumentException("Output stream does not support reading.", nameof(output));
            }

            Log     = loggerFactory.CreateLogger <LspConnection>();
            _input  = input;
            _output = output;

            // What does client version do? Do we have to negotiate this?
            // The connection may change its Serializer instance once connected; this can be propagated to other components as required.
            Serializer = new Serializer(ClientVersion.Lsp3);
        }
Esempio n. 2
0
        public void SimpleTest(string expected)
        {
            var model = new CancelParams()
            {
                Id = "123"
            };
            var result = Fixture.SerializeObject(model);

            result.Should().Be(expected);

            var deresult = new OmniSharp.Extensions.LanguageServer.Protocol.Serialization.Serializer(ClientVersion.Lsp3).DeserializeObject <CancelParams>(expected);

            deresult.Should().BeEquivalentTo(model);
        }