From 5d5294ae25c1f7569bd3a7cd894a4ac2b4b99889 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Tue, 13 Jul 2021 11:19:26 +0200 Subject: [PATCH] remove try/catch from types searches --- Crow/src/IML/CompilerServices.cs | 59 ++++++++++++++------------------ 1 file changed, 26 insertions(+), 33 deletions(-) diff --git a/Crow/src/IML/CompilerServices.cs b/Crow/src/IML/CompilerServices.cs index 75248505..4ad57009 100644 --- a/Crow/src/IML/CompilerServices.cs +++ b/Crow/src/IML/CompilerServices.cs @@ -412,29 +412,24 @@ namespace Crow.IML { foundMI = null; if (assembly == null) - return false; - try - { - - foreach (Type t in assembly.GetExportedTypes().Where - (ty => ty.IsDefined (typeof (ExtensionAttribute), false))) { - foreach (MethodInfo mi in t.GetMethods - (BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).Where - (m=> m.Name == methodName && m.IsDefined (typeof (ExtensionAttribute), false) && - m.GetParameters ().Length > 0)) { - Type curType = extendedType; - while (curType != null) { - if (mi.GetParameters () [0].ParameterType == curType) { - foundMI = mi; - return true; - } - curType = curType.BaseType; - } - } - - } - } - catch (System.Exception) {} + return false; + foreach (Type t in assembly.GetExportedTypes().Where + (ty => ty.IsDefined (typeof (ExtensionAttribute), false))) { + foreach (MethodInfo mi in t.GetMethods + (BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).Where + (m=> m.Name == methodName && m.IsDefined (typeof (ExtensionAttribute), false) && + m.GetParameters ().Length > 0)) { + Type curType = extendedType; + while (curType != null) { + if (mi.GetParameters () [0].ParameterType == curType) { + foundMI = mi; + return true; + } + curType = curType.BaseType; + } + } + + } return false; } /// @@ -874,16 +869,14 @@ namespace Crow.IML knownTypes.Add (strDataType, dataType); return dataType; } - foreach (Assembly a in Interface.crowAssemblies) { - try { - foreach (Type expT in a.GetExportedTypes ()) { - if (expT.Name != strDataType && expT.FullName != strDataType) - continue; - if (!knownTypes.ContainsKey(strDataType)) - knownTypes.Add (strDataType, expT); - return expT; - } - }catch{} + foreach (Assembly a in Interface.crowAssemblies) { + foreach (Type expT in a.GetExportedTypes ()) { + if (expT.Name != strDataType && expT.FullName != strDataType) + continue; + if (!knownTypes.ContainsKey(strDataType)) + knownTypes.Add (strDataType, expT); + return expT; + } } knownTypes.Add (strDataType, null); return null; -- 2.47.3