using System.Collections.Generic;
using System.Diagnostics;
using System.Dynamic;
-using System.Linq;
using System.Linq.Expressions;
using Microsoft.CSharp.RuntimeBinder.Errors;
using Microsoft.CSharp.RuntimeBinder.Semantics;
LocalVariableSymbol[] locals)
{
Debug.Assert(arguments.Length >= 2);
- Debug.Assert(arguments.All(a => a.Type != null));
+ Debug.Assert(Array.TrueForAll(arguments, a => a.Type != null));
string name = payload.Name;
using System;
using System.Diagnostics;
-using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
// Recurse in for generic types arrays, byref and pointer types.
if (t1.IsGenericType && t2.IsGenericType)
{
- var args1 = t1.GetGenericArguments();
- var args2 = t2.GetGenericArguments();
+ Type[] args1 = t1.GetGenericArguments();
+ Type[] args2 = t2.GetGenericArguments();
if (args1.Length == args2.Length)
{
- return t1.IsGenericallyEqual(t2) &&
- Enumerable.All(Enumerable.Zip(args1, args2, (ta1, ta2) => ta1.IsGenericallyEquivalentTo(ta2, member1, member2)), x => x);
+ if (!t1.IsGenericallyEqual(t2))
+ {
+ return false;
+ }
+
+ for (int i = 0; i < args1.Length; i++)
+ {
+ if (!args1[i].IsGenericallyEquivalentTo(args2[i], member1, member2))
+ {
+ return false;
+ }
+ }
+
+ return true;
}
}
string name = type.GetCustomAttribute<DefaultMemberAttribute>()?.MemberName;
if (name != null)
{
- if (type.GetProperties(
- BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance)
- .Any(p => p.Name == name && p.GetIndexParameters().Length != 0))
+ foreach (PropertyInfo p in type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance))
{
- return name;
+ if (p.Name == name && p.GetIndexParameters().Length != 0)
+ {
+ return name;
+ }
}
}
using System.Collections.Generic;
using System.Diagnostics;
-using System.Linq;
using Microsoft.CSharp.RuntimeBinder.Syntax;
namespace Microsoft.CSharp.RuntimeBinder.Semantics
out CandidateFunctionMember methAmbig1,
out CandidateFunctionMember methAmbig2)
{
- Debug.Assert(list.Any());
- Debug.Assert(list.First().mpwi != null);
- Debug.Assert(list.Count > 0);
+ Debug.Assert(list.Count != 0);
+ Debug.Assert(list[0].mpwi != null);
// select the best method:
/*
goto phase 2
Phase 2: compare all items before candidate to candidate
If candidate always better, return it, otherwise return null
+ */
- */
// Record two method that are ambiguous for error reporting.
CandidateFunctionMember ambig1 = null;
CandidateFunctionMember ambig2 = null;
{
// For some reason, we have an ambiguity but never had a tie.
// This can easily happen in a circular graph of candidate methods.
- methAmbig1 = list.First();
- methAmbig2 = list.Skip(1).First();
+ methAmbig1 = list[0];
+ methAmbig2 = list[1];
}
return null;
using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Linq;
using Microsoft.CSharp.RuntimeBinder.Errors;
using Microsoft.CSharp.RuntimeBinder.Syntax;
int iDst = 0;
int argCount = ExpressionIterator.Count(argsPtr);
- Debug.Assert(!@params.Items.Any(p => p is ArgumentListType)); // We should never have picked a varargs method to bind to.
+ Debug.Assert(!Array.Exists(@params.Items, p => p is ArgumentListType)); // We should never have picked a varargs method to bind to.
bool bDontFixParamArray = false;
using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Linq;
using Microsoft.CSharp.RuntimeBinder.Errors;
using Microsoft.CSharp.RuntimeBinder.Syntax;
{
return false;
}
- var o = field.AssociatedFieldInfo.GetCustomAttributes(typeof(System.Runtime.CompilerServices.DynamicAttribute), false).ToArray();
+ var o = field.AssociatedFieldInfo.GetCustomAttributes(typeof(System.Runtime.CompilerServices.DynamicAttribute), false);
if (o.Length == 1)
{
da = o[0] as System.Runtime.CompilerServices.DynamicAttribute;
{
return false;
}
- var o = prop.AssociatedPropertyInfo.GetCustomAttributes(typeof(System.Runtime.CompilerServices.DynamicAttribute), false).ToArray();
+ var o = prop.AssociatedPropertyInfo.GetCustomAttributes(typeof(System.Runtime.CompilerServices.DynamicAttribute), false);
if (o.Length == 1)
{
da = o[0] as System.Runtime.CompilerServices.DynamicAttribute;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
-using System.Linq;
namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
public void AssertValid()
{
Debug.Assert(Count >= 0);
- Debug.Assert(Items.All(item => item != null));
+ Debug.Assert(Array.TrueForAll(Items, item => item != null));
}
public void CopyItems(int i, int c, CType[] dest) => Array.Copy(Items, i, dest, 0, c);
using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
(Assembly, Assembly) key = (assemblyThatDefinesAttribute, assemblyToCheck);
if (!s_internalsVisibleToCache.TryGetValue(key, out bool result))
{
- AssemblyName assyName;
-
// Assembly.GetName() requires FileIOPermission to FileIOPermissionAccess.PathDiscovery.
// If we don't have that (we're in low trust), then we are going to effectively turn off
// InternalsVisibleTo. The alternative is to crash when this happens.
try
{
- assyName = assemblyToCheck.GetName();
- result = assemblyThatDefinesAttribute.GetCustomAttributes()
- .OfType<InternalsVisibleToAttribute>()
- .Select(ivta => new AssemblyName(ivta.AssemblyName))
- .Any(an => AssemblyName.ReferenceMatchesDefinition(an, assyName));
+ AssemblyName assyName = assemblyToCheck.GetName();
+ foreach (Attribute attr in assemblyThatDefinesAttribute.GetCustomAttributes())
+ {
+ if (attr is InternalsVisibleToAttribute ivta &&
+ AssemblyName.ReferenceMatchesDefinition(new AssemblyName(ivta.AssemblyName), assyName))
+ {
+ result = true;
+ break;
+ }
+ }
}
catch (SecurityException)
{
// 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;
using System.Diagnostics;
-using System.Linq;
namespace Microsoft.CSharp.RuntimeBinder.Syntax
{
{
int hashCode = ComputeHashCode(name.Text);
// make sure it doesn't already exist
- Debug.Assert(_entries.All(e => e?.Name.Text != name.Text));
+ Debug.Assert(Array.TrueForAll(_entries, e => e?.Name.Text != name.Text));
AddEntry(name, hashCode);
}