From 5fbf59ab01742e8cbea0d6c8b5dea55e585e2807 Mon Sep 17 00:00:00 2001 From: Jan Jones Date: Wed, 29 Apr 2026 12:36:12 +0200 Subject: [PATCH] Fix broken run-file test RefDirective_Duplicate --- .../CommandTests/Run/RunFileTests_Directives.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/dotnet.Tests/CommandTests/Run/RunFileTests_Directives.cs b/test/dotnet.Tests/CommandTests/Run/RunFileTests_Directives.cs index 56db0c6c50e8..75f6a2e82d48 100644 --- a/test/dotnet.Tests/CommandTests/Run/RunFileTests_Directives.cs +++ b/test/dotnet.Tests/CommandTests/Run/RunFileTests_Directives.cs @@ -572,6 +572,7 @@ public static class Greeter } """); + // Duplicate #:ref directives are allowed (MSBuild can handle that). File.WriteAllText(filePath, """ #:ref lib.cs #:ref lib.cs @@ -581,8 +582,8 @@ public static class Greeter new DotnetCommand(Log, "run", relativeFilePath) .WithWorkingDirectory(testInstance.Path) .Execute() - .Should().Fail() - .And.HaveStdErrContaining(DirectiveError(filePath, 2, FileBasedProgramsResources.DuplicateDirective, "#:ref lib.cs")); + .Should().Pass() + .And.HaveStdOut("Hello!"); File.WriteAllText(filePath, """ #:ref lib.cs @@ -590,7 +591,6 @@ public static class Greeter Console.WriteLine(MyLib.Greeter.Greet()); """); - // https://github.com/dotnet/sdk/issues/51139: we should detect the duplicate ref new DotnetCommand(Log, "run", relativeFilePath) .WithWorkingDirectory(testInstance.Path) .Execute() @@ -603,7 +603,6 @@ public static class Greeter Console.WriteLine(MyLib.Greeter.Greet()); """); - // https://github.com/dotnet/sdk/issues/51139: we should detect the duplicate ref new DotnetCommand(Log, "run", relativeFilePath) .WithWorkingDirectory(testInstance.Path) .Execute()