зеркало из https://github.com/dotnet/razor.git
Коммит
2518a370be
|
@ -20,6 +20,8 @@
|
|||
<FileSignInfo Include="OmniSharp.Extensions.LanguageServer.dll" CertificateName="3PartySHA2" />
|
||||
<FileSignInfo Include="OmniSharp.Extensions.LanguageServer.Shared.dll" CertificateName="3PartySHA2" />
|
||||
<FileSignInfo Include="Nerdbank.Streams.dll" CertificateName="3PartySHA2" />
|
||||
<FileSignInfo Include="MessagePack.Annotations.dll" CertificateName="3PartySHA2" />
|
||||
<FileSignInfo Include="MessagePack.dll" CertificateName="3PartySHA2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -147,6 +147,7 @@
|
|||
<MonoAddinsPackageVersion>1.3.8</MonoAddinsPackageVersion>
|
||||
<MonoDevelopSdkPackageVersion>1.0.15</MonoDevelopSdkPackageVersion>
|
||||
<MoqPackageVersion>4.16.0</MoqPackageVersion>
|
||||
<MessagePackPackageVersion>2.5.108</MessagePackPackageVersion>
|
||||
<NewtonsoftJsonPackageVersion>13.0.3</NewtonsoftJsonPackageVersion>
|
||||
<NerdbankStreamsPackageVersion>2.9.116</NerdbankStreamsPackageVersion>
|
||||
<NuGetSolutionRestoreManagerInteropVersion>4.8.0</NuGetSolutionRestoreManagerInteropVersion>
|
||||
|
|
|
@ -5,23 +5,23 @@ using System.Collections.Immutable;
|
|||
using System.IO;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.ProjectSystem;
|
||||
using Microsoft.AspNetCore.Razor.Serialization;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Microbenchmarks;
|
||||
|
||||
internal static class CommonResources
|
||||
{
|
||||
public static readonly byte[] LegacyTagHelperBytes = Resources.GetResourceBytes("taghelpers.json");
|
||||
public static readonly ImmutableArray<TagHelperDescriptor> LegacyTagHelpers = LoadTagHelpers(LegacyTagHelperBytes);
|
||||
public static readonly byte[] LegacyTagHelperJsonBytes = Resources.GetResourceBytes("taghelpers.json");
|
||||
public static readonly ImmutableArray<TagHelperDescriptor> LegacyTagHelpers = LoadTagHelpers(LegacyTagHelperJsonBytes);
|
||||
|
||||
public static readonly byte[] LegacyProjectRazorJsonBytes = Resources.GetResourceBytes("project.razor.json");
|
||||
public static readonly ProjectRazorJson LegacyProjectRazorJson = LoadProjectRazorJson(LegacyProjectRazorJsonBytes);
|
||||
public static readonly byte[] LegacyProjectInfoJsonBytes = Resources.GetResourceBytes("project.razor.json");
|
||||
public static readonly RazorProjectInfo LegacyProjectInfo = LoadProjectInfo(LegacyProjectInfoJsonBytes);
|
||||
|
||||
public static readonly byte[] TelerikTagHelperBytes = Resources.GetResourceBytes("Kendo.Mvc.Examples.taghelpers.json", folder: "Telerik");
|
||||
public static readonly ImmutableArray<TagHelperDescriptor> TelerikTagHelpers = LoadTagHelpers(TelerikTagHelperBytes);
|
||||
public static readonly byte[] TelerikTagHelperJsonBytes = Resources.GetResourceBytes("Kendo.Mvc.Examples.taghelpers.json", folder: "Telerik");
|
||||
public static readonly ImmutableArray<TagHelperDescriptor> TelerikTagHelpers = LoadTagHelpers(TelerikTagHelperJsonBytes);
|
||||
|
||||
public static readonly byte[] TelerikProjectRazorJsonBytes = Resources.GetResourceBytes("Kendo.Mvc.Examples.project.razor.json", folder: "Telerik");
|
||||
public static readonly ProjectRazorJson TelerikProjectRazorJson = LoadProjectRazorJson(TelerikProjectRazorJsonBytes);
|
||||
public static readonly byte[] TelerikProjectInfoJsonBytes = Resources.GetResourceBytes("Kendo.Mvc.Examples.project.razor.json", folder: "Telerik");
|
||||
public static readonly RazorProjectInfo TelerikProjectInfo = LoadProjectInfo(TelerikProjectInfoJsonBytes);
|
||||
|
||||
private static ImmutableArray<TagHelperDescriptor> LoadTagHelpers(byte[] bytes)
|
||||
{
|
||||
|
@ -33,12 +33,12 @@ internal static class CommonResources
|
|||
static r => ObjectReaders.ReadTagHelper(r, useCache: false))).NullToEmpty();
|
||||
}
|
||||
|
||||
private static ProjectRazorJson LoadProjectRazorJson(byte[] bytes)
|
||||
private static RazorProjectInfo LoadProjectInfo(byte[] bytes)
|
||||
{
|
||||
using var stream = new MemoryStream(bytes);
|
||||
using var reader = new StreamReader(stream);
|
||||
|
||||
return JsonDataConvert.DeserializeData(reader,
|
||||
static r => r.ReadNonNullObject(ObjectReaders.ReadProjectRazorJsonFromProperties));
|
||||
static r => r.ReadNonNullObject(ObjectReaders.ReadRazorProjectInfoFromProperties));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ using System.IO;
|
|||
using System.Text;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Microsoft.AspNetCore.Razor.Serialization;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Converters;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
using Newtonsoft.Json;
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Microsoft.AspNetCore.Razor.ProjectSystem;
|
||||
using Microsoft.AspNetCore.Razor.Serialization;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Microbenchmarks.Serialization;
|
||||
|
||||
public class ProjectRazorJsonSerializationBenchmark
|
||||
{
|
||||
[ParamsAllValues]
|
||||
public ResourceSet ResourceSet { get; set; }
|
||||
|
||||
private ProjectRazorJson ProjectRazorJson
|
||||
=> ResourceSet switch
|
||||
{
|
||||
ResourceSet.Telerik => CommonResources.TelerikProjectRazorJson,
|
||||
_ => CommonResources.LegacyProjectRazorJson
|
||||
};
|
||||
|
||||
private byte[] ProjectRazorJsonBytes
|
||||
=> ResourceSet switch
|
||||
{
|
||||
ResourceSet.Telerik => CommonResources.TelerikProjectRazorJsonBytes,
|
||||
_ => CommonResources.LegacyProjectRazorJsonBytes
|
||||
};
|
||||
|
||||
private static ProjectRazorJson DeserializeProjectRazorJson(TextReader reader)
|
||||
{
|
||||
return JsonDataConvert.DeserializeData(reader,
|
||||
static r => r.ReadNonNullObject(ObjectReaders.ReadProjectRazorJsonFromProperties));
|
||||
}
|
||||
|
||||
private static void SerializeProjectRazorJson(TextWriter writer, ProjectRazorJson projectRazorJson)
|
||||
{
|
||||
JsonDataConvert.SerializeObject(writer, projectRazorJson, ObjectWriters.WriteProperties);
|
||||
}
|
||||
|
||||
[Benchmark(Description = "Serialize ProjectRazorJson")]
|
||||
public void Serialize()
|
||||
{
|
||||
using var stream = new MemoryStream();
|
||||
using var writer = new StreamWriter(stream, Encoding.UTF8, bufferSize: 4096);
|
||||
|
||||
SerializeProjectRazorJson(writer, ProjectRazorJson);
|
||||
}
|
||||
|
||||
[Benchmark(Description = "Deserialize ProjectRazorJson")]
|
||||
public void Deserialize()
|
||||
{
|
||||
using var stream = new MemoryStream(ProjectRazorJsonBytes);
|
||||
using var reader = new StreamReader(stream);
|
||||
|
||||
var projectRazorJson = DeserializeProjectRazorJson(reader);
|
||||
|
||||
if (projectRazorJson.ProjectWorkspaceState is null ||
|
||||
projectRazorJson.ProjectWorkspaceState.TagHelpers.Length != ProjectRazorJson.ProjectWorkspaceState?.TagHelpers.Length)
|
||||
{
|
||||
throw new InvalidDataException();
|
||||
}
|
||||
}
|
||||
|
||||
[Benchmark(Description = "RoundTrip ProjectRazorJson")]
|
||||
public void RoundTrip()
|
||||
{
|
||||
using var stream = new MemoryStream();
|
||||
using (var writer = new StreamWriter(stream, Encoding.UTF8, bufferSize: 4096, leaveOpen: true))
|
||||
{
|
||||
SerializeProjectRazorJson(writer, ProjectRazorJson);
|
||||
}
|
||||
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
using var reader = new StreamReader(stream);
|
||||
|
||||
var projectRazorJson = DeserializeProjectRazorJson(reader);
|
||||
|
||||
if (projectRazorJson.ProjectWorkspaceState is null ||
|
||||
projectRazorJson.ProjectWorkspaceState.TagHelpers.Length != ProjectRazorJson.ProjectWorkspaceState?.TagHelpers.Length)
|
||||
{
|
||||
throw new InvalidDataException();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,148 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using System.Buffers;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using MessagePack;
|
||||
using Microsoft.AspNetCore.Razor.ProjectSystem;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Microbenchmarks.Serialization;
|
||||
|
||||
public class RazorProjectInfoSerializationBenchmark
|
||||
{
|
||||
private ReadOnlyMemory<byte> _projectInfoMessagePackBytes;
|
||||
|
||||
[ParamsAllValues]
|
||||
public ResourceSet ResourceSet { get; set; }
|
||||
|
||||
private RazorProjectInfo ProjectInfo
|
||||
=> ResourceSet switch
|
||||
{
|
||||
ResourceSet.Telerik => CommonResources.TelerikProjectInfo,
|
||||
_ => CommonResources.LegacyProjectInfo
|
||||
};
|
||||
|
||||
private byte[] ProjectInfoJsonBytes
|
||||
=> ResourceSet switch
|
||||
{
|
||||
ResourceSet.Telerik => CommonResources.TelerikProjectInfoJsonBytes,
|
||||
_ => CommonResources.LegacyProjectInfoJsonBytes
|
||||
};
|
||||
|
||||
private static RazorProjectInfo DeserializeProjectInfo_Json(TextReader reader)
|
||||
{
|
||||
return JsonDataConvert.DeserializeData(reader,
|
||||
static r => r.ReadNonNullObject(ObjectReaders.ReadRazorProjectInfoFromProperties));
|
||||
}
|
||||
|
||||
private static void SerializeProjectInfo_Json(TextWriter writer, RazorProjectInfo projectInfo)
|
||||
{
|
||||
JsonDataConvert.SerializeObject(writer, projectInfo, ObjectWriters.WriteProperties);
|
||||
}
|
||||
|
||||
[Benchmark(Description = "Serialize RazorProjectInfo (JSON)")]
|
||||
public void Serialize_Json()
|
||||
{
|
||||
using var stream = new MemoryStream();
|
||||
using var writer = new StreamWriter(stream, Encoding.UTF8, bufferSize: 4096);
|
||||
|
||||
SerializeProjectInfo_Json(writer, ProjectInfo);
|
||||
}
|
||||
|
||||
[Benchmark(Description = "Deserialize RazorProjectInfo (JSON)")]
|
||||
public void Deserialize_Json()
|
||||
{
|
||||
using var stream = new MemoryStream(ProjectInfoJsonBytes);
|
||||
using var reader = new StreamReader(stream);
|
||||
|
||||
var projectInfo = DeserializeProjectInfo_Json(reader);
|
||||
|
||||
if (projectInfo.ProjectWorkspaceState is null ||
|
||||
projectInfo.ProjectWorkspaceState.TagHelpers.Length != ProjectInfo.ProjectWorkspaceState?.TagHelpers.Length)
|
||||
{
|
||||
throw new InvalidDataException();
|
||||
}
|
||||
}
|
||||
|
||||
[Benchmark(Description = "RoundTrip RazorProjectInfo (JSON)")]
|
||||
public void RoundTrip_Json()
|
||||
{
|
||||
using var stream = new MemoryStream();
|
||||
using (var writer = new StreamWriter(stream, Encoding.UTF8, bufferSize: 4096, leaveOpen: true))
|
||||
{
|
||||
SerializeProjectInfo_Json(writer, ProjectInfo);
|
||||
}
|
||||
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
using var reader = new StreamReader(stream);
|
||||
|
||||
var projectInfo = DeserializeProjectInfo_Json(reader);
|
||||
|
||||
if (projectInfo.ProjectWorkspaceState is null ||
|
||||
projectInfo.ProjectWorkspaceState.TagHelpers.Length != ProjectInfo.ProjectWorkspaceState?.TagHelpers.Length)
|
||||
{
|
||||
throw new InvalidDataException();
|
||||
}
|
||||
}
|
||||
|
||||
[GlobalSetup(Targets = new[] { nameof(Serialize_MessagePack), nameof(Deserialize_MessagePack), nameof(RoundTrip_MessagePack) })]
|
||||
public void GlobalSetup_MessagePack()
|
||||
{
|
||||
_projectInfoMessagePackBytes = SerializeProjectInfo_MessagePack(ProjectInfo);
|
||||
}
|
||||
|
||||
private static RazorProjectInfo DeserializeProjectInfo_MessagePack(ReadOnlyMemory<byte> bytes)
|
||||
{
|
||||
var reader = new MessagePackReader(bytes);
|
||||
|
||||
return RazorProjectInfoFormatter.Instance.Deserialize(ref reader, MessagePackSerializerOptions.Standard);
|
||||
}
|
||||
|
||||
private static ReadOnlyMemory<byte> SerializeProjectInfo_MessagePack(RazorProjectInfo projectInfo)
|
||||
{
|
||||
var buffer = new ArrayBufferWriter<byte>();
|
||||
var writer = new MessagePackWriter(buffer);
|
||||
|
||||
RazorProjectInfoFormatter.Instance.Serialize(ref writer, projectInfo, MessagePackSerializerOptions.Standard);
|
||||
writer.Flush();
|
||||
|
||||
return buffer.WrittenMemory;
|
||||
}
|
||||
|
||||
[Benchmark(Description = "Serialize ProjectRazorJson (MessagePack)")]
|
||||
public void Serialize_MessagePack()
|
||||
{
|
||||
SerializeProjectInfo_MessagePack(ProjectInfo);
|
||||
}
|
||||
|
||||
[Benchmark(Description = "Deserialize ProjectRazorJson (MessagePack)")]
|
||||
public void Deserialize_MessagePack()
|
||||
{
|
||||
var projectInfo = DeserializeProjectInfo_MessagePack(_projectInfoMessagePackBytes);
|
||||
|
||||
if (projectInfo.ProjectWorkspaceState is null ||
|
||||
projectInfo.ProjectWorkspaceState.TagHelpers.Length != ProjectInfo.ProjectWorkspaceState?.TagHelpers.Length)
|
||||
{
|
||||
throw new InvalidDataException();
|
||||
}
|
||||
}
|
||||
|
||||
[Benchmark(Description = "RoundTrip ProjectRazorJson (MessagePack)")]
|
||||
public void RoundTrip_MessagePack()
|
||||
{
|
||||
var bytes = SerializeProjectInfo_MessagePack(ProjectInfo);
|
||||
var projectInfo = DeserializeProjectInfo_MessagePack(bytes);
|
||||
|
||||
if (projectInfo.ProjectWorkspaceState is null ||
|
||||
projectInfo.ProjectWorkspaceState.TagHelpers.Length != ProjectInfo.ProjectWorkspaceState?.TagHelpers.Length)
|
||||
{
|
||||
throw new InvalidDataException();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,50 +2,58 @@
|
|||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Buffers;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using MessagePack;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Serialization;
|
||||
using Microsoft.AspNetCore.Razor.PooledObjects;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Microbenchmarks.Serialization;
|
||||
|
||||
public class TagHelperSerializationBenchmark
|
||||
{
|
||||
[AllowNull]
|
||||
private ArrayBufferWriter<byte> _buffer;
|
||||
private ReadOnlyMemory<byte> _tagHelperMessagePackBytes;
|
||||
|
||||
[ParamsAllValues]
|
||||
public ResourceSet ResourceSet { get; set; }
|
||||
|
||||
private IReadOnlyList<TagHelperDescriptor> TagHelpers
|
||||
private ImmutableArray<TagHelperDescriptor> TagHelpers
|
||||
=> ResourceSet switch
|
||||
{
|
||||
ResourceSet.Telerik => CommonResources.TelerikTagHelpers,
|
||||
_ => CommonResources.LegacyTagHelpers
|
||||
};
|
||||
|
||||
private byte[] TagHelperBytes
|
||||
private byte[] TagHelperJsonBytes
|
||||
=> ResourceSet switch
|
||||
{
|
||||
ResourceSet.Telerik => CommonResources.TelerikTagHelperBytes,
|
||||
_ => CommonResources.LegacyTagHelperBytes
|
||||
ResourceSet.Telerik => CommonResources.TelerikTagHelperJsonBytes,
|
||||
_ => CommonResources.LegacyTagHelperJsonBytes
|
||||
};
|
||||
|
||||
private static IReadOnlyList<TagHelperDescriptor> DeserializeTagHelpers(TextReader reader)
|
||||
private static ImmutableArray<TagHelperDescriptor> DeserializeTagHelpers_Json(TextReader reader)
|
||||
{
|
||||
return JsonDataConvert.DeserializeData(reader,
|
||||
static r => r.ReadArray(
|
||||
static r => ObjectReaders.ReadTagHelper(r, useCache: false)))
|
||||
?? Array.Empty<TagHelperDescriptor>();
|
||||
static r => r.ReadImmutableArray(
|
||||
static r => ObjectReaders.ReadTagHelper(r, useCache: false)));
|
||||
}
|
||||
|
||||
private static void SerializeTagHelpers(TextWriter writer, IReadOnlyList<TagHelperDescriptor> tagHelpers)
|
||||
private static void SerializeTagHelpers(TextWriter writer, ImmutableArray<TagHelperDescriptor> tagHelpers)
|
||||
{
|
||||
JsonDataConvert.SerializeData(writer,
|
||||
w => w.WriteArray(tagHelpers, ObjectWriters.Write));
|
||||
}
|
||||
|
||||
[Benchmark(Description = "Serialize Tag Helpers")]
|
||||
public void Serialize()
|
||||
[Benchmark(Description = "Serialize Tag Helpers (JSON)")]
|
||||
public void Serialize_Json()
|
||||
{
|
||||
using var stream = new MemoryStream();
|
||||
using var writer = new StreamWriter(stream, Encoding.UTF8, bufferSize: 4096);
|
||||
|
@ -53,22 +61,22 @@ public class TagHelperSerializationBenchmark
|
|||
SerializeTagHelpers(writer, TagHelpers);
|
||||
}
|
||||
|
||||
[Benchmark(Description = "Deserialize Tag Helpers")]
|
||||
public void Deserialize()
|
||||
[Benchmark(Description = "Deserialize Tag Helpers (JSON)")]
|
||||
public void Deserialize_Json()
|
||||
{
|
||||
using var stream = new MemoryStream(TagHelperBytes);
|
||||
using var stream = new MemoryStream(TagHelperJsonBytes);
|
||||
using var reader = new StreamReader(stream);
|
||||
|
||||
var tagHelpers = DeserializeTagHelpers(reader);
|
||||
var tagHelpers = DeserializeTagHelpers_Json(reader);
|
||||
|
||||
if (tagHelpers.Count != TagHelpers.Count)
|
||||
if (tagHelpers.Length != TagHelpers.Length)
|
||||
{
|
||||
throw new InvalidDataException();
|
||||
}
|
||||
}
|
||||
|
||||
[Benchmark(Description = "RoundTrip Tag Helpers")]
|
||||
public void RoundTrip()
|
||||
[Benchmark(Description = "RoundTrip Tag Helpers (JSON)")]
|
||||
public void RoundTrip_Json()
|
||||
{
|
||||
using var stream = new MemoryStream();
|
||||
using (var writer = new StreamWriter(stream, Encoding.UTF8, bufferSize: 4096, leaveOpen: true))
|
||||
|
@ -80,20 +88,70 @@ public class TagHelperSerializationBenchmark
|
|||
|
||||
using var reader = new StreamReader(stream);
|
||||
|
||||
var tagHelpers = DeserializeTagHelpers(reader);
|
||||
var tagHelpers = DeserializeTagHelpers_Json(reader);
|
||||
|
||||
if (tagHelpers.Count != TagHelpers.Count)
|
||||
if (tagHelpers.Length != TagHelpers.Length)
|
||||
{
|
||||
throw new InvalidDataException();
|
||||
}
|
||||
}
|
||||
|
||||
[Benchmark(Description = "TagHelperDescriptor.GetHashCode()")]
|
||||
public void TagHelperDescriptor_GetHashCode()
|
||||
[GlobalSetup(Targets = new[] { nameof(Serialize_MessagePack), nameof(Deserialize_MessagePack), nameof(RoundTrip_MessagePack) })]
|
||||
public void GlobalSetup_MessagePack()
|
||||
{
|
||||
foreach (var tagHelper in TagHelpers)
|
||||
_buffer = new ArrayBufferWriter<byte>(initialCapacity: 1024 * 1024);
|
||||
_tagHelperMessagePackBytes = SerializeTagHelpers_MessagePack(TagHelpers);
|
||||
}
|
||||
|
||||
private static ImmutableArray<TagHelperDescriptor> DeserializeTagHelpers_MessagePack(ReadOnlyMemory<byte> bytes)
|
||||
{
|
||||
var reader = new MessagePackReader(bytes);
|
||||
|
||||
using var _ = TagHelperSerializationCache.Pool.GetPooledObject(out var cache);
|
||||
return TagHelperFormatter.Instance.DeserializeImmutableArray(ref reader, MessagePackSerializerOptions.Standard, cache);
|
||||
}
|
||||
|
||||
private ReadOnlyMemory<byte> SerializeTagHelpers_MessagePack(ImmutableArray<TagHelperDescriptor> tagHelpers)
|
||||
{
|
||||
var writer = new MessagePackWriter(_buffer);
|
||||
|
||||
using var _ = TagHelperSerializationCache.Pool.GetPooledObject(out var cache);
|
||||
|
||||
TagHelperFormatter.Instance.SerializeArray(ref writer, tagHelpers, MessagePackSerializerOptions.Standard, cache);
|
||||
writer.Flush();
|
||||
|
||||
return _buffer.WrittenMemory;
|
||||
}
|
||||
|
||||
[Benchmark(Description = "Serialize Tag Helpers (MessagePack)")]
|
||||
public void Serialize_MessagePack()
|
||||
{
|
||||
SerializeTagHelpers_MessagePack(TagHelpers);
|
||||
_buffer.Clear();
|
||||
}
|
||||
|
||||
[Benchmark(Description = "Deserialize Tag Helpers (MessagePack)")]
|
||||
public void Deserialize_MessagePack()
|
||||
{
|
||||
var tagHelpers = DeserializeTagHelpers_MessagePack(_tagHelperMessagePackBytes);
|
||||
|
||||
if (tagHelpers.Length != TagHelpers.Length)
|
||||
{
|
||||
_ = tagHelper.GetHashCode();
|
||||
throw new InvalidDataException();
|
||||
}
|
||||
}
|
||||
|
||||
[Benchmark(Description = "RoundTrip Tag Helpers (MessagePack)")]
|
||||
public void RoundTrip_MessagePack()
|
||||
{
|
||||
var bytes = SerializeTagHelpers_MessagePack(TagHelpers);
|
||||
var tagHelpers = DeserializeTagHelpers_MessagePack(bytes);
|
||||
|
||||
if (tagHelpers.Length != TagHelpers.Length)
|
||||
{
|
||||
throw new InvalidDataException();
|
||||
}
|
||||
|
||||
_buffer.Clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#nullable enable
|
||||
Microsoft.AspNetCore.Razor.ExternalAccess.RoslynWorkspace.RazorWorkspaceListener
|
||||
Microsoft.AspNetCore.Razor.ExternalAccess.RoslynWorkspace.RazorWorkspaceListener.Dispose() -> void
|
||||
Microsoft.AspNetCore.Razor.ExternalAccess.RoslynWorkspace.RazorWorkspaceListener.EnsureInitialized(Microsoft.CodeAnalysis.Workspace! workspace, string! projectRazorJsonFileName) -> void
|
||||
Microsoft.AspNetCore.Razor.ExternalAccess.RoslynWorkspace.RazorWorkspaceListener.EnsureInitialized(Microsoft.CodeAnalysis.Workspace! workspace, string! projectInfoFileName) -> void
|
||||
Microsoft.AspNetCore.Razor.ExternalAccess.RoslynWorkspace.RazorWorkspaceListener.NotifyDynamicFile(Microsoft.CodeAnalysis.ProjectId! projectId) -> void
|
||||
Microsoft.AspNetCore.Razor.ExternalAccess.RoslynWorkspace.RazorWorkspaceListener.RazorWorkspaceListener(Microsoft.Extensions.Logging.ILoggerFactory! loggerFactory) -> void
|
||||
virtual Microsoft.AspNetCore.Razor.ExternalAccess.RoslynWorkspace.RazorWorkspaceListener.SerializeProjectAsync(Microsoft.CodeAnalysis.ProjectId! projectId, System.Threading.CancellationToken ct) -> System.Threading.Tasks.Task!
|
|
@ -9,7 +9,7 @@ using Microsoft.AspNetCore.Razor.PooledObjects;
|
|||
using Microsoft.AspNetCore.Razor.ProjectEngineHost;
|
||||
using Microsoft.AspNetCore.Razor.ProjectSystem;
|
||||
using Microsoft.AspNetCore.Razor.Serialization;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Converters;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
using Microsoft.AspNetCore.Razor.Telemetry;
|
||||
using Microsoft.AspNetCore.Razor.Utilities;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
@ -20,14 +20,14 @@ using Newtonsoft.Json;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.ExternalAccess.RoslynWorkspace;
|
||||
|
||||
internal static class RazorProjectJsonSerializer
|
||||
internal static class RazorProjectInfoSerializer
|
||||
{
|
||||
private static readonly JsonSerializer s_serializer;
|
||||
private static readonly EmptyProjectEngineFactory s_fallbackProjectEngineFactory;
|
||||
private static readonly StringComparison s_stringComparison;
|
||||
private static readonly (IProjectEngineFactory Value, ICustomProjectEngineFactoryMetadata)[] s_projectEngineFactories;
|
||||
|
||||
static RazorProjectJsonSerializer()
|
||||
static RazorProjectInfoSerializer()
|
||||
{
|
||||
s_serializer = new JsonSerializer()
|
||||
{
|
||||
|
@ -99,7 +99,7 @@ internal static class RazorProjectJsonSerializer
|
|||
|
||||
var jsonFilePath = Path.Combine(intermediateOutputPath, projectRazorJsonFileName);
|
||||
|
||||
var projectRazorJson = new ProjectRazorJson(
|
||||
var projectInfo = new RazorProjectInfo(
|
||||
serializedFilePath: jsonFilePath,
|
||||
filePath: project.FilePath!,
|
||||
configuration: configuration,
|
||||
|
@ -107,7 +107,7 @@ internal static class RazorProjectJsonSerializer
|
|||
projectWorkspaceState: projectWorkspaceState,
|
||||
documents: documents);
|
||||
|
||||
WriteJsonFile(jsonFilePath, projectRazorJson);
|
||||
WriteJsonFile(jsonFilePath, projectInfo);
|
||||
}
|
||||
|
||||
private static RazorConfiguration ComputeRazorConfigurationOptions(AnalyzerConfigOptionsProvider options, out string defaultNamespace)
|
||||
|
@ -135,7 +135,7 @@ internal static class RazorProjectJsonSerializer
|
|||
return razorConfiguration;
|
||||
}
|
||||
|
||||
private static void WriteJsonFile(string publishFilePath, ProjectRazorJson projectRazorJson)
|
||||
private static void WriteJsonFile(string publishFilePath, RazorProjectInfo projectInfo)
|
||||
{
|
||||
// We need to avoid having an incomplete file at any point, but our
|
||||
// project configuration is large enough that it will be written as multiple operations.
|
||||
|
@ -152,7 +152,7 @@ internal static class RazorProjectJsonSerializer
|
|||
// by the time we move the temp file into its place
|
||||
using (var writer = tempFileInfo.CreateText())
|
||||
{
|
||||
s_serializer.Serialize(writer, projectRazorJson);
|
||||
s_serializer.Serialize(writer, projectInfo);
|
||||
}
|
||||
|
||||
var fileInfo = new FileInfo(publishFilePath);
|
|
@ -13,7 +13,7 @@ public class RazorWorkspaceListener : IDisposable
|
|||
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private string? _projectRazorJsonFileName;
|
||||
private string? _projectInfoFileName;
|
||||
private Workspace? _workspace;
|
||||
private ImmutableDictionary<ProjectId, TaskDelayScheduler> _workQueues = ImmutableDictionary<ProjectId, TaskDelayScheduler>.Empty;
|
||||
|
||||
|
@ -22,15 +22,15 @@ public class RazorWorkspaceListener : IDisposable
|
|||
_logger = loggerFactory.CreateLogger(nameof(RazorWorkspaceListener));
|
||||
}
|
||||
|
||||
public void EnsureInitialized(Workspace workspace, string projectRazorJsonFileName)
|
||||
public void EnsureInitialized(Workspace workspace, string projectInfoFileName)
|
||||
{
|
||||
// Make sure we don't hook up the event handler multiple times
|
||||
if (_projectRazorJsonFileName is not null)
|
||||
if (_projectInfoFileName is not null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_projectRazorJsonFileName = projectRazorJsonFileName;
|
||||
_projectInfoFileName = projectInfoFileName;
|
||||
_workspace = workspace;
|
||||
_workspace.WorkspaceChanged += Workspace_WorkspaceChanged;
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ public class RazorWorkspaceListener : IDisposable
|
|||
|
||||
private void EnqueueUpdate(Project? project)
|
||||
{
|
||||
if (_projectRazorJsonFileName is null ||
|
||||
if (_projectInfoFileName is null ||
|
||||
project is not
|
||||
{
|
||||
Language: LanguageNames.CSharp
|
||||
|
@ -161,7 +161,7 @@ public class RazorWorkspaceListener : IDisposable
|
|||
// Protected for testing
|
||||
protected virtual Task SerializeProjectAsync(ProjectId projectId, CancellationToken ct)
|
||||
{
|
||||
if (_projectRazorJsonFileName is null || _workspace is null)
|
||||
if (_projectInfoFileName is null || _workspace is null)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ public class RazorWorkspaceListener : IDisposable
|
|||
}
|
||||
|
||||
_logger.LogTrace("{projectId} writing json file", projectId);
|
||||
return RazorProjectJsonSerializer.SerializeAsync(project, _projectRazorJsonFileName, ct);
|
||||
return RazorProjectInfoSerializer.SerializeAsync(project, _projectInfoFileName, ct);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer;
|
|||
internal class ProjectConfigurationFileChangeEventArgs
|
||||
{
|
||||
private readonly JsonFileDeserializer _jsonFileDeserializer;
|
||||
private ProjectRazorJson? _projectRazorJson;
|
||||
private RazorProjectInfo? _projectInfo;
|
||||
private readonly object _projectSnapshotHandleLock;
|
||||
private bool _deserialized;
|
||||
|
||||
|
@ -50,12 +50,12 @@ internal class ProjectConfigurationFileChangeEventArgs
|
|||
|
||||
public RazorFileChangeKind Kind { get; }
|
||||
|
||||
public bool TryDeserialize([NotNullWhen(true)] out ProjectRazorJson? projectRazorJson)
|
||||
public bool TryDeserialize([NotNullWhen(true)] out RazorProjectInfo? projectInfo)
|
||||
{
|
||||
if (Kind == RazorFileChangeKind.Removed)
|
||||
{
|
||||
// There's no file to represent the snapshot handle.
|
||||
projectRazorJson = null;
|
||||
projectInfo = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -66,31 +66,31 @@ internal class ProjectConfigurationFileChangeEventArgs
|
|||
// We use a deserialized flag instead of checking if _projectSnapshotHandle is null because if we're reading an old snapshot
|
||||
// handle that doesn't deserialize properly it could be expected that it would be null.
|
||||
_deserialized = true;
|
||||
var deserializedProjectRazorJson = _jsonFileDeserializer.Deserialize<ProjectRazorJson>(ConfigurationFilePath);
|
||||
if (deserializedProjectRazorJson is null)
|
||||
var deserializedProjectInfo = _jsonFileDeserializer.Deserialize<RazorProjectInfo>(ConfigurationFilePath);
|
||||
if (deserializedProjectInfo is null)
|
||||
{
|
||||
projectRazorJson = null;
|
||||
projectInfo = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
var normalizedSerializedFilePath = FilePathNormalizer.Normalize(deserializedProjectRazorJson.SerializedFilePath);
|
||||
var normalizedSerializedFilePath = FilePathNormalizer.Normalize(deserializedProjectInfo.SerializedFilePath);
|
||||
var normalizedDetectedFilePath = FilePathNormalizer.Normalize(ConfigurationFilePath);
|
||||
if (string.Equals(normalizedSerializedFilePath, normalizedDetectedFilePath, FilePathComparison.Instance))
|
||||
{
|
||||
_projectRazorJson = deserializedProjectRazorJson;
|
||||
_projectInfo = deserializedProjectInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Stale project configuration file, most likely a user copy & pasted the project configuration file and it hasn't
|
||||
// been re-computed yet. Fail deserialization.
|
||||
projectRazorJson = null;
|
||||
projectInfo = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
projectRazorJson = _projectRazorJson;
|
||||
if (projectRazorJson is null)
|
||||
projectInfo = _projectInfo;
|
||||
if (projectInfo is null)
|
||||
{
|
||||
// Deserialization failed
|
||||
return false;
|
||||
|
|
|
@ -52,7 +52,7 @@ internal class ProjectConfigurationStateSynchronizer : IProjectConfigurationFile
|
|||
case RazorFileChangeKind.Changed:
|
||||
{
|
||||
var configurationFilePath = FilePathNormalizer.Normalize(args.ConfigurationFilePath);
|
||||
if (!args.TryDeserialize(out var projectRazorJson))
|
||||
if (!args.TryDeserialize(out var projectInfo))
|
||||
{
|
||||
if (!_configurationToProjectMap.TryGetValue(configurationFilePath, out var lastAssociatedProjectKey))
|
||||
{
|
||||
|
@ -68,7 +68,7 @@ internal class ProjectConfigurationStateSynchronizer : IProjectConfigurationFile
|
|||
// We found the last associated project file for the configuration file. Reset the project since we can't
|
||||
// accurately determine its configurations.
|
||||
|
||||
EnqueueUpdateProject(lastAssociatedProjectKey, projectRazorJson: null);
|
||||
EnqueueUpdateProject(lastAssociatedProjectKey, projectInfo: null);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -76,19 +76,19 @@ internal class ProjectConfigurationStateSynchronizer : IProjectConfigurationFile
|
|||
{
|
||||
_logger.LogWarning("Found no project key for configuration file. Assuming new project. Configuration file path: '{0}'", configurationFilePath);
|
||||
|
||||
AddProject(configurationFilePath, projectRazorJson);
|
||||
AddProject(configurationFilePath, projectInfo);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Project configuration file changed for project '{0}': '{1}'", associatedProjectKey.Id, configurationFilePath);
|
||||
|
||||
EnqueueUpdateProject(associatedProjectKey, projectRazorJson);
|
||||
EnqueueUpdateProject(associatedProjectKey, projectInfo);
|
||||
break;
|
||||
}
|
||||
case RazorFileChangeKind.Added:
|
||||
{
|
||||
var configurationFilePath = FilePathNormalizer.Normalize(args.ConfigurationFilePath);
|
||||
if (!args.TryDeserialize(out var projectRazorJson))
|
||||
if (!args.TryDeserialize(out var projectInfo))
|
||||
{
|
||||
// Given that this is the first time we're seeing this configuration file if we can't deserialize it
|
||||
// then we have to noop.
|
||||
|
@ -96,7 +96,7 @@ internal class ProjectConfigurationStateSynchronizer : IProjectConfigurationFile
|
|||
return;
|
||||
}
|
||||
|
||||
AddProject(configurationFilePath, projectRazorJson);
|
||||
AddProject(configurationFilePath, projectInfo);
|
||||
break;
|
||||
}
|
||||
case RazorFileChangeKind.Removed:
|
||||
|
@ -113,38 +113,38 @@ internal class ProjectConfigurationStateSynchronizer : IProjectConfigurationFile
|
|||
|
||||
_logger.LogInformation("Project configuration file removed for project '{0}': '{1}'", projectFilePath, configurationFilePath);
|
||||
|
||||
EnqueueUpdateProject(projectFilePath, projectRazorJson: null);
|
||||
EnqueueUpdateProject(projectFilePath, projectInfo: null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void AddProject(string configurationFilePath, ProjectRazorJson projectRazorJson)
|
||||
void AddProject(string configurationFilePath, RazorProjectInfo projectInfo)
|
||||
{
|
||||
var projectFilePath = FilePathNormalizer.Normalize(projectRazorJson.FilePath);
|
||||
var projectFilePath = FilePathNormalizer.Normalize(projectInfo.FilePath);
|
||||
var intermediateOutputPath = Path.GetDirectoryName(configurationFilePath).AssumeNotNull();
|
||||
var rootNamespace = projectRazorJson.RootNamespace;
|
||||
var rootNamespace = projectInfo.RootNamespace;
|
||||
|
||||
var projectKey = _projectService.AddProject(projectFilePath, intermediateOutputPath, projectRazorJson.Configuration, rootNamespace);
|
||||
var projectKey = _projectService.AddProject(projectFilePath, intermediateOutputPath, projectInfo.Configuration, rootNamespace);
|
||||
_configurationToProjectMap[configurationFilePath] = projectKey;
|
||||
|
||||
_logger.LogInformation("Project configuration file added for project '{0}': '{1}'", projectFilePath, configurationFilePath);
|
||||
EnqueueUpdateProject(projectKey, projectRazorJson);
|
||||
EnqueueUpdateProject(projectKey, projectInfo);
|
||||
}
|
||||
|
||||
void UpdateProject(ProjectKey projectKey, ProjectRazorJson? projectRazorJson)
|
||||
void UpdateProject(ProjectKey projectKey, RazorProjectInfo? projectInfo)
|
||||
{
|
||||
if (projectRazorJson is null)
|
||||
if (projectInfo is null)
|
||||
{
|
||||
ResetProject(projectKey);
|
||||
return;
|
||||
}
|
||||
|
||||
var projectWorkspaceState = projectRazorJson.ProjectWorkspaceState ?? ProjectWorkspaceState.Default;
|
||||
var documents = projectRazorJson.Documents;
|
||||
var projectWorkspaceState = projectInfo.ProjectWorkspaceState ?? ProjectWorkspaceState.Default;
|
||||
var documents = projectInfo.Documents;
|
||||
_projectService.UpdateProject(
|
||||
projectKey,
|
||||
projectRazorJson.Configuration,
|
||||
projectRazorJson.RootNamespace,
|
||||
projectInfo.Configuration,
|
||||
projectInfo.RootNamespace,
|
||||
projectWorkspaceState,
|
||||
documents);
|
||||
}
|
||||
|
@ -154,10 +154,10 @@ internal class ProjectConfigurationStateSynchronizer : IProjectConfigurationFile
|
|||
await Task.Delay(EnqueueDelay).ConfigureAwait(true);
|
||||
|
||||
var delayedProjectInfo = ProjectInfoMap[projectKey];
|
||||
UpdateProject(projectKey, delayedProjectInfo.ProjectRazorJson);
|
||||
UpdateProject(projectKey, delayedProjectInfo.ProjectInfo);
|
||||
}
|
||||
|
||||
void EnqueueUpdateProject(ProjectKey projectKey, ProjectRazorJson? projectRazorJson)
|
||||
void EnqueueUpdateProject(ProjectKey projectKey, RazorProjectInfo? projectInfo)
|
||||
{
|
||||
if (!ProjectInfoMap.ContainsKey(projectKey))
|
||||
{
|
||||
|
@ -165,7 +165,7 @@ internal class ProjectConfigurationStateSynchronizer : IProjectConfigurationFile
|
|||
}
|
||||
|
||||
var delayedProjectInfo = ProjectInfoMap[projectKey];
|
||||
delayedProjectInfo.ProjectRazorJson = projectRazorJson;
|
||||
delayedProjectInfo.ProjectInfo = projectInfo;
|
||||
|
||||
if (delayedProjectInfo.ProjectUpdateTask is null || delayedProjectInfo.ProjectUpdateTask.IsCompleted)
|
||||
{
|
||||
|
@ -188,6 +188,6 @@ internal class ProjectConfigurationStateSynchronizer : IProjectConfigurationFile
|
|||
{
|
||||
public Task? ProjectUpdateTask { get; set; }
|
||||
|
||||
public ProjectRazorJson? ProjectRazorJson { get; set; }
|
||||
public RazorProjectInfo? ProjectInfo { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ using System;
|
|||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Converters;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
using Microsoft.AspNetCore.Razor.Telemetry;
|
||||
using Microsoft.CodeAnalysis.Razor;
|
||||
using Microsoft.CodeAnalysis.Razor.Workspaces;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using System.IO;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Converters;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.LanguageServer.Serialization;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Razor.LanguageServer.Serialization;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Converters;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
using Microsoft.VisualStudio.LanguageServer.Protocol;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="$(MicrosoftCodeAnalysisWorkspacesCommonPackageVersion)" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
|
||||
<PackageReference Include="MessagePack" Version="$(MessagePackPackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -7,14 +7,8 @@ using Microsoft.AspNetCore.Razor.Serialization;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.ProjectSystem;
|
||||
|
||||
internal sealed class ProjectRazorJson
|
||||
internal sealed class RazorProjectInfo
|
||||
{
|
||||
// This version number must be incremented if the serialization format for ProjectRazorJson
|
||||
// or any of the types that compose it changes. This includes: RazorConfiguration,
|
||||
// ProjectWorkspaceState, TagHelperDescriptor, and DocumentSnapshotHandle.
|
||||
// NOTE: If this version is changed, a coordinated insertion is required between Roslyn and Razor for the C# extension.
|
||||
public const int Version = 2;
|
||||
|
||||
public string SerializedFilePath { get; }
|
||||
public string FilePath { get; }
|
||||
public RazorConfiguration? Configuration { get; }
|
||||
|
@ -22,7 +16,7 @@ internal sealed class ProjectRazorJson
|
|||
public ProjectWorkspaceState? ProjectWorkspaceState { get; }
|
||||
public ImmutableArray<DocumentSnapshotHandle> Documents { get; }
|
||||
|
||||
public ProjectRazorJson(
|
||||
public RazorProjectInfo(
|
||||
string serializedFilePath,
|
||||
string filePath,
|
||||
RazorConfiguration? configuration,
|
|
@ -135,7 +135,13 @@
|
|||
<data name="Expected_JSON_token_0_but_it_was_1" xml:space="preserve">
|
||||
<value>Expected JSON token '{0}', but it was '{1}'.</value>
|
||||
</data>
|
||||
<data name="Unsupported_project_razor_json_version_encountered" xml:space="preserve">
|
||||
<value>Unsupported project.razor.json version encounted.</value>
|
||||
<data name="Unsupported_argument_kind" xml:space="preserve">
|
||||
<value>Unsupported argument kind: '{0}'.</value>
|
||||
</data>
|
||||
<data name="Unsupported_argument_type" xml:space="preserve">
|
||||
<value>Unsupported argument type: '{0}'.</value>
|
||||
</data>
|
||||
<data name="Unsupported_razor_project_info_version_encountered" xml:space="preserve">
|
||||
<value>Unsupported razor project info version encounted.</value>
|
||||
</data>
|
||||
</root>
|
|
@ -32,9 +32,19 @@
|
|||
<target state="translated">V řetězci JSON se očekával token {0}, ale byl {1}.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_project_razor_json_version_encountered">
|
||||
<source>Unsupported project.razor.json version encounted.</source>
|
||||
<target state="translated">Byla zjištěna nepodporovaná verze project.razor.json.</target>
|
||||
<trans-unit id="Unsupported_argument_kind">
|
||||
<source>Unsupported argument kind: '{0}'.</source>
|
||||
<target state="new">Unsupported argument kind: '{0}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_argument_type">
|
||||
<source>Unsupported argument type: '{0}'.</source>
|
||||
<target state="new">Unsupported argument type: '{0}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_razor_project_info_version_encountered">
|
||||
<source>Unsupported razor project info version encounted.</source>
|
||||
<target state="new">Unsupported razor project info version encounted.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
|
|
|
@ -32,9 +32,19 @@
|
|||
<target state="translated">Erwartet wurde das JSON-Token '{0}', es lautete jedoch '{1}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_project_razor_json_version_encountered">
|
||||
<source>Unsupported project.razor.json version encounted.</source>
|
||||
<target state="translated">Nicht unterstützte Version von "project.razor.json" festgestellt.</target>
|
||||
<trans-unit id="Unsupported_argument_kind">
|
||||
<source>Unsupported argument kind: '{0}'.</source>
|
||||
<target state="new">Unsupported argument kind: '{0}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_argument_type">
|
||||
<source>Unsupported argument type: '{0}'.</source>
|
||||
<target state="new">Unsupported argument type: '{0}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_razor_project_info_version_encountered">
|
||||
<source>Unsupported razor project info version encounted.</source>
|
||||
<target state="new">Unsupported razor project info version encounted.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
|
|
|
@ -32,9 +32,19 @@
|
|||
<target state="translated">Se esperaba un token JSON ''{0}'', pero era {1}.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_project_razor_json_version_encountered">
|
||||
<source>Unsupported project.razor.json version encounted.</source>
|
||||
<target state="translated">Se encontró una versión de project.razor.json no admitida.</target>
|
||||
<trans-unit id="Unsupported_argument_kind">
|
||||
<source>Unsupported argument kind: '{0}'.</source>
|
||||
<target state="new">Unsupported argument kind: '{0}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_argument_type">
|
||||
<source>Unsupported argument type: '{0}'.</source>
|
||||
<target state="new">Unsupported argument type: '{0}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_razor_project_info_version_encountered">
|
||||
<source>Unsupported razor project info version encounted.</source>
|
||||
<target state="new">Unsupported razor project info version encounted.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
|
|
|
@ -32,9 +32,19 @@
|
|||
<target state="translated">Jeton JSON {0} attendu, mais il a été {1}.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_project_razor_json_version_encountered">
|
||||
<source>Unsupported project.razor.json version encounted.</source>
|
||||
<target state="translated">Version de project.razor.json non prise en charge.</target>
|
||||
<trans-unit id="Unsupported_argument_kind">
|
||||
<source>Unsupported argument kind: '{0}'.</source>
|
||||
<target state="new">Unsupported argument kind: '{0}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_argument_type">
|
||||
<source>Unsupported argument type: '{0}'.</source>
|
||||
<target state="new">Unsupported argument type: '{0}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_razor_project_info_version_encountered">
|
||||
<source>Unsupported razor project info version encounted.</source>
|
||||
<target state="new">Unsupported razor project info version encounted.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
|
|
|
@ -32,9 +32,19 @@
|
|||
<target state="translated">Previsto token JSON '{0}', ma era '{1}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_project_razor_json_version_encountered">
|
||||
<source>Unsupported project.razor.json version encounted.</source>
|
||||
<target state="translated">Incontrata versione project.razor.json non supportata.</target>
|
||||
<trans-unit id="Unsupported_argument_kind">
|
||||
<source>Unsupported argument kind: '{0}'.</source>
|
||||
<target state="new">Unsupported argument kind: '{0}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_argument_type">
|
||||
<source>Unsupported argument type: '{0}'.</source>
|
||||
<target state="new">Unsupported argument type: '{0}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_razor_project_info_version_encountered">
|
||||
<source>Unsupported razor project info version encounted.</source>
|
||||
<target state="new">Unsupported razor project info version encounted.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
|
|
|
@ -32,9 +32,19 @@
|
|||
<target state="translated">JSON トークン '{0}' が必要ですが、'{1}' でした。</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_project_razor_json_version_encountered">
|
||||
<source>Unsupported project.razor.json version encounted.</source>
|
||||
<target state="translated">サポートされていない project.razor.json バージョンが検出されました。</target>
|
||||
<trans-unit id="Unsupported_argument_kind">
|
||||
<source>Unsupported argument kind: '{0}'.</source>
|
||||
<target state="new">Unsupported argument kind: '{0}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_argument_type">
|
||||
<source>Unsupported argument type: '{0}'.</source>
|
||||
<target state="new">Unsupported argument type: '{0}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_razor_project_info_version_encountered">
|
||||
<source>Unsupported razor project info version encounted.</source>
|
||||
<target state="new">Unsupported razor project info version encounted.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
|
|
|
@ -32,9 +32,19 @@
|
|||
<target state="translated">JSON 토큰 '{0}'이(가) 필요하지만 '{1}'입니다.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_project_razor_json_version_encountered">
|
||||
<source>Unsupported project.razor.json version encounted.</source>
|
||||
<target state="translated">지원되지 않는 project.razor.json 버전이 있음.</target>
|
||||
<trans-unit id="Unsupported_argument_kind">
|
||||
<source>Unsupported argument kind: '{0}'.</source>
|
||||
<target state="new">Unsupported argument kind: '{0}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_argument_type">
|
||||
<source>Unsupported argument type: '{0}'.</source>
|
||||
<target state="new">Unsupported argument type: '{0}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_razor_project_info_version_encountered">
|
||||
<source>Unsupported razor project info version encounted.</source>
|
||||
<target state="new">Unsupported razor project info version encounted.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
|
|
|
@ -32,9 +32,19 @@
|
|||
<target state="translated">Oczekiwano tokenu JSON „{0}”, ale to był „{1}”.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_project_razor_json_version_encountered">
|
||||
<source>Unsupported project.razor.json version encounted.</source>
|
||||
<target state="translated">Napotkano nieobsługiwaną wersję pliku project.razor.json.</target>
|
||||
<trans-unit id="Unsupported_argument_kind">
|
||||
<source>Unsupported argument kind: '{0}'.</source>
|
||||
<target state="new">Unsupported argument kind: '{0}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_argument_type">
|
||||
<source>Unsupported argument type: '{0}'.</source>
|
||||
<target state="new">Unsupported argument type: '{0}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_razor_project_info_version_encountered">
|
||||
<source>Unsupported razor project info version encounted.</source>
|
||||
<target state="new">Unsupported razor project info version encounted.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
|
|
|
@ -32,9 +32,19 @@
|
|||
<target state="translated">Token JSON esperado '{0}', mas foi '{1}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_project_razor_json_version_encountered">
|
||||
<source>Unsupported project.razor.json version encounted.</source>
|
||||
<target state="translated">Versão project.razor.json sem suporte encontrada.</target>
|
||||
<trans-unit id="Unsupported_argument_kind">
|
||||
<source>Unsupported argument kind: '{0}'.</source>
|
||||
<target state="new">Unsupported argument kind: '{0}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_argument_type">
|
||||
<source>Unsupported argument type: '{0}'.</source>
|
||||
<target state="new">Unsupported argument type: '{0}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_razor_project_info_version_encountered">
|
||||
<source>Unsupported razor project info version encounted.</source>
|
||||
<target state="new">Unsupported razor project info version encounted.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
|
|
|
@ -32,9 +32,19 @@
|
|||
<target state="translated">Ожидался токен JSON "{0}", но он имел значение "{1}".</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_project_razor_json_version_encountered">
|
||||
<source>Unsupported project.razor.json version encounted.</source>
|
||||
<target state="translated">Обнаружена неподдерживаемая версия project.razor.json.</target>
|
||||
<trans-unit id="Unsupported_argument_kind">
|
||||
<source>Unsupported argument kind: '{0}'.</source>
|
||||
<target state="new">Unsupported argument kind: '{0}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_argument_type">
|
||||
<source>Unsupported argument type: '{0}'.</source>
|
||||
<target state="new">Unsupported argument type: '{0}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_razor_project_info_version_encountered">
|
||||
<source>Unsupported razor project info version encounted.</source>
|
||||
<target state="new">Unsupported razor project info version encounted.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
|
|
|
@ -32,9 +32,19 @@
|
|||
<target state="translated">'{0}' JSON belirteci bekleniyordu ancak '{1}' idi.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_project_razor_json_version_encountered">
|
||||
<source>Unsupported project.razor.json version encounted.</source>
|
||||
<target state="translated">Desteklenmeyen project.razor.json sürümü hesaplandı.</target>
|
||||
<trans-unit id="Unsupported_argument_kind">
|
||||
<source>Unsupported argument kind: '{0}'.</source>
|
||||
<target state="new">Unsupported argument kind: '{0}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_argument_type">
|
||||
<source>Unsupported argument type: '{0}'.</source>
|
||||
<target state="new">Unsupported argument type: '{0}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_razor_project_info_version_encountered">
|
||||
<source>Unsupported razor project info version encounted.</source>
|
||||
<target state="new">Unsupported razor project info version encounted.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
|
|
|
@ -32,9 +32,19 @@
|
|||
<target state="translated">预期为 JSON 令牌“{0}”,但实际为“{1}”。</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_project_razor_json_version_encountered">
|
||||
<source>Unsupported project.razor.json version encounted.</source>
|
||||
<target state="translated">遇到不支持的 project.razor.json 版本。</target>
|
||||
<trans-unit id="Unsupported_argument_kind">
|
||||
<source>Unsupported argument kind: '{0}'.</source>
|
||||
<target state="new">Unsupported argument kind: '{0}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_argument_type">
|
||||
<source>Unsupported argument type: '{0}'.</source>
|
||||
<target state="new">Unsupported argument type: '{0}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_razor_project_info_version_encountered">
|
||||
<source>Unsupported razor project info version encounted.</source>
|
||||
<target state="new">Unsupported razor project info version encounted.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
|
|
|
@ -32,9 +32,19 @@
|
|||
<target state="translated">必須是 JSON 權杖 '{0}',但卻是 '{1}'。</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_project_razor_json_version_encountered">
|
||||
<source>Unsupported project.razor.json version encounted.</source>
|
||||
<target state="translated">遇到不受支援的 project.razor.json 版本。</target>
|
||||
<trans-unit id="Unsupported_argument_kind">
|
||||
<source>Unsupported argument kind: '{0}'.</source>
|
||||
<target state="new">Unsupported argument kind: '{0}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_argument_type">
|
||||
<source>Unsupported argument type: '{0}'.</source>
|
||||
<target state="new">Unsupported argument type: '{0}'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Unsupported_razor_project_info_version_encountered">
|
||||
<source>Unsupported razor project info version encounted.</source>
|
||||
<target state="new">Unsupported razor project info version encounted.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNetCore.Razor.ProjectSystem;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.Converters;
|
||||
|
||||
internal class ProjectRazorJsonJsonConverter : ObjectJsonConverter<ProjectRazorJson>
|
||||
{
|
||||
public static readonly ProjectRazorJsonJsonConverter Instance = new();
|
||||
|
||||
private ProjectRazorJsonJsonConverter()
|
||||
{
|
||||
}
|
||||
|
||||
protected override ProjectRazorJson ReadFromProperties(JsonDataReader reader)
|
||||
=> ObjectReaders.ReadProjectRazorJsonFromProperties(reader);
|
||||
|
||||
protected override void WriteProperties(JsonDataWriter writer, ProjectRazorJson value)
|
||||
=> ObjectWriters.WriteProperties(writer, value);
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using Microsoft.AspNetCore.Razor.Utilities;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.Converters;
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.Json.Converters;
|
||||
|
||||
internal class ChecksumJsonConverter : ObjectJsonConverter<Checksum>
|
||||
{
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.Converters;
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.Json.Converters;
|
||||
|
||||
internal partial class ProjectSnapshotHandleJsonConverter : ObjectJsonConverter<ProjectSnapshotHandle>
|
||||
{
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNetCore.Razor.ProjectSystem;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.Json.Converters;
|
||||
|
||||
internal class RazorProjectInfoJsonConverter : ObjectJsonConverter<RazorProjectInfo>
|
||||
{
|
||||
public static readonly RazorProjectInfoJsonConverter Instance = new();
|
||||
|
||||
private RazorProjectInfoJsonConverter()
|
||||
{
|
||||
}
|
||||
|
||||
protected override RazorProjectInfo ReadFromProperties(JsonDataReader reader)
|
||||
=> ObjectReaders.ReadRazorProjectInfoFromProperties(reader);
|
||||
|
||||
protected override void WriteProperties(JsonDataWriter writer, RazorProjectInfo value)
|
||||
=> ObjectWriters.WriteProperties(writer, value);
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.Converters;
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.Json.Converters;
|
||||
|
||||
internal partial class TagHelperDeltaResultJsonConverter : ObjectJsonConverter<TagHelperDeltaResult>
|
||||
{
|
|
@ -4,9 +4,10 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Json.Converters;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.Converters;
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
|
||||
internal static class JsonConverterCollectionExtensions
|
||||
{
|
||||
|
@ -14,7 +15,7 @@ internal static class JsonConverterCollectionExtensions
|
|||
new JsonConverter[]
|
||||
{
|
||||
ChecksumJsonConverter.Instance,
|
||||
ProjectRazorJsonJsonConverter.Instance,
|
||||
RazorProjectInfoJsonConverter.Instance,
|
||||
ProjectSnapshotHandleJsonConverter.Instance,
|
||||
TagHelperDeltaResultJsonConverter.Instance,
|
||||
});
|
|
@ -6,7 +6,7 @@ using System.IO;
|
|||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization;
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
|
||||
internal static class JsonDataConvert
|
||||
{
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using Microsoft.Extensions.ObjectPool;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization;
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
|
||||
internal partial class JsonDataReader
|
||||
{
|
|
@ -8,7 +8,7 @@ using Microsoft.AspNetCore.Razor.PooledObjects;
|
|||
using Microsoft.Extensions.ObjectPool;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization;
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
|
||||
internal delegate T ReadValue<T>(JsonDataReader reader);
|
||||
internal delegate T ReadProperties<T>(JsonDataReader reader);
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using Microsoft.Extensions.ObjectPool;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization;
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
|
||||
internal partial class JsonDataWriter
|
||||
{
|
|
@ -10,7 +10,7 @@ using Microsoft.AspNetCore.Razor.PooledObjects;
|
|||
using Microsoft.Extensions.ObjectPool;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization;
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
|
||||
internal delegate void WriteProperties<T>(JsonDataWriter writer, T value);
|
||||
internal delegate void WriteValue<T>(JsonDataWriter writer, T value);
|
|
@ -6,7 +6,7 @@ using System.Diagnostics.CodeAnalysis;
|
|||
using System.Runtime.CompilerServices;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization;
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
|
||||
internal static class JsonReaderExtensions
|
||||
{
|
|
@ -4,7 +4,7 @@
|
|||
using System;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization;
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
|
||||
internal abstract class ObjectJsonConverter<T> : JsonConverter<T>
|
||||
where T : class
|
|
@ -11,7 +11,7 @@ using Microsoft.CodeAnalysis.CSharp;
|
|||
using static Microsoft.AspNetCore.Razor.Language.RequiredAttributeDescriptor;
|
||||
using Checksum = Microsoft.AspNetCore.Razor.Utilities.Checksum;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization;
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
|
||||
internal static partial class ObjectReaders
|
||||
{
|
||||
|
@ -331,21 +331,21 @@ internal static partial class ObjectReaders
|
|||
}
|
||||
}
|
||||
|
||||
public static ProjectRazorJson ReadProjectRazorJsonFromProperties(JsonDataReader reader)
|
||||
public static RazorProjectInfo ReadRazorProjectInfoFromProperties(JsonDataReader reader)
|
||||
{
|
||||
if (!reader.TryReadInt32(WellKnownPropertyNames.Version, out var version) || version != ProjectRazorJson.Version)
|
||||
if (!reader.TryReadInt32(WellKnownPropertyNames.Version, out var version) || version != SerializationFormat.Version)
|
||||
{
|
||||
throw new ProjectRazorJsonSerializationException(SR.Unsupported_project_razor_json_version_encountered);
|
||||
throw new RazorProjectInfoSerializationException(SR.Unsupported_razor_project_info_version_encountered);
|
||||
}
|
||||
|
||||
var serializedFilePath = reader.ReadNonNullString(nameof(ProjectRazorJson.SerializedFilePath));
|
||||
var filePath = reader.ReadNonNullString(nameof(ProjectRazorJson.FilePath));
|
||||
var configuration = reader.ReadObject(nameof(ProjectRazorJson.Configuration), ReadConfigurationFromProperties);
|
||||
var projectWorkspaceState = reader.ReadObject(nameof(ProjectRazorJson.ProjectWorkspaceState), ReadProjectWorkspaceStateFromProperties);
|
||||
var rootNamespace = reader.ReadString(nameof(ProjectRazorJson.RootNamespace));
|
||||
var documents = reader.ReadImmutableArray(nameof(ProjectRazorJson.Documents), static r => r.ReadNonNullObject(ReadDocumentSnapshotHandleFromProperties));
|
||||
var serializedFilePath = reader.ReadNonNullString(nameof(RazorProjectInfo.SerializedFilePath));
|
||||
var filePath = reader.ReadNonNullString(nameof(RazorProjectInfo.FilePath));
|
||||
var configuration = reader.ReadObject(nameof(RazorProjectInfo.Configuration), ReadConfigurationFromProperties);
|
||||
var projectWorkspaceState = reader.ReadObject(nameof(RazorProjectInfo.ProjectWorkspaceState), ReadProjectWorkspaceStateFromProperties);
|
||||
var rootNamespace = reader.ReadString(nameof(RazorProjectInfo.RootNamespace));
|
||||
var documents = reader.ReadImmutableArray(nameof(RazorProjectInfo.Documents), static r => r.ReadNonNullObject(ReadDocumentSnapshotHandleFromProperties));
|
||||
|
||||
return new ProjectRazorJson(serializedFilePath, filePath, configuration, rootNamespace, projectWorkspaceState, documents);
|
||||
return new RazorProjectInfo(serializedFilePath, filePath, configuration, rootNamespace, projectWorkspaceState, documents);
|
||||
}
|
||||
|
||||
public static Checksum ReadChecksum(JsonDataReader reader)
|
||||
|
@ -353,10 +353,10 @@ internal static partial class ObjectReaders
|
|||
|
||||
public static Checksum ReadChecksumFromProperties(JsonDataReader reader)
|
||||
{
|
||||
var data1 = reader.ReadInt64();
|
||||
var data2 = reader.ReadInt64();
|
||||
var data3 = reader.ReadInt64();
|
||||
var data4 = reader.ReadInt64();
|
||||
var data1 = reader.ReadInt64(nameof(Checksum.HashData.Data1));
|
||||
var data2 = reader.ReadInt64(nameof(Checksum.HashData.Data2));
|
||||
var data3 = reader.ReadInt64(nameof(Checksum.HashData.Data3));
|
||||
var data4 = reader.ReadInt64(nameof(Checksum.HashData.Data4));
|
||||
|
||||
var hashData = new Checksum.HashData(data1, data2, data3, data4);
|
||||
|
|
@ -11,7 +11,7 @@ using Microsoft.AspNetCore.Razor.ProjectSystem;
|
|||
using Microsoft.AspNetCore.Razor.Utilities;
|
||||
using Checksum = Microsoft.AspNetCore.Razor.Utilities.Checksum;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization;
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
|
||||
internal static class ObjectWriters
|
||||
{
|
||||
|
@ -230,12 +230,12 @@ internal static class ObjectWriters
|
|||
}
|
||||
}
|
||||
|
||||
public static void Write(JsonDataWriter writer, ProjectRazorJson value)
|
||||
public static void Write(JsonDataWriter writer, RazorProjectInfo value)
|
||||
=> writer.WriteObject(value, WriteProperties);
|
||||
|
||||
public static void WriteProperties(JsonDataWriter writer, ProjectRazorJson value)
|
||||
public static void WriteProperties(JsonDataWriter writer, RazorProjectInfo value)
|
||||
{
|
||||
writer.Write(WellKnownPropertyNames.Version, ProjectRazorJson.Version);
|
||||
writer.Write(WellKnownPropertyNames.Version, SerializationFormat.Version);
|
||||
writer.Write(nameof(value.SerializedFilePath), value.SerializedFilePath);
|
||||
writer.Write(nameof(value.FilePath), value.FilePath);
|
||||
writer.WriteObject(nameof(value.Configuration), value.Configuration, WriteProperties);
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
|
||||
internal static class SerializationFormat
|
||||
{
|
||||
// This version number must be incremented if the serialization format for ProjectRazorJson
|
||||
// or any of the types that compose it changes. This includes: RazorConfiguration,
|
||||
// ProjectWorkspaceState, TagHelperDescriptor, and DocumentSnapshotHandle.
|
||||
// NOTE: If this version is changed, a coordinated insertion is required between Roslyn and Razor for the C# extension.
|
||||
public const int Version = 2;
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization;
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
|
||||
internal static class WellKnownPropertyNames
|
||||
{
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack;
|
||||
|
||||
internal enum ArgKind
|
||||
{
|
||||
Integer,
|
||||
String,
|
||||
Null,
|
||||
True,
|
||||
False,
|
||||
Boolean
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack;
|
||||
|
||||
internal enum DocumentationKind
|
||||
{
|
||||
Descriptor,
|
||||
String
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using MessagePack;
|
||||
using Microsoft.AspNetCore.Razor.Utilities;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
|
||||
|
||||
internal sealed class ChecksumFormatter : MessagePackFormatter<Checksum>
|
||||
{
|
||||
public static readonly MessagePackFormatter<Checksum> Instance = new ChecksumFormatter();
|
||||
|
||||
private ChecksumFormatter()
|
||||
{
|
||||
}
|
||||
|
||||
public override Checksum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
|
||||
{
|
||||
var data1 = reader.ReadInt64();
|
||||
var data2 = reader.ReadInt64();
|
||||
var data3 = reader.ReadInt64();
|
||||
var data4 = reader.ReadInt64();
|
||||
|
||||
var hashData = new Checksum.HashData(data1, data2, data3, data4);
|
||||
|
||||
return new Checksum(hashData);
|
||||
}
|
||||
|
||||
public override void Serialize(ref MessagePackWriter writer, Checksum value, MessagePackSerializerOptions options)
|
||||
{
|
||||
var hashData = value.Data;
|
||||
|
||||
writer.Write(hashData.Data1);
|
||||
writer.Write(hashData.Data2);
|
||||
writer.Write(hashData.Data3);
|
||||
writer.Write(hashData.Data4);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using MessagePack;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
|
||||
|
||||
internal sealed class DocumentSnapshotHandleFormatter : MessagePackFormatter<DocumentSnapshotHandle>
|
||||
{
|
||||
public static readonly MessagePackFormatter<DocumentSnapshotHandle> Instance = new DocumentSnapshotHandleFormatter();
|
||||
|
||||
private DocumentSnapshotHandleFormatter()
|
||||
{
|
||||
}
|
||||
|
||||
public override DocumentSnapshotHandle Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
|
||||
{
|
||||
var filePath = DeserializeString(ref reader, options);
|
||||
var targetPath = DeserializeString(ref reader, options);
|
||||
var fileKind = DeserializeString(ref reader, options);
|
||||
|
||||
return new DocumentSnapshotHandle(filePath, targetPath, fileKind);
|
||||
}
|
||||
|
||||
public override void Serialize(ref MessagePackWriter writer, DocumentSnapshotHandle value, MessagePackSerializerOptions options)
|
||||
{
|
||||
writer.Write(value.FilePath);
|
||||
writer.Write(value.TargetPath);
|
||||
writer.Write(value.FileKind);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using MessagePack;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
|
||||
|
||||
internal abstract partial class MessagePackFormatter<T>
|
||||
{
|
||||
public readonly ref struct AllowNullWrapper(MessagePackFormatter<T> formatter)
|
||||
{
|
||||
private readonly MessagePackFormatter<T> _formatter = formatter;
|
||||
|
||||
public T? Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
|
||||
=> reader.TryReadNil() ? default : _formatter.Deserialize(ref reader, options);
|
||||
|
||||
public void Serialize(ref MessagePackWriter writer, T? value, MessagePackSerializerOptions options)
|
||||
{
|
||||
if (value is null)
|
||||
{
|
||||
writer.WriteNil();
|
||||
}
|
||||
else
|
||||
{
|
||||
_formatter.Serialize(ref writer, value, options);
|
||||
}
|
||||
}
|
||||
|
||||
public string? DeserializeString(ref MessagePackReader reader, MessagePackSerializerOptions options)
|
||||
=> s_stringFormatter.Deserialize(ref reader, options);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using MessagePack;
|
||||
using MessagePack.Formatters;
|
||||
using Microsoft.AspNetCore.Razor.PooledObjects;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
|
||||
|
||||
internal abstract partial class MessagePackFormatter<T> : IMessagePackFormatter<T>
|
||||
{
|
||||
private static readonly StringInterningFormatter s_stringFormatter = new();
|
||||
|
||||
public AllowNullWrapper AllowNull => new(this);
|
||||
|
||||
public abstract T Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options);
|
||||
public abstract void Serialize(ref MessagePackWriter writer, T value, MessagePackSerializerOptions options);
|
||||
|
||||
public static string DeserializeString(ref MessagePackReader reader, MessagePackSerializerOptions options)
|
||||
=> s_stringFormatter.Deserialize(ref reader, options).AssumeNotNull();
|
||||
|
||||
public virtual T[] DeserializeArray(ref MessagePackReader reader, MessagePackSerializerOptions options)
|
||||
{
|
||||
var count = reader.ReadArrayHeader();
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
return Array.Empty<T>();
|
||||
}
|
||||
|
||||
using var builder = new PooledArrayBuilder<T>(capacity: count);
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var item = Deserialize(ref reader, options);
|
||||
builder.Add(item);
|
||||
}
|
||||
|
||||
return builder.ToArray();
|
||||
}
|
||||
|
||||
public virtual ImmutableArray<T> DeserializeImmutableArray(ref MessagePackReader reader, MessagePackSerializerOptions options)
|
||||
{
|
||||
var count = reader.ReadArrayHeader();
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
return ImmutableArray<T>.Empty;
|
||||
}
|
||||
|
||||
using var builder = new PooledArrayBuilder<T>(capacity: count);
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var item = Deserialize(ref reader, options);
|
||||
builder.Add(item);
|
||||
}
|
||||
|
||||
return builder.DrainToImmutable();
|
||||
}
|
||||
|
||||
public virtual void SerializeArray(ref MessagePackWriter writer, IReadOnlyList<T> array, MessagePackSerializerOptions options)
|
||||
{
|
||||
var count = array.Count;
|
||||
writer.WriteArrayHeader(count);
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
Serialize(ref writer, array[i], options);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void SerializeArray(ref MessagePackWriter writer, ImmutableArray<T> array, MessagePackSerializerOptions options)
|
||||
{
|
||||
writer.WriteArrayHeader(array.Length);
|
||||
|
||||
foreach (var item in array)
|
||||
{
|
||||
Serialize(ref writer, item, options);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using MessagePack;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
|
||||
|
||||
internal sealed class ProjectSnapshotHandleFormatter : MessagePackFormatter<ProjectSnapshotHandle>
|
||||
{
|
||||
public static readonly MessagePackFormatter<ProjectSnapshotHandle> Instance = new ProjectSnapshotHandleFormatter();
|
||||
|
||||
private ProjectSnapshotHandleFormatter()
|
||||
{
|
||||
}
|
||||
|
||||
public override ProjectSnapshotHandle Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
|
||||
{
|
||||
var projectIdString = DeserializeString(ref reader, options);
|
||||
var configuration = RazorConfigurationFormatter.Instance.AllowNull.Deserialize(ref reader, options);
|
||||
|
||||
var rootNamespace = AllowNull.DeserializeString(ref reader, options);
|
||||
|
||||
var projectId = ProjectId.CreateFromSerialized(Guid.Parse(projectIdString));
|
||||
|
||||
return new(projectId, configuration, rootNamespace);
|
||||
}
|
||||
|
||||
public override void Serialize(ref MessagePackWriter writer, ProjectSnapshotHandle value, MessagePackSerializerOptions options)
|
||||
{
|
||||
writer.Write(value.ProjectId.Id.ToString());
|
||||
|
||||
if (value.Configuration is { } configuration)
|
||||
{
|
||||
RazorConfigurationFormatter.Instance.Serialize(ref writer, configuration, options);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteNil();
|
||||
}
|
||||
|
||||
writer.Write(value.RootNamespace);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using MessagePack;
|
||||
using Microsoft.AspNetCore.Razor.PooledObjects;
|
||||
using Microsoft.AspNetCore.Razor.ProjectSystem;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
|
||||
|
||||
internal sealed class ProjectWorkspaceStateFormatter : MessagePackFormatter<ProjectWorkspaceState>
|
||||
{
|
||||
public static readonly MessagePackFormatter<ProjectWorkspaceState> Instance = new ProjectWorkspaceStateFormatter();
|
||||
|
||||
private ProjectWorkspaceStateFormatter()
|
||||
{
|
||||
}
|
||||
|
||||
public override ProjectWorkspaceState Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
|
||||
{
|
||||
using var _ = TagHelperSerializationCache.Pool.GetPooledObject(out var cache);
|
||||
|
||||
var tagHelpers = TagHelperFormatter.Instance.DeserializeImmutableArray(ref reader, options, cache);
|
||||
var csharpLanguageVersion = (LanguageVersion)reader.ReadInt32();
|
||||
|
||||
return new ProjectWorkspaceState(tagHelpers, csharpLanguageVersion);
|
||||
}
|
||||
|
||||
public override void Serialize(ref MessagePackWriter writer, ProjectWorkspaceState value, MessagePackSerializerOptions options)
|
||||
{
|
||||
using var _ = TagHelperSerializationCache.Pool.GetPooledObject(out var cache);
|
||||
|
||||
TagHelperFormatter.Instance.SerializeArray(ref writer, value.TagHelpers, options, cache);
|
||||
writer.Write((int)value.CSharpLanguageVersion);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using MessagePack;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.PooledObjects;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
|
||||
|
||||
internal sealed class RazorConfigurationFormatter : MessagePackFormatter<RazorConfiguration>
|
||||
{
|
||||
public static readonly MessagePackFormatter<RazorConfiguration> Instance = new RazorConfigurationFormatter();
|
||||
|
||||
private RazorConfigurationFormatter()
|
||||
{
|
||||
}
|
||||
|
||||
public override RazorConfiguration Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
|
||||
{
|
||||
var configurationName = DeserializeString(ref reader, options);
|
||||
var languageVersionText = DeserializeString(ref reader, options);
|
||||
|
||||
var count = reader.ReadArrayHeader();
|
||||
|
||||
var extensions = count > 0
|
||||
? ReadExtensions(ref reader, count, options)
|
||||
: Array.Empty<RazorExtension>();
|
||||
|
||||
var languageVersion = RazorLanguageVersion.TryParse(languageVersionText, out var version)
|
||||
? version
|
||||
: RazorLanguageVersion.Version_2_1;
|
||||
|
||||
return RazorConfiguration.Create(languageVersion, configurationName, extensions);
|
||||
}
|
||||
|
||||
private RazorExtension[] ReadExtensions(ref MessagePackReader reader, int count, MessagePackSerializerOptions options)
|
||||
{
|
||||
using var builder = new PooledArrayBuilder<RazorExtension>();
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var extensionName = DeserializeString(ref reader, options);
|
||||
builder.Add(new SerializedRazorExtension(extensionName));
|
||||
}
|
||||
|
||||
return builder.ToArray();
|
||||
}
|
||||
|
||||
public override void Serialize(ref MessagePackWriter writer, RazorConfiguration value, MessagePackSerializerOptions options)
|
||||
{
|
||||
writer.Write(value.ConfigurationName);
|
||||
|
||||
if (value.LanguageVersion == RazorLanguageVersion.Experimental)
|
||||
{
|
||||
writer.Write(nameof(RazorLanguageVersion.Experimental));
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write(value.LanguageVersion.ToString());
|
||||
}
|
||||
|
||||
var extensions = value.Extensions;
|
||||
var count = extensions.Count;
|
||||
|
||||
writer.WriteArrayHeader(count);
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
writer.Write(extensions[i].ExtensionName);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using MessagePack;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
|
||||
|
||||
internal sealed class RazorDiagnosticFormatter : MessagePackFormatter<RazorDiagnostic>
|
||||
{
|
||||
public static readonly MessagePackFormatter<RazorDiagnostic> Instance = new RazorDiagnosticFormatter();
|
||||
|
||||
private RazorDiagnosticFormatter()
|
||||
{
|
||||
}
|
||||
|
||||
public override RazorDiagnostic Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
|
||||
{
|
||||
var id = DeserializeString(ref reader, options);
|
||||
var severity = (RazorDiagnosticSeverity)reader.ReadInt32();
|
||||
var message = DeserializeString(ref reader, options);
|
||||
|
||||
var filePath = AllowNull.DeserializeString(ref reader, options);
|
||||
var absoluteIndex = reader.ReadInt32();
|
||||
var lineIndex = reader.ReadInt32();
|
||||
var characterIndex = reader.ReadInt32();
|
||||
var length = reader.ReadInt32();
|
||||
|
||||
var descriptor = new RazorDiagnosticDescriptor(id, MessageFormat(message), severity);
|
||||
var span = new SourceSpan(filePath, absoluteIndex, lineIndex, characterIndex, length);
|
||||
|
||||
return RazorDiagnostic.Create(descriptor, span);
|
||||
|
||||
static Func<string> MessageFormat(string message)
|
||||
{
|
||||
return () => message;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(ref MessagePackWriter writer, RazorDiagnostic value, MessagePackSerializerOptions options)
|
||||
{
|
||||
writer.Write(value.Id);
|
||||
writer.Write((int)value.Severity);
|
||||
writer.Write(value.GetMessage(CultureInfo.CurrentCulture));
|
||||
|
||||
var span = value.Span;
|
||||
writer.Write(span.FilePath);
|
||||
writer.Write(span.AbsoluteIndex);
|
||||
writer.Write(span.LineIndex);
|
||||
writer.Write(span.CharacterIndex);
|
||||
writer.Write(span.Length);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using MessagePack;
|
||||
using Microsoft.AspNetCore.Razor.ProjectSystem;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
|
||||
|
||||
internal sealed class RazorProjectInfoFormatter : MessagePackFormatter<RazorProjectInfo>
|
||||
{
|
||||
public static readonly MessagePackFormatter<RazorProjectInfo> Instance = new RazorProjectInfoFormatter();
|
||||
|
||||
private RazorProjectInfoFormatter()
|
||||
{
|
||||
}
|
||||
|
||||
public override RazorProjectInfo Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
|
||||
{
|
||||
if (reader.NextMessagePackType != MessagePackType.Integer)
|
||||
{
|
||||
throw new RazorProjectInfoSerializationException(SR.Unsupported_razor_project_info_version_encountered);
|
||||
}
|
||||
|
||||
var version = reader.ReadInt32();
|
||||
|
||||
if (version != SerializationFormat.Version)
|
||||
{
|
||||
throw new RazorProjectInfoSerializationException(SR.Unsupported_razor_project_info_version_encountered);
|
||||
}
|
||||
|
||||
var serializedFilePath = DeserializeString(ref reader, options);
|
||||
var filePath = DeserializeString(ref reader, options);
|
||||
var configuration = RazorConfigurationFormatter.Instance.AllowNull.Deserialize(ref reader, options);
|
||||
var projectWorkspaceState = ProjectWorkspaceStateFormatter.Instance.AllowNull.Deserialize(ref reader, options);
|
||||
var rootNamespace = AllowNull.DeserializeString(ref reader, options);
|
||||
var documents = DocumentSnapshotHandleFormatter.Instance.DeserializeImmutableArray(ref reader, options);
|
||||
|
||||
return new RazorProjectInfo(serializedFilePath, filePath, configuration, rootNamespace, projectWorkspaceState, documents);
|
||||
}
|
||||
|
||||
public override void Serialize(ref MessagePackWriter writer, RazorProjectInfo value, MessagePackSerializerOptions options)
|
||||
{
|
||||
writer.Write(SerializationFormat.Version);
|
||||
writer.Write(value.SerializedFilePath);
|
||||
writer.Write(value.FilePath);
|
||||
RazorConfigurationFormatter.Instance.AllowNull.Serialize(ref writer, value.Configuration, options);
|
||||
ProjectWorkspaceStateFormatter.Instance.AllowNull.Serialize(ref writer, value.ProjectWorkspaceState, options);
|
||||
writer.Write(value.RootNamespace);
|
||||
DocumentSnapshotHandleFormatter.Instance.SerializeArray(ref writer, value.Documents, options);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using MessagePack;
|
||||
using Microsoft.AspNetCore.Razor.PooledObjects;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
|
||||
|
||||
internal sealed class TagHelperDeltaResultFormatter : MessagePackFormatter<TagHelperDeltaResult>
|
||||
{
|
||||
public static readonly MessagePackFormatter<TagHelperDeltaResult> Instance = new TagHelperDeltaResultFormatter();
|
||||
|
||||
private TagHelperDeltaResultFormatter()
|
||||
{
|
||||
}
|
||||
|
||||
public override TagHelperDeltaResult Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
|
||||
{
|
||||
using var _ = TagHelperSerializationCache.Pool.GetPooledObject(out var cache);
|
||||
|
||||
var delta = reader.ReadBoolean();
|
||||
var resultId = reader.ReadInt32();
|
||||
var added = TagHelperFormatter.Instance.DeserializeImmutableArray(ref reader, options, cache);
|
||||
var removed = TagHelperFormatter.Instance.DeserializeImmutableArray(ref reader, options, cache);
|
||||
|
||||
return new(delta, resultId, added, removed);
|
||||
}
|
||||
|
||||
public override void Serialize(ref MessagePackWriter writer, TagHelperDeltaResult value, MessagePackSerializerOptions options)
|
||||
{
|
||||
using var _ = TagHelperSerializationCache.Pool.GetPooledObject(out var cache);
|
||||
|
||||
writer.Write(value.Delta);
|
||||
writer.Write(value.ResultId);
|
||||
TagHelperFormatter.Instance.SerializeArray(ref writer, value.Added, options, cache);
|
||||
TagHelperFormatter.Instance.SerializeArray(ref writer, value.Removed, options, cache);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using MessagePack;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
|
||||
|
||||
internal sealed class AllowedChildTagFormatter : TagHelperObjectFormatter<AllowedChildTagDescriptor>
|
||||
{
|
||||
public static readonly TagHelperObjectFormatter<AllowedChildTagDescriptor> Instance = new AllowedChildTagFormatter();
|
||||
|
||||
private AllowedChildTagFormatter()
|
||||
{
|
||||
}
|
||||
|
||||
public override AllowedChildTagDescriptor Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options, TagHelperSerializationCache? cache)
|
||||
{
|
||||
var name = reader.ReadString(cache);
|
||||
var displayName = reader.ReadString(cache);
|
||||
var diagnostics = RazorDiagnosticFormatter.Instance.DeserializeArray(ref reader, options);
|
||||
|
||||
return new DefaultAllowedChildTagDescriptor(name, displayName, diagnostics);
|
||||
}
|
||||
|
||||
public override void Serialize(ref MessagePackWriter writer, AllowedChildTagDescriptor value, MessagePackSerializerOptions options, TagHelperSerializationCache? cache)
|
||||
{
|
||||
writer.Write(value.Name, cache);
|
||||
writer.Write(value.DisplayName, cache);
|
||||
|
||||
RazorDiagnosticFormatter.Instance.SerializeArray(ref writer, value.Diagnostics, options);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using MessagePack;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
|
||||
|
||||
internal sealed class BoundAttributeFormatter : TagHelperObjectFormatter<BoundAttributeDescriptor>
|
||||
{
|
||||
public static readonly TagHelperObjectFormatter<BoundAttributeDescriptor> Instance = new BoundAttributeFormatter();
|
||||
|
||||
private BoundAttributeFormatter()
|
||||
{
|
||||
}
|
||||
|
||||
public override BoundAttributeDescriptor Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options, TagHelperSerializationCache? cache)
|
||||
{
|
||||
var kind = reader.ReadString(cache).AssumeNotNull();
|
||||
var name = reader.ReadString(cache);
|
||||
var typeName = reader.ReadString(cache);
|
||||
var isEnum = reader.ReadBoolean();
|
||||
var hasIndexer = reader.ReadBoolean();
|
||||
var indexerNamePrefix = reader.ReadString(cache);
|
||||
var indexerTypeName = reader.ReadString(cache);
|
||||
var displayName = reader.ReadString(cache);
|
||||
var documentationObject = DocumentationObjectFormatter.Instance.Deserialize(ref reader, options, cache);
|
||||
var caseSensitive = reader.ReadBoolean();
|
||||
var isEditorRequired = reader.ReadBoolean();
|
||||
var parameters = BoundAttributeParameterFormatter.Instance.DeserializeArray(ref reader, options, cache);
|
||||
|
||||
var metadata = MetadataCollectionFormatter.Instance.Deserialize(ref reader, options, cache);
|
||||
var diagnostics = RazorDiagnosticFormatter.Instance.DeserializeArray(ref reader, options);
|
||||
|
||||
return new DefaultBoundAttributeDescriptor(
|
||||
kind, name, typeName, isEnum,
|
||||
hasIndexer, indexerNamePrefix, indexerTypeName,
|
||||
documentationObject, displayName, caseSensitive, isEditorRequired,
|
||||
parameters, metadata, diagnostics);
|
||||
}
|
||||
|
||||
public override void Serialize(ref MessagePackWriter writer, BoundAttributeDescriptor value, MessagePackSerializerOptions options, TagHelperSerializationCache? cache)
|
||||
{
|
||||
writer.Write(value.Kind, cache);
|
||||
writer.Write(value.Name, cache);
|
||||
writer.Write(value.TypeName, cache);
|
||||
writer.Write(value.IsEnum);
|
||||
writer.Write(value.HasIndexer);
|
||||
writer.Write(value.IndexerNamePrefix, cache);
|
||||
writer.Write(value.IndexerTypeName, cache);
|
||||
writer.Write(value.DisplayName, cache);
|
||||
DocumentationObjectFormatter.Instance.Serialize(ref writer, value.DocumentationObject, options, cache);
|
||||
writer.Write(value.CaseSensitive);
|
||||
writer.Write(value.IsEditorRequired);
|
||||
BoundAttributeParameterFormatter.Instance.SerializeArray(ref writer, value.BoundAttributeParameters, options, cache);
|
||||
|
||||
MetadataCollectionFormatter.Instance.Serialize(ref writer, (MetadataCollection)value.Metadata, options, cache);
|
||||
RazorDiagnosticFormatter.Instance.SerializeArray(ref writer, value.Diagnostics, options);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using MessagePack;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
|
||||
|
||||
internal sealed class BoundAttributeParameterFormatter : TagHelperObjectFormatter<BoundAttributeParameterDescriptor>
|
||||
{
|
||||
public static readonly TagHelperObjectFormatter<BoundAttributeParameterDescriptor> Instance = new BoundAttributeParameterFormatter();
|
||||
|
||||
private BoundAttributeParameterFormatter()
|
||||
{
|
||||
}
|
||||
|
||||
public override BoundAttributeParameterDescriptor Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options, TagHelperSerializationCache? cache)
|
||||
{
|
||||
var kind = reader.ReadString(cache).AssumeNotNull();
|
||||
var name = reader.ReadString(cache);
|
||||
var typeName = reader.ReadString(cache);
|
||||
var isEnum = reader.ReadBoolean();
|
||||
var displayName = reader.ReadString(cache);
|
||||
var documentationObject = DocumentationObjectFormatter.Instance.Deserialize(ref reader, options, cache);
|
||||
var caseSensitive = reader.ReadBoolean();
|
||||
|
||||
var metadata = MetadataCollectionFormatter.Instance.Deserialize(ref reader, options, cache);
|
||||
var diagnostics = RazorDiagnosticFormatter.Instance.DeserializeArray(ref reader, options);
|
||||
|
||||
return new DefaultBoundAttributeParameterDescriptor(
|
||||
kind, name, typeName,
|
||||
isEnum, documentationObject, displayName, caseSensitive,
|
||||
metadata, diagnostics);
|
||||
}
|
||||
|
||||
public override void Serialize(ref MessagePackWriter writer, BoundAttributeParameterDescriptor value, MessagePackSerializerOptions options, TagHelperSerializationCache? cache)
|
||||
{
|
||||
writer.Write(value.Kind, cache);
|
||||
writer.Write(value.Name, cache);
|
||||
writer.Write(value.TypeName, cache);
|
||||
writer.Write(value.IsEnum);
|
||||
writer.Write(value.DisplayName, cache);
|
||||
DocumentationObjectFormatter.Instance.Serialize(ref writer, value.DocumentationObject, options, cache);
|
||||
writer.Write(value.CaseSensitive);
|
||||
|
||||
MetadataCollectionFormatter.Instance.Serialize(ref writer, (MetadataCollection)value.Metadata, options, cache);
|
||||
RazorDiagnosticFormatter.Instance.SerializeArray(ref writer, value.Diagnostics, options);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,151 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using MessagePack;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.PooledObjects;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
|
||||
|
||||
internal sealed class DocumentationObjectFormatter : TagHelperObjectFormatter<DocumentationObject>
|
||||
{
|
||||
public static readonly TagHelperObjectFormatter<DocumentationObject> Instance = new DocumentationObjectFormatter();
|
||||
|
||||
private DocumentationObjectFormatter()
|
||||
{
|
||||
}
|
||||
|
||||
public override DocumentationObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options, TagHelperSerializationCache? cache)
|
||||
{
|
||||
if (reader.TryReadNil())
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
var documentationKind = (DocumentationKind)reader.ReadInt32();
|
||||
|
||||
switch (documentationKind)
|
||||
{
|
||||
case DocumentationKind.Descriptor:
|
||||
var id = (DocumentationId)reader.ReadInt32();
|
||||
|
||||
var count = reader.ReadArrayHeader();
|
||||
var args = count > 0
|
||||
? ReadArgs(ref reader, count, cache)
|
||||
: Array.Empty<object>();
|
||||
|
||||
return DocumentationDescriptor.From(id, args);
|
||||
|
||||
case DocumentationKind.String:
|
||||
return reader.ReadString(cache).AssumeNotNull();
|
||||
|
||||
default:
|
||||
throw new NotSupportedException(SR.FormatUnsupported_argument_kind(documentationKind));
|
||||
}
|
||||
}
|
||||
|
||||
private object?[] ReadArgs(ref MessagePackReader reader, int count, TagHelperSerializationCache? cache)
|
||||
{
|
||||
using var builder = new PooledArrayBuilder<object?>(capacity: count);
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var item = ReadArg(ref reader, cache);
|
||||
builder.Add(item);
|
||||
}
|
||||
|
||||
return builder.ToArray();
|
||||
}
|
||||
|
||||
private object? ReadArg(ref MessagePackReader reader, TagHelperSerializationCache? cache)
|
||||
{
|
||||
if (reader.TryReadNil())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var argKind = (ArgKind)reader.ReadInt32();
|
||||
|
||||
return argKind switch
|
||||
{
|
||||
ArgKind.String => reader.ReadString(cache),
|
||||
ArgKind.Integer => reader.ReadInt32(),
|
||||
ArgKind.Boolean => reader.ReadBoolean(),
|
||||
|
||||
_ => throw new NotSupportedException(SR.FormatUnsupported_argument_kind(argKind)),
|
||||
};
|
||||
}
|
||||
|
||||
public override void Serialize(ref MessagePackWriter writer, DocumentationObject value, MessagePackSerializerOptions options, TagHelperSerializationCache? cache)
|
||||
{
|
||||
switch (value.Object)
|
||||
{
|
||||
case DocumentationDescriptor descriptor:
|
||||
writer.Write((int)DocumentationKind.Descriptor);
|
||||
writer.Write((int)descriptor.Id);
|
||||
|
||||
var args = descriptor.Args;
|
||||
var count = args.Length;
|
||||
writer.WriteArrayHeader(count);
|
||||
|
||||
foreach (var arg in args)
|
||||
{
|
||||
WriteArg(ref writer, arg, cache);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case string text:
|
||||
writer.Write((int)DocumentationKind.String);
|
||||
writer.Write(text, cache);
|
||||
break;
|
||||
|
||||
case null:
|
||||
writer.WriteNil();
|
||||
break;
|
||||
|
||||
default:
|
||||
Debug.Fail($"Documentation objects should only be of type {nameof(DocumentationDescriptor)}, string, or null.");
|
||||
break;
|
||||
}
|
||||
|
||||
static void WriteArg(ref MessagePackWriter writer, object? value, TagHelperSerializationCache? cache)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case string s:
|
||||
writer.Write((int)ArgKind.String);
|
||||
writer.Write(s, cache);
|
||||
break;
|
||||
|
||||
case int i:
|
||||
writer.Write((int)ArgKind.Integer);
|
||||
writer.Write(i);
|
||||
break;
|
||||
|
||||
case bool b:
|
||||
writer.Write((int)ArgKind.Boolean);
|
||||
writer.Write(b);
|
||||
break;
|
||||
|
||||
case null:
|
||||
writer.WriteNil();
|
||||
break;
|
||||
|
||||
case var arg:
|
||||
ThrowNotSupported(arg.GetType());
|
||||
break;
|
||||
}
|
||||
|
||||
[DoesNotReturn]
|
||||
static void ThrowNotSupported(Type type)
|
||||
{
|
||||
throw new NotSupportedException(
|
||||
SR.FormatUnsupported_argument_type(type.FullName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using MessagePack;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
|
||||
|
||||
internal static class Extensions
|
||||
{
|
||||
public static string? ReadString(this ref MessagePackReader reader, TagHelperSerializationCache? cache)
|
||||
{
|
||||
if (cache is null)
|
||||
{
|
||||
return reader.ReadString();
|
||||
}
|
||||
|
||||
if (reader.NextMessagePackType == MessagePackType.Integer)
|
||||
{
|
||||
var referenceId = reader.ReadInt32();
|
||||
return cache.Strings.GetValue(referenceId);
|
||||
}
|
||||
|
||||
var result = reader.ReadString();
|
||||
|
||||
if (result is not null)
|
||||
{
|
||||
cache.Strings.Add(result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void Write(this ref MessagePackWriter writer, string? value, TagHelperSerializationCache? cache)
|
||||
{
|
||||
if (cache is null)
|
||||
{
|
||||
writer.Write(value);
|
||||
return;
|
||||
}
|
||||
|
||||
if (value is null)
|
||||
{
|
||||
writer.WriteNil();
|
||||
}
|
||||
else if (cache.Strings.TryGetReferenceId(value, out var referenceId))
|
||||
{
|
||||
writer.Write(referenceId);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write(value);
|
||||
cache.Strings.Add(value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using MessagePack;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
|
||||
#if !NET
|
||||
using System.Collections.Generic;
|
||||
#endif
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
|
||||
|
||||
internal sealed class MetadataCollectionFormatter : TagHelperObjectFormatter<MetadataCollection>
|
||||
{
|
||||
public static readonly TagHelperObjectFormatter<MetadataCollection> Instance = new MetadataCollectionFormatter();
|
||||
|
||||
private MetadataCollectionFormatter()
|
||||
{
|
||||
}
|
||||
|
||||
public override MetadataCollection Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options, TagHelperSerializationCache? cache)
|
||||
{
|
||||
if (cache is not null && reader.NextMessagePackType == MessagePackType.Integer)
|
||||
{
|
||||
var referenceId = reader.ReadInt32();
|
||||
return cache.Metadata.GetValue(referenceId);
|
||||
}
|
||||
|
||||
// Divide the number of array elements by two because each key/value pair is stored as two elements.
|
||||
var count = reader.ReadArrayHeader() / 2;
|
||||
|
||||
using var builder = new MetadataBuilder();
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var key = reader.ReadString(cache).AssumeNotNull();
|
||||
var value = reader.ReadString(cache);
|
||||
|
||||
builder.Add(key, value);
|
||||
}
|
||||
|
||||
var result = builder.Build();
|
||||
|
||||
cache?.Metadata.Add(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void Serialize(ref MessagePackWriter writer, MetadataCollection value, MessagePackSerializerOptions options, TagHelperSerializationCache? cache)
|
||||
{
|
||||
if (cache is not null)
|
||||
{
|
||||
if (cache.Metadata.TryGetReferenceId(value, out var referenceId))
|
||||
{
|
||||
writer.Write(referenceId);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
cache.Metadata.Add(value);
|
||||
}
|
||||
}
|
||||
|
||||
writer.WriteArrayHeader(value.Count * 2);
|
||||
|
||||
foreach (var (k, v) in value)
|
||||
{
|
||||
writer.Write(k, cache);
|
||||
writer.Write(v, cache);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using MessagePack;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using static Microsoft.AspNetCore.Razor.Language.RequiredAttributeDescriptor;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
|
||||
|
||||
internal sealed class RequiredAttributeFormatter : TagHelperObjectFormatter<RequiredAttributeDescriptor>
|
||||
{
|
||||
public static readonly TagHelperObjectFormatter<RequiredAttributeDescriptor> Instance = new RequiredAttributeFormatter();
|
||||
|
||||
private RequiredAttributeFormatter()
|
||||
{
|
||||
}
|
||||
|
||||
public override RequiredAttributeDescriptor Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options, TagHelperSerializationCache? cache)
|
||||
{
|
||||
var name = reader.ReadString(cache);
|
||||
var nameComparison = (NameComparisonMode)reader.ReadInt32();
|
||||
var caseSensitive = reader.ReadBoolean();
|
||||
var value = reader.ReadString(cache);
|
||||
var valueComparison = (ValueComparisonMode)reader.ReadInt32();
|
||||
var displayName = reader.ReadString(cache);
|
||||
|
||||
var metadata = MetadataCollectionFormatter.Instance.Deserialize(ref reader, options, cache);
|
||||
var diagnostics = RazorDiagnosticFormatter.Instance.DeserializeArray(ref reader, options);
|
||||
|
||||
return new DefaultRequiredAttributeDescriptor(
|
||||
name, nameComparison,
|
||||
caseSensitive,
|
||||
value, valueComparison,
|
||||
displayName!, diagnostics, metadata);
|
||||
}
|
||||
|
||||
public override void Serialize(ref MessagePackWriter writer, RequiredAttributeDescriptor value, MessagePackSerializerOptions options, TagHelperSerializationCache? cache)
|
||||
{
|
||||
writer.Write(value.Name, cache);
|
||||
writer.Write((int)value.NameComparison);
|
||||
writer.Write(value.CaseSensitive);
|
||||
writer.Write(value.Value, cache);
|
||||
writer.Write((int)value.ValueComparison);
|
||||
writer.Write(value.DisplayName, cache);
|
||||
|
||||
MetadataCollectionFormatter.Instance.Serialize(ref writer, (MetadataCollection)value.Metadata, options, cache);
|
||||
RazorDiagnosticFormatter.Instance.SerializeArray(ref writer, value.Diagnostics, options);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using MessagePack;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
|
||||
|
||||
internal sealed class TagHelperFormatter : TagHelperObjectFormatter<TagHelperDescriptor>
|
||||
{
|
||||
public static readonly TagHelperObjectFormatter<TagHelperDescriptor> Instance = new TagHelperFormatter();
|
||||
|
||||
private TagHelperFormatter()
|
||||
{
|
||||
}
|
||||
|
||||
public override TagHelperDescriptor Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options, TagHelperSerializationCache? cache)
|
||||
{
|
||||
var kind = reader.ReadString(cache).AssumeNotNull();
|
||||
var name = reader.ReadString(cache).AssumeNotNull();
|
||||
var assemblyName = reader.ReadString(cache).AssumeNotNull();
|
||||
|
||||
var displayName = reader.ReadString(cache);
|
||||
var documentationObject = DocumentationObjectFormatter.Instance.Deserialize(ref reader, options, cache);
|
||||
var tagOutputHint = reader.ReadString(cache);
|
||||
var caseSensitive = reader.ReadBoolean();
|
||||
|
||||
var tagMatchingRules = TagMatchingRuleFormatter.Instance.DeserializeArray(ref reader, options, cache);
|
||||
var boundAttributes = BoundAttributeFormatter.Instance.DeserializeArray(ref reader, options, cache);
|
||||
var allowedChildTags = AllowedChildTagFormatter.Instance.DeserializeArray(ref reader, options, cache);
|
||||
|
||||
var metadata = MetadataCollectionFormatter.Instance.Deserialize(ref reader, options, cache);
|
||||
var diagnostics = RazorDiagnosticFormatter.Instance.DeserializeArray(ref reader, options);
|
||||
|
||||
return new DefaultTagHelperDescriptor(
|
||||
kind, name, assemblyName,
|
||||
displayName!, documentationObject,
|
||||
tagOutputHint, caseSensitive,
|
||||
tagMatchingRules, boundAttributes, allowedChildTags,
|
||||
metadata, diagnostics);
|
||||
}
|
||||
|
||||
public override void Serialize(ref MessagePackWriter writer, TagHelperDescriptor value, MessagePackSerializerOptions options, TagHelperSerializationCache? cache)
|
||||
{
|
||||
writer.Write(value.Kind, cache);
|
||||
writer.Write(value.Name, cache);
|
||||
writer.Write(value.AssemblyName, cache);
|
||||
writer.Write(value.DisplayName, cache);
|
||||
DocumentationObjectFormatter.Instance.Serialize(ref writer, value.DocumentationObject, options, cache);
|
||||
writer.Write(value.TagOutputHint, cache);
|
||||
writer.Write(value.CaseSensitive);
|
||||
TagMatchingRuleFormatter.Instance.SerializeArray(ref writer, value.TagMatchingRules, options, cache);
|
||||
BoundAttributeFormatter.Instance.SerializeArray(ref writer, value.BoundAttributes, options, cache);
|
||||
AllowedChildTagFormatter.Instance.SerializeArray(ref writer, value.AllowedChildTags, options, cache);
|
||||
MetadataCollectionFormatter.Instance.Serialize(ref writer, (MetadataCollection)value.Metadata, options, cache);
|
||||
RazorDiagnosticFormatter.Instance.SerializeArray(ref writer, value.Diagnostics, options);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using MessagePack;
|
||||
using Microsoft.AspNetCore.Razor.PooledObjects;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
|
||||
|
||||
internal abstract class TagHelperObjectFormatter<T> : MessagePackFormatter<T>
|
||||
{
|
||||
public sealed override T Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
|
||||
=> Deserialize(ref reader, options, cache: null);
|
||||
|
||||
public sealed override void Serialize(ref MessagePackWriter writer, T value, MessagePackSerializerOptions options)
|
||||
=> Serialize(ref writer, value, options, cache: null);
|
||||
|
||||
public sealed override T[] DeserializeArray(ref MessagePackReader reader, MessagePackSerializerOptions options)
|
||||
=> DeserializeArray(ref reader, options, cache: null);
|
||||
|
||||
public sealed override ImmutableArray<T> DeserializeImmutableArray(ref MessagePackReader reader, MessagePackSerializerOptions options)
|
||||
=> DeserializeImmutableArray(ref reader, options, cache: null);
|
||||
|
||||
public sealed override void SerializeArray(ref MessagePackWriter writer, ImmutableArray<T> array, MessagePackSerializerOptions options)
|
||||
=> SerializeArray(ref writer, array, options, cache: null);
|
||||
|
||||
public sealed override void SerializeArray(ref MessagePackWriter writer, IReadOnlyList<T> array, MessagePackSerializerOptions options)
|
||||
=> SerializeArray(ref writer, array, options, cache: null);
|
||||
|
||||
public abstract T Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options, TagHelperSerializationCache? cache);
|
||||
public abstract void Serialize(ref MessagePackWriter writer, T value, MessagePackSerializerOptions options, TagHelperSerializationCache? cache);
|
||||
|
||||
public T[] DeserializeArray(ref MessagePackReader reader, MessagePackSerializerOptions options, TagHelperSerializationCache? cache)
|
||||
{
|
||||
var count = reader.ReadArrayHeader();
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
return Array.Empty<T>();
|
||||
}
|
||||
|
||||
using var builder = new PooledArrayBuilder<T>(capacity: count);
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var item = Deserialize(ref reader, options, cache);
|
||||
builder.Add(item);
|
||||
}
|
||||
|
||||
return builder.ToArray();
|
||||
}
|
||||
|
||||
public virtual ImmutableArray<T> DeserializeImmutableArray(ref MessagePackReader reader, MessagePackSerializerOptions options, TagHelperSerializationCache? cache)
|
||||
{
|
||||
var count = reader.ReadArrayHeader();
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
return ImmutableArray<T>.Empty;
|
||||
}
|
||||
|
||||
using var builder = new PooledArrayBuilder<T>(capacity: count);
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var item = Deserialize(ref reader, options, cache);
|
||||
builder.Add(item);
|
||||
}
|
||||
|
||||
return builder.DrainToImmutable();
|
||||
}
|
||||
|
||||
public virtual void SerializeArray(ref MessagePackWriter writer, IReadOnlyList<T> array, MessagePackSerializerOptions options, TagHelperSerializationCache? cache)
|
||||
{
|
||||
var count = array.Count;
|
||||
writer.WriteArrayHeader(count);
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
Serialize(ref writer, array[i], options, cache);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void SerializeArray(ref MessagePackWriter writer, ImmutableArray<T> array, MessagePackSerializerOptions options, TagHelperSerializationCache? cache)
|
||||
{
|
||||
writer.WriteArrayHeader(array.Length);
|
||||
|
||||
foreach (var item in array)
|
||||
{
|
||||
Serialize(ref writer, item, options, cache);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.Extensions.ObjectPool;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
|
||||
|
||||
internal sealed partial class TagHelperSerializationCache
|
||||
{
|
||||
private sealed class Policy : IPooledObjectPolicy<TagHelperSerializationCache>
|
||||
{
|
||||
public static readonly Policy Instance = new();
|
||||
|
||||
private Policy()
|
||||
{
|
||||
}
|
||||
|
||||
public TagHelperSerializationCache Create() => new();
|
||||
|
||||
public bool Return(TagHelperSerializationCache cache)
|
||||
{
|
||||
if (cache._metadataMap is { } metadataMap)
|
||||
{
|
||||
metadataMap.Dispose();
|
||||
cache._metadataMap = null;
|
||||
}
|
||||
|
||||
if (cache._stringMap is { } stringMap)
|
||||
{
|
||||
stringMap.Dispose();
|
||||
cache._stringMap = null;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Razor.PooledObjects;
|
||||
using Microsoft.Extensions.ObjectPool;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
|
||||
|
||||
internal sealed partial class TagHelperSerializationCache
|
||||
{
|
||||
public struct ReferenceMap<T> : IDisposable
|
||||
where T : notnull
|
||||
{
|
||||
private readonly ObjectPool<Dictionary<T, int>> _dictionaryPool;
|
||||
private List<T> _values;
|
||||
private Dictionary<T, int> _valueToIdMap;
|
||||
|
||||
public ReferenceMap(ObjectPool<Dictionary<T, int>> dictionaryPool)
|
||||
{
|
||||
_dictionaryPool = dictionaryPool;
|
||||
_values = ListPool<T>.Default.Get();
|
||||
_valueToIdMap = _dictionaryPool.Get();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_values is { } values)
|
||||
{
|
||||
ListPool<T>.Default.Return(values);
|
||||
_values = null!;
|
||||
}
|
||||
|
||||
if (_valueToIdMap is { } valueToIdMap)
|
||||
{
|
||||
_dictionaryPool.Return(valueToIdMap);
|
||||
_valueToIdMap = null!;
|
||||
}
|
||||
}
|
||||
|
||||
public T GetValue(int referenceId)
|
||||
=> _values[referenceId];
|
||||
|
||||
public readonly bool TryGetReferenceId(T value, out int referenceId)
|
||||
=> _valueToIdMap.TryGetValue(value, out referenceId);
|
||||
|
||||
public void Add(T value)
|
||||
{
|
||||
var id = _values.Count;
|
||||
_values.Add(value);
|
||||
_valueToIdMap.Add(value, id);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.PooledObjects;
|
||||
using Microsoft.Extensions.ObjectPool;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
|
||||
|
||||
internal sealed partial class TagHelperSerializationCache
|
||||
{
|
||||
public static readonly ObjectPool<TagHelperSerializationCache> Pool = DefaultPool.Create(Policy.Instance);
|
||||
|
||||
private static readonly ObjectPool<Dictionary<MetadataCollection, int>> s_metadataPool
|
||||
= DictionaryPool<MetadataCollection, int>.Default;
|
||||
|
||||
private static readonly ObjectPool<Dictionary<string, int>> s_stringPool
|
||||
= StringDictionaryPool<int>.Ordinal;
|
||||
|
||||
private ReferenceMap<MetadataCollection>? _metadataMap;
|
||||
private ReferenceMap<string>? _stringMap;
|
||||
|
||||
private TagHelperSerializationCache()
|
||||
{
|
||||
}
|
||||
|
||||
public ReferenceMap<MetadataCollection> Metadata
|
||||
=> _metadataMap ??= new ReferenceMap<MetadataCollection>(s_metadataPool);
|
||||
|
||||
public ReferenceMap<string> Strings
|
||||
=> _stringMap ??= new ReferenceMap<string>(s_stringPool);
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using MessagePack;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
|
||||
|
||||
internal sealed class TagMatchingRuleFormatter : TagHelperObjectFormatter<TagMatchingRuleDescriptor>
|
||||
{
|
||||
public static readonly TagHelperObjectFormatter<TagMatchingRuleDescriptor> Instance = new TagMatchingRuleFormatter();
|
||||
|
||||
private TagMatchingRuleFormatter()
|
||||
{
|
||||
}
|
||||
|
||||
public override TagMatchingRuleDescriptor Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options, TagHelperSerializationCache? cache)
|
||||
{
|
||||
var tagName = reader.ReadString(cache).AssumeNotNull();
|
||||
var parentTag = reader.ReadString(cache);
|
||||
var tagStructure = (TagStructure)reader.ReadInt32();
|
||||
var caseSensitive = reader.ReadBoolean();
|
||||
var attributes = RequiredAttributeFormatter.Instance.DeserializeArray(ref reader, options, cache);
|
||||
var diagnostics = RazorDiagnosticFormatter.Instance.DeserializeArray(ref reader, options);
|
||||
|
||||
return new DefaultTagMatchingRuleDescriptor(
|
||||
tagName, parentTag,
|
||||
tagStructure, caseSensitive,
|
||||
attributes, diagnostics);
|
||||
}
|
||||
|
||||
public override void Serialize(ref MessagePackWriter writer, TagMatchingRuleDescriptor value, MessagePackSerializerOptions options, TagHelperSerializationCache? cache)
|
||||
{
|
||||
writer.Write(value.TagName, cache);
|
||||
writer.Write(value.ParentTag, cache);
|
||||
writer.Write((int)value.TagStructure);
|
||||
writer.Write(value.CaseSensitive);
|
||||
RequiredAttributeFormatter.Instance.SerializeArray(ref writer, value.Attributes, options, cache);
|
||||
RazorDiagnosticFormatter.Instance.SerializeArray(ref writer, value.Diagnostics, options);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using MessagePack;
|
||||
using MessagePack.Formatters;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
|
||||
using Microsoft.AspNetCore.Razor.Utilities;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Resolvers;
|
||||
|
||||
internal sealed class ChecksumResolver : IFormatterResolver
|
||||
{
|
||||
public static readonly ChecksumResolver Instance = new();
|
||||
|
||||
private ChecksumResolver()
|
||||
{
|
||||
}
|
||||
|
||||
public IMessagePackFormatter<T>? GetFormatter<T>()
|
||||
{
|
||||
return Cache<T>.Formatter;
|
||||
}
|
||||
|
||||
private static class Cache<T>
|
||||
{
|
||||
public static readonly IMessagePackFormatter<T>? Formatter;
|
||||
|
||||
static Cache()
|
||||
{
|
||||
if (typeof(T) == typeof(Checksum))
|
||||
{
|
||||
Formatter = (IMessagePackFormatter<T>)ChecksumFormatter.Instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using MessagePack;
|
||||
using MessagePack.Formatters;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Resolvers;
|
||||
|
||||
internal sealed class ProjectSnapshotHandleResolver : IFormatterResolver
|
||||
{
|
||||
public static readonly ProjectSnapshotHandleResolver Instance = new();
|
||||
|
||||
private ProjectSnapshotHandleResolver()
|
||||
{
|
||||
}
|
||||
|
||||
public IMessagePackFormatter<T>? GetFormatter<T>()
|
||||
{
|
||||
return Cache<T>.Formatter;
|
||||
}
|
||||
|
||||
private static class Cache<T>
|
||||
{
|
||||
public static readonly IMessagePackFormatter<T>? Formatter;
|
||||
|
||||
static Cache()
|
||||
{
|
||||
if (typeof(T) == typeof(ProjectSnapshotHandle))
|
||||
{
|
||||
Formatter = (IMessagePackFormatter<T>)ProjectSnapshotHandleFormatter.Instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using MessagePack;
|
||||
using MessagePack.Formatters;
|
||||
using Microsoft.AspNetCore.Razor.ProjectSystem;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Resolvers;
|
||||
|
||||
internal sealed class RazorProjectInfoResolver : IFormatterResolver
|
||||
{
|
||||
public static readonly RazorProjectInfoResolver Instance = new();
|
||||
|
||||
private RazorProjectInfoResolver()
|
||||
{
|
||||
}
|
||||
|
||||
public IMessagePackFormatter<T>? GetFormatter<T>()
|
||||
{
|
||||
return Cache<T>.Formatter;
|
||||
}
|
||||
|
||||
private static class Cache<T>
|
||||
{
|
||||
public static readonly IMessagePackFormatter<T>? Formatter;
|
||||
|
||||
static Cache()
|
||||
{
|
||||
if (typeof(T) == typeof(RazorProjectInfo))
|
||||
{
|
||||
Formatter = (IMessagePackFormatter<T>)RazorProjectInfoFormatter.Instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using MessagePack.Resolvers;
|
||||
using MessagePack;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Resolvers;
|
||||
|
||||
internal static class RazorResolvers
|
||||
{
|
||||
public static readonly IFormatterResolver All = CompositeResolver.Create(
|
||||
ChecksumResolver.Instance,
|
||||
RazorProjectInfoResolver.Instance,
|
||||
ProjectSnapshotHandleResolver.Instance,
|
||||
TagHelperDeltaResultResolver.Instance,
|
||||
StandardResolver.Instance);
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using MessagePack;
|
||||
using MessagePack.Formatters;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Resolvers;
|
||||
|
||||
internal sealed class TagHelperDeltaResultResolver : IFormatterResolver
|
||||
{
|
||||
public static readonly TagHelperDeltaResultResolver Instance = new();
|
||||
|
||||
private TagHelperDeltaResultResolver()
|
||||
{
|
||||
}
|
||||
|
||||
public IMessagePackFormatter<T>? GetFormatter<T>()
|
||||
{
|
||||
return Cache<T>.Formatter;
|
||||
}
|
||||
|
||||
private static class Cache<T>
|
||||
{
|
||||
public static readonly IMessagePackFormatter<T>? Formatter;
|
||||
|
||||
static Cache()
|
||||
{
|
||||
if (typeof(T) == typeof(TagHelperDeltaResult))
|
||||
{
|
||||
Formatter = (IMessagePackFormatter<T>)TagHelperDeltaResultFormatter.Instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack;
|
||||
|
||||
internal static class SerializationFormat
|
||||
{
|
||||
// This version number must be incremented if the serialization format for ProjectRazorJson
|
||||
// or any of the types that compose it changes. This includes: RazorConfiguration,
|
||||
// ProjectWorkspaceState, TagHelperDescriptor, and DocumentSnapshotHandle.
|
||||
// NOTE: If this version is changed, a coordinated insertion is required between Roslyn and Razor for the C# extension.
|
||||
public const int Version = 2;
|
||||
}
|
|
@ -5,6 +5,6 @@ using System;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Serialization;
|
||||
|
||||
internal class ProjectRazorJsonSerializationException(string? message) : Exception(message)
|
||||
internal class RazorProjectInfoSerializationException(string? message) : Exception(message)
|
||||
{
|
||||
}
|
|
@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces.ProjectSystem;
|
|||
|
||||
internal static class IProjectSnapshotExtensions
|
||||
{
|
||||
public static ProjectRazorJson ToProjectRazorJson(this IProjectSnapshot project, string serializedFilePath)
|
||||
public static RazorProjectInfo ToRazorProjectInfo(this IProjectSnapshot project, string serializedFilePath)
|
||||
{
|
||||
using var documents = new PooledArrayBuilder<DocumentSnapshotHandle>();
|
||||
|
||||
|
@ -24,7 +24,7 @@ internal static class IProjectSnapshotExtensions
|
|||
}
|
||||
}
|
||||
|
||||
return new ProjectRazorJson(
|
||||
return new RazorProjectInfo(
|
||||
serializedFilePath: serializedFilePath,
|
||||
filePath: project.FilePath,
|
||||
configuration: project.Configuration,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Converters;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ using System.ComponentModel.Composition;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Converters;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Json.Converters;
|
||||
using Microsoft.CodeAnalysis.Razor;
|
||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
using Microsoft.CodeAnalysis.Razor.Workspaces;
|
||||
|
@ -22,7 +22,7 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor;
|
|||
/// </summary>
|
||||
[Shared]
|
||||
[Export(typeof(IProjectSnapshotChangeTrigger))]
|
||||
internal class ProjectRazorJsonPublisher : IProjectSnapshotChangeTrigger
|
||||
internal class RazorProjectInfoPublisher : IProjectSnapshotChangeTrigger
|
||||
{
|
||||
internal readonly Dictionary<string, Task> DeferredPublishTasks;
|
||||
|
||||
|
@ -54,7 +54,7 @@ internal class ProjectRazorJsonPublisher : IProjectSnapshotChangeTrigger
|
|||
}
|
||||
|
||||
[ImportingConstructor]
|
||||
public ProjectRazorJsonPublisher(
|
||||
public RazorProjectInfoPublisher(
|
||||
LSPEditorFeatureDetector lSPEditorFeatureDetector,
|
||||
ProjectConfigurationFilePathStore projectConfigurationFilePathStore,
|
||||
RazorLogger logger)
|
||||
|
@ -86,7 +86,7 @@ internal class ProjectRazorJsonPublisher : IProjectSnapshotChangeTrigger
|
|||
#if DEBUG
|
||||
_serializer.Formatting = Formatting.Indented;
|
||||
#endif
|
||||
_serializer.Converters.Add(ProjectRazorJsonJsonConverter.Instance);
|
||||
_serializer.Converters.Add(RazorProjectInfoJsonConverter.Instance);
|
||||
}
|
||||
|
||||
// Internal settable for testing
|
||||
|
@ -284,8 +284,8 @@ internal class ProjectRazorJsonPublisher : IProjectSnapshotChangeTrigger
|
|||
// by the time we move the tempfile into its place
|
||||
using (var writer = tempFileInfo.CreateText())
|
||||
{
|
||||
var projectRazorJson = projectSnapshot.ToProjectRazorJson(publishFilePath);
|
||||
_serializer.Serialize(writer, projectRazorJson);
|
||||
var projectInfo = projectSnapshot.ToRazorProjectInfo(publishFilePath);
|
||||
_serializer.Serialize(writer, projectInfo);
|
||||
}
|
||||
|
||||
var fileInfo = new FileInfo(publishFilePath);
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Converters;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
|
||||
namespace Microsoft.VisualStudio.LiveShare.Razor.Serialization;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNetCore.Razor.Serialization;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
|
||||
namespace Microsoft.VisualStudio.LiveShare.Razor.Serialization;
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -14,8 +13,7 @@ using Microsoft.AspNetCore.Razor.LanguageServer;
|
|||
using Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts;
|
||||
using Microsoft.AspNetCore.Razor.LanguageServer.Serialization;
|
||||
using Microsoft.AspNetCore.Razor.LanguageServer.Test.Common;
|
||||
using Microsoft.AspNetCore.Razor.Serialization;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Converters;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
|
||||
using Microsoft.CodeAnalysis.Razor;
|
||||
|
@ -74,13 +72,14 @@ public abstract class LanguageServerTestBase : TestBase
|
|||
return requestContext;
|
||||
}
|
||||
|
||||
protected static RazorCodeDocument CreateCodeDocument(string text, IReadOnlyList<TagHelperDescriptor>? tagHelpers = null, string? filePath = null)
|
||||
protected static RazorCodeDocument CreateCodeDocument(string text, ImmutableArray<TagHelperDescriptor> tagHelpers = default, string? filePath = null)
|
||||
{
|
||||
var fileKind = FileKinds.GetFileKindFromFilePath(filePath ?? "test.cshtml");
|
||||
tagHelpers ??= Array.Empty<TagHelperDescriptor>();
|
||||
tagHelpers = tagHelpers.NullToEmpty();
|
||||
|
||||
if (fileKind == FileKinds.Component)
|
||||
{
|
||||
tagHelpers = tagHelpers.Concat(GetDefaultRuntimeComponents()).ToArray();
|
||||
tagHelpers = tagHelpers.AddRange(RazorTestResources.BlazorServerAppTagHelpers);
|
||||
}
|
||||
|
||||
var sourceDocument = TestRazorSourceDocument.Create(text, filePath: filePath);
|
||||
|
@ -145,19 +144,6 @@ public abstract class LanguageServerTestBase : TestBase
|
|||
return monitor.Object;
|
||||
}
|
||||
|
||||
private static IReadOnlyList<TagHelperDescriptor> GetDefaultRuntimeComponents()
|
||||
{
|
||||
var bytes = RazorTestResources.GetResourceBytes(RazorTestResources.BlazorServerAppTagHelpersJson);
|
||||
|
||||
using var stream = new MemoryStream(bytes);
|
||||
using var reader = new StreamReader(stream);
|
||||
|
||||
return JsonDataConvert.DeserializeData(reader,
|
||||
static r => r.ReadArray(
|
||||
static r => ObjectReaders.ReadTagHelper(r, useCache: false)))
|
||||
?? Array.Empty<TagHelperDescriptor>();
|
||||
}
|
||||
|
||||
[Obsolete("Use " + nameof(LSPProjectSnapshotManagerDispatcher))]
|
||||
private class TestProjectSnapshotManagerDispatcher : ProjectSnapshotManagerDispatcher
|
||||
{
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
|
@ -776,10 +777,7 @@ public class RazorTranslateDiagnosticsEndpointTest : LanguageServerTestBase
|
|||
var addTagHelper = $"@addTagHelper *, TestAssembly{Environment.NewLine}";
|
||||
var codeDocument = CreateCodeDocument(
|
||||
$"{addTagHelper}<button></button>",
|
||||
new[]
|
||||
{
|
||||
GetButtonTagHelperDescriptor().Build()
|
||||
});
|
||||
ImmutableArray.Create(GetButtonTagHelperDescriptor().Build()));
|
||||
var documentContext = CreateDocumentContext(documentPath, codeDocument);
|
||||
var diagnosticsService = new RazorTranslateDiagnosticsService(_mappingService, LoggerFactory);
|
||||
var diagnosticsEndpoint = new RazorTranslateDiagnosticsEndpoint(diagnosticsService, LoggerFactory);
|
||||
|
@ -808,10 +806,7 @@ public class RazorTranslateDiagnosticsEndpointTest : LanguageServerTestBase
|
|||
var addTagHelper = $"@addTagHelper *, TestAssembly{Environment.NewLine}";
|
||||
var codeDocument = CreateCodeDocument(
|
||||
$"{addTagHelper}<button></button>",
|
||||
new[]
|
||||
{
|
||||
GetButtonTagHelperDescriptor().Build()
|
||||
});
|
||||
ImmutableArray.Create(GetButtonTagHelperDescriptor().Build()));
|
||||
var documentContext = CreateDocumentContext(documentPath, codeDocument);
|
||||
var diagnosticsService = new RazorTranslateDiagnosticsService(_mappingService, LoggerFactory);
|
||||
var diagnosticsEndpoint = new RazorTranslateDiagnosticsEndpoint(diagnosticsService, LoggerFactory);
|
||||
|
@ -928,9 +923,7 @@ public class RazorTranslateDiagnosticsEndpointTest : LanguageServerTestBase
|
|||
new SourceSpan(addTagHelper.Length + 38, 9),
|
||||
new SourceSpan(addTagHelper.Length + 25, 9))
|
||||
},
|
||||
new[] {
|
||||
descriptor.Build()
|
||||
});
|
||||
ImmutableArray.Create(descriptor.Build()));
|
||||
var documentContext = CreateDocumentContext(documentPath, codeDocument);
|
||||
var diagnosticsService = new RazorTranslateDiagnosticsService(_mappingService, LoggerFactory);
|
||||
var diagnosticsEndpoint = new RazorTranslateDiagnosticsEndpoint(diagnosticsService, LoggerFactory);
|
||||
|
@ -977,9 +970,7 @@ public class RazorTranslateDiagnosticsEndpointTest : LanguageServerTestBase
|
|||
</div>",
|
||||
projectedCSharpSource: string.Empty,
|
||||
sourceMappings: Array.Empty<SourceMapping>(),
|
||||
new[] {
|
||||
descriptor.Build()
|
||||
});
|
||||
ImmutableArray.Create(descriptor.Build()));
|
||||
var documentContext = CreateDocumentContext(documentPath, codeDocument);
|
||||
var diagnosticsService = new RazorTranslateDiagnosticsService(_mappingService, LoggerFactory);
|
||||
var diagnosticsEndpoint = new RazorTranslateDiagnosticsEndpoint(diagnosticsService, LoggerFactory);
|
||||
|
@ -1207,7 +1198,7 @@ public class RazorTranslateDiagnosticsEndpointTest : LanguageServerTestBase
|
|||
string razorSource,
|
||||
string projectedCSharpSource,
|
||||
IEnumerable<SourceMapping> sourceMappings,
|
||||
IReadOnlyList<TagHelperDescriptor>? tagHelpers = null)
|
||||
ImmutableArray<TagHelperDescriptor> tagHelpers = default)
|
||||
{
|
||||
var codeDocument = CreateCodeDocument(razorSource, tagHelpers);
|
||||
var csharpDocument = RazorCSharpDocument.Create(
|
||||
|
|
|
@ -13,7 +13,6 @@ using Microsoft.AspNetCore.Razor.Language.IntegrationTests;
|
|||
using Microsoft.AspNetCore.Razor.LanguageServer.Extensions;
|
||||
using Microsoft.AspNetCore.Razor.LanguageServer.Protocol;
|
||||
using Microsoft.AspNetCore.Razor.LanguageServer.Test.Common;
|
||||
using Microsoft.AspNetCore.Razor.Serialization;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Razor;
|
||||
|
@ -40,7 +39,6 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.Formatting;
|
|||
public class FormattingTestBase : RazorIntegrationTestBase
|
||||
{
|
||||
private static readonly AsyncLocal<string> s_fileName = new();
|
||||
private static readonly ImmutableArray<TagHelperDescriptor> s_defaultComponents = GetDefaultRuntimeComponents();
|
||||
|
||||
public FormattingTestBase(ITestOutputHelper testOutput)
|
||||
: base(testOutput)
|
||||
|
@ -238,9 +236,10 @@ public class FormattingTestBase : RazorIntegrationTestBase
|
|||
{
|
||||
fileKind ??= FileKinds.Component;
|
||||
tagHelpers = tagHelpers.NullToEmpty();
|
||||
|
||||
if (fileKind == FileKinds.Component)
|
||||
{
|
||||
tagHelpers = tagHelpers.AddRange(s_defaultComponents);
|
||||
tagHelpers = tagHelpers.AddRange(RazorTestResources.BlazorServerAppTagHelpers);
|
||||
}
|
||||
|
||||
var sourceDocument = text.GetRazorSourceDocument(path, path);
|
||||
|
@ -338,16 +337,4 @@ public class FormattingTestBase : RazorIntegrationTestBase
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ImmutableArray<TagHelperDescriptor> GetDefaultRuntimeComponents()
|
||||
{
|
||||
var bytes = RazorTestResources.GetResourceBytes(RazorTestResources.BlazorServerAppTagHelpersJson);
|
||||
|
||||
using var stream = new MemoryStream(bytes);
|
||||
using var reader = new StreamReader(stream);
|
||||
|
||||
return JsonDataConvert.DeserializeData(reader,
|
||||
static r => r.ReadImmutableArray(
|
||||
static r => ObjectReaders.ReadTagHelper(r, useCache: false)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ public class ProjectConfigurationFileChangeEventArgsTest(ITestOutputHelper testO
|
|||
{
|
||||
// Arrange
|
||||
var jsonFileDeserializer = new Mock<JsonFileDeserializer>(MockBehavior.Strict);
|
||||
jsonFileDeserializer.Setup(deserializer => deserializer.Deserialize<ProjectRazorJson>(It.IsAny<string>()))
|
||||
.Returns(new ProjectRazorJson(
|
||||
jsonFileDeserializer.Setup(deserializer => deserializer.Deserialize<RazorProjectInfo>(It.IsAny<string>()))
|
||||
.Returns(new RazorProjectInfo(
|
||||
"/path/to/obj/project.razor.json",
|
||||
"c:/path/to/project.csproj",
|
||||
configuration: null,
|
||||
|
@ -44,23 +44,23 @@ public class ProjectConfigurationFileChangeEventArgsTest(ITestOutputHelper testO
|
|||
{
|
||||
// Arrange
|
||||
var jsonFileDeserializer = new Mock<JsonFileDeserializer>(MockBehavior.Strict);
|
||||
var projectRazorJson = new ProjectRazorJson(
|
||||
var projectInfo = new RazorProjectInfo(
|
||||
"/path/to/ORIGINAL/obj/project.razor.json",
|
||||
"c:/path/to/project.csproj",
|
||||
configuration: null,
|
||||
rootNamespace: null,
|
||||
projectWorkspaceState: null,
|
||||
documents: ImmutableArray<DocumentSnapshotHandle>.Empty);
|
||||
jsonFileDeserializer.Setup(deserializer => deserializer.Deserialize<ProjectRazorJson>(It.IsAny<string>()))
|
||||
.Returns(projectRazorJson);
|
||||
jsonFileDeserializer.Setup(deserializer => deserializer.Deserialize<RazorProjectInfo>(It.IsAny<string>()))
|
||||
.Returns(projectInfo);
|
||||
var args = new ProjectConfigurationFileChangeEventArgs("/path/to/DIFFERENT/obj/project.razor.json", RazorFileChangeKind.Added, jsonFileDeserializer.Object);
|
||||
|
||||
// Act
|
||||
var result = args.TryDeserialize(out var deserializedProjectRazorJson);
|
||||
var result = args.TryDeserialize(out var deserializedProjectInfo);
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
Assert.Null(deserializedProjectRazorJson);
|
||||
Assert.Null(deserializedProjectInfo);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -68,26 +68,26 @@ public class ProjectConfigurationFileChangeEventArgsTest(ITestOutputHelper testO
|
|||
{
|
||||
// Arrange
|
||||
var jsonFileDeserializer = new Mock<JsonFileDeserializer>(MockBehavior.Strict);
|
||||
var projectRazorJson = new ProjectRazorJson(
|
||||
var projectInfo = new RazorProjectInfo(
|
||||
"/path/to/obj/project.razor.json",
|
||||
"c:/path/to/project.csproj",
|
||||
configuration: null,
|
||||
rootNamespace: null,
|
||||
projectWorkspaceState: null,
|
||||
documents: ImmutableArray<DocumentSnapshotHandle>.Empty);
|
||||
jsonFileDeserializer.Setup(deserializer => deserializer.Deserialize<ProjectRazorJson>(It.IsAny<string>()))
|
||||
.Returns(projectRazorJson);
|
||||
jsonFileDeserializer.Setup(deserializer => deserializer.Deserialize<RazorProjectInfo>(It.IsAny<string>()))
|
||||
.Returns(projectInfo);
|
||||
var args = new ProjectConfigurationFileChangeEventArgs("/path/to/obj/project.razor.json", RazorFileChangeKind.Added, jsonFileDeserializer.Object);
|
||||
|
||||
// Act
|
||||
var result1 = args.TryDeserialize(out var projectRazorJson1);
|
||||
var result2 = args.TryDeserialize(out var projectRazorJson2);
|
||||
var result1 = args.TryDeserialize(out var projectInfo1);
|
||||
var result2 = args.TryDeserialize(out var projectInfo2);
|
||||
|
||||
// Assert
|
||||
Assert.True(result1);
|
||||
Assert.True(result2);
|
||||
Assert.Same(projectRazorJson, projectRazorJson1);
|
||||
Assert.Same(projectRazorJson, projectRazorJson2);
|
||||
Assert.Same(projectInfo, projectInfo1);
|
||||
Assert.Same(projectInfo, projectInfo2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -96,9 +96,9 @@ public class ProjectConfigurationFileChangeEventArgsTest(ITestOutputHelper testO
|
|||
// Arrange
|
||||
var jsonFileDeserializer = new Mock<JsonFileDeserializer>(MockBehavior.Strict);
|
||||
var callCount = 0;
|
||||
jsonFileDeserializer.Setup(deserializer => deserializer.Deserialize<ProjectRazorJson>(It.IsAny<string>()))
|
||||
jsonFileDeserializer.Setup(deserializer => deserializer.Deserialize<RazorProjectInfo>(It.IsAny<string>()))
|
||||
.Callback(() => callCount++)
|
||||
.Returns<ProjectRazorJson>(null);
|
||||
.Returns<RazorProjectInfo>(null);
|
||||
var args = new ProjectConfigurationFileChangeEventArgs("/path/to/obj/project.razor.json", RazorFileChangeKind.Changed, jsonFileDeserializer.Object);
|
||||
|
||||
// Act
|
||||
|
|
|
@ -51,24 +51,24 @@ public class ProjectConfigurationStateSynchronizerTest : LanguageServerTestBase
|
|||
public async Task ProjectConfigurationFileChanged_Removed_NonNormalizedPaths()
|
||||
{
|
||||
// Arrange
|
||||
var projectRazorJson = new ProjectRazorJson(
|
||||
var projectInfo = new RazorProjectInfo(
|
||||
"/path/to/obj/project.razor.json",
|
||||
"path/to/project.csproj",
|
||||
RazorConfiguration.Default,
|
||||
rootNamespace: "TestRootNamespace",
|
||||
new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, LanguageVersion.CSharp5),
|
||||
ImmutableArray<DocumentSnapshotHandle>.Empty);
|
||||
var intermediateOutputPath = Path.GetDirectoryName(projectRazorJson.SerializedFilePath);
|
||||
var intermediateOutputPath = Path.GetDirectoryName(projectInfo.SerializedFilePath);
|
||||
var projectKey = TestProjectKey.Create(intermediateOutputPath);
|
||||
var projectService = new Mock<RazorProjectService>(MockBehavior.Strict);
|
||||
projectService.Setup(service => service.AddProject(projectRazorJson.FilePath, @"path\to\obj", projectRazorJson.Configuration, projectRazorJson.RootNamespace))
|
||||
projectService.Setup(service => service.AddProject(projectInfo.FilePath, @"path\to\obj", projectInfo.Configuration, projectInfo.RootNamespace))
|
||||
.Returns(projectKey);
|
||||
projectService.Setup(service => service.UpdateProject(
|
||||
projectKey,
|
||||
projectRazorJson.Configuration,
|
||||
projectRazorJson.RootNamespace,
|
||||
projectRazorJson.ProjectWorkspaceState,
|
||||
projectRazorJson.Documents)).Verifiable();
|
||||
projectInfo.Configuration,
|
||||
projectInfo.RootNamespace,
|
||||
projectInfo.ProjectWorkspaceState,
|
||||
projectInfo.Documents)).Verifiable();
|
||||
projectService.Setup(service => service.UpdateProject(
|
||||
projectKey,
|
||||
null,
|
||||
|
@ -76,7 +76,7 @@ public class ProjectConfigurationStateSynchronizerTest : LanguageServerTestBase
|
|||
ProjectWorkspaceState.Default,
|
||||
ImmutableArray<DocumentSnapshotHandle>.Empty)).Verifiable();
|
||||
var synchronizer = GetSynchronizer(projectService.Object);
|
||||
var jsonFileDeserializer = CreateJsonFileDeserializer(projectRazorJson);
|
||||
var jsonFileDeserializer = CreateJsonFileDeserializer(projectInfo);
|
||||
var addArgs = new ProjectConfigurationFileChangeEventArgs("/path/to\\obj/project.razor.json", RazorFileChangeKind.Added, jsonFileDeserializer);
|
||||
var enqueueTask = await Dispatcher.RunOnDispatcherThreadAsync(async () =>
|
||||
{
|
||||
|
@ -105,7 +105,7 @@ public class ProjectConfigurationStateSynchronizerTest : LanguageServerTestBase
|
|||
// Arrange
|
||||
var projectService = new Mock<RazorProjectService>(MockBehavior.Strict);
|
||||
var synchronizer = GetSynchronizer(projectService.Object);
|
||||
var jsonFileDeserializer = Mock.Of<JsonFileDeserializer>(d => d.Deserialize<ProjectRazorJson>(It.IsAny<string>()) == null, MockBehavior.Strict);
|
||||
var jsonFileDeserializer = Mock.Of<JsonFileDeserializer>(d => d.Deserialize<RazorProjectInfo>(It.IsAny<string>()) == null, MockBehavior.Strict);
|
||||
var args = new ProjectConfigurationFileChangeEventArgs("/path/to/project.razor.json", RazorFileChangeKind.Added, jsonFileDeserializer);
|
||||
|
||||
// Act
|
||||
|
@ -120,25 +120,25 @@ public class ProjectConfigurationStateSynchronizerTest : LanguageServerTestBase
|
|||
public async Task ProjectConfigurationFileChanged_Added_AddAndUpdatesProject()
|
||||
{
|
||||
// Arrange
|
||||
var projectRazorJson = new ProjectRazorJson(
|
||||
var projectInfo = new RazorProjectInfo(
|
||||
"/path/to/obj/project.razor.json",
|
||||
"path/to/project.csproj",
|
||||
RazorConfiguration.Default,
|
||||
rootNamespace: "TestRootNamespace",
|
||||
new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, LanguageVersion.CSharp5),
|
||||
ImmutableArray<DocumentSnapshotHandle>.Empty);
|
||||
var projectKey = TestProjectKey.Create(Path.GetDirectoryName(projectRazorJson.SerializedFilePath));
|
||||
var projectKey = TestProjectKey.Create(Path.GetDirectoryName(projectInfo.SerializedFilePath));
|
||||
var projectService = new Mock<RazorProjectService>(MockBehavior.Strict);
|
||||
projectService.Setup(service => service.AddProject(projectRazorJson.FilePath, @"path\to\obj", projectRazorJson.Configuration, projectRazorJson.RootNamespace))
|
||||
projectService.Setup(service => service.AddProject(projectInfo.FilePath, @"path\to\obj", projectInfo.Configuration, projectInfo.RootNamespace))
|
||||
.Returns(projectKey);
|
||||
projectService.Setup(service => service.UpdateProject(
|
||||
projectKey,
|
||||
projectRazorJson.Configuration,
|
||||
projectRazorJson.RootNamespace,
|
||||
projectRazorJson.ProjectWorkspaceState,
|
||||
projectRazorJson.Documents)).Verifiable();
|
||||
projectInfo.Configuration,
|
||||
projectInfo.RootNamespace,
|
||||
projectInfo.ProjectWorkspaceState,
|
||||
projectInfo.Documents)).Verifiable();
|
||||
var synchronizer = GetSynchronizer(projectService.Object);
|
||||
var jsonFileDeserializer = CreateJsonFileDeserializer(projectRazorJson);
|
||||
var jsonFileDeserializer = CreateJsonFileDeserializer(projectInfo);
|
||||
var args = new ProjectConfigurationFileChangeEventArgs("/path/to/obj/project.razor.json", RazorFileChangeKind.Added, jsonFileDeserializer);
|
||||
|
||||
// Act
|
||||
|
@ -157,23 +157,23 @@ public class ProjectConfigurationStateSynchronizerTest : LanguageServerTestBase
|
|||
public async Task ProjectConfigurationFileChanged_Removed_ResetsProject()
|
||||
{
|
||||
// Arrange
|
||||
var projectRazorJson = new ProjectRazorJson(
|
||||
var projectInfo = new RazorProjectInfo(
|
||||
"/path/to/obj/project.razor.json",
|
||||
"path/to/project.csproj",
|
||||
RazorConfiguration.Default,
|
||||
rootNamespace: "TestRootNamespace",
|
||||
new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, LanguageVersion.CSharp5),
|
||||
ImmutableArray<DocumentSnapshotHandle>.Empty);
|
||||
var projectKey = TestProjectKey.Create(Path.GetDirectoryName(projectRazorJson.SerializedFilePath));
|
||||
var projectKey = TestProjectKey.Create(Path.GetDirectoryName(projectInfo.SerializedFilePath));
|
||||
var projectService = new Mock<RazorProjectService>(MockBehavior.Strict);
|
||||
projectService.Setup(service => service.AddProject(projectRazorJson.FilePath, @"path\to\obj", projectRazorJson.Configuration, projectRazorJson.RootNamespace))
|
||||
projectService.Setup(service => service.AddProject(projectInfo.FilePath, @"path\to\obj", projectInfo.Configuration, projectInfo.RootNamespace))
|
||||
.Returns(projectKey);
|
||||
projectService.Setup(service => service.UpdateProject(
|
||||
projectKey,
|
||||
projectRazorJson.Configuration,
|
||||
projectRazorJson.RootNamespace,
|
||||
projectRazorJson.ProjectWorkspaceState,
|
||||
projectRazorJson.Documents)).Verifiable();
|
||||
projectInfo.Configuration,
|
||||
projectInfo.RootNamespace,
|
||||
projectInfo.ProjectWorkspaceState,
|
||||
projectInfo.Documents)).Verifiable();
|
||||
projectService.Setup(service => service.UpdateProject(
|
||||
projectKey,
|
||||
null,
|
||||
|
@ -181,7 +181,7 @@ public class ProjectConfigurationStateSynchronizerTest : LanguageServerTestBase
|
|||
ProjectWorkspaceState.Default,
|
||||
Array.Empty<DocumentSnapshotHandle>())).Verifiable();
|
||||
var synchronizer = GetSynchronizer(projectService.Object);
|
||||
var jsonFileDeserializer = CreateJsonFileDeserializer(projectRazorJson);
|
||||
var jsonFileDeserializer = CreateJsonFileDeserializer(projectInfo);
|
||||
var addArgs = new ProjectConfigurationFileChangeEventArgs("/path/to/obj/project.razor.json", RazorFileChangeKind.Added, jsonFileDeserializer);
|
||||
var enqueueTask = await Dispatcher.RunOnDispatcherThreadAsync(async () =>
|
||||
{
|
||||
|
@ -208,24 +208,24 @@ public class ProjectConfigurationStateSynchronizerTest : LanguageServerTestBase
|
|||
public async Task ProjectConfigurationFileChanged_Changed_UpdatesProject()
|
||||
{
|
||||
// Arrange
|
||||
var initialProjectRazorJson = new ProjectRazorJson(
|
||||
var initialProjectInfo = new RazorProjectInfo(
|
||||
"/path/to/obj/project.razor.json",
|
||||
"path/to/project.csproj",
|
||||
RazorConfiguration.Default,
|
||||
rootNamespace: "TestRootNamespace",
|
||||
new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, LanguageVersion.CSharp5),
|
||||
ImmutableArray<DocumentSnapshotHandle>.Empty);
|
||||
var projectKey = TestProjectKey.Create(Path.GetDirectoryName(initialProjectRazorJson.SerializedFilePath));
|
||||
var projectKey = TestProjectKey.Create(Path.GetDirectoryName(initialProjectInfo.SerializedFilePath));
|
||||
var projectService = new Mock<RazorProjectService>(MockBehavior.Strict);
|
||||
projectService.Setup(service => service.AddProject(initialProjectRazorJson.FilePath, @"path\to\obj", initialProjectRazorJson.Configuration, initialProjectRazorJson.RootNamespace))
|
||||
projectService.Setup(service => service.AddProject(initialProjectInfo.FilePath, @"path\to\obj", initialProjectInfo.Configuration, initialProjectInfo.RootNamespace))
|
||||
.Returns(projectKey);
|
||||
projectService.Setup(service => service.UpdateProject(
|
||||
projectKey,
|
||||
initialProjectRazorJson.Configuration,
|
||||
initialProjectRazorJson.RootNamespace,
|
||||
initialProjectRazorJson.ProjectWorkspaceState,
|
||||
initialProjectRazorJson.Documents)).Verifiable();
|
||||
var changedProjectRazorJson = new ProjectRazorJson(
|
||||
initialProjectInfo.Configuration,
|
||||
initialProjectInfo.RootNamespace,
|
||||
initialProjectInfo.ProjectWorkspaceState,
|
||||
initialProjectInfo.Documents)).Verifiable();
|
||||
var changedProjectInfo = new RazorProjectInfo(
|
||||
"/path/to/obj/project.razor.json",
|
||||
"path/to/project.csproj",
|
||||
RazorConfiguration.Create(
|
||||
|
@ -237,12 +237,12 @@ public class ProjectConfigurationStateSynchronizerTest : LanguageServerTestBase
|
|||
ImmutableArray<DocumentSnapshotHandle>.Empty);
|
||||
projectService.Setup(service => service.UpdateProject(
|
||||
projectKey,
|
||||
changedProjectRazorJson.Configuration,
|
||||
changedProjectRazorJson.RootNamespace,
|
||||
changedProjectRazorJson.ProjectWorkspaceState,
|
||||
changedProjectRazorJson.Documents)).Verifiable();
|
||||
changedProjectInfo.Configuration,
|
||||
changedProjectInfo.RootNamespace,
|
||||
changedProjectInfo.ProjectWorkspaceState,
|
||||
changedProjectInfo.Documents)).Verifiable();
|
||||
var synchronizer = GetSynchronizer(projectService.Object);
|
||||
var addDeserializer = CreateJsonFileDeserializer(initialProjectRazorJson);
|
||||
var addDeserializer = CreateJsonFileDeserializer(initialProjectInfo);
|
||||
var addArgs = new ProjectConfigurationFileChangeEventArgs("path/to/obj/project.razor.json", RazorFileChangeKind.Added, addDeserializer);
|
||||
|
||||
var enqueueTask = await Dispatcher.RunOnDispatcherThreadAsync(async () =>
|
||||
|
@ -252,7 +252,7 @@ public class ProjectConfigurationStateSynchronizerTest : LanguageServerTestBase
|
|||
}, DisposalToken);
|
||||
await enqueueTask;
|
||||
|
||||
var changedDeserializer = CreateJsonFileDeserializer(changedProjectRazorJson);
|
||||
var changedDeserializer = CreateJsonFileDeserializer(changedProjectInfo);
|
||||
var changedArgs = new ProjectConfigurationFileChangeEventArgs("path/to/obj/project.razor.json", RazorFileChangeKind.Changed, changedDeserializer);
|
||||
|
||||
// Act
|
||||
|
@ -271,24 +271,24 @@ public class ProjectConfigurationStateSynchronizerTest : LanguageServerTestBase
|
|||
public async Task ProjectConfigurationFileChanged_Changed_CantDeserialize_ResetsProject()
|
||||
{
|
||||
// Arrange
|
||||
var initialProjectRazorJson = new ProjectRazorJson(
|
||||
var initialProjectInfo = new RazorProjectInfo(
|
||||
"/path/to/obj/project.razor.json",
|
||||
"path/to/project.csproj",
|
||||
RazorConfiguration.Default,
|
||||
rootNamespace: "TestRootNamespace",
|
||||
new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, LanguageVersion.CSharp5),
|
||||
ImmutableArray<DocumentSnapshotHandle>.Empty);
|
||||
var projectKey = TestProjectKey.Create(Path.GetDirectoryName(initialProjectRazorJson.SerializedFilePath));
|
||||
var projectKey = TestProjectKey.Create(Path.GetDirectoryName(initialProjectInfo.SerializedFilePath));
|
||||
var projectService = new Mock<RazorProjectService>(MockBehavior.Strict);
|
||||
projectService.Setup(service => service.AddProject(initialProjectRazorJson.FilePath, @"path\to\obj", initialProjectRazorJson.Configuration, initialProjectRazorJson.RootNamespace))
|
||||
projectService.Setup(service => service.AddProject(initialProjectInfo.FilePath, @"path\to\obj", initialProjectInfo.Configuration, initialProjectInfo.RootNamespace))
|
||||
.Returns(projectKey);
|
||||
projectService.Setup(service => service.UpdateProject(
|
||||
projectKey,
|
||||
initialProjectRazorJson.Configuration,
|
||||
initialProjectRazorJson.RootNamespace,
|
||||
initialProjectRazorJson.ProjectWorkspaceState,
|
||||
initialProjectRazorJson.Documents)).Verifiable();
|
||||
var changedProjectRazorJson = new ProjectRazorJson(
|
||||
initialProjectInfo.Configuration,
|
||||
initialProjectInfo.RootNamespace,
|
||||
initialProjectInfo.ProjectWorkspaceState,
|
||||
initialProjectInfo.Documents)).Verifiable();
|
||||
var changedProjectInfo = new RazorProjectInfo(
|
||||
"/path/to/obj/project.razor.json",
|
||||
"path/to/project.csproj",
|
||||
RazorConfiguration.Create(
|
||||
|
@ -307,7 +307,7 @@ public class ProjectConfigurationStateSynchronizerTest : LanguageServerTestBase
|
|||
ProjectWorkspaceState.Default,
|
||||
Array.Empty<DocumentSnapshotHandle>())).Verifiable();
|
||||
var synchronizer = GetSynchronizer(projectService.Object);
|
||||
var addDeserializer = CreateJsonFileDeserializer(initialProjectRazorJson);
|
||||
var addDeserializer = CreateJsonFileDeserializer(initialProjectInfo);
|
||||
var addArgs = new ProjectConfigurationFileChangeEventArgs("/path/to/obj/project.razor.json", RazorFileChangeKind.Added, addDeserializer);
|
||||
var enqueueTask = await Dispatcher.RunOnDispatcherThreadAsync(async () =>
|
||||
{
|
||||
|
@ -316,7 +316,7 @@ public class ProjectConfigurationStateSynchronizerTest : LanguageServerTestBase
|
|||
}, DisposalToken);
|
||||
await enqueueTask;
|
||||
|
||||
var changedDeserializer = Mock.Of<JsonFileDeserializer>(d => d.Deserialize<ProjectRazorJson>(It.IsAny<string>()) == null, MockBehavior.Strict);
|
||||
var changedDeserializer = Mock.Of<JsonFileDeserializer>(d => d.Deserialize<RazorProjectInfo>(It.IsAny<string>()) == null, MockBehavior.Strict);
|
||||
var changedArgs = new ProjectConfigurationFileChangeEventArgs("/path/to/obj/project.razor.json", RazorFileChangeKind.Changed, changedDeserializer);
|
||||
|
||||
// Act
|
||||
|
@ -337,7 +337,7 @@ public class ProjectConfigurationStateSynchronizerTest : LanguageServerTestBase
|
|||
// Arrange
|
||||
var projectService = new Mock<RazorProjectService>(MockBehavior.Strict);
|
||||
var synchronizer = GetSynchronizer(projectService.Object);
|
||||
var changedDeserializer = Mock.Of<JsonFileDeserializer>(d => d.Deserialize<ProjectRazorJson>(It.IsAny<string>()) == null, MockBehavior.Strict);
|
||||
var changedDeserializer = Mock.Of<JsonFileDeserializer>(d => d.Deserialize<RazorProjectInfo>(It.IsAny<string>()) == null, MockBehavior.Strict);
|
||||
var changedArgs = new ProjectConfigurationFileChangeEventArgs("/path/to/project.razor.json", RazorFileChangeKind.Changed, changedDeserializer);
|
||||
|
||||
// Act
|
||||
|
@ -356,16 +356,16 @@ public class ProjectConfigurationStateSynchronizerTest : LanguageServerTestBase
|
|||
public async Task ProjectConfigurationFileChanged_RemoveThenAdd_OnlyAdds()
|
||||
{
|
||||
// Arrange
|
||||
var projectRazorJson = new ProjectRazorJson(
|
||||
var projectInfo = new RazorProjectInfo(
|
||||
"/path/to/obj/project.razor.json",
|
||||
"path/to/project.csproj",
|
||||
RazorConfiguration.Default,
|
||||
rootNamespace: "TestRootNamespace",
|
||||
new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, LanguageVersion.CSharp5),
|
||||
ImmutableArray<DocumentSnapshotHandle>.Empty);
|
||||
var projectKey = TestProjectKey.Create(Path.GetDirectoryName(projectRazorJson.SerializedFilePath));
|
||||
var projectKey = TestProjectKey.Create(Path.GetDirectoryName(projectInfo.SerializedFilePath));
|
||||
var projectService = new Mock<RazorProjectService>(MockBehavior.Strict);
|
||||
projectService.Setup(service => service.AddProject(projectRazorJson.FilePath, @"path\to\obj", projectRazorJson.Configuration, projectRazorJson.RootNamespace))
|
||||
projectService.Setup(service => service.AddProject(projectInfo.FilePath, @"path\to\obj", projectInfo.Configuration, projectInfo.RootNamespace))
|
||||
.Returns(projectKey);
|
||||
projectService.Setup(p => p.UpdateProject(
|
||||
projectKey,
|
||||
|
@ -375,10 +375,10 @@ public class ProjectConfigurationStateSynchronizerTest : LanguageServerTestBase
|
|||
It.IsAny<IReadOnlyList<DocumentSnapshotHandle>>()));
|
||||
|
||||
var synchronizer = GetSynchronizer(projectService.Object);
|
||||
var changedDeserializer = CreateJsonFileDeserializer(projectRazorJson);
|
||||
var removedArgs = new ProjectConfigurationFileChangeEventArgs(projectRazorJson.SerializedFilePath, RazorFileChangeKind.Removed, changedDeserializer);
|
||||
var addedArgs = new ProjectConfigurationFileChangeEventArgs(projectRazorJson.SerializedFilePath, RazorFileChangeKind.Added, changedDeserializer);
|
||||
var changedArgs = new ProjectConfigurationFileChangeEventArgs(projectRazorJson.SerializedFilePath, RazorFileChangeKind.Changed, changedDeserializer);
|
||||
var changedDeserializer = CreateJsonFileDeserializer(projectInfo);
|
||||
var removedArgs = new ProjectConfigurationFileChangeEventArgs(projectInfo.SerializedFilePath, RazorFileChangeKind.Removed, changedDeserializer);
|
||||
var addedArgs = new ProjectConfigurationFileChangeEventArgs(projectInfo.SerializedFilePath, RazorFileChangeKind.Added, changedDeserializer);
|
||||
var changedArgs = new ProjectConfigurationFileChangeEventArgs(projectInfo.SerializedFilePath, RazorFileChangeKind.Changed, changedDeserializer);
|
||||
|
||||
// Act
|
||||
var enqueueTask = await Dispatcher.RunOnDispatcherThreadAsync(async () =>
|
||||
|
@ -422,10 +422,10 @@ public class ProjectConfigurationStateSynchronizerTest : LanguageServerTestBase
|
|||
return synchronizer;
|
||||
}
|
||||
|
||||
private static JsonFileDeserializer CreateJsonFileDeserializer(ProjectRazorJson deserializedHandle)
|
||||
private static JsonFileDeserializer CreateJsonFileDeserializer(RazorProjectInfo deserializedHandle)
|
||||
{
|
||||
var deserializer = new Mock<JsonFileDeserializer>(MockBehavior.Strict);
|
||||
deserializer.Setup(deserializer => deserializer.Deserialize<ProjectRazorJson>(It.IsAny<string>()))
|
||||
deserializer.Setup(deserializer => deserializer.Deserialize<RazorProjectInfo>(It.IsAny<string>()))
|
||||
.Returns(deserializedHandle);
|
||||
|
||||
return deserializer.Object;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
|
@ -364,7 +365,7 @@ public class RazorLanguageEndpointTest : LanguageServerTestBase
|
|||
|
||||
private static RazorCodeDocument CreateCodeDocumentWithCSharpProjection(string razorSource, string projectedCSharpSource, IEnumerable<SourceMapping> sourceMappings)
|
||||
{
|
||||
var codeDocument = CreateCodeDocument(razorSource, Array.Empty<TagHelperDescriptor>());
|
||||
var codeDocument = CreateCodeDocument(razorSource, ImmutableArray<TagHelperDescriptor>.Empty);
|
||||
var csharpDocument = RazorCSharpDocument.Create(
|
||||
codeDocument,
|
||||
projectedCSharpSource,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.AspNetCore.Razor.Serialization;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common;
|
||||
using Microsoft.AspNetCore.Razor.Utilities;
|
||||
using Xunit;
|
||||
|
@ -124,14 +124,7 @@ public class ChecksumTests(ITestOutputHelper testOutput) : TestBase(testOutput)
|
|||
[Fact]
|
||||
public void TestTagHelperEquality()
|
||||
{
|
||||
var bytes = RazorTestResources.GetResourceBytes(RazorTestResources.BlazorServerAppTagHelpersJson);
|
||||
|
||||
using var stream = new MemoryStream(bytes);
|
||||
using var reader = new StreamReader(stream);
|
||||
|
||||
var tagHelpers = JsonDataConvert.DeserializeData(reader,
|
||||
static r => r.ReadImmutableArray(
|
||||
static r => ObjectReaders.ReadTagHelper(r, useCache: false)));
|
||||
var tagHelpers = RazorTestResources.BlazorServerAppTagHelpers;
|
||||
|
||||
for (var i = 0; i < tagHelpers.Length; i++)
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Serialization;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Converters;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
|
|
|
@ -9,7 +9,7 @@ using System.Text;
|
|||
using Microsoft.AspNetCore.Mvc.Razor.Extensions;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Serialization;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Converters;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Json.Converters;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
|
@ -24,16 +24,7 @@ public class TagHelperDeltaResultSerializationTest(ITestOutputHelper testOutput)
|
|||
public void TagHelperResolutionResult_DefaultBlazorServerProject_RoundTrips()
|
||||
{
|
||||
// Arrange
|
||||
var bytes = RazorTestResources.GetResourceBytes(RazorTestResources.BlazorServerAppTagHelpersJson);
|
||||
|
||||
ImmutableArray<TagHelperDescriptor> tagHelpers;
|
||||
using (var stream = new MemoryStream(bytes))
|
||||
using (var reader = new StreamReader(stream))
|
||||
{
|
||||
tagHelpers = JsonDataConvert.DeserializeData(reader,
|
||||
static r => r.ReadImmutableArray(
|
||||
static r => ObjectReaders.ReadTagHelper(r, useCache: false)));
|
||||
}
|
||||
var tagHelpers = RazorTestResources.BlazorServerAppTagHelpers;
|
||||
|
||||
var expectedResult = new TagHelperDeltaResult(
|
||||
Delta: true,
|
||||
|
|
|
@ -6,7 +6,8 @@ using System.Linq;
|
|||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.ProjectSystem;
|
||||
using Microsoft.AspNetCore.Razor.Serialization;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Converters;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Json.Converters;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Newtonsoft.Json;
|
||||
|
@ -37,10 +38,10 @@ public class SerializationTest : TestBase
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void ProjectRazorJson_InvalidVersionThrows()
|
||||
public void RazorProjectInfo_InvalidVersionThrows()
|
||||
{
|
||||
// Arrange
|
||||
var projectRazorJson = new ProjectRazorJson(
|
||||
var projectInfo = new RazorProjectInfo(
|
||||
"/path/to/obj/project.razor.json",
|
||||
"/path/to/project.csproj",
|
||||
_configuration,
|
||||
|
@ -48,7 +49,7 @@ public class SerializationTest : TestBase
|
|||
_projectWorkspaceState,
|
||||
ImmutableArray<DocumentSnapshotHandle>.Empty);
|
||||
|
||||
var jsonText = JsonConvert.SerializeObject(projectRazorJson, ProjectRazorJsonJsonConverter.Instance);
|
||||
var jsonText = JsonConvert.SerializeObject(projectInfo, RazorProjectInfoJsonConverter.Instance);
|
||||
Assert.NotNull(jsonText);
|
||||
|
||||
var serializedJObject = JObject.Parse(jsonText);
|
||||
|
@ -58,21 +59,21 @@ public class SerializationTest : TestBase
|
|||
Assert.NotNull(updatedJsonText);
|
||||
|
||||
// Act
|
||||
ProjectRazorJson? deserializedProjectRazorJson = null;
|
||||
Assert.Throws<ProjectRazorJsonSerializationException>(() =>
|
||||
RazorProjectInfo? deserializedProjectInfo = null;
|
||||
Assert.Throws<RazorProjectInfoSerializationException>(() =>
|
||||
{
|
||||
deserializedProjectRazorJson = JsonConvert.DeserializeObject<ProjectRazorJson>(updatedJsonText, ProjectRazorJsonJsonConverter.Instance);
|
||||
deserializedProjectInfo = JsonConvert.DeserializeObject<RazorProjectInfo>(updatedJsonText, RazorProjectInfoJsonConverter.Instance);
|
||||
});
|
||||
|
||||
// Assert
|
||||
Assert.Null(deserializedProjectRazorJson);
|
||||
Assert.Null(deserializedProjectInfo);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ProjectRazorJson_MissingVersionThrows()
|
||||
public void RazorProjectInfo_MissingVersionThrows()
|
||||
{
|
||||
// Arrange
|
||||
var projectRazorJson = new ProjectRazorJson(
|
||||
var projectInfo = new RazorProjectInfo(
|
||||
"/path/to/obj/project.razor.json",
|
||||
"/path/to/project.csproj",
|
||||
_configuration,
|
||||
|
@ -80,7 +81,7 @@ public class SerializationTest : TestBase
|
|||
_projectWorkspaceState,
|
||||
ImmutableArray<DocumentSnapshotHandle>.Empty);
|
||||
|
||||
var jsonText = JsonConvert.SerializeObject(projectRazorJson, ProjectRazorJsonJsonConverter.Instance);
|
||||
var jsonText = JsonConvert.SerializeObject(projectInfo, RazorProjectInfoJsonConverter.Instance);
|
||||
Assert.NotNull(jsonText);
|
||||
|
||||
var serializedJObject = JObject.Parse(jsonText);
|
||||
|
@ -90,23 +91,23 @@ public class SerializationTest : TestBase
|
|||
Assert.NotNull(updatedJsonText);
|
||||
|
||||
// Act
|
||||
ProjectRazorJson? deserializedProjectRazorJson = null;
|
||||
Assert.Throws<ProjectRazorJsonSerializationException>(() =>
|
||||
RazorProjectInfo? deserializedProjectInfo = null;
|
||||
Assert.Throws<RazorProjectInfoSerializationException>(() =>
|
||||
{
|
||||
deserializedProjectRazorJson = JsonConvert.DeserializeObject<ProjectRazorJson>(updatedJsonText, ProjectRazorJsonJsonConverter.Instance);
|
||||
deserializedProjectInfo = JsonConvert.DeserializeObject<RazorProjectInfo>(updatedJsonText, RazorProjectInfoJsonConverter.Instance);
|
||||
});
|
||||
|
||||
// Assert
|
||||
Assert.Null(deserializedProjectRazorJson);
|
||||
Assert.Null(deserializedProjectInfo);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ProjectRazorJson_CanRoundTrip()
|
||||
public void RazorProjectInfo_CanRoundTrip()
|
||||
{
|
||||
// Arrange
|
||||
var legacyDocument = new DocumentSnapshotHandle("/path/to/file.cshtml", "file.cshtml", FileKinds.Legacy);
|
||||
var componentDocument = new DocumentSnapshotHandle("/path/to/otherfile.razor", "otherfile.razor", FileKinds.Component);
|
||||
var projectRazorJson = new ProjectRazorJson(
|
||||
var projectInfo = new RazorProjectInfo(
|
||||
"/path/to/obj/project.razor.json",
|
||||
"/path/to/project.csproj",
|
||||
_configuration,
|
||||
|
@ -114,19 +115,19 @@ public class SerializationTest : TestBase
|
|||
_projectWorkspaceState,
|
||||
ImmutableArray.Create(legacyDocument, componentDocument));
|
||||
|
||||
var jsonText = JsonConvert.SerializeObject(projectRazorJson, ProjectRazorJsonJsonConverter.Instance);
|
||||
var jsonText = JsonConvert.SerializeObject(projectInfo, RazorProjectInfoJsonConverter.Instance);
|
||||
Assert.NotNull(jsonText);
|
||||
|
||||
// Act
|
||||
var deserializedProjectRazorJson = JsonConvert.DeserializeObject<ProjectRazorJson>(jsonText, ProjectRazorJsonJsonConverter.Instance);
|
||||
Assert.NotNull(deserializedProjectRazorJson);
|
||||
var deserializedProjectInfo = JsonConvert.DeserializeObject<RazorProjectInfo>(jsonText, RazorProjectInfoJsonConverter.Instance);
|
||||
Assert.NotNull(deserializedProjectInfo);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(projectRazorJson.FilePath, deserializedProjectRazorJson.FilePath);
|
||||
Assert.Equal(projectRazorJson.Configuration, deserializedProjectRazorJson.Configuration);
|
||||
Assert.Equal(projectRazorJson.RootNamespace, deserializedProjectRazorJson.RootNamespace);
|
||||
Assert.Equal(projectRazorJson.ProjectWorkspaceState, deserializedProjectRazorJson.ProjectWorkspaceState);
|
||||
Assert.Collection(projectRazorJson.Documents.OrderBy(doc => doc.FilePath),
|
||||
Assert.Equal(projectInfo.FilePath, deserializedProjectInfo.FilePath);
|
||||
Assert.Equal(projectInfo.Configuration, deserializedProjectInfo.Configuration);
|
||||
Assert.Equal(projectInfo.RootNamespace, deserializedProjectInfo.RootNamespace);
|
||||
Assert.Equal(projectInfo.ProjectWorkspaceState, deserializedProjectInfo.ProjectWorkspaceState);
|
||||
Assert.Collection(projectInfo.Documents.OrderBy(doc => doc.FilePath),
|
||||
document =>
|
||||
{
|
||||
Assert.Equal(legacyDocument.FilePath, document.FilePath);
|
||||
|
|
|
@ -3,8 +3,11 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Test.Common;
|
||||
|
||||
|
@ -12,6 +15,8 @@ internal static class RazorTestResources
|
|||
{
|
||||
public const string BlazorServerAppTagHelpersJson = "BlazorServerApp.TagHelpers.json";
|
||||
|
||||
private static ImmutableArray<TagHelperDescriptor>? s_blazorServerAppTagHelpers;
|
||||
|
||||
private readonly static Dictionary<(string Name, string? Folder), string> s_textMap = new();
|
||||
private readonly static Dictionary<(string Name, string? Folder), byte[]> s_bytesMap = new();
|
||||
|
||||
|
@ -71,4 +76,24 @@ internal static class RazorTestResources
|
|||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public static ImmutableArray<TagHelperDescriptor> BlazorServerAppTagHelpers
|
||||
{
|
||||
get
|
||||
{
|
||||
return s_blazorServerAppTagHelpers ??= ReadBlazorServerAppTagHelpers();
|
||||
|
||||
static ImmutableArray<TagHelperDescriptor> ReadBlazorServerAppTagHelpers()
|
||||
{
|
||||
var bytes = GetResourceBytes(BlazorServerAppTagHelpersJson);
|
||||
|
||||
using var stream = new MemoryStream(bytes);
|
||||
using var reader = new StreamReader(stream);
|
||||
|
||||
return JsonDataConvert.DeserializeData(reader,
|
||||
static r => r.ReadImmutableArray(
|
||||
static r => ObjectReaders.ReadTagHelper(r, useCache: false)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Serialization;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common;
|
||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
using Xunit;
|
||||
|
|
|
@ -3,10 +3,11 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Serialization;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
@ -25,22 +26,10 @@ public class TagHelperDescriptorSerializationTest : TestBase
|
|||
public void TagHelperDescriptor_DefaultBlazorServerProject_RoundTrips()
|
||||
{
|
||||
// Arrange
|
||||
var bytes = RazorTestResources.GetResourceBytes(RazorTestResources.BlazorServerAppTagHelpersJson);
|
||||
var expectedTagHelpers = RazorTestResources.BlazorServerAppTagHelpers;
|
||||
|
||||
// Act
|
||||
|
||||
// Read in the tag helpers
|
||||
IReadOnlyList<TagHelperDescriptor> expectedTagHelpers;
|
||||
|
||||
using (var stream = new MemoryStream(bytes))
|
||||
using (var reader = new StreamReader(stream))
|
||||
{
|
||||
expectedTagHelpers = JsonDataConvert.DeserializeData(reader,
|
||||
static r => r.ReadArray(
|
||||
static r => ObjectReaders.ReadTagHelper(r, useCache: false)))
|
||||
?? Array.Empty<TagHelperDescriptor>();
|
||||
}
|
||||
|
||||
using var writeStream = new MemoryStream();
|
||||
|
||||
// Serialize the tag helpers to a stream
|
||||
|
@ -53,14 +42,13 @@ public class TagHelperDescriptorSerializationTest : TestBase
|
|||
// Deserialize the tag helpers from the stream we just serialized to.
|
||||
writeStream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
IReadOnlyList<TagHelperDescriptor> actualTagHelpers;
|
||||
ImmutableArray<TagHelperDescriptor> actualTagHelpers;
|
||||
|
||||
using (var reader = new StreamReader(writeStream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true, bufferSize: 4096, leaveOpen: true))
|
||||
{
|
||||
actualTagHelpers = JsonDataConvert.DeserializeData(reader,
|
||||
static r => r.ReadArray(
|
||||
static r => ObjectReaders.ReadTagHelper(r, useCache: false)))
|
||||
?? Array.Empty<TagHelperDescriptor>();
|
||||
static r => r.ReadImmutableArray(
|
||||
static r => ObjectReaders.ReadTagHelper(r, useCache: false)));
|
||||
}
|
||||
|
||||
// Assert
|
||||
|
|
|
@ -2,11 +2,8 @@
|
|||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Serialization;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common;
|
||||
using Microsoft.AspNetCore.Razor.Utilities;
|
||||
using Xunit;
|
||||
|
@ -60,7 +57,7 @@ public class TagHelperDescriptorCacheTest(ITestOutputHelper testOutput) : TestBa
|
|||
// Reads 5 copies of the TagHelpers (with 5x references)
|
||||
for (var i = 0; i < 5; ++i)
|
||||
{
|
||||
var tagHelpersBatch = ReadTagHelpers();
|
||||
var tagHelpersBatch = RazorTestResources.BlazorServerAppTagHelpers;
|
||||
tagHelpers.AddRange(tagHelpersBatch);
|
||||
tagHelpersPerBatch = tagHelpersBatch.Length;
|
||||
}
|
||||
|
@ -77,7 +74,7 @@ public class TagHelperDescriptorCacheTest(ITestOutputHelper testOutput) : TestBa
|
|||
public void GetHashCode_AllTagHelpers_NoCacheIdCollisions()
|
||||
{
|
||||
// Arrange
|
||||
var tagHelpers = ReadTagHelpers();
|
||||
var tagHelpers = RazorTestResources.BlazorServerAppTagHelpers;
|
||||
|
||||
// Act
|
||||
var hashes = new HashSet<int>(tagHelpers.Select(TagHelperDescriptorCache.GetTagHelperDescriptorCacheId));
|
||||
|
@ -85,16 +82,4 @@ public class TagHelperDescriptorCacheTest(ITestOutputHelper testOutput) : TestBa
|
|||
// Assert
|
||||
Assert.Equal(hashes.Count, tagHelpers.Length);
|
||||
}
|
||||
|
||||
private static ImmutableArray<TagHelperDescriptor> ReadTagHelpers()
|
||||
{
|
||||
var bytes = RazorTestResources.GetResourceBytes(RazorTestResources.BlazorServerAppTagHelpersJson);
|
||||
|
||||
using var stream = new MemoryStream(bytes);
|
||||
using var reader = new StreamReader(stream);
|
||||
|
||||
return JsonDataConvert.DeserializeData(reader,
|
||||
static r => r.ReadImmutableArray(
|
||||
static r => ObjectReaders.ReadTagHelper(r, useCache: false)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,12 +20,12 @@ using Xunit.Sdk;
|
|||
|
||||
namespace Microsoft.VisualStudio.LanguageServerClient.Razor.Test;
|
||||
|
||||
public class ProjectRazorJsonPublisherTest : LanguageServerTestBase
|
||||
public class RazorProjectInfoPublisherTest : LanguageServerTestBase
|
||||
{
|
||||
private readonly ProjectSnapshotManagerBase _projectSnapshotManager;
|
||||
private readonly ProjectConfigurationFilePathStore _projectConfigurationFilePathStore;
|
||||
|
||||
public ProjectRazorJsonPublisherTest(ITestOutputHelper testOutput)
|
||||
public RazorProjectInfoPublisherTest(ITestOutputHelper testOutput)
|
||||
: base(testOutput)
|
||||
{
|
||||
_projectSnapshotManager = CreateProjectSnapshotManager(allowNotifyListeners: true);
|
||||
|
@ -45,7 +45,7 @@ public class ProjectRazorJsonPublisherTest : LanguageServerTestBase
|
|||
var initialProjectSnapshot = CreateProjectSnapshot(@"C:\path\to\project.csproj", new ProjectWorkspaceState(tagHelpers, CodeAnalysis.CSharp.LanguageVersion.Preview));
|
||||
var expectedProjectSnapshot = CreateProjectSnapshot(@"C:\path\to\project.csproj", new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, CodeAnalysis.CSharp.LanguageVersion.Preview));
|
||||
var expectedConfigurationFilePath = @"C:\path\to\obj\bin\Debug\project.razor.json";
|
||||
var publisher = new TestProjectRazorJsonPublisher(
|
||||
var publisher = new TestRazorProjectInfoPublisher(
|
||||
_projectConfigurationFilePathStore,
|
||||
onSerializeToFile: (snapshot, configurationFilePath) =>
|
||||
{
|
||||
|
@ -80,7 +80,7 @@ public class ProjectRazorJsonPublisherTest : LanguageServerTestBase
|
|||
var hostProject = new HostProject(@"C:\path\to\project.csproj", @"C:\path\to\obj", RazorConfiguration.Default, rootNamespace: "TestRootNamespace");
|
||||
var hostDocument = new HostDocument(@"C:\path\to\file.razor", "file.razor");
|
||||
_projectSnapshotManager.ProjectAdded(hostProject);
|
||||
var publisher = new TestProjectRazorJsonPublisher(
|
||||
var publisher = new TestRazorProjectInfoPublisher(
|
||||
_projectConfigurationFilePathStore,
|
||||
onSerializeToFile: (snapshot, configurationFilePath) => attemptedToSerialize = true)
|
||||
{
|
||||
|
@ -105,7 +105,7 @@ public class ProjectRazorJsonPublisherTest : LanguageServerTestBase
|
|||
var hostDocument = new HostDocument(@"C:\path\to\file.razor", "file.razor");
|
||||
_projectSnapshotManager.ProjectAdded(hostProject);
|
||||
_projectSnapshotManager.DocumentAdded(hostProject.Key, hostDocument, new EmptyTextLoader(hostDocument.FilePath));
|
||||
var publisher = new TestProjectRazorJsonPublisher(
|
||||
var publisher = new TestRazorProjectInfoPublisher(
|
||||
_projectConfigurationFilePathStore,
|
||||
onSerializeToFile: (snapshot, configurationFilePath) => attemptedToSerialize = true)
|
||||
{
|
||||
|
@ -134,7 +134,7 @@ public class ProjectRazorJsonPublisherTest : LanguageServerTestBase
|
|||
var projectSnapshot = _projectSnapshotManager.GetProjects()[0];
|
||||
var expectedConfigurationFilePath = @"C:\path\to\obj\bin\Debug\project.razor.json";
|
||||
_projectConfigurationFilePathStore.Set(projectSnapshot.Key, expectedConfigurationFilePath);
|
||||
var publisher = new TestProjectRazorJsonPublisher(
|
||||
var publisher = new TestRazorProjectInfoPublisher(
|
||||
_projectConfigurationFilePathStore,
|
||||
onSerializeToFile: (snapshot, configurationFilePath) =>
|
||||
{
|
||||
|
@ -164,7 +164,7 @@ public class ProjectRazorJsonPublisherTest : LanguageServerTestBase
|
|||
var serializationSuccessful = false;
|
||||
var projectSnapshot = CreateProjectSnapshot(@"C:\path\to\project.csproj", new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, CodeAnalysis.CSharp.LanguageVersion.CSharp7_3));
|
||||
var expectedConfigurationFilePath = @"C:\path\to\obj\bin\Debug\project.razor.json";
|
||||
var publisher = new TestProjectRazorJsonPublisher(
|
||||
var publisher = new TestRazorProjectInfoPublisher(
|
||||
_projectConfigurationFilePathStore,
|
||||
onSerializeToFile: (snapshot, configurationFilePath) =>
|
||||
{
|
||||
|
@ -198,7 +198,7 @@ public class ProjectRazorJsonPublisherTest : LanguageServerTestBase
|
|||
var changedProjectSnapshot = CreateProjectSnapshot(@"C:\path\to\project.csproj", new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, CodeAnalysis.CSharp.LanguageVersion.CSharp8));
|
||||
var expectedConfigurationFilePath = @"C:\path\to\obj\bin\Debug\project.razor.json";
|
||||
var aboutToChange = false;
|
||||
var publisher = new TestProjectRazorJsonPublisher(
|
||||
var publisher = new TestRazorProjectInfoPublisher(
|
||||
_projectConfigurationFilePathStore,
|
||||
onSerializeToFile: (snapshot, configurationFilePath) =>
|
||||
{
|
||||
|
@ -243,7 +243,7 @@ public class ProjectRazorJsonPublisherTest : LanguageServerTestBase
|
|||
var attemptedToSerialize = false;
|
||||
var projectSnapshot = CreateProjectSnapshot(@"C:\path\to\project.csproj");
|
||||
var expectedConfigurationFilePath = @"C:\path\to\obj\bin\Debug\project.razor.json";
|
||||
var publisher = new TestProjectRazorJsonPublisher(
|
||||
var publisher = new TestRazorProjectInfoPublisher(
|
||||
_projectConfigurationFilePathStore,
|
||||
onSerializeToFile: (snapshot, configurationFilePath) => attemptedToSerialize = true)
|
||||
{
|
||||
|
@ -273,7 +273,7 @@ public class ProjectRazorJsonPublisherTest : LanguageServerTestBase
|
|||
var firstSnapshot = CreateProjectSnapshot(@"C:\path\to\project.csproj");
|
||||
var secondSnapshot = CreateProjectSnapshot(@"C:\path\to\project.csproj", new[] { @"C:\path\to\file.cshtml" });
|
||||
var expectedConfigurationFilePath = @"C:\path\to\obj\bin\Debug\project.razor.json";
|
||||
var publisher = new TestProjectRazorJsonPublisher(
|
||||
var publisher = new TestRazorProjectInfoPublisher(
|
||||
_projectConfigurationFilePathStore,
|
||||
onSerializeToFile: (snapshot, configurationFilePath) =>
|
||||
{
|
||||
|
@ -306,7 +306,7 @@ public class ProjectRazorJsonPublisherTest : LanguageServerTestBase
|
|||
var firstSnapshot = CreateProjectSnapshot(@"C:\path\to\project.csproj");
|
||||
var secondSnapshot = CreateProjectSnapshot(@"C:\path\to\project.csproj", new[] { @"C:\path\to\file.cshtml" });
|
||||
var expectedConfigurationFilePath = @"C:\path\to\objbin\Debug\project.razor.json";
|
||||
var publisher = new TestProjectRazorJsonPublisher(
|
||||
var publisher = new TestRazorProjectInfoPublisher(
|
||||
_projectConfigurationFilePathStore,
|
||||
onSerializeToFile: (snapshot, configurationFilePath) =>
|
||||
{
|
||||
|
@ -345,7 +345,7 @@ public class ProjectRazorJsonPublisherTest : LanguageServerTestBase
|
|||
"FileName.razor"
|
||||
});
|
||||
var expectedConfigurationFilePath = @"C:\path\to\obj\bin\Debug\project.razor.json";
|
||||
var publisher = new TestProjectRazorJsonPublisher(
|
||||
var publisher = new TestRazorProjectInfoPublisher(
|
||||
_projectConfigurationFilePathStore,
|
||||
onSerializeToFile: (snapshot, configurationFilePath) =>
|
||||
{
|
||||
|
@ -374,7 +374,7 @@ public class ProjectRazorJsonPublisherTest : LanguageServerTestBase
|
|||
public void Publish_UnsetConfigurationFilePath_Noops()
|
||||
{
|
||||
// Arrange
|
||||
var publisher = new TestProjectRazorJsonPublisher(
|
||||
var publisher = new TestRazorProjectInfoPublisher(
|
||||
_projectConfigurationFilePathStore)
|
||||
{
|
||||
_active = true,
|
||||
|
@ -393,7 +393,7 @@ public class ProjectRazorJsonPublisherTest : LanguageServerTestBase
|
|||
var serializationSuccessful = false;
|
||||
var omniSharpProjectSnapshot = CreateProjectSnapshot(@"C:\path\to\project.csproj");
|
||||
var expectedConfigurationFilePath = @"C:\path\to\obj\bin\Debug\project.razor.json";
|
||||
var publisher = new TestProjectRazorJsonPublisher(
|
||||
var publisher = new TestRazorProjectInfoPublisher(
|
||||
_projectConfigurationFilePathStore,
|
||||
onSerializeToFile: (snapshot, configurationFilePath) =>
|
||||
{
|
||||
|
@ -421,7 +421,7 @@ public class ProjectRazorJsonPublisherTest : LanguageServerTestBase
|
|||
var serializationSuccessful = false;
|
||||
var expectedConfigurationFilePath = @"C:\path\to\obj\bin\Debug\project.razor.json";
|
||||
|
||||
var publisher = new TestProjectRazorJsonPublisher(
|
||||
var publisher = new TestRazorProjectInfoPublisher(
|
||||
_projectConfigurationFilePathStore,
|
||||
onSerializeToFile: (snapshot, configurationFilePath) =>
|
||||
{
|
||||
|
@ -455,7 +455,7 @@ public class ProjectRazorJsonPublisherTest : LanguageServerTestBase
|
|||
var serializationSuccessful = false;
|
||||
var expectedConfigurationFilePath = @"C:\path\to\obj\bin\Debug\project.razor.json";
|
||||
|
||||
var publisher = new TestProjectRazorJsonPublisher(
|
||||
var publisher = new TestRazorProjectInfoPublisher(
|
||||
_projectConfigurationFilePathStore,
|
||||
onSerializeToFile: (snapshot, configurationFilePath) =>
|
||||
{
|
||||
|
@ -482,7 +482,7 @@ public class ProjectRazorJsonPublisherTest : LanguageServerTestBase
|
|||
public async Task ProjectRemoved_UnSetPublishFilePath_NoopsAsync()
|
||||
{
|
||||
// Arrange
|
||||
var publisher = new TestProjectRazorJsonPublisher(
|
||||
var publisher = new TestRazorProjectInfoPublisher(
|
||||
_projectConfigurationFilePathStore)
|
||||
{
|
||||
_active = true,
|
||||
|
@ -504,7 +504,7 @@ public class ProjectRazorJsonPublisherTest : LanguageServerTestBase
|
|||
var serializationSuccessful = false;
|
||||
var expectedConfigurationFilePath = @"C:\path\to\obj\bin\Debug\project.razor.json";
|
||||
|
||||
var publisher = new TestProjectRazorJsonPublisher(
|
||||
var publisher = new TestRazorProjectInfoPublisher(
|
||||
_projectConfigurationFilePathStore,
|
||||
onSerializeToFile: (snapshot, configurationFilePath) =>
|
||||
{
|
||||
|
@ -574,7 +574,7 @@ public class ProjectRazorJsonPublisherTest : LanguageServerTestBase
|
|||
func,
|
||||
DisposalToken);
|
||||
|
||||
private class TestProjectRazorJsonPublisher : ProjectRazorJsonPublisher
|
||||
private class TestRazorProjectInfoPublisher : RazorProjectInfoPublisher
|
||||
{
|
||||
private static readonly Mock<LSPEditorFeatureDetector> s_lspEditorFeatureDetector = new(MockBehavior.Strict);
|
||||
|
||||
|
@ -583,14 +583,14 @@ public class ProjectRazorJsonPublisherTest : LanguageServerTestBase
|
|||
private readonly bool _shouldSerialize;
|
||||
private readonly bool _useRealShouldSerialize;
|
||||
|
||||
static TestProjectRazorJsonPublisher()
|
||||
static TestRazorProjectInfoPublisher()
|
||||
{
|
||||
s_lspEditorFeatureDetector
|
||||
.Setup(t => t.IsLSPEditorAvailable())
|
||||
.Returns(true);
|
||||
}
|
||||
|
||||
public TestProjectRazorJsonPublisher(
|
||||
public TestRazorProjectInfoPublisher(
|
||||
ProjectConfigurationFilePathStore projectStatePublishFilePathStore,
|
||||
Action<IProjectSnapshot, string> onSerializeToFile = null,
|
||||
bool shouldSerialize = true,
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче