From 878ac6940bd10e2161edcacea22d0ae890f80db9 Mon Sep 17 00:00:00 2001 From: Maxim Lipnin Date: Tue, 11 May 2021 14:41:01 +0300 Subject: [PATCH] Annotate the respective methods in VB --- .../VisualBasic/CompilerServices/VB6BinaryFile.vb | 4 ++++ .../VisualBasic/CompilerServices/VB6File.vb | 12 ++++++++++++ .../VisualBasic/CompilerServices/VB6RandomFile.vb | 4 ++++ .../src/Microsoft/VisualBasic/FileSystem.vb | 14 ++++++++++++++ 4 files changed, 34 insertions(+) diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/VB6BinaryFile.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/VB6BinaryFile.vb index 5d2d9eae3dc60..e43d3822eacfc 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/VB6BinaryFile.vb +++ b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/VB6BinaryFile.vb @@ -26,7 +26,9 @@ Namespace Microsoft.VisualBasic.CompilerServices End Sub ' the implementation of Lock in base class VB6RandomFile does not handle m_lRecordLen=-1 + + Friend Overloads Overrides Sub Lock(ByVal lStart As Long, ByVal lEnd As Long) If lStart > lEnd Then Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Start")) @@ -50,7 +52,9 @@ Namespace Microsoft.VisualBasic.CompilerServices End Sub ' see Lock description + + Friend Overloads Overrides Sub Unlock(ByVal lStart As Long, ByVal lEnd As Long) If lStart > lEnd Then Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Start")) diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/VB6File.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/VB6File.vb index bbcb474b87383..1a6793bd16005 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/VB6File.vb +++ b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/VB6File.vb @@ -603,18 +603,24 @@ Namespace Microsoft.VisualBasic.CompilerServices Return m_position End Function + + Friend Overridable Overloads Sub Lock() 'Lock the whole file, not just the current size of file, since file could change. m_file.Lock(0, Int32.MaxValue) End Sub + + Friend Overridable Overloads Sub Unlock() m_file.Unlock(0, Int32.MaxValue) End Sub + + Friend Overridable Overloads Sub Lock(ByVal Record As Long) If m_lRecordLen = -1 Then m_file.Lock((Record - 1), 1) @@ -623,7 +629,9 @@ Namespace Microsoft.VisualBasic.CompilerServices End If End Sub + + Friend Overridable Overloads Sub Unlock(ByVal Record As Long) If m_lRecordLen = -1 Then m_file.Unlock((Record - 1), 1) @@ -632,7 +640,9 @@ Namespace Microsoft.VisualBasic.CompilerServices End If End Sub + + Friend Overridable Overloads Sub Lock(ByVal RecordStart As Long, ByVal RecordEnd As Long) If m_lRecordLen = -1 Then m_file.Lock((RecordStart - 1), (RecordEnd - RecordStart) + 1) @@ -641,7 +651,9 @@ Namespace Microsoft.VisualBasic.CompilerServices End If End Sub + + Friend Overridable Overloads Sub Unlock(ByVal RecordStart As Long, ByVal RecordEnd As Long) If m_lRecordLen = -1 Then m_file.Unlock((RecordStart - 1), (RecordEnd - RecordStart) + 1) diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/VB6RandomFile.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/VB6RandomFile.vb index aa89c7c7b37cb..7d47dfa1e191d 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/VB6RandomFile.vb +++ b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/VB6RandomFile.vb @@ -122,7 +122,9 @@ Namespace Microsoft.VisualBasic.CompilerServices CloseTheFile() End Sub + + Friend Overloads Overrides Sub Lock(ByVal lStart As Long, ByVal lEnd As Long) If lStart > lEnd Then Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Start")) @@ -137,7 +139,9 @@ Namespace Microsoft.VisualBasic.CompilerServices m_file.Lock(lStartByte, lLength) End Sub + + Friend Overloads Overrides Sub Unlock(ByVal lStart As Long, ByVal lEnd As Long) If lStart > lEnd Then Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Start")) diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/FileSystem.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/FileSystem.vb index d9dfc899cbda2..2590c49e89fe4 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/FileSystem.vb +++ b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/FileSystem.vb @@ -1009,7 +1009,9 @@ Namespace Microsoft.VisualBasic End Try End Sub + + Public Function InputString(ByVal FileNumber As Integer, ByVal CharCount As Integer) As String Try Dim oFile As VB6File @@ -1047,37 +1049,49 @@ Namespace Microsoft.VisualBasic Return oFile.LineInput() End Function + + Public Sub Lock(ByVal FileNumber As Integer) Dim assem As System.Reflection.Assembly = System.Reflection.Assembly.GetCallingAssembly() GetStream(assem, FileNumber).Lock() End Sub + + Public Sub Lock(ByVal FileNumber As Integer, ByVal Record As Long) Dim assem As System.Reflection.Assembly = System.Reflection.Assembly.GetCallingAssembly() GetStream(assem, FileNumber).Lock(Record) End Sub + + Public Sub Lock(ByVal FileNumber As Integer, ByVal FromRecord As Long, ByVal ToRecord As Long) Dim assem As System.Reflection.Assembly = System.Reflection.Assembly.GetCallingAssembly() GetStream(assem, FileNumber).Lock(FromRecord, ToRecord) End Sub + + Public Sub Unlock(ByVal FileNumber As Integer) Dim assem As System.Reflection.Assembly = System.Reflection.Assembly.GetCallingAssembly() GetStream(assem, FileNumber).Unlock() End Sub + + Public Sub Unlock(ByVal FileNumber As Integer, ByVal Record As Long) Dim assem As System.Reflection.Assembly = System.Reflection.Assembly.GetCallingAssembly() GetStream(assem, FileNumber).Unlock(Record) End Sub + + Public Sub Unlock(ByVal FileNumber As Integer, ByVal FromRecord As Long, ByVal ToRecord As Long) Dim assem As System.Reflection.Assembly = System.Reflection.Assembly.GetCallingAssembly() GetStream(assem, FileNumber).Unlock(FromRecord, ToRecord)