Initial port of Microsoft.VisualBasic.Devices and Microsoft.VisualBasic.MyServices...
authorCharles Stoner <chucks@microsoft.com>
Mon, 22 Apr 2019 18:32:16 +0000 (11:32 -0700)
committerGitHub <noreply@github.com>
Mon, 22 Apr 2019 18:32:16 +0000 (11:32 -0700)
Commit migrated from https://github.com/dotnet/corefx/commit/37703f186d593425418a7fcf705173c707da30d4

34 files changed:
src/libraries/Microsoft.VisualBasic.Core/ref/Microsoft.VisualBasic.Core.cs
src/libraries/Microsoft.VisualBasic.Core/ref/Microsoft.VisualBasic.Core.csproj
src/libraries/Microsoft.VisualBasic.Core/src/Microsoft.VisualBasic.Core.vbproj
src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/ApplicationServices/ApplicationBase.vb [new file with mode: 0644]
src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/ApplicationServices/User.vb [new file with mode: 0644]
src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/ProjectData.vb
src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/Audio.vb [new file with mode: 0644]
src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/Clock.vb [new file with mode: 0644]
src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/Computer.vb [new file with mode: 0644]
src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/ComputerInfo.vb [new file with mode: 0644]
src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/Keyboard.vb [new file with mode: 0644]
src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/Mouse.vb [new file with mode: 0644]
src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/Network.vb [new file with mode: 0644]
src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/Ports.vb [new file with mode: 0644]
src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/ServerComputer.vb [new file with mode: 0644]
src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/FileIO/FileSystem.vb
src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/FileIO/TextFieldParser.vb
src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/FileSystem.vb [new file with mode: 0644]
src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/MyServices/ClipboardProxy.vb [new file with mode: 0644]
src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/MyServices/FileSystemProxy.vb [new file with mode: 0644]
src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/MyServices/RegistryProxy.vb [new file with mode: 0644]
src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/MyServices/SpecialDirectoriesProxy.vb [new file with mode: 0644]
src/libraries/Microsoft.VisualBasic.Core/tests/Configurations.props
src/libraries/Microsoft.VisualBasic.Core/tests/ErrObjectTests.cs
src/libraries/Microsoft.VisualBasic.Core/tests/Microsoft.VisualBasic.Core.Tests.csproj
src/libraries/Microsoft.VisualBasic.Core/tests/Microsoft/VisualBasic/ApplicationServices/ApplicationBaseTests.cs [new file with mode: 0644]
src/libraries/Microsoft.VisualBasic.Core/tests/Microsoft/VisualBasic/ApplicationServices/UserTests.cs [new file with mode: 0644]
src/libraries/Microsoft.VisualBasic.Core/tests/Microsoft/VisualBasic/Devices/ClockTests.cs [new file with mode: 0644]
src/libraries/Microsoft.VisualBasic.Core/tests/Microsoft/VisualBasic/Devices/ComputerInfoTests.cs [new file with mode: 0644]
src/libraries/Microsoft.VisualBasic.Core/tests/Microsoft/VisualBasic/Devices/ComputerTests.cs [new file with mode: 0644]
src/libraries/Microsoft.VisualBasic.Core/tests/Microsoft/VisualBasic/Devices/ServerComputerTests.cs [new file with mode: 0644]
src/libraries/Microsoft.VisualBasic.Core/tests/Microsoft/VisualBasic/MyServices/FileSystemProxyTests.cs [new file with mode: 0644]
src/libraries/Microsoft.VisualBasic.Core/tests/Microsoft/VisualBasic/MyServices/SpecialDirectoriesProxyTests.cs [new file with mode: 0644]
src/libraries/Microsoft.VisualBasic.Core/tests/ProjectDataTests.cs

index 2016691b8a53f4736022b16f698fc7f0fed18a43..cbe398926cf41ed28f9f6a44f836446dc3d2b15a 100644 (file)
@@ -301,6 +301,15 @@ namespace Microsoft.VisualBasic
 }
 namespace Microsoft.VisualBasic.ApplicationServices
 {
+    public partial class ApplicationBase
+    {
+        public ApplicationBase() { }
+        public void ChangeCulture(string cultureName) { throw null; }
+        public void ChangeUICulture(string cultureName) { throw null; }
+        public System.Globalization.CultureInfo Culture { get { throw null; } }
+        public System.Globalization.CultureInfo UICulture { get { throw null; } }
+        public string GetEnvironmentVariable(string name) { throw null; }
+    }
     public partial class StartupEventArgs : System.ComponentModel.CancelEventArgs
     {
         public StartupEventArgs(System.Collections.ObjectModel.ReadOnlyCollection<string> args) { }
@@ -319,6 +328,16 @@ namespace Microsoft.VisualBasic.ApplicationServices
         public UnhandledExceptionEventArgs(bool exitApplication, System.Exception exception) : base (default(System.Exception)) { }
         public bool ExitApplication { get { throw null; } set { } }
     }
+    public partial class User
+    {
+        public User() { }
+        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+        public System.Security.Principal.IPrincipal CurrentPrincipal { get { throw null; } set { } }
+        protected virtual System.Security.Principal.IPrincipal InternalPrincipal { get { throw null; } set { } }
+        public bool IsAuthenticated { get { throw null; } }
+        public bool IsInRole(string role) { throw null; }
+        public string Name { get { throw null; } }
+    }
 }
 namespace Microsoft.VisualBasic.CompilerServices
 {
@@ -643,6 +662,7 @@ namespace Microsoft.VisualBasic.CompilerServices
         internal ProjectData() { }
         public static void ClearProjectError() { }
         public static System.Exception CreateProjectError(int hr) { throw null; }
+        public static void EndApp() { }
         public static void SetProjectError(System.Exception ex) { }
         public static void SetProjectError(System.Exception ex, int lErl) { }
     }
@@ -717,11 +737,64 @@ namespace Microsoft.VisualBasic.CompilerServices
 }
 namespace Microsoft.VisualBasic.Devices
 {
+    public partial class Audio
+    {
+        public Audio() { }
+    }
+    public partial class Clock
+    {
+        public Clock() { }
+        public System.DateTime GmtTime { get { throw null; } }
+        public System.DateTime LocalTime { get { throw null; } }
+        public int TickCount { get { throw null; } }
+    }
+    public partial class Computer : ServerComputer
+    {
+        public Computer() { }
+        public Audio Audio { get { throw null; } }
+        public Microsoft.VisualBasic.MyServices.ClipboardProxy Clipboard { get { throw null; } }
+        public Keyboard Keyboard { get { throw null; } }
+        public Mouse Mouse { get { throw null; } }
+        public Ports Ports { get { throw null; } }
+    }
+    public partial class ComputerInfo
+    {
+        public ComputerInfo() { }
+        public System.Globalization.CultureInfo InstalledUICulture { get { throw null; } }
+        public string OSPlatform { get { throw null; } }
+        public string OSVersion { get { throw null; } }
+    }
+    public partial class Keyboard
+    {
+        public Keyboard() { }
+    }
+    public partial class Mouse
+    {
+        public Mouse() { }
+    }
+    public partial class Network
+    {
+        public Network() { }
+    }
     public partial class NetworkAvailableEventArgs : System.EventArgs
     {
         public NetworkAvailableEventArgs(bool networkAvailable) { }
         public bool IsNetworkAvailable { get { throw null; } }
     }
+    public partial class Ports
+    {
+        public Ports() { }
+    }
+    public partial class ServerComputer
+    {
+        public ServerComputer() { }
+        public Clock Clock { get { throw null; } }
+        public Microsoft.VisualBasic.MyServices.FileSystemProxy FileSystem { get { throw null; } }
+        public ComputerInfo Info { get { throw null; } }
+        public string Name { get { throw null; } }
+        public Network Network { get { throw null; } }
+        public Microsoft.VisualBasic.MyServices.RegistryProxy Registry { get { throw null; } }
+    }
 }
 namespace Microsoft.VisualBasic.FileIO
 {
@@ -879,3 +952,36 @@ namespace Microsoft.VisualBasic.FileIO
         OnlyErrorDialogs = 2,
     }
 }
+namespace Microsoft.VisualBasic.MyServices
+{
+    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
+    public partial class ClipboardProxy
+    {
+        internal ClipboardProxy() { }
+    }
+    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
+    public partial class FileSystemProxy
+    {
+        internal FileSystemProxy() { }
+        public SpecialDirectoriesProxy SpecialDirectories { get { throw null; } }
+    }
+    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
+    public partial class RegistryProxy
+    {
+        internal RegistryProxy() { }
+    }
+    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
+    public partial class SpecialDirectoriesProxy
+    {
+        internal SpecialDirectoriesProxy() { }
+        public string AllUsersApplicationData { get { throw null; } }
+        public string CurrentUserApplicationData { get { throw null; } }
+        public string Desktop { get { throw null; } }
+        public string MyDocuments { get { throw null; } }
+        public string MyMusic { get { throw null; } }
+        public string MyPictures { get { throw null; } }
+        public string Programs { get { throw null; } }
+        public string ProgramFiles { get { throw null; } }
+        public string Temp { get { throw null; } }
+    }
+}
index 82a69235e1af977132f0d66e5e3f11e641e909f3..f0a801087f577faf1021c8613551dce7cf2f23ea 100644 (file)
@@ -15,6 +15,7 @@
     <ProjectReference Include="..\..\System.Runtime\ref\System.Runtime.csproj" />
     <ProjectReference Include="..\..\System.Runtime.Extensions\ref\System.Runtime.Extensions.csproj" />
     <ProjectReference Include="..\..\System.Runtime.InteropServices\ref\System.Runtime.InteropServices.csproj" />
+    <ProjectReference Include="..\..\System.Security.Principal\ref\System.Security.Principal.csproj" />
     <ProjectReference Include="..\..\System.Threading.Thread\ref\System.Threading.Thread.csproj" />
   </ItemGroup>
 </Project>
index 73da487de0e316d6c3c94e71e7e08247a8c26f15..926d04c5bc9e44078f9f7be438d53983b6177969 100644 (file)
     <Compile Include="Microsoft\VisualBasic\FileIO\FileSystem.Unix.vb" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="Microsoft\VisualBasic\ApplicationServices\ApplicationBase.vb" />
     <Compile Include="Microsoft\VisualBasic\ApplicationServices\StartupEventArgs.vb" />
     <Compile Include="Microsoft\VisualBasic\ApplicationServices\StartupNextInstanceEventArgs.vb" />
     <Compile Include="Microsoft\VisualBasic\ApplicationServices\UnhandledExceptionEventArgs.vb" />
+    <Compile Include="Microsoft\VisualBasic\ApplicationServices\User.vb" />
     <Compile Include="Microsoft\VisualBasic\CallType.vb" />
     <Compile Include="Microsoft\VisualBasic\Collection.vb" />
     <Compile Include="Microsoft\VisualBasic\ComClassAttribute.vb" />
     <Compile Include="Microsoft\VisualBasic\ControlChars.vb" />
     <Compile Include="Microsoft\VisualBasic\Conversion.vb" />
     <Compile Include="Microsoft\VisualBasic\DateAndTime.vb" />
+    <Compile Include="Microsoft\VisualBasic\Devices\Audio.vb" />
+    <Compile Include="Microsoft\VisualBasic\Devices\Clock.vb" />
+    <Compile Include="Microsoft\VisualBasic\Devices\Computer.vb" />
+    <Compile Include="Microsoft\VisualBasic\Devices\ComputerInfo.vb" />
+    <Compile Include="Microsoft\VisualBasic\Devices\Keyboard.vb" />
+    <Compile Include="Microsoft\VisualBasic\Devices\Mouse.vb" />
+    <Compile Include="Microsoft\VisualBasic\Devices\Network.vb" />
     <Compile Include="Microsoft\VisualBasic\Devices\NetworkAvailableEventArgs.vb" />
+    <Compile Include="Microsoft\VisualBasic\Devices\Ports.vb" />
+    <Compile Include="Microsoft\VisualBasic\Devices\ServerComputer.vb" />
     <Compile Include="Microsoft\VisualBasic\ErrObject.vb" />
     <Compile Include="Microsoft\VisualBasic\FileIO\FileSystem.vb" />
     <Compile Include="Microsoft\VisualBasic\FileIO\MalformedLineException.vb" />
     <Compile Include="Microsoft\VisualBasic\FileIO\SpecialDirectories.vb" />
     <Compile Include="Microsoft\VisualBasic\FileIO\TextFieldParser.vb" />
+    <Compile Include="Microsoft\VisualBasic\FileSystem.vb" />
     <Compile Include="Microsoft\VisualBasic\Globals.vb" />
     <Compile Include="Microsoft\VisualBasic\Helpers\ForEachEnum.vb" />
     <Compile Include="Microsoft\VisualBasic\HideModuleNameAttribute.vb" />
     <Compile Include="Microsoft\VisualBasic\Information.vb" />
     <Compile Include="Microsoft\VisualBasic\Interaction.vb" />
     <Compile Include="Microsoft\VisualBasic\MyGroupCollectionAttribute.vb" />
+    <Compile Include="Microsoft\VisualBasic\MyServices\ClipboardProxy.vb" />
+    <Compile Include="Microsoft\VisualBasic\MyServices\FileSystemProxy.vb" />
+    <Compile Include="Microsoft\VisualBasic\MyServices\RegistryProxy.vb" />
+    <Compile Include="Microsoft\VisualBasic\MyServices\SpecialDirectoriesProxy.vb" />
     <Compile Include="Microsoft\VisualBasic\Strings.vb" />
     <Compile Include="Microsoft\VisualBasic\VariantType.vb" />
     <Compile Include="Microsoft\VisualBasic\VBFixedArrayAttribute.vb" />
     <Reference Include="System.Runtime" />
     <Reference Include="System.Runtime.Extensions" />
     <Reference Include="System.Runtime.InteropServices" />
+    <Reference Include="System.Security.Principal" />
     <Reference Include="System.Text.RegularExpressions" />
     <Reference Include="System.Threading" />
     <Reference Include="System.Threading.Tasks" />
diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/ApplicationServices/ApplicationBase.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/ApplicationServices/ApplicationBase.vb
new file mode 100644 (file)
index 0000000..b91fca6
--- /dev/null
@@ -0,0 +1,119 @@
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Option Strict On
+Option Explicit On
+
+Imports System
+Imports ExUtils = Microsoft.VisualBasic.CompilerServices.ExceptionUtils
+
+Namespace Microsoft.VisualBasic.ApplicationServices
+
+    '''**************************************************************************
+    ''' ;ApplicationBase
+    ''' <summary>
+    ''' Abstract class that defines the application Startup/Shutdown model for VB 
+    ''' Windows Applications such as console, winforms, dll, service.
+    ''' </summary>
+    Public Class ApplicationBase
+
+        '= PUBLIC =============================================================
+
+        Public Sub New()
+        End Sub
+
+        '''**************************************************************************
+        ''' ;GetEnvironmentVariable
+        ''' <summary>
+        ''' Return the value of the specified environment variable.
+        ''' </summary>
+        ''' <param name="Name">A String containing the name of the environment variable.</param>
+        ''' <returns>A string containing the value of the environment variable.</returns>
+        ''' <exception cref="System.ArgumentNullException">if Name is Nothing. (Framework)</exception>
+        ''' <exception cref="System.Security.SecurityException">if caller does not have EnvironmentPermission.Read. (Framework)</exception>
+        ''' <exception cref="System.ArgumentException">if the specified environment variable does not exist. (Ours)</exception>
+        Public Function GetEnvironmentVariable(ByVal name As String) As String
+
+            ' Framework returns Null if not found.
+            Dim VariableValue As String = System.Environment.GetEnvironmentVariable(name)
+
+            ' Since the explicity requested a specific environment variable and we couldn't find it, throw
+            If VariableValue Is Nothing Then
+                Throw ExUtils.GetArgumentExceptionWithArgName("name", SR.EnvVarNotFound_Name, name)
+            End If
+
+            Return VariableValue
+        End Function
+
+        '**********************************************************************
+        ';Culture
+        '
+        'Summary:
+        '   Get the information about the current culture used by the current thread.
+        'Returns:
+        '   The CultureInfo object that represents the culture used by the current thread.
+        '**********************************************************************
+        Public ReadOnly Property Culture() As System.Globalization.CultureInfo
+            Get
+                Return System.Threading.Thread.CurrentThread.CurrentCulture
+            End Get
+        End Property
+
+        '**********************************************************************
+        ';UICulture
+        '
+        'Summary:
+        '   Get the information about the current culture used by the Resource
+        '   Manager to look up culture-specific resource at run time.
+        'Returns:
+        '   The CultureInfo object that represents the culture used by the 
+        '   Resource Manager to look up culture-specific resources at run time.
+        '**********************************************************************
+        Public ReadOnly Property UICulture() As System.Globalization.CultureInfo
+            Get
+                Return System.Threading.Thread.CurrentThread.CurrentUICulture
+            End Get
+        End Property
+
+        '**********************************************************************
+        ';ChangeCulture
+        '
+        'Summary:
+        '   Change the culture currently in used by the current thread.
+        'Params:
+        '   CultureName: name of the culture as a String. For a list of possible 
+        '   names, see http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemGlobalizationCultureInfoClassTopic.asp
+        'Remarks:
+        '   CultureInfo constructor will throw exceptions if CultureName is Nothing 
+        '   or an invalid CultureInfo ID. We are not catching those exceptions.
+        '**********************************************************************
+        Public Sub ChangeCulture(ByVal cultureName As String)
+            System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo(cultureName)
+        End Sub
+
+        '**********************************************************************
+        ';ChangeUICulture
+        '
+        'Summary:
+        '   Change the culture currently used by the Resource Manager to look
+        '   up culture-specific resource at runtime.
+        'Params:
+        '   CultureName: name of the culture as a String. For a list of possible 
+        '   names, see http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemGlobalizationCultureInfoClassTopic.asp
+        'Remarks:
+        '   CultureInfo constructor will throw exceptions if CultureName is Nothing 
+        '   or an invalid CultureInfo ID. We are not catching those exceptions.
+        '**********************************************************************
+        Public Sub ChangeUICulture(ByVal cultureName As String)
+            System.Threading.Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo(cultureName)
+        End Sub
+
+        '= FRIEND =============================================================
+
+        '= PROTECTED ==========================================================
+
+        '= PRIVATE ==========================================================
+
+    End Class 'ApplicationBase
+End Namespace
diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/ApplicationServices/User.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/ApplicationServices/User.vb
new file mode 100644 (file)
index 0000000..e36ac7d
--- /dev/null
@@ -0,0 +1,101 @@
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Option Explicit On
+Option Strict On
+
+Imports System.ComponentModel
+Imports System.Security.Principal
+
+Namespace Microsoft.VisualBasic.ApplicationServices
+
+    '''************************************************************************
+    ''';User
+    ''' <summary>
+    ''' Class abstracting the computer user
+    ''' </summary>
+    Public Class User
+
+        '==PUBLIC**************************************************************
+
+        '''********************************************************************
+        ''';New
+        ''' <summary>
+        ''' Creates an instance of User
+        ''' </summary>
+        Public Sub New()
+        End Sub
+
+        '''********************************************************************
+        ''';Name
+        ''' <summary>
+        ''' The name of the current user
+        ''' </summary>
+        Public ReadOnly Property Name() As String
+            Get
+                Return InternalPrincipal.Identity.Name
+            End Get
+        End Property
+
+        '''********************************************************************
+        ''';CurrentPrincipal
+        ''' <summary>
+        ''' The current IPrincipal which represents the current user
+        ''' </summary>
+        ''' <value>An IPrincipal representing the current user</value>
+        <EditorBrowsable(EditorBrowsableState.Advanced)> Public Property CurrentPrincipal() As IPrincipal
+            Get
+                Return InternalPrincipal
+            End Get
+            Set(ByVal value As IPrincipal)
+                InternalPrincipal = value
+            End Set
+        End Property
+
+        '''********************************************************************
+        ''';IsAuthenticated
+        ''' <summary>
+        ''' Indicates whether or not the current user has been authenticated.
+        ''' </summary>
+        Public ReadOnly Property IsAuthenticated() As Boolean
+            Get
+                Return InternalPrincipal.Identity.IsAuthenticated
+            End Get
+        End Property
+
+        '''********************************************************************
+        ''';IsInRole
+        ''' <summary>
+        ''' Indicates whether or not the current user is a member of the passed in role
+        ''' </summary>
+        ''' <param name="role">The name of the role</param>
+        ''' <returns>True if the user is a member of the role otherwise False</returns>
+        Public Function IsInRole(ByVal role As String) As Boolean
+            Return InternalPrincipal.IsInRole(role)
+        End Function
+
+        '==PROTECTED***********************************************************
+
+        ''';InternalPrincipal
+        ''' <summary>
+        ''' The principal representing the current user.
+        ''' </summary>
+        ''' <value>An IPrincipal representing the current user</value>
+        ''' <remarks> 
+        ''' This should be overriden by derived classes that don't get the current
+        ''' user from the current thread
+        ''' </remarks>
+        Protected Overridable Property InternalPrincipal() As IPrincipal
+            Get
+                Return System.Threading.Thread.CurrentPrincipal
+            End Get
+            Set(ByVal value As IPrincipal)
+                System.Threading.Thread.CurrentPrincipal = value
+            End Set
+        End Property
+
+    End Class 'User
+
+End Namespace
+
index 3587e998538fbec9043d167fe2a44e6ceafe7955..6738542777949d4e72d6e499e5df5e34e33f0fc2 100644 (file)
@@ -3,6 +3,7 @@
 ' See the LICENSE file in the project root for more information.
 
 Imports System
+Imports Microsoft.VisualBasic.FileIO
 
 Namespace Global.Microsoft.VisualBasic.CompilerServices
     <Global.System.Diagnostics.DebuggerNonUserCode()>
@@ -87,5 +88,10 @@ Namespace Global.Microsoft.VisualBasic.CompilerServices
         Public Shared Sub ClearProjectError()
             Err.Clear()
         End Sub
+
+        Public Shared Sub EndApp()
+            FileSystem.CloseAllFiles(System.Reflection.Assembly.GetCallingAssembly())
+            System.Environment.Exit(0) 'System.Environment.Exit will cause finalizers to be run at shutdown
+        End Sub
     End Class
 End Namespace
diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/Audio.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/Audio.vb
new file mode 100644 (file)
index 0000000..e28094d
--- /dev/null
@@ -0,0 +1,33 @@
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Option Explicit On
+Option Strict On
+
+Namespace Microsoft.VisualBasic
+
+    Namespace Devices
+
+        '''**************************************************************************
+        ''';Audio
+        ''' <summary>
+        '''  An object that makes it easy to play wav files
+        ''' </summary>
+        ''' <remarks></remarks>
+        Public Class Audio
+
+            '* PUBLIC **************************************************************
+
+            '''**********************************************************************
+            ''';New
+            ''' <summary>
+            '''  Creates a new Audio object
+            ''' </summary>
+            ''' <remarks></remarks>
+            Public Sub New()
+            End Sub
+
+        End Class 'Audio
+    End Namespace
+End Namespace
diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/Clock.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/Clock.vb
new file mode 100644 (file)
index 0000000..381ed64
--- /dev/null
@@ -0,0 +1,65 @@
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Option Strict On
+Option Explicit On
+
+Imports System
+
+Namespace Microsoft.VisualBasic.Devices
+
+    '''**************************************************************************
+    ''' ;Clock
+    ''' <summary>
+    ''' A wrapper object that acts as a discovery mechanism to quickly find out
+    ''' the current local time of the machine and the GMT time.
+    ''' </summary>
+    Public Class Clock
+
+        '* PUBLIC *************************************************************
+
+        '''**************************************************************************
+        ''' ;LocalTime
+        ''' <summary>
+        ''' Gets a DateTime that is the current local date and time on this computer.
+        ''' </summary>
+        ''' <value>A DateTime whose value is the current date and time.</value>
+        Public ReadOnly Property LocalTime() As DateTime
+            Get
+                Return DateTime.Now
+            End Get
+        End Property
+
+        '''**************************************************************************
+        ''' ;GmtTime
+        ''' <summary>
+        ''' Gets a DateTime that is the current local date and time on this 
+        ''' computer expressed as GMT time.
+        ''' </summary>
+        ''' <value>A DateTime whose value is the current date and time expressed as GMT time.</value>
+        Public ReadOnly Property GmtTime() As DateTime
+            Get
+                Return DateTime.UtcNow
+            End Get
+        End Property
+
+        '''**************************************************************************
+        ''' ;TickCount
+        ''' <summary>
+        ''' This property wraps the Environment.TickCount property to get the
+        ''' number of milliseconds elapsed since the system started.
+        ''' </summary>
+        ''' <value>An Integer containing the amount of time in milliseconds.</value>
+        Public ReadOnly Property TickCount() As Integer
+            Get
+                Return System.Environment.TickCount
+            End Get
+        End Property
+
+        '* FRIEND *************************************************************
+
+        '* PRIVATE ************************************************************
+
+    End Class 'Clock
+End Namespace
diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/Computer.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/Computer.vb
new file mode 100644 (file)
index 0000000..f5c3aa5
--- /dev/null
@@ -0,0 +1,126 @@
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Option Strict On
+Option Explicit On
+
+Imports System
+Imports Microsoft.VisualBasic.MyServices
+Imports System.ComponentModel
+Imports System.Security.Permissions
+Imports Microsoft.VisualBasic
+
+Namespace Microsoft.VisualBasic.Devices
+
+    '''**************************************************************************
+    ''' ;Computer 
+    ''' <summary>
+    '''   A RAD object representing the 'computer' that serves as a discovery 
+    '''   mechanism for finding principle abstractions in the system that you can
+    '''   code against such as the file system, the clipboard, performance 
+    '''   counters, etc. It also provides functionality you would expect to see 
+    '''   associated with the computer such as playing sound, timers, access to 
+    '''   environment variables, etc. This class represent a general computer
+    '''   available from a Windows Application, Web app, Dll library, etc.
+    ''' </summary>
+    Public Class Computer : Inherits ServerComputer
+
+        '= PUBLIC =============================================================
+
+        'NOTE: The .Net design guidelines state that access to Instance members does not have to be thread-safe.  Access to Shared members does have to be thread-safe. 
+        'Since My.Computer creates the instance of Computer in a thread-safe way, access to the Computer will necessarily be thread-safe.
+        'There is nothing to prevent a user from passing our computer object across threads or creating their own instance and then getting into trouble.
+        ' But that is completely consistent with the rest of the FX design.  It is MY.* that is thread safe and leads to best practice access to these objects.
+        '  If you dim them up yourself, you are responsible for managing the threading.
+
+        '''**************************************************************************
+        ''' ;Audio
+        ''' <summary>
+        ''' Get an Audio object which can play sound files or resources.
+        ''' </summary>
+        ''' <value>A sound object.</value>
+        Public ReadOnly Property Audio() As Audio
+            Get
+                If m_Audio IsNot Nothing Then Return m_Audio
+                m_Audio = New Audio()
+                Return m_Audio
+            End Get
+        End Property
+
+        '''**************************************************************************
+        ''' ;Clipboard
+        ''' <summary>
+        ''' A thin wrapper for System.Windows.Forms.Clipboard
+        ''' </summary>
+        ''' <value>An object representing the clipboard</value>
+        Public ReadOnly Property Clipboard() As ClipboardProxy
+            Get
+                If m_Clipboard Is Nothing Then
+                    m_Clipboard = New ClipboardProxy()
+                End If
+
+                Return m_Clipboard
+            End Get
+        End Property
+
+        '''**************************************************************************
+        ''' ;Ports
+        ''' <summary>
+        ''' Gets a port object which gives access to the ports on the local machine
+        ''' </summary>
+        ''' <value>A collection of serial ports on the machine.</value>
+        Public ReadOnly Property Ports() As Ports
+            Get
+                If m_Ports Is Nothing Then
+                    m_Ports = New Ports()
+                End If
+
+                Return m_Ports
+            End Get
+        End Property
+
+        '''**************************************************************************
+        ''' ;Mouse
+        ''' <summary>
+        ''' This property returns the Mouse object containing information about
+        ''' the physical mouse installed to the machine.
+        ''' </summary>
+        ''' <value>An instance of the Mouse class.</value>
+        Public ReadOnly Property Mouse() As Mouse
+            Get
+                If m_Mouse IsNot Nothing Then Return m_Mouse
+                m_Mouse = New Mouse
+                Return m_Mouse
+            End Get
+        End Property
+
+        '''**************************************************************************
+        ''' ;Keyboard
+        ''' <summary>
+        ''' This property returns the Keyboard object representing some
+        ''' keyboard properties and a send keys method
+        ''' </summary>
+        ''' <value>An instance of the Keyboard class.</value>
+        Public ReadOnly Property Keyboard() As Keyboard
+            Get
+                If m_KeyboardInstance IsNot Nothing Then Return m_KeyboardInstance
+                m_KeyboardInstance = New Keyboard
+                Return m_KeyboardInstance
+            End Get
+        End Property
+
+        '= FRIENDS ============================================================
+
+        '= PROTECTED ==========================================================
+
+        '= PRIVATE ============================================================
+
+        Private m_Audio As Audio 'Lazy initialized cache for the Audio class.
+        Private m_Ports As Ports 'Lazy initialized cache for the Ports class
+        Private Shared m_Clipboard As ClipboardProxy 'Lazy initialized cacche for the clipboard class. (proxies can be shared - they have no state)
+        Private Shared m_Mouse As Mouse 'Lazy initialized cache for the Mouse class. SHARED because Mouse behaves as a readonly singleton class
+        Private Shared m_KeyboardInstance As Keyboard 'Lazy initialized cache for the Keyboard class.  SHARED because Keyboard behaves as a readonly singleton class
+
+    End Class 'Computer
+End Namespace
diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/ComputerInfo.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/ComputerInfo.vb
new file mode 100644 (file)
index 0000000..0d9d405
--- /dev/null
@@ -0,0 +1,108 @@
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Imports System
+Imports System.Diagnostics
+
+Namespace Microsoft.VisualBasic.Devices
+
+    '''*************************************************************************
+    ''' ;ComputerInfo
+    ''' <summary>
+    ''' Provides configuration information about the current computer and the current process.
+    ''' </summary>
+    <DebuggerTypeProxy(GetType(ComputerInfo.ComputerInfoDebugView))>
+    Public Class ComputerInfo
+
+        ' Keep the debugger proxy current as you change this class - see the nested ComputerInfoDebugView below.
+
+        '= PUBLIC =============================================================
+
+        '''******************************************************************************
+        ''' ;New
+        ''' <summary>
+        ''' Default ctor
+        ''' </summary>
+        Sub New()
+        End Sub
+
+        '''******************************************************************************
+        ''' ;InstalledUICulture
+        ''' <summary>
+        ''' Gets the current UICulture installed on the machine.
+        ''' </summary>
+        ''' <value>A CultureInfo object represents the UI culture installed on the machine.</value>
+        Public ReadOnly Property InstalledUICulture() As Globalization.CultureInfo
+            Get
+                Return Globalization.CultureInfo.InstalledUICulture
+            End Get
+        End Property
+
+        '''**************************************************************************
+        ''' ;OSPlatform
+        ''' <summary>
+        ''' Gets the platform OS name.
+        ''' </summary>
+        ''' <value>A string containing a Platform ID like "Win32NT", "Win32S", "Win32Windows". See PlatformID enum.</value>
+        ''' <exception cref="System.ExecutionEngineException">If cannot obtain the OS Version information.</exception>
+        Public ReadOnly Property OSPlatform() As String
+            Get
+                Return Environment.OSVersion.Platform.ToString
+            End Get
+        End Property
+
+        '''******************************************************************************
+        ''' ;OSVersion
+        ''' <summary>
+        ''' Get the current version number of the operating system.
+        ''' </summary>
+        ''' <value>A string contains the current version number of the operating system.</value>
+        ''' <exception cref="System.ExecutionEngineException">If cannot obtain the OS Version information.</exception>
+        Public ReadOnly Property OSVersion() As String
+            Get
+                Return Environment.OSVersion.Version.ToString
+            End Get
+        End Property
+
+        '= FRIEND =============================================================
+
+        '''******************************************************************************
+        ''' ;ComputerInfoDebugView
+        ''' <summary>
+        ''' Debugger proxy for the ComputerInfo class.  The problem is that OSFullName can time out the debugger
+        ''' so we offer a view that doesn't have that field. 
+        ''' </summary>
+        ''' <remarks></remarks>
+        Friend NotInheritable Class ComputerInfoDebugView
+            Public Sub New(ByVal RealClass As ComputerInfo)
+                m_InstanceBeingWatched = RealClass
+            End Sub
+
+            <DebuggerBrowsable(DebuggerBrowsableState.RootHidden)>
+            Public ReadOnly Property InstalledUICulture() As Globalization.CultureInfo
+                Get
+                    Return m_InstanceBeingWatched.InstalledUICulture
+                End Get
+            End Property
+
+            <DebuggerBrowsable(DebuggerBrowsableState.RootHidden)>
+            Public ReadOnly Property OSPlatform() As String
+                Get
+                    Return m_InstanceBeingWatched.OSPlatform
+                End Get
+            End Property
+
+            <DebuggerBrowsable(DebuggerBrowsableState.RootHidden)>
+            Public ReadOnly Property OSVersion() As String
+                Get
+                    Return m_InstanceBeingWatched.OSVersion
+                End Get
+            End Property
+
+            <DebuggerBrowsable(DebuggerBrowsableState.Never)> Private m_InstanceBeingWatched As ComputerInfo
+        End Class
+
+    End Class
+
+End Namespace
diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/Keyboard.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/Keyboard.vb
new file mode 100644 (file)
index 0000000..dbefa08
--- /dev/null
@@ -0,0 +1,20 @@
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Option Explicit On
+Option Strict On
+
+Namespace Microsoft.VisualBasic.Devices
+
+    '*****************************************************************************
+    ';Keyboard
+    '
+    'Remarks: A class representing a computer keyboard. Enables discovery of key
+    '         state information for the most common scenarios and enables SendKeys 
+    '*****************************************************************************
+    Public Class Keyboard
+
+    End Class
+
+End Namespace
diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/Mouse.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/Mouse.vb
new file mode 100644 (file)
index 0000000..d860eca
--- /dev/null
@@ -0,0 +1,23 @@
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Option Strict On
+Option Explicit On
+
+Namespace Microsoft.VisualBasic.Devices
+
+    '''**************************************************************************
+    ''' ;Mouse
+    ''' <summary>
+    ''' A wrapper object that acts as a discovery mechanism for finding 
+    ''' information about the mouse on your computer such as whether the mouse
+    ''' exists, the number of buttons, wheelscrolls details.
+    ''' 
+    ''' This class is a Singleton Class. See Common.Computer for details.
+    ''' </summary>
+    ''' <remarks></remarks>
+    Public Class Mouse
+
+    End Class 'Mouse
+End Namespace
diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/Network.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/Network.vb
new file mode 100644 (file)
index 0000000..442d160
--- /dev/null
@@ -0,0 +1,31 @@
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Option Explicit On
+Option Strict On
+
+Namespace Microsoft.VisualBasic.Devices
+
+    '''**************************************************************************
+    ''';Network
+    ''' <summary>
+    '''  An object that allows easy access to some simple network properties and functionality.
+    ''' </summary>
+    ''' <remarks></remarks>
+    Public Class Network
+
+        '* PUBLIC *************************************************************
+
+        '''**********************************************************************
+        ''';New - Constructor
+        ''' <summary>
+        '''  Creates class and hooks up events
+        ''' </summary>
+        ''' <remarks></remarks>
+        Public Sub New()
+        End Sub
+
+    End Class
+
+End Namespace
diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/Ports.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/Ports.vb
new file mode 100644 (file)
index 0000000..5ea9ad6
--- /dev/null
@@ -0,0 +1,30 @@
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Option Explicit On
+Option Strict On
+
+Namespace Microsoft.VisualBasic.Devices
+
+    '''*************************************************************************
+    ''';Ports
+    ''' <summary>
+    '''  Gives access to Ports on the local machine
+    ''' </summary>
+    ''' <remarks>Only serial ports are supported at present, but this class may expand in the future</remarks>
+    Public Class Ports
+
+        '==PUBLIC**************************************************************
+
+        '''*********************************************************************
+        ''';New
+        ''' <summary>
+        '''  Constructor
+        ''' </summary>
+        ''' <remarks></remarks>
+        Public Sub New()
+        End Sub
+
+    End Class
+End Namespace
diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/ServerComputer.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Devices/ServerComputer.vb
new file mode 100644 (file)
index 0000000..9d4a1de
--- /dev/null
@@ -0,0 +1,135 @@
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Option Strict On
+Option Explicit On
+
+Imports System
+Imports System.ComponentModel
+Imports System.Security.Permissions
+Imports Microsoft.VisualBasic
+Imports Microsoft.VisualBasic.MyServices
+
+Namespace Microsoft.VisualBasic.Devices
+
+    '''**************************************************************************
+    ''' ;ServerComputer
+    ''' <summary>
+    ''' A RAD object representing the server 'computer' for the web/Windows Services
+    ''' that serves as a discovery mechanism for finding principle abstractions in
+    ''' the system that you can code against
+    ''' </summary>
+    Public Class ServerComputer
+
+        '= PUBLIC =============================================================
+
+        'NOTE: The .Net design guidelines state that access to Instance members does not have to be thread-safe.  Access to Shared members does have to be thread-safe. 
+        'Since My.Computer creates the instance of Computer in a thread-safe way, access to the Computer will necessarily be thread-safe.
+        'There is nothing to prevent a user from passing our computer object across threads or creating their own instance and then getting into trouble.
+        'But that is completely consistent with the rest of the FX design.  It is MY.* that is thread safe and leads to best practice access to these objects.
+        'If you dim them up yourself, you are responsible for managing the threading.
+
+        '''**************************************************************************
+        ''' ;Clock
+        ''' <summary>
+        ''' Returns the Clock object which contains the LocalTime and GMTTime.
+        ''' </summary>
+        Public ReadOnly Property Clock() As Clock
+            Get
+                If m_Clock IsNot Nothing Then Return m_Clock
+                m_Clock = New Clock
+                Return m_Clock
+            End Get
+        End Property
+
+        '''**************************************************************************
+        ''' ;FileSystem
+        ''' <summary>
+        ''' Gets the object representing the file system of the computer.
+        ''' </summary>
+        ''' <value>A System.IO.FileSystem object.</value>
+        ''' <remarks>The instance returned by this property is lazy initialized and cached.</remarks>
+        Public ReadOnly Property FileSystem() As FileSystemProxy
+            Get
+                If m_FileIO Is Nothing Then
+                    m_FileIO = New FileSystemProxy
+                End If
+                Return m_FileIO
+            End Get
+        End Property
+
+        '''**************************************************************************
+        ''' ;Info
+        ''' <summary>
+        ''' Gets the object representing information about the computer's state
+        ''' </summary>
+        ''' <value>A Microsoft.VisualBasic.MyServices.ComputerInfo object.</value>
+        ''' <remarks>The instance returned by this property is lazy initialized and cached.</remarks>
+        Public ReadOnly Property Info() As ComputerInfo
+            Get
+                If m_ComputerInfo Is Nothing Then
+                    m_ComputerInfo = New ComputerInfo
+                End If
+                Return m_ComputerInfo
+            End Get
+        End Property
+
+        '''**************************************************************************
+        ''' ;Network
+        ''' <summary>
+        ''' This property returns the Network object containing information about 
+        ''' the network the machine is part of.
+        ''' </summary>
+        ''' <value>An instance of the Network.Network class.</value>
+        Public ReadOnly Property Network() As Network
+            Get
+                If m_Network IsNot Nothing Then Return m_Network
+                m_Network = New Network
+                Return m_Network
+            End Get
+        End Property
+
+        '''**************************************************************************
+        ''' ;Name
+        ''' <summary>
+        ''' This property wraps the System.Environment.MachineName property 
+        ''' in the .NET framework to return the name of the computer.
+        ''' </summary>
+        ''' <value>A string containing the name of the computer.</value>
+        Public ReadOnly Property Name() As String
+            Get
+                Return System.Environment.MachineName
+            End Get
+        End Property
+
+        '''**************************************************************************
+        ''' ;Registry
+        ''' <summary>
+        ''' Get the Registry object, which can be used to read, set and 
+        ''' enumerate keys and values in the system registry.
+        ''' </summary>
+        ''' <value>An instance of the RegistryProxy object</value>
+        ''' <remarks></remarks>
+        Public ReadOnly Property Registry() As RegistryProxy
+            Get
+                If m_RegistryInstance IsNot Nothing Then Return m_RegistryInstance
+                m_RegistryInstance = New RegistryProxy
+                Return m_RegistryInstance
+            End Get
+        End Property
+
+        '= FRIENDS ============================================================
+
+        '= PROTECTED ==========================================================
+
+        '= PRIVATE ============================================================
+
+        Private m_ComputerInfo As ComputerInfo 'Lazy initialized cache for ComputerInfo
+        Private m_FileIO As FileSystemProxy 'Lazy initialized cache for the FileSystem.
+        Private m_Network As Network 'Lazy initialized cache for the Network class.
+        Private m_RegistryInstance As RegistryProxy 'Lazy initialized cache for the Registry class
+        Private Shared m_Clock As Clock 'Lazy initialized cache for the Clock class.  SHARED because Clock behaves as a readonly singleton class
+
+    End Class 'MyServerComputer
+End Namespace
index a40cfb7a2daf637085c6474370c5da10cd6adabb..d6c3e88d251a0d04d5723e2f6eac3ce7ff681684 100644 (file)
@@ -30,7 +30,6 @@ Namespace Microsoft.VisualBasic.FileIO
             Get
                 ' NOTE: Don't cache the collection since it may change without us knowing.
                 ' The performance hit will be small since it's a small collection.
-                ' CONSIDER: : Create a read-only collection from an array?
                 Dim DriveInfoCollection As New ObjectModel.Collection(Of System.IO.DriveInfo)
                 For Each DriveInfo As System.IO.DriveInfo In IO.DriveInfo.GetDrives()
                     DriveInfoCollection.Add(DriveInfo)
index 4b503cd393c4335a391c674e294550a51a2efe8e..5e67cd9ece5eb4a6bb34b30f9386aad26d0ed309 100644 (file)
@@ -486,7 +486,7 @@ Namespace Microsoft.VisualBasic.FileIO
         End Sub
 
         ''' <summary>
-        ''' Validates that the value being passed as an AudioPlayMode enum is a legal value
+        ''' Validates that the value being passed as an FieldType is a legal value
         ''' </summary>
         ''' <param name="value"></param>
         ''' <remarks></remarks>
diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/FileSystem.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/FileSystem.vb
new file mode 100644 (file)
index 0000000..c5a509d
--- /dev/null
@@ -0,0 +1,17 @@
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Imports System
+
+Namespace Microsoft.VisualBasic
+
+    Friend Module FileSystem
+
+        Friend Sub CloseAllFiles(ByVal assem As System.Reflection.Assembly)
+            ' CloseAllFiles(ProjectData.GetProjectData().GetAssemblyData(assem))
+        End Sub
+
+    End Module
+End Namespace
+
diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/MyServices/ClipboardProxy.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/MyServices/ClipboardProxy.vb
new file mode 100644 (file)
index 0000000..96f5642
--- /dev/null
@@ -0,0 +1,32 @@
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Option Explicit On
+Option Strict On
+
+Imports System.ComponentModel
+
+Namespace Microsoft.VisualBasic.MyServices
+
+    '''*****************************************************************************
+    ''';ClipboardProxy
+    ''' <summary>
+    ''' A class that wraps System.Windows.Forms.Clipboard so that
+    ''' a clipboard can be instanced.
+    ''' </summary>
+    <EditorBrowsable(EditorBrowsableState.Never)>
+    Public Class ClipboardProxy
+
+        '==PUBLIC*******************************************************************
+
+        '''*************************************************************************
+        ''';New
+        ''' <summary>
+        ''' Only Allows instantiation of the class
+        ''' </summary>
+        Friend Sub New()
+        End Sub
+
+    End Class
+End Namespace
diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/MyServices/FileSystemProxy.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/MyServices/FileSystemProxy.vb
new file mode 100644 (file)
index 0000000..1a69015
--- /dev/null
@@ -0,0 +1,44 @@
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Option Strict On
+Option Explicit On
+
+Imports System
+Imports System.ComponentModel
+
+Namespace Microsoft.VisualBasic.MyServices
+
+    '''******************************************************************************
+    ''' ;FileSystemProxy
+    ''' <summary>
+    ''' An extremely thin wrapper around Microsoft.VisualBasic.FileIO.FileSystem to expose the type through My.
+    ''' </summary>
+    <System.ComponentModel.EditorBrowsable(EditorBrowsableState.Never)>
+    Public Class FileSystemProxy
+
+        '= PUBLIC =============================================================
+
+        Public ReadOnly Property SpecialDirectories() As MyServices.SpecialDirectoriesProxy
+            Get
+                If m_SpecialDirectoriesProxy Is Nothing Then
+                    m_SpecialDirectoriesProxy = New SpecialDirectoriesProxy
+                End If
+                Return m_SpecialDirectoriesProxy
+            End Get
+        End Property
+
+        '= FRIEND =============================================================
+
+        '''******************************************************************************
+        ''' ;New
+        ''' <summary>
+        ''' Proxy class can only created by internal classes.
+        ''' </summary>
+        Friend Sub New()
+        End Sub
+
+        Private m_SpecialDirectoriesProxy As SpecialDirectoriesProxy = Nothing
+    End Class
+End Namespace
diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/MyServices/RegistryProxy.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/MyServices/RegistryProxy.vb
new file mode 100644 (file)
index 0000000..703bdeb
--- /dev/null
@@ -0,0 +1,29 @@
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Imports System.ComponentModel
+
+Namespace Microsoft.VisualBasic.MyServices
+
+    '''*************************************************************************
+    ''' ;RegistryProxy
+    ''' <summary>
+    ''' An extremely thin wrapper around Microsoft.Win32.Registry to expose the type through My.
+    ''' </summary>
+    <System.ComponentModel.EditorBrowsable(EditorBrowsableState.Never)>
+    Public Class RegistryProxy
+
+        '= FRIEND =============================================================
+
+        '''*************************************************************************
+        ''' ;New
+        ''' <summary>
+        ''' Proxy class can only created by internal classes.
+        ''' </summary>
+        Friend Sub New()
+        End Sub
+
+    End Class
+End Namespace
+
diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/MyServices/SpecialDirectoriesProxy.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/MyServices/SpecialDirectoriesProxy.vb
new file mode 100644 (file)
index 0000000..30ae3df
--- /dev/null
@@ -0,0 +1,86 @@
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Imports System.ComponentModel
+Imports Microsoft.VisualBasic.FileIO
+
+Namespace Microsoft.VisualBasic.MyServices
+
+    '''*************************************************************************
+    ''' ;SpecialDirectoriesProxy
+    ''' <summary>
+    ''' An extremely thin wrapper around Microsoft.VisualBasic.FileIO.SpecialDirectories to expose the type through My.
+    ''' </summary>
+    <System.ComponentModel.EditorBrowsable(EditorBrowsableState.Never)>
+    Public Class SpecialDirectoriesProxy
+
+        '= PUBLIC =============================================================
+
+        Public ReadOnly Property MyDocuments() As String
+            Get
+                Return SpecialDirectories.MyDocuments
+            End Get
+        End Property
+
+        Public ReadOnly Property MyMusic() As String
+            Get
+                Return SpecialDirectories.MyMusic
+            End Get
+        End Property
+
+        Public ReadOnly Property MyPictures() As String
+            Get
+                Return SpecialDirectories.MyPictures
+            End Get
+        End Property
+
+        Public ReadOnly Property Desktop() As String
+            Get
+                Return SpecialDirectories.Desktop
+            End Get
+        End Property
+
+        Public ReadOnly Property Programs() As String
+            Get
+                Return SpecialDirectories.Programs
+            End Get
+        End Property
+
+        Public ReadOnly Property ProgramFiles() As String
+            Get
+                Return SpecialDirectories.ProgramFiles
+            End Get
+        End Property
+
+        Public ReadOnly Property Temp() As String
+            Get
+                Return SpecialDirectories.Temp
+            End Get
+        End Property
+
+        Public ReadOnly Property CurrentUserApplicationData() As String
+            Get
+                Return SpecialDirectories.CurrentUserApplicationData
+            End Get
+        End Property
+
+        Public ReadOnly Property AllUsersApplicationData() As String
+            Get
+                Return SpecialDirectories.AllUsersApplicationData
+            End Get
+        End Property
+
+        '= FRIEND =============================================================
+
+        '''*************************************************************************
+        ''' ;New
+        ''' <summary>
+        ''' Proxy class can only created by internal classes.
+        ''' </summary>
+        Friend Sub New()
+        End Sub
+
+    End Class
+
+End Namespace
index acf56fa2750edf0a2ee74cb48b217910d70f50eb..0ea07aa8f9a7bc22a77474953a62736b3d78e5ec 100644 (file)
@@ -3,6 +3,7 @@
     <BuildConfigurations>
       netcoreapp;
       uap;
+      netfx;
     </BuildConfigurations>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index ce134d4ce0c9962be8d1cee68fe9c2090ba06345..7039fb806b9b7e55be27cf79851cf8a341ea2ac9 100644 (file)
@@ -47,14 +47,17 @@ namespace Microsoft.VisualBasic.Tests
         [Fact]
         public void FilterDefaultMessage()
         {
-            ProjectData.SetProjectError(new System.IO.FileNotFoundException("Description"));
-            Assert.Equal("Description", Information.Err().Description);
+            string message = "Description";
+            ProjectData.SetProjectError(new System.IO.FileNotFoundException(message));
+            Assert.Equal(message, Information.Err().Description);
 
-            ProjectData.SetProjectError(new System.IO.FileNotFoundException(""));
-            Assert.Equal("ID53", Information.Err().Description);
+            message = "";
+            ProjectData.SetProjectError(new System.IO.FileNotFoundException(message));
+            Assert.NotEqual(message, Information.Err().Description);
 
-            ProjectData.SetProjectError(new System.IO.FileNotFoundException("Exception from HRESULT: 0x80"));
-            Assert.Equal("ID53", Information.Err().Description);
+            message = "Exception from HRESULT: 0x80";
+            ProjectData.SetProjectError(new System.IO.FileNotFoundException(message));
+            Assert.NotEqual(message, Information.Err().Description);
         }
     }
 }
index e8de35a609dcee7be169fd1154c2832281eb8f49..35f67df1bbef0349c5b75da8a4f9014b11503b9d 100644 (file)
     <Compile Include="LateBindingTests.cs" />
     <Compile Include="LikeOperatorTests.cs" />
     <Compile Include="LongTypeTests.cs" />
+    <Compile Include="Microsoft\VisualBasic\ApplicationServices\ApplicationBaseTests.cs" />
     <Compile Include="Microsoft\VisualBasic\ApplicationServices\StartupEventArgsTests.cs" />
     <Compile Include="Microsoft\VisualBasic\ApplicationServices\StartupNextInstanceEventArgsTests.cs" />
     <Compile Include="Microsoft\VisualBasic\ApplicationServices\UnhandledExceptionEventArgsTests.cs" />
+    <Compile Include="Microsoft\VisualBasic\ApplicationServices\UserTests.cs" />
     <Compile Include="Microsoft\VisualBasic\ComClassAttributeTests.cs" />
     <Compile Include="Microsoft\VisualBasic\CompilerServices\DesignerGeneratedAttributeTests.cs" />
     <Compile Include="Microsoft\VisualBasic\CompilerServices\OptionCompareAttributeTests.cs" />
     <Compile Include="Microsoft\VisualBasic\CompilerServices\OptionTextAttributeTests.cs" />
     <Compile Include="Microsoft\VisualBasic\CompilerServices\StandardModuleAttributeTests.cs" />
     <Compile Include="Microsoft\VisualBasic\CompilerServices\StructUtilsTests.cs" />
+    <Compile Include="Microsoft\VisualBasic\Devices\ClockTests.cs" />
+    <Compile Include="Microsoft\VisualBasic\Devices\ComputerInfoTests.cs" />
+    <Compile Include="Microsoft\VisualBasic\Devices\ComputerTests.cs" />
     <Compile Include="Microsoft\VisualBasic\Devices\NetworkAvailableEventArgsTests.cs" />
+    <Compile Include="Microsoft\VisualBasic\Devices\ServerComputerTests.cs" />
     <Compile Include="Microsoft\VisualBasic\HideModuleNameAttributeTests.cs" />
     <Compile Include="Microsoft\VisualBasic\MyGroupCollectionAttributeTests.cs" />
+    <Compile Include="Microsoft\VisualBasic\MyServices\FileSystemProxyTests.cs" />
+    <Compile Include="Microsoft\VisualBasic\MyServices\SpecialDirectoriesProxyTests.cs" />
     <Compile Include="Microsoft\VisualBasic\VBFixedArrayAttributeTests.cs" />
     <Compile Include="Microsoft\VisualBasic\VBFixedStringAttributeTests.cs" />
     <Compile Include="ObjectTypeTests.cs" />
diff --git a/src/libraries/Microsoft.VisualBasic.Core/tests/Microsoft/VisualBasic/ApplicationServices/ApplicationBaseTests.cs b/src/libraries/Microsoft.VisualBasic.Core/tests/Microsoft/VisualBasic/ApplicationServices/ApplicationBaseTests.cs
new file mode 100644 (file)
index 0000000..d83952b
--- /dev/null
@@ -0,0 +1,60 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Xunit;
+
+namespace Microsoft.VisualBasic.ApplicationServices.Tests
+{
+    public class ApplicationBaseTests
+    {
+        [Fact]
+        public void Culture()
+        {
+            var app = new ApplicationBase();
+            var culture = app.Culture;
+            Assert.Equal(System.Threading.Thread.CurrentThread.CurrentCulture, culture);
+            try
+            {
+                app.ChangeCulture("en-US");
+                Assert.Equal(System.Threading.Thread.CurrentThread.CurrentCulture, app.Culture);
+                Assert.Equal("en-US", app.Culture.Name);
+            }
+            finally
+            {
+                System.Threading.Thread.CurrentThread.CurrentCulture = culture;
+            }
+        }
+
+        [Fact]
+        public void UICulture()
+        {
+            var app = new ApplicationBase();
+            var culture = app.UICulture;
+            Assert.Equal(System.Threading.Thread.CurrentThread.CurrentUICulture, culture);
+            try
+            {
+                app.ChangeUICulture("en-US");
+                Assert.Equal(System.Threading.Thread.CurrentThread.CurrentUICulture, app.UICulture);
+                Assert.Equal("en-US", app.UICulture.Name);
+            }
+            finally
+            {
+                System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
+            }
+        }
+
+        [Fact]
+        public void GetEnvironmentVariable()
+        {
+            var app = new ApplicationBase();
+            var variables = System.Environment.GetEnvironmentVariables().Keys;
+            foreach (string variable in variables)
+            {
+                Assert.Equal(System.Environment.GetEnvironmentVariable(variable), app.GetEnvironmentVariable(variable));
+                break;
+            }
+        }
+    }
+}
diff --git a/src/libraries/Microsoft.VisualBasic.Core/tests/Microsoft/VisualBasic/ApplicationServices/UserTests.cs b/src/libraries/Microsoft.VisualBasic.Core/tests/Microsoft/VisualBasic/ApplicationServices/UserTests.cs
new file mode 100644 (file)
index 0000000..0cae95b
--- /dev/null
@@ -0,0 +1,25 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Xunit;
+
+namespace Microsoft.VisualBasic.ApplicationServices.Tests
+{
+    public class UserTests
+    {
+        [Fact]
+        public void Properties()
+        {
+            var user = new User();
+            Assert.Equal(System.Threading.Thread.CurrentPrincipal, user.CurrentPrincipal);
+            if (user.CurrentPrincipal != null)
+            {
+                Assert.Equal(System.Threading.Thread.CurrentPrincipal.Identity.Name, user.Name);
+                Assert.Equal(System.Threading.Thread.CurrentPrincipal.Identity.IsAuthenticated, user.IsAuthenticated);
+                Assert.Equal(System.Threading.Thread.CurrentPrincipal.IsInRole("Guest"), user.IsInRole("Guest"));
+            }
+        }
+    }
+}
diff --git a/src/libraries/Microsoft.VisualBasic.Core/tests/Microsoft/VisualBasic/Devices/ClockTests.cs b/src/libraries/Microsoft.VisualBasic.Core/tests/Microsoft/VisualBasic/Devices/ClockTests.cs
new file mode 100644 (file)
index 0000000..92a7deb
--- /dev/null
@@ -0,0 +1,58 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Xunit;
+
+namespace Microsoft.VisualBasic.Devices.Tests
+{
+    public class ClockTests
+    {
+        [Fact]
+        public void LocalTime()
+        {
+            var clock = new Clock();
+
+            var before = clock.LocalTime;
+            System.Threading.Thread.Sleep(10);
+
+            var now = DateTime.Now;
+            System.Threading.Thread.Sleep(10);
+
+            var after = clock.LocalTime;
+
+            Assert.True(before <= now);
+            Assert.True(now <= after);
+        }
+
+        [Fact]
+        public void GmtTime()
+        {
+            var clock = new Clock();
+
+            var before = clock.GmtTime;
+            System.Threading.Thread.Sleep(10);
+
+            var now = DateTime.UtcNow;
+            System.Threading.Thread.Sleep(10);
+
+            var after = clock.GmtTime;
+
+            Assert.True(before <= now);
+            Assert.True(now <= after);
+        }
+
+        [Fact]
+        public void TickCount()
+        {
+            var clock = new Clock();
+
+            var before = clock.TickCount;
+            System.Threading.Thread.Sleep(10);
+
+            var after = clock.TickCount;
+            Assert.True(before <=  after);
+        }
+    }
+}
diff --git a/src/libraries/Microsoft.VisualBasic.Core/tests/Microsoft/VisualBasic/Devices/ComputerInfoTests.cs b/src/libraries/Microsoft.VisualBasic.Core/tests/Microsoft/VisualBasic/Devices/ComputerInfoTests.cs
new file mode 100644 (file)
index 0000000..a3395ca
--- /dev/null
@@ -0,0 +1,21 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Xunit;
+
+namespace Microsoft.VisualBasic.Devices.Tests
+{
+    public class ComputerInfoTests
+    {
+        [Fact]
+        public void Properties()
+        {
+            var info = new ComputerInfo();
+            Assert.Equal(System.Globalization.CultureInfo.InstalledUICulture, info.InstalledUICulture);
+            Assert.Equal(System.Environment.OSVersion.Platform.ToString(), info.OSPlatform);
+            Assert.Equal(System.Environment.OSVersion.Version.ToString(), info.OSVersion);
+        }
+    }
+}
diff --git a/src/libraries/Microsoft.VisualBasic.Core/tests/Microsoft/VisualBasic/Devices/ComputerTests.cs b/src/libraries/Microsoft.VisualBasic.Core/tests/Microsoft/VisualBasic/Devices/ComputerTests.cs
new file mode 100644 (file)
index 0000000..8e922f0
--- /dev/null
@@ -0,0 +1,38 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Xunit;
+
+namespace Microsoft.VisualBasic.Devices.Tests
+{
+    public class ComputerTests
+    {
+        [Fact]
+        public void Properties()
+        {
+            var computer = new Computer();
+
+            var audio = computer.Audio;
+            Assert.NotNull(audio);
+            Assert.Same(audio, computer.Audio);
+
+            var clipboard = computer.Clipboard;
+            Assert.NotNull(clipboard);
+            Assert.Same(clipboard, computer.Clipboard);
+
+            var keyboard = computer.Keyboard;
+            Assert.NotNull(keyboard);
+            Assert.Same(keyboard, computer.Keyboard);
+
+            var mouse = computer.Mouse;
+            Assert.NotNull(mouse);
+            Assert.Same(mouse, computer.Mouse);
+
+            var ports = computer.Ports;
+            Assert.NotNull(ports);
+            Assert.Same(ports, computer.Ports);
+        }
+    }
+}
diff --git a/src/libraries/Microsoft.VisualBasic.Core/tests/Microsoft/VisualBasic/Devices/ServerComputerTests.cs b/src/libraries/Microsoft.VisualBasic.Core/tests/Microsoft/VisualBasic/Devices/ServerComputerTests.cs
new file mode 100644 (file)
index 0000000..de0e1e4
--- /dev/null
@@ -0,0 +1,40 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Xunit;
+
+namespace Microsoft.VisualBasic.Devices.Tests
+{
+    public class ServerComputerTests
+    {
+        [Fact]
+        public void Properties()
+        {
+            var computer = new ServerComputer();
+
+            Assert.Equal(System.Environment.MachineName, computer.Name);
+
+            var clock = computer.Clock;
+            Assert.NotNull(clock);
+            Assert.Same(clock, computer.Clock);
+
+            var fileSystem = computer.FileSystem;
+            Assert.NotNull(fileSystem);
+            Assert.Same(fileSystem, computer.FileSystem);
+
+            var info = computer.Info;
+            Assert.NotNull(info);
+            Assert.Same(info, computer.Info);
+
+            var network = computer.Network;
+            Assert.NotNull(network);
+            Assert.Same(network, computer.Network);
+
+            var registry = computer.Registry;
+            Assert.NotNull(registry);
+            Assert.Same(registry, computer.Registry);
+        }
+    }
+}
diff --git a/src/libraries/Microsoft.VisualBasic.Core/tests/Microsoft/VisualBasic/MyServices/FileSystemProxyTests.cs b/src/libraries/Microsoft.VisualBasic.Core/tests/Microsoft/VisualBasic/MyServices/FileSystemProxyTests.cs
new file mode 100644 (file)
index 0000000..7fe939d
--- /dev/null
@@ -0,0 +1,22 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Microsoft.VisualBasic.Devices;
+using Xunit;
+
+namespace Microsoft.VisualBasic.MyServices.Tests
+{
+    public class FileSystemProxyTests
+    {
+        [Fact]
+        public void SpecialDirectories()
+        {
+            FileSystemProxy fileSystem = new ServerComputer().FileSystem;
+            var specialDirectories = fileSystem.SpecialDirectories;
+            Assert.NotNull(specialDirectories);
+            Assert.Same(specialDirectories, fileSystem.SpecialDirectories);
+        }
+    }
+}
diff --git a/src/libraries/Microsoft.VisualBasic.Core/tests/Microsoft/VisualBasic/MyServices/SpecialDirectoriesProxyTests.cs b/src/libraries/Microsoft.VisualBasic.Core/tests/Microsoft/VisualBasic/MyServices/SpecialDirectoriesProxyTests.cs
new file mode 100644 (file)
index 0000000..f7d05e7
--- /dev/null
@@ -0,0 +1,43 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Microsoft.VisualBasic.Devices;
+using Xunit;
+
+namespace Microsoft.VisualBasic.MyServices.Tests
+{
+    public class SpecialDirectoriesProxyTests
+    {
+        [Fact]
+        public void Properties()
+        {
+            SpecialDirectoriesProxy specialDirectories = new ServerComputer().FileSystem.SpecialDirectories;
+            VerifySpecialDirectory(() => Microsoft.VisualBasic.FileIO.SpecialDirectories.AllUsersApplicationData, () => specialDirectories.AllUsersApplicationData);
+            VerifySpecialDirectory(() => Microsoft.VisualBasic.FileIO.SpecialDirectories.CurrentUserApplicationData, () => specialDirectories.CurrentUserApplicationData);
+            VerifySpecialDirectory(() => Microsoft.VisualBasic.FileIO.SpecialDirectories.Desktop, () => specialDirectories.Desktop);
+            VerifySpecialDirectory(() => Microsoft.VisualBasic.FileIO.SpecialDirectories.MyDocuments, () => specialDirectories.MyDocuments);
+            VerifySpecialDirectory(() => Microsoft.VisualBasic.FileIO.SpecialDirectories.MyMusic, () => specialDirectories.MyMusic);
+            VerifySpecialDirectory(() => Microsoft.VisualBasic.FileIO.SpecialDirectories.MyPictures, () => specialDirectories.MyPictures);
+            VerifySpecialDirectory(() => Microsoft.VisualBasic.FileIO.SpecialDirectories.Programs, () => specialDirectories.Programs);
+            VerifySpecialDirectory(() => Microsoft.VisualBasic.FileIO.SpecialDirectories.ProgramFiles, () => specialDirectories.ProgramFiles);
+            VerifySpecialDirectory(() => Microsoft.VisualBasic.FileIO.SpecialDirectories.Temp, () => specialDirectories.Temp);
+        }
+
+        private static void VerifySpecialDirectory(Func<string> getExpected, Func<string> getActual)
+        {
+            string expected;
+            try
+            {
+                expected = getExpected();
+            }
+            catch (Exception)
+            {
+                return;
+            }
+            string actual = getActual();
+            Assert.Equal(expected, actual);
+        }
+    }
+}
index 64887d94a0521d38b228e35122337f32f1903673..f1af4d34481fe0b44ecf83d1287304acdbfe96d9 100644 (file)
@@ -2,7 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-using Microsoft.VisualBasic.CompilerServices;
+using Microsoft.DotNet.RemoteExecutor;
 using System;
 using Xunit;
 
@@ -48,5 +48,16 @@ namespace Microsoft.VisualBasic.CompilerServices.Tests
             Assert.Null(Information.Err().GetException());
             Assert.Equal(0, Information.Err().Erl);
         }
+
+        [Fact]
+        public void EndApp()
+        {
+            RemoteExecutor.Invoke(new Action(() =>
+            {
+                ProjectData.EndApp();
+                throw new Exception(); // Shouldn't reach here.
+            }),
+            new RemoteInvokeOptions() { ExpectedExitCode = 0 }).Dispose();
+        }
     }
 }