Repository: dotnet/roslyn
File: src/Compilers/Core/MSBuildTaskTests/TargetTests.cs (C#)

Code before:

            var compilerApiVersion = Version.Parse(compilerApiVersionString.Substring("roslyn".Length));

            var expectedVersionString = assembly.GetCustomAttributes<AssemblyMetadataAttribute>()
                .Single(a => a.Key == "CurrentCompilerApiVersion")
                .Value ?? string.Empty;
            var expectedVersion = Version.Parse(expectedVersionString);

            Assert.Equal(expectedVersion, compilerApiVersion);
        }

        [Theory]
        [InlineData(".NETCoreApp")]
        [InlineData(".NETFramework")]
        [InlineData(".NETStandard")]
        public void CanImportCSharpTargetsWithDifferentTargetFrameworks(string targetFrameworkIdentifier)
        {
            XmlReader xmlReader = XmlReader.Create(new StringReader($@"
<Project>
    <PropertyGroup>
        <TargetFrameworkIdentifier>{targetFrameworkIdentifier}</TargetFrameworkIdentifier>
        <_TargetFrameworkVersionWithoutV>5.0</_TargetFrameworkVersionWithoutV>
    </PropertyGroup>
    <Import Project=""Microsoft.CSharp.Core.targets"" />
</Project>
"));

            // This test verifies that the C# targets file can be successfully imported 
            // and evaluated for different target frameworks, including .NETCoreApp
            // which has CS8002 suppression logic.
            var instance = CreateProjectInstance(xmlReader);
            Assert.NotNull(instance);
        }

        [Theory]
        [InlineData(".NETCoreApp")]
        [InlineData(".NETFramework")]
        [InlineData(".NETStandard")]
        public void CanImportVisualBasicTargetsWithDifferentTargetFrameworks(string targetFrameworkIdentifier)
        {
            XmlReader xmlReader = XmlReader.Create(new StringReader($@"
<Project>
    <PropertyGroup>
        <TargetFrameworkIdentifier>{targetFrameworkIdentifier}</TargetFrameworkIdentifier>
    </PropertyGroup>
    <Import Project=""Microsoft.VisualBasic.Core.targets"" />
</Project>
"));

            // This test verifies that the Visual Basic targets file can be successfully imported 
            // and evaluated for different target frameworks, including .NETCoreApp

Review comment (suggestion):
@copilot Use raw string literals `"""` for test code snippets

Code after:

            var compilerApiVersion = Version.Parse(compilerApiVersionString.Substring("roslyn".Length));

            var expectedVersionString = assembly.GetCustomAttributes<AssemblyMetadataAttribute>()
                .Single(a => a.Key == "CurrentCompilerApiVersion")
                .Value ?? string.Empty;
            var expectedVersion = Version.Parse(expectedVersionString);

            Assert.Equal(expectedVersion, compilerApiVersion);
        }

        private static ProjectInstance CreateProjectInstance(XmlReader reader)
        {
            Project proj = new Project(reader);

            // add a dummy prepare for build target
            proj.Xml.AddTarget("PrepareForBuild");

            // create a dummy WriteLinesToFile task
            addTask(proj, "WriteLinesToFile", new()
            {
                { "Lines", "System.String[]" },
                { "File", "System.String" },
                { "Overwrite", "System.Boolean" },
                { "WriteOnlyWhenDifferent", "System.Boolean" }
            });

            // dummy makeDir task
            addTask(proj, "MakeDir", new()
            {
                { "Directories", "System.String[]" }
            });

            // dummy Message task
            addTask(proj, "Message", new()
            {
                { "Text", "System.String" },
                { "Importance", "System.String" }
            });

            // create an instance and return it
            return proj.CreateProjectInstance();

            static void addTask(Project proj, string taskName, Dictionary<string, string> parameters)
            {
                var task = proj.Xml.AddUsingTask(taskName, string.Empty, Assembly.GetExecutingAssembly().FullName);
                task.TaskFactory = nameof(DummyTaskFactory);

                var taskParams = task.AddParameterGroup();
                foreach (var kvp in parameters)
                {