本文整理汇总了C#中DeclarationModifiers类的典型用法代码示例。如果您正苦于以下问题:C# DeclarationModifiers类的具体用法?C# DeclarationModifiers怎么用?C# DeclarationModifiers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DeclarationModifiers类属于命名空间,在下文中一共展示了DeclarationModifiers类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateMethod
private ISymbol GenerateMethod(
Compilation compilation,
IMethodSymbol method,
Accessibility accessibility,
DeclarationModifiers modifiers,
bool generateAbstractly,
bool useExplicitInterfaceSymbol,
string memberName,
CancellationToken cancellationToken)
{
var syntaxFacts = this.Document.GetLanguageService<ISyntaxFactsService>();
var updatedMethod = method.EnsureNonConflictingNames(
this.State.ClassOrStructType, syntaxFacts, cancellationToken);
updatedMethod = updatedMethod.RemoveInaccessibleAttributesAndAttributesOfTypes(
this.State.ClassOrStructType,
AttributesToRemove(compilation));
return CodeGenerationSymbolFactory.CreateMethodSymbol(
updatedMethod,
accessibility: accessibility,
modifiers: modifiers,
explicitInterfaceSymbol: useExplicitInterfaceSymbol ? updatedMethod : null,
name: memberName,
statements: generateAbstractly ? null : new[] { CreateStatement(compilation, updatedMethod, cancellationToken) });
}
示例2: CreatePropertySymbol
internal static IPropertySymbol CreatePropertySymbol(
INamedTypeSymbol containingType,
IList<AttributeData> attributes,
Accessibility accessibility,
DeclarationModifiers modifiers,
ITypeSymbol type,
IPropertySymbol explicitInterfaceSymbol,
string name,
IList<IParameterSymbol> parameters,
IMethodSymbol getMethod,
IMethodSymbol setMethod,
bool isIndexer = false,
SyntaxNode initializer = null)
{
var result = new CodeGenerationPropertySymbol(
containingType,
attributes,
accessibility,
modifiers,
type,
explicitInterfaceSymbol,
name,
isIndexer,
parameters,
getMethod,
setMethod);
CodeGenerationPropertyInfo.Attach(result, modifiers.IsNew, modifiers.IsUnsafe, initializer);
return result;
}
示例3: SourceMemberFieldSymbol
internal SourceMemberFieldSymbol(
SourceMemberContainerTypeSymbol containingType,
VariableDeclaratorSyntax declarator,
DeclarationModifiers modifiers,
bool modifierErrors,
DiagnosticBag diagnostics)
: base(containingType, declarator.Identifier.ValueText, declarator.GetReference(), declarator.Identifier.GetLocation())
{
this.modifiers = modifiers;
this.CheckAccessibility(diagnostics);
var location = Location;
if (modifierErrors)
{
// skip the following checks
}
else if (containingType.IsSealed && (DeclaredAccessibility == Accessibility.Protected || DeclaredAccessibility == Accessibility.ProtectedOrInternal))
{
diagnostics.Add(AccessCheck.GetProtectedMemberInSealedTypeError(containingType), location, this);
}
else if (IsVolatile && IsReadOnly)
{
diagnostics.Add(ErrorCode.ERR_VolatileAndReadonly, location, this);
}
else if (containingType.IsStatic && !IsStatic)
{
diagnostics.Add(ErrorCode.ERR_InstanceMemberInStaticClass, location, this);
}
// TODO: Consider checking presence of core type System.Runtime.CompilerServices.IsVolatile
// if there is a volatile modifier. Perhaps an appropriate error should be reported if the
// type isn’t available.
}
示例4: CreateAccessorSymbol
public static SourcePropertyAccessorSymbol CreateAccessorSymbol(
NamedTypeSymbol containingType,
SourcePropertySymbol property,
DeclarationModifiers propertyModifiers,
string propertyName,
ArrowExpressionClauseSyntax syntax,
PropertySymbol explicitlyImplementedPropertyOpt,
string aliasQualifierOpt,
DiagnosticBag diagnostics)
{
string name;
ImmutableArray<MethodSymbol> explicitInterfaceImplementations;
GetNameAndExplicitInterfaceImplementations(
explicitlyImplementedPropertyOpt,
propertyName,
property.IsCompilationOutputWinMdObj(),
aliasQualifierOpt,
isGetMethod: true,
name: out name,
explicitInterfaceImplementations:
out explicitInterfaceImplementations);
return new SourcePropertyAccessorSymbol(
containingType,
name,
property,
propertyModifiers,
explicitInterfaceImplementations,
syntax.Expression.GetLocation(),
syntax,
diagnostics);
}
示例5: Create
public static CompletionItem Create(
string displayText,
TextSpan span,
Glyph? glyph,
DeclarationModifiers modifiers,
int line,
ISymbol symbol,
SyntaxToken token,
int descriptionPosition,
CompletionItemRules rules)
{
var props = ImmutableDictionary<string, string>.Empty
.Add("Line", line.ToString())
.Add("Modifiers", modifiers.ToString())
.Add("TokenSpanEnd", token.Span.End.ToString());
return SymbolCompletionItem.Create(
displayText: displayText,
span: span,
symbol: symbol,
glyph: glyph,
descriptionPosition: descriptionPosition,
properties: props,
rules: rules);
}
示例6: CodeGenerationNamedTypeSymbol
public CodeGenerationNamedTypeSymbol(
INamedTypeSymbol containingType,
IList<AttributeData> attributes,
Accessibility declaredAccessibility,
DeclarationModifiers modifiers,
TypeKind typeKind,
string name,
IList<ITypeParameterSymbol> typeParameters,
INamedTypeSymbol baseType,
IList<INamedTypeSymbol> interfaces,
SpecialType specialType,
IList<ISymbol> members,
IList<CodeGenerationAbstractNamedTypeSymbol> typeMembers,
INamedTypeSymbol enumUnderlyingType)
: base(containingType, attributes, declaredAccessibility, modifiers, name, specialType, typeMembers)
{
_typeKind = typeKind;
_typeParameters = typeParameters ?? SpecializedCollections.EmptyList<ITypeParameterSymbol>();
_baseType = baseType;
_interfaces = interfaces ?? SpecializedCollections.EmptyList<INamedTypeSymbol>();
_members = members ?? SpecializedCollections.EmptyList<ISymbol>();
_enumUnderlyingType = enumUnderlyingType;
this.OriginalDefinition = this;
}
示例7: GenerateMember
private ISymbol GenerateMember(
ISymbol member,
bool addUnsafe,
CancellationToken cancellationToken)
{
var modifiers = new DeclarationModifiers(isOverride: true, isUnsafe: addUnsafe);
var accessibility = member.ComputeResultantAccessibility(_state.ClassType);
if (member.Kind == SymbolKind.Method)
{
return GenerateMethod((IMethodSymbol)member, modifiers, accessibility, cancellationToken);
}
else if (member.Kind == SymbolKind.Property)
{
return GenerateProperty((IPropertySymbol)member, modifiers, accessibility, cancellationToken);
}
else if (member.Kind == SymbolKind.Event)
{
var @event = (IEventSymbol)member;
return CodeGenerationSymbolFactory.CreateEventSymbol(
@event,
accessibility: accessibility,
modifiers: modifiers);
}
return null;
}
示例8: 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;
}
示例9: CheckModifiers
internal static DeclarationModifiers CheckModifiers(
DeclarationModifiers modifiers,
DeclarationModifiers allowedModifiers,
Location errorLocation,
DiagnosticBag diagnostics,
out bool modifierErrors)
{
modifierErrors = false;
DeclarationModifiers errorModifiers = modifiers & ~allowedModifiers;
DeclarationModifiers result = modifiers & allowedModifiers;
while (errorModifiers != DeclarationModifiers.None)
{
DeclarationModifiers oneError = errorModifiers & ~(errorModifiers - 1);
Debug.Assert(oneError != DeclarationModifiers.None);
errorModifiers = errorModifiers & ~oneError;
switch (oneError)
{
case DeclarationModifiers.Partial:
diagnostics.Add(ErrorCode.ERR_PartialMethodOnlyMethods, errorLocation);
break;
default:
diagnostics.Add(ErrorCode.ERR_BadMemberFlag, errorLocation, ConvertSingleModifierToSyntaxText(oneError));
break;
}
modifierErrors = true;
}
bool isMethod = (allowedModifiers & (DeclarationModifiers.Partial | DeclarationModifiers.Virtual)) == (DeclarationModifiers.Partial | DeclarationModifiers.Virtual);
if (isMethod && ((result & (DeclarationModifiers.Partial | DeclarationModifiers.Private)) == (DeclarationModifiers.Partial | DeclarationModifiers.Private)))
{
diagnostics.Add(ErrorCode.ERR_PartialMethodInvalidModifier, errorLocation);
}
return result;
}
示例10: LocalFunctionSymbol
public LocalFunctionSymbol(
Binder binder,
Symbol containingSymbol,
LocalFunctionStatementSyntax syntax)
{
_syntax = syntax;
_containingSymbol = containingSymbol;
_declarationModifiers =
DeclarationModifiers.Private |
DeclarationModifiers.Static |
syntax.Modifiers.ToDeclarationModifiers();
var diagnostics = DiagnosticBag.GetInstance();
if (_syntax.TypeParameterList != null)
{
binder = new WithMethodTypeParametersBinder(this, binder);
_typeParameters = MakeTypeParameters(diagnostics);
}
else
{
_typeParameters = ImmutableArray<TypeParameterSymbol>.Empty;
}
if (IsExtensionMethod)
{
diagnostics.Add(ErrorCode.ERR_BadExtensionAgg, Locations[0]);
}
_binder = binder;
_refKind = (syntax.ReturnType.Kind() == SyntaxKind.RefType) ? RefKind.Ref : RefKind.None;
_diagnostics = diagnostics.ToReadOnlyAndFree();
}
示例11: CodeGenerationNamespaceOrTypeSymbol
protected CodeGenerationNamespaceOrTypeSymbol(
INamedTypeSymbol containingType,
IList<AttributeData> attributes,
Accessibility declaredAccessibility,
DeclarationModifiers modifiers,
string name)
: base(containingType, attributes, declaredAccessibility, modifiers, name)
{
}
示例12: CreateEventSymbol
/// <summary>
/// Creates an event symbol that can be used to describe an event declaration.
/// </summary>
public static IEventSymbol CreateEventSymbol(
IList<AttributeData> attributes, Accessibility accessibility,
DeclarationModifiers modifiers, ITypeSymbol type,
IEventSymbol explicitInterfaceSymbol, string name,
IMethodSymbol addMethod = null, IMethodSymbol removeMethod = null, IMethodSymbol raiseMethod = null)
{
var result = new CodeGenerationEventSymbol(null, attributes, accessibility, modifiers, type, explicitInterfaceSymbol, name, addMethod, removeMethod, raiseMethod);
CodeGenerationEventInfo.Attach(result, modifiers.IsUnsafe);
return result;
}
示例13: SourceMemberFieldSymbol
internal SourceMemberFieldSymbol(
SourceMemberContainerTypeSymbol containingType,
DeclarationModifiers modifiers,
string name,
SyntaxReference syntax,
Location location)
: base(containingType, name, syntax, location)
{
_modifiers = modifiers;
}
示例14: 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);
}
示例15: CodeGenerationTypeSymbol
protected CodeGenerationTypeSymbol(
INamedTypeSymbol containingType,
IList<AttributeData> attributes,
Accessibility declaredAccessibility,
DeclarationModifiers modifiers,
string name,
SpecialType specialType)
: base(containingType, attributes, declaredAccessibility, modifiers, name)
{
this.SpecialType = specialType;
}