Skip to content

Commit ecee79e

Browse files
authored
Merge branch 'master' into patch-5
2 parents b7361b4 + 8f943b9 commit ecee79e

13 files changed

Lines changed: 194 additions & 54 deletions

File tree

.github/ISSUE_TEMPLATE/Feature_Request.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ assignees: ''
99

1010
# Summary of the new feature/enhancement
1111

12+
<!--
1213
A clear and concise description of what the problem is that the new feature would solve.
1314
Try formulating it in user story style (if applicable):
1415
'As a user I want X so that Y.' with X being the being the action and Y being the value of the action.
16+
-->
1517

1618
# Proposed technical implementation details (optional)
1719

20+
<!--
1821
A clear and concise description of what you want to happen.
1922
Consider providing an example PowerShell experience with expected result.
23+
-->

.poshchan/settings.json

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
1-
{
2-
"build_targets": {
3-
"staging": "PowerShell-CI-static-analysis",
4-
"windows": "PowerShell-CI-windows",
5-
"macos": "PowerShell-CI-macos",
6-
"linux": "PowerShell-CI-Linux",
7-
"all": [
8-
"PowerShell-CI-static-analysis",
9-
"PowerShell-CI-windows",
10-
"PowerShell-CI-macOS",
11-
"PowerShell-CI-Linux"
1+
"version": "0.1",
2+
"azdevops": {
3+
"build_targets": {
4+
"staging": "PowerShell-CI-static-analysis",
5+
"windows": "PowerShell-CI-windows",
6+
"macos": "PowerShell-CI-macos",
7+
"linux": "PowerShell-CI-Linux",
8+
"all": [
9+
"PowerShell-CI-static-analysis",
10+
"PowerShell-CI-windows",
11+
"PowerShell-CI-macos",
12+
"PowerShell-CI-Linux"
13+
]
14+
},
15+
"authorized_users": [
16+
"adityapatwardhan",
17+
"anmenaga",
18+
"daxian-dbw",
19+
"iSazonov",
20+
"JamesWTruher",
21+
"PaulHigin",
22+
"rjmholt",
23+
"SteveL-MSFT",
24+
"TravisEz13",
25+
"TylerLeonhardt"
1226
]
1327
},
14-
"authorized_users": [
15-
"adityapatwardhan",
16-
"anmenaga",
17-
"daxian-dbw",
18-
"iSazonov",
19-
"JamesWTruher",
20-
"PaulHigin",
21-
"rjmholt",
22-
"SteveL-MSFT",
23-
"TravisEz13",
24-
"TylerLeonhardt"
25-
]
28+
"reminders": {
29+
"authorized_users": "*"
30+
}
2631
}

.vsts-ci/linux.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ trigger:
1212
exclude:
1313
- /tools/releaseBuild/**/*
1414
- /.vsts-ci/misc-analysis.yml
15+
- /.github/ISSUE_TEMPLATE/*
1516
pr:
1617
branches:
1718
include:
@@ -23,6 +24,7 @@ pr:
2324
exclude:
2425
- /tools/releaseBuild/**/*
2526
- /.vsts-ci/misc-analysis.yml
27+
- /.github/ISSUE_TEMPLATE/*
2628
variables:
2729
DOTNET_CLI_TELEMETRY_OPTOUT: 1
2830
POWERSHELL_TELEMETRY_OPTOUT: 1

.vsts-ci/mac.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ trigger:
1212
exclude:
1313
- /tools/releaseBuild/**/*
1414
- /.vsts-ci/misc-analysis.yml
15+
- /.github/ISSUE_TEMPLATE/*
1516
pr:
1617
branches:
1718
include:
@@ -23,6 +24,7 @@ pr:
2324
exclude:
2425
- /tools/releaseBuild/**/*
2526
- /.vsts-ci/misc-analysis.yml
27+
- /.github/ISSUE_TEMPLATE/*
2628
variables:
2729
DOTNET_CLI_TELEMETRY_OPTOUT: 1
2830
POWERSHELL_TELEMETRY_OPTOUT: 1

.vsts-ci/windows.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ trigger:
1212
exclude:
1313
- /tools/releaseBuild/**/*
1414
- /.vsts-ci/misc-analysis.yml
15+
- /.github/ISSUE_TEMPLATE/*
1516
pr:
1617
branches:
1718
include:
@@ -23,7 +24,8 @@ pr:
2324
exclude:
2425
- /tools/releaseBuild/**/*
2526
- /.vsts-ci/misc-analysis.yml
26-
27+
- /.github/ISSUE_TEMPLATE/*
28+
2729
variables:
2830
GIT_CONFIG_PARAMETERS: "'core.autocrlf=false'"
2931
DOTNET_CLI_TELEMETRY_OPTOUT: 1

src/Microsoft.PowerShell.Commands.Utility/Microsoft.PowerShell.Commands.Utility.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
<ItemGroup>
6969
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.10.0" />
7070
<PackageReference Include="System.Threading.AccessControl" Version="4.5.0" />
71-
<PackageReference Include="NJsonSchema" Version="9.13.26" />
71+
<PackageReference Include="NJsonSchema" Version="9.13.27" />
7272
</ItemGroup>
7373

7474
</Project>

src/Microsoft.PowerShell.Commands.Utility/commands/utility/Send-MailMessage.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ namespace Microsoft.PowerShell.Commands
1414
/// <summary>
1515
/// Implementation for the Send-MailMessage command.
1616
/// </summary>
17+
[Obsolete("This cmdlet does not guarantee secure connections to SMTP servers. While there is no immediate replacement available in PowerShell, we recommend you do not use Send-MailMessage at this time. See https://aka.ms/SendMailMessage for more information.")]
1718
[Cmdlet(VerbsCommunications.Send, "MailMessage", HelpUri = "https://go.microsoft.com/fwlink/?LinkID=135256")]
1819
public sealed class SendMailMessage : PSCmdlet
1920
{

src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs

Lines changed: 53 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -716,35 +716,48 @@ internal static void SetMode(ConsoleHandle consoleHandle, ConsoleModes mode)
716716
/// </summary>
717717
/// <param name="consoleHandle"></param>
718718
/// Handle to the console device returned by GetInputHandle
719-
/// <param name="initialContent">
720-
/// Initial contents of the edit buffer, if any. charactersToRead should be at least as large as the length of this string.
719+
/// <param name="initialContentLength">
720+
/// Length of initial content of the edit buffer. Zero if no initial content exists.
721+
/// Must be less than editBuffer length.
722+
/// </param>
723+
/// <param name="editBuffer">
724+
/// Edit buffer with optional initial content.
725+
/// Caution! Last position in the edit buffer is for a null in native code.
721726
/// </param>
722727
/// <param name="charactersToRead">
723728
/// Number of characters to read from the device.
729+
/// Must be less than editBuffer length.
724730
/// </param>
725731
/// <param name="endOnTab">
726-
/// true to allow the user to terminate input by hitting the tab or shift-tab key, in addition to the enter key
732+
/// True to allow the user to terminate input by hitting the tab or shift-tab key, in addition to the enter key
727733
/// </param>
728734
/// <param name="keyState">
729-
/// bit mask indicating the state of the control/shift keys at the point input was terminated.
735+
/// Bit mask indicating the state of the control/shift keys at the point input was terminated.
736+
/// </param>
730737
/// </param>
731738
/// <returns></returns>
732739
/// <exception cref="HostException">
733740
/// If Win32's ReadConsole fails
734741
/// </exception>
735742

736-
internal static string ReadConsole(ConsoleHandle consoleHandle, string initialContent,
737-
int charactersToRead, bool endOnTab, out uint keyState)
743+
internal static string ReadConsole(
744+
ConsoleHandle consoleHandle,
745+
int initialContentLength,
746+
Span<char> editBuffer,
747+
int charactersToRead,
748+
bool endOnTab,
749+
out uint keyState)
738750
{
739751
Dbg.Assert(!consoleHandle.IsInvalid, "ConsoleHandle is not valid");
740752
Dbg.Assert(!consoleHandle.IsClosed, "ConsoleHandle is closed");
741-
Dbg.Assert(initialContent != null, "if no initial content is desired, pass string.Empty");
753+
Dbg.Assert(initialContentLength < editBuffer.Length, "initialContentLength must be less than editBuffer.Length");
754+
Dbg.Assert(charactersToRead < editBuffer.Length, "charactersToRead must be less than editBuffer.Length");
742755
keyState = 0;
743756

744757
CONSOLE_READCONSOLE_CONTROL control = new CONSOLE_READCONSOLE_CONTROL();
745758

746759
control.nLength = (ULONG)Marshal.SizeOf(control);
747-
control.nInitialChars = (ULONG)initialContent.Length;
760+
control.nInitialChars = (ULONG)initialContentLength;
748761
control.dwControlKeyState = 0;
749762
if (endOnTab)
750763
{
@@ -753,28 +766,34 @@ internal static string ReadConsole(ConsoleHandle consoleHandle, string initialCo
753766
control.dwCtrlWakeupMask = (1 << TAB);
754767
}
755768

756-
DWORD charsReadUnused = 0;
757-
StringBuilder buffer = new StringBuilder(initialContent, charactersToRead);
769+
DWORD charsReaded = 0;
770+
758771
bool result =
759772
NativeMethods.ReadConsole(
760773
consoleHandle.DangerousGetHandle(),
761-
buffer,
774+
editBuffer,
762775
(DWORD)charactersToRead,
763-
out charsReadUnused,
776+
out charsReaded,
764777
ref control);
765778
keyState = control.dwControlKeyState;
766779
if (result == false)
767780
{
768781
int err = Marshal.GetLastWin32Error();
769782

770-
HostException e = CreateHostException(err, "ReadConsole",
771-
ErrorCategory.ReadError, ConsoleControlStrings.ReadConsoleExceptionTemplate);
783+
HostException e = CreateHostException(
784+
err,
785+
"ReadConsole",
786+
ErrorCategory.ReadError,
787+
ConsoleControlStrings.ReadConsoleExceptionTemplate);
772788
throw e;
773789
}
774790

775-
if (charsReadUnused > (uint)buffer.Length)
776-
charsReadUnused = (uint)buffer.Length;
777-
return buffer.ToString(0, (int)charsReadUnused);
791+
if (charsReaded > (uint)charactersToRead)
792+
{
793+
charsReaded = (uint)charactersToRead;
794+
}
795+
796+
return editBuffer.Slice(0, (int)charsReaded).ToString();
778797
}
779798

780799
/// <summary>
@@ -3019,15 +3038,30 @@ IntPtr reserved
30193038

30203039
[DllImport(PinvokeDllNames.ReadConsoleDllName, SetLastError = true, CharSet = CharSet.Unicode)]
30213040
[return: MarshalAs(UnmanagedType.Bool)]
3022-
internal static extern bool ReadConsole
3041+
private static extern unsafe bool ReadConsole
30233042
(
30243043
NakedWin32Handle consoleInput,
3025-
StringBuilder buffer,
3044+
char* lpBuffer,
30263045
DWORD numberOfCharsToRead,
30273046
out DWORD numberOfCharsRead,
30283047
ref CONSOLE_READCONSOLE_CONTROL controlData
30293048
);
30303049

3050+
internal static unsafe bool ReadConsole
3051+
(
3052+
NakedWin32Handle consoleInput,
3053+
Span<char> buffer,
3054+
DWORD numberOfCharsToRead,
3055+
out DWORD numberOfCharsRead,
3056+
ref CONSOLE_READCONSOLE_CONTROL controlData
3057+
)
3058+
{
3059+
fixed (char* bufferPtr = &MemoryMarshal.GetReference(buffer))
3060+
{
3061+
return ReadConsole(consoleInput, bufferPtr, numberOfCharsToRead, out numberOfCharsRead, ref controlData);
3062+
}
3063+
}
3064+
30313065
[DllImport(PinvokeDllNames.PeekConsoleInputDllName, SetLastError = true, CharSet = CharSet.Unicode)]
30323066
[return: MarshalAs(UnmanagedType.Bool)]
30333067
internal static extern bool PeekConsoleInput

src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,9 @@ private object ReadLineSafe(bool isSecureString, char? printToken)
307307
#if UNIX
308308
ConsoleKeyInfo keyInfo = Console.ReadKey(true);
309309
#else
310-
uint unused = 0;
311-
string key = ConsoleControl.ReadConsole(handle, string.Empty, 1, false, out unused);
310+
const int CharactersToRead = 1;
311+
Span<char> inputBuffer = stackalloc char[CharactersToRead + 1];
312+
string key = ConsoleControl.ReadConsole(handle, initialContentLength: 0, inputBuffer, charactersToRead: CharactersToRead, endOnTab: false, out _);
312313
#endif
313314

314315
#if UNIX
@@ -1287,7 +1288,7 @@ internal enum ReadLineResult
12871288
endedOnBreak = 3
12881289
}
12891290

1290-
private const int maxInputLineLength = 8192;
1291+
private const int MaxInputLineLength = 1024;
12911292

12921293
/// <summary>
12931294
/// Reads a line of input from the console. Returns when the user hits enter, a break key, a break event occurs. In
@@ -1468,13 +1469,19 @@ private string ReadLineFromConsole(bool endOnTab, string initialContent, bool ca
14681469
_rawui.ClearKeyCache();
14691470
uint keyState = 0;
14701471
string s = string.Empty;
1472+
Span<char> inputBuffer = stackalloc char[MaxInputLineLength + 1];
1473+
if (initialContent.Length > 0)
1474+
{
1475+
initialContent.AsSpan().CopyTo(inputBuffer);
1476+
}
1477+
14711478
#endif
14721479
do
14731480
{
14741481
#if UNIX
14751482
keyInfo = Console.ReadKey(true);
14761483
#else
1477-
s += ConsoleControl.ReadConsole(handle, initialContent, maxInputLineLength, endOnTab, out keyState);
1484+
s += ConsoleControl.ReadConsole(handle, initialContent.Length, inputBuffer, MaxInputLineLength, endOnTab, out keyState);
14781485
Dbg.Assert(s != null, "s should never be null");
14791486
#endif
14801487

@@ -1861,9 +1868,9 @@ internal string ReadLineWithTabCompletion(Executor exec)
18611868
completedInput += restOfLine;
18621869
}
18631870

1864-
if (completedInput.Length > (maxInputLineLength - 2))
1871+
if (completedInput.Length > (MaxInputLineLength - 2))
18651872
{
1866-
completedInput = completedInput.Substring(0, maxInputLineLength - 2);
1873+
completedInput = completedInput.Substring(0, MaxInputLineLength - 2);
18671874
}
18681875

18691876
// Remove any nulls from the string...

src/System.Management.Automation/System.Management.Automation.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" />
2424
<!-- the following package(s) are from the powershell org -->
2525
<PackageReference Include="Microsoft.Management.Infrastructure" Version="1.0.0" />
26-
<PackageReference Include="Microsoft.PowerShell.Native" Version="6.2.0-rc.1" />
26+
<PackageReference Include="Microsoft.PowerShell.Native" Version="6.2.0" />
2727
</ItemGroup>
2828

2929
<PropertyGroup>

0 commit comments

Comments
 (0)