• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# BasePropertyDeclarationSyntax类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中BasePropertyDeclarationSyntax的典型用法代码示例。如果您正苦于以下问题:C# BasePropertyDeclarationSyntax类的具体用法?C# BasePropertyDeclarationSyntax怎么用?C# BasePropertyDeclarationSyntax使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BasePropertyDeclarationSyntax类属于命名空间,在下文中一共展示了BasePropertyDeclarationSyntax类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CheckForFormat

 public static void CheckForFormat(NeosSdiMef neosSdiMef, CodingRule rule, BasePropertyDeclarationSyntax _property, string text, string textFull, int spanStart, int spanEnd)
 {
     switch (rule.RuleCase)
     {
         case CodingRuleCaseEnum.UpperCamelCase:
             string upperText = rule.RuleFirstLetter + text.UpperCamelCase();
             if (text != upperText)
             {
                 neosSdiMef.AddDecorationError(_property, textFull, "Replace " + text + " by " + upperText, () =>
                 {
                     var span = Span.FromBounds(spanStart, spanEnd);
                     neosSdiMef._textView.TextBuffer.Replace(span, upperText);
                 });
             }
             break;
         case CodingRuleCaseEnum.LowerCamelCase:
             string lowerText = rule.RuleFirstLetter + text.LowerCamelCase();
             if (text != lowerText)
             {
                 neosSdiMef.AddDecorationError(_property, textFull, "Replace " + text + " by " + lowerText, () =>
                 {
                     var span = Span.FromBounds(spanStart, spanEnd);
                     neosSdiMef._textView.TextBuffer.Replace(span, lowerText);
                 });
             }
             break;
         default:
             break;
     }
 }
开发者ID:jefflequeux,项目名称:DarkangeUtils,代码行数:30,代码来源:CheckFormat.cs


示例2: ApplyFix

        private static async Task<Document> ApplyFix(
            Document document
            , BaseTypeSyntax derivingClass
            , BasePropertyDeclarationSyntax viewModelProperty
            , CancellationToken cancellationToken)
        {
            var genericClassDeclaration = SyntaxFactory.SimpleBaseType(
                SyntaxFactory.GenericName(
                    SyntaxFactory.Identifier(
                            derivingClass.Type.ToString()
                        )
                    )
                    .WithTypeArgumentList(
                        SyntaxFactory.TypeArgumentList(
                            SyntaxFactory.SingletonSeparatedList(viewModelProperty.Type)
                        )
                    )
                ).WithAdditionalAnnotations(Formatter.Annotation);

            var editor = await DocumentEditor.CreateAsync(document, cancellationToken);
            editor.RemoveNode(viewModelProperty);
            editor.ReplaceNode(derivingClass, genericClassDeclaration);

            return editor.GetChangedDocument();
        }
开发者ID:MvvmCross,项目名称:MvvmCross,代码行数:25,代码来源:ConsiderUsingGenericBaseViewCodeFix.cs


示例3: AddDecorationError

        public void AddDecorationError(BasePropertyDeclarationSyntax _property, string textFull, string toolTipText, FixErrorCallback errorCallback)
        {
            var lineSpan = tree.GetLineSpan(_property.Span, usePreprocessorDirectives: false);
            int lineNumber = lineSpan.StartLinePosition.Line;
            var line = _textView.TextSnapshot.GetLineFromLineNumber(lineNumber);
            var textViewLine = _textView.GetTextViewLineContainingBufferPosition(line.Start);
            int startSpace = textFull.Length - textFull.TrimStart().Length;
            int endSpace = textFull.Length - textFull.TrimEnd().Length;

            SnapshotSpan span = new SnapshotSpan(_textView.TextSnapshot, Span.FromBounds(line.Start.Position + startSpace, line.End.Position - endSpace));
            Geometry g = _textView.TextViewLines.GetMarkerGeometry(span);
            if (g != null)
            {
                rects.Add(g.Bounds);

                GeometryDrawing drawing = new GeometryDrawing(_brush, _pen, g);
                drawing.Freeze();

                DrawingImage drawingImage = new DrawingImage(drawing);
                drawingImage.Freeze();

                Image image = new Image();
                image.Source = drawingImage;
                //image.Visibility = Visibility.Hidden;

                Canvas.SetLeft(image, g.Bounds.Left);
                Canvas.SetTop(image, g.Bounds.Top);
                _layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, image, (t, ui) =>
                {
                    rects.Remove(g.Bounds);
                });

                DrawIcon(span, g.Bounds.Left - 30, g.Bounds.Top, toolTipText, errorCallback);
            }
        }
开发者ID:jefflequeux,项目名称:DarkangeUtils,代码行数:35,代码来源:BaseMef.cs


示例4: HasBothAccessors

        private static bool HasBothAccessors(BasePropertyDeclarationSyntax property)
        {
            var accessors = property.AccessorList.Accessors;
            var getter = accessors.FirstOrDefault(ad => ad.Kind() == SyntaxKind.GetAccessorDeclaration);
            var setter = accessors.FirstOrDefault(ad => ad.Kind() == SyntaxKind.SetAccessorDeclaration);

            return getter?.Body?.Statements.Count == 1 && setter?.Body?.Statements.Count == 1;
        }
开发者ID:CNinnovation,项目名称:TechConference2016,代码行数:8,代码来源:AutoPropertyRewriter.cs


示例5: BasePropertyDeclarationTranslation

        public BasePropertyDeclarationTranslation(BasePropertyDeclarationSyntax syntax, SyntaxTranslation parent) : base(syntax, parent)
        {
            Type = syntax.Type.Get<TypeTranslation>(this);
            AccessorList = syntax.AccessorList.Get<AccessorListTranslation>(this);
            Modifiers = syntax.Modifiers.Get(this);

            AccessorList.SetModifier(Modifiers);
        }
开发者ID:asthomas,项目名称:TypescriptSyntaxPaste,代码行数:8,代码来源:BasePropertyDeclarationTranslation.cs


示例6: HasBothAccessors

        /// <summary>
        /// Returns true if both get and set accessors exist on the given property; otherwise false.
        /// </summary>
        private static bool HasBothAccessors(BasePropertyDeclarationSyntax property)
        {
            var accessors = property.AccessorList.Accessors;
            var getter = accessors.FirstOrDefault(ad => ad.Kind() == SyntaxKind.GetAccessorDeclaration);
            var setter = accessors.FirstOrDefault(ad => ad.Kind() == SyntaxKind.SetAccessorDeclaration);

            if (getter != null && setter != null)
            {
                // The getter and setter should have a body.
                return getter.Body != null && setter.Body != null;
            }

            return false;
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:17,代码来源:CodeRefactoringProvider.cs


示例7: ConvertToExpressionBodiedMemberAsync

        private static async Task<Document> ConvertToExpressionBodiedMemberAsync(Document document, BasePropertyDeclarationSyntax declaration, CancellationToken cancellationToken)
        {
            var accessors = declaration.AccessorList.Accessors;
            var body = accessors[0].Body;
            var returnStatement = body.Statements[0] as ReturnStatementSyntax;

            var arrowExpression = SyntaxFactory.ArrowExpressionClause(
                returnStatement.Expression);

            var newDeclaration = declaration;

            newDeclaration = ((dynamic)declaration)
                .WithAccessorList(null)
                .WithExpressionBody(arrowExpression)
                .WithSemicolon(SyntaxFactory.Token(SyntaxKind.SemicolonToken));

            newDeclaration = newDeclaration.WithAdditionalAnnotations(Formatter.Annotation);

            return await ReplaceNodeAsync(document, declaration, newDeclaration, cancellationToken);
        }
开发者ID:haroldhues,项目名称:code-cracker,代码行数:20,代码来源:ConvertToExpressionBodiedMemberCodeFixProvider.cs


示例8: AnalyzeProperty

        private static void AnalyzeProperty(SyntaxNodeAnalysisContext context, BasePropertyDeclarationSyntax propertyDeclaration)
        {
            if (propertyDeclaration?.AccessorList == null)
            {
                return;
            }

            var accessors = propertyDeclaration.AccessorList.Accessors;
            if (propertyDeclaration.AccessorList.IsMissing ||
                accessors.Count != 2)
            {
                return;
            }

            if (accessors[0].Kind() == SyntaxKind.SetAccessorDeclaration &&
                accessors[1].Kind() == SyntaxKind.GetAccessorDeclaration)
            {
                context.ReportDiagnostic(Diagnostic.Create(Descriptor, accessors[0].GetLocation()));
            }
        }
开发者ID:nvincent,项目名称:StyleCopAnalyzers,代码行数:20,代码来源:SA1212PropertyAccessorsMustFollowOrder.cs


示例9: GetDeclaredSymbol

 public override ISymbol GetDeclaredSymbol(BasePropertyDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
 {
     // Can't define property inside member.
     return null;
 }
开发者ID:orthoxerox,项目名称:roslyn,代码行数:5,代码来源:MemberSemanticModel.cs


示例10: GetEndPoint

            private VirtualTreePoint GetEndPoint(SourceText text, BasePropertyDeclarationSyntax node, EnvDTE.vsCMPart part)
            {
                int endPosition;

                switch (part)
                {
                    case EnvDTE.vsCMPart.vsCMPartName:
                    case EnvDTE.vsCMPart.vsCMPartAttributes:
                    case EnvDTE.vsCMPart.vsCMPartHeader:
                    case EnvDTE.vsCMPart.vsCMPartWhole:
                    case EnvDTE.vsCMPart.vsCMPartBodyWithDelimiter:
                    case EnvDTE.vsCMPart.vsCMPartHeaderWithAttributes:
                        throw Exceptions.ThrowENotImpl();

                    case EnvDTE.vsCMPart.vsCMPartAttributesWithDelimiter:
                        if (node.AttributeLists.Count == 0)
                        {
                            throw Exceptions.ThrowEFail();
                        }

                        endPosition = node.AttributeLists.Last().Span.End;
                        break;

                    case EnvDTE.vsCMPart.vsCMPartWholeWithAttributes:
                        endPosition = node.Span.End;
                        break;

                    case EnvDTE.vsCMPart.vsCMPartNavigate:
                        var firstAccessorNode = FindFirstAccessorNode(node);
                        if (firstAccessorNode != null)
                        {
                            if (firstAccessorNode.Body != null)
                            {
                                return GetBodyEndPoint(text, firstAccessorNode.Body.CloseBraceToken);
                            }
                            else
                            {
                                // This is total weirdness from the old C# code model with auto props.
                                // If there isn't a body, the semi-colon is used
                                return GetBodyEndPoint(text, firstAccessorNode.SemicolonToken);
                            }
                        }

                        throw Exceptions.ThrowEFail();

                    case EnvDTE.vsCMPart.vsCMPartBody:
                        if (node.AccessorList != null && !node.AccessorList.CloseBraceToken.IsMissing)
                        {
                            return GetBodyEndPoint(text, node.AccessorList.CloseBraceToken);
                        }

                        throw Exceptions.ThrowEFail();

                    default:
                        throw Exceptions.ThrowEInvalidArg();
                }

                return new VirtualTreePoint(node.SyntaxTree, text, endPosition);
            }
开发者ID:Rickinio,项目名称:roslyn,代码行数:59,代码来源:CSharpCodeModelService.NodeLocator.cs


示例11: IsNotPublicModifier

 private static bool IsNotPublicModifier(BasePropertyDeclarationSyntax property, string modifier)
 {
     return property.Modifiers.Any(x => string.Compare(x.Text, modifier, StringComparison.InvariantCultureIgnoreCase) == 0);
 }
开发者ID:laurentkempe,项目名称:Furnace,代码行数:4,代码来源:RoslynContentTypes.cs


示例12: RegisterPropertyLikeDeclarationCodeFix

 private SyntaxNode RegisterPropertyLikeDeclarationCodeFix(SyntaxNode syntaxRoot, BasePropertyDeclarationSyntax node, IndentationOptions indentationOptions)
 {
     return this.ReformatElement(syntaxRoot, node, node.AccessorList.OpenBraceToken, node.AccessorList.CloseBraceToken, indentationOptions);
 }
开发者ID:JaRau,项目名称:StyleCopAnalyzers,代码行数:4,代码来源:SA1502CodeFixProvider.cs


示例13: SourcePropertySymbol

        // CONSIDER: if the parameters were computed lazily, ParameterCount could be overridden to fall back on the syntax (as in SourceMemberMethodSymbol).

        private SourcePropertySymbol(
            SourceMemberContainerTypeSymbol containingType,
            Binder bodyBinder,
            BasePropertyDeclarationSyntax syntax,
            string name,
            Location location,
            DiagnosticBag diagnostics)
        {
            // This has the value that IsIndexer will ultimately have, once we've populated the fields of this object.
            bool isIndexer = syntax.Kind() == SyntaxKind.IndexerDeclaration;
            var interfaceSpecifier = GetExplicitInterfaceSpecifier(syntax);
            bool isExplicitInterfaceImplementation = (interfaceSpecifier != null);

            _location = location;
            _containingType = containingType;
            _syntaxRef = syntax.GetReference();

            SyntaxTokenList modifiers = syntax.Modifiers;
            bodyBinder = bodyBinder.WithUnsafeRegionIfNecessary(modifiers);
            bodyBinder = bodyBinder.WithAdditionalFlagsAndContainingMemberOrLambda(BinderFlags.SuppressConstraintChecks, this);

            bool modifierErrors;
            _modifiers = MakeModifiers(modifiers, isExplicitInterfaceImplementation, isIndexer, location, diagnostics, out modifierErrors);
            this.CheckAccessibility(location, diagnostics);

            this.CheckModifiers(location, isIndexer, diagnostics);

            if (isIndexer && !isExplicitInterfaceImplementation)
            {
                // Evaluate the attributes immediately in case the IndexerNameAttribute has been applied.
                // NOTE: we want IsExplicitInterfaceImplementation, IsOverride, Locations, and the syntax reference
                // to be initialized before we pass this symbol to LoadCustomAttributes.

                // CONSIDER: none of the information from this early binding pass is cached.  Everything will
                // be re-bound when someone calls GetAttributes.  If this gets to be a problem, we could
                // always use the real attribute bag of this symbol and modify LoadAndValidateAttributes to
                // handle partially filled bags.
                CustomAttributesBag<CSharpAttributeData> temp = null;
                LoadAndValidateAttributes(OneOrMany.Create(this.CSharpSyntaxNode.AttributeLists), ref temp, earlyDecodingOnly: true);
                if (temp != null)
                {
                    Debug.Assert(temp.IsEarlyDecodedWellKnownAttributeDataComputed);
                    var propertyData = (PropertyEarlyWellKnownAttributeData)temp.EarlyDecodedWellKnownAttributeData;
                    if (propertyData != null)
                    {
                        _sourceName = propertyData.IndexerName;
                    }
                }
            }

            string aliasQualifierOpt;
            string memberName = ExplicitInterfaceHelpers.GetMemberNameAndInterfaceSymbol(bodyBinder, interfaceSpecifier, name, diagnostics, out _explicitInterfaceType, out aliasQualifierOpt);
            _sourceName = _sourceName ?? memberName; //sourceName may have been set while loading attributes
            _name = isIndexer ? ExplicitInterfaceHelpers.GetMemberName(WellKnownMemberNames.Indexer, _explicitInterfaceType, aliasQualifierOpt) : _sourceName;
            _isExpressionBodied = false;

            bool hasAccessorList = syntax.AccessorList != null;
            var propertySyntax = syntax as PropertyDeclarationSyntax;
            var arrowExpression = propertySyntax != null
                ? propertySyntax.ExpressionBody
                : ((IndexerDeclarationSyntax)syntax).ExpressionBody;
            bool hasExpressionBody = arrowExpression != null;
            bool hasInitializer = !isIndexer && propertySyntax.Initializer != null;

            bool notRegularProperty = (!IsAbstract && !IsExtern && !isIndexer && hasAccessorList);
            AccessorDeclarationSyntax getSyntax = null;
            AccessorDeclarationSyntax setSyntax = null;
            if (hasAccessorList)
            {
                foreach (var accessor in syntax.AccessorList.Accessors)
                {
                    if (accessor.Kind() == SyntaxKind.GetAccessorDeclaration &&
                        (getSyntax == null || getSyntax.Keyword.Span.IsEmpty))
                    {
                        getSyntax = accessor;
                    }
                    else if (accessor.Kind() == SyntaxKind.SetAccessorDeclaration &&
                        (setSyntax == null || setSyntax.Keyword.Span.IsEmpty))
                    {
                        setSyntax = accessor;
                    }
                    else
                    {
                        continue;
                    }

                    if (accessor.Body != null)
                    {
                        notRegularProperty = false;
                    }
                }
            }
            else
            {
                notRegularProperty = false;
            }

            if (hasInitializer)
//.........这里部分代码省略.........
开发者ID:rafaellincoln,项目名称:roslyn,代码行数:101,代码来源:SourcePropertySymbol.cs


示例14: GetExplicitInterfaceSpecifier

 private static ExplicitInterfaceSpecifierSyntax GetExplicitInterfaceSpecifier(BasePropertyDeclarationSyntax syntax)
 {
     switch (syntax.Kind())
     {
         case SyntaxKind.PropertyDeclaration:
             return ((PropertyDeclarationSyntax)syntax).ExplicitInterfaceSpecifier;
         case SyntaxKind.IndexerDeclaration:
             return ((IndexerDeclarationSyntax)syntax).ExplicitInterfaceSpecifier;
         default:
             throw ExceptionUtilities.UnexpectedValue(syntax.Kind());
     }
 }
开发者ID:rafaellincoln,项目名称:roslyn,代码行数:12,代码来源:SourcePropertySymbol.cs


示例15: ComputeType

        private TypeSymbol ComputeType(Binder binder, BasePropertyDeclarationSyntax syntax, DiagnosticBag diagnostics)
        {
            var type = binder.BindType(syntax.Type, diagnostics);
            HashSet<DiagnosticInfo> useSiteDiagnostics = null;

            if (!this.IsNoMoreVisibleThan(type, ref useSiteDiagnostics))
            {
                // "Inconsistent accessibility: indexer return type '{1}' is less accessible than indexer '{0}'"
                // "Inconsistent accessibility: property type '{1}' is less accessible than property '{0}'"
                diagnostics.Add((this.IsIndexer ? ErrorCode.ERR_BadVisIndexerReturn : ErrorCode.ERR_BadVisPropertyType), _location, this, type);
            }

            diagnostics.Add(_location, useSiteDiagnostics);

            if (type.SpecialType == SpecialType.System_Void)
            {
                ErrorCode errorCode = this.IsIndexer ? ErrorCode.ERR_IndexerCantHaveVoidType : ErrorCode.ERR_PropertyCantHaveVoidType;
                diagnostics.Add(errorCode, _location, this);
            }

            return type;
        }
开发者ID:rafaellincoln,项目名称:roslyn,代码行数:22,代码来源:SourcePropertySymbol.cs


示例16: GetPropertyPrototype

        private string GetPropertyPrototype(BasePropertyDeclarationSyntax node, IPropertySymbol symbol, PrototypeFlags flags)
        {
            if ((flags & PrototypeFlags.Signature) != 0)
            {
                if (flags != PrototypeFlags.Signature)
                {
                    // vsCMPrototypeUniqueSignature can't be combined with anything else.
                    throw Exceptions.ThrowEInvalidArg();
                }

                // The unique signature is simply the node key.
                return GetNodeKey(node).Name;
            }

            var builder = new StringBuilder();

            AppendPropertyPrototype(builder, symbol, flags, GetName(node));

            return builder.ToString();
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:20,代码来源:CSharpCodeModelService_Prototype.cs


示例17: BasePropertyDeclarationProlog

        private void BasePropertyDeclarationProlog(BasePropertyDeclarationSyntax node)
        {
            _writer.WriteIndent();

            WriteAttributes(
                node,
                _writer.Configuration.LineBreaksAndWrapping.Other.PlacePropertyIndexerEventAttributeOnSameLine
            );

            WriteMemberModifiers(node.Modifiers);

            node.Type.Accept(this);
            _writer.WriteSpace();

            if (node.ExplicitInterfaceSpecifier != null)
                node.ExplicitInterfaceSpecifier.Accept(this);
        }
开发者ID:modulexcite,项目名称:CSharpSyntax,代码行数:17,代码来源:SyntaxPrinter.cs


示例18: GetDeclaredSymbol

 /// <summary>
 /// Given a syntax node that declares a property, indexer or an event, get the corresponding declared symbol.
 /// </summary>
 /// <param name="declarationSyntax">The syntax node that declares a property, indexer or an event.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns>The symbol that was declared.</returns>
 public override ISymbol GetDeclaredSymbol(BasePropertyDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (Logger.LogBlock(FunctionId.CSharp_SemanticModel_GetDeclaredSymbol, message: this.SyntaxTree.FilePath, cancellationToken: cancellationToken))
     {
         return GetDeclaredMemberSymbol(declarationSyntax);
     }
 }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:13,代码来源:SyntaxTreeSemanticModel.cs


示例19: GetExpressionBodyDeclarationInfo

        private static DeclarationInfo GetExpressionBodyDeclarationInfo(
            BasePropertyDeclarationSyntax declarationWithExpressionBody,
            ArrowExpressionClauseSyntax expressionBody,
            SemanticModel model,
            bool getSymbol,
            CancellationToken cancellationToken)
        {
            // TODO: use 'model.GetDeclaredSymbol(expressionBody)' when compiler is fixed to return the getter symbol for it.
            var declaredAccessor = getSymbol ? (model.GetDeclaredSymbol(declarationWithExpressionBody, cancellationToken) as IPropertySymbol)?.GetMethod : null;

            return new DeclarationInfo(
                declaredNode: expressionBody,
                executableCodeBlocks: ImmutableArray.Create<SyntaxNode>(expressionBody),
                declaredSymbol: declaredAccessor);
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:15,代码来源:CSharpDeclarationComputer.cs


示例20: GetParameters

		private string GetParameters(BasePropertyDeclarationSyntax syntax)
		{
			var symbol = ModelExtensions.GetSymbolInfo(_semanticModel, syntax.Type).Symbol as ITypeSymbol;
			return string.Format("({0})", symbol == null ? string.Empty : ResolveTypeName(symbol));
		}
开发者ID:henrylle,项目名称:ArchiMetrics,代码行数:5,代码来源:MemberNameResolver.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# BaseQuestGump类代码示例发布时间:2022-05-24
下一篇:
C# BasePlayer类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap