Exemplo n.º 1
0
        public override TextEdit ReadJson(JsonReader reader, Type objectType, TextEdit existingValue, bool hasExistingValue, JsonSerializer serializer)
        {
            var      result = JObject.Load(reader);
            TextEdit edit;

            if (result["annotationId"] is { Type : JTokenType.String } annotation)
            {
                edit = new AnnotatedTextEdit()
                {
                    AnnotationId = annotation.ToObject <ChangeAnnotationIdentifier>()
                };
            }
Exemplo n.º 2
0
        public void AnnotatedTest(string expected)
        {
            var model = new AnnotatedTextEdit {
                NewText      = "new text",
                Range        = new Range(new Position(1, 1), new Position(2, 2)),
                AnnotationId = "Cool story"
            };
            var result = Fixture.SerializeObject(model);

            result.Should().Be(expected);

            var deresult = new LspSerializer(ClientVersion.Lsp3).DeserializeObject <TextEdit>(expected);

            deresult.Should().BeOfType <AnnotatedTextEdit>();
            deresult.Should().BeEquivalentTo(model, x => x.UsingStructuralRecordEquality());
        }