예제 #1
0
        static void InitializeExportedType(ExportedType exportedType, LinkContext context, AssemblyDefinition assembly)
        {
            if (!context.Annotations.IsMarked(exportedType))
            {
                return;
            }

            if (!context.Annotations.TryGetPreservedMembers(exportedType, out TypePreserveMembers members))
            {
                return;
            }

            TypeDefinition type = exportedType.Resolve();

            if (type == null)
            {
                if (!context.IgnoreUnresolved)
                {
                    context.LogError(null, DiagnosticId.ExportedTypeCannotBeResolved, exportedType.Name);
                }

                return;
            }

            context.Annotations.Mark(type, new DependencyInfo(DependencyKind.ExportedType, exportedType), new MessageOrigin(assembly));
            context.Annotations.SetMembersPreserve(type, members);
        }
예제 #2
0
        static void InitializeExportedType(ExportedType exportedType, LinkContext context)
        {
            if (!context.Annotations.IsMarked(exportedType))
            {
                return;
            }

            if (!context.Annotations.TryGetPreservedMembers(exportedType, out TypePreserveMembers members))
            {
                return;
            }

            TypeDefinition type = exportedType.Resolve();

            if (type == null)
            {
                if (!context.IgnoreUnresolved)
                {
                    context.LogError($"Exported type '{exportedType.Name}' cannot be resolved.", 1038);
                }

                return;
            }

            context.Annotations.Mark(type, new DependencyInfo(DependencyKind.ExportedType, exportedType));
            context.Annotations.SetMembersPreserve(type, members);
        }
예제 #3
0
 public static TypeDefinition TryResolve(this ExportedType exportedType)
 {
     try {
         return(exportedType.Resolve());
     } catch (AssemblyResolutionException) { }
     return(null);
 }
예제 #4
0
 void MatchExportedType(ExportedType exportedType, ModuleDefinition module, Regex regex, XPathNavigator nav)
 {
     if (regex.Match(exportedType.FullName).Success)
     {
         MarkingHelpers.MarkExportedType(exportedType, module, new DependencyInfo(DependencyKind.XmlDescriptor, _xmlDocumentLocation));
         TypeDefinition type = exportedType.Resolve();
         if (type != null)
         {
             ProcessType(type, nav);
         }
     }
 }
 void MatchExportedType(ExportedType exportedType, ModuleDefinition module, Regex regex, XPathNavigator nav)
 {
     if (regex.Match(exportedType.FullName).Success)
     {
         MarkingHelpers.MarkExportedType(exportedType, module);
         TypeDefinition type = exportedType.Resolve();
         if (type != null)
         {
             ProcessType(type, nav);
         }
     }
 }
예제 #6
0
 void MatchExportedType(ExportedType exportedType, ModuleDefinition module, Regex regex, XPathNavigator nav)
 {
     if (regex.Match(exportedType.FullName).Success)
     {
         Annotations.Mark(exportedType);
         Annotations.Mark(module);
         var type = exportedType.Resolve();
         if (type != null)
         {
             ProcessType(type, nav);
         }
     }
 }
예제 #7
0
        private static TypeDefinition ResolveRequiredType(this ExportedType exportedType)
        {
            TypeDefinition typeDef;

            try
            {
                typeDef = exportedType.Resolve();
            }
            catch (Exception ex)
            {
                throw new WeavingException($"Could not resolve type {exportedType.FullName}: {ex.Message}");
            }

            return(typeDef ?? throw new WeavingException($"Could not resolve type {exportedType.FullName}"));
        }
예제 #8
0
 void MatchExportedType(ExportedType exportedType, ModuleDefinition module, Regex regex, XPathNavigator nav)
 {
     if (regex.Match(exportedType.FullName).Success)
     {
         Annotations.Mark(exportedType);
         Annotations.Mark(module);
         TypeDefinition type = null;
         try {
             type = exportedType.Resolve();
         }
         catch (AssemblyResolutionException) {
         }
         if (type != null)
         {
             ProcessType(type, nav);
         }
     }
 }
예제 #9
0
 protected virtual TypeDefinition ProcessExportedType(ExportedType exported, AssemblyDefinition assembly) => exported.Resolve();