當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。