Beispiel #1
0
        private static DocumentationCache ReadDocumentation(string documentationLocation)
        {
            XmlDocumentationReader      reader        = new XmlDocumentationReader();
            Dictionary <string, string> map           = reader.ReadDocumentation(documentationLocation);
            DocumentationCache          documentation = new DocumentationCache(map, documentationLocation);

            return(documentation);
        }
Beispiel #2
0
        /// <summary>
        /// Retrieves the documentation string for <paramref name="member"/>.
        /// </summary>
        /// <param name="member">The member that is documented.</param>
        /// <returns>Returns the string of the documentation. If no documentation was found for <paramref name="member"/> returns null.</returns>
        public static string GetDocumentationForMember(IMemberDefinition member)
        {
            DocumentationCache cache = GetDocumentationCache(member);

            if (cache == null)
            {
                return(null);
            }
            return(cache.GetDocumentationForMember(member));
        }
        private static DocumentationCache GetDocumentationCache(ModuleDefinition module)
        {
            if (DocumentationManager.IsCachedModule(module))
            {
                return(DocumentationManager.cachedDocumentation);
            }
            V_0 = DocumentationManager.locker;
            V_1 = false;
            try
            {
                Monitor.Enter(V_0, ref V_1);
                if (!DocumentationManager.IsCachedModule(module))
                {
                    if (!XmlDocumentationResolver.TryResolveDocumentationLocation(module, out V_2))
                    {
                        DocumentationManager.cachedDocumentation = null;
                        DocumentationManager.cachedXmlFile       = null;
                    }
                    else
                    {
                        if (!String.op_Inequality(DocumentationManager.cachedXmlFile, V_2))
                        {
                            V_3 = DocumentationManager.cachedDocumentation;
                            goto Label1;
                        }
                        else
                        {
                            DocumentationManager.cachedDocumentation = DocumentationManager.ReadDocumentation(V_2);
                            DocumentationManager.cachedXmlFile       = V_2;
                        }
                    }
                    DocumentationManager.CacheModule(module);
                    goto Label0;
                }
                else
                {
                    V_3 = DocumentationManager.cachedDocumentation;
                }
            }
            finally
            {
                if (V_1)
                {
                    Monitor.Exit(V_0);
                }
            }
Label1:
            return(V_3);

Label0:
            return(DocumentationManager.cachedDocumentation);
        }
Beispiel #4
0
        private static DocumentationCache GetDocumentationCache(ModuleDefinition module)
        {
            if (IsCachedModule(module))
            {
                return(cachedDocumentation);
            }


            lock (locker)
            {
                if (IsCachedModule(module))
                {
                    return(cachedDocumentation);
                }

                string filePath;
                bool   hasDocumentation = XmlDocumentationResolver.TryResolveDocumentationLocation(module, out filePath);
                if (hasDocumentation)
                {
                    if (cachedXmlFile != filePath)
                    {
                        cachedDocumentation = ReadDocumentation(filePath);
                        cachedXmlFile       = filePath;
                    }
                    else
                    {
                        // This can be the case if two different assemblies share the same documentation file and are decompiled in sequence.
                        // For instance PresentationFramework.dll form 32 and 64 bit .NET folders.
                        return(cachedDocumentation);
                    }
                }
                else
                {
                    cachedDocumentation = null;
                    cachedXmlFile       = null;
                }
                CacheModule(module);
            }
            return(cachedDocumentation);
        }
Beispiel #5
0
        public void TestInitialize()
        {
            var configuration = new Poco2SwiftType
            {
                imports       = new ModuleType[0],
                skiptypes     = new SkipType[0],
                externaltypes = new ExternalType[0],
                enumerations  = new EnumType[0],
                classes       = new ClassType[0],
            };
            var filter        = new NullTypeFilter();
            var documentation = new DocumentationCache();
            var callback      = new NullProxyCallback();

            _proxyUtils = new NullProxyUtils {
                Callback = callback
            };
            _appDomain = new NullAppDomain {
                Utils = _proxyUtils
            };
            _translator = new SwiftTranslator(configuration, filter, documentation, _appDomain);
            _writer     = new NullWriter(configuration);
        }