diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ModelExpressionPassTest.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ModelExpressionPassTest.cs index 86ac59f29a5..ac71330be11 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ModelExpressionPassTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ModelExpressionPassTest.cs @@ -8,7 +8,8 @@ using System.Text; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Intermediate; -using Microsoft.AspNetCore.Razor.Language.Legacy; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Xunit; namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X; @@ -156,6 +157,7 @@ private RazorEngine CreateEngine(params TagHelperDescriptor[] tagHelpers) return RazorProjectEngine.Create(b => { b.Features.Add(new TestTagHelperFeature(tagHelpers)); + b.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); }).Engine; } diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTagHelperPassTest.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTagHelperPassTest.cs index 5d46dac4fe4..10b4e08b859 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTagHelperPassTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTagHelperPassTest.cs @@ -7,6 +7,8 @@ using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Extensions; using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Xunit; using static Microsoft.AspNetCore.Razor.Language.CommonMetadata; @@ -219,6 +221,7 @@ private static RazorEngine CreateEngine(params TagHelperDescriptor[] tagHelpers) b.Features.Add(new MvcViewDocumentClassifierPass()); b.Features.Add(new TestTagHelperFeature(tagHelpers)); + b.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); }).Engine; } diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/InjectDirectiveTest.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/InjectDirectiveTest.cs index effa4c063c9..424cd2d25fc 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/InjectDirectiveTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/InjectDirectiveTest.cs @@ -3,9 +3,10 @@ #nullable disable -using System.Text; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Xunit; namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X; @@ -180,6 +181,7 @@ private RazorEngine CreateEngine() // Notice we're not registering the InjectDirective.Pass here so we can run it on demand. b.AddDirective(InjectDirective.Directive); b.AddDirective(ModelDirective.Directive); + b.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); }).Engine; } diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ModelExpressionPassTest.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ModelExpressionPassTest.cs index 0d31134cc5d..a96752a9de9 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ModelExpressionPassTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ModelExpressionPassTest.cs @@ -7,6 +7,8 @@ using System.Text; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Xunit; namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X; @@ -154,6 +156,7 @@ private RazorEngine CreateEngine(params TagHelperDescriptor[] tagHelpers) return RazorProjectEngine.Create(b => { b.Features.Add(new TestTagHelperFeature(tagHelpers)); + b.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); }).Engine; } diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/PageDirectiveTest.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/PageDirectiveTest.cs index 4d3a1420ec6..378e06a960b 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/PageDirectiveTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/PageDirectiveTest.cs @@ -6,6 +6,8 @@ using System.Collections.Immutable; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Xunit; namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X; @@ -128,6 +130,7 @@ private RazorEngine CreateEngine() return RazorProjectEngine.Create(b => { PageDirective.Register(b); + b.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); }).Engine; } diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTagHelperPassTest.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTagHelperPassTest.cs index aa07f59f81d..ed86454092e 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTagHelperPassTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTagHelperPassTest.cs @@ -7,6 +7,8 @@ using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Extensions; using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Xunit; using static Microsoft.AspNetCore.Razor.Language.CommonMetadata; @@ -217,8 +219,8 @@ private static RazorProjectEngine CreateProjectEngine(params TagHelperDescriptor return RazorProjectEngine.Create(b => { b.Features.Add(new MvcViewDocumentClassifierPass()); - b.Features.Add(new TestTagHelperFeature(tagHelpers)); + b.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); }); } diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ModelExpressionPassTest.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ModelExpressionPassTest.cs index f97fab6b120..c877ecbc534 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ModelExpressionPassTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ModelExpressionPassTest.cs @@ -7,6 +7,8 @@ using System.Text; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Xunit; namespace Microsoft.AspNetCore.Mvc.Razor.Extensions; @@ -154,6 +156,7 @@ private RazorEngine CreateEngine(params TagHelperDescriptor[] tagHelpers) return RazorProjectEngine.Create(b => { b.Features.Add(new TestTagHelperFeature(tagHelpers)); + b.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); }).Engine; } diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/PageDirectiveTest.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/PageDirectiveTest.cs index 2bafe5f7480..19fcf5ae712 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/PageDirectiveTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/PageDirectiveTest.cs @@ -6,6 +6,8 @@ using System.Collections.Immutable; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Xunit; namespace Microsoft.AspNetCore.Mvc.Razor.Extensions; @@ -128,6 +130,7 @@ private RazorEngine CreateEngine() return RazorProjectEngine.Create(b => { PageDirective.Register(b); + b.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); }).Engine; } diff --git a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTagHelperPassTest.cs b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTagHelperPassTest.cs index 6fcaffb9f0a..2596851d7ff 100644 --- a/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTagHelperPassTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTagHelperPassTest.cs @@ -7,6 +7,8 @@ using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Extensions; using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Xunit; using static Microsoft.AspNetCore.Razor.Language.CommonMetadata; @@ -217,8 +219,8 @@ private RazorProjectEngine CreateProjectEngine(params TagHelperDescriptor[] tagH return RazorProjectEngine.Create(b => { b.Features.Add(new MvcViewDocumentClassifierPass()); - b.Features.Add(new TestTagHelperFeature(tagHelpers)); + b.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); }); } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorIntermediateNodeLoweringPhaseIntegrationTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorIntermediateNodeLoweringPhaseIntegrationTest.cs index 88f537b936e..52d39459102 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorIntermediateNodeLoweringPhaseIntegrationTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorIntermediateNodeLoweringPhaseIntegrationTest.cs @@ -9,6 +9,8 @@ using Microsoft.AspNetCore.Razor.Language.Extensions; using Microsoft.AspNetCore.Razor.Language.Intermediate; using Microsoft.AspNetCore.Razor.Language.Legacy; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Moq; using Xunit; using static Microsoft.AspNetCore.Razor.Language.CommonMetadata; @@ -465,6 +467,7 @@ private static DocumentIntermediateNode Lower( b.AddTagHelpers(tagHelpers); b.Features.Add(new DesignTimeOptionsFeature(designTime)); + b.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); }; var projectEngine = RazorProjectEngine.Create(configureEngine); diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorTagHelperBinderPhaseTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorTagHelperBinderPhaseTest.cs index e8d4c35a4b5..664d84b36fb 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorTagHelperBinderPhaseTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorTagHelperBinderPhaseTest.cs @@ -9,6 +9,8 @@ using Microsoft.AspNetCore.Razor.Language.Components; using Microsoft.AspNetCore.Razor.Language.Legacy; using Microsoft.AspNetCore.Razor.Language.Syntax; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Xunit; using static Microsoft.AspNetCore.Razor.Language.CommonMetadata; @@ -25,6 +27,7 @@ public void Execute_CanHandleSingleLengthAddTagHelperDirective() // Arrange var projectEngine = RazorProjectEngine.Create(builder => { + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); builder.AddTagHelpers([]); }); @@ -64,6 +67,7 @@ public void Execute_CanHandleSingleLengthRemoveTagHelperDirective() // Arrange var projectEngine = RazorProjectEngine.Create(builder => { + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); builder.AddTagHelpers([]); }); @@ -103,6 +107,7 @@ public void Execute_CanHandleSingleLengthTagHelperPrefix() // Arrange var projectEngine = RazorProjectEngine.Create(builder => { + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); builder.AddTagHelpers([]); }); @@ -142,6 +147,7 @@ public void Execute_RewritesTagHelpers() // Arrange var projectEngine = RazorProjectEngine.Create(builder => { + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); builder.AddTagHelpers( [ CreateTagHelperDescriptor( @@ -242,7 +248,11 @@ public void Execute_NullTagHelperDescriptorsFromCodeDocument_FallsBackToTagHelpe typeName: "TestInputTagHelper", assemblyName: "TestAssembly"), }; - var projectEngine = RazorProjectEngine.Create(builder => builder.AddTagHelpers(tagHelpers)); + var projectEngine = RazorProjectEngine.Create(builder => + { + builder.AddTagHelpers(tagHelpers); + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); + }); var discoveryPhase = new DefaultRazorTagHelperContextDiscoveryPhase() { @@ -287,7 +297,11 @@ public void Execute_EmptyTagHelperDescriptorsFromCodeDocument_DoesNotFallbackToT typeName: "TestInputTagHelper", assemblyName: "TestAssembly"), }; - var projectEngine = RazorProjectEngine.Create(builder => builder.AddTagHelpers(tagHelpers)); + var projectEngine = RazorProjectEngine.Create(builder => + { + builder.AddTagHelpers(tagHelpers); + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); + }); var phase = new DefaultRazorTagHelperContextDiscoveryPhase() { @@ -334,6 +348,7 @@ public void Execute_DirectiveWithoutQuotes_RewritesTagHelpers_TagHelperMatchesEl var projectEngine = RazorProjectEngine.Create(builder => { builder.AddTagHelpers([descriptor]); + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); }); var discoveryPhase = new DefaultRazorTagHelperContextDiscoveryPhase() @@ -393,6 +408,7 @@ public void Execute_DirectiveWithQuotes_RewritesTagHelpers_TagHelperMatchesEleme var projectEngine = RazorProjectEngine.Create(builder => { builder.AddTagHelpers([descriptor]); + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); }); var discoveryPhase = new DefaultRazorTagHelperContextDiscoveryPhase() @@ -440,7 +456,11 @@ public void Execute_TagHelpersFromCodeDocumentAndFeature_PrefersCodeDocument() typeName: "TestInputTagHelper", assemblyName: "TestAssembly"), }; - var projectEngine = RazorProjectEngine.Create(builder => builder.AddTagHelpers(featureTagHelpers)); + var projectEngine = RazorProjectEngine.Create(builder => + { + builder.AddTagHelpers(featureTagHelpers); + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); + }); var discoveryPhase = new DefaultRazorTagHelperContextDiscoveryPhase() { @@ -508,6 +528,7 @@ public void Execute_NoopsWhenNoTagHelperDescriptorsAreResolved() // Arrange var projectEngine = RazorProjectEngine.Create(builder => { + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); builder.Features.Add(new TestTagHelperFeature()); }); @@ -537,6 +558,7 @@ public void Execute_SetsTagHelperDocumentContext() // Arrange var projectEngine = RazorProjectEngine.Create(builder => { + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); builder.Features.Add(new TestTagHelperFeature()); }); @@ -566,6 +588,7 @@ public void Execute_CombinesErrorsOnRewritingErrors() // Arrange var projectEngine = RazorProjectEngine.Create(builder => { + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); builder.AddTagHelpers( [ CreateTagHelperDescriptor( diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/DirectiveRemovalOptimizationPassTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/DirectiveRemovalOptimizationPassTest.cs index fdb17caf229..9d31766b80a 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/DirectiveRemovalOptimizationPassTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/DirectiveRemovalOptimizationPassTest.cs @@ -3,9 +3,10 @@ #nullable disable -using System; using System.Linq; using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Xunit; using static Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeAssert; @@ -23,6 +24,7 @@ public void Execute_Custom_RemovesDirectiveNodeFromDocument() var defaultEngine = RazorProjectEngine.Create(b => { b.AddDirective(DirectiveDescriptor.CreateDirective("custom", DirectiveKind.SingleLine, d => d.AddStringToken())); + b.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); }).Engine; var documentNode = Lower(codeDocument, defaultEngine); var pass = new DirectiveRemovalOptimizationPass() @@ -57,6 +59,7 @@ public void Execute_MultipleCustomDirectives_RemovesDirectiveNodesFromDocument() var defaultEngine = RazorProjectEngine.Create(b => { b.AddDirective(DirectiveDescriptor.CreateDirective("custom", DirectiveKind.SingleLine, d => d.AddStringToken())); + b.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); }).Engine; var documentNode = Lower(codeDocument, defaultEngine); var pass = new DirectiveRemovalOptimizationPass() @@ -88,6 +91,7 @@ public void Execute_DirectiveWithError_PreservesDiagnosticsAndRemovesDirectiveNo var codeDocument = RazorCodeDocument.Create(sourceDocument); var defaultEngine = RazorProjectEngine.Create(b => { + b.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); b.AddDirective(DirectiveDescriptor.CreateDirective("custom", DirectiveKind.SingleLine, d => d.AddStringToken())); }).Engine; var documentNode = Lower(codeDocument, defaultEngine); diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Extensions/DefaultTagHelperOptimizationPassTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Extensions/DefaultTagHelperOptimizationPassTest.cs index 64de74b4188..c5a12a8cbd6 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Extensions/DefaultTagHelperOptimizationPassTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Extensions/DefaultTagHelperOptimizationPassTest.cs @@ -5,6 +5,8 @@ using System.Linq; using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Xunit; using static Microsoft.AspNetCore.Razor.Language.CommonMetadata; @@ -92,6 +94,7 @@ private RazorEngine CreateEngine(params TagHelperDescriptor[] tagHelpers) return RazorProjectEngine.Create(b => { b.Features.Add(new TestTagHelperFeature(tagHelpers)); + b.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); }).Engine; } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Extensions/MetadataAttributePassTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Extensions/MetadataAttributePassTest.cs index 7891fc15c81..49d8c778835 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Extensions/MetadataAttributePassTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Extensions/MetadataAttributePassTest.cs @@ -6,6 +6,8 @@ using System.Collections.Immutable; using Microsoft.AspNetCore.Razor.Language.Components; using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Xunit; using static Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeAssert; @@ -452,6 +454,7 @@ private static RazorEngine CreateEngine() { return RazorProjectEngine.Create(b => { + b.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); b.Features.Add(new DefaultMetadataIdentifierFeature()); }).Engine; } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Extensions/SectionDirectivePassTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Extensions/SectionDirectivePassTest.cs index ebed51ddcf7..a76e12b000a 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Extensions/SectionDirectivePassTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Extensions/SectionDirectivePassTest.cs @@ -4,6 +4,8 @@ #nullable disable using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Xunit; using static Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeAssert; @@ -83,6 +85,7 @@ private static RazorProjectEngine CreateProjectEngine() return RazorProjectEngine.Create(b => { SectionDirective.Register(b); + b.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); }); } diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor/test/CompilationTagHelperFeatureTest.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor/test/CompilationTagHelperFeatureTest.cs index e93e5617c6e..ce7156f1c60 100644 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor/test/CompilationTagHelperFeatureTest.cs +++ b/src/Compiler/Microsoft.CodeAnalysis.Razor/test/CompilationTagHelperFeatureTest.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.TagHelpers; using Microsoft.CodeAnalysis.CSharp; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Moq; using Xunit; @@ -76,6 +77,7 @@ public void GetDescriptors_DoesNotSetCompilation_IfCompilationIsInvalid() var engine = RazorProjectEngine.Create( configure => { + configure.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); configure.Features.Add(new DefaultMetadataReferenceFeature()); configure.Features.Add(provider.Object); configure.Features.Add(new CompilationTagHelperFeature()); @@ -111,6 +113,7 @@ public void GetDescriptors_SetsCompilation_IfCompilationIsValid() var engine = RazorProjectEngine.Create( configure => { + configure.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); configure.Features.Add(new DefaultMetadataReferenceFeature { References = references }); configure.Features.Add(provider.Object); configure.Features.Add(new CompilationTagHelperFeature()); diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor/test/RazorProjectEngineBuilderExtensionsTest.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor/test/RazorProjectEngineBuilderExtensionsTest.cs index 346ea440f59..0455fb3cc31 100644 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor/test/RazorProjectEngineBuilderExtensionsTest.cs +++ b/src/Compiler/Microsoft.CodeAnalysis.Razor/test/RazorProjectEngineBuilderExtensionsTest.cs @@ -5,6 +5,8 @@ using System.Linq; using Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Xunit; using static Microsoft.CodeAnalysis.Razor.RazorProjectEngineBuilderExtensions; @@ -22,6 +24,7 @@ public void SetCSharpLanguageVersion_ResolvesNonNumericCSharpLangVersions() var projectEngine = RazorProjectEngine.Create(builder => { builder.SetCSharpLanguageVersion(csharpLanguageVersion); + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default.WithLanguageVersion(csharpLanguageVersion))); }); // Assert diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/RazorOnAutoInsertProviderTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/RazorOnAutoInsertProviderTestBase.cs index c5e809d705a..e0f3a6c9941 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/RazorOnAutoInsertProviderTestBase.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/RazorOnAutoInsertProviderTestBase.cs @@ -7,9 +7,11 @@ using System.Collections.Generic; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Test.Common.LanguageServer; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Razor.AutoInsert; using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Text; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Microsoft.VisualStudio.LanguageServer.Protocol; using Xunit; using Xunit.Abstractions; @@ -59,7 +61,10 @@ private static RazorCodeDocument CreateCodeDocument(SourceText text, string path fileKind ??= FileKinds.Component; tagHelpers ??= Array.Empty(); var sourceDocument = RazorSourceDocument.Create(text, RazorSourceDocumentProperties.Create(path, path)); - var projectEngine = RazorProjectEngine.Create(builder => { }); + var projectEngine = RazorProjectEngine.Create(builder => + { + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); + }); var codeDocument = projectEngine.ProcessDesignTime(sourceDocument, fileKind, importSources: default, tagHelpers); return codeDocument; } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/CSharp/DefaultCSharpCodeActionProviderTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/CSharp/DefaultCSharpCodeActionProviderTest.cs index 2f668586916..f11d350837b 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/CSharp/DefaultCSharpCodeActionProviderTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/CSharp/DefaultCSharpCodeActionProviderTest.cs @@ -11,10 +11,12 @@ using Microsoft.AspNetCore.Razor.LanguageServer.Hosting; using Microsoft.AspNetCore.Razor.Test.Common.LanguageServer; using Microsoft.AspNetCore.Razor.Test.Common.Workspaces; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Razor.ProjectSystem; using Microsoft.CodeAnalysis.Razor.Protocol.CodeActions; using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Text; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Microsoft.VisualStudio.LanguageServer.Protocol; using Moq; using Xunit; @@ -323,7 +325,11 @@ private static RazorCodeActionContext CreateRazorCodeActionContext( { var tagHelpers = ImmutableArray.Empty; var sourceDocument = TestRazorSourceDocument.Create(text, filePath: filePath, relativePath: filePath); - var projectEngine = RazorProjectEngine.Create(builder => builder.AddTagHelpers(tagHelpers)); + var projectEngine = RazorProjectEngine.Create(builder => + { + builder.AddTagHelpers(tagHelpers); + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); + }); var codeDocument = projectEngine.ProcessDesignTime(sourceDocument, FileKinds.Component, importSources: default, tagHelpers); var csharpDocument = codeDocument.GetCSharpDocument(); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/CSharp/TypeAccessibilityCodeActionProviderTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/CSharp/TypeAccessibilityCodeActionProviderTest.cs index 86d1b8239e5..4a48e62efb9 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/CSharp/TypeAccessibilityCodeActionProviderTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/CSharp/TypeAccessibilityCodeActionProviderTest.cs @@ -12,10 +12,12 @@ using Microsoft.AspNetCore.Razor.LanguageServer.CodeActions.Models; using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.AspNetCore.Razor.Test.Common.LanguageServer; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Razor.ProjectSystem; using Microsoft.CodeAnalysis.Razor.Protocol; using Microsoft.CodeAnalysis.Razor.Protocol.CodeActions; using Microsoft.CodeAnalysis.Text; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Microsoft.VisualStudio.LanguageServer.Protocol; using Moq; using Xunit; @@ -454,6 +456,7 @@ private static RazorCodeActionContext CreateRazorCodeActionContext( { builder.AddTagHelpers(tagHelpers); builder.AddDirective(InjectDirective.Directive); + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); }); var codeDocument = projectEngine.ProcessDesignTime(sourceDocument, FileKinds.Component, importSources: default, tagHelpers); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/CodeActionEndpointTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/CodeActionEndpointTest.cs index 882c953ce78..ea7425ad5c4 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/CodeActionEndpointTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/CodeActionEndpointTest.cs @@ -14,11 +14,13 @@ using Microsoft.AspNetCore.Razor.LanguageServer.Hosting; using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.AspNetCore.Razor.Test.Common.LanguageServer; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Razor.DocumentMapping; using Microsoft.CodeAnalysis.Razor.Protocol; using Microsoft.CodeAnalysis.Razor.Protocol.CodeActions; using Microsoft.CodeAnalysis.Razor.Workspaces; using Microsoft.CodeAnalysis.Text; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Microsoft.VisualStudio.LanguageServer.Protocol; using Moq; using Xunit; @@ -623,7 +625,10 @@ private static IDocumentMappingService CreateDocumentMappingService(LinePosition private static RazorCodeDocument CreateCodeDocument(string text) { var sourceDocument = TestRazorSourceDocument.Create(text); - var projectEngine = RazorProjectEngine.Create(builder => { }); + var projectEngine = RazorProjectEngine.Create(builder => + { + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); + }); return projectEngine.ProcessDesignTime(sourceDocument, "mvc", importSources: [], tagHelpers: []); } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/Html/DefaultHtmlCodeActionProviderTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/Html/DefaultHtmlCodeActionProviderTest.cs index 8bcc81013b1..e948ebdb666 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/Html/DefaultHtmlCodeActionProviderTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/Html/DefaultHtmlCodeActionProviderTest.cs @@ -10,11 +10,13 @@ using Microsoft.AspNetCore.Razor.LanguageServer.CodeActions.Models; using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.AspNetCore.Razor.Test.Common.LanguageServer; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Razor.DocumentMapping; using Microsoft.CodeAnalysis.Razor.ProjectSystem; using Microsoft.CodeAnalysis.Razor.Protocol.CodeActions; using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Text; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Microsoft.VisualStudio.LanguageServer.Protocol; using Moq; using Xunit; @@ -148,7 +150,11 @@ private static RazorCodeActionContext CreateRazorCodeActionContext( { var tagHelpers = ImmutableArray.Empty; var sourceDocument = TestRazorSourceDocument.Create(text, filePath: filePath, relativePath: filePath); - var projectEngine = RazorProjectEngine.Create(builder => builder.AddTagHelpers(tagHelpers)); + var projectEngine = RazorProjectEngine.Create(builder => + { + builder.AddTagHelpers(tagHelpers); + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); + }); var codeDocument = projectEngine.ProcessDesignTime(sourceDocument, FileKinds.Component, importSources: default, tagHelpers); var documentSnapshot = Mock.Of(document => diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/Razor/ComponentAccessibilityCodeActionProviderTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/Razor/ComponentAccessibilityCodeActionProviderTest.cs index 2a0e033c4b5..0fc53c12226 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/Razor/ComponentAccessibilityCodeActionProviderTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/Razor/ComponentAccessibilityCodeActionProviderTest.cs @@ -8,10 +8,12 @@ using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Components; using Microsoft.AspNetCore.Razor.Test.Common.LanguageServer; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Razor.ProjectSystem; using Microsoft.CodeAnalysis.Razor.Protocol.CodeActions; using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Text; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Microsoft.VisualStudio.LanguageServer.Protocol; using Moq; using Xunit; @@ -454,7 +456,11 @@ private static RazorCodeActionContext CreateRazorCodeActionContext(VSCodeActionP var tagHelpers = ImmutableArray.Create(shortComponent.Build(), fullyQualifiedComponent.Build(), shortGenericComponent.Build(), fullyQualifiedGenericComponent.Build()); var sourceDocument = TestRazorSourceDocument.Create(text, filePath: filePath, relativePath: filePath); - var projectEngine = RazorProjectEngine.Create(builder => builder.AddTagHelpers(tagHelpers)); + var projectEngine = RazorProjectEngine.Create(builder => + { + builder.AddTagHelpers(tagHelpers); + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); + }); var codeDocument = projectEngine.ProcessDesignTime(sourceDocument, FileKinds.Component, importSources: default, tagHelpers); var csharpDocument = codeDocument.GetCSharpDocument(); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Completion/DirectiveAttributeTransitionCompletionItemProviderTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Completion/DirectiveAttributeTransitionCompletionItemProviderTest.cs index 62edca4716a..5fea690ab10 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Completion/DirectiveAttributeTransitionCompletionItemProviderTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Completion/DirectiveAttributeTransitionCompletionItemProviderTest.cs @@ -7,8 +7,10 @@ using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Syntax; using Microsoft.AspNetCore.Razor.Test.Common; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Razor.Completion; using Microsoft.CodeAnalysis.Text; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Xunit; using Xunit.Abstractions; @@ -311,7 +313,10 @@ private static RazorSyntaxTree GetSyntaxTree(string text, string fileKind = null { fileKind ??= FileKinds.Component; var sourceDocument = TestRazorSourceDocument.Create(text); - var projectEngine = RazorProjectEngine.Create(builder => { }); + var projectEngine = RazorProjectEngine.Create(builder => + { + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); + }); var codeDocument = projectEngine.ProcessDesignTime(sourceDocument, fileKind, importSources: default, Array.Empty()); var syntaxTree = codeDocument.GetSyntaxTree(); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Completion/TagHelperServiceTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Completion/TagHelperServiceTestBase.cs index 7a2dbb635fc..cdf1730f37d 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Completion/TagHelperServiceTestBase.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Completion/TagHelperServiceTestBase.cs @@ -7,7 +7,9 @@ using Microsoft.AspNetCore.Razor.Language.Components; using Microsoft.AspNetCore.Razor.Test.Common.LanguageServer; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Razor.Completion; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Xunit.Abstractions; using static Microsoft.AspNetCore.Razor.Language.CommonMetadata; @@ -266,7 +268,10 @@ internal static RazorCodeDocument CreateCodeDocument(string text, string filePat tagHelpers = tagHelpers.NullToEmpty(); var sourceDocument = TestRazorSourceDocument.Create(text, filePath: filePath, relativePath: filePath); - var projectEngine = RazorProjectEngine.Create(builder => { }); + var projectEngine = RazorProjectEngine.Create(builder => + { + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); + }); var fileKind = filePath.EndsWith(".razor", StringComparison.Ordinal) ? FileKinds.Component : FileKinds.Legacy; var codeDocument = projectEngine.ProcessDesignTime(sourceDocument, fileKind, importSources: default, tagHelpers); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Debugging/RazorBreakpointSpanEndpointTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Debugging/RazorBreakpointSpanEndpointTest.cs index 7fa3f0ae3e8..ec265930146 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Debugging/RazorBreakpointSpanEndpointTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Debugging/RazorBreakpointSpanEndpointTest.cs @@ -5,8 +5,10 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Test.Common.LanguageServer; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Razor.DocumentMapping; using Microsoft.CodeAnalysis.Razor.Protocol.Debugging; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Microsoft.VisualStudio.LanguageServer.Protocol; using Xunit; using Xunit.Abstractions; @@ -266,7 +268,10 @@ public async Task Handle_InvalidBreakpointSpan_ReturnsNull() private static RazorCodeDocument CreateCodeDocument(string text, string? fileKind = null) { var sourceDocument = TestRazorSourceDocument.Create(text); - var projectEngine = RazorProjectEngine.Create(builder => { }); + var projectEngine = RazorProjectEngine.Create(builder => + { + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); + }); var codeDocument = projectEngine.ProcessDesignTime(sourceDocument, fileKind ?? FileKinds.Legacy, importSources: default, tagHelpers: []); return codeDocument; } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingContentValidationPassTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingContentValidationPassTest.cs index 119c16efd7b..0d62aae1122 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingContentValidationPassTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingContentValidationPassTest.cs @@ -9,10 +9,11 @@ using Microsoft.AspNetCore.Razor.LanguageServer.Test; using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.AspNetCore.Razor.Test.Common.LanguageServer; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Razor.Formatting; using Microsoft.CodeAnalysis.Razor.ProjectSystem; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Moq; using Xunit; using Xunit.Abstractions; @@ -100,7 +101,11 @@ private static (RazorCodeDocument, IDocumentSnapshot) CreateCodeDocumentAndSnaps fileKind ??= FileKinds.Component; tagHelpers = tagHelpers.NullToEmpty(); var sourceDocument = RazorSourceDocument.Create(text, RazorSourceDocumentProperties.Create(path, path)); - var projectEngine = RazorProjectEngine.Create(builder => builder.SetRootNamespace("Test")); + var projectEngine = RazorProjectEngine.Create(builder => + { + builder.SetRootNamespace("Test"); + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); + }); var codeDocument = projectEngine.ProcessDesignTime(sourceDocument, fileKind, importSources: default, tagHelpers); var documentSnapshot = new Mock(MockBehavior.Strict); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingDiagnosticValidationPassTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingDiagnosticValidationPassTest.cs index d3c305d51d9..a667ec5855c 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingDiagnosticValidationPassTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingDiagnosticValidationPassTest.cs @@ -8,9 +8,11 @@ using Microsoft.AspNetCore.Razor.LanguageServer.Test; using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.AspNetCore.Razor.Test.Common.LanguageServer; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Razor.Formatting; using Microsoft.CodeAnalysis.Razor.ProjectSystem; using Microsoft.CodeAnalysis.Text; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Xunit; using Xunit.Abstractions; @@ -97,7 +99,11 @@ private static (RazorCodeDocument, IDocumentSnapshot) CreateCodeDocumentAndSnaps fileKind ??= FileKinds.Component; tagHelpers = tagHelpers.NullToEmpty(); var sourceDocument = RazorSourceDocument.Create(text, RazorSourceDocumentProperties.Create(path, path)); - var projectEngine = RazorProjectEngine.Create(builder => builder.SetRootNamespace("Test")); + var projectEngine = RazorProjectEngine.Create(builder => + { + builder.SetRootNamespace("Test"); + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); + }); var codeDocument = projectEngine.ProcessDesignTime(sourceDocument, fileKind, importSources: default, tagHelpers); var documentSnapshot = FormattingTestBase.CreateDocumentSnapshot(path, tagHelpers, fileKind, importsDocuments: [], imports: [], projectEngine, codeDocument); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RazorDocumentMappingServiceTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RazorDocumentMappingServiceTest.cs index f5eb72e2a2f..105d3d7dfd2 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RazorDocumentMappingServiceTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RazorDocumentMappingServiceTest.cs @@ -1,19 +1,18 @@ // 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.Immutable; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.AspNetCore.Razor.Test.Common.LanguageServer; using Microsoft.AspNetCore.Razor.Test.Common.Workspaces; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Razor.DocumentMapping; -using Microsoft.CodeAnalysis.Razor.Protocol; using Microsoft.CodeAnalysis.Razor.Workspaces; using Microsoft.CodeAnalysis.Text; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Xunit; using Xunit.Abstractions; -using static Microsoft.AspNetCore.Razor.Language.CommonMetadata; namespace Microsoft.AspNetCore.Razor.LanguageServer; @@ -700,7 +699,10 @@ public void TryMapToGeneratedDocumentRange_CSharp_End_LessThan_Start() private static RazorCodeDocument CreateCodeDocumentWithCSharpProjection(string razorSource, string projectedCSharpSource, ImmutableArray sourceMappings) { var sourceDocument = TestRazorSourceDocument.Create(razorSource); - var projectEngine = RazorProjectEngine.Create(builder => { }); + var projectEngine = RazorProjectEngine.Create(builder => + { + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); + }); var codeDocument = projectEngine.ProcessDesignTime(sourceDocument, "mvc", importSources: default, tagHelpers: []); var csharpDocument = new RazorCSharpDocument( diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/TagHelperFactsServiceTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/TagHelperFactsServiceTest.cs index 4e4bba21832..9a3d0016889 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/TagHelperFactsServiceTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/TagHelperFactsServiceTest.cs @@ -8,6 +8,8 @@ using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Syntax; using Microsoft.AspNetCore.Razor.LanguageServer.Completion; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Microsoft.VisualStudio.Editor.Razor; using Xunit; using Xunit.Abstractions; @@ -243,7 +245,10 @@ private static RazorCodeDocument CreateComponentDocument(string text, ImmutableA { tagHelpers = tagHelpers.NullToEmpty(); var sourceDocument = TestRazorSourceDocument.Create(text); - var projectEngine = RazorProjectEngine.Create(builder => { }); + var projectEngine = RazorProjectEngine.Create(builder => + { + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); + }); var codeDocument = projectEngine.ProcessDesignTime(sourceDocument, FileKinds.Component, importSources: default, tagHelpers); return codeDocument; } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Language/IntegrationTests/RazorToolingIntegrationTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Language/IntegrationTests/RazorToolingIntegrationTestBase.cs index 8d4d088e7d9..6126af7a104 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Language/IntegrationTests/RazorToolingIntegrationTestBase.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Language/IntegrationTests/RazorToolingIntegrationTestBase.cs @@ -16,6 +16,7 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Razor; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Xunit; using Xunit.Abstractions; using Xunit.Sdk; @@ -128,6 +129,7 @@ private RazorProjectEngine CreateProjectEngine(RazorConfiguration configuration, }); b.SetCSharpLanguageVersion(CSharpParseOptions.LanguageVersion); + b.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions)); CompilerFeatures.Register(b); }); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Language/Legacy/ToolingParserTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Language/Legacy/ToolingParserTestBase.cs index 7a50ab83643..e9c36530e56 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Language/Legacy/ToolingParserTestBase.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Language/Legacy/ToolingParserTestBase.cs @@ -254,7 +254,7 @@ internal static RazorParserOptions CreateParserOptions( directives.ToArray(), designTime, parseLeadingDirectives: false, - useRoslynTokenizer: false, // PROTOTYPE: switch to true + useRoslynTokenizer: true, version: version, fileKind: fileKind, enableSpanEditHandlers, diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/LanguageServerTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/LanguageServerTestBase.cs index 95ab0722b98..4ed6d98fc3e 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/LanguageServerTestBase.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/LanguageServerTestBase.cs @@ -17,12 +17,14 @@ using Microsoft.AspNetCore.Razor.Test.Common.ProjectSystem; using Microsoft.AspNetCore.Razor.Test.Common.Workspaces; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.ExternalAccess.Razor; using Microsoft.CodeAnalysis.Razor; using Microsoft.CodeAnalysis.Razor.ProjectSystem; using Microsoft.CodeAnalysis.Razor.Workspaces; using Microsoft.CodeAnalysis.Text; using Microsoft.CommonLanguageServerProtocol.Framework; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Microsoft.VisualStudio.LanguageServer.Protocol; using Xunit.Abstractions; @@ -83,6 +85,7 @@ protected static RazorCodeDocument CreateCodeDocument(string text, ImmutableArra } RazorExtensions.Register(b); + b.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); }); var importDocumentName = fileKind == FileKinds.Legacy ? "_ViewImports.cshtml" : "_Imports.razor"; var defaultImportDocument = TestRazorSourceDocument.Create( diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/ProjectSystem/TestProjectSnapshot.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/ProjectSystem/TestProjectSnapshot.cs index 5aab58bb5d5..36da196783d 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/ProjectSystem/TestProjectSnapshot.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/ProjectSystem/TestProjectSnapshot.cs @@ -8,8 +8,10 @@ using Microsoft.AspNetCore.Razor.ProjectEngineHost; using Microsoft.AspNetCore.Razor.ProjectSystem; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Razor.ProjectSystem; using Microsoft.CodeAnalysis.Text; +using Microsoft.NET.Sdk.Razor.SourceGenerators; namespace Microsoft.AspNetCore.Razor.Test.Common.ProjectSystem; @@ -57,6 +59,9 @@ private TestProjectSnapshot(ProjectState state) public override RazorProjectEngine GetProjectEngine() { - return RazorProjectEngine.Create(RazorConfiguration.Default, RazorProjectFileSystem.Create("C:/")); + return RazorProjectEngine.Create( + RazorConfiguration.Default, + RazorProjectFileSystem.Create("C:/"), + b => b.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default))); } } diff --git a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Extensions/RazorCodeDocumentExtensionsTest.cs b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Extensions/RazorCodeDocumentExtensionsTest.cs index 64b1d1c9da1..1b3dd731ac5 100644 --- a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Extensions/RazorCodeDocumentExtensionsTest.cs +++ b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Extensions/RazorCodeDocumentExtensionsTest.cs @@ -1,15 +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; -using System.Collections.Generic; using System.Collections.Immutable; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Test.Common; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Razor.Protocol; +using Microsoft.NET.Sdk.Razor.SourceGenerators; using Xunit; using Xunit.Abstractions; using static Microsoft.AspNetCore.Razor.Language.CommonMetadata; @@ -333,7 +330,10 @@ private static RazorCodeDocument CreateCodeDocument(TestCode code, params Immuta tagHelpers = tagHelpers.NullToEmpty(); var sourceDocument = TestRazorSourceDocument.Create(code.Text); - var projectEngine = RazorProjectEngine.Create(builder => { }); + var projectEngine = RazorProjectEngine.Create(builder => + { + builder.Features.Add(new ConfigureRazorParserOptions(useRoslynTokenizer: true, CSharpParseOptions.Default)); + }); return projectEngine.ProcessDesignTime(sourceDocument, "mvc", importSources: default, tagHelpers); }