本文整理汇总了C#中ImmutableArray.SelectAsArray方法的典型用法代码示例。如果您正苦于以下问题:C# ImmutableArray.SelectAsArray方法的具体用法?C# ImmutableArray.SelectAsArray怎么用?C# ImmutableArray.SelectAsArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImmutableArray
的用法示例。
在下文中一共展示了ImmutableArray.SelectAsArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessResult
private static ImmutableArray<INavigateToSearchResult> ProcessResult(
string searchPattern,
ImmutableArray<ValueTuple<DeclaredSymbolInfo, Document, IEnumerable<PatternMatch>>> results)
{
var containsDots = searchPattern.IndexOf('.') >= 0;
return results.SelectAsArray(r => ConvertResult(containsDots, r));
}
示例2: Convert
internal static ImmutableArray<CustomModifier> Convert(ImmutableArray<Metadata.PE.MetadataDecoder.ModifierInfo> customModifiers)
{
if (customModifiers.IsDefault)
{
return ImmutableArray<CustomModifier>.Empty;
}
return customModifiers.SelectAsArray(Convert);
}
示例3: Convert
internal static ImmutableArray<CustomModifier> Convert(ImmutableArray<ModifierInfo<TypeSymbol>> customModifiers)
{
if (customModifiers.IsDefault)
{
return ImmutableArray<CustomModifier>.Empty;
}
return customModifiers.SelectAsArray(Convert);
}
示例4: ConstructedMethodSymbol
internal ConstructedMethodSymbol(MethodSymbol constructedFrom, ImmutableArray<TypeSymbol> typeArguments)
: base(containingSymbol: constructedFrom.ContainingType,
map: new TypeMap(constructedFrom.ContainingType, ((MethodSymbol)constructedFrom.OriginalDefinition).TypeParameters, typeArguments.SelectAsArray(TypeMap.TypeSymbolAsTypeWithModifiers)),
originalDefinition: (MethodSymbol)constructedFrom.OriginalDefinition,
constructedFrom: constructedFrom)
{
_typeArguments = typeArguments;
}
示例5: RewriteConstructor
internal static BoundTypeOrInstanceInitializers RewriteConstructor(ImmutableArray<BoundInitializer> boundInitializers, MethodSymbol method)
{
Debug.Assert(!boundInitializers.IsDefault);
Debug.Assert((method.MethodKind == MethodKind.Constructor) || (method.MethodKind == MethodKind.StaticConstructor));
var sourceMethod = method as SourceMethodSymbol;
var syntax = ((object)sourceMethod != null) ? sourceMethod.SyntaxNode : method.GetNonNullSyntaxNode();
return new BoundTypeOrInstanceInitializers(syntax, boundInitializers.SelectAsArray(RewriteInitializersAsStatements));
}
示例6: LocalSlotMapBuilder
private LocalSlotMapBuilder(
ImmutableArray<string> localNames,
ImmutableArray<MetadataDecoder.LocalInfo> localInfo,
Dictionary<EncLocalInfo, int> locals)
{
this.localNames = localNames.SelectAsArray(ParseName);
this.localInfo = localInfo;
this.locals = locals;
this.slotIndex = 0;
}
示例7: LambdaSymbol
private LambdaSymbol(
Symbol containingSymbol,
ImmutableArray<ParameterSymbol> parameters,
TypeSymbol returnType,
MessageID messageID,
CSharpSyntaxNode syntax,
bool isSynthesized,
bool isAsync)
{
this.containingSymbol = containingSymbol;
this.messageID = messageID;
this.syntax = syntax;
this.returnType = returnType;
this.isSynthesized = isSynthesized;
this.isAsync = isAsync;
this.parameters = parameters.SelectAsArray(CopyParameter, this);
}
示例8: LambdaSymbol
public LambdaSymbol(
Symbol containingSymbol,
ImmutableArray<ParameterSymbol> parameters,
RefKind refKind,
TypeSymbol returnType,
MessageID messageID,
CSharpSyntaxNode syntax,
bool isSynthesized)
{
_containingSymbol = containingSymbol;
_messageID = messageID;
_syntax = syntax;
_refKind = refKind;
_returnType = returnType;
_isSynthesized = isSynthesized;
_parameters = parameters.SelectAsArray(CopyParameter, this);
}
示例9: ConstructedNamedTypeSymbol
internal ConstructedNamedTypeSymbol(NamedTypeSymbol constructedFrom, ImmutableArray<TypeWithModifiers> typeArguments, bool unbound = false)
: base(newContainer: constructedFrom.ContainingSymbol,
map: new TypeMap(constructedFrom.ContainingType, constructedFrom.OriginalDefinition.TypeParameters, typeArguments),
originalDefinition: constructedFrom.OriginalDefinition,
constructedFrom: constructedFrom, unbound: unbound)
{
bool hasTypeArgumentsCustomModifiers = false;
_typeArguments = typeArguments.SelectAsArray(a =>
{
if (!a.CustomModifiers.IsDefaultOrEmpty)
{
hasTypeArgumentsCustomModifiers = true;
}
return a.Type;
});
_hasTypeArgumentsCustomModifiers = hasTypeArgumentsCustomModifiers;
_constructedFrom = constructedFrom;
Debug.Assert(constructedFrom.Arity == typeArguments.Length);
Debug.Assert(constructedFrom.Arity != 0);
}
示例10: TypeMap
// Only when the caller passes allowAlpha=true do we tolerate substituted (alpha-renamed) type parameters as keys
internal TypeMap(ImmutableArray<TypeParameterSymbol> from, ImmutableArray<TypeParameterSymbol> to, bool allowAlpha = false)
: this(from, to.SelectAsArray(TypeSymbolAsTypeWithModifiers), allowAlpha)
{
// mapping contents are read-only hereafter
}
示例11: SubstituteTypeParameters
internal ImmutableArray<TypeParameterSymbol> SubstituteTypeParameters(ImmutableArray<TypeParameterSymbol> original)
{
return original.SelectAsArray((tp, m) => (TypeParameterSymbol)m.SubstituteTypeParameter(tp).AsTypeSymbolOnly(), this);
}
示例12: GetLocalInfo
internal override ImmutableArray<EncLocalInfo> GetLocalInfo(
Cci.IMethodDefinition methodDef,
ImmutableArray<LocalDefinition> localDefs)
{
if (localDefs.IsEmpty)
{
return ImmutableArray<EncLocalInfo>.Empty;
}
// Find declarators in current method syntax.
var declarators = LocalVariableDeclaratorsCollector.GetDeclarators((MethodSymbol)methodDef);
// Create a map from declarator to declarator index.
var declaratorToIndex = CreateDeclaratorToIndexMap(declarators);
return localDefs.SelectAsArray(localDef => GetLocalInfo(declaratorToIndex, localDef));
}
示例13: ProcessParameterlessCrefMemberLookupResults
/// <summary>
/// At this point, we have a list of viable symbols and no parameter list with which to perform
/// overload resolution. We'll just return the first symbol, giving a diagnostic if there are
/// others.
/// Caveat: If there are multiple candidates and only one is from source, then the source symbol
/// wins and no diagnostic is reported.
/// </summary>
private ImmutableArray<Symbol> ProcessParameterlessCrefMemberLookupResults(
ImmutableArray<Symbol> symbols,
int arity,
MemberCrefSyntax memberSyntax,
TypeArgumentListSyntax typeArgumentListSyntax,
out Symbol ambiguityWinner,
DiagnosticBag diagnostics)
{
// If the syntax indicates arity zero, then we match methods of any arity.
// However, if there are both generic and non-generic methods, then the
// generic methods should be ignored.
if (symbols.Length > 1 && arity == 0)
{
bool hasNonGenericMethod = false;
bool hasGenericMethod = false;
foreach (Symbol s in symbols)
{
if (s.Kind != SymbolKind.Method)
{
continue;
}
if (((MethodSymbol)s).Arity == 0)
{
hasNonGenericMethod = true;
}
else
{
hasGenericMethod = true;
}
if (hasGenericMethod && hasNonGenericMethod)
{
break; //Nothing else to be learned.
}
}
if (hasNonGenericMethod && hasGenericMethod)
{
symbols = symbols.WhereAsArray(s =>
s.Kind != SymbolKind.Method || ((MethodSymbol)s).Arity == 0);
}
}
Debug.Assert(!symbols.IsEmpty);
Symbol symbol = symbols[0];
// If there's ambiguity, prefer source symbols.
// Logic is similar to ResultSymbol, but separate because the error handling is totally different.
if (symbols.Length > 1)
{
// Size is known, but IndexOfSymbolFromCurrentCompilation expects a builder.
ArrayBuilder<Symbol> unwrappedSymbols = ArrayBuilder<Symbol>.GetInstance(symbols.Length);
foreach (Symbol wrapped in symbols)
{
unwrappedSymbols.Add(UnwrapAliasNoDiagnostics(wrapped));
}
BestSymbolInfo secondBest;
BestSymbolInfo best = GetBestSymbolInfo(unwrappedSymbols, out secondBest);
Debug.Assert(!best.IsNone);
Debug.Assert(!secondBest.IsNone);
unwrappedSymbols.Free();
int symbolIndex = 0;
if (best.IsFromCompilation)
{
symbolIndex = best.Index;
symbol = symbols[symbolIndex]; // NOTE: symbols, not unwrappedSymbols.
}
if (symbol.Kind == SymbolKind.TypeParameter)
{
CrefSyntax crefSyntax = GetRootCrefSyntax(memberSyntax);
diagnostics.Add(ErrorCode.WRN_BadXMLRefTypeVar, crefSyntax.Location, crefSyntax.ToString());
}
else if (secondBest.IsFromCompilation == best.IsFromCompilation)
{
CrefSyntax crefSyntax = GetRootCrefSyntax(memberSyntax);
int otherIndex = symbolIndex == 0 ? 1 : 0;
diagnostics.Add(ErrorCode.WRN_AmbiguousXMLReference, crefSyntax.Location, crefSyntax.ToString(), symbol, symbols[otherIndex]);
ambiguityWinner = ConstructWithCrefTypeParameters(arity, typeArgumentListSyntax, symbol);
return symbols.SelectAsArray(sym => ConstructWithCrefTypeParameters(arity, typeArgumentListSyntax, sym));
}
}
else if (symbol.Kind == SymbolKind.TypeParameter)
{
//.........这里部分代码省略.........
示例14: AssemblyMetadata
internal AssemblyMetadata(ImmutableArray<ModuleMetadata> modules)
{
this.Modules = modules;
this.Assembly = new PEAssembly(this, modules.SelectAsArray(m => m.Module));
}
示例15: MakeTempsForDiscardArguments
internal ImmutableArray<BoundExpression> MakeTempsForDiscardArguments(ImmutableArray<BoundExpression> arguments, ArrayBuilder<LocalSymbol> builder)
{
var discardsCount = arguments.Count(a => a.Kind == BoundKind.DiscardExpression);
if (discardsCount != 0)
{
arguments = arguments.SelectAsArray(
(arg, t) => arg.Kind == BoundKind.DiscardExpression ? t.factory.MakeTempForDiscard((BoundDiscardExpression)arg, t.builder) : arg,
(factory: this, builder: builder));
}
return arguments;
}