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


C# ISymbol.ToString方法代码示例

本文整理汇总了C#中ISymbol.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ISymbol.ToString方法的具体用法?C# ISymbol.ToString怎么用?C# ISymbol.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISymbol的用法示例。


在下文中一共展示了ISymbol.ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetAction

 public IAction GetAction(int stateId, ISymbol symbol)
 {
     try{
         return actionMap[stateId][symbol];
     }
     catch(KeyNotFoundException e){
      Console.WriteLine(stateId+" "+symbol.ToString());
         return null;
     }
 }
开发者ID:kamatanay,项目名称:MayaLanguage,代码行数:10,代码来源:States.cs

示例2: ConvertSymbolToString

        public override string ConvertSymbolToString(int errorCode, ISymbol symbol)
        {
            // show extra info for assembly if possible such as version, public key token etc.
            if (symbol.Kind == SymbolKind.Assembly || symbol.Kind == SymbolKind.Namespace)
            {
                return symbol.ToString();
            }

            return SymbolDisplay.ToDisplayString(symbol, SymbolDisplayFormat.CSharpShortErrorMessageFormat);
        }
开发者ID:MischkowskyM,项目名称:roslyn,代码行数:10,代码来源:MessageProvider.cs

示例3: DetectGivenUpFieldOwnershipInControlFlowGraph

        /// <summary>
        /// Analyses the given control flow graph node to find if it gives up ownership of
        /// data from a machine field.
        /// </summary>
        /// <param name="cfgNode">Control flow graph node</param>
        /// <param name="givesUpNode">Gives up node</param>
        /// <param name="target"Target</param>
        /// <param name="giveUpSource">Give up source</param>
        /// <param name="visited">Already visited cfgNodes</param>
        /// <param name="originalMachine">Original machine</param>
        /// <param name="model">SemanticModel</param>
        /// <param name="log">Log</param>
        private void DetectGivenUpFieldOwnershipInControlFlowGraph(ControlFlowGraphNode cfgNode,
            ControlFlowGraphNode givesUpNode, ISymbol target, InvocationExpressionSyntax giveUpSource,
            HashSet<ControlFlowGraphNode> visited, ClassDeclarationSyntax originalMachine,
            SemanticModel model, Log log)
        {
            if (!cfgNode.IsJumpNode && !cfgNode.IsLoopHeadNode &&
                visited.Contains(givesUpNode))
            {
                foreach (var syntaxNode in cfgNode.SyntaxNodes)
                {
                    var stmt = syntaxNode as StatementSyntax;
                    var localDecl = stmt.DescendantNodesAndSelf().OfType<LocalDeclarationStatementSyntax>().FirstOrDefault();
                    var expr = stmt.DescendantNodesAndSelf().OfType<ExpressionStatementSyntax>().FirstOrDefault();

                    if (localDecl != null)
                    {
                        var varDecl = localDecl.Declaration;
                        foreach (var variable in varDecl.Variables.Where(v => v.Initializer != null))
                        {
                            var rightSymbols = new HashSet<ISymbol>();
                            if (variable.Initializer.Value is IdentifierNameSyntax ||
                                variable.Initializer.Value is MemberAccessExpressionSyntax)
                            {
                                if (DataFlowAnalysis.FlowsIntoTarget(variable, target, syntaxNode, cfgNode,
                                    givesUpNode.SyntaxNodes.First(), givesUpNode, model))
                                {
                                    IdentifierNameSyntax identifier = null;
                                    if (variable.Initializer.Value is IdentifierNameSyntax)
                                    {
                                        identifier = variable.Initializer.Value as IdentifierNameSyntax;
                                    }
                                    else if (variable.Initializer.Value is MemberAccessExpressionSyntax)
                                    {
                                        identifier = this.AnalysisContext.GetFirstNonMachineIdentifier(
                                            variable.Initializer.Value, model);
                                    }

                                    if (identifier != null)
                                    {
                                        var rightSymbol = model.GetSymbolInfo(identifier).Symbol;
                                        rightSymbols.Add(rightSymbol);
                                    }
                                }
                            }
                            else if (variable.Initializer.Value is InvocationExpressionSyntax)
                            {
                                var invocation = variable.Initializer.Value as InvocationExpressionSyntax;
                                log.InsertCall(cfgNode.Summary.Method, invocation);
                                var returnSymbols = this.DetectGivenUpFieldOwnershipInInvocation(
                                    invocation, target, syntaxNode, cfgNode, givesUpNode.SyntaxNodes.First(),
                                    givesUpNode, originalMachine, model, log);

                                if (DataFlowAnalysis.FlowsIntoTarget(variable, target, syntaxNode, cfgNode,
                                    givesUpNode.SyntaxNodes.First(), givesUpNode, model))
                                {
                                    rightSymbols = returnSymbols;
                                }
                            }
                            else if (variable.Initializer.Value is ObjectCreationExpressionSyntax)
                            {
                                var objCreation = variable.Initializer.Value as ObjectCreationExpressionSyntax;
                                log.InsertCall(cfgNode.Summary.Method, objCreation);
                                var returnSymbols = this.DetectGivenUpFieldOwnershipInObjectCreation(
                                    objCreation, target, syntaxNode, cfgNode, givesUpNode.SyntaxNodes.First(),
                                    givesUpNode, model, log);

                                if (DataFlowAnalysis.FlowsIntoTarget(variable, target, syntaxNode, cfgNode,
                                    givesUpNode.SyntaxNodes.First(), givesUpNode, model))
                                {
                                    rightSymbols = returnSymbols;
                                }
                            }

                            foreach (var rightSymbol in rightSymbols)
                            {
                                if (!rightSymbol.Equals(target) && !variable.Initializer.Value.
                                    ToString().Equals(target.ToString()))
                                {
                                    var rightDef = SymbolFinder.FindSourceDefinitionAsync(rightSymbol,
                                        this.AnalysisContext.Solution).Result;
                                    var type = model.GetTypeInfo(variable.Initializer.Value).Type;
                                    if (rightDef != null && rightDef.Kind == SymbolKind.Field &&
                                        this.AnalysisContext.DoesFieldBelongToMachine(rightDef, cfgNode.Summary) &&
                                        !this.AnalysisContext.IsTypeAllowedToBeSend(type) &&
                                        !this.AnalysisContext.IsExprEnum(variable.Initializer.Value, model) &&
                                        !DataFlowAnalysis.DoesResetInSuccessors(rightSymbol,
                                        target, syntaxNode, cfgNode) &&
                                        FieldUsageAnalysis.IsAccessedBeforeBeingReset(rightDef,
//.........这里部分代码省略.........
开发者ID:huangpf,项目名称:PSharp,代码行数:101,代码来源:RespectsOwnershipAnalysis.cs

示例4: WriteDetectedThreadingNamespaceUsage

        internal void WriteDetectedThreadingNamespaceUsage(Enums.ThreadingNamespaceDetected type, string documentPath, ISymbol symbol, SyntaxNode node)
        {
            if (Enums.ThreadingNamespaceDetected.None != type)
            {


                Logger usagelog=null;
                Logger typelog=null;

                switch (type)
                {
                    case Enums.ThreadingNamespaceDetected.ThreadClass:
                        usagelog = Logs.TempLog;
                        typelog = Logs.TempLog2;
                        break;
                    case Enums.ThreadingNamespaceDetected.ThreadpoolClass:
                        usagelog = Logs.TempLog3;
                        typelog = Logs.TempLog4;
                        break;
                    case Enums.ThreadingNamespaceDetected.OtherClass:
                        usagelog = Logs.TempLog5;
                        typelog = Logs.TempLog6;
                        break;
                }

                SyntaxNode block=null;
                var temp = node.Ancestors().OfType<BlockSyntax>();
                if (temp.Any())
                    block = temp.First();
                else
                    block = node.Ancestors().ElementAt(3);

                typelog.Info("{0};{1}", symbol.ContainingType, symbol.ToString());
                usagelog.Info("{0} {1}\r\n{2}\r\n--------------------------", symbol, documentPath,  block);


                //// Let's get rid of all specific information!
                //if (!symbol.ReturnsVoid)
                //    returntype = symbol.ReturnType.OriginalDefinition.ToString();

                //typelog.Info(@"{0};{1};{2};{3};{4};{5};{6};{7}", AppName, documentPath, type.ToString(), returntype, symbol.OriginalDefinition.ContainingNamespace, symbol.OriginalDefinition.ContainingType, symbol.OriginalDefinition.Name, ((MethodSymbol)symbol.OriginalDefinition).Parameters);
            }
        }
开发者ID:modulexcite,项目名称:concurrent-code-analyses,代码行数:43,代码来源:TaskifierAnalysisResult.cs

示例5: PrettyPrint

 private void PrettyPrint(ISymbol symbol)
 {
     string tabs = new string('\t', tabCount);
     Console.WriteLine(tabs + symbol.ToString());
 }
开发者ID:JoshVarty,项目名称:RoslynPad,代码行数:5,代码来源:NamedTypeVisitor.cs


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