Skip to content

TestWriteAfterExit fails on .NET 8 #117

@Bartleby2718

Description

@Bartleby2718

Explanation of the Bug

The test TestWriteAfterExit is affected by a breaking change in .NET 8: FileStream writes when pipe is closed.

Reproduction steps

  1. Target net8.0 in MedallionShell.Tests.csproj and in SampleCommand.csproj
  2. Run TestWriteAfterExit targeting net8.0

Full error output

 TestWriteAfterExit
No source available
 Duration: 158 ms

Message: 
should run on current platform
Expected: No Exception to be thrown
But was: <System.IO.IOException: The pipe is being closed.
at System.IO.RandomAccess.WriteAtOffset(SafeFileHandle handle, ReadOnlySpan`1 buffer, Int64 fileOffset)
at System.IO.Strategies.OSFileStreamStrategy.Write(ReadOnlySpan`1 buffer)
at System.IO.Strategies.OSFileStreamStrategy.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.Strategies.BufferedFileStreamStrategy.Flush(Boolean flushToDisk)
at Medallion.Shell.Streams.ProcessStreamWrapper.<>c.b__22_0(Stream s, Boolean ) in //MedallionShell/Streams/ProcessStreamWrapper.cs:line 49
at Medallion.Shell.Streams.ProcessStreamWrapper.DoWriteOperation[TArg](TArg arg, Action`2 action) in //MedallionShell/Streams/ProcessStreamWrapper.cs:line 155
at Medallion.Shell.Streams.ProcessStreamWrapper.Flush() in /
/MedallionShell/Streams/ProcessStreamWrapper.cs:line 49
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at System.IO.StreamWriter.Write(Char[] buffer)
at Medallion.Shell.Streams.ProcessStreamWriter.WriteLine() in /_/MedallionShell/Streams/ProcessStreamWriter.cs:line 294
at SampleCommand.PlatformCompatibilityTests.TestWriteAfterExit() in C:\Users\bartl\Documents\GitHub\MedallionShell\SampleCommand\PlatformCompatibilityTests.cs:line 58
at Medallion.Shell.Tests.PlatformCompatibilityTest.<>c__DisplayClass10_0.b__0() in C:\Users\bartl\Documents\GitHub\MedallionShell\MedallionShell.Tests\PlatformCompatibilityTest.cs:line 51
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
--- End of stack trace from previous location ---
at NUnit.Framework.Internal.ExceptionHelper.Rethrow(Exception exception)
at NUnit.Framework.Internal.Reflect.DynamicInvokeWithTransparentExceptions(Delegate delegate)
at NUnit.Framework.Internal.ExceptionHelper.RecordException(Delegate parameterlessDelegate, String parameterName)>

Stack Trace: 
PlatformCompatibilityTest.RunTestAsync(Expression`1 testMethod) line 51
GenericAdapter`1.GetResult()
AsyncToSyncAdapter.Await(Func`1 invoke)
TestMethodCommand.RunTestMethod(TestExecutionContext context)
TestMethodCommand.Execute(TestExecutionContext context)
<>c__DisplayClass4_0.b__0()
<>c__DisplayClass1_0`1.b__0(Object _)
1) at Medallion.Shell.Tests.PlatformCompatibilityTest.RunTestAsync(Expression`1 testMethod) in C:\Users\bartl\Documents\GitHub\MedallionShell\MedallionShell.Tests\PlatformCompatibilityTest.cs:line 51
AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
PlatformCompatibilityTest.RunTestAsync(Expression`1 testMethod)
PlatformCompatibilityTest.TestWriteAfterExit() line 22

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions