本文整理汇总了C#中SemanticModel.TryGetSpeculativeSemanticModel方法的典型用法代码示例。如果您正苦于以下问题:C# SemanticModel.TryGetSpeculativeSemanticModel方法的具体用法?C# SemanticModel.TryGetSpeculativeSemanticModel怎么用?C# SemanticModel.TryGetSpeculativeSemanticModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SemanticModel
的用法示例。
在下文中一共展示了SemanticModel.TryGetSpeculativeSemanticModel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestGetSpeculativeSemanticModelForTypeSyntax_Common
private static void TestGetSpeculativeSemanticModelForTypeSyntax_Common(
SemanticModel model,
int position,
TypeSyntax speculatedTypeSyntax,
SpeculativeBindingOption bindingOption,
SymbolKind expectedSymbolKind,
string expectedTypeDislayString)
{
Assert.False(model.IsSpeculativeSemanticModel);
Assert.Null(model.ParentModel);
Assert.Equal(0, model.OriginalPositionForSpeculation);
SemanticModel speculativeModel;
var success = model.TryGetSpeculativeSemanticModel(position, speculatedTypeSyntax, out speculativeModel, bindingOption);
Assert.True(success);
Assert.NotNull(speculativeModel);
Assert.True(speculativeModel.IsSpeculativeSemanticModel);
Assert.Equal(model, speculativeModel.ParentModel);
Assert.NotNull(speculativeModel);
Assert.Equal(position, speculativeModel.OriginalPositionForSpeculation);
var symbol = speculativeModel.GetSymbolInfo(speculatedTypeSyntax).Symbol;
Assert.NotNull(symbol);
Assert.Equal(expectedSymbolKind, symbol.Kind);
Assert.Equal(expectedTypeDislayString, symbol.ToDisplayString());
var typeSymbol = speculativeModel.GetTypeInfo(speculatedTypeSyntax).Type;
Assert.NotNull(symbol);
Assert.Equal(expectedSymbolKind, symbol.Kind);
Assert.Equal(expectedTypeDislayString, symbol.ToDisplayString());
if (speculatedTypeSyntax.Kind == SyntaxKind.QualifiedName)
{
var right = ((QualifiedNameSyntax)speculatedTypeSyntax).Right;
symbol = speculativeModel.GetSymbolInfo(right).Symbol;
Assert.NotNull(symbol);
Assert.Equal(expectedSymbolKind, symbol.Kind);
Assert.Equal(expectedTypeDislayString, symbol.ToDisplayString());
typeSymbol = speculativeModel.GetTypeInfo(right).Type;
Assert.NotNull(symbol);
Assert.Equal(expectedSymbolKind, symbol.Kind);
Assert.Equal(expectedTypeDislayString, symbol.ToDisplayString());
}
}