Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions DotnetRuntimeMetadata.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"sdk": {
"channel": "6.0.1xx-preview6",
"channel": "6.0.1xx-preview7",
"quality": "signed",
"qualityFallback": "daily",
"packageVersionPattern": "6.0.0-preview.6",
"packageVersionPattern": "6.0.0-preview.7",
"sdkImageVersion": "6.0.100",
"nextChannel": "6.0.1xx-preview7"
"nextChannel": "6.0.1xx-rc1"
},
"internalfeed" : {
"url": null
Expand Down
14 changes: 7 additions & 7 deletions assets/wix/files.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -1608,9 +1608,6 @@
<Component Id="cmp72C41225E0B4457C8CB5F4C5FE6E3187" Guid="{ee32f38f-14ee-4a85-914f-d02522cc3635}">
<File Id="fil04B0F83A7AED430A86A7E6E3E99AB45D" KeyPath="yes" Source="$(var.ProductSourcePath)\ref\System.Formats.Asn1.dll" />
</Component>
<Component Id="cmp49588B1BA09F4BBCA352B162F387AAF1">
<File Id="fil77BEE4F2A1A44842B4135984E1D71538" KeyPath="yes" Source="$(var.ProductSourcePath)\ref\System.Net.Quic.dll" />
</Component>
<Component Id="cmpEE26930D65E346FDAE1B3E07F5DBEF77">
<File Id="filBC93A3F22F78439F8D4173E4C64ACFDC" KeyPath="yes" Source="$(var.ProductSourcePath)\ref\System.Text.Encodings.Web.dll" />
</Component>
Expand Down Expand Up @@ -3054,8 +3051,11 @@
<Component Id="cmp3547A55EA9D04784B4CF2FC717447E16">
<File Id="fil463DDA419769417A8D5A34C433E194F2" KeyPath="yes" Source="$(var.ProductSourcePath)\System.Speech.dll" />
</Component>
<Component Id="cmp8A922220F11C42439D6447B6654A8FC2">
<File Id="fil1EE3A80C6C944700A5C2B75C4AB30B21" KeyPath="yes" Source="$(var.ProductSourcePath)\mscordaccore_$(var.FileArchitecture)_$(var.FileArchitecture)_6.0.21.35212.dll" />
<Component Id="cmp5E1C887083A44CA997E4A89EA8D68CBD">
<File Id="fil6A1709A231934053A635AC3D2206C00B" KeyPath="yes" Source="$(var.ProductSourcePath)\msquic.dll" />
</Component>
<Component Id="cmp7F5B29262950404DB57715553E6C85B4">
<File Id="filA6BE2BBACE6C44DAB26EDF950176F2D6" KeyPath="yes" Source="$(var.ProductSourcePath)\mscordaccore_$(var.FileArchitecture)_$(var.FileArchitecture)_6.0.21.37719.dll" />
</Component>
</DirectoryRef>
</Fragment>
Expand Down Expand Up @@ -4027,7 +4027,6 @@
<ComponentRef Id="cmpC0FFB3F4FB30438082D2DC0F4E4BF12D" />
<ComponentRef Id="cmp1EBDE676D79B4B0DB859B3F601D78513" />
<ComponentRef Id="cmpB92B70CEFC2F438386F97264FB436CDD" />
<ComponentRef Id="cmp49588B1BA09F4BBCA352B162F387AAF1" />
<ComponentRef Id="cmpEE26930D65E346FDAE1B3E07F5DBEF77" />
<ComponentRef Id="cmp8635213A03B04AAE8E1BFB7EA85E0DB2" />
<ComponentRef Id="cmp834F3E0C83664E92B0D115A39A8FAACB" />
Expand All @@ -4038,10 +4037,11 @@
<ComponentRef Id="cmpFAD6557C4AEC48B89DDC4E6485C020C4" />
<ComponentRef Id="cmpB5458B36303A472B80582AF1C2E7FB94" />
<ComponentRef Id="cmp0EBD333D501A45089F58504074E229E7" />
<ComponentRef Id="cmp8A922220F11C42439D6447B6654A8FC2" />
<ComponentRef Id="cmpD11E9CA5069045578BA5D89C86F7FDEF" />
<ComponentRef Id="cmp708913639F7A46E784CC0FA862A1A2CE" />
<ComponentRef Id="cmpA75DEF5617C54DA1937CB37D5824BF79" />
<ComponentRef Id="cmp5E1C887083A44CA997E4A89EA8D68CBD" />
<ComponentRef Id="cmp7F5B29262950404DB57715553E6C85B4" />
</ComponentGroup>
</Fragment>
</Wix>
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "6.0.100-preview.6.21355.2"
"version": "6.0.100-preview.7.21379.14"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

<ItemGroup>
<!-- the following package(s) are from https://github.com/dotnet/corefx -->
<PackageReference Include="System.ServiceProcess.ServiceController" Version="6.0.0-preview.6.21352.12" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="6.0.0-preview.7.21377.4" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.0-1.final" />
<PackageReference Include="System.Threading.AccessControl" Version="6.0.0-preview.6.21352.12" />
<PackageReference Include="System.Drawing.Common" Version="6.0.0-preview.6.21352.12" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.0-2.final" />
<PackageReference Include="System.Threading.AccessControl" Version="6.0.0-preview.7.21377.4" />
<PackageReference Include="System.Drawing.Common" Version="6.0.0-preview.7.21377.4" />
<PackageReference Include="NJsonSchema" Version="10.5.2" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<!-- the following package(s) are from https://github.com/dotnet/corefx -->
<PackageReference Include="System.Diagnostics.EventLog" Version="6.0.0-preview.6.21352.12" />
<PackageReference Include="System.Diagnostics.EventLog" Version="6.0.0-preview.7.21377.4" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
<!-- the following package(s) are from https://github.com/dotnet/fxdac -->
<PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
<!-- the following package(s) are from https://github.com/dotnet/corefx -->
<PackageReference Include="System.IO.Packaging" Version="6.0.0-preview.6.21352.12" />
<PackageReference Include="System.Net.Http.WinHttpHandler" Version="6.0.0-preview.6.21352.12" />
<PackageReference Include="System.Text.Encodings.Web" Version="6.0.0-preview.6.21352.12" />
<PackageReference Include="System.IO.Packaging" Version="6.0.0-preview.7.21377.4" />
<PackageReference Include="System.Net.Http.WinHttpHandler" Version="6.0.0-preview.7.21377.4" />
<PackageReference Include="System.Text.Encodings.Web" Version="6.0.0-preview.7.21377.4" />
<!-- the following package(s) are from https://github.com/dotnet/wcf -->
<PackageReference Include="System.ServiceModel.Duplex" Version="4.9.0-preview1.21220.1" />
<PackageReference Include="System.ServiceModel.Http" Version="4.9.0-preview1.21220.1" />
Expand All @@ -30,7 +30,7 @@
<PackageReference Include="System.Private.ServiceModel" Version="4.9.0-preview1.21220.1" />
<!-- the source could not be found for the following package(s) -->
<PackageReference Include="Microsoft.NETCore.Windows.ApiSets" Version="1.0.1" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0-preview.4.21253.7" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0-preview.7.21377.4" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<ProjectReference Include="..\System.Management.Automation\System.Management.Automation.csproj" />
<ProjectReference Include="..\Microsoft.WSMan.Runtime\Microsoft.WSMan.Runtime.csproj" />
<!-- the following package(s) are from https://github.com/dotnet/corefx -->
<PackageReference Include="System.ServiceProcess.ServiceController" Version="6.0.0-preview.6.21352.12" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="6.0.0-preview.7.21377.4" />
</ItemGroup>

<PropertyGroup>
Expand Down
9 changes: 0 additions & 9 deletions src/System.Management.Automation/CoreCLR/CorePsPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -516,11 +516,6 @@ internal static bool NonWindowsIsHardLink(FileSystemInfo fileInfo)
return Unix.IsHardLink(fileInfo);
}

internal static string NonWindowsInternalGetTarget(string path)
{
return Unix.NativeMethods.FollowSymLink(path);
}

internal static string NonWindowsGetUserFromPid(int path)
{
return Unix.NativeMethods.GetUserFromPid(path);
Expand Down Expand Up @@ -1139,10 +1134,6 @@ internal static extern int CreateSymLink([MarshalAs(UnmanagedType.LPStr)] string
internal static extern int CreateHardLink([MarshalAs(UnmanagedType.LPStr)] string filePath,
[MarshalAs(UnmanagedType.LPStr)] string target);

[DllImport(psLib, CharSet = CharSet.Ansi, SetLastError = true)]
[return: MarshalAs(UnmanagedType.LPStr)]
internal static extern string FollowSymLink([MarshalAs(UnmanagedType.LPStr)] string filePath);

[DllImport(psLib, CharSet = CharSet.Ansi, SetLastError = true)]
[return: MarshalAs(UnmanagedType.LPStr)]
internal static extern string GetUserFromPid(int pid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
<!-- the Application Insights package -->
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.18.0" />
<!-- the following package(s) are from https://github.com/dotnet/corefx -->
<PackageReference Include="Microsoft.Win32.Registry.AccessControl" Version="6.0.0-preview.6.21352.12" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0-preview.6.21352.12" />
<PackageReference Include="System.DirectoryServices" Version="6.0.0-preview.6.21352.12" />
<PackageReference Include="Microsoft.Win32.Registry.AccessControl" Version="6.0.0-preview.7.21377.4" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0-preview.7.21377.4" />
<PackageReference Include="System.DirectoryServices" Version="6.0.0-preview.7.21377.4" />
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="6.0.0-preview.5.21301.5" />
<PackageReference Include="System.Management" Version="6.0.0-preview.6.21352.12" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0-preview.6.21352.12" />
<PackageReference Include="System.Management" Version="6.0.0-preview.7.21377.4" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0-preview.7.21377.4" />
<PackageReference Include="System.Security.AccessControl" Version="6.0.0-preview.5.21301.5" />
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="6.0.0-preview.6.21352.12" />
<PackageReference Include="System.Security.Permissions" Version="6.0.0-preview.6.21352.12" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="6.0.0-preview.6.21352.12" />
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="6.0.0-preview.7.21377.4" />
<PackageReference Include="System.Security.Permissions" Version="6.0.0-preview.7.21377.4" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="6.0.0-preview.7.21377.4" />
<!-- the following package(s) are from the powershell org -->
<PackageReference Include="Microsoft.Management.Infrastructure" Version="2.0.0" />
<PackageReference Include="Microsoft.PowerShell.Native" Version="7.2.0-preview.2" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ private static bool IsWindowsApplication(string fileName)
// SHGetFileInfo() does not understand reparse points and returns 0 ("non exe or error")
// so we are trying to get a real path before.
// It is a workaround for Microsoft Store applications.
string realPath = Microsoft.PowerShell.Commands.InternalSymbolicLinkLinkCodeMethods.WinInternalGetTarget(fileName);
string realPath = Microsoft.PowerShell.Commands.FileSystemProvider.GetFileSystemInfo(fileName, out _).LinkTarget;
if (realPath is not null)
{
fileName = realPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -676,17 +676,6 @@ private void Process_Types_Ps1Xml(string filePath, ConcurrentBag<string> errors)
typeMembers,
isOverride: false);

newMembers.Add(@"Target");
AddMember(
errors,
typeName,
new PSCodeProperty(
@"Target",
GetMethodInfo(typeof(Microsoft.PowerShell.Commands.InternalSymbolicLinkLinkCodeMethods), @"GetTarget"),
setterCodeReference: null),
typeMembers,
isOverride: false);

newMembers.Add(@"LinkType");
AddMember(
errors,
Expand Down
119 changes: 4 additions & 115 deletions src/System.Management.Automation/namespaces/FileSystemProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ private static string GetCorrectCasedPath(string path)
/// <exception cref="System.UnauthorizedAccessException">
/// An I/O error or a specific type of security error.
/// </exception>
private static FileSystemInfo GetFileSystemInfo(string path, out bool isContainer)
internal static FileSystemInfo GetFileSystemInfo(string path, out bool isContainer)
{
// We use 'FileInfo.Attributes' (not 'FileInfo.Exist')
// because we want to get exceptions
Expand Down Expand Up @@ -2069,7 +2069,7 @@ public static string NameString(PSObject instance)
{
if (InternalSymbolicLinkLinkCodeMethods.IsReparsePointLikeSymlink(fileInfo))
{
return $"{PSStyle.Instance.FileInfo.SymbolicLink}{fileInfo.Name}{PSStyle.Instance.Reset} -> {InternalSymbolicLinkLinkCodeMethods.GetTarget(instance)}";
return $"{PSStyle.Instance.FileInfo.SymbolicLink}{fileInfo.Name}{PSStyle.Instance.Reset} -> {fileInfo.LinkTarget}";
Comment on lines 2070 to +2072
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to get rid of IsReparsePointLikeSymlink() call and check fileInfo.LinkTarget is not null but .Net API has slightly different behavior - can we enhance the .Net API?

// The name surrogate bit 0x20000000 is defined in https://docs.microsoft.com/windows/win32/fileio/reparse-point-tags
// Name surrogates (0x20000000) are reparse points that point to other named entities local to the filesystem
// (like symlinks and mount points).
// In the case of OneDrive, they are not name surrogates and would be safe to recurse into.
if ((data.dwReserved0 & 0x20000000) == 0 && (data.dwReserved0 != IO_REPARSE_TAG_APPEXECLINK))
{
return false;
}

(Also you can see as IsReparsePointLikeSymlink() is used in other places. It seems it work the same for directory removal scenario but directory enumeration requires enhaсing of .Net API)

}
else if (fileInfo.Attributes.HasFlag(FileAttributes.Directory))
{
Expand All @@ -2096,7 +2096,7 @@ public static string NameString(PSObject instance)
{
return instance?.BaseObject is FileSystemInfo fileInfo
? InternalSymbolicLinkLinkCodeMethods.IsReparsePointLikeSymlink(fileInfo)
? $"{fileInfo.Name} -> {InternalSymbolicLinkLinkCodeMethods.GetTarget(instance)}"
? $"{fileInfo.Name} -> {fileInfo.LinkTarget}"
: fileInfo.Name
: string.Empty;
}
Expand Down Expand Up @@ -8112,11 +8112,7 @@ public static string GetTarget(PSObject instance)
{
if (instance.BaseObject is FileSystemInfo fileSysInfo)
{
#if !UNIX
return WinInternalGetTarget(fileSysInfo.FullName);
#else
return UnixInternalGetTarget(fileSysInfo.FullName);
#endif
return fileSysInfo.LinkTarget;
}

return null;
Expand All @@ -8139,20 +8135,6 @@ public static string GetLinkType(PSObject instance)
return null;
}

#if UNIX
private static string UnixInternalGetTarget(string filePath)
{
string link = Platform.NonWindowsInternalGetTarget(filePath);

if (string.IsNullOrEmpty(link))
{
throw new Win32Exception(Marshal.GetLastWin32Error());
}

return link;
}
#endif

private static string InternalGetLinkType(FileSystemInfo fileInfo)
{
if (Platform.IsWindows)
Expand Down Expand Up @@ -8446,99 +8428,6 @@ internal static bool WinIsHardLink(ref IntPtr handle)
return succeeded && (handleInfo.NumberOfLinks > 1);
}

#if !UNIX
internal static string WinInternalGetTarget(string path)
{
// We set accessMode parameter to zero because documentation says:
// If this parameter is zero, the application can query certain metadata
// such as file, directory, or device attributes without accessing
// that file or device, even if GENERIC_READ access would have been denied.
using (SafeFileHandle handle = OpenReparsePoint(path, FileDesiredAccess.GenericZero))
{
return WinInternalGetTarget(handle);
}
}

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods")]
private static string WinInternalGetTarget(SafeFileHandle handle)
{
int outBufferSize = Marshal.SizeOf<REPARSE_DATA_BUFFER_SYMBOLICLINK>();

IntPtr outBuffer = Marshal.AllocHGlobal(outBufferSize);
bool success = false;

try
{
int bytesReturned;

// OACR warning 62001 about using DeviceIOControl has been disabled.
// According to MSDN guidance DangerousAddRef() and DangerousRelease() have been used.
handle.DangerousAddRef(ref success);

bool result = DeviceIoControl(
handle.DangerousGetHandle(),
FSCTL_GET_REPARSE_POINT,
InBuffer: IntPtr.Zero,
nInBufferSize: 0,
outBuffer,
outBufferSize,
out bytesReturned,
lpOverlapped: IntPtr.Zero);

if (!result)
{
// It's not a reparse point or the file system doesn't support reparse points.
return null;
}

string targetDir = null;

REPARSE_DATA_BUFFER_SYMBOLICLINK reparseDataBuffer = Marshal.PtrToStructure<REPARSE_DATA_BUFFER_SYMBOLICLINK>(outBuffer);

switch (reparseDataBuffer.ReparseTag)
{
case IO_REPARSE_TAG_SYMLINK:
targetDir = Encoding.Unicode.GetString(reparseDataBuffer.PathBuffer, reparseDataBuffer.SubstituteNameOffset, reparseDataBuffer.SubstituteNameLength);
break;

case IO_REPARSE_TAG_MOUNT_POINT:
REPARSE_DATA_BUFFER_MOUNTPOINT reparseMountPointDataBuffer = Marshal.PtrToStructure<REPARSE_DATA_BUFFER_MOUNTPOINT>(outBuffer);
targetDir = Encoding.Unicode.GetString(reparseMountPointDataBuffer.PathBuffer, reparseMountPointDataBuffer.SubstituteNameOffset, reparseMountPointDataBuffer.SubstituteNameLength);
break;

case IO_REPARSE_TAG_APPEXECLINK:
REPARSE_DATA_BUFFER_APPEXECLINK reparseAppExeDataBuffer = Marshal.PtrToStructure<REPARSE_DATA_BUFFER_APPEXECLINK>(outBuffer);
// The target file is at index 2
if (reparseAppExeDataBuffer.StringCount >= 3)
{
string temp = Encoding.Unicode.GetString(reparseAppExeDataBuffer.StringList);
targetDir = temp.Split('\0')[2];
}
break;
Comment on lines -8504 to -8517

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are currently only supporting symlinks, not mount points or apexeclinks. I don't think this should be deleted yet.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can defer merging after .NET 6 RC1 is released (and consumed by pwsh), which will include that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it already in a PR?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


default:
return null;
}

if (targetDir != null && targetDir.StartsWith(NonInterpretedPathPrefix, StringComparison.OrdinalIgnoreCase))
{
targetDir = targetDir.Substring(NonInterpretedPathPrefix.Length);
}

return targetDir;
}
finally
{
if (success)
{
handle.DangerousRelease();
}

Marshal.FreeHGlobal(outBuffer);
}
}
#endif

internal static bool CreateJunction(string path, string target)
{
// this is a purely Windows specific feature, no feature flag
Expand Down
2 changes: 1 addition & 1 deletion test/tools/TestService/TestService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0-preview.4.21253.7" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0-preview.6.21352.13" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions test/tools/WebListener/WebListener.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.0-preview.6.21355.2" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="6.0.0-preview.6.21352.12" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.0-preview.7.21378.6" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="6.0.0-preview.7.21377.4" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading