提交 ca9ba10a 编写于 作者: H Heejae Chang 提交者: GitHub

Merge pull request #21564 from heejaechang/noImmutableMore

removed usage of ImmutableArray in json.net
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using Microsoft.CodeAnalysis.CodeActions;
......@@ -19,7 +20,7 @@ internal class AddImportFixData
/// May be empty for fixes that don't need to add an import and only do something like
/// add a project/metadata reference.
/// </summary>
public ImmutableArray<TextChange> TextChanges { get; }
public IList<TextChange> TextChanges { get; }
/// <summary>
/// String to display in the lightbulb menu.
......@@ -29,7 +30,7 @@ internal class AddImportFixData
/// <summary>
/// Tags that control what glyph is displayed in the lightbulb menu.
/// </summary>
public ImmutableArray<string> Tags { get; private set; }
public IList<string> Tags { get; private set; }
/// <summary>
/// The priority this item should have in the lightbulb list.
......
......@@ -5,6 +5,7 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.AddImport
{
......@@ -44,9 +45,9 @@ private abstract class AddImportCodeAction : CodeAction
FixData = fixData;
Title = fixData.Title;
Tags = fixData.Tags;
Tags = fixData.Tags.ToImmutableArrayOrEmpty();
Priority = fixData.Priority;
_textChanges = fixData.TextChanges;
_textChanges = fixData.TextChanges.ToImmutableArrayOrEmpty();
}
protected async Task<Document> GetUpdatedDocumentAsync(CancellationToken cancellationToken)
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using Microsoft.CodeAnalysis.AddImport;
......@@ -165,7 +166,7 @@ protected override PackageWithTypeResult ReadValue(JsonReader reader, JsonSerial
var typeName = ReadProperty<string>(reader);
var version = ReadProperty<string>(reader);
var rank = (int)ReadProperty<long>(reader);
var containingNamespaceNames = ReadProperty<ImmutableArray<string>>(serializer, reader);
var containingNamespaceNames = ReadProperty<IList<string>>(serializer, reader);
Contract.ThrowIfFalse(reader.Read());
Contract.ThrowIfFalse(reader.TokenType == JsonToken.EndObject);
......@@ -237,7 +238,7 @@ protected override ReferenceAssemblyWithTypeResult ReadValue(JsonReader reader,
var assemblyName = ReadProperty<string>(reader);
var typeName = ReadProperty<string>(reader);
var containingNamespaceNames = ReadProperty<ImmutableArray<string>>(serializer, reader);
var containingNamespaceNames = ReadProperty<IList<string>>(serializer, reader);
Contract.ThrowIfFalse(reader.Read());
Contract.ThrowIfFalse(reader.TokenType == JsonToken.EndObject);
......@@ -298,9 +299,9 @@ protected override AddImportFixData ReadValue(JsonReader reader, JsonSerializer
Contract.ThrowIfFalse(reader.TokenType == JsonToken.StartObject);
var kind = (AddImportFixKind)ReadProperty<long>(reader);
var textChanges = ReadProperty<ImmutableArray<TextChange>>(serializer, reader);
var textChanges = ReadProperty<IList<TextChange>>(serializer, reader).ToImmutableArrayOrEmpty();
var title = ReadProperty<string>(reader);
var tags = ReadProperty<ImmutableArray<string>>(serializer, reader);
var tags = ReadProperty<IList<string>>(serializer, reader).ToImmutableArrayOrEmpty();
var priority = (CodeActionPriority)ReadProperty<long>(reader);
var projectReferenceToAdd = ReadProperty<ProjectId>(serializer, reader);
......@@ -344,13 +345,13 @@ protected override void WriteValue(JsonWriter writer, AddImportFixData source, J
writer.WriteValue((int)source.Kind);
writer.WritePropertyName(nameof(AddImportFixData.TextChanges));
serializer.Serialize(writer, source.TextChanges);
serializer.Serialize(writer, source.TextChanges ?? SpecializedCollections.EmptyList<TextChange>());
writer.WritePropertyName(nameof(AddImportFixData.Title));
writer.WriteValue(source.Title);
writer.WritePropertyName(nameof(AddImportFixData.Tags));
serializer.Serialize(writer, source.Tags.NullToEmpty());
serializer.Serialize(writer, source.Tags ?? SpecializedCollections.EmptyList<string>());
writer.WritePropertyName(nameof(AddImportFixData.Priority));
writer.WriteValue((int)source.Priority);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册