예제 #1
0
        protected virtual void ProcessXml(bool stripResource, bool ignoreResource)
        {
            if (!AllowedAssemblySelector.HasFlag(AllowedAssemblies.AnyAssembly) && _resourceAssembly == null)
            {
                throw new InvalidOperationException("The containing assembly must be specified for XML which is restricted to modifying that assembly only.");
            }

            try {
                XPathNavigator nav = _document.CreateNavigator();

                // Initial structure check - ignore XML document which don't look like linker XML format
                if (!nav.MoveToChild(LinkerElementName, XmlNamespace))
                {
                    return;
                }

                if (_resource != null)
                {
                    if (stripResource)
                    {
                        _context.Annotations.AddResourceToRemove(_resourceAssembly, _resource);
                    }
                    if (ignoreResource)
                    {
                        return;
                    }
                }

                if (!ShouldProcessElement(nav))
                {
                    return;
                }

                ProcessAssemblies(nav.SelectChildren("assembly", ""));

                // For embedded XML, allow not specifying the assembly explicitly in XML.
                if (_resourceAssembly != null)
                {
                    ProcessAssembly(_resourceAssembly, nav, warnOnUnresolvedTypes: true);
                }
            } catch (Exception ex) when(!(ex is LinkerFatalErrorException))
            {
                throw new LinkerFatalErrorException(MessageContainer.CreateErrorMessage($"Error processing '{_xmlDocumentLocation}'", 1013), ex);
            }
        }
예제 #2
0
        protected virtual void ProcessXml(bool ignoreResource)
        {
            if (!AllowedAssemblySelector.HasFlag(AllowedAssemblies.AnyAssembly) && _owningModule == null)
            {
                throw new InvalidOperationException("The containing assembly must be specified for XML which is restricted to modifying that assembly only.");
            }

            try
            {
                XPathNavigator nav = _document.CreateNavigator();

                // Initial structure check - ignore XML document which don't look like linker XML format
                if (!nav.MoveToChild(LinkerElementName, XmlNamespace))
                {
                    return;
                }

                if (_owningModule != null)
                {
                    if (ignoreResource)
                    {
                        return;
                    }
                }

                if (!ShouldProcessElement(nav))
                {
                    return;
                }

                ProcessAssemblies(nav);

                // For embedded XML, allow not specifying the assembly explicitly in XML.
                if (_owningModule != null)
                {
                    ProcessAssembly(_owningModule, nav, warnOnUnresolvedTypes: true);
                }
            }
            catch (Exception ex)
            {
                // throw new LinkerFatalErrorException(MessageContainer.CreateErrorMessage(null, DiagnosticId.ErrorProcessingXmlLocation, _xmlDocumentLocation), ex);
                throw ex;
            }
        }