本文整理汇总了C#中DeclarationModifiers类的典型用法代码示例。如果您正苦于以下问题:C# DeclarationModifiers类的具体用法?C# DeclarationModifiers怎么用?C# DeclarationModifiers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DeclarationModifiers类属于命名空间,在下文中一共展示了DeclarationModifiers类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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) });
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:27,代码来源:AbstractImplementInterfaceService.CodeAction_Method.cs
示例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;
}
开发者ID:RoryVL,项目名称:roslyn,代码行数:29,代码来源:CodeGenerationSymbolFactory.cs
示例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.
}
开发者ID:riversky,项目名称:roslyn,代码行数:34,代码来源:SourceMemberFieldSymbol.cs
示例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);
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:32,代码来源:SourcePropertyAccessorSymbol.cs
示例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);
}
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:25,代码来源:MemberInsertingCompletionItem.cs
示例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;
}
开发者ID:RoryVL,项目名称:roslyn,代码行数:25,代码来源:CodeGenerationNamedTypeSymbol.cs
示例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;
}
开发者ID:GloryChou,项目名称:roslyn,代码行数:27,代码来源:AbstractImplementAbstractClassService.Editor.cs
示例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;
}
开发者ID:RoryVL,项目名称:roslyn,代码行数:26,代码来源:CodeGenerationMethodSymbol.cs
示例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;
}
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:35,代码来源:ModifierUtils.cs
示例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();
}
开发者ID:jkotas,项目名称:roslyn,代码行数:34,代码来源:LocalFunctionSymbol.cs
示例11: CodeGenerationNamespaceOrTypeSymbol
protected CodeGenerationNamespaceOrTypeSymbol(
INamedTypeSymbol containingType,
IList<AttributeData> attributes,
Accessibility declaredAccessibility,
DeclarationModifiers modifiers,
string name)
: base(containingType, attributes, declaredAccessibility, modifiers, name)
{
}
开发者ID:RoryVL,项目名称:roslyn,代码行数:9,代码来源:CodeGenerationNamespaceOrTypeSymbol.cs
示例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;
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:13,代码来源:CodeGenerationSymbolFactory.cs
示例13: SourceMemberFieldSymbol
internal SourceMemberFieldSymbol(
SourceMemberContainerTypeSymbol containingType,
DeclarationModifiers modifiers,
string name,
SyntaxReference syntax,
Location location)
: base(containingType, name, syntax, location)
{
_modifiers = modifiers;
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:10,代码来源:SourceMemberFieldSymbol.cs
示例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);
}
开发者ID:GloryChou,项目名称:roslyn,代码行数:11,代码来源:SourceDelegateMethodSymbol.cs
示例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;
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:11,代码来源:CodeGenerationTypeSymbol.cs
示例16: GenerateProperty
private ISymbol GenerateProperty(
Compilation compilation,
IPropertySymbol property,
Accessibility accessibility,
DeclarationModifiers modifiers,
bool generateAbstractly,
bool useExplicitInterfaceSymbol,
string memberName,
CancellationToken cancellationToken)
{
var factory = this.Document.GetLanguageService<SyntaxGenerator>();
var comAliasNameAttribute = compilation.ComAliasNameAttributeType();
var getAccessor = property.GetMethod == null
? null
: CodeGenerationSymbolFactory.CreateAccessorSymbol(
property.GetMethod.RemoveInaccessibleAttributesAndAttributesOfType(
accessibleWithin: this.State.ClassOrStructType,
removeAttributeType: comAliasNameAttribute),
attributes: null,
accessibility: accessibility,
explicitInterfaceSymbol: useExplicitInterfaceSymbol ? property.GetMethod : null,
statements: GetGetAccessorStatements(compilation, property, generateAbstractly, cancellationToken));
var setAccessor = property.SetMethod == null
? null
: CodeGenerationSymbolFactory.CreateAccessorSymbol(
property.SetMethod.RemoveInaccessibleAttributesAndAttributesOfType(
accessibleWithin: this.State.ClassOrStructType,
removeAttributeType: comAliasNameAttribute),
attributes: null,
accessibility: accessibility,
explicitInterfaceSymbol: useExplicitInterfaceSymbol ? property.SetMethod : null,
statements: GetSetAccessorStatements(compilation, property, generateAbstractly, cancellationToken));
var syntaxFacts = Document.GetLanguageService<ISyntaxFactsService>();
var parameterNames = NameGenerator.EnsureUniqueness(
property.Parameters.Select(p => p.Name).ToList(), isCaseSensitive: syntaxFacts.IsCaseSensitive);
var updatedProperty = property.RenameParameters(parameterNames);
updatedProperty = updatedProperty.RemoveAttributeFromParameters(comAliasNameAttribute);
// TODO(cyrusn): Delegate through throughMember if it's non-null.
return CodeGenerationSymbolFactory.CreatePropertySymbol(
updatedProperty,
accessibility: accessibility,
modifiers: modifiers,
explicitInterfaceSymbol: useExplicitInterfaceSymbol ? property : null,
name: memberName,
getMethod: getAccessor,
setMethod: setAccessor);
}
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:53,代码来源:AbstractImplementInterfaceService.CodeAction_Property.cs
示例17: SourceFixedFieldSymbol
internal SourceFixedFieldSymbol(
SourceMemberContainerTypeSymbol containingType,
VariableDeclaratorSyntax declarator,
DeclarationModifiers modifiers,
bool modifierErrors,
DiagnosticBag diagnostics)
: base(containingType, declarator, modifiers, modifierErrors, diagnostics)
{
// Checked in parser: a fixed field declaration requires a length in square brackets
Debug.Assert(this.IsFixed);
}
开发者ID:orthoxerox,项目名称:roslyn,代码行数:12,代码来源:SourceFixedFieldSymbol.cs
示例18: GlobalExpressionVariable
internal GlobalExpressionVariable(
SourceMemberContainerTypeSymbol containingType,
DeclarationModifiers modifiers,
TypeSyntax typeSyntax,
string name,
SyntaxReference syntax,
Location location)
: base(containingType, modifiers, name, syntax, location)
{
Debug.Assert(DeclaredAccessibility == Accessibility.Private);
_typeSyntax = typeSyntax.GetReference();
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:12,代码来源:GlobalExpressionVariable.cs
示例19: SynthesizedFieldSymbolBase
public SynthesizedFieldSymbolBase(
NamedTypeSymbol containingType,
string name,
bool isPublic,
bool isReadOnly,
bool isStatic)
{
Debug.Assert(!string.IsNullOrEmpty(name));
this.containingType = containingType;
this.name = name;
this.modifiers = (isPublic ? DeclarationModifiers.Public : DeclarationModifiers.Private) |
(isReadOnly ? DeclarationModifiers.ReadOnly : DeclarationModifiers.None) |
(isStatic ? DeclarationModifiers.Static : DeclarationModifiers.None);
}
开发者ID:afrog33k,项目名称:csnative,代码行数:15,代码来源:SynthesizedFieldSymbolBase.cs
示例20: ConvertSingleModifierToSyntaxText
private static string ConvertSingleModifierToSyntaxText(DeclarationModifiers modifier)
{
switch (modifier)
{
case DeclarationModifiers.Abstract:
return SyntaxFacts.GetText(SyntaxKind.AbstractKeyword);
case DeclarationModifiers.Sealed:
return SyntaxFacts.GetText(SyntaxKind.SealedKeyword);
case DeclarationModifiers.Static:
return SyntaxFacts.GetText(SyntaxKind.StaticKeyword);
case DeclarationModifiers.New:
return SyntaxFacts.GetText(SyntaxKind.NewKeyword);
case DeclarationModifiers.Public:
return SyntaxFacts.GetText(SyntaxKind.PublicKeyword);
case DeclarationModifiers.Protected:
return SyntaxFacts.GetText(SyntaxKind.ProtectedKeyword);
case DeclarationModifiers.Internal:
return SyntaxFacts.GetText(SyntaxKind.InternalKeyword);
case DeclarationModifiers.ProtectedInternal:
return SyntaxFacts.GetText(SyntaxKind.ProtectedKeyword) + " " + SyntaxFacts.GetText(SyntaxKind.InternalKeyword);
case DeclarationModifiers.Private:
return SyntaxFacts.GetText(SyntaxKind.PrivateKeyword);
case DeclarationModifiers.ReadOnly:
return SyntaxFacts.GetText(SyntaxKind.ReadOnlyKeyword);
case DeclarationModifiers.Const:
return SyntaxFacts.GetText(SyntaxKind.ConstKeyword);
case DeclarationModifiers.Volatile:
return SyntaxFacts.GetText(SyntaxKind.VolatileKeyword);
case DeclarationModifiers.Extern:
return SyntaxFacts.GetText(SyntaxKind.ExternKeyword);
case DeclarationModifiers.Partial:
return SyntaxFacts.GetText(SyntaxKind.PartialKeyword);
case DeclarationModifiers.Unsafe:
return SyntaxFacts.GetText(SyntaxKind.UnsafeKeyword);
case DeclarationModifiers.Fixed:
return SyntaxFacts.GetText(SyntaxKind.FixedKeyword);
case DeclarationModifiers.Virtual:
return SyntaxFacts.GetText(SyntaxKind.VirtualKeyword);
case DeclarationModifiers.Override:
return SyntaxFacts.GetText(SyntaxKind.OverrideKeyword);
case DeclarationModifiers.Replace:
return SyntaxFacts.GetText(SyntaxKind.ReplaceKeyword);
case DeclarationModifiers.Async:
return SyntaxFacts.GetText(SyntaxKind.AsyncKeyword);
default:
throw ExceptionUtilities.UnexpectedValue(modifier);
}
}
开发者ID:RoryVL,项目名称:roslyn,代码行数:48,代码来源:ModifierUtils.cs
注:本文中的DeclarationModifiers类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论