зеркало из https://github.com/dotnet/razor.git
Update tests
This commit is contained in:
Родитель
d81dd600c4
Коммит
1e660568b6
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"__Version": 6,
|
||||
"__Version": 7,
|
||||
"ProjectKey": "C:\\Users\\admin\\location\\Kendo.Mvc.Examples\\obj\\Debug\\net7.0\\",
|
||||
"FilePath": "C:\\Users\\admin\\location\\Kendo.Mvc.Examples\\Kendo.Mvc.Examples.csproj",
|
||||
"Configuration": {
|
||||
|
@ -159527,6 +159527,7 @@
|
|||
}
|
||||
}
|
||||
],
|
||||
"UseRoslynTokenizer": false,
|
||||
"CSharpLanguageVersion": 1100
|
||||
},
|
||||
"RootNamespace": "Kendo.Mvc.Examples",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"__Version": 6,
|
||||
"__Version": 7,
|
||||
"ProjectKey": "C:\\Users\\admin\\location\\blazorserver\\obj\\Debug\\net7.0\\",
|
||||
"FilePath": "C:\\Users\\admin\\location\\blazorserver\\blazorserver.csproj",
|
||||
"Configuration": {
|
||||
|
@ -16126,6 +16126,7 @@
|
|||
}
|
||||
}
|
||||
],
|
||||
"UseRoslynTokenizer": false,
|
||||
"CSharpLanguageVersion": 800
|
||||
},
|
||||
"RootNamespace": "blazorserver",
|
||||
|
|
|
@ -30,13 +30,13 @@ internal sealed class ProjectWorkspaceState : IEquatable<ProjectWorkspaceState>
|
|||
|
||||
public static ProjectWorkspaceState Create(
|
||||
ImmutableArray<TagHelperDescriptor> tagHelpers,
|
||||
bool useRoslynTokenizer,
|
||||
bool useRoslynTokenizer = false,
|
||||
LanguageVersion csharpLanguageVersion = LanguageVersion.Default)
|
||||
=> tagHelpers.IsEmpty && csharpLanguageVersion == LanguageVersion.Default
|
||||
? Default
|
||||
: new(tagHelpers, useRoslynTokenizer, csharpLanguageVersion);
|
||||
|
||||
public static ProjectWorkspaceState Create(LanguageVersion csharpLanguageVersion, bool useRoslynTokenizer)
|
||||
public static ProjectWorkspaceState Create(LanguageVersion csharpLanguageVersion, bool useRoslynTokenizer = false)
|
||||
=> csharpLanguageVersion == LanguageVersion.Default
|
||||
? Default
|
||||
: new(ImmutableArray<TagHelperDescriptor>.Empty, useRoslynTokenizer, csharpLanguageVersion);
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System.Collections.Immutable;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using MessagePack;
|
||||
using MessagePack.Resolvers;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
|
@ -12,15 +11,13 @@ using Microsoft.AspNetCore.Razor.Serialization;
|
|||
using Microsoft.AspNetCore.Razor.Serialization.Json;
|
||||
using Microsoft.AspNetCore.Razor.Serialization.MessagePack.Resolvers;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common;
|
||||
using Microsoft.CodeAnalysis.Razor.Logging;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
using MessagePackSerializationFormat = Microsoft.AspNetCore.Razor.Serialization.MessagePack.SerializationFormat;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.ProjectEngineHost.Test.Serialization;
|
||||
|
||||
public class SerializerValidationTest(ITestOutputHelper testOutput) : ToolingTestBase(testOutput)
|
||||
{
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("Kendo.Mvc.Examples.project.razor.json")]
|
||||
[InlineData("project.razor.json")]
|
||||
|
|
|
@ -77,7 +77,7 @@ public class StreamExtensionTests
|
|||
.TagMatchingRuleDescriptor(rule => rule.RequireTagName("tag-name"))
|
||||
.Build();
|
||||
|
||||
var projectWorkspaceState = ProjectWorkspaceState.Create([tagHelper], CodeAnalysis.CSharp.LanguageVersion.Latest);
|
||||
var projectWorkspaceState = ProjectWorkspaceState.Create([tagHelper], useRoslynTokenizer: true, CodeAnalysis.CSharp.LanguageVersion.Latest);
|
||||
|
||||
var projectInfo = new RazorProjectInfo(
|
||||
new ProjectKey("TestProject"),
|
||||
|
|
|
@ -190,11 +190,35 @@ public class ProjectStateGeneratedOutputTest : WorkspaceTestBase
|
|||
// Arrange
|
||||
var csharp8ValidConfiguration = new RazorConfiguration(RazorLanguageVersion.Version_3_0, _hostProject.Configuration.ConfigurationName, _hostProject.Configuration.Extensions);
|
||||
var hostProject = TestProjectData.SomeProject with { Configuration = csharp8ValidConfiguration };
|
||||
var originalWorkspaceState = ProjectWorkspaceState.Create(_someTagHelpers, LanguageVersion.CSharp7);
|
||||
var originalWorkspaceState = ProjectWorkspaceState.Create(_someTagHelpers, useRoslynTokenizer: false, LanguageVersion.CSharp7);
|
||||
var original =
|
||||
ProjectState.Create(ProjectEngineFactoryProvider, hostProject, originalWorkspaceState)
|
||||
.WithAddedHostDocument(_hostDocument, TestMocks.CreateTextLoader("@DateTime.Now", VersionStamp.Default));
|
||||
var changedWorkspaceState = ProjectWorkspaceState.Create(_someTagHelpers, LanguageVersion.CSharp8);
|
||||
var changedWorkspaceState = ProjectWorkspaceState.Create(_someTagHelpers, useRoslynTokenizer: false, LanguageVersion.CSharp8);
|
||||
|
||||
var (originalOutput, originalInputVersion) = await GetOutputAsync(original, _hostDocument, DisposalToken);
|
||||
|
||||
// Act
|
||||
var state = original.WithProjectWorkspaceState(changedWorkspaceState);
|
||||
|
||||
// Assert
|
||||
var (actualOutput, actualInputVersion) = await GetOutputAsync(state, _hostDocument, DisposalToken);
|
||||
Assert.NotSame(originalOutput, actualOutput);
|
||||
Assert.NotEqual(originalInputVersion, actualInputVersion);
|
||||
Assert.Equal(state.ProjectWorkspaceStateVersion, actualInputVersion);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ProjectWorkspaceStateChange_WithProjectWorkspaceState_UseRoslynTokenizerChange_DoesNotCacheOutput()
|
||||
{
|
||||
// Arrange
|
||||
var csharp8ValidConfiguration = new RazorConfiguration(RazorLanguageVersion.Version_3_0, _hostProject.Configuration.ConfigurationName, _hostProject.Configuration.Extensions);
|
||||
var hostProject = TestProjectData.SomeProject with { Configuration = csharp8ValidConfiguration };
|
||||
var originalWorkspaceState = ProjectWorkspaceState.Create(_someTagHelpers, useRoslynTokenizer: false, LanguageVersion.CSharp7);
|
||||
var original =
|
||||
ProjectState.Create(ProjectEngineFactoryProvider, hostProject, originalWorkspaceState)
|
||||
.WithAddedHostDocument(_hostDocument, TestMocks.CreateTextLoader("@DateTime.Now", VersionStamp.Default));
|
||||
var changedWorkspaceState = ProjectWorkspaceState.Create(_someTagHelpers, useRoslynTokenizer: true, LanguageVersion.CSharp7);
|
||||
|
||||
var (originalOutput, originalInputVersion) = await GetOutputAsync(original, _hostDocument, DisposalToken);
|
||||
|
||||
|
|
|
@ -654,7 +654,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
var originalTagHelpers = original.TagHelpers;
|
||||
var originalProjectWorkspaceStateVersion = original.ProjectWorkspaceStateVersion;
|
||||
|
||||
var changed = ProjectWorkspaceState.Create(_projectWorkspaceState.TagHelpers, LanguageVersion.CSharp6);
|
||||
var changed = ProjectWorkspaceState.Create(_projectWorkspaceState.TagHelpers, useRoslynTokenizer: false, LanguageVersion.CSharp6);
|
||||
|
||||
// Act
|
||||
var state = original.WithProjectWorkspaceState(changed);
|
||||
|
@ -727,7 +727,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
_ = original.TagHelpers;
|
||||
_ = original.ProjectWorkspaceStateVersion;
|
||||
|
||||
var changed = ProjectWorkspaceState.Create(original.TagHelpers, original.CSharpLanguageVersion);
|
||||
var changed = ProjectWorkspaceState.Create(original.TagHelpers, original.ProjectWorkspaceState.UseRoslynTokenizer, original.CSharpLanguageVersion);
|
||||
|
||||
// Act
|
||||
var state = original.WithProjectWorkspaceState(changed);
|
||||
|
|
Загрузка…
Ссылка в новой задаче