Skip to content

reflectiontypeloadexception in HestleReflection on recompile #5

Description

@friuns2

reflectiontypeloadexception in HestleReflection on recompile

based on this, i modified HestleReflection.cs

https://stackoverflow.com/questions/7889228/how-to-prevent-reflectiontypeloadexception-when-calling-assembly-gettypes

public static IEnumerable<HasteTuple<T, MethodInfo>> GetAttributesInAssembly<T>(Assembly assembly) {
      var flags = BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Static|BindingFlags.DeclaredOnly;
      Type[] enumerable=null;
      try
      {
        enumerable = assembly.GetTypes();
      }
      catch (ReflectionTypeLoadException e)
      {
        yield break;        
      }
      foreach (var type in enumerable) {
        foreach (var methodInfo in type.GetMethods(flags)) {
          foreach (var attribute in methodInfo.GetCustomAttributes(typeof(T), true)) {
            yield return HasteTuple.Create((T)attribute, methodInfo);
          }
        }
      }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions