-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use checksums for Roslyn OOP communication
This change updates TagHelperDeltaResult to return Checksums for tag helpers that were added and introduces a new OOP API for fetching tag heleprs by checksum. These are used to only fetch tag helpers from Roslyn OOP that aren't already cached by Razor tooling.
- Loading branch information
1 parent
97421c1
commit 5b07c22
Showing
24 changed files
with
611 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...r/src/Microsoft.AspNetCore.Razor.ProjectEngineHost/Serialization/FetchTagHelpersResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// 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.Immutable; | ||
using Microsoft.AspNetCore.Razor.Language; | ||
|
||
namespace Microsoft.AspNetCore.Razor.Serialization; | ||
|
||
internal sealed record FetchTagHelpersResult(ImmutableArray<TagHelperDescriptor> TagHelpers) | ||
{ | ||
public static readonly FetchTagHelpersResult Empty = new(ImmutableArray<TagHelperDescriptor>.Empty); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
....ProjectEngineHost/Serialization/MessagePack/Formatters/FetchTagHelpersResultFormatter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// 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.Immutable; | ||
using MessagePack; | ||
using Microsoft.AspNetCore.Razor.Language; | ||
|
||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters; | ||
|
||
internal sealed class FetchTagHelpersResultFormatter : TopLevelFormatter<FetchTagHelpersResult> | ||
{ | ||
public static readonly TopLevelFormatter<FetchTagHelpersResult> Instance = new FetchTagHelpersResultFormatter(); | ||
|
||
private FetchTagHelpersResultFormatter() | ||
{ | ||
} | ||
|
||
protected override FetchTagHelpersResult Deserialize(ref MessagePackReader reader, SerializerCachingOptions options) | ||
{ | ||
var tagHelpers = reader.Deserialize<ImmutableArray<TagHelperDescriptor>>(options); | ||
|
||
return new(tagHelpers); | ||
} | ||
|
||
protected override void Serialize(ref MessagePackWriter writer, FetchTagHelpersResult value, SerializerCachingOptions options) | ||
{ | ||
writer.SerializeObject(value.TagHelpers, options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...or.ProjectEngineHost/Serialization/MessagePack/Resolvers/FetchTagHelpersResultResolver.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// 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 MessagePack; | ||
using MessagePack.Formatters; | ||
using Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters; | ||
using Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers; | ||
|
||
namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Resolvers; | ||
|
||
internal sealed class FetchTagHelpersResultResolver : IFormatterResolver | ||
{ | ||
public static readonly FetchTagHelpersResultResolver Instance = new(); | ||
|
||
private FetchTagHelpersResultResolver() | ||
{ | ||
} | ||
|
||
public IMessagePackFormatter<T>? GetFormatter<T>() | ||
{ | ||
return Cache<T>.Formatter; | ||
} | ||
|
||
private static class Cache<T> | ||
{ | ||
public static readonly IMessagePackFormatter<T>? Formatter; | ||
|
||
static Cache() | ||
{ | ||
Formatter = (IMessagePackFormatter<T>?)TypeToFormatterMap.GetFormatter(typeof(T)); | ||
} | ||
} | ||
|
||
private static class TypeToFormatterMap | ||
{ | ||
private static readonly Dictionary<Type, object> s_map = new() | ||
{ | ||
FetchTagHelpersResultFormatter.Instance, | ||
|
||
// tag helpers | ||
AllowedChildTagFormatter.Instance, | ||
BoundAttributeFormatter.Instance, | ||
BoundAttributeParameterFormatter.Instance, | ||
DocumentationObjectFormatter.Instance, | ||
MetadataCollectionFormatter.Instance, | ||
RazorDiagnosticFormatter.Instance, | ||
RequiredAttributeFormatter.Instance, | ||
TagHelperFormatter.Instance, | ||
TagMatchingRuleFormatter.Instance | ||
}; | ||
|
||
public static object? GetFormatter(Type t) | ||
{ | ||
if (s_map.TryGetValue(t, out var formatter)) | ||
{ | ||
return formatter; | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.