本文整理汇总了C#中IMethodSymbol.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# IMethodSymbol.ToString方法的具体用法?C# IMethodSymbol.ToString怎么用?C# IMethodSymbol.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMethodSymbol
的用法示例。
在下文中一共展示了IMethodSymbol.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsAsyncLibraryConstruct
public void IsAsyncLibraryConstruct(IMethodSymbol symbol)
{
if (symbol.ContainingNamespace.ToString().Equals("System.Threading.Tasks") ||
symbol.ContainingNamespace.ToString().Equals("System.Threading") ||
(symbol.ContainingNamespace.ToString().Equals("System.Linq") && (symbol.ContainingType.ToString().Contains("ParallelQuery") || symbol.ContainingType.ToString().Contains("ParallelEnumerable"))) ||
symbol.ContainingNamespace.ToString().Equals("System.Collections.Concurrent"))
{
if (ConsultingAnalysisResult.libraryUsage.ContainsKey(symbol.ToString()))
ConsultingAnalysisResult.libraryUsage[symbol.ToString()]++;
else
ConsultingAnalysisResult.libraryUsage[symbol.ToString()] = 1;
}
}
示例2: IsSelectingADifferentMethod
private static bool IsSelectingADifferentMethod(IEnumerable<SyntaxNode> childNodes, SimpleNameSyntax methodName, SyntaxTree tree, IMethodSymbol methodSymbol, ExpressionSyntax invocationExpression, Compilation compilation)
{
var parameterExpressions = GetParameterExpressions(childNodes);
var firstArgument = parameterExpressions.FirstOrDefault();
var argumentList = CreateArgumentListSyntaxFrom(parameterExpressions.Skip(1));
var newInvocationStatement = CreateInvocationExpression(firstArgument, methodName, argumentList)
.WithAdditionalAnnotations(introduceExtensionMethodAnnotation);
var extensionMethodNamespaceUsingDirective = SyntaxFactory.UsingDirective(methodSymbol.ContainingNamespace.ToNameSyntax());
var speculativeRootWithExtensionMethod = tree.GetCompilationUnitRoot()
.ReplaceNode(invocationExpression, newInvocationStatement)
.AddUsings(extensionMethodNamespaceUsingDirective);
var speculativeTree = speculativeRootWithExtensionMethod.SyntaxTree;
var speculativeTreeOptions = (CSharpParseOptions)speculativeTree.Options;
var speculativeTreeWithCorrectLanguageVersion = speculativeTree.WithRootAndOptions(speculativeRootWithExtensionMethod, speculativeTreeOptions.WithLanguageVersion(((CSharpParseOptions)tree.Options).LanguageVersion));
var speculativeModel = compilation.ReplaceSyntaxTree(tree, speculativeTreeWithCorrectLanguageVersion)
.GetSemanticModel(speculativeTreeWithCorrectLanguageVersion);
var speculativeInvocationStatement = speculativeTreeWithCorrectLanguageVersion.GetCompilationUnitRoot().GetAnnotatedNodes(introduceExtensionMethodAnnotation).Single() as InvocationExpressionSyntax;
var speculativeExtensionMethodSymbol = speculativeModel.GetSymbolInfo(speculativeInvocationStatement.Expression).Symbol as IMethodSymbol;
var speculativeNonExtensionFormOfTheMethodSymbol = speculativeExtensionMethodSymbol?.GetConstructedReducedFrom();
return speculativeNonExtensionFormOfTheMethodSymbol == null || speculativeNonExtensionFormOfTheMethodSymbol.ToString() != methodSymbol.ToString();//can't compare equality, as speculative symbol might be different
}
示例3: IsAsyncLibraryConstruct
public void IsAsyncLibraryConstruct(IMethodSymbol symbol)
{
if (symbol.ContainingNamespace.ToString().Equals("System.Threading.Tasks") ||
symbol.ContainingNamespace.ToString().Equals("System.Threading") ||
(symbol.ContainingNamespace.ToString().Equals("System.Linq") && (symbol.ContainingType.ToString().Contains("ParallelQuery") || symbol.ContainingType.ToString().Contains("ParallelEnumerable"))) ||
symbol.ContainingNamespace.ToString().Equals("System.Collections.Concurrent"))
{
var libraryUsage = Result.LibraryUsage;
int temp;
string key = symbol.ToString();
libraryUsage.TryGetValue(key, out temp);
libraryUsage[key] = ++temp;
}
}
示例4: Task
public Task(IMethodSymbol symbol, bool step)
{
CheckSignature(symbol);
signature = symbol.ToString();
this.step = step;
}
示例5: CheckSignature
static void CheckSignature(IMethodSymbol symbol)
{
bool hasDuplicateParameters = symbol.Parameters
.GroupBy(p => p.Name, StringComparer.OrdinalIgnoreCase)
.Any(p => p.Count() > 1);
if (!symbol.ReturnsVoid ||
symbol.IsGenericMethod ||
symbol.Parameters.Any(p => p.RefKind != RefKind.None || !TypeConverter.IsSupported(p.Type)) ||
hasDuplicateParameters)
throw new TaskSignatureViolationException(symbol.ToString());
}
示例6: DetectBlockingOperations
private void DetectBlockingOperations(InvocationExpressionSyntax methodCall, IMethodSymbol methodCallSymbol)
{
var methodDeclaration = methodCall.FirstAncestorOrSelf<MethodDeclarationSyntax>();
var replacement = ((IMethodSymbol)methodCallSymbol.OriginalDefinition).DetectSynchronousUsages(SemanticModel);
if (methodDeclaration != null)
{
if (replacement != "None")
{
Logs.TempLog6.Info(@"{0}{1}{2}{3}**********************************************",
Document.FilePath,
System.Environment.NewLine + System.Environment.NewLine + "BLOCKING METHODCALL: " + methodCallSymbol.ToString(),
System.Environment.NewLine + System.Environment.NewLine + "REPLACE IT WITH: " + replacement,
methodDeclaration.ToLog());
}
}
}
示例7: Add
public void Add(IMethodSymbol ms)
{
if (IsLibrary)
return;
FlatArrayBuilder fab = new FlatArrayBuilder();
fab.Add(FlatValue.Int32(ms.IsStatic ? (int)ClassMemberType.StaticMethod : (int)ClassMemberType.Method));
fab.Add(FlatValue.String(ms.GetFullyQualifiedName()));
Function f;
if (!Chunk.Functions.TryGetValue(ms, out f))
{
throw new LS2ILMethodException("Method not found " + ms.ToString());
}
fab.Add(FlatValue.Int32(f.NumFunction));
// input declarations
fab.Add(GenerateInputDeclarations(ms).GetFlatValue());
Members.Add(fab.GetFlatValue());
}