本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol.InferExtensionMethodTypeArguments方法的典型用法代码示例。如果您正苦于以下问题:C# MethodSymbol.InferExtensionMethodTypeArguments方法的具体用法?C# MethodSymbol.InferExtensionMethodTypeArguments怎么用?C# MethodSymbol.InferExtensionMethodTypeArguments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol
的用法示例。
在下文中一共展示了MethodSymbol.InferExtensionMethodTypeArguments方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
/// <summary>
/// Return the extension method in reduced form if the extension method
/// is applicable, and satisfies type parameter constraints, based on the
/// "this" argument type. Otherwise, returns null.
/// </summary>
public static MethodSymbol Create(MethodSymbol method, TypeSymbol receiverType, Compilation compilation)
{
Debug.Assert(method.IsExtensionMethod && method.MethodKind != MethodKind.ReducedExtension);
Debug.Assert(method.ParameterCount > 0);
Debug.Assert((object)receiverType != null);
HashSet<DiagnosticInfo> useSiteDiagnostics = null;
method = method.InferExtensionMethodTypeArguments(receiverType, compilation, ref useSiteDiagnostics);
if ((object)method == null)
{
return null;
}
var conversions = new TypeConversions(method.ContainingAssembly.CorLibrary);
var conversion = conversions.ConvertExtensionMethodThisArg(method.Parameters[0].Type, receiverType, ref useSiteDiagnostics);
if (!conversion.Exists)
{
return null;
}
if (useSiteDiagnostics != null)
{
foreach (var diag in useSiteDiagnostics)
{
if (diag.Severity == DiagnosticSeverity.Error)
{
return null;
}
}
}
return Create(method);
}