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

C# AttributeArgumentSyntax类代码示例

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

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



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

示例1: AttributeArgument

 public static string AttributeArgument(AttributeArgumentSyntax arg)
 {
     var output = SyntaxNode(arg.Expression);
     if (arg.NameColon != null)
     {
         output = SyntaxNode(arg.NameColon.Name) + ": " + output;
     }
     return output;
 }
开发者ID:UIKit0,项目名称:SharpSwift,代码行数:9,代码来源:ArgumentSyntaxParser.cs


示例2: Delete

        private Document Delete(Document document, AttributeArgumentSyntax node)
        {
            var argumentList = node.FirstAncestorOrSelf<AttributeArgumentListSyntax>();
            var newArgumentList = argumentList.RemoveNode(node, SyntaxRemoveOptions.KeepNoTrivia);

            return document.ReplaceNodeAsync(argumentList, newArgumentList, CancellationToken.None)
                           .WaitAndGetResult_CodeModel(CancellationToken.None);
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:8,代码来源:CSharpCodeModelService.cs


示例3: AttributeArgument

 /// <summary>
 /// Initializes a new instance of the <see cref="AttributeArgument"/> class.
 /// </summary>
 /// <param name="syntaxNode"></param>
 /// <param name="kind"></param>
 /// <remarks>
 /// When providing the semantic model, some properites will be devised from that.
 /// </remarks>
 public AttributeArgument(AttributeArgumentSyntax syntaxNode, SemanticModel semanticModel)
     : base(syntaxNode, semanticModel)
 {
 }
开发者ID:andry-tino,项目名称:Rosetta,代码行数:12,代码来源:AttributeArgument.cs


示例4: GetEndPoint

            private VirtualTreePoint GetEndPoint(SourceText text, AttributeArgumentSyntax 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:
                    case EnvDTE.vsCMPart.vsCMPartBody:
                    case EnvDTE.vsCMPart.vsCMPartNavigate:
                        throw Exceptions.ThrowEFail();

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

                    default:
                        throw Exceptions.ThrowEInvalidArg();
                }

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


示例5: InferTypeInAttributeArgument

            private IEnumerable<ITypeSymbol> InferTypeInAttributeArgument(
                int index,
                IEnumerable<ImmutableArray<IParameterSymbol>> parameterizedSymbols,
                AttributeArgumentSyntax argumentOpt = null)
            {
                if (argumentOpt != null && argumentOpt.NameEquals != null)
                {
                    // [MyAttribute(Prop = ...

                    return InferTypeInNameEquals(argumentOpt.NameEquals, argumentOpt.NameEquals.EqualsToken);
                }

                var name = argumentOpt != null && argumentOpt.NameColon != null ? argumentOpt.NameColon.Name.Identifier.ValueText : null;
                return InferTypeInArgument(index, parameterizedSymbols, name);
            }
开发者ID:jerriclynsjohn,项目名称:roslyn,代码行数:15,代码来源:CSharpTypeInferenceService.TypeInferrer.cs


示例6: VisitAttributeArgument

 /// <summary>
 /// 
 /// </summary>
 /// <param name="node"></param>
 public override sealed void VisitAttributeArgument(AttributeArgumentSyntax node)
 {
     this.OnNodeVisited(node, this.type.IsInstanceOfType(node));
     base.VisitAttributeArgument(node);
 }
开发者ID:andry-tino,项目名称:Rosetta,代码行数:9,代码来源:ASTWalkerNodeTypeOperationExecutor.cs


示例7: BindNamedAttributeArgumentType

        private TypeSymbol BindNamedAttributeArgumentType(AttributeArgumentSyntax namedArgument, Symbol namedArgumentNameSymbol, NamedTypeSymbol attributeType, DiagnosticBag diagnostics)
        {
            if (namedArgumentNameSymbol.Kind == SymbolKind.ErrorType)
            {
                return (TypeSymbol)namedArgumentNameSymbol;
            }

            // SPEC:    For each named-argument Arg in named-argument-list N:
            // SPEC:        Let Name be the identifier of the named-argument Arg.
            // SPEC:        Name must identify a non-static read-write public field or property on 
            // SPEC:            attribute class T. If T has no such field or property, then a compile-time error occurs.

            bool invalidNamedArgument = false;
            TypeSymbol namedArgumentType = null;
            invalidNamedArgument |= (namedArgumentNameSymbol.DeclaredAccessibility != Accessibility.Public);
            invalidNamedArgument |= namedArgumentNameSymbol.IsStatic;

            if (!invalidNamedArgument)
            {
                switch (namedArgumentNameSymbol.Kind)
                {
                    case SymbolKind.Field:
                        var fieldSymbol = (FieldSymbol)namedArgumentNameSymbol;
                        namedArgumentType = fieldSymbol.Type;
                        invalidNamedArgument |= fieldSymbol.IsReadOnly;
                        invalidNamedArgument |= fieldSymbol.IsConst;
                        break;

                    case SymbolKind.Property:
                        var propertySymbol = ((PropertySymbol)namedArgumentNameSymbol).GetLeastOverriddenProperty(this.ContainingType);
                        namedArgumentType = propertySymbol.Type;
                        invalidNamedArgument |= propertySymbol.IsReadOnly;
                        var getMethod = propertySymbol.GetMethod;
                        var setMethod = propertySymbol.SetMethod;
                        invalidNamedArgument = invalidNamedArgument || (object)getMethod == null || (object)setMethod == null;
                        if (!invalidNamedArgument)
                        {
                            invalidNamedArgument =
                                getMethod.DeclaredAccessibility != Accessibility.Public ||
                                setMethod.DeclaredAccessibility != Accessibility.Public;
                        }
                        break;

                    default:
                        invalidNamedArgument = true;
                        break;
                }
            }

            if (invalidNamedArgument)
            {
                return new ExtendedErrorTypeSymbol(attributeType,
                    namedArgumentNameSymbol,
                    LookupResultKind.NotAVariable,
                    diagnostics.Add(ErrorCode.ERR_BadNamedAttributeArgument,
                        namedArgument.NameEquals.Name.Location,
                        namedArgumentNameSymbol.Name));
            }
            if (!namedArgumentType.IsValidAttributeParameterType(Compilation))
            {
                return new ExtendedErrorTypeSymbol(attributeType,
                    namedArgumentNameSymbol,
                    LookupResultKind.NotAVariable,
                    diagnostics.Add(ErrorCode.ERR_BadNamedAttributeArgumentType,
                        namedArgument.NameEquals.Name.Location,
                        namedArgumentNameSymbol.Name));
            }

            return namedArgumentType;
        }
开发者ID:RoryVL,项目名称:roslyn,代码行数:70,代码来源:Binder_Attributes.cs


示例8: Create

 public static IUnifiedArgumentSyntax Create(AttributeArgumentSyntax argument)
 {
     return new UnifiedArgumentSyntax(argument);
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:4,代码来源:UnifiedArgumentSyntax.cs


示例9: UpdateValueOfArgumentAsync

 private static Task<Document> UpdateValueOfArgumentAsync(Document document, SyntaxNode root, AttributeArgumentSyntax argument)
 {
     var newArgument = argument.WithExpression(GetNewAttributeValue());
     return Task.FromResult(document.WithSyntaxRoot(root.ReplaceNode(argument, newArgument)));
 }
开发者ID:JaRau,项目名称:StyleCopAnalyzers,代码行数:5,代码来源:SA1404CodeFixProvider.cs


示例10: VisitAttributeArgument

            public override void VisitAttributeArgument(AttributeArgumentSyntax node)
            {
                var saveCurrentScope = currentScope;
                currentScope = new DeclarationScope(saveCurrentScope);

                Visit(node.Expression);

                Debug.Assert(currentScope.Parent == saveCurrentScope);
                currentScope = saveCurrentScope;
            }
开发者ID:jerriclynsjohn,项目名称:roslyn,代码行数:10,代码来源:DeclarationExpressionsTests.cs


示例11: GetLiteral

 private string GetLiteral(AttributeArgumentSyntax argument, SemanticModel semanticModel)
 {
     var literal = argument.Expression.GetLiteral(semanticModel);
     // Literal would be wrapped in double quotes, removing them
     return literal.Substring(1, literal.Length - 2);
 }
开发者ID:SergeyTeplyakov,项目名称:ErrorProne.NET,代码行数:6,代码来源:DebuggerDisplayAttributeAnanlyzer.cs


示例12: VisitAttributeArgument

        public void VisitAttributeArgument(AttributeArgumentSyntax node)
        {
            if (node == null)
                throw new ArgumentNullException("node");

            node.Validate();

            if (node.NameColon != null)
                node.NameColon.Accept(this);
            if (node.NameEquals != null)
                node.NameEquals.Accept(this);

            node.Expression.Accept(this);
        }
开发者ID:modulexcite,项目名称:CSharpSyntax,代码行数:14,代码来源:SyntaxPrinter.cs


示例13: BindNamedAttributeArgument

        private BoundExpression BindNamedAttributeArgument(AttributeArgumentSyntax namedArgument, NamedTypeSymbol attributeType, DiagnosticBag diagnostics)
        {
            bool wasError;
            LookupResultKind resultKind;
            Symbol namedArgumentNameSymbol = BindNamedAttributeArgumentName(namedArgument, attributeType, diagnostics, out wasError, out resultKind);

            ReportDiagnosticsIfObsolete(diagnostics, namedArgumentNameSymbol, namedArgument, hasBaseReceiver: false);

            Debug.Assert(resultKind == LookupResultKind.Viable || wasError);

            TypeSymbol namedArgumentType;
            if (wasError)
            {
                namedArgumentType = CreateErrorType();  // don't generate cascaded errors.
            }
            else
            {
                namedArgumentType = BindNamedAttributeArgumentType(namedArgument, namedArgumentNameSymbol, attributeType, diagnostics);
            }

            // BindRValue just binds the expression without doing any validation (if its a valid expression for attribute argument).
            // Validation is done later by AttributeExpressionVisitor
            BoundExpression namedArgumentValue = this.BindValue(namedArgument.Expression, diagnostics, BindValueKind.RValue);
            namedArgumentValue = GenerateConversionForAssignment(namedArgumentType, namedArgumentValue, diagnostics);

            // TODO: should we create an entry even if there are binding errors?
            var fieldSymbol = namedArgumentNameSymbol as FieldSymbol;
            IdentifierNameSyntax nameSyntax = namedArgument.NameEquals.Name;
            BoundExpression lvalue;
            if ((object)fieldSymbol != null)
            {
                var containingAssembly = fieldSymbol.ContainingAssembly as SourceAssemblySymbol;

                // We do not want to generate any unassigned field or unreferenced field diagnostics.
                containingAssembly?.NoteFieldAccess(fieldSymbol, read: true, write: true);

                lvalue = new BoundFieldAccess(nameSyntax, null, fieldSymbol, ConstantValue.NotAvailable, resultKind, fieldSymbol.Type);
            }
            else
            {
                var propertySymbol = namedArgumentNameSymbol as PropertySymbol;
                if ((object)propertySymbol != null)
                {
                    lvalue = new BoundPropertyAccess(nameSyntax, null, propertySymbol, resultKind, namedArgumentType);
                }
                else
                {
                    lvalue = BadExpression(nameSyntax, resultKind);
                }
            }

            return new BoundAssignmentOperator(namedArgument, lvalue, namedArgumentValue, namedArgumentType);
        }
开发者ID:RoryVL,项目名称:roslyn,代码行数:53,代码来源:Binder_Attributes.cs


示例14: InferTypeInAttribute

 private IEnumerable<ITypeSymbol> InferTypeInAttribute(AttributeSyntax attribute, int index, AttributeArgumentSyntax argumentOpt = null)
 {
     var info = this.semanticModel.GetSymbolInfo(attribute, cancellationToken);
     var methods = info.GetBestOrAllSymbols().OfType<IMethodSymbol>();
     return InferTypeInAttributeArgument(index, methods, argumentOpt);
 }
开发者ID:jerriclynsjohn,项目名称:roslyn,代码行数:6,代码来源:CSharpTypeInferenceService.TypeInferrer.cs


示例15: BindNamedAttributeArgumentName

 private Symbol BindNamedAttributeArgumentName(AttributeArgumentSyntax namedArgument, NamedTypeSymbol attributeType, DiagnosticBag diagnostics, out bool wasError, out LookupResultKind resultKind)
 {
     var identifierName = namedArgument.NameEquals.Name;
     var name = identifierName.Identifier.ValueText;
     LookupResult result = LookupResult.GetInstance();
     HashSet<DiagnosticInfo> useSiteDiagnostics = null;
     this.LookupMembersWithFallback(result, attributeType, name, 0, ref useSiteDiagnostics);
     diagnostics.Add(identifierName, useSiteDiagnostics);
     Symbol resultSymbol = this.ResultSymbol(result, name, 0, identifierName, diagnostics, false, out wasError);
     resultKind = result.Kind;
     result.Free();
     return resultSymbol;
 }
开发者ID:RoryVL,项目名称:roslyn,代码行数:13,代码来源:Binder_Attributes.cs


示例16: GenerateNameForArgument

		public static string GenerateNameForArgument(
			this SemanticModel semanticModel, AttributeArgumentSyntax argument)
		{
			// If it named argument then we use the name provided.
			if (argument.NameEquals != null)
			{
				return argument.NameEquals.Name.Identifier.ValueText;
			}

			return semanticModel.GenerateNameForExpression(argument.Expression);
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:11,代码来源:SemanticModelExtensions.cs


示例17: VisitAttributeArgument

 /// <summary>
 /// 
 /// </summary>
 /// <param name="node"></param>
 public override sealed void VisitAttributeArgument(AttributeArgumentSyntax node)
 {
     this.OnNodeVisited(node);
     if (!this.traverseRootOnly) base.VisitAttributeArgument(node);
 }
开发者ID:andry-tino,项目名称:Rosetta,代码行数:9,代码来源:MultiPurposeASTWalker.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# AttributeCollection类代码示例发布时间:2022-05-24
下一篇:
C# Attribute类代码示例发布时间: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