本文整理汇总了C#中MethodKind类的典型用法代码示例。如果您正苦于以下问题:C# MethodKind类的具体用法?C# MethodKind怎么用?C# MethodKind使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MethodKind类属于命名空间,在下文中一共展示了MethodKind类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SourceConstructorSymbol
private SourceConstructorSymbol(
SourceMemberContainerTypeSymbol containingType,
Location location,
ConstructorDeclarationSyntax syntax,
MethodKind methodKind,
DiagnosticBag diagnostics) :
base(containingType, syntax.GetReference(), syntax.Body.GetReferenceOrNull(), ImmutableArray.Create(location))
{
bool modifierErrors;
var declarationModifiers = this.MakeModifiers(syntax.Modifiers, methodKind, location, diagnostics, out modifierErrors);
this.flags = MakeFlags(methodKind, declarationModifiers, returnsVoid: true, isExtensionMethod: false);
var bodyOpt = syntax.Body;
if (bodyOpt != null)
{
if (IsExtern)
{
diagnostics.Add(ErrorCode.ERR_ExternHasBody, location, this);
}
}
var info = ModifierUtils.CheckAccessibility(this.DeclarationModifiers);
if (info != null)
{
diagnostics.Add(info, location);
}
if (!modifierErrors)
{
this.CheckModifiers(methodKind, location, diagnostics);
}
}
示例2: SignatureOnlyMethodSymbol
public SignatureOnlyMethodSymbol(
string name,
TypeSymbol containingType,
MethodKind methodKind,
Cci.CallingConvention callingConvention,
ImmutableArray<TypeParameterSymbol> typeParameters,
ImmutableArray<ParameterSymbol> parameters,
RefKind refKind,
TypeSymbol returnType,
ImmutableArray<CustomModifier> returnTypeCustomModifiers,
ushort countOfCustomModifiersPrecedingByRef,
ImmutableArray<MethodSymbol> explicitInterfaceImplementations)
{
_callingConvention = callingConvention;
_typeParameters = typeParameters;
_refKind = refKind;
_returnType = returnType;
_returnTypeCustomModifiers = returnTypeCustomModifiers;
_countOfCustomModifiersPrecedingByRef = countOfCustomModifiersPrecedingByRef;
_parameters = parameters;
_explicitInterfaceImplementations = explicitInterfaceImplementations.NullToEmpty();
_containingType = containingType;
_methodKind = methodKind;
_name = name;
}
示例3: CodeGenerationMethodSymbol
public CodeGenerationMethodSymbol(
INamedTypeSymbol containingType,
IList<AttributeData> attributes,
Accessibility declaredAccessibility,
DeclarationModifiers modifiers,
ITypeSymbol returnType,
bool returnsByRef,
IMethodSymbol explicitInterfaceSymbolOpt,
string name,
IList<ITypeParameterSymbol> typeParameters,
IList<IParameterSymbol> parameters,
IList<AttributeData> returnTypeAttributes,
MethodKind methodKind = MethodKind.Ordinary)
: base(containingType, attributes, declaredAccessibility, modifiers, name, returnTypeAttributes)
{
_returnType = returnType;
_returnsByRef = returnsByRef;
_typeParameters = typeParameters.AsImmutableOrEmpty();
_parameters = parameters.AsImmutableOrEmpty();
_explicitInterfaceImplementations = explicitInterfaceSymbolOpt == null
? ImmutableArray.Create<IMethodSymbol>()
: ImmutableArray.Create(explicitInterfaceSymbolOpt);
this.OriginalDefinition = this;
_methodKind = methodKind;
}
示例4: 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);
}
}
示例5: SourceDelegateMethodSymbol
protected SourceDelegateMethodSymbol(
SourceMemberContainerTypeSymbol delegateType,
TypeSymbol returnType,
DelegateDeclarationSyntax syntax,
MethodKind methodKind,
DeclarationModifiers declarationModifiers)
: base(delegateType, syntax.GetReference(), bodySyntaxReferenceOpt: null, location: syntax.Identifier.GetLocation())
{
_returnType = returnType;
this.MakeFlags(methodKind, declarationModifiers, _returnType.SpecialType == SpecialType.System_Void, isExtensionMethod: false);
}
示例6: CodeAccessorFunction
private CodeAccessorFunction(CodeModelState state, AbstractCodeMember parent, MethodKind kind)
: base(state, parent.FileCodeModel)
{
Debug.Assert(kind == MethodKind.EventAdd ||
kind == MethodKind.EventRaise ||
kind == MethodKind.EventRemove ||
kind == MethodKind.PropertyGet ||
kind == MethodKind.PropertySet);
_parentHandle = new ParentHandle<AbstractCodeMember>(parent);
_kind = kind;
}
示例7: GetMethodMatch
internal static Match<SyntaxNode> GetMethodMatch(string src1, string src2, ParseOptions options = null, MethodKind kind = MethodKind.Regular)
{
var m1 = MakeMethodBody(src1, options, kind);
var m2 = MakeMethodBody(src2, options, kind);
var diagnostics = new List<RudeEditDiagnostic>();
var match = Analyzer.ComputeBodyMatch(m1, m2, Array.Empty<AbstractEditAndContinueAnalyzer.ActiveNode>(), diagnostics, out var oldHasStateMachineSuspensionPoint, out var newHasStateMachineSuspensionPoint);
bool needsSyntaxMap = oldHasStateMachineSuspensionPoint && newHasStateMachineSuspensionPoint;
Assert.Equal(kind != MethodKind.Regular && kind != MethodKind.ConstructorWithParameters, needsSyntaxMap);
if (kind == MethodKind.Regular || kind == MethodKind.ConstructorWithParameters)
{
Assert.Empty(diagnostics);
}
return match;
}
示例8: DelegateMethodSymbol
protected DelegateMethodSymbol(
SourceNamedTypeSymbol containingType,
DelegateDeclarationSyntax syntax,
MethodKind methodKind,
DeclarationModifiers declarationModifiers,
Binder binder,
DiagnosticBag diagnostics)
: base(containingType, binder.GetSyntaxReference(syntax), blockSyntaxReference: null, location: binder.Location(syntax.Identifier))
{
this.parameters = MakeParameters(binder, syntax, diagnostics);
this.returnType = MakeReturnType(binder, syntax, diagnostics);
this.flags = MakeFlags(methodKind, declarationModifiers, this.returnType.SpecialType == SpecialType.System_Void, isExtensionMethod: false);
var info = ModifierUtils.CheckAccessibility(this.DeclarationModifiers);
if (info != null)
{
diagnostics.Add(info, this.locations[0]);
}
}
示例9: SignatureOnlyMethodSymbol
public SignatureOnlyMethodSymbol(
string name,
TypeSymbol containingType,
MethodKind methodKind,
Cci.CallingConvention callingConvention,
ImmutableArray<TypeParameterSymbol> typeParameters,
ImmutableArray<ParameterSymbol> parameters,
TypeSymbol returnType,
ImmutableArray<CustomModifier> returnTypeCustomModifiers,
ImmutableArray<MethodSymbol> explicitInterfaceImplementations)
{
this.callingConvention = callingConvention;
this.typeParameters = typeParameters;
this.returnType = returnType;
this.returnTypeCustomModifiers = returnTypeCustomModifiers;
this.parameters = parameters;
this.explicitInterfaceImplementations = explicitInterfaceImplementations.NullToEmpty();
this.containingType = containingType;
this.methodKind = methodKind;
this.name = name;
}
示例10: SourceConstructorSymbol
private SourceConstructorSymbol(
SourceMemberContainerTypeSymbol containingType,
Location location,
ConstructorDeclarationSyntax syntax,
MethodKind methodKind,
DiagnosticBag diagnostics) :
base(containingType, syntax.GetReference(), syntax.Body?.GetReference() ?? syntax.ExpressionBody?.GetReference(), ImmutableArray.Create(location))
{
bool modifierErrors;
var declarationModifiers = this.MakeModifiers(syntax.Modifiers, methodKind, location, diagnostics, out modifierErrors);
this.MakeFlags(methodKind, declarationModifiers, returnsVoid: true, isExtensionMethod: false);
bool hasBlockBody = syntax.Body != null;
_isExpressionBodied = !hasBlockBody && syntax.ExpressionBody != null;
if (IsExtern)
{
if (methodKind == MethodKind.Constructor && syntax.Initializer != null)
{
diagnostics.Add(ErrorCode.ERR_ExternHasConstructorInitializer, location, this);
}
if (hasBlockBody || _isExpressionBodied)
{
diagnostics.Add(ErrorCode.ERR_ExternHasBody, location, this);
}
}
var info = ModifierUtils.CheckAccessibility(this.DeclarationModifiers);
if (info != null)
{
diagnostics.Add(info, location);
}
if (!modifierErrors)
{
this.CheckModifiers(methodKind, location, diagnostics);
}
}
示例11: DelegateMethodSymbol
protected DelegateMethodSymbol(
SourceNamedTypeSymbol containingType,
string name,
DelegateDeclarationSyntax syntax,
MethodKind methodKind,
DeclarationModifiers declarationModifiers,
Binder binder,
DiagnosticBag diagnostics,
CancellationToken cancellationToken)
: base(containingType, name, binder.GetSyntaxReference(syntax), blockSyntax: null, location: binder.Location(syntax.Identifier))
{
var location = this.locations[0];
bool isExtensionMethod;
this.parameters = MakeParameters(binder, syntax, out isExtensionMethod, out this.isVararg, diagnostics, cancellationToken);
this.returnType = MakeReturnType(binder, syntax, diagnostics);
this.flags = MakeFlags(methodKind, declarationModifiers, IsVoidType(this.returnType), isExtensionMethod: isExtensionMethod);
var info = ModifierUtils.CheckAccessibility(this.DeclarationModifiers);
if (info != null)
{
diagnostics.Add(info, location);
}
}
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:24,代码来源:SourceNamedTypeSymbol.DelegateMethodSymbol.cs
示例12: SetAssociatedEvent
/// <summary>
/// Associate the method with a particular event. Returns
/// false if the method is already associated with a property or event.
/// </summary>
internal bool SetAssociatedEvent(PEEventSymbol eventSymbol, MethodKind methodKind)
{
Debug.Assert((methodKind == MethodKind.EventAdd) || (methodKind == MethodKind.EventRemove));
return this.SetAssociatedPropertyOrEvent(eventSymbol, methodKind);
}
示例13: SetAssociatedPropertyOrEvent
private bool SetAssociatedPropertyOrEvent(Symbol propertyOrEventSymbol, MethodKind methodKind)
{
if ((object)_associatedPropertyOrEventOpt == null)
{
Debug.Assert(propertyOrEventSymbol.ContainingType == _containingType);
// No locking required since SetAssociatedProperty/SetAssociatedEvent will only be called
// by the thread that created the method symbol (and will be called before the method
// symbol is added to the containing type members and available to other threads).
_associatedPropertyOrEventOpt = propertyOrEventSymbol;
// NOTE: may be overwriting an existing value.
Debug.Assert(
_packedFlags.MethodKind == default(MethodKind) ||
_packedFlags.MethodKind == MethodKind.Ordinary ||
_packedFlags.MethodKind == MethodKind.ExplicitInterfaceImplementation);
_packedFlags.MethodKind = methodKind;
return true;
}
return false;
}
示例14: InitializeMethodKind
public void InitializeMethodKind(MethodKind methodKind)
{
Debug.Assert((int)methodKind == ((int)methodKind & MethodKindMask));
int bitsToSet = (((int)methodKind & MethodKindMask) << MethodKindOffset) | MethodKindIsPopulatedBit;
Debug.Assert(BitsAreUnsetOrSame(_bits, bitsToSet));
ThreadSafeFlagOperations.Set(ref _bits, bitsToSet);
}
示例15: SetAssociatedProperty
/// <summary>
/// Associate the method with a particular property. Returns
/// false if the method is already associated with a property or event.
/// </summary>
internal bool SetAssociatedProperty(PEPropertySymbol propertySymbol, MethodKind methodKind)
{
Debug.Assert((methodKind == MethodKind.PropertyGet) || (methodKind == MethodKind.PropertySet));
return this.SetAssociatedPropertyOrEvent(propertySymbol, methodKind);
}