本文整理汇总了C#中MethodKind类的典型用法代码示例。如果您正苦于以下问题:C# MethodKind类的具体用法?C# MethodKind怎么用?C# MethodKind使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MethodKind类属于命名空间,在下文中一共展示了MethodKind类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:EkardNT,项目名称:Roslyn,代码行数:32,代码来源:SourceConstructorSymbol.cs
示例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;
}
开发者ID:otawfik-ms,项目名称:roslyn,代码行数:25,代码来源:SignatureOnlyMethodSymbol.cs
示例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;
}
开发者ID:RoryVL,项目名称:roslyn,代码行数:26,代码来源:CodeGenerationMethodSymbol.cs
示例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);
}
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:56,代码来源:SourceMemberMethodSymbol.cs
示例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);
}
开发者ID:GloryChou,项目名称:roslyn,代码行数:11,代码来源:SourceDelegateMethodSymbol.cs
示例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;
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:12,代码来源:CodeAccessorFunction.cs
示例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;
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:18,代码来源:RudeEditTestBase.cs
示例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]);
}
}
开发者ID:EkardNT,项目名称:Roslyn,代码行数:19,代码来源:SourceNamedTypeSymbol_Delegates.cs
示例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;
}
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:21,代码来源:SignatureOnlyMethodSymbol.cs
示例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);
}
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:39,代码来源:SourceConstructorSymbol.cs
示例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);
}
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:9,代码来源:PEMethodSymbol.cs
示例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;
}
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:23,代码来源:PEMethodSymbol.cs
示例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);
}
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:7,代码来源:PEMethodSymbol.cs
示例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);
}
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:9,代码来源:PEMethodSymbol.cs
示例16: TestGlyph
private void TestGlyph(
StandardGlyphGroup expectedGlyphGroup,
SymbolKind kind = SymbolKind.Method,
Accessibility declaredAccessibility = Accessibility.NotApplicable,
bool isExtensionMethod = true,
MethodKind methodKind = MethodKind.Ordinary,
INamedTypeSymbol containingType = null,
bool isConst = false,
ITypeSymbol elementType = null,
INamespaceOrTypeSymbol target = null,
ITypeSymbol pointedAtType = null,
bool isWithEvents = false,
TypeKind typeKind = TypeKind.Unknown)
{
var symbol = CreateSymbolMock(kind, declaredAccessibility, isExtensionMethod, methodKind, containingType, isConst, elementType, target, pointedAtType, isWithEvents, typeKind);
Assert.Equal(expectedGlyphGroup, symbol.GetGlyph().GetStandardGlyphGroup());
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:17,代码来源:ISymbolExtensionsTests.cs
示例17: CreateSymbolMock
private static ISymbol CreateSymbolMock(
SymbolKind kind,
Accessibility declaredAccessibility = Accessibility.NotApplicable,
bool isExtensionMethod = false,
MethodKind methodKind = MethodKind.Ordinary,
INamedTypeSymbol containingType = null,
bool isConst = false,
ITypeSymbol elementType = null,
INamespaceOrTypeSymbol target = null,
ITypeSymbol pointedAtType = null,
bool isWithEvents = false,
TypeKind typeKind = TypeKind.Unknown)
{
var symbolMock = new Mock<ISymbol>();
symbolMock.SetupGet(s => s.Kind).Returns(kind);
symbolMock.SetupGet(s => s.DeclaredAccessibility).Returns(declaredAccessibility);
symbolMock.SetupGet(s => s.ContainingType).Returns(containingType);
if (kind == SymbolKind.ArrayType)
{
var arrayTypeMock = symbolMock.As<IArrayTypeSymbol>();
arrayTypeMock.SetupGet(s => s.ElementType).Returns(elementType);
}
if (kind == SymbolKind.Alias)
{
var aliasMock = symbolMock.As<IAliasSymbol>();
aliasMock.SetupGet(s => s.Target).Returns(target);
}
if (kind == SymbolKind.Method)
{
var methodTypeMock = symbolMock.As<IMethodSymbol>();
methodTypeMock.SetupGet(s => s.MethodKind).Returns(methodKind);
methodTypeMock.SetupGet(s => s.IsExtensionMethod).Returns(isExtensionMethod);
}
if (kind == SymbolKind.NamedType)
{
var namedTypeMock = symbolMock.As<INamedTypeSymbol>();
namedTypeMock.SetupGet(s => s.TypeKind).Returns(typeKind);
}
if (kind == SymbolKind.Field)
{
var fieldMock = symbolMock.As<IFieldSymbol>();
fieldMock.SetupGet(s => s.IsConst).Returns(isConst);
}
if (kind == SymbolKind.PointerType)
{
var pointerTypeMock = symbolMock.As<IPointerTypeSymbol>();
pointerTypeMock.SetupGet(s => s.PointedAtType).Returns(pointedAtType);
}
if (kind == SymbolKind.Property)
{
var propertyMock = symbolMock.As<IPropertySymbol>();
propertyMock.SetupGet(s => s.IsWithEvents).Returns(isWithEvents);
}
return symbolMock.Object;
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:64,代码来源:ISymbolExtensionsTests.cs
示例18: VerifyAccessor
private void VerifyAccessor(MethodSymbol accessor, PEPropertySymbol associatedProperty, MethodKind methodKind)
{
Assert.NotNull(accessor);
Assert.Equal(accessor.AssociatedSymbol, associatedProperty);
Assert.Equal(accessor.MethodKind, methodKind);
if (associatedProperty != null)
{
var method = (methodKind == MethodKind.PropertyGet) ? associatedProperty.GetMethod : associatedProperty.SetMethod;
Assert.Equal(accessor, method);
}
}
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:12,代码来源:PropertyTests.cs
示例19: AddImpliedModifiers
private static DeclarationModifiers AddImpliedModifiers(DeclarationModifiers mods, bool containingTypeIsInterface, MethodKind methodKind)
{
// Let's overwrite modifiers for interface and explicit interface implementation methods with what they are supposed to be.
// Proper errors must have been reported by now.
if (containingTypeIsInterface)
{
mods = (mods & ~DeclarationModifiers.AccessibilityMask) | DeclarationModifiers.Public | DeclarationModifiers.Abstract;
}
else if (methodKind == MethodKind.ExplicitInterfaceImplementation)
{
mods = (mods & ~DeclarationModifiers.AccessibilityMask) | DeclarationModifiers.Private;
}
return mods;
}
开发者ID:jkotas,项目名称:roslyn,代码行数:14,代码来源:SourceMemberMethodSymbol.cs
示例20: MakeMethodBody
internal static BlockSyntax MakeMethodBody(
string bodySource,
ParseOptions options = null,
MethodKind kind = MethodKind.Regular)
{
string source;
switch (kind)
{
case MethodKind.Iterator:
source = "class C { IEnumerable<int> F() { " + bodySource + " } }";
break;
case MethodKind.Async:
source = "class C { async Task<int> F() { " + bodySource + " } }";
break;
case MethodKind.ConstructorWithParameters:
source = "class C { C" + bodySource + " }";
break;
default:
source = "class C { void F() { " + bodySource + " } }";
break;
}
var tree = ParseSource(source, options: options);
var root = tree.GetRoot();
tree.GetDiagnostics().Verify();
var declaration = (BaseMethodDeclarationSyntax)((ClassDeclarationSyntax)((CompilationUnitSyntax)root).Members[0]).Members[0];
// We need to preserve the parent node to allow detection of state machine methods in the analyzer.
// If we are not testing a state machine method we only use the body to avoid updating positions in all existing tests.
if (kind != MethodKind.Regular)
{
return ((BaseMethodDeclarationSyntax)SyntaxFactory.SyntaxTree(declaration).GetRoot()).Body;
}
return (BlockSyntax)SyntaxFactory.SyntaxTree(declaration.Body).GetRoot();
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:41,代码来源:RudeEditTestBase.cs
注:本文中的MethodKind类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论