<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.Extensions" />
<Reference Include="System.Runtime.InteropServices" />
- <Reference Include="System.Security.Permissions" />
<Reference Include="System.Text.RegularExpressions" />
<Reference Include="System.Threading" />
<Reference Include="System.Threading.Tasks" />
Imports System.Diagnostics
Imports System.Dynamic
Imports System.Reflection
-Imports System.Security
Imports Microsoft.VisualBasic.CompilerServices.Symbols
Imports Microsoft.VisualBasic.CompilerServices.ConversionResolution
Return ChangeType(Expression, TargetType, False)
End Function
- <SecuritySafeCritical()>
Friend Shared Function ChangeType(ByVal Expression As Object, ByVal TargetType As Type, ByVal Dynamic As Boolean) As Object
If TargetType Is Nothing Then
Throw New ArgumentException(SR.Format(SR.Argument_InvalidNullValue1, "TargetType"))
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Security
-Imports System.Runtime.Versioning
Imports System.Text
Imports Microsoft.VisualBasic.CompilerServices
''' Copy/MoveFile will call this directly. Copy/MoveDirectory will call ShellCopyOrMoveDirectory first
''' to change the path if needed.
''' </remarks>
- <SecurityCritical()>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Private Shared Sub ShellCopyOrMove(ByVal Operation As CopyOrMove, ByVal TargetType As FileOrDirectory,
ByVal FullSourcePath As String, ByVal FullTargetPath As String, ByVal ShowUI As UIOptionInternal, ByVal OnUserCancel As UICancelOption)
Debug.Assert(System.Enum.IsDefined(GetType(CopyOrMove), Operation))
''' <remarks>
''' We don't need to consider Recursive flag here since we already verify that in DeleteDirectory.
''' </remarks>
- <SecurityCritical()>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Private Shared Sub ShellDelete(ByVal FullPath As String,
ByVal ShowUI As UIOptionInternal, ByVal recycle As RecycleOption, ByVal OnUserCancel As UICancelOption, ByVal FileOrDirectory As FileOrDirectory)
''' <param name="FullTarget">The full path to the target. Nothing if this is a Delete operation.</param>
''' <param name="OnUserCancel">Value from UICancelOption, specifying to throw or not when user cancels the operation.</param>
'''<remarks></remarks>
- '<HostProtection(Resources:=HostProtectionResource.ExternalProcessMgmt, UI:=True)>
- <SecurityCritical()>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Private Shared Sub ShellFileOperation(ByVal OperationType As SHFileOperationType, ByVal OperationFlags As ShFileOperationFlags,
ByVal FullSource As String, ByVal FullTarget As String, ByVal OnUserCancel As UICancelOption, ByVal FileOrDirectory As FileOrDirectory)
- ' Apply HostProtectionAttribute(UI = true) to indicate this function belongs to UI type.
-
Debug.Assert(System.Enum.IsDefined(GetType(SHFileOperationType), OperationType))
Debug.Assert(OperationType <> SHFileOperationType.FO_RENAME, "Don't call Shell to rename!!!")
Debug.Assert(FullSource <> "" And IO.Path.IsPathRooted(FullSource), "Invalid FullSource path!!!")
''' <param name="SourcePath">The source file / directory path.</param>
''' <param name="TargetPath">The target file / directory path. Nothing in case of delete.</param>
''' <returns>A fully initialized SHFILEOPSTRUCT.</returns>
- <SecurityCritical()>
Private Shared Function GetShellOperationInfo(
ByVal OperationType As SHFileOperationType, ByVal OperationFlags As ShFileOperationFlags,
ByVal SourcePath As String, Optional ByVal TargetPath As String = Nothing) As SHFILEOPSTRUCT
''' <param name="SourcePaths">A string array containing the paths of source files. Must not be empty.</param>
''' <param name="TargetPath">The target file / directory path. Nothing in case of delete.</param>
''' <returns>A fully initialized SHFILEOPSTRUCT.</returns>
- <SecurityCritical()>
Private Shared Function GetShellOperationInfo(
ByVal OperationType As SHFileOperationType, ByVal OperationFlags As ShFileOperationFlags,
ByVal SourcePaths() As String, Optional ByVal TargetPath As String = Nothing) As SHFILEOPSTRUCT
''' - Exception message does not contain the path since at this point it is normalized.
''' - Instead of using PInvoke of GetMessage and MakeHRFromErrorCode, use managed code.
''' </remarks>
- <SecurityCritical()>
Private Shared Sub ThrowWinIOError(ByVal errorCode As Integer)
Select Case errorCode
Case NativeTypes.ERROR_FILE_NOT_FOUND
Imports System.Diagnostics
Imports System.Globalization
Imports System.Security
-Imports System.Runtime.Versioning
Imports System.Text
Imports Microsoft.VisualBasic.CompilerServices
''' This class represents the file system on a computer. It allows browsing the existing drives, special directories;
''' and also contains some commonly use methods for IO tasks.
''' </summary>
- '<HostProtection(Resources:=HostProtectionResource.ExternalProcessMgmt)>
Partial Public Class FileSystem
''' <summary>
''' Return the names of all available drives on the computer.
''' </summary>
''' <param name="sourceDirectoryName">The path to the source directory, can be relative or absolute.</param>
''' <param name="destinationDirectoryName">The path to the target directory, can be relative or absolute. Parent directory will always be created.</param>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Public Shared Sub CopyDirectory(ByVal sourceDirectoryName As String, ByVal destinationDirectoryName As String)
CopyOrMoveDirectory(CopyOrMove.Copy, sourceDirectoryName, destinationDirectoryName,
overwrite:=False, UIOptionInternal.NoUI, UICancelOption.ThrowException)
''' <param name="sourceDirectoryName">The path to the source directory, can be relative or absolute.</param>
''' <param name="destinationDirectoryName">The path to the target directory, can be relative or absolute. Parent directory will always be created.</param>
''' <param name="overwrite">True to overwrite existing files with the same name. Otherwise False.</param>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Public Shared Sub CopyDirectory(ByVal sourceDirectoryName As String, ByVal destinationDirectoryName As String, ByVal overwrite As Boolean)
CopyOrMoveDirectory(CopyOrMove.Copy, sourceDirectoryName, destinationDirectoryName,
overwrite, UIOptionInternal.NoUI, UICancelOption.ThrowException)
''' <param name="sourceDirectoryName">The path to the source directory, can be relative or absolute.</param>
''' <param name="destinationDirectoryName">The path to the target directory, can be relative or absolute. Parent directory will always be created.</param>
''' <param name="showUI">ShowDialogs to display progress and confirmation dialogs. Otherwise HideDialogs.</param>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Public Shared Sub CopyDirectory(ByVal sourceDirectoryName As String, ByVal destinationDirectoryName As String, ByVal showUI As UIOption)
CopyOrMoveDirectory(CopyOrMove.Copy, sourceDirectoryName, destinationDirectoryName,
overwrite:=False, ToUIOptionInternal(showUI), UICancelOption.ThrowException)
''' </summary>
''' <param name="sourceFileName">The path to the source file, can be relative or absolute.</param>
''' <param name="destinationFileName">The path to the destination file, can be relative or absolute. Parent directory will always be created.</param>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Public Shared Sub CopyFile(ByVal sourceFileName As String, ByVal destinationFileName As String)
CopyOrMoveFile(CopyOrMove.Copy, sourceFileName, destinationFileName,
overwrite:=False, UIOptionInternal.NoUI, UICancelOption.ThrowException)
''' <param name="sourceFileName">The path to the source file, can be relative or absolute.</param>
''' <param name="destinationFileName">The path to the destination file, can be relative or absolute. Parent directory will always be created.</param>
''' <param name="overwrite">True to overwrite existing file with the same name. Otherwise False.</param>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Public Shared Sub CopyFile(ByVal sourceFileName As String, ByVal destinationFileName As String, ByVal overwrite As Boolean)
CopyOrMoveFile(CopyOrMove.Copy, sourceFileName, destinationFileName,
overwrite, UIOptionInternal.NoUI, UICancelOption.ThrowException)
''' <param name="sourceFileName">The path to the source file, can be relative or absolute.</param>
''' <param name="destinationFileName">The path to the destination file, can be relative or absolute. Parent directory will always be created.</param>
''' <param name="showUI">ShowDialogs to display progress and confirmation dialogs. Otherwise HideDialogs.</param>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Public Shared Sub CopyFile(ByVal sourceFileName As String, ByVal destinationFileName As String, ByVal showUI As UIOption)
CopyOrMoveFile(CopyOrMove.Copy, sourceFileName, destinationFileName,
overwrite:=False, ToUIOptionInternal(showUI), UICancelOption.ThrowException)
''' <param name="showUI">ShowDialogs to display progress and confirmation dialogs. Otherwise HideDialogs.</param>
''' <param name="onUserCancel">ThrowException to throw exception if user cancels the operation. Otherwise DoNothing.</param>
''' <remarks>onUserCancel will be ignored if showUI = HideDialogs.</remarks>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Public Shared Sub CopyFile(ByVal sourceFileName As String, ByVal destinationFileName As String, ByVal showUI As UIOption, ByVal onUserCancel As UICancelOption)
CopyOrMoveFile(CopyOrMove.Copy, sourceFileName, destinationFileName,
overwrite:=False, ToUIOptionInternal(showUI), onUserCancel)
''' </summary>
''' <param name="directory">The path to the directory.</param>
''' <param name="onDirectoryNotEmpty">DeleteAllContents to delete everything. ThrowIfDirectoryNonEmpty to throw exception if the directory is not empty.</param>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Public Shared Sub DeleteDirectory(ByVal directory As String, ByVal onDirectoryNotEmpty As DeleteDirectoryOption)
DeleteDirectoryInternal(directory, onDirectoryNotEmpty,
UIOptionInternal.NoUI, RecycleOption.DeletePermanently, UICancelOption.ThrowException)
''' <param name="directory">The path to the directory.</param>
''' <param name="showUI">True to shows progress window. Otherwise, False.</param>
''' <param name="recycle">SendToRecycleBin to delete to Recycle Bin. Otherwise DeletePermanently.</param>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Public Shared Sub DeleteDirectory(ByVal directory As String, ByVal showUI As UIOption, ByVal recycle As RecycleOption)
DeleteDirectoryInternal(directory, DeleteDirectoryOption.DeleteAllContents,
ToUIOptionInternal(showUI), recycle, UICancelOption.ThrowException)
''' <param name="showUI">ShowDialogs to display progress and confirmation dialogs. Otherwise HideDialogs.</param>
''' <param name="recycle">SendToRecycleBin to delete to Recycle Bin. Otherwise DeletePermanently.</param>
''' <param name="onUserCancel">Throw exception when user cancel the UI operation or not.</param>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Public Shared Sub DeleteDirectory(ByVal directory As String,
ByVal showUI As UIOption, ByVal recycle As RecycleOption, ByVal onUserCancel As UICancelOption)
DeleteDirectoryInternal(directory, DeleteDirectoryOption.DeleteAllContents,
''' Delete the given file.
''' </summary>
''' <param name="file">The path to the file.</param>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Public Shared Sub DeleteFile(ByVal file As String)
DeleteFileInternal(file, UIOptionInternal.NoUI, RecycleOption.DeletePermanently, UICancelOption.ThrowException)
End Sub
''' <param name="file">The path to the file.</param>
''' <param name="showUI">ShowDialogs to display progress and confirmation dialogs. Otherwise HideDialogs.</param>
''' <param name="recycle">SendToRecycleBin to delete to Recycle Bin. Otherwise DeletePermanently.</param>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Public Shared Sub DeleteFile(ByVal file As String, ByVal showUI As UIOption, ByVal recycle As RecycleOption)
DeleteFileInternal(file, ToUIOptionInternal(showUI), recycle, UICancelOption.ThrowException)
End Sub
''' <param name="onUserCancel">Throw exception when user cancel the UI operation or not.</param>
''' <exception cref="IO.Path.GetFullPath">IO.Path.GetFullPath() exceptions: if FilePath is invalid.</exception>
''' <exception cref="IO.FileNotFoundException">if a file does not exist at FilePath</exception>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Public Shared Sub DeleteFile(ByVal file As String, ByVal showUI As UIOption, ByVal recycle As RecycleOption,
ByVal onUserCancel As UICancelOption)
''' </summary>
''' <param name="sourceDirectoryName">The path to the source directory, can be relative or absolute.</param>
''' <param name="destinationDirectoryName">The path to the target directory, can be relative or absolute. Parent directory will always be created.</param>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Public Shared Sub MoveDirectory(ByVal sourceDirectoryName As String, ByVal destinationDirectoryName As String)
CopyOrMoveDirectory(CopyOrMove.Move, sourceDirectoryName, destinationDirectoryName,
overwrite:=False, UIOptionInternal.NoUI, UICancelOption.ThrowException)
''' </summary>
''' <param name="sourceDirectoryName">The path to the source directory, can be relative or absolute.</param>
''' <param name="destinationDirectoryName">The path to the target directory, can be relative or absolute. Parent directory will always be created.</param> ''' <param name="overwrite">True to overwrite existing files with the same name. Otherwise False.</param>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Public Shared Sub MoveDirectory(ByVal sourceDirectoryName As String, ByVal destinationDirectoryName As String, ByVal overwrite As Boolean)
CopyOrMoveDirectory(CopyOrMove.Move, sourceDirectoryName, destinationDirectoryName,
overwrite, UIOptionInternal.NoUI, UICancelOption.ThrowException)
''' <param name="sourceDirectoryName">The path to the source directory, can be relative or absolute.</param>
''' <param name="destinationDirectoryName">The path to the target directory, can be relative or absolute. Parent directory will always be created.</param>
''' <param name="showUI">ShowDialogs to display progress and confirmation dialogs. Otherwise HideDialogs.</param>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Public Shared Sub MoveDirectory(ByVal sourceDirectoryName As String, ByVal destinationDirectoryName As String, ByVal showUI As UIOption)
CopyOrMoveDirectory(CopyOrMove.Move, sourceDirectoryName, destinationDirectoryName,
overwrite:=False, ToUIOptionInternal(showUI), UICancelOption.ThrowException)
''' <param name="destinationDirectoryName">The path to the target directory, can be relative or absolute. Parent directory will always be created.</param>
''' <param name="showUI">ShowDialogs to display progress and confirmation dialogs. Otherwise HideDialogs.</param>
''' <param name="onUserCancel">ThrowException to throw exception if user cancels the operation. Otherwise DoNothing.</param>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Public Shared Sub MoveDirectory(ByVal sourceDirectoryName As String, ByVal destinationDirectoryName As String, ByVal showUI As UIOption, ByVal onUserCancel As UICancelOption)
CopyOrMoveDirectory(CopyOrMove.Move, sourceDirectoryName, destinationDirectoryName,
overwrite:=False, ToUIOptionInternal(showUI), onUserCancel)
''' </summary>
''' <param name="sourceFileName">The path to the source file, can be relative or absolute.</param>
''' <param name="destinationFileName">The path to the destination file, can be relative or absolute. Parent directory will always be created.</param>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Public Shared Sub MoveFile(ByVal sourceFileName As String, ByVal destinationFileName As String)
CopyOrMoveFile(CopyOrMove.Move, sourceFileName, destinationFileName,
overwrite:=False, UIOptionInternal.NoUI, UICancelOption.ThrowException)
''' <param name="sourceFileName">The path to the source file, can be relative or absolute.</param>
''' <param name="destinationFileName">The path to the destination file, can be relative or absolute. Parent directory will always be created.</param>
''' <param name="overwrite">True to overwrite existing file with the same name. Otherwise False.</param>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Public Shared Sub MoveFile(ByVal sourceFileName As String, ByVal destinationFileName As String, ByVal overwrite As Boolean)
CopyOrMoveFile(CopyOrMove.Move, sourceFileName, destinationFileName,
overwrite, UIOptionInternal.NoUI, UICancelOption.ThrowException)
''' <param name="sourceFileName">The path to the source file, can be relative or absolute.</param>
''' <param name="destinationFileName">The path to the destination file, can be relative or absolute. Parent directory will always be created.</param>
''' <param name="showUI">ShowDialogs to display progress and confirmation dialogs. Otherwise HideDialogs.</param>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Public Shared Sub MoveFile(ByVal sourceFileName As String, ByVal destinationFileName As String, ByVal showUI As UIOption)
CopyOrMoveFile(CopyOrMove.Move, sourceFileName, destinationFileName,
overwrite:=False, ToUIOptionInternal(showUI), UICancelOption.ThrowException)
''' <param name="showUI">ShowDialogs to display progress and confirmation dialogs. Otherwise HideDialogs.</param>
''' <param name="onUserCancel">ThrowException to throw exception if user cancels the operation. Otherwise DoNothing.</param>
''' <remarks>onUserCancel will be ignored if showUI = HideDialogs.</remarks>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Public Shared Sub MoveFile(ByVal sourceFileName As String, ByVal destinationFileName As String, ByVal showUI As UIOption, ByVal onUserCancel As UICancelOption)
CopyOrMoveFile(CopyOrMove.Move, sourceFileName, destinationFileName,
overwrite:=False, ToUIOptionInternal(showUI), onUserCancel)
''' IOException: Target directory is under source directory - cyclic operation.
''' IOException: TargetDirectoryPath points to an existing file.
''' IOException: Some files and directories can not be copied.</exception>
- <SecuritySafeCritical()>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Private Shared Sub CopyOrMoveDirectory(ByVal operation As CopyOrMove,
ByVal sourceDirectoryName As String, ByVal destinationDirectoryName As String,
ByVal overwrite As Boolean, ByVal showUI As UIOptionInternal, ByVal onUserCancel As UICancelOption)
''' <param name="targetDirectoryPath">Target path - must be full path.</param>
''' <param name="Overwrite">True to overwrite the files. Otherwise, False.</param>
''' <exception cref="IO.IOException">Some files or directories cannot be copied or moved.</exception>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Private Shared Sub FxCopyOrMoveDirectory(ByVal operation As CopyOrMove,
ByVal sourceDirectoryPath As String, ByVal targetDirectoryPath As String, ByVal overwrite As Boolean)
''' <param name="SourceDirectoryNode">The source node. Only copy / move directories contained in the source node.</param>
''' <param name="Overwrite">True to overwrite sub-files. Otherwise False.</param>
''' <param name="Exceptions">The list of accumulated exceptions while doing the copy / move</param>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Private Shared Sub CopyOrMoveDirectoryNode(ByVal Operation As CopyOrMove,
ByVal SourceDirectoryNode As DirectoryNode, ByVal Overwrite As Boolean, ByVal Exceptions As ListDictionary)
''' ArgumenNullException: If NewName = "".
''' ArgumentException: If NewName contains path information.
''' </exception>
- <SecuritySafeCritical()>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Private Shared Sub CopyOrMoveFile(ByVal operation As CopyOrMove,
ByVal sourceFileName As String, ByVal destinationFileName As String,
ByVal overwrite As Boolean, ByVal showUI As UIOptionInternal, ByVal onUserCancel As UICancelOption
''' <param name="recycle">SendToRecycleBin to delete to Recycle Bin. Otherwise DeletePermanently.</param>
''' <param name="onUserCancel">Throw exception when user cancel the UI operation or not.</param>
''' <remarks>If user wants shell features, onDirectoryNotEmpty is ignored.</remarks>
- <SecuritySafeCritical()>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Private Shared Sub DeleteDirectoryInternal(ByVal directory As String, ByVal onDirectoryNotEmpty As DeleteDirectoryOption,
ByVal showUI As UIOptionInternal, ByVal recycle As RecycleOption, ByVal onUserCancel As UICancelOption)
''' <param name="recycle">DeletePermanently or SendToRecycleBin</param>
''' <param name="onUserCancel">DoNothing or ThrowException</param>
''' <remarks></remarks>
- <SecuritySafeCritical()>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Private Shared Sub DeleteFileInternal(ByVal file As String, ByVal showUI As UIOptionInternal, ByVal recycle As RecycleOption,
ByVal onUserCancel As UICancelOption)
' Verify enums
Imports System
Imports System.ComponentModel
Imports System.Globalization
-Imports System.Security
-Imports System.Security.Permissions
Imports Microsoft.VisualBasic.CompilerServices.Utils
''' <param name="info"></param>
''' <param name="context"></param>
''' <remarks></remarks>
- <SecurityCritical()>
- <SecurityPermission(SecurityAction.Demand, SerializationFormatter:=True)>
<EditorBrowsable(EditorBrowsableState.Advanced)>
Public Overrides Sub GetObjectData(ByVal info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext)
If info IsNot Nothing Then ' Fix FxCop violation ValidateArgumentsOfPublicMethods.
''' </summary>
''' <param name="path">The path of the file to be parsed</param>
''' <remarks></remarks>
- '<HostProtection(Resources:=HostProtectionResource.ExternalProcessMgmt)>
Public Sub New(ByVal path As String)
' Default to UTF-8 and detect encoding
''' <param name="path">The path of the file to be parsed</param>
''' <param name="defaultEncoding">The decoding to default to if encoding isn't determined from file</param>
''' <remarks></remarks>
- '<HostProtection(Resources:=HostProtectionResource.ExternalProcessMgmt)>
Public Sub New(ByVal path As String, ByVal defaultEncoding As System.Text.Encoding)
' Default to detect encoding
''' <param name="defaultEncoding">The decoding to default to if encoding isn't determined from file</param>
''' <param name="detectEncoding">Indicates whether or not to try to detect the encoding from the BOM</param>
''' <remarks></remarks>
- '<HostProtection(Resources:=HostProtectionResource.ExternalProcessMgmt)>
Public Sub New(ByVal path As String, ByVal defaultEncoding As System.Text.Encoding, ByVal detectEncoding As Boolean)
InitializeFromPath(path, defaultEncoding, detectEncoding)
''' </summary>
''' <param name="stream"></param>
''' <remarks></remarks>
- '<HostProtection(Resources:=HostProtectionResource.ExternalProcessMgmt)>
Public Sub New(ByVal stream As Stream)
' Default to UTF-8 and detect encoding
''' <param name="stream"></param>
''' <param name="defaultEncoding">The decoding to default to if encoding isn't determined from file</param>
''' <remarks></remarks>
- '<HostProtection(Resources:=HostProtectionResource.ExternalProcessMgmt)>
Public Sub New(ByVal stream As Stream, ByVal defaultEncoding As System.Text.Encoding)
' Default to detect encoding
''' <param name="defaultEncoding">The decoding to default to if encoding isn't determined from file</param>
''' <param name="detectEncoding">Indicates whether or not to try to detect the encoding from the BOM</param>
''' <remarks></remarks>
- '<HostProtection(Resources:=HostProtectionResource.ExternalProcessMgmt)>
Public Sub New(ByVal stream As Stream, ByVal defaultEncoding As System.Text.Encoding, ByVal detectEncoding As Boolean)
InitializeFromStream(stream, defaultEncoding, detectEncoding)
''' <param name="detectEncoding">Indicates whether or not to try to detect the encoding from the BOM</param>
''' <param name="leaveOpen">Indicates whether or not to leave the passed in stream open</param>
''' <remarks></remarks>
- '<HostProtection(Resources:=HostProtectionResource.ExternalProcessMgmt)>
Public Sub New(ByVal stream As Stream, ByVal defaultEncoding As System.Text.Encoding, ByVal detectEncoding As Boolean, ByVal leaveOpen As Boolean)
m_LeaveOpen = leaveOpen
''' </summary>
''' <param name="reader">The TextReader that does the reading</param>
''' <remarks></remarks>
- '<HostProtection(Resources:=HostProtectionResource.ExternalProcessMgmt)>
Public Sub New(ByVal reader As TextReader)
If reader Is Nothing Then
Option Explicit On
Imports System
-Imports System.Security
Imports System.Runtime.InteropServices
-Imports System.Runtime.Versioning
Namespace Microsoft.VisualBasic.CompilerServices
<ComVisible(False)>
Friend NotInheritable Class NativeMethods
- <SecurityCritical()>
- <ResourceExposure(ResourceScope.None)>
<PreserveSig()>
Friend Declare Function _
CloseHandle _
''' </summary>
''' <param name="lpFileOp">32-bit SHFILEOPSTRUCT</param>
''' <returns>0 if successful, non-zero otherwise.</returns>
- <SecurityCritical()>
- <ResourceExposure(ResourceScope.Machine)>
- <ResourceConsumption(ResourceScope.Machine)>
Friend Shared Function SHFileOperation(ByRef lpFileOp As SHFILEOPSTRUCT) As Int32
If (IntPtr.Size = 4) Then ' 32-bit platforms
Return SHFileOperation32(lpFileOp)
''' You cannot use SHFileOperation to move special folders My Documents and My Pictures from a local drive to a remote computer.
''' File deletion is recursive unless you set the FOF_NORECURSION flag.
''' </remarks>
- <SecurityCritical()>
- <ResourceExposure(ResourceScope.Machine)>
<DllImport("shell32.dll", CharSet:=CharSet.Auto, EntryPoint:="SHFileOperation", SetLastError:=True, ThrowOnUnmappableChar:=True)>
Private Shared Function SHFileOperation32(ByRef lpFileOp As SHFILEOPSTRUCT) As Int32
End Function
''' <summary>
''' Copies, moves, renames or deletes a file system object on 64-bit platforms.
''' </summary>
- <SecurityCritical()>
- <ResourceExposure(ResourceScope.Machine)>
<DllImport("shell32.dll", CharSet:=CharSet.Auto, EntryPoint:="SHFileOperation", SetLastError:=True, ThrowOnUnmappableChar:=True)>
Private Shared Function SHFileOperation64(ByRef lpFileOp As SHFILEOPSTRUCT64) As Int32
End Function
''' Win 95/98/Me: SHChangeNotify is supported by Microsoft Layer for Unicode.
''' To use this http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mslu/winprog/microsoft_layer_for_unicode_on_windows_95_98_me_systems.asp
''' </remarks>
- <SecurityCritical()>
- <ResourceExposure(ResourceScope.None)>
<DllImport("shell32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
Friend Shared Sub SHChangeNotify(ByVal wEventId As UInt32, ByVal uFlags As UInt32,
ByVal dwItem1 As IntPtr, ByVal dwItem2 As IntPtr)
''' The MoveFileEx function moves an existing file or directory.
''' http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/movefileex.asp
''' </summary>
- <SecurityCritical()>
- <ResourceExposure(ResourceScope.Machine)>
<DllImport("kernel32",
PreserveSig:=True,
CharSet:=CharSet.Auto,
Imports System
Imports System.Diagnostics
-Imports System.Security
-Imports System.Runtime.ConstrainedExecution
Imports System.Runtime.InteropServices
Imports Microsoft.Win32.SafeHandles
Public lpSecurityDescriptor As IntPtr
Public bInheritHandle As Boolean
- <SecuritySafeCritical()>
- <ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)>
Public Overloads Sub Dispose() Implements IDisposable.Dispose
If lpSecurityDescriptor <> IntPtr.Zero Then
UnsafeNativeMethods.LocalFree(lpSecurityDescriptor)
''' This is required because call to constructor of SafeHandle is not allowed in constrained region.
''' </summary>
''' <remarks>VSWhidbey 544308</remarks>
- <SecurityCritical()>
- <SuppressUnmanagedCodeSecurity()>
Friend NotInheritable Class LateInitSafeHandleZeroOrMinusOneIsInvalid
Inherits SafeHandleZeroOrMinusOneIsInvalid
- <SecurityCritical()>
Friend Sub New()
MyBase.New(True)
End Sub
- <SecurityCritical()>
Friend Sub InitialSetHandle(ByVal h As IntPtr)
Debug.Assert(MyBase.IsInvalid, "Safe handle should only be set once.")
MyBase.SetHandle(h)
End Sub
- <SecurityCritical()>
Protected Overrides Function ReleaseHandle() As Boolean
Return NativeMethods.CloseHandle(Me.handle) <> 0
End Function
''' (using LateInitSafeHandleZeroOrMinusOneIsInvalid.InitialSetHandle) to correctly use and dispose the handle.
''' </remarks>
<StructLayout(LayoutKind.Sequential)>
- <System.Security.SecurityCritical()>
- <System.Security.SuppressUnmanagedCodeSecurity()>
Friend NotInheritable Class PROCESS_INFORMATION
Public hProcess As IntPtr = IntPtr.Zero
Public hThread As IntPtr = IntPtr.Zero
''' </summary>
''' <remarks></remarks>
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)>
- <System.Security.SecurityCritical()>
- <System.Security.SuppressUnmanagedCodeSecurity()>
Friend NotInheritable Class STARTUPINFO
Implements IDisposable
Private m_HasBeenDisposed As Boolean ' To detect redundant calls. Default initialize = False.
- <SecuritySafeCritical()>
Protected Overrides Sub Finalize()
Dispose(False)
End Sub
' IDisposable
- <SecurityCritical()>
Private Sub Dispose(ByVal disposing As Boolean)
If Not m_HasBeenDisposed Then
If disposing Then
End Sub
' This code correctly implements the disposable pattern.
- <SecuritySafeCritical()>
- <ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)>
Friend Sub Dispose() Implements IDisposable.Dispose
' Do not change this code. Put cleanup code in Dispose(ByVal disposing As Boolean) above.
Dispose(True)
' See the LICENSE file in the project root for more information.
Imports System
-Imports System.Security
Imports System.Runtime.InteropServices
-Imports System.Runtime.Versioning
Namespace Microsoft.VisualBasic.CompilerServices
<ComVisible(False)>
- <SuppressUnmanagedCodeSecurityAttribute()>
Friend NotInheritable Class UnsafeNativeMethods
''' <summary>
''' Frees memory allocated from the local heap. i.e. frees memory allocated
''' <param name="LocalHandle"></param>
''' <returns></returns>
''' <remarks></remarks>
- <SecurityCritical()>
- <ResourceExposure(ResourceScope.None)>
<DllImport("kernel32", ExactSpelling:=True, SetLastError:=True)>
Friend Shared Function LocalFree(ByVal LocalHandle As IntPtr) As IntPtr
End Function
Imports System
Imports System.Globalization
Imports System.Security
-Imports System.Security.Permissions
Imports Microsoft.VisualBasic.CompilerServices
Imports Microsoft.VisualBasic.CompilerServices.ExceptionUtils
Imports Microsoft.VisualBasic.CompilerServices.Utils
using System;
using System.Diagnostics;
using System.Security;
- using System.Security.Permissions;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
view.SetIndex2("", DataViewRowState.CurrentRows, null, true);
}
- // avoid HostProtectionAttribute(Synchronization=true) by not calling virtual methods from inside a lock
view = Interlocked.CompareExchange<DataView>(ref _defaultView, view, null);
if (null == view)
{
<Reference Include="System.Runtime.Extensions" />
<Reference Include="System.Runtime.InteropServices" />
<Reference Include="System.Security.Claims" />
- <Reference Include="System.Security.Permissions" />
<Reference Include="System.Security.Principal" />
<Reference Include="System.Security.Principal.Windows" />
<Reference Include="System.Text.Encoding.CodePages" />
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Runtime.InteropServices;
-using System.Security.Permissions;
using System.Text;
using SysTx = System.Transactions;
<Reference Include="System.Security.Claims" />
<Reference Include="System.Security.Principal" />
<Reference Include="System.Security.Principal.Windows" />
- <Reference Include="System.Security.Permissions" />
<Reference Include="System.Text.Encoding.CodePages" />
<Reference Include="System.Text.Encoding.Extensions" />
<Reference Include="System.Text.RegularExpressions" />
using System;
using System.Data.Common;
using System.Runtime.Serialization;
-using System.Security.Permissions;
namespace Microsoft.SqlServer.Server
{
using System.Globalization;
using System.Reflection;
using System.Runtime.InteropServices;
-using System.Security.Permissions;
using System.Text;
using System.Runtime.CompilerServices;
using System.Data.SqlTypes;
internal override int Size => 8;
}
-}
\ No newline at end of file
+}
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
-using System.Security.Permissions;
using Microsoft.Win32.SafeHandles;
using System.Buffers;
_m_fs.Flush();
}
- [HostProtection(ExternalThreading = true)]
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
{
if (_m_disposed)
return _m_fs.EndRead(asyncResult);
}
- [HostProtection(ExternalThreading = true)]
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
{
if (_m_disposed)
<Reference Include="System.Runtime.Extensions" />
<Reference Include="System.Runtime.InteropServices" />
<Reference Include="System.Resources.ResourceManager" />
- <Reference Include="System.Security.Permissions" />
<Reference Include="System.Security.Principal.Windows" />
<Reference Include="System.Threading" />
<Reference Include="System.Threading.AccessControl" />
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-using System.Security.Permissions;
using System.Threading;
using Microsoft.Win32;
using Microsoft.Win32.SafeHandles;
boolFlags[Flag_monitoring] = isMonitoring;
}
- [HostProtection(Synchronization = true)]
private static void RemoveListenerComponent(EventLogInternal component, string compLogName)
{
lock (InternalSyncObject)
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
-using System.Security.Permissions;
using System.Security.Principal;
using System.Text;
using System.Threading;
// 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.Security.Permissions;
-
namespace System.Diagnostics
{
public class ConsoleTraceListener : TextWriterTraceListener {
<Reference Include="System.IO.FileSystem.AccessControl" />
<Reference Include="System.Runtime" />
<Reference Include="System.Security.AccessControl" />
- <Reference Include="System.Security.Permissions" />
<Reference Include="System.Security.Principal.Windows" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' != 'netstandard'">
using System.Runtime.InteropServices;
using System.Net;
using System.Security.Principal;
-using System.Security.Permissions;
using System.DirectoryServices;
using System.Text;
using System.Runtime.InteropServices;
using System.Net;
using System.Security.Principal;
-using System.Security.Permissions;
using System.Collections.Specialized;
using System.DirectoryServices;
using System.Text;
using System.Diagnostics;
using System.Globalization;
using System.Security.Principal;
-using System.Security.Permissions;
using System.Collections.Generic;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;
using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
-using System.Security.Permissions;
namespace System.DirectoryServices.AccountManagement
{
using System;
using System.Diagnostics;
using System.Collections.Generic;
-using System.Security.Permissions;
namespace System.DirectoryServices.AccountManagement
{
using System.Text;
using System.Threading;
using System.Collections;
-using System.Security.Permissions;
namespace System.DirectoryServices.AccountManagement
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Security.Permissions;
namespace System.DirectoryServices.AccountManagement
{
using System.Diagnostics;
using System.Globalization;
using System.Security.Principal;
-using System.Security.Permissions;
using System.Collections.Generic;
using System.ComponentModel;
using System.Collections;
using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Security.Permissions;
using System.Security.Principal;
namespace System.DirectoryServices.AccountManagement
using System;
using System.Diagnostics;
using System.Collections.Generic;
-using System.Security.Permissions;
using System.Security.Principal;
namespace System.DirectoryServices.AccountManagement
using System.Runtime.InteropServices;
using System.Text;
using System.Security.Authentication;
-using System.Security.Permissions;
namespace System.DirectoryServices.AccountManagement
{
using System.Runtime.InteropServices;
using System;
using System.Security;
- using System.Security.Permissions;
using System.Text;
internal class Constants
</ItemGroup>
<ItemGroup>
<Reference Include="System.Security.AccessControl" />
- <Reference Include="System.Security.Permissions" />
<Reference Include="System.Security.Principal.Windows" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' != 'netstandard'">
using System.Xml;
using System.Threading;
using System.Security.Cryptography.X509Certificates;
-using System.Security.Permissions;
namespace System.DirectoryServices.Protocols
{
using System.Diagnostics;
using System.Security.Authentication;
using System.Runtime.CompilerServices;
-using System.Security.Permissions;
namespace System.DirectoryServices.Protocols
{
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.ComponentModel;
-using System.Security.Permissions;
using System.IO;
namespace System.DirectoryServices.ActiveDirectory
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security.Authentication;
-using System.Security.Permissions;
namespace System.DirectoryServices.ActiveDirectory
{
using System.Net;
using System.Collections;
using System.Security.Principal;
-using System.Security.Permissions;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Globalization;
using System.ComponentModel;
using System.Threading;
using System.Reflection;
-using System.Security.Permissions;
using System.DirectoryServices.Design;
using System.Globalization;
using System.Net;
// See the LICENSE file in the project root for more information.
using System.Net;
-using System.Security.Permissions;
namespace System.DirectoryServices
{
// See the LICENSE file in the project root for more information.
using System.Collections;
-using System.Security.Permissions;
namespace System.Drawing.Design
{
//
using System.Collections.Generic;
-using System.Security.Permissions;
using Xunit;
namespace System.Drawing.Drawing2D.Tests
using System.Drawing.Tests;
using System.IO;
using System.Runtime.InteropServices;
-using System.Security.Permissions;
using Xunit;
namespace System.Drawing.Text.Tests
using System.Drawing.Imaging;
using Xunit;
using System.IO;
-using System.Security.Permissions;
namespace MonoTests.System.Drawing.Imaging
{
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Security.Cryptography;
-using System.Security.Permissions;
using System.Text;
using System.Xml.Serialization;
using Xunit;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.InteropServices;
-using System.Security.Permissions;
using Xunit;
namespace MonoTests.System.Drawing.Imaging
namespace System.IO.Pipes
{
- // [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
public sealed class PipeAccessRule : AccessRule
{
//
namespace System.IO.Pipes
{
- //[System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
public sealed class PipeAuditRule : AuditRule
{
public PipeAuditRule(
namespace System.IO.Pipes
{
- //[System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
public class PipeSecurity : NativeObjectSecurity
{
public PipeSecurity()
<Reference Include="Microsoft.Win32.Primitives" />
<Reference Include="Microsoft.Win32.Registry" />
<Reference Include="System.CodeDom" />
- <Reference Include="System.Security.Permissions" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' != 'netstandard'">
<Reference Include="System.Collections.NonGeneric" />
using System.Security;
using System.Runtime.Serialization;
using System.Threading;
-using System.Security.Permissions;
using System.Runtime.Versioning;
using System.Text;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
-using System.Security.Permissions;
namespace System.Management
{
using System.Reflection;
using System.ComponentModel.Design.Serialization;
using System.Security;
-using System.Security.Permissions;
using Microsoft.Win32;
namespace System.Management
{
using System;
using System.Security;
- using System.Security.Permissions;
using System.Runtime.CompilerServices;
internal sealed class SurrogateDataContract : DataContract
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp' OR '$(TargetGroup)' == 'uap'">
<Reference Include="System.Collections" />
<Reference Include="System.Diagnostics.Debug" />
- <Reference Include="System.Security.Permissions" />
</ItemGroup>
</Project>
\ No newline at end of file
<Reference Include="System.Runtime.Extensions" />
<Reference Include="System.Runtime.InteropServices" />
<Reference Include="System.Runtime.InteropServices.RuntimeInformation" />
- <Reference Include="System.Security.Permissions" />
<Reference Include="System.Security.Principal.Windows" />
<Reference Include="System.Threading" />
<Reference Include="System.Threading.AccessControl" />
using System.Runtime.Caching.Hosting;
using System.Diagnostics;
using System.Security;
-using System.Security.Permissions;
using System.Threading;
namespace System.Runtime.Caching
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Security;
-using System.Security.Permissions;
using System.Threading;
using System.Runtime.Versioning;
using System.Collections;
using System.IO;
using System.Security;
-using System.Security.Permissions;
namespace System.Runtime.Caching
{
using System.Runtime.Caching.Resources;
using System.Globalization;
using System.Security;
-using System.Security.Permissions;
using System.Text;
using System.Threading;
using System.Configuration;
using System.Diagnostics.CodeAnalysis;
using System.Security;
-using System.Security.Permissions;
using System.Threading;
namespace System.Runtime.Caching
using System.Threading;
using System.Diagnostics;
using System.Security;
-using System.Security.Permissions;
using System.Diagnostics.CodeAnalysis;
namespace System.Runtime.Caching
using System.Globalization;
using System.Reflection;
using System.Security;
-using System.Security.Permissions;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Globalization;
using System.IO;
using System.Security.Cryptography.X509Certificates;
-using System.Security.Permissions;
using System.Text;
using System.Threading;
using System.Xml;
using System.Globalization;
using System.IO;
using System.Security.Cryptography.X509Certificates;
-using System.Security.Permissions;
using System.Text;
using System.Threading;
using System.Xml;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
-using System.Security.Permissions;
using System.Xml;
using Microsoft.Win32;
using System.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
-using System.Security.Permissions;
using System.Text;
using System.Threading;
using System.Xml;