public void TestTake() { var zero = IndexedTypeParameterSymbol.TakeSymbols(0); Assert.Equal(0, zero.Length); var five = IndexedTypeParameterSymbol.TakeSymbols(5); Assert.Equal(5, five.Length); Assert.Equal(five[0], IndexedTypeParameterSymbol.GetTypeParameter(0)); Assert.Equal(five[1], IndexedTypeParameterSymbol.GetTypeParameter(1)); Assert.Equal(five[2], IndexedTypeParameterSymbol.GetTypeParameter(2)); Assert.Equal(five[3], IndexedTypeParameterSymbol.GetTypeParameter(3)); Assert.Equal(five[4], IndexedTypeParameterSymbol.GetTypeParameter(4)); var fifty = IndexedTypeParameterSymbol.TakeSymbols(50); Assert.Equal(50, fifty.Length); // prove they are all unique var set = new HashSet <TypeParameterSymbol>(fifty); Assert.Equal(50, set.Count); var fiveHundred = IndexedTypeParameterSymbol.TakeSymbols(500); Assert.Equal(500, fiveHundred.Length); }
/// <summary> /// Given a list of method and/or property candidates, choose the first one (if any) with a signature /// that matches the parameter list in the cref. Return null if there isn't one. /// </summary> /// <remarks> /// Produces a diagnostic for ambiguous matches, but not for unresolved members - WRN_BadXMLRef is /// handled in BindMemberCref. /// </remarks> private static ImmutableArray <Symbol> PerformCrefOverloadResolution(ArrayBuilder <Symbol> candidates, ImmutableArray <ParameterSymbol> parameterSymbols, int arity, MemberCrefSyntax memberSyntax, out Symbol?ambiguityWinner, BindingDiagnosticBag diagnostics) { ArrayBuilder <Symbol>?viable = null; foreach (Symbol candidate in candidates) { // BREAK: In dev11, any candidate with the type "dynamic" anywhere in its parameter list would be skipped // (see XmlDocCommentBinder::bindXmlReference). Apparently, this was because "the params that the xml doc // comments produce never will." This does not appear to have made sense in dev11 (skipping dropping the // candidate doesn't cause anything to blow up and may cause resolution to start succeeding) and it almost // certainly does not in roslyn (the signature comparer ignores the object-dynamic distinction anyway). Symbol signatureMember; switch (candidate.Kind) { case SymbolKind.Method: { MethodSymbol candidateMethod = (MethodSymbol)candidate; MethodKind candidateMethodKind = candidateMethod.MethodKind; bool candidateMethodIsVararg = candidateMethod.IsVararg; // If the arity from the cref is zero, then we accept methods of any arity. int signatureMemberArity = candidateMethodKind == MethodKind.Constructor ? 0 : (arity == 0 ? candidateMethod.Arity : arity); // CONSIDER: we might want to reuse this method symbol (as long as the MethodKind and Vararg-ness match). signatureMember = new SignatureOnlyMethodSymbol( methodKind: candidateMethodKind, typeParameters: IndexedTypeParameterSymbol.TakeSymbols(signatureMemberArity), parameters: parameterSymbols, // This specific comparer only looks for varargs. callingConvention: candidateMethodIsVararg ? Microsoft.Cci.CallingConvention.ExtraArguments : Microsoft.Cci.CallingConvention.HasThis, // These are ignored by this specific MemberSignatureComparer. containingType: null, name: null, refKind: RefKind.None, isInitOnly: false, isStatic: false, returnType: default, refCustomModifiers: ImmutableArray <CustomModifier> .Empty, explicitInterfaceImplementations: ImmutableArray <MethodSymbol> .Empty); break; }