本文整理汇总了C#中ImmutableArray.Any方法的典型用法代码示例。如果您正苦于以下问题:C# ImmutableArray.Any方法的具体用法?C# ImmutableArray.Any怎么用?C# ImmutableArray.Any使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImmutableArray
的用法示例。
在下文中一共展示了ImmutableArray.Any方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetExpectedDescendants
protected IList<SyntaxNode> GetExpectedDescendants(IEnumerable<SyntaxNode> nodes, ImmutableArray<SyntaxKind> expected)
{
var descendants = new List<SyntaxNode>();
foreach (var node in nodes)
{
if (expected.Any(e => e == node.Kind()))
{
descendants.Add(node);
continue;
}
foreach (var child in node.ChildNodes())
{
if (expected.Any(e => e == child.Kind()))
{
descendants.Add(child);
continue;
}
if (child.ChildNodes().Count() > 0)
descendants.AddRange(GetExpectedDescendants(child.ChildNodes(), expected));
}
}
return descendants;
}
示例2: SourceAttributeData
internal SourceAttributeData(
SyntaxReference applicationNode,
NamedTypeSymbol attributeClass,
MethodSymbol attributeConstructor,
ImmutableArray<TypedConstant> constructorArguments,
ImmutableArray<int> constructorArgumentsSourceIndices,
ImmutableArray<KeyValuePair<string, TypedConstant>> namedArguments,
bool hasErrors,
bool isConditionallyOmitted)
{
Debug.Assert(!isConditionallyOmitted || (object)attributeClass != null && attributeClass.IsConditional);
Debug.Assert(!constructorArguments.IsDefault);
Debug.Assert(!namedArguments.IsDefault);
Debug.Assert(constructorArgumentsSourceIndices.IsDefault ||
constructorArgumentsSourceIndices.Any() && constructorArgumentsSourceIndices.Length == constructorArguments.Length);
this.attributeClass = attributeClass;
this.attributeConstructor = attributeConstructor;
this.constructorArguments = constructorArguments;
this.constructorArgumentsSourceIndices = constructorArgumentsSourceIndices;
this.namedArguments = namedArguments;
this.isConditionallyOmitted = isConditionallyOmitted;
this.hasErrors = hasErrors;
this.applicationNode = applicationNode;
}
示例3: SymbolImplementation
public SymbolImplementation(ImmutableArray<BoundStatement> statements, SymbolScope scope)
{
Scope = scope;
Statements = statements;
DeclaresVariables = statements.Any(x => x is BoundVariableDeclaration);
}
示例4: TryAddSnippetInvocationPart
private async Task<ImmutableArray<TaggedText>> TryAddSnippetInvocationPart(
Document document, CompletionItem item,
ImmutableArray<TaggedText> parts, CancellationToken cancellationToken)
{
var languageServices = document.Project.LanguageServices;
var snippetService = languageServices.GetService<ISnippetInfoService>();
if (snippetService != null)
{
var change = await GetTextChangeAsync(document, item, ch: '\t', cancellationToken: cancellationToken).ConfigureAwait(false) ??
new TextChange(item.Span, item.DisplayText);
var insertionText = change.NewText;
if (snippetService != null && snippetService.SnippetShortcutExists_NonBlocking(insertionText))
{
var note = string.Format(FeaturesResources.Note_colon_Tab_twice_to_insert_the_0_snippet, insertionText);
if (parts.Any())
{
parts = parts.Add(new TaggedText(TextTags.LineBreak, Environment.NewLine));
}
parts = parts.Add(new TaggedText(TextTags.Text, note));
}
}
return parts;
}
示例5: SetScriptInitializerReturnType
private static void SetScriptInitializerReturnType(
CSharpCompilation compilation,
SynthesizedInteractiveInitializerMethod scriptInitializer,
ImmutableArray<ImmutableArray<FieldOrPropertyInitializer>> fieldInitializers,
DiagnosticBag diagnostics)
{
bool isAsync = scriptInitializer.IsSubmissionInitializer && fieldInitializers.Any(i => i.Any(ContainsAwaitsVisitor.ContainsAwait));
var resultType = scriptInitializer.ResultType;
TypeSymbol returnType;
if ((object)resultType == null)
{
Debug.Assert(!isAsync);
returnType = compilation.GetSpecialType(SpecialType.System_Void);
}
else if (!isAsync)
{
returnType = resultType;
}
else
{
var taskT = compilation.GetWellKnownType(WellKnownType.System_Threading_Tasks_Task_T);
var useSiteDiagnostic = taskT.GetUseSiteDiagnostic();
if (useSiteDiagnostic != null)
{
diagnostics.Add(useSiteDiagnostic, NoLocation.Singleton);
}
returnType = taskT.Construct(resultType);
}
scriptInitializer.SetReturnType(isAsync, returnType);
}
示例6: BuildText
private string BuildText(ImmutableArray<Todo> todos)
{
if (!todos.Any()) return string.Empty;
if (todos.Count() == 1) return "1 item left";
return $"{todos.Count()} items left";
}
示例7: DesktopStrongNameProvider
/// <summary>
/// Creates an instance of <see cref="DesktopStrongNameProvider"/>.
/// </summary>
/// <param name="keyFileSearchPaths">
/// An ordered set of fully qualified paths which are searched when locating a cryptographic key file.
/// </param>
public DesktopStrongNameProvider(ImmutableArray<string> keyFileSearchPaths = default(ImmutableArray<string>))
{
if (!keyFileSearchPaths.IsDefault && keyFileSearchPaths.Any(path => !PathUtilities.IsAbsolute(path)))
{
throw new ArgumentException(CodeAnalysisResources.AbsolutePathExpected, "keyFileSearchPaths");
}
_keyFileSearchPaths = keyFileSearchPaths.NullToEmpty();
}
示例8: FixItemSpans
private static ImmutableArray<CompletionItem> FixItemSpans(ImmutableArray<CompletionItem> items, TextSpan defaultSpan)
{
if (defaultSpan != default(TextSpan) && items.Any(i => i.Span == default(TextSpan)))
{
items = items.Select(i => i.Span == default(TextSpan) ? i.WithSpan(defaultSpan) : i).ToImmutableArray();
}
return items;
}
示例9: AnalyzerImageReference
public AnalyzerImageReference(ImmutableArray<DiagnosticAnalyzer> analyzers, string fullPath = null, string display = null)
{
if (analyzers.Any(a => a == null))
{
throw new ArgumentException("Cannot have null-valued analyzer", "analyzers");
}
_analyzers = analyzers;
_fullPath = fullPath;
_display = display;
}
示例10: ExistingReferencesResolver
public ExistingReferencesResolver(
MetadataFileReferenceResolver resolver,
ImmutableArray<PortableExecutableReference> availableReferences,
AssemblyIdentityComparer assemblyIdentityComparer)
{
Debug.Assert(!availableReferences.Any(r => r.Properties.Kind != MetadataImageKind.Assembly));
_resolver = resolver;
_availableReferences = availableReferences;
_assemblyIdentityComparer = assemblyIdentityComparer;
}
示例11: ValidateSearchPaths
internal static void ValidateSearchPaths(ImmutableArray<string> paths, string argName)
{
if (paths.IsDefault)
{
throw new ArgumentNullException(argName);
}
if (paths.Any(path => !PathUtilities.IsAbsolute(path)))
{
throw new ArgumentException(CodeAnalysisResources.AbsolutePathExpected, argName);
}
}
示例12: VerifyAnalyzersArgument
private static void VerifyAnalyzersArgument(ImmutableArray<DiagnosticAnalyzer> analyzers)
{
if (analyzers.IsDefaultOrEmpty)
{
throw new ArgumentException(CodeAnalysisResources.ArgumentCannotBeEmpty, nameof(analyzers));
}
if (analyzers.Any(a => a == null))
{
throw new ArgumentException(CodeAnalysisResources.ArgumentElementCannotBeNull, nameof(analyzers));
}
}
示例13: LocalScope
internal LocalScope(int offset, int endOffset, ImmutableArray<ILocalDefinition> constants, ImmutableArray<ILocalDefinition> locals)
{
Debug.Assert(!locals.Any(l => l.Name == null));
Debug.Assert(!constants.Any(c => c.Name == null));
Debug.Assert(offset >= 0);
Debug.Assert(endOffset > offset);
StartOffset = offset;
EndOffset = endOffset;
_constants = constants;
_locals = locals;
}
示例14: ExistingReferencesResolver
public ExistingReferencesResolver(
ImmutableArray<PortableExecutableReference> availableReferences,
ImmutableArray<string> referencePaths,
string baseDirectory,
AssemblyIdentityComparer assemblyIdentityComparer,
TouchedFileLogger logger)
: base(referencePaths, baseDirectory, logger)
{
Debug.Assert(!availableReferences.Any(r => r.Properties.Kind != MetadataImageKind.Assembly));
_availableReferences = availableReferences;
_assemblyIdentityComparer = assemblyIdentityComparer;
}
示例15: LocalScope
internal LocalScope(uint offset, uint length, ImmutableArray<ILocalDefinition> constants, ImmutableArray<ILocalDefinition> locals)
{
// We should not create 0-length scopes as they are useless.
// however we will allow the case of "begin == end" as that is how edge inclusive scopes of length 1 are represented.
Debug.Assert(!locals.Any(l => l.Name == null));
Debug.Assert(!constants.Any(c => c.Name == null));
_offset = offset;
_length = length;
_constants = constants;
_locals = locals;
}