本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Symbols.PropertySymbol类的典型用法代码示例。如果您正苦于以下问题:C# PropertySymbol类的具体用法?C# PropertySymbol怎么用?C# PropertySymbol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PropertySymbol类属于Microsoft.CodeAnalysis.CSharp.Symbols命名空间,在下文中一共展示了PropertySymbol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakePropertyGetAccess
private BoundExpression MakePropertyGetAccess(
SyntaxNode syntax,
BoundExpression rewrittenReceiver,
PropertySymbol property,
ImmutableArray<BoundExpression> rewrittenArguments,
MethodSymbol getMethodOpt = null,
BoundPropertyAccess oldNodeOpt = null)
{
if (_inExpressionLambda && rewrittenArguments.IsEmpty)
{
return oldNodeOpt != null ?
oldNodeOpt.Update(rewrittenReceiver, property, LookupResultKind.Viable, property.Type) :
new BoundPropertyAccess(syntax, rewrittenReceiver, property, LookupResultKind.Viable, property.Type);
}
else
{
var getMethod = getMethodOpt ?? property.GetOwnOrInheritedGetMethod();
Debug.Assert((object)getMethod != null);
Debug.Assert(getMethod.ParameterCount == rewrittenArguments.Length);
Debug.Assert(((object)getMethodOpt == null) || ReferenceEquals(getMethod, getMethodOpt));
return BoundCall.Synthesized(
syntax,
rewrittenReceiver,
getMethod,
rewrittenArguments);
}
}
示例2: 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);
}
示例3: SynthesizedImplementationMethod
public SynthesizedImplementationMethod(
MethodSymbol interfaceMethod,
NamedTypeSymbol implementingType,
string name = null,
bool debuggerHidden = false,
PropertySymbol associatedProperty = null,
MethodSymbol asyncKickoffMethod = null)
{
//it does not make sense to add methods to substituted types
Debug.Assert(implementingType.IsDefinition);
this.name = name ?? ExplicitInterfaceHelpers.GetMemberName(interfaceMethod.Name, interfaceMethod.ContainingType, aliasQualifierOpt: null);
this.interfaceMethod = interfaceMethod;
this.implementingType = implementingType;
this.debuggerHidden = debuggerHidden;
this.associatedProperty = associatedProperty;
this.explicitInterfaceImplementations = ImmutableArray.Create<MethodSymbol>(interfaceMethod);
this.asyncKickoffMethod = asyncKickoffMethod;
// alpha-rename to get the implementation's type parameters
var typeMap = interfaceMethod.ContainingType.TypeSubstitution ?? TypeMap.Empty;
typeMap.WithAlphaRename(interfaceMethod, this, out this.typeParameters);
var substitutedInterfaceMethod = interfaceMethod.ConstructIfGeneric(this.typeParameters.Cast<TypeParameterSymbol, TypeSymbol>());
this.returnType = substitutedInterfaceMethod.ReturnType;
this.parameters = SynthesizedParameterSymbol.DeriveParameters(substitutedInterfaceMethod, this);
}
示例4: SynthesizedImplementationMethod
public SynthesizedImplementationMethod(
MethodSymbol interfaceMethod,
NamedTypeSymbol implementingType,
string name = null,
bool generateDebugInfo = true,
PropertySymbol associatedProperty = null)
{
//it does not make sense to add methods to substituted types
Debug.Assert(implementingType.IsDefinition);
_name = name ?? ExplicitInterfaceHelpers.GetMemberName(interfaceMethod.Name, interfaceMethod.ContainingType, aliasQualifierOpt: null);
_interfaceMethod = interfaceMethod;
_implementingType = implementingType;
_generateDebugInfo = generateDebugInfo;
_associatedProperty = associatedProperty;
_explicitInterfaceImplementations = ImmutableArray.Create<MethodSymbol>(interfaceMethod);
// alpha-rename to get the implementation's type parameters
var typeMap = interfaceMethod.ContainingType.TypeSubstitution ?? TypeMap.Empty;
typeMap.WithAlphaRename(interfaceMethod, this, out _typeParameters);
var substitutedInterfaceMethod = interfaceMethod.ConstructIfGeneric(_typeParameters.Cast<TypeParameterSymbol, TypeSymbol>());
_returnType = substitutedInterfaceMethod.ReturnType;
_parameters = SynthesizedParameterSymbol.DeriveParameters(substitutedInterfaceMethod, this);
}
示例5: RetargetingPropertySymbol
public RetargetingPropertySymbol(RetargetingModuleSymbol retargetingModule, PropertySymbol underlyingProperty)
: base(underlyingProperty)
{
Debug.Assert((object)retargetingModule != null);
Debug.Assert(!(underlyingProperty is RetargetingPropertySymbol));
_retargetingModule = retargetingModule;
}
示例6: RetargetingPropertySymbol
public RetargetingPropertySymbol(RetargetingModuleSymbol retargetingModule, PropertySymbol underlyingProperty)
{
Debug.Assert((object)retargetingModule != null);
Debug.Assert((object)underlyingProperty != null);
Debug.Assert(!(underlyingProperty is RetargetingPropertySymbol));
this.retargetingModule = retargetingModule;
this.underlyingProperty = underlyingProperty;
}
示例7: SynthesizedSealedPropertyAccessor
public SynthesizedSealedPropertyAccessor(PropertySymbol property, MethodSymbol overriddenAccessor)
{
Debug.Assert((object)property != null);
Debug.Assert(property.IsSealed);
Debug.Assert((object)overriddenAccessor != null);
_property = property;
_overriddenAccessor = overriddenAccessor;
_parameters = SynthesizedParameterSymbol.DeriveParameters(overriddenAccessor, this);
}
示例8: SynthesizedStateMachineMethod
protected SynthesizedStateMachineMethod(
string name,
MethodSymbol interfaceMethod,
StateMachineTypeSymbol stateMachineType,
PropertySymbol associatedProperty,
bool generateDebugInfo,
bool hasMethodBodyDependency)
: base(interfaceMethod, stateMachineType, name, generateDebugInfo, associatedProperty)
{
_hasMethodBodyDependency = hasMethodBodyDependency;
}
示例9: VisitProperty
public override void VisitProperty(PropertySymbol symbol)
{
var sourceProperty = symbol as SourcePropertySymbol;
if ((object)sourceProperty != null && sourceProperty.IsSealed)
{
var synthesizedAccessor = sourceProperty.SynthesizedSealedAccessorOpt;
if ((object)synthesizedAccessor != null)
{
moduleBeingBuilt.AddCompilerGeneratedDefinition(sourceProperty.ContainingType, synthesizedAccessor);
}
}
}
示例10: SynthesizedStateMachineMethod
public SynthesizedStateMachineMethod(
string name,
MethodSymbol interfaceMethod,
NamedTypeSymbol implementingType,
MethodSymbol asyncKickoffMethod,
PropertySymbol associatedProperty,
bool debuggerHidden,
bool hasMethodBodyDependency)
: base(interfaceMethod, implementingType, name, debuggerHidden, associatedProperty, asyncKickoffMethod)
{
this.hasMethodBodyDependency = hasMethodBodyDependency;
}
示例11: CreateAccessorSymbol
public static SourcePropertyAccessorSymbol CreateAccessorSymbol(
NamedTypeSymbol containingType,
SourcePropertySymbol property,
DeclarationModifiers propertyModifiers,
string propertyName,
AccessorDeclarationSyntax syntax,
PropertySymbol explicitlyImplementedPropertyOpt,
string aliasQualifierOpt,
bool isAutoPropertyAccessor,
DiagnosticBag diagnostics)
{
Debug.Assert(syntax.Kind == SyntaxKind.GetAccessorDeclaration || syntax.Kind == SyntaxKind.SetAccessorDeclaration);
bool isGetMethod = (syntax.Kind == SyntaxKind.GetAccessorDeclaration);
bool isWinMd = property.IsCompilationOutputWinMdObj();
string name;
ImmutableArray<MethodSymbol> explicitInterfaceImplementations;
if ((object)explicitlyImplementedPropertyOpt == null)
{
name = GetAccessorName(propertyName, isGetMethod, isWinMd);
explicitInterfaceImplementations = ImmutableArray<MethodSymbol>.Empty;
}
else
{
MethodSymbol implementedAccessor = isGetMethod ? explicitlyImplementedPropertyOpt.GetMethod : explicitlyImplementedPropertyOpt.SetMethod;
string accessorName = (object)implementedAccessor != null ? implementedAccessor.Name
: GetAccessorName(explicitlyImplementedPropertyOpt.MetadataName, isGetMethod, isWinMd); //Not name - could be indexer placeholder
name = ExplicitInterfaceHelpers.GetMemberName(accessorName, explicitlyImplementedPropertyOpt.ContainingType, aliasQualifierOpt);
explicitInterfaceImplementations =
(object)implementedAccessor == null ?
ImmutableArray<MethodSymbol>.Empty :
ImmutableArray.Create<MethodSymbol>(implementedAccessor);
}
var methodKind = isGetMethod ? MethodKind.PropertyGet : MethodKind.PropertySet;
return new SourcePropertyAccessorSymbol(
containingType,
name,
property,
propertyModifiers,
explicitInterfaceImplementations,
syntax.Keyword.GetLocation(),
syntax,
methodKind,
isAutoPropertyAccessor,
diagnostics);
}
示例12: MakePropertyAccess
private BoundExpression MakePropertyAccess(
SyntaxNode syntax,
BoundExpression rewrittenReceiverOpt,
PropertySymbol propertySymbol,
LookupResultKind resultKind,
TypeSymbol type,
bool isLeftOfAssignment,
BoundPropertyAccess oldNodeOpt = null)
{
// check for System.Array.[Length|LongLength] on a single dimensional array,
// we have a special node for such cases.
if (rewrittenReceiverOpt != null && rewrittenReceiverOpt.Type.IsArray() && !isLeftOfAssignment)
{
var asArrayType = (ArrayTypeSymbol)rewrittenReceiverOpt.Type;
if (asArrayType.IsSZArray)
{
// NOTE: we are not interested in potential badness of Array.Length property.
// If it is bad reference compare will not succeed.
if (ReferenceEquals(propertySymbol, _compilation.GetSpecialTypeMember(SpecialMember.System_Array__Length)) ||
!_inExpressionLambda && ReferenceEquals(propertySymbol, _compilation.GetSpecialTypeMember(SpecialMember.System_Array__LongLength)))
{
return new BoundArrayLength(syntax, rewrittenReceiverOpt, type);
}
}
}
if (isLeftOfAssignment && propertySymbol.RefKind == RefKind.None)
{
// This is a property set access. We return a BoundPropertyAccess node here.
// This node will be rewritten with MakePropertyAssignment when rewriting the enclosing BoundAssignmentOperator.
return oldNodeOpt != null ?
oldNodeOpt.Update(rewrittenReceiverOpt, propertySymbol, resultKind, type) :
new BoundPropertyAccess(syntax, rewrittenReceiverOpt, propertySymbol, resultKind, type);
}
else
{
// This is a property get access
return MakePropertyGetAccess(syntax, rewrittenReceiverOpt, propertySymbol, oldNodeOpt);
}
}
示例13: AsyncMethodBuilderMemberCollection
internal AsyncMethodBuilderMemberCollection(
NamedTypeSymbol builderType,
TypeSymbol resultType,
MethodSymbol setException,
MethodSymbol setResult,
MethodSymbol awaitOnCompleted,
MethodSymbol awaitUnsafeOnCompleted,
MethodSymbol start,
MethodSymbol setStateMachine,
PropertySymbol task)
{
BuilderType = builderType;
ResultType = resultType;
SetException = setException;
SetResult = setResult;
AwaitOnCompleted = awaitOnCompleted;
AwaitUnsafeOnCompleted = awaitUnsafeOnCompleted;
Start = start;
SetStateMachine = setStateMachine;
Task = task;
}
示例14: AccessingAutopropertyFromConstructor
internal static bool AccessingAutopropertyFromConstructor(BoundExpression receiver, PropertySymbol propertySymbol, Symbol fromMember)
{
var sourceProperty = propertySymbol as SourcePropertySymbol;
var propertyIsStatic = propertySymbol.IsStatic;
return (object)sourceProperty != null &&
sourceProperty.IsAutoProperty &&
sourceProperty.ContainingType == fromMember.ContainingType &&
((MethodSymbol)fromMember).MethodKind == (propertyIsStatic ? MethodKind.StaticConstructor
: MethodKind.Constructor) &&
(propertyIsStatic || receiver.Kind == BoundKind.ThisReference);
}
示例15: CheckExplicitImplementationAccessor
// Separate these checks out of FindExplicitlyImplementedProperty because they depend on the accessor symbols,
// which depend on the explicitly implemented property
private void CheckExplicitImplementationAccessor(MethodSymbol thisAccessor, MethodSymbol otherAccessor, PropertySymbol explicitlyImplementedProperty, DiagnosticBag diagnostics)
{
var thisHasAccessor = (object)thisAccessor != null;
var otherHasAccessor = (object)otherAccessor != null;
if (otherHasAccessor && !thisHasAccessor)
{
diagnostics.Add(ErrorCode.ERR_ExplicitPropertyMissingAccessor, this.Location, this, otherAccessor);
}
else if (!otherHasAccessor && thisHasAccessor)
{
diagnostics.Add(ErrorCode.ERR_ExplicitPropertyAddingAccessor, thisAccessor.Locations[0], thisAccessor, explicitlyImplementedProperty);
}
}