本文整理汇总了C#中InvocationExpressionSyntax.ToFullString方法的典型用法代码示例。如果您正苦于以下问题:C# InvocationExpressionSyntax.ToFullString方法的具体用法?C# InvocationExpressionSyntax.ToFullString怎么用?C# InvocationExpressionSyntax.ToFullString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InvocationExpressionSyntax
的用法示例。
在下文中一共展示了InvocationExpressionSyntax.ToFullString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Go
public static void Go(OutputWriter writer, InvocationExpressionSyntax invocationExpression)
{
var symbolInfo = TypeProcessor.GetSymbolInfo(invocationExpression);
var expressionSymbol = TypeProcessor.GetSymbolInfo(invocationExpression.Expression);
var symbol = symbolInfo.Symbol ?? symbolInfo.CandidateSymbols.FirstOrDefault(); // Resolution error
if (symbol == null)
{
writer.WriteLine("/*" + invocationExpression.ToFullString() +" //SharpNative Failed To Get Symbol */");
}
var methodSymbol = symbol.OriginalDefinition.As<IMethodSymbol>().UnReduce();
var memberReferenceExpressionOpt = invocationExpression.Expression as MemberAccessExpressionSyntax;
var firstParameter = true;
var extensionNamespace = methodSymbol.IsExtensionMethod
? methodSymbol.ContainingNamespace.FullNameWithDot() + methodSymbol.ContainingType.FullName()
: null; //null means it's not an extension method, non-null means it is
string methodName;
string typeParameters = null;
ExpressionSyntax subExpressionOpt;
if (expressionSymbol.Symbol is IEventSymbol)
{
methodName = "Invoke";
}
else if (methodSymbol.MethodKind == MethodKind.DelegateInvoke)
methodName = null;
else
methodName = OverloadResolver.MethodName(methodSymbol);
if (methodSymbol.ContainingType.TypeKind == TypeKind.Interface ||
Equals(methodSymbol.ContainingType.FindImplementationForInterfaceMember(methodSymbol),
methodSymbol))
{
/* methodName =
Regex.Replace(TypeProcessor.ConvertType(methodSymbol.ContainingType.OriginalDefinition)
.RemoveFromStartOfString(methodSymbol.ContainingNamespace + ".Namespace.") + "_" +
methodName,
@" ?!\(.*?\)", string.Empty);*/
if (methodSymbol.ContainingType.ContainingType != null)
methodName = methodName.RemoveFromStartOfString(methodSymbol.ContainingType.ContainingType.Name + ".");
}
var interfaceMethods =
methodSymbol.ContainingType.AllInterfaces.SelectMany(
u =>
u.GetMembers(methodName)).ToArray();
ISymbol interfaceMethod =
interfaceMethods.FirstOrDefault(
o => methodSymbol.ContainingType.FindImplementationForInterfaceMember(o) == methodSymbol);
// if (interfaceMethod == null)
// {
// //TODO: fix this for virtual method test 7, seems roslyn cannot deal with virtual
// // overrides of interface methods ... so i'll provide a kludge
// if (!method.Modifiers.Any(SyntaxKind.NewKeyword))
// interfaceMethod = interfaceMethods.FirstOrDefault(k => CompareMethods(k as IMethodSymbol, methodSymbol));
// }
if (interfaceMethod != null)
// && CompareMethods(interfaceMethod ,methodSymbol)) {
{
//This is an interface method //TO
if (methodSymbol.ContainingType.SpecialType == SpecialType.System_Array)
writer.Write("");
else
{
/* var typenameI =
Regex.Replace(
TypeProcessor.ConvertType(interfaceMethod.ContainingType.ConstructedFrom, true),
@" ?!\(.*?\)", string.Empty);
//TODO: we should be able to get the original interface name, or just remove all generics from this
if (typenameI.Contains('.'))
typenameI = typenameI.SubstringAfterLast('.');
writer.Write(typenameI + "_");*/
}
}
var containingType = interfaceMethod == null ? methodSymbol.ContainingType : interfaceMethod.ContainingType;
bool isVirtualGeneric = methodSymbol.IsGenericMethod &&
(methodSymbol.IsVirtual ||
methodSymbol.ContainingType.TypeKind == TypeKind.Interface)
&& !containingType.IsAssignableFrom(Context.Instance.Type);// !(invocationExpression.Expression is BaseExpressionSyntax);
if (isVirtualGeneric)
methodName = TypeProcessor.ConvertType(containingType,false,false,false).Replace(".", "_") + "_" + methodName;
if (methodSymbol.MethodKind == MethodKind.DelegateInvoke)
subExpressionOpt = invocationExpression.Expression;
else if (memberReferenceExpressionOpt != null)
{
//.........这里部分代码省略.........