public void Open(Microsoft.CodeAnalysis.ISymbol element, bool expandNode = true)
        {
            var url = element.OriginalDefinition.GetDocumentationCommentId();             //AssemblyBrowserWidget.GetIdString (member);

            widget.PublicApiOnly = element.DeclaredAccessibility == Microsoft.CodeAnalysis.Accessibility.Public;
            widget.Open(url, expandNode: expandNode);
        }
示例#2
0
 //note: this method is very careful to check that the generated URLs exist in MonoDoc
 //because if we send nonexistent URLS to MonoDoc, it shows empty pages
 public string GetMonoDocHelpUrl(Microsoft.CodeAnalysis.ISymbol result)
 {
     if (result == null)
     {
         return(null);
     }
     return(result.GetDocumentationCommentId());
 }
        private static void AssertMethodCalliIndex(Microsoft.CodeAnalysis.ISymbol interfaceMethod, int correctIndex)
        {
            var methodSyntax      = interfaceMethod.DeclaringSyntaxReferences[0].GetSyntax();
            var calliCall         = methodSyntax.DescendantNodes().OfType <InvocationExpressionSyntax>().First();
            var nativePtrArgument = calliCall.ArgumentList.Arguments.First().Expression;

            Assert.IsType <IdentifierNameSyntax>(nativePtrArgument);
            var functionPtrArgument = calliCall.ArgumentList.Arguments.Last().Expression;
            var methodIndex         = functionPtrArgument.DescendantNodes().OfType <BracketedArgumentListSyntax>().First();

            Assert.Equal(correctIndex.ToString(), methodIndex.Arguments.Single().ToString());
        }
            static bool IsEmptyPartialMethod(Microsoft.CodeAnalysis.ISymbol member, CancellationToken cancellationToken = default(CancellationToken))
            {
                var method = member as Microsoft.CodeAnalysis.IMethodSymbol;

                if (method == null || method.IsDefinedInMetadata())
                {
                    return(false);
                }
                foreach (var r in method.DeclaringSyntaxReferences)
                {
                    var node = r.GetSyntax(cancellationToken) as Microsoft.CodeAnalysis.CSharp.Syntax.MethodDeclarationSyntax;
                    if (node == null)
                    {
                        continue;
                    }
                    if (node.Body != null || !node.Modifiers.Any(m => m.IsKind(Microsoft.CodeAnalysis.CSharp.SyntaxKind.PartialKeyword)))
                    {
                        return(false);
                    }
                }

                return(true);
            }
示例#5
0
 public static Completion.Glyph GetGlyph(this Microsoft.CodeAnalysis.ISymbol symbol)
 {
     return((Completion.Glyph)Microsoft.CodeAnalysis.Shared.Extensions.ISymbolExtensions2.GetGlyph(symbol));
 }
示例#6
0
 public static AttributeCollection Create(Microsoft.CodeAnalysis.ISymbol symbol)
 {
     return(new AttributeCollection(symbol.GetAttributes().Select(x => new Attribute(x))));
 }
示例#7
0
//
//		public CSharpAmbience () : base ("C#")
//		{
//		}
//
//		static Dictionary<TypeKind, string> classTypes = new Dictionary<TypeKind, string> ();
//
        public override Task <MonoDevelop.Ide.CodeCompletion.TooltipInformation> GetTooltip(CancellationToken token, Microsoft.CodeAnalysis.ISymbol entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }
            return(MonoDevelop.CSharp.Completion.RoslynSymbolCompletionData.CreateTooltipInformation(token, null, null, entity, false, true));
        }
        private static Symbol SymbolFromRoslynSymbol(int offset, Microsoft.CodeAnalysis.SemanticModel semanticModel, Microsoft.CodeAnalysis.ISymbol symbol)
        {
            var result = new Symbol();

            if (symbol is Microsoft.CodeAnalysis.IMethodSymbol methodSymbol)
            {
                result.IsVariadic = methodSymbol.Parameters.LastOrDefault()?.IsParams ?? false;
                result.Kind       = CursorKind.CXXMethod;

                result.Arguments = new List <ParameterSymbol>();

                foreach (var parameter in methodSymbol.Parameters)
                {
                    var argument = new ParameterSymbol();
                    argument.Name = parameter.Name;

                    var info = CheckForStaticExtension.GetReturnType(parameter);

                    if (info.HasValue)
                    {
                        argument.TypeDescription = info.Value.name;
                        argument.IsBuiltInType   = info.Value.inbuilt;
                    }

                    result.Arguments.Add(argument);
                }
            }

            result.Name = symbol.Name;

            var returnTypeInfo = CheckForStaticExtension.GetReturnType(symbol);

            if (returnTypeInfo.HasValue)
            {
                result.ResultType    = returnTypeInfo.Value.name;
                result.IsBuiltInType = returnTypeInfo.Value.inbuilt;
            }

            result.TypeDescription = symbol.Kind == Microsoft.CodeAnalysis.SymbolKind.NamedType ? symbol.ToDisplayString() : symbol.ToMinimalDisplayString(semanticModel, offset);
            var xmlDocumentation = symbol.GetDocumentationCommentXml();

            var docComment = DocumentationComment.From(xmlDocumentation, Environment.NewLine);

            result.BriefComment = docComment.SummaryText;

            return(result);
        }
示例#9
0
 public static bool IsPublic(this Microsoft.CodeAnalysis.ISymbol entity) =>
 entity.DeclaredAccessibility == Microsoft.CodeAnalysis.Accessibility.Protected ||
 entity.DeclaredAccessibility == Microsoft.CodeAnalysis.Accessibility.ProtectedOrInternal ||
 entity.DeclaredAccessibility == Microsoft.CodeAnalysis.Accessibility.Public;
示例#10
0
        public SamplePresenter(Microsoft.CodeAnalysis.ISymbol symbol)
        {
            var asmName = symbol.ContainingAssembly.Name;

            if (asmName == "zarif")
            {
                flagOk = false;
                return;
            }

            var appDTE      = (DTE2)Package.GetGlobalService(typeof(SDTE));
            var curProj     = appDTE.ActiveDocument.ProjectItem.ContainingProject;
            var vsCurProj   = (VSProject)curProj.Object;
            var asmFilePath = vsCurProj.References.OfType <Reference>().FirstOrDefault(r => r.Name == asmName).Path;

            var className    = symbol.ContainingType.ToDisplayString(Microsoft.CodeAnalysis.SymbolDisplayFormat.FullyQualifiedFormat).Replace("global::", "");
            var functionName = symbol.Name;

            var paramTypes = new List <Type>();

            foreach (var parm in ((Microsoft.CodeAnalysis.IMethodSymbol)symbol).Parameters)
            {
                paramTypes.Add(parm.Type.Name.ToString().ToType());
            }


            var objAssembly = Assembly.LoadFrom(asmFilePath);

            ClassType = objAssembly.GetType(className);
            // var ClassCons2 = ClassType.GetConstructors();
            classInstance = ValueSampler.SampleValue(ClassType);
            if (ClassType == null)
            {
                flagOk = false;
                return;
            }

            if (!(ClassType.GetConstructor(Type.EmptyTypes) == null && ClassType.IsAbstract && ClassType.IsSealed))
            {
                if (classInstance == null)
                {
                    if (ClassType.GetConstructor(Type.EmptyTypes) != null)
                    {
                        classInstance = Activator.CreateInstance(ClassType);
                    }
                    else
                    {
                        flagOk = false;
                        return;
                    }
                }
            }

            MI = ClassType.GetMethod(functionName, paramTypes.ToArray());
            if (MI == null)
            {
                flagOk = false;
                return;
            }

            var StyleFilePath  = Path.GetTempPath() + "Style.css";
            var SampleFilePath = Path.GetTempPath() + "present.html";

            if (!File.Exists(StyleFilePath))
            {
                File.WriteAllText(StyleFilePath, Constant.StylePage);
            }

            // -----------Assigning Value---------
            @namespace = ClassType.Namespace;
            if (MI.DeclaringType != null)
            {
                declaringType = "<p><em>DeclaringType: <strong>" + MI.DeclaringType.Name + "</strong></em></p>";
            }

            // remarks = "Remarks of method";
            doc = symbol.GetDocumentationCommentXml();
            var @nameSpaceDot = @namespace + ".";

            @methodname = MI.Name;
            @return     = MI.ReturnType.Name;
            var parInfos = MI.GetParameters();

            var cnt = 1;

            foreach (var pInfo in parInfos)
            {
                @paramsType += pInfo.ParameterType.Name;
                if (parInfos.Count() != cnt)
                {
                    @paramsType += ",";
                }
                cnt += 1;
            }

            if (parInfos.Count() == 0)
            {
                GenerateSamples(1);
            }
            else
            {
                GenerateSamples(3);
            }

            // -----------------------------------
            strPageContent = strPageContent.Replace("@namespace", @namespace).Replace("@declaringType", declaringType).Replace("@methodname", @methodname).Replace("@return", @return);
            strPageContent = strPageContent.Replace("@params", paramsType).Replace("@doc", @doc).Replace("@tRows", @tRows).Replace("@remarks", remarks);
            System.IO.File.WriteAllText(SampleFilePath, strPageContent);
        }