Merge branch 'master' into preview.7

This commit is contained in:
Dongbo Wang 2020-09-08 16:27:29 -07:00 committed by GitHub
commit 47f3beafcd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 23 additions and 29 deletions

View file

@ -34,7 +34,7 @@
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.7.0" />
<PackageReference Include="System.Threading.AccessControl" Version="5.0.0-preview.8.20407.11" />
<PackageReference Include="System.Drawing.Common" Version="5.0.0-preview.8.20407.11" />
<PackageReference Include="NJsonSchema" Version="10.1.24" />
<PackageReference Include="NJsonSchema" Version="10.1.26" />
</ItemGroup>
</Project>

View file

@ -121,16 +121,11 @@ namespace Microsoft.WSMan.Management
{
string result = m_SessionObj.Get(helper.CredSSP_RUri, 0);
XmlDocument resultopxml = new XmlDocument();
string inputXml = null;
resultopxml.LoadXml(result);
XmlNamespaceManager nsmgr = new XmlNamespaceManager(resultopxml.NameTable);
nsmgr.AddNamespace("cfg", helper.CredSSP_XMLNmsp);
XmlNode xNode = resultopxml.SelectSingleNode(helper.CredSSP_SNode, nsmgr);
if (!(xNode == null))
{
inputXml = @"<cfg:Auth xmlns:cfg=""http://schemas.microsoft.com/wbem/wsman/1/config/client/auth""><cfg:CredSSP>false</cfg:CredSSP></cfg:Auth>";
}
else
if (xNode is null)
{
InvalidOperationException ex = new InvalidOperationException();
ErrorRecord er = new ErrorRecord(ex, helper.GetResourceMsgFromResourcetext("WinrmNotConfigured"), ErrorCategory.InvalidOperation, null);
@ -138,6 +133,8 @@ namespace Microsoft.WSMan.Management
return;
}
string inputXml = @"<cfg:Auth xmlns:cfg=""http://schemas.microsoft.com/wbem/wsman/1/config/client/auth""><cfg:CredSSP>false</cfg:CredSSP></cfg:Auth>";
m_SessionObj.Put(helper.CredSSP_RUri, inputXml, 0);
if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA)
@ -188,19 +185,12 @@ namespace Microsoft.WSMan.Management
{
string result = m_SessionObj.Get(helper.Service_CredSSP_Uri, 0);
XmlDocument resultopxml = new XmlDocument();
string inputXml = null;
resultopxml.LoadXml(result);
XmlNamespaceManager nsmgr = new XmlNamespaceManager(resultopxml.NameTable);
nsmgr.AddNamespace("cfg", helper.Service_CredSSP_XMLNmsp);
XmlNode xNode = resultopxml.SelectSingleNode(helper.CredSSP_SNode, nsmgr);
if (!(xNode == null))
{
inputXml = string.Format(CultureInfo.InvariantCulture,
@"<cfg:Auth xmlns:cfg=""{0}""><cfg:CredSSP>false</cfg:CredSSP></cfg:Auth>",
helper.Service_CredSSP_XMLNmsp);
}
else
if (xNode is null)
{
InvalidOperationException ex = new InvalidOperationException();
ErrorRecord er = new ErrorRecord(ex,
@ -210,6 +200,10 @@ namespace Microsoft.WSMan.Management
return;
}
string inputXml = string.Format(CultureInfo.InvariantCulture,
@"<cfg:Auth xmlns:cfg=""{0}""><cfg:CredSSP>false</cfg:CredSSP></cfg:Auth>",
helper.Service_CredSSP_XMLNmsp);
m_SessionObj.Put(helper.Service_CredSSP_Uri, inputXml, 0);
}
finally

View file

@ -313,13 +313,13 @@ namespace System.Management.Automation.ComInterop
if (argumentType == typeof(IntPtr))
{
primitiveVarEnum = VarEnum.VT_PTR;
primitiveVarEnum = VarEnum.VT_INT;
return true;
}
if (argumentType == typeof(UIntPtr))
{
primitiveVarEnum = VarEnum.VT_PTR;
primitiveVarEnum = VarEnum.VT_UINT;
return true;
}

View file

@ -70,14 +70,14 @@ namespace System.Management.Automation.InteropServices
// VT_INT
public void SetAsByrefInt(ref IntPtr value)
public void SetAsByrefInt(ref int value)
{
SetAsByref(ref value, VarEnum.VT_INT);
}
// VT_UINT
public void SetAsByrefUint(ref UIntPtr value)
public void SetAsByrefUint(ref uint value)
{
SetAsByref(ref value, VarEnum.VT_UINT);
}

View file

@ -5482,7 +5482,7 @@ end {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static bool HasDefaultConstructor(Type type)
{
return !(type.GetConstructor(Type.EmptyTypes) == null);
return type.GetConstructor(Type.EmptyTypes) is not null;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]

View file

@ -1255,7 +1255,7 @@ namespace System.Management.Automation.Language
{
var rdp = runtimeDefinedParamList[index];
var paramAttribute = (ParameterAttribute)rdp.Attributes.First(attr => attr is ParameterAttribute);
if (!(rdp.ParameterType == typeof(SwitchParameter)))
if (rdp.ParameterType != typeof(SwitchParameter))
{
paramAttribute.Position = pos++;
}
@ -5664,7 +5664,7 @@ namespace System.Management.Automation.Language
if (rhs is ConstantExpression && rhs.Type == typeof(Type))
{
var isType = (Type)((ConstantExpression)rhs).Value;
if (!(isType == typeof(PSCustomObject)) && !(isType == typeof(PSObject)))
if (isType != typeof(PSCustomObject) && isType != typeof(PSObject))
{
lhs = lhs.Type.IsValueType ? lhs : Expression.Call(CachedReflectionInfo.PSObject_Base, lhs);
if (binaryExpressionAst.Operator == TokenKind.Is)

View file

@ -93,7 +93,7 @@ namespace System.Management.Automation.Language
if (baseValue != null && baseValue.GetType() == typeof(object[]))
{
var effectiveArgType = Adapter.EffectiveArgumentType(obj.Value);
var methodInfo = !(effectiveArgType == typeof(object[]))
var methodInfo = effectiveArgType != typeof(object[])
? CachedReflectionInfo.PSInvokeMemberBinder_IsHomogenousArray.MakeGenericMethod(effectiveArgType.GetElementType())
: CachedReflectionInfo.PSInvokeMemberBinder_IsHeterogeneousArray;
@ -1136,7 +1136,7 @@ namespace System.Management.Automation.Language
Diagnostics.Assert(pipelineResult != null, "Pipeline result is always an IList");
var ilistExpr = target.Expression;
if (!(typeof(IList) == ilistExpr.Type))
if (typeof(IList) != ilistExpr.Type)
{
ilistExpr = Expression.Convert(ilistExpr, typeof(IList));
}
@ -2651,7 +2651,7 @@ namespace System.Management.Automation.Language
return new DynamicMetaObject(arg.Expression.Cast(typeof(object)), target.CombineRestrictions(arg));
}
if (target.LimitType.IsNumericOrPrimitive() && !(target.LimitType == typeof(char)))
if (target.LimitType.IsNumericOrPrimitive() && target.LimitType != typeof(char))
{
var numericArg = GetArgAsNumericOrPrimitive(arg, target.LimitType);
if (numericArg != null)
@ -3075,7 +3075,7 @@ namespace System.Management.Automation.Language
var targetExpr = target.Expression.Cast(typeof(string));
// Doing a string comparison no matter what.
var argExpr = !(arg.LimitType == typeof(string))
var argExpr = arg.LimitType != typeof(string)
? DynamicExpression.Dynamic(PSToStringBinder.Get(), typeof(string),
arg.Expression, ExpressionCache.GetExecutionContextFromTLS)
: arg.Expression.Cast(typeof(string));
@ -3253,7 +3253,7 @@ namespace System.Management.Automation.Language
var targetExpr = target.Expression.Cast(typeof(string));
// Doing a string comparison no matter what.
var argExpr = !(arg.LimitType == typeof(string))
var argExpr = arg.LimitType != typeof(string)
? DynamicExpression.Dynamic(PSToStringBinder.Get(), typeof(string),
arg.Expression, ExpressionCache.GetExecutionContextFromTLS)
: arg.Expression.Cast(typeof(string));
@ -3811,7 +3811,7 @@ namespace System.Management.Automation.Language
target.Expression.Cast(typeof(object)),
Expression.Constant(toType, typeof(Type)));
if (!(binder.ReturnType == typeof(void)))
if (binder.ReturnType != typeof(void))
{
expr = Expression.Block(expr, Expression.Default(binder.ReturnType));
}

View file

@ -8246,7 +8246,7 @@ namespace Microsoft.PowerShell.Commands
bool isHardLink = false;
// only check for hard link if the item is not directory
if (!((fileInfo.Attributes & System.IO.FileAttributes.Directory) == System.IO.FileAttributes.Directory))
if ((fileInfo.Attributes & System.IO.FileAttributes.Directory) != System.IO.FileAttributes.Directory)
{
IntPtr nativeHandle = InternalSymbolicLinkLinkCodeMethods.CreateFile(
fileInfo.FullName,