[mono-vb] patch for Microsoft.VisualBasic.CompilerServices.Utils

Rolf Bjarne Kvinge rolflists at ya.com
Fri Mar 23 04:17:44 EDT 2007


Hi Max,

Did you write this patch or did you use any tools to disassemble the MS
runtime (like Reflector)? It looks so because there is quite much unused
code in it as well as method calls only the compiler is using.

Rolf

> -----Original Message-----
> From: mono-vb-bounces at lists.ximian.com [mailto:mono-vb-
> bounces at lists.ximian.com] On Behalf Of Max V. Irgiznov
> Sent: viernes, 16 de marzo de 2007 8:47
> To: mono-vb at lists.ximian.com
> Subject: [mono-vb] patch for
> Microsoft.VisualBasic.CompilerServices.Utils
> 
> Hello, mono-vb.
> 
> I call upon you to patch for
> Class Microsoft.VisualBasic.CompilerServices.Utils
> 
> that supports method GetResourceString (ByVal ResourceKey As String,
> ByVal ParamArray Args As
> String ()) As String
> 
> 
> Index: Utils.vb
> ===================================================================
> --- Utils.vb    (revision 74452)
> +++ Utils.vb    (working copy)
> @@ -29,16 +29,212 @@
>  ' WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
> 
>  Imports System
> +Imports System.Resources
> +Imports System.Reflection
> +Imports System.Threading
>  Imports System.Runtime.InteropServices
> 
>  Namespace Microsoft.VisualBasic.CompilerServices
> 
> <System.ComponentModel.EditorBrowsable(ComponentModel.EditorBrowsableSt
> ate.Never)> _
>      Public NotInheritable Class Utils
> 
> +        Private Shared m_TriedLoadingResourceManager As Boolean
> +        Private Shared m_VBAResourceManager As ResourceManager
> +        Private Shared ReadOnly ResourceManagerSyncObj As Object
> +
>          Private Sub New()
>              'Nobody should see constructor
>          End Sub
> +        '----------------------------------
> +        Shared Sub New()
> +            Utils.ResourceManagerSyncObj = New Object
> +        End Sub
> 
> +        Friend Enum vbErrors
> +            ' Fields
> +            Abort = &H11F
> +            AccessViolation = -2147467261
> +            ActionNotSupported = &H1BD
> +            AdviseLimit = &H60
> +            AmbiguousName = &H802C
> +            ArrayLocked = 10
> +            BadCallToFriendFunction = &H61
> +            BadFileMode = &H36
> +            BadFileNameOrNumber = &H34
> +            BadFunctionId = &H8006
> +            BadLibId = &H88C3
> +            BadModuleKind = &H88BD
> +            BadPatStr = &H5D
> +            BadRecordLen = &H3B
> +            BadRecordNum = &H3F
> +            BadTypeId = &H88C2
> +            BrokenLibRef = &H88CD
> +            BufferTooSmall = &H8016
> +            CantContinue = &H11
> +            CantCreateObject = &H1AD
> +            CantCreateTmpFile = &H142
> +            CantEvalWatch = &H9C65
> +            CantFindDllEntryPoint = &HE741
> +            CantPassPrivateObject = &H62
> +            CantSaveFileToTemp = &H2DF
> +            CantUseNull = &H5E
> +            CircularType = &H9C84
> +            CodeResourceLockError = &H1C7
> +            CodeResourceNotFound = &H1C6
> +            CompileError = &H9C64
> +            DevUnavailable = &H44
> +            DifferentDrive = &H4A
> +            DiskFull = &H3D
> +            DiskNotReady = &H47
> +            DivByZero = 11
> +            DLLBadCallingConv = &H31
> +            DLLCallException = &H63
> +            DLLLoadErr = &H30
> +            DoesntImplementICollection = 100
> +            DuplicateKey = &H1C9
> +            ElementNotFound = &H802B
> +            EndOfFile = &H3E
> +            Eof = &H88C4
> +            ExpectedFuncNotModule = &H88C7
> +            ExpectedFuncNotProject = &H88C9
> +            ExpectedFuncNotRecord = &H88C8
> +            ExpectedFuncNotVar = &H88CA
> +            ExpectedTokens = &H9C6F
> +            ExpectedTypeNotProj = &H88CB
> +            ExprTooComplex = &H10
> +            FileAlreadyExists = &H3A
> +            FileAlreadyOpen = &H37
> +            FileLockViolation = &H8007
> +            FileNotFound = &H35
> +            FileNotFoundWithName = &H9D33
> +            FuncArityMismatch = 450
> +            GetNotSupported = &H18A
> +            GetNotSupportedAtRuntime = &H189
> +            IdentNotMember = &H1CD
> +            IdTooLong = &H9C6D
> +            IllegalChar = &H9C6C
> +            IllegalFor = &H5C
> +            IllegalFuncCall = 5
> +            InconsistentPropFuncs = &H9C83
> +            IncorrectTypeChar = &H9C6A
> +            InternalError = &H33
> +            InvalidClipboardFormat = 460
> +            InvalidDllFunctionName = &H1C5
> +            InvalidFileFormat = &H141
> +            InvalidNumLit = &H9C6B
> +            InvalidOrdinal = &H1C4
> +            InvalidPicture = &H1E1
> +            InvalidPropertyArrayIndex = &H17D
> +            InvalidPropertyValue = 380
> +            InvalidResourceFormat = &H145
> +            InvalidState = &H8029
> +            InvalidTypeInfoKind = &H88D1
> +            InvalidTypeLibFunction = &H88D2
> +            InvalidTypeLibVariable = &H1CA
> +            InvDataRead = &H8018
> +            IOError = &H39
> +            LastTrappable = &H2EA
> +            LibNotRegistered = &H801D
> +            LocaleSettingNotSupported = &H1BF
> +            LostTLB = &H1BA
> +            MissingEndBrack = &H9C69
> +            MissingVbaTypeLib = &H9C66
> +            ModNameConflict = &H802D
> +            ModuleAsType = &H88D0
> +            NamedArgsNotSupported = &H1BE
> +            NamedParamNotFound = &H1C0
> +            NeedPropertyArrayIndex = &H181
> +            NoContainingLib = &H88C1
> +            None = 0
> +            NoSuchControlOrProperty = &H1A7
> +            NotEnum = &H1C3
> +            NotObject = &H1A8
> +            NotYetImplemented = &H8000
> +            ObjDoesNotSupportEvents = &H1CB
> +            ObjNotRegistered = &H1CF
> +            ObjNotSet = &H5B
> +            OLEAutomationError = 440
> +            OLEFileNotFound = &H1B0
> +            OLENoDefault = &H1BB
> +            OLENoPropOrMethod = &H1B6
> +            OLENotSupported = 430
> +            OperationNotAllowedInDll = &H9C63
> +            OutOfBounds = 9
> +            OutOfMemory = 7
> +            OutOfStack = &H1C
> +            OutOfStrSpace = 14
> +            Overflow = 6
> +            ParameterNotOptional = &H1C1
> +            PathFileAccess = &H4B
> +            PathNotFound = &H4C
> +            PermissionDenied = 70
> +            PrinterError = &H1E2
> +            PropertyNotFound = &H1A6
> +            QualifiedNameDisallowed = &H8028
> +            ReadFault = &H8004
> +            RegistryAccess = &H801C
> +            ReplacementsTooLong = &H2EA
> +            ResumeWOErr = 20
> +            ReturnWOGoSub = 3
> +            SearchTextNotFound = &H2E8
> +            SeekErr = &H8003
> +            ServerNotFound = &H1CE
> +            SetNotPermitted = &H183
> +            SetNotSupported = &H17F
> +            SetNotSupportedAtRuntime = &H17E
> +            ShareRequired = &H8015
> +            SizeTooBig = &H88C5
> +            StatementTooComplex = &H9C6E
> +            TooManyClients = &H2F
> +            TooManyFiles = &H43
> +            TypeMismatch = 13
> +            UndefinedProc = &H23
> +            UndefinedType = &H8027
> +            UNDONE = &H1D
> +            UnknownLcid = &H802E
> +            UnsuitableFuncPropMatch = &H88CC
> +            UnsupFormat = &H8019
> +            UnsupportedTypeLibFeature = &H88CE
> +            Usage = &H801F
> +            UserDefined = &H5F
> +            UserInterrupt = &H12
> +            UserReset = &H9C68
> +            WriteFault = &H8005
> +            WrongTypeKind = &H802A
> +        End Enum
> +
> +        Friend Shared ReadOnly Property VBAResourceManager() As
> ResourceManager
> +            Get
> +                If (Utils.m_VBAResourceManager Is Nothing) Then
> +                    Dim expression As Object =
> Utils.ResourceManagerSyncObj
> +
> ObjectFlowControl.CheckForSyncLockOnValueType(expression)
> +                    SyncLock expression
> +                        If Not Utils.m_TriedLoadingResourceManager
> Then
> +                            Try
> +                                Utils.m_VBAResourceManager = New
> ResourceManager("Microsoft.VisualBasic", Assembly.GetExecutingAssembly)
> +                            Catch exception As StackOverflowException
> +                                Throw exception
> +                            Catch exception2 As OutOfMemoryException
> +                                Throw exception2
> +                            Catch exception3 As
> Threading.ThreadAbortException
> +                                Throw exception3
> +                            Catch exception6 As Exception
> +                            End Try
> +                            Utils.m_TriedLoadingResourceManager = True
> +                        End If
> +                    End SyncLock
> +                End If
> +                Return Utils.m_VBAResourceManager
> +            End Get
> +        End Property
> +
> +        Friend Shared Function GetCultureInfo() As
> Globalization.CultureInfo
> +            Return Thread.CurrentThread.CurrentCulture
> +        End Function
> +
> +
> +        '---------------------------------
> +
>          Public Shared Function CopyArray(ByVal arySrc As System.Array,
> ByVal aryDest As System.Array) As System.Array
> 
>              If arySrc Is Nothing Then
> @@ -75,11 +271,81 @@
>          Public Shared Sub ThrowException(ByVal hr As Integer)
>              Throw New NotImplementedException
>          End Sub
> -#If NET_2_0 Then
> +
> +        Friend Shared Function GetResourceString(ByVal ResourceId As
> vbErrors) As String
> +            Return Utils.GetResourceString(("ERR" &
> Conversions.ToString(CInt(ResourceId))))
> +        End Function
> +
> +
> <ComponentModel.EditorBrowsable(ComponentModel.EditorBrowsableState.Nev
> er)> _
> +        Friend Shared Function GetResourceString(ByVal ResourceKey As
> String) As String
> +            Dim text2 As String
> +            If (Utils.VBAResourceManager Is Nothing) Then
> +                Return "Message text unavailable.  Resource file
> 'Microsoft.VisualBasic resources' not found."
> +            End If
> +            Try
> +                text2 =
> Utils.VBAResourceManager.GetString(ResourceKey, Utils.GetCultureInfo)
> +                If (text2 Is Nothing) Then
> +                    text2 = "Application-defined or object-defined
> error."
> +                End If
> +            Catch exception As StackOverflowException
> +                Throw exception
> +            Catch exception2 As OutOfMemoryException
> +                Throw exception2
> +            Catch exception3 As ThreadAbortException
> +                Throw exception3
> +            Catch exception6 As Exception
> +                text2 = "Message text unavailable.  Resource file
> 'Microsoft.VisualBasic resources' not found."
> +            End Try
> +            Return text2
> +        End Function
> +
> +        Friend Shared Function GetResourceString(ByVal ResourceKey As
> String, ByVal NotUsed As Boolean) As String
> +            Dim text2 As String
> +            If (Utils.VBAResourceManager Is Nothing) Then
> +                Return "Message text unavailable.  Resource file
> 'Microsoft.VisualBasic resources' not found."
> +            End If
> +
> +            Try
> +                text2 =
> Utils.VBAResourceManager.GetString(ResourceKey, Utils.GetCultureInfo)
> +                If (text2 Is Nothing) Then
> +                    text2 =
> Utils.VBAResourceManager.GetString(ResourceKey)
> +                End If
> +            Catch exception As StackOverflowException
> +                Throw exception
> +            Catch exception2 As OutOfMemoryException
> +                Throw exception2
> +            Catch exception3 As ThreadAbortException
> +                Throw exception3
> +            Catch exception6 As Exception
> +                text2 = Nothing
> +            End Try
> +
> +            Return text2
> +        End Function
> +
>          Public Shared Function GetResourceString(ByVal ResourceKey As
> String, ByVal ParamArray Args As String()) As String
> -            Throw New NotImplementedException
> +            Dim left As String = Nothing
> +            Dim format As String = Nothing
> +
> +            Try
> +                format = Utils.GetResourceString(ResourceKey)
> +                left =
> String.Format(Thread.CurrentThread.CurrentUICulture, format, Args)
> +            Catch exception As StackOverflowException
> +                Throw exception
> +            Catch exception2 As OutOfMemoryException
> +                Throw exception2
> +            Catch exception3 As ThreadAbortException
> +                Throw exception3
> +            Catch exception4 As Exception
> +
> +            End Try
> +
> +            If (Operators.CompareString(left, "", False) <> 0) Then
> +                Return left
> +            End If
> +            Return format
>          End Function
> -#End If
> +
>      End Class
> 
>  End Namespace
> 
> 
> --
> Sincerely,
>  Max V. Irgiznov    System Administrator of Ulyanovsk State University
>  mailto:xeon at ulsu.ru
> 
> _______________________________________________
> Mono-vb mailing list
> Mono-vb at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-vb



More information about the Mono-vb mailing list