Skip to content

Commit a98fe6c

Browse files
authored
mark FileStream.Lock and Unlock as unsupported on macOS (#47040)
* mark FileStream.Lock and Unlock as unsupported on macOS * update ref assembly * annotate types derived from FileStream * annotate VisualBasic parts as well
1 parent a7d1332 commit a98fe6c

File tree

9 files changed

+37
-0
lines changed

9 files changed

+37
-0
lines changed

src/libraries/Microsoft.VisualBasic.Core/ref/Microsoft.VisualBasic.Core.cs

+7
Original file line numberDiff line numberDiff line change
@@ -394,12 +394,16 @@ public static void Input(int FileNumber, ref long Value) { }
394394
public static void Input(int FileNumber, ref object Value) { }
395395
public static void Input(int FileNumber, ref float Value) { }
396396
public static void Input(int FileNumber, ref string Value) { }
397+
[System.Runtime.Versioning.UnsupportedOSPlatform("macos")]
397398
public static string InputString(int FileNumber, int CharCount) { throw null; }
398399
public static void Kill(string PathName) { }
399400
public static string LineInput(int FileNumber) { throw null; }
400401
public static long Loc(int FileNumber) { throw null; }
402+
[System.Runtime.Versioning.UnsupportedOSPlatform("macos")]
401403
public static void Lock(int FileNumber) { }
404+
[System.Runtime.Versioning.UnsupportedOSPlatform("macos")]
402405
public static void Lock(int FileNumber, long Record) { }
406+
[System.Runtime.Versioning.UnsupportedOSPlatform("macos")]
403407
public static void Lock(int FileNumber, long FromRecord, long ToRecord) { }
404408
public static long LOF(int FileNumber) { throw null; }
405409
public static void MkDir(string Path) { }
@@ -415,8 +419,11 @@ public static void SetAttr(string PathName, Microsoft.VisualBasic.FileAttribute
415419
public static Microsoft.VisualBasic.SpcInfo SPC(short Count) { throw null; }
416420
public static Microsoft.VisualBasic.TabInfo TAB() { throw null; }
417421
public static Microsoft.VisualBasic.TabInfo TAB(short Column) { throw null; }
422+
[System.Runtime.Versioning.UnsupportedOSPlatform("macos")]
418423
public static void Unlock(int FileNumber) { }
424+
[System.Runtime.Versioning.UnsupportedOSPlatform("macos")]
419425
public static void Unlock(int FileNumber, long Record) { }
426+
[System.Runtime.Versioning.UnsupportedOSPlatform("macos")]
420427
public static void Unlock(int FileNumber, long FromRecord, long ToRecord) { }
421428
public static void Write(int FileNumber, params object[] Output) { }
422429
public static void WriteLine(int FileNumber, params object[] Output) { }

src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/VB6BinaryFile.vb

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
Imports System
55
Imports Microsoft.VisualBasic.CompilerServices.ExceptionUtils
66
Imports Microsoft.VisualBasic.CompilerServices.Utils
7+
Imports System.Runtime.Versioning
78

89
Namespace Microsoft.VisualBasic.CompilerServices
910

@@ -24,6 +25,7 @@ Namespace Microsoft.VisualBasic.CompilerServices
2425
End Sub
2526

2627
' the implementation of Lock in base class VB6RandomFile does not handle m_lRecordLen=-1
28+
<UnsupportedOSPlatform("macos")>
2729
Friend Overloads Overrides Sub Lock(ByVal lStart As Long, ByVal lEnd As Long)
2830
If lStart > lEnd Then
2931
Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Start"))
@@ -47,6 +49,7 @@ Namespace Microsoft.VisualBasic.CompilerServices
4749
End Sub
4850

4951
' see Lock description
52+
<UnsupportedOSPlatform("macos")>
5053
Friend Overloads Overrides Sub Unlock(ByVal lStart As Long, ByVal lEnd As Long)
5154
If lStart > lEnd Then
5255
Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Start"))

src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/VB6File.vb

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Imports System.Security
77
Imports System.Globalization
88
Imports System.IO
99
Imports System.Text
10+
Imports System.Runtime.Versioning
1011

1112
Imports Microsoft.VisualBasic.CompilerServices.StructUtils
1213
Imports Microsoft.VisualBasic.CompilerServices.ExceptionUtils
@@ -595,15 +596,18 @@ Namespace Microsoft.VisualBasic.CompilerServices
595596
Return m_position
596597
End Function
597598

599+
<UnsupportedOSPlatform("macos")>
598600
Friend Overridable Overloads Sub Lock()
599601
'Lock the whole file, not just the current size of file, since file could change.
600602
m_file.Lock(0, Int32.MaxValue)
601603
End Sub
602604

605+
<UnsupportedOSPlatform("macos")>
603606
Friend Overridable Overloads Sub Unlock()
604607
m_file.Unlock(0, Int32.MaxValue)
605608
End Sub
606609

610+
<UnsupportedOSPlatform("macos")>
607611
Friend Overridable Overloads Sub Lock(ByVal Record As Long)
608612
If m_lRecordLen = -1 Then
609613
m_file.Lock((Record - 1), 1)
@@ -612,6 +616,7 @@ Namespace Microsoft.VisualBasic.CompilerServices
612616
End If
613617
End Sub
614618

619+
<UnsupportedOSPlatform("macos")>
615620
Friend Overridable Overloads Sub Unlock(ByVal Record As Long)
616621
If m_lRecordLen = -1 Then
617622
m_file.Unlock((Record - 1), 1)
@@ -620,6 +625,7 @@ Namespace Microsoft.VisualBasic.CompilerServices
620625
End If
621626
End Sub
622627

628+
<UnsupportedOSPlatform("macos")>
623629
Friend Overridable Overloads Sub Lock(ByVal RecordStart As Long, ByVal RecordEnd As Long)
624630
If m_lRecordLen = -1 Then
625631
m_file.Lock((RecordStart - 1), (RecordEnd - RecordStart) + 1)
@@ -628,6 +634,7 @@ Namespace Microsoft.VisualBasic.CompilerServices
628634
End If
629635
End Sub
630636

637+
<UnsupportedOSPlatform("macos")>
631638
Friend Overridable Overloads Sub Unlock(ByVal RecordStart As Long, ByVal RecordEnd As Long)
632639
If m_lRecordLen = -1 Then
633640
m_file.Unlock((RecordStart - 1), (RecordEnd - RecordStart) + 1)

src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/VB6RandomFile.vb

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
Imports System
55
Imports System.IO
6+
Imports System.Runtime.Versioning
67

78
Imports Microsoft.VisualBasic.CompilerServices.ExceptionUtils
89
Imports Microsoft.VisualBasic.CompilerServices.Utils
@@ -120,6 +121,7 @@ Namespace Microsoft.VisualBasic.CompilerServices
120121
CloseTheFile()
121122
End Sub
122123

124+
<UnsupportedOSPlatform("macos")>
123125
Friend Overloads Overrides Sub Lock(ByVal lStart As Long, ByVal lEnd As Long)
124126
If lStart > lEnd Then
125127
Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Start"))
@@ -134,6 +136,7 @@ Namespace Microsoft.VisualBasic.CompilerServices
134136
m_file.Lock(lStartByte, lLength)
135137
End Sub
136138

139+
<UnsupportedOSPlatform("macos")>
137140
Friend Overloads Overrides Sub Unlock(ByVal lStart As Long, ByVal lEnd As Long)
138141
If lStart > lEnd Then
139142
Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Start"))

src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/FileSystem.vb

+7
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,7 @@ Namespace Microsoft.VisualBasic
10001000
End Try
10011001
End Sub
10021002

1003+
<UnsupportedOSPlatform("macos")>
10031004
Public Function InputString(ByVal FileNumber As Integer, ByVal CharCount As Integer) As String
10041005
Try
10051006
Dim oFile As VB6File
@@ -1037,31 +1038,37 @@ Namespace Microsoft.VisualBasic
10371038
Return oFile.LineInput()
10381039
End Function
10391040

1041+
<UnsupportedOSPlatform("macos")>
10401042
Public Sub Lock(ByVal FileNumber As Integer)
10411043
Dim assem As System.Reflection.Assembly = System.Reflection.Assembly.GetCallingAssembly()
10421044
GetStream(assem, FileNumber).Lock()
10431045
End Sub
10441046

1047+
<UnsupportedOSPlatform("macos")>
10451048
Public Sub Lock(ByVal FileNumber As Integer, ByVal Record As Long)
10461049
Dim assem As System.Reflection.Assembly = System.Reflection.Assembly.GetCallingAssembly()
10471050
GetStream(assem, FileNumber).Lock(Record)
10481051
End Sub
10491052

1053+
<UnsupportedOSPlatform("macos")>
10501054
Public Sub Lock(ByVal FileNumber As Integer, ByVal FromRecord As Long, ByVal ToRecord As Long)
10511055
Dim assem As System.Reflection.Assembly = System.Reflection.Assembly.GetCallingAssembly()
10521056
GetStream(assem, FileNumber).Lock(FromRecord, ToRecord)
10531057
End Sub
10541058

1059+
<UnsupportedOSPlatform("macos")>
10551060
Public Sub Unlock(ByVal FileNumber As Integer)
10561061
Dim assem As System.Reflection.Assembly = System.Reflection.Assembly.GetCallingAssembly()
10571062
GetStream(assem, FileNumber).Unlock()
10581063
End Sub
10591064

1065+
<UnsupportedOSPlatform("macos")>
10601066
Public Sub Unlock(ByVal FileNumber As Integer, ByVal Record As Long)
10611067
Dim assem As System.Reflection.Assembly = System.Reflection.Assembly.GetCallingAssembly()
10621068
GetStream(assem, FileNumber).Unlock(Record)
10631069
End Sub
10641070

1071+
<UnsupportedOSPlatform("macos")>
10651072
Public Sub Unlock(ByVal FileNumber As Integer, ByVal FromRecord As Long, ByVal ToRecord As Long)
10661073
Dim assem As System.Reflection.Assembly = System.Reflection.Assembly.GetCallingAssembly()
10671074
GetStream(assem, FileNumber).Unlock(FromRecord, ToRecord)

src/libraries/System.IO.IsolatedStorage/ref/System.IO.IsolatedStorage.cs

+2
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ public override void EndWrite(System.IAsyncResult asyncResult) { }
119119
public override void Flush() { }
120120
public override void Flush(bool flushToDisk) { }
121121
public override System.Threading.Tasks.Task FlushAsync(System.Threading.CancellationToken cancellationToken) { throw null; }
122+
[System.Runtime.Versioning.UnsupportedOSPlatform("macos")]
122123
public override void Lock(long position, long length) { }
123124
public override int Read(byte[] buffer, int offset, int count) { throw null; }
124125
public override int Read(System.Span<byte> buffer) { throw null; }
@@ -127,6 +128,7 @@ public override void Lock(long position, long length) { }
127128
public override int ReadByte() { throw null; }
128129
public override long Seek(long offset, System.IO.SeekOrigin origin) { throw null; }
129130
public override void SetLength(long value) { }
131+
[System.Runtime.Versioning.UnsupportedOSPlatform("macos")]
130132
public override void Unlock(long position, long length) { }
131133
public override void Write(byte[] buffer, int offset, int count) { }
132134
public override void Write(System.ReadOnlySpan<byte> buffer) { }

src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFileStream.cs

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Microsoft.Win32.SafeHandles;
55
using System.Threading;
66
using System.Threading.Tasks;
7+
using System.Runtime.Versioning;
78

89
namespace System.IO.IsolatedStorage
910
{
@@ -327,11 +328,13 @@ public override IntPtr Handle
327328
get { return _fs.Handle; }
328329
}
329330

331+
[UnsupportedOSPlatform("macos")]
330332
public override void Unlock(long position, long length)
331333
{
332334
_fs.Unlock(position, length);
333335
}
334336

337+
[UnsupportedOSPlatform("macos")]
335338
public override void Lock(long position, long length)
336339
{
337340
_fs.Lock(position, length);

src/libraries/System.Private.CoreLib/src/System/IO/FileStream.cs

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Diagnostics;
55
using System.Runtime.InteropServices;
66
using System.Runtime.Serialization;
7+
using System.Runtime.Versioning;
78
using System.Threading;
89
using System.Threading.Tasks;
910
using Microsoft.Win32.SafeHandles;
@@ -256,6 +257,7 @@ public FileStream(string path, FileMode mode, FileAccess access, FileShare share
256257
[Obsolete("This property has been deprecated. Please use FileStream's SafeFileHandle property instead. https://go.microsoft.com/fwlink/?linkid=14202")]
257258
public virtual IntPtr Handle => SafeFileHandle.DangerousGetHandle();
258259

260+
[UnsupportedOSPlatform("macos")]
259261
public virtual void Lock(long position, long length)
260262
{
261263
if (position < 0 || length < 0)
@@ -271,6 +273,7 @@ public virtual void Lock(long position, long length)
271273
LockInternal(position, length);
272274
}
273275

276+
[UnsupportedOSPlatform("macos")]
274277
public virtual void Unlock(long position, long length)
275278
{
276279
if (position < 0 || length < 0)

src/libraries/System.Runtime/ref/System.Runtime.cs

+2
Original file line numberDiff line numberDiff line change
@@ -7172,6 +7172,7 @@ public override void EndWrite(System.IAsyncResult asyncResult) { }
71727172
public override void Flush() { }
71737173
public virtual void Flush(bool flushToDisk) { }
71747174
public override System.Threading.Tasks.Task FlushAsync(System.Threading.CancellationToken cancellationToken) { throw null; }
7175+
[System.Runtime.Versioning.UnsupportedOSPlatform("macos")]
71757176
public virtual void Lock(long position, long length) { }
71767177
public override int Read(byte[] buffer, int offset, int count) { throw null; }
71777178
public override int Read(System.Span<byte> buffer) { throw null; }
@@ -7180,6 +7181,7 @@ public virtual void Lock(long position, long length) { }
71807181
public override int ReadByte() { throw null; }
71817182
public override long Seek(long offset, System.IO.SeekOrigin origin) { throw null; }
71827183
public override void SetLength(long value) { }
7184+
[System.Runtime.Versioning.UnsupportedOSPlatform("macos")]
71837185
public virtual void Unlock(long position, long length) { }
71847186
public override void Write(byte[] buffer, int offset, int count) { }
71857187
public override void Write(System.ReadOnlySpan<byte> buffer) { }

0 commit comments

Comments
 (0)