diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/CodeGenerationIntegrationTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/CodeGenerationIntegrationTest.cs index 6156e55f838..7cc86053e41 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/CodeGenerationIntegrationTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/CodeGenerationIntegrationTest.cs @@ -10,6 +10,8 @@ using Microsoft.AspNetCore.Mvc.Razor.Extensions; using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.Test.Utilities; using Roslyn.Test.Utilities; namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests; @@ -22,8 +24,15 @@ public CodeGenerationIntegrationTest(bool designTime = false) : base(layer: TestProject.Layer.Compiler) { this.designTime = designTime; - BaseCompilation = BaseCompilation.AddReferences( - MetadataReference.CreateFromFile(typeof(TestTagHelperDescriptors).Assembly.Location)); + var testTagHelpers = CSharpCompilation.Create( + assemblyName: "Microsoft.AspNetCore.Razor.Language.Test", + syntaxTrees: + [ + CSharpSyntaxTree.ParseText(TestTagHelperDescriptors.Code), + ], + references: ReferenceUtil.AspNetLatestAll, + options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); + BaseCompilation = BaseCompilation.AddReferences(testTagHelpers.VerifyDiagnostics().EmitToImageReference()); } [IntegrationTestFact] diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/TestTagHelperDescriptors.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/TestTagHelperDescriptors.cs index 96d58b5f8dc..34fc03d46eb 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/TestTagHelperDescriptors.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/TestTagHelperDescriptors.cs @@ -215,7 +215,7 @@ public static IEnumerable EnumTagHelperDescriptors .Name("catch-all") .Metadata(PropertyName("CatchAll")) .AsEnum() - .TypeName($"{typeof(TestTagHelperDescriptors).FullName}.{nameof(MyEnum)}"), + .TypeName("Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors.MyEnum"), }), CreateTagHelperDescriptor( tagName: "input", @@ -227,7 +227,7 @@ public static IEnumerable EnumTagHelperDescriptors .Name("value") .Metadata(PropertyName("Value")) .AsEnum() - .TypeName($"{typeof(TestTagHelperDescriptors).FullName}.{nameof(MyEnum)}"), + .TypeName("Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors.MyEnum"), }), }; } @@ -644,9 +644,17 @@ private class TestType public string BoundProperty { get; set; } } - public enum MyEnum - { - MyValue, - MySecondValue - } + public static readonly string Code = """ + namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests + { + public class TestTagHelperDescriptors + { + public enum MyEnum + { + MyValue, + MySecondValue + } + } + } + """; }