c# - How to throw exception from a method with generic return type -


while building extension method obtaining value of attributes have following method signature:

public static ienumerable<tvalue> getattributevalues<tattribute, tvalue>(       type type,       string methodname,       type[] parametertypes,       func<tattribute, tvalue> valueselector,       bool inherit = false) tattribute : attribute 

however, during testing i've found cannot usefully throw exception inside method. if throw instance of argumentexception execution process appears ignore it, i.e., exception doesn't bubble up. try... catch in calling method catches nothing.

if call gettype() on result of method call, type presented fully-qualified name of method.

i can't step method while debugging.

can explain why i'm unable stop application exception, if method throw exception?

because extension method returning ienumerable<t> need call toarray or first on otherwise won't enumerate.


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -