Don't close passed in FileStream handles in constructor (dotnet/coreclr#12253)
authorJeremy Kuhne <jeremy.kuhne@microsoft.com>
Mon, 19 Jun 2017 22:31:01 +0000 (15:31 -0700)
committerGitHub <noreply@github.com>
Mon, 19 Jun 2017 22:31:01 +0000 (15:31 -0700)
commitd737c9b8f0e5cd4e6dad4a84c08d94b182ec9b6f
treeb482e9fc53e04ae62f786c70dde73125356e099f
parent630c1db446d199cb8ba18bda1126f2fbb3de67f0
Don't close passed in FileStream handles in constructor (dotnet/coreclr#12253)

* Don't close passed in FileStream handles in constructor

As the finalizer will run when throwing we need to be
careful to make sure we don't put the passed-in handle
in the member field until we're sure we've succeeeded.

Additionally we need to make sure any wrapping SafeHandle
we create on a passed in IntPtr isn't collected.

* Move platform specific assertion and add comment.

* Comment- fix mistake in CanSeekCore

Commit migrated from https://github.com/dotnet/coreclr/commit/8a8bda14a618b14264cb85c012e097b3e01992e9
src/coreclr/src/mscorlib/shared/System/IO/FileStream.Unix.cs
src/coreclr/src/mscorlib/shared/System/IO/FileStream.Windows.cs
src/coreclr/src/mscorlib/shared/System/IO/FileStream.cs