From a .net core lib I am consuming a legacy lib written in .net 3.5. I am configuring some mappings with classes that live in that lib. Some of these classes are exposing some non-static public methods that returns or receives as arguments non-compatible types with .net core (types residing in System.Web or System.Web.Services). Even though, I am sure that these methods won't be used from the code I am building, I am getting an error in startup because of the following method that runs when creating internally the type details
private MethodInfo[] BuildPublicNoArgMethods()
{
return Type.GetAllMethods()
.Where(mi => mi.IsPublic && !mi.IsStatic && mi.DeclaringType != typeof(object))
.Where(m => (m.ReturnType != typeof(void)) && (m.GetParameters().Length == 0))
.ToArray();
}
Since the return or parameter type cannot be loaded, the initialization process stops with a TypeLoadException.
Changing the legacy assembly is not an option because is out of my control. And I am trying to avoid to add a reference to System.Web or System.Web.Services just for the purpose to fool the initialization mapping.
To prevent this issue, it would be great if we could limit what is being scanned during type details creation. I can think of several solutions
- Add new config property
SkipScanPublicNoArgMethods - In this case non-static public methods won't be scanned at all
- Add new config property
IgnoreTypeLoadErrorsInPublicMethods
- Add a new config property
ShouldScanPublicMethod (Func<MethodInfo, bool>)
I think 1) is very simple. Do you think any of these solutions is reasonable?
Please let me know yout thoughts.
From a .net core lib I am consuming a legacy lib written in .net 3.5. I am configuring some mappings with classes that live in that lib. Some of these classes are exposing some non-static public methods that returns or receives as arguments non-compatible types with .net core (types residing in System.Web or System.Web.Services). Even though, I am sure that these methods won't be used from the code I am building, I am getting an error in startup because of the following method that runs when creating internally the type details
Since the return or parameter type cannot be loaded, the initialization process stops with a TypeLoadException.
Changing the legacy assembly is not an option because is out of my control. And I am trying to avoid to add a reference to System.Web or System.Web.Services just for the purpose to fool the initialization mapping.
To prevent this issue, it would be great if we could limit what is being scanned during type details creation. I can think of several solutions
SkipScanPublicNoArgMethods- In this case non-static public methods won't be scanned at allIgnoreTypeLoadErrorsInPublicMethodsShouldScanPublicMethod(Func<MethodInfo, bool>)I think 1) is very simple. Do you think any of these solutions is reasonable?
Please let me know yout thoughts.