本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Syntax.MethodDeclarationSyntax.GetReference方法的典型用法代码示例。如果您正苦于以下问题:C# MethodDeclarationSyntax.GetReference方法的具体用法?C# MethodDeclarationSyntax.GetReference怎么用?C# MethodDeclarationSyntax.GetReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Syntax.MethodDeclarationSyntax
的用法示例。
在下文中一共展示了MethodDeclarationSyntax.GetReference方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SourceMemberMethodSymbol
private SourceMemberMethodSymbol(
NamedTypeSymbol containingType,
TypeSymbol explicitInterfaceType,
string name,
Location location,
MethodDeclarationSyntax syntax,
MethodKind methodKind,
DiagnosticBag diagnostics) :
base(containingType,
syntax.GetReference(),
// Prefer a block body if both exist
syntax.Body?.GetReference() ?? syntax.ExpressionBody?.GetReference(),
location)
{
_name = name;
_explicitInterfaceType = explicitInterfaceType;
SyntaxTokenList modifiers = syntax.Modifiers;
// The following two values are used to compute and store the initial value of the flags
// However, these two components are placeholders; the correct value will be
// computed lazily later and then the flags will be fixed up.
const bool returnsVoid = false;
var firstParam = syntax.ParameterList.Parameters.FirstOrDefault();
bool isExtensionMethod = firstParam != null &&
!firstParam.IsArgList &&
firstParam.Modifiers.Any(SyntaxKind.ThisKeyword);
bool modifierErrors;
var declarationModifiers = this.MakeModifiers(modifiers, methodKind, location, diagnostics, out modifierErrors);
var isMetadataVirtualIgnoringModifiers = (object)explicitInterfaceType != null; //explicit impls must be marked metadata virtual
this.MakeFlags(methodKind, declarationModifiers, returnsVoid, isExtensionMethod, isMetadataVirtualIgnoringModifiers);
_typeParameters = (syntax.Arity == 0) ?
ImmutableArray<TypeParameterSymbol>.Empty :
MakeTypeParameters(syntax, diagnostics);
bool hasBlockBody = syntax.Body != null;
_isExpressionBodied = !hasBlockBody && syntax.ExpressionBody != null;
if (hasBlockBody || _isExpressionBodied)
{
CheckModifiersForBody(location, diagnostics);
}
_refKind = syntax.RefKeyword.Kind().GetRefKind();
var info = ModifierUtils.CheckAccessibility(this.DeclarationModifiers);
if (info != null)
{
diagnostics.Add(info, location);
}
}
示例2: SourceMemberMethodSymbol
private SourceMemberMethodSymbol(
NamedTypeSymbol containingType,
TypeSymbol explicitInterfaceType,
string name,
Location location,
Binder bodyBinder,
MethodDeclarationSyntax syntax,
MethodKind methodKind,
DiagnosticBag diagnostics) :
base(containingType,
syntax.GetReference(),
// Prefer a block body if both exist
syntax.Body?.GetReference() ?? syntax.ExpressionBody?.GetReference(),
location)
{
_name = name;
_explicitInterfaceType = explicitInterfaceType;
SyntaxTokenList modifiers = syntax.Modifiers;
// The following two values are used to compute and store the initial value of the flags
// However, these two components are placeholders; the correct value will be
// computed lazily later and then the flags will be fixed up.
const bool returnsVoid = false;
var firstParam = syntax.ParameterList.Parameters.FirstOrDefault();
bool isExtensionMethod = firstParam != null &&
!firstParam.IsArgList &&
firstParam.Modifiers.Any(SyntaxKind.ThisKeyword);
bool modifierErrors;
var declarationModifiers = this.MakeModifiers(modifiers, methodKind, location, diagnostics, out modifierErrors);
var isMetadataVirtualIgnoringModifiers = (object)explicitInterfaceType != null; //explicit impls must be marked metadata virtual
this.MakeFlags(methodKind, declarationModifiers, returnsVoid, isExtensionMethod, isMetadataVirtualIgnoringModifiers);
// NOTE: by creating a WithMethodTypeParametersBinder, we are effectively duplicating the
// functionality of the BinderFactory. Unfortunately, we cannot use the BinderFactory
// because it depends on having access to the member list of our containing type and
// that list cannot be complete because we're not finished constructing this member.
// TODO: at least keep this in sync with BinderFactory.VisitMethodDeclaration.
bodyBinder = bodyBinder.WithUnsafeRegionIfNecessary(modifiers);
Binder withTypeParamsBinder;
if (syntax.Arity == 0)
{
withTypeParamsBinder = bodyBinder;
_typeParameters = ImmutableArray<TypeParameterSymbol>.Empty;
}
else
{
var parameterBinder = new WithMethodTypeParametersBinder(this, bodyBinder);
withTypeParamsBinder = parameterBinder;
_typeParameters = MakeTypeParameters(syntax, diagnostics);
}
bool hasBlockBody = syntax.Body != null;
_isExpressionBodied = !hasBlockBody && syntax.ExpressionBody != null;
if (hasBlockBody || _isExpressionBodied)
{
CheckModifiersForBody(location, diagnostics);
}
var info = ModifierUtils.CheckAccessibility(this.DeclarationModifiers);
if (info != null)
{
diagnostics.Add(info, location);
}
if (this.IsPartial)
{
// Partial methods must be completed early because they are matched up
// by signature while producing the enclosing type's member list. However,
// that means any type parameter constraints will be bound before the method
// is added to the containing type. To enable binding of constraints before the
// .ctor completes we hold on to the current binder while the .ctor is executing.
// If we change the handling of partial methods, so that partial methods are
// completed lazily, the 'constraintClauseBinder' field should be removed.
_constraintClauseBinder = withTypeParamsBinder;
state.NotePartComplete(CompletionPart.StartMethodChecks);
MethodChecks(syntax, withTypeParamsBinder, diagnostics);
state.NotePartComplete(CompletionPart.FinishMethodChecks);
_constraintClauseBinder = null;
}
}