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

Code before:
    </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
            // which has CS8002 suppression logic.
            var instance = CreateProjectInstance(xmlReader);
            Assert.NotNull(instance);
        }

        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

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

Code after:
                { "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)
                {
                    taskParams.AddParameter(kvp.Key, string.Empty, string.Empty, kvp.Value);
                }

            }
        }

        private static ILogger[] GetTestLoggers([CallerMemberName] string callerName = "")
        {
#if DUMP_MSBUILD_BIN_LOG
            return new ILogger[]
            {
                new Build.Logging.BinaryLogger()
                {
                    Parameters = callerName + ".binlog"
                }
            };
#else
            return Array.Empty<ILogger>();
#endif
        }
    }