本文整理汇总了C#中ImmutableArray.Reverse方法的典型用法代码示例。如果您正苦于以下问题:C# ImmutableArray.Reverse方法的具体用法?C# ImmutableArray.Reverse怎么用?C# ImmutableArray.Reverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImmutableArray
的用法示例。
在下文中一共展示了ImmutableArray.Reverse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestSemanticModelAPI
private static void TestSemanticModelAPI(
CSharpCompilation compilation,
SyntaxTree tree,
ImmutableArray<SemanticModelInfo> infos,
ImmutableArray<Diagnostic> diagnostics,
bool backwards)
{
SemanticModel semanticModel = compilation.GetSemanticModel(tree);
SymbolInfo symInfo;
TypeInfo typeInfo;
foreach (var info in backwards ? infos.Reverse() : infos)
{
info.Clear();
switch (info.Node.Kind)
{
case SyntaxKind.Parameter:
var parameterDecl = (ParameterSyntax)info.Node;
var param = (ParameterSymbol)semanticModel.GetDeclaredSymbol(parameterDecl);
Assert.Equal(parameterDecl.Identifier.ValueText, param.Name);
Assert.Equal(parameterDecl.Identifier.GetLocation(), param.Locations[0]);
info.SymInfo = new SymbolInfo(param);
break;
case SyntaxKind.VariableDeclarator:
var declarator = (VariableDeclaratorSyntax)info.Node;
var local = (LocalSymbol)semanticModel.GetDeclaredSymbol(declarator);
if ((object)local != null)
{
Assert.Equal(declarator.Identifier.ValueText, local.Name);
Assert.Equal(declarator.Identifier.GetLocation(), local.Locations[0]);
}
else if (declarator.Identifier.IsMissing)
{
break;
}
else
{
Assert.Equal(SyntaxKind.DeclarationExpression, declarator.Parent.Kind);
Assert.True(diagnostics.Where(d => d.Code == (int)ErrorCode.ERR_DeclarationExpressionOutOfContext &&
d.Location == declarator.Parent.GetLocation()).Any());
break;
}
info.SymInfo = new SymbolInfo(local);
if (declarator.Parent.Kind == SyntaxKind.DeclarationExpression)
{
Assert.Equal(LocalDeclarationKind.RegularVariable, local.DeclarationKind);
var declExpr = (DeclarationExpressionSyntax)declarator.Parent;
symInfo = semanticModel.GetSymbolInfo(declExpr);
Assert.Same(local, symInfo.Symbol);
typeInfo = semanticModel.GetTypeInfo(declExpr);
Assert.Equal(local.Type, typeInfo.Type);
}
Assert.True(semanticModel.LookupNames(declarator.Identifier.Position).Contains(local.Name));
var declDiagnostics = diagnostics.Where(d => d.Location == declarator.Identifier.GetLocation()).ToArray();
bool duplicate = declDiagnostics.Where(d => d.Code == (int)ErrorCode.ERR_LocalDuplicate).Any();
bool overrides = declDiagnostics.Where(d => d.Code == (int)ErrorCode.ERR_LocalIllegallyOverrides).Any();
Assert.False(duplicate && overrides);
if (duplicate)
{
Assert.NotEqual(local, semanticModel.LookupSymbols(declarator.Identifier.Position, name: local.Name).Single());
}
else
{
Assert.Same(local, semanticModel.LookupSymbols(declarator.Identifier.Position, name: local.Name).Single());
}
break;
case SyntaxKind.CatchDeclaration:
var catchDecl = (CatchDeclarationSyntax)info.Node;
local = (LocalSymbol)semanticModel.GetDeclaredSymbol(catchDecl);
Assert.Equal(catchDecl.Identifier.ValueText, local.Name);
Assert.Equal(catchDecl.Identifier.GetLocation(), local.Locations[0]);
info.SymInfo = new SymbolInfo(local);
break;
case SyntaxKind.ForEachStatement:
var loop = (ForEachStatementSyntax)info.Node;
local = (LocalSymbol)semanticModel.GetDeclaredSymbol(loop);
Assert.Equal(loop.Identifier.ValueText, local.Name);
Assert.Equal(loop.Identifier.GetLocation(), local.Locations[0]);
info.SymInfo = new SymbolInfo(local);
break;
//.........这里部分代码省略.........