Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotate FileStream.Lock/Unlock as unsupported on iOS/tvOS #52433

Merged

Conversation

MaximLipnin
Copy link
Contributor

Part of #47910.

FileStream.Lock/Unlock methods throw PNSE with Locking/unlocking file regions is not supported on this platform. Use FileShare on the entire file instead. message.

An example:

<failure exception-type="System.PlatformNotSupportedException">
    <message><![CDATA[System.PlatformNotSupportedException : Locking/unlocking file regions is not supported on this platform. Use FileShare on the entire file instead.]]></message>
    <stack-trace><![CDATA[   at System.IO.Strategies.Net5CompatFileStreamStrategy.Lock(Int64 position, Int64 length) in System.Private.CoreLib.dll:token 0x60055fc+0x5
    at System.IO.FileStream.Lock(Int64 position, Int64 length) in System.Private.CoreLib.dll:token 0x60052ee+0x38
    at System.IO.Tests.FileStream_LockUnlock.NonOverlappingRegions_Success(Int64 fileLength, Int64 firstPosition, Int64 firstLength, Int64 secondPosition, Int64 secondLength) in System.IO.FileSystem.Tests.dll:token 0x60000de+0x3d
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) in System.Private.CoreLib.dll:token 0x6004a23+0x6a]]></stack-trace>
</failure>

@ghost
Copy link

ghost commented May 7, 2021

Tagging subscribers to this area: @carlossanlop
See info in area-owners.md if you want to be subscribed.

Issue Details

Part of #47910.

FileStream.Lock/Unlock methods throw PNSE with Locking/unlocking file regions is not supported on this platform. Use FileShare on the entire file instead. message.

An example:

<failure exception-type="System.PlatformNotSupportedException">
    <message><![CDATA[System.PlatformNotSupportedException : Locking/unlocking file regions is not supported on this platform. Use FileShare on the entire file instead.]]></message>
    <stack-trace><![CDATA[   at System.IO.Strategies.Net5CompatFileStreamStrategy.Lock(Int64 position, Int64 length) in System.Private.CoreLib.dll:token 0x60055fc+0x5
    at System.IO.FileStream.Lock(Int64 position, Int64 length) in System.Private.CoreLib.dll:token 0x60052ee+0x38
    at System.IO.Tests.FileStream_LockUnlock.NonOverlappingRegions_Success(Int64 fileLength, Int64 firstPosition, Int64 firstLength, Int64 secondPosition, Int64 secondLength) in System.IO.FileSystem.Tests.dll:token 0x60000de+0x3d
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) in System.Private.CoreLib.dll:token 0x6004a23+0x6a]]></stack-trace>
</failure>
Author: MaximLipnin
Assignees: -
Labels:

area-System.IO

Milestone: -

@filipnavara
Copy link
Member

filipnavara commented May 7, 2021

Would it make sense to update the test annotations in src/libraries/System.IO.FileSystem/tests/FileStream/LockUnlock.cs along with this change?

ie. replace [SkipOnPlatform(TestPlatforms.OSX, "Not supported on OSX.")] with [SkipOnPlatform(TestPlatforms.OSX | TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Not supported on macOS/iOS/tvOS/MacCatalyst.")]

There's also one [PlatformSpecific(TestPlatforms.OSX)] that should be replaced with [PlatformSpecific(TestPlatforms.OSX | TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)].

@MaximLipnin MaximLipnin force-pushed the annotate_System.IO.FileSystem_as_unsupported branch from 1045ed9 to 529b5c3 Compare May 7, 2021 11:25
@MaximLipnin
Copy link
Contributor Author

MaximLipnin commented May 7, 2021

Would it make sense to update the test annotations in src/libraries/System.IO.FileSystem/tests/FileStream/LockUnlock.cs along with this change?

ie. replace [SkipOnPlatform(TestPlatforms.OSX, "Not supported on OSX.")] with [SkipOnPlatform(TestPlatforms.OSX | TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Not supported on macOS/iOS/tvOS/MacCatalyst.")]

There's also one [PlatformSpecific(TestPlatforms.OSX)] that should be replaced with [PlatformSpecific(TestPlatforms.OSX | TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)].

There is other work to process all the respective tests - #51491

@MaximLipnin MaximLipnin force-pushed the annotate_System.IO.FileSystem_as_unsupported branch 2 times, most recently from 0a50c37 to b1be016 Compare May 11, 2021 14:30
@MaximLipnin MaximLipnin force-pushed the annotate_System.IO.FileSystem_as_unsupported branch from b1be016 to 878ac69 Compare May 12, 2021 07:01
@steveisok steveisok merged commit 2aa5062 into dotnet:main May 12, 2021
@MaximLipnin MaximLipnin deleted the annotate_System.IO.FileSystem_as_unsupported branch May 13, 2021 06:18
@karelz karelz added this to the 6.0.0 milestone May 20, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jun 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants