コード例 #1
0
        static private bool getParameterInfo(IVsXMLMemberIndex file, string xml, IList <string> names, IList <string> descriptions)
        {
            //Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
            IVsXMLMemberData data = null;
            var result            = file.GetMemberDataFromXML(xml, out data);
            int numparams         = 0;

            if (result >= 0 && data != null)
            {
                result = data.GetParamCount(out numparams);
            }
            if (result >= 0 && numparams != 0)
            {
                string paramName;
                string paramDesc;
                for (int i = 0; i < numparams; i++)
                {
                    result = data.GetParamTextAt(i, out paramName, out paramDesc);
                    names.Add(paramName);
                    paramDesc = CleanUpResult(paramDesc);
                    descriptions.Add(paramDesc);
                }
            }
            return(true);
        }
コード例 #2
0
        public static IVsXMLMemberIndex GetXmlDocFile(Assembly assembly, XProject project)
        {
            IVsXMLMemberIndex index = null;
            var location            = assembly.Location;

            if (!string.IsNullOrWhiteSpace(location))
            {
                if (!_memberIndexes.TryGetValue(location, out index))
                {
                    _XMLMemberIndexService.CreateXMLMemberIndex(location, out index);
                    if (index != null)
                    {
                        _memberIndexes.Add(location, index);
                    }
                }
            }
            if (index == null)  // Sometimes we get a type in the Microsoft.Net folder and not the reference assemblies folder
            {
                string refasm = "";
                foreach (var asm in project.AssemblyReferences)
                {
                    if (asm.FullName == assembly.FullName)
                    {
                        refasm = asm.FileName;
                        break;
                    }
                    if (!string.IsNullOrEmpty(asm.FileName) && asm.FileName.EndsWith("System.DLL", StringComparison.OrdinalIgnoreCase))
                    {
                        if (assembly.FullName.Contains("mscorlib"))
                        {
                            refasm = Path.Combine(Path.GetDirectoryName(asm.FileName), "mscorlib.dll");
                            break;
                        }
                    }
                }

                if (refasm != location && !String.IsNullOrEmpty(refasm))
                {
                    if (!_memberIndexes.TryGetValue(refasm, out index))
                    {
                        _XMLMemberIndexService.CreateXMLMemberIndex(refasm, out index);
                        if (index != null)
                        {
                            if (!String.IsNullOrWhiteSpace(location))
                            {
                                _memberIndexes.Add(location, index);
                            }
                            _memberIndexes.Add(refasm, index);
                        }
                    }
                }
            }

            return(index);
        }
コード例 #3
0
        static XSharpXMLDocTools()
        {
            _XMLMemberIndexService = (IVsXMLMemberIndexService)XSharpProjectPackage.GetGlobalService(typeof(SVsXMLMemberIndexService));
            // create default entry so our own xml lookup will work
            var node        = @"HKEY_LOCAL_MACHINE\Software\XSharpBV\XSharp";
            var InstallPath = (string)Microsoft.Win32.Registry.GetValue(node, "XSharpPath", "");
            var assemblies  = Path.Combine(InstallPath, "Assemblies");
            var location    = Path.Combine(assemblies, "XSharp.Core.dll");
            IVsXMLMemberIndex index;

            _XMLMemberIndexService.CreateXMLMemberIndex(location, out index);
            if (index != null)
            {
                _memberIndexes.Add(location, index);
                coreLoc   = location;
                coreIndex = index;
            }
        }
コード例 #4
0
        static private string getSummary(IVsXMLMemberIndex file, string xml, out string returns, out string remarks)
        {
            string summary = "";

            returns = remarks = "";
            IVsXMLMemberData data = null;
            var result            = file.GetMemberDataFromXML(xml, out data);

            if (result >= 0 && data != null)
            {
                result = data.GetSummaryText(out summary);
                result = data.GetReturnsText(out returns);
                result = data.GetRemarksText(out remarks);
            }
            summary = CleanUpResult(summary);
            returns = CleanUpResult(returns);
            remarks = CleanUpResult(remarks);
            return(summary);
        }
コード例 #5
0
        private static async Task LoadCoreDllAsync()
        {
            var node = IntPtr.Size == 8 ? Constants.RegistryKey64 : Constants.RegistryKey;

            node = "HKEY_LOCAL_MACHINE\\" + node;
            var InstallPath = (string)Microsoft.Win32.Registry.GetValue(node, "XSharpPath", "");
            var assemblies  = Path.Combine(InstallPath, "Assemblies");

            coreLoc   = Path.Combine(assemblies, "XSharp.Core.dll");
            coreIndex = null;
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            _XMLMemberIndexService.CreateXMLMemberIndex(coreLoc, out IVsXMLMemberIndex index);
            if (index != null)
            {
                _memberIndexes.Add(coreLoc, index);
                coreIndex = index;
            }
            return;
        }
コード例 #6
0
        async static Task <int> InitXML()
        {
            var lang = XSharpProjectPackage.Instance;

            _XMLMemberIndexService = (IVsXMLMemberIndexService)await lang.GetServiceAsync(typeof(SVsXMLMemberIndexService));

            // create default entry so our own xml lookup will work
            var node        = @"HKEY_LOCAL_MACHINE\Software\XSharpBV\XSharp";
            var InstallPath = (string)Microsoft.Win32.Registry.GetValue(node, "XSharpPath", "");
            var assemblies  = Path.Combine(InstallPath, "Assemblies");
            var location    = Path.Combine(assemblies, "XSharp.Core.dll");
            IVsXMLMemberIndex index;

            _XMLMemberIndexService.CreateXMLMemberIndex(location, out index);
            if (index != null)
            {
                _memberIndexes.Add(location, index);
                coreLoc   = location;
                coreIndex = index;
            }
            return(0);
        }
コード例 #7
0
        static public string GetMemberSummary(IXMember member, XProject project, out string returns, out string remarks)
        {
            string summary = null;

            returns = remarks = "";
            if (member == null)
            {
                return("");
            }

            //
            if (member is XMemberDefinition)
            {
                var xdef  = (XMemberDefinition)member;
                var xml   = xdef.XmlComments;
                var xfile = XSharpXMLDocTools.firstfile;
                if (xfile != null && !string.IsNullOrEmpty(xml))
                {
                    summary = getSummary(xfile, xml, out returns, out remarks);
                }
                return(summary);
            }
            if (!(member is XMemberReference))
            {
                return("");
            }

            var xmember             = (XMemberReference)member;
            var declarationAssembly = xmember.Assembly;

            //
            var file = XSharpXMLDocTools.GetXmlDocFile(declarationAssembly, project);

            if (file == null)
            {
                return(null);
            }
            lastfile = file;
            var sig = xmember.XMLSignature;

            try
            {
                if (!string.IsNullOrEmpty(sig))
                {
                    uint   id     = 0;
                    string xml    = "";
                    var    result = file.ParseMemberSignature(sig, out id);

                    result = file.GetMemberXML(id, out xml);
                    if (!string.IsNullOrEmpty(xml))
                    {
                        summary = getSummary(file, xml, out returns, out remarks);
                    }
                }
            }
            catch (Exception e)
            {
                XSharpProjectPackage.Instance.DisplayOutPutMessage("Exception in XSharpXMLDocMember.GetDocSummary");
                XSharpProjectPackage.Instance.DisplayException(e);
            }
            //
            return(summary);
        }