当前位置: 首页>>代码示例>>C#>>正文


C# Symbols.PropertySymbol类代码示例

本文整理汇总了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);
            }
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:29,代码来源:LocalRewriter_PropertyAccess.cs

示例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);
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:32,代码来源:SourcePropertyAccessorSymbol.cs

示例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);
        }
开发者ID:riversky,项目名称:roslyn,代码行数:27,代码来源:SynthesizedMethodSymbol.cs

示例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);
        }
开发者ID:RoryVL,项目名称:roslyn,代码行数:25,代码来源:SynthesizedImplementationMethod.cs

示例5: RetargetingPropertySymbol

        public RetargetingPropertySymbol(RetargetingModuleSymbol retargetingModule, PropertySymbol underlyingProperty)
            : base(underlyingProperty)
        {
            Debug.Assert((object)retargetingModule != null);
            Debug.Assert(!(underlyingProperty is RetargetingPropertySymbol));

            _retargetingModule = retargetingModule;
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:8,代码来源:RetargetingPropertySymbol.cs

示例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;
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:9,代码来源:RetargetingPropertySymbol.cs

示例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);
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:10,代码来源:SynthesizedSealedPropertyAccessor.cs

示例8: SynthesizedStateMachineMethod

 protected SynthesizedStateMachineMethod(
     string name,
     MethodSymbol interfaceMethod,
     StateMachineTypeSymbol stateMachineType,
     PropertySymbol associatedProperty,
     bool generateDebugInfo,
     bool hasMethodBodyDependency)
     : base(interfaceMethod, stateMachineType, name, generateDebugInfo, associatedProperty)
 {
     _hasMethodBodyDependency = hasMethodBodyDependency;
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:11,代码来源:SynthesizedStateMachineMethod.cs

示例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);
         }
     }
 }
开发者ID:riversky,项目名称:roslyn,代码行数:12,代码来源:SynthesizedMethodMetadataCompiler.cs

示例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;
 }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:12,代码来源:SynthesizedStateMachineMethod.cs

示例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);
        }
开发者ID:riversky,项目名称:roslyn,代码行数:47,代码来源:SourcePropertyAccessorSymbol.cs

示例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);
            }
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:41,代码来源:LocalRewriter_PropertyAccess.cs

示例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;
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:21,代码来源:AsyncMethodBuilderMemberCollection.cs

示例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);
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:12,代码来源:Binder_Statements.cs

示例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);
            }
        }
开发者ID:rafaellincoln,项目名称:roslyn,代码行数:16,代码来源:SourcePropertySymbol.cs


注:本文中的Microsoft.CodeAnalysis.CSharp.Symbols.PropertySymbol类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。