mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Format Utility csproj with updated codeformatter (#7263)
Related #4708. Format Microsoft.PowerShell.Commands.Utility.csproj by codeformatter with default options. The codeformatter is used that I compiled with newest Roslyn packages (version 2.8.2).
This commit is contained in:
@@ -122,7 +122,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
[Parameter(ParameterSetName = FromMemberParameterSetName)]
|
||||
[AllowNull]
|
||||
[Alias("NS")]
|
||||
public String Namespace { get; set; } = "Microsoft.PowerShell.Commands.AddType.AutoGeneratedTypes";
|
||||
public String Namespace { get; set; } = "Microsoft.PowerShell.Commands.AddType.AutoGeneratedTypes";
|
||||
|
||||
/// <summary>
|
||||
/// Any using statements required by the auto-generated type.
|
||||
@@ -182,7 +182,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// The literal path to the source code or DLL to load.
|
||||
/// </summary>
|
||||
[Parameter(Mandatory = true, ParameterSetName = FromLiteralPathParameterSetName)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
|
||||
public string[] LiteralPath
|
||||
{
|
||||
@@ -870,7 +870,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
switch (Language)
|
||||
{
|
||||
case Language.CSharp:
|
||||
return CSharpSyntaxTree.ParseText(sourceText, (CSharpParseOptions) parseOptions, path);
|
||||
return CSharpSyntaxTree.ParseText(sourceText, (CSharpParseOptions)parseOptions, path);
|
||||
|
||||
default:
|
||||
throw PSTraceSource.NewNotSupportedException();
|
||||
@@ -1044,7 +1044,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
// Visit symbols in all namespaces and collect duplicates.
|
||||
private class AllNamedTypeSymbolsVisitor : SymbolVisitor
|
||||
{
|
||||
int _hash;
|
||||
private int _hash;
|
||||
|
||||
public readonly ConcurrentBag<String> DuplicateSymbols = new ConcurrentBag<String>();
|
||||
public readonly ConcurrentBag<String> UniqueSymbols = new ConcurrentBag<String>();
|
||||
@@ -1241,7 +1241,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
sb.AppendLine(diagnisticMessage);
|
||||
sb.AppendLine(errorLineString);
|
||||
|
||||
for (var i = 0 ; i < errorLineString.Length ; i++)
|
||||
for (var i = 0; i < errorLineString.Length; i++)
|
||||
{
|
||||
if (!char.IsWhiteSpace(errorLineString[i]))
|
||||
{
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter()]
|
||||
[ValidateNotNullOrEmpty]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
|
||||
public string LiteralPath
|
||||
{
|
||||
@@ -544,7 +544,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter(ValueFromPipelineByPropertyName = true)]
|
||||
[ValidateNotNullOrEmpty]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
|
||||
public string[] LiteralPath
|
||||
{
|
||||
@@ -1260,10 +1260,12 @@ namespace Microsoft.PowerShell.Commands
|
||||
{
|
||||
values[0] = values[0].Substring(9);
|
||||
Header = values;
|
||||
} else if (values.Count != 0 && values[0].StartsWith("#"))
|
||||
}
|
||||
else if (values.Count != 0 && values[0].StartsWith("#"))
|
||||
{
|
||||
// Skip all lines starting with '#'
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is not W3C Extended Log File Format
|
||||
// By default first line is Header
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
///
|
||||
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = "ByLiteralPath")]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string LiteralPath
|
||||
{
|
||||
get { return _path; }
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// Literal path of the XML file.
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName = "ByLiteralPath", Mandatory = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public String LiteralPath
|
||||
{
|
||||
get
|
||||
|
||||
+3
-3
@@ -15,9 +15,9 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// <summary>
|
||||
/// Displays the hexidecimal equivalent of the input data.
|
||||
/// </summary>
|
||||
[Cmdlet(VerbsCommon.Format, "Hex", SupportsShouldProcess = true, HelpUri ="https://go.microsoft.com/fwlink/?LinkId=526919")]
|
||||
[Cmdlet(VerbsCommon.Format, "Hex", SupportsShouldProcess = true, HelpUri = "https://go.microsoft.com/fwlink/?LinkId=526919")]
|
||||
[OutputType(typeof(Microsoft.PowerShell.Commands.ByteCollection))]
|
||||
[Alias ("fhx")]
|
||||
[Alias("fhx")]
|
||||
public sealed class FormatHex : PSCmdlet
|
||||
{
|
||||
private const int BUFFERSIZE = 16;
|
||||
@@ -36,7 +36,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter(Mandatory = true, ParameterSetName = "LiteralPath")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string[] LiteralPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// Mandatory file name to write to.
|
||||
/// </summary>
|
||||
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = "ByLiteralPath")]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string LiteralPath
|
||||
{
|
||||
get
|
||||
|
||||
+3
-3
@@ -22,7 +22,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// FALSE: accumulate all the data, then write a single string.
|
||||
/// TRUE: write one line at the time.
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName="StreamFormatting")]
|
||||
[Parameter(ParameterSetName = "StreamFormatting")]
|
||||
public SwitchParameter Stream
|
||||
{
|
||||
get { return _stream; }
|
||||
@@ -47,11 +47,11 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// <summary>
|
||||
/// False to add a newline to the end of the output string, true if not.
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName="NoNewLineFormatting")]
|
||||
[Parameter(ParameterSetName = "NoNewLineFormatting")]
|
||||
public SwitchParameter NoNewline
|
||||
{
|
||||
get { return _noNewLine; }
|
||||
set { _noNewLine = value;}
|
||||
set { _noNewLine = value; }
|
||||
}
|
||||
|
||||
private bool _noNewLine = false;
|
||||
|
||||
@@ -478,7 +478,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
|
||||
// FirstFourDayWeek and DayOfWeek.Monday is from ISO 8601
|
||||
sb.Append(StringUtil.Format("{0:00}",calender.GetWeekOfYear(normalizedDatetime,
|
||||
sb.Append(StringUtil.Format("{0:00}", calender.GetWeekOfYear(normalizedDatetime,
|
||||
CalendarWeekRule.FirstFourDayWeek,
|
||||
DayOfWeek.Monday)));
|
||||
break;
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[Parameter(Mandatory = true, ParameterSetName = LiteralPathParameterSet, Position = 0, ValueFromPipelineByPropertyName = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public String[] LiteralPath
|
||||
{
|
||||
get
|
||||
@@ -275,21 +275,21 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// <summary>
|
||||
/// FileHashInfo class contains information about a file hash.
|
||||
/// </summary>
|
||||
public class FileHashInfo
|
||||
{
|
||||
public class FileHashInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Hash algorithm name.
|
||||
/// </summary>
|
||||
public string Algorithm { get; set;}
|
||||
public string Algorithm { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Hash value.
|
||||
/// </summary>
|
||||
public string Hash { get; set;}
|
||||
public string Hash { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// File path.
|
||||
/// </summary>
|
||||
public string Path { get; set;}
|
||||
}
|
||||
public string Path { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
// InternalTestHooks.StopwatchIsNotHighResolution is used as test hook.
|
||||
if (Stopwatch.IsHighResolution && !InternalTestHooks.StopwatchIsNotHighResolution)
|
||||
{
|
||||
TimeSpan uptime = TimeSpan.FromSeconds(Stopwatch.GetTimestamp()/Stopwatch.Frequency);
|
||||
TimeSpan uptime = TimeSpan.FromSeconds(Stopwatch.GetTimestamp() / Stopwatch.Frequency);
|
||||
|
||||
switch (ParameterSetName)
|
||||
{
|
||||
@@ -65,5 +65,5 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// Parameter set name for DateTime OutputType.
|
||||
/// </summary>
|
||||
private const string SinceParameterSet = "Since";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
///
|
||||
[Parameter(Mandatory = true, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, ParameterSetName = LiteralPathParameterSetName)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string LiteralPath
|
||||
{
|
||||
get
|
||||
|
||||
+4
-4
@@ -15,7 +15,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
HelpUri = "https://go.microsoft.com/fwlink/?LinkID=623621", RemotingCapability = RemotingCapability.None)]
|
||||
public class ImportPowerShellDataFileCommand : PSCmdlet
|
||||
{
|
||||
bool _isLiteralPath;
|
||||
private bool _isLiteralPath;
|
||||
|
||||
/// <summary>
|
||||
/// Path specified, using globbing to resolve.
|
||||
@@ -30,7 +30,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter(Mandatory = true, Position = 0, ParameterSetName = "ByLiteralPath", ValueFromPipelineByPropertyName = true)]
|
||||
[ValidateNotNullOrEmpty]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
|
||||
public string[] LiteralPath
|
||||
{
|
||||
@@ -46,7 +46,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
foreach (var path in Path)
|
||||
{
|
||||
var resolved = PathUtils.ResolveFilePath(path, this, _isLiteralPath);
|
||||
if(!string.IsNullOrEmpty(resolved) && System.IO.File.Exists(resolved))
|
||||
if (!string.IsNullOrEmpty(resolved) && System.IO.File.Exists(resolved))
|
||||
{
|
||||
Token[] tokens;
|
||||
ParseError[] errors;
|
||||
@@ -85,7 +85,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
WriteError(errorRecord);
|
||||
}
|
||||
|
||||
void WriteInvalidDataFileError(string resolvedPath, string errorId)
|
||||
private void WriteInvalidDataFileError(string resolvedPath, string errorId)
|
||||
{
|
||||
var errorCategory = ErrorCategory.InvalidData;
|
||||
var errorMessage = string.Format(UtilityResources.CouldNotParseAsPowerShellDataFile, resolvedPath);
|
||||
|
||||
@@ -996,7 +996,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = "LiteralFile")]
|
||||
[FileinfoToString]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
|
||||
public string[] LiteralPath
|
||||
{
|
||||
|
||||
@@ -311,7 +311,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
_allStats = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private bool _allStats;
|
||||
|
||||
/// <summary>
|
||||
@@ -467,7 +467,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
|
||||
// finally call the base class.
|
||||
base.BeginProcessing();
|
||||
base.BeginProcessing();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -710,6 +710,6 @@ namespace Microsoft.PowerShell.Commands
|
||||
return result;
|
||||
}
|
||||
|
||||
OrderByPropertyComparer _orderByPropertyComparer = null;
|
||||
private OrderByPropertyComparer _orderByPropertyComparer = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
[Alias("ral")]
|
||||
public class RemoveAliasCommand : PSCmdlet
|
||||
{
|
||||
#region Parameters
|
||||
#region Parameters
|
||||
|
||||
/// <summary>
|
||||
/// The alias name to remove.
|
||||
@@ -45,7 +45,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
foreach(string aliasName in Name)
|
||||
foreach (string aliasName in Name)
|
||||
{
|
||||
AliasInfo existingAlias = null;
|
||||
if (String.IsNullOrEmpty(Scope))
|
||||
@@ -64,7 +64,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
else
|
||||
{
|
||||
ItemNotFoundException notAliasFound = new ItemNotFoundException(StringUtil.Format(AliasCommandStrings.NoAliasFound, "name", aliasName));
|
||||
ErrorRecord error = new ErrorRecord(notAliasFound, "ItemNotFoundException",ErrorCategory.ObjectNotFound, aliasName);
|
||||
ErrorRecord error = new ErrorRecord(notAliasFound, "ItemNotFoundException", ErrorCategory.ObjectNotFound, aliasName);
|
||||
WriteError(error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// The literal path of the file to unblock
|
||||
/// </summary>
|
||||
[Parameter(Mandatory = true, ParameterSetName = "ByLiteralPath", ValueFromPipelineByPropertyName = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
|
||||
public string[] LiteralPath
|
||||
{
|
||||
|
||||
@@ -976,11 +976,11 @@ namespace Microsoft.PowerShell.Commands
|
||||
if (entries.Count > 0)
|
||||
{
|
||||
Context.FormatDBManager.UpdateDataBase(entries, this.Context.AuthorizationManager, this.Context.EngineHostInterface, false);
|
||||
FormatAndTypeDataHelper.ThrowExceptionOnError( "ErrorsUpdatingFormats",
|
||||
FormatAndTypeDataHelper.ThrowExceptionOnError("ErrorsUpdatingFormats",
|
||||
null,
|
||||
entries,
|
||||
RunspaceConfigurationCategory.Formats);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (RuntimeException e)
|
||||
{
|
||||
|
||||
+2
-2
@@ -30,8 +30,8 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// <summary>
|
||||
/// Gets or sets the parameter CustomMethod.
|
||||
/// </summary>
|
||||
[Parameter(Mandatory=true,ParameterSetName = "CustomMethod")]
|
||||
[Parameter(Mandatory=true,ParameterSetName = "CustomMethodNoProxy")]
|
||||
[Parameter(Mandatory = true, ParameterSetName = "CustomMethod")]
|
||||
[Parameter(Mandatory = true, ParameterSetName = "CustomMethodNoProxy")]
|
||||
[Alias("CM")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public override string CustomMethod
|
||||
|
||||
+11
-11
@@ -262,8 +262,8 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// <summary>
|
||||
/// Gets or sets the CustomMethod property.
|
||||
/// </summary>
|
||||
[Parameter(Mandatory=true,ParameterSetName = "CustomMethod")]
|
||||
[Parameter(Mandatory=true,ParameterSetName = "CustomMethodNoProxy")]
|
||||
[Parameter(Mandatory = true, ParameterSetName = "CustomMethod")]
|
||||
[Parameter(Mandatory = true, ParameterSetName = "CustomMethodNoProxy")]
|
||||
[Alias("CM")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public virtual string CustomMethod
|
||||
@@ -280,8 +280,8 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// <summary>
|
||||
/// Gets or sets the NoProxy property.
|
||||
/// </summary>
|
||||
[Parameter(Mandatory=true,ParameterSetName = "CustomMethodNoProxy")]
|
||||
[Parameter(Mandatory=true,ParameterSetName = "StandardMethodNoProxy")]
|
||||
[Parameter(Mandatory = true, ParameterSetName = "CustomMethodNoProxy")]
|
||||
[Parameter(Mandatory = true, ParameterSetName = "StandardMethodNoProxy")]
|
||||
public virtual SwitchParameter NoProxy { get; set; }
|
||||
|
||||
#endregion
|
||||
@@ -326,7 +326,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// A value may be a collection of form values or single form value.
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public virtual IDictionary Form {get; set;}
|
||||
public virtual IDictionary Form { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ContentType property.
|
||||
@@ -572,7 +572,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
// supplying a credential overrides the UseDefaultCredentials setting
|
||||
WebSession.UseDefaultCredentials = false;
|
||||
}
|
||||
else if ((Credential != null || null!= Token) && Authentication != WebAuthenticationType.None)
|
||||
else if ((Credential != null || null != Token) && Authentication != WebAuthenticationType.None)
|
||||
{
|
||||
ProcessAuthentication();
|
||||
}
|
||||
@@ -797,7 +797,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
|
||||
private void ProcessAuthentication()
|
||||
{
|
||||
if(Authentication == WebAuthenticationType.Basic)
|
||||
if (Authentication == WebAuthenticationType.Basic)
|
||||
{
|
||||
WebSession.Headers["Authorization"] = GetBasicAuthorizationHeader();
|
||||
}
|
||||
@@ -826,7 +826,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
/// <param name="message">Message for the exception</param>
|
||||
/// <param name="response">Response from the HTTP server</param>
|
||||
public HttpResponseException (string message, HttpResponseMessage response) : base(message)
|
||||
public HttpResponseException(string message, HttpResponseMessage response) : base(message)
|
||||
{
|
||||
Response = response;
|
||||
}
|
||||
@@ -1255,9 +1255,9 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
|
||||
// Returns true if the status code is one of the supported redirection codes.
|
||||
static bool IsRedirectCode(HttpStatusCode code)
|
||||
private static bool IsRedirectCode(HttpStatusCode code)
|
||||
{
|
||||
int intCode = (int) code;
|
||||
int intCode = (int)code;
|
||||
return
|
||||
(
|
||||
(intCode >= 300 && intCode < 304)
|
||||
@@ -1268,7 +1268,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
|
||||
// Returns true if the status code is a redirection code and the action requires switching from POST to GET on redirection.
|
||||
// NOTE: Some of these status codes map to the same underlying value but spelling them out for completeness.
|
||||
static bool IsRedirectToGet(HttpStatusCode code)
|
||||
private static bool IsRedirectToGet(HttpStatusCode code)
|
||||
{
|
||||
return
|
||||
(
|
||||
|
||||
+1
-1
@@ -120,7 +120,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
{
|
||||
get
|
||||
{
|
||||
if(_headers == null)
|
||||
if (_headers == null)
|
||||
{
|
||||
_headers = WebResponseHelper.GetHeadersDictionary(BaseResponse);
|
||||
}
|
||||
|
||||
+2
-2
@@ -182,7 +182,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
else if (obj is Newtonsoft.Json.Linq.JObject jObject)
|
||||
{
|
||||
rv = jObject.ToObject<Dictionary<object,object>>();
|
||||
rv = jObject.ToObject<Dictionary<object, object>>();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -444,6 +444,6 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// <summary>
|
||||
/// Exception used for Stopping.
|
||||
/// </summary>
|
||||
private class StoppingException : System.Exception {}
|
||||
private class StoppingException : System.Exception { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +129,8 @@ namespace Microsoft.PowerShell.Commands
|
||||
if (Platform.IsWindows)
|
||||
{
|
||||
// only generate the windows user agent once
|
||||
if(s_windowsUserAgent == null){
|
||||
if (s_windowsUserAgent == null)
|
||||
{
|
||||
// find the version in the windows operating system description
|
||||
Regex pattern = new Regex(@"\d+(\.\d+)+");
|
||||
string versionText = pattern.Match(OS).Value;
|
||||
|
||||
+20
-17
@@ -343,7 +343,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
internal static void SaveStreamToFile(Stream stream, string filePath, PSCmdlet cmdlet)
|
||||
{
|
||||
// If the web cmdlet should resume, append the file instead of overwriting.
|
||||
if(cmdlet is WebRequestPSCmdlet webCmdlet && webCmdlet.ShouldResume)
|
||||
if (cmdlet is WebRequestPSCmdlet webCmdlet && webCmdlet.ShouldResume)
|
||||
{
|
||||
using (FileStream output = new FileStream(filePath, FileMode.Append, FileAccess.Write, FileShare.Read))
|
||||
{
|
||||
@@ -432,7 +432,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
return result;
|
||||
}
|
||||
|
||||
static readonly Regex s_metaexp = new Regex(@"<meta\s[.\n]*[^><]*charset\s*=\s*[""'\n]?(?<charset>[A-Za-z].[^\s""'\n<>]*)[\s""'\n>]");
|
||||
private static readonly Regex s_metaexp = new Regex(@"<meta\s[.\n]*[^><]*charset\s*=\s*[""'\n]?(?<charset>[A-Za-z].[^\s""'\n<>]*)[\s""'\n>]");
|
||||
|
||||
internal static string DecodeStream(Stream stream, ref Encoding encoding)
|
||||
{
|
||||
@@ -444,25 +444,28 @@ namespace Microsoft.PowerShell.Commands
|
||||
isDefaultEncoding = true;
|
||||
}
|
||||
|
||||
string content = StreamToString (stream, encoding);
|
||||
if (isDefaultEncoding) do
|
||||
string content = StreamToString(stream, encoding);
|
||||
if (isDefaultEncoding)
|
||||
{
|
||||
// check for a charset attribute on the meta element to override the default.
|
||||
Match match = s_metaexp.Match(content);
|
||||
if (match.Success)
|
||||
do
|
||||
{
|
||||
Encoding localEncoding = null;
|
||||
string characterSet = match.Groups["charset"].Value;
|
||||
|
||||
if (TryGetEncoding(characterSet, out localEncoding))
|
||||
// check for a charset attribute on the meta element to override the default.
|
||||
Match match = s_metaexp.Match(content);
|
||||
if (match.Success)
|
||||
{
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
content = StreamToString(stream, localEncoding);
|
||||
// report the encoding used.
|
||||
encoding = localEncoding;
|
||||
Encoding localEncoding = null;
|
||||
string characterSet = match.Groups["charset"].Value;
|
||||
|
||||
if (TryGetEncoding(characterSet, out localEncoding))
|
||||
{
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
content = StreamToString(stream, localEncoding);
|
||||
// report the encoding used.
|
||||
encoding = localEncoding;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (false);
|
||||
} while (false);
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// Mandatory file name to write to.
|
||||
/// </summary>
|
||||
[Parameter(Mandatory = true, ParameterSetName = "ByLiteralPath")]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string LiteralPath
|
||||
{
|
||||
get
|
||||
@@ -295,7 +295,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// Mandatory file name to read from.
|
||||
/// </summary>
|
||||
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = "ByLiteralPath")]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
|
||||
public String[] LiteralPath
|
||||
{
|
||||
@@ -822,7 +822,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
|
||||
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = "LiteralPath")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public String[] LiteralPath
|
||||
{
|
||||
get { return Path; }
|
||||
|
||||
@@ -417,7 +417,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
|
||||
if (!_fragment)
|
||||
{
|
||||
if(!_transitional)
|
||||
if (!_transitional)
|
||||
{
|
||||
WriteObject("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
|
||||
}
|
||||
@@ -427,17 +427,19 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
WriteObject("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
|
||||
WriteObject("<head>");
|
||||
if(_charsetSpecified)
|
||||
if (_charsetSpecified)
|
||||
{
|
||||
WriteObject("<meta charset=\"" + _charset + "\">");
|
||||
}
|
||||
if(_metaSpecified)
|
||||
if (_metaSpecified)
|
||||
{
|
||||
List<string> useditems = new List<string>();
|
||||
foreach(string s in _meta.Keys)
|
||||
foreach (string s in _meta.Keys)
|
||||
{
|
||||
if(!useditems.Contains(s)){
|
||||
switch(s.ToLower()){
|
||||
if (!useditems.Contains(s))
|
||||
{
|
||||
switch (s.ToLower())
|
||||
{
|
||||
case "content-type":
|
||||
case "default-style":
|
||||
case "x-ua-compatible":
|
||||
|
||||
@@ -276,7 +276,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
|
||||
private int _streamedObjectCount;
|
||||
private int _first,_last,_skip,_skipLast;
|
||||
private int _first, _last, _skip, _skipLast;
|
||||
private bool _firstOrLastSpecified;
|
||||
}
|
||||
|
||||
@@ -332,7 +332,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
// ExcludeProperty implies -Property * for better UX
|
||||
if ((Property == null) || (Property.Length == 0))
|
||||
{
|
||||
Property = new Object[]{"*"};
|
||||
Property = new Object[] { "*" };
|
||||
_propertyMshParameterList = processor.ProcessParameters(Property, invocationContext);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
[Cmdlet("Sort",
|
||||
"Object",
|
||||
HelpUri = "https://go.microsoft.com/fwlink/?LinkID=113403",
|
||||
DefaultParameterSetName="Default",
|
||||
DefaultParameterSetName = "Default",
|
||||
RemotingCapability = RemotingCapability.None)]
|
||||
public sealed class SortObjectCommand : OrderObjectBase
|
||||
{
|
||||
@@ -42,15 +42,15 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// <summary>
|
||||
/// This param specifies you only want the top N items returned.
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName="Default")]
|
||||
[ValidateRange(1,int.MaxValue)]
|
||||
[Parameter(ParameterSetName = "Default")]
|
||||
[ValidateRange(1, int.MaxValue)]
|
||||
public int Top { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// This param specifies you only want the bottom N items returned.
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName="Bottom", Mandatory=true)]
|
||||
[ValidateRange(1,int.MaxValue)]
|
||||
[Parameter(ParameterSetName = "Bottom", Mandatory = true)]
|
||||
[ValidateRange(1, int.MaxValue)]
|
||||
public int Bottom { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// Literal FilePath parameter.
|
||||
/// </summary>
|
||||
[Parameter(Mandatory = true, ParameterSetName = "LiteralFile")]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string LiteralPath
|
||||
{
|
||||
get
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[Parameter(ParameterSetName = "optionsSet")]
|
||||
[Alias("PSPath","Path")]
|
||||
[Alias("PSPath", "Path")]
|
||||
public string FilePath
|
||||
{
|
||||
get { return base.FileListener; }
|
||||
|
||||
+1
-1
@@ -95,7 +95,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[Parameter]
|
||||
[Alias("PSPath","Path")]
|
||||
[Alias("PSPath", "Path")]
|
||||
public string FilePath
|
||||
{
|
||||
get { return base.FileListener; }
|
||||
|
||||
Reference in New Issue
Block a user